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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
676732f39826403c66f0d0ab84335b8e1432bf27 | Ruby | ippei94da/gitan | /bin/gitan | UTF-8 | 3,955 | 3.171875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | #! /usr/bin/env ruby
# coding: utf-8
#gitan heads
# Show hash value of every git repository.
#
#gitan status
# Show status of every git working trees.
# You should confirm the command 'git rev-parse FETCH_HEAD'
# shows a hash value.
# If not, you should execute 'git pull'
#
#gitan commit
# Commit every working tree th... | true |
132a65c7a183833d95f039b300261f6f109c4846 | Ruby | wachin/Windows-WachiManuales | /Sketchup/Google_Sketchup/Plugins/Ruby_Scripts_de_sketchup.google.com/Windows_Tools/WindowTools/trim_tool.rb | UTF-8 | 1,268 | 2.921875 | 3 | [] | no_license | =begin
# Author tomot
# Name: TrimTool
# Description: Create a simple Exterior or Interior Window, Trim
# Usage: click 3 points, on an EXISTING OPENING, creates a Window Trim
# Date: 2008,09,17
# Type: Tool
# Revised: 2008,09,20 Thanks to Jim Foltz for ... | true |
ae9a91fc7a0eff537a4c9697c85fda9bcf039507 | Ruby | shibayu36/algorithms | /ruby/lib/hackerrank/one-week-again/palindrome-index.rb | UTF-8 | 781 | 3.390625 | 3 | [] | no_license | #!/bin/ruby
require 'json'
require 'stringio'
#
# Complete the 'palindromeIndex' function below.
#
# The function is expected to return an INTEGER.
# The function accepts STRING s as parameter.
#
def palindromeIndex(s)
left = 0
right = s.length - 1
while left < right
if s[left] == s[right]
left += 1... | true |
0c20480d9d912f75096117d3da8d1cf5a20e2571 | Ruby | Overload119/active_record_uuid | /lib/active_record_uuid/extensions/association_methods.rb | UTF-8 | 1,606 | 2.546875 | 3 | [
"MIT"
] | permissive | module ActiveRecordUuid
module AssociationMethods
def has_many(name, options = {}, &extension)
options = uuid_assoc_options(:has_many, name, options)
super
end
def has_one(name, options = {})
options = uuid_assoc_options(:has_one, name, options)
super
end
def belo... | true |
5e23a6e9bdd27db8fe5b382c3a5782981bf84328 | Ruby | kristjan/adventofcode | /2017/4/valid.rb | UTF-8 | 147 | 2.890625 | 3 | [] | no_license | phrases = File.readlines(ARGV[0]).map(&:strip)
count = phrases.count do|p|
words = p.split(' ')
words.size == words.uniq.size
end
puts count
| true |
d24acb843720e554541464cd3f59842ab9c8f464 | Ruby | sunsplat/tree_trie_tro_trum | /lib/letter_node.rb | UTF-8 | 301 | 3.109375 | 3 | [] | no_license | Letter = Struct.new(:letter, :definition, :children, :parent, :depth)
class LetterNode
attr_accessor :letter, :definition, :children, :parent, :depth
def new(word)
@node = Letter.new
@node.letter(word)
@node.definition
@node.children
@node.parent
@node.depth
return @node
end
end | true |
980223db9beb13c8aa5702b6b377c1a2e9e5f3b8 | Ruby | yaozhen1979/RubyCookbook | /src/file/simple_write_file.rb | UTF-8 | 101 | 2.953125 | 3 | [] | no_license | # open and write to a file with ruby
open('myfile.out', 'w') { |f|
f.puts "Hello, world !!!"
} | true |
ea8e8b6152bf956721024dadeb7a1c70bfacf1aa | Ruby | dmktel/ruby_basics | /part9/pass_train.rb | UTF-8 | 265 | 3.015625 | 3 | [] | no_license | class PassTrain < Train
def initialize(number)
super(number, :pass)
end
def add_wagon(wagon)
if wagon.instance_of?(PassWagon)
super(wagon)
else
puts 'To passenger trains it is possible to add only passenger wagons!'
end
end
end
| true |
03e485ae988205761d66c48e12426257e271c1f9 | Ruby | sekharvajjhala/apisonator | /lib/3scale/backend/analytics/kinesis/adapter.rb | UTF-8 | 7,367 | 2.828125 | 3 | [
"Apache-2.0",
"LGPL-2.0-or-later",
"BSD-3-Clause",
"MIT",
"Ruby",
"BSD-2-Clause",
"GPL-2.0-or-later",
"Python-2.0",
"Artistic-2.0"
] | permissive | require '3scale/backend/logging'
module ThreeScale
module Backend
module Analytics
module Kinesis
class Adapter
# Each Kinesis record is rounded to the nearest 5KB to calculate the
# cost. Each of our events is a hash with a few keys: service,
# metric, period, time, v... | true |
3ba0b9848cbfedb4dc1cfb5cfb16f890b98a2736 | Ruby | mscoutermarsh/exercism | /ruby/grade-school/school.rb | UTF-8 | 263 | 3.28125 | 3 | [] | no_license | class School
attr_reader :db
def initialize
@db = Hash.new{ |a,b| a[b] = Array.new }
end
def add(name, grade)
@db[grade] << name
end
def sort
@db.each_value(&:sort!)
Hash[@db.sort]
end
def grade(grade)
@db[grade]
end
end | true |
a6b87acc0b6082ef8b99814ee7372e2cba292a54 | Ruby | sorah/dqx_tools | /lib/dqx_tools/session.rb | UTF-8 | 2,341 | 2.640625 | 3 | [
"MIT"
] | permissive | # coding: utf-8
require 'mechanize'
require_relative './character'
module DQXTools
# 1. GET http://hiroba.dqx.jp/sc/login/ -> redirect
# 2. GET https://secure.square-enix.com/account/app/svc/login?cont=... -> form
# 3. POST https://secure.square-enix.com/account/app _pr_confData_sqexid, passwd -> redirect
# ... | true |
ab5f30970a6261cecf5583921cc28323cad0f471 | Ruby | collabnix/dockerlabs | /vendor/bundle/ruby/2.6.0/gems/yell-2.2.2/examples/002.2-log-level-on-certain-severities-only.rb | UTF-8 | 729 | 3.34375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | # encoding: utf-8
require_relative '../lib/yell'
puts <<-EOS
# The Yell::Level parser allows you to exactly specify on which levels to log,
# ignoring all the others. For instance: If we want to only log at the :debug
# and :warn levels we simply providing an array:
# * %i[] is a built-in for an array of symbols
... | true |
35c7ed53adac5a3b09097c30908335d2d9a9a7d0 | Ruby | timothykim/hcsuzukiviolin.com | /app/models/session.rb | UTF-8 | 2,782 | 2.5625 | 3 | [] | no_license | class Session < ActiveRecord::Base
has_many :weekly_availablities, :dependent => :destroy
has_many :session_days, :dependent => :destroy
has_many :registration_options, :dependent => :destroy
has_many :registrations, :order => "created_at DESC"
has_many :registered_dates, :through => :registrations
has_many... | true |
d771b03476dc91ed0d3cc14e37d9d07711510850 | Ruby | sushmasatish/handy_apn | /lib/handy_apn/apn_send_helper.rb | UTF-8 | 2,664 | 2.890625 | 3 | [] | no_license | class ApnSendHelper
attr_reader :device_token
attr_reader :should_send_message_to_apn_prod
attr_reader :apn_pem_file_path
attr_reader :apn_pass_phrase
attr_reader :message
def initialize(apn_pem_file_path, apn_pass_phrase, device_token, should_send_message_to_apn_prod, message)
@apn_pem_file_path = apn_pem_fi... | true |
ba16f5486928003bbc812eccaccabcfc7f5853ac | Ruby | jeffstienstra/ruby-practice | /show-me-the-money.rb | UTF-8 | 540 | 4.5 | 4 | [] | no_license | # Given a string, write a function that returns true if the “$” character
# is contained within the string or false if it is not.
# Input: “i hate $ but i love money i know i know im crazy”
# Output: true
# Input: “abcdefghijklmnopqrstuvwxyz”
# Output: false
phrase1 = "i hate $ but i love money i know i know im craz... | true |
203e6f39ffd4e9ecae1a00c54d18d93ccdf9f6ad | Ruby | dylanrhodius/lrthw | /ex45.rb | UTF-8 | 6,702 | 3.796875 | 4 | [] | no_license | class Scene
def enter()
puts "This scene is not yet configured. Subclass it and implement enter()."
exit(1)
end
end
class Engine
def initialize(scene_map)
@scene_map = scene_map
end
def play()
current_scene = @scene_map.opening_scene()
last_scene = @scene_map.next_scene('... | true |
3d321a32c3699f53223972c3e32eb614af227caa | Ruby | JenniferGrudi/practice_work | /hello_world/homework2.rb | UTF-8 | 528 | 4.09375 | 4 | [] | no_license | # def create_array_of_numbers (num)
# 100.times do
# puts num
# my_array = []
# my_array << num
# num = num + 1
# end
# end
# create_array_of_numbers (1)
def create_array_of_numbers (num)
100.times do
#puts num
my_array = []
my_array << num
num = num + 1
if (num % 3 == 0 && num % 5 == 0)
puts "Gr... | true |
b714c266c51ff08099629ffcb2f2c5dd20b55a60 | Ruby | ChantalDemissie/VideoStoreAPI | /app/models/movie.rb | UTF-8 | 381 | 2.65625 | 3 | [] | no_license | class Movie < ApplicationRecord
has_many :rentals
validates :title, presence: true
validates :inventory, presence: true, numericality: { greater_than_or_equal_to: 0 }
def available_inventory
inventory = self.inventory
rentals = self.rentals.count{ |rental| rental.return_date.nil? }
avail_inventor... | true |
59120fa1deea5b48f2f8de4c2af3ab7fd259522e | Ruby | amatsukixgithub/atcoder | /ABC/ABC126/126A.rb | UTF-8 | 80 | 3.078125 | 3 | [] | no_license | N,K=gets.chomp.split.map(&:to_i)
S=gets.chomp.chars
S[K-1].downcase!
puts S.join | true |
b88df5b66b01fa813af66c83697d05845922b528 | Ruby | htll/swapfil.es | /server.rb | UTF-8 | 1,968 | 2.84375 | 3 | [] | no_license | #!/usr/bin/ruby
require "openssl"
require "socket"
require "timeout"
require "thread"
CHUNK_SIZE = 4 * 1024
PORT = ARGV.shift.to_i
# ctx = OpenSSL::SSL::SSLContext.new
# ctx.cert = OpenSSL::X509::Certificate.new File.open("cert.pem")
# ctx.key = OpenSSL::PKey::RSA.new File.open("priv.pem")
# server = OpenSSL::SSL::... | true |
4daee2470aea6d12e53cf2a440c5a2b80b2edc80 | Ruby | fishbrain/administrate-field-belongs_to_search | /app/views/administrate/application/index.json.jbuilder | UTF-8 | 795 | 2.71875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | # ## Index
#
# This view is the template for the index page.
#
# ## Local variables:
#
# - `page`:
# An instance of [Administrate::Page::Collection][1].
# Contains helper methods to help display a table,
# and knows which attributes should be displayed in the resource's table.
# - `resources`:
# An instance of ... | true |
a0a58b76188e1b603a2093478f68c1eeb2ef86c0 | Ruby | rossfoley/advent-of-code | /2015/day4.rb | UTF-8 | 554 | 3.453125 | 3 | [] | no_license | require 'digest/md5'
# Part 1: 5 Zeroes
input = 'ckczppom'
answer = 1
found_answer = false
while not found_answer
md5 = Digest::MD5.hexdigest(input + answer.to_s)
if md5[0..4] == '00000'
found_answer = true
else
answer += 1
end
end
puts "5 Zeroes Answer: #{answer}"
# Part 2: 6 Zeroes
input = 'ckc... | true |
93655f46cfffc6665fd94e548d35d8925fe9db00 | Ruby | joshpencheon/tent | /lib/tent.rb | UTF-8 | 1,991 | 3.265625 | 3 | [
"MIT"
] | permissive | require 'monitor'
# Provides a way of deferring method calls to
# an underlying object.
class Tent
include MonitorMixin
# Yields a `Tent` over the given `underlying`.
# By default, commits to the underlying when
# the block closes.
def self.cover(underlying, auto_commit = true, &block)
new(underlying).t... | true |
d07fc4aa42f8e3cfc06d37714b54dba8ee3cb78a | Ruby | isatakebayashi/cargox-coding-challenge | /spec/models/position_spec.rb | UTF-8 | 751 | 2.796875 | 3 | [
"Unlicense"
] | permissive | require 'spec_helper'
require_relative '../../app/models/position'
require_relative '../../app/models/surface'
describe Position do
describe '#move' do
context 'when can move the robot' do
let(:surface) { Surface.new('5 5') }
let(:position) { described_class.new('1', '1', surface) }
it 'updat... | true |
50b5a7140ceed423abf30c8a1b0f30b5dba62520 | Ruby | tpham-netprotections/sa_course | /Shimaya/module_oriented/user_module.rb | UTF-8 | 3,176 | 3.390625 | 3 | [] | no_license | module User
# ファンクションのためのモジュールで、データは持たない
# require('./data.rb')
def signup(members)
a = {}
puts "新規会員登録に必要な情報を入力してください。"
puts "mail_address?"
mail_address = gets.chomp
a['mail_address'] = mail_address
puts "phone_number?"
phone_number = gets.chomp
a['phone_numb... | true |
598883ef08b3ae9a9967ad989f087060984c4a28 | Ruby | tausvels/2_player_math_game | /main.rb | UTF-8 | 293 | 3.015625 | 3 | [] | no_license | require "./Player.rb"
require "./Question.rb"
require "./Game.rb"
#----- ENTER PLAYER NAME ------ #
# p "Enter player1 name"
# name1=gets.chomp
# p "Enter player2 name"
# name2=gets.chomp
# player1 = Player.new(name1)
# player2 = Player.new(name2)
# player1.info
game=Game.new
game.run_game | true |
8e5d8708c6783796c604f82525cb2a505ccf538a | Ruby | PaulDebevec/codewars | /string_ends_with/string_ends_with.rb | UTF-8 | 54 | 2.875 | 3 | [
"MIT"
] | permissive | def solution(str, ending)
str.end_with?(ending)
end
| true |
0ac86c60bd53b01db3005aaa2b8be304ddc65119 | Ruby | taw/paradox-tools | /analysis_eu4/list_countries | UTF-8 | 4,458 | 2.609375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require_relative "./eu4_analysis"
class CountryHistory
attr_reader :tag
attr_accessor :government, :government_rank, :technology_group, :religion, :primary_culture
def initialize(tag, node, date)
@tag = tag
@date = date
add(node)
end
def add(node)
node.each do |key, val... | true |
42d53a0a3e57ccc60a6c35e1b2226171fad02611 | Ruby | Felipeandres11/desafioruby1 | /DesafioArreglosII/desafio4.rb | UTF-8 | 179 | 2.9375 | 3 | [] | no_license |
recibir = ARGV
numbers = recibir.to_a
def chart(numbers, size=2)
numbers.each do |dato|
puts "| #{"*" * dato.to_i * size}"
end
end
return chart(numbers,4)
| true |
df65c01abdc3c75676c28b857934844b5df8bf8e | Ruby | ygor/mt940 | /test/mt940_triodos_test.rb | UTF-8 | 1,126 | 2.515625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'helper'
class TestMt940Triodos < Test::Unit::TestCase
def setup
file_name = File.dirname(__FILE__) + '/fixtures/triodos.txt'
@transactions = MT940::Base.transactions(file_name)
@transaction = @transactions.first
end
should 'have the correct number of transactions' do
assert_equal 2, ... | true |
8b240e1099dfbe6f96f09da1973f3cdb48646191 | Ruby | wilsonsilva/loqate | /spec/loqate/phone/phone_number_validation_spec.rb | UTF-8 | 3,095 | 2.734375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'loqate/phone/phone_number_validation'
RSpec.describe Loqate::Phone::PhoneNumberValidation do
let(:attributes) do
{
phone_number: '+447440019210',
request_processed: true,
is_valid: 'Yes',
network_code: '26',
network_name: 'Telefonica UK',
network_country: 'GB',
... | true |
40348a9e02443be4414f8f98becc10fccc3371ed | Ruby | byoung1018/datastructures | /lib/graphs/edge.rb | UTF-8 | 157 | 2.875 | 3 | [] | no_license | class Edge
attr_accessor :start, :finish, :weight
def initialize(start, finish, weight)
@start, @finish, @weight = start, finish, weight
end
end
| true |
0d55bcc78704ec3bac62776de214f0e51aa9ae48 | Ruby | piptcb/gemnasium-gem | /lib/gemnasium/configuration.rb | UTF-8 | 2,485 | 2.96875 | 3 | [
"MIT"
] | permissive | require 'yaml'
module Gemnasium
class Configuration
attr_accessor :site, :api_key, :use_ssl, :profile_name, :project_name, :api_version, :project_branch, :ignored_paths
DEFAULT_CONFIG = { 'site' => 'gemnasium.com',
'use_ssl' => true,
'api_version' => 'v2',
... | true |
981704d133c617098437e47a9d964a202140e426 | Ruby | SanderKleykens/improvise | /bin/improvise | UTF-8 | 2,963 | 2.96875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'gli'
require 'json'
require 'zlib'
require 'improvise'
include GLI::App
program_desc 'Improvise generates random words by learning from existing text.'
version Improvise::VERSION
flag [:f, :format], :desc => 'The format of the dictionary (marshal or json)', :default_value => :marshal, :... | true |
6b1d392109bb2f9db57b447864c24d25cc704e94 | Ruby | Agkura/rspec_poker | /poker/lib/deck.rb | UTF-8 | 461 | 3.59375 | 4 | [] | no_license | require_relative "card"
class Deck
def initialize
@cards = []
fill_deck
end
def num_cards
@cards.length
end
def draw(count = 1)
raise "Not enough cards" if count > num_cards
drawn = []
count.times {drawn << @cards.pop}
drawn
end
def shuffle
@cards.shuffle!
end
pri... | true |
3236cdf512034daacf349c376672d1ed9fc09564 | Ruby | yamunanollu/MyTest | /median.rb | UTF-8 | 410 | 3.46875 | 3 | [] | no_license | a=Array.new
puts "enter number of elements:"
n=gets.chomp.to_i
puts "enter elements:"
for j in 0..n-1
a[j]=gets.chomp.to_f
end
print "elements in sorted order is: "
for i in 0...n
for j in i+1...n
if a[i]>a[j]
a[i],a[j]=a[j],a[i]
end
end
print "#{a[i]} "
end
puts "\nmedian is :"
if a.length%2!=0
med=a.leng... | true |
38fba7ab7c10693c59d918e36cb03da207ae40e1 | Ruby | Mackdatascience007/MORPION | /lib/box.rb | UTF-8 | 177 | 2.5625 | 3 | [] | no_license |
class Box
attr_accessor :content, :name
# Création de la case qui servira à la création du tableau
def initialize
@content = " "
end
end
| true |
38764d3b3667a6cda3d47905d6076e27de209c6d | Ruby | Patarta/git-thp | /ruby/exo_16.rb | UTF-8 | 147 | 3.1875 | 3 | [] | no_license | puts "quelle est votre age?"
age = gets.chomp.to_i
i = 0
until age == 0 do
puts "il y a #{age} ans, tu avais #{i} ans"
age-=1
i+=1
end
| true |
ebcf48a70def51dffab1222380937626a664c551 | Ruby | Harry-KNIGHT/fire-test-2020 | /anagramme.rb | UTF-8 | 350 | 2.953125 | 3 | [] | no_license |
value = ARGV[0]
file_word_find = ARGV[1]
word_on_array = []
position = 0
File.foreach(file_word_find) { |line| word_on_array[position] = line.chomp; position += 1}
i = 0
while( i < word_on_array.length)
if (word_on_array[i].split('').sort.join('') == value.split('').sort.join(''))
puts word_on_arra... | true |
ad3fb61df11f5385a25160848ac95b1037bb1764 | Ruby | JuanDuran85/ejercicios_ruby_basico | /ejercicios_basicos/ejercicio6.rb | UTF-8 | 427 | 3.375 | 3 | [
"Apache-2.0"
] | permissive | =begin
Se pide crear el programa escape.rb donde el usuario ingrese la gravedad y el radio, y comoresultado obtenga la velocidad de escape del planeta (la velocidad mínima necesaria para poder salir de unplaneta) ). Fórmula Ve=(2gr)^1/2
=end
puts "Calculando la velocidad de escape del planeta"
g = ARGV[0].to_f
r =... | true |
03839e365543903798237734eb792d923792ae37 | Ruby | LightLaboratories/tdg5_project_euler_2009 | /pe_05.rb | UTF-8 | 862 | 3.28125 | 3 | [] | no_license | #while
def isPrime(r)
for i in 2..Math.sqrt(r)
if r%i == 0 then
return false
end
i+=1
end
return true
end
print "Enter the Upper Bound: "
STDOUT.flush
o = gets
start = Time.now
o=o.to_i
@t= Array.new(o,0)
@a= Array.new(o,0)
for rr in 1..o
@a[rr]=0
... | true |
f1795dbc860e50c892bb3455d5f7127df631d41c | Ruby | satek/mitier | /lib/mitier/tokenizer.rb | UTF-8 | 572 | 2.703125 | 3 | [
"MIT"
] | permissive | module Mitier
class Tokenizer
attr_accessor :tokens, :text
def initialize(text)
@text = text.to_s.strip
end
def process
return [] if text.empty?
tokens_ptr = tokenize
process_token_elements tokens_ptr
end
private
def tokenize
Wrapper.mitie_tokenize text
... | true |
1535cdb647568a8b91fd449037514af5068e2b4b | Ruby | nurrutia/clase29 | /ejercicio2connil.rb | UTF-8 | 544 | 3.859375 | 4 | [] | no_license | a = [1,2,3,4,5]
c = [1,12,3,45,21]
##uno
#map
b = a.select{ |x| x % 2 == 0 }
puts "con select #{b}"
puts
#do
a.each do |x|
if x % 2 == 0
puts "con do #{x}"
end
end
puts
##
##dos
d = c.map{|e| e if e < 15}
puts "con map #{d}"
e = c.reject{ |x| x > 15}
puts "con reject #{d}"
puts
##
##tres
nombres = ["Guillermo","... | true |
443b13c0e5b0dc383c16987f091951129023a5e1 | Ruby | PaulineLabaisse/exo_ruby | /exo_10.rb | UTF-8 | 151 | 3.546875 | 4 | [] | no_license | puts"Quelle est ton année de naissance ?"
birthday = gets.chomp.to_i
age_2017 = 2017 - birthday
#user age in 2017
puts"Tu avais #{age_2017} en 2017" | true |
afef49481c5584f6b9fc6bd2a092ea392bafb269 | Ruby | kdbanman/ruby_four | /src/util/size_entry.rb | UTF-8 | 440 | 2.9375 | 3 | [
"Apache-2.0"
] | permissive | require_relative '../util/text_entry.rb'
class SizeEntry < TextEntry
MINSIZE = 4
MAXSIZE = 10
def initialize(view, name)
super(view, name)
end
def valid?
if text.match(/^\d+$/)
if text.to_i >= MINSIZE and text.to_i <= MAXSIZE
return true
end
end
raise_invalid_dialog "Siz... | true |
da63df7073e7215011f8a119d0939cb9b4edd1fe | Ruby | oihiro/nokogiri | /pana_oss.rb | UTF-8 | 8,244 | 2.65625 | 3 | [] | no_license | # -*- coding: utf-8 -*-
#
# pana_oss.rb
#
# scrape the Panasonic OSS site
#
require 'uri'
require 'open-uri'
require 'nokogiri'
require 'optparse'
require 'pg'
#
# カテゴリ、モデル、OSSを全て記録するクラス
#
class ProductOSS
attr_accessor :last_ctg
def initialize
@h = {}
@tv_h = {}
end
def set_ctg name
@last_ctg =... | true |
d586d0d3a18f89c88c011077535096376d9bdd1b | Ruby | ziptrade/kyc-admin | /lib/applications/single_sign_on.rb | UTF-8 | 680 | 2.625 | 3 | [
"MIT"
] | permissive | module Applications
class SingleSignOn
def initialize(auth_application, jwt_config)
@auth_application = auth_application
@jwt_config = jwt_config
end
def authenticate_user_with(auth_token)
user_auth_token, redirect_to_path = jwt_decoder.decode(auth_token)
@auth_application.sign_i... | true |
c093ebcebfe51b21b8a6b81db4094d6322b0a79e | Ruby | giangbimin/goodeats | /app/services/show_order_service.rb | UTF-8 | 659 | 3.03125 | 3 | [
"Apache-2.0"
] | permissive | class ShowOrderService
attr_reader :foods, :total
def initialize(current_orders)
@current_orders = current_orders
prepare_data
end
private
def prepare_data
prepare_foods
prepare_total
end
def prepare_foods
@foods = FoodDecorator.decorate_collection(Food.find(id_quantity_hash.keys))... | true |
1f6746843b1395cb3b9a7c23d77a5d9475d97ce4 | Ruby | gaborfoldes/originations | /lib/LOC/Lines.rb | UTF-8 | 2,728 | 2.65625 | 3 | [] | no_license |
require "date"
module LOC
class Lines
SEPARATOR = "\t"
attr_accessor :lines
def initialize
@lines = {}
@exclusions = {}
end
def put(line)
@lines[line.id] = line
end
# display info
def print(ids=nil)
puts LineOfCredit::HEADER + "\n"
if ids.nil? then
@lines.each do |id, l... | true |
c4c99ee0968ec7aa60bc6f1c2b9ea27872303660 | Ruby | tbeau5595/pokemon-scraper-houston-web-career-021819 | /lib/pokemon.rb | UTF-8 | 913 | 3.359375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require "pry"
require "sqlite3"
db = SQLite3::Database.new('pokemon.db')
class Pokemon
# attr_reader :name, :db, :type
attr_reader :db
attr_accessor :id, :name, :type, :hp
@@all = []
def initialize(id: nil, name: nil, type: nil, db: nil, hp: nil)
@id = id
@name = name
... | true |
31a87feaf468ab917be266ba156a17217b5d548d | Ruby | whoojemaflip/aoc | /2017/12/part_2.rb | UTF-8 | 1,105 | 3.59375 | 4 | [] | no_license | def assert_equal(a, b)
raise unless a == b
end
data = File.read('input.txt').strip
test_data = <<EOF
0 <-> 2
1 <-> 1
2 <-> 0, 3, 4
3 <-> 2, 4
4 <-> 2, 3, 6
5 <-> 6
6 <-> 4, 5
EOF
def parse(str)
regex = %r{^(\d*) <-> (.*)$}
strs = str.split("\n").map do |line|
matches = regex.match line
{
from: ma... | true |
16020292bc1c64d90c9355779d465b94c46ef60c | Ruby | JustinStoddard/CasinoProject | /poker.rb | UTF-8 | 4,189 | 3.75 | 4 | [] | no_license | require_relative 'customer'
require_relative 'deck'
#deck array should be hashes with three keys - number, suit, value
class Poker
attr_accessor :customer, :player_hand, :house_hand, :line_spread, :cash_pot, :hand_values
def initialize (customer)
@customer = customer
@player_hand = []
@house_hand = ... | true |
383fc5e4c69efb928666381f33eca8f7c103fa92 | Ruby | rabble/rillow | /lib/rillow_helper.rb | UTF-8 | 847 | 3.25 | 3 | [] | no_license | module RillowHelper
# The find_attribute helper method is to provide a easy eay to find a attribute within the hash and array
# Examples:
# rillow = Rillow.new ('your-zillow-service identifier')
# result = rillow.get_search_results('2114 Bigelow Ave','Seattle, WA')
# valuationRange = result.find_attribute 'valua... | true |
38949708c65103af3d0616d028d2210543b5dc97 | Ruby | kat-siu/ruby-notes | /nil-false-evaluation.rb | UTF-8 | 1,381 | 4.625 | 5 | [] | no_license | # if-else conditionals
name = 'Xavier'
if name == 'Javier'
puts 'What a nice name!'
elsif name == 'Xavier'
puts 'Another nice name!'
end
# The only difference between or and || is their precedence. || has a higher precedence than or.
if name == 'Javier' or name == 'Xavier' then
puts 'Welcome ' + name +... | true |
3dfe961c574ad8f7a26e7cead9181cff5fc4b3a1 | Ruby | 404pnf/itest-find-similar-strings | /find_duplicate_records.rb | UTF-8 | 1,507 | 3.203125 | 3 | [] | no_license | # ## 使用方法
#
# USAGE: ruby script.rb inputfile
#
# ----
require 'csv'
# require 'test/unit'
require 'digest/md5'
require 'pp'
# ## 命名空间呗
module ItestFindDuplicateRecords
# inputfile is a csv file with the format:
# id, text
# id, text
# ...
#
# We process the records with following steps
# 1. parse ... | true |
ab4e1dceb0a6eefca4c48f1573b72b4e065550f2 | Ruby | G07Watch/AA-Classwork | /W5D3/recursion.rb | UTF-8 | 2,527 | 4.09375 | 4 | [] | no_license | #Warm up
def range(start, endpt)
#returns an array of all numbers from start to end excluding end
#returns an empty array if end < start
rarr = []
return rarr if endpt <= start
rarr << start
rarr += range(start+1,endpt)
end
# p range(1,10)
#Sum an array recursive
def re_sum(arr)
r... | true |
5adbbd33a97fb0bad9f7392042b166dbe24da243 | Ruby | zwaarty/project_euler | /ruby/problem_054.rb | UTF-8 | 2,614 | 3.796875 | 4 | [] | no_license |
class PokerHand
def initialize hand
@cards = my_cards hand
@rank, @highest = decipher
end
attr_reader :cards, :rank, :highest
def win? other
if self.rank > other.rank
true
elsif self.rank == other.rank
self.highest > other.highest
else
false
end
end
private
de... | true |
084cae8d1f54d979f89c67ad9f0d791327cde361 | Ruby | paulipayne/oo-email-parser-v-000 | /lib/email_parser.rb | UTF-8 | 352 | 3.09375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class EmailParser
attr_accessor :emails
def initialize(emails)
@emails = emails
end
def parse
unique_emails_list = []
emails_list = self.emails.split(/( |\, )/)
emails_list.each_with_index do |item, index|
if index.even? && !(unique_emails_list.include?(item))
unique_emails_list << item
end
en... | true |
9d112f606144ff0bf5cf25692779eb34ab03aca5 | Ruby | J-Y/RubyQuiz | /ruby_quiz/quiz112_sols/solutions/Sander Land/str_eq.rb | UTF-8 | 320 | 3.203125 | 3 | [
"MIT"
] | permissive | require 'matrix'
class String
def to_freq
('a'..'z').map{|c| Rational(count(c)) } # use Rational for stability in calculating rank
end
end
def has_string_eqn(words)
table = words.uniq.map{|w| w.downcase.gsub(/[^a-z]/,'').to_freq }.transpose
nullity = words.length - Matrix[*table].rank
return nullity > 0
end
| true |
199f575ff00e6f6a2d7a81118c601cf69588516c | Ruby | MikeSap/cli-applications-guessing-game-chi01-seng-ft-091420 | /guessing_game_cli.rb | UTF-8 | 454 | 4.125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Code your solution here!
def prompt
puts"Guess a number from 1-6!"
end
def num_gen
rand(6) + 1
end
def capture_input
gets.chomp
end
def goodbye
puts "Goodbye!"
end
def run_guessing_game
answer = num_gen
puts"Guess a number from 1-6!"
user_guess = capture_input
if user_guess.to_i == answer
puts "Yo... | true |
9db5ee8e61c2f57ed8f0e2c5c4d265b0558ee43c | Ruby | chrisstafford/learn-ruby | /ex15.rb | UTF-8 | 977 | 4.3125 | 4 | [] | no_license | # Sets the variable filename to the first argument
filename = ARGV.first
# Sets the variable prompt to >
prompt = "> "
# Sets the variable to the file contained in the variable filename
txt = File.open(filename)
# Prints out the text "Here's your file" then the contents of the variable filename as a string
puts "He... | true |
a689a8e3600311efe05ccf50ffbeead2052a845a | Ruby | maran/rlp-ruby | /lib/encode.rb | UTF-8 | 498 | 2.640625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | module RLP
module Encode;
def to_rlp(is_array = false)
return [0x80] if self == ""
length = self.bytes.to_a.length
offset = [0x80, 0xb7]
offset = [0xc0, 0xf7] if is_array
if length == 1 && !is_array && self.bytes.first <= 0x7f
return [self.bytes.first]
elsif length <... | true |
bd0070cdbad99402b67116174e8a5cc2b616b07b | Ruby | RaduMatees/TheOdinProject | /Ruby-basics/learn-ruby2.rb | UTF-8 | 221 | 2.796875 | 3 | [] | no_license | # def grandfatherClock(&block)
# todayHours = Time.now.hour
# todayHours.times do
# block.call
# end
# end
#
# grandfatherClock do
# puts 'DONG!'
# end
def log(blockDescription, &block)
block.call
end
log
| true |
daa21f0befcf491cc74118c2db1cab953e54a1d6 | Ruby | MelnikovaK/rubyLab | /spec/unit/deposits_spec.rb | UTF-8 | 1,268 | 2.890625 | 3 | [] | no_license | # frozen_string_literal: true
require 'deposits'
RSpec.describe Deposits do
before do
@deposits = Deposits.new
@deposit = Deposit.new('Travel', 4, true)
@deposit1 = Deposit.new('Super', 10, false)
end
describe '#delete_deposit' do
it 'should delete deposit by index' do
ped_list = Deposits.new
ped_lis... | true |
970eeb8bf98dfe4aa043dc3d73308d9705505f40 | Ruby | zlschatz/phase-0 | /week-5/die-class/my_solution.rb | UTF-8 | 2,320 | 4.53125 | 5 | [
"MIT"
] | permissive | # Die Class 1: Numeric
# I worked on this challenge [by myself, with: ]
# I spent [] hours on this challenge.
# 0. Pseudocode
# Input: number of sides
# Output: number of sides / random value within range
# Steps:
# Define class
# initialize method passing the argument of sides
# define variable sides
# def... | true |
e6513409cf953a4ddca9907bdf364df554b09ea7 | Ruby | abowler2/small_problems | /medium1/rotation3.rb | UTF-8 | 661 | 4.0625 | 4 | [] | no_license |
def rotate_array(array)
array.slice(1, array.size) << array[0]
end
def rotate_rightmost_digits(number, n)
num_array = number.to_s.split('')
right_side = num_array.slice(-n, n)
left_side = num_array.slice(0, num_array.size - n)
(left_side + rotate_array(right_side)).join.to_i
end
def max_rotation(number)
... | true |
98cdb46065bec123faa5dece343d6dbf42b9a3fa | Ruby | deadelf79/Redenik | /code/module.Redenik.GameData.class.Person.rb | UTF-8 | 4,319 | 2.65625 | 3 | [] | no_license | # encoding utf-8
class Redenik::Person < Redenik::Basic
FEATURES___TOO_LOW = (1..3)
FEATURES___LOW = (4..8)
FEATURES___NORMAL = (9..11)
FEATURES___HIGH = (12..16)
FEATURES___SUPERB = (17..20)
LEVEL___MAXIMUM = 100
attr_reader :appearance, :stats, :equips
attr_reader :exp, :level, :skills, :sex, :gender
... | true |
18aafd89d2a8ea108300eac4aba9acac50b1e915 | Ruby | braddeibert/learn_ruby | /05_book_titles/book.rb | UTF-8 | 1,408 | 3.609375 | 4 | [] | no_license | class Book
# write your code here
def initialize
end
def title=(title)
@title = title
end
def title
words = @title.split(" ")
formatted_title = ""
conjunctions = ["for", "and", "nor", "but", "or", "yet", "so"]
prepositions = ["about", "a... | true |
0cacd2d137f6b0dbbd53319befedaa78b875db8e | Ruby | DamonClark/introtoruby | /variables/example1a.rb | UTF-8 | 112 | 3.546875 | 4 | [] | no_license | puts "Can you please type your name into the console?"
name = gets.chomp
puts "Hello " + name + ", how are you?" | true |
69d45686aa29eb52138c49549861e66a6ccd46b1 | Ruby | emilyjspencer/ruby-practice1 | /dice_game.rb | UTF-8 | 944 | 3.921875 | 4 | [] | no_license | puts 'Let\'s play a game! I have two die and I\'m going to roll them. You need
to guess the total!'
counters = 20
while counters > 0
puts 'Give me a total. You have ' + counters.to_s + ' counters left!'
guess = gets.chomp
while true
if (counters.to_i - guess.to_i) < 0
puts 'You don\'t have that many counters! T... | true |
44dfe6697703d62fa4f3c6f8d7a9bdf8509b778c | Ruby | Moniet/programming_languages-london-web-051319 | /programming_languages.rb | UTF-8 | 401 | 2.8125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive |
require "pry"
def reformat_languages(languages)
new_hash = {}
languages.each do |type, data|
data.each do |lang, val| # binding.pry
if lang == :javascript
new_hash[lang] = val
new_hash[lang][:style] = [:oo, :functional]
else
new_hash[lang] = val
new_hash[lang][:style]... | true |
d4040d4251d5af13b0494fc21faee0191d039c60 | Ruby | descala/b2b-utils | /peppol-id2ap/peppol-id2ap | UTF-8 | 2,252 | 3.078125 | 3 | [] | no_license | #!/usr/bin/env ruby
# == Synopsis
# Given a Participant ID obtains its Access Point URL(s)
#
# == Examples
# peppol-id2url 9906:05359681003
#
# == Usage
# peppol-id2url [options] participant_id [document_id] [process_id]
#
# For help use: peppol-id2url -h
#
# == Options
# -h, --help Displays hel... | true |
e889144ab3404724c47c69dfc69f0eb8b494dcee | Ruby | DouglasAllen/code-Programming_Ruby_3rd_ed | /Part_IV--Ruby_Library_Reference/ch27_Built-in_Classes_and_Modules/Alphabetical_Listing/Module/cdesc-Module.rb | UTF-8 | 1,795 | 3.46875 | 3 | [] | no_license | =begin
Module < Object
(from ~/.rdoc)
------------------------------------------------------------------------------
A Module is a collection of methods and constants. The methods in a
module may be instance methods or module methods. Instance methods appear as
methods in a class when the module is included, module m... | true |
452bfd8862765920f9b2d05886a821a58452a321 | Ruby | NorbertLam/ruby-boating-school-dumbo-web-career-010719 | /app/models/instructor.rb | UTF-8 | 998 | 3.3125 | 3 | [] | no_license | class Instructor
attr_reader :name
@@all = []
def initialize(name)
@name = name
@@all << name
end
def pass_student(student_name, test_name)
boat_test = BoatingTest.all.find{ |test|
test.student.first_name == student_name and test.test_name == test_name
}
... | true |
228bdbd044a9750617fc607a10591a93dad179fe | Ruby | RichardLW6/Tealeaf_Week1 | /paper_rock_scissors/paper_rock_scissors.rb | UTF-8 | 2,095 | 4.15625 | 4 | [] | no_license | #PAPER/ROCK/SCISSORS APPLICATION
puts "Play Paper Rock Scissors!"
choices = {'p' => 'Paper', 'r' => 'Rock', 's' => 'Scissors'}
computer_score = 0
user_score = 0
while true
begin
puts "Choose one: (P/R/S)"
user_answer = gets.chomp.downcase
end until choices.keys.include?(user_answer)
computer_answer = ch... | true |
4320f13d1dcf60fece13b819194dafab54d51e57 | Ruby | Icicleta/practical_object_oriented_design_in_ruby | /05_Duck_Types/01.rb | UTF-8 | 1,101 | 4.5625 | 5 | [] | no_license | # Duck type objects are chameleons that are defined more by their BEHAVIOUR than by their CLASS. This is how the technique gets it's name:
# If it walks like a duck, and quacks like a duck, then its class is immaterial - it's a duck.
# Duck typing is possible in Ruby, but not in, say, Java, because Ruby is dynamicall... | true |
397fbf76762f91e8ca3226281a4dd9f871f9870f | Ruby | holderbaum-io/think-about-website | /test/event_test.rb | UTF-8 | 2,720 | 2.5625 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/spec'
require 'psych'
require 'tmpdir'
require 'fileutils'
require_relative '../lib/event'
REFERENCE_PERFORMANCE = {
title: 'my title',
track: 'keynote',
lang: 'en',
abstract: "my\nabstract",
speakers: [
{
name: 'Speaker 1',
slug: 'speaker_1',
... | true |
465dc8aaea904ba5844678610be0641400be98b6 | Ruby | natey37/Black-Thursday | /black_thursday/lib/sales_engine.rb | UTF-8 | 1,398 | 2.78125 | 3 | [] | no_license | require_relative './merchant_repository.rb'
require_relative './item_repository.rb'
require_relative './invoice_repository.rb'
require_relative './invoice_item_repository.rb'
require_relative './transaction_repository.rb'
require_relative "./customer_repository.rb"
require 'pry'
class SalesEngine
attr_reade... | true |
87cd03e4e0a5df8239eb851cc4745a9cfe5e73dd | Ruby | avdi/tick | /examples/fake-server.rb | UTF-8 | 584 | 2.890625 | 3 | [] | no_license | $:.unshift(File.expand_path('../lib', File.dirname(__FILE__)))
require 'rack/fake'
fake = Rack::Fake.new("hello", :port => 8700) do
get '/hello' do
"Hello, world"
end
get '/goodbye' do
"Goodbye, world"
end
end
puts "Starting fake"
fake.start
puts "Fake started"
host = fake.host
port = fake.port
pu... | true |
ad292a24fab24621b4f20e721e6853ed1c3de48d | Ruby | inem/hamdown | /lib/hamdown/engine.rb | UTF-8 | 502 | 2.8125 | 3 | [
"MIT"
] | permissive | require 'hamdown_core'
require_relative 'haml_handler'
module Hamdown
# Main module
# Mahine to compile hamdown text to html
module Engine
# It takes string with hamdown text and compile it to html
def self.perform(hd_text = '')
return '' if hd_text.nil? || hd_text.size == 0
# step 1: hamdow... | true |
14b07da80f615f0427ba41a59f1d23aa7674cb0e | Ruby | xincere-inc/jira_command | /lib/jira_command/prompt/base.rb | UTF-8 | 3,091 | 2.609375 | 3 | [
"MIT"
] | permissive | require_relative '../config'
require_relative '../jira/sprint'
require_relative '../jira/user'
require_relative '../jira/issue_type'
require 'tty-prompt'
module JiraCommand
module Prompt
class Base
attr_writer :prompt, :config
def initialize
@prompt = TTY::Prompt.new
@config = JiraCo... | true |
469f3d68bb61b8eedeab48bceb408db05d287f39 | Ruby | kaiamz/Ruby | /ruby-exercise-1.rb | UTF-8 | 918 | 4.0625 | 4 | [] | no_license | poem = File.read('the-man-from-snowy-river.txt')
lines = poem.lines
#/\W+/ is a "regular expression" - a text-searching pattern.
# /\s+/ The slashes start and end the pattern. \W means "any non-alphabetic character"
# and + means "repeated one or more times"
words = poem.split(/\W+/)
stanzas = poem.split(/\n\n/)
#... | true |
c0c4cb33232280b1091d9ee4a2b5f431ffe3a400 | Ruby | codereport/LeetCode | /0019_Problem_1.rb | UTF-8 | 242 | 2.953125 | 3 | [] | no_license | # code_report Solution
# Problem Link (Contest): https://leetcode.com/contest/leetcode-weekly-contest-19/problems/base-7/
# Problem Link (Practice): https://leetcode.com/problems/base-7/
def convert_to_base7(num)
return num.to_s(7)
end
| true |
0d1dff7085593ecb3605afa781910a381002f5b0 | Ruby | FillanL/intro-to-tdd-rspec-and-learn-nyc-web-career-021819 | /current_age_for_birth_year.rb | UTF-8 | 114 | 2.53125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def
current_age_for_birth_year(birth_year)
current_year = 2003
age_of_person = current_year - birth_year
end | true |
4e8e920a1743505ba7eff9ca39f41f048a4890d9 | Ruby | Kmfisher13/Ruby-Basics | /hashes/low_medium_high.rb | UTF-8 | 340 | 4.375 | 4 | [] | no_license | # Use Hash#select to iterate over numbers and return a hash containing only
# key-value pairs where the value is less than 25. Assign the returned hash
# to a variabe named low_numbers and print its value using #p.
numbers = {
high: 100,
medium: 50,
low: 10
}
low_numbers = numbers.select { |key, value| value < ... | true |
962e03698e0c3412704276dc40d83ea29694cebc | Ruby | arun-instructor/BEWD11-Arun | /week_10/day_1/book.rb | UTF-8 | 438 | 3.609375 | 4 | [] | no_license | class Book
attr_accessor :library
def initialize
@library = []
@book_count = 0
end
def all
return @library
end
def add(book)
@library.push({
id: @book_count += 1,
book: book
})
end
def show(id)
@library.each do |book|
if book[:id] == id
return book
end
end
end
def remove(id)... | true |
ec8e53540055aabd02b89aa6d004e94fb2c7f8ee | Ruby | rymai/on_the_snow | /lib/on_the_snow/client/regions.rb | UTF-8 | 636 | 2.65625 | 3 | [
"MIT"
] | permissive | module OnTheSnow
class Client
# Wrapper for the OnTheSnow REST API regions method.
#
class Regions
module Helper
# Gets a list of Region elements which contain all the State/Provinces
# listed by OTS. The method can be used to retrieve the list of state
# names and state ab... | true |
cb523c269685b45ec1603608aa6d92d6a2fad181 | Ruby | alexandradlg/THP_scrapping | /THP_scrapping/exo3.rb | UTF-8 | 2,161 | 3.296875 | 3 | [] | no_license | require 'rubygems'
require 'nokogiri'
require 'open-uri'
require 'HTTParty'
def get_info_about_incubators(lien)
page = Nokogiri::HTML(open(lien))
number_of_pages = page.css('div.nav-links > a.page-numbers:nth-last-child(-n+2)')
# Pour connaitre la dernière page = récupération des deux dernier élément de l... | true |
26b05967e426acc71c0b21253c84682e0654195e | Ruby | senkadam/MI-RUB-Ukol2 | /test/test_reader.rb | UTF-8 | 690 | 2.640625 | 3 | [] | no_license | # To change this template, choose Tools | Templates
# and open the template in the editor.
$:.unshift File.join(File.dirname(__FILE__),'..','lib')
require 'test/unit'
require 'reader'
class TestMain < Test::Unit::TestCase
def test_is_number1
r=Reader.new
assert_equal(r.is_number?(5),true)
end
def ... | true |
3694f8b5abc054004de3b9ca62e940268ac91989 | Ruby | BenCmjn/THP_D_06 | /trader_du_lundi.rb | UTF-8 | 3,601 | 3.515625 | 4 | [] | no_license | # Lehman Brothers sont très fiers de ton travail.
# Ils veulent maintenant te faire travailler sur plusieurs entreprises à la fois.
# Ils vont te filer les stocks sous un format hash chaque jour,
# et tu devras trouver les meilleurs moments pour acheter et vendre des actions
# de chaque entreprise. Voici un exemple ave... | true |
9f54de1f595931468480c1d8c3fa3d7c15e2c14e | Ruby | thomasbeckett/sparta_stuff | /week-8/api_testing/rails_api_som/spec/philosopher_index_spec.rb | UTF-8 | 1,243 | 2.65625 | 3 | [] | no_license | require_relative '../lib/philosopher.rb'
describe Philosopher do
context "getting all the philosophers" do
before(:all) do
@philosopher_index = Philosopher.new.philosopher_index_service
@philosopher_index.get_philosophers
end
it "should get an array" do
expect(@philosopher_index.get_ph... | true |
f2121c3297c1f645fc2651e76fbcce1074d60d8a | Ruby | bainewedlock/aoc2018ruby | /day9/solution1.rb | UTF-8 | 1,292 | 3.359375 | 3 | [] | no_license | class Solver
def initialize(players, marbles)
@circle = [0]
@current_marble = 0
@player = 0
@players = Array.new(players, 0)
play marbles
puts "solution for #{players}/#{marbles}: #{@players.max}"
end
def play(marbles)
(1..marbles).each do |value|
if (value % 23).zero?
... | true |
f6f04527a53299cc0e866504bc5491f4b7f9f7af | Ruby | zvkemp/varese | /lib/varese/fips/state.rb | UTF-8 | 4,309 | 2.625 | 3 | [
"MIT"
] | permissive | module Varese
module FIPS
class State
ABBREVIATIONS = {
"ak" => "alaska",
"al" => "alabama",
"ar" => "arkansas",
"as" => "american samoa",
"az" => "arizona",
"ca" => "california",
"co" => "colorado",
"ct" => "connecticut",
"dc" => "dist... | true |
3e255b1eade97450aa6056be006c93f12d869252 | Ruby | kenhys/drnbench | /lib/drnbench/shuttle/gradual-runner.rb | UTF-8 | 2,224 | 2.75 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # -*- coding: utf-8 -*-
require "drnbench/shuttle/runner"
require "csv"
module Drnbench
module Shuttle
class GradualRunner
attr_reader :start_n_clients, :end_n_clients, :step
attr_reader :report_progressively, :result
DEFAULT_START_N_CLIENTS = 1
DEFAULT_END_N_CLIENTS = 1
DEFAULT_S... | true |
e83755dd8c9b6cc720a9bcb9d6febd25beb25802 | Ruby | mrlhumphreys/just_chess | /lib/just_chess/pieces/knight.rb | UTF-8 | 564 | 3.328125 | 3 | [
"MIT"
] | permissive | require 'just_chess/pieces/piece'
module JustChess
# = Knight
#
# The piece that jumps over pieces 1v2h or 2v1h
class Knight < Piece
# All the squares that the piece can move to and/or capture.
#
# @param [Square] square
# the origin square.
#
# @param [GameState] game_state
# ... | true |
0f33556257a58512cc3de3a1e448014ed894812e | Ruby | usman-tahir/rubyeuler | /geometric_mean.rb | UTF-8 | 174 | 3.46875 | 3 | [] | no_license | # http://rosettacode.org/wiki/Averages/Pythagorean_means
def geometric_mean(low,high)
(low..high).to_a.inject(:*) ** (1.0 / (low..high).count)
end
p geometric_mean(1,10)
| true |
926fc5bc0d65e1300df8dc912584d4a76475f050 | Ruby | ruby/rbs | /test/stdlib/TSort_test.rb | UTF-8 | 5,174 | 2.734375 | 3 | [
"BSD-2-Clause",
"Ruby"
] | permissive | require_relative "test_helper"
require "tsort"
class TSortSingletonTest < Test::Unit::TestCase
include TypeAssertions
library 'tsort'
testing "singleton(::TSort)"
class EachNode
def initialize(*nodes)
@nodes = nodes
end
def call(&block)
@nodes.each(&block)
end
end
class Eac... | true |
cdbf228880ed694b6950820bcf1311dbfe897447 | Ruby | YOMOGItaro/rubyfuzzylib | /FuzzySet.rb | UTF-8 | 1,167 | 3.203125 | 3 | [] | no_license | require 'MembershipFunction.rb'
class FuzzySet
@name
@membership_functions
def initialize(name, membership_functions)
@name = name
@membership_functions = membership_functions
end
def each
@membership_functions.each{ |k,mf|
yield mf
}
end
def label
@name
end
def to_... | true |
14e75504d749ba02e83255b303b7340a9a0d898c | Ruby | kenta-s/algorithms | /ruby/quicksort.rb | UTF-8 | 869 | 3.578125 | 4 | [] | no_license | require 'minitest/autorun'
class TestQuicksort < Minitest::Test
def test_quicksort_with_integers_returns_sorted_array
array = (1..10).to_a.shuffle
expected_array = [1,2,3,4,5,6,7,8,9,10]
assert_equal expected_array, quicksort(array)
array = (32..150).to_a.shuffle
expected_array = (32..150).to_a
... | true |
2e0603faaf0bfd51b1e772bf4f8c5f176e8eae8a | Ruby | c7devteam/baio_tracking_client | /lib/baio_tracking_client/client.rb | UTF-8 | 2,481 | 2.578125 | 3 | [
"MIT"
] | permissive | require 'faraday'
require 'typhoeus'
require 'typhoeus/adapters/faraday'
require 'faraday_middleware'
require 'ostruct'
module BaioTrackingClient
class Client
attr_reader(:base_url, :port, :username, :password)
def initialize(config = {})
@base_url = "http://#{ config.fetch(:base_url, get_c... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.