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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
216890f35368c744cbae883342dc01c2585aa126 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/rna-transcription/98210579c08848c09ac84fa4af286d0e.rb | UTF-8 | 542 | 3.28125 | 3 | [] | no_license | class Complement
def self.of_dna(dna)
result = String.new
for i in 0...dna.length
case dna[i]
when 'C'
result << 'G'
when 'G'
result << 'C'
when 'T'
result << 'A'
when 'A'
result << 'U'
end
end
return result
end
def self.of_rna(rna)
result = String.... | true |
c910f552a2f6b8219154d59c6c3a9139407bd6da | Ruby | wolox-training/sd-rails | /app/services/open_library_service.rb | UTF-8 | 804 | 2.578125 | 3 | [] | no_license | class OpenLibraryService
include HTTParty
base_uri 'https://openlibrary.org'
def initialize(isbn)
@isbn = isbn
@options = { query: { bibkeys: "ISBN:#{isbn}", format: 'json', jscmd: 'data' } }
end
def book
response = self.class.get('/api/books', @options)
format_ol_response(@isbn, response)
... | true |
43fe8c1bb7664f7945ed855929c54372f1a51d7b | Ruby | coffeeexistence/oxford-comma-v-000 | /lib/oxford_comma.rb | UTF-8 | 244 | 3.328125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def oxford_comma(array)
if array.length()==1
return array[0]
end
if array.length()==2
return "#{array[0]} and #{array[1]}"
end
oxford_ending=", and #{array.pop()}"
oxford=array.join(", ")
oxford+=oxford_ending
oxford
end | true |
a77a0b152f1d2aabf11df37703eaf310ea27fd1a | Ruby | siddhantbajaj/classroom | /spec/lib/octopoller_spec.rb | UTF-8 | 1,980 | 2.765625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require "rails_helper"
RSpec.describe Octopoller do
it "does not accept negative wait time" do
expect { Octopoller.poll(wait: -1) {} }.to raise_error(ArgumentError, "Cannot poll backwards in time")
end
it "does not accept negative timeout" do
expect { Octopoller.poll(timeo... | true |
781a509d6506adf055d9c07a084fca9784fef22c | Ruby | smbsimon/ruby-practice | /rpn.rb | UTF-8 | 438 | 3.390625 | 3 | [] | no_license | class RPNCalculator
def evaluate(rpn)
stack = []
split_elements = rpn.split(" ")
split_elements.each_with_index do |element, index|
if element =~ /\d+/
stack << element.to_i
else
last_two_elements = stack.pop(2)
result = last_two_elements.inject(element)
stack... | true |
20600d40e5c6e74d39367b2af7a80b6ac74bd954 | Ruby | onetwotrip/postal | /script/generate_key_iv.rb | UTF-8 | 286 | 2.6875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'openssl'
require 'base64'
cipher = OpenSSL::Cipher.new('aes256')
cipher.encrypt
key = cipher.random_key
iv = cipher.random_iv
puts "Key: #{Base64.urlsafe_encode64(key, padding: false)}"
puts "IV: #{Base64.urlsafe_encode64(iv, padding: false)}" | true |
26f96d10221f41ed074406e556906dc6921f6648 | Ruby | charupriya/calculator_new | /lib/operations/sqr_command.rb | UTF-8 | 187 | 2.53125 | 3 | [] | no_license | #it square the value
class SqrCommand < Command
def initialize(operand, history, model)
super(operand, history, model)
end
def run_without_adding_to_history
@model.sqr
end
end | true |
df6423e15c059246f00da83d9a61cbc8c8099a09 | Ruby | farverio/OO-mini-project-houston-web-071618 | /lib/ingredient.rb | UTF-8 | 589 | 3.296875 | 3 | [] | no_license | class Ingredient
@@all = []
attr_reader :name
def initialize(name)
@name = name
@@all << self
end
def self.most_common_allergen
#find out how many users are have X ingredient as allergen
hash = Hash.new(0)
Allergen.all.each do |allergen_obj|
hash[allergen_obj.ingredient] += 1
... | true |
400781181b7e98f52b62fe43f7a5c2a5dfa2b646 | Ruby | asuka-tameya/contest | /task16_2.rb | UTF-8 | 266 | 3.484375 | 3 | [] | no_license | def cutbar(m,n)
count = 0
current = 1 #currentは現在の長さ
while n > current do
if current < m
current += current
count = count + 1
else
current += m
count += 1
end
end
puts (count)
end
cutbar(3,20)
cutbar(5,100) | true |
ff3450ac490fa711e06dc64d283c047ad31cf2a4 | Ruby | smgt/rainbow-painter-rb | /lib/rainbow_painter/palette.rb | UTF-8 | 3,829 | 2.671875 | 3 | [
"MIT"
] | permissive | require 'json'
module RainbowPainter
# Palette holds a set of colors
class Palette # rubocop:disable Metric/ClassLength
class FileNotFound < StandardError; end
class InvalidType < StandardError; end
attr_reader :custom
TERMINAL_COLORS = %w[color0 color1 color2 color3 color4 color5 color6
... | true |
4a7533d5222a5517ab6c613d8524d1f2b57fac31 | Ruby | srijondasgit/drawstories | /cbse/class7/SocialScience/chapter6.rake | UTF-8 | 1,931 | 2.765625 | 3 | [] | no_license | desc "TODO"
task chappter_one: :environment do
# Chappter.delete_all
# Book.delete_all
# Section.delete_all
# Question.delete_all
book = Book.new(school_id: 1, name: 'Book', author: 'author', book_type: 'General')
if book.save
chappter = Chappter.create(book_id: bo... | true |
b90aea7754a1e207415cde9c0936fd4c1215cf45 | Ruby | miyamadoKL/til | /til_20180609/lib/range.rb | UTF-8 | 544 | 3.765625 | 4 | [] | no_license | def liquid?(temperature)
(1...100).include?(temperature)
end
def charge(age)
case age
when 0..5
0
when 6..12
300
when 13..18
600
else
1000
end
end
range_and_under = 1..5
p range_and_under.include?(5) #=> true
range_less_than = 1...5
p range_less_than.include?(5) #=> false
a = 'abcdef'
p... | true |
48fbd8e2d9f427838f34d64928a8ceba4fbb8199 | Ruby | justinmauldin7/real_estate | /lib/house.rb | UTF-8 | 752 | 3.5625 | 4 | [] | no_license | require './lib/room'
class House
attr_reader :price, :address, :rooms_in_house
def initialize(price, address)
@price = price.split("$")[1].to_i
@address = address
@rooms_in_house = []
end
def rooms
@rooms_in_house
end
def add_room(room)
@rooms_in_house << room
end
def rooms_from_c... | true |
da4e7a05915159a433ff21af2eadabc91f2d1fe7 | Ruby | cowang01/cc_BRF | /specs/river_specs.rb | UTF-8 | 821 | 3.0625 | 3 | [] | no_license |
require('minitest/autorun')
require('minitest/rg')
require_relative('../river.rb')
require_relative('../fish.rb')
require_relative('../bear.rb')
class RiverTest < MiniTest::Test
def setup
@fishy1 = Fish.new("Bob")
@fishy2 = Fish.new("Tom")
@fishy3 = Fish.new("Dot")
@fishy4 = Fish.new("Loc")
... | true |
b8c2353f1fb06feb6d303fdec3e3b1f8f44ae724 | Ruby | fareedpatel/rps-challenge | /spec/computer_spec.rb | UTF-8 | 243 | 2.53125 | 3 | [] | no_license | require 'computer'
describe Computer do
subject(:computer) { described_class.new }
it 'computer chooses weapon' do
allow(computer).to receive(:choose_weapon).and_return :rock
expect(computer.choose_weapon).to eq :rock
end
end | true |
9ad47b4243df511f35dd65aad58be850271fde8b | Ruby | sineong/wabook | /app/helpers/books_helper.rb | UTF-8 | 944 | 2.828125 | 3 | [] | no_license | module BooksHelper
def isCorrectISBN?(isbn)
Rails.logger.info isbn
book_data = getBookFromISBN(isbn)
if book_data["title"] == ""
Rails.logger.info "incorrect!"
return false
else
return true
end
end
def isRegistered?(isbn)
books = Book.all
books.each do |b|
if b.isbn == isbn
return true
... | true |
5e414676dd2a74ed8da85e991e47d603679fabf0 | Ruby | puppetlabs/rototiller | /spec/rototiller/utilities/color_text_spec.rb | UTF-8 | 565 | 2.5625 | 3 | [
"Apache-2.0"
] | permissive | require "spec_helper"
require "rototiller/utilities/color_text.rb"
describe Rototiller::ColorText do
# extended class
let(:extended_dummy) { Class.new { extend Rototiller::ColorText } }
let(:string) { random_string }
let(:color) { 8 }
it { expect(extended_dummy.colorize(string, color)).to match color.to_s +... | true |
567abde294fbc2a83ad664c8a5ebc84494786845 | Ruby | geraldy1st/Prac | /felix/test.rb | UTF-8 | 637 | 4 | 4 | [] | no_license |
def ajouter
puts "Donne moi un numero!"
nombre = gets.chomp.to_i
tour = 1
stocker = 0
while tour <= nombre
stocker = stocker + tour
puts "le nombre de tour: #{tour} + le num stocké: #{stocker} = ???"
tour += 1
end
end
ajouter()
# nom = "Geraldy"
# nom1 = "Larry"
# nom2 = "Zac"
# nom3 = ... | true |
fbaa8205ea2bac294a08075876542b6a105b2635 | Ruby | farmerchuk/120_object_oriented | /twenty_one.rb | UTF-8 | 4,427 | 3.515625 | 4 | [] | no_license | module Hand
MAX_VALUE = 21
DEALER_STAND_ON = 17
attr_reader :hand
def display_hand
puts "#{name} has these cards:"
hand.each { |card| puts card.to_s }
puts "Total value of: #{hand_value}"
puts
end
def hand_value
aces = hand.count { |card| card.name == 'ACE' }
value = hand.map(&:va... | true |
cd1a9f79bb49977a6bafdae10af91a3da93a04e2 | Ruby | ddiaz810/David_Diaz_LaunchSchool | /m_saydefault.rb | UTF-8 | 338 | 3.796875 | 4 | [] | no_license |
#When you're defining methods you may want to structure your method so
#that it always works, whether given parameters or not.
def say(words = 'hello') #a default parameter that is used whenever our method is called without any arguments.
puts words + '.'
end
say()
say("hi")
say("how are you")... | true |
283d0491081875f46d9d72b718f200a9f58df984 | Ruby | liyancode/DPCrawl | /crawl/app/crawl/category_and_region_crawl.rb | UTF-8 | 1,255 | 2.65625 | 3 | [] | no_license | # pseudocode
all_city_list=[]
all_category_level_0_list=[]
http_client=HTTPClient.new
all_city_list.each{ |city|
all_category_level_0_list.each{|category_level_0|
city_category_0_page=http_client.get(
"http://www.dianping.com/search/category/#{city.city_id}/#{category_level_0.category_id}/"
).c... | true |
f82b1de9ebbf9e8b936770f11019331d4b6e8cf2 | Ruby | connor-wright/sticker-app | /app/modules/imgur_api_wrapper.rb | UTF-8 | 906 | 2.609375 | 3 | [] | no_license | #A module used to wrap the imgur api client calls
#based off here https://www.nopio.com/blog/how-to-create-an-api-wrapper-of-an-external-service-in-rails/
module ImgurApiWrapper
class Client
API_ENDPOINT = 'https://api.imgur.com/3/'
CLIENT_ID = ENV['IMGUR_CLIENT_ID']
def search_image(query)
... | true |
925bb7f8ddc09c44fbbfc34ce576511f3f0f6391 | Ruby | nanstey/ar-exercises | /exercises/exercise_8.rb | UTF-8 | 545 | 2.828125 | 3 | [] | no_license | require_relative '../setup'
require_relative './exercise_1'
require_relative './exercise_2'
require_relative './exercise_3'
require_relative './exercise_4'
require_relative './exercise_5'
require_relative './exercise_6'
require_relative './exercise_7'
# ActiveRecord::Schema.define do
# change_table :employees do |t... | true |
b2805aa502fe56f78d3b99dfd5fc3b1960c61ae3 | Ruby | yeeboo-digital/data_director | /lib/data_director/normalize.rb | UTF-8 | 821 | 2.703125 | 3 | [] | no_license | module DataDirector
class Normalize
class << self
def call(record)
self.new.call(record)
end
def inherited(subclass)
DataDirector::Normalize.subclasses << subclass unless DataDirector::Normalize.subclasses.include?(subclass)
end
def subclasse... | true |
0f5fc4ed6b86f795fd0a527b6b07368fdcbf6e91 | Ruby | boradori/linkedList | /linkedlist.rb | UTF-8 | 1,875 | 4.3125 | 4 | [] | no_license | class Node # Node object
attr_accessor :value, :next
def initialize(value) # initialize with a value
@value = value
end
end
class LinkedList
def self.print_forward(node) # This method prints out node object
while node != nil # while node exists
puts node.value # puts node's value
node = no... | true |
ac5d1a7886709df373e5f17bc5147b49db809a2d | Ruby | artyom-ukhabin/AdviceMeAgain | /app/services/collaborations/rater.rb | UTF-8 | 789 | 2.5625 | 3 | [] | no_license | module Collaborations
class Rater
def initialize(items_type, queries_aggregator)
@items_type = items_type
@queries_aggregator = queries_aggregator
end
def find_highrated_items(user)
@queries_aggregator.find_highrated_items(user).to_a
end
def find_lowrated_items(user)
@que... | true |
199a699143f18daa4942c8b34dc0a3a8807787f0 | Ruby | ga-wolf/WDI10-Homework | /kasturi-ghosh/week_04/Ruby_day2/pling-plang-plong.rb | UTF-8 | 557 | 4.75 | 5 | [] | no_license | # If the number contains 3 as a prime factor, output 'Pling'. If the number contains 5 as a prime factor, output 'Plang'. If the number contains 7 as a prime factor, output 'Plong'.
# If the number does not contain 3, 5, or 7 as a prime factor, simply return the string representation of the number itself.
print "Ente... | true |
f35ac3a4b235ef2592274d9275328adadcafdab2 | Ruby | saasbook/Project-Elevate | /app/models/coach_availability.rb | UTF-8 | 1,304 | 2.703125 | 3 | [] | no_license | class CoachAvailability < ApplicationRecord
def self.availibility
1...13
end
def self.this_week(coach_id)
res = Hash.new
Date::DAYNAMES.each do |day|
res[day] = CoachAvailability.where(:coach_id => coach_id, :day => day)
end
return res
end
def se... | true |
b1cb157c62bc82731a5f4544850bf899f6a09b77 | Ruby | Samdabell/Big_Als_record_store_project | /models/album.rb | UTF-8 | 2,430 | 3.390625 | 3 | [] | no_license | require_relative ('../db/sql_runner')
require_relative ('./artist')
class Album
attr_accessor :id, :title, :artist_id, :stock, :genre, :year, :buy_price, :sell_price, :artwork, :spotify
def initialize(options)
@id = options['id'].to_i
@title = options['title']
@artist_id = options['artist_id'].to_i
... | true |
31f7433d4f59bc099ab1070ad2f02f8c4f5d332b | Ruby | zabir8809/ruby-data-structures-algorithms-patterns | /data-structure/binary_search_tree.rb | UTF-8 | 1,529 | 3.890625 | 4 | [] | no_license | class Node
attr_accessor :value, :left_node, :right_node
def initialize(val)
@value = val
@left_node = nil
@right_node = nil
end
end
class BinarySearhTree
attr_reader :root
def initialize(value = nil)
@root = Node.new(val)
end
def depth_first_in_order
end
def breadth_first
... | true |
c46381c8c52895633fa0fd94888dd7c8bea903b3 | Ruby | mayra-cabrera/kalite | /app/models/attribute.rb | UTF-8 | 971 | 2.65625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
class Attribute < ActiveRecord::Base
has_many :concepts
attr_accessible :name
validates :name, :presence => true
validates_format_of :name, :with => /^(?:[^_]|\s)*$/u
def how_many_concepts(concepts, attribute_id)
count = 0;
concepts.each do |c|
concept = Concept.fin... | true |
8d13009a88cc14777d085cdf196004e06d21f724 | Ruby | ifelajulo/ptax | /lib/helpers/rest_helper.rb | UTF-8 | 1,105 | 2.578125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module Helpers
module RestHelper
def get(url, params = {})
RestClient.get(url, :params => split_params(params)) do |response, request, result|
case response.code
when 200
response.body
else
raise "PTAX API Error(code=#{response.code}): #{response.body}"
... | true |
288e502da4db66437a6976d4b6a79070af2b9331 | Ruby | scmilee/TrailOrTrash | /spec/models/hiker_spec.rb | UTF-8 | 1,255 | 2.59375 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe Hiker do
let (:hiker) { create(:hiker, name:'Forrest Gump') }
let(:trail) { create(:trail) }
let (:fake_big_dependency) {FakeBigDependency.new()}
it 'has a name' do
expect(hiker.name).to eq 'Forrest Gump'
end
it 'can add a trail to its hiked trails' do
... | true |
60214e07e748f91c126141cdc98e3f2b0a996c8c | Ruby | kaineer/ream | /lib/ream/shell/interactor.rb | UTF-8 | 485 | 3.09375 | 3 | [
"MIT"
] | permissive | # 2009.12.02
module Ream
class Shell
class Interactor
def initialize( prompt = nil )
@prompt = prompt
end
def read( default_value = nil )
print prompt_value
value = gets.chomp
if default_value && value.empty?
value = default_value
else
... | true |
469860799c783ccd761d8ee8ed54c858242e8355 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/proverb/2a487b63c91b498d93a9fc23033b3f43.rb | UTF-8 | 473 | 3.296875 | 3 | [] | no_license | class Proverb
def initialize(*causes, qualifier: nil)
@causes = causes
@clause = qualifier + " " if qualifier
@root_cause = causes.first
end
def to_s
(stanzas << ending).join("\n")
end
def stanzas
@causes.each_cons(2).map { |cause, effect| stanza(cause, effect) }
end
def stanza(cau... | true |
1496ca2d9403d55f5d221c31c9c21d1b45b41e81 | Ruby | Heybluguy/black_thursday | /lib/customer_repository.rb | UTF-8 | 909 | 3 | 3 | [] | no_license | require_relative 'customer'
class CustomerRepository
attr_reader :all,
:sales_engine
def initialize(parent = nil)
@all = []
@sales_engine = parent
end
def inspect
"#<#{self.class} #{@all.size} rows>"
end
def populate(filename)
CSV.foreach(filename, headers: true, header_con... | true |
f4e7826097f84f781ce96da491281e19eb92415d | Ruby | thiagossdev/ruby-101 | /module_03/section_04/blocks.rb | UTF-8 | 430 | 3.90625 | 4 | [] | no_license | def block
puts 'This is the beginning of the block'
yield
puts 'This is the end of the block'
end
block { puts 'I was called in the method call block' }
puts '---------------------------------------------------'
block do
puts 'This way, you can call several instructions for the block'
puts ':)'
end
def has_... | true |
4b7014b69067810aad68e26af27224e8193ea2ef | Ruby | fgrehm/clipper | /lib/clipper/syntax/sql.rb | UTF-8 | 1,099 | 2.9375 | 3 | [] | no_license | module Clipper
module Syntax
class Sql
def initialize(repository)
@repository = repository
end
def serialize(sexp)
send(*sexp)
end
protected
def and(*args)
"(" + args.map do |expr|
send(*expr)
end.join(" AND ") + ")"
end
... | true |
78b8abf335ca93e12d6396fa16ad91d2c4d3e8ed | Ruby | eshao/stationx | /nginx_server.rb | UTF-8 | 2,506 | 2.515625 | 3 | [] | no_license | # lib/nginx_server.rb
#
#
class N
attr_accessor :name, :prefix, :opt, :suffix
def initialize(*params)
# Check for subdomain parameter
@name = params[0]
@port = 80
if @name =~ /^(.*):(\d*)$/
@name = $1
@port = $2
end
if @name =~ /^\.(.*)$/
@sd = true
@name = $1
en... | true |
638d0077f46c78a6f445e5bc79234a17b0bc5eaf | Ruby | TrevMcKendrick/backoffice | /app/models/customer_builder.rb | UTF-8 | 739 | 2.625 | 3 | [] | no_license | class CustomerBuilder
include ActiveModel::Model
attr_accessor :first_name, :last_name, :email, :company
def initialize(hash)
@first_name = hash[:first_name]
@last_name = hash[:last_name]
@email = hash[:email]
@company = hash[:company]
end
def with_token(token)
customer = Stripe::Custom... | true |
895b3e9138577cf61f04d626ad239979a33cde13 | Ruby | jakef203/RB120-ObjectOrientedProgramming | /Lesson_4/Practice_Problems/Hard1_q1.rb | UTF-8 | 1,103 | 3.203125 | 3 | [] | no_license |
# class SecretFile
# attr_reader :data, :logged_info
# def initialize(secret_data)
# @data = secret_data
# @logged_info = SecurityLogger.new
# end
# end
# class SecurityLogger
# attr_reader :time, :filesize
# def create_log_entry(filesize)
# @time = Time.now
# @filesize = filesize
# end
... | true |
382bccf4d2e5f89045970cf845f00cf4263807d8 | Ruby | Djamal1/Ruby | /Ruby_0/r7/string_1.rb | UTF-8 | 187 | 3.203125 | 3 | [] | no_license | =begin
i = 1
while i < 5
puts i
end
# Бесконечная цифра 0, точнее спам, с помощью while
=end
i = 0
while i < 6
puts i
i = i + 1
end | true |
586a85a30505ba3bd4f454f118493e4c66fba6f5 | Ruby | RobertoJofreGodoy/Presencial16 | /prueba.rb | UTF-8 | 2,185 | 3.5625 | 4 | [] | no_license | data = []
File.open("notas.csv", "r") { |file| data= file.readlines }
def promedios(hashito)
lines = hashito.map(&:chomp)
nota = File.open("promedios.csv", 'w')
lines.each do |value|
promedio = value.split(',')
sum = 0
cont = 0
promedio.each do
if promedio[cont].to_i.is_a? Inte... | true |
709c35fbf3d54f3086f4dbad142cd2815a0bfaf7 | Ruby | russellcape/ar-exercises | /exercises/exercise_6.rb | UTF-8 | 1,107 | 3.015625 | 3 | [] | no_license | require_relative '../setup'
require_relative './exercise_1'
require_relative './exercise_2'
require_relative './exercise_3'
require_relative './exercise_4'
require_relative './exercise_5'
puts "Exercise 6"
puts "----------"
# Your code goes here ...
@store1.employees.create(first_name: "Barack", last_name: "Obama", h... | true |
2e9d14ef69320b189d15ecc295493941a3336a48 | Ruby | rhinorphan/projet_validant_ruby | /exo_17.rb | UTF-8 | 595 | 3.859375 | 4 | [] | no_license | puts "Salut, bienvenue dans ma super pyramide ! Choisis un nombre d'étages entre 1 et 25."
print "> "
floors_input = gets.to_i
for i in 0..floors_input # number of loop depending of our how many row we want to print (user_floors)
blank = " "
symbol = "#"
print blank * (floors_input - i) # number of empty "case" i... | true |
ca56edfed07a160b62036868ececdd4c91be9f84 | Ruby | trailblazer/reform | /lib/reform/form/populator.rb | UTF-8 | 4,596 | 2.625 | 3 | [
"MIT"
] | permissive | # Implements the :populator option.
#
# populator: -> (fragment:, model:, :binding)
# populator: -> (fragment:, collection:, index:, binding:)
#
# For collections, the entire collection and the currently deserialised index is passed in.
class Reform::Form::Populator
def initialize(user_proc)
@user_proc = user_p... | true |
5894ecf26a427fe8671d8b54f337f9c19e6ccb96 | Ruby | lefant/whole_history_rating | /test/whr_test.rb | UTF-8 | 2,682 | 2.90625 | 3 | [
"MIT"
] | permissive | require 'test/unit'
require 'whole_history_rating'
class WholeHistoryRatingTest < Test::Unit::TestCase
def setup
@whr = WholeHistoryRating::Base.new
end
def setup_game_with_elo(white_elo, black_elo, handicap)
game = @whr.create_game("black", "white", "W", 1, handicap)
game.black_player.days[0... | true |
2f7b59295af2605a5772a0d676ca21fa76f9fc0e | Ruby | carbonfive/slacky | /lib/slacky/message.rb | UTF-8 | 1,469 | 3.125 | 3 | [] | no_license | module Slacky
class Message
attr_reader :raw, :text, :user, :channel
@@decorator = @@bot = nil
def self.decorator=(decorator)
@@decorator = decorator
end
def self.bot=(bot)
@@bot = bot
end
def initialize(user, channel, raw)
@raw = raw
@user = user
@channel... | true |
c1a1ee492a77177e655f49c3463029b696767e64 | Ruby | Skylled30/Standard-deviation | /deviation.rb | UTF-8 | 289 | 3.125 | 3 | [] | no_license | file = File.open("inp2.txt")
data = []
file.each do |line|
data << line.to_f
end
amount = 0
data.each do |number|
amount += number
end
average = amount / data.size
amount = 0.0
data.each do |number|
amount += (number - average) ** 2
end
puts Math.sqrt(amount / data.size)
| true |
6ba6226f91147f8947c4a9a7bd54afb44b5ed089 | Ruby | ApiBootstraper/Rails-server | /app/models/application.rb | UTF-8 | 1,083 | 2.765625 | 3 | [
"MIT"
] | permissive | class Application < ActiveRecord::Base
# Hooks
before_create :before_create
# Protect datas
attr_accessible :app_id, :app_key, :name, :comment, :enable
# Validators
validates :name, :presence => true,
:uniqueness => true
# Named Scopes
scope :enabled, lambda{ where("is_enable = ... | true |
5c00c5e267cfa2d8181a59795b80c9955e36077e | Ruby | tomdalling/dabooks | /lib/dabooks/cli/running_command.rb | UTF-8 | 1,415 | 2.765625 | 3 | [] | no_license | require 'csv'
module Dabooks
class CLI::RunningCommand
DETAILS = {
description: 'Shows a running total for a given account.',
usage: 'dabooks running [options] <account> <filename>+',
schema: {
csv: {
long: '--csv',
short: '-c',
doc: 'Output in CSV format'
},
},
... | true |
0f5ea9c0f2894b0139ee36ff6ccd97657db4f164 | Ruby | tactppp/intern_training_algorithm | /draw_hand.rb | UTF-8 | 1,755 | 3.3125 | 3 | [] | no_license | class << self
define_method "draw_hand" do
winning_hand_keys = DrawHander::FIXING_HANDS.keys
is_call_winning_hand = winning_hand_keys.any? do |key|
ARGV[0] == key.to_s
end
if is_call_winning_hand
type = ARGV[0].to_sym
else
type = :random
end
draw_hander = DrawHander.... | true |
774169f79240985d5cf7bc28a44d9e765abc246b | Ruby | Zapata/rockstails | /model/bar_stats_calculator.rb | UTF-8 | 572 | 3 | 3 | [] | no_license | require_relative 'bar_stats'
class BarStatsCalculator
def compute_stats(bar, cocktails)
bar_stats = BarStats.new
cocktails.each do |c|
if bar.can_do?(c)
bar_stats.add_cocktail(c.rate)
else
missing_ingredients = (c.ingredient_names.to_set - bar.ingredient_names)
if mis... | true |
e7cc52ed9f65de8337f6affd1957971e8dc1ef81 | Ruby | rhomobile/rhodes | /spec/framework_spec/app/spec/core/kernel/fixtures/caller_fixture2.rb | UTF-8 | 414 | 2.6875 | 3 | [
"MIT"
] | permissive | module CallerFixture
def block
@block
end
module_function :block
def block=(block)
@block = block
end
module_function :block=
def capture(&block)
@block = block
end
module_function :capture
def caller_of(block)
eval("caller(0)", block.binding)
end
module_function :caller_of
... | true |
52a14f2bd848427b632267ce9465f2acd325d004 | Ruby | wisetara/4.1Parcels_Triangles_To-Do | /Parcels/triangles/spec/triangles_spec.rb | UTF-8 | 840 | 3.375 | 3 | [] | no_license | require 'rspec'
require 'triangles'
describe Triangle do
it "is initialized with three sides" do
test_triangle = Triangle.new(5,10,20)
test_triangle.should be_an_instance_of Triangle
end
it "recognizes an equilateral triangle" do
test_triangle = Triangle.new(5,5,5)
test_triangle.type.should eq "T... | true |
78f9f991a52299603efbdf7c01604d86f912f93e | Ruby | roll/goodread.rb | /lib/helpers.rb | UTF-8 | 2,584 | 2.953125 | 3 | [
"MIT"
] | permissive | require 'yaml'
require 'emoji'
require 'colorize'
$state = {'last_message_type' => nil}
# Module API
def read_config()
config = {'documents' => ['README.md']}
if File.file?('goodread.yml')
config = YAML.load(File.read('goodread.yml'))
for document, index in config['documents'].each_with_index
if do... | true |
04e893de3e6c1c17d8604ee38ca8672b9653538a | Ruby | project-eutopia/keisan | /lib/keisan/interpreter.rb | UTF-8 | 810 | 2.984375 | 3 | [
"MIT"
] | permissive | require "keisan/repl"
module Keisan
class Interpreter
attr_reader :calculator
def initialize(allow_recursive: false)
@calculator = Calculator.new(allow_recursive: allow_recursive)
end
def run(file_name)
if file_name.nil?
run_from_stdin
else
run_from_file(file_name)... | true |
0f25f0e5e6fcf976ce3e3604c16264b99d1e18bc | Ruby | abowler2/small_problems | /easy6/triangle.rb | UTF-8 | 244 | 3.875 | 4 | [] | no_license | def triangle(n)
star = '*'
space = ' '
star_index = 1
space_index = (n - 1)
while star_index <= n
puts (space * space_index) + (star * star_index)
space_index -= 1
star_index += 1
end
end
triangle(5)
triangle(9)
| true |
6476f69e91d50ae7545eb331cb9fbf5e99883b12 | Ruby | brilatimer/ride-share | /ride_share.rb | UTF-8 | 3,708 | 3.171875 | 3 | [] | no_license | rides = [
{
driver_id: 'DR0004',
date: '3rd Feb 2016',
cost: '5',
rating: '5',
rider_id: 'RD0022',
},
{
driver_id: 'DR0001',
date: '3rd Feb 2016',
cost: '10',
rating: '3',
rider_id: 'RD0003',
},
{
driver_id: 'DR0002',
date: '3rd Feb 2016',
cost: '25',
r... | true |
7e4da768bfb4b3b46419e50469e96e6dfbb65bdb | Ruby | elm-city-craftworks/space_explorer | /lib/space_explorer/rover.rb | UTF-8 | 648 | 2.953125 | 3 | [] | no_license | require "thread"
module SpaceExplorer
class Rover
def initialize(world, radio_link)
@world = world
@radio_link = radio_link
@queue = Queue.new
Thread.new { loop { process_command(@queue.pop) } }
end
def receive_command(command)
@queue.push(command)
end
def p... | true |
6d18b6f4fa0e99e3d0075805106b88414a24eda4 | Ruby | selfup/mod2-individual-work | /LRTHW/jex21.rb | UTF-8 | 1,066 | 4.75 | 5 | [] | no_license | def add(a, b)
puts "ADDING #{a} + #{b}"
return a + b # return simply means perform said action or "this will equal"
end
def subtract(a, b)
puts "SUBTRACTING #{a} - #{b}"
return a - b # remember return is what comes after the "=" sign
end
def multiply(a, b)
puts "MULTIPLYING #{a} * #{b}"
return a * b
end
... | true |
4e8b621cfbb4eaede6f43aa8f0f5f2ae8749fef5 | Ruby | hyphenized/study-group-utils | /commands/print.rb | UTF-8 | 240 | 2.515625 | 3 | [
"MIT"
] | permissive | #
# EXAMPLE COMMAND TEMPLATE
#
#
class Print < Command
NAME = "print"
DESCRIPTION = "Outputs something to the CLI"
def initialize
super
end
def run(**kwargs)
puts kwargs[:args]
end
end
$_commands[__FILE__] = Print.new
| true |
4697c30e76bc4130c6df17c92e85371262f0ee06 | Ruby | kxion/fancywidget | /lib/fancywidget/widget/window.rb | UTF-8 | 1,068 | 2.515625 | 3 | [] | no_license | module FancyWidget
class Window < Flow
attr_accessor :title, :icon, :resizable
attr_accessor :canvas
include TextStyle
def default_styles
super.merge({
title: 'Fancy Widget',
width: 600,
height: 400,
background: white,
color: black,
font: Font.n... | true |
4f02309c3581877a0249540189d692c2cca34c43 | Ruby | holyketzer/ctci_v6 | /ruby/spec/10_sorting_and_searching/11_peak_and_valleys.rb | UTF-8 | 752 | 3.078125 | 3 | [
"MIT"
] | permissive | # Time = O(n), Mem = O(1)
def peak_and_valleys_a(arr)
(0..(arr.size - 3)).each do |i|
peak = i % 2 == 1
if peak
min, mid, max = *arr[i..(i+2)].sort
arr[i] = min
arr[i + 1] = max
arr[i + 2] = mid
end
end
arr
end
RSpec.describe 'peak_and_valleys' do
%i(a).each do |implement... | true |
c37b6da3d28c36fee438d42da3821b4682a7a401 | Ruby | leighanotleia/ruby_fundamentals2 | /exercise5.rb | UTF-8 | 165 | 3.96875 | 4 | [] | no_license | puts "What's the temperature out there?"
temp = gets.to_i
def temp_f(temp)
(temp - 32) * (9 / 5)
end
puts "You said #{temp} but in Canada thats #{temp_f(temp)}"
| true |
3123dff41e7bc7ebae9d5a60a7023040a5106a42 | Ruby | ElizabethU/Space-Data-Conversion | /planet_scraper.rb | UTF-8 | 1,714 | 2.984375 | 3 | [] | no_license | require 'mechanize'
class Planet_data_getter
def initialize
@agent = Mechanize.new
@page = @agent.get('http://omniweb.gsfc.nasa.gov/coho/helios/planet.html')
@planet_array = ["venus", "mars", "jupiter", "saturn", "uranus", "neptune", "earth", "mercury"]
end
def submit_form
for n in (0..7)
... | true |
1fc38134b535a67fe2bbb17bc527e25fe8f81e0d | Ruby | AlbertCarreras/ruby-object-initialize-lab-bootcamp-prep-000 | /lib/dog.rb | UTF-8 | 110 | 3.171875 | 3 | [] | no_license | class Dog
def initialize(name_dog, breed_dog = "Mutt")
@name = name_dog
@breed = breed_dog
end
end | true |
ecb8fdaed03ad34f4d714e1059aa42cdba0e9422 | Ruby | libis/ReIReSearch | /agensgraph_loader/src/lib/Ingester.rb | UTF-8 | 4,651 | 2.625 | 3 | [] | no_license | require 'uri'
require './lib/agensgraph'
require 'date'
class Ingester
def initialize(host,username,password, graph)
@agens = AgensGraph.new(host)
@agens.connect(username, password)
@agens.set_graph(graph)
@validator = Validator.new
@sdParameters = {}
end
def setStoredDataParameter(key, valu... | true |
f311688f1de912356789a5cb5776f45f505cfb09 | Ruby | osorubeki-fujita/odpt_tokyo_metro | /lib/tokyo_metro/factory/generate/static/railway_line/info.rb | UTF-8 | 2,894 | 2.5625 | 3 | [
"MIT"
] | permissive | class TokyoMetro::Factory::Generate::Static::RailwayLine::Info < TokyoMetro::Factory::Generate::Static::MetaClass::Info::WithAttrSameAs
include ::TokyoMetro::ClassNameLibrary::Static::RailwayLine
include ::OdptCommon::Modules::Time::Set
include ::TokyoMetro::Factory::Generate::Static::MetaClass::Polymorphic::Tw... | true |
8f3f693a00c6095385a2b096d68ecd5685dbfa37 | Ruby | invernizzi/lint_fu | /lib/lint_fu/core/issue.rb | UTF-8 | 1,010 | 2.5625 | 3 | [
"MIT"
] | permissive | module LintFu::Core
class Issue
attr_reader :file, :sexp, :confidence
def initialize(scan, file, sexp, confidence=1.0)
@scan = scan
@file = file
@sexp = sexp.deep_clone
self.confidence = confidence
end
def line
@sexp.line
end
def relative_file
File.re... | true |
3e323c7f86ed5f043c5425c75fd5f27e798f2fbd | Ruby | j0rdania/phase-0-tracks | /ruby/iteration.rb | UTF-8 | 5,375 | 4.125 | 4 | [] | no_license | ############## RELEASE 0 #####################
puts "RELEASE 0"
#define method that will take block code as argument
def display_favorite_things
puts "This method is gearing up to start!"
# yield to block code in method call, passing three colors
yield("blue","purple","pink")
# yield to block code in method call,... | true |
24ebbf60f4b7922c9806814105c27a5d98204613 | Ruby | Ryo-Odo/jihanki | /jihanki.rb | UTF-8 | 5,439 | 3.40625 | 3 | [] | no_license | # irb
# load './jihanki.rb'
# vm = VendingMachine.new(1)
# 作成した自動販売機に100円を入れる
# vm.slot_money (100)
# 作成した自動販売機に入れたお金がいくらかを確認する(表示する)
# vm.current_slot_money
# 作成した自動販売機に入れたお金を返してもらう
# vm.return_money
#---------------------------------------------------------------------------------------------------
module... | true |
3498a7829589066383bf4855e46fa905c3bfa6a9 | Ruby | guokear/programming | /rubyprogramming/count.rb | UTF-8 | 186 | 3.28125 | 3 | [] | no_license | source = "abcdefg"
new_string = []
source.split('') . each {|c|
new_string.unshift(c)
}
p new_string.join
list =%w(1 3 5 1 7 nil 7)
p list.sort
str = "abcdefg"
p str.chop
p str
| true |
193820519377670fa2d812643e2c21763c2d3b99 | Ruby | ceccocats/LapackWrapper | /Manual_doxygen/doxygenFilter.rb | UTF-8 | 1,777 | 2.640625 | 3 | [] | no_license | #!/usr/bin/env ruby -w
require 'fileUtils'
$figname = ""
$figlines = ""
def write_figure()
# stampo comando di inclusione figura
dir = File.dirname(__FILE__)+"/DoxygenImages/" ;
basename = dir+$figname.to_s;
fname = basename+".asy";
outname = basename+".pdf";
docmp = File.exist?(fname) # con... | true |
3ffa52b7d4ccda29ea776e6181a24585891a9c6a | Ruby | walidzbiri/gestion_biblio | /biblio.rb | UTF-8 | 5,754 | 2.9375 | 3 | [] | no_license | $LOAD_PATH << File.dirname(__FILE__)
require 'empruntable'
require'adherent'
require 'document'
require 'materiel'
require 'csv'
require 'exceptions'
require 'customized_array'
require 'mon_hash'
class Biblio
attr_accessor :adherents,:documents,:materiels,:emprunts
def initialize(adherents=CustomizedArray.new... | true |
7ae67c082f1532c8c8d1ca94a766453a43cbef12 | Ruby | unagiootoro/RGSS_MZ | /rgss/scripts/src/Window_ShopStatus.rb | UTF-8 | 3,922 | 2.75 | 3 | [] | no_license | #==============================================================================
# ■ Window_ShopStatus
#------------------------------------------------------------------------------
# ショップ画面で、アイテムの所持数やアクターの装備を表示するウィンドウです。
#==============================================================================
class Wind... | true |
978ef51eb3b4da7f83656822ac1d99c1ee66c130 | Ruby | znz/fprog-nadoka-plugins | /messagebot.nb | UTF-8 | 4,550 | 2.546875 | 3 | [] | no_license | # -*-ruby; coding: utf-8 -*- vim:set filetype=ruby:
#
# Copyright (C) 2004-2005 Kazuhiro NISHIYAMA
#
# This program is free software with ABSOLUTELY NO WARRANTY.
# You can re-distribute and/or modify this program under
# the same terms of the Ruby's license.
#
# $Id$
#
=begin
== Abstract
pass on a mes... | true |
cc0de2e8ab1c55cc21d55e9f615912668fb4c3ab | Ruby | myronmarston/ghosts-and-spirits | /vendor/extensions/variables/lib/variables/page_tags.rb | UTF-8 | 2,396 | 2.84375 | 3 | [
"MIT"
] | permissive | module Variables
def self.contextual_vars(tag)
var_attrs = {}
tag.context.instance_variable_get(:@tag_binding_stack).each do |tag_binding|
case tag_binding.name
when 'snippet'
var_attrs.merge!(tag_binding.attr.except('name'))
when 'content'
var_attrs.merge!(... | true |
a9a9f6d797a08ac2fe2a4596c76603189c65fe80 | Ruby | Gabrielg1976/text2midi | /text2midi/lib/shred/foo.rb | UTF-8 | 1,122 | 2.984375 | 3 | [] | no_license | module Chuckr
module Shreds
class Foo < Shred
def setup
# add_patch :SinOsc, "SinOsc => JCRev => dac"
set :loop => true, :time => 100, :gain => 0.2, :mix_by => 0.1, :pattern => [ 0, 2, 4, 7, 9, 11 ]
set :pattern => [ 0, 2, 4, 7, 9, 11 ]
setup_ck do
%{
SinOsc s => JCRev r... | true |
e6285530bdc9f6dce35b2c2a21276cc56ee94b3b | Ruby | rvaddadi/puzzles | /tower-of-hanoi/hanoi.rb | UTF-8 | 1,243 | 3.34375 | 3 | [] | no_license | require 'set'
class Node
attr_reader :situation, :moves
def initialize(situation, moves = [])
@situation = situation
@moves = moves
end
def ==(other)
situation == other.situation
end
end
def read_line
gets.strip.split(' ').map(&:to_i)
end
n, k = read_line
current_node = Node.new(read... | true |
ed46d48df5adf298c179f567469ea8d54a8e7d96 | Ruby | sloanm/ruby | /foreach.rb | UTF-8 | 511 | 3.25 | 3 | [] | no_license | #!/usr/bin/ruby
require 'fileutils'
#This array had to have the quotes around each letter or windows threw an error
array = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p']
# does not work without single quotes array = [ a, b, c, d, f, g, h, i, j, k , l, m, n, o,]
# FileUtils.mkdir... | true |
1755bbbda90555cedf9a1beaf104cf0e92cf64b6 | Ruby | mahesh-karipe/leetcode | /algorithms/235_lowest_common_ancestor_of_bst.rb | UTF-8 | 1,053 | 3.671875 | 4 | [] | no_license | # https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-search-tree/
# Definition for a binary tree node.
# class TreeNode
# attr_accessor :val, :left, :right
# def initialize(val)
# @val = val
# @left, @right = nil, nil
# end
# end
# @param {TreeNode} root
# @param {TreeNode} p
... | true |
9621d0cc40f23fb7e91090d86c21ad0db352522b | Ruby | jfarrell/whimsy-agenda | /views/utils.js.rb | UTF-8 | 935 | 2.84375 | 3 | [] | no_license | # A convenient place to stash server data
Server = {}
# Escape HTML characters so that raw text can be safely inserted as HTML
def htmlEscape(string)
return string.gsub('&', '&').gsub('>', '>').gsub('<', '<')
end
# "AJAX" style post request to the server, with a callback
def post(target, data, &block)
x... | true |
36af4be59965f9ccd28aee99e90418c73a1dcc1c | Ruby | DmitriyMalayev/badges-and-schedules-onl01-seng-pt-052620 | /conference_badges.rb | UTF-8 | 594 | 3.65625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require "pry"
def badge_maker(name)
return "Hello, my name is #{name}."
end
def batch_badge_creator(names)
names.map do |name|
"Hello, my name is #{name}."
end
end
def assign_rooms(speakers)
counter = 1
speakers.each_with_index.map do |speaker, index|
"Hello, #{speaker}! Yo... | true |
d67ddbd3c8b63eb51d90a96bc8dc9afb617fe2d2 | Ruby | anggadarkprince/learn-ruby | /src/exercises/list.rb | UTF-8 | 181 | 3.140625 | 3 | [] | no_license | begin
print("Name of file? ")
name = gets
myFile = File.open(name.chomp)
lines = myFile.read
puts lines
rescue
print("File not found. Enter another name. ")
retry
end
| true |
b9a1ecfe77f1df924d7b3486dc9e57f7c05ece61 | Ruby | jasimper/Yardage-Credit | /app/models/yarn.rb | UTF-8 | 766 | 2.71875 | 3 | [] | no_license | class Yarn < ActiveRecord::Base
belongs_to :user
before_save :update_yardage_credit
protected
def update_yardage_credit
if num_of_plies > 1
self.yardage_credit = plied_yardage + (plied_yardage * num_of_plies)
else
self.yardage_credit = plied_yardage
end
end
validates :num_of_pli... | true |
72d5ba2b71a462b7bc2e643091feb9a799bd68e5 | Ruby | andreademoja/basic_git | /Deaf_grandmother.rb | UTF-8 | 244 | 2.984375 | 3 | [] | no_license | puts "HELLO SON, HOW ARE YOU?"
answer = gets.chomp
while answer != answer.upcase
puts "DA FUCK DID YOU SAY? RAISE YOUR VOICE SON!"
answer = gets.chomp
end
if answer == answer.upcase
puts ("HELL NO, NOT SINCE " +rand(1930..1950).to_s)
end
| true |
481017d0c4efef8c7898299ab44f671d255043d6 | Ruby | kyjoya/kickball | /models/player.rb | UTF-8 | 320 | 2.796875 | 3 | [] | no_license | require_relative "./team_data"
class Player
attr_reader :team_name, :player, :position, :players
@@instances = []
def initialize(team_name, player, position)
@@instances << self
@team_name = team_name
@player = player
@position = position
end
def self.all
return @@instances
end
end
| true |
8909700f7e895a7557b03810831894a8290e46c7 | Ruby | Hadeweka/Inuhh-Shinvasion | /lib/Enemies/Gasshi.rb | UTF-8 | 677 | 2.515625 | 3 | [
"MIT"
] | permissive | class Gasshi < Enemy # Fast and strong and can jump over some holes
def activation
@strength = 2
@score = 5000
@speed = 5
@range = 300
@world = 2
@hunting = true
@border_turn = false
@abyss_turn = false
@border_jump_delay = 1
@abys... | true |
ab0c9eca2421fdb641060cb97e0e2d5b788b67d7 | Ruby | machamp0714/chery_book | /row_col_sum/lib/excel.rb | UTF-8 | 945 | 3.75 | 4 | [] | no_license | class Excel
INPUT = [
[9, 85, 92, 20],
[68, 25, 80, 55],
[43, 96, 71, 73],
[43, 19, 20, 87],
[95, 66, 73, 62]
]
def self.output
new.output
end
def output
input = INPUT.dup
row_sum_array = input.map { |row|
row.inject(0) { |sum, num| sum += num }
}
col_sum_array... | true |
0d9a9cb192470fe2097660dcdb9f6f06daaac408 | Ruby | marti700/SPOJ | /The.Last.Digit/the.last.digit.rb | UTF-8 | 158 | 2.875 | 3 | [] | no_license | test_cases = gets.chomp
test_cases.to_i.times do
input = gets.chomp.split
base = input[0].to_i
index = input[1].to_i
puts (base**index) % 10
end
| true |
fb7909a0756b4f2e2435e20b6e683a8c767109c0 | Ruby | kozak/vim-i18n | /plugin/add_store_key | UTF-8 | 2,354 | 3.15625 | 3 | [] | no_license | #!/usr/bin/env ruby
# vim: ft=ruby:
require "yaml"
require 'json'
class Hash
def sort_by_key(recursive=false, &block)
self.keys.sort(&block).reduce({}) do |seed, key|
seed[key] = self[key]
if recursive && seed[key].is_a?(Hash)
seed[key] = seed[key].sort_by_key(true, &block)
end
s... | true |
7fa6b889221576fc6a9f33fd92f3b4ade57dd9d2 | Ruby | feernandobraga/super_finder_on_rails | /app/controllers/documents_controller.rb | UTF-8 | 2,715 | 2.78125 | 3 | [] | no_license | class DocumentsController < ApplicationController
def home
end
# this method is called by fetch when no record was found on the database
# and therefore needs to be searched on the HDD
def result(term, path)
# a hash that will store all found documents where they key is the filename
# and the value... | true |
6f82c3c234b90273a3c62c4f788c9d99970b650f | Ruby | marrrgarita/ruby-fundamentals-2 | /exercise11.rb | UTF-8 | 655 | 3.78125 | 4 | [] | no_license | my_dogs = [
{ :name => 'Ralph', :position => 5 },
{ :name => 'Cindy', :position => 12 },
{ :name => 'Jade', :position => 11 },
]
def get_absent_dog(my_dogs)
absent_dogs = []
my_dogs.each do |dog|
if dog[:position] > 10
absent_dogs << dog[:name]
end
end
return absent_dogs
end
puts get_abs... | true |
5da44a0042f4a4e3a644eda55d887d062ab48038 | Ruby | AIESEC-no-Brasil/databazi | /app/validators/youth_validator.rb | UTF-8 | 294 | 2.703125 | 3 | [] | no_license | class YouthValidator < ActiveModel::Validator
def validate(record)
return if record.icx?
return if record.birthdate && record.birthdate <= 18.years.ago &&
record.birthdate >= 30.years.ago
record.errors[:birthdate] << 'Necessário ter entre 18 e 30 anos.'
end
end
| true |
86c8eabe0c23f9da8d90edfffbe2773b65a84d5c | Ruby | KalMegati/countdown-to-midnight-online-web-pt-090919 | /countdown.rb | UTF-8 | 305 | 3.640625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | #write your code here
def countdown(tMinus)
while tMinus > 0
puts "#{tMinus} SECOND(S)!"
tMinus -= 1
end
"HAPPY NEW YEAR!"
end
def countdown_with_sleep(tMinus)
while tMinus > 0
puts "#{tMinus} SECOND(S)!"
sleep(1)
tMinus -= 1
end
"HAPPY NEW YEAR!"
end | true |
4f7a39e64cdce628f7baa6cf1b7835207794f5f6 | Ruby | JumpstartLab/son_of_store_engine | /solutions/wengzilla/app/lib/cart_storage.rb | UTF-8 | 659 | 3.046875 | 3 | [] | no_license | # extact cart storage
class CartStorage
attr_reader :session
def initialize(session)
@session = session
end
def [](store_id)
carts = get_hash_from_session
carts[store_id]
end
def keys
get_hash_from_session.keys
end
def values
get_hash_from_session.values
end
def []=(store_id... | true |
2beecc222cd6d8fcd65738eb697e69bd74713e3f | Ruby | meurett/academic | /cs465/hw4/sim2.rb | UTF-8 | 2,660 | 2.875 | 3 | [] | no_license | #!/usr/bin/ruby
# Example:
#
# Simulation do |with|
# with.policies LRU, Random
# with.associativity 1, 2, 4, 8, 16
# measure Miss
# end
#
class Simulator
Options = {
:cache_size => '-l1-usize',
:block_size => '-l1-ubsize',
:associative => '-l1-dassoc',
:policy => '-l1-dre... | true |
2a2ffe871c169f538336f8d107d93f125158b45d | Ruby | vwhwang/slack-cli | /lib/channel.rb | UTF-8 | 667 | 2.765625 | 3 | [] | no_license | require_relative 'recipient'
module SlackCli
class Channel < Recipient
attr_reader :member_count, :topic
def initialize(slack_id:,name:,member_count:,topic:)
super(slack_id,name)
@member_count = member_count
@topic = topic
end
def self.list_all
data = self.get("#{BASE_U... | true |
dc764f2c39e4b6bac5b90dd2b389e9931798a799 | Ruby | RobertoGaitan/kwk-l1-ruby-class-variables-and-class-methods-lab-teachers-l1 | /lib/song.rb | UTF-8 | 962 | 3.671875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | #Song.new("Lucifer", "Jay-Z", "rap" )
#Song.new("99 Problems", "Jay-Z", "rap")
#Song.new("hit me baby one more time", "Brittany Spears", "pop")
class Song
@@count = 0
@@genres = []
@@artists = []
def initialize(name, artist, genre)
@name = name
@artist = artist
@genre = genre
@@count += 1
@@genres << gen... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.