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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
a68f9689976fa4fe8a92c743715a3a5669c0032e | Ruby | iangraham20/cs214 | /projects/08/scripts/script.ruby | UTF-8 | 5,477 | 3.296875 | 3 | [] | no_license | Script started on Tue 10 Apr 2018 03:10:20 PM EDT
ls
igc2@backus-naur:~/workspace/214/projects/08/ruby$ ls
script.ruby Temperature.rb temperatureTester.rb
igc2@backus-naur:~/workspace/214/projects/08/ruby$ ruby T temperatureTester.rb
Testing Constructor... Passed!
Testing toFahrenheit... Passed!
Testing toCel... | true |
2b7c63f50bfed10d3e43b8941c4e83e9275d607e | Ruby | lorantcsiszer1119/socialdog | /app/models/twitter_user.rb | UTF-8 | 1,883 | 2.59375 | 3 | [] | no_license | require 'net/http'
class TwitterUser < ActiveRecord::Base
include TwitterAuth
belongs_to :user
# Post a new tweet to Twitter and return either the tweet id on success, or false on failure
def post_update(text)
access_token = token
resp = access_token.post('/statuses/update.json', :status =>... | true |
b5859d9453900486483b5f4da327a80a53009d83 | Ruby | micahlagrange/ruby-podcast-rss-generator | /lib/s3.rb | UTF-8 | 2,506 | 2.828125 | 3 | [
"MIT"
] | permissive | require "open3"
require "aws-sdk-s3"
require "json"
require "time"
# Call:
# Podcast::S3Buckets.episodes
#
# #<struct Podcast::S3Buckets::Episode
# path="episodes/draft-stb-2019-03-03-first.mp3",
# guid="63f25dfa4743c0d9315d4e5:e75a3fb242f080349a84b2b03119:94ab40aa86624892e0acc802d38",
# release_date=... | true |
217958f2d48b62f1150e78e1443de96da7c526f8 | Ruby | scarlettperry/algos | /ruby/fizzbuzz.rb | UTF-8 | 320 | 3.90625 | 4 | [] | no_license | def fizz_buzz(int)
fizz_buzz_array = []
(1..int).each do |i|
if i % 3 == 0 && i % 5 == 0
fizz_buzz_array << "FizzBuzz"
elsif i % 3 == 0
fizz_buzz_array << "Fizz"
elsif i % 5 == 0
fizz_buzz_array << "Buzz"
else
fizz_buzz_array << i.to_s
end
end
fizz_buzz_array
end
| true |
dc04b1e30ff1491800f7bd7eb07d14f4d64b8289 | Ruby | NikValdez/learn_ruby | /01_temperature/temperature.rb | UTF-8 | 77 | 2.828125 | 3 | [] | no_license | F2C = (5.0/9.0)
def ftoc f
(f-32.0)*F2C
end
def ctof c
32.0+(c/F2C)
end | true |
d4dfe4d9535cd7154c9d788246f65b18e1cdba68 | Ruby | wjordan/libev_scheduler | /test/test_io.rb | UTF-8 | 1,027 | 2.578125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'bundler/setup'
require 'minitest/autorun'
require 'minitest/reporters'
require 'libev_scheduler'
class TestFiberIO < MiniTest::Test
MESSAGE = "Hello World"
def test_read
i, o = IO.pipe
message = nil
thread = Thread.new do
scheduler = Libev::Scheduler.new
... | true |
9538798322da93a0589bde7d0974d926b4a38478 | Ruby | dux/lux-fw | /lib/overload/raise_variants.rb | UTF-8 | 1,483 | 2.6875 | 3 | [
"MIT"
] | permissive | class Object
# raise object
def r what
if what.is_a?(Method)
rr [:source_location, what.source_location.join(':')]
else
rr what
end
raise StandardError.new(what)
end
# better console log dump
def rr what
klass = what.class
klass = '%s at %s' % [klass, what.source_location... | true |
0bc0e6224594a7bbd735ba9ec922e23a32c929e3 | Ruby | ellefaraday/tic-tac-toe-rb-v-000 | /lib/tic_tac_toe.rb | UTF-8 | 2,424 | 4.28125 | 4 | [] | no_license | def display_board(board)
puts " #{board[0]} | #{board[1]} | #{board[2]} "
puts "-----------"
puts " #{board[3]} | #{board[4]} | #{board[5]} "
puts "-----------"
puts " #{board[6]} | #{board[7]} | #{board[8]} "
end
def input_to_index(input)
index = input.to_i - 1
end
def position_taken?(board, index)
!(b... | true |
213f2b560b3851d8b3636d98c3b9ecc52369e6c3 | Ruby | andreadelfante/gitlab-release-tools | /lib/gitlab/release/changelog/generator.rb | UTF-8 | 5,184 | 2.734375 | 3 | [
"MIT"
] | permissive | require 'gitlab/release/api_client'
require 'gitlab/release/changelog/entries'
require 'gitlab/release/changelog/entry'
require 'gitlab/release/version'
module Gitlab
module Release
module Changelog
##
# This class generates the changelog entries
#
class Generator < ApiClient
##
... | true |
91707ab87d1189af9cf1e488ea353f871ec4a9aa | Ruby | davidjnelson/aws_static_website_deploy | /lib/aws_static_website_deploy/YamlParser.rb | UTF-8 | 521 | 2.703125 | 3 | [
"MIT"
] | permissive | require 'uri'
class YamlParser
public
def initialize(configFilePath)
File.open(configFilePath) do |configFile|
@config = YAML::load(configFile)
end
end
public
def getUrl()
url = @config['url']
uri = URI.parse(url)
host = uri.host
if !host.match(/^www\./)
raise 'url in _... | true |
f28c83a54afa339a955ca3e3e91525f955d5bb26 | Ruby | DaikiMasaoka/lesson | /lesson14.rb | UTF-8 | 191 | 3.296875 | 3 | [] | no_license | # 長さ 3の文字列
# Sが与えられます。
# Sの先頭の文字を
# Sの末尾に移動して得られる文字列
# S′を出力してください。
s = gets
puts s[1]+s[2]+s[0] | true |
9f913fcf269121340b937d686da79d590b78be24 | Ruby | jcasimir/slimgin | /test/invoice_repository_test.rb | UTF-8 | 5,145 | 2.765625 | 3 | [] | no_license | require_relative 'test_helper'
require_relative '../lib/invoice_repository.rb'
require_relative '../lib/sales_engine.rb'
class InvoiceRepositoryTest < Minitest::Test
attr_reader :engine
def setup
@engine = SalesEngine.new("./test/fixtures")
engine.startup
end
def test_it_can_find_all_successful_invo... | true |
c549e27e60022081b72455d93fa5d339851c1156 | Ruby | iain/rule_table | /lib/rule_table.rb | UTF-8 | 1,554 | 2.78125 | 3 | [
"MIT"
] | permissive | require "rule_table/version"
module RuleTable
def self.matcher(name, &block)
matchers[name] = block
end
def self.matchers
@matchers ||= {}
end
def self.new(&block)
Table.new.tap { |table| TableDefiner.new(table, &block) }
end
class Table
def initialize
@rules = []
end
... | true |
c163caf8c36471baf320edc8b0509f2bec8800d1 | Ruby | olore/im_ron_burgundy | /test/object_test.rb | UTF-8 | 1,874 | 2.96875 | 3 | [] | no_license | require File.dirname(__FILE__) + '/test_helper'
class ObjectTest < Test::Unit::TestCase
def test_object_is_not_ron_burgundy
assert_equal 1, Object.methods.sort.grep(/im_ron_burgundy/).size
assert_equal false, Object.im_ron_burgundy?
end
def test_ron_burgundy_class_IS_ron_burgundy
dummy_class = Clas... | true |
d1efccd49694c9ac21aa159d23f220a536fcbe9b | Ruby | RobK-AA/registrationApp | /app/models/user.rb | UTF-8 | 1,348 | 2.75 | 3 | [] | no_license | class User < ApplicationRecord
validates :first_name, presence: true
validates :last_name, presence: true
validates :address_1, presence: true
validates :city, presence: true
validates :state, presence: true, inclusion: { in: ['AL', 'AK', 'AS', 'AZ', 'AR', 'CA', 'CO', 'CT', 'DE', 'DC', 'FM', 'FL', '... | true |
e0c8c968ddddd6f5b125cb9e9bfc992cf5ecb866 | Ruby | agdsarge/ruby-project-guidelines-wdc01-seng-ft-042020 | /bin/interface/launch_investor_interface.rb | UTF-8 | 6,596 | 3.4375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def investor_help
system("clear")
puts "\n\n\n\n\n\n"
puts " quit"
puts " - this command will logout a user."
puts "\n"
puts " quote" # that i own
puts " - this command will print a position of a single equity."
puts " * require a compan... | true |
249ade0165c4ac0d60d3e9fb0b60fb51f127c0f1 | Ruby | abcm1989/method_man | /lib/method_object.rb | UTF-8 | 4,259 | 2.796875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require('method_object/version')
# See gemspec for description
class MethodObject
class AmbigousMethodError < NameError; end
class << self
def attrs(*attributes)
@attributes = attributes
Setup.call(attributes: attributes, subclass: self)
end
def call(**args)... | true |
62144e351c6b1db423c486b73944882f9089b3d9 | Ruby | NoSoft-SA/crossbeams-layout | /lib/crossbeams/layout/progress_step.rb | UTF-8 | 3,449 | 2.640625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Crossbeams
module Layout
# A progress steps renderer - for displaying positioin in amulti-step process.
class ProgressStep
include PageNode
attr_reader :steps, :page_config, :position, :state_description,
:show_finished, :current_step_id, :si... | true |
b477a0cf80604c9b89b42b2e7cc523d25b15d9c5 | Ruby | xijo/adventofcode-2020 | /day07/day07b.rb | UTF-8 | 521 | 3.265625 | 3 | [] | no_license | require 'fileutils'
tree = {}
puts ARGV.first || 'input'
File.read('day07/input').each_line do |line|
bag = line[/\A\w+\s\w+/]
tree[bag] = {}
if line.end_with?('contain no other bags')
else
line.scan(/(\d+\s\w+\s\w+)/).each do |match|
tree[bag][match.first[/\w+\s\w+\z/]] = match.first[/\d+/].to_i
... | true |
c29e66d7cb7f3aae017e097aa04ae410efeab0a4 | Ruby | fanjieqi/LeetCodeRuby | /1201-1300/1292. Maximum Side Length of a Square with Sum Less than or Equal to Threshold.rb | UTF-8 | 749 | 3.265625 | 3 | [
"MIT"
] | permissive | # @param {Integer[][]} mat
# @param {Integer} threshold
# @return {Integer}
def max_side_length(mat, threshold)
n, m = mat.size, mat[0].size
row_sum, sum = [], []
sum[0] = (0..m).map { 0 }
(0..n-1).each do |i|
row_sum[i] ||= [0]
sum[i+1] ||= [0]
(0..m-1).each do |j|
row_sum[i][j+1] = row_sum[i... | true |
4a976a73577e32d1147e9234523296cd898d81fc | Ruby | JackNolan/playlister-rb | /lib/song.rb | UTF-8 | 130 | 2.78125 | 3 | [] | no_license | class Song
attr_accessor :genre, :name, :artist
def initialize
end
def genre=(gen)
@genre = gen
gen.add_song self
end
end | true |
0c363bebf6e4b4c4e443d361e96c73acdef51a01 | Ruby | icortex/mongoid_ext | /lib/mongoid_ext/filter/parser.rb | UTF-8 | 1,479 | 2.8125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module MongoidExt
module Filter
class Parser
def initialize(stemmer)
@stemmer = stemmer
end
def parse(query)
query, quotes = parse_quoted_text(query)
query, ops = parse_operators(query)
query.gsub!(/\s+/, ' ')
query.gsub!(/\?|\!|\:|\)|\(/, "")
wo... | true |
d1079bbcfe6a7d91e13032647765aef5a7a9c0b1 | Ruby | matDobek/memo | /src/use_cases/system/import_data_from_directory/directory_parser.rb | UTF-8 | 697 | 2.796875 | 3 | [] | no_license | module UseCases::System
module ImportDataFromDirectory
class DirectoryParser
def initialize(directory)
@directory = directory
end
def parsed_collection
return [] if invalid_directory?
collection = []
file_paths.each do |rel_path|
file_content = File.r... | true |
512012cd8400621d65d191cb9d8dc08bcfa4c943 | Ruby | msvickylau/ttt-7-valid-move-v-000 | /lib/valid_move.rb | UTF-8 | 210 | 3.125 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # code your #valid_move? method here
def valid_move?(board, index)
if board[index] == " "
move = true
elsif board[index] == "X" || board[index] == "O"
move = false
else
move = false
end
end
| true |
223f13db33def467d1edfe8dec8a9f4a51e39b95 | Ruby | MHS-QA-Forked/cracking-the-coding-interview | /spec/2.5.a_spec.rb | UTF-8 | 493 | 2.828125 | 3 | [] | no_license | require_relative 'spec_helper'
require_relative '../chapter2/linked_list'
require_relative '../chapter2/list_node'
require_relative '../chapter2/2.5.a'
describe 'sum of reverse lists' do
it 'returns the sum of the nodes two linked lists' do
first_list = LinkedList.new(3)
first_list.add(5)
first_list.add(... | true |
fabb23858c7deb939ecb0298ed8a05a5799af618 | Ruby | BillBarnhill/bcpm | /lib/bcpm/tests/test_match.rb | UTF-8 | 4,194 | 2.71875 | 3 | [] | no_license | require 'tmpdir'
# :nodoc: namespace
module Bcpm
# :nodoc: namespace
module Tests
# A match run for simulation purposes.
#
# Each test case is its own anonymous class.
class TestMatch
# Side of the tested player in the match.
attr_reader :side
# Name of opposing player in the match.
attr_reader :vs
# N... | true |
4b08e7234b078a8f3fa02fb5b44c98c86dd0e0cb | Ruby | samcassie/five_a_side_programme | /models/specs/player_specs.rb | UTF-8 | 965 | 2.828125 | 3 | [] | no_license | require("minitest/autorun")
require('minitest/reporters')
Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
require_relative("../player.rb")
class TestPlayer < MiniTest::Test
def setup()
options1 = {
'first_name' => 'Sam',
'second_name' => 'Cassie',
'age'... | true |
b501afd1892b7a3a4b488db328776173f3f39afb | Ruby | bluepostit/696-food-delivery | /app/views/orders_view.rb | UTF-8 | 530 | 3.03125 | 3 | [] | no_license | class OrdersView
def display(orders)
orders.each_with_index do |order, index|
puts "#{index + 1}. #{order.meal.name} ➡️ #{order.customer.address} - #{order.employee.username} #{order.delivered?}"
end
end
def ask_user_for(item)
puts "Please enter the #{item}"
print '> '
gets.chomp
end
... | true |
f8e27a772f9953737310b959330a342ef86f5e25 | Ruby | LMacchi/scripts | /parse_trusted_facts/parse_trusted_facts.rb | UTF-8 | 1,971 | 2.703125 | 3 | [] | no_license | #!/opt/puppetlabs/puppet/bin/ruby
require 'optparse'
require 'puppet'
require 'puppetdb'
class TrustedFact
attr_accessor :cert, :name, :value
def initialize
@cert = ''
@name = ''
@value = ''
end
end
def parse_opts
options = {}
help = OptionParser.new do |opts|
opts.banner = "Usage: #{$0}... | true |
973f4a9ba2be69dad2a5e644d685581313c86eee | Ruby | igorsimdyanov/ruby | /blocks/map_full_block.rb | UTF-8 | 106 | 3.375 | 3 | [] | no_license | p( [1, 2, 3, 4, 5].map do |x| x * x end )
arr = [1, 2, 3, 4, 5].map do |x|
x * x
end
p arr
| true |
019c621f0f0e06676d33667755658366bf5afb86 | Ruby | benclifford79/sys-uptime | /lib/linux/sys/uptime.rb | UTF-8 | 2,145 | 3.40625 | 3 | [] | no_license | # The Sys module serves as a namespace only.
module Sys
# The Uptime class encapsulates various bits of information regarding your
# system's uptime, including boot time.
class Uptime
# Error typically raised in one of the Uptime methods should fail.
class Error < StandardError; end
# The version o... | true |
87cf834752ccc9479c94eadfdccebe40a63c6f6f | Ruby | nagata03/Ruby_Cherry | /lib/proc_lambda_return_break.rb | UTF-8 | 456 | 3.796875 | 4 | [] | no_license | def proc_return
f = Proc.new { |n| return n * 10 }
ret = [1, 2, 3].map(&f)
"ret: #{ret}"
end
def lambda_return
f = ->(n) { return n * 10 }
ret = [1, 2, 3].map(&f)
"ret: #{ret}"
end
p proc_return
p lambda_return
puts
#def proc_break
# f = Proc.new { |n| break n * 10 }
# ret = [1, 2, 3].map(&f)
# "ret: ... | true |
b8b428045c117ac2bece938bf43d4e7900281a10 | Ruby | Jose59300/6-exo-rb | /exo_2.rb | UTF-8 | 441 | 3.640625 | 4 | [] | no_license | #exo 2 - Table de multiplication
#L’utilisateur devrait renseigne un nombre de 1 chiffre
#Le résultat affichera :
#La table de multiplication du chiffre ##chiffre saisie## est :
#1 * chiffre saisie = chiffre saisie * 1
#2 * …
#3 *
#…
#10 *
multiplication = gets.chomp.to_i
puts 'la table de multiplication du chiffre #... | true |
e4618bb7354769d4f7edcd33d51194deb73cf583 | Ruby | jdleesmiller/si_taxi | /lib/si_taxi/mdp_model_a.rb | UTF-8 | 9,295 | 3.03125 | 3 | [] | no_license | module SiTaxi
class MDPStateA < MDPStateBase
def initialize model
super model
@queue = [0]*model.num_stations
@destin = [0]*model.num_veh
@eta = [0]*model.num_veh
end
#
# Create state from array representation (see to_a).
#
def self.from_a model, a
state = se... | true |
94261ab16537229c7a1330661fef448c10e61d67 | Ruby | joeypoon/iron_yard | /day-2.rb | UTF-8 | 1,373 | 4.125 | 4 | [] | no_license | #Create an array of the words in the sentence below
# "Tacos must not have lettuce. Only meat and cheese and salsa."
tacos = "Tacos must not have lettuce. Only meat and cheese and salsa.".split('.').join(' ').split(' ')
print tacos
#Find how many words have a length equal to 5
length_five = tacos.select do |word|
... | true |
bd6c558c1c63d42c7d0a40ed47c7e4591377421c | Ruby | rdsavage10/The-Bank | /the_bank.rb | UTF-8 | 4,039 | 3.59375 | 4 | [] | no_license | #the_bank.rb
require_relative 'bank_classes'
@customers = []
def welcome_screen
clear_screen
@current_customer = ''
puts 'Welcome to the Bank of Savage'
puts 'Please choose from the following'
puts '--------------------------------'
puts '1. Customer Sign-In'
puts '2. New Customer Registra... | true |
058a53148cfb39f1ccdd2a40d1f9dab0658cd795 | Ruby | tonymj76/ruby-tut | /Quest01/ex05/my_isinteger.rb | UTF-8 | 163 | 3.3125 | 3 | [] | no_license | #check the type of variable parameter
def my_isinteger(n)
case n
when Integer
return 1
else
return 0
end
end
puts my_isinteger(6) | true |
672a2d95306693fb58d898e4d05d2d49f891d3b5 | Ruby | bhuga/quantity | /spec/unit.spec | UTF-8 | 9,303 | 2.75 | 3 | [
"LicenseRef-scancode-public-domain",
"Unlicense"
] | permissive | $:.unshift(File.expand_path(File.join(File.dirname(__FILE__), 'lib')))
require 'quantity/dimension'
require 'quantity/unit'
describe Quantity::Unit do
context "definition" do
before(:all) do
Quantity::Dimension.__reset!
Quantity::Unit.__reset!
length = Quantity::Dimension.add_dimension :l... | true |
f5c902b73276eaf39f50682df9f28291127569ba | Ruby | magiyo/D2 | /city.rb | UTF-8 | 604 | 3.421875 | 3 | [] | no_license | # class for the Cities for the map
class City
attr_reader :name, :cities, :maxruby, :maxfakes, :prng
def initialize(name, maxruby, maxfakes, prng)
@name = name
@cities = nil
@maxruby = maxruby
@maxfakes = maxfakes
@prng = prng
end
def add_neighbors(cities)
return nil unles... | true |
f369bc38ac36770a3616d1f775bb928a8d956863 | Ruby | edwinelisia/ruby | /trie/trie.rb | UTF-8 | 2,256 | 4 | 4 | [] | no_license | # Edwin Elisia
# 2015/05/01
# Really Simple Trie with Hash and Node Class
# Given words, Each character should be parsed as a child in the tree. Trie ?
#
# Sample application:
# * Given N Characters, iterate through all the characters and check if chosen characters is in the Node
class Node
attr_accessor :value, :ch... | true |
00b39b717f00339d0d8766a407e251856b1f488c | Ruby | jaroldwong/launchschool | /exercises/blocks/easy2/count.rb | UTF-8 | 334 | 3.5625 | 4 | [] | no_license | def count(arr)
total = 0
arr.each { |e| total += 1 if yield(e) }
total
end
count([1, 3, 6]) { |value| value.odd? } == 2
count([1, 3, 6]) { |value| value.even? } == 1
count([1, 3, 6]) { |value| value > 6 } == 0
count([1, 3, 6]) { |value| true } == 3
count([]) { |value| true } == 0
count([1, 3, 6]) { |value| val... | true |
ed495453ac7703f4f99f8771346dc3d9a24fd52f | Ruby | mrchucho/deck | /lib/deck/deck.rb | UTF-8 | 782 | 3.484375 | 3 | [] | no_license | class Deck
attr_reader :cards, :drawn
def initialize
build_deck
shuffle
end
def shuffle
build_deck if !@drawn.empty?
@cards.shuffle!
end
def draw(hand_size = 1)
hand_size = size if hand_size > size
if hand_size == 1
card = @cards.shift
@drawn.unshift(card)
card
... | true |
e6880908c7a485efc2e1140d53b52682efd5ff2b | Ruby | rogueminx/recipe-book | /lib/Recipe.rb | UTF-8 | 1,298 | 2.984375 | 3 | [] | no_license | #!/usr/bin/env ruby
class Recipe < ActiveRecord::Base
has_and_belongs_to_many(:categories)
validates(:recipe_name, {:presence => true, :length => {minimum: 3}})
validates(:ingredients, {:presence => true, :length => {minimum: 3}})
validates(:instructions, {:presence => true, :length => {minimum: 3}})
before_s... | true |
436ac559438958b3799e69be074064e31fab21fe | Ruby | lfnascimento/black_widow | /app/services/financial_transactions/create_service.rb | UTF-8 | 808 | 2.875 | 3 | [
"MIT"
] | permissive | module FinancialTransactions
class CreateService
attr_reader :source_account, :destination_account, :amount
def initialize(source_account, destination_account, amount)
@source_account = source_account
@destination_account = destination_account
@amount = amount
end
def perform
... | true |
4a520722a34335ef1bd667eeeb84c2001aa3461f | Ruby | myers3cr/agora | /test/unit/message_test.rb | UTF-8 | 1,013 | 2.796875 | 3 | [] | no_license | require 'test_helper'
class MessageTest < ActiveSupport::TestCase
test "message attributes must not be empty" do
message = Message.new
assert message.invalid?
assert message.errors[:headline].any?
assert message.errors[:content].any?
assert message.errors[:start_date].any?
assert message... | true |
375941e6d62c38cdf1e5115bc0425f45e1e81bcc | Ruby | robindoble/takeaway_deli_delights | /spec/takeaway_spec.rb | UTF-8 | 2,184 | 2.734375 | 3 | [] | no_license | require 'takeaway'
describe T do
let (:takeaway) {T.new}
before(:each) do
# stub(:gets).and_return(:soup)
takeaway.stub(:puts)
end
context 'creating a takeaway service with a user menu' do
it 'first we need a takeaway operation of some sort' do
expect(takeaway.class).to be_true
end
it 'should h... | true |
166bb5bdd039b55af2b652274ce2055fec363777 | Ruby | osyo-manga/gem-hecoration | /spec/hecoration_spec.rb | UTF-8 | 4,160 | 2.578125 | 3 | [] | no_license | require "spec_helper"
RSpec.describe Hecoration do
before do
module Deco
include Hecoration::Decoratable
def deco
decorator { |f|
proc { |*args|
["deco", self, f.bind(self).(*args)]
}
}
end
def deco2
decorator { |f|
proc { |*args|
["deco2", self, f.bind(self).(*a... | true |
a0635c4fbb7753b90f2756efeb5fcf24085db54e | Ruby | nishchitajagadish/HackerRank | /find-digits.rb | UTF-8 | 126 | 3.09375 | 3 | [] | no_license | gets.to_i.times {
y = x = gets.to_i
c = 0
while x > 0
c += 1 if x%10 > 0 && y%(x%10) == 0
x /= 10
end
p c
}
| true |
3c503be5e0d58da811ed5d29e945838c744df4d6 | Ruby | Tallwave/github_issue_exporter | /lib/issue_exporter/github.rb | UTF-8 | 616 | 2.828125 | 3 | [
"MIT"
] | permissive | module IssueExporting
def self.api_url
"https://api.github.com/repos/%s/%s/issues?access_token=%s"
end
def self.make_url(owner, repo, token)
url_format = IssueExporting.api_url
root_url = url_format % [owner, repo, token]
return root_url
end
def self.make_uri(owner, repo, token)
URI(Iss... | true |
a5c734d65b4034f48708ab10c703dd337792c452 | Ruby | tk0358/meta_programming_ruby2 | /chapter5/21module_trouble_solution.rb | UTF-8 | 142 | 2.96875 | 3 | [] | no_license | module MyModule
def my_method; 'hello'; end
end
class MyClass
class << self
include MyModule
end
end
p MyClass.my_method | true |
e837643e2b611fc5f9b64f02c408e74a630b2d13 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/cs169/800/feature_try/whelper_source/16741.rb | UTF-8 | 256 | 3.015625 | 3 | [] | no_license | def combine_anagrams(words)
hash = Hash.new
hash.default = []
words.each do |s|
q = s.downcase.split("").sort { |a, b| (a <=> b) }.join("")
hash[q] = (hash[q] + [s])
end
res = Array.new
hash.each { |k, v| res = (res + [v]) }
res
end
| true |
220f08c2b8223030e7e690d37a5dab050fbe5e3a | Ruby | LearningToCode-MakersAndMore/PreCourse | /Precourse/Codewars_Precourse/string_search | UTF-8 | 311 | 3.8125 | 4 | [] | no_license | #!/usr/bin/ruby
# search input string for first instance of non repeated letter
# CodeWars name 'First non-repeating character'
def first_non_repeating_letter(s)
ans = s.chars.find { |chr| s.downcase.chars.count(chr.downcase) == 1 }
return ans != nil ? ans : ''
end
puts first_non_repeating_letter('test')
| true |
b1997ff04c4abafa4338a491c875d896aa667025 | Ruby | adamcameron/otherLanguages | /ruby/7Li7W/ruby/day2/symbol2.rb | UTF-8 | 459 | 2.71875 | 3 | [] | no_license | hash = {
:subHash1 => {
:subKeySymbol => "v1",
"subKeyString" => "v2"
},
:subHash2 => {
:subKeySymbol => "v3",
"subKeyString" => "v4"
}
}
hash.each do |ko,vo|
puts "outer key: #{ko}"
vo.each do |ki,vi|
puts "inner"
puts "key: #{ki}";
puts "key ID: #{ki.object_id}"
puts "value: #{vi}"
end
puts ... | true |
4a4a35be6ea1e283b3f4e5414500903482246f3c | Ruby | DanDobrick/orghunter | /lib/orghunter/charity.rb | UTF-8 | 2,509 | 2.625 | 3 | [
"MIT"
] | permissive | module Orghunter
class Charity
attr_reader :name, :category, :org_hunter_URL, :donation_URL, :city, :state, :zip_code, :status, :search_score, :website, :mission, :ein, :in_care_of, :street, :country, :subsection, :classification, :affiliation, :ruling_date, :deductibility, :deductibility_status, :foundation, :or... | true |
d410dbe599de6095ae450ec7cf6e5e8cf144541a | Ruby | birmacher/AppleEpfImporter | /lib/apple_epf_importer/apple_epf_extractor.rb | UTF-8 | 416 | 2.515625 | 3 | [
"MIT"
] | permissive | module AppleEpfImporter
class AppleEpfExtractor
def extract(filename, files_to_extract)
files = Array.new
files_to_extract.each do |f|
files.push File.basename(filename, '.tbz') + '/' + f
end
system "cd #{AppleEpfImporter.configuration.extract_dir} && tar -xjf #{filename} #... | true |
cba7cd330943d7e135425c45b65b742f1c87cb43 | Ruby | julianvargasalvarez/sudoku-solver-ruby | /spec/solver_spec.rb | UTF-8 | 1,725 | 3.078125 | 3 | [] | no_license | require 'rspec'
one = [0,1,8,0,3,0,0,4,0,
6,0,0,0,0,5,0,0,2,
0,0,0,0,0,4,0,0,8,
0,7,9,0,0,0,0,0,0,
3,0,0,0,0,0,0,0,1,
0,0,0,0,0,0,2,8,0,
2,0,0,9,0,0,0,0,0,
1,0,0,6,0,0,0,0,7,
0,6,0,0,4,0,1,3,0]
two = [0,4,0,2,0,0,3,0,0,
0,0,0,0,0,7,0,0,8,
8,0,5,3,0... | true |
5a59c59489da4320cc3c4cc39ce82ab6efca158c | Ruby | AustinWood/homeworks | /w3d2/aa_questions/user.rb | UTF-8 | 1,650 | 2.96875 | 3 | [] | no_license | require 'sqlite3'
require_relative 'db_connection'
class User
attr_accessor :fname, :lname
def self.all
data = DBConnection.instance.execute("SELECT * FROM users")
data.map { |datum| User.new(datum) }
end
def initialize(options)
@id = options['id']
@fname = options['fname']
@lname = optio... | true |
9d4a809ad3c36b219d41731a5cc99d651f52846c | Ruby | AlexandraChen/IronHack | /week2_exercises/imdb/sl10_imdb2_rspec.rb | UTF-8 | 1,133 | 2.984375 | 3 | [] | no_license | require 'rspec'
require_relative "./sl10_imdb2.rb"
describe Imdb2 do
before do
@tv = Imdb2.new
end
describe "#search_title" do
it "should return the number of series with that title" do
expect(@tv.search_title("Cat")).to eq(200)
end
end
describe "#most_seasons_from" do
it "should return the serie ... | true |
5b18ef454e584589d99973b91f3f40d99799fa1e | Ruby | rodrigotomonari/intercom-test | /test/customer_collection_builder_test.rb | UTF-8 | 493 | 2.515625 | 3 | [] | no_license | # frozen_string_literal: true
require "test_helper"
require "customer_collection_builder"
class CustomerCollectionBuilderTest < Minitest::Test
def setup
@customer_collection_builder = CustomerCollectionBuilder.new(StubReader.new, StubFactory)
end
def test_build
collection = @customer_collection_builder... | true |
90524c80d48560c00ef2645486a370c11352b7eb | Ruby | lucyconklin/1Module | /bubble_sort.rb | UTF-8 | 361 | 3.765625 | 4 | [] | no_license | class BubbleSort
def sort(array)
n = array.length
loop do
swapped = false
(n-1).times do |i|
if array[i] > array[i+1]
array[i+1], array[i] = array[i], array[i+1]
swapped = true
end
end
break if not swapped
end
print array
end
end
sorter = BubbleSo... | true |
a28294251c2b6d1f83e00530548f9881ebda05bd | Ruby | aromatt/pushfour | /regress/candidates.rb | UTF-8 | 327 | 2.75 | 3 | [] | no_license | #! /usr/bin/env ruby
require_relative '../lib/strategy'
include PushFour
size = 6
win_len = 4
[
'++++++
++++++
+#r+++
+#r+++
++++++
++++++',
].each do |string|
b = Board.new(size, size, win_len, string)
s = Strategy.new(b, 'r')
puts b.board_picture
move = s.best_move
puts "best_move: #{s.best_move... | true |
d4a80127d8a4d28efc004e21503bc612453c5e38 | Ruby | feigningfigure/WDI_NYC_Apr14_String | /w01/d05/Dara_Mao/classes/student.rb | UTF-8 | 258 | 3.234375 | 3 | [] | no_license | class Student
attr_accessor :name # this creates method to give access to to match the instance @name
def initialize(student_hash)
@name = $students["Name"]
end
def to_s
"My name is #{@name}" #how to put the name of the studetns
end
end
| true |
898ebb5bffd34197ed5fcef9bf25b5fe2126f3fc | Ruby | papyrusdo/ProxBox | /proxbox.rb | UTF-8 | 1,441 | 2.84375 | 3 | [] | no_license | #!/usr/bin/env ruby
#i
#
require 'rubygems'
require 'open-uri'
require 'mechanize'
require 'nokogiri'
@agent = Mechanize.new()
puts "Scraping page..."
data = ""
for i in 0..20
puts "Scraping page #{i}"
suffix = ""
if i < 10
suffix = "0" + i.to_s
else
suffix = i.to_s
end
data += @agent.get("http://samair.ru/p... | true |
8aa67ff112f6a222da9336f9b572c588734493c3 | Ruby | krmsh/travel | /if_travel2.rb | UTF-8 | 844 | 3.21875 | 3 | [] | no_license | # 以下参考コード全体(要リファクタリング)
plans = [
{ name: "沖縄旅行", price: 10000},
{ name: "北海道旅行", price: 20000},
{ name: "九州旅行", price: 15000},
]
puts "旅行プランを選択して下さい。"
plans.each.with_index(1) do |plan, i|
puts "#{i}. #{plan[:name]}(¥#{plan[:price]})"
end
select_num = gets.to_i - 1
chosen_plan = plans[select_num]
... | true |
111d198a8ba1ee863f07e44d1d6970f6ca768a4a | Ruby | masa-1013/atcoder | /abc136/D-Gathering-Children.rb | UTF-8 | 342 | 3.1875 | 3 | [] | no_license | S = gets.chomp
n = S.length
ans = Array.new(S.length, 0)
cnt = 0
n.times do |i|
if S[i] == 'R'
cnt += 1
else
ans[i] += cnt/2
ans[i-1] += (cnt+1)/2
cnt = 0
end
end
cnt = 0
(n-1).downto(0) do |i|
if S[i] == 'L'
cnt += 1
else
ans[i] += cnt/2
ans[i+1] += (cnt+1)/2
cnt = 0
end
end... | true |
9759d59fcf511b543d85d5ce6015fea3e815f19d | Ruby | smashtank/subly | /lib/subly/model.rb | UTF-8 | 1,990 | 2.59375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | module Subly
class Model < ActiveRecord::Base
require 'chronic_duration'
set_table_name 'subly_models'
belongs_to :subscriber, :polymorphic => true
before_validation :convert_duration
validates_presence_of :subscriber_type
validates_presence_of :subscriber_id, :unless => Proc.new { |subly| ... | true |
786909f485f5a431d0de01a72014836f5a47bb82 | Ruby | Adeptus/Swiss_system | /lib/swiss_system/round.rb | UTF-8 | 1,530 | 3.21875 | 3 | [] | no_license | module SwissSystem
class Round
def paring_player(players_array, round)
return shuffle_paring(players_array) if round == "New"
points_paring(players_array)
end
private
def shuffle_paring(players_array)
players_array = remove_oponents(players_array.shuffle)
output_array = paring_p... | true |
61ef7c4389d80db75138f92487cf9ceabd41c3c8 | Ruby | Dean-Delagrange/small_problems | /easy4/9.rb | UTF-8 | 830 | 4.125 | 4 | [] | no_license | # Convert a number to a string!
# Method:
# takes psoitive integer or zero
# converts it to a string
# can't use .to_s, String() or Kernel#format
DIGITS = { '0' => 0, '1' => 1, '2' => 2, '3' => 3, '4' => 4,
'5' => 5, '6' => 6, '7' => 7, '8' => 8, '9' => 9 }
DIGITS2 = ['0', '1', '2', '3', '4', '5', '6', '7... | true |
108a8cacffcbbc73dc9969777169e6ddf50a0d65 | Ruby | rachaellynn/rampup_homework | /week2_2_double_up.rb | UTF-8 | 293 | 3.96875 | 4 | [] | no_license | #week 2.2 double_up
def double_up(string)
newstring = []
chars = string.split('')
chars.each do |i|
i = i + i
newstring << i
end
puts newstring.join
end
puts "Please enter a string and I'll double up the letters for you"
string = gets.chomp
double_up(string) | true |
817011c534c32252aff1502e94eff8b26197a29e | Ruby | jshwa/ruby-object-initialize-lab-bootcamp-prep-000 | /lib/person.rb | UTF-8 | 66 | 2.5625 | 3 | [] | no_license | class Person
def initialize(new_name)
@name = new_name
end
end
| true |
a2d70fffb941d01080bdb006564471e5d3254ac6 | Ruby | logeshraj/data_structures_ruby | /lib/graph/kruskals.rb | UTF-8 | 2,818 | 3.578125 | 4 | [] | no_license | class Graph
class Edge
attr_accessor :src, :dest, :weight
def initialize(src, dest, weight)
self.src = src
self.dest = dest
self.weight = weight
end
def <=>(other)
self.weight <=> other.weight
end
end
class Node
attr_accessor :value
def initialize(value)
... | true |
be0ae108c575f5dd601c6a4023690df3ad89918f | Ruby | AhmedIraqi/parrot-ruby-re-coded-000 | /parrot.rb | UTF-8 | 143 | 3.15625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Create method `parrot` that outputs a given phrase and
# returns the phrase
def parrot(voice="Squawk!")
puts "#{voice}"
return voice
end
| true |
37dc07d6b7bd40caab87b23a7c133a359824f49c | Ruby | gervin0726/Prework | /Shake Shack/shakeshack.rb | UTF-8 | 1,560 | 4 | 4 | [] | no_license | class MilkShake
attr_reader :total_price_of_milkshake
def initialize()
@base_price = 2
@ingredients = []
end
def add_ingredient(ingredient)
@ingredients.push(ingredient)
end
def price_of_milshake ()
@total_price_of_milkshake = @base_price
@ingredients.each do |ingredient|
@total_pr... | true |
45957c041624641ab7b970003cd13feac9ea6552 | Ruby | RubyNunatak/rubykids | /teil_03/theorie_07.rb | UTF-8 | 2,615 | 3.6875 | 4 | [] | no_license | # theorie_07.rb
# Klasse Tür
class Tuer
attr_reader :farbe, :material, :zustand
attr_writer :zustand
def initialize(farbe, material)
@farbe = farbe
@material = material
@zustand = :geschlossen
end
def to_s
"Tuer[zustand=#{@zustand}, farbe=#{@farbe}, material=#{@material}]... | true |
c1f375123ae3433407f5398cb308be6defbc9c94 | Ruby | VadimBrodsky/calculator | /calculator.rb | UTF-8 | 1,442 | 4.25 | 4 | [] | no_license | # Assignment: Calculator
# ======================
#
# Code up your own calculator from the lecture.
# Make sure you can run it from the command line.
# Save the calculator file in a directory, and initialize the directory as a git repository.
# Make sure this isn't nested in another existing git repository.
# Then, pus... | true |
c4617342b19c76b520f00c13e19e0a8a6a5b5315 | Ruby | kev2480/Simple-Ruby-Phonebook | /app.rb | UTF-8 | 4,061 | 3.1875 | 3 | [] | no_license | # app.rb
require 'rubygems'
require 'sinatra'
require 'json'
require 'daybreak'
#Home page
get '/' do
#Return index.html
File.read(File.join('public', 'index.html'))
end
#Error 404
get '/error404/?' do
#Return error404.html
status 404
File.read(File.join('public', '404.html'))
end
#List all contacts
get '/... | true |
e770f120ad3fca68dd1c9e08bf9f9a88f61370e7 | Ruby | deloristhompson/magic_the_gathering_deck_builder | /app/seeders/color_seeder.rb | UTF-8 | 394 | 2.796875 | 3 | [] | no_license | class ColorSeeder
COLORS = [
{
name: 'Red'
}, {
name: 'White'
}, {
name: 'Blue'
}, {
name: 'Black'
}, {
name: 'Green'
}
]
def self.seed!
COLORS.each do |color|
card_name = color[:name]
new_name = Color.find_or_create_by!(name: card_name)
... | true |
dd4742f7a7d49c37628ca1a7cc0298be9012034e | Ruby | sandersonraul/DesafioSemanal-01 | /tarefa-001.rb | UTF-8 | 95 | 3.578125 | 4 | [] | no_license | puts "Digite seu nome: "
nome = gets.chomp
puts "Comprimento do nome: #{nome.size} caracteres" | true |
6cc0ade4b8447b34c162b8f94883d450be04bd01 | Ruby | bmrsny/traffic_spy | /lib/traffic_spy/models/event.rb | UTF-8 | 1,554 | 2.578125 | 3 | [
"MIT"
] | permissive | module TrafficSpy
class Event
extend ModelHelper
def self.table
DB.from(:events)
end
def self.sorted_events_by(identifier)
combined_db = DB.from(:sources).join(:payloads, :source_id => :id).join(:events, :id => :eventName_id)
filtered_db = combined_db.filter(:source_id => identifi... | true |
98d071d5956c54c1255798e1561981161e180aee | Ruby | carloscheddar/CreateAlias | /CreateAlias.rb | UTF-8 | 1,570 | 3.25 | 3 | [] | no_license | #! /bin/env/ruby
#Author: Carlos Feliciano Barba
#GitHub: carloscheddar
#Email: c.feliciano2009@gmail.com
# Ask for the folder name and target folder if no argument is given
if not ARGV[0]
print "Drag the show folder to the terminal window: "
# Get folder from user
path = gets.chomp(" \n") + "/"
print "Drag ... | true |
40392096cd2f8e55b47a924426ed943c79cf6d12 | Ruby | lyntco/wdi_melb_homework | /gumballs/vasko_traikovski/quiz/cake_candles_spec.rb | UTF-8 | 1,090 | 3.015625 | 3 | [] | no_license | class Cake
def candle_count(strDate)
birthday = Date.parse(strDate)
today = Date.today
years = ((today - birthday)/365).to_i
can = (0..years).to_a.reduce(:+)
cand = (years===1)? "candle" : "candles"
"#{can} #{cand} have burned for you"
end
end
require 'date'
require 'm... | true |
f1257867b97eae9d32f5747c4992cb6e4eb95196 | Ruby | fahryfauzan/GenerasiGigih | /module4/session2/exercise/incremental_array.rb | UTF-8 | 250 | 3.40625 | 3 | [] | no_license | class IncrementArray
def increment(number)
if number == [0]
return number = [1]
elsif number == [1]
return number = [2]
elsif number == [9]
return number = [1, 0]
end
end
end | true |
37d43344b4e3361f143180a577af29fdf88ddccb | Ruby | christianlarwood/ruby_small_problems | /codewars_problems.rb/lexicographical_order.rb | UTF-8 | 1,044 | 4.1875 | 4 | [] | no_license | =begin
Given two arrays of strings a1 and a2 return a sorted array r in lexicographical order of the strings of a1 which are substrings of strings of a2.
#Example 1: a1 = ["arp", "live", "strong"]
a2 = ["lively", "alive", "harp", "sharp", "armstrong"]
returns ["arp", "live", "strong"]
#Example 2: a1 = ["tarp", "mic... | true |
49bece2583a4fecd68c79f2894c7ea13ba8521a1 | Ruby | mcmillan/nts-api | /app/models/show.rb | UTF-8 | 1,535 | 2.875 | 3 | [] | no_license | class Show
attr_reader :url
def initialize(from: nil, to: nil, url: nil, title: nil)
@from = from
@to = to
@url = url
@title = title
end
def now?
DateTime.now.between?(from, to)
end
def to_json(*args)
{
title: title,
description: description,
location: location,
... | true |
c01d4ef8f070cf675d261a13bf668042fed232a9 | Ruby | ming-ancino/stackoverflow | /app/models/question.rb | UTF-8 | 1,280 | 2.515625 | 3 | [] | no_license | class Question < ActiveRecord::Base
attr_accessible :username, :subject, :text, :tags_used
belongs_to :user
has_many :answers, :dependent => :destroy, :as => :container
has_many :question_tags
has_many :tags, :through => :question_tags
has_many :votes, :as => :voteable
validates :subject, :presence => ... | true |
6f12ddc5e7d67610c11276d6f4ef796e4e8df9c6 | Ruby | coalest-zz/launch_school | /exercises/rb101-rb109_small_problems/easy_5/alphabetical_numbers.rb | UTF-8 | 600 | 3.890625 | 4 | [] | no_license | ENGLISH_NUMS = %w(zero one two three four five six
seven eight nine ten eleven twelve thirteen
fourteen fifteen sixteen seventeen eighteen nineteen)
def alphabetic_number_sort(array)
array.sort_by { |element| ENGLISH_NUMS[element] }
end
p alphabetic_number_sort((0..19).to_a) == [
8, 18, 11, 15, 5, 4, 14, 9,... | true |
ab8b56cb042c5e6d37c534f1f3c67c1a968d6eaa | Ruby | brenothales/Eva-IA-Robot | /Eva.rb | UTF-8 | 1,585 | 2.6875 | 3 | [] | no_license | require "cgi"
require 'open-uri'
require 'json'
require 'win32ole'
require 'rbconfig'
shell = WIN32OLE.new('Shell.Application')
def pergunta()
p 'gravando ...'
system('rec.exe -r 16000 test.flac silence -l 1 0.1 1% 1 1.5 1%')
p 'Enviando arquivo'
request = %x(wget.exe -q -U "rate=16000" -O - "http://www.google.co... | true |
dc70c41bb5c1efa247b5a73debede0ddac2af442 | Ruby | student-tomasz/aisd-projekt-indywidualny | /lib/mesh/faces_hash.rb | UTF-8 | 218 | 2.5625 | 3 | [] | no_license | module Mesh
class FacesHash < Array
def [] id
super(id-1)
end
def []= id, face
super(id-1, face)
end
def add id, vertices
self[id] ||= Face.new id, *vertices
end
end
end
| true |
fffeeb2629a4e14521b93d51a2880600f31cb058 | Ruby | tastybacon/advent_of_code | /2021/lib/diagnostic_interpreter.rb | UTF-8 | 2,110 | 3.234375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
# Takes submarine diagnostic information and extracts useful information
class DiagnosticInterpreter
def self.calculate_gamma_rate(bit_counts)
bit_counts
.map { |count| count.max_by { |_, v| v }[0] }
.reverse
.join
.to_i(2)
end
def self.count_bits(diagno... | true |
a14fcf9bbcb64bdcc7c759ce40a16e0f9f83e29a | Ruby | mross1080/CSC410-ResearchProject | /collecttweets.rb | UTF-8 | 857 | 2.703125 | 3 | [] | no_license | require 'twitter'
require 'yaml'
#OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
client = Twitter::REST::Client.new do |config|
config.consumer_key = ENV["consumer_key"]
config.consumer_secret = ENV["consumer_secret"]
config.access_token = ENV["access_token"]
config.access_token_secr... | true |
37d40e44d8c61110bb3dc27a3eff67eb2b5535ce | Ruby | 0xhansdampf/chronix.fluentd | /lib/fluent/plugin/out_chronix.rb | UTF-8 | 4,837 | 2.53125 | 3 | [
"Apache-2.0"
] | permissive | module Fluent
require 'base64'
require 'msgpack'
require 'protobuf'
require 'rubygems'
require 'rsolr'
require 'zlib'
require_relative 'proto/Point.rb'
require_relative 'proto/StracePoint.rb'
class ChronixOutput < BufferedOutput
Fluent::Plugin.register_output('chronix', self)
config_param :... | true |
d7a44e8e54d9d9826cebe7f71dea6f81372415de | Ruby | fidothe/xeroid | /lib/xeroid/objects/invoice.rb | UTF-8 | 1,382 | 2.625 | 3 | [
"MIT"
] | permissive | require 'xeroid/objects/attributes'
module Xeroid
module Objects
class Invoice
include Attributes
module Status
DRAFT = :draft
SUBMITTED = :submitted
AUTHORISED = :authorised
VOIDED = :voided
DELETED = :deleted
PAID = :paid
VALID = [DRAFT, SUB... | true |
0da641d870756927906dca14eed6dbcf63a94da1 | Ruby | yitzy32/practice_ruby | /desbugging.rb | UTF-8 | 2,276 | 4.34375 | 4 | [] | no_license | # dickens = ["Charles Dickens", "1870"]
# thackeray = ["William Thackeray", "1863"]
# trollope = ["Anthony Trollope", "1882"]
# hopkins = ["Gerard Manley Hopkins", "1889"]
# def died(array)
# name = array[0]
# year = array[1]
# puts "#{name} died in #{year}."
# end
# died(dickens)
# died(thackeray)
# died(troll... | true |
d95a24027c5ff280fe514384cefeb53bc0521cf6 | Ruby | walidwahed/ls | /120-oop/lesson_1-oop_book/object_model.rb | UTF-8 | 1,192 | 4.46875 | 4 | [] | no_license | # How do we create an object in Ruby? Give an example of the creation of an object.
# We create objects in Ruby through the process of instantiation. Instantiation is when we call upon a class in Ruby to generate a new object in the "mold" of that class. This object will have access to the methods of that class, inclu... | true |
a5ca15205119c5e1b4585751b5ad6c25510d5d99 | Ruby | rjb16/Sinatra_Cinema_HW | /console.rb | UTF-8 | 641 | 2.515625 | 3 | [] | no_license | require_relative('models/customer')
require_relative('models/film')
require_relative('models/ticket')
require('pry-byebug')
Ticket.delete_all()
Customer.delete_all()
Film.delete_all()
customer1 = Customer.new({
'name' => 'John',
'funds' => 20
})
customer1.save()
film1 = Film.new({
'title' => 'The GodF... | true |
b126395109d1f94e21fed691608efd4548da4159 | Ruby | joelzerr/rb_101 | /small_problems/easy_4/multiples_of.rb | UTF-8 | 249 | 3.40625 | 3 | [] | no_license | def multisum(number)
range = *(1..number)
result = []
range.select do |n|
if n % 3 == 0 || n % 5 == 0
result << n
end
end
result.sum
end
p multisum(3) == 3
p multisum(5) == 8
p multisum(10) == 33
p multisum(1000) #== 234168
| true |
212c2b776d15866f64480c795b02d8ea43bf38dc | Ruby | thomasvincent/open3_backport | /lib/open3_backport/open3.rb | UTF-8 | 19,811 | 3.203125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"BSD-2-Clause",
"Ruby"
] | permissive | #
# = open3.rb: Popen, but with stderr, too
#
# Author:: Yukihiro Matsumoto, backport by Chris Johnson & David McCullars
# Documentation:: Konrad Meyer, backport by Chris Johnson & David McCullars
#
# Open3 gives you access to stdin, stdout, and stderr when running other
# programs.
#
#
# Open3 grants you a... | true |
79b5090ae280ac5870cc552ca61440c45b166ac2 | Ruby | atpsoft/dohutil | /lib/dohutil/core_ext/bigdecimal.rb | UTF-8 | 995 | 3.15625 | 3 | [
"MIT"
] | permissive | require 'bigdecimal'
require 'bigdecimal/util'
class Integer
if !method_defined?(:to_d)
def to_d
BigDecimal(self)
end
end
end
class BigDecimal
if !method_defined?(:to_d)
def to_d
self
end
end
alias :_doh_original_to_s :to_s
def to_s(format = 'F')
_doh_original_to_s(format)... | true |
9b5d8ebc90c6a78eab4d8222f7b3d29a5d1fc164 | Ruby | CarlosSe/reto-01-ruby-dia-04 | /Game.rb | UTF-8 | 577 | 3.25 | 3 | [] | no_license | require_relative 'CreateBoard'
require_relative 'SearchNeighbors'
require_relative 'ShowGame'
class Game
SIZE = 25
def start
game = CreateBoard.create(size: SIZE)
while true
system('clear')
game.each do |row|
row.each do |cell|
contador = SearchNeighbors.search(game: game, cel... | true |
cc23cfe78ea49d9d312155a6714405306acc74ce | Ruby | 13k/go-steam-resources | /rakelib/logging.rb | UTF-8 | 1,231 | 2.984375 | 3 | [] | no_license | # frozen_string_literal: true
require 'rake'
LOG_M = Mutex.new
COLORS = {
reset: 0,
black: 30,
red: 31,
green: 32,
yellow: 33,
blue: 34,
magenta: 35,
cyan: 36,
white: 37,
}.freeze
# Hack to synchronize rake output messages.
# This won't avoid out-of-order lines from multiple tasks, it will only avo... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.