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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
f7c1c31d2a8202a090261c067f25ce3772dd55f7 | Ruby | SolalDR/Grow2018 | /heightmapper/main.rb | UTF-8 | 1,330 | 2.90625 | 3 | [] | no_license | require 'net/http'
from = {
lat: ARGV[0].to_f,
lon: ARGV[1].to_f
}
to = {
lat: ARGV[2].to_f,
lon: ARGV[3].to_f
}
if ARGV[4]
resolution = ARGV[4].to_i
else
resolution = 20
end
coords = [];
for x in 0..resolution
for y in 0..resolution
coord = {}
coord[:lat] = from[:lat] + ((to[:lat] - from[:... | true |
69628a95ecaaa07b360c0f81e6f917165eaa0046 | Ruby | Keftcha/codingame | /training/easy/onboarding/ruby.rb | UTF-8 | 307 | 3.15625 | 3 | [] | no_license | STDOUT.sync = true # DO NOT REMOVE
loop do
enemy_1 = gets.chomp # name of enemy 1
dist_1 = gets.to_i # distance to enemy 1
enemy_2 = gets.chomp # name of enemy 2
dist_2 = gets.to_i # distance to enemy 2
if dist_1 < dist_2
puts enemy_1
else
puts enemy_2
end
end
| true |
cdcb851f20e888531c1e66a59343203ab09f7305 | Ruby | dishantpatel27/ar-exercises | /exercises/exercise_7.rb | UTF-8 | 595 | 2.890625 | 3 | [] | no_license | require_relative '../setup'
require_relative './exercise_1'
require_relative './exercise_2'
require_relative './exercise_3'
require_relative './exercise_4'
require_relative './exercise_5'
require_relative './exercise_6'
puts "Exercise 7"
puts "----------"
# Your code goes here ...
puts "Enter store's name:"
user_inp... | true |
8fc245dcc67e49ab5ad60264a34b2a03951f8390 | Ruby | darrendc/phrg-array-methods-lab-pca-000 | /lib/array_methods.rb | UTF-8 | 252 | 3.296875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def using_include(array, element)
array.include?(element)
end
def using_sort(dogs)
dogs.sort
end
def using_reverse(dogs)
dogs.reverse
end
def using_first(dogs)
dogs.first
end
def using_last(dogs)
dogs.last
end
def using_size(dogs)
dogs.size
end
| true |
8cbe2c0ba50f9a15b990083604b85d0a83397892 | Ruby | rafacv/rails | /activerecord/test/cases/types_test.rb | UTF-8 | 5,345 | 2.734375 | 3 | [
"Ruby",
"MIT"
] | permissive | require "cases/helper"
require 'models/company'
module ActiveRecord
module ConnectionAdapters
class TypesTest < ActiveRecord::TestCase
def test_type_cast_boolean
type = Type::Boolean.new
assert type.type_cast('').nil?
assert type.type_cast(nil).nil?
assert type.type_cast(tr... | true |
a242f948e8b19d7fac8ae20e4af05baec589092f | Ruby | FDPS/FDPS | /pikg/src/intermediate_exp_class.rb | UTF-8 | 57,147 | 2.703125 | 3 | [
"MIT"
] | permissive | # class definition
class Kernelprogram
attr_accessor :iodeclarations, :functions, :statements
def initialize(x)
#@iodeclarations, @functions, @statements =*x
if x[0][0].class == Iodeclaration
@iodeclarations = x.shift
else
@iodeclarations = []
end
if x[0][0].class == Function
@... | true |
5c690ddf40646d375ccd19ccb52e547afc9a15fe | Ruby | nodog/rubytictactoegame | /lib/game_explorer.rb | UTF-8 | 3,286 | 3.328125 | 3 | [
"Unlicense"
] | permissive | #!/opt/local/bin/ruby1.9
require 'yaml'
require_relative 'tic_tac_toe_game'
require_relative 'tic_tac_toe_game/board'
#----------------------------------------
class GameExplorer
PLAYER_1_MARK = 'X'
PLAYER_2_MARK = 'O'
def catalog(filename)
@count = 0
@hash_of_states = {}
a_board = Board.... | true |
a3efabec324f25a4e7b1a87a29798921d5eb3f67 | Ruby | Mohit-Pawar/training | /ruby/program/ArrayAndHash/test.rb | UTF-8 | 3,310 | 4.03125 | 4 | [] | no_license | class CowsBullsGame
No_OF_CHANCES = 5
attr_accessor :config_file_path
def play
begin
@word = get_random_word
rescue => e
puts e.message and return
end
@no_of_chances = get_no_of_chances(word) if @word.length > 8
no_of_chances.times do |attempt|
@user_guessed_word = guess_... | true |
97e6cc73d69b803911ca7cc74875a8f85aa4db00 | Ruby | Haushoffer/mundoWumpus | /lib/bat.rb | UTF-8 | 764 | 2.828125 | 3 | [] | no_license | require './lib/cave.rb'
class Bat
attr_accessor :caveOfPosition, :batAlive
def initialize(caveOfPosition)
@caveOfPosition = caveOfPosition
@caveOfPosition.hostBat()
@batAlive = true
setSmellAround(true)
end
def setSmellAround(value)
if (@caveOfPosition.topNeighbor... | true |
ec1f7b2dc86cf897cba650a45f0a021915bc40b3 | Ruby | lilian2112/learn_to_program | /ch12-new-classes-of-objects/happy_birthday.rb | UTF-8 | 299 | 3.78125 | 4 | [] | no_license | puts "Hey you, what year were you born in?"
year = gets.chomp.to_i
puts "And the month?"
month = gets.chomp.to_i
puts "On what day?"
day = gets.chomp.to_i
born = Time.local(year, day, month)
today = Time.new
age = 1
while Time.local(year + age, day, month) <= today
puts 'SPANK!'
age = age + 1
end
| true |
5af0a4ff522f5519fd7ed53b4911dbf4970517dc | Ruby | DimaSamodurov/game_of_life | /game.rb | UTF-8 | 538 | 3.046875 | 3 | [] | no_license | # encoding: utf-8
require_relative 'grid'
require 'matrix'
require 'pry'
class Game
attr_reader :grid
def initialize(initial_state)
@grid = Grid.new(initial_state)
end
def play
render @grid
loop do
render @grid = @grid.tik
sleep 0.1
end
end
def render(grid)
system 'clea... | true |
c4e15c408b9476d1723bac6c989a5f78afe23678 | Ruby | aldelcy/IronHack-Class | /Week 2/Day 1/fizz_buzz/app.rb | UTF-8 | 148 | 3.125 | 3 | [] | no_license | require_relative "lib/fizzbuzz.rb"
input = FizzBuzz.new
puts input.change_input(9)
puts input.change_input(10)
puts input.change_input(15) | true |
a8f0c866236eb6b63e94f75c3b7ef224950e05e6 | Ruby | tomasklapka/cracke | /src/ruby/loader.rb | UTF-8 | 453 | 2.65625 | 3 | [] | no_license | puts "loader.rb loading..."
$mainfile = 'main.rb'
$mainfile_path = './cracke/src/ruby/'+$mainfile
$mtime = File.mtime($mainfile_path);
puts "main.rb loading..."
load $mainfile
puts "main.rb loaded"
def check_mainfile
if File.mtime($mainfile_path) != $mtime
$mtime = File.mtime($mainfile_path)
load $mainfile
... | true |
b66091abc92b3215aaade0003a822775c15ef385 | Ruby | mdk/scrapsc | /src/printer.rb | UTF-8 | 2,178 | 3.09375 | 3 | [] | no_license | # Copyright (c) 2009 New Wild.
#
# Authors:
# * Michael Dominic K. <mdk@new-wild.com>
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitatio... | true |
41c38dd6a2e03c8bbae7109d516a2bd22c77afc6 | Ruby | mwottonbc/bayesianpsych | /classifier.rb | UTF-8 | 968 | 2.78125 | 3 | [] | no_license | # encoding: UTF-8
require 'classifier'
require 'madeleine'
require 'awesome_print'
class Massager
def initialize(argf)
@cache = {}
argf.each do |line|
last, *elems = line.split(' ').reverse
label = last.split(':')[1].to_sym
@cache[label] ||= ""
elems.each do |e|
word, count =... | true |
25c42b08cde8b638a9fcbd0be7ea3c05abe91ffe | Ruby | Lycoris/Project-Euler | /071-080/071.rb | UTF-8 | 402 | 3.53125 | 4 | [] | no_license | # http://projecteuler.net/problem=71
#
#
def ordered_fraction(n, d, l)
answer = 0
l.downto(2) {|i|
p i
1.upto(i - 1) {|j|
if Rational(j, i) >= Rational(3, 7) then
if Rational(j - 1, i) > answer then
answer = Rational(j - 1, i)
p answer
break
else
break
end
end
}
}
retur... | true |
cb00a37f4931e99b9ebcfd2419612c11741e0c61 | Ruby | pr0d1r2/unwebarchive | /lib/webarchive.rb | UTF-8 | 975 | 2.5625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'plist'
require 'fileutils'
require 'tmpdir'
# Allows to list all resources contained in "*.webarchive" file
class Webarchive
def initialize(file)
@plist = plist_data(file)
end
def self.resources(file)
new(file).resources
end
def resources
main_resource_ha... | true |
11b53e518c888d49becd156f9c5cbd3bebc5114c | Ruby | qwertyebobo/lrnruby | /ch7/ex2.rb | UTF-8 | 558 | 2.9375 | 3 | [] | no_license | # задача из 5-й главы (форматирование вывода) измененная
# с приминение массивов
chpt = ['Содержание', 'Глава 1:', 'Глава 2:', 'Глава 3:']
text = ['Числа', 'Буквы', 'Переменные']
page = ['стр. 1', 'стр. 72', 'стр. 118']
puts chpt[0].center(50)
puts ''
puts (chpt[1] + ' ' + text[0]).ljust(25) + page[0].rjust(25)
put... | true |
c4ac97ec1a764d0be18cd75a175b50659f0d320c | Ruby | onigra/twada-tdd | /ruby/test/contract_service_test.rb | UTF-8 | 2,368 | 2.640625 | 3 | [] | no_license | require 'test/unit'
require 'contract_service'
class TC_ContractService < Test::Unit::TestCase
sub_test_case "商品カテゴリがワードプロセッサの場合" do
def test_契約日に全額収益認識できる
# given
name = "MS Word"
price = 18800
category = Category.new(name: :word_processor)
# and
product = Product.new... | true |
867cd6e4e9058a3694b50e4b43dbde7eeda6e0fd | Ruby | rparkerson/launch-school | /RB100/ruby_basics/strings/10.rb | UTF-8 | 877 | 4.28125 | 4 | [] | no_license | # Using the following code, print true if colors includes the
# color 'yellow' and print false if it doesn't.
# Then, print true if colors includes the color 'purple' and
# print false if it doesn't.
# colors = 'blue pink yellow orange'
# Expected output:
# true
# false
colors = 'blue pink yellow orange'
arr = ... | true |
15b16c3a04815fb8fa493226c1c16cdc628b008e | Ruby | Abhideveloper28/ImageManipulate | /lib/exts/file_ext.rb | UTF-8 | 577 | 2.71875 | 3 | [] | no_license | # frozen_string_literal: true
class File
def self.write_tempfile(file_name, file_content)
f = Tempfile.open [File.basename(file_name, ".*"), File.extname(file_name)]
f.binmode
f.write file_content
f.close
f
end
def self.to_temp_file(file)
if file.respond_to?('get_input_stream')
wri... | true |
f8c6817e23b0033962f9e7495c376b5ab525ebce | Ruby | moglich/ls_programs | /lesson_2/rock_paper_scissors.rb | UTF-8 | 1,814 | 3.53125 | 4 | [] | no_license | VALID_CHOICES = { 'r' => 'rock',
'p' => 'paper',
's' => 'scissors',
'o' => 'spock',
'l' => 'lizard' }.freeze
WINNING_STATES = { 'rock' => %w(lizard scissors),
'paper' => %w(rock spock),
'scissors' => %w(paper ... | true |
c05bb7aa4d460c1a9fb2556c831ddfad7090a939 | Ruby | fuchaimead/ruby_golf | /hole2.rb | UTF-8 | 273 | 3.84375 | 4 | [] | no_license | require 'pry'
def rps
puts '1) rock, 2) paper, 3) scissors?'
a = gets.to_i - 1
w = [0,1,2].sample
puts w == 0 ? 'rock' : w == 1 ? 'paper' : 'scissors'
puts a == w ? 'tie' : a == 0 && w == 2 ? 'win' : a == 2 && w == 0 ? 'lose' : w > a ? 'lose' : 'win'
end
rps
| true |
dd344b38df923e272461ad3ffa6ffbdecf44909b | Ruby | BohanHsu/leetcode2 | /add_and_search_word_-_data_structure_design.rb | UTF-8 | 1,598 | 3.828125 | 4 | [] | no_license | class WordDictionary
def initialize
@root = Node.new
end
# @param {string} word
# @return {void}
# Adds a word into the data structure.
def add_word(word)
n = @root
word.chars.each do |chr|
if n.children.has_key?(chr)
n = n.children[chr]
else
new_n = Node.new
... | true |
cdb2138103ff384b756b53de4c54358e611468a1 | Ruby | johnyph/doctor_api | /app/models/user.rb | UTF-8 | 676 | 2.515625 | 3 | [] | no_license | require 'sinatra/activerecord'
module Doctor
class User < ActiveRecord::Base
has_secure_password
# Validation
validates :email, presence:true, uniqueness:true
validates :first_name, :last_name, presence: true
validates :vat, presence:true, numericality: true, length: { is: 9 }
# Call... | true |
656421296dafdb7225c303d33eaf00305dcccf25 | Ruby | ccls/odms | /lib/tasks/zip_codes.rake | UTF-8 | 1,253 | 2.5625 | 3 | [
"MIT"
] | permissive | namespace :app do
namespace :zip_codes do
# 20160504 - Commented out to avoid accidental usage.
# task :destroy_all => :environment do
## uses the default scope limit of 10 so doesn't destroy ALL.
## ZipCode.destroy_all
## ZipCode.unscoped.destroy_all # can take a while
# ZipCode.unscoped.delete_all
# end
# 2... | true |
24cb88e648f86a6c4181b5e503ab008487c00da0 | Ruby | AlekhyaR/checkout_system | /spec/lib/numeric_spec.rb | UTF-8 | 245 | 2.71875 | 3 | [] | no_license | describe Numeric do
context '#formatted_price' do
let(:price) {'£23.23'}
it 'checks whether formatted price returns correct price in float value' do
expect(described_class.formatted_price(price)).to eq(23.23)
end
end
end | true |
59e773657e2e004d2c2c8de871925c017f340706 | Ruby | thomas07vt/number_to_word | /bench/memory.rb | UTF-8 | 687 | 2.953125 | 3 | [
"MIT"
] | permissive | require "benchmark/memory"
require 'number_to_word'
def zero
NumberToWord.new(0).word
end
def single_digit
NumberToWord.new(7).word
end
def tens
NumberToWord.new(18).word
end
def below_hundred
NumberToWord.new(84).word
end
def thousands
NumberToWord.new(4321).word
end
def millions
NumberToWord.new(1_8... | true |
61a986c67b5d60bb27a7f1ca842c95d7c2a64dd3 | Ruby | llinneaa/hotel | /test/reservation_test.rb | UTF-8 | 827 | 2.859375 | 3 | [] | no_license | require_relative 'test_helper'
require 'rake'
describe "Reservation class" do
describe "Reservation instantiation" do
before do
@date_range = Hotel::DateRange.new("2001/2/3", "2001/2/5")
@reservation = Hotel::Reservation.new(
room_number: 1,
date_range: @date_range
)
end
... | true |
ffe318f2934a7a586fcdb3c102be4d4bf0def794 | Ruby | shantanutrip/RubyMethod | /mainRuby.rb | UTF-8 | 951 | 2.90625 | 3 | [] | no_license | require 'MethodCall';
require 'ripper'
require 'treetop'
require 'ripper-plus'
require 'axiom_of_choice'
require 'stream'
require 'object_regex'
require 'trollop'
require 'Sexp'
puts "Hi"
files = ["/home/shantanu/RubyCodes/classRuby.rb","/home/shantanu/RubyCodes/ParserAttempt1.rb"];
def read_file(file)
case file
... | true |
1fb913c68a0d669c8a2f33a9f72fb00dc8652555 | Ruby | rewhowe/snapdragon | /src/tokenizer/lexer/token_lexers/function_call.rb | UTF-8 | 567 | 2.59375 | 3 | [] | no_license | module Tokenizer
class Lexer
module TokenLexers
def function_call?(chunk)
@current_scope.function? chunk, signature_from_stack
end
def tokenize_function_call(chunk)
function = @current_scope.get_function chunk, signature_from_stack
regularize_function_call_parameters! f... | true |
b263eb23c0522644faab78908e1e3a1a5f47967b | Ruby | alokpradhan/assignment_ruby_oop_warmups | /hanoi.rb | UTF-8 | 1,949 | 4.125 | 4 | [] | no_license | =begin
-Class for entering the height and initializing data structure
-Class displaying board
-Class holding main that loops through moves
method to check if the game is over
-Class for validation
validates entered move ( tower - 1,2,3)
validates disk_movemnt (can disk move)
-Class for making the move
=e... | true |
f25db8bdbfc41c317332c88679088102450c969b | Ruby | EvelynG382020/Desafio_ecommerce | /app/models/order.rb | UTF-8 | 872 | 2.625 | 3 | [] | no_license | class Order < ApplicationRecord
belongs_to :user
has_many :order_items
has_many :products, through: :order_items
has_many :payments
has_many :variations
validates :number, uniqueness: true
def total_in_cents #metodo indica el total de la order utilizado en carts controller
total * 100
end
def s... | true |
fe632a03ad3f04c11db63f466b1f92a2f9c8a6f8 | Ruby | jimneath/sucker | /lib/sucker/response.rb | UTF-8 | 2,315 | 2.75 | 3 | [
"MIT"
] | permissive | require "active_support/xml_mini/nokogiri"
module Sucker #:nodoc:
# A Nokogiri-driven wrapper around the cURL response
class Response
# The response body
attr_accessor :body
# The HTTP status code of the response
attr_accessor :code
# Transaction time in seconds for request
attr_accesso... | true |
670ed8cfbc18f79804fa0802be01643671fdca7b | Ruby | marcosortiz/easy_sockets | /lib/easy_sockets/basic_socket.rb | UTF-8 | 5,427 | 3.078125 | 3 | [
"MIT"
] | permissive | require 'logger'
require 'socket'
require 'timeout'
require 'easy_sockets/constants'
require 'easy_sockets/utils'
module EasySockets
#
# @author Marcos Ortiz
# @abstract Please check the following subclasses: {EasySockets::TcpSocket} and {EasySockets::UnixSocket}.
#
class BasicSocket
includ... | true |
f5001cdf225d4dbcaaa65a81d1cda187185f58fa | Ruby | vecerek/less2sass | /lib/less2sass/sass/ast_handler.rb | UTF-8 | 1,532 | 2.953125 | 3 | [
"MIT"
] | permissive | module Less2Sass
module Sass
# Wrapped Sass AST
class ASTHandler
# Creates an empty Sass AST.
#
# @param [::Sass::Tree::Node] tree the Sass AST
def initialize(tree)
@tree = tree
end
# Appends child notes to the empty Sass AST.
#
# Note, that this should... | true |
6e0e71e312919606848bd495d7e091e15c6c4e25 | Ruby | hayduke19us/quote_finder | /chris_quotes.rb | UTF-8 | 1,343 | 3.515625 | 4 | [] | no_license | require 'rubygems'
require 'active_support'
require "Nokogiri"
require "open-uri"
class Quote
attr_accessor :author, :index
attr_reader :document, :quotes
def initialize(author='hitchens')
@author = author
@document = Nokogiri::HTML(open endpoints[@author])
@quotes = @document.css('blockquote')... | true |
9575d62eceb0eb1e4a75a8f4a593164fbdb4cc35 | Ruby | agoryachev/molnia_sport | /lib/parsers/creator.rb | UTF-8 | 9,985 | 2.703125 | 3 | [] | no_license | module Parsers
module Creator
extend ActiveSupport::Concern
included do
# Парсинг лиг
#
# @param [Object] category - текущая категория
# @param [Object] country - текущая страна
# @param [String] url - ссылка с которой парсим
# @param [String] name_prefix - ... | true |
0e9e4e49af691f5fbf4cd1dc946cf1490476efe2 | Ruby | marick/stunted | /lib/stunted/shapeable.rb | UTF-8 | 352 | 2.765625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | module Stunted
module ShapeableClassMethods
def shaped_class(*shapes)
klass = Class.new(self)
shapes.each do | mod |
klass.send(:include, mod)
end
klass
end
end
module Shapeable
def become(*shapes)
return self if shapes.empty?
self.class.shaped_class(*shap... | true |
b5b3626c79cf8da133b8551bfffeddacf41f300d | Ruby | harry101491/RubyTesting | /loops.rb | UTF-8 | 535 | 3.8125 | 4 | [] | no_license |
index = 1
while index <= 5
puts(index)
index += 1
end
list = [ "Jane", "Doe", "lorem", "ipsum", "Jon", "Doe", "Jane", "Roe" ]
list.map do |ele|
puts(ele)
end
list.map { |ele| puts(ele) }
6.times do |i|
puts(i)
end
6.times { |i| puts(i) }
for ele in list
puts(ele)
end
for index in 0..5
pu... | true |
fa5e1cf8915365386e51e506b8330ee2ca6097c1 | Ruby | armenta-angel/Abril-Bowling | /germandz/lib/score_card.rb | UTF-8 | 582 | 3.359375 | 3 | [] | no_license | require "frame"
class ScoreCard
attr_reader :notation, :frames
def notation= notation
@notation = notation
@frames = []
last_frame = nil
rolls = notation.split(//)
while (!rolls.empty?) do
frame = Frame.new
frame.first_roll = rolls.shift
frame.second_roll = rolls.shift unl... | true |
e71c03fcd680567dab899657c10bfbe688cef2b7 | Ruby | AllisonAnz/phase-3-active-record-introduction | /Notes/ActiveRecordMigration.rb | UTF-8 | 7,301 | 3.546875 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # Active Record Migrations
# Create, connect to, and manipulate a SQLite database using Active Record
# Using activerecord gem create a mapping between our db and modle
# Migrations are a convenient way for you to alter your db in a structured and organized manner
# Migration allows you to describe transformations us... | true |
328a4fefea90ba92870c987330b5e6c2507a9126 | Ruby | carlhume/fun_with_gosu | /prototype/play_screen.rb | UTF-8 | 919 | 2.765625 | 3 | [] | no_license | require_relative 'camera'
require_relative 'map'
require_relative 'tank'
class PlayScreen < Screen
def initialize( game )
super( game )
@tank = Tank.new( game )
@camera = Camera.new( game, @tank )
@map = Map.new( game )
end
def update
@camera.update
@game.w... | true |
db2e967dc3076aa99be1a9559faa88a697c55feb | Ruby | HelenKing029/LLC-Ruby-Workshop-Exercises | /ex4_emissions_comparison.rb | UTF-8 | 618 | 3.828125 | 4 | [] | no_license | # Require the csv library
require 'csv'
# Open the 'no-emissions.csv' with a foreach loop
CSV.foreach("./no-emissions.csv") do |row|
# Loop through each of the rows
country = row [0].to_s
emissions2002 = row [1].to_i
emissions2012 = row [2].to_i
# Compare the integer in the second (row[1]) with the integer i... | true |
0b4823ccf98c9fb32e43936b65b19ce91aba1393 | Ruby | fog/fog | /lib/fog/cloudsigma/models/price_record.rb | UTF-8 | 1,109 | 2.5625 | 3 | [
"MIT"
] | permissive | require 'fog/cloudsigma/nested_model'
require 'bigdecimal'
module Fog
module Compute
class CloudSigma
class PriceRecord < Fog::CloudSigma::CloudsigmaModel
attribute :resource, :type => :string
attribute :multiplier, :type => :integer
attribute :price, :type => :string
attrib... | true |
6cc5288a21eb3a52c828b3c70edca4f9172fb0bf | Ruby | ifyouseewendy/algs4ruby | /test/stack_and_queue/queue_test.rb | UTF-8 | 1,335 | 3 | 3 | [
"MIT"
] | permissive | require 'test_helper'
module Algs4ruby
class QueueTest < MiniTest::Test
attr_reader :queues
def setup
@queues = Queue::STRATEGIES.map{|strategy| Queue.new(strategy)}
end
def data
@data ||= DATA.readline.strip.split
end
def test_size
queues.each do |queue|
assert_e... | true |
5b743ac1a1372ed3fbb5446b1d6a4bf720d4e61a | Ruby | wfwalker/birdwalker3 | /test/unit/location_test.rb | UTF-8 | 1,247 | 2.75 | 3 | [] | no_license | require File.dirname(__FILE__) + '/../test_helper'
class LocationTest < ActiveSupport::TestCase
fixtures :locations, :taxons, :trips, :sightings, :counties, :states, :photos
def setup
@first = locations(:location_one)
@second = locations(:location_two)
end
def test_county_association
assert_equal... | true |
ab6781dcbcffe5f412d36825eac8ba79199b64f6 | Ruby | jordicucala/ruby-katas | /First Kata/Jordi/regexp.rb | UTF-8 | 430 | 3.0625 | 3 | [] | no_license | array_chars = ['407-555-1212','407-555-1212','434-555-1212','457-555-1212', '321-555-1212']
array_chars.map{|chars| p chars.match(/^(407|321)-555-1212$/)}
emails = ['Sara@example.COM','sara@example.com', 'sara@example.net' , 'sara@example.org', 'sara.example.edu', 'sara@example!com', 'sara@example.comlasada']
emails... | true |
080430447951dcac5b90da5fefcbc154e2a8d86c | Ruby | dmbf29/hospital_471 | /patient.rb | UTF-8 | 372 | 3.046875 | 3 | [] | no_license | class Patient
attr_reader :name
attr_accessor :room, :id
def initialize(attributes = {})
@id = attributes[:id]
@name = attributes[:name]
@cured = attributes[:cured] || false
end
def cured? #reader
@cured
end
def cure!
@cured = true
end
end
# Patient.new('Seigo', 12, true, "A-", f... | true |
60b700b2049659b11cc5b2ec083e95b7fe3f6efc | Ruby | avioli/opal | /lib/opal/command.rb | UTF-8 | 5,630 | 3.03125 | 3 | [
"MIT"
] | permissive | require 'optparse'
require 'fileutils'
require 'opal/bundle'
require 'opal/builder'
require 'opal/version'
module Opal
# Command runner. When using the `opal` bin file, this class is used to
# delegate commands based on the options passed from the command line.
class Command
# Valid command line arguments
... | true |
87efac41f26edf1405c59beabeb021b511bab408 | Ruby | CareyCosta/Bitmaker-2018 | /oop/player.rb | UTF-8 | 1,024 | 3.5625 | 4 | [] | no_license | class Player
def initialize
@gold_coins = 0
@health_points = 10
@lives = 5
end
def gold_coins
return @gold_coins
end
def health_points
return @health_points
end
def lives
return @lives
end
def level_up
@lives += 1
puts "your lives are at #{@lives}"
end
def col... | true |
fa472d315714a2a44c0a8a42fed8792bb6aa2931 | Ruby | xcart/xcart-docs | /_plugins/swagger_jekyll/schema/number.rb | UTF-8 | 1,083 | 2.78125 | 3 | [] | no_license | require_relative '../schema'
module SwaggerJekyll
class Schema::Number < Schema
def compact_type
out = type
if has_min? && has_max?
out << " (#{min_display_left} n #{max_display_right})"
elsif has_min?
out << " (n #{min_display_right})"
elsif has_max?
out << " (n ... | true |
96c8f84ddb4489e75790c2891cb4b1b2c6436d89 | Ruby | JaredShay/fubby | /lib/fubby/lazy.rb | UTF-8 | 1,018 | 3.015625 | 3 | [
"MIT"
] | permissive | require_relative './core.rb'
require_relative './std_lib.rb'
module Lazy
C = Class.new { extend Core }
private_constant :C
S = Class.new { extend StdLib }
private_constant :S
# lazify :: (a -> b) -> [a] -> Int -> [c]
def lazify
->(fx) {
C.curry.(
->(fy, xs, n) {
fx.call(fy, nt... | true |
d6e8b926a8092bcd0315af3f52953bb322c41125 | Ruby | bmsheets/W2D3 | /poker/spec/card_spec.rb | UTF-8 | 402 | 2.921875 | 3 | [] | no_license | require 'rspec'
require 'card'
describe Card do
subject(:card) { Card.new(:ace, :spades) }
describe "#initialize" do
it "accepts a value" do
expect(card.value).to eq(:ace)
end
it "accepts a suit" do
expect(card.suit).to eq(:spades)
end
end
describe "#to_s" do
it "prints a su... | true |
4526cb5fc79b2484179c83d2b75ba2fc2146892a | Ruby | josephdlawson21/oo-my-pets-web-121117 | /lib/fish.rb | UTF-8 | 213 | 2.90625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require_relative "cat"
require_relative "dog"
require_relative "owner"
require "pry"
class Fish
attr_reader :name
attr_accessor :mood
def initialize(name)
@name = name
@mood = "nervous"
end
end
| true |
fb934f544641f5f7b83ffbd08f2a89070575f7ec | Ruby | AlexanderLit/codebreaker | /lib/codebreaker/marker.rb | UTF-8 | 1,249 | 3.484375 | 3 | [
"MIT"
] | permissive |
module Codebreaker
class Marker
CODEBREAKER_WINS_MESSAGE = 'You won!'
def initialize(secret, guess)
@secret = secret
@guess = guess
@secret = @secret.split('')
@guess = @guess.split('')
end
def exact_match_count
if !@exact_match_counter
count = 0
4.times do |... | true |
42b21b415703688be554bcbfb380e84bc7251aa7 | Ruby | okb/Pomerania | /lib/Serialization/lazy_loader.rb | UTF-8 | 1,147 | 2.609375 | 3 | [
"MIT"
] | permissive | module Pomerania::Serialization
class LazyLoader
def initialize(property_definition,json_definition,headers,schema)
@property_definition=property_definition
@json_definition=json_definition
@headers=headers
@schema=schema
@value=nil
end
def retrieve
if(@value==nil)
... | true |
7ed2a5a9c7da3a50d8de25c7b72e23503f44baa7 | Ruby | LouisaBarrett/sales_engine_dependency_sketch | /lib/merchant_repository.rb | UTF-8 | 309 | 2.65625 | 3 | [] | no_license | class MerchantRepository
attr_reader :engine
def initialize(engine)
@engine = engine
end
def merchants
[ Merchant.new({:id => 1}, self) ]
end
def find_by_id(id)
merchants.detect{|m| m.id == id}
end
def items_for(merchant)
engine.items_for_merchant_id(merchant.id)
end
end | true |
769d9872e75b1ba04a047fca0be0246f911ace55 | Ruby | isaacsanders/data_structures | /lib/data_structures/binary_search_tree.rb | UTF-8 | 3,543 | 3.375 | 3 | [
"MIT"
] | permissive | module DataStructures
class BinarySearchTree
attr_reader :root
def insert(element)
if has_root?
root.insert(element)
else
@root = DataStructures::BinarySearchTree::Node.new(element)
true
end
end
def remove(element)
if has_root?
@root = root.rem... | true |
03e93a98460239e9ebd2bfd9bad925f63f8b228a | Ruby | sparkleformation/sparkle_formation | /lib/sparkle_formation/sparkle_struct.rb | UTF-8 | 6,466 | 2.53125 | 3 | [
"Apache-2.0"
] | permissive | require "sparkle_formation"
require "attribute_struct/monkey_camels"
class SparkleFormation
# SparkleFormation customized AttributeStruct
class SparkleStruct < AttributeStruct
# AWS specific struct
class Aws < SparkleStruct
include SparkleAttribute
include SparkleAttribute::Aws
end
#... | true |
5214c2641178c12ceb51124638e07f8a77856cdd | Ruby | w-zengtao/RubyNote | /Rails/join.rb | UTF-8 | 1,175 | 2.71875 | 3 | [] | no_license | # eg 关于SQL的 join 可以参看这里 http://www.w3school.com.cn/sql/sql_join.asp
#
# 分类
class Category < ActiveRecord::Base
has_many :posts
end
# 文章
class Post < ActiveRecord::Base
belongs_to :category
has_many :comments
has_many :tags
end
# 评论
class Comment < ActiveRecord::Base
belongs_to :post
has_one :guest
end
... | true |
1407bfeaab149bdab338dab1c2ee4180ca8c015f | Ruby | mannut2014/Leetcode | /ruby/easy/paint_house.rb | UTF-8 | 498 | 3.1875 | 3 | [
"MIT"
] | permissive | # @param {Integer[][]} costs
# @return {Integer}
def min_cost(costs)
return 0 unless !costs.empty?
prev_red, prev_blue, prev_green = costs[0][0], costs[0][1], costs[0][2]
for i in 1..costs.length-1
red = [prev_blue, prev_green].min + costs[i][0]
blue = [prev_red, prev_green].min + costs[i][1... | true |
c8a9009b3aa9920506ff217b5bd6514debfc86c5 | Ruby | kilometro28/learningruby | /11_hashes/7_the_length_and_empty?_methods.rb | UTF-8 | 198 | 2.953125 | 3 | [] | no_license | # length and empty? methods
shopping_list = {bananas: 5, oranges: 10, carrots: 3, crackers: 15}
vegan_shopping_list = {}
p shopping_list.length
p shopping_list.empty?
p vegan_shopping_list.empty?
| true |
f8e14638fcee9b899a3f0fb064c28550c81a6a53 | Ruby | elcuervo/flag | /lib/flag.rb | UTF-8 | 3,547 | 2.75 | 3 | [] | no_license | require "zlib"
require "redic"
module Flag
FEATURES = "_flag:features".freeze
RedisGoneError = StandardError
Members = Struct.new(:name) do
USERS = "users".freeze
GROUPS = "groups".freeze
def <<(item)
Flag.execute do |store|
if item.to_s.end_with?("%")
store.call("HSET", F... | true |
46a7790787c5914341c9a68b22987187b21d0e23 | Ruby | Polkendotts/W04D4 | /W4D4/TTD/spec/exe_spec.rb | UTF-8 | 1,123 | 3.59375 | 4 | [] | no_license | require 'exe'
require 'rspec'
# take in an array
# removes dupes- subject:[1, 2, 1, 3, 3] => result:[1, 2, 3]
# input arr is not the same obj id as output arr
describe "my_uniq" do
let(:arr) {[1, 2, 1, 3, 3]}
it "should take in an array as an argument" do
expect{my_uniq(arr)}.to_not raise_error(Arg... | true |
c07f22b7e98c984be2230b56cbe792427d696302 | Ruby | oTnTh/rgd | /test/test_copy_rotated.rb | UTF-8 | 404 | 2.578125 | 3 | [
"BSD-2-Clause"
] | permissive | # coding: utf-8
m = RGD::Image.create_truecolor(50, 50)
m.filled_rectangle(0, 0, 50, 50, 0xFF0000)
m.transparent = 0xFF0000
m.filled_ellipse(25, 25, 30, 40, 0x50FFFFFF)
n = RGD::Image.create_truecolor(50, 50)
n.copy_rotated(m, 25, 25, 0, 0, 50, 50, 60)
basename = File.basename(__FILE__, '.rb')
t = RGD::Im... | true |
15ce20dc32553945f04aa9b70775dcfcdb0369e2 | Ruby | aronchee/challenges | /Week 1 Get to know Ruby/Day 3/binary-search/binary-search.rb | UTF-8 | 1,023 | 3.859375 | 4 | [] | no_license | # Place your solutions here
# def binary_search(num,nums)
# nums.sort
# low = 0
# high = nums.length-1
# mid = (low+high)/2
# if num == nums[mid]
# low = low
# high = high
# elsif num < nums[mid]
# high == mid
# mid = (low+high)/2
# elsif num > nums[mid]
# low == mid
# mid = (low+high)... | true |
4dc8ef902f949c4e0192a6017f2345e30bc2eb04 | Ruby | okazzz/ruby-stardigio-tools | /rename_csv.rb | ISO-8859-7 | 3,398 | 2.53125 | 3 | [] | no_license | #!/usr/local/bin/ruby
# usage ruby rename.rb date ch startindex
#
# ex. ruby rename.rb 20071231 401
require 'rubygems'
require 'mp3info'
require 'fileutils'
require 'kconv.rb'
require 'net/http'
require 'csv'
def screen_mp3(files)
n_files = files.size
isEdge = false
(n_files/2).downto(0)... | true |
63861e3b94c73c984b3e5fe49d564a6a45af0dec | Ruby | c2cn/PDFNetWrappers | /Samples/PDF2HtmlTest/RUBY/PDF2HtmlTest.rb | UTF-8 | 4,471 | 2.890625 | 3 | [] | no_license | #---------------------------------------------------------------------------------------
# Copyright (c) 2001-2021 by PDFTron Systems Inc. All Rights Reserved.
# Consult LICENSE.txt regarding license information.
#---------------------------------------------------------------------------------------
require '../../..... | true |
52eeb9daead199518324bd10fec1c615dc40ccb4 | Ruby | aenain/simple_email_exception_notifier | /lib/simple_email_exception_notifier/message.rb | UTF-8 | 1,008 | 2.765625 | 3 | [
"MIT"
] | permissive | require_relative 'formatter'
module SimpleEmailExceptionNotifier
class Message
def initialize(formatter = Formatter.new)
@content = []
@formatter = formatter
end
def self.compose(formatter = Formatter.new, &block)
message = self.new(formatter)
block.call(message)
message.to... | true |
06d7fca5509613fe65866de459c5a8a09c2f6ffd | Ruby | fookiee/10min_crawler | /first_cr.rb | UTF-8 | 2,003 | 2.734375 | 3 | [
"MIT"
] | permissive | # -*- cpding: utf-8 -*-
require 'cgi'
require 'open-uri'
require 'rss'
# page_source = open('samplepage.html', &:read)
def parse(page_source)
# 日付取得
dates = page_source.scan(
%r!(¥d+)年 ?(¥d+)月 ?(¥d+)日<br/>!)
# タイトル取得
url_titles = page_source.scan(
%r!^<a href="(.+?)">(.+?)</a><br/>!)
# 各要素の対応を付ける
... | true |
53c8a384b012502a57bf2e784f61f7abb90bd2d6 | Ruby | mjp90/artist-tracker | /lib/apis/twitter_api/request.rb | UTF-8 | 1,053 | 2.515625 | 3 | [] | no_license | module Apis
module TwitterApi
class Request
attr_reader :error, :formatted_response
def initialize(client:, request_name:, response_formatter:, arg: nil, options: nil)
@client = client
@request_name = request_name
@response_formatter = response_formatter
... | true |
47da84c291f85ae05e703c150a2aecfd9f86108c | Ruby | za4emnik/sinatra | /classes/Factory.rb | UTF-8 | 398 | 2.703125 | 3 | [] | no_license | class FactoryType #factory class
#singleton
@@instance = FactoryType.new()
def self.getInstance
return @@instance
end
private_class_method :new
def getObj #get new object
case Input.getInstance.operation.to_s
when 'plus'
Plus.new
when 'minus'
Minus.new
when 'div'
Div.new
... | true |
fcafc95d6d67adc4bbef88d5e4546f7177f865a7 | Ruby | veplechuc/tutorias | /src/string_to_a.rb | UTF-8 | 114 | 3.46875 | 3 | [] | no_license |
class String
def foo
'foo'
end
def to_a
split('')
end
end
puts String.new.foo
puts 'hello'.to_a | true |
c81730c3d90f8121b92d42a6ba81e00867ebbc68 | Ruby | JCGuest/headlines | /lib/headlines/source.rb | UTF-8 | 342 | 2.546875 | 3 | [
"MIT"
] | permissive | class Headlines::Source
attr_accessor :name, :url, :headlines_ary, :url_ary
@@all = []
def initialize(name, url, headlines_ary, url_ary)
@name = name
@url = url
@headlines_ary = headlines_ary
@url_ary = url_ary
@@all << self
end
def self.all
@@al... | true |
95a60fa856b42d415725434282e77ab83f415fe9 | Ruby | rmwerner18/Audition-App | /app/models/audition.rb | UTF-8 | 1,007 | 2.625 | 3 | [] | no_license | class Audition < ApplicationRecord
belongs_to :event
belongs_to :actor
validates :time, uniqueness: { scope: :actor, message: "This actor already has an audition at this time" }
validates :time, uniqueness: { scope: :event, message: "There is already an audition for this event at this time" }
valida... | true |
ecb0aa1bb6bffcec666c9eeabad52bda50339dc1 | Ruby | ealwafai/viewing_party | /app/facades/movie_facade.rb | UTF-8 | 1,190 | 2.9375 | 3 | [] | no_license | class MovieFacade
def self.top_40_movies
movies = MovieService.top_rated_movies('1')[:results] + MovieService.top_rated_movies('2')[:results]
movies.map do |movie_data|
Movie.new(movie_data)
end
end
def self.search_by_title(title)
movies = MovieService.movie_search(title, 1)[:results] + Mov... | true |
28336cbaf0b03d3e9c20e0a2e54595a4e77a1d76 | Ruby | ktalmage/learn-co-sandbox | /class.rb | UTF-8 | 256 | 3.53125 | 4 | [] | no_license | class Dog
attr_accessor :name, :owner
def initialize(name)
@name = name
end
def bark
"Woof!"
end
def get_adopted(owner_name)
self.owner = owner_name
end
end
dog = Dog.new("fido")
puts dog.owner
| true |
82bfb063613a82c2825ce5c310f7f61482efbdde | Ruby | GoWebMe2020/twitter_ruby | /spec/tweet_spec.rb | UTF-8 | 2,649 | 2.9375 | 3 | [] | no_license | require 'tweet'
require 'comment'
describe Tweet do
let(:comment_class) { double(:comment_class) }
describe '.all' do
it 'returns a list of tweets' do
connection = SQLite3::Database.new "twitter_test.db"
tweet = Tweet.create(tweet:'This is test tweet 1')
Tweet.create(tweet:'This is test t... | true |
ac7a66f67a479e277b004bf776fdcf1e5581c9a7 | Ruby | johan--/abm-portal | /app/models/user.rb | UTF-8 | 911 | 2.828125 | 3 | [
"MIT"
] | permissive | class User
include ActiveModel::AttributeMethods
include ActiveModel::Model
include ActiveModel::SerializerSupport
ATTRIBUTES = [
'address',
'email',
'id',
'name',
'occupation',
'year_hunting'
]
attr_accessor *ATTRIBUTES
# Data Access Class Methods
def self.all
raw = UserA... | true |
e2eaef79500b075d7cfd831b10127360f981ab5c | Ruby | saschakala/autism_resource_backend | /app/models/tag.rb | UTF-8 | 998 | 2.59375 | 3 | [
"MIT"
] | permissive | class Tag < ApplicationRecord
has_many :source_tags
has_many :sources, through: :source_tags
has_many :book_tags
has_many :books, through: :book_tags
has_many :article_tags
has_many :articles, through: :article_tags
has_many :sma_tags
has_many :social_media_accounts, through: :sma_tag... | true |
e163611c8f1e0db71eee482a7a647ae2c1063eb7 | Ruby | EmmaJean/Ruby-Assignment | /glob.rb | UTF-8 | 231 | 2.78125 | 3 | [] | no_license | #Emma Mossinger
def glob_match(filenames, pattern)
pattern.gsub!(/[\*\?\.]/, ‘*’ => ‘.*’, ‘.’ => ‘\.’, ‘?’ => ‘.’)
regex = Regexp.new(pattern)
filenames.select do |filename|
filename =~ regex
end
end
| true |
321a2af79290ab3d659f341f73b26e453bd6f717 | Ruby | UHERO/udaman | /app/lib/download/integer_pattern_processor.rb | UTF-8 | 4,247 | 3.046875 | 3 | [] | no_license | class IntegerPatternProcessor
def initialize(pattern)
@pattern = pattern.to_s
end
def compute(index, cached_files = nil, handle = nil, sheet = nil)
Integer(@pattern) ## if it's an integer literal, just return that, else... complication below
rescue
p = @pattern.split(':').map {|w| Integer(w) resc... | true |
894097f0b6df4bd40a5dd4e7de7fb201f8e5d73a | Ruby | ibc/AsyncEngine | /test/test_timer.rb | UTF-8 | 2,626 | 2.890625 | 3 | [] | no_license | require "ae_test_helper"
class TestTimer < AETest
def test_01_timer_fires
t1_executed = false
AE.run do
t1 = AE::Timer.new(0.01) { t1_executed = true ; assert_false t1.alive? }
assert_true t1.alive?
AE.add_timer(0.02) { assert_false t1.alive? }
AE.add_timer(0.03) { assert_false t1.... | true |
2c660a9c399162c73bd47b19d77c4270de8fe8e9 | Ruby | dry-rb/dry-core | /spec/support/memoized.rb | UTF-8 | 985 | 2.75 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # frozen_string_literal: true
class Memoized
include Module.new {
def test9
# NOP
end
}
include Dry::Core::Memoizable
def test1(arg1, *args, kwarg1:, kwarg2: "default", **kwargs, &block)
# NOP
end
def test2(arg1, arg2 = "default", *args, &block)
# NOP
end
def test3(&block)
... | true |
b3c1007410e2eddf0888f2f9735e6a76edece8b5 | Ruby | diegojromerolopez/babik | /lib/babik/queryset/components/aggregation.rb | UTF-8 | 6,055 | 2.90625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
# Common module for Babik library
module Babik
# QuerySet module
module QuerySet
# A set of aggregation operations
class Aggregation
attr_reader :model, :functions
# Construct a new aggregation
# @param model [Class] class that inherits from ActiveRecord::B... | true |
9be1f8b435ad3ba3a325886ce9eec18ddc911ab6 | Ruby | complikatyed/cheers_take3 | /test/units/test_birthday_parser.rb | UTF-8 | 1,125 | 2.921875 | 3 | [
"MIT"
] | permissive | require_relative '../test_helper'
require_relative '../../lib/birthday_parser'
class TestBirthdayParser < Minitest::Test
def test_parse_not_a_date
assert_nil BirthdayParser.parse("09/31")
end
def test_non_birthday
assert_nil BirthdayParser.parse("Anne")
end
def test_backwards_day
assert_nil Bi... | true |
e2e3ec03987044819a24859f39e2597f58a28e47 | Ruby | martijnrusschen/pushover | /spec/lib/pushover/user_spec.rb | UTF-8 | 1,256 | 2.5625 | 3 | [
"MIT",
"Beerware"
] | permissive | require 'spec_helper'
describe "user" do
before(:each) do
Bini::Config.clear
Bini::Options.clear
User.current_user = nil
end
it "can add a user to the Config[:users] hash." do
User.add "foo", "bar"
Bini::Config[:users]["foo"].should eq("bar")
end
it "can remove a user from the hash." do
User.add "fo... | true |
423e87e84e41a022704167aeba00e1d76292b58f | Ruby | wwood/bioruby-tm_hmm | /bin/bio-tm_hmm | UTF-8 | 2,260 | 2.96875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | #!/usr/bin/env ruby
# Author:: Ben J. Woodcroft
# Copyright:: 2011
# License:: The Ruby License
require 'rubygems'
require 'bio'
require 'bio-tm_hmm'
require 'optparse'
# If being run directly instead of being require'd,
# output one transmembrane per line, and
# indicate that a particular protein has no transmembra... | true |
c9c7528059cfcfdd723cb74915a221f83b411dc0 | Ruby | m-mrcr/exercisms | /sieve/sieve.rb | UTF-8 | 176 | 3.203125 | 3 | [] | no_license | class Sieve
def initialize(limit)
@limit = limit
end
def primes
set = (2..@limit).to_a
set.each { |p| p.upto(@limit) { |n| set.delete(p * n) } }
end
end
| true |
08e63e740552d7b01a0bdf3e38b36272ae6718b8 | Ruby | brettgrigsby/ruby-exercises | /command-query/product.rb | UTF-8 | 115 | 2.515625 | 3 | [
"MIT"
] | permissive | class Product < Struct.new(:type, :price)
def price
self[:price]
end
def type
self[:type]
end
end
| true |
32c5856ba3a185cb4411fc132796928795d44073 | Ruby | tamu222i/ruby01 | /tech-book/5/5-253.rb | UTF-8 | 98 | 3.296875 | 3 | [] | no_license | # countメソッドとfirstメソッド
[1,2,3,4,5].count
[1,2,3,4,5].first
[1,2,3,4,5].first(3)
| true |
bedf0ae3d93a028f76e5a27b9c81b67d35c52c92 | Ruby | fabianoalmeida/little_world | /app/models/friend.rb | UTF-8 | 1,341 | 2.75 | 3 | [] | no_license | class Friend < ActiveRecord::Base
attr_accessible :latitude, :longitude, :name
validates :name, :latitude, :longitude, :presence => true
validates :latitude,
:numericality => true,
:uniqueness => { :scope => :longitude }
validates :longitude,
:numericality => true,
... | true |
edaab1c07c0ba1764f682029c3db66d110c1e9b8 | Ruby | pseegaha/LGTM-Generator-from-Dropbox | /lib/generator.rb | UTF-8 | 2,832 | 2.890625 | 3 | [] | no_license | require './lib/string.rb'
module Generator
module Base
def drawer
# set common attributes
Magick::Draw.new {
self.font = 'Helvetica'
self.font_weight = Magick::BoldWeight
self.stroke = 'black'
self.gravity = Magick::SouthEastGravity
}
end
def attach_tran... | true |
374752b2918cd7283f42a51d2832f66df0521bf2 | Ruby | gitvar/back-end-development | /assessment-109-revision/guess_a_number.rb | UTF-8 | 1,134 | 4.75 | 5 | [] | no_license | # The program will first randomly pick a number between 1 and 100. The program will then ask the user to guess the number. If the user guesses correctly, the program will end. If the user guessed too high or low, the program will respond with "Your number is to high" or "Your number is to low" respectively, and allow t... | true |
7e281d317d4a84a3d414d91193365ecc187b4c37 | Ruby | dieulinh/Mortgage-Club | /app/services/completed_loan_services/tab_assets.rb | UTF-8 | 3,262 | 2.71875 | 3 | [] | no_license | module CompletedLoanServices
class TabAssets
attr_accessor :assets, :rental_properties,
:primary_property, :subject_property,
:own_investment_property, :loan_refinance
def initialize(args)
@assets = args[:assets]
@subject_property = args[:subject_property]
... | true |
8bce14c080464632107f165d61e2307605171ead | Ruby | GittiMcHub/ruby-mastermind | /test/TestCodebreakerKI.rb | UTF-8 | 1,372 | 3.203125 | 3 | [
"MIT"
] | permissive | require 'test/unit'
require_relative '../Turn'
require_relative '../Game'
require_relative '../CodebreakerKI'
require_relative '../CodebreakerKIRandom'
require_relative '../CodeMakerKI'
class TestCodebreakerKI < Test::Unit::TestCase
def setup()
@dummy_maker = CodemakerKI.new("TÜV Alt.F4")
@amount_of_game... | true |
ae15e2600440f22ab965eb4421e419549c961445 | Ruby | siuying/rubberband-audio | /lib/rubberband/processor.rb | UTF-8 | 1,451 | 2.9375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require 'open3'
require 'shellwords'
module RubberBand
class Processor
attr_reader :command
def initialize(input_file, output_file, options = Options.new)
@input_file = input_file
@output_file = output_file
@errors = []
if options.is_a?(String) || options.is_a?(Options)
@ra... | true |
27b186ec1108c97de1907b93b69551ab1cdb4dde | Ruby | Jenietoc/Basic-sintaxis-of-Ruby | /delimitadores.rb | UTF-8 | 63 | 2.859375 | 3 | [] | no_license | num1 = 0; num2 = 1; num3 = 2
puts num1; puts num2; puts num3
| true |
6e2733d948c40c5d99d30a9e46e07e5aed14c94a | Ruby | solufemi91/sparta-rspec-practice | /euler/lib/euler.rb | UTF-8 | 373 | 3.859375 | 4 | [] | no_license | #Find the sum of all the multiples of 3 and 5 between a certain range
class Euler
def initialize
@multipleOf3and5 = []
end
def findSumOfMultiplesBetweenRange(num1, num2)
(num1..num2).each do |x|
if x % 3 == 0
@multipleOf3and5.push(x)
elsif x % 5 == 0
@multipleOf3and5.push(x)
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.