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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
cc0f9e1231331b494a75dc890406171c20ccb900 | Ruby | Mariastakh/Mars_Rover_Kata | /rover.rb | UTF-8 | 3,977 | 4.0625 | 4 | [] | no_license | =begin
Implement obstacle detection before each move to a new square.
If a given sequence of commands encounters an obstacle,
the rover moves up to the last possible point,
aborts the sequence and reports the obstacle.
=end
class Rover
attr_reader :x
attr_reader :y
attr_reader :orient
def initiali... | true |
2020bafff1bbf0fe17ecdf59ed9e64c1d29cba83 | Ruby | rbiojout/mygoodcourse | /app/models/concerns/capitalize_name.rb | UTF-8 | 197 | 2.703125 | 3 | [] | no_license | module CapitalizeName
extend ActiveSupport::Concern
private
# we want a name that start with capital
def capitalize_name
self.name = name.sub(/\S/, &:upcase) unless name.nil?
end
end
| true |
8887d937ec08c8e67a0e7d11606574eb293a8340 | Ruby | DevonJamesWright/collections_practice-online-web-ft-120919 | /collections_practice.rb | UTF-8 | 488 | 3.40625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | array = [25,7,1]
def sort_array_asc(array)
array.sort
end
array2 = [25,7,14]
def sort_array_desc(array2)
array2.sort do |a,b|
-(a <=> b)
end
end
array3 = ["dogs","cats","Horses"]
def sort_array_char_count(array3)
array3.sort do |x,y|
x.length <=> y.length
end
end
array4 = ["blake", "ashley", "scott"]
de... | true |
712acf168ce02227da4b937332eb956d20fd7885 | Ruby | jamis/ekawada-web | /app/models/notation/prose.rb | UTF-8 | 610 | 2.640625 | 3 | [
"BSD-3-Clause"
] | permissive | class Notation::Prose < Notation
def paragraphs?
true
end
def parse(definition)
position = 0
instruction = []
complete = Proc.new do
yield position, interpret_step_data(extract_step_data(instruction.join("\n")))
instruction.clear
position += 1
end
definition.each_line ... | true |
107a04d9d093d25dbc62c92e93c76d7ab7adccd5 | Ruby | dayne/tools | /go/notify.rb | UTF-8 | 494 | 2.515625 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'RNotify'
require 'dgs'
Notify.init("DGS")
u = DgsUser.new('bish0p')
loop do
u.check
u.parse
new = u.current_games - u.last_games
messages = []
if new.size > 0
new.each do |g|
puts "#{g[:opponent]} has moved"
msg = Notify::Notification.new("DGS", "#{g[:opponent]}... | true |
e33c0217643f1a6aec380d0a7152793cb43f75b9 | Ruby | k-sensitive/rock-paper-scissors | /lib/rock_paper_scissors.rb | UTF-8 | 214 | 2.625 | 3 | [] | no_license | class String
define_method(:beats?) do |weapon|
wins = { "rock" => "scissors" , "paper" => "rock" , "scissors" => "paper" }
if wins.fetch(self) == weapon
true
else
false
end
end
end
| true |
d560cfe3c361898df84513e8346bd58a183b2e99 | Ruby | lodestone/board_game_geek | /lib/board_game_geek.rb | UTF-8 | 4,975 | 2.8125 | 3 | [] | no_license | require "bundler/setup"
require "nokogiri"
require "open-uri"
require "ostruct"
require "json"
module BoardGameGeek
class Game < OpenStruct
def to_json(options={})
{ name: name,
bgg_id: bgg_id,
ranking: ranking,
rating: rating,
release_date: release... | true |
a218a1c7e592e1e429e761f012539e8a65479fc7 | Ruby | kont-noor/heat_controller | /pcb/sensor/test/create_pcb_html.rb | UTF-8 | 875 | 2.53125 | 3 | [] | no_license | require 'nokogiri'
@doc = Nokogiri::HTML::DocumentFragment.parse <<-EOHTML
<style>
svg {
background: #000;
margin: 20px;
}
svg:nth-child(2), svg:nth-child(3) {
transform: rotate(180deg);
-webkit-transform: rotate(180deg);
-moz-transform: rotate(180deg);
-o-transform: rotate(180deg);
... | true |
d926b9aa7df4eeee75b628f1cb947f8b25853096 | Ruby | mitchbank/Ruby-fundamentals-two | /exercise7.rb | UTF-8 | 481 | 3.765625 | 4 | [] | no_license | def cohort_size(num_students)
num_students.each do |cohort, size|
puts "#{cohort} #{size} students"
end
end
students = {
cohort1: 34,
cohort2: 42,
cohort3: 22
}
students[:cohort4] = 43
# cohort_size(students)
# students.each do |key, value|
# puts key
# end
# students.each do |cohort, size|
# new_size... | true |
300ed8537f2d7f4b42c2d325c6e0df7461a31de3 | Ruby | collabnix/dockerlabs | /vendor/bundle/ruby/2.6.0/gems/colorator-1.1.0/lib/colorator.rb | UTF-8 | 2,823 | 2.828125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | $:.unshift File.dirname(__FILE__)
module Colorator
module_function
VERSION = "1.1.0"
# --------------------------------------------------------------------------
ANSI_MATCHR = /\x1b.*?[jkmsuABGKH]/
ANSI_COLORS = {
:black => 30,
:red => 31,
:green => 32,
:yellow => 33,
:blue ... | true |
ccebfcb34c6b8049bbdab9e0feb2360220c51c05 | Ruby | MattGough/rps-challenge | /app.rb | UTF-8 | 777 | 2.609375 | 3 | [] | no_license | require 'sinatra/base'
require './lib/player'
require './lib/computer'
require './lib/result'
class RockPaperScissors < Sinatra::Base
enable :sessions
get '/' do
erb :home
end
post '/name' do
$player_name = Player.new(params[:player_name])
redirect '/choose_your_weapon'
end
get '/choose_you... | true |
7bfec6ec64b7a406d143baf91be6963bdbab3137 | Ruby | gusailov/rack_interface | /app.rb | UTF-8 | 796 | 2.828125 | 3 | [] | no_license | class App
def call(env)
req = Rack::Request.new(env)
if req.path == '/time'
time_response(req)
else
response(404, 'The requested resource is not available')
end
end
private
def time_response(req)
format_string = req.params['format']
if format_string
check_format_res... | true |
f3b149d9946691a91fa86848f53b92e6e02ef282 | Ruby | pjf/masterwork-dwarf-fortress | /Dwarf Fortress/hack/scripts/probability-syndrome.rb | UTF-8 | 6,305 | 2.65625 | 3 | [
"Zlib",
"MIT",
"BSD-2-Clause",
"LicenseRef-scancode-public-domain"
] | permissive | # probability-syndrome.rb - Run commands with a certain probability
#
# = DESCRIPTION
#
# Including the PROBABILITY_TABLE stone in our reaction causes the
# probability-syndrome script to scan it, build a probability table, and
# execute one command according to the weightings listed
#
# For example the following woul... | true |
f44cce7d3385de80eb9771612ef72a62ad9d56a2 | Ruby | J-Y/RubyQuiz | /ruby_quiz/quiz122_sols/solutions/Chris Shea/cc_check.rb | UTF-8 | 1,031 | 3.171875 | 3 | [
"MIT"
] | permissive | #!/usr/local/bin/ruby
class CreditCard
TYPES = {
:visa => {:length => [13, 16], :start => [4]},
:discover => {:length => [16], :start => [6011]},
:mastercard => {:length => [16], :start => 51..55},
:amex => {:length => [15], :start => [34, 37]}
}
def initialize(number)
@number = number.gsub... | true |
8b7deea789e3d22a9baff995519fdc601462e4c2 | Ruby | basktballer/jungle-rails | /app/models/order.rb | UTF-8 | 640 | 2.515625 | 3 | [] | no_license | class Order < ActiveRecord::Base
belongs_to :user
has_many :line_items
has_many :products, through: :line_items # has many through association
monetize :total_cents, numericality: true
validates :stripe_charge_id, presence: true
after_create :update_inventory
def update_inventory
self.line_items... | true |
2b80c6e88d7f7bcec9e8891bbdf14db0a3bf73b1 | Ruby | m-rcd/student-directory | /directory.rb | UTF-8 | 3,203 | 4.0625 | 4 | [] | no_license | require 'csv'
@students = []
@input_students_count = 0
def interactive_menu
loop do
print_menu
process(STDIN.gets.chomp)
end
end
def input_students
puts 'Please enter the names of the students'
puts 'To finish, just hit return twice'
name = STDIN.gets.chomp
until name.empty?
students_list(stud... | true |
b48ae8160191411cc46d03ac26369c23880e42ba | Ruby | JoseGomez247/codeacamp | /prework/Martes/edades.rb | UTF-8 | 296 | 3.203125 | 3 | [] | no_license | p edad= 23
case edad
when 0..6
puts "infancia"
when 6..12
puts "Niñez"
when 12..20
puts "Adolescencia"
when 20..25
puts "Juventud"
when 25..60
puts "Adultez"
else
puts "Ancianidad"
end
p x = [1,2,3,4,5]
x.each do |x|
x += 5
puts "#{x}"
end
| true |
ac4b53a1fc0e402db8912b6555754f8dcd020f48 | Ruby | howardbdev/cartoon-collections-v-000 | /cartoon_collections.rb | UTF-8 | 486 | 3.453125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def roll_call_dwarves(names)
names.each_with_index do |name, i|
# Your code here
puts "#{i + 1}. #{name}"
end
end
def summon_captain_planet(elements)
# Your code here
elements.map {|element| "#{element.capitalize}!"}
end
def long_planeteer_calls(calls)
calls.any? {|call| call.length > 4}
end
def f... | true |
41a3cfd32f034a611f57005379f13ef3f5b191bd | Ruby | davidrenz60/launch_school_OOP | /Lesson_4/easy_1/5.rb | UTF-8 | 422 | 3.84375 | 4 | [] | no_license | # which class has an instance variable?
class Fruit
def initialize(name)
name = name
end
end
class Pizza
def initialize(name)
@name = name
end
end
# Pizza class has a name instance variable, it is prefixed with '@'
# can check by using instance_variables method
apple = Fruit.new('apple')
cheese = ... | true |
1faf593784450a38bf6c0240e272096768c8b3ab | Ruby | forward100-cmd/RUBY | /chisla.rb | UTF-8 | 561 | 3.203125 | 3 | [] | no_license | puts "Введите число 1:"
number1 = gets.to_i
puts "Введите число 2:"
number2 = gets.to_i
puts "Введите число 3:"
number3 = gets.to_i
arithmetic_mean = (number1+number2+number3) /3
puts "Среднее арифметическое:" + arithmetic_mean.to_s
#Я разобрался!!! Это правильно!!! Наконец-то!!!Ура!!! Нужно было в нужном месте... | true |
27fd3f5b22f6d04bf3a1ad68eb76a270b4f8df69 | Ruby | jin501/anagram-detector-wdf-000 | /lib/anagram.rb | UTF-8 | 646 | 3.28125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Your code goes here!
class Anagram
attr_accessor :word
def initialize(word)
@word = word
end
def match(array)
array.select {|w| w.split("").sort == @word.split("").sort}
end
end
# array.select do |w|
# arr = []
# i = 0
# x = array[i]
# if x.split("").sort == @word.s... | true |
42b0be6ac8fe4fc376c08cbdd568aa9a9e6d62bd | Ruby | CaptainPhilipp/tn | /1/3_equation.rb | UTF-8 | 1,133 | 3.65625 | 4 | [] | no_license | #
# Квадратное уравнение.
#
# Пользователь вводит 3 коэффициента a, b и с.
# Программа вычисляет дискриминант (D) и корни уравнения (x1 и x2, если они есть)
# и выводит значения дискриминанта и корней на экран.
puts 'Введите три коэфициента (a, b и c) через пробел'
string = gets.chomp
split = string.split(' ').map { ... | true |
989fa235add838f6673236cf658d2d8f47654b90 | Ruby | msmithnova/learn_ruby | /15_in_words/in_words.rb | UTF-8 | 1,147 | 3.421875 | 3 | [] | no_license | module InWords
def in_words
high = ['trillion', 'billion', 'million', 'thousand', nil]
return "zero" if self == 0
result = []
num = ("%015d" % self).to_s.scan(/\d{1,3}/).map {|n| n.to_i}
num.each_with_index do |n, index|
if n > 0 then
result += process_section(n).split
suffix... | true |
0616f5ad9d12a440ec4ae9cfe74e71eeb814ca24 | Ruby | awmartin/yuzu | /lib/uploader/service.rb | UTF-8 | 1,392 | 2.6875 | 3 | [
"MIT"
] | permissive | require 'helpers/import'
import 'helpers/path'
import 'helpers/system_checks'
module Uploader
class UnrecognizedContentType < Exception; end
class ServiceNotConnected < Exception; end
class UploadArgumentError < Exception; end
class Service
include Helpers
def initialize(config)
@config = con... | true |
c96e0be2bc074b7f22e6dedb3446ecf3b581412f | Ruby | rebelcolony/lottomail | /app/models/lotto.rb | UTF-8 | 879 | 2.71875 | 3 | [] | no_license | class Lotto
class << self
def lotto_numbers
(1..49).to_a.sort{rand() - 0.5 } [0..5]
end
def euro_numbers
(1..50).to_a.sort{ rand() - 0.5 }[0..4]
end
def euro_stars
(1..9).to_a.sort{ rand() - 0.5 }[0..1]
end
def thunder_main
(1..34).to_a.sort{ rand(... | true |
c8f9f28e3caea521feaab225de7156e50ba3885f | Ruby | itiut/sutra-copying | /practical-object-oriented-design-in-ruby/c09/gear02_test.rb | UTF-8 | 680 | 2.671875 | 3 | [] | no_license | require_relative 'gear02'
require_relative 'wheel01'
require_relative 'test_helper'
require 'minitest/autorun'
class DiameterDouble
def diameter
10
end
end
class DiameterDoubleTest < Minitest::Test
include DiameterizableInterfaceTest
def setup
@subject = DiameterDouble.new
end
end
class GearTest ... | true |
c80ace42295e09e332a7476d17f0cc494cb72728 | Ruby | mkrumholz/symmetrical-spoon | /spec/features/competitions/show_spec.rb | UTF-8 | 2,184 | 2.546875 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe 'competition show page' do
before :each do
@comp_1 = Competition.create!(name: 'Show Me What You Got', location: 'Space', sport: 'Performance art')
@comp_2 = Competition.create!(name: 'Intergalactic Baseball', location: 'The Milky Way', sport: 'Baseball')
@team_1 = ... | true |
f4f788cb4b664ea4350f4a23dd3e8d958d0b9c65 | Ruby | nikfor/movies | /bin/movies.rb | UTF-8 | 590 | 2.578125 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'optparse'
require_relative '../lib/movies/my_movies_list'
films = MyMoviesList.from_file("../files/movies.txt","|")
func = ''
#films.send(ARGV[0])
opts = OptionParser.new do |opts|
opts.banner = "Movies: easy library for work with imdb-250 or tmdb-250"
opts.separator ""
opts.separa... | true |
9170cf40b4b6c38cf2e2cc200aab33997e0276eb | Ruby | theablefew/facebook_topics | /lib/facebook_topics/results/feed_collection.rb | UTF-8 | 724 | 2.53125 | 3 | [] | no_license | module FacebookTopics
class FeedCollection < Collection
attr_accessor :paging, :id
def initialize(results = [])
super(results)
@id = results["id"]
@paging = results["paging"] || results["ranked_posts"]["paging"]
@results = (results["data"] || results["ranked_posts"]["data"] || ... | true |
992c1cfed1ca68d9329ec0d1893297a26bf368b2 | Ruby | patapat/test-first-ruby-master | /08_book_titles/book.rb | UTF-8 | 517 | 3.859375 | 4 | [] | no_license | class Book
def title
@book
end
def title=(title)
@book = titleize(title)
end
private
def titleize(book_title)
excluded_words = ['the', 'a', 'an', 'and', 'in', 'of']
count = -1
final_phrase = []
split_phrase = book_title.split(' ')
split_phrase.each do |word|
count += 1
if count == 0
... | true |
fcb5a3227a67cb12be8d87fcfcfe829e36dc3e31 | Ruby | pfarrell/suck | /report.rb | UTF-8 | 2,035 | 2.65625 | 3 | [
"MIT"
] | permissive | require 'splunk-sdk-ruby'
require 'json'
require 'httparty'
class GDS
include HTTParty
attr_accessor :host, :group, :date, :data, :tags
def initialize(host="http://127.0.0.1:9292")
@host = host
@group = "gds"
@data = {}
@tags = []
end
def self.parse(str)
gds = GDS.new
generic=/\[(?<... | true |
bb3d3dc802f0819e0f7e207e9f2f0ee6124d4252 | Ruby | tjennings/obtiva-jruby-course | /first_half/solutions/calculator_solution.rb | UTF-8 | 1,494 | 3.125 | 3 | [] | no_license | require 'java'
require '../calculator'
class CalculatorUI
include_package 'javax.swing'
include_package 'java.awt'
include_package 'java.awt.event'
def initialize
@calculator = Calculator.new
window, panel = init_window
@display = init_display
panel.add @display
panel.add init_digits
... | true |
a388bf74a0373e84e534ca509c9fc2061a4a6b6c | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/roman-numerals/6b84be706a3f45e1ac3ac0266d2415c1.rb | UTF-8 | 200 | 3.375 | 3 | [] | no_license | module Digits
def thousands_value
self / 1000
end
def hundreds_value
(self % 1000) / 100
end
def tens_value
(self % 100) / 10
end
def ones_value
(self % 10)
end
end
| true |
f99967d73a6e351b0ad7466bf6f0ba7c36027f96 | Ruby | hatsu38/atcoder-ruby | /edpc/c.rb | UTF-8 | 544 | 3.21875 | 3 | [] | no_license | # frozen_string_literal: true
### 例
# N
# a_1 b_1
# ...
# a_N b_N
# h,w = gets.chomp.split(' ').map(&:to_i)
# strs = h.times.map{ gets.chomp.split('') }
# input
# 7
# 6 7 8
# 8 8 3
# 2 5 2
# 7 8 6
# 4 6 8
# 2 3 4
# 7 5 1
# output
# 46
n = gets.to_i
strs = Array.new(n) { gets.chomp.split.map(&:to_i) }
dp = Array.new... | true |
037b501ee99c8d90f7e0ef89a8ec87e35b90651e | Ruby | durrantm/ruby_learning | /ruby_spec_with_answers.rb | UTF-8 | 8,953 | 3.65625 | 4 | [] | no_license | require 'rspec'
require_relative 'answer_with_answers'
def fail_fast_for_step_by_step_learning_style
RSpec.configure {|c| c.fail_fast = true}
end
fail_fast_for_step_by_step_learning_style
describe "Ruby education" do
include Answer
it "Example_A1 - The number 5" do
expect(answer_A1).to eq 5
end
it "... | true |
44e62408cbb22fcc682e7a2340040afca05024d6 | Ruby | lugray/advent_of_code | /2016/day02/keypad.rb | UTF-8 | 1,316 | 3.78125 | 4 | [] | no_license | require 'matrix'
class Keypad
KEYPAD_A=[
[1, 2, 3],
[4, 5, 6],
[7, 8, 9],
]
KEYPAD_B = [
[nil, nil, 1],
[nil, 2, 3, 4],
[5, 6, 7, 8, 9],
[nil, "A", "B", "C"],
[nil, nil, "D"],
]
def initialize(weird_keypad = false)
if weird_keypad
@keypad = KEYPAD_B
@position =... | true |
a42992f2243b47ebd85c512f539feb35c995fe2f | Ruby | paulstuartparker/ruby_sound | /oscillator.rb | UTF-8 | 1,526 | 3.5 | 4 | [] | no_license | class Oscillator
attr_reader :output
attr_reader :size
attr_reader :freq
def initialize(freq, amplitude = 1.0, sample_rate = 44100.0)
@freq = freq
@amplitude = amplitude
@sample_rate = sample_rate
@period_position = 0.0
set_period_position_delta
end
def ... | true |
a17840835bb362a63456df0dbdce6e89ba49a26f | Ruby | priithaamer/adyen-skinbuilder | /lib/hash.rb | UTF-8 | 360 | 2.765625 | 3 | [
"MIT"
] | permissive | # Taken from File activesupport/lib/active_support/core_ext/hash/keys.rb, line 23
# + added symbolize_keys! for values
class Hash
def symbolize_keys!
keys.each do |key|
self[(key.to_sym rescue key) || key] = if (value = delete(key)) && value.is_a?(Hash)
value.symbolize_keys!
else
val... | true |
1300e1f4c07be694fe48d2286eb510e8792dba59 | Ruby | Proskurina/airport_challenge | /spec/airport_spec.rb | UTF-8 | 3,304 | 3.09375 | 3 | [] | no_license | require 'airport'
## Note these are just some guidelines!
## Feel free to write more tests!!
# A plane currently in the airport can be requested to take off.
#
# No more planes can be added to the airport, if it's full.
# It is up to you how many planes can land in the airport
# and how that is implemented.
#
# If th... | true |
2a4bc2942b5d4d7a1893a0d2179eb014d3928288 | Ruby | JackDelia/chess | /game.rb | UTF-8 | 1,093 | 3.59375 | 4 | [] | no_license | require_relative 'board'
require_relative 'human_player'
class Game
def initialize(player1, player2)
@board = Board.new
@player1 = player1
@player2 = player2
@player2.color = :b
@current_player = player1
end
def take_turn
input = nil
while input.nil?
puts @current_player.name
... | true |
7cba75eca26c143ae2f2fc5a291b9331feb4e715 | Ruby | gdaroch/estudiando_ruby | /AlcanceVariables.rb | UTF-8 | 647 | 3.96875 | 4 | [] | no_license | $variableGlobal = "Hola mundo global"
=begin
Ejemplo detipos de alcance de variables.
Variables Globales = en cualquier clase.
Variables de instancia = solo dentro de la clase.
Variables locales = solo dentro de un método.
=end
class HolaMundo
def initialize()
@variableInstancia = "Hola mundo instancia"
end
d... | true |
317ac5c62f445c6db585d76d52302ed0766382af | Ruby | SimonRuppGreene/2015week2 | /deliverables/ruby_monk_problems/random_select.rb | UTF-8 | 109 | 3.046875 | 3 | [] | no_license | def random_select(array, n)
outarray = []
n.times { outarray << array.shuffle[0] }
return outarray
end
| true |
95272eac7c4d964ea683559c67c316de9271dd61 | Ruby | sahyoni/RubyDoc | /load_require.rb | UTF-8 | 486 | 2.984375 | 3 | [] | no_license | load 'class_simple.rb' #load the class inside the file 'class_simple.rb' and let me use it
owner1=Car.new
owner1.set_owner("mohammad")
owner1.get_owner
#we use 'load' if we have some thing not fixed and always changing
#becouase load every time it reload the file and execute it
#we use require if we have some thing c... | true |
68873be061f55fdf9b81f8c632acbd02cfe1fae0 | Ruby | bookeee/high_load_app | /app/exceptions/wrong_posts_amount.rb | UTF-8 | 218 | 2.59375 | 3 | [] | no_license | # frozen_string_literal: true
class WrongPostsAmount < StandardError
attr_reader :message
def initialize(message = 'Should be not more not less then 1 and not more then 200000!')
@message = message
end
end
| true |
049c948921461fb48a8d031bdec4a13e75553529 | Ruby | Mantixas/RubyOnRails | /RubyMonk/pirmas.rb | UTF-8 | 219 | 3.015625 | 3 | [] | no_license | mas = []
puts "Iveskite, kiek masyvas tures elementu:"
n = gets.to_i
n.times do
puts "Iveskite skaiciu:"
str = gets.chomp
mas.push str
end
result = 0
result = mas[rand(mas.length)]
puts "Random number: "+ result
| true |
48735db3f30b477cf963919fbf3f32285d8e3b74 | Ruby | ali88b/ruby-object-initialize-lab-cb-000 | /lib/dog.rb | UTF-8 | 240 | 3.4375 | 3 | [] | no_license | class Dog
def initialize (dogs_name, dogs_breed = "Mutt")
@name = dogs_name
@breed = dogs_breed
end
def name= (doggy)
dogs_name,dogs_bread = doggy.split
end
def name
"#{@dogs_name} #{@dogs_breed}".strip
end
end
| true |
f3e2c49c775c1b4eee21cc0059fb2cf834841d9d | Ruby | haneuma201010/schedule | /app/helpers/admin_sessions_helper.rb | UTF-8 | 1,510 | 2.546875 | 3 | [] | no_license | module AdminSessionsHelper
def admin_log_in(admin_user) # なんかしらのデータを受け取る(この場合はadmin_user)
session[:admin_user_id] = admin_user.id # [:admin_user_id]っていう名前をつけた
# ()の中のadmin_userと4行目右辺のadmin_user.idは同じ
# ユーザーのブラウザ内の一時cookiesに暗号化済みのユーザーIDが自動で作成される。プラウザを閉じた瞬間に有効期限が終了する
# session変数
end
# 現在ログイン中のユー... | true |
d6745f9e53c69cd8be3d1c33d6d77f12ca22a687 | Ruby | shihaotan91/boggle_assignment | /app/services/game_board/validate_answer.rb | UTF-8 | 1,387 | 2.96875 | 3 | [] | no_license | module GameBoard
class ValidateAnswer
include CheckAnswer
include FindAnswer
attr_reader :response
def initialize(game, answer)
@game = game
@result = Result.find_by(game_id: game.id)
@answer = answer.upcase
@found = false
@response = { error_messages: [], board: @game... | true |
61b62803c40d87478394e59e37d3c65ae4b9b44a | Ruby | pr0d1r2/dir_checksum | /dir_checksum.rb | UTF-8 | 2,229 | 2.75 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'yaml'
require 'fileutils'
start_dir = Dir.pwd
case `uname`
when 'Darwin'
@md5cmd = 'md5'
else
@md5cmd = 'md5sum'
end
def md5(file)
if file.include?("'")
`#{@md5cmd} "#{file}" | cut -b1-32`.strip
else
`#{@md5cmd} '#{file}' | cut -b1-32`.strip
end
end
def proper_suffix?... | true |
1ce8901e5b84abd573652affc833427c40f9b278 | Ruby | maggieee/learn-to-program-chris-pine | /exercises/dice.rb | UTF-8 | 603 | 3.609375 | 4 | [] | no_license | class Die
def initialize
roll
end
def roll
@number_showing = 1 + rand(6)
end
def showing
@number_showing
end
def cheat
puts 'Please give me a valid die side number to show on the die.'
@number_showing = gets.chomp
valid_die_sides = [1,2,3,4,5,6]
if valid_die_sides.include?(@number_showing.to_... | true |
ee6305dcb6344077477e53ab0aabc66d57006358 | Ruby | lisushka/rogare | /commands/calc.rb | UTF-8 | 1,371 | 2.71875 | 3 | [
"Apache-2.0"
] | permissive | # frozen_string_literal: true
class Rogare::Commands::Calc
extend Rogare::Command
command 'calc'
aliases '='
usage '`!% <a calculation>`'
handle_help
match_command /(.+)/
match_message /(?:\d+\s*[\-+]\s*\d+)/
match_empty :help_message
def execute(m, param)
param.strip!
# By far the most c... | true |
fcef3588fe792d3db76242097a7c5d4feb901bcb | Ruby | chrisadames/101_programming_foundations | /small_problems/easy_3/odd_lists.rb | UTF-8 | 642 | 4.3125 | 4 | [] | no_license | =begin
Write a method that returns an Array that contains every other element of an Array that is passed in as an argument. The values in the returned
list should be those values that are in the 1st, 3rd, 5th, and so on elements of the argument Array.
Examples:
oddities([2, 3, 4, 5, 6]) == [2, 4, 6]
oddities(['abc',... | true |
71c4d5059393fcf382e25e56ffb755d1a101e954 | Ruby | kevindjacobson/minecraft_api | /lib/world.rb | UTF-8 | 744 | 2.71875 | 3 | [] | no_license | require_relative 'block'
class World
def initialize(api)
@api = api
end
def block_at(x,y,z)
response = @api.send_and_receive("world.getBlock(#{x},#{y},#{z})")
Block.find(response.to_i)
end
def block(x,y,z,block)
@api.send("world.setBlock(#{x},#{y},#{z},#{block.as_parameter_list})")
end
... | true |
1d574dc5df1d2a1a0f30d38fad7bb048ba48a6a7 | Ruby | groupofn/3Lisp.Ruby | /3LispReader.rb | UTF-8 | 13,771 | 3.359375 | 3 | [] | no_license | # encoding: UTF-8
####################################
# #
# Ruby Implementation of 3Lisp #
# #
# Version 1.00 #
# #
# 2011-05-20 #
# Group of N #
# ... | true |
6b7e9609afb52400b01a727b4738ed3cff43d28c | Ruby | nicolasqueen/my-each-cb-000 | /my_each.rb | UTF-8 | 158 | 3.625 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def my_each(stuff)
i = 0
while i < stuff.length
yield(stuff[i])
i += 1
end
stuff
end
collection = [1, 2, 3, 4]
my_each(collection) do |num|
num
end | true |
a815552228b74a530f09ee17b6f75a3d6d1ae26f | Ruby | ianfleeton/zmey | /lib/discounts/calculator.rb | UTF-8 | 1,727 | 2.8125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Discounts
# Calculates discounts for a basket.
# It delegates to a specialized calculator for each discount type.
class Calculator
attr_reader :basket
attr_accessor :discounts
attr_accessor :discount_lines
def initialize(discounts, basket)
@basket = bas... | true |
8ab82996916d8433079d20851fcb5d3adba1ee86 | Ruby | MBO/euler | /euler009.rb | UTF-8 | 599 | 3.53125 | 4 | [] | no_license | #!/usr/bin/env ruby1.9
#******************************************************************************
# A Pythagorean triplet is a set of three natural numbers, a b c, for which,
# a^2 + b^2 = c^2
#
# For example, 3^2 + 4^2 = 9 + 16 = 25 = 5^2.
#
# There exists exactly one Pythagorean triplet for which a + b + c = ... | true |
4fddea137ab39fea688d92ad89c53701a37d667b | Ruby | nathaniel-miller/fedex_sort | /app/models/sort_type.rb | UTF-8 | 433 | 2.59375 | 3 | [] | no_license | class SortType < ApplicationRecord
belongs_to :roster
belongs_to :setup
has_many :sorts
has_and_belongs_to_many :schedules
# return array of integers (0-6) representing days Sun - Sat
#for use with date.wday method
def weekdays
wdays = []
wdays << 0 if sun
wdays << 1 if mon
wdays << 2 if ... | true |
23d34b672417b706f13d4393be2630a49ccfe190 | Ruby | jeffmaury/golo-lang | /benchmarks/src/main/ruby/dynamicobjects.rb | UTF-8 | 373 | 3.1875 | 3 | [
"Apache-2.0"
] | permissive | require 'java'
def run
obj = Object.new
obj.instance_variable_set("@random", java.util.Random.new)
def obj.rand
@random.nextInt()
end
obj.instance_variable_set("@acc", 0)
def obj.acc
@acc
end
def obj.acc=(value)
@acc = value
end
i = 0
while i < 5000000 do
obj.acc = obj.acc + obj.r... | true |
11bc92a319a3d80044e74d3967d7aaa6881b9ad3 | Ruby | michaelpmattson/battleship | /spec/cell_spec.rb | UTF-8 | 5,855 | 3.21875 | 3 | [] | no_license | require './lib/ship'
require './lib/cell'
RSpec.describe Cell do
context '#initialize' do
it 'exists' do
cell = Cell.new("B4")
expect(cell).to be_a(Cell)
end
it 'has a coordinate' do
cell = Cell.new("B4")
expect(cell.coordinate).to eq("B4")
end
it 'starts with no ship'... | true |
edc3d5d33e73bd84e1caa1190768d93952e8e844 | Ruby | Dvvuuh/Exo0704 | /exo_10.rb | UTF-8 | 132 | 2.90625 | 3 | [] | no_license | puts "Bonjour, c'est quoi ton année de naissance ?"
user_date = gets.chomp
puts "D'accord en 2017 tu avais #{2017 - user_date}"
| true |
eb46e26b460b5fcc8693862fe934ab2e38549347 | Ruby | GerryG/wikirate | /mod/metric_answer_lookup/spec/lib/answer/answer_search_spec.rb | UTF-8 | 2,123 | 2.546875 | 3 | [] | no_license | RSpec.describe Answer, "Answer.search" do
def search args
described_class.search args
end
def record_names args
search(args.merge(return: %i[metric_id company_id])).map do |array|
Card::Name[*array]
end
end
it "searches by title" do
expect(record_names(title_id: "darkness rating".card_... | true |
963eb0eec5b5f59a41092b87b9bb02c486027d92 | Ruby | aconstandinou/ls-exercises | /120_small_problems/easy_two/pet_shelter.rb | UTF-8 | 1,784 | 3.875 | 4 | [] | no_license | require 'pry'
class Pet
attr_reader :type, :name
def initialize(pet_type, pet_name)
@type = pet_type
@name = pet_name
end
end
class Owner
attr_accessor :name, :number_of_pets
def initialize(owner_name)
@name = owner_name
@number_of_pets = 0
end
def number_of_pets
@number_of_pets
... | true |
66cfe32449a93b29f988fdf30cfd8f117e2cd54d | Ruby | daynS/hangman | /spec/game_spec.rb | UTF-8 | 395 | 2.671875 | 3 | [
"MIT"
] | permissive | require "spec_helper"
module Hangman
describe Game do
context "#initialize" do
it "randomly selects a word 5-12 chars" do
#puts Dir.pwd
game = Game.new
expect(game.word.length).to be_between(5, 12).inclusive
end
skip it "gives the same number of clues as word.length" do
game = Game.new
... | true |
5977db0a3a07b14121d6cab0d297caefa777057e | Ruby | DaxSoft/RGSS3 | /ULSE_EN.rb | UTF-8 | 15,305 | 2.609375 | 3 | [] | no_license | #==============================================================================
# • Ultimate Sensor Event [EN]
#==============================================================================
# Author: Dax
# Requeris: Ligni Core
# Version: 5.2
# Site: www.dax-soft.weebly.com
#============================================... | true |
9703201fcc91e8808973096f2fe34d835bb7b363 | Ruby | abbieneufeld/RB120 | /Exercises/OO_Basics_Accessor_Methods/10.rb | UTF-8 | 216 | 3.4375 | 3 | [] | no_license | class Person
def name=(name)
@first_name = name.split.first
@last_name = name.split.last
end
def name
@first_name + " " + @last_name
end
end
person1 = Person.new
person1.name = 'John Doe'
puts person1.name | true |
86260484e4b9cb443dd432a772d6509db8038de7 | Ruby | untoldone/skyrocket | /lib/skyrocket/processor.rb | UTF-8 | 745 | 2.578125 | 3 | [] | no_license | module Skyrocket
module Processor
def extension
raise NotImplimentedError.new("must impliment #{caller[0][/`.*'/][1..-2]} for #{self.class.name}")
end
def process(contents, name)
contents = preprocess_contents(contents, name) if self.respond_to?(:preprocess_contents)
process_contents(co... | true |
035f22662147fa384cd5d5055be90ed2732c8927 | Ruby | grosser/i18n_data | /spec/i18n_data_spec.rb | UTF-8 | 6,615 | 2.546875 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
require "spec_helper"
NUM_2_LETTER_LANGUAGES = 184
NUM_COUNTRIES = 249
describe I18nData do
require "i18n_data/live_data_provider"
require "i18n_data/file_data_provider"
def blank_keys_or_values(hash)
hash.detect{|k,v| k.to_s.empty? or v.to_s.empty?}
end
around do |t|
old = I18nD... | true |
2fec569b8ac0821b29745d200d073b10e432b902 | Ruby | zeroalpha/project_euler | /problem_2/problem_2.rb | UTF-8 | 469 | 4.15625 | 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.
... | true |
9dfb00725e69c8706815de0be8f1fd879a3b56a8 | Ruby | MECU/exercism-ruby | /kindergarten-garden/kindergarten_garden.rb | UTF-8 | 638 | 3.53125 | 4 | [] | no_license | class Garden
PLANTS = {
'G' => :grass,
'C' => :clover,
'R' => :radishes,
'V' => :violets
}
STUDENTS = %w[Alice Bob Charlie David Eve Fred Ginny Harriet Ileana Joseph Kincaid Larry]
def initialize(garden, students = STUDENTS)
@garden = garden.split("\n").map { |r| r.split('') }
@student... | true |
a6d192880c4377043fa4bc3b57f82fc488182159 | Ruby | rishirajkumar97/vending_machine | /app/controllers/vending_controller.rb | UTF-8 | 1,806 | 2.75 | 3 | [] | no_license | # frozen_string_literal: true
class VendingController < ApplicationController
DISPENSED = 'Dispensed'
# Index Method to Dispense a Beverage by calling /vend with required beverage id
# Also Notifies the user if after any dispense action which of the ingredients reached 0 or has become empty
# with its details... | true |
aaa7a7fab260912e2b13a54a5096fc9467c1a158 | Ruby | MagicKey23/W1D1 | /enumerables.rb | UTF-8 | 1,880 | 3.484375 | 3 | [] | no_license | class Array
def my_each(&prc)
i = 0
while i < self.length
prc.call(self[i])
i += 1
end
self
end
def my_select(&prc)
i = 0
new_arr = []
while i < self.length
if prc.call(self[i])
new_arr << self[i]
end
i += 1
end
new_arr
end
def my_reject(&prc)
i = 0
new_arr = [... | true |
ae43bf25758e1d2852a5572287d24b50d9f3cd89 | Ruby | BalintMendli/Tic-tac-toe | /lib/ui.rb | UTF-8 | 254 | 3.125 | 3 | [] | no_license | module UI
def output(str, new_line = false)
print str + (new_line ? "\n" : '')
end
def input
gets.chomp
end
def clear_console
system('clear')
end
def show_welcome_message
output('Welcome to Tic-tac-toe!', true)
end
end
| true |
e71cef03cb103c35d32d4270bbba11b3fef835a7 | Ruby | anisharamnani/command-line-classmates | /lib/scraper.rb | UTF-8 | 2,176 | 3.875 | 4 | [] | no_license | # Ashley's gist--command line classmates
# https://gist.github.com/ashleygwilliams/7586141
# require the libraries that we need
require 'open-uri'
require 'nokogiri'
class Scraper
attr_reader :html
def initialize(url)
download = open(url)
# into the class Nokogiri
# using the method HTML
# passing the ... | true |
e97aecd2f26cf78ffd90c4e480961101a991a7b9 | Ruby | AvraamMavridis/ruby-exercises | /non_consecutive_pairs/non_consecutive_pairs.rb | UTF-8 | 247 | 3.078125 | 3 | [] | no_license | def non_consec_pairs(myarray)
if(myarray.size < 2)
return []
end
arr = myarray.each_with_index.map do |x, i|
l = myarray.slice(i, myarray.size)
[x].product(l)
end
arr.flatten(1).select{ |(a,b)| (a.ord-b.ord).abs > 1 }
end
| true |
c3fb4f077e17d8d089356ec6b58203ebe09d1aca | Ruby | gman-code/method-scope-lab-onl01-seng-ft-090820 | /lib/catch_phrase.rb | UTF-8 | 47 | 2.578125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def catch_phrase(phrase)
puts"#{phrase}"
end
| true |
f8f2b7d69f507f377ae7826a37ade4386ab6665a | Ruby | zendesk/mocha | /test/assertions.rb | UTF-8 | 280 | 2.546875 | 3 | [
"MIT",
"Ruby"
] | permissive | module Assertions
def assert_method_visiblity(object, method_name, visiblity)
method_key = RUBY_VERSION < '1.9' ? method_name.to_s : method_name.to_sym
assert object.send("#{visiblity}_methods", false).include?(method_key), "#{method_name} is not #{visiblity}"
end
end | true |
63d8806ba77e5eb5c630d3ab7ccba17fdc31b8fd | Ruby | MichaelBaker/katas | /word-wrap/06/word_wrap.rb | UTF-8 | 345 | 3.40625 | 3 | [] | no_license | module Wrapper
def self.wrap(text, max_column)
lines = []
while text.length > max_column
line = text[0...max_column]
white_space = line.rindex /\s/
limit = white_space || max_column
lines << text[0...limit]
text = text[limit..-1].strip
end
lines << text
l... | true |
07bc0740f7f6de8562ce33b5f3f8e9dcb3e75cdf | Ruby | Jonesyd/launchschool_exercises | /small_problems2/12_medium_2/07_unlucky_days.rb | UTF-8 | 218 | 3.5625 | 4 | [] | no_license | require "date"
def friday_13th(year)
array = []
12.times { |month| array << 1 if Date.new(year, month + 1, 13).friday? }
array.sum
end
p friday_13th(2015) == 3
p friday_13th(1986) == 1
p friday_13th(2019) == 2
| true |
a7c3188062a95903e01950852033fdafcee54ad3 | Ruby | feigningfigure/WDI_NYC_Apr14_String | /w03/d03/Victor_Rodriguez/inheritance/ninja.rb | UTF-8 | 119 | 3.0625 | 3 | [] | no_license | class Ninja
attr_accessor :name
def intialize(name)
@name = name
end
def real_ultimate_power?
true
end
end
| true |
0125db4f07e96caa4a64f4fb514937eb47b502a6 | Ruby | sumanththikka/RailsCodingChallenge | /spec/cuboid_spec.rb | UTF-8 | 5,368 | 3.296875 | 3 | [
"MIT"
] | permissive | require 'cuboid'
require 'vertex'
#This test is incomplete and, in fact, won't even run without errors.
# Do whatever you need to do to make it work and please add your own test cases for as many
# methods as you feel need coverage
describe Cuboid do
describe "move_to" do
it "changes the origin in the simp... | true |
349ae88f75f80f0f87677e96b46449335fa479a3 | Ruby | ignoch/mass_insert | /spec/adapters/column_types/boolean_spec.rb | UTF-8 | 1,381 | 2.59375 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe "Boolean" do
before :each do
@values, @options = [{:active => true}], {}
end
context "when exist in values hashes" do
context "when contains boolean value" do
context "when is true" do
it "should be saved correctly" do
User.mass_insert(@values, @o... | true |
e1c5eba1428256cb56efdad754345e23c47e17f1 | Ruby | taish/rails_app | /lib/tasks/follow_task.rb | UTF-8 | 1,474 | 2.515625 | 3 | [] | no_license | class Tasks::FollowTask
# アンフォローリストの最初から10件づつ削除
def self.execute
loop do
TwitterUser.all.find_each do |twi_user|
twitter = Api::Service::Twitter.new(twi_user.access_token, twi_user.access_token_secret)
search_words = twi_user.search_words.pluck(:word)
if search_words.present?
... | true |
92562877a806ffa5f1b855055d9da6826d82d166 | Ruby | lkdjiin/electr | /lib/electr/compiler.rb | UTF-8 | 622 | 3.265625 | 3 | [
"Apache-2.0"
] | permissive | module Electr
# The toolchain that takes a code at input and outputs it in another
# structure.
#
# The compiler could outputs the code either as an AST or as a list of
# element in the prefix notation.
class Compiler
def self.compile_to_ast(code)
units = []
tokenizer = Tokenizer.new(code)... | true |
f3cfc77d6d3273645dc26308ab14f9a9bf35c3bd | Ruby | vtourrilhes/AyDO2017-TPFinal | /TpFinal/spec/recursos_builder_spec.rb | UTF-8 | 3,754 | 2.796875 | 3 | [] | no_license | require 'rspec'
require 'json'
require_relative '../model/recursos_builder'
require_relative '../model/recurso_sala'
require_relative '../model/recurso_proyector'
describe 'RecursosBuilder' do
let(:builder) { RecursosBuilder.new() }
it 'Se deberia crear un recurso tipo Sala a partir de un nombre y sin estado' do
... | true |
23e7d28e26e53ec277df08b0fe4f63981207899f | Ruby | eroiyo/ruby-school-library | /person.rb | UTF-8 | 760 | 3.09375 | 3 | [] | no_license | # frozen_string_literal: true
require_relative 'corrector'
# Base data than all the people share
class Person
attr_accessor :name, :age, :rentals, :parent_permission
attr_reader :id
def initialize(name, age, parent_permission, id)
@id = id
@id = Random.rand(1..1000) if id.nil?
@name = name
@age... | true |
b5b2989a93f42824d479ce89e6247ecfa60e0f97 | Ruby | justinweiss/error_stalker | /lib/error_stalker/client.rb | UTF-8 | 2,325 | 2.75 | 3 | [
"MIT"
] | permissive | require 'error_stalker/exception_report'
require 'error_stalker/backend'
require 'tempfile'
# The error_stalker client enables you to log exception data to a
# backend. The class method ErrorStalker::Client.report is usually the
# method you want to use out of this class, although for those who
# like block syntax, th... | true |
e3936ad9de0851544d58b6d3d1fcb6b4c4f7a354 | Ruby | RamadanYosiPratama/Belajar_Ruby | /insertanddelete.rb | UTF-8 | 527 | 3.46875 | 3 | [] | no_license | nama = ["one","two","tri","for"]
# nama.unshift("pip") # pip akan dimasukkan oleh unshift unutk di array pertama
# # unshift adalah untuk insert data
# nama.push("six") # push adalah cara insert data untuk di array terakhir
# nama.insert(4, "sepen") # insert dan 4 adalah memasu... | true |
e1e2099b4533accefae05063f0901e418df35369 | Ruby | hassanrehman/project_euler | /problem006.rb | UTF-8 | 100 | 2.65625 | 3 | [] | no_license | require './utility.rb'
limit = 100
puts (1..limit).to_a.sum**2 - (1..limit).to_a.map{|a| a**2 }.sum | true |
62aea3d68dd50b968696419eb3e6d072eb216f81 | Ruby | Chasteau/ar-exercises | /exercises/exercise_4.rb | UTF-8 | 909 | 3.046875 | 3 | [] | no_license | require_relative '../setup'
require_relative './exercise_1'
require_relative './exercise_2'
require_relative './exercise_3'
puts "Exercise 4"
puts "----------"
# Your code goes here ...
@store4 = Store.create(name: "Surrey", annual_revenue: 224000, mens_apparel: false, womens_apparel: true)
@store5 = Store.create(nam... | true |
efa7cffadca7ca5e1449571852c9a1e75167b9a0 | Ruby | sinithwar/CodeEval | /Palindrome.rb | UTF-8 | 482 | 3.5625 | 4 | [] | no_license | =begin
class Integer
def digits
self.to_s.split('').map(&:to_i)
end
def palindrome?
self.to_s == self.to_s.reverse
end
end
=end
resultRoom = []
=begin
start = 0
result = start.to_s
if result == result.reverse
resultRoom << result
end
until(start <= 1000)
start = start + 1
end
elsi... | true |
2ad4b01f5efa049e6c428192bd6f7ef66b5f8552 | Ruby | nakaly/aozorahack_fk | /header_footer_cut.rb | UTF-8 | 288 | 2.609375 | 3 | [] | no_license | #!/usr/bin/env ruby
# coding: utf-8
KISAI = /^-{5,}/
MATSUBI_START = /^底本:/
kisai_count = 0
while line = STDIN.gets
if kisai_count != 2
if line =~ KISAI
kisai_count += 1
end
next
else
if line =~ MATSUBI_START
break
end
puts line
end
end
| true |
9c0809abff1b1c4e6d28b95d5060f7159647ebfa | Ruby | jimm/www-jimmenard-com-jekyll | /rubyquiz/quiz60/numeric_maze_test.rb | UTF-8 | 1,175 | 3.484375 | 3 | [] | no_license | #! /usr/bin/env ruby
require 'test/unit'
require 'numeric_maze'
class NumericMazeTest < Test::Unit::TestCase
def test_equal
assert_equal("12 == 12. You tried to trick me!", solve(12, 12))
end
def test_prune_cycles
paths = [[1,2,4,3,4], [1,2,3,4,5], [1,2,3,4,2], [1,2,3,4,1]]
assert_equal([[1,2,3,4,5... | true |
3726501d9d8bd7d7c0393c8172ee745836587167 | Ruby | cmramseyer/glass | /lib/override/custom_date_time_format.rb | UTF-8 | 406 | 2.65625 | 3 | [] | no_license | module CustomDateTimeFormat
def normal_format
strftime("%m/%d/%y %H:%M")
end
def only_date_format
strftime("%m/%d/%y")
end
def only_month_day
strftime("%m/%d")
end
def large_format
strftime("%h %d, %Y %H:%M:%S")
end
end
class Time
include CustomDateTimeFormat
end
class Date
in... | true |
7d76f257759568aa1e2113f188fb5227ce7383b6 | Ruby | wtfspm/advent_of_code | /2018/07/assembly.rb | UTF-8 | 736 | 3.21875 | 3 | [] | no_license | require 'pry-byebug'
EXPR_RE = /Step ([A-Z]) must be finished before step ([A-Z]) can begin./
steps = ARGF.readlines.map { |step| EXPR_RE.match(step).captures }
sequence = ''
def build_graph(steps)
graph = steps.flatten.uniq.each_with_object({}) { |step,g| g[step] = [] }
steps.each do |prereq, step|
graph[s... | true |
de1a034356a1fc8a54798eb19aa679c23f472aed | Ruby | djmicros/ror-tasks | /task-4/test/user.rb | UTF-8 | 3,100 | 2.609375 | 3 | [] | no_license | require_relative 'test_helper'
require_relative '../lib/user'
require_relative '../lib/todo_item'
require_relative '../lib/todo_list'
describe User do
include TestHelper
subject(:user) { User.create(name: name, surname: surname, email: email, password: password, password_confirmation: password_... | true |
e98a764c5c4e7a614c4f312b4f2c9f495307a445 | Ruby | trevor-gitgoat-dev/rdie | /lib/spec/rake/verify_spec_ratio.rb | UTF-8 | 2,752 | 2.765625 | 3 | [] | no_license | module Spec
module Rake
# A task that can verify that the ratio of (lines of spec)
# over (lines of code) doesn't drop below a certain threshold.
# It should be run after running Spec::Rake::SpecTask.
class VerifySpecRatioTask < ::Rake::TaskLib
# Name of the task. Defaults to :verify_spec_r... | true |
2481eb3caf70e340f0dd44e3e5cbc499bee01c87 | Ruby | hayaminahiro/AttendanceSystem_A | /app/helpers/users_helper.rb | UTF-8 | 771 | 3.265625 | 3 | [] | no_license | module UsersHelper
# 基本時間・指定勤務時間などをフォーマット化
def format_basic_info(datetime)
format("%.2f", ((datetime.hour * 60) + datetime.min) / 60.0)
end
# (例) 18:30 => 18.5
# “%.2f”, ((datetime.hour * 60) + datetime.min)/60.0)
# a = 18(datetime.hour) * 60 == 1080
# b = 30(datetime.min)
# c = a + b == 1110 / 60.0
# ... | true |
fd44048428afa89d5b879f71a6de596f8f853075 | Ruby | ffeldhaus/soil | /app/models/game.rb | UTF-8 | 1,551 | 2.578125 | 3 | [] | no_license | class Game < ApplicationRecord
has_many :players, autosave: true, dependent: :destroy
has_many :rounds, through: :players
belongs_to :admin
serialize :weather
serialize :vermin
accepts_nested_attributes_for :players
validates :name, :presence => true, :length => {:in => 4..128}
after_initialize do
... | true |
35642a7b9fb596909fef52b4152d232dee60254f | Ruby | ainkaran/webdev | /ruby_basics_june_2017/basics/multiply_nums.rb | UTF-8 | 210 | 4.09375 | 4 | [] | no_license | puts "Give me a number, human! 🤖"
print "> "
num1 = gets.chomp.to_f
puts "Give me another number, human! 🤖"
print "> "
num2 = gets.chomp.to_f
puts "I have multiplied your numbers! Tada! #{num1 * num2}"
| true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.