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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
4d32f3c9a5a4e8b7cee8027f2ede8d8c0d59ffb4 | Ruby | aryanjain28/Josh-Training-Assignments | /Ruby_Day4_Rutuja/Day 1/prime_or_not.rb | UTF-8 | 123 | 3.15625 | 3 | [] | no_license | def prime(no)
return false if no < 2
(2..(no-1)).each do |i|
return false if no % i == 0
end
return true
end
| true |
2f71877f9fc13da264722ad5ec95033a42760769 | Ruby | sergelerator/dijkstra_shortest_path | /lib/dijkstra/path.rb | UTF-8 | 206 | 2.8125 | 3 | [] | no_license | class Dijkstra::Path
attr_accessor :left_end, :right_end, :distance
def initialize(left_end, right_end, distance)
@left_end = left_end
@right_end = right_end
@distance = distance
end
end
| true |
dcc26430d9ffa7bb2644e506d06c68d771e59675 | Ruby | kaitlinaryan/rspec-fizzbuzz-v-000 | /fizzbuzz.rb | UTF-8 | 145 | 3.359375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def fizzbuzz(n)
if n % 3 == 0 && n % 5 == 0
"FizzBuzz"
elsif n % 3 == 0
"Fizz"
elsif n % 5 == 0
"Buzz"
else n % 3 && n % 5 != 0
nil
end
end
| true |
81a781c174324958a85d1f80a6ff437915fd3df6 | Ruby | ivillicana/ruby-enumerables-hash-practice-nyc-pigeon-organizer-lab-online-web-prework | /nyc_pigeon_organizer.rb | UTF-8 | 413 | 2.953125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def nyc_pigeon_organizer(data)
result = {}
data.each do |attribute, attr_hash|
attr_hash.each do |nested_attr, names_array|
names_array.each do |name|
result[name] = {} if !result[name]
result[name][attribute] = [] if !result[name][attribute]
result[name][attribute] << nested_attr... | true |
5316a3371034334c55dafeb902471cad0e0bdefb | Ruby | racheltdesign/rspec-fizzbuzz-cb-gh-000 | /fizzbuzz.rb | UTF-8 | 220 | 3.421875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def fizzbuzz(int)
if int % 3 == 0 && int % 5 == 0
print "FizzBuzz"
return "FizzBuzz"
elsif int % 3 == 0
print "Fizz"
return "Fizz"
elsif int % 5 == 0
print "Buzz"
return "Buzz"
end
end
| true |
09d4f0e29a9ad03286979f2b8243feac5dc51b4d | Ruby | 1vp/myapp | /app/models/currency.rb | UTF-8 | 1,524 | 2.671875 | 3 | [] | no_license | =begin
t.string :id_currency
t.integer :numCode
t.string :charCode
t.integer :nominal
t.string :name
t.string :value
t.string :previous
=end
require 'nokogiri'
require 'open-uri'
class Currency < ApplicationRecord
validates :id_currency, :numCode, :nominal, :name, :value, presence: true
validates :value, numerical... | true |
b590e72291b98f17b06c7ee0b28a543f66cf9d76 | Ruby | anitaf/classrubyproject | /prime.rb | UTF-8 | 95 | 3.171875 | 3 | [] | no_license | require 'prime'
puts "Give me a number greater than 1:"
num = gets.chomp.to_i
x = 2
count = 0 | true |
2837429a9816e60a0f5a0a0b9ffb80ab766699b7 | Ruby | yhara/simple_twitter | /lib/simple_twitter/error.rb | UTF-8 | 1,119 | 2.828125 | 3 | [
"MIT"
] | permissive | module SimpleTwitter
# Error base class
class Error < StandardError
# @!attribute [r] raw_response
# @return [HTTP::Response] raw error response
# @see https://www.rubydoc.info/github/httprb/http/HTTP/Response HTTP::Response documentation
attr_reader :raw_response
# @!attribute [r] body
# @... | true |
bb3793543504ac1c909a87c9ac690512c5b77e68 | Ruby | Li-jinqiang/rubyflux | /src/test/ruby/bench_fractal.rb | UTF-8 | 697 | 3.3125 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/local/bin/ruby
BAILOUT = 16
MAX_ITERATIONS = 1000
def fractal
puts "Rendering"
y = -39
while y <= 39
puts
x = -39
while x <= 39
i = iterate(x/40.0,y/40.0)
if (i == 0)
print "*"
else
print " "
end
x+=1
end
y+=1
end
end
def iterate(x,y)
... | true |
f8a4c55e5b1e2514a8c72214e27d29544918f2a9 | Ruby | deepj/rango | /lib/rango/ext/colored_string.rb | UTF-8 | 2,322 | 3.34375 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
require "delegate"
require "extlib"
require_relative "string"
require_relative "attribute"
class ColoredString
ATTRIBUTES = {
clear: 0,
reset: 0, # synonym for :clear
bold: 1,
dark: 2,
italic: 3, # not widely implemented
underline: 4,
underscore: 4, # ... | true |
85326e7bc36d6c5e7504b2456ee76220dd9d3705 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/hamming/290554d57a064d5ea8766a48fb14d09e.rb | UTF-8 | 121 | 3.359375 | 3 | [] | no_license | class Hamming
def self.compute(str1, str2)
str1.chars.zip(str2.chars).count { |e| e[1] && e[0] != e[1] }
end
end
| true |
55df3227e56771fd1bb4858ae89ced227237c663 | Ruby | igorsimdyanov/ruby | /regexp/price_extract.rb | UTF-8 | 106 | 2.953125 | 3 | [] | no_license | str = 'Цена билета 500.00 рублей'
result = str.match /\d+[.,]\d+/
puts result[0] # 500.00
| true |
9884a0fbb2809258c0969cf1eacfff708efa9325 | Ruby | bvluong/aa_homework | /W1D5/knight_travails/KnightPathFinder.rb | UTF-8 | 1,301 | 3.375 | 3 | [] | no_license | require_relative '00_tree_node.rb'
class KnightPathFinder
def initialize(pos)
@pos = pos
@visited_positions = [@pos]
build_move_tree
end
attr_accessor :pos, :visited_positions
def build_move_tree
cur_node = [pos]
until visited_positions.length >= 64
new_move_positions(cur_node.shift... | true |
5eb7a8353dd60546c43be3258e75f11fbdf1212b | Ruby | claclacla/Applications-in-the-time-of-microservices | /ruby/lib/printExecutionTime.rb | UTF-8 | 209 | 2.71875 | 3 | [
"MIT"
] | permissive | def printExecutionTime
puts "==============================================="
puts "Execution time: " + Time.now.strftime("%d/%m/%Y %H:%M").to_s
puts "==============================================="
end | true |
54cce0f0d57c27582c66657934e231c259fa4fc9 | Ruby | ilyakava/stefon | /lib/stefon/surveyor/surveyor.rb | UTF-8 | 1,179 | 2.953125 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
module Stefon
module Surveyor
# A store for the scores that each surveyor calculates, it takes
# the form of a hash where author names are keys, and points are
# values. Points are counts of lines or commits that belong to a person
class SurveyorStore < ::Hash
def initialize(d... | true |
b5fe75272689a1a591ed64903d5e59e899578b9d | Ruby | localshred/sevenlangs | /ruby/clean_tree.rb | UTF-8 | 742 | 3.734375 | 4 | [] | no_license | class Tree
attr_accessor :children, :node_name, :level
def initialize(name, children={}, level=0)
@node_name = name
@level = level
@children = build_children(children)
end
def visit_all(&block)
visit &block
children.each {|c| c.visit_all &block }
end
def visit(&block)
block.call self
end
def bui... | true |
a75f739031521f2b2e904579301b8f7c208aea1b | Ruby | johnTheDudeMan/the_odin_project | /ruby_scripts/advanced_building_blocks/bubble_sort_by.rb | UTF-8 | 453 | 3.53125 | 4 | [] | no_license | def bubble_sort_by(array)
sorted = false
swaps = 0
passes = 0
n = array.length
until sorted
for i in 1...(n - passes)
if yield(array[i-1],array[i]) > 0
array[i], array[i-1] = array[i-1], array[i]
swaps += 1
end
end
sorted = true if swaps == 0
swaps = 0
... | true |
0d3d72a9a445768d3900a37fab70e3abc81f7107 | Ruby | redgetan/riversub | /lib/subtitle_parser.rb | UTF-8 | 2,860 | 3.3125 | 3 | [] | no_license | module SubtitleParser
class InvalidFormatError < StandardError; end
# returns an array of hashes where
# keys are (:start_time, :end_time, :text)
#
def self.parse_srt(text, filename = "")
lines = text.split(/\n{2}/).map { |section|
rows = section.strip.split("\n")
3.times.each_with_index... | true |
51e3b49a9b009eb5baba650ec450bd4ab7cd8977 | Ruby | MukulPatil123/ruby_repository | /assignments_1/calculator.rb | UTF-8 | 385 | 3.765625 | 4 | [] | no_license | #!/usr/bin/ruby -w
#var=gets.to_i
puts "1st number"
n1=gets.to_i
puts "2nd number"
n2=gets.to_i
puts "Enter choice"
choice=gets.chomp
case choice
when "a"
tot=n1+n2
puts "Addition is:#{tot} "
when "s"
tot=n1-n2
puts "Subtraction is:#{tot} "
when "m"
tot=n1*n2
puts "Multiplication is:#{tot} "
when "d"
t... | true |
ae8c11c926f3a090139dba59ba37a998ca01bee5 | Ruby | irischang/learn-ruby-the-hard-way | /ex1.rb | UTF-8 | 326 | 3.34375 | 3 | [] | no_license | a = 2 # print line 2
case a
when 1
puts "Hello, world!"
when 2
puts "Hello, again"
when 3
puts 'I like typing this.'
when 4
puts "This is fun."
when 5
puts 'Yay! Printing.'
when 6
puts "I'd rather you much 'not'"
when 7
puts 'I "said" do not touch this.'
when 8
puts 'This is another lin... | true |
2643c4afd3d4848ef1bbb582ba08be05250f0c14 | Ruby | graemekean/hotel_booking | /reports.rb | UTF-8 | 450 | 2.765625 | 3 | [] | no_license | def list_chain(chain)
chain.business
end
def business_report(chain)
binding.pry
puts chain.hotels.value.name
end
def chain_report(chain)
puts "We are in the schain report"
puts "Feature not yet implemented"
end
def staff_report(chain)
puts "We are in the staff report method"
puts "Feature not yet imple... | true |
89d6e9d01855bb95d4251f73bc291c58d1830c9d | Ruby | dare1010/rl1 | /2wk/1e_process_string.rb | UTF-8 | 374 | 3.546875 | 4 | [] | no_license | # http://pastebin.com/YP0xczKA
s = "Welcome to the forum.\nHere you can learn Ruby.\nAlong with other members.\n"
lines = s.split("\n")
lines.each.with_index(1) do |line, index|
puts "Line #{index}: #{line}"
end
%w(now is the time for all good men).each.with_index(5) do |word, index|
puts "#{word} is not index #{... | true |
7b441d351b4640a137315c68e4f55dfa72874f9a | Ruby | lbrian357/knight_moves.rb | /chess_knight.rb | UTF-8 | 4,657 | 3.34375 | 3 | [] | no_license | class Node
attr_accessor :value, :parent, :child_1, :child_2, :child_3, :child_4, :child_5, :child_6, :child_7, :child_8
def initialize(value = nil, parent = nil, child_1 = nil, child_2 = nil, child_3 = nil, child_4 = nil, child_5 = nil, child_6 = nil, child_7 = nil, child_8 = nil)
@value = value
@parent = ... | true |
85fa1afe8556cd2f8376bbf9013069ba6473aa1b | Ruby | sagarvi-dev/kopal | /kopal/lib/kopal/url.rb | UTF-8 | 1,797 | 2.828125 | 3 | [
"Unlicense"
] | permissive | #Extends URI::HTTP with helpful methods.
class Kopal::Url < URI::HTTP
def initialize uri
uri = URI.parse uri
#Kind of kopal_url_object = (Kopal::Url) uri_http_object (From C/C++)
super *[uri.scheme, uri.userinfo, uri.host, uri.port, uri.registry,
uri.path, uri.opaque, uri.query, uri.fragment]
@... | true |
287f96b84b80b1bae9c4cff7ad0fe82f14a8e21d | Ruby | TezSmith/keys-of-hash-dumbo-web-060418 | /lib/keys_of_hash.rb | UTF-8 | 296 | 3.4375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Hash
def keys_of(*arguments)
#returns an array with every key from the hash whose value matches the value(s) given as an argument.
all_keys =[]
self.each do |key, value|
if arguments.include?(value)
all_keys << key
end
end
all_keys
end
end
| true |
9543d36537eec4c721390f4b4ab64307f95bf689 | Ruby | ctrlaltpat-flatiron-work/key-for-min-value-london-web-091718 | /key_for_min.rb | UTF-8 | 423 | 3.546875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # prereqs: iterators, hashes, conditional logic
# Given a hash with numeric values, return the key for the smallest value
def key_for_min_value(name_hash)
if !name_hash.empty?
lowest_val = Float::INFINITY
rtn_key = ""
name_hash.each do |key,value|
next_val = value
if next_val < lowest_val
... | true |
9b6e61dfc4acfe5263f595fa7ad36f3a73473f4e | Ruby | AMahinko/Inheritance | /Exercise1/people.rb | UTF-8 | 383 | 3.109375 | 3 | [] | no_license | require "./Student.rb"
require "./Instructor.rb"
christina = Student.new("Christina")
chris = Instructor.new("Chris")
puts chris.greeting
puts christina.greeting
puts chris.teach
puts christina.learn
# puts christina.teach #<- Won't work, as the teach and learn methods are undefined for christina
# puts chris.lea... | true |
fee3fe18fb5ff7aadcdd701a908170f139ba8808 | Ruby | taichi0129/code_collection | /ruby/piz_collection/C072_モンスターの進化.rb | UTF-8 | 2,528 | 4.03125 | 4 | [] | no_license | # 入力は以下のフォーマットで与えられます。
# ATK DEF AGI
# N
# s_1 MINATK_1 MAXATK_1 MINDEF_1 MAXDEF_1 MINAGI_1 MAXAGI_1
# s_2 MINATK_2 MAXATK_2 MINDEF_2 MAXDEF_2 MINAGI_2 MAXAGI_2
# ...
# s_N MINATK_N MAXATK_N MINDEF_N MAXDEF_N MINAGI_N MAXAGI_N
# ・1 行目にはそれぞれ、モンスターの現在の攻撃力、防御力、素早さを表す 3 つの整数 ATK, DEF, AGI がこの順で半角スペース区切りで与えられます。
# ・2 行目には進... | true |
5a4304637090f3bcae02ce4ecf92acd1d3b8b32a | Ruby | manbooo/LikeLion_rails-lotto | /app/controllers/lotto_controller.rb | UTF-8 | 1,539 | 2.59375 | 3 | [] | no_license | class LottoController < ApplicationController
def index
end
def show
# https://m.blog.naver.com/PostView.nhn?blogId=crazytta&logNo=220322383157&proxyReferer=https%3A%2F%2Fwww.google.co.kr%2F
# http://konkuk.likelion.org/material-w3-api
# https://manana.kr/lotto/simple
require 'open-uri'
... | true |
bc3685b55a288d9840eb8a1d2a1ebc01efa4eb52 | Ruby | hongyang90/Homeworks | /W1D4/ADTs.rb | UTF-8 | 1,219 | 3.921875 | 4 | [] | no_license | class Stack
def initialize
@stack = []
end
def push(el)
@stack.push(el)
end
def pop
@stack.pop
end
def peek
@stack[-1]
end
end
class Queue
def initialize
@queue = []
end
def enqueue(el)
@queue.unshift(el)
end
def d... | true |
b68d0d143396b31e17e9b551a37c99d444c71efb | Ruby | tommasobicocchi/airbnb_tllr | /db/seeds.rb | UTF-8 | 4,001 | 2.625 | 3 | [] | no_license | #retrieving from mapbox
require 'faker'
require 'json'
require 'open-uri'
10.times do
#email
faker_email = Faker::Internet.email
puts faker_email
#gender
faker_gender = Faker::Gender.binary_type
if faker_gender == "Female"
#name
faker_first_name = Faker::Name.male_first_name
else
faker_first_name = Faker::Name... | true |
873c98e171d5178f489e15a301b408c790b5d091 | Ruby | drmcastles/Ruby_2 | /calendar.rb | UTF-8 | 710 | 3.515625 | 4 | [] | no_license | last_days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
puts 'Введитете даты в формате: ДД.ММ.ГГГГ'
#создаем массив с полученными данным и конвертируем их в integer
day, month, year = gets.chomp.split('.').map(&:to_i)
#проверка является ли год високосным
leap_year = (year % 4 == 0) && (year % 100 != 0) || (year % ... | true |
a2ed612ba0d3424a08fe530f7891c62a5874d076 | Ruby | jasiek/ciscowx-ruby | /weather.rb | UTF-8 | 1,464 | 3 | 3 | [
"MIT"
] | permissive | require 'json'
ForecastIO.api_key = ENV['FORECASTIO_KEY']
class Weather
TTL = 24 * 3600
def initialize(url=ENV["REDISCLOUD_URL"], city:, country:, latitude:, longitude:)
@redis = Redis.new(url: url)
@latitude = latitude
@longitude = longitude
@city = city
@country = country
end
def s... | true |
26b051d16e553dcfe826aa1ec192a47ac53d5dfd | Ruby | dkimdon/balboa_worldwide_app | /lib/bwa/messages/status.rb | UTF-8 | 5,071 | 2.796875 | 3 | [] | no_license | module BWA
module Messages
class Status < Message
attr_accessor :priming,
:heating_mode,
:temperature_scale,
:twenty_four_hour_time,
:heating,
:temperature_range,
:hour, :minute,
... | true |
c658c4db97550dfc53bdc89d1049811cc6c99f85 | Ruby | pattilouhoo/skillcrush-repository1 | /always_three.rb/always_three.rb | UTF-8 | 235 | 3.390625 | 3 | [] | no_license | puts "Give me a number"
users_first_num = gets.to_i
user_num = users_first_num +5
user_num = user_num * 2
user_num = user_num - 4
user_num = user_num / 2
final_num = user_num - users_first_num
puts "The final number is #{final_num}" | true |
b186e6d04bcf4a0fd5be32ff0360003f265273fc | Ruby | bdurand/fast_serializer | /lib/fast_serializer/serialized_field.rb | UTF-8 | 3,244 | 2.8125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module FastSerializer
# Data structure used internally for maintaining a field to be serialized.
class SerializedField
attr_reader :name, :condition
def initialize(name, optional: false, serializer: nil, serializer_options: nil, enumerable: false, condition: nil)
@name ... | true |
fd0091e88c04c00cf581bea869fbd1a71247921a | Ruby | lekegitrepo/algorithms-and-data-structures-leetcode | /diameter_of_binary_tree.rb | UTF-8 | 332 | 3.109375 | 3 | [] | no_license | # frozen_string_literal: true
@max = 0
def diameter_of_binary_tree(root)
@max = 0
return @max if root.nil?
tree_depth(root)
@max
end
def tree_depth(node)
return 0 if node.nil?
left = tree_depth(node.left)
right = tree_depth(node.right)
curr = left + right
@max = curr if curr > @max
[left, right... | true |
9890abaf2be05dbe9cf1d75f955ef2d8f3e73191 | Ruby | jogi91/worms-on-a-plane | /lib/fx_snake_window.rb | UTF-8 | 6,552 | 2.828125 | 3 | [] | no_license | # Interface für FX-Ruby
#
# Diese Datei modifiziert das Objekt Element, so dass bei jeder
# änderung die Gafik automatisch neu gezeichnet wird.
#
require 'rubygems'
require 'fox16'
require 'fox16/kwargs'
include Fox
require "spiel"
require "element"
require "tournier_dialog"
class Element
# Neue Klassenvariabl... | true |
616a3506b5453c766be6ae864a8c16d3bdbf1dbf | Ruby | rabelirv/my-each-dumbo-web-100818 | /my_each.rb | UTF-8 | 164 | 3.125 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def my_each(collection)
# code here
i = 0
while i < collection.length
yield collection[i]
i = i + 1
end
collection
end
my_each([1,2,3,4]){|num| print num} | true |
47b4107e9f2073cf245f26e12c5fc627ac59550e | Ruby | benfiola/ruby_blackjack | /Blackjack/BlackjackHand.rb | UTF-8 | 4,194 | 3.890625 | 4 | [] | no_license | require_relative "./BlackjackCard.rb"
require_relative "../Generic/Hand.rb"
require_relative "../Display/Message"
# This class contains the blackjack specific methods
# we might want to call on a hand of cards. Since a Blackjack hand tends
# to define what a player can/can't do bet-wise as well decide the outcome
# ... | true |
2e559e6ed36340057dc61741f7e654ab7458255a | Ruby | Avanera/code_examples | /2020-2021 (Linkio)/third_party_api/helpcrunch_api/endpoints.rb | UTF-8 | 752 | 2.5625 | 3 | [] | no_license | module HelpcrunchApi
class Endpoints
def initialize
@client = Client.new.class
end
def fetch_helpcrunch_customer(user, create_if_not_found: false)
query = { filter: [field: 'customers.email', operator: '=', value: user.email] }.to_json
request_result = @client.post(
'/customers/... | true |
7230681fee3a6f12e6b390f256cfd969409ed819 | Ruby | blambeau/veritas | /lib/veritas/function/numeric/exponentiation.rb | UTF-8 | 1,558 | 2.796875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # encoding: utf-8
module Veritas
class Function
class Numeric
# A class representing a exponentiation function
class Exponentiation < Numeric
include Binary, Binary::Invertible, Comparable
# Return the Exponentiation operation
#
# @example
# Exponentiation.... | true |
88df1a6259360c47635133af476b13a4aeb2b739 | Ruby | diegoeis/exercicios-ruby | /exercicio-primo.rb | UTF-8 | 364 | 3.96875 | 4 | [] | no_license | require 'prime' # chama classe default do ruby para descobrir se é primo...
puts "Qual número você deseja saber se é primo?"
primo = gets.to_i
if Prime.instance.prime?(primo) # http://ruby-doc.org/stdlib-1.9.3/libdoc/prime/rdoc/Prime.html
puts "Sim, ele é primo. Bem vindo à família!"
else
puts "Não, ele não é pri... | true |
09ff02a6521f8f0da43c0e9a6b087be6024ae862 | Ruby | Xrazik1/black_jack | /table.rb | UTF-8 | 1,562 | 3.484375 | 3 | [] | no_license | # frozen_string_literal: true
require_relative 'player'
require_relative 'dealer'
require_relative 'deck'
class Table
attr_reader :player, :dealer, :round, :bank, :bet
def initialize(player, dealer, bet)
@bank = 0
@round = 1
@deck = Deck.new
@player = player
... | true |
c2efa6d4106e51db9a8922f02114519b506b07d2 | Ruby | sebastiangeiger/instapaper_download | /bin/instapaper_download | UTF-8 | 1,383 | 2.640625 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'instapaper_download.rb'
require 'mechanize'
config_file = Instapaper::ConfigFile.new
account = Instapaper::Account.from_config_file(config_file)
agent = Mechanize.new
agent.user_agent_alias = 'Mac Safari'
login_page = Instapaper::LoginPage.new(agent)
agent = login_page.login(account)
if ... | true |
7c3617e098362f2d4a696ad94910f9576cab19c2 | Ruby | nikkolasg/interviews | /ruby/tree.rb | UTF-8 | 3,452 | 3.734375 | 4 | [] | no_license | #!/usr/bin/env ruby
module Tree
module BinaryTree
class Node
attr_accessor :value,:left,:right
def initialize value
@value = value
@left = nil
@right = nil
end
def to_s
@value
end... | true |
6b2d2942726b70f7b9e4ecbdb5a5c8e1d376d9af | Ruby | hellouniverse26/cm1 | /ruby/projects/poker/solution/spec/player_spec.rb | UTF-8 | 2,400 | 3.375 | 3 | [] | no_license | require 'rspec'
# require 'player'
load 'player.rb'
describe Player do
subject(:player) { Player.new(100) }
describe '::buy_in' do
it 'should create a player' do
expect(Player.buy_in(100)).to be_a(Player)
end
it 'should set the players bankroll' do
expect(Player.buy_in(100).bankroll).to e... | true |
c19102f0e293808e15822ba710933d0ce8e7f766 | Ruby | thesunnytrail/ruby-sunnytrail | /spec/sunnytrail_spec.rb | UTF-8 | 3,465 | 2.734375 | 3 | [
"MIT"
] | permissive | require 'sunnytrail'
require 'mock'
describe Sunnytrail do
before :all do
TIME_NOW = Time.now.to_i
OPTIONS_HASH = {"id" => 123,
"email" => "user123@example.com",
"name" => "User123",
"action" => {
"name" => "Signup",
"create... | true |
834e3cf4a2e397e7023fb3d6a1b4b901bec77067 | Ruby | cjwales/week_1_day_3_homework | /exercise_a.rb | UTF-8 | 987 | 3.96875 | 4 | [] | no_license | stops = [ "Croy", "Cumbernauld", "Falkirk High", "Linlithgow", "Livingston", "Haymarket" ]
#Add "Edinburgh Waverley" to the end of the array
stops.push("Edinburgh Waverley")
#Add "Glasgow Queen St" to the start of the array
stops.unshift("Glasgow Queen St")
#Add "Polmont" at the appropriate point (between "Falkirk H... | true |
0f6a19e9fd4e6c2fbc4281e3db99310d4d9b02a7 | Ruby | ViolaCrellin/slice-to-win | /lib/game.rb | UTF-8 | 2,524 | 3.359375 | 3 | [] | no_license | require 'legal_moves_calculator'
require 'computer_turn'
class Game
attr_accessor :board
attr_reader :legal_moves_klass, :turn_klass, :legal_moves, :original_board
def initialize(board, legal_moves_klass=LegalMovesCalculator, turn_klass=ComputerTurn)
@original_board = board
@board = board
@legal_mo... | true |
3178f0106500e510b2402d08409474e1b0877f85 | Ruby | megamsys/megam_api | /lib/megam/core/credits_collection.rb | UTF-8 | 3,403 | 3.21875 | 3 | [
"MIT"
] | permissive | module Megam
class CreditsCollection
include Enumerable
attr_reader :iterator
def initialize
@credits = Array.new
@credits_by_name = Hash.new
@insert_after_idx = nil
end
def all_credits
@credits
end
def [](ind... | true |
f95540c4c06e98949bc2e89798351d01cb9971b5 | Ruby | jasemabeed114/lantiamaster2 | /scripts/carTheftScript.rb | UTF-8 | 615 | 2.875 | 3 | [] | no_license | require 'csv'
national_file_name = "public/carTheft/national.csv"
CSV.open(national_file_name, 'w', write_headers: false) do |writer|
CSV.foreach('public/municipal_delitos.csv') do |row|
if row[7] == "Robo de vehículo automotor"
writer << row
end
end
end
bigCounties = County.where("population > ?",50000)
b... | true |
60646ea09df24469d34f7f71e329ccfe4b1fb31e | Ruby | facenord-sud/icwot | /lib/icwot/console.rb | UTF-8 | 1,959 | 3.03125 | 3 | [
"MIT"
] | permissive | class Console
attr_reader :produces, :accept, :port, :host, :protocol, :log_path, :errors
attr_accessor :host_url
def initialize
@produces = 'application/json'
@accept = 'application/json'
@port = 4567
@host = ''
@protocol = 'http://'
@log_path = ''
@errors = ''
end
def parse
... | true |
ccbc6c28a9c60d86d3fe4336d124d528dc8e1255 | Ruby | progpyftk/webwiner | /lib/wine.rb | UTF-8 | 719 | 2.609375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
# require_relative 'db_client' # this class defines a wine object
# Wine: models the wine object
class Wine
attr_accessor :name, :maker, :year, :grape, :region, :link, :price_club, :price_regular,
:price_sale, :store_sku, :store, :global_id
def initialize
@name = ... | true |
3f90d9d8e7a46636555bef8f538a9cb18dd54b3f | Ruby | RonanRS/learningRuby | /maleandtall.rb | UTF-8 | 273 | 3.765625 | 4 | [] | no_license | ismale = false
istall = false
if ismale and istall
puts "You are a tall male!"
elsif ismale and !istall
puts "You are a short male!"
elsif !ismale and istall
puts "You are not male, but is tall!"
else ismale and istall
puts "You are a short girl!"
end
| true |
139c2405f39cc1f6da24159a4ed42eceeb170d11 | Ruby | antw/imp | /spec/command/dispatch_spec.rb | UTF-8 | 2,196 | 2.625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
module DispatchSpec
class Simple < Imp::Command
def go
end
private
def nothanks
end
end
class WithArgs < Imp::Command
arg :verbose
def go
end
end
class WithRequiredArgs < Imp::Command
arg... | true |
d5aae63ca6ee9c191e922cdbc8b99e5602fc9844 | Ruby | ghounakey/School | /cs214/projects/proj04/script.ruby | UTF-8 | 1,515 | 3.53125 | 4 | [] | no_license | Script started on Tue 26 Feb 2019 02:19:18 PM EST
ajs244@maroon24:~/cs214/projects/proj04$ cat factorial.rb
#! /usr/bin/ruby
# factorial.rb computes the factorial of a given number
#
# Input: the integer n.
# Precondition: the integer is >= 0.
# Output: the factorial of that integer n.
#
# Begun by: Prof. Adam... | true |
ca584f905702d7016984d59f29d2ed167152f10f | Ruby | laujonat/Data-Structure-Algos | /heaps/lib/heap_sort.rb | UTF-8 | 336 | 3.125 | 3 | [] | no_license | require_relative "heap"
class Array
def heap_sort!
1.upto(length - 1) do |idx|
BinaryMinHeap.heapify_up(self, idx) { |el, el1| el <=> el1 }
end
(length - 1).downto(0) do |idx|
self[0], self[idx] = self[idx], self[0]
BinaryMinHeap.heapify_down(self, 0, idx) { |el, el2| el <=> el2 }
end
re... | true |
a62de6f2d5b9ce5f7cfa55c402780eb333640194 | Ruby | ruckc/gocd | /tools/jruby/lib/ruby/gems/1.8/gems/rubyzip-0.9.1/lib/quiz1/t/solutions/Moses Hohman/solitaire.rb | UTF-8 | 292 | 2.671875 | 3 | [
"LGPL-2.1-only",
"CPL-1.0",
"LGPL-2.0-or-later",
"GPL-1.0-or-later",
"Ruby",
"GPL-2.0-only",
"BSD-2-Clause",
"Apache-2.0"
] | permissive | #!/usr/bin/env ruby
require 'cipher'
require 'yaml'
module Solitaire
text = ARGV.join(" ")
if FileTest::readable?("deck.yaml")
deck = Deck.new(YAML::load(File.open("deck.yaml")))
else
deck = Deck.new
end
cipher = Cipher.new(text, deck)
puts "#{cipher.mode}ed: #{cipher.crypt}"
end
| true |
2761c22292ff0fe575dd7fa7836b64f1604d1349 | Ruby | sdbeng/ryby_stand_class | /player_spec.rb | UTF-8 | 2,114 | 3.203125 | 3 | [] | no_license | require './player'
RSpec.describe Player do
# code block to remove duplication
before(:example) do
@initial_health = 150
@player = Player.new("larry", @initial_health)
end
#to suppress standard output to the console (to only see green dots...)
before do
$stdout = StringIO.new
end
#code examples go here
it "has a c... | true |
56646180fd9bb43ff6eb7b8569c223ba628b77dd | Ruby | vicmaster/dijkstra | /spec/node_spec.rb | UTF-8 | 456 | 2.53125 | 3 | [] | no_license | require 'spec_helper'
describe Node do
it 'should return a node created' do
node = Node.new('a')
node.name.should eq('a')
end
it 'should return comparisions into different nodes' do
node_a = Node.new('a')
node_b = Node.new('b')
node_a.name.should_not eq node_b.name
end
it 'should retur... | true |
cd8bf7eaa67513f258f6e96b7b1fa27ddefc5b35 | Ruby | wycats/net2-reactor | /lib/net2/reactor/channel.rb | UTF-8 | 498 | 2.625 | 3 | [] | no_license | module Net2
class Reactor
class IOChannel
attr_reader :io
attr_writer :reactor
def initialize(io)
@io = io
end
def read
return call unless @io.eof?
@reactor.stop_watching(@io, :read)
eof
end
def write
end
def err
end
... | true |
575883c7e5f7ac798047c70fe93c602803af151f | Ruby | julienemo/thp-9-scrapping | /lib/02_cher_depute.rb | UTF-8 | 1,788 | 3.109375 | 3 | [] | no_license | require "pry"
require "nokogiri"
require "open-uri"
def personal_info(deputy_page)
# basic settings
page = Nokogiri::HTML(open(deputy_page))
info = {}
personal_mails = []
# getting emails by pure xpath, no pain at all
# just that some has more than one
# I'll put them in a list
personal_mails << page.... | true |
ba0dda9dddc262ece34d4a0211d40faa7a1eea92 | Ruby | doreymiller/ruby_small_problems | /easy_4/multiples_3_5.rb | UTF-8 | 1,097 | 4.90625 | 5 | [] | no_license | # multiples_3_5.rb
#Write a method that searches for all multiples of 3 or 5 that lie between
# 1 and some other number, and then computes the sum of those multiples. For
# instance, if the supplied number is 20, the result should be
# 98 (3 + 5 + 6 + 9 + 10 + 12 + 15 + 18 + 20).
# You may assume that the number p... | true |
70024dcf26add33b20bf98648e6d5c35fcdffbcc | Ruby | obiora22/launch_school | /exercises/count_characters.rb | UTF-8 | 173 | 3.65625 | 4 | [] | no_license | puts "Please enter one or more words:"
input = gets.chomp
input_with_no_spaces = input.gsub(" ","")
puts "You have #{input_with_no_spaces.length} characters in\n#{input}!"
| true |
26df2f810c0fb230a6e26f06d27885e49e1f4693 | Ruby | beardy/lincoln_client | /app/models/rule.rb | UTF-8 | 3,711 | 2.734375 | 3 | [] | no_license | require 'ip_conversion'
class Rule < ActiveRecord::Base
include IPConvert
belongs_to :group
validates_numericality_of :port_incoming_start, :port_incoming_end, :port_outgoing_start, :port_outgoing_end, :allow_nil => true
#Nasty IP regular expression is from http://www.regular-expressions.info/examples.html
... | true |
774336930401448256d01df110f8607425dadf5a | Ruby | ellehallal/LRTHW | /ex19.rb | UTF-8 | 920 | 4.53125 | 5 | [] | no_license | def cheese_and_crackers(cheese_count, boxes_of_crackers)
puts "You have #{cheese_count} cheeses!"
puts "You have #{boxes_of_crackers} boxes of crackers"
puts "Man that's enough for a party"
puts "Get a blanket\n"
end
#calling function with numbers as arguments
puts "We can give the function numbers directly"
c... | true |
8ba722a5151ce74377ae2e14e5983df22109fca3 | Ruby | RaskUlv/Rubuquet | /rubuquet-cuneiform/rubuquet.rb | UTF-8 | 2,634 | 2.53125 | 3 | [] | no_license | #!/usr/bin/env ruby
# coding: utf-8
require 'fileutils'
if ARGV.length == 0 or ARGV.length == 1 or ARGV.length > 2
puts "Please, specify a file to OCR and language or read README file to get help."
exit
else
in_file = ARGV[0]
arg_file_ext = File.extname(in_file)
file_name = File.basename(in_file, ".*")
fi... | true |
d6df7703e1decaf034b60eed1b3118b499a4bd79 | Ruby | okaydokay97/ruby-oo-relationships-practice-gym-membership-exercise-chi01-seng-ft-051120 | /lib/gym.rb | UTF-8 | 515 | 3.28125 | 3 | [] | no_license | require 'pry'
class Gym
attr_reader :name
attr_accessor
@@all = []
def initialize(name)
@name = name
@@all << self
end
def self.all
@@all
end
def memberships
Membership.all.select {|membership| membership.gym == self}
end
def members_list
list_of_members = memberships.map {|m... | true |
f643177270114271e0640543b8ca7c62b13de21f | Ruby | diminish7/beholder | /lib/beholder/logic_component.rb | UTF-8 | 5,020 | 3 | 3 | [] | no_license | #Logic components for the parser
module Beholder
module LogicComponent
include NodeUtils
#Replaces the node with text from the value attribute
# Raises MissingAttributeException if value attribute is not present
def _raw(node)
raise MissingAttributeException.new("'value' attribute not prese... | true |
78c1558b0434b56c7d83c780930f587456fcb338 | Ruby | codedogfish/ruby-in-action | /meta/block/basics.rb | UTF-8 | 262 | 3.796875 | 4 | [] | no_license | def a_method(a,b)
a + yield(a,b)
end
puts a_method(1,2) {|x,y|(x+y)*4}
def b_method
# Kernel#block_given? to check the method is called by yield or not
return yield if block_given?
'no block'
end
puts b_method
puts b_method {"here's a block"}
| true |
2d318a052b1499b2102055fa71e4e169dce0a865 | Ruby | kenman21/sinatra-mvc-lab-web-022018 | /models/piglatinizer.rb | UTF-8 | 902 | 3.703125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class PigLatinizer
attr_accessor :text
# def initialize(text)
# @text = text.downcase
# end
def piglatinize(text)
alphabet = ('A'..'Z').to_a
vowels = %w[A E I O U]
consonants = alphabet - vowels
if vowels.include?(text[0].capitalize)
text = text + "way"
elsif consonants.include?... | true |
1779057134d6b0a3c9d0e70cbc447ea2ea941c92 | Ruby | rhinorphan/morpion | /lib/show.rb | UTF-8 | 639 | 3.171875 | 3 | [] | no_license | class Show
def show_board(board)
#TO DO : affiche sur le terminal l'objet de classe Board en entrée. S'active avec un Show.new.show_board(instance_de_Board)
puts " -------------".center(70)
puts "A | #{board.grid["A1"]} | #{board.grid["A2"]} | #{board.grid["A3"]} |".center(70)
puts " -------------"... | true |
53fc8ac3cbcefbba3cc17f8746b85c1634d3ff09 | Ruby | dru/Bank-Online-2011 | /Import/Import.rb | UTF-8 | 2,311 | 2.546875 | 3 | [] | no_license | # encoding: utf-8
require "roo"
require "json"
doc = Excelx.new("Import.xlsx")
json = Hash.new
authors = Hash.new
section = ""
date = ""
sectionId = 0;
doc.default_sheet = doc.sheets[1]
4.upto(doc.last_row) do |line|
author = doc.cell(line, 'A') ? doc.cell(line, 'A') : ""
authors[author] = Hash.new();
authors... | true |
23ea1699637433a03e75dafa84ce3780979767d8 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/rna-transcription/949c25ebbdca41f090c7743e20561ec4.rb | UTF-8 | 150 | 2.6875 | 3 | [] | no_license | class Complement
def self.of_dna(rna)
return rna.tr("GCTA", "CGAU")
end
def self.of_rna(dna)
return dna.tr("CGAU", "GCTA")
end
end
| true |
1afcfdb6348178b463441dc98b0d1365bcbd9c35 | Ruby | twzyliu/RichMan_Ruby_Mechanism | /src/tools/tool.rb | UTF-8 | 553 | 2.75 | 3 | [] | no_license | class Tool
CHEAPEST = 30
def initialize
@point = 0
@num = 0
end
def cheapest
CHEAPEST
end
def point
@point
end
def num
@num
end
def set_num(num)
@num = num
end
def use(player, step)
place = player.game_map.place(player.position + step)
not_far = (step < 11 ... | true |
1c76adb2de4b41d7c07f2aaa22d7c9b40311913f | Ruby | startupvictoria/membership-site | /spec/lib/authenticator_spec.rb | UTF-8 | 1,447 | 2.53125 | 3 | [] | no_license | require 'authenticator'
describe Authenticator do
let(:session) { {} }
let(:authenticator) { Authenticator.new(session) }
describe "#log_in" do
it "sets the session user_id to the given User ID" do
user = double(id: 123)
authenticator.log_in(user)
expect(session[:user_id]).to eq(123)
e... | true |
716b92a9bf24fc31b4f3a9810578f99310282254 | Ruby | Elucidation/Nbody_Ruby | /c_1_0.rb | UTF-8 | 366 | 3.1875 | 3 | [] | no_license | class Body
# Initialize
def initialize(mass = 0, pos = [0,0,0], vel = [0,0,0])
@mass,@pos,@vel = mass,pos,vel
end
# Mass
def mass
@mass
end
def mass= m
@mass = m
end
# Position
def pos
@pos
end
def pos= p
@pos = p
end
# Velocity
def vel
@vel
end
def vel... | true |
e80abfac6a548e162a99d5b76114f5ff7b4b5f97 | Ruby | dcadenas/active_record_state_pattern | /vendor/state_pattern/lib/state_pattern/invalid_transition_exception.rb | UTF-8 | 369 | 2.6875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | module StatePattern
class InvalidTransitionException < RuntimeError
attr_reader :from_module, :to_module, :event
def initialize(from_module, to_module, event)
@from_module = from_module
@to_module = to_module
@event = event
end
def message
"Event #@event cannot transition from... | true |
8b3694f16e432b3e6bb05e64556f2ffcf183ef2c | Ruby | kiran-gurujada/pickaxe | /chapter8/methods_and_blocks.rb | UTF-8 | 808 | 4.53125 | 5 | [] | no_license | # methods can be associated with blocks
# normally the block is called using yield from within the method
def double(p1)
yield(p1*2)
end
p double(3) {|val| "I got #{val}" } # => "I got 6"
p double("tom") {|val| "Then I got #{val}"} # => "Then I got tomtom"
# however if the last argument in a method definition is p... | true |
d5836d66d0cd306dba76f53db32df4595a50fb93 | Ruby | michelleisclever/ruby-challenges | /upthecreek.rb | UTF-8 | 3,479 | 3.671875 | 4 | [] | no_license | # I understand this is the parent
class Blog
#I believe this is the empty array to catch posts
@@all_blog_posts = []
#This begins count at 0
@@num_blog_posts = 0
#I have no idea what is happening here
def self.all
@@all_blog_posts
end
#I cannot understand THING but... | true |
bd85869734fd056a829681a6e05bfd5860040477 | Ruby | cntran/myflix | /spec/models/video_spec.rb | UTF-8 | 2,808 | 2.71875 | 3 | [] | no_license | require 'spec_helper'
describe Video do
it { should belong_to(:category) }
it { should validate_presence_of(:title) }
it { should validate_presence_of(:description) }
describe ".search_by_title" do
it "returns empty array if no match is found" do
Video.create(title: "Mad Men", description: "Ameri... | true |
32bb793eb0a1b537367d759e792bf06dfb04d0db | Ruby | nicalpi/vim-condense-tutor | /vim-condense-tutor.rb | UTF-8 | 4,181 | 2.53125 | 3 | [] | no_license | # The absolute minimum
You are now in normal mode
Press i to enter insert mode (writting text)
Press <esc> to return normal mode
Press : to enter command mode
:w to save a file
:e to open and edit a file
:q to quit
:q! to quit without saving
Press . to repeat last command
# Need help?
:help
:he... | true |
1f8e47097315d97acc1e59076df91d167e1ccc64 | Ruby | ubershibs/hackerrank | /projecteuler/06-sum-square-difference.rb | UTF-8 | 302 | 3.59375 | 4 | [] | no_license | def sum_of_squares(num)
i = 0
1.upto(num) do |n|
i = i + n**2
end
i
end
def square_of_sums(num)
i = 0
1.upto(num) do |n|
i = i + n
end
i = i**2
i
end
t = gets.strip.to_i
t.times do
n = gets.strip.to_i
solution = square_of_sums(n) - sum_of_squares(n)
puts solution
end
| true |
23388df444fabc1f5f0e85ebe11d1b6f78283787 | Ruby | cooljacob204/oo-cash-register-online-web-sp-000 | /lib/cash_register.rb | UTF-8 | 895 | 3.3125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class CashRegister
attr_accessor :total, :discount
def initialize(discount = -1)
@total = 0
@discount = discount
@items = []
end
def add_item(item, price, quantity = 1)
@items << {item => {:quantity => quantity, :price => price}}
@total += price * quantity
end
def... | true |
738e85145458fc437c59cf199f7637df5f8e6008 | Ruby | mazamachi/Euler | /15.rb | UTF-8 | 76 | 2.703125 | 3 | [] | no_license | seki = 1
for i in 21..40
seki *= i
end
for i in 1..20
seki /= i
end
p seki | true |
255d84467d4c746048f8f0366a30cce73a4ae2c3 | Ruby | dbruggisser/ruby-day1 | /exo_19.rb | UTF-8 | 226 | 2.734375 | 3 | [] | no_license | email_list = []
i = 0
50.times do
if i > 8
email_list << "jean.dupont#{i +=1}@email.fr"
else
email_list << "jean.dupont.0#{i +=1}@email.fr"
end
end
puts "#{email_list[1]}"
i = 1
24.times do
puts "#{email_list[i +=2]}"
end | true |
091aadfa2a2ea4cfdf963f2f4487893ca40c0d63 | Ruby | Michael-Luxus/vendredijob | /exo_10.rb | UTF-8 | 92 | 3.34375 | 3 | [] | no_license | puts "Quel âge avez-vous?"
age = gets.chomp.to_i
puts "En 2017, vous aviez #{age - 1} ans!" | true |
2b156875832e10f9463f4177dc3f131de983b8be | Ruby | dokipen/cards | /lib/cards/forte-fives/game.rb | UTF-8 | 13,114 | 2.984375 | 3 | [] | no_license | require 'cards/cards'
require 'orderedhash'
require 'ruby-debug'
module ForteFives
include PlayingCards
class Trick
attr_accessor :lead, :trump, :plays
def self.create_ranks suite, rank, start
Hash[
[(start...start+rank.size).to_a, rank].
transpose.
collect {|or... | true |
c3fb13aa53cc36c4f1abe36cd53af0b3aab367fd | Ruby | intfrr/raidit | /test/unit/interactors/list_characters_test.rb | UTF-8 | 739 | 2.65625 | 3 | [] | no_license | require 'unit/test_helper'
require 'interactors/list_characters'
require 'models/user'
require 'models/character'
describe ListCharacters do
it "takes a user on construction" do
user = User.new
action = ListCharacters.new user
action.user.must_equal user
end
describe "#run" do
it "finds all cha... | true |
fc3b02beed5df07db9b7f151f5dbf48435f08d87 | Ruby | ordepdev/euler | /ruby/prob4.rb | UTF-8 | 451 | 3.234375 | 3 | [] | no_license | require "test/unit"
# Project Euler - Problem 4 #
class Euler
def self.run
c=0
999.downto(100) do |a|
if a*a<c
break
end
a.downto(100) do|b|
x=a*b
y=x.to_s
if y==y.reverse
if x>c
c=x
break
end
end
end
... | true |
8a984f2848973df53edf8e620a82fa5d1f0e14ab | Ruby | grumpyjames/Compass | /ruby/test/tc_roll_action.rb | UTF-8 | 1,428 | 3.046875 | 3 | [
"MIT"
] | permissive | require 'test/unit'
require '../test/fake_board.rb'
require '../test/fake_player.rb'
require '../test/fake_game.rb'
require '../impl/roll_action.rb'
class FakeDice
def initialize(score)
@score = score
end
def roll
return @score
end
end
class TC_RollAction < Test::Unit::TestCase
#this will *not*... | true |
5c81558aad801e05de6f0c10b78b88ff09eb5373 | Ruby | knorthrup83/blur | /blur3.rb | UTF-8 | 2,740 | 3.671875 | 4 | [] | no_license | class Image
def initialize(image)
@image = image
end
def output_image(manhattan)
@new_array = Marshal.load(Marshal.dump(@image))
@image.each_with_index do |row, row_index|
row.each_with_index do |cell, col_index|
if cell == 1
blur(manhattan, col_index, row_index)
end
... | true |
70cca3cf815fc1b4a6da969996add753148f7431 | Ruby | BabsLabs/code_songs_microservice | /spec/services/watson_service_spec.rb | UTF-8 | 1,357 | 2.703125 | 3 | [] | no_license | require 'spec_helper'
describe WatsonService do
it 'fetches the sentiment of lyrics', :vcr do
text = "No clouds in my stones\nLet it rain, I hydroplane in the bank (eh, eh, eh)\nComing down with the Dow Jones\nWhen the clouds come, we gone, we Roc-A-Fella (eh, eh, eh, eh)\nWe fly higher than weather, in G5's or ... | true |
0af971444350ee753b6272f28f9e2ae99fffc257 | Ruby | hyperturing/advanced-building-blocks | /spec/enumerable_methods_spec.rb | UTF-8 | 2,674 | 3.5625 | 4 | [] | no_license | require './enumerable/enumerable_methods.rb'
require './enumerable/array.rb'
require './enumerable/hash.rb'
RSpec.describe Enumerable do
describe '#my_select' do
it 'filters an array by value' do
array1 = [1, 2, 3, 4, 2, 5, 2]
expect(array1.my_select { |value| value == 2 }).to eql([2, 2, 2])
end
... | true |
020aecdd4f767a701a30dac2be1c3a4b10b47ce5 | Ruby | rferraz/ruby-llvm-dsl | /test/memory_access_test.rb | UTF-8 | 1,714 | 2.5625 | 3 | [
"BSD-2-Clause",
"LicenseRef-scancode-unknown-license-reference",
"BSD-3-Clause"
] | permissive | require "test_helper"
class MemoryAccessTestCase < Test::Unit::TestCase
def setup
LLVM.init_x86
end
def test_memory_access
assert_equal 1 + 2, run_default_function(simple_heap_memory_access_function, 1, 2).to_i
assert_equal 3 + 4, run_default_function(array_memory_access_function, 3, 5, 4).to_i
... | true |
26a0a089f7e6e8198407bf6ae487e25f48870d99 | Ruby | darthjee/azeroth | /lib/azeroth/model.rb | UTF-8 | 2,134 | 3 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Azeroth
# @api private
# @author Darthjee
#
# Model responsible for making the conection to the resource model class
class Model
# @param name [String,Symbol] name of the resource
# @param options [Azeroth::Options] resource options
def initialize(name, option... | true |
69e2f54cad6e4f4167e985dbedf5611eccade07f | Ruby | shanyi/Ruby-exercises | /Chap8.rb | UTF-8 | 556 | 3.875 | 4 | [] | no_license | # puts 'type as many words as you want'
# words = []
# while true
# word = gets.chomp
# if word == ''
# break
# end
# words.push word
# end
# puts words.sort
line_width = 50
table = ['Table of Contents','Chapter 1: Getting Started','Page 1','Chapter 2: Numbers','Page 9','Chapter 3: Letters','Page 13']
puts (tabl... | true |
44464c1ae1747b7df2f8c5eb2bb16f52d1a87b51 | Ruby | thisisniall/nycda_basic_ruby_2 | /bonus.rb | UTF-8 | 4,104 | 4.3125 | 4 | [] | no_license | # Bonus assignment: Create a "choose your own adventure" Ruby game using the gets ruby method to get user input from the command line. Have the game send the user down many different paths depending on the input that they enter. Use objects to store data about the user and different items they could collect along the w... | true |
dbc82684d1f626b42a1fc6818e2947cee04b2ad5 | Ruby | ga-wolf/wdi-18 | /09-tdd/bank/bank.rb | UTF-8 | 422 | 3.546875 | 4 | [] | no_license | require 'pry'
class Bank
attr_accessor :name, :accounts
def initialize( name )
@name = name
@accounts = {}
end
def create_account( name, balance )
@accounts[name] = balance
end
def balance( name )
@accounts[name]
end
def deposit( name, amount )
@accounts[name] += amount
end
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.