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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
5b1f372f7f5ea17f67d62780db384072398ad30d | Ruby | Intetaget/Homework | /OO-tic-tac-toe/Player_tic_tac.rb | UTF-8 | 284 | 3.859375 | 4 | [] | no_license | #require 'pry'
class Player
def initialize(letter)
@name = get_name
@letter = letter
end
def name
@name
end
def letter
@letter
end
def get_move
gets.chomp.to_i
end
private
def get_name
puts "What is your name? Human player"
gets.chomp
end
end | true |
a183a86411116b34a35187403159cbf1a0eac628 | Ruby | silcam/cmbpayroll | /test/models/loan_payment_test.rb | UTF-8 | 2,084 | 2.515625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require "test_helper"
class LoanPaymentTest < ActiveSupport::TestCase
def setup
@luke = employees :Luke
@loan_one = loans :one
end
test "Validate Presence of Required Attributes" do
model_validation_hack_test LoanPayment, some_valid_params
end
test "Get all payments for period" do
anakin =... | true |
605e4f2cdf7b4dcb32cf0e9064fc8246e2537af1 | Ruby | seanmsmith23/matasano-crypto | /lib/set-1/03-single-byte-xor-cypher.rb | UTF-8 | 1,102 | 3.546875 | 4 | [] | no_license | require 'awesome_print'
require 'byebug'
# http://cryptopals.com/sets/1/challenges/3/
class DecryptSingleXOR
def initialize(hex_string, test_array)
@hex = hex_decode(hex_string)
@test_array = test_array
end
def ranked_solutions
scored_solutions.sort_by { |solution| solution[:score] }.reverse
end... | true |
f52eb065416993909de7d5113c679d66f016698c | Ruby | handwerger/launch-school-repo | /chapter_3/3_5.rb | UTF-8 | 102 | 2.890625 | 3 | [] | no_license | def scream(words)
words = words + "!!!!"
puts words
end
scream ("Yipeeee")
#prints "Yipeeee!!!!"
| true |
9f2118c3ddc691798bcd16978814aa5b04e021aa | Ruby | benfurber/bank_ruby | /spec/unit/account_spec.rb | UTF-8 | 964 | 2.828125 | 3 | [
"MIT"
] | permissive | require 'account'
describe Account do
subject { Account.new(transaction_class_double, statement_class_double) }
let(:transaction_class_double) { double 'Transaction', new: transaction }
let(:transaction) { double 'transaction_instance' }
let(:statement_class_double) { double 'Statement', new: statement }
l... | true |
79206d415ae0acc6837e593d6cad017fb5fef266 | Ruby | JK8283/BEWD | /secret_number.rb | UTF-8 | 2,069 | 4.5 | 4 | [] | no_license | def intro
puts "Welcome to the secret number game! Created by John Kim. Type q to quit."
puts "What is your name?"
name = gets.chomp
if name != "q"
puts "Hi #{name}!"
game1
else response = name
end
end
## First guess method.
def game1
secret_number = 5
puts "Guess a number between 1 and 10. You only have 3... | true |
395af3bb5d36393417fc6381d072b0d1b5f227cb | Ruby | sge/beefcake | /lib/beefcake/delayed.rb | UTF-8 | 895 | 2.90625 | 3 | [
"MIT"
] | permissive | module Beefcake
class Delayed
attr_accessor :klass, :bytes, :object
def initialize(klss, byts)
@klass, @bytes = klss, byts
end
def decode
__object__
end
def encode
(@object) ? @object.encode : @bytes
end
def class_from_string(str)
str.split('::').inject(Obj... | true |
1eb3224e9022683c5596d24ce4e6feb356fdec54 | Ruby | fx-kirin/ruby_backtest | /test/test_backtest_order_list.rb | UTF-8 | 3,714 | 2.609375 | 3 | [
"Apache-2.0"
] | permissive | require_relative "test_master"
require_relative "../lib/backtest_order_manager/backtest_order_list"
class TestBacktestOrderList < TestMaster
def setup
@list = BacktestOrderList.new
end
def test_insert_get_update_order
order = @list.new_order
assert_raise(BacktestOrderList::NoDataFoundException, "M... | true |
a11afc036a72dfd8f58913764f92db831dbb874c | Ruby | rebeccanewborn/oxford-comma-prework | /lib/oxford_comma.rb | UTF-8 | 565 | 3.5625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def oxford_comma(array)
# if array.size == 1
# return array[0]
# elsif array.size == 2
# return "#{array[0]} and #{array[1]}"
# else
# output = ""
# counter = 0
# while counter < array.size - 1
# output << "#{array[counter]}, "
# counter += 1
# end
# output << "and #{array[... | true |
3d0914618e40a01a53600ca2700de10413b25258 | Ruby | Jablooo/ATM | /atm_v1.rb | UTF-8 | 3,624 | 4.03125 | 4 | [] | no_license | =begin
****BRIEF****
Use Ruby to create a terminal app that behaves like an ATM in real life.
structure:
- intro to customer and displaying the options.
- use case when for your code
- running each option individually (withdraw, check balance, greeting, deposit)
- use loops
- sign off
TRY ADDING A PIN TO ... | true |
af5353cbd8d275921b8b4620cd8f7e22460758bb | Ruby | bleakwood/web-crawler | /selenium.rb | UTF-8 | 1,468 | 2.546875 | 3 | [] | no_license | require "selenium-webdriver"
require "pry-byebug"
require 'timers'
def collect_data
driver = Selenium::WebDriver.for :firefox
driver.navigate.to "https://mp.weixin.qq.com"
element = driver.find_element(:name, 'account')
element.send_keys "danna@beamalliance.com"
element = driver.find_element(:name, 'password')
... | true |
d29b9705d104b3357d5278f3fb132da1011e044a | Ruby | TakuLibraries/DuplicateFile | /lib/duplicate_file.rb | UTF-8 | 739 | 2.796875 | 3 | [
"MIT"
] | permissive | require "duplicate_file/command"
require "duplicate_file/version"
module DuplicateFile
def self.group_by_checksum(root_path)
all_files = Dir.glob(root_path + "**/*").select{|path| File.file?(path) }
all_files.group_by{|path| Digest::MD5.file(path).to_s }
end
def self.unique!(root_path)
stay_pathes =... | true |
a6d381e1f4aebe55848671390d7e53c8302b1a84 | Ruby | david-azevedo/advent-of-code-2019 | /src/day24.rb | UTF-8 | 1,069 | 2.796875 | 3 | [
"MIT"
] | permissive | lines = File.readlines("../data/#{__FILE__.split('.')[0]}.txt").map(&:strip)
def cal_bio(layout)
bin_layout = layout.join.reverse.gsub('#', '1').gsub('.', '0')
bin_layout.to_i(2)
end
starting_layout = lines
previous_layouts = { starting_layout.join => 1 }
stop = false
until stop
next_layout = Array.new(5) { '.... | true |
018004db6be64a540494e31045a77ae98cda37d1 | Ruby | tsuruhaya/freemarket_sample_64b | /spec/models/user_spec.rb | UTF-8 | 5,292 | 2.921875 | 3 | [] | no_license | require 'rails_helper'
describe User do
describe '#create' do
it "is valid with a nickname, email, password, first_name, last_name" do
user = build(:user)
expect(user).to be_valid
end
# ニックネームが空では登録できない
it "it invalid without a nickname" do
user = build(:user, nickname: nil)
u... | true |
470e4554711fb218ee67ae39d7a71677cde65ac8 | Ruby | timm3/regnow | /mock/main.rb | UTF-8 | 22,584 | 2.734375 | 3 | [] | no_license | require 'sinatra'
require_relative '../requirements'
FILE_CONFIG = File.dirname(__FILE__) + "/classes.csv"
FILE_USERS = File.dirname(__FILE__) + "/users.csv"
FOLDER = 'views/mock/'
FILE_LOGIN = FOLDER + 'login.html'
FILE_LOGOUT = FOLDER + 'banner_logout.html'
FILE_LOGOUTDO ... | true |
5013bf20af134fc258cd1b16f8a957492fc44072 | Ruby | winterle/cryptopal | /set5/dh_mitm_injection.rb | UTF-8 | 1,684 | 2.671875 | 3 | [] | no_license | require_relative 'dh'
g = 2
p = "ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024
e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd
3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec
6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f
24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361
... | true |
c32504607da9fb9f590ce06f33811b548ab0ec79 | Ruby | zohrehj/timestamp_state_fields | /lib/timestamp_state_fields.rb | UTF-8 | 1,608 | 2.703125 | 3 | [
"MIT"
] | permissive | module TimestampStateFields
extend ActiveSupport::Concern
module ClassMethods
# Implements ActiveRecord state fields based on timestamp columns.
#
# Requires a column in the model to have :`state`_at
#
# Example:
#
# class User < ActiveRecord::Base
# include TimestampStateFiel... | true |
0708cac7ba520e42464ca1c420d31d94118c353a | Ruby | patcarrasco/collections_practice_vol_2-dumbo-web-111918 | /collections_practice.rb | UTF-8 | 2,234 | 3.609375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # your code goes here
def begins_with_r(array)
match_array = []
match_array = array.select {|word| word.start_with?('r')}
if array.size == match_array.size
true
else
false
end
end
def contain_a(array)
new = []
array.each do |word|
eval = word.include?('a')
if eval == true
new.push(... | true |
e940cc83caef2f8348ab682a8a4f0bfbfe5b63b9 | Ruby | craigh44/Boris_Bikes | /lib/van.rb | UTF-8 | 739 | 2.859375 | 3 | [] | no_license | require_relative 'bike_container'
class Van
include BikeContainer
def initialize(options = {})
self.capacity = options.fetch(:capacity, capacity)
end
def pick_up_bikes(station)
station.unavailable_bikes.each { |broken_bike|
station.release(broken_bike)
dock(broken_bike)}
end
def full_error_message
... | true |
aa78917dfeb59ab282c5b2e9cc17e278a99b9f72 | Ruby | Zheka1988/ruby_replay | /lesson_1/ideal_mass.rb | UTF-8 | 285 | 3.203125 | 3 | [] | no_license | puts 'Kak vas zovut?'
name = gets.chomp
# puts "Kakoy u vas ves?"
# ves = gets.chomp.to_i
puts 'Kakoy u vas rost?'
height = gets.chomp.to_i
ideal_ves = (height - 110) * 1.15
if ideal_ves < 0
puts 'Vash ves optimalniy!'
else
puts "#{name}, vash idealniy ves = #{ideal_ves}!!!"
end
| true |
a70110c4b2c933e60505ce861db9abfb90f539a9 | Ruby | rwestgeest/dialoogtafels | /spec/lib/csv/person_export_spec.rb | UTF-8 | 2,076 | 2.734375 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
require 'csv/person_export'
module Csv
describe Csv do
let(:people_repository) { mock(PeopleRepository) }
let(:first_person) { Person.new :name => "Piet", :telephone => "123123123", :email => "e@mail.com" }
let(:second_person) { Person.new :name => "Henk", :telephone => "234234234"... | true |
484e0eca560cfad758443b33607c3d11b336c9a7 | Ruby | ryuchan00/Miscellaneous | /option_paser/sample.rb | UTF-8 | 171 | 2.796875 | 3 | [] | no_license | require 'optparse'
opt = OptionParser.new
opt.on('-a', '--add', 'add an item') { puts 'Added' }
opt.on('-d', '--del', 'delete an item') { puts 'Deleted' }
opt.parse(ARGV) | true |
d2e01a99c35ebd1b42f16c48dbe3fd04bb1f7600 | Ruby | graphiti-api/graphiti_spec_helpers | /lib/graphiti_spec_helpers/errors_proxy.rb | UTF-8 | 1,133 | 2.5625 | 3 | [
"MIT"
] | permissive | module GraphitiSpecHelpers
class ErrorsProxy
class Error
attr_reader :json
def initialize(json)
@json = json
end
def attribute
@json[:meta][:attribute]
end
# TODO: move to top-level code in errorable
def code
@json[:meta][:code]
end
... | true |
071cfc4ec8a37c1a6d9a727f75efa7478cf579ad | Ruby | dagpan/ruby-oo-relationships-practice-auto-shop-exercise-nyc04-seng-ft-012720 | /app/models/car.rb | UTF-8 | 717 | 3.203125 | 3 | [] | no_license | class Car
attr_reader :make, :model, :classification
@@all = []
def initialize(make, model, classification)
@make = make
@model = model
@classification = classification
@@all << self
end
def self.all
@@all
# - Get a list of all cars
end
def self.cars_classifications
# - Ge... | true |
5a2f86f8384c25a45754e061888889917008b6dd | Ruby | btwelch/gluestick | /lib/gluestick/onboarding.rb | UTF-8 | 585 | 2.578125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'json'
module Gluestick
class OnboardingCustomer
attr_accessor :customer_email, :customer_name, :customer_phone, :customer_website
def initialize(params = {})
params.each do |k, v|
instance_variable_set("@#{k}", v) unless v.nil?
end
yield self if block_given?
end
d... | true |
2724ae141b33cb7d9511a9b8bfa14ada5cfb8207 | Ruby | annehoogerbrugge/attensi-ec-game | /app/services/weekly_summary.rb | UTF-8 | 1,195 | 2.984375 | 3 | [] | no_license | # frozen_string_literal: true
class WeeklySummary
def initialize(week_number, stat_option)
@week_number = week_number.to_i
@stat_option = stat_option
@scores = {}
end
def find_top_scores
# I forgot to ask; the top players on score,
# is that the total score of the week, or the highest score ... | true |
232f44449651a98a7908afb5b5aa1d88259a9fb9 | Ruby | MattRice12/wk2day-01-assignments | /bob2.rb | UTF-8 | 1,560 | 3.421875 | 3 | [] | no_license | class Bob
attr_accessor :remark
def initialize
@remark = remark
end
def feedback(remark)
puts "Bob hears #{text.inspect}, and.."
end
def shouting
remark.to_s != remark.upcase
end
def shouting_gibberish
remark =~ /^[A-Z]*$/
end
def asking_a_question
remark =~ /^[A-Z]([a-z]*\s)... | true |
8fe5ed926428cceafe5fa9bc924dbe9d36cc1566 | Ruby | afrolambo/ruby-oo-relationships-practice-art-gallery-exercise-nyc01-seng-ft-060120 | /tools/console.rb | UTF-8 | 765 | 2.984375 | 3 | [] | no_license | require_relative '../config/environment.rb'
met = Gallery.new("Metropolitan Art Gallery", "New York")
charles = Doner.new("Charles", 1000)
arty = Artist.new("Arthur", 15, charles)
sam = Artist.new("Sam", 25, charles)
x = Painting.new("X", 200, arty, met)
y = Painting.new("Y", 35, arty, met)
w = Painting.new("W", 70... | true |
a59cc1d20aed84f2938956f0a32bdc74097448f5 | Ruby | japanrock/TwitterTools | /shorten_url.rb | UTF-8 | 1,297 | 2.859375 | 3 | [] | no_license | require 'rubygems'
require 'net/http'
Net::HTTP.version_1_2
require 'json'
require 'yaml'
# Thanks!! http://d.hatena.ne.jp/m-kawato/20090603/1244041369
# Usage:
# shorten_url = ShortenURL.new
# shorten_url.get_short_url("http://yahoo.co.jp")
# puts shorten_url.short_url
# => http://bit.ly/dnBGwo
class Shor... | true |
d34db33faf07e7144bb981a8d88f16c96fdf12d8 | Ruby | brenoperucchi/tdlib-ruby | /lib/tdlib/types/validated_order_info.rb | UTF-8 | 511 | 2.546875 | 3 | [
"MIT"
] | permissive | module TD::Types
# Contains a temporary identifier of validated order information, which is stored for one hour.
# Also contains the available shipping options.
#
# @attr order_info_id [String] Temporary identifier of the order information.
# @attr shipping_options [Array<TD::Types::ShippingOption>] Available... | true |
a3166d6ec8c9313b4c45e991c2efdca6911dc1e8 | Ruby | norskbrek/ruby-foundations | /small_problems/02_easy1/06.rb | UTF-8 | 276 | 3.703125 | 4 | [] | no_license | def reverse_words(string)
words = []
string.split.each do |word|
word.reverse! if word.length >= 5
words.push(word)
end
words.join(' ')
end
puts reverse_words('Professional')
puts reverse_words('Walk around the block')
puts reverse_words('Launch School') | true |
39e7d96d6f46a939f2745decf4b5511a2c449a53 | Ruby | postageapp/configature | /spec/unit/configature_data_spec.rb | UTF-8 | 1,118 | 2.640625 | 3 | [
"MIT"
] | permissive | RSpec.describe Configature::Data do
context 'can be initialized with' do
it 'defaults' do
data = Configature::Data.new
expect(data.test).to eq(nil)
expect(data.to_h).to eq({ })
end
it 'a Hash' do
data = Configature::Data.new(test: 'value')
expect(data.test).to eq('value')
... | true |
89315964cdae0b5c4b88bf36fe31d570c1233dde | Ruby | nulogy/Gorgon | /spec/host_state_spec.rb | UTF-8 | 2,261 | 2.796875 | 3 | [] | no_license | require 'gorgon/host_state'
describe Gorgon::HostState do
it { should respond_to(:file_started).with(2).arguments }
it { should respond_to(:file_finished).with(2).arguments }
it { should respond_to(:each_running_file).with(0).argument }
it { should respond_to(:total_running_workers).with(0).argument }
befor... | true |
7082322c997a01e381a2469d31e4cc92c2c10d5c | Ruby | nicrou/hotel_management_system | /app/helpers/currency_helper.rb | UTF-8 | 171 | 2.546875 | 3 | [] | no_license | module CurrencyHelper
def number_to_euro(number)
number_to_currency(number, :unit => '€', precision: 2, separator: ",", delimiter: ".", format: "%n %u")
end
end
| true |
98ea49c762d84195c1560257ae12ff3655f082e6 | Ruby | sdonohue0918/rails-create-action-readme-nyc01-seng-ft-082420 | /app/controllers/posts_controller.rb | UTF-8 | 728 | 2.734375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class PostsController < ApplicationController
def index
@posts = Post.all
end
def show
@post = Post.find(params[:id])
end
def new
@post = Post.new
end
def create
@post = Post.new
@post.title = params[:title]
@post.description = params[:description]
@post.save
redirect_... | true |
2ca0799276ff0a9d416ac4615a07a9ca48cacff1 | Ruby | alphagov/smart-answers | /test/unit/calculators/marriage_abroad_data_query_test.rb | UTF-8 | 13,229 | 2.515625 | 3 | [
"MIT",
"LicenseRef-scancode-proprietary-license"
] | permissive | require_relative "../../test_helper"
module SmartAnswer
module Calculators
class MarriageAbroadDataQueryTest < ActiveSupport::TestCase
context MarriageAbroadDataQuery do
setup do
@data_query = MarriageAbroadDataQuery.new
end
context "#marriage_data" do
should "l... | true |
cd3eaf0de9bf9bb7acd0d1a4751a1194f0bfaa27 | Ruby | hidehiro98/some_codes | /atcoder_abc001_4.rb | UTF-8 | 893 | 3.25 | 3 | [] | no_license | # this programme only pass the tests partial
a = []
result = []
n = gets.chomp.to_i
n.times do
b = gets.chomp
temp_array = []
temp_array2 = []
temp_array = b.split("-").map(&:to_i)
temp_array.each_with_index do |num, index|
if (num % 5).zero?
temp_array2 << num
else
if index.zero?
... | true |
6354e2088d9e82a8d8c046a8087d049c2d5043fa | Ruby | agrberg/benchmarks | /string_shovel_join_or_interp.rb | UTF-8 | 970 | 3 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'benchmark'
# Make sure you `gem install benchmark-ips`
require 'benchmark/ips'
TIMES = [5, 20, 100]
ALPHA = ('a'..'z').to_a
benchmark_lambda = lambda do |x|
TIMES.each do |i|
base_string = Array.new(i) { ALPHA.sample }.join
TIMES.each do |j|
string_to_append = Array.new(j... | true |
6ddfbcd5c38c3a4664a43b992dcb16345af759fc | Ruby | arvida/cf-invalidator | /cf-invalidator.rb | UTF-8 | 2,221 | 2.796875 | 3 | [] | no_license | #!/usr/bin/env ruby
puts " * Please install the fog gem\n $ gem install fog" and exit if !defined?("Fog") == 'constant' && Fog.class == Module
require 'rubygems'
require 'optparse'
require 'fog'
options = {}
opt_parser = OptionParser.new do |opt|
opt.banner = "Usage: cf-invalidator.rb -a ACCESS_KEY_ID -s SECRET_AC... | true |
093186d14391f7f57017b62a0aaafffd9fd2c620 | Ruby | vinay-ankola/pickaxe | /stock_stats.rb | UTF-8 | 286 | 2.9375 | 3 | [] | no_license | require_relative 'csv_reader'
reader = CsvReader.new
ARGV.each do |csv_file_name|
STDERR.puts "Processing #{csv_file_name}"
reader.read_in_csv_data(csv_file_name)
end
puts "Total value = #{reader.total_value_in_stock}"
#b1 = BookInStock.new("isbn1", 3)
#puts b1
#p b1 | true |
319042bb10d34129c6069d87357a19b58168208b | Ruby | cojenco/binary-and-decimal | /test/binary_to_decimal_test.rb | UTF-8 | 1,661 | 2.984375 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/reporters'
require_relative '../lib/binary_to_decimal'
Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
describe "binary to decimal" do
it "From 10011001 to 153" do
binary_array = [1, 0, 0, 1, 1, 0, 0, 1]
expected_decimal = 153
binary_to_decima... | true |
d9e9d8a4fe95bda4f77c360193d8c9b516ef13ab | Ruby | nergzd723/osdev | /script/user_program_dump | UTF-8 | 194 | 2.515625 | 3 | [] | no_license | #!/usr/bin/env ruby
raw = `xxd user_program.bin`
lines = raw.split("\n")
formatted_lines = lines.map do |line|
line[9,41].tr(' ', '')
end
puts formatted_lines.join("").gsub(/(.{2})/, '\1 ') | true |
e048ea1fd88bef866efa224309c0a94c0437cb6e | Ruby | metade/rena | /spec/literal_spec.rb | UTF-8 | 4,504 | 2.59375 | 3 | [
"MIT"
] | permissive | require 'lib/rena'
describe "Literals" do
it "accept a language tag" do
f = Literal.untyped("tom", "en")
f.lang.should == "en"
end
it "accepts an encoding" do
f = Literal.typed("tom", "http://www.w3.org/2001/XMLSchema#string")
f.encoding.to_s.should == "http://www.w3.org/2001/XMLSchema#string"... | true |
5ea3445595809cba524139350cc04f8d9296126c | Ruby | shhavel/training_tasks | /spec/07_stacks_and_queues/02_brackets_spec.rb | UTF-8 | 569 | 3.15625 | 3 | [] | no_license | # frozen_string_literal: true
describe 'solution' do
def solution(s)
len = s.length
return 1 if len == 0
return 0 if len.odd?
open_b = (o1, o2, o3 = %w<( [ {>)
c1, c2, c3 = %w<) ] }>
opened = []
s.each_char do |b|
if open_b.include?(b)
opened << b
else
o = open... | true |
08df1d967750a2e99841f3b0b7eff7fdf428ee8a | Ruby | agrmv/SoftwareOptimization | /degree_conversion/lib/input_checker/input_check.rb | UTF-8 | 277 | 3.359375 | 3 | [] | no_license | class InputCheck
def is_number?(string)
string if Float(string) rescue abort("Value not a numeric")
end
def unit_is_true?(string)
if string == 'C' or string == 'K' or string == 'F'
string
else
abort("Unit is not true(C, K, F)")
end
end
end
| true |
d872e48363bd337f59b5d0339bfc4b9604115036 | Ruby | antonzaharia/algorithms | /Ruby/last_digit.rb | UTF-8 | 142 | 3.40625 | 3 | [] | no_license | class LastDigit
def last_digit(n1, n2)
square = n1**n2
square.infinite? ? 0 : square.to_s.split("").last.to_i
end
end | true |
4701d83ee9be252e681f9177f3456b96ec8c70ff | Ruby | fursich/pry-stack_explorer | /test/commands_test.rb | UTF-8 | 11,608 | 2.921875 | 3 | [
"MIT"
] | permissive | require_relative 'test_helper'
class Top
attr_accessor :method_list, :middle
def initialize method_list
@method_list = method_list
end
def bing
@middle = Middle.new method_list
@middle.bong
end
end
class Middle
attr_accessor :method_list, :bottom
def initialize method_list
@method_list =... | true |
acc41dabbaece7651a88df1754f6cfa864f6b0fe | Ruby | UnglazedPottery/jsdir | /AlgorithmswithFernando/chessSquareMatch.rb | UTF-8 | 687 | 3.828125 | 4 | [] | no_license | #Fernando's soln
def chessboard_cell_color(cell1, cell2)
letters = ('A'..'H').to_a
colors = ['Black', 'White','Black', 'White','Black', 'White','Black', 'White']
arr_cells = []
arr_colors = []
hash = {}
for i in 1..8
for x in letters
arr_cells << x + i.to_s
end
... | true |
2305967cc8823959af0b28ecf161236f0edf47b4 | Ruby | dpreli/ttt-7-valid-move-q-000 | /lib/valid_move.rb | UTF-8 | 462 | 3.296875 | 3 | [] | no_license | board = [" ", " ", " ", " ", " ", " ", " ", " ", " "]
def valid_move?(board, position)
if (position.to_i-1).between?(0, 8) == true && position_taken?(board, position) == false
true
else
false
end
end
def position_taken?(board, position)
if board[position.to_i - 1] == " " || board[position.to_i - 1] ==... | true |
aba9a06626981feb8dc401e6b5c615e90d2fc4b9 | Ruby | hpi-epic/workshop-portal-analysis | /app/models/event.rb | UTF-8 | 925 | 2.609375 | 3 | [
"MIT"
] | permissive | # == Schema Information
#
# Table name: events
#
# id :integer not null, primary key
# name :string
# description :string
# max_participants :integer
# active :boolean
# created_at :datetime not null
# updated_at :datetime not null
#
c... | true |
49444cf9b321c1ca290c341901fa2b1e274c728d | Ruby | gregwebs/module-import | /lib/module-import.rb | UTF-8 | 2,266 | 2.890625 | 3 | [
"MIT"
] | permissive | class ImportError < Exception; end
module Kernel
# abstraction:: only include the methods given by _meths_
# implementation:: includes a duplicate of _mod_ with only the specified instance methods included. By default, all private methods will be included unless the option :import_private is set to false. If no... | true |
4892f179126984299e2fd8cdff1d1694e147ff43 | Ruby | TonishevAlexey/black_jack | /game.rb | UTF-8 | 2,684 | 3.40625 | 3 | [] | no_license | require_relative 'deck'
require_relative 'user'
class Game
attr_reader :user, :dealer, :deck
attr_accessor :stop, :state
def initialize
@user = nil
@dealer = User.new
@deck = Deck.new
@stop = false
@state = nil
end
def start_game
@stop = false
if user.nil?
print "Введите с... | true |
677baa21bf4895d312e26c5eacc8f757927800a8 | Ruby | AliSchlereth/job-tracker | /app/models/company.rb | UTF-8 | 646 | 2.59375 | 3 | [] | no_license | class Company < ActiveRecord::Base
validates :name, :city, presence: true
validates :name, uniqueness: true
has_many :jobs, dependent: :destroy
has_many :contacts
def self.top_three_companies_by_interest
top_3 = joins(:jobs).group(:id).order("AVG(jobs.level_of_interest) DESC").limit(3).pluck(:name, "AVG(... | true |
7436ca271796f23941dfc7940667d26d77246581 | Ruby | hanmoonkyo/tt-lib | /modules/command.rb | UTF-8 | 2,018 | 2.734375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
Sketchup.require 'modules/resource'
module SkippyLib
# A wrapper on top of `UI::Command` which will automatically pick the
# appropriate vector file format alternative for icon resources.
#
# @since 3.0.0
module Command
# Allows for an error handler to be configured for wh... | true |
11ec4f45e5b4f795bd67ef7329541073ea1950a2 | Ruby | hoarf/farm-control-system | /app/models/fact.rb | UTF-8 | 1,243 | 2.640625 | 3 | [] | no_license | # coding: utf-8
# This class represents any accounting relevant thing that happens.
class Fact < ActiveRecord::Base
MOVES_COUNT_MIN = 2
# Relationships
has_many :moves, dependent: :destroy, inverse_of: :fact
has_many :credits, dependent: :destroy
has_many :debits, dependent: :destroy
has_one :entry, depe... | true |
e7c908ca600c28292a31f828dafca30318cd5221 | Ruby | armaultasch/important_program | /lib/blog.rb | UTF-8 | 432 | 3.390625 | 3 | [] | no_license | #lib/blog.rb
class Blog
def initialize
@posts = []
end
def add_post (post)
@posts.push(post)
end
def show_post
@posts.sort! {|a,b| b.date <=> a.date}
@posts.each do |x|
x.print_post
end
end
starts = 0
stops = 3
def show_paginated(num)
puts page_amount = (@posts.length / 3.0).ceil
@posts[st... | true |
9ed775695c6aa2fa35b85c5b981c96b3042222ab | Ruby | borkabrak/binfiles | /iphmotj | UTF-8 | 1,820 | 4.125 | 4 | [] | no_license | #!/usr/bin/env ruby
#
# Obfuscate text by shifting each consonant and vowel one consonant or
# vowel to the right (e.g., 'english' becomes 'iphmotj').
#
# Example:
# a -> e # next vowel
# b -> c
# c -> d
# d -> f # next consonant
#
# In other words, it's a rotation cipher but where con... | true |
5383051a4f46913f7d2c1eec894557e99d877caf | Ruby | ljsking/PatternSearch | /src/ptxt.rb | UTF-8 | 275 | 3.109375 | 3 | [] | no_license | class PTxt
attr_accessor :filename, :sentences
def initialize
@sentences = []
end
def verify
return true
end
def size
return @sentences.size
end
def add(sentence)
@sentences << sentence
end
def get(idx)
return @sentences[idx]
end
end | true |
bca4d0243dcaaf065eed145f0caa272e349831bc | Ruby | DanOlson/evergreen-menus | /app/services/availability_range.rb | UTF-8 | 454 | 2.828125 | 3 | [] | no_license | module AvailabilityRange
FORMAT = '%l:%M %P'
class << self
def call(menu)
start_time = menu.availability_start_time && menu.availability_start_time.strftime(FORMAT)
end_time = menu.availability_end_time && menu.availability_end_time.strftime(FORMAT)
if start_time
[start_time, end_time... | true |
01d5ccff81443e5a9e2dbe7c35eb03b71381d5ea | Ruby | globalxolutions/cond | /spec/calc_spec.rb | UTF-8 | 1,697 | 3.0625 | 3 | [
"MIT"
] | permissive | require File.dirname(__FILE__) + '/cond_spec_base'
require 'cond/dsl'
class DivergedError < StandardError
attr_reader :epsilon
def initialize(epsilon)
super()
@epsilon = epsilon
end
def message
"Failed to converge with epsilon #{@epsilon}"
end
end
def calc(x, y, epsilon)
restartable do
... | true |
9413d74ab76b732804a29c442f85804171fe3dde | Ruby | RollingStone90/Brainbuster-ruby-2 | /loopspractice.rb | UTF-8 | 867 | 4.03125 | 4 | [] | no_license | # 5.times do
# puts"I think i can"
# end
# count=0
# 10.times do
# puts count*count
# count += 1
# end
#until loops
#double users number through 10
# puts"Give a number from 1 to 10"
# num = gets.chomp.to_i
# until num == 11
# puts num * 2
# num +=1
# end
# puts"Give a number from 1 to 10"
# num= gets.chomp.t... | true |
777d6f5ec8d5e721af431bf4ba5f535fac03a86f | Ruby | chellberg/advent | /3/solution_part_2.rb | UTF-8 | 3,409 | 3.90625 | 4 | [] | no_license | # --- Day 3: Perfectly Spherical Houses in a Vacuum ---
# Santa is delivering presents to an infinite two-dimensional grid of houses.
# He begins by delivering a present to the house at his starting location, and
# then an elf at the North Pole calls him via radio and tells him where to move
# next. Moves are always ... | true |
a54f30aaacd85b78e4bc5e3bc4d4fc6e050f2794 | Ruby | delambo/gettit | /example/Rakefile | UTF-8 | 909 | 2.59375 | 3 | [
"MIT"
] | permissive | require 'rubygems'
require 'jammit'
# Usage:
# rake build
# Think before you change - this directory is removed!!!
BUILDDIR = "build"
desc "minify source with jammit"
task :build do
puts "Building to #{BUILDDIR}/"
FileUtils.rm_rf BUILDDIR, :verbose => true
Jammit.package!({
:config_path => "assets.yml",
... | true |
01dd7d363aa100dbc6b41749e431895203ba349e | Ruby | PerfectoCode/reporting-ruby-sdk | /lib/perfecto-reporting/test/TestContext.rb | UTF-8 | 1,519 | 2.859375 | 3 | [
"Apache-2.0"
] | permissive | require_relative '../model/CustomField.rb'
# TestContext
#
# TestExecutionTags will be presented in reporting ui.
# This tags attached to each test execution.
#
# Custom Fields defined for the TestContext are presented in report UI
# These custom fields override the values in the PerfectoExecutionContext
class TestC... | true |
f9bef9e88a02e189574970b260aa8bf19c8a477a | Ruby | fcontreras18/intro_to_programming | /back_end_prep/intro_exercises/exercise7.rb | UTF-8 | 125 | 2.546875 | 3 | [] | no_license | What's the major difference between an Array and a Hash?
Arrays store data in an index, hashes store data in key value pairs | true |
aacc2b28babb8c7a973f80a9cb9d6adc2aa105fe | Ruby | craftdata/locations_ng | /lib/locations_ng/state.rb | UTF-8 | 1,012 | 2.78125 | 3 | [
"MIT"
] | permissive | module LocationsNg
class State
@all_states = LocationsNg::LoadFile.read('states')
class << self
def all
@all_states.map{ |s| {name: s['name'], capital: s['capital']} }
end
def details(state)
state_index = @all_states.index{ |s| s['alias'] == format_query(state) }
i... | true |
3aa47bfe5eacddfeb70882149a3bd0e5608c637f | Ruby | adammcfadden/anagrams | /spec/anagrams_spec.rb | UTF-8 | 315 | 2.734375 | 3 | [] | no_license | require 'rspec'
require 'anagrams'
describe('String#anagrams') do
it('return true if a word is an anagram to the given word') do
expect('dog'.anagrams('god')).to(eq(true))
end
it('return false if a word is an anagram to the given word') do
expect('pool'.anagrams('elephant')).to(eq(false))
end
end
| true |
d32f7e6b4a19178f0c672c4cd7f78da976a2b5ad | Ruby | benrconway/Cinema-modelling-homework | /db/console.rb | UTF-8 | 2,198 | 2.84375 | 3 | [] | no_license | require("pry")
require_relative("../models/customer.rb")
require_relative("../models/film.rb")
require_relative("../models/ticket.rb")
require_relative("../models/screening.rb")
Customer.delete_all()
Film.delete_all()
Ticket.delete_all()
Screening.delete_all()
customer1 = Customer.new({"name" => "Dr Worm", "funds" =>... | true |
40797270003b0992bc9feb766acb12ee30b7eb47 | Ruby | mwlang/ramaze-protos | /erubis_sequel_bacon_railsy/lib/enforce_ssl.rb | UTF-8 | 2,021 | 2.71875 | 3 | [
"MIT"
] | permissive | if Ramaze.options.mode == :bogus
require 'rack/utils'
module Rack
#
# EnforceSSL is a Rack middleware app that enforces that users visit
# specific paths via HTTPS. If a sensitive path is requested over
# plain-text HTTP, a 307 Redirect will be issued leading to the HTTPS
# version of the Requ... | true |
24d2d6f30df35d574e828e97f094ee4edac864dc | Ruby | KalMegati/anagram-detector-online-web-pt-090919 | /lib/anagram.rb | UTF-8 | 298 | 3.46875 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'pry'
# Your code goes here!
class Anagram
attr_accessor :word
def initialize(word)
@word = word
end
def matching
yield.split(//).sort == word.split(//).sort
end
def match(phrase)
phrase.map{ |piece| piece if matching{piece} }.compact
end
end | true |
c4c9302d594e20d10cd6bf378179f68811977edd | Ruby | kondorkiewicz/climbing-judge-terminal | /lib/list_manager.rb | UTF-8 | 1,326 | 3.078125 | 3 | [] | no_license | module ListManager
extend self
def add_score(comp, score)
comp[:score] = score.to_i
end
def print_list(list)
columns_names = list.first.keys.map { |key| key.to_s.upcase }
puts "\n\n"
columns_names.each { |name| print name.center(12) }; puts
list.each do |comp|
comp.values.each {... | true |
e772c1482f71c4f756c6823c895bd1f403e24bd9 | Ruby | bazzel/coursera-algorithms-part-1.rb | /lib/percolation/percolation_randomizer.rb | UTF-8 | 693 | 3.484375 | 3 | [] | no_license | class PercolationRandomizer
attr_reader :n, :positions
# Create an array representing an n*n plane
# with [x,y] coordinates as its elemens
#
# @example
# PercolationRandomizer.new(4)
# # => [[1,1], [1,2], [1,3], [1,4],
# [2,1], [2,2], [2,3], [2,4],
# [3,1], [3,2], [3,3], [3,4],
... | true |
a4abce8779e7ce0e7f2d1d3c20775921fa2706c4 | Ruby | mloreti/learning | /odin-project/ruby-basics-project/cypher.rb | UTF-8 | 503 | 4.1875 | 4 | [] | no_license | puts "What message do you want to encrypt?"
word = gets.chomp.downcase
puts "How many letters do you want to shift?"
number = gets.chomp.to_i
def cipher input, key
alphabet = ('a'..'z').to_a
new_alphabet = alphabet.rotate(key)
word = input.split("")
new_word = ""
word.each do |letter|
if !(alphabet.inc... | true |
83dee3c0e1737fff19b25e5b331ab4bc6e1db2af | Ruby | angelalonso/cal_eyo_rb | /old/test.rb | UTF-8 | 3,410 | 3.65625 | 4 | [] | no_license | #!/usr/bin/ruby
# usage: ruby SortCsvFile.rb InputFilename > OutputFilename
# define a "Person" class to represent the three expected columns
class Calendar <
# a Person has a first name, last name, and city
Struct.new(:day, :sintrom_amount, :blood_test, :shift, :birthdays, :task1, :task2, :task3, :task4)
... | true |
39e3aaef2543f59e70ce390e3b14d0f317bab0c6 | Ruby | dball1126/Coding_problems | /ruby/inorder_traversal.rb | UTF-8 | 497 | 3.453125 | 3 | [] | no_license | # Definition for a binary tree node.
class TreeNode
attr_accessor :val, :left, :right
def initialize(val)
@val = val
@left, @right = nil, nil
end
end
def inorder_traversal(root)
return [] if !root
inorder = []
stack = [root]
end
node1 = TreeNode.new(1)
node2 = TreeNode.new(2)
n... | true |
cbd9ec9e5f10a3391616cb91e2223354c3de8b48 | Ruby | Shelvak/nebula-game | /lib/flyers/lib/keygen.rb | UTF-8 | 593 | 2.921875 | 3 | [
"LicenseRef-scancode-other-permissive"
] | permissive | #!/usr/bin/env ruby
require 'rubygems'
require 'yaml'
class Keygen
STEP = 4
TIME_MULT = 100000
def self.part_string(string, step, separator="-")
parts = []
0.step(string.length - 1, step) do |start_index|
parts.push string[start_index...start_index + step]
end
parts.join(separator)
end
... | true |
76f0e6fdcd04b7f171574278f8d8163579ba4b5d | Ruby | thagomizer/Euler | /015s/paths.rb | UTF-8 | 1,079 | 3.890625 | 4 | [] | no_license | require 'rubygems'
require 'pp'
# Starting in the top left corner of a 22 grid, there are 6 routes
# (without backtracking) to the bottom right corner.
# Each route is a combination of rights and downs. The number of rights and
# downs is equal to the the manhattan distance from corner to corner. And
# half of them... | true |
6151f53a5150052e705946b3c79195c84541e19e | Ruby | jamesponeal/phase-0 | /week-5/die-class/my_solution.rb | UTF-8 | 3,051 | 4.3125 | 4 | [
"MIT"
] | permissive | # Die Class 1: Numeric
# I worked on this challenge by myself.
# I spent [1.5] hours on this challenge.
# 0. Pseudocode
# Input:
# The input is an integer which represents the number of sides of a die.
# Output:
# If .sides is called:
# The output will be an integer corresponding to the number of sides the... | true |
e016c4b1187965f51193abecfcac48c0eccb4cf3 | Ruby | rugl-at/www | /_plugins/storyblok_page.rb | UTF-8 | 1,242 | 2.59375 | 3 | [] | no_license | require "storyblok"
module Jekyll
class StoryblokPage < Page
def initialize(site, base, dir, story, links)
@site = site
@base = base
@dir = dir
@name = 'index.html'
# We will use the page component (which acts as content-type here) as layout
layout = story['content']['compon... | true |
bb4a83448d76d9e672811fa58c8f390b48fda30d | Ruby | Noelryn/fizzbuzz-october2019 | /spec/fizz_buzz_spec.rb | UTF-8 | 461 | 3.546875 | 4 | [] | no_license | require './lib/fizzbuzz.rb'
describe 'fizzbuzz' do
it 'returns 1 if number is 1' do
expect(fizzbuzz(1)).to eq 1
end
it 'returns Fizz! if number is divisable by 3' do
expect(fizzbuzz(3)).to eq 'Fizz!'
end
it 'returns Buzz! if number is divisable by 5' do
expect(fizzbuzz(5))... | true |
3f7eb30bbc663dd9a46209fd605693cdac8cbd53 | Ruby | zachholcomb/black_thursday_lite | /test/merchant_collection_test.rb | UTF-8 | 1,645 | 2.921875 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/pride'
require './lib/merchant'
require './lib/merchant_collection'
class MerchantCollectionTest < Minitest::Test
def setup
@merchant = Merchant.new({:id => 5, :name => "Turing School"})
@merchant2 = Merchant.new({:id => 6, :name => "Starbucks"})
@merchant3 = ... | true |
e7468cbae233ebc1159c9f268b9a349621b4851c | Ruby | moufidjaber/moufidjaber | /reboot/horse_race/race.rb | UTF-8 | 368 | 3.5625 | 4 | [] | no_license | def display_horses(horses)
horses.each_with_index do |horse, index|
puts "#{index + 1} - #{horse}"
end
end
def run_race(horses)
shuffled = []
4.times do |lap|
# Each lap, shuffle the array
shuffled = horses.shuffle
puts "Here is the ranking at lap #{lap + 1}:"
display_horses(shuffled)
sle... | true |
28e45d4955ba58920e8da38c71d32417ae730af8 | Ruby | timrogers/alexa_bank_details_lookup | /lib/validate_uk_bank_details_handler.rb | UTF-8 | 1,693 | 2.546875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'alexa_skills_ruby'
require_relative 'bank_details_lookup_service'
class ValidateUkBankDetailsHandler < AlexaSkillsRuby::Handler
on_intent('ValidateUkBankDetails') { look_up_bank_details }
private
def look_up_bank_details
bank_details_lookup = bank_details_lookups.crea... | true |
2c55f90d9b951c263b08236f4f218c24e7818721 | Ruby | horisakis/pro_ruby_intro | /02/2.05/2.5.2/logical_operator.rb | UTF-8 | 138 | 2.609375 | 3 | [] | no_license | t1 = true
t2 = true
f1 = false
f2 = false
t1 && t2
t1 && f1
t1 || f1
f1 || f2
t1 && t2 || f1 && f2
t1 && (t2 || f1) && f2
!(t1 && f1)
| true |
bc3743e89b3220cc2c5ce558a830c9e6041c857f | Ruby | filipeamoreira/rstat.us | /test/models/update_test.rb | UTF-8 | 9,168 | 2.609375 | 3 | [
"WTFPL"
] | permissive | require_relative '../test_helper'
describe Update do
include TestHelper
describe "text length" do
it "is not valid without any text" do
u = Factory.build(:update, :text => "")
refute u.save, "I made an empty update, it's very zen."
end
it "is valid with one character" do
u = Factory... | true |
0facc922de024115ddd844091934b88638347866 | Ruby | yangzpag/SecureStreams-DEBS17 | /remote/lib/settings.rb | UTF-8 | 2,051 | 2.671875 | 3 | [] | no_license | require 'yaml'
module DeepMergeHash
refine Hash do
def deep_merge(second)
merger = proc { |key, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2 }
self.merge(second, &merger)
end
end
end
using DeepMergeHash
class Settings
DEFAULT_OPTS = {
'cluster' => {
'manager... | true |
343efff894141b9a2215586243312514b9a72853 | Ruby | Quackers71/automation-sre | /yikes2.rb | UTF-8 | 100 | 2.703125 | 3 | [] | no_license | # using the system method
output = system("lazy")
puts output
puts "continuing on our merry way..." | true |
748b7e5d244c1aa8324e6509c9118ceddba5ce98 | Ruby | hugocorbucci/github-contest-2009 | /lib/heuristics/popular_projects.rb | UTF-8 | 673 | 3.03125 | 3 | [
"MIT"
] | permissive | require 'lib/project'
require 'lib/user'
class PopularProjects
def initialize(projects, users)
followers = count_followers(users)
@populars = sort(followers).slice(0..10)
end
def select_projects_for(user)
@populars
end
private
def count_followers(users)
follower_counter = {}
users... | true |
acb0621e3701fc4759283a1e2d0ba83e75c35763 | Ruby | MRudolph/battlebays | /app/helpers/users_helper.rb | UTF-8 | 813 | 2.515625 | 3 | [
"MIT"
] | permissive | module UsersHelper
def user_text_link (user)
if user
link_to h(user.displayed_name), user
else
t('users.missing')
end
end
def user_photo_link(user,size=nil)
if user
link_to image_tag(user.photo.url(size),:title=>user.displayed_name),user
else
""
end
end
def... | true |
36c3fb1b953ad0bd077ab4358464a47d5e539fd1 | Ruby | yendai-vo/nyc-pigeon-organizer-prework | /nyc_pigeon_organizer.rb | UTF-8 | 490 | 3.03125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def nyc_pigeon_organizer(data)
# write your code here!
organizedData = Hash.new
data.each do |attributeType, attributeValues |
attributeValues.each do |attributeValue, birdNames|
birdNames.each do |bird|
organizedData[bird] = {} unless organizedData[bird]
organizedData[bird][attributeTyp... | true |
0694b09494b15a85ceb280cf552b130d95cb084f | Ruby | svslight/ruby-basics | /lesson1/perfect_weight.rb | UTF-8 | 353 | 3.59375 | 4 | [] | no_license | print 'Введите Ваше имя: '
name = gets.chomp.capitalize
print "#{name}, введите Ваш рост: "
height = gets.to_i
perfect_weight = ((height - 110) * 1.15).round(2)
if perfect_weight > 0
puts "#{name}, Ваш идеальный вес: #{perfect_weight} кг."
else
puts 'Ваш вес уже оптимальный'
end | true |
03782070e21bbfcd9f78c276c04d5f7aff6fd7df | Ruby | Zensaburou/slack_cli | /lib/message_poster_service.rb | UTF-8 | 416 | 3.0625 | 3 | [
"MIT"
] | permissive | class MessagePosterService
def initialize
user_input = nil
until user_input == 'exit'
user_input = gets.chomp
post_message(user_input)
end
end
private
def post_message(user_input)
channel_name, message = parse_input(user_input)
WebInterface.new.post_message_to_channel_by_name(... | true |
262be022e39f861d46045e5d574eb8372a8c97e6 | Ruby | ArjunAranetaCodes/MoreCodes-Ruby | /Loops/problem4.rb | UTF-8 | 125 | 3.109375 | 3 | [] | no_license | #Problem 4: Write a program that outputs an asterisk
#pyramid.
for y in 0..5
for x in 0..y
print "*"
end
puts
end
| true |
b16eadb845b3c56fb6844470582e0fc67b12c638 | Ruby | crossmann/ruby-example | /CsvReader.rb | UTF-8 | 469 | 3.640625 | 4 | [] | no_license | require 'csv'
require_relative 'book_in_stock.rb'
# read data from CSV file (book.csv)
class CsvReader
def initialize
@books_in_stock =[]
end
def read_csv_book(csv_filename)
CSV.foreach(csv_filename, headers: true) do |row|
@books_in_stock << BookInStock.new(row['ISBN'], row['Price'])
end
en... | true |
e191a7f6a9aafbe66289e050f5ce9d34b4a0892c | Ruby | wyhaines/ridgepole-executor | /lib/ridgepole/executor/config.rb | UTF-8 | 1,057 | 2.65625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'json'
module Ridgepole
class Executor
# Parse and encapsulate the configuration that may be provided.
class Config
attr_reader :config
def initialize(json = '{}')
@config = {}
parse(json)
end
def parse(json = '{}')
json... | true |
115120cbbc97c7628d314a8b8f28128826f66ac2 | Ruby | trashcanmonster8/Tic-Tac-Toe | /lib/Board.rb | UTF-8 | 1,642 | 3.90625 | 4 | [] | no_license | class Board
#initialize the class by creating the board
def initialize()
$board = [[ 0, 0, 0 ], [ 0, 0, 0 ], [ 0, 0, 0 ]]
@boardtomarkerhash = {
-1 => ' o',
1 => ' x',
0 => ' _'
}
$markertoboardhash = {
'x' => 1,
'o' => -1
}
system('cls')
puts "Welcome to ... | true |
1722a408ca373de5de275bf25394d117e4426073 | Ruby | MyriamBoran/Myriam_Boran_PDA | /PDA_Static_and_Dynamic_Task_A/specs/testing_task_2_specs.rb | UTF-8 | 739 | 3.078125 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/rg'
require_relative('../testing_task_2.rb')
require_relative('../card.rb')
class TestCardGame < Minitest::Test
def setup
@card1 = Card.new("ace", 1)
@card2 = Card.new("two", 2)
@card_game = CardGame.new()
end
def test_check_for_ace
assert_equal(true... | true |
cf330d7145996c15bf181b1eec7f89eabe8c98bb | Ruby | polymar/pages | /lib/twitter_client.rb | UTF-8 | 2,913 | 2.859375 | 3 | [] | no_license | require 'net/http'
require 'json'
require 'lib/short_url'
require 'logger'
module Twitter
class Client
def initialize( auth )
@auth = auth
end
# public method for updating twitter status
def update_status( status ) # status = { :message => 'new post on ruby', :url => 'http://www.ruby-... | true |
c28534f7ab50751d5c302f3e2b82f4ee4ba5bbde | Ruby | woundedfrog/Ruby-prep-exercises | /ch10_more/ex3.rb | UTF-8 | 337 | 3.015625 | 3 | [] | no_license | #Exception handling is a piece of code that handles errors, if they occur.
# If an erorr occurs, then the specified 'exception handling' rules will allow the program to signal that an error occured, but still continue executing the remaining code.
#
# Without an exception handling rule stated, the program wil... | true |
64b7167c5389bdc12748a72c2d775852ea28b366 | Ruby | faezeh-ashtiani/betsy | /test/models/category_test.rb | UTF-8 | 1,536 | 2.78125 | 3 | [] | no_license | require "test_helper"
describe Category do
let (:category) {
Category.new(
name: "Weird Name"
)
}
describe "relations" do
it "can access the products related to the category throug join table" do
products = [products(:product1), products(:product2), products(:product3)]
products.ea... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.