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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
5a81184f961e974af2d690d2ebb12d5dd76c5560 | Ruby | mondrian/tubform-rsig | /vendor/plugins/i18n_localize_core/lib/i18n_localize_core/string_extensions.rb | UTF-8 | 580 | 2.703125 | 3 | [
"MIT"
] | permissive | class String
def as_delocalized_number
result = self.clone
result.gsub!(I18n.thousand_separator, '_') if I18n.thousand_separator
result.gsub!(I18n.decimal_separator, '.') if I18n.decimal_separator
result
end
alias original_to_f to_f
def to_f(localize = nil)
localize = I18n.localize_core i... | true |
f3513748a8ef6712385a3695a95704e2f2b21ddb | Ruby | BearerPipelineTest/girl_friday | /test/test_error_handler.rb | UTF-8 | 1,340 | 2.703125 | 3 | [
"MIT"
] | permissive | require 'helper'
class TestErrorHandler < MiniTest::Unit::TestCase
Stderr = GirlFriday::ErrorHandler::Stderr
Airbrake = GirlFriday::ErrorHandler::Airbrake
class FakeStderr
include Faker
def flush
"WOOSH!"
end
alias_method :puts, :count
alias_method :write, :count
end
class FakeAi... | true |
7e8ba671a8736b8992e6d83a89887d88a144e476 | Ruby | sullycodes/parks | /lib/parks.rb | UTF-8 | 467 | 3.234375 | 3 | [
"MIT"
] | permissive | require_relative '../config/environment'
class Park
attr_accessor :name, :url, :address, :phone, :overview, :activities
@@all = []
def initialize(name = nil, url = nil)
@name = name
@url = url
@@all << self
end
def self.all
@@all
end
def add_park_attributes(park_url)
hash = Scraper.scrape_park... | true |
8f8b0a3e5569fdb00a91edd5833e5d2b6cb3436c | Ruby | runcoderun/cogent_times | /spec/controllers/crud_controller_spec.rb | UTF-8 | 3,977 | 2.515625 | 3 | [] | no_license | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
def model(clazz, attributes=nil, &attribute_block)
define_method(:model_class) {return clazz}
attr_accessor :valid_model_attributes
attr_accessor :valid_parameters
define_method(:initialize_attributes) do
object_attributes = attributes ||... | true |
cddf2d3ce7bd2ebd5918f8eca9b0a7f0ae485e63 | Ruby | clondono/FriendSplitter | /test/models/event_test.rb | UTF-8 | 10,174 | 2.96875 | 3 | [] | no_license | # Author: Lucy
require 'test_helper'
class EventTest < ActiveSupport::TestCase
# Event should not save if there is no amount field
test "Validate amount presence" do
event = Event.new
event.title = "Title"
event.description = "Description"
assert !event.save, "Event should not ... | true |
8eb82b474cd66a94bf05a296b1e2d8a06a56edbd | Ruby | Jablooo/Restaurant | /restaurant2.rb | UTF-8 | 5,117 | 4 | 4 | [] | no_license | class Pasta
# - How do we describe it
def initialize(name, ingredients, price)
@name = name
@ingredients = ingredients
@price = price
end
attr_accessor :name, :ingredients, :price
# - What does it do
def show_pasta_ingredients
@name.each do |pastaType|
puts "- #{pastaType.ingredients}"
... | true |
7c95562a2b2ef0a6ecbe9d90ec838ffc9ec039e8 | Ruby | Hansen-Nick/RB101 | /101-109_practice_problems/easy_3/counting.rb | UTF-8 | 135 | 3.84375 | 4 | [] | no_license | print "Please write a word or multiple words: "
words = gets.chomp
puts "There are #{words.delete(' ').length} characters in #{words}." | true |
f13ccec0868906e6851e7bd37265a06a978ee1d9 | Ruby | Dwire/deli_counter_flatiron | /customer_view.rb | UTF-8 | 653 | 3.375 | 3 | [] | no_license |
module CustomerView
def line_view(current_line)
puts current_line.length > 0 ? "\nThe line is currently: #{current_line.join(" ")}" : "\nThe line is currently empty."
end
def take_a_number_view(name)
puts @deli_line.length == 1 ? "Welcome #{name}, you are first in line." : "Welcome #{name}, you are num... | true |
c7e36795f11822fb3aa4edefd395f87bf4c1be14 | Ruby | shristigautam/vector-space-model | /data/reuters21578/remove_nils.rb | UTF-8 | 696 | 2.703125 | 3 | [] | no_license | require 'fileutils'
i = 0
Dir.new("adapted_docs").select{|name| name != "." and name != ".."}.each do |name|
if File.size("adapted_docs/#{name}") <= 10
i = i + 1
puts name
FileUtils.rm "adapted_docs/#{name }"
end
end
puts "#{i} files removed"
missing = {}
Dir.new("adapted_topics").select{|name| name != "." and... | true |
20c431614cad5c7cac4fd9d2ab16bd617104b730 | Ruby | lermannen/advent_of_code_2015 | /day6a.rb | UTF-8 | 10,546 | 3.109375 | 3 | [] | no_license | def handle_input(line, grid)
coords = line.match(/(\d+),(\d+) through (\d+),(\d+)/)
.captures.map(&:to_i)
case
when line.start_with?("turn on") then turn_on(coords, grid)
when line.start_with?("turn off") then turn_off(coords, grid)
when line.start_with?("toggle") then toggle(coords, grid)
end
end
def t... | true |
aa75ea288c34a84319eaa388bbb22cbb913453ee | Ruby | takuan517/aoj_ruby | /ITP1/ITP1_2_B.rb | UTF-8 | 135 | 3.25 | 3 | [] | no_license | a = gets
b = a.split
if b[0].to_i < b[1].to_i && b[1].to_i < b[2].to_i && b[0].to_i < b[2].to_i
puts "Yes"
else
puts "No"
end
| true |
4e01c4c09bacd08a4368afe593a0c0815f8e6203 | Ruby | georgebixby/BEWD_NYC_6_Homework | /__george_bixby/midterm/play.rb | UTF-8 | 322 | 3.1875 | 3 | [] | no_license | require 'json'
require 'rest-client'
require 'pry'
require './word_counter'
require './times_headline'
@year = 0
while @year <= 1900 || @year >= 2013 do
puts "Please enter a date between 1900 and 2013"
year = gets
@year = year.to_i
end
t = TimesHeadline.new(@year)
w = WordCounter.new(t.headlines)
w.count_word... | true |
d7c14979c9b82decf79d215b91755ed59950add5 | Ruby | stujo/pokemonit | /pokemonit.rb | UTF-8 | 1,472 | 2.9375 | 3 | [] | no_license | require 'dotenv'
Dotenv.load
require 'sinatra'
require 'httparty'
def load_data(filename)
File.readlines(filename).inject({}) do |hash, line|
matches = /^(\d+)\s+([^\s]+)/.match(line)
hash[matches[1].to_i] = matches[2]
hash
end
end
$names = load_data('./data.txt')
$filter = [
1,2,3,5,6,9... | true |
52b7e6e97a7b60833ff1c7e83fc07a519692f397 | Ruby | cwrydberg/ninjabear | /bear.rb | UTF-8 | 334 | 3.21875 | 3 | [] | no_license | require_relative 'fighter'
#links from the fighter.rb file in the ninjabeargame folder
class Bear < Fighter
def attack(enemy)
puts "Rawwr!!"
enemy.lose_health(self.power)
end
end
# bear = Bear.new("Bear", 100, 12)
# ninja = Fighter.new("Ninja", 100, 10)
# # ninja.attack(bear)
# # p bear
# # bear.attack(ninja)... | true |
cce116ed42d99e3139648c6caf62de059e2367a3 | Ruby | utensils/barcoded | /docker-assets/usr/local/bin/edit-unicorn-config.rb | UTF-8 | 2,099 | 3 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
# This script is used to read a unicorn configuration file into memory
# Update values based on ENV variables and write it back to disk.
CONFIG_FILE = '/usr/local/etc/barcoded/unicorn.rb'
ENV_CONFIG_OPTIONS = {
'UNICORN_WORKERS' => 'worker_processes',
'UNICORN_TIMEOUT' => 'timeout'... | true |
2d1f7cc2092ee1f628362badfbcc2ad42addaddf | Ruby | danpariente/trading_risk_calculator | /risk_calculator.rb | UTF-8 | 550 | 3.3125 | 3 | [] | no_license | class RiskCalculator
ATR_RATIO = 1.5
RISK_PERCENTAGE = 0.02
private_constant :ATR_RATIO, :RISK_PERCENTAGE
attr_writer :atr_ratio, :risk_percentage
def initialize(balance:, atr:)
@balance = balance
@atr = atr
end
def pip_value
(risk / (atr_ratio * atr)).round(2)
end
def risk
balance... | true |
4ce53a4fb2999426d814ce001ec4d211d64f29f0 | Ruby | AamuLumi/UniSoc | /main.rb | UTF-8 | 1,391 | 2.796875 | 3 | [] | no_license | $: << "."
require 'timeout'
require 'lib/uniSocPrinter'
require 'lib/twitterDebug'
# executeCommand
# -> Execute la commande spécifiée
# PARAMS :
# command : la commande à exécuter
# RETURN : No
def executeCommand(command)
commands = command.downcase.split(" ")
case commands[0] # Correspond à la première commande ... | true |
2f2f5b20a15e50c928d6a01cc035f33624fa4435 | Ruby | nickborbe/bootcamp | /week_2/thursday/web_blog/app.rb | UTF-8 | 1,923 | 3.203125 | 3 | [] | no_license | require "sinatra"
require "sinatra/reloader"
require 'date'
require_relative('lib/blog.rb')
require_relative('lib/post.rb')
require_relative('lib/comment.rb')
my_blog = Blog.new
post0 = Post.new("Downtown Chickens", Date.new(2016, 1, 1), "I saw feral chickens under the metro rail station", "Nick Borbe")
post1 = Post... | true |
8ad63f894b8fc312dbab752c2c0e537318b268d7 | Ruby | Srkiscool/phase2_s19 | /test/models/customer_test.rb | UTF-8 | 2,754 | 2.703125 | 3 | [] | no_license | require 'test_helper'
class CustomerTest < ActiveSupport::TestCase
#Relationships
# --------------------------
should have_many(:orders)
should have_many(:addresses)
#Validation macros...
should validate_presence_of(:first_name)
should validate_presence_of(:last_name)
#validate phone number
should ... | true |
67803cd0d28c9dacb5612628e02a28509f2e0c96 | Ruby | paradigmshift/course1 | /lesson2/oop_blackjack.rb | UTF-8 | 3,946 | 3.8125 | 4 | [] | no_license | class Card
attr_accessor :rank, :suit
def initialize(rank, suit)
self.rank = rank
self.suit = suit
end
def to_s
"#{rank} of #{suit}"
end
end
class Deck
attr_accessor :cards
def initialize(number_of_decks=1)
self.cards = []
number_of_decks.times do
["Hearts", "Diamonds", "Spades... | true |
4c09541de22cd97a2c7144dbb72ec0d5a9771b91 | Ruby | wesenu/rrobots | /bots/SpaceInvader.rb | UTF-8 | 7,095 | 2.9375 | 3 | [] | no_license | require 'rrobots/robot.rb'
class Sector
attr_accessor :name
attr_accessor :range
attr_accessor :enemies
attr_accessor :closest_enemy
attr_accessor :gun_direction
def initialize(sector_range, sector_name)
@name = sector_name
@range = sector_range
@fire_to = range.first
@gun_direction = 1... | true |
230767b61eeea38878ab199718e819d232bf4042 | Ruby | gnufied/representable | /test/json_test.rb | UTF-8 | 3,792 | 2.796875 | 3 | [
"MIT"
] | permissive | require 'test_helper'
require 'representable/json'
module JsonTest
class APITest < MiniTest::Spec
Json = Representable::JSON
Def = Representable::Definition
describe "Xml module" do
describe "#binding_for_definition" do
it "returns ObjectBinding" do
assert_kind_of Json::Objec... | true |
08da21bf9a37a6c7ce62140363293986847be2bd | Ruby | faheemmughal/bitmap_editor | /lib/bitmap_editor/image.rb | UTF-8 | 2,354 | 3.359375 | 3 | [] | no_license | # frozen_string_literal: true
module BitmapEditor
class Image
MIN_COLUMNS = MIN_ROWS = 1
MAX_COLUMNS = MAX_ROWS = 250
attr_accessor :number_of_rows, :number_of_columns, :bitmap
def initialize(columns, rows)
# we are going to store the image in zero based arrays
# and do translation on f... | true |
b6af0e4a8bf5d5a50479a60122c4f7e05f7116b2 | Ruby | navya7744/Coding_Assignment | /features/libraries/locator.rb | UTF-8 | 4,854 | 2.671875 | 3 | [] | no_license | # frozen_string_literal: true
module Libraries
class Locator
attr_accessor :how, :what, :options
def initialize(
how,
what,
options = {
'hidden' => false,
'ajax_load' => false
}
)
@how = how
@what = what
@options = options
end
# #Highlig... | true |
90dd1ba153bf89208274187102c677c0ab9db5a7 | Ruby | javifc/forecast | /app/services/forecast_service.rb | UTF-8 | 970 | 3.046875 | 3 | [] | no_license | require 'net/http'
class ForecastService
@base_url_find_by_city = "http://api.openweathermap.org/data/2.5/forecast/daily?"
def self.find_by_city(city, days=16, format="json", units="metric")
return {success: false, error: "A city has to be provided" } if city.blank?
url = @base_url_find_by_city + "q=#{city}&... | true |
e34d73b5f78d4e23560a65011a25e3a902a28a4a | Ruby | yanovitchsky/karibu | /lib/karibu/request.rb | UTF-8 | 1,322 | 2.75 | 3 | [
"MIT"
] | permissive | # @author yanovitchsky
module Karibu
class Request
attr_accessor :uniq_id, :resource, :method, :params
def initialize(packet)
@packet = packet
end
def decode
@msg = MessagePack.unpack(@packet, :symbolize_keys => true, :encoding => Encoding::UTF_8)
check_msg()
[:type=, :uniq_id... | true |
48a0ded6d663ea32916c3414f38fe8d7c5533113 | Ruby | ryu2129/paiza | /Brank/4-1.rb | UTF-8 | 190 | 3.703125 | 4 | [] | no_license | #3文字列がスペース区切りで2つ入力されるので、スペースで分割し、2行で出力してください。(同じ問題多いな・・・)
N = gets.split(' ')
puts N | true |
3ca92024d1d1461d7d6c50c3408b80288c118550 | Ruby | dclechok/ruby-class-variables-and-class-methods-lab-online-web-ft-090919 | /lib/song.rb | UTF-8 | 1,061 | 3.640625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Song
attr_accessor :name, :artist, :genre
@@count = 0
@@genres = []
@@artists = []
def initialize(song_name, artist, genre)
@@count += 1
@@genres << genre
@@artists << artist
@name = song_name
@artist = artist
@genre = genre
end
def self.count()
@@coun... | true |
e0c8a0ee1855a81144386b8ed41311e7bdcc0c19 | Ruby | Whelpley/phase-0 | /week-5/die-class/my_solution.rb | UTF-8 | 2,339 | 4.25 | 4 | [
"MIT"
] | permissive | # Die Class 1: Numeric
# I worked on this challenge [by myself!]
# I spent [1.5] hours on this challenge.
# 0. Pseudocode
=begin
# Input:
# Output:
-Depends on the methods being called.
Initialize: takes the # of sides, return the new Die object
Sides: takes no arguments, returns the # of sides
Roll: takes no argume... | true |
461e46c1cf7237e0ef9b72d39e3a67b09a0d4851 | Ruby | lsethi-xoriant/interviewcake | /solutions/ruby/stockPrices.rb | UTF-8 | 681 | 3.984375 | 4 | [] | no_license | =begin
Solution
We walk through the array from beginning to end, keeping track of:
our min_price so far
our max_profit so far
For each time, we check to see if:
we have a new min_price, or
buying at the current min_price and selling at the current_price would give a new max_profit.
So we have:
=end
m... | true |
dc747a997e42183aa12624c854e0859076788921 | Ruby | giraffi/giraffi | /lib/giraffi/client/triggers.rb | UTF-8 | 3,904 | 2.734375 | 3 | [
"MIT"
] | permissive | module Giraffi
class Client
# Defines methods related to the triggers
module Triggers
# Returns the desired trigger
#
# @requires_apikey Yes
# @param options [Hash] The request params to retrieve the desired triggers
# @return [HTTParty::Response]
def find_triggers(options... | true |
6a73c1c6c5ecb5cb415cdc91b67861bf35c7738e | Ruby | alu0100902341/P12_LPP | /lib/gema/cocinero.rb | UTF-8 | 960 | 3.421875 | 3 | [
"MIT"
] | permissive | class Cocinero
attr_accessor :experiencia, :contador, :edad
def initialize
@edad = 36
@experiencia = "pinche"
@contador = 0
end
def uno_mas
if @edad < 50
@edad = @edad + 1
if @edad == 44
@experiencia = "cocinero"
end
if @edad >= 44
@contador = @contador + 1
end
else
... | true |
0bd7ead59654a3bca2b7da4b172619b0e37f3aae | Ruby | gardengeek/remarkable | /remarkable/lib/remarkable/dsl/assertions.rb | UTF-8 | 6,423 | 3.453125 | 3 | [
"MIT"
] | permissive | module Remarkable
module DSL
module Assertions
protected
# It sets the arguments your matcher receives on initialization.
#
# arguments :name, :range
#
# Which is roughly the same as:
#
# def initialize(name, range, options = {})
# @n... | true |
dd62dd27b2fb13cfff01fefa8414ed61fb251e40 | Ruby | cielavenir/procon | /atcoder/codefestival/tyama_atcodercodefestival2015qualaC.rb | UTF-8 | 145 | 2.703125 | 3 | [
"0BSD"
] | permissive | #!/usr/bin/ruby
N,T=gets.split.map &:to_i
s=0
A=N.times.map{a,b=gets.split.map &:to_i;s+=a;b-a}.sort
p s>T ? (1..N).find{|i|(s+=A[i-1])<=T}||-1:0 | true |
0da038425b1f33cda9ee7756fd3c842fd876d272 | Ruby | qbahers/google-code-jam | /2013/qualification-round/tic-tac-toe-tomek/tic-tac-toe-tomek.rb | UTF-8 | 2,847 | 3.296875 | 3 | [] | no_license | class Problem
def check_rows(board, output)
board.each do |row|
if (row.first == "X" || row.first == "O")
symbol = row.first
else
symbol = row[1]
end
count = row.count(symbol)
t_symbol = row.include?("T")
if ((symbol == "X" || symbol == "O") &&
(... | true |
b548a2a5e7a28f6d7fabddb0296f2f9c34b481ee | Ruby | braydon322/sql-crowdfunding-lab-v-000 | /lib/sql_queries.rb | UTF-8 | 1,634 | 2.65625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive |
def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabetized_by_name
"SELECT projects.title, SUM(pledges.amount) FROM projects INNER JOIN pledges ON projects.id = pledges.project_id GROUP BY projects.id ORDER BY projects.title ASC;"
end
def selects_the_user_name_age_and_pledge_amount_for_all_pledges_a... | true |
0af084c554f42d721a4aef8727364657ae2ea656 | Ruby | AlfredoVillalobos/Desafio-latam | /Desafio-latam/clases online/hola.rb/primera-clase-ruby/entrada.rb | UTF-8 | 69 | 3.15625 | 3 | [] | no_license | numero = -1
numero = gets.chomp.to_i while numero < 0 || numero > 36 | true |
8592858e1fa261bc4d411ff8f85f2d8fa31f9613 | Ruby | rowlandjl/ruby-collaborating-objects-lab-cb-000 | /lib/song.rb | UTF-8 | 509 | 3.03125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Song
attr_accessor :name, :artist
@@all = []
def self.all
@@all
end
def initialize(name)
@name = name
self.class.all << self
end
def self.new_by_filename(name)
parse = name.split(" - ")
artist = Artist.find_or_create_by_name(parse[0])
song = Song.new(parse[... | true |
5f8557bbf4af391c70e5aefca8ae63837ae90797 | Ruby | lainventoria/aaww | /lib/aaww/transaction.rb | UTF-8 | 2,096 | 2.578125 | 3 | [
"MIT"
] | permissive | module Aaww
class Transaction
include ActiveModel::Model
extend Forwardable
attr_accessor :key, :token, :file, :email, :value, :job_id, :link,
:ssl_link, :status, :progress
def_delegators :status, :ok?, :error?
# Creates a single unique token for this transaction
# Returns... | true |
9b9f7f03141bc6a6c57f7871152047fa8fdc5cef | Ruby | dibdas/tic-tac-toe | /lib/player.rb | UTF-8 | 161 | 3.125 | 3 | [] | no_license | class Player
attr_reader :name, :symbol
attr_accessor :moves
def initialize(name, symbol)
@name = name
@symbol = symbol
@moves = []
end
end
| true |
51244061c826b7522c8942e3d4bd1e25f6e7e877 | Ruby | kennethjohnbalgos/wiser_trails | /lib/wiser_trails/common.rb | UTF-8 | 10,388 | 2.703125 | 3 | [
"MIT"
] | permissive | module WiserTrails
# Happens when creating custom activities without either action or a key.
class NoKeyProvided < Exception; end
# Used to smartly transform value from metadata to data.
# Accepts Symbols, which it will send against context.
# Accepts Procs, which it will execute with controller and context.... | true |
a9c9164c3643820d259e535cb27010dc002caa4d | Ruby | garyeh/projects | /chess/knight.rb | UTF-8 | 163 | 2.671875 | 3 | [] | no_license | require_relative 'stepping_piece'
class Knight < Piece
include SteppingPiece
def initialize(position, board, color)
super
@symbol = "∑"
end
end
| true |
782e211ccf6b48a20f48cf557532b701bb0fe7e3 | Ruby | sagar601/nekoshop-master | /test/factories/order_item_factory_test.rb | UTF-8 | 929 | 2.53125 | 3 | [] | no_license | require 'test_helper'
describe OrderItemFactory do
it 'transforms a collection o CartItems into equivalent OrderItems' do
cart_items = [
Monkey.imitate(CartItem.new,
name: 'item1',
variations: [],
quantity: 1,
base_price: Money.new(99),
options_cost: Money.new(150),... | true |
b518d61d721782ab78af38810f92856274b65c60 | Ruby | fritzvl/protobuf | /lib/protobuf/rpc/servers/socket/server.rb | UTF-8 | 3,249 | 2.53125 | 3 | [] | no_license | require 'protobuf/rpc/server'
require 'protobuf/rpc/servers/socket/worker'
module Protobuf
module Rpc
module Socket
class Server
include ::Protobuf::Rpc::Server
include ::Protobuf::Logger::LogMethods
def self.cleanup?
# every 10 connections run a cleanup routine after clo... | true |
51023463d1a1b27f97700d0b3fec06321fea65da | Ruby | ariera/i19 | /lib/i19/key.rb | UTF-8 | 2,191 | 2.640625 | 3 | [
"MIT"
] | permissive | module I19
class Key
class SourceOcurrence
attr_accessor :src_path, :pos, :line_num, :line_pos, :line
def initialize(args)
@src_path = args[:src_path]
@pos = args[:pos]
@line_num = args[:line_num]
@line_pos = args[:line_pos]
@line = args[:line]
en... | true |
d9549af7358eb3a7e6afd44d7e3072005b26d7b3 | Ruby | nomatteus/adventofcode | /2019/day11/day11.rb | UTF-8 | 3,183 | 3.921875 | 4 | [] | no_license | require 'matrix'
require 'set'
require 'pry'
# Day 9 Intcode works as-is for this problem, so use that
require_relative '../day09/intcode_day9'
input = IO.read('input')
program = Intcode::Helpers.parse_program(input)
class PaintingRobot
attr_reader :painted_panels
# Color values
BLACK = 0
WHITE = 1
# Outp... | true |
df3170a965515e46d17017d936ebfb9a497c437b | Ruby | plato721/ruby-exercism | /allergies/allergies/allergies_test.rb | UTF-8 | 991 | 3.03125 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/pride'
require './allergies.rb'
class AllergiesTest < Minitest::Test
def setup
@all = ["cats", "pollen", "chocolate", "tomatoes", "strawberries", "shellfish",
"peanuts", "eggs"]
@tester = Allergies.new(255)
end
def test_255_returns_all_allergies
tes... | true |
0c820b0e3080dad4d01d800ac419c70af21b172c | Ruby | ga-dc/wdi5 | /w02/d01_object_oriented_programming/04_inheritance/time_traveler.rb | UTF-8 | 245 | 2.703125 | 3 | [] | no_license | class TimeTraveler < Car
def initialize color, max_speed
super
@can_time_travel = true
end
def visit_past
puts "the year is 1900"
end
def drive speed
super
puts "a blazing trail of fire was left behind"
end
end
| true |
c42b28e12cb34917fa4dbc6191aab7bab9e38f08 | Ruby | ahawkins/chassis-example | /vendor/cache/chassis-fca0c675c66b/lib/chassis/dirty_session.rb | UTF-8 | 2,229 | 2.96875 | 3 | [
"MIT"
] | permissive | require 'set'
module Chassis
class DirtySession < Proxy
def initialize(*args)
super
@original_values = { }
@new_values = { }
end
def clean?
new_values.empty?
end
def dirty?
!clean?
end
def original_values
@original_values
end
def new_values... | true |
af6a3741e3fed48b849dfeb349a3514877299b35 | Ruby | KnightsofRen/knights_chess | /spec/models/rook_spec.rb | UTF-8 | 1,214 | 2.796875 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe Rook, type: :model do
describe 'valid_move?' do
it 'should return true if valid, false if invalid' do
game = FactoryGirl.create(:game)
game.pieces.delete_all
# rook is at (4, 4), other pieces at (2, 4) and (4, 2)
rook = FactoryGirl.create(:rook, game_... | true |
370e445d62632e86375c81a0ba6871d9ce3573b6 | Ruby | dariathompson/oystercard | /lib/oystercard.rb | UTF-8 | 612 | 3.515625 | 4 | [] | no_license | # frozen_string_literal: true
class Oystercard
attr_reader :balance
attr_accessor :state
LIMIT = 90
MIN_BAL = 1
def initialize(balance = 0, state = false)
@balance = balance
@state = state
end
def top_up(value)
@balance += value
raise "You exceeded the limit of #{LIMIT}£" if limit?
@... | true |
d311300645fbd6748bb8d0ef3dd9b0a05f5405f8 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/gigasecond/05cf48b01cd046478d4037982d435443.rb | UTF-8 | 124 | 2.8125 | 3 | [] | no_license | class Gigasecond
GIGASECOND = 10**9
class << self
def from(date)
(date.to_time + GIGASECOND).to_date
end
end
end
| true |
463097ea78a09a65d50547aa247ddc2117f8f82d | Ruby | cominvent/elasticrawl | /lib/elasticrawl/job_step.rb | UTF-8 | 1,560 | 2.765625 | 3 | [
"MIT"
] | permissive | module Elasticrawl
# Represents an Elastic MapReduce job flow step. For a parse job this will
# process a single Common Crawl segment. For a combine job a single step
# will aggregate the results of multiple parse jobs.
class JobStep < ActiveRecord::Base
belongs_to :job
belongs_to :crawl_segment
... | true |
9e63080738d515138a50e38c268837715d03d657 | Ruby | caelum/ruby_on_br_forum | /vendor/rails/activerecord/test/defaults_test.rb | UTF-8 | 1,140 | 2.640625 | 3 | [
"BSD-3-Clause",
"MIT"
] | permissive | require 'abstract_unit'
require 'fixtures/default'
require 'fixtures/entrant'
class DefaultTest < Test::Unit::TestCase
def test_nil_defaults_for_not_null_columns
column_defaults =
if current_adapter?(:MysqlAdapter)
{ 'id' => nil, 'name' => '', 'course_id' => nil }
else
{ 'id' => nil,... | true |
bbe72ba3c0e7f5f641f36f90df5ccbf25006c66d | Ruby | warmwaffles/skeleton | /lib/skeleton/item.rb | UTF-8 | 3,543 | 2.84375 | 3 | [
"MIT"
] | permissive | require 'skeleton/model'
module Skeleton
class Item < Model
attr_accessor :type, :format, :title, :description, :default, :multiple_of,
:maximum, :exclusive_maximum, :minimum, :exclusive_minimum,
:max_length, :min_length, :pattern, :max_items, :min_items,
:un... | true |
4b0006c1bb451be824d6251755503f36f852e0dc | Ruby | nigel-lowry/the_ray_tracer_challenge | /lib/point_light.rb | UTF-8 | 266 | 3.3125 | 3 | [] | no_license | class PointLight
attr_reader :position, :intensity
def initialize position, intensity
@position, @intensity = position, intensity
end
def ==(other)
self.class == other.class and @position == other.position and @intensity = other.intensity
end
end | true |
a1a4ecd0a67fd6280543cbdc4d1494d694417837 | Ruby | jonareyes/Destripando-twiter | /destripando_twitter.rb | UTF-8 | 2,135 | 3.25 | 3 | [] | no_license | require 'nokogiri'
class TwitterScrapper
def initialize(url)
@url = Nokogiri::HTML(File.open(url))
end
def extract_username
user = @url.search(".ProfileHeaderCard-name > a")
user.first.inner_text
end
def extract_tweets
tweets = @url.search(".ProfileNav-value")
tweets.first.inner_te... | true |
0c9bc469477179fb1c25aec101386ab6eadc7331 | Ruby | Lee-oh/engine-honeypot-ruby | /bin/executer.rb | UTF-8 | 330 | 2.84375 | 3 | [] | no_license | port_1 = ARGV[0]
port_2 = ARGV[1]
port_3 = ARGV[2]
threads = []
if port_1
threads << Thread.new {system("start main.rb #{port_1}")}
end
if port_2
threads << Thread.new {system("start main.rb #{port_2}")}
end
if port_3
threads << Thread.new {system("start main.rb #{port_3}")}
end
threads.each { |thr| t... | true |
9712e46fcc0288017e8fc3244ebf802abd51566c | Ruby | ECOtterstrom/Ruby_Basics | /12_hashes/ex_129.rb | UTF-8 | 180 | 3.140625 | 3 | [] | no_license | # 12_hashes exercise 9
vehicles = {
car: { type: 'sedan', color: 'blue', year: '2003' },
truck: { type: 'pickup', color: 'red', year: '1998' }
}
puts vehicles | true |
674b2e2d0f530f4257e7c67e8e9de3b00b77d0d1 | Ruby | KalyanAkella/graphs | /spec/topological_sort_spec.rb | UTF-8 | 731 | 2.71875 | 3 | [] | no_license |
require 'graph'
require 'topological_sort'
describe 'topological sort on a graph' do
before(:all) do
@graph = Graph.create %w(shorts pants belt shirt tie jacket socks shoes watch)
shorts, pants, belt, shirt, tie, jacket, socks, shoes, watch = @graph.vertices
@graph.edges(shorts, pants, shoes)
@graph... | true |
3c3b666df93c8873d8951a593d23a495b1abf006 | Ruby | northofnormal/ruby_fundementals | /Data/Happy_Numbers.rb | UTF-8 | 129 | 2.8125 | 3 | [] | no_license | def happy_number?(a)
10.times do
a = a.to_s.chars.map { |x| x.to_i ** 2 }.inject(:+)
return true if a == 1
end
false
end
| true |
2cf6301aaf888a7244a39f336f802a94339a60ba | Ruby | digideskio/icast | /app/models/xiph/directory.rb | UTF-8 | 293 | 2.578125 | 3 | [] | no_license | require 'nokogiri'
require 'open-uri'
class Xiph::Directory
attr_reader :path, :xml
def initialize(path)
@path = path
@xml = Nokogiri::XML(open(path))
end
def each
xml.xpath('//directory/entry').each do |xml_node|
yield Xiph::Entry.new(xml_node)
end
end
end
| true |
11094a6821ef687afab47fa113e60827836d3980 | Ruby | bradx3/fundation | /app/models/deposit_template.rb | UTF-8 | 1,323 | 2.59375 | 3 | [] | no_license | class DepositTemplate < ActiveRecord::Base
validates_presence_of :name
validates_uniqueness_of :name, :scope => :user_id
belongs_to :user
validates_presence_of :user
has_many :deposit_template_fund_percentages, :order => "id asc", :dependent => :destroy
accepts_nested_attributes_for :deposit_template_fund_... | true |
0e37104fcbd97924857476229f83204955e7be43 | Ruby | Edward-Phillips/Bookmark_manager | /lib/bookmark.rb | UTF-8 | 1,013 | 3.015625 | 3 | [] | no_license | require 'pg'
require 'uri'
class Bookmark
attr_reader :name, :address, :id
def initialize(who: "nobody", where: "nowhere", id:)
@id = id
@name = who
@address = where
end
def self.all
self.connect
rs = @con.exec "SELECT * FROM bookmarks"
rs.map { |row| Bookmark.new(where: row['url'], wh... | true |
e75570de3ea004cc9ff50733037b3d0acde7fb3a | Ruby | growth-nirvana/events-ruby | /spec/helpers/runscope_client.rb | UTF-8 | 978 | 2.640625 | 3 | [
"MIT"
] | permissive | require 'faraday'
require 'pmap'
class RunscopeClient
def initialize(api_token)
headers = { 'Authorization' => "Bearer #{api_token}" }
@conn = Faraday.new('https://api.runscope.com', headers: headers)
end
def requests(bucket_key)
with_retries(3) do
response = @conn.get("/buckets/#{bucket_key}/... | true |
6520101130131ff88f0db7eae4e09d029d3e7509 | Ruby | felipeclopes/pontueme | /app/models/coupon.rb | UTF-8 | 413 | 2.578125 | 3 | [] | no_license | class Coupon < ActiveRecord::Base
belongs_to :benefit
belongs_to :user
belongs_to :card
def self.generate_code
code = ''
while code.blank? or Coupon.find_by_code(code)
code = String.random_alphanumeric(8)
end
code
end
private
def String.random_alphanumeric(size=16)
chars = ('a'..'z').to_a... | true |
b1591aa30b49936891913519fe37f37dc0e4fc30 | Ruby | topdan/memory_record | /test/crud_test.rb | UTF-8 | 2,422 | 2.6875 | 3 | [] | no_license | require 'helper'
class CrudTest < Test::Unit::TestCase
include ClassHelper
define_classes %(
class Post < MemoryRecord::Base
attribute.integer :id, auto: true
attribute.string :title
attribute.integer :comments_count
end
)
test 'only create when saved' do
@... | true |
6ddb61ec64179a9ff272850471353cddeeda2cc4 | Ruby | kathirvalavan/data_type_validator | /spec/common_helper.rb | UTF-8 | 299 | 2.59375 | 3 | [
"MIT"
] | permissive | module CommonHelper
def get_sample_value(type)
case type
when :string
['sample1', 'sample2', 'sample3', 'sample4'].sample
when :integer
[1, 2, 3, 4].sample
when :float
[1.12, 2.12, 3.12, 4.12].sample
when :boolean
[true, false].sample
end
end
end
| true |
85be0b849a1b204e16d7956276e54404351c6d28 | Ruby | hessammehr/RubyMeep | /kpoint.rb | UTF-8 | 311 | 2.96875 | 3 | [] | no_license | module MEEP
class KPoint
attr_accessor :freqs, :k
def initialize k, freqs
@k = k
@freqs = freqs
end
# String representation of k-point
# e.g. k-point at (0, 0, 0)
def to_s
"k-point at k=(#{k[0]}, #{k[1]}, #{k[2]}) omega = #{freqs.to_s[1..-2]}"
end
end
end
| true |
f8dc10dae7458cd3df2fa867ae41bc346ee34d47 | Ruby | kopylovvlad/easy_captcha | /lib/easy_captcha/espeak.rb | UTF-8 | 1,562 | 2.90625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | module EasyCaptcha
# espeak wrapper
class Espeak
# generator for captcha images
def initialize(&block)
defaults
yield self if block_given?
end
# set default values
def defaults
@amplitude = 80..120
@pitch = 30..70
@gap = 80
@voice = nil
end... | true |
8a5cf11e60fc4960b982335784bd57ddc2ad4736 | Ruby | leedc0/tic-tac-toe-rb-online-web-sp-000 | /lib/tic_tac_toe.rb | UTF-8 | 3,572 | 4.28125 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # 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], # First column
[1,4,7], # Middle column
[2,5,8], # Last column
[0,4,8], # Left diagonal
[2,4,6] # Right diagonal
]
# Define display_board that accepts a board and prints... | true |
856f59ff2f4d352135780c831eed4be72cb786ee | Ruby | ctrlaltpat-flatiron-work/reverse-each-word-london-web-091718 | /reverse_each_word.rb | UTF-8 | 323 | 3.5625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def reverse_each_word(sentence)
# words = sentence.split(" ")
# words_reversed = []
# words.each do |word|
# words_reversed << word.reverse
# end
# words_reversed.join(" ")
words_reversed = []
sentence.split(" ").collect do |word|
words_reversed << word.reverse
end
words_reversed.join(" ")
... | true |
9df7f5a8f2149fe4f5248e34b8c3ab6d98799f63 | Ruby | shock/vitalsigns | /lib/vital_signs/config.rb | UTF-8 | 982 | 2.765625 | 3 | [
"LicenseRef-scancode-warranty-disclaimer",
"Apache-2.0"
] | permissive | module VitalSigns
class Config
attr_accessor :sensors
class << self
def parse_from_string config_string, filename="String", starting_line_number=1
config = new
config.instance_eval(config_string, filename, 1)
config
end
def parse_from_file filename
conf... | true |
74ff0d189ae0388ebf81670ffab25b50aa2eb6ec | Ruby | ohmie/LutheranHymnody | /ruby/tlh.rb | UTF-8 | 2,801 | 3.078125 | 3 | [] | no_license | require 'nokogiri'
require 'open-uri'
words = Hash.new(0)
dictionary = Hash.new();
def add_word(word, words, file)
return if word == nil
word.gsub!(/[“”—,;:\*\.!?]/,'')
word.gsub!(/’s$/, '')
word.gsub!(/s’$/, 's')
words[word] += 1
#print word, " ", file, "\n" if word.include? "reconciled"
#print word, " ", fil... | true |
64f9b91891e0dc929ec8025dbf8b8c5026d554ca | Ruby | DrDhoom/RMVXA-Script-Repository | /00_Bug Fixes/Screen Shake Fix.rb | UTF-8 | 1,358 | 2.59375 | 3 | [
"MIT"
] | permissive | #--------------------------------------------------------------------------
# Screen Shake Fix
# Author(s):
# Hiino
#--------------------------------------------------------------------------
# This script is a little bug fix for the Screen shake event command.
# Originally, the "Wait for the end" checkbox was useless,... | true |
65205cd9b5bba4d0065424a3cf9d6721a0c045a5 | Ruby | shilovk/tn | /lesson2/3.rb | UTF-8 | 458 | 4.03125 | 4 | [] | no_license | # frozen_string_literal: true
# 3. Заполнить массив числами фибоначчи до 100
def fibonachi(max_value)
fib = [0, 1]
loop do
value = fib[-1] + fib[-2]
break if value >= max_value
fib << value
end
fib
end
puts fibonachi(100)
puts fibonachi(100)[10]
def fibonachi_of(numbers)
fib = [0, 1]
(2..nu... | true |
d25d044a162b30aa20023db89033df1ab49e720c | Ruby | estiens/tictactoe | /lib/game_runner.rb | UTF-8 | 1,910 | 3.546875 | 4 | [] | no_license | require_relative "game"
require_relative "human_player"
require_relative "./ai_players/hard_ai"
require_relative "./ai_players/medium_ai"
require_relative "./ai_players/dumb_ai"
require_relative "./ai_players/negamax_ai"
require_relative "io_parser"
X = 1
O = -1
N = 0
class Runner
attr_accessor :game, :board, :pars... | true |
5672c0cf6689206c1375e128d982eb68b8394660 | Ruby | mrarthurwhite/project1_arthur_cli | /lib/actor.rb | UTF-8 | 996 | 2.703125 | 3 | [
"MIT"
] | permissive |
class Actor < Person
attr_accessor :roles, :country
def initialize(attributes)
super(attributes)
attributes.each do |k,v|
self.send("#{k}=",v) if self.respond_to?("#{k}=")
end
@roles=[]
end
def self.create(attributes)
a = Actor.new(attributes)
a.save
a
end... | true |
889d2ccf07a9a9edec455fa8039074a116e26641 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/hamming/76d9d0ba0925465e99b1b9390fec79c7.rb | UTF-8 | 211 | 3.5 | 4 | [] | no_license | class Hamming
def self.compute(strand1, strand2)
hamming = 0
i = 0
while i < strand1.length && i < strand2.length
if strand1[i] != strand2[i]
hamming += 1
end
i += 1
end
return hamming
end
end
| true |
5fc4a767d68bba2de87605428030112c3515e57e | Ruby | jin/algorithms_and_data_structures.rb | /hackerrank/maximum_subarray.rb | UTF-8 | 790 | 3.53125 | 4 | [] | no_license | # Solution for the maximum subarray problem (both contiguous and non-contiguous versions)
#
# Given a 1D integer array, find a contiguous and non-contiguous block of elements such that their sum is the maximum.
gets.to_i.times do
n = gets.to_i
ints = gets.split.map(&:to_i)
max_non_contiguous_sum = 0
max_contig... | true |
b205493f71b0e098fc7a5680ac70ac723da49ec8 | Ruby | imageoptimiser/abbot-ng | /lib/sproutcore/entries.rb | UTF-8 | 6,183 | 2.75 | 3 | [] | no_license | require "tsort"
Entry = Struct.new(:name, :requires, :source) do
end
# Construct a special Array that uses the Ruby TSort
# module to sort files by their dependencies
module SproutCore
class Entries < Array
include TSort
# TSort requires that tsort_each_node iterates through
# all nodes. Since this is... | true |
0be960f9b1f6b64d0b07d11c746c55a942dc69bc | Ruby | jenmccarthy/expense_tracker_AR | /spec/expense_spec.rb | UTF-8 | 1,649 | 2.796875 | 3 | [] | no_license | require 'spec_helper'
require 'category'
describe Expense do
it { should validate_presence_of :description }
it { should validate_presence_of :price }
it 'converts the description to capital case' do
expense = Expense.create({description: 'pizza', price: 4.99})
expect(expense.description).to eq 'Pi... | true |
7f4014128756b169e914ed92f9e3de681016cb0d | Ruby | jackfrostwillbeking/atcoder_sample | /ABC/ruby/061/A.rb | UTF-8 | 173 | 3.1875 | 3 | [] | no_license | A,B,C = gets().chomp.split(' ').map { |n| n.to_i }
exit if !( -100 <= A && A <= 100 && -100 <= B && B <= 100 && -100 <= C && C <= 100 )
puts A <= C && C <= B ? 'Yes' : 'No' | true |
7ae0f5a339c03b31b0cd8d36309dd787ccef6325 | Ruby | playto/ruby-object-attributes-lab-q-000 | /lib/dog.rb | UTF-8 | 173 | 3.046875 | 3 | [] | no_license | class Dog
def name=(name_string)
@name = name_string
end
def name
@name
end
def breed=(breed)
@breed = breed
end
def breed
@breed
end
end | true |
c1b0eee0d26b526288920c1f8bb2008edf7f224f | Ruby | mitchconquer/test-first-ruby | /15_in_words/in_words.rb | UTF-8 | 2,171 | 3.859375 | 4 | [] | no_license | class Fixnum
def in_words(current = self)
places = []
output = ''
if current >= 1_000_000_000_000
trillions = current / 1_000_000_000_000
current = current - (trillions * 1_000_000_000_000)
output += in_words(trillions).to_s + " trillion"
if current > 0
output += ' '
end
end
if current ... | true |
815039b78682f65dde8bc153e02c04d1494ed4e8 | Ruby | grandballoon/ruby-objects-has-many-through-lab-nyc-web-062518 | /lib/appointment.rb | UTF-8 | 271 | 2.859375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require "pry"
class Appointment
@@all = []
attr_reader :occurrence, :patient, :doctor
def initialize (occurrence, patient, doctor)
@occurrence = occurrence
@patient = patient
@doctor = doctor
@@all << self
#binding.pry
end
def self.all
@@all
end
end
| true |
9f21cab66f461818965a3ff067369bae69d5072d | Ruby | Unclerojelio/mazes_for_programmers | /killing_cells.rb | UTF-8 | 330 | 3.078125 | 3 | [] | no_license | require 'grid'
require 'recursive_backtracker'
grid = Grid.new(5, 5)
#orphan the cell in the northwest corner
grid[0, 0].east.west = nil
grid[0, 0].south.north = nil
# ... and the one in the southwest corner
grid[4, 4].west.east = nil
grid[4, 4].north.south = nil
RecursiveBacktracker.on(grid, start_at: grid[1, 1])
... | true |
533fd952f98fa910ebf5607548674f9d66b8034e | Ruby | J-Y/RubyQuiz | /ruby_quiz/quiz81_sols/solutions/Logan Capaldo/hash_to_open_struct2.rb | UTF-8 | 1,097 | 3.296875 | 3 | [
"MIT"
] | permissive | require 'yaml'
require 'ostruct'
class Object
def hash_to_ostruct(visited = [])
self
end
end
class Array
def hash_to_ostruct(visited = [])
map { |x| x.hash_to_ostruct(visited) }
end
end
class Hash
def hash_to_ostruct(visited = [])
os = OpenStruct.new
each do |k, v|
item = visited.find ... | true |
19a3acf465a5ceccf955ec577e6a87b971f36aaf | Ruby | bajwahassan/badges-and-schedules-onl01-seng-ft-030220 | /conference_badges.rb | UTF-8 | 813 | 3.9375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def badge_maker(name)
return "Hello, my name is #{name}."
end
# ----------------------------------------------------------------
def batch_badge_creator(array)
batch_messages = []
array.each do |name|
batch_messages.push("Hello, my name is #{name}.")
end
return batch_messages
end
# --------------... | true |
6535a2555446b50e0d774f507a1df96ae048cadb | Ruby | krishnau2/personal_expense_tracking | /app/services/transaction_creator.rb | UTF-8 | 2,315 | 2.890625 | 3 | [] | no_license | class TransactionCreator
EXPENSE = 'Expense'
INCOME = 'Income'
TRANSFER = 'Transfer'
def initialize(transaction_data)
@transaction_data = transaction_data
@expense_transactions = @transaction_data["transactions"]
@source_account = Account.find(@transaction_data["source_account_id"])
@transaction_date = @tr... | true |
a5de8e54425dfcab3bdb8feafc6ba309497500d9 | Ruby | shouxingzi/chat-app | /app/controllers/application_controller.rb | UTF-8 | 1,657 | 2.578125 | 3 | [] | no_license | # 全てのコントローラーが継承するファイル
# deviseのコントローラーはここに記述する。なぜならば、deviseのコントローラーはGem内に記述されているため編集ができないから
class ApplicationController < ActionController::Base
before_action :authenticate_user!
# authenticate_user!
# ログイン状態によって表示するページを切り替えるdeviseのメソッド。処理が呼ばれた段階でユーザーがログインしていなければ、そのユーザーをログイン画面に遷移させる。
# before_actionで呼び出すことでアクシ... | true |
f63a6840783fb2276da1d5a53ac816776c9a6759 | Ruby | kristianmandrup/on_the_map | /spec/on_the_map/geo_locatable_spec.rb | UTF-8 | 1,011 | 2.515625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require 'spec_helper'
require 'on_the_map/geo_locatable'
class MyGeoCodableAddress
include Mongoid::Document
include OnTheMap::GeoLocatable
end
describe OnTheMap::GeoLocatable do
subject { address }
context 'empty address' do
let(:address) { MyGeoCodableAddress.create street: '', city: '' }
it 'sh... | true |
98d141b00d0f8b299dae8144eb9e0c6897ca93ac | Ruby | chantal66/jungle_beat | /test/jungle_beat_test.rb | UTF-8 | 888 | 2.984375 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/pride'
require './lib/jungle_beat'
require 'pry'
class JungleBeatTest < Minitest::Test
def test_head_knows_nil
jb = JungleBeat.new
assert_equal nil, jb.list.head
end
def test_can_it_append
jb = JungleBeat.new
result = jb.append("deep doo ditt")
... | true |
3e9e7a3050b42806eac666a68e764cbabf8d8f0e | Ruby | ksmithbaylor/GPAgent | /app/models/student.rb | UTF-8 | 465 | 2.765625 | 3 | [] | no_license | require 'semester'
class Student
include DataMapper::Resource
property :id, Serial
property :name, String
has n, :semesters
def gpa
attempted_hours = 0
grade_points = 0
@semesters.each do |semester|
semester.courses.each do |course|
attempted_hours += course.hours if course.... | true |
0689fad92ba03a3d7f5e86dcc5a6c84d80aae093 | Ruby | nachiket87/codeforces | /282A.rb | UTF-8 | 179 | 3.5 | 4 | [] | no_license | n = gets.to_i
x = 0
while(n>0)
n-=1
s = gets.chomp
if s[0] == "+" || s[-1] == "+"
x+=1
elsif s[0] == "-" || s[-1] == "-"
x-=1
end
end
puts x
| true |
751945e41b5151d88031f1605d881996c803c4a0 | Ruby | T-o-s-s-h-y/Learning | /Ruby/exercises/app/mission_d_192.rb | UTF-8 | 203 | 3.203125 | 3 | [] | no_license | =begin
文字列に感嘆符を付与する。
=end
class MissionD192
def run
# 対象の文字列
str = $stdin.gets.chomp!
# 感嘆符を付与して出力
puts "#{str}!"
end
end
| true |
f78abf9465683f098fda55edc03fca76526399f4 | Ruby | copypastel/attr_private | /lib/attr_private/active_record_base.rb | UTF-8 | 1,721 | 2.609375 | 3 | [
"MIT"
] | permissive | module ActiveRecord
class Base
class << self
def attr_private(*attributes)
attr_protected(*attributes)
write_inheritable_attribute(:attr_private,Set.new(attributes.map { |a| a.to_s }) + (private_attributes || []))
end
def private_attributes
read_inheritable_attribute(:at... | true |
6d2200858f0c406b3a2a9e7abaa835b34dae4e0f | Ruby | jdejong/galactic-senate | /lib/galactic-senate/delegation.rb | UTF-8 | 2,832 | 2.78125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module GalacticSenate
class Delegation
SUPREME_CHANCELLOR_INTERVAL = 10
SENATOR_INTERVAL = 30
RAND_INTERVAL = 15
KEY = "galactic-senate-supreme-chancellor"
def initialize
@running = true
@supreme_chancellor_timeout = 0
end
def self.instance
... | true |
646e1e789dd1aa6557a7473313f1442e4fe86ea6 | Ruby | mattsp1290/hipchatbot | /app/classes/reply_handler.rb | UTF-8 | 743 | 2.609375 | 3 | [
"MIT"
] | permissive | class ReplyHandler
def self.process(event)
replies = Reply.all
handled = false
replies.each do |reply|
if ((event.room == reply.room.to_i) || (reply.room == '') || (reply.room.nil?)) && (not handled)
if (reply.mention_name == '' || reply.mention_name.nil?) || (reply.mention_name == event.mentio... | true |
8bf827274b8112dbd1c4253f649a25d77275eddd | Ruby | MayOneUS/mayday-2.0-backend | /spec/lib/integration/here_spec.rb | UTF-8 | 1,519 | 2.546875 | 3 | [
"Apache-2.0"
] | permissive | require 'rails_helper'
describe Integration::Here do
describe ".geocode_address" do
context "good address" do
subject(:response) do
Integration::Here.geocode_address( address:'2020 Oregon St',
city: 'Berkeley',
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.