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
0e0db47dedd19aec01be02edda3f5236245d67d7
Ruby
mlg-/brussels-sprouting
/lib/recipe.rb
UTF-8
1,892
3.359375
3
[]
no_license
class Ingredient attr_accessor :quantity, :unit, :name def initialize(quantity, unit, name) @quantity = quantity @unit = unit @name = name end def summary "#{@quantity} #{@unit} #{@name}" end def valid? valid_ingredients_list = ["brussels sprouts", "spinac...
true
d4c48a210ba9f24129c6340e215f7447e3060f29
Ruby
accua/change
/lib/change.rb
UTF-8
1,633
3.171875
3
[]
no_license
class Float define_method(:disp_change) do |cash| quarters_get = 0 dimes_get = 0 nickels_get = 0 pennies_get = 0 remainder = 0 change_get = cash - self if change_get >= 0.25 disp_q = (change_get / 0.25).to_i counter = 0 until (counter.== (disp_q)) || (counter == 8) ...
true
08a01d67de62f88d815f71f0c49fbe640545b810
Ruby
jichen3000/colin-ruby
/test/bin/write_bin_file_test.rb
UTF-8
1,212
3.046875
3
[]
no_license
require 'colin_helper' def write_file(filename) file = File.new(filename,'r+b') arr = ["a","b","c"] # i_arr = ["23","45","96"] # block = i_arr.pack("H2"*i_arr.size) i_arr = ["2300","4500","9600"] block = i_arr.pack("H4"*i_arr.size) puts ColinHelper.barr2str16(block) puts block file.seek(9,IO::SEEK_CUR)...
true
bf25a2749729975741813b6e6b0bdfcbdc759240
Ruby
yairmon/pecera
/objetos/tiburon.rb
UTF-8
3,442
3.09375
3
[]
no_license
#!/usr/bin/env ruby require 'rubygems' rescue nil $LOAD_PATH.unshift File.join(File.expand_path(__FILE__), "..", "..", "lib") require 'chingu' include Gosu require_relative "../logica/direccion" # # Tiburon: # Es el objeto que se mueve dentro de la ventana libre y aleatoriamente # En busca de peces que pue...
true
17417146a914217ec21ba9172be4d93d4574c865
Ruby
wwwkang8/Ruby_study
/hash/frequency_program.rb
UTF-8
1,189
3.4375
3
[]
no_license
require_relative 'words_from_string' require_relative 'count_frequency' raw_text = %{ saying that the National Assembly and its President Juan Guaidó are best placed to lead Venezuela to the restoration of its democracy, its economy and its freedom," said UK Minister of State Alan Duncan. In a statement, the Bank of E...
true
cd19e4d838e8567c7c335a4469af67a31f44d716
Ruby
jbayer/cf-buildpack-go
/lib/buildpack_packager.rb
UTF-8
1,570
2.53125
3
[]
no_license
require 'zip' require 'tmpdir' module BuildpackPackager EXCLUDE_FROM_BUILDPACK = [ /\.git/, /\.gitignore/ ] DEPENDENCIES = [ "http://go.googlecode.com/files/go1.1.1.linux-amd64.tar.gz", "http://go.googlecode.com/files/go1.1.2.linux-amd64.tar.gz", "http://go.googlecode.com/files/go1.1.lin...
true
b2d9add8753c69151b3c40f564eb754b685dcdd1
Ruby
gentlawk/PuyoPuyo
/src/control_block.rb
UTF-8
2,655
2.78125
3
[]
no_license
#==============================================================================# # control_block.rb # #------------------------------------------------------------------------------# # @copyright (c) 2013, BlueRedZone ...
true
c8409b7ba366c56f04e2452947d116b3c262bbae
Ruby
smoll/loca
/lib/loca/git/branch_creator.rb
UTF-8
1,535
2.578125
3
[ "MIT" ]
permissive
module Loca module Git class BranchCreator include Common include Utils def initialize(pull_num, branch_name, remote_name, remote_url) @pull_num = pull_num @branch_name = branch_name @remote_name = remote_name @remote_url = remote_url end def create ...
true
53d91746e6087f1d3f84b5c8a69065b124fb14be
Ruby
shioimm/til
/practices/ruby/concurrency/counter/fiber_ver04.rb
UTF-8
499
3.265625
3
[]
no_license
require 'fiber' @queue = [] Fiber.new do 10.times do File.open('fiber_counter', File::RDWR | File::CREAT) do |f| ex_count = f.read.to_i count = ex_count + 1 @queue << [count, Fiber.current] end Fiber.yield end end.resume Fiber.new do 10.times do count, fiber = @queue.shift ...
true
d0fc4ccf665c14e70bfd38d5d4073c1579a088f8
Ruby
svmartin/l_school_challenges
/ruby_small_problems/easy_8/all_substrings.rb
UTF-8
1,042
4.4375
4
[]
no_license
# Write a method that returns a list of all substrings of a string. The returned # list should be ordered by where in the string the substring begins. This means # that all substrings that start at position 0 should come first, then all # substrings that start at position 1, and so on. Since multiple substrings will...
true
54c89d83124f8d12f3a710189fefba30140e6362
Ruby
anitajordan/tic-tac-toe-rb-q-000
/lib/tic_tac_toe.rb
UTF-8
4,496
3.9375
4
[]
no_license
WIN_COMBINATIONS = [ [0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 3, 6], [1, 4, 7], [2, 5, 8], [0, 4, 8], [2, 4, 6] ] def display_board(board) print " #{board[0]} ", "|", " #{board[1]} ", "|", " #{board[2]} \n" puts "-----------" print " #{board[3]} ", "|", " #{board[4]} ", "|", " #{boar...
true
c0c6a3884eb92b63dd381881cc4f3b51bf4fafc2
Ruby
Niikwartey/devise_lab-wdf-000
/app/helpers/application_helper.rb
UTF-8
186
2.609375
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
module ApplicationHelper def magic(sentence) tmp = sentence.split(" ") first = tmp.shift a = first + " " + tmp.map(&:downcase).join(" ") a.gsub(/! y/ ,"! Y") end end
true
0943ffe0a22a118a1d562ed26a43778c1237c466
Ruby
susanev/advent-of-code
/2016/day16/part1.rb
UTF-8
1,003
3.8125
4
[]
no_license
# susan evans # last edited 12/16/2016 # advent of code 2016, day 16, part 1 class Part1 CONST_DISK_SIZE = 272 def initialize(file_name) @data = File.open(file_name, "r").first generate_data find_valid_checksum output end def generate_data until @data.length >= CONST_DISK_SIZE next_data = reverse_i...
true
1460a18c92841ea52967f31ce54d78f93b66d6c8
Ruby
sadhu89/computer_store
/lib/line_item.rb
UTF-8
294
3.203125
3
[]
no_license
# frozen_string_literal: true class LineItem attr_reader :product, :quantity def initialize(product, quantity = 1) @product = product @quantity = quantity end def price @product.price * @quantity end def increase_quantity(units = 1) @quantity += units end end
true
e82fdcfb885b2168b52765089a1378420436bef3
Ruby
gavinblack87/week2-day2-homework
/specs/river_specs.rb
UTF-8
569
3
3
[]
no_license
require('minitest/autorun') require('minitest/rg') require_relative('../river.rb') require_relative('../fish.rb') class RiverTest < MiniTest::Test def setup() @fish1 = Fish.new("Gav") @fish2 = Fish.new("Gav") @fish3 = Fish.new("Gav") @fish = [@fish1, @fish2, @fish3] @river = River.new("Amazo...
true
0db63de829890805619889be5185ef047fe2197c
Ruby
nicklombardi/wdi
/assignments/happiTails1.rb
UTF-8
2,873
3.375
3
[]
no_license
# require 'pry' class Shelter attr_accessor :shelter, :client, :animal def initialize(shelter) @shelter = shelter @client = {} @animal = {} end end class Animal attr_accessor :name, :breed, :age, :gender, :favorite_toy, :client def initialize (name, breed, age, gender, favorite_toy) @name = ...
true
a85254879f7906af46553892b5d22311b395f1da
Ruby
Talbatross/18xx
/lib/engine/share_holder.rb
UTF-8
1,526
2.609375
3
[ "MIT", "LicenseRef-scancode-free-unknown" ]
permissive
# frozen_string_literal: true module Engine module ShareHolder def shares shares_by_corporation.values.flatten end def shares_by_corporation @shares_by_corporation ||= Hash.new { |h, k| h[k] = [] } end def shares_of(corporation) return [] unless corporation shares_by_co...
true
ba3564c39522c461f9c00f3ea55e603eddfa08a3
Ruby
0xddom/cobaya-old
/spec/cobaya/generator/literal_spec.rb
UTF-8
2,433
2.609375
3
[ "MIT" ]
permissive
require 'spec_helper' RSpec.describe Cobaya::Literals::True do include Cobaya::SexpHelper it 'generates a true expression' do expected = s(:true) srand 2346 lit = Cobaya::LiteralGenerator.random result = lit.generate expect(result).to eq expected end end RSpec.describe Cobaya::Literals:...
true
a335022768ab3e5f247815fe12c254127128f83f
Ruby
hwchan91/various_ai_programs
/rule_abbreviator.rb
UTF-8
420
2.53125
3
[]
no_license
# require './lisp_methods.rb' # module RuleAbbreviator # include LispMethods # PAT_ABBREV = { # "?X*" => %w(?* ?X), # "?Y*" => %w(?* ?Y), # "?X+" => %w(?+ ?X), # "?Y+" => %w(?+ ?Y), # "x" => "?X", # "y" => "?Y", # }.freeze # def expand_rules(rules) # PAT_ABBREV.each do |patter...
true
b5c952a553fa62e08fa306093aab31f8dbe6f3c8
Ruby
DocX/personal-timetabling
/www/app/controllers/api/solver_controller.rb
UTF-8
8,243
2.625
3
[]
no_license
class Api::SolverController < ApplicationController @@user_solvers = {} SOLVER_TIMEOUT = 30000 # start new sovler by given properties # # :problem_type # problem type to create for new solver instance. # :all - run solver on all events of user, even past # :future - run solver on future events. ...
true
28c145924b321bbed0b5427a22cfe4bca19f14b3
Ruby
sokampdx/hackerrank
/algorithms/staircase.rb
UTF-8
238
3.375
3
[]
no_license
#!/usr/bin/ruby def print_step(current, max) return if current > max space = max - current space.times { print " " } current.times { print "#" } print "\n" print_step(current + 1, max) end num = gets.chomp.to_i print_step(1, num)
true
9bbdaf7264ce4700c64221129f20397f9ba0e742
Ruby
jasylwong/battle
/lib/game.rb
UTF-8
596
3.65625
4
[]
no_license
require './lib/player.rb' class Game attr_reader :player1, :player2, :current_turn def initialize(player1, player2) @player1 = player1 @player2 = player2 @current_turn = @player1 @counter = 1 end def self.create(player1, player2) @game = Game.new(player1, player2) end def self.ins...
true
ba2d8c96f43cd731c61438892d7f012b80f68e01
Ruby
nick-zhang/rubyPractice
/basicStuff/string.rb
UTF-8
595
4.40625
4
[]
no_license
# p013expint.rb def say_goodnight(name) result = "Good night, #{name}" return result end puts say_goodnight('Satish') # modified program def say_goodnight2(name) "Good night, #{name}".reverse end puts say_goodnight2('Talim') puts "Upper case".upcase puts "Lower case".downcase # puts St...
true
97d6e1a043e7ab3d16b96d607fe97feeffa0d5f9
Ruby
brandallk/tic-tac-toe-rb-bootcamp-prep-000
/lib/tic_tac_toe.rb
UTF-8
2,127
4.1875
4
[]
no_license
WIN_COMBINATIONS = [ [0,1,2], # top row [3,4,5], # middle row [6,7,8], # bottom row [0,3,6], # left column [1,4,7], # middle column [2,5,8], # right column [0,4,8], # top-right to bottom-left diagonal [2,4,6], # top-left to bottom-right diagonal ] def display_board(board) cells = board.collect {|elt|...
true
875f199be4e628eb4dc3e37600e2dadbb88d7fea
Ruby
katmutua/tetris
/lib/shape_i.rb
UTF-8
592
2.953125
3
[]
no_license
require 'gosu' require_relative 'shape' class ShapeI < Shape LIGHT_PINK_COLOR = 0xffb2ffff def initialize(game) super(game) @blocks = [] @rotation_block = @blocks[1] @rotation_cycle = 2 end def get_blocks @blocks[0].x = @x @blocks[1].x = @x @blocks[2].x = @x @blocks[3].x = ...
true
ce6af7d9a15853b1fdd641ba017e1b2cefd7d330
Ruby
captproton/omnifocus_evernote_team
/models/project.rb
UTF-8
3,560
2.8125
3
[]
no_license
class Project attr_accessor( :title, :formatted_title, :url_encoded_project_title, :source_directory_path, :file_uri, :evernote_link, :omnifocus_link, ...
true
1cb24f70a7405193db6d692bd6b4a1ed301868c9
Ruby
MS-87/ruby_code
/coding_challenges/Grandmas_House/closest_points.rb
UTF-8
3,641
3.890625
4
[]
no_license
require 'benchmark' # struct which will define our points Point = Struct.new(:x, :y) #Compare distance of 2 points def distance(pt1, pt2) Math.sqrt((pt1.x - pt2.x)**2 + (pt1.y - pt2.y)**2) end #brute force method for finding closest point. #Will only be used in cases where N<3 def compare_all(points) return Floa...
true
47d52d546b9774d765c78257d20484e182854c31
Ruby
rluck0419/rr_mvc_json
/app/models/comment.rb
UTF-8
504
2.796875
3
[]
no_license
require 'faker' class Comment @@all = [] attr_reader :id, :post_id attr_accessor :message, :author def initialize(post_id, author, message) @@all << self @id = set_id @post_id = post_id @author = author @message = message end def to_json(json_arg = nil) { id: @id, messa...
true
a94771a46fa670872ee02c7444a0492b74a6c85c
Ruby
yunglleung1/OO-Auto-Shop
/app/models/car_owner.rb
UTF-8
790
3.484375
3
[]
no_license
class CarOwner @@all = [] attr_reader :name def initialize(name) @name = name @@all << self end def self.all #Get a list of all owners @@all end def owner_mechanics # Get a list of all the mechanics that a specific owner goes to mechanics = Mechanic.all.map do |mechanic| if mecha...
true
36ba211fdff3c8600d87ebe6859cedf1904bfb32
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/src/2909.rb
UTF-8
206
3.078125
3
[]
no_license
def compute(genome1,genome2) min_length = [genome1.length, genome2.length].min h_score = 0 (0..min_length-1).each do |i| h_score+=1 unless genome1[i]==genome2[i] end h_score end
true
9c0df7e900be609eae393c74c7614a228b5f723a
Ruby
ged/ore
/lib/ore/naming.rb
UTF-8
3,897
2.78125
3
[ "MIT" ]
permissive
module Ore # # Provides methods for guessing the namespaces and directories # of projects. {Naming} uses the naming conventions of project names # defined by the # [Ruby Packaging Standard (RPS)](http://chneukirchen.github.com/rps/). # # @since 0.9.0 # module Naming # The directory which contains ...
true
00d4b5438286f9372863b2d15e696ef9d957daba
Ruby
gerrygoo/designpatternsquiz
/services/quiz-score.rb
UTF-8
2,526
3.140625
3
[]
no_license
# Final Project: Quiz Application with Microservices # Date: 14-May-2019 # Authors: # Ariel Ortiz # A01371872 Gerardo Galván # A01377503 Ian Neumann # A01371779 Andrés de Lago require 'json' require 'aws-sdk-dynamodb' # handles a bad method event DYNAMODB = Aws::DynamoDB::Client.new # the dynamo...
true
29b44e524636913c1ca81b226bfca42633869015
Ruby
helton/understanding-computation
/semantics/lib/simple_core.rb
UTF-8
603
3.09375
3
[ "MIT" ]
permissive
class Value < Struct.new(:value) def to_s value.to_s end def inspect "<<#{self}>>" end def reducible? false end def evaluate(environment) self end def to_ruby "-> e { #{value.inspect} }" end end Number = Class.new(Value) Boolean = Class.new(Value) class Variable < Struct.n...
true
ff2ca92a460180a35067eb8b35da5692c0b3d3b5
Ruby
veezus/trakstar
/anagram.rb
UTF-8
403
3.515625
4
[]
no_license
class Anagram def self.anagrams? first, second first_a = first.split '' second_a = second.split '' return false unless first_a.length == second_a.length return false unless first_a.all? {|character| second_a.include? character } first_a.each do |character| next unless index = second_a.inde...
true
056428fd48a213951c87b2b64ddc75dd580f563d
Ruby
swenson/t-essentials
/app/helpers/application_helper.rb
UTF-8
421
2.515625
3
[]
no_license
# Methods added to this helper will be available to all templates in the application. module ApplicationHelper def fixwebsite(url) return "http://#{url}" unless url[0..6] == 'http://' return url end def email(addr) link_to addr, "mailto:#{addr}" end def twodec(num) sprintf("%.2f", num) ...
true
3f76a7e70eff1964087da9618a3a9ed8c317ab00
Ruby
bonochof/re-source-defence
/deck.rb
UTF-8
689
3.15625
3
[]
no_license
class Deck def initialize() @deck_recipe = [ [CardInfo::FARM, 3], [CardInfo::MARKET, 3], [CardInfo::TEST, 1] ] @deck = [] build #show end def build @deck_recipe.each do |card| card[1].times do @deck << card[0] end end @deck = @deck.shuffle e...
true
b64fd659d5b44f1550d0787e8a7fc3afb798dcb2
Ruby
provpup/LHLTwoPlayerMathGame
/mathgame.rb
UTF-8
1,634
3.75
4
[]
no_license
require_relative('questions') @max_lives = 3 @player_one = {name: nil, lives: nil} @player_two = {name: nil, lives: nil} def prompt_for_name(default_player_name) print "Please enter name for #{default_player_name}: " gets.chomp end def question_round(player) question_to_ask = generate_question(player[:name]) ...
true
ccb051bfaebb020f65c1a70d29afbdcd0bb0d97b
Ruby
tvumbaca/event_manager
/lib/event_manager.rb
UTF-8
2,478
3.46875
3
[]
no_license
require "csv" require "sunlight/congress" require "erb" Sunlight::Congress.api_key = "e179a6973728c4dd3fb1204283aaccb5" def clean_zipcode(zipcode) zipcode.to_s.rjust(5, "0")[0..4] end # Clean and validate phone numbers def valid_phone(phone) phone.gsub!(/\D/, "") if phone.length == 10 puts phone elsif ph...
true
9df88c3adee2dc399a2b78ce093911890bf1f766
Ruby
jeffkbui/W4D5
/algorithms/execution_time_diff.rb
UTF-8
1,117
3.921875
4
[]
no_license
class Array # def my_min #phase 1: big-O(n^2) # min = first # self.each_with_index do |el1, idx1| # self.each_with_index do |el2, idx2| # if idx2 > idx1 && el1 < el2 # min = el1 if el1 < min # end # end # end # min # end def my_min #phase 2: big-O(n) min...
true
71e03558b1ff6a7b4c36eb920cca6f27cc0b0a14
Ruby
jkingharman/ruby-kickstart
/session6/challenge/sinatra_encrypter/lib/encryptor.rb
UTF-8
629
3.453125
3
[ "MIT" ]
permissive
module Encryptor def create_cipher cipher_lower = Hash[('a'..'w').to_a.zip(('d'..'z').to_a)] cipher_lower["x"] = "a"; cipher_lower["y"] = "b"; cipher_lower["z"] = "c" cipher_upper = Hash[('A'..'W').to_a.zip(('D'..'Z').to_a)] cipher_upper["X"] = "A"; cipher_lower["Y"] = "B"; cipher_lower["Z"] = "C" combo_ci...
true
de87e231ed21a24e6632fcef8d16248b80e9b822
Ruby
big-data-europe/ruby-cleanup
/lib/helpers/clean.rb
UTF-8
2,487
2.84375
3
[ "Apache-2.0" ]
permissive
### # Helper module for cleaning methods ### module Helpers module Clean ### # Method to clean data from the database # # Use this method when pulling the query from the # config files is enough ### private def clean(config, delete_param, graph_param...
true
689a00567511bf7157b1026dff1b3d1312f761fb
Ruby
softwarehistorysociety/geojson-diff
/script/create-fixture
UTF-8
1,263
2.578125
3
[ "MIT" ]
permissive
#! /usr/bin/env ruby # Usage: script/create-fixture name-of-fixture # # Ensures before.geojson and after.geojson exist in test/fixtures/name-of-fixture # # If they do, saves geojson-diff job output for added, removed, and unchanged $LOAD_PATH.unshift(File.expand_path('../lib', File.dirname(__FILE__))) require 'geojs...
true
3b686d0771d74546d54d34726140d1b0b2be2125
Ruby
MacKLess/anagram_antigram
/spec/anagram_antigram_spec.rb
UTF-8
1,676
3.1875
3
[ "MIT" ]
permissive
require('rspec') require('anagram_antigram') require('pry') describe('#anygrams?') do it("turns first string input into array") do word_test = WordChecker.new("confusion", "ignorance") expect(word_test.create_array(word_test.input1)).to(eq(["c","o","n","f","u","s","i","o","n"])) end it("returns denial if...
true
f78d545a3080a5c5cf4fd1da0013715cb94b8cfb
Ruby
mwagner19446/wdi_work
/w03/d05/Michael/food/food.rb
UTF-8
4,846
3.234375
3
[]
no_license
require 'pry' require 'active_record' ActiveRecord::Base.establish_connection( :adapter => "postgresql", :host => 'localhost', :username => 'michaelwagner', :password => '', :database => 'fridge_db' ) class Fridge < ActiveRecord::Base has_many :foods has_many :drinks end class Food < ActiveRecord::Bas...
true
ded074e7ff9629c0f60e3e23b3fe5c53f8a5a5c2
Ruby
yvanross/upc-scrapers-roda
/scraper/barcode-database.rb
UTF-8
679
2.578125
3
[]
no_license
require_relative '../lib/strategy' class BarcodeDatabase < Strategy def scrape(code) description = image_url = '' valid = false html = HTTParty.get("https://barcodesdatabase.org/barcode/#{code}") doc = Nokogiri::HTML(html) container = doc.css("#internal-db.well") ...
true
f4f188942c16a409f791f76f4ba2170b16b9f5f6
Ruby
jmschles/codeeval
/moderate/jolly_jumpers.rb
UTF-8
334
3.078125
3
[]
no_license
File.open(ARGV[0]).each_line do |line| data = line.chomp.split.map(&:to_i) abs_values = [] data.shift len = data.count data.each_index do |i| break if i == len - 1 abs_values << (data[i] - data[i+1]).abs end if abs_values.uniq.sort == (1..(len-1)).to_a puts "Jolly" else puts "Not jo...
true
e8ec60b1bb84899dc7ecdb5eb15ac1093745269a
Ruby
RyanL2020/say-hello-ruby-ruby-intro-000
/say_hello.rb
UTF-8
212
2.6875
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def say_hello(name= "Ruby Programmer") puts "Hello #{name}!" end # def say_hello("Kent Beck") # puts "Hello Kent Beck!" # end # def say_hello() # puts "Hello Ruby Programmer!" # end # say_hello() # say_hello("")
true
2583cf54126f36cbe540d93fae19dc4c0b91a932
Ruby
EdmundLeex/others
/ruby_algor_practice/some_fun_challenges/swingers.rb
UTF-8
1,180
4.15625
4
[]
no_license
# Implement a Swingers game. The method swingers should take an array of couple arrays and return the same type of data structure, with the couples mixed up. Assume that the first item in the couple array is a man, and the second item is a woman. Don't pair a person with someone of their own gender (sorry to ruin your ...
true
e798fc5d357d520911267c1561617528f3398846
Ruby
wkirschbaum/RailsOwaspSamples
/4.rb
UTF-8
389
2.796875
3
[]
no_license
# app/views/layouts/shared/_header.html.erb <li style="color: #FFFFFF"> <!-- I'm going to use HTML safe because we had some weird stuff going on with funny chars and jquery, plus it says safe so I'm guessing nothing bad will happen --> Welcome, <%= current_user.first_name.html_safe %> </li> # Simil...
true
78e94724a2bc002af3745d25d321139db9276b3a
Ruby
pumzy/ruby-lecture-reading-error-messages-bootcamp-prep-000
/lib/a_syntax_error.rb
UTF-8
100
3.1875
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def numbers(n) str = n.to_s i = 0 while str.length > i print "ggwp" i += 1 end end
true
329cfafbacb9b3c4ef700263139b44e06a76c104
Ruby
alscotty/Algorithms-Review
/11_6.rb
UTF-8
1,372
3.484375
3
[]
no_license
# @param {Integer[]} nums # @return {Integer} def find_peak_element(nums) return 0 if nums.size == 1 peak = nil (0...nums.length).each do |i| if nums[i-1] && nums[i+1] && nums[i] > nums[i-1] && nums[i] > nums[i+1] peak = i elsif !nums[i-1] && nums[i+1] && nums[i] > nums[i...
true
c64c0a34e6c02b274344ed4bf703be709fdb93b7
Ruby
nixsticks/secrets
/encoder.rb
UTF-8
407
3.296875
3
[]
no_license
message = "The quick brown fox jumped over the lazy dog" def encode(message) gsub_args = [ [/a/, "BZZZ"], [/e/, "FZZZ"], [/i/, "TRZZZ"], [/o/, "KRZZZ"], [/u/, "PRZZZ"], [/ /, "YRZZZ"] ] history = Hash.new(message) gsub_args.each_with_index do |args, i| history[(i+1)] = history[i...
true
29f70cfd7ac5ffed7a4a303ca47ee10ec056f9b2
Ruby
thefrenchentrepreneur/blackcurtain
/app/models/guess.rb
UTF-8
489
2.53125
3
[]
no_license
class Guess < ActiveRecord::Base belongs_to :app email_regex = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i validates :character, :presence => true, :length => { :maximum => 1 } validates :email, :presence => true, :format => { :with => email_regex }, :l...
true
5fb074385488499f530649ceada3bc4120e97407
Ruby
reckenrode/advent_2019
/lib/advent_2019/day1.rb
UTF-8
1,644
3.3125
3
[ "MIT" ]
permissive
# frozen_string_literal: true # lib/advent_2019/day1.rb # Copyright © 2019 Randy Eckenrode # # This program is distributed under the terms of the MIT license. You should # have received a copy of this license with this program. If you did not, you # can find a copy of this license online at https://opensource.org/li...
true
c9700c0e11fa98e98eb24bff430775d01e54a9b1
Ruby
williamtome/ruby-course
/conceitos/op_mat/subtracao.rb
UTF-8
50
2.734375
3
[]
no_license
puts 5-3 num3 = 100 num4 = 20 puts num3 - num4
true
8ae04542553a6234482b3f4dd82c7b94ba44138d
Ruby
melmalfa/godot
/w01/d05/student/refactored_code.rb
UTF-8
1,525
4.34375
4
[]
no_license
# *Read* through the following code # Write comments above *each line* explaining what it does require 'colorize' require 'pry' # Methods def generate_random_number (1..10).to_a.sample end def alert(message) $stdout.puts(message.green) end #mcreates ethod called "warn' def warn(message) # method prints info to ...
true
f41abd35fba778f1399d5e8b7f19bef0d7bf8f32
Ruby
aldefouw/redcap_calc_value_differences
/library/browser.rb
UTF-8
1,491
2.515625
3
[ "MIT" ]
permissive
require 'mechanize' require "#{Dir.getwd}/library/authentication" class Browser attr_reader :options attr_reader :threads attr_reader :redcap_url attr_reader :redcap_version attr_reader :agent attr_reader :project_id attr_reader :threads attr_accessor :authentication attr_reader :events_page de...
true
9b1b703d7f94ebae95285e6c8c365e95830544dc
Ruby
jlovedragon/LeetCodePractice
/rightSideViewTree.rb
UTF-8
375
2.75
3
[]
no_license
def right_side_view(root) return [] if root ==nil ta=Array.new qu=Array.new qu.push root while true tal=Array.new que=Array.new while qu.size>0 tr=qu.shift que.push tr.left if tr.left!=nil que.push tr.right if tr.right !=nil tal.push tr.val end qu=que ta.push t...
true
2525ab3c92b0534addfe936fdff2c2b4b473d03b
Ruby
collabnix/dockerlabs
/vendor/bundle/ruby/2.6.0/gems/rubocop-0.93.1/lib/rubocop/cop/layout/empty_line_after_guard_clause.rb
UTF-8
4,231
2.671875
3
[ "Apache-2.0", "CC-BY-NC-4.0", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
# frozen_string_literal: true module RuboCop module Cop module Layout # This cop enforces empty line after guard clause # # @example # # # bad # def foo # return if need_return? # bar # end # # # good # def foo # ...
true
19f9d1499040ca020b0bc11375ddf405efce0417
Ruby
AdilOmary/rps-game
/app/models/game.rb
UTF-8
650
2.6875
3
[]
no_license
class Game < ApplicationRecord belongs_to :user accepts_nested_attributes_for :user enum move: [:rock, :paper, :scissors] enum bot_move: [:rock, :paper, :scissors], _prefix: true validates :move, inclusion: ['rock', 'paper', 'scissors'] validates :bot_move, inclusion: ['rock', 'paper', 'scissors'] de...
true
88edc9cc1486b1298da468018959eab7bf58f759
Ruby
lastgleam/atcoder-solutions
/src/C-WalkOnMultipulationTable.rb
UTF-8
250
3.234375
3
[]
no_license
# C - Walk on Multiplication Table # https://atcoder.jp/contests/abc144/tasks/abc144_c # answer = 0 num = gets.strip.to_i max = Math.sqrt(num).to_i max.downto(1) do |n| if num % n == 0 answer = n + (num / n) - 2 break end end puts answer
true
4d110837e06585cdc48034646eed488e1fbc732f
Ruby
jdcarey128/enigma
/test/shift_test.rb
UTF-8
3,781
3.203125
3
[]
no_license
require './test/test_helper' class ShiftTest < Minitest::Test def test_it_exists_and_has_attributes shift = Shift.new("hello world", "02794", "170920") assert_instance_of Shift, shift assert_equal "hello world", shift.message assert_equal "02794", shift.key assert_equal "170920", shift.date ...
true
0634f7d38daaf3c271f53cb2213db463404cdb8c
Ruby
cloudwicklabs/ankus-modules
/utils/lib/puppet/provider/wait_for/ruby.rb
UTF-8
2,346
2.625
3
[ "Apache-2.0" ]
permissive
Puppet::Type.type(:wait_for).provide(:ruby) do desc "Waits for something to happen." def exit_code query = resource[:query] `#{query}` return $? end def exit_code=(expected_exit_code) fetch_parameters info "waiting until the exit code of #{@query} is #{expected_exit_code.to_s}" info "p...
true
97cd87219664d917ec40095f3cff1e972e3b848a
Ruby
brickstar/event_reporter
/test/print_formatter_test.rb
UTF-8
4,474
2.703125
3
[]
no_license
require './lib/print_formatter' require './lib/attendee' require './lib/queue' require 'minitest/autorun' require 'minitest/pride' require 'pry' class PrintFormatterTest < Minitest::Test def test_headers q = Q.new assert_equal ["LAST NAME", "FIRST NAME", "EMAIL", "ZIPCODE", "CITY", "STATE", "ADDRESS", "PHO...
true
a4efa737f5ad4d66ee7e6af186cb5c03c78599ff
Ruby
marioatpb/advent_of_code
/2017/01/spec/captch_spec.rb
UTF-8
1,118
2.921875
3
[]
no_license
require './captch.rb' require 'rspec' require 'pry' describe Advent do let(:input) { <<~EOS 91212129 EOS } describe Advent::Captch do let(:ad) { Advent::Captch.new(input) } describe "#new" do it "loads a sequence of digits" do expect(ad.digits).to eq([9, 1, 2, 1, 2, 1, 2, 9...
true
744894be19563581a60dbd93f9edd1732fc04d7a
Ruby
cmvandrevala/footprints-public
/spec/applicant_dispatch/scorers/skill_scorer_spec.rb
UTF-8
1,230
2.53125
3
[]
no_license
require 'ostruct' require 'applicant_dispatch/strategies/scoring_strategy' require 'applicant_dispatch/util/scoreable_entity' module ApplicantDispatch module Scorers describe "SkillScorer" do subject { SkillScorer } let(:weight) { WEIGHT[:matching_skill_level] } let(:applicants_skill) { "Ping ...
true
8a39530a20142feaaf77b3640e6c6916a2eeaa94
Ruby
andrewgy8/Ruby_Projects
/stock_picker.rb
UTF-8
1,025
4.125
4
[]
no_license
def stock_picker(stocks) high = [] low = [] #puts first number in stock set to the high array high << stocks[0] #iterates through stock array to test whether they are higher in value than the current high array value #if it is the high array is emptied, and the new value take its place stocks.each do |stock| ...
true
30a92c5d7458b289627c03ba8b059a97e3b3d04a
Ruby
RailsEventStore/rails_event_store
/ruby_event_store/lib/ruby_event_store/stream.rb
UTF-8
499
2.6875
3
[ "MIT" ]
permissive
# frozen_string_literal: true module RubyEventStore class Stream def initialize(name) raise IncorrectStreamData if !name.equal?(GLOBAL_STREAM) && (name.nil? || name.empty?) @name = name end def global? name.equal?(GLOBAL_STREAM) end attr_reader :name def hash name.h...
true
041eb299eeb24e53f66a218e2f80b632bdadcce9
Ruby
acseler/cdrk
/spec/game_spec.rb
UTF-8
2,876
3
3
[ "MIT" ]
permissive
require 'spec_helper' require 'codebreaker_rack_app/game' require 'codebreaker_rack_app/game_enums' # Module CodebreakerRackApp module CodebreakerRackApp RSpec.describe Game do subject(:game) { Game.new } context '#start' do before { game.start } it 'generates secret code' do expect(game...
true
7cd912fad6028425895392824ff2484a9f1dd6ee
Ruby
sneakin/CooCoo
/examples/reinforcer/moving-bit.rb
UTF-8
341
3.4375
3
[ "LicenseRef-scancode-warranty-disclaimer" ]
no_license
#!/usr/bin/env ruby # Generates lines of zeros and ones where the one moves # right column to column on each iteration. iters = (ARGV[0] || 1000).to_i nbits = (ARGV[1] || 4).to_i iters.times do (nbits + 1).times do |n| bits = [ 0 ] * nbits bits[n] = 1 unless n >= nbits $stdout.puts(bits.collect(&:to_s)....
true
bd1b3433fa0882195094cc03670ee47213e5d878
Ruby
MikeBlumenthal/Week2Day3LabPub
/specs/pub_secs.rb
UTF-8
564
2.84375
3
[]
no_license
require("minitest/autorun") require("minitest/rg") require_relative("../pub.rb") require_relative("../drink.rb") class Pubtest < MiniTest::Test def setup() @drink1 = Drink.new("Tennants",2) @drink2 = Drink.new("Cider",3) @drink3 = Drink.new("Beer",4) @pub = Pub.new("Chanter",10,[@drink1,@drink2,@dri...
true
eb89ec9bf14387c5c4d33bc1f293677bdd962632
Ruby
blowerone/RubyDev
/source/day07/ruby_object.rb
UTF-8
8,499
4.1875
4
[]
no_license
=begin Ruby 面向对象 Ruby 是纯面向对象的语言,Ruby 中的一切都是以对象的形式出现。Ruby 中的每个值都是一个对象,即使是最原始的东西:字符串、数字,甚至连 true 和 false 都是对象。类本身也是一个对象,是 Class 类的一个实例。本章将向您讲解所有与 Ruby 面向对象相关的主要功能。 类用于指定对象的形式,它结合了数据表示法和方法,把数据整理成一个整齐的包。类中的数据和方法被称为类的成员。 Ruby 类定义 当您定义一个类时,您实际是定义了一个数据类型的蓝图。这实际上并没有定义任何的数据,而是定义了类的名称意味着什么,也就是说,定义了类的对象将由什么组成,以及在该对象上能执行什么操作。 类定义...
true
c3fa5e755722f04725f6d4fb9d74433d785e64e0
Ruby
rhorrace/exercism
/ruby/sum-of-multiples/sum_of_multiples.rb
UTF-8
493
3.765625
4
[]
no_license
=begin Write your code for the 'Sum Of Multiples' exercise in this file. Make the tests in `sum_of_multiples_test.rb` pass. To get started with TDD, see the `README.md` file in your `ruby/sum-of-multiples` directory. =end class SumOfMultiples def initialize(*args) @factors = args.to_a end def to(lim) r...
true
2468a7df9c9a0c3c697dde55b6648ec6d6860ce7
Ruby
rcuhljr/rosalind
/rosalind_genome_assembly.rb
UTF-8
1,074
2.640625
3
[ "MIT" ]
permissive
load 'fasta.rb' fasta = FASTA.new() fasrecs = fasta.load_file "genome_assembly.fas" File.open('results.txt', "w") do |output| result, *sequences = fasrecs.values.clone while sequences.length > 0 do sequence, *sequences = sequences n = sequence.length/2+(sequence.length%2) offset = res...
true
eebb29b91a67a9dfda0daad8709290cf85ba0968
Ruby
jennianelson/ruby-class-variables-and-class-methods-lab-v-000
/lib/song.rb
UTF-8
1,116
3.796875
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require "pry" class Song attr_accessor :name, :artist, :genre @@count = 0 @@genres = [] @@artists = [] def initialize (name, artist, genre) @name = name @artist = artist @genre = genre @@count += 1 #each time a new instance of the Song class is created, the counter will increase by 1. @@...
true
473526f386229fc5a1bccde3b753d3ebb125826f
Ruby
OkiStuff/ConsoleGL
/examples/keypresseed.rb
UTF-8
163
2.671875
3
[ "MIT" ]
permissive
require 'ConsoleGL' # loop while true do if Input.KeyPressed("a") puts "CORRECT KEY PRESSED" else puts "INCORRECT KEY PRESSED" end end
true
f6aa2133059f8ddbfc8234fc9e9b9d66d84dec35
Ruby
RDFroeber/bevalkyri
/app/models/board.rb
UTF-8
1,166
2.859375
3
[]
no_license
class Board < ActiveRecord::Base has_many :games has_many :players, :through => :games has_many :tiles has_many :buildings include BoardHelper def build_board(player) set_player(player) create_tiles place_castle assign_money end def set_player(player) @player = Player.find(player....
true
057f74d75517747a523042c759c61168d663e0ea
Ruby
Nauktis/nauktis_utils
/lib/nauktis_utils/archiver.rb
UTF-8
4,285
2.53125
3
[ "MIT" ]
permissive
module NauktisUtils # Wrapper around TAR class Archiver include Logging attr_reader :options def initialize(&block) @options = { paths: [], } if block_given? instance_eval(&block) tar end end def tar Tracer.info "Creating archive for #{@options[:paths]}" raise "TAR is not ava...
true
3810098031e4a5edf1ed86d73593341c5ec1048f
Ruby
BandanaKM/rubylearning
/core/week4/ex3.rb
UTF-8
1,440
4.15625
4
[]
no_license
=begin Exercise3. Call this program (p026zdeafgm2.rb) - Modify your Deaf Grandma program (Week 3 / Exercise6): What if grandma doesn"t want you to leave? When you shout BYE, she could pretend not to hear you. Change your previous program so that you have to shout BYE three times in a row. Make sure to test your prog...
true
82e6b612e3997dcfd14bc5222a078e2c97bb353e
Ruby
changeworld/hackerrank
/domains/algorithms/arrays-and-sorting/countingsort1.rb
UTF-8
92
2.734375
3
[]
no_license
#!/bin/ruby _ = gets k = [0]*100 gets.strip.split.each{|x| k[x.to_i] += 1} puts k.join ' '
true
3b17d5ea0ebd5ca37924429086e180c4b6dabc16
Ruby
enjareyes/RubyPractice
/ruby-exercises/ifelse.rb
UTF-8
4,216
4.625
5
[]
no_license
=begin If Statements Now that we know how to write conditional statements, we can use them to modify the flow of the program between different branches. If Statements The basic branching structure in Ruby is the if structure. The if structure allows the program to run a particular set of code (or a branch) when a ...
true
2b7d93397e404e0a39827e8e1b8f49c518e4e586
Ruby
StephenVarela/methods
/exercise5.rb
UTF-8
232
3.3125
3
[]
no_license
def greet_backwards(name) return "Hello #{name.reverse*2}! Welcome Home" end puts(greet_backwards('Amanda')) puts(greet_backwards('Bob')) puts(greet_backwards('Shirly')) puts(greet_backwards('Sue')) puts(greet_backwards('Andy'))
true
39cdc7cfa84a8c3110e5c840b7b65d7f42d9cb5d
Ruby
JakeMKelly/phase-0-tracks
/ruby/gps2_2.rb
UTF-8
2,627
4.625
5
[]
no_license
# Create a new list # Add an item with a quantity to the list # Remove an item from the list # Update quantities for items in your list # Print the list (Consider how to make it look nice!) # Method to create a list # input: string of items separated by spaces (example: "carrots apples cereal pizza") # output:...
true
f5277b9a10328a18e8b584c542caeec2a727d629
Ruby
ZehaIrawan/learn_ruby
/05_book_titles/book.rb
UTF-8
349
3.640625
4
[]
no_license
class Book def title @title end def title=(string_in) words = string_in.split(' ') words[0][0] = words[0][0].upcase for word in words do if !["the","and","in","on","over", "of", "a", "an"].include?(word) word[0] = word[0].upcase end end @title = ...
true
193da24a7d71fc0bd29ce8db1910b8b70f8c7a89
Ruby
rainly/cbcl
/app/models/subscription_presenter.rb
UTF-8
2,982
2.8125
3
[]
no_license
class SubscriptionPresenter # Details view: subscription (one per survey), list of total, total_active (since last payment) # Summary view: periods # periods -> total used in period attr_accessor :group, :subscriptions, :summary_view, :surveys, :periods, :detailed_view, :params def initialize(group, survey...
true
7b64332c4d28b9cbc3d5ec3d6f316c3a57eb7a3e
Ruby
erivera0108/ruby-oo-practice-flatiron-zoo-exercise-nyc-web-033020
/run.rb
UTF-8
628
3.046875
3
[]
no_license
require_relative "lib/Animal.rb" require_relative "lib/Zoo.rb" require_relative "lib/Zoo_Animal" require 'pry' #Test your code here z1 = Zoo.new("Flatiron Zoo", "NYC") z2 = Zoo.new("Code Zoo", "Phily") z3 = Zoo.new("Dog Zoo", "NYC") a1 = Animal.new("Dog", "Spotty", 5) a2 = Animal.new("Dog", "Rex", 25) a3 = Animal.ne...
true
cc3d095f4a49f7a217745ccefb5a758093070ccd
Ruby
danielribeiro/rubytricks
/blockswithblocks.rb
UTF-8
230
2.84375
3
[ "MIT" ]
permissive
#!/usr/bin/env ruby #not possible in 1.8: http://stackoverflow.com/questions/89650/how-do-you-pass-arguments-to-definemethod b = lambda do |*args| puts args end b.call(6, 7, 89, lambda { puts 'done'}, lambda { puts 'and done'})
true
aa618dbd537b8e4f54e7e83d5efb3c670c5ad783
Ruby
learn-co-curriculum/rails-form-lecture-web-1116
/db/seeds.rb
UTF-8
498
2.6875
3
[]
no_license
# Faker Gem 10.times do Song.create(title: Faker::Hipster.sentence(rand(1..2))) end 10.times do Artist.create(name: Faker::Superhero.name) end music_genres = ["Hip Hop", "Country", "Electronic", "Pop", "Rock", "Classical"] 10.times do Genre.create(name: music_genres[rand(music_genres.length)]) end Song.all.e...
true
2fb5e950eeb4e857f84f949d3e5b42e73bbc29fc
Ruby
HugoHead/memorize
/memorizelist.rb
UTF-8
309
2.96875
3
[]
no_license
puts "memeorize lists!!" list = ['alif', "baa", "taa", "thaa", "jeem", "Haa", "KHaa", "daal", "dhaal", "raa", "zaay", "seen", "sheen", "sOd", "dOd", "TTaa'", "THaa'", "Ayn", "Ghayn", "faa", "Qaaf", "Kaaf", "lam", "meme", "noon", "haa", "wow", "ya"] puts list[0] list.each do |n| print n gets end
true
fb60ae0043dfd63f666e128889ae9e56027255aa
Ruby
Andrew8xx8/GreenMidget
/lib/green_midget/models/words.rb
UTF-8
561
2.515625
3
[]
no_license
# Copyright (c) 2011, SoundCloud Ltd., Nikola Chochkov # # A model for Words used in GreenMidget. See Countable # module GreenMidget class Words < Countable self.prefix = 'word::' def self.record_keys(words, category = nil) words.map do |word| Array(category || CATEGORIES).map{ |category| Words...
true
e7815d0d99e121a713829836faa62128dd95f5e3
Ruby
jrwhitmer/adventure_2103
/lib/hiker.rb
UTF-8
885
3.328125
3
[]
no_license
class Hiker attr_reader :name, :experience_level, :snacks, :parks_visited def initialize(name, experience_level) @name = name @experience_level = experience_level @snacks = {} @parks_visited = [] end def pack(snack, quantity) if @snacks[snack].nil...
true
c0438e4cbbf7e492ee79f76159ccc106148377a4
Ruby
shhr1214/aoj
/ruby/maximum_profit.rb
UTF-8
309
3.09375
3
[]
no_license
if __FILE__ == $0 n = gets.to_i r1 = gets.to_i r2 = gets.to_i max_diff = r2 - r1 min_value = r2 < r1 ? r2 : r1 for i in 0..(n-2) r3 = gets.to_i max_diff = (r3 - min_value) < max_diff ? max_diff : (r3 - min_value) min_value - min_value < r3 ? min_value : r3 end print max_diff end
true
f33f10060d33a6dc85216201ff0a505f5b874b5f
Ruby
stuwags/Project_Euler_problems
/25.rb
UTF-8
296
3.46875
3
[]
no_license
@fa = 1 @fb = 1 @ticker = 2 def fibonacci_sequence temp = @fa + @fb @fa = @fb @fb = temp @ticker += 1 end while @fb.to_s.length < 1000 fibonacci_sequence end puts "This is the first three digit fib number #{@fa} and this is the number the precedes it #{@fb}" puts "It happened at f #{@ticker}"
true
ea74c1d6d76c07de83f1e4bed27bcbbef1f613c5
Ruby
kolishchak/codewars
/Design Patterns/strategy.rb
UTF-8
301
3.078125
3
[]
no_license
class Fly def move(unit) unit.position += 10 end end class Walk def move(unit) unit.position += 1 end end class Viking attr_accessor :position, :move_behavior def initialize @position = 0 @move_behavior = Walk.new end def move move_behavior.move self end end
true
a47f9ed8497850e3bbc8baf8581f60f7dae028d8
Ruby
colbymorrison/cs377
/final/smores/init-ts.rb
UTF-8
337
2.53125
3
[]
no_license
# # cs377 # S'mores Problem # Colby Morrison # init-ts.rb # # Initialize tuple space require 'rinda/rinda' # Connect to tuple space URI = "druby://localhost:67671" DRb.start_service ts = Rinda::TupleSpaceProxy.new(DRbObject.new(nil, URI)) # Write a select semaphore ts.write(["sem", "select"]) puts "Tuple space s...
true
a1bf986df5699b3a55d4ae6938949c5631585099
Ruby
kaievns/svrails-2014-06-19
/slides/10.rb
UTF-8
98
2.609375
3
[ "MIT" ]
permissive
# Moving To The Beginning Of Line print "I promise!" sleep 2 print "\rNah, I've changed my mind"
true
7c49572e08ecab715084aca996f63fcbe6d75e5e
Ruby
dawanda/doctools
/spec/doctools/repo_spec.rb
UTF-8
1,038
2.5625
3
[]
no_license
require 'spec_helper' require 'doctools/repo' module Doctools describe Repo do pending 'Implement proper url parsing' let(:repo) { Repo.new('vimrunner', 'AndrewRadev', 'vimrunner', 'master') } it "knows its name" do repo.name.should eq 'vimrunner' repo.github_project.should eq 'vimrunner' ...
true
f7581575a0dabe3f3936bf6a2439537c2933646c
Ruby
Vutienbka/Ruby
/Variables/LocalVariables.rb
UTF-8
268
3.046875
3
[]
no_license
def method1 def method2 def method3 m5, m6 = 3 puts "Level 3" puts local_variables end m3, m4 = 5 puts "Level 2" puts local_variables method3 end m1, m2 = 7 puts "Level 1" puts local_variables method2 end method1
true
c6485709cdff8b0d8b02b27c01008259c07e2f55
Ruby
udit7590/chewcandy
/app/models/shopping_cart.rb
UTF-8
2,035
2.75
3
[]
no_license
class ShoppingCart < ActiveRecord::Base has_many :shopping_cart_items, dependent: :destroy belongs_to :user has_one :order delegate :discount_amount, to: :coupon scope :active, -> { where(active: true) } scope :inactive, -> { where(active: false) } def add(product_id, quantity) product = Product.fi...
true
0568f2d0de0c9010dd926501ca5d5b9a4cdd92a1
Ruby
tomas-stefano/financial
/spec/financial/deposit_spec.rb
UTF-8
2,265
2.859375
3
[]
no_license
require 'spec_helper' module Financial describe Deposit do let(:deposit) { Deposit.new(1000, :a_account_name) } describe '#name' do after(:each) do ensure_locale :en end it 'should return the the name in english' do deposit.name.should == 'Deposit: anonymous' end ...
true