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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
36c762969f07b7840956baa2761decdb621a8d4a | Ruby | snovity/konstructor | /spec/gem_conflicts/contracts_spec.rb | UTF-8 | 3,438 | 2.734375 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
require_relative '../shared'
describe "Konstructor with contracts.ruby" do
before :all do
require 'konstructor'
end
# Contracts seem not to work with any kind of class metaprogramming,
# so have to define regular classes
context "when contract is for method" do
before :all do... | true |
bc0663015d1a58f1bb1ffe23c364d42b9d8fe1f4 | Ruby | ahorner/advent-of-code | /lib/2019/13.rb | UTF-8 | 951 | 3.09375 | 3 | [] | no_license | require_relative "./shared/intcode"
TILES = [".", "|", "#", "_", "o"].freeze
def render(tiles)
screen = Hash.new(0)
score = 0
tiles.each_slice(3) do |x, y, value|
if x == -1 && y == 0
score = value
else
screen[[x, y]] = value
end
end
[screen, score]
end
cabinet = Computer.new(INTC... | true |
2923522cfc7bfb247e23f4ed0e0b13da0f404133 | Ruby | andreybakanovsky/homeworks-2021 | /HW04/aleksandr_serikov/lib/person.rb | UTF-8 | 383 | 3.0625 | 3 | [] | no_license | # frozen_string_literal: true
# Person
class Person
attr_reader :name, :surname, :notifications
def initialize(name, surname)
@name = name
@surname = surname
@notifications = []
end
def add_notification(notification)
notifications << notification
end
def mark_as_read!
notifications.c... | true |
d0205a63d7e9cf1d73baf2a8b56be868fa3db777 | Ruby | zdennis/strac | /vendor/plugins/presentation_object/vendor/behaviors/test/tasks_test/test/user_test.rb | UTF-8 | 838 | 3.015625 | 3 | [
"MIT"
] | permissive | require 'test/unit'
here = File.expand_path(File.dirname(__FILE__))
require "#{here}/../../../lib/behaviors"
require "#{here}/../lib/user"
class UserTest < Test::Unit::TestCase
extend Behaviors
def setup
@user = User.new('edith',18)
end
context 'when constructing' do
should 'set name and age accessor... | true |
808a85892db391bc0957fc0c772ea53183ebbf85 | Ruby | ccsalespro/ams_new | /app/algorithm/interchange_cost.rb | UTF-8 | 229 | 3.03125 | 3 | [] | no_license | class InterchangeCost
def initialize(inttableitems)
@inttableitems = inttableitems
end
def calculate_cost
@costs = 0
@inttableitems.each do |item|
@costs += item.costs
end
@costs
end
end | true |
c7fde18bdf8a6ebcc177c965f1483fc99fb4f772 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/raindrops/520c15c7e31c4309ac042d93612ab972.rb | UTF-8 | 360 | 3.625 | 4 | [] | no_license | class Raindrops
def initialize
@str = ""
end
def Raindrops.convert num
if divisible?(num, 3)
@str << "Pling"
elsif divisible?(num, 5)
@str << "Plang"
elsif divisible?(num, 7)
@str << "Plong"
else
return num.to_s
end
return @str
end
def Raindrops.divisib... | true |
cac77a9a9ac7e1798c62376c43f7ce9a5de7bdd3 | Ruby | Jendnice/ruby-inheritance-lab-online-web-ft-090919 | /bin/time_for_school | UTF-8 | 996 | 3.515625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | #!/usr/bin/env ruby
require_relative "../lib/user.rb"
require_relative "../lib/teacher.rb"
require_relative "../lib/student.rb"
jim = User.new
jim.first_name = "Jim"
jim.last_name = "Johnson"
steve = Student.new
steve.first_name = "Steve"
steve.last_name = "Jobs"
nora = Student.new
nora.first_name = "Nora"
nora.las... | true |
1d00b2599c06dbd14ad43474e47fd9154fe79e3f | Ruby | codyduval/dork | /spec/lib/dork_spec.rb | UTF-8 | 9,049 | 3.0625 | 3 | [] | no_license | require "spec_helper"
require "dork"
module Dork
describe Node do
it "can add a child" do
root = Node.new(:root)
child = Node.new(:child)
root.add(child)
expect(root.children).to include(child)
end
it "can add a child via a block" do
root = Node.new(:root) do
Node... | true |
20c325bb027071e5e9112154313ac142c7a1ce39 | Ruby | kopchak/OOP_Library | /order.rb | UTF-8 | 172 | 3.015625 | 3 | [] | no_license | class Order
attr_accessor :book, :reader, :date
def initialize(book, reader)
@book, @reader, @date = book, reader, Time.now.strftime("%H:%M:%S %d-%m-%Y")
end
end | true |
b424daa6969bf6a982487beb0bd01b7d208d515f | Ruby | billbell73/phototo | /app/models/tag.rb | UTF-8 | 544 | 2.515625 | 3 | [] | no_license | class Tag < ActiveRecord::Base
has_and_belongs_to_many :photos
validates :content, length: {minimum: 2}
def self.create_tags_for!(tag_list, photo)
tag_list.split(' ').each do |tag_content|
slug = tag_content.gsub('#', '').downcase
photo.tags << find_or_create_by!(content: tag_content, slug: slug)
... | true |
a860b19ec2bb3e0e79c424f2dd39c8345a8bd764 | Ruby | RubyCamp/rc2018sp_g5 | /practice15/Scene/senser/senser_all.rb | UTF-8 | 338 | 2.8125 | 3 | [] | no_license | class Senser_all
def initialize(board)
@board = board
end
def draw
data = @board.analog_read(0)
#p data
end
def light_now_getter
@board.analog_read(0)
end
def distance_value_getter #距離センサの値を読む
@board.analog_read(4) #距離センサーはA3に挿す
end
end
| true |
89974a94e7eaee7945304655d7ca8a1a32d1c55f | Ruby | DouglasAllen/code-The_Book_of_Ruby | /code/ch08/method_call.rb | UTF-8 | 188 | 3.375 | 3 | [] | no_license | # ch08 The Book of Ruby - http://www.sapphiresteel.com
def nochange(x)
x
end
num = 10
puts("num.object_id=#{num.object_id}")
num = nochange(num)
puts("num.object_id=#{num.object_id}")
| true |
c90366e3196969d69e81a1da318441d7a7edbbf0 | Ruby | reedlaw/ruby-mmo | /players/jbttn.rb | UTF-8 | 1,316 | 3.1875 | 3 | [] | no_license | module Jbttn
def move
if stats[:health] >= 100 && !am_i_leading?
attack
else
[:rest]
end
end
def to_s
"Jbttn"
end
private
def everyone
Game.world[:players].select{ |p| p.alive }
end
def leaders
everyone.sort!{ |a,b| a.stats[:experience] <=> b.stats[:e... | true |
178a676f101594fb0fb0836476d7f82840bdcae9 | Ruby | KajiMaster/personal | /deck_v01.rb | UTF-8 | 2,748 | 3.25 | 3 | [] | no_license | class Card
SUITS = %w(Spades Hearts Clubs Diamonds)
RANKS = %W(A K Q J 10 9 8 7 6 5 4 3 2)
attr_accessor :suit, :rank
def initialize(id)
self.suit = SUITS[id % 4]
self.rank = RANKS[id % 13]
end
end
class Deck
attr_accessor :cards
def initialize
@cards = (0..51).to_a.shuffle.collect { |id| Card.new(i... | true |
8f19446a46ff63ebefe3db107c581e0f5ea41f24 | Ruby | DanielDo92/houzie | /app/models/bills/parking.rb | UTF-8 | 221 | 2.546875 | 3 | [] | no_license | module Bills
class Parking < Base
PRICE_PER_VEHICLE = 100_000
def unit_count
room.vehicle_count
end
def calculate_total
self.total_price = unit_count * PRICE_PER_VEHICLE
end
end
end
| true |
a49f4278865ca884ad3a9d13edb5146e78c471ae | Ruby | osmszk/dla_team14 | /devide_test_train.rb | UTF-8 | 1,092 | 2.765625 | 3 | [] | no_license | require 'fileutils'
#ももくろに戻すときはtrue
is_momokuro = false
talents = is_momokuro ? ['kanako','shiori','ayaka','momoka','reni'] : ['takemoto','taniai','suzuki']
ext = is_momokuro ? 'jpg' : 'png'
train_image_dir = './data/train/'
test_image_dir = './data/test/'
#以下、学習データとテストデータにわける
RATIO_TRAIN_DATA = 0.7
talents.each d... | true |
375c1112a5da073753f84bf19e42099c141e4ad4 | Ruby | elDante/eoat | /lib/eoat/cache/memcached_cache.rb | UTF-8 | 2,460 | 2.625 | 3 | [
"MIT"
] | permissive | module EOAT
module Cache
# Memcached cache handler. Used `gem memcache`
# Default use standard connection parameters.
# @author Ivan Kotov {mailto:i.s.kotov.ws e-mail}
# @example Set Memcached as a cache storage, with default Memcached `address` and `port`
# EOAT.cache = EOAT::Cache::MemcachedCa... | true |
fb7fc70c841eee6922a9cd8f40e3578c1283a267 | Ruby | rokoroku/partyrecruit | /app/helpers/parties_helper.rb | UTF-8 | 448 | 2.59375 | 3 | [] | no_license | # coding: UTF-8
module PartiesHelper
def category_list
['취미', '운동', '식사', '스터디', '공연', '영화', '봉사', '기타']
end
def print_remaining_time(ended_at)
unless ended_at.nil?
remaining = (ended_at - Time.now)/60 + 0.5
if remaining >= 60
(remaining/60).to_i.to_s << "시간 " << (remaining%60).to_i.... | true |
b7984b407bd7f359c2fc02bffe622acda9dfc337 | Ruby | christaylor19/citylines | /api/test/unit/models/lines.rb | UTF-8 | 2,524 | 2.515625 | 3 | [
"MIT"
] | permissive | require File.expand_path '../../../test_config', __FILE__
describe Line do
before do
@city = City.new(name: 'Some city',
start_year: 2017,
url_name: 'city',
country: 'Argentina')
@city.coords = Sequel.lit("ST_GeomFromText('POINT(-71.064544 42.28... | true |
fa9eb9ec9d86fcccf7a23a01b47e79e6128f947d | Ruby | cajun/resume | /lib/resume.rb | UTF-8 | 5,027 | 3.03125 | 3 | [
"MIT"
] | permissive | require 'rubygems'
require 'facets/ansicode'
module Resume
def self.included(base)
base.extend(ANSICode)
base.extend(ClassMethods)
(base.methods - Object.methods).each do |method|
base.send(method, Array.new) if method =~ /=$/
end
base.contact_info = Hash.new
ba... | true |
161c65c82e7b65ecc37f2f38c919e4938813db6a | Ruby | Manfred/Four | /test/support/collector.rb | UTF-8 | 309 | 3.34375 | 3 | [
"MIT"
] | permissive | class Collector
attr_accessor :_written
def initialize
self._written = []
end
def puts(*args)
args.each { |line| write(line.end_with?("\n") ? line : line + "\n") }
end
def write(*args)
self._written << args
end
def flush
# noop
end
def to_s
_written.join
end
end | true |
e2b41fe69edfa49530da85d59507184d482952aa | Ruby | Bw00d/ruby_tic_tac_toe | /spec/tic_tac_toe_spec.rb | UTF-8 | 2,772 | 3.28125 | 3 | [] | no_license | require 'space'
require 'board'
require 'player'
require 'game'
require 'rspec'
describe Space do
describe '#initialize' do
it 'initializes a new instance of Space' do
test_space = Space.new(0, 0)
test_space.should be_an_instance_of Space
end
end
describe '#mark_by' do
it 'lets a player ... | true |
e82150a2c6ea1f4f93fcbbbe5966d6881eacac35 | Ruby | clio/slow_query_exporter | /lib/slow_query_exporter/query_parser.rb | UTF-8 | 484 | 2.609375 | 3 | [
"MIT"
] | permissive | module SlowQueryExporter
class QueryParser
def initialize(logger)
@buffer = ""
@logger = logger
@parsed = []
reset!
end
def reset!
@query = SlowQuery.new
end
def parse_line(line)
@query.parse_line(line)
if @query.done?
@parsed << @query
@... | true |
74c990490fb6317f7d015d3e3e89ffbb61e3207a | Ruby | tommchenry/drem-tem-ruby-racer | /view.rb | UTF-8 | 522 | 3.53125 | 4 | [] | no_license | require_relative 'game'
require_relative 'car'
require_relative 'reset_screen'
class View
def get_input
gets.chomp
end
def race_starter
puts "READY..."
sleep 1
puts "SET..."
sleep 1
puts "GO!"
sleep 1
end
def pretty_board(arr_of_cars, track_length)
arr_of_cars.each do |car|
... | true |
c5939633f06c49ac0914d9fee0f2c33f551d6733 | Ruby | janewysoki/Page-Of-Reason | /app/models/book.rb | UTF-8 | 724 | 2.65625 | 3 | [
"MIT"
] | permissive | class Book < ApplicationRecord
belongs_to :author
belongs_to :user
has_many :reviews
has_many :users, through: :reviews
accepts_nested_attributes_for :author
validates :title, presence: true
validates :author, presence: true
validate :no_duplicates
scope :alphabetize, -> { order(:title) }
def... | true |
e15ad132f087a55dfd8c9e96619fe6f7917c73b9 | Ruby | corneliusellen/http | /lib/game.rb | UTF-8 | 729 | 3.4375 | 3 | [] | no_license | class Game
attr_accessor :number_of_guesses,
:user_guess,
:high_or_low,
:secret_number
def initialize
@secret_number = rand(0..5)
@number_of_guesses = 0
@user_guess = nil
@high_or_low = nil
end
def assign_user_guess(request)
@number_of_guess... | true |
9e4d63d688fb4cf5b3598097f1ff64e1bbba8d19 | Ruby | Illianthe/ProjectEuler | /lib/utility.rb | UTF-8 | 608 | 3.859375 | 4 | [] | no_license | module Utility
# Checks if a number is prime via trial division
def is_prime?(n)
(2..Math.sqrt(n).floor).each do |i|
return false if n % i == 0
end
true
end
# Returns an array of all the proper divisors of n
def proper_divisors(n)
divisors = []
(1..Math.sqrt(n).floor).ea... | true |
3500a012bc14d6d3c9caa2435ff0883d094dc38d | Ruby | chestercun/common | /lib/utility/file_utility.rb | UTF-8 | 677 | 3.203125 | 3 | [] | no_license | module FileUtility
def cat_file(fn)
line_arr(fn).each do |line|
p line
end
end
def line_arr(fn)
# call private
file = open(fn)
# build line array
tmp = []
file.each do |line|
next if line =~ /\A\n\Z/
line.sub! /\n$/, ''
tmp.push(line)
end
tmp
end
... | true |
c9021694765e12da7c3c28d1a0fd6f0141a28e16 | Ruby | MyReplayLive/schedule-scrape | /lib/schedule-scraper.rb | UTF-8 | 1,177 | 2.65625 | 3 | [
"MIT"
] | permissive | require 'nibbler'
require 'open-uri'
require 'csv'
require 'uri'
require 'nokogiri'
require "schedule-scraper/version"
require "schedule-scraper/config"
require "schedule-scraper/event"
require "schedule-scraper/schedule"
require "schedule-scraper/pointstreak/event"
require "schedule-scraper/pointstreak/schedule"
requi... | true |
e27439816387f641b1677b1f6e3f7e3944399076 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/rna-transcription/49019e2c4ee14f789ea0db69b3b6fac3.rb | UTF-8 | 301 | 2.9375 | 3 | [] | no_license | class Complement
RNA = { 'G' => 'C', 'C' => 'G', 'T' => 'A', 'A' => 'U' }
DNA = { 'C' => 'G', 'G' => 'C', 'A' => 'T', 'U' => 'A' }
def self.of_dna(dna)
dna.each_char.inject('') { |a, e| a << RNA[e] }
end
def self.of_rna(rna)
rna.each_char.inject('') { |a, e| a << DNA[e] }
end
end
| true |
0319c94700030fd44da001df02d75ca2afd5b610 | Ruby | claudiobm/base_app | /lib/slugify.rb | UTF-8 | 809 | 2.703125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require "string_helper"
module Slugify
LIST_FIELD = [:name, :title]
def slugify(word, unique = true)
slug = ""
slug = word.slugfy
if unique
i = 1
if self.id
while self.class.where(['slug = ? AND id <> ?', slug, self.id]).count > 0 do
slug = ("#{i}-#{slug}}")
i ... | true |
af7df44aa93bdbb41eb6f47c389487177c3ce2f3 | Ruby | dare1010/rl1 | /4wk/1ea_dog.rb | UTF-8 | 529 | 4.03125 | 4 | [] | no_license | # http://pastebin.com/tSzvcDC0
class Dog
attr_reader :name, :tricks
def method_missing(name, *args, &block)
if @tricks.has_key?(name)
puts "#{@tricks[name]}"
else
puts "I don't know such tricks. Teach me!"
end
end
def initialize(name)
@name = name
@tricks = {}
end
def bark... | true |
f43778a94be53e6f629b4e85987b89c151a62483 | Ruby | shawn42/free-radicals | /src/electron.rb | UTF-8 | 2,252 | 2.890625 | 3 | [] | no_license |
class ElectronView < ActorView
def draw(target, x_off, y_off, z)
target.draw_circle @actor.x,@actor.y, @actor.radius, [40,225,25,255], z
target.draw_circle @actor.x,@actor.y, @actor.radius+3, [20,255,20,155], z
end
end
class Electron < Actor
has_behaviors :updatable, :audible, :layered => 2
attr_acc... | true |
7215fda527dc30f16fd80dc056f31c663b767b12 | Ruby | jcreiff/exercism | /ruby/queen-attack/queen_attack.rb | UTF-8 | 598 | 3.8125 | 4 | [] | no_license | class Queens
attr_reader :white, :black
def initialize(white: [], black: [])
[white, black].each do |position|
raise ArgumentError, 'Invalid position' unless valid?(position)
end
@white = white
@black = black
end
def attack?
same_row? || same_column? || same_diagonal?
end
privat... | true |
2e96a39548281b41e0368787fb6aaac03d57dc5d | Ruby | bay-qa/linkedin_script | /linkdin.rb | UTF-8 | 2,312 | 3.125 | 3 | [] | no_license | require 'capybara/dsl'
require 'selenium-webdriver'
require 'pry'
Capybara.register_driver :selenium do |app|
Capybara::Selenium::Driver.new(app, browser: :chrome)
end
Capybara.javascript_driver = :chrome
Capybara.configure do |config|
config.default_max_wait_time = 10 # seconds
config.default_driver = :seleni... | true |
6d1a96bacfdc8d8a8a0a096ace97ba74886ef41a | Ruby | TriciaAI/ruby-challenges | /symbols.rb | UTF-8 | 302 | 3.671875 | 4 | [] | no_license | hash1 = {name: "Baby Jaguar", description: "cracked eye", description2: "worn fur"}
hash2 = {name: "Jaguar", description: "biggest", description2: "looks new" }
hash3 = {name: "Jaggy", description: "smallest", description2: "floppy head" }
winner = hash1[:name]
puts "The most-loved jaguar is #{winner}!"
| true |
b78ea2176d7e6495a296d5e1ac163e617f62a3e0 | Ruby | technolingo/gimchi | /lib/gimchi.rb | UTF-8 | 10,062 | 3.453125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | #!/usr/bin/env ruby
# encoding: UTF-8
# Junegunn Choi (junegunn.c@gmail.com)
require 'yaml'
require 'set'
require 'gimchi/char'
require 'gimchi/pronouncer'
class Gimchi
class << self
attr_reader :chosungs, :jungsungs, :jongsungs
def Char ch
Gimchi::Char.new(ch)
end
# Decompose a Korean character into 3 ... | true |
8845e429364ccd4f6efbe09644a03c9bc85bafe7 | Ruby | Boltmade/Phonepad-Chess | /knight.rb | UTF-8 | 375 | 3.09375 | 3 | [] | no_license | class Knight < ChessPiece
def is_move_legal?(board, x, y)
# Knight moves in L or stays in its place
return super && ( (board.current_x == x) && (board.current_y == y) ||
((board.current_x - x).abs == 1) && ((board.current_y - y).abs == 2) ||
((board.current_x - x).a... | true |
23173d11ea0628287a22cf8069960abfd5e18c88 | Ruby | okeeffe/playboard | /app/models/user.rb | UTF-8 | 1,919 | 2.765625 | 3 | [] | no_license | class User < ActiveRecord::Base
# Establishes the relationship between Users and Plays, and that if a User is deleted, their Plays are too.
has_many :plays, :dependent => :destroy
# All the validations for a User.
validates :first_name, :presence => true, :length => {:minimum => 1}
validates :last_name, :p... | true |
87855d277f9a5530f44c0d04d8af75343b28e5d2 | Ruby | wilkosz/domain_com_au | /lib/domain_com_au/client.rb | UTF-8 | 422 | 2.515625 | 3 | [
"MIT"
] | permissive | require 'domain_com_au/http_client'
require 'domain_com_au/domain_listing'
class Client
def initialize(client_id, client_secret)
@http_client = HttpClient.new(client_id, client_secret)
end
def get_token
@http_client.auth_token
end
def search_listings(type, params={})
DomainListing.index(@http_c... | true |
4192235d3ed7eaadfcb528ad5d68759ae7e2b9aa | Ruby | Khomyachok5/equation | /app/controllers/equations_controller.rb | UTF-8 | 2,966 | 3.21875 | 3 | [] | no_license | class EquationsController < ApplicationController
require 'csv'
require 'equation_solver'
def main_page
end
def handle_input
@status = []
@total_pairs = []
if params[:a_value] || params[:b_value] || params[:c_value]
a = params[:a_value]
b = params[:b_value]
c = params[:c_value]... | true |
2ec4e118d89ec5f9bec5d6241d5846f0eb9251e7 | Ruby | hermine-dm/scrapping | /lib/townhall.rb | UTF-8 | 1,437 | 3.265625 | 3 | [] | no_license | require 'rubygems'
require 'nokogiri'
require 'open-uri'
=begin
def finding_the_page(ville)
townhall_url = Nokogiri::HTML(open("https://www.annuaire-des-mairies.com/95/#{ville}.html"))
return townhall_url
end
=end
def get_townhall_email(townhall_url)
begin #ne sert à rien il n'y avait pas d'erreur haha
page = No... | true |
49637cdd5cc2e06f6c5b0a8943b717636edf2207 | Ruby | nguyennhan09cntt/4room.vn | /app/models/user.rb | UTF-8 | 1,148 | 2.59375 | 3 | [] | no_license | require 'digest/sha1'
class User < ApplicationRecord
self.table_name = "user"
before_create :encrypt_password
after_create :clear_password
validates :user_name, :presence => {message: "is required" }, :length => { in: 4..20, message: "from 4 to 20 charters"}, uniqueness: true
validates :password, :presence => tr... | true |
fa4459887e2b8e04dc6c108b2bccdffe08f3a64d | Ruby | benhutton/facebooker2 | /lib/facebooker2.rb | UTF-8 | 1,938 | 2.59375 | 3 | [
"MIT"
] | permissive | # Provides rails helpers for interfacing with Facebook's OpenGraph Javascript
# API, http://developers.facebook.com/docs/reference/javascript/.
require "mogli"
require "facebooker2/rails/controller"
require "facebooker2/rails/helpers/facebook_connect"
require "facebooker2/rails/helpers/javascript"
require "facebooker2... | true |
b081d4f2bfb97d61071a29cb224f4d8d09aa0742 | Ruby | Thermatix/dynamised-rb | /lib/dynamised/node.rb | UTF-8 | 946 | 2.90625 | 3 | [
"MIT"
] | permissive | module Dynamised
class Node
include Enumerable
attr_accessor :childs,:init, :data, :ident,:siblings
def initialize(init={},ident=nil)
@ident = ident
@childs = {}
@sibilngs = {}
@init = init.clone
@data = init.clone
end
def each(&block)
block.call(self)... | true |
de9f52943d7f7d59a32d95672b73acd1dc863cec | Ruby | malachispencer/codewars | /ruby/6kyu/ranking-nba-teams.rb | UTF-8 | 4,760 | 3.671875 | 4 | [] | no_license | =begin
Codewars. 28/05/20. 'Ranking NBA teams'. 6kyu. We are given a string of the results of NBA games, separated by commas, and another string,
an NBA team. Here we create a method which provides a breakdown of that team's results/stats for example
"Boston Celtics:W=4;D=0;L=0;Scored=403;Conceded=350;Points=12". Her... | true |
12d92a9b644407557ea6b4a313c21232029b9f17 | Ruby | mbraga24/ruby-oo-fundamentals-object-attributes-lab-nyc04-seng-ft-041920 | /lib/dog.rb | UTF-8 | 310 | 3.578125 | 4 | [] | no_license | class Dog
# SETTERS
def name=(dog_name)
@name = dog_name
end
def breed=(dog_breed)
@breed = dog_breed
end
# GETTERS
def name
@name
end
def breed
@breed
end
end
laika = Dog.new
laika.name = "Laika"
laika.breed = "Mixed"
puts laika.name
puts laika.breed | true |
1dcef8b2da3bcf4429eec9e7ff58fce190d0589c | Ruby | sue445/cure-mastodon-bots | /lib/on_air_bot.rb | UTF-8 | 1,136 | 2.734375 | 3 | [
"MIT"
] | permissive | require_relative "bot"
require_relative "program_manager"
class OnAirBot < Bot
DELAY_MINUTES = 10
RANGE_MINUTES = 30
def initialize
super(ENV["MASTODON_URL"], ENV["ACCESS_TOKEN_ON_AIR"])
end
def perform
on_air_programs = current_programs
if on_air_programs.empty?
puts "Doesn't found on a... | true |
ba3ae312455f61aeeed5d58b50cbcf6f94f939fe | Ruby | niklaslong/epicodus-lessons | /Ruby/train/spec/train_spec.rb | UTF-8 | 2,122 | 2.734375 | 3 | [] | no_license | require 'unit_helper_spec'
describe 'Train' do
describe '.all' do
it 'Will return an empty array for the all method' do
expect(Train.all).to eq []
end
end
describe '.save' do
it 'It will save a train to the trains table' do
name = "test train"
train_uuid = Train.save(name)
e... | true |
ba77ee4e9939ba95004baa637d91e15e263eed8d | Ruby | IamElaya/contact-list.v4 | /app/actions.rb | UTF-8 | 614 | 2.515625 | 3 | [] | no_license | # Homepage (Root path)
get '/' do
erb :index
end
get '/contacts' do
contacts = Contact.all
# contacts = contacts.where("name ILIKE ?", params[:name]) if params[:name].present?
contacts.to_json
end
post '/contacts' do
firstname = params[:firstname]
lastname = params[:lastname]
email = params[:email]
... | true |
c65096c0651bf6edd98650690ffb8d7fcd93dc4c | Ruby | dachrisch/extreme_startup | /lib/extreme_startup/question_factory.rb | UTF-8 | 9,949 | 3.40625 | 3 | [] | no_license | require 'set'
require 'prime'
# TODO: This really should be somewhere better
# but I don't know how to best set up the require's for that
class Array
def pick_one
self[Kernel.rand(self.length)]
end
end
module ExtremeStartup
class Question
class << self
def generate_uuid
@uuid_generator ||... | true |
2f219ec7fb08dd479141e26110a2ed18d30b694d | Ruby | abak-press/apress-sources | /lib/apress/sources/object_id_extractor.rb | UTF-8 | 1,713 | 3.109375 | 3 | [
"MIT"
] | permissive | module Apress
module Sources
# Extract id from params where exists object key
#
# @example:
# Apress::Sources::ObjectIdExtractor.new(:user).call(object: {user_id: 1})
# => 1
#
# @api public
#
# @since 0.2.0
class ObjectIdExtractor
attr_reader :object_name
# Cre... | true |
afca3dac1d831d37e4aa2af6c7f3e94888454fa1 | Ruby | maximkoo/ruby-repo | /Ruby Stuff/Ruby Lecture/3. Blocks/080.rb | UTF-8 | 146 | 3.046875 | 3 | [] | no_license | def m6(&block1)
puts block1.class.name
block1.call
yield
end;
pp=Proc.new do
puts "Proc executed as a block"
end
m6(&pp) | true |
b7f07980d50011faa56bb0d5809678a010a93206 | Ruby | BeRMaNyA/minesweeper-api | /app/models/time_entry.rb | UTF-8 | 376 | 2.515625 | 3 | [] | no_license | # frozen_string_literal: true
class TimeEntry
include Mongoid::Document
field :start_time, type: Time
field :end_time, type: Time
field :duration, type: Float
embedded_in :game
def finish
self.end_time = Time.now.utc
self.duration = (end_time - start_time).round(2)
end
def duration
... | true |
39bc32eb0b96f89274c06de8c941dacb85f7ed63 | Ruby | baumanj/matasano_crypto_challenges | /103_single-byte_xor_cipher.rb | UTF-8 | 3,909 | 2.96875 | 3 | [] | no_license | # Single-byte XOR cipher
# The hex encoded string:
# 1b37373331363f78151b7f2b783431333d78397828372d363c78373e783a393b3736
# ... has been XOR'd against a single character. Find the key, decrypt the message.
# You can do this by hand. But don't: write code to do it for you.
# How? Devise some method for "scoring" a pi... | true |
86319e716d98b9a29aaadb10cd559cebf44a98e4 | Ruby | nathaliesantana/cocktail_recipes | /lib/cocktail_recipes/cli.rb | UTF-8 | 1,327 | 3.59375 | 4 | [
"MIT"
] | permissive | class CocktailRecipes::Cli
def welcome
CocktailRecipes::Scraper.new("https://www.foodandwine.com/cocktail-recipes").scrape
puts "Hi, Welcome to Reinvented Classic Cocktails"
main_menu
end
def main_menu
puts "Here is a list of all of our cocktails:"
display_cocktails_list
puts "Type the n... | true |
4f0f27a78bbf74684d46cd55718192d393067a1d | Ruby | danisbubblesdad/Introduction_to_Ruby_and_Web_Development | /Lesson_2/OOP_Workbook/easy/Quiz_1/e6.rb | UTF-8 | 348 | 3.703125 | 4 | [] | no_license | # 6 - What could we add to the class below to access the instance variable
# @volume?
class Cube
attr_reader :volume #if we add an attr_reader we can access the
#instance variable. We could also add a method
#that returns the variable.
def initialize(volume)
... | true |
a81bd5631d8a25f53b370eb23bf5bc988efc7659 | Ruby | MasoodGit/rubytdddemo | /spec/testunit.rb | UTF-8 | 716 | 2.640625 | 3 | [] | no_license | gem 'minitest'
require 'minitest/autorun'
require '../lib/string_calc'
class TestTheCalc< MiniTest::Test
def test_add_emptystring_returnsdefaultvalue
result = StringCalculator.new.add("")
assert_equal 0,result
end
end
describe StringCalculator do
describe "adding" do
describe "empty s... | true |
719e0d6801beb70d1455a699aa8bd8a81a449f33 | Ruby | mabid/EpisodeCalendar3 | /app/helpers/followings_helper.rb | UTF-8 | 726 | 2.859375 | 3 | [] | no_license | module FollowingsHelper
def print_unwatched(count)
if count > 0
"<em class=\"green\">#{count} unwatched episodes</em>"
else
"<em>#{count} unwatched episodes</em>"
end
end
def wasted_in_words(to)
time_hash = Time.diff(Time.now, Time.now + to.minutes)
wasted = []
months = time... | true |
0457ff2b8c103e46353abd2d9b70d9937690f5b4 | Ruby | saintprug/rubytalks.org | /spec/support/request_helpers.rb | UTF-8 | 2,337 | 2.53125 | 3 | [] | no_license | # frozen_string_literal: true
module RequestHelpers
APP = Hanami.app
class Request
def initialize(method, path, options)
@path, @query_string = path.split('?', 2)
@method = method
@body = options[:body]
@headers = options[:headers] || {}
end
def env
default_env.tap do |e... | true |
22fe150c3dac920bb1bcfba8966487499a6083be | Ruby | haotianwang/CanvUs | /test/unit/bitmap_test.rb | UTF-8 | 2,676 | 2.734375 | 3 | [] | no_license | require 'test_helper'
class BitmapTest < ActiveSupport::TestCase
# Empties the test Bitmap database and adds some test data.
def setup
Bitmap.destroy_all
Bitmap.create(bitmap: 'bitmap_0', canvas_id: 0)
Bitmap.create(bitmap: 'bitmap_1', canvas_id: 1)
Bitmap.create(bitmap: 'bitmap_2', canvas_id: 2... | true |
d2788458ea9815c9444c4064845fbc86e41764ff | Ruby | tomclose/norrington_app | /app.rb | UTF-8 | 698 | 3.015625 | 3 | [] | no_license | require 'sinatra'
require 'csv'
data = CSV.read('./data/norrington_over_years.csv', :col_sep => "\t")
headings = data.first
values = data[1..-1]
values_as_hashes = values.map {|v| Hash[headings.zip(v)] }
get '/' do
@name = 'tom'
erb :index
end
get '/year/:year' do | year |
allowed_years = %w( 2006 2007 2008... | true |
ffaf12320bf58ef6c2ab57ed421cce2f8354be41 | Ruby | mitio/rubocop | /lib/rubocop/cop/style/braces_around_hash_parameters.rb | UTF-8 | 1,952 | 2.703125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # encoding: utf-8
module Rubocop
module Cop
module Style
# This cop checks for braces in method calls with hash parameters.
class BracesAroundHashParameters < Cop
def on_send(node)
_receiver, method_name, *args = *node
# Discard attr writer methods.
return if me... | true |
208833063dec4808f04e61ce5359d09460437b4d | Ruby | tzinfo/tzinfo | /lib/tzinfo/format1/timezone_definer.rb | UTF-8 | 3,279 | 2.703125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # encoding: UTF-8
# frozen_string_literal: true
module TZInfo
module Format1
# Instances of {Format1::TimezoneDefiner} are yielded to TZInfo::Data
# format 1 modules by {TimezoneDefinition} to allow the offsets and
# transitions of the time zone to be specified.
#
# @private
class TimezoneDef... | true |
86176b097154e6f120ec492fb5b5493f40373bee | Ruby | Garrett-Bodley/countdown-to-midnight | /countdown.rb | UTF-8 | 625 | 4.1875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def countdown(time)
# loop function while time in seconds is greater than 0
while time > 0
# output a string of the amount of seconds left
puts "#{time} SECOND(S)!"
# decrement time
time -= 1
end
# return HAPPY NEW YEAR!
"HAPPY NEW YEAR!"
end
def countdown_with_sleep(time)
# loop function w... | true |
05f1bedd53075e84813306e4c9f44798a72cbe43 | Ruby | cclazarou/phase-0-tracks | /ruby/vampires.rb | UTF-8 | 2,461 | 4.21875 | 4 | [] | no_license | require 'date'
#VARIABLES
conclusion = "Results inconclusive"
current_year = Date.today.year
#need to check if today is last day of year
is_last_day_of_year = Date.today.year != Date.today.next_day.year
age_is_right = nil
allergy = nil
# SURVEY
puts "How many employees will be processed?"
number_of_emplo... | true |
bc75db413ef8dfb01147662a366b0eacf0b84f3c | Ruby | osifoanosike/basicruby | /6/lib/vehicle.rb | UTF-8 | 297 | 3.53125 | 4 | [] | no_license | class Vehicle
def initialize(name, price)
@name = name
@price = price
end
def show_content
puts "\n#{self.class} Details \nName: #{@name} \nPrice: #{@price}\nDealer: #{@dealer}"
end
def change_price(new_price)
@price = new_price
end
end
#trying yo split things up
| true |
639f7a4c06f6e33e84069c7a71b6d69803a68d31 | Ruby | Mk-Etlinger/SQL-bear-organizer-lab-v-000 | /lib/sql_queries.rb | UTF-8 | 1,012 | 3.078125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def selects_all_female_bears_return_name_and_age
"SELECT name, age FROM bears WHERE gender = 'F';"
end
def selects_all_bears_names_and_orders_in_alphabetical_order
"SELECT name FROM bears ORDER BY name ASC;"
end
def selects_all_bears_names_and_ages_that_are_alive_and_order_youngest_to_oldest
"SELECT name, age F... | true |
1e03020a131d0b47590fc2d0518ce13f2567c5d2 | Ruby | swatkns785/car-listings | /spec/features/manufacturers/user_adds_manufacturer_spec.rb | UTF-8 | 1,841 | 2.90625 | 3 | [] | no_license | require "rails_helper"
feature "a user adds a manufacturer to database", %q(
As a car salesperson
I want to record a car manufacturer
So that I can keep track of the types of cars found in the lot
[x] I must specify a manufacturer name and country.
[x] If I do not specify the required information, I am presented with... | true |
c75ed2585ed349da986c7899022e543426a7e5c9 | Ruby | samfader/tilesets-api-cli-ruby | /lib/job.rb | UTF-8 | 2,071 | 2.703125 | 3 | [] | no_license | require 'tty-prompt'
require 'dotenv/load'
require 'http'
class Job
@prompt = TTY::Prompt.new(enable_color: true)
def self.list_all
puts "Working..."
result = @prompt.collect do
key(:tileset_id).ask("Enter the tileset ID:", help: "The ID is composed of your username followed by a period and the til... | true |
cbfc5c666c7c7846643567d15829f248857b6a8e | Ruby | ginason/ruby_fundamentals2 | /exercise8.rb | UTF-8 | 456 | 3.921875 | 4 | [] | no_license |
# sum_of_expense=0
# total_expenses=[]
# while true
# price=gets.to_f
# total_expenses.push(price)
# sum_of_expense += price
# puts "total expense is #{total_expenses} and sum is #{sum_of_expense}"
# end
def add(numbers)
puts "numbers is #{numbers}"
total_expenses=0
numbers.each do |i|
puts "i is #{i}"
... | true |
2c06cd0047dade6d2855032784344832beacde37 | Ruby | armanbalani/app-academy-repo | /Week 4/W4D4/octupus-problems.rb | UTF-8 | 1,502 | 3.703125 | 4 | [] | no_license | fish = ['fish', 'fiiish', 'fiiiiish', 'fiiiish', 'fffish', 'ffiiiiisshh', 'fsh', 'fiiiissshhhhhh']
def sluggish_octopus(array)
array.find do |ele|
array.all? do |ele2|
ele.length >= ele2.length
end
end
end
def dominant_octopus(array)
merge_sort(array).last
end
def clever_octo... | true |
e918d4a4d0f5ce3499d7b27e276d704305e0e5d1 | Ruby | mamarjan/bioruby-gff3-plugin | /lib/bio/output/gfffastawriter.rb | UTF-8 | 649 | 2.71875 | 3 | [
"MIT"
] | permissive |
module Bio
module GFFbrowser
class FastaWriter
def initialize translate, validate
@do_translate = translate
@do_validate = validate
end
def put id, seq
puts '>'+id
put_seq id, seq
end
private
def put_seq id, seq
if @do_translate or @d... | true |
c188b98b78166864c75013d4009713a677f0c71f | Ruby | klavinslab/protocols_aquarium_1_0 | /mutagenesis_workflow/020_run_gel.rb | UTF-8 | 3,377 | 2.65625 | 3 | [] | no_license | needs "aqualib/lib/standard"
class Protocol
include Standard
def debug
false
end
def arguments
{
stripwell_ids: [],
gels_ids: [],
volume: 50 # The volume of PCR fragment to load in µL
}
end
def main
stripwells = input[:stripwell_ids].collect { |i| collection_fro... | true |
f74adf104d26bd6d5015f458e7e8d7962245ba8f | Ruby | PianoFF/ruby-boating-school-london-web-102819 | /tools/console.rb | UTF-8 | 1,219 | 2.890625 | 3 | [] | no_license | require_relative '../config/environment.rb'
def reload
load 'config/environment.rb'
end
spongebob = Student.new("Spongebob")
patrick = Student.new("Patrick")
cindy = Student.new("Cindy")
puff= Instructor.new("Ms.Puff")
krabs= Instructor.new("Mr.Krabs")
sb = Student.find_student('Spongebob')
# puts "student shoul... | true |
d171709fd41fb1060551c944f546be92c999cca6 | Ruby | noahschultz/dealesque | /app/values/cart.rb | UTF-8 | 348 | 2.671875 | 3 | [] | no_license | class Cart
attr_accessor :id, :hmac, :encoded_hmac, :purchase_url
def initialize(attributes = {})
raise ArgumentError.new("Missing attributes") unless attributes
{id: "", hmac: "", encoded_hmac: "", purchase_url: ""}.each do |property, default_value|
send("#{property}=", attributes[property] || defa... | true |
9f2049d6d28c56e74e7177dc45413ea736f678d2 | Ruby | Jun-lo/tokinagara | /re.0428.rb | UTF-8 | 682 | 3.78125 | 4 | [] | no_license | #-*- coding: utf-8 -*-
#キーボードから次々と整数値を読み込んで、負でない値の合計値と平均を求めるプログラム
# 読み込んだ負の整数値の数の個数は平均を求める際の分母から除外する
puts "整数を加算します"
print "何個加算しますか?"
input = gets
n = input.to_i
sum = 0
count = 0
for i in 0..(n - 1)
print "整数:"
input = gets
y = input.to_i
if (y < 0)
puts "負の数は加算しません。"
end
sum += y
count += 1
end... | true |
8f301f26af0fd5bfb576ffdf391c639243b1edde | Ruby | derbya/Hackerrank_Projects | /30 Days of Code/Day 3: Intro to Conditional Statements/ruby.rb | UTF-8 | 535 | 3.53125 | 4 | [] | no_license | #!/bin/ruby
require 'json'
require 'stringio'
#I was playing around with procs to see what I could do. A lot of this in not needed.
N = gets.to_i
lessThanSix = proc {|x| (2..5).each do |n|
if n == x
puts "Not Weird"
end
end
}
moreThanSix = proc {|x| (6..20).each do |n|
if n == x
puts "Wei... | true |
e4c3fbb2a8f0e2c777557c627d18064fdffb83b0 | Ruby | jasonliz85/PartnerManage | /app/models/bridge.rb | UTF-8 | 9,439 | 2.625 | 3 | [] | no_license | class Bridge < ActiveRecord::Base
has_event_calendar
#validations
validates_presence_of :start_at, :end_at, :name
validates :start_at, :uniqueness => true
#scopes
#relationships
#callbacks
#functions
def update_bridge!()
#checks whether bridge has been updated (added new shifts) since it was c... | true |
9f9619b009b95360937ebfa5a105efc3fd5d9836 | Ruby | henkm/leisureking | /lib/leisureking/authentication.rb | UTF-8 | 1,102 | 2.59375 | 3 | [
"MIT"
] | permissive | module LeisureKing::Authentication
require 'digest'
require 'jwt'
require 'base64'
require 'openssl'
# The communication layer implements all the methods available in the LeisureKing API
class << self
attr_accessor :token
# Set's the default value's to nil and false
# @return [Hash] conguratio... | true |
6ab8dacc746f9aea6d0f0d6ffa98d2bf808ae1d0 | Ruby | nateberkopec/Marks-Fake-Facts | /server.rb | UTF-8 | 960 | 2.90625 | 3 | [] | no_license | require './initializer'
class Mark
def generate_fact
candidate = gabbler
if (110..140) === candidate.length && good_grammar?(candidate)
return candidate
else
generate_tweet
end
end
def initialize(dict_location = 'dictionaries/hot.txt')
@dict_location = dict_location
end
def... | true |
36dd58bf7621078d271f6d322b873955b0e2aaae | Ruby | juliesof/wdi_1_ruby_lab_apartments | /lib/tenant.rb | UTF-8 | 835 | 3.28125 | 3 | [] | no_license | require 'pry'
class Tenant
attr_reader :first_name, :age, :credit_score
attr_accessor :last_name
def initialize(first_name:, last_name:, age:, credit_score:)
@first_name = first_name
@last_name = last_name
@full_name = last_name + ', ' + first_name
@age = age
@credit_score = credit_score
... | true |
18006cb754c8e6f4f581dd46790b986ff4fe55b7 | Ruby | emdurr/devpoint-casino | /craps_win.rb | UTF-8 | 4,563 | 3.5 | 4 | [] | no_license | require 'pry'
require_relative 'user_input.rb'
require_relative 'dice_images.rb'
require_relative 'dice_roll.rb'
class CrapsWin
attr_accessor :player, :game
def initialize#(player, game)
@player = player
@game = game
@available_bets = ['Pass Line', "Don't Pass Line",
'Place Bet, Place Be... | true |
0e7ef68126d9e0ed2b12c230b8ae2f870590a72e | Ruby | dchopson/guitar_builder | /app/models/order.rb | UTF-8 | 3,093 | 2.53125 | 3 | [] | no_license | class Order < ActiveRecord::Base
belongs_to :user
has_many :guitars, dependent: :destroy
accepts_nested_attributes_for :guitars
i18n_scope = [:models, :order]
STATUSES = {
complete: I18n.t('statuses.complete', scope: i18n_scope),
in_progress: I18n.t('statuses.in_progress', scope: i18n_scope),
pe... | true |
8fb2f69a01eaee5943ac80eccf81e3e2dff3dd85 | Ruby | naveed-ahmad/productivity-scripts | /git/commit-msg | UTF-8 | 933 | 3.078125 | 3 | [] | no_license | #!/usr/bin/env ruby
#
# Script for appending the pivotal id of a story to the commits
# Branches must begin with st{pivotal_story_id}_description_here
#
# Reads the pivotal story from the branch name and appends it to the
# commit messages. Supports the following formats
#
# Examples:
# st{#pivotal_id}_commit_descr... | true |
7aa87189035fae3a1367bc594e0c2f4be57232ae | Ruby | Elizabeth-Roche/phase-0 | /week-6/die-2/my_solution.rb | UTF-8 | 1,889 | 4.46875 | 4 | [
"MIT"
] | permissive | # Die Class 2: Arbitrary Symbols
# I worked on this challenge [by myself, with: ].
# I spent [#] hours on this challenge.
# Pseudocode
# Input: an array of strings
# Output: a random string from the input array
# Steps: raise an argumenterror if labels size is less than one
#create method sides that returns the siz... | true |
97269ba0a0e57fb8d815bd7f2f70a29ab2206bb9 | Ruby | kmorcinek/apihack | /app/domain/int_matcher.rb | UTF-8 | 124 | 2.578125 | 3 | [
"MIT"
] | permissive | class IntMatcher
def ===(other)
other.kind_of?(Integer)
end
def as_json(options={})
"[an integer]"
end
end
| true |
d0b59885a6c5114f2f2c4d09827c923ea16f6628 | Ruby | jukinner/Coding-Practice-Codewars-Codility-Hackerrank-etc.- | /User_class_with_block.rb | UTF-8 | 1,362 | 4 | 4 | [] | no_license | # Build a User Class that Can Be Passed a Block to Set Its Values
# In this Ruby coding exercise your knowledge of blocks will be tested. The requirement is to build a User class that can be created and passed a block to set its values in addition to the traditional process for setting an object's data.
# Summary
# Bui... | true |
b57f08c7c87f7afa3b63e6b24332f7db53f67ff0 | Ruby | menge101/merkle | /lib/merkle_tree.rb | UTF-8 | 4,228 | 3.5625 | 4 | [] | no_license | # frozen_string_literal: true
require 'ruby-xxhash'
# Implementation of a Merkle tree
# This implementation is for exploring the details of the data structure
# It is not meant to be a servicable production library
# A non-cryptographically secure library is used for creating the hashes
# it has the benefit of being ... | true |
d3e2f28c5c07439f5505108b1f1d337d958c5bf2 | Ruby | DouglasDDo/Data-Structures-and-Algorithms | /data_structures/heaps/ruby/binary_heap_arr_rep.rb | UTF-8 | 4,665 | 3.828125 | 4 | [] | no_license | # Objective: Implement a min/max heap using an array-representation of nodes
# Defaults to min heap; Pass in a > b proc for max heap
class Heap
attr_reader :nodes
def initialize(opts = {})
@comparator = opts.fetch(:comparator, Proc.new {|a,b| a < b})
@nodes = Heap.build_heap!(opts.fetch(:nodes, Array.new),... | true |
6b54567a5814a137ca7184b93c973339f974d3da | Ruby | ElliotOlbright/sweater_weather | /app/POROS/forecast.rb | UTF-8 | 305 | 3.171875 | 3 | [] | no_license | class Forecast
attr_reader :daily,
:hourly,
:current,
:id
def initialize(current_weather, five_day_weather, hourly_weather)
@id = nil
@current = current_weather
@daily = five_day_weather
@hourly = hourly_weather
end
end | true |
0282dd2f7947f9c0f579a24c17a806cd00436861 | Ruby | Himuravidal/E9CP1A1 | /Ejercicio06.rb | UTF-8 | 469 | 3.234375 | 3 | [] | no_license | class Product
attr_reader :name, :tallas
def initialize(name, *tallas)
@name = name
@tallas = tallas.map(& :to_i)
end
def average
@tallas.inject(& :+) / @tallas.size.to_f
end
end
products_list = []
data = []
File.open('catalogo.txt', 'r') { |file| data = file.readlines }
data.each do |prod|
... | true |
c13ca6920ee935ec52c41e5467f186d79b58adac | Ruby | cradle/todoist | /todoist.rb | UTF-8 | 441 | 2.5625 | 3 | [] | no_license | #!/usr/bin/ruby1.8
require 'rubygems'
require 'json'
require 'net/http'
class Todoist
def initialize(token)
@token = token
end
def projects
get_action('getProjects')
end
def labels
get_action('getLabels')
end
private
def get_action(action)
JSON.parse(Net::HTTP.get(base_uri(action)))... | true |
ace48f9cd8c9d0c8d4a9a1719f2bd278f495f4d1 | Ruby | tomoasleep/yoda | /lib/yoda/server/server_controller/progress_reporter.rb | UTF-8 | 2,695 | 2.609375 | 3 | [
"MIT"
] | permissive | module Yoda
class Server
class ServerController
class ProgressReporter
# @param [String, Integer, nil]
attr_reader :work_done_token
# @param [String, Integer, nil]
attr_reader :partial_result_token
# @param [Notifier]
attr_reader :notifier
# @param ... | true |
7d2893216773ffae1e54da85d2bea90bf76de282 | Ruby | mjc/genealogy | /spec/genealogy/model_settings_spec.rb | UTF-8 | 4,181 | 2.515625 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
module ModelSettingsSpec
extend GenealogyTestModel
describe "*** Model and table settings ***" do
before(:each) do
ModelSettingsSpec.define_test_model_class(has_parents_opts)
end
describe 'model with options :father_column => "padre", :mother_column => "madre", :current... | true |
3eef60e44ebc465d71cb184cb46ed1090b2b593b | Ruby | MefazM/md-server-v2 | /lib/battle/entity/spells/stun_spell.rb | UTF-8 | 401 | 2.6875 | 3 | [] | no_license | module Battle
class StunSpell
def initialize(time)
@time = time
@finish_at = time + Time.now.to_f
@complited = false
end
def reset!
@finish_at = @time + Time.now.to_f
end
def ready?(time)
@complited = @finish_at < time
end
def complited?
@complited
... | true |
805a7fce1386970d9a13ac6ad3513127ddff6ec4 | Ruby | Sheddyka07/learn-co-sandbox | /scraper.rb | UTF-8 | 326 | 2.734375 | 3 | [] | no_license | require 'nokogiri'
require 'open-uri'
html = open("https://web.archive.org/web/20160227204808/http://flatironschool.com/team")
doc = Nokogiri::HTML(html)
instructors = doc.css("#instructors .team-holder .person-box")
instructors.each do |instructor|
puts "Flatiron School <3 " + instructor.css("h2").tex... | true |
3957e20e98f76ea80ac59359405a4424d7a17c56 | Ruby | SJeannie/oo-banking-houston-web-071618 | /lib/bank_account.rb | UTF-8 | 1,128 | 3.484375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
require_relative "transfer"
class BankAccount
attr_reader :name
attr_accessor :balance, :status
@@all_accounts = []
def initialize(name)
@name = name
@balance = 1000
@status = "open"
@valid = true
@@all_accounts << self
end
def deposit(amount)
@balance += amount
... | true |
336c9a9fdf2747ba6b37b8a878d5f7cca2fad6b1 | Ruby | johnlinatoc/countdown-to-midnight-chicago-web-051319 | /countdown.rb | UTF-8 | 260 | 3.609375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | #write your code here
def countdown(input)
while input>0
puts "#{input} SECOND(S)!"
input-=1
end
"HAPPY NEW YEAR!"
end
def countdown_with_sleep(input)
while input>0
puts "#{input} SECOND(S)!"
input-=1
sleep 1
end
"HAPPY NEW YEAR!"
end
| true |
a39564ac2c07582fd61c89fa672b2704d0ef05c9 | Ruby | kernelsmith/workbook | /test/test_table.rb | UTF-8 | 4,945 | 2.921875 | 3 | [
"MIT",
"GPL-3.0-only",
"LGPL-2.0-or-later",
"GPL-2.0-only",
"Ruby"
] | permissive | # frozen_string_literal: true
require File.join(File.dirname(__FILE__), "helper")
class TestTable < Minitest::Test
def test_initialize
t = Workbook::Table.new
assert_equal(t, [])
c = Workbook::Cell.new("celllll")
t = Workbook::Table.new [[c]]
assert_equal([[c]], t)
end
def test_header
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.