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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
43ff0cbe9b923f81d58a03038699b3c426b98e7d | Ruby | blm768/plasmid | /lib/plasmid/buildable.rb | UTF-8 | 4,823 | 3.015625 | 3 | [
"MIT"
] | permissive | require 'plasmid/validatable'
# Design notes
# We'll want lazy evaluation, but when we do, we'll need to make sure that
# validations run on lazy attribute evaluation. (We'll probably also cache the
# result of the evaluation.) The lazy evaluation type must not be allowed as the
# type of a field (if the type is set) ... | true |
9be5d5765e81a8a1aee31fef4d8c816f287c59c7 | Ruby | ababup1192/Rating_aizu_v2 | /src/util/tkextension.rb | UTF-8 | 3,316 | 2.96875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
require 'tk'
# Tkユーティリティクラス
class TkUtils
def self.set_entry_value(entry, value)
if !value.nil? then
entry.state = 'normal'
entry.value = value
entry.state = 'readonly'
end
end
def self.set_text_value(textbox, value)
if !value.nil? then
textbox.state =... | true |
c5d956c2e3c9140b0bc3155524ee12a939e37475 | Ruby | fespinoza/custom-git-scripts | /lib/not_released_changes.rb | UTF-8 | 1,423 | 2.90625 | 3 | [
"MIT"
] | permissive | class NotReleasedChanges
attr_reader :base_ref, :current_ref
@@output = $stdout
def self.print_usage
@@output.puts "Usage: git not-released [base-ref] [current-ref](optional)"
end
def initialize(base_ref, current_ref)
@base_ref = base_ref
@current_ref = current_ref
end
def print_formatt... | true |
556bd7fa918f0aa97852bcec6f2a2e08832b4685 | Ruby | nick-zhang/rubyPractice | /rubyLesson2/src/Caesar.rb | UTF-8 | 250 | 3.171875 | 3 | [] | no_license | def encrypt text
result = ''
text.each_byte do |ascii|
if (ascii <= 'Z'.ord && ascii > 90-3) || (ascii > 122-3)
result += ((ascii + 3) -26).chr
else
result += (ascii + 3).chr
end
end
result
end
puts encrypt 'Za' | true |
fe7783c82254e1c45bf41fbf52eb222fbccb5125 | Ruby | joelparkerhenderson/simple_shipping | /lib/simple_shipping/shipment.rb | UTF-8 | 1,420 | 2.75 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | module SimpleShipping
# Represents a shipment.
#
# == Attributes:
# * _shipper_ (an instance of {SimpleShipping::Party}
# * _recipient_ (an instance of {SimpleShipping::Party}
# * _package_ (an instance of {SimpleShipping::Package}
# * _payor_ (:shipper, :recipient). Default value is :shipper
class Shi... | true |
4156136d6434e13f3129abe1402c158254b4928b | Ruby | kaos34k/AprendiendoRuby | /procedimientos.rb | UTF-8 | 266 | 3.734375 | 4 | [] | no_license | class Array
def iterar(bloque)
self.each_with_index do |n,i|
self[i] = bloque.call(n)
end
end
end
#estanciar procedimientos
arreglo = [1,2,3,4]
elevarCuadrado = Proc.new do |n|
n**2
end
arreglo.iterar(elevarCuadrado)
for i in arreglo
puts i
end
gets() | true |
67ff2de18dfc5229942acaebe048e5da5d89f552 | Ruby | alex-benoit/git-103 | /workshop/conditions.rb | UTF-8 | 323 | 3.71875 | 4 | [] | no_license | puts "What time is it?"
hour = gets.chomp.to_i
if hour < 9
puts "closed!"
elsif hour > 20
puts "closed!"
elsif hour > 12 && hour < 14
puts "closed!"
else
puts "open!"
end
# puts "How old are you?"
# user_age = gets.chomp.to_i
# if user_age >= 18
# puts "You can vote!"
# else
# puts "You cannot vote!"
# e... | true |
d4beebdb9c8ac47172cf790a677131173978e038 | Ruby | th13/yomi-archive | /db/seeds.rb | UTF-8 | 1,287 | 2.921875 | 3 | [] | no_license | # This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel... | true |
8692b5192d798e3b5025b87e881739c852ea365b | Ruby | mitchelson1021/E6CP1A1 | /2 ciclos/ejercicio2.rb | UTF-8 | 134 | 3.140625 | 3 | [] | no_license | # En el siguiente código reemplaza la instrucción 'while' por 'times'.
i = 0
while i < 10
puts "Iteración #{i}"
i = i + 1
end
| true |
de039746e3940bf1be061de20a8c45bd21ca799e | Ruby | fdeco/BEWD_NYC_5 | /02_Classes_Objects/slides/code/code_along_toy.rb | UTF-8 | 264 | 3.171875 | 3 | [] | no_license | Toy = Class.new do
def initialize name, description, player
@name = name
@description = description
@player = player
end
def player player
@player = player
end
def welcome
"Welcome to #{@name} #{@player}! #{@description}"
end
end
| true |
fd34d5235fcaf7946ac8dc2c727039e54e039653 | Ruby | HansHauge/InternetVortex | /lib/ext/string.rb | UTF-8 | 573 | 2.6875 | 3 | [] | no_license | class String
require 'htmlentities'
def is_probably_a_picture?
image_extensions = %w(.jpg .png .gif .jpeg .gifv)
image_extensions.each do |ext|
return true if ends_with?(ext)
end
false
end
def remove_html_tags
re = /<("[^"]*"|'[^']*'|[^'">])*>/
self.gsub(re, '')
end
def remo... | true |
dab8de5949f77e2ef05f4bf0b7e96a1cc09a5270 | Ruby | yalinhuang/ProjectEulerRuby | /prob_58.rb | UTF-8 | 247 | 3.0625 | 3 | [] | no_license | #!/usr/bin/env ruby
require "MyInteger"
totalCount = 1
primeCount = 0
num = 1
diff = 2
begin
4.times {
num += diff
primeCount += 1 if num.isPrime?
totalCount += 1
}
diff += 2
end while primeCount.to_f/totalCount.to_f>=0.1
puts diff-1
| true |
79dd1832175467005d9f1108ac8b2b38a88d9f8b | Ruby | billyjack1988/d3_isbn_chart | /bucket_func.rb | UTF-8 | 1,223 | 2.84375 | 3 | [] | no_license | require 'rubygems'
require 'aws-sdk'
require 'csv'
load './local_env.rb' if File.exist?('./local_env.rb')
def connect_to_s3()
Aws::S3::Client.new(
access_key_id: ENV['AWS_ACCESS_KEY_ID'],
secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
region: ENV['AWS_REGION'],
)
file = "myresults.csv"
bucket =... | true |
491a522e5242cdff7b683c0d4a4be6b9c0a0b1e7 | Ruby | luiemilio/MTGTCGBot | /mtg.rb | UTF-8 | 1,057 | 2.671875 | 3 | [] | no_license | require 'byebug'
require 'mtg_sdk'
require 'telegram/bot'
require_relative 'token'
token = KEY
def get_cards(search_term)
cards = MTG::Card.where(name: search_term).all[0..9]
get_unique_cards(cards)
end
def get_unique_cards(cards)
card_names, unique_cards = [], []
cards.each do |card|
next if card_names.... | true |
ecb4d155d715f92129b517b8c86a27276e05da5f | Ruby | andywenk/ruby-lint | /spec/ruby-lint/parser/keywords.rb | UTF-8 | 2,544 | 2.546875 | 3 | [
"MIT"
] | permissive | require File.expand_path('../../../helper', __FILE__)
describe 'Rlint::Parser' do
it 'Parse a defined? keyword' do
token = RubyLint::Parser.new('defined?(Foobar)').parse[0]
token.class.should == RubyLint::Token::KeywordToken
token.type.should == :keyword
token.name.should == 'defined?'
token.... | true |
a1abd2a90df8d66cdf79cdbd476963879bfc5c25 | Ruby | brandonparsons/api.retirementplan.io | /app/services/quotes_service.rb | UTF-8 | 676 | 2.703125 | 3 | [] | no_license | module QuotesService
extend self
## ONLY CALL quotes_json ONCE! Or cache it in method ##
def for_etfs(tickers)
raise "Tickers must be an array" unless tickers.is_a?(Array)
get_as_objects.select {|k,v| tickers.include?(k) }
end
private
def get_as_objects
top_level = Hashie::Mash.new(JSON.pa... | true |
e1e51166135118683c160c8bb8addf61a1ce7de6 | Ruby | miriamdong/TwO-O-Player-Math-Game | /main.rb | UTF-8 | 920 | 3.84375 | 4 | [] | no_license | require "./players"
require "./games"
player1 = Players.new(player1)
player2 = Players.new(player2)
count = 0
while (player1.alive? && player2.alive?) do
player = (count == 0) ? player1 : player2
puts '----- NEW TURN -----'
game = Games.new
puts "#{player.name}: #{game.question}"
print '> '
answer = gets... | true |
a74459b64566d898645ee29f392659bf3d50e181 | Ruby | jahman07104/cli-applications-simple-blackjack-online-web-prework | /lib/blackjack.rb | UTF-8 | 698 | 2.953125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def welcome
puts "Welcome to the Blackjack Table"
end
def deal_card
rand(1..11)
end
def
display_card_total 8
"your cards add up to" #{display_card_totalcard_total}
end
def
puts display_card_total()
end
def prompt_user
puts "Type 'h' to hit or 's' to stay".
end
def get_user_input
gets.strip
end
def end_... | true |
441f6f0e8acca6513f4e95dba4adc8b688a1cf5d | Ruby | rebekahliu/Homework | /w1d5_homework/w1d5_rebekah_liu.rb | UTF-8 | 929 | 3.359375 | 3 | [] | no_license | class Stack
def initialize
@stack = []
end
def add(el)
@stack << el
end
def remove
@stack.pop
end
def show
@stack
end
end
class Queue
def initialize
@queue = []
end
def enqueue(el)
@queue << el
end
def dequeue
@queue.shift
end
def show
@queue
end
en... | true |
6190f82631f0868fad258e947787cea74c19aaf9 | Ruby | J-Y/RubyQuiz | /ruby_quiz/quiz3_sols/solutions/martinus/geodesic.rb | UTF-8 | 1,263 | 3.796875 | 4 | [
"MIT"
] | permissive | # Creates a geodesic dome from primitives as described in ruby quiz #3
class GeoDesicDome
# Create a geodesic dome for a given primitive
def subsample(primitive, freq)
triangles = []
primitive[:faces].each do |face|
# get array of points from letters (like, "abc" -> Array with point a, point b, and point c).
... | true |
19a92e92f570a033e4675f598fc041f999245b38 | Ruby | jaysonia/Curling-Teams | /Curler_test.rb | UTF-8 | 519 | 3.1875 | 3 | [] | no_license | require 'test/unit'
require_relative 'Curler.rb'
class CurlerTest < Test::Unit::TestCase
def setup
@curler1 = Curler.new('Jason', 5, 10)
end
def test_to_s
assert_equal("Jason's proficiency is 5. Seeks partner with a proficiency >= 10", @curler1.to_s, 'incorrectly setup')
end
def test_out_of_ran... | true |
852f47224457aaf42d23462113eb84dcff14ad9a | Ruby | mattcameron/WDI-MELB-2_Homework | /Matt Cameron/classwork/5/warmups/scrabble.rb | UTF-8 | 478 | 4.03125 | 4 | [] | no_license | class Scrabble
def self.score(word)
@score = 0
word.upcase!.split("").each {|letter| check_letter(letter)}
puts @score
end
def self.check_letter(letter)
scores = {
1 => %w{A E I O U L N R S T},
2 => %w{D G},
3 => %w{B C M P},
4 => %w{F H V W Y},
5 => %w{K},
8 => %w{J W},
10 => %w{Q Z}
... | true |
fbd6bcfa79aa491f0264802576e552b04b40e348 | Ruby | 4rlm/dbc_onsite | /3.5_group-active-record-legislators/app/models/legislator.rb | UTF-8 | 2,166 | 2.71875 | 3 | [] | no_license | class Legislator < ApplicationRecord
# Remember to create a migration!
belongs_to :state
belongs_to :chamber
belongs_to :party
## Release 1: Display Legislators in Office
###################
## Definition of scope
scope :in_office_format, -> { joins(:chamber).select(:title).select(:first_name, :middl... | true |
0dfea248a7753660730f5be5f057a051cef4a05c | Ruby | llovich/tts_rubycode | /secret_santa.rb | UTF-8 | 352 | 2.9375 | 3 | [] | no_license | # is there a way to solve this one
# where you ask the user for a list of names and use space or comma
# to delimit each value / item of array
# then once you have the array, use it and a matching algorithm
# to create hash pairs
# easy way would be to create hash table w key and value set up
# then us loop to list ma... | true |
8fd751f758b612bf5a660af812fe16247105bbb0 | Ruby | ryhorton/chess | /rook.rb | UTF-8 | 237 | 2.703125 | 3 | [] | no_license | # coding: utf-8
require_relative 'sliding_pieces.rb'
class Rook < SlidingPieces
def to_s
self.color == :w ? "♖" : "♜"
end
def move_dirs
straight_moves
end
def inspect
type + " " + self.color.to_s
end
end
| true |
40720f5d297d3170e1ba58ae19ba71b95ba706bb | Ruby | ondras/ardulike | /scripts/game | UTF-8 | 1,527 | 3.078125 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'ostruct'
require 'json'
require './config'
require './helpers'
require './entities'
require './algorithms'
DEBUG = false
def debug(msg)
puts msg if DEBUG
end
player = Player.new(
Conditions.starting_toughness,
Conditions.starting_hp,
Conditions.starting_hp,
Conditions.startin... | true |
d218c9978bfe0c7b23cccf5ee50a7aa90ece9124 | Ruby | learn-academy-2021-delta/week-4-assessment-HackCoder77 | /code_challenges.rb | UTF-8 | 1,530 | 4.59375 | 5 | [] | no_license | # ASSESSMENT 4: Ruby Coding Practical Questions
# MINASWAN
# --------------------1) Create a method that takes in a number and determines if the number is even or odd. Use the test variables provided.
num1 = 7
# Expected output: '7 is odd'
if num1 % 2 === 1
p "#{num1} is odd"
end
num2 = 42
# Expected output: '42 is ... | true |
98ae0821cb44979efb6fb08b9caa9c7e19590003 | Ruby | leandrobento84/AutomacaoComCapybara-Ruby | /spec/teste.rb | UTF-8 | 73 | 3.203125 | 3 | [] | no_license | nomes = ['Adriana', 'Maria', 'Paula', 'Nubia', 'Paola']
puts nomes.sample | true |
bf3c9bac667854e59c6e4e275a2b1bf8c61b1ed1 | Ruby | Justafigurehead/CodeClanWork | /week_2/day_1/specs/bank_account_spec.rb | UTF-8 | 1,358 | 3.28125 | 3 | [] | no_license | # require files. require... = ('file/filename.rb')
require('minitest/autorun')
require('minitest/rg')
# require_relative('../bank_account.rb')
require_relative('../BankAccount.rb')
class TestBankAccount < MiniTest::Test
#They have used the BankAccount as a blueprint of themselves but they are two separate accounts, ... | true |
4a0bfb375f42c82727916d57593a804681d3606a | Ruby | abdulrahmannmohamed/W3D3 | /URLShortener/bin/cli | UTF-8 | 574 | 2.75 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'launchy'
puts "please enter email"
email = gets.chomp
user = User.find_by(email: email)
while true
puts "enter 0 to visit or 1 to create"
mode = gets.chomp.to_i
case mode
when 0
puts "enter shortened URL"
shortened_url = gets.chomp
short = ShortenedURL.find_by(short_url... | true |
99e938a952ab885510dbbd81d650da40f2e97ee6 | Ruby | fbell123/oystercard | /lib/oystercard.rb | UTF-8 | 1,056 | 3.46875 | 3 | [] | no_license | class OysterCard
MAX = 90
DEFAULT_BALANCE = 5
MINIMUM_BALANCE = 1
BASIC_FARE = 1
attr_reader :balance, :in_journey, :station, :journeys
def initialize(balance=DEFAULT_BALANCE, station = nil)
@balance = DEFAULT_BALANCE
@in_journey = false
@station = station
@journeys = []
@history = {}... | true |
2f2bda4e06b97f01234f271125df91783a9b1ee9 | Ruby | IjayAbby/Tic-Tac-Toe | /spec/player_spec.rb | UTF-8 | 498 | 2.75 | 3 | [
"MIT"
] | permissive | require_relative '../lib/player'
describe Player do
let(:p1) { Player.new('player1', 'X') }
let(:p2) { Player.new('player2', 'O') }
describe '#initialize' do
it 'returns player1 name' do
expect(p1.name).to eql('player1')
end
it 'returns player1 symbol' do
expect(p1.symbol).to eql('X')
... | true |
baedcbc3cf4c744a40786b07a1c421eef4613ded | Ruby | cristiancfe/Curso_Ruby | /Arquivos/E-gets.rb | UTF-8 | 225 | 3.421875 | 3 | [
"MIT"
] | permissive | print "Digite seu nome: "
name = gets.chomp
puts "Olá #{name}!"
print "Digite seu nome: "
name2 = gets.chomp.to_s
print "Digite sua idade: "
age = gets.chomp.to_i
print "Digite os ml do seu copo: "
ml = gets.chomp.to_f
| true |
82d5de1d2592f9fb6c3ddd24521ada11f7ddd5bb | Ruby | SumOfUs/Champaign | /app/lib/payment_processor/braintree/error_processing.rb | UTF-8 | 2,787 | 2.515625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module PaymentProcessor
module Braintree
class ErrorProcessing
# Collection of error codes, generated by braintree for invalid
# customer/credit card transaction data.
#
# See https://developers.braintreepayments.com/reference/general/validation-errors/all/ru... | true |
a58a1fb6dc7450c9bf4e01184d23f6f13f8c9e89 | Ruby | moneytree/by_star | /lib/by_star/by_fortnight.rb | UTF-8 | 1,998 | 3.015625 | 3 | [
"MIT"
] | permissive | module ByStar
module ByFortnight
# For reasoning why I use *args rather than variables here,
# please see the by_year method comments in lib/by_star/by_year.rb
def by_fortnight(*args)
options = args.extract_options!.symbolize_keys!
time = args.first
time ||= Time.local(options[:year], 1... | true |
e159b6c1967388e07d7af8a1b9d4972cf929184c | Ruby | burke/coursework | /winter2009/comp2150/a5/q2/lib/abstract.rb | UTF-8 | 1,625 | 3.15625 | 3 | [] | no_license | # abstract.rb
# Copyright 2009 Burke Libbey <burke@burkelibbey.org> under MIT license
#
# http://gist.github.com/91561
#
# Implements slightly Java-esque abstract classes in ruby,
# using painfully simple syntax.
#
# Usage:
#
# class Foo
# include Abstract
# abstract_methods :baz
# end
#
# class Bar < Foo
# ... | true |
ee02b1a877d053cd35bcaea9d639563859d5ece1 | Ruby | NYPL/lionactor | /lib/lionactor/location.rb | UTF-8 | 3,382 | 3.1875 | 3 | [
"MIT"
] | permissive | module Lionactor
# A single location. Either a circulating branch or research library.
#
# @!method id
# The location's id. This is an abbreviation, e.g., "SASB" for the Stephen A. # Schwarzman Building.
# @return [String]
#
# @!method name
# The location's name. E.g., "Stephen A. Schwarzman... | true |
0352f990f22d2ae87d9e56c91b99bc8e0192bda1 | Ruby | mikowitz/the_little_rubyist | /lib/ruby/chapter_02.rb | UTF-8 | 259 | 2.8125 | 3 | [] | no_license | def lat?(list)
case
when (null? list) then true
when (atom? (car list)) then (lat? (cdr list))
else false
end
end
def member?(atom, list)
case
when (null? list) then false
else ((eq? (car list), atom) or (member? atom, (cdr list)))
end
end
| true |
994574a75c0cf5d06a03533507ffb9abff5440b2 | Ruby | makevoid/bapp_models | /lib/bapp_models/eth_kv.rb | UTF-8 | 3,080 | 2.796875 | 3 | [
"MIT"
] | permissive | # exposes a key-value owner contract access by mimicking the redis API
require 'redis'
# use ethereum (key value / KVOwner contracts) as you use redis:
#
# R = Redis.new
# R.get "foo" #=> "bar"
# R["foo"] #=> "bar"
# R.set "foo", "baz" #=> true
# R["foo"] = "baz"
#
# ETH = EthKV.new
# ETH.get "foo... | true |
34c6b5aaf135c5e84ba6125ed66e8f503572fbf2 | Ruby | makramibrahim/Ruby | /case.rb | UTF-8 | 482 | 3.59375 | 4 | [] | no_license | #case expression
# when expression_1
# statements
# when expression_2
# statements
# when expression_3
# statements
#run the code here for student grades
print ("Enter your numric grade: ")
grade = Integer(gets)
case grade
when 95..100
letterGrade = "A"
when 90..94
letterGrade = "A-"
when 85..89
lett... | true |
02e45c3b134eb040ec4b0f163131610865012894 | Ruby | chris510/aA-Classwork | /W8D3/intro_js_project/bubblesort.rb | UTF-8 | 243 | 3.546875 | 4 | [] | no_license | def bubble_sort(arr)
sorted = false
until sorted
sorted = true
(0...arr.length - 1).each do |i|
if arr[i] >= arr[i + 1]
arr[i], arr[i + 1] = arr[i + 1], arr[i]
sorted = false
end
end
end
arr
end | true |
da1586bb79921ed17170257069a7947d7fe973cd | Ruby | thielen4/software-design | /app.rb | UTF-8 | 1,936 | 2.75 | 3 | [] | no_license | # Set up for the application and database. DO NOT CHANGE. ###################
require "sinatra" #
require "sinatra/reloader" if development? #
require "sequel" #
require ... | true |
56eb2b9505ae78bb580e81a416e62291333d2ba6 | Ruby | lbvf50mobile/til | /20211202_Thursday/20211202.rb | UTF-8 | 947 | 3.796875 | 4 | [] | no_license | # Leetcode: 328. Odd Even Linked List.
# https://leetcode.com/problems/odd-even-linked-list/
# = = = = = = =
# Accepted.
# Thanks God!
# = = = = = = =
# Runtime: 52 ms, faster than 90.32% of Ruby online submissions for Odd Even Linked List.
# Memory Usage: 210.4 MB, less than 54.84% of Ruby online submissions for Odd E... | true |
63c314fa8a7b51fe8cb868e9092a239eeebcfc9b | Ruby | btaitelb/RubyTraining | /completed_labs/lab01_basic_types/variables.rb | UTF-8 | 138 | 2.875 | 3 | [] | no_license | #!/usr/bin/env ruby
puts name = 'Ben'
puts age = years = 35
puts age + 1
puts age
puts age = age + 1
puts age
puts years
puts years += 1
| true |
47c2dac3426030e1cf370830b889979b40938eaa | Ruby | maximkoo/ruby-repo | /Ruby Stuff/Ruby Lecture/1.3 Variables/040.rb | UTF-8 | 138 | 3.15625 | 3 | [] | no_license | class C1
attr_reader "a"
attr_writer "a"
def initialize
@a=1
end;
end;
c=C1.new
puts c.a
c.a=2
puts c.a | true |
ea5cbb90b2b68ca40c6903d47b042235d80cf7bb | Ruby | alansparrow/learningruby | /GServer1.rb | UTF-8 | 567 | 2.859375 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'gserver'
class HelloServer < GServer
def serve(io)
io.puts "To stop this server, type 'shutdown'"
self.stop if io.gets =~ /shutdown/
end
end
if GServer.in_service?(1234)
puts "Can't create new server. Already running!"
else
puts "New server on 1234!"
server = HelloServe... | true |
7d70fd6b975935249e8b4976fbd8428dbf6745b3 | Ruby | theouternet/my-each-cb-000 | /my_each.rb | UTF-8 | 122 | 2.921875 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def my_each(words)
if block_given?
i = 0
while i < words.length
yield words[i]
i=i + 1
end
words
end
end
| true |
26d06b4329417b142227e2dbb222d63b2a1af014 | Ruby | artistwhocodes/HP_Quiz | /lib/HP_Quiz/gryffindor.rb | UTF-8 | 3,818 | 2.90625 | 3 | [
"MIT"
] | permissive |
class HPQuiz::Gryffindor
def gryffindor_banner
banner = HPQuiz::Scraper.new.banner("gryffindor")
box = TTY::Box.frame(width: TTY::Screen.width, height: TTY::Screen.height, border: :thick, align: :center, padding: 4,style: {
fg: :black, bg: :bright_red, border: { fg: :dark, bg: :bright_white } },
titl... | true |
223f5a36caa57c3bbebb6ea305af411bf5eccdb5 | Ruby | Trevor-Robinson/sweater_weather | /spec/poros/coordinates_spec.rb | UTF-8 | 321 | 2.546875 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe Coordinates do
it 'makes Coordinates object from data' do
coords = {:lat=>39.738453, :lng=>-104.984853}
result = Coordinates.new(coords)
expect(result.class).to eq(Coordinates)
expect(result.lat).to eq(39.738453)
expect(result.lon).to eq(-104.984853)
end
end... | true |
62fd3e3ae3ae94769bc58a1f3cf4e40735127209 | Ruby | fdevillalobos/challenges | /HackerRank/stairs.rb | UTF-8 | 259 | 3.5625 | 4 | [] | no_license | # Creates staircase with # signs from input
def step(length, step_num)
str = ""
str << " "*(length - step_num)
str << "#"*(length - str.size)
return str
end
stair_len = gets.chomp.to_i
(0...stair_len).each do |i|
puts step(stair_len, i+1)
end
| true |
8c8d9ebf44e4642511e51cf271f3f0a26f635aa9 | Ruby | yuuyuu244/ruby-sample | /sample2.rb | UTF-8 | 87 | 3.078125 | 3 | [] | no_license | array = ["fuck", "awesome", "shit", "awesome"]
array.each{|word|
print(word, "\n")
}
| true |
a7d11a7850a47c65fc815f5f665340b384e03f5a | Ruby | adoan91/essential-ruby | /iterators.rb | UTF-8 | 436 | 3.703125 | 4 | [] | no_license | result = []
first_names = ["Hamburglar", "Grimace", "Ronald"]
last_name = "McDonald"
first_names.each do |n|
result << n + " " + last_name
end
#
["fat", "bat", "rat"].each do |word|
puts word + "-land"
#
counter = 0
array = ["fat", "bat", "rat"]
while counter < array.length
puts array[counter] + "-land"
coun... | true |
d68428ac2e3c5d21b6a301fe7ca3861aa5ae3f6c | Ruby | thepaulduca/phase-0-tracks | /ruby/list/to_do_list.rb | UTF-8 | 291 | 3.234375 | 3 | [] | no_license | class To_do_list
attr_reader :list
def initialize(list)
@list = list
end
def get_items
@list
end
def add_item(item_to_add)
@list << item_to_add
end
def delete_item(item_to_delete)
@list.delete(item_to_delete)
end
def get_item(item_index)
@list[item_index]
end
end | true |
9755ff50455585db8bc2430bf96990fd2ec45935 | Ruby | gsuper/ZombieTwitter | /lib/zombie.rb | UTF-8 | 153 | 3.4375 | 3 | [] | no_license | class Zombie
attr_accessor :name, :brains, :hungry
def initialize
@name = 'Jim'
@brains = 0
@hungry = true
end
def hungry?
@hungry
end
end | true |
68d9812791e3788ffc15560fb30217260730582e | Ruby | googleapis/google-cloud-ruby | /google-cloud-bigtable/lib/google/cloud/bigtable/project.rb | UTF-8 | 22,130 | 2.515625 | 3 | [
"Apache-2.0"
] | permissive | # frozen_string_literal: true
# Copyright 2018 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicabl... | true |
741e178559e7134c5c7b59cce35ce520554c0c7f | Ruby | nikolas/openvault | /lib/openvault.rb | UTF-8 | 748 | 2.515625 | 3 | [] | no_license | require 'nokogiri'
module Openvault
class << self
attr_accessor :ng_parse_options
def ng_parse_options= val
raise "ng_parse_options expects an integer, #{val.class} given" unless val.kind_of? Integer
@ng_parse_options = val
end
##
# Convenience method for using self.ng_parse_options... | true |
7d3cba8e704e56831c3dd0a8950907631e19a58c | Ruby | bry4n/sleep | /spec/sleep_spec.rb | UTF-8 | 1,014 | 2.5625 | 3 | [
"MIT"
] | permissive | require File.expand_path("../spec_helper", __FILE__)
describe Sleep do
before do
@sleep = Sleep.new
end
it "settings" do
assert_equal @sleep.delay, false
assert_equal @sleep.sleep_delay, 14
assert_equal @sleep.sleep_cycle, 90
end
it "#now" do
assert_kind_of Array, @sleep.now
assert... | true |
17f7944aa73cef43b4a6c5361f059d122a76ad81 | Ruby | IceColdCoder/mspire | /script/mzml_translator.rb | UTF-8 | 1,121 | 2.609375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #!/usr/bin/env ruby
require 'mspire/mzml'
if ARGV.size == 0
puts "usage: #{File.basename(__FILE__)} <file>.mzML ..."
puts "output: <file>.baselined.mzML ..."
puts "NOT SURE THIS IS WORKING JUST YET!!"
exit
end
ARGV.each do |file|
base = file.chomp(File.extname(file))
outfile = base + ".baselined.mzML"
... | true |
9447736d6f669994bec1015ad91d9d56c3bec864 | Ruby | nikila-saravanan/the-bachelor-todo-web-0715-public | /lib/bachelor.rb | UTF-8 | 1,521 | 3.65625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
def get_first_name_of_season_winner(data, season)
# code here
season_info = data[season]
#binding.pry
winner = season_info.collect do |contestant|
contestant["name"] if contestant["status"] == "Winner"
end
winner = winner.compact
name = winner[0].split(" ")
name[0]
end
def get_conte... | true |
200f76fb230037f17e811a849a5f77263a6a7cfc | Ruby | FretlessUL/mutant_school_api_model | /lib/mutant_school_api_model/mutant.rb | UTF-8 | 2,739 | 2.8125 | 3 | [
"MIT"
] | permissive | module MutantSchoolAPIModel
class Mutant
def self.base_url
"https://mutant-school.herokuapp.com/api/v1/mutants"
end
def self.attribute_names
[
:id,
:mutant_name,
:real_name,
:power,
:eligibility_begins_at,
:eligibility_ends_at,
:may_adv... | true |
19e5b63f9db3850234457874f5c18e34f9a68b36 | Ruby | marcwright/WDI_ATL_1_Instructors | /REPO - DC - Students/w01/d02/Brett/air_conditioning.rb | UTF-8 | 523 | 3.6875 | 4 | [] | no_license | puts "What's the current temperature?"
current_temp = gets.chomp
puts "Is the AC working [y/n]?"
working = gets.chomp.downcase
puts "What temperature would you like it to be?"
desired_temp = gets.chomp
if working == "y" && current_temp > desired_temp
puts "Turn on the AC please"
elsif working == "n" && current_tem... | true |
e7d9a2b13f5948e32b62ab31286e19a4c9f115e4 | Ruby | jasl/activeentity | /lib/active_entity/core.rb | UTF-8 | 11,326 | 2.515625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require "active_support/core_ext/hash/indifferent_access"
require "active_support/core_ext/string/filters"
require "active_support/parameter_filter"
require "concurrent/map"
module ActiveEntity
module Core
extend ActiveSupport::Concern
included do
##
# :singleton-m... | true |
f686cc3a8b4adfb5dd25f952a2a9ee13c2818ae2 | Ruby | sinharahul/solr | /Derivative.rb | UTF-8 | 1,100 | 2.703125 | 3 | [] | no_license |
# Derivative.rb
#
#
# Created by RAHUL SINHA on 1/9/16.
#
class UnderLying
attr_accessor :name,:buyprice,:sellprice
def profit
@sellprice-@buyprice
end
end
class Market
end
class OTC < Market
end
class ExchangeTraded < Market
end
=begin
A Derivative is a financial instrument that derives... | true |
108b1cb1ac567c40624e395c025db089ebd4c831 | Ruby | tobywinter/oystercard-1 | /spec/journey_spec.rb | UTF-8 | 1,218 | 2.890625 | 3 | [] | no_license | require 'journey'
require 'oystercard'
describe Journey do
subject(:journey) {described_class.new}
let(:penalty_charge) {double :penalty_charge}
station1 = Station.new("Bank", 1)
station2 = Station.new("Kingston", 6)
it 'initializes with @penalty_charge' do
expect(journey).to respond_to :penalty_charge
... | true |
fb1f13f6d3238ef82ae25c3f099dd12172b1f9b2 | Ruby | neilbilly/sh24_exercise_1 | /app/models/github_account.rb | UTF-8 | 826 | 2.75 | 3 | [] | no_license | require 'open-uri'
class GithubAccount
def initialize(account)
begin
@user_info = Octokit.user account
rescue
@user_info
end
end
def user_info
@user_info
end
def fetch_user_repos
if user_info.present?
if self.user_info.repos_url.present?
JSON.load(open(self.us... | true |
86c9d2997c4367d6382f12412f05ed777f53b612 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/hexadecimal/2f43bc5f30494459b612f202fd3b9b5d.rb | UTF-8 | 495 | 3.953125 | 4 | [] | no_license | class Hexadecimal
HEX = ["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"]
def initialize(hexa)
@hexa = hexa
end
def to_decimal
return 0 unless @hexa.chars.all?{|c| HEX.include?(c.upcase)}
@hexa.chars.each_with_index.inject(0) do |decimal, (char, i)|
decimal += base_number(c... | true |
f5d58106c4ce15fbeac9858876e174686d8a5527 | Ruby | chantal66/Ruby_Challenges | /max_char/longest_sentence.rb | UTF-8 | 281 | 3.078125 | 3 | [] | no_license | def longest_sentence(sentence)
sentences = sentence.split(".")
sentences.map do |sentence|
sentence.split(' ').count
end.max
end
p longest_sentence("We test coders. Give us a try?") # should return 4
p longest_sentence("Forget CVs..Save time . x x") # should return 2
| true |
07aeff241187d3525ba3ae3e3b7a312e81feca7b | Ruby | khemraj-chauhan/Movie-Backend-problem | /app/models/seat.rb | UTF-8 | 225 | 2.703125 | 3 | [] | no_license | class Seat
attr_accessor :seat_number, :status
attr_accessor :show, :category
def initialize(seat_number:, status:, category:)
@seat_number = seat_number
@status = status
self.category = category
end
end
| true |
bca0ba7a35a66807e294386086a72aab8d401b31 | Ruby | yileye/commit_hookr | /test/test_message.rb | UTF-8 | 1,413 | 2.609375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require 'helper'
class TestCommitHookrMessage < Test::Unit::TestCase
def test_load_helpers
CommitHookr.helpers do
def my_helper
"bar"
end
end
message = hookr_message
assert message.respond_to?("my_helper")
assert "bar", message.my_helper
end
def test_load_original_co... | true |
dec00be262e36ddf60129fa9a9b0fe6a255b6154 | Ruby | CrossRef/tinypub | /vendor/bundle/ruby/1.9.1/gems/dm-validations-1.2.0/lib/dm-validations/validators/within_validator.rb | UTF-8 | 2,410 | 2.890625 | 3 | [
"MIT"
] | permissive | module DataMapper
module Validations
# @author Guy van den Berg
# @since 0.9
class WithinValidator < GenericValidator
def initialize(field_name, options={})
super
@options[:set] = [] unless @options.has_key?(:set)
end
def call(target)
value = target.validation... | true |
217e50f545a701e4f568ddce01d4a9b9cc4bf606 | Ruby | CamR20/cams-blog | /app/controllers/articles_controller.rb | UTF-8 | 2,283 | 2.84375 | 3 | [] | no_license | class ArticlesController < ApplicationController
# performs this action before anything else on this page where set article is used
# write this code once the controller has been coded and you can see what has the same code
before_action :set_article, only: [:show, :edit, :update, :destroy]
def show
# uses t... | true |
16c001ef153efce51227a97763606df4f9a94578 | Ruby | jnv/projektomega | /spec/support/capybara_matchers.rb | UTF-8 | 1,557 | 2.6875 | 3 | [] | no_license | module Capybara
module RSpecMatchers
class HaveFieldWithAttribute
def initialize(name, attribute=nil, should = true)
@name = name
@attribute = attribute
@should_have_attribute = should
end
def attribute_exists?(field, attribute)
val = field[attribute]
!... | true |
531e9413ce840d60ffe6bc6c8ebdf54ad527959d | Ruby | llb1026/alggago-rb | /ai_daGgaGo2.rb | UTF-8 | 13,025 | 2.859375 | 3 | [] | no_license | ################################################################################
# Encoding: UTF-8
require 'gosu'
require 'chipmunk'
require 'singleton'
require 'slave'
require "xmlrpc/client"
require 'childprocess'
require 'rbconfig'
########################################################################... | true |
b3cf907bfbb63125c09cd13b35560dca05d7eb04 | Ruby | roomorama/concierge | /lib/concierge/suppliers/poplidays/commands/lodging_fetcher.rb | UTF-8 | 1,235 | 2.765625 | 3 | [] | no_license | module Poplidays
module Commands
# +Poplidays::Commands::LodgingFetcher+
#
# This class is responsible for wrapping the logic related to getting
# lodging details from Poplidays, parsing the response,
# and building the +Result+ object with the raw data returned from their API.
#
# Usage
... | true |
3dbf743dcb53907c35182c202ceed6ad93eaa0e9 | Ruby | JoePeterson51/black_thursday | /spec/transaction_repository_spec.rb | UTF-8 | 9,961 | 2.5625 | 3 | [] | no_license | require 'simplecov'
SimpleCov.start
require './lib/sales_engine'
require './lib/transaction_repository'
require './lib/transaction'
require 'bigdecimal'
RSpec.describe TransactionRepository do
describe '#initialize' do
it 'exists' do
mock_sales_engine = instance_double('SalesEngine')
tr = Transaction... | true |
738e91e13e89b3f6311eae5d057786bf437dca2f | Ruby | gjvera/Project-Euler | /ruby/problems1-10/problem8/problem8.rb | UTF-8 | 434 | 3.03125 | 3 | [] | no_license | data = ''
f = File.open("problem8.txt", "r")
f.each_line do |line|
data += line
end
nums = data.chars
nums = nums.map(&:to_i);
max = 13;
min = 0;
orig_min = 0;
max_prod = 0;
while max < nums.length
min = orig_min
temp_prod = 1;
while min != max
temp_prod *= nums[min]
min+=1
end
... | true |
53926858b3a280b6deaf3a7b952fcab85bd9c075 | Ruby | ralphreid/WDI_LDN_3_Work | /ralphreid/w2d3/classwork/sinatra_quiz_lab/solution/quiz.rb | UTF-8 | 1,717 | 3.046875 | 3 | [] | no_license | require 'pry'
require 'sinatra'
require 'sinatra/contrib/all'
enable :sessions
set :questions, {
1 => ["Ruby can use short easy to read syntax a.should > 7?", true),
2 => ["Ruby can use use standardised libraries", true],
3 => ["You can call blocks from within method using yield", true]
4 => ["A two-dot range... | true |
dd46d34397bc502e9e49b98c035b8c01bc096afb | Ruby | patrickjr/rails | /box/app/models/box_user.rb | UTF-8 | 2,785 | 2.8125 | 3 | [] | no_license | require 'src/BoxApi/Request'
require 'src/BoxApi/Response'
require 'src/BoxApi/File'
require 'src/BoxApi/BoxApi'
require 'src/BoxApi/OAuth'
class BoxUser < ActiveRecord::Base
validates :client_id, :client_secret, :presence => true
attr_accessor :file, :file_names
def self.get_from(session)
validate_box_user... | true |
386b7a74e0f1168e00ca1e07edd5d7a79f5f374a | Ruby | Nasrin-Rahimi/ruby-music-library-cli-onl01-seng-pt-070620 | /lib/song.rb | UTF-8 | 1,248 | 3 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class Song
extend Concerns::Findable
attr_accessor :name
attr_reader :artist, :genre
@@all = []
def initialize(name,artist = nil ,genre = nil)
@name = name
self.artist=(artist) if artist
self.genre=(genre) if genre
end
def self.all
@@all
end
def save... | true |
c6e1a80f4b565160faa7030e1ac856b00b69a235 | Ruby | victoralvess/learn-ruby-the-hard-way | /ex3.rb | UTF-8 | 626 | 4.5 | 4 | [
"MIT"
] | permissive | # prints a string
puts "I will now count my chickens:"
# prints a string using interpolation
puts "Hens #{25.0 + 30 / 6}"
puts "Roosters #{100.0 - 25.0 * 3.0 % 4.0}"
# prints another string
puts "Now I will count the eggs:"
# prints the result of this equation
puts 3.0 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6
# prints a boolean... | true |
c9cf6c31bb3faefcc711ef4f4803f089d8758556 | Ruby | krdiamond/square_array-ruby-apply-000 | /square_array.rb | UTF-8 | 128 | 3.5 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def square_array(array)
nums_squared = []
array.each do |num|
nums_squared << num * num
end
return nums_squared
end
| true |
ceda5f587a47b6c424b4d33a29be6d4e1d0a877b | Ruby | joshsarna/practice_problems | /actualize_practice_problems/postcourse_workthrough/q3-3.rb | UTF-8 | 795 | 3.953125 | 4 | [] | no_license | =begin
Use the `select` method combined with the `map` method to convert the array of hashes
movies = [
{id: 1, title: "Die Hard", rating: 4.0},
{id: 2, title: "Bad Boys", rating: 5.0},
{id: 3, title: "The Chamber", rating: 3.0},
{id: 4, title: "Fracture", rating: 2.0}
]
into an array of hashes that only con... | true |
3bbda4fd54c281d0b36a55936aeacf1801096a87 | Ruby | eadz/linode_api | /api.rb | UTF-8 | 2,108 | 2.671875 | 3 | [] | no_license | #!/usr/bin/env ruby
#
#A Ruby library to perform low-level Linode API functions.
#
#Copyright (c) 2008 David S Bell <dave@geordish.org>
#
#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
... | true |
66c4861ae5c14a93aea95ed51ec159d0925f096e | Ruby | jackclarkeparker/RB120 | /exercises/easy_1/fix_the_program-flight_data.rb | UTF-8 | 793 | 3.296875 | 3 | [] | no_license | =begin
Consider the following class definition:
=end
class Flight
attr_accessor :database_handle
def initialize(flight_number)
@database_handle = Database.init
@flight_number = flight_number
end
end
=begin
There is nothing technically incorrect about this class,
but the definition may lead to proble... | true |
6f8827ce1e073003a8d539db1dff9ff085d0db7a | Ruby | marina101/advent-of-code-2017 | /day7/part1.rb | UTF-8 | 740 | 3.046875 | 3 | [] | no_license | def process(test = false)
input = test ? test_string : File.read('input.txt')
lines = input.split("\n")
parent_nodes = []
child_nodes = []
lines.each do |string|
line = string.split(" ")
next unless line[2]
parent_nodes << line[0]
line[3..-1].each do |node|
node = node.gsub(",", "")
... | true |
3bd22d9fd33069b231872f253f7a92b81e98da9c | Ruby | amacdougall/dungeon_fight | /interpreter.rb | UTF-8 | 2,177 | 3.8125 | 4 | [] | no_license | # Classes which map user input to commands.
# Base class for reading and interpreting user input. Call next_command() to
# prompt for user input and convert it to a game logic method call.
# Interpreter classes should never have to do game logic, and game logic
# should never have to interpret strings.
#
# The comman... | true |
f5835fb2e2396b8788efbe9934295713d0250218 | Ruby | JazzyMussels/ruby-objects-has-many-lab-nyc-clarke-web-082619 | /lib/author.rb | UTF-8 | 372 | 3.015625 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class Author
attr_accessor :name, :post
def initialize(name)
@name = name
end
def posts
Post.all.select{|posting| posting.author == self}
end
def add_post(posting)
posting.author = self
end
def add_post_by_title(new_post)
posting = Post.new(new_post)
posting.author = self
end... | true |
163ecd9d74ccad1908c1494fd699fdeb692dd0f9 | Ruby | greenjoshua/introduction_to_programming | /more_stuff/exercise_1.rb | UTF-8 | 298 | 3.375 | 3 | [] | no_license | # method that checks for a pattern "lab" in each word
def check_pattern(word)
if word =~ /lab/
puts word
else
puts "Does not match."
end
end
check_pattern("laboratory")
check_pattern("experiment")
check_pattern("Pans Labyrinth")
check_pattern("elaborate")
check_pattern("polar bear") | true |
eeb657bebb00b2beef39b7cbd0260df0d1729b37 | Ruby | influitive/seedomatic | /lib/seedomatic/seeder.rb | UTF-8 | 2,276 | 2.609375 | 3 | [] | no_license | module SeedOMatic
class Seeder
attr_accessor :model_name, :items, :match_on, :seed_mode
def initialize(data)
@model_name = data[:model_name]
@items = data[:items]
@match_on = [*data[:match_on]]
@seed_mode = data[:seed_mode] || "always"
end
def import
new_records = 0
... | true |
111b923c906b55ea06f87735814564094f2a0674 | Ruby | robertfall/twitter-example | /src/follower_map.rb | UTF-8 | 731 | 2.859375 | 3 | [] | no_license | require 'set'
require_relative 'follow'
class FollowerMap
def self.from_list(follows)
new.tap { |map| map.add_follows(follows) }
end
def initialize
@follows = {}
@users = SortedSet.new
end
def add_follow(follow)
@users.add(follow.broadcaster)
@users.add(follow.subscriber)
followers... | true |
60609f456ad96c3b6b0f447f90b55b4549f2d419 | Ruby | nhessler/converserver | /lib/converserver06.rb | UTF-8 | 1,175 | 2.8125 | 3 | [] | no_license | require 'sinatra/base'
require 'minitest/autorun'
require 'minitest/pride'
require 'minitest/spec'
require 'rack/test'
class Converserver < Sinatra::Base
get '/hello/:name' do
redirect to("/say/Hello?name=#{params[:name]}")
end
get '/goodbye/:name' do
redirect to("/say/Goodbye?name=#{params[:name]}")
... | true |
1fc760c4201e7548ce8cfa77b9b81001fb735437 | Ruby | hmarr/backup | /lib/backup/logger.rb | UTF-8 | 2,884 | 3.125 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
module Backup
class Logger
##
# Outputs a messages to the console and writes it to the backup.log
def self.message(string)
puts loggify(:message, string, :green) unless quiet?
to_file loggify(:message, string)
end
##
# Outputs an error to the console and wri... | true |
ccf6e2ac22943f4866e47de154c7066a4143786a | Ruby | prototype2012/codebreaker_gem | /spec/codebreaker/game_process_spec.rb | UTF-8 | 4,084 | 2.796875 | 3 | [
"MIT"
] | permissive | RSpec.describe Codebreaker::GameProcess do
context 'when works correctly' do
subject(:game_process) { described_class.new(config.clone) }
let(:secret_code) { [1, 2, 3, 3] }
let(:wrong_code) { [5, 4, 3, 1] }
let(:config) do
{ player_name: 'boris',
difficulty: :easy,
secret_code: ... | true |
16dd7c491c14b609247a90991269735736b0e14b | Ruby | brilliantfantastic/laziness | /spec/support/slack_stub_factory.rb | UTF-8 | 491 | 2.515625 | 3 | [
"MIT"
] | permissive | module SlackStubFactory
def stub_slack_request(method, path, fixtures)
fixtures = [fixtures].flatten
full_path = "https://slack.com/api/#{path}"
stub = stub_request(method, full_path)
begin
fixture = fixtures.shift
stub.to_return(status: 200, body: slack_json_fixture(fixture))
end wh... | true |
439c79326e01fcad88d06cb973dfc97627038f7a | Ruby | AnishSid/SCRIPTS | /Ruby/Ruby_study/string_search_sentence.rb | UTF-8 | 200 | 3.28125 | 3 | [] | no_license |
puts "enter the sentence:"
array = gets.chomp
puts "enter the string to search:"
query = gets.chomp
def findWord(query, array)
a = array.grep(/#{query}/i)
a.empty? ? ["Empty"] : a
end
| true |
31dd61aaeeed94dd2284e942e21b9ef54cceb857 | Ruby | mhern1415/ruby-objects-has-many-through-lab-online-web-sp-000 | /lib/doctor.rb | UTF-8 | 432 | 3.203125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Doctor
attr_accessor :name, :appointment, :patient
@@all = []
def initialize(name)
@name = name
@@all << self
end
def self.all
@@all
end
def new_appointment(patient, date)
Appointment.new(patient, self, date)
end
def appointments
Appointment.all.select do |appointment|
appointment.doctor =... | true |
9a1b0bbe0aa2193de18ccd82a9d7e7c0b7c5bac3 | Ruby | lada000/thinknetica_ruby_course | /lesson_7/lib/passenger_wagon.rb | UTF-8 | 254 | 2.859375 | 3 | [] | no_license | class PassengerWagon < Wagon
attr_reader :total
attr_accessor :filled
def initialize(total_seat_number = 30)
@type = :passenger
super(total_seat_number)
end
def take_a_place(message = 'No free places')
super(1, message)
end
end
| true |
09c55d0432b2a1a448cc387411111f237f860727 | Ruby | dealencarmarcelo/fibonacci_ruby | /for_fibonacci.rb | UTF-8 | 298 | 3.46875 | 3 | [] | no_license | def fibonacci(value)
for i in 0..value do
if i <= 1
final_value = i
else
final_value = @first + @second
@first = @second
@second = final_value
end
end
return final_value
end
@first = 0
@second = 1
p fibonacci(7)
| true |
ec05b82fe6da185da0f28ac1e212a0c5571c8e7e | Ruby | EldrickWT/My-Crazy-Dwarf-Fortress-Mods | /dfhack.40.06/scripts/devel/spawn-unit-helper.rb | UTF-8 | 807 | 2.53125 | 3 | [] | no_license | # setup stuff to allow arena creature spawn after a mode change
df.world.arena_spawn.race.clear
df.world.arena_spawn.caste.clear
df.world.raws.creatures.all.length.times { |r_idx|
df.world.raws.creatures.all[r_idx].caste.length.times { |c_idx|
df.world.arena_spawn.race << r_idx
df.world.arena_spaw... | true |
ea866c5372ca28b7935754472bf74eb4b6ca9746 | Ruby | katsuya245126/App-Academy-Projects | /Finished/Ruby/Reference/Memory Puzzle/Revised/card.rb | UTF-8 | 788 | 4.0625 | 4 | [] | no_license | class Card
# values for cards
# using a constant here since I don't need to make an instance of card to use this variable
VALUES = ("A".."Z").to_a
# class method to return shuffled pairs of values selected randomly in an array
def self.shuffled_pairs(num_pair)
# I get a warning if I don't assign VALUES t... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.