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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
ff63a18ac09121734f2709009b655743a10467be | Ruby | atseng3/Rails-Lite | /lib/rails_lite/controller_base.rb | UTF-8 | 1,244 | 2.578125 | 3 | [] | no_license | require 'active_support/core_ext'
require 'erb'
require_relative 'params'
require_relative 'session'
class ControllerBase
attr_reader :params, :req, :res, :route_params
def initialize(req, res, route_params={})
@req = req
@res = res
@params = Params.new(req, route_params)
@already_rendered = false... | true |
3c31759a2c10e2865be9067c6d36ec32cd539f98 | Ruby | abresler/nba_stats | /app/models/referee.rb | UTF-8 | 725 | 2.84375 | 3 | [] | no_license | class Referee < ActiveRecord::Base
def self.find_full_name(full_name)
full_names = full_name.split(" ")
if full_names.length > 2
return_id = -1
else
matches = Referee.find(:all, :conditions => {:first_name => full_names[0], :last_name=>full_names[1]})
if matches.length == 1
re... | true |
d1a0b68f96bcca189a448d366da86053d9fafd27 | Ruby | dew-uff/vphadoop | /scripts/analysis/parse_logs_stdalone.rb | UTF-8 | 787 | 2.609375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
# Gabriel Tessarolli
Dir.glob('*.txt') do |log_file|
File.open(log_file, "r") do |infile|
exec_time = 0
while (line = infile.gets)
values = line.strip.split(":")
case values[0].strip
when "Job id"
jobid = values[1].strip
... | true |
e46313399b289877c5fbb407e064bba1939aadd5 | Ruby | joonty/chain-reactor | /test/test_json_parser.rb | UTF-8 | 1,846 | 2.625 | 3 | [] | no_license | require 'test/unit'
require 'rubygems'
require 'mocha/setup'
require 'parsers/parser'
require 'parsers/json_parser'
require 'helpers'
# Test case for the <tt>ChainReactor::Parsers::JsonParser</tt> class.
class TestJsonParser < Test::Unit::TestCase
include ChainReactor::TestHelpers
# Test that a ParseError is rais... | true |
f334d011cf4f1ea06c24c8aea23bec19fb631f6d | Ruby | ezekielriva/weather_channel | /app/helpers/application_helper.rb | UTF-8 | 289 | 2.546875 | 3 | [
"MIT"
] | permissive | module ApplicationHelper
def cloud_condition(percentage)
if percentage == 0
'Sunny (Clear)'
elsif percentage < 25
'Mostly Sunny'
elsif percentage < 50
'Partly Cloudy'
elsif percentage < 75
'Mostly Cloudy'
else
'Cloudy'
end
end
end
| true |
e11ec62d8af9a86bb9aed9aa3a1ee87495b3a5d1 | Ruby | FeehAvelar/rubyPuro | /Aula03/Condicionais/If-Else-Elif.rb | UTF-8 | 386 | 3.84375 | 4 | [] | no_license | #puts ('', end = \n)
#print ('' end = '')
puts("What Day is today? ");
day = gets.chomp;
if (day == "Sunday")
time = "little late"
lunch = "Special";
elsif (day == "Holiday")
lunch = "very special";
time = "very time";
else
lunch = "normal";
time = "some minutes to hour";
end
... | true |
46f1aa57f096ddbe31a24603ae08468e82b8074f | Ruby | scottag99/myhomelibrary | /app/models/custom_column_widget.rb | UTF-8 | 2,497 | 2.75 | 3 | [
"MIT"
] | permissive | class CustomColumnWidget < Widget
attribute :column1, :widgetlist
attribute :column2, :widgetlist
attribute :column3, :widgetlist
attribute :column4, :widgetlist
attribute :column5, :widgetlist
attribute :column6, :widgetlist
attribute :column1_width, :enum, values: ("0".."12").to_a, default: "4"
attri... | true |
f41e84ab1a34d6f26887cd2e4fb33d50772601ea | Ruby | NexusClash/NexusClash | /behaviour/effect/skill_prerequisite.rb | UTF-8 | 653 | 2.609375 | 3 | [] | no_license | module Effect
class SkillPrerequisite
attr_reader :parent
attr_reader :link
def initialize(parent, prerequisite)
@parent = parent
@link = Entity::StatusType.find prerequisite.to_i
end
def describe
case @link.family
when :class
"Must be a #{@link.name}."
when :skill
"Must know #{... | true |
9a19adaa0e2670613ca0ea1dc8bd1f37b83c3df0 | Ruby | sdball/code-playground | /advent-of-code/day6/test/grid_without_brightness.rb | UTF-8 | 1,169 | 2.859375 | 3 | [] | no_license | require "minitest/autorun"
require_relative "../grid_without_brightness"
describe GridWithoutBrightness do
subject { GridWithoutBrightness.new }
it "starts with all lights off" do
subject.count_lit_lights.must_equal 0
end
it "can turn on many lights" do
subject.turn_on([0,0], [99,99])
subject.co... | true |
0413712c46bbf6c8210aa3b1bb4b0db43eb616d8 | Ruby | feigningfigure/WDI_NYC_Apr14_String | /w02/d01/Mason_Tang/atm/app.rb | UTF-8 | 888 | 3.734375 | 4 | [] | no_license | require_relative 'classes/atm'
require_relative 'classes/client'
@machine = Atm.new
def menu
puts "What would you like to do?"
puts "A: Check balance"
puts "B: Withdraw"
puts "C: Deposit"
puts "Q: Quit"
command = gets.chomp.upcase
case command
when "A"
puts @machine.display_balance
when "B"
... | true |
4f57333dcc246f570f0bfbaceab02b420e422782 | Ruby | chad/rubinius | /spec/core/ctype/isdigit_spec.rb | UTF-8 | 360 | 2.515625 | 3 | [] | no_license | require File.dirname(__FILE__) + '/../../spec_helper'
describe "CType#isdigit" do
it "returns true if self is between 0..9" do
a = []
"0a1b2C3;4:5d6=7+8p9".each_byte { |b| a << b.isdigit }
a.should == [ true, false, true, false, true, false, true, false, true, false, true,
false, true, false, tr... | true |
341374a2d4043d8776997e77c210920d394ca944 | Ruby | jpstroop/rack-iiif | /lib/iiif/image_response.rb | UTF-8 | 1,559 | 2.796875 | 3 | [
"LicenseRef-scancode-public-domain",
"Unlicense"
] | permissive | module IIIF
##
# An response object for Image requests
class ImageResponse < Response
require 'iiif/image_response/parameter'
autoload :Region, 'iiif/image_response/region'
autoload :Size, 'iiif/image_response/size'
autoload :Rotation, 'iiif/image_response/rotation'
# @!attribute... | true |
6c53f45e2cc6bde6c5ecc44049e242eb9856416d | Ruby | jgayfer/overwatch_league | /spec/mocks/mock_response.rb | UTF-8 | 128 | 2.875 | 3 | [
"MIT"
] | permissive | class MockResponse
attr_reader :code, :body
def initialize(code, body)
@code = code
@body = body
end
end
| true |
65fdbbb36f3e3a0881a4d84edad08a6c2cb89f5b | Ruby | LeoValentim/Fastlane | /git_merge.rb | UTF-8 | 1,475 | 2.59375 | 3 | [] | no_license | module Fastlane
module Actions
module SharedValues
GIT_MERGE = :GIT_MERGE
end
class GitMergeAction < Action
def self.run(params)
end
#####################################################
# @!group Documentation
#####################################################
... | true |
56f930977c436e8d570a274f39828411644a0048 | Ruby | anikchowdhury/anikchowdhury | /program4.rb | UTF-8 | 1,080 | 3.953125 | 4 | [] | no_license | =begin
Assignment-1 Dated:07.06.2013
Program-4
Problem Statement:Fibonacci Series
=end
#Program Starts
=begin
This 'checkValidInput(value)' Method Will Check Whether Valid I/P is given i.e. Not A Positive Integer Or Empty I/P
Return true If Valid I/P Else false
=end
def checkValidInput(value)
flag=true... | true |
3e533a8de08c75797f92162c4e0e7d6c2cc6880d | Ruby | irongaze/iron-enum | /spec/enum/model_spec.rb | UTF-8 | 2,938 | 2.828125 | 3 | [
"MIT"
] | permissive | describe Enum do
describe 'model attributes' do
module AREnum
enum :one, 1
enum :two, 2
enum :thirty_three, 33
end
module AnotherEnum
enum :yo, 10
enum :bob, 20
end
class ARTest < ActiveRecord::Base
enum_attr :enum_field => AREnum, :another_enum =... | true |
9068d5cb9c726530345bc4cbe5a1802a9c21e416 | Ruby | sahidur-prosku/gs1 | /lib/gs1/validations/length_validation.rb | UTF-8 | 558 | 2.640625 | 3 | [
"MIT"
] | permissive | module GS1
module Validations
# Ensures correct length validation.
#
module LengthValidation
def validate_length
errors << 'Invalid length' unless valid_length?
end
def valid_length?
return false unless data
valid_barcode_length? || valid_allowed_length?
e... | true |
c9f32499d77f03e23686e55517fc23898d2a6694 | Ruby | j1wilmot/toddler | /lib/toddler/crawler.rb | UTF-8 | 2,142 | 3.078125 | 3 | [
"MIT"
] | permissive | require 'set'
require 'faraday'
# Follow all relative paths on pages in a domain
# This is single threaded so it isn't particularly fast and won't DDOS sites
# Should check sites' robot.txt before using to ensure sites allow crawling
module Toddler
class Crawler
attr_reader :visited_paths, :queued_paths, :paths_... | true |
6160ca5af8c475b99d474c3e4ef5542036d21732 | Ruby | esther-ng/BankAccounts | /savings_account.rb | UTF-8 | 259 | 2.875 | 3 | [] | no_license | require_relative 'account'
class SavingsAccount < Bank::Account
MINIMUM_BALANCE = 1000
def withdraw(amount, fee = 200)
super
end
def add_interest(rate)
interest = @balance * (rate/100)
@balance += interest
return interest
end
end
| true |
fd2e6c67189760b4061556105a7338e604d5c142 | Ruby | dhouglaspedruzzi/microblog-abler | /app/services/create_notification_service.rb | UTF-8 | 547 | 2.65625 | 3 | [] | no_license | class CreateNotificationService
def initialize user_id, message
@user = User.find_by id: user_id
@message = message
end
def call
OpenStruct.new success?: false, error: 'Usuário não encontrado!' unless @user
send_notification
end
def send_notification
notification = @user.notifications.c... | true |
718ffe35c89b3c5a76c95153b9eaad866d053c8a | Ruby | sad16/thinknetica-ruby | /lesson_2/3_fibonacci_numbers.rb | UTF-8 | 169 | 3.046875 | 3 | [] | no_license | fibonacci_numbers = [0, 1]
while 101 > (next_fibonacci_number = fibonacci_numbers.last(2).sum)
fibonacci_numbers << next_fibonacci_number
end
puts fibonacci_numbers
| true |
d73c8ac11df8073988319d2e549181e6d031a094 | Ruby | shearwaterintl/typeform_data | /test/test_helper.rb | UTF-8 | 3,727 | 2.59375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
require 'typeform_data'
require 'minitest/autorun'
require 'flexmock/minitest'
require 'pry'
class TypeformDataTest < Minitest::Test
def typeform_mock_and_client_for(typeform_id, json)
client = TypeformData::Client.new(ap... | true |
4691fa0de0b7092eb702a62d71fa058a3a6d77fc | Ruby | tpak/digitalPictureFrame | /flickr/flickr_raw_auth.rb | UTF-8 | 4,079 | 2.703125 | 3 | [
"MIT"
] | permissive | #
require 'rubygems'
require 'flickraw'
require 'yaml'
require 'json'
include Logging
# FlickrAuth uses the gem flickraw to authenticate and authorize
# against the Flickr API. More info on the Flickr API can be found on the
# Flickr services page: http://www.flickr.com/services/api
# FlickrAuth uses a Hash 'con... | true |
a914323e460cc37c0e824d89b621ac8514e50061 | Ruby | TheDesignExchange/app | /db/seeds.rb | UTF-8 | 8,712 | 2.96875 | 3 | [] | no_license | # full seed: loads users, design methods, case studies and discussions
require "json"
require 'spreadsheet'
# Seeding Users
users_file = 'users.json'
# File should be in public
def get_data_user(json_file)
file = Rails.root.join('public', json_file);
data_users = JSON.parse(IO.read(file))
end
def process_users(... | true |
d16db50db9c0faf378f28eb9c1d8a6e697ffe7ae | Ruby | uni51/dic-ruby-basic | /phase2/classic_algorithm_eratosthenes.rb | UTF-8 | 625 | 3.984375 | 4 | [] | no_license | def eratosthenes(number)
numbers = (2..number).to_a # 2からnumberまでの配列を用意
primes = [] #素数を入れる配列を用意
while true
target = numbers.shift # 配列の先頭要素を取得
break if !target # nilの場合に終了
primes << target # 素数の配列に追加
to_delete = [] # 削除対象を入れる配列
numbers.each do |x|
to_delete << x if x % target == 0 #割り切れ... | true |
2ecda127ddffea527b1da2dd80887369d7953a61 | Ruby | eliotrhys/sQuid-Final | /controllers/transactions_controller.rb | UTF-8 | 1,333 | 2.578125 | 3 | [] | no_license | require('sinatra')
require( 'sinatra/contrib/all' )
require( 'pry-byebug' )
require_relative('../models/transaction.rb')
require_relative('../models/merchant.rb')
require_relative('../models/tag.rb')
get '/transactions' do #INDEX
@transactions = Transaction.all()
erb(:"transactions/index")
end
get '/all_transact... | true |
0d49ca2f106836d5b2e1fcd71261e7a3613dee95 | Ruby | jhbadger/scripts | /createCoverageListFromPromer | UTF-8 | 894 | 2.875 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'optparse'
require 'ostruct'
require 'rubygems'
require 'csv'
opt = OpenStruct.new
o = OptionParser.new
o.banner << " mummer-csv"
begin
o.parse!
rescue
STDERR << $!.message << "\n"
STDERR << o
exit(1)
end
if (ARGV.size != 1)
STDERR << o
exit(1)
end
csv, rest = ARGV
coverage =... | true |
126591fa9c47639fa0e859124c12597e5dbb71a6 | Ruby | quatro/bw | /lib/license_fee_calculator.rb | UTF-8 | 995 | 3.125 | 3 | [] | no_license | class LicenseFeeCalculator
def calculate(booking)
annual_booking_number = booking.annual_booking_number
usage_fee_rate = percentage_rate(annual_booking_number)
# Get all the rates summed across all of the rooms
room_rates_total = booking.rate_total
# Usage fee based off the rate of the hotel, d... | true |
31781bee39c4ab6ac3d9a44f5749d86becbc9876 | Ruby | willerup/clubman | /lib/tasks/import.rake | UTF-8 | 3,264 | 3.046875 | 3 | [] | no_license | #Name,Grade,Rating,Name,Grade,Assessment,StartRating,Parent(s),Family,Email,Phone
#Aiden Teegarden 1 203 Aiden Teegarden 1 1 Kirsten & Dean Teegarden kirstentee@yahoo.com 338-5227
#Alastair Gough 2 171 Alastair Gough 2 3 148 Paige & Marco Gough paige.somoza@boiseschools.org 608-0207 440-8135
require 'csv'
task :imp... | true |
e8936f8444f33e19e38ce05b057d01fe06581da5 | Ruby | AlexJukes/bank-test | /spec/account_spec.rb | UTF-8 | 1,231 | 2.890625 | 3 | [] | no_license | describe Account do
let(:account) {described_class.new}
let(:deposit) {double:deposit, amount: 100, date: Date.parse('10-01-2017')}
describe '#initialize' do
it 'should initialise with a balance of 0 and no log history' do
expect(account.balance).to eq(0)
expect(account.log.empty?).to be(true)
... | true |
404bfde3282561c4ab5e92d66f7e31663c670004 | Ruby | benmyles/AsyncRedisModel | /lib/async_redis_model/index.rb | UTF-8 | 1,464 | 2.828125 | 3 | [
"MIT"
] | permissive | require 'digest/sha1'
module AsyncRedisModel
class Index
class MissingOptionError < RuntimeError; end
attr_accessor :class_name, :key
def self.build_key(class_name, *args)
["AsyncRedisModel",class_name,args].join(":")
end
def self.encoded_value(val)
AsyncRedisModel::Base.... | true |
107c3189b9258f3cfe2c0abe0f45dd1c08cf2e92 | Ruby | macbury/detox | /app/services/security/verify_url.rb | UTF-8 | 670 | 2.703125 | 3 | [] | no_license | module Security
# Check if url signature is valid and returns decoded url
class VerifyUrl < Service
def initialize(hash:, encoded_url:)
@hash = hash
@encoded_url = encoded_url
end
def call
return decoded_url if decoded_hash == hash
raise ServiceFailure, "Invalid hash(#{hash}) f... | true |
829a37067141e490bd54f659a86570f0af8f90de | Ruby | lullman/phase-0 | /week-5/nums-commas/my_solution.rb | UTF-8 | 4,080 | 4.5 | 4 | [
"MIT"
] | permissive | # Numbers to Commas Solo Challenge
# I spent [] hours on this challenge.
# Complete each step below according to the challenge directions and
# include it in this file. Also make sure everything that isn't code
# is commented in the file.
# 0. Pseudocode
# What is the input? A positive integer
# What is the output?... | true |
c1bedb6e2ebf5a885c7d00ac0490e5682fdda877 | Ruby | alexp/dealframe | /app/models/couppon.rb | UTF-8 | 1,362 | 2.5625 | 3 | [] | no_license | class Couppon < ActiveRecord::Base
belongs_to :company
belongs_to :user
belongs_to :offer
STATUSES = ['niezweryfikowany', 'nowy', 'wykonany', 'odmowa', 'anulowana']
validates_inclusion_of :status, :in => STATUSES,
:message => "{{value}} must be in #{STATUSES.join ','}"
scope :expired,
:c... | true |
c175fa26f28bc151cbdcb74aa40cef7e47bde7ec | Ruby | amb54/MediaRanker | /test/models/vote_test.rb | UTF-8 | 1,084 | 2.578125 | 3 | [] | no_license | require "test_helper"
describe Vote do
describe "validations" do #success case
it "Can be created with all attributes" do
a_work = Work.create(category: "movie",title: "A title",creator: "A name",publication_year: 2017)
a_user = User.create(name: "Anna")
a_vote = Vote.create!(work: a_work, use... | true |
0ce4e004efea044d772eb97e5e3403564d744c56 | Ruby | ltk/s2backup | /sow/dependency_sorter.rb | UTF-8 | 1,936 | 2.9375 | 3 | [] | no_license | module Sow
class DependencySorter
attr_reader :items
def initialize(items)
@items = items.to_a
end
def sorted_items
sorted_tags.map do |tag|
tag_dictionary[tag]
end
end
private
class MissingDependencyError < StandardError
attr_reader :original
def ... | true |
0344a28537e6c4bcc02c25b7a12d1fa5d2753af5 | Ruby | rmf34/oauth_desk_trial | /config/initializers/date_formats.rb | UTF-8 | 357 | 2.8125 | 3 | [] | no_license | # http://ruby-doc.org/core-2.0/Time.html#method-i-strftime
# other app wide formatting for time data can be easily added here
# Usage: <Date>.to_s(:normal_date_time) # => Mar 29, 2014 17:58PM
[Date, Time, DateTime].each do |klass|
# klass::DATE_FORMATS[:short_full_date] = "%b %d, '%y"
klass::DATE_FORMATS[:normal_... | true |
4dff9623b55ccc834a1753e9c30368f5aac74e02 | Ruby | pfaithmtan/W4D2 | /Cats99/app/models/cat.rb | UTF-8 | 323 | 2.890625 | 3 | [] | no_license | class Cat < ApplicationRecord
COLORS = %w(blue red orange black white yellow)
validates :color, inclusion: { in: COLORS, message: "Color is a not a valid color!"}
validates :color, :birth_date, :name, :sex, :description, presence: true
def age
age = DateTime.now.year - self.birth_date.year
age
end
e... | true |
fbb895153984305002d123add305ec4e433d35b8 | Ruby | Evie-Skinner18/dharma_quotes | /lib/dharma_quotes.rb | UTF-8 | 1,462 | 3.109375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require_relative './quote_libraries/dhammapada'
require_relative './quote_libraries/other_texts'
require_relative './quote_libraries/four_noble_truths'
require_relative './quote_libraries/noble_eightfold_path'
require_relative './quote_libraries/pema_chodron_books'
require_relative './quo... | true |
f4e9432f29350123e4ffa616ba2bfbf2665e3958 | Ruby | jesperes/hacks | /java/se.eskilson.projecteuler/ruby/problem24.rb | UTF-8 | 453 | 3.46875 | 3 | [] | no_license | def permute0(list, rest, &block)
rest.each do |n|
restrest = rest.collect { |x| x if x != n }.compact
if restrest.length == 0
block.call(list + [n])
else
permute0(list + [n], restrest, &block)
end
end
end
def permute(list, &block)
permute0([], list, &block)
end
n = 1
... | true |
3f351ce9f335034ce74eb46ba7005b5812fc4398 | Ruby | Lordnibbler/data_structures | /examples/binary_tree | UTF-8 | 416 | 3.140625 | 3 | [] | no_license | #!/usr/bin/env ruby -Ilib
require './binary_tree'
require 'pry'
include BinaryTree
# initialize a $root object
$root = nil
# build the binary tree
%w{to be or not to be}.each do |value|
if $root.nil?
$root = Node.new(value)
else
$root.insert(Node.new(value))
end
end
$root.each do |node|
puts "#{nod... | true |
479ecd7275a6ade73ab18b07fe6eb3d994fc33fc | Ruby | airhorns/thwart | /lib/thwart/role_builder.rb | UTF-8 | 6,599 | 2.65625 | 3 | [
"MIT"
] | permissive | require 'active_support/core_ext/hash/deep_merge'
module Thwart
class ActionOrGroupNotFoundError < StandardError; end
class OutsideRoleDefinitionError < StandardError; end
# Internal class used to build the role objects during configuration
class RoleBuilder
include ActiveSupport::Callbacks
define_ca... | true |
792d43692a281a7a389da8d5cfbf6a7d309d0139 | Ruby | pilcrow/rdbi | /test/test_database.rb | UTF-8 | 6,670 | 2.640625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'helper'
class TestDatabase < Test::Unit::TestCase
def setup
@dbh = mock_connect
end
def assert_transaction(count)
in_transaction = @dbh.instance_variable_get("@in_transaction") ||
@dbh.instance_variable_get(:@in_transaction)
assert_equal(count, in_transaction)
if in_transaction >... | true |
140f82ac5dfe5cf96f5a4ac0410686ff9f6bfed7 | Ruby | kasharaylo/RubyCore-Selenium | /Screencast/ep12.rb | UTF-8 | 115 | 3.15625 | 3 | [] | no_license | class Item
def price
rand(100)
end
end
item1 = Item.new
item2 = Item.new
puts item1.price
puts item2.price | true |
7cfe1ed70783967d61453c77c4671da270dd8f69 | Ruby | anais-c/BookStore | /test/integration/user_stories_test.rb | UTF-8 | 3,540 | 3.0625 | 3 | [] | no_license | #Integration tests simulate a continuous session between one or more virtual users and our application
require 'test_helper'
class UserStoriesTest < ActionDispatch::IntegrationTest
fixtures :products
# A user goes to the index page. They select a product, adding it to their
# cart, and check out, filling in t... | true |
7ab4907c4a8a3376e6c0a7425bb50ec293ebab33 | Ruby | NandiniNayak/classes_objects | /restaurant.rb | UTF-8 | 1,567 | 3.875 | 4 | [] | no_license | require 'terminal-table'
exit = false
class Customer
def initialize(food,orderNo,bill)
@food= food
@orderNo = orderNo
@bill = 0
end
attr_accessor :food,:orderNo,:bill
def menu
# @menu = Hash.new
@menu = {"1.Big Mac" => 8 , "2.Cheese Burger" => 6 , "3.Ham Burger" => 5, "4.MC Chicken" => 6}
... | true |
68cc32733a423ef21e0f374b91447ae86b18d277 | Ruby | department-of-veterans-affairs/caseflow | /app/models/hearing_rooms.rb | UTF-8 | 454 | 2.71875 | 3 | [
"CC0-1.0",
"LicenseRef-scancode-public-domain"
] | permissive | # frozen_string_literal: true
class HearingRooms
ROOMS = Constants::HEARING_ROOMS_LIST.freeze
attr_reader :key
def initialize(key)
@key = key
end
def label
location_hash["label"]
end
private
def location_hash
@location_hash ||= compute_location_hash
end
def compute_location_hash
... | true |
74f5d795d9a6c32a431ca3fac831fbf88c1dd621 | Ruby | ikigaidojo/for-while-until-ruby-loop-exercise | /_exercise_9.rb | UTF-8 | 136 | 3.34375 | 3 | [] | no_license | # using a until loop, write a ruby program that will print all the numbers from 1 to 100.
j = 0 and until j > 99 do j +=1 and puts j end | true |
a91616ffe383415d111eef7d23420c6ab25b661d | Ruby | alain-andre/rottenpotatoes-rails-intro | /app/models/movie.rb | UTF-8 | 439 | 2.765625 | 3 | [] | no_license | class Movie < ActiveRecord::Base
##
# @return all ratings
def self.get_ratings
Movie.select(:rating).distinct.map(&:rating)
end
##
# @param {hash} params Request parameters
# @return all movies filtered by rating
def self.get_all params
if params[:ratings] != nil
Movie.where(:rat... | true |
2ee0ee102d3d79b87000d134ac1372e510961480 | Ruby | marioaquino/vending | /lib/money.rb | UTF-8 | 394 | 3.140625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module Money
def Money.const_missing(key)
VALUES[key]
end
def Money.coin?(value)
COINS.has_value? value
end
def Money.valid_money?(value)
VALUES.has_value? value
end
def Money.token_for(value)
VALUES.key(value)
end
private
VALUES = {:QUARTER => 25, :DIME => 10, :NICKEL => 5,... | true |
58ab482db64477f1a7f2d8800a5e60f7fa11953e | Ruby | lcorr8/broadway-now-cli-gem | /spec/broadway_now_spec.rb | UTF-8 | 909 | 2.734375 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe BroadwayNow do
it 'has a version number' do
expect(BroadwayNow::VERSION).not_to be nil
end
#pseudo code for tests:
# CLI expectations
# greets user
# uses show master list (@@all) in order to list all shows (puts 20 shows)
# allows user to obtain more information on ... | true |
4b699f9858978ab3a1857090db20a09228f3977f | Ruby | dblonc/dblonc-aA-homeworks | /W3D5/W3D5_DIY_ADTs.rb | UTF-8 | 1,006 | 3.578125 | 4 | [] | no_license | class Stack
def initialize
@stack = []
end
def push(el)
@stack += [el]
end
def pop
@stack -= [@stack.last]
end
def peek
@stack.first
end
end
class Queue
def initialize
@stack = []
end
def enqueue(el)
@stack = [el] + @stac... | true |
baf00612b71d25ff202613a00518a93ddd7927ab | Ruby | kmcphillips/digital_stress | /lib/persistence/dnd_5e_data.rb | UTF-8 | 2,240 | 2.671875 | 3 | [] | no_license | # frozen_string_literal: true
module Dnd5eData
extend self
DB_FILE = Global.root.join("dnd5e.sqlite3")
def load
return false if defined?(@loaded)
@db = Sequel.sqlite(DB_FILE.to_s)
spells = @db[:spells].all.map { |s| Spell.new(s) }
@spell_matcher = FuzzyMatch.new(spells, read: :name)
@load... | true |
69f81bdd6eea6b8dbd7b2fedfdf59b784eece48a | Ruby | RobVee88/Blackjack-PDR | /main.rb | UTF-8 | 1,878 | 2.578125 | 3 | [] | no_license | require 'sinatra'
require 'active_record'
# require 'sinatra/reloader'
require 'pry'
require 'pg'
require_relative 'db_config'
require_relative 'models/user'
# to enable random string - when the user loginIn
enable :sessions # sinatra dealing with storing the session for you
### HELPERS METHODS ###
helpers do
def... | true |
561b565631674ca9c44fb67d47280648383e772c | Ruby | NoHomey/cheating-the-system | /task_3R_1.rb | UTF-8 | 1,427 | 3.28125 | 3 | [] | no_license | #Develop a program named FirstName_LastName_ClassNumber_04c4c6.rb
#
#1. you are given two arguments for a folders with files;
#1.1 if there are other arguments they should be discarded;
#2. Find all the files from both folders that are not in the format FirsrName_LastName_digit.rb. If there are duplicates the file must... | true |
d0a61be9d21a5011b8948a53da8239ef3ac3ef23 | Ruby | vendetta546/codewars | /Ruby/8KYU/Multiply2Num.rb | UTF-8 | 278 | 3.6875 | 4 | [] | no_license | =begin
This function has to be called multiply and needs to take two numbers as
arguments, and has to return the multiplication of the two arguments.
=end
# My Solution
def multiply(*args)
args[0] * args[1]
end
# Better Solution
def multiply (*nums)
nums.reduce(:*)
end
| true |
1602463dd638c7313cda18d2dbbd7f49b5a9b060 | Ruby | Maifunti/terminal-paint | /spec/support/test_cursor_display.rb | UTF-8 | 1,046 | 2.515625 | 3 | [] | no_license | # frozen_string_literal: true
require PROJECT_ROOT + '/terminal_paint/display/curses_display_adapter.rb'
# allows us to provide input and capture stdout when using curses library
module Test
class CursesDisplay < TerminalPaint::Display::CursesDisplayAdapter
def self.build(width, height)
new(width, height)... | true |
e553d07e3350d1d4d571a9df66220345a30c6109 | Ruby | arrowcircle/plan | /app/models/concerns/tree_sortable.rb | UTF-8 | 636 | 2.671875 | 3 | [] | no_license | module TreeSortable
extend ActiveSupport::Concern
module ClassMethods
def sort(list = {})
temp = {}
list.each do |key, value|
if temp[value]
temp[value] << key
else
temp[value] = [key]
end
end
temp.each do |parent, cats|
i = 1
... | true |
c2e2b30f60497390a23f2461a2491f4078a1e9b8 | Ruby | caioalonso/jsonapitest | /app/models/page.rb | UTF-8 | 474 | 2.59375 | 3 | [] | no_license | require 'open-uri'
class Page < ApplicationRecord
serialize :h1
serialize :h2
serialize :h3
serialize :links
validates :url, presence: true, url: true
def scrape
doc = Nokogiri::HTML(open(self.url))
self.h1 = doc.css('h1').map { |el| el.text }
self.h2 = doc.css('h2').map { |el| el.text }
s... | true |
ab77b0522b6782fee36da0f57f51fcc77ed2868b | Ruby | Tasha25/LRTHW2016 | /ex0.rb | UTF-8 | 1,371 | 2.828125 | 3 | [] | no_license | #The Setup
Do the following tasks to complete this exercise:
Go to https://atom.io/ with your browser, get the Atom text editor, and install it.
-> done
Put Atom (your editor) in your dock so you can reach it easily.
-> done
Find your Terminal program. Search for it. You will find it.
-> done
Put your Terminal in... | true |
3d5c138939abf6a91ece8a1827aee96b7b96ea42 | Ruby | Maxthreve/euler | /threeAndFive.rb | UTF-8 | 123 | 2.921875 | 3 | [] | no_license | sum = 0
(0..999).each do |i|
if i%5 ==0 || i%3== 0
sum += i
# puts sum
end
end
puts sum
# def returns_sum=(100)
| true |
09df34fa9c61a543c2bcc1521452a093de64e0fc | Ruby | peregrinebalas/backend_prework | /day_3/ex31newgame.rb | UTF-8 | 441 | 4.46875 | 4 | [] | no_license | puts "Hello and welcome to the guessing game!"
puts "If you guess the number between 1 and 10 correctly, you win!"
puts "What is your guess?"
numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
random = numbers.shuffle[0]
guess = gets.chomp
if guess.to_i > 10 || guess.to_i < 1
puts "Sorry, the guess needs to be between 1 and... | true |
04a887bf356c771f30ddd4313718b96e7385d5e5 | Ruby | nigelgomesot/dsap | /design_patterns/structural/adapter.rb | UTF-8 | 938 | 3.625 | 4 | [] | no_license | # REF: https://refactoring.guru/design-patterns/adapter/ruby/example
# Problem: Allow objects with incompatbile interfaces to collaborate
# Solution: define an object that converts the interface of one object so that another object can understand it.
require 'test/unit/assertions'
include Test::Unit::Assertions
clas... | true |
3abc913226a9549c0a6a46ab2742fd93134335e1 | Ruby | antotm99/Jungle-Rails | /spec/user_spec.rb | UTF-8 | 3,950 | 2.53125 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe User, type: :model do
describe 'Validations' do
subject {described_class.new(first_name: 'Anto', last_name: 'Ter-Mesropian', email: 'anto@anto.com', password: '123456', password_confirmation: '123456')}
describe 'Password exists' do
it 'is valid with a valid passw... | true |
d2815ab44145ce9fd809fe45d2019c06d0bc64b0 | Ruby | SeaWar741/Codeacamp | /Prework/semana_3/Miercoles/age.rb | UTF-8 | 642 | 4.3125 | 4 | [] | no_license | require 'date'
class Person
def initialize(date,names)
@date = date
@names = names
end
def age
years_old
end
private
def years_old
current_year = Time.new.year
age = current_year -= @date
"#{@names} is #{age} years old."
end
end
carlos = Person.new(1987,"Carlos")
martha = Pers... | true |
f309c41143eb94f30472a8501c36f0cfd7a0f8f2 | Ruby | florent-augier/RUBY | /MATHS/caesar_cipher2.rb | UTF-8 | 546 | 3.984375 | 4 | [] | no_license | string = "ola les gens"
puts string
ascii = string.chars.map(&:ord)
puts "Voici la chaine de caractères convertie en tableau de décimaux ASCII: "
print ascii
puts "\n"
shifted = ascii.map {|c| c + 8 } # Méthode pour décaler les caractères selon la grille ascii => c + 8
puts "Et maintenant on a décalé tous les déc... | true |
6511a417f83a2cd5f52666984f0145e45b4381fb | Ruby | amygbui/DynamiteRecord | /lib/associatable.rb | UTF-8 | 4,312 | 2.640625 | 3 | [] | no_license | require_relative 'assoc_options'
require 'active_support/inflector'
# require_relative 'tableize'
module Associatable
def belongs_to(name, options = {})
options = BelongsToOptions.new(name, options)
define_method(name) do
object = options.model_class
foreign_key = self.send(options.foreign_key)
... | true |
5ab8271fb4cc9f7603a4f6de3acd27707e3b6e50 | Ruby | AliceNewton/government-digital-strategy | /compiling/minifying.rb | UTF-8 | 1,771 | 2.5625 | 3 | [] | no_license | require_relative "./utils.rb"
class Minifying
def self.minify_js
puts "-> Running R.js optimizer"
%x[cd assets/javascripts && node ../../r.js -o name=app out=built.js baseUrl=. && cd ../../]
puts "-> Replacing JS links in all files"
Dir.glob("built/**/*.html").each do |file|
content = Utils.rea... | true |
04913114d7864eab4a760ee2c167984c2a33c63e | Ruby | ramfjord/my_life | /lib/my_life/create_entries.rb | UTF-8 | 1,309 | 2.90625 | 3 | [] | no_license | module MyLife::CreateEntries
PATH = "/Users/tramfjord/Workspace/my_life"
TEMPLATE_PATH = "#{PATH}/records/template.yml"
def blank_entry
$blank_entry ||= File.read(TEMPLATE_PATH)
end
# returns a String of a blank entry made from a date and the template entry file
def blank_entry_for(date)
"date: '#... | true |
33b1dfd4c3a753b703bf18a34470d1df661d97b0 | Ruby | estein1988/backend_module_0_capstone | /day_7/fizzbuzz.rb | UTF-8 | 629 | 4.21875 | 4 | [] | no_license | x = 1
while x <= 100
if x % 3 == 0 && x % 5 == 0
puts "FizzBuzz"
elsif x % 3 == 0
puts "Fizz"
elsif x % 5 == 0
puts "Buzz"
else
puts x
end
x += 1
end
puts "-" * 20
#bonus
puts "Enter a number: "
print "> "
n1 = $stdin.gets.chomp.to_i
puts "Enter a second number: "
print "> "
n2 = $stdi... | true |
7313dbf60dc4f2e9a811eafe5dd7adf1e3864442 | Ruby | Xaeart/TechTalentSouthRubyBootcamp | /Bookwork/hoursInYear.rb | UTF-8 | 373 | 3.484375 | 3 | [] | no_license | #how many hours in a year?
#there are 365 days in a year
#there are 24 hours in a day
#so, i need to do 365 * 24
hoursInYear = 365 * 24
puts hoursInYear
# how many minutes in a decade?
# a decade is 10 years.
# there are 60 minutes in an hour
# there are 24 hours in a day
# there are 365 days in a year..
hoursInDec... | true |
7b5f4c15da51bde307f8cea75bf30132dd3db2c7 | Ruby | mose89/testing | /classes/todo_list.rb | UTF-8 | 291 | 2.984375 | 3 | [] | no_license | class List
def initialize(tasks)
@tasks = tasks
@completed = false
end
def all_tasks
@tasks
end
def done?
@completed
end
def add_task(task)
@tasks << task
end
def remove_task!(task)
@tasks.delete!(task)
end
def add_list(filepath)
end
end
| true |
631b0989c595ce5a3704fc037d688073da68c4a8 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/anagram/d3d59b1d02704983b4ed5eec28be74b7.rb | UTF-8 | 963 | 3.6875 | 4 | [] | no_license | class Anagram
def initialize(detector)
@normalized_detector = normalize(detector)
end
def match(potential_anagrams)
anagrams = []
index = 0
potential_anagrams.each do |potential_anagram|
@normalized_anagram = normalize(potential_anagram)
if anagram?(
sort_characters_in_wo... | true |
7f2d1326f535ac96a4e9aa319e0770ebb55de305 | Ruby | waingram/md5-service | /md5.rb | UTF-8 | 571 | 2.515625 | 3 | [] | no_license | require "sinatra"
require "open-uri"
get '/md5' do
content_type 'text/plain'
if !params[:url].nil?
identify_with_sha1(params[:url])
end
end
helpers do
def identify_with_sha1(url)
file = open(url) do |io|
fname = URI.parse(url).path[%r{[^/]+\z}]
Dir.mktmpdir { |tmp|
open("#{tmp}/#{f... | true |
d984028fc4227e7cd80bed68f82ad2cb8b6b864c | Ruby | bradx3/quinc | /lib/quinc/sources/basic.rb | UTF-8 | 291 | 2.515625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module Quinc
module Sources
class Basic
attr_reader :path
def initialize(path)
@path = File.expand_path(path)
end
def files
Dir.
glob(File.join(@path, "**", "*")).
select { |f| File.file?(f) }
end
end
end
end
| true |
2a314c8befd4615a18861ba1db5d7797561535fc | Ruby | Raf-Batista/oo-student-scraper-online-web-sp-000 | /lib/scraper.rb | UTF-8 | 1,101 | 3.09375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'open-uri'
require 'pry'
class Scraper
def self.scrape_index_page(index_url)
doc = Nokogiri::HTML(open(index_url))
students = doc.css(".student-card")
array = []
students.each do |student|
info = {}
info[:name] = student.css("h4.student-name").text
info[:location] = student... | true |
d206b82776e8fbda693c971123eea9def2e2cfea | Ruby | mrdevin/scss-lint | /lib/scss_lint/linter/id_with_extraneous_selector.rb | UTF-8 | 800 | 2.515625 | 3 | [
"MIT"
] | permissive | module SCSSLint
# Checks for a selector with an ID combined with some other selector.
class Linter::IdWithExtraneousSelector < Linter
include LinterRegistry
def visit_simple_sequence(seq)
id_sel = seq.members.find { |simple| simple.is_a?(Sass::Selector::Id) }
return unless id_sel
can_be_... | true |
976a9cab008b78bb5c7d4f7576cdd44719d21529 | Ruby | jamescook106/sun_final | /test/models/user_test.rb | UTF-8 | 1,392 | 2.515625 | 3 | [] | no_license | require 'test_helper'
class UserTest < ActiveSupport::TestCase
test "Default User is not admin" do
user=User.new
user.save
if user.admin
assert false, 'Default User is an admin'
else
assert true, 'Default User is not an admin'
end
end
test "Default User is not sadmin" do
use... | true |
cd74141962956cba79faf8d9d1dd7fb08b3afb12 | Ruby | khinezarthwe/researchversion_2 | /counting.rb | UTF-8 | 2,093 | 3.3125 | 3 | [] | no_license | # << seperateuser.rb ........>>> creatingmatrix.rb
#OK! counting the listening count for each song from this result we can construct the
# user song matrix with the weight listenting frequency.
#<< seperateuser.rb ........>>> creatingmatrix.rb
#OK! counting the listening count for each song from this result we can co... | true |
058b44b2a2350d126631408e92f04b191d71a2bd | Ruby | utkarsh2102/AdventOfCode | /2020/day2/day2.rb | UTF-8 | 553 | 3.28125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/ruby
counter_part1 = 0
counter_part2 = 0
ARGF.each_line do |i|
str = i.chomp.to_s
low = str.partition('-')[0].to_i
high = str.partition('-')[2].partition(' ')[0].to_i
key = str.partition(':')[0].partition(' ')[2].to_s
passwd = str.partition(': ')[2].to_s
# Part 1
count = passwd.count(key)
... | true |
4470d9c18ecac9114c6e6efbe29769bd39a8fb66 | Ruby | findoutwho/hasbeen.in | /spec/traveller/traveller_spec.rb | UTF-8 | 2,408 | 2.71875 | 3 | [] | no_license | # encoding: utf-8
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper.rb')
describe "A traveller" do
let(:traveller) { traveller = Travellers.find("Bascht") }
let(:encoding_junkie) { traveller = Travellers.find("encoder") }
let(:amerika) { traveller.find_location("Amerika") }
it "should ini... | true |
9e255a2a90de8e59dff15736bb755144b28e9024 | Ruby | acook/that_object_is_so_basic | /uspec/wrapper_spec.rb | UTF-8 | 3,446 | 2.84375 | 3 | [
"Apache-2.0"
] | permissive | require_relative "uspec_helper"
class ::TestObject < BasicObject; end
obj = ::TestObject.new
toisb = TOISB.wrap obj
bowrap = TOISB.wrap BasicObject.new
arraywrap = TOISB.wrap(Array)
anonwrap = TOISB.wrap(Class.new Class.new)
modwrap = TOISB.wrap(Module.new)
spec "can inspect BasicObject subclasses" do
expected = "... | true |
ce1a7970574439c250f1a1d2ae164fa6e218194b | Ruby | Samplasion/premonition | /lib/premonition/attributes/stacker.rb | UTF-8 | 879 | 2.6875 | 3 | [
"LicenseRef-scancode-proprietary-license",
"MIT"
] | permissive | # frozen_string_literal: true
require 'strscan'
module Jekyll
module Premonition
module Attributes
# Instances of this class are pushed onto the parser stack upon parsing of block attributes.
class Stacker
# Get the string value from the stacker
attr_reader :value
# Get the s... | true |
07d83f6a4d36e955cdbf602c0f80e3710c7f05dd | Ruby | MadiNaf/scrapping | /coinmarketcap.rb | UTF-8 | 1,631 | 3.046875 | 3 | [] | no_license | #! /usr/bin/env ruby
require 'rubygems'
require 'nokogiri'
require 'open-uri'
require 'pry'
require 'uri'
#-----------------------------------------------------------------------------------
def get_all_crypto_names(page)
crypto_names = []
idx = 0
page.xpath('//a[@class="currency-name-container link-secondary"]').... | true |
b345844da96ca4b386c3e228fa613389773ab56c | Ruby | mwewa23/first_programs | /final_test.rb | UTF-8 | 1,180 | 3.84375 | 4 | [] | no_license | # bol = true
# a = 10
# b = 22
# value = bol and a > b
# p value
a = [7, "str", 11]
a << "this"
b = a.pop
c = a.pop
puts c
puts
person = "bobparker"
s = "homer"
if s.length > "2".to_i + 10
person = person + "x"
elsif s.length / 2 >= 3
person = "alice"
elsif 5.0 >= s.length - 3 and s.length - 5 >= 0
person = ... | true |
87d35cf6e202fd075492d639d29882ba85a5bc28 | Ruby | janikgar/TTS-coursework | /Week-1/skills-check/arrays_hashes/04_ice_cream.rb | UTF-8 | 107 | 2.578125 | 3 | [] | no_license | ice_cream = ["vanilla", "chocolate", "rocky road"]
ice_cream.push("strawberry")
puts ice_cream.join(", ") | true |
c8aa6aa6ed51a7358387ce92de2f0e5d7370e9b4 | Ruby | Rpascar1/ruby-collaborating-objects-lab-online-web-ft-090919 | /lib/artist.rb | UTF-8 | 594 | 3.21875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Artist
attr_accessor :name, :songs, :add_song
@@all = []
def initialize(name)
@name = name
@@all << self
end
def name
@name
end
def self.all
@@all
end
def songs
songs = Song.all.select{|song| song.artist == self }
songs
end
def add_song(song)
... | true |
f927f7f993ba4cccf616c65a222aad8fdddf9d9e | Ruby | akradev/smile | /lib/smile/json.rb | UTF-8 | 473 | 2.609375 | 3 | [
"MIT"
] | permissive | module Smile
class Json
class << self
def parse( text )
Smile::Base.logger.info( text )
@result = Yajl::Parser.parse(text)
raise_exception! if has_error?
@result
end
def has_error?
@result["stat"] == 'fail'
end
def error_message
... | true |
a98bcdee286e40dabb769c865d4c291ee9201b70 | Ruby | freerange/method_log | /bin/method_log | UTF-8 | 1,548 | 2.765625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'method_log'
require 'method_log/version'
require 'optimist'
options = Optimist::options do
version MethodLog::VERSION
banner <<-EOS
Display the commit history for a single method.
Usage:
method_log [options] <method-signature>
where <method-signature> is in the Ruby Index for... | true |
9f4a32c97beb871d5610b2ebcb47f609aebace03 | Ruby | vickyberylsystems/training | /ruby_program/count_letter.rb | UTF-8 | 310 | 3.4375 | 3 | [] | no_license | class Sample
def letter_counter(arr, letter)
arr=arr.flatten
puts arr.count(letter)
end
end
lc=Sample.new
lc.letter_counter([
["D", "E", "Y", "H", "A", "D"],
["C", "B", "Z", "Y", "J", "K"],
["D", "B", "C", "A", "M", "N"],
["F", "G", "G", "R", "S", "R"],
["V", "X", "H", "A", "S", "S"]
], "D")
| true |
230e39e55d193956c9dcc1e262277dad9c475462 | Ruby | mohit91189/coursera-1 | /hw1/part3.rb | UTF-8 | 214 | 3.109375 | 3 | [] | no_license | def combine_anagrams(words)
groups = {}
words.each {|word|
array = word.downcase.each_char.sort
groups[array] = [] unless groups.has_key? array
groups[array] << word
}
return groups.values
end
| true |
ce964c6acde295d733b9910dfa130c2f49b3a30a | Ruby | Ralphasaurus/rb101 | /small_problems/easy9/problem_11.rb | UTF-8 | 967 | 4.25 | 4 | [] | no_license | # Given the array...
words = ['demo', 'none', 'tied', 'evil', 'dome', 'mode', 'live',
'fowl', 'veil', 'wolf', 'diet', 'vile', 'edit', 'tide',
'flow', 'neon']
# need to create an hash of hashes with strings as keys and arrays as values
def grouped_ana(array)
storage_hash = {}
array.each do |w... | true |
67bd883c61a8f14f6045818a1cef2a7446aa19d2 | Ruby | atawfique21/caesar_cipher | /caesar.rb | UTF-8 | 560 | 3.765625 | 4 | [] | no_license | def crypt
puts "Enter the sentence you would like to mangle"
userinput = gets.chomp.to_s
puts "Enter the number of times you would like to shift"
shift = gets.chomp.to_i
alphabet = [*'a'..'z', *'a'..'z', *'a'..'z', *'a'..'z', *'a'..'z', *'a'..'z', *'a'..'z', *'a'..'z', *'a'..'z', *'a'..'z', *'a'..'z']
inpu... | true |
e2351a64808c49d2fe64d47f7d9f398a2e07562a | Ruby | sue-hntr/classyparent | /app/models/something.rb | UTF-8 | 434 | 2.828125 | 3 | [] | no_license | require 'net/http'
require 'json'
def itunes_api_response
# encode URI using the URI constant
uri = URI("https://itunes.apple.com/search?term=michael+jackson&entity=song")
# tell Net::HTTP to GET the URI
Net::HTTP.get(uri) # => String
end
# if we require this file in an IRB session, then
# assign itunes_api... | true |
cf671348863ecaa9719586816ffc0cdd09e45c40 | Ruby | nsharmagrepruby/assignments | /sales_tax/test case/test_input_to_item_parser.rb | UTF-8 | 593 | 3.046875 | 3 | [] | no_license | require "minitest/autorun"
require_relative "../item"
require_relative "../input_to_item_parser"
class TestInputToItemParser < Minitest::Test
def setup
@input_to_item = InputToItemParser.new
@item = Item.new(0.85, 'chocolate', false)
end
def test_get_item
assert_equal @item, @input_to_item.get_ite... | true |
5a74faed3589c2722c63e9c319205b129b23385c | Ruby | gavinlaking/vedeu | /test/support/coverage.rb | UTF-8 | 1,329 | 2.796875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
# frozen_string_literal: true
# Find all methods which don't have corresponding test method, or all test
# methods without corresponding method. Produces quite a few false positives,
# but useful for a quick check.
source_files = Dir.glob("lib/vedeu/**/*.rb")
test_files = Dir.glob("test/lib/ved... | true |
8786af384306f6b00fc2c78599b82552be05bd82 | Ruby | pastak/rapid-game-fes-2013 | /RubySDLGame.app/Contents/Resources/lib/ruby/site_ruby/1.8/mygame.rb | UTF-8 | 15,857 | 2.6875 | 3 | [] | no_license | require 'sdl'
module MyGame
class Wave
@@wave = {}
def initialize(filename, ch = :auto, loop = 1)
@ch = ch
@loop = loop
@filename = filename
load(filename)
end
def load(filename)
@@wave[filename] = SDL::Mixer::Wave.load(filename)
end
def self.clea... | true |
e053e32520fc51f595aded7e8edeb6c3fd79cdc5 | Ruby | cflament/S04_R1_mini_jeu_POO | /app.rb | UTF-8 | 997 | 3.609375 | 4 | [] | no_license | require 'bundler'
Bundler.require
require_relative 'lib/game'
require_relative 'lib/player'
player1 = Player.new("Josiane")
player2 = Player.new("José")
def battle(player1,player2)
puts "Voici l'état de chaque joueur : "
player1.show_state
player2.show_state
puts "Passons à la phase d'attaque : "
... | true |
a4e7caf20dc81042be9ff54da7a73c31157bc4c0 | Ruby | Dan-Heintzelman/phase-0 | /week-4/add-it-up/my_solution.rb | UTF-8 | 2,600 | 4.15625 | 4 | [
"MIT"
] | permissive | # Add it up!
# Complete each step below according to the challenge directions and
# include it in this file. Also make sure everything that isn't code
# is commented in the file.
# I worked on this challenge [with: Kevin Sullivan ].
# 0. total Pseudocode
# make sure all pseudocode is commented out!
# define a metho... | true |
2f97d86a97a4e28bfa89a849010d737ea77ad3e6 | Ruby | peggy110336/ruby_hard_way | /ex13/ex13_study_more.rb | UTF-8 | 160 | 2.734375 | 3 | [] | no_license | language1, language2, language3, language4 = ARGV
puts "The script is called: #{$0}"
puts "I can write #{language1}, #{language2}, #{language3}, #{language4}." | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.