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
3520a0c404c1ad1526ac0fee73f4e206eaf7546c
Ruby
rlcheng/tic_tac_toe
/launch.rb
UTF-8
573
2.859375
3
[]
no_license
require_relative 'game' require_relative 'user_interface' def select_order choice = @UI.get_choice @player = Player.new(choice, @UI) @UI.message("You are Player #{@player.marker}") if choice == 1 @cpu = Cpu.new(2) @current_player = @player else @cpu = Cpu.new(1) @current_player = @cpu end ...
true
432ca78ba87ac8d79fff9c20bbd1af2f7ffc488e
Ruby
saito-y2014/Ruby-training
/Lesson3/vartest1.rb
UTF-8
74
3.03125
3
[]
no_license
# encoding: utf-8 hensuu = "Ruby" puts("変数値は hansuu です。")
true
585c1634da153fe23ef62b27aec2c45bc9993c0b
Ruby
OrlaC15/A3_Tutor
/stage.rb
UTF-8
386
3.578125
4
[]
no_license
class Stage attr_reader :stage def initialize (start_level, end_level) @end_level = end_level @start_level = start_level @stage = start_level end def level_down if @stage>@start_level @stage-=1 else @stage = @start_level end end def level_up if @stage<@end_level ...
true
015c3693be83558c64a1a812975e72bed8f6eff7
Ruby
Projamming/Practice
/HomieWippman/Clojure Practice and Notes from Class Day3.rb
UTF-8
1,084
3.859375
4
[]
no_license
;; TODAY: for loops, if statements ;; loops ;; (for [i (range 10)] (* i 2)) ;; (for [cat primes dogs '(2 3 4)] (+ cat dog)) ;; (def daves_list '("a" "b" "c" "d" "e" "f" "g")) ;; (for [k '(1 3 5)] (nth daves_list k)) ;; Ruby Version: ;; daves_list = ["a", "b", "c", "d", "e", "f", "g"] ;; for k in [1, 3, 5] ;; puts d...
true
f9aa490e7a6a06887afb8adfd6556081fd5d3f90
Ruby
daryakuritsyna/lesson1
/lesson1.rb
UTF-8
570
3.859375
4
[]
no_license
require 'date' class Lesson1 def sum(val = 0) val.to_s.chars.map(&:to_i).inject(:+) end def age(birthday) if birthday days = (Date.today - Date.parse(birthday)).to_i "Я живу #{(days / 365).to_i} или #{days} дней или #{days * 24} часов или #{days * 24 * 60} минут или #{days * 24 ...
true
409c70cfbbb5649296aebd2249ae61a6a6095398
Ruby
igkuz/self_testing_framework
/lib/self_testing_framework/test_case.rb
UTF-8
381
2.609375
3
[ "MIT" ]
permissive
module SelfTestingFramework class TestCase class << self def run(name) iam = new iam.before iam.send(name) iam.after end end def before end def after end def assert(arg, fail_message = nil) fail_message ||= "Assertion Fails" raise...
true
cbcc5a705b2cc45f6e78c102cc620ddb03fbefc5
Ruby
ph8tel/ruby
/B/spec/08_bubble_sort_spec.rb
UTF-8
451
3.6875
4
[]
no_license
# github.com/ph8tel require '../bubble_sort' require 'rspec' # The function `bubble_sort(arr)` will sort an array of # integers using the "bubble sort" # methodology. describe "#bubble_sort" do it "works with an empty array" do bubble_sort([]).should == [] end it "works with an array of one item" do ...
true
5f2e8ad10365b868e5b2703099ae0e5ad105514f
Ruby
iota-cohort-dc/Daniel-Perez
/Ruby/firstVagrantBox/rubyEx/array.rb
UTF-8
458
3.46875
3
[]
no_license
def guess_number guess number= 25 if guess == number puts "Correct" elsif guess > number puts "number too high" else puts number too low end end guess_number 88 arr = ["one", "two", "three", "four", "five", "six"] #puts arr.at(3) #puts arr.slice!(2) ##puts arr #puts arr.reverse #puts arr...
true
3710a5d0565a47eaf6823237a68f0847d3652060
Ruby
stac47/ruby-sandbox
/00-basics/arguments.rb
UTF-8
438
2.8125
3
[ "MIT" ]
permissive
#!/usr/bin/ruby -w # vi:set fileencoding=utf-8 : # # Created on 2013-12-23 # # @author : Laurent Stacul # # Simply display the arguements passed to the program. # # $ ruby 00-basics/arguments.rb test test test 2>~/err.log # # The arguments are displayed on standard and error output channel. The # previous command will ...
true
7dcb1fd41f03e1a68baf47efa3cbe24d75d51537
Ruby
stavnycha/fuzzy_classnames
/lib/fuzzy_classnames/finder.rb
UTF-8
1,286
3.109375
3
[]
no_license
require_relative "../ext/string" require_relative "file_reader" require_relative "lexer" module FuzzyClassnames class Finder attr_reader :pattern, :filename def initialize(pattern, filename) @pattern = pattern.to_s @filename = filename unless @pattern.lower? || @pattern[0].upper? ...
true
561fd5e47fb321b0df5b74fd98bf969dfb63f849
Ruby
azhou31/Ruby-Fundamentals-OOP
/OOP/Humans/ninja.rb
UTF-8
316
3.140625
3
[]
no_license
require_relative : 'human' class Ninja < Human attr_reader :stealth def initialize @stealth = 175 self end def steal if obj.class.ancestors.include?(Human) @health += 10 self end end def get_away @health -= 15 end end
true
7b1e7d21ae0d29f2e5b6dc53c92865ae8cd3f3aa
Ruby
CapellutoY/THP_Semaine3_Jour2
/tictactoe.rb
UTF-8
4,040
3.703125
4
[]
no_license
class Game attr_accessor :name, :boardcase, :board def initialize(name1,name2) @name1 = name1 @name2 = name2 end def self.winning_condition(boardcase) #verifie si une condition gagnante a ete remplie# n=0 if boardcase[0] == "X" && boardcase[1] == "X" && boardcase[2] == "X" puts "Joueur 1 vo...
true
812560014a3dc92afee0f1c3cfaaf760b497e858
Ruby
JPprojects/Oystercard
/spec/station_spec.rb
UTF-8
521
2.828125
3
[]
no_license
require "station.rb" describe Station do it "should create a new instance of itself" do oldstreet = Station.new("old_street", "zone_1") expect(oldstreet).to be_instance_of Station end it 'should initialize a name instance variable' do oldstreet = Station.new("old_street", "zone_1") expect(oldstre...
true
109c36ac1d1c4c6aa845c79dc0eeaa5dc12dab53
Ruby
idinyte/Connect-Four-TDD
/lib/display.rb
UTF-8
755
3.578125
4
[]
no_license
# frozen_string_literal: true class Display def rename_message(default) "#{default} change your name if you wish or press enter to continue" end def show_board(a) x = a[0].length y = a.length board = '' y.times do |i| x.times do |j| board += "|#{a[y-i-1][j]} " end b...
true
e811df0e9954c0a34e1fe9dd0a4e6607bd2a9011
Ruby
shinokaro/evolve_defence
/simulation.rb
UTF-8
1,142
3.1875
3
[]
no_license
class Simulation def initialize(monster) @turn = 0 @monster = monster @map = Map.new.map end def result(num) num.times{step} return @monster end def step return if(finished?) @map.each_with_index do |x,i| x.each_with_index do |y,j| case y when 1 i...
true
2f81a547fecd44c4a44ee5ead36b55c1a49a5783
Ruby
Saicheg/bsuir-courses
/2016/NikitaKolokoltsev/homework-2/lib/exceptions.rb
UTF-8
620
2.96875
3
[]
no_license
DATE_FORMAT_ERROR = " Incorrect date format! Available formats: dd-mm-yyyy dd.mm.yyyy dd/mm/yyyy. Try again. ".freeze SEMESTER_DATE_ERROR = " The end of the semester cannot be earlier than its beginning. Try again. ".freeze LABS_COUNT_FORMAT_ERROR = " Incorrect number of labs. Try again. ".freeze SUBJECT_FORMAT_ERRO...
true
80e15c4a4d34081040baf9393d011e87ad7d15e5
Ruby
salvadorJimenez/ruby_basics
/chapter_11/build_a_better_playlist.rb
UTF-8
1,275
3.671875
4
[]
no_license
# build a better playlist def shuffle words unsorted_array = [] while words.length > 0 random_index = rand(words.length) unsorted_array.push(words.slice!(random_index)) end unsorted_array end def music_shuffle playlist playlist.sort! next_value = "" shuffled_array_final = [] playlist.each do |s...
true
8a538b78b87ecd40c2f8465b004aabf488f66c31
Ruby
NiaK-130/091921-Phase-3-Code-Challenge-Reviews
/db/seeds.rb
UTF-8
1,436
3.140625
3
[]
no_license
# This will delete any existing rows from the Product and User tables # so you can run the seed file multiple times without having duplicate entries in your database puts "Deleting old data..." Product.destroy_all User.destroy_all puts "Creating users..." user1 = User.create(name: Faker::Name.name) user2 = User.create...
true
6822eada4fca9c9de37147e568ae9c33309921e3
Ruby
LogInsight/logstash
/qa/integration/framework/fixture.rb
UTF-8
2,037
2.671875
3
[ "Apache-2.0" ]
permissive
require_relative "../services/service_locator" # A class that holds all fixtures for a given test file. This deals with # bootstrapping services, dealing with config files, inputs etc class Fixture FIXTURES_DIR = File.expand_path(File.join("..", "..", "fixtures"), __FILE__) attr_reader :input attr_reader :actua...
true
e78d82bafc89344833bfd81c3cda1cb25e0b1b19
Ruby
nicnilov/face_rec
/lib/face_rec/prepare.rb
UTF-8
1,931
2.90625
3
[]
no_license
require 'highline/import' require 'pry' module Prepare def self.execute source_dir = request_source_directory image_index = request_image_index filenames = group_file_names(source_dir) known_dir = request_destination_known_directory unknown_dir = request_destination_unknown_directory populate...
true
5f26397800fae8d9434cd7b6fddebd5ba47f553b
Ruby
sofibraun/connect-four
/app/models/board.rb
UTF-8
2,114
3.40625
3
[]
no_license
class Board < ActiveRecord::Base class ColumnIsFullException < Exception; end belongs_to :game validates_presence_of :player_1_id, :player_2_id, :rows, :cols before_create :initialize_board def play!(column, player_id) row = find_free_row(column) self.cells[row][column] = player_id s...
true
0545e3d6f8b7924569c5ba4ab105fd7a2aaa0b2d
Ruby
learn-co-students/dc-web-040119
/06-many-to-many/user.rb
UTF-8
1,098
3.390625
3
[]
no_license
class User attr_reader :username def initialize(username) @username = username end def tweets Tweet.all.select do |tweet| tweet.user == self end end def post_tweet(text) Tweet.new(text, self) end def like_tweet(tweet) Like.new(tw...
true
93078eb5a606b5bd81706d2d70827280ec97a2e0
Ruby
ruyielder/TicTacToe
/app/field_value_line_enumerator.rb
UTF-8
1,275
3.296875
3
[]
no_license
class FieldValueLineEnumerator include Enumerable def initialize(fields) @fields = fields @row_count = fields.size @column_count = fields.size end def each each_horizontal_line do |line| yield line end each_vertical_line do |line| yield line end each_cross_line do...
true
3ca79c4389e70409f908fff5b9ed20d0ebb20832
Ruby
thp-grenobles8/s08.todolist-app.gui
/db/seeds.rb
UTF-8
2,264
2.78125
3
[]
no_license
# This file should contain all the record creation needed to seed the database with its default values. # The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup). # # Examples: # # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) # Ch...
true
722953842906db0c21364234e3740328165e86a0
Ruby
jenf/18xx
/lib/engine/action/buy_train.rb
UTF-8
649
2.625
3
[ "MIT" ]
permissive
# frozen_string_literal: true require_relative 'base' module Engine module Action class BuyTrain < Base attr_reader :train, :price, :exchange def initialize(entity, train, price, exchange = nil) @entity = entity @train = train @price = price @exchange = exchange ...
true
66b39aafa4616b845dc0d72ebaa1d118d70f68fe
Ruby
Yiazmat1/Me-Learning-Ruby
/While_simple_loop.rb
UTF-8
77
2.921875
3
[]
no_license
$i = 1 $cont = 5 while $i <= $cont do puts ("Loop i = #$i") $i += 1 end
true
97d0066dc5ce3fbfeccb9321b2708f47fc48c3da
Ruby
puma/puma
/test/test_example_cert_expiration.rb
UTF-8
1,317
2.515625
3
[ "BSD-3-Clause" ]
permissive
require_relative 'helper' require 'openssl' # # Thes are tests to ensure that the checked in certs in the ./examples/ # directory are valid and work as expected. # # These tets will start to fail 1 month before the certs expire # class TestExampleCertExpiration < Minitest::Test EXAMPLES_DIR = File.expand_path '../ex...
true
b810cbc76dedccab628642d29e6615e9c98cf836
Ruby
gerdadecio/bitmap_editor
/lib/parser.rb
UTF-8
401
2.953125
3
[]
no_license
require './lib/errors' class Parser def parse(file) raise Errors::IncorrectFile.new if file.nil? || !File.exists?(file) commands = [] File.open(file).each do |line| line = line.chomp commands << parse_line(line) end commands end private def parse_line(line) commands = {}...
true
13f07389ac6eb3759a3a77cff0dfe5abe68da5e1
Ruby
JKCodes/ecommerce-app-api
/app/models/cart.rb
UTF-8
1,137
2.609375
3
[]
no_license
class Cart < ApplicationRecord belongs_to :user has_many :line_items, dependent: :destroy has_many :items, through: :line_items def add_item(item, quantity) if item.inventory != 0 line_item = self.line_items.find_by(item_id: item) if line_item line_item.update(quantity: set_quantity(lin...
true
c46161541f5a0a9f5a56b4dcd2dc5eb3bb9045ec
Ruby
andrewdmoore408/LS-RB130-Exercises
/easy_1/optional_blocks.rb
UTF-8
716
4.4375
4
[]
no_license
=begin Optional Blocks Write a method that takes an optional block. If the block is specified, the method should execute it, and return the value returned by the block. If no block is specified, the method should simply return the String 'Does not compute.'. =end # def compute # if block_given? # yield # els...
true
d60b2a0f8fbab0dad12c55de33d6f09c8d8e0c80
Ruby
WJLiddy/woodshedrecords
/piano.rb
UTF-8
1,538
2.921875
3
[]
no_license
require_relative "music_common" def gen_chord_event(chord,len) events = [] chord_root, chord_quality = get_intervals(chord) invert(chord_quality,1) while ((chord_quality.sum / chord_quality.count) < 45) chord_quality.each do |i| events << MIDI::NoteOn.new(0, chord_root + i, 127, 0) end chord_quality.each_...
true
6231d46c833093c14748b020830d45df06e3bde6
Ruby
nickstenning/outback
/spec/outback/task_spec.rb
UTF-8
1,150
2.84375
3
[]
no_license
require File.dirname(__FILE__) + '/../spec_helper' describe Outback::Task do before do @task = Outback::Task.new end it "should take an optional block on its constructor, passing itself in as the block parameter" do lambda { @task = Outback::Task.new }.should_not raise_error temp = nil @task ...
true
928c82eb92f74d23ffed7c0d54c0557fd6f9ca09
Ruby
evanphx/prattle
/lib/vendor/kpeg/lib/kpeg.rb
UTF-8
19,348
2.890625
3
[]
no_license
require 'strscan' module KPeg class ParseFailure < RuntimeError; end class Parser < StringScanner def initialize(str, grammar) super str @grammar = grammar # A 2 level hash. @memoizations = Hash.new { |h,k| h[k] = {} } @failing_pos = nil @failing_rule = nil end a...
true
b9e87a68569d192133f7a184e9f14a232e7875f1
Ruby
ToshiDono/patients
/app/decorators/has_human_date.rb
UTF-8
268
2.828125
3
[]
no_license
module HasHumanDate def human_created_at human_date_on(:created_at) end def human_date_time human_date_on(:date_time) end def human_date_on(field) date(send(field)) end private def date(date) date.strftime("%d - %m - %Y") end end
true
f773b22ed54925113be81efa3bb33a7f73a66024
Ruby
cnees/neochess
/app/controllers/chessboards_controller.rb
UTF-8
1,666
2.625
3
[]
no_license
class ChessboardsController < ApplicationController def petpage render 'chessboards/petpage' end def svg @letter_pieces = letter_pieces board = Chessboard.for_player(player) path = get_path(request) if valid_square?(path) @square = path if board.selected_square? begin ...
true
b59ae637599488e6c31d0a3658f990019eec1d45
Ruby
DeepakUp9/Ruby_Basic_Code
/Basic/Calculator.rb
UTF-8
638
4.15625
4
[]
no_license
# cancation between the number puts "Enter a number :" num1=gets.chomp() puts "Enter Another number :" num2=gets.chomp() puts(num1 + num2) # converting into Integer and then add puts "Enter a number :" num1=gets.chomp() puts "Enter Another number :" num2=gets.chomp() puts(num1.to_i + num2.to_i) # converting int...
true
98c735c948d8a51517ddcd60bfbf004ad1e1cf38
Ruby
Pussy-sultan/labs
/lab7/part1/lb7_1.rb
UTF-8
533
3.640625
4
[]
no_license
# lb7_1.rb # class class Text attr_accessor :str def initialize(f = 'F.txt',h = 'H.txt') @file_f = f @file_h = h end def make File.open(@file_f, 'r'){ |file| @str = file.read } File.open(@file_h, 'w'){ |file| for i in 0..@str.length if @str[i] == "a" file....
true
aa94835b6ff521926e01b124494b987a15726483
Ruby
sammbeller/EulerProject
/Stack.rb
UTF-8
275
3.484375
3
[]
no_license
#Stack.rb require 'LinkedList' class Stack attr_accessor :top def initialize() @top = nil @list = LinkedList.new() end def empty?() @top == nil end def pop @list.delete(0) end def push(data) @list.insert(data, 0) end def peek @list.head end end
true
48549cc8465f9c7c15fd39d80d78f6774370104f
Ruby
fluxusfrequency/nugz
/lib/nugz/stores.rb
UTF-8
320
2.515625
3
[ "MIT" ]
permissive
module Nugz class Stores def self.all response = Faraday.get('http://www.milehighbuzz.co/api/v1/stores') JSON.parse(response.body) end def self.find_store(slug) response = Faraday.get("http://www.milehighbuzz.co/api/v1/stores/#{slug}") JSON.parse(response.body) end end end
true
9877687981c8f91ed56c7aadb83713d382a36e05
Ruby
SymmetricInDesign/AA-Homework
/W4D3/skeleton/lib/simon.rb
UTF-8
1,118
3.734375
4
[]
no_license
class Simon @@COLORS = %w(red blue green yellow) attr_accessor :sequence_length, :game_over, :seq def initialize @sequence_length = 1 @game_over = false @seq = [] end def play until @game_over self.take_turn end self.game_over_message self.reset_game end def take_turn...
true
5521ed08b2b8176b3da896910296d0c1a799d986
Ruby
eewang/warbygram
/lib/tasks/import_product_csv.rake
UTF-8
850
2.6875
3
[]
no_license
require 'csv' desc 'Imports product info CSV file into ActiveRecord table' task :import => :environment do glasses = CSV.open "lib/frames_productinfo.csv", headers: true, header_converters: :symbol glasses.each do |row| name = row[:style] color = row[:color] collection = row[:collection] optical = row[:opt...
true
8ee55a7357d05fc1b0d157bf8f42943b314e8f2d
Ruby
singhshivam/leetcode
/200.rb
UTF-8
494
3.5
4
[]
no_license
# https://leetcode.com/problems/number-of-islands/ # @param {Character[][]} grid # @return {Integer} def num_islands(grid) islands = 0 grid.each_with_index { |arr, i| arr.each_with_index { |el, j| if el == "1" islands += dfs(grid, i, j) end } } islands end def dfs(grid, i, j) if i < 0 || i >= grid....
true
cfd18e9aea2766d63ae6d9e88d5ebfc2e5866587
Ruby
Abeleda/video-fetcher
/app/services/scanner/vimeo.rb
UTF-8
1,405
2.640625
3
[ "MIT" ]
permissive
require 'action_view/helpers/text_helper' include ActionView::Helpers::TextHelper module Scanner class Vimeo PER_PAGE = 50 # Do not set this more than 50 BREAK_AFTER = 1000000 def initialize(channel, number_of_pages=BREAK_AFTER) channel_id = channel.url[/[^\/]*\Z/] @channel = API::Vimeo.new...
true
860a533e19e7a803f2fe60fe12f0b0e5119eb512
Ruby
yyvettey/hw-ruby-intro
/lib/ruby_intro.rb
UTF-8
971
3.953125
4
[]
no_license
# When done, submit this entire file to the autograder. # Part 1 def sum arr # YOUR CODE HERE arr.inject(0, :+) end def max_2_sum arr # YOUR CODE HERE if arr.length == 0 return 0 elsif arr.length == 1 return arr[0] else arr = arr.sort return arr[-1] + arr[-2] end end def sum_to_n? arr,...
true
9bbaeeb43285615407e8d965cc98e1ed3883852a
Ruby
AsadK47/Fizzbuzz
/spec/fizzbuzz_spec.rb
UTF-8
817
3.359375
3
[]
no_license
require "fizzbuzz" describe "Fizzbuzz" do numbers = (1..100) it "Returns 'fizz' when input is a multiple of 3" do numbers.each do |num| if num % 3 == 0 && num % 5 != 0 expect(num.fizzbuzz).to eq("fizz") end end end it "Returns 'buzz' when input is a multiple of 5" do numbers.ea...
true
bcbd267b6388f6f190a8b14ba4903d867f50b236
Ruby
clarehsu390/LeetCode
/Ruby/longest_substring.rb
UTF-8
412
3.625
4
[]
no_license
def length_of_longest_substring(string) count = string[0] string.each_char.with_index do |ch, idx| (idx+1..string.length - 1).each do |j| if string[idx..j].chars.uniq == string[idx..j].chars count = string[idx..j] if string[idx..j].length >= count.length end ...
true
e7684d223a231741e2bc099867eafdd42ab5386d
Ruby
angelbotto/psd.rb
/lib/psd/layer.rb
UTF-8
9,431
2.5625
3
[ "MIT" ]
permissive
class PSD # Represents a single layer and all of the data associated with # that layer. class Layer include Section attr_reader :id, :mask, :blending_ranges, :adjustments, :channels_info attr_reader :blend_mode, :layer_type, :blending_mode, :opacity, :fill_opacity attr_reader :channels, :image ...
true
450dcb207bd6556ed225cb87a0bfd5d5a5c1d256
Ruby
jags-aaron/CursoRuby
/METODOS/Metodo Constructor/main.rb
UTF-8
196
3.03125
3
[]
no_license
require_relative 'clsGato.rb' cat = Gato.new("maru", "casero") puts cat.dame_nombre puts cat.dame_raza print "\n" cat2 = Gato.new("Kiba", "Tigre") puts cat2.dame_nombre puts cat2.dame_raza gets()
true
9af44db3d47165a0aa05210fd416969384812c07
Ruby
rkh/rubinius
/kernel/bootstrap/compiled_method.rb
UTF-8
1,069
2.75
3
[ "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
module Rubinius class CompiledMethod < Executable def self.allocate Ruby.primitive :compiledmethod_allocate raise PrimitiveFailure, "CompiledMethod.allocate primitive failed" end def dup Ruby.primitive :compiledmethod_dup raise PrimitiveFailure, "CompiledMethod#dup primitive fail...
true
f627f46bf600c22322dda08f30b377c9d0c7f546
Ruby
kathdovi/Exercises-for-Programmers
/rb/Exercise9.rb
UTF-8
252
3.609375
4
[]
no_license
print "Enter length: " length = gets.chomp.to_i print "Enter width: " width = gets.chomp.to_i area = length * width gallons_needed = (area.to_f/350).ceil puts "You will need to purchase #{gallons_needed} gallons of paint to cover #{area} square feet."
true
4805a3a86114fb791594a7111bbc2955dbabb6ea
Ruby
sydney-sisco/TwO-O-Player-Math-Game
/game.rb
UTF-8
902
4
4
[]
no_license
require './player.rb' require './turn.rb' class Game def initialize(player_count) @player_count = player_count @current_player = 0 @players = [] (1..@player_count).each do |i| @players << Player.new("Player #{i}") end end def next_player @current_player = (@current_player + 1) % ...
true
189257717c2576a24f71efba868436008887c487
Ruby
cmonterrosa/tree
/app/controllers/main_controller.rb
UTF-8
4,211
2.609375
3
[]
no_license
############################################ # Controller to link with folder ############################################ require "pathname" class MainController < ApplicationController def index #@hash = directory_hash("/var/www/html/owncloud/data/cmonterrosa/files/CONSEJO DE LA JUDICATURA") #@hash = dire...
true
8216119396a0557b5472778866130067c5e06403
Ruby
bion/slither
/lib/identify_entity.rb
UTF-8
531
2.625
3
[]
no_license
require 'mechanize' require_relative './identify_entity/entity_builder' class IdentifyEntity attr_reader :uri def self.run(*args) new(*args).run end def initialize(uri) @uri = uri end def run return nil unless builder entity = builder.find_or_build_entity return nil unless entity ...
true
387023fdd388553fa00628fa6eb83ff9541840e6
Ruby
cardo22/Ironhack
/week1/Projects/ruby/ruby_examples.rb
UTF-8
335
3.359375
3
[]
no_license
# p escaped_string = "This is Sharon's escaped string" # movie = "Ricardo" # puts "My favourite movie is #{movie}" # 10.times { # puts 'beetlejuice' # } my_array = ["Hello", "Hi", 2] # puts my_array[2] my_array << "hey" puts my_array.inspect my_array.delete_at 2 puts my_array.inspect my_array = [10,8,9,7...
true
a9f223ef0835181c7a8a1d8978f83cd5e0540010
Ruby
soolydev/Lruby
/exo_09.rb
UTF-8
161
3
3
[]
no_license
puts "Quel est votre nom ?" userLastname = gets.chomp puts "Quel est votre prenom ?" userFirstName = gets.chomp puts "Bonjour , #{userLastname} #{userFirstName}"
true
3a2adf9c693ff2d1a03bd54a017dc9d82378bc72
Ruby
MichaelBeamish/2-12
/while2.rb
UTF-8
81
2.859375
3
[]
no_license
rand_num = nil while rand_num != 7 do puts rand_num rand_num = rand(1..10) end
true
ec515673d2675e7bd59dba2b013422195650b4c0
Ruby
Jhay-M/Ruby-Exercises
/lib/fibonacci.rb
UTF-8
402
4.03125
4
[]
no_license
def fibs(int, result = [0, 1]) if int == 1 result = 0 elsif int == 2 result = 0, 1 else i = 2 while i < int new_int = result[i - 2] + result[i - 1] result << new_int i += 1 end result end end def fibs_rec(int) return 0 if int == 1 return [0, 1] if int == 2 fibs_...
true
2323897a8c735f50d13ea830b0e4b89b585529ed
Ruby
wangliyao/test-rspec
/spec/models/contact_spec.rb
UTF-8
2,544
2.546875
3
[]
no_license
require 'spec_helper' describe Contact do it "is valid with a firstname ,lastname an email" do # contact = Contact.new( # firstname: "Aaron", # lastname: "Zs", # email: "tester@gmail.com" # ) expect(build(:contact)).to be_valid end #测试是否会出现预期的错误,进行数据验证 it "invalid without a...
true
40ec6440d38e46352261c85905bf01266b197e2a
Ruby
mkrakowiak/rspec-template
/zadanie3_nowe/spec/unit/polynominal_spec.rb
UTF-8
6,692
3.15625
3
[]
no_license
require_relative '../../lib/polynominal.rb' require 'simplecov' SimpleCov.start describe Polynominal do context "initialization" do it 'correct data' do expect { Polynominal.new([1,2],5) }.to_not raise_error end it 'works with fractions' do expect { Polynominal...
true
255b2c90060b737123a0d0604712ade5222dd690
Ruby
janx/crypto013
/feistel2.rb
UTF-8
226
3.328125
3
[]
no_license
def to_codes(s) s.scan(/../).map {|code| code.to_i(16) } end l20 = gets.chomp l21 = gets.chomp codes20 = to_codes(l20) codes21 = to_codes(l21) (0...codes20.size).each do |i| print(codes20[i] ^ codes21[i]) end puts "\n"
true
ab6ab714e4ff1f9b50d6de41dd176e3953605849
Ruby
ispzz/sei40-homework
/alistair_gray/week4/databases/pets-sql-site/server.rb
UTF-8
2,782
3.15625
3
[]
no_license
require 'sqlite3' require 'sinatra' require 'sinatra/reloader' def db_query(sql) puts '====================' puts sql puts '====================' db = SQLite3::Database.new 'database.db' db.results_as_hash = true results = db.execute sql db.close results # implicit return end # db_query # ROOT ROU...
true
2264e0d2160f13640e4d9c1dfcc762ccbe848cfe
Ruby
socializer/socializer
/app/models/socializer/activity.rb
UTF-8
8,335
2.515625
3
[ "MIT" ]
permissive
# frozen_string_literal: true # # Namespace for the Socializer engine # module Socializer # # Activity model # # {Socializer::Activity} objects are specializations of the base # {Socializer::ObjectTypeBase Object} # type that provide information about pending, ongoing or completed actions. # # Activiti...
true
8ecbdc0a51042771d5a5b13448292fd81c4b5f23
Ruby
kooshanfilm/Ruby
/Ruby-course/Part1/loop_conditionals.rb
UTF-8
226
3.5
4
[]
no_license
random_num = Random.new.rand(5) loop do print "Guss a number" ans = gets.chomp if (ans=="e") puts random_num break else if (ans.to_i == random_num) puts "wow" break else print "try again" end end end
true
6ef5113c5a438ecfffd202b05902a257b8548b9d
Ruby
tastycode/bay-bar
/app/route_menu.rb
UTF-8
416
2.71875
3
[]
no_license
class RouteMenu < NSMenuItem attr_reader :route def initialize(route) @route = route super() self.title = route.title self.submenu = NSMenu.new fetchStops end def fetchStops route.stops do |stops| stopGroups = stops.group_by(&:title) stopGroups.each do |title, groupStops...
true
9b301d5ea1696caf42e7fa837a003fc99e4c0cab
Ruby
mattiasarro/geckoboard-test
/lib/ruby-developer-test/word_source.rb
UTF-8
1,480
3.515625
4
[]
no_license
class WordSource def initialize(content="") @words = content.split(",").map(&:strip).reject(&:empty?) @words_cnt = Hash.new(0) @callbacks = Hash.new @idx = 0 end def run while next_word end end def next_word @words[@idx].tap do |word| if word @words_cnt[word] += 1...
true
25cb51a4944bc582d041b987bb952f2b7a8f3027
Ruby
jaelapen0/W3D5
/lib/00_tree_node.rb
UTF-8
1,198
3.453125
3
[]
no_license
require "byebug" class PolyTreeNode attr_accessor :parent, :children attr_reader :value def initialize(value) @value = value @parent = nil @children = [] end def parent=(node) #debugger old_parent = @parent old_parent.children.delete(self) unless old_parent == nil @parent = node...
true
952b96a0c295aadd1ff2892e81bb4daacffd3eab
Ruby
adamgriffis/satdatatracker
/app/models/satellite_datum.rb
UTF-8
1,217
2.578125
3
[]
no_license
class SatelliteDatum < ApplicationRecord validates_presence_of :altitude validates_presence_of :timestamp # no point in having a duplicate timestamp, no point in having a record without at timestam and altitude validates :timestamp, uniqueness: true MINIMUM_SAFE_ALTITUDE = 160 def self.stats last_five...
true
ed81799aec936f5abbf99b1c884f2f97e1bf3f83
Ruby
Subbareddyg/rubyPractice
/End.rb
UTF-8
258
3.03125
3
[]
no_license
END { puts "this should be invoked at the end of the program" } puts " let try this when this gets executed" BEGIN { puts " this should execute first " } =begin This is a comment. This is a comment, too. This is a comment, too. I said that already. =end
true
864b812fb04bad34debab26d49b600021583eefb
Ruby
pemacy/Launch_School
/Coursework/100/109/Exercises/Easy3/searching_101.rb
UTF-8
598
4.375
4
[]
no_license
require 'ordinalize' def input(num) arr = [] num.times do |n| if n == num - 1 puts "Enter the last number" arr[n] = gets.chomp.to_i else puts "Enter the #{(n+1).ordinalize} number" arr[n] = gets.chomp.to_i end end arr end def is_present?(arr) if arr[0..arr.size-2].include...
true
20102d5eb8ced4d27826d4e60fe272caa4c1988f
Ruby
emm-ess/Mareeba
/SuperPeer/messageHandler.rb
UTF-8
1,456
2.671875
3
[]
no_license
require 'logger' require_relative 'connectionManager' require_relative 'connection' class MessageHandler def initialize(peerID, logger) @peerID = peerID @logger = logger @serviceHndl = {} end def handleMessage(msg, con) if(@serviceHndl.has_key? msg["head"]["service"]) @serviceHndl[msg["h...
true
c3802280e48fb0e6f916590b4a945cd6ca9eb9f5
Ruby
ashbb/labyrinth
/lib/mk_labyrinth.rb
UTF-8
1,313
2.53125
3
[]
no_license
# mk_labyrinth.rb module Stages def mk_labyrinth n r1 = rect :left => 12, :top => 448, :width => 23, :height => 20 r2 = rect :left => 52, :top => 448, :width => 38, :height => 20 r3 = rect :left => 112, :top => 448, :width => 38, :height => 20 background forestgreen style Shoes::LinkHover, :fill =...
true
30c917d221cbb9e79a8721ecc02b8031f1e5a122
Ruby
tamouse/ruby-examples
/splatargdeflate.rb
UTF-8
733
3.390625
3
[ "MIT" ]
permissive
def splatargdeflate(args,argnames) return args unless args.is_a?(Array) return args if args.length < 1 if args.last.is_a?(Hash) last_arg = args.pop else last_arg = {} end # arg_hash={} # argnames.each_index do |i| # arg_hash[argnames[i]] = args.shift # end arg_hash = argnames.reduce(h={}){...
true
dd53cc4f02dafea35c8ac762d105f3dba028f627
Ruby
jch/scripts
/test/remove_assert_nothing_raised_expected.rb
UTF-8
272
2.828125
3
[ "MIT" ]
permissive
class Foo # inline blocks foobar # assigned inline blocks value = garply # preserve original level of nesting some :other do puts foo end # works for nested blocks inner :code do puts "inner" end outer :code do puts "outer" end end
true
8e6d386e8d04c07da71ef742c2c1dec258db0143
Ruby
adamesj/calculator
/spec/features/operators/subtraction_feature.rb
UTF-8
1,336
2.609375
3
[]
no_license
require 'rails_helper' describe "performing subtraction functions", :type => :feature, :js => true do it "subtracts two positive numbers" do visit root_path find('.button_6').click click_operator('-') find('.button_2').click find('.equals').click expect(find('#input').text).to eq '4' end...
true
fa595ed4d14b4055c0199eef11b0e23333ef06be
Ruby
garsiden/Peterstone-Birds
/lib/pbgraph.rb
UTF-8
3,365
2.6875
3
[]
no_license
require 'gruff' require 'sequel' require 'pp' class Gruff::Base DEFAULT_SIZE = '720x540' DEFAULT_THEME = 'psbirds' @spec = nil def theme_psbirds reset_themes @colors = [ '#2f5a11', # green '#664114', # brown '#290D45', # blue '#8C8296', ...
true
9896e9c74ffdfc6979664c9339ad27015613fed3
Ruby
JackRamos021495/anagram-detector-onl01-seng-ft-050420
/lib/anagram.rb
UTF-8
195
3.515625
4
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
# Your code goes here! class Anagram attr_accessor :word def initialize(word) @word = word end def match(words) words.select {|string|string.split("").sort == @word.split("").sort} end end
true
c08ef32a94a52b4510cd94c1a123160a98cec686
Ruby
rachaelghorbani/programming-univbasics-4-array-methods-lab-nyc01-seng-ft-080320
/lib/array_methods.rb
UTF-8
426
3.59375
4
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
def using_include(array, element) array.include?(element) end def using_sort(array) sorted_array = array.sort sorted_array end def using_reverse(array) reversed_array = array.reverse reversed_array end def using_first(array) first_element = array.first first_element end def using_last(array) last_el...
true
c1df63c25bbe0f4a4829cd23b11571401cbc758f
Ruby
mudafar/forecast
/app/models/city_location.rb
UTF-8
188
2.859375
3
[]
no_license
class CityLocation < City attr_accessor :latitude, :longitude def initialize(name, latitude, longitude) super(name) @latitude = latitude @longitude = longitude end end
true
229f2b2145751cc4c97f162dd12985cceb55aeb1
Ruby
luisreyesxv/ruby-oo-practice-relationships-domains-nyc01-seng-ft-062220
/app/models/air_bnb_trips.rb
UTF-8
351
2.875
3
[]
no_license
# create files for your ruby classes in this directory class Trip attr_accessor :guest, :listing, :status, :date @@all = [] def initialize(listing,guest,date) @guest = guest @listing = listing @status = "pending" @date = date @@all << self end def self...
true
5db9b663b1e88e98e1f4b9121b3782a6a8755f32
Ruby
bfpepper/black_thursday
/lib/customer.rb
UTF-8
472
2.90625
3
[]
no_license
class Customer attr_reader :id, :first_name, :last_name, :created_at, :updated_at def initialize(row, parent = nil) @id = row[:id].to_i @first_name = row[:first_name] @last_name = row[:last_name] @created_at = Time.strptime(row[:created_at], "%Y-%m-%d %H:%M:%S %z") @updated_at = Time.strptime(...
true
43fc04edf83531abc4cb14dd36879fb62c8cda18
Ruby
jonesan2/Ruby-small-problems
/interview_prep/test1.rb
UTF-8
245
3.0625
3
[]
no_license
def method1(str) ch_array = str.chars.each do |ch| ch.upcase! end ch_array.join end p method1("Hi everyone! Our session will start in about 10 minutes.") p method1("I will send links to Zoom and Coderpad at that time. See you soon!")
true
9a251b012ef8819cc934b66d30c480c03982a9b8
Ruby
cdrvfe/TowerDefence
/Wave.rb
UTF-8
1,049
3.046875
3
[]
no_license
# encoding: utf-8 require "./ReadFileModule.rb" class Wave attr_reader :isActive def initialize(filepath) @isActive = true @count = 0 @nowTime = 0 @enemyTime = [30,60,120,150,180] @enemyId = [1,1,1,1,1] createWaveFromFile(filepath) end def createWaveFromFile(filepath) filedata = ReadFileModule.rea...
true
8bba4f84acdca230f28b6597b03a22919af784f4
Ruby
fridl8/Portfolio-Tracker
/app/models/portfolio.rb
UTF-8
765
2.625
3
[ "MIT" ]
permissive
class Portfolio < ApplicationRecord validates :portfolio_name, presence: true belongs_to :user has_many :positions has_many :stocks, through: :positions def total_value value = 0 positions.each do |position| value += (position.stock.current_price.to_f * position.owned_shares) end valu...
true
c4ecdaf61ec38cfee9da7e91c192ff39dda52d79
Ruby
flyptkarsh/Cracking-The-Coding-Interview-Ruby-Solutions
/recursion_and_dynamic_programing/problems/parens.rb
UTF-8
1,220
4.53125
5
[]
no_license
# frozen_string_literal: true # 8.9 Parens: # Print all combinations of balanced parentheses # # Algorithm: # # Create a recursive function that accepts a string (s), count of opening brackets (o) and count of closing brackets (c) and the value of n. # if the value of opening bracket and closing bracket is equal to n...
true
4c72d3b578d428a50b3e2360139eb32bb2909242
Ruby
michaelengland/oauth2_server
/lib/oauth2_server/scope_authenticator.rb
UTF-8
313
2.546875
3
[ "MIT" ]
permissive
module Oauth2Server class ScopeAuthenticator def initialize(token) @token = token end def authenticate_scope!(scope) unless token.scopes.include?(scope) raise Errors::InsufficientScope.new(scope: scope) end true end private attr_reader :token end end
true
9492f2d06083b66a0590c1733ef7146d9b3c392a
Ruby
SinkLineP/RubyOnRails-18.08.2021
/Ruby on Rails/repozitories/ruby_development/ruby artem/projects/bak/4/MyApp2/lesson 10/cods/app3.rb
UTF-8
712
3.609375
4
[]
no_license
arr = [] #массив while true #цикл будет повторятся потому что стоит "true" puts "Кого добавить в список?: " y = gets.chomp! #обрезает пробелы if y == "stop" puts"все из списка" break #прерывает цикл, но не выходит из программы end arr << y #значеиния загоня...
true
0c205ef5d8b08779832abdcda98e492e1965db20
Ruby
katylouise/parliament-opensearch
/lib/parliament/open_search/description_error.rb
UTF-8
663
2.5625
3
[ "MIT" ]
permissive
module Parliament module OpenSearch # An error raised when there is an issue processing an OpenSearch description file. # This could be raised when the URL provided is invalid, or when we are unable to find a URL template for future requests. # # @attr_reader url the description url that caused the Pa...
true
61ca9a6b7dad31016d6c2e19d01ebaa0109c5df4
Ruby
ChristopherJamesJordan/is_it_feasible
/db/seeds.rb
UTF-8
1,541
2.625
3
[]
no_license
# This file should contain all the record creation needed to seed the database with its default values. # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). # # Examples: # # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) # Mayor.create(name: 'Emanuel...
true
559fd32fc3045095fbcc38a289d05678b0f6eff3
Ruby
lito707/weather_processing
/app/models/scrapper.rb
UTF-8
1,279
2.734375
3
[]
no_license
# Authors # Dimas Antony Chacon Salas - 659825 # Tou Lee - 656128 # David Monroy - 610346 # Jhon Manuel Portella Delgado - 680794 # ___________________________________________ URL = 'http://www.bom.gov.au/vic/observations/vicall.shtml' CARDINAL_TO_DEGREES = {"CALM"=>0, "N"=>0, "NNE"=>22, "NE"=>45, "ENE"=>67, "E"=>90, ...
true
ca1ce2e4df1987e12b594611f01ef80702ecd631
Ruby
darkbitio/cspm-lite
/lib/metricsexporter.rb
UTF-8
2,991
2.765625
3
[]
no_license
# frozen_string_literal: true require 'pry' class MetricsExporter def initialize(skip_platform) puts "Metrics Export" @skip_platform = skip_platform list_to_export = get_list_to_export export_metrics(list_to_export) end private def export_metrics(list_to_export) # for each missing ...
true
16d8b2ecc8c6feadb0c14dd1d5736a1262284019
Ruby
men32z/coding-challenges
/replit/28-hash-more-practice.rb
UTF-8
474
3.765625
4
[]
no_license
# Full Credit # Solve the problem with only one iteration through the numbers. def find_pairs(array, k) # write your code here jach = Hash.new(0) pairs = [] array.each do |x| jach[k-x] = x if k-x != 0 pairs.push([jach[x], x]) if jach.has_key?(k-x) && jach[x] + x == k end pairs end p find_pairs([1, 9,...
true
1046a124d598dca2c3d1e24df2565cbc5d38401a
Ruby
hiwaylon/triathlon
/lib/bike.rb
UTF-8
373
3.171875
3
[]
no_license
require 'converter' require 'time_presenter' class Bike attr_accessor :distance, :speed include TimePresenter def initialize(distance, speed) self.distance = distance.to_f self.speed = speed.to_f end def compute_time time = distance / speed # time in hours present_hours_as_string(time) end...
true
97cfb3c349090335169d078f61894c4cc41cda9d
Ruby
Pathigh/repaso-arrays-objetos-hashes
/Arrays/Ejercicio9.rb
UTF-8
123
2.921875
3
[]
no_license
string = "1,2,7,1,3,5,3.4,9,1" arr = string.split(',') arr.map! {|i| i.to_i} puts arr.sum.to_f/arr.size puts arr.mode
true
fc8b0d0fdb4651de94f6a2e24ecfa2fb187eaaf4
Ruby
ianbone1/week2_day2_homework
/River.rb
UTF-8
322
3.609375
4
[]
no_license
class River attr_reader :name def initialize(name) @name = name @fish_population = [] end def fish_count return @fish_population.length() end def add_fish(fish) @fish_population << fish if fish.class.to_s == "Fish" end def remove_fish() return @fish_population.shift end en...
true
8717559c93a890b42331910629233c7278a85a08
Ruby
libryder/codingchallenge
/lib/user_level.rb
UTF-8
628
3.125
3
[]
no_license
class UserLevel include Math attr_reader :user attr_accessor :level, :points, :progress def initialize(user) @user = user @points = 1 calculate_base_level end private def calculate_base_level float_level = Math.log(experience_points + Math.sqrt(experience_points)) if float_level >= ...
true
701bd57189863ce665854dc10a3875c424084d46
Ruby
vpereira/simulateQos
/lib/simulate_qos.rb
UTF-8
2,849
3.0625
3
[]
no_license
require "bundler/setup" require 'csv' require "discrete_event" require_relative "simulate_qos/probability" require_relative "simulate_qos/packet" class SimulateQOS < DiscreteEvent::Simulation attr_reader :arrival_rate, :service_rate, :system, :sent_packets, :queues, :enqueued_packets #the arrival rate = rate th...
true
c2fbbbb17b4a6e212e7ea352392d1c7a73c89671
Ruby
ForrestWeiswolf/hangman
/app.rb
UTF-8
1,299
2.9375
3
[]
no_license
require 'sinatra' require "yaml" require_relative 'hangman' enable :sessions set :session_secret, "secret" #not secure, obviously get '/' do erb :index end get '/save' do session[:game] = YAML.dump(GAME) erb :message, :locals => {:message => "Game saved."} end get '/load' do #GAME shouldn't be a constant GAME...
true
eee7130a17ecc58759934c26c3f3eb75fe05b313
Ruby
thien-truong/learn-ruby-the-hard-way
/ex11.rb
WINDOWS-1252
991
4.40625
4
[]
no_license
# Exercise 11: Asking Questions - Inputs print "How old are you? " # 'gets' accepts a single line of data from the standard input. # 'gets' returns a string and a '\n' character. # 'chomp' removes '\n' age = gets.chomp() print "How tall are you? " height = gets.chomp() print "How much do you weigh? " weight = gets....
true
32164647b7fd2ac4ddd8b981c7dc5962138bf187
Ruby
MarkKairuz/phase-0-tracks
/ruby/hamsters.rb
UTF-8
618
4.125
4
[]
no_license
puts "What is the hamster's name?" Name = gets.chomp puts "How loud is the hamster from 1 to 10?" Loud = gets.chomp.to_i puts "What is the fur color?" Color = gets.chomp puts "Is the hamster a good candidate for adoption?" Adoption = gets.chomp puts "What is the estimated age of the hamster?" Age = gets.chomp if Age =...
true
98dad576f814e8690c10508a9e846d72c7a946d3
Ruby
rafa2000/olelo
/lib/olelo/util.rb
UTF-8
3,284
2.59375
3
[]
no_license
# -*- coding: utf-8 -*- module Olelo class NotFound < NameError def initialize(id) super(:not_found.t(:id => id), id) end def status :not_found end end class MultiError < StandardError attr_accessor :messages def initialize(messages) @messages = messages end d...
true