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
00d7a9741e2cf47befc0986efa47af89747d5882
Ruby
willemmanuel/innisfree
/app/controllers/houses_controller.rb
UTF-8
2,922
2.625
3
[ "MIT" ]
permissive
class HousesController < ApplicationController before_action :set_house, only: [:show, :edit, :update, :destroy] before_action :check_admin, except: [:index, :show, :edit, :update] before_action :check_privileges, only: [:edit, :update] before_action :set_most_recent, ony: [:new] # GET /houses # GET /house...
true
0783a61848adae47c6a793a389d3861cd979a0d2
Ruby
vincentpaca/whosthis
/whosthis.rb
UTF-8
4,353
2.71875
3
[]
no_license
require 'nokogiri' require 'open-uri' require 'uri' require 'whois' require 'anemone' class WhosThis @@filtered_mails = ['domaindiscreet', 'domainsbyproxy', 'whois', 'domains'] @@regex = Regexp.new(/\b[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}\b/) def initialize #get inputs puts "...
true
d657d71c0722c6e6395a21b65a2de96e15f4f5bb
Ruby
andyprickett/launch-school
/exercises/101-109-small-problems/easy-1/07_stringy_strings.rb
UTF-8
439
3.78125
4
[]
no_license
def stringy(n, first=1) string = [] while n > 0 if n.odd? string.unshift(first) else string.unshift((first - 1).abs) end n -= 1 end # OR # n.times do |i| # s = i.even? ? 1 : 0 # string << s # end string.join end puts stringy(6) == '101010' puts stringy(9) == '101010101...
true
9b897987ead561126944f4398fbd9d88eaa4fd66
Ruby
daelynj/poker_hands
/lib/poker_hands/hand_rankings/find_straight.rb
UTF-8
758
3.109375
3
[ "MIT" ]
permissive
require 'poker_hands/hand_rankings/hand_entities/straight' module PokerHands class FindStraight def call(hand) sorted_hand = hand.sort_by { |card| card.rank } if sorted_hand[-1].rank == 14 && sorted_hand[-2].rank == 5 wheel = sorted_hand.clone wheel.pop high_card = wheel.las...
true
98c2529485e8eac177452e5aea20aa7ee35255ba
Ruby
lucasdonuts/hangman
/lib/hangman.rb
UTF-8
3,523
3.90625
4
[]
no_license
require_relative 'word.rb' require_relative 'noose.rb' def get_dictionary file = File.open("dictionary.txt") dictionary = file.read.split("\r\n") dictionary = dictionary.delete_if { |word| word.length > 12 || word.length < 5 } end class Hangman attr_accessor :word, :chances, :letters_guessed def initiali...
true
c1a12e62e44b526db203529a2b638a2d24f1d44c
Ruby
zlang19/sortingAlgorithms
/selectionSort.rb
UTF-8
297
3.265625
3
[]
no_license
def selection_sort(arr = Array.new) (0..arr.length - 2).each do |i| lowestIndex = i (i + 1..arr.length - 1).each do |other| if arr[lowestIndex] > arr[other] lowestIndex = other end end arr[i], arr[lowestIndex] = arr[lowestIndex], arr[i] end return arr end
true
3258728b1da58acf2aaa3718020aa5748db48c7f
Ruby
Tantarium/AmazonAutomationTests
/features/AmazonAutomationTest/step-definitions/shopping_cart_steps.rb
UTF-8
7,220
2.53125
3
[]
no_license
require 'page-object' require 'watir' require_relative '../workflows/navigation' require_relative '../workflows/searching' require_relative '../workflows/shopping_cart' include Navigation include Searching include ShoppingCart And(/^I navigate to a specific item$/) do @amazon.goto_watership_down end When(/^I click...
true
b654b4999835733a5a06eba53174328269465365
Ruby
Hektve87/upcoming-events
/lib/upcoming/country.rb
UTF-8
629
2.53125
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
module Upcoming class Country include Upcoming::Defaults # +country_id+ (Required) # The country_id number of the country to look within. Country ID's are referred to within other API methods, such as metro.getStateList and state.getInfo. To run getInfo on multiple countries, simply pass an array or ...
true
feba3e2c2bb5a9f77d19d3a21329b60525910c5b
Ruby
sridhar61/Tasks
/task69.rb
UTF-8
379
3.578125
4
[]
no_license
class Constant PI=3.14 @@r=2 class << Constant def area puts"The area is :#{PI*@@r*@@r}" end end def perimeter puts"The perimeter is: #{2*PI*@@r}" end end class Secondclass @@r=2 @@a=0.5 def semic puts"The area of the semicircle: #{@@a*Constant::PI*@@r*@@r}" end end obj=Constant.new obj...
true
151def6d24069dc44e32271642bf1e334c31a6e8
Ruby
jhartwell/ironruby
/Tests/Experiments/Misc/Locals.rb
UTF-8
109
3.109375
3
[]
no_license
def foo() b = 123 puts "before eval" eval("a = b;puts a,b") puts "after eval" puts a end foo
true
dbc8a47816d1a2255d4ea9fe3fa962d46eb5b47b
Ruby
Dfletcher1234/dice
/rolls_sorted.rb
UTF-8
188
2.859375
3
[]
no_license
# number = Random.rand(6) results = [] 10.times { results << Random.rand(1..6) + 1 } results.sort! results.each{|result| puts "The result of your roll is #{result}"}
true
c6dac3a5f8bd76809aeccb5fc1ee7c14010c8768
Ruby
Freygarr/disgaea-2-save-editor
/app/models/base_data/plain_string.rb
UTF-8
417
2.765625
3
[ "MIT" ]
permissive
#renaming because Ruby is fucking retarded about figuring out what constants we actually want class BaseData::PlainString < BaseData::Base def self.struct_size; 1; end def disassemble(file_data) self.value = raw_from_file(file_data) end #TODO: Limit string lengths when re-assigned def self.clean_...
true
a3c044d0ff065ca0aa01b892b342bbed9ec0316a
Ruby
makotoyokei/at_coder
/arc113/c_string_invasion.rb
UTF-8
250
3.015625
3
[]
no_license
arr = gets.chomp!.split('') result = 0 l = arr.length (l-2).downto(1) do |i| next if !(arr[i-1] == arr[i] && arr[i-1] != arr[i+1]) result += l - i - 1 - arr[i+1...l].count(arr[i-1]) arr[i+1...l] = Array.new(l-i-1){arr[i-1]} end puts result
true
6108b40cd09fed5ab3cfbfb446b7888f7230dda5
Ruby
dividead/ru8y
/project_euler/21.rb
UTF-8
205
3.28125
3
[]
no_license
def factors(x) (1...x).select {|n| (x % n).zero?}.reduce(:+) end a=[] (2..10000).each do |i| x = factors(i) a<< i unless a.include?(i) if i==factors(x) and i!=x end p a.reduce(:+)
true
e4fc01b239b0abc403b74ff0dd44f5b49536a6bc
Ruby
bellesamways/ruby-exercises
/animal.rb
UTF-8
470
3.890625
4
[]
no_license
class Animal def pular puts 'toim toim toim' end def dormir puts 'zzzzz' end end class Cachorro < Animal def latir puts 'auau' end end cachorro = Cachorro.new cachorro.pular cachorro.dormir cachorro.latir # Cachorro é um objeto que possui todos os comportamentos existentes na classe animal #...
true
f7b3dbf3efa6c20b4d379578ea1915418972d809
Ruby
fazer06/micro-shop
/app/models/customer.rb
UTF-8
1,471
2.71875
3
[]
no_license
# == Schema Information # # Table name: customers # # id :integer not null, primary key # first_name :string # last_name :string # username :string # password :string # email_address :string # created_at :datetime not null # updated_at :datetime not nul...
true
467a22e42249c697d8d567cf20c95eb5acb6e3bf
Ruby
MikeSilvis/espn-scraper
/lib/espn_scraper/schedule/team.rb
UTF-8
3,705
2.65625
3
[]
no_license
module ESPN::Schedule class Team attr_accessor :league, :name def initialize(league, name) self.league = league self.name = name end def self.find(league, team) new(league, team).get_with_cache end def get_with_cache ESPN::Cache.fetch("by_team_#{league}_#{name}", e...
true
6f3412ab6898f0fb9c0f5e7a06464803949634ad
Ruby
johnmarindotco/ruby-codewars
/finddigit.rb
UTF-8
580
3.640625
4
[]
no_license
def find_digit(num, nth) if (nth <= 0) return -1 elsif (nth > num.abs.to_s.length) return 0 else num = num.abs place = nth - 1 arr = num.to_s.split('').map(&:to_i).reverse return arr[place] end end # Complete the function that takes two numbers as input, num and nth and return the...
true
4b21d074958365ca267b4cef293a90d289a598f6
Ruby
lpenzey/battle_ship
/lib/validation.rb
UTF-8
642
3.640625
4
[]
no_license
class Validation def valid_first_move?(board, x, y) open_space?(board, x, y) end def valid_second_move?(board, x, y, ship) open_space?(board, x, y) && has_neighbor?(board, x, y, ship) end private def open_space?(board, x, y) board[x][y] == 0 end def has_neighbor?(board, x, y, ship) ...
true
8c5881946cc837dc83201c8c51e944d0e39a5118
Ruby
hassanshamim/chess
/lib/pawn.rb
UTF-8
626
3.015625
3
[]
no_license
require_relative 'game_piece.rb' class Pawn < GamePiece def piece_initial 'P' end def valid_attack_coords new_rank = ( color == :white ? rank + 1 : rank - 1 ) coords = [ [file-1, new_rank], [file+1, new_rank] ] coords.select do |file, rank| (0..7).include?(file) and (0..7).include?(rank) ...
true
3e38dcedb94fccf727b88655771f63b076b796cf
Ruby
kiote/Pythagoras
/bin/run_pyth
UTF-8
395
2.75
3
[]
no_license
#!/usr/bin/env ruby $LOAD_PATH << File.expand_path('../../lib', __FILE__) require 'pyth' require 'thor' class RunPyth < Thor default_task :birthday desc :birthday, 'Draw pyth square' def birthday b = ask "your birhtday (dd.mm.yyyy):" say 'Your square:', :green res = Pyth.birthday(b...
true
1bb5b3f3315f1faac5794dfe8bcdbf73dafb1d57
Ruby
Nucc/lucie
/lucie-lib/lib/lucie/command_line_slicer.rb
UTF-8
1,781
3.453125
3
[ "MIT" ]
permissive
module Lucie module Core # Command Line Slicer can split the input string to words. # class CommandLineSlicer # Initializes a CommandLineSlicer object with the input. # # @param line [String] The input that need to be sliced def initialize(line) @line = line.split("") ...
true
225e0290db6e91b94a57b4348c1bb35ed9a52d84
Ruby
hasandeveloper/Programms-and-Data-structures
/School/Round-robin-optimized-code-medium-problems-practice/practice-1/Array1/max_consecutive_1.rb
UTF-8
666
3.4375
3
[]
no_license
# Given a binary array, find the index of 0 to be flipped to get max nor of consecutive 1' only single 0 flip is allowed # i/p:- [0,1,1,1,0,1,0,1,0,1,0,1] def max_con_1(array) s = -1 zero_count = 0 array.push(0) n=0 array.each_with_index do |v,e| if v == 0 zero_count += 1 ...
true
c5623a1664f4bc687db4c95cad724215afccecc4
Ruby
tbreitenfeldt/utopia-agent-microservice
/travelers.rb
UTF-8
3,078
2.65625
3
[]
no_license
require 'jwt' require 'json' require 'mysql2' require 'sequel' begin $DB = Sequel.connect( :adapter => 'mysql2', :host => ENV["DB_HOST"], :port => ENV["DB_PORT"], :database => ENV["DB_NAME"], :user => ENV["DB_USER"], :password => ENV["DB_PASSWORD"]) class Travelers < Sequel:...
true
5b9d1426558accac52e9a52bd501c2288a1183ac
Ruby
JayTeeSF/cmd_notes
/security/patch_servers.rb
UTF-8
1,632
2.625
3
[]
no_license
#!/usr/bin/env ruby class ServerControl SERVERS = [ ... ] # FIXME USER = '...' # FIXME PATCHED = 'not vulnerable' def patched?(server) PATCHED == remote_execute('wget https://dl.dropboxusercontent.com/u/6867373/CVE-2015-0235.c && gcc CVE-2015-0235.c -o CVE-2015-0235 && ./CVE-2015-0235', server).chomp e...
true
0a8936bfa4ea4b2acf94cd5ed61d279382304d36
Ruby
derric-d/todo_list.rb
/listPlay.rb
UTF-8
2,181
3.640625
4
[]
no_license
movies = { Memento: 3, Primer: 4, Ishtar: 1 } puts "What would you like to do?" puts "-- Type 'add' to add a movie." puts "-- Type 'update' to update a movie." puts "-- Type 'display' to display all movies." puts "-- Type 'delete' to delete a movie." choice = gets.chomp.downcase case choice when 'add' puts "W...
true
185fad9b57805645ab79872205733f9850ead35b
Ruby
alex6851/badges-and-schedules-online-web-sp-000
/conference_badges.rb
UTF-8
564
3.875
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def badge_maker(name) "Hello, my name is #{name}." end def batch_badge_creator(list_of_names) badges = [] list_of_names.each {|name| badges << "Hello, my name is #{name}."} badges end def assign_rooms(list_of_names) assignments = [] list_of_names.each_with_index {|name, room| assignments << "Hello, #{...
true
ae73d85869c4e091e5a01185961a3f2f8473c770
Ruby
emadb/playground
/ruby/palindrome.rb
UTF-8
269
3.671875
4
[]
no_license
#!/usr/bin/ruby def run input = STDIN.gets i = 0 j = input.length-2 match = true while match and i < j match = input[i] == input[j] i = i+1 j = j-1 end result = match ? "Y": "N" puts result end STDIN.gets.to_i.times { run }
true
4433cdc6ddea0e4bc3721c56b61ac6f406c4aa95
Ruby
pasha-bolokhov-cs/Udemy
/Ruby/times.rb
UTF-8
201
3.59375
4
[]
no_license
#!/usr/bin/ruby # a number of times 5.times do print ("Hey there!\n") end puts() 1.upto(8) do |k| print (" k = " + k.to_s() + "\n") end puts() 0.step(40,4) { | k | puts( "k = " + k.to_s() ) }
true
7397346506b0e485b34c7141ae7470c407fe7b65
Ruby
yamadaj2/object_orientated_game
/lib/object_orientated_game/characters/character.rb
UTF-8
3,630
3.421875
3
[]
no_license
require_relative '../modules/trash_talk' require_relative '../modules/attack_list' require_relative '../modules/attack_remarks' class Character include AttackList include TrashTalk include AttackRemarks attr_accessor :name, :health_points attr_reader :attack_points def initialize(name, health_points, att...
true
e96578e2a1f5074e1e4ff8cd464ef87b6744892f
Ruby
richwblake/school-domain-onl01-seng-pt-110319
/lib/school.rb
UTF-8
437
3.390625
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class School attr_accessor :roster def initialize( school ) @school = school @roster = {} end def add_student( student_name, student_grade ) if roster[student_grade] == nil roster[student_grade] = [student_name] else roster[student_grade].push( student_name) end end def g...
true
0dfe866e203c16f5eac9c8922645898f7083372a
Ruby
davidSoutarson/tuto_ruby
/tuto-pour-coder/tp_amis_avec.rb
UTF-8
482
3.65625
4
[]
no_license
class Utilisateur attr_accessor :prenom, :amis def est_amis_avec?(prenom) puts"On vas tester si amis avec "+prenom amis.each do |ami| puts "on test sur " + ami.prenom return true if ami.prenom == prenom end return false end end alice = Utilisateur.new alice.prenom = "Alice" bob = ...
true
b04e8b776be4e4c1cc5c15838e3d540b660183be
Ruby
tra38/example_api_library
/lib/customer_profile.rb
UTF-8
1,116
3.03125
3
[]
no_license
require 'net/http' require 'json' require_relative 'http_request' class CustomerProfile attr_reader :age, :income, :zipcode, :propensity, :ranking def initialize(age:, income:, zipcode:) @age = age @income = income @zipcode = zipcode json = acquire_json if json @propensity = json["prop...
true
908b508709cbb76ba85779532716245a701f5af2
Ruby
jcasts/sunshine
/lib/commands/run.rb
UTF-8
3,681
2.96875
3
[ "MIT" ]
permissive
module Sunshine ## # Run one or more sunshine scripts. # # Usage: sunshine run [options] [run_file] ... # # Arguments: # run_file Load a script or app path. Defaults to ./Sunshine # # Options: # -l, --level LEVEL Set trace level. Defaults to info. # -e, --env DEPLOY_ENV ...
true
f2aeab1156a4bc79949a4049c9228a27ea947b7c
Ruby
IF977/SchoolClue
/spec/comparador_spec.rb
UTF-8
747
2.703125
3
[]
no_license
require "rails_helper" describe "#comparestring" do obj = KeeperController.new it "should be defined" do expect {obj.send(:comparestring,"escola do seu joão", "escola municipal do seu joão")}.to_not raise_error end it "returns true when one of the parameters has all its words inside the other" do obj.send(:...
true
0fe0cde792ff847f032073eb9225d17815d343fe
Ruby
Sruthisarav/My-computer-science-journey
/The Odin Project/Ruby Programming/Testing Ruby Code/Enumerables/spec/enumerables_spec.rb
UTF-8
3,337
3.75
4
[]
no_license
require './lib/enumerables.rb' describe Enumerable do describe "#my_all?" do it "returns true if array is empty" do expect([].my_all?{|num| num > 0}).to eql(true) end it "returns false if even one elemnt doesn't meet condition" do expect([1, 5, -1].my_all? {|num| num...
true
8f53aa51d6685274cf38e8272149ef2ff574d6a6
Ruby
aconstandinou/ls-exercises
/101_109_small_problems/easy_1/sum_of_digits.rb
UTF-8
402
3.671875
4
[]
no_license
def sum(num) last_index = num.to_s.length # tells us how many values to sum sum = 0 num_string = num.to_s (0..last_index).each do |idx| sum += num_string[idx].to_i end sum end puts sum(23) == 5 puts sum(496) == 19 puts sum(123_456_789) == 45 # LS answer def sum(number) number.to_s.chars.map(&:to_i)....
true
07b810c573f0116d34a721f19b8595d5064831c6
Ruby
tim0414/ruby_practice
/range_test.rb
UTF-8
1,011
4.125
4
[]
no_license
class Discrete_Point attr_accessor :x, :y #include Comparable def initialize(x,y) @x, @y = x, y end =begin def succ Discrete_Point.new(@x+2, @y+2) end =end def <=> (obj) return 1 if (self.x > obj.x) && (self.y > obj.y) return 0 if (self.x == obj.x) && (self.y...
true
1534f661ea638844d3c0015d096d5584e440bc08
Ruby
joshjeong/phase_0_unit_2
/week_5/9_gps2.1/my_solution.rb
UTF-8
4,181
3.53125
4
[]
no_license
# U2.W5: The Bakery Challenge (GPS 2.1) # Your Names # 1) Lienha Carleton # 2) Josh Jeong # This is the file you should end up editing. def bakery_num(num_of_people, fav_food) my_list = {"pie" => [8,0], "cake" => [6,0], "cookie" => [1,0]} raise ArgumentError.new("You can't make that food") unless my_list.has...
true
1c4e1ce40a4ce07f0535fb862ea2270d59c151bd
Ruby
bbatsov/opalrb.org
/source/javascripts/try_opal.rb
UTF-8
1,970
2.71875
3
[ "MIT" ]
permissive
require 'opal' require 'opal-parser' require 'opal-jquery' DEFAULT_TRY_CODE = <<-RUBY class User attr_accessor :name def initialize(name) @name = name end def admin? @name == 'Admin' end end user = User.new('Bob') puts user puts user.admin? RUBY class TryOpal class Editor def initialize(dom...
true
1e09b61b14df80dc53de20e62bd27b22174ce0f1
Ruby
amitkgupta/adventofcode.com
/2017/day15/part2.rb
UTF-8
435
2.75
3
[]
no_license
a, b = ENV["TEST"] == "true" ? [65, 8921] : [722, 354] judge_a = [] judge_b = [] num_comparisons = 0 num_matches = 0 until num_comparisons == 5_000_000 a = (a * 16807) % 2147483647 b = (b * 48271) % 2147483647 judge_a << a if a % 4 == 0 judge_b << b if b % 8 == 0 unless judge_a.empty? || judge_b.empty? num_co...
true
96543327b898caaf29056f54f4e5f33154be04da
Ruby
AndreasHolmback/190815_livecode
/acronymize/spec/acronymize_spec.rb
UTF-8
765
3
3
[]
no_license
require_relative "../acronymize" describe "#acronymize" do it "returns an empty string when passed an empty string" do actual = acronymize("") expected = "" # passes if `actual == expected` expect(actual).to eq(expected) end it 'returns "FAQ" when passed "frequently asked questions"' do actu...
true
e0833dbfc2ba4c488d2b71bae2f7dc13bf6acd66
Ruby
vishank1997/ruby-practice
/numberguessing.rb
UTF-8
519
3.78125
4
[]
no_license
#ruby puts "welcome to whats my number?" puts "what is your name?" ch=gets.to_s.chomp print "hello"+ ch + "how are you" number = rand(10..20) print number print "ok i have selected my number guess what it is" select=gets.to_i guess=1 until select==number if select<number print "your number is smaller\n tr...
true
802df1e7d565a763b067285d4625bf779d85afe7
Ruby
dantebronto/consensus
/lib/tasks/setup.rake
UTF-8
818
2.875
3
[ "MIT" ]
permissive
namespace :setup do desc "create the admin user" task :admin => :environment do admin = User.first(:conditions => {:permission_level => -1}) if admin puts "Admin user already exists" else puts "This user has the ability to create all other users in the system" login = ask("what should ...
true
8e057bd2f94e5984e9b0ce8f63109b7460e29328
Ruby
m-oka-system/demo_app
/sample11.rb
UTF-8
447
3.8125
4
[]
no_license
class Player attr_accessor :name, :health_point, :attack def initialize @name = "主人公" @health_point = 10 @attack = 3 end def dead(is_dead) if is_dead @name + "は戦闘不能になりました" else @name + "は元気です" end end end p = Player.new puts p.dead(false) puts p.dead(...
true
d4b3a90486dbdb0d7940b4a777e101d7bbf67871
Ruby
mlevine1708/oo-tic-tac-toe-online-web-sp-000
/lib/tic_tac_toe.rb
UTF-8
1,579
3.78125
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class TicTacToe attr_accessor :board def initialize @board = [" ", " ", " ", " ", " ", " ", " ", " ", " "] end end WIN_COMBINATIONS = [ [0,1,2], [3,4,5], [6,7,8], [0,4,8], [2,4,6], [0,3,6], [1,4,7], [2,5,8] ] def play while !over? turn end if won? puts "Congratulations #{winner}!" ...
true
56e23e900f7015c64a989d7104836b15a944055a
Ruby
oknashar/Problem-Solving
/CodeFights Challenges/stringsCrossover.rb
UTF-8
339
2.71875
3
[]
no_license
#link: https://app.codesignal.com/challenge/hbQgkZtYLXHpg7nKR def stringsCrossover(a, r) c = 0 for i in 0..a.size-1 for j in i+1..a.size-1 ok = true for k in 0..r.size-1 ok &&= r[k] == a[i][k] || r[k] == a[j][k] end c += 1 if ok end...
true
b62e3f7de4c3346f083084e09d58034458bc0ca5
Ruby
lebrancconvas/Ruby-Lab
/range.rb
UTF-8
233
3.1875
3
[]
no_license
#(<num1>..<num2>) is mean from range num1 to num2 (include) include_array = (1..10).to_a puts include_array puts "" #(<num1>...<num2>) is mean from range num1 to num2 - 1 (exclude) exclude_array = (1...10).to_a puts exclude_array
true
e7c356218b9410e84369f7561613e30511b1d018
Ruby
wachr/Project-Euler-Programs
/euler-prob-004.rb
UTF-8
788
3.796875
4
[]
no_license
#! euler-prob-004.rb # euler-prob-04.rb # author: Ray Wach # date: 2014-10-02 # info: Program to solve Project Euler problem 4 in Ruby. def palindrome?(arg) if (arg.to_s.reverse == arg.to_s) true else false end end num_digits = ARGV[0].to_i if (ARGV[0].nil?) puts "Usage: #{$0} <num_digits>" exit(1...
true
adb5dfa50e8d7f370db9b0b4a1dc52a456f1f7de
Ruby
fantasygame/watcher
/app/models/tv.rb
UTF-8
1,365
2.53125
3
[]
no_license
class Tv < Resource attr_reader :seasons_summary def self.find(id) loop do begin return build Tmdb::TV.detail(id) rescue => e raise e unless e.message =~ /over the allowed limit/ end end end def seasons(sort: :asc) seasons_since(0, nil, sort: sort) end def se...
true
e338dd604960b14a02e07dd3a9285b575c76902e
Ruby
alphagov/optic14n
/lib/uri/bluri.rb
UTF-8
3,622
2.6875
3
[ "MIT" ]
permissive
module URI ## # A URI class with a bit extra for canonicalising query strings # class BLURI < URI::HTTP PATH_ESCAPE_MAPPINGS = { "[" => "%5b", "]" => "%5d", "," => "%2c", '"' => "%22", "'" => "%27", "|" => "%7c", "!" => "%21", "£" => "%c2%a3", }.freeze ...
true
a0dfb8060846826e9ce5081fce748c5a5a52dc3c
Ruby
hacaravan/boris-bikes-2
/lib/docking_station.rb
UTF-8
564
3.234375
3
[]
no_license
class DockingStation attr_reader :bikes, :capacity, :broken_bikes DEFAULT_CAPACITY = 20 def initialize(capacity = DEFAULT_CAPACITY) @bikes = [] @broken_bikes = [] @capacity = capacity end def release_bike raise "Sorry, no bikes" if empty? bike = bikes[-1] bikes.delete(bike) bike ...
true
0bc37880c71d038e0109200a875cab0bf2b2c771
Ruby
chrisgit/yeoman-generator-sinatra-rack
/generators/app/templates/app/models/product.rb
UTF-8
186
2.53125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
class Product attr_reader :productid, :description, :cost def initialize(args = {}) args.each do |k,v| instance_variable_set("@#{k}", v) unless v.nil? end end end
true
6606b75e062183c5c1b67ff4067abdb8f5b51f47
Ruby
CodingMBA/ls_101_lesson_6
/twenty_one.rb
UTF-8
5,316
3.84375
4
[]
no_license
SUITS = ['H', 'D', 'C', 'S'] VALUES = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A'] GAME = 31 DEALER_STAYS = GAME - 4 def prompt(message) puts "=> #{message}" end def initialize_deck VALUES.product(SUITS).shuffle end def total(cards) # cards = [['H', '3'], ['S', 'Q'], ... ] values = card...
true
319cdcc4d4590ea6e077e9618b0784dce30eb1b7
Ruby
rockdisco/coderbyte
/SecondGreatLow.rb
UTF-8
159
2.96875
3
[]
no_license
def SecondGreatLow(arr) arr = arr.sort.uniq return "#{arr[0]} #{arr[0]}" if arr.length == 1 return "#{arr[1]} #{arr[-2]}" end SecondGreatLow(STDIN.gets)
true
5c97b581a927b6f313f3e8cde480c15e8816d8d6
Ruby
averimj/backend_prework
/day_7/10_little_monkeys_test.rb
UTF-8
938
2.96875
3
[]
no_license
require "minitest/autorun" require "minitest/pride" require "./10_little_monkeys" class LittleMonkeysTest < Minitest::Test def test_it_exist little_monkeys = LittleMonkeys.new assert_instance_of LittleMonkeys, little_monkeys end def test_count_down little_monkeys = LittleMonkeys.new expected =...
true
1a1b05279bbf40aa365beda320d3fd495fe1f78e
Ruby
marcinwal/wealth
/app/models/user.rb
UTF-8
1,188
2.609375
3
[]
no_license
require 'bcrypt' class User include DataMapper::Resource has n, :peeps ,:through => Resource has n, :comments ,:through => Resource property :id, Serial property :name, String property :username, String, :unique => true, :message => "User name is already taken" property :email, String, :unique => true...
true
976ccf3ef7dd0a8863a24dde058efd6034ed4710
Ruby
Dancalif/Learning-Ruby
/TA/HW_23/script_23_01.rb
UTF-8
667
3.25
3
[]
no_license
# Convertion BEGIN{ name = "Denis Umanets" description = "Convertion without slice, using delete, reverse, chop" puts "#################################### " puts "Author \s\s\s\s\s : " + name puts "Date \s\s\s\s\s\s\s\s: " + Time.now.to_s[0 .. 18] puts "" puts "Ruby version ...
true
3e28dbf71fbb3663dc9b5c0d0a669a956cce481c
Ruby
dangalipo/Toyrobotv2
/lib/direction.rb
UTF-8
259
3.015625
3
[]
no_license
# frozen_string_literal: true class Direction attr_reader :name, :move_x, :move_y def initialize(name:, move_x:, move_y:) self.name = name self.move_x = move_x self.move_y = move_y end private attr_writer :name, :move_x, :move_y end
true
89d6dc6b95d1796578149887adbc2190a20a04a6
Ruby
krlenell/rails-demo-app
/tutorials/samples/ex13.rb
UTF-8
224
3.453125
3
[]
no_license
first, second, third = ARGV puts "first variable is #{first}" puts "first second is #{second}" puts "first third is #{third}" puts "what is your birthday? " birthday = $stdin.gets.chomp puts "your birthday is #{birthday}"
true
9a3d7eb0ee0a209d8f80fa6eeb9b16eac2ac238f
Ruby
duxdamian/Pedro_le_scrappeur_fou
/lib/dark_trader.rb
UTF-8
1,537
2.875
3
[]
no_license
require 'pry' require 'dotenv' require 'rubygems' require 'nokogiri' require 'open-uri' # def open_website(url) # page = Nokogiri::HTML(open(url)) # page.class # => Nokogiri::HTML::Document # end def open_website(url) page = Nokogiri::HTML(open(url)) # page.class # => Nokogiri::HTML::Document page end de...
true
0128f43504c6bad4039ff4a7a83e14e44dc671a9
Ruby
GBH/letmein
/test/letmein_test.rb
UTF-8
7,268
2.5625
3
[ "MIT" ]
permissive
require 'test/unit' require 'rails' require 'letmein' require 'sqlite3' $stdout_orig = $stdout $stdout = StringIO.new ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => ':memory:') ActiveRecord::Base.logger = Logger.new($stdout) class User < ActiveRecord::Base ; end class Admin < ActiveRecor...
true
3db507e9213b41b1fc59d15b347568e5c382ecc9
Ruby
ykpythemind/github-deploy-hook
/hook.rb
UTF-8
1,832
2.5625
3
[ "MIT" ]
permissive
require "sinatra" SCRIPT_FILE = (ENV["SCRIPT_FILE"] || "test.sh").freeze SCRIPT_DIR = 'scripts'.freeze if ENV["SCRIPT_PATH"] SCRIPT_PATH = ENV["SCRIPT_PATH"] else SCRIPT_PATH = File.expand_path("../#{SCRIPT_DIR}/#{SCRIPT_FILE}", __FILE__) end abort "SCRIPT_FILE not found" unless File.exist? SCRIPT_PATH LOG_PAT...
true
4d6dba0636f2aab965e314ce1f74c17e8fa90ba2
Ruby
alproddev/portable_light
/vendor/plugins/table_helper/test/unit/header_test.rb
UTF-8
7,023
2.6875
3
[ "MIT" ]
permissive
require File.expand_path(File.dirname(__FILE__) + '/../test_helper') class HeaderByDefaultTest < Test::Unit::TestCase def setup @table = TableHelper::CollectionTable.new([]) @header = TableHelper::Header.new(@table) end def test_should_hide_when_empty assert @header.hide_when_empty end def ...
true
1f3abed04fec9717b56111cf67d26eea3d0e1afc
Ruby
tundal45/project_euler
/2_fib_even_sum.rb
UTF-8
748
4.0625
4
[]
no_license
# Project Euler # Problem # 2 # # Description: Each new term in the Fibonacci sequence is generated by adding # the previous two terms. By starting with 1 and 2, the first 10 # terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... # Find the sum of all the even-valued terms in t...
true
57552cce87c84b8bb07df725d56931f421265795
Ruby
instructure/ims-lti
/spec/ims/lti/models/parameter_spec.rb
UTF-8
4,406
2.53125
3
[ "MIT" ]
permissive
require 'spec_helper' module IMS::LTI::Models describe Parameter do describe '#fixed?' do it 'returns true if the value is fixed' do subject.fixed = 'my_fixed_value' expect(subject.fixed?).to eq true end it 'returns false if the value is variable' do subject.variable ...
true
42427b422692c777ab64f8550344cb891e4b9fad
Ruby
Koda-thp/RPG_Game
/lib/game.rb
UTF-8
5,636
3.78125
4
[]
no_license
#SPECIFICATIONS Class game.rb #Voici ce que tu dois faire dans la classe Game (80 % du travail consiste à rapatrier #du code depuis app_2.rb) : #Crée la classe Game qui aura 2 attr_accessor : un @human_player de type HumanPlayer #et un array @enemies qui contiendra des Player. # ¿WHY? # Cette Classe doit gerer les ...
true
1b98983a9920a0c17b7935dd294bd77c763350ff
Ruby
nstory/boston_public_records
/lib/tocsv.rb
UTF-8
617
2.703125
3
[ "MIT" ]
permissive
require "csv" require "logger" require "pry" require_relative "./page.rb" $logger = Logger.new(STDERR) def to_text(file) `pdftotext -layout "#{file}" -` end def tocsv(filename, field_count, row_regexp) text = to_text(filename) pages = Page.from_text(text) pages.each do |page| rows = page.extract(field_c...
true
b024971f7f4cd30e082e3571c02cb608de6d2d2b
Ruby
HouseTrip/guignol
/lib/guignol/commands/base.rb
UTF-8
1,677
2.59375
3
[ "BSD-2-Clause", "BSD-3-Clause" ]
permissive
require 'thor' require 'pathname' require 'parallel' require 'guignol' require 'guignol/configuration' require 'guignol/models/instance' require 'core_ext/array/collect_key' module Guignol::Commands class Base def initialize(patterns, options = {}) @configs = select_configs(patterns) @options = opti...
true
954dfd6c12c21c3d7c310a83793ef3d5186d754d
Ruby
MathieuGilbert/litecoin-cracker
/word.rb
UTF-8
1,835
3.859375
4
[]
no_license
class Word SUBS = { 'a' => ['@'], 'e' => ['3'], 'g' => ['9'], 'h' => ['#'], 'i' => ['1', '!'], 'l' => ['1', '!'], 'o' => ['0'], 'r' => ['2'], 's' => ['$'], 't' => ['7'] }.freeze attr_accessor :word_array def initialize(the_word) self.word_array = arrayify_letters(th...
true
7054ecd954427b3b7cea6ba4421e6feea42f890e
Ruby
mare-imbrium/umbra
/lib/umbra/table.rb
UTF-8
8,837
2.671875
3
[ "MIT" ]
permissive
# ----------------------------------------------------------------------------- # # File: table.rb # Description: widget for tabular data # Author: j kepler http://github.com/mare-imbrium/umbra/ # Date: 2018-05-06 - 09:56 # License: MIT # Last update: 2018-06-03 14:43 # -------------------...
true
7387d15236a5a0e7c456b23d5fb9226ef8c17c22
Ruby
terchiem/ruby_tictactoe
/tictactoe.rb
UTF-8
3,103
3.609375
4
[]
no_license
module SetSpace def set(i, j, value) if @spaces[i][j].nil? @spaces[i][j] = value return true end false end def clear @spaces = Array.new(3){ Array.new(3) } end end class Board include SetSpace def initialize @spaces = Array.new(3){ Array.new(3) } end def display p...
true
57dad704cdc6a130bd2062ceef1ff250b1aa728d
Ruby
juan-gm/RB101
/lesson_4/practice_problem_1.rb
UTF-8
161
3.140625
3
[]
no_license
flintstones = ["Fred", "Barney", "Wilma", "Betty", "Pebbles", "BamBam"] hsh = {} flintstones.each_with_index do |word, index| hsh[word] = index end puts hsh
true
3f45fbc5730e7a50d58682e57f7e020b9a218ccc
Ruby
jescriba/light_server
/lib/lights/server.rb
UTF-8
671
2.515625
3
[]
no_license
require 'json' require 'pi_piper' module Lights class Server include PiPiper def initialize @row_handler = RowHandler.new end # Process JSON requests from web server def listen(data) ## TODO: Check if needs to be updated by comparing to command history data_table = JSON.parse(...
true
5e94db983556c806049abfbd20b11c05a80d5c6b
Ruby
davesousa/2playergame
/two_player_game.rb
UTF-8
1,209
3.8125
4
[]
no_license
@p1_score = 3 @p2_score = 3 @turn = 2 def lose_1 @p1_score -= 1 end def lose_2 @p2_score -= 1 end def question "what is #{@num1} + #{@num2}" end def answer @answer = @num1 + @num2 end def turn @turn += 1 end def game while @p1_score > 0 and @p2_score > 0 if @turn.even? @num1 = Ran...
true
69c11f5e612182375f0d374ed9a9efbc3a10c51b
Ruby
12ew/collections_practice_vol_2-prework
/collections_practice.rb
UTF-8
2,107
3.453125
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require 'pry' def begins_with_r(array) array.all? do |tool| # binding.pry tool[0] == "r" end end def contain_a(array) my_arr = [] array.each do |element| if element.include?("a") my_arr << element end end my_arr end def first_wa(array) array.each do |word| if word.to_s.inc...
true
935c0b7fcaebfdbc28cbd5215224fa5987383e8c
Ruby
chenyan19209219/gitlab-ce
/lib/gitlab/i18n/metadata_entry.rb
UTF-8
1,037
2.53125
3
[ "MIT", "CC-BY-SA-4.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
# frozen_string_literal: true module Gitlab module I18n class MetadataEntry attr_reader :entry_data # Avoid testing too many plurals if `nplurals` was incorrectly set. # Based on info on https://www.gnu.org/software/gettext/manual/html_node/Plural-forms.html # which mentions special case...
true
b86b9cbad5a96a7ed239fc5eb1ed7cbaa3cd334d
Ruby
shentianyi/warehouse
/RailsClient/app/models/enum/impl_user_type.rb
UTF-8
845
2.796875
3
[ "MIT" ]
permissive
class ImplUserType SENDER = 0 RECEIVER = 1 EXAMINER = 2 REJECTOR = 3 def self.display(type) case type when SENDER '发送人员' when RECEIVER '收货人员' when EXAMINER '质检人员' when REJECTOR '拒收人员' end end def self.display_action(type) case type ...
true
5f65d8d98b5e83ea1e5a1b17431506935ddfe959
Ruby
mandarandriam/ruby-vendredi
/pyramide.rb
UTF-8
349
3.421875
3
[]
no_license
print "Choisissez un nombre entre 1 et 25 et ça va sortir une pyramide à descendre de tant d'étages que ce nombre!!" user_number = Integer(gets.chomp) puts "\n" start = 0 i = "#" while user_number > 0 do espace = " " * (user_number + 1) brique = "#" * (start + 1) user_number -= 1 start += 1 print "#{es...
true
a367d3b48820d94341690b88285544a1fa5176bb
Ruby
aldompe95/beerMe
/app/models/beer_log.rb
UTF-8
350
2.53125
3
[]
no_license
class BeerLog < ApplicationRecord belongs_to :user belongs_to :beer validates :user_id, presence: true validates :quantity, presence: true validates :date, presence: true validate :is_future? def is_future? if date.present? && date > Date.today errors.add(:date, "can't be of the future, are y...
true
14338c6718ba0b5668ad61e5d85f00fc7ef30c17
Ruby
matz/mail
/lib/mail/fields/to_field.rb
UTF-8
1,485
2.859375
3
[ "MIT" ]
permissive
# encoding: utf-8 # # = To Field # # The To field inherits to StructuredField and handles the To: header # field in the email. # # Sending to to a mail message will instantiate a Mail::Field object that # has a ToField as its field type. This includes all Mail::CommonAddress # module instance metods. # # Only one ...
true
1c86cfb393f46bb8ef3efe0dda615e6d38924d32
Ruby
romanobrooks/pointswop
/itemtest.rb
UTF-8
370
3.5
4
[]
no_license
array_test = ["first line","second line","third line"] for item in array_test puts item end $end puts print "This is in normal direction" puts #any value can be used. for doos in array_test print doos end $end puts print "This is in reverese" puts #any value can be used. This is in reverese for s...
true
be8a9415625a15ec00f66a9971e4dce1ec878f48
Ruby
tsg-ut/tsgctf
/crypto/omega/writeup/make_problem.rb
UTF-8
1,748
3.0625
3
[]
no_license
srand(68) UNITS = [[0,1],[0,-1],[1,0],[-1,0],[1,1],[-1,-1]] def to_complex(x) a, b = x w = Math::E ** Complex(0, Math::PI*2.0/3.0) a + b*w end def add(x, y) a, b = x c, d = y [a+c, b+d] end def sub(x, y) a, b = x c, d = y [a-c, b-d] end def scalar(k) [k, 0] end def mul(*xs) r = [1, 0] xs.e...
true
8f86579815fb9048e3e5b34a7f92271cf90d2a1c
Ruby
kikihakiem/geokit
/lib/geokit/geocoders/mapbox.rb
UTF-8
3,181
2.59375
3
[ "MIT" ]
permissive
module Geokit module Geocoders # Mapbox geocoder implementation. Requires the Geokit::Geocoders::MapboxGeocoder:key variable to # contain a Mapbox access token. Conforms to the interface set by the Geocoder class. class MapboxGeocoder < Geocoder config :key self.secure = true private ...
true
280b100a25bea30db5c1934ac056d8cc4962296a
Ruby
rahul-sekhar/story-rev
/spec/models/book_award_spec.rb
UTF-8
1,066
2.515625
3
[]
no_license
require "spec_helper" describe BookAward do let(:book_award) { build(:book_award) } subject { book_award } describe "year" do it "should be an integer" do ["1a", "0", 5.5].each do |x| book_award.year = x book_award.should be_invalid end end it "should have a lower limit ...
true
bc3620e0d76a807a156e5b09ec2032d5d32ab139
Ruby
toramuryo796/bookact
/app/services/star_rate.rb
UTF-8
780
3.125
3
[]
no_license
class StarRate def self.rate(book) introduces = book.introduces if introduces.present? array = [] sum = 0 introduces.each do |introduce| array << introduce.title sum += introduce.star.name end num = array.length avg = (sum / num).round(1) if avg >=4.8...
true
3fda2405b4ae032c460fb03d131fe77593dd9c68
Ruby
annadolan/enigma
/lib/key_generator.rb
UTF-8
141
2.703125
3
[]
no_license
class KeyGenerator attr_reader :key def initialize @key = key end def key @key = rand(0..99999).to_s.rjust(5, "0") end end
true
7683462ad4ec8e6dae62147b01f43a2ce98624d7
Ruby
Mwriley1/ls_course_120
/lesson1/exercises.rb
UTF-8
2,872
4.09375
4
[]
no_license
class Student attr_reader :name def initialize(name, grade) @name = name @grade = grade end def better_grade_than?(person) puts "Well done!" if self.grade < person.grade end protected attr_reader :grade end joe = Student.new("Joe", "A") bob = Student.new("Bob", "B") p joe.better_...
true
ba76f2f03df1518647d29f54e39f58015b05c9b6
Ruby
ojammeh/algorithms
/time_slots.rb
UTF-8
215
2.546875
3
[]
no_license
class TimeSlot NUMOFDAYS = 0 NUMOFPERIODSPERDAY = 0 NUMTIMES = 0 NUMROOMS = 5 def t_slots(d, p) rows, cols = d, p slots = Array.new(rows) {Array.new(cols,0)} return slots end end
true
96bf6b2ffe9041ddeb94834df5096272a8630560
Ruby
BkBky/dos
/maraton_active records/maraton/db/seeds.rb
UTF-8
7,027
2.640625
3
[]
no_license
# Este archivo sirve para crear registros de prueba user1 = User.create(name: 'Erick', password: '123', email: 'erick@gmail.com') user2 = User.create(name: 'Esme', password: '456', email: 'esme@gmail.com') user3 = User.create(name: 'Fausto', password: '789', email: 'fausto@gmail.com') #Deck deck1 = Deck.create(name:...
true
21d6c24185caab3e25654c2f3ce89db7cbd8a3c7
Ruby
charleshenriponiard/pet-lost
/app/models/pet.rb
UTF-8
261
2.765625
3
[]
no_license
class Pet < ApplicationRecord SPECIES = ["cat", "dog", "bird"] validates :species, inclusion: { in: SPECIES } validates :name, presence: true def found_days_ago "#{self.name} has been found #{(Date.today - self.found_on).to_i} days ago!" end end
true
ebdcc899ea28ff3c6e0e2e2f1808ba530940b8cd
Ruby
mikeyduece/black_thursday
/modules/customer_analyst.rb
UTF-8
2,326
2.59375
3
[]
no_license
module CustomerAnalyst def ranked(params) params.keys.sort_by {|customer_id| params[customer_id].reduce(:+)}.reverse end def unpaid_invoices se.all_invoices.find_all {|invoice| !invoice.is_paid_in_full?} end # def customers_with_unpaid_invoices # cust_ids = unpaid_invoices.group_by {|invoice| i...
true
04b0f2f2af119c008705bdadfe89ace87e34ae29
Ruby
RyanSpartan117/Project-Euler
/euler2.rb
UTF-8
575
3.671875
4
[]
no_license
require_relative 'spec/spec_helper' class Fibonnaci def fibonnaci_numbers number fibArray = [1, 2] currentFib = 1 secondFib = 2 i = 1 while i < number do nextFib = currentFib += secondFib fibArray.push(nextFib) currentFib = secondFib secondFib = nextFib i = currentFib + secondFib ...
true
fa918acf5c5c1c6984aabfc10595a938ab4ffc1c
Ruby
dedayog/Learning-Ruby
/Rubyrush.ru/step066.rb
UTF-8
507
2.984375
3
[]
no_license
require_relative 'win_stdin' exit_loop = -1 until exit_loop == '0' time = Time.now time_str_to_file_name = time.strftime('%Y-%m-%d %H-%M') file_name = __dir__ + '/face ' + time_str_to_file_name if File.file?(file_name) puts ("File #{file_name} already exist. Wait to create a new one") else file = Fil...
true
c579cfbe9408bd94d72a201d6316e77d2c7829df
Ruby
tdeo/advent_of_code
/2016/lib/18_like_a_rogue.rb
UTF-8
816
3.453125
3
[]
no_license
# frozen_string_literal: true class LikeARogue def initialize(input) @rows = [] @rows[0] = input.strip end def above_chars(i) [ (i == 0 ? '.' : ''), @rows.last[[i - 1, 0].max..[i + 1, @rows.last.size - 1].min], (i == @rows.last.size - 1 ? '.' : ''), ].join end def next_row...
true
b00ad9f82ebcab5ad4cb624f926361e2dd5d3c61
Ruby
evilmartians/evil-client
/lib/evil/client/builder.rb
UTF-8
1,147
2.53125
3
[ "MIT" ]
permissive
class Evil::Client # # @abstract # Base class for scope/operation builders # # Every builder just wraps scope/operation schema along with # preinitialized [#parent] settings of its super-scope. # The instance method [#new] quacks like the lazy constructor # for scope/operation instance whose options rel...
true
d408863beb21649570c9eada7b71470e17857a82
Ruby
agata-anastazja/learn-to-program
/chap_10/test.rb
UTF-8
969
3.78125
4
[]
no_license
def sort some_array # This "wraps" recursive_sort. dict_sort some_array, [] end def find_smallest(unsorted_array) candidate_word = unsorted_array[0] candidate_word_index = 0 unsorted_array.each_with_index do |word, index| if word.downcase < candidate_word.downcase candidate_word = word candida...
true
091721add5ed8afda1a22610d7cb8bc58385113f
Ruby
jon-dominguez94/w2d1-proj
/chess/board.rb
UTF-8
1,496
3.65625
4
[]
no_license
require_relative 'piece' class Board def initialize @grid = Array.new(8) {Array.new(8) } populate end def move_piece(start_pos, end_pos) raise ArgumentError, "No piece at this pos!" if self[start_pos].nil? raise ArgumentError, "Space is taken!" unless self[end_pos].nil? start_piece = ...
true
936b873cf5798421269d75d9fd36dca0f5930d21
Ruby
mpfilbin/conductor
/lib/conductor/applications/stack.rb
UTF-8
626
2.71875
3
[ "MIT" ]
permissive
require_relative 'interface' module Conductor module Applications # Represents a collection of application interfaces within a given application stack class Stack include Enumerable attr_accessor :applications def initialize(interfaces) @applications = [] load_interfaces(in...
true
9fcc00f8b7c468a6de48105679e60efeb73e9b34
Ruby
CrystalToh/LearnRubyTheHardWay
/Functions.rb
UTF-8
878
4.46875
4
[]
no_license
def extra_credit(var1, var2) puts "So, the first variable is #{var1}." puts "And the second variable is #{var2}." puts "I guess that's about it." puts end puts "Integers:" extra_credit(1, 2) puts "Floating points:" extra_credit(1.2, 3.4) puts "Variables:" x = 30 y = 40 extra_credit(x, y) puts "Integer math:" ex...
true