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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
9ef595ffb26785cdc9cab08433220b9c99059f9b | Ruby | TIY-Q2-ROR-CHS-2014/VehicleApplication | /app/helpers/vehicles_helper.rb | UTF-8 | 285 | 2.515625 | 3 | [] | no_license | module VehiclesHelper
def display_availability(vehicle)
if vehicle.workflow_state == 'new'
'Available'
else
'Sold'
end
end
def availability_class(vehicle)
if vehicle.workflow_state == 'new'
'success'
else
'warning'
end
end
end
| true |
baff77e624f554186bbf0bc2bbe9424c22e7c3f8 | Ruby | IceDragon200/rm-macl | /lib/rm-macl/mixin/table_ex.rb | UTF-8 | 8,537 | 2.828125 | 3 | [
"MIT"
] | permissive | #
# rm-macl/lib/rm-macl/mixin/table_ex.rb
# by IceDragon
require 'rm-macl/macl-core'
require 'rm-macl/xpan/convert'
module MACL
module Mixin
module TableEx
class TableError < RuntimeError
end
##
# xp - X-Plus
# xm - X-Minus
# yp - Y-Plus
# ym - Y-Minus
# zp - Z-... | true |
322b1fe9bd31225e9b2484f589dc525756c1d5c2 | Ruby | EagleDog/ChinguGemGo | /rb/ending.rb | UTF-8 | 13,014 | 2.609375 | 3 | [] | no_license | #
# GAMEOVER GAMESTATE
# simple GameOver gamestate
class GameOver < (Gamestate rescue Gosu::Window) # < Chingu::GameState
def initialize
super
self.input = { :esc => :exit, [:enter, :return] => Introduction, :p => Pause, :r => lambda{current_game_state.setup}, [:q, :l] => :pop }
end
def setup
@... | true |
150caf127ff221e4182dad9bd07f49665d729d08 | Ruby | cheef/radiant-questions | /app/models/question.rb | UTF-8 | 672 | 2.625 | 3 | [] | no_license | class Question < ActiveRecord::Base
has_many :answers, :dependent => :destroy
validates_presence_of :body
validates_associated :answers
def answers_attributes=(answers_attributes)
answers_attributes.each { |number, answer_attributes| detect_answer answer_attributes }
end
protected
def detect... | true |
a608630edb3802757cc56e77374aa00b32de5754 | Ruby | drhuffman12/gherkin-cr | /rb_to_cr.rb | UTF-8 | 168 | 2.578125 | 3 | [
"MIT"
] | permissive | require 'fileutils'
paths.each do |path|
to_path = path.gsub('.rb','.cr')
puts "from_path: #{path}"
puts "to_path : #{to_path}"
FileUtils.mv path, to_path
end
| true |
98d442dd0040933aba565245cadf2a21bd8f8d21 | Ruby | bankair/plex-importer | /lib/video/worker.rb | UTF-8 | 1,499 | 2.578125 | 3 | [] | no_license | # frozen_string_literal: true
$LOAD_PATH.unshift(Pathname.new(Dir.pwd) + 'lib')
require 'sidekiq'
require 'fileutils'
require 'temp_folder'
require 'video'
class Video
# Worker in charge of draining and saving videos
class Worker
include Sidekiq::Worker
class << self
def storage
@storage ||=... | true |
b36a190647cda01fe91cfa57663930b629b884f8 | Ruby | rdp/timerr | /bin/timerr | UTF-8 | 244 | 2.9375 | 3 | [] | no_license | #!/usr/bin/env ruby
raise 'need args for something to time' unless ARGV[0]
start = Time.now
c = ARGV.shift + " " + ARGV.map{|a| a.include?(' ') ? '"' + a + '"' : a}.join(" ")
puts c
system(c)
print "took #{Time.now - start}s (ran #{c})"
| true |
7d323661d9f49d9e51f157fd632f248430e623dc | Ruby | ionutnechita/datadrake-mark-this-down | /lib/parse/tables.rb | UTF-8 | 1,000 | 2.703125 | 3 | [
"MIT"
] | permissive | TABLE = /((?:(?:\|[^|\n]*)*\|\n)+)/
TABLE_HEADER = /((?:(?:\|[^|\n]*)+\|\n)*)(?:(?:\|[\- ]*)+\|\n)/
TABLE_BODY = /(?:(?:\|[\- ]*)+\|\n)((?:(?:\|[^|\n]*)+\|\n)*)/
TABLE_ROW = /((?:\|[^|\n]*)*\|\n)/
TABLE_CELL = /\| ([^|\n]+) /
module MarkThisDown
module Parse
def tables( wiki )
wiki.gsub!(TABLE) do | t |
... | true |
72f61e53df8b9efdbd152deb88c8c8c753fbe636 | Ruby | KavitojSingh/oo-counting-sentences-web-1116 | /lib/count_sentences.rb | UTF-8 | 377 | 3.546875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class String
def sentence?
self.end_with?(".")
end
def question?
self.end_with?("?")
end
def exclamation?
self.end_with?("!")
end
def count_sentences
new_string = self.gsub("?", ".")
second_string = new_string.gsub("!", ".")
first_array = second_string.split(".")
second_a... | true |
4f8400f6c73caf76277b2d653466fd9818836a5d | Ruby | hjpdev/rock-paper-scissors | /spec/rps_spec.rb | UTF-8 | 2,099 | 2.953125 | 3 | [] | no_license | require 'rps_game.rb'
describe RockPaperScissors do
let(:test_case1) { double :rps, input: 'rock', c_choice: 'scissors'}
let(:test_case2) { double :rps, input: 'scissors', c_choice: 'paper'}
let(:test_case3) { double :rps, input: 'paper', c_choice: 'rock'}
it "Take the user's name when #get_name is called." d... | true |
38b9d44bf94568f42f1d4b1bdaa7acb795b90c41 | Ruby | novito/descobreix | /app/helpers/experiences_helper.rb | UTF-8 | 264 | 2.53125 | 3 | [] | no_license | module ExperiencesHelper
# Checks if the current user is the one visiting a page that has a user id on it.
def visitor_is_current_user? visitor
return false if !user_signed_in?
if visitor == current_user
return true
else
return false
end
end
end
| true |
3ce48c0020b1d3f703a980baea9bad5e0d9d19ad | Ruby | gavinwcheng/boris_bikes | /lib/docking_station.rb | UTF-8 | 714 | 3.359375 | 3 | [] | no_license | require_relative 'bike'
class DockingStation
DEFAULT_CAPACITY = 20
attr_accessor :capacity
attr_accessor :bikes
def initialize
@bikes = []
@capacity = DEFAULT_CAPACITY
end
def release_bike(bike)
fail "No bikes available" if empty?
fail "Bike is broken" if bike.working? == false
@bikes.delete bike... | true |
66c988c2adcb0714815bf11238c94729e6d044ee | Ruby | WilfredTA/ruby_basics | /small_problems/easy5/after_midnight_p2.rb | UTF-8 | 716 | 3.859375 | 4 | [] | no_license | HOURS_PER_DAY = 24
MINUTES_PER_HOUR = 60
MINUTES_PER_DAY = MINUTES_PER_HOUR * HOURS_PER_DAY
#Counts up from midnight
#Split into hours and minutes
# Total minutes is hours converted to minutes plus minutes
# Edge cases where minutes exceeds min per day?
# Solution: Remainder of quotient of total minutes / min per day
... | true |
807c665cc77bd32684524eeb86df93b7de367017 | Ruby | aeberle1/mbta | /app/controllers/schedule_controller.rb | UTF-8 | 563 | 2.625 | 3 | [] | no_license | require 'open-uri'
require 'csv'
class ScheduleController < ApplicationController
def index
@schedule_items = []
begin
mbta_csv = CSV.new(open("http://developer.mbta.com/lib/gtrtfs/Departures.csv"), :headers => :first_row)
mbta_csv.each do |line|
@schedule_items << line
end
... | true |
e9aded46101239903775e8d426aca7d2059caf11 | Ruby | remind101/email-provider | /lib/email_provider/lookup/mx.rb | UTF-8 | 906 | 2.5625 | 3 | [
"MIT"
] | permissive | module EmailProvider
module Lookup
class Mx < Base
SUPPORTED_PROVIDERS = /google|outlook|hotmail|aol|yahoo/
attr_reader :email
def initialize(email)
@email = email
end
def lookup
DomainParser.parse(supported_mail_exchange)
end
private
def supporte... | true |
ecf6ce09b8a0585a43a23533b620b2d6d4c8a2a6 | Ruby | mohammadaliawan/launch_school_RB101 | /lesson_3/easy_1/q8.rb | UTF-8 | 356 | 3.109375 | 3 | [] | no_license | flintstones = { "Fred" => 0, "Wilma" => 1, "Barney" => 2, "Betty" => 3, "BamBam" => 4, "Pebbles" => 5 }
# barney_hsh = flintstones.select{|key, value| key == "Barney"}
# p barney_hsh
# p barney_hsh.to_a.flatten
# p flintstones.assoc("Barney")
hsh = {
ali: "0320 8457 469",
amna: "0323 4237187",
ammi: "0323 88... | true |
d192a44fe8a17a41e69fc11239b607c38536c278 | Ruby | philcowans/csg | /spec/src/boundary_rep_spec.rb | UTF-8 | 2,418 | 2.671875 | 3 | [] | no_license | require 'spec_helper'
require 'cuboid'
describe BoundaryRep do
context 'for the universe' do
it 'should calculate the right boundary rep' do
root = Node.new(true)
boundary_rep = BoundaryRep.new(10000.0)
boundary_rep.partition_by_bsp_tree!(root)
boundary_rep.polygons.size.should == 12
... | true |
5b21b66233bd1ff8ff8002ef58a272e3ce66d6c7 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/beer-song/f61360b5739642fe996a539e029ebf36.rb | UTF-8 | 2,903 | 3.890625 | 4 | [] | no_license | # Let's concede that if one where willing to put a bunch of
# 'if' statments in this it would be shorter, and that doing
# so would likely be the best solution for the beer song (which
# has not changed since the dawm of time).
#
# Let's.
#
# Instead, let's imagine that we are forced (forced, I say!) to
# solve this vi... | true |
2969cb7c30e853fced6594b5f59e2c6942091696 | Ruby | Queeshon/square_array-nyc-web-031218 | /square_array.rb | UTF-8 | 101 | 3.46875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def square_array(array)
sqarray = []
array.each do |i|
sqarray << i ** 2
end
sqarray
end
| true |
597a05f7818c38ed1f7f7fd8dbf4cdda40644df4 | Ruby | Linsdsay/number_guessing_practice | /number_guess.rb | UTF-8 | 1,990 | 3.609375 | 4 | [] | no_license | puts "Hi, I am going to pick a number between 1 and 100 and you have to guess it."
puts "I'm picking my number now..."
random_num= rand(1..100)
puts random_num
puts "Now enter your number guess."
puts "When you are done guessing, just press enter."
person_guess = gets.chomp
person_guess_num = person_guess.to_i
while ... | true |
d039984fc4f634b3abddee414fbe83273d0dbd99 | Ruby | Laner12/ruby-exercises | /command-query/clearance.rb | UTF-8 | 231 | 3.078125 | 3 | [
"MIT"
] | permissive | class Clearance
def initialize
@clearance = []
end
def best_deal
return nil if @clearance.empty?
@clearance.max_by do |item|
item.percent
end.name
end
def <<(item)
@clearance << item
end
end
| true |
932d8c7e40c0dcd8a56f12115fd3efcbc7ebd0a7 | Ruby | patbl/podcast_tools | /spec/episode_spec.rb | UTF-8 | 2,030 | 2.90625 | 3 | [] | no_license | # frozen_string_literal: true
require "spec_helper"
require_relative "../lib/podcast_tools/episode"
module PodcastTools
RSpec.describe Episode do
describe "#normalized_name" do
it "lower-cases" do
episode = described_class.new("Lol.mp4")
expect(episode.normalized_name).to eq "lol.mp4"
... | true |
773fb7d0f3fe2d0de40a6287c41d1fb57ec84e44 | Ruby | florianeck/rails_friendly_extensions | /test/hash_test.rb | UTF-8 | 1,200 | 3.203125 | 3 | [] | no_license | require "test/unit"
require "hash"
class HashTest < Test::Unit::TestCase
#== Test for .ordered
def test_hash_should_get_ordered
test_hash = {
1 => "a", 2 => "b", 3 => "c"
}
# Test options with sym or integer
assert_equal test_hash.ordered(:key), test_hash.ordered(0)
assert_eq... | true |
c8d393c220e5912b7d29acc50a0640d14ded669a | Ruby | isabella232/ripple-encryption | /lib/ripple-encryption/encryptor.rb | UTF-8 | 1,547 | 3.109375 | 3 | [
"Apache-2.0"
] | permissive | module Ripple
module Encryption
# Implements a simple object that can either encrypt or decrypt arbitrary data.
#
# Example usage:
# encryptor = Ripple::Encryption::Encryptor.new Ripple::Encryption::Config.defaults
# encryptor.encrypt stuff
# encryptor.decrypt stuff
class Encry... | true |
b8629e2a8222abae02bd05fd6898be50c6ae17ee | Ruby | thebengeu/interrobeng.com | /plugins/gist_no_css_tag.rb | UTF-8 | 5,299 | 2.75 | 3 | [
"MIT"
] | permissive | # Include gists without the annoying github CSS.
#
# Usage:
#
# Specify everything:
# {% gist_no_css username/gist_id filename %}
#
# Example: {% gist_no_css jbrains/4111662 TestingIoFailure.java %}
# This gives you the code with the title "TestingIoFailure.java"
# and a link to https://gist.github.com/jbrains/4111662
... | true |
c91c71713dcf56506bf6a66c3ecd97c80331d4cc | Ruby | makemp/nbp_exchange_rate | /lib/nbp/commons.rb | UTF-8 | 533 | 2.75 | 3 | [
"MIT"
] | permissive | module NBP
module Commons
CORE_WEB_PATH = 'http://www.nbp.pl/kursy/xml/'
def self.extended(base)
base.private_class_method :normalize_time_period
end
def nbp_date_format_hash(date)
day = normalize_time_period date.day.to_s
month = normalize_time_period date.month.to_s
year = ... | true |
764f4afc72dd12f66bd16015b73f088dbd3c9f80 | Ruby | binaryage/totalspaces2-api | /ruby/lib/totalspaces2.rb | UTF-8 | 24,778 | 2.703125 | 3 | [
"MIT"
] | permissive | # = TotalSpaces2 - Ruby API bindings for TotalSpaces2 from BinaryAge
#
# This gem enables you to get information from and to control {TotalSpaces2}[link:http://totalspaces.binaryage.com]
#
# It is the officially supported way of using the API library libtotalspaces2api, and the required dylib
# comes bundled with this... | true |
1081a75bc9a31eef3816eb71fcdf1e522a3432ec | Ruby | MarkKourie/learn_ruby | /01_temperature/temperature.rb | UTF-8 | 103 | 3.265625 | 3 | [] | no_license | #write your code here
def ftoc(n)
(n - 32.0) * 5.0/9.0
end
def ctof(n)
(n * 9.0/5.0) + 32
end | true |
9a2e779c64cca17d44f5e36a18b79de0b5756fc6 | Ruby | citygent/W3D4 | /mta.rb | UTF-8 | 1,286 | 3.4375 | 3 | [] | no_license | mta = {
'n': ['times square', '34th', '28th', '23rd', 'union square', '8th'],
'l': ['8th', '6th', 'union square', '3rd', '1st'],
'6': ['grand central', '33rd', '28th', '23rd', 'union square', 'astor place']
}
puts "Welcome to MTA! \n Which line are you getting on at?"
line_on = gets.downcase.chomp.to_sym
puts lin... | true |
157ff849c3ecbeb818a24230cccbe9c572ee6bb8 | Ruby | ajhanson22227/mastermind | /game.rb | UTF-8 | 1,246 | 3.734375 | 4 | [] | no_license | require 'colorize'
require 'pry'
#Game engine class
class Game
def initialize
@turn = 1
@secret_code = Code.new
@player_code = Code.new
@player = Player.new
end
def play
@secret_code.generate_code
@secret_code.display_code
loop do
puts "T... | true |
e89f553855f0335989956f384e5c2dd120014e73 | Ruby | cclamb/ontology-xform | /etc/exp/method-sort-exp.rb | UTF-8 | 1,682 | 3.09375 | 3 | [] | no_license | require_relative '../lib/flounder/parser'
include Flounder
def get_class_name e
e[0].split('#').last
end
#filename = 'Ontology2.owl'
filename = 'Ontology.owl'
#filename = 'simple-ontology.owl'
p = Parser.new
xml = File.read filename
r = p.parse xml
elements = r[:elements]
clazzez = []
comp_str = "def comparato... | true |
7729f4e0ee706fba6511fbf40c9de90afc08e0a0 | Ruby | krazylegz/CityWiki | /app.rb | UTF-8 | 2,901 | 2.71875 | 3 | [] | no_license | require 'sinatra'
require 'json'
require 'unirest'
require 'geocoder'
set :port, 8080
def key
File.read('keystore')
end
get '/' do
'Type localhost:8080/new%20york+ny or localhost:8080/tampa+fl in the address bar and press enter.'
end
get '/:city+:state' do
content_type :json
@city = "#{params['city']}"
@... | true |
0ac302c4e4d6f28e0bbafbf90b468aa7f858b059 | Ruby | Tayyab-athar-1998/assignment-1 | /app/models/person_without_join.rb | UTF-8 | 1,069 | 2.921875 | 3 | [] | no_license | class PersonWithoutJoin < ApplicationRecord
validate :if_parent_exists
validates :name, uniqueness: true
def print_tree
parent = self.parent
logger.info(self)
value = "{Name :'#{self.name}'"
memo = [self.name]
while parent!=nil do
parent_person = PersonW... | true |
288beeafe88c13cf45c1e4746c4d87660a204100 | Ruby | alexwang949/allegro_app | /server.rb | UTF-8 | 2,516 | 2.671875 | 3 | [] | no_license | require 'pry'
require 'sinatra/reloader'
require './lib/mood.rb'
require './lib/piece.rb'
require './lib/user.rb'
require './lib/connection.rb'
# require './lib/database.yml'
# require './environments.rb'
require './lib/event.rb'
require './lib/favorite.rb'
require 'sinatra'
require 'mustache'
require 'HTTParty'
#####... | true |
959ad3592ac34399fde367aeff321f2c341f9233 | Ruby | concord-consortium/rigse | /rails/app/models/firebase_app.rb | UTF-8 | 1,110 | 2.59375 | 3 | [
"MIT",
"LicenseRef-scancode-public-domain"
] | permissive | class FirebaseApp < ApplicationRecord
self.table_name = :firebase_apps
validates_presence_of :name, :message => "can't be blank"
validates_format_of :client_email, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i, :message => 'is not a valid email address'
validates_presence_of :private_key, :message => ... | true |
8d027b01a69d6ad585a4a20148e6c43929950de5 | Ruby | thash/helloworlds | /Ruby/fib.rb | UTF-8 | 80 | 2.765625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
def fib n
return 1 if n <= 2
fib(n-1)+fib(n-2)
end
| true |
198f30e34ed595abfa2b0b6846a849b4b5b2c515 | Ruby | dudoslav/rushour | /lib/rushour/time_manager.rb | UTF-8 | 757 | 2.703125 | 3 | [] | no_license | module Rushour
class TimeManager
def initialize
@intervals = Rushour::Settings.intervals.map do |interval|
Rushour::Interval.new(Rushour::Daytime.from_str(interval[:start]),
Rushour::Daytime.from_str(interval[:finish]))
end
end
def check
now = Rusho... | true |
c981781c1acfed5369a4682676631909d459dea4 | Ruby | SinaCode1387/onlineconvert-api-example-codes | /Ruby/online_convert.rb | UTF-8 | 7,954 | 2.640625 | 3 | [
"MIT"
] | permissive | #
# OnlineConvert Class
#
# API class for www.online-convert.com service.
#
# Version:: 1.0
# Author:: NIRAV RANPARA (mailto:nirav.programmer@gmail.com)
# Copyright:: Copyright (c) 2002 The Pragmatic Programmers, LLC
# License:: Distributes under The MIT License
class OnlineConvert
#Online Converter API ... | true |
125bdfdeb8cf6f31b5059749b87578aab59f91d0 | Ruby | rubenkostucki/sudoku | /lib/board.rb | UTF-8 | 173 | 3.078125 | 3 | [] | no_license | class Board
attr_reader :total_cells, :rows
def initialize(grid_number)
@total_cells = grid_number ** 2
@rows = [R1, R2, R3, R4, R5, R6, R7, R8, R9]
end
end | true |
652d36ae82d6645f24dc63e34550bb6a9ac6350a | Ruby | otegami/c9 | /basic/5/string.rb | UTF-8 | 92 | 2.96875 | 3 | [] | no_license | str1 = "これは"
str2 = "文字列オブジェクトです"
puts ( str1 )
puts ( str2 )
| true |
8dc9694546c7f1f3a402c2a00eead72f3271434c | Ruby | umaz/opac | /easy.rb | UTF-8 | 2,325 | 2.734375 | 3 | [] | no_license | #!/usr/bin/ruby
# -*- coding: utf-8 -*-
require("sqlite3")
def read1field(io)
line = io.gets
if !line
return nil
end
line.chomp!
field = line.split(/:\s*/, 2)
return field
end
def read1record(io)
record = Hash.new
while field = read1field(io)
if field[0] == "*"
break
end
if re... | true |
f6c508d7165511673dc7a8623fb435c1b3dc585b | Ruby | natecampbell/ruby-music-library-cli-v-000 | /lib/music_library_controller.rb | UTF-8 | 1,471 | 3.34375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class MusicLibraryController
attr_accessor :path
def initialize(path = "./db/mp3s")
@path = path
MusicImporter.new(path).import
end
def call
input = ""
while input != "exit"
input = gets.strip
case input
when "list songs"
songs
when "list artists"
... | true |
55d4bb14419af8d1705bd32cc14327bc7f27d704 | Ruby | kishoreravi24/ruby | /array.rb | UTF-8 | 512 | 3.984375 | 4 | [] | no_license | arr = Array.new
puts arr.length
puts arr.size
arr1 = Array.new(10)
puts arr1.length
puts arr1.size
#you cannot import Array.new for already existed one
=begin
arr1 = Array.new('a'..'z')
puts arr1
=end
# you cannot do Array.new('a'..'z') bcz you are initialize the values where the new is for getting the size
arr2 = [... | true |
24735127c8ab8de98b857789fd36d88e570c4e88 | Ruby | randsina/teor_transl | /lab1/app.rb | UTF-8 | 577 | 2.71875 | 3 | [
"MIT"
] | permissive | tokens = {
EQUAL: /^=$/,
PLUS: /^\+$/,
MINUS: /^\-$/,
MULTI: /^\*$/,
DIV: /^\/$/,
POWER: /^\*\*$/,
NUMBER: /^-?\d+\.?\d?$/,
STRING: /^".*"$/,
RESERVED: /^(end|print|def|)$/,
ID: /^[a-z_A-Z]\w*$/,
UNDEFINED: /^[^a-z_A-Z]\w*$/
}
lines =... | true |
805c6550fe2828daf7542c58d7c447cdbbcbcc0a | Ruby | bnyf/Haiway | /framework/libs/network/esp8266/tests/projects/http_test.rb | UTF-8 | 688 | 2.8125 | 3 | [
"MPL-2.0",
"ISC",
"Apache-2.0",
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-warranty-disclaimer",
"BSD-3-Clause"
] | permissive | # HTTP test responder: simple web server that responds to requests from espruino in order to
# test sockets
require 'sinatra'
get "/ping" do
"pong\nEND"
end
get "/empty" do
""
end
get "/data" do
size = params[:size].to_i || 4013
text = "This is a #{size} byte response from the friendly test server\n"
resp... | true |
7d2d110de83d236c47923c912b7d11e045f115d3 | Ruby | stovermc/practice-repo | /algorithm-practice-ruby/circle_area.rb | UTF-8 | 126 | 3.59375 | 4 | [] | no_license | # method for calculating the area of a circle given radius
def area(radius)
Math::PI * (radius ** 2)
end
r = 10
p area(r)
| true |
bd981ca9f69f40c2a6444a3fcef7f086e396f546 | Ruby | raketbizdev/jobready | /spec/product_spec.rb | UTF-8 | 589 | 2.609375 | 3 | [] | no_license | require 'spec_helper'
require 'product'
describe Product do
it 'Should have value for the item_quantity, item_name, item_price' do
product = Product.new
product.item_quantity = 1
product.item_name = 'Books'
product.item_price = 12.49
expect(product).to have_attributes(item_quantity: 1)
... | true |
08ade6bbb342bef70b34dfbb099b73077b48f729 | Ruby | divyams1/Homework | /W5D3/DoggyDayCare/app/models/dog.rb | UTF-8 | 565 | 2.65625 | 3 | [] | no_license | class Dog < ApplicationRecord
validate :check_name_length
validates :name, presence: true
def check_name_length
unless self.name.length >= 4
errors[:name] << "Name is too short"
end
end
# def toys
# Toy.where({ dog_id: self.id })
# end ... | true |
8aec36d5d7d0c0c24cf9487c15678757b4bfd738 | Ruby | orenmagid/OO-mini-project-dc-web-060418 | /app/models/Allergen.rb | UTF-8 | 233 | 2.828125 | 3 | [] | no_license | class Allergen
attr_accessor :user_O, :ingredient_O
@@all = []
def self.all
@@all
end
def initialize(user_O, ingredient_O)
@user_O = user_O
@ingredient_O = ingredient_O
self.class.all << self
end
end
| true |
e2379a0f5f1aff97026e7b666adcd54a8f68d0d9 | Ruby | AaronReyes-ML/Trail-Weather-Tracker | /vendor/bundle/ruby/2.3.0/gems/cane-2.6.2/spec/violation_formatter_spec.rb | UTF-8 | 1,113 | 2.65625 | 3 | [
"Apache-2.0"
] | permissive | require 'spec_helper'
require 'cane/violation_formatter'
describe Cane::ViolationFormatter do
def violation(description)
{
description: description
}
end
it 'includes number of violations in the group header' do
described_class.new([violation("FAIL")]).to_s.should include("(1)")
end
it '... | true |
68175b72b5f09630a0a007d4d73c0a18135d5e99 | Ruby | Whelton/pretty_id | /lib/pretty_id/generator.rb | UTF-8 | 465 | 2.578125 | 3 | [
"MIT"
] | permissive | module PrettyId
class Generator
attr_reader :record
def initialize(record)
@record = record
end
def id
"#{prefix}#{separator}#{SecRandom.alphanumeric(length)}"
end
def length
12
end
def prefix
if record.class.id_prefix.is_a? Proc
record.class.id_pref... | true |
99fe37775a05f4a391dbb4a6cf29c69366ab0e95 | Ruby | bruadarach/ruby-study-note | /45_arrayMethodSplitJoin.rb | UTF-8 | 4,123 | 4.84375 | 5 | [] | no_license | # split / join
# (1) string.split : evaluates "to an array"
# split : Return an array / from a string to an array!
# split divides str into substrings based on a delimiter, returning an array of these substrings.
# " now's the time".split #=> ["now's", "the", "time"]
# " now's the time".spli... | true |
aec12f7ac310c1fe18bfe404b335339e62167ee0 | Ruby | beasteim/ruby-challenges | /symbols_and_hashes.rb | UTF-8 | 393 | 2.859375 | 3 | [] | no_license |
outfit1 = { :shoes => "gold flats", :Top => "red striped tee", :Bottom => "faded denim"}
outfit2 = {:shoes => "brown leather wedges", :Top => "Burnt orange sweater", :Bottom => "dark blue denim"}
outfit3 = { :shoes => "nude classic heels", :Top => "Prim black peplum", :Bottom => "red gradient pencil skirt"}
todays... | true |
b4baba546408a4e53489ed39313c42b992b3a92c | Ruby | cielavenir/ruby_libciel | /lib/hash/fetch_nested.rb | UTF-8 | 459 | 2.984375 | 3 | [
"BSD-2-Clause"
] | permissive | class Hash
#nil safe version of Hash#[].
# h.fetch_nested(*['hello','world']) is basically the same as h['hello'].try.send(:[],'world').
def fetch_nested(*keys)
begin
keys.reduce(self){|accum, k| accum.fetch(k)}
rescue (RUBY_VERSION<'1.9' ? IndexError : KeyError)
block_given? ? yield(*keys) : nil
end
en... | true |
167c610d87c2e667b4e12ec3bf4c81afca9585e9 | Ruby | occipudding/OO-mini-project-dumbo-web-051319 | /app/models/User.rb | UTF-8 | 750 | 2.96875 | 3 | [] | no_license | class User
attr_reader :name
@@all = []
def initialize(name)
@name = name
@@all << self
end
def recipes
RecipeCard.all.select{|card| card.user == self}
end
def allergens
Allergy.all.select{|alg| alg.user == self}
end
def add_recipe_card(recipe, rating, date = Time.now)
RecipeC... | true |
e86caf3fbeb198653a7f0129a94b8a8dada30e93 | Ruby | singpolyma/MyLibrary | /lib/isbn.rb | UTF-8 | 3,039 | 3.234375 | 3 | [
"ISC"
] | permissive | #!/usr/bin/ruby
#
# Copyright (c) 2010, John D. Lewis <balinjdl at gmail.com>, 2011 Stephen Paul Weber <singpolyma.net>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
#
# * Redistributions of so... | true |
8101658a423a5b8c4fe4c8f86dcc317ca05b9f0c | Ruby | RyN21/final_b2_2005 | /app/models/flight.rb | UTF-8 | 458 | 2.546875 | 3 | [] | no_license | class Flight < ApplicationRecord
has_many :flight_passengers
has_many :passengers, through: :flight_passengers
belongs_to :airline
validates_presence_of :number,
:date,
:time,
:departure_city,
:arrival_city
... | true |
d17d710da2ada9f3dbd9254dd136ce89addb548d | Ruby | szibis/sensu-plugins | /handlers/hipchat/hipchat.rb | UTF-8 | 11,988 | 2.640625 | 3 | [] | no_license | #!/usr/bin/env ruby
#
# Sensu Handler: hipchat
#
# This handler script is used to send notifications to Hipchat rooms.
#
# Input:
# @event - Event attributes.
# @event['action'] - Property to figure out the event type i.e. whether it is create or resolve.
# @event['check'] - Map of attributes from the check... | true |
76138f428b0fa0553a73d8cc644d3cd4683ab14b | Ruby | lena-pl/wholesome-lang | /src/ast_nodes/assignment_node.rb | UTF-8 | 791 | 2.90625 | 3 | [
"MIT",
"CC-BY-4.0"
] | permissive | # frozen_string_literal: true
require_relative './ast_base.rb'
class AssignmentNode < ASTBase
attr_reader :identifier, :literal
def debug_print(level)
identifier = children_of_type(IdentifierToken).first
expression = @children - [identifier]
expression_string = expression.map { |a| a.debug_print(leve... | true |
12ed6ed63fab652e1a315846b55441215e055e12 | Ruby | domo2192/backend_mod_1_prework | /day_5/exercises/hashmexicostates.rb | UTF-8 | 962 | 3.734375 | 4 | [] | no_license | # create a mapping of state to abbreviation
states = {
'Mexico City' => 'MC',
'Mexico' => 'ME',
'Jalisco' => 'JA',
'Puebla' => 'PU',
'Chihuahua' => 'CH',
'Baja California' => 'BC'
}
cities = {
'MC' => 'Mexico City',
'ME' => 'Ecatepec',
'JA' => 'Guadalajara'
}
cities['PU'] = 'Puebla City'
cities['CH'... | true |
2257561d0c7d6271f72d5f9a3240537f3210b9eb | Ruby | Zivi/barkPark_api | /spec/requests/counties_spec.rb | UTF-8 | 1,398 | 2.640625 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe 'Counties API', type: :request do
# initialize test data
let!(:counties) { create_list(:county, 10) }
let(:county_id) { counties.first.id }
# Test suite for GET /counties
describe 'GET /counties' do
before { get '/counties' }
it 'returns counties' do... | true |
3bf5d4b0491e8adf92fbf2bf1972944947213044 | Ruby | heckfy/unshorter | /lib/unshorter.rb | UTF-8 | 658 | 2.875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require "uri"
require "net/http"
class Unshorter
attr_reader :max_level
def initialize(max_level = 5)
@max_level = max_level
end
def call(url)
url = "http://#{url}" if url !~ %r{^(http|https)://}
original_uri = uri = URI(url)
max_level.times do
response = ... | true |
8aaad8a6c60e768cbb4153d5d044a526956b4924 | Ruby | hathitrust/print_holdings | /report/custom/calimergia/with_without_rlf.rb | UTF-8 | 2,998 | 2.9375 | 3 | [] | no_license | # UC wants to know what it would look like if we folded back nrlf->berkeley and srlf->ucla
# Took about 3.5h to run on punch while the build was running.
require 'hathidb';
require 'hathilog';
require 'hathidata';
db = Hathidb::Db.new();
conn = db.get_conn();
log = Hathilog::Log.new();
cost... | true |
afcf88c9aba7656a0f5c1b9e43a98b4f628fe48e | Ruby | berchev/oreilly-learning-ruby | /book_1/chapter03_conditional_love/if_5.rb | UTF-8 | 126 | 2.953125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
ruby = "nifty"
programing = "fun"
if ruby == "nifty" && programing == "fun"
puts "Keep programing"
end | true |
3f3ec32d6894e781b01c3c7db14f6d03f5dce90a | Ruby | linearregression/meangirls | /lib/meangirls.rb | UTF-8 | 1,358 | 2.546875 | 3 | [
"MIT"
] | permissive | module Meangirls
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__))
class ReinsertNotAllowed < RuntimeError; end
class DeleteNotAllowed < RuntimeError; end
class DecrementNotAllowed < RuntimeError; end
require 'set'
require 'base64'
require 'securerandom'
require 'socket'
require 'meangirls... | true |
3c5b9fe15be0a872df188decfb876b8197a833d5 | Ruby | donv/front | /app/models/user.rb | UTF-8 | 2,052 | 2.71875 | 3 | [] | no_license | # frozen_string_literal: true
require 'digest/sha1'
class User < ApplicationRecord
# Virtual attribute for the unencrypted password
attr_accessor :password
validates :login, :email, presence: true
validates :password, presence: { if: :password_required? }
validates :password_confirmation, presence: { if: :... | true |
69736908746021a3bf577abd948b1ff19b569cab | Ruby | carlos727/run_jar | /libraries/helpers.rb | UTF-8 | 4,715 | 2.515625 | 3 | [] | no_license | include Chef::Mixin::PowershellOut
module Tools
require 'net/smtp'
require 'net/http'
require 'json'
# Method to fetch data in JSON format from an URL
def self.fetch(url)
resp = Net::HTTP.get_response(URI.parse(url))
data = resp.body
return JSON.parse(data)
end
# Method to unindent multil... | true |
f7d2f948e7ae3116ccdbd014c0035bd2306dd753 | Ruby | hmahalik/apple_cloud_notes_parser | /lib/AppleNoteStore.rb | UTF-8 | 20,952 | 2.84375 | 3 | [
"MIT"
] | permissive | require 'digest'
require 'sqlite3'
require_relative 'AppleNote.rb'
require_relative 'AppleNotesAccount.rb'
require_relative 'AppleNotesFolder.rb'
##
# This class represents an Apple NoteStore file. It tries to handle the hard work of taking
# any Apple Notes database, determining the proper version of it, and tailori... | true |
cdc66c8daf633d2b44660ba8e8e4047a68fe1d5e | Ruby | bestwebua/codewars | /ruby/is_a_number_prime.rb | UTF-8 | 550 | 4.15625 | 4 | [] | no_license | =begin
Is a number prime? by Vladislav Trotsenko
Define a function isPrime that takes one integer argument and returns true or false
depending on if the integer is a prime.
Per Wikipedia, a prime number (or a prime) is a natural number greater than 1 that
has no positive divisors other than 1 and itself.
isPrime(5) ... | true |
958b6277fa7a1d881ec2671c1a90e6f60a523496 | Ruby | aikanshgarg/CopyCat-Instagram | /instagram/app/controllers/posts_controller.rb | UTF-8 | 2,202 | 2.609375 | 3 | [] | no_license | class PostsController < ApplicationController
before_action :authenticate_user!
before_action :find_post, only: [:show, :destroy]
# includes is like a join table between posts and photos/user/likes
def index
# @posts = Post.all.limit(10).includes(:photos, :user, :likes).order('created_at desc')
@p... | true |
2bab264baf45d84e998cdbab647a83c0c96e7e05 | Ruby | CEsGutierrez/stacks-queues | /lib/problems.rb | UTF-8 | 2,310 | 3.359375 | 3 | [] | no_license | require_relative './stack.rb'
# Time Complexity: O(n)
# Space Complexity: O(1)
def balanced(string)
if string.length == 0 || string.length == 1
return true
elsif string.length.odd?
return false
end
reference = Hash.new
reference = {
"(" => ")",
")" => "(",
"[" => "]",
"]" => "[",
"{"... | true |
de208f1ceea7cfb6c0e1ef29a96e895f9b253337 | Ruby | batterseapower/boardlog | /lib/boardlog/images.rb | UTF-8 | 1,331 | 2.859375 | 3 | [] | no_license | require 'exifr'
require 'gd2'
module Boardlog
class Images
def self.guess_image_date_time(filename)
begin
time = EXIFR::JPEG.new(filename).date_time_original
# If the time data in the EXIF doesn't match an expected format we get back a string..
time.class == Time.class ? time : nil
... | true |
8b691691ebee9631dc745605923f14b3e3fec75c | Ruby | ochlupin/reverse-each-word-prework | /reverse_each_word.rb | UTF-8 | 130 | 3.40625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def reverse_each_word(string)
reversed_string = string.split(" ").collect {|word| word.reverse}
reversed_string.join(" ")
end
| true |
3dfceabf4be247eabb54dd372095de747217b7f6 | Ruby | Balaji-Ramasubramanian/Food2Home | /facebookBot/send_menu.rb | UTF-8 | 1,351 | 2.65625 | 3 | [
"Apache-2.0"
] | permissive | require_relative './menu'
require_relative './bot'
# @author Balaji
class MessengerBot
# @param id [Integer] The Facebook User ID.
# @return [nil].
# Method to show menu items to the user.
#
def self.send_menu(id)
template = GENERIC_TEMPLATE_BODY
elements = []
(0..9).each { |i|
break if i > MENU_ITE... | true |
2673bad934b783448777087c244e2ea1b0baa807 | Ruby | codeship/bitbucket | /lib/bitbucket_rest_api/issues/milestones.rb | UTF-8 | 3,321 | 2.625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | # encoding: utf-8
module BitBucket
class Issues::Milestones < API
VALID_MILESTONE_INPUTS = %w[
name
].freeze # :nodoc:
# Creates new Issues::Milestones API
def initialize(options = {})
super(options)
end
# List milestones for a repository
#
# = Examples
# bitbucket... | true |
5cd49280b9a05522ea8585e2fdd60d3a6dfaf2ad | Ruby | mathieugagne/milo-app | /app/helpers/projects_helper.rb | UTF-8 | 807 | 2.5625 | 3 | [] | no_license | module ProjectsHelper
def project_status_label status
status_class = case status
when 'ongoing' then 'info'
when 'completed' then 'success'
when 'canceled' then 'warning'
else
'default'
end
content_tag(:span, status, class: "label label-#{status_class}")
end
def project_user_li... | true |
8107f3a1f19b66efb92680bba5269660f4fedf15 | Ruby | dbaspi9/logs_compiler | /logs_compiler.rb | UTF-8 | 2,026 | 2.578125 | 3 | [] | no_license | class LogsCompiler
require 'open-uri'
require 'nokogiri'
require 'net/ftp'
require 'yaml'
require 'json'
def initialize
@secrets = YAML.load_file('secrets.yml')
@varnish_logs = File.readlines('varnish.log')
download_xml_data
@xml_logs = Nokogiri::XML(File.read('data.xml'))
download_json... | true |
8dc5fa581144584b794415ea2b176f0aceb6e933 | Ruby | denvolchkevich/GeekBrains_Ruby | /second_lesson.rb | UTF-8 | 5,294 | 4.21875 | 4 | [] | no_license | # Second lesson homework
# Для класса Fixnum:
# Метод, возвращающий вещественный результат от деления
111.fdiv 12.3 # => 9.024390243902438
# Метод проверяющий, является ли число нечётным
10.odd? # => false
# Для класса Integer:
# Метод, возвращающий Наибольший Общий Делитель 2-х чисел
8.gcd(4... | true |
5bf1a2ba3d15e2e8b6d189fbd3cba4fea6f516dd | Ruby | budabum/eduke-server | /eduke-server.rb | UTF-8 | 7,783 | 2.859375 | 3 | [
"MIT"
] | permissive | require 'json'
require 'pp'
require 'yaml'
require 'sinatra'
set :bind, '0.0.0.0'
set :port, 9944
def _get(*args, &blk) get(*args, &blk) ; end
def _post(*args, &blk) get(*args, &blk) ; end
PERSISTENT_FILE = "eduke.yml"
class User
attr_accessor :email, :first_name, :last_name, :phone
def initialize(email, fn, l... | true |
75cfed63d0b79ec6e8377c7dc5e2f5220885d969 | Ruby | JohnBat26/gnawrnip | /example/web.rb | UTF-8 | 1,040 | 2.53125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'sinatra'
require 'erb'
get '/' do
"Hello World!!"
end
get '/form' do
erb :index
end
post '/result' do
erb :index
end
get '/confirm' do
erb :confirm
end
post '/result_confirm' do
erb :confirm
end
__END__
@@ index
<!DOCTYPE html>
<html>
<head>
<style>
body { background-color: #aaaaa... | true |
caff1a0e5023b063bdab5a8d508cb5e9c4dae06c | Ruby | pvinis/project-euler-in-ruby | /func/ntoa.rb | UTF-8 | 129 | 3.296875 | 3 | [] | no_license | class Numeric
def to_a
n = self
a = []
while n != 0
a.insert 0, n % 10
n /= 10
end
a
end
end
| true |
62ab27cd6a8230ddd0d681662eea360e4fafa4da | Ruby | julesnuggy/chitter-challenge | /lib/db_connection.rb | UTF-8 | 362 | 2.71875 | 3 | [] | no_license | require 'pg'
class DB_Connection
attr_reader :dbname, :user
def self.setup(db_name, db_user = 'julesnuggy')
@dbname = db_name
@connection = PG.connect(dbname: @dbname, user: db_user)
end
def self.dbname
@dbname
end
def self.connection
@connection
end
def self.query(query_string)
... | true |
65bec7ffd73d7260586108067c25a3982a29e040 | Ruby | haruto167/rubyBasicStudy | /02_varidate.rb | UTF-8 | 270 | 3.6875 | 4 | [] | no_license | # 数字
p 4.8.class
# クラス名 Float
p 4.8.methods
# 使えるメソッド floor,round
# + - * / % **
p 10 + 3
p 10 * 3
p 2.4 * 4
p 10 / 3
p 10 % 3
p 10.0 / 3
# 分数の計算
p Rational(2,5) + Rational(3,4)
p 2/5r + 3/4r
p 52.6.round
p 52.6.floor
p 52.6.ceil | true |
5ab48ca8c8afd27bb4a87e6ecdf5820b7465954e | Ruby | copiousfreetime/heel | /lib/heel/mime_map.rb | UTF-8 | 2,357 | 2.5625 | 3 | [
"BSD-3-Clause"
] | permissive | #--
# Copyright (c) 2007 - 2013 Jeremy Hinegardner
# All rights reserved. Licensed under the BSD license. See LICENSE for details
#++
require 'mime/types'
module Heel
# MimeMap is a Heel specific mime mapping utility. It is based upon
# MIME::Type and adds some additional mime types. It can also say what the
... | true |
f63db2e9341808a710fad976074ee3a7ddb0d373 | Ruby | SophieTochon/the-team-project | /app/services/twitter_bot.rb | UTF-8 | 1,105 | 2.671875 | 3 | [] | no_license | Dotenv.load
class TwitterBot
attr_accessor :tab
def initialize()
@tab_tweet = []
end
def perform
log_in_to_twitter
search_tweet("#eSports -rt")
search_tweet("#FUT18 -rt")
#fav_tweet
#@tab_tweet
send_tweet
end
def log_in_to_twitter
@client = Twitter::REST::Client.new do |c... | true |
2db72a1da9ccfea76d8052f0a193ef220e6954f8 | Ruby | oguzpol/ruby-tutorial | /case_statement.rb | UTF-8 | 1,942 | 3.484375 | 3 | [] | no_license | def rate_my_food
print "What is your order ? \n"
print "= >"
food = gets.chomp
case food
when 'Steak'
'Pass the steak sauce! That\'s delicious'
when 'Sushi'
'Nice choice!'
when 'Mantı', 'mantı', 'MANTI'
'Best choice! My favorite meal!'
when 'Tacos', 'Burritos', 'Quesdillas'
'Cheesy and f... | true |
d51a31b6ec6e89efdc42670315ad3ab5b2b46eef | Ruby | presto53/blondy-dhcpd | /lib/blondy/dhcpd/server.rb | UTF-8 | 1,175 | 2.609375 | 3 | [
"MIT"
] | permissive | require 'net-dhcp'
require 'eventmachine'
require 'socket'
require 'log4r'
require_relative 'dispatcher'
module Blondy
module DHCPD
# Main class for handling connections
class Server < EM::Connection
def initialize
@buffer = String.new
super
end
# Fires up Dispatcher and send reply back b... | true |
db42fc8fa653aa2d9ed7c73fddba923016354230 | Ruby | KeisukeMurata4210/Object-Oriented_Design_in_Ruby | /1st_time/chapter_5/2_getting_worse.rb | UTF-8 | 2,356 | 3.375 | 3 | [] | no_license | # 旅行コーディネイター、運転手も含まれたら
class Trip
attr_reader :bicycles, :customers, :vehicle
def prepare(preparers)
preparers.each do |preparer|
case preparer
when Mechanic
preparer.prepare_bicycles(bicycles)
when TripCoordinator
preparer.buy_food(cus... | true |
565938d9ac3c56579db17fd3d9c82fab86bbe304 | Ruby | MrJaba/Coding-Katas | /09-checkout/checkout.rb | UTF-8 | 329 | 3.171875 | 3 | [] | no_license | require 'catalogue'
require 'trolley'
class CheckOut
def initialize( catalogue )
@catalogue = catalogue
end
def scan( item )
trolley.add( item )
end
def trolley
@trolley ||= Trolley.new( @catalogue )
end
def total
trolley.items.inject(0){ |sum, item| sum + item.price }
e... | true |
871cf5d8005d57fdd70b9042353fc9cebdb58d4d | Ruby | sciencefixion/pantry_2005 | /lib/recipe.rb | UTF-8 | 483 | 3.109375 | 3 | [] | no_license | class Recipe
attr_reader :name,
:ingredients_required,
:ingredients
def initialize(name)
@name = name
@ingredients_required = {}
@ingredients = @ingredients_required.keys
end
def add_ingredient(ingredient = 0, amnt)
if @ingredients_required[ingredient].nil?
@i... | true |
8e1aa90f5377be3f5c1138efcc5ea982d368a721 | Ruby | weakweak/SimcScripts | /Combinator.rb | UTF-8 | 910 | 2.6875 | 3 | [] | no_license | def SimcLogToCSV(infile, outfile)
puts "Converting #{infile} to CSV..."
sims = { }
# Read results
File.open(infile, 'r') do |results|
while line = results.gets
if line.start_with?('Player:') then
name = line.split()[1]
dps = results.gets.split()[1]
sims[name] = dps
end
... | true |
2ef9c0937fbffd625168db8b7cd18a8fd50d6649 | Ruby | giorgil/merb_cache_more | /lib/merb_cache_more/request.rb | UTF-8 | 2,130 | 3.109375 | 3 | [
"MIT"
] | permissive | module Merb
class Request
class << self
# ==== Parameters
# value<Array, Hash, Dictionary ~to_s>:: The value for the query string.
# prefix<~to_s>:: The prefix to add to the query string keys.
#
# ==== Returns
# String:: The query string.
#
# ==== Alternatives
... | true |
d220086a2d0e8661a351fa8fbdefbd69f9fd3cab | Ruby | essian/project_cli_blackjack | /blackjack.rb | UTF-8 | 1,178 | 3.9375 | 4 | [] | no_license | require 'pry'
class Card
attr_accessor :rank, :suit
def initialize(rank, suit)
@rank = rank
@suit = suit
end
end
class Deck
attr_accessor :stack_of_cards
def initialize
@stack_of_cards = []
ranks = %w{A 2 3 4 5 6 7 8 9 10 J Q K}
suits = %w{Spades Hearts Diamonds Clubs}
suits.each... | true |
6c40006be9e8e46c908ba4c700b4a7fa40ffd127 | Ruby | vrunda2712/assignment_roll-of-the-die | /total_times.rb | UTF-8 | 403 | 3.515625 | 4 | [] | no_license | # how many times each total will come up if each possible permutation is rolled once.
total_permutations = {}
(2..12).each do |total|
total_permutations[total] = 0
end
(1..6).each do |die1|
(1..6).each do |die2|
# total_permutations[total] = "#{die1 + die2}"
total_permutations[die1 + die2] += 1
end
end... | true |
7909def8325880309ea8b6a3db7f1a0f984cc580 | Ruby | timwebster9/smashing-bus | /jobs/buses.rb | UTF-8 | 1,206 | 2.78125 | 3 | [] | no_license | require 'httparty'
require 'json'
require 'time'
class BusArrival
def initialize(currentTime, busNo, arrivalTime)
@currentTime = currentTime
@busNo=busNo
@arrivalTime=arrivalTime
end
def busNo
@busNo
end
def arrivalTime
@arrivalTime
end
def eta
((@arrivalTime - @currentTime) / ... | true |
16b62cc7f107b0bec704de85c819634c477ab68d | Ruby | rparkerson/launch-school | /RB100/oop_with_ruby/object_model/2.rb | UTF-8 | 789 | 4 | 4 | [] | no_license | # What is a module? What is its purpose?
# How do we use them with our classes?
# Create a module for the class you created in exercise 1 and
# include it properly.
# A module lets you access methods and functionality across multiple
# classes.
# Modules can be mixed in with the include method invocation - called... | true |
a6e836badd916c4597cabb61b078e92bc37b71ea | Ruby | tk0358/Refactoring_Ruby | /chapter9/9.6/s1_after1.rb | UTF-8 | 224 | 2.53125 | 3 | [] | no_license | def pay_amount
return dead_amount if @dead
if @separated
result = separated_amount
else
if @retired
result = retired_amount
else
result = normal_pay_amount
end
end
result
end | true |
a3e3b249a3190a6cc78dea44db6bc329757cf6c6 | Ruby | lbvf50mobile/exeptional_ruby_avdi_grimm | /list17.rb | UTF-8 | 306 | 2.890625 | 3 | [] | no_license | class SaveError < StandardError
attr :prev
def initialize(msg, prev = $!)
@prev = prev
super(msg)
end
end
begin
begin
raise "Error One"
rescue => e
raise SaveError, "Error Two"
end
rescue SaveError => e
p e.message
p e.prev.message
end | true |
b41338dacdafa72a6a0b08be03ab3b368810dae5 | Ruby | muydanny/backend_module_0_capstone | /day_4/exercises/methods.rb | UTF-8 | 1,125 | 4.59375 | 5 | [] | no_license | # In the exercises below, write your own code where indicated
# to achieve the desired result. You should be able to run this
# file from your terminal with the command `ruby day_4/exercises/methods.rb`
# example: Write a method below that, when called will print your name
def print_name
p "Severus Snape"
end
def... | true |
3bbd0b1ecf0b0caa8745bd1dce05ede6825ebf45 | Ruby | nilsandrey/tweetstorm | /test/storm_internals_test.rb | UTF-8 | 1,088 | 2.9375 | 3 | [
"MIT"
] | permissive | require 'minitest/autorun'
require 'twitter_client/storm'
class StormSpy < TwitterClient::Storm
def prepend_test(index)
prepend(index)
end
def pager_test(index)
pager(index)
end
end
class StormInternalsTest < Minitest::Test
def setup
@spy = StormSpy.new
@spy.content= 'Magna eros augue tellu... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.