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
bfed4377d9d355f8e8b3f3fc1e9ca3e85e2dbc26
Ruby
FiXato/ubuntu-machine
/lib/capistrano/ext/ubuntu-machine/helpers.rb
UTF-8
2,628
2.828125
3
[ "MIT" ]
permissive
require 'erb' # render a template def render(file, binding) template = File.read("#{File.dirname(__FILE__)}/templates/#{file}.erb") result = ERB.new(template).result(binding) end # allows to sudo a command which require the user input via the prompt def sudo_and_watch_prompt(cmd, regex_to_watch) sudo cmd, :pty ...
true
38efcf7ed3a7da755fc7145c62f3aa8f233e7bc2
Ruby
Moutalib/humpass
/lib/humpass/database.rb
UTF-8
1,403
2.90625
3
[ "MIT" ]
permissive
require "base64" require "json" module Humpass class << self attr_accessor :database end def self.set_database(file_path = nil) self.database ||= Database.new(file_path) end class Database attr_accessor :file_path def initialize(file_path = __dir__ + '/humpass.dat') raise 'Configurat...
true
6915f2719dc57efc7aed891c07855a97375b96d2
Ruby
neelabhgupta/Geometry
/lib/length.rb
UTF-8
683
3.859375
4
[]
no_license
#Length in metres class Length M_UNIT = 'm' CM_UNIT = 'cm' MM_UNIT = 'mm' attr_reader :length_m def initialize(length, unit) @length_m = convert_to_m(length.to_f, unit) end def convert_to_m(side, unit) if unit == CM_UNIT side = side / 100 elsif unit == MM_UNIT side = side / 1000 ...
true
23104bd0c197b13212566200a4214230b61b6ed1
Ruby
testdouble/suture
/test/suture/adapter/log_test.rb
UTF-8
1,771
2.515625
3
[ "MIT" ]
permissive
require "suture/adapter/log" module Suture::Adapter class LogTest < UnitTest class FakeThing include Suture::Adapter::Log def stuff log_debug("an debug") log_info("an info") log_warn("an warn") log_error("an error") end end def setup super @...
true
d1e9cc18d4b9da1f8e5c393fe8ecea1d6753ccf2
Ruby
mattapayne/jambase4r
/lib/models/event.rb
UTF-8
741
2.734375
3
[ "MIT" ]
permissive
module JamBase4R class Event include Model attr_reader :id, :artists, :venue, :ticket_url, :event_url, :date def initialize(element) return if element.blank? build(element) end private def build(element) @artists = [] @id = get_value(element, EVEN...
true
13b0298e335b856b28adbea02d6dd0ad0e3bdfa5
Ruby
DUSAEN052/green_grocer-dumbo-web-career-010719
/grocer.rb
UTF-8
1,466
3.21875
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def consolidate_cart(cart) # code here output = {} cart.each do |item| item.each do |key, value| if output.key?(key) output[key][:count] += 1 else output[key] = value output[key].merge!({:count => 1}) end end end return output end def apply_coupons(cart...
true
64997a57b06b4197f2cbbcd56cd5be57a4c081b0
Ruby
vivianafb/Actividad17
/Ejercicio6.rb
UTF-8
492
3.234375
3
[]
no_license
class Product attr_accessor :name, *:medidas def initialize(name, *medidas) @name = name @medidas = medidas.map(&:to_i) end def promedio @medidas.inject(&:+) / @medidas.size.to_f end end products_list = [] data = [] File.open('catalogo.txt', 'r') { |file| data = file.readlines.map(&:chomp)} data...
true
5f959a9b37edfb308fc23810a95af8be040a0125
Ruby
cernandes/curso-ruby
/missoes_especiais/compras/app.rb
UTF-8
449
3.53125
4
[]
no_license
# 3 - No arquivo app.rb crie uma instância da classe Produto e adicione valores aos atributos nome e preco. # Depois, inicie uma instância da classe Mercado passsando como atributo a instância da classe Produto e para finalizar execute o método comprar. require_relative 'produto' require_relative 'mercado' produto = P...
true
bbfcd041e079b7de2605b9f9585a8a1476be9f53
Ruby
zacholauson/tictactoe.rb
/spec/gamestate_spec.rb
UTF-8
6,241
3.296875
3
[]
no_license
describe Gamestate do describe "#initialize" do let(:gamestate) { Gamestate.new } it "should create a new board" do expect(gamestate.board).to eq(['-', '-', '-', '-', '-', '-', '-', '-', '-']) end it "should set the first move to 'x' for the computer" do expect(gamestate.turn).to eq("x")...
true
6bd159a66f2e353d2150246cafcdff1b828dad73
Ruby
acevedo93/EXERCISM
/ruby/rna-transcription/rna_transcription.rb
UTF-8
650
2.71875
3
[]
no_license
class Complement def self.of_dna complement_string='' # Best solution complement_strng.tr('CGTA', 'GCAU') # Manual solution # final_complement = '' # complement_string.split('').each do |c| # case c # when 'G' # final_complement += 'C'...
true
73a5e796510ddbc36b6e479194f9922628f89864
Ruby
yasmineezequiel/Vanilla_Ruby
/Section_19_Modules_and_Mixins/Introduction_to_Modules.rb
UTF-8
566
3.296875
3
[]
no_license
# What is a module? # A module is a toolbox or container of methods and constants # Module methods and constants can be used as needed # Modules create namespaces for methods with the same name # Modules cannot be used to create instances # Modules can be mixed into classes to add behavior # Syntax and Style: # Modu...
true
c5bca7078bcf4eced6ea74ca96c31e82a2a1ba97
Ruby
cbrenner04/advent_of_code
/2019/05/solution.rb
UTF-8
168
2.796875
3
[]
no_license
# frozen_string_literal: true require_relative("../intcode") part_one, = Intcode.new(INPUT, 1).run part_two, = Intcode.new(INPUT, 5).run puts part_one puts part_two
true
93e1df23bf36fe5124bd03fffaa2c5d08af89923
Ruby
BhargaviAA/ruby_assignments
/assignment1/simple_calculator.rb
UTF-8
474
3.921875
4
[]
no_license
#!/urs/bin/ruby -w puts('Enter two numbers') num1=gets num2=gets number1=num1.to_i number2=num2.to_i puts "[add], [subtract], [multiply] or [divide]" answer=gets.chomp case answer when 'add' sum=number1+number2 print sum.to_s when 'subtract' difference=number1-number2 print difference.to_...
true
31ac8dae653d9172769f2b8a418e8196353e9b3e
Ruby
archive-for-processing/JRubyArt
/test/color_group_test.rb
UTF-8
790
2.5625
3
[ "GPL-3.0-only", "LicenseRef-scancode-proprietary-license", "GPL-1.0-or-later", "GPL-2.0-only", "LicenseRef-scancode-warranty-disclaimer", "LGPL-2.0-or-later" ]
permissive
# frozen_string_literal: true require_relative 'test_helper' require_relative '../library/color_group/color_group' Java::Monkstone::JRLibrary.load(JRuby.runtime) java_import Java::Monkstone::ColorUtil PALETTE = %w[#FFFFFF #FF0000 #0000FF].freeze COLORS = [16_777_215, 16_711_680, 255].to_java(:int) # ColorGroup Tests...
true
3d569eb5ed40ebf0996fe3832b0446c7f52a8234
Ruby
southpawgeek/perlweeklychallenge-club
/challenge-141/roger-bell-west/ruby/ch-2.rb
UTF-8
501
3.3125
3
[]
no_license
#! /usr/bin/ruby def likenumber(source,factor) s=source.to_s.split('').map {|i| i.to_i} m=s.length n=0 1.upto((1<<m)-2) do |mask| c=0 0.upto(m-1) do |di| if (mask & 1<<di)>0 then c=c*10+s[di] end end if c % factor == 0 then n+=1 end end return n end require 't...
true
cfc718c6883dcc5de2b0c60577a6f07e7313edc5
Ruby
nmbits/rbe
/gen/lib/rbe/cpp/type.rb
UTF-8
708
2.578125
3
[ "MIT" ]
permissive
module RBe module Cpp class Type < String def initialize(string) self.replace normalize_common(string) end def void? self == "void" end def normalize normalize_common self.dup end def normalize! normalize_common self end ...
true
2341346699138ff8a6abfbb0debbca2d363d26cd
Ruby
NicholasBaraldi/Ruby
/Rock_Paper_Scissors.rb
UTF-8
1,746
4.03125
4
[]
no_license
class Player MOVES = [:rock, :paper, :scissors] attr_reader :score, :move def initialize @score = 0 @move = nil end def get_move loop do puts "Pick a move." print "> " @move = gets.chomp.strip.downcase.to_sym if @move == :qui...
true
dd24dd36593f6b288656f0e2d195b96c2b97085d
Ruby
CarterNelms/amateur_sports_league
/app/controllers/session_controller.rb
UTF-8
1,292
2.765625
3
[ "MIT" ]
permissive
class SessionController TERMINATE_COMMANDS = ['end','exit','quit','q'] def begin @controller = SportsController.new() @command = "list" sign_in apply_user_input end def sign_in puts "Hello. Please enter your username" username = clean_gets.capitalize # Player.create(username: user...
true
91d8e3a7ae5d78f77ee6e4c27bee7a38a598231f
Ruby
isabella232/java_service
/libraries/option.rb
UTF-8
608
3.4375
3
[ "MIT" ]
permissive
class Option attr_reader :name attr_reader :value attr_reader :prefix def initialize(name, value, prefix, separator) @name = name @value = value @prefix = prefix @separator = separator end def apply_quotes(value) if /\s/ =~ value.to_s and not /^(["']).*\1$/ =~ value value = "\"#{...
true
d031ebb693d7b26b480904a01b7e0a7b410af685
Ruby
mellowcoder/myflix
/spec/features/user_manages_their_queue_spec.rb
UTF-8
2,531
2.578125
3
[]
no_license
require 'spec_helper' feature "A User Manages Their Queue" do given(:steve) {Fabricate(:user, email: "smartin@example.com", password: "king-tut", full_name: "Steve Martin")} scenario "adding videos to queue and reordering queue" do comedy = Fabricate(:category, name: 'Comedy') monk1 = ...
true
62dff053924d5e3f345ff1964cf5dc3ca1a3fa81
Ruby
zackads/mumble
/spec/mumble_spec.rb
UTF-8
882
3.453125
3
[]
no_license
require('mumble') describe Mumble do describe '.mumble_letters' do context 'given an empty string' do it 'returns an empty string' do expect(Mumble.new.mumble_letters('')).to eq '' end end context 'given a single upper case character string' do it 'returns the given string' do ...
true
b710b1fda2f13e59e14bb9c7d3f0e7a027eb459c
Ruby
alexauff/THP
/Week_3/Week_3_Thu/tictactoe/tic_tac.rb
UTF-8
3,065
3.984375
4
[]
no_license
require "pry" class BoardCase #TO DO : la classe a 2 attr_accessor, sa valeur (X, O, ou vide), ainsi que son numéro de case) attr_accessor :value, :number def initialize(value, number) #TO DO doit régler sa valeur, ainsi que son numéro de case @value = value @number= number end def to...
true
8cf1d83fafe5b5f049fc0f2d9e1c55a71cd9eea6
Ruby
charlottebrf/57-shades-of-ruby
/09_paint_calculator/spec/checks_validity_spec.rb
UTF-8
649
3.078125
3
[ "MIT" ]
permissive
require_relative "../checks_validity" describe "checks validity of user input" do it "returns false if given 0" do checker = ChecksValidity.new("0") expect(checker.is_valid?()).to eq (false) end it "returns true if a digit between 1-9 is given" do checker = ChecksValidity.new("6") expect(checker....
true
0baa8240eca8b5c2ad8bd75d416eac1aae6c87d3
Ruby
charlescui/oauth-clients
/lib/oauth_clients/core.rb
UTF-8
1,474
2.53125
3
[ "MIT" ]
permissive
require 'oauth_clients/oauth_upload.rb' module OAuthClients::Core class Base attr_accessor :provider, :credentials delegate :get, :post, :to => :http_client def initialize(provider,credentials,options={}) @provider = provider @credentials = credentials end def http_client ...
true
15c5d2445fd63d517aa49e7c45fbeb65f642fe8d
Ruby
michaelpmattson/substrings
/substrings.rb
UTF-8
864
4.46875
4
[]
no_license
dictionary = ["below","down","go","going","horn","how","howdy","it","i","low","own","part","partner","sit"] def substrings(my_string, dictionary) #first, convert my_string to an array. my_array = my_string.downcase.split #make an output hash. output = Hash.new #make an each loop that looks at all items i...
true
de0f65d2290db8cd23d799380f1638d6f7c8181a
Ruby
robfors/ruby-sumac
/lib/sumac/calls/remote_calls.rb
UTF-8
2,032
3.046875
3
[ "Apache-2.0" ]
permissive
module Sumac class Calls # Manages calls originating from the remote endpoint. # Keeps track of ongoing calls such that: # * a killed connection can wait for them to finish # * the connection can be set to the correct state when it knows all calls have completed # @api private class RemoteCal...
true
eae7252ba040bbeadf1ad26f4653a272010d1757
Ruby
marckm/firsthandonruby
/ruby_lang/5-enums.rb
UTF-8
417
3.40625
3
[ "MIT" ]
permissive
# symbols in ruby are quite like enums in C# # a symbol is declared with : # symbols are a representation to a unique location in memory # symbols are also very performant because they are precalculated def display_shape_name(shapeType) case shapeType when :square then puts "I am a square" when :circle then puts "I...
true
f216cb00f63656521586d8ce2427520100d6d481
Ruby
BadzoProgra/rails-yelp-mvp
/db/seeds.rb
UTF-8
1,732
2.5625
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
8d057ad0a5ab9ba49a37ed489292bb3237b06a17
Ruby
timkellogg/autoFB
/updateFB.rb
UTF-8
791
2.671875
3
[]
no_license
require 'rubygems' require 'selenium-webdriver' # Get user email print 'email:' email = gets.chomp! # Get user password print 'password:' password = gets.chomp! # Get user status print 'Status Update to Make' status = gets.chomp! # Set driver to Selenium for firefox & get address driver = Selenium::WebDriver.for...
true
1301f6251c1d9bce570424848cb757235f3c013a
Ruby
kArTeL/Natty
/Dangerfile
UTF-8
2,175
2.65625
3
[]
no_license
# Sometimes it's a README fix, or something like that - which isn't relevant for # including in a project's CHANGELOG for example declared_trivial = github.pr_title.include? "#trivial" # Make it more obvious that a PR is a work in progress and shouldn't be merged yet warn("PR is classed as Work in Progress") if github...
true
10d65b96360d9c7994cd0aab73c914565e550882
Ruby
Mauricepwong/robotbay_T2A2
/app/controllers/robots_controller.rb
UTF-8
2,651
2.640625
3
[]
no_license
class RobotsController < ApplicationController # pull the specific robot from the database and sets it before a method is run. before_action :set_robot, only: %i[show edit update destroy] # prompts for login if user not signed in before_action :authenticate_user!, except: %i[index] # ensure user has p...
true
81678185d89197b475bc77e59a4b14155e144f6a
Ruby
ecarlisle/nfg-fundraiser
/app/models/fundraiser.rb
UTF-8
247
2.609375
3
[]
no_license
class Fundraiser < ActiveRecord::Base def full_name [first_name, last_name].join(' ') end def percent_to_goal ((current_amount/goal_amount)*100).round end def image_file ([first_name, last_name].join('_') + ".jpg").downcase end end
true
ec1fa8b46b4ab9c8cd56d67970507cbc7c96dc76
Ruby
chrisvire/export-bsv-script
/export-bsv-script.rb
UTF-8
1,401
2.9375
3
[ "MIT" ]
permissive
require 'docx' require 'optparse' class String def is_integer? self.to_i.to_s == self end end ARGV << "-h" if ARGV.empty? $options = { :title => 'Title', :passage => '' } OptionParser.new do |opts| opts.banner = 'Usage: export_bsv_script.rb [options] FILENAME' opts.on('-t', '--title TITLE', 'Title of scr...
true
264d25e7d467dad8d094f6e895be3daf8669c324
Ruby
tybenz/project-euler
/problem06.rb
UTF-8
114
2.859375
3
[]
no_license
list = *(1..100) sosq = list.inject(0) do |s, n| s += n * n end sqos = list.inject(:+) ** 2 puts sqos - sosq
true
7365756365a2111faeefc312834ed40171a0f90d
Ruby
zhusan/mower
/spec/models/mower_spec.rb
UTF-8
862
2.96875
3
[]
no_license
require 'spec_helper' require './models/lawn' require './models/mower' describe Mower do it "is valid with a direction" do mower = Mower.new(1, 2, "N") expect(mower).to be_valid end it "is valid with an invalid direction" do mower = Mower.new(1, 2, "A") expect(mower).not_to be_valid end it...
true
3a1c6a1207e403433829327f2f698b988478992c
Ruby
rgilbert82/Data-Structures
/heap.rb
UTF-8
1,300
3.71875
4
[]
no_license
class Heap attr_reader :data def initialize(*values) @data = values max_heapify! end def sort! max_heapify! last = size - 1 while last > 0 @data[0], @data[last] = @data[last], @data[0] last -= 1 sift!(0, last) end @data end def sort Heap.new(*@data).sort...
true
82a9453134a602e0a14f2d802993bb0cd49fa1b0
Ruby
malev/freeling-client
/lib/freeling_client/token.rb
UTF-8
324
2.671875
3
[ "MIT" ]
permissive
module FreelingClient class Token attr_accessor :form, :lemma, :tag, :prob, :pos def initialize(opt = {}) @form = opt[:form] @lemma = opt[:lemma] @tag = opt[:tag] @prob = opt[:tag] end def [](key) key = key.to_sym if key.is_a? String self.send(key) end end ...
true
21f78b5f9f60c4b87475ddcd22b3f47d9edca819
Ruby
yumayo14/character_game
/character_checker.rb
UTF-8
744
3.3125
3
[]
no_license
# frozen_string_literal: true class CharacterChecker attr_reader :characters def initialize(characters) @characters = characters end def best_characters characters.select { |character| character.attack + character.defence == highest_parameter } end def best_attackers characters.select { |cha...
true
3b48dccba066453e983ad41ec773fe933e649995
Ruby
jeremiahkellick/terminal-chess
/pawn.rb
UTF-8
1,625
3.09375
3
[]
no_license
require_relative "add_pos" class Pawn < Piece def initialize(pos, board, color) super @vertical = color == :white ? -1 : 1 @promotion_row = color == :white ? 0 : 7 @first_time_pos_set = true @starting_row = nil end def pos=(value) super if @first_time_pos_set @starting_row = va...
true
e9e6e5c928fe67b8e9e7d020fd62a9e8fb0c9081
Ruby
kavinderd/todo
/lib/todo.rb
UTF-8
1,193
2.625
3
[ "MIT" ]
permissive
#TODO: Read PR article about require and require relative require_relative "todo/version" require_relative "todo/version" require_relative "todo/list" require_relative 'todo/presenter' module Todo class Application def initialize(persistent: false) @list = init_list(persistent) @presenter = Todo::...
true
65171af1e6c761875710398124d272259f8c7b01
Ruby
fred84/calabash-extras
/test/walker_test.rb
UTF-8
3,427
2.953125
3
[]
no_license
require 'test/unit' require 'calabash-extras/walker' require 'calabash-extras/page_object_comparator' class WalkerTest < Test::Unit::TestCase class BaseDummyPage include Calabash::Extras::PageObjectComparator attr_accessor :will_match, :called, :back_called def initialize @called = false @b...
true
4a7b73e1f8218109508ea4f0aba40625680b8ed1
Ruby
Zimbra/zm-genesis
/src/ruby/reportResult.rb
UTF-8
2,366
2.578125
3
[]
no_license
#!/bin/env ruby # # $File$ # $DateTime$ # # $Revision$ # $Author$ # # 2006 Zimbra # # Test Summary Processing require "yaml" (resultFilePattern, suite, os, build, branch, type, url) = ARGV #resultFilePattern = "testsummary.txt" #suite = "SOAP" #os = "FC5" #branch = "main" #type = "SMOKE" #build = "20061107020101_FOSS...
true
936a558852b0cc36fbaec42482644141e2ad5ae2
Ruby
potatocommune/Ruby-Learn-to-program-Exercises
/chapter8/method.rb
UTF-8
348
3.59375
4
[]
no_license
def do_you_like_mexican_food(food) goodAnswer = false while (not goodAnswer) puts "Do you like eating #{food.to_s}?" answer = gets.chomp.downcase if (answer == 'yes' or answer == 'no') goodAnswer = true else puts 'Please answer "yes" or "no".' end end puts answer end do_you_like...
true
25f5ee503500d9293f3e46af6c47806da7e90806
Ruby
lethan/Advent-of-Code
/2018/day10.rb
UTF-8
1,162
3.03125
3
[]
no_license
file = File.open('input_day10.txt', 'r') points = [] while (line = file.gets) points << /position=<\s*(-?\d+),\s*(-?\d+)> velocity=<\s*(-?\d+),\s*(-?\d+)>/.match(line)[1..4].map(&:to_i) end file.close x_minmax = points.map(&:first).minmax area = (x_minmax[1] - x_minmax[0]).abs y_minmax = points.map { |a| a[1] }.minm...
true
c9becc3ebb6d8c6838f60647045235085f6d56f9
Ruby
Lupeman/WDI_10_homework
/Jaime/WEEK4/d1/calculator-class.rb
UTF-8
587
3.4375
3
[]
no_license
require "pry" require "./calculator.rb" calculator = Calculator.new def get_info(calculator) puts "Enter the numbers you want to work with:" calculator.value1 = gets.chomp.to_i calculator.value2 = gets.chomp.to_i puts "Would you like to add, subtract, multiply, divide or quit?" calculator.operator_info = g...
true
5902a1002d02e7cab7a80f69e289da9957b9843d
Ruby
kyrasteen/sales_engine
/test/invoice_items_repository_test.rb
UTF-8
1,701
2.59375
3
[]
no_license
require 'minitest/autorun' require 'minitest/pride' require_relative '../lib/invoice_item_repository' class InvoiceItemRepoTest < Minitest::Test def setup filename = './test/support/invoice_items_test_data.csv' @invoice_items = InvoiceItemRepo.new(filename, nil) end def test_it_finds_all assert_equ...
true
b5ac5c6fc242f83eb21a9054adc1b4fe2f1d0a93
Ruby
hayduke19us/forgot_tmux
/lib/trail_head/setup.rb
UTF-8
1,480
2.953125
3
[]
no_license
require "course/simple_walk" require "course/auto_simple" require "course/complex_walk" require "course/auto_complex" require "trail_head/start" module Setup def self.initial_setup Start.find_bash puts %{We reccomend you remap your CAPS LOCK key to CTRL. In OS X this option is within your Sy...
true
48d4f6d01aed81b73759da4e0fe88eccc382c2db
Ruby
AmeliaFannin/euler
/euler-027.rb
UTF-8
1,570
4
4
[]
no_license
# Quadratic primes # Problem 27 # Euler discovered the remarkable quadratic formula: # n² + n + 41 # It turns out that the formula will produce 40 primes for the consecutive values # n = 0 to 39. # However, when n = 40, 402 + 40 + 41 = 40(40 + 1) + 41 is divisible by 41, # and certainly when n = 41, 41² + 41 + 4...
true
71483932f3be432821c6b219519e6ed7231df74a
Ruby
woahdae/rush
/lib/rush/service.rb
UTF-8
7,157
3.375
3
[ "MIT" ]
permissive
## # === Creating new services # To create new services, you need to create two subclasses, one from this # (Rush::Service), and another from Rush::ServiceInstance. They must # be named Rush::Service::[ServiceName] and # Rush::Service::[ServiceName]Instance, respectively. # # Your Rush::Service subclass needs to defin...
true
f2e3217c5cee9542d2f8031ecf76fc2ca8a4c720
Ruby
leetie/learn_ruby
/04_pig_latin/pig_latin.rb
UTF-8
1,343
3.9375
4
[]
no_license
#write your code here #def translate word # vowelArray = ["a", "e", "i", "o", "u", "y"] # wordArray = word.split("") # output = "" # vowelArray.each do |vowel| # if wordArray[0] == vowel # output = word + "ay" # return output # end # break # end # firstLetter = wordArray.slice!(0,...
true
b38bab0be354cf86b32e845a0296e4289f0f2cce
Ruby
emadb/playground
/ruby/fibo.rb
UTF-8
475
3.765625
4
[]
no_license
#!/usr/bin/ruby # def fibo(x) # f1 = 1 # f2 = 1 # fn = 1 # [2..x].each do |n| # fn = f1 + f2 # f2 = f1 # f1 = fn # puts "f1=#{f1} f2=#{f2} fn=#{fn}" # end # fn # end def fibo(x) @sq5 = Math.sqrt(5) @gm = (1 + @sq5) / 2 @gn = (1 - @sq5) / 2 return ((@gm**x - @gn**...
true
b6ff82cd944c84d681bc30a028f8f8f5d6bca028
Ruby
zayneio/ghostchat
/app/models/group.rb
UTF-8
1,780
2.875
3
[]
no_license
require 'digest/md5' require 'encrypt_text' class Group < ApplicationRecord attr_accessor :expires_in has_secure_password validations: false has_many :users, dependent: :destroy # has_one :creator, class_name: "User", dependent: :destroy # accepts_nested_attributes_for :creator # accepts_nested_attribute...
true
cd0ac7c1cce1fb3b811bcf0af81fb4b1d344394e
Ruby
victor-am/ruby_detective
/lib/ruby_detective/ast/nodes/query.rb
UTF-8
2,565
2.71875
3
[ "MIT" ]
permissive
module RubyDetective module AST module Nodes class Query attr_reader :node def initialize(node) @node = node end # TODO: accept multiple criteria def where(criteria = {}) case when criteria.key?(:type) type_validation_functi...
true
412e9b5b8fa077a7a4e7f9d60dfa52a786e99728
Ruby
mjburgess/public-notes
/ruby-notes/00.Overview/01.Overview-Course.rb
UTF-8
1,340
3.125
3
[]
no_license
puts "PURPOSE: To Learn Ruby Programming " puts "OBJECTIVE: To complete 14 modules in ruby, as below. " puts "INTRODUCTIONS: Hello! " puts "EXPERIENCE: What relevant experience do you have?" puts "APPLICATIONS: How will you use ruby? " puts puts "SCHEDULE" puts puts "QA RUBY PROGRAMMING -- FOUR DAY" puts %w{ ...
true
37ca9b93497aba449468d37942a7c0f6e2bec8f1
Ruby
liyunlunaomi123/conference_plan
/lib/conference_plan/track.rb
UTF-8
2,458
2.984375
3
[]
no_license
# frozen_string_literal: true module ConferencePlan class Track attr_reader :date attr_accessor :morning, :lunch, :afternoon, :networking_event def initialize(date) @date = date end def arrange_talks(talks_per_track) @total_time = talks_per_track.map(&:talk_length).inject do ...
true
95ee2d7fd2d09a65f5f4c147675bde2521d8585c
Ruby
jeanlazarou/swiby
/demo/word_puzzle/puzzle_server.rb
UTF-8
10,427
2.78125
3
[]
no_license
#-- # Copyright (C) Swiby Committers. All rights reserved. # # The software in this package is published under the terms of the BSD # style license a copy of which has been included with this distribution in # the LICENSE.txt file. # #++ require 'thread' require 'mongrel' require 'cgi/session' require '...
true
45d045b097d87a22ffd2b3714344f2cb8352ae92
Ruby
alejandro-mr/data-structures-practice
/ruby/linked_list/singly_linked_list/SinglyLinkedList.rb
UTF-8
2,087
3.65625
4
[]
no_license
class LinkedList def initialize(head = nil) @head = head if head @count = 1; else @count = 0; end end def getCount @count end def print_list _current = @head unless _current puts "List is empty!" else while _current do puts "Node: #{_current.ge...
true
35753a712ac29ead6db85c848148bdd78f70929d
Ruby
ihsaneddin/ripple-lib-rpc-ruby
/lib/ripple/methods/transaction.rb
UTF-8
6,693
2.5625
3
[ "ISC" ]
permissive
module Ripple module Methods module Transaction # # TODO # The book_offers method retrieves a list of offers, also known as the order book, between two currencies # options are: # ledger_hash String (Optional) A 20-byte hex string for the ledger version to use. (See Specifying a L...
true
3cd579848dd5f91a6b0d7b638713878d3801880f
Ruby
tactppp/intern_training_algorithm
/poker_step4.rb
UTF-8
2,619
3.8125
4
[]
no_license
require './draw_hand.rb' tehuda_card = draw_hand def card_suite(card) case card[0] when "S" kono_suite = "スペード" when "H" kono_suite = "ハート" when "D" kono_suite = "ダイヤ" when "C" kono_suite = "クラブ" end return kono_suite end def card_num(card) if card[1,2].to_i > 0 kono_num = card[1,...
true
9f54d2d052b108ec4c70608250e380108e28194d
Ruby
remiodufuye/oo-relationships-practice-dc-web-102819
/app/models/guest.rb
UTF-8
919
3.359375
3
[]
no_license
class Guest @@all = [] attr_reader :name def initialize (name) @name = name @@all = self end def self.all @@all end def trips Trip.all.select do |trip| trip.guest == self end end def listings self.trips.m...
true
bb9b128a562ae2cb35d3a0f502de1390d73921d0
Ruby
mshkdm/wikipedia-scrapper
/hello-world.rb
UTF-8
298
2.65625
3
[ "MIT" ]
permissive
require "open-uri" # puts open("https://en.wikipedia.org/wiki/Ada_Lovelace").read # puts open("http://nytimes.com").read remote_base_url = "https://en.wikipedia.org/wiki" remote_page_name = "Ada_Lovelace" remote_full_url = remote_base_url + "/" + remote_page_name puts open(remote_full_url).read
true
5b710ccfc5a9b226138f087621a2a7eabd6bcdd6
Ruby
sds/scss-lint
/lib/scss_lint/linter/placeholder_in_extend.rb
UTF-8
976
2.71875
3
[ "MIT" ]
permissive
module SCSSLint # Checks that `@extend` is always used with a placeholder selector. class Linter::PlaceholderInExtend < Linter include LinterRegistry def visit_extend(node) # Ignore if it cannot be statically determined that this selector is a # placeholder since its prefix is dynamically gener...
true
83b77d3dc5be01bd8c7ed061eab3886cf57af01d
Ruby
troygnichols/zark-billing-api
/app/commands/authenticate_user.rb
UTF-8
794
2.6875
3
[]
no_license
class AuthenticateUser prepend SimpleCommand def initialize(email, password) @email = email @password = password end def call if user = find_user AuthenticateUser.response_content(user) else nil end end def AuthenticateUser.response_content(user) { token: create_...
true
a2e1394a01b028d1f8305b463b7fd709b89e0382
Ruby
hangmanandhide/aA-Pair-Programming-Projects
/W2D1/Chess/NullPiece.rb
UTF-8
149
2.609375
3
[]
no_license
class NullPiece < Piece attr_reader :color, :symbol include Singleton def initialize @color = "rainbow" @symbol = :sunshine end end
true
a9a1a6d40746809f46e95ee19d0cfb407a093338
Ruby
MrMicrowaveOven/AlgorithmsCurriculum
/Heap.rb
UTF-8
738
3.6875
4
[]
no_license
class MinHeap def initialize(&prc) @values = [] prc ||= Proc.new {|x,y| x <=> y} @comparator = prc end def min @values.first end def pop popped = @values.shift heapify_up! popped end def swap(key1, key2) @values[key1], @values[key2] = @values[key2], @values[key1] end ...
true
8614c6d4fbaca43deaa4c15fd82f97cd3252281a
Ruby
susanev/advent-of-code
/2016/day03/part1.rb
UTF-8
440
3.625
4
[]
no_license
class Part1 def initialize(file_name) @count = 0 processFile(file_name) output end def processFile(file_name) File.open(file_name, "r") do |f| f.each_line do |line| validTriangle(line.chomp.split(" ").map(& :to_i)) end end end def validTriangle(sides) max = sides.max if sides.reduce(:+) -...
true
ca8cbb52f6f44080e9210414e916e5d0109768f6
Ruby
antonhalim/green_grocer-bk-002-public
/grocer.rb
UTF-8
1,974
3.234375
3
[]
no_license
require 'pry' require 'pry-nav' def consolidate_cart(cart:[]) foodhash = {} ## cart.each_with_objec({}) do |carthash, new_cart_hash| cart.each do |food| #cart is the array food = each index in array {"tempeh"=>} food.each do |food_name, attribute_hash| #food_name = "TEMPEH" attribute_has...
true
3c6e96092457cfe9cc9c3b51ba1dfbb73a783047
Ruby
hosiawak/rubinius_macros
/spec/andand_spec.rb
UTF-8
1,422
3.140625
3
[]
no_license
describe "Andand macro" do it "returns the left hand argument if the right is missing" do :foo.andand.should == :foo end it "rewrites foo.andand.bar into __x__ = foo; x && x.bar" do [1,2,3].andand.to_s.should == "123" nil.andand.to_s.should == nil end it "rewrites sends with 1 argument" do ...
true
e1f360abeabbb5462c3f57ccb452dae62b42b356
Ruby
brooksquil/back-end-class-demos
/modules_mixins/main.rb
UTF-8
371
3.140625
3
[]
no_license
require_relative "student_type_error" require_relative "cars" require_relative "student" #creates instance of student jordan = Student.new("Jordan") puts jordan #following works with extend: # puts Student.description #following works with include: puts jordan.description puts Student.has_car? #if below changed to str...
true
5cf71fc78763b9cb8a52fb5a922bbe82458f3009
Ruby
dannehdan/birthday
/lib/birthday_calc.rb
UTF-8
291
3.328125
3
[]
no_license
require 'date' class BirthdayCalc def initialize(date) @date = Date.parse(date) end def birthday @date end def days_until_birthday year = Date.today.year next_bday = "#{@date.day}-#{@date.month}-#{year}" (Date.today - Date.parse(next_bday)).to_i end end
true
e3cd1f468bfa956184e42963792a8b8248752b5a
Ruby
cgilroy/chess
/piece.rb
UTF-8
4,586
3.40625
3
[]
no_license
require 'singleton' require_relative 'slideable' require_relative 'stepable' require_relative 'board' class Piece attr_accessor :pos attr_reader :color, :board def initialize(color,board,pos) @color = color @board = board @pos = pos end def destination_square_type(end_pos) ...
true
4f5cf758116da1e9e8fe94595eba94e189d05b40
Ruby
challyed/EdsDailyProgrammerRUBY
/spaces.rb
UTF-8
998
3.578125
4
[]
no_license
"I am 6'2\" tall" # escape double-qoute inside a string 'I am 6\'2" tall.' # escape single-qoute inside a sting tabby_cat = "\tI'm tabbed in." #\t puts a tab persian_cat = "I'm split\non a line." # \n means new line blackslash_cat = "I'm \\a\\ cat." #shows what a double \\\\ does fat_cat = <<MY_HEREDOC I'll to do list...
true
3d5a9763af5c8f2688d88a24fa49b70fb3e2ddc2
Ruby
Cosmin-Croitoriu/bank_tech_kata
/spec/transaction_spec.rb
UTF-8
926
2.59375
3
[]
no_license
# frozen_string_literal: true require 'transaction' describe Transaction do describe '#initialize' do it 'initializes a new transaction' do transaction = Transaction.new expect(transaction).to be_an_instance_of(Transaction) end end describe '#deposit_transaction' do it 'creates a log fo...
true
514221359c9ae3d28fe6f153389c8227fdc87bd6
Ruby
ThomasPedersen/Plant
/plant.rb
UTF-8
441
2.640625
3
[ "MIT" ]
permissive
require 'rubygems' require 'serialport' serialport = SerialPort.new("/dev/tty.usbmodemfd121", 9600, 8, 1, SerialPort::NONE) file = File.open("samples.csv", 'a') trap("INT") { file.close(); exit } while true do while (line = serialport.gets.chomp) do a = line.split(',') a.unshift (Time.now.utc.to_f * 1000).t...
true
bae2b56c39df83651e34cdc889474f1e9c106002
Ruby
bryanmillstein/Chess
/Sliding_Piece.rb
UTF-8
780
3.125
3
[]
no_license
require 'byebug' class SlidingPiece < Piece DELTA_DIAGONOL = [ [-1, -1], [1, 1], [1, -1], [-1, 1] ] DELTA_HORZ_VERT = [ [1, 0], [-1, 0], [0, 1], [0, -1] ] def moves moves = [] self.class::DELTA.each do |delta| moves += each_delta(delta) end #validatio...
true
b66bab057493871b8af013a59939497d3036b5a1
Ruby
JoyJing1/app_academy
/emoji_chess/pieces/pawn.rb
UTF-8
1,160
3.328125
3
[]
no_license
require_relative 'piece' class Pawn < Piece attr_accessor :moved PAWN_DIR = { :white => [[-1,-1], [-1, 0], [-1,1]], :black => [[1,-1], [1,0], [1,1]] } def initialize(color, start_pos, board) @value = (color == :black ? ' 💩 ' : ' 🌊 ') @moved = false super end def build_moves moves = ...
true
295454f2d111ec1fa6331b96a0357410c5ad2e54
Ruby
wordtreefoundation/archdown
/lib/archdown/download.rb
UTF-8
920
2.671875
3
[ "MIT" ]
permissive
require 'archivist/client' require 'retriable' require 'archdown/librarian' require 'archdown/library' module Archdown class Download attr_reader :library_root, :search_terms def initialize(library_root, search_terms) @library = Library.new(library_root) @search_terms = search_terms @clie...
true
b8b6c178d662bfe1a17095987ec0e34ee347a178
Ruby
pmanko/slice
/app/models/engine/expressions/unary.rb
UTF-8
252
2.671875
3
[ "MIT" ]
permissive
# frozen_string_literal: true module Engine module Expressions class Unary < Expression attr_accessor :operator, :right def initialize(operator, right) @operator = operator @right = right end end end end
true
014ca55d1b4892f2435049657123de9559ef2622
Ruby
carriewalsh/module_3_diagnostic
/spec/features/user_can_search_by_zip_spec.rb
UTF-8
1,229
2.71875
3
[]
no_license
require "rails_helper" describe "User can search by zip code" do it "returns a list of stations that match query" do visit "/" fill_in "zip", with: 80206 click_on "Locate" expect(current_path).to eq('/search') expect(page).to have_content("Total Results: 93") expect(page).to have_css(".stat...
true
fa9219c7012878174bb73e5959c2eb2037244cd7
Ruby
bodrovis-learning/Ruby-SOLID-video
/dip/before.rb
UTF-8
538
3.171875
3
[]
no_license
class TerminalPrinter def write(msg) $stdout.write "#{@prefix} #{message}" end end class FilePrinter def write(msg) File.open('log.txt', 'a+:UTF-8') do |f| f.write msg f.write "\n" end end end class Logger def initialize @prefix = "#{Time.now.strftime('%d-%b-%Y %H:%M:%S')} -->" ...
true
c8908784741397dd022b695d5e4f7382c3809b2d
Ruby
KED-2020/app-mind-map
/app/presentation/view_objects/subscriptions_list.rb
UTF-8
419
2.59375
3
[]
no_license
# frozen_string_literal: true require_relative 'subscription' module Views # View for a a list of project entities class SubscriptionsList def initialize(subscriptions) @subscriptions = subscriptions.map.with_index { |sub, i| Subscription.new(sub, i) } end def each @subscriptions.each do ...
true
9270c2805f5b30fe42f079a1af988bff600a558d
Ruby
atpons/lect-satlib
/network_sat/server.rb
UTF-8
833
2.90625
3
[]
no_license
require "../satrb.rb" require "socket" require "logger" @log = Logger.new(STDOUT) @port = 20000 @log.info("[*] Listening on #{@port} for initialize information") s0 = TCPServer.open(@port) sock = s0.accept while buf = sock.gets buf = eval(buf) @c_begin = buf[0] @c_end = buf[1] end sock.close s0.close @log.info...
true
5b54b42c90312f4b0bcef7be9ee3267daa720d28
Ruby
triposorbust/digraph
/lib/arc.rb
UTF-8
380
3.296875
3
[]
no_license
require 'node' class Arc # Arcs always originate in the parent Node. attr_reader :destination attr_accessor :weight def initialize destination, weight raise TypeError, "arcs must link to node" unless destination.is_a? Node raise TypeError, "weight must be numeric" unless weight.is_a? Numeric @des...
true
cf94b9dd71bd3584691ea7a3d1a084811e4c1f54
Ruby
irenemoreno/InBetweenJobs
/WeArePeople/pruebaWAp/gom_jabbar/cart.rb
UTF-8
552
3.03125
3
[]
no_license
class Cart def initialize(pricing_rules = nil) @items = [] @kr = 3.14 @me = 42 @un = 999 end def add item @items << item end def total kr = @items.count "KR" if kr % 2 == 0 then total_kr = (kr.to_i / 2) * @kr else total_kr = (kr.to_i / 2 + 1) * @...
true
605fe9807a3b250e23816a8aebb16ee72ab82abc
Ruby
33marvil/CodeaCamp
/semana_2/Martes 3_02/adivina_numero.rb
UTF-8
418
3.984375
4
[]
no_license
class NumberGuessingGame def initialize end def guess(num_usuario) num = rand(1..10) if num_usuario < num puts "Too low" elsif num_usuario > num puts "Too high" else "You got it!" end p num end end # Pruebas game = NumberGuessingGame.new p game.guess(5) == "Too lo...
true
b864fa9120d95b18a9f16d7f36336dd51645ee79
Ruby
pocke/mighty_json
/lib/mighty_json/errors.rb
UTF-8
914
2.765625
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
# frozen_string_literal: true module MightyJSON class Error < StandardError attr_reader :path, :type, :value def initialize(path:, type:, value:) @path = path @type = type @value = value end def to_s position = path.empty? ? "" : " at .#{path.join('.')}" "Expected type...
true
2901a6642d358f161d7d435d0cc38132c84558eb
Ruby
christinamcmahon/programming-univbasics-4-square-array-seattle-web-120919
/lib/square_array.rb
UTF-8
180
3.4375
3
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
def square_array(array) # your code here counter = 0 result = [] while array[counter] do result[counter] = array[counter]**2 counter += 1 end return result end
true
412ed6ecc61be966947a244e3bf7b59295cf561e
Ruby
maddymthompson/kwk-t1-say-hello-ruby-teachers-l1
/colors.rb
UTF-8
89
3.078125
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
colors = ["Red", "Yellow", "Blue"] puts "First: #{colors[0]}" puts "Last: #{colors[2]}"
true
c1de2f52cae6a621df6da3b9cee994f94824b156
Ruby
itatchi3/bootcamp
/ruby/test.rb
UTF-8
306
3.328125
3
[]
no_license
class Foo def initialize(arg) @foo = arg end def foo puts @foo end def bar puts @foo end end foo = Foo.new("foo") foo.foo #=> foo foo.bar #=> foo bar = Foo.new("bar") bar.foo #=> bar foo.bar #=> bar # 異なる値をインスタンス変数に代入している foo.foo #=> foo
true
454d0e6ab0d403e8298a27f8aaa32b7c28bcb53e
Ruby
thomascpan/exercises
/sorting_agorithms/SelectionSort.rb
UTF-8
424
3.4375
3
[]
no_license
# Selection Sort unsorted_list1 = 10.times.map{rand(100)} unsorted_list2 = 10.times.map{rand(100)} def selection_sort(list) i = 0 while i < list.length-1 min_index = i j = i+1 while j < list.length min_index = j if list[j] < list[min_index] j+=1 end list[i],list[min_index] = list[...
true
bb204b237a4bee7507f088d770aee168fea68825
Ruby
anthonylebrun/rpn_calculator
/lib/abstract_factory.rb
UTF-8
803
3.203125
3
[]
no_license
# This class returns a module that when included defines the # concrete_factories method on its class which in turn returns # an array of classes belonging to the argument module. # Usage: # # class Foo # include AbstractFactory.new(FactoryWrapperModule) # # concrete_factories.each do |factory| # ... # end #...
true
bae353326550e7c5f26fdf5ce1384e010be9f72e
Ruby
necmigunduz/hackerrank-solutions
/manas_and_stones.rb
UTF-8
539
3.28125
3
[]
no_license
#!/bin/ruby require 'json' require 'stringio' # Complete the stones function below. def stones(n, a, b) ar=[0] (n-1).times do |val| tmp=[] ar.each do |v| tmp << v+a if !tmp.include?(v+a) tmp << v+b if !tmp.include?(v+b) end ar=tmp end ar.sort end fptr = ...
true
4df5bc41601edb77d7f3bec85917670281af95dc
Ruby
adamjmurray/mtk
/spec/mtk/patterns/sequence_spec.rb
UTF-8
6,033
2.875
3
[ "BSD-3-Clause" ]
permissive
require 'spec_helper' describe MTK::Patterns::Sequence do SEQUENCE = MTK::Patterns::Sequence let(:elements) { [1,2,3] } let(:sequence) { SEQUENCE.new(elements) } it "is a MTK::Collection" do sequence.should be_a MTK::Groups::Collection # and now we won't test any other collection features here... se...
true
b64391c2df461099f4daffefb83475e1f0c23198
Ruby
uswitch/ontology
/lib/ontology/cli.rb
UTF-8
815
2.703125
3
[ "Apache-2.0" ]
permissive
require_relative './source.rb' require_relative './store.rb' module Ontology module CLI def self.store_from_paths(paths, options) store = Store.new paths.each { |path| if File.directory?(path) $stderr.puts "Loading directory '#{path}'" directory = Ontology::Source::Dir...
true
d752f67e6522281df924fcf0db8e79238e6b5ee3
Ruby
hilkeros/raudio-test
/app/models/midi.rb
UTF-8
1,672
3.03125
3
[]
no_license
class Midi attr_accessor :script def initialize(instrument) @instrument = instrument.identifier @script = ("<script id='MidiCode'> window.onload = function() { var midi_converter = " + self.midi_converter_array.to_s + "; if (navigator.requestMIDIAccess) { console.log('...
true
74555d185777741fc202ddcda9139db9ee93b03a
Ruby
tckmn/oldstuffs
/ruby/num-coder.rb
UTF-8
1,407
3.59375
4
[]
no_license
$chrs = %w[0 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z . , ? ! ( ) ' / \ @ # $ % ^ & * : + - =] $len = $chrs.length def encode i, iterations code = '' while i != 0 code = String($chrs[i % $len]) + code i /= $len end if iterations > 0 puts "#{iterations} iteratio...
true
12bd1b71feac26d6702da0c5a0d3103fbf0f7bf0
Ruby
netosober/ruby-project-euler
/02-fib.rb
UTF-8
161
3.296875
3
[]
no_license
a = 1 b = 2 sum = 0 while a < 4000000 && b <4000000 do if (b%2 == 0) sum += b puts "#{b} - #{sum}" end c = a + b a = b b = c end puts sum
true
124168bd7db906786fb68513f96fdfd45fecbd87
Ruby
genya0407/boxboxbox-cli
/mrblib/box.rb
UTF-8
265
2.875
3
[ "MIT" ]
permissive
class Box # @dynamic image_name, top_left, bottom_right attr_reader :image_name, :top_left, :bottom_right def initialize(image_name:, top_left:, bottom_right:) @image_name = image_name @top_left = top_left @bottom_right = bottom_right end end
true
226d1a1bd0ab3d3d6ff034687f34e154b951f597
Ruby
gd875/ruby-collaborating-objects-lab-v-000
/lib/mp3_importer.rb
UTF-8
435
3
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require 'pry' class MP3Importer attr_accessor :path def initialize(path) @path = path end def files all_file_paths = Dir["#{path}/**/*.mp3"] normalized_files = [] all_file_paths.each do |file_path| normalized_files << file_path.split("/")[4] end normalized_files #binding.pry...
true
c452239ffcf571987144844d56bfd217a01cb0a4
Ruby
SamuSan/ballin_spice
/cards/diamond.rb
UTF-8
106
2.671875
3
[]
no_license
require_relative 'card.rb' class Diamond < Card def initialize value super @suit = :d end end
true