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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
64ead8ab488fcaebf56888881e5a7a0813f77e4f | Ruby | martinezjf2/programming-univbasics-4-array-concept-review-lab-online-web-prework | /lib/array_methods.rb | UTF-8 | 188 | 2.859375 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive |
def find_element_index(array, value_to_find)
end
def find_max_value(array)
5.times do |index|
puts index
end
def find_min_value(array)
# Add your solution here
end
| true |
ae7a84286df4c26a5f8c88a32367d49acabf6532 | Ruby | amd61/Music_Lib | /models/Album.rb | UTF-8 | 1,134 | 3.15625 | 3 | [] | no_license | require('pg')
require_relative('../db/SqlRunner')
class Album
attr_accessor :id, :title, :genre, :artist_id
def initialize(options)
@id = options['id'].to_i
@title = options['title']
@genre = options['genre']
@artist_id = options['artist_id'].to_i
end
def save()
sql = "INSERT INTO albums ( title, ge... | true |
1371008bd5c6506cac90b4cfb08ad4afc5a16c89 | Ruby | cguess/sinatra_more | /lib/sinatra_more/mailer_plugin/mail_object.rb | UTF-8 | 1,229 | 3.015625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | # This represents a particular mail object which will need to be sent
# A mail_object requires the mail attributes and the delivery_settings
module SinatraMore
class MailObject
def initialize(mail_attributes={}, smtp_settings={})
@mail_attributes = mail_attributes.dup
@smtp_settings = smtp_settings.d... | true |
fcc497dc9c837bf8258c9bd9e72da9aba7d48723 | Ruby | jakedub/ruby_blackjack | /deck.rb | UTF-8 | 586 | 3.5 | 4 | [] | no_license | require_relative 'card'
#above points to the card.rb file in the same directory
class Deck
attr_accessor :card_holder
def initialize
create_deck
shuffle_cards
end
# cretes a shuffled deck of cards in array
def create_deck
self.card_holder = []
Card.faces.each do |face|
Card.suits.each d... | true |
3c5803936ed940e727c2c4791ed9253e0b76c612 | Ruby | ReLrO/bowling | /app/models/score.rb | UTF-8 | 1,266 | 2.828125 | 3 | [] | no_license | class Score
include ActiveModel::Validations
validates_presence_of :score_string
attr_accessor :score_string
def to_key
end
def calculate score_string
score = 0
score_array = score_string.split('')
(0..score_array.length-1).each do |i|
score += point(i, ... | true |
aa88e3c5a1706832974bc0a51473fcf87b04179a | Ruby | cirosantilli-puppet/test | /a.rb | UTF-8 | 28 | 2.640625 | 3 | [] | no_license | def f(x)
return x + 1
end
| true |
60218d037ee72d43acf4889a20df3e95201b8236 | Ruby | birchlore/teachly | /spec/create_new_expert.rb | UTF-8 | 1,480 | 2.875 | 3 | [] | no_license | require './spec_helper'
describe Expert do
before :each do
@expert = Expert.new(first_name: "Matt", last_name: "Gradidge", hourly_rate: 12.00, rating: 0.0, skills: "LHL TA")
end
describe "association" do
it "expert can retrive all its reviews " do
expect{@expert.reviews}.not_to raise_error
... | true |
8f1c9f1183bb567044f234581dae674ddc83b2a5 | Ruby | leesc22/ar-sunlight-legislators | /app/main.rb | UTF-8 | 2,254 | 3.15625 | 3 | [] | no_license | require_relative 'models/representative'
require_relative 'models/senator'
# Query 1
def list_legislators_by_state(state)
puts "Senators:"
Senator.where(state: state).order(:lastname).each do |s|
puts " #{s.firstname} #{s.middlename} #{s.lastname} (#{s.party})".squeeze(" ")
end
puts "Representatives:"
Repre... | true |
901a3294666537f724ec27dd38fa786c088fa30e | Ruby | methodmissing/cb | /lib/cb.rb | UTF-8 | 1,922 | 3.15625 | 3 | [] | no_license | begin
require 'mri_callback'
rescue LoadError
end
# A simple __send__ based callback implementation, simply Object Orients
# something equivalent to:
#
# lambda { |*args| object.__send__ method, *args }
class Callback
class << self; attr_reader :extension_loaded; end
begin
cb = new(self, :instance_variable... | true |
84dae00ee09854db401e3b91f5c6ffb3408a6fe1 | Ruby | Kasvit/validator | /lib/concerns/instance_methods.rb | UTF-8 | 488 | 3.09375 | 3 | [] | no_license | module InstanceMethods
# check if all validators return true if exists
def valid?
result = if self.class.validators.any?
self.class.validators.map { |v| v.valid?(self) }
else
[]
end
result.all? {|r| r == true }
end
# check if valid? else raise an error
def validate!
... | true |
b413b2e1b57bcd2b373558c21c2ea9fb85814107 | Ruby | pivotal-cf/bookbinder | /spec/lib/bookbinder/sheller_spec.rb | UTF-8 | 1,739 | 2.84375 | 3 | [
"Apache-2.0"
] | permissive | require_relative '../../../lib/bookbinder/sheller'
module Bookbinder
describe Sheller do
it 'redirects stdout to specified target' do
sheller = Sheller.new
out = StringIO.new
sheller.run_command("echo 'hello'", out: out)
out.rewind
expect(out.read).to eq("hello\n")
end
it ... | true |
75c1bfe53387ef28d5992356f49b342be5d27305 | Ruby | collabnix/dockerlabs | /vendor/bundle/ruby/2.6.0/gems/tzinfo-1.2.9/test/tc_data_timezone.rb | UTF-8 | 2,959 | 2.6875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require File.join(File.expand_path(File.dirname(__FILE__)), 'test_utils')
include TZInfo
class TCDataTimezone < Minitest::Test
class TestTimezoneInfo < TimezoneInfo
attr_reader :utc
attr_reader :local
attr_reader :utc_to
attr_reader :utc_from
def initialize(identifier, utc_period, local_... | true |
99c72d200f5ef74e8123c4152121753e02660d2f | Ruby | sugaryourcoffee/sycsvpro-scripts | /expired_rsc.rb | UTF-8 | 2,571 | 2.9375 | 3 | [
"MIT"
] | permissive | require 'syctimeleap/time_leap'
# Extract customers with RSCs and categorize regarding expiration date
#
# :call-seq:
# sycsvpro execute expired_rsc.rb expired_rsc INFILE COUNTRY_NAME
#
# INFILE:: input csv-file sperated with colons (;) to operate on
# COUNTRY_NAME:: country-identifier for the resulting files
#
# Ex... | true |
72dff883fcf8b2c322c256780477c927f6091ba9 | Ruby | kulturbande/ricette | /test/unit/project_test.rb | UTF-8 | 535 | 2.5625 | 3 | [] | no_license | require 'test_helper'
class ProjectTest < ActiveSupport::TestCase
def setup
@project = Project.new({:title => "test"})
end
test "should be successful" do
assert @project.save, "normal save should be successful"
end
test "should not save project without title" do
project = Project.new
asser... | true |
640d0267e770d16b6be6744f5558dcd9f3c90187 | Ruby | dalalsunil1986/algorithms_ruby | /practice/quick_sort.rb | UTF-8 | 1,664 | 3.859375 | 4 | [] | no_license | # def quick_sort(arr)
# quick_sort_helper2(arr, 0, arr.length - 1)
# arr
# end
#
# def quick_sort_helper(arr, low, high)
# return if low >= high
#
# pivot = arr[high]
# pi = partition(arr, pivot, low, high)
# quick_sort_helper(arr, low, pi - 1)
# quick_sort_helper(arr, pi + 1, high)
# end
#
# def partitio... | true |
ca315b78f7025cb8fedb158b06410e8d9ffa1ed7 | Ruby | Guribot/adventofcode2020 | /day01/part2linear.rb | UTF-8 | 1,214 | 3.796875 | 4 | [] | no_license | input_file = File.open('./input/actual.txt')
THE_NUMBER = 2020
def get_total(input)
totals = {}
first_index = 0
second_index = 1
third_index = 2
len = input.size
one = input[first_index]
while second_index < len
two = input[second_index]
puts "two is #{two}"
while third_index < len
... | true |
2b0c010a3e279594c8ecab1cdabf5c91465673f9 | Ruby | pumpkincouture/gilded_rose | /lib/concert_item.rb | UTF-8 | 264 | 2.921875 | 3 | [] | no_license | require_relative 'item'
class ConcertItem < Item
def update_quality
if @sell_in <= 0
@quality = 0
elsif @sell_in <= 10
@quality += 2
elsif @sell_in <= 5
@quality += 3
else
@quality += 1
end
end
def update_sellin
@sell_in -= 1
end
end | true |
f837449752e6c062562ab589f6a35a3592a00053 | Ruby | emboss/krypt | /lib/krypt/provider/ffi/digest.rb | UTF-8 | 6,790 | 3.125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | module Krypt::FFI
##
# A Krypt::Digest implementation using FFI.
#
class Digest
include Krypt::FFI::LibC
##
# call-seq:
# Krypt::FFI::Digest.new(provider, name_or_oid) -> Digest
#
# Creates a Digest using a C struct krypt_provider as +provider+
# argument. The +provider+ is ty... | true |
e13e2fb4463e3cb4cf7834afcff5a5fbda958c97 | Ruby | cheezenaan/procon | /atcoder/arc073/c.rb | UTF-8 | 159 | 2.859375 | 3 | [] | no_license | n, t = gets.split.map(&:to_i)
ts = gets.split.map(&:to_i)
ans = t
(n - 1).times do |i|
diff = ts[i + 1] - ts[i]
ans += diff < t ? diff : t
end
puts ans
| true |
2a25aecd853a7f1f97294f67b324a4ab11023386 | Ruby | ninjapanzer/naive_pronounceable_password | /lib/letter_probability.rb | UTF-8 | 820 | 3 | 3 | [] | no_license | class LetterProbability
attr_reader :probability_hash
def initialize
@probability_hash = {}
end
def load_dictionary
file_source = 'data/noun.pnz'
File.open(file_source).each do |line|
max_length = line.length
line.chars.each_with_index do |c, i|
break if line[i+1] == "\n"
... | true |
b828af0f174bb52157b465974dae68bcc335fe23 | Ruby | joysa17/E6CP1A1 | /2 ciclos/ejercicio9.rb | UTF-8 | 412 | 3.0625 | 3 | [] | no_license | =begin
Generar el código para imprimir la siguiente tabla:
<table>
<tbody>
<tr>
<td> 1 </td>
<td> 2 </td>
<td> 3 </td>
</tr>
</tbody>
</table>
=end
a = 1
b = ' <td> 1 </td>'
c = ' <td> 2 </td>'
d = ' <td> 3 </td>'
puts '<table>'
puts ' <tbody>'
puts ' <tr>'
... | true |
ab0f8976e7f5aef70f216e353cb69308c8065c37 | Ruby | Haira505/Pythoncode | /ruby/mainfunciones.rb | UTF-8 | 590 | 3.828125 | 4 | [] | no_license | #principal
load 'funciones.rb'
ciclo = "S"
while ciclo =="S" or ciclo =="s"
print "operaciones con ruby: \n"
print "ingresa el primer numero: \n"
n1 = Integer(gets.chomp)
print "ingresa el segundo numero: \n"
n2 = Integer(gets.chomp)
print mensaje()
print "la suma es: ", suma(n1,n2),"\n"
print "la resta es: ", resta... | true |
9fc27bc35087cfb170bfa4b7c3d00fefe2a44a0b | Ruby | nicoproto/livecode | /02-OOP/cookbook-reboot/lib/view.rb | UTF-8 | 260 | 3.15625 | 3 | [] | no_license | class View
def display_all(recipes)
recipes.each_with_index do |recipe, index|
puts "#{index + 1} - #{recipe.name}: #{recipe.description}"
end
end
def ask_for(stuff)
puts "GIve me the #{stuff}, now: (please)"
gets.chomp
end
end
| true |
8446c5f799122a038f4ecdca5e5f6c7dca71ebe3 | Ruby | christoomey/plugin-ruby | /test/assign.rb | UTF-8 | 1,641 | 2.609375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
# rubocop:disable Lint/UselessAssignment, Style/ParallelAssignment
a = 1
a =
begin
2
end
a, b, c = [1, 2, 3]
a = 1, 2, 3
a, b, c = 1, 2, 3
a, *b = 1, 2, 3
a, *b, c, d = 1, 2, 3
a, * = 1, 2, 3
a = *a
(a, b), c = [1, 2], 3
* = [1, 2, 3]
*, a = [1, 2, 3]
super_super_supe... | true |
9bae9917b8498bb9a2cf9cac3e788f5346208d1f | Ruby | Shadowfiend/vico | /Support/lib/tm/save_current_document.rb | UTF-8 | 2,993 | 2.59375 | 3 | [
"BSD-2-Clause"
] | permissive | require "fileutils"
require ENV['TM_SUPPORT_PATH'] + '/lib/tm/tempfile'
VICO = ENV['TM_APP_PATH'] + '/Contents/MacOS/vicotool' unless defined? VICO
module TextMate
class << self
#
# Calling TextMate.save_current_document ensures that one of the following hold true:
# 1. If TM_FILEPATH is writeable, th... | true |
7cb86372eb472269fe314fc31749966fecdac507 | Ruby | jshopsin/phase-0-tracks | /ruby/vampires.rb | UTF-8 | 4,981 | 4.09375 | 4 | [] | no_license | # PROCESS MULTIPLE EMPLOYEES
# Ask the user how many employees will be processed, then begin the survey process for the first employee.
puts "How many employees will be processed at this time?"
employee_number = gets.chomp.to_i
# START SURVEY LOOP
=begin
The Control Flow Rubric shows ratings for using >, <, >= , o... | true |
d40d7d791f7213e2f1ee48e4d6dbb4ee03465c39 | Ruby | GiancarloZ/reverse-each-word-v-000 | /reverse_each_word.rb | UTF-8 | 243 | 3.421875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def reverse_each_word(phrase)
phrase.split.collect {|word| word.reverse}.join(" ")
end
#def reverse_each_word(phrase)
# flip = []
# flip = phrase.split(/ /)
# flip.each do |word|
# word.reverse!
# end
# flip.join(" ")
#end | true |
5894f7f0cd2cfa54a906f18348486f0211e2674f | Ruby | musiccity365/pfwtfp-stats-with-subroutines-dc-web-mod1-repeat | /spec/stats_spec.rb | UTF-8 | 1,369 | 2.984375 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'spec_helper'
INTERESTING_INTEGER_SET = [63, 60, 1, 51, 90, 69, 97, 29, 24, 62, 7, 43, 33, 79, 48, 37, 20, 94, 49, 21, 78, 28, 54, 0, 64, 18, 63, 37, 56, 56, 71, 37, 46, 33, 1, 85, 74, 99, 91, 16, 80, 32, 16, 18, 75, 55, 96, 95, 13, 37, 30, 48, 61, 33, 52, 2, 28, 36, 90, 44, 48, 59, 74, 54, 91, 21, 56, 39, 29,... | true |
88466f3bc4ba2fa8ef7fe272da6ae3a72f8bcb26 | Ruby | tvaroglu/ruby-exercises | /mythical-creatures/lib/direwolf/direwolf.rb | UTF-8 | 1,152 | 3.296875 | 3 | [] | no_license | class Direwolf
attr_accessor :name, :home, :size, :color, :starks_to_protect, :hunts_white_walkers
def initialize(name='Aenocyon Dirus', home='Beyond the Wall', size='Massive', color='White')
@name = name
@home = home
@size = size
@color = color
@starks_to_protect = Array.new
@hunts_white_w... | true |
e86459fdc718a91d1870af4a02add524bbfe557e | Ruby | nishacodes/command_line_classmates | /app.rb | UTF-8 | 2,984 | 3.6875 | 4 | [] | no_license | require './lib/scraper.rb'
require './lib/student.rb' # requires all files in lib directory
require 'launchy'
class Directory
attr_accessor :names, :twitters, :blogs, :students, :request, :student, :index
def initialize
scraper = Scraper.new("http://flatironschool-bk.herokuapp.com/")
@names = scraper.get_stude... | true |
ec5b9b0c377fceff19f74df604541ed796420cb6 | Ruby | jioherry/oop | /get_name.rb | UTF-8 | 217 | 3.84375 | 4 | [] | no_license | # sparky.get_name
class GoodDog
def initialize(name)
@name = name
end
def get_name
@name
end
def speak
"#{@name} says arf!"
end
end
sparky = GoodDog.new("Sparky")
puts sparky.speak
puts sparky.get_name | true |
9e0029efb8260e563986e2f2793b9a7e10e8ee99 | Ruby | relteq/simx | /bin/duplicate | UTF-8 | 3,341 | 2.65625 | 3 | [] | no_license | #!/usr/bin/env ruby
topdir = File.expand_path("..", File.dirname(__FILE__))
libdir = File.join(topdir, "lib")
$LOAD_PATH.unshift libdir
db_url = ARGV[0]
require 'sequel'
require 'nokogiri'
DB = Sequel.connect db_url
require 'db/model/aurora'
require 'db/model/scenario'
module Aurora
COPY_TYPES = {
'scenario' =... | true |
38446721b2012d609ba45ebe73577aad90bfab8a | Ruby | j-wilkins/short | /lib/shortener/configuration.rb | UTF-8 | 6,440 | 2.53125 | 3 | [
"WTFPL"
] | permissive | require 'uri'
require 'cgi'
require 'yaml'
require 'redis-namespace'
class Shortener
# The class for storing Configuration Information
class Configuration
class << self
def current
@current_configuration ||= Configuration.new(conf_current_placeholder: nil)
end
end
attr_accessor :o... | true |
1921b0c96067cd89131a0f3de372822195ac955a | Ruby | pol65/ExoRubySemaine1Jour2 | /exo_19.rb | UTF-8 | 104 | 2.875 | 3 | [] | no_license |
count = 2
email = ["jeandupont#{count}@gmail.com"]
while (count <= 50)
email << "jeandupont#{count}@gmail.com"
count += 2
end
puts email | true |
c18dea4a2d72c2a59fee1f9c0725334d6a37bc2e | Ruby | modelcreate/infoworks-ruby-scripts | /scripts/elevations_gb_os_ntf/lib/os_ntf_elevations/OSGroundGridCalculator.rb | UTF-8 | 1,637 | 3.1875 | 3 | [
"MIT"
] | permissive | require 'os_ntf_elevations/BilinearInterpolation'
class OSGroundGridCalculator
def initialize(tile)
@tile = tile
if @tile.spacing == 10
@rowsInDtm = 501
@modulas = 5000
else
@rowsInDtm = 401
@modulas = 20000
end
end
def ca... | true |
bfd2110a6a61558eb94caa89c5f4a3cbb761a8a7 | Ruby | karlwitek/launch_school_rb120 | /oop_exercises/easy2/nobility_further2.rb | UTF-8 | 2,171 | 4.3125 | 4 | [] | no_license |
# Further (nobility.rb)
# 1.
# This exercise can be solved in a similar manner by using inheritance; a Noble is a Person,
# and a Cheetah is a Cat, and both Persons and Cats are Animals. What changes would you need
# to make to this program to establish these relationships and eliminate the two duplicated
# #to_... | true |
b56cdce884172af988b1d9eca45d1f601928e5f3 | Ruby | yxlau/prep_ruby_challenges | /primes.rb | UTF-8 | 189 | 3.4375 | 3 | [] | no_license | def is_prime?(num)
i = 1
factors = []
while i <= num
if num % i == 0
factors << i
end
i += 1
end
if factors.length > 2
return false
end
return true
end
| true |
6b3329ac24f684a85131507697e275574b9c1e35 | Ruby | kevnIBM/transitland-datastore | /app/models/concerns/has_a_onestop_id.rb | UTF-8 | 1,094 | 2.515625 | 3 | [
"MIT"
] | permissive | module HasAOnestopId
extend ActiveSupport::Concern
included do
validates :onestop_id, presence: true
validate :onestop_id, :validate_onestop_id
def self.find_by_onestop_id!(onestop_id)
# TODO: make this case insensitive
self.find_by!(onestop_id: onestop_id)
end
def self.find_by_on... | true |
6ac24338e31a2fcbf2bd37b0a41f4d73bbb7e89b | Ruby | stacurry/ruby-challenges | /object-oriented-design/cookies-and-ovens/runner.rb | UTF-8 | 467 | 2.609375 | 3 | [] | no_license | require_relative 'cookie'
require_relative 'baker'
require_relative 'oven'
oven = Oven.new()
cc_cookie_args = {:type => "Chocolate Chip", :bake_time => 15}
pb_cookie_args = {:type => "Peanut Butter", :bake_time => 10}
Baker.place_cookies_in_oven(cc_cookie_args, 6, oven)
Baker.place_cookies_in_oven(pb_cookie_args, 6, ... | true |
c41998166865f2559dbfa9f9fbe0a96465c10b48 | Ruby | alex-solo/ruby-problems | /weekly-challenges/series.rb | UTF-8 | 1,054 | 4.71875 | 5 | [] | no_license | # Write a program that will take a string of digits and give you all the possible consecutive number series of length n in that string.
# For example, the string "01234" has the following 3-digit series:
# - 012
# - 123
# - 234
# And the following 4-digit series:
# - 0123
# - 1234
# And if you ask for a 6-digit seri... | true |
c12c3d13c72b57e543a5968689c9ed2dbcbdebef | Ruby | dngo/experiments | /app/models/pieces/queen.rb | UTF-8 | 165 | 2.8125 | 3 | [] | no_license | class Queen < Piece
SYM = "Q"
DIRECTIONS = %w(nw n ne e se s sw w)
LIMIT = 8
private
def directions
DIRECTIONS
end
def limit
LIMIT
end
end
| true |
2657601a8e708001592134fef906c9f7637aad37 | Ruby | wendelhuang/Ruby | /RubyLearning/set_cover/set_cover.rb | UTF-8 | 4,364 | 3.34375 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'set'
class Set
def cover(s)
count = 0
self.each do |element|
count += 1 if s.include?(element)
end
return count
end
end
class BuildData
def self.random_number
return rand(20) + 1
end
def self.build_data
@S = Hash.new
s_length = random... | true |
5c2a76c0b5675314bf3b716097a6239e91e58805 | Ruby | NMehmed/lift-ruby | /lib/floor.rb | UTF-8 | 622 | 3.53125 | 4 | [] | no_license | require './lib/passenger'
class Floor
attr_reader :floor_number
def initialize(queue, floor)
@floor_number = floor
@down_queue = queue.select do |passenger|
passenger.floor_number < floor
end
@up_queue = queue.select do |passenger|
passenger.floor_number > floor
end
end
def... | true |
c8c72f4bbd4daf4692f316ed68ce6b3c7a4c8d9a | Ruby | Madeline-Stark/school-domain-v-000 | /lib/school.rb | UTF-8 | 542 | 3.421875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class School
attr_accessor :name, :roster
def initialize(name)
@name = name
@roster = {}
end
def add_student(student_name, grade)
unless roster.include?(grade)
roster[grade] = []
end
roster[grade] << student_name
end
def grade(year)
roster[year]
end
def sor... | true |
1ec1b291d2302fa23db2d6d582a55bf62dda2b93 | Ruby | piotrmurach/tty-config | /spec/unit/write_spec.rb | UTF-8 | 9,804 | 2.578125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # frozen_string_literal: true
RSpec.describe TTY::Config, "#write", type: :sandbox do
it "writes configuration to a specified file" do
config = TTY::Config.new
config.set(:settings, :base, value: "USD")
config.set(:settings, :exchange, value: "CCCAGG")
config.set(:coins, value: %w[BTC TRX DASH])
... | true |
13962a6bd1cc8cc6d1187c103d21a19d2a05bdd0 | Ruby | Uthaeus/exercises | /Diner/methods.rb | UTF-8 | 218 | 2.609375 | 3 | [] | no_license | main = {
'main_course': ['Steak', 'Pizza', 'Po Boy', 'Sushi']
}
def chef_special hash
# i = hash.flatten.sample
# i.to_s
menu_items = []
hash.map { |category| menu_items << category.last }.flatten.sample
end | true |
c1a452bff976a815e322e1c615a3ccf2556913c3 | Ruby | mcormier/ppcurses | /lib/ppcurses/menu/BaseMenu.rb | UTF-8 | 1,892 | 2.765625 | 3 | [
"MIT"
] | permissive | module PPCurses
#noinspection RubyResolve
class BaseMenu
attr_accessor :menu_items
attr_accessor :selection
attr_accessor :side_wall_char
attr_accessor :top_bot_wall_char
def initialize(menu_items, action_items=nil)
@selection=0
@max_menu_width = 0
@side_wall_char = '|'
... | true |
02ac016778f8bfe42b0cbb26e402158e360c0432 | Ruby | morristech/ssl_certificate_expiration_checker | /lib/ssl_checker/expiration_checker.rb | UTF-8 | 2,810 | 3.09375 | 3 | [
"MIT"
] | permissive | require 'date'
require 'logger'
module SSLChecker
# Checks if a SSL Certificate is expired
class ExpirationChecker
attr_accessor :logger
attr_reader :deadline, :notifier
# Initializes an ExpirationChecker, with the specified deadline.
#
# @param deadline [DateTime] The date to use when evaluat... | true |
607f5f5a65fcbe885e06973b0d9b7583c5b260a5 | Ruby | plangrade/plangrade-ruby | /lib/plangrade/resources/participant.rb | UTF-8 | 2,941 | 2.53125 | 3 | [
"MIT"
] | permissive | module Plangrade
module Resources
class Participant < Plangrade::Resources::Base
attr_accessor_deffered :company_id, :employee_id, :first_name, :last_name, :street1, :street2, :city, :state, :zip, :dob, :email, :phone
def self.create(company_id, first_name, last_name, street1, street2, city, state, ... | true |
1298d747d34f06ff352db17d1a229cab870b167b | Ruby | anga/extend_at | /lib/extend_at/environment.rb | UTF-8 | 1,036 | 2.625 | 3 | [
"MIT"
] | permissive | require File.expand_path('../structure', __FILE__)
module ExtendModelAt
class Environment
def initialize
@config = {}
@config[:has_one] = {}
@config[:has_many] = {}
@config[:belongs_to] = {}
@config[:static] = false
end
def run(env=nil, model=nil)
instance_exec en... | true |
980569594e48017908c09280ce89f92a60eac330 | Ruby | CanaceWong/Oystercard_day5- | /spec/station_spec.rb | UTF-8 | 312 | 2.609375 | 3 | [] | no_license | require 'station'
describe Station do
subject(:station) { described_class.new(name: 'name', zone: 1)}
it 'is expected to display station name info as required' do
expect(station.name).to eq('name')
end
it 'is expected to display station zone info as required' do
expect(station.zone).to eq(1)
end
end
| true |
f1622c456b481f3588c69bb93e2a6daacae2e8d5 | Ruby | luprz/runa-access-control | /client/app/services/employee.rb | UTF-8 | 1,146 | 2.734375 | 3 | [] | no_license | class Employee
API = '/api/v1/employees'
def initialize(headers:)
@headers = headers
end
def find(id)
response = api.get do |req|
req.url "#{API}/#{id}"
end
render(response.body)
end
def create(employee)
response = api.post do |req|
req.url API
req.params['employee']... | true |
aeb5a4565ee37ecfd5eaaab0efe509d528cc16c5 | Ruby | jdhang/tl_precourse | /name.rb | UTF-8 | 374 | 3.65625 | 4 | [] | no_license | puts "What is your name?"
name = gets.chomp
puts "Hi! #{name}"
10.times {puts name}
puts "What is your first name?"
first_name = gets.chomp
puts "What is your last name?"
last_name = gets.chomp
puts "Hi #{first_name} #{last_name}!"
# 5. first one, x = 3, second one, it gives an error, x is out of scope
# 6. the vari... | true |
3cc95c917507b92c48eaf0e817c842f049a96936 | Ruby | bradsokol/advent-of-code-2018 | /day10.rb | UTF-8 | 1,122 | 3.578125 | 4 | [] | no_license | #! /usr/bin/env ruby
# frozen_string_literal: true
require 'pp'
require 'pry'
class Point
attr_reader :x, :y
def initialize(initial_x, initial_y, dx, dy)
@x = initial_x
@y = initial_y
@dx = dx
@dy = dy
end
def move(direction = 1)
@x += @dx * direction
@y += @dy * direction
end
end... | true |
9ef0cf24496771bc020f41a20b53200756fdfb08 | Ruby | StevenMeiklejohn/ubiquitous-guide | /class_notes/cx3-4-master/week_2/day_4/blocks/code/app_spec.rb | UTF-8 | 1,176 | 3.125 | 3 | [] | no_license | require('minitest/autorun')
require_relative('app')
class TestApp < Minitest::Test
def test_adds_one_to_each_item
assert_equal([2,3,4], add([1,2,3]))
end
def test_multiply_each_item_by_two
assert_equal([2,4,6], multiply([1,2,3]))
end
def test_map_multiply_each_item_by_two
assert_equal([2,4,6], ... | true |
7a3cdc5a7c30236f208b211b9cbfd06c7f99168c | Ruby | Ruben-Castillo/desafio_herencia_polimorfismo | /ejercicio1.rb | UTF-8 | 987 | 3.96875 | 4 | [] | no_license | class Person
attr_reader :first_name, :last_name, :age, :type
def initialize (first,last,age)
@first_name = first
@last_name = last
@age = age
end
def birthday
@age += 1
end
def talk
"Qué querí' que te diga?"
end
def introduce
"Hola, soy u... | true |
27be3a3e83df711f73fb80fcb13f91c03b90b0e8 | Ruby | Angelmmiguel/ditto_code | /lib/dittocode/parse.rb | UTF-8 | 9,796 | 2.609375 | 3 | [
"MIT"
] | permissive | require 'pry'
module DittoCode
class Parse
# Require
require 'indentation'
require 'rainbow'
require 'rainbow/ext/string'
# Initialize the environment
def initialize(override, verbose, indent)
@env = ENV["DITTOCODE_ENV"]
@override = override
@verbose = verbose
@inden... | true |
29309b7abc3aa1489efcff869e705ce4b0bb99a7 | Ruby | sbeckeriv/ahoy_email | /lib/ahoy_email/mailer.rb | UTF-8 | 869 | 2.53125 | 3 | [
"MIT"
] | permissive | module AhoyEmail
module Mailer
def self.included(base)
base.extend ClassMethods
base.class_eval do
class_attribute :ahoy_options
self.ahoy_options = {}
alias_method_chain :mail, :ahoy
end
end
module ClassMethods
def track(options)
self.ahoy_options... | true |
d9574f8254c772d3565ea0ee6e8123117816c8de | Ruby | trishume/proj | /lib/proj/library.rb | UTF-8 | 1,036 | 2.8125 | 3 | [
"MIT"
] | permissive | require "proj/project"
require "fuzzy_match"
module Proj
class Library
attr_accessor :config,:projects
def initialize(config,projects = [])
@config = config
@projects = projects
end
def add_project(proj)
@projects << proj
end
def remove_project(name)
@projects.delete_i... | true |
a3c5caa69bc086c53fe66c50ab4807d37e46f003 | Ruby | zblevine/ls-book-viewer | /book_viewer.rb | UTF-8 | 1,145 | 2.578125 | 3 | [] | no_license | require "sinatra"
require "sinatra/reloader"
require "tilt/erubis"
helpers do
def in_paragraphs(chptr)
lines = chptr.split("\n\n")
lines.each_with_index { |line, idx| line.prepend("<p id='#{idx}'>") << "</p>"}
lines.join
end
def highlight(para, str)
para.gsub(str, "<strong>" + str + "</strong>")... | true |
26219f0f11288dd6ff90a02c9e8df8ab715fb5d9 | Ruby | MooseBoost/rps-game-app-1 | /models/rps_game.rb | UTF-8 | 847 | 3.703125 | 4 | [] | no_license | class RPSGame
attr_reader :player
attr_accessor :computer_play
COMMANDS = [:paper, :scissors, :rock]
def initialize(item)
raise PlayTypeError if !COMMANDS.include?(item)
@player = item
@computer_play = COMMANDS.shuffle[0] # computer randomly picks 1 of 3
end
def won?
p = COMMANDS.index(se... | true |
63de54ef138f8f7320591bb0f0b8a061d6fcb7fa | Ruby | massud/vending-machine-kata | /lib/vending_machine.rb | UTF-8 | 792 | 3.125 | 3 | [] | no_license | class VendingMachine
VALID_COINS = ['5','10','25']
attr_reader :coin_return
def display
initialize if self.ready_to_reset
self.ready_to_reset = true if @display == 'THANK YOU'
@display
end
def initialize
self.display = 'INSERT COIN'
self.coins = []
self.ready_to_reset = false
end... | true |
918d4110e7db8283895f0e1f9962c981b421cd98 | Ruby | samnissen/WhoisXMLAPI2 | /lib/whoisxmlapi2/configuration.rb | UTF-8 | 1,123 | 2.546875 | 3 | [
"MIT"
] | permissive | module WhoisXMLAPI2
class Configuration
attr_accessor :username, :api_key, :secret, :url, :browser_key,
:mock_out_for_testing
DEFAULT_SERVICE_ENDPOINT = "https://whoisxmlapi.com/whoisserver/WhoisService?".freeze
def initialize(params = {})
apply_configuration(params)
end
... | true |
6fb797056cdce59023f56edcd567e4778dd984f8 | Ruby | rf-/advent-of-code-2020 | /day16.rb | UTF-8 | 1,637 | 2.875 | 3 | [] | no_license | require './shared'
input = File.read('day16.input')
defs = input.scan(/^(.+): (.+)-(.+) or (.+)-(.+)$/).map do |name, *bounds|
bounds = bounds.map(&:to_i)
[name, bounds[0]..bounds[1], bounds[2]..bounds[3]]
end
your_ticket = input[/your ticket:\n(.*?)\n/, 1]
.split(',').map(&:to_i)
nearby_tickets = input[/near... | true |
cdb72fdaa17154480f1ad2c29e94962dcaba365e | Ruby | KhSh2/TristeD-sespoir | /tests-ruby-master/lib/03_basics.rb | UTF-8 | 1,992 | 3.53125 | 4 | [] | no_license | def who_is_bigger(a,b,c)
arr=Array.new
arr << a
arr << b
arr << c
return arr.max
end
#puts who_is_bigger(nil, 42, 21) #à revérifier
#puts who_is_bigger(84, 42, 21)
#puts who_is_bigger(42, 84, 21)
#puts who_is_bigger(42, 21, 84)
def reverse_upcase_noLTA(var)
if var.include? ';'
b =... | true |
a5b687cdb86ac8cd3c7f6765f6ebdad3589fe2ab | Ruby | takumiabe/sphy_gmo | /lib/sphy_gmo/error_info.rb | UTF-8 | 961 | 2.640625 | 3 | [
"MIT"
] | permissive | require 'csv'
module SphyGmo
ErrorInfo = Struct.new('ErrorInfo', :code, :info, :message) do |s|
class << s
attr_accessor :all
def parse(v)
v = v.send(:error_info) if v.respond_to?(:error_info)
infos = case v
when Hash
v['ErrInfo'].split('|')
... | true |
87c2fdf7c155cd21edbe03541968c552b3c44960 | Ruby | Simo72/ruby-kickstart | /session3/challenge/6_arguments.rb | UTF-8 | 1,677 | 4.4375 | 4 | [
"MIT"
] | permissive | # Write a method, match_maker, which will receive an unknown number of
# elements, and return an array where every two elements are represented by true or false.
#
# The very first parameter will not be part of this set. Instead, it will tell
# you how to determine what their value should be.
# If it is true, then they... | true |
af3461502fb6cba9d73610ef5068cec2b0b2e71a | Ruby | uyorum/toggl_reports_v2 | /TogglReportsV2.rb | UTF-8 | 501 | 2.515625 | 3 | [] | no_license | require 'faraday'
require 'json'
class TogglReports
def initialize(api_key)
@connection = Faraday.new(url: 'https://www.toggl.com/reports/api/v2') do |faraday|
faraday.request :url_encoded
faraday.adapter Faraday.default_adapter
faraday.headers = {"Content-Type" => "application/json... | true |
6a6863999b71348d02e8a28405327f069c408451 | Ruby | greciaro/LeetCode | /1572.rb | UTF-8 | 707 | 3.75 | 4 | [] | no_license | Given a square matrix mat, return the sum of the matrix diagonals.
Only include the sum of all the elements on the primary diagonal and all the elements on the secondary diagonal that are not part of the primary diagonal.
Example 1:
Input: mat = [[1,2,3],
[4,5,6],
[7,8,9]]
... | true |
84558c0bd46d45264bd27358991d196b85f58712 | Ruby | RenaultAI/statuspagerb | /lib/statuspage-cli.rb | UTF-8 | 4,512 | 2.84375 | 3 | [
"MIT"
] | permissive | require 'rubygems'
require 'httparty'
require 'yaml'
require_relative 'statuspage'
class StatusPageCLI
COMPONENT_STATUSES = ["operational", "degraded performance", "partial outage", "major outage"]
INCIDENT_STATUSES = ["investigating", "identified", "monitoring", "resolved"]
def initialize(args=nil)
@status... | true |
9d507ed8497755d5efdcaa5e441769366b4f0403 | Ruby | interconn-isp/bollettino | /lib/bollettino/renderer/address.rb | UTF-8 | 1,027 | 2.640625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Bollettino
module Renderer
class Address < Base
class << self
def render(image, address)
render_street(image, address)
render_zip(image, address)
render_location(image, address)
end
private
def render_stree... | true |
6d568f7f2c58f2c5ffb8cff4a7119c513e0dbd69 | Ruby | rkrupnick/skillcrush-ruby | /projects/magic.rb | UTF-8 | 929 | 2.875 | 3 | [] | no_license | require 'rubygems'
require 'twilio-ruby'
account_sid = "ACfa16b33c92fb695c5b30296be3901ae9"
auth_token = "735542464031556bfee4a255f082c56c"
@client = Twilio::REST::Client.new(account_sid, auth_token)
puts "I can see into the future. And I always tell the truth..."
puts "Ask me anything: "
gets
puts "Please enter you... | true |
4e20c1ad1727f2d41977f815beb2330d56a376df | Ruby | pabloq/hash-vs-sqlite-examples | /std_names_hash.rb | UTF-8 | 348 | 2.578125 | 3 | [] | no_license | STD_NAME = {}
File.new("#{File.dirname(__FILE__)}/STD_NAMES_MASTER.csv",'r').each{|line|
record = line.gsub(/[\n\r]/,'').split(",",-1)
STD_NAME[record[0]]=[record[1],record[2]]
}
STD_NAME_FLAT = STD_NAME.to_a
def std_names_fake_like name
res = STD_NAME_FLAT.detect{|v| v[0] =~ Regexp.new("^.*(#{name}).*$")}
res||=[n... | true |
363a8b08b2e6dec988846f331140c904d57a06b1 | Ruby | swethagnath/ruby-programs | /even.rb | UTF-8 | 219 | 3.953125 | 4 | [] | no_license | # 2. Find the sum of even numbers in the array
numbers = [10,25,30,45]
sum_even = 0
numbers.each do |number|
if number.even?
sum_even += number
end
end
puts "the sum of the even numbers in the array is #{sum_even}" | true |
3e42e48da01c7e1a7f912166bbdf434b8e028507 | Ruby | stefanooldeman/hal-cli | /spec/lib/state_spec.rb | UTF-8 | 2,671 | 2.65625 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
RSpec.describe State do
let(:api) { double(:api) }
let(:setup_block) { instance_double(Proc, :setup_block) }
let(:eval_block) { instance_double(Proc, :eval_block) }
let(:next_state) do
State.new(api).tap do |a|
a.instance_variable_set(:@eval_block, eval_block)
end
end
l... | true |
8948d9b67d3cedc4b42b8a8f84b3e6ac4f8c8814 | Ruby | chiaowenlin075/Chess-game | /computer_player.rb | UTF-8 | 1,122 | 3.59375 | 4 | [] | no_license | class ComputerPlayer
attr_reader :team, :board
def initialize(board,team)
@board, @team = board, team
end
def play_turn
board.show_board
puts "Team #{team}, please choose a piece to move (ex: F2): "
from_piece = choose_from_piece
from_pos = from_piece.pos
from_pos_show = idx_to_show_po... | true |
58ccd775149b8b44ef7db2a1526b357ba14da7c1 | Ruby | wfslithtaivs/AA_Homeworks_and_Projects | /ClassesBorcsh/w1d3/wordchains.rb | UTF-8 | 1,724 | 3.65625 | 4 | [] | no_license | require "set"
class WordChainer
attr_accessor :dict, :start, :target
def initialize(filename)
@dict = Set.new(File.readlines(filename).map{|word| word.chomp})
end
def one_step(str1, str2)
diff = 0
str1.chars.each_with_index do |el, idx|
diff += 1 if el != str2[idx]
end
diff == 1
... | true |
a7e4b8d00350625cfc879fcf1cebd8862d8face8 | Ruby | saparjohnick/flatstack_task_one | /line_producer.rb | UTF-8 | 897 | 3.65625 | 4 | [] | no_license | class LineProducer
attr_reader :num_array
def initialize(num_array)
raise ArgumentError.new("nil input detected") if num_array.nil?
@num_array = num_array.to_s.chars.map(&:to_i)
end
def find_indicies
result_array = []
num_array.each_with_index do |_digit, index|
result_array.push(index)... | true |
2b55a8d0d9fc34300fb5a87a5dafc8c050805f23 | Ruby | rahulpattanshetty/ruby-programs | /assignments/highest.rb | UTF-8 | 387 | 3.71875 | 4 | [] | no_license | =begin
Input:
2
11
1 2 3 4 5 6 5 4 3 2 1
9
1 3 4 5 7 8 9 5 2
Output:
6
9
first_num = input.first
max = input.max
input.each do |num|
if num == first_num
first_num +=1
else
puts first_num-1
break
end
end
=end
#input = [1, 3, 4, 5, 7, 8, 9, 5, 2]
input = [1, 2, 3, 4, 5, 6, 5, 4, ... | true |
87098ad2bee711152a49d74bc6f70c6f2b5f36d7 | Ruby | csrgxtu/BeautifulReading | /test/bookland/lib/bookland/validators.rb | UTF-8 | 494 | 2.578125 | 3 | [
"MIT"
] | permissive | %w(ASIN EAN ISBN).each do |klass|
Object.class_eval <<-EOF
class #{klass.capitalize}Validator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
unless Bookland::#{klass}.valid?(value)
message = "is not an #{klass}"
if options[:strict]
raise Acti... | true |
726a86d9c4b2f895976858c37e03dcd195e28614 | Ruby | ericalmeng/Rails-Decal | /fa15-hw1-master/foobar.rb | UTF-8 | 275 | 3.140625 | 3 | [] | no_license | class Foobar
# Q4 CODE HERE
def self.baz(a)
a = a.map(&:to_i)
a = a.uniq
b = Array.new
for i in a
if (i % 2 == 0) && (i < 10)
b << i
end
end
sum = 0
b = b.map{|item| item+2 }
b.each { |a| sum+=a }
return sum
end
end
| true |
2f77a274d36e3d715c6b9713f78f90a80bde629b | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/rna-transcription/ede4248bac784e34b1c021c86dcb7070.rb | UTF-8 | 486 | 3.3125 | 3 | [] | no_license | class Complement
def self.dna_to_rna
{
"G" => "C",
"C" => "G",
"T" => "A",
"A" => "U"
}
end
def self.rna_to_dna
{
"C" => "G",
"G" => "C",
"A" => "T",
"U" => "A"
}
end
def self.of_dna(dna)
dereference(dna, Complement.dna_to_rna)
end
def... | true |
4d63f29e1bf9134a59fb37153aeb984dee6333da | Ruby | Raiper34/exercism-ruby | /series/series.rb | UTF-8 | 231 | 3.390625 | 3 | [] | no_license | class Series
def initialize(serieString)
@serieArray = serieString.chars
end
def slices(serieSize)
raise ArgumentError if @serieArray.length < serieSize
@serieArray.each_cons(serieSize).map(&:join)
end
end
| true |
4034f23b419161499fdfe2f83d76f0eb4b47dc75 | Ruby | kedji/socket2 | /lib/socket2.rb | UTF-8 | 1,339 | 2.703125 | 3 | [
"MIT"
] | permissive | module Socket2
VERSION = "0.1.0"
end
require 'socket'
class Socket
SIOCGIFINDEX = 0x8933 # bits/ioctls.h
SIOCGIFHWADDR = 0x8927 # linux/sockios.h
# linux/if_ether.h, needs to be native-endian uint16_t
ETH_P_ALL = [ 0x0003 ].pack('S>').unpack('S').first
# Bind a layer-2 raw socket to the given ... | true |
7d83633d17360255a7121e8b5fdf0085e8bd5ea9 | Ruby | Sebastiansc/Chess | /player.rb | UTF-8 | 346 | 3.015625 | 3 | [] | no_license | require_relative 'display'
class Player
attr_reader :name, :color
def initialize(color, name, display)
@display = display
@name = name
@color = color
end
def play_turn
pos = nil
loop do
# byebug
pos = @display.cursor.get_input
@display.render(@color)
break if pos
... | true |
00ee7a05c387cfb89152a547c898b8105330904c | Ruby | alexamy/thinknetica-ror | /oop/ui/ui.rb | UTF-8 | 889 | 3.296875 | 3 | [] | no_license | # UI helper functions
module Ui
def self.choose_from(collection)
select_in_collection(collection)
rescue StandardError => e
puts e.message
retry
end
def self.select_in_collection(collection)
print_collection(collection)
index = get_input('your option').to_i
raise 'Unknown index' unless ... | true |
77eb498d9eed0957d2ada60c6e822c5c9ec4cf38 | Ruby | UalaceCafe/ruby2d | /lib/ruby2d/font.rb | UTF-8 | 2,032 | 3.015625 | 3 | [
"MIT"
] | permissive | # Ruby2D::Font
module Ruby2D
class Font
class << self
# List all fonts, names only
def all
all_paths.map { |path| path.split('/').last.chomp('.ttf').downcase }.uniq.sort
end
# Find a font file path from its name
def path(font_name)
all_paths.find { |path| path.dow... | true |
4eb4d630d626131abb02f23175679c430d2cefa5 | Ruby | Katie-McDonagh/BB | /spec/vans_spec.rb | UTF-8 | 1,561 | 2.5625 | 3 | [] | no_license | require 'vans'
describe Van do
let(:bike) { double :bike }
let(:docking_station) { double :docking_station }
it "is passed broken bikes by the docking station" do
bike = double(:bike, broken: true)
bikes = [bike]
subject.pick_up_bike(bikes)
expect(subject.broken_bikes).to include(bike)
end
... | true |
c4ffae9834a242aad4ab5d359b3ef66ecac063c9 | Ruby | Moataz-Mahmoud/Blackjack | /card_spec.rb | UTF-8 | 929 | 3.125 | 3 | [] | no_license | require_relative 'card'
RSpec.describe Card do
before do
suit = "Diamonds"
rank = "8"
@card = Card.new(suit, rank)
end
it "responds to suit" do
expect(@card).to respond_to(:suit)
end
it "responds to rank" do
expect(@card).to respond_to(:rank)
end
... | true |
764dd7e08784a344144c86a959071fd7c6cc9b1a | Ruby | agrzelewska/AdventOfCode2019 | /day_6.rb | UTF-8 | 1,513 | 3.703125 | 4 | [] | no_license | class Orbits_Counter
attr_reader :input, :all_orbits
def initialize(input)
@input = input
end
def all_orbits_list
@all_orbits = {}
orbits = input.map { |orbit| orbit.split(')') }
orbits.map { |orbit| all_orbits.merge!( orbit[1] => orbit[0] ) }
all_orbits
end
def calculate_distance(sta... | true |
6f7d6b448d5a6d796d619f2705bd0189b3b3d788 | Ruby | anneln/fullstack-challenges | /01-Ruby/01-Programming-basics/04-Stupid-coaching/lib/interface.rb | UTF-8 | 381 | 3.625 | 4 | [] | no_license | require_relative "coach_answer"
# TODO: Implement the program that makes you discuss with your coach from the terminal.
question = gets.chomp
if question.include?("?")
puts "silly question, get dressed and go to work!"
else
puts "I don't care, get dresses and go to work!"
unless question == "I am going to work ri... | true |
30957238e0f2d98e913720a40b98175dfd44f527 | Ruby | EnmanuelCode/Ruby-javascript-python | /Ejercicios en ruby/times.rb | UTF-8 | 191 | 3.015625 | 3 | [] | no_license |
puts "iterador Times"
class Programa
def initialize()
end
def times()
50.times {puts "no hice la tarea"}
end
end
objeto = Programa.new()
objeto.times
gets() | true |
3c1b06d646fea1459d24393e12ca01e312e89423 | Ruby | avjohnston/enigma_project | /test/key_test.rb | UTF-8 | 1,061 | 3.078125 | 3 | [] | no_license | require 'simplecov'
SimpleCov.start
require 'minitest/autorun'
require 'minitest/pride'
require './lib/key'
class KeyTest < Minitest::Test
def test_it_exists_and_has_attributes
key = Key.new
key2 = Key.new('01234')
assert_instance_of Key, key
assert_equal 5, key.key.length
assert_equal '01234',... | true |
298e56c1dbefc64ed82fb2f8de405b01faf5c172 | Ruby | swi-infra/git-sync | /src/config.rb | UTF-8 | 3,749 | 2.609375 | 3 | [] | no_license | require 'yaml'
require 'ap'
class GitSync::Config
attr_reader :config
attr_reader :sources
def initialize
@config = nil
end
def load_from_file(path)
file = File.open(path)
load file.read
end
def load(yaml)
@config = YAML.load(yaml)
default_to = nil
publishers = []
# "glob... | true |
e2c1fb0c352594c556974d5c3b65c303a834da9c | Ruby | NakyungLee/forms-and-basic-associations-rails-lab-v-000 | /app/models/song.rb | UTF-8 | 614 | 2.703125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Song < ActiveRecord::Base
belongs_to :artist
belongs_to :genre
has_many :notes
def artist_name=(name)
self.artist = Artist.find_or_create_by(name:name)
end
def genre_name=(name)
self.genre = Genre.find_or_create_by(name:name)
end
def artist_name
self.artist.name if self.artist
end... | true |
d66a3f9ea0e0b93064e09d730ef3941d5d3eae72 | Ruby | groupefungo/m3uzi2 | /lib/m3uzi/specification/attribute_specification.rb | UTF-8 | 654 | 2.703125 | 3 | [
"MIT"
] | permissive | require_relative 'constraints'
module M3Uzi2
# === Description
#
class AttributeSpecification
attr_reader :name,
:contraints
def initialize(name)
@name = name
@constraints = Constraints.new
end
def create_constraint(err_msg, &block)
@constraints << Constraint.n... | true |
782de58027d80fe597ac84c61035f62cd531a0a9 | Ruby | sw-contact/LS | /small_problems/easy5/dailydouble.rb | UTF-8 | 208 | 3.34375 | 3 | [] | no_license | def crunch(str)
index = 0
new_str = ''
while index <= str.length - 1
new_str << str[index] unless str[index] == str[index + 1]
index += 1
end
new_str
end
p crunch('ddaaiillyy ddoouubbllee') | true |
fae790e27f8404aa1e34a361d150b0b375f9047f | Ruby | ccMehdi/CodeCore | /12-aug/by_five.rb | UTF-8 | 97 | 3.328125 | 3 | [] | no_license | def by_five?(number)
number % 5 == 0
end
puts by_five?(5)
puts by_five?(10)
puts by_five?(13)
| true |
c121277f3888fd1ce5e4afff1ff670aa12805dc0 | Ruby | jkrth617/data-structures-and-algorithms | /adjacency_list.rb | UTF-8 | 2,637 | 3.890625 | 4 | [
"MIT"
] | permissive | require 'pry'
class Node
attr_reader :info
attr_accessor :next
def initialize(info)
@info = info
@next = nil
end
end
class Q
attr_accessor :head
def initialize
@head = nil
end
def empty?
!head
end
def add(insert_info)#not inserting a node but rather... | true |
5a5c6af69a1d2dc15e78d69735b5b8a25fa53c6b | Ruby | denheck/PassCrypt | /lib/loader/FileLoader.rb | UTF-8 | 853 | 3.078125 | 3 | [] | no_license | # Used to process password file contents. (class methods only)
# File extension determines how it will get loaded
class FileLoader
def self.loadFile(fileName, fileContents)
begin
fileType = fileName.split('.').last
if fileType == 'yaml'
return self.loadYaml(fileContents)
else
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.