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
8c60005be190af05c176a0b22add5c7c059eaacf
Ruby
munazo/codility
/ruby/3-FrogJmp.rb
UTF-8
166
2.90625
3
[]
no_license
# https://codility.com/programmers/lessons/3-time_complexity/frog_jmp/ def solution(x, y, d) distance = y - x (distance / d.to_f).ceil end p solution(1, 1, 1)
true
80c0d711059ce2676644207220e0e66e16e4e580
Ruby
Jalindner/phase-0-tracks
/ruby/mini-course/first.rb
UTF-8
333
4.03125
4
[]
no_license
#puts "Hi there!" #puts "Welcome to my program!" #name = "Jennifer" #p name #name = "Jen" #puts "Hi #{name}!" #puts "What's your name?" #name = gets.chomp #puts "Hi #{name}" puts "Give me a word" word_1 = gets.chomp puts "Give me a word" word_2 = gets.chomp result = word_1 + word_2 puts "The result ...
true
d26aced8b00a80ec09caaf5017257bf827ea8a59
Ruby
d-khorolsuren/rubylesson
/game.rb
UTF-8
4,147
4.3125
4
[]
no_license
class Player def hand # Display "Sentences that require the player to enter 0 to 2". puts "Please enter a number." puts "0:グー, 1:チョキ, 2:パー" # Get what the player has entered in the variable "input_hand" and assign it. #Hint! Use the "gets method". # input_hand = # 「input_hand」(取得した値)が「0,...
true
ab164842142043805a9377409e14ebe96810d15c
Ruby
jasonsutter87/Algorithm-Practice
/arrays_and_strings/urlify.rb
UTF-8
369
3.859375
4
[ "MIT" ]
permissive
# Write a method to replace all spaces in a string with a '%20'. You may assume that the string has sufficient space at the end to hold the addition characters, and that you are given the "true" length of the string. # input: "Mr John Smith" # output: "Mr%20John%20Smith" def urlify(string) if string.include?(' ') == ...
true
a85feb2d07bbaed492d60bd63bbff6a5633f2214
Ruby
darrencauthon/richmond
/lib/richmond/rtfm.rb
UTF-8
2,715
2.921875
3
[]
no_license
require 'find' require 'ostruct' module Richmond class RTFM attr_accessor :record_pattern, :end_record_pattern, :output_file_pattern include Richmond::Logging def initialize @record_pattern =/^\=begin richmond/i @output_file_pattern = /output-file:\s+.*\s*/i @end_record_pattern = ...
true
2f56cfe905fbc89c1efa4ca50d27e6b98fe75b6c
Ruby
sweettsubaki/J6repoexo
/exo_08.rb
UTF-8
122
3.4375
3
[]
no_license
user_name = gets.chomp puts "Coucou, #{user_name} !" #résultat en ayant choisit user_name = 'célia' : #Coucou, célia !
true
aca3ad92d86d7630a4a86c9168203014d7f54c86
Ruby
longmei2016/programming-exercise
/03-triangle.rb
UTF-8
295
3.921875
4
[]
no_license
# 题目: 使用者输入直角三角形的宽和高,输出三角形的面积 print "请输入直角三角形的高,然后按 Enter: " a = gets a = a.to_f print "请输入直角三角形的底边,然后按 Enter: " b = gets b = b.to_f puts "直角三角形的面积是: __#{a*b/2}___"
true
2e4ab6c5374f15a28a6567547caaf6b16f5f31dd
Ruby
TeamMoodGitHub/Allan-Term-1
/scripts/fta_seed.rb
UTF-8
2,274
2.578125
3
[]
no_license
require 'rubygems' require 'active_record' require 'open-uri' require 'nokogiri' require 'uri' require 'addressable/uri' ActiveRecord::Base.establish_connection( :adapter => "mysql2", :host => "localhost", :username => "root", :password => "guest", :database => "FindThatAnime_development" ) class Anime < ActiveRecor...
true
d720accec566fb2d59c3f8bbd954904368cc1d9e
Ruby
jjeffers/acks_reggen
/lib/fractal.rb
UTF-8
402
2.546875
3
[]
no_license
def linear_midpoint_displacement(start, endpoint, length) max_offset = 1 roughness = 1.0 values = [0.0, 0.0] while values.size < length do values = values.enum_for(:each_cons, 2).map do |left, right| mid = (left + right) / 2 r = (rand(4)-2) mid += r * max_offset [left, mid.to_...
true
05e48f6601eb673d4f96042ec4dd62d74762335b
Ruby
christafaa/enrollment-app
/db/seeds.rb
UTF-8
2,285
2.609375
3
[ "MIT" ]
permissive
florence = Student.create(name: "Florence Perez", username: "florence", password_digest: BCrypt::Password.create("perez")) luis = Student.create(name: "Luis Potter", username: "luis", password_digest: BCrypt::Password.create("potter")) herbert = Student.create(name: "Herbert Robbins", username: "herbert", password_dige...
true
85598ded3788e39053aaeb6de6ebde01c511b4c1
Ruby
jamessteininger/Dogemon
/app/models/pvp_battle.rb
UTF-8
2,081
2.765625
3
[]
no_license
class PvpBattle < ActiveRecord::Base validates :user_id, presence: true # validates :other_id, presence: true validates :pet1_id, presence: true # validates :pet2_id, presence: true belongs_to :user, class_name: 'User', foreign_key: 'user_id' belongs_to :other, class_name: 'User', foreign_key: 'other_id...
true
16563892b73985fa9a94c52e29bce3af2561000a
Ruby
Cparusso/many-to-many-review-lecture
/trial-run/trial-tools/run.rb
UTF-8
722
3.4375
3
[]
no_license
require "pry" require_relative "../models/Human.rb" require_relative "../models/Alien_Overlord.rb" require_relative "../models/Abduction.rb" puts "creating humans" h1 = Human.new("Charlie", "hazel") h2 = Human.new("Brianna", "brown") h3 = Human.new("Brad", "blue") puts "created humans" puts "creating alien over...
true
0c27687bddc3106ac754dce9cf7bc63533bad087
Ruby
ventadour/appRails
/webService.rb
UTF-8
383
3.21875
3
[]
no_license
require 'sinatra' class Compteur attr_accessor :val def initialize(valeur) @val = valeur end def plus @val += 1 end def moins @val -= 1 end end get '/' do @cpt = Compteur.new(0) end get '/cpt' do "valeur" end get '/cpt/plus' do @cpt.plus "valeur #{ @cpt.val }" end g...
true
adc3ba0fc28fcab3a3c1d89df830e6e9be631328
Ruby
shirleyz9402/ruby-objects-belong-to-lab-web-022018
/lib/song.rb
UTF-8
147
2.78125
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class Song attr_accessor :title, :artist def self.create(title) song = self.new song.title = title song.artist = artist end end
true
77087d07ac1267fff7c924f3c1a6e2f5b45213ec
Ruby
KellyIB/enigma
/test/shift_test.rb
UTF-8
1,969
3.140625
3
[]
no_license
require_relative '../test/test_helper' require_relative '../lib/enigma' require 'date' require 'mocha/minitest' require_relative '../lib/shift' class ShiftTest < Minitest::Test def setup @enigma = Enigma.new @shift = Shift.new end def test_is_an_instance_of assert_instance_of Shift, @shift end ...
true
bc1426c02aae01d4cdc2d7e4723b551288a80f63
Ruby
cjbrock/object-relationships-081720
/run.rb
UTF-8
820
2.8125
3
[]
no_license
require 'pry' require_relative 'passenger.rb' require_relative 'ticket.rb' corinna = Passenger.new("Corinna", "Paris") ken = Passenger.new("Ken", "Greece") adam = Passenger.new("Adam", "Las Vegas") briana = Passenger.new("Briana", "Phuket") tabatha = Passenger.new("Tabatha", "Dublin") john = Passenger.new("John", "Me...
true
3ceeb5c6a0f8bcf04ee7bee6935d02adf17684f0
Ruby
totothink/design_patterns_in_ruby
/command/command_with_meta.rb
UTF-8
4,778
2.734375
3
[]
no_license
# 问题: 在定义command的过程中有很多的重复代码,这些重复代码严重降低了代码的编写效率,增加了代码的维护成本。 # 解题思路: # 1. 定义一套DSL语言,允许程序员通过配置的方式来定义Command # 2. Command之间可继承,减少需要配置的代码 # # 解决方案: # 1. DSL语言 # 1.1 command # command用来定义一个命令 # 1.2 execute # execute用来定义命令需要执行的操作 # 1.3 undo # undo用来定义命令撤销时需要执行的操作 # 1.4 target # target用来保存目标...
true
c93303e4499fb52d3833024e7b8c6223fd0cc602
Ruby
natey37/Black-Thursday
/black_thursday/lib/sales_analyst.rb
UTF-8
23,114
3.046875
3
[]
no_license
require_relative './sales_engine.rb' require 'date' class SalesAnalyst attr_reader :items_count, :average def initialize(se_instance) @se_instance = se_instance merchants = @se_instance.merchants ids = merchants.merchant_ids merchants1 = [] ids.each do |id| merchants1...
true
cc02791c48d2f4d39344e35bcf51e70e497754ee
Ruby
dsully/loser
/app/models/weighing.rb
UTF-8
692
2.609375
3
[]
no_license
class Weighing include DataMapper::Resource include Merb::GlobalHelpers property :id, Serial property :date, Date, :index => true property :weight, Float, :required => true belongs_to :user belongs_to :round belongs_to :participant validates_with_method :date, :method => :validate_date ...
true
f520f6342c8b639b7fcf5f2ea6c5328f713b8cf8
Ruby
Dobrzhanskij/silicium
/test/algebra_test.rb
UTF-8
5,440
2.671875
3
[ "MIT" ]
permissive
require 'test_helper' require 'algebra' require 'algebra_diff' require 'polynomial_division' class AlgebraTest < Minitest::Test include Silicium::Algebra include Silicium::Division #New class objects #@@polynom = Polynom.new @@diff = Differentiation.new @@polynom_div = Polynom_division.new def test_tha...
true
9701b18649d8425ca4e50099f4f9329067a664c7
Ruby
AbbottMichael/enigma
/lib/decrypt.rb
UTF-8
972
3.34375
3
[]
no_license
require './lib/enigma' abort("ERROR: You must provide a message to decrypt:\ <file.txt>") if ARGV[0] == nil abort("ERROR: You must provide a file to write the decrypted message to:\ <file.txt>") if ARGV[1] == nil abort("ERROR: You must provide the key used to encrypt the message:\ <12345>") if ARGV[2] == ni...
true
440994fc0eb941b00b3240974dc77436e09fbed8
Ruby
libc/help_scout
/lib/help_scout.rb
UTF-8
4,500
2.65625
3
[ "MIT" ]
permissive
require "help_scout/version" require "httparty" class HelpScout class ValidationError < StandardError; end class NotImplementedError < StandardError; end HTTP_CREATED = 201 HTTP_BAD_REQUEST = 400 attr_accessor :last_response def initialize(api_key) @api_key = api_key end # Public: Create conver...
true
a46a190c37955288aeb15f12228988c7792a5f33
Ruby
rogerleite/http_objects
/lib/http_objects/headers_hash.rb
UTF-8
709
2.921875
3
[ "MIT" ]
permissive
module HttpObjects # Public: Hash with HTTP Headers methods. # # Examples # # headers = HttpObjects::Headers.new # headers["key"] = "value" # is kind of Hash # # # And for HTTP headers, you have objects # headers["Content-Type"] = "text/html;Charset=utf-8" # headers.content_type? # =...
true
bfa931d2a19fd38fffcf92589a84ec4223d7dc08
Ruby
TsutomuNakamura/adap
/test/adap_add_user_test.rb
UTF-8
7,623
2.5625
3
[]
no_license
require "test_helper" class ModAdapTest < Minitest::Test def test_add_user_should_failed_if_ldap_add_was_failed # get_operation_result will returns... # if success: # #<OpenStruct extended_response=nil, code=0, error_message="", matched_dn="", message="Success"> # else if failed: # #<...
true
c6518a5ffb16f68ca8bcce1dcf7480ba4b54577e
Ruby
NUBIC/castanet
/lib/castanet/client.rb
UTF-8
5,803
2.546875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
require 'logger' require 'net/http' require 'net/https' require 'uri' require 'castanet/proxy_ticket' require 'castanet/service_ticket' module Castanet ## # The top-level interface for Castanet. # # See the README for usage examples and interface expectations. # # # Security requirements # ==========...
true
f7544be69a12b25ab77f685e151c46886972ea74
Ruby
nagerz/enigma
/lib/ceaser_cipher.rb
UTF-8
456
3.1875
3
[]
no_license
module CeaserCipher def shift_letter(letter, index, shifts, type) letter_index = @char_set.index(letter) shift_index = index % 4 shift = shifts[shift_index] rotate_letter_by_type(type, shift, letter_index) end def rotate_letter_by_type(type, shift, letter_index) if type == "encrypt" @c...
true
e4afdddf381d4ec5f47ae4124885a257c36fa40e
Ruby
taylorthurlow/advent-of-code-2018
/day1/day1-golf.rb
UTF-8
277
3.15625
3
[]
no_license
#!/usr/bin/env ruby data = File.read('data.txt').chomp.split("\n") # PART 1 puts data.sum(&:to_i) # PART 2 found = nil list = [0] f = 0 until found data.each do |d| f += d.to_i found = f if list.include? f break if found list << f end end puts found
true
e542137891f663465f0e16451bc2db85526b1fcc
Ruby
consected/restructure
/app/models/nfs_store/manage/group.rb
UTF-8
2,261
2.59375
3
[ "BSD-3-Clause" ]
permissive
module NfsStore module Manage class Group RoleNamePrefix = 'nfs_store group ' NfsMountNamePrefix = 'gid' # Configuration of valid filesystem group ID gids # @return [Range] like 600..610 def self.group_id_range Filesystem.group_id_range end # Valid role names ba...
true
53d530f6a929fb9d436b83ab39d4009dab42a577
Ruby
montaan/muryu
/test/benchmark/browsing_simulation.rb
UTF-8
1,855
2.828125
3
[ "MIT" ]
permissive
$cookie = "future_session_id=8516282a2b031156040b99f3344e73cc" def url(x,y,z,i) rx = (z*x + i%5)*256 ry = (z*y + i/5)*256 "http://manifold.fhtr.org:8080/tile/x#{rx}y#{ry}z#{z}" end def fetch(n, x, y, z, threads=2) times = [] sizes = [] (0...threads).map do |t| Thread.new(t) do (n/threads).times{...
true
a0fedf993e2511db0244cb5d994789c7b0a991b3
Ruby
tyfirth/oxford-comma-onl01-seng-pt-050420
/lib/oxford_comma.rb
UTF-8
280
3.3125
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def oxford_comma(array) if array.length == 1 return "#{array[0]}" elsif array.length == 2 return "#{array[0]} and #{array[1]}" elsif array.length >= 3 new_last_element = "and #{array[-1]}" array.pop array.push(new_last_element) return array.join(", ") end end
true
f6727c531220d5b93ded114dea0c5aeb6d0303e0
Ruby
eggmantv/ruby_advanced
/05/16_send.rb
UTF-8
63
2.546875
3
[]
no_license
# send method def hello puts 'hello world' end send(:hello)
true
01c7ffada3724c21eac16175472ada63550830c4
Ruby
MaximumViableProduct/MaxViableProduct
/app/models/game.rb
UTF-8
510
2.5625
3
[]
no_license
class Game < ApplicationRecord # Remember to create a migration! belongs_to :user belongs_to :deck has_many :guesses has_many :guessed_cards, through: :guesses, source: :card validates :deck, presence: true def cards_available self.deck.cards.each { |c| c } end def unanswered_cards card_pool...
true
29962b5340d9a92476b583336f82272bd28714a0
Ruby
lucasvmiguel/expert-ruby-programming-ten-steps-to-mastery
/section_4/exceptions.rb
UTF-8
282
2.921875
3
[]
no_license
x = nil begin x = 10 / 1 # raise TypeError rescue TypeError, ZeroDivisionError => e x = 0 p e.class p e # retry # retry code again before excepetion was raised rescue Exception => e x = 0 p e.class p e else # execute when has not error ensure x += 2 end p x
true
5fa015dea8425b8f052688fb304adef70c7ba152
Ruby
SheetalJadhav/bitcasa
/lib/bitcasa/session.rb
UTF-8
6,767
2.734375
3
[ "MIT" ]
permissive
require_relative 'client' require_relative 'account' require_relative 'user' require_relative 'filesystem' module Bitcasa # Establishes a session with the api server on behalf of an authenticated end-user # # It maintains restful bitcasa api client object that provides authenticated access # to Bitcasa Cloudfs...
true
14f56f2b281daade3f837fa1a20f29ffe759d5b6
Ruby
FergusDevelopmentLLC/hiking_project_cli
/lib/hiking_project_cli/scraper.rb
UTF-8
2,212
2.828125
3
[ "MIT" ]
permissive
class HikingProjectCli::Scraper def self.get_trails_from_api(coords) #returns an array of trail hashes #coords = "lat=40.0274&lon=-105.2519" #coords = "lat=28.539358&lon=-81.398444" url = "https://www.hikingproject.com/data/get-trails?#{coords}&maxDistance=10&key=...
true
d1d5cab70b48ae3e49b97bea8745c76a76ae8370
Ruby
f3mshep/ruby_interview_algorithm_practice
/solutions/linked_list_contains_cycle.rb
UTF-8
764
3.90625
4
[]
no_license
# Detect if a linked list contains a cycle. Optimize for speed AND complexity. class LinkedListNode attr_accessor :value, :next def initialize(value) self.value = value self.next = nil end end # We can reduce space here def unoptimized_contains_cycle(head) histo = {} node = head while node ...
true
91a9a435b2324d813781a5e493bca03e6b9811bd
Ruby
IvanitiX/PDO_Civitas
/CivitasRuby/lib/Sorpresa.rb
UTF-8
779
2.828125
3
[]
no_license
#encoding UTF-8 #Author: Miguel Muñoz Molina #Author: Iván Valero Rodríguez module Civitas class Sorpresa private_class_method :new def initialize(texto) @texto = texto end def jugadorCorrecto(actual, todos) return ( actual >= 0 and actual < todos.size ) end def ...
true
51cb92c34c1f9012475352a1a31ac56cabc58018
Ruby
mrgcohen/jpa-jruby-wrapper
/Format.rb
UTF-8
1,065
3.1875
3
[]
no_license
module Format # return "" on nil response from harbinger def d(&block) begin yield rescue "" end end # show as time def self.to_time(datetime) begin Time.parse(datetime.to_s).strftime("%T") rescue "" end end # show as date def self.to_date(datetime) ...
true
4e39cedae7aa6df6d21dbbe0b48e2329108e1010
Ruby
jawheeler/trap_ui
/spec/trap_spec.rb
UTF-8
869
2.78125
3
[]
no_license
require File.dirname(__FILE__) + '/../lib/trap' require 'set' describe Trap do before(:each) do @trap = Trap.new(Set.new(['A','B']),Set.new(['C','D'])) end it "should be released by any captor's ok, ignoring other oks" do @trap.release?(Set.new(['A'])).should == false @trap.release?(Set.new(['C'])...
true
f17292dc931c3c1ab64adb98f5fd3de86a0be2cd
Ruby
jhulford/rex12
/lib/rex12/element.rb
UTF-8
1,076
3.53125
4
[ "MIT" ]
permissive
# Represents an ANSI X.12 Element module REX12; class Element # @return [String] base text value of the element (does not break up sub elements) attr_reader :value # @return [Integer] zero based location of this element in its parent segment attr_reader :position # @param value [String] base text value of t...
true
f3b821b54fedf1833d704064bce42e04630e186d
Ruby
snarf24/backend_module_0_capstone
/day_2/exercises/iteration_and_each.rb
UTF-8
1,523
4.28125
4
[]
no_license
num_ary = [1, 2, 3, 4] # array is iterated then convert to string then doubles are returned to increase number of repeated digits increase multiple. num_ary.each { |num_ary| puts num_ary.to_s * 2 } # array is iterated into block that only prints if .even? true condition is returned. For odd number apply .odd? conditi...
true
1dcae1480a1bf9eeb8eba6df3221b8f05763bbd2
Ruby
JustinLove/gsl
/lib/gsl/value_resource.rb
UTF-8
817
2.625
3
[]
no_license
module GSL class Resource module Value def set(n) n = wrap(n) if self.class.range.include?(n) self.value = n else Language.error 'resource out of range' end end def if_gain(n) n = wrap(n) if self.class.range.include?(self.value...
true
6c98e6c536ec399caec798ce095cfc8abd0d8b74
Ruby
JamesDBudge/week2-day1-class-homework
/specs/sports_team.specs.rb
UTF-8
1,649
3
3
[]
no_license
require('minitest/autorun') require('minitest/rg') require_relative('../sports_team') class TestSportsTeam < MiniTest::Test def test_sports_team_name team = SportsTeam.new("Clachnacuddin", ["Jim", "Paul", "Peter"], "James") assert_equal("Clachnacuddin", team.team_name) end def test_sports_team_players...
true
8149c64c569ba05bb33db92d30dcb8a87206046b
Ruby
teliosdev/mixture
/lib/mixture/validate/presence.rb
UTF-8
807
2.84375
3
[ "MIT" ]
permissive
# encoding: utf-8 # frozen_string_literal: true module Mixture module Validate # Checks that a value is present. class Presence < Base register_as :presence # Performs the validation. # # @param (see Base#validate) # @return (see Base#validate) # @raise [ValidationError] I...
true
a564cf2f5238bab0b101520be71833c0911360c2
Ruby
kylehenson/sales_engine
/test/merchant_test.rb
UTF-8
1,588
2.78125
3
[]
no_license
require 'CSV' require './lib/merchant' require 'minitest/autorun' require 'minitest/pride' class MerchantTest < Minitest::Test def test_it_exists assert Merchant end def test_find_id merchants = CSV.open('./data/merchants.csv', headers: true, header_converters: :symbol) one_mer = merchants.each do ...
true
a2eb035bfaa12958d4e5862fd3a4b1ee3ba6a581
Ruby
tilia/tilia-vobject
/lib/tilia/v_object/v_card_converter.rb
UTF-8
13,357
2.65625
3
[ "BSD-3-Clause" ]
permissive
require 'base64' module Tilia module VObject # This utility converts vcards from one version to another. class VCardConverter # Converts a vCard object to a new version. # # targetVersion must be one of: # Document::VCARD21 # Document::VCARD30 # Document::VCARD40 ...
true
179063f98764e3714665dc0de9a699479fba6e99
Ruby
NickLaMuro/manageiq-providers-autosde
/spec/models/manageiq/providers/autosde/autosde_client_all_storage_models_spec.rb
UTF-8
4,444
2.640625
3
[ "Apache-2.0" ]
permissive
describe ManageIQ::Providers::Autosde::StorageManager::AutosdeClient do # assumption to the test # -system exists # -resource(pool) exists # service exists # # When creating object, how to know which attributes to set in initializer? # Autocomplete does not help # Example: create Volume # Using client...
true
64f690b6c5411c02b541a90d0d749dab756dfed6
Ruby
jajapop-m/AtCoder
/過去問/PAST/1/D.rb
UTF-8
312
3.078125
3
[]
no_license
N = gets.to_i array = Array.new(N+1,0) dup = nil N.times do |i| input = gets.to_i dup = input if not array[input].zero? array[input] += 1 end array.shift result = nil array.find.with_index{|value, index| result = index+1 if value == 0} puts [dup, result].join(" ") if result puts 'Correct' if not result
true
8b9a9a62591aeac91e49b3ee4c03f35cc50b8e75
Ruby
Kusnierewicz/TestFirstRubySection
/01_temperature/temperature.rb
UTF-8
292
4.03125
4
[]
no_license
def ftoc(n) cal = 100.0/(212.0-32) cel = (n - 32)*cal #cel = (n * cal) - 32 return cel.ceil end puts ftoc(212) def ctof(n) cal = (212.0-32)/100.0 cel = (n * cal) + 32 #cel = (n * cal) - 32 if n == 37 return cel else return cel.floor end end puts ctof(37)
true
9652e2213a720832b126c99c0e372691e85beb6f
Ruby
12meses12katas/Junio-Simple-Lists
/lantoli/lib/simplelists.rb
UTF-8
953
3.296875
3
[]
no_license
class SingleLinkedList def each_node if block_given? node = @first_node while not node.nil? yield node node = node.next_node end else self.to_enum :each_node end end def find(value) each_node.find { |node| node.value == value } end def values ...
true
568f1d1766dd992d69cba3d129a5d366615f7f60
Ruby
mingle/mingle_events
/lib/mingle_events/xml.rb
UTF-8
2,748
2.671875
3
[ "Apache-2.0" ]
permissive
module MingleEvents module Xml class Element attr_reader :node, :namespaces def initialize(node, namespaces) @node = node @namespaces = namespaces end def nil? @node.nil? end ["inner_text", "optional_inner_text", "select", "select_all", "attr", "child...
true
366b3512f9a79ca5030d43cadd900bf1e2276c37
Ruby
ECOtterstrom/IntroToProgRuby
/9_exercises/ex_914.rb
UTF-8
1,031
2.828125
3
[]
no_license
# 9_exercises exercise 14 contact_data = ["joe@email.com", "123 Main st.", "555-123-4567"] contacts = {"Joe Smith" => {}} fields = [:email, :address, :phone] contact_fields = {} fields.zip(contact_data){ |x, y| contact_fields[x] = y } contacts["Joe Smith"] = contact_fields puts contacts ...
true
be5f8f45c1fd34fa402f60c4e62e688acd28a6fe
Ruby
kristianmandrup/friendly_view
/app/models/property.rb
UTF-8
1,375
2.59375
3
[]
no_license
class Property def mash @mash ||= Hashie::Mash.new title: 'A beautiful property', description: %q{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent mauris arcu, auctor ac rhoncus non, imperdiet non quam. Aliquam elementum vestibulum arcu, et vulputate lectus vehicula ac. Do...
true
672c4efe69f26a5788002901546628a055d05d13
Ruby
livecodelife/gift-assigner
/db/seeds.rb
UTF-8
898
2.5625
3
[]
no_license
3.times do Family.create end Assignment.create(person: "Caleb", family: Family.first, age: "adult") Assignment.create(person: "Ruth", family: Family.first, age: "adult") Assignment.create(person: "Gideon", family: Family.first, age: "child") Assignment.create(person: "Lillian", family: Family.first, age: "child") ...
true
8ef76ed3f2cdb9f934a51d6cb81a0da0218e4f65
Ruby
KF525/far_mar_finder
/lib/far_mar/vendor.rb
UTF-8
898
2.921875
3
[]
no_license
module FarMar class Vendor attr_accessor :id, :name, :no_of_employees, :market_id def initialize(vendor_array) @id = vendor_array[0].to_i @name = vendor_array[1] @no_of_employees = vendor_array[2].to_i @market_id = vendor_array[3].to_i end def self.all @all ||= all_crea...
true
9d5479922fe014f5179e3c13f98c57d68b0d5cbf
Ruby
devcamp2014/MosaIKU
/get_pixiv_img.rb
UTF-8
1,909
2.921875
3
[]
no_license
# -*- coding: utf-8 -*- require 'uri' require 'open-uri' require 'csv' require 'set' require 'digest/sha1' class PixivImg DOWNLOAD_LOG_FILE = "download.log" SESSION_ID = "11353907_6a9ca04b5e12727dee45049e2abce045" def initialize() @urlset = Set.new CSV.foreach(DOWNLOAD_LOG_FILE) do |row| @urlset...
true
b2da2bac89af46f9e0310884de246961ed22340a
Ruby
drink-this/drink-this-backend
/spec/services/cocktail_service_spec.rb
UTF-8
5,415
2.671875
3
[]
no_license
require 'rails_helper' RSpec.describe CocktailService, :vcr do describe 'class methods' do describe '::get_cocktail_details' do it 'returns cocktail data', :vcr do response = CocktailService.get_cocktail_details(11008) expect(response).to be_a Hash expect(response[:drinks]).to be_a...
true
6ddf98569a79c3291e89d451b3fbcd866aa4ab28
Ruby
colinritchey/app-academy-projects
/W2D3_v2/poker/spec/deck_spec.rb
UTF-8
1,592
3.546875
4
[]
no_license
require 'deck' describe Deck do subject { Deck.new } describe "#initialize" do it "exposes a contents array" do expect(subject.contents).to be_a(Array) end it "creates 52 cards" do expect(subject.contents.size).to eq(52) end it "has only cards as contents" do expect(subject...
true
99585a7c9055be3a10f513159680d1800b17959e
Ruby
zfv200/sql-library-lab-web-022018
/lib/querying.rb
UTF-8
1,422
2.75
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def select_books_titles_and_years_in_first_series_order_by_year "SELECT books.title, books.year FROM books WHERE books.series_id = 1" # JOIN series ON series.id = 1" # GROUP BY books.year" end def select_name_and_motto_of_char_with_longest_motto "SELECT name, motto FROM characters ORDER BY motto ASC LIMIT 1" e...
true
5a1d457dfc1c8ad6fcf05e5dca9865a35ce515c9
Ruby
cmastel/math_game
/player.rb
UTF-8
221
3.03125
3
[]
no_license
class Player attr_accessor :id, :lives_remaining, :total_lives def initialize(id) @id = id @total_lives = 3 @lives_remaining = 3 end def decrease_lives() self.lives_remaining -= 1 end end
true
0598b7ff4a05911ca725f9a3733f1b4716abb201
Ruby
tanphan313/leet_works
/queue_stack/backspace_string_compare.rb
UTF-8
986
3.96875
4
[]
no_license
<<-Doc Given two strings s and t, return true if they are equal when both are typed into empty text editors. '#' means a backspace character. Note that after backspacing an empty text, the text will continue empty. Input: s = "ab#c", t = "ad#c" Output: true Explanation: Both s and t become "ac". Input: s = "ab##", t...
true
ad2fa6cb57615fd342ae8af0e61e0b34d57964f9
Ruby
jho406/code-test-defmethod
/lib/code_test.rb
UTF-8
1,343
3.03125
3
[]
no_license
require 'code_test/input' require 'code_test/transformer' require 'code_test/output' module CodeTest extend self FILES_HEADERS_AND_DELIMITERS = [ ['comma.txt', [:last_name, :first_name, :sex, :color, :dob], ','], ['pipe.txt', [:last_name, :first_name, :initial, :sex, :color, :dob], '|'], ['space.txt'...
true
79050552d53b9543f09f270e8fde5fad8b69d3b6
Ruby
Carmer/my_chaims
/db/seeds.rb
UTF-8
809
2.875
3
[]
no_license
class Seed def initialize generate_artists generate_albums generate_songs end def generate_artists puts "Start Artists" 50.times do Artist.create(name: Faker::Name.name) end end def generate_albums puts "Start Albums" years = (1965..2015).to_a 250.times do |i| ...
true
787741077d8a9c0b4b30986905c2a7c7d4740339
Ruby
revence27/Outreach-Costing
/app/models/location.rb
UTF-8
385
2.921875
3
[]
no_license
module Location # scope :by_name, self.order('name ASC') def children raise NoMethodError.new(%[You should over-ride #children.]) end # Ensures that the walk is a proper descent; in return for higher time # complexity. def walk &blk self.children.each do |child| yield child end self....
true
861c62b6365e4353298d1bbdf74465cbbb6b14f9
Ruby
ferranpm/dotfiles
/bin/dineros
UTF-8
1,823
3.03125
3
[]
no_license
#!/usr/bin/env ruby require 'nokogiri' require 'date' require 'optparse' PARTICIPANTS = 4.freeze Transaction = Struct.new(:date, :concept, :amount, :balance) class SantanderFile def initialize(file) @page = Nokogiri::XML(File.read(File.expand_path(file))) end attr_reader :page def transactions rows ...
true
e906b13b818806958a82a5985be90c31e9fe0897
Ruby
berkes/pijpenstelen
/test/models/pijpenstelen/graph_test.rb
UTF-8
1,840
2.59375
3
[ "MIT" ]
permissive
require "test_helper" class PijpenstelenGraphTest < TestCase before do @graph = stub("Graph", :labels= => true, data: true, :theme_pastel => {}, :marker_font_size= => 0, :minimum_value= => 0) end describe "#graph setu...
true
c7a597bbff71e848dcd053eea830a373b396939f
Ruby
ShrwdFlrst/courses
/pragprog-excercies-for-programmers-rb/ruby/chapter_01/spec/tip_calculator_spec.rb
UTF-8
590
2.9375
3
[]
no_license
require "./tip_calculator" RSpec.describe TipCalculator do describe '#calculate_tip' do it 'returns the percentage of the total' do expect(TipCalculator.new.calculate_tip(11.25, 15)).to eq(1.69) end end describe '#calculate_total' do it 'returns the sum of the bill and the tip' do ...
true
5687890ccd95555f1075af47fd801342363c1147
Ruby
gerardo-navarro/road_through_euler
/project_euler/eu27_quadratic_primes/solution_algorithm.rb
UTF-8
2,653
3.578125
4
[]
no_license
class SolutionAlgorithm # 1st implementation - Provide complexity def SolutionAlgorithm.solve primes = [] prime_sieve = Array.new(1000, true) prime_sieve[0] = false prime_sieve[1] = false i = 2 while i < prime_sieve.size primes << i (2*i).step(999, i) { |i| prime_sieve[i] ...
true
345d04686bbe29d6d1a60b00cdf6ff90ac01bc48
Ruby
innku/trophywallclient
/lib/trophywall/challenge.rb
UTF-8
3,227
2.609375
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
module TrophyWall module Challenge def self.included(base) base.send :extend, ClassMethods base.send :include, InstanceMethods base.send :trophywall_hit_on_create end module ClassMethods def challenge(name) self.cattr_accessor :trophywall_challenge_name ...
true
d18707d20d80fb821e8e0b8a1ca3b6570f93af59
Ruby
htan712/SqlitePractice
/01Assignment.rb
UTF-8
2,064
2.921875
3
[]
no_license
Database Schema: apps: id: Integer, name: Text, price: Integer, downloads: Integer, category: Text # Remove duplicates "SELECT DISTINCT category FROM apps" App.select(:category).distinct # filter records using inequalities, pattern matching, ranges, and boolean logic top_paid = sql.performQuery("SELECT * FROM ap...
true
3826aa9b46f30aa843771cccc3ca361ada4ab1e6
Ruby
jessicafarias/CodingChallenges
/HACKERANK/HurdleRace/Fibonacci/fibonnacci.rb
UTF-8
247
3.6875
4
[]
no_license
def fibonacci(number) test = 0 str = [1, 2] while str[test + 1] <= number sum = str[test] + str[test + 1] str.push(sum) test += 1 end test = 0 str.each { |x| test += x if x.even? && x < number } p test end fibonacci(10)
true
062d224bec8ce35b1f2e0575d147618952de5724
Ruby
DanHefrman/stuff
/NEW/ruby-metaprogramming-challenge/solutions/AE9RB/solution.rb
UTF-8
2,230
2.640625
3
[]
no_license
# by David Turnbull AE9RB # Tested with Ruby 1.9.2p320 # Extremely minimal solution. lambda do return unless count_calls_to = ENV['COUNT_CALLS_TO'] return unless match = count_calls_to.match(/(.+)(#|\.)(.+)/) klass, kind, kall = match.captures kall = kall.to_sym count = 0 enabled = false stopper = fal...
true
137f5e0ec84720174d30c6d8aa9b96cd4b59b783
Ruby
xiagu/2015-advent-of-code
/day6/spec/solver_spec.rb
UTF-8
582
2.5625
3
[]
no_license
require "rspec" require_relative "../solver" RSpec.describe "Day 6 Part 1" do describe LightGrid do subject { LightGrid.new } it { expect(subject.instr("turn on 0,0 through 999,999").lights_on).to be 1_000_000 } it { expect(subject.instr("toggle 0,0 through 999,0").lights_on).to be 1_000 } it { expe...
true
e8ebdcbb9e53a0e47607f9c228f4669e230d96e7
Ruby
polyfox/moon-packages
/lib/moon/packages/render_primitives/screen_element.rb
UTF-8
2,229
3.1875
3
[ "MIT" ]
permissive
require 'render_primitives/rectangular' module Moon module RenderPrimitive # I can be shot for this afterwards... module ScreenElement include Rectangular # Returns the expected screen position of the object # # @return [Vector2] position # @abstract Overwrite this in your clas...
true
f286b60db723059a359f88e021599658293a4811
Ruby
swojeet/ruby_http_server
/thread_pooling.rb
UTF-8
443
2.984375
3
[]
no_license
require 'benchmark' require 'thread' POOL_SIZE = 5 count = 0 jobs = Queue.new 10_000.times {|i| jobs.push i} puts Benchmark.measure{ workers = (POOL_SIZE).times.map do Thread.new do begin while x = jobs.pop(true) count += 1 puts "Time is #{Time.now.to_f * 1000} #{count}" ...
true
ccc8a299b4129769dd070f172f66743c2f438f95
Ruby
GaryZCLau/ruby-oo-relationships-practice-boating-school-exercise-nyc04-seng-ft-030920
/app/models/student.rb
UTF-8
704
3.03125
3
[]
no_license
class Student attr_accessor :first_name @@all = [] def initialize(first_name) @first_name = first_name @@all << self end def self.all @@all end def add_boating_test(testname, teststatus, instructor) BoatingTest.new(self, testname, teststatus, instructor) ...
true
30a292c6de14488c4426ac769c9e6d453d397465
Ruby
eva-barczykowska/Ruby
/sololearn/solo-games/ex_from_solo10.rb
UTF-8
1,849
4
4
[]
no_license
s1 = 'It\'s cool to earn money' s2 = s1.split print s2 #["It's", "cool", "to", "earn", "money"] s3 = s2[0][3] + s2[1][2,3] * 2 + s2[3] puts puts s3 puts puts puts ("a".."z").size #returns nil puts puts arr = [1, 3, 4, 5, 6, 7] other_arr = arr.map(&:even?) p other_arr puts puts other_arr.index(true) #it will return...
true
77ebcd09f8f8cf552e81cc257d1ca19b50657609
Ruby
doctordeep/arachni
/lib/arachni/http/cookie_jar.rb
UTF-8
5,231
2.515625
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
=begin Copyright 2010-2014 Tasos Laskos <tasos.laskos@gmail.com> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless requi...
true
95c0afca6f7711c5fdc1f13435e62f730f11d297
Ruby
jjulian/money-for-nothin
/hello.rb
UTF-8
1,471
2.984375
3
[]
no_license
require 'sinatra' require 'image_suckr' get '/' do suckr = ImageSuckr::GoogleSuckr.new image_url = suckr.get_image_url('q' => "Dire Straits") erb :index, locals: { lyric: lyrics.shuffle.first.strip.upcase, image_url: image_url } end def lyrics %{ Now look at them yo-yo's that's the way you do it ...
true
7e878dbbf9576cfcd8bb564b8e59e802af7b2cbf
Ruby
FrancescoPalma/CodeClan---CX3
/week_1/d2/gentleman.rb
UTF-8
1,801
3.59375
4
[]
no_license
# Robot Settings def robot ( name, platform, programming_language, framework, task ) puts "Robot Name: #{name}" puts "Platform: #{platform}" puts "Programming Language used: #{programming_language}" puts "Framework used: #{framework}" puts "Main task: #{task}" end robot("Gentleman", "Arduino", "Ruby", "Arto...
true
4069c2bcea94ed36c6880e663c3e456f0cd4e1da
Ruby
TristanHoladay/gothonweb_game
/tests/map_tests.rb
UTF-8
2,632
3.15625
3
[]
no_license
require "gothonweb/map.rb" require "test/unit" class TestMap < Test::Unit::TestCase def test_room() gold = Map::Room.new("GoldMap::Room", """This room has gold in it you can grab. There's a door to the north.""") assert_equal("GoldMap::Room", gold.name) ...
true
7d4da1956f4b023c2593720c3fc031e829051ed8
Ruby
mitsukan/oyster_card
/spec/oystercard_spec.rb
UTF-8
3,132
3.390625
3
[]
no_license
require './lib/oystercard' describe Oystercard do # let(:class) {double(:label)} #the symbol in the let statement is just shitty rspec syntaxing. it "has a balance" do expect(subject.balance).to eq(0) end it "has a journey tracker" do expect(subject.in_journey).to eq(false) end it "has an empty j...
true
e5711a6541941492fd3bdbd0fe9105671d23cebc
Ruby
getadeo/code-snippets
/ruby-snippets/composition.rb
UTF-8
158
2.78125
3
[]
no_license
class Item attr_reader :name def initialize name, special_attributes = [] @id, @name = 1, name @special_attributes = special_attributes end end
true
1f45ce568194003783ec08df196ed2f076224cad
Ruby
Papipo/tongo
/lib/tongo/parser.rb
UTF-8
1,348
2.65625
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
module Tongo class Parser attr_reader :ns def call(src) src = "<root xmlns:#{@ns}=\"http://blog.codecaster.es\">#{src}</root>" doc = Nokogiri::XML::DocumentFragment.parse(src) traverse_children(doc.children) end def initialize(options = {}) @ns = options[:ns] || 'tng'...
true
56e7529dd60f6a1970ba8e16efe8cc1b27fcfa93
Ruby
Katy600/gilded-rose
/gilded_rose_spec.rb
UTF-8
2,987
3.078125
3
[]
no_license
# All items have a SellIn value which denotes the number of days we have to sell the item # - All items have a Quality value which denotes how valuable the item is # - At the end of each day our system lowers both values for every item require File.join(File.dirname(__FILE__), 'gilded_rose') describe GildedRose do...
true
310e53185511d51d8e8c87579fb62270f2ae7b06
Ruby
kaylee42/my-select-001-prework-web
/lib/my_select.rb
UTF-8
134
3.484375
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def my_select(collection) new_array = [] for item in collection new_array.push(item) if yield(item) == true end new_array end
true
c7599a4607334d1b33cba153be1d894e948149b9
Ruby
ivan-selchenkov/tevi.ru
/app/models/picture.rb
UTF-8
751
2.546875
3
[]
no_license
class Picture < ActiveRecord::Base has_and_belongs_to_many :galleries has_attached_file :image has_attached_file :thumb, :styles => { :meduim => "250x250>", :thumb => "150x150>" } validates :name, :presence => true validates :description, :presence => true validates :image, :presence => true validates ...
true
64adde77a93e76b74aa997ae26c833492af875e5
Ruby
DavidBarriga-Gomez/Enigma
/test/shift_test.rb
UTF-8
403
2.78125
3
[]
no_license
# require 'simplecov' # SimpleCov.start require 'minitest/autorun' require 'minitest/pride' require './lib/shift' require 'pry' class ShiftTest < Minitest::Test def setup @shift = Shift.new("00000", "09132019") end def test_existence assert_instance_of Shift, @shift end def test_initialized as...
true
1d27d5bb680576c53e8733d8ccb9690ce82c0b15
Ruby
sophiewo/secret_diary
/lib/secret_diary.rb
UTF-8
582
3.5
4
[]
no_license
class SecretDiary attr_reader :locked, :diary_pages #not sure adding diary pages here is good practice even though it satisfys test? def initialize @locked = true @diary_pages = [] end def unlock @locked = false end def lock @locked = true end def add_entry(entry) fail "Diary ...
true
d534fb3157781e14fb0e536bb475ebfbae9528d9
Ruby
RobotOptimist/event_manager
/lib/event_manager.rb
UTF-8
2,373
3.15625
3
[]
no_license
require "csv" require "sunlight/congress" require 'erb' require 'date' Sunlight::Congress.api_key = "8c7a9be6703a42f296f40a3aebeeba5f" def clean_zipcode(zipcode) zipcode.to_s.rjust(5,"0")[0..4] end def legislators_by_zipcode(zipcode) Sunlight::Congress::Legislator.by_zipcode(zipcode) end def save_thank_you_lette...
true
c778bf49733d218477404d73c5fb1553d9f79641
Ruby
ARozputnii/RoR-Ruby-Basics
/1 lesson/53.rb
UTF-8
311
3.59375
4
[]
no_license
# Дан целочисленный массив. #Найти количество элементов, #расположенных перед последним максимальным. print arr = [1, -1, 3, 4, 5, -5, 44, 55, -100, 100] max_arr = arr.index(arr.max) puts print arr[0...max_arr].size puts
true
44c2a7b9c5708375c1c4852f6abe405031865d9f
Ruby
dgilbs/exercises
/roman_numerals.rb
UTF-8
1,064
4.4375
4
[]
no_license
require 'pry' ##Attempting to write an algorithm that would allow the computer to evaluate Roman Numerals. ##Took an object-oriented approach, the algorithm itself is in the #evaluate method class RomanNumeral attr_accessor :numerals def initialize(numerals) @numerals = numerals end def compare_nume...
true
014de8df79c563eeafe66804d1681c75327eb731
Ruby
MikeUrban93/marskal-doc
/lib/marskal/rdoc/samples/directives.rb
UTF-8
2,376
2.625
3
[ "MIT" ]
permissive
module Marskal module Rdoc module Samples ## # Directives. This module should have a method for most of the common doc modifiers for RDoc # # *NOTE:* RDoc Directives may not be available in the +Yard+ # # :include:../includes/reference_links.rb # {include:file:lib/marska...
true
771e57ee9def3d258224fd37084ff4f65241e0a4
Ruby
DAdDY0055/ruby-practice
/zero_ruby/rubybook/chapter2/practice/2-3.rb
UTF-8
389
3.15625
3
[]
no_license
coffee_price = 300 shot_price = 100 puts "コーヒー:" + coffee_price.to_s + "円" puts "合計:" + (coffee_price + shot_price * 2).to_s + "円" coffee_price = 400 shot_price = 100 puts "コーヒー:" + coffee_price.to_s + "円" puts "合計:" + (coffee_price + shot_price * 2).to_s + "円" puts "コーヒー: #{coffee_price}円" puts "合計: #{coffee_price...
true
b6cbe3b882313b203aef433c0d8d860680730dd8
Ruby
danpaulgo/ticket-track
/spec/models/performer_spec.rb
UTF-8
1,616
2.53125
3
[]
no_license
require 'rails_helper' RSpec.describe Performer, type: :model do include_context "fixtures" it 'has all necessary fields' do expect(Performer.new).to respond_to(:name) end it "is valid with a name" do expect(performer).to be_valid end it "is invalid without a name" do performer.name = nil e...
true
2151a776337546f8b99c6a34466286ae7366961d
Ruby
kdstearns/ruby_april_2018
/kyla_stearns/Fundamentals/basic13.rb
UTF-8
1,615
4.125
4
[]
no_license
# Print 1-255 p (1..255).to_a # Print odd numbers between 1-255 (1..255).to_a.select { |elem| p elem if elem.odd? } # Print Sum def print_sum sum = 0 for i in (1..255) p "Number: #{i} and Sum: #{sum = sum + i}" end end print_sum # Iterating through an array x = [1,3,5,7,9,13] x.each { |i| p i } # Find Max def...
true
0ab356355b81321f810419f391d66862ac2c6828
Ruby
d12/leetcode-solutions
/0268-missing_number.rb
UTF-8
322
3.296875
3
[]
no_license
# O(N) time, O(1) space def missing_number(nums) saw_a_zero = false max = 0 sum = 0 nums.each do |i| max = [max, i].max saw_a_zero = true if i == 0 sum += i end max_sum = (0..max).to_a.sum # Couldn't remember Gauses formula dif = max_sum - sum dif == 0 ? (saw_a_zero ? max + 1 : 0) : dif e...
true
1da490814549af2b4e8cab446bc74e9ba8f60b92
Ruby
adamruzicka/mqpi
/lib/mqpi/handler.rb
UTF-8
1,021
2.515625
3
[]
no_license
module MQPI class Handler attr_accessor :name, :port, :host, :job_options def initialize(name: nil, port: nil, host: nil, logger: Logger.new(STDOUT), job_options: {}) @name = name @port = port @host = host @logger = logger @job_options = job_options end def run cli...
true
63ae75f5a6418ac3f0df038998f342211bb0e9c8
Ruby
chrispjacobs/oo-tic-tac-toe-cb-000
/lib/tic_tac_toe.rb
UTF-8
2,835
4.34375
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class TicTacToe def initialize(board = nil) @board = board || Array.new(9, " ") end WIN_COMBINATIONS = [ [0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 3, 6], [1, 4, 7], [2, 5, 8], [0, 4, 8], [2, 4, 6] ] def display_board puts " #{@board[0]} | #{@board[1]} | #{@board[2]} " ...
true
9c3a6be32ff93abebf354e023517fe7e9a35ffd0
Ruby
urbanautomaton/template_tree
/lib/template_tree/node.rb
UTF-8
1,619
3.296875
3
[ "MIT" ]
permissive
require 'template_tree/errors' require 'template_tree/formatters/ascii' module TemplateTree class Node attr_accessor :name, :parent, :children def initialize(name, parent) @name, @parent = name, parent @children = [] end def to_a [name, children.map(&:to_a)] end def to_s(...
true