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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
f10bb6b8aacb6248606fd891cb48adff18f766f0 | Ruby | lucasnvp/TADP-PatternMatching | /spec/executable_context_spec.rb | UTF-8 | 564 | 2.5625 | 3 | [] | no_license | require 'rspec'
require_relative '../lib/_executable_context'
describe 'Execution Context' do
context 'test context' do
it 'that the value is the correct one' do
_hash = {a: 1, b: 2}
context = ExcecutableContext.from _hash
expect(context.instance_eval(&proc {a + b})).to eq 3
end
it '... | true |
d4471043f1436569ced110be1814658d7d6054a6 | Ruby | Protobit/ridoku | /lib/ridoku/maintenance.rb | UTF-8 | 1,614 | 2.671875 | 3 | [
"BSD-2-Clause"
] | permissive | #
# Command: maintenance
#
require 'ridoku/base'
module Ridoku
register :maintenance
class Maintenance < Base
attr_accessor :app
def run
clist = Base.config[:command]
command = clist.shift
sub_command = clist.shift
case sub_command
when 'on'
maintenance(true)
... | true |
1d4ab5589086b436542ff75dc80f66b0ae1ad42a | Ruby | aimangual/amangual-Blocmetrics | /db/seeds.rb | UTF-8 | 771 | 2.578125 | 3 | [] | no_license | require 'faker'
# create users
5.times do
user = User.new(
name: Faker::Name.name,
email: Faker::Internet.email,
password: 'password'
)
user.skip_confirmation!
user.save!
end
users = User.all
# create registered applications
counter = 0
10.times do
counter += 1
app = RegisteredApplication.crea... | true |
fc2a17181a7a005b314e52fd96e2f58d5853b9d0 | Ruby | kirankm/Launch_School | /RB101/lesson_5/practice/ex_15.rb | UTF-8 | 197 | 3.078125 | 3 | [] | no_license | arr = [{a: [1, 2, 3]}, {b: [2, 4, 6], c: [3, 6], d: [4]}, {e: [8], f: [6, 10]}]
out = arr.select do |hsh|
hsh.values.all? do |int_arr|
int_arr.all? {|x| x.even?}
end
end
puts out.inspect
| true |
3fef5770f23658e8c4202c25fddff3f7abcc8639 | Ruby | AndyStabler/honeybadger-api | /lib/honeybadger-api/paginator.rb | UTF-8 | 1,656 | 2.921875 | 3 | [
"MIT"
] | permissive | module Honeybadger
module Api
class Paginator
attr_reader :current_page, :total_page_count, :pages
def initialize(path, filters, handler)
@path = path
@filters = filters
@handler = handler
@pages = {}
@filters.merge!({ :page => 1 }) if !@filters.has_key?(:pa... | true |
9db1ba98757008e1b5f2b7a18266bc638a74b66b | Ruby | gabriel-murakami/bike-tipo-vc | /app/services/devolution_service.rb | UTF-8 | 757 | 2.5625 | 3 | [] | no_license | # frozen_string_literal: true
class DevolutionService
attr_reader :devolution_station, :bike, :user
def initialize(station:, bike:, user:)
@devolution_station = station
@bike = bike
@user = user
end
def execute
return false if same_station_from_initial? || devolution_station.full?
Active... | true |
9fd3623f0eacabcba9781c6a020cfa5cf7a26fc1 | Ruby | kalpeshdave/BowlingGame | /lib/bowling_game.rb | UTF-8 | 941 | 3.1875 | 3 | [] | no_license | class BowlingGame
def initialize(*total_knocked_pins)
fail "Please provie valid input score for each run" if total_knocked_pins.size < 20 || total_knocked_pins.empty?
@frames = []
total_knocked_pins.each_slice(2) {|slice| @frames << slice}
fail "For each frame knocked pins should not exceeds 10" if @... | true |
b6255b74aa863746cf1c1dcaf9a2ec672c63a17c | Ruby | signaturelabs/pixxxer | /lib/pixxxer/field.rb | UTF-8 | 1,070 | 2.828125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require 'pixxxer/field_pixxxitter'
require 'pixxxer/field_depixxxitter'
class PixxxerField
attr_reader :width, :name, :position, :type, :precision, :true_value, :false_value
def initialize(field_name, template, true_value, false_value)
@template = template
@name = field_name
@position = 0
@precision = 0
@t... | true |
754e41bd47235636421e9d5d0337e8024d1291af | Ruby | schambers/learning-ruby | /scripts/statements.rb | UTF-8 | 120 | 2.96875 | 3 | [] | no_license | radiation = 4000
puts "Danger Will Robinson!" if radiation > 3000
square = 2
square = square*square while square < 1000
puts square
| true |
ca192bb4c89f5606927123d581843c0a75a69c10 | Ruby | rubyunworks/corpus-ruby | /work/deprecated/word_table.rb | UTF-8 | 1,483 | 3.40625 | 3 | [] | no_license | module Corpus
##
#
#
class WordTable
include Enumerable
#
# Initialize new WordTable object.
#
def initialize(table={})
@table = table
end
#
# Table is a hash.
#
# Returns [Hash].
#
attr :table
#
#
#
def [](spelling)
table[spelling]... | true |
2e5a4a6dab8ef8a647a8b6dea17054a410803f5c | Ruby | thomasleyer/ruby_course | /find_successor.rb | UTF-8 | 184 | 3.703125 | 4 | [] | no_license | #!/usr/bin/env ruby
print "Please enter a number: "
number = gets.chop
if ( number.to_s == number.to_i.to_s )
puts number.succ
else
puts "No, really, I meant enter a number!"
end
| true |
269a88038060dfd4963dbbfd4695ecb26c4d74b2 | Ruby | tanaken0515/ruby-examination | /gold/challenge01/ex29/sample01.rb | UTF-8 | 270 | 3.453125 | 3 | [] | no_license | module Enumerable
def with_prefix(prefix)
return to_enum(hoge, prefix) { size } unless block_given?
each do |char|
yield "#{prefix} #{char}"
end
end
end
[1,2,3,4,5].with_prefix("Awesome") {|char|
puts char
}
[1,2,3,4,5].with_prefix("Awesome")
| true |
2c14465a996927febe396ab67f3c83d3151dced7 | Ruby | lyang/braintree-rails | /lib/braintree_rails/array_ext.rb | UTF-8 | 217 | 3.015625 | 3 | [
"MIT"
] | permissive | class Array
def deep_dup
self.dup.tap do |dupped|
dupped.each_with_index do |element, index|
dupped[index] = element.respond_to?(:deep_dup) ? element.deep_dup : element
end
end
end
end
| true |
45d895eb3c3ee5deb6d70930f6752327e4bb0927 | Ruby | cohako/TreinaDev_Logica | /exercicio2.rb | UTF-8 | 398 | 3.5 | 4 | [] | no_license |
alunos=[]
aluno = {nome: 'Murilo', nota: 7, disciplina: 'Arte'}
alunos << aluno
puts alunos[0]
#posso adicionar varios hashs ao mesmo tempo no array
alunos = [{nome: 'Murilo', nota: 7, disciplina: 'Arte'},
{nome: 'Pedro', nota: 3, disciplina: 'Arte'},
{nome: 'Paulo', nota: 8, disciplina: 'Arte'}]
#para exib... | true |
291cf6e40d7a419c23f705e81281a4c1fdb397c0 | Ruby | bvehige/sinatra-mvc-lab-online-web-sp-000 | /models/piglatinizer.rb | UTF-8 | 488 | 3.28125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class PigLatinizer
def convert_word(text)
if /^[aeiou]/i.match(text)
"#{text}way"
else
word = text.split(/([aeiou].*)/)
"#{word[1]}#{word[0]}ay"
end
end
def piglatinize(text)
#vowels = ["a", "e", "i", "o", "u", "A", "E", "I", "O", "U"]... | true |
9269043cb51923a29e984c11a42db07ee6364378 | Ruby | marcandre/backports | /lib/backports/2.4.0/comparable/clamp.rb | UTF-8 | 442 | 2.765625 | 3 | [
"MIT"
] | permissive | unless Comparable.method_defined? :clamp
require 'backports/tools/arguments'
module Comparable
def clamp(min, max)
if Backports.coerce_to_comparison(min, max) > 0
raise ArgumentError, "min argument must be smaller than max argument"
end
case Backports.coerce_to_comparison(self, min)
... | true |
bccabb3052697e63144a9ceef3e7b8da3520e779 | Ruby | glv/smithereen | /lib/smithereen/grammar.rb | UTF-8 | 3,308 | 2.96875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'active_support/core_ext/module/attribute_accessors'
module Smithereen
class Grammar
END_TOKEN_TYPE = :"(end)"
attr_accessor :parser
attr_reader :symbol_table
def initialize
@symbol_table = self.class.symbol_table.dup
end
def symbolize(token)
token.tap do
... | true |
370a91ea95e3ff5846993687a85950ee0275bfae | Ruby | Drumitar/regex-lab-v-000 | /lib/regex_lab.rb | UTF-8 | 490 | 3.421875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def starts_with_a_vowel?(word)
if word.match(/\A[aeiouAEIOU]/)
true
else
false
end
end
def words_starting_with_un_and_ending_with_ing(text)
text.scan(/un[a-z]*ing/)
end
def words_five_letters_long(text)
text.scan(/\b[a-z]{5}\b/)
end
def first_word_capitalized_and_ends_with_punctuation?(text)
if t... | true |
44fd69b61c36c54b0676cbf967fb1612b43de64c | Ruby | jstricklin89/OO-mini-project-houston-web-082718 | /app/models/Ingredient.rb | UTF-8 | 990 | 3.359375 | 3 | [] | no_license | class Ingredient
attr_accessor :name
@@all = []
def initialize(name)
@name = name
@@all << self
end
# This is a custom helper method for allergens
# in the recipe class. It links an ingredient from the
# allergen array to an ingredient instance.
def allergen?
... | true |
adf6e5444ed48bba5e535845d02edc19fde894bb | Ruby | porawiec/programming-univbasics-4-array-concept-review-lab-chicago-web-111819 | /lib/array_methods.rb | UTF-8 | 392 | 3.28125 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def find_element_index(array, value_to_find)
# Add your solution here
if array.include?(value_to_find) == true
index_val = array.index(value_to_find)
index_val
else
nil
end
end
def find_max_value(array)
# Add your solution here
array.sort!
max = array.last
max
end
def find_min_value(array)... | true |
691073250b8fcea0285d237c95eabd50d1d4d9e0 | Ruby | TheGreatestZenMaster/RubyChess | /lib/player.rb | UTF-8 | 385 | 3.796875 | 4 | [] | no_license | class Player
attr_reader :name, :color
def initialize(color)
@name = name
(color == "white")? @color = :white: @color = :black
end
def check_color(piece)
same_color = false
piece.nil?? (puts "There's no piece there!"): (piece.color == @color.to_s)? same_color = true:... | true |
9c056bbf2c8bbad13136eea5ba10df27adc1c4d9 | Ruby | pooza/ginseng-core | /lib/ginseng/periodic_creator.rb | UTF-8 | 1,876 | 2.59375 | 3 | [
"MIT"
] | permissive | module Ginseng
class PeriodicCreator
include Package
attr_reader :dir, :counter
def initialize(period)
@dir = PeriodicCreator.destroot(period)
@logger = logger_class.new
rewind
end
def rewind
@counter = 900
end
def clear
Dir.glob(File.join(dir, '*')) do |f|... | true |
74b5422193e813730b075d9ed50f6152b3cec981 | Ruby | femto/trailblazer-activity | /test/finalizer_test.rb | UTF-8 | 7,795 | 2.578125 | 3 | [] | no_license | require "test_helper"
class DrawGraphTest < Minitest::Spec
Right = Activity::Right
Left = Activity::Left
# Z = "bla"
class S; end
class A; end
class E; end
class B; end
class C; end
class F; end
class ES; end
class EF; end
=begin
[
S: -R>
R> A: -R> -L> a is magnetic to R (incoming)
]
=end
... | true |
ab415076e197f9fb1e4e5b6aeff3e1f27a010231 | Ruby | muzammal-murtaza/etyme | /app/models/concerns/date_calculation.rb | UTF-8 | 295 | 2.9375 | 3 | [] | no_license | # frozen_string_literal: true
module DateCalculation
def date_of_next(day, current_date)
s = current_date.wday
n = Date.parse(day).wday
i = if s < n
n - s
elsif s > n
n + (7 - s)
else
7
end
current_date + i.days
end
end
| true |
1555ef1c3801b2b68af0f9a1a606296600cbd4c0 | Ruby | Kpumuh/Git | /Salt.rb | UTF-8 | 731 | 3.453125 | 3 | [] | no_license | require "nokogiri"
require "open-uri"
PAGE_URL = "https://www.saltedge.com/pages/our_team"
page = Nokogiri::HTML(open(PAGE_URL))
#Store each member description in an array
review = []
reviews = page.css('div.team-list p').each do |rev|
review << rev.content
end
#Store all members in an array
name = []
membe... | true |
8b7963c216911c6232fd4735e25002a017cadd17 | Ruby | dangrammer/OO-FlatironMifflin-dumbo-web-82619 | /run.rb | UTF-8 | 740 | 3.15625 | 3 | [] | no_license | require_relative "lib/Manager"
require_relative "lib/Employee"
require 'pry'
# managers
michael = Manager.new("Michael Scott", 42, "Scranton Branch")
dwight = Manager.new("Dwight K. Schrute", 38, "Sales")
jim = Manager.new("Jim Halpert", 32, "Accounting")
# employees
meredith = Employee.new("Meredith Palmer", 35000... | true |
4510f56161765f2b7cae6f31e7ad33fe89f298e5 | Ruby | mathur7/Coding_Challenges | /palindrome.rb | UTF-8 | 524 | 4.40625 | 4 | [] | no_license | # Palindrome: a palindrome is a word that spells out the same word when the letters are reversed.
# Notable Examples:
# dad
# mom
# pop
# eye
# civic
# kayak
# level
# madam
# radar
# racecar
# Directions: write a method called is_palindrome
# that returns true if a word is a palindrome
# or false if it isn't. Don... | true |
b3b8b208025a88f86eee85c9e2b49101eb98a5bc | Ruby | lowderdev/katas | /ruby/code_wars/statistics_for_an_athletic_association.rb | UTF-8 | 612 | 3.109375 | 3 | [] | no_license | # strg = "01|15|59, 1|47|16, 01|17|20, 1|32|34, 2|17|17"
def stat(strg)
return '' if strg.empty?
results = []
strg.split(',').each do |result|
h_m_s = result.split('|').map(&:to_i)
results << (h_m_s[0] * 3600 + h_m_s[1] * 60 + h_m_s[2])
end
results.sort!
length = results.length
range = results[-... | true |
1453e6fa797192b27000ac7f5d07243c92b86c5f | Ruby | RSon84/ruby-object-initialize-lab-v-000 | /lib/person.rb | UTF-8 | 75 | 2.71875 | 3 | [] | no_license | class Person
def initialize(first_name)
@name = first_name
end
end
| true |
222bc3780756f6cc1dbcf5ea52bee3332f7b11a2 | Ruby | courtneyphillips/coin-machine | /spec/coin_app_spec.rb | UTF-8 | 514 | 2.515625 | 3 | [] | no_license | require ('rspec')
require ('./coin_app')
describe("Fixnum#coin_app") do
it("Counts how many times we can divide Money by 25") do
expect(120.coin_app()).to(eq([4,2,0,0]))
end
it("Counts how many dimes required to make change") do
expect(120.coin_app()).to(eq([4,2,0,0]))
end
it("Counts how many nic... | true |
b21e00f218f1ed8b6c72c9a13c39464bfbd4d27e | Ruby | apirogov/Aphorism | /im_funcs.rb | UTF-8 | 10,206 | 2.953125 | 3 | [] | no_license | #!/usr/bin/env ruby
#Request Funcs for IM
#Copyright (C) 2010 Anton Pirogov
#Licensed under the GPLv3 or later
#here all the fun happens :) this is an interface for the whole functionality...
#the data contains all commands and data as JSON... responses are JSON objects too
#evaluates the cmd string and does stuff an... | true |
aff031d7d100ebfeb69f6a88c02acc4e68fa22c6 | Ruby | dhruvilbadani/fa15-hw1 | /foobar.rb | UTF-8 | 115 | 2.765625 | 3 | [] | no_license | class Foobar
# Q4 CODE HERE
arr.map{|i| (i.to_i) + 2}.select{|x| (x <= 10 && x %2 == 0)}.uniq().inject(:+)
end
| true |
2678cfc1aa2659d63a396bc2c0c1483fefabc89c | Ruby | lisafolliard/places | /spec/places_spec.rb | UTF-8 | 1,001 | 3.46875 | 3 | [] | no_license | require('rspec')
require('places')
require('pry')
describe('Places') do # create class
# BEFORE
before() do
Places.clear() # calls clear method, update spec file to clear things out before each spec run:
end
describe('#location') do
it('create a location object') do
new_place = Places.new('Paris... | true |
2d10a5f08e2a324a76b58496c1afdae1aeaa835c | Ruby | juangb/leetcode | /datastructures/linked_lists/palindrome.rb | UTF-8 | 1,615 | 4.125 | 4 | [] | no_license | =begin
Palindrome Linked List
Given a singly linked list, determine if it is a palindrome.
Example 1:
Input: 1->2
Output: false
Example 2:
Input: 1->2->2->1
Output: true
Follow up:
Could you do it in O(n) time and O(1) space?
=end
load 'list_node.rb'
#################
# O(n) time and O(1) space
# I will reverse ... | true |
3f350189acca72b461589992179afb8b1b092693 | Ruby | wtag/lsv-plus | /lib/lsv_plus/record.rb | UTF-8 | 1,862 | 2.84375 | 3 | [] | no_license | require 'bigdecimal'
require 'lsv_plus/base_container'
require 'lsv_plus/errors'
module LSVplus
class Record < LSVplus::BaseContainer
class InvalidProcessingDate < LSVplus::Errors::InvalidAttribute
ATTRIBUTE = :processing_date
end
class InvalidAmount < LSVplus::Errors::InvalidAttribute
ATTRIB... | true |
b3ba7799679f72e7329eb1d05b37faa898b29173 | Ruby | HenryPascua/MiniRubyExperiments- | /ruby/rps.rb | UTF-8 | 299 | 3.25 | 3 | [] | no_license | $player_score
$computer_score
puts "lets play rock paper scissors"
puts "Rock Paper scissors.... shoot! (give me an one)"
player_input = gets.chomp
a = %w(rock paper scissors)
def input
computer = rand(3)
if computer == 0
puts "paper"
elsif computer == 1
puts "rock"
else
end
end
| true |
d43842423b956e78a75b4287558c15d89a531906 | Ruby | ub-digit/dFlow | /backend/app/models/source.rb | UTF-8 | 1,187 | 2.53125 | 3 | [] | no_license | class Source
def self.find_by_name(name)
source = SYSTEM_DATA["sources"].find{|x| x["name"] == name}
if source.nil?
return nil
else
return Kernel.const_get("#{source["class_name"]}")
end
end
def self.find_by_class_name(class_name)
source = SYSTEM_DATA["sources"].find{|x| x["class... | true |
f39a7006b3c28a8d0c7148395baa028c21242868 | Ruby | collabnix/dockerlabs | /vendor/bundle/ruby/2.6.0/gems/rouge-3.26.0/lib/rouge/lexers/escape.rb | UTF-8 | 1,528 | 2.625 | 3 | [
"Apache-2.0",
"MIT",
"BSD-2-Clause"
] | permissive | # -*- coding: utf-8 -*- #
# frozen_string_literal: true
module Rouge
module Lexers
class Escape < Lexer
tag 'escape'
aliases 'esc'
desc 'A generic lexer for including escaped content - see Formatter.enable_escape!'
option :start, 'the beginning of the escaped section, default "<!"'
... | true |
80ac08d526b69532b118b77e1319babaa5a151f2 | Ruby | Segreto/segreto-cli | /src/api/secret.rb | UTF-8 | 1,269 | 2.65625 | 3 | [] | no_license | require 'base64'
class Secret < API::Record
attr_accessor :key
attr_reader :encrypted_value
def initialize params={}
@key = params[:key]
@cipher = OpenSSL::Cipher::AES.new 256, :CBC
if params[:plaintext]
self.client_iv = params[:client_iv] || generate_iv
self.value = params[:value]
... | true |
9ee06cc6b4a765a158dee2046e5a8b69aa5f5676 | Ruby | fernandoalmeida/akatus-rb | /lib/akatus/installments.rb | UTF-8 | 1,242 | 2.703125 | 3 | [] | no_license | module Akatus
class Installments
SIMULATION_URI =
def self.simulate(payment_method_code, amount)
url = "#{Akatus.akatus_api_uri}/parcelamento/simulacao.json?email=#{Akatus.seller_email}&api_key=#{Akatus.seller_api_key}&payment_method=#{payment_method_code}&amount=#{amount}"
request = HTTPI::Requ... | true |
ed2d5c0c788e06fe768aa9a0704558c379d46fb3 | Ruby | pyonnuka/ProjectEuler | /Ruby/problem20.rb | UTF-8 | 177 | 3.75 | 4 | [] | no_license | class Integer
def factorial
return 1 if self == 0
self * (self - 1).factorial
end
end
puts 100.factorial.to_s.split('').map(&:to_i).inject(0) { |sum, i| sum += i }
| true |
7e3dfd9a4505e66bd3428f2e1d8788a3081acf23 | Ruby | raresdragusSV/RubyLearn | /spec/arabic_spec.rb | UTF-8 | 1,400 | 3.359375 | 3 | [] | no_license | require 'arabic'
describe ArabicNumber do
context '.initialize' do
it 'should create Arabic(1)' do
arabic = ArabicNumber.new(1)
expect(arabic.number).to eq(1)
end
it 'should not create Arabic(0)' do
arabic = ArabicNumber.new(0)
expect(arabic.number).to eq(nil)
end
it '... | true |
17399250f38c9f42b8bf29dc29487a85eb5f523c | Ruby | bastienwillet/ultimate_townhall | /lib/app/#townhalls_follower_watir.rb | UTF-8 | 2,313 | 2.765625 | 3 | [] | no_license | require 'rubygems'
require 'json'
require 'pp'
require 'twitter'
require "dotenv"
Dotenv.load
# pour Watir
require 'watir' # Crawler
require 'pry' # Ruby REPL
require 'rb-readline' # Ruby IRB
require 'awesome_print' # Console output
class TownhallsFollowerWatir
def jsonscrap
json = File.read('../../db/townha... | true |
c4edf18bc0e1a45b5b64ca7975a09b5a0e351683 | Ruby | tubbo/makeover | /lib/rake/test_runner.rb | UTF-8 | 1,444 | 2.59375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'active_support/core_ext/module/attribute_accessors'
module Rake
# Functions for running tests directly on the command line with
#
# rake test test/path/to/file_test.rb`
#
# Ideas copied from Rails 5.
module TestRunner
class << self
mattr_accessor :filte... | true |
4715f818c7f623c2d01cbc0ee76f74ac3dd69cf9 | Ruby | grzegorzzajac1989/theOdinProject | /ruby/advenced_building_block/enumerable_methods.rb | UTF-8 | 2,043 | 4.03125 | 4 | [] | no_license | #!/usr/bin/ruby
module Enumerable
def my_each
for i in 0...self.length
yield(self[i])
end
end
def my_each_with_index
for i in 0...self.length
yield(self[i], i)
end
end
def my_select
self.my_each do |i|
puts i if yield(i) == true
end
end
def my_all?
my_all = []
self.my_each do |i|
... | true |
4fcd0faf08615d4edd04660c03dbb389cedaf9c2 | Ruby | adamwells/ActiveRecordLite | /lib/01_sql_object.rb | UTF-8 | 2,451 | 3 | 3 | [] | no_license | require_relative 'db_connection'
require 'active_support/inflector'
require_relative '02_searchable'
# NB: the attr_accessor we wrote in phase 0 is NOT used in the rest
# of this project. It was only a warm up.
class SQLObject
def self.columns
self_with_columns = DBConnection.execute2(<<-SQL)
SELECT
... | true |
208a5666cfd0d879fdf5d4e1c992930721a6f524 | Ruby | namtax/funding | /lib/core_ext/numeric.rb | UTF-8 | 91 | 3.4375 | 3 | [] | no_license | class Numeric
def prime_number?
(2...self).none?{ |n| (self / n) % 1 == 0 }
end
end | true |
bbef2c4476930b3ddbc9458c4f368f8b957b5aa9 | Ruby | Cmajewski/anagram-detector-online-web-pt-071519 | /lib/anagram.rb | UTF-8 | 246 | 3.21875 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'pry'
class Anagram
attr_accessor :word
def initialize (word)
@word=word
end
def match (array)
array.select do |array_word|
array_word.split("").sort== @word.split("").sort
end
end
end
# Your code goes here!
| true |
9d9c06998df560555f9f8e0da4992db63e1313ad | Ruby | Cfretz244/Euler | /prob28/prob28.rb | UTF-8 | 511 | 3.203125 | 3 | [] | no_license | def topRight
total = 0
for i in 1..500
term = ((2 * i) + 1) ** 2
total += term
end
total
end
def bottomLeft
total = 0
for i in 1..500
term = ((2 * i) ** 2) + 1
total += term
end
total
end
def otherDiagonal
increment = 2
prev = 1
total = 0
... | true |
acb290456d669c3ef7febda7567dee12b569161d | Ruby | snltd/aur | /spec/aur/renamers_spec.rb | UTF-8 | 3,966 | 2.59375 | 3 | [
"BSD-2-Clause"
] | permissive | #!/usr/bin/env ruby
# frozen_string_literal: true
require_relative '../spec_helper'
require_relative '../../lib/aur/renamers'
require_relative '../../lib/aur/fileinfo'
# Renaming tests
#
class TestRenamers < Minitest::Test
include Aur::Renamers
def test_track_fnum
assert_equal('06', track_fnum(flac_info))
... | true |
d2a83fc354723474dc4d47b5f35acf0fda3cff4b | Ruby | sergei-romanenko/spsc | /spsc-lite-ruby/HE.rb | UTF-8 | 1,074 | 3.21875 | 3 | [] | no_license | require 'SLL'
require 'Algebra'
module HE
extend SLL
# Enhanced homeomorphic embedding:
# expressions are compared only if they belong
# to the same category (as defined by `aVarIsUnderAttack`).
def embeddedIn(e1, e2)
aVarIsUnderAttack(e1) == aVarIsUnderAttack(e2) && he(e1, e2)
end
# This is the "c... | true |
54f80d6b6dbfa8f04608f0c317b589e87cb6c08f | Ruby | Noah2610/TextAdventure_v2 | /src/rb/Instances/Rooms/Room.rb | UTF-8 | 5,998 | 2.921875 | 3 | [] | no_license |
module Instances
module Rooms
## ROOMS constant in which all loaded Rooms will be stored
ROOMS = {}
## Initialize / load all rooms and return them
def self.init_rooms
return self.constants.map do |constname|
room = self.init_room(constname)
next [constname, room] unless (room.nil?)
next nil
... | true |
0cedaba043f2f89f480315a08d980417c36a3667 | Ruby | oddruud/Ruby-Hive | /lib/hive/cli/hive_cli.rb | UTF-8 | 1,158 | 2.8125 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'optparse'
require 'Server'
options = {}
opt_parser = OptionParser.new do |opt|
opt.banner = "Usage: HiveCLI COMMAND [OPTIONS]"
opt.separator ""
opt.separator "Commands"
opt.separator " login: login to ruby.com"
opt.separator " help: help for anything"
opt.separator... | true |
cdea8cd91cfdc6ff7a5e026aeaf7fdc55da0723d | Ruby | yoolk/yoolk_liquid | /spec/drops/yoolk/liquid/hour_drop_spec.rb | UTF-8 | 605 | 2.5625 | 3 | [
"MIT"
] | permissive | require 'rails_helper'
module Yoolk
module Liquid
describe HourDrop do
let(:hour_drop) { Yoolk::Liquid::HourDrop.new('08:30') }
it 'initializes from string' do
expect(hour_drop).to be_instance_of(Yoolk::Liquid::HourDrop)
end
it '#hour' do
expect(hour_drop.hour).to eq('08... | true |
59f2d02667afd2512724e0dee9500fed519b601f | Ruby | SimonChenboYi/exercism-ruby | /sum-of-multiples/sum_of_multiples.rb | UTF-8 | 292 | 3.265625 | 3 | [] | no_license | class SumOfMultiples
attr_accessor :inputnum
def initialize(*inputnum)
@inputnum = inputnum
end
def to(tonum)
slt = []
inputnum.each do |n|
(1...tonum).map { |x| slt << x unless x % n != 0 || slt.include?(x) }
end
slt.empty? ? 0 : slt.reduce(:+)
end
end
| true |
8651c0d574289cad78cd3f48c7712acdbcffd2eb | Ruby | yskoht/atcoder | /2020-05-02-abc165/d.rb | UTF-8 | 120 | 2.984375 | 3 | [] | no_license | a, b, n = gets.chomp.split.map(&:to_i)
x = [b - 1, n].min
b = b.to_f
t = (a * x / b).floor - a * (x / b).floor
puts t | true |
5ba672ded0d9a6392d12129effb4662550bdd051 | Ruby | eli-zbth/DL_Fundamentos_Ruby | /05_Sin_Clasificar/fuerza_bruta2.rb | UTF-8 | 89 | 3.078125 | 3 | [] | no_license | pass= ARGV[0].to_s
res="a"
i=0
until res==pass
res=res.next()
i+=1
end
puts i | true |
d790181069174e6ae648b6712cb2976730139c95 | Ruby | cbfowler4/AppAcademy | /w2d3/daywork/tdd/spec/tdd_spec.rb | UTF-8 | 3,399 | 3.875 | 4 | [] | no_license | require 'tdd'
describe Array do
describe "#my_uniq" do
it "removes repeated elements" do
expect([1,2,1,3,3].my_uniq).to eq([1,2,3])
end
it "returns elements in order of appearance" do
expect([9,1,2,1,3,3].my_uniq).to eq([9,1,2,3])
end
it "if given empty array, r... | true |
9121e3a6d10d5df72a0b994c5c313c2291f40840 | Ruby | doomleika/learnrubythehardway | /e2.rb | UTF-8 | 198 | 3.078125 | 3 | [] | no_license | # comment 1
puts "I could have code like this." # comment after first print(puts)
# command after first puts
puts "This will run."
# comment after end
puts #i comment this out "i don't get printed" | true |
adf100635ac42f26cdb327c22d70b1722e5e73de | Ruby | JakeH91/headfirst | /ruby/ch07/votes.rb | UTF-8 | 236 | 2.828125 | 3 | [] | no_license | lines = []
File.open("votes.txt") do |vote_file|
lines = vote_file.readlines
end
votes = Hash.new(0)
lines.each do |line|
name = line.chomp.capitalize
votes[name] += 1
end
votes.each do |name, votes|
puts "#{name}: #{votes}"
end | true |
adc1c13ce88585eb90c941f0732a2a08f6a10c2f | Ruby | joshcarter/tweetblogger | /test/http_helper_test.rb | UTF-8 | 2,157 | 2.75 | 3 | [
"MIT"
] | permissive | require 'http_helper'
class HttpHelperTest < Test::Unit::TestCase
def setup
@url = 'http://foo.com/bar'
end
def test_url_with_parameters
# No parameters should leave url unchanged
assert_equal @url, @url.with_parameters(nil)
assert_equal @url, @url.with_parameters(Hash.new)
# One param (s... | true |
39b43fe2f9f358e5a0c4f92d925afeeafc776a09 | Ruby | JustinData/GA-WDI-Work | /w04/d03/Tea/morning_cipher.rb | UTF-8 | 257 | 2.921875 | 3 | [] | no_license | def encode plaintext
plain = ('a'..'z').to_a
cipher = plain.rotate(13)
codex = Hash[plain.zip cipher]
plaintext_array = plaintext.split(//)
ciphertext_array = plaintext_array.map do |char|
codex[char]
end
ciphertext_array.join("")
end
| true |
0c93277c1d80e6e31843ce4877a1e6be2d49072d | Ruby | kachan1208/microCache | /server.rb | UTF-8 | 2,371 | 3.15625 | 3 | [] | no_license | require "socket"
class MicroCache
def initialize(port, mem, thr, autoclear = false)
@port = port.to_i
@memoryLimit = mem.to_i
@threadsLimit = thr.to_i
@data = {}
@threads = []
@expire = {}
@server = TCPServer.new(@port)
if autoclear
Thread.new {
... | true |
49b2b53ae2e7c9b9e85f684bc14c92c8794f1f1e | Ruby | opu-yokotalab/learn-prot-clang | /history_db.cgi | EUC-JP | 4,968 | 2.671875 | 3 | [] | no_license | #!/usr/bin/env ruby
# DBؤεϿ
#
# ѥ륨顼ȯʤȤưޤ(
# ɥݥȥεϿΡå(
# CGI
require "cgi"
# REXML
require "rexml/document"
# Ruby-PostgreSQL
require "postgres"
# Date
require "date"
class History
include REXML
#
def initialize
qs = CGI.new
@params = qs.params
end
# XMLʸɬפʾ(Compile Error)
# HashΥꥹȤ֤
def ... | true |
fabf434f0954af2fda10b9353efc2b50f2fd8024 | Ruby | procandi/learnDICOM | /3.connect_db_ok/PACSHandle.rb | UTF-8 | 7,087 | 2.53125 | 3 | [] | no_license | # encoding: UTF-8
require 'rubygems'
require "date"
require 'pg'
class PACSHandle
def initialize(host,port,name,id,pw)
#設定寫入的db
$conn = PGconn.open(host,port,'','',name,id,pw)
#初始化搜尋用的data set
$query_elements=Hash.new
#初始化回傳用的data set
$send_elements=Hash.new
... | true |
32a638ac1815bb43e41164191dfbbae56e561abb | Ruby | floehopper/datestamp | /bin/datestamp | UTF-8 | 351 | 2.6875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'pathname'
ARGV.each do |filename|
source = Pathname.new(filename)
unless source.directory?
birthtime = source.birthtime
datestamp = birthtime.strftime('%Y-%m-%d')
directory, basename = source.split
target = Pathname.new(directory).join("#{datestamp} #{basename}")
s... | true |
ca0c0719b4c5bdd95eedd4edbc0fca7b0da2ef5b | Ruby | nccgroup/autochrome | /lib/chromecache.rb | UTF-8 | 2,578 | 2.640625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | require 'rbconfig'
class ChromeCache
def available?(version=nil)
false
end
def get_cache(version=nil)
raise NotImplementedError
end
def update(crfile, version)
true
end
# Only cache if the type matches the host
def self.get_host(type)
os ||= RbConfig::CONFIG['host_os']
case os
... | true |
694c245d636444486fb8749aacf4cc657981fd4f | Ruby | MichaelOptimus/tests-ruby | /lib/03_basics.rb | UTF-8 | 718 | 3 | 3 | [] | no_license | def who_is_bigger ( a , b , c )
si a ! = nil && b ! = nil && c ! = nil
retourner "a est plus grand" si a > b && a > c
retourne "b est plus grand" si b > a && b > c
retourner "c est plus grand" si c > a && c > b
autre
retour "nul détecté"
fin
fin
def reverse_upc... | true |
a741511af45f7d2ca62c66f3dfe256a0041b8080 | Ruby | Charliemowood/learn-ruby-the-hard-way | /ex16a.rb | UTF-8 | 258 | 3.796875 | 4 | [] | no_license | filename = ARGV.first
# variable which uses the input from ARGV
txt = open(filename)
puts "You are now going to read the file you requested."
# This is how you read file apparently () are for an argument.
print txt.read
puts "Now closing file."
txt.close
| true |
1db9da17df92deeb19c639e277a8d873c53f5d3a | Ruby | urizaraj/anagram-detector-v-000 | /lib/anagram.rb | UTF-8 | 382 | 3.546875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Anagram
attr_accessor :word
def initialize(word)
self.word = word
end
def match(anagrams)
result = anagrams.select do |anagram|
word_to_hist(word) == word_to_hist(anagram)
end
end
def word_to_hist(word)
result = {}
word.each_char do |char|
result.has_key?(char) ? resu... | true |
baa6869a8162443577180a84a64658e562a9ae43 | Ruby | dongli/esmdiag | /framework/tests/test_dataset.rb | UTF-8 | 4,920 | 2.578125 | 3 | [] | no_license | require 'minitest/autorun'
require '../dataflow/dataset'
describe ScriniumEsmDiag::Dataset do
before do
@dataset = ScriniumEsmDiag::Dataset.new
end
describe 'root attribute' do
it 'sets @root instance variable only once' do
@dataset.root = '/foo/bar'
@dataset.root.must_equal '/foo/bar'
e... | true |
9a12ecb02227ec9e617c053d7afabbb3fc8e22fe | Ruby | HirenBhalani/My-Pro | /age.rb | UTF-8 | 2,164 | 3 | 3 | [] | no_license | # puts Time.now
puts "Please enter yr birth date in this formate 'YYYY-MM-DD' "
bdt=gets.chomp
puts "Enter Time this formate 'hh:mm:ss'"
bdttm=gets.chomp
bh=bdttm.split(':')[0].to_i
bmn=bdttm.split(':')[1].to_i
bs=bdttm.split(':')[2].to_i
by=bdt.split('-')[0].to_i
bm=bdt.split('-')[1].to_i
bd=bdt.split('-')[2].to_... | true |
1c2f7eba3e6163357b2d1537c9fd4ffbcb496977 | Ruby | dmitryilyin/ruby_tasklib | /misc/daemon.rb | UTF-8 | 1,347 | 2.6875 | 3 | [] | no_license | require 'rubygems'
require 'daemons'
# demo of daemonization
NAME = 'daemon_test'
def setproctitle(name)
$0 = name.to_s
end
def daemon_code
setproctitle "#{NAME}: daemon_code"
loop do
File.open '/tmp/daemon.txt', 'a+' do |file|
time = Time.now
file.puts "Time to log: #{time}"
file.flush
... | true |
4a3717c84f1edcea4991ac309b7bff3b9f64e667 | Ruby | jairusjimenez/ruby_sandbox | /linked-lists/node.rb | UTF-8 | 143 | 2.921875 | 3 | [] | no_license | class Node
attr_accessor :value, :next_node
def initialize( value = nil, next_node = nil)
@value = value
@next_node = next_node
end
end | true |
e95c24b8a8100a08c186b59c6dcd7b5eb3474531 | Ruby | kouno/monitrb | /spec/lib/config_spec.rb | UTF-8 | 3,218 | 2.671875 | 3 | [] | no_license | require 'spec_helper'
describe MonitRB::Config do
describe "::initialize" do
subject { MonitRB::Config.new }
it { should respond_to(:conditions) }
it { should respond_to(:env) }
it { should respond_to(:name) }
it { should respond_to(:path) }
it { should respond_to(:pid_file) }
it { shoul... | true |
f827328d9856c7ab1df9dfd9fe689c92063e0129 | Ruby | peshroo/Object-Oriented-Programming-Class-Methods-and-Class-Variables | /BankAccount.rb | UTF-8 | 669 | 3.5625 | 4 | [] | no_license | class BankAccount
attr_accessor :balance, :name
@@interest_rate = 0.09
@@accounts = []
def initialize
@balance = 0
end
def deposit(money)
@balance += money
end
def withdraw(money)
@balance -= money
end
def self.create
name = BankAccount.new
@@accounts << name
name
en... | true |
453b3e39fcb309079711658b361cc97365141f8d | Ruby | NREL/OpenStudio-analysis-spreadsheet | /measures/InjectOsmGeometryIntoAnExternalIdf/measure.rb | UTF-8 | 13,741 | 2.5625 | 3 | [] | no_license | #see the URL below for information on how to write OpenStudio measures
# http://openstudio.nrel.gov/openstudio-measure-writing-guide
#see your EnergyPlus installation or the URL below for information on EnergyPlus objects
# http://apps1.eere.energy.gov/buildings/energyplus/pdfs/inputoutputreference.pdf
#see the... | true |
49c3c5c93d3145f2c2fe6ee95f9f8890fa4fa7d3 | Ruby | doytsujin/RubyOnAkka | /lib/akka.rb | UTF-8 | 1,814 | 2.625 | 3 | [
"MIT"
] | permissive | require 'java'
module Akka
include_package 'se.scalablesolutions.akka.actor'
end
module Actors
class Base < Akka::UntypedActor
def self.create(*args)
self.new(*args)
end
def self.build(*args)
return Akka::UntypedActor.actorOf(self) if args.empty?
Akka::UntypedActor.actorOf { self.ne... | true |
4b1ff3b73900b4dc3f63f2930f701c07850e5a35 | Ruby | kazuki0714/object_q5 | /honda.rb | UTF-8 | 169 | 2.515625 | 3 | [] | no_license | # honda car
class Honda < Car
def initialize
@type = 'ホンダ'
@capacity = 8
@price = 100
@speed = 10
@height = 100
@passenger = 1
end
end
| true |
9472db53ec8b543aa6c5a90601cae2bbf96464a8 | Ruby | Marineepo/algorithms | /prime_counter.rb | UTF-8 | 406 | 3.5625 | 4 | [] | no_license | require 'prime'
prime_array = Prime.take_while { |p| p < 2_000_000 }
total_count = prime_array.inject { |sum, x| sum + x }
p total_count
# 142,913,828,922 total count of primes from 0 - 2 million
# looks for all primes and puts in array and then put in a method
# and then added all of them by stacking ( sum is tota... | true |
42f7aa4e437fd7b847f410f3ae89023f8716e323 | Ruby | danielpump/aprendizadoRuby | /src/monkeyPatchZuanoOMais.rb | UTF-8 | 64 | 2.828125 | 3 | [] | no_license | class Fixnum
def +(num)
self - num
end
end
puts 5+2
| true |
10c7260b99f1ef0c37a5d9d7da1c39cc06c7500f | Ruby | carden-code/metaprog | /03_lesson/03_example.rb | UTF-8 | 730 | 3.40625 | 3 | [] | no_license | class Abc
attr_accessor :block
def do_it
@a = 1
block.call
end
end
c = 1
a = Abc.new
a.block = -> { puts "c=#{c}" }
a.do_i # напечатает 1, т.к. с находится в одной области видимости с блоком!
a.block = -> { puts "@a=#{@a.inspect}" }
a.do_it # напечатает nil, т.к. @a не инициализирована в нашем контексте... | true |
97c0841bd3ccb0fd96af11c9e55fb9a55f3bdc42 | Ruby | gcongreve/w02_d1_ClassesLab | /part_c/specs/library_specs.rb | UTF-8 | 2,182 | 3.015625 | 3 | [] | no_license | require('minitest/autorun')
require('minitest/rg')
require_relative('../library')
class TestLibrary < MiniTest::Test
def test_initialize
book = Library.new([{title: "lord of the rings", rental_details: {student_name: "Jeff", date: "01/12/16"}}])
assert_equal([{title: "lord of the rings", rental_details: {student_... | true |
bbb324d5e5848b6a24abf26a8611760ccca4b976 | Ruby | MillsProvosty/date_night | /lib/tree_node.rb | UTF-8 | 194 | 2.984375 | 3 | [] | no_license | class TreeNode
attr_reader :value,
:left,
:right
def initialize(value, left = nil, right = nil)
@value = value
@left = left
@right = right
end
end
| true |
d4f27103b5a2fe0e049810cce0d2d1ab882e1120 | Ruby | tadeuzagallo/test-thoughtworks-hotel-reservation | /spec/models/hotel_spec.rb | UTF-8 | 3,243 | 2.90625 | 3 | [] | no_license | require_relative '../spec_helper'
require_relative '../../lib/models/hotel'
describe Hotel do
let (:regular_customer) { :regular }
let (:rewards_customer) { :rewards }
let (:regular_week_value) { 100 }
let (:regular_weekend_value) { 60 }
let (:rewards_week_value) { 100 }
let (:rewards_weekend_value) { 60... | true |
79af38d3d2a8ff94724d056bf613691b644884a8 | Ruby | AMekss/scripter | /lib/scripter/errors.rb | UTF-8 | 676 | 2.609375 | 3 | [
"MIT"
] | permissive | # -*- encoding : utf-8 -*-
module Scripter
module Errors
def errors
@errors ||= []
end
def errors_grouped
@errors_grouped ||= errors.group_by{|err| err[:category] }
end
def errors_count
errors.count
end
def valid?
errors.empty?
end
def invalid?
!v... | true |
290fd65fd70f60ec88034c2fd6a67414576fef71 | Ruby | prrn-pg/Shojin | /Practice/AOJ/Volumes/0014/volumes0014.rb | UTF-8 | 193 | 3.390625 | 3 | [] | no_license | ans = 0
loop do
d = gets
break if d.nil?
d = d.to_i
wide_d = d
i = 1
ans = 0
while d < 600
ans += (d**2)*wide_d
i+=1
d = i*wide_d
end
puts ans
end
| true |
4da51a602c554bfb3934da59a0cf4491f5e483bb | Ruby | pwentz/poker-hands | /spec/card_spec.rb | UTF-8 | 1,210 | 3.21875 | 3 | [] | no_license | require './lib/card'
RSpec.describe Card do
describe "#value" do
it 'returns the string value of the card' do
card = Card.new("8C")
expect(card.value).to eq("8")
end
end
describe '#suit' do
it 'returns the string suit of the card' do
card = Card.new("8C")
expect(card.suit).... | true |
ac5fc3d02fff778a46e49f9008a1b6ad430ca8c6 | Ruby | tommyb67/Ruby-the-Hard-Way | /ex3.rb | UTF-8 | 588 | 4.375 | 4 | [] | no_license | puts "I will now count my chickens:"
puts "Hens", 25 + 30 /6
puts "Roosters", 100 - 25 * 3 % 4
puts "Now I will count the eggs:"
puts 3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6
puts "Is it true that 3.0 + 2.2 < 5 - 7?"
puts 3 + 2 < 5 - 7
# The following will print what is in quotes and then perform the operation and print... | true |
8008904de911e8375e9ec822b945258c87d655a5 | Ruby | Actualize-Apprenticeship-Team-Alex/pizza-gem | /lib/pizza-generator.rb | UTF-8 | 1,535 | 3.34375 | 3 | [] | no_license | class Pizza
TOPPINGS = ["Anchovies", "Bacon", "Beef", "Chorizo", "Ham", "Meatballs", "Pepperoni", "Proscuitto", "Sausage", "Basil", "Bay Leaf", "Dried Chili", "Chives", "Cilantro", "Garlic", "Oregano", "Parsley", "Pepper", "Artichoke Hearts", "Avocado", "Broccoli", "Capers", "Capicolla", "Cherry Tomatoes", "Eggplant... | true |
2e44433921ef839cb4159686d23a5fb9e8fb618f | Ruby | cervols/think-a | /part3/6-shopping_cart.rb | UTF-8 | 616 | 3.5625 | 4 | [] | no_license | puts "Welcome in the \"Shopping cart\" program!\n" +
"(enter \"stop\" as product name if you want to exit)"
puts "#{'-' * 25}"
cart = {}
loop do
puts "Enter product:"
product = gets.chomp
break if product.downcase == 'stop'
puts "Unit price ($):"
price = gets.chomp.to_f
puts "Quantity:"
amount =... | true |
cbcd5b2399fbae4f7f9dd4be263885ec3e56bb84 | Ruby | aandrewjeski/bank | /model/bank_transaction.rb | UTF-8 | 587 | 2.640625 | 3 | [] | no_license | require_relative 'bank_account'
# ==== Purchasing Account ====
# Starting Balance: $201.94
# Ending Balance: $637.09
# $29.99 WITHDRAWAL 09/12/2013 - Amazon.com
# $500.33 DEPOSIT 09/14/2013 - Sales Deposit
# $35.19 WITHDRAWAL 09/15/2013 - Staples.com
# ========
# ==== Business Checking ====
# Starting B... | true |
833bc5495a45382e65325ce6654d7b068d93a9ee | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/proverb/12790640a6434c2396f9d86aa2bb0c33.rb | UTF-8 | 575 | 3.5 | 4 | [] | no_license | class Proverb
def initialize(*words)
@words = *words
if @words.last.class == Hash
@qualifier = @words.last[:qualifier]
@words.pop
end
end
def to_s
start = ''
count = 0
@words.each do |w|
unless w == @words.last
count += 1
start += "For want of a #{w} the ... | true |
ffb281c7ff51ee31d63261e550277ea64862d65d | Ruby | ebastien/rds-talk-rubinius | /demo/bug.rb | UTF-8 | 82 | 2.90625 | 3 | [] | no_license | # Run with `rbx -Xdebug -S ./bug.rb`
def inc(x)
y = x + 2
y
end
puts inc(3)
| true |
cdae4364bd8e66d1dbf7dcf5e6733514f1a5f2d5 | Ruby | IvanBashkirov/Kele | /lib/roadmap.rb | UTF-8 | 1,582 | 2.734375 | 3 | [] | no_license | module Roadmap
def get_me
headers = {"authorization" => @auth_token}
response = self.class.get("/users/me", { "headers": headers})
JSON.parse(response.body)
end
def get_roadmap(roadmap_id)
headers = {"authorization" => @auth_token}
body = {"id": roadmap_id}
response = self.class.get("/ro... | true |
457705f2c311fbb3b59c995757584bee49c0c871 | Ruby | haanhduclinh/ai-block-battle | /lib/bot/go.rb | UTF-8 | 3,205 | 3.078125 | 3 | [] | no_license | class Go
include GameMatrix
attr_accessor :current_pos, :target_pos, :character_type, :original_matrix, :debug
def initialize(current_pos, target_pos, character_type, original_matrix, debug: false)
@current_pos = current_pos
@target_pos = target_pos
@character_type = character_type
@view = View.n... | true |
f904b5df0e0447b5b455fbd989d1c056a151dbf5 | Ruby | jrhafer/programming_foundations | /ruby_101/easy5/easy5_ex1.rb | UTF-8 | 236 | 3 | 3 | [] | no_license | def acsii_value(words)
ascii_total = 0
words.chars.each { |char| ascii_total += char.ord }
ascii_total
end
p acsii_value('Four score') == 984
p acsii_value('Launch School') == 1251
p acsii_value('a') == 97
p acsii_value('') == 0
| true |
b6c7da5118d88495dc48c0a7bcb0ba9d8869782e | Ruby | JeremyDownes/LS-Ruby-Small-Problems | /Advanced/Merge Sorted Lists.rb | UTF-8 | 2,658 | 3.90625 | 4 | [] | no_license | # Merge Sorted Lists # this is kinda clumsy idk it works / Doesn't work breaks w uneven arrays
def merge(list1,list2)
x1 = list1.length
x2 = list2.length
out = []
if x1 != 0 && x2 != 0 # I skipped comparing empty array and just appended at the end
x = x1 + x2 # add both lengths for # of steps
... | true |
bc755ca5ef671f0353c8294219745046948381af | Ruby | tanlaan/top_recursion_ruby | /lib/merge_sort.rb | UTF-8 | 1,060 | 4 | 4 | [] | no_license | def merge_sort(objects)
# return object if singlet
return objects if objects.length < 2
# sort left
left = merge_sort(objects.slice(0, objects.length / 2))
# sort right
right = merge_sort(objects.slice(objects.length / 2, objects.length))
# merge left and right
merged = []
lefty =... | true |
e4bd9904716e6e93bcb8efd92040939441419d6b | Ruby | PatoLopezCl/modulo6-ruby | /ejercicio1/ejercicios_hash.rb | UTF-8 | 2,400 | 3.453125 | 3 | [] | no_license |
#1.- Hash | Diccionarios
system("clear")
equipo1 = { nombre: 'argentina', estadio: 'Estadio Único de Santiago del Estero' }
equipo2 = { nombre: 'bolivia', estadio: 'Estadio Hernando Siles' }
equipo3 = { nombre: 'brasil', estadio: 'Estadio José Pinheiro Borda' }
equipo4 = { nombre: ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.