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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
07f3f5389ef264614e8924c1df706e81fba00c95 | Ruby | wilsonsilva/loqate | /lib/loqate/gateway.rb | UTF-8 | 1,837 | 2.796875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'loqate/address/gateway'
require 'loqate/bank/gateway'
require 'loqate/email/gateway'
require 'loqate/geocoding/gateway'
require 'loqate/phone/gateway'
module Loqate
# Acts as a single point of entry for a defined group of API's.
class Gateway
# The gem configuration.
#
# @return [Configuration... | true |
187b10aec4912e0c9b94c644be463ea91639af51 | Ruby | ajgosling/App_Academy_Review | /Ruby/W1D2_Reference/Sudoku/game.rb | UTF-8 | 767 | 3.4375 | 3 | [] | no_license | require_relative "board.rb"
class Game
def initialize(file_name)
@board = Board.from_file(file_name)
end
def play
until @board.solved?
system("clear")
@board.render
@board.update(*prompt)
end
system("clear")
@board.render
puts "WOW, YOU SOLVED IT"
end
def prompt
... | true |
301f0ef9536209ce51afefae1e8a55e5e1b85d40 | Ruby | MarcusBullock/takeaway-challenge | /lib/menu.rb | UTF-8 | 181 | 3.265625 | 3 | [] | no_license | class Menu
attr_reader :dishes
def initialize
@dishes = {'pizza' => 4, 'chicken' => 6, 'dessert' => 3, 'drink' => 1}
end
def price(item)
@dishes[item]
end
end
| true |
2d8d9c7c46dde577db6effd0641d71e83af43efd | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/difference-of-squares/96e6955c20cb46dfad82f62a61a41609.rb | UTF-8 | 260 | 3.3125 | 3 | [] | no_license | class Squares
def self.new(n)
@ns = (1..n)
self
end
def self.square_of_sums
@ns.reduce(:+)**2
end
def self.sum_of_squares
@ns.reduce(0) { |sum, n| sum + n**2 }
end
def self.difference
square_of_sums - sum_of_squares
end
end
| true |
b5beea1715ae8749f043e3a3f8f69a3a5227115b | Ruby | shinh/test | /string_minus.rb | UTF-8 | 109 | 2.953125 | 3 | [] | no_license | class String
def -(s)
gsub(s,'')
end
end
puts "abc" - "b"
puts "abcabc" - "b"
puts "abcdef" - /b../
| true |
a12ffe9219f7faf2231f147a514e94bba3a5e786 | Ruby | afriedman886/phase-0-tracks | /ruby/alias_manager.rb | UTF-8 | 1,600 | 3.875 | 4 | [] | no_license | # Alias creator
def incognito(name)
# Swap first and last name
# Transform the string into an array
name_array = name.downcase.split(' ').reverse.join(' ').chars
# Loop through array to alter each letter value
# Push each new value to new array: shift
i = 0
shift = []
while i < name_array.length
# ... | true |
7bdb0a17a38505cb61945bfefbfa619e4833157e | Ruby | GenMaker/oo-kickstarter-online-web-sp-000 | /lib/project.rb | UTF-8 | 253 | 2.796875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require "pry"
class Project
attr_reader :title, :project, :backers
def initialize (title)
@title = title
@project
@backers = []
end
def add_backer(backers)
@backers << backers
backers.backed_projects << self
end
end
| true |
fac88d8d7576f5dadb3a08c72186afa58cea01ac | Ruby | palumbamboo/se2-groupD | /app/models/teacher.rb | UTF-8 | 601 | 2.546875 | 3 | [] | no_license | class Teacher < ApplicationRecord
attribute :name
attribute :surname
attribute :subjects, :string, array: true, default: []
belongs_to :user
has_many :assignments
has_and_belongs_to_many :school_classes, class_name: 'SchoolClass'
has_many :lectures
has_many :marks
validates :name, :surname, presenc... | true |
804580661e0f70dff66848047f1cb3e383377f69 | Ruby | squeemishly/homework | /bad_connection.rb | UTF-8 | 553 | 3.53125 | 4 | [] | no_license | ready_to_quit = false
goodbye = 0
puts "HELLO, THIS IS A GROCERY STORE!"
input = gets.chomp
until ready_to_quit
if input == ""
puts "HELLO?!"
elsif input == "GOODBYE!"
goodbye += 1
if goodbye == 1
puts "Can I do anything else for you?"
else
ready_to_quit = t... | true |
893f5a2baa69c99bb366e8f04ab2b025a6f9a44b | Ruby | Johannes-Berggren/proff.no-scraper | /scrape-contact-info.rb | UTF-8 | 1,630 | 3.453125 | 3 | [
"MIT"
] | permissive | require 'Nokogiri'
require 'spreadsheet'
require 'open-uri'
require 'highline/import'
org_nr = []
contact_information = []
puts "
This program is designed to collect phone numbers from the Norwegian business catalogue Proff.no.
Currently, this program only accepts .xls files (not .xlsx). The organization numbers mus... | true |
bc702db1102214773d034ac1eddf192723c2caa3 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/word-count/2e140b7ff7924420a448a76720f9c4f7.rb | UTF-8 | 372 | 3.421875 | 3 | [] | no_license | class Phrase
def initialize(content)
@count = calculate_word_count(content)
end
def word_count
@count
end
private
def calculate_word_count(content)
words = content.downcase.split(/[\W]/).reject(&:empty?)
uniq_words = words.uniq
count = {}
uniq_words.each do |word|
count[wo... | true |
348504757fd5b3875635226ff86e9289a51b4c0a | Ruby | seven1m/scheme-vm | /vm/char.rb | UTF-8 | 366 | 3.234375 | 3 | [
"MIT"
] | permissive | class VM
class Char
def initialize(code)
@code = code
end
def self.from_string(str)
new(str.ord)
end
def raw
@code
end
def ==(other)
return false unless other.is_a?(Char)
raw == other.raw
end
alias eq? ==
def to_s
@code.chr
end
... | true |
12b3ecc45edf7d8a1837a778b9b649ac85e91661 | Ruby | cmn53/betsy | /test/models/review_test.rb | UTF-8 | 1,427 | 2.515625 | 3 | [] | no_license | require "test_helper"
describe Review do
describe 'validations' do
before do
@review = Review.new(rating: 4, product: products(:macaron))
end
it 'can be created with all required fields' do
result = @review.valid?
result.must_equal true
end
it 'is invalid without a rating' do... | true |
de144b44b0783a3533863f4138c0fd393ee241d4 | Ruby | ULL-ESIT-LPP-1819/tdd-alu0100658705 | /spec/prct10_spec.rb | UTF-8 | 5,965 | 2.96875 | 3 | [] | no_license | RSpec.describe Prct06 do
before :each do
@persona1=Pacientes.new("Pablo",26,1,70,1.77,[],[],[],[],[],[])
@persona2=Pacientes.new("Elena",26,0,69,1.60,[],[],[],[],[],[])
@persona3=Pacientes.new("Sara",19,0,45,1.58,[],[],[],[],[],[])
@persona4=Pacientes.new("Arturo",35,1,90,1.79,[],[],[],[],[],[])
@persona5=Pa... | true |
1a5f6a92f16561d46eac4483550184c83a0ed8cd | Ruby | lunaeidi/pokemon-scraper-v-000 | /lib/pokemon.rb | UTF-8 | 461 | 3.09375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Pokemon
attr_accessor :id, :name, :type, :db, :hp
def initialize(name: ,type:,id:, db:)
@name=name
@type=type
@id=id
end
def self.save(name,type,db)
db.execute("INSERT INTO pokemon (name, type) VALUES (?, ?)", name, type)
end
def self.find(id, db)
Pokemon.new(name: "Pikachu",type... | true |
cd249d2fceacab68aa95e814ecd8117248ae9292 | Ruby | eric-dowty/game_of_life | /board.rb | UTF-8 | 7,003 | 3.640625 | 4 | [] | no_license | require 'matrix'
require './cell'
class Board
attr_accessor :board, :iteration, :cell_rows, :next_seed
def initialize
@board = seed_board
@iteration = 0
@cell_rows = []
@next_seed = seed_board
end
def seed_board(seed = [], dead_alive = [1,0])
rand_seed = Proc.new{ dead_alive.sampl... | true |
aed364bbe9f6c7e1707add2eb1d2fca2f4c93f0a | Ruby | FernandoBasso/programming-how-to | /ruby/other/codecademy/lambdas/lambda1.rb | UTF-8 | 691 | 3.703125 | 4 | [] | no_license | #!/usr/bin/env ruby -wU
#
# Like procs, lambdas are objects. The similarities don't stop there: with the
# exception of a bit of syntax and a few behavioral quirks, lambdas are
# identical to procs.
#
lambda { puts 'Hello!' }
#
# Other example.
#
def lambda_demo(a_lambda)
puts "I'm the method!"
# Call the la... | true |
5f70351d1c61ef9f64f7970d0aef3464c9375ddb | Ruby | theodi/coopy-ruby | /lib/coopy/simple_cell.rb | UTF-8 | 171 | 2.78125 | 3 | [
"MIT"
] | permissive | module Coopy
class SimpleCell
attr_accessor :datum
def initialize(datum = nil)
@datum = datum
end
def to_s
@datum.to_s
end
end
end
| true |
6acd01852179c6046b200cd6124178a8bbea237f | Ruby | skunath/STAT | /high.rb | UTF-8 | 447 | 3.265625 | 3 | [] | no_license | class High
@high_hash = {}
@high_hash["close"] = 1.0
@high_hash["semiclose"] = 0.8
@high_hash["closemid"] = 0.65
@high_hash["mid"] = 0.5
@high_hash["openmid"] = 0.35
@high_hash["semiopen"] = 0.2
@high_hash["open"] = 1.0
def initialize()
end
def self.heights()
return @high_hash.keys().sort()
... | true |
d960ac39abc9fe2e957e8d0342248343bcf17b29 | Ruby | gnagel/pr-helicopter | /lib/helicopter/notification.rb | UTF-8 | 2,091 | 2.890625 | 3 | [
"Apache-2.0"
] | permissive |
#
# Generic notification class.
# One notification might be sent to multiple channels.
#
class Helicopter
# Helicopter::Notification
class Notification
# Initializes the notifcation.
# @param {type} Type of the notification
# @param {file} Path of the touched file
# @param {pr} Link to the pull re... | true |
251d0d44e05bba30395aa7248af2e9ac34e64083 | Ruby | morganburrows/Learn_Ruby_the_Hard_Way | /ex5.rb | UTF-8 | 518 | 3.859375 | 4 | [] | no_license | name = 'Morgan T. Burrows'
age = 20 # as of May 25th 2016
height = 76.0 # inches (6ft 4in)
weight = 200.0 # lbs
eyes = 'grey'
teeth = 'white'
hair = 'brown'
puts "Lets talk about #{name}."
puts "He's #{height} inches and #{height * 2.54} centimeters tall."
puts "He's #{weight} pounds and #{weight * 0.453592} kilograms... | true |
026b8c5e25fbae24c148dac2a6876436460df277 | Ruby | grwthomps/little_shop_1908 | /spec/models/cart_spec.rb | UTF-8 | 2,104 | 2.671875 | 3 | [] | no_license | require 'rails_helper'
describe Cart, type: :model do
before :each do
@bike_shop = Merchant.create!(name: "Brian's Bike Shop", address: '123 Bike Rd.', city: 'Denver', state: 'CO', zip: 80_203)
@chain = @bike_shop.items.create!(name: 'Chain', description: "It'll never break!", price: 50, image: 'https://www.... | true |
16a2cdf39d5240e7541cc3a46325dc522c858b1a | Ruby | agsdot/xiki | /menu/html.rb | UTF-8 | 2,973 | 2.734375 | 3 | [
"MIT"
] | permissive | class Html
MENU_HIDDEN = "
.outline/
"
def self.menu_before *args
# If enter+all on blank menu, grab html from browser
if args.blank? && Keys.prefix == "all"
txt = Dom.dom(:prefix=>"all")
return txt
end
nil
end
MENU = "
| <h1>Sample</h1>
| <p>Type some html here... | true |
2e04764adac8fa7c783f729461b937f1eb656480 | Ruby | leesheppard/coding-test-sales-tax | /lib/apply_tax.rb | UTF-8 | 786 | 3.125 | 3 | [] | no_license | require_relative "../lib/input"
require_relative "../lib/import"
require_relative "../lib/calculator"
require_relative "../lib/output"
class ApplyTax
def initialize(filename)
@filename = filename
end
def input(filename)
Input.new(filename)
end
def parse(file, exclusions)
list = Import.new(file,... | true |
5b31d3919962c86213344f5798c3c418a7a42c07 | Ruby | yaboichrissyb/phase-0 | /week-4/variables-methods.rb | UTF-8 | 2,171 | 4.21875 | 4 | [
"MIT"
] | permissive | ##Links
[address](https://github.com/yaboichrissyb/phase-0/tree/master/week-4/address)
[math](https://github.com/yaboichrissyb/phase-0/tree/master/week-4/math)
###Full name greeting:
puts 'Hello there, what\'s your first name?'
first_name=gets.chomp
puts 'Cool, and your middle name?'
middle_name=gets.chomp
puts 'Nic... | true |
6b05b73cffa08efd387228ca22589a078912a65b | Ruby | dmityreus/ruby_practice | /environment/Arrays/long_words.rb | UTF-8 | 215 | 3.59375 | 4 | [] | no_license | def long_words(str)
long = []
str.each do |word|
if word.length > 4
long << word
end
end
return long
end
print long_words(["whats", "for", "dinner", "babe"]) | true |
d708f21bb65df447a49c07af88ee70558d8c56c5 | Ruby | amauris-f/nanotwitter | /service.rb | UTF-8 | 1,488 | 2.765625 | 3 | [] | no_license | require 'json'
require 'sinatra'
require 'active_record'
require "sinatra/activerecord"
require 'pry'
require './config/environments'
require './models/user'
require './models/tweet'
require './models/bond'
require './models/comment'
require './models/retweet'
# Get information about a specific user with his or her id... | true |
69859ce0f64cc24302cb0dc1f3aa361bce50cd07 | Ruby | davidwilliam/fhe-crt-ga | /app/xp.rb | UTF-8 | 911 | 2.96875 | 3 | [] | no_license | module X
class Xp
attr_accessor :primes, :c, :d, :residue
def initialize(primes,c,d)
@primes = primes
@c = c
@d = d
@residue = Residue.new(@primes,@c,@d)
end
def to_s
"{" + residue.residues.join(", ") + "}"
end
def inspect
to_s
end
def to_r
... | true |
dada19b01e6f56c5f259b9bd1164bf48b94ac331 | Ruby | redding/undies | /test/unit/raw_tests.rb | UTF-8 | 509 | 2.84375 | 3 | [
"MIT"
] | permissive | require 'assert'
require 'undies/raw'
require 'undies/template'
class Undies::Raw
class UnitTests < Assert::Context
desc 'the Raw class'
before do
@rs = Undies::Raw.new "ab&<>'\"/yz"
end
subject { @rs }
should "be a String" do
assert_kind_of ::String, subject
end
should "i... | true |
626580e3d32b5348b5c54098b17326f0e6ef4db3 | Ruby | asross/repor | /lib/repor/dimensions/time_dimension.rb | UTF-8 | 2,464 | 2.6875 | 3 | [
"MIT"
] | permissive | module Repor
module Dimensions
class TimeDimension < BinDimension
STEPS = %i(seconds minutes hours days weeks months years)
BIN_STEPS = (STEPS - [:seconds]).map { |s| s.to_s.singularize }
DURATION_PATTERN = /\A\d+ (?:#{STEPS.map{|s| "#{s}?" }.join('|')})\z/
def validate_params!
su... | true |
a840b86b751a2b968c39638c7c3d2b189ef3713a | Ruby | Alex1100/codewars | /ruby/strive_matching_one.rb | UTF-8 | 253 | 2.734375 | 3 | [] | no_license | candidate1 = { 'min_salary'=>120000 }
candidate2 = { 'min_salary'=>190000 }
job1 = { 'max_salary'=>130000 }
job2 = { 'max_salary'=>80000 }
job3 = { 'max_salary'=>171000 }
def match(candidate, job)
candidate['min_salary'] * 0.9 <= job['max_salary']
end | true |
00807aa79e7e2808637278c973f89b43893a838f | Ruby | dmullek/project_euler | /0002.rb | UTF-8 | 265 | 3.40625 | 3 | [] | no_license | int i = 1
int j = 2
int next_term = 0
numbers = [i, j]
while next_term < 4000000
next_term = i + j
numbers.insert(-1, next_term) if next_term < 4000000
i = j
j = next_term
end
numbers.delete_if {|x| x%2 != 0}
sum = 0
numbers.each {|x| sum += x}
puts sum | true |
7f0ca54d3ce21afce45cf8cad7fe3bf71339024d | Ruby | pawel2105/ruby-poetry | /tweet_n_delete.rb | UTF-8 | 946 | 3.21875 | 3 | [] | no_license | require 'twitter'
require "./paths.rb"
require 'ruby_rhymes'
require './twitter.rb' #just my twitter credentials
def rhyme?(a,b)
as = a.gsub /\W/,""
bs = b.gsub /\W/,""
as.to_phrase.rhymes.flatten.join(", ").include?(bs.to_phrase.rhymes.flatten.join(", ")) &&
(as.length + bs.length < 140)
end
file = open(RH... | true |
b17a3459a4904125561ead2f4ff070992d533e26 | Ruby | rer7891/backend_module_0_capstone | /day_3/ex29.rb | UTF-8 | 1,186 | 4.3125 | 4 | [] | no_license | people = 20
cats = 30
dogs = 15
if people < cats
puts "Too many cats! The world is doomed!"
end
if people > cats
puts "Not many cats! The world is saved!"
end
if people > dogs
puts "The world is dry!"
end
dogs += 5
if people >= dogs
puts "People are greater than or equal to dogs."
end
if people <= dogs
... | true |
a5cd62441bf6e87b8d71e64b08e9d582de869cde | Ruby | pindell-matt/complete-me | /lib/node.rb | UTF-8 | 766 | 3.609375 | 4 | [] | no_license | require 'pry'
class Node
attr_accessor :is_word, :children, :weights
def initialize(is_word = false)
@is_word = is_word
@children = Hash.new {|hash, key| hash[key] = Node.new}
@weights = Hash.new(0)
end
def insert(chars)
char = chars.shift
if chars.empty?
children[char] = Node.new... | true |
85acd690a85f81fe8efefea0cd2f1f267541ba13 | Ruby | valmar1322/valmar_ruby | /sixth_lesson/station.rb | UTF-8 | 924 | 3.4375 | 3 | [] | no_license | class Station
include InstanceCounter
include Validator
MIN_STATION_NAME_LENGTH = 3
MAX_STATION_NAME_LENGTH = 25
MIN_SYMBOLS = 'Название станции должно быть минимум 3 символа'
MAX_SYMBOLS = 'Название станции должно быть не более 25 символов'
attr_reader :trains, :name
@@stations = []
def self.all
... | true |
c26e820a153edfe5d34c6b5478b38f404205e5a9 | Ruby | cjprieb/AdventOfCode2015 | /Day10/main.rb | UTF-8 | 849 | 3.359375 | 3 | [] | no_license | require_relative 'sequence'
require 'benchmark'
Benchmark.bm do |x|
input = "1113122113"
count = 50
result = ""
x.report { result = Sequence.transform(input, count) }
puts "\t#{result} is the length of #{input} transformed #{count} times.\n"
end
# Benchmark when keeping strings in the program
# user sy... | true |
76c2cdc0766f693905322b2d98f4addef8a68380 | Ruby | nessaarruda/food_truck_event_2008 | /lib/event.rb | UTF-8 | 2,112 | 3.65625 | 4 | [] | no_license | class Event
attr_reader :name,
:food_trucks,
:date
def initialize(name)
@name = name
@food_trucks = []
@date = Date.today
end
def add_food_truck(food_truck)
@food_trucks << food_truck if !@food_trucks.include?(food_truck)
end
def food_truck_names
@food_truc... | true |
02ac518ad541de91566ee6c2e7ebd0db5d3b6308 | Ruby | Hirosvk/adt_utilit | /lib/adt_utilit/stack_queue.rb | UTF-8 | 2,831 | 3.234375 | 3 | [] | no_license | require_relative "queue"
require_relative "stack"
class StackQueue
include Enumerable
def initialize(value = nil)
@stack_a = Stack.new
@stack_b = Stack.new
if !value.nil?
if value.is_a?(Array)
value.each { |el| @stack_a.push(el) }
else
@stack_a.push(value)
end
end
... | true |
2c9fe58cbcacc5aa17126e6161e1ca9124b0e066 | Ruby | GMalzac/euler-rspec | /spec/euler_spec.rb | UTF-8 | 1,082 | 3.421875 | 3 | [] | no_license | require "./euler.rb"
describe Euler do
context "problem_1" do
it "should return a kind of integer" do
euler = Euler.new
expect(euler.problem_1(10)).to be_a_kind_of(Integer)
end
it "sums the multiples of 3 and 5 under 10" do
euler = Euler.new
expect(euler.problem_1(10)).to eq(23)... | true |
3db33fc02e44fa89e5af6d3c8a4a1b70bc66a41f | Ruby | liuffy/Time-Space-complexity-exercises | /exec_time_diff/exec_time_diff.rb | UTF-8 | 3,462 | 4.34375 | 4 | [] | no_license | # my_min
#
# Given a list of integers find the smallest number in the list.
#
# Example:
#
# list = [ 0, 3, 5, 4, -5, 10, 1, 90 ]
# my_min(list) # => -5
# Phase I
#
# First, write a function that compares each element to every other element of the list. Return the element if all other elements in the array ar... | true |
3d9aeccf1b546210baa8b80b96f263d9e1900c71 | Ruby | rewhowe/snapdragon | /src/tokenizer/lexer/token_lexers/comp_2_not_mod.rb | UTF-8 | 260 | 2.734375 | 3 | [] | no_license | module Tokenizer
class Lexer
module TokenLexers
def comp_2_not_mod?(chunk)
chunk =~ /\A(で|じゃ)?ない\z/
end
def tokenize_comp_2_not_mod(chunk)
tokenize_comp_2_mod chunk, reverse?: true
end
end
end
end
| true |
d9a78ebc025c7c72b87c0fe9ee6c5e9e74134a70 | Ruby | lucasefe/www.justoalcaer.com.ar | /_helpers.rb | UTF-8 | 2,481 | 2.78125 | 3 | [
"MIT"
] | permissive | require 'cgi'
require 'haml-coderay'
require 'lib/slugalizer'
FEED_URL = "http://www.justoalcaer.com.ar/posts.atom"
MYSPACE_URL = "http://www.myspace.com/justoalcaer"
MESES = %w(WHAT Enero Febrero Marzo Abril Mayo Junio Julio Agosto Septiembre Octubre Noviembre Diciembre)
module Helpers
def nav_link(name, link, css ... | true |
f2af8b534b213c819146567fe296ddddf62a0155 | Ruby | markkauffman22/ttt-game-status-bootcamp-prep-000 | /lib/scratch.rb | UTF-8 | 2,621 | 4.5 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # Helper Method
def position_taken?(board, index)
!(board[index].nil? || board[index] == " ")
end
# Define your WIN_COMBINATIONS constant
WIN_COMBINATIONS = [
[0,1,2], # Top row
[3,4,5], # Middle row
[6,7,8], # Bottom row
[0,3,6], # Left column
[1,4,7], # Middle column
[2,5,8], # Right c... | true |
4728d201a7215747dbcceb9524a585fa742eee5a | Ruby | rmosolgo/css_modules | /test/css_modules/assets/css_module_test.rb | UTF-8 | 2,121 | 2.5625 | 3 | [
"MIT"
] | permissive | require "test_helper"
class CSSModulesJSTest < Minitest::Test
ITEMS_LIST_ITEM = "items_5257_list-item"
ITEMS_LIST_ITEM_PRODUCTION = "i5257list-item"
def execjs_context
@execjs_context ||= begin
css_modules_js = Rails.application.assets["css_module.js"].to_s
ExecJS.compile(css_modules_js)
end... | true |
2be7db5134644a2ca4e09306a4423d019c3e3895 | Ruby | DanielFarber/wdi | /w01/d03/Classwork/hashes.rb | UTF-8 | 1,096 | 3.234375 | 3 | [] | no_license | # harry.potter@hogwarts.edu
# hermione.granger@hogwarts.edu
# ronald.weasley@hogwarts.edu
# arthur_weasley@ministryofmagic.gov.uk
# garrick@olivanderswands.co.uk
zoo = {
"Lyle" => "Giraffe",
"Belmont" => "Flamingo",
"Michael" => "Llama",
"Peter" => "Tree Frog",
"Edsel" => "Elephant"
}
zoo["Sam"] = "Lion"
zoo["Yo... | true |
d9f683ebad5a9eba85e073e9a0fafdb46fa00406 | Ruby | georgi/git_store | /test/helper.rb | UTF-8 | 237 | 2.90625 | 3 | [
"MIT"
] | permissive |
def git_show(id)
IO.popen("git show #{id}") do |io|
io.gets
end
end
def git_ls_tree(id)
lines = []
IO.popen("git ls-tree #{id}") do |io|
while line = io.gets
lines << line.split(" ")
end
end
lines
end
| true |
ece957d1685f4fcd319b3a4f6bff089d41f8cd03 | Ruby | shugo/textbringer | /lib/textbringer/input_methods/hiragana_input_method.rb | UTF-8 | 2,485 | 2.53125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Textbringer
class HiraganaInputMethod < InputMethod
HIRAGANA_TABLE = {
"a" => "あ", "i" => "い", "u" => "う", "e" => "え", "o" => "お",
"ka" => "か", "ki" => "き", "ku" => "く", "ke" => "け", "ko" => "こ",
"ga" => "が", "gi" => "ぎ", "gu" => "ぐ", "ge" => "げ", "go" => "ご... | true |
5a34efc029cbbb85cfdca02aad2b61215c686673 | Ruby | tamu222i/ruby01 | /tech-book/5/5-225.rb | UTF-8 | 97 | 2.515625 | 3 | [] | no_license | # 定数を取り除く
class MyClass
MYCONST = 1
p remove_const(:MYCONST)
p MYCONST
end
| true |
c22a4df741428d7cf47da19c706f4dd6c6328099 | Ruby | leiaj/refactoring_intro | /extra practice/finished/transaction.rb | UTF-8 | 509 | 3.078125 | 3 | [] | no_license |
class Transaction
attr_accessor :product, :city, :discount
def initialize(product, city, discount)
@product = product
@city = city
@discount = discount || NullObject
end
def tax_rate
if @product.is_taxable
return @city.sales_tax_rate / 100.0 + 1
end
return 1
end
def discoun... | true |
109c3f70a3458b891acca1c77de45cebc99d6134 | Ruby | takeshita0531/rub_webcamp | /lesson2.rb | UTF-8 | 91 | 2.75 | 3 | [] | no_license | # 確認問題
puts "私の名前は竹下林です。年齢は" + 24.to_s + "歳です。" | true |
1d5aa913860d7d55216596147a8ff404e2a9a9e4 | Ruby | mluts/mini-nrepl | /lib/mini_nrepl/nrepl/op.rb | UTF-8 | 1,772 | 2.65625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'set'
require 'mini_nrepl/logging'
module MiniNrepl
class Nrepl
# Represends single nrepl operation
class Op
include Logging
Erorr = Class.new(StandardError)
attr_reader :name, :desc
# @param name [String] Operation name as was in "describe" re... | true |
ec8a57cb893621a8e13709e7cdbb0eda2a7b4c9c | Ruby | jykim/lifidea | /rubylib/ir/language_model.rb | UTF-8 | 1,718 | 2.953125 | 3 | [] | no_license | # LanguageModel Library
# - Initialize from Frequency Distribution
class LanguageModel
attr_accessor :f, :p, :size, :ql, :text
PTN_TERM = /[A-Za-z0-9]+/
def initialize(input, o = {})
#return if !text
#puts "#{input.inspect}"
@ql = {} # cache of query likelihood
@f = case input.class.to_s
when ... | true |
2744fb58032802d1ed0f3570d947994b0c79c44b | Ruby | WhiteShay/emails_scrapps_POO | /lib/scrapper.rb | UTF-8 | 2,514 | 3.140625 | 3 | [] | no_license | class Scrapper
require 'rubygems'
require 'nokogiri'
require 'json'
require 'csv'
require 'google_drive'
#1 Première méthode : Collecte de l'email d'une mairie d'une ville du Val d'Oise
def get_townhall_email(townhall_url)
#/ on indique un site URL neutre qui sera indiqué dans la pr... | true |
42b73b4f2f3467bec12938666c3368303177bf89 | Ruby | c-Nosetab/change_machine | /fizzbuzz.rb | UTF-8 | 2,435 | 3.734375 | 4 | [] | no_license | require 'rspec'
class Fizzbuzz
def output(number)
return 'FizzBuzz' if number % 15 == 0
return 'Buzz' if number % 5 == 0
return 'Fizz' if number % 3 == 0
number
end
def go
(1..100).each do |number|
puts output(number)
end
end
end
count = Fizzbuzz.new
count.go
RSpec.descr... | true |
13cdec39a7dfb6d1eef4626b4c96c48ca0c7876d | Ruby | adamwight/merge-migrate | /lib/row.rb | UTF-8 | 1,502 | 2.8125 | 3 | [] | no_license | class Row
attr_reader :id, :row, :table
def ==(other)
if ignore = @table.ignored_columns
cut_row = @row.reject { |key, value| return ignore.include?(key) }
cut_other = other.row.reject { |key, value| return ignore.include?(key) }
return cut_row == cut_other
e... | true |
da38eee6351012e6f6026b28b13849d558d2f6be | Ruby | jkr2255/jsrt.rb | /lib/jsrt/values/string_value.rb | UTF-8 | 892 | 2.890625 | 3 | [
"MIT"
] | permissive | require 'jsrt/value'
module JSRT
module Values
# class for String value.
class StringValue < JSRT::Value
def to_ruby
# freeze as JavaScript string is immutable
@ruby_value ||= handle2str(handle).freeze
end
def type
:string
end
def to_i
to_ruby.to... | true |
a5acf94be4587d0e19604684deff054449ee10f2 | Ruby | amital/products-catalog | /Catalog.rb | UTF-8 | 3,675 | 3.0625 | 3 | [
"Apache-2.0"
] | permissive | require 'json'
class Product
attr_accessor :name
attr_accessor :price
attr_accessor :on_stock
def initialize (name, price, on_stock)
@name = name
@price = price
@on_stock = on_stock
end
def Add_Attribute(attr, value)
self.class.class_eval { attr_accessor attr }
send("#{... | true |
2d843b9ead14262fe175c7adccce029592ce45fc | Ruby | nathanbaliteau/morpion | /lib/app/application.rb | UTF-8 | 491 | 2.890625 | 3 | [] | no_license | class Application
def perform
puts "\n ----------------------------------------"
puts " | Bienvenue dans ce MORPION de l'enfer ! |"
puts " ----------------------------------------"
game = Game.new
view = Show.new
while game.game_status == "game_on"
view.show_board(game.board)
... | true |
cbc5d32ce74babc806b2b2900847eb8499b9516d | Ruby | Hadeweka/Shidacea | /demo_projects/Example_Shooter/scripts/basics/Ship.rb | UTF-8 | 3,457 | 2.546875 | 3 | [
"MIT"
] | permissive | module ShooterTest
class Ship < SDC::Entity
# Define new properties
self.define_class_property :max_health, default: 10
self.define_class_property :shield, default: 0
self.define_class_property :weapon, default: nil
self.define_class_property :drive, default: :CombustionDrive
self.define_class_property :s... | true |
b430dec7b0a042c8166c12728e18f3881d1b48de | Ruby | MIKEALGEE/pub-classes | /specs/pub_specs.rb | UTF-8 | 1,369 | 3.078125 | 3 | [] | no_license | require("minitest/rg")
require("minitest/autorun")
require_relative("../food.rb")
require_relative("../pub.rb")
require_relative("../drinks.rb")
require_relative("../customers.rb")
class PubTest < MiniTest::Test
def setup
@drink1 = Drinks.new("Punk IPA", 4.6, 0.04)
@drink2 = Drinks.new("Guinness", 5.2, 0.... | true |
a5306e7dc51c14e282d6a0a8603b4fd63fc61ff0 | Ruby | kabligh/bowling-challenge-ruby | /lib/frame.rb | UTF-8 | 432 | 3.296875 | 3 | [] | no_license | class Frame
STARTING_PINS = 10
attr_reader :rolls, :remaining_pins
def initialize(frame_num, previous_frame)
@previous_frame = previous_frame
@rolls = []
@remaining_pins = STARTING_PINS
end
def roll(pins)
if !played?
@remaining_pins -= pins
@rolls.push(pins)
end
end
de... | true |
c44289a95f71b4c2ef2b8a41dd949ab60994320a | Ruby | chantebryana/RubyHangman | /RubyHangmanTesting02.rb | UTF-8 | 1,639 | 4.28125 | 4 | [] | no_license | #P1 enters the hangman word:
print "P1, enter a single real English word, then press ENTER: " #(P1 inputs whole word, presses ENTER)
word = gets.chomp.downcase
letter = word.scan(/./) # => ["q", "u", "a", "s", "h"]
letterTally = letter.length #a potential marker for winning condition?
guessArray = []
#create enough n... | true |
5ea56123fe553f5805d61143ec60d666db089667 | Ruby | thebravoman/software_engineering_2014 | /class004/Marian_Belchev_Class4_2.rb | UTF-8 | 635 | 2.921875 | 3 | [] | no_license | hash = Hash.new{|name, tasks| name[tasks] = Array.new}
Dir.glob("#{ARGV[0]}/*.*") do |file|
firstName = file.split("/").last.split("_").first
lastName = file.split("/").last.split("_", 2).last.split("_").first
taskNumber = file.split("_").last.split(".").first
if taskNumber.to_i.to_s == taskNumber
if taskNumber.... | true |
7f460beb118eb4454e4aa309b1996713da9e7c60 | Ruby | maxgrok/trainer_domain | /trainer.rb | UTF-8 | 443 | 2.984375 | 3 | [] | no_license | class Trainer
attr_accessor :name, :appointments
@@all = []
def initialize(name)
@name = name
@appointments = []
end
def self.all
@@all
end
def add_appointment(appointment)
@appointments << appointment
#belongs to trainer
appointment.trainer = self
end
#has many clients th... | true |
68f70c2a0c4a8f7d97a9edbac133ecdb2d2042a7 | Ruby | matiasmasca/ProbandoRuby | /Elefantes.rb | UTF-8 | 715 | 3.921875 | 4 | [] | no_license | #Canción de los Elefantes.
#Escribir un programa que muestre la letra de la canción de los 2 elefantes.
#Se escribe veía y araño... pero hasta que sepa como meter un non US-ASCII va veia y arania
elefantes = 1
puts(elefantes.to_s + " elefante se balanceaba")
puts("sobre la tela de una arania")
puts("y como veia que re... | true |
909412515aaa98a8ff201b6f196e10984ad97e52 | Ruby | ZoeBai0714/activerecord-associations-intro-houston-web-career-021819 | /Rakefile | UTF-8 | 731 | 2.921875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require_relative 'config/environment.rb'
require "sinatra/activerecord/rake"
desc "starts console"
task :console do
Pry.start
end
=begin
The model that has_many is considered the parent.
The model that belongs_to is considered the child.
If you tell the child that it belongs to the parent, the parent won't know a... | true |
5b34553fa2fd733b3066c64ccbe56c21c904c709 | Ruby | hunaba/Ruby- | /TestRuby/exo05.rb | UTF-8 | 1,009 | 4.0625 | 4 | [] | no_license | puts "On va compter le nombre d'heures de travail à THP" #puts permet d'afficher
puts "Travail : #{10 * 5 * 11}" # les symboles #{} permettent de concatener un entier dans un string
puts "En minutes ça fait : #{10 * 5 * 11 * 60}" # l'asterisque permet de multiplier, ça affiche le nombre d'heures/minutes/secondes travai... | true |
ab8bc22a0103c5f3b3cd1d41a2c7cc1282d85eb4 | Ruby | wvanbergen/assistly_api | /lib/assistly/api/result.rb | UTF-8 | 807 | 2.859375 | 3 | [] | no_license | module Assistly
module API
class Result
include Enumerable
attr_reader :results, :total, :count, :page
def initialize(hash, klass)
@total = hash['total'].to_i
@count = hash['count'].to_i
@page = hash['page'].to_i
return unless hash['results']
... | true |
69a32901bb5ca16a95c09537f6fd6d5f5f312e2e | Ruby | ssaekoo/Code-Eval | /Penultimate Word.rb | UTF-8 | 108 | 3.171875 | 3 | [] | no_license | def penultimate_word(line)
line.split(' ')[-2]
end
ARGF.lines do |line|
puts penultimate_word(line)
end | true |
ae6c17d26804c6d75c43adaff863a3d1dee775fd | Ruby | nicolefederici/pre-work-on_lomax | /lib/scraper.rb | UTF-8 | 1,177 | 2.90625 | 3 | [] | no_license | require_relative 'recording.rb'
require 'open-uri'
require 'nokogiri'
class Scraper
def self.get_places
doc = Nokogiri::HTML(open('https://www.loc.gov/collections/alan-lomax-in-michigan/index/location/'))
places_array = []
doc.css(".index li").each do |item|
city_hash = {}
city_hash[:name] =... | true |
a58aa0f5976bafaeb24a29336ab22f2f2f4d124d | Ruby | zquestz/startpoint | /app/models/setting.rb | UTF-8 | 738 | 2.59375 | 3 | [] | no_license | class Setting
# Access all settings through the method missing
def self.method_missing(method, *args)
begin
super(method, *args)
rescue
app_settings[method.to_s]
end
end
# Get application settings from default YAML file and merge with
# environment YAML file.
def self.app_sett... | true |
6cf63763228b2223d479b6536af4d704dfa7e64e | Ruby | white1033/ProjectEuler | /Ruby/081.rb | UTF-8 | 458 | 3.203125 | 3 | [] | no_license | #!/usr/bin/env ruby -wKU
grid = []
File.foreach('matrix.txt') { |line| grid << line.split(/,/).map(&:to_i) }
(0 ... grid.size).reverse_each do |i|
(0 ... grid.size).reverse_each do |j|
next if i == grid.size - 1 && j == grid.size - 1
if i == grid.size - 1
min = grid[i][j+1]
elsif j == grid.size - ... | true |
22b1fa717280b1ee871c228c89de1c28e09554e6 | Ruby | sunnyshah2894/portfolio_app | /app/models/company.rb | UTF-8 | 389 | 2.609375 | 3 | [] | no_license | class Company < ActiveRecord::Base
has_many :investments
validate :symbol_length_should_be_less
def symbol_length_should_be_less
if symbol.length <3 or symbol.length>4
errors.add :symbol,'should be either 3 or 4 lettered'
end
end
validate :should_be_positive
def should_be_positive
if price... | true |
05cbc734cbfdc65b4b56669ecba63b39bf2f90dc | Ruby | rhomobile/rhodes | /spec/framework_spec/app/spec/library/digest/hmac_spec.rb | UTF-8 | 2,497 | 2.734375 | 3 | [
"MIT"
] | permissive | require "hmac-md5"
require "hmac-sha1"
describe "Hmac" do
it "should pass s_digest" do
key = "\x0b" * 16
text = "Hi There"
hmac = HMAC::MD5.new(key)
hmac.update(text)
hmac.digest.should == HMAC::MD5.digest(key, text)
end
it "should pass s_hexdigest" do
... | true |
5fa29dccf207c13dd039ac4c8e6105cff0f4e4ab | Ruby | Kris-LIBIS/LIAS_Ingester | /lib/tools/string.rb | UTF-8 | 1,344 | 2.78125 | 3 | [] | no_license | # coding: utf-8
class String
def blank?
self == ''
end
def sort_form
result = []
matcher = /^(\D*)(\d*)(.*)$/
self.split('.').each { |s|
while !s.empty? and (x = matcher.match s)
a = x[1].to_s.strip
b = a.gsub(/[ _]/, '')
result << [b.downcase, b, a]
result... | true |
0fa84bcd66ef119063d700d0e5c021ecf2546a2f | Ruby | colmarius/depot | /db/seeds.rb | UTF-8 | 1,692 | 2.90625 | 3 | [] | no_license | Product.delete_all
Product.create!(title: 'Web Development with Clojure',
description:
%{<p>
If the usual patchwork of web development tools and languages
just isn't cutting it for you, you need Web Development With Clojure.
Clojure gives you the rich infrastructure of the JVM with the
ex... | true |
769086cc0b329ec5a89febd601c0579289a2475c | Ruby | tsbuck/ruby_practice | /practice.rb | UTF-8 | 637 | 3.71875 | 4 | [] | no_license | #for reference
def sorted?(array)
array.each_with_index do |value, index|
if (index < (array.length - 1)) && (array[index] > array[index + 1])
return false
end
end
true
end
def bubble_sort(array)
sorted_array = array
until sorted?(sorted_array)
helper_array = sorted_array
helper_array.each_with_index... | true |
ef7dea00efef20c1c875097e34d51e9c9e9af5bd | Ruby | OlgaEva/movie_buff | /bin/run.rb | UTF-8 | 8,727 | 2.640625 | 3 | [] | no_license | require_relative '../config/environment'
require_relative '../script.rb'
require 'pry'
require 'json'
require 'tty-prompt'
require 'colorize'
require 'omdb/api'
ActiveRecord::Base.logger = nil
class MovieBuff
puts "Welcome to Movie Buff!".colorize(:red)
puts "
/\\
... | true |
96ef243d151b0055b8c60f7649ae6e4aab3dadf7 | Ruby | kzazarashvili/HackerRank | /Regex/2-HackerRank-tweets/solution.rb | UTF-8 | 146 | 3.265625 | 3 | [] | no_license | def check line
line =~ /hackerrank/i
end
n = gets.to_i
hackerrenk = 0
n.times do
hackerrenk += 1 if check(gets.to_s)
end
puts hackerrenk | true |
a873067c7cd3f56552cbc2aac50d5294d3f74d5b | Ruby | seanmsmith23/matasano-crypto | /lib/set-1/parse_string.rb | UTF-8 | 204 | 3.0625 | 3 | [] | no_license | class ParseString
attr_reader :contents
def initialize(filepath)
opened = File.open(filepath)
@contents = File.read(opened)
end
def split_by_newline
@contents.split("\n")
end
end | true |
89d4352f2aa301478aad5caa58cef90be78d29d7 | Ruby | zluo16/ttt-10-current-player-ruby-intro-000 | /lib/current_player.rb | UTF-8 | 311 | 3.703125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def turn_count(board)
occupied = 0
board.each do |cell|
if cell == "X" || cell == "O"
occupied += 1
end
end
return occupied
end
def current_player(board)
turn_count = turn_count(board)
unless turn_count == 0 || turn_count % 2 == 0
player = "O"
else
player = "X"
end
end
| true |
0e78a36e84a9e7bf87e1c1b6d6d0d16c3842a1a4 | Ruby | jimmyjchen/rails-mister-cocktail | /db/seeds.rb | UTF-8 | 506 | 2.921875 | 3 | [] | no_license | Ingredient.delete_all if Rails.env.development?
require "json"
require "rest-client"
response = RestClient.get "https://www.thecocktaildb.com/api/json/v1/1/list.php?i=list"
result = JSON.parse(response)
puts "Attempting to add ingredients to the database..."
result["drinks"].each do |ingredient|
new_ingredient =... | true |
17d10733c4376a9c5fedbd9d79b328ee83d4bdd6 | Ruby | britneywright/june2014 | /library.rb | UTF-8 | 538 | 3.84375 | 4 | [] | no_license | class Book
def initialize(title, categoy, borrow_time)
end
end
def Integer.all
Enumerator.new do |yielder, n: 0|
loop { yielder.yield(n += 1) }
end.lazy
end
def palindrome?(n)
n = n.to_s
n == n.reverse
end
p Integer
.all
.select {|i| (i % 3).zero? }
.select { |i| palindrome?(i) }
.first(10)
de... | true |
ba006ccfe97a67f72a7efabc1c4a561b68a5f6cd | Ruby | ttokutake/example-ruby-interpreter_pattern | /executor.rb | UTF-8 | 117 | 2.703125 | 3 | [] | no_license | # frozen_string_literal: true
# program executor
class Executor
def execute(name)
puts "Do #{name}"
end
end
| true |
1b41fab5b361cf4820a41cd0d5c8b4383544e147 | Ruby | KKOA/battle | /app.rb | UTF-8 | 975 | 2.796875 | 3 | [] | no_license | # my_app.rb
require 'sinatra/base'
require './lib/player'
require './lib/game'
class Battle < Sinatra::Base
set :sessions, true
get '/' do
erb(:index)
end
post '/names' do
if (params[:player1_name] == '' || params[:player2_name] == '')
session['err'] = 'Player name cannot be empty'
redirec... | true |
ca08b2a99e7d1db4f31ab324e3e9f9104e278f55 | Ruby | rahuljgovind/testrepo | /test_files/counter.rb | UTF-8 | 1,168 | 4.28125 | 4 | [] | no_license | #Author: Rahul Govind
# Overall notes at the bottom.
def is_palindrome (n) #Checks to see if the number is a palindrome
if n == n.reverse
return true
end
end
def run (filename) #runs filename
array = []
palin = []
file = File.open(filename, "r") do |file| #reads file
file.each_line{|line | ... | true |
883feea556dc3c9b0bcc36328b541af44b32ecbe | Ruby | SinkLineP/RubyOnRails-18.08.2021 | /Ruby on rails/coalla-cosmetology-ddcbe64f3200/app/helpers/courses_shop/group_price_helper.rb | UTF-8 | 852 | 2.609375 | 3 | [] | no_license | module CoursesShop
module GroupPriceHelper
def tooltip_text(group_price)
if group_price.bank_installment?
"Первый взнос - оплачиваем сейчас, остаток - оплачиваем банку равными платежами в срок #{months_count_text(group_price.bank_installment_months)}.".html_safe
else
'Первый взнос&nbs... | true |
718ba5187a5f3da63d9fafcbb4783e0a9b01270c | Ruby | GergKllai1/ATM_Challenge | /spec/person_spec.rb | UTF-8 | 3,298 | 3.25 | 3 | [] | no_license | require './lib/person'
require './lib/atm'
describe Person do
subject {described_class.new(name: 'Thomas')}
before do
subject.getting_a_job('Junior Frontend Developer', 25)
end
it 'is expected to have a :name on initialize' do
expect(subject.name).not_to be nil
end
it 'is expe... | true |
00c158b47ccda1656545c887344f6559b23852f8 | Ruby | a-G-a-o/RB101 | /small_problems/easy_7/7.rb | UTF-8 | 1,123 | 4.75 | 5 | [] | no_license | =begin
Write a method that takes an Array of integers as input, multiplies all the numbers together,
divides the result by the number of entries in the Array, and then prints the result rounded to 3 decimal places.
Assume the array is non-empty.
Examples:
show_multiplicative_average([3, 5]) # ... | true |
8816e1f8dab160a445b676ba5d9387174b40a0f2 | Ruby | fredemmott/rxhp | /hello.rb | UTF-8 | 1,351 | 2.875 | 3 | [
"ISC"
] | permissive | #!/usr/bin/env ruby
$LOAD_PATH.push './lib'
require 'rxhp'
# This actually defines a new kind of element, that is composed of other
# elements - it has no real rendering itself.
class HelloWorldBody < Rxhp::ComposableElement
include Rxhp::Html # Import methods for every tag
def compose
body do
p 'Hello,... | true |
ff24ef4af1bac30f55f719399398aa05463f8eba | Ruby | JeffWHenderson/school-domain-v-000 | /lib/school.rb | UTF-8 | 707 | 4.03125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # code here!
class School
attr_reader :roster, :name
def initialize(name)
@name = name
@roster = {}
end
def add_student(student, grade)
# create key IF key doesn't exist and add student... << student if it does
if @roster[grade]
@roster[grade] << student
else
@roster[gr... | true |
5ec3061846c88e5c3952ca8efde82528aea7c494 | Ruby | jrw-git/monte_carlo_bot | /lib/player.rb | UTF-8 | 711 | 3.484375 | 3 | [] | no_license | # encoding: UTF-8
class Player
attr_reader :symbol
public
def initialize(player_symbol)
@symbol = player_symbol
end
def get_move(current_board)
return get_random_move(current_board)
end
def to_s
return @symbol
end
private
def get_random_move(current_board)
# need to account f... | true |
42f5dadb49949adfd500017a8b7a0f816f5553c8 | Ruby | goermine/storehouse | /storehouse-api/lib/task_services/filter_product.rb | UTF-8 | 558 | 2.859375 | 3 | [] | no_license | module TaskServices
class FilterProduct
CATEGORY = 'category'.freeze
def initialize(products)
@products = products
end
def apply_by(name)
@products.each do |obj|
next unless obj[CATEGORY]&.match(/#{name}/i)
products_dictionary[name].push(obj)
remove_category_attr(... | true |
00131a2e94fd8b5e6a789eaa2bb0eb5a27d65344 | Ruby | harfang14/Tic_Tac_Toe | /Player.rb | UTF-8 | 182 | 3.234375 | 3 | [] | no_license | class Player
attr_writer :etat
attr_accessor :w
def initialize(nom, etat = nil)
$nom = nom
$etat = etat
end
w = $w
$w = " "
def winner
return $w
end
end
| true |
8b0719b57485cad9d74aeb91b78884c2281d74d4 | Ruby | pelicularities/macrotery-redux | /app/models/dish.rb | UTF-8 | 638 | 2.578125 | 3 | [] | no_license | class Dish < ApplicationRecord
belongs_to :eatery
has_many :order_dishes, dependent: :destroy
has_many :reviews, through: :order_dishes
has_one_attached :photo
validates :name, :price_cents, :protein, :carbs, :fats, presence: true
validates :name, uniqueness: { scope: :eatery, message: 'eatery already has a... | true |
6a6fbb565b2a7089a7c19a08964f1fdd536b9073 | Ruby | voidsatisfaction/Project-Euler-in-Ruby | /100.rb | UTF-8 | 730 | 3.375 | 3 | [] | no_license |
class Problem100
def self.find_ans
sum = 10**12
while 1
p sum
blue = (sum * (1.0/2)**0.5).to_i
value = (2*sum-1)**2 - 2*(2*blue-1)**2
while value >= -1
value = (2*sum-1)**2 - 2*(2*blue-1)**2
return blue if value === -1
blue += 1
end
sum += 1
end... | true |
839da52931708aa7f49a94fe49de19c8b2998cfe | Ruby | rmtolmach/cs-fundamentals | /stack-queue/Stack.rb | UTF-8 | 1,923 | 4.28125 | 4 | [] | no_license | require 'pry'
# this is the Stack class
class Stack
# on initialization, a size parameter must be passed in.
def initialize(size)
# 'size' is made an instance variable so @store can use it throughout the class.
@size = size
@store = Array.new(@size)
# The last element will be at index -1. Since it's a stack,... | true |
6a762186ab252613f43d4e721c5a7c62237ed2b3 | Ruby | ggerdsen/sweater_weather | /app/poros/weather_data.rb | UTF-8 | 396 | 3.171875 | 3 | [] | no_license | class WeatherData
attr_reader :id,
:type,
:current_weather,
:daily_weather,
:hourly_weather
def initialize(data)
@id = nil
@type = "forecast"
@current_weather = CurrentWeather.new(data[:current])
@daily_weather = DailyWeather.new_day(data[:d... | true |
eaac555ce9e2770376b6b171c7d46d38826edca0 | Ruby | mathias/kilt-cli | /lib/kilt.rb | UTF-8 | 987 | 2.6875 | 3 | [
"MIT"
] | permissive | require 'rest_client'
require 'crack/xml'
require 'rufus/scheduler'
class Kilt
include Crack
attr_reader :id
ICON = File.expand_path(File.join(File.dirname(__FILE__), '..', 'img', 'pivotal.png'))
def self.init(token)
new token
end
def update
activities = fetch_activities
activities.reverse.... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.