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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
65856e1de9296d9f750ab3c87c8b8686bb4717b5 | Ruby | MixMasterT/Daily-Projects | /spec/deck_spec.rb | UTF-8 | 1,071 | 3.390625 | 3 | [] | no_license | require "deck"
require "rspec"
describe "#initialize" do
subject(:deck) {Deck.new}
it "start with a full deck" do
expect(deck.cards.length).to eq(52)
end
let(:high_card) {double("ace of spades", value: :ace, suit: :spades)}
it "provides a deck ordered from highest to lowest value" do
expect(deck.car... | true |
ff10fc58f0f5c1f976c13e92081952beb5efdb2b | Ruby | frm/covid_pt | /lib/covid_pt/report.rb | UTF-8 | 3,975 | 2.71875 | 3 | [
"MIT"
] | permissive | require "rest-client"
require "pdf-reader"
require "nokogiri"
module CovidPT
class Report
MUNICIPALITY_EDGE_CASES = {
"Monsaraz" => "Reguengos de Monsaraz",
"Graciosa" => "Santa Cruz da Graciosa",
"Penaguião" => "Santa Marta de Penaguião",
"António" => "Vila Real de Santo António",
}.... | true |
b24aac29563fd7af8316cf34b2e34fc7a907d00d | Ruby | svillegascreative/learn_ruby | /02_calculator/calculator.rb | UTF-8 | 332 | 3.734375 | 4 | [] | no_license | def add(x, y)
x + y
end
def subtract(x, y)
x - y
end
def sum(array)
total = 0
array.each {|x| total += x}
total.to_i
end
def multiply(x, y)
x * y
end
def product(array)
total = 1
array.each {|x| total *= x}
total.to_i
end
def factorial(n)
total = 1
(1..n).each do |num|
total *= num
end
... | true |
b56871f9303b8f356d06ac12c058277357b2bf92 | Ruby | pmimark/muskokaroastery09052017 | /current/app/models/shopping_cart.rb | UTF-8 | 3,124 | 2.890625 | 3 | [] | no_license | class ShoppingCart
attr_reader :items, :promo_discount, :shipping, :discount_id, :order_id
def initialize()
# @items = options[:items] || []
# @promo_discount = options[:promo_discount] || 0
# @discount_id = options[:discount_id] || nil
@items = []
@promo_discount = 0
@discount_id = nil
... | true |
26dbdb3bf752b7012545c26cefb912534ebc0487 | Ruby | clockworkpc/cpc-study-projects | /advent_of_code_2020/aoc2020ruby/spec/advent_of_code/day_06_custom_customs_spec.rb | UTF-8 | 2,742 | 3 | 3 | [] | no_license | require './lib/advent_of_code/custom_customs'
RSpec.describe AdventOfCode::CustomCustoms do
let(:puzzle_input) { File.read('./spec/fixtures/input_day_06.txt') }
let(:sample_input) do
<<~'HEREDOC'
abc
a
b
c
ab
ac
a
a
a
a
... | true |
82f44dc7d6a1905a70e60e2adcd8bbe510cc0e9d | Ruby | EMG114/cartoon-collections-001-prework-web | /cartoon_collections.rb | UTF-8 | 593 | 3.28125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def roll_call_dwarves(dwarf_list)
dwarf_list.each_with_index do |dwarf, index|
puts "#{index + 1}. #{dwarf}"
end
end
def summon_captain_planet(natural_elements)
natural_elements.map do |natural_element|
natural_element.capitalize!
natural_element << "!"
end
end
def long_planete... | true |
fe4e50a01b5a8bfdc6bd375e3fd9ff19b2448ee0 | Ruby | pusewicz/sonia | /widgets/foursquare/foursquare.rb | UTF-8 | 1,863 | 2.59375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | module Sonia
module Widgets
class Foursquare < Sonia::Widget
CHECKINS_URL = "http://api.foursquare.com/v1/checkins.json"
def initialize(config)
super(config)
EventMachine::add_periodic_timer(150) { fetch_data }
end
def initial_push
fetch_data
end
def... | true |
7dba1024dcd67da42d009358d12e5c44ea0a3e88 | Ruby | brianchiang-tw/RoR_Intro | /class_methods_variables.ru | UTF-8 | 615 | 4.25 | 4 | [] | no_license |
class MathFunctions
def self.double( var )
times_called;
return (var * 2)
end
# Using << self
class << self
def times_called
# Initialized to 0 by default
@@times_called ||= 0;
return @@times_called += 1
end
... | true |
7c6158ffe2cfe9b1b16a6182296cbecda9302182 | Ruby | TenjinInc/procrastinator | /lib/procrastinator/task_store/simple_comma_store.rb | UTF-8 | 6,023 | 2.828125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'csv'
require 'pathname'
module Procrastinator
# Task storage strategies.
#
# All task stores must implement the API #read, #create, #update, #delete.
module TaskStore
# Simple Task I/O adapter that writes task information (ie. TaskMetaData attributes) to a CSV ... | true |
4f448ead00cbcc61f397e0958a6452eb7c957bfa | Ruby | GiovaniGil/CaixaEletronico | /test/models/cliente_test.rb | UTF-8 | 634 | 2.59375 | 3 | [] | no_license | require "test_helper"
class ClienteTest < ActiveSupport::TestCase
def cliente
@cliente ||= Cliente.new nome: "Giovani Paulino", email: 'j@j.com.br', password: Devise::Encryptor.digest(Cliente, 'password')
end
def test_valid
assert cliente.valid?, "Erro no modelo Cliente: "+errors
end
def test_sem_... | true |
cdd539a12696b5b5a7ad6bf3265b3cb2412c5391 | Ruby | gdistasi/omf-tools | /routing/static_routing.rb | UTF-8 | 978 | 2.515625 | 3 | [] | no_license | require 'core/orbit.rb'
require 'core/routing_stack.rb'
class StaticRouting < RoutingStack
def initialize(prefix)
@prefix=prefix
end
def InstallStack
@orbit.GetNodes().each do |node|
node.GetInterfaces().each do |ifn|
if (ifn.IsWifi()) then
address=Address.new("#{@pr... | true |
96c4b781b17215b72149aaa78705a3938a45d90c | Ruby | jerryzhucs1999/ICS-Course | /ICS-Course/ch10/dictSort.rb | UTF-8 | 524 | 3.890625 | 4 | [] | no_license | def dictionary_sort arr
capital_sort arr, []
end
def capital_sort unsorted, sorted
if unsorted.length <= 0
return sorted
end
smallest = unsorted.pop
still_unsorted = []
unsorted.each do |var|
if var.downcase < smallest.downcase
still_unsorted.push smallest
smallest = var
else
st... | true |
eb3bfef4c37928ab630f59f426ca9d7187495197 | Ruby | Wenhui/BestBay | /app/models/comment.rb | UTF-8 | 1,110 | 2.890625 | 3 | [] | no_license | #Corresponding database table: comments
#This class describes a comment that a user can leave for an item.
# #It has the following attributes:
# [created_at] :datetime
# [updated_at] :datetime
# [id] :integer id of the comment
# [item_id] :integer ... | true |
3f2d272ca09bbb48a795d1c90498334fa6c66ec7 | Ruby | Greg-Aubert/mini_game_POO | /lib/player.rb | UTF-8 | 3,079 | 3.734375 | 4 | [] | no_license | class Player #génère une classe qui permettra la création de joueurs respectant les paramètres ci dessous
attr_accessor :name, :life_points
def initialize(name)
@name = name #nom du personnage
@life_points = 10 #nb de pdv du personnage
end
def show_state #permet d'afficher les points de vie du personn... | true |
b7b1e3edc7ba7f1875a7e0e684a21d0a369a7c0f | Ruby | aziparu/gilded_rose_kata_1 | /test/models/gilded_rose_spec.rb | UTF-8 | 1,725 | 2.921875 | 3 | [] | no_license | require 'rails_helper'
describe GildedRose do
describe '#update_quality' do
it 'does not change the name' do
items = [Item.new('foo', 0, 0)]
GildedRose.new(items).update_quality()
expect(items[0].name).to eq 'foo'
end
it 'does not degrade quality below zero' do
no_quality_item =... | true |
5b01037c32c292880f94b1015f3c81989a173f4f | Ruby | Krolmir/ruby-exercises | /rb120_object_oriented_programming/oo_basics_4/prefix_the_name.rb | UTF-8 | 273 | 4.25 | 4 | [] | no_license | # PRoblem: Add the proper accessor method so that name is returns with Mr.
class Person
attr_reader :name
def name=(first_name)
@name = "Mr. " + first_name
end
end
person1 = Person.new
person1.name = 'James'
puts person1.name
# Expected output:
# Mr. James | true |
f7186c4b8e4df24135ee70292fd596d773d5d2f0 | Ruby | keithb418/lv-gsa | /test/selenium-ruby/spec/menu_spec.rb | UTF-8 | 1,202 | 2.625 | 3 | [] | no_license | require_relative '../../selenium-ruby/pages/Welcome'
require_relative '../../selenium-ruby/pages/Menu'
describe 'Menu' do
# GSA-7: Menu Button
before(:all) do
@welcome = Welcome.new (@driver)
@menu = Menu.new (@driver)
@welcome.return_proceed_button.click
end
it 'will have links to graph, medlist,... | true |
d5deb4324bc0cfd39269b3be970fd69a3f318136 | Ruby | infochimps-labs/senor_armando | /lib/senor_armando/rack/set_content_type.rb | UTF-8 | 2,583 | 2.515625 | 3 | [
"MIT"
] | permissive | require 'rack/mime'
require 'rack/respond_to'
require 'pathname'
module SenorArmando
module Rack
# The render middleware will set the Content-Type of the response
# based on the provided HTTP_ACCEPT headers.
#
# @example
# use SenorArmando::Rack::SetContentType
#
class SetContentType
... | true |
451f39330bc4af21e3985ec9e27668a98ebfd7b5 | Ruby | shiratsu/shoppingrails | /lib/tasks/rakuten_category_crawl.rb | UTF-8 | 1,064 | 2.515625 | 3 | [] | no_license | # coding: utf-8
require 'net/http'
require 'uri'
require 'json'
require "date"
class Tasks::RakutenCategoryCrawl
# メイン処理
def self.execute
d = Date.today
now = d.strftime("%Y-%m-%d %H:%M:%S")
#APIリクエスト回数
start = 0;
apiRequestLimit = 2000
apikey = '1059788590851227265'
category_id=0
... | true |
e3c20371cd10b6d392fef01152fa14e76978887f | Ruby | maureena/pippin | /db/seeds.rb | UTF-8 | 1,089 | 2.71875 | 3 | [] | no_license | require 'faker'
# Create Users
5.times do
user = User.new(
name: Faker::Name.name,
email: Faker::Internet.email,
password: Faker::Lorem.characters(10)
)
user.skip_confirmation!
user.save
end
users = User.all
# Create Venues
20.times do
Venue.create(
name: Faker::Lorem.words(3).join("... | true |
3d5be36abe18a69d97d09b21268486cd7543ccba | Ruby | quick919/sandox | /2017/12/testdriven_ruby/Money.rb | UTF-8 | 757 | 3.71875 | 4 | [] | no_license | require_relative './ExpressionInterface'
require_relative './Sum'
class Money < ExpressionInterface
attr_accessor :amount, :currency
def initialize(amount, currency)
@amount = amount
@currency = currency
end
def ==(other_money)
@amount == other_money.amount && @currency == other_money.currency
e... | true |
b46f4b832f3332dbe7bed0b6cd64627bb8fd523b | Ruby | careo/neverblock | /lib/neverblock/core/pool.rb | UTF-8 | 2,635 | 2.953125 | 3 | [
"Ruby"
] | permissive | module NeverBlock
# Author:: Mohammad A. Ali (mailto:oldmoe@gmail.com)
# Copyright:: Copyright (c) 2008 eSpace, Inc.
# License:: Distributes under the same terms as Ruby
#
# A pool of initialized fibers
# It does not grow in size or create transient fibers
# It will queue code blocks when needed ... | true |
57dfb01328ca42c09e14068118622b487b512e8d | Ruby | zimbatm/monkeypatch | /lib/monkeypatch.rb | UTF-8 | 5,604 | 3.09375 | 3 | [
"LicenseRef-scancode-public-domain"
] | permissive | =begin rdoc
This is the public API to produce new patches.
Once you have a patch, look at Patch and it's children to see how to use it.
=end
module MonkeyPatch
# MonkeyPatch's version as a string
VERSION = '0.1.2'
# May be raised on check_conflicts
class ConflictError < StandardError; end
# A collection... | true |
213632cbbe6cdcdfeb94762dc62e8b325f2fb218 | Ruby | wonda-tea-coffee/atcoder | /abc/104/a.rb | UTF-8 | 88 | 2.796875 | 3 | [] | no_license | r = gets.to_i
if r < 1200
puts 'ABC'
elsif r < 2800
puts 'ARC'
else
puts 'AGC'
end | true |
b2bbc4a0220a971289a3ea9ef5487926f97f1a17 | Ruby | maxgud/Git_Assignment_Week_2_Dev_Point | /Ruby_Shopping/shopping_with_ruby.rb | UTF-8 | 9,003 | 3.59375 | 4 | [] | no_license | @cash = 50.00
@a = 0
@b = 0
@c = 0
@d = 0
@e = 0
class Customer_Items
attr_accessor :customer_item, :c_amount
def initialize(customer_item, c_amount)
@customer_item = customer_item
@c_amount = c_amount
end
end
class Store
attr_accessor :item, :amount, :price
def initialize(item, amount, price)
@item = ... | true |
6bf84a7f7358c463eef09fe64a70a84dc3823207 | Ruby | SHiroaki/Ruby | /dokusyu/sec3_numeric.rb | UTF-8 | 639 | 3.890625 | 4 | [] | no_license | # coding: utf-8
# 数値の比較
i,j,k,m = 5,8,3,5
# <=> 左項が大きいときは1,左項と右項が等しい時は0, 右項が大きい時は-1を返す
p i <=> j
p i <=> k
p i <=> m
# prac3.2
puts "--------------------prac3.2--------------------"
puts 10 / 3, 10 % 3
f = 10.3
d = -10.3
puts f.ceil
puts d.floor
t = 255
puts t.to_s(2)
puts t.to_s(8)
puts t.to_s(16)
puts "--------... | true |
f3d176ccac8d27430256e9a63e845419365cac6f | Ruby | shorrockin/adventofcode2020 | /11.rb | UTF-8 | 2,531 | 3.375 | 3 | [] | no_license | # typed: false
# frozen_string_literal: true
require './boilerplate.rb'
require './coordinates.rb'
require './11_test_data.rb'
module State
FLOOR = '.'
EMPTY = 'L'
OCCUPIED = '#'
end
# converts a sequence of lines into a Flat::Grid object
def to_grid(lines)
lines = lines.split("\n") if lines.is_a?(String)
F... | true |
c4769dd19ffe33ba81f01cf483ae010d6b75b2a6 | Ruby | kchansf5/aA-homeworks | /W1D4/DIY_ADTs.rb | UTF-8 | 908 | 3.734375 | 4 | [] | no_license | # Exercise 1
class Stack
def initialize
@stack = []
end
def add(el)
@stack << el
end
def remove
@stack.pop
end
def show
@stack
end
end
# Exercise 2
class Queue
def initialize
@queue = []
end
def enqueue(el)
@queue << el
end
def dequeue
@queue.shift
end
d... | true |
a7e098b43d1108ec018ecc2b01d6a1179b0be6c4 | Ruby | zhxbab/r2x | /generate_pram.rb | UTF-8 | 3,691 | 2.53125 | 3 | [] | no_license | #!/usr/bin/env ruby_dv_1_9_2
#!/usr/bin/env ruby_dv_1_9_2 --disable-gems
#
require 'json'
$chip = ARGV[0]
$ucodedefine = ARGV[1]
raise "chip not defined" if ! $chip
$output = "#{$chip}_tracer_autogen.pm"
$all_subs = []
def usage
print "#{$0} <ucodedefine> covert pram ucode define file into la2avp tracer data s... | true |
0ff4c22ac07082373a798d046ffdf10cd81e4631 | Ruby | Shiler/abi-bot | /lib/lp_updates_manager.rb | UTF-8 | 280 | 2.765625 | 3 | [] | no_license | require_relative 'message.rb'
class LPUpdatesManager
def LPUpdatesManager.get_messages(updates)
new_messages = []
updates.each do |update|
update.first == 4 ? new_messages << Message.new(update[1], update[3], update[6]) : nil
end
new_messages
end
end | true |
8f345aa24bc35f770bd13a3b25b47c5089b09cf5 | Ruby | MysteriousSonOfGod/propython | /fundamentos/metaprog/roman.rb | UTF-8 | 187 | 3.3125 | 3 | [] | no_license |
class Roman
def romanToInt(str)
# ...
end
def method_missing(methId)
str = methId.id2name
romanToInt(str)
end
end
r = Roman.new
r.iv » 4
r.xxiii » 23
r.mm » 2000
| true |
af6b184a69f069dfbaf441f1c654737b626fac75 | Ruby | crispyears/beer_exercise | /beer.rb | UTF-8 | 453 | 4.625 | 5 | [] | no_license | require 'pry'
#write a function that accepts a variable: age
#if age is greater than 21, display "Yay, have a beer!"
#if age is less than 21, display "Nay, don't have a beer!"
def can_you_drink(age)
if age.to_i < 21
puts "Nay don't have a beer!"
else
puts "Yay, have a beer!"
end
end
#ask for the user's age
put... | true |
f3c8863d712094065ed74fb772488f75c849d898 | Ruby | denys-kvyk/Projects | /TAQC with RUBY/pages/application.rb | UTF-8 | 2,350 | 2.546875 | 3 | [] | no_license | require_relative '../data/application_source.rb'
require_relative '../data/application_source_repository.rb'
require_relative '../tools/browser_wrapper.rb'
#require_relative './user/home_page.rb'
#require_relative './user/shopping_cart.rb'
require_relative 'user/home_page/home_page_atomic'
require_relative 'user/home_p... | true |
84804cfaea652355ea492602a13c6a136a61a5ec | Ruby | maksimmanzhai/RubySchool | /lesson 09/app11.rb | UTF-8 | 178 | 3.640625 | 4 | [] | no_license | #lesson 9
arr = []
while true
puts "What is your favorite color? Stop for exit"
color = gets.strip
if color == "stop"
puts arr.reverse.uniq!
exit
end
arr << color
end | true |
7c02cf02887c5ddedb0dff0ff8768284399f777b | Ruby | csu-xiao-an/bricolage | /lib/bricolage/taskqueue.rb | UTF-8 | 2,239 | 2.859375 | 3 | [
"MIT"
] | permissive | require 'bricolage/jobnet'
require 'bricolage/exception'
require 'fileutils'
require 'pathname'
module Bricolage
class TaskQueue
def initialize
@queue = []
end
def empty?
@queue.empty?
end
def size
@queue.size
end
def queued?
not empty?
end
def each(&b... | true |
920d9925671b1a24a8092ebcd8cf1d613d622ed7 | Ruby | alyaluk/ruby-flashcards | /flashcard.rb | UTF-8 | 1,560 | 3.6875 | 4 | [] | no_license | # Main file for your code.
list = []
IO.foreach('flashcard_samples.txt') do |line|
list << line
end
list.delete("\n")
x = 1
$game = Hash.new
random = []
$keys = []
points = 0
number = nil
$multi = false
size = list.length / 2
for i in (0...list.length/2)
$game[list[x].gsub("\n","")] = list[x-1].gsub("\n","")
rando... | true |
80451d0bf05d2bb796d1b153f9468f0f0f4b24d5 | Ruby | spartalisdigital/lotu | /spec/lotu/actor_spec.rb | UTF-8 | 2,669 | 2.578125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'lotu'
class Actress < Lotu::Actor
collides_as :actress_in_distress
use Lotu::SteeringSystem
end
class Fan < Actress
use Lotu::StalkerSystem
end
describe "Actor" do
before :each do
@game = Lotu::Game.new(:parse_cli_options => false)
@actor = Lotu::Actor.new
@actress = Actress.new
@fa... | true |
be4dca508bd9139de730faa72eedeae2f5a49ead | Ruby | junftnt/whistlepig | /build/gen-test-main.rb | UTF-8 | 771 | 3.046875 | 3 | [
"BSD-3-Clause"
] | permissive | #!/usr/bin/env ruby
abort "expecting one argument: the filename" unless ARGV.size == 1
fn = ARGV.shift
funcs = []
IO.foreach(fn) do |l|
if l =~ /TEST\((.+?)\)/
funcs << $1
end
end
puts %q!
#include <stdio.h>
#include "error.h"
#include "test.h"
!
puts funcs.map { |f| "TEST(#{f});" }
puts %q!
int main(int ar... | true |
c2fcfc411b53e97e6300e921d6aab4467e9d14a3 | Ruby | kylelong/ruby_tutorial | /hexToRgb.rb | UTF-8 | 926 | 3.828125 | 4 | [] | no_license | =begin
Converts hex codes to rgb
https://www.mathsisfun.com/hexadecimals.html
supports hashtag and non hashtag
@param s string to be converted to RGB
@return RGB representation of a string
=end
def hex_to_rgb(s)
if s[0] == "#" #removes '#' from evalutation
s = s[1..s.length]
end
if s.to_s.length < 6... | true |
023b8baeba2526a069533b435292bc15f3ba4d2a | Ruby | mfichman/portfolio | /app/helpers/chart_helper.rb | UTF-8 | 2,118 | 3.03125 | 3 | [] | no_license | module ChartHelper
def percent(value, total)
"#{(value / total * 100).round}%"
end
def legend(labels)
capture do
labels.each_with_index do |label, n|
yield label, n
end
end
end
# Takes an array of series, each of which is a list of values
def line(series, style: 'fill')
... | true |
fc1433afc1bfc560ba5b28bf8a85cb8cb11f7f1e | Ruby | mozulevskyi/schooling | /app/models/arrays.rb | UTF-8 | 2,197 | 3.53125 | 4 | [] | no_license | a = Array.new(10).map(){rand(10)}
#Дан целочисленный массив. Необходимо переставить в обратном порядке элементы массива, расположенные между его минимальным и максимальным элементами.
a = [7, 2, 7, 1, 6, 3, 2, 9, 8]
s = a.index(a.min)
d = a.index(a.max)
a[s+1..d-1].reverse
#=> [2, 3, 6]
#Дан целочисленный массив. Не... | true |
9812b8d0388e92d3191da7b614beea34f04910e4 | Ruby | abi-wilson25/Final-Project | /models/model.rb | UTF-8 | 6,555 | 2.828125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'net/http'
require 'json'
require 'pp'
require "http"
require "optparse"
# Place holders for Yelp Fusion's OAuth 2.0 credentials. Grab them
# from https://www.yelp.com/developers/v3/manage_app
CLIENT_ID = "x0LOXFAjrgc9FObJNnszTQ"
CLIENT_SECRET = "1mWDj5IL7JIGZ7KLnvzTNpWDy2777z3NHr4XvBf54MPLDRJGu3gJqxQG8J1gX... | true |
67943e61e34bce083af98957efc29f65d463da21 | Ruby | opener-project/pos-tagger-en-es | /lib/opener/pos_taggers/en_es/es.rb | UTF-8 | 395 | 2.59375 | 3 | [
"Apache-2.0"
] | permissive | module Opener
module POSTaggers
##
# Spanish POS tagger class. This class forces the language to Spanish
# regardless of what the KAF document claims the language to be.
#
class ES < EnEs
##
# @see [Opener::POSTaggers::Base#language_from_kaf]
#
def language_from_kaf(input)
... | true |
56da20330aca61e538e331713829369419e5adc0 | Ruby | adambird/entity_stormotion | /spec/motion/sqlite_entity_store_spec.rb | UTF-8 | 2,195 | 2.53125 | 3 | [
"MIT"
] | permissive | # Integration tests for the local store
class DummyEntity
include EntityStore::Entity
attr_accessor :name
def set_name(at, name)
record_event DummyEntityNameSet.new(at: at, name: name)
end
end
class DummyEntityNameSet
include EntityStore::Event
attr_accessor :name
time_attribute :at
def apply... | true |
ea755dba40d2abaa1269cd0f4dc3fefd5ab3764a | Ruby | ilpoldo/connie | /lib/connie/connie.rb | UTF-8 | 1,619 | 3.0625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | module Connie
class DictionaryNotFound < StandardError; end
class DictionaryNameNotAllowed < StandardError; end
@dictionaries = {}
@alphabet = %w(a A b B c C d D e E f F g G h H i I j J k K l L m M n N o O p P q Q r R s S t T u U v V w W x X y Y z Z)
def self.dictionaries_paths;@dictionaries_paths;en... | true |
7485179d9e345f202a284ddbf1329c2c2b20fcf5 | Ruby | takkkun/idol_master | /lib/idol_master/cinderella_girls/user.rb | UTF-8 | 1,472 | 2.6875 | 3 | [] | no_license | require 'idol_master/cinderella_girls/idol'
require 'idol_master/cinderella_girls/idol_store'
require 'idol_master/cinderella_girls/ensure'
require 'yaml'
module IdolMaster
module CinderellaGirls
class User
def initialize(path, options = {})
@options = options
data = YAML.load_file(path... | true |
c192b0c0f6ae171e21c73e324511b0a8e15ea9b6 | Ruby | stupendousC/ride-share-rails | /app/controllers/trips_controller.rb | UTF-8 | 4,926 | 2.53125 | 3 | [] | no_license | class TripsController < ApplicationController
def index
# Where did the request come from? Per passenger? or per driver? or per trips index?
@passenger = Passenger.find_by(id: params[:passenger_id])
@driver = Driver.find_by(id: params[:driver_id])
if @driver
# showing trips for a specific dr... | true |
20331ec7aabec2e857396452c8347ab93ca67654 | Ruby | hdemon/hdemon-backend | /response.rb | UTF-8 | 191 | 2.53125 | 3 | [] | no_license | class Response
attr_accessor :data, :message, :error
def render
{
message: @message || "Success.",
errors: @errors || [],
data: @data
}.to_json
end
end
| true |
e2ea3ecb23e0f0ce1e0583a7681d4e07ce3478e9 | Ruby | JetechNY/ruby-oo-relationships-practice-boating-school-exercise | /app/models/student.rb | UTF-8 | 873 | 3.125 | 3 | [] | no_license | require 'pry'
class Student
attr_accessor :first_name
@@all = []
def initialize(first_name)
@first_name = first_name
@@all << self
end
def self.all
@@all
end
def add_boating_test(testname, teststatus, instructor )
BoatingTest.new(self, testname, testst... | true |
ec4c9b69e3c45e177bfae01feda716ef6431de7a | Ruby | radiospiel/vex | /lib/vex/base/hash/slop.rb | UTF-8 | 2,939 | 3.390625 | 3 | [] | no_license | #
# - allows to use hash.xx.yy where you would have to use
# hash["xx"][:yy] etc.
#
# - supports
#
# hash.xx?
#
# as a shortcut for hash.key?(:xx) || hash.key?("xx")
#
# - does not support assignment, though; i.e.
#
# hash.yy = zz
#
# will raise a NoMethodError.
#
class Hash
module Slop
private
def ... | true |
57c2247c65571008dbb46f17ccd646878b13e24e | Ruby | bumpouce/ruby-oo-relationships-practice-blood-oath-exercise-seattle-web-030920 | /tools/console.rb | UTF-8 | 2,404 | 2.90625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require_relative '../config/environment.rb'
def reload
load 'config/environment.rb'
end
# Insert code here to run before hitting the binding.pry
# This is a convenient place to define variables and/or set up new object instances,
# so they will be available to test and play around with in your console
#Test cult se... | true |
a3eb31ac89d0023f601ad85143117e8f9014ae4b | Ruby | evgeniradev/ruby_data_structures_and_algorithms | /data_structures/linked_list.rb | UTF-8 | 1,559 | 3.78125 | 4 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class LinkedList
def initialize(value)
node = Node.new(value)
@head = node
@tail = node
@length = 1
end
attr_reader :head, :tail, :length
def append(value)
node = Node.new(value)
@tail.next = node
@tail = node
@length += 1
node
end
def prepend(value)
node = Node.ne... | true |
274fcd2156d5f4119bac4c6fda2895c2d0ac25fb | Ruby | Mstandley1985/ted_lasso_2103 | /lib/team.rb | UTF-8 | 280 | 3.4375 | 3 | [] | no_license | class Team
attr_reader :name,
:coach,
:players
def initialize(name, coach, players)
@name = name
@coach = coach
@players = []
end
def add_player(player)
@players << player
end
def total_salary
@players
end
end
| true |
610c04d27c66a85a9ddd6aafb919c9f74be1ab2c | Ruby | Ess91/black_history | /lib/black_history/oct_blackhistory.rb | UTF-8 | 673 | 3.03125 | 3 | [
"MIT"
] | permissive | require 'pry'
class BlackHistory::Oct_BlackHistory
@@all = []
attr_accessor :events, :dates, :locations, :event_url, :descriptions
def initialize
#@events = events
#@dates = dates
#@locations = locations
#@event_url = event_url
# @descriptions = descriptions
@@all << self
end
def self.all... | true |
f7947e36fb8fd6e511a09b0948ab73160e16fd11 | Ruby | bgraves14/Battleships | /lib/ship.rb | UTF-8 | 180 | 3.28125 | 3 | [] | no_license |
class Ship
attr_reader :coordinates, :placed
def initialize
@placed = false
@coordinates = []
end
def position(ship_position)
@coordinates << ship_position
end
end
| true |
00d3c0c4e7832573ca491436162f87a31d35e293 | Ruby | rn0rno/kyopro | /aoj/ruby/01_ITP/ITP1_10_C.rb | UTF-8 | 174 | 3 | 3 | [] | no_license | #!/usr/bin/env ruby
until (n = gets.to_i).zero?
s = gets.chomp.split.map(&:to_f)
ave = s.inject(:+) / n
puts Math.sqrt(s.map { |i| (i - ave)**2 }.inject(:+) / n)
end
| true |
e3a4107ede1dd1662924dee9e28e1eeaeaf25db2 | Ruby | ShetlandJ/employee_system_practice | /company.rb | UTF-8 | 775 | 2.859375 | 3 | [] | no_license | require_relative('employee')
require_relative('manager')
require_relative('supervisor')
require_relative('cog')
class Company
def initialize(name, employees, performance, cash)
@name = name
@employees = employees
@performance = performance
@available_cash = cash
end
# getters
def name()
... | true |
0d5ea9dc40d07b0ace962a562d305e46940bfabf | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/gigasecond/6342e324c9394f49b0277d6dae67d47c.rb | UTF-8 | 157 | 2.84375 | 3 | [] | no_license | module Gigasecond
def self.from(date)
seconds = date.to_time.to_i
gigaseconds = seconds + 1_000_000_000
Time.at(gigaseconds).to_date
end
end
| true |
5d180f3de7b8acad5bfaf7781ec01557543624e5 | Ruby | phil/playbox | /lib/controllers/interface.rb | UTF-8 | 1,592 | 2.921875 | 3 | [] | no_license | require 'singleton'
# Interface controller is responsible for managing connections and updating those connections as events are processed by thr player
class InterfaceController
include Singleton
attr_accessor :connections
def connections
@connections ||= Array.new
end
def client_connected conn
self.con... | true |
3042b09ca5d0c3b8387e6724bc43c65af794c5dc | Ruby | rohita/MusicExplorer | /test/unit/lfm_album_test.rb | UTF-8 | 1,387 | 2.578125 | 3 | [] | no_license | require 'test_helper'
class LfmAlbumTest < ActiveSupport::TestCase
def setup
@album = LfmAlbum.find("Dummy", "Portishead")
end
test "can get album title" do
assert_equal "Dummy", @album.title
end
test "can get album artist name" do
assert_equal "Portishead", @album.artist_name
end
t... | true |
589f0f54ab5ea5018445c24f73213613e25fc305 | Ruby | jodokusquack/connect_four | /spec/cell_spec.rb | UTF-8 | 821 | 3.25 | 3 | [] | no_license | require './lib/cell.rb'
RSpec.describe Cell do
subject(:cell){ Cell.new(content: "X") }
describe "#content" do
it "returns the content of the cell" do
expect(cell.content).to eq "X"
end
end
describe "#to_s" do
it "prints its content to the screen" do
expect { puts cell }.to output("X... | true |
79ce3cd21e2e83b7f4d50fc3a671a778a5f15b0a | Ruby | billdevcode/phase-0 | /week-4/calculate-grade/my_solution.rb | UTF-8 | 629 | 4.0625 | 4 | [
"MIT"
] | permissive | # Calculate a Grade
# I worked on this challenge [with: David Walden].
# Your Solution Below
=begin
input: integer
output: string
IF provided integer is between 90 to 100
grade is A so return "A"
IF provided integer is between 80 to 89
grade is B so return "B"
IF provided integer is between 70 to 79
grade i... | true |
991c7939c0f7281df0870918f8a8d7c26fb1f4e7 | Ruby | B0NG0FURY/upcoming_releases | /lib/upcoming_releases/scraper.rb | UTF-8 | 2,036 | 2.859375 | 3 | [
"MIT"
] | permissive | class UpcomingReleases::Scraper
def self.scrape_release_page(release_url)
doc = Nokogiri::HTML(open(release_url))
result = []
doc.css("div.product-page div.uk-grid div.album").each do |album|
info = {
:name => album.css("h5").text,
:artist => album... | true |
675a3386462570212239f64fbdaaf38ce2a38eae | Ruby | renamabo/enigma-1 | /spec/offset_spec.rb | UTF-8 | 504 | 2.625 | 3 | [] | no_license | require './spec/spec_helper'
require './lib/offset'
RSpec.describe Offset do
context 'instantiation' do
it 'exists' do
date = "16-05-2003"
offset = Offset.new(date)
expect(offset).to be_instance_of(Offset)
end
it 'has attributes' do
date = "16-05-2003"
offset = Offset.n... | true |
034ff1713b968c48ccd479389663010f70189f2d | Ruby | chrystalfaith/ruby-challenges | /blog.rb | UTF-8 | 965 | 3.765625 | 4 | [] | no_license | class My_Blog
def initialize
@time_created = Time.now
puts "What would you like to call your blog?"
@blog_title = gets.chomp
@all_posts = []
@total_posts = 0
end
def create_post
new_post = Blog_Post.new
puts "This is my brand spanking new blog post!"
@all_posts << new_post
@total_posts += 1
end
... | true |
689b60db21d82c55fe22afa6a4e4af29956fbd3e | Ruby | simonrodonnell/function_testing | /ruby_functions_practice.rb | UTF-8 | 1,534 | 4.03125 | 4 | [] | no_license | def return_10
return 10
end
def add(first_number, second_number)
return first_number + second_number
end
def subtract(first_number, second_number)
return first_number - second_number
end
def multiply(first_number, second_number)
return first_number * second_number
end
def divide(first_number, second_number)... | true |
9be4bb6dfc3f473cde03b2d6ffa839f4ef5befec | Ruby | chinmaydd/SnakeforRuby | /game.rb | UTF-8 | 1,993 | 3.703125 | 4 | [] | no_license | class Board
@board = []
100.times do |i|
row = []
@board<<row
end
@board.each do |row|
100.times do |i|
row<<'0'
end
end
def set_snake
choice_x = rand(0..99)
choice_y = rand(0..99)
board[choice_x][choice_y]=3
end
de... | true |
7e34f5a8c859ed85395e6dfb72024066bb4ecf52 | Ruby | b-shears/Relocate-Back-End-Rails | /app/poros/business.rb | UTF-8 | 644 | 3.4375 | 3 | [] | no_license | class Business
attr_reader :name,
:image,
:url,
:phone,
:distance,
:location,
:id
def initialize(result)
@name = result[:name]
@image = result[:image]
@url = result[:url]
@phone = result[:phone]
@distance = mete... | true |
32e3f014dc2f0e6c49d8deff74364f9578e053ea | Ruby | anhbk93/rails_recipe_manager | /test/models/chef_test.rb | UTF-8 | 1,756 | 2.703125 | 3 | [] | no_license | require 'test_helper'
class ChefTest < ActiveSupport::TestCase
def setup
@chef = Chef.new(
chefname: "Anh NV",
email: "navait93@gmail.com"
)
end
test "chef should be valid" do
assert @chef.valid?
end
test "chefname should be present"... | true |
2a67803c2605a8f753d833166784843ba9e3dd06 | Ruby | houston/attentive | /test/entities/core_number_test.rb | UTF-8 | 1,660 | 2.515625 | 3 | [
"MIT"
] | permissive | require "test_helper"
class CoreNumberTest < Minitest::Test
extend Attentive::Test::Entities
entity("core.number").should do
match("0").as(0)
match("4").as(4)
match("-5").as(-5)
match("6.75").as(BigDecimal.new("6.75"))
match("451,972.00").as(BigDecimal.new("451972.00"))
match("$6.45").as... | true |
58efbc13b0c2b6e5370e876761d08b6f55c3c12b | Ruby | bmaland/hyde | /lib/jekyll/engines.rb | UTF-8 | 2,065 | 2.671875 | 3 | [
"MIT"
] | permissive | module Jekyll
module Engines
def self.setup(config)
# Set the Markdown interpreter (and Maruku self.config, if necessary)
@@config = config
case config['markdown']
when 'rdiscount'
begin
require 'rdiscount'
rescue LoadError
puts 'You must have the rdisc... | true |
7f6912750fb55a3a90f029d5d8b7711632169c80 | Ruby | philcrooks/homework04.1 | /models/wordformatter.rb | UTF-8 | 223 | 3.25 | 3 | [] | no_license | class WordFormatter
def WordFormatter.postcode(text)
return text.upcase
end
def WordFormatter.camel_case(text)
words = text.downcase.split(' ').map { | word | word.capitalize }
return words.join
end
end | true |
24af99edae29278f71df77aae0285113439e7352 | Ruby | Paolavuolo/it-s_me_mario | /exo_13.rb | UTF-8 | 331 | 3.546875 | 4 | [] | no_license | #liste d'email
i = 1
email_list = Array.new()
while (i <= 50)
if (i<10) #cette ligne permet d'ajouter un 0, pour 01,02 etc..
email = "jean.dupont.0#{i}@email.fr"
else
email = "jean.dupont.#{i}@email.fr"
end
email_list.push (email) #.push() va permettre d'insérer les mails dans l'array... | true |
4ab9592a8faa69b0ab9ab660f034f1786f8c0d06 | Ruby | primeapple/ruby-experiments | /experiments/tic-tac-toe/state.rb | UTF-8 | 1,806 | 3.65625 | 4 | [] | no_license | class State
SIZE = 3
def initialize(state = {})
@state = state
if state == {}
SIZE.times do |x|
SIZE.times do |y|
@state[[x, y]] = ' '
end
end
end
end
def next_state(x, y, char)
raise ArgumentError.new('Wrong argument for x given') unless x.between?(0, 2)... | true |
be290f71514d46b0fe49ad2fabc9c0e5f431ca13 | Ruby | lebrancconvas/Ruby-Lab | /avc.rb | UTF-8 | 43 | 2.71875 | 3 | [] | no_license | a = [1,2,3,4]
b = a.map(a = a + 5)
print(b) | true |
de657d749e2706fe2aebebe0d51c014ff95a500e | Ruby | luong-komorebi/dd-trace-rb | /lib/ddtrace/augmentation/shim.rb | UTF-8 | 2,539 | 2.765625 | 3 | [] | permissive | require 'set'
require 'ddtrace/patcher'
require 'ddtrace/augmentation/method_wrapping'
module Datadog
# A "stand-in" that intercepts calls to another object. i.e. man-in-the-middle.
# This shim forwards all methods to object, except those overriden.
# Useful if you want to intercept inbound behavior to an object... | true |
e7b7e7f3e62e1472608de4b78c1b5e3d6e6e74f7 | Ruby | helenpxx/ics_bc_s18 | /week4/ch10/dict_sort.rb | UTF-8 | 642 | 3.859375 | 4 | [] | no_license | def dict_sort(some_array) # This "wraps" recursive_sort.
recursive_dict_sort some_array, []
end
def recursive_dict_sort(unsorted_array, sorted_array)
# Your fabulous code goes here.
if unsorted_array.length == 0
sorted_array
else
min_index = min_ind unsorted_array
min_elem = unsorted_array.delete_at mi... | true |
890c3cf720d054fcdc8ad006d75a41755bd68c66 | Ruby | drwrf/lang | /old/lib/lang/token.rb | UTF-8 | 1,862 | 3.15625 | 3 | [] | no_license | class Lang::Token
class << self
def define(&block)
class_eval(&block)
end
def token(name, start, capture: nil, quote: false, &block)
cls = Class.new(self)
cls.const_set('START', start)
cls.const_set('CAPTURE', capture)
cls.const_set('QUOTE', quote)
const_set(name, cls... | true |
fe1307ec4540d6fb5e71a7652f90c27e315c9bf0 | Ruby | paddyjoneill/wk2_weekend_homework | /karaoke_bar.rb | UTF-8 | 1,990 | 3.625 | 4 | [] | no_license | require 'pry'
class KaraokeBar
attr_reader :name, :rooms, :bars, :till, :entrance_fee
def initialize(name, rooms, bars, initial_balance, entrance_fee)
@name = name
@rooms = rooms
@bars = bars
@till = initial_balance
@entrance_fee = entrance_fee
end
def add_room(room)
@rooms << room
... | true |
7404c70261d67a315656d86289cb3d9e02df235a | Ruby | lsegal/couchio | /lib/couchio/couch_open.rb | UTF-8 | 374 | 2.546875 | 3 | [
"MIT"
] | permissive | module CouchOpen
def open(name, mode = 'r', *perm, &block)
if name.index("couch://") == 0
couch_io_class.new(name, mode, &block)
else
couch_orig_open(name, mode, *perm, &block)
end
end
alias new open
private
def couch_io_class
case self.to_s
when 'File'
CouchDocumen... | true |
97bb18ef882b5297249c264c7f9bec83431265f7 | Ruby | extreem-engineer/extreme-engineer4 | /fare.rb | UTF-8 | 150 | 2.84375 | 3 | [] | no_license | class Fare
attr_accessor :fare, :dept, :dest
def initialize(fare,dept,dest)
@fare = fare
@dept = dept
@dest = dest
end
end | true |
ebd7c2a5f3eab884db3202d013f7bf3a69cb14cb | Ruby | soundasleep/adventofcode2016 | /spec/advent_01_spec.rb | UTF-8 | 4,792 | 3.40625 | 3 | [] | no_license | require "spec_helper"
class Advent01
attr_reader :x, :y, :dx, :dy
attr_reader :previous_visits, :visited_twice
NORTH = [0, -1]
SOUTH = [0, 1]
WEST = [-1, 0]
EAST = [1, 0]
def initialize
@x = 0
@y = 0
@dx, @dy = NORTH
@previous_visits = {}
end
def call(input)
input.split(", ").e... | true |
a1731382621a7a28fdfbe56fffe1de1bde08aa87 | Ruby | PewePro/alef-tng | /lib/tasks/data.rake | UTF-8 | 9,874 | 2.78125 | 3 | [] | no_license | require 'rubygems'
require 'nokogiri'
require 'open-uri'
require 'pandoc-ruby'
require 'csv'
namespace :alef do
namespace :data do
# import questions from ALEF docbook environment
# run:
# rake alef:data:import_xml['xml_dir']
task :import_xml, [:directory] => :environment do |t, args|
direct... | true |
14db0cf4de75ed69c0da05be9060018fc31d2efb | Ruby | rails/rails | /actioncable/lib/action_cable/channel/broadcasting.rb | UTF-8 | 1,297 | 2.71875 | 3 | [
"MIT",
"Ruby"
] | permissive | # frozen_string_literal: true
require "active_support/core_ext/object/to_param"
module ActionCable
module Channel
module Broadcasting
extend ActiveSupport::Concern
included do
delegate :broadcasting_for, :broadcast_to, to: :class
end
module ClassMethods
# Broadcast a ha... | true |
31053a49775f3aad2c0da20b41a7f0aecfc4b37f | Ruby | willfowls/prepcourse | /ruby_books/intro_to_ruby/more_stuff/exercises/5.rb | UTF-8 | 408 | 3.359375 | 3 | [] | no_license | # Why does the following code
# Give us the error message below the code itself
#def execute(block)
# block.call
# end
#
# execute { puts "Hello from inside the execute method!" }
#block.rb1:in `execute': wrong number of arguments (0 for 1) (ArgumentError)
#from test.rb:5:in `<main>'
# I believe that it is di... | true |
f5d330584893ffbc160d7782d5e27850ae123f3d | Ruby | drunkwater/leetcode | /hard/ruby/c0043_224_basic-calculator/00_leetcode_0043.rb | UTF-8 | 667 | 3.75 | 4 | [] | no_license | # DRUNKWATER TEMPLATE(add description and prototypes)
# Question Title and Description on leetcode.com
# Function Declaration and Function Prototypes on leetcode.com
#224. Basic Calculator
#Implement a basic calculator to evaluate a simple expression string.
#The expression string may contain open ( and closing parenth... | true |
ced9fc160cbb78a8c7184c4ddb60a15704fbe057 | Ruby | ishikota/PokerServer | /spec/poker_engine/deck_spec.rb | UTF-8 | 1,230 | 2.875 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe Deck do
let(:deck) { Deck.new }
describe "#draw_card" do
it "should return a card and remove it from deck" do
card = deck.draw_card
expect(card.to_s).to eq 'SK'
expect(deck.size).to eq 51
end
end
describe "#draw_cards" do
it "should retur... | true |
4f663f7686353ee298e3f07dd7f893f68f2d1ce0 | Ruby | codonnell/railsicorn | /test/services/attacks_coercer_test.rb | UTF-8 | 1,764 | 2.71875 | 3 | [] | no_license | require 'test_helper'
class AttacksCoercerTest < ActiveSupport::TestCase
def generic_attacks
{ attacks:
{ :"1" =>
{
timestamp_started: 1000,
timestamp_ended: 1050,
attacker_id: 12,
attacker_name: 'twiddles',
attacker_faction: 13,
attacker_factionname:... | true |
5cf0fb7269d0681b6f0e38da823b361f93503f36 | Ruby | Davidslv/programming-exercises | /wegottickets-scrapper/scrapper.rb | UTF-8 | 1,632 | 3.078125 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'nokogiri'
require 'restclient'
require 'json'
require 'pry'
class Scrapper
attr_reader :page_number, :page, :acts, :listing_outers
MAX_NUMBER_PAGES = 20
def initialize
@page_number = 1
@acts = []
@outers = 10
process_page
process_outers
end
def process_... | true |
a7dd4bf4c60148a21e4b14a74356fe620b1b7fa6 | Ruby | bwl21/vector2d | /lib/vector2d/fitting.rb | UTF-8 | 1,658 | 3.34375 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
class Vector2d
module Fitting
# Scales down the given vector unless it fits inside.
#
# vector = Vector2d(20, 20)
# vector.contain(Vector2d(10, 10)) # => Vector2d(10,10)
# vector.contain(Vector2d(40, 20)) # => Vector2d(20,10)
# vector.contain(Vector2d(20, 40)) # => ... | true |
f9cf4c5cd4cc7513931f53d0dc8d9b40cc7c82c9 | Ruby | ShahakBH/jazzino-master | /support/deployment/lib/scp.rb | UTF-8 | 1,777 | 2.5625 | 3 | [] | no_license | module Yazino
class SCP
def self.start(hostname, params = {}, &block)
ssh = Yazino::SCP.new(hostname, params)
if block_given?
yield ssh
else
ssh
end
end
def initialize(hostname, params = {})
@username = ENV['USER']
@port = 22
@exit_on_error = tru... | true |
9284885730a354f9f0dc907a47dcad3d81ab9a75 | Ruby | J-Y/RubyQuiz | /ruby_quiz/quiz117_sols/solutions/Albert Ng/SimFrost2.rb | UTF-8 | 3,902 | 3.25 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby -w
class SimFrost
require 'RMagick'
VACUUM=" " #Chris Shea reminded me of constants...
VAPOR="+"
ICE="*"
ICECOLOR='blue'
VAPORCOLOR='grey'
VACUUMCOLOR='white'
attr_reader :grid, :vapor
def initialize (width=30,height=24, vapor_percent=30, showvapor=true)
@x_size=width... | true |
385e74830774562c897a7b17298ebe94c1ff13a2 | Ruby | hiroshima-t1/Nomikai | /vendor/gems/ri_cal-0.8.7/lib/ri_cal/property_value/recurrence_rule/occurrence_incrementer/by_minute_incrementer.rb | UTF-8 | 813 | 2.546875 | 3 | [
"MIT"
] | permissive | module RiCal
class PropertyValue
class RecurrenceRule < PropertyValue
#- ©2009 Rick DeNatale, All rights reserved. Refer to the file README.txt for the license
#
class OccurrenceIncrementer # :nodoc:
class ByMinuteIncrementer < ListIncrementer #:nodoc:
def self.for_rrule(rrule)... | true |
2541e7b598cb55e06c6aeaf652b578aca1e99e34 | Ruby | QiruiSun/Assignment-Ruby-Fundamentals-Part-Two | /exercise7.rb | UTF-8 | 756 | 3.703125 | 4 | [] | no_license | students = { :cohort1 => 34,
:cohort2 => 42,
:cohort3 => 22
}
students.each {|key, value| puts "#{key} : #{value} students"}
students[:cohort4] = 43
students.each { |key, value| puts "#{key}"} #what happens when you only put |key| in the {}
students.each do |key, value|
num = value * 1.05
puts "#{key} : #{n... | true |
34394a71127e962ae5e8c822e26a79d88b75a84f | Ruby | brianburridge/mvc_sample | /team_view.rb | UTF-8 | 180 | 2.796875 | 3 | [] | no_license | class TeamView
def self.cheer(team)
puts "Go #{team.team_name}!"
end
def self.announce_win(team)
puts "The #{team.team_name} from #{team.home_town} wins!"
end
end
| true |
fbf27ac086d67bd76b3057fc18ce5656bcc794a6 | Ruby | AbbottMichael/backend_mod_1_prework | /final_prep/annotations.rb | UTF-8 | 4,454 | 4.5 | 4 | [] | no_license | # Add your annotations, line by line, to the code below using code comments.
# Try to focus on using correct technical vocabulary.
# Use the # to create a new comment
# Build a Bear
# declare a new function that takes 5 arguments
def build_a_bear(name, age, fur, clothes, special_power)
# declares the local variable... | true |
1b7eb0a95c837b455a69dc316d895986335af447 | Ruby | fourmojo/siwapp | /app/models/invoice.rb | UTF-8 | 2,516 | 2.734375 | 3 | [] | no_license | class Invoice < Common
belongs_to :recurring_invoice
has_many :payments, dependent: :delete_all
accepts_nested_attributes_for :payments, :reject_if => :all_blank, :allow_destroy => true
validates :customer_email,
format: {with: /\A([\w+\-].?)+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+\z/i,
message: "Only ... | true |
293fe189344b163b75fb4b1cec404918f42ffd67 | Ruby | hackhands/riot-rails | /test/active_record/validates_length_of_test.rb | UTF-8 | 1,484 | 2.84375 | 3 | [
"MIT"
] | permissive | require 'teststrap'
context "The validates_length_of assertion macro" do
setup_test_context
setup { topic.asserts("room") { Room.new } }
should("fail when minimum length causes an error") do
topic.validates_length_of(:name, (4..15)).run(Riot::Situation.new)
end.equals([:fail, ":name should be able to be 4... | true |
a616333f23857efa9e91dfdbc4cb94b913deeb47 | Ruby | RubyProjectVu/LDB | /LDB_5lab/spec/models/budget_manager_spec.rb | UTF-8 | 1,879 | 2.546875 | 3 | [] | no_license | # frozen_string_literal: true
require_relative 'custom_matcher'
require_relative '../rails_helper'
describe BudgetManager do
let :bm do
described_class.new
end
it 'retrieves the state' do
expect(bm.stater).to be true
end
it 'returns state after setting budget' do
Project.create(name: 'test', b... | true |
ea21b97bf3a598578b1e107c2d7f7232d66a94c1 | Ruby | ZuhairS/Algorithms-and-Data-Structures | /Assortment/Count_triplet_sum_less_than_target.rb | UTF-8 | 423 | 3.625 | 4 | [] | no_license | def count_triplets(arr, target)
count = 0
arr.sort!
(0...arr.length - 2).each do |idx|
left_idx, right_idx = idx + 1, arr.length - 1
while left_idx < right_idx
sum = arr[idx] + arr[left_idx] + arr[right_idx]
if sum < target
count += (right_idx - left_idx)
left_idx += 1
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.