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
4e6719d84792aa7185c65443cf69c36f152d6b53
Ruby
nagano564/tv_app
/app/services/movie_api.rb
UTF-8
1,634
2.984375
3
[]
no_license
require 'httparty' require_relative '../models/movie' class MovieAPI def initialize @api_key = ENV['MY_API_ENV'] @api_base = 'https://api.themoviedb.org/3/' end def get_popular_shows params = '&sort_by=popularity.desc' response = http_get('discover/tv', params) response['results'].map { |mov...
true
c5ef1cf4d94989e476b778c9c3f2963492aca231
Ruby
a-velasquez/collections_practice-online-web-pt-051319
/collections_practice.rb
UTF-8
818
3.84375
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def sort_array_asc(array) array.sort end def sort_array_desc(array) array.sort do |a, b| b <=> a end end def sort_array_char_count(array) array.sort do |a, b| a.length <=> b.length end end def swap_elements(array) array[1], array[2] = array[2], array[1] array end def reverse_array(array) a...
true
2c01b7d3f7a6cb13e5ee2acc3f6e6b375afb3383
Ruby
anshulverma/bin
/scripts/xdu
UTF-8
2,876
3.171875
3
[ "MIT" ]
permissive
#!/usr/bin/env ruby require 'cliqr' require 'filesize' require 'pty' cli = Cliqr.interface do name 'xdu' description <<-EOS A extended disk usage facility. Currently supports: - Get list of top files sorted by size EOS version '0.1.0' shell :disable action :list do description 'print list of top n fil...
true
c81e65b1eafa641f4a4f0ae2ce75c6da840a9e9c
Ruby
kopz9999/directory-scanner
/lib/directory_scanner/scanner/base.rb
UTF-8
2,191
2.59375
3
[]
no_license
module DirectoryScanner module Scanner class Base attr_accessor :settings, :directory public # @param [String] scanner_path # @param [DirectoryScanner::Directory] directory def initialize(scanner_path, directory) conf = YAML::load_file(scanner_path).deep_symbolize_keys! ...
true
f5022c6b341eed76cc36a7a4fa2a31d783828e40
Ruby
muyscully/ruby_challenges
/bobby_class_02.rb
UTF-8
842
3.96875
4
[]
no_license
class Baby def set_name (name) @baby_name = name end def get_name return @baby_name end def set_birthdate (birthdate) @baby_birthdate = birthdate end def get_birthdate return @baby_birthdate end def favorite_songs @songs= [] end def get_favorite_songs return @songs end def add_favorite...
true
a7718a357f6bbc1ade6202add84eacb9bdaa2c37
Ruby
georgebrock/greeter
/lib/greeter.rb
UTF-8
432
3.796875
4
[]
no_license
class Greeter class BadNameError < StandardError; end VALID_NAME_REGEXP = /^\w+$/.freeze def self.greeting(name) new(name).greeting end def initialize(name) @name = name end def greeting if valid_name? "Hello #{name}" else raise BadNameError, "#{name.inspect} is not a valid...
true
b6cd081a369c625b7c9989888c774268eaa1f9f6
Ruby
pravosleva/ocrsdk.com
/Ruby/abbyy_ruby_example.rb
UTF-8
5,032
2.59375
3
[ "Apache-2.0" ]
permissive
# OCR SDK Ruby sample # Documentation available on https://ocrsdk.com/documentation/ require "rubygems" # IMPORTANT! # Make sure you have rest-client (see https://github.com/archiloque/rest-client for detaile) gem installed or install it: # gem install rest-client require "rest_client" require "rexml/document" #...
true
015246d969d588fb7cfd6ce294e5215da4346413
Ruby
i3zhe/sample_rails_app
/spec/models/user_spec.rb
UTF-8
2,738
2.578125
3
[]
no_license
require 'spec_helper' describe User do # pending "add some examples to (or delete) #{__FILE__}" before(:each) do @attr = {:name => "Example User", :email => "user@example.com", :password => "foobar", :password_confirm => "foobar" } end it "should create a new instance given valid attribut...
true
4b6d1b39b0498c64b1478bfde224599dc70813cc
Ruby
jtmaclachlan/diff_json
/ruby/lib/diff_json/diff.rb
UTF-8
2,680
2.640625
3
[]
no_license
require_rel './diff' module DiffJson def self.diff(old_json, new_json, return_type, diff_opts = {}, output_opts = {}) completed_diff = Diff.new(old_json, new_json, **diff_opts) return case return_type when :raw completed_diff when :patch patch_operations = [] completed_diff.diff.e...
true
dd99fecbe894a7de8b44170ee8dc9f64720b5f3d
Ruby
simi/ruby-sentiments
/jankubr/events/app/services/leave_event.rb
UTF-8
164
2.71875
3
[]
no_license
class LeaveEvent attr_accessor :event def initialize(event) self.event = event end def leave(user) event.users -= [user] event.save end end
true
2a34f26c550a398543bc7081ad85b8a07e2517b8
Ruby
voydz/souyuz
/lib/souyuz/msbuild/project.rb
UTF-8
938
2.53125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
module Souyuz module Msbuild class Project attr_accessor :options def initialize(options) @options = options end def project_name @options[:project_name] end def project_path @options[:project_path] end def ios? is_platform? Souyu...
true
686e83aa6b4dfee3c08ba688938937c08f10dc97
Ruby
UzmaKR/todo-rspec
/list_spec.rb
UTF-8
1,963
3.03125
3
[]
no_license
require "rspec" require_relative "list" describe List do let(:title) { "todo at the serengeti" } let(:task1) { mock(:task, :description => "walk the lion", :complete => false) } let(:task2) { mock(:task, :descripttion => "go on safari", :complete => true) } let(:task3) { mock(:task, :descripttion => "watch th...
true
0d968566e06d1994f08cf86db138910043e7cbba
Ruby
CSavi/ruby-music-library-cli-v-000
/lib/concerns/findable.rb
UTF-8
264
2.578125
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
module Concerns::Findable def find_by_name(name) all.detect {|song| song.name == name} end def find_or_create_by_name(name) find_by_name(name) || create(name) end #helper method def sorted all.sort {|a,b| a.name <=> b.name} end end
true
fb6f759ef64f0adf08fd81097ae49a4b1a5df609
Ruby
JMazzy/assignment_rspec_ruby_tdd
/spec/dice_thrower_spec.rb
UTF-8
1,902
3.140625
3
[]
no_license
require 'dice_thrower' require 'human' require 'computer' describe DiceThrower do let(:dice_thrower) { DiceThrower.new(human_double,computer_double) } let(:human_double) { instance_double("Human") } let(:computer_double) { instance_double("Computer") } describe '#play' do it 'asks the player for their nu...
true
3898266e55c3dce641bd040d801b5ce698e13d4c
Ruby
brad72287/project-euler-solutions
/23 - Non-abundant sums.rb
UTF-8
684
3.65625
4
[]
no_license
def divisors(x) arr=Array.new (1..(x**0.5)).each do |number| arr << number if x%number==0 arr << x/number if x%number==0 unless x / number == x end arr.sort.uniq end def perfect?(x) return false if x != divisors(x).reduce(:+) return true end def abundant?(x) return true if x < divisors(x).reduc...
true
fdf10b0ecbf66a071a8aac53de37c4f63a3d2fdc
Ruby
brucewu/exmail
/lib/exmail.rb
UTF-8
6,281
2.578125
3
[ "MIT" ]
permissive
require 'exmail/version' require 'restclient' module Exmail class Server attr_accessor :key, :account_name, :access_token #主要用于获取token DOMAIN_TOKEN = 'exmail.qq.com' #主要是调用API DOMAIN_API = 'openapi.exmail.qq.com:12211' def initialize(account_name, key) @account_name, @key=account_name,...
true
a9ff21355c83465eec2c2a72622a04020bbb2dcd
Ruby
bukshev/PBXProjMaestro
/Sources/Utilities/FileFinder/physical_files_finder.rb
UTF-8
2,602
2.65625
3
[ "MIT" ]
permissive
# frozen_string_literal: true # MIT License # # Copyright (c) 2019 Ivan Bukshev # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights...
true
4ef25bf0bbab4ea9173e657461a6d0811b5c0439
Ruby
RobertoBarros/isometric_ruby
/face.rb
UTF-8
601
3.53125
4
[]
no_license
class Face FACES = %i[north west south east] def initialize(face: :north) @current_index = FACES.index(face) end def current FACES[@current_index] end def rotate_clockwise @current_index = increment_index end def rotate_anticlockwise @current_index = decrement_index end def next...
true
257615678ccbd42223122b8757472f76cab9a198
Ruby
vladiim/carprice_crawler
/lib/car_price/crawler.rb
UTF-8
370
2.984375
3
[]
no_license
class Crawler attr_reader :agent def initialize @agent = Mechanize.new end def cars(url) agent.get(url). search('.content').search('a'). map { |car| process_car(car) } end private def get(url) agent.get(url) end def process_car(raw_data) car = CarScrapper.new(raw_data)...
true
3e7ebec3a181c56f5802b569bc814490727af1bd
Ruby
ggwc82/rps-challenge
/lib/cpu.rb
UTF-8
294
2.921875
3
[]
no_license
class Cpu def initialize @name = "CPU" end def pick ($rules == 'normal')? (@choice = hands[0..2].sample) : (@choice = hands.sample) end attr_reader :choice, :name private attr_reader :hands def hands ["Rock", "Paper", "Scissors", "Spock", "Lizard"] end end
true
3b142438d62d35602fddf591bc27f1da18602c10
Ruby
kelmerp/tic-tac-toe-ruby
/spec/board_spec.rb
UTF-8
1,332
2.96875
3
[]
no_license
require 'spec_helper' describe Board do before :each do @board = Board.new end describe "#get_lines" do context "with a 3 X 3 board" do it "returns an array containing the 8 lines on the board" do expect(@board.get_lines.size).to eq 8 end end context "with a 4 X 4 board"...
true
f2b89879aa8f571035ddd2db3efbcc3d7eda4204
Ruby
fvthreee/alexandria
/app/query_builders/sorter.rb
UTF-8
273
2.59375
3
[]
no_license
class Sorter def initialize(scope, params) @scope = scope @column = params[:sort] @direction = params[:dir] end def sort return @scope unless @column && @direction @scope.order("#{@column} #{@direction}") end end
true
df44e76059cf92a7b9bc3c817d2c523c7235ba52
Ruby
InfernoPC/ruby_practice
/AOJ/Q001/Q0019.rb
UTF-8
95
3.25
3
[]
no_license
#Factorial class Integer def fact (1..self).reduce(:*) || 1 end end puts gets.to_i.fact
true
bf5a47f50e103d5d87269ace27672c3686a5a08e
Ruby
shanebarringer/code_session
/loops/each_addition.rb
UTF-8
223
3.875
4
[]
no_license
array = [0, 1, 2, 3, 4, 5] array.each do |x| x = x + 2 #add 2 to each item in the array puts "#{x}." end #puts array.inspect #anything we do inside the block only applies to the ITEM variable inside the block
true
b1c32735e781b309fc8ed77c770d80d0028518a6
Ruby
fabioromeo/code_labs
/Documentos/Notebook/Estudos/Coding/Ruby/maior_ou_menor_v3.rb
UTF-8
1,257
3.875
4
[]
no_license
def da_boas_vindas puts "Bem vindo ao jogo de adivinhar" puts "Qual o seu nome?" nome = gets puts "\n\n" puts "Começaremos o jogo " + nome end def sorteia_numero_secreto puts "escolhendo um número secreto entre 0 e 200..." sorteado = 175 #variável local puts "Escolhido. Que tal adivinhar hoje o nosso numero secret...
true
b193982fb9cb620f4fadb8b8547ebd4994390990
Ruby
hyperturing/mastermind
/computer.rb
UTF-8
2,875
3.34375
3
[]
no_license
# frozen_string_literal: true require_relative 'board' require_relative 'utils' require 'set' # Citation: ################ # RubyConf 2018: # Beating Mastermind: Winning with the help of Donald Knuth by Adam Forsyth # http://confreaks.tv/videos/rubyconf2018-beating-mastermind-winning-with-the-help-of-donald-knuth # ...
true
94eeb46aaa42d5f9fa92a12c1bbd27f3e25b5d76
Ruby
tetuyoko/rumbler
/lib/rumbler.rb
UTF-8
558
3.46875
3
[]
no_license
require 'rumbler/shuffle' # shuffle and progress module Rumbler class << self KEYS = [*1..7] DEFAULT_AMOUNT = 1000 def play(amount = DEFAULT_AMOUNT) shuffle = Shuffle.new(amount, score_board) shuffle.rumble finish end def score_board @score_board ||= create_score_board ...
true
ea8cb7495b8fe3feaa3889460b7fc04fffa69bb8
Ruby
rkh/minimal-redjs
/spec/embedded_javascript_spec.rb
UTF-8
2,261
2.71875
3
[]
no_license
require File.expand_path('../spec_helper', __FILE__) shared_examples_for "embedded javascript" do before do begin require library rescue LoadError pending "not installed" end @context = context_class.new end describe :evaluate do statements = %w[true false 42 1.5 1+1] stateme...
true
a348ed04cb869cb14402fce514d63a6f622a640b
Ruby
schanur/headless-jukebox
/headless-jukebox/command_param_functions.rb
UTF-8
1,217
2.796875
3
[ "MIT" ]
permissive
require 'pp' def video_feed_url_to_video_url(feed_url) run_cmd('curl -s ' + feed_url + ' | grep ".h264.mp4" | cut -f 2 -d "\"" |head -n 1') .gsub("\n", '') end # Scramble list order and return first item that is a media filename. def random_media_file_from_list(filename_list) filename_list.shuffle.each do |fi...
true
5c7b09a199f4de7085316d737ecaf6ac2d5e9599
Ruby
m1kal/exercism_ruby
/bob/bob.rb
UTF-8
500
3.6875
4
[ "MIT" ]
permissive
class Bob ANSWER_QUESTION = 'Sure.' ANSWER_YELL = 'Whoa, chill out!' ANSWER_BOB = 'Fine. Be that way!' ANSWER = 'Whatever.' def self.hey(remark) return ANSWER_YELL if yell?(remark) return ANSWER_QUESTION if question?(remark) return ANSWER_BOB if empty?(remark) ANSWER end def self.questi...
true
838c41f4b236246917908a8eb88328bbda838f0d
Ruby
Naomi-Dennis/ruby-music-library-cli-v-000
/lib/music_importer.rb
UTF-8
449
2.984375
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require "pry" class MusicImporter attr_accessor :path, :data, :songs def initialize(path) @path = path end def files filenames = Dir[@path + "/*"]; @data = filenames.collect do |filename| filename = filename.slice(@path.size + 1, filename.size) filename end @data end def i...
true
20423d5eaa48a9b1ea4c94bc96640f17eceec423
Ruby
ThomasD972/Ruby_THP
/Ruby_exo/lib/01_pyramids.rb
UTF-8
391
3.453125
3
[]
no_license
puts "Bonjour combien d'étages veux-tu a ta pyramide ? (nombre impair)" print ">" input = gets.chomp.to_i if (input%2==0) puts "J'tai dis impair jeune délinquant" else 1.upto(input/2+1) do |i| spaces = " " * (input-i) dots = "#" * (i*2-1) puts spaces + dots end end 0.upto(input/2+1) do |i| dots = "#" * (...
true
6874a8dfa9fc9e3f95790135430e49ffe140feb4
Ruby
mutle/fu2
/app/models/channel_tag.rb
UTF-8
631
2.515625
3
[ "MIT" ]
permissive
class ChannelTag < ActiveRecord::Base include SiteScope belongs_to :channel belongs_to :post belongs_to :user class << self def all_tags(site) res = PGDB.query(<<-SQL) SELECT DISTINCT(tag) FROM channel_tags WHERE site_id = #{site.id}; SQL res.map(&:first) end def channel_ids(site, t...
true
bf142a84e8f2f27e2789dc0ae4ff065039a49013
Ruby
rossta/exercism-exercises
/ruby/prime-factors/prime_factors.rb
UTF-8
279
3.265625
3
[]
no_license
class PrimeFactors def self.for(n) for_results(n, []) end def self.for_results(n, results) return results if n < 2 return results + [n] if n < 4 2.upto(n).each do |div| return for_results(n / div , results + [div]) if n % div == 0 end end end
true
e5dd1bee0af2dcc22e499eba58b47085000e4450
Ruby
self-unit/week2_homework
/guest.rb
UTF-8
360
3.5
4
[]
no_license
class Guest attr_reader :name, :fav_song attr_accessor :wallet def initialize(name, wallet, fav_song) @name = name @wallet = wallet @fav_song = fav_song end def pay_tab(room_tab) @wallet -= room_tab end def room_has_fav_song(room) if room.songs.any? {|song| song.name == @fav_song} ...
true
37c33faa315b790235bca4ffd45ff1f7f2d24b24
Ruby
morotsman/learning-ruby
/validating_inputs/lib/input_validator.rb
UTF-8
1,425
3.46875
3
[]
no_license
class InputValidator private def filled_in?(input) input != nil && input != "" end def minimum_length?(minimum_length, input) input.size >= minimum_length end def length?(length, input) input.size == length end def only_digits?(input) input !~ /\D/ end def only_lette...
true
bb78955531235db70d0d993d20fdd60c45c89550
Ruby
rlew421/tech_challenges
/ruby/majority_element.rb
UTF-8
1,641
4.34375
4
[]
no_license
# Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times. # # You may assume that the array is non-empty and the majority element always exist in the array. # # Example 1: # # Input: [3,2,3] # Output: 3 # Example 2: # # Input: [2,2,1,1,1,2,2] # Outp...
true
56c0f1f13ad03176c44b59dfb2e34db0ec805318
Ruby
DerekMaffett/sea-c21-ruby
/lib/class5/exercise3.rb
UTF-8
1,357
4.0625
4
[ "MIT" ]
permissive
#!/usr/bin/env ruby # # 5 points # # Write a program that copies .jpg files from the source directory to the target # directory, appending the file's size to the end of the file name. # # So, assuming there's a source file that's 12,345 bytes long: # # source/photo.jpg # # the program should copy it to the target fil...
true
d68b3828fbd9ef87b9ae37d4e94ed3d90b2d5da5
Ruby
namthanh174/alpha-blog
/Code/ruby_projects/analyzer.rb
UTF-8
2,236
4.375
4
[]
no_license
# puts "Please enter your first name" # first_name = gets.chomp # puts "Please enter your last name" # last_name = gets.chomp # puts "welcome to the analzer programe #{first_name} #{last_name}" # puts "Your first name has #{first_name.length} characters in it" # puts "Your last name has #{last_name.length} characters...
true
439dfc198a0c87f7470bf6ad4a9f79f2d94a21d2
Ruby
ragueroanna/loops_for_poops
/poo.rb
UTF-8
212
2.984375
3
[ "MIT" ]
permissive
#!/usr/bin/env ruby def can_i_poo? puts 'type a "p" for poo' line = $stdin.readline if line.strip == 'p' puts '💩' true else puts "\u{1f639}" false end end loop until can_i_poo?
true
f6398ae1ca0a76169e35cd31400cc2d92aafd88f
Ruby
evanrushton/stickyUnit
/db/migrate/20140709073101_load.rb
UTF-8
13,905
2.6875
3
[]
no_license
class Load < ActiveRecord::Migration def up # Create initial users. down cr = User.new(:login => "Crushton") cr.save(:validate => false) # Create initial units. unit1 = Unit.new(:name => "What is Fair? (Measures of central tendency)
") unit1.user = cr unit1.save(:validate => fals...
true
a1437940c0d80b9730ea3cebb09b167fb1e20925
Ruby
jasonlhoward/ls-basics
/user_input/e5.rb
UTF-8
214
3.21875
3
[]
no_license
loop do print 'How many lines do you want? Enter an integer >= 3: ' answer = gets.chomp.to_i next puts 'That\'s not enough lines.' if answer < 3 break answer.times { puts 'Launch School is the best!' } end
true
7ef2a98822e0fdbce76116aa1cb132b0d446a5b1
Ruby
pwojcikpl/ArtGallery
/app/models/image.rb
UTF-8
3,078
2.625
3
[]
no_license
class Image < ActiveRecord::Base def file= (f) @file = f end def validate # Empty 'name' field is not allowed errors.add_on_empty 'name' # @file should contain file uploaded by HTTP # it is either StringIO object (if file was smaller than 10Kb) # or Tempfile (otherwise) ...
true
8552839d857272ab3621ff6fc4e137c979579bdd
Ruby
docljn/i_need_a_budget_in_ruby_sinatra
/models/vendor.rb
UTF-8
1,555
2.984375
3
[]
no_license
# vendor.rb require_relative('../db/sql_runner.rb') class Vendor attr_reader :id attr_accessor :name def initialize(options) @id = options['id'].to_i if options['id'] @name = options['name'] end # delete def self.delete_all() sql = "DELETE FROM vendors;" sql_result = SqlRunner.run(sql) ...
true
55761dcce493f65b3f474be0bd214cb76427786e
Ruby
nirmalsi/trainings
/Tranings/ruby_program/module_staff.rb
UTF-8
188
3.21875
3
[]
no_license
module Staff def swim "i am swimming!" end end class Animal end class Dog < Animal include Staff end class Cat < Dog end dog = Dog.new cat = Cat.new puts dog.swim puts cat.swim
true
81dca2419a876d169d287f7e94377395468ea535
Ruby
amandeep1420/ruby-basics-exercises
/9_conditionals/9_cool_numbers.rb
UTF-8
142
3.875
4
[]
no_license
# my answer: number = rand(10) if number == 5 puts '5 is a cool number!' else puts 'Other numbers are cool too!' end # 100% correct.
true
7d98b78f3f440a4c02000c45542b0e1565cfb6af
Ruby
kashfiarahman89688/midterm_ror
/0b.rb
UTF-8
506
4.625
5
[]
no_license
#0b #b) The second method you have to fill in is sort_array_plus_one. This method takes in an array of integers, sorts it, #then increments every element by 1, and returns it. It does not matter if this method is destructive or not. def sort_array_plus_one(array) array.sort! {|x, y| x <=> y} puts "Input arra...
true
44746b98058128db4f2150921e66bde6ae20223a
Ruby
juliemiller/poker
/spec/card_spec.rb
UTF-8
377
2.734375
3
[]
no_license
require 'rspec' require 'card.rb' describe Card do let(:card) { Card.new( :king, :spades ) } it "knows its suit" do expect( card.suit ).to eq( :spades ) end it "has a type" do expect( card.type ).to eq( :king ) end it "has a color" do expect( card.color ).to eq( :black ) end it "has a v...
true
6b9806f1d2c9482836a94688450934c385a77944
Ruby
tfpractice/tfp_metaprogramming
/lib/tfp_metaprogramming/callable/procs/arity.rb
UTF-8
405
2.640625
3
[ "MIT" ]
permissive
module TfpMetaprogramming module Callable module Procs module Arity def arity_proc proc {|x,y| [x, y] } end def arity_lambda ->(x,y) { [x, y] } end def call_for_arity(&callable) # begin callable.call(1) # rescue Argu...
true
5d5eb0cd8382bf5396858e16f41f1d9dbcb0fcbe
Ruby
blabash/aA_homework
/simon/lib/simon.rb
UTF-8
1,132
3.5625
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 = [] self.play end def play self.take_turn until @game_over == true self.take_turn end self.gam...
true
edf399479d075f682456003d0496d9148f7638fb
Ruby
chrnobyl/guessing-cli-prework
/guessing_cli.rb
UTF-8
349
3.84375
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def run_guessing_game puts "Guess a number between 1 and 6." num = rand(1..6).to_s command = "" until command == "exit" command = gets.chomp if command == num puts "You guessed the correct number!" elsif command != num puts "The computer guessed #{num}." else break end ...
true
1fb6ab5bbb71940303be00639d0e84a9990a9cf8
Ruby
kellyredding/xmlss
/test/unit/style/interior_tests.rb
UTF-8
1,707
2.515625
3
[ "MIT" ]
permissive
require "assert" require 'xmlss/style/interior' require 'enumeration/assert_macros' class Xmlss::Style::Interior class UnitTests < Assert::Context include Enumeration::AssertMacros desc "Xmlss::Style::Interior" before { @i = Xmlss::Style::Interior.new } subject { @i } should have_enum :patter...
true
6459397f07e02a3ffb76f5bccc8ece35088b8139
Ruby
uk-gov-mirror/guidance-guarantee-programme.output-uat
/lib/sample_output_document.rb
UTF-8
2,122
2.5625
3
[ "MIT" ]
permissive
require_relative './output_document' require 'faker' Faker::Config.locale = 'en-GB' class SampleOutputDocument < OutputDocument def initialize(id: nil, format: 'standard', variant: nil, attendee_name: nil, attendee_address_line_1: nil, ...
true
3ef977f1e57d26f773975a9f80a500fbd6e459aa
Ruby
potapovDim/full
/ruby/po/editor/share/color-picke-unusedr.rb
UTF-8
874
2.890625
3
[]
no_license
#color picker class ColorPicker #css selectors def initialize(browser) @browser = browser @color_picker_pointer = '.pointer_35h' @alpha_input = '[data-test="input-number-input"]' @saturation = '[data-test="color-picker-saturation"]>div' @hue_vertical = '.hue-vertical' end def change_color_...
true
8e4652b43d1bcb55036e923ec19672ec6db046c5
Ruby
tjwudi/learn-ruby
/meta-prog/include.rb
UTF-8
131
3.140625
3
[]
no_license
module M def foo puts 'foo' end private def bar puts 'bar' end end class C include M end c = C.new c.foo c.bar
true
2962dd353a3fe70ad450899387bb40323359fae4
Ruby
relteq/simx
/bin/export-aurora-xml
UTF-8
1,246
2.5625
3
[]
no_license
#!/usr/bin/env ruby topdir = File.expand_path("..", File.dirname(__FILE__)) libdir = File.join(topdir, "lib") $LOAD_PATH.unshift libdir require 'simx/argos' optdef = { "h" => true, "help" => true, "log" => true } opts = Argos.parse_options(ARGV, optdef) if ARGV.size != 2 or not ARGV.grep(/...
true
44e98f7864b7d45c00308dcf15e95b0c8944a8e9
Ruby
th7/programming-challenges
/non-adjacent-robbery/benchmark.rb
UTF-8
408
2.84375
3
[]
no_license
require 'benchmark' require './non_adjacent_robbery_v1' v1 = NonAdjacentRobbery Object.send(:remove_const, :NonAdjacentRobbery) require './non_adjacent_robbery_v2' v2 = NonAdjacentRobbery Object.send(:remove_const, :NonAdjacentRobbery) n = 1_000_00 Benchmark.bm(10) do |x| x.report('v' + v1.v) {n.times{v1.rob([1,2,...
true
2b45afbea00cac592372b39c7ac5d757f67a9797
Ruby
AllanaOliveira/UFFMAIL
/app/helpers/students_helper.rb
UTF-8
455
2.640625
3
[]
no_license
module StudentsHelper def translate_attribute(object = nil,method = nil) if object && method object.model.human_attribute_name(method) else "Informe os parâmetros corretamente" end end def choose_email(student) byebug emails = [] nome = student.name 5.times do |i| em...
true
dfc0421d35a802526426b046c323bf7bcc6486ee
Ruby
pablotarga/project-euler
/00004_largest_palindrome.rb
UTF-8
991
3.984375
4
[]
no_license
module Math def self.largest_palindrome(pow:2) min, max, found = 10**(pow-1), (10**pow)-1, 0 a = b = max begin product = a * b found = product if product > found && product.palindrome? if b > min && product > found b -= 1 else a, b = a-1, max break if a * ...
true
58dea5e0eb97e7271063871497a376a4b4e91b86
Ruby
Gyenh/learn_ruby_rspec
/04_simon_says/simon_says.rb
UTF-8
407
3.890625
4
[]
no_license
def echo(name) name end def shout(a) a.upcase end def repeat(a, b) a = a + " " a = a * b a = a[0...-1] a end def start_of_word(word, b) word.slice(0...b) end def first_word(a) a.split[0] end def titleize(a) lowercase_words = %w{a an the and but or for nor of} a.split.each_with_index.map{|x...
true
d35de2fff8d2246fb1a8d670759cbe81f8f6974c
Ruby
aequihua/vcap-addsvc
/test.rb
UTF-8
627
3.09375
3
[]
no_license
def create_instance_cmdline(path) puts "estoy entrando a crear el comando pinky" cmdline = "#{path}" comando = "memcached " cmdline.each_line do |s| paso = s.split if paso.length>1 if paso[0].downcase=="port" comando = comando + " -p"+paso[1] else if paso[0].downcase=="daemoniz...
true
f756b499e5e158b809b3a9db05b7d271eb344362
Ruby
mikereinhart/labs
/week1/524_tdd_bank/bank_spec2.rb
UTF-8
1,002
3.171875
3
[]
no_license
require_relative "bank" describe Bank do describe '#new' do it 'builds a new bank with a name' do bank = Bank.new('MyCiti') bank.should be_instance_of Bank bank.name.should == 'MyCiti' end end end describe '#open_account' do it 'opens a new account' do bank = Bank.new('MyCiti') account = bank.op...
true
21b1deba21915603e9f993a403d78e722c865914
Ruby
laurenrosie/student-directory
/directory.rb
UTF-8
4,312
4.0625
4
[]
no_license
@center_by = 60 @students = [] require 'csv' # method printing just the header def print_header puts "The students of Villians Academy".center(@center_by) puts "-------------".center(@center_by) end # method printing the student name and cohort using .each_with_index def print_students_list @students.each_with...
true
9f792da30001626ab089377a1b4110d7a28b5c47
Ruby
cellog/testable
/lib/testable/element.rb
UTF-8
6,903
3.171875
3
[ "MIT" ]
permissive
require "watir" module Testable module_function NATIVE_QUALIFIERS = %i[visible].freeze def elements? @elements end def recognizes?(method) @elements.include? method.to_sym end def elements @elements ||= Watir::Container.instance_methods unless @elements end module Pages module El...
true
02cf0df483ed85921bf30506aee1081c8c86492d
Ruby
nrhyan/launch_school
/contact_data.rb
UTF-8
1,385
3.0625
3
[]
no_license
contact_data = [["joe@email.com", "123 Main st.", "555-123-4567"], ["sally@email.com", "404 Not Found Dr.", "123-234-3454"]] contacts = {"Joe Smith" => {}, "Sally Johnson" => {}} contact_data = ["joe@email.com", "123 Main st.", "555-123-4567"] contacts = {"Joe Smith" => {}} fields = [:email, :address, :ph...
true
830ccbff360c8d7b087dc949e93c8dc52c11ad32
Ruby
JumpStartGeorgia/Work-Gender-Inequality
/app/models/faq_translation.rb
UTF-8
468
2.53125
3
[ "MIT" ]
permissive
class FaqTranslation < ActiveRecord::Base belongs_to :faq attr_accessible :faq_id, :question, :answer, :locale validates :question, :answer, :presence => true def required_data_provided? provided = false provided = self.question.present? && self.answer.present? return provided end ...
true
63e35d67906ad253176b0cb5b4624cb305c04ee0
Ruby
plammiez/moss.rb
/test/testnoisefilterwithc.rb
UTF-8
534
2.609375
3
[]
no_license
#!/usr/bin/env ruby #Testing the Noise Filter #Unit Tests FTW! require 'test/unit' require '../lib/myth/filter.rb' class TestNoiseFilter < Test::Unit::TestCase def test_remove_comments() fp=File.open('../conf/c.conf') confinstance=Myth::Filter::FilterConfset.new(fp) text_contents=File.read('./cfile...
true
5c230cf0f9f8e0d7db016feaecb774999604d905
Ruby
iharmonyharper/movies
/lib/movie/modern_movie.rb
UTF-8
152
2.578125
3
[]
no_license
module Movies class ModernMovie < Movie def to_s "#{@title} — современное кино: играют #{@actors}" end end end
true
823b460a87b1b6f3ddd810becbbc1f02dd04c76b
Ruby
inglesp/ruby-crash-course
/examples/nine_times_table_3.rb
UTF-8
113
3.171875
3
[]
no_license
# nine_times_table_3.rb i = 1 while true puts "#{i} * 9 = #{i * 9}" i += 1 if i > 10 break end end
true
dcdefc43ea6679b8bc6385219778d20d3670d5e1
Ruby
mkroman/meta-rpc_client
/lib/meta/rpc/client.rb
UTF-8
2,249
3.03125
3
[]
no_license
# frozen_string_literal: true module Meta module RPC # {Client} is the main interface you'll be working with to connect to Meta's # RPC server. It opens a single TCP connection to the given +url+ and takes # care of encrypting and decrypting the messages using a shared key. # # @example # c...
true
c2661fe5bf5d598cd24db7ea66b436b2597f0e53
Ruby
ivanternovyi/repo
/zavd.rb
UTF-8
144
2.8125
3
[]
no_license
require 'singleton' class Student attr_accessor :age include Singleton end K = Student.instance B = Student.instance K.age = 17 B.age p B
true
2d643f6c534d852631fb9f265028db007fecc715
Ruby
chiibis/rasn1
/spec/types/octet_string_spec.rb
UTF-8
1,871
2.671875
3
[ "MIT" ]
permissive
require_relative '../spec_helper' module RASN1::Types describe OctetString do describe '.type' do it 'gets ASN.1 type' do expect(OctetString.type).to eq('OCTET STRING') end end describe '#initialize' do it 'creates a OctetString with default values' do os = OctetString...
true
5ad2f871e9387f52e7ab2e3b7e040d54eb0fa3d7
Ruby
razorpay/ifsc
/scraper/scripts/utils.rb
UTF-8
1,401
2.734375
3
[ "LicenseRef-scancode-public-domain", "MIT" ]
permissive
require '../../src/ruby/ifsc' def sanitize(str) return nil if str.nil? or str.length==0 ["┬ô", "┬û",'┬ö','┬Æ','┬á','┬æ','┬ù','ý','ý','┬á','Â'].each do |pattern| str.gsub!(pattern,' ') end str.gsub!('├ë','e') str.gsub!('├å','a') str.gsub!('├ë','e') str.gsub!('`',"'") str.gsub!('ý'," ") # replace ...
true
777e346408aa0a1093711729b0cc522dbb348677
Ruby
achambel/conference-track-manager
/lib/conference-track-manager/talk.rb
UTF-8
881
2.90625
3
[]
no_license
require 'securerandom' module ConferenceTrackManager module Model class Talk attr_reader :title, :duration attr_accessor :schedule def initialize(line) line_splited = line.split duration = line_splited.last == "lightning" ? 5 : line.split.last.to_i line_splited.pop ...
true
8f48b7e57567fd0639900d23cf43d974c6300345
Ruby
armandylon/todo-ruby-basics-001-prework-web
/lib/ruby_basics.rb
UTF-8
391
3.515625
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def division(num1 = 42, num2 = 7) num1/num2 end def assign_variable(value = "Bob") value end def argue(phrase = "I'm right and you are wrong!") phrase end def greeting(greeting = "Hi there, ", name = "Bobby!") greeting end def return_a_value(phrase = "Nice") phrase end def last_evaluated_value(phras...
true
1108a3e6ddbb90747d9fb7ba00d048b71bd07de4
Ruby
sifterapp/sifter-ruby
/lib/sifter/project.rb
UTF-8
1,085
2.515625
3
[ "MIT" ]
permissive
# Wrapper for a Sifter project. Fetch projects using Sifter::Account. class Sifter::Project < Hashie::Dash property :name property :archived property :primary_company_name property :url property :api_url property :issues_url property :milestones_url property :people_url property :api_milestones_url ...
true
2ad4268fc5aa4b24d7e7580587336f1fad7effb9
Ruby
takehome1/takehome
/lib/rover.rb
UTF-8
242
2.828125
3
[]
no_license
class Rover attr_reader :position, :direction, :instructions def initialize(position:, direction:, instructions:) @position = position @direction = direction @instructions = instructions end end
true
b6b31b654251aee055b7eed22866e7e1754b765f
Ruby
Forison/Testing-custom_enum
/spec/custom_enum_spec.rb
UTF-8
6,857
3.546875
4
[ "MIT" ]
permissive
require './enum_methods/custom_enum.rb' RSpec.describe Enumerable do let(:test_array_one) { [1, 2, 3, 4, 5] } let(:test_array_two) { ['a','a','a','b'] } let(:test_array_three) { ['kofi','ama', 99] } let(:test_array_four) { ['kofi','ama', 'adwoa'] } let(:test_array_five) { ['kofi','akosua', 'ad...
true
8c2c80db5bb37420f6bb5a0512737d3c8208831a
Ruby
app2641/translaunder
/lib/translaunder/response_parser.rb
UTF-8
595
2.84375
3
[ "MIT" ]
permissive
#encoding: utf-8 require 'json' module TransLaunder class ResponseParser def initialize text @text = text end def parse @text = decode @text extract_text end private def decode text encoding = 'UTF-8' text.gsub!(/(\\x26#39;)/, "'") text.force_encoding(en...
true
c3e3ef5f52f7f5f8d8cb8bb4d363ef732855a375
Ruby
cmkoller/choose-your-own-adventure
/server.rb
UTF-8
3,530
2.515625
3
[]
no_license
require 'dotenv' require 'csv' require 'pg' require 'sinatra' require 'sinatra/activerecord' require 'sinatra/flash' require 'omniauth-github' require_relative 'config/application' Dotenv.load Dir['app/**/*.rb'].each { |file| require_relative file } helpers do def current_user user_id = session[:user_id] ...
true
789e185f0ddf94c825a0f12b7422a3b49458ec64
Ruby
syfo/the_force
/lib/the_force/slugs.rb
UTF-8
967
3.0625
3
[ "MIT" ]
permissive
# CRZ - given a name to slug-ize, and either a list or a table and column, make a unique slug # - There's are inherent race conditions here, naturally. # - Should go like "b" -> "b_1" # e.g. TheForce.unique_slug("My Gallery", Gallery, :permalink) # e.g. TheForce.unique_slug("My Gallery", ["My_Gallery", "MY GALL...
true
50037405fc951f705abd389398c71664e54bb5f9
Ruby
Shadae/VariousThings
/second_week/Baker_class.rb
UTF-8
311
2.96875
3
[]
no_license
class Baker attr_accessor :eggs, :butter, :rolling_pin def initialize @flour = 2 @butter = 5 @sugar = 3 @eggs =23 end def self.find_all_the_bakers def make_cookies heat_oven(350) end def heat_oven(temperature) puts "The oven is heating up to #{temp}" end end
true
814a36194abc4b7d92b00c5746cfea3db8375158
Ruby
jichen3000/colin-ruby
/test/require_test/relative_test/a.rb
UTF-8
130
2.515625
3
[]
no_license
class A p "a" end class B p "b" end module AM class A p "a" end class B p "b" end end def mm puts "mm" end
true
b7a58f6b7f673e0d36904ffd3d1cc8afaa85cb12
Ruby
verdi327/weatherbase
/lib/weatherbase/client.rb
UTF-8
1,558
3.0625
3
[ "MIT" ]
permissive
module WeatherbaseApi class Client attr_reader :agent def initialize @agent = Mechanize.new end def weather_for(location) #fetch page with correct url with location for all possible matches #click one of the matches #returns an object representing the data agent.get loc...
true
50ccb296dfbfa6b3b0ad277b1056abebc7613b08
Ruby
knightstick/aoc2020
/lib/aoc2020/day_eleven.rb
UTF-8
4,237
3.453125
3
[]
no_license
require 'pry' module Aoc2020 module DayEleven class << self def part_one(input) end_up_occupied(grid(input)) end def part_two(input) end_up_occupied(grid(input), :new_state_visible) end def grid(input) input.chomp.split("\n").each.with_index.reduce({}) do |...
true
013750a2d39549ff52c9af1d6b8d70cc57ab9a16
Ruby
sahana-vajrakumar/Project-3
/app/models/movie_poster.rb
UTF-8
778
2.625
3
[]
no_license
class MoviePoster < ApplicationRecord def self.get_poster_path_cached( id ) m = MoviePoster.find_by tmdb_id: id if m puts "=" * 80 puts "FOUND IN DB: #{ id }" p m return [m.poster_path, m.overview] end # fallback to API request, but save results in our DB movie = HTTParty...
true
c63ac940d19a55fcc429e64b4770e9da688ca584
Ruby
smileart/invisible_logger
/lib/invisible_logger.rb
UTF-8
8,575
2.890625
3
[ "MIT" ]
permissive
# frozen_string_literal: true # encoding: UTF-8 # A tool to output complex logs with minimal intrusion and smallest possible # footprint in the "host" code + additional ability to aggregate separate logs class InvisibleLogger # Lib Semantic Version Constant VERSION = '0.1.1' # Read-only content of the buffered ...
true
621d58835939974da27893c799440d2018445468
Ruby
mwagner19446/wdi_work
/w01/d03/Isaac/tip.rb
UTF-8
279
3.71875
4
[]
no_license
puts "Enter the price of your meal" price = gets.chomp.to_f puts "Enter the tax percentage" tax_rate = gets.chomp.to_f puts "What percentage would you like to tip" tip_rate = gets.chomp.to_f total = price + (price * (tax_rate/100)) + (price * (tip_rate/100)) print total.round(2)
true
e6ce6c582e051e0436f400609c1ac027bec479c0
Ruby
khaning96/Calc
/Calculator.rb
UTF-8
1,275
3.421875
3
[]
no_license
class Calculator def Evaluate (math) #Parentheses if math =~ /\((\d+[+\-\*\/\^]\d+)\)/ #Recursion time math.gsub!(/\(\d+[+\-\*\/\^]\d+\)/, Evaluate($1)) end #Exponents if math =~ /(([0-9]*\.?[0-9]*)\^([0-9]*\.?[0-9]*))/ math.gsub!(/(([0-9]*\.?[0-9]*)\^([0-9]*\.?[0-9]*))/, ($2.to_f**$3....
true
0a6947391134b89ac10da97c50128d3a4110ce5b
Ruby
tell-k/code-snippets
/ruby/map_between.rb
UTF-8
104
3.15625
3
[]
no_license
test = [1, 2, 3, 4, 5] def f(x) x.each_cons(2).map{|y,z| yield(y,z)} end p f(test){|x, y| x + y}
true
99144a6fe780791f8fa4048bd15033c60b5336ec
Ruby
tamietta/phase-0-tracks
/ruby/word-game/word-game.rb
UTF-8
2,472
4.34375
4
[]
no_license
class WordGame attr_reader :secret, :guess_count, :word_state, :guesses # METHOD: initialise word game # INPUT: secret word as string # OUTPUT: WordGame instance def initialize(secret) @secret = secret @guess_count = secret.length @word_state = ["_"] * secret.length @guesses = [] end #...
true
2283fcb7137e2b28350904b3d78ff2f980326fd2
Ruby
potatoHVAC/hackerrank
/ruby/tut_hello_hackerrank.rb
UTF-8
183
2.578125
3
[]
no_license
#https://www.hackerrank.com/challenges/ruby-hello-world/problem #completed Oct 2017 # Enter your code here. Read input from STDIN. Print output to STDOUT print "Hello HackerRank!!"
true
ef37075cedb8d0a44b110f8238932ec5128fcf5d
Ruby
jcompagni10/rand_gen
/lib/rand_gen.rb
UTF-8
4,132
3.59375
4
[]
no_license
require_relative "binary_min_heap" class RandomGenerator attr_reader :output_queue def initialize(gen_amt) @output_queue = [] @thread_output = gen_amt / 5 @running = false @thread_queues = Array.new(5) { [] } end #start random generator threads and writer thread def start @running = tru...
true
e6935538efd28ffd2af371fbdb8dc019f248656c
Ruby
Valeri01/PPS-ELSYS-2017-softwares
/domashno_pps.rb
UTF-8
626
2.921875
3
[]
no_license
require 'csv' require 'matrix' mat1 = "./matrix1.csv" mat2 = "./matrix2.csv" csv1 = Array.new csv2 = Array.new csv1_red = 0 csv1_kolona = 0 csv2_red = 0 csv2_kolona = 0 CSV.foreach(mat1) do |rows| csv1 << rows.map(&:to_i) csv1_red =+ 1 csv1_kolona = rows.size end CSV.foreach(mat2) do |rows| csv2 << ro...
true
892a4ee26628227b4cec703c10fd232d5f85250b
Ruby
BrodyRichardson/WIP
/WIP.rb
UTF-8
1,665
3.84375
4
[]
no_license
def Start item = ["Fountain Drink", "Frozen Drink", "Candy Bars", "Chips", "Hamburger", "Cheeseburger", "Hot Dog", "Chili Dog", "Pop Corn",] itemprice = ["1.00","1.50","1.00","0.50","2.00","2.50","1.50","2.00","0.50"] MenuDisplay(item, itemprice) UserSelection(item,itemprice) Totals() end ...
true
bea166057a48924a66b8f43609f383dc293e1417
Ruby
G9A2HvK9/tictactoe_techtest
/spec/game_spec.rb
UTF-8
1,038
2.84375
3
[]
no_license
describe Game do subject { Game.new } let (:game0) { Game.new(0) } let (:game1) { Game.new(1)} let (:grid) { subject.grid } it { is_expected.to be_an_instance_of(Game) } it { is_expected.to have_attributes(turn: nil) } it { is_expected.to respond_to(:play_move).with(2).arguments } it "should initiali...
true
31ab813903a3fcdd7693af709470e11000d56b64
Ruby
yenisbel/ruby_exercises
/practice-code.rb
UTF-8
10,519
4.15625
4
[]
no_license
require 'rspec/autorun' #By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. #What is the nth prime number? def nth_prime(n) arry_prime = [] value = 2 while arry_prime.size < n if is_prime?(value) arry_prime << value end value += 1 end ar...
true
c818124037afaf29c82737f6e0d4519bb2fcf3c8
Ruby
hackarts/wesabot
/lib/campfire/polling_bot/plugins/airbrake/airbrake/error.rb
UTF-8
1,201
2.625
3
[ "MIT" ]
permissive
module Airbrake class Error include DataMapper::Resource property :id, Serial property :error_id, Integer, :required => true attr_accessor :field # Given a block of XML returned from the Airbrake API, return an # Airbrake::Error object def self.from_xml(xml) field = {} xml.xp...
true
80c7c9b3cfe8e5297aec123c25542b90914dba28
Ruby
theachyutkadam/ruby_learning_basic
/school_operation/school.rb
UTF-8
3,738
3.765625
4
[]
no_license
class Classroom @@classroom = [] def process_classroom_creation print "How many class are you like to Add : " number_of_class = gets.chomp.to_i $school_count = @@classroom i = 0 while i < number_of_class print "Enter your #{i+1} class name : " c_name = gets.to_s.capitalize @@...
true
d7eafa27bd393473fdd1cca1553ceee9970338cc
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/robot-name/697b3defa5cd44f487ca5df155aafcdc.rb
UTF-8
392
3.265625
3
[]
no_license
class Robot ALPHABET = ('A'..'Z').to_a NUMERIC = (1..9).to_a def reset @last_name = @name @name = nil end def name @name ||= generate_name end private def generate_name alph = ALPHABET.dup.shuffle[0,2].join num = NUMERIC.dup.shuffle[0,3].join result = "#{alph}#{num}" ...
true