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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
cfe95c5e0f1d451fd95b79fce4b24c4e03f86090 | Ruby | ysulaiman/communique | /experiments/experiment_helpers.rb | UTF-8 | 769 | 2.53125 | 3 | [] | no_license | require 'benchmark'
require 'rubygems'
require 'text-table'
require_relative '../lib/dbc_method'
require_relative '../lib/dbc_object'
require_relative '../lib/dbc_use_case'
require_relative '../lib/noise_generator'
require_relative '../lib/planner'
def solve_and_report(use_case)
planner = Planner.new(:best_first_fo... | true |
aa759d3a040b21c54a77d55a6732f259d9554b65 | Ruby | minoritea/ruby_rspec | /spec/lib/VendingMachine_spec.rb | UTF-8 | 4,400 | 2.765625 | 3 | [
"Apache-2.0"
] | permissive | # -*- encoding: utf-8 -*-
require 'spec_helper'
describe VendingMachine do
let(:vm){ VendingMachine.new }
#let(:yen10) {Money.new 10}
context '初期状態のテスト' do
it '何も投入しなければ合計0件' do
vm.total.should eq 0
end
it '何も投入しなければつり銭ボックスは' do
vm.change.should eq 0
end
end
context 'コインを投入したとき... | true |
59771b8858344ef054e783cf416542f3842f6ec6 | Ruby | Codehoff/Codewars | /take_a_ten_minute_walk.rb | UTF-8 | 125 | 2.953125 | 3 | [] | no_license | def is_valid_walk(walk)
walk.length == 10 && walk.count("s") == walk.count("n") && walk.count("e") == walk.count("w")
end | true |
7528b7e788e6a951334310fc7006c7c9c6b4746d | Ruby | Marisha-Sahay/bitcoin | /app/models/product.rb | UTF-8 | 523 | 2.640625 | 3 | [] | no_license | class Product < ApplicationRecord
has_many :images
has_many :categorized_products
has_many :categories, through: :categorized_products
has_many :carted_products
has_many :orders, through: :carted_products
validates :name, presence: true
validates_numericality_of :price, :greater_than => 0, :less_than => 1... | true |
40f72b2e28ae457ffb84195a8a5d421bb08ebed8 | Ruby | scmountain/ApiCurious | /app/models/starred_repo.rb | UTF-8 | 455 | 2.734375 | 3 | [] | no_license | class StarredRepo
attr_reader :name, :updated_at, :language, :html_url
def initialize(params)
@name = params["name"]
@updated_at = params["updated_at"]
@language = params["language"]
@html_url = params["html_url"]
end
def self.count
end
def self.all(current_user)
starred_repos_hashes... | true |
1fddfb65821e8941911f78991d076965ca34dba6 | Ruby | AnaPaulaSousa/estudos_alura | /sistema.rb | UTF-8 | 1,326 | 3.34375 | 3 | [] | no_license | require_relative "livro"
require_relative "estoque"
def livro_para_news_letter(livro)
if livro.ano_lancamento < 1999
puts "NewsLetter/Liquidação"
puts livro.titulo
puts livro.preco
puts livro.possui_reimpressao
end
end
algoritmos = Livro.new("Algoritmos", 100, 1998, true)
arqui... | true |
599efc89826478611fbc74eee5a31df8b4871991 | Ruby | RadiusNetworks/radius-spec | /benchmarks/bm_setup.rb | UTF-8 | 1,225 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | # frozen_string_literal: true
require 'kalibera'
require 'benchmark/ips'
# Enable and start GC before each job run. Disable GC afterwards.
#
# Inspired by https://www.omniref.com/ruby/2.2.1/symbols/Benchmark/bm?#annotation=4095926&line=182
class GCSuite
def warming(*)
run_gc
end
def running(*)
run_gc
... | true |
f8138b005bb29a345f8f6acaf7975b706e1bab9e | Ruby | geolopigs/traderpogserver | /app/helpers/posts_helper.rb | UTF-8 | 7,483 | 3.078125 | 3 | [] | no_license | module PostsHelper
##
# Get the region that the post is located in
##
def PostsHelper.coordtoregion(latitude, longitude, fraction)
lat_index = PostsHelper.get_index(latitude, fraction, -90, 90)
lon_index = PostsHelper.get_index(longitude, fraction, -180, 180)
(lat_index * 360 * (1.0 / fraction).to_i... | true |
c2bfe661db132cbae271d9100efe8c9cd36446ed | Ruby | complikatyed/Whatcha_Reading | /test/test_helper.rb | UTF-8 | 1,011 | 2.75 | 3 | [
"MIT"
] | permissive | ENV["TEST"] = "true"
require 'rubygems'
require 'bundler/setup'
require "minitest/reporters"
require_relative "../lib/environment"
reporter_options = { color: true }
Minitest::Reporters.use! [Minitest::Reporters::DefaultReporter.new(reporter_options)]
require 'minitest/autorun'
class Minitest::Test
def setup
Da... | true |
b64102fe5cdff3220ea70a3cad98da1834fa02ec | Ruby | dtgit/lftwb | /vendor/plugins/less_monkey_patching/lib/string.rb | UTF-8 | 1,191 | 2.515625 | 3 | [
"MIT"
] | permissive | class String
def strip_xml
self.gsub(/<(.*?)>/, '')
end
def strip_tag_and_contents tag
self.gsub(/<style.*>.*?<\/style>/mi, '')
end
def to_safe_uri
self.strip.downcase.gsub('&', 'and').gsub(' ', '-').gsub(/[^\w-]/,'')
end
def from_safe_uri
self.gsub('-', ' ')
end
def add_param ... | true |
8f8a2b99333a104feaeb73a540d01e5d6eaaa638 | Ruby | emilywiegand/ruby-challenges | /first_ruby_object_refactor.rb | UTF-8 | 415 | 3 | 3 | [] | no_license | class Mon_Calamari
attr_writer :name, :job
attr_reader :name, :job
def outburst
return "IT'S A TRAP!"
end
end
this_calamari = Mon_Calamari.new
this_calamari.name = "Admiral Ackbar"
calamariname = this_calamari.name
this_calamari.job = "Military Commander of the Rebel Alliance"
calamarijob = this_calamari.job... | true |
ffbdb7f2738c21ea2f4d0f83fa39b94778f0bfef | Ruby | emmabeynon/oystercard | /spec/journey_log_spec.rb | UTF-8 | 1,975 | 2.59375 | 3 | [] | no_license | require 'journey_log'
describe JourneyLog do
subject(:journey_log) { described_class.new(journey_klass) }
let(:journey) { double :journey, fare: 6 }
let(:journey_klass) { double :journey_klass, new: journey, exit_station: exit_station}
let(:entry_station) { double :station}
let(:exit_station) { double :stati... | true |
01a86d838b2b40dfcb333ee1130a8a2679341de6 | Ruby | danhodge/cfb | /lib/cfb/team.rb | UTF-8 | 723 | 2.734375 | 3 | [
"MIT"
] | permissive | module CFB
Team = Struct.new(:name, :wins, :losses, :ranking, :point_spreads) do
def self.from_json(json)
new(
json["name"],
json["wins"],
json["losses"],
json["ranking"],
json["point_spreads"]
)
end
def attributes
to_h
end
def point_spre... | true |
bba508eacd83b10a4510c6134ca74bd5bc191bbd | Ruby | nguyhh/ddd_code_samples_ruby | /claim_test.rb | UTF-8 | 1,453 | 3.03125 | 3 | [] | no_license | require "test/unit"
require 'date'
require_relative './claim'
require_relative './repair_po'
require_relative './line_item'
class ClaimTest < Test::Unit::TestCase
def test_claim_is_setup_correctly
line_item1 = LineItem.new("PARTS", 45.0, "Replacement part for soap dispenser")
line_item2 = LineItem.new("L... | true |
4f48d710e63f389036f8c5d65ffe2b5cc85c8cec | Ruby | alu0101126692/pract10 | /lib/foodie/menu.rb | UTF-8 | 1,257 | 3.265625 | 3 | [
"MIT"
] | permissive | class Menu
#Nombre del menu
attr_reader :nombre
#lista de platos
attr_accessor :listapl
#lista precios
attr_accessor :listapr
#descripcion del menu
attr_accessor :desc
#precio total
attr_accessor :precios
def initialize(nombre,&block)
@nombre = nombre
@listapl = Listas.new()
@listapr = Listas.... | true |
9adb97e9cc7cb72d5c9430c0c0365731568cf749 | Ruby | raxoft/form_input | /lib/form_input/types.rb | UTF-8 | 5,015 | 2.96875 | 3 | [
"MIT"
] | permissive | # Common form types.
require 'time'
require 'date'
# Extend forms with arguments for form parameter types which are used often.
class FormInput
# Regular expressions commonly used to validate input arguments.
# Matches names using latin alphabet.
LATIN_NAMES_RE = /\A[\p{Latin}\-\. ]+\z/u
# Matches common e... | true |
a1e7d7f1a100f23ab7de8e396def8d09e62bedd6 | Ruby | MichaelSRomero/oo-cash-register-dumbo-web-career-012819 | /lib/cash_register.rb | UTF-8 | 909 | 3.421875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class CashRegister
attr_accessor :total, :discount, :items, :last_transaction
# attr_reader :discount
def initialize(discount = 0)
@total = 0
@discount = discount
@items = []
# @last_transaction = nil
end
def add_item(title, price, quantity = 1)
self.last_transaction = price
quantit... | true |
d866898be1a7df79327c83483695daabae7ac7c0 | Ruby | evanidul/simpleweed | /lib/simpleweed/timedateutil/timedateservice.rb | UTF-8 | 13,866 | 3.359375 | 3 | [] | no_license | module Simpleweed
module Timedateutil
class Timedateservice
def sayHi
return "timedateservice"
end
#given 0-23 hours as an int, 00-59 minutes as an int, return am/pm string
def formatMilitaryTimeAsAMPM(hours, minutes)
if hours.nil? || minutes.nil?
return
end
... | true |
9f0e8ae486b3779232febf8de2ee533f7890d27c | Ruby | rkmathi/two_rank_down | /reopen_class.rb | UTF-8 | 533 | 4.09375 | 4 | [] | no_license | puts 'this is string'
# puts 'this is string'.hoge # `String#hoge`メソッドは存在しないのでエラー
### Stringクラスを再オープンしてhogeメソッドを定義
class String
def hoge
self + ' hogehoge'
end
end
puts 'this is string'.hoge
str = 'fugafuga'
puts str.hoge
### 整数(Fixnum)クラスの+メソッド
puts 2.+(3)
puts 2 + 4
### Fixnumクラスを再オープンしてfugaメソッド(ただの掛け算... | true |
8bab930bb8f99306b127976a50aca137642ab2d5 | Ruby | Osvimil/RubyCourse | /Clase3.rb | UTF-8 | 489 | 3.859375 | 4 | [] | no_license | class Persona
def initialize(nombre,apellido1,apellido2)
@nombre = nombre
@apellido1 = apellido1
@apellido2 = apellido2
end
def mostrar
print("Nombre: "+@nombre+" Ap_paterno: "+@apellido1+" Ap_mat: "+@apellido2)
end
def nombre
@nombre
end
def apellido1
@apellido1
end
def ap... | true |
b34933b9a3df8a69dbfaa8dbfbf68ce4af8f55de | Ruby | anoam/meeting_schedule | /lib/meeting_deserializer.rb | UTF-8 | 745 | 3.0625 | 3 | [] | no_license | # frozen_string_literal: true
require 'meeting'
require 'invalid_data'
# Provides {Meeting}s deserialization from string
class MeetingDeserializer
MEETING_REGEXP = /(?<title>.+)\s(?<duration>\d+)min/
# Restores collection of meetings from string
# @param source [String] formatted string that contains serialize... | true |
733a3441f75c7177295d42e20712495b703a8e88 | Ruby | thracken/mastermind | /mastermind.rb | UTF-8 | 3,552 | 3.515625 | 4 | [] | no_license | module Mastermind
class Game
def initialize
@player = Player.new
@answer = Solution.new.create
@turns = 0
@guesses = Array.new
@all_clues = Array.new
@turn_count = 0
end #initialize
def play
show_board
loop do
take_turn
break ... | true |
f8f7aa572bf50dcb338894deaedfa1b65dcf8718 | Ruby | vanmichael/hrpay | /app/models/commission_sales_person.rb | UTF-8 | 593 | 2.90625 | 3 | [] | no_license | class CommissionSalesPerson < Employee
attr_reader :total_sales, :commission
def initialize(first_name, last_name, base_salary, commission)
super(first_name,last_name,base_salary)
@commission = commission.to_f
get_sales(last_name)
end
def get_sales(last_name)
@total_sales = 0
employee_sales = SaleReader... | true |
220ed259eab720a8a8b3e44e96cb69f7bf38b3e7 | Ruby | david-sawatske/Interview-Cake-Problems | /Problems/2. others_prod_prob.rb | UTF-8 | 408 | 3.96875 | 4 | [] | no_license | # Write a function get_products_of_all_ints_except_at_index() that takes an array
# of integers and returns an array of the products, excluding the integer at
# the current index
# do not use division
# Time
# Space
def others_prod(arr)
end
arr1 = [1, 7, 3, 4]
arr2 = [3, 1, 2, 5, 6, 4]
p others_prod(arr1) == [84... | true |
21a9c1722f8c60751f4e99e2cc1d6bf70f44e181 | Ruby | annielin28815/ruby-hw1 | /0.8.05 - 邏輯判斷與流程控制/09.case-range-02.rb | UTF-8 | 204 | 3.78125 | 4 | [] | no_license | # 用case...when...的寫法1
age = 10
case
when age >= 0 && age <= 3
puts "嬰兒"
when age >= 4 && age <= 10
puts "兒童"
when age >= 11 && age <= 17
puts "青少年"
else
puts "成年"
end | true |
dfbba92e4d397074884a83dd6b49e23b35aca8ff | Ruby | danielnsilva/pullreqs | /bin/comment_stripper.rb | UTF-8 | 1,594 | 2.734375 | 3 | [
"BSD-2-Clause"
] | permissive | #
# (c) 2012 -- 2014 Georgios Gousios <gousiosg@gmail.com>
#
# BSD licensed, see LICENSE in top level dir
#
module CommentStripper
def strip_shell_style_comments(buff)
in_comment = false
out = []
buff.each_byte do |b|
case b
when '#'.getbyte(0)
in_comment = true
when "\r"... | true |
6a16647abf3163bce17aaedf34e088e95eef3680 | Ruby | temi77/hwf-calculator | /app/forms/date_of_birth_form.rb | UTF-8 | 1,152 | 3.171875 | 3 | [] | no_license | # A form object for the date of birth question
# Allows for date's being represented using rails '1i, 2i and 3i' notation.
class DateOfBirthForm < BaseForm
# @!attribute [rw] date_of_birth
# @return [Date] The date of birth of the individual or the eldest in a couple
attribute :date_of_birth, :date
# The typ... | true |
c0d820b8cfe6f8ff362061694b409b6c9bb43137 | Ruby | Jean-Christian-petetin/algoPseudoCode | /algo3ruby.rb | UTF-8 | 181 | 2.5625 | 3 | [] | no_license | #author JesuScript
$word = "anticonstitutionnellement"
$char = "n"
$result = 0
$i = 0
while $i < $word.length
if $word[$i] == $char
$result += 1
end
$i += 1
end
print $result
| true |
faf30a65033a00c59913e2d9b8d6b97386477b9f | Ruby | SugarBowlAcademy/grade-calculator-laurenpalermo10 | /ProjectBegin.rb | UTF-8 | 3,118 | 4.3125 | 4 | [] | no_license | =begin
in this project you will be creating a program that tells people what grade they will need on a test to get a particular overall grade in the class. Look at the pseudocode below as an example of how the the UI is and how the calculation works
=end
=begin
desiredpoints = .9 x total + testworth
pointsontest= des... | true |
a872d155babb32a405ccdbba9d5bd2e6b4e35ff6 | Ruby | hashrocket/localpolitics.in | /vendor/plugins/rspec_expectation_matchers/lib/active_record/validates_uniqueness_of.rb | UTF-8 | 1,596 | 2.515625 | 3 | [
"MIT"
] | permissive | module EdgeCase
module RSpecExpectationMatchers
module ProvidesFor
module ActiveRecord
class ValidatesUniquenessOf < BaseValidationMatcher
def initialize(attribute, options = {})
@attribute = attribute.to_sym
@options = options
@invalid_value = @option... | true |
2222bde8c37c5afb3ef2efaf5c43cd17e198a620 | Ruby | ajLapid718/CodeWars-Problems | /6Kyu Kata/Numerical_Palindrome_Three_Point_Five.rb | UTF-8 | 1,788 | 4.3125 | 4 | [] | no_license | # A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward as forward. Examples of numerical palindromes are:
#
# 2332
# 110011
# 54322345
#
# For a given number num, write a function which returns an array of all the numerical palindromes contained within each number. The a... | true |
eb9292c2c418c66138eb14bc35c1e4175acd955b | Ruby | rscustom/rocksmith-custom-song-toolkit | /RocksmithToolkitCLI/generalscripts/sng-decrypt-cfb.rb | UTF-8 | 4,279 | 2.796875 | 3 | [] | no_license | require 'openssl'
require 'zlib'
def convert_key(key)
keystr = ''
key.each { |k|
a = k >> 24
b = k >> 16 & 0xff
c = k >> 8 & 0xff
d = k & 0xff
dword = sprintf('%c%c%c%c', d,c,b,a)
keystr += dword
}
return keystr
end
# AES-256-CFB, uninitialized IV
# TOC header key
toc = [ 0x38b23dc5, ... | true |
7106b5565a2aab04439d77fce17521f2964b4c55 | Ruby | cunhasb/project-euler-multiples-3-5-web-100817 | /lib/primenumbers.rb | UTF-8 | 140 | 3.484375 | 3 | [] | no_license | require 'pry'
def prime(n)
is_prime = true
(2...n).each do |i|
if n% i == 0
is_prime = false
break
end
end
is_prime
end
| true |
d1c49f2bc6427b6249661719ccf1231da193f4b9 | Ruby | Foreversparce1/Fundamentos-2013 | /TallerPC03/ejecicio01.rb | UTF-8 | 1,605 | 3.546875 | 4 | [] | no_license | =begin
Una persona tiene un dinero que ha heredado. Necesita tomar la decisión de dónde colocarlo para que le rinda una rentabilidad adecuada. Para esto, ha investigado que un banco le puede ofrecer por su dinero en modalidad a Plazo Fijo, una atractiva oferta.
La oferta consiste en tener tasas de interés escalonadas ... | true |
7f1efaff53515920efbb91a4f3ad899aa11365ed | Ruby | Efutei/atcoder | /ABC100/ringo.rb | UTF-8 | 161 | 2.921875 | 3 | [] | no_license | a,b=gets.chomp.split(" ").map(&:to_i)
if b==100 then
b += 1
end
if a == 0 then
ans = b
elsif a == 1 then
ans = b * 100
else
ans = b * 10000
end
puts ans
| true |
bd63462f25ca4e71f0196ca42265947376d056c6 | Ruby | gaohongwei/ruby_tool | /array.rb | UTF-8 | 219 | 3.15625 | 3 | [] | no_license | These applys to Enumerable and array
########## map ##########
ar.map(&:name)
ar.map{|x|x.name}
########## any?, all? ##########
It takes a block
The default block {|x|x} if no block provided
The block returns a bool
| true |
8b7850a2c7dd306f6929ba01b6e0ed084b2fc09b | Ruby | gively/mdex_client | /lib/mdex_client/mdata/record.rb | UTF-8 | 1,416 | 2.546875 | 3 | [
"MIT"
] | permissive | require 'mdex_client/mdata/node'
module MDEXClient
module MData
class Record < Node
class Attributes < Hash
def initialize(*args)
super(*args)
@dimension_value_ids = {}
@dimension_ids = {}
end
def dimension_value_id(key)
@d... | true |
417d8f48ea0eb2ec55a6d72e5303a317fac925c1 | Ruby | MariaMancipe/smart-tools | /lib/test_converter.rb | UTF-8 | 1,823 | 2.59375 | 3 | [] | no_license | require 'streamio-ffmpeg'
require 'mysql2'
require 'fileutils'
$original = "#{ENV['VIDEO_ORIGINAL']}"
$converted = "#{ENV['VIDEO_CONVERTED']}"
$upload = "#{ENV['VIDEO_UPLOAD']}"
def convert_to_mp4_five(path)
puts "convert to mp4 #{path}"
movie = FFMPEG::Movie.new(path)
converted = "./public/video/converted/"
... | true |
991ebfa6b7d5d2ef733afd05c3f643cd6d241e12 | Ruby | heroku/configvar | /test/helper.rb | UTF-8 | 495 | 2.734375 | 3 | [
"MIT"
] | permissive | module EnvironmentHelper
# Override an environment variable in the current test.
def set_env(key, value)
overrides[key] = ENV[key] unless overrides.has_key?(key)
ENV[key] = value
end
# Restore the environment back to the state before tests ran.
def teardown
overrides.each do |key, value|
EN... | true |
1f66d995b1ede1ec5600614dccdb22432e815d2b | Ruby | pzb/r509 | /lib/r509/openssl/pkey_ecdsa.rb | UTF-8 | 5,903 | 2.5625 | 3 | [
"Apache-2.0"
] | permissive | # vim: set sts=2 ts=2 sw=2 et:
if defined?(OpenSSL::PKey::EC) && !defined?(OpenSSL::PKey::EC::UNSUPPORTED)
module OpenSSL::PKey
class ECDSA < OpenSSL::PKey::EC
@initialized = false
def self.generate(arg)
if (arg.kind_of? String) || (arg.kind_of? Symbol)
curve_name = arg.to_s
... | true |
43c686d7d0f5a272e8a43805e08824ee820a0750 | Ruby | gloriasoh/exercises | /hello_world.rb | UTF-8 | 50 | 2.828125 | 3 | [] | no_license | result = 2 + 2
puts "The number is #{result + 4}"
| true |
e8312a0e4c5391ff627ebb7525c3feb20415ed63 | Ruby | ezgiyuksektepe/antfarm | /Meadow.rb | UTF-8 | 4,365 | 3.359375 | 3 | [] | no_license | require 'colorize'
require 'set'
require 'singleton'
require_relative 'Cell'
require_relative 'EventStore'
require_relative 'Queen'
class Meadow
include Singleton
attr_reader :num_cols
attr_reader :num_rows
attr_reader :num_queens
attr_reader :max_ants_per_hill
attr_reader :grid
def initialize
# Me... | true |
79e388c75ea2654342c6d9bfba1fd2fb3b48245a | Ruby | mymorkkis/ricks-music-stock-app | /specs/album_specs.rb | UTF-8 | 358 | 2.65625 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/rg'
require_relative '../models/album'
class TestAlbums < MiniTest::Test
def setup
@album1 = Album.new('title' => 'The Black Album', 'year' => 2003)
end
def test_album_title
assert_equal('The Black Album', @album1.title)
end
def test_album_year
asse... | true |
c6641d7a7db5c34e8f2b1c0d1223ea5ff4fafd24 | Ruby | bengler/tilt-jadeite | /benchmarks/benchmarks.rb | UTF-8 | 1,339 | 2.9375 | 3 | [
"MIT"
] | permissive | require 'bundler'
Bundler.require
require 'benchmark'
require 'haml'
require 'tilt-jadeite'
class Scope
def foo(what)
"Foo says #{what}"
end
def play(artist, song)
"Play #{song} from #{artist}"
end
def say_hello
"Hello to you!"
end
def fruity_song
"banana-na-na-na-na-na"
end
def ... | true |
7ce199ac0c198dd91ff8e5b74918664094971f35 | Ruby | dorton/tarantino | /app/models/profane_word.rb | UTF-8 | 333 | 3.0625 | 3 | [] | no_license | class ProfaneWord
def initialize(movie)
@movie = movie
end
def all_words
all_words = @movie.datasets.all.map { |a| a.profane_word }
end
def the_words
unique_words_array = all_words.uniq
end
def word_counts
the_words.each do |word|
all_words.select {|a| a == word }.count
en... | true |
3829ab0f3ebf082e5f1365bb38c52bb25c2aab20 | Ruby | WMudgeEllis/relational_rails | /app/models/book.rb | UTF-8 | 247 | 2.59375 | 3 | [] | no_license | class Book < ApplicationRecord
belongs_to :bookshelf
def self.read_books
Book.where(read: true)
end
def self.alphabetize
Book.order(:name)
end
def self.min_read_time(min)
Book.where("books.read_time > #{min}")
end
end
| true |
cbc4712274dc925f4aaddcadf83746f0da48a472 | Ruby | oconetta/archive.org-getter | /tv_data_analysis.rb | UTF-8 | 886 | 3.34375 | 3 | [] | no_license | require 'rubygems'
require 'json'
require 'pp'
#parse data from JSON files and store in array of hashes
tv_data = JSON.parse(File.read('TVNews_results200.json'))
tv_data += JSON.parse(File.read('TVNews_results400.json'))
tv_data += JSON.parse(File.read('TVNews_results600.json'))
tv_data += JSON.parse(File.read('TVNews... | true |
d6c210db89f3f9da08b318454c6e986550d306e8 | Ruby | Technici4n/beoi-training-1 | /scripts/json_build_units/json_build_units.rb | UTF-8 | 4,179 | 2.84375 | 3 | [] | no_license | #
# Script to build README.md files from JSON files
# You might need the "json" gem to run it
#
require 'pathname'
unless require 'json'
puts 'You need to install the json gem !'
exit
end
require_relative 'network_util'
class String
def is_i?
/\A[-+]?\d+\z/ === self
end
end
MAIN_DIR = '../../'
MAIN_... | true |
948371d2f05e57553eff58bb096ca33937f9640c | Ruby | at1as/terminal-rubiks | /printer.rb | UTF-8 | 3,268 | 3.21875 | 3 | [
"MIT"
] | permissive | module Printer
def draw_row(row)
'| ' + row.join(' | ') + ' |'
end
def draw_separator(len, offset = 0)
puts offset + '-' * len
end
def print_cell(cell, offset: 0, top: true, bottom: true)
width = 0
spacing = ' ' * offset
cell.each_with_index do |row, idx|
current_row = draw_row(r... | true |
d837c55c695db38c462d291dc31940342d60120d | Ruby | nagerz/SweaterWeather | /app/facades/forecast_facade.rb | UTF-8 | 934 | 2.84375 | 3 | [] | no_license | # frozen_string_literal: true
class ForecastFacade
attr_reader :location, :forecast
def initialize(location)
@location = location
@forecast = make_forecast(search_city(geodata))
end
def geolocation
geocode_service.geocode(@location)
end
def geodata
data = {}
data[:geo_lat] = geolocat... | true |
99a4d8a226bcd6a5aec45a5d7a1828bfeeb2bbb3 | Ruby | metalerk/distritos-electorales-mx | /seccion | UTF-8 | 2,554 | 2.6875 | 3 | [] | no_license | #!/usr/bin/env ruby
# encoding: utf-8
require_relative 'lib/common.rb'
require 'ruby-progressbar'
Crawler.max_concurrency = 200
secciones = Crawler::Runner.new URL_SECCIONES
secciones.request_parser = -> (request){
self.method = :post
self.body = {
e: data[:entidad],
q: data[:seccion],
t: 'seccion',
... | true |
422d7ab1d2b6af3dde8eade0305b49e0521cdfb8 | Ruby | tmikeschu/yahtzee | /test/yahtzee/getters_test.rb | UTF-8 | 632 | 2.90625 | 3 | [] | no_license | require "minitest/autorun"
require "yahtzee/getters"
module Yahtzee
class TestStore
include Getters
attr_reader :state
def initialize(hands = {})
@state = {hands: hands}
end
end
class GettersTest < Minitest::Test
def test_total_score_returns_0_initially
store = TestStore.new
... | true |
a268970cacdfd9ac78d83ccf274900f174978f2f | Ruby | Nick-Howlett/W2D1 | /chess/display.rb | UTF-8 | 1,580 | 3.34375 | 3 | [] | no_license | require "colorize"
require_relative "cursor"
require_relative "board"
require "byebug"
class Display
attr_accessor :possible_moves, :board
def initialize(board)
@board = board
@cursor = Cursor.new([0,0], board)
@possible_moves = []
end
def render
puts(" " + %w(0 1 ... | true |
b0ed34a2286a5165b21f4541869288c7130221cb | Ruby | baseonmars/boffin_tag | /library_tagger.rb | UTF-8 | 982 | 2.734375 | 3 | [] | no_license | require 'rubygems'
require 'id3lib'
require 'sqlite3'
db = SQLite3::Database.new( "LC.db" )
rows = db.execute("SELECT f.id, d.path, f.filename from files f INNER JOIN directories d on f.directory = d.id")
rows.each_with_index do |row,index|
puts "#{index}/#{rows.size} processing file /#{row[1]}#{row[2]}"
fi... | true |
e18d104fa2031ed4d0f81e9ea30f85393d143540 | Ruby | wrozka/capybara-angular | /lib/capybara/angular/waiter.rb | UTF-8 | 1,059 | 2.578125 | 3 | [
"MIT"
] | permissive | module Capybara
module Angular
class Waiter
WAITER_JS = IO.read(File.expand_path "../waiter.js", __FILE__)
attr_accessor :page
def initialize(page)
@page = page
end
def wait_until_ready
return unless driver_supports_js?
start = Time.now
until ready... | true |
499ab21e4bbe2a495bf913f34679010cf2ba516d | Ruby | trujillojosh/ruby | /d02/ex06/play_with_arrays.rb | UTF-8 | 110 | 2.921875 | 3 | [] | no_license | #!/usr/bin/env ruby
arr = [2, 8, 9, 48, 8, 22, -12, 2]
p arr
arr.uniq!
new = arr.map{|x| x += 2}
p new[1..4]
| true |
4fae7d90fcb6d34b7e4239820361c5798a3deaf8 | Ruby | MichaelCSlevin/high_school | /models/subject.rb | UTF-8 | 903 | 3.125 | 3 | [] | no_license | require_relative '../db/sql_runner'
class Subject
attr_accessor :id, :name, :teacher
attr_reader :id
def initialize (subject_hash)
@id = subject_hash['id'].to_i if subject_hash ['id']
@name = subject_hash['name']
@teacher = subject_hash['teacher']
end
def save
sql = "INSERT INTO subjects
... | true |
f198f7792d6b9fa71cfe788018b758eb2a2f938e | Ruby | Zahid4960/RoR_office_meal_management_system_backend | /app/services/designation_service.rb | UTF-8 | 699 | 2.515625 | 3 | [] | no_license | class DesignationService
require_relative '../repositories/designation_repository'
require_relative '../models/designation'
@@model = Designation
def index(page, limit)
designation_repo.designation_with_office(page, limit)
end
def create(payload)
designation_repo.save_data(@@model, payload)
en... | true |
4f9a907062a0e1b1f1f3a6beacfe3403499072f8 | Ruby | lindsayhong/ga_itr_final_project_lindsay_hong | /app/helpers/users_helper.rb | UTF-8 | 505 | 3.015625 | 3 | [] | no_license | module UsersHelper
# Calculate fairways and greens in regulation, sandies, and up and downs.
def yes_no_total(array)
array.count { |x| x == "Yes" || x == "No" }
end
def yes_count(array)
array.count("Yes")
end
def total_percentage(array)
calculate_percentage = array.count("Yes").to_f/yes_no_tot... | true |
38b51373484b851f9f275db162ee659ee92c5c82 | Ruby | rex/butler | /lib/utils/helpers.rb | UTF-8 | 342 | 2.90625 | 3 | [
"MIT"
] | permissive | module Utils
class Helpers
def self.header(text)
puts "\n------------\n\n#{text.upcase}\n-------\n"
end
def self.subheader(text)
puts " ---> #{text}\n====="
end
def self.to_object_id(str)
BSON::ObjectId.from_string(str)
end
def self.sanitize(str)
str.chomp.strip.... | true |
de5954627c1dba8fa3c663ec1ae019dbc8849739 | Ruby | pedrokp/contador | /contador.rb | UTF-8 | 740 | 3.0625 | 3 | [] | no_license | #Autor: Pedro Kowalski Pereira
#22/09/2017
require 'open-uri'
require 'nokogiri'
@dic = Hash.new(0)
doc = Nokogiri::HTML(open('http://www.threescompany.com/','r:UTF-8',&:read))
doc.css('script').remove
doc.css('style').remove
conteudo = doc.css('body')
def palavras_na_string(string)
string.scan(/[\w']+[^a-zA-Z]/... | true |
4020aeb1c6722215b2e4871c56459c2888613a04 | Ruby | nakajima/rebound | /spec/rebound_spec.rb | UTF-8 | 2,742 | 2.890625 | 3 | [
"MIT"
] | permissive | require File.join(File.dirname(__FILE__), 'spec_helper')
describe UnboundMethod do
before(:each) do
@a = Class.new { def foo; :bar end }
@b = Class.new { def called?; @called end }
@mod = Module.new { def call; @called = true; end }
@object_a = @a.new
@object_b = @b.new
end
describe "#name... | true |
5cff51f2b2fe8e0da63fda4c04c643295009a364 | Ruby | deatheragetr/playlister-rb | /lib/models/playlister.rb | UTF-8 | 1,410 | 3.09375 | 3 | [] | no_license | require_relative '../concerns/findbyname.rb'
class Artist
extend FindByName
attr_reader :genre
attr_accessor :name, :songs
@@artists = []
def self.count
@@artists.size
end
def self.reset_artists
@@artists = []
end
def self.all
@@artists
end
def self.get_binding
binding()
en... | true |
f711894642aafda8b87808430ad4863b9032703c | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/hamming/eaf59c367c9341b5977235e6398e6df3.rb | UTF-8 | 497 | 3.46875 | 3 | [] | no_license | class Hamming
def self.compute(first,second)
if first.eql?(second)
0
else
self.disparity(first,second)
end
end
def self.disparity(first,second)
disparityLevel=0
shorter=self.shorter(first,second)
(0..shorter).each do |i|
if not first[i].eql?(second[i])
disparityLev... | true |
56d4891b25e7df2756064a8a5ec527ab6169c2f4 | Ruby | alim/baseballstats | /app/controllers/players_controller.rb | UTF-8 | 5,020 | 2.625 | 3 | [
"MIT"
] | permissive | ########################################################################
# The PlayersController is responsible for managing the
# interaction and updating of Player records. It has all the
# standard CRUD actions plus an action that supports uploading and
# replacing the system's player records from a CSV file.
######... | true |
c31b3fa00ecce72342130acd228aaabfac387947 | Ruby | bxdn/RubyProjects | /RubyExcercises.rb | UTF-8 | 3,072 | 3.40625 | 3 | [] | no_license | def caesar_cipher(str,rep)
lows = [*('a'..'z')]
ups = [*('A'..'Z')]
output = str.chars.map do |let|
if lows.include?let or ups.include?let
if lows.include?let
ref = lows
else
ref = ups
end
ref[(ref.index(let)+rep)%26]
... | true |
bc4b6fb37b8e6c86ceb5ad318960c82f2bab279b | Ruby | krisswiltshire30/boris-bikes | /spec/docking_station_spec.rb | UTF-8 | 1,670 | 3.15625 | 3 | [] | no_license | require './lib/docking_station'
require './lib/bike'
describe DockingStation do
it { is_expected.to respond_to :release_bike }
it 'has a method dock' do
expect(subject).to respond_to :dock
end
it 'has a method bike that returns a bike' do
expect(subject).to respond_to :bikes
end
it 'returns do... | true |
d1a0515d1f41c255045721d082d3799eddd2c71c | Ruby | NoorAlkattan/atm_machine | /app/models/account.rb | UTF-8 | 1,548 | 3 | 3 | [] | no_license | class Account < ActiveRecord::Base
belongs_to :user
has_many :transactions, dependent: :destroy
#validates_presence_of :user_id
attr_accessor :amount
#validates :balance, :numericality => { greater_than_or_equal_to: 0 }
# validates :account_no, :balance, :presence => true
def deposit (a... | true |
a0130dff988b2e079a356c3e1f21496073904fca | Ruby | YanchWare/GitHubStats | /Report.rb | UTF-8 | 2,153 | 3.375 | 3 | [
"MIT"
] | permissive | =begin
Class representing an user object used in order to hold report data
=end
class User
def initialize(name, firstIssue)
@userName = name
@issuesSolved = [firstIssue]
end
def IssuesSolved
@issuesSolved
end
def UserName
@userName
end
def eql?(other_object)
(self.class.eq... | true |
bb70a3d2f8d0999f7fcadae4c02a52ff5295c28f | Ruby | blakeynwa/phase-0-tracks | /ruby/gps2_2.rb | UTF-8 | 3,731 | 4.34375 | 4 | [] | no_license | # Method to create a list
# input: string of items separated by spaces (example: "carrots apples cereal pizza")
# steps:
# Get user input - list (use driver code)
# set default quantity. How many items in the list .max
# print the list to the console [can you use one of your other methods here?]
# output: [what... | true |
a766b87e7f43fd56dcec78556fe1a3debd365495 | Ruby | 3den/hash_delegate | /lib/hash_delegate/accessor.rb | UTF-8 | 537 | 2.6875 | 3 | [
"MIT"
] | permissive | module HashDelegate
class Accessor < Struct.new :klass
def define_getter(key, hash)
define_delegation key do
data = self.send(hash) || {}
data[key.to_s] || data[key.to_sym]
end
end
def define_setter(key, hash)
define_delegation "#{key}=" do |value|
self.send(hash... | true |
6487a9b6f52067ca0a7ed619bbcee9fd2c785dd6 | Ruby | bekkopenkurs/railskurs | /spec/ntnu/api/course_parser_spec.rb | UTF-8 | 2,424 | 2.578125 | 3 | [] | no_license | #encoding: utf-8
require 'rspec'
require 'spec_helper'
require 'json'
require 'ntnu/api/parser'
module NTNU
module API
describe CourseParser do
it "should handle requests for invalid courses" do
nonexisting_course = JSON.parse('{ "course": [], "request": { "courseCode": "tdt5110" }}')
exp... | true |
62eedf72841b9371b87766674426f0de1c71d5c4 | Ruby | Malachirwin/malachis_gofish | /lib/card_deck.rb | UTF-8 | 775 | 3.546875 | 4 | [] | no_license | require_relative 'card'
class CardDeck
def initialize
@deck = create_deck
end
def create_deck
suits = ['H', 'D', 'S', 'C']
suits.map do |suit|
13.times.map do |number|
rank = number + 1
Card.new(suit, rank)
end
end.flatten
end
def shuffle
card_deck.shuffle!
... | true |
decfb3982d7a98424b0dd9515ab3e3a3f1e6f161 | Ruby | saikrishnagaddipati/rails-interview | /app/models/student.rb | UTF-8 | 785 | 3.015625 | 3 | [] | no_license | class Student < ActiveRecord::Base
# Instance method responsible for showing student's name
def name
# checking duplicate firstname
firstname_count = Student.where(firstname: firstname).count
# we are checking conditions as per duplicate firstname
firstname_count > 1 ? "#{firstname} #{lastname[0]}.... | true |
5b4f47d18f668ca07be392b666b96d33eba145c5 | Ruby | mercebc/TicTacToe-ruby | /lib/core/players_factory.rb | UTF-8 | 1,133 | 3.234375 | 3 | [] | no_license | require 'core/players/player_factory'
class PlayersFactory
MODE = {
:HUMAN_VS_HUMAN => 'h',
:HUMAN_VS_EASY_COMPUTER => 'e',
:HUMAN_VS_HARD_COMPUTER => 'i'
}
def initialize(ui)
@ui = ui
end
def build(mode, starting_player_symbol = "X")
new_player = PlayerFactory.new
players = Arra... | true |
33347e1973f37fddbfe1d490e26a38b6df373895 | Ruby | tdevereux/brine | /ruby/lib/brine/step_definitions/assertions.rb | UTF-8 | 1,595 | 2.9375 | 3 | [
"MIT"
] | permissive | # assertions.rb - General assertions to be used with a Selector
Then(/^it is equal to `([^`]*)`$/) do |value|
perform { selector.assert_that(value) {|v| eq v} }
end
Then(/^it is equal to:$/) do |value|
perform { selector.assert_that(value) {|v| eq v} }
end
Then(/^it is matching `([^`]*)`$/) do |value|
perform { ... | true |
d36afb09a1321f44b354446453cda266253d7a13 | Ruby | rbotafogo/galaaz | /lib/R_interface/rlanguage.rb | UTF-8 | 3,175 | 2.828125 | 3 | [
"BSD-2-Clause"
] | permissive | # -*- coding: utf-8 -*-
##########################################################################################
# @author Rodrigo Botafogo
#
# Copyright © 2018 Rodrigo Botafogo. All Rights Reserved. Permission to use, copy, modify,
# and distribute this software and its documentation, without fee and without a sig... | true |
d7eb31c47546d45788b0eb3c30b17b0122c6bd8e | Ruby | oguzpol/ruby-tutorial | /while_keyword.rb | UTF-8 | 625 | 3.234375 | 3 | [] | no_license | # i = 1
# while i < 10
# puts i
# i += 1
# end
# puts
# p i
# password condition
# status = true
# while status == true
# print "Please enter username : "
# username = gets.chomp.downcase
# print "Plesase enter password : "
# password = gets.chomp.downcase
# if username == "boris" && password == "be... | true |
faa183eb8a42d654b8ca12197f251d809576928a | Ruby | festinalent3/learn_to_program | /ch09-writing-your-own-methods/old_school_roman_numerals.rb | UTF-8 | 1,295 | 3.828125 | 4 | [] | no_license | def old_roman_numeral num
roman_array = ["I", "V", "X", "L", "C", "D", "M"]
to_roman = ""
to_roman << roman_array[6] * (num / 1000)
to_roman << roman_array[5] * (num % 1000/ 500)
to_roman << roman_array[4] * (num % 500/ 100)
to_roman << roman_array[3] * (num % 100/ 50)
to_roman << roman_array[2] * (num... | true |
7bef3d03e446427a3410def07112094dc3dfe3c2 | Ruby | muupan/project_euler | /42/pe42.rb | UTF-8 | 481 | 3.59375 | 4 | [] | no_license | $score_of_a = "A".bytes.to_a[0]
def calc_score_of_char(char)
char.bytes.to_a[0] - $score_of_a + 1
end
def calc_score(word)
return word.split("").inject(0){|sum, c| sum + calc_score_of_char(c)}
end
def is_triangle_number(n)
for i in 1...999 do
return true if i * (i + 1) / 2 == n
return false if i * (i + 1) / 2... | true |
7b59d12fae1d008f7a56a1d2bfcdc8d6770c62a0 | Ruby | SoftwareWithFriends/forwardable_content_hash_binder | /lib/forwardable_content_hash_binder.rb | UTF-8 | 434 | 2.734375 | 3 | [
"MIT"
] | permissive |
class ForwardableContentHashBinder
attr_reader :content_hash
def initialize(content_hash)
@content_hash = content_hash
end
def method_missing(method, *args)
super(method, args) unless @content_hash[method.to_s]
value = @content_hash[method.to_s]
return value unless value.kind_of? Proc
val... | true |
a0ae749782164f1416c4c32e2b560446b268071b | Ruby | edwardkerry/airport_challenge | /lib/airport.rb | UTF-8 | 1,136 | 3.296875 | 3 | [] | no_license | require_relative 'plane'
require_relative 'weather'
class Airport
attr_accessor :capacity
attr_reader :runway
STANDARD_CAPACITY = 10
def initialize(capacity = STANDARD_CAPACITY)
@runway = []
@stormy = Weather.new
@capacity = capacity
end
def land_plane(inbound_plane)
fail "Plane already... | true |
ae52d90930e7c3a0a49a8d0689ad29bc6f142e87 | Ruby | freejacque/project_euler | /question_01.rb | UTF-8 | 109 | 2.890625 | 3 | [] | no_license |
selected_numbers = (1..999).find_all { |i| i % 3 == 0 || i % 5 == 0}
answer = selected_numbers.reduce(:+)
| true |
3e92d1bba2891a59481fb82c8b20768fbc973bdf | Ruby | fafafariba/app-academy-projects | /w3d3/URLShortener/app/models/shortened_url.rb | UTF-8 | 1,160 | 2.609375 | 3 | [] | no_license | # require 'secure_random'
# == Schema Information
#
# Table name: shortened_urls
#
# id :integer not null, primary key
# short_url :string
# long_url :string not null
# submitter_id :integer not null
#
class ShortenedUrl < ActiveRecord::Base
validates :short_url, uni... | true |
77282b17f39fa8402c1d3dab9c5bc3eb1f477455 | Ruby | nemrow/guess_who | /db/seeds.rb | UTF-8 | 988 | 2.65625 | 3 | [] | no_license | require 'faker'
User.delete_all
Friend.delete_all
Board.delete_all
# Create 200 users
def create_user
id = (1..100).to_a.sample
user = User.create( :first_name => Faker::Name.first_name,
:last_name => Faker::Name.last_name,
:email => Faker::In... | true |
9c588ccf2c12e32d0a698369f77a76fc1055821b | Ruby | SpringMT/study | /ruby/reading_meta_ruby/20120405/shared_scope.rb | UTF-8 | 187 | 2.875 | 3 | [] | no_license | #!/usr/bin/env ruby
# encoding: UTF-8
require 'pp'
def my_method
@shared = 0
end
def counter
p @shared
end
def inc(args)
@shared += args
end
my_method
counter
inc(4)
counter
| true |
494db0b0d6ddc4a10cce2809ee17a5479673bae3 | Ruby | trailblazer/reform | /test/changed_test.rb | UTF-8 | 1,100 | 2.6875 | 3 | [
"MIT"
] | permissive | require "test_helper"
require "reform/form/coercion"
class ChangedTest < MiniTest::Spec
Song = Struct.new(:title, :album, :composer)
Album = Struct.new(:name, :songs, :artist)
Artist = Struct.new(:name)
class AlbumForm < TestForm
property :name
collection :songs do
property :title
prope... | true |
665c1e191e01e8fa52286bcd3b1d82aa0bec8a03 | Ruby | houndci/hound | /spec/models/commit_spec.rb | UTF-8 | 2,639 | 2.546875 | 3 | [
"MIT"
] | permissive | require "spec_helper"
require "attr_extras"
require "octokit"
require "app/models/commit"
describe Commit do
describe "#file_content" do
context "when content is returned from GitHub" do
it "returns content" do
commit = build_commit("some content")
expect(commit.file_content("test.rb")).to... | true |
f1b5469ba70234d44e52e4f983b5d1fb1a826fd0 | Ruby | trevorwhitney/csci446 | /project05/test/unit/author_test.rb | UTF-8 | 1,110 | 2.65625 | 3 | [] | no_license | require 'test_helper'
class AuthorTest < ActiveSupport::TestCase
setup do
@valid_photo = File.new("test/fixtures/onion.jpg")
@invalid_photo = File.new("test/fixtures/lena.bmp")
end
teardown do
@valid_photo.close
@invalid_photo.close
end
test "name_should_not_include_pat" do
author = ... | true |
8e10efa5e412cf7975f873b1acc979d2b20e26ae | Ruby | andrewmorrismacleod/ruby_project | /models/film.rb | UTF-8 | 1,649 | 3.140625 | 3 | [] | no_license | require_relative( '../db/sql_runner' )
require_relative ('actor')
require 'pry'
class Film
attr_reader :id, :title
def initialize( options )
@id = options['id'].to_i if options['id']
@title = options['title']
end
def save()
sql = "INSERT INTO films
(title)
VALUES
($1)
RETUR... | true |
4a9d6305457abeba162ab3105c3cccfa1cae9e80 | Ruby | bruadarach/ruby-study-note | /114_rubyiestNotesStyle.rb | UTF-8 | 1,835 | 4.34375 | 4 | [] | no_license | ##### IMPLICIT RETURNS #####
# Less Preferred
def get_avg(num_1, num_2)
return (num_1 + num_2) / 2
end
puts get_avg(4, 6) #=> 5
# Preferred by a Rubyist
def get_avg(num1, num2)
(num1 + num2) / 2
end
puts get_avg(2, 6) #=> 4
##### OMMITTING PARENTHESES FOR METHOD CALLS WITH NO ARGUMENTS #####
# Less pref... | true |
74cc4eb63d8c8f29009a85b1fe559a6ea2f63020 | Ruby | lassebunk/shortie | /lib/shortie/service.rb | UTF-8 | 783 | 3.265625 | 3 | [] | no_license | module Shortie
class Service
@@services = []
# Register a new service by key, name, and shortener, e.g. register("bitly", "bit.ly", Bitly).
def self.register(key, name, shortener)
@@services << Service.new(key, name, shortener)
end
# Get a list of all services.
def self.all
... | true |
f2edbd1e2475be1d1bd666834b6af4b7ad1f8a4a | Ruby | harrim91/airport_challenge | /lib/airport.rb | UTF-8 | 1,416 | 3.46875 | 3 | [] | no_license | require_relative "weather"
class Airport
include Weather
DEFAULT_CAPACITY = 1
STORM_ERR = "The weather is stormy"
ACCEPT_ERR = "Plane already at an airport"
RELEASE_ERR = "Plane not at this airport"
FULL_ERR = "Airport is full"
def initialize capacity=DEFAULT_CAPACITY
@planes = []
@capacity = c... | true |
4d9896f55c94623abc437ba180d1d881f4d84de3 | Ruby | Krishna312/test | /calculator.rb | UTF-8 | 893 | 4.1875 | 4 | [] | no_license | def add(a,b)
result = a + b
# put your code here
end
def subtract(a,b)
result = a - b
# put your code here
end
def multiply(a,b)
result = a * b
# put your code here
end
def divide(a,b)
result = a / b
# put your code here
end
puts "Welcome to RubyCalc"
print "Enter first number: "
a = gets.chomp
... | true |
76ec221623e45cdccb3debd2dbac4144c77ec3a9 | Ruby | koiralakiran0/ruby-calisthenics | /lib/cartesian_product.rb | UTF-8 | 381 | 3.703125 | 4 | [] | no_license | class CartesianProduct
include Enumerable
# YOUR CODE HERE
def initialize(arr1, arr2)
@array1 = arr1
@array2 = arr2
end
def each
# ret = []
@array1.each { |x|
#temp = [x]
@array2.each { |y|
#temp.push(y)
yield [x,y]
}
# ret.push(temp)
}
#return re... | true |
de9911625514571012473de83a0985fbf4eb807f | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/hamming/c8cb0105340244edb5f91e4b184cb4a9.rb | UTF-8 | 255 | 2.765625 | 3 | [] | no_license | class Hamming
def self.compute dna_strand_a, dna_strand_b
merged_dna = dna_strand_b.split('').zip dna_strand_b.split('')
merged_dna.reduce(0) do |differences, joint|
differences += 1 if joint.uniq == 2
differences
end
end
end
| true |
2539f359e91a91bbeb09f17cfe5b7b5fc28eeebe | Ruby | Maha-Magdy/Custom-HTML-Linter | /bin/main.rb | UTF-8 | 2,015 | 2.515625 | 3 | [
"MIT"
] | permissive | require 'nokogiri'
require 'open-uri'
require 'colorize'
require 'tty-box'
require 'ruby-progressbar'
require_relative '../lib/file_reader'
require_relative '../lib/reviewer'
system 'clear'
system 'cls'
if ARGV[0].nil?
puts TTY::Box.warn('There is no file passed to check.')
else
progressbar = ProgressBar.create(f... | true |
7a0e9343b64ec0ed6871de67dfee3fc892bf39af | Ruby | forgotera/BMSTU_PROG_WEB_3SEM | /lab6_3/lambdaMain6_3.rb | UTF-8 | 297 | 3.796875 | 4 | [] | no_license | require './logical6_3'
def main(n)
puts "enter #{n} coordinate x y "
(0...n).each do |i|
puts "#{i+1} coordinate"
x = gets.to_f
y = gets.to_f
yield x, y
end
end
puts 'how much coordinate do you want to enter?'
n = gets.to_i
block = ->(x, y) { neibr x, y }
main(n, &block)
| true |
9ef2b01949350738e994db862f0709ab9fab8bae | Ruby | pombreda/NounNews | /lib/noun_identifier/override.rb | UTF-8 | 760 | 3.296875 | 3 | [] | no_license | module NounIdentifier
class Override
def initialize(identifier)
@identifier = identifier
@nouns = File.read('data/override/nouns.txt').split.map(&:downcase)
@not_nouns = File.read('data/override/not_nouns.txt').split.map(&:downcase)
end
def is_noun?(word)
# no posessives
... | true |
661ff51e5fd8a375f11e0e32243b4801c37f0f98 | Ruby | Matt808/Challenge-F | /Banger.rb | UTF-8 | 456 | 2.953125 | 3 | [] | no_license | # Use this variable to speed up, then slow down the sample
x = 1
# Use this variable to store the long file path of your sample
banger = "C:/Users/matthew_marin/Downloads/challenge_f/this_is_a_banger.wav"
sample banger
sleep 3
4.times do
x = x - 0.1
sample banger, rate: x
sleep 3
print x
end
4... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.