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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
c0da9d9c0f32e634e85077ae4b01b954dfce0da9 | Ruby | suryagaddipati/linqr | /examples/linqr2enumerable/ordering_operators_spec.rb | UTF-8 | 1,512 | 2.90625 | 3 | [] | no_license | require 'linqr'
require 'spec_helper'
describe "order by" do
Item = Struct.new(:name , :price, :discount_price)
it "should order by the order by operator" do
words = [ "cherry", "apple", "blueberry" ]
sorted_words = __{
from word in_ words
order_by word
select word
}
sorted_words.... | true |
e4e5fe032ee732f8a6c374157a210d5f71f5d696 | Ruby | learningearnings/Mayhem | /app/models/importers/le/local_rewards_importer.rb | UTF-8 | 3,404 | 2.6875 | 3 | [] | no_license | require_relative './base_importer'
# NOTE: This importer assumes there is a directory at /tmp/le_images, with a structure like:
#
# $ tree -d /tmp/le_images
# /tmp/le_images
# └── images
# ├── localrewards
# └── rewardimage
#
# To test it out:
#
# i = Importers::Le::LocalRewardsImporter.new("/ho... | true |
efde98de2edcc9ab1a1ac69b470f807e9fa09812 | Ruby | bilus/Mary | /www/lib/project.rb | UTF-8 | 207 | 2.546875 | 3 | [] | no_license | class Project
def self.initialize!(project_name)
@names ||= {}
token = rand.to_s
@names[token] = project_name
token
end
def self.name(access_token)
@names[access_token]
end
end | true |
aba2080fad5dee8500496b175e3ed45a11030b6e | Ruby | david-boyd/connect_four | /lib/connect_four/computer.rb | UTF-8 | 815 | 3.390625 | 3 | [] | no_license | require_relative 'player'
require 'tty-spinner'
class Computer < Player
def get_move(valid_columns)
valid_columns = Array(valid_columns)
#Pick a random column
column_choice = valid_columns[Random.rand(valid_columns.length)]
#show computer is thinking to user if there is a prompt
unless prompt.... | true |
5c066c3ce1b90b2d3cc0a40f8377556fdda46c45 | Ruby | I3uckwheat/web_guesser | /web_guesser.rb | UTF-8 | 1,217 | 3.125 | 3 | [] | no_license | require 'sinatra'
require 'sinatra/reloader'
@@secret_number = rand(100)
@@guesses_left = 5
get '/' do
guess = params['guess'].to_i
color = color_choice(guess)
@@guesses_left -= 1
number = select_number
message = @@guesses_left.zero? ? reset : check_guess(guess)
puts @@guesses_left
erb :index, locals: {... | true |
18d41db858538e385e90a76b68172d1260c6c4b8 | Ruby | gevann/advent-of-code-2019 | /ruby/lib/operations/multiply.rb | UTF-8 | 254 | 2.515625 | 3 | [] | no_license | require 'operations/binary_operation'
module Operations
class Multiply < BinaryOperation
def self.call(tape, instruction, _output_stream)
BinaryOperation.(tape, instruction)
end
def self.evaluate(a, b)
a * b
end
end
end
| true |
67dc60381df9a50608f196336a37afee107b48a2 | Ruby | TheCSpider/GLOBO_Queueing_Project | /AgentProcessor/agentProcessor.rb | UTF-8 | 1,848 | 3.046875 | 3 | [
"MIT"
] | permissive | #agentProcessor.rb
# Asks for Clients of the Client Queues it has connected to
# @author = Shad Scarboro
#---------------------------------------------------------------------------
# Existing Ruby Gems
require 'socket'
require 'json'
# Locally defined files/classes/modules
require_relative '../Client/clientCommunica... | true |
e5950ab82278746e31848ee63d54956a2b74fe05 | Ruby | arnavgup/Attendify_iOS | /AttendifyAPI(Swagger)/app/models/student.rb | UTF-8 | 392 | 2.515625 | 3 | [
"MIT"
] | permissive | class Student < ApplicationRecord
has_many :photos
has_many :enrollments
validates_presence_of :andrew_id
validates :andrew_id, uniqueness: true
scope :alphabetical, -> { order(:last_name, :first_name) }
scope :active, -> {where(active: true)}
scope :inactive, -> {where(active: false)... | true |
a0fb11ca94b6b8d78584b2f89da9c4f918df103e | Ruby | evanphx/talon | /lib/talon/environment.rb | UTF-8 | 1,505 | 2.78125 | 3 | [] | no_license | require 'talon/templated_class'
require 'talon/ops'
module Talon
class Environment
def initialize(parent=Environment.toplevel)
@identifiers = {}
@parent = parent
end
@toplevel = nil
def self.toplevel
return @toplevel if @toplevel
t = Environment.new(nil)
t.add "int", ... | true |
fda947292d59e1cf52c20501ab85e8787c42f690 | Ruby | davidpdrsn/underscore-as-a-service | /app/services/underscorer.rb | UTF-8 | 203 | 2.8125 | 3 | [] | no_license | class Underscorer
def self.call(text)
new(text).call
end
def initialize(text)
@text = text
end
def call
RustUnderscorer.underscore(text)
end
private
attr_reader :text
end
| true |
31d168ce98c087ead53753b811b3442637671bad | Ruby | varesc90/nycda-rails-homework | /homework-3/problem-2/problem-2.rb | UTF-8 | 169 | 3.53125 | 4 | [] | no_license | class Animal
def speak
puts "Moo Moo"
end
end
class Dog < Animal
def speak
puts "Woof Woof"
end
end
cow = Animal.new
cow.speak
jumbo = Dog.new
jumbo.speak
| true |
ec1f5c7244b3a9ea277962d6cc5e80ea9b8e7aed | Ruby | norrise120/grocery-store | /lib/customer.rb | UTF-8 | 604 | 3.359375 | 3 | [] | no_license | require "csv"
class Customer
attr_reader :id
attr_accessor :email, :address
def initialize(id, email, address)
@id = id
@email = email
@address = address
end
def self.all
customers = []
CSV.read("data/customers.csv").each do |row|
customer_address = {street: row[2], city: row[3], ... | true |
6a37bb95f2d0eaccbb143bdb9db40e1d26dbbf1c | Ruby | styliii/RubyJobScraper | /employer_3.rb | UTF-8 | 488 | 3.125 | 3 | [] | no_license | # Let's try to implement the save method, which basically interacts with the Database object
# first step?
# Employer's responsibility should include what table it belongs to
require 'sqlite3'
class Employer
attr_accessor :name, :url, :about
def initialize(name="", url="", about="")
@name = name
@url = ur... | true |
914dce5012b397261ae11cb227bd56045274df75 | Ruby | jamccarty99/go_fish_rails | /spec/models/user_spec.rb | UTF-8 | 1,426 | 2.59375 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe User, type: :model do
describe '#name' do
before do
@user = User.new(name: "Example User", password: "foobar", password_confirmation: "foobar")
end
it 'is required' do
@user.name = ""
expect(@user.valid?).not_to be(true)
end
it "should be ... | true |
a81723645733a02a22512d64c57a9be4466b19ab | Ruby | sodabrew/puppet-dashboard | /lib/registry.rb | UTF-8 | 1,705 | 2.65625 | 3 | [
"Apache-2.0"
] | permissive | class Registry
class << self
delegate :add_callback, :each_callback, :find_first_callback, :to => :instance
end
def self.instance
@instance ||= new
end
def add_callback( feature_name, hook_name, callback_name, value = nil, &block )
disallow_uninstalled_plugins do
if block and value
... | true |
dd01c9a34194bf488b60105d010af391e2e11a0a | Ruby | MarcoBgn/bolt-template | /app/models/utility/hist_parameters.rb | UTF-8 | 2,257 | 2.90625 | 3 | [] | no_license | # frozen_string_literal: true
# Helper to facilitate the handling of time period parameters (historical parameters)
class Utility::HistParameters < ApplicationModel
attr_accessor :from, :to, :period
validate :from_before_to?
def initialize(attrs = {})
filtered_attributes = attrs.to_h.symbolize_keys.slice(:f... | true |
963fde3d858f9b494e7e302b005ed326a06b1f0b | Ruby | AJDot/Launch_School_Files | /Exercises/Ruby_Basics/Return/tricky_number.rb | UTF-8 | 229 | 3.9375 | 4 | [] | no_license | # Tricky Number
#
# What will the following code print? Why? Don't run it until you've attempted
# to answer.
#
# def tricky_number
# if true
# number = 1
# else
# 2
# end
# end
#
# puts tricky_number
# ANSWER
# 1
| true |
374504bb985346aa21a37dbea5d029924c86db36 | Ruby | GoldenLion07/parrot-ruby-prework | /parrot.rb | UTF-8 | 276 | 3.671875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Create method `parrot` that outputs a given phrase and
# returns the phrase
def parrot(phrase="Squawk!")
puts phrase #outputs a new line
return phrase #our return disrupts the flow of our program and instead of outputting => nil in irb, it replaces it with "Squawk!"
end | true |
30f1250470dc4eccf9048bd107b192aed0035c7c | Ruby | jmorris3/ttt-10-current-player-bootcamp-prep-000 | /lib/current_player.rb | UTF-8 | 133 | 3.28125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def current_player(board)
turn_count(board).even? ? "X":"O"
end
def turn_count(board)
board.count {|el| el == "X" || el == "O"}
end
| true |
4d578c11b47443769c570175e1be2b916489bab6 | Ruby | NeelTandel-BTC/torrent_test | /HighTensionMaximumDemandTemporarySupply.rb | UTF-8 | 592 | 3.21875 | 3 | [] | no_license | # calculate charge for High_Tension_Maximum_Demand_Temporary_Supply
class HighTensionMaximumDemandTemporarySupply
attr_accessor :unit
FLAT_RATE = 6.96
DEMAND = 800
FIX_KW = 500
UPTO_DEMAND = 25
ABOVE_DEMAND = 30
MONTH = 28
def initialize(unit)
@unit = unit
end
def cal
final_bill = unit * F... | true |
4a973276241bbaf64635c868058fa79310472eb9 | Ruby | okuramasafumi/ginko | /lib/ginko/name_query.rb | UTF-8 | 1,422 | 2.5625 | 3 | [
"MIT"
] | permissive | module Ginko
module NameQuery
def search(query, options={})
limit = options[:limit] || 10
if query.nil? || query.empty?
# parse after limiting number of items for performance reason
parse(data.take(limit))
else
result[query] if cached?(query)
parse(update(query))... | true |
954e8dfd3c6eb4aebca72bd09c3a99c7396086a1 | Ruby | smoip/adventure | /character.rb | UTF-8 | 12,055 | 3.46875 | 3 | [] | no_license | require "magic"
require "qwertyio"
class Character
include Magic
include QwertyIO
def initialize (inName, npcFlag)
@name = inName
@npc = npcFlag
@maxHP = 10
@currentHP = maxHP
@maxMP = 10
@currentMP = maxMP
@attackPoints = 1
@defensePoints = 1
@agility = 1
@ap_mod = 0
@dp_mod = 0
@ag_mod =... | true |
1eb2c7c3d24cb1df5672239a3e57a331073e992c | Ruby | cmaher92/launch_school | /exercises/codewars/consonant_value.rb | UTF-8 | 698 | 3.765625 | 4 | [] | no_license | # consonant value
# https://www.codewars.com/kata/59c633e7dcc4053512000073
require 'pry'
# input
# string; lowercase, alphabetic chars only, no spaces
# output
# int; the highest value substring
# rules
# consonants are any letters of the alphabet except 'aeiou'
# split the given str on any vowels
def solve(s... | true |
f750d71a3ee995ee8dd3eb30fc1fbfbac984e75b | Ruby | MeganRenea/school-domain-nyc-clarke-web-082619 | /lib/school.rb | UTF-8 | 467 | 3.703125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require "pry"
class School
attr_reader :roster, :name
def initialize(name)
@name = name
@roster = {}
end
def add_student(student, grade)
roster[grade] ? roster[grade] << student : roster[grade] = [student]
end
def grade(grade)
roster[grade]
end
def sor... | true |
6afe4866766792447156be879d800c8f26477e30 | Ruby | chasepeeler/isis | /lib/isis/connections/hipchat-smackr.rb | UTF-8 | 2,796 | 2.640625 | 3 | [] | no_license | # HipChat connection
# Uses Smackr's XMPP connection to HipChat
require 'smackr'
require 'isis/connections/base'
class Isis::Connections::HipChatSmackr < Isis::Connections::Base
attr_accessor :client, :rooms
def initialize(config)
load_config(config)
create_smackr
end
# API
def connect
client... | true |
718ab63592ff56ebc0383ab5df987e43ada4013c | Ruby | dmitryS1666/thinknetica_rep | /less_7/carriage.rb | UTF-8 | 330 | 3 | 3 | [] | no_license | load 'module/modules.rb'
class Carriage
include CompanyModule
attr_reader :number, :type
def initialize(number)
@number = number
initial_type
end
def cargo?
type == :cargo
end
def passenger?
type == :passenger
end
protected
attr_writer :type
def initial_type
@type = ''
... | true |
2fb612667511e8c6cc34f8490be59725a13e6d90 | Ruby | aindrayana/codecore-oct-2015 | /day1/d1-forloop.rb | UTF-8 | 102 | 3.28125 | 3 | [] | no_license | # 7...18 from 7 to 17 not including 18
# 7..18 from 7 to 18
for number in 7..18
puts number
end
| true |
68124f4d4d27e678231417f5cd8b559ff099c15a | Ruby | YohannTisserand/student-directory | /exercises/1_to_10.rb | UTF-8 | 1,575 | 4.03125 | 4 | [] | no_license | def input_students
puts "Please enter the names of the students"
puts "To finish, just hit return twice"
students = []
while true do
puts "-- Name please: --"
name = gets.delete("\n")
break if name.empty?
puts "-- Cohort please: --"
cohort = gets.delete("\n")
cohort = "" if cohort.emp... | true |
72820f7f02c6893727e8ab30e201187a425821fc | Ruby | AliceOJJm/yandex-direct-api | /lib/yandex-direct-api.rb | UTF-8 | 2,980 | 2.546875 | 3 | [] | no_license | require 'net/http'
require 'net/https'
require 'json'
require 'yaml'
require 'uri'
module YandexDirect
class RuntimeError < RuntimeError
end
def self.url
configuration['sandbox'] ? 'https://api-sandbox.direct.yandex.com/json/v5/' : 'https://api.direct.yandex.com/json/v5/'
end
def self.configuration
... | true |
0e3526886eee7e8fe14a35c84ed079b5a0be7a4b | Ruby | flatiron-lessons/sinatra-basic-routes-lab-web-071717 | /app.rb | UTF-8 | 293 | 2.71875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require_relative 'config/environment'
class App < Sinatra::Base
get '/' do
"This is the homepage!"
end
get '/name' do
"My name is James."
end
get '/hometown' do
"My hometown is Howard Beach."
end
get '/favorite-song' do
"My favorite song is Love Yours by J Cole."
end
end
| true |
c7760a4f7b20b687bf0b822dbc79dbb46f7f242e | Ruby | glucero/sysshep | /lib/sysshep/xml/generic.rb | UTF-8 | 601 | 2.546875 | 3 | [
"MIT"
] | permissive | module SysShep::XML
class Generic
include Enumerable
attr_reader :agent
def initialize(datapoints, options = {})
@agent = options[:agent]
@datapoints = datapoints.each do |datapoint|
datapoint.host ||= options[:host]
datapoint.client ||= options[:client]
end
end... | true |
fd8cf9a9285b973e2f7e4b7ccfb41cc5acfbe8c0 | Ruby | ichbinorange/AdaCohort14_HW | /w2ex_binary_to_decimal.rb | UTF-8 | 2,490 | 4.53125 | 5 | [] | no_license | =begin
Calculate the decimal value for this binary number using the algorithm you devised in class. Return the decimal value.
Note: Do not use Ruby functions. You may use .length method on the array
and retrieve values at a particular index in the array.
Author using the algorithm you devised in class. You ... | true |
b8703e37a7f470a96c2e4fdd85f1eaf7a886d672 | Ruby | akuhn/euler | /problem_20.rb | UTF-8 | 176 | 3 | 3 | [] | no_license | require_relative 'euler'
# Problem 20
# 21 June 2002
# n! means n (n 1) ... 3 2 1
# Find the sum of the digits in the number 100!
100.factorial.digit_sum.should == 648
| true |
220a64bdc44d98cba71d7c073e8968a598ea44a3 | Ruby | itggot-emil-willbas/Fesk | /slimapp.rb | UTF-8 | 4,949 | 2.609375 | 3 | [] | no_license |
require 'rubygems'
require 'sinatra'
require 'slim'
require 'sqlite3'
require 'byebug'
require 'bcrypt'
require_relative 'module.rb'
include Database
enable :sessions
#Varför kan man inte routa till '/mainadmin' om man först reggar, sen loggar in?
get('/') do
slim(:index)
end
get('/logout') do
session.clea... | true |
193637028b216e6a25f5d3519459732a73c70e3f | Ruby | shoynoi/books-app | /test/models/user_test.rb | UTF-8 | 1,193 | 2.703125 | 3 | [] | no_license | require 'test_helper'
class UserTest < ActiveSupport::TestCase
def setup
@user = User.new(name: "Example User",
email: "user@example.com",
password: "password",
password_confirmation: "password",
postcode1: "123",
... | true |
91984a07911d7a50c28fba2b925fb7e851896499 | Ruby | ToadJamb/ruby_deploy | /test/lib/deploy_support.rb | UTF-8 | 18,018 | 2.5625 | 3 | [] | no_license | # This file contains a module which bridges the gap between test code
# and applciation code.
#--
################################################################################
# Copyright (C) 2011 Travis Herrick #
###########################################################... | true |
3a77016baac4819c33cb8ca762fcc6bf23fc0336 | Ruby | mashiro/saorin | /lib/saorin/request.rb | UTF-8 | 1,645 | 2.703125 | 3 | [
"MIT"
] | permissive | require 'saorin/error'
require 'saorin/dumpable'
require 'saorin/utility'
module Saorin
class Request
include Dumpable
attr_accessor :version, :method, :params, :id
def initialize(method, params, options = {})
@version = options[:version] || Saorin::JSON_RPC_VERSION
@method = method
@... | true |
2727f4b96d7e5abe1f3cb4754d1a450520659abd | Ruby | floriank/codeclimate | /lib/cc/cli/command.rb | UTF-8 | 1,536 | 2.578125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require "highline"
require "active_support"
require "active_support/core_ext"
require "rainbow"
module CC
module CLI
class Command
CODECLIMATE_YAML = ".codeclimate.yml".freeze
def initialize(args = [])
@args = args
end
def run
$stderr.puts "unknown command #{self.class.n... | true |
75c2ddadd456e51c4e4377526eb3b925fb6a3758 | Ruby | DercilioFontes/jungle-rails | /spec/models/user_spec.rb | UTF-8 | 4,125 | 2.546875 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe User, type: :model do
describe "Validations" do
it "must not be created with different password and password_corfimation" do
@user = User.create(first_name: 'Sylvia', last_name: 'Almeida', email: 'sylvia@gmail.com', password: 'KkKk', password_confirmation: 'KtKk')
... | true |
eaab523c2a6a08af2d5e3b3e0abe1f35191b55b3 | Ruby | sxua/dynamics | /base/templates/patches.rb | UTF-8 | 159 | 2.609375 | 3 | [
"MIT"
] | permissive | class Object
def swizzle(method, &block)
self.class.send(:alias_method, "old_#{method.to_s}".to_sym, method)
self.instance_eval &block
end
end | true |
7bac051ff65a2d7d30a4aca2db54d9e8454b3727 | Ruby | KoukiKishida/furima-34299 | /spec/models/product_spec.rb | UTF-8 | 4,749 | 2.671875 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe Product, type: :model do
before do
@product = FactoryBot.build(:product)
end
describe '商品出品機能' do
context '商品出品がうまくいくとき' do
it '画像と商品名、商品説明、カテゴリー、商品状態、配送料負担、発送元の地域、発送までの日数、販売価格が存在すれば登録できる' do
expect(@product).to be_valid
end
it '販売価格9,999,... | true |
a49751451b9563bca5f331b007cf9dd57b871674 | Ruby | mikiok/IronHack-Prework | /ShoppingCart.rb | UTF-8 | 1,022 | 3.75 | 4 | [] | no_license | class Item
attr_reader :name, :price
def initialize(name, price)
@name = name
@price = price
end
end
class Houseware < Item
end
class Fruit < Item
end
class ShoppingCart
def initialize
@items = []
@articles = 0
end
def add_item(item)
@items.p... | true |
b1f2fead4478c7bef4d04c4ed402ede943b94169 | Ruby | eriksacre/todolist | /app/exhibits/exhibit.rb | UTF-8 | 2,873 | 2.6875 | 3 | [] | no_license | class Exhibit < SimpleDelegator
@@exhibits = []
def initialize(model, context)
@context = context
super(model)
end
def self.exhibits
# @@exhibits
[
IncompleteTaskExhibit,
CompleteTaskExhibit,
TaskListExhibit,
ActivitiesExhibit,
ActivityExhibit,
Enumerabl... | true |
adce6669216a4f1193f1f543e83b5a3aeb30e8bb | Ruby | chrisdel101/object_oriented_programming | /paperboy.rb | UTF-8 | 917 | 3.65625 | 4 | [] | no_license | class Paperboy
attr_reader :earnings
attr_reader :experience
def initialize(name, side)
@name = name
@experience = 0
@side = side
@earnings = 0
end
def quota
(@experience * 0.5) + 50
end
#
def deliver(end_address, start_address)
houses = ((end_address.to_f - start_address + 1) ... | true |
354cae7d03d6e7dff5037fbaf6bc17607522c412 | Ruby | trizen/sidef | /scripts/RosettaCode/haversine_formula.sf | UTF-8 | 837 | 3.671875 | 4 | [
"Artistic-2.0"
] | permissive | #!/usr/bin/ruby
#
## http://rosettacode.org/wiki/Haversine_formula
#
class EarthPoint(lat, lon) {
const earth_radius = 6371 # mean earth radius
const radian_ratio = Num.pi/180
# accessors for radians
method latR { self.lat * radian_ratio }
method lonR { self.lon * radian_ratio }
metho... | true |
255aa88d64993ff5cf4218ab64a0fdeb42e46360 | Ruby | mrtbld/practice | /advent-of-code/2018/day4/part_one.rb | UTF-8 | 136 | 2.625 | 3 | [] | no_license | require_relative 'common.rb'
input = File.readlines('input')
guard_id, minute = find_sleepy_guard(input, &:sum)
puts guard_id * minute
| true |
52918a460b07ccf6d7da481deca9ce81029d4eec | Ruby | monochromegane/pendulum | /lib/pendulum/command/apply.rb | UTF-8 | 848 | 2.671875 | 3 | [
"MIT"
] | permissive | module Pendulum::Command
class Apply
attr_accessor :client, :dry_run, :force
def initialize(client, from, to, dry_run=false, force=false, color=false)
@schedules = matched_schedules(client, from, to, dry_run, force, color)
end
def execute
@schedules.each{|s| s.apply }
end
privat... | true |
4fc26eee5f67c7603b8b104a5561e008ce62cbd4 | Ruby | tim-group/Blondin | /saturation-test/test.rb | UTF-8 | 505 | 3.140625 | 3 | [
"MIT"
] | permissive | require "net/http"
THREAD_POOL = []
def for_all_threads(&blk)
100.times { THREAD_POOL << Thread.new(&blk) }
end
def request(path)
http = Net::HTTP.new("localhost", 8082)
http.read_timeout = 500
response = http.get(path)
print '.'
if response.code != '200'
puts "Failed. Response was #{response.code}... | true |
6ff1601782854f0f5a9ff3265bab3156a0212d96 | Ruby | vmar13/ruby-enumerables-generalized-map-and-reduce-lab-nyc-web-021720 | /lib/my_code.rb | UTF-8 | 368 | 3.5 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def map(array)
new_array = []
counter = 0
while counter < array.length
new_array.push(yield(array[counter]))
counter += 1
end
new_array
end
def reduce(array, starting_value=nil)
if starting_value
sum = starting_value
i = 0
else
sum = array[0]
i = 1
end
while i < array.length
sum = ... | true |
bfdb9d2b5e6e452bd415d4e3fa87c69cc3220440 | Ruby | panteha/Makersbnb | /spec/booking_spec.rb | UTF-8 | 1,230 | 2.53125 | 3 | [] | no_license | require_relative '../app/models/booking.rb'
require_relative '../app/models/pendingbooking.rb'
describe Booking do
it 'makes a new booking in the bookings database table' do
space = double(:space, id: 1, available_from: Date.parse('01-06-2017'), available_to: Date.parse('02-06-2017'), save_parents: true, save_... | true |
289029cf700564ef4ebe7a5dff3e74bebb1bc709 | Ruby | ziruinyc/countdown-to-midnight-001-prework-web | /countdown.rb | UTF-8 | 281 | 3.8125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | #write your code here
def countdown(counter)
while counter > 0 do
puts "#{counter} SECOND(S)!"
counter -= 1
end
"HAPPY NEW YEAR!"
end
def countdown_with_sleep(time)
while time > 0 do
puts "#{time} SECOND(S)!"
sleep(10)
time -= 10
end
"HAPPY NEW YEAR!"
end | true |
3db32f98990c00d1eb08edb3a6fd17f58a7128e2 | Ruby | sbonds/ruby-learning | /head first ruby/11 Documentation/pool puzzle.rb | UTF-8 | 430 | 4.21875 | 4 | [] | no_license | array = [10, 5, 7, 3, 9]
first = array.shift
puts "We pulled #{first} off the start of the array."
last = array.pop
puts "We pulled #{last} off the end of the array."
largest = array.max
puts "The largest remaining number is #{largest}."
=begin
Output goal:
We pulled 10 off the start of the array.
We pulled 9 off ... | true |
027e8b643adbbd1257a183417386177705f644fd | Ruby | HoustonRaboni/first | /game1.rb | UTF-8 | 1,256 | 4.59375 | 5 | [] | no_license | # get my number game
# written by me
puts "welcome to \'GET MY NUMBER !\'"
#get the player name and greet him
print "what's your name: "
input = gets
name = input.chomp #is great for cleaning up string return from gets()
puts "welcome #{name}!"
=begin
puts name.inspect
p name
puts 42.methods
puts 42.enum_for
puts... | true |
b8e108daebbe6bcaa9856ece6a5fdd3768654b2f | Ruby | elijahkim/Metis-Prework | /bottles_of_beer_recursive.rb | UTF-8 | 242 | 3.640625 | 4 | [] | no_license |
def bottles amt
puts "#{amt} of beer on the wall"
puts "#{amt} of beer!"
puts "take one down, pass it around"
puts "#{amt-1} bottles of beer on the wall!"
puts
if amt>0
bottles (amt-1)
end
end
bottles gets.chomp.to_i
| true |
e0bd2b4c42705e1719208a9fd1614d1e7e5115f6 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/grains/b807b46a29584a9f9969d7b36d295f70.rb | UTF-8 | 328 | 3.453125 | 3 | [] | no_license | # Clase de granos por cada cuadro en un ajedrez
class Grains
attr_reader :total_cuadros
def initialize
@total_cuadros = 64
end
# Potencia de 2 a la n-1
def square(num_cuadro)
2**(num_cuadro - 1)
end
# Total
def total
@total_cuadros.times do |i|
self.total_granos += square(i)
end
... | true |
6d03b0d7d7c0d63b5569f68cf3038ebf349ec51b | Ruby | ma-v/rutabaga_extension | /Le_Wagon_Lectures/Week2/Day2/demo_parsing.rb | UTF-8 | 331 | 2.546875 | 3 | [] | no_license | require 'open-uri'
require 'nokogiri'
ingredient = 'lemon'
url = "http://www.letscookfrench.com/recipes/find-recipe.aspx?s=#{ingredient}"
html_file = open(url).read
html_doc = Nokogiri::HTML(html_file)
html_doc.search('.m_titre_resultat a').each do |element|
puts element.text.strip
puts element.attribute('href')... | true |
27510b8f95e936c87a754b979fd983b51f8fe830 | Ruby | dainiusjocas/labs | /IV_semester/ruby/learning_app/spec/models/exam_spec.rb | UTF-8 | 3,100 | 2.828125 | 3 | [
"Beerware"
] | permissive | require File.dirname(__FILE__) + '/../spec_helper'
describe Exam do
fixtures :users
fixtures :words
fixtures :exams
fixtures :scores
describe Exam, " validations/associations" do
it { should validate_presence_of :title }
it { should have_many :tags }
it { should have_many :scores }
it { shou... | true |
16e50e0f168fd776854eb492cd13eaf80e24a566 | Ruby | aswilliamson19/Week2_day4_Library-lab | /specs/book_spec.rb | UTF-8 | 266 | 2.734375 | 3 | [] | no_license | require('minitest/autorun')
require('minitest/rg')
require_relative('../book')
class BookTest < MiniTest::Test
def setup
@book1 = Book.new('2001: A Space Odyssey')
end
def test_book_name
assert_equal('2001: A Space Odyssey', @book1.name)
end
end
| true |
87e5c5c98179ba9c6e401ae12aba9e4c34364416 | Ruby | moj-analytical-services/tech-docs-gem | /lib/govuk_tech_docs/table_of_contents/heading_tree_builder.rb | UTF-8 | 844 | 3.03125 | 3 | [
"LicenseRef-scancode-proprietary-license",
"MIT"
] | permissive | module GovukTechDocs
module TableOfContents
class HeadingTreeBuilder
def initialize(headings)
@headings = headings
@tree = HeadingTree.new
@pointer = @tree
end
def tree
@headings.each do |heading|
move_to_depth(heading.size)
@pointer.children... | true |
a834142cfb8f29ac1978126204651f99921981c7 | Ruby | fiery-skippers-2014/Kitter | /app/helpers/user.rb | UTF-8 | 421 | 2.75 | 3 | [] | no_license | helpers do
def authenticate(user_name)
user = User.find_by_user_name(user_name)
if user != nil
return true
else
return false
end
end
def time_since_tweet(time_stamp)
minutes = ((Time.now - time_stamp)/60).round
if minutes < 1440
time_stamp.strftime("Posted ... | true |
ac2ffd58a61d2f3b8f37b2d86d46d8e0a03b7823 | Ruby | DavidAMAnderson/student-directory | /directory.rb | UTF-8 | 1,757 | 4.3125 | 4 | [] | no_license | def input_students
puts "Please enter the names of your students"
puts "To finish, just hit return twice"
students = []
name = gets.chomp
while !name.empty? do
students << {name: name, cohort: :november}
puts "Now we have #{students.count} students"
name = gets.chomp
end
students
end
def prin... | true |
f912f86a62c7c75731b891ef919b39e2a1d3bf92 | Ruby | ohnickmoy/ruby-enumerables-cartoon-collections-lab-nyc-web-100719 | /cartoon_collections.rb | UTF-8 | 531 | 3.421875 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def roll_call_dwarves(array)
array.each_with_index { |item, index| puts "#{index + 1}. #{item}" }
end
def summon_captain_planet(planeteer)
planeteer.map { |call| call.capitalize + "!" }
end
def long_planeteer_calls(calls)
longFlag = false
calls.map { |x| if x.length > 4 then longFlag = true end }
longFlag
e... | true |
6589214ff763c8d9d8cd054dd69ebbd4c11a2882 | Ruby | hightower86/tn_lessons | /Lesson_09/route.rb | UTF-8 | 844 | 3.375 | 3 | [] | no_license | require_relative 'validation'
require_relative 'modules'
require_relative 'station'
class Route
include InstanceCounter, Validation
attr_reader :route
# attr_accessor :start_station, :end_station
validate :start_station, :presence, Station
validate :end_station, :type, Station
def initialize(start_stat... | true |
bbb3ed453b73ba8511f9bb6cc0c56b9323fe8389 | Ruby | rocky/rbx-trepanning | /test/unit/test-app-iseq.rb | UTF-8 | 1,667 | 2.71875 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'test/unit'
require 'rubygems'; require 'require_relative'
require_relative '../../app/iseq'
class TestAppISeq < Test::Unit::TestCase
def test_disasm_prefix
meth = Rubinius::VM.backtrace(0, true)[0].method
assert_equal(' -->', Trepan::ISeq.disasm_prefix(0, 0, meth))
assert_eq... | true |
92f1d4dfbc8dc03c74d401e266f2fde562bccd9e | Ruby | masterkain/rmega | /lib/rmega/progress.rb | UTF-8 | 1,006 | 3.3125 | 3 | [
"MIT"
] | permissive | module Rmega
class Progress
def initialize(params)
@total = params[:total]
@caption = params[:caption]
@bytes = 0
@start_time = Time.now
show
end
def show
percentage = (100.0 * @bytes / @total).round(2)
message = "[#{@caption}] #{humanize(@bytes)} of #{humaniz... | true |
ee9d0997b4634019423be694b45237f6984640d5 | Ruby | aceimdevelopment/aceim | /config/initializers/string.rb | UTF-8 | 565 | 3.140625 | 3 | [] | no_license | #encoding: utf-8
class String
def normalizar
string = self.strip.gsub(" ","")
string = self.strip.gsub("'","")
string = string.gsub("á","a")
string = string.gsub("é","e")
string = string.gsub("í","i")
string = string.gsub("ó","o")
string = string.gsub("ú","u")
string = string.gsub("ñ",... | true |
5a39f9538b753a819b6b6f70c3a8c57b24ed0d8b | Ruby | juanmaberrocal/wkndr-cr | /app/helpers/controller_error_response_helper.rb | UTF-8 | 690 | 2.734375 | 3 | [] | no_license | module ControllerErrorResponseHelper
# build all error responses the same way
def build_error_response(messages, status=:unprocessable_entity)
# return json { errors: [messages] }, status: :code
render json: { errors: flatten_messsages(messages) }, status: check_status_code(status)
end
private
# ensure error... | true |
f8e7ce0294aa1cc65981097c61c41c1a447a5c76 | Ruby | RudeWalrus/git-hub-gist-adder | /lib/gistfile.rb | UTF-8 | 391 | 3.03125 | 3 | [] | no_license | class GistFile
def initialize(file_array)
@file_array = file_array
end
def file_name
p @file_array.first
@file_array.first.keys.first
end
def content
@file_array.first['test_file']['content']
end
def ==(other)
if other.class != self.class
false
else
self.file_name... | true |
09569bb203b4e7444cdea91e7b930e7ee46f2796 | Ruby | thomasrogers03/cassandra_model | /lib/cassandra_model/v2/read_query.rb | UTF-8 | 2,153 | 2.5625 | 3 | [
"Apache-2.0"
] | permissive | module CassandraModel
module V2
class ReadQuery
attr_reader :column_names, :hash
def initialize(table, select_columns, restrict_columns, order, limit)
@table_name = table.name
@select_columns = select_columns
@column_names = @select_columns.any? ? @select_columns : table.colum... | true |
9e19a4f264f8ab6a983c5c3854a1692a4f94ef90 | Ruby | srobert1953/introduction-to-programming | /flow_control/conditionals2.rb | UTF-8 | 992 | 4.28125 | 4 | [] | no_license | # cnoditionals2.rb
# more conditionals
# puts "Is it 3 or 25?"
# input = gets.chomp.to_i
# if input == 3
# puts "3? you're the boss!"
# elsif input == 25
# puts "That's right, 25 it is."
# else
# puts "Awhh... you don't listen..."
# puts "Let's try again... 3 or 25?"
# input2 = gets.chomp.to_i
# if inpu... | true |
ee0f2690f3f376ce8769073d0055d7b62bee199b | Ruby | hotsdm/Python_ruby | /Container_loop/1.rb | UTF-8 | 101 | 2.8125 | 3 | [] | no_license | members = ['SDM', 'Single']
i = 0
while i < members.length do
puts(members[i])
i = i + 1
end
| true |
21068183b6cb6ddf396e4eab4f91d93cb1c0a928 | Ruby | vzaffalon/account_movement_challenge | /csv_importer.rb | UTF-8 | 3,027 | 3.28125 | 3 | [] | no_license | # frozen_string_literal: true
require 'csv'
require 'redis'
@redis = nil
@accounts_csv = nil
@transactions_csv = nil
@parsed_accounts_csv = nil
@parsed_transactions_csv = nil
class String
def is_number?
true if Integer(self)
rescue StandardError
false
end
end
def receive_args
if ARGV[0].nil? || ARGV... | true |
33f40c3c91b7ac61e28d8765be25b3b114fe5f6d | Ruby | MBARI-ESP/ESP2Gmisc | /ruby/sourceref.rb | UTF-8 | 10,861 | 3.046875 | 3 | [] | no_license | ################## sourceref.rb -- brent@mbari.org #####################
# $Source$
# $Id$
#
# The SourceRef class relies on a patched version of ruby/eval.c
# to provide access to the source file and line # where every Method
# or Proc is defined. SourceRef is a container for these and implements
# methods to:
... | true |
84dc79c9e0edc4cce1dc188d81152a77bad9e600 | Ruby | neilb14/euler | /ruby/36/double-base-palindromes.rb | UTF-8 | 284 | 3.546875 | 4 | [] | no_license | def is_palindrome(num)
digits,length = num.to_s.chars, num.to_s.length
for i in 0..(length/2)
return false unless digits[i] == digits[length-1-i]
end
true
end
sum =0
for n in 0..999_999
next unless is_palindrome(n)
next unless is_palindrome(n.to_s(2))
sum += n
end
puts sum | true |
e6261c36aac744cbc890ccfd149273a3ffa27338 | Ruby | rahmanifarid/chess | /Chess/pawn.rb | UTF-8 | 1,158 | 3.21875 | 3 | [] | no_license | require_relative 'piece'
class Pawn < Piece
def moves
moves = []
x , y = position
dirs = move_dirs
x1 = position[0] + dirs[0][0]
if board[[x1,y]].is_a?(NullPiece)
moves << [x1, y]
end
if color == :white && position[0] == 1 || color == :black && position[0] == 6
x2 = positi... | true |
5f43200e96bfdaf93630dfd463b45c055a0a0435 | Ruby | DerekTownsend/my-collect-prework | /lib/my_collect.rb | UTF-8 | 114 | 3.140625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def my_collect(array)
i=0
temp=[]
while i<array.length
temp<< yield(array[i])
i+=1
end
temp
end
| true |
057bedb16d7f4c228de1d47de0c1afe1e5a6cc5e | Ruby | kahlil29/GEC-Spectrum-Hackathon | /feature_extraction.rb | UTF-8 | 3,315 | 3.25 | 3 | [] | no_license | require 'sentimentalizer'
require 'sinatra/activerecord'
require 'sqlite3'
require 'sinatra'
set :database, {adapter: "sqlite3", database: "ReviewsDb"}
class Reviews<ActiveRecord::Base
end
def startSearch
heating_count = 0
camera_count = 0
display_count = 0
memory_count = 0
Sentimentalizer.setup
Revie... | true |
4ca0d8e2af44429c4f14ae636529ec214f222285 | Ruby | bblack16/cli_chef | /lib/cli_chef/apps/media_info.rb | UTF-8 | 2,848 | 2.515625 | 3 | [
"MIT"
] | permissive | require 'cli_chef' unless defined?(CLIChef::VERSION)
require_relative 'media_info/file'
class MediaInfo < CLIChef::Cookbook
self.description = 'MediaInfo is a convenient unified display of the most relevant technical and tag data for video and audio files.'
add_exit_codes(
{ code: 0, description: 'No error' }... | true |
dfe3be801a6dfcac3a6d1d60bf22fc158c4c476d | Ruby | pedroandrade/downloader | /down.rb | UTF-8 | 1,899 | 2.96875 | 3 | [] | no_license | require 'rubygems'
require 'eventmachine'
require 'set'
require 'fiber'
require 'em-http'
class Downloader
def initialize www, workers = 10, &block
@queue = [{:url => www, :type => :head, :other => nil}]
@visited = {}
@traversers = {}
@workers = []
@worknum = workers
instance_eval &block... | true |
7d6535f046a38e3a96fe595b1279f39ed9c93d29 | Ruby | thomaslindback/pepper_ruby | /pepper_object_send_3.rb | UTF-8 | 592 | 3.828125 | 4 | [] | no_license | #pepper_send
# Object is called a reciever
# send ,essages to object
class P
attr_accessor :name
def initialize n
@name = n
end
def greeting
"Hello #{@name}"
end
def setter m
self.send("name=", m)
end
end
puts 4+5
puts 4.+ 5
puts 4.send :+,5
puts ""
#p = P.new 'thomas'
#puts p.name
#p.name... | true |
34347461a8b04dc71cffccacf43500c5319ac037 | Ruby | XuVic/isspay_api | /app/supports/array_helper.rb | UTF-8 | 126 | 3.046875 | 3 | [] | no_license | module ArrayHelper
def to_range(array)
min = array[0] || 0
max = array[1] || Float::INFINITY
min..max
end
end | true |
4887be0f90f1b7d0c8d636b636cf68323a50d5fa | Ruby | DeeGee1015/Rumblr | /server.rb | UTF-8 | 1,733 | 2.515625 | 3 | [] | no_license | require "sinatra"
require "sinatra/activerecord"
if ENV['RACK_ENV']
ActiveRecord::Base.establish_connection(ENV['DATABASE_URL'])
else
set :database, {adapter: "sqlite3", database: "database.sqlite3"}
end
enable :sessions
class User < ActiveRecord::Base
end
class Post < ActiveRecord::Base
end
get "/" do
erb... | true |
848b554c9f8e3a6df83fcc19a57e3fdf0423b223 | Ruby | JaredRoth/headcount | /lib/module_helper.rb | UTF-8 | 682 | 3.15625 | 3 | [] | no_license | require_relative "errors"
module Helper
def error?(condition)
raise UnknownDataError unless condition
end
def truncate(value)
value.to_s[0..4].to_f
end
def sanitize_data(input)
input.to_s.gsub!(/[\s]+/,'')
input = input.to_f if String === input
truncate(input)
end
def sanitize_dat... | true |
3d24b81373e9926e22311c685f472c76abc1c75f | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/word-count/be3cf32e6a234fb9b69b451d46042a52.rb | UTF-8 | 451 | 3.59375 | 4 | [] | no_license | class Phrase
def initialize phrase
@phrase = phrase
end
def word_count
@word_count || populate_word_count(@phrase) && @word_count
end
private
def add_word word
@word_count[word] += 1
end
def populate_word_count phrase
@word_count = Hash.new(0)
words = extract_word_list phrase
... | true |
8b8f2440f7085f2ccbca62441add4d9bc9ed9125 | Ruby | jmondo/bus_tracker | /bus.rb | UTF-8 | 736 | 2.546875 | 3 | [] | no_license | require 'sinatra'
require 'json'
require 'httparty'
get '/' do
content_type :json
{potrero: predictions(0), pacific: predictions(1)}.to_json
end
def predictions(index)
prediction_objects = [xml["body"]["predictions"][index]["direction"]].flatten.collect { |h| h["prediction"] }.flatten
minutes = prediction_obj... | true |
5a2c9e86592466df18aa71a5ebe2399a2b4e844c | Ruby | vincentwoo/misc | /euler_12.rb | UTF-8 | 355 | 3.203125 | 3 | [] | no_license | triangles = Enumerator.new do |yielder|
num = 1
sum = 1
loop do
yielder.yield sum
num += 1
sum += num
end
end
triangles.each do |triangle|
divisors = 0
(1..Math.sqrt(triangle).ceil).each do |factor|
divisors += 2 if triangle % factor == 0
end
# p [triangle, divisors]
if divisors > 500... | true |
57e0b7f86a295362e407b8796b9c31a0b5e8d169 | Ruby | laranicolas/leetcode | /two_sum.rb | UTF-8 | 1,408 | 4.09375 | 4 | [] | no_license | # Given an array of integers, return indices of the two numbers such that they add up to a specific target.
# You may assume that each input would have exactly one solution, and you may not use the same element twice.
# Example:
# Given nums = [2, 7, 11, 15], target = 9,
# Because nums[0] + nums[1] = 2 + 7 = 9,
# r... | true |
9255699a6fbd268c1445c22ba4f09565d47b7384 | Ruby | Inglorion-G/AppAcademy | /Week1/W1D5/knight.rb | UTF-8 | 2,608 | 3.703125 | 4 | [] | no_license | class KnightPathFinder
MOVE_POSITIONS = [
[+1,+2],
[-1,-2],
[+1,-2],
[-1,+2],
[+2,+1],
[+2,-1],
[-2,+1],
[-2,-1]
]
attr_accessor :start_pos, :tree
def initialize(start_pos)
@start_pos = start_pos
@tree = create_node(self.start_pos)
build_move_tree
end
def crea... | true |
97c0eee73a9f5edce16226de7b1f116770478bf0 | Ruby | bragnikita/readmanga-downloader | /test/download_task_test.rb | UTF-8 | 3,485 | 2.515625 | 3 | [
"MIT"
] | permissive | require 'minitest/autorun'
require 'minitest/unit'
require 'shoulda'
require 'pathname'
require 'fileutils'
require_relative '../lib/readmanga_dldr'
MD = ReadMangaDownloader
class DownloadTasktest < Minitest::Test
context 'After initialization' do
setup do
@root_dir = Dir.mktmpdir 'manga_root'
FileU... | true |
8a7bc515aeb006c696dc4da409356130ec1b8d42 | Ruby | codeAligned/super_happy_interview_time | /rb/lib/leetcode/lc_617.rb | UTF-8 | 1,630 | 3.71875 | 4 | [
"MIT"
] | permissive | # frozen_string_literal: true
module LeetCode
# 617. Merge Two Binary Trees
module LC617
TreeNode = Struct.new(:val, :left, :right)
# Description:
# Given two binary trees and imagine that when you put one of them to cover the other,
# some nodes of the two trees are overlapped while the others ar... | true |
74114dab8332aa66583d0744d2dd273eaef2f279 | Ruby | KurisuFin/ratebeer | /app/models/brewery.rb | UTF-8 | 836 | 2.71875 | 3 | [] | no_license | class Brewery < ActiveRecord::Base
include RatingAverage
has_many :beers, dependent: :destroy
has_many :ratings, through: :beers
validates :name, presence: true
validates :year, numericality: { only_integer: true }
validate :inspect_year
scope :active, -> { where active:true }
scope :retired, -> { where act... | true |
df50a6122b157fddf13d416e890546a4edfa4937 | Ruby | akanksha007/fabelio | /app/controllers/users_controller.rb | UTF-8 | 833 | 2.59375 | 3 | [] | no_license | class UsersController < ApplicationController
# to list all the images in asc order of their position
def index
@users = User.all.order(:position)
end
# to pass a user object to view so as help storing it in db
def new
@user = User.new
end
# to save the user input value in database
def create
@user = U... | true |
b3a91054f08d4e303d867608f5f2054a1bfd616f | Ruby | adamruzicka/taggata | /lib/taggata/persistent/directory.rb | UTF-8 | 1,817 | 2.609375 | 3 | [
"BSD-2-Clause"
] | permissive | module Taggata
module Persistent
class Directory < Abstract
include ::Taggata::Persistent::WithParent
attr_reader :db, :name, :parent_id, :id
def initialize(db, name, parent_id = nil, id = nil)
@db = db
@name = name
@parent_id = parent_id
@id = id
end
... | true |
57d07245747d2362259b410891272c81f53e32d9 | Ruby | wordkarin/BankAccounts | /savings_test.rb | UTF-8 | 1,841 | 3.25 | 3 | [] | no_license | require_relative 'savings_account'
puts "SAVINGS TEST - $10 open amount, withdrawl fail"
sa = Bank::SavingsAccount.new(1212, 2014, 1000)
puts sprintf("New %s opened with balance of $%0.02f, account number: %i.", sa.class.to_s, sa.balance/100.to_f, sa.account_id)
puts "withdraw $1" #expect this to fail, because minimu... | true |
5c1adce5daf5c57511de1893c78b5a810cf85206 | Ruby | MiguelSavignano/graphql-ruby | /spec/graphql/schema/interface_spec.rb | UTF-8 | 2,522 | 2.59375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require "spec_helper"
describe GraphQL::Schema::Interface do
let(:interface) { Jazz::GloballyIdentifiableType }
describe "type info" do
it "tells its type info" do
assert_equal "GloballyIdentifiable", interface.graphql_name
assert_equal 2, interface.fields.size
en... | true |
9e023f401ad983580aba0f3dbc7105163f26a836 | Ruby | wilbertom/aws_provisioner | /spec/aws_provisioner/extensions_spec.rb | UTF-8 | 392 | 2.765625 | 3 | [
"MIT"
] | permissive | describe "Language extensions" do
describe "Symbol#camelize" do
it "transforms a single word symbol" do
expect(:example.camelize).to eq("Example")
end
it "camel cases two words or more seperated by underscores" do
expect(:another_example.camelize).to eq("AnotherExample")
expect(:another... | true |
4fda1fc884f7d7648aa25e331562b18571fd5286 | Ruby | msalo3/WordChecker | /WordChecker.rb | UTF-8 | 1,124 | 4.0625 | 4 | [] | no_license | def in_words(array,string)
count=0
array.each do |word|
if word==string
count+=1
end
end
if count>0
puts "The word is in that array!"
else
puts "It's not in that array"
end
end
def possible_words(array,string)
value=true
string_holder=""
temp_input=Array.new(string.length)
c... | true |
b682d16b043ef3ae683cd3934249f757ac1411ab | Ruby | moofmayeda/hacker-news | /app/models/link.rb | UTF-8 | 507 | 2.5625 | 3 | [] | no_license | class Link < ActiveRecord::Base
before_save :url_checker
# has_many :comments
has_many :comments, as: :commentable
validates :url, :presence => true
def vote
self.update(votes: self.votes + 1)
end
def score
days_elapsed = (Time.new - self.created_at)/60.0/60/24
self.votes/days_elapsed
end
... | true |
01396e47f0f2743f4fa077e87f2c7da9e9343f2e | Ruby | sblackstone/project_euler_solutions | /434-2.rb | UTF-8 | 3,618 | 3.21875 | 3 | [] | no_license | =begin
00----01----02----03
| A | B | C |
04----05----06----07
| D | E | F |
08----09----10----11
0,0 0,1 0,2 0,3
1,0 1,1 1,2 1,3
2,0 2,1 2,2 2,3
boxr boxc nodes
2 3 (boxr+1)*(boxc+1)
Edges
Each row has boxc edges
Each col has boxr edges
(boxr+1)*box... | true |
dba011a6dcdcaeef5accf7220f9df3035180dbec | Ruby | vitivey/ruby-objects-has-many-through-lab-v-000 | /lib/patient.rb | UTF-8 | 335 | 3.09375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Patient
def initialize(name)
@name=name
end
def new_appointment(doctor, date)
appointment=Appointment.new(self, doctor, date)
end
def appointments
Appointment.all
end
def doctors
Appointment.all.collect do |appointment|
appointment.doctor
en... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.