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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
c4f4742095f263b7853c594112a94818b9c53c86 | Ruby | DimaSavitsky/story_roller | /app/controllers/concerns/anti_magic_shield.rb | UTF-8 | 358 | 2.671875 | 3 | [] | no_license | module AntiMagicShield
refine Class do
def define_method(*)
warn 'You are not allowed to define methods on any Class.'
end
end
refine Method do
def call(*)
warn 'You are calling some method.'
super
end
end
refine Game do
def method_added(method_name)
warn 'Aha, y... | true |
b6f0d904c80533e1e8270c96fc1b1b1217b121a9 | Ruby | jhh/mg2en | /spec/ingredient_spec.rb | UTF-8 | 1,052 | 2.65625 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe Mg2en::Ingredient do
let(:parser) do
Mg2en::Parser.new(File.dirname(__FILE__) + '/fixtures/1.mgourmet3')
end
it 'parses ingredients' do
i = parser.recipes[0].ingredients
expect(i.size).to eql(2)
expect(i[0].measurement).to eql('clove')
expect(i[0].quantity).to... | true |
033d26ea236dd5d3bc9b2803209653c79e62f9dd | Ruby | phddoom/scripts | /librmpd.rb | UTF-8 | 30,283 | 3.28125 | 3 | [] | no_license | #
#== librmpd.rb
#
# librmpd.rb is another Ruby MPD Library with a goal of greater
# ease of use, more functionality, and thread safety
#
# Author:: Andrew Rader (bitwise_mcgee AT yahoo.com | http://nymb.us)
# Copyright:: Copyright (c) 2006 Andrew Rader
# License:: Distributed under the GNU GPL v2 (See COPYING file)
#
... | true |
8b5d77d8784f381dde055ecde5c839934d2941de | Ruby | Awce/cursoruby | /cap2/condicionalif.rb | UTF-8 | 257 | 3.796875 | 4 | [] | no_license | #Programa que indica la mayoría de edad con IF.
puts "Por favor escribe tu edad:"
STDOUT.flush
edad = gets.chomp.to_i
if edad >= 18
puts "Tu edad es #{edad} años, ya eres Adulto."
elsif edad <= 18
puts "Tu edad es #{edad} años, eres un Niño."
end
| true |
5152a53b4fc95a7f58352322ca284a42a9446c67 | Ruby | JohnDanNinjaMan/exercism_ruby | /roman-numerals/roman_numerals.rb | UTF-8 | 1,067 | 3.765625 | 4 | [] | no_license | module BookKeeping
VERSION = 2
end
Roman_num = {"M"=>1000, "CM"=>900, "D"=>500, "CD"=>400, "C"=>100, "XC"=>90, "L"=>50, "XL"=>40, "X"=>10, "IX"=>9, "V"=>5, "IV"=>4, "I"=>1}
#puts Roman_num.key(1000) # Gives key (i.e. letter) from value
#puts Roman_num.values[-1] # Gives value from element number
#puts Roman_num.key... | true |
ba7ce4ca4ffaf32add0d1cc952370f9260ec6b1e | Ruby | yoikosugi/cherry | /section7/780.rb | UTF-8 | 349 | 2.9375 | 3 | [] | no_license | # class Product
# DEFAULT_PRICE = 0
# end
# p Product::DEFAULT_PRICE
# class Product
# DEFAULT_PRICE = 0
# # 定数をprivateにする
# private_constant :DEFAULT_PRICE
# end
# p Product::DEFAULT_PRICE
class Product
def foo
# メソッドの内部で定数を作成すると構文エラーになる
DEFAULT_PRICE = 0
end
end
| true |
e5dda030ee26d364ca093bbfad38e0bea469664d | Ruby | zenm/launch-school-LS100-intro | /ruby_basics/project07_methods/ex02_print_me.rb | UTF-8 | 68 | 2.90625 | 3 | [] | no_license | def print_me
return "I'm printing within a method."
end
print_me | true |
8546491fdfbeb95b94cbe05174ede1456f5268a1 | Ruby | dpmontooth/rb101 | /small_problems/easy_2/how_old_is_teddy.rb | UTF-8 | 376 | 4.46875 | 4 | [] | no_license | # build a program that randomly generates and prints Teddy's age.
# To get the age, you should generate a random number between 20 and 200
# input: none
# output: string stating teddy's age
# algorithm:
# assign random number between 20 and 200 to age variable
# interpolate age variable to string stating teddy's age
... | true |
53ea9a3776eb6bbfd487b83357fd3bb3b044f72d | Ruby | awaresec/hids-ui | /app/models/user.rb | UTF-8 | 341 | 2.578125 | 3 | [] | no_license | class User < ActiveRecord::Base
def password=(password)
self.password_salt = [Array.new(10) { rand(256).chr }.join].pack("m").chomp
self.password_hash = Digest::SHA1.hexdigest(password + password_salt)
end
def password_is?(password)
self.password_hash == Digest::SHA1.hexdigest(password + passwor... | true |
8e6f87cab2a25e7b7a4fb6719744e0af3bbc7786 | Ruby | vienbk91/Ruby | /Basic/bien.rb | UTF-8 | 1,308 | 3.84375 | 4 | [] | no_license | # PI: Đây là biến toàn cục và được đăt ở ngoài lớp
# Có thể gọi biến toàn cục ở bất cứ nơi nào
# Cách viết bắt đầu bằng dấu $
# Chú ý trong Ruby thì phân biệt chữ hoa chữ thường nên $pi và $PI là khác nhau
$PI = 3.14 # global variables
class Nguoi
# GIOI_TINH: Hằng số, được viết hoa toàn bộ
# Giá trị chỉ được gán ... | true |
0bab50b99c133c6540f6f428176ca9ee38d5ae8c | Ruby | Watsaiye/first_exos_ruby_3IW1 | /table.rb | UTF-8 | 315 | 3.671875 | 4 | [] | no_license | array = []
i = 0
sum = 0
while i < 5
puts "Entrez le nombre numéro " + i.to_s
array.push(gets.chomp.to_i)
sum = sum + array[i]
i = i + 1
end
moyenne = sum / 5
indiceMax = array.index(array.max)
puts "l'indice du plus grand nombre est " + indiceMax.to_s
puts "la moyenne est de " + moyenne.to_s
| true |
3fb4a5d6ba5f55449c0714de9a23ee05e75f4251 | Ruby | buzztaiki/ec2region | /lib/ec2region/regions.rb | UTF-8 | 711 | 3 | 3 | [
"MIT"
] | permissive | require 'ipaddr'
module EC2Region
# The representation of regions and ips
class Regions
# @param [Hash{String => Array<String>}] regions_hash
def initialize(regions_hash)
@regions = regions_hash
end
# @return [Array<String>] name of regions
def names
@regions.keys
end
# @p... | true |
6bc6b0848168b543365a243768df3e3f1ab65830 | Ruby | karayusuf/tictactoe | /spec/winning_space_spec.rb | UTF-8 | 4,402 | 2.921875 | 3 | [] | no_license | require 'rspec'
require File.dirname(__FILE__) + '/../lib/winning_space'
module TicTacToe
describe WinningSpace do
context "when there is no winning space" do
let(:board) do
Board.new([ ["_", "_", "_"],
["_", "_", "_"],
["_", "_", "_"] ])
end
it ... | true |
142b73ed08cfc939bf2d91a8ec894f464f6569f3 | Ruby | zanker/sc2ranks | /app/models/character_achievement.rb | UTF-8 | 989 | 2.5625 | 3 | [] | no_license | class CharacterAchievement < ActiveRecord::Base
has_one :data, :class_name => "Achievement", :foreign_key => :achievement_id, :primary_key => :achievement_id
def world_rank
#return self.cached_world_rank || (Rails.cache.fetch("/achieve/rank/#{self.earned_on.to_i}/#{self.achievement_id}", :raw => true, :expires_in... | true |
56bf0118ac56cf37c70162587d7aa1e2019d7329 | Ruby | postageapp/mua | /spec/support/mock_stream.rb | UTF-8 | 1,305 | 2.609375 | 3 | [
"MIT"
] | permissive | require 'async/io/stream'
require 'socket'
require 'fcntl'
module MockStream
MODE_DEFAULT = 'r'.freeze
module SendReceiveHelper
def puts(*args)
super(*args, separator: "\r\n")
end
def gets
super("\r\n", chomp: true)
end
end
def self.new(string = '', mode = nil)
Async::IO::Str... | true |
540c5b18a9f900028db1140b6a9a18cbb824fae3 | Ruby | markjeee/coding-bible | /Rakefile | UTF-8 | 624 | 2.578125 | 3 | [] | no_license | require 'rake'
require 'pp'
desc 'Update our copy of the style guide from the original at github:bbatsov'
task :update_ruby_style_guide do
rsg_source = 'https://raw.githubusercontent.com/bbatsov/ruby-style-guide/master/README.md'
rsg_output = 'ruby-style-guide.md'
prepend_layout = <<PPLAYOUT
---
layout: page
--... | true |
198994a999a1ef49ee055c45000ce96902e8f7d9 | Ruby | sagmor/nid | /spec/nid/object_spec.rb | UTF-8 | 2,450 | 2.75 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe NID do
describe '#initialize' do
it 'generates a random NID for the given namespace' do
nid = NID.new(:tests)
expect(nid).not_to be_nil
expect(nid.namespace).to be(:tests)
end
it 'accepts a Time object' do
time = Time.now
nid1 = NID.new(:test... | true |
957fe635ccb6b611017c8cc356eddfa8a14ab661 | Ruby | 4rlm/dbc_onsite | /3.4_ar-polymorphic-associations/app/models/student.rb | UTF-8 | 478 | 2.875 | 3 | [] | no_license | class Student < Person
# Remember to create a migration!
# belongs_to :teacher
has_many :student_teachers, :foreign_key => :student_id
has_many :teachers, :through => :student_teachers
validates :given_name, :surname, :phone, :birthday, { presence: true }
# Getter
def full_name
[given_name, surname]... | true |
f68d4ca2ea881d7bfe0b7966784f5e2bf3429b18 | Ruby | bryanduxbury/cellular_chronometer | /rb/spec/pt_spec.rb | UTF-8 | 1,252 | 2.53125 | 3 | [] | no_license | require "rspec"
require File.expand_path(File.dirname(__FILE__) + "/../pt")
describe Pt do
it "should translate as expected"
it "should compare by X then Y"
it "should flip coordinates"
it "should convert from point lists to bitvector rows" do
pts = [
Pt.new(0,1),
Pt.new(1,2),
Pt.new(2,3... | true |
8899fe7bc8cf8235f9c0aa28c0728b484405a892 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/raindrops/6b64c370afd342eb9195f531d57104a9.rb | UTF-8 | 1,269 | 3.75 | 4 | [] | no_license | class Raindrops
require 'Prime'
@prime_factors = []
@rain_sound = ""
def self.convert(number)
@prime_factors = []
@rain_sound = ""
return number.to_s if number % 3 != 0 && number % 5 != 0 && number % 7 != 0 #return number if doesn't have factors of 3, 5 or 7
divide_by_3(number)
end
def f... | true |
0833cc6f78867e26760d789e95a78f743692b635 | Ruby | rlew421/module_0_capstone | /day_1/practice_calc.rb | UTF-8 | 48 | 3.171875 | 3 | [] | no_license | puts 25 / 5
puts "5"
x = 25
y = 5
puts x / y
| true |
58c79bfd3ef643b2f1c2761c5c62a4db7c59fd82 | Ruby | jamiepg1/alephant-renderer | /lib/alephant/renderer/engines/mustache.rb | UTF-8 | 1,505 | 2.546875 | 3 | [
"MIT"
] | permissive | require 'alephant/logger'
require 'mustache'
require 'i18n'
module Alephant
module Renderer
class Mustache
include ::Alephant::Logger
attr_reader :template_file
def initialize(template_file, base_path, model)
@template_file = template_file
@base_path = base_path
@m... | true |
0265280cd31a70d07bc92c5a056454f10a03a1eb | Ruby | pinchaque/etl | /spec/input/influxdb_spec.rb | UTF-8 | 4,555 | 2.625 | 3 | [
"MIT"
] | permissive | require 'influxdb'
require 'etl/core'
RSpec.describe "influxdb inputs" do
let(:dbconfig) { ETL.config.db[:influxdb] }
let(:iql) { '' }
let(:idb) { ETL::Input::Influxdb.new(dbconfig, iql) }
let(:ts) { Time.parse('2015-01-10T23:00:50Z').utc } # changing this will break tests
let(:series) { 'input_test' ... | true |
607ec2ebc97bc4250bcd628bed87df10ad4f50d4 | Ruby | Maxim-Filimonov/knight_api | /spec/knight_api/knight_spec.rb | UTF-8 | 2,989 | 2.78125 | 3 | [] | no_license | require 'knight_api/knight'
describe KnightApi::Knight do
describe '#initialize' do
it 'is valid' do
expect(subject).to be_valid
end
end
describe '#routes_to' do
it 'finds single route within one step' do
subject = described_class.new(start: 'a1')
routes = subject.routes_to('b3', m... | true |
6540134a36786230daee1a43d6d1ff40d921f7b9 | Ruby | laxmi1/jobvox_sst | /smoke_test/vendor.rb | UTF-8 | 2,572 | 2.5625 | 3 | [] | no_license | load File.dirname(__FILE__) + '/../test_helper.rb'
load File.dirname(__FILE__) + '/../test_helper.rb'
class Vendor < Test::Unit::TestCase
fixtures :users
# To open firefox browser and the application url
def setup
@driver = get_driver
@accept_next_alert = true
@verification_errors = []
end
# Thr... | true |
01650e180808a1bcbfcca089463c836744ad6ca3 | Ruby | jamaga/temp_exercise | /22czerwca_pdomowa/main_class.rb | UTF-8 | 542 | 2.8125 | 3 | [] | no_license | class Main
def self.zamieniaj(nasza_tablica)
wynik = {}
nasza_tablica.each do |jeden_element|
if jeden_element.is_a?(Hash)
jeden_element.each do |klucz, wartosc|
if wynik[klucz].nil?
wynik[klucz] = 0
end
if wartosc.is_a?(Array)
wynik[klucz]... | true |
7454bce0e7cb5f65d2f8912b5614e72e1fc2782e | Ruby | kinoppyd/reading-metaprogramming-ruby | /02_object_model/02_hierarchy.rb | UTF-8 | 2,067 | 3.8125 | 4 | [
"WTFPL"
] | permissive | module M1
def name
'M1'
end
end
module M2
def name
'M2'
end
end
module M3
def name
'M3'
end
end
module M4
def name
'M4'
end
end
# NOTE: これより上の行は変更しないこと
# Q1.
# 次の動作をする C1 class を実装する
# - C1.ancestors.first(2) が [C1, M1] となる
# - C1.new.name が 'C1' を返す
class C1
def name
'C1'
... | true |
c4a7255120bd7aefe8d6e8da183ac3c387a76442 | Ruby | njiiriJohnii/Ruby | /user.rb | UTF-8 | 310 | 3.6875 | 4 | [] | no_license | def user
puts "enter the first integer"
x=gets.chomp.to_i
puts "enter the second integer"
c=gets.chomp.to_i
puts "enter the operation"
op = gets.chomp
case op
when "-"
puts "the subtraction is #{x-c}"
when "+"
puts "the addition is #{x+c}"
when "*"
puts "the multiplication is #{x*c}"
end
end
user
| true |
bc3c66698370faa10458424ec48e8c7879085ff0 | Ruby | jkwellyn/orb_archetyper | /lib/orb_archetyper/archetype_generator.rb | UTF-8 | 2,920 | 2.78125 | 3 | [] | no_license | require_relative 'file_utils'
require_relative '../projects/project_factory'
require 'ansi'
require 'erb'
require 'orb_github_project/project'
require 'ostruct'
require 'orb_logger'
require 'semver'
# Archetype generator
class ArchetypeGenerator
# Create new generator instance given a project name
# Project name i... | true |
128221760bbdaf7c39cf852a809b4d9785563565 | Ruby | UANDES-ICC5180-201710/laboratorio-2-jparevalo | /app/models/student.rb | UTF-8 | 484 | 2.6875 | 3 | [
"MIT"
] | permissive | class Student < ApplicationRecord
belongs_to :person, :foreign_key => 'student_id'
belongs_to :course, :foreign_key => 'course_id'
def self.import_student(course_id,student_id)
new_student = Student.new
puts "iii"
puts student_id
puts "ooo"
if student_id!=nil
... | true |
e918e7c6d9227400da98b93fe29f601acca8adb8 | Ruby | MikeBlyth/mission_database | /app/models/pers_task.rb | UTF-8 | 3,130 | 2.875 | 3 | [] | no_license | # == Schema Information
# Schema version: 20120522135023
#
# Table name: pers_tasks
#
# id :integer not null, primary key
# task :string(255)
# pipeline :boolean
# orientation :boolean
# start_of_term :boolean
# end_of_term :boolean
# end_of_service :boolean
# alert ... | true |
0db8fa80c242410ecb714f04c39c43ae0be84036 | Ruby | annalaise/bank_tech_test | /lib/linebuilder.rb | UTF-8 | 624 | 3.1875 | 3 | [] | no_license | class LineBuilder
attr_reader :transactions
def generate(transactions)
transactions.reverse_each.map do |transaction|
case transaction[:transaction]
when :deposit
return_deposit(transaction)
when :withdrawal
return_withdrawal(transaction)
else
raise 'transaction ... | true |
3e224e843ee71e80a11b7162cc6bb5ddab619fe9 | Ruby | KimSeeun1214/Ruby-tutorial | /ex3.rb | UTF-8 | 520 | 4.5 | 4 | [] | no_license | #!/usr/bin/ruby -w
# define a class
class Polygon
# constructor method
def initialize(w,h)
@width, @height = w, h
end
# instance method
def getArea
@width * @height
end
end
# define a subclass
class Triangle < Polygon
# change existing getArea method as follows
d... | true |
df20a120be6ef8e6c0724c48ac89ae687c29b1bf | Ruby | barthez/skbus | /app/models/concerns/redis_cache.rb | UTF-8 | 1,438 | 2.609375 | 3 | [] | no_license |
module RedisCache
module CachingModule
def self.to_s
methods = instance_methods - [:redis_key]
"CachingModule(#{methods.join(', ')})"
end
def self.inspect
to_s
end
def self.define_cached_method(name)
define_method(name) do |*args|
__redis_cache_fetch(name, *args)... | true |
6451f9be921bc6aedd1d6419501aa07c5825dc02 | Ruby | NUBIC/ncs_navigator_core | /features/support/api_requests.rb | UTF-8 | 930 | 2.71875 | 3 | [] | no_license | ##
# Helpers for setting up Rack::Test to do API requests.
module ApiRequests
##
# Given a table of the form
#
# | bar | qux |
# | header:Content-Type | application/json |
# | header:X-Client-ID | 1234567890 |
# | qux | baz ... | true |
ae1880b49295275b2345499a3d26e7f6c37da25e | Ruby | stakach/streamio-ffmpeg | /lib/ffmpeg/transcoder.rb | UTF-8 | 5,160 | 2.5625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'open3'
require 'shellwords'
module FFMPEG
class Transcoder
@@timeout = 200
def self.timeout=(time)
@@timeout = time
end
def self.timeout
@@timeout
end
def initialize(movie, output_file, options = EncodingOptions.new, transcoder_options = {})
@movie = movie
... | true |
5d1f963578c1a683e79733ad83803bd4fb804093 | Ruby | Maddog164/reverse-each-word-onl01-seng-pt-070620 | /reverse_each_word.rb | UTF-8 | 1,829 | 3.8125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
def reverse_each_word(string)
newstring = string.split(" ") #separates string by spaces
final_string_array = []
final_string = ""
array_count = 0
#binding.pry
newstring.each do |word| #do for each word in array
word_to_rev = []
word_to_rev = newstring[array_count].split("") #wor... | true |
17ce26b837f601046ae5eb646d77e5c705f0e433 | Ruby | yuukubo/sort | /01_Ruby/01_src/01_bubble_1_00.rb | UTF-8 | 1,199 | 3.46875 | 3 | [] | no_license | require 'logger'
log = Logger.new('./bubble_sort.log', 'daily') # make log file at current directory
log2 = Logger.new('./bubble_sorted.log', 'daily') # make log file at current directory
log.info("Program started")
$t_start = 0
$t_end = 0
$t_pass = 0
$t_sum = 0
num_times = 10000
$arr_num = []
num_times.tim... | true |
72dfdfb727a32a3b35ad8a17f130201538c0fd09 | Ruby | sarboc/wdi_work | /week01/rental_app/apartment.rb | UTF-8 | 633 | 3.609375 | 4 | [] | no_license | class Apartment
attr_accessor :rent, :available, :tenant
attr_reader :sqft, :rooms, :bathrooms
def initialize(sqft, rooms, bathrooms, rent, available=false, tenant=nil)
@sqft = sqft
@rooms = rooms
@rent = rent
@available = true
@available = available
@tenant = tenant
end
def raise_rent(percentage)
... | true |
33d75539d834c1801160108216cb1c67d1a44a0c | Ruby | PhilippePerret/ProximityNew | /lib/required/_then/Lemma.rb | UTF-8 | 3,055 | 2.765625 | 3 | [
"Apache-2.0"
] | permissive | # encoding: UTF-8
require 'treetagger'
class Lemma
BINARY_PATH = "/usr/local/bin/tree-tagger-french"
NATURE_TO_SYMBOL = {
'VER' => :verbe, 'DET' => :determinant, 'ADJ' => :adjectif, 'NOM' => :nom,
'PRO' => :pronom, 'PRO:PER' => :pronom_personnel,
'PRP' => :preposition, 'SENT' => :point, 'KON' => :kon,
'ADV' =>... | true |
3e29af77a8ba10adb06fe30743202d69c2386b7f | Ruby | RuffWorksTech/RB101-Programming-Foundations | /lesson_3/medium_1.rb | UTF-8 | 716 | 3.71875 | 4 | [] | no_license | #-1
10.times { |n| puts (' ' * n) + "The Flintstones Rock!" }
#-2
puts "the value of 40 + 2 is #{40 + 2}"
#-3
def factors(number)
divisor = number
factors = []
while divisor > 0
factors << number / divisor if number % divisor == 0 #this means there is no remainder
divisor -= 1
end
factors #t... | true |
33b43e9b5dc65a27bb6edfeeb5dd32afcfc2b9c5 | Ruby | lugray/advent_of_code | /2015/day10/look_and_say.rb | UTF-8 | 370 | 3.703125 | 4 | [] | no_license | class LookAndSay
def initialize(input)
@input = input
end
def step(prev)
prev.scan(/((.)\2*)/).map(&:first).map{ |part| part.length.to_s + part[0] }.join
end
def nth(n)
prev = @input
n.times { prev = step(prev) }
prev
end
end
look_and_say = LookAndSay.new('1321131112')
puts look_and_s... | true |
17f19482bd64efc57e2297e85753850030ea6d94 | Ruby | wahl77/Linker | /lib/extensions/integer.rb | UTF-8 | 265 | 3.09375 | 3 | [] | no_license | class Integer
def round_to_nearest(precision)
(self.to_f / precision).round * precision
end
def round_to_nearest!(precision)
replace round_to_nearest(precision)
end
def humanize
self.to_s.gsub /(\d)(?=(\d\d\d)+(?!\d))/, "\\1,"
end
end
| true |
2e0e0cdd4432f78e2fcf0f631e4f826ec49d929f | Ruby | aspalding/ttt-ruby | /spec/console_spec.rb | UTF-8 | 864 | 2.90625 | 3 | [] | no_license | require 'board'
require 'console'
require 'player_manager'
require 'io_helper'
describe Console do
let(:b) {Board.new(3)}
let(:c) {Console.new(IoFake.new)}
it "shows a pretty board" do
io = IoFake.new(3)
con = Console.new(io)
con.get_size
pretty_board = "\n- | - | -\n- | - | -\n- | - | -\n\n"
... | true |
ffd726b16b1b0574f2f311fefbe6564b7b570fa3 | Ruby | LaRaye/anagram-detector-online-web-pt-011419 | /lib/anagram.rb | UTF-8 | 350 | 3.3125 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class Anagram
attr_accessor :word
def initialize(word)
@word = word
end
def match(array)
match_arr = []
array.each do |possible|
pos_arr = possible.split("").sort
word_arr = @word.split("").sort
if word_arr == pos_arr
match_arr << possible
end
end
ma... | true |
bdbe8ad2fc3045c23bba92824752e4a3746f7fda | Ruby | NicolasArayaB/linked-list | /node.rb | UTF-8 | 261 | 3.359375 | 3 | [] | no_license | class Node
attr_accessor :value, :next
def initialize
@value = nil
@next = nil
end
def value(value)
@value = value
end
def r_value
@value
end
def next_node(pointer)
@next = pointer
end
def next
@next
end
end
| true |
62ce3c2938f65f79b4704c3f5a6f6fd5c27f2fa6 | Ruby | paolabaccaro/cocktail_mania | /firstclasspart1.rb | UTF-8 | 51 | 2.578125 | 3 | [] | no_license | s = Square.new
s.side_length = 5
s.side_length
=> 5 | true |
6cd568617cf6d8a4f07507d7a9ae7b48ab62913b | Ruby | adisorganization/RubyLearning | /robot_gear.rb | UTF-8 | 6,726 | 3.265625 | 3 | [] | no_license | $current_credits = 1000
$helmet_options = [
":plastic costs $20. Grants you +25 hp.",
":bucket is $80. Grants you +50 hp.",
":worldWar is $125. Grants you +10 damage.",
":angel is $400. Grants you +20 damage.",
":god is $700. Grants you +100 hp."
]
$tool_options = [
":screwdriver is $30. Grants you +10 dama... | true |
ce6da4ff84be296486c9ed0d663272e6174d9bb9 | Ruby | wt5ljon/merge_sort | /merge_sort.rb | UTF-8 | 896 | 3.984375 | 4 | [] | no_license | # main merge sort function
def merge_sort(array)
return array if array.length == 1
if array.length > 1
p = 0
r = array.length
q = (p + r)/2
b = array.dup.slice(0, q)
c = array.dup.slice(q, r)
end
merge_sort(b)
merge_sort(c)
merge(b, c, array)
end
# merging helper function
def merge(first, second, array... | true |
bbf0182c4aa6baf7e703688fd7b75b9acac83792 | Ruby | jgorman/activity-timer | /app/models/concerns/guest_history.rb | UTF-8 | 2,163 | 2.578125 | 3 | [] | no_license | # frozen_string_literal: true
require "faker"
module GuestHistory
Defaults = {
guest: {
email: "guest@guest.com",
first_name: "Guest",
last_name: "Account",
role_s: "guest",
password: "guest123"
},
clients: 5,
projects_per_client: 5,
project_reuse: 0.80,
name_re... | true |
f3510ca89528a1bda48d7dfac001cdad549560ac | Ruby | lucasmundim/rgithook | /lib/rgithook/rgithook/base.rb | UTF-8 | 1,521 | 2.671875 | 3 | [] | no_license | module RGitHook
module Base
def self.included(base) #::nodoc::
base.extend ClassMethods
end
# Initialize a new instance of rgithook in the given repo or path
def initialize(repo_or_path)
@repo = self.class.parse_path(repo_or_path)
@runner = Runner.new(@repo)
... | true |
84d97232a06a7fa0ad1f175d7bd6bcab3a59f54e | Ruby | jereynolds/cloudcoreo | /lib/euler_prime_job.rb | UTF-8 | 935 | 3.078125 | 3 | [] | no_license | class EulerPrimeJob
attr_reader :length, :location, :result, :key
def initialize(location, length)
@euler = EulerCalc.new
@pc = PrimeChecker.new
@key = { :length => length, :location => location }
@length = Integer(length) rescue nil
@location = Integer(location) rescue nil
@completed = fa... | true |
7b8fb417733caa1aea0bc217299004e2e245a005 | Ruby | Pluvie/italian-ruby | /lib/italian/ruby/metodi/string.rb | UTF-8 | 4,598 | 3.296875 | 3 | [] | no_license | # frozen_string_literal: true
class String
##
# Codici colori.
CODICI_COLORI = Hash[
rosso: "31",
verde: "32",
giallo: "33",
blu: "34",
magenta: "35",
azzurro: "36",
arancione: "38;5;214",
verde_pallido: "38... | true |
70c0eee6c278ee194278a8ab44e7ec763379cd75 | Ruby | SurveyMoonBear/SurveyMoonbear_APP | /application/services/outputs/transform_responses_to_csv.rb | UTF-8 | 5,000 | 2.71875 | 3 | [] | no_license | # frozen_string_literal: true
require 'dry/transaction'
module SurveyMoonbear
module Service
# Return CSV format of responses
# Usage: Service::TransformResponsesToCSV.new.call(launch_id: "...")
class TransformResponsesToCSV
include Dry::Transaction
include Dry::Monads
# Item orders o... | true |
b64ba3ab0f0d63ac6443b8fc0c5f6f18fbe8e989 | Ruby | elenagarrone/RPSLS | /spec/game_spec.rb | UTF-8 | 834 | 3 | 3 | [] | no_license | require 'game'
describe Game do
let(:game) { Game.new }
let(:player) { Player.new('Elena') }
it "should be initialized with a player" do
expect(game.player).to eq(nil)
end
it "should be able to add a player and his/her name" do
game.player = player
expect(game.player.name).to eq('Elena')
e... | true |
db075f0a0eaf0be02e32d5e1153ed58c39b6535b | Ruby | Dean-Foulds/Le_wagon_notes | /food_delivery_with_sign_in_session/app/controllers/sessions_controller.rb | UTF-8 | 535 | 2.734375 | 3 | [] | no_license | require_relative "../views/sessions_view"
class SessionsController
def initialize(employee_repository)
@view = SessionsView.new
@employee_repository = employee_repository
end
def sign_in
username = @view.ask_for(:username)
password = @view.ask_for(:password)
employee = @employee_repository.f... | true |
d9256c834636809f524e6cd692583572731e0063 | Ruby | jeremyjbowers/scraperotus | /textifier.rb | UTF-8 | 744 | 2.75 | 3 | [
"Apache-2.0"
] | permissive | # encoding: UTF-8
# converts PDFs to plaintext via docsplit
require 'docsplit'
require 'fileutils'
class Textifier
def initialize; end
def textify
folders = Dir["pdfs/*"]
folders.each do |folder|
files = Dir.glob("#{folder}/*")
files.each do |file|
FileUtils.mv(file, file + ".pdf") u... | true |
50f1c8a980889d65755c9a218e5bdd35a6a5b767 | Ruby | sklise/asciidoc | /lib/asciidoc/elements/emphasis_element.rb | UTF-8 | 687 | 2.65625 | 3 | [] | no_license | module AsciiDoc
class EmphasisElement < AsciiElement
def parse_metadata(xml)
@attributes = xml.attributes
# if only child is a phrase element with a role attribute, make generative span class
# this is used for strike-through, etc. role attribute will be added as span... | true |
345142b3ba9544e3fb3321d8d29923fabc02dfc5 | Ruby | Ihsaan700/AppAcademyOpen-notes-and-exercises | /1 Intro to Programming/6_loops.rb | UTF-8 | 3,468 | 4.4375 | 4 | [] | no_license | # frozen_string_literal: true
def repeat(str)
i = 0
while i <= str.length
puts str
i += 1
end
end
def repeat2(str)
i = 0
while i <= str.length
puts str[i]
i += 1
end
end
# puts repeat2("experience")
def print_nums(min, max, step)
i = min
while i <= max
puts i
i += step
end
... | true |
16bae97b2b9b02da368eac88a51e01d15361d153 | Ruby | tied/DevArtifacts | /master/url_dictionary-master/url_dictionary-master/lib/url_dictionary/dictionary.rb | UTF-8 | 849 | 3.21875 | 3 | [
"MIT"
] | permissive | module UrlDictionary
class Dictionary
def initialize(hash, site_key)
@hash = hash
@site_key = site_key
end
def translate(full_key)
search(@hash, full_key, full_key.split('.'))
end
alias_method :t, :translate
private
def search(hash, full_key, remaining_segments)
... | true |
75ad62af9ca321c8c11455546963b15469ca2d70 | Ruby | Tapjoy/chore | /lib/chore/strategies/worker/forked_worker_strategy.rb | UTF-8 | 7,503 | 2.625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'chore/signal'
module Chore
module Strategy
class ForkedWorkerStrategy #:nodoc:
include Util
attr_accessor :workers
def initialize(manager, opts={})
@options = opts
@manager = manager
@stopped = false
@workers = {}
@queue = Queue.new
Chor... | true |
6b2b533836a6ead5611d50ac82c6c854057d89c4 | Ruby | matt9j/colte | /lte_extras/maps/app/helpers/banner_helper.rb | UTF-8 | 1,318 | 2.609375 | 3 | [
"MIT",
"GPL-2.0-only"
] | permissive | module BannerHelper
def active_banners
BANNERS.reject do |_k, v|
enddate = v[:enddate]
begin
parsed = enddate && Date.parse(enddate)
rescue StandardError
parsed = nil
end
!parsed.is_a?(Date) || (parsed.is_a?(Date) && parsed.past?)
end
end
# returns the least ... | true |
b46343eb8eb94dbd9b2250385143eaf97304e284 | Ruby | KKlawiter/portfolio | /js/data.rb | UTF-8 | 348 | 2.875 | 3 | [] | no_license | require 'active_support/all'
num = 1
f = 1.0
string = "Hello!"
sym = :symbol
array = [1, 2, 3, 4]
hash ={
1=> "One",
2=> "Two",
3=> "Three",
4=> "Four",
}
#puts hash.to_json.inspect
json_string = '{"1":"One","2":"Two","3":"Three","4":"Four"}'
parsed = ActiveSupport::JSON.decode(json_string)
puts parsed.insp... | true |
e6d933ecda85c38d7bf5d76c019a82b295321ddf | Ruby | mooz/rios | /lib/rios/proxy.rb | UTF-8 | 3,144 | 2.546875 | 3 | [
"MIT"
] | permissive | require "rios/util"
require "rios/terminal"
module Rios
class Proxy
DEFAULT_COMMAND = ENV["SHELL"]
def initialize
@fd_master, @fd_slave = Util.openpty($stdin.fileno)
@input_filters = []
@output_filters = []
@on_finishes = []
@pty_lock = Mutex.new
end
##
#... | true |
63151dd375b057385b36ffbbf6be6149d7509a76 | Ruby | ponta1106/object_oriented | /main.rb | UTF-8 | 374 | 3 | 3 | [] | no_license | require './drink/drink'
require './drink/drink_type'
require './vending_machine'
vm = VendingMachine.new
drink = vm.buy(Coin::FIVE_HUNDRED, DrinkType::COKE)
charge = vm.refund
if drink != nil && drink.coke?
print "コーラを購入しました。"
print "お釣りは#{charge}です"
else
raise StandardError.new("コーラ買えんかった(´゚д゚`)")
end
| true |
e9fe20348f57ad20de8163a6bb5d464527512e5b | Ruby | AnthonySuper/FifthedSim | /lib/fifthed_sim/actor.rb | UTF-8 | 1,840 | 3.046875 | 3 | [
"MIT"
] | permissive | module FifthedSim
class Actor
class DefinitionProxy
def initialize(name, &block)
@attrs = {
name: name,
attacks: {},
spells: {},
base_ac: 10
}
instance_eval(&block)
end
attr_reader :attrs
def attack(name, &block)
if ... | true |
f58119db59e4f51a5e6bfef02e2aef042e052bfd | Ruby | chrisdurheim/investsim | /lib/investsim/shiller_parser.rb | UTF-8 | 863 | 3.078125 | 3 | [
"MIT"
] | permissive | require 'spreadsheet'
require 'investsim/returns_month'
class ShillerParser
attr_reader :data_table
DEFAULT_DATA = Pathname.new(__FILE__) + '../../../data/ie_data.xls'
def initialize(file_path = DEFAULT_DATA)
Spreadsheet.client_encoding = 'UTF-8'
book = Spreadsheet.open file_path
data_sheet = bo... | true |
7ed72611eb3e2ec7177f42c16d531de178d8f4a6 | Ruby | XavierMeunier/user_skills | /app/services/parent_skill_info_service.rb | UTF-8 | 610 | 2.53125 | 3 | [] | no_license | class ParentSkillInfoService
def initialize
end
def get
get_parent_skills_info
end
private
def get_parent_skills_info
users_grouped_by_skills = User.with_skills
.select(:id, :points)
.includes("skills")
... | true |
34ec547417ead5ec1ae003419d878b3caafb249d | Ruby | YegDevLikeBoss/cloud-computing | /exploading_ate/Call.rb | UTF-8 | 223 | 3.375 | 3 | [] | no_license | class Call
State = {'PENDING': 0, 'ACTIVE': 1}
def initialize(caller, number)
@caller1 = caller
@caller2 = number
@state = State['PENDING']
end
attr_accessor :caller1, :caller2
end | true |
34f27e2f4feb2e064f1ac2a4e7695b7ee18dba8d | Ruby | darrenburgess/launch-school-object-oriented-programming | /lesson_04/easy01_08.rb | UTF-8 | 291 | 3.84375 | 4 | [] | no_license | class Cat
attr_accessor :type, :age
def initialize(type)
@type = type
@age = 0
end
def make_one_year_older
self.age +=1
end
end
cat = Cat.new("domestic")
cat.make_one_year_older
puts cat.age
# self in the make_one_year_older method refers to the object
# instance
| true |
4fe77983bf6156d7956b45f0448aba226ba5a423 | Ruby | ThoMich22/THPJ15_mini_jeu_POO | /lib/player.rb | UTF-8 | 2,508 | 3.828125 | 4 | [] | no_license | require 'pry'
class Player
attr_accessor :name, :life_points
def initialize (player_name)
@name = player_name
@life_points = 10
end
def show_state
if @life_points <= 0
puts "#{@name} a 0 point de vie"
else puts "#{@name} a #{@life_points} poi... | true |
46f3ac6bec499c244ad147d40da3131fd102cdbe | Ruby | Hal9000/rubytext | /examples/demo.rb | UTF-8 | 2,381 | 3.359375 | 3 | [] | no_license | $LOAD_PATH.unshift "lib"
require 'rubytext'
def delay(sec)
sleep sec/@speed
end
speed = ARGV.first || 1.0
@speed = speed.to_f
delay 1
RubyText.start(log: "mylog.txt", fg: Blue, bg: Black)
print "Here goes... "
delay 2
ymax, xmax = STDSCR.rows, STDSCR.cols
puts "STDSCR is #{ymax.inspect} by #{xmax.inspect}"
del... | true |
da0c2c18fad1438458a468e5726169177487e7ea | Ruby | ogcv/git-thp | /exo_02.rb | UTF-8 | 76 | 2.96875 | 3 | [] | no_license | puts "Hello world"
puts "Et avec une vois sexy, ca donne : Bonjour, monde !" | true |
b7680f86f6250f6ae8c43751588baa2272334a52 | Ruby | rsmith88/chitter-challenge | /spec/user_spec.rb | UTF-8 | 2,625 | 2.828125 | 3 | [] | no_license | require 'user'
describe User do
describe '.all' do
it 'returns a list of bookmarks' do
connection = PG.connect(dbname: 'chitter_test')
connection.exec("INSERT INTO users (name, email, username, password) VALUES ('RaySmith', 'ray@smith.com', 'RayRay', 'ray123');")
connection.exec("INSERT INTO u... | true |
275c416242f56516373c15a63d1fcf88576d33e1 | Ruby | tiffany-simionescu/udemy-rails-notes | /1_mvc.rb | UTF-8 | 628 | 2.6875 | 3 | [] | no_license | Model View Controller
MVC - Seperation of presentation layer (what the user
of the application sees in the browser/mobile device)
and the business-logic or back-end (invisible layer)
Model - resources in your app that are used (user,
post, article, stock). Each will have its own table
Views - make up the front-e... | true |
f63aaf6be34a74d17ae75fb12f42802c8fb4985a | Ruby | LateDevonian/Conversion-Calculator | /spec/compute_areas_unit_spec.rb | UTF-8 | 3,659 | 3.390625 | 3 | [] | no_license | require 'rspec'
require_relative '../sums/compute_areas'
RSpec.describe ComputeAreas do
let(:rectangle_m) { {length: 4, width: 2 } }
let(:square_m) { {length: 4, width: 4} }
let(:triangle_m) { {length: 4, height_depth: 5} }
let(:circle_m) { { radius: 3} }
let(:ellipse_m) { {axis_a: 2, axis_b: 6 } }
let(:... | true |
e02e3db78af7579d57a3dac05ea87482795e5fff | Ruby | klorenz/gollum-caves | /spec/wiki_settings_spec.rb | UTF-8 | 3,191 | 2.53125 | 3 | [] | no_license | require 'rspec'
require File.expand_path '../../lib/gollum-caves/wiki_manager.rb', __FILE__
require File.expand_path '../../lib/gollum-caves/deep_merge.rb', __FILE__
describe "Hash::deeper_merge" do
it "can merge hashes and arrays deeply" do
hash1 = {
:foo => [ 1, 2],
:glork => {
"first" =>... | true |
4d7e685bc721ac23f405669d682ecc6159f8f687 | Ruby | shioyama/mobility | /lib/rails/generators/mobility/translations_generator.rb | UTF-8 | 2,763 | 2.6875 | 3 | [
"MIT"
] | permissive | # frozen-string-literal: true
module Mobility
=begin
Generator to create translation tables or add translation columns to a model
table, for either Table or Column backends.
==Usage
To add translations for a string attribute +title+ to a model +Post+, call the
generator with:
rails generate mobility:translations... | true |
276a7951726826839f0b66eba3931ddf5674921f | Ruby | bfontaine/TwitterLiafa | /src/extractions/extract_friends_ids.rb | UTF-8 | 2,297 | 2.734375 | 3 | [] | no_license | #! /usr/bin/ruby1.9.1
# gem install 'twitter'
require 'yaml'
require 'twitter'
require 'json'
# -- CONFIG --
client = Twitter::Client.new(
YAML.load(File.read("tokens.yml"))
)
Output_dir = './friends_ids'
# -- ////// --
force = (ARGV.length > 0 && ARGV[0] == '--force')
if !File.directory?(Output_dir)
Dir.mk... | true |
fc74883ad042b9fc650429daab949046bd820bf1 | Ruby | jdugarte/date_time_attributes | /test/date_time_attributes_test.rb | UTF-8 | 4,396 | 2.96875 | 3 | [
"MIT"
] | permissive | require 'test_helper'
require 'timecop'
class DateTimeAttributesTest < ActiveSupport::TestCase
def setup
@object = Dummy.new
end
test "responds to getter/setter for date and time attributes" do
assert_respond_to @object, :ending_date
assert_respond_to @object, :ending_time
assert_respond_to @ob... | true |
27978f57ec09007a5d3ad36ce29a912094f6bfb1 | Ruby | wpotratz/LS_1_programming_foundations | /2_small_programs/calculator.rb | UTF-8 | 2,860 | 3.96875 | 4 | [] | no_license | # ask the user for two numbers
# ask the user for an operation to perform
# perform the operation on the two numbers
# display the resulting number
require 'pry'
require 'yaml'
MESSAGES = YAML.load_file('calculator_messages.yml')
LANGUAGE = 'en'
def prompt(message)
puts "=> #{message}"
end
def prompt_short(messa... | true |
6b2667a68bae5f16e65031158d6049a5d5589bc0 | Ruby | amarp/pascal | /parse_cal.rb | UTF-8 | 4,882 | 3.03125 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'rubygems'
require 'mechanize'
require 'hpricot'
require 'icalendar'
require 'date'
include Icalendar
def dump_day(items, year, month, cal)
raise "Not an array!" unless items.is_a?(Array)
raise "Not a calendar!" unless cal.is_a?(Calendar)
# puts "-----"
# puts "Date -> #{it... | true |
9e4a167c382564a375f57f46017978af51eef6fe | Ruby | lukemenard/cli-applications-guessing-game-den-web-071519 | /guessing_game_cli.rb | UTF-8 | 405 | 3.828125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def get_random_number
rand(6)+1
end
def get_user_input
gets.chomp
end
def give_outputs
random_number = get_random_number
user_input = get_user_input
if user_input == "exit"
puts "Goodbye!"
elsif user_input == random_number.to_s
puts "You guessed the correct number!"
else
puts "Sorry! The com... | true |
35a6c2da8b1fb6b16a897b6a8d16be98e3ccc715 | Ruby | ipahenderson/solo_project_greazy | /models/eatery.rb | UTF-8 | 1,746 | 3.109375 | 3 | [] | no_license | require_relative('../db/sql_runner')
class Eatery
attr_reader(:id, :name, :contact, :logo)
def initialize( options )
@id = options['id'].to_i if options['id']
@name = options['name']
@contact = options['contact']
@logo = options['logo']
end
def save
sql = "INSERT INTO eateries
(
... | true |
55453f398cf0fa42a097960a77a1dc47ab9f7573 | Ruby | KitaitiMakoto/nulab_backlog | /lib/nulab_backlog/connection.rb | UTF-8 | 3,552 | 2.734375 | 3 | [
"MIT"
] | permissive | require 'forwardable'
require 'json'
require 'faraday'
module NulabBacklog
class Connection
def initialize(uri:, api_key:)
@connection = Faraday.new(uri, request: {params_encoder: ParamsEncoder})
@api_key = api_key
end
def request_json(method: :get, path: , params: nil, body: nil, headers: {... | true |
a13117909050c9bf8715446defcdcf284658d756 | Ruby | Pierre-Berger/THP-RubyExo | /exo_07.rb | UTF-8 | 150 | 2.828125 | 3 | [] | no_license | puts "Tu sais compter jusqu'a combien ?"
print ">"
user_number = gets.to_i
user_number.to_i.times do |i|
puts 1+ i
end
puts "Moi aussi !!!!"
| true |
ab4a2244788c242683301fe976d057be6db57c83 | Ruby | bananno/rubyadventure | /game.rb | UTF-8 | 3,212 | 3.375 | 3 | [] | no_license | class PlayGame
def initialize
require "colorize"
create_map
clear_screen
print_map
get_action
end
def create_map
@grass = 0
@water = 1
@snow = 2
@the_map = [
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2],
... | true |
e1133c4cbdcce041ea68567b24ba5653fdf9d8d7 | Ruby | rrosenb12/ruby-project-alt-guidelines-nyc01-seng-ft-060120 | /lib/sighting.rb | UTF-8 | 929 | 3.203125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class Sighting < ActiveRecord::Base
belongs_to :birdwatcher
belongs_to :bird
def nice_description
return "#{self.id} ) On #{self.time_of_day} you saw a #{self.bird.color} #{self.bird.common_name}. It was #{self.weather} at #{self.location}"
end
def self.see_all_birds_by_ever... | true |
e0ee41edfcbef13cb7c91254f1e567d2fa9a5119 | Ruby | bpstein/learn_to_program | /ch12-new-classes-of-objects/birthday_helper.rb | UTF-8 | 723 | 3.8125 | 4 | [] | no_license | birth_dates = {}
File.readlines('birthday_dates.txt').each do |line|
name, date, year = line.split(',')
birth_dates[name] = Time.gm(year, *(date.split))
end
puts 'Enter a famous Christopher please.'
name = gets.chomp
birthday = birth_dates[name]
if birthday == nil
puts "Error: Enter a famous CHRISTOPHER."
els... | true |
c49ba970706ad7ca7a6a35ae7d53ee75bdb7d5f6 | Ruby | MarkAndreev/Exercism-Ruby-exercises | /high-scores/high_scores.rb | UTF-8 | 382 | 3.078125 | 3 | [] | no_license | class HighScores
def initialize(scores)
@scores = scores
end
def scores
@scores
end
def latest
sort_scores
@scores.first
end
def personal_best
sort_scores
@scores.last
end
def personal_top_three
sort_scores
@scores.reverse!
@scores[0..2]
end
private
def ... | true |
3cae5c67aaf73c8638286bfa01f566c086e03eac | Ruby | paulogaspari/sudoku_web | /sudoku.rb | UTF-8 | 2,998 | 3.03125 | 3 | [] | no_license |
require 'sinatra'
require 'rack-flash'
require_relative './lib/sudoku'
require_relative './lib/cell'
enable :sessions
set :session_secret, "I'm the secret key to sign the cookie"
use Rack::Flash
# GETs
#####################################################################
get '/' do
prepare_to_check_solutio... | true |
b0d6bea9cba4480c1da9aab0616f8c057a81e80c | Ruby | shirohige3/furima-29760 | /spec/models/item_spec.rb | UTF-8 | 2,880 | 2.53125 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe Item, type: :model do
before do
@item = FactoryBot.build(:item)
end
describe '商品出品' do
context '商品出品が上手くいく時' do
it 'name,description,price,category_id,condition_id,shipping_fee_id,ship_form_id,shipping_day_idが存在する時' do
expect(@item).to be_valid
en... | true |
a953277e4d55ff8af5a96e291a13fb9921cc4627 | Ruby | alexgaganov/learn-ruby-the-hard-way | /ex33.rb | UTF-8 | 467 | 4.15625 | 4 | [] | no_license | def while_loop(numbers, n, x)
i = 0
# while i < n
(1..6).each do |i|
puts "At the top i is #{i}"
numbers.push(i)
# i += x
puts "Numbers now: ", numbers
puts "At the bottom i is #{i}"
end
return numbers... | true |
618a2b0ac69f3068459f98ebe84a879480528375 | Ruby | marc/iostreams | /lib/io_streams/zip/writer.rb | UTF-8 | 2,037 | 2.890625 | 3 | [
"Apache-2.0"
] | permissive | module IOStreams
module Zip
class Writer < IOStreams::Writer
# Write a single file in Zip format to the supplied output file name
#
# Parameters
# file_name [String]
# Full path and filename for the output zip file.
#
# entry_file_name: [String]
# Name o... | true |
01b9fc28e95f286e876aef279551a50e5027468b | Ruby | accua/shoestore | /lib/store.rb | UTF-8 | 310 | 2.71875 | 3 | [
"MIT"
] | permissive | class Store < ActiveRecord::Base
has_and_belongs_to_many(:brands)
validates(:name, :presence => true)
before_save(:capitalize_name)
private
def capitalize_name
store_name = self.name.split
new_name = store_name.map { |store| store.capitalize }
self.name = new_name.join(' ')
end
end
| true |
9b6331443aa957f48ce1417c64c040b21cae201d | Ruby | jjasghar/kitchen-terraform | /lib/kitchen/verifier/terraform.rb | UTF-8 | 6,644 | 2.515625 | 3 | [
"Apache-2.0"
] | permissive | # frozen_string_literal: true
# Copyright 2016 New Context Services, Inc.
#
# 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless requir... | true |
2f41eb423c1ff25323cfc98bcdc88614e6ecb500 | Ruby | GemmaPercvial/week3_day2 | /model/bounty.rb | UTF-8 | 1,980 | 2.890625 | 3 | [] | no_license | require ('pg')
require('pry-byebug')
class Bounty
attr_writer :cashed_in
def initialize (options)
@id = options['id'].to_i if options['id'] != nil
@name = options ['name']
@bounty_value = options ['bounty_value'].to_i
@danger_level = options ['danger_level']
@cashed_in = (options['cashed_in'] =... | true |
4e724c4ed8b4218c3c17be1f1bc618e9acb8495d | Ruby | carden-code/domz | /1.part/modulo_devision2.rb | UTF-8 | 514 | 3.53125 | 4 | [] | no_license | def modulo_devision(dividend, divisor)
modulo = dividend / divisor
without = divisor * modulo
balance = dividend - bezostatka
return [modulo, without, balance]
end
puts "Modulo devision"
puts "Specify a positive integer greater than 0:"
dividend = gets.chomp.to_i
puts "Divisor:"
divisor = gets.chomp.to_i
puts("... | true |
cc5bbff603fb7ee3eb410ad94e6be559183b74cf | Ruby | RoastedPhoenix/calculators | /PythagoreanHypotenuseCalc.rb | UTF-8 | 164 | 3.4375 | 3 | [] | no_license | puts "What is the first side?"
a = gets.to_f
puts "What is the second side"
b = gets.to_f
x = a**2
y = b**2
z = x+y
c = z**0.5
puts "The hypatanuse is"
puts c.to_f
| true |
cc8cb8290030611c23c61613d23424580f6ba9b1 | Ruby | divbeech/programming-univbasics-4-intro-to-hashes-lab-nyc-web-091619 | /spec/intro_to_ruby_hashes_lab_spec.rb | UTF-8 | 275 | 2.53125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require_relative 'spec_helper'
require_relative '../intro_to_ruby_hashes_lab.rb'
def new_hash
hash = { }
end
end
def my_hash
healthy_things = {smoothies:"Green"}
end
end
def pioneer
pioneer = {:name => "Grace Hopper"}
end
end
def id_generator
id = {:age => 30}
end
end
| true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.