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
472a13487a3a2a2f04e4d547c8a733fb02168061
Ruby
Rockster160/Games
/split_csv.rb
UTF-8
752
2.78125
3
[]
no_license
#!/usr/bin/env ruby -w filename = "/Users/rocconicholls/Downloads/total care patient list - Copy of PatientDemo_2Line.csv" lines_per_file = 100 header_lines = 1 extension = File.extname(filename) basename = File.basename(filename, extension) puts "#{extension} - #{basename}" header = [] File.foreach(filename).with_i...
true
b80a42bcdb22dc4a91310125903e99dfbc200fd4
Ruby
Ricardo-Paul/auto_sales
/lib/auto_sales/cli.rb
UTF-8
1,105
3.34375
3
[ "MIT" ]
permissive
class AutoSales::CLI def call list_auto menu end def list_auto @cars = AutoSales::Car.car_info @cars.each.with_index(1) {|car, i| puts " #{i}. #{car.model}"} end def menu puts" Enter the number of car to have more info / and 'show' to display the list " in...
true
98f28f8243357b9eead0ee9f98df2372a5d429f2
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/difference-of-squares/290035c1bb0b4d8592ad132c6bc7ca05.rb
UTF-8
330
3.46875
3
[]
no_license
class Squares attr_reader :n def initialize(n) @n = n end def sum_of_squares f = lambda { |n| n < 2 ? n : f[n-1] + n**2 } f.call(n) end def square_of_sums f = lambda { |n| n < 2 ? n : f[n-1] + n } f.call(n)**2 end def difference square_of_sums - sum_of_squares ...
true
82b4d9219c69d48295950681f0fd4df8af2061b5
Ruby
Kweiss/Ruby-Code
/L2C/ex15.rb
UTF-8
810
4.4375
4
[]
no_license
#takes teh rguments we pass (file name) and assigns them to the filename string value filename = ARGV.first #creates a string value with >> in it prompt = ">>" #defines the txt object with the file open command, and uses the filename argument from the first run as the parameters txt = File.open(filename) #puts the li...
true
c1e774903900bc9492d140c410e5c2d8790c9831
Ruby
genehsu/wildmat
/spec/wildmat_spec.rb
UTF-8
3,995
2.875
3
[ "MIT" ]
permissive
require "spec_helper" require "wildmat" describe Wildmat do context 'word characters' do bad_string = "foo bar baz" %w[ asdf _ 123 a1 foo_bar_baz _under after_ ].each do |input| it "should not change word characters: #{input}" do Wildmat.regexp_pat...
true
8568de9555f7c347494d81f977be58992776a2f0
Ruby
Carmer/bike-share-1
/spec/models/station_spec.rb
UTF-8
3,589
2.859375
3
[]
no_license
require_relative '../spec_helper' RSpec.describe Station do describe 'validations' do it 'validates presence of name' do station = Station.create( city: City.create(name: "New Victoria"), dock_count: 1, installation_date: 1 ) expect(station).to_not be_valid end ...
true
2a797a7225338f1b405099739c89cb5c5e08e46a
Ruby
blakeshall/CfA-Dashboard
/post.rb
UTF-8
1,484
2.515625
3
[]
no_license
require 'net/http' require 'time' require 'rubygems' require 'json' @host = 'localhost' @port = '4567' @post_ws = "/commit" @payload ={ :before => "before", :after => "after", :ref => "ref", :commits => [{ :id => "commit.id", :message => "I fixed something", :timestamp...
true
c30a3aa8ac5d194b24f6421997a8f99087997181
Ruby
elishevaelbaz/activerecord-validations-lab-nyc04-seng-ft-041920
/app/models/post.rb
UTF-8
509
2.84375
3
[]
no_license
class Post < ActiveRecord::Base validates :title, presence: true validates :content, length: {minimum: 250} validates :summary, length: {maximum: 250} validates :category, inclusion: { in: %w(Fiction Non-Fiction)} validate :non_clickbait def non_clickbait clickbait_arr = [ /Won't Believ...
true
184eab30ac00be7c07d2498cdd299009c2022dd6
Ruby
jdollete/phase-0-tracks
/databases/module_8.5/workout_app.rb
UTF-8
5,399
3.390625
3
[]
no_license
# An app to record your swole-ness # Insert New Rows # Input: String # Step: # - Ask user to input workout, weight, and reps Value # - Input values into Database # - Until user inputs they are done, loop through the Method # Output: Updated Database # Update Rows # Input: String # Step: # - Ask User what they...
true
680df1b004e1d9406b5589b9fa01321fabfbf54b
Ruby
samchen2009/dep_tree
/dep_tree.rb
UTF-8
3,080
3.0625
3
[]
no_license
# ========================================= # Script to pass the C header dependancy. # # Author: shanchen@marvell.com # Revision: # 0.1. 2012-09-04 # ========================================== class Node attr_accessor :name,:parent,:childs,:is_leaf def initialize(name,parent=nil,is_leaf=false) ...
true
c9ee10c1dbac6818338598b556f1d2edbe0fa90f
Ruby
mabuelkhair/simple-filter
/db/seeds.rb
UTF-8
1,373
2.546875
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
911ea3cfd8f502a4e6b4747224d4b70ee40f0ba7
Ruby
milikkan/intro-to-programming-with-ruby
/ch09-exercises/ex10.rb
UTF-8
168
3.578125
4
[]
no_license
# Can hash values be arrays? h = {a: [1, 2], b: [3, 4, 5]} p h # Can you have an array of hashes? (give examples) arr = [{a: 1, b: 2}, {name: "bob", age: 24}] p arr
true
b2c64aab0cedd0553ca4dd171841fef8bbfc7970
Ruby
Tman22/new_enigma
/message.rb
UTF-8
453
3.28125
3
[]
no_license
require 'pry' class Message attr_reader :message Con = (' '..'z').to_a def initialize(message) @message = message end def split @message = @message.chars end def assign_to_constant message = split message_index = message.map do |letter| Con.index(letter) end message_index ...
true
7a4aea8111d9a42c211d599874bdc108cd68aae5
Ruby
msilen/rbets
/lib/gamebookers.rb
UTF-8
4,654
2.71875
3
[]
no_license
require 'rubygems' require 'celerity' require 'gamebookers_helper' require 'ruby-debug' Debugger.start Celerity.index_offset = 0 #настройка Celerity для индексов с 0 class Gamebookers < Celerity::Browser include GamebookersHelper def run establish_connection get_links_of_sports iterate_through_valid_...
true
92b338c755e2983baa796c5d1f1c395900b15a13
Ruby
GabbySang/battleattackgame
/spec/player_spec.rb
UTF-8
437
2.625
3
[]
no_license
# frozen_string_literal: true require 'player' describe Player do subject { described_class.new('Gabby') } describe '#name' do it 'returns the player\'s name' do expect(subject.name).to eq('Gabby') end end describe '#receive_damage' do it 'reduces a players hp' do expect(subject.hp)....
true
3478ef545acdaffae9eceac4cb6f414c59f8d0b4
Ruby
Bohurtadop/CodumAcademy
/Kata04/Kata04.rb
UTF-8
1,634
3.8125
4
[]
no_license
## PARTE 3: DRY FUSION def calculateDiference(array) thingWithLessDiference = "" lessDiference = 100 for i in array if i[1] < lessDiference lessDiference = i[1] thingWithLessDiference = i[0] end end thingWithLessDiference end ## LEYENDO WEATHER.dat columnNames = 0 tempD...
true
6293656318bd8d914c9ebe568166b7b577f06950
Ruby
aaj3f/liquery-cli
/lib/LiquerY/drink.rb
UTF-8
5,516
3.1875
3
[ "MIT" ]
permissive
class Drink attr_accessor :idDrink, :strDrink, :all_ingredients, :strIngredient1, :strIngredient2, :strIngredient3, :strIngredient4, :strIngredient5, :strIngredient6, :strIngredient7, :strIngredient8, :strIngredient9, :strMeasure1, :strMeasure2, :strMeasure3, :strMeasure4, :strMeasure5, :strMeasure6, :strMeasure7, :s...
true
90fbbb88bb26bf7288c401036e26d8a60bb4cced
Ruby
philmccarthy/backend_mod_1_prework
/day_1/lesson_one/ex11.rb
UTF-8
385
4.28125
4
[]
no_license
print "How old are you? " age = gets.chomp print "How tall are you? " height = gets.chomp print "What unit of measure was that? " height_unit = gets.chomp print "How much do you weigh? " weight = gets.chomp print "What unit of measure was that? " weight_unit = gets.chomp puts "So, you're #{age} years old, #{height + "...
true
499aba0483aeb780ac4b5d8a990fd47ccfd6d933
Ruby
1i1it/tea-BE
/bl/teas.rb
UTF-8
1,348
2.59375
3
[]
no_license
CATEGORIES = ["Green", "Red", "White", "Black"] TEAS = ["Lotus", "Fruit", "Roibus", "Lemon"] IMAGES = ["http://f.tqn.com/y/britishfood/1/0/f/0/-/-/tealeaves.jpg", "https://auntpattysporch.files.wordpress.com/2015/09/loose-leaf-tea.jpg", "http://pad1.whstatic.com/images/thumb/f/f7/Store-Loose-Leaf-Tea-Step-1.jpg/aid845...
true
407ded902a44b1f44a6f504225a7504288a773af
Ruby
hswick/protosemiotics
/network.rb
UTF-8
2,361
3
3
[]
no_license
require './node' #Gene [act_id, out_id, init_value1, init_value2] #Id_range is the max number of genes in a chromosome (genome) class Network def initialize(num_nodes=0, id_range = 100, num_act_fns=5) @nodes = {} for i in 0..num_nodes-1 @nodes[i] = Node.new(i, rand(num_act_fns), rand(id_range), rand_weight, ra...
true
60d070122120fdff581d787857ab00730881137c
Ruby
homeflow/homeflow_api
/lib/homeflow/api/request.rb
UTF-8
4,036
2.578125
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
module Homeflow module API YAML::ENGINE.yamler= 'syck' if defined?(YAML::ENGINE) class Request include HTTParty attr_accessor :resource_class, :request_specification def initialize(request_specification) @request_specification = request_specification end def perform begin ...
true
1f3af3cacffd8a0348c7bf5b0a68fdb82600489f
Ruby
Tkam13/atcoder-problems
/abc154/c.rb
UTF-8
108
2.703125
3
[]
no_license
n = gets.to_i as = gets.chomp.split.map(&:to_i) if as.size == as.uniq.size puts "YES" else puts "NO" end
true
7f90a3a1828c67b9a3e51d29e6eb5260c18976b8
Ruby
adamluzsi/mpatch
/examples/hash.rb
UTF-8
376
2.859375
3
[]
no_license
require "mpatch" x = {} (1..10000).each do |i| x["key#{i}"] = i end t=Time.now x.map_hash{ |k,v| { k.to_sym => v.to_s } } puts Time.now - t var= {hello: "world",no: "yes"} puts var var= [[:hello, "world"],[:no, "yes"]].map_hash{|k,v| {k => v} } puts var.inspect # require 'debugger' # debugger var = { hello: "...
true
53a4b9e46928a32cd572a520f66b6f16e65322f2
Ruby
brittkistner/codewars
/day2/day2.rb
UTF-8
2,157
4.46875
4
[]
no_license
# Finish the solution so that it sorts the passed in array of numbers. If the function passes in an empty array or null/nil value then it should return an empty array. def solution(nums) if nums.class != Array || nums.length ==0 return [] end nums.sort end # Santa's senior gift organizer Elf developed a way...
true
74ce87510e8533adaf264b7b1a5ca6dbb7e5428d
Ruby
kaiogoncarvalho/ruby-codesaga
/2 - Primeiros passos com Ruby/2 - Trabalhando com coleções/4 - Salvar e carregar arquivos/Desafio/task_list.rb
UTF-8
2,785
3.671875
4
[]
no_license
def menu() puts "Bem-vindo ao Task List! Escolha uma opção no menu: \n" puts '[1] Inserir uma tarefa' puts '[2] Ver todas as tarefas' puts '[3] Buscar tarefa' puts '[4] Marcar tarefa como finalizada' puts '[5] Sair' puts print 'Opção escolhida: ' gets.to_i end def show(tarefas) tarefas.each_w...
true
31e4faef6599b1c37c4d9d2fa84d0af67b44fe8a
Ruby
ares/vzory
/pruby/e06/transmitters.rb
UTF-8
390
2.90625
3
[]
no_license
class StandardTransmitter def puts(str) Kernel.puts str end end class DebugTransmitter def puts(str) Kernel.puts "size: #{str.size}" Kernel.puts "message: #{str.inspect}" end end class FileTransmitter def initialize(f) @file = f end def puts(str) @file.puts str rescue => e Ker...
true
c1667c7ef5b9dbda5dc0c48eb1a06ed0b00771c6
Ruby
thelazycamel/tinia
/lib/tinia/query_builder.rb
UTF-8
2,115
2.8125
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
module Tinia class QueryBuilder def initialize(klass, query, opts) @klass = klass @query = query @opts = opts end def build AWSCloudSearch::SearchRequest.new.tap do |req| bq_terms = ["type:'#{@klass.name}'"] if @query.present? if @query =~ /[:\)\(]/...
true
f60377c4817ee4206edebff51db3825fb43fff9e
Ruby
pedronotpaydro/params_game_app
/app/controllers/api/params_controller.rb
UTF-8
691
2.546875
3
[]
no_license
class Api::ParamsController < ApplicationController def name_action input_value = params["your_name"].upcase @output_value = "Your name is #{input_value}" render "name.json.jb" end def number_guess_action winning_number = 33 input_value = params["guess"].to_i @question = "Guess the numbe...
true
e4a42260253fedc91e39d7745f1baef12ee45484
Ruby
devvmh-forks/sandi_meter
/lib/sandi_meter/calculator.rb
UTF-8
5,221
2.984375
3
[ "MIT" ]
permissive
module SandiMeter class Calculator def initialize @data = {classes: [], methods: {}, method_calls: []} @output = {} end def push(data) data.each_pair do |key, value| if value.kind_of?(Array) @data[key] ||= [] @data[key] += value elsif value.kind_of?(H...
true
b1e95b0ccccba9576d76774186028f48130c18fa
Ruby
steve-goldman/wespeak-rails
/test/helpers/statement_states_test.rb
UTF-8
973
2.609375
3
[]
no_license
require 'test_helper' class StatementStatesTest < ActiveSupport::TestCase test "[] works" do assert_equal 1, StatementStates[:alive] assert_equal 2, StatementStates[:dead] assert_equal 3, StatementStates[:voting] assert_equal 4, StatementStates[:accepted] assert_equal 5, StatementStates[:rejecte...
true
8492cd9b4bd6b9aa4bf8f38c38f5379e5d1a3a67
Ruby
joe-hamilton/RB_101
/codewars_ls/7.rb
UTF-8
567
4.0625
4
[]
no_license
# Substring Fun =begin problem: Complete the function that takes an array of words. You must concatenate the nth letter from each word to construct a new word which should be returned as a string, where n is the position of the word in the list. =end def nth_char(arr) arr.map.with_index { |word, idx| word[idx] }...
true
ba724f672cb3efbb9a7f63e2bb0a62952ebb20bc
Ruby
terminalobject/battle
/spec/features/attack_spec.rb
UTF-8
894
2.84375
3
[]
no_license
#spec/features/attack_spec.rb feature 'attack' do scenario 'attack Player 2 and get a confirmation' do sign_in_and_play click_button('Attack') expect(page).to have_content('attacked') end end feature 'decrease hp' do scenario 'hp reduced by 10' do sign_in_and_play click_button('Attack') ...
true
9c4a820092793b741cf9495736e2dde1840717d0
Ruby
Gonozal/World-Gen
/polygon_math.rb
UTF-8
7,439
3
3
[]
no_license
module WorldGen class Polygon # Bounding Box: [Vector[tl_x, tl_y], Vector[br_x, br_y]]: minimum bounding rect # Vertices: [Vector[x1, y1], Vector[x2, y2], ... , Vector[xn, yn]]: defining points attr_accessor :vertices, :bounding_box, :game_map, :opacity, :parent def initialize(params) params.ea...
true
e5777d1dfa5a2fe6de879f728803b6e66904de6b
Ruby
marcosfparreiras/ruby-rack-api
/spec/handlers/token_spec.rb
UTF-8
5,037
2.5625
3
[]
no_license
require_relative '../../src/handlers/token' describe 'Token' do let(:token_id) { 'mytokenid' } let(:user_cpf) { 12341234 } let(:account_number) { 333 } let(:account) do double('account', number: account_number, current_balance: 100 ) end let(:user) do double('user', cpf: use...
true
a55b5bd7b24960b37000e32bd402e846c49fc10f
Ruby
serendipidoussophia/kwk-l1-ruby-2-meal-choice-lab-kwk-students-l1-min-072318
/meal_choice.rb
UTF-8
435
3.8125
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def snacks(food="Cheetos") "Any time, is the right time for #{food}!" end def breakfast(food="frosted flakes") "Morning is the best time for #{food}!" end def lunch(food="grilled cheese") "Noon is the best time for #{food}!" end def dinner(food="salmon") "Evening is the best time for #{food}!" end puts b...
true
d96dcc2ca01fe545661853e27ca925d49c05b287
Ruby
jorgemtoledo/scriptsRuby
/ruby_studies/one/ruby_avancado_2/self.rb
UTF-8
1,193
4.46875
4
[]
no_license
# Self # No ruby, self é uma variável especial que aponta para o objeto atual. # 1- Crie o arquivo self.rb com o seguinte código # Exemplo 1: # class Foo # def bar # puts self # end # end # foo = Foo.new # puts foo # foo.bar # A variável self aponta para o Objeto onde ela se encontra. # No caso está...
true
78ad1c010f7ee42fb4e00093f89e35295db8b0fb
Ruby
jacobswartzentruber/project_euler
/problem_18.rb
UTF-8
1,555
4.40625
4
[]
no_license
#By starting at the top of the triangle below and moving to adjacent numbers on the row below, the maximum total from top to bottom is 23. #3 #7 4 #2 4 6 #8 5 9 3 #That is, 3 + 7 + 4 + 9 = 23. #Find the maximum total from top to bottom of the triangle below: def max_sum_triangle number = "75 95 64 17 47 82...
true
3342021438ebe9fd11e7849d672c7b6551b3f745
Ruby
T-monius/ruby_small_problems
/easy_2/tip_calculator.rb
UTF-8
833
4.4375
4
[]
no_license
# tip_calculator.rb # Create a simple tip calculator. The program should prompt for a # bill amount and a tip rate. The program must compute the tip and # then display both the tip and the total amount of the bill. # Understanding: # Inputs 2 strings # Output 2 Strings with interpolated floats # Validate Numbers? #...
true
d7eb36dd9174c4b1ad99beb036fc7b5006f53828
Ruby
manveru/tick
/lib/tick/bin/list.rb
UTF-8
1,737
2.890625
3
[]
no_license
module Tick::Bin::List DESCRIPTION = 'List available tickets by custom criteria' USAGE = <<-DOC tick list displays available tickets and provides filtering and sorting SYNOPSIS tick list [OPTIONS] [Search terms] DOC module_function def parser(bin, opt) bin.on('-a', '--all', 'Show all ticke...
true
c071b2ec9e44059ce30ce33462258805ebdc8fee
Ruby
archangel519/Burndown
/models/task.rb
UTF-8
656
2.875
3
[]
no_license
require 'active_record' class Task < ActiveRecord::Base belongs_to :story validates_uniqueness_of :id, :scope => :story_id validates_uniqueness_of :title, :scope => :story_id validates_presence_of :story_id, :title, :hours, :status after_initialize :init def hours=(value) value = value.to_f i...
true
42c49a39aaa613cc911de0a583394583681baa90
Ruby
TheRoster/thecollegeroster
/app/lib/importer.rb
UTF-8
546
2.734375
3
[]
no_license
require 'csv' class Importer def self.execute high_school_file_path = "#{Rails.root}/lib/data/high_school.csv" sport_file_path = "#{Rails.root}/lib/data/sports.csv" # position_file_path = "#{Rails.root}/lib/data/positions.csv" importer = Importer.new message "Importing high schools..." Hig...
true
c97524bbc870efa4cd5101ebea15febecf2c4bba
Ruby
silatham99/bash-git-branch
/bash_git_branch.rb
UTF-8
949
2.90625
3
[]
no_license
#!/usr/bin/ruby # bash_git_branch.rb - Script to show the current git branch in the bash PS1 # Rewritten in Ruby by Scott I. Latham (silatham99) # v1.0.3 - 04/18/2014 BLACK = '\[\033[0;38m\]' GREEN = '\[\033[0;32m\]' RED = '\[\033[0;31m\]' YELLOW = '\[\033[0;33m\]' DEFAULT_PS1 = "#{YELLOW}"'\w '"#{BLACK}: " def get_...
true
48051563eaa0cc590047af31f7424191800f6823
Ruby
Nova840/phase-0
/week-4/variables-methods.rb
UTF-8
1,162
4
4
[ "MIT" ]
permissive
puts "What is your first name?" first_name = gets.chomp puts "What is your middle name?" middle_name = gets.chomp puts "What is your last name?" last_name = gets.chomp puts "Hello #{first_name} #{middle_name} #{last_name}.\n\n" puts "What is your favorite number?" favorite_number = gets.chomp puts "The number #{favori...
true
9408f6260870da32b2f08aa42764d5dfbc895cc5
Ruby
cnyuanh/tutorials
/analysis_of_introgression_with_chromosome_length_alignments/src/get_age_reduction.rb
UTF-8
2,900
3.109375
3
[]
no_license
# m_matschiner Tue May 29 21:35:40 CEST 2018 # Get the command-line argument. inmatrix_file_name = ARGV[0] outmatrix_file_name = ARGV[1] unless ARGV[2] == nil exclude_ids = ARGV[2].split(",") end # Read the input matrix. inmatrix_file = File.open(inmatrix_file_name) inmatrix_lines = inmatrix_file.readlines inmatrix_...
true
c436400a7ed8d10124f5b930db9b68912b36710c
Ruby
chasenyc/prime_multiplication_tables
/spec/lib/prime_spec.rb
UTF-8
602
3.484375
3
[]
no_license
require_relative '../../lib/prime' describe Prime do it "first(amount) returns first n prime numbers in an array" do expect(Prime.first(2)).to be_a_kind_of(Array) expect(Prime.first(2)).to eq [2, 3] expect(Prime.first(8)).to eq [2, 3, 5, 7, 11, 13, 17, 19] expect(Prime.first(-1)).to eq [] end i...
true
652e88e6a37f19aecda8fd30b4d83dd96eec8aea
Ruby
janenyasoro/begin_ruby
/nested_classes.rb
UTF-8
247
3.03125
3
[]
no_license
class Drawing def self.give_me_a_circle Circle.new end class Line end class Circle def what_am_i "This is a circle" end end end a = Drawing.give_me_a_circle puts a.what_am_i a = Drawing::Circle.new puts a.what_am_i a = Circle.new puts a.what_am_i
true
be92dc406c06c0d94007a34878c9a9a0e6a27dbe
Ruby
Achury/rei
/integrador/app/models/api/authentication.rb
UTF-8
400
2.515625
3
[]
no_license
class Api::Authentication < Api::Base def self.valid_password?(username, password) return false if username.blank? or password.blank? request = get("/ulises/schedule", :query => { :username => username, :password => password }) puts request return request.parsed_response.is_a?(Array) # If it's valid,...
true
1c9b945f3894abbe764e4aa7d965734488965d92
Ruby
duckyrettes/learn_ruby
/03_simon_says/simon_says.rb
UTF-8
672
3.9375
4
[]
no_license
def echo(phrase) return phrase end def shout(phrase) return phrase.upcase end def repeat(phrase, num=2) str = "" result = while num > 0 do str += phrase + " " num -= 1 end str.strip! return str end def start_of_word(word, num=1) return word[0..num-1] end def first_word(phrase) return phra...
true
fb204e60ea8a6d3ae8a5544c180ec032e267a4f4
Ruby
braegel/AmateurfunkPruefungsfragen
/extractor.rb
UTF-8
510
2.90625
3
[]
no_license
#!/usr/bin/ruby filename="TechnischeKenntnisseA.txt" data = File.read(filename) while data =~ /\n/ data = data.gsub(/\n/,"") end qna_pattern = Regexp.new("([A-Z]{2}[0-9]{3,4}.+?)(A .+?)B ",Regexp::MULTILINE) file_out = File.open("#{filename}.tab.txt", 'w') counter = 0 while data =~ qna_pattern counter += 1...
true
acfdd4483b20b4b48779f41379caf1f39ae3e090
Ruby
SandUniHH/PBI-Blatt04
/Aufgabe4.3/stack-skeleton.rb
UTF-8
1,258
3.71875
4
[]
no_license
#!/usr/bin/ruby # # Dieses ist unsere Ruby - Implementierung für einen Stack # Zum Glück sind viele Stack-Funktionalitäten schon mit in die Ruby-Array Klasse # eingebaut. Daher ist es nicht viel Arbeit, diese Implementierung zu # vervollständigen. class Stack # initialize() initalisiert ein Objekt einer Klasse und w...
true
7893e332120e53e334b6b5bb424fd3f307109874
Ruby
kylelaughlin/w02-d01-classes
/lib/guitar_player.rb
UTF-8
615
3.1875
3
[]
no_license
require 'pry' require_relative 'guitar.rb' class GuitarPlayer attr_accessor :name, :age, :sweet_riffs_played def initialize(name:, age:) @name = name @age = age @sweet_riffs_played = 0 @guitar = nil end def guitar @guitar end def guitar=(guitar) @guitar = guitar end def pic...
true
fbd9ddc172da3d0575d078719ef8f38eef920694
Ruby
junwen29/amazingcoders-rails
/app/services/wish_service.rb
UTF-8
2,318
2.734375
3
[]
no_license
class WishService module ClassMethods def wish(venue_id, user_id) unless Venue.exists?(venue_id) raise ActiveRecord::RecordNotFound end wish = Wish.where(venue_id:venue_id, user_id: user_id).first if wish ## if you have already done wish, you can't. return wish end...
true
dc531b30cb238bfad1f0db7f87eb3b598bd29145
Ruby
patricia13/blog
/blog/app/models/article.rb
UTF-8
251
2.53125
3
[]
no_license
association to achieve this. Modify the Article model, app/models/article.rb, as follows: class Article < ActiveRecord::Base has_many :comments, dependent: :destroy validates :title, presence: true, length: { minimum: 5 } end
true
970490b4d43976e0b53bd7752961dfa93c48db11
Ruby
whimet/RobotSimulator
/lib/robot_simulator/table.rb
UTF-8
255
3.203125
3
[]
no_license
class Table def initialize(width, height) raise 'invalid width' if width <= 0 raise 'invalid height' if height <= 0 @width = width @height = height end def contains(coordinate) coordinate.within(0, 0, @width, @height) end end
true
40767515b92680247eaf142bf27421c4a81ddca2
Ruby
hemashree/data_structure
/compute_sum.rb
UTF-8
154
3.578125
4
[]
no_license
class A def sum(n) result = 0 i = 1 while( i <= n) result += i i += 1 end return result end end a = A.new p a.sum(10)
true
92223db2594e52bb8cde56f531b47c3084c671f3
Ruby
sameerank/Ruby-exercises
/poker/rspec_demo/bobs_bad_code/tree_written_october_2015.rb
UTF-8
140
2.546875
3
[]
no_license
# The person who wrote this file doesn't know that tree_written_august_2013.rb exists class Tree def grow "getting WIDER" end end
true
1ce55a80cc848e01d3bf87a62a918b108d416f1e
Ruby
mray6288/the-bachelor-todo-prework
/lib/bachelor.rb
UTF-8
1,353
3.5625
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
def get_first_name_of_season_winner(data, season) winner = '' data[season].each do |contestant| if contestant['status'] == 'Winner' winner = contestant['name'].split[0] break end end winner end def get_contestant_name(data, occupation) name = '' data.each...
true
bb37f5ccb19c47f15ae82cd3254a13c0692cf7ac
Ruby
GrayMyers/the-last-airbender
/app/poros/character.rb
UTF-8
290
2.796875
3
[]
no_license
class Character attr_reader :affiliation, :enemies, :allies, :name, :image_url def initialize(data) @name = data[:name] @image_url = data[:photoUrl] ? data[:photoUrl] : "" @affiliation = data[:affiliation] @enemies = data[:enemies] @allies = data[:allies] end end
true
5e7dc7be71cd1873a8e4d6b34428a0a41b895e5e
Ruby
SimonBo/ruby
/caesar.rb
UTF-8
1,398
3.765625
4
[]
no_license
def caesar_cipher(message, shift) letter_hash={} letter_hash_capital={} final_string="" nr=1 ('a'..'z').to_a.each do |letter| letter_hash[letter]= nr nr+=1 end nr_for_capital=1 ('A'..'Z').to_a.each do |letter| letter_hash_capital[letter]= nr_for_capital nr_for_capital+=1 end mess...
true
9d51cbb8739e83031f81c4fd21d4fae68d6aa31e
Ruby
marcelomanhabosco/SentimentalAnalysis
/db/seeds.rb
UTF-8
6,969
2.53125
3
[]
no_license
# encoding: UTF-8 caminho = "#{Rails.root}/db/seed_data/" # StopWords File.open(caminho + 'stopwords.txt').each_with_index do |linha, index| puts "Importando StopWords #{index} - #{linha}" StopWord.create!(:stop_word => linha.chomp) end # Dicionário Internetês File.open(caminho + 'internetslangwords.txt').each_w...
true
2c08cc14ae81b3c8f8dfeee8c48fd7cd5f3cae6e
Ruby
plagelao/PlageServer
/server/application.rb
UTF-8
1,071
2.953125
3
[]
no_license
class ApplicationFactory APPLICATIONS = {:tutorial => "<html><head></head>\n<body>\n<h3>\nWelcome to the tutorial\n</h3>\n<p>To add a web page put it in the same directory where the server is running</p></body></html>"} def create(application_name) return RootApplication.new if application_name == '/' app...
true
4b9840609c090132b8c27a710fcad7d2cc9ba250
Ruby
asim/logslam
/lib/logslam/auth.rb
UTF-8
757
2.703125
3
[ "MIT" ]
permissive
require 'net/http' require 'digest/sha1' require 'base64' module AUTH def self.authenticated?(username, password) url = URI.parse('http://example.com/some_auth_url') http = Net::HTTP.new(url.host, url.port) request = Net::HTTP::Post.new(url.path) request.set_form_data({ 'username' => username, ...
true
2d4381a690c3439f140af659763f28e5ceae9111
Ruby
merwan/Pongosu.old
/lib/pongosu/ball.rb
UTF-8
468
3.21875
3
[]
no_license
class Ball attr_accessor :x, :y, :height def initialize(window) @height = 5 @image = Gosu::Image.new(window, "images/ball.png", true) @x = 100.0 @y = 100.0 @vel_x = -2 @vel_y = -2 end def draw @image.draw(@x, @y, 1) end def move ...
true
850fc747ad5a95a8e1fd5441d46d698d959483ee
Ruby
safiire/cryptopals
/lib/cryptopals/cyclic_xor.rb
UTF-8
971
3
3
[]
no_license
# frozen_string_literal: true module Cryptopals class CyclicXor Result = Struct.new(:plaintext, :key) def self.crack(ciphertext, max_keysize: 40) new.crack(ciphertext, max_keysize) end def crack(ciphertext, max_keysize) key_size = CyclicXorKeysize.call(ciphertext, max_keysize: max_keysi...
true
246fb9bbd71f2218e0f84adc9825d61826868d45
Ruby
kailanak1/ruby-oo-complex-objects-school-domain-seattle-web-012720
/lib/school.rb
UTF-8
846
3.921875
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
# code here! require 'pry' class School attr_accessor = :roster, :name def initialize(name) @name = name @roster = {} end def name @name end def roster @roster end def add_student(name, grade) #if the grade exists, add stud...
true
a4a7e09d95a159d2f7b34307d4acfdf850623770
Ruby
cklim83/launch_school
/02_rb101_rb109_small_problems/04_easy_4/10_signed_number_to_string.rb
UTF-8
2,379
4.53125
5
[]
no_license
=begin Convert a Signed Number to a String! In the previous exercise, you developed a method that converts non-negative numbers to strings. In this exercise, you're going to extend that method by adding the ability to represent negative numbers as well. Write a method that takes an integer, and converts it to a stri...
true
69201db0f16db4eac47cea2f025ad3351c3ff37b
Ruby
UweKrause/haw-pm1-a4
/person_comparable.rb
UTF-8
2,745
3.984375
4
[]
no_license
require 'set' #beschreibt eine Klasse Person, die Briefe von anderen Personen erhalten kann und Briefe an andere Personen senden #inkludiert Comparable #Das Inkludieren des Moduls 'Comparable' ist insofern sinnvoll, da dieses weitere Vergleichsoperatoren, #wie z.B: <,>,= auf Basis des Spaceship_Operators definie...
true
d0281b4a94d5e7b9db87f6a8280a640d887f16f9
Ruby
sectrimte/wuxia
/envoi_mail.rb
UTF-8
798
2.65625
3
[]
no_license
require 'gmail' class MailAttached def initialize( subject, filename, msg="envoye par ruby") puts 'creating mailAttached' @subject = subject @msg = msg @filename = filename @gmail = Gmail.connect('sectrimte', 'password') end def sendMail(dest_mail) filename = @filename subject = @s...
true
da903faee1b136fea5f2fc4a604b1bc47db00186
Ruby
jeanetterosario88/ruby-puppy-onl01-seng-pt-032320
/lib/dog.rb
UTF-8
264
3.640625
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class Dog attr_reader :name @@all = [] def initialize (name) @name = name save end def save @@all << self end def self.all @@all end def self.print_all self.all.each do |dog| puts dog.name end end def self.clear_all @@all.clear end end
true
0bbd22925541822138ad7305cc2296b8cf9d35aa
Ruby
kage1029/atcoder
/atcoder154C.rb
UTF-8
127
3.15625
3
[]
no_license
n = gets.chomp.to_i array = gets.split(" ").map(&:to_i) if array.size == array.uniq.size puts "YES" else puts "NO" end
true
402ad18104568f9eb59c6d8dbb503f774e78d2d4
Ruby
michaeltanner/vhdl_parser
/lib/vhdl_parse_ret.rb
UTF-8
1,551
2.765625
3
[]
no_license
require "vhdl_parser" filename = ARGV[0] entity = VHDL_Parser.parse_file(filename) #TODO: Handle generics #TODO: parse command-line arguments in a real way (e.g., -h, -o asdf.as, etc.) output_type = ARGV[1] case output_type when "signals" entity.ports.each_with_index do |port, index| print "signal s_" + p...
true
645fbf30442df98a6cf22630350bedcc7bf0fb15
Ruby
emersonp/epicodus
/ruby/oo/todo/lib/task.rb
UTF-8
478
3.296875
3
[ "MIT" ]
permissive
class Task def initialize(description) @description = description @complete = false @priority = 3 end def description @description end def complete? @complete end def complete_toggle if @complete @complete = false else ...
true
14c3debe4c40b410c8bbb37992e93df5fbfa1e97
Ruby
runpaint/numb
/lib/numb/størmer.rb
UTF-8
108
2.65625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
# coding: utf-8 class Integer def størmer? ((self ** 2) + 1).prime_factors.max >= 2 * self end end
true
c2c4a35a226e9f9984f92e8a23352101570cdcf9
Ruby
zigvu/chia
/ruby/classes/PatchTracker.rb
UTF-8
4,790
2.703125
3
[]
no_license
require 'json' require 'fileutils' class PatchTracker attr_reader :allPatches def initialize(configReader, patchFolder, annotationFolder) @patchFolder = patchFolder @annotationFolder = annotationFolder @vt_caffeBatchSize = configReader.vt_caffeBatchSize # key: frameNumber, value: JSON from file @allPatc...
true
dc3ac267deb2774eef4311b28be8f05474f9a6aa
Ruby
drod1000/job-tracker
/spec/models/company_spec.rb
UTF-8
1,605
2.515625
3
[]
no_license
require 'rails_helper' describe Company do describe "validations" do context "invalid attributes" do it "is invalid without a name" do company = Company.new() expect(company).to be_invalid end it "has a unique name" do Company.create(name: "Dropbox") company = C...
true
0207f630d88c80e2d01b5372305d7a4d316a7dcb
Ruby
DFE-Digital/apply-for-teacher-training
/app/components/provider_interface/user_personal_details_component.rb
UTF-8
698
2.53125
3
[ "MIT", "LicenseRef-scancode-proprietary-license" ]
permissive
module ProviderInterface class UserPersonalDetailsComponent < SummaryListComponent def initialize(user:, change_path: nil) @user = user @change_path = change_path end def rows %i[first_name last_name email_address].map do |field| row_for_field(field) end end private...
true
e01303bf9bd3eb68fd6d6bb9bcde427e1834dab3
Ruby
DevLuDaley/ruby_cli_gem_project
/lib/RubyCliGemProject/player.rb
UTF-8
2,152
2.859375
3
[ "MIT" ]
permissive
class RubyCliGemProject::Player #https://stackoverflow.com/questions/3772864/how-do-i-remove-leading-whitespace-chars-from-ruby-heredoc attr_accessor :name, :number, :position, :player_height, :player_age, :player_weight, :player_college, :player_salary, :p...
true
164460d66966bc25c1058fb10b5b1cdf23e1bf0c
Ruby
metermaid/algorithms
/heaps/kth_largest.rb
UTF-8
519
4.375
4
[]
no_license
# Finding the kth largest element using a min-heap # We start counting at one right hahahaha def kth_largest(arr, k) return nil if k > arr.length heaped, remaining = arr[0..k-1], arr[k..-1] heap = Heap.new(heaped) remaining.each do |n| if n > heap.top heap.pop! heap.push(n) en...
true
e6501d579c67bfa4c8129faf1f0cd15129fc9bb9
Ruby
leanlabs/fitgem_oauth2
/lib/fitgem_oauth2/body_measurements.rb
UTF-8
2,150
2.578125
3
[]
no_license
module FitgemOauth2 class Client fat_periods = %w("1d" "7d" "1w" "1m") weight_periods = %("1d" "7d" "30d" "1w" "1m") body_goals = %("fat" "weight") # ====================================== # Boday Fat API # ====================================== def fat_on_date(date) get_call("...
true
62569034760925d0375239af18e0a5c0b7b755b3
Ruby
RedTeamCOSC470/Stargazer
/test/unit/schedule_test.rb
UTF-8
4,006
2.8125
3
[]
no_license
# == Schema Information # # Table name: schedules # # id :integer(38) not null, primary key # start_time :datetime # exposure :integer(38) # number_of_pictures :integer(38) # created_at :datetime # updated_at :datetime # user_id :integer(38) # are...
true
1ff5f0df3ea3663e286d0509d4b8d347064e6a06
Ruby
ryan-brock/CoffeeAndCode
/puzzlers/kata02/ntbrock/karate_chop.rb
UTF-8
2,753
3.34375
3
[]
no_license
#!/usr/bin/env ruby # http://codekata.com/kata/kata02-karate-chop/ # https://test-unit.github.io/ require "rubygems" gem "test-unit" require "test/unit" require "test/unit/ui/console/testrunner" # POSH - Plain Old Semantic HTML def chop(needle, haystackRaw) chop_recurse(needle, haystackRaw.sort, 0, haystackRaw.leng...
true
1aadf9772c886d527b10e8353a1cdc46a642f3b5
Ruby
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/ruby/etl/769b60286fd14090bed0224958dc6f3c.rb
UTF-8
232
2.796875
3
[]
no_license
class ETL class << self def transform(scores) scores.each_with_object({}) do |(key,value), split_scores| value.each do |word| split_scores[word.downcase] = key end end end end end
true
6f8280a2a709eb8d01c8c47e8873e821930dd672
Ruby
jaharaclark/railsy-engine
/spec/requests/api/v1/merchants_request_spec.rb
UTF-8
3,252
2.65625
3
[]
no_license
require 'rails_helper' RSpec.describe 'Merchants API' do before :each do @merchant = create(:merchant) @item_1 = create(:item, merchant: @merchant) @item_2 = create(:item, merchant: @merchant) end #Get All Merchants it 'happy: gets all merchants, a maximum of 20 at a time' do create_list(:...
true
d64eb477a1803470567587c2e5109ac0b8f0caf1
Ruby
CarlosMontilla/codeeval
/easy/theMajorElement/theMajorElement
UTF-8
555
3.5625
4
[]
no_license
#!/usr/bin/ruby # It finds the major element that repeats more than a half of the list # It does not work with list with negative numbers def solveProblem lst big = -1 numbers = {} half = lst.length / 2 lst.each do |i| if numbers.has_key?(i) then numbers[i] += 1 else numbers[i] = 1 end ...
true
362601af620cafa84c54784696f2c74a38f499ed
Ruby
venkatev/chronus_app
/app/models/user.rb
UTF-8
1,277
2.71875
3
[]
no_license
require 'digest/sha1' class User < ActiveRecord::Base include Authentication include Authentication::ByPassword include Authentication::ByCookieToken #----------------------------------------------------------------------------- # ATTRIBUTES AND RELATIONSHIPS #---------------------------------------------...
true
8dc8f9695aa1c3f69d4e9fe539b79ad143923468
Ruby
jonmorehouse/pmd
/lib/pmd/pause.rb
UTF-8
367
2.546875
3
[]
no_license
module PMD class Pause def initialize end def self.is_paused if File.exists? Config.pause_path return true end return false end def execute! if not File.exists? Config.pause_path FileUtils.touch Config.pause_path else FileUtils.rm ...
true
ef1995538838798a999fc263809e851b2ec0f28f
Ruby
venelrene/learn_ruby_the_hard_way
/ex5.rb
UTF-8
750
4.09375
4
[]
no_license
name = "Zed A. Shaw" age = 35 # not a lie 2009 height = 74 # inches weight = 180 eyes = 'Blue' teeth = 'White' hair = 'Brown' centimeter = 2.54 kilogram = 2.205 puts "Let's talk about #{name}." puts "He's #{height} inches tall." # added the formula to get centimeters puts "Which is #{height + centimeter} centimeters ...
true
643e36b836d8949740d8a5bd2c4f8fe8153967ae
Ruby
rahulrajdevaraj/artoo-crazyflie
/lib/artoo/adaptors/crazyflie.rb
UTF-8
1,308
2.5625
3
[ "Apache-2.0" ]
permissive
require 'artoo/adaptors/adaptor' module Artoo module Adaptors # Connect to a crazyflie quadcopter # @see crazyflie documentation for more information class Crazyflie < Adaptor attr_reader :crazyflie, :commander # Creates a connection with crazyflie # @return [Boolean] def connect...
true
cdc5d4afc8d8c36503b213b832908aee1ceb9f68
Ruby
dashalary/oo-tic-tac-toe-bootcamp-prep-000
/lib/tic_tac_toe.rb
UTF-8
1,763
4.25
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class TicTacToe def initialize(board = nil) @board = board || Array.new(9, " ") end def current_player turn_count % 2 == 0 ? "X" : "O" end def turn_count @board.count{|token| token == "X" || token == "O"} end def display_board puts " #{@board[0]} | #{@board[1]} | #{@board[2]} " p...
true
282ca677cf8a5c2e081ae2db7580017956cfe087
Ruby
robobee/rademade_fixtures
/lib/rademade_fixtures/active_record.rb
UTF-8
1,977
2.71875
3
[]
no_license
module RademadeFixtures class ActiveRecord attr_accessor :persisted attr_accessor :attributes attr_accessor :table_name def initialize(config = {}) @connection = config[:connection] || Connection.instance @attributes = config[:attributes] || self.class.attributes @table_name = conf...
true
af74c9c82dcae870fc8f0470ce2786bcb78789e6
Ruby
simoniong/patterns
/tests/user_test.rb
UTF-8
1,067
2.6875
3
[]
no_license
require File.dirname(__FILE__) + '/test_helper' require "not_active_record" require "models/user" class UserTest < Test::Unit::TestCase def test_initialize_with_attributes user = User.new(id: 1, name: "Marc") assert_equal 1, user.id assert_equal "Marc", user.name end def test_find user = User.fi...
true
ff7e06d6dfd62d8365d76bc42a64e3753d2996cf
Ruby
alanwillms/defender
/spec/actor/monster_spec.rb
UTF-8
5,970
2.625
3
[]
no_license
describe Monster do let :image do image = instance_double("Image") allow(image).to receive(:resized_width).and_return(32) allow(image).to receive(:resized_height).and_return(32) image end let :map do Game.current_window.current_screen.map end let :monster do map.monsters.first end ...
true
c1e4961f9cd85768a7f94f0d342e2c4b1f6538a2
Ruby
nog/atcoder
/contests/abc258/g/main.rb
UTF-8
295
3.03125
3
[]
no_license
N = gets.to_i A = Array.new N N.times do |i| A[i] = gets.to_i(2) end result = 0 (N-2).times do |i| ai = A[i] (i+1).upto(N-2) do |j| next if ai[j] == 0 aj = A[j] warn "i:#{i} j:#{j} str:#{(ai & aj).to_s(2)}" result += (ai & aj).to_s(2).count('1') end end puts result / 2
true
b5e59027e88699fb0b91ea9a3d7b9135e179bd2a
Ruby
ebababi/modalbox_helper
/lib/modalbox_helper.rb
UTF-8
1,776
2.953125
3
[ "MIT" ]
permissive
# = Modalbox Helper module ModalboxHelper # # Returns a link of the given +name+ that will trigger the ModalBox JavaScript # library's function show using the onclick handler and return false after the # fact. # # The first argument +name+ is used as the link text. # # The next arguments are optional a...
true
45e22b9d4f423770b5cfdb131d94ba62c4c22e55
Ruby
machvee/craps-strategy-simulator
/lib/craps/strategies/bet_presser.rb
UTF-8
3,551
3.109375
3
[]
no_license
class BetPresser # # bring bet to exact amount in sequence until # press_amounts array is exhausted, and maintain the last # amount until the bet is lost. Or, press bet by # press_unit if not nil. PARLAY in sequence or press_unit means # full press of winnings to scale. begin processing sequence at # s...
true
2717fdc5ae446383e8e3cf5571ad5a403ef4b734
Ruby
GenSplice-Research-Development/version
/Chemical Structure of DNA/char.rb
UTF-8
2,382
3.421875
3
[]
no_license
#A tribute to Erwin Chargaff def Chargaff(*b,a) nib = *b.map{|d|d.upcase}.sort percent = a.abs return "Only integers are permitted" unless percent.class == Integer or percent.class == Float return "Only one or two bases are allowed" if nib.count > 2 if nib.count == 1 return "argument error" if nib[0].leng...
true
a9c9e2d4113eeb5d6e904658454a7262a2e6da99
Ruby
mannyhappenings/interview
/hackerrank/calculate-gcd/calculate_gcd.rb
UTF-8
562
3.453125
3
[]
no_license
# frozen_string_literal: true puts 'Running in ruby' def min(first, second) first < second ? first : second end def max(first, second) first > second ? first : second end def gcd(first, second) first, second = min(first, second), max(first, second) first, second = second % first, first until (second % firs...
true
7d2134dc56a39472cdc1394c3cd6c8fe90df16e1
Ruby
twerth/acts_as_boolean
/lib/acts_as_boolean.rb
UTF-8
5,321
3.421875
3
[ "MIT" ]
permissive
require 'active_record/version' module ActsAsBoolean module ClassMethods # Treats a column as a boolean, whether it's a tinyint, integer, float, # string, etc. No matter how the true and false are stored in the database. # # This is useful when you don't have control over how booleans are # s...
true
67821d18d7b5d079474006b28977f776de80f3ac
Ruby
kkburr/homework_assignments
/Warmups/11/spec/lib/Crypt_spec.rb
UTF-8
1,649
3.015625
3
[]
no_license
require 'rspec' require './lib/crypt.rb' describe Crypt do subject {Crypt} # context '#encrypt' do # it 'should return "DBC" for .encrypt("CAB", 1)' do # expect(subject.encrypt('CAB', 1)).to eq('DBC') # end # end # # context '#decrypt' do # it 'should return "CAB" for .decrypt("DBC", 1)' do # ...
true
ff178a21a64117055d2fa4dbaac514cad64cad33
Ruby
edward-mn/learn-ruby
/OneBit/method_missing.rb
UTF-8
263
3.953125
4
[ "MIT" ]
permissive
class Fish #método missing def method_missing(method_name) puts "Fish don't have #{method_name.capitalize} behavior" end def swim puts 'Fish is swimming' end end my_fish = Fish.new my_fish.swim my_fish.walk #Aqui o método missing é acionado
true