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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
c47f194afac568700bec478733582c41f4aa098b | Ruby | gini/gini-api-ruby | /lib/gini-api/client.rb | UTF-8 | 12,716 | 2.65625 | 3 | [
"MIT"
] | permissive | require 'uri'
require 'json'
require 'logger'
require 'faraday'
require 'benchmark'
module Gini
module Api
# Main class to operate on the Gini API
#
class Client
attr_reader :token, :log
# Instantiate a new Gini::Api::Client object with OAuth capabilities
#
# @param [Hash] opti... | true |
7a03f7b0c0a4967a9958269c6f24a77f4e4ca96f | Ruby | villages-brewery/beer_finder | /app/domain/utils.rb | UTF-8 | 1,090 | 3.328125 | 3 | [] | no_license | class Utils
class << self
def get_beer_name(text)
t = text.clone
t = t.sub /\ can.*/, ''
t = t.sub /\ Can.*/, ''
t = t.sub /\ keg.*/, ''
t.sub /\ Keg.*/, ''
end
def is_keg?(text)
return true if text.include? 'keg'
return true if text.include? 'Keg'
false
... | true |
ff92a6f773f532a6f711b399a670ae51874cb498 | Ruby | marcwright/WDI_ATL_1_Instructors | /REPO - DC - Students/w03/d02/INSTRUCTOR/pig_latin/lib/word.rb | UTF-8 | 598 | 3.40625 | 3 | [] | no_license | class Word
# attr_reader :vowels, :consonants
def initialize(original_word)
@original_word = original_word
end
def original_word
return @original_word.downcase
end
def piglatinize
orig_copy = original_word.chars
['y', 'squ', 'qu'].each do |pattern|
if original_word.start_with?(patte... | true |
be85d63554d9bd486c5afc94c5c2cd26923f61e6 | Ruby | czuger/westeros2 | /work/map/tokens.rb | UTF-8 | 2,304 | 3.03125 | 3 | [] | no_license | require 'rmagick'
require 'fileutils'
SQUARE_BORDER=2
TOKEN_PATH = '../app/assets/images/tokens'
token_size = 22
houses_colors = {}
houses_colors[:stark] = 'white'
houses_colors[:lannister] = 'red'
houses_colors[:tully] = 'blue'
houses_colors[:greyjoy] = 'black'
houses_colors[:arryn] = 'cyan'
houses_colors[:tyrell] =... | true |
1ef05b39e3e40ed093e254b8a5abccfc49bb9e69 | Ruby | raspy8766/OOBlackjack | /OOblackjack.rb | UTF-8 | 7,149 | 4 | 4 | [] | no_license | # blackjack is a game with the objective of getting as close to 21 as possible without going over. If a player hits blackjack 21, then that player wins. The dealer goes first and continues to hit until he has more than 17. dealer wins tied values.
# classes: Players, Player, Dealer, Deck, Blackjack
# methods: hit_sta... | true |
2f8fb8d3628e9d395bddfdd4f79f5cf8ba713e05 | Ruby | wyh770406/findbest360 | /app/helpers/groupbuy_sites_helper.rb | UTF-8 | 360 | 2.546875 | 3 | [
"LicenseRef-scancode-public-domain"
] | permissive | # coding: utf-8
module GroupbuySitesHelper
def get_cities_by_letter(letter)
GroupbuyCity.all.select {|l| l.pinyin.first == letter.downcase}
end
def price_sort_name(num)
name = ""
case num
when '1'
name = "<10元"
when '2'
name = "10-50元"
when '3'
name = ">100元"
en... | true |
5e17e5ff9e0fc693be10e323bd620773f1299a61 | Ruby | menoelpis/rubytest | /string01_intro.rb | UTF-8 | 712 | 3.96875 | 4 | [] | no_license | string = "My first string"
puts "The length of the string is " + string.length.to_s
puts "'i' occurs " + string.count('i').to_s + " times"
puts string.length.next
french_string = "il \xc3\xa9tait une fois"
puts french_string
long_string = <<EOF
Here is a long string
With many paragraphs
EOF
puts long_string
# stri... | true |
36c27606086b5ae530cfc78032075e810a519878 | Ruby | SamSweigart13/Ruby_101 | /small_problems/bonus.rb | UTF-8 | 283 | 3.703125 | 4 | [] | no_license | def calculate_bonus(number, boolean)
bonus = []
if boolean == true
number * 0.5
else bonus == false
bonus = 0
end
end
puts calculate_bonus(2800, true) == 1400
puts calculate_bonus(1000, false) == 0
puts calculate_bonus(50000, true) == 25000 | true |
306679ebd88f62d43d341c170305fc3429f9d661 | Ruby | Jnrichards/kwk-l1-oo-ruby-anagram-detector-london-whitehat-1905 | /lib/anagram.rb | UTF-8 | 271 | 3.703125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Your code goes here!
class Anagram
attr_accessor :word
def initialize(word)
@word = word.downcase
end
def match(words)
words.select do |word|
is_anagram?(word)
end
end
def is_anagram?(word)
word.chars.sort == @word.chars.sort
end
end
| true |
28b68baa81cfead919a039544ba415f9ae3c7881 | Ruby | JoseLopez235/oauth_workshop | /app/poro/user_info.rb | UTF-8 | 211 | 2.6875 | 3 | [] | no_license | class UserInfo
attr_reader :id,
:login,
:token
def initialize(user_data, access_token)
@id = user_data[:id]
@login = user_data[:login]
@token = access_token
end
end
| true |
9a87d53ffe5d3293b10f167e8d5db06c60bbbce2 | Ruby | gonyolac/ls_ruby_course | /random_exercises/suzuki_lineup.rb | UTF-8 | 506 | 3.46875 | 3 | [] | no_license | require 'pry'
def lineup_students(students)
name_arr = students.split(' ')
largest = name_arr.map {|x| x.size}.max
smallest = name_arr.map {|x| x.size}.min
empty = []
(smallest..largest).each_with_index do |x, idx|
name_arr.select {|y| y.size == x}.empty? ? "nothing" : empty << name_arr.select {|y| y.size... | true |
5fda350a1182bb867472ec5d962d0a1822d457f6 | Ruby | singsang2/movie_review | /lib/movie_review/cli.rb | UTF-8 | 2,490 | 3.828125 | 4 | [
"MIT"
] | permissive | class MovieReview::CLI
attr_accessor :sorted_movies
def start
puts "Welcome to the Movie Review App!"
puts "Here are the top 100 movies:"
MovieReview::Scraper.scrape_movies
sort_movies
#scrape all the movies - call to the scraper class
#list the top 100 movies
list_movies
puts "Ple... | true |
0f8f7ccd6cedd4e2b777d9b5cc34569c2c451932 | Ruby | apmarino/AR_Callbacks | /animal_farm/models/pig.rb | UTF-8 | 688 | 3.1875 | 3 | [] | no_license | require_relative('../lib/connection')
class Pig < ActiveRecord::Base
def give_birth(num)
i = 1
while i <= num
if rand < 0.5
sex = "Male"
else
sex = "Female"
end
breed = self.breed
Pig.create({name: "Piglet#{i}", age: 0, sex: "#{sex}", breed: "#{breed}" })
... | true |
4bb98f9bef74d4dd29dc4a6480d10517b78167bc | Ruby | jeff-fichtner/ruby_challenges | /learn_to_program_ed_2/roman_numerals_modern.rb | UTF-8 | 2,081 | 4.75 | 5 | [
"MIT"
] | permissive | # roman numerals traditional
def subtract number, roman_number
number - roman_number
end
def add_to_numeral roman_letter, roman_string
roman_string << roman_letter
end
while true
puts "What integer would you like to convert? (or type 'q' to quit)"
original_input = gets.chomp
number = original_input.to_i
roman... | true |
35be0065b268b9e37c1282336a81c27f5d5b2ff9 | Ruby | MagneticRegulus/101_exercises | /easy_8/2_madlibs.rb | UTF-8 | 1,034 | 4.375 | 4 | [] | no_license | # Mad libs are a simple game where you create a story template with blanks for
# words. You, or another player, then construct a list of words and place them
# into the story, creating an often silly or funny story as a result.
# Create a simple mad-lib program that prompts for a noun, a verb, an adverb, and
# an adje... | true |
12ed7d11b21cb5054424c7aeda49f13734b710a7 | Ruby | Jae/meetup | /app/decorators/preference_decorator.rb | UTF-8 | 272 | 2.609375 | 3 | [] | no_license | class PreferenceDecorator < SimpleDelegator
def start_times_from
format_time(start_times.try(:first))
end
def start_times_to
format_time(start_times.try(:last))
end
private
def format_time(time)
time.try(:strftime, "%Y-%m-%dT%H:%M:%S")
end
end
| true |
81afaa87a0c66ca15d4ea68dfc6465beb64334c8 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/hamming/aabdf15d68c04f628fba4fa40805a770.rb | UTF-8 | 273 | 3.375 | 3 | [] | no_license | class Hamming
def self.compute(str1, str2)
distance=0
if str1.length > str2.length
temp=str1
str1=str2
str2=temp
end
str1.length.times do |i|
if str1[i] != str2[i]
distance += 1
end
end
distance
end
end
| true |
b9e44863e4dcc11643afdb708f7069e6c3305882 | Ruby | shelleyyz/WDi28-Homework | /wenjun_liu/week_04/day_02/line.rb | UTF-8 | 700 | 3.671875 | 4 | [] | no_license | class Line
def initialize(name, stations)
@name = name
@stations = stations
end
def check_line(line)
@name == line
end
def stations
@stations
end
def find_station_index(station_name)
@stations.each do |s|
if s.name == station_name
return @stations.index(s)
end
... | true |
9f0e828f25f058a6b3e977262af408b4c8bc3f38 | Ruby | exwarvlad/second_large_quality | /spec/second_large_quality.rb | UTF-8 | 603 | 3.078125 | 3 | [] | no_license | require 'rspec'
require_relative '../algorithms/calculate_second_large_quality'
describe '.calculate_second_large' do
it 'multiple n' do
3.times do |index|
array = [1, 2, 3].map { |num| num * (index + 1) }
big_array = [1, 2, 3, 4, 5].map { |num| num * (index + 1) }
expect(calculate_second_larg... | true |
bd4611f77809891de6b73ceb6dd2814b767f03ad | Ruby | pschlatt/sweater_weather | /app/facades/forecast_facade.rb | UTF-8 | 960 | 2.640625 | 3 | [] | no_license | class ForecastFacade
def initialize(location)
@location = location
end
def geo_coordinates
coords = grab_geocode["results"].first["geometry"]["location"]
Coordinate.new(coords["lat"], coords['lng'])
end
def forecast
Forecast.new(grab_forecast)
end
def background
back = grab_backgrou... | true |
4ab9d4b18627971f56d0911fb16c7d0d51fcee60 | Ruby | zippy/metaform | /lib/metaform/reports.rb | UTF-8 | 5,855 | 2.546875 | 3 | [
"MIT"
] | permissive | #require 'metaform/utilities'
class Reports
# we store the field answers in an answer class that can handle the indexes but also
# has accessors for the non-indexted case
class << self
include Utilities
def reports
@reports ||= {}
@reports
end
##############################... | true |
05be1a663e114a370c20926b730c01d65fae2f72 | Ruby | kellyarwine/aggrego_hack_night | /spec/problem_2_spec.rb | UTF-8 | 397 | 2.921875 | 3 | [] | no_license | require 'problem_2'
describe Problem2 do
it "does something1" do
subject.calculate([1,2], 10).should == [1,2,3,5,8]
end
it "does something2" do
subject.sum_calculate_array([1,2]).should == 3
end
it "returns even values" do
subject.pick_even_values([2,3,4,5,6,7]).should == [2,4,6]
end
it "r... | true |
b6b6475e44f1e1d4781e70b9aeb1c059396329b6 | Ruby | Bapuch/ruby | /exo_12.rb | UTF-8 | 121 | 3.375 | 3 | [] | no_license | puts "Je compte jusqu'à combien ?"
print ">"
x = gets.chomp
x_int = x.to_i
x_int += 1
x_int.times do |i|
puts i
end
| true |
538dd03e60d1f38fa732f816fc6f707b7bef0ba1 | Ruby | BashaM2020/ArraysnHashes | /exercise3.rb | UTF-8 | 2,047 | 4.125 | 4 | [] | no_license | #exercise 10 rb
#! creating a new key just put it in [:hfbhf]
# when iterating through hashes 2 block values are
#used, for key and hash
# # EXERCISE 3
# students = {
# :cohort1 => 34,
# :cohort2 => 42,
# :cohort3 => 22
# }
# # 3. adding a key and varible to a hash.
# students[:cohort4] ... | true |
bc97bf183c988aed2dec24c207d12f0962f9d60c | Ruby | costajob/rsync_cron | /lib/rsync_cron/command.rb | UTF-8 | 717 | 2.609375 | 3 | [] | no_license | require "rsync_cron/options"
module RsyncCron
class Command
NAME = `which rsync`.strip
def initialize(src:, dest:, options: Options.new, name: NAME, log: nil, io: STDOUT)
@src = src
@dest = dest
@options = options
@name = name
@log = log
@io = io
end
def to_s
... | true |
c234ddec871f945888373ecc7f2634afe260ac1b | Ruby | b0n0n/AoC_2017 | /22/22_2.rb | UTF-8 | 2,355 | 4.125 | 4 | [] | no_license | =begin
If it is clean, it turns left.
If it is weakened, it does not turn, and will continue moving in the same direction.
If it is infected, it turns right.
If it is flagged, it reverses direction, and will go back the way it came.
Clean nodes become weakened.
Weakened nodes become infected.
Infected nodes become fla... | true |
714cadfbc7f614ab9ed166bb9730a0d05cdd785a | Ruby | bernardoarancibia/tt_app | /app/models/merma.rb | UTF-8 | 1,200 | 2.71875 | 3 | [
"MIT"
] | permissive | #encoding:utf-8
class Merma < ActiveRecord::Base
#---Dependencia Existencial---
belongs_to :producto
#---Crear campo nombre_de_producto---
attr_accessor :nombre_de_producto
#---Atributos Accesibles---
#attr_accessible :producto_id, :cantidad, :tipo_merma, :comentario, :nombre_de_producto
#---Validacio... | true |
59d4cd3437ce0a9493acb105901b237e01369471 | Ruby | Albin-Willman/advent | /2016/day11/elevator.rb | UTF-8 | 4,707 | 3.28125 | 3 | [] | no_license | #!/usr/bin/env ruby
class Level
attr_accessor :generators, :microchips
def initialize(generators, microchips)
@generators, @microchips = generators, microchips
end
def valid?
return true if generators.select { |k,v| v }.length == 0
microchips.each do |key, val|
return false unless generators... | true |
25f11ac9edc14f93b11786af3bc39b5a42f3d3cc | Ruby | liosha2007/groupdocs-ruby | /groupdocs/models/geteditlockresult.rb | UTF-8 | 1,153 | 2.6875 | 3 | [
"Apache-2.0"
] | permissive | class GetEditLockResult
attr_accessor :doc_guid, :file_id, :edit_url
# :internal => :external
def self.attribute_map
{
:doc_guid => :doc_guid, :file_id => :file_id, :edit_url => :edit_url
}
end
def initialize(attributes = {})
# Morph attribute keys into undescored rubyish style
if attribu... | true |
d54625d2dd785b8d560955979792bc028f88c225 | Ruby | nbogie/production_log_analyzer | /lib/report/report_parser.rb | UTF-8 | 3,084 | 2.6875 | 3 | [
"BSD-2-Clause"
] | permissive | class Report
attr_accessor :name
attr_accessor :requests
attr_accessor :started_at
attr_accessor :summary
def initialize
@summary = Request.new #blagging it. doesn't have controller/action.
@requests=[]
end
def get_request_like(other)
@requests.select { |r| r.controller == other.control... | true |
bed40d276369d2a93fdb61362b520815dd51cb34 | Ruby | jubaan/the_labradors | /missing_letter/benchmark.rb | UTF-8 | 1,325 | 3.046875 | 3 | [] | no_license | require 'benchmark'
require 'benchmark/memory'
require 'benchmark/ips'
# --- Files to benchmark ------------------------------------------------------
require_relative 'missing_letter.rb'
def benchmark(array)
puts
puts '--- bmbm ---'
puts
Benchmark.bmbm do |x|
x.report ('Julio') { missing_letter_julio(ar... | true |
54ba2fb34fb7b7e76d8d27622688d05fae938c07 | Ruby | tothutra/ttt-game-status-q-000 | /lib/game_status.rb | UTF-8 | 1,037 | 3.640625 | 4 | [] | no_license | # Helper Method
def position_taken?(board, location)
!(board[location].nil? || board[location] == " ")
end
WIN_COMBINATIONS = [
[0,1,2],
[3,4,5],
[6,7,8],
[0,4,8],
[6,4,2],
[0,3,6],
[1,4,7],
[2,5,8]
]
#WIN_COMBINATIONS.each do |win_index|
# win_index.each do |win_location|
# end
#end
#def won?(bo... | true |
86f00de37c5f6099805c56d9612ee9181aeb55e7 | Ruby | ruby/typeprof | /smoke/dummy-execution1.rb | UTF-8 | 177 | 2.75 | 3 | [
"MIT"
] | permissive | def foo(n)
n
end
def bar
foo(1)
end
__END__
# Classes
class Object
private
def foo: (Integer | untyped n) -> (Integer | untyped)
def bar: -> (Integer | untyped)
end
| true |
7a450eb33f3bc38f16965647a9791fe9b8ed327e | Ruby | dgrizzanti/exercism.io | /ruby/raindrops/raindrops.rb | UTF-8 | 763 | 3.5 | 4 | [] | no_license | class Raindrops
def self.convert(value)
factors = get_factors(value)
generate_output(factors, value)
end
private
def self.get_factors(value)
if value % 2 == 0
[2].concat get_factors(value/2)
elsif value % 3 == 0
[3].concat get_factors(value/3)
elsif value % 5 == 0
[5].con... | true |
1f76243bae3ed1fc463318ff849d2aff0b07b60b | Ruby | zsy056/solutions | /leetcode/162-find-peak-element.rb | UTF-8 | 262 | 3.25 | 3 | [] | no_license | # @param {Integer[]} nums
# @return {Integer}
def find_peak_element(nums)
n = nums.size
nums.each_with_index do |x, idx|
left = (idx == 0 or nums[idx-1] < x)
right = (idx == n-1 or nums[idx+1] < x)
return idx if (left and right)
end
0
end
| true |
5087707290c4c2c2f866d254121ae74294ac2861 | Ruby | mansakondo/activemodel-embedding | /test/activemodel/embedding_test.rb | UTF-8 | 4,185 | 2.546875 | 3 | [
"MIT"
] | permissive | require "test_helper"
class ActiveModel::EmbeddingTest < ActiveSupport::TestCase
test "it has a version number" do
assert ActiveModel::Embedding::VERSION
end
fixtures "marc/records"
class SomeCollection
include Enumerable
include ActiveModel::Embedding::Collecting
end
class SomeType < Active... | true |
f17d76598f63e807f102069b5f49390aef7f885c | Ruby | karlitxo/cantango | /lib/cantango/permission_engine/statement.rb | UTF-8 | 398 | 2.515625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module CanTango
class PermissionEngine < Engine
class Statement
attr_reader :method, :action, :conditions
def initialize method, action, conditions = {}
@method, @action, @conditions = [method, action, conditions]
end
def to_code
line = conditions.empty? ? "#{method}(:#{a... | true |
f9b7141e35efc35c0e00c329d8c32e8deceaf67b | Ruby | ikzekly/RubyProjects | /thinknetica/lesson2/Hashes/hash_tasks.rb | UTF-8 | 2,064 | 4.25 | 4 | [] | no_license | # Make a hash that contains months and the number
# of days in a month. In the cycle, output those
# months, in which the number of days is exactly 30.
puts 'Task 1'
months = {
January: 31,
February: 29,
March: 31,
April: 30,
May: 31,
June: 30,
July: 31,
August: 31,
September: 30,
October: 31,
No... | true |
0fd8c97ab4f34373e36aecf2e56e08b06607531f | Ruby | iddumied/MIMA | /test/ALUTest.rb | UTF-8 | 7,100 | 2.53125 | 3 | [] | no_license | require './lib/MIMA.rb'
require 'test/unit'
class ALUTest < Test::Unit::TestCase
include MIMA
def test_do_nothing
alu = ALU.new
alu.c0 = 0
alu.c1 = 0
alu.c2 = 0
x = alu.x
y = alu.y
z = alu.z
1000.times do
x.read = 1
y.read = 1
z.read = 1
x.write = 0
... | true |
e21aa1239760a369995b451d72717220d481e647 | Ruby | synion/recruitment-web-app | /app/services/users_csv_export.rb | UTF-8 | 603 | 3.328125 | 3 | [] | no_license | require 'csv'
class UsersCsvExport
ATTRIBUTES = %w{email age gender}
def initialize(users)
@users = users
end
def generate
CSV.generate do |csv|
csv << user_heading
@users.each do |user|
csv << user_column(user)
end
end
end
private
def user_heading
ATTRIBUTES... | true |
29de48aeb2c79470853b100f64f3f5a0faf10a56 | Ruby | web1221/FT_Number_to_Word | /lib/num_to_word.rb | UTF-8 | 1,691 | 4.03125 | 4 | [] | no_license | class Converter
def initialize(converter)
@converter = converter
@single_digit = {
1 => 'one',
2 =>'two',
3 =>'three',
4 =>'four',
5 =>'five',
6 =>'six',
7 =>'seven',
8 =>'eight',
9 =>'nine'
}
@tens = {
1 => 'ten',
2 => 'twenty',
... | true |
c3130615698e9281455a3c5e0ead481c796441cd | Ruby | urbantumbleweed/urbantumbleweed | /w01/d02/Igor_Yuzovitskiy/my_third_ruby_app.rb | UTF-8 | 123 | 3.5625 | 4 | [] | no_license | puts "Hey guys, write your names to get started"
name1 = gets.chomp
name2 = gets.chomp
puts "Hey, #{name1} meet #{name2}!"
| true |
b80d253727f76dbe0c8c3479ae17b73b47c617b1 | Ruby | siu00adg/eav_products | /app/models/product.rb | UTF-8 | 8,905 | 2.75 | 3 | [] | no_license | class Product < ApplicationRecord
has_many :values, :dependent => :destroy
belongs_to :product_type
OPERATORS = {:equal => "=", :like => "LIKE", :gt => ">", :lt => "<"}
SORT_OPERATORS = {:asc => "ASC", :desc => "DESC"}
# Strangely it can be quicker to chain filters together rather than add all
# options t... | true |
df72a0f5f32a8f5eeb075d8c203c3db0c5450b84 | Ruby | CalebJamesStevens/Chess | /lib/piece.rb | UTF-8 | 253 | 3.546875 | 4 | [] | no_license | require 'colorize'
class Piece
attr_accessor :color, :piece_type
def initialize(color, piece_type)
@color = color
@piece_type = piece_type.downcase
end
def to_s
puts @piece_type.to_s.send(@color)
end
end | true |
8e484c00c15345cc4f132e78234e00a977bb4038 | Ruby | jeperkins4/delivery_service | /lib/forecast.rb | UTF-8 | 746 | 2.625 | 3 | [] | no_license | require 'builder'
require 'cgi'
require 'open-uri'
module Forecast
class Mapping
def self.get(origin)
unless origin.empty?
lat = origin[:latitude]
lng = origin[:longitude]
url_string = "https://api.forecast.io/#{APP[:forecastio][:key]}/#{lat},#{lng}"
params = {}
para... | true |
ebe86f06c60858d7b248fc7538298d0ef9861512 | Ruby | islandpress/commons | /db/seeds.rb | UTF-8 | 1,318 | 2.609375 | 3 | [] | no_license | # config
users_count = 0
resources_count = 0
networks_count = 0
list_count = 0
p 'Creating admin user with email \'admin@greencommons.org\' and password \'thecommons\'...'
admin = FactoryGirl.create(:user, email: 'admin@greencommons.org',
password: 'thecommons')
p "Creating #{users_c... | true |
5d562b4ad8f4a39a06407e80c599604966295d9a | Ruby | jkronz/advent | /test/day_one_test.rb | UTF-8 | 339 | 2.53125 | 3 | [] | no_license | require 'minitest/autorun'
require './lib/day_one'
class DayOneTest < MiniTest::Test
def setup
@day = DayOne.new
end
def test_part_one
@day = DayOne.new
assert_equal 5, @day.process_part_one(%w(R2 L3))
end
def test_part_two
@day = DayOne.new
assert_equal 4, @day.process_part_two(%w(R8 R4... | true |
d9daef791a3439dfe99cee1de748f7dd495c410f | Ruby | 14tinchov/codika_api | /app/decorators/posts_decorator.rb | UTF-8 | 302 | 2.890625 | 3 | [] | no_license | class PostsDecorator
attr_accessor :posts
def initialize(posts_collection)
@posts = posts_collection
end
def as_json
{
posts: build_posts
}
end
private
def build_posts
posts.inject([]) do |rtn, post|
rtn << PostDecorator.new(post).as_json
end
end
end
| true |
1a38387c67b6048da35f7f86754339cdee108940 | Ruby | gollo/healthcheck-cookbook | /libraries/misc_helpers.rb | UTF-8 | 149 | 2.546875 | 3 | [
"MIT"
] | permissive |
def attribute_exists? (*attributes)
parent = node
attributes.each { |a|
return false unless parent[a]
parent = parent[a]
}
true
end
| true |
6195972e2e610c0a859ffdc8d940b2e7b0db4792 | Ruby | Shonda860/Hashmap-Questions | /lib/array_intersection.rb | UTF-8 | 296 | 3.265625 | 3 | [
"MIT"
] | permissive | def intersection(list1, list2)
# raise NotImplementedError, "Intersection not implemented"
hash = {}
list2.each do |num|
hash[num] = true
end
intersect_list = []
list1.each do |target|
if hash[target]
intersect_list << target
end
end
return intersect_list
end
| true |
a27ff640cd7881413a4380b28877fe984988c9aa | Ruby | linojon/ym | /app/models/person.rb | UTF-8 | 3,183 | 2.734375 | 3 | [] | no_license | require Rails.root.join('lib/capitalize_name.rb')
require Rails.root.join('lib/hebrew_date.rb')
class Person < ActiveRecord::Base
#extend ActiveSupport::Memoizable
def full_name
[ prefix, first_name, middle_name, last_name, suffix ].join(' ')
end
composed_of :death_hebrew_date,
:class_... | true |
94cfb58a1b3f605694a4dee9fa30cceaa652eb84 | Ruby | LPP-T-04/matrix | /matrix.rb | UTF-8 | 2,017 | 3.859375 | 4 | [] | no_license | #!/usr/bin/ruby
a = [[2,0,1],[3,0,0],[5,1,1]] # Inicialización de la matriz 3*3 de nombre A.
b = [[1,0,1],[1,2,1],[1,1,0]] # Inicialización de la matriz 3*3 de nombre B.
$row = 3 # Número de filas de la matriz.
$colum = 3 # Número de columnas de la matriz.
# Se define la función de Suma:
def sumar(a,b)
@c = Array.ne... | true |
b02a315e756681efd475c063fca1ff4587b93517 | Ruby | abhilashkkumar/Knight-tour-problem | /valid_moves.rb | UTF-8 | 563 | 3.671875 | 4 | [] | no_license | require './spot'
require './board'
class ValidMove
# available moves fro the current position
@@x = [0, 0, 3, -3, 2, -2, -2, 2]
@@y = [3, -3, 0, 0, 2, 2, -2, -2]
# check if the current spot is in board limit or not
def self.under_board(spot)
(spot.x >= 0 && spot.y >= 0) && (spot.x < Board.size && spot.y ... | true |
3f3c58672a7b62eafcbe7d440acbf438268a8c73 | Ruby | JGTR/sql-stuff | /ruby/word_reverse.rb | UTF-8 | 549 | 4.6875 | 5 | [] | no_license | # From [Rubeque](http://rubeque.com/problems/reverse-each-word)
# Write a method that takes a sentence and returns it with each word reversed in place.
# reverse_each_word.rb
# Write a method that takes a sentence and returns it with each word reversed in place.
# A String has many methods that can be called on it:... | true |
da50ca6765a44773022a8543cb0699472daa14db | Ruby | drpitch/ruby-calculator | /token.rb | UTF-8 | 207 | 3.21875 | 3 | [
"MIT"
] | permissive | class Token
attr_reader :token_type, :value
def initialize(token_type, value)
@token_type = token_type
@value = value
end
def to_s
"#{@token_type.id} (#{@value})"
end
end
| true |
61ad9952516725f6eca73726afa4aa55748b8100 | Ruby | werner/slaw | /lib/slaw/parse/builder.rb | UTF-8 | 12,391 | 2.625 | 3 | [
"MIT"
] | permissive | # encoding: UTF-8
require 'builder'
require 'treetop'
module Slaw
module Parse
# The primary class for building Akoma Ntoso documents from plain text documents.
#
# The builder uses a grammar to break down a plain-text version of an act into a
# syntax tree. This tree can then be serialized into an ... | true |
7d00acf8f8567f0a98ea3669cfd3cd98330ac4c8 | Ruby | eallsopp/second-ruby-intro-reading | /Methods/return.rb | UTF-8 | 1,663 | 4.625 | 5 | [] | no_license | def add_three(number)
number + 3
end
returned_value = add_three(4)
puts returned_value
#The last line of a method invocation is always the one called unless there is an
#explicit return programmed into the method invocation
def add_three(number)
return number + 3
end
returned_value = add_three(4)
puts returned_... | true |
3d6caadbe63353f0f8c4ef3e2440b1d9a883243d | Ruby | radar/forem-redcarpet | /lib/forem/formatters/redcarpet.rb | UTF-8 | 1,038 | 2.546875 | 3 | [] | no_license | require 'redcarpet'
require 'pygments'
require 'nokogiri'
module Forem
module Formatters
class Redcarpet
def self.format(text)
options = [:hard_wrap, :filter_html, :autolink, :no_intraemphasis, :fenced_code, :gh_blockcode]
renderer = ::Redcarpet::Markdown.new(::Redcarpet::Render::HTML, :fen... | true |
17fe6515375eb21283a061a9fc7b8f1420c507de | Ruby | baughje/practice | /rps_tournament.rb | UTF-8 | 491 | 2.859375 | 3 | [] | no_license | class WrongNumberOfPlayersError < StandardError ; end
class NoSuchStrategyError < StandardError ; end
def rps_tournament_winner(tournament)
tournament = [
[ [ ["Armando", "P"], ["Dave", "S"] ],
[ ["Richard", "R"], ["Michael", "S"] ], ],
[ [ ["Allen", "S"], ["Omer", "P"] ],
[ ["David E.", "R"], ["Richard X."... | true |
8c31fa592ad191d993f3d3e8958185beff4f6953 | Ruby | mbukantz/collections_practice-001-prework-web | /collections_practice.rb | UTF-8 | 708 | 3.96875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def sort_array_asc(arr)
arr.sort
end
def sort_array_desc(arr)
arr.sort do |a,b|
b <=> a
end
end
def swap_elements(arr)
arr[1],arr[2] = arr[2], arr[1]
arr
end
def swap_elements_from_to(array,index,destination_index)
array[index],array[destination_index] = array[destination_index], array[index]
array... | true |
ff0b3e9ecea527e9e75073c25dda60124dd4e81d | Ruby | josephjlee/sageworld-catalog | /lib/sage_world/api/product.rb | UTF-8 | 8,584 | 2.6875 | 3 | [
"MIT"
] | permissive | # Summary
# Sage world product api provides you 2 basic operations for
# => search -> returns collection of searched products.
# => details -> return details of product.
module SageWorld
module Api
class Product < SageWorld::Api::Base
DEFAULT_SEARCH_PARAMS = {
quick_search: ''
}.freeze... | true |
170e1b9bc84dbaa35b30485deee9e68dfac430be | Ruby | LogaJ/ruby_prag_prog | /variables/freezing.var.references.rb | UTF-8 | 206 | 3.109375 | 3 | [] | no_license | person_one = "Timmy"
person_two = person_one
person_one.freeze
person_two[0] = 'B'
puts person_two #will raise an exception. The reference person_one cannot be changed, therefor neither can person_two's.
| true |
910237683539725b37643a8d67a81a51972d08b8 | Ruby | ChanKim04/school | /214/projects/07/NameTester.rb | UTF-8 | 3,158 | 3.96875 | 4 | [] | no_license | # NameTester.rb tests class Name and its operations
#
# Begun by: Dr. Adams, for CS 214 at Calvin College.
# Completed by: Chan Kim (ck45)
# Date: 3/29/2018
####################################################
require 'test/unit/assertions' # needed for assert
include Test::Unit::Assertions
# Replace this line with... | true |
e4c1631b6540a0f0067d65ba60a7d194a0e71cf9 | Ruby | 06190914/progmanage | /proen/ex8_13ver2.rb | UTF-8 | 170 | 3.375 | 3 | [] | no_license | def maxvalue(b)
l = b.length
max = 0
b.each do |ary|
if max < ary then
max = ary
end
end
return max
end
b = [19,3,4,10]
print(maxvalue(b),"\n.")
| true |
9c48c8cbc0d5ba70d658cf5a0934de02afacf8b5 | Ruby | httprb/http | /spec/lib/http/request/writer_spec.rb | UTF-8 | 3,482 | 2.625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # coding: utf-8
# frozen_string_literal: true
RSpec.describe HTTP::Request::Writer do
let(:io) { StringIO.new }
let(:body) { HTTP::Request::Body.new("") }
let(:headers) { HTTP::Headers.new }
let(:headerstart) { "GET /test HTTP/1.1" }
subject(:writer) { described_class.new(io, body, head... | true |
b3a9acfc9d22a06626993fe7d21bb67eda14abd8 | Ruby | evansenter/ucsb | /side_project/tests/overlord.rb | UTF-8 | 669 | 2.796875 | 3 | [] | no_license | tests = Dir.new(File.dirname(__FILE__)).entries.select do |file_name|
file_name =~ /^.*_test.rb$/
end
totals = {
:tests => 0,
:assertions => 0,
:failures => 0,
:errors => 0
}
tests.each do |test|
results = `ruby #{test}`
results =~ /(\d+) tests, (\d+) assertions, (\d+) failures, (\d+) errors... | true |
546b1bf9659c88645508b419d8010711387a808b | Ruby | isabella232/win32-changenotify | /examples/example_win32_changenotify.rb | UTF-8 | 882 | 2.78125 | 3 | [
"Artistic-2.0",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | #######################################################################
# example_win32_changenotify.rb
#
# An example script for general futzing and demonstration. You can
# run this program via the 'rake example' task.
#
# Modify as you see fit.
#######################################################################
... | true |
d005d148abf4097de79a3bc05861d8420e6e686a | Ruby | hankim813/good_morning | /controllers/forecast_controller.rb | UTF-8 | 899 | 2.921875 | 3 | [] | no_license | # encoding: utf-8
require 'forecast_io'
class ForecastFor
def self.setup
ForecastIO.configure do |configuration|
configuration.api_key = 'GET YOUR OWN'
end
@forecast = ForecastIO.forecast(37.7833, -122.4167)
end
def self.weekly
@forecast.daily.map do |item|
item[0] == "summary" ? (WeatherView.forecas... | true |
25ad4fc862fcb9f0715de83c075be38394fafa24 | Ruby | edhuang24/Algorithms-DataStructures | /algorithms/breadth_first_search.rb | UTF-8 | 325 | 3.28125 | 3 | [] | no_license | def bfs(target_value)
queue = []
queue << self
until queue.empty?
current = queue.shift
if current.value == target_value
return current
else
# we need to use += instead of shovel, otherwise we are passing in an entire array into the queue
queue += current.children
end
end
nil... | true |
9154676c8a99c4eef95cca57695d1e18ced5f131 | Ruby | abachman/sketchbook | /rubygame/demo_rubygame.rb | UTF-8 | 13,797 | 3.09375 | 3 | [] | no_license | #!/usr/bin/env ruby
# This program is released to the PUBLIC DOMAIN.
# It is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# This demo shows a simple example of game structure.
# It demonstrate... | true |
c0726180da33d14ae91ea509ec0e461cef80dbe0 | Ruby | caramorelli/the-bachelor-todo-prework | /lib/bachelor.rb | UTF-8 | 974 | 3.515625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def get_first_name_of_season_winner(data, season)
data.each do |key, val|
if season == key
val.first.each do |k, v|
return v.split(' ').first if k == 'name'
end
end
end
end
def get_contestant_name(data, occupation)
data.each do |key, val|
val.each do |name|
return name["name"] if name[... | true |
a05ef4a38582554d62b16a98ebcfa5cd430c8a89 | Ruby | nevans/lazier_enum | /lib/lazier/proxy.rb | UTF-8 | 3,786 | 3.03125 | 3 | [
"MIT"
] | permissive | require "forwardable"
require "lazier/enumerable"
require "lazier/forced"
require "lazier/schema"
module Lazier
module Proxy
# does nothing but delegate force to parent
class Basic
extend Forwardable
include Enumerable
attr_reader :parent
def initialize(parent)
@parent = pa... | true |
c57c2f7c4a9af3e5b48899f3493e1220c2354204 | Ruby | mbetts7/new_relic_api | /email.rb | UTF-8 | 544 | 2.53125 | 3 | [] | no_license | require 'mandrill'
class MyEmailer
def send
m = Mandrill::API.new
message = {
:subject => 'hello world',
:from_name => 'Mike Betts',
:text => 'Hi Ian! Sending you an email via this API I just made.',
:to =>[
{
:email => 'iolsen@newrelic.com',
:name => ... | true |
83c1a21251c3c133ee703cd52106214485d63892 | Ruby | teasacura/OO-mini-project-dumbo-web-042318 | /app/models/Recipe.rb | UTF-8 | 1,189 | 2.9375 | 3 | [] | no_license | class Recipe
attr_accessor :title, :ingredients
@@all = []
def initialize(title)
@title = title
# @ingredients = ingredients
@@all << self
end
def self.all
@@all
end
def users
RecipeCard.all.select do |card|
card.recipe == self
end.map do |recipe|
recipe.user
en... | true |
023a34e211f379278314da85eda4b4b122403498 | Ruby | AllPurposeName/final-assessment | /test/features/better_match_suggestion_test.rb | UTF-8 | 1,200 | 2.53125 | 3 | [] | no_license | require "test_helper"
class BetterMatchSuggestionTest < ActiveSupport::TestCase
def test_it_shows_pending_users_first
simply_log_in
all_user = User.find_by(name: "AllPurposeName")
user = User.find_by(name: "worace")
user.pairs << User.all
user.pairings.where(pair_id: all_user.id).first.mark_as_i... | true |
4fa253573b31c48be3a2558a80a386a91a8454e3 | Ruby | anjanamohanty/guessing_game | /guessing_game.rb | UTF-8 | 1,209 | 4.21875 | 4 | [] | no_license | def check_guess(u, c)
if u > c
return "high"
elsif u < c
return "low"
else
return "match"
end
end
def is_repeat_guess?(n, guesses)
(guesses.length - 1).times do |i|
if guesses[i] == guesses[n]
return true
break
end
end
return false
end
def generate_random_number
return ... | true |
a0ff58b0f4b9a4e0b5504f31186a9f9cd6acdf22 | Ruby | livecodelife/fareharbor_external_api | /lib/fh/company/booking.rb | UTF-8 | 1,898 | 2.53125 | 3 | [
"MIT"
] | permissive | module FH
class Company::Booking
attr_reader :display_id,
:status,
:customers,
:uuid,
:receipt_taxes,
:note_safe_html,
:receipt_subtotal,
:arrival,
:rebooked_to,
:confirm... | true |
8e0c6d32ec36ea73355c1da6e9f0a025fc78bedf | Ruby | jwright/gotcha-json-api-ruby | /lib/base64_image.rb | UTF-8 | 568 | 2.546875 | 3 | [] | no_license | class Base64Image
REGEXP = /\Adata:([-\w]+\/[-\w\+\.]+)?;base64,(.*)/m
def self.decode(encoded, filename="")
if data = encoded.match(REGEXP)
content_type = data[1]
mime_type = Mime::Type.lookup content_type
[StringIO.new(Base64.strict_decode64(data[2] || "")),
"#{filename}.#{mime_type.... | true |
a4bd131a2c346b87a85b75637ea1da428ddcb38b | Ruby | BrianZanti/dpl_1901 | /lib/library.rb | UTF-8 | 1,229 | 3.25 | 3 | [] | no_license | class Library
attr_reader :books
def initialize
@books = []
end
def add_to_collection(book)
@books << book
end
def include?(title)
# titles = @books.map do |book|
# book.title
# end
# titles.include?(title)
# @books.each do |book|
# if book.title == title
# re... | true |
9c55b00213e5b3476f6e7b06768d8e1a9e57a79f | Ruby | alex-solo/ruby-problems | /deck_of_cards.rb | UTF-8 | 1,024 | 4 | 4 | [] | no_license | class Deck
RANKS = (2..10).to_a + %w(Jack Queen King Ace).freeze
SUITS = %w(Hearts Clubs Diamonds Spades).freeze
def initialize
reset
end
def reset
card_arr = RANKS.product(SUITS).shuffle
@deck = card_arr.map { |rank, suit| Card.new(rank, suit) }.shuffle
end
def draw
reset if @deck.em... | true |
d5e0309bedc724c66e621d625fe39d0077f13899 | Ruby | crazydays/crazydays | /ruby.edu/deck/eval/poker_eval_test.rb | UTF-8 | 3,093 | 2.9375 | 3 | [] | no_license | require 'eval/poker_eval'
require 'test/unit'
class TestPokerEvaluator < Test::Unit::TestCase
def test_score_high_card()
cards = Array.new()
cards << Card.new(Suit::SPADE, 1)
cards << Card.new(Suit::HEART, 5)
cards << Card.new(Suit::SPADE, 6)
cards << Card.new(Suit::SPADE, 7)
cards << Card.ne... | true |
0d96efdd1adf6ee587c9705796329d4fcbe32ae9 | Ruby | Lykos/cube_trainer | /app/models/training_case.rb | UTF-8 | 943 | 2.546875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
# Represents case that we train to get better on, e.g. one 3-cycle, one parity case,
# one twist case, one scramble etc.
# This contains a specific case attached to a training session with a specific solution.
# For the abstract case (independent of its solution), see Case.
class Training... | true |
6086a2764b81efb21b93bf7d7cddced1f873db6d | Ruby | javonesm89/ttt-3-display_board-example-nyc-fasttrack-082419 | /lib/display_board.rb | UTF-8 | 231 | 3.21875 | 3 | [] | no_license | # Define a method display_board that prints a 3x3 Tic Tac Toe Board
def display_board
cell = " | | "
ticTacRows = "-----------"
puts cell
puts ticTacRows
puts cell
puts ticTacRows
puts cell
end | true |
1c7b80ec5c73e8285c3c26967f08db0b2ad1f7a5 | Ruby | Dseiger83/FruitTree | /Fruit.rb | UTF-8 | 493 | 3.203125 | 3 | [] | no_license | require_relative 'Season'
require_relative 'FormPrompter'
class Fruit
def Type?
type = ['Peach(s)', 'Orange(s)', 'Grapefruit(s)', 'Pear(s)', 'Apple(s)', 'Banana(s)']
end
def Ripe?
if (Season.Summer == true or Season.Fall == true)
FormPrompter.Display 'Yum! So sweet!'
ripe = true
elsif Season.Spring =... | true |
7c14e2ede6f01b4485680147d43cac84aeebd667 | Ruby | joskid/startup_score | /lib/parser.rb | UTF-8 | 1,001 | 2.796875 | 3 | [] | no_license | require 'nokogiri'
require 'open-uri'
require 'cgi'
require 'json'
class Parser
def self.score(url)
doc = Nokogiri::HTML(open(url))
names = doc.css('.founder a.linkedin').map do |el|
(el['href'].match(%r{linkedin.com/in/(\w+)})||[])[1]
end.compact
names << (url.match(%r{angel.co/([0-9... | true |
6afdbcc3bcd21125e69d6c3fd16adc3e10a256d8 | Ruby | mrstebo/advent-of-code-2017 | /test/day_one/part_one/captcha_test.rb | UTF-8 | 677 | 2.859375 | 3 | [
"MIT"
] | permissive | require_relative '../../test_helper'
require_relative '../../../lib/day_one/part_one/captcha'
module DayOne
module PartOne
class CaptchaTest < Minitest::Test
def setup
@tester = DayOne::PartOne::Captcha.new
end
def test_first_digit_matches_second_and_third_digit_matches_forth
a... | true |
37d8f829edeec4e5d9d8a84d39745e3aeefc007f | Ruby | chiuthecoder/ruby-basic | /ruby-basic1-exercise/exercise1.8.rb | UTF-8 | 617 | 4.15625 | 4 | [] | no_license | age = 23
# if age > 21
# puts "Welcome to the party"
# else
# puts "Not yet"
# end
# number = 25
# if number % 3 == 0 && number % 5 == 0
# puts "FizzBuzz"
# elsif number % 3 == 0
# puts "Fizz"
# elsif number % 5 == 0
# puts "Buzz"
# end
# unless age < 21
# puts "Welcome to the party"
# else
# puts "Not yet"
#... | true |
d81000b4e7c30ad374e8eea3f6ed64822be110dc | Ruby | xis19/leetcode | /408.rb | UTF-8 | 394 | 3.203125 | 3 | [] | no_license | def valid_word_abbreviation(word, abbr)
wi, ai = 0, 0
wl, al = word.length, abbr.length
while wi < wl && ai < al
if word[wi] == abbr[ai]
wi += 1
ai += 1
elsif abbr[ai] =~ /[0-9]/
index = abbr[ai..-1].to_i
return false if index == 0
wi += index
ai += index.to_s.length
... | true |
7ede21c3fa033f1a91ebeff6a02b4730c1e39f75 | Ruby | morcik/learn_ruby_the_hard_way | /ex0.rb | UTF-8 | 194 | 3.015625 | 3 | [] | no_license | puts "hello World!"
puts "Hello again"
puts "I like typing this"
puts "o what the hell!"
puts "let's try the single quotes inside double quotes"
puts 'or maybe "double quotes" in single quotes.' | true |
9d3c3ac5ddaae27f85e0c275d08dd314cbe4aa5a | Ruby | MrAaronOlsen/VoltSuite | /spec/lib/core/containers/heap_spec.rb | UTF-8 | 666 | 2.78125 | 3 | [] | no_license | RSpec.describe Heap do
describe "Heap" do
it "can order in default min priority" do
heap = Heap.new
heap.add(30)
heap.add(10)
heap.add(15)
heap.add(50)
expect(heap.pop).to eq(50)
expect(heap.pop).to eq(30)
expect(heap.pop).to eq(15)
expect(heap.pop).to eq(... | true |
d77c35057b7ae8c92b5943ce47b2cef4fa693354 | Ruby | otokunaga2/RMSSimulator | /result-parser.rb | UTF-8 | 2,530 | 3.203125 | 3 | [] | no_license | require 'fileutils'
require 'csv'
require 'find'
class ResultParser
attr_reader :matched_list, :stored_hash, :number_true_positive,
:number_false_positive, :number_false_negative, :number_true_negative, :country_list
ILL=1
HEALTHY=0
RESULT_PREFIX="result"
SPECIFIC_COUNTRY_NAME=ARGV[0]
CSV_FILE... | true |
9e1904e48cf7c0ae58613b0ae71a469ab7f90d47 | Ruby | moshee/orbit | /bot.rb | UTF-8 | 2,318 | 2.515625 | 3 | [] | no_license | #!/usr/bin/env ruby -w
# encoding: UTF-8
# file: bot.rb
print "Loading dependencies... "
%w[json net/http libxml cgi htmlentities optparse yaml].each do |r|
print r + '... '
require r
end
puts
OptionParser.new do |args|
args.on('-p', '--profile [NUMBER]', 'Use config profile NUMBER (in config.yml)') { |profile|... | true |
6ab3364e233abf76bb5576c2a34524b869ab20a9 | Ruby | jan-czekawski/introduction-to-programming-exercises | /more/book_of_ruby/14_yaml/cd_db.rb | UTF-8 | 2,105 | 4.0625 | 4 | [] | no_license | require "yaml"
# array for cd objects
$cd_arr = []
# file for saving/loading
$fn = "cd_db.yml"
class CD
def initialize(arr)
@name = arr[0]
@artist = arr[1]
@num_tracks = arr[2]
end
def get_details
[@name, @artist, @num_tracks]
end
end
class PopCD < CD
def initialize(arr)
super(arr)
... | true |
97644dea9c99194b761eba1a3175d3a6c97285ff | Ruby | ElCubanoPoderoso/jruby-classloader-issue | /simple-ruby-plugin/src/main/resources/ruby/RubyImpl.rb | UTF-8 | 243 | 2.65625 | 3 | [] | no_license | 'use java'
java_import com.ruby.plugin.interfaces.RubyInterface
class RubyImpl
include RubyInterface
def initialize(stringInput)
@stringInput = stringInput
end
def doSomething()
puts @stringInput
end
end
| true |
28e94953ad2f8dd585cb798c4c8905e75b60633a | Ruby | paulkelly20/week-2-day-1-homework | /team.rb | UTF-8 | 629 | 3.171875 | 3 | [] | no_license | class Team
attr_accessor :team_name, :players, :coach
attr_writer :team_name, :players, :coach
def initialize(team_name, players, coach)
@team_name = team_name
@players = players
@coach = coach
@points = 0
end
# def team_name()
# return @team_name
# end
#
# def players()
# return @players
# end
#
# de... | true |
73ae33f82912d79bfff1c2df7a6df0f668573b37 | Ruby | RiNZL3R1/Ruby | /istisnalari_yakalamak.rb | UTF-8 | 1,448 | 3.671875 | 4 | [] | no_license | def topla(x,y)
puts x+y
rescue
puts "hata var dayiiii"
puts "bu nasil x degeri bilader duzgun yaz sunu"unless x.is_a?(Integer)
puts "bu nasil y degeri bilader duzgun yaz sunu"unless y.is_a?(Integer)
end
topla(1,"a")
puts "the end"
def bolme(x,y)
puts x/y
rescue TypeError
puts "hata var dayii... | true |
647c159ede73a3a1d958c9f736c34eb013b3e03d | Ruby | ckib16/launchschool | /exercises/101/easy5/6.rb | UTF-8 | 1,003 | 4.3125 | 4 | [] | no_license | # Letter Counter (Part 1)
#
# Write a method that takes a string with one or more space separated words and returns a hash that shows the number of words of different sizes.
#
# Words consist of any string of characters that do not include a space.
def word_sizes(input_string)
counts = Hash.new(0) # =>... | true |
e05012cb60ca59ff50c750f1648abdec7ebf8a90 | Ruby | cpdundon/ruby-collaborating-objects-lab-v-000 | /lib/song.rb | UTF-8 | 400 | 3.15625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Song
attr_accessor :name, :artist
def self.new_by_filename(filename)
line = filename.strip.slice(0, filename.length - 4)
arr = line.split(" - ")
a_name = arr[0]
s_name = arr[1]
artist = Artist.new(a_name).save
s = Song.new(s_name)
artist.add_song(s)
s.arti... | true |
833d686eba5487de412f3e0c0954df1595f5ec3e | Ruby | heroku/vault-tools | /test/pipeline_test.rb | UTF-8 | 1,598 | 3 | 3 | [
"MIT"
] | permissive | require 'helper'
class PipelineTest < Vault::TestCase
include Vault
# create a Module, Class, and lambda
def setup
super
@append_a = Module.new
@append_a.define_singleton_method(:call) do |thing|
thing << 'a'
thing
end
@append_b = Class.new
@append_b.define_singleton_method(... | true |
5c281387c100966ea6c2bc9714e01fa10f5aab04 | Ruby | softwaree40/ruby-enumerables-introduction-to-map-and-reduce-lab-online-web-prework | /lib/my_code.rb | UTF-8 | 964 | 3.3125 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def map_to_negativize(source_array)
new_array =source_array.map {|num| num * -1}
return new_array
end
def map_to_no_change(source_array)
new_array =source_array.map {|num| num}
return new_array
end
def map_to_double(source_array)
new_array =source_array.map {|num| num*2}
return new_array
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.