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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
8e6c8dd32226e426f0a902b28099305660d2e6a9 | Ruby | VectorMC/Website | /lib/cacher.rb | UTF-8 | 515 | 2.921875 | 3 | [
"MIT"
] | permissive | # Write a key-value pair to the rails cache.
def set_cache(var, value, time)
Rails.cache.write(var, value, :expires_in => time)
value
end
# Get a value from the rails cache.
# If the cache does not contain the key, the default will be used.
def get_cache(var, default = nil)
stored = Rails.cache.read(var)
store... | true |
46888ca3077cc10e477e9cc425f84ca08404dc79 | Ruby | RomanADavis/challenges | /exercism/ruby/run-length-encoding/run_length_encoding.rb | UTF-8 | 716 | 2.984375 | 3 | [] | no_license | class RunLengthEncoding
def self.encode(string)
last = encoding = ''
count = 0
string.chars.each do |char|
count += 1 if last == char
unless last == char
encoding += "#{count > 1 ? count : ""}#{last}"
last, count = char, 1
end
end
encoding + "#{count > 1 ? count :... | true |
03388511fe6576fae63edcffbbeff3eeb359f2b4 | Ruby | shin1rok/atcoder | /ABC124/D/answer.rb | UTF-8 | 351 | 3.09375 | 3 | [] | no_license | N, K = gets.chomp.split
S = gets.chomp.split("")
puts N
puts K
p S
# N = 14
# K = 2
# S = ["1", "1", "1", "0", "1", "0", "1", "0", "1", "1", "0", "0", "1", "1"]
#
# 0の数を数える(連続している場合は1つとしてカウント)
# 0の数がKより小さい場合、逆立ちしている人は全員
#
# 0の数がKより大きい場合
#
| true |
33a5e24a3fa51259a3e40773ce58e0443fafbdda | Ruby | JoesGitCode/WK2_D3_Snowman_Lab | /game.rb | UTF-8 | 938 | 3.265625 | 3 | [] | no_license | class Game
attr_reader :player, :hidden_word
attr_accessor :guessed_letters
def initialize(player, hidden_word, guessed_letters)
@player = player
@hidden_word = hidden_word
@guessed_letters = guessed_letters
end
def show_hidden_word_display
return @hidden_word.display
end
... | true |
22281e4bea974d9498beacc9c783fe831e547db6 | Ruby | nelgau/intent | /lib/intent/parsing/transformer.rb | UTF-8 | 1,271 | 2.8125 | 3 | [] | no_license | module Intent
class Transformer
attr_reader :source
attr_reader :source_lines
attr_reader :lines
def initialize(source)
@source = source
@source_lines = source.lines.to_a
@lines = []
@scope_stack = []
@spacing_scopes = Set.new
end
def output
lines.join
... | true |
fefc017ab8c1ee08715d87a097f393dc174be165 | Ruby | NathanSadler/epicode_1 | /leetspeak/lib/leetspeak.rb | UTF-8 | 565 | 3.4375 | 3 | [] | no_license | require('pry')
class String
def leetspeak
leet_phrase = []
self.split('').each do |letter|
if (letter == 'e')
leet_phrase.append('3')
elsif (letter == 'o')
leet_phrase.append('0')
elsif (letter == 'I')
leet_phrase.append('1')
elsif (letter == 's')
if (l... | true |
a3dfb48a556b07bc221fc62e644a3f0f83c2af81 | Ruby | hubenias/disco | /lib/discount/items_qty.rb | UTF-8 | 320 | 2.90625 | 3 | [] | no_license | module Discount
class ItemsQty
PERCENTAGE = 0.05
DISCOUNT_QTY = 3
class << self
def calculate(order)
discount = 0
order.order_lines.each do |l|
next if l.qty < DISCOUNT_QTY
discount += l.price * PERCENTAGE
end
discount
end
end
end
end | true |
74ba40ee5b11260bb7d5ac07ff87e80dc44e1190 | Ruby | christianlarwood/ruby_small_problems | /live_coding_exercises/all_substrings.rb | UTF-8 | 761 | 4.3125 | 4 | [] | no_license | =begin
Write a method that finds all substrings in a string, no 1 letter words.
algorithm:
- iterate over the string starting from the first character using a range
- iterate over the string starting from the first character
- if substring.size > 1 then add it to our new array
- return new array
=end
de... | true |
0fc09a8f0ec802f3c2dc29f70a20550976ddc379 | Ruby | jarrettkong/flash_cards | /lib/card_generator.rb | UTF-8 | 230 | 2.703125 | 3 | [] | no_license | # frozen_string_literal: true
require 'csv'
require_relative './card'
class CardGenerator
attr_accessor :cards
def initialize(filename)
csv = CSV.read(filename)
@cards = csv.map { |data| Card.new(*data) }
end
end
| true |
aa93203e710452d431a677e2b1bdf1656bfe6109 | Ruby | tinamarfo16/My-travel-diary- | /Mytraveldiary.rb | UTF-8 | 742 | 2.921875 | 3 | [] | no_license | require 'sinatra'
<<<<<<< HEAD
get('/') do
"Hello"
end
get('/:name') do
@name = params[:name]
# @name
erb :hello
end
get('/bye/:name') do
name = params[:name]
"Goodbye " + name
end
get('/bye/:name/day') do
@name = params[:name]
"Hello " + name + "Have a good day"
@time = 'day'
erb :hello
end
get('/bye/:na... | true |
263a6d6436b64f9c280b7fcd93a056af826d601e | Ruby | vladplotnikov/Bootcamp_Notes | /week6/day4/student/student.rb | UTF-8 | 444 | 3.859375 | 4 | [] | no_license | class Student
def initialize (first_name, last_name, score)
@first_name, @last_name, @score = first_name, last_name, score
end
def full_name
"#{@first_name} #{@last_name}"
end
def grade
if @score >= 90
"A"
elsif @score >= 75
"B"
elsif @sc... | true |
d33d7780b6dd0816e04f9f41d06ea8a5d18c802d | Ruby | silvanagv/oxford-comma-001-prework-web | /lib/oxford_comma.rb | UTF-8 | 331 | 3.421875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def oxford_comma(array)
if array.length == 1
array.join
elsif array.length == 2
array.join(" and ")
elsif array.length >= 3
x = 0
string = ""
array_length = array.length
while x < (array.length - 1)
string += "#{array[x]}, "
x += 1
end
string += "and #{array[x]}"
end... | true |
ca610c5c5eca6af8e2f2419ae89fbb2ec7fbf4d8 | Ruby | louisaspicer/lrthw | /chap15/ex1.rb | UTF-8 | 526 | 4 | 4 | [] | no_license | print "please enter filename you would like to read: "
filename = gets.chomp
#a new variable is created, which is the opened file 'filename'
#open takes a parameter and returns a value which you can set to your own variable
#this makes a "File object"
txt = open(filename)
#prints out what the filename from the ARGV ... | true |
de0744d15cce389d1d3b14cb9fa520870920f4fc | Ruby | rationality6/team_randomizer | /team.rb | UTF-8 | 1,063 | 3.375 | 3 | [] | no_license | require 'sinatra'
require 'sinatra/reloader'
def randomiz(team_array, how_many, method)
team_array_rand = team_array.shuffle
array_result = []
team_count = 1
how_many = (team_array.length / Float(how_many)).ceil if method == 'teamcount'
# how_many = team_array.length / how_many if method == 'teamcount'
sl... | true |
32a6ddacdbc6250f619081706863b1deab896797 | Ruby | DeCode2018/badges-and-schedules-dc-web-082718 | /conference_badges.rb | UTF-8 | 1,788 | 3.65625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # conference_badges
# #badge_maker
# should return a formatted badge (FAILED - 1)
def badge_maker(name)
return "Hello, my name is #{name}."
end
# #batch_badge_creator
# should return a list of badge messages (FAILED - 2)
# should not hard-code response (FAILED - 3)
def batch_badge_creator(atte... | true |
c5bc5182ee7decc3b5214dd3943d3ad1223039bb | Ruby | dmexe/r4r | /lib/r4r/windowed_adder.rb | UTF-8 | 2,924 | 3.0625 | 3 | [
"MIT"
] | permissive | # require 'concurrent/thread_safe/util/adder'
# require 'concurrent/atomic/atomic_fixnum'
module R4r
# A Ruby port of the finagle's WindowedAdder.
#
# @see https://github.com/twitter/util/blob/master/util-core/src/main/scala/com/twitter/util/WindowedAdder.scala
# @see https://github.com/ruby-concurrency/concu... | true |
cac5aaab90561e37cd263330fea11fcd75b2a2b9 | Ruby | mehlah/neo4j-playground | /friends-path.rb | UTF-8 | 1,625 | 3.5 | 4 | [] | no_license | require 'rubygems'
require 'neography'
@neo = Neography::Rest.new
def create_person(name)
@neo.create_node("name" => name)
end
def make_mutual_friends(node1, node2)
@neo.create_relationship("friends", node1, node2)
@neo.create_relationship("friends", node2, node1)
end
def degrees_of_separation(start_node, des... | true |
7cc5e8d9db05ba2ce1be11218b0d16a9b258de41 | Ruby | Tubbz-alt/planner-core | /db/migrate/20110219174507_update_phone_numbers.rb | UTF-8 | 604 | 2.546875 | 3 | [
"Apache-2.0"
] | permissive | require 'person'
require 'address'
require 'postal_address'
require 'phone_number'
class UpdatePhoneNumbers < ActiveRecord::Migration
def self.up
# Go through the people and extract those that have a phone number in their address
people = Person.where('postal_addresses.phone is not null').includes(:postal_ad... | true |
d6858d8e999582b343aa4da171a17e5f485673a6 | Ruby | lukefraenza/LearnRuby | /Part1/2_Ruby.new/intro_5.rb | UTF-8 | 196 | 3.40625 | 3 | [] | no_license | def say_goodnight(name)
result = "good night, " + name
return result
end
# Time for bed...
puts say_goodnight("John-Boy")
puts say_goodnight("Mary-Ellen")
puts "And good night, \n\t\tGrandma"
| true |
3a58577ba719f3b39ce2900f52505e95be3dfbcc | Ruby | johnhamelink/xdefaults_to_termite | /option.rb | UTF-8 | 121 | 2.609375 | 3 | [
"MIT"
] | permissive | class Option
attr_accessor :key, :value
def initialize(key, value)
self.key, self.value = key, value
end
end
| true |
6b571836e605cd1b5b8f7cff52b28240a9dcfd3d | Ruby | jchamberlain909/ruby-objects-has-many-through-lab-dc-web-060418 | /lib/artist.rb | UTF-8 | 537 | 3.640625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Artist
@@all =[]
attr_accessor :name, :songs
def initialize (name)
@name = name
@songs = []
self.class.all << self
end
def new_song (name, genre)
song =Song.new(name, self, genre)
self.songs << song
song
end
def genres
genres =... | true |
1b28223e371c0a69641b97305e38c24e81b680f4 | Ruby | EthWorks/ethereum.rb | /lib/ethereum/deployment.rb | UTF-8 | 1,310 | 2.703125 | 3 | [
"MIT",
"LicenseRef-scancode-free-unknown"
] | permissive | module Ethereum
class Deployment
DEFAULT_TIMEOUT = 300.seconds
DEFAULT_STEP = 5.seconds
attr_accessor :id, :contract_address, :connection, :deployed, :mined
attr_reader :valid_deployment
def initialize(txid, connection)
@id = txid
@connection = connection
@deployed = false
... | true |
5e9f7b13f8da7652c8aa9751f4be8c0b4daec590 | Ruby | kalbasit/.nixpkgs | /overlays/all/zsh-config/bin/find-duplicates | UTF-8 | 1,000 | 3.09375 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'fileutils'
require 'digest/md5'
class DuplicateFiles
attr_reader :files
attr_reader :md5_to_files
def initialize(dir)
@base_dir = dir
_scan_for_files @base_dir
_hash_files
end
def scan_for_duplicates
@duplicate_files ||= Hash.new
@md5_to_files.each do |v|
if v[1].size... | true |
e90af5b87ccbcc766e1afa14ca3c509ec70329eb | Ruby | gkpacker/exercism-ruby | /gigasecond/gigasecond.rb | UTF-8 | 227 | 2.734375 | 3 | [] | no_license | module BookKeeping
VERSION = 6 # Where the version number matches the one in the test.
end
class Gigasecond
def self.from(time_utc)
year_gigasecond = time_utc.to_i + (10**9)
Time.at(year_gigasecond).utc
end
end
| true |
8caaec0673d9341df3b5072e2004dfff71607895 | Ruby | dannynpham/cryptocurrencycoinbot | /helpers/currency.rb | UTF-8 | 1,437 | 2.9375 | 3 | [
"Apache-2.0"
] | permissive | require 'open-uri'
require 'money'
I18n.config.available_locales = :en
module Currency
URL = "https://api.coinmarketcap.com/v1/ticker/?limit=500"
def get_symbols(text, trigger_word)
text.gsub(trigger_word, '').strip.upcase.split(' ')
end
def get_coinwatch_currencies
currencies = {}
JSON.parse(op... | true |
cf7142fd34c65c64097ea78f3efb32d97134cae6 | Ruby | egamasa/study | /ruby-cherry-book/Section4/4-5-2_range_more_less.rb | UTF-8 | 460 | 3.796875 | 4 | [] | no_license | ### n以上m以下、n以上m未満 の判定 ###
# 不等号
def liquid?(temperature)
0 <= temperature && temperature < 100
end
p liquid?(-1) #=> false
p liquid?(0) #=> true
p liquid?(99) #=> true
p liquid?(100) #=> false
# 範囲オブジェクト
def liquid_range?(temperature)
(0...100).include?(temperature)
end
p liquid_range?(-1) #=> false
... | true |
1586fb4553254d3ef20f706c451c9cd0865e9a75 | Ruby | jemc/wires | /spec/base/channel_spec.rb | UTF-8 | 16,345 | 2.546875 | 3 | [] | no_license |
require 'spec_helper'
describe Wires::Channel do
# A Channel object to operate on
subject { Wires::Channel.new 'channel' }
# Some common objects to operate with
let(:event) { Wires::Event.new }
let(:event2) { :other_event[] }
let(:a_proc) { Proc.new { nil } }
let(:b_proc) { Proc.new { true } }
... | true |
ed38b36b63376c681bc989b64ddee9187141c62f | Ruby | a6ftcruton/addycaddy | /lib/csv_importer.rb | UTF-8 | 171 | 2.640625 | 3 | [] | no_license | require 'csv'
require 'net/http'
class CSVImporter
attr_reader :uri
def initialize(uri)
@uri = uri
end
def read_file
Net::HTTP.get(uri)
end
end
| true |
ea22d7001b728cf100849ce1502a7242f590a537 | Ruby | mattrayner/givepuppi.es | /spec/models/puppies_spec.rb | UTF-8 | 1,757 | 2.921875 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe Puppy do
before :each do
when_i_create_a_number_of_puppies
end
describe 'can search by orientation' do
before :each do
and_i_search_by_orientation
end
it '.horizonal' do
there_are_five_horizontal_puppies
end
it '.vertical' do
ther... | true |
e931300c9ee9f50d6701c0efaad3a01c55fc320f | Ruby | GetPhage/phage | /lib/phage/scan/arp-snmp.rb | UTF-8 | 1,000 | 2.8125 | 3 | [
"MIT"
] | permissive | require 'snmp'
require 'pp'
# https://github.com/hallidave/ruby-snmp
module Scan
class ArpSNMP
include Enumerable
attr :collection
def initialize(host)
@host = host
@collection = []
end
def perform
SNMP::Manager.open(host: @host) do |manager|
manager.walk('ipNetToMed... | true |
42068f372611482d29c927aa89520ccf745a09b0 | Ruby | annieyshin/ruby_animal_shelter | /spec/customer_spec.rb | UTF-8 | 3,256 | 2.875 | 3 | [] | no_license | require("rspec")
require("pg")
require("animal_shelter")
require("spec_helper")
require('pry')
require('customer')
describe(Customer) do
describe(".all") do
it("is empty at first") do
expect(Customer.all()).to(eq([]))
end
end
end
describe('#save') do
it('adds a customer to the array of saved cust... | true |
52623c847f60c079d0c9b0232d0c5658f773f59e | Ruby | michaelporter/Vinyl | /bin/vinyl.rb | UTF-8 | 923 | 2.5625 | 3 | [] | no_license | #!/usr/bin/env ruby
$: << File.join(File.dirname(__FILE__), "/..")
require 'lib/vinyl/album.rb'
require 'lib/vinyl/artist_solo.rb'
require 'lib/vinyl/artist_group.rb'
require 'lib/vinyl/menu.rb'
require 'lib/vinyl/migration.rb'
require 'lib/vinyl/utility.rb'
require 'lib/vinyl/database_operations.rb'
include Menu
in... | true |
611b7797055e0306406f72fab3ee71b29d30d5b1 | Ruby | dpantic/rubylearning_37 | /3wk/11-exercise.rb | UTF-8 | 123 | 3.59375 | 4 | [] | no_license | collection = [12, 23, 456, 123, 4579].each do |num|
print "#{ num } \tis"
num.even? ? puts(" even") :puts(" odd")
end
| true |
82f800fd6a006f4d304a03e27785e5cb3d5a5fdf | Ruby | compwron/lc | /roman-to-integer.rb | UTF-8 | 850 | 3.75 | 4 | [] | no_license | # @param {String} s
# @return {Integer}
def roman_to_int(s)
m = {
"I" => 1,
"V" => 5,
"X" => 10,
"L" => 50,
"C" => 100,
"D" => 500,
"M" => 1000,
}
pieces = s.split('')
skip_ = false
sum = 0
pieces.each_with_index do |c, idx|
curr = m[c]
if idx == pieces.coun... | true |
9f6a04f06d3656c5c60c5b1b7769a816992ea0d7 | Ruby | mattdvhope/postit_template | /lib/sluggable.rb | UTF-8 | 2,490 | 3.25 | 3 | [] | no_license | module Sluggable # This code is extracted from post.rb, category.rb & user.rb models. Use 'self.class.' to work with all three classes.
extend ActiveSupport::Concern
included do
before_save :generate_slug!
class_attribute :slug_column # Used to save the col_name below.
end
def generate_slug! #.slug me... | true |
bc203fb7d6255e07732844e15c4930130f371fd0 | Ruby | egaichet/ElementWar | /test/models/castle_test.rb | UTF-8 | 1,024 | 2.890625 | 3 | [] | no_license | require 'test_helper'
class CastleTest < MiniTest::Test
def test_can_populate_castle_rooms
castle = Castle.new([foe, foe, foe])
assert_equal ['left', 'middle', 'right'], castle.available_rooms
end
def test_room_with_dead_character_is_not_available
castle = Castle.new([dead_foe, foe, foe])
asse... | true |
8c6a7a68d21182dd9c9889eb87d26d413e7f9525 | Ruby | harrison-blake/black_thursday | /test/invoice_item_repository_test.rb | UTF-8 | 2,707 | 2.875 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/pride'
require './lib/invoice_item_repository'
require './lib/sales_engine'
require './lib/sales_analyst'
require './lib/invoice_item'
require 'time'
require 'bigdecimal'
class InvoiceItemRepositoryTest < Minitest::Test
def setup
merchant_path = './data/merchants.csv'
... | true |
d041dc43bd0daf5e0e39517ee1fc70a2276b500f | Ruby | TashaGor/ruby_lessons | /lesson_4/task_1.rb | UTF-8 | 1,024 | 3.984375 | 4 | [] | no_license | puts "Введите число для выполнения расчета"
num = gets.chomp.to_i
#while
i = 1
summ_number = 0.0
while i < num do
summ_number = summ_number + i
i += 1
end
puts "Сумма цикла while равна #{summ_number}"
puts "Среднее арифметическое равно #{summ_number / num}"
#until
i = 1
summ_number = 0.0
until i >= num do
summ_... | true |
2ed5cb844bfa795113ab680d5b6a73f08ceb774e | Ruby | aivakhnenko/ror_blackjack | /main.rb | UTF-8 | 191 | 2.515625 | 3 | [] | no_license | require_relative 'interface'
class Main
def initialize
@interface = Interface.new
end
def start
interface.start
end
private
attr_reader :interface
end
Main.new.start
| true |
9d20cc2f41f54dcb754a848d57af0780798d5f21 | Ruby | ironllama/adventofcode2018 | /aoc-03a.rb | UTF-8 | 1,299 | 3.171875 | 3 | [] | no_license | # allLineString = %[#1 @ 1,3: 4x4
# #2 @ 3,1: 4x4
# #3 @ 5,5: 2x2
# ]
# allLinesArr = allLineString.split("\n")
allLinesArr = File.read('aoc-03.in').split("\n")
# p allLinesArr
oneDimension = 1000
# wholeFabric = Array.new(oneDimension, Array.new(oneDimension, 0)); # Every inner array is a reference to the same arr... | true |
9dc616e3e85dac2e02b2e5da17c13b07cc68046c | Ruby | lukaswet/My-Ruby-first-steps | /bak/1/app1/app5.rb | UTF-8 | 130 | 3.28125 | 3 | [] | no_license | print "Enter your name: "
name = gets
puts "Hello, " + name
puts ""
print "Enter your age: "
age = gets
puts "Your age is " + age
| true |
d2a6e51b27cd9707f0ea0c9cbd7f74888071ac8a | Ruby | night1ightning/ruby_course | /listen4/cli/routes/route/route_station_add.rb | UTF-8 | 1,233 | 3.015625 | 3 | [] | no_license | class Cli::RouteStationAdd < Cli::BaseCommands
def info
super 'Добавить станцию в маршрут'
end
protected
attr_reader :route, :available_stations
def params_valid?
self.route = keeper.get_current_object
stations = keeper.get_collection_by_type(:station)
self.available_stations = stations - r... | true |
21b436302b63cebe612050615e83ccab5196e928 | Ruby | jai-singhal/djangopy | /vendor/bundle/ruby/2.3.0/gems/rmagick-2.16.0/doc/ex/cbezier6.rb | UTF-8 | 1,264 | 2.65625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-proprietary-license"
] | permissive | #!/usr/bin/env ruby -w
require 'rmagick'
imgl = Magick::ImageList.new
imgl.new_image(400, 300, Magick::HatchFill.new('white','lightcyan2'))
gc = Magick::Draw.new
# Draw Bezier curve
gc.stroke('red')
gc.stroke_width(2)
gc.fill_opacity(0)
gc.bezier(50,150, 50,50, 200,50, 200,150, 200,250, 350,250, 350,15... | true |
939289b198c16eedc3ef151d7f39d1fd92b744e0 | Ruby | aaaronlopez/hairsalonpro | /app/models/appointment.rb | UTF-8 | 2,983 | 2.625 | 3 | [] | no_license | require 'google_calendar'
class Appointment < ApplicationRecord
include GoogleCalendar
belongs_to :customer
validates :start_time, presence: true
validates :end_time, presence: true
validate :start_cannot_be_greater_than_end, :time_cannot_be_in_the_past,
:appointments_cannot_be_greater_than_limit
#va... | true |
2ab40627be6b61ffc29015ed28696adaea0dcd4a | Ruby | jojo89/tic_tac_toe | /spec/lib/layout_analyzer_spec.rb | UTF-8 | 2,543 | 2.890625 | 3 | [] | no_license | require 'spec_helper.rb'
RSpec.shared_examples "completed_board" do
before do
allow(subject).to receive(:layout).and_return(layout)
end
context "with a turn that doesn't win the game " do
it "returns nil" do
expect(subject.three_in_a_row?(1, 2)).to eq(false)
end
end
context "with a turn t... | true |
33ccf411410a70e18a512ae1a5fcfbd490cc728f | Ruby | abhaved/alarm-clock | /application_controller.rb | UTF-8 | 383 | 2.546875 | 3 | [] | no_license | require 'bundler'
require_relative 'models/riddle.rb'
Bundler.require
class MyApp < Sinatra::Base
get '/' do
$question = riddle
erb :index
end
post '/results' do
riddle = params[:riddle]
@answer = params[:answer]
if answer_method(@answer, riddle) == true
erb :results
else... | true |
ba0bf8ec5166bfff6114aba2af29fee4ca21289e | Ruby | JunKikuchi/ht2p | /lib/ht2p/client/response.rb | UTF-8 | 1,436 | 2.75 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | class HT2P::Client::Response
extend Forwardable
def_delegators :@header, :[], :[]=
attr_reader :code, :header
alias :headers :header
HAS_BODY = [:get, :post, :put, :delete, :trace]
def initialize(client)
@client, @code, @header = client, *HT2P::Header.load(client)
@body = if HAS_BODY.include? @... | true |
f5662e51f859679f2b1aeff45bb674b496679ca8 | Ruby | xfbs/euler | /src/050-consecutive-prime-sum/ruby/src/solver.rb | UTF-8 | 692 | 3.640625 | 4 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'euler/prime'
module Solver
# find the prime smaller than max that is the sum of the most consecutive
# primes.
def self.solve(max)
primes = Euler::Prime.new
# find the maximum amount of consecutive primes that you can add up to be
# smaller than max, and their sum.
max_len = 0
sum_p... | true |
1d857beb0fdad255143c1740385805a35954994b | Ruby | jkalu1/todo-ruby-basics-dc-web-051319 | /lib/ruby_basics.rb | UTF-8 | 263 | 2.765625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def division(num1, num2)
sum = num1/num2
end
def assign_variable(value)
puts (value)
end
def argue
end
def greeting (greeting, name)
greeting + "" + name
end
def return_a_value
end
def last_evaluated_value
end
def pizza_party"cheese"
puts ()
end | true |
674e32af1ce2dffc0c64ad2e39c6f3bc88553792 | Ruby | astro/remcached | /lib/remcached/packet.rb | UTF-8 | 8,190 | 2.875 | 3 | [
"Apache-2.0"
] | permissive | require 'remcached/pack_array'
module Memcached
class Packet
##
# Initialize with fields
def initialize(contents={})
@contents = contents
(self.class.fields +
self.class.extras).each do |name,fmt,default|
self[name] ||= default if default
end
end
##
# Get fie... | true |
6e57298199ec18996f3484be671c417b5b3de22d | Ruby | ndelforno/object_oriented_programming-sept-10th | /exercise1.rb | UTF-8 | 336 | 3.203125 | 3 | [] | no_license | class BankAccount
def initialize(balance,interest_rate)
@balance = balance
@interest_rate = interest_rate
end
def deposit(ammount)
@balance = @balance + ammount
end
def withdraw(ammount)
@balance = @balance - ammount
end
def gain_interest
@balance = @balance + (@balance * @interest_... | true |
7db7524f00b31a221c4962bbff8e4f8a289ce784 | Ruby | DavidHuie/corleone | /lib/corleone/server.rb | UTF-8 | 1,566 | 2.5625 | 3 | [
"MIT"
] | permissive | class Corleone::Server
def initialize(emitter, collector, uri)
@emitter = emitter
@collector = collector
@uri = uri
@runner_args = @emitter.runner_args
@registry = Corleone::Registry.new
end
def logger
Corleone.logger
end
def log(type, message)
logger.send(type, message)
ret... | true |
a6f66829b7d498ffd61cc74a7405454fe5ba9fdc | Ruby | rsupak/tc-challenges | /UnSpecdFiles/fold_array/lib/fold_array.rb | UTF-8 | 525 | 4.1875 | 4 | [] | no_license | # In this challenge you have to write a method that folds a given array
# of integers by the middle x-times. For example when [1,2,3,4,5] is folded
# 1 times, it gives [6,6,3] and when folded two times it gives [9,6].
def fold_array(array, folds)
return array if folds.zero?
new_array = []
new_array << array.shi... | true |
4c403487bc54e56cfac7f52612f3140d660a85ab | Ruby | Schmitze333/odin-testfirst-ruby | /04_pig_latin/pig_latin.rb | UTF-8 | 606 | 3.8125 | 4 | [] | no_license | def change_word(word)
vowels = %w(a e i o u)
two_letter_beginnings = %w(ch qu th br)
three_letter_beginnings = %w(thr sch squ)
if vowels.include? word[0]
word + "ay"
elsif index = three_letter_beginnings.index(word[0...3])
word[3..-1] + three_letter_beginnings[index] + "ay"
elsif index = two_letter... | true |
2ce7925ba6b720f337f468957255d3d44c2fd16b | Ruby | rarvear/E7CP1A1 | /Ej2.rb | UTF-8 | 257 | 2.671875 | 3 | [] | no_license | productos = {
'bebida' => 850,
'chocolate' => 1200,
'galletas' => 900,
'leche' => 750
}
productos.each { |producto, _or_valor| puts producto }
productos['cereal'] = 2200
productos['bebida'] = 2000
prod = productos.to_a
productos.delete('galletas')
| true |
37bac381214e2956dc824743dff13bf8828125b4 | Ruby | jtsang586/SDET10 | /rspec/calc/spec/calc.rb | UTF-8 | 192 | 3.21875 | 3 | [] | no_license | class Calculator
def add(num1,num2)
num1 + num2
end
def minus(num1,num2)
num1 - num2
end
def divide(num1,num2)
num1 / num2
end
def multiply(num1,num2)
num1 * num2
end
end
| true |
d123353fe5688326135c4f83ec138ad3e6a1c936 | Ruby | tehAnswer/RoR | /Agile Web Development/depot/app/helpers/application_helper.rb | UTF-8 | 1,148 | 2.609375 | 3 | [] | no_license | module ApplicationHelper
def notice_color(notice)
if notice
type = type_notice(notice)
message = message_notice(type, notice)
div_tag_head = "<div class=\"alert alert-#{type} alert-dismissable\">"
cross_button = "<button type=\"button\" class=\"close\" data-dismiss=\"alert\" aria-hidden=\"tru... | true |
0c3a3ba9bd663532883d3ef58a4fa2f32b10f615 | Ruby | funkomatic/ns-ramaze-ext | /tests/ramaze/helper/banana_form.rb | UTF-8 | 26,498 | 2.6875 | 3 | [] | no_license | ###############################################################################
## File branched from Ramaze::Helper::BlueForm spec tests and updated for
## BananaForm features.
## Use it from the gem root by issuing the rake tests command
###############################################################################
... | true |
51f67bf7f915a4d930a482039c45bb68598ce1ac | Ruby | Linzeur/codeable-exercises | /week-2/extended-project/banzai/todo-list/cli.rb | UTF-8 | 799 | 3.046875 | 3 | [] | no_license | # define global variable
$bd_name = File.expand_path('../', __FILE__) + '/bd.txt'
def read_file
File.read($bd_name).split("\n").map { |line| line.split(" - ").map(&:strip) }
end
def save_file(tasks)
newTasks = tasks.map { |fil| fil.join(' - ') }.join("\n")
File.write($bd_name, newTasks)
end
def write(task)
... | true |
34bbeb1c288ce50066ae27e9032d5c330379df3d | Ruby | project-kotinos/BathHacked___energy-sparks | /spec/lib/amr_usage_spec.rb | UTF-8 | 7,342 | 2.796875 | 3 | [
"MIT"
] | permissive | require 'rails_helper'
require 'amr_usage.rb'
describe 'AmrUsage' do
let!(:school) { FactoryBot.create :school }
let(:supply){ :electricity }
let!(:electricity_meter_1) { FactoryBot.create :electricity_meter, school_id: school.id }
let!(:electricity_meter_2) { FactoryBot.create :electricity_meter, school_id: ... | true |
e66b2c9e9bc6cb1c912033fc07f4bfd12979d63c | Ruby | Megumi-0712/Ruby_practice-part2 | /pop-test.rb | UTF-8 | 136 | 3.609375 | 4 | [] | no_license | test1 = [0,1,2,3,4]
puts test1.pop
test2 = [0,1,[2,3],4,]
test2.pop
puts test2.pop
a = ["愛","友情","慈愛"]
a.pop
puts a.pop | true |
3d528d9265f57f30f44586336fe828af9fc9d3c1 | Ruby | hyperwing/SetGameInRuby | /Utilities/set_functions.rb | UTF-8 | 3,661 | 3.359375 | 3 | [] | no_license | # File created 09/04/2019 by Sri Ramya Dandu
# File renamed 09/18/2019 by Neel Mansukhani to set_functions.rb
# Edited 09/05/2019 by Leah Gillespie
# Edited 09/06/2019 David Wing
# Edited 09/06/2019 by Neel Mansukhani
# Edited 09/07/2019 by Sharon Qiu
# Edited 09/07/2019 by Neel Mansukhani
# Edited 09/07/2019 by Sri Ra... | true |
be4680ee97580b629216de7f4cb992b70d3bdc20 | Ruby | markbiz41/Assignments | /19.rb | UTF-8 | 1,121 | 4.5 | 4 | [] | no_license | # Note for this exercise, follow these simplified pig latin rules
# If the first letter is a vowel, add "way" to the end
# If the first letter is a consonant, move it to the end and add "ay"
class PigLatin
VOWELS = %w(a e i o u)
def self.pigatize(a)
# Check to see if the first letter is a vowel, if not it's... | true |
e4d04066a066d57b13a11f68297fc23057b17ba5 | Ruby | apperen/NPDV-1 | /lessons1-7/lesson7/07-3.rb | UTF-8 | 469 | 3.171875 | 3 | [] | no_license | # encoding: utf-8
choice = nil
# будет повторяться пока пользователь не введет 1 ИЛИ 2 ИЛИ 3
until (choice == 1 || choice == 2 || choice == 3)
puts "введите число: 1 – да, 2 – нет, 3 – иногда, и нажмите Enter"
choice = gets.chomp.to_i
end
# Адаптируйте под ваши имена переменных и набор разрешенных значений... | true |
4ce2ce78f95598b291306cba73f488d53c2b833f | Ruby | ClaytonWong/cw-toy-robot | /get_input.rb | UTF-8 | 236 | 3.5625 | 4 | [] | no_license | def get_input()
input = gets.upcase.strip # Read input from user, change it to upper case and remove spaces
inputs = input.to_s.split(" ") # Split input up into pieces marked by spaces
return inputs
end # End get_input definition | true |
d30fca60b0935af4522e811dd839748b64c1d876 | Ruby | ivanionut/old-study | /ruby/containers-blocks-and-iterators/hash_test.rb | UTF-8 | 711 | 3.203125 | 3 | [] | no_license | require 'test-unit'
class HashTest < Test::Unit::TestCase
def test_1
h = {'dog' => 'canine', 'cat' => 'feline', 'donkey' => 'asinine'}
p h.length
p h['dog']
h['cow'] = 'bovine'
h[0] = 0
h['cat'] = 999
p h
end
def test_2
h = {'dog' => 'canine', 'cat' => 'feline', 'donkey' => 'asi... | true |
daf4e691ada0469075a70f1594877fbabe5e51dc | Ruby | larskotthoff/assurvey | /web/convert.rb | UTF-8 | 3,500 | 2.546875 | 3 | [] | no_license | #!/usr/bin/env ruby
# encoding: UTF-8
require 'rubygems'
require 'json'
TEX = ARGV[0]
BBL = ARGV[1]
# key: citation key
# value: [short citation (stuff in \bibitem), full citation]
bibs = {}
agg = ""
doneski = true
IO.readlines(BBL).each { |b|
bp = b.strip
if bp =~ /^\\bibitem/ or not doneski
donesk... | true |
fa3bb03ec2a2eabb3b2f7e20ef8c1af7419af305 | Ruby | sarojinidehuri/RoRAssignments | /19-05/ass5.rb | UTF-8 | 225 | 3.421875 | 3 | [] | no_license | puts "print the num for a pyramid: "
star= gets.chomp.to_i
star1=0
(0...star).each do |i|
(0...i).each do |j|
print " "
end
(0...star-star1).each do |j|
print "* "
end
star1 += 1
puts ""
end
| true |
3914b06d7d8a100a3ac7bc57f03307ee6305546e | Ruby | ruslanrozhkov/drone | /lib/gyroscope.rb | UTF-8 | 411 | 2.96875 | 3 | [] | no_license | # gyroscope.rb
require 'observer'
class Gyroscope
include Observable
attr_reader :x, :y, :z
def initialize
@x, @y, @z = 0, 0, 0
end
def vectors
{x: @x, y: @y, z: @z}
end
def x=(x)
return if @x == x
@x = x
changed
notify_observers(Time.now, vectors)
end
def y=(y)
re... | true |
f38ae0bb199c445a070495ba7b150a3b890b4269 | Ruby | Danieleclima/ruby-objects-has-many-lab-online-web-pt-031119 | /lib/author.rb | UTF-8 | 336 | 2.84375 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class Author
attr_accessor :name
def initialize (name)
@name = name
end
def posts
Post.all
end
def add_post (posts)
posts.author = self
end
def add_post_by_title (post_title)
new_post = Post.new (post_title)
new_post.author = self
end
def self.post_count
Post.all... | true |
8956df74d6aa39876966eaf72424701577d7fcae | Ruby | yutof/bib | /src/Deck.rb | UTF-8 | 518 | 3.796875 | 4 | [] | no_license | #!/usr/bin/ruby
class Deck
def initialize()
@deck = Array.new
end
def Add(card)
@deck << card
end
def Shuffle()
@deck.shuffle!
end
def Draw()
@deck.pop
end
def IsEmpty()
@deck.empty?
end
def IsNotEmpty()
@deck.empty? == false
end
def Length()
@deck.length
end
def GetDeckAverage... | true |
3f6c2d2c340467be6d3ce80828c449d316e2d5ae | Ruby | manhgn/ruby_repo | /chapters/2_variables/name.rb | UTF-8 | 365 | 4.25 | 4 | [] | no_license | #exercise one#
puts "Hey! Type in your name!"
text = gets.chomp
puts "Hello! #{text}"
#exercise three#
10.times {puts text}
#exercise four#
puts "What's your first name?"
first = gets.chomp
puts "What's your last name?"
last = gets.chomp
puts "#{first} #{last}"
#exercise five#
#the first prints 3 and the second give... | true |
8f8a35ab58b0f54174258406ad4a578ca9b5c319 | Ruby | apidigital/roart | /lib/roart/core/array.rb | UTF-8 | 137 | 2.609375 | 3 | [
"WTFPL"
] | permissive | class Array
def to_hash
h = Hash.new
self.each do |element|
h.update(element.to_sym => nil)
end
h
end
end | true |
89a7a591b6e7b4891969170c63b6c29f89e8b889 | Ruby | Papankr/-7 | /2/test.rb | UTF-8 | 349 | 2.671875 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'test/unit'
require '/Users/tenzy/Desktop/lab7/main2'
# Test for part2
class Test2 < Test::Unit::TestCase
def setup
@box = Box.new(10, 10, 10)
end
def test_1
assert @box.is_a? Board
end
def test_2
assert_equal(1000, @box.volume)
end
def test_3
assert_equal(... | true |
95e8f78d6c3e040ad7fb14a22d345c0215fa28d7 | Ruby | EJLarcs/my-each-web-0715-public | /my_each.rb | UTF-8 | 365 | 3.890625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def my_each(array)
counter = 0
while counter < array.length
#length on an array tells you about of strings in array
yield array[counter]
#yielding item in the array and then it comes back
counter += 1
end
array
end
#when you have to puts from an array as well as return it you must
#also call it at the end
... | true |
22f0b7d58eb7ef72d73785f1f83bc5dbd7181c7e | Ruby | bartoszkopinski/ghstats | /spec/ghstats/stats_spec.rb | UTF-8 | 1,551 | 2.546875 | 3 | [
"MIT"
] | permissive | require "ostruct"
require "spec_helper"
require "ghstats/stats"
module GHStats
class DummyAPIClient
REPOS = {
"rubyist" => %w{Ruby JavaScript PHP Ruby},
"inactive" => [],
"unknown" => [nil, nil, "C++"],
"mixed" => ["Swift", "Swift", "Objective-C", "Objective-C"],
}
def initialize... | true |
3bfe815505183fe21fb9863de35a0cf894a44b9f | Ruby | iamyevesky/Ruby2048 | /2048.rb | UTF-8 | 7,422 | 3 | 3 | [] | no_license | ['io/console', 'colorize'].each{ |g| require g }
@achievements = {
16 => 'Unlock the 16 Tile',
32 => 'Unlock the 32 Tile',
64 => 'Unlock the 64 Tile',
128 => 'Unlock the 128 Tile',
256 => 'Unlock the... | true |
4a62a2b7a84f9aeb80b141198119873ad8ebedb9 | Ruby | CraftAcademy/slow_food_sinatra_august_17 | /spec/order_spec.rb | UTF-8 | 2,146 | 2.796875 | 3 | [
"MIT"
] | permissive | require './lib/models/order.rb'
describe Order do
let(:item_1) { Dish.create(name: 'Test 1',
price: 50) }
let(:item_2) { Dish.create(name: 'Test 2', price: 10) }
let!(:buyer) { User.create!(username: 'Buyer',
password: 'password',
... | true |
577756fc7e462007e66b15fd9fa392d3c2bcf020 | Ruby | aphero/voting_api | /app/models/voter.rb | UTF-8 | 628 | 2.5625 | 3 | [] | no_license | class Voter < ActiveRecord::Base
before_create :generate_access_token # Before a voter is created, generate an access token.
has_one :vote
validates :name, uniqueness: true, presence: true
validates :party, presence: true
private def generate_access_token
begin ... | true |
e57f8313b589f0692bb2177f13b2b868cda0b735 | Ruby | cmkoller/rescue_mission | /spec/features/user_creates_a_question_spec.rb | UTF-8 | 2,827 | 2.625 | 3 | [] | no_license | require "rails_helper"
feature "Post a Question", %q(
As a user
I want to post a question
So that I can receive help from others
Acceptance Criteria
[ ] I must provide a title that is at least 40 characters long
[ ] I must provide a description that is at least 150 characters long
[ ] I must be presente... | true |
51535d2a242f55aece980ec8074544d9d83a6053 | Ruby | wlodi83/Praca-Magisterska | /app/models/article.rb | UTF-8 | 2,041 | 2.578125 | 3 | [] | no_license | class Article < ActiveRecord::Base
has_many :comment
before_save :update_published_at
belongs_to :user
has_many :photos, :dependent => :destroy
has_and_belongs_to_many :categories,
:after_add => :counter_inc,
:after_remove => :counter_dec
def counter_inc(t... | true |
12f27d04a43d453043f50e419fd0e46f1255e79b | Ruby | abeidahmed/tic-tac-toe | /bin/main.rb | UTF-8 | 1,518 | 3.765625 | 4 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require_relative '../lib/player'
require_relative '../lib/game'
EXIT_KEY = 'q'.freeze
def register_player_for(player_name)
puts "✨ Please enter Player #{player_name}'s name ✨"
player_name = gets.chomp.to_s.strip
while player_name.empty?
puts 'Please enter a valid name'
player_name... | true |
92dc512564f29043aa7912f78026dc8220e11f15 | Ruby | bula21/mova21-orca | /app/services/activity_linter.rb | UTF-8 | 871 | 2.53125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
class ActivityLinter
CHECKS = {
title_translated: ->(activity) { activity.label_in_database.values.count(&:present?) > 3 },
description_translated: ->(activity) { activity.description_in_database.values.count(&:present?) > 3 },
participant_count_min: ->(activity) { activity.... | true |
0be93e98a8a41a6b326d3138dd86cc163ff4f6ba | Ruby | meh/ruby-protobuffo | /lib/protobuffo/message/fields.rb | UTF-8 | 1,555 | 2.84375 | 3 | [] | no_license | #--
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
# Version 2, December 2004
#
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
# TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
#
# 0. You just DO WHAT THE FUCK YOU WANT TO.
#++
module ProtoBuffo; class Message
... | true |
7e54faba4e06027531db3e2235c61fb66913fb24 | Ruby | OpenRubyRMK/game-engine | /data/scripts/new_rpg_data/baseitem.rb | UTF-8 | 906 | 2.78125 | 3 | [] | no_license | require_relative "baseobject"
module RPG
class BaseItem < BaseObject
attr_accessor :price
#translation :name,:description
def initialize(name)
@price=0
super
end
end
end
module Game
class BaseItem
attr_reader :name
def initialize(name)
@name = name
#get the Game Modules of the cur... | true |
d0690d60501f898275d55fdf249bcfb648e7cd45 | Ruby | screencastmint/mhack | /lib/mhack.rb | UTF-8 | 1,075 | 2.515625 | 3 | [
"MIT"
] | permissive | class Mhack
attr_reader :techno, :action, :params, :helper
def initialize
@techno = ARGV[0]
@action = ARGV[1]
@params = Array.new
@helper = Helper.new
argv_size = ARGV.length
2.upto(argv_size) { |i| @params.push ARGV[i] }
end
#Instantiates mhackmd desig... | true |
9c8a9e9f95eba78c706afa5d2f6351013d34858f | Ruby | IceDragon200/BaconBot | /plugins/weather.rb | UTF-8 | 355 | 2.78125 | 3 | [] | no_license | require 'weather-underground'
plugin :Weather do
def cmds
"weather"
end
match /weather\s+(.+)/
def execute m, loc
m.reply get_weather(loc)
end
def get_weather loc
w = WeatherUnderground::Base.new
obv = w.CurrentObservations(loc)
obv.display_location[0].full + ": " + obv.temperature_st... | true |
02f95704e9502f1abbb29eafbb9c572c9845b99b | Ruby | agiambro/algos | /app/run.rb | UTF-8 | 185 | 2.984375 | 3 | [] | no_license | #!/usr/bin/env ruby
require_relative 'lib/search'
# arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 100, 101, 201, 301, 401, 501]
arr = (1..90000000).to_a
puts Search.find(9900000, arr)
| true |
6c90444f7e94e52ab75045301686d515e048fe1a | Ruby | mattknox/jeweler | /bin/jeweler | UTF-8 | 2,432 | 2.640625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'rubygems'
require 'optparse'
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
require 'jeweler'
class JewelerOpts < Hash
attr_reader :opts
def initialize(args)
super()
self[:test_style] = :shoulda
@opts = OptionParser.new do |o|
o.banner = "Usag... | true |
55d35ac5a15c44a235486e798f5a788f5987cd2a | Ruby | imurchie/checkers | /lib/piece.rb | UTF-8 | 1,955 | 3.296875 | 3 | [
"MIT"
] | permissive | module Checkers
class Piece
attr_reader :color, :row, :col
def initialize(color, board, position, directions)
@color, @board = color, board
@row = position[0]
@col = position[1]
@directions = directions
end
def available_moves
moves = jump_moves
moves += slide... | true |
43ce8fb1b6f3a35a2e730959efedd2e489a95593 | Ruby | chinnurtb/rtb_decode | /lib/rtb_decode/ADExchange/gadx.rb | UTF-8 | 1,010 | 2.796875 | 3 | [
"MIT"
] | permissive | module Rtbdecode
module ADExchange
class Gadx < Base
def initialize(*args)
config = args.shift
@encryption_key = config.gadx[:e_key].unpack("m")[0]
end
def decode_price(final_message)
decoded = final_message.tr("-_", "+/").unpack("m")[0]
# split message into ... | true |
8d822e5bf04d73ad68ea9d394c4c850eaec0d9c5 | Ruby | spatchcock/math-function | /lib/math_function/function.rb | UTF-8 | 2,855 | 3.109375 | 3 | [
"MIT"
] | permissive | module Math
class Function
attr_accessor :place_holders
def initialize(options={},&block)
if block_given?
@function = block
@variable = nil
@place_holders = []
initialize_place_holders &block
else
raise ArgumentError, "No block given"
end
... | true |
ab466c7cd58dcb0755dfd399211642fbbab846e7 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/rna-transcription/d1be8065f58a49fab9b4c08d6bf47edc.rb | UTF-8 | 435 | 3.3125 | 3 | [] | no_license | class RibonucleicAcid
def initialize(string)
@string = string
end
def to_s
@string
end
def ==(object)
object.to_s == @string
end
end
class String
alias :old_equals :==
def ==(that)
if that.kind_of?(RibonucleicAcid)
that == self
else
old_equals(that)
end
end
end
c... | true |
35d2d22bb1708182f76bf01fb8e65228537e311b | Ruby | kaz29/candycane | /scripts/gloc2gettext.rb | UTF-8 | 854 | 2.953125 | 3 | [] | no_license | #!/usr/bin/ruby
master_file = "/Users/kabayaki91/ruby/redmine-0.8.1/lang/en.yml"
local_file = "/Users/kabayaki91/ruby/redmine-0.8.1/lang/ca.yml"
class Gloc2gettext
def Gloc2gettext.parse(fname)
tmpmap = Hash.new
File.open(fname){|f|
i = 0;
f.each_line do |line|
i += 1
next if i <... | true |
5874f9abeb78c0f096a0042de2f935c145b00f16 | Ruby | kriom/ray | /test/scene_test.rb | UTF-8 | 3,781 | 2.765625 | 3 | [
"Zlib"
] | permissive | require File.expand_path(File.dirname(__FILE__)) + '/helpers.rb'
context "a scene" do
setup do
always_proc = @always_proc = Proc.new {}
@game = a_small_game
@game.scene(:test) { always { exit! } }
@game.scene(:other) { always { exit! } }
@game.scene(:normal) { always { always_proc.call } }
... | true |
74c375df413dcd6d4c9fc97bd3c4919d516b8106 | Ruby | molawson/repeatable | /lib/repeatable/expression/set.rb | UTF-8 | 950 | 2.703125 | 3 | [
"MIT"
] | permissive | # typed: strict
module Repeatable
module Expression
class Set < Base
abstract!
sig { returns(T::Array[Expression::Base]) }
attr_reader :elements
sig { params(elements: T.any(Expression::Base, T::Array[Expression::Base])).void }
def initialize(*elements)
@elements = T.let(el... | true |
a46153d780e17e035182de7b7d5d1ba96047ee49 | Ruby | mikamai/rxp-hpp-ruby | /lib/rxp_hpp.rb | UTF-8 | 946 | 2.59375 | 3 | [] | no_license | # frozen_string_literal: true
require 'hpp_request'
require 'hpp_response'
require 'utils/validator'
# RealexHpp class for converting HPP requests and responses to and from JSON.
# This class is also responsible for validating inputs, generating defaults
# and encoding parameter values.
class RealexHpp
include Vali... | true |
b470e3b737ac32535d782343d23441f3305e75f8 | Ruby | zerolive/simple_sinatra_rest_api | /spec/app_spec.rb | UTF-8 | 4,064 | 2.59375 | 3 | [] | no_license | require 'spec_helper'
require 'json'
describe 'Simple app' do
before do
Widgets.reset
end
context 'GET /' do
it 'returns with the list of witgets' do
widgets = [{ :id => 1, :name => "First Widget"}, { :id => 2, :name => "Second Widget"}]
get '/'
expect(last_response.body).to eq(wid... | true |
38d1b177e0ea65e9379ea212a97e93c6ed87393f | Ruby | winch/osm-projects | /sqlite/test/test_node.rb | UTF-8 | 3,066 | 2.828125 | 3 | [] | no_license | #!/usr/bin/env ruby
#--
# $Id$
#
#Copyright (C) 2007 David Dent
#
#This program is free software; you can redistribute it and/or
#modify it under the terms of the GNU General Public License
#as published by the Free Software Foundation; either version 2
#of the License, or (at your option) any later version.
#
#This p... | true |
ea5cc154ffc09e994fd20b0c4fbdae0e7778d724 | Ruby | EgleMekaite/ruby-exercises | /ruby1.rb | UTF-8 | 824 | 3.671875 | 4 | [] | no_license | puts "What is your full name?"
full_name=gets.chomp
puts "Hi, #{full_name}!"
puts "What is your street address?"
street_address = gets.chomp
#puts street_address.split(' ')
first_name = full_name.split(' ').first
last_name = full_name.split(' ').last
block_letter = street_address.split(' ').first.split('').last
#street... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.