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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
59e24cd3780edd0a2f1a42eebc315111cab1f743 | Ruby | MatheusAlves00/exerAlgoritmoRuby | /ex021.rb | UTF-8 | 639 | 3.375 | 3 | [] | no_license | numero_divisivel_n, numero_ate_x, count_divisiveis = [0, 0, 0]
lista_divisiveis = Array.new
print "Entre com o valor do número para ver seus divisíveis: "
numero_divisivel_n = gets.chomp.to_i
print "Entre com o valor de X para ver o intervalo de 1 até X: "
numero_ate_x = gets.chomp.to_i
(0..numero_ate_x).each do |it... | true |
443a03c03f83f27dd97cf3c631c237628af07144 | Ruby | noda50/RubyItk | /Canvas/myCanvasTk.rb | UTF-8 | 4,238 | 2.78125 | 3 | [
"Apache-2.0"
] | permissive | ## -*- Mode:Ruby -*-
##Header:
##Title: Canvas Utility using tk
##Author: Itsuki Noda
##Type: class definition
##Date: 2004/12/01
##EndHeader:
## this is not completed to implement.
## the problem is that tk can not understand state command.
$LOAD_PATH.push(File::dirname(__FILE__)) ;
require 'tk' ;
require 'thread' ... | true |
d6c6a402351dcec69d46e8eed7881cc04808798b | Ruby | Breno-Silva1/Alien-Game | /stars.rb | UTF-8 | 421 | 2.953125 | 3 | [] | no_license | require 'gosu'
class Estrela
attr_reader :x, :y
def initialize(window)
@game = window
@x = rand(960)
@y = 0
@x2 = rand(600)
@y2 = 0
@star_green = Gosu::Image.load_tiles(@game, "media/star_green.png",36,36, false)
@current_frame = @star_green[0]
end
def draw
@current_frame.draw(@x,@y,3)
@current_... | true |
9ea610b72072c77bfae5e2acdb73ac6b557f3328 | Ruby | EricRicketts/LaunchSchool | /exercises/Ruby/small_problems/medium/two/fifth_exercise.rb | UTF-8 | 2,020 | 3.875 | 4 | [] | no_license | require 'minitest/autorun'
require 'minitest/pride'
require 'pry-byebug'
=begin
Triangle Sides
A triangle is classified as follows:
equilateral All 3 sides are of equal length
isosceles 2 sides are of equal length, while the 3rd is different
scalene All 3 sides are of different length
To be a valid triangle, the su... | true |
1186f7e3e8fe2e8952fdc74eb10b84ca7e8bc906 | Ruby | kritoke/launchschool | /Exercises/Ruby-Basics/loops_2/empty_the_array.rb | UTF-8 | 249 | 4.5 | 4 | [] | no_license | # Given the array below, use loop to remove and print each name. Stop the loop once names doesn't contain any more elements.
names = ['Sally', 'Joe', 'Lisa', 'Henry']
loop do
if names.size > 0
names.pop
p names
else
break
end
end | true |
2f012b1ae9c77110ca3c7f2083c93aedf167295a | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/cs169/800/feature686/whelper_source/18360.rb | UTF-8 | 208 | 3.140625 | 3 | [] | no_license | def combine_anagrams(words)
h = {}
r = []
words.each { |x| h[x.downcase.chars.sort.join] = [] }
words.each { |x| (h[x.downcase.chars.sort.join] << x) }
h.each { |k, v| (r << h[k]) }
return r
end
| true |
a7a949a9b5e245ec3d03832001b5c837e70b7283 | Ruby | progpyftk/webwiner | /lib/db/db_update.rb | UTF-8 | 1,024 | 2.546875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require_relative 'db_connection'
# DBUpdate: update rows at tables
class DBUpdate
def self.row(conn_params, sql_params, field, field_value, table)
string_sql(sql_params, field, field_value, table)
conn = DB::Client.new(conn_params)
conn.execute_params(@sql, @values)
end
... | true |
698d893777e8e670eeaaf7d60be0bd13210ff231 | Ruby | Gene5ive/Triangle | /lib/triangles.rb | UTF-8 | 684 | 3.171875 | 3 | [] | no_license | class Triangle
define_method(:initialize) do |side_a, side_b, side_c|
@side_a = side_a
@side_b = side_b
@side_c = side_c
end
define_method(:triangle_type) do
unless
@side_a + @side_b > @side_c &&
@side_b + @side_c > @side_a &&
@side_c + @side_a > @side_b
"Not a triang... | true |
cac893f902a6408869e33020e3882adb699c2d16 | Ruby | Seabreg/yawast | /lib/string_ext.rb | UTF-8 | 213 | 3.21875 | 3 | [
"BSD-3-Clause"
] | permissive | class String
#see if string is numeric
def is_number?
true if Float(self) rescue false
end
def trim
trimmed = self.strip
if trimmed == nil
self
else
trimmed
end
end
end
| true |
499bc360379317a4490474bfe2d7bfdbb2727e06 | Ruby | JerryMtezH/newbie-S01 | /LeerInformacionDeCSV.rb | UTF-8 | 793 | 3.46875 | 3 | [] | no_license | require 'csv'
class Person
@@personas = []
def initialize(first_name, last_name, email, phone)
@first_name = first_name
@last_name = last_name
@email = email
@phone = phone
@created_at = Time.new
@@personas << {first_name: @first_name, last_name: @last_name, email: @email, ... | true |
4f4a3c5611425943abdac553c112391d16d712c0 | Ruby | BojanapuMohan/group-app | /lib/time_range.rb | UTF-8 | 257 | 3.21875 | 3 | [] | no_license | class TimeRange
attr_accessor :start_time, :end_time
def initialize(start_time, end_time)
@start_time = start_time
@end_time = end_time
end
def overlaps?(other)
( start_time <= other.end_time && other.start_time <= end_time )
end
end
| true |
b078da5d2a0f12115423fa15c5d703a6d819ee8b | Ruby | srachal674/image-blur | /Image_Blur.rb | UTF-8 | 2,554 | 3.796875 | 4 | [] | no_license | class Image
attr_accessor :image
def initialize(image)
@image = image
end
def output_image(message = "Outputting Image")
puts message
@image.each do |a|
puts a.join(" ")
end
end
def make_copy
output = []
@image.each do |row|
row_copy = []
... | true |
619a9cbbc06ddc1e5e7fcfc7936307d82c15706a | Ruby | fs/sequence | /spec/sequence_spec.rb | UTF-8 | 622 | 2.96875 | 3 | [] | no_license | require "sequence"
describe Sequence do
let(:sequence) { Sequence.new("1") }
describe "#to_s" do
it "returns initial value" do
expect(sequence.to_s).to eql "1"
end
end
describe "#next" do
it "generates next state" do
expect(sequence.next.to_s).to eql "11"
end
it "returns Sequ... | true |
5cae36c267310c29cbd723703bc8245dad71897b | Ruby | sfb673/ruby-for-linguists | /projects/chart_parser/specs/simple_chart_parser_spec.rb | UTF-8 | 2,300 | 2.8125 | 3 | [] | no_license |
%w(lexicon lex_entry).each do |k|
require "../../mini-english/classes/#{k}"
end
%w(chart chart_entry rule rule_set simple_chart_parser).each do |k|
require "../classes/#{k}"
end
describe Chart do
before :each do
# Hier wird eine reduzierte Version von Mini-English
# eingesetzt - versuchen Sie mal, ob... | true |
a2d39c245c3b2ce51df71fdc9f7ced30e584a8db | Ruby | aluisribeiro/academico-ads | /disciplina.rb | UTF-8 | 338 | 3.15625 | 3 | [] | no_license | class Disciplina
attr_reader :nome, :modulos, :professores
def initialize (nome)
@nome = nome
@modulos = []
@professores = []
end
def add_modulo modulo
@modulos << modulo
end
def add_professor professor
@professores << profe... | true |
597776c8fb6ac661c606e8fc08e4e9d8934eae67 | Ruby | elena-ageeva/NPI-Lookup-Scraper | /lib/npi_lookup/scraper.rb | UTF-8 | 1,959 | 2.78125 | 3 | [] | no_license | require 'open-uri'
require 'pry'
class NpiLookup::Scraper
attr_accessor :doctors
@doctors=[]
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#method is responsible for scraping the index page that lists all of the students
#++++++++++++++++++++++++++++++++++++++++++++++++++++++... | true |
30116bb0b688749e4f8413a4aa0e39f3c1a33c8d | Ruby | vdice/epicodus-dealership | /lib/bicycle.rb | UTF-8 | 482 | 2.890625 | 3 | [
"MIT"
] | permissive | class Bicycle
@@bicycles = []
define_method(:initialize) do |make, bike_model, year|
@make = make
@bike_model = bike_model
@year = year
end
define_method(:make) do
@make
end
define_method(:model) do
@bike_model
end
define_method(:year) do
@year
end
define_method(:save) d... | true |
190b6d3b3c30f99c2bcf738137261827bea0ebf4 | Ruby | NULL-OPERATOR/takeaway-challenge | /lib/menu.rb | UTF-8 | 199 | 3.296875 | 3 | [] | no_license | class Menu
attr_reader :menu_list
MENU = {icecream: 5, dohnuts: 2, potatoes: 1}
def initialize(menu=MENU)
@menu_list = menu
end
def price(food)
@menu_list[food.to_sym]
end
end
| true |
139fbde9f9e4c82f5105d57596bdd24d355354d8 | Ruby | swcfischer/challenge_exercises | /protein_translation.rb | UTF-8 | 820 | 3.28125 | 3 | [] | no_license | class Translation
CODONS = { Methionine: ["AUG"], Phenylalanine: ["UUU", "UUC"], Leucine: ["UUA", "UUG"], Serine: ["UCU", "UCC", "UCA", "UCG"],
Tyrosine: ["UAU", "UAC"], Cysteine: ["UGU", "UGC"], Tryptophan: ["UGG"],
STOP: ["UAA", "UAG", "UGA"]}
def self.of_codon(codon)
CODONS.each do |key,... | true |
8f64cf7ff6fe236795e591417a64488302364dce | Ruby | Ricartho/deli-counter-noukod-000 | /deli_counter.rb | UTF-8 | 783 | 3.78125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Write your code here.
katz_deli = []
def line(katz_deli)
puts "The line is currently empty." if katz_deli.empty?
if !katz_deli.empty?
message = "The line is currently:"
katz_deli.each_with_index do |val,index|
message += " #{index.to_i+1}. #{val.strip}"
end
puts "#{message}"
end
end
def tak... | true |
b545dd19f0e003e33355d3a9e5425ce95ec48606 | Ruby | abowler2/foundations | /lesson_2/mortgage_calc.rb | UTF-8 | 1,336 | 4.34375 | 4 | [] | no_license | # Mortgage Calculator
# need loan amount
# need APR (annual percentage rate)
# need loan duration
# calculate monthly interest rate
# calculate duration in months
# formula: m = p * (j / (1 - (1 + j)**-n))
# m = monthly payment, p = loan amount,
# j = monthly interest rate, n = loan duration in months
def prompt(me... | true |
934ae3fb5d329e4ec7f32951e603b7d5316080d3 | Ruby | stockrt/latency | /latency.rb | UTF-8 | 7,176 | 2.640625 | 3 | [] | no_license | #!/usr/bin/env ruby
# coding: utf-8
# === Author
#
# Rogério Carvalho Schneider <stockrt@gmail.com>
#############
## DEFINES ##
#############
# Distributed Ruby Objects.
DRB_URL = 'druby://localhost:8787'
##############
## REQUIRES ##
##############
require 'slop'
require 'colorize'
require 'net/http'
require 'uri... | true |
bc9589b0f9eca8b091f4603396384e7abbccfeb8 | Ruby | valmikroy/lc-practice | /Arrays and Strings/Minimum Window Substring/problem.rb | UTF-8 | 2,172 | 3.375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
#
=begin
Given a string S and a string T, find the minimum window in S which will
contain all the characters in T in complexity O(n).
Example:
Input: S = "ADOBECODEBANC", T = "ABC"
Output: "BANC"
Note:
If there is no such window in S that covers all characters in T, return the
empty string "".
... | true |
be4bc5a838582b0f2cdced529b23a773b6dc0b90 | Ruby | raycast/script-commands | /templates/script-command.template.rb | UTF-8 | 900 | 2.59375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
# Raycast Script Command Template
#
# Dependency: This script requires Ruby
# Install Ruby: http://www.ruby-lang.org/
#
# Duplicate this file and remove ".template." from the filename to get started.
# See full documentation here: https://github.com/raycast/script-commands
#
# Required parameters:
... | true |
8e8ddda50dec890430c3591a02cd13fbcc720fa0 | Ruby | ECE421W17/Project2 | /part2/prototype/timer | UTF-8 | 2,188 | 3.4375 | 3 | [] | no_license | #! /usr/bin/env ruby
require 'getoptlong'
require 'test/unit/assertions'
require_relative 'messageprinter'
include Test::Unit::Assertions
def print_help
puts "timer [AMOUNT] [MESSAGE]"
# The following range was chosen because the time in seconds will be of
# time_t, which is of c type int, which can hold... | true |
cabdeda051ab09113dd61ff4d6c4dc338521615c | Ruby | Jp1200/programming-univbasics-3-labs-with-tdd-austin-web-012720 | /calculator.rb | UTF-8 | 211 | 2.71875 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # Add your variables here
first_number = 69
second_number = 12
sum = first_number+second_number
difference = first_number- second_number
product= first_number*second_number
quotient = first_number/second_number | true |
858cf2b17712eb0a69afec3025ecf565c6c2a83c | Ruby | marcwright/WDI_ATL_1_Instructors | /REPO - DC - Students/w02/d02/Salil/bank_starter/lib/bank.rb | UTF-8 | 1,482 | 3.640625 | 4 | [] | no_license | require "pry"
class Bank
attr_accessor :name
def initialize(name)
@name = name
@accounts = []
end
def accounts
return @accounts
end
def empty?
end
def open_account(name, deposit)
if deposit >= 200.0
accounts.push({:name => name, :balance => deposit})
else
puts "You ... | true |
b37035b0c7ece8e563bfe4fd098ad1ffa7b29485 | Ruby | railkun/ruby_routes_trie | /lib/trie/node.rb | UTF-8 | 402 | 3.203125 | 3 | [] | no_license | module RubyRoutesTrie
class Node
DYNAMIC = 1
STATIC = 0
attr_reader :value, :children
attr_accessor :method, :route, :type
def initialize(value)
@children = []
@value = value
@method = ''
@route = ''
@type = value[0] == ':' ? DY... | true |
6647421e89b91f83b184dcc014a1651c4bab2f30 | Ruby | kasumi8pon/nlp100 | /01.rb | UTF-8 | 82 | 2.90625 | 3 | [] | no_license | puts "パタトクカシーー".chars.map.with_index { |s, i| s if i.even? }.join
| true |
58d63881bd32546a9999768bb045b7bfa4e83a48 | Ruby | foton/egg_hunt_api | /app/models/coordinate.rb | UTF-8 | 936 | 2.921875 | 3 | [] | no_license | class Coordinate < ActiveRecord::Base
has_many :locations, dependent: :destroy
COORDINATES_REGEXP =/(\d*.\d*)([NSEW])\s*,\s*(\d*.\d*)([NSEW])/
def initialize(*args)
if args.first.kind_of?(String) && (p_match=args.first.upcase.match(COORDINATES_REGEXP))
super({latitude_number: p_match[1].to_f, latitude... | true |
8b6dd96f0b8ccde04bc4d606d15663aa1a3c8d02 | Ruby | ToccataN/rubyblock1 | /CC.rb | UTF-8 | 380 | 3.765625 | 4 | [] | no_license | puts "Phrase: "
text = gets.chomp.downcase()
puts "Number: "
n = gets.chomp.to_i
alpha = ('a'..'z').to_a
letters= text.split('').to_a
number = Hash[alpha.map.with_index.to_a]
string = []
letters.each do |i|
if number[i] == nil
string.push(" ")
else
number2= number[i] -n
newletter=alpha[number2]
strin... | true |
7a71815b8b79232db0233d97b4225f66704d61ae | Ruby | tmtmtmtm/stance-viewer-jekyll | /_bin/generate_issue_pages.rb | UTF-8 | 592 | 2.640625 | 3 | [] | no_license | #!/usr/bin/ruby
# Generate pages for each Issue
require 'json'
require 'yaml'
require 'parallel'
@data = JSON.parse(File.read('_data/issues.yaml'))
es = ARGV[0].nil? ? @data : @data.select { |e| e['id'] == ARGV[0] }
warn "Operating on #{es.count} entries"
Parallel.each(es, :in_threads => 5) do |e|
filename = "is... | true |
7926fe51b9824c41f6e0279dfb53b08be51d68fb | Ruby | jeltz/innate | /spec/innate/state/thread.rb | UTF-8 | 877 | 2.65625 | 3 | [
"MIT"
] | permissive | require 'spec/helper'
require 'innate/state/thread'
describe Innate::State::Thread do
T = Innate::State::Thread
it 'sets value in current thread with #[]=' do
t = T.new
t[:a] = :b
Thread.current[:a].should == :b
end
it 'gets value in current thread with #[]' do
t = T.new
Thread.current[:b... | true |
70602c83cab781e21e1adede04b06e280b2e911c | Ruby | Torgian/Ruby_Exercises | /ChapterOne/exercise_two.rb | UTF-8 | 101 | 2.96875 | 3 | [] | no_license | puts 5283 / 1000
puts 9832 % 1000 / 100 #hundreds
puts 8137 % 100 / 10 #tens
puts 1394 % 10 / 1 #ones | true |
4be7aa6b8ab03e28c5a1dacaf292e9ae33386eac | Ruby | zidailiu/rails-yelp-mvp | /db/seeds.rb | UTF-8 | 1,002 | 2.78125 | 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 |
693a32d4e89c90bf769b5561e44c04119702e431 | Ruby | wyy1234567/ruby-enumerables-hash-practice-emoticon-translator-lab-nyc-web-030920 | /lib/translator.rb | UTF-8 | 736 | 3.28125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # require modules here
require "yaml"
def load_library(file)
# code goes here
ans = {'get_meaning' => {}, 'get_emoticon' => {}}
emoticons = YAML.load_file(file)
emoticons.each do |key, value|
ans['get_meaning'][value[1]] = key
ans['get_emoticon'][value[0]] = emoticons[key][1]
end
ans
end
def... | true |
1c51296297bf623a721dc54e2721627fb0228673 | Ruby | din982/yard-docco | /example/annotated_source.rb | UTF-8 | 9,288 | 3.140625 | 3 | [
"MIT"
] | permissive | # An example pirate ship.
class Example
# @todo Yar! There be comments ahead, within these method. And if you are wise
# you will view the annotated source.
def a_word_of_warning
# Comments are found and collected and matched to the code that immediately
# follows the comments. You will be able... | true |
7741277c61e676750ccaeb8dec47feff256eec27 | Ruby | r3h4n/Intro_to_Programming_LS | /my_randoms/while_loop.rb | UTF-8 | 269 | 4.1875 | 4 | [] | no_license | ## Write a while loop that takes input from
## the user, performs an action, and only
## stops when the user types "STOP".
## Each loop can get info from the user.
x = gets.chomp.to_s
while x != "STOP"
puts 'Say something'
x = gets.chomp.to_s
end
puts "Done"
| true |
593e58bfaf5ddc41402cff91decd0ac0f4bd5167 | Ruby | jmcaffee/ppmtogdl | /lib/ppmtogdl/ppmcontext.rb | UTF-8 | 2,061 | 2.953125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | ###############################################################################
# File:: ppmcontext.rb
# Purpose:: PpmContext class holds ppm variable definitions
#
# Author:: Jeff McAffee 04/30/2015
#
##############################################################################
module PpmToGdl
class... | true |
061bb1e407cd94aa2593c2ce073d0acae05756ed | Ruby | TotodileNTHU/Totodile | /spec/account_spec.rb | UTF-8 | 2,660 | 2.515625 | 3 | [] | no_license | require_relative './spec_helper'
describe 'Testing unit level properties of accounts' do
before do
Posting.dataset.destroy
Account.dataset.destroy
@original_password = 'mypassword'
@account = CreateAccount.call(
name: 'soumya.ray',
email: 'sray@nthu.edu.tw',
password: @original_pa... | true |
dca98a4e3d285b2c83bc6d725767cef6025002a7 | Ruby | jamestunnell/spnet | /lib/spnet/storage/link_state.rb | UTF-8 | 1,187 | 3.03125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module SPNet
# Represent a Link object using only serializeable objects.
#
# @author James Tunnell
class LinkState
include Hashmake::HashMakeable
# Define arg specs to use in processing hashed arguments during #initialize.
ARG_SPECS = {
:from => arg_spec(:reqd => true, :type => PortLocater),
:to => ar... | true |
218fe1b338056f31e371fd9ceb3f68cc16d36c16 | Ruby | txusyk/rubyIdeas | /IMDB-Manager/test/tc_actor_catalog.rb | UTF-8 | 809 | 2.8125 | 3 | [] | no_license | require 'test/unit'
require_relative '../actor_catalog'
require_relative '../actor'
class Tc_actor_catalog < Test::Unit::TestCase
def test_initialize
assert_not_nil(Actor_catalog.instance)
p '*****'*5+'test_initialize'+'*****'*5
p 'Is Actor_catalog null? --->'+Actor_catalog.instance.nil?.to_s
end
d... | true |
3a9b55f5223d6baa211c63feda14051e70a544d4 | Ruby | TetsuyaNegishi/atcoder | /AtCoderProblems/ABC068/B.rb | UTF-8 | 98 | 3.1875 | 3 | [] | no_license | N = gets.chomp.to_i
result = 1
loop do
break if result > N
result *= 2
end
puts result / 2
| true |
5384b7abac2006dac912e61630f4b3166933180a | Ruby | JoshuaHinman/101 | /lesson3/easy1/question5.rb | UTF-8 | 58 | 3.015625 | 3 | [] | no_license | if (0..100).include?(42)
puts '42'
else
puts 'not'
end | true |
cc695439044219436d578364142f5aa03c140a9e | Ruby | christianlarwood/ruby_small_problems | /live_coding_exercises/repeated_substring_v2.rb | UTF-8 | 1,854 | 4.28125 | 4 | [] | no_license | =begin
Given a non-empty string, check if it can be constructed by taking a substring of it and appending multiple copies of the substring together. You may assume the given string consists of lowercase English letters only.
Example 1:
- Input "abab"
- Output: True
- Explanation: It's the substring 'ab' twice. ... | true |
46cebc620af81d17a6dc807a66bcfce400fde699 | Ruby | MrChriss/Ruby | /LS-ObjectOrientedProgramming-BackEnd/lesson_4/easy_1.rb | UTF-8 | 1,844 | 3.875 | 4 | [] | no_license | # Question 1
# all of the folowing are objects
# to find wich classes they belong to,
# use .class instance method of Object class.
# true.class
# => TrueClass
# "hello".class
# => String
# [1, 2, 3, "happy days"].class
# => Array
# 142.class
# => Fixnum
# Question 2
# by including the modlue Speed in the classes Car ... | true |
4cae124a1f683753f713fd628fb90732d020d74b | Ruby | hgodinot/hgodinot-Launch_School | /RB_challenges/medium_1/6.rb | UTF-8 | 549 | 3.625 | 4 | [] | no_license | class School
def initialize
@hsh = Hash.new
end
def to_h
@hsh.sort.to_h
end
def add(name, grade)
@hsh[grade].nil? ? @hsh[grade] = [name] : (@hsh[grade] << name).sort!
end
def grade(grd)
@hsh[grd] || []
end
end
# other way:
class School
attr_reader :hash
def initialize
... | true |
b4f877e74d8158a0072a81b0aa75ff860af55f10 | Ruby | miguelvieira123/BetESSEntrega | /MVC/SportEvent.rb | UTF-8 | 463 | 2.953125 | 3 | [] | no_license | class SportEvent < Object
attr_reader :event_id,:state,:team1,:team2,:result,:odd,:owner_id
def initialize(owner, event_id)
@event_id = event_id
@state = false
@team1
@team2
@result = "-"
@odd = [1.0,1.0,1.0]
@owner_id = owner
end
def setTeam1(team)
@team1 = team
end
def setState(state)
@state ... | true |
f651e897603574ae4083ba26fde0e5c0aded687f | Ruby | apavlyut/geekbrainsror | /vehicle.rb | UTF-8 | 2,976 | 3.015625 | 3 | [] | no_license | class Vehicle
def initialize(name='ТС пользователя',doors=4,weels=4,distance=30.0, reaction=1.5, coef_road=0.7)
@name=name
@doors=doors
@weels=weels
@distance=distance # дистанция до впереди идущей машины
@reaction=reaction # время реакции водителя
@status='ok'
... | true |
6889afa29677c12469dca849940c30703e6b5060 | Ruby | AlondraZepeda96/Ruby_ejemplos2 | /ejemplos/documento.rb | UTF-8 | 549 | 2.640625 | 3 | [] | no_license | clase Documento
attr_accessor : nombre , : tipo , : a ño
def initialize ( nombre , tipo , a ño)
@nombre = nombre
@tipo = tipo
@a ño = año
fin
fin
clase Libro <Documento
attr_accessor : autor
def initialize ( autor , nombre , tipo , a ño)
@autor = autor
... | true |
08c4fe13a10d2136fbc556031f2cc8d667254cd2 | Ruby | myneworder/atmosphere | /lib/atmosphere/utils.rb | UTF-8 | 2,609 | 2.96875 | 3 | [
"MIT"
] | permissive | module Atmosphere
module Utils
def min_elements_by(arr, &block)
if block_given?
min_elements_by_with_block(arr, &block)
else
min_elements_by_without_block(arr)
end
end
def max_elements_by(arr, &block)
if block_given?
max_elements_by_with_block(arr, &block)
... | true |
839982427e1ed1f6f4d5f5120d30ccd3f2f7a2d4 | Ruby | emrekutlu/bluebird | /lib/bluebird/strategies/via/strategy.rb | UTF-8 | 1,521 | 2.671875 | 3 | [
"MIT"
] | permissive | module Bluebird
module Strategies
module Via
class Strategy < Bluebird::Strategies::Base
class << self
def run(tweet, config)
if run?(config.via.username)
add_separator(tweet)
tweet.add_partial(text(config.via), :via)
end
end
... | true |
d5987ee33075c20ee507b40cf42ffc9f549c27bb | Ruby | Dalf32/AdventOfCode2015 | /Day1/day_1-2.rb | UTF-8 | 198 | 3.375 | 3 | [] | no_license | #day_1-2.rb
BASEMENT = -1
current_floor = 0
index = 0
open(ARGV.shift).each_char do |char|
index += 1
current_floor += char == '(' ? 1 : -1
break if current_floor == BASEMENT
end
puts index
| true |
7ad2920da1ff83ab08f552b0488d2cf53c3cc42e | Ruby | QPC-WORLDWIDE/rubinius | /benchmark/app/rdoc-2.4.3/lib/rdoc/any_method.rb | UTF-8 | 3,217 | 2.921875 | 3 | [
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'rdoc/code_object'
require 'rdoc/tokenstream'
##
# AnyMethod is the base class for objects representing methods
class RDoc::AnyMethod < RDoc::CodeObject
##
# Method name
attr_writer :name
##
# public, protected, private
attr_accessor :visibility
##
# Parameters yielded by the called block... | true |
c9aca1302d981ff9296d7035c46cd9ab979f8346 | Ruby | johnmartirano/speller_test | /lib/matcher.rb | UTF-8 | 5,849 | 3.328125 | 3 | [] | no_license |
# Matcher.match attempts to select best match for an input_word from
# an array of possabilities. The algorithm used is an experiment
# which attempts to determine the 'distance' between 2 words.
# This algorithm would be useless on arbitrary word comparisons but given
# the grouping of normalized words in NormHash,... | true |
5c22e9ca31c06c2cb4164d6d1f1e2d51eb03ee0c | Ruby | nitehawk/jekyll-frontadder | /lib/jekyll-frontadder.rb | UTF-8 | 1,491 | 3.265625 | 3 | [
"MIT"
] | permissive | # This Jekyll Generator plugin looks for specified hashes in a post's front matter and adds them up.
# The final result is stored into the site's data tree for use in layouts
module Jekyll
# Here's our work horse class
class JekyllFrontAdderGen < Jekyll::Generator
# Called by Jekyll to run our plugin
def ge... | true |
a34990e2911857086f3770a37b0de639262df3f4 | Ruby | MaximeKjaer/jekyll-block | /lib/jekyll-block/block_tag.rb | UTF-8 | 1,335 | 2.6875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require "jekyll"
module Jekyll
module Block
# A Jekyll Liquid {% block %} block tag that generates HTML for block-styled content.
# The content of the block can contain Markdown, which will be parsed by kramdown.
#
# Usage:
# {% block <type> ["Title"] %}
# *... | true |
b66ccd1f43229ce1738cbacd24a9e591fe6b9ebe | Ruby | mitsukan/chitter-challenge | /lib/chitter.rb | UTF-8 | 492 | 2.734375 | 3 | [] | no_license | require 'pg'
ENV["DB"] = "chitter"
class Chitter
def self.all
con = PG.connect :dbname => ENV["DB"]
result = con.exec "SELECT * FROM chitters"
result.map {|post| [post['name'], post['peep'], post['timestamp']]}
end
def self.create(params)
con = PG.connect :dbname => ENV["DB"]
time = (Time.... | true |
b187b2d4297427b4e4d610af0045e35c3ad49754 | Ruby | ruannawe/hell-triangule | /spec/message_spec.rb | UTF-8 | 382 | 2.53125 | 3 | [] | no_license | require './lib/execute'
describe Execute do
describe '#hell_triangle' do
context 'when receive valid array' do
let(:valid_array) { '[[6],[3,5],[9,7,1],[4,6,8,4]]' }
let(:valid_response) { [6,5,7,8] }
it 'has the prescribed elements in valid_response' do
expect(Execute.hell_triangle(val... | true |
22a10589e99326c1b15e0a30b1ef7c3009aeb705 | Ruby | michaelHartling/launchschool-Intro-to-Programming | /ch_04/method_num_position.rb | UTF-8 | 516 | 4.9375 | 5 | [] | no_license | # write program that takes a number from a user b/w 1 - 100 and gives back its position in blocks of 0 - 50, 51 - 100, greater than 100
def position(num)
if num < 0
puts "Number is less than zero. Try another number."
elsif num > 100
puts "Your number is greater than 100."
elsif num > 51
puts "Your n... | true |
5bde43eec13aefc24df89dc309975866c9b84e1f | Ruby | yehudamakarov/growing | /app/models/day.rb | UTF-8 | 434 | 2.6875 | 3 | [
"MIT"
] | permissive | class Day < ActiveRecord::Base
has_many :day_tasks
has_many :tasks, through: :day_tasks
def self.sunday
Day.find_by_id(1)
end
def self.monday
Day.find_by_id(2)
end
def self.tuesday
Day.find_by_id(3)
end
def self.wednesday
Day.find_by_id(4)
end
def self.thursday
Day.find_by... | true |
39a31776b3f4fd977026a4b61b1ef9bfc9bc95b5 | Ruby | evertrue/shinken-cookbook | /files/default/plugins/check_mesos_resource | UTF-8 | 1,425 | 2.546875 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/env ruby
require 'unirest'
require 'optimist'
module ShinkenPlugins
class CheckMesosResource
def run
pm = portion_resource
print("MESOS #{opts[:resource].upcase} ")
if pm > opts[:threshold].to_f
printf("CRITICAL: %.2f/1.00\n", pm)
exit 1
end
printf("OK: %... | true |
612dbbff1be89822f2071f4e33e110aa439b7bf7 | Ruby | kapelner/learnopedia | /lib/parse_and_rewrite_tools.rb | UTF-8 | 6,780 | 2.53125 | 3 | [] | no_license | module ParseAndRewriteTools
#Things that should be deleted from all wikipedia pages:
#1) The "[edit]" links
def rewrite_links_to_wikipedia_or_learnopedia(page, options)
#titles_to_id_hash = Page.all.inject({}){|hash, p| hash[p.title] = p.id; hash}
pages = Page.all
titles_to_id = Hash[pages.map{|p|... | true |
dfcca4cb227ffaeb617eaf189c564f0fd4e856f5 | Ruby | ATXkatrina/phase-0-tracks | /ruby/iteration.rb | UTF-8 | 636 | 4 | 4 | [] | no_license | def test
puts "This is a test"
yield puts "This is a second message"
end
test {puts "This is a block message"}
breakfast_foods = ["tacos", "eggs", "pancakes"]
breakfast_drinks = { milk: "white", oj: "orange", coffee: "brown" }
breakfast_foods.each do |list|
p list
end
breakfast_drinks.each do |other_list|
p... | true |
a7f27d496fb2323fd5a8f1080daf892ecfc81c1d | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/hamming/a3c7b6febd3540b49886371fd4aecb1d.rb | UTF-8 | 391 | 3.609375 | 4 | [] | no_license | class Hamming
def self.compute(strand1, strand2)
strand_length = strand1.length
difference = 0
(0..strand_length-1).each do |i| # use ruby style each instead of traditional for loop
if strand1[i] != strand2[i] # strand1[i] is the same as strand1[i,1]
difference += 1
end... | true |
27586707d9d2718b5a5323e17bc566b92cd58847 | Ruby | QPC-WORLDWIDE/ruby-ode | /tests/world.tests.rb | UTF-8 | 2,444 | 2.8125 | 3 | [
"CC-BY-4.0",
"CC-BY-1.0"
] | permissive | #!/usr/bin/ruby
$LOAD_PATH.unshift File::dirname(__FILE__)
require "odeunittest"
class World_test < ODE::TestCase
def setup
@world = ODE::World.new
end
def teardown
@world = nil
end
def test_00_new
assert_instance_of( ODE::World, @world )
end
def test_01_gravity_get
gravity = nil
assert_noth... | true |
e15820dfd658f1ee20ff08dd83d1cbeb39a7a71e | Ruby | supun/RosettaCodeData | /Task/Sorting-algorithms-Selection-sort/Ruby/sorting-algorithms-selection-sort.rb | UTF-8 | 399 | 3.78125 | 4 | [] | no_license | class Array
def selectionsort!
0.upto(length - 2) do |i|
(min_idx = i + 1).upto(length - 1) do |j|
if self[j] < self[min_idx]
min_idx = j
end
end
if self[i] > self[min_idx]
self[i], self[min_idx] = self[min_idx], self[i]
end
end
self
end
end
ary ... | true |
b16a3d64f96f6cce45e4096601921ff581a2289c | Ruby | georgian-se/pathfinder | /app/controllers/api/shortestpath_controller.rb | UTF-8 | 3,982 | 2.59375 | 3 | [] | no_license | # -*- encoding : utf-8 -*-
class Api::ShortestpathController < ApiController
def index
origins = ( if params[:from] and params[:to]
from = params[:from].split(':').map{ |x| x.to_f }
to = params[:to].split(':').map{ |x| x.to_f }
[ from, to ]
else
params[:ids].map{|x| a=x.split('/'); a[0... | true |
7fa7d8de32c7d16519282eebbb9ac38536612870 | Ruby | sunrick/kolla | /lib/kolla/display.rb | UTF-8 | 1,631 | 2.953125 | 3 | [
"MIT"
] | permissive | module Kolla
class Display
attr_accessor :options, :output, :tab_size, :tab_character, :indent_count
def initialize(opts = {})
self.options = Utils.merge(opts, Kolla.config.default_options)
self.output = options[:display][:output]
self.tab_size = options[:display][:tab_size]
self.tab_c... | true |
5ce0b02a632546d13565d291013e1725ed18d11c | Ruby | ffwu2001/ttt-8-turn-ruby-intro-000 | /lib/turn.rb | UTF-8 | 1,067 | 4.1875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def display_board( board )
puts " #{board[0]} | #{board[1]} | #{board[2]} "
puts "-----------"
puts " #{board[3]} | #{board[4]} | #{board[5]} "
puts "-----------"
puts " #{board[6]} | #{board[7]} | #{board[8]} "
end
def input_to_index( input )
input = input.to_i
input = input - 1
end
def move( board, in... | true |
0a53a396cc1598561d5bc8fa315eda86006642f3 | Ruby | dan-vernon/cookbook-sinatra | /lib/cookbook.rb | UTF-8 | 886 | 3.421875 | 3 | [] | no_license | require 'csv'
require_relative 'recipe'
require 'pry-byebug'
class Cookbook
attr_reader :recipes
def initialize(csv_file_path)
@csv = csv_file_path
@recipes = []
load_csv
end
def load_csv
CSV.foreach(@csv) do |row|
@recipes << Recipe.new(row[0], row[1])
end
end
def all
@re... | true |
e445729023eb6c4612799879e978d9f8ede70952 | Ruby | kikihakiem/word_game | /spec/word_game_spec.rb | UTF-8 | 1,415 | 2.875 | 3 | [] | no_license | require 'minitest/autorun'
require_relative 'spec_helper'
require_relative '../lib/word_game'
describe WordGame do
let(:level1_words) { %w(buku roti motor) }
let(:level2_words) { %w(kualifikasi termometer transnasional) }
let(:attempts) { %w(buuk buku roti) }
let(:input) { BogusInput.new(attempts) }
... | true |
ac109970f0da52e843d703e8004acff807905fdc | Ruby | prashantmukhopadhyay/CatRentalRequest | /db/seeds.rb | UTF-8 | 489 | 2.546875 | 3 | [] | no_license |
cat1 = Cat.new({
name: "Whiskers",
age: "3",
color: "Yellow",
sex: "M",
birthday: "09/08/2010"
}).save!
cat2 = Cat.new({
name: "Carlos",
age: "7",
color: "Black",
sex: "M",
birthday: "09/08/2006"
}).save!
request1 = CatRentalRequest.new({
cat_id: 1,
start_date: "11/11/2013",
end_date: "27/... | true |
2c50d665e4c6d69e92851df5d975d11d387eb48a | Ruby | blinded93/oo-cash-register-v-000 | /lib/cash_register.rb | UTF-8 | 777 | 3.203125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class CashRegister
attr_accessor :total, :discount, :items, :price, :last_item
def initialize(discount=0)
@total = 0
@discount = discount
@items = []
@last_item = {cost: nil, amount: nil}
end
def apply_discount
self.total = self.total*(100 - self.discount)*0.01
if self.discount ==... | true |
82bd240ea41b49777bf2fe3fa9b5f71532ab3bd9 | Ruby | Alixdb/Alixdb | /reboot/scraping.rb | UTF-8 | 1,295 | 3.421875 | 3 | [] | no_license | # on scrap l'url : https://www.etsy.com/fr/search?q=elephants
# Card => .v2-listing-card_info
# => .text-body (name)
# => .currency-value
require 'open-uri'
require 'nokogiri'
# puts "quel catégorie t'intéresse"
# ouvrir l'url pour récupérer le fichier html
# file = open(url)
# html_text = file.read
#... | true |
f28da539c2bc0c5131e9b4f434f874e0bb0936fe | Ruby | waleo/gauguin | /lib/gauguin/image.rb | UTF-8 | 1,221 | 2.90625 | 3 | [
"MIT"
] | permissive | require 'rmagick'
require 'forwardable'
module Gauguin
class Image
extend Forwardable
attr_accessor :image
delegate [:color_histogram, :columns, :rows, :write] => :image
def initialize(path = nil)
return unless path
list = Magick::ImageList.new(path)
self.image = list.first
en... | true |
3a902e664100098b6f3afe81b03c8bda0438e08a | Ruby | lawsonhung/Perfect-Desserts-Backend | /app/controllers/auth_controller.rb | UTF-8 | 13,261 | 3.234375 | 3 | [] | no_license | class AuthController < ApplicationController
# Make sure to uncomment 'bcrypt' gem in Gemfile
# $$$$$$$$$$$$$$$$$$$$$$$$$$$$ Terminal/Command Line notes
# Opens up the rails console
# $ rails c
# Creates a user with username:"kev" and password:"buffaloboy"
# > User.create(username:"kev", password:"buffalo... | true |
fda70329bfa2b0221c7e1be53cffdeec81907b8a | Ruby | jmay/pipeline | /mod/format.rb | UTF-8 | 1,049 | 2.890625 | 3 | [] | no_license | #!/usr/bin/env ruby
# Reformat the contents of columns in an NSF file
def reformat(string, format)
case format
when "MM/YYYY"
val = string.to_i
sprintf("%02d/%4d", val % 12 + 1, val / 12)
when /.*%.*f.*/
sprintf(format, string.to_f).gsub(/(\d)(?=\d{3}+(\.\d*)?[^0-9]*$)/, '\1,')
when /.*%.*d.*/
... | true |
f9f53d75909db3d67223855e00bf4f66a469003d | Ruby | lavikoder/oo-cash-register-onl01-seng-pt-120819 | /lib/cash_register.rb | UTF-8 | 1,094 | 3.53125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class CashRegister
attr_accessor :total, :discount, :items, :price, :quantity
def initialize(discount = 0)
@total = 0
@discount = discount
@quantity = quantity
@items = []
end
def add_item(title, price, quantity = 1)
@price = price
@quantity = quantity
@total += (price * quantit... | true |
86d61a7a465b38b183dc9ab78bf4114f40002986 | Ruby | dipzzzz/code-workout | /app/helpers/feedback_timeout_updater.rb | UTF-8 | 709 | 2.875 | 3 | [] | no_license | require 'thread'
require 'singleton'
class FeedbackTimeoutUpdater
include Singleton
# constants in milliseconds
MIN_THRESHOLD = 1700 # minus the 300 padding
def initialize
@semaphore = Mutex.new
@avg_timeout = 1700
end
attr_accessor :avg_timeout
# Update the feedback_timeout config value b... | true |
bd416e522d23d153434ccb8edf55f7fc311a7300 | Ruby | scifisamurai/todo | /test/unit/task_test.rb | UTF-8 | 393 | 2.546875 | 3 | [] | no_license | require 'test_helper'
class TaskTest < ActiveSupport::TestCase
test "should not save without description" do
task = Task.new
assert !task.save
end
test "should save with a description" do
task = Task.new(:description => "Buy Bread")
assert task.save
assert_not_nil Task.find_by_descri... | true |
ee1d023e43f1930d1e49443cd71c2d48e1c47b0b | Ruby | bhawani11/cucumber-ruby | /features/common/All programs/Registration .rb | UTF-8 | 2,906 | 2.578125 | 3 | [] | no_license | # load in the webdriver gem to interact with Selenium
require 'selenium-webdriver'
#Run Chrome driver.exe to get chrome browser
driver = Selenium::WebDriver.for :chrome
# use of explicit wait
wait = Selenium::WebDriver::Wait.new(:timeout => 10)
def document_initialised(driver)
driver.execute_script('return initialis... | true |
c3d718192d941585aa4daf5aeb79f448f2cc408c | Ruby | MaxfieldLewin/rails_lite | /lib/controller_base.rb | UTF-8 | 1,929 | 2.515625 | 3 | [] | no_license | require 'active_support'
require 'active_support/core_ext'
require 'erb'
require_relative './route_helper'
require_relative './view_helpers'
require_relative './flash'
require_relative './params'
require_relative './session'
require_relative './authenticity_token'
class InvalidCSRFTokenError < StandardError; end
cla... | true |
12ef4d9782e4517aac0fd2deceaac6d9605d2e04 | Ruby | rentalname/site_prism | /spec/section_spec.rb | UTF-8 | 2,453 | 2.59375 | 3 | [
"BSD-3-Clause"
] | permissive | # frozen_string_literal: true
require 'spec_helper'
describe SitePrism::Page do
describe '.section' do
context 'second argument is not a Class and a block given' do
context 'block given' do
it 'should create an anonymous section with the block' do
class PageWithSection < SitePrism::Page
... | true |
54608aeaf790a33ba692bd325118e709dd609269 | Ruby | iachettifederico/my_new_app | /app/models/user.rb | UTF-8 | 128 | 2.765625 | 3 | [] | no_license | class User < ActiveRecord::Base
def say_hello
[
"Hola,",
"you",
"soy",
name
].join(" ")
end
end
| true |
4249f48afce930e731ccc1b701db45c722a9639e | Ruby | dotsi/spree_one_page_checkout | /app/services/create_payment.rb | UTF-8 | 402 | 2.6875 | 3 | [
"BSD-3-Clause"
] | permissive | class CreatePayment
def initialize(payment_factory, payment_method)
@payment_factory = payment_factory
@payment_method = payment_method
end
def call(total, source)
payment_factory.create do |payment|
payment.amount = total
payment.payment_method = payment_method
payment.source = sou... | true |
ea83f9914f4ad27b0b65e1726b44f920156e4ecd | Ruby | clm1403/OOP | /inheritance/exercise2.rb | UTF-8 | 1,648 | 4.09375 | 4 | [] | no_license | module Towable
def can_tow(pounds)
pounds < 2000 ? true : false
end
class Vehicle
attr_accessor :color
attr_reader :year
@@num_vehicles = 0
def self.total_num_vehicles
puts "This program has created #{@@num_vehicles} vehicles"
end
def initialize
@@num_vehicles += 1
end
def initia... | true |
2b49875c727f21f26597cc0e32f034b76dfea623 | Ruby | edgcastillo/Programming_Challenges | /ruby-test/coderbyte.rb | UTF-8 | 5,767 | 4.15625 | 4 | [] | no_license | #Programming Challenges from Coderbyte.com Level: Easy
#Reverse String - reverse a string
def reverse_string(string)
return string.reverse
end
p reverse_string("hola")
#First Factorial - find the factorial of a given number
def factorial(number)
factorial = 1
(1..number).each do |x|
factorial *= x
end
return f... | true |
b779f62b87752b487bc0ae6cda7e6c71bb75f154 | Ruby | GunioRobot/ESPN.COM-scoreboard-parser | /espn_nhl_parser.rb | UTF-8 | 1,636 | 3.03125 | 3 | [] | no_license | require 'rubygems'
require 'nokogiri'
require 'open-uri'
require 'timeout'
page = nil
games = []
url = "http://espn.go.com/nhl/scoreboard" # fetch URL
begin
timeout(60) do # Exit after 60 seconds
while page.nil? do ... | true |
7db8ca3f3fe2378fce08b08c7a9cee3ca685fde8 | Ruby | idhallie/grocery-store | /lib/order.rb | UTF-8 | 3,574 | 3.609375 | 4 | [] | no_license | require 'csv'
require_relative 'customer'
require 'pry'
class Order
attr_reader :id, :customer, :fulfillment_status, :products
# Constructor
def initialize(id, products, customer, fulfillment_status = :pending)
@id = id
@products = products
@customer = customer
@fulfillment_status = fulfill... | true |
242e2e309293fdd53cc09291700f9e37addefdec | Ruby | BDCraven/learn-to-program | /chap07/ex1.rb | UTF-8 | 502 | 3.921875 | 4 | [] | no_license | bottles = 5
while bottles > 2
puts "#{bottles} bottles of beer on the wall. #{bottles} bottles of beer."
puts "Take one down and pass it around. #{bottles -1} bottles of beer on the wall."
bottles -= 1
end
puts "#{bottles} bottles of beer on the wall. #{bottles} bottle of beer."
puts "Take one down and pass it ar... | true |
8dbe0f43b1abb69002575f46c66de792d27db48c | Ruby | forest/fepfile | /lib/fepfile/transaction_detail_record.rb | UTF-8 | 4,704 | 2.828125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module FEPFileSpecification
class TransactionDetailRecord
include ActiveModel::Validations
attr_accessor :receiver_id, :routing_number, :account_type, :account_number, :effective_date,
:credit_or_debit_flag, :amount, :transaction_id
validates_presence_of :receiver_id, :routing_number, ... | true |
883f4314043db8de2da146147c2882c8d251cf51 | Ruby | bbensch09/phase-0 | /week-6/nested_data_solution.rb | UTF-8 | 2,544 | 4.09375 | 4 | [
"MIT"
] | permissive | =begin
REFLECTION
What are some general rules you can apply to nested arrays?
- In general to call values you simply use a 2nd/3rd/4th bracket notation after the first one in order to retrive values from the 2nd/3rd/4th level inner arrays.
What are some ways you can iterate over nested arrays?
- pretty much any enumer... | true |
aedc3111d39e401f8a6b165d87ed29fc221852ee | Ruby | dantarian/bladesdb | /db/fixtures/races.rb | UTF-8 | 445 | 2.515625 | 3 | [
"MIT"
] | permissive | # db/fixtures/races.rb
# Character races
Race.seed( :name ) do |r|
r.name = "Human"
r.death_thresholds = 10
end
Race.seed( :name ) do |r|
r.name = "Elf"
r.death_thresholds = 3
end
Race.seed( :name ) do |r|
r.name = "Half Elf"
r.death_thresholds = 6
end
Race.seed( :name ) do |r|
r.name = ... | true |
e86cbafa695e418151ea33f7dbed4f243f9415f1 | Ruby | incredulous/hoodwinkd | /lib/clean-html.rb | UTF-8 | 1,657 | 2.53125 | 3 | [] | no_license | class String
BASIC_TAGS = {
'a' => ['href', 'title'],
'img' => ['src', 'alt', 'title'],
'br' => [],
'i' => nil,
'u' => nil,
'b' => nil,
'pre' => nil,
'kbd' => nil,
'code' => ['lang'],
'cite' => nil,
'strong' => nil,
'em'... | true |
be014856f0b16274aa268949384ddedbbb58acb0 | Ruby | strizzwald/algorithms-and-datastructures | /test.rb | UTF-8 | 151 | 2.65625 | 3 | [] | no_license | def read_file(filename)
begin
document = File.open(filename, 'r')
document.readlines
end
end
file = ARGV[0]
puts read_file(file).inspect
| true |
178aca3e104cb698feaaf4298ab34f81c35df252 | Ruby | JeJones21/futbol | /spec/game_manager_spec.rb | UTF-8 | 2,309 | 2.96875 | 3 | [] | no_license | require 'spec_helper'
RSpec.describe GameManager do
before(:each) do
game_path = './data/games_sample.csv'
team_path = './data/teams.csv'
game_teams_path = './data/game_teams_sample.csv'
locations = {
games: game_path,
teams: team_path,
game_teams: game_teams_path
}
@game_... | true |
e56da955ca37dc9fd577b9200e0c1540cb5bc23b | Ruby | josemarialopez/codewars | /challenges/reverse_or_rotate/tests.rb | UTF-8 | 304 | 2.59375 | 3 | [
"MIT"
] | permissive | require './solution'
describe "Reverse or Rotate" do
context "Basic tests" do
it { expect(revrot("1234", 0)).to eq("") }
it { expect(revrot("", 0)).to eq("") }
it { expect(revrot("1234", 5)).to eq("") }
it { expect(revrot("733049910872815764", 5)).to eq("330479108928157") }
end
end
| true |
a1d2e46fdf6e27f9cb3e4128b2764fe470afcc2b | Ruby | greghynds/kata | /ruby/racing_car/spec/dummy_pressure.rb | UTF-8 | 146 | 3.0625 | 3 | [] | no_license | class DummyPressureSource
def initialize(pressure)
@pressure = pressure
end
def sample_pressure
@pressure
end
end | true |
421ec087dfca70318649367c1d826109a11364ca | Ruby | parryjos1/sei35-homework | /ramteen-taheri/week4/mortgage-calculator/mortgage-calculator.rb | UTF-8 | 519 | 3.6875 | 4 | [] | no_license | puts "***********************************"
puts "Welcome to the mortgage calculator."
puts ""
puts "We are going to ask you some questions."
print "What is the principal amount borrowed? $"
p_amount = gets.chomp
p_amount = p_amount.to_f
print "Enter the total number of months in repayments: "
months = gets.chomp
month... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.