blob_id stringlengths 40 40 | language stringclasses 1
value | repo_name stringlengths 4 137 | path stringlengths 2 355 | src_encoding stringclasses 31
values | length_bytes int64 11 3.9M | score float64 2.52 5.47 | int_score int64 3 5 | detected_licenses listlengths 0 49 | license_type stringclasses 2
values | text stringlengths 11 3.93M | download_success bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|
45b4ce1ce9c813aea8035769cbfeab23d29d6677 | Ruby | josh-h/curvy-poker | /spec/lib/curvy_poker/hand_spec.rb | UTF-8 | 1,831 | 3.28125 | 3 | [] | no_license | # frozen_string_literal: true
RSpec.describe CurvyPoker::Hand do
context 'when dealing a new hand' do
context '#new' do
it 'handles string argument' do
expect(hand('AATTK')).to be_a CurvyPoker::Hand
end
it 'handles array argument' do
expect(hand(%w[A A T T K])).to be_a CurvyPok... | true |
40ba84f08a97d15e858474afd3f81324e2c1e8a7 | Ruby | kavinderd/hobo | /lib/hobo.rb | UTF-8 | 782 | 2.75 | 3 | [] | no_license | require "pathname"
module Hobo
def self.source_root
@root ||= Pathname.new(File.expand_path("."))
end
end
plugin_load_proc = lambda do |directory|
# We only care about directories
next false if !directory.directory?
# If there is a plugin file in the top-level directory, then load
# that up.
plu... | true |
21ec5c98a767ef8a6e4b94167c595456f2e527f3 | Ruby | oscarpw/arreglos_y_archivos | /D3/calculo_notas2.rb | UTF-8 | 220 | 2.90625 | 3 | [] | no_license | data = open('notas.data').readlines.map{|elem| elem.chomp}
def nota_mas_alta(row)
nota_alta = []
notas = row.split(",").map{|e| e.to_i}.inject(0){|x, i| x >= i ? x : i}
nota_alta.push(notas)
return nota_alta
end
| true |
5d5c0eb2f04f73d4918310ab5fb1ce29b475a81c | Ruby | piogna/robots | /lib/unattackable_enemy_error.rb | UTF-8 | 122 | 2.515625 | 3 | [] | no_license | class UnattackableEnemyError < StandardError
def initialize(message = "That enemy is unattackable")
super
end
end
| true |
12cf793ded80c0676c7275dad7ea2ed15ce976c0 | Ruby | maibarra/graph-up | /scripts/one.rb | UTF-8 | 2,916 | 3.3125 | 3 | [] | no_license | require 'csv'
require 'duration'
require 'json'
class Duration
def to_f
to_i.to_f
end
end
class Record
attr_reader :row
def initialize(row)
@row = row
end
def date
row[:date]
end
def bedtime_at
date + bedtime_at_minutes.minutes
end
def up_at
bedtime_at + bed_duration.to_i.s... | true |
df49217d2ac81c5959d2f46e127b86356a20e27f | Ruby | albertbahia/wdi_june_2014 | /w03/d02/alexander_levine/trainers/lib/trainers_seed.rb | UTF-8 | 504 | 2.78125 | 3 | [] | no_license | require_relative 'trainers'
require 'pry'
trainer_names = %w(Ash Misty Brock Gary Lorelei Bruno Agatha Lance)
trainer_ages = [10,13,15,25,76,32,89,345,21,9001]
trainer_hometown = ['Pallet Town','Saffron City', 'Cerulean City',
'Celadon City', 'Cinnabar Island', 'Fuschia City', 'Goldenrod City']
trainer_array = trai... | true |
7add88bd171103948b81453b9a49f284eae2ec31 | Ruby | romalopes/lawn-mowing-api | /mower.rb | UTF-8 | 645 | 2.625 | 3 | [] | no_license | require 'sinatra'
require 'sinatra/activerecord'
require './environments'
class Mower < ActiveRecord::Base
belongs_to :lawn, dependent: :destroy
validates_presence_of :x, :y, :headings, :commands
validates :x, numericality: { only_integer: true }
validates :y, numericality: { only_integer: true }
validate ... | true |
d2ea1479d8005174c5c31123a84c979f15b529b1 | Ruby | jouissances/sinatra-nested-forms-readme-v-000 | /app.rb | UTF-8 | 819 | 3 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require_relative 'config/environment'
class App < Sinatra::Base
get '/' do
erb :new
end
post '/student' do
@student = Student.new(params[:student])
# Pay attention to the above parameters being passed!
params[:student][:courses].each do |details|
Course.new(de... | true |
5b94147ec2ca1f3cffd687afbe6cf0e543f5bcad | Ruby | clemiraho/ruby | /exo_07_c.rb | UTF-8 | 195 | 2.515625 | 3 | [] | no_license | user_name = gets.chomp
puts user_name
#_a demande juste gentillement prénom
#_b y intégre une invitation avec un chevron
#_c tu te débrouille, à toi de savoir qu'il faut y mettre ton prénom | true |
3a4ef573e3bf625126c27f3363ed04cebdad7e1b | Ruby | athomschke/speakerinnen_liste | /app/services/iso_language.rb | UTF-8 | 429 | 2.765625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
class IsoLanguage
TOP = %w[de el en es fr it nl pl pt ru sv tr].freeze
def self.all
I18n.t(:iso_639_1).invert.sort.to_h.values.map(&:to_s)
end
def self.top_list
all.select { |key| TOP.include?(key) }
end
def self.rest_list
all - TOP
end
def self.all_languag... | true |
b134695bfc7b62274c55e976ee5baf1ff594f7b1 | Ruby | tcrane20/AdvanceWarsEngine | /Advance Wars Edit/Scripts/[248]CO Select.rb | UTF-8 | 9,598 | 2.625 | 3 | [] | no_license | =begin
__________________
CO_Select \_____________________________________________________________
Pretty complicated thing I made here. It's a sprite that can process player
input to do things like as if a scene. This class handles everything regarding
to choosing which CO the player(s) wish to be, both ... | true |
7b55b039f65cc51972b5890f7933fc0cf2ec1847 | Ruby | raspygold/advent_of_code | /2016/03/part2.rb | UTF-8 | 498 | 3.21875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
file_path = File.expand_path("../input", __FILE__)
input = File.readlines(file_path)
valid_triangle_count = 0
parsed_input = input.map do |row|
row.strip.split(/\s+/).map(&:to_i)
end
parsed_input.transpose.each do |triangle_set|
triangle_set.each_slice(3) do |triangle_sides|
triangle_s... | true |
1193103147c15b43856ba7bee75d6f0728365fb8 | Ruby | ramlang/intro-to-programming-with-ruby | /intro_the_basics/bas_ex_3.rb | UTF-8 | 590 | 3.609375 | 4 | [] | no_license | # Make a hash of movie titles and output the years
# my_answer =>
movies = {
:jaws => 1975, # jaws : 1975,
:the_day_after_tomorrow => 2004, # the_day_after_tomorrow: 2004,
:captain_philips => 2013, # captain_philips: 2013
:a_beautiful_mind => 2001, # a_beautfiul_mind: 2001,
... | true |
4421dde61812194149b0f45754a750fefd17c8ba | Ruby | alphagov/transition | /lib/transition/path_or_url.rb | UTF-8 | 637 | 2.703125 | 3 | [
"MIT",
"LicenseRef-scancode-proprietary-license"
] | permissive | module Transition
class PathOrUrl
STARTS_WITH_HTTP_SCHEME = %r{^https?://}
# TLDs for Hosts in transition
TLDS = %w[
.co.uk
.com
.gov.uk
.ie
.info
.mod.uk
.net
.nhs.uk
.org
.org.uk
.police.uk
.tv
].freeze
def self.starts_wit... | true |
ed9592b7f065e5ce84b411926439c440eab5f96d | Ruby | MaryHuynh/ruby-challenges | /nokogiri.rb | UTF-8 | 512 | 3.203125 | 3 | [] | no_license | require "nokogiri"
require "open-uri"
doc = Nokogiri::HTML(open("http://www.marthastewart.com/312598/brick-pressed-sandwich"))
#The ingredients list is an unordered list with the class "components-list"
#search = doc.search("ul")
#You could do a loop to get the text for each ingredient,
#but you get the same output... | true |
d6d2e4139ac7ce403e9841e23e0d50e111029298 | Ruby | b4thestorm/object-calisthenics | /lib/jobseeker_items.rb | UTF-8 | 323 | 3.046875 | 3 | [] | no_license | class JobseekerItems
attr_accessor :jobs
def initialize
@jobs = Jobs.new
@resumes = []
end
def has_resume?(resume)
@resumes.include?(resume)
end
def add_job(job)
@jobs.add(job)
end
def add_resume(resume)
@resumes << resume
end
def my_job?(job)
@jobs.include?(job)
end
e... | true |
44c9e3e1cc1125960987077881d86e1b03f14dd5 | Ruby | leffen/roots2012_tweets | /lib/high_score_card.rb | UTF-8 | 651 | 2.921875 | 3 | [] | no_license | # encoding: utf-8
require 'redis'
class HighScoreCard
attr_accessor :storage,:name
def initialize(storage=nil,name="HighScoreCard")
@name = name
@storage = storage || Redis.new
end
def reset
@storage.del(@name)
end
def score_add(name,score_to_add=1)
@storage.zincrby( @name , score_to_a... | true |
5fb9f351dd3730787ac81e53c93a3c5066115018 | Ruby | etewiah/real_estate_finance | /spec/real_estate_finance_spec.rb | UTF-8 | 8,437 | 2.75 | 3 | [
"MIT"
] | permissive | require "spec_helper"
describe RealEstateFinance do
context "tests methods" do
it "has a version number" do
expect(RealEstateFinance::VERSION).not_to be nil
end
it "tests gross potential income" do
monthly_income = 34000
gpi = RealEstateFinance::GrossPotentialIncome.new(monthly_income)... | true |
9f362c67da737611ace2f5c85a28f01efd18ce1c | Ruby | willnotwish/spa-striders-bookings | /app/validators/events/has_space_validator.rb | UTF-8 | 460 | 2.546875 | 3 | [] | no_license | module Events
class HasSpaceValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
return unless value
unless EventWrapper.new(value).event_has_space?
record.errors[attribute] << (options[:message] || "has no space")
end
end
private
class EventW... | true |
0f302d4a7ca96506b2ed8b413907ada122e690e4 | Ruby | takano-hi/clue | /db/seeds.rb | UTF-8 | 1,234 | 2.921875 | 3 | [] | no_license | require 'csv'
# Heroku の無料版MySQLは1時間に3200クエリという上限があるので、
# 500レコードを一括で入れる
banks = []
CSV.foreach('db/bankdata.csv') do |row|
if row[4].to_i == 1
banks << Bank.new(bank_id: "#{row[0]}", store_id: row[1], name: row[3] ,name_kana: row[2])
end
if banks.count % 500 == 0 && banks.count != 0
Bank.import banks... | true |
1aea3101971d9e1d9d06e146fe1824b5356b3082 | Ruby | xsimov/array_challenge | /lib/oo_solution.rb | UTF-8 | 368 | 3.296875 | 3 | [] | no_license | class Array
def my_flatten
each_with_object([]) do |element, output_array|
do_flatten(element, output_array)
end
end
private
def do_flatten(element, output_array)
if element.is_a?(Array)
element.each do |inner_element|
do_flatten(inner_element, output_array)
end
else
... | true |
abd111b48cf43e23211f4aa68fdc31c440f0ab23 | Ruby | HaopengLiu-1992/leetcode-ruby | /leetcode/728_Self_Dividing_Numbers.rb | UTF-8 | 335 | 3.640625 | 4 | [
"ICU",
"Ruby"
] | permissive | # Leetcode 728
class SelfDividingNumbers
def self_dividing_numbers(left, right)
res = []
(left..right).each { |num| res << num if self_dividing?(num) }
res
end
def self_dividing?(num)
num.to_s.each_char do |s|
digit = s.to_i
return false if digit.zero? || num % digit != 0
end
... | true |
07ed6f2f368265cc8e4734b82901619d429df47b | Ruby | paulovpereira/rubytwh | /ex16.rb | UTF-8 | 909 | 3.625 | 4 | [] | no_license | filename = ARGV.first
script = $0
puts "We're going to erase #{filename}."
puts "If you don't want that, hit CTRL-C (^C)."
puts "If you want that, hit RETURN."
print "? "
STDIN.gets
puts "Opening the file..."
#o mode "w" significa que o arquivo será aberto no modo
#escrita deletando seu conteúdo automaticamente
targ... | true |
1f9d6c203da01dd2da17e2eb29d0e9b6fdc7b447 | Ruby | paulfioravanti/pianoforall | /section03/lesson03/if_i_could_save_time_in_a_bottle.rb | UTF-8 | 792 | 2.6875 | 3 | [
"MIT"
] | permissive | # Section 3 - Lesson 3 - New Chords Cm, Fm, Gm, Db, Eb, Ab
# If I Could Save Time in a Bottle
require "#{Dir.home}/ruby/pianoforall/section03/lesson03/three_beat_bounce"
use_synth :piano
use_bpm 70
in_thread(name: :right_hand) do
three_beat_bounce_treble(:D4, :minor)
three_beat_bounce_treble(:D4, :minor)
three_b... | true |
e5fb1e1451b383d4522b6c0a34fc073f3abc506d | Ruby | corvec/Grab-Bag | /src/gui.rb | UTF-8 | 1,757 | 2.515625 | 3 | [] | no_license | require 'rubygems'
require 'Qt'
# Other Project Files
require_relative 'database'
require_relative 'gui_draw'
require_relative 'gui_records'
require_relative 'gui_npc_lookup'
require_relative 'gui_events'
class GrabBagGUI < Qt::Widget
attr_reader :database
def initialize
super
@database = GrabBagDatabase.new
... | true |
fa88e2dd9d8098e197021a7393d4a6c821a65031 | Ruby | confluentinc/bottledwater-pg | /spec/retrying_proxy.rb | UTF-8 | 1,170 | 2.890625 | 3 | [
"LicenseRef-scancode-warranty-disclaimer",
"Apache-2.0"
] | permissive | # Proxy that retries methods of the proxied object if they throw an exception.
#
# Optionally logs each retry, along with the exception that triggered it.
#
# Mostly intended for retrying operations that are known to intermittently fail,
# such as calls to the Docker API where we've observed sometimes receiving partial... | true |
0147026ed7749e9204206bf6508f644b8ad1c457 | Ruby | leafty/AnimeSmart | /scripts/dir_list.rb | UTF-8 | 526 | 2.84375 | 3 | [] | no_license | # encoding: utf-8
require './os.rb'
class DirList
attr_accessor :dir
def initialize( dir )
@dir = File.absolute_path dir
@dir = @dir.encode "Windows-1252" if OS.windows?
end
def subdirs
if File.directory? @dir
list = []
d = Dir.new @dir
d.each do |file|
path... | true |
5f16051bf9f436d003e132bee4c5ee828d9b6494 | Ruby | gauzeee/lessons | /lesson10/coach.rb | UTF-8 | 287 | 3.34375 | 3 | [] | no_license | class Coach
attr_reader :type, :busy_space
include CompanyName
def initialize(type, space)
@type = type
@space = space
@busy_space = 0
end
def take_space(vol)
@busy_space += vol if vol <= free_space
end
def free_space
@space - @busy_space
end
end
| true |
e9df5efe86f95282081663e83bff52ecd18b1c28 | Ruby | barbarajohnsonATX/oo-email-parser-online-web-sp-000 | /lib/email_parser.rb | UTF-8 | 589 | 3.5625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Build a class EmailParser that accepts a string of unformatted
# emails. The parse method on the class should separate them into
# unique email addresses. The delimiters to support are commas (',')
# or whitespace (' ').
require 'pry'
class EmailParser
attr_accessor :emails
@emails
def initialize(... | true |
1d39cfe0e14ea078767190441ca973fd1907631f | Ruby | acornellier/adventofcode | /2020/22.rb | UTF-8 | 997 | 3.1875 | 3 | [] | no_license | require_relative 'util'
require_relative 'input'
# @example_extension = 'ex1'
groups = str_groups_separated_by_blank_lines(__FILE__)
player_1 = groups[0][1..].map(&:to_i)
player_2 = groups[1][1..].map(&:to_i)
def play(player_1, player_2)
completed_games = Set.new
loop do
card_1 = player_1.shift
card_2 = ... | true |
7c80aaa4aeeaf9f6db4cf2d7b3f787fbff810a31 | Ruby | vizvamitra/watch_counter | /lib/watch_counter/config.rb | UTF-8 | 794 | 2.578125 | 3 | [
"MIT"
] | permissive | module WatchCounter
class Config
DEFAULT = {
storage: {
adapter: 'memory',
stale_interval: 6
},
http_server: {
bind: 'localhost',
port: '4567'
}
}
def initialize options={}
options[:storage] = DEFAULT[:storage].merge!(options[:storage] || {})... | true |
9dc5ab5616b4b3e15b06707b607d9332b57d811b | Ruby | berchev/oreilly-learning-ruby | /book_1/chapter03_conditional_love/timer.rb | UTF-8 | 278 | 3.203125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
def timer( start )
puts "Minutes: " + start.to_s
start_time = Time.now
puts start_time.strftime("Start to_time: %I:%M:%S %p")
start.downto(1) { |i| sleep 60 }
end_time = Time.now
print end_time.strftime("Elapsed time: %I:%M:%S %p")
end
timer 10 | true |
0eb83cf58107919ee27369048a5f78e44cd1f359 | Ruby | Jerok0/simpleparser | /tests/braintest.rb | UTF-8 | 646 | 2.84375 | 3 | [] | no_license | require 'test/unit'
require_relative '../brainfuck.rb'
class Tester < Test::Unit::TestCase
def test1
mybrain = Brainfuck.new
mybrain.newprogram(",.+.+.", "a")
assert_equal(mybrain.parse, "abc")
mybrain.newprogram("+++[->,++.<]", "abc")
assert_equal(mybrain.parse, "cde")
mybrain.newprogram("++... | true |
f1417f7031a147dc6f55f730d0483de9998b3685 | Ruby | steveklabnik/require_relative | /lib/require_relative.rb | UTF-8 | 1,409 | 2.890625 | 3 | [
"WTFPL"
] | permissive | # encoding: utf-8
# This is the source code for require_relative, a Ruby gem that backports that
# particular feature to Ruby 1.8.
#
# Please check out the [README](https://github.com/steveklabnik/require_relative/blob/master/README.md)
# for more information on how to build your own copy of the gem, as well as
# contr... | true |
188eeefabf4eaccbe69b2c13b82bc14f1b385208 | Ruby | JackDrogon/Interesting | /minirake/proto_rake | UTF-8 | 2,388 | 2.609375 | 3 | [] | no_license | #!/usr/bin/env ruby
# require 'ftools'
class Task
TASKS = Hash.new
attr_reader :prerequisites
def initialize(task_name)
@name = task_name
@prerequisites = []
@actions = []
end
def enhance(deps=nil, &block)
@prerequisites |= deps if deps
@actions << block if block_given?
self
end... | true |
37c85c9a526ae25006e0e39a57289e87afd32dfc | Ruby | CodeCoreYVR/class_demos_july_2018 | /ruby_basics/age_of_car.rb | UTF-8 | 213 | 3.96875 | 4 | [] | no_license | print "What year was your car made?\n> "
year = gets.chomp.to_i
if year < 1999
puts "It's very old"
elsif year < 2015
puts "It's old"
elsif year < 2018
puts "It's new"
else
puts "It's from the future"
end | true |
337cece62c0ecc070a39959fa811769972e462e8 | Ruby | briancappello/rails-osm-gis | /app/helpers/application_helper.rb | UTF-8 | 929 | 3.125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Beerware"
] | permissive | SECONDS_PER_HOUR = 60 * 60
SECONDS_PER_DAY = 24 * SECONDS_PER_HOUR
module ApplicationHelper
def page_title(sep = ' | ')
[content_for(:title), 'Sample App'].compact.join(sep)
end
def duration_of_time_in_words(total_seconds)
# make sure we've got an integer
if total_seconds % 1 == 0
total_secon... | true |
a5b26f6db510486dc5f99acb32f8a9d4aae55e4e | Ruby | zekusu0426/master_table | /app/models/user.rb | UTF-8 | 504 | 2.75 | 3 | [] | no_license | class User < ActiveRecord::Base
attr_accessor :month, :day, :year
validate :validate_birthday
validates :emp_id, :name, :birthday, :phone1, :post_number, :address, presence: true
validates :emp_id, uniqueness: true
private
def convert_birthday
begin
self.birthday = Date.new(self.year.to_i, self.mo... | true |
78e1fc68e930f1eeb86b69effa489aa89de0e544 | Ruby | dannyenfp/sinatra-mvc-lab-v-000 | /app.rb | UTF-8 | 306 | 2.5625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require_relative 'config/environment'
class App < Sinatra::Base
get '/' do
erb :user_input
end
post '/piglatinize' do
new_pig_class = PigLatinizer.new
@user_text = params[:user_phrase]
@pig_latin_text = new_pig_class.to_pig_latin(@user_text)
erb :piglatinize
end
end | true |
fbbec84ecf023211bfd800a880466b55fdf03f9a | Ruby | kenchan/competitive_programming | /atcoder/abc307/A.rb | UTF-8 | 149 | 2.828125 | 3 | [] | no_license | # https://atcoder.jp/contests/abc307/tasks/abc307_a
N = gets.to_i
As = gets.split.map(&:to_i)
puts N.times.map {|i|
As[i * 7, 7].sum
}.join(" ")
| true |
b24a47f4657b051d4df00ff89a4cdbdc77cbff60 | Ruby | AntoniaChristensen/Taller_de_integracion_T1 | /app/controllers/seasons_controller.rb | UTF-8 | 1,997 | 2.609375 | 3 | [] | no_license | class SeasonsController < ApplicationController
before_action :get_episodios, only: %i[home show]
def home
end
def show
@episodios = {}
if params[:serie] == "BB"
@temp = $temporadas_bb[params[:id]]
if @temp.nil?
redirect_to root_path, alert: 'Season Not Found'
else
@s... | true |
476643fd6b078a07a3da01edb4999d973465211f | Ruby | VuphanMinh/rails_shopping_cart | /app/models/customer.rb | UTF-8 | 1,014 | 2.53125 | 3 | [] | no_license | # == Schema Information
#
# Table name: customers
#
# id :bigint not null, primary key
# address :string
# email :string
# name :string
# password_digest :string
# phone :string
# created_at :datetime not null
# updated_at :datetime... | true |
c6d85a20917da2ec15c4b9c4539e2ccc9d7c0436 | Ruby | bstiber/epicodus | /branching_and_looping/loops2.rb | UTF-8 | 217 | 4.34375 | 4 | [] | no_license | # loops2.rb
#
# removing the last 4 items of an array using pop
array = [1, 2, 3, 4, 5, 6, 7, 7, 8, 9]
array.pop(4)
# adding a number plus itself over and over
number = 0
5.times do
number = number + 5
end
number
| true |
bd97990ab5b63314a59d4f9c9b11e4fa77179eeb | Ruby | Bibilidibipi/matasano-crypto-challenges | /Set2/16_cbc_bitflipping_attacks.rb | UTF-8 | 1,403 | 3.15625 | 3 | [] | no_license | require_relative "./10_implement_cbc_mode"
class UserService2
def initialize
@key = rand_key
@iv = rand_key
end
def create_ciphertext(user_data)
encrypt(profile_str_for(user_data))
end
def parse_ciphertext(code)
parse(decrypt(code))
end
private
attr_accessor :key, :iv
def rand_ke... | true |
b38ced147acec421b59c3f6b507210400e00672b | Ruby | RetynaGirl/food_truck_event_2008 | /lib/food_truck.rb | UTF-8 | 501 | 3.421875 | 3 | [] | no_license | # frozen_string_literal: true
# Food Truck Class
class FoodTruck
attr_reader :name, :inventory
def initialize(name)
@name = name
@inventory = {}
end
def check_stock(item)
@inventory[item] || 0
end
def stock(item, amount)
if @inventory[item]
@inventory[item] += amount
else
... | true |
c6fb7c5c89e54e4030afa56de6c22a337288b6a2 | Ruby | sunclx/supermemomaker | /supermemomaker.rb | UTF-8 | 393 | 2.734375 | 3 | [] | no_license | require './course.rb'
require './block.rb'
course = Course.new
=begin
File.foreach('dates.txt') { |line|
block = SDrapDrop.new.sentence_with_n(line.chomp)
puts block.to_s
Item.new(course).add_to_question(block).write_to_file
}
course.write_to_file
=end
block = SDrapDrop.new.sentence_with_n('I saw that a tiger sat... | true |
7f43e044ad2357bcf5fc60ee3bb1b8c997c35ecf | Ruby | cielavenir/procon | /yukicoder/9xxx/tyama_yukicoder9002.rb | UTF-8 | 128 | 3.21875 | 3 | [
"0BSD"
] | permissive | #!/usr/bin/ruby
puts (1..gets.to_i).map{|i|
if i%15==0
:FizzBuzz
elsif i%3==0
:Fizz
elsif i%5==0
:Buzz
else
i
end
} | true |
ba96f64a4ec6372f195e86e6a58bb2e0987c88d5 | Ruby | achman1729/ruby_revision | /exercise3.rb | UTF-8 | 1,074 | 4.96875 | 5 | [] | no_license | # Make a class for creating cars. Give the class an initialising method that takes two arguments, a make, and a colour, and that then initialises two attributes of the same name. Make the colour attribute read and write accessible, and the make the other attribute only read accessible. Give this class an instance metho... | true |
285d34a008005f97755cc562862bc771416fd69c | Ruby | javier-aguilar/brownfield-of-dreams | /app/models/github.rb | UTF-8 | 530 | 2.5625 | 3 | [] | no_license | module Github
def self.repos(token)
data = GithubService.new(token).list_repos.take(5)
data.map { |repo| Repo.new(repo[:name], repo[:html_url]) }
end
def self.followers(token)
data = GithubService.new(token).list_followers
data.map do |user|
Github::User.new(user[:id], user[:login], user[:h... | true |
30ba243ca3a1d08e83d6dd26e319fed0a6511026 | Ruby | milewdev/tchart | /lib/tchart/process/layout_builder.rb | UTF-8 | 4,492 | 3.15625 | 3 | [
"MIT"
] | permissive | module TChart
#
# Responsible for calculating chart metrics and storing them
# in an instance of Layout. Metrics depend on chart settings
# and the number and dates ranges of the items being plotted.
#
class LayoutBuilder
def self.build(settings, items) # => [ layout, errors ]
layout = bui... | true |
cadeae9fa0313e3dd3e8dd387cd9e50d80f68d0a | Ruby | tuliang/ruby-markdown | /lib/parser.rb | UTF-8 | 2,709 | 3.796875 | 4 | [] | no_license | class Parser
attr_accessor :ast
def initialize(queue)
@queue = queue
@ast = ast_runner
end
def ast_runner
index = 0
ast = []
# 遍历队列
while @queue.length > index do
token = @queue[index]
case token.type
when :h1, :h2, :h3, :h4, :h5, :h6
node = ASTHeading.new(t... | true |
ba5a4b967687a49a4612a2bf087049f619477060 | Ruby | RomanTurner/-Object-Relations-Practice-Code-Challenge-Magazines-Many-Many | /app/models/magazine.rb | UTF-8 | 327 | 2.5625 | 3 | [] | no_license | class Magazine < ActiveRecord::Base
has_many :subscriptions
has_many :readers, through: :subscriptions
def email_list
list = []
self.readers.each do |r|
list << r.email
end
list.join(";")
end
def self.most_popular
self.all.sort_by {|m| m.readers.count}.last
e... | true |
501a197198229209b82954317c7380fe32f4b30b | Ruby | TGohil/Deck-Project | /application.rb | UTF-8 | 373 | 3.234375 | 3 | [] | no_license | require 'yaml'
require 'pry'
#class Deck
#
# def initialize
# file = File.open('satellar.yml')
# @data = YAML::load(file)
# end
#
# def shuf
# puts @data.shuffle![0..5]
# end
#
#end
puts 'Deck: (Type file name with extension)'
decklist = gets.chomp
file = File.open(deckli... | true |
0f3dded067770ba0474b918108589280ed9599c6 | Ruby | francosta/oo-relationships-practice-london-web-career-040119 | /app/models/show.rb | UTF-8 | 331 | 3.109375 | 3 | [] | no_license | class Show
attr_reader :name, :all
@@all = []
def initialize(name)
@name = name
@@all << self
end
def self.all
@@all
end
def on_the_big_screen
if
@@all.map {|show| Movie.all.find {|movie| self.name == movie.name}}.uniq.compact.length == 1
true
else
false
end
... | true |
4106e0f46bceaff93a0bd82592bb585da3e75697 | Ruby | INRokh/rent-my-shelf | /app/models/campaign.rb | UTF-8 | 1,010 | 2.546875 | 3 | [] | no_license | class Campaign < ApplicationRecord
belongs_to :user
has_one :order
has_and_belongs_to_many :spaces
has_and_belongs_to_many :products
validates :title, :size, :start_date, :end_date, :contact_info, :products, presence: true
validate :correct_date_interval?
enum size: {
small: 0,
medium: 1,
... | true |
742b89e91cff5fa2435c3cae74f2b95bfe014513 | Ruby | minnonong/Codecademy_Ruby | /09. Methods, Blocks, & Sorting/09_10.rb | UTF-8 | 390 | 4.4375 | 4 | [] | no_license | # 09_10 How Blocks Differ from Methods
=begin
블록과 메소드의 차이점
- 블록 : 한 번만 호출 가능.
- 메소드 : 여러번 호출 가능.
=end
def capitalize(string)
puts "#{string[0].upcase}#{string[1..-1]}"
end
capitalize("ryan")
capitalize("jane")
["ryan", "jane"].each {|string| puts "#{string[0].upcase}#{string[1..-1]}"} # prints "Ryan",... | true |
b9bc1196dbe408db6b13f078e80c777bd3bfa1ba | Ruby | supertinou/database_theory | /spec/lib/functionnal_dependency_spec.rb | UTF-8 | 937 | 2.5625 | 3 | [
"MIT"
] | permissive | require "spec_helper"
module DatabaseTheory
describe FunctionnalDependency do
it "should have a determinant set" do
fd = FunctionnalDependency.new("A,B,C" , "E,F,J")
fd.determinant.should == ["A","B","C"]
end
it "is not possible its determinant is not set" do
expect { FunctionnalDependency.new() ... | true |
0223274c6a9e999fcdae6943b66349177a683fb9 | Ruby | gkchestertron/ets | /config/initializers/monkeypatches.rb | UTF-8 | 1,015 | 3.203125 | 3 | [] | no_license | class String
def to_msec
msplit = self.split('.')
hms = msplit[0].split(':')
ms = msplit[1].to_i
hours = hms[0].to_i
minutes = hms[1].to_i
seconds = hms[2].to_i
(3600*hours + 60*minutes + seconds) * 1000 + ms
end
end
class Fixnum
def to_ra... | true |
4f3d58a1e145b5a12601ae5a38fcebc0900b36dc | Ruby | dpad22/ruby_OOP | /mathDojo.rb | UTF-8 | 494 | 3.875 | 4 | [] | no_license | class MathDojo
attr_accessor :sum
def initialize
@sum = 0
end
def add (*number)
number.each {|num| @sum += num}
self
end
def subtract (*number)
number.each {|num| @sum -= num}
self
end
def result
puts @sum
self
end
end
ch... | true |
caa91ede342d68c19044f066af4bee912174e12c | Ruby | bitfidget/daily-exercises | /say_exercise.rb | UTF-8 | 426 | 3.265625 | 3 | [] | no_license | require 'numbers_and_words'
I18n.enforce_available_locales = false
print "Please enter a number or q to quit "
input = gets.chomp
while input != 'q'
if input.to_i.between?(1,99)
output = input.to_i.to_words
elsif input == 'q'
exit
else
output = "That number is out of the acceptable range"
end
... | true |
aaa8da24967dba7836302940f127b50bc8e17394 | Ruby | 6eff/toy_robot | /spec/toyrobot_spec.rb | UTF-8 | 1,646 | 3.25 | 3 | [] | no_license | require 'toyrobot.rb'
describe Toyrobot do
context 'toyrobot is placed on tabletop' do
let(:tabletop) { { x_axe: 0..5, y_axe: 0..5 } }
it 'can be palced on tabletop' do
toyrobot = Toyrobot.new
toyrobot.place([1, 2, 'east'], tabletop)
expect(toyrobot.coordinates).to eq [1, 2, 'east']
en... | true |
1702aa60eb8e6767944247fd91a0603e125b6cb1 | Ruby | chenyan19209219/gitlab-ce | /lib/gitlab/git/raw_diff_change.rb | UTF-8 | 2,007 | 2.8125 | 3 | [
"MIT",
"CC-BY-SA-4.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # frozen_string_literal: true
module Gitlab
module Git
# This class behaves like a struct with fields :blob_id, :blob_size, :operation, :old_path, :new_path
# All those fields are (binary) strings or integers
class RawDiffChange
attr_reader :blob_id, :blob_size, :old_path, :new_path, :operation
... | true |
201f9a52fce9605a726235ca17fbc06f55b773a9 | Ruby | damir/humidifier | /lib/humidifier/fn.rb | UTF-8 | 768 | 2.5625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Humidifier
# Builds CFN function calls
class Fn
# The list of all internal functions provided by AWS from
# http://docs.aws.amazon.com
# /AWSCloudFormation/latest/UserGuide/intrinsic-function-reference.html
FUNCTIONS = Utils.underscored(%w[And Base64 Equals Fi... | true |
241664b586ccd6bc585bba4bac4796ec3dcd35a3 | Ruby | atjohnfeng/aa_homework | /W4D3/skeleton/lib/simon.rb | UTF-8 | 1,682 | 3.65625 | 4 | [] | no_license | class Simon
require 'colorize'
COLORS = %w(red blue green yellow)
attr_accessor :sequence_length, :game_over, :seq
def initialize
@sequence_length = 1
@seq = []
@game_over = false
end
def play
until game_over
take_turn
end
game_over_message
reset_game
if play_again
... | true |
84df5e28d6d6765d7c8a53bec1234d334c75ec71 | Ruby | iwabuchiken/CR6_R | /lib/utils.rb | UTF-8 | 16,628 | 2.5625 | 3 | [] | no_license | require "csv"
require "uri"
require "net/http"
require 'zip/zip'
require 'zip/zipfilesystem'
# require 'fileutils'
# @max_line_num = 3000
# This line is needed; otherwise => C:/WORKS/WS/WS_Android/CR6(R)/lib/utils.rb:5:in `<top (required)>': uninitialized constant Const (NameError)
require_dependency 'c... | true |
8e579709cc969d34093916bc9ec7148a9f3552d0 | Ruby | OMYDUDU/projecteuler | /43.rb | UTF-8 | 909 | 4.25 | 4 | [] | no_license | #The number, 1406357289, is a 0 to 9 pandigital number because it is made up of each of the digits 0 to 9 in some order, but it also has a rather interesting sub-string divisibility property.
#Let d1 be the 1st digit, d2 be the 2nd digit, and so on. In this way, we note the following:
#d2d3d4=406 is divisible by 2
#d3d... | true |
13b8316d27809df4049095d866824d736c833c87 | Ruby | heitaiwadate/pubgrate | /pubg.rb | UTF-8 | 1,657 | 2.859375 | 3 | [] | no_license | require 'date'
require 'twitter'
require 'open-uri'
require 'nokogiri'
puts "実行中!"
loop do
d = DateTime.now
hour = d.hour
minut = d.min
second = d.sec
if hour == 0 && minut == 0 && second == 0
sleep(1)
url = "https://dak.gg/profile/cocoaprpr"
charset = nil
html = open(url).read do |f|
... | true |
b60aa211cfdfac62b3666f1e3bff72dc86aa5661 | Ruby | krismacfarlane/godot | /w02/d04/instructor/wdi_the_program/teacher.rb | UTF-8 | 205 | 3.3125 | 3 | [] | no_license | class Teacher < Human
def speak(x)
puts "#{x} (said the teacher in a soothing voice)"
end
def teach(y)
speak(y)
puts "(checks for understanding and redirects if necessary)"
end
end
| true |
3ec9dfdc1c9ff863cf0e4659eb1fcda1495afb4d | Ruby | liaa2/wdi30-homework | /sean_mccusker/homework/week04/07-databases/butterflies/main.rb | UTF-8 | 1,873 | 2.84375 | 3 | [] | no_license | require 'sinatra'
require 'sinatra/reloader'
require 'sqlite3'
get '/' do
erb :home
end
# INDEX - Show all butterflies
get '/butterflies' do
@butterflies = query_db "SELECT * FROM butterflies"
erb :butterflies_index
end
# NEW - Form for adding a new butterfly
get '/butterflies/new' do
erb :butterflies_new
en... | true |
32c27112bc4c4b5296ca21c7b3f40459c302b94f | Ruby | vaishalisharma1994/hello_app | /block1.rb | UTF-8 | 80 | 2.53125 | 3 | [] | no_license | def test
puts "t1"
yield
puts "You"
yield
end
test {puts "You are there"}
| true |
722d77ec1bb15dbc85bed6cd9fdc25430fcedaf8 | Ruby | jdcalvin/ruby_poker | /spec/lib/ruby_poker_spec.rb | UTF-8 | 552 | 2.734375 | 3 | [] | no_license | require 'ruby_poker'
require 'spec_helper'
RSpec.describe ::RubyPoker do
describe '#initilize' do
# write tests checking for valid argument here
end
describe ':two_of_a_kind' do
context 'true' do
it 'when cards have 2 or more of same value' do
expect(described_class.new([1,1,'A',9,4]).tw... | true |
47f2a56d7185a746f8f82ce9942319727245e50d | Ruby | arturocedilloh/LS_101 | /lesson_3/ex_2.rb | UTF-8 | 2,197 | 3.5 | 4 | [] | no_license | # Question 1
puts ages = { "Herman" => 32, "Lily" => 30, "Grandpa" => 402, "Eddie" => 10 }
puts ages.key?("Spot")
puts ages.member?("Spot")
puts ages.include?("Spot")
# Question 2
puts "==================Question 2======================="
puts munsters_description = "The Munsters are creepy in a good way."
puts munste... | true |
fe5e7419a5b7ae84eaff4b6e26a78388b33c76b5 | Ruby | Garllon/link | /link/window.rb | UTF-8 | 1,004 | 2.84375 | 3 | [
"MIT"
] | permissive | module Link
class Window < Gosu::Window
SCREEN_HEIGHT = 700
SCREEN_WIDTH = 700
def initialize
super(SCREEN_HEIGHT, SCREEN_WIDTH, false)
self.caption = 'A Legend of Link'
@player = Player.new(self)
@running = true
@offset = 0
end
def upd... | true |
ad6bb763e7eaf803bd6abb2df3f971e45514b587 | Ruby | kubimtk/KubisRubyMotionSamples | /SpriteAnimator/app/movement.rb | UTF-8 | 695 | 3.4375 | 3 | [
"MIT"
] | permissive |
class LinearMovement
def initialize
speed=10*rand(0)
@dx=speed*rand(0)
@dy=speed*rand(0)
end
def move(x,y,direction_x,direction_y,distance)
[x+@dx*direction_x,y+@dx*direction_y]
end
end
class SinusMovement
N=256
PI=3.14159265358979
def initialize
@dist_2pi=100+2000*rand(0)
@am... | true |
48d16e1016d55fdb84f07df5a32388e15c7525d7 | Ruby | eewang/view_finder | /app/models/gameable.rb | UTF-8 | 854 | 3.109375 | 3 | [] | no_license | module Gameable
# CLASS METHODS
# When a user clicks on an image on the landing page, the application does the following:
# => Searches the photos table for all images within [1000 m] of the target picked by the user
def search(target, radius)
self.near(target, radius)
end
# => Filters out the results that t... | true |
57503fad4330f9a6ada7bd7410888ed30d0aaf1f | Ruby | heyvito/giter8.rb | /lib/giter8/template.rb | UTF-8 | 577 | 2.859375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Giter8
# Template represents a Template variable in an AST. Contains a source file,
# the line and column where the template begins, the variable name to be
# looked up, a set of options, and the parent to which the node belongs to.
class Template
attr_accessor :source,... | true |
a660ab51c7db29902dee06a631ec46750b0e5f58 | Ruby | cunningj/rubyBasicSocket | /client.rb | UTF-8 | 996 | 3.296875 | 3 | [] | no_license | #!/usr/bin/ruby
require 'socket'
# 1. Reads 1024 bytes from /dev/urandom
def getOneKb
# copy stream used with 1024 byte limit as last param
IO.copy_stream('/dev/urandom', ARGV[0], 1024)
end
getOneKb
# 2. Cleans out all non UTF-8 compliant chars
# 3. Replaces all spaces with *
def filterUtf
file = File.open(... | true |
ee385df0e9e3c183f4e7b2b8d269219fe9fd874e | Ruby | laCour/cache | /app/models/transaction.rb | UTF-8 | 904 | 2.53125 | 3 | [
"MIT"
] | permissive | class Transaction < ActiveRecord::Base
include ExpireableTransaction
belongs_to :listing
def new_address
begin
response = BlockIo.get_new_address
address = response['data']['address']
label = response['data']['label']
rescue Exception
raise('Unable to create payment address')
... | true |
3b1bc5affef3e3d94e7a31db65c17bfbeeb7893a | Ruby | eduardopoleo/myflix | /app/decorators/video_decorator.rb | UTF-8 | 238 | 2.65625 | 3 | [] | no_license | class VideoDecorator
attr_reader :video
def initialize(video)
@video = video
end
def show_rating
if video.rating_average
"Rating: #{video.rating_average}/5.0"
else
"No rating available"
end
end
end
| true |
b9fe1791c3fa650d36b5275abcfa277daefd1623 | Ruby | kitallis/pie-man | /plugins/markov.rb | UTF-8 | 1,312 | 3.359375 | 3 | [] | no_license | module PieMan
class Markov
def initialize(file)
@text = Hash.new
read_text(file)
end
def create_paragraph(len)
scan = Array.new(2,"\n")
@words = Array.new
flag = 0
while @words.length <= len || flag == 0
flag = 0
word = random_word(scan)
break ... | true |
a88331beaec06f4d3db675820de95177e08ad6d2 | Ruby | marionavarra/tesienea | /dati/espandi_dizionario_con_flesse.rb | UTF-8 | 644 | 2.71875 | 3 | [] | no_license | file_dizionario_originale = File.open("dizionario_originale.txt", "r")
file_dizionario = File.open("dizionario2.txt", "w")
file_lemmi = File.open("lemmatization-it.txt", "r")
linee_dizionario = file_dizionario_originale.readlines
linee_lemmi = file_lemmi.readlines
linee_dizionario.each do |word_old|
file_dizionario.w... | true |
e6faca36bda18517a416d58ba5383ba80039d3ff | Ruby | Tkam13/atcoder-problems | /abc104/c.rb | UTF-8 | 487 | 2.734375 | 3 | [] | no_license | d,g = gets.chomp.split.map(&:to_i)
ps = d.times.map{gets.chomp.split.map(&:to_i)}
ans = 10**18
(2**d).times do |i|
cnt = 0
sum = 0
idx = 0
d.times do |j|
if i[j] == 1
cnt += ps[j][0]
sum += ps[j][0] * (j+1) * 100 + ps[j][1]
else
idx = j
end
end
if sum >= g
ans = cnt if ans ... | true |
936d308b2da5b517dcc7eb34ad1b0f3db08aa01a | Ruby | Nandini0206/student-directory | /Excercise2.8.rb | UTF-8 | 130 | 2.75 | 3 | [] | no_license | def print_code
file = file.open( $0 , "r")
file.readlines.each do |line|
puts readline
end
file.close
end
print_code
| true |
29b20da24da27645ec11ae25b7d80455b3f83b3c | Ruby | fivepointssolutions/texp | /test/texp/year_interval_test.rb | UTF-8 | 1,677 | 2.6875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require File.expand_path(File.dirname(__FILE__)) + '/../texp_tests'
class YearIntervalTest < Test::Unit::TestCase
def test_year_interval
te = TExp::YearInterval.new(d("Feb 10, 2008"), 3)
assert te.includes?(d("Feb 10, 2008"))
assert ! te.includes?(d("Feb 11, 2008"))
assert ! te.... | true |
b491f499c0d6adb6a7febf3307fccf51c6495516 | Ruby | josephbudina/backend_mod_1_prework | /day_3/exercises/else_and_if.rb | UTF-8 | 1,333 | 4.09375 | 4 | [] | no_license | people = 12
cars = 4980
trucks = 2000
# if cars are greater than or equal to trucks and people are greater than trucks
# print string. Otherwise, if trucks are equal to cars or people or equal to trucks
# print second string. If neither are true print third string
if cars >= trucks && people > trucks
puts "So many v... | true |
431adc89d9fa5881a8d2ed832cc77fbeae502044 | Ruby | shripadjoshi/ConvertPhoneNoToWord | /lib/constants.rb | UTF-8 | 548 | 2.921875 | 3 | [] | no_license | #This class is used for the returning the constants values for the converter,
#in this cas it is returning mapping words and directory data.
class Constant
def self.set_constants
return [
#number to word mappings
{
2 => %w(a b c),
3 => %w(d e f),
4 => %w(g h i),
5 => %... | true |
80ad45c6bf74805861094fa2a166eab53bbc2dc3 | Ruby | Dielerorn/RubyScripts | /GuessTheNumberGame.rb | UTF-8 | 141 | 3.625 | 4 | [] | no_license | #!/usr/bin/ruby
n = rand(1..10)
puts 'Guess the number between 1-10: '
puts 'Wrong! Guess again: ' until gets.to_i == n
puts 'Well guessed!'
| true |
b005ba8eb2e838c751d909ee59c9130dbdaae63b | Ruby | mattfoulger/Robot | /lib/battery.rb | UTF-8 | 124 | 2.515625 | 3 | [] | no_license | class Battery < Item
def initialize
super("Battery", 25)
end
def charge(unit)
unit.charge_shields
end
end
| true |
fba71dd14f52b9896686bc353674106b7e1668d1 | Ruby | realms-ai/rspec_practice | /hello/3/features/step_definitions/greeter_steps.rb | UTF-8 | 601 | 2.5625 | 3 | [] | no_license | #---
# Excerpted from "The RSpec Book",
# published by The Pragmatic Bookshelf.
# Copyrights apply to this code. It may not be used to create training material,
# courses, books, articles, and the like. Contact us if you are in doubt.
# We make no guarantees that this code is fit for any purpose.
# Visit http://www.p... | true |
ecbc6e430175d46c17afc92d7b878c17de35ca25 | Ruby | rsmease/ruby-misc | /prime?.rb | UTF-8 | 783 | 4.09375 | 4 | [] | no_license | def prime?(num)
(2..num/2).none? {|divisor| num % divisor === 0}
end
# puts prime?(6)
def my_take(enum, range=1)
i = range;
until range === 0 do
new_enum = enum.delete_at(0)
puts new_enum
range -= 1
end
end
# puts my_take([1,2,3])
def convert_temp(temp, input_scale:, output_s... | true |
49a0ae9bcd37ac5e2bb69baa7c573e7fc6c6412f | Ruby | optanix/deb-s3 | /lib/deb/s3/lock.rb | UTF-8 | 2,418 | 2.71875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'tempfile'
require 'socket'
require 'etc'
require 'securerandom'
class Deb::S3::Lock
attr_accessor :user
attr_accessor :host
def initialize
@user = nil
@host = nil
end
class << self
def locked?(codename, component = nil, architecture = nil, cache_control =... | true |
e5ad504f4f90c3800b74176780449783bea838e1 | Ruby | krauzer/phase_0_unit_2 | /week_4/3_group_research_methods/my_solution.rb | UTF-8 | 3,893 | 4.4375 | 4 | [] | no_license | # U2.W4: Research Methods
i_want_pets = ["I", "want", 3, "pets", "but", "I", "only", "have", 2]
my_family_pets_ages = {"Evi" => 6, "Hoobie" => 3, "George" => 12, "Bogart" => 4, "Poly" => 4,
"Annabelle" => 0, "Ditto" => 3}
# Person 1's solution
def my_array_finding_method(source, thing_to_find)
list = []... | true |
7e29634c292890d89afaf2ce62a2b4607f69d270 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/leap/830f8e404464469d918195c5ee74afc5.rb | UTF-8 | 108 | 3.171875 | 3 | [] | no_license | class Year
def self.leap?(n)
return (n%4 == 0) &&
((n%100 != 0) || (n%400 == 0))
end
end
| true |
32afff00540bfd958461bc559875bff0d31ff2ab | Ruby | darshan405/ruby_questions_set_1 | /questions/4.rb | UTF-8 | 133 | 3.390625 | 3 | [] | no_license | #Print 15 times the string "Qwinix".
# i = 0
# loop do
# i+= 1
# print "Qwinix\n"
# break if i >=15
# end
15.times { puts "qwinix"} | true |
cf1c57b623ef675385dc679962fcc5b67d629c4f | Ruby | shahwarspall/my-each-online-web-pt-110419 | /my_each.rb | UTF-8 | 128 | 3.21875 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def my_each(collection)
i=0
while i < collection.length
yield(collection[i])
i=i+1
end
collection
end | true |
08a4e0e76d3e4548fbb4880393a748ca5f58dce2 | Ruby | labradorescence/nyc-dumbo-web-120919 | /35-rails-api-review/seeds.rb | UTF-8 | 442 | 2.703125 | 3 | [] | no_license | # copy words from db.json to array and use this
words.each do |word_hash|
# for each word, create a definition
word = Word.create(word_hash.except(:id, :definitions)) # .except in Rails will return a hash without the specified keys
word_hash[:definitions].each do |definition_hash|
# for each definition on ... | true |
3289ae6c7e3209bdccd25e6f429e5137bd068ef7 | Ruby | changmason/id_maker | /lib/id_maker.rb | UTF-8 | 1,232 | 3.046875 | 3 | [] | no_license |
module IdMaker
AREA = {
"A" => "臺北市", "B" => "臺中市", "C" => "基隆市", "D" => "臺南市",
"E" => "高雄市", "F" => "新北市", "G" => "宜蘭縣", "H" => "桃園縣",
"I" => "嘉義市", "J" => "新竹縣", "K" => "苗栗縣", "M" => "南投縣",
"N" => "彰化縣", "O" => "新竹市", "P" => "雲林縣", "Q" => "嘉義縣",
"T" => "屏東縣", "U" => "花蓮縣", "V" => "臺東縣", "W" =... | true |
51e3ac9c63b5204b964db70106fb95e4fda02972 | Ruby | aqdas95/rails-test | /spec/models/order_spec.rb | UTF-8 | 1,350 | 2.5625 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe Order, type: :model do
it "validates that the amount > 0, coin in ['ETH', 'ADA', 'XLM'] and one of extra1 or extra2 must be provided (extra1 provided)" do
order = Order.new(coin: "ADA",amount: 12.3456789012345678, extra1: "either this field")
expect(order).to be_valid
... | true |
a894da551335d2bd0ebf6f11369ec967494a5f58 | Ruby | esellers25/nyc-web-031522 | /27-many-to-many/run.rb | UTF-8 | 647 | 3.203125 | 3 | [] | no_license | require "pry"
require_relative "models/ride"
require_relative "models/passenger"
require_relative "models/driver"
erin = Driver.new("Erin", 4)
danny = Driver.new("danny", 5)
adam = Driver.new("adam", 3)
jon = Driver.new("jon", 4)
geddy = Passenger.new("Geddy", 5)
sabella = Passenger.new("Isabella", 4)
rianna = Passen... | true |
1947fffe6975b62ff3d7e1ca45453241a49b823e | Ruby | fousa/trump | /bin/trump | UTF-8 | 287 | 2.65625 | 3 | [
"MIT"
] | permissive | #! /usr/bin/ruby
require "thor"
require "trump"
class TrumpCommand < Thor
default_command :add
desc "add [NAME]", "Add the last version of the gem to the Gemfile with all the extra data supplied."
def add(name)
Trump::Base.add(name)
end
end
TrumpCommand.new.add(ARGV[0])
| true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.