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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
508d661e2f9ef9c7ba66ddae1ba069c3d01fc2e8 | Ruby | brettapeters/dinodex | /lib/dinodex.rb | UTF-8 | 1,378 | 2.765625 | 3 | [] | no_license | class DinoDex
require 'json'
FILTERS = {
:period => %w(jurassic cretaceous triassic permian),
:'period subdivision' => %w(oxfordian albian),
:continent => %w(north\ america south\ america asia africa europe),
:diet => %w(carnivore herbivore),
:'diet subtype' => %w(piscivore insectivore),
:w... | true |
16fb6258ff49525f78567083713dc9836e533309 | Ruby | saaitt/rubyTest | /scrapper.ru | UTF-8 | 2,612 | 3.171875 | 3 | [] | no_license | require 'nokogiri'
require 'json'
require 'open-uri'
require 'cgi'
cityURLs = [
"united-states/illinois/chicago-2379574",
"japan/tokyo-prefecture/tokyo-1118370",
"united-kingdom/england/london-44418"
]
def getTenDaysOfWeather(cityURL)
doc = Nokogiri::HTML(URI.open('https://www.yahoo.com/news/weather/... | true |
13871be4dd03162400f86deea4f4dcd67927eeb5 | Ruby | FournierA-dev/Flavie-Crochette | /app/models/event.rb | UTF-8 | 1,318 | 2.578125 | 3 | [] | no_license | class Event < ApplicationRecord
#Validations
validates :start_date, presence: true
validates :duration, presence: true
validate :event_specific_validation
validates :title, presence: true, length: {in: 5..140}
validates :description, presence: true, length: {in: 20..1000}
validates :price, presence: true... | true |
bdd00eb8ea1e7375557527de733d6d60d3caca44 | Ruby | cout/become | /test/test_become.rb | UTF-8 | 587 | 2.984375 | 3 | [
"MIT"
] | permissive | require 'test/unit'
require 'become'
class BecomeTest < Test::Unit::TestCase
class Foo
def initialize
@a = 1
@b = 2
end
end
class BarBase
end
class Bar < BarBase
def initialize
@c = 3
@d = 4
end
end
def test_become
foo = Foo.new
bar = Bar.new
foo.be... | true |
be35a20abca8a6c8e50991cbdd31c843e22654b1 | Ruby | pdornfel/shapes_challenge | /lib/square.rb | UTF-8 | 96 | 2.8125 | 3 | [] | no_license | class Square
def initialize(side)
@side = side
end
def area
@side **2
end
end | true |
86258faae9e380251e1f52757d14f2d6addbec9e | Ruby | Chitroopa/Word-Definer | /spec/word_definer_spec.rb | UTF-8 | 3,145 | 2.78125 | 3 | [
"MIT"
] | permissive | require('rspec')
require('word_definer')
describe('Definition') do
describe("#attr_reader") do
it("will return definition") do
test_definition = Definition.new({:definition=> "definition of word"})
expect(test_definition.definition()).to eq("definition of word")
end
end
end
describe('Word') do... | true |
2aa89a19067e42ca6947a6c17020953fc0ff09df | Ruby | sealink/ruby_core_extensions | /lib/ruby_core_extensions/hash.rb | UTF-8 | 460 | 3.015625 | 3 | [
"MIT"
] | permissive | class Hash
def map_key_value(key_method, value_method = nil)
value_method ||= key_method
each.with_object({}) do |(k, v), new_hash|
new_hash[k.send(key_method)] = v.send(value_method)
end
end
def map_key(method)
each.with_object({}) do |(k, v), new_hash|
new_hash[k.send(method)] = v
... | true |
aacb2ae1acdf038f283d4183370a32fdf3f4a397 | Ruby | karthickpdy/CP | /valera_seller.rb | UTF-8 | 181 | 2.96875 | 3 | [] | no_license | n,v = gets.split(" ").map(&:to_i)
sellers = []
(1..n).each do |s|
sellers << s if gets.split(" ").map(&:to_i)[1..-1].any?{|x| v > x}
end
puts sellers.count
puts sellers.join(" ")
| true |
53672ca8416da62e546e03b483a3411ff3d98d49 | Ruby | fgrehm/dotfiles | /bin/archive-dir | UTF-8 | 659 | 2.53125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
real = 0.0
compressed = 0.0
errors = []
skip = [ 'Arquivo' ]
console_output = $stdout
Dir['*/'].sort.each do |dir|
file = dir[0..-2]
next if skip.any? {|s| file == s }
puts "7zr a -mx9 #{file}.7z #{dir}"
`7zr a -mx9 #{file}.7z #{dir}`
if (`7zr t #{file}.7z` =~ /Everything is Ok(?:... | true |
a5aa64f10741d7459401441cf7eb6897fbde1e9f | Ruby | jeffrothwell/ruby-fundamentals-methods | /ex6.rb | UTF-8 | 348 | 3.859375 | 4 | [] | no_license | puts "Give me a Fahenheit temperature and I'll tell you what it is in Celsius, a more sensible temperature unit"
user_temp = gets.to_i
def convert_temp(ftemp)
ctemp = (ftemp - 32) * 5 / 9
end
puts "#{user_temp} degrees F is equal to #{convert_temp(user_temp)} degrees C\nNote that this is approximate because I can ... | true |
556f95dd3d5f6d562d383f9491345c940a8a2eec | Ruby | kimallen/phase-0 | /week-4/leap-years/my_solution.rb | UTF-8 | 488 | 4.09375 | 4 | [
"MIT"
] | permissive | # I worked on this challenge [by myself, with: Marcel Galang ].
# Your Solution Below
def leap_year?(number)
if ((number % 4) == 0) && ((number % 100) != 0)
puts "This is a leap year."
true
elsif ((number % 400) == 0)
puts "This is a leap year."
true
elsif ((number % 4) == 0) && ((number % 100)... | true |
0724c60c9aba2449b9e660b5a7c0fb83102ea4ee | Ruby | sinefunc/hyde-legacy | /lib/hyde/utils.rb | UTF-8 | 962 | 2.609375 | 3 | [
"MIT"
] | permissive | module Hyde
module Utils
protected
def escape_html(str)
str.
gsub('&', '&').
gsub('"', '"').
gsub('<', '<').
gsub('>', '>').
gsub("'", '&39;')
end
def same_file?(a, b)
File.expand_path(a) == File.expand_path(b)
end
def matches_... | true |
f3fa8ef63de3abc993c6ef6e79aab9ee30690124 | Ruby | jhund/rails-data-explorer | /spec/rails_data_explorer/data_type/categorical_spec.rb | UTF-8 | 3,423 | 2.65625 | 3 | [
"MIT"
] | permissive | require_relative '../../helper_no_rails'
class RailsDataExplorer
class DataType
describe Categorical do
let(:dt) { Categorical.new }
let(:values) { ['a', 'a', 'b', 'c'] }
describe "#descriptive_statistics" do
let(:desc_stats) {
dt.descriptive_statistics(values)
}
... | true |
0a4aeb3ac8a21bbd8ab8a5c463c77a6d937add9e | Ruby | MaximePierron/Scraping | /LeScrapperFou/lib/cher_depute.rb | UTF-8 | 3,814 | 2.890625 | 3 | [] | no_license | #appelle nokogiri pour le scrapping
require 'nokogiri'
#appelle open uri nativement dans ruby pour ouvrir un URL
require 'open-uri'
def get_deputy_email (deputy_url)
email_html = deputy_url.xpath('//section[1]/div/article/div[3]/div/dl/dd[4]/ul/li[2]/a').text #l'adresse mail des députés se trouvent sur ce xpath po... | true |
86b72344f373d9e07bc892db30caef31a94c2d87 | Ruby | Cerunnos/ruby-class-variables-and-class-methods-lab-web-010818 | /lib/song.rb | UTF-8 | 766 | 3.296875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Song
@@count=0
@@artists=[]
@@genres=[]
attr_accessor :name,:artist,:genre
def initialize(name,artist,genre)
@@count+=1
@@artists<<artist
@@genres<<genre
@name=name
@artist=artist
@genre=genre
end
def self.count
@@count
end
def self.artists
@@artists.uniq
end
... | true |
741046675e52aaf6c1106fe95a3d81d632469749 | Ruby | Neilly808/ruby | /exo_14.rb | UTF-8 | 70 | 3.21875 | 3 | [] | no_license | puts "Entrez un nombre"
i = gets.chomp.to_i
until i==0
puts i-=1
end
| true |
958c9a62d135ae70028d08f0eaa63de573163261 | Ruby | uconnjosh/expense_tracker_round2 | /spec/category_spec.rb | UTF-8 | 980 | 2.921875 | 3 | [] | no_license | require 'spec_helper'
describe 'Category' do
it 'initializes a new instance of category' do
test_category = Category.new("Fun")
test_category.should be_an_instance_of Category
end
describe '.all' do
it 'starts with an empty array' do
Category.all.should eq []
end
end
describe 'save' do
... | true |
817314866c716c647431f5574c1775893a04b6d9 | Ruby | tomoasleep/yoda | /lib/yoda/ast/parameter_kind_predicates.rb | UTF-8 | 710 | 2.53125 | 3 | [
"MIT"
] | permissive | module Yoda
module AST
module ParameterKindPredicates
# @return [Boolean]
def parameter?
%i(arg optarg mlhs).include?(self.type)
end
# @return [Boolean]
def rest_parameter?
self.type == :restarg
end
# @return [Boolean]
def keyword_parameter?
... | true |
e76503e3bca250ffee7943346f1252f30485a154 | Ruby | bingo8670/ruby_metaprogramming | /part2/greet_with_super.rb | UTF-8 | 342 | 3.46875 | 3 | [] | no_license | module Greetings
def greet
"hello"
end
end
module EnthusiasticGreetings
include Greetings
def greet
"Hey, #{super}!"
end
end
class MyClass
include EnthusiasticGreetings
end
p MyClass.ancestors # => [MyClass, EnthusiasticGreetings, Greetings, Object, Kernel, BasicObject]
p MyClass.new.greet ... | true |
d1c95a998e15df95c44769eca7fd5fca91b99e4b | Ruby | jamiepg1/smartdown | /spec/engine/state_spec.rb | UTF-8 | 1,987 | 3.046875 | 3 | [
"MIT"
] | permissive | require 'smartdown/engine/state'
describe Smartdown::Engine::State do
subject {
described_class.new(current_node: :start_state)
}
it "raises if current_node not given to constructor" do
expect { described_class.new() }.to raise_error(ArgumentError)
end
it "initializes path and responses" do
exp... | true |
bb98cbcd06af24ca693c2710a0ab02484988c516 | Ruby | jdickey/repository-support | /spec/repository/support/result_builder_spec.rb | UTF-8 | 2,316 | 2.609375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'spec_helper'
describe Repository::Support::ResultBuilder do
describe 'initialisation' do
it 'requires one parameter' do
message = /wrong number of arguments \(.+?\)/
expect { described_class.new }.to raise_error ArgumentError, message
end
it 'can be in... | true |
669bdc99989305cf371f53f20d3313f19a193082 | Ruby | w5762847/Learn | /OrginalServerCode/OrginalCode/shushanchuangqi/sscq2/Tools/Robot/Protocol/LoginPkgProtBase.rb | UTF-8 | 5,375 | 2.640625 | 3 | [] | no_license | #************************************************************************
# 工具自动生成的Ruby客户端协议代码
# File Name: LoginPkgProt.rb
# Purpose: 累计登入礼包协议
# Copyright (c) 2010-2020 上海恺英网络科技有限公司, All rights reserved.
#*************************************************************************/
require_relative '../core/... | true |
43dee19048f486cbac7d7859867d7caa24172925 | Ruby | VoronoyAlexandr/ruby | /index.rb | UTF-8 | 897 | 3.6875 | 4 | [] | no_license | array = [1,2,3,4,5,6]
array.each do |x|
puts x
end
puts "write first line"
text = gets.chomp
puts "write second line"
redact = gets.chomp
words = text.split(" ")
words.each do |word|
if word == redact
print "REDACTED"
else
print word + " "
end
end
my_hash = { "name" => "Eric",
"age" ... | true |
113dd78fd3955d2ee83780b84045e41fd1e4db3e | Ruby | amirfayek/project-euler | /p003.rb | UTF-8 | 686 | 3.84375 | 4 | [] | no_license | # k = 1
# Carmichael = (6*k+1)*(12*k+1)*(18*k+1)
# puts Carmichael
# puts 7*13*19
# def largest_prime_factor(n)
# sqrt = n**(1/2)+1
# current = sqrt
# while sqrt.reverse
# puts largest_prime_factor(13195)
def greatest_prime_factor(n)
return false if n < 1
divisor = Math.sqrt(n).floor
while divisor>=2
... | true |
f753fa29ed0f9f45fe0a6104eb35c6ff36cdfc53 | Ruby | euxx/advent_of_code | /2020/day_07/solution.rb | UTF-8 | 950 | 3.6875 | 4 | [] | no_license | input = File.readlines("./2020/day_07/input.txt")
RULES = # {color_a => {color_b => n1, color_c => n2}}
input.each_with_object({}) do |line, rules|
color = line.scan(/\A\w+ \w+/).first
sub_rules = line.scan(/(\d+) (\w+ \w+)/).map do |n, c|
[c, n.to_i]
end
rules[color] = sub_rules.to_h
end
#... | true |
f195cfcc4a5459e1423564a9385f46d7a17065d4 | Ruby | marcolee1107/su-ruby-practice | /examples/ex_604.rb | UTF-8 | 483 | 2.5625 | 3 | [] | no_license | # 當SketchUp遇見Ruby - 邁向程式化建模之路(碁峯出版)
# http://books.gotop.com.tw/v_AEC009100
# ex_604.rb - 傳回容器中的face物件
# 建立測試的Face物件
ent = Sketchup.active_model.entities
face = ent.add_face [1, 1, 1], [11, 1, 1], [11, 11, 1], [1, 11, 1]
face.pushpull 10
# 尋找Face物件中向量為+X軸的面
xface = ent.find { |ent| ent.typename == "Face" && ent.norma... | true |
f4cf02a0d932a48c386ba5e5d5d4d6246a0f2df9 | Ruby | anzaika/insectdb | /db/seed_stages/seed_third_stage.rb | UTF-8 | 2,255 | 2.8125 | 3 | [] | no_license | ########################################################
#
# Populate Div and Snp tables with data from Seq table
#
########################################################
module SeedThirdStage
include Constants
SEGS_IN_BIN = 200
def self.run
self.submit_jobs
while Resque.size(:seed) != 0 || Resque.i... | true |
28236f83223d45e76ee8fda155bbe585c6d9220d | Ruby | Domitalk/ruby-boating-school-dumbo-web-102819 | /app/models/student.rb | UTF-8 | 812 | 3.28125 | 3 | [] | no_license | class Student
@@all = []
attr_reader :first_name
def initialize(first_name)
@first_name = first_name
@@all << self
end
def self.all
@@all
end
def self.find_student(first_name)
@@all.find do |instance|
instance.first_name == first_name
e... | true |
7dac8b9dd3d405064d9e3b5e9cb01106bf054e06 | Ruby | mascot6699/news | /backend/services/content-serving/app.rb | UTF-8 | 2,045 | 2.765625 | 3 | [] | no_license | #
# ContentServingFunction
#
# Serves article content by retrieving from Amazon S3 bucket, converting
# from Markdown to HTML and returning result.
#
require 'aws-sdk-dynamodb'
require 'aws-sdk-s3'
require 'json'
require 'redcarpet'
## DyanmoDB client instance
$ddb_client = nil
## S3 Client
$s3_client = nil
$render... | true |
e87dc8c7bc8ddc18f511299b3e6189c79dfb418a | Ruby | Le6ow5k1/vm_hack_translator | /code_spitter.rb | UTF-8 | 2,515 | 3.140625 | 3 | [] | no_license | # frozen_string_literal: true
require_relative 'code_spitter/emit_arithmetic_logical_command'
require_relative 'code_spitter/emit_memory_access_command'
require_relative 'code_spitter/emit_branching_command'
require_relative 'code_spitter/emit_function_command'
require_relative 'code_spitter/emit_call_command'
require... | true |
ffc8374e44ec0b0d43829940ed834f02d8c8924a | Ruby | internetee/registry | /lib/core_monkey_patches/hash.rb | UTF-8 | 103 | 2.578125 | 3 | [
"MIT"
] | permissive | class Hash
def select_keys(*args)
select { |k, _| args.include?(k) }.map { |_k, v| v }
end
end
| true |
5624d36e85adbffc83b43fe043a432c85120068b | Ruby | jumbezee/rspec | /hero_spec.rb | UTF-8 | 345 | 2.96875 | 3 | [] | no_license | require './hero'
describe Hero do
it "has a capitalized name" do
hero = Hero.new 'mike'
expect(hero.name).to eq 'Mike'
end
it "has a health up" do
hero = Hero.new 'mike'
expect(hero.power_up).to eq 110
end
it "has a health down" do
hero = Hero.new 'mike'
expect(hero.power_d... | true |
35bc5f3b291ef241f5256420369f333844ff2b90 | Ruby | namoricoo/Coderbyte-Ruby-Rspec | /spec/palindrome_two_spec.rb | UTF-8 | 872 | 4.0625 | 4 | [] | no_license | # Using the Ruby language, have the function PalindromeTwo(str)
# take the str parameter being passed and return the string true
# if the parameter is a palindrome, (the string is the same
# forward as it is backward) otherwise return the string false.
# The parameter entered may have punctuation and symbols but
# they... | true |
d76ee6afaf864064a626e6d0782a9d0b6d23b60f | Ruby | imeisel/countdown-to-midnight-web-012918 | /countdown.rb | UTF-8 | 228 | 3.65625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def countdown(n)
while n > 0 do
puts "#{n} SECOND(S)!"
n-=1
end
"HAPPY NEW YEAR!"
end
def countdown_with_sleep(n)
while n > 0 do
puts "#{n} SECOND(S)!"
sleep(1)
n-=1
end
"Happy New Year!"
end
| true |
e098eaaeba9d83296f71de70c501eda4ca007f9e | Ruby | Joerg-Seitz/treasures.io | /app/models/geometry/edge.rb | UTF-8 | 587 | 3.125 | 3 | [
"MIT"
] | permissive | class Geometry::Edge
attr_reader :from, :to
def initialize(from, to)
@from = from
@to = to
end
def length
x_distance = (to.first - from.first)
y_distance = (to.last - from.last)
Math.sqrt(x_distance**2 + y_distance**2)
end
def offset_point_by_half_of_length(factor = 1)
[(midpoint.... | true |
9d41dd3b22434e7387546a5d0ae0b1ebed4ba9e1 | Ruby | SurajG/codeeval | /easy/set-intersection/set-intersection.rb | UTF-8 | 330 | 3.546875 | 4 | [] | no_license | # You are given two sorted list of numbers(ascending order). The lists
# themselves are comma delimited and the two lists are semicolon delimited.
# Print out the intersection of these two sets.
File.open(ARGV[0]).each_line do |line|
s1, s2 = line.split(';').map { |s| s.split(',').map(&:to_i) }
puts (s1 & s2).join... | true |
be3e75cbf1e58a15bfaa7a47b6e680565f6c0c93 | Ruby | fanfilmu/tpr2016 | /pi_mc/scripts/csv_parser.rb | UTF-8 | 1,786 | 2.828125 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'csv'
require 'pry'
data = CSV.parse File.read(ARGV[0]), headers: true
experiments = data.group_by { |row| [row['scalable'], row['problem_size']] }
def calculate_speed_up(one_core_entry, entry)
one_core_entry['time'].to_f / entry['time'].to_f * (entry['scalable'] == 'true' ? entry['proc... | true |
70fb7965593d8c529aafb1e18226295daa0b91ff | Ruby | nari19/AtCoder | /10x/106/b.rb | UTF-8 | 141 | 2.953125 | 3 | [] | no_license | n = gets.to_i
a = 0
(1..n).each do |i|
next if i.even?
count = 0
(1..i).each{ |j| count+=1 if i%j == 0 }
a += 1 if count==8
end
p a | true |
c53027c1092bac3c17405373e469be0e5db7539e | Ruby | primaulia/iterator_block | /greet.rb | UTF-8 | 393 | 3.296875 | 3 | [] | no_license | def greet(first_name, last_name)
full_name = "#{first_name.capitalize} #{last_name.upcase}"
yield(full_name, 'test')
end
greet('Prima', 'Gusta') do |param_from_yield|
puts "Hello, #{param_from_yield}"
end
greet('Sonia', 'Monteiro') do |param_from_yield|
puts "Bonjour, #{param_from_yield}"
end
greet('Guido', ... | true |
997f8da276e4a660ffe48ce21f6a1c9c2c4c044b | Ruby | meldefern/sdet10 | /oop/animal_types/mammals.rb | UTF-8 | 379 | 3.484375 | 3 | [] | no_license | module Mammals
# do not instantiate modules
def self.common_traits
puts 'Mammals have lungs, all express milk, have vertebrae, warm blooded'
end
class Quadruped
def self.four_legs
puts 'heyy ive got 4 legs'
end
end
class Biped
def self.two_legs
puts 'heyy ive got 2 legs'
end
end
end
# Mammal... | true |
136c1a47d16b38c4c8ac6647eaa761879271de42 | Ruby | teloe/algorithms | /coding-dojo/basic-13/ruby/print1to255.rb | UTF-8 | 134 | 3.71875 | 4 | [] | no_license | # Write a function that prints all numbers from 1 to 255
def print_to_255
(1..255).each {
|n| puts n
}
end
print_to_255()
| true |
0f1825b880e2e192ddbe7123df5091531d39e351 | Ruby | bashmb/cliqr | /test/models/user_test.rb | UTF-8 | 921 | 2.53125 | 3 | [] | no_license | require 'test_helper'
class UserTest < ActiveSupport::TestCase
test "should not save user without email" do
user = User.new
assert_not user.save, "Saved the user without an email"
end
test "should not save user without a password" do
user = User.new
user.email = "user@example.com"
assert_not... | true |
22a8b9eb36b3796bc1902d511c340eacd6b27bfe | Ruby | bnjtgly/api-pokemon | /app/controllers/api/v1/pokemons_controller.rb | UTF-8 | 1,061 | 2.546875 | 3 | [] | no_license | class Api::V1::PokemonsController < ApplicationController
require 'poke-api-v2'
def index
@pokemon = Pokemon.limit(6)
render :json => @pokemon.to_json(include: { info: { except: [:id, :created_at, :updated_at, :pokemon_id]} }), status: :ok
end
def show
pokemon = PokeApi.get(pok... | true |
bdbb95438f3c68bb0f4658ba5a0d0685d9618fcb | Ruby | SeanLuckett/project_dom_tree | /spec/text_element_spec.rb | UTF-8 | 582 | 2.8125 | 3 | [] | no_license | require_relative '../lib/text_element'
RSpec.describe TextElement do
let(:sample_text) { 'this is some text ' }
let(:el) { TextElement.new(sample_text) }
describe 'attributes' do
specify { expect(el).to have_attributes type: 'text' }
specify { expect(el).to have_attributes content: sample_text.strip }
... | true |
221a5e9eeb4e393ab5a7fc164cfe948fa95d9790 | Ruby | mcrouse911/rubyscrape | /scrape_wikipedia.rb | UTF-8 | 507 | 2.875 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'Nokogiri'
require 'open-uri'
require 'csv'
#point it at your webpage
url = "https://en.wikipedia.org/wiki/List_of_parishes_in_Louisiana"
#get the webpage as HTML
html = Nokogiri::HTML(open(url))
#make a csv out of the html table
csv = CSV.open("la_parishes.csv", "w",{:col_sep => ",", :qu... | true |
c8f965bdf327feef098fd933a613e62e6d83f977 | Ruby | biciclista22/api-muncher | /test/lib/recipes_test.rb | UTF-8 | 1,776 | 3.015625 | 3 | [] | no_license | require 'test_helper'
describe Recipe do
it "Can be instantiated with id, name, image, url, ingredients, servings, and total nutrients" do
id = "id"
name = "name"
image = "image"
url = "url"
ingredients = "ingredients"
servings = "servings"
recipe = Recipe.new(id, name, image, url, ingre... | true |
33d093a6c9404e9d57ef050b7d3146461a59a0a5 | Ruby | nsarno/problemhunt-api | /app/models/problem.rb | UTF-8 | 390 | 2.640625 | 3 | [] | no_license | class Problem < ActiveRecord::Base
# Associations
belongs_to :room
belongs_to :user
has_many :upvotes, dependent: :destroy
# Validations
validates :room, presence: true
validates :description, presence: true, length: { in: (5..200) }
def created_by? user
self.user == user
end
def upvoted_by? ... | true |
ce4feb0946973d6cd792bfa037e6005bc403f736 | Ruby | chrisjgilbert/bank | /spec/unit/statement_spec.rb | UTF-8 | 502 | 2.90625 | 3 | [] | no_license | require 'spec_helper'
require 'statement'
describe Statement do
describe('#print') do
it('prints out the transaction history in reverse order') do
transactions = [{ date: '01/10/2010', credit: 100, balance: 100 }, { date: '02/11/2010', debit: 50, balance: 50 }]
statement = Statement.new
expect ... | true |
9e8b01247ac525998a13eb01bc47201e7778584c | Ruby | Joeeeeyy/ttt-2-board-rb-cb-gh-000 | /lib/board.rb | UTF-8 | 187 | 3.09375 | 3 | [] | no_license | # Define the variable board below.
board = [" ", " ", " ", " ", " ", " "," ", " ", " "]
board [0]
board [1]
board [2]
board [3]
board [4]
board [5]
board [6]
board [7]
board [8]
| true |
4b9c05e127475fbf4d1a0e026f5096a90167a6f8 | Ruby | mkrahu/launchschool | /challenges/easy_1/series.rb | UTF-8 | 289 | 3.5625 | 4 | [] | no_license | # series.rb
class Series
attr_reader :numbers
def initialize(num)
@numbers = num.each_char
end
def slices(slice_by)
raise ArgumentError, 'Invalid size, must be less than numbers length' if slice_by > numbers.size
numbers.map(&:to_i).each_cons(slice_by).to_a
end
end | true |
6233ee9bf6993134fff4b1bd28988957d04bc2a1 | Ruby | SuperLazyDog/Algorithm-Practise | /books/oreilly/s6_tree/practice/6.rb | UTF-8 | 1,794 | 3.9375 | 4 | [] | no_license | class BinaryTree
attr_accessor :right, :left, :data
# attr_accessor :data
def initialize(data = nil)
@right = nil
@left = nil
@data = data
end
def generate(data:, side:)
if side == :left
@left = BinaryTree.new(data)
else
@right = BinaryTree.new(data)
end
end
def show
... | true |
29eeed4b4266c16701be563978dc474fa30a8c2b | Ruby | ehawk823/prework-ruby-assessment-web-0715-public | /lib/003_methods.rb | UTF-8 | 541 | 3.0625 | 3 | [] | no_license | # code you methods for the 003_method spec here
# Note: You will need to pass the school variable to each of these methods to include it in scope
def get_grade (school, name)
school[:students].each { |x| return x[:grade] if x[:name] == name}
end
def update_subject (school, instructor, new_subject)
school[:instruct... | true |
59710ebb62d03a144b4ac297f9cca7118bfd4d28 | Ruby | nax2uk/decorating-command-line | /lib/example_ansi_escape_sequence.rb | UTF-8 | 764 | 2.953125 | 3 | [] | no_license | # Shows how to use raw ANSI excape sequences
puts ""
print "\e[0;34m This is blue and the next line is not reset to default \n\n" #no reset code at the end
print " This is the next line.\n\n"
print "\e[0;31m This is red and the next line is reset to default \e[0m\n\n"
print " This is the next line.\n\n"... | true |
a877d40fd7452554716f3b8d35ae8dca9b430ae2 | Ruby | jmosteen/ruby-challenges | /fizzbuzz.rb | UTF-8 | 258 | 3.546875 | 4 | [] | no_license | current_number = 0
while current_number < 101
if current_number%3 == 0 && current_number%5 == 0
puts "FizzBuzz"
elsif current_number%3 == 0
puts "Fizz"
elsif current_number%5 == 0
puts "Buzz"
else
puts current_number
end
current_number+=1
end
| true |
99abf256f91d212eae1477e0a5aeca69eb07c1d8 | Ruby | bmc/brizzled | /plugins/code_figure.rb | UTF-8 | 321 | 2.78125 | 3 | [
"MIT"
] | permissive | # bmc@clapper.org
module CodeFigure
def figurize(str, title)
res = "<figure class='code'>"
res += "<figcaption><span>#{@title}</span></figcaption>" if @title
res += str
res += "</figure>"
end
def escape_html(str)
str.gsub('&', '&').
gsub('<', '<').
gsub('>', '>')
... | true |
d7e567fe155da019c43680dbddf13ca70d899cf7 | Ruby | Techshido/madeingville | /app/models/achievement.rb | UTF-8 | 1,618 | 2.71875 | 3 | [] | no_license | # == Schema Information
#
# Table name: achievements
#
# id :integer not null, primary key
# hacker_id :integer
# category :string(255)
# description :text
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_achievements_on_type (categ... | true |
6626b544ba709b4b602cd837287426fdd7855730 | Ruby | jlbao/harness | /lib/report.rb | UTF-8 | 534 | 2.53125 | 3 | [] | no_license |
require_relative 'test_directory.rb'
require_relative 'history.rb'
class Report
def self.test_results
dirs = ['unclassified', 'passed', 'failed']
Dir.chdir("results")
results = {}
dirs.each do |dir|
Dir.chdir(dir)
new_dir = TestDirectory.new
count = new_dir.testfile_number
case dir
when 'unc... | true |
122283acfc8c99df5ac996d2e3561adb71f99b9b | Ruby | fmigues/rails-mister-cocktail | /db/seeds.rb | UTF-8 | 433 | 2.6875 | 3 | [] | no_license | require 'open-uri'
require 'json'
Cocktail.destroy_all
Ingredient.destroy_all
url = 'http://www.thecocktaildb.com/api/json/v1/1/list.php?i=list'
user_serialized = open(url).read
user = JSON.parse(user_serialized)
user.each do |key, index|
index.each { |value| Ingredient.create(name: value["strIngredient1"] ) }
end... | true |
a15b54f56e461edc437e9b1bd390c3919d1d6b71 | Ruby | Ratatoskor/project_euler | /ruby/034.rb | UTF-8 | 885 | 4.1875 | 4 | [] | no_license | #DIGIT FACTORIALS
=begin
145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145.
Find the sum of all numbers which are equal to the sum of the factorial of their digits.
Note: as 1! = 1 and 2! = 2 are not sums they are not included.
=end
@cache = {0 => 1, 1 =>1}
# Returns factorial of input @ caches each i... | true |
cfc79a3a7e37ea69f0dccaa3693ecf8380dc29b7 | Ruby | net-ssh/net-ssh | /lib/net/ssh/transport/hmac.rb | UTF-8 | 1,819 | 2.875 | 3 | [
"MIT"
] | permissive | require 'net/ssh/transport/key_expander'
require 'net/ssh/transport/hmac/md5'
require 'net/ssh/transport/hmac/md5_96'
require 'net/ssh/transport/hmac/sha1'
require 'net/ssh/transport/hmac/sha1_96'
require 'net/ssh/transport/hmac/sha2_256'
require 'net/ssh/transport/hmac/sha2_256_96'
require 'net/ssh/transport/hmac/sha2... | true |
f46a773adb6ae90a431e28e1f4f2f1e96675f6cc | Ruby | dannielyavocado/ruby-collaborating-objects-lab-onl01-seng-pt-072720 | /lib/song.rb | UTF-8 | 597 | 2.984375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Song
attr_accessor :name
attr_reader :artist
@@all = []
def initialize(name)
@name = name
@@all << self
end
def self.all
@@all
end
def self.new_by_filename(file_name)
arr = file_name.split("-").map(&:strip)
artist = Artist.new(arr[0])
song = self... | true |
22fc1e31673b037c72a747781c31c7c47394e1fa | Ruby | greytape/backend | /120/oop_book_cars.rb | UTF-8 | 1,644 | 4.0625 | 4 | [] | no_license | # *** CARS ***
module Childlock
def lock_back_doors(num)
num
end
end
class Vehicle
@@number_of_vehicles = 0
attr_accessor :color
attr_reader :model, :year
def initialize(year, model, color)
@@number_of_vehicles += 1
@year = year
@color = color
@model = model
@current_speed = ... | true |
23bebd3688ad32722adf0e16ce1e24411ab230c6 | Ruby | toumait/orbf2 | /app/models/formula.rb | UTF-8 | 2,214 | 2.515625 | 3 | [
"MIT"
] | permissive | # == Schema Information
#
# Table name: formulas
#
# id :integer not null, primary key
# code :string not null
# description :string not null
# expression :text not null
# rule_id :integer
# created_at :datetime not null
# updated_at :dateti... | true |
928cecd5b882584fd1c9accf7a015db697f5b31a | Ruby | NickTerrafranca/bank-account-summary | /bank_account_executable.rb | UTF-8 | 751 | 2.9375 | 3 | [] | no_license | require_relative 'bank_transaction'
require_relative 'bank_account'
BALANCES = 'balances.csv'
BANK_DATA = 'bank_data.csv'
purchasing_account = BankAccount.new(BALANCES, BANK_DATA, 'Purchasing Account')
business_checking = BankAccount.new(BALANCES, BANK_DATA, 'Business Checking')
puts "\n==== Purchasing Account ===="
p... | true |
2750130d97596b77b08fb54040633942ba7ac062 | Ruby | lukistar/MDA-Simula | /lib/constructor.rb | UTF-8 | 1,988 | 3.5 | 4 | [] | no_license | require 'gosu'
require_relative './player'
require_relative './tile'
require_relative './sprite'
require_relative './point'
require_relative './virtual_model'
class Constructor
def self.create_virtual_model(image)
# upside down
top = Point.new(0, image.height-1)
bottom = Point.new(0, 0)
left = Point.new(ima... | true |
10baed9e560189b538a8379b6ea61d6d01819239 | Ruby | dotboris/boxes_server | /commons/spec/gluegun/request_spec.rb | UTF-8 | 1,824 | 2.609375 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
require 'gluegun/request'
describe GlueGun::Request do
let(:request) { GlueGun::Request.new 'a.queue', 42, 55, 200, 300 }
it 'should have a queue' do
expect(request).to respond_to :queue, :queue=
expect(request.queue).to eq 'a.queue'
end
it 'should have a row count' do
expec... | true |
57e4adf4e2a84c9dd5d19ac18764817d4a4001b2 | Ruby | jimmysoho/soho | /test.rb | UTF-8 | 33 | 2.625 | 3 | [
"MIT"
] | permissive | (1..10).each do |x|
puts x
end
| true |
ef8d7314cf3b76cbd272b2a1b52ab5b315f43514 | Ruby | mattdizon/Code_Wars | /6 Kyu/count_char.rb | UTF-8 | 95 | 3.5625 | 4 | [] | no_license | def count_chars(s)
hash = Hash.new(0)
s.each_char do |x|
hash[x] += 1
end
hash
end
| true |
ec51ac845008ff4cb655d2f1671e3e380df352ca | Ruby | IanLawson8913/codewar_exercises | /directions.rb | UTF-8 | 1,987 | 4.15625 | 4 | [] | no_license | # input: array of directions
# output: simplified version of array
# rules: if a direction is followed by it's opposite, both are removed from array
# iterate through array, two adjacent elements at a time
# -- if adjacent elements are opposites, elements are deleted from array
# -- -- iteration repeats
# -- if are n... | true |
d3ca78308b688f2b5b0a685f18c29779ce50b6ab | Ruby | amyaturner/ls_rb_101_programming_foundations | /small_problems_exercises/2_easy/02.rb | UTF-8 | 564 | 4.59375 | 5 | [] | no_license | # 02
# Build a program that asks a user for the length and width of a room in meters and then displays the area of the room in both square meters and square feet.
# Note: 1 square meter == 10.7639 square feet
# Do not worry about validating the input at this time.
puts "Enter the length of the room in meters:"
l = ... | true |
38b5bc283df93407d138989915076e1f199579ef | Ruby | Mgubser98625790/ebanq_api | /lib/ebanq_api/blocks/reports.rb | UTF-8 | 4,549 | 2.71875 | 3 | [] | no_license | # frozen_string_literal: true
require 'ebanq_api/client'
require 'ebanq_api/api_paths'
# Reports block
module EbanqApi
##
# This class represents an reports functional of Ebanq REST Api.
class Reports
include ApiPaths
# Declares an client instance.
def initialize(client)
@client = client
e... | true |
7b8e34e1bae642cb528add1ed1c868e24f9401c9 | Ruby | deepigarg/rubyx | /lib/rubyx/rubyx_compiler.rb | UTF-8 | 4,505 | 3.203125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module RubyX
# The RubyXCompiler provides the main interface to create binaries, and also
# give helper functions to create any intermediate layer.
# Layers are:
# - ruby , always needed as input, string
# - sol - intermediate language layer
# - slot_machine - intermediate machine layer
# - risc - "last" ... | true |
d53643df29c86b2ff925805241865fedccdd14b8 | Ruby | iamtash/simple-blackjack-cli-online-web-prework | /lib/blackjack.rb | UTF-8 | 1,182 | 3.953125 | 4 | [
"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(card_total)
puts "Your cards add up to #{card_total}"
end
def prompt_user
puts "Type 'h' to hit or 's' to stay"
end
def get_user_input
gets.chomp
end
def end_game(card_total)
puts "Sorry, you hit ... | true |
ebd3f0c804b2641f6f7e38d63df9f1c9f1b40b31 | Ruby | tewecske/saas-class-homework | /hw1/source/palindrome.rb | UTF-8 | 328 | 3.453125 | 3 | [] | no_license | class Palindrome
def palindrome?(string)
eq(filter(string))
end
def eq(string)
string == string.reverse
end
def filter(string)
string.gsub(/\W/, "").downcase
end
def count_words(string)
m = Hash.new(0)
string.downcase.split(/\W+/).each do |k|
m[k] = m[k] + 1
end
m
e... | true |
c256e14bf66139eb4aa3c22bfb2373ba98e7a850 | Ruby | UDAYA2308/day3 | /ex2.rb | UTF-8 | 130 | 3.125 | 3 | [] | no_license | class A
def m1
puts "parent class"
end
end
class B<A
def m2
puts "Child class"
end
end
b=B.new
b.m1
b.m2
a=A.new
a.m1
| true |
10345cf62c63af7197f16a0e88088402d1b037c4 | Ruby | fog/fog-openstack | /examples/storage/set-account-quota.rb | UTF-8 | 2,158 | 2.5625 | 3 | [
"MIT"
] | permissive | require 'fog/openstack'
require 'pp'
#
# This example sets the account quota (in bytes) for the tenant demo@test.lan
# using an admin account (admin has the reseller user role).
#
# Uses the account impersonation feature recently added to the
# OpenStack Storage service in Fog (See https://github.com/fog/fog/pull/1632... | true |
7115b8f08f943416dc612301a442111ba052dc7c | Ruby | catburston/townbikes | /app/models/reservation.rb | UTF-8 | 1,815 | 2.671875 | 3 | [] | no_license | class Reservation < ActiveRecord::Base
attr_accessor :current_user
belongs_to :bicycle
belongs_to :renter ,foreign_key: "user_id", class_name: "User"
has_one :location, through: :owner
has_one :owner, through: :bicycle, foreign_key: "user_id", class_name: "User"
validates :bicycle_id, presence: ... | true |
aad96a3349e7de2b030d7ff63b6071ae801b03df | Ruby | langphil/needless-backpack | /lib/banking.rb | UTF-8 | 259 | 3.078125 | 3 | [] | no_license | # Banking Transaction Object
class Banking
attr_reader :time, :credit, :debit, :balance
def initialize(credit = 0, debit = 0, balance = 0)
@balance = credit
@debit = debit
@credit = balance
@time = Time.now.strftime('%d/%m/%Y')
end
end
| true |
2fb9f18f16a438eee320933ed3e1a4f802aa0c86 | Ruby | chdoh5/ruby-oo-practice-relationships-silicon-valley-exercise-chi01-seng-ft-010620 | /app/models/venture_capitalist.rb | UTF-8 | 1,472 | 3.0625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require "pry"
class VentureCapitalist
attr_reader :name, :total_worth, :startup, :type, :investment, :domain
@@all = []
def initialize(name, total_worth)
@name = name
@total_worth = total_worth
# "$"+total_worth.to_s.reverse.gsub(/...(?=.)/,'\&,').reverse
@@all <... | true |
1f94b66ec56de8a7b01b21036cb638fe6345e1ea | Ruby | renanmartins/infinity_tracks | /lib/client.rb | UTF-8 | 933 | 2.671875 | 3 | [] | no_license | class Client
attr_reader :play_token, :api_key
def initialize
@api_key = "e098e014125339698e741cb25feebd9f54b1a89b"
end
def api_header
"--header \"X-Api-Key: #{@api_key}\""
end
def play_token
`curl -s #{api_header} http://8tracks.com/sets/new.json`
end
def playlist url
`cur... | true |
cc44a81d276550dd9244ed951e4614472f59df8c | Ruby | AlexanderOsborne/backend_mod_1_prework | /day_6/exercises/person.rb | UTF-8 | 678 | 4.21875 | 4 | [] | no_license | # Create a person class with at least 2 attributes and 2 behaviors.
# Call all person methods below the class and print results
# to the terminal that show the methods in action.
class Person
attr_reader :name, :awake, :caffinated, :coding
def initialize(name, awake, caffinated, coding)
@name = name
@awake ... | true |
28890a7ca0575b895787087b52b0878e3193776f | Ruby | pschyska/sencha-model | /lib/sencha-model/adapters/sequel.rb | UTF-8 | 2,802 | 2.703125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | ##
# Sequel adapter to Sencha::Model mixin
#
module Sencha
module Model
module ClassMethods
def sencha_primary_key
self.primary_key.to_sym
end
def sencha_column_names
self.column_names.map(&:to_sym)
end
def sencha_columns_hash
self.columns
... | true |
a90e7d045828865dac3bef4c014c5ed8e7ee1d26 | Ruby | TH-Programming/pokemon-scraper-onl01-seng-ft-072720 | /lib/pokemon.rb | UTF-8 | 596 | 3.015625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Pokemon
attr_accessor :id, :name, :type, :db
def initialize(id: nil, name:, type:, db:)
self.id = id
self.name = name
self.type = type
self.db = db
end
def self.save(name, type, db)
sql = <<-SQL
INSERT INTO db (name, type)
VALUES (?,?,?)
SQL
db.execute(sql, name, type... | true |
33cb70341d23e00b6c838b6891b27b20af8826a2 | Ruby | chelsearostonrappazzo/object_oriented_ruby- | /store_item.rb | UTF-8 | 1,542 | 4.21875 | 4 | [] | no_license | # item1 = { name: "regency evening gown", color: "mazarine blue", price: 465 }
# item2 = { name: "regency promenade gown", color: "sprigged muslin", price: 200 }
# item3 = { :name => "regency mourning gown", :color => "onyx black", :price => 325 }
class Item
attr_reader :name, :color, :price
attr_writer :price
... | true |
86f0bc5bb6083fd185d6d5cb0eb9f2a1630459e5 | Ruby | willhowes/fibonacci_memoized | /spec/fibonacci_spec.rb | UTF-8 | 531 | 3.453125 | 3 | [] | no_license | require 'fibonacci'
describe '#fibonacci' do
it 'returns 1 for an input of 1' do
expect(fibonacci(1)).to eq(1)
end
it 'returns 1 for an input of 2' do
expect(fibonacci(2)).to eq(1)
end
it 'returns 2 for an input of 3' do
expect(fibonacci(3)).to eq(2)
end
it 'ret... | true |
4f091ca974dff5273bb22513660569732686f44f | Ruby | vipul2690/url_shortener | /app/models/url.rb | UTF-8 | 585 | 2.703125 | 3 | [] | no_license | class Url < ApplicationRecord
has_many :analytics, class_name: "Analytic", foreign_key: "url_id"
validates :full_url, presence: true, format: URI::regexp(%w[http https])
validates :short_url, presence: true
validates_length_of :full_url, within: 3..255, on: :create, message: "too long"
validates_le... | true |
76310f098a2e38fdda8166d4c9d9e922b6a8783b | Ruby | rjharmon/rovers_example | /lib/plateau.rb | UTF-8 | 247 | 3.078125 | 3 | [] | no_license | class Plateau
attr_accessor :width, :height
# okay, this class didn't end up pull its weight. We could factor it out
# but time is up.
def initialize(max_x, max_y)
self.width = max_x + 1
self.height = max_y + 1
self
end
end | true |
b1e21cdc9e08ec61d09dc8e28bcc3d5f014e2e47 | Ruby | pepabo/siteguard_lite-log-parser | /lib/siteguard_lite_log_parser.rb | UTF-8 | 509 | 2.8125 | 3 | [
"MIT"
] | permissive | require 'siteguard_lite/log/detect'
class SiteguardLiteLogParser
def initialize(type, options = {})
@type = type
@options = options
@parser = get_parser(type)
end
def parse(line_str)
@parser.parse(line_str)
end
private
def get_parser(type)
case type
when 'detect'
Siteguard... | true |
76c30430d76d8f7c30a2908839d309183800641b | Ruby | NashFP/fizzbuzz | /vinbarnes+ruby/fizzbuzz_test.rb | UTF-8 | 667 | 2.953125 | 3 | [] | no_license | require 'test/unit'
require 'fizzbuzz'
class TestFizzBuzz < Test::Unit::TestCase
def test_fizzbuzziness
assert_equal [1], fizzbuzz(1..1)
assert_equal [1, 2], fizzbuzz(1..2)
assert_equal [1, 2, 'Fizz'], fizzbuzz(1..3)
assert_equal [1, 2, 'Fizz', 4], fizzbuzz(1..4)
assert_equal [1, 2, 'Fizz', 4, 'B... | true |
bbd09b910eb09405835ef4dfee4ce487dd0c0f8b | Ruby | jehenderson/RB130 | /exercises/easy/divisors.rb | UTF-8 | 537 | 4.34375 | 4 | [] | no_license | # Write a method that returns a list of all of the divisors of the positive
# integer passed in as an argument. The return value can be in any sequence
# you wish.
def divisors(num)
divisors = Array.new
counter = 1
while counter <= num
divisors << counter if num % counter == 0
counter += 1
end
divi... | true |
82edff44a1c474dd7faf244ea34121b33c95261f | Ruby | domivabc/Voter-Simulation-Project | /voter.rb | UTF-8 | 382 | 3.1875 | 3 | [] | no_license | class Voter
attr_reader :name, :political_affiliation
attr_writer :name, :political_affiliation # creates the setter methods
def initialize(name, political_affiliation)
@name = name
@political_affiliation = political_affiliation
end
def print_info
puts " Voter , #{@name.ljust(... | true |
2ba01201b44237df04f6f31a460873816010107b | Ruby | loz/try_with | /lib/try_with.rb | UTF-8 | 689 | 2.921875 | 3 | [
"MIT"
] | permissive | require "try_with/version"
module TryWith
# Your code goes here...
class Attempts
def initialize(*args)
@count = args.first
end
def attempts &block
@tries = 0
while trying? do
try_block block
end
end
private
def try_block(block)
block.call
resc... | true |
264775054163bf3e6ff9fb6af1ad0c4623e68271 | Ruby | teracyhq-incubator/teracy-dev-core | /lib/teracy-dev-core/config/provisioners.rb | UTF-8 | 2,619 | 2.578125 | 3 | [
"MIT"
] | permissive | require 'teracy-dev'
require 'teracy-dev/util'
module TeracyDevCore
module Config
# see: https://www.vagrantup.com/docs/provisioning/
class Provisioners < TeracyDev::Config::Configurator
def configure_node(settings, config)
provisioners_settings = settings['provisioners'] ||= []
Terac... | true |
c2368ad98ca963edcc02a81646b2ee36025c4914 | Ruby | n00dl3nate/Homework_week02_day05 | /room.rb | UTF-8 | 1,930 | 3.375 | 3 | [] | no_license | require_relative("./songs.rb")
require_relative("./guest.rb")
class Rooms
attr_accessor :amount , :cost ,:playlist, :tracklist
def initialize(amount,cost,tracklist)
@amount = amount
@cost = cost
@tracklist = tracklist
@play_list = []
# @playlist = []
end
def get_total_amount
retu... | true |
d44c833d51014c505f6cfb9be5e57ae63a03959b | Ruby | melicious-dish/Solar-System | /main.rb | UTF-8 | 2,488 | 3.875 | 4 | [] | no_license | require_relative 'planet'
require_relative 'solar_system'
def main()
earth = Planet.new("Earth", "blue-green", 5.972e24, 1.496e8, "Only planet known to support life")
# puts earth.name
# puts earth.summary
#create an instance of SolarSystem
solar_system = SolarSystem.new('Sol')
#add planets to the pla... | true |
45d12f8dc1d006e99a9910d54f24461ff7135b77 | Ruby | kei2100/playground_ruby | /perfect_ruby_study/chapter4_ishimura-2.rb | UTF-8 | 448 | 3.59375 | 4 | [] | no_license | #!/usr/bin/env ruby
module Swappable
def swap(i1, i2)
return self if i1 < 0 || i2 < 0
return self if self[i1].nil? || self[i2].nil?
self.clone.swap! i1, i2
end
def swap!(i1, i2)
return self if i1 < 0 || i2 < 0
return self if self[i1].nil? || self[i2].nil?
self[i1], self[i2] = self[... | true |
0d5016daaf3fd8639174038ffb6d0c3e572b74a6 | Ruby | DanielmColey/ruby-code | /Regex/email_matcher.rb | UTF-8 | 386 | 2.59375 | 3 | [] | no_license | VALID_EMAIL_REGEX = /\A([\w+\-].?)+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+\z/i
def is_valid_email? email
email =~ VALID_EMAIL_REGEX
end
p is_valid_email?("dan@coley.com") ? "Valid" : "Invaild"
p is_valid_email?("dancoley.com") ? "Valid" : "Invaild"
p is_valid_email?("dan.h@coley.com") ? "Valid" : "Invaild"
p is_valid_email?... | true |
17982ca97b66f1f596a1fd54d0450e68d5b59e75 | Ruby | Soumya739/ruby-oo-practice-flatiron-zoo-exercise-seattle-web-091619 | /lib/Animal.rb | UTF-8 | 597 | 3.234375 | 3 | [] | no_license | class Animal
attr_accessor :species, :weight, :nickname
@@all = []
def initialize(species, weight, nickname)
@species = species
@weight = weight
@nickname = nickname
@@all << self
end
def self.all
@@all
end
def zoo
Location.all.each do |... | true |
409a23407e51b27f37639721696d5a5984e85a57 | Ruby | kjdowns/sinatra-mvc-lab-online-web-ft-110419 | /models/piglatinizer.rb | UTF-8 | 603 | 3.59375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class PigLatinizer
attr_accessor :text, :pl_text
def initialize(text: "")
@text = text
end
def piglatinize(string)
self.text = string
word_array = self.text.split(" ")
pl_array = word_array.map do |word|
cons = word.scan(/^[bcdfghjklmnpq... | true |
0cb11d70ef435fa5ad1b790b88bbb27c9843adeb | Ruby | bleavitt92/budget_app | /budget.rb | UTF-8 | 6,717 | 2.796875 | 3 | [] | no_license | require "sinatra"
require "sinatra/reloader"
require "tilt/erubis"
require "date"
configure do
enable :sessions
set :session_secret, 'secret'
end
before do
session[:budget] ||= {
'january' => [],
'february' => [],
'march' => [],
'april' => [],
'may' => [],
'june' => [],
'july' => []... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.