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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
5b074e5ba65c7f8a32900ec959100e642b223b91 | Ruby | HiroyukiTonami/AtCoder_library | /ABC207/C.rb | UTF-8 | 633 | 3.140625 | 3 | [] | no_license | N = gets.to_i
tlrs = N.times.map{gets.split.map(&:to_i)}
# 準備。'より大きい'と'未満'を消して全部'以上'と'以下'の条件にする。
N.times do |i|
# 0.5を取り扱うのが面倒なので2倍する
tlrs[i][1] *= 2
tlrs[i][2] *= 2
if tlrs[i][0] == 2
tlrs[i][2] -= 1
elsif tlrs[i][0] == 3
tlrs[i][1] += 1
elsif tlrs[i][0] == 4
tlrs[i][1] += 1
tlrs[i][2]... | true |
dcbb63f6c02f60a3221b823e80d7b61c26027c2e | Ruby | ashucoding/instance-methods-lab-ruby-onl01-seng-pt-030220 | /lib/dog.rb | UTF-8 | 124 | 3.484375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Dog
def bark
puts "Woof!"
end
def sit
puts "The Dog is sitting"
end
end
fido = Dog.new
fido.bark
fido.sit | true |
693299eb9c59fe56204e7c7b232af51c8f09318d | Ruby | stacybanks514/Practice | /ruby_notes2.rb | UTF-8 | 168 | 3 | 3 | [] | no_license | class Bored
attr_reader :title
def title
@title = "inferno"
end
def article
@title.capiatlize
@title
end
end
inf = Bored.new
puts inf
puts @title | true |
fed6e813531a0cfd136260d054e620f423ef8a37 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/accumulate/50536d81c86e46a2b39345c339fa0adc.rb | UTF-8 | 124 | 3.3125 | 3 | [] | no_license | class Array
def accumulate(&code)
result = []
for x in self
result << code.call(x)
end
result
end
end
| true |
8b1f468b437fb1e3fdb2adf80599d2fa22cef4a0 | Ruby | KPolit0v/Ruby | /luhn_algorithm.rb | UTF-8 | 129 | 2.546875 | 3 | [] | no_license | require_relative 'cardnumber'
account_number = ARGV.first
acc_number = CardNumber.new(account_number)
puts acc_number.valid?
| true |
fc71afdd82c8d4db7bf0ff04ba17375dc70ce09f | Ruby | iandeth/trials | /ruby/basics/mysql2.rb | UTF-8 | 560 | 2.515625 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/local/bin/ruby -w
require 'mysql2'
begin
client = Mysql2::Client.new :host=>"127.0.0.1", :username=>"root", :database=>'test'
# s = client.escape "foo"
# results = client.query "SELECT * FROM foo WHERE text = #{s}"
results = client.query "SHOW TABLES"
results.each do |r|
p r
end
... | true |
e7ffe0fb6f8fa7845683f55d69c5aaed28632168 | Ruby | ranjan/InterviewBit_ruby_week1 | /longestPalindromeSubstring_optimal.rb | UTF-8 | 775 | 3.46875 | 3 | [] | no_license | class Solution
# @param a : string
# @return a string
def longestPalindrome(s)
i = 0
max = ""
size = s.size
max_size = max.size
while max_size/2 + i <= size - 1
p = get_palindrome(s, i, i)
if p.size > max_size
max_size = p.size
... | true |
74fce0294133644fbef9a87f7265ecbd8a0f4935 | Ruby | ilrt/mca | /DataTriage/src/jruby/bopen-libraries.rb | UTF-8 | 1,861 | 3.25 | 3 | [
"BSD-2-Clause"
] | permissive | require 'java'
require 'rubygems'
require 'digest/md5'
require 'postcode_lookup.rb'
require 'namespaces.rb'
require 'generate_rdf.rb'
class LibraryLocation
def initialize(uri_prefix, name, address, point)
@uri_prefix = uri_prefix
@name = name
@address = address
@point = point
... | true |
d2fe4f6650e3cbcd99a25c25720e90f9d078af58 | Ruby | opal/opal | /benchmark/bm_hash_rassoc_object.rb | UTF-8 | 97 | 2.6875 | 3 | [
"MIT"
] | permissive | h = {}
10_000.times do |i|
h[Object.new] = i
end
1_000.times do |i|
k, v = h.rassoc(i)
end
| true |
750dfcf3a880da9ad609ad61f25b7545046c7f1f | Ruby | GabrielValle91/CLI-Data-Gem-Project | /movies_nearby/lib/movies_nearby/scraper.rb | UTF-8 | 1,095 | 2.765625 | 3 | [
"MIT"
] | permissive | class MovieScraper
def self.scrape_movie_overview(overview_url, zip_code)
doc = Nokogiri::HTML(open(overview_url))
movie_array = []
movie_list = doc.css(".lister-item")
movie_list.each do |movie|
movie_hash = {}
movie_hash[:name] = movie.css(".title").text
movie_hash[:url] = ("https:... | true |
d70c6e4fcafb7507882cde2cb68aa861803b4767 | Ruby | joecowton/oystercard-1 | /lib/journeylog.rb | UTF-8 | 368 | 2.90625 | 3 | [] | no_license | class JourneyLog
attr_reader :journeys
def initialize
@journeys = []
@current_journey = nil
end
def start(station)
@current_journey = Journey.new(station)
end
def finish(station)
@current_journey.exit_station(station)
current_journey
end
def aquire_fare
@current_journey.fare
end
private
def current_j... | true |
8c20fb66e849cd3d17e5ac8b9060389411187cc4 | Ruby | drunkwater/leetcode | /medium/ruby/c0190_375_guess-number-higher-or-lower-ii/00_leetcode_0190.rb | UTF-8 | 1,158 | 4.125 | 4 | [] | no_license | # DRUNKWATER TEMPLATE(add description and prototypes)
# Question Title and Description on leetcode.com
# Function Declaration and Function Prototypes on leetcode.com
#375. Guess Number Higher or Lower II
#We are playing the Guess Game. The game is as follows:
#I pick a number from 1 to n. You have to guess which number... | true |
a3b77ebfcc6037492a28cb26600b4312e60d2608 | Ruby | CoinCash-eu/set_locale | /lib/set_locale/strategies/http_header/parser.rb | UTF-8 | 815 | 2.640625 | 3 | [
"MIT"
] | permissive | class SetLocale::Strategies::HttpHeader::Parser
# Taken directly from iain/http_accept_language:
# https://github.com/iain/http_accept_language/blob/master/lib/http_accept_language/parser.rb
def self.parse(header)
header.to_s.gsub(/\s+/, '').split(',').map do |language|
locale, quality = language.split(... | true |
caba7aa9219c6faf538b64976949c4542dd85978 | Ruby | zhanglei/crypt--xxtea | /lib/crypt_tea/xxtea.rb | UTF-8 | 3,209 | 3.1875 | 3 | [
"MIT"
] | permissive | module Crypt
class XXTEA
DELTA = 0x9E3779B9
def initialize(new_key)
@key = str_to_longs(new_key)
if @key.length > 4
raise 'Key is too long (no more than 16 chars)'
elsif @key.length == 0
raise 'Key cannot be empty'
elsif @key.length < 4
@key.length.upto(4) {... | true |
402905e18099577db7ada32bfaecd3fca67d2d25 | Ruby | emilyadavis303/mastermind | /lib/sequence_generator.rb | UTF-8 | 212 | 2.96875 | 3 | [] | no_license | class SequenceGenerator
def generate
letters = [["R", "G", "Y", "B"], ["R", "G", "Y", "B"], ["R", "G", "Y", "B"], ["R", "G", "Y", "B"]]
letters.map {|letter|
letter.shuffle.first
}
end
end
| true |
f1101678505b4f8e5e4241728815a210b679412f | Ruby | ben-harvey/Small-problems-Ruby | /procedural/easy4/10.rb | UTF-8 | 1,387 | 4.25 | 4 | [] | no_license | # Input: integers with + or - characters
# Output: a string of integers that matches the input
# Rules: no standard conversion methods(Fixnum#$to_s or String()
# Logic: Check if number is negative
# num * -1 > 0
DIGITS = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
def integer_to_string(number)
r... | true |
a46fb9eb8d94c20cedbffdcf6c52aabc6c8631d4 | Ruby | J-Y/RubyQuiz | /ruby_quiz/quiz76_sols/solutions/joey/scramble2.rb | UTF-8 | 77 | 2.515625 | 3 | [
"MIT"
] | permissive | puts
$<.inject([]){|a,w|a<<w.gsub(/\B(\w+)\B/){$1.split('').sort_by{rand}}}
| true |
d14c719bf9661ceddad399dd17667526a327430c | Ruby | panand71/fashion_truck_us | /app/helpers/sessions_helper.rb | UTF-8 | 390 | 2.71875 | 3 | [] | no_license | module SessionsHelper
# Logs in the given owner.
def log_in(owner)
session[:owner_id] = owner.id
end
def current_owner
@current_owner ||= Owner.find_by(id: session[:owner_id])
end
def logged_in?
!current_owner.nil?
end
def log_out
session.delete(:owner_id)
@current_owner = nil
... | true |
b1b8e2bca66da42041aa42d335aa860a671c01a0 | Ruby | WayneBuxton/ruby-objects-has-many-lab-v-000 | /lib/post.rb | UTF-8 | 241 | 3 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require "pry"
class Post
attr_accessor :author, :name, :title
def initialize(title)
@title = title
@name = name
@author = author
#binding.pry
end
def author_name
if self.author
self.author.name
else
nil
end
end
end
| true |
ac3418dc84e57810eb5fcfa9d655555c40aa9326 | Ruby | charithhewage/toy_robot_challenge | /lib/directions/west_direction.rb | UTF-8 | 258 | 3.078125 | 3 | [] | no_license | module Directions
module West
class << self
def turn_left(x,y)
[x, y, "SOUTH"]
end
def turn_right(x,y)
[x, y, "NORTH"]
end
def move_forward(x,y)
[x-1, y, "WEST"]
end
end
end
end | true |
7bcfd062583ccc46f73a7c5fe4483837ff6649df | Ruby | Cambero/codility | /lessons/07_stone_wall.rb | UTF-8 | 332 | 3.59375 | 4 | [] | no_license | # https://codility.com/programmers/lessons/7-stacks_and_queues/stone_wall/
def solution(h)
stack = []
blocks = 0
h.each do |i|
stack.pop while !stack.empty? && stack.last > i
if stack.empty? || stack.last < i
stack << i
blocks += 1
end
end
blocks
end
solution([8, 8, 5, 7, 9, 8, 7, ... | true |
1d016414471239da2a4155025e0615d1c2fbb9bd | Ruby | eeng/ar-enums | /spec/ar_enums/enum_definition_spec.rb | UTF-8 | 4,563 | 2.96875 | 3 | [
"MIT"
] | permissive | require File.expand_path('../spec_helper', File.dirname(__FILE__))
describe "Internal enumerations" do
def define_traffic_light *options
define_model_class 'TrafficLight' do
enum *options
end
end
before do
define_traffic_light :state, %w[red green yellow]
end
context "getter and setter" d... | true |
d5a771c59eeeec36d8ff287842920e26a5d84138 | Ruby | Felipeb1003/apples-and-holidays-onl01-seng-ft-050420 | /lib/holiday.rb | UTF-8 | 4,345 | 3.65625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
def second_supply_for_fourth_of_july(holiday_hash)
{
:winter => {
:christmas => ["Lights", "Wreath"],
:new_years => ["Party Hats"]
},
:summer => {
:fourth_of_july => ["Fireworks", "BBQ"]
},
:fall => {
:thanksgiving => ["Turkey"]
},
:spring => {
... | true |
b63b209be1dbf90f173132e36836cbe1ac8cf96c | Ruby | ha4gu/atcoder | /ABC/090/090/A.rb | UTF-8 | 52 | 2.75 | 3 | [] | no_license | puts 3.times.map { |i| gets.split('')[i] }.join('')
| true |
ae2c2ac0bfa3bd6fc0cd397b69596cbf1e255a20 | Ruby | mrjaimisra/Chisel | /test/strong_test.rb | UTF-8 | 598 | 2.9375 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/pride'
require '../lib/strong'
class StrongTester < Minitest::Test
def test_it_converts_the_opening_tags
i = Strong.new("**bold this**")
half_bolded = i.convert_opening_tags
assert_equal ["<strong>bold", "this**"], half_bolded
end
def test_it_converts_a_... | true |
586cf5171cb1abdfa38655ab5eb3900c95a4501b | Ruby | everdrone/graphql-ruby | /lib/graphql/types/iso_8601_date_time.rb | UTF-8 | 1,046 | 2.640625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module GraphQL
module Types
# This scalar takes `DateTime`s and transmits them as strings,
# using ISO 8601 format.
#
# To use it, require it in your project:
#
# require "graphql/types/iso_8601_date_time"
#
# Then use it for fields or arguments:
#... | true |
909cec81c276c3ce11b6f7edbff65b4bcccd1c37 | Ruby | nanne007/solutions_of_projecteuler | /1-50/30.rb | UTF-8 | 331 | 3.359375 | 3 | [] | no_license | # def max_digits
# i = 1
# i+=1 until 9**i > 8*i*9**5 + 1
# i-1
# end
# puts max_digits
res = []
2.upto(354294) do |i|
# res << i if i == i.to_s.scan(/\d/).inject(0) {|mem, var| mem += var.to_i**5 }
mem, t = 0, i
until t < 10
mem += (t%10)**5
t /= 10
end
res << i if mem + t**5 == i
end
p res... | true |
2edb082f21991c237290a419de8c542260f4c9c7 | Ruby | thatkaiguy/misc | /practice-questions/cracking-the-coding-interview/1-6.rb | UTF-8 | 372 | 3.859375 | 4 | [] | no_license | # Write a method to rotate an NxN matrix by 90 degrees.
def rotate_matrix(sq_matrix)
dim = sq_matrix.size
result_matrix = Array.new(dim) { Array.new(dim) }
dim.times do |i|
dim.times do |j|
result_matrix[i][j] = sq_matrix[j][i]
end
end
result_matrix.map! do |row|
row.reverse!
end
res... | true |
3f506166766d6a2ceb55a62d3a8405281510cf59 | Ruby | tkbrigham/recursive_word_chain | /chain_with_log.rb | UTF-8 | 3,037 | 3.671875 | 4 | [] | no_license | require_relative 'possible_words'
def optimal_length(starting_word, target)
count ||= (starting_word.length - target.length).abs + 1
short_word = starting_word.length < target.length ? starting_word : target
long_word = starting_word.length > target.length ? starting_word : target
(0..short_word.length-1).each... | true |
14e04c01e3a451b07cbfc0d2f46ea130f2169136 | Ruby | weaponisedbutterfly/hashes_and_arrays_HWD3 | /bank_accounts_functions.rb | UTF-8 | 1,449 | 3.59375 | 4 | [] | no_license | ACCOUNTS = [
{
holder_name: "Jay",
amount: 55,
type: "business"
},
{
holder_name: "Rick",
amount: 1,
type: "personal"
},
{
holder_name: "Keith",
amount: 500,
type: "business"
},
{
holder_name: "Valerie",
amount: 100,
type: "personal"
},
{
holder_name... | true |
5074734a787d761423d6eebb86012dcdfa68644e | Ruby | g-mehra/intro-to-ruby-day2 | /exercise5.rb | UTF-8 | 153 | 3.59375 | 4 | [] | no_license | def fahrenheit_celcius(fahrenheit)
celcius = (fahrenheit.to_i - 32) * 5/9
p "#{fahrenheit} degrees fahrenheit is #{celcius} degrees in celcius!"
end
| true |
40146660aee38eca2b8556eedfb41aabc8062f69 | Ruby | SalubriousTechnologies/scheduling_with_timezones | /app/models/schedule.rb | UTF-8 | 926 | 2.9375 | 3 | [] | no_license | class Schedule < ApplicationRecord
belongs_to :doctor
before_save :change_to_utc
def change_to_utc
local_date = Date.parse(num_to_day_mapper(self.day_identifier))
Time.zone = Time.find_zone(self.doctor.time_zone_field)
# for ensuring consistency, params can be changed to time here instead
timing ... | true |
c4cc3dcea631540025d49e680096d8acd2f44202 | Ruby | modorange/deathnullsaga | /game_states/scene.rb | UTF-8 | 1,377 | 2.703125 | 3 | [] | no_license | class Scene < GameState
def initialize
super
@scene = YAML.load_file("game_scenes/01_briljant.yml")
@font = Gosu::Font.new($window, "Courier", 18)
@string
@zoom = 1.0
@index = 0
self.input = {
r: :say_next,
holding_q: :zoom_in,
holding_w: :zoom_out
}
end
... | true |
62c97858bef9cdb5ab41631e112f6e14c6f4462a | Ruby | GrahamSM/rooted-foods-co-new | /rooted-foods-co/app/models/order.rb | UTF-8 | 1,467 | 2.5625 | 3 | [] | no_license | class Order < ActiveRecord::Base
belongs_to :user
belongs_to :sale
has_many :order_items
has_many :bundles, through: :order_items
has_many :products, through: :order_items
# TODO: Clean up these methods
def update_products(options)
quantity = options[:quantity]
is_bundle = options[:is_bundle]
... | true |
744258585d784d2890c2f71af588f5e2cedef617 | Ruby | Olefine/image_fetcher | /lib/image_fetcher/logger.rb | UTF-8 | 395 | 2.578125 | 3 | [
"MIT"
] | permissive | require 'logger'
module ImageFetcher
class Logger
class << self
def init_logger(logfile)
if File.exist?(logfile)
@logger ||= ::Logger.new(logfile)
else
raise ImageFetcher::LogfileDoesNotExist, "#{logfile}"
end
end
def log(message)
@logger.add... | true |
5a1c4a6e5307cc37b73aebd0ae61b7b9631e59b3 | Ruby | chaintope/bitcoinrb | /lib/bitcoin/message/ping.rb | UTF-8 | 511 | 2.578125 | 3 | [
"MIT"
] | permissive | module Bitcoin
module Message
# ping message class
# https://bitcoin.org/en/developer-reference#ping
class Ping < Base
COMMAND = 'ping'
attr_accessor :nonce
def initialize(nonce = SecureRandom.random_number(0xffffffff))
@nonce = nonce
end
def self.parse_from_payl... | true |
836f11dc01962ab56a2c567fa04bd336a996bd91 | Ruby | marciemo/chatroom_client | /spec/room_spec.rb | UTF-8 | 1,157 | 2.5625 | 3 | [] | no_license | require 'spec_helper'
describe Room do
let (:name) {{:name => 'green'}}
let (:room) {Room.new(name)}
it 'initializes with a hash of the name' do
room.should be_an_instance_of Room
end
context 'readers' do
it 'returns the name with #name' do
room.name.should eq name[:name]
end
end
c... | true |
1073363e4cb5ee4912b3b146a2ef244586cf4d5e | Ruby | joshsherwood1/module_0_capstone | /day_1/ex4.rb | UTF-8 | 1,663 | 4.46875 | 4 | [] | no_license | # these first 4 variable assignments are self-explanatory. They give a number value to a variable.
cars = 100
space_in_a_car = 4.0
drivers = 30
passengers = 90
# This variable is defined by a calculation done by other variables. It is number of cars driven minus number so cars
cars_not_driven = cars - drivers
# Variabl... | true |
26a8c468ac7335dfa6bae896f121b309fa893359 | Ruby | rezaf/DataStructures_and_Algorithms | /sorts/heap_sort.rb | UTF-8 | 381 | 3.40625 | 3 | [] | no_license | require_relative '../bin_min_heap'
# Time: O(nlog(n)), Space: O(1)
def heap_sort(arr)
2.upto(arr.length - 1).each do |heap_size|
BinaryMinHeap.heapify_up(arr, heap_size - 1, heap_size)
end
arr.length.downto(2).each do |heap_size|
arr[heap_size - 1], arr[0] = arr[0], arr[heap_size - 1]
BinaryMinHeap.... | true |
fea5aa96f9289bdc871bed51ee017bda3241a8af | Ruby | yowchun93/gilded-rose-kata | /lib/backstage.rb | UTF-8 | 430 | 3.046875 | 3 | [] | no_license | class Backstage
attr_reader :quality, :days_remaining
def initialize(quality, days_remaining)
@quality = quality
@days_remaining = days_remaining
end
def tick
@days_remaining -= 1
return if @quality >= 50
## quality is 0 after sale date
return @quality = 0 if @days_remaining < 0
... | true |
0bf584091a8e929deb46c384365ef027442d8471 | Ruby | siberry/keys-of-hash-dumbo-web-career-031119 | /lib/keys_of_hash.rb | UTF-8 | 359 | 3.65625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require "pry"
class Hash
def keys_of(*arguments)
ans = []
arguments.collect do |x|
self.collect do |y,z|
if arguments.include?(z)
ans << y
end
end
end
ans.uniq
end
end
# x is argument(s)which are values, givens
#y is key, z is value of y (e.g. y => z)
# self.c... | true |
a9af5aa600c0843caae564084a5a0102800c7a94 | Ruby | mpospelov/Soldat-2 | /lib/exec.rb | UTF-8 | 2,472 | 3.421875 | 3 | [] | no_license | class Exec
attr_accessor :command, :op1_type, :op1_value, :op2_type, :op2_value
@@commands = [:add, :sub, :div, :mul, :and, :or, :mov, :shr, :shl, :jz, :jn, :jmp, :inc, :dec, :stop, :not]
def initialize(str)
@command = str[0..3].to_i(2)
@op1_type = str[4..5].to_i(2)
@op1_value = str[6..17].to_i(2)
... | true |
f85cb1c0165acc0a311d659383cbf95087435107 | Ruby | subtleGradient/ruby-ansi | /lib/ansi.rb | UTF-8 | 527 | 3.078125 | 3 | [] | no_license | require("sauce")
require("Parser")
class ANSI
attr_accessor :width, :height, :filename
def initialize(ansi)
if ansi.respond_to? :read
@raw = ansi.read
elsif ansi =~ /\n/
@raw = ansi.to_s
else
throw unless File.exists ansi
@raw = File.read ansi
end
... | true |
95c086510453c38f74daf577ad9c54b0b83f4970 | Ruby | jeffxx/ctf-writeup | /0ctf2016/trace/simulator.rb | UTF-8 | 5,679 | 2.5625 | 3 | [] | no_license | #!/usr/bin/env ruby
require "awesome_print"
def int(str)
return [str[2..-1].rjust(8,'0')].pack("H*").unpack("l>")[0]
end
def uint(str)
#return [str[2..-1].rjust(8,'0')].pack("H*").unpack("l>")[0]
return str.to_i(16)
end
@reg = Hash.new(0)
@mem = Hash.new(0)
skip = 0
chr = ""
save_str = ""
@mem[0x00410EA0] = 0x40... | true |
ef04de25bc92627a2e0cf3c062ae614535f24bd0 | Ruby | prostory/agate | /lib/agate/signature.rb | UTF-8 | 1,664 | 2.90625 | 3 | [
"MIT"
] | permissive | module SLang
class Signature
attr_accessor :types
def initialize(types = [])
@types = types.clone
if types.last.is_a?(VarList)
@types.pop
@types.push *types.last.members
@is_var_list = true
else
@is_var_list = false
end
end
def var_list?
... | true |
b30aa8b713791f7c75f721e5994fddf636b10748 | Ruby | hummeldon/odin-ruby-assignments | /caesar_cipher.rb | UTF-8 | 463 | 3.828125 | 4 | [] | no_license | def caesar_cipher(string, key)
string_characters = string.split("")
solution = ""
string_characters.each do |character|
if character =~ /[a-z]/ || character =~ /[A-Z]/
character = character.ord
if character + key > 90 && character <= 90 || character + key > 122
character -= 26
end
... | true |
03cbbff414c8ad2975a6b6eb4bf674104971943f | Ruby | max-powell/oo-relationships-practice-london-web-career-021819 | /app/models/bakery/dessert.rb | UTF-8 | 362 | 3.3125 | 3 | [] | no_license | class Dessert
attr_accessor :bakery
@@desserts = []
def initialize(name, bakery)
@name = name
@bakery = bakery
@@desserts << self
end
def self.all
@@desserts
end
def ingredients
Ingredient.all.select {|ingr| ingr.dessert == self}
end
def calories
ingredients.inject(0) {|... | true |
72317654f8ccde564b06b79a097213d6a78acc2d | Ruby | asross/adventofcode | /10/day10.rb | UTF-8 | 153 | 3.25 | 3 | [] | no_license | require_relative './looksay'
t = Time.now
n = "3113322113"
50.times do |i|
n = looksay(n)
puts "at #{i}: #{n.length}, #{(Time.now - t).round}s"
end
| true |
fb512cdb5361bda87c8db14c1166168b38460e46 | Ruby | gtongue/app_academy_homework | /W5D4/test.rb | UTF-8 | 135 | 3.734375 | 4 | [] | no_license | def isPrime(num)
if num < 2
return false
end
(2...num).each do |i|
return false if num % i == 0
end
return true
end | true |
b6822f1f2f3671d9ad3e69789b9a06389453f392 | Ruby | ivo-/sandbox | /ruby/rpoker/test/rpoker/player/human_test.rb | UTF-8 | 1,604 | 2.53125 | 3 | [
"MIT"
] | permissive | require "test_helper"
class TestHumanPlayer < MiniTest::Unit::TestCase
include Rpoker::Deck
include Rpoker::Data
include Rpoker::Player
def setup
@player = Human.new :I
@deck = French.new.shuffle
@cards = 5.times.map { |_| @deck.pop }
@pocket = 2.times.map { |_| @deck.pop }
... | true |
10e18162e88a6e3fcebab891331a82ff91fce9e3 | Ruby | tylerpalef/rocket | /rocket_test.rb | UTF-8 | 591 | 2.515625 | 3 | [] | no_license | require "minitest/autorun"
require_relative "rocket"
class RocketTest < Minitest::Test
def setup
@rocket = Rocket.new
end
def test_initalize_default_name
# arrange
# act
expected = @rocket.name
actual = @rocket.name
#assert
assert_equal(expected, actual)
end
def test_initalize_default_colour
# ... | true |
1408cc4797f9b7ffefb3855a9621bcd28eb34d26 | Ruby | tdeo/advent_of_code | /2017/test/25.rb | UTF-8 | 784 | 2.890625 | 3 | [] | no_license | # frozen_string_literal: true
require 'minitest/autorun'
require_relative('../lib/25_halting_problem')
describe HaltingProblem do
before { @k = HaltingProblem }
def test_part1
assert_equal 3, @k.new('Begin in state A.
Perform a diagnostic checksum after 6 steps.
In state A:
If the current value is 0:
... | true |
35359cfda32d08b72795d38612a37dc28f751b8c | Ruby | pieckenst/ruby-things | /outputfirstnumber.rb | UTF-8 | 549 | 3.359375 | 3 | [] | no_license | #Дано неотрицательное целое число. Найдите и выведите первую цифру числа (первую слева).
#Формат входных данных
#На вход дается натуральное число n, не превосходящее 10000 (n <= 10000).
#Формат выходных данных
#Выведите одно целое число - первую цифру заданного числа.
a = gets.chomp.to_i
while a >= 10 && a <= 10000... | true |
e02607a99bd0b52bf6a614dd8533183da808c96b | Ruby | jin501/flatiron-bnb-methods-wdf-000 | /app/models/concerns/reservations.rb | UTF-8 | 755 | 2.59375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | module Reservable
extend ActiveSupport::Concern
def openings(checkin, checkout)
self.listings.each do |listing|
listing.reservations.find do |reservation|
if reservation.checkin.to_s > checkin || reservation.checkout.to_s < checkout
reservation.listing
end
end
end
e... | true |
083dea4fce6f57ca86814c926db30d49964b2b29 | Ruby | allewun/euler | /solved/005.rb | UTF-8 | 709 | 3.859375 | 4 | [] | no_license | #============================================================================
# euler005
# 6/20/12, 3/1/13 rewritten
#
# What is the smallest positive number that is
# evenly divisible by all of the numbers from 1 to 20?
#============================================================================
def euler005
num =... | true |
1f52ba51f28dac0cd8a0a23ea949366d479d1746 | Ruby | geetfun/pg_creditcard | /test/test_pg_creditcard.rb | UTF-8 | 2,192 | 2.671875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require 'helper'
class TestPgCreditcard < Test::Unit::TestCase
def test_raises_argument_error_if_options_nil
assert_raise(ArgumentError) do
@cc = PgCreditcard.new
end
end
def test_does_not_raise_argument_error_if_options_nil
assert_nothing_raised(ArgumentError) do
@cc = PgCreditcard... | true |
9aee4bcb43d7f561486064eeacd7b0b6ffdd2bc2 | Ruby | morizotter/SwiftyDrop | /vendor/bundle/gems/claide-1.0.2/lib/claide/command/plugin_manager.rb | UTF-8 | 4,313 | 2.59375 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
module CLAide
class Command
# Handles plugin related logic logic for the `Command` class.
#
# Plugins are loaded the first time a command run and are identified by the
# prefix specified in the command class. Plugins must adopt the following
# conventions:
#
# - Support ... | true |
fc4b36581845bfacd5985eff0a2442894d37f1b7 | Ruby | DavidWeinstein/aA-ruby-test | /adjacent-sum.rb | UTF-8 | 541 | 4.5625 | 5 | [] | no_license | # Write a method adjacent_sum that takes in an array of numbers and returns a new array containing the sums of adjacent numbers in the original array. See the examples.
def adjacent_sum(array)
new_array = []
i = 0
while i < array.length - 1
new_array << array[i] + array[i + 1]
i += 1
en... | true |
cc6039a69ec6a485b22691e8c235b426429dbf23 | Ruby | jeannegreulich/simp-utils | /scripts/sbin/migrate_to_simplib | UTF-8 | 4,371 | 2.625 | 3 | [] | no_license | #!/usr/bin/env ruby
# This script is intended to assist users in upgrading their modules and hieradata
# from the using `common` and `functions` module.
#
# Run the script with the --help option for usage information.
require 'find'
require 'yaml'
require 'fileutils'
require 'optparse'
def first_checks( path )
can... | true |
dcabd885faa7ba84ee6e8e918278791b23c428db | Ruby | nashsibanda/app_academy_open | /Software Engineering Foundations/Object Oriented Programming/mastermind_project/lib/mastermind.rb | UTF-8 | 474 | 3.4375 | 3 | [] | no_license | require_relative "code"
class Mastermind
def initialize(length)
@secret_code = Code.random(length)
end
def print_matches(code_inst)
puts "Exact matches: " + @secret_code.num_exact_matches(code_inst).to_s
puts "Near matches: " + @secret_code.num_near_matches(code_inst).to_s
end
def ask_user_f... | true |
c1f336d62f65d385f63920608a66e782bc996385 | Ruby | BerilBBJ/scraperwiki-scraper-vault | /Users/K/kineticasolutions/fravegaproductosporcategoria.rb | UTF-8 | 5,990 | 2.953125 | 3 | [] | no_license | # Frávega - Scrapper para Productos por categoria
require 'nokogiri'
begin
html = ScraperWiki.scrape "http://www.fravega.com/"
rescue
html = ""
end
error = nil
doc = Nokogiri::HTML(html, nil, 'utf-8')
doc.search("#tab-categorias .item").each do |item|
if error != nil
break
end
finishedCategoryLastP... | true |
6fd0824ada3beb86be5e6b0bc92685fe3113bd84 | Ruby | padwasabimasala/oc-rack-auth-jruby | /lib/rack/auth/oc_tanner/small_hour.rb | UTF-8 | 1,054 | 2.71875 | 3 | [] | no_license | class Rack::Auth::OCTanner::SmallHour
EPOCH_YEAR = 1970
#123456789012345678901234
YEAR_MASK = 0b11111100000000000000
MONTH_MASK = 0b00000011110000000000
DAY_MASK = 0b00000000001111100000
HOUR_MASK = 0b00000000000000011111
YEAR_SHIFT = 14
MONTH_SHIFT = 10
DAY_SHIFT = 5
HOUR_... | true |
1b4b7e8f06708b16f121cc795058faae8f8222bb | Ruby | gaflorez47/project-euler | /20-29/p26.rb | UTF-8 | 346 | 3.140625 | 3 | [] | no_license | def cycle n
mod = 1%n
nums = []
while true
if nums.include?(mod)
return nums.size - nums.index(mod)
end
return 0 if mod==0
nums.push mod
mod = mod*10%n
end
end
cycle 3
limit = 1000
maxd = 0
max = 0
(1..limit).each do |i|
c = cycle i
if c > max
max = c
maxd = i
end
end
... | true |
73c19e1fdfde1fc2a3ab6158c88eb579aee4ab73 | Ruby | itsmechlark/devise_security_extension | /test/support/assertions.rb | UTF-8 | 1,144 | 2.53125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require 'active_support/test_case'
class ActiveSupport::TestCase
def assert_not(assertion, msg = '')
assert !assertion, msg
end
def assert_blank(assertion, msg = '')
assert assertion.blank?, msg
end
def assert_present(assertion)
assert assertion.present?
end
def assert_email_sent(address =... | true |
42d5875ea8af56093b74a744fbaa8a7990082081 | Ruby | Se7enB2st/Algorithm | /sorting_string.rb | UTF-8 | 216 | 4.25 | 4 | [] | no_license | # Create a method named 'sort_string' which accepts a String and rearranges all the words in ascending order, by length.
def sort_string(string)
string.split.sort { |w1,w2| w1.length <=> w2.length }.join(" ")
end
| true |
56137c78c319253febbf618a0422a744c54cf059 | Ruby | intinig/indian-poker | /lib/server/deck.rb | UTF-8 | 355 | 3.375 | 3 | [] | no_license | module Server
class Deck
attr_reader :cards
def initialize
@cards = []
%w(h s d c).each do |suit|
((1..10).to_a + %w(J Q K)).each do |val|
@cards << val.to_s + suit
end
end
@cards.shuffle!
end
def shuffle
@cards.shuffle
end
def deal
... | true |
4978834bffccb578e1df1062c86653ddae663e11 | Ruby | DigitalDsntHurt/farm_tracking | /app/controllers/dashboards_controller.rb | UTF-8 | 25,320 | 2.53125 | 3 | [] | no_license |
class DashboardsController < ApplicationController
##
## ## helper methods
##
helper_method :add_shit
def add_shit(n1,n2)
n1 + n2
end
def turn_orders_into_soak_instructions(orders)
@payload = []
@days_of_week_ref = ["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]
... | true |
2b951038b06f138d551ada6d7f78efd5d936a0fc | Ruby | Turese/fableplay | /db/seeds/basicitems.seeds.rb | UTF-8 | 5,383 | 2.765625 | 3 | [] | no_license |
#item info:
# kinds
# 0 = Color Essence
# 1 = Element Orb
# 2 = Food
# 3 = ?
capsule_blurb = "A capsule containing the essence of the color colorname. Unscrew the lid to add a new color to a Fablepet's repertoire."
orb_blurb = "A glass orb charged with elementname elemental energy. Crack it open to add a new ele... | true |
e1dba5f0f1d462cb76729df483130d6461c95b1a | Ruby | shiro-tech/ruby | /hello.rb | UTF-8 | 107 | 2.609375 | 3 | [] | no_license | puts "hello ruby !!!!!!"
puts '"Branding Engineer"'
puts '"Hello"'
puts '"HR Tech"'
puts 1
puts 2
puts 3 | true |
1a6f95643781b2b80d0745775a03de95b03ef874 | Ruby | nickrw/relayapi | /lib/relayapi/gpiodriver/wiringpipins.rb | UTF-8 | 490 | 2.53125 | 3 | [] | no_license | require 'wiringpi'
require 'relayapi/gpiodriver/base'
module RelayAPI::GPIODriver
class WiringPiPins < RelayAPI::GPIODriver::Base
def initialize(*args)
super *args
@io = WiringPi::GPIO.new(WiringPi::GPIO.const_get('WPI_MODE_PINS'))
@io.mode(@pin, OUTPUT)
end
def raw_read
@io.rea... | true |
2c33d5dd8be84183d3204cd7ebb7917f6162fc10 | Ruby | nardonykolyszyn/schedules | /spec/services/create_event_service_spec.rb | UTF-8 | 3,762 | 2.546875 | 3 | [] | no_license | require 'rails_helper'
describe CreateEventService do
describe '#create' do
let!(:service) { CreateEventService.new(params) }
context 'When event is valid' do
let(:params) {
{
starts_at: Time.zone.today,
ends_at: Time.zone.today + 5,
schedules: [
{ day... | true |
2d46bc90490dcc26037fa662c21673fb0738cdd4 | Ruby | sd-pocket-gophers-2017/assessment | /part-2/spec/dog_show_spec.rb | UTF-8 | 1,743 | 3.09375 | 3 | [] | no_license | require 'spec_helper'
RSpec.describe DogShow do
let(:fido) { Dog.new({name: 'Fido', cuteness: 7, obedience: 2, tricks: 1}) }
let(:fluffy) { Dog.new({name: 'Fluffy', cuteness: 5, obedience: 4, tricks: 7}) }
let(:zanzibar) { Dog.new({name: 'Zanzibar', cuteness: 1, obedience: 6, tricks: 3}) }
let(:woof) { Dog.ne... | true |
7488b19b8881a7d143ebe24cbb4732787aebb239 | Ruby | tompave/voucher-technical-test | /lib/user.rb | UTF-8 | 257 | 2.671875 | 3 | [] | no_license | require 'order'
require 'voucher'
class User
attr_accessor :voucher, :orders
def initialize(orders = [], voucher = nil)
@voucher = voucher
@orders = [orders]
end
def bill
new_order = Order.new(self)
@orders << new_order
end
end | true |
77ba54c3234b87b65a30b3a61d01b5ec39713ebd | Ruby | corinnekunze/hardway | /ex/readtxtfile.rb | UTF-8 | 245 | 3.75 | 4 | [] | no_license | puts "What file do you want to read?"
txt = STDIN.gets.chomp()
def readthrough(x)
puts x.read() # need the argument variable for the function here so it will open regardless if the variable changes
end
file = File.open(txt)
readthrough(file) | true |
f184216ca83df137c4caa560f8528029f2db4d2d | Ruby | danmayer/coverage-bug | /app.rb | UTF-8 | 205 | 2.640625 | 3 | [
"MIT"
] | permissive | class App
def self.process(params = {})
up_to = params[:up_to].to_i
iterations = params[:iterations].to_i
data = []
iterations.times do
data << BigMath.PI(up_to)
end
end
end
| true |
e9fb090a77055b583014632552f59a94b69f3237 | Ruby | otuyelu/ProjectEuler-and-Algorithms | /euler/tower_of_hanoi.rb | UTF-8 | 3,774 | 3.78125 | 4 | [] | no_license | # Raymond Gan-------Tower of Hanoi problem-------------
# http://en.wikipedia.org/wiki/Tower_of_Hanoi
# http://www.skorks.com/2010/03/solving-the-towers-of-hanoi-mathematically-and-programmatically-the-value-of-recursion/
# Recursive solution:
# http://www.sparknotes.com/cs/recursion/examples/section6.rhtml
# ... | true |
aa20172b9eae368b5f5829282661b010712e9189 | Ruby | nellams/sales_tracking | /code.rb | UTF-8 | 170 | 3.90625 | 4 | [] | no_license | puts "Enter price: "
total_price = 0.0
while total_price < 100
print ">"
price = gets.chomp.to_f
total_price += price
end
puts "You've reached $#{total_price}!"
| true |
a4b7e3630f50ed5f88544b0bea7d918f8417d607 | Ruby | comwrg/ruby-practice | /009-classes.rb | UTF-8 | 671 | 3.5625 | 4 | [] | no_license | #!/usr/bin/env ruby
class A
@@v # a static variable I think
def initialize
puts 'A, initialize'
end
def say
puts "........."
end
def love
puts 'I love A'
end
def v=(v) # nice grammar
@@v = v
end
def v
@@v
end
def age=(age)
@age = age # instance variable
end
def... | true |
8af7dc766d782c79e9e305e8bb6ed6e62e23f50a | Ruby | synackme/getMSPatches | /get-microsoft-patches.rb | UTF-8 | 1,056 | 2.703125 | 3 | [] | no_license | require 'rubygems'
require 'net/http'
require 'uri'
require 'json'
require 'american_date'
#require 'date'
require 'pry'
page = 1
patches_per_page = 100
patches = Array.new
while true
url = "http://technet.microsoft.com"\
"/sto/services/BulletinSearch.asmx/GetBulletins?productId=-1"\
"&mostRecent=false&startD... | true |
bb006e6f5a22df0cf4ff9e0282c6a5c510d4ff70 | Ruby | admuaq/my-select-london-web-071618 | /lib/my_select.rb | UTF-8 | 187 | 3.171875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def my_select(collection)
# your code here!
cont = []
i = 0
while i < collection.length
if yield(collection[i]) == true
cont << collection[i]
end
i+=1
end
cont
end
| true |
34d6c615b54ea1ec629150b17559be0cb9103ce6 | Ruby | ashleymichal/computation | /list/ruby/04-list-rb-function-scott | UTF-8 | 5,099 | 3.0625 | 3 | [] | no_license | #!/usr/bin/env ruby
require_relative './list_rb_oo_tests'
module List
# :type list: List a ≡ forall c. (c, (a, List a) -> c) -> c
# :type ifNil: b
# :type ifCons: (a, List a) -> b
# :rtype: b
def self.match(list, ifNil, ifCons)
list.(ifNil, ifCons)
end
# :rtype: List a ≡ forall b. (b, (a, L... | true |
3f767d7b8c81b11b42c2caf752ea0a1dbacde2af | Ruby | adavidev/story_time | /lib/story_time/third_person.rb | UTF-8 | 1,375 | 3.5 | 4 | [
"MIT"
] | permissive | class ThirdPerson
def initialize(name = "John Doe", gender = "male")
@tgr = ::EngTagger.new
@name = name
@gender = gender
@eyes = 0
end
def find(str)
tagged = @tgr.add_tags(str)
pronouns = @tgr.get_pronouns(tagged).keys
{}.tap do |hs|
p... | true |
c7542c6df62d50a4a987e5f0bfdde6b1f4d6ff41 | Ruby | south37/pb_json_parser | /lib/pb_json_parser/ast/association.rb | UTF-8 | 754 | 2.953125 | 3 | [
"MIT"
] | permissive | module PbJsonParser
module AST
class Association
Kind = {
has_one: "has_one".freeze,
has_many: "has_many".freeze,
}.freeze
attr_reader :name, :kind, :class_name
# @param [String] name
# @param [String] kind
# @param [String] class_name
def initialize(na... | true |
57c6ce9c625755e5ce0dd30ce75ef71ff6dd1fd3 | Ruby | BreadMan96/Ruby_School | /RubyRush/Example_4_Tests/lib/hashtags_search_method.rb | UTF-8 | 93 | 2.828125 | 3 | [] | no_license | def search(text)
hashtag_regexp = /#[[:word:]-]+/
@hashtags = text.scan(hashtag_regexp)
end | true |
77bc45f391f45a6b60a72ed5794cd7888e017614 | Ruby | rlister/awful | /lib/awful/acm.rb | UTF-8 | 2,367 | 2.65625 | 3 | [
"MIT"
] | permissive | require 'yaml'
require 'aws-sdk-acm'
module Awful
class Acm < Cli
COLORS = {
ISSUED: :green,
EXPIRED: :red,
REVOKED: :red,
FAILED: :red,
in_use: :green,
not_in_use: :red,
}
no_commands do
def acm
@_acm ||= Aws::ACM::Client.new
end
## return ... | true |
e8716084c7811a866fd56f0a46da2d037e3e8631 | Ruby | alehandermartins/leftbehind | /spec/lib/winner_selection_spec.rb | UTF-8 | 1,140 | 2.515625 | 3 | [] | no_license | describe 'WinnerSelection' do
xdescribe "when there's only one candidate" do
it 'selects it' do
team_players = [
{
'name' => 'player_name',
'uuid' => 'player_uuid'
},
{
'name' => 'otter_player_name',
'uuid' => 'otter_player_uuid'
},
... | true |
f3b6074a3bd3c509efc8934ba7035d1db4b97828 | Ruby | ianberman/App-Academy-Open | /Intro to Programming/enumerables & ranges/to_initials.rb | UTF-8 | 487 | 4.375 | 4 | [] | no_license | # Write a method that takes in a person's name string and returns a string
# representing their initials
def to_initials(name)
arr_name = name.split(" ")
initials = ""
arr_name.each { |part| initials += part[0] }
return initials
end
# every part is first name/last name etc passed into block
# each iterates th... | true |
dded5022032ef59c3db7f23b5bc4e726e27b5a47 | Ruby | sebkkom/LogBook | /test/log_book_test.rb | UTF-8 | 2,775 | 2.59375 | 3 | [
"MIT"
] | permissive | require_relative "test_helper"
class LogBookTest < MiniTest::Unit::TestCase
def setup
LogBook::Event.destroy_all
User.destroy_all
Item.destroy_all
@user = User.create!(:name => "User Name")
@item = Item.create!(:title => "Item Title", :log_book_historian => @user)
end
def test_event
ass... | true |
be512b3c7717a756e74b7f748a8dbd70c5e7b44a | Ruby | pumzy/App-Academy-Classwork | /App-Academy-Work/WRK W3D5 Amaar Esufally /lib/02_searchable.rb | UTF-8 | 465 | 2.53125 | 3 | [] | no_license | require_relative 'db_connection'
require_relative '01_sql_object'
require 'byebug'
module Searchable
def where(params)
query = params.map{|k,v| "#{self.table_name}.#{k} = ?"}
print query.join(" AND ")
print params.values
# debugger
abcd = DBConnection.execute(<<-SQL, params.values)
select *
... | true |
c90e959e5150addeb633d795f1490dc5fcacda7a | Ruby | codesicario/Exercises-Launch-School | /multiples_of_3_and_5.rb | UTF-8 | 535 | 3.71875 | 4 | [] | no_license | def multisum(num)
counter = 1
sum_ary = []
while counter <= num
sum_ary << counter
counter += 1
end
sum_ary.select! { |i| i % 3 == 0 || i % 5 == 0 }
sum_ary.reduce(:+)
end
p multisum(3) == 3
p multisum(5) == 8
p multisum(10) == 33
p multisum(1000) == 234168
p multisum(2457)
#LS solution
def mul... | true |
9cfaeb96066fd5f37438001808b74b6cbb88a717 | Ruby | Uthaeus/lang-exercises | /ruby-exercises/pig_latin.rb | UTF-8 | 1,654 | 3.625 | 4 | [] | no_license | require 'rspec'
def pig_latin
def translate str
vowels = ['a', 'e', 'i', 'o']
result_arr = []
my_arr = str.downcase.split(' ')
my_arr.each do |item|
my_item = item.split(//)
if vowels.include?(my_item[0])
result_arr << my_item.join('') + 'ay'
else
x = 0
... | true |
623d48acfe352ca20bedf8c171c61a4aa5f8a7af | Ruby | thyrlian/FunHome | /extra/player.rb | UTF-8 | 1,212 | 2.71875 | 3 | [] | no_license | module FunHome
class Player
class << self
def speak(text, args = {})
language = args[:language]
voice = args[:voice]
if voice
unless osx_speech(voice, text)
raise("No available voice found, please check if you have downloaded voice [#{voice}] in System Preferenc... | true |
caaff1e8e358e1e44cbb307662407c7cfd010231 | Ruby | Asana/graphite | /libraries/chef_graphite.rb | UTF-8 | 1,388 | 2.984375 | 3 | [] | no_license | module ChefGraphite
class << self
def ini_file(hash)
data = generate_conf_data(hash)
lines = Array.new
data.each do |section, config|
lines << "[#{section}]"
config.each { |key, value| lines << "#{key} = #{value}" }
lines << ""
end
lines.join("\n").concat("\... | true |
0ca6a906deb6b386bd44540dc910ff5b6eaa0233 | Ruby | CleanSolLLC/programming-univbasics-nds-nds-to-insight-with-methods-online-web-prework | /lib/nds_extract.rb | UTF-8 | 466 | 3.109375 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'directors_database'
def directors_totals(nds)
result = {}
row = 0
while row < nds.length
director_totals = gross_for_director(nds[row])
result[nds[row][:name]] = director_totals
row +=1
end
result
end
def gross_for_director(director_data)
movie = 0
director_gross = 0
while movi... | true |
73d22d035da5166ecaee90e01d90e4343f288c96 | Ruby | bp50fathoms/alpha | /spec/cases_spec.rb | UTF-8 | 2,068 | 2.75 | 3 | [] | no_license | require 'cases'
require 'property'
require 'strategy_helpers'
module CasesSpec
describe CasesStrategy do
def strategy; CasesStrategy end
describe CasesStrategy, 'when just built' do
include StrategyHelpers
it_should_behave_like 'NewStrategy'
end
describe CasesStrategy do
it_sho... | true |
ae9d1719ecda0ecefbf52b4bed70a5cf2ca872ff | Ruby | nanma80/euler_project | /p001_025/p023/main.rb | UTF-8 | 692 | 3.28125 | 3 | [] | no_license | require File.expand_path('../integer', __FILE__)
def is_sum_of_abundant_numbers?(n, abundant_numbers, is_abundant)
abundant_numbers.each do |abundant_number|
diff = n - abundant_number
return true if diff > 0 && is_abundant[diff]
return false if diff < abundant_number
end
false
end
MAX = 30_000
is_... | true |
d1183ebaf3b9bdbfed6bd0e1bedc362ad0018375 | Ruby | garysweaver/schema-dump | /schemadump | UTF-8 | 4,621 | 2.546875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/ruby -w
# requires you to have previously run:
# gem install dbi
require 'rubygems'
require 'dbi'
require 'trollop'
class Object
# from Rails
def blank?
respond_to?(:empty?) ? empty? : !self
end
def prettify
self.class.name == 'OCI8::CLOB' ? read() : to_s()
end
# this is for -i to... | true |
d61687170787a497ac66fb451ce320a1f40bd757 | Ruby | hvdson/launchschool-OOP-ruby | /class_and_objs_part2_exercise.rb | UTF-8 | 1,282 | 4.4375 | 4 | [] | no_license | # --- EXERCISE 2 --- #
class MyCar
attr_accessor :colour
attr_reader :year
attr_reader :model
def initialize(year, colour, model)
@year = year
@colour = colour
@model = model
@current_speed = 0
end
def speed_up(number)
@current_speed += number
puts "You push the gas and accelerat... | true |
351dba5adb43e8e112e6a80cff430a9bd96842cb | Ruby | mattjmorris/dvo | /spec/analyzer_spec.rb | UTF-8 | 669 | 3.046875 | 3 | [] | no_license | require "spec"
require File.dirname(__FILE__) + "/../src/board"
require File.dirname(__FILE__) + "/../src/analyzer"
describe "A board extended with analyzer" do
before(:all) do
@board = Board.new
@board.extend(Analyzer)
end
it "should tell you a player's possible moves, in the format: {:position_1 => [... | true |
2491300e32dcfe912a003f029caa596ba4ff8fe0 | Ruby | achentha/bog_apps | /db/seeds.rb | UTF-8 | 2,185 | 2.8125 | 3 | [] | no_license | Creature.delete_all
Creature.create([
{
name: "Unicorn",
description: "The unicorn is a legendary creature that has been described since antiquity as a beast with a single large, pointed, spiraling horn projecting from its forehead.",
image: "unicorn.jpg"
},
{
name: "Minotaur",
description: ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.