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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
f4a8a84d6ecf06de043d696ac8b7b8f5f7faafd5 | Ruby | ada74m/grebe | /spec/models/criteria/criterion_spec.rb | UTF-8 | 5,383 | 2.640625 | 3 | [] | no_license | require 'spec_helper'
describe Criterion do
describe "when in a hierarchy" do
before(:each) do
@root = CompositeCriterion.and
@root.children << (@or = CompositeCriterion.or)
@or.children << (@built1974 = Equals.new :model => :ship, :property => :built_year, :integer_a => 1974)
@or.chil... | true |
92145d072875e92319ecdd5383e7685e68c26a3b | Ruby | amcrawford/web_guesser | /web_guesser.rb | UTF-8 | 776 | 3.328125 | 3 | [] | no_license | require 'sinatra'
require 'sinatra/reloader'
NUMBER = rand(100)
get '/' do
guess = params["guess"]
message = check_guess(guess)
erb :index, :locals =>{:number => NUMBER, :message => message, :background_color => @background_color}
end
def check_guess(guess)
variation = guess.to_i - NUMBER
if variation > 0
... | true |
3af9fb05511ab31ca647a770d3d1652b632a4c1c | Ruby | MIsatoFujihara/game | /game.rb | UTF-8 | 3,520 | 3.421875 | 3 | [] | no_license | # カレントディレクトリにあるファイルをrequire
# maruの状態(trueかfalseか)をtableの状態(int型)にして返す
# ○がおかれていたら表の状態は1,×がおかれていたら表の状態は2
def player_state(player)
return player ? Maru : Batsu
end
# 3つそろっていたらtrue,そうでなければfalseを返す関数
# ClearCheckクラスを扱う
def call_clear(table, player)
# table[0][0]は縦横斜め方向にそろっているかを調べる
check = ClearCheck.new(0, 0, ta... | true |
e1840d41371c8ca67326ed610bf7c3e4e43be636 | Ruby | earl-stephens/enigma | /lib/key.rb | UTF-8 | 1,206 | 3.34375 | 3 | [] | no_license | class Key
attr_reader :random_number,
:key_array,
:converted_key_array,
:number_as_string
def initialize
@random_number = ""
@key_array =[]
@converted_key_array = []
end
def main_test_method(number)
test_random_number(number)
fill_in_zeroes
pop... | true |
0153f359436c7c0183a6b2ef8ddfa46f1ff99032 | Ruby | nickpearson/dottie | /lib/dottie/freckle.rb | UTF-8 | 1,191 | 3.40625 | 3 | [
"MIT"
] | permissive | module Dottie
class Freckle
include Methods
##
# Creates a new Freckle to wrap the supplied object.
def initialize(obj)
case obj
when Hash, Array
@_wrapped_object = obj
else
raise TypeError, 'must be a Hash or Array'
end
end
##
# Retur... | true |
157f48550720c7b1a5307199edabd1f76dbee447 | Ruby | karlwitek/launch_school_rb120 | /oop_exercises/medium2/fe_ranking_cards.rb | UTF-8 | 2,191 | 3.984375 | 4 | [] | no_license | class Card
include Comparable
attr_reader :rank, :suit
SUIT_VALUES = { 'Spades' => 4, 'Hearts' => 3, 'Clubs' => 2, 'Diamonds' => 1 }
def initialize(rank, suit)
@rank = rank
@suit = suit
end
def ranking
case @rank
when 'Jack' then 11
when 'Queen' then 12
when 'K... | true |
f03f4f400d55fdceed28c056f18d5cd4602b096d | Ruby | TaylorWu21/school_rspec | /app/models/classroom.rb | UTF-8 | 298 | 2.765625 | 3 | [] | no_license | class Classroom < ActiveRecord::Base
validates_presence_of :name
belongs_to :school
def classroom_name
"#{name} is a cool class."
end
def classroom_size
if (size >= 50)
"Big class"
elsif (size < 50 && size > 25)
"Medium class"
else (size < 30)
"Small class"
end
end
end
| true |
ffdaadfbbd9ceace35b4e9ac9e978e44a332980b | Ruby | jpheos/batch-586 | /02-OOP/food-delivery/livecodes/food-delivery-reboot/app/repositories/customer_repository.rb | UTF-8 | 426 | 2.8125 | 3 | [] | no_license | require "csv"
require_relative "../models/customer"
require_relative "record_repository"
class CustomerRepository < RecordRepository
def update(customer)
p customer
save_csv
end
private
def row_to_record(row)
row[:id] = row[:id].to_i
Customer.new(row)
end
def record_to_row(customer)
... | true |
367ce26fabb3e4e47adef411330d5b16718fef4c | Ruby | SimplySorc/StatusChecker | /status_checker.rb | UTF-8 | 552 | 2.921875 | 3 | [] | no_license | # frozen_string_literal: true
require 'csv'
require 'json'
require 'net/http'
class StatusChecker
def initialize(file_path)
@results = []
CSV.foreach(file_path, headers: :first_row) do |row|
url = row.fetch('URL')
@results << { name: url, status: get_site_status(url) }
end
end
def to_j... | true |
408b665403146bdaa531579dd5cc05655f140f45 | Ruby | lateralstudios/railgun_devise | /lib/railgun_devise/configuration.rb | UTF-8 | 554 | 2.59375 | 3 | [
"MIT"
] | permissive | module RailgunDevise
class Configuration
@@defaults = {
}
cattr_accessor :settings
def initialize
@@settings ||= self.class.get_from_hash(@@defaults)
end
def self.settings
@@settings
end
def method_missing(name, *args, &block)
self.settings.send(name, *args, &block)
end
... | true |
6e2498b7829243042f869be3cd6024b07970ea3a | Ruby | shaoshing/projecat | /cat_feeder/devices/eating_detect_device.rb | UTF-8 | 1,377 | 2.734375 | 3 | [] | no_license | require 'pi_piper'
module CatFeeder
class EatingDetectDevice
PIN_NUM = 6
INITIAL_TIME_OUT = 5 # INITIAL_TIME_OUT * DURATION (seconds)
TIME_OUT = 20 # TIME_OUT * DURATION (seconds)
DURATION = 0.5
def self.eating?
@started_at = nil
@ended_at = nil
@pin ||= PiPiper::Pin.new(:pin =... | true |
017c1fa796d79c85e677049df6b0a47308fe324d | Ruby | tdeo/advent_of_code | /2015/lib/22_wizard_simulator.rb | UTF-8 | 3,389 | 3.0625 | 3 | [] | no_license | # frozen_string_literal: true
require 'set'
class WizardSimulator
def initialize(input)
@input = input
@spells = [
{ name: :magic_missile, mana_cost: 53 },
{ name: :drain, mana_cost: 73 },
{ name: :shield, mana_cost: 113 },
{ name: :poison, mana_cost: 173 },
{ name: :recharge, ... | true |
8ce993e9177ac2dcca7dc6f4eaaebca672712e5d | Ruby | cantorandball/centrebot | /app/models/date_outcome.rb | UTF-8 | 323 | 2.796875 | 3 | [] | no_license | class DateOutcome < Outcome
def correct_period?(incoming_date)
is_correct = true
if lower_bound
is_correct = false if incoming_date <= Date.today.prev_year(lower_bound)
end
if upper_bound
is_correct = false if incoming_date > Date.today.prev_year(upper_bound)
end
is_correct
end
e... | true |
d293614164a23d9212fce2d37bfcc281b6cf9371 | Ruby | Birdie0/glue-bot | /src/modules/commands/random.rb | UTF-8 | 1,037 | 2.703125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Bot
module DiscordCommands
# Picks random n songs from pre-generated playlists.
# Max 25 songs for one request.
module Random
extend Discordrb::Commands::CommandContainer
command(:random,
min_args: 1,
description: 'Picks random... | true |
ff539dabaf3716093fa705840ad71eb539572538 | Ruby | Beaulieu527/speaking-grandma-online-web-prework | /grandma.rb | UTF-8 | 379 | 3.578125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Write a speak_to_grandma method.
speak_to_grandma = gets.chomp
# Whatever you say to grandma, she should respond with
# HUH?! SPEAK UP, SONNY!
# unless you shout it (type in all capitals).
if speak_to_grandma = "I LOVE YOU GRANDMA!"
puts "I LOVE YOU TOO PUMPKIN"
elsif speak_to_grandma != " ".upcase
puts "HUH? SP... | true |
eede7cb82896c453d1a7541e408143ce64de5170 | Ruby | TheBaxes/ProductCast | /app/models/Prediction_Models/Single_Exp_Smoothing_Model.rb | UTF-8 | 1,117 | 3.03125 | 3 | [] | no_license | require_relative '../Base_Prediction_Model/base_model'
require_relative './../Data/historical_data'
require_relative './../Data/predicted_data'
require 'date'
class Single_Exp_Smoothing_Model < BaseModel
@public_name = "Suavizacion exponencial"
@parameters_list = ["Alfa"]
@local_parameters = [:Alpha]
@... | true |
c4ae9710476a1d736b752a2d8789d72aa2ca380f | Ruby | siegy22/energy_air | /exe/energy_air | UTF-8 | 597 | 2.875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
tel_number = ARGV[0]
if tel_number.nil? || tel_number.empty?
puts <<~MSG
Please provide your telephone number to earn the tickets (don't use spaces):
$ energy_air 791234567
MSG
exit
end
require 'bundler/setup'
require 'energy_air'
puts '==== Energy Air Quiz bot ===='
puts "Version: #... | true |
c914569f5ec10bb482d963a51787a8dbcd92a1f6 | Ruby | dalexj/ideabox | /lib/idea_box/idea.rb | UTF-8 | 615 | 2.9375 | 3 | [] | no_license | class Idea
include Comparable
attr_reader :title, :description, :rank, :id, :tags
def initialize(data = {})
@title = data["title"]
@description = data["description"]
@rank = data["rank"] || 0
@id = data["id"]
@tags = data["tags"]
end
def to_h
{
"title" => title,
"descripti... | true |
98b944cceaad6fa6dacaaa755c36d1ddfcdcfe92 | Ruby | desarrollolocal/etiquetica | /lib/product.rb | UTF-8 | 452 | 2.546875 | 3 | [] | no_license | require_relative 'indicator'
class Product
include Mongoid::Document
field :name, type: String
field :creation_date, type: Time, default: ->{ Time.now.to_i }
embeds_many :indicators
validates_presence_of [:name, :creation_date]
validates_uniqueness_of :name, message: "Ya existe un producto con ese nom... | true |
7a6747311e2d9ec11861d5bf5095ecfccb188150 | Ruby | phedders/prh-rlib | /lib/prh-tmail.rb | UTF-8 | 1,107 | 2.703125 | 3 | [] | no_license | require 'net/smtp'
class TMail::Maildir
def self.maildir?(path)
return false unless File.directory?(path)
File.directory?(path+"/cur") and File.directory?(path+"/tmp") and File.directory?(path+"/new")
end
def self.maildirmake(path, folder = nil)
if folder == true
fpath = path
elsif folder.... | true |
9a9a05f30fbdb9c20b71fc85a330fdc71b266fe0 | Ruby | vtka/VTKA | /lesson2/purchase.rb | UTF-8 | 723 | 3.75 | 4 | [] | no_license | total_basket_price = 0
basket = {}
loop do
print "Press Enter to continue! Enter 'stop', whenever you're finished: "
stop = gets.chomp
break if stop.downcase == 'stop'
print "Enter the item name: "
item_name = gets.chomp
print "Enter the price per item: "
item_price = gets.chomp.to_f
print "How man... | true |
09f17c877f3fd333dd76ea422b4fccf934c9ba3b | Ruby | marcelomaidden/jobsity-bowling-game | /lib/file_utils.rb | UTF-8 | 1,885 | 3.375 | 3 | [] | no_license | # frozen_string_literal: true
# FileValidator validates the file checking extension and file structure
class FileValidator
attr_reader :error
def initialize(filename, extension)
@filename = filename
@extension = extension
if valid_extension?
file = File.open(filename)
@lines = file.readlin... | true |
5f7a5c9c65b4465c01d83b01777cc19675863a6e | Ruby | ZephyrRS/session0202_exercises | /RichardLin_RichardLin3/exercises/d4/reverse.rb | UTF-8 | 297 | 3.75 | 4 | [] | no_license | #E1: The Road Not Taken
def reverse(array)
reversed_index = []
array.each_with_index do |spacejam, index|
new_index = array.length - 1 -index
reversed_index[new_index] = spacejam
end
reversed_index
end
random_objects = ['apples', 4, 'bananas', 'kiwis', 'pears']
puts reverse(random_objects)
| true |
46f881c585f8f25f81be1abc33bce18efdfb8d1b | Ruby | carolyn0429/dataiku | /cucumber/features/helpers/TestClient.rb | UTF-8 | 2,288 | 2.59375 | 3 | [] | no_license | require 'rubygems'
require 'selenium-webdriver'
require 'cucumber'
require 'rest-client'
class TestClient
@@URL = "http://hung.qatest.dataiku.com/"
@@username = nil
@@password = nil
def create_a_user(username, password)
response = RestClient::Request.execute(
:method => :post,
:url => @@UR... | true |
1bdca8af05cfb53ad4d6a6899c11f5da2b596a00 | Ruby | hugobast/tipo | /lib/tipo/table/base.rb | UTF-8 | 506 | 2.71875 | 3 | [
"MIT"
] | permissive | module Tipo
module Table
class Base
attr_reader :font_header, :font
attr_accessor :name
def initialize font_header, font
@font_header = font_header
@font = font
end
def offset
seek_to_table @name
end
private
def seek_to_table tag
... | true |
53d4439a60e25e1307dc40f45df73fc319e8c1ce | Ruby | AndersonMAaron/werd | /lib/werd.rb | UTF-8 | 644 | 2.796875 | 3 | [] | no_license | require 'werd/dictionary'
module Werd
def self.fail(message='')
raise message
end
def self.dictionary_in(language, min_letter_cnt=3)
Werd::Dictionary.from_file(
File.expand_path("../../dictionaries/#{language.to_s.downcase}", __FILE__),
min_letter_cnt,
)
end
end
######################... | true |
4cc20021ddd8fbb7cd58ba721b3dca3932fbe67d | Ruby | reggieb/which_page | /app/tools/thesaurus.rb | UTF-8 | 453 | 2.953125 | 3 | [] | no_license | require 'bronto'
class Thesaurus
attr_reader :word
def self.nouns_matching(word)
[word] + new(word).nouns
end
def initialize(word)
@word = word
end
def lookup
@lookup ||= bronto.lookup word
end
def nouns
(lookup && lookup[:noun]) ? lookup[:noun][:syn] : []
end
def ... | true |
757e90f72b293fcb6e71c0ae557511a937d4e3e5 | Ruby | apiaryio/apiary_blueprint_convertor | /lib/apiary_blueprint_convertor/cli.rb | UTF-8 | 1,537 | 2.8125 | 3 | [
"MIT"
] | permissive | require 'optparse'
require 'apiary_blueprint_convertor/version'
require 'apiary_blueprint_convertor/convertor'
module ApiaryBlueprintConvertor
class CLI
attr_reader :command
def self.start
cli = CLI.new
options = cli.parse_options!(ARGV)
cli.runCommand(ARGV, options)
end
d... | true |
3395d649f46fda72a38c832661d459d6cb0d75d1 | Ruby | sergii/AND-Digital-Golden-Shoe | /app/models/basket.rb | UTF-8 | 441 | 2.5625 | 3 | [] | no_license | class Basket < ApplicationRecord
validates :uuid, presence: true
has_many :basket_items, dependent: :destroy
def add_unit(unit)
current_item = basket_items.find_by(unit_id: unit.id)
if current_item
current_item.increment!(:quantity)
else
current_item = basket_items.create(unit_id: unit.i... | true |
c2a7d79626360a5602c83109b6bb925f693e918f | Ruby | DonChilders/while-loops | /while.rb | UTF-8 | 701 | 3.953125 | 4 | [] | no_license | #while loops
# requires 3 items
# initial condition
# boolean expression that will end the loop
# some kinda statement in the loop that will modify the boolean expression
# ......need some way of ending the loop
# count from 1 through 100
# count = 1
# while count <= 100
# puts count
# #change something to end th... | true |
6d409986ac3b3f093598ff5b766c9647580c341d | Ruby | Crysicia/THP_S6 | /THP-TheGossipProject/lib/view.rb | UTF-8 | 686 | 2.921875 | 3 | [] | no_license | class View
def new_gossip
puts "--- Gossip creation interface ---"
print "| What's your name ? : "
author = gets.chomp
print "| What's your crunchy story ? : "
content = gets.chomp
return params = {'author' => author, 'content' => content}
end
def index_gossips(arr)
arr.each do |gos... | true |
145d43af95ba7a8c7d2a164e746de61df589f84c | Ruby | zph/mri_2_0_0_zlib_troubleshooting | /wunderground-working-2_0.rb | UTF-8 | 445 | 2.8125 | 3 | [] | no_license | require 'rest-client'
require 'json'
api_key = '' # required by producing your own API key from http://www.wunderground.com/weather/api/
url = "http://api.wunderground.com/api/#{api_key}/geolookup/conditions/q/IA/Cedar_Rapids.json"
res = RestClient.get url
parsed_json = JSON.parse(res)
location = parsed_json['locati... | true |
443acabf46e4baad313baf328a36da8ae5083d23 | Ruby | tenshi3/MTG | /lib/game.rb | UTF-8 | 2,472 | 3.609375 | 4 | [] | no_license | require_relative "utils"
require_relative "player/_player_header"
class Game
include Utils
attr_accessor :players
attr_accessor :round_number
def initialize
self.players = []
self.round_number = 1
end
def add_player(name, deck, ai)
self.players << if ai
AiPlayer.new(name, deck)
els... | true |
8dd971b392ede25516fc9cfa04fdca7332a0a9f1 | Ruby | googleapis/google-cloud-ruby | /google-cloud-firestore/samples/transactions_and_batched_writes.rb | UTF-8 | 3,234 | 2.875 | 3 | [
"Apache-2.0"
] | permissive | # Copyright 2020 Google, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | true |
15595b08c5ed0df8d11897f54397ea8d55bcce5c | Ruby | ieyasu/rbot2 | /hooks/unicode.rb | UTF-8 | 2,473 | 2.625 | 3 | [] | no_license | ASCII_CONTROL = [
'(null)',
'(start of heading)',
'(start of text)',
'(end of text)',
'(end of transmission)',
'(enquiry)',
'(acknowledge)',
'(bell)',
'(backspace)',
'(horizontal tab)',
'(NL line feed, new line)',
'(vertical tab)',
'(NP form feed, new page)',
'(ca... | true |
a0f5c743439ed706e71b60ce6585e84ba5392a69 | Ruby | GeoffreyMesnier/rails-yelp-mvp | /db/seeds.rb | UTF-8 | 996 | 2.609375 | 3 | [] | no_license | # This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... | true |
96684250909965abdce701dc0fbe80823e98b78e | Ruby | eTarget1/school-domain-noukod-000 | /lib/school.rb | UTF-8 | 479 | 3.625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # code here!
class School
# school = School.new("Bayside High School")
# school.roster = {}
# school.add_student("Zach Morris", 9)
# school.roster
def initialize(name)
@name = name
@roster = {}
end
def roster
@roster
end
def add_student(name, grade)
if @roster[grade] != nil
@roster[grade] << name
... | true |
7f5300100b45d3284b19fa933f5d932ad1b033c7 | Ruby | jerome/tsearchable | /lib/tsearchable/results.rb | UTF-8 | 1,013 | 2.75 | 3 | [] | no_license | module TSearchable
class Results < Array
attr_reader :current_page, :per_page, :total_entries
def initialize(page, per_page, total = nil)
@current_page = page.to_i
@per_page = per_page.to_i
self.total_entries = total if total
end
def self.create(page, per_page, total = nil, &block)... | true |
33d5137d3ebdbde46478846f07d7eda94c275259 | Ruby | remm9/aa_classwork | /W3D4/firstname_lastname/lib/assessment01.rb | UTF-8 | 2,871 | 3.953125 | 4 | [] | no_license | class Array
# Write an `Array#my_inject` method. If my_inject receives no argument, then
# use the first element of the array as the default accumulator.
# **Do NOT use the built-in `Array#inject` or `Array#reduce` methods in your
# implementation.**
def my_inject(accumulator = nil, &prc)
accumulator ||... | true |
c9c0f24ee3cd817b170e2531c59186bea454b6d8 | Ruby | white731/lunch_lady | /ui.rb | UTF-8 | 2,445 | 3.859375 | 4 | [] | no_license | class Ui
def initialize (menu)
@menu = menu
end
def print_menu
puts ""
puts "Welcome to Landon's Kitchen! You're going to love our food!"
puts "Landon's Kitchen Menu"
puts "~~~~~~~~~~~~~~~~~~~~~~"
@menu.each_with_index do |menu_item, index|
puts m... | true |
d57da500a4a4bd5dffbf18e7faafadc828ba7a57 | Ruby | Sam-Levene/Rightmove | /features/steps/rightmove_step_definitions.rb | UTF-8 | 3,155 | 2.515625 | 3 | [] | no_license | Given("I can access the rightmove website") do
@rightmove_website = Rightmovewebsite.new
@rightmove_website.rightmove_homepage.load
end
Then("I can see the rightmove homepage") do
@rightmove_website.rightmove_homepage.assertVisible
end
When("I click on the {string} link") do |string|
@rightmove_website.rightm... | true |
14b83b95d57904c5bc6629542ae66595a60b641d | Ruby | kwoodard22/kelsey_wdi | /practice_w01.rb | UTF-8 | 3,043 | 3.390625 | 3 | [] | no_license | # people = [
# {:name => "Stacy", :money => 5, :plays_instrument => true},
# {:name => "Daniel", :money => 10, :plays_instrument => false},
# {:name => "Oscar", :money => 80, :plays_instrument => true},
# {:name => "Kayla", :money => 20, :plays_instrument => false},
# {:name => "Brandon", :money => 20, :plays... | true |
5c2930ab2340f4f48e38f8d7f9dfce0129ea007e | Ruby | pablomontoja/activepesel | /lib/activepesel/pesel.rb | UTF-8 | 796 | 2.828125 | 3 | [
"MIT"
] | permissive | module Activepesel
class Pesel
class << self
delegate :generate, :to => "Activepesel::PeselGenerator".to_sym
end
DIGIT_WEIGHTS = [1, 3, 7, 9, 1, 3 ,7, 9, 1, 3, 1].freeze
attr_reader :number
delegate :date_of_birth, :sex, :to => :personal_data
def initialize(number)
... | true |
6413a69f81caf817b5b69ba4d545ad2bd86ae48d | Ruby | MERatio/fibonacci | /fibs_rec.rb | UTF-8 | 239 | 3.03125 | 3 | [] | no_license | # frozen_string_literal: true
def fibs_rec(num, sequence = [0, 1])
return sequence[0..num] if [0, 1].include?(num)
return sequence if sequence.length == num + 1
sequence << sequence[-1] + sequence[-2]
fibs_rec(num, sequence)
end
| true |
1b72ca860da0b9516069033773ccb9258bc1dd84 | Ruby | carney2490/jakelrthw | /ex6.rb | UTF-8 | 1,140 | 4.375 | 4 | [] | no_license | # setting types of people to 10
types_of_people = 10
# string using types of people variable
x = "There are #{types_of_people} types of people."
# setting binary to binary
binary = "binary"
# setting do_not to don't
do_not = "don't"
# setting y to string using binary and do_not variable
y = "Those who know #{b... | true |
7cb442a020a5b6c93dde33ced34f0a4fe391c709 | Ruby | sproul/div_calendar_crawler | /src/div_calendar_crawler.rb | UTF-8 | 6,508 | 2.890625 | 3 | [
"MIT"
] | permissive | require 'json'
require_relative 'u.rb'
class Div_calendar_crawler
COMPANY_NAME = 'COMPANY_NAME'
SYMBOL = 'SYMBOL'
EX_DATE = 'EX_DATE'
DIVIDEND = 'DIVIDEND'
INDICATED_ANNUAL_DIVIDEND = 'INDICATED_ANNUAL_DIVIDEND'
RECORD_DATE = 'RECORD_DATE'
ANNOUNCMENT_DATE = 'ANN... | true |
90e390379c83c392f9f401bd35e1bc53af4f8ba9 | Ruby | Jhowden/rails_chess | /spec/models/game_pieces/knight_spec.rb | UTF-8 | 1,575 | 2.6875 | 3 | [] | no_license | require "rails_helper"
describe GamePieces::Knight do
let(:board) { double( chess_board: Array.new( 8 ) { |cell| Array.new( 8 ) } ) }
let(:knight) { described_class.new( { "file" => "e", "rank" => 4, "team" => :black, "board" => board } ) }
let(:knight2) { described_class.new( { "file" => "e", "rank" => 4, "t... | true |
19f014522d7937c810120ae28ff8ddea382d2dab | Ruby | singram/euler | /problem97/problem97.rb | UTF-8 | 575 | 3.625 | 4 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
# The first known prime found to exceed one million digits was discovered in 1999, and is a Mersenne prime of the form 2^6972593−1; it contains exactly 2,098,960 digits. Subsequently other Mersenne primes, of the form 2p−1, have been found which contain more digits.
# However, in 2004 there w... | true |
8dc7c7fe9266fbcca909df303d3a0c2293473316 | Ruby | kyudai-se/bankm_banksm | /spec/controllers/areams_controller_spec.rb | UTF-8 | 5,910 | 2.578125 | 3 | [] | no_license | require 'spec_helper'
# This spec was generated by rspec-rails when you ran the scaffold generator.
# It demonstrates how one might use RSpec to specify the controller code that
# was generated by Rails when you ran the scaffold generator.
#
# It assumes that the implementation code is generated by the rails scaffold
... | true |
4fcf1320b97107c2aaf5a6de98a66e71f8b621b5 | Ruby | ryooo/timestamper | /app/models/stamp.rb | UTF-8 | 1,836 | 2.734375 | 3 | [] | no_license | class Stamp < ActiveRecord::Base
serialize :timeframes
class Timeframe
attr_reader :date
def initialize(h, date)
@in_at = h[:i]
@out_at = h[:o]
@date = date
end
def sec
((@out_at || Time.current.to_i) - @in_at)
end
def in_at
Time.at(@in_at)
end
def ou... | true |
db89576d698f05582504219749cd6347cf4506d4 | Ruby | AJourdan/ruby_fundamentals2 | /exercise5.rb | UTF-8 | 200 | 4.3125 | 4 | [] | no_license | print "Give me a temperature in Farenheit and we will convert it to Celcius"
temp = gets.chomp
def num(temp)
(temp.to_i - 32) * 5/9
end
puts "#{temp} Farenheit is equal to #{num(temp)} in Celcius " | true |
75b8bd5ddd0b130084087645e23ac57e194b2797 | Ruby | joshuajhun/chisel | /class files/ordered_list.rb | UTF-8 | 711 | 3.234375 | 3 | [] | no_license | # require 'pry' # ~> LoadError: cannot load such file -- pry
class Ordered_list
attr_reader :input_text
def initialize (input_text)
@input_text = input_text
end
def chunk_text
text = @input_text
a = text.split("\n")
# a.chars # ~> NoMethodError: undefined method `chars' for ["1. r... | true |
05f7f5978679ddcacba18139955fe91c782f779a | Ruby | dresselm/Rubot | /functions/admincommands/force.rb | UTF-8 | 486 | 2.796875 | 3 | [] | no_license | # This command will lock down the bot and only allow the admin to use it
def force
@locked = '' # Set the variable to lock/unlock
option = get_message # Get the user choice
case option
when 'lock'
@locked = true
chan_send("Set to lockdown mode.")
when 'unlock'
@locked = false
... | true |
b2a865a1a386354d9c3e0f58d63851aec5625e53 | Ruby | phss/hackyventure | /situations/adventure.rb | UTF-8 | 438 | 2.859375 | 3 | [] | no_license | class Adventure
def initialize(story)
@situations = story.situations
@current = :start
@context = story.initial_context
end
def while_not_finished
while @current != :end
current_situation = @situations[@current]
current_situation.with_context(@context)
resolution = yield... | true |
3fb5697af31c5790c18f27039b96fcb7e95a8bbb | Ruby | alphagov/content-publisher | /lib/whitehall_importer/integrity_checker/unpublishing_check.rb | UTF-8 | 1,485 | 2.5625 | 3 | [
"MIT",
"LicenseRef-scancode-proprietary-license"
] | permissive | module WhitehallImporter
class IntegrityChecker::UnpublishingCheck
attr_reader :edition, :unpublishing
def initialize(edition, unpublishing)
@edition = edition
@unpublishing = unpublishing
end
def expected_type?
unpublishing["type"] == expected_type
end
def expected_type
... | true |
bcb1bbde8c4b0206024d204adab4a6deb9a79139 | Ruby | BohanHsu/leetcode2 | /3sum.rb | UTF-8 | 1,282 | 3.328125 | 3 | [] | no_license | # @param {Integer[]} nums
# @return {Integer[][]}
def three_sum(nums)
result = {}
nums.sort!
hsh = {}
nums.each_with_index do |num, i|
if !hsh.has_key?(num)
hsh[num] = []
end
hsh[num] << i
end
j = nums.length - 1
while j >= 0 && nums[j] >= 0 do
i = 0
while i < nums.length && num... | true |
4eb421aa9126ca3c5141595a4ad82324f6510165 | Ruby | nicholasklick/find_by_sql_file | /lib/find_by_sql_file.rb | UTF-8 | 1,921 | 2.6875 | 3 | [
"MIT"
] | permissive | require 'erb'
require 'active_record'
module FindBySqlFile
# This makes it a tad simpler to create a clean ERB binding context. It
# works like so:
#
# ERBJacket.wrap "A Foo is: <%= @foo -%>", :foo => 'not a bar'
#
class ERBJacket
def initialize(hash) # :nodoc:
hash.each { |k, v| instance_variabl... | true |
5f61266830429b515658df1f46451d11f5c836c3 | Ruby | artemave/oompa-loompa | /spec/tweet_text_spec.rb | UTF-8 | 818 | 2.765625 | 3 | [] | no_license | require_relative 'spec_helper'
require_relative '../lib/tweet_text'
require_relative '../lib/models/link'
describe TweetText do
let(:link) do
Link.new(
score: 23,
title: 'this is title',
url: 'u' * 23,
comments_url: 'c' * 23,
source: 'Hn'
)
end
context "title is too long" d... | true |
840175ce92c7ae3e855d4d996a049a11c2dfd876 | Ruby | tilmitt11191/.dotfiles | /fonts/other_fonts/documents/pasta/generate_kml/lcl_thrput.rb | UTF-8 | 913 | 2.515625 | 3 | [] | no_license | #!/usr/bin/env ruby
#
# pcapファイルからIPアドレスの取得@ip_list
# 取得したIPアドレスから、経度、緯度、地域の割り出す@geoip
#
require 'fileutils'
tmplog_dir = "tmp_log"
FileUtils.mkdir(tmplog_dir) unless FileTest.exist?(tmplog_dir)
require "#{File.dirname(__FILE__)}/ip_list.rb"
require "#{File.dirname(__FILE__)}/geoip.rb"
if ARGV.empty?
puts "*.pcap... | true |
fa2574e02689ff62f7590c9a21c584de60d4965b | Ruby | Saganesque/todolists_final | /app/models/profile.rb | UTF-8 | 1,123 | 2.890625 | 3 | [] | no_license | class Profile < ActiveRecord::Base
belongs_to :user
validates_inclusion_of :gender, in: %w( male female )
validate :my_happy_fname_lname_null_validator
validate :no_sue
default_scope {order birth_year: :asc}
=begin
Add a class method to the Profile class, called get_all_profiles, which:
accepts a min and m... | true |
a331c591cc28283f9e7b8401e00566f79a06460a | Ruby | RachaelMahon/Week3---Pairing-with-Tom- | /Battle/spec/player_spec.rb | UTF-8 | 576 | 2.546875 | 3 | [] | no_license | require 'views/player'
describe Player do
subject(:buddy) {Player.new('Buddy')}
subject(:ginger) {Player.new('Ginger')}
describe '#name' do
it 'returns the name' do
expect(buddy.name).to eq 'Buddy'
end
end
context '#hit_points' do
it 'returns the hit points' do
... | true |
a6a59e902f7983b5494a70cc46c5551156872595 | Ruby | AnthonyGarino/Chess | /rook.rb | UTF-8 | 315 | 2.59375 | 3 | [] | no_license | require_relative 'slideable.rb'
require_relative 'pieces.rb'
class Rook < Piece
include Slideable
def symbol
if color == :w
"\u2656".encode('utf-8')
else
"#{"\u265C".force_encoding('utf-8')}"
end
end
def move_dirs
LINEAR_DIRS
end
end | true |
e1402ebe415f463011a439ab4f91e1398a9b1c40 | Ruby | AkhileshwarReddy/Data-Munging | /kata-weather.rb | UTF-8 | 389 | 3.09375 | 3 | [] | no_license | weather_data = File.read('./data/weather.dat').lines
spread_min = 1.0/0
day = 0
weather_data.each_with_index do |line, index|
next if index == 0 or line.split.length == 0
line_data = line.split
spread = (line_data[1].to_i - line_data[2].to_i).abs
if spread < spread_min
spread_min = spread
... | true |
a2df3c3139c4e33964507dcef0d19313f998dd5c | Ruby | etsune/kanstat | /scripts/get_genres.rb | UTF-8 | 619 | 2.734375 | 3 | [] | no_license | require 'net/http'
require 'uri'
require 'json'
# Парсим жанры и генерим JSON result/genres.json
genres = {}
data_dir = File.expand_path("../../result/", __FILE__)
search_url = "http://yomou.syosetu.com/search.php"
search_page = Net::HTTP.get(URI.parse(search_url)).force_encoding('UTF-8')
genres_rx = /<label><input ... | true |
2c3e6c710878e6a054f6554a58242bc997c6f7fd | Ruby | misleb/opular | /app/assets/javascripts/untitled.rb | UTF-8 | 1,681 | 2.6875 | 3 | [] | no_license | $opular.module('op').constant('a', 1).constant('b', 2)
i = Op::Injector.new(['op'])
fn = ->(a, b) { a + b }
class Blah
attr_reader :result
def initialize(a, b)
puts self.inspect
@result = a + b
end
end
class A
def _get(b)
self
end
end
class B
def _get()
self
end
end
class C
def _g... | true |
83e6fd93508f22cac07894b3a31454d828cf0428 | Ruby | LaraLaPierre/prework | /3_39_2.rb | UTF-8 | 304 | 4.09375 | 4 | [] | no_license |
# Create a function that takes in a string as its input and returns a tripled version of the string.
# So if the input is “cat”, the output should be “catcatcat”.
#Question 2:
def triple_machine(string)
output = "#{string}#{string}#{string}"
return output
end
p triple_machine("lara") | true |
285c51d0da2f7b8ce4b373acc886efb0943762bb | Ruby | javiermortiz/app-academy | /W6D2/knights_travails/knight_path_finder.rb | UTF-8 | 1,958 | 3.75 | 4 | [] | no_license | require_relative "polytreenode"
class KnightPathFinder
attr_reader :starting_pos, :considered_pos
attr_accessor :root_node
MOVES = [[1,2], [1,-2], [2,1], [2,-1], [-1,-2], [-1, 2], [-2,-1], [-2,1]]
def initialize(starting_pos)
@starting_pos = starting_pos
@considered_pos = [sta... | true |
03d40ac202f5ac571364b6cb8250091d77e978a8 | Ruby | concord-consortium/lab-interactive-management | /bin/im_process.rb | UTF-8 | 1,721 | 2.578125 | 3 | [] | no_license | require 'json'
load "meta_data/interactive_metadata.rb"
#puts "interactive_meta = #{$interactive_metadata}"
# require activesupport for this?
class String
def to_underscore!
gsub!(/(.)([A-Z])/,'\1_\2') && downcase!
end
def to_underscore
dup.tap { |s| s.to_underscore! }
end
end
all_properties = []
mo... | true |
f9bb5458ff59bbd9881abaf76e758037a9116d77 | Ruby | ac0rn/africa | /app/controllers/mineral_stats_controller.rb | UTF-8 | 1,329 | 2.53125 | 3 | [] | no_license | require 'data_as_color'
require 'build_kml'
class MineralStatsController < ApplicationController
COUNTRY_LIST = File.open(File.join(Rails.root, "db/seeds/countries.txt"),"r:utf-8").read.strip.split("|")
def index
flash[:error] = flash[:errors] = flash[:notice] = nil
@data = COUNTRY_LIST.collect do |country|
c... | true |
754c5e4cdc507eb1bbc8e0b7a8486e9361bbe1eb | Ruby | twitnithegirl/practice | /lib/project-euler/even_fibonacci_numbers.rb | UTF-8 | 282 | 3.703125 | 4 | [] | no_license | def even_fibonacci_sum(limit)
even_numbers(fibonacci_numbers(limit)).sum
end
def fibonacci_numbers(limit)
x = 1
y = 0
fibs = []
until (x + y) > limit do
fibs.push(x + y)
y = x
x = fibs.last
end
fibs
end
def even_numbers(fibs)
fibs.find_all(&:even?)
end | true |
764f00bc040ca2f49e3da31b7fe050512133c465 | Ruby | diegobolivar/spanish | /lib/spanish/verb.rb | UTF-8 | 677 | 2.890625 | 3 | [
"MIT"
] | permissive | module Spanish
module Features
extend self
attr_reader :person, :mood, :tense
# if no bits set, then 1st
@person = {
:second => 1 << 0,
:third => 1 << 1,
:plural => 1 << 2,
:familiar => 1 << 3
}
# if no bits set, then indicative
@mood = {
:subjunct... | true |
08953d2fd87bde147ed91820ba52323a59e8cb3a | Ruby | jasonLaster/DMKoans | /dm-code.rb | UTF-8 | 778 | 2.515625 | 3 | [] | no_license | require 'rubygems'
require 'data_mapper'
# setup sqlite3 connections
DataMapper.setup(:default, 'sqlite::memory:')
########################################
# MODELS ###############################
########################################
class Puppy
include DataMapper::Resource
# Properties
property :id, Seria... | true |
5d63032d3476a62eb05d133d6644a7794dcbe0da | Ruby | alekvuka/cartoon-collections-v-000 | /cartoon_collections.rb | UTF-8 | 671 | 3.3125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
def roll_call_dwarves(dwarfs)
dwarfs.each_with_index do |dwarf, index|
puts "#{index+1} #{dwarf}"
end
end
def summon_captain_planet(planets)
planets.map do |planet|
"#{planet.capitalize}!"
#require 'pry'
end
end
def long_planeteer_calls(calls)
calls.each do |call|
if call.s... | true |
583ed3b367f7f648448804000186b27c1de3919d | Ruby | Seluxit/easy_fake_network | /models/utility/obj.rb | UTF-8 | 1,487 | 2.65625 | 3 | [] | no_license | module Core_Lib
module Obj
def self.remove_nil_element(hash)
case hash
when Hash
hash.compact!
hash.each_value{|v| remove_nil_element(v)}
when Array
hash.compact!
hash.each{|v| remove_nil_element(v)}
end
hash
end
def self.load(hash, symbol_key... | true |
0f7e2d5b2a1b7fb5f071161396f327ae5587dbf1 | Ruby | philwhisenhunt/ruby-basics | /3sum.rb | UTF-8 | 617 | 3.375 | 3 | [] | no_license | def three_sum(nums)
res = []
nums = nums.sort()
nums.each_with_index do |num, index|
if index > 0 && num == nums[index - 1]
next
end
l = index + 1
r = nums.length - 1
while l < r
threeSum = num + nums[l] + nums[r]
if threeSum > 0
r -= 1
elsif threeSum... | true |
0ff6e850c4997f59c487e8f0c9c42adc5a5dd9ea | Ruby | ivar/magic-search-engine | /lib/condition/condition_frame.rb | UTF-8 | 189 | 2.9375 | 3 | [] | no_license | class ConditionFrame < ConditionSimple
def initialize(frame)
@frame = frame.downcase
end
def match?(card)
card.frame == @frame
end
def to_s
"is:#{@frame}"
end
end
| true |
958e25e1d47265fd1746d14b928f524459fca9c3 | Ruby | AnthonyLebro/ruby_battle_royal | /app.rb | UTF-8 | 566 | 2.984375 | 3 | [] | no_license | require 'bundler'
Bundler.require
require_relative 'lib/game'
require_relative 'lib/player'
player1 = Player.new("Colonel Antho")
player2 = Player.new("Destructor Xabi")
puts "Voici l'état de chaque joueur :"
puts "-------------------------------"
player1.show_state
player2.show_state
puts "--------------------------... | true |
cd7a050fc796b6993223c5fb5aeade5bc4525211 | Ruby | albertyw/rosalind | /stronghold/perm.rb | UTF-8 | 640 | 3.453125 | 3 | [] | no_license | n = 5
# Recursively get permutations
def get_permutations(digits)
return [digits] if digits.length == 1
permutations = []
digits.each_with_index do |digit, index|
digits_left = digits.rotate(index+1)[0,digits.length-1]
permutations_left = get_permutations(digits_left)
permutations_left.map!{|permutat... | true |
dd98c0b32bd70abba8c595ae7b1addfa221461d0 | Ruby | molenick/chain_punk | /spec/lib/chain_punk/generator_spec.rb | UTF-8 | 4,777 | 2.734375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe ChainPunk::Generator do
subject { ChainPunk::Generator.new(frequency_table) }
let(:frequency_table) {}
let(:grapheme_count) { 0 }
let(:options) { {} }
context '#phrase' do
context 'when called with a grapheme count of zero' do
le... | true |
a5d2fd14949653a7c505c2c30607dd47f24b7394 | Ruby | wing-x/paiza | /hack/sexy.rb | UTF-8 | 78 | 3.09375 | 3 | [] | no_license | m,n= gets.split.map(&:to_i)
if m > n
puts m - n
else
puts "0"
end
| true |
b43d69e2da112d567c5c43fb2d61880a939566f1 | Ruby | jdashton/glowing-succotash | /daniel/AoC/advent01.rb | UTF-8 | 169 | 2.703125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require_relative 'lib/advent01'
INPUT = IO.read('input/advent01.txt')
adv1 = Advent01.new
puts adv1.total_fuel(INPUT.lines.map(&:to_i))
| true |
cb7a0e7a8619482c94ee2bc934c4ab52e3ef9b9a | Ruby | unalterable/rails_enquiries | /sextant-altered/lib/schema_scraper.rb | UTF-8 | 875 | 3.1875 | 3 | [
"MIT"
] | permissive | class Schema_scraper
attr_reader :table_contents
def initialize(text)
@text = text
@table = false
@current_table = []
@table_contents = []
end
def scrape_schema
@text.each do |line|
end_in_line?(line)
create_table_in_line?(line)
@current_table << line[1].gsub(/[^0-9a-z]... | true |
33cf88f27512ee9a5378006ca4dedd642c56332c | Ruby | candlerb/nanoc | /lib/nanoc3/helpers/tagging.rb | UTF-8 | 2,281 | 3.171875 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
module Nanoc3::Helpers
# Nanoc3::Helpers::Tagging provides some support for managing tags added to
# items. To add tags to items, set the +tags+ attribute to an array of
# tags that should be applied to the item. For example:
#
# tags: [ 'foo', 'bar', 'baz' ]
#
# To activate this hel... | true |
17348b0d9532396f7cc4339542db58c840292c99 | Ruby | thomascpan/exercises | /data_structures/new/LinkedListTest.rb | UTF-8 | 909 | 3.328125 | 3 | [] | no_license | require_relative 'LinkedList'
p "linked_list1"
# INITIALIZE
linked_list1 = LinkedList.new
# INSERT
linked_list1.insert(1)
linked_list1.insert(2)
linked_list1.insert(0,0)
# PRINT_VALUES1
linked_list1.print_values1
# GET
p linked_list1.get(0)
p linked_list1.get(1)
p linked_list1.get(2)
p linked_list1.get(3)
# DELETE... | true |
7815f55873bbd70fcc293a5511c8af084cfdf549 | Ruby | lisataylor5472/backend_mod_1_prework | /section4/exercises/class_object.rb | UTF-8 | 1,468 | 4.09375 | 4 | [] | no_license | # Create a class called MyCar
class MyCar
attr_accessor :color
attr_reader :year
# Define instance variables year, color, model
def initialize(year, color, model)
@year = year
@color = color
@model = model
# set a starting point for a current_speed instance variable
@current_speed = 0
end
# f... | true |
14f7821e0cdf61ef89f2895a5d8f00de4a42f36b | Ruby | wayudi208012/learnmeabitcoin-code | /hexdec.rb | UTF-8 | 125 | 3.15625 | 3 | [] | no_license | #!/usr/bin/env ruby
def hexdec(hex)
dec = hex.to_i(16)
return dec
end
hex = ARGV[0] || STDIN.gets.chomp
puts hexdec(hex)
| true |
733337ae1c26aee48d903ef4fd4c06a6cc15cd39 | Ruby | ding-an-sich/batch-447 | /lectures/OOP/bank_account.rb | UTF-8 | 681 | 4.03125 | 4 | [] | no_license | # frozen_string_literal: true
# This is the Bank Account class
class BankAccount
attr_reader :money
def initialize(money, account_number, owner, bank_name)
@money = money
@account_number = account_number
@owner = owner
@bank_name = bank_name
end
def deposit(money)
change_balance(money)
... | true |
61ede11379d27f77bc54a5d887411c61972083c0 | Ruby | duleorlovic/config | /bin/whereami.rb | UTF-8 | 4,655 | 3.125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
#
# TODO: find blocks inside same intent and remove in level
# FULL_PREVIOUS_IF_NOT_BEGIN_WITH_SAME_WORD
#
# Run test:
# whereami.rb test
# Specific test
# whereami.rb --name test_same_level_on_previous
# Use byebug
# ruby -rbyebug whereami.rb test --name test_only_previous
# or uncomment foll... | true |
385be2935842f102466bc096aad5ad12dfb55e02 | Ruby | VAMelend/oxford-comma-001-prework-web | /lib/oxford_comma.rb | UTF-8 | 394 | 3.34375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | array = ["hippo,giraffe,monkey,horse"]
def oxford_comma(array)
if array.length == 1
return array.join
elsif array.length == 2
array.insert(1, "and")
array.join(" ")
elsif array.length == 3
newy= array.pop
lov= "and "+newy
yer= array.push(lov)
yer.join(", ")
elsif array.length > 3
eli= array.pop
di... | true |
c6a0f8697f3182c86a7523b6bc5b9a94d994f2e5 | Ruby | tlau425/blood-oath-relations-nyc-web-career-031119 | /app/models/follower.rb | UTF-8 | 514 | 3.25 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Follower
attr_accessor :name, :life_motto
attr_reader :age
@@all = []
def initialize(name, age, life_motto)
@name = name
@age = age
@life_motto = life_motto
@@all << self
end
def cults
Cult.all.select do |cult|
cult.followers.include?(self)
end
end
def join_cult(... | true |
b40fdeeefb09b51d294c0badda929b9eec2a48ab | Ruby | Jbern16/algos | /merge_meetings.rb | UTF-8 | 542 | 3.390625 | 3 | [] | no_license | def merge_meetings(meetings)
sorted_meetings = meetings.sort_by(&:first)
merged = [sorted_meetings[0]]
sorted_meetings[1..-1].each do |meeting_start, meeting_end|
prev_meeting_start, prev_meeting_end = merged[-1]
if meeting_start <= prev_meeting_end
merged[-1] = [ prev_meeting_start, ([meeting_end,... | true |
8595e0c3be4a4b8e84ed424ac48a95ca3e44357f | Ruby | SunOfDawn/extend-validators | /lib/extend-validators/validations/hash_validator.rb | UTF-8 | 3,946 | 2.75 | 3 | [
"MIT"
] | permissive | require 'extend-validators/validations'
module ActiveModel
module Validations
class HashValidator < EachValidator
include JsonValidationHelper
attr_accessor :validators, :default_options
def initialize(options)
super
init_sub_validators
end
def init_sub_validators... | true |
fba699a1408544b6cf0334cc7dce98f74cc077ce | Ruby | evansenter/gene | /test/unit/petri_test.rb | UTF-8 | 2,056 | 2.953125 | 3 | [
"WTFPL"
] | permissive | require File.join(File.dirname(__FILE__), "..", "test_helper.rb")
class PetriTest < Test::Unit::TestCase
def setup
# Don't make a petri here.
end
def test_true
assert true
end
def test_prepare_image
petri = setup_petri
assert_equal Magick::Image, petri.target_image.class
assert_equa... | true |
2ac87f5863bd2fb356b45ff4ea2aba391ef2e0aa | Ruby | ycohen26/Prework | /meanaverage.rb | UTF-8 | 247 | 3.671875 | 4 | [] | no_license | puts "Please enter 5 numbers."
num1 = gets.chomp
num2 = gets.chomp
num3 = gets.chomp
num4 = gets.chomp
num5 = gets.chomp
puts
answer = (num1.to_i+num2.to_i+num3.to_i+num4.to_i+num5.to_i)/5.to_f
puts "The mean average of your numbers is #{answer}"
| true |
83e5ee894398b59f3919bda0ef0ea35d8f72c17a | Ruby | Grynet/DYPL | /assignment2/code_generation.rb | UTF-8 | 3,253 | 3.21875 | 3 | [] | no_license | module Model
def self.generate(filepath)
file = File.open(filepath)
array_of_lines = file.readlines
file.close()
title_line = array_of_lines[0].split(" ")
title_line[1].slice! ":"
class_name = title_line[1]
attribute_hash = Hash.new()
constraint_hash = Hash.new()
for line in array_of_lines
if lin... | true |
c7484642c6659554bfaf06b6b6f382866664636a | Ruby | Florent2/Puzzle-Node--14 | /lib/user.rb | UTF-8 | 1,083 | 3.265625 | 3 | [] | no_license | class User
require "set"
attr_reader :name, :mentioned_names
def initialize(name)
@name = name
@mentioned_names = SortedSet.new
@connections = Array.new
end
def ==(other_user)
name == other_user.name
end
def <=>(other_user)
name <=> other_user.name
end
def add_... | true |
b779759338fa57e0d6d0076e6978323930953ac2 | Ruby | survivingknowledge/twlms | /app/helpers/sessions_helper.rb | UTF-8 | 1,718 | 2.703125 | 3 | [] | no_license | module SessionsHelper
# Logs in given user by setting session key
def log_in(user)
session[:user_id] = user.id
end
# Remembers a user in persistent session
def remember(user)
user.remember
# cookie is encrypted and expires in 20 years
cookies.permanent.signed[:user_id] = user.id
cookies.p... | true |
6f18aaaa04d3c4b8242b2267a2c1f110178c5963 | Ruby | Christopher-Steel/freecycle-sofa-harvester | /harvest.rb | UTF-8 | 1,162 | 2.78125 | 3 | [
"MIT"
] | permissive | require 'rest-client'
require_relative 'harvested_page'
API_URL = 'https://groups.freecycle.org'.freeze
class Harvester
def initialize
@api = RestClient::Resource.new(API_URL)
@sofas = []
end
def harvest_group(group)
@api["group/#{group}/posts/search"].post(
{
search_w... | true |
f10efd327bd7945d87e31be5e541eda0143b3332 | Ruby | sahyoni/RubyDoc | /inh_classes.rb | UTF-8 | 428 | 3.46875 | 3 | [] | no_license | class Animals
attr_accessor :color,:voice
def get_voice
return @voice
end
def get_color
return @color
end
end
class Dog< Animals
attr_accessor :owner
def get_owner
return @owner
end
end
def main
my_dog=Dog.new
my_dog.color=" black"
puts my_dog.get_color
my_dog.owner="hussein"
... | true |
607ffd3103af6c64bc0f179969006b390eb4520d | Ruby | edfallon/day_two_test | /ruby_functions_practice.rb | UTF-8 | 1,214 | 3.890625 | 4 | [] | no_license | def return_10
return 10
end
def add(num_1, num_2)
return num_1 + num_2
end
def subtract(num_1, num_2)
return num_1 - num_2
end
def multiply(num_1, num_2)
return num_1 * num_2
end
def divide(num_1, num_2)
return num_1 / num_2
end
def length_of_string(string_to_check)
return string_to_check.length
end
d... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.