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
8eb3e26e20bc18da8f7be25b4a2cd02c116b670c
Ruby
hildjj/magic_reveal
/spec/magic_reveal/slide_renderer_spec.rb
UTF-8
3,883
2.75
3
[ "MIT" ]
permissive
require 'spec_helper' require 'magic_reveal/slide_renderer' require 'tmpdir' describe MagicReveal::SlideRenderer do describe '.header' do context 'when no slides have been shown' do before { subject.has_shown_slides = false } it 'starts with <section>' do expect(subject.header('text', 1)).to ...
true
c2e5cad7751e794b1953e9a0329b1fed7deea0eb
Ruby
NAKKA-K/learn-metapro-ruby
/blocks/instance_eval.rb
UTF-8
239
3.46875
3
[]
no_license
class MyClass def initialize @v = 1 end end obj = MyClass.new v = 2 # objインスタンスのスコープでコードを書ける obj.instance_eval do p self #=> #<MyClass:0x00007fb03d18c0c8 @v=1> p @v #=> 1 p v #=> 2 end
true
b27ad40e9011d6ad390e717168a7888ae037ca4d
Ruby
banthaherder/number-to-words
/lib/number_words.rb
UTF-8
796
3.484375
3
[]
no_license
class Integer def number_words # Partial list of required numbers ones = {0 => "zero", 1 => "one", 2 => "two", 3 => "three", 4 => "four", 6 => "six", 7 => "seven"} tens = {2 => "twenty ", 7 => "seventy ", 8 => "eighty "} # List of denomination names denoms = {1 => " hundred ", 2 => " thousand ",...
true
4fa7e79b1bdc6e9d75346a17895928a62f5e9cb0
Ruby
hisaacdelr/VideoStoreAPI
/test/models/movie_test.rb
UTF-8
1,688
2.765625
3
[]
no_license
require "test_helper" describe Movie do let (:movie) {Movie.new} let (:one) {movies(:one)} let (:two) {movies(:two)} it "must have a title to be vaild" do one.valid?.must_equal true one.title = nil one.valid?.must_equal false end it "must have a overview to be vaild" do one.valid?.must_eq...
true
99767a4110a0648a0abfe7fba224a6b3e1da72ae
Ruby
cjolokai/launchschool
/lesson_2/pseudo.rb
UTF-8
875
4.375
4
[]
no_license
#1. a method that returns the sum of two integers # START # GET one integer from user # GET another integer from user # RETRIEVE the sum of both integers # END #2 a method that takes an array of strings, and # returns a string that is all those strings # concatenated together # START # Given an array of strings call...
true
008184359a235bc995c88813b529c4fc689db798
Ruby
urbantumbleweed/urbantumbleweed
/w01/d03/Joshua_Lieberman/Homework/subway2.rb
UTF-8
1,377
3.359375
3
[]
no_license
n = ['ts', '34th', '28th-n', '23rd-n', 'us'] l = ['8th', '6th', 'us', '3rd', '1st'] s = ['gc', '33rd', '28th-s', '23rd-s', 'us'] mta = {} mta[:n] = n mta[:l] = l mta[:s] = s def subway(subway_hash) n = ['ts', '34th', '28th-n', '23rd-n', 'us'] l = ['8th', '6th', 'us', '3rd', '1st'] s = ['gc', '33rd', '28th-s', '23rd...
true
98abe59d66c72c6a7cfc684e676c9b7ff0468b4f
Ruby
rosariovalech/PruebaRuby2
/Ejercicio1.rb
UTF-8
85
3.046875
3
[]
no_license
class T def method1() puts "funciona" end end t = T.new t.method1()
true
c1e58fa4e850e529617d5da431ec0b83923504e5
Ruby
HoorayForZoidberg/tylerknottgregson
/finder.rb
UTF-8
2,119
3.671875
4
[]
no_license
# frozen_string_literal: true def check_snippet(snippet, target_sentence_array) # order words last to first (because snippets are found using the last word) # memoize the index marking the last word (start with snippet length) upper_boundary = snippet.length count = 0 # for each word, find the highest match...
true
73f0cd723661ac6aaa6cee7ab1c4a492ce38c813
Ruby
haggen/mobility
/lib/mobility/configuration.rb
UTF-8
1,300
2.59375
3
[ "MIT" ]
permissive
module Mobility =begin Stores shared Mobility configuration referenced by all backends. =end class Configuration # Alias for mobility_accessor (defaults to +translates+) # @return [Symbol] attr_accessor :accessor_method # Name of query scope/dataset method (defaults to +i18n+) # @return [Symbol...
true
4a38f3206cfef1bc20ac1c3f814d6ef95755606a
Ruby
fbonetti/great_lakes_data
/app/services/data_importer.rb
UTF-8
1,752
2.84375
3
[]
no_license
require 'open-uri' class DataImporter def self.import(station, year) # Alpena has a different path for some reason if station.id == 6 station_id = 'c6' else station_id = station.id.to_s.rjust(2, '0') end uri = URI::HTTP.build( host: 'www.glerl.noaa.gov', path: "/metdata/#...
true
22ae860063f96fec2aaaa11ace9fd31ed1a4d3cb
Ruby
erickcsh/TicTacToe
/spec/tic_tac_toe/input_spec.rb
UTF-8
6,226
2.578125
3
[]
no_license
require 'tic_tac_toe' require 'constants' require 'boards' describe TicTacToe::Input, ".input_name" do let(:display) { double(:display).as_null_object } subject { described_class.instance } before do allow(TicTacToe::Display).to receive(:instance) { display } allow(subject).to receive(:input_line) en...
true
1708863f357c6cc03b150a4cfeffbb38cdc3f858
Ruby
ScoRay72/awsum
/lib/awsum/s3.rb
UTF-8
9,206
2.859375
3
[ "MIT" ]
permissive
require 'awsum' require 'awsum/s3/bucket' require 'awsum/s3/object' require 'awsum/s3/headers' module Awsum # Handles all interaction with Amazon S3 # #-- # TODO: Change this to S3 # ==Getting Started # Create an Awsum::Ec2 object and begin calling methods on it. # require 'rubygems' # require 'aws...
true
4a3d9db963fefb8498aee802f34f4920ca37235f
Ruby
sol-vin/pixesoteric
/p_thread.rb
UTF-8
3,845
3.453125
3
[]
no_license
require_relative './memory_wheel' # Single thread for an instruction reader and executor. class PThread # parent of the thread, should be a machine attr_reader :parent # 2d array of instructions, is of type Instructions attr_reader :position_x, :position_y # direction of travel attr_reader :direction # m...
true
a18abd604a046b5959a7c8e84be304273e89d9da
Ruby
JRRHarper/class_project1
/danger_pets.rb
UTF-8
335
2.84375
3
[]
no_license
class DangerPets attr_reader :name, :species, :price, :danger_level def initialize( name, species, price, danger_level) @name = name @species = species @price = price @danger_level = danger_level end # def danger_test # for pet in @pets # for key, value in pet # return key if value...
true
166f5831da4b94d3cb24e6b1b8bbe728e4f7bbc1
Ruby
adamliesko/sng-histogram
/lib/tasks/computing.rake
UTF-8
1,278
2.703125
3
[ "MIT" ]
permissive
namespace :computing do task :compute_histograms => :environment do Artist.find_each do |artist| color_counts = Hash.new { |hash, key| hash[key] = 0 } global_histogram = Hash.new { |hash, key| hash[key] = 0 } artist.records.each do |record| record.histogram.each do |color, value| ...
true
76c24a9c5349848ca702c7bab84673f9c237acf3
Ruby
miguelnietoa/ruby-basics
/13-HashesII/merge_method_to_combine_hashes.rb
UTF-8
479
3.59375
4
[]
no_license
market = {garloc: "3 cloves", tomatoes: "5 batches", milk: "10 galons"} kitchen = {bread: "2 loaves", yogurt: "20 cans", milk: "100 galons"} # If there are keys in common, .merge will preserve ones of second hash p market.merge(kitchen) p kitchen.merge(market) # Bang method is available: .merge! # --- def custom_me...
true
84604ca550c35136621a073bc6521ecc668ff063
Ruby
Barendan/IH_exercises
/Week2/Monday/TodoList/lib/todo_list.rb
UTF-8
528
3
3
[]
no_license
class TodoList attr_reader :tasks attr_reader :user def initialize(user) @tasks = [] @user = user end def add_task(new_task) @tasks.push(new_task) end def delete_task(task_id) @tasks.delete_if do |task| task.id == task_id end end def find_task_by_id(t...
true
aad8161a008c6275637a6eff824fc80cab3f09f3
Ruby
carlhuda/thor
/spec/parser/option_spec.rb
UTF-8
5,881
2.78125
3
[ "MIT" ]
permissive
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') require 'thor/parser' describe Thor::Option do def parse(key, value) Thor::Option.parse(key, value) end def option(name, description=nil, required=false, type=nil, default=nil, banner=nil, group=nil, aliases=[]) @option ||= Thor::Optio...
true
915af428332a37a931bb8e89571aecc8ba5d8bca
Ruby
rajeshvyas2005/react-on-rails-tutorial
/lib/ruby_syntax/table_loop.rb
UTF-8
128
3
3
[]
no_license
#!/bin/ruby n = gets.strip.to_i (1..10).each_with_index do | country, index | puts "#{n} x #{index+1} = #{n*(index+1)}" end
true
9d04fd6db4cdc00fc438b10a50796320783b4cba
Ruby
dmagliola/maze_experiment
/app/models/maze_cell.rb
UTF-8
876
3.90625
4
[]
no_license
class MazeCell attr_accessor :coords attr_accessor :visited attr_accessor :neighbours attr_accessor :walls def initialize(x, y, maze_size) @coords = [x, y] @visited = false # Initialize the neighbors @neighbours = [] @neighbours << left unless x <= 0 @neighbours << up unless y <= 0 ...
true
617fae2915dd4ea79d03e87b4fdec628bab2d026
Ruby
ttscott2/programming_foundations
/lesson_3/easy1.rb
UTF-8
478
3.875
4
[]
no_license
#Question 1 # the code will print out the original numbers array. The uniq method is not destructive. # Question 2 # != is "not equals" # used before a variable, ! means "not"; used after a variable, it usually indicates a destructive method. # Question 5 range = (10..100) range_array = range.to_a if range_array.inclu...
true
d8b2bf50ba21bf7e2fed423e4e85607a274e05c3
Ruby
rsupak/tc-challenges
/DoubleLinkedList/double_linked_list/lib/double_linked_list.rb
UTF-8
1,433
3.671875
4
[]
no_license
# Node class for Double Linked List class Link attr_accessor :key, :val, :nxt, :prev def initialize(key = nil, val = nil, nxt = nil, prev = nil) @key, @val, @nxt, @prev = key, val, nxt, prev end def to_s "#{@key}, #{@val}" end end # Main Class class DoubleLinkedList attr_accessor :head, :tail, :l...
true
a8dd57a13b776af9eab9dd73cf6e90772a44108d
Ruby
bexfinken/phase-0-tracks
/ruby/classy house/house.rb
UTF-8
520
3.203125
3
[]
no_license
# # Build a house out of classes # HOUSE CLASS (A HOUSE IS MADE OF ROOMS, ROOMS OUT OF ITEMS) # Attributes: # - rooms (a collection of Room instances) # Methods: # - getter for rooms # - add_room (only allows up to 10 rooms) # - square_footage (adds up the house's square footage and returns it as an integer) # ...
true
b796ab1c9a9bbb19cf31a6d9ea9426723396e3bb
Ruby
codacy20/RubyExercism
/rna-transcription/rna_transcription.rb
UTF-8
662
3.0625
3
[ "MIT" ]
permissive
class Complement def self.of_dna(item = '') arr2 = ['G', 'C', 'T', 'A'] answer = [] unless item == '' count = item.length for i in 0...count if arr2.include?(item[i]) case item[i] when 'G' answer[i] = 'C' when 'C' ...
true
a2429492f38c2a0c9c98d15f76060bfbe6d1de89
Ruby
jakef203/RB101-ProgrammingFoundations
/Exercises/Easy5/bannerizer.rb
UTF-8
2,447
3.71875
4
[]
no_license
# def print_in_box(string) # length = string.length # print_horizontal_border(length) # print_inside_blank_line(length) # puts "| #{string} |" # print_inside_blank_line(length) # print_horizontal_border(length) # end # def print_horizontal_border(length) # puts "+#{'-' * (length + 2)}+" # end # def...
true
6d70cdd84d19a65a1b29c60b9656157e674b9378
Ruby
ericovinicosta/pdti-ruby-respostas-exercicio04
/resposta06.rb
UTF-8
798
3.546875
4
[]
no_license
=begin Faça um Programa que peça as quatro notas de 10 alunos, calcule e armazene num vetor a média de cada aluno, imprima o número de alunos com média maior ou igual a 7.0. =end dados_alunos = [] (1..10).each do |i| print "Informe o nome do aluno #{i}: " nome = gets.chomp notas = [] #solicitaçao de notas (...
true
3ac225adf389df8296c35fed17877629b1834b08
Ruby
ismcodes/nwrun
/app/models/event_manager.rb
UTF-8
392
2.578125
3
[]
no_license
class EventManager < ActiveRecord::Base belongs_to :runner before_create :zero_all def zero_all self.mean = self.stdev = self.number_races = 0 end def update_stats race_time self.mean = (self.mean * self.number_races + race_time) / (self.number_races + 1).to_f #puts "#{self.mean} #{race_time} #{...
true
488b0c6f0591c02f0ff05af4e1890fc418adc02f
Ruby
kirizawa/webtrends_api_parser
/lib/wt_api_extract.rb
UTF-8
796
2.5625
3
[]
no_license
require 'net/http' require 'net/https' def query(account, username, password, query) # puts account # puts username # puts password # puts query hostname = "ws.webtrends.com" https = Net::HTTP.new(hostname, Net::HTTP.https_default_port) https.use_ssl = true https.ca...
true
972cc260e756094d6ede53e7661d24933d1b2f75
Ruby
stephan-dev/MVC_THP_Next_s01
/app/models/item.rb
UTF-8
741
2.859375
3
[]
no_license
# frozen_string_literal: true # == Schema Information # # Table name: items # # id :bigint(8) not null, primary key # original_price :float not null # has_discount :boolean default(FALSE) # discount_percentage :integer default(0) # created_at ...
true
23fbdff7062ff4abdbbf5511bfd06eee5577ded8
Ruby
dallinder/ls_small_pbs_round2
/easy_5/1.rb
UTF-8
108
3.109375
3
[]
no_license
def ascii_value(string) string.chars.map { |char| char.ord }.inject(:+) end p ascii_value('Four score')
true
34240a984de66d60b66485de6dbeaf80cda8a169
Ruby
eriksk/kawaii
/lib/kawaii/physics_manager.rb
UTF-8
968
2.84375
3
[ "MIT" ]
permissive
require 'chipmunk' module Kawaii class PhysicsManager attr_accessor :space, :entities SUBSTEPS = 10 def initialize @space = CP::Space.new @space.gravity = CP::Vec2.new(0, 5) @entities = [] end def add_static_physics_entity entity if entity.class == PhysicsEntity @entities.push entit...
true
04807846c87e28aa5c87a1f7a6e95abc81883232
Ruby
shiryu92/metafuzz
/src/word_fuzzbot/debug_server.rb
UTF-8
1,394
2.5625
3
[]
no_license
require File.dirname(__FILE__) + '/../core/connector' require File.dirname(__FILE__) + '/conn_cdb' require 'rubygems' require 'msgpack/rpc' require 'trollop' OPTS=Trollop::options do opt :port, "Port to listen on, default 8888", :type=>:integer, :default=>8888 opt :debug, "Debug output", :type=>:boolea...
true
cf877700f7e0448735c09e1d983bc06a2c07171a
Ruby
genericlady/design_patterns
/chapter01_strategy/interface/ruby/duck_sim/lib/fly_with_wings.rb
UTF-8
62
2.65625
3
[]
no_license
class FlyWithWings def fly puts "I'm flying!" end end
true
a8783df0723ab0cf9f9f25fbe141a1981f17be96
Ruby
craigem/LearnRubyTheHardWay
/ex19.rb
UTF-8
2,276
4.4375
4
[]
no_license
# Defines the function cheese_and_crackers def cheese_and_crackers(cheese_count, boxes_of_crackers) # Prints the text and the value ot cheese_count to STDOUT puts "You have #{cheese_count} cheeses!" # Prints the text and the value ot boxes_of_crackers to STDOUT puts "You have #{boxes_of_crackers} boxes of crack...
true
a719509b36f4bbd8684a57d6cceee20a01294674
Ruby
bcasadei/hangman
/hangman.rb
UTF-8
4,356
3.734375
4
[]
no_license
require 'yaml' # Word class defines a random word for the game. class Word def random contents = File.open('5desk.txt', 'r').read array = contents.split.select { |word| word.size > 4 && word.size < 13 } array.sample(1).join.downcase end end # Player class defines player's information class Player at...
true
07827422f611de134f854617ce64fbd22182cac1
Ruby
KarlHarnois/task_cli
/lib/task_cli/deserializers/task_deserializer.rb
UTF-8
277
2.625
3
[ "MIT" ]
permissive
require 'json' require_relative '../models/task' class TaskCli class TaskDeserializer def initialize(json) @json = JSON.parse(json) end def to_item Task.new(@json) end def to_list @json.map { |json| Task.new(json) } end end end
true
f8f3a9da0890a850e40c40b3c4c1ac52baea88e1
Ruby
pharaonick/ls_101
/ex/easy8/middle_char.rb
UTF-8
634
4.34375
4
[]
no_license
# input: non-empty str # output: return middle char if str odd length, middle 2 if even # -- 1 char, return that char def center_of(str) if str.length.odd? str[str.length / 2] else str[str.length / 2 - 1, 2] # this sets length of 2 char from position end end # might be better to set length variable but ...
true
29187505443b3b3fb90043222e367bbb3252fe0e
Ruby
wainhudec88/escuchat
/vendor/plugins/attr_encrypted/lib/huberry/attr_encrypted/default_encryptor.rb
UTF-8
834
2.53125
3
[ "MIT" ]
permissive
module Huberry module AttrEncrypted class DefaultEncryptor require 'openssl' def self.encrypt(value, key, options = {}) crypt 'encrypt', value, key, options end def self.decrypt(value, key, options = {}) crypt 'decrypt', value, key, options end p...
true
dfc3754eda628c37d794b6de54b6838730a39eab
Ruby
pitosalas/ruby_inheritance_demo
/example1.rb
UTF-8
623
3.75
4
[]
no_license
require 'pry-byebug' # Represent game characters that can move: People and Cars # Using a @type variable (an immedaite smell!) class Character attr_reader :location, :velocity, :type def initialize(args) @type = args[:type] @velocity = args[:starting_v] end def passengers if @type == :car 4...
true
8f2d58452b87fa16ddc0a75e283d736f4db96630
Ruby
alwikah/chronoTime
/app/models/item.rb
UTF-8
826
2.859375
3
[]
no_license
class Item < ActiveRecord::Base attr_accessible :label, :payment_type, :payment_unit, :time validates :time, :presence => true before_validation :setup def setup self.time = 0 if(self.time.nil?) end def self.clean_all_items unless Item.count > 10000 Item.all.each do |item| unless i...
true
af6c68bf4652a7dce7c155d24031046dd60ef78a
Ruby
bRRRITSCOLD/openweatherrough
/lib/owm/classes/response.rb
UTF-8
277
2.953125
3
[]
no_license
module OWM class Response attr_accessor :response, :response_body, :weather def initialize res @response = res end def response_body @response_body = @response.body end def weather @weather = Weather.new JSON.parse(response_body) end end end
true
41789e61807ef10d082b583a9536392600244b7e
Ruby
dmyers3/launch_school_101
/Exercises/Easy6/reversed_arrays.rb
UTF-8
409
3.65625
4
[]
no_license
def reverse!(arr) arr_copy = arr.dup arr_size = arr.size arr.map! do |element| arr_size -= 1 arr_copy[arr_size] end end def reverse(arr) arr_copy = arr.dup arr_size = arr.size arr.map do |element| arr_size -= 1 arr_copy[arr_size] end end # list = %w(a b c d e) # result = reverse!(lis...
true
de13e38e0026008c4a9ac776ecc03189f4f92246
Ruby
crawsible/advent-2019
/01/spec/fuel_counter_spec.rb
UTF-8
1,220
2.78125
3
[]
no_license
require 'fuel_counter' RSpec.describe FuelCounter do describe "#required_fuel_for_modules" do context "with one module weight" do it "returns its required fuel amount without factoring fuel weight" do expect(FuelCounter.new([9]).required_fuel_for_modules).to eq(1) expect(FuelCounter.new([33...
true
d07bcd0db6cb0ad1197c051ab305efc582b74e45
Ruby
co2co2/nov29ordinal_indicator
/Untitled.rb
UTF-8
275
4.0625
4
[]
no_license
def ordinal_indicator(number) n = number.to_s.split('') if n[-1] == "1" puts "#{number}st" elsif n[-1] == "2" puts "#{number}nd" elsif n[-1] == "3" puts "#{number}rd" else puts "#{number}th" end end puts ordinal_indicator(12)
true
a4858f2f15c187e20501a8735e1f674f433a0323
Ruby
sagutierrez10/routes-controllers
/practice/app/controllers/hello_controller.rb
UTF-8
743
2.609375
3
[]
no_license
class HelloController < ApplicationController def index render :text => "Hello Coding Dojo!" end def say render :text => "Saying hello!" end def sayname render :text => "Saying Hello Joe" end def saynamem if params[:name] == 'michael' redirect_t...
true
c316063af58f57ffc362f07c3c970ac6bde3cbd5
Ruby
DenisColoma/Semaine03_J01_Ruby_spec
/lib/00_hello.rb
UTF-8
95
3.34375
3
[]
no_license
def hello return "Hello!" end name = gets.chomp def greet(name) return "Hello, #{name}!" end
true
b633c173a5be2e744eadda768359ace2051a29b9
Ruby
akoltun/form_obj
/test/form/persistence_test.rb
UTF-8
4,260
2.921875
3
[ "MIT" ]
permissive
require "test_helper" class FormPersistenceTest < Minitest::Test class Team < FormObj::Form attribute :name attribute :cars, array: true, primary_key: :code do attribute :code attribute :driver end attribute :colour do attribute :rgb end end class DefaultTeam < FormObj::Fo...
true
6de573a52e0f0f539f0dbe9378ece38ba9ab147d
Ruby
Azzamobeid/Azzam_The_Bank
/Thebank/the_bank.rb
UTF-8
3,855
3.625
4
[]
no_license
require_relative 'bank_classes' @customers = [] @accounts = [] def welcome_screen @current_customer = "" puts "Welcome to Azzam's Bank" puts "Please choose for Menu" puts "_-_-_-_-_-_-_-_-_-_-_-_" puts "1. Customer sign-in" puts "2. New customer registration " choice = gets.chomp.to_i case choice wh...
true
4273d5f121e39e672e258cc763e0c6ecf06cd689
Ruby
WHomer/mod1-midmod
/test/student_test.rb
UTF-8
711
3.046875
3
[]
no_license
require 'minitest/autorun' require './lib/student' class TestStudent < MiniTest::Test def setup @morgan = Student.new({name: "Morgan", age: 21}) end def test_it_exists assert_instance_of Student, @morgan end def test_it_has_a_name assert_equal "Morgan", @morgan.name end def test_it_h...
true
c668aacd99e469a061265f8c9cc1920613d655c3
Ruby
Anthony-Mendola/pokemon-scraper-v-000
/lib/pokemon.rb
UTF-8
799
3.09375
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class Pokemon attr_accessor :id, :name, :type, :hp, :db DATABASE_CONNECTION = SQLite3::Database.new('db/pokemon.db') def initialize(attributes) attributes.each {|attribute, value| self.send(("#{attribute}="), value)} end def self.save(name, type, db) sql = File.read("db/schema_migration.sql") db.execute_b...
true
2c49b713e20a513bdaf5762de9822e75fb90a455
Ruby
fenkod/todos
/spec/todo/todo_spec.rb
UTF-8
2,235
2.875
3
[]
no_license
require 'spec_helper' class Login < SitePrism::Section element :username_input, "input#username" element :password_input, "input#password" element :submit_button, "input[value='Login']" def login_with(username, password) username_input.set(username) password_input.set(password) submit_button.click end en...
true
dd49b95a82b3715bb311b75dd076c068f7374549
Ruby
Lojistic/NwsAlerts-gem
/lib/nws/api/alerts/alert.rb
UTF-8
1,852
2.796875
3
[ "MIT" ]
permissive
# The Alert class encapsulates all of the important information for a given weather alert module Nws module Api module Alerts class Alert attr_reader :nws_id, :onset, :expires, :message_type, :severity, :certainty, :urgency, :instruction, :geometry def self.from_api_response(client, pars...
true
345d28e5f8727c0698a7bafe86a010fe6538a5d6
Ruby
mk10305/rubyonrails_bootcamp
/intro_to_ruby_web_dev/precourse/1_Basics/3.rb
UTF-8
150
2.984375
3
[]
no_license
movies = {:Snow_White => 1937, :Cinderalla => 1950, :Jungle_Book=> 1967} puts movies[:Snow_White] puts movies [:Cinderalla] puts movies[:Jungle_Book]
true
d3a0acbeb2c86dd717db2f8b67bf3ab051bdbc4b
Ruby
Flameeyes/attic
/try/10_attic_tryouts.rb
UTF-8
944
2.78125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
group "Attic" library :attic, "lib" tryouts "Basics" do drill "can extend Attic", true do class ::Worker extend Attic def kind() :true end end # 1.9 # 1.8 Worker.methods.member?(:attic) || Worker.methods.member?('attic') end drill "can't include Attic ...
true
8272ddaf1643420d3285f43f9604370ec7e188d0
Ruby
tbae2/odin_project_ruby
/ceaser_cipher.rb
UTF-8
1,271
3.90625
4
[]
no_license
def ceaser_cipher(userentry, shift) #how to create ceaser_cipher index pulled from an example, taking notes as decoding what someone has done #for learning purposes #the a to z ranges produce a - Z to_a places i into an array. concat appends A-Z caps array #to preexisting array alphabet_index = ('a'....
true
455ef49899f35b258e8dffe0cb3ba261f648badf
Ruby
mgmilton/black_thursday
/test/item_test.rb
UTF-8
417
2.6875
3
[]
no_license
require './test/test_helper' require './lib/item' class ItemTest < MiniTest::Test def setup @item = Item.new({ :name => "Pencil", :description => "You can use it to write things", :unit_price => BigDecimal.new(1099), :created_at => Time.now, :updated_at => Time.now}) end...
true
0b7744fe1680b792f9f7fad8ccb89771be118b5f
Ruby
h0tl33t/Gradebook
/test/models/enrollment_test.rb
UTF-8
2,060
2.625
3
[]
no_license
require 'test_helper' class EnrollmentTest < ActiveSupport::TestCase setup do @enrollment = Enrollment.first end teardown do @enrollment = nil end test 'invalid without a student' do enrollment = FactoryGirl.build(:enrollment, student: nil) refute enrollment.valid?, 'Not validating pres...
true
c50e3fa76abee746b481df44d30469b1913a0d63
Ruby
kristianmandrup/partializer
/lib/partializer/collection.rb
UTF-8
2,212
2.859375
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
class Partializer class Collection include Enumerable include Partializer::PathHelper attr_reader :hashie, :name, :ns, :action def initialize name, *items hash = items.extract_options! partials << partial_keys(items) self.name = name.to_s @hashie = Hashie::Mash.new reso...
true
ea63927437189005d3135a213bdd69d9b317b9a5
Ruby
ralzate/FES2
/app/decorators/user_decorator.rb
UTF-8
283
2.5625
3
[]
no_license
module UserDecorator def select_genero [['Masculino', 1], ['Femenino', 2]] end def label_generos if select_genero.flatten.include?(genero.to_i) select_genero.each { |nombre, id| return nombre if genero.to_i == id } end end end
true
85b82abb98d13ebbd2b15031e1dac0a8ebafebe1
Ruby
gegerlan/Gentle-Love-Quest
/Source/Scripts/Scene_End.rb
UTF-8
4,914
2.59375
3
[]
no_license
#============================================================================== # ** Scene_End #------------------------------------------------------------------------------ # This class performs game end screen processing. #============================================================================== class Scene_E...
true
54f111efacd571d3e77020c0b5e2b26c2ed91261
Ruby
carolyny/launchschool
/Backend/101/Exercises/bonus.rb
UTF-8
205
3.375
3
[]
no_license
def calculate_bonus(salary, yesno) if yesno == true salary/2 else 0 end end puts calculate_bonus(2800, true) == 1400 puts calculate_bonus(1000, false) == 0 puts calculate_bonus(50000, true) == 25000
true
20ce21c4e80cdf90b998d90c1e1ac6c7046412c5
Ruby
dam5s/somanyfeeds
/app/models/feed/blog.rb
UTF-8
1,078
2.90625
3
[ "MIT" ]
permissive
require 'open-uri' require 'nokogiri' class Feed::Blog < Feed def self.default new(name: 'My Blog', info: 'your blog url') end def url=(info) if info new_url = info.normalize_url new_url.insert(0, 'http://') unless info.match /^http/ if doc = Nokogiri(open new_url) rescue nil ...
true
6a9f8bf1522b612f4f0e4afb63a9febc5ecf4865
Ruby
jk1dd/night_writer
/lib/file_writer.rb
UTF-8
223
3.1875
3
[]
no_license
class FileWriter def write_braille (string) write_file = File.open(ARGV[1], 'w+') write_file.write(string) write_file.close puts "Created file #{ARGV[1]} containing #{string.length} characters." end end
true
c8c5f414f4f2f549409b2f56183e1a860e50e29b
Ruby
nilbus/teaspoon
/lib/teaspoon/utility.rb
UTF-8
696
3.0625
3
[ "BSD-3-Clause", "MIT" ]
permissive
module Teaspoon module Utility # Cross-platform way of finding an executable in the $PATH. # http://stackoverflow.com/questions/2108727/which-in-ruby-checking-if-program-exists-in-path-from-ruby # # @example # which('ruby') #=> /usr/bin/ruby # # @param cmd [String] the executable to fin...
true
ea3ddae5d80f93fc3ebebcff6909863ff1810dfb
Ruby
AaronC81/parlour
/lib/parlour/options.rb
UTF-8
2,489
3.203125
3
[ "MIT" ]
permissive
# typed: true module Parlour # A set of immutable formatting options. class Options extend T::Sig sig { params(break_params: Integer, tab_size: Integer, sort_namespaces: T::Boolean).void } # Creates a new set of formatting options. # # @example Create Options with +break_params+ of +4+ and +tab...
true
434ba02a56534f6f2be45ed0c791d5d3739c0394
Ruby
DanielaCarvajal/ruby-collaborating-objects-lab-v-000
/lib/mp3_file.rb
UTF-8
190
3.046875
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class MP3File attr_reader :artist, :song, :genre def initialize(file) @artist = file.split(" - ")[0] @song = file.split(" - ")[1] @genre = file.split(" - ")[2] end end
true
01eee193fe3a4a68becc0e70eee0d2b4affe05c1
Ruby
fabianp5060/bwtoolkit
/src/bwhelpers/confluence_helpers.rb
UTF-8
1,815
2.734375
3
[]
no_license
require 'net/http' require 'uri' class CDKConfluence def initialize(config_data) c = $bw.get_app_config(config_data) @url = c[:confluence_url] @user = c[:confluence_user] @pass = c[:confluence_pass] end def fetch(uri_part, limit=10) raise ArgumentError, 'too many HTTP redirects' if limit == 0...
true
b2dd75f2c78d4ca4c7f504447f8c5b1461ed1f89
Ruby
dominictarr/practice
/class_herd/old/class_conductor2.rb
UTF-8
2,366
3.109375
3
[]
no_license
#class conductor using symbol shadowing #~ #two ways to reconfigure: #~ #1. #~ #replace (X,Y) #~ #means: always use Y in the place of X globally. #~ #2. #~ #for(A).replace(B,C) #~ #means: A now uses C instead of B #~ #3. #~ #[for(A)].replace(B,C).when {test is true}... #~ #could monkey patch Class instead of going For...
true
0b4906dcf350afa0a2e4f210b3e087d7df6e9ac8
Ruby
andhapp/rb_tnetstring
/lib/rb_tnetstring/encoder/integer_encoder.rb
UTF-8
213
2.640625
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
module RbTNetstring class IntegerEncoder < Encoder def initialize(obj) @obj = obj end def encode int_string = @obj.to_s "#{int_string.length}:#{int_string}#" end end end
true
9b86d18c96ed52d47b4fa87d72f800ce0caa4bf1
Ruby
hyperturing/chess
/lib/game.rb
UTF-8
1,591
3.78125
4
[]
no_license
require './board.rb' require './player.rb' class Game attr_reader :board, :players, :winner def initialize(player1: 'Ashley', player2: 'Ashley-2.0') instructions @board = Board.new @players = { white: Player.new(name: player1), black: Player.new(name: player2) } @board.display_bo...
true
3e4145a623c4493933d9207bf4d0a0a6ba3071ab
Ruby
ajessen-thp/exercice_ruby
/exo_13.rb
UTF-8
120
3.296875
3
[]
no_license
puts "Qu'elle est ton année de naissance ?" year = gets.chomp.to_i i = year while i != 2017 do i = i + 1 puts i end
true
e66d4ee55dfe9c5618189b9c218f6fa12f242c5c
Ruby
CDRH/african_poetics
/config/initializers/data.rb
UTF-8
514
2.5625
3
[]
no_license
# this file collects the country and region information # for display on the map pages yml_path = File.join(Rails.root, "config", "data", "countries.yml") begin COUNTRIES = YAML.load_file(yml_path)["countries"] # TODO remove or alter this when we are no longer supporting originally # proof of concept map c...
true
367eb75f1dfe6c21271a003eac405cdd07c2dab6
Ruby
mattcameron/WDI-MELB-2_Homework
/Matt Cameron/classwork/7-tdd/tdd/phone/phone.rb
UTF-8
376
3.6875
4
[]
no_license
class Phone def initialize(number) @number = number.tr('(). -', '') end def number @number[0] = '' if @number[0..1] == "11" && @number.length == 11 @number = "0000000000" if @number.length == 11 || @number.length == 9 @number end def area_code @number[0..2] end def to_s @number.insert(0, '(') @...
true
c5f5d3e59e0f41699818c546626d96fb5d820b64
Ruby
aherrmann20/Week_1_Project
/rehearse-app.rb
UTF-8
3,202
2.65625
3
[]
no_license
require "sinatra" get '/' do erb :home end get "/songs/:song" do |song| random_number = rand(3) if random_number == 0 redirect("https://www.youtube.com/watch?v=dQw4w9WgXcQ") end @songs = { breaking_free: { movie: "High School Musical", lyrics: "http://www.lyricsmode.com/lyrics/h/high_school_musi...
true
ae53da1507bb9f734da67352c55aedb79307c160
Ruby
Alex2Yang/prepcourse_ruby_exercises
/tla_ruby_workbook/easy_quiz_2/ex9.rb
UTF-8
152
3.421875
3
[]
no_license
# Using array#map!, shorten each of these names to just 3 characters: # # flintstones = %w(Fred Barney Wilma Betty BamBam Pebbles) # flintstones.map! { |i| i[0..2]}
true
e68611096bb2e7b89a6bc27b2fcba8ee97274050
Ruby
Velfolt/fyb
/lib/fyb/client.rb
UTF-8
2,215
2.828125
3
[ "MIT" ]
permissive
module Fyb # Client class containing all the methods needed to buy and sell btc. class Client # Returns the current ask price. def ask BigDecimal Fyb.public.ticker.perform.parse['ask'], 2 end # Returns the current bid price. def bid BigDecimal Fyb.public.ticker.perform.parse['bid'],...
true
8b51c28c584f88e2a11b5fdf92fa8149acc8edbd
Ruby
isabella232/statue
/lib/statue/backends/udp.rb
UTF-8
812
2.5625
3
[ "MIT" ]
permissive
require 'socket' module Statue class UDPBackend attr_reader :host, :port def self.from_uri(uri) uri = URI(uri) new(host: uri.host, port: uri.port) end def initialize(host:, port:) @host = host @port = port end def collect_metric(metric) if metric.sample_rate =...
true
f21199b78877641b23aa37ef3753f2d4eb29624a
Ruby
showwin/AtCoder
/agc001/A.rb
UTF-8
190
2.96875
3
[]
no_license
n = gets.to_i c = gets.split("").map{|str| str.to_i } cnt = [] 1.upto(4) do |ans| cnt[ans-1]=0 n.times do |i| cnt[ans-1] += 1 if ans == c[i] end end print "#{cnt.max} #{cnt.min}\n"
true
db5ad3e93336ba8c56a310d79c30a29837cb364f
Ruby
firehose-codemasters/codemasters_chess
/app/models/game.rb
UTF-8
2,457
2.6875
3
[]
no_license
class Game < ApplicationRecord belongs_to :white_player, class_name: 'User' belongs_to :black_player, class_name: 'User' validates :name, presence: true has_many :pieces # Need to communicate that each game has this validates :result, inclusion: { in: %w(in_progress white_win black_win draw), message:...
true
ada5927760588e07cb577e8f0b33fab7eee8ece6
Ruby
bschwartz10/def_method
/lib/player.rb
UTF-8
468
3.421875
3
[]
no_license
class Player attr_reader :player, :last_name, :first_name, :gender, :favorite_color, :date_of_birth def initialize(player) @player = player @last_name = player[0] @first_name = player[1] @gender = formatted_gender @favorite_color = player[3] @date_of_birth = formatted_date_of_birth end ...
true
b9de71b2c0e1fda8c88f2f571efce77c35ca2c5b
Ruby
jpietrzyk/kwh-api
/app/services/get_cached_request_service.rb
UTF-8
975
2.875
3
[]
no_license
require 'redis' require 'json' # This is first layer cache writter. It saves request url as a key, and # parsed and validated result as a value, so when request is in cache # we don't need parse raw xml, and validate responsed data class GetCachedRequestService def initialize(request:) @redis = Redis.new @re...
true
638309ffa6c80432b1a8249e0f942322eda1caeb
Ruby
somcode/Leap-years
/lib/leap_year.rb
UTF-8
89
2.84375
3
[ "MIT" ]
permissive
def leap_year?(year) (year % 400).zero? || (year % 4).zero? && !(year % 100).zero? end
true
1e815f45b2f26364a3759972a7b73f6e0e3805b1
Ruby
kelvinjhwong/ruby-exercises
/ruby-small-problems/03_easy_3/03_10.rb
UTF-8
542
4.0625
4
[]
no_license
# Does not work for numbers with leading 0s require 'pry' def palindromic_number?(number) number = number.to_s binding.pry while number.start_with? '0' number = number[1..-1] end number == number.reverse end puts palindromic_number?(034543) == true puts palindromic_number?(00123210) == false puts palin...
true
f1e8998330e56851785aa2d4b4223266d0a034c7
Ruby
konung/rubytoolbox
/app/models/search.rb
UTF-8
327
2.59375
3
[ "MIT" ]
permissive
# frozen_string_literal: true class Search attr_accessor :query private :query= def initialize(query) self.query = query.presence&.strip end def query? query.present? end def projects @projects ||= Project.search(query) end def categories @categories ||= Category.search(query) e...
true
afb15e8202bfa3a7188b71d4d1950fff733fee68
Ruby
amyfranz/ruby-metaprogramming-mass-assignment-lab-london-web-012720
/lib/person.rb
UTF-8
722
2.875
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class Person attr_accessor :name, :birthday, :hair_color, :eye_color, :height, :weight, :handed, :complexion, :t_shirt_size, :wrist_size, :glove_size, :pant_length, :pant_width @@all = [] def initialize(*args) @name = args[0][:name] @birthday = args[0][:birthday] @hair_color = args[0][:hair_color] ...
true
2f06ab5e05425f26c580d1c0d5ac60f697ee4a42
Ruby
Umnums/ttt-7-valid-move-online-web-sp-000
/lib/valid_move.rb
UTF-8
500
3.5
4
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
def position_taken?(board,index) if (board[index] == "" || board[index] == " " || board[index] == nil) return false else puts "true" return true end end def valid_move?(board, index) if (index >= 0 && index <= 8 && !position_taken?(board,index)) puts "true" return true else puts ...
true
b3a073aae78a06e2524c323f2c13c8d39b81ac57
Ruby
mofahmy/clio
/scripts/scrape_cfps.rb
UTF-8
3,456
2.921875
3
[ "CC0-1.0" ]
permissive
#!/usr/bin/ruby require 'rubygems' require 'nokogiri' require 'open-uri' require 'sqlite3' $script_dir = File.dirname(__FILE__) # Read in categories names from a text file (one per line) def load_categories(file) categories = IO.readlines(file) categories.each do |cat| cat.strip! end return categories ...
true
cfb5789a9f43df8fd850833f1d42a78bf467afee
Ruby
CFWLoader/LeetCode
/Problem557/Solution.rb
UTF-8
644
3.5
4
[]
no_license
# @param {String} s # @return {String} def reverse_words(s) ret_val = '' end_idx = -1 back_idx = 0 iter_idx = 0 iter_end = s.size while iter_idx != iter_end if s[iter_idx] == ' ' back_idx = iter_idx - 1 while back_idx > end_idx ret_val << s[back_idx] back_idx -= 1 ...
true
69d02a951df3c2fbbfefa53251143b5dd65fa818
Ruby
ucarion/moho
/lib/moho/lang.rb
UTF-8
1,459
2.796875
3
[ "MIT" ]
permissive
module Moho module Lang class Environment < Struct.new(:bindings, :parent) def [](name) bindings.fetch(name) { parent[name] } end def self.global Stdlib.env end end class Expression < Struct.new(:value) end class List < Expression def eval(env = Env...
true
feda140fbc54f9a0fa8957aab4013602a30d929c
Ruby
hawkenritter/phase-0-tracks
/ruby/puppy_methods.rb
UTF-8
888
4.09375
4
[]
no_license
#class Puppy# # def fetch(toy) # puts "I brought back the #{toy}!" # toy # end# # def rollover # puts "*rollover*" # end# # def speak(integer) # puts "Woof! " * integer # end # def dog_years(human_years) # dog_age = 7 * human_years # puts "is " + dog_age.to_s + " years old" # end # def sha...
true
2038ab95fb42e01151fd0f8e9dc5bfec3d8979e0
Ruby
SlevinMcGuigan/SMG
/library/test/tc_book_in_stock.rb
UTF-8
1,444
3.359375
3
[]
no_license
require 'test/unit' require 'lib/book_in_stock' class TcBookInStock < Test::Unit::TestCase def test_isbn_is_initialized_correctly book = BookInStock.new("1234",23) assert_equal("1234",book.isbn) end def test_price_is_initialized_correctly book = BookInStock.new("1234",23) assert_equal(2...
true
4bf1cee6da5fcba1e6d37aac345b3284ae746921
Ruby
JayZonday/oo-cash-register-web-112017
/lib/cash_register.rb
UTF-8
1,200
3.28125
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class CashRegister attr_accessor :discount, :total, :items def initialize(discount=0) @total = 0 @discount = discount @items = [] end def add_item(title, price, quantity = 1) @last_total = total @total += price * quantity quantity.times do @items << title end end def apply_discount if discount > 0 @tot...
true
0e095e38ded8854aa1a4b03909e6561caa476726
Ruby
kimpalita/ironhack_week_01_02
/ex_unit_test/spec/conway_game2_spec.rb
UTF-8
1,552
2.703125
3
[]
no_license
require_relative '../conway_game2.rb' require 'pry' RSpec.describe "" do before :each do @grid_cells = [{x: 1, y: 1}, {x: 1, y: 2}, {x: 1, y: 3}, {x: 2, y: 1}, {x: 2, y: 2}, {x: 2, y: 3}, {x: 3, y: 1}, {x: 3, y: 2}, {x: 3, y: 3}] end let(:first_seeds) do instance_double("Seed Generation Grid", :seed_positi...
true
90a1c59c583881c302c6a980c09c5e60e0333ccb
Ruby
tylerb33/ruby-lists
/planets.rb
UTF-8
1,440
4.0625
4
[]
no_license
planet_list = ["Mercury", "Mars"] #Use push() to add Jupiter and Saturn at the end of the array. planet_list.push("Jupiter", "Saturn") # puts planet_list #Use the concat() method to add another array of the last two planets in our solar system to the end of the array. planet_list.concat(["Uranus", "Neptune"]) #Use i...
true
c720872039757059d85824173483fd22dffe9a32
Ruby
bertrandk/botr
/lib/botr/videos/video_tag.rb
UTF-8
1,666
2.84375
3
[ "MIT" ]
permissive
module BOTR # The BOTR::VideoTag class contains calls for manipulating video tags. # # Tags are essentially labels that can be used for the classification of # videos. class VideoTag < BOTR::Object class << self attr_reader :last_status # Return a list of video tags. # # @param [Hash] options sea...
true
37599c0c46c05171900a4b7d4e9ad9267dfe911e
Ruby
ekene966/hackerrank
/ruby/compare_the_triplets.rb
UTF-8
512
3.59375
4
[ "MIT" ]
permissive
# Triplet Comparator class TripletComparator def self.scores(a_triplet, b_triplet) "#{a_score(a_triplet, b_triplet)} #{b_score(a_triplet, b_triplet)}" end def self.a_score(a_triplet, b_triplet) a_triplet.zip(b_triplet).count { |a, b| a > b } end def self.b_score(a_triplet, b_triplet) a_triplet.z...
true
e1d65a3dfefdf12c79e4cdf8973a20376a73573f
Ruby
remyaub/ruby
/exo_21.rb
UTF-8
352
3.21875
3
[]
no_license
puts " Salut, bienvenue dans ma super pyramide ! Combien d'étages veux-tu ?" print " > " userFloor = gets.to_i v = 0 diez = "#" space = " " if userFloor <= 25 puts "Let's go bro" loop do break if v == userFloor (userFloor - 1 - v).times do print space end puts diez diez += "#" v += 1 end else puts...
true
55dd91d3d44ecddeedb37847cf9139f2cd8236a1
Ruby
stefanp227/Athlon-task
/spec/deck_spec.rb
UTF-8
650
3.109375
3
[]
no_license
require_relative '../deck' require_relative '../card' require_relative 'spec_helper' describe Deck, "#count" do context "testing deck functionalities" do it "checks the size of the deck" do deck = Deck.new expect(deck.count).to eql 52 end end end describe Deck, "#draw" do context "testing deck functional...
true
c345c5e682c971fca8c450e243796cad6c7c6948
Ruby
pooja-yadav-ctrl/Ror-training
/ruby monk/cubes.rb
UTF-8
97
3.546875
4
[]
no_license
def sum_of_cubes(a, b) (a..b).inject(0) { |sum, x| sum += (x*x*x)} end puts sum_of_cubes(1,3)
true
c132af22fa6b92481a36c3a0d09e664f04618638
Ruby
ducc/dablang
/src/compiler/nodes/node_reference_member.rb
UTF-8
391
2.65625
3
[ "MIT" ]
permissive
require_relative 'node_reference.rb' class DabNodeReferenceMember < DabNodeReference def initialize(base, name) super() insert(base) @name = name end def base children[0] end def name @name end def compiled DabNodePropertyGet.new(base.compiled, @name) end def formatted_sou...
true