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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
2956887262e14618a0dc97283ea3e0bfec29d3e6 | Ruby | ok-skalko/ma-ruby | /lesson_1/home_work_1.rb | UTF-8 | 1,883 | 3.375 | 3 | [] | no_license | require 'tzinfo'
class HomeWork
COLORS = { red: 31, green: 32, yellow: 33, blue: 34, pink: 35 }.freeze
class << self
def timezone(zone_name)
tzinfo = TZInfo::Timezone.get(zone_name)
period = tzinfo.current_period
utc_offset = period.offset.utc_total_offset
puts Time.now.getlocal(utc_o... | true |
96cb970554151a3a50fe69934cf2147cdab8de3e | Ruby | rubynetix/sparse-matrix | /lib/tridiagonal_iterator.rb | UTF-8 | 697 | 3.65625 | 4 | [
"MIT"
] | permissive | class TriDiagonalIterator
def initialize(low_diag, main_diag, up_diag)
@diags = [main_diag, up_diag, low_diag]
@idx = 0
end
def has_next?
@idx < (@diags[0].length + @diags[1].length + @diags[2].length)
end
def next
diag, offset = @idx % 3, @idx / 3
val = @diags[diag][offset]
row = of... | true |
668588ef116b8d32ff5545b044c3096763551c93 | Ruby | sakihet/git_log_to_json | /lib/git_log_to_json.rb | UTF-8 | 1,511 | 2.828125 | 3 | [
"MIT"
] | permissive | require "git_log_to_json/version"
require 'json'
require 'optparse'
module GitLogToJson
option = {}
OptionParser.new do |opt|
opt.on('--version', 'show version') { |v| option[:version] = v }
opt.on('-n', '--number [NUM]', Integer, '') { |v| option[:number] = v }
# TODO
# opt.on('--hash') { |v| opti... | true |
0b7fcd7532197aa6332b3ae75a017bfda8906013 | Ruby | alxjrvs/pathfounder-api | /app/models/deity.rb | UTF-8 | 1,148 | 3.015625 | 3 | [] | no_license | class Deity
DEITIES = YAML.load_file('./deities.yaml')
attr_accessor :name, :alignment, :domains, :subdomains, :favored_weapon
def initialize(name)
god = DEITIES.select { |d| d['name'] == name }.first
@name = god["name"]
@alignment = god["alignment"].to_sym
@domains = god["domains"]
@subdomai... | true |
bf4cee7e0c73bcc1ef82327b710832a873bf6e03 | Ruby | Mandeepahlawat/todo | /app/models/facebook_todo.rb | UTF-8 | 647 | 3.015625 | 3 | [] | no_license | class FacebookTodo
attr_reader :graph, :status_message
def initialize(token)
@graph = Koala::Facebook::API.new(token)
end
def get_status
begin
@statuses = @graph.get_connections("me","statuses")
@status_message = @statuses.first["message"]
return values(true,@status_message)
rescue Farad... | true |
ad4d789f99a7a8d65ab96c5e0d7f4cca717a64a7 | Ruby | MilanNosal/ruby-test-dsl | /TestDSL/open_question.rb | UTF-8 | 2,230 | 3 | 3 | [] | no_license | require_relative './question'
class OpenQuestion < Question
NAME = 'open-answer-question'
attr_accessor :caseSensitive
def initialize(text, points, caseSensitive = false)
super(text, points)
@caseSensitive = caseSensitive
end
def to_js(id)
"testFreeAnswer('##{id}')"
end
def to_html(id)
... | true |
98e204c31d6ba155f12845156a512887df8cee6e | Ruby | kbehnfeldt/ruby_intro_book_exercises | /hashes/hash_exercises/exercise2.rb | UTF-8 | 383 | 3.421875 | 3 | [] | no_license | pets = {
dog: "Jet",
cat: "Stella",
parrot: "Sam"
}
family = {
dad: "Terry",
mom: "Cathy",
brother: "Dan"
}
puts "family.merge(pets) result: #{family.merge(pets)}"
puts "original family hash: #{family}"
puts "original pets hash: #{pets}"
puts "family.merge!(pets) result: #{family.merge!(pets)}"
puts "orig... | true |
4224a8356ea8dde6e6483b6bd902ff61c644d213 | Ruby | bahtiyarb-ef/bm2-core | /fuzzer.rb | UTF-8 | 15,726 | 2.921875 | 3 | [
"MIT"
] | permissive | # Author: Ben Nagy
# Copyright: Copyright (c) Ben Nagy, 2006-2010.
# License: The MIT License
# (See README.TXT or http://www.opensource.org/licenses/mit-license.php for details.)
require File.dirname(__FILE__) + '/binstruct.rb'
require File.dirname(__FILE__) + '/generators.rb'
require File.dirname(__FILE__) + ... | true |
9196a3a0d19ef95de13b63579b8cd93962ccab5f | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/clock/1b6a9ccdcdf94e6b8cb86d9fbd63ff13.rb | UTF-8 | 503 | 3.5 | 4 | [] | no_license | class Clock
attr_reader :hh, :mm
def initialize(hh, mm)
@hh = hh
@mm = mm
end
def self.at(hh, mm=0)
Clock.new(hh, mm)
end
def to_s
sprintf("%02d:%02d", hh, mm)
end
def + (minutes)
new_time(minutes)
end
def - (minutes)
new_time(-minutes)
end
def == (other)
@hh =... | true |
bd2ab7dea4fdeab3a6d3d0449b63d3f57ba2134a | Ruby | GSA/search-gov | /spec/config/initializers/dynamic_errors_spec.rb | UTF-8 | 742 | 2.609375 | 3 | [] | no_license | # frozen_string_literal: true
class TestModel
include ActiveModel::Model
attr_accessor :foo, :bar, :baz_quux
end
describe 'ActiveModel::Errors' do
let(:test_model) { TestModel.new }
describe '#full_messages' do
subject(:full_messages) { test_model.errors.full_messages }
context 'when the instance i... | true |
020b990db9b88028ea9cf1c4b877ab4da8ac7bac | Ruby | TimCPB/Advent-Of-Code | /lib/day3.rb | UTF-8 | 685 | 3.046875 | 3 | [] | no_license | class Ski_resort
attr_reader :tree_count_array
def initialize(input)
@input = input
@row_length = input[0].length
@tree_count_array = []
end
def count_trees(right = 3, down = 1)
tree_count = 0
lateral_coord = 0
row_count = 0
while row_count < @input.length do
if @input[row_... | true |
68ca9779222f1857d8f04e42aea72716b0e0375e | Ruby | Batou99/espn_backend | /models/models.rb | UTF-8 | 3,189 | 2.65625 | 3 | [] | no_license | require 'active_resource'
require "net/http"
env = ENV['RACK_ENV'] || 'development'
config = YAML::load( File.open( 'config/connection.yml' ) )[env]
API_KEY = config["api_key"]
ESPN_SERVER = config["espn_server"]
API_VERSION = config["api_version"]
class Leagues < Array
def self.from_json(data)
leagues = League... | true |
4bcbc1de2633892997ed50ad4b1b191543930f17 | Ruby | heatherkylee/mini_capstone | /app/controllers/api/products_controller.rb | UTF-8 | 2,506 | 2.515625 | 3 | [] | no_license | class Api::ProductsController < ApplicationController
# before_action :authenticate_admin, except: [:index, :show]
#will show a specific product
def show
product_id = params[:id]
@product1 = Product.find_by(id: product_id)
render "show.json.jbuilder"
end
# will show all products
def index
#... | true |
db186a480ba9397f66c7c1d73a7bd84ac4078a35 | Ruby | dfenjves/random_order_generator | /bin/sinatra_runner.rb | UTF-8 | 1,674 | 3.421875 | 3 | [] | no_license | require_relative '../config/environment'
class Random_Order_Generator
attr_reader :address, :quantity, :max_price, :restaurants, :restaurant_id, :restaurant_name, :restaurant_url, :menu
def initialize(address, quantity, max_price=100)
self.address = address
self.quantity = quantity
self.max_price = max_price
... | true |
5e6a17da31c7a6333145fd723e31dc6854b05c69 | Ruby | snmgian/ruy | /lib/ruy/conditions/except.rb | UTF-8 | 347 | 2.609375 | 3 | [
"MIT"
] | permissive | module Ruy
module Conditions
# Expects that the sub-condition is not satisfied.
class Except < CompoundCondition
# @yield a block in the context of the current rule
def initialize(&block)
super
instance_exec(&block) if block_given?
end
def call(ctx)
!super
... | true |
70b26abf60ada4202024efb749b094ee8ef4bca4 | Ruby | jacobwgillespie/archive | /the-movie-scoop/app/lib/composite_score_loader.rb | UTF-8 | 320 | 2.53125 | 3 | [] | no_license | class CompositeScoreLoader
def self.load(id)
new(id).load
end
def self.enqueue(id)
CompositeScoreLoadWorker.perform_async(id)
end
attr_reader :movie
def initialize(id)
@movie = Movie.find(id)
end
def load
movie.composite_score = CompositeScore.compute(movie)
movie.save
end
end
| true |
fdf07e23a83eb2d5f7c85d29835dcd5ea79b02dc | Ruby | icorson3/bt | /test/customer_repo_test.rb | UTF-8 | 2,023 | 2.546875 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/pride'
require './lib/customer_repo'
require './lib/sales_engine'
require 'pry'
class CustomerRepoTest < Minitest::Test
attr_reader :c, :se
def setup
@se = SalesEngine.from_csv({
:items => "./data/items.csv",
:merchants => "./data/merchants.csv",
:... | true |
9d7aa94e4534e6e4c95a8b831e003cc7b21a667e | Ruby | rasmusra/FiRe | /test/full/utils.rb | UTF-8 | 2,289 | 2.609375 | 3 | [] | no_license | require 'fileutils'
require 'yaml'
class Utils
def Utils.runFiRe(cfg)
# just put the tmp configfile somewhere
configfile = "test/data/tmp.yml"
# create the configfile
f = File.open(configfile, "w")
f.print(cfg.to_yaml)
f.close
# add args if not done before
if !$*.inclu... | true |
861250ae3ac4ab83dfff4b8fcb2ae80fec96d1b4 | Ruby | franzejr/graph-algorithms | /ruby/main.rb | UTF-8 | 450 | 3.078125 | 3 | [] | no_license | #Some Graph Examples methods
require_relative 'graph'
require_relative 'faker_vertex'
require_relative 'read_file'
puts "Testing Class Graph"
g = Graph.new
g.add_vertex 4
g.add_vertex 5
g.add_vertex 77
puts g.vertexes
puts "Testing Class Vertex"
#hash = {:description=>"" }
#v = Vertex.build
... | true |
76c3aec6936b7cf423fae73f2b53649419cc3385 | Ruby | IMP1/raven | /ruby_interpreter/parser.rb | UTF-8 | 23,682 | 3 | 3 | [] | no_license | require_relative 'log'
require_relative 'expression'
require_relative 'statement'
require_relative 'compiler'
require_relative 'fault'
require_relative 'types'
class Parser
def initialize(tokens)
@log = Log.new("Parser")
@tokens = tokens
@current = 0
@type_hint = nil
@allow... | true |
9db038084e623bfe3ae1df622ddceb613c9f3a9b | Ruby | DawidJanczak/CodeJam | /codejam2012/elimination/b/googlers.rb | UTF-8 | 790 | 3.3125 | 3 | [] | no_license | #!/usr/bin/ruby
class GooglerCommitee
def initialize(n, s, p, *total_points)
@n, @s, @p = n, s, p
@total_points = total_points
end
def get_max_result
return @total_points.size if @p == 0
return @total_points.count { |tp| tp > 0 } if @p == 1
@result = 0
@total_points.each do |tp|
i... | true |
9289683193eee9638e4b68f4e1b8bcce49958074 | Ruby | LeraNickolaeva/price_calculator | /lib/receipt/printer.rb | UTF-8 | 550 | 3.4375 | 3 | [] | no_license | module Receipt
class Printer
OUTPUT_TEXT = 'Please enter all the items purchased separated by a comma'
EMPTY_INPUT_TEXT = 'There are no any purchased items'
class << self
def call
purchased_items.any? ? print_receipt : (puts EMPTY_INPUT_TEXT)
end
def purchased_items
@pu... | true |
d688eb14c077fd317655675f4b8b456032fa7481 | Ruby | kogulko/hackerrank | /Implementation/encryption.rb | UTF-8 | 390 | 3.53125 | 4 | [] | no_license | #!/bin/ruby
#solution for https://www.hackerrank.com/challenges/encryption/problem
def encryption(s)
rows = Math.sqrt(s.size).floor
columns = Math.sqrt(s.size).ceil
rows = columns if rows * columns < s.size
columns.times.map do |i|
rows.times.map do |j|
s[i + columns * j]
end.join
end.join(' ')... | true |
e49252a9bb55609632ad663c0f28f33ea096c392 | Ruby | Kseniya82/ruby | /lesson_2/task5.rb | UTF-8 | 639 | 3.09375 | 3 | [] | no_license | day_in_month_arr= [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
puts "Введите число интересующей даты: "
date_day = gets.to_i
puts "Введите месяц интересующей даты: "
date_month = gets.to_i
puts "Введите год интересующей даты: "
date_year = gets.to_i
leap_year = date_year % 4 == 0 && date_year % 100 != 0 || date_yea... | true |
b20bc78c87b3761240cda182ccf73224b9f8360b | Ruby | kvyinn/ucbpblmembersportal | /app/models/commitment.rb | UTF-8 | 720 | 2.5625 | 3 | [] | no_license | # == Schema Information
#
# Table name: commitments
#
# id :integer not null, primary key
# member_id :integer
# summary :string(255)
# start_time :datetime
# end_time :datetime
# created_at :datetime not null
# updated_at :datetime not null
#
# == Description
#
# A segmen... | true |
c971ebd0ec3a0a58127449c9cf5e33d6ef748f93 | Ruby | GriwMF/spacesim | /app/models/factory.rb | UTF-8 | 1,792 | 2.640625 | 3 | [] | no_license | class Factory < ApplicationRecord
include HasGoods
include HasPositionVector
has_many :productions
# has_many :characters, as: :base
def step
# characters.generate_character(self) if Random.rand(100).zero?
transaction do
take_materials_or_rollback
self.progress += speed
History.cr... | true |
8b3649af524e43cf0648809a670f322e4eb13dde | Ruby | karthick-soolapani/code-problems | /code-challenges/01-easy1/01_easy1_q10_roman_numerals.rb | UTF-8 | 1,124 | 3.4375 | 3 | [] | no_license | $stdout.sync = true # To display output immediately on windows using git bash
class Integer
def to_roman
roman_matrix = {'M' => 1000, 'CM' => 900, 'D' => 500, 'CD' => 400,
'C' => 100, 'XC' => 90, 'L' => 50, 'XL' => 40, 'X' => 10,
'IX' => 9, 'V' => 5, 'IV' => 4, 'I' => 1}
num = self.abs
roma... | true |
24bdbeaeb4a8b7444e3ab7bcf34b954401cc907f | Ruby | Bazing4/tictactoe | /lib/tic_tac_toe.rb | UTF-8 | 513 | 3.875 | 4 | [
"MIT"
] | permissive | require "tic_tac_toe/version"
module TicTacToe
require_relative 'Board.rb'
puts "Starting tic-tac-toe..."
players = ['X','O']
current_player = players[rand(2)]
b = Board.new(current_player)
b.display()
puts
while not b.board_full() and not b.winner()
b.ask_player_for_move(current_player)
cu... | true |
288d26d7d062ee90c395a56337917a4732f98cc6 | Ruby | kmdsbng/webio | /spec/app/webio_spec.rb | UTF-8 | 1,822 | 2.796875 | 3 | [
"MIT"
] | permissive | # -*- encoding: utf-8 -*-
require 'spec_helper'
require 'webio'
describe WebIO do
def send_url(command)
`curl http://localhost:53333/#{command}`
end
def responce_for(command)
send_url(command)
@responce
end
def start_webio_thread(option=nil)
@responce = nil
@webio_thread = Thread.new do... | true |
cc53c27f3534926cebf6ef2f4fb3cabf7e8121f4 | Ruby | jastix/challenges | /CodeEval/Easy/17_Happy_numbers/happy_numbers.rb | UTF-8 | 464 | 4 | 4 | [] | no_license | UNHAPPY_NUMBERS = [0, 4, 16, 20, 37, 42, 58, 89, 145]
def check_happy(num)
return 1 if num == 1
return 0 if UNHAPPY_NUMBERS.include?(num)
end
def compute_happy(num)
results = [num]
until results.last == 1 or UNHAPPY_NUMBERS.include?(results.last)
results << results.last.to_s.split('').map { |n| n.to_i }.m... | true |
4418f1c6829eea2ee12277e87cf292d0ff40432e | Ruby | Jhon112/ruby-snake-game | /tests/test_actions.rb | UTF-8 | 1,754 | 2.828125 | 3 | [] | no_license | require 'minitest/autorun'
require_relative "../src/controller/actions"
require_relative "../src/models/state"
class ActionsTest < Minitest::Test
def setup
@initial_state = Models::State.new(
Models::Snake.new([
Models::Coord.new(1,1),
Models::Coord.new(0,1... | true |
415d3f64dde6fd1698a410aa27c66584c5e28f2a | Ruby | JeffLAtPay/LearningStuff | /TDD/1/spec/monad_spec.rb | UTF-8 | 669 | 2.8125 | 3 | [] | no_license | require_relative '../monad.rb'
require 'spec_helper'
describe Monad do
before :each do
@f1 = lambda {|x| x+1 }
@f2 = lambda {|x| x+10 }
@monad = Monad.new 0
end
describe "#new" do
it "should throw an argument error if not passed a argument." do
lambda { monad = Monad.new }.sho... | true |
51ba88e1f2c9c7f90e589a232573d806a49732ec | Ruby | rbotafogo/galaaz | /lib/R_interface/r.rb | UTF-8 | 4,993 | 2.71875 | 3 | [
"BSD-2-Clause"
] | permissive | # -*- coding: utf-8 -*-
##########################################################################################
# @author Rodrigo Botafogo
#
# Copyright © 2018 Rodrigo Botafogo. All Rights Reserved. Permission to use, copy, modify,
# and distribute this software and its documentation, without fee and without a sig... | true |
00287403eedbbe119650acd319a18a493914600b | Ruby | austbuhl/ruby-oo-relationships-practice-blood-oath-exercise-nyc01-seng-ft-082420 | /app/models/follower.rb | UTF-8 | 925 | 2.9375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive |
class Follower
attr_accessor :name, :age, :life_motto
@@all = []
def initialize(name, age, life_motto)
@name = name
@age = age
@life_motto = life_motto
@@all << self
end
def self.all
@@all
end
def self.most_active
self.all.max_by { |cults|... | true |
9a2bccdfd421bbd3af76e58e061752a07c680f85 | Ruby | apohllo/rod-rest | /test/spec/property_metadata.rb | UTF-8 | 2,385 | 2.515625 | 3 | [
"MIT"
] | permissive | require 'bundler/setup'
require_relative 'test_helper'
require 'rod/rest/property_metadata'
module Rod
module Rest
describe PropertyMetadata do
let(:property_metadata) { PropertyMetadata.new(name,options) }
let(:name) { :age }
let(:options) { { type: :integer } }
d... | true |
5a7edb117e3fdb0b0bdaa8dcc911d222fbff2157 | Ruby | rdprado/cleanRuby | /Entities/appointment.rb | UTF-8 | 195 | 3.078125 | 3 | [] | no_license | class Appointment
attr_accessor :date, :title
def initialize(date, title)
@date = date
@title = title
end
def fullfill()
@fullfilled = true
end
end
| true |
fb6e682372c83a7f8f9d37bdbee1906f557bb115 | Ruby | TheWalkingLeek/skills | /spec/models/company_spec.rb | UTF-8 | 2,903 | 2.609375 | 3 | [] | no_license | # == Schema Information
#
# Table name: companies
#
# id :integer not null, primary key
# name :string
# web :string
# email :string
# phone :string
# partnermanager :string
# contact_person :string
# em... | true |
1b4e427ae927623a3bd193f8c752e859b0179887 | Ruby | ga-wolf/WDi14-Homework | /FabioCamatti/week_07/warm-ups/10-JUN-2016/fib.rb | UTF-8 | 172 | 3.46875 | 3 | [] | no_license | def fibonacci(n)
n <= 1 ? n : fibonacci( n - 1 ) + fibonacci( n - 2 )
n.times do |n|
result = fibonacci(n)
puts result
end
end
puts fibonacci( 10 )
| true |
e623940ba084e36114e153d3b0854d83098886b7 | Ruby | MarsiliFrancoDavid/robot-world | /spec/models/stock_spec.rb | UTF-8 | 3,631 | 2.640625 | 3 | [] | no_license | require "rails_helper"
RSpec.describe Stock do
components = JSON.parse(ENV["CAR_COMPONENTS"] || '{"wheel":4,"chassis":1,"laser":1,"computer":1,"engine":1,"seat":2}')
it "should be created when its attributes are passed in properly" do
stock = Stock.create(name: "Factory Stock", type: "Stock")
... | true |
020810b08813bcd433a93a559d8aee0aa927b3a6 | Ruby | kejadlen/hivary | /lib/hive/insect/spider.rb | UTF-8 | 1,152 | 2.75 | 3 | [] | no_license | require_relative 'base'
module Hive
module Insect
class Spider < Base
def valid_moves
moves = super
return moves if moves.empty?
# Remove the spider and don't replace it with an empty space (so
# it doesn't affect the movement calculation)
self.board.source.delete(s... | true |
8e1d30967a0bf5880e296af7f8b6c3dea261c474 | Ruby | JAdshead/populate-me | /test/document_test.rb | UTF-8 | 35,759 | 2.890625 | 3 | [
"MIT"
] | permissive | require 'bacon'
$:.unshift File.expand_path('../../lib', __FILE__)
require 'populate_me/document'
describe 'PopulateMe::Document' do
# PopulateMe::Document is the base for any document
# the Backend is supposed to deal with.
#
# Any module for a specific ORM or ODM should include
# this module first.
# It... | true |
cfaed51bb9deef39ba8010664fcda542a4b4d230 | Ruby | minyoungryoo/Ironhack | /Week1/Day5/Chess/lib/chess.rb | UTF-8 | 574 | 3.359375 | 3 | [] | no_license | class Chess
def initialize(board)
@board = board
end
def gui
puts ""
puts ""
puts "Type anything to get started. Type exit to quit"
input = gets.chomp
cont = ""
while input.downcase != "exit" && cont != "N"
puts ""
puts "Which piece are you moving?"
input = gets.chomp
piece = @board.names[in... | true |
6b63a38a4acc69b8d2c12ae9da3319b56c55fc3a | Ruby | plerohellec/logfile_interval | /lib/logfile_interval/interval_builder.rb | UTF-8 | 2,584 | 2.765625 | 3 | [
"MIT"
] | permissive | require File.join(File.expand_path('..', __FILE__), '/interval_builder/ascending')
require File.join(File.expand_path('..', __FILE__), '/interval_builder/descending')
module LogfileInterval
class IntervalBuilder
attr_reader :parsed_lines_enum, :parser_columns, :length
def initialize(parsed_lines_enum, parse... | true |
c222b5d4031897ac78607c75dd450fd94feb73d0 | Ruby | raeno/hackerrank_ruby | /solutions/algorithms/strings/camel_case.rb | UTF-8 | 160 | 2.875 | 3 | [] | no_license | module Algorithms
module Strings
class CamelCase
def words_count(str)
1 + str.chars.count { |c| c == c.upcase }
end
end
end
end
| true |
22f9af32f542d5a11814f2257d5e28c6738e0b6f | Ruby | MichaelCSlevin/pet_shop_homework | /pet_shop.rb | UTF-8 | 3,173 | 3.890625 | 4 | [] | no_license | # Lookup key name in pet_shop
# Return value
#1
def pet_shop_name(pet_shop)
return pet_shop[:name]
end
# lookup key admin in pet_shop
# lookup key total_cash in that!
# perfect!
# Nested.
#2
def total_cash(pet_shop)
return pet_shop[:admin][:total_cash]
end
#3 & 4
def add_or_remove_cash(pet_shop, cheddar)
retur... | true |
61d62f6bca58d70b2b6313e5c5597cd3984c033f | Ruby | doozr/Pudl | /pudl.rb | UTF-8 | 486 | 2.625 | 3 | [
"MIT"
] | permissive | require 'logger'
require_relative './lib/pudl'
logger = Logger.new STDOUT
logger.level = Logger::INFO
Pudl.logger = logger
c = {
pirate: "YARR",
ninja: "..."
}
Pudl.add_method :config do |key|
c[key] || "NO"
end
Pudl.add_method :params do
ARGV
end
# Simple sample pipeline of madness
pipeline = Pudl.parse "... | true |
b5ec66b6daaf81c7fe40c26547139ad9d8168824 | Ruby | kapy2010/Mars-Problem | /run_rover.rb | UTF-8 | 665 | 3.796875 | 4 | [] | no_license | require_relative "rovers.rb"
puts "Enter the number of rovers"
number_of_rovers = gets.chomp.to_i
while number_of_rovers > 0
puts "Enter the dimensions of plateau"
plat_coordinates = gets.chomp.split(" ")
# plat_coordinates = plat_coordinates.split(" ")
plateau = Plateau.new(plat_coordinates[0].to_i, plat_coo... | true |
754c1a7317cee482e33e65b6193f6d945f14c924 | Ruby | polossk/Renai-SLG-Solution | /Ruby-in-FP-Style/problem1-3.rb | UTF-8 | 309 | 3.265625 | 3 | [] | no_license | #!/usr/bin/ruby
# 自分の得意な言語で
# Let's チャレンジ!!
n = gets
na = gets
own = gets.split(' ').map(&:to_i)
nb = gets
need = gets.split(' ').map(&:to_i)
buy = need.select { |e| !own.include?(e) }.sort
if buy.length == 0 then
buy_s = "None"
else
buy_s = buy.join(' ')
end
puts buy_s | true |
4c2c2154f8dd8f96c644ef1a23a3d24086485dd0 | Ruby | nyaago/cms | /app/models/layout/static_methods.rb | UTF-8 | 3,010 | 2.609375 | 3 | [] | no_license | module Layout
# = Conig::Layout::StaticMethods
# レイアウト Config関連の static method を定義
module StaticMethods
# 設定yamlファイルを読み込み,
# config_path属性がディレクトリーならそのディレクトリー内のymlファイルを全て,
# 通常ファイルであればそのファイルを読み込む.
# 結果として,modelのarrayを生成する.
def load
models = []
# file一覧を取得
files = ... | true |
6f4e6df7ebf81d5345f6442cb8ecb396df230eb4 | Ruby | acidhelm/kq_scene_scoring_server | /test/models/tournament_test.rb | UTF-8 | 710 | 2.609375 | 3 | [
"MIT"
] | permissive | require "test_helper"
class TournamentTest < ActiveSupport::TestCase
def setup
@tournament = tournaments(:tournament_1)
end
test "Try to save a tournament with an illegal title" do
@tournament.title = ""
assert_not @tournament.save
end
test "Try to save a tournament with a... | true |
310b153b8f014f3681c8ca8825c943984055f131 | Ruby | luong-komorebi/Ruby-Sorting-Algorithm | /SortingAlgo/insertion_sort.rb | UTF-8 | 318 | 3.53125 | 4 | [] | no_license | module SortingAlgo
class InsertionSort
def self.sort(arr)
n = arr.length
(n).times do |i|
while i > 0
if arr[i-1] > arr[i]
arr[i-1], arr[i] = arr[i], arr[i-1]
else
break
end
i-=1
end
end
arr
end
end
end | true |
e02b50e5a8b743c3c9a7052e29857b84e22d140f | Ruby | innerspirit/hexpress | /lib/hexpress/character.rb | UTF-8 | 507 | 3.34375 | 3 | [
"MIT"
] | permissive | class Hexpress
class Character
attr_reader :upcase
def initialize(name, upcase = false)
@value = case name
when :word then '\w'
when :digit then '\d'
when :space then '\s'
when :any then '.'
when :tab then '\t'
when :newline then '\n'
when :return ... | true |
3076fffc491ed314fe9c4fc2e6ff2d3c69d4a705 | Ruby | k2lxn/flight-booker | /app/models/flight.rb | UTF-8 | 582 | 2.625 | 3 | [] | no_license | class Flight < ActiveRecord::Base
belongs_to :departs_from, class_name: "Airport"
belongs_to :arrives_at, class_name: "Airport"
def self.search(departs_from, arrives_at, date)
matches = Flight.where(departs_from_id: departs_from,
arrives_at_id: arrives_at,
date: date)
end
def s... | true |
189f9861a7820d285663e86809e564d1779f0fff | Ruby | JakeH91/headfirst | /ruby/ch07/candidates.rb | UTF-8 | 601 | 3.84375 | 4 | [] | no_license | class Candidate
attr_accessor :name, :age, :occupation, :hobby, :birthplace
def initialize(name, age:, occupation:, hobby: nil, birthplace: nil)
self.name = name
self.age = age
self.occupation = occupation
self.hobby = hobby
self.birthplace = birthplace
end
def print_summary
puts "Candidate: #{self.nam... | true |
12b118b1f4e7d633e68a4f783892c198ef640357 | Ruby | csaden/rbnd-toycity-part3 | /lib/customer.rb | UTF-8 | 721 | 3.28125 | 3 | [
"MIT"
] | permissive | require_relative "./errors"
require_relative "./transaction"
class Customer
attr_reader :name, :purchases
@@customers = []
def initialize(options={})
@name = options[:name]
@purchase_count = 0
@purchases = []
add_to_customers
end
def purchase(product)
Transaction.new(self, product)
... | true |
9f8b2ccdd03a1c61d4143123da35d0d48a9ad551 | Ruby | aimangual/amangual-Blocitoff | /db/seeds.rb | UTF-8 | 634 | 2.859375 | 3 | [] | no_license | require 'faker'
# Create Users
10.times do
user = User.new(
name: Faker::Name.name,
email: Faker::Internet.email,
password: Faker::Lorem.characters(10)
)
user.skip_confirmation!
user.save!
end
users = User.all
# Create Items
30.times do
Item.create!(
name: Fa... | true |
0e4e37b65bcb7911ce4230153d6f49dbe8f5cfbb | Ruby | bookmate/bm-cancellation | /examples/futures.rb | UTF-8 | 1,132 | 2.703125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'bundler/setup'
require 'bm/cancellation'
require 'concurrent'
def checked(cancellation, semaphore)
semaphore.acquire
return cancellation.reason if cancellation.cancelled?
yield
ensure
semaphore.release
end
def map(array, cancellation) # rubocop:disable Metrics/AbcSize,... | true |
71043eb33e1a1f750676b9500e66397407263842 | Ruby | tchryssos/week-1-group-review-web-0716 | /review-question-3.rb | UTF-8 | 1,014 | 3.796875 | 4 | [] | no_license | require 'pry'
# begin to build a simple program that models Instagram
# you should have a User class, a Photo class and a comment class
class User
attr_accessor :name, :photos
def initialize(name)
@name=name
@photos=[]
end
def add_photo(photo)
@photos<<photo
end
end
class Photo
attr_accessor ... | true |
2b18c1a7f7300e7153f5f30efc1eccfb5ba29b25 | Ruby | WATANAPEI/learning | /rails/chapter2/2-4-3b.rb | UTF-8 | 388 | 3.734375 | 4 | [] | no_license | class Robot
attr_reader :name
attr_accessor :score
def initialize(name)
@name = name
@x = @y = 0
@score = 10
end
def move(x, y)
@x += x
@y += y
end
def to_s
"#{@name}: #{@x}, #{@y}"
end
end
robo1 = Robot.new("ロボ一号")
robo2 = Robot.new("ロボ二号")
puts robo1
puts "score: #{robo2.sc... | true |
1961d91fad221bc3652881c08ab6bd66358d4d1d | Ruby | radlab/SCADS | /piql/src/main/ruby/avro_record.rb | UTF-8 | 4,618 | 2.609375 | 3 | [] | no_license | class Object
# Mainly to convert String to Utf8 without having to check if an Object is a String
# Can help if anything besides a String needs a similar process
def pickle
self
end
end
class String
def carmelize
base = self.camelize
base.slice(0,1).downcase + base.slice(1,base.size)
end
# Co... | true |
21a39b1220518a2ea327fe200ce8d86e7b78fb60 | Ruby | APTrust/exchange | /efsbug/update_fixed_files.rb | UTF-8 | 2,033 | 2.921875 | 3 | [
"Apache-2.0"
] | permissive | require 'json'
require 'sqlite3'
# CREATE TABLE fixed_files (
# id integer primary key autoincrement,
# identifier varchar(255),
# uuid varchar(36),
# batch_number int not null default 0,
# size bigint not null default 0,
# error_message text,
# restore_requested_at datetime,
# restore_... | true |
44cb1f4ff01076feb45dd43636f69c4904c3ef12 | Ruby | HannahCarney/Battleships | /lib/cell.rb | UTF-8 | 210 | 3.03125 | 3 | [] | no_license | class Cell
def initialize
@contents = :water
end
def contents
@contents
end
def place! ship
@contents = ship
end
def receive_hit
@contents == :water ? :miss : :hit
end
end | true |
e94f7adc906c47855598d538f4dcb36d9726756b | Ruby | Naveenkumar007/data_structures_and_algo | /DS/arrays/two_sum.rb | UTF-8 | 423 | 4.09375 | 4 | [] | no_license | #You are given an array and some number S. Determine if any two numbers within the array sum to S.
arr = [1,5,6,3,2,7,9]
def twosum(arr,sum)
hashTable = {}
arr.each_with_index do |value,index|
subs_value = sum - arr[index]
if hashTable.key?(subs_value)
puts "Num1:::#{arr[index]}@@@@@@@@@@Num2:::#{sub... | true |
d8772d0f26429fe4b95fbee35d105624511807e2 | Ruby | Charlotte-91/oystercard-1 | /spec/journey_spec.rb | UTF-8 | 571 | 2.59375 | 3 | [] | no_license | require 'journey'
describe Journey do
it 'creates an instance of Journey' do
expect(subject).to be_an_instance_of Journey
end
it 'initializes with an empty list of journeys' do
expect(subject.journey).to eq(nil)
end
it 'stores a journey' do
expect(subject.store_journey).to eq subject.jou... | true |
91f4a37e377fc754e61583da0ce19a01c4a429fe | Ruby | nashby/imstat | /lib/imstat/skype.rb | UTF-8 | 376 | 2.5625 | 3 | [] | no_license | require 'open-uri'
require "rexml/document"
module Imstat
class Skype
def self.get_status(user)
skype_xml_status = REXML::Document.new open("http://mystatus.skype.com/#{user}.xml").read
status = Hash.new
REXML::XPath.each(skype_xml_status, "//presence") do |el|
status[el.attributes["xml:lang"].to_... | true |
ee69e30ae0a7a1734a57344e1eb842633d010b59 | Ruby | medevuono/makeitreal_reto5 | /reto5.rb | UTF-8 | 280 | 3.109375 | 3 | [] | no_license | require './question.rb'
class Reto5
attr_reader :reto5
def initialize
@reto5 = []
end
def read_file(file)
File.foreach(file) do |line|
question, answer = line.chomp.split(';')
@reto5.push(Question.new(question, answer))
end
end
end
| true |
6627b1055a1e56e9f3a0eb4d0398a1b263890337 | Ruby | jcat1504/codewarsruby | /reversedwords.rb | UTF-8 | 273 | 3.21875 | 3 | [] | no_license | #Complete the solution so that it reverses all the words within the string
#passed in
def solution(sentence)
sentence.split.reverse.join(" ")
end
def solution(s)
s.split(" ").reverse.join(" ") end
def solution(sentence)
sentence.split(/\st).reverse.join(' '); end
| true |
2364552224063ad0a651719a9d70d045835cb1e9 | Ruby | dzyomaArtem/lesson1 | /lesson1.rb | UTF-8 | 663 | 3.859375 | 4 | [] | no_license | require 'date'
class Lesson1
def sum(val = 0)
sum = 0
val.to_s.split('').each { |num| sum += num.to_i }
sum
end
def age(birthday)
if birthday
days = (Date.parse(Time.now.to_s) - Date.parse(birthday)).to_i
years = days / 365
hours = days * 24
min = hours * 60
sec = mi... | true |
55060d7cb12a9a29305dbafbd1a0e358d16c02b8 | Ruby | lvafi/hook-lab | /spec/models/news_article_spec.rb | UTF-8 | 2,498 | 2.53125 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe NewsArticle, type: :model do
let(:current_user) { FactoryBot.create :user }
def news_article
@news_article ||= NewsArticle.new(
title: 'Awesome Article',
description: 'This is just the best article.',
user: current_user
)
end
describe 'validation... | true |
561914e616d3d140eae62daa477734053487f9da | Ruby | sj26/dd-trace-rb | /lib/datadog/core/backport.rb | UTF-8 | 1,310 | 2.59375 | 3 | [
"Apache-2.0",
"BSD-2-Clause",
"MIT",
"BSD-3-Clause"
] | permissive | # frozen_string_literal: true
module Datadog
module Core
# This module is used to provide features from Ruby 2.5+ to older Rubies
module BackportFrom25
if ::String.method_defined?(:delete_prefix)
def self.string_delete_prefix(string, prefix)
string.delete_prefix(prefix)
end
... | true |
257efadcae3fd42e0bb6c369756100e69eb9865f | Ruby | BrennanAyers/enigma | /lib/engine_module.rb | UTF-8 | 847 | 3 | 3 | [] | no_license | module EngineModule
def offset_keys
generate_keys(key).map.with_index do |key, index|
key_offset = generate_offsets(date)[index]
key += key_offset
end
end
def generate_offsets(date)
offsets = date.to_i.abs2.to_s
last_4 = offsets.split("").last(4)
last_4.map(&:to_i)
end
def g... | true |
7d8e18788bfe288a62e546fd5e97bd8a21da3118 | Ruby | arunrajendiran/EX2 | /ex13.rb | UTF-8 | 110 | 2.78125 | 3 | [] | no_license | Arun,Yogesh,Thiru =ARGV
puts"my name is:#{Arun}"
puts"2nd person is :#{Yogesh}"
puts"3rd person is:#{Thiru}"
| true |
789e5eaf4a3b3b1c9ee835469f24b46d70f9b459 | Ruby | kachel/sql-crowdfunding-lab-v-000 | /lib/sql_queries.rb | UTF-8 | 1,833 | 3.109375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive |
# Write your sql queries in this file in the appropriate method like the example below:
#
# def select_category_from_projects
# "SELECT category FROM projects;"
# end
# Make sure each ruby method returns a string containing a valid SQL statement.
def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphab... | true |
c5eac7f9a9ae4f01b36da1454acd79e72bb54432 | Ruby | Njunu-sk/Ruby | /Test/dup.rb | UTF-8 | 178 | 3.140625 | 3 | [] | no_license | s = "This is a dup element "
def duplication
s.dup
end
puts s
x = "This defines a freeze element"
def change(x)
x.freeze
x = "should not change"
end
puts change(x) | true |
1522ffd7e7d0a873e2c4e0bfe69041024b2c6fd1 | Ruby | kdoroudi/ruby | /monkAndEulerCodes/InterviewQuestion/practice set/bianary-conv.rb | UTF-8 | 363 | 3.8125 | 4 | [] | no_license | def convertor(num)
number = num.to_i
bianary = ''
if number == 0
return 0
end
while 0 < number
if number % 2 == 0
number = number / 2
bianary << "0"
else
number = number / 2
bianary << "1"
end
end
return bianary.reverse
end
puts(convertor(156))
puts(convertor(1... | true |
4131867c7b479b7a9f5a2712918ef09671930116 | Ruby | yurets89/saltedge_courses_2019 | /shestachenko/hw_9/script.rb | UTF-8 | 541 | 3.03125 | 3 | [] | no_license | require 'json'
names = File.read("names.json")
names_hash = JSON.parse(names)
array_firstnames = names_hash.keys
array_lastnames = names_hash.values
names_new = []
array_firstnames.each do |first_name|
if first_name == "Anastasia" || first_name == "Valeria" || first_name == "Alexandra"
gender = "Woman"
els... | true |
01bf0eec9a379cca8fb193c6d1eb5bcc3cadbad1 | Ruby | MihaiVisu/RubyStuff | /ex32.rb | UTF-8 | 385 | 3.828125 | 4 | [
"MIT"
] | permissive | the_count = [1,2,3,4,5]
fruits = ['apples','oranges','pears','apricots']
change = [1,'pennies',2,'dimes',3,'quarters']
for number in the_count
puts "This is count #{number}"
end
fruits.each do |fruit|
puts "A fruit of type: #{fruit}"
end
change.each { |i| puts "I got #{i}" }
elements = []
(0..5).each { |i| eleme... | true |
a6f6894331301dcfa485b7a067a0afd750ddb97f | Ruby | KVexcavator/ruby_out_factory_archive | /out_factory/bak/1-10/lesson_9/array_1.rb | UTF-8 | 73 | 2.859375 | 3 | [] | no_license | arr=[1,2,3,4,5,6]
puts arr
arr << 111
arr << 222
arr << 333
puts arr | true |
d81f9e3658617a83e83a7c03f82c3b978cbf7320 | Ruby | nathanarmstrong/MathFun | /Question.rb | UTF-8 | 1,004 | 3.5625 | 4 | [] | no_license | class Question
def initialize(asking_player)
@num_a = 0
@num_b = 0
@num_c = 0
@answer = nil
@response = nil
@asking_player_number = asking_player
end
def ask_for_nums(current_player)
#set state questions
p '---------------new question -----------------------'
p "#{current_pl... | true |
3faf055de1cbfd57b1cd517ce246fa1116eb3c27 | Ruby | rgarcia5/project_euler | /ruby/problem9.rb | UTF-8 | 330 | 3.421875 | 3 | [] | no_license | def pythagorean_formula(a,b)
Math.hypot(a,b)
end
def triplet
i = 2
while i < 500
j = 2
while j < 500
hypotenuse = pythagorean_formula(i,j)
if hypotenuse% 1 == 0
sum = i +j + hypotenuse
return i*j*hypotenuse if sum == 1000
end
j += 1
end
i += 1
end
end
... | true |
7eff58559f32a7ec2086df8b9c5735d0f4ab09d3 | Ruby | YoshikiMaruya/ruby-basic | /grammar/method.rb | UTF-8 | 252 | 3.875 | 4 | [] | no_license | # メソッドの基本
def greeting(country)
if country == 'Japan'
puts 'こんにちは'
elsif country == 'US'
print 'hello'
else
p '知りません'
end
end
greeting('Japan')
greeting('China')
greeting('US')
| true |
aeea8a34a8a672a22e03ef6421315615be8454f7 | Ruby | braintreeps/hydra | /test/message_test.rb | UTF-8 | 701 | 2.515625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require File.join(File.dirname(__FILE__), 'test_helper')
class MessageTest < Test::Unit::TestCase
class MyMessage < Hydra::Message
attr_accessor :my_var
def serialize
super(:my_var => @my_var)
end
end
context "with a message" do
setup do
@m = MyMessage.new(:my_var => 'my value')
... | true |
c5fb94b58cea5cd3fcfba3f7c47a244d0c5f2029 | Ruby | vivit-jc/evolve_defence | /game.rb | UTF-8 | 2,515 | 2.734375 | 3 | [] | no_license | class Game
require 'monster'
require 'simulation'
require 'evolution'
require 'map'
attr_reader :state,:money,:polit,:pause
def initialize
@state = :title
@minutes = 0
@hour = 10
@day = Date.today.day
@month = Date.today.month
@money = 600
@polit = 10
@pause = true
end
... | true |
825e333819b60822938825c445f1bbc24754da4d | Ruby | alim/baseballstats | /spec/models/player_spec.rb | UTF-8 | 1,917 | 2.859375 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe Player do
# Attribute checks ---------------------------------------------------
describe "Attribute/method checks" do
it { should respond_to :player_id }
it { should respond_to :birth_year }
it { should respond_to :first_name }
it { should respond_to :last_name }
... | true |
15ddc02f01614b14ee1bc287716c6fb979593bb1 | Ruby | aditya-app/Titania | /system/core/http_client.rb | UTF-8 | 3,870 | 2.953125 | 3 | [] | no_license | require_relative('titania.rb')
module Titania::System::Core
# Encapsulate the native http client
class HttpClient
private_instance_methods :formatHeader
# Initialize a new instance of http client
# @param [stream] client : The native http client
# @param [array] headers : Headers sent by the client... | true |
d72be1d7f0baa3ae30e90e2b8e8c137b5078b0cb | Ruby | sunghyukpark/algorithm_practice | /is_bst?.rb | UTF-8 | 2,660 | 3.9375 | 4 | [] | no_license | # PSEUDOCODE
# 1. binary_tree is given as a form of array?
# 2. binary_tree does not have an empty node?
# 3. balanced? (binary tree has at most 2 children)
# 4. Range of values given? (to check int_min and int_max)
# BRUTE FORCE SOLUTION
# 1. Perform in-order traversal and store elements in O(n) time - go over all no... | true |
041c171f01452957e0f036d60e06f18c1861cb02 | Ruby | christerforsgren91/Exam_Week4 | /lib/rubyanswers.rb | UTF-8 | 363 | 3.234375 | 3 | [] | no_license | x = 'virable'
## data typ is a string
## and some other data types
age = 29 ## Integer
job = 'student' ## String
weight = 80.03 ## Float
nerd = true ## Boolean
friuts = [] ## Array
food = {:ke => 'kebab'} ## Hash, a symbol and a string.
cars = ['Audi', 'Ford']
cars[0] = {weels: 4, max_speed: '240kph', color: 'white'}... | true |
4ce3d2bb3fafa370c4b06c23c73905d92c086918 | Ruby | localshred/maguro | /lib/maguro.rb | UTF-8 | 2,275 | 2.734375 | 3 | [] | no_license | require 'rubygems'
require 'mynu'
require 'yaml'
$: << File.expand_path('./', File.dirname(__FILE__))
require 'maguro/project'
module Maguro
class Menu
attr_accessor :menu, :projects
BT_DOMAIN = 'http://builder.bigtuna.appelier.com'.freeze
BT_URL_PATTERN = 'projects/%s/feed.atom'.freeze
BT_PROJECT... | true |
9ff932de1cf1e67948b95a63118aa1753c9c4cce | Ruby | princybathla999/alpha-blog | /test/models/category_test.rb | UTF-8 | 785 | 2.609375 | 3 | [] | no_license | require 'test_helper'
class CategoryTest < ActiveSupport::TestCase
def setup
@category = Category.new(name: "sports")
end
test "category should me valid" do
assert @category.valid?
end
test "category name should be present" do
@category.name =" "
assert_not @category.valid?
end
test "categor... | true |
ce11877ae9b9b59a45e7f6588f6a62330d5d4ce1 | Ruby | hochardga/RaspberryDevelopment | /RubyBoxing/init/zzz_test.rb | UTF-8 | 4,572 | 3.03125 | 3 | [] | no_license | # WARNING, YOU SHOULD NOT BE EDITING THIS FILE
class FighterA < Fighter
def initialize
@name = "Fighter A"
@opening_line = "Fighter A"
@moves = [
Move.new('hard punch', :damage, 25),
Move.new('eye poke', :stun, 33),
Move.new('"I guess I should heal"', :heal, 90),
Move.new('"I an g... | true |
cd25fcc285d5170af1f483238cf5144fea4337b9 | Ruby | bthachdev/localtower | /lib/localtower/generators/service_objects/insert_defaults.rb | UTF-8 | 1,511 | 2.671875 | 3 | [] | no_license | module Localtower
module Generators
module ServiceObjects
class InsertDefaults
def initialize(attributes)
@attributes = attributes
end
def call
insert_defaults
end
private
attr_reader :attributes
def insert_defaults
a... | true |
243b59e81f270121c11d8ac8fc7124a781532cae | Ruby | eugenci/global_weather | /lib/global_weather/weather.rb | UTF-8 | 3,006 | 2.859375 | 3 | [
"MIT"
] | permissive | module GlobalWeather
class Weather
ATTRIBUTES = %w(location time wind temperature
dew_point relative_humidity pressure sky_conditions
visibility)
attr_reader *ATTRIBUTES
def initialize(country = nil, city = nil, options = {})
client = Client.connect(option... | true |
004bd85f3590eb11fa3ab2d62e6fa73239e03776 | Ruby | james-cape/cross_check | /lib/game_statistics_module.rb | UTF-8 | 1,737 | 3.09375 | 3 | [] | no_license | module GameStatistics
def highest_total_score
high_game = games.max_by {|game| game.away_goals + game.home_goals}
high_game.away_goals + high_game.home_goals
end
def lowest_total_score
low_game = games.min_by {|game| game.away_goals + game.home_goals}
low_game.away_goals + low_game.home_goals
e... | true |
99b2122db2087f3d8d3a89e290b716149250bf1e | Ruby | Kievbuy/dice_rolling_simulator | /roller.rb | UTF-8 | 627 | 4.25 | 4 | [] | no_license | class Die
def initialize(sides)
@sides = sides
end
def generate_die_roll
rand(@sides) + 1
end
def roll(number=1)
roll_array = []
number.times do
roll_array << generate_die_roll
end
total = 0
roll_array.each do |roll|
puts "First Die: #{roll}"
new_total = total + roll
total = new_total... | true |
89fefe25ec9734c554e52eefce18f353be009912 | Ruby | occam/couchmacrb | /lib/couch_db/view.rb | UTF-8 | 1,081 | 2.6875 | 3 | [
"Apache-2.0"
] | permissive | module CouchDB
module View
extend self
def map_functions
@functions ||= []
end
def add_map_function(funcstr)
func = Sandbox.make_proc(funcstr)
map_functions.push(func)
true
end
def reset
map_functions.clear
end
def map(doc)
map_function... | true |
6c94999aba994048ade01a110d14b1369ab0a659 | Ruby | WhiteMexicanIsland/skypekit | /test/test_skypekit.rb | UTF-8 | 951 | 2.578125 | 3 | [
"MIT"
] | permissive | require "test/unit"
require "skypekit"
def cb
puts "A1"
return 0
end
class TestSkypekit < Test::Unit::TestCase
def test_hello_world
puts "initialize"
skype = Skypekit.new('/home/leo/skype/sslkeys/skype.pem', '127.0.0.1', 8963, '/tmp/skype.log')
puts "login"
skype.login("test4monkey", "test4m... | true |
4e7d2632b2c92ab961b143aac909d79e1a501f40 | Ruby | stahnma/crunchy | /lib/megahal/testwrapper.rb | UTF-8 | 361 | 2.90625 | 3 | [] | no_license | #!/usr/bin/ruby -w
#
# Test script for megahal wrapper
#
#
require 'megahal.rb'
def acceptInput
print "Say:\n"
foo = gets.chomp
get_response(foo)
end
def get_response(input)
if input == "exit"
exit
end
print @wrapper.getResponse(input)
print "\n"
acceptInput
end
@wrapper = MegaHAL.new
print "... | true |
a3651302320eb40ca0b8adb972898830b1d42761 | Ruby | jamaga/temp_exercise | /sorting_balls_tests.rb | UTF-8 | 363 | 2.65625 | 3 | [] | no_license | require 'minitest/autorun'
require './sorting_balls'
class SortingBallsTest < Minitest::Test
def test_random_ball
rack = Rack.new
assert_equal([], rack.balls)
rack.add(20)
assert_equal([ 20 ], rack.balls)
rack.add(10)
assert_equal([ 10, 20 ], rack.balls)
rack.add(30)
assert_equal(... | true |
c05ebb923ba7b86f6cb7f1e86297e3d1d1ff5ecb | Ruby | codelabsone/CarDealership-Jeff-One | /car_dealership.rb | UTF-8 | 5,052 | 2.84375 | 3 | [] | no_license | require 'sqlite3'
require_relative 'dbconnection'
require_relative 'filter'
require_relative 'menu'
require_relative 'paginated_menu'
require_relative 'Sales'
require_relative 'vehicle_finance_calc'
class DealershipApp
attr_accessor :filters, :break
def initialize(name)
clear_screen
@name = name
@db ... | true |
d71ac54289705746bc957b86f72729333db315dd | Ruby | ruby-marc/ruby-marc | /lib/marc/writer.rb | UTF-8 | 4,888 | 3.09375 | 3 | [
"MIT"
] | permissive | module MARC
# A class for writing MARC records as binary MARC (ISO 2709)
#
# == Too-long records
#
# The MARC binary format only allows records that are total 99999 bytes long,
# due to size of a length field in the record.
#
# By default, the Writer will raise a MARC::Exception when encountering
# in... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.