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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
51bb7ec41865ab94ec014c4e2103d6d1682ebd45 | Ruby | abrofford/ruby-course | /week_three/nov_8/celsius.rb | UTF-8 | 658 | 4.3125 | 4 | [] | no_license | class Fahrenheit
attr_accessor :temp_type, :temperature
def initialize(temp_type, temperature)
@temp_type = temp_type
@temperature = temperature
end
def choice
if @temp_type == "C"
(1.8*@temperature) + 32
elsif @temp_type == "F"
(@temperature - 32)*0.5556
else
puts "Enter... | true |
386b82bc8bcdf3a5ddc4ab132e529c8fb479042c | Ruby | cakejelly/wunderlist | /lib/wunderlist/resource_proxy.rb | UTF-8 | 447 | 2.703125 | 3 | [] | no_license | module Wunderlist
class ResourceProxy
attr_reader :client, :base, :resource
def initialize(client, base, resource)
@client = client
@base = base
@resource = resource
end
def method_missing(method, *args, &block)
@resource.public_send(method, *([client] + args), &block)
en... | true |
65f3756b4954e1e7e52cc6bf4255940670979058 | Ruby | Omeshwor/algorithms | /ruby/String/unrepeated.rb | UTF-8 | 579 | 4.46875 | 4 | [] | no_license | # Remove Repeated Characters
# Create a function that will remove any repeated charcter(s) in a word passed to the function. Not just consecutive characters, but characters repeating anywhere in the input.
# Examples
def unrepeated(str)
arr = str.split("")
arr.uniq.join()
end
puts unrepeated("hello") #➞ "helo"
... | true |
daf5dab1dacaac7358918236acbb6f52d127c568 | Ruby | aokai/plugin_manager | /lib/plugin_manager/tipper_truck.rb | UTF-8 | 970 | 2.828125 | 3 | [
"MIT"
] | permissive | require 'rubygems'
require 'rubygems/dependency_installer'
# This loads and installs gems if needed. This is stolen and modified from:
# http://github.com/mdub/gem_collector/blob/master/lib/gem_collector.rb
class TipperTruck
def self.get
@truck ||= TipperTruck.new
end
def initialize home = nil
if home
... | true |
a99f016b27e571d046cfa97057a91ef49092afe9 | Ruby | josh-works/boeing-fleet-market-share | /app.rb | UTF-8 | 635 | 2.765625 | 3 | [] | no_license | require 'sinatra'
require 'csv'
get "/" do
erb :index
end
post "/sponsors" do
File.open("production.log", "a") do |file|
file.puts params
end
end
get "/sponsors" do
File.open("production.log").read
end
get "/api/top-models-by-number" do
load_csv_data
end
def load_csv_data
csv = DataGetter.get_top_m... | true |
24738f2b5c7b26423f8c165b53b9fe400626be1f | Ruby | 25shwetak/Ruby-Training | /regex.rb | UTF-8 | 1,352 | 2.828125 | 3 | [] | no_license | # frozen_string_literal: true
print 'Enter mobile number'
n = gets
if n.match(/\A[1-9][0-9]{9}\Z/)
print 'A Mobile number'
else
print 'Not a mobile number'
end
puts ' '
puts ' '
print 'Enter email address'
n = gets
if n.match(/\A[a-zA-Z0-9]+[.|_]*[a-zA-Z0-9]+[@][a-zA-Z]+[.][a-z]{3}\Z/)
print 'A valid email a... | true |
259a5d4da9f1559d69457d5860e5697133d21d4c | Ruby | maiyama18/AtCoder | /arc/029/a.rb | UTF-8 | 340 | 2.890625 | 3 | [] | no_license | n = gets.to_i
ts = n.times.map { gets.to_i }
mint = 50 * 4 + 1
[0, 1].repeated_permutation(ts.size).each do |b|
ts0, ts1 = [], []
b.each_index do |i|
case b[i]
when 0
ts0 << ts[i]
when 1
ts1 << ts[i]
end
end
mint = [
mint,
[ts0.reduce(0, &:+), ts1.reduce(0, &:+)].max
]... | true |
378584124c30f99c48681102d1da20c91e88e0fa | Ruby | acui97/GALA-HackOHI-O | /dataAep.rb | UTF-8 | 3,804 | 3.125 | 3 | [] | no_license | # This class uses data from xlsx file to get the information about the AepCostumers and selects it
# with different criteria and use it to send celebration emails.
# Author Ganesh rahut
require 'roo' #ruby gem to read data from xlsx file
require 'date' # Date gem
require_relative 'database' #database class which is... | true |
4dd59d9367ce284e7a6ddfaaa6f268f3476bb692 | Ruby | bolshakov/fear | /lib/fear/either.rb | UTF-8 | 11,279 | 3.8125 | 4 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Fear
# Represents a value of one of two possible types (a disjoint union.)
# An instance of +Either+ is either an instance of +Left+ or +Right+.
#
# A common use of +Either+ is as an alternative to +Option+ for dealing
# with possible missing values. In this usage, +None... | true |
e90c1f4ac7e018d6bf005ad5431d274d69a2c952 | Ruby | viing937/codeforces | /src/246B.rb | UTF-8 | 119 | 2.96875 | 3 | [
"MIT"
] | permissive | n = gets.to_i
a = gets.split.collect{|i| i.to_i}
if a.inject(0){|sum,i| sum+i}%n == 0
puts n
else
puts n-1
end
| true |
1d6e067c3ee37919eb4484a16c3d15d666126ced | Ruby | rubysuperhero/hero-notes | /lib/clitasks/split_on_unescaped.rb | UTF-8 | 128 | 2.734375 | 3 | [
"MIT"
] | permissive | class String
def split_on_unescaped(str)
self.split(/\s*(?<!\\)#{str}\s*/).map{|s| s.gsub(/\\(?=#{str})/, '') }
end
end
| true |
ec9529d74e0636de97d29ed0db84476e14a079b6 | Ruby | malimccalla/traffic-lights | /four-phase-testing/traffic_light/spec/traffic_light_spec.rb | UTF-8 | 804 | 2.953125 | 3 | [] | no_license | require_relative '../lib/traffic_light.rb'
describe TrafficLight do
it 'this is a fantastic test' do
#setup
x = 1
#exercise
x += 1
#verify
expect(x).to eq(2)
#teardown (you will probably not need this)
end
it 'should have the state Red when instantiated' do
expect(subject.state).to eq(:red)
e... | true |
836204dc3a0850ff11e4ad956160d534d9fc88de | Ruby | CocoJu/rbstudy | /src/screencasts/9_methods_p1.rb | UTF-8 | 144 | 3.359375 | 3 | [] | no_license | def hello_world(name)
puts "Hello world"
puts "My name is" + name
end
hello_world("Dmitry")
hello_world("James")
hello_world("Jane") | true |
ac3c5b715bf8e577f2ed450cba55b87b5d772018 | Ruby | bidiaz101/rotate-array-clockwise | /solutions/rotate_array.rb | UTF-8 | 1,690 | 4.15625 | 4 | [] | no_license | def rotate_array(arr, k)
# avoid divide by zero error in Ruby, which will otherwise occur on L5
return arr if arr.empty? || k.zero?
rotations = k % arr.length
removed = arr.slice!(arr.length - rotations, rotations)
removed + arr
end
if __FILE__ == $PROGRAM_NAME
puts "Expecting: [4, 1, 2, 3]"
print rotat... | true |
3709593deea2954269580e7eb8e4ce394effc516 | Ruby | kurokouji/test-Rmenu00 | /Application/Myapp00/CacheReplaceConvert.rb | UTF-8 | 1,735 | 2.96875 | 3 | [] | no_license | # coding: UTF-8
require 'fileutils'
class CacheInitConvert
def initialize()
begin
rescue Exception
raise
end
end
def convHTML(buffer)
w_datetime = Time.now.strftime("%Y%m%d%H%M")
afterScript = "\?var=" + w_datetime
buffer.gsub!(/\?var=[0-9]{12}/, af... | true |
6d9c8b7fc40e3c6501b121833a61fba2b8df2926 | Ruby | volpe28v/kotaren | /app/models/tuning.rb | UTF-8 | 473 | 2.59375 | 3 | [] | no_license | class Tuning < ActiveRecord::Base
has_many :tunes
def progress_average(user)
progress_sum_of_tunes_by_user(user) / number_of_tunes
end
def number_of_tunes
self.tunes.size
end
def number_of_touched_tunes_by_user(user)
progresses_of_tunes.active.by_user(user)
end
private
def progress_sum... | true |
5074cde5c374b86d7b70fa81d3c6fd36097f9c12 | Ruby | MarcusAl/Food-Delivery-App | /app/controllers/customers_controller.rb | UTF-8 | 1,225 | 3.625 | 4 | [
"MIT"
] | permissive | require_relative '../repositories/customer_repository'
require_relative '../views/views'
class CustomersController
# This class handles the management of adding and listing customer data
# It is initialized with the customer repo class
def initialize(customer_repo)
@customer_repo = customer_repo
@view = V... | true |
0563ae71f965447019af08e30d10d5c025f37522 | Ruby | meine-buecherei/meine-buecherei.github.io | /src/db_stat.rb | UTF-8 | 5,977 | 2.53125 | 3 | [] | no_license | # Erzeuge Büchereistatistiken aus Datenbank
require 'yaml'
require 'odbc_utf8'
require 'dbi'
require 'fileutils'
require 'axlsx'
group_conditions = {
# mcode: 1=Buch, 2=Zeitschrift, 5=CD, 17=DVDs
# gruppe1 (Statistikgruppe): 13=SL, 14=Kinder, 12=Sachbücher
:sach => {
:name => "Sachbücher",
:sql => "medi... | true |
9b6dfbb2b9835a570426d470b4aeedd349ae119d | Ruby | arafatm/software-development-curriculum | /nss/exercises/04-testing-practice/testcli/lib/my_app.rb | UTF-8 | 247 | 3.265625 | 3 | [
"MIT"
] | permissive | class MyApp
def initialize(args, stdout)
@stdout = stdout
end
def run
@stdout.puts "Welcome!"
input = gets #Julie
@stdout.puts "Welcome, #{input.strip}"
input = gets #Bob
@stdout.puts "Welcome, #{input.strip}"
end
end
| true |
2b3a817873ad9997556e98bc5c072637137b2acf | Ruby | nick-stebbings/ruby-rb101-109 | /small_problems/Easy_2/ex6.rb | UTF-8 | 608 | 4.125 | 4 | [] | no_license | # Planning based on PEDAC
# https://medium.com/launch-school/solving-coding-problems-with-pedac-29141331f93f
# Problem
# - print all ODD numbers in the range 1..99, one number per line
# Examples
# Data structures
# - input:
# - output:
# Algorithm
# - initialize counter variable
# - Loop: - puts th... | true |
9788327142c67f7f61682376895a2e61658861c2 | Ruby | cruzbasco/Organization | /spec/attribute_spec.rb | UTF-8 | 1,710 | 3.234375 | 3 | [
"MIT"
] | permissive | require 'attribute'
require 'information'
require 'attribute_types/text_type'
require 'attribute_types/numeric_type'
describe "An attribute" do
subject(:text_type) {TextType.new}
subject(:attribute) {Attribute.new("","",text_type,Information::PUBLIC)}
it "has a property" do
attribute.add_property("sample"... | true |
fb52596d9a29e6df802b0bc2c0853ae3df0e8ec7 | Ruby | r3nya/Learning-ruby | /4mono/init.rb | UTF-8 | 335 | 2.625 | 3 | [] | no_license | require_relative "garage"
require_relative "cars"
@cars = []
@cars << Cars.new({ :name => "lada", :price => 300, :year => 2012 })
@cars << Cars.new({ :name => "audi", :price => 800, :year => 2000 })
@cars << Cars.new({ :name => "bmw", :price => 900, :year => 2002 })
@cars << Cars.new({ :name => "vw", :price => 600, :y... | true |
e5f56ac344c3c1453207f851c63f0dd0aeba6252 | Ruby | SiCuellar/LeetCode | /Ruby/Prac1/longest_common_prefix/lcp.rb | UTF-8 | 527 | 3.59375 | 4 | [] | no_license | require "pry"
class Lcp
def longest_common_pre(words)
words.each_with_index do |word, index|
binding.pry
word_compare(word, words[index+1])
end
end
def word_parser(word)
word.chars
end
def word_compare(first_w, sec_w)
common_prefix = []
first_letters = word_parser(first_w)
... | true |
07289d6d28a7ef2e9e1268582e9848cb7c2a90fa | Ruby | sittercity/bureaucrat | /lib/bureaucrat/fields/big_decimal_field.rb | UTF-8 | 2,830 | 2.875 | 3 | [
"MIT"
] | permissive | require 'bigdecimal'
require 'bureaucrat/fields/field'
require 'bureaucrat/validation_error'
require 'bureaucrat/validators/max_value'
require 'bureaucrat/validators/min_value'
module Bureaucrat
module Fields
class BigDecimalField < Field
def initialize(options={})
@max_value = options[:max_value]
... | true |
0a3f265b35c21d4a3d10f71357cac4f52e909a4c | Ruby | gregspencer/blackjack | /blackjack.rb | UTF-8 | 2,439 | 3.875 | 4 | [] | no_license | cards = ["2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King", "Ace"]
suits = ["Hearts", "Clubs", "Spades", "Diamonds"]
deck = cards.product(suits).shuffle
player_hand = []
computer_hand = []
player_hand << deck.pop
computer_hand << deck.pop
player_hand << deck.pop
computer_hand << deck.pop
def cal... | true |
34551d7c942a192b45ba8baf444392acce4c8cfd | Ruby | philipdesmedt/bitcoin_analytics | /experimental/bitcoin_address_growth.rb | UTF-8 | 703 | 3.109375 | 3 | [
"LicenseRef-scancode-warranty-disclaimer"
] | no_license | # WIP: Below data is wrong.
require 'csv' # frozen_string_literal: true
FILE = 'btc.csv'
days = 365 if ARGV.empty? || !ARGV[0].to_i.is_a?(Numeric)
bitcoin_data = CSV.parse(File.read(FILE), headers: true, col_sep: ',')
days ||= ARGV[0].to_i
bitcoin_data = bitcoin_data[bitcoin_data.length - days..bitcoin_data.length]
d... | true |
901ef81edb0553fda4c9a0854390474a00dd0f0c | Ruby | zgavin/moo2maps | /lib/models/star.rb | UTF-8 | 2,533 | 2.515625 | 3 | [] | no_license | class Star
include Model
belongs_to :player
belongs_to :wormhole_star,:type=>'star'
has_many :ships,:leaders
pointable
def clear
clean_dependents
super
end
def clean_dependents
planets.compact.each do |planet|
planet.clear if planet.star == self
end
ship... | true |
447a2d6f698bb28927a3ed59211746ed50eae84c | Ruby | cradle/feedtools | /lib/feed_tools/database_feed_cache.rb | UTF-8 | 5,169 | 2.515625 | 3 | [] | no_license | #--
# Copyright (c) 2005 Robert Aman
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# d... | true |
c6024485168fb36180215318d51236d88914ca29 | Ruby | danieln96/BookWeb_SIAG | /app/models/book.rb | UTF-8 | 459 | 2.828125 | 3 | [] | no_license | require 'net/http'
class Book < ApplicationRecord
has_many :opinions
validates :title, presence: {message: "Musisz podać tytuł"}
validates :author, presence: {message: "Musisz podać autora"}
validates :genre, presence: {message: "Musisz podać kategorię"}
def position
books = Book.all... | true |
c86dc87f1d8997655069e13b0bde162fac9d5958 | Ruby | jgamsan/spree_green_tax | /app/models/spree/calculator/tire_green_rate.rb | UTF-8 | 1,540 | 2.703125 | 3 | [
"BSD-3-Clause"
] | permissive | require_dependency 'spree/calculator'
module Spree
class Calculator::TireGreenRate < Calculator
def self.description
I18n.t(:green_rate)
end
def self.register
super
end
def compute(order)
compute_order(order)
end
def find_green_rate(variant)
# calculate the tax ... | true |
9daa3411faed5a6dd625db1792d90abc04aceea7 | Ruby | dpad22/Ruby_Assignments | /basic13.rb | UTF-8 | 4,435 | 4.6875 | 5 | [] | no_license | # Assignment: Basic 13
# Solve all 13 problems below in as much of a Ruby way as possible.
# Bonus: Try to use as few lines as possible for each question
# Print 1-255
# Write a program that would print all the numbers from 1 to 255.
# for i in 1..255
# puts i
# end
puts (1..255).to_a
# # Print odd numbers be... | true |
61d8b0036f68cfda69f4191b3be13e3978b5e59f | Ruby | obliviusm/two_nums | /main.rb | UTF-8 | 1,510 | 3.671875 | 4 | [] | no_license | require_relative 'merge_sort'
require_relative 'radix_sort'
require_relative 'mark_sort'
def has_two_nums? c, x
# x = NUMBERS.dup
x = x.delete_if {|n| n + x.first > c }
i = 0
j = x.length - 1
while i != j do
sum = x[i] + x[j]
if sum < c
i += 1
elsif sum > c
j -= 1
else
ret... | true |
070c03804086f9ee7e56b159a39cbdc691699cb6 | Ruby | corbinsykes/sinatra-to-do-homework | /main.rb | UTF-8 | 2,143 | 2.640625 | 3 | [] | no_license | require 'pry'
require 'sinatra'
require 'pg'
require 'sinatra/reloader' if development?
# List todo items
get '/' do
db = PG.connect(:dbname => 'lists', :host => 'localhost')
sql = "SELECT * FROM to_do"
@todo = db.exec(sql)
db.close
erb :todos
end
# Show the details of a todo
get '/todo/:id' do
id = par... | true |
10ca4b0a771fe8ced96d4cc9c9fb950920286f6a | Ruby | NZenitram/sendgrid-stats-api-consumer | /app/helpers/global.rb | UTF-8 | 1,020 | 2.546875 | 3 | [
"MIT"
] | permissive | class Global
attr_accessor :date, :blocks, :bounce_drops, :bounces, :clicks, :deferred, :delivered, :opens, :invalid_emails, :processed, :requests, :spam_report_drops, :spam_reports, :unique_clicks, :unique_opens, :unsubscribe_drops, :unsubscribes, :user_id
def initialize(date, blocks, bounce_drops, bounces, click... | true |
629d79a9ca1f0ba900ebdd89fb6f9dc8dea679e0 | Ruby | erikolsen/battleship | /print_board.rb | UTF-8 | 707 | 3.5625 | 4 | [] | no_license | # string = '619030040270061008000047621486302079000014580031009060005720806320106057160400030'
# Takes board as an array of arrays. Output is a series of strings.
def print_board(board)
puts "+- - - - - - - - - - - - - - - -+"
for row in (0..8)
print "| "
for col in (0..8)
cell = board[row][col]
... | true |
70a5ea7e0b3c23f7036b24812a59b6ac76e64092 | Ruby | pingworks/mofa | /lib/mofa/cmd_line_args.rb | UTF-8 | 453 | 2.78125 | 3 | [
"Apache-2.0"
] | permissive | module Mofa
class CmdLineArgs
def self.instance
@__instance__ ||= new
end
def initialize
@cmd_line_args = {}
end
def register(cmd_line_args)
@cmd_line_args = cmd_line_args
end
def get(key)
raise "Cmd Line Arg with key #{key} does not exist!" unless @cmd_line_args... | true |
6e4a71d086cffb9cef9e5aec58789312dae87134 | Ruby | tomekw/yaml_converters | /lib/yaml_converters/yaml_to_segments_converter.rb | UTF-8 | 943 | 2.828125 | 3 | [
"MIT"
] | permissive | require "psych"
module YamlConverters
class YamlToSegmentsConverter
def initialize(yaml_reader, segment_writer = YamlConverters::SegmentToHashWriter.new)
@yaml_reader = yaml_reader
@segment_writer = segment_writer
end
def convert
flatten_hash(raw_yaml_hash)
@segment_writer.re... | true |
d2edd84c5e82313fa7ee5622d86f9e7d72740edf | Ruby | rimvydasa/Ruby-projektai | /ruby-1-uzd/Skaitmenu_dubliavimas/dubliavimas.rb | UTF-8 | 176 | 3.3125 | 3 | [] | no_license | sk = 0
puts ("Iveskite sk: ")
n = gets
while n.to_i != 0
temp = n[0..0]
n = n[1..-1]
sk = sk.to_i * 100 + temp.to_i * 10 + temp.to_i
end
puts("result: #{sk}")
| true |
3748ac18d7970e1aa628db58d190b51484d90067 | Ruby | shawn42/killbox | /src/debug_draw.rb | UTF-8 | 184 | 3.0625 | 3 | [] | no_license | class DebugDraw
attr_reader :draw_blocks
def initialize
clear
end
def clear
@draw_blocks = {}
end
def draw(name, &block)
@draw_blocks[name] = block
end
end
| true |
9e912db2a184d3b74bed8d32f9c0d7d99084ffdf | Ruby | J-Y/RubyQuiz | /ruby_quiz/quiz11_sols/solutions/Brian Schroeder/tictactoe-interface.rb | UTF-8 | 2,740 | 3.875 | 4 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
# Contains different interfaces to play tic tac toe.
# An Interface can either connect to a person or to a artificial intelligence.
#
# Maybe the word Interface is not really a perfect choice here.
module Interface
class BasicInterface
attr_accessor :player
def initialize()
end
... | true |
f8042d1f010609d20b37ce43cc762af316e4d429 | Ruby | ta1kt0me/scheme-in-ruby | /cap1/eval.rb | UTF-8 | 2,796 | 3.1875 | 3 | [] | no_license | require 'byebug'
def _eval exp, env
if not list?(exp)
if immediate_val? exp
exp
else
lookup_var exp, env
end
else
if special_form? exp
eval_special_form exp, env
else
fun = _eval(car(exp), env)
args = eval_list(cdr(exp), env)
apply fun, args
end
end
end... | true |
8d54d34c7003c0531cbf28df49a251898f6dd96d | Ruby | rsocci/Euler | /fib.rb | UTF-8 | 806 | 4 | 4 | [] | no_license | # Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:
# 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
# By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.
re... | true |
42297a034c58375188a08865b3385302682c10d1 | Ruby | ChrisBaker-dev/TerminalApplication | /src/profile.rb | UTF-8 | 3,053 | 3.421875 | 3 | [] | no_license | require 'tty-table'
class Profile
attr_reader :username, :description, :available_funds, :investments, :starting_funds, :key
def initialize(username) # may want to remove starting funds from here
@username = username
@description = ''
@available_funds = starting_funds
@starting... | true |
5eca881de917e109978d97671571866fa940d515 | Ruby | albertbahia/wdi_june_2014 | /w03/d02/alexandra_ackerman/hw_w03_d02/lib/pokemon_seed_script.rb | UTF-8 | 977 | 2.921875 | 3 | [] | no_license | require_relative './pokemon_seed.rb'
require 'pry'
require 'active_record'
require_relative 'pokemon.rb'
ActiveRecord::Base.establish_connection({
database: 'pokemon_db',
adapter: 'postgresql'
})
# pokemon = get_pokemon
def get_moves(moves_hash)
result = ''
moves_hash.each do |key,value|
value.each do ... | true |
1129b828a1f1ff051dbb5aff2b728bea284fb3e3 | Ruby | paploo/ProjectEuler | /Ruby/lib/extensions/string/digits.rb | UTF-8 | 137 | 2.796875 | 3 | [] | no_license | module Extensions
module String
module Digits
def to_digits
self.chars.map {|c| c.to_i}
end
end
end
end | true |
719f6184383698827bfcf6306f0df183bec8e3c6 | Ruby | webmil-internship/tokenizr | /lib/providers/base_provider.rb | UTF-8 | 356 | 2.71875 | 3 | [] | no_license | module Providers
class BaseProvider
attr_accessor :key_phrase
def initialize(key_phrase)
@array = []
@key_phrase = key_phrase
end
def results
raise 'Key_phrase has invalid format.' unless key_phrase.is_a?(String)
search_word
save_array
end
def search_word; end
... | true |
6237fb94252495c0e9ccc38db67c6d83aba338f8 | Ruby | joacomf/STR-simulador | /model/planificador_fifo.rb | UTF-8 | 741 | 2.90625 | 3 | [] | no_license | require_relative './planificador'
class PlanificadorFIFO < Planificador
def initialize(procesador)
tareas = PQueue.new([]) do |tarea1, tarea2|
criterio(tarea1, tarea2)
end
super(procesador: procesador, tareas: tareas)
end
def siguiente_tarea
tarea_seleccionada = @nop
tarea = @tareas.... | true |
f31779fc9d57321c1725865a41034f140b51d6ad | Ruby | codeunion/fundamentals-of-web-development | /session-notes/2015-02-19/lambda-example.rb | UTF-8 | 1,992 | 3.421875 | 3 | [] | no_license | input_person = {
id: '213', # => "213"
name: 'buddy', # => "buddy"
birthday: 'June 30, 1982' # => "June 30, 1982"
} # => {:id=>"213", :name=>"buddy", :birthday=>"June 30, 1982"}
require 'date' # => true
class User
attr_accessor :id, :name, :birthday # ... | true |
e89eef9c4fac5f815f823df03fde5d3980107fd6 | Ruby | yumayo14/character_game | /skills/fighter_skill.rb | UTF-8 | 377 | 2.9375 | 3 | [] | no_license | # frozen_string_literal: true
require_relative '../skill'
require_relative 'fighter_skills/fighter_man_skill'
require_relative 'fighter_skills/fighter_woman_skill'
class FighterSkill < Skill
def name
checked_skill.name
end
private
def checked_skill
return FighterManSkill.new if sex.name == 'man'
... | true |
9b070a460ff95b8bae3a739a99f4303cefcea0c4 | Ruby | soramugi/hayday-data | /models/items.rb | UTF-8 | 375 | 3 | 3 | [] | no_license | class Items
def csv
require "csv"
CSV.open(File.expand_path(File.dirname(__FILE__)) + "/../data/item_list.csv", "r")
end
def list
list = []
self.csv.each do |csv|
item = Item.new
item.name = csv.shift
item.price = csv.shift.to_f
item.max_price = csv.shif... | true |
72820cec1fd6dcf7b4dcb51b51f3afe9feacd436 | Ruby | diogo55/OnlinePythonTutor | /v4-cokapi/backends/ruby/tests/constants-3.rb | UTF-8 | 285 | 4.125 | 4 | [
"MIT"
] | permissive | # adapted from http://www.tutorialspoint.com/ruby/ruby_variables.htm
class Example
VAR1 = 100
VAR2 = 200
def show
puts "Value of first Constant is #{VAR1}"
puts "Value of second Constant is #{VAR2}"
end
end
# Create Objects
object=Example.new()
object.show
| true |
f66ce1f3c87a25be85d510848a7b97366d4fb221 | Ruby | lilychencodes/aA_recursion_exercises | /array.rb | UTF-8 | 864 | 3.53125 | 4 | [] | no_license | class Array
def my_each(&prc)
self.length.times do |index|
prc.call(self[index])
end
self
end
def my_map(&prc)
new_array = []
self.my_each do |el|
new_array << prc.call(el)
end
new_array
end
def my_select(&prc)
new_array = []
self.my_each do |el|
new_arr... | true |
f6fb210e50f481cb358ece3bc27d5b36888c0fc1 | Ruby | johannes-keinestam/tpv715-rental-system | /lib/views/listings_menu.rb | UTF-8 | 3,594 | 3.625 | 4 | [] | no_license | require_relative "welcome_menu"
require_relative "../data/order_handler"
require_relative "../data/product_handler"
#Menu which shows selection and customer listings to the user.
module ListingsMenu
#Shows main listings menu
def ListingsMenu.show
system "cls"
puts "========================================... | true |
e95bb363f19a35ebc81f4b47f6a8ff037df36da5 | Ruby | dstanley1994/trac_lang | /spec/parser_spec.rb | UTF-8 | 6,895 | 2.9375 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
module TracLang
RSpec.describe Parser do
describe 'parsing' do
before do
@p = Parser.new
@failer = proc { fail 'unreachable' }
@empty_result = {value: '', force: false}
end
context 'given bad string' do
it 'sends reset' do
... | true |
5cffc4291bb310b5f9d5c71a78d1fcb99a41a688 | Ruby | tzmfreedom/apex_parser | /lib/apex_parser/runtime/array.rb | UTF-8 | 1,580 | 2.671875 | 3 | [
"MIT"
] | permissive | module ApexParser
ApexClassCreator.new do |c|
c.add_class(:Array, %i[public])
c.add_instance_method(:Array, %i[public], :void, []) do |local_scope|
this = local_scope[:this]
this.apex_instance_variables[:records] = [SObject.new, SObject.new]
end
c.add_instance_method(:next, %i[public], :... | true |
5a95f9f2b138ce295bd8233de1b8475946007094 | Ruby | nellams/leaderboard | /lib/leaderboard.rb | UTF-8 | 2,416 | 3.484375 | 3 | [] | no_license | require_relative 'team'
GAME_INFO = [
{
home_team: "Patriots",
away_team: "Broncos",
home_score: 17,
away_score: 13
},
{
home_team: "Broncos",
away_team: "Colts",
home_score: 24,
away_score: 7
},
{
home_team: "Patriots",
away_team: "Colts"... | true |
3a5d3fae08ee906243482859817a519b25db559a | Ruby | DanL12186/sinatra-mvc-lab-v-000 | /spec/sinatra_mvc_lab_spec.rb | UTF-8 | 2,199 | 2.875 | 3 | [] | no_license | describe "Pig Latinizer App" do
describe "GET '/'" do
before(:each) do
get '/'
end
it "returns a 200 status code" do
expect(last_response.status).to eq(200)
end
it "renders the instructions" do
expect(last_response.body).to include("Pig Latinizer!")
end
it "renders a n... | true |
b46b7e6af474cb1704587b3dc30e7c765fc396cc | Ruby | stevenocchipinti/tank | /www/Tank.rb | UTF-8 | 3,186 | 3.375 | 3 | [] | no_license | class Tank
P_ADDR=0x378
P_FILE="/dev/port"
def initialize()
# Open the parallel port
@p = open(P_FILE, 'w')
@p.sync = true
end
# ============================================================================
# Movement methods
# ================================================================... | true |
a068955af69a1794e99596fd32a975c0495b08b2 | Ruby | matthewpaulmcgowan/ruby-music-library-cli-v-000 | /lib/music_library_controller.rb | UTF-8 | 2,891 | 3.703125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class MusicLibraryController
def initialize(path="./db/mp3s")
@path=path
MusicImporter.new(path).import
end
def call
response=nil
while response!= "exit"
puts "Your choices are list songs, list artists, list genres, play song, list artist, list genre, or exit"... | true |
8450dcb105a0cf977df80c42a3fb4b3cbabfdb6c | Ruby | tbogus/codeforces-ruby | /1263b_PIN_codes.rb | UTF-8 | 555 | 3.25 | 3 | [] | no_license | # https://codeforces.com/problemset/problem/1263/B
gets.to_i.times do
count = gets.to_i
cards = []
digits = Array.new(10, false)
count.times do |i|
cards << card = gets.chomp.split('').map(&:to_i)
digits[cards[i][0]] = true
end
moves = 0
i = 0
while i < count do
j = i + 1
while j < count do
... | true |
de17862531a281f74ac1c6b5f639f9cdeb2f0ea2 | Ruby | nsatragno/cookie-tower-defense | /app/levels/level.rb | UTF-8 | 804 | 2.71875 | 3 | [] | no_license | class Level
ENEMY_SPAWN_TIME = 120
attr_reader :allowed_buttons
attr_reader :map
attr_reader :path
attr_reader :spawn
attr_reader :base
attr_reader :song
def initialize
@timer = 0
@map = []
(0...Tileset::WIDTH).each do |x|
line = []
(0...Tileset::HEIGHT).each do |y|
li... | true |
f3f351790c0dd232f1a92bb2ea67ee9d2be78f79 | Ruby | chn-challenger/takeaway-challenge | /lib/takeaway.rb | UTF-8 | 163 | 3.171875 | 3 | [] | no_license | class TakeAway
attr_reader :menu, :orders
def initialize(menu)
@menu = menu
@orders = []
end
def take_order(order)
orders << order
end
end
| true |
f8613c65c4733fe24c463f2666edde8ae5c4157f | Ruby | NYPL/lionactor | /lib/lionactor/blog.rb | UTF-8 | 303 | 2.515625 | 3 | [
"MIT"
] | permissive | module Lionactor
class Blog < Resource
attr_reader :pubdate, :author
# @param data [Hash] Parsed JSON data for the Location resource
def initialize(data)
super(data)
@pubdate = DateTime.strptime(data['pubdate'])
@author = OpenStruct.new(data['author'])
end
end
end
| true |
72d7f7f1e1d5f88d1a725c32d56de29e25af4796 | Ruby | vendetta546/codewars | /Ruby/4KYU/TextAlign.rb | UTF-8 | 2,833 | 3.6875 | 4 | [] | no_license | =begin
our task in this Kata is to emulate text justification in monospace font.
You will be given a single-lined text and the expected justification width.
The longest word will never be greater than this width.
Here are the rules:
Use spaces to fill in the gaps between words.
Each line should contain as many words... | true |
cc9aa49ecbd8d3cc0ecf59ec2b44cb223c2508fa | Ruby | MAshrafM/The_Odin_Project | /11_Data_Structure/BinTrees/spec/node_spec.rb | UTF-8 | 534 | 2.65625 | 3 | [
"MIT"
] | permissive | # spec/node_spec
require "spec_helper"
module BinTrees
describe Node do
context "#initialize" do
it "raise an exception when init no value" do
expect{Node.new()}.to raise_error
end
it "init node value" do
node = Node.new(4)
expect(node.value).to be 4
end
it "child work" do
... | true |
66f29894bd079be3ecb10f0956359dc421b5d399 | Ruby | Vrturo/Algo-Gem | /Algorithms/Ruby/arrays/shellgame.rb | UTF-8 | 1,631 | 4 | 4 | [
"MIT"
] | permissive | # "The Shell Game" involves three shells/cups/etc upturned on a playing surface,
# with a ball placed underneath one of them. The shells are then rapidly swapped round,
# and the game involves trying to track the swaps and, once they are complete,
# identifying the shell containing the ball.
# This is usually a con, b... | true |
eb0186ab269de58215e236558ceeccf05e10403a | Ruby | JayVish/Programming | /Day03/ex02/help_your_professor.rb | UTF-8 | 420 | 3.8125 | 4 | [] | no_license | #!/usr/bin/ruby
def average_mark(grades)
total_pts = 0
grades.each do |name, mark|
total_pts+=mark
end
return total_pts/grades.size
end
class_01 = {
"margot" => 18,
"jenny" => 8,
"billy" => 14
}
class_02 = {
"bob" => 16,
"the" => 20,
"builder" => 17
}
puts "Average mar... | true |
edab054457674276305bc5e2eb749df87036acad | Ruby | jeffreyroy/games-on-rails | /app/models/piece.rb | UTF-8 | 396 | 3.265625 | 3 | [] | no_license | class Piece
attr_accessor :location
# Set initial location
def initialize(game, location)
# @game = game
@location = location
end
# Return true if location is a valid destination
# Default is to let game handle this
def inbounds(destination)
# @game.inbounds(destination)
end
# Return l... | true |
5c14c710ca9ccc520a068bea9c8de15d2cb792b9 | Ruby | jude-lawson/coding_challenges | /ruby_challenges/lib/fizz_buzz.rb | UTF-8 | 275 | 3.9375 | 4 | [] | no_license | print "What range do you want? "
input = gets.chomp.to_i
range = (1..input)
range.each do |number|
if number % 3 == 0 && number % 5 == 0
puts 'FizzBuzz'
elsif number % 3 == 0
puts 'Fizz'
elsif number % 5 == 0
puts 'Buzz'
else
puts number
end
end
| true |
1fc90c2bf3cda44587ae8e011d6539e3b50d5554 | Ruby | kosmatov/konfi | /lib/konfi/builder.rb | UTF-8 | 948 | 2.71875 | 3 | [
"BSD-3-Clause"
] | permissive | class Konfi::Builder
attr_reader :config
def self.build(env, &block)
builder = new(env, &block)
builder.config
end
def initialize(env, &block)
@envs = {}
@ancestry = {}
instance_eval(&block)
check_cycle!(env)
santa_barbara(env)
@config = Konfi::Config.new @envs[env]
end
... | true |
da246a36d3dfa6a3267f7d4efe00d3050eafdbba | Ruby | royachobineh/TwO-O-Player-Math-Game | /player.rb | UTF-8 | 202 | 3.75 | 4 | [] | no_license | class Player
attr_accessor :name, :lives
def initialize (name)
self.name = name
self.lives = 3
end
def lose_life
self.lives -= 1
end
def alive
self.lives > 0
end
end | true |
882dcef8fdb2f1e106fc789b5bb6437f00971c3c | Ruby | jasondoggart/churchconnect | /test/models/memory_verse_test.rb | UTF-8 | 760 | 2.59375 | 3 | [] | no_license | require 'test_helper'
class MemoryVerseTest < ActiveSupport::TestCase
def setup
@memory_verse = MemoryVerse.new(verse: "A scripture verse", reference: "A reference", verse_date: "September 25, 2017")
end
test "should be valid" do
assert @memory_verse.valid?
end
test "verse should be present" do
... | true |
583736b305b7ed0772f245e894169d5fb4ef8360 | Ruby | gerard-morera/altmetric | /01-problem/lib/validators/article.rb | UTF-8 | 943 | 2.953125 | 3 | [] | no_license | require_relative './properties/doi.rb'
require_relative './properties/title.rb'
require_relative './properties/issn.rb'
module Validators
class Article
def initialize data, doi_validator: Validators::Properties::Doi, title_validator: Validators::Properties::Title, issn_validator: Validators::Properties::Issn
... | true |
1edfdff5a0c02e7f2d3e9e9ae117d86cf05ffbe1 | Ruby | andreybakanovsky/homeworks-2021 | /HW04/Pavel_Shalyga/lib/notification.rb | UTF-8 | 216 | 2.921875 | 3 | [] | no_license | # Notification class is used to notify students or mentors about changes
class Notification
attr_accessor :messages
def initialize
@messages = []
end
def add(message)
@messages << message
end
end
| true |
ce82da3b067685f5e4f100dc0960b0e2afe25933 | Ruby | frausto/skillz | /lib/skillz/match.rb | UTF-8 | 1,146 | 2.890625 | 3 | [
"MIT"
] | permissive | module Skillz
class Match
def self.score(*teams)
#set initial values
teams.each{|t| t.uncertainty; t.skill_level}
teams.each do |team1|
omega = 0.0
delta = 0.0
teams.each do |team2|
next if team1 == team2
ciq = Math.sqrt(team1.uncertainty + team2.un... | true |
bbc7303893b80eded302cdcdc704d3409ec4ab10 | Ruby | zjentohlauedy/MBA | /ScheduleParser.rb | UTF-8 | 2,519 | 3.265625 | 3 | [] | no_license | class ScheduleParser
class Game
attr_reader :played, :home_team, :road_team, :home_score, :road_score
attr_accessor :televised, :number
def initialize( road_team, home_team, road_score = nil, home_score = nil )
@home_team = home_team
@road_team = road_team
@home_score = home_score.to_i... | true |
dc1dc950638e9b8526dd7e98a1c05298af563a68 | Ruby | Msagusa/bdd_projects | /bsmi-master/app/helpers/mentor_teacher/schedules_helper.rb | UTF-8 | 826 | 2.59375 | 3 | [] | no_license | module MentorTeacher::SchedulesHelper
#Convert cal event hashes into javascript
def dump_events(cal_events)
cal_events.each do |e|
monkey_patch_event(e)
end
JSON.dump(cal_events)
end
def dump_event(cal_event)
monkey_patch_event(cal_event)
JSON.dump(cal_event)
end
def monkey... | true |
9b92e7cb5f5aa0d7521333d49401f48d81915276 | Ruby | olsonmatt/devmatt | /ruby/arraytest.rb | UTF-8 | 204 | 3.171875 | 3 | [] | no_license |
excuse_array = ["the inclement weather.", "the fact that I didn't sleep well.", "the fact that my parents are no longer able to watch my children today."]
excuse = excuse_array.sample
print "#{excuse}" | true |
b6c223d6084e76903168c2bb62c31e915379dc5a | Ruby | joshweir/tormanager | /lib/tormanager/create_eye_config.rb | UTF-8 | 695 | 2.703125 | 3 | [
"MIT"
] | permissive | module TorManager
class CreateEyeConfig
def initialize params={}
@settings = params
end
def create
File.open(@settings[:eye_tor_config_path], "w") do |file|
file.puts read_eye_tor_config_template_and_substitute_keywords
end
end
private
def read_eye_tor_config_templ... | true |
ec3794aea26e4e50a650b3dbe033859d477a65df | Ruby | GregoryJFischer/black_thursday | /spec/item_spec.rb | UTF-8 | 1,361 | 3.015625 | 3 | [] | no_license | require_relative 'spec_helper'
require 'Rspec'
require 'bigdecimal'
require_relative '../lib/item'
describe Item do
before :each do
@i = Item.new({
:id => '1',
:name => 'Pencil',
:description => 'You can use it to write things',
:unit_price => '10.99',
:created_at ... | true |
818b7aa01411d02c12cf7432bfa9990a8eb88058 | Ruby | ChrisWade112358/learn-co-sandbox | /cli-2/cli-2/lib/author.rb | UTF-8 | 3,039 | 3.53125 | 4 | [
"MIT"
] | permissive | class Author
attr_accessor :name, :page
@@all = []
def initialize(name)
@name = name
@@all << self
end
def self.all
@@all
end
def self.search_or_new(item)
object = @@all.select{|a| a.name == item}
if object == []
object = Author.new(item)
object
end
... | true |
88f250f2a75cac33989cefe711ed721611239629 | Ruby | ambercodes/practicing-ruby | /untilex2.rb | UTF-8 | 100 | 3.640625 | 4 | [] | no_license | puts "Give me a number between 1-10."
num = gets.chomp.to_i
until num <= 0
puts num
num -=1
end
| true |
2676f5f4acf45c796f907b21fbfa41d83e506bd2 | Ruby | tungshan/general | /dallaspermits/parse_permits_t.rb | UTF-8 | 1,132 | 3.109375 | 3 | [] | no_license | require 'nokogiri'
require 'open-uri'
class String
alias_method :old_strip, :strip
def strip
self.gsub(/^[\302\240|\s]*|[\302\240|\s]*$/, '').gsub(/(\n)|\s+/,' ')
end
end
doc = Nokogiri::HTML(open('abbr_permitsjan2008.html'))
#remove <span> tags within <td>
doc.css('table tr td span').each do |element|
element... | true |
db797943330bae10b21feb2e990da3d560154e85 | Ruby | alexm/refactoring-book | /ruby/test/tc_statement.rb | UTF-8 | 1,553 | 3.359375 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'test/unit'
require 'movie'
require 'rental'
require 'customer'
class StatementTest < Test::Unit::TestCase
def setup
if Movie.instance_methods.find_index(:price=)
movie = Movie.new("The Watchmen", NewReleasePrice.new)
movie2 = Movie.new("The Quiet Man", ... | true |
67043648d9e082345c8373b4ae969ccc0221f0c1 | Ruby | warrenniu/ruby-project-guidelines | /app/models/user.rb | UTF-8 | 1,740 | 2.859375 | 3 | [
"MIT"
] | permissive | require 'tty-prompt'
class User < ActiveRecord::Base
has_many :games
has_many :planets, through: :games
@@prompt = TTY::Prompt.new
def self.create_account
@@prompt.say("Type exit to leave the program",color: :red)
username = @@prompt.ask("Enter your full name i.e. LukeSkywalker")
... | true |
f5488b5f55ee35a88def497b1037fef614748a6b | Ruby | giorgi01/ruby-playground | /Book_exercises/10. Exceptions/rescue-ensure.rb | UTF-8 | 220 | 2.703125 | 3 | [] | no_license | begin
k = 2/0
k += 'one'
rescue TypeError, NameError => boom
print "String doesn't compile: #{boom}\n"
rescue ZeroDivisionError => bang
print "Error running script: #{bang}\n"
ensure
print "End of the programe."
end | true |
dd42d79b4cfc9fb54c01c3d908eab4556679f39c | Ruby | ukutaht/Flashcard | /flashcard_view.rb | UTF-8 | 948 | 3.203125 | 3 | [] | no_license | class FlashcardView
attr_reader :user_answer
def initialize
@user_answer
@answer
end
def display_welcome
puts "Welcome to Flashcards"
puts "You'll get a definition: try and provide a matching term"
# puts "Type 'next' if you want to move on to the next card question"
# puts "Type 'qui... | true |
6a5227607ca50ffe183a4b4a0ab98d0daad1bfd6 | Ruby | msgpack/msgpack-ruby | /spec/exttypes.rb | UTF-8 | 823 | 2.796875 | 3 | [
"Apache-2.0"
] | permissive | class DummyTimeStamp1
TYPE = 15
attr_reader :utime, :usec, :time
def initialize(utime, usec)
@utime = utime
@usec = usec
@time = Time.at(utime, usec)
end
def ==(other)
self.utime == other.utime && self.usec == other.usec
end
def self.type_id
15
end
def self.from_msgpack_ext(da... | true |
a33823bc13774f8b2e593867f2794e57efaa690f | Ruby | Chris-Wong-1/ruby-algorithms | /sieve_of_eratosthenes.rb | UTF-8 | 849 | 4.375 | 4 | [
"MIT"
] | permissive | def sieve_of_eratosthenes(max)
# Create an array with all numbers 0 through max
primes = (0..max).to_a
# Set the first and second position to nil because 0 and 1 are not prime
primes[0] = nil
primes[1] = nil
counter = 0
primes.each do |num|
# Skip if nil
next unless num
# Break once we excee... | true |
563a5d1f23bc54ca6d887aebcd2eab03a6963492 | Ruby | cin9247/MealMonster | /app/interactors/create_tour.rb | UTF-8 | 581 | 2.546875 | 3 | [] | no_license | require_relative "./base"
require_relative "../models/tour"
module Interactor
class CreateTour < Base
register_boundary :customer_gateway, -> { CustomerMapper.new }
register_boundary :tour_gateway, -> { TourMapper.new }
def run
customers = customer_gateway.find(request.customer_ids)
tour... | true |
21228e30623906bbb48dbf91a1a3aa5fedc42ac1 | Ruby | jazzarati/csv_piper | /lib/csv_piper/piper.rb | UTF-8 | 2,133 | 2.8125 | 3 | [
"MIT"
] | permissive | module CsvPiper
class Piper
HEADER_LINE_INDEX = 1
FIRST_DATA_LINE_INDEX = 2
CSV_HEADER_OPTIONS = { headers: true, return_headers: true, skip_blanks: true, skip_lines: /^(\s*,)*$/ }
def initialize(io_stream:, pre_processors: [], processors: [], csv_options: {}, required_headers: [])
@pre_process... | true |
d97527b7893605e9fbfdff7d9321a2ff38a06816 | Ruby | drewlong/twitter_datamining | /twitter_search_url_spider.rb | UTF-8 | 3,053 | 2.796875 | 3 | [] | no_license | # This is an example of how to combine a previous module of mine, SpidrTools
# with my Twitter API wrapper and a MySQL database, via mysql2 gem, to
# aggregate email lists from Twitter searches. The primary method of operation
# is to use search terms from saved term lists to aggregate targeted tweets,
# and then col... | true |
4e2a0a430b187a8e3d580f1ef8e44bdb90747a78 | Ruby | fivesenses/cropster | /lib/cropster/response/machine.rb | UTF-8 | 413 | 2.609375 | 3 | [
"MIT"
] | permissive | ##
# Converts a Hash object into a Cropster::Response::Machine
#
module Cropster::Response
class Machine < Cropster::Response::FormattedResponseItem
attr_accessor :name, :machine_type, :capacity
def load_attributes(attributes)
return if attributes.nil?
@name = attributes[:name]
@machine_typ... | true |
7dc915f0ff8e5183f13d13db8fd792a521268178 | Ruby | wesley974/rubygame | /lib/system.rb | UTF-8 | 404 | 3.1875 | 3 | [
"MIT"
] | permissive | require 'io/console'
# Trapping and press any key features
class System
def bybye
puts "Goodbye #{@name}.\n\n"
exit
end
def ctrlc_trap
trap('INT') do
ctrlc_action
end
end
def ctrlc_action
print "\r^C received. "
bybye
end
def press_any_key
puts 'Press any key to conti... | true |
2128f02bc2ca83c9a7ebc181b80470dc7e1136b1 | Ruby | johnsonsirv/repl.it | /DFS_Graphs.rb | UTF-8 | 608 | 3.0625 | 3 | [
"MIT"
] | permissive | require 'set'
def graph_DFS_recursive(graph: hash_graph)
$result= []
$visited =[]
def traverse_DFS (dfs_graph: graph, dfs_vertex: vertex)
return nil if dfs_vertex.nil?
$visited << dfs_vertex and $result << dfs_vertex
dfs_graph[dfs_vertex].each do |neighbour|
traverse_DFS... | true |
94e89d50345cea070e111fac0e89328b7351e772 | Ruby | rstrauss127/ny_lotto_scraper | /lib/ny_lotto_scraper/cli.rb | UTF-8 | 1,283 | 3.65625 | 4 | [
"MIT"
] | permissive | class NyLottoScraper::CLI
def call
welcome
list_games
menu
goodbye
end
def welcome
puts "Welcome, what state would you like to see a list of lotto games for?."
puts "Two word states should have a dash, e.g new-york"
input = gets.strip.downcase
scrape(input)
end
def scrape(st... | true |
bfa85a4bb2f314f4f0f6374add3149afb03fd0b1 | Ruby | seguidor777/ejercicios_34 | /zombies/zombie.rb | UTF-8 | 263 | 3.6875 | 4 | [] | no_license | class Zombie
def initialize(x, y)
@x = x
@y = y
end
def walk
@direction = ["x", "y"].sample
if direction == "x"
@x += 1
elsif direction == "y"
@y += 1
end
end
def to_s
"#{@x}, #{@y} braiiiiins"
end
end
| true |
e4625aeb2bb3e40f29b36c4f4af61789f2f7793d | Ruby | nix12/odin-flight-booker | /app/models/flight.rb | UTF-8 | 496 | 2.609375 | 3 | [] | no_license | class Flight < ActiveRecord::Base
belongs_to :from_airport, foreign_key: :start_airport_id, class_name: 'Airport'
belongs_to :to_airport, foreign_key: :end_airport_id, class_name: 'Airport'
has_many :passengers
has_many :bookings
def self.all_airports
Airport.all
end
def self.all_dates
Flight.plu... | true |
c10151b13d990e3e9ab58499a5dbf9bbb8ba6930 | Ruby | jakewilkins/searcher | /result_notifier.rb | UTF-8 | 1,198 | 2.765625 | 3 | [
"CC0-1.0",
"LicenseRef-scancode-public-domain"
] | permissive | require 'mailgun'
require 'erb'
class ResultNotifier
TEMPLATE_PATH = Pathname.new(__FILE__).dirname.join('email.erb')
MAILGUN_DOMAIN = ENV.fetch('MAILGUN_DOMAIN')
def self.call(updates)
new(updates).call
end
attr_reader :updates
def initialize(updates)
@updates = updates
end
def call
upd... | true |
56fc51eb0835fb955a850c43ba42e66c2f4cd599 | Ruby | nebrera/druid-dumbo | /lib/hdfs_scanner.rb | UTF-8 | 5,224 | 2.671875 | 3 | [
"MIT",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | require 'json'
require 'time'
require 'thread'
require 'thread/pool'
require 'set'
require 'tempfile'
module Druid
class HdfsScanner
def initialize(opts = {})
@file_pattern = opts[:file_pattern] || raise('Must pass :file_pattern param')
@files = opts[:cache] || {}
@enable_rescan = opts[:enable... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.