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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
6b81b13b9391c9a8ee726d3cbcd38d1ad3c09d36 | Ruby | StephanieCunnane/Launch_School_Course_120 | /exercises/medium_1/number_guesser_part_2.rb | UTF-8 | 3,596 | 4.34375 | 4 | [] | no_license | class GuessingGame
def initialize(lower_bound, upper_bound)
@lower_bound = lower_bound
@upper_bound = upper_bound
@range = (@lower_bound..@upper_bound)
@secret_number = rand(@range)
@guesses_remaining = calculate_max_guesses
end
def play
display_welcome_message
loop do
display_g... | true |
431d661136d17de90056fb45f5ec6fcca7159015 | Ruby | charleenmperrier/math_game | /game.rb | UTF-8 | 1,750 | 3.75 | 4 | [] | no_license | require './question'
require './player'
class Game
attr_accessor :current_player, :round_num
def initialize
@current_player = current_player
@round_num = 0
end
#starts the game on command-line
def begin_game
puts "Welcome to Math Game!"
question_round
end
def game_over
"Good Bye!"... | true |
95e55611c28b64896d094a3019b7b0f6256b3673 | Ruby | Dujota/Ruby-comprehensive-examples-for-students | /IO_DataStorage/entireread.rb | UTF-8 | 746 | 3.53125 | 4 | [] | no_license | filename = "sample.txt"
arr = IO.readlines(filename)
lines = arr.size
puts "sample.txt has #{lines} lines in it."
longest = arr.collect {|x| x.length}.max
puts "the longest line in it has #{longest} chars."
str = IO.read(filename)
bytes = str.size
puts "#{filename} has #{bytes} bytes in it."
#longest = str.collect {|... | true |
9b12f3f1dff873b11a09ba9c9ea6539531cd89dc | Ruby | yury/escape_utils | /benchmark/html_unescape.rb | UTF-8 | 755 | 2.546875 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/..')
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
require 'rubygems'
require 'benchmark'
require 'cgi'
require 'haml'
require 'escape_utils'
module HamlBench
extend Haml::Helpers
end
times = 100
url = "http... | true |
809f1680b147a7369fa4ab9c7862ce6cfcb7fa66 | Ruby | yoshimotokenta/furima-31685 | /spec/models/item_spec.rb | UTF-8 | 2,643 | 2.75 | 3 | [] | no_license | require 'rails_helper'
describe Item do
before do
@item = FactoryBot.build(:item)
end
describe'商品出品機能'do
context '出品登録がうまくいくとき' do
it "nameとinfo、categoryとcondition、areaとestimated,sellerとimageとpriceが存在すれば登録できる" do
expect(@item).to be_valid
end
end
context '出品登録がうまくいかないとき' do
... | true |
1961c396cdc0178b97ce91373d9e4046144e76fb | Ruby | GreyCat/ruby-tsv | /spec/lib/tsv_spec.rb | UTF-8 | 1,811 | 2.5625 | 3 | [
"MIT"
] | permissive | require File.join(File.dirname(__FILE__), '..', 'spec_helper.rb')
describe TSV do
let(:filename) { 'example.tsv' }
describe "#parse" do
let(:header) { nil }
let(:content) { IO.read(File.join(File.dirname(__FILE__), '..', 'fixtures', filename)) }
let(:parameters) { { header: header } }
subject { T... | true |
078ce232c3b01a2af5fa9d7d0f838de14d52e599 | Ruby | whites11/advent-of-code-2020 | /day1/2/run.rb | UTF-8 | 640 | 3.21875 | 3 | [] | no_license | #!/usr/bin/ruby
file="input"
candidates = []
f = File.open(file, "r")
f.each_line { |line|
candidates << line.to_i
}
f.close
candidates.sort!
candidates.each_with_index do |d, k|
target = 2020-d
i=0
j=candidates.size - 1
while i != j do
if i == k then
i = i+1
next
end
if j == k t... | true |
641f1d3f33fd9e6d6c6c71f17b3e51cd8699a100 | Ruby | ralcaide/sinapse_mqtt_client | /lib/sinapse_mqtt_client/epd_simulator.rb | UTF-8 | 2,669 | 2.8125 | 3 | [
"MIT"
] | permissive | require_relative "helpers"
require "mqtt"
#
# Class that implements a simulation of the Sinapse EPDs talking the Vodafone API
#
class SinapseEPDSimulatorVodafone < SinapseMQTTClientWrapper::SinapseMQTTClient
# Method that sends a status frame through the provided topic. The values of the Status frame are provided th... | true |
505d69fdee10a5b8fb2aaf59b8f833baac4aafed | Ruby | gitter-badger/admiral_stats | /app/batches/ship_card_ownership_batch.rb | UTF-8 | 1,884 | 2.640625 | 3 | [
"MIT"
] | permissive | # 艦娘カードの所有率の集計を行うバッチです。
# 実行方法は以下の通りです。-e オプションを指定しない場合は、development で実行されます。
# rails runner ShipCardOwnershipBatch.execute -e (development|production)
class ShipCardOwnershipBatch
def self.execute
# レポートの生成時刻を記録
reported_at = Time.current
Rails.logger.info("Ship Card Ownership Batch started")
begin... | true |
b519767abc0200664ca5240506a743bbcf9a1cea | Ruby | mizukiA/freemarket_sample_52a | /spec/models/card_spec.rb | UTF-8 | 2,372 | 2.625 | 3 | [] | no_license | require 'rails_helper'
describe Card do
describe '#create' do
# 登録可能
it "is valid with a card_number, expiration_year, expiration_month, security_code" do
card = build(:card)
expect(card).to be_valid
end
# 登録不可能(カード番号なし)
it "is invalid without a card_number" do
card = build(:c... | true |
43f7945de551b6b6437484af3e3a9f66fb0c2ea8 | Ruby | hitlion/Rubymotion-Childern-app-for-iOS | /app/models/story/story_document.rb | UTF-8 | 5,235 | 2.625 | 3 | [
"Apache-2.0"
] | permissive | # The Story module contains all classes dealing with parsing, validation
# and internal representation of story definitions (control.yml / control.json)
module Story
# A thin wrapper around a documents root structure.
# This class encapsulates all the metadata as well as header information.
# The document body ca... | true |
fa351f99cd14a7c3393f4eb171232f7053864e77 | Ruby | naoki-furuma/triangle | /triangle.rb | UTF-8 | 348 | 3.765625 | 4 | [] | no_license | a = ARGV[0].to_i
b = ARGV[1].to_i
c = ARGV[2].to_i
if (a + b > c) && (b + c > a) && (c + a > b)
if (a == b) && (b == c)
puts '正三角形ですね!'
elsif (a != b) && (b != c) && (c != a)
puts '不等辺三角形ですね!'
else
puts '二等辺三角形ですね!'
end
else
puts '三角形じゃないです><'
end | true |
17c2c587e708e7e9bcc9699e8614561d69e7f02f | Ruby | kevinkaske/rails-twitter-oauth-sample | /lib/oauth_system.rb | UTF-8 | 5,652 | 2.71875 | 3 | [
"MIT"
] | permissive | require 'json'
require 'oauth/consumer'
module OauthSystem
class GeneralError < StandardError
end
class RequestError < OauthSystem::GeneralError
end
class NotInitializedError < OauthSystem::GeneralError
end
# controller method to handle logout
def signout
self.current_user = false
flash[:notice] = "You h... | true |
1bf345edbcedbd6d10dba8d02b6a47d4bec6b096 | Ruby | aquilllwal/daily_assignment_ruby | /day_04/scraper/scraper.rb | UTF-8 | 1,575 | 2.78125 | 3 | [] | no_license | require 'httparty'
require 'nokogiri'
require 'byebug'
def url
url = {"Interglobe Aviation Ltd."=>"https://www.moneycontrol.com/india/stockpricequote/transport-logistics/interglobeaviation/IA04",
"SBI"=>"https://www.moneycontrol.com/india/stockpricequote/banks-public-sector/statebankindia/SBI",
"IC... | true |
9cc6bafae93d302c261065881cac69df39907835 | Ruby | a-suenami/tddbc-sendai-x-trial-ruby | /spec/lib/strawberry_spec.rb | UTF-8 | 1,534 | 3 | 3 | [
"Apache-2.0"
] | permissive | describe Strawberry do
context '未定義の品種の場合' do
it '作成に失敗する' do
expect { Strawberry.new('未定義の品種', 30) }.to raise_error ArgumentError
end
end
context '0g以下の場合' do
it '作成に失敗する' do
expect { Strawberry.new('あまおう', 0) }.to raise_error ArgumentError
end
end
describe '#to_s' do
describ... | true |
1990d883b79414d17e69813ec0bab4de761a4503 | Ruby | CheungGiven/suggest | /lib/trie_suggest.rb | UTF-8 | 5,736 | 2.84375 | 3 | [
"MIT"
] | permissive | # Trie tree class
class TrieTree
require 'natto'
require 'romaji'
require 'active_support'
require 'active_support/core_ext'
# char type https://github.com/buruzaemon/natto/wiki/Node-Parsing-char_type#appendix-d-node-parsing-and-char_type
DEFAULT = 0
SPACE = 1
KANJI = 2
SYMBOL = 3
NUMERIC = 4
ALPH... | true |
8023b538fd560546ecd9a4ff27345b528e390c93 | Ruby | Rygel-XVI/reverse-each-word-v-000 | /reverse_each_word.rb | UTF-8 | 356 | 3.46875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # def reverse_each_word(sentence)
# reversed_array = []
# sentence.split(" ").each do |word|
# reversed_array << word.reverse
# end
# return reversed_array*" "
# end
def reverse_each_word(sentence)
reversed = sentence.split
reversed = reversed.collect do |word|
"#{word.reverse}"... | true |
79b0bf671a8e840fb6a370ef7d9f6ebee594b132 | Ruby | tschannes/bm_exercises | /moulton/moulton.rb | UTF-8 | 978 | 2.609375 | 3 | [] | no_license | require 'Nokogiri'
require 'Open-Uri'
require 'pry'
require 'CSV'
doc = Nokogiri::HTML(open('http://www.ebay.com/sch/i.html?_odkw=moulton&_osacat=177831&_from=R40&_trksid=p2045573.m570.l1313.TR0.TRC0&_nkw=moulton&_sacat=177831'))
moultons = [["description"],["price"]]
description = doc.css('div.ittl h4 a.vip')
... | true |
308921ff2f208e770c08363624af60eeb51ec344 | Ruby | simon-hicks/scails | /lib/scails/instrument.rb | UTF-8 | 746 | 2.859375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #!/usr/bin/env ruby
module Scails::Instrument
def self.included klass
klass.send :attr_accessor, :repeat
end
def play_at time, *args
Scails::Clock.instance.at time do |t|
self.play *args
end
end
# stops BEFORE the specified time, so that if you run #stop(next_bar) it stops at the end of t... | true |
4a9d15b07d87c1e76afb7e7b910d36b6134c5f62 | Ruby | wofockham/wdi-9 | /04-ruby/oop/rental_lab/main.rb | UTF-8 | 1,878 | 3.515625 | 4 | [] | no_license | require 'pry'
require_relative 'tenant'
require_relative 'apartment'
require_relative 'building'
def create_tenant
puts "Tenant Creation:"
print "Enter tenant name: "
name = gets.chomp
print "Enter tenant age: "
age = gets.to_i
print "Enter tenant gender: "
gender = gets.chomp
Tenant.new name, age, ... | true |
10d651993fce3c310cf8f1bc7c84af09f5858bcd | Ruby | dhf0820/fhir-ruby | /spec/selection_spec.rb | UTF-8 | 750 | 2.5625 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe 'Fhir::Selection' do
module TestSelection
def my_selection(selection)
selection
end
end
let(:graph) do
Object.new.tap do |g|
g.stub(:modules).and_return([TestSelection])
end
end
example do
initial_selection = Object.new
selection = Fhir::Se... | true |
5e1b57bc7d1ba84b8ccae39fb9aac32f50fd6a23 | Ruby | wojkly/ruby-exercises | /project-caeser-cipher/lib/main.rb | UTF-8 | 905 | 3.65625 | 4 | [
"MIT"
] | permissive |
class Cipher
def caesar_cipher(string, shift)
shift = shift % 26
string = string.split("")
string.map! do |letter|
is_letter = true
# upcase
if 65 <= letter.ord && letter.ord <= 90
min_ord = 65
max_ord = 91
# d... | true |
6cd367479eb20cbe5531636b10e9d84e0a8424eb | Ruby | iNecas/sysflow | /lib/sysflow/actions/command.rb | UTF-8 | 1,349 | 2.53125 | 3 | [
"MIT"
] | permissive | module Sysflow
module Actions
class Command < ::Actions::EntryAction
include Algebrick::Matching
input_format do
param :cmd, String
end
def run(event = nil)
match(event,
on(nil) do
init_run
suspend do |suspended_action|
... | true |
e1370fc2add43b305c2ee7cd43f6b74765cdacad | Ruby | CodingDojo-Ruby-03-17/tibbetts | /TDD/RubyTDD/AppleTree/appletree_spec.rb | UTF-8 | 1,616 | 3.25 | 3 | [] | no_license | require_relative 'appletree'
RSpec.describe AppleTree do
before(:each) do
@tree = AppleTree.new()
end
it 'has an age with getter and setter' do
@tree.age = 100
expect(@tree.age).to eq(100)
end
it 'has a height attribute with a getter' do
expect{ @tree.height }.not_to raise_error(NoMethodErr... | true |
134b68f2a02dc26155d516fbbd9f16a91393c2e5 | Ruby | zooey/gtranslate | /gtranslate.rb | UTF-8 | 747 | 3.15625 | 3 | [] | no_license | require 'net/http'
require 'uri'
require 'json'
if ARGV.length<1
puts "Too little arguments!\nUsage:\nruby gtranslate <text> [lang_from] [lang_to]\nDefault: en -> pl"
exit
else
text = ARGV[0]
lang_to = 'pl'
lang_from = 'en'
if ARGV.length == 3
lang_to = ARGV[2]
lang_from = ARGV[1]
elsif ARGV.length == 2
la... | true |
1c2e8bf0864aca339f72447d1e9ed7ce2499e444 | Ruby | johnvoyage/programming_languages-web-012918 | /programming_languages.rb | UTF-8 | 354 | 2.953125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require "pry"
def reformat_languages(languages)
new_hash = {}
languages.each do |styl, hash|
hash.each do |lang, hash_two|
if new_hash[lang] == nil
new_hash[lang] = {
type: "#{hash_two[:type]}",
style: [styl]
}
else
new_hash[lang][:style].push(styl)
... | true |
931f4bcfd0773450962c886e5f2e8597a0b0845c | Ruby | gil231/string1.rb | /string.rb | UTF-8 | 325 | 3.296875 | 3 | [] | no_license | str = "Esto es una linea de texto"
str.downcase
str.upcase
str.count "texto"
str2 = "hello"
"".empty?
str2.swapcase
str2.capitalize
str2.chr
str3 = "perro"
str3.sub(/[e]/, '*')
str3.gsub(/[r]/, '*')
str3.include? "r"
str4 = "adios amigo " "hello"
str4.index "ad"
str4.reverse
str4.split
str4.strip
str4[0]
str4.byt... | true |
06ef3c342dd2359720f14a70a827d48e4ec7b96b | Ruby | Joshuaatt/rock_paper_scissors | /app.rb | UTF-8 | 504 | 2.765625 | 3 | [] | no_license | require('sinatra')
require('sinatra/reloader')
require('./lib/rock_paper_scissors')
get('/') do
erb(:index)
end
get('/one_player') do
erb(:one_player)
end
get('/two_player') do
erb(:two_player)
end
get('/two_player_answer') do
answer = params.fetch('player1').beats?(params.fetch('player2'))
if answer ==... | true |
932ed37a43791bfb90c7ea61e9185996ceb78091 | Ruby | xta/project_euler | /answers/ruby/problem_003.rb | UTF-8 | 378 | 3.90625 | 4 | [] | no_license | # Largest prime factor
## The prime factors of 13195 are 5, 7, 13 and 29.
## What is the largest prime factor of the number 600851475143 ?
require 'prime'
target = 600_851_475_143
ceiling = Math.sqrt(target).floor
factors = (1..ceiling).select do |n|
target % n == 0
end
primes = factors.select { |n| Prime.prime... | true |
482f63bbaf88cea1d6ef71c800f87b81b9a6c4f8 | Ruby | AakashOfficial/ThreatExchange | /ruby/lib/ThreatExchange/client.rb | UTF-8 | 8,685 | 2.65625 | 3 | [
"BSD-3-Clause"
] | permissive | require "ThreatExchange/http_methods"
require "logger"
module ThreatExchange
# The ThreatExchange::Client object handles all interactions
# with https://graph.facebook.com.
# Some TODO's - Better Error handling and explicit requirements
# around parameters passed to the methods.
#
# Docs: https://developer... | true |
19fb58c1f106a7ddb71d132c0310d33bcf5315a1 | Ruby | Heybluguy/flashcards | /flashcard_runner.rb | UTF-8 | 1,442 | 3.921875 | 4 | [] | no_license | require "./lib/guess"
require "./lib/deck"
require "./lib/card"
require "./lib/round"
require "./lib/card_generator"
class FlashcardRunner
attr_reader :deck, :round, :user_input, :current_card
def initialize(filename)
@deck = Deck.new(CardGenerator.new(filename).cards)
@round = Round.new(deck)
@user_i... | true |
e9de0b9aae650b88fbc0f2e78207cbb47d460ff2 | Ruby | sevendials/trello_cli | /lib/trello_cli/formatters/card_create.rb | UTF-8 | 333 | 2.59375 | 3 | [
"MIT"
] | permissive | module TrelloCli
module Formatters
class CardCreate < Base
def to_legacy
msg = "Card Created.\n"
msg << "Name : #{data[:name]}\n"
msg << "Description : #{data[:desc]}\n"
end
def to_tsv
[data[:id], data[:name], data[:desc]].join("\t") + "\n"
end
e... | true |
df77c8f21d4dd70c3155098c36ab1a3dd029f593 | Ruby | wangjoc/betsy | /test/controllers/reviews_controller_test.rb | UTF-8 | 2,531 | 2.671875 | 3 | [] | no_license | require "test_helper"
describe ReviewsController do
describe "create" do
it "responds with not found if product is nil" do
product_id = "taco"
review_info = {
review: {
rating: 5,
review_text: "Tacos are a really good food",
product_id: product_id,
},
... | true |
c24d065b516c5a69be050a80e2c209b17aa0b210 | Ruby | ljnissen/rubycode | /004/file_06.rb | UTF-8 | 130 | 3 | 3 | [] | no_license | class Callable
def callable_method_ii
puts "Hi from callable_method_ii"
end
end
Callable.new.method(:callable_method_ii).call | true |
7dc07b19d122813ffb791eb561d7797548a7a1a5 | Ruby | yoshoku/rumale | /rumale-linear_model/lib/rumale/linear_model/svr.rb | UTF-8 | 5,013 | 2.8125 | 3 | [
"BSD-3-Clause"
] | permissive | # frozen_string_literal: true
require 'lbfgsb'
require 'rumale/base/regressor'
require 'rumale/validation'
require_relative 'base_estimator'
module Rumale
module LinearModel
# SVR is a class that implements Support Vector Regressor with the squared epsilon-insensitive loss.
#
# @note
# Rumale::S... | true |
007a8aa05e7b767ef19e60470f334a05c5a0c7aa | Ruby | lotterblad/githubarchive.org | /reports/daily.rb | UTF-8 | 2,143 | 2.5625 | 3 | [
"MIT"
] | permissive | require 'hominid'
require 'json'
require 'erb'
yesterday = (Time.now - 60*60*24).strftime("%Y-%m-%d")
template = ERB.new IO.read('template.html')
top_new_repos = <<-SQL
SELECT repository_name, repository_language, repository_description, COUNT(repository_name) as cnt, repository_url
FROM github.timeline
WHERE type="... | true |
c165384691e7acdd066c61da8603b90ccbd40e58 | Ruby | Sillhouette/collections_practice-v-000 | /collections_practice.rb | UTF-8 | 2,014 | 4.5 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | ##
# => #sort_array_asc sorts the array in ascending order
##
def sort_array_asc(array)
return array.sort;
end
##
# => #sort_array_desc sorts the array in decending order
##
def sort_array_desc(array)
return array.sort {|a, b| b <=> a};
end
##
# => #sort_array_char_count sorts the array according to the number of... | true |
4232a07b48bcb1d62d69fa658633343c69188237 | Ruby | moridonut/rubyStudy | /test.rb | UTF-8 | 74 | 2.65625 | 3 | [] | no_license |
def test_method(aaa,bbb)
puts aaa
puts bbb
end
test_method
sleep()
| true |
98df0f81cb34be71849928a22b809d92cbe76bce | Ruby | mattforni/validity | /lib/validity/frameworks/test_unit/record.rb | UTF-8 | 3,379 | 2.953125 | 3 | [
"MIT"
] | permissive | module Validity
module TestUnit
module Record
extend Test::Unit::Assertions
# Asserts a record has a +belongs_to+ association as indicated by the provided
# +field+ and that the record equals the +target+ record, if provided.
#
# * *Args*:
# - +record+ the record to validate
... | true |
d7d8022fd02205802df5a1df4a3fee52893d673b | Ruby | msa/beergame | /app/models/player.rb | UTF-8 | 1,075 | 3.25 | 3 | [] | no_license | class Player
attr_accessor :name, :inventory, :shipped, :backlog, :balance, :upstream, :downstream
attr_reader :order
INVENTORY_COST = 0.5
BACKLOG_COST = 1
def initialize(name = 'player')
self.name = name
self.inventory = 12
self.shipped = 0
self.backlog = 0
self.balance = 0... | true |
fa55c7bee2cb593563ba55674c13957fdb1abcff | Ruby | wInevitable/Checkers | /Checkers.rb | UTF-8 | 3,062 | 3.546875 | 4 | [] | no_license | #encoding: utf-8
require 'pry'
require 'yaml'
require 'colorize'
require_relative 'board'
require_relative 'piece'
require_relative 'invalid_move_error'
class Checkers
attr_reader :players
attr_accessor :current_player, :board
def initialize
@board = Board.new
@players = {
:white => HumanPla... | true |
b3c8798ff8adae250a416de952a569a7f0c64e25 | Ruby | bryanwoods/gen_spec | /example.rb | UTF-8 | 468 | 3 | 3 | [
"MIT"
] | permissive | require 'gen_spec'
def adder(x, y)
puts "x: #{x}, y: #{y}"
(x + y) # <- Output is a Fixnum
end
gen_spec :adder, "Fixnum inputs always return a Fixnum" do
inputs { "Fixnum, Fixnum" }
validator { result.is_a?(Fixnum) }
end
#=> true
def adder(x, y)
puts "x: #{x}, y: #{y}"
(x + y).to_f # <- Output is a Floa... | true |
d6478efc501e038e9a105f2846bb08dc7a6df342 | Ruby | jasonleibowitz/zlatanisms | /lib/main.rb | UTF-8 | 1,091 | 3.71875 | 4 | [] | no_license | require_relative "zlatanisms"
zlatan = Zlatanisms.new
initializer = "start"
while initializer != "3"
puts " |---------------------------|
| Welcome to the Zlatan |
| Quote Generator 1.0 |
|---------------------------|"
puts
puts "This application will entertain you with actual quotes uttered ... | true |
e3af2d7f02d6cc491e1511e4b5459c0849deb3c2 | Ruby | suppy/CodeIQ | /CodeIQ-q348/CodeIQ-q348.rb | UTF-8 | 184 | 3.078125 | 3 | [] | no_license | def A(m, n)
# print "A(", m, ", ", n, ")\n"
if m == 0 then
n + 1
elsif n == 0 then
A(m - 1, 1)
else
A(m - 1, A(m, n - 1))
end
end
print A(4, 1)
| true |
6de8f8c34cdaa614bcfc353b5dc5b09ee8cc03fb | Ruby | ministryofjustice/gov_uk_date_fields | /lib/gov_uk_date_fields/acts_as_gov_uk_date.rb | UTF-8 | 5,281 | 2.609375 | 3 | [
"MIT"
] | permissive | module GovUkDateFields
module ActsAsGovUkDate
extend ActiveSupport::Concern
included do
end
module ClassMethods
VALID_ERROR_CLASH_BEHAVIOUR_OPTIONS = [ :append_gov_uk_date_field_error, :omit_gov_uk_date_field_error, :override_with_gov_uk_date_field_error]
DEFAULT_GOV_UK_DATE_OPTIONS = { ... | true |
a4c6eb22ca82cb802db932f370fb4b798d535ae6 | Ruby | unnitallman/survey_results_parser | /app/models/csv_parser/main.rb | UTF-8 | 1,788 | 2.78125 | 3 | [] | no_license | require 'csv'
module CsvParser
class Main
def initialize(file)
csv_data = file.read
@surveyname = file.original_filename
@meta_information = CsvParser::MetaInformation.new(csv_data).parse
@responses = CsvParser::Responses.new(csv_data).parse
end
def load
... | true |
57803b595af22c6d345bd342278da9fe56ba45e0 | Ruby | Shimin-Zhang/Checkers | /board.rb | UTF-8 | 1,883 | 3.421875 | 3 | [] | no_license | require_relative "piece"
class Board
BACKGROUND = {1 => :light_black,
0 => :light_white}
SIZE = 10
attr_reader :grid
def initialize(blank = false)
make_grid
make_pieces unless blank == true
end
def dup
new_board = self.class.new(true)
self.grid.each do |row|
row.each... | true |
fe55c4f52034f10dbe36118414002c491c388b23 | Ruby | heitzke/new_dividend_reporter | /lib/yahoo_integrator.rb | UTF-8 | 1,094 | 2.546875 | 3 | [] | no_license | class YahooIntegrator
attr_accessor :stocks, :quotes
def get_quotes stock_array
yahoo_hash = YahooFinance.get_standard_quotes stock_array
yahoo_hash.keys.each do |ticker|
if Stock.find_by_ticker ticker
stock = Stock.find_by_ticker ticker
else
stock = Stock.new
end
quo... | true |
ad53e50749508d8d42bc11edff207e64eca40c66 | Ruby | haleylikesrocks/RB120_object_oriented_programming | /Exercises/Easy_1.rb | UTF-8 | 3,781 | 4.375 | 4 | [] | no_license | ### Banner Class
class Banner
def initialize(message)
@message = message
@message_length = message.size
end
def to_s
[horizontal_rule, empty_line, message_line, empty_line, horizontal_rule].join("\n")
end
private
def horizontal_rule
'+' + '-' * (@message_length + 2) + '+'
end
def em... | true |
aab5380b61c186d17b5da7fe46de613004785db7 | Ruby | luizromariofilho/exercism | /ruby/rna-transcription/rna_transcription.rb | UTF-8 | 516 | 3.265625 | 3 | [] | no_license | # Write your code for the 'Rna Transcription' exercise in this file. Make the tests in
# `rna_transcription_test.rb` pass.
#
# To get started with TDD, see the `README.md` file in your
# `ruby/rna-transcription` directory.
class Complement
class << self
COMPLEMENT_RNA = {
'G': 'C',
'C': 'G',
'T... | true |
66bb75a9aa73ca50b9b964e4872f907dec0f945b | Ruby | eashan/Ruby-Basics | /testmodule.rb | UTF-8 | 705 | 4.25 | 4 | [] | no_license | #Can't create subclass from modules although itappears similar to class
#Uses??
# 1. Modularity
# 2. Mixins
module MyModule
GoodMood = "Happy"
BadMood = "Grumpy"
#Instance Method
def greet
return "I am #{GoodMood}. how are you?"
end
#Module Method
def MyModule.greet
return"I am #{BadMood}. How are you?"
en... | true |
8be87507ed916ec2cfac3b228dbef9e96030fbb5 | Ruby | oupo/inzm3scripts | /inzm3-premium.rb | SHIFT_JIS | 2,047 | 2.609375 | 3 | [] | no_license | #!ruby
# encoding: cp932
require_relative "utils.rb"
require_relative "inzm3-data-decode.rb"
@settings = [
{name: "premiumcondition.dat", size: 60, type: :unit},
{name: "premium_item.dat", size: 36, type: :item},
{name: "premiumcondition_hurri.dat", size: 64, type: :unit},
{name: "premium_item_hurri.dat", size: 36... | true |
a4e235f7f15f03356c3f2203f4670339e6ce8bf3 | Ruby | ndlib/sipity | /app/models/sipity/models/collaborator.rb | UTF-8 | 3,424 | 2.703125 | 3 | [
"Apache-2.0"
] | permissive | module Sipity
module Models
# A collaborator for the given work. These are the named people that
# collaborated on the creation of the scholarly work (i.e. they helped write
# the paper). It is not the people that collaborated on the processing of
# the work (i.e. they signed off on the metadata for a... | true |
09e733c7799a86c0758b928ce9e246519048d74b | Ruby | zizhizhan/q | /lib/q.rb | UTF-8 | 474 | 2.53125 | 3 | [
"MIT"
] | permissive | require "q/version"
module Q
def self.defer(&block)
defer = Q::Defer.new
block.call(defer)
defer.promise
end
def self.when(promises)
defer = Q::Defer.new
@results = []
promises.each do |promise|
promise.then do |result|
@results << result
defer.resolve(@results)... | true |
76c44e1d3eafbd1aa37c1f2173f2c0c7a240f5cf | Ruby | bitmakerlabs/wdi-december-2017 | /28-sessions-and-authentication/instructor/outline.rb | UTF-8 | 370 | 2.625 | 3 | [] | no_license | class User < ApplicationRecord
def authenticate(submitted_password)
salt = password_digest[0..1]
hsp = password_digest[2..*]
hsp == hash(submitted_password, salt)
end
end
def hash(str, salt)
return operation(str, salt)
end
u = User.find_by(email: params[:email])
if u.authenticate(params[:passwor... | true |
38b613f1f0ec4f75bd02a199032bf20399a011af | Ruby | hmuyba/ExamenFinIngSoft | /spec/posinicial_spec.rb | UTF-8 | 490 | 3.21875 | 3 | [] | no_license | require './lib/MoveCar.rb'
RSpec.describe "separar correctamente los caracteres introducidos en un string" do
it "deberia deboler el array [1,2] al introducir el texto 1,2" do
numero="1,2"
resultado=getInitialPosition(numero)
expect(resultado).to eq([1,2])
end
it "deberia devolver ... | true |
8ad9f0b01f6aeeff5bbe73272486cc6b0f5dc566 | Ruby | andres-fortier/visible | /spec/requests/stock_quotes_spec.rb | UTF-8 | 4,740 | 2.578125 | 3 | [] | no_license | require 'rails_helper'
# TODO: Test proper validation and errors
describe 'StockQuote API' do
let(:json) { JSON.parse(response.body) }
let(:json_headers) do
{"CONTENT_TYPE" => "application/json"}
end
let(:stock_quotes) do [
StockQuote.new(
trade_date: Date.parse('2016-01-20'),
open_valu... | true |
359141fb844b4985cda8d314ff151cff47f6a3a0 | Ruby | peteroupc/rubysnappy | /rsnappy.rb | UTF-8 | 9,201 | 2.71875 | 3 | [
"MIT"
] | permissive | # Defines two methods, 'snappyCompress' and 'snappyUncompress',
# that compress and decompress byte strings in Snappy format.
#
# NOTE: Adapted by Peter O. (github.com/peteroupc)
# from snappy-js (https://github.com/zhipeng-jia/snappyjs), which is licensed as follows.
# The license and the copyright notice for sna... | true |
ea28ac235ae95aa26c1c860383fdde2c5797995f | Ruby | Umitosan/palindromes | /spec/palindromes_spec.rb | UTF-8 | 493 | 3.328125 | 3 | [] | no_license | require('rspec')
require('palindromes')
require('pry')
describe() do
it("returns the reversed version of a word") do
expect("hannah".pal?()).to(eq(true))
end
it("returns the reversed version of a word") do
expect("taco cat".pal?()).to(eq(true))
end
it("returns the reversed version of a word") do
... | true |
d263c95f24cc2cd91ef799e3bfbd5ad953e1523c | Ruby | intenex/aa-practice-test-generator | /solutions/base_converter_solution.rb | UTF-8 | 164 | 3.25 | 3 | [] | no_license | def base_converter(num, b)
return num.to_s if [0,1].include?(num)
digits = %w(0 1 2 3 4 5 6 7 8 9 a b c d e f)
base_converter(num/b, b) + digits[num % b]
end | true |
dc29efa305fdaddf9c0e893d5390ae06bf04edf1 | Ruby | JulianHernandez19/Ruby-Introduccion | /clsPerro2.rb | UTF-8 | 345 | 2.9375 | 3 | [] | no_license | class Perro
def initialize(nombre = 'sin nombre', raza = 'sin raza')
@nombre = nombre
@raza = raza
end
def ladrar
return "gua gua"
end
def dame_nombre
return @nombre
end
def dame_raza
return @raza
end
#def nombre
# return @nombre
#end
#def nombre=(nombre)
# @nombre = nombre
#end
attr_acc... | true |
4d9b723d99752cda52bf945bb97787224e09de5c | Ruby | mlebrun/singularity_dsl | /lib/singularity_dsl/errors.rb | UTF-8 | 666 | 2.65625 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
module SingularityDsl
# error & failure classes / methods
module Errors
class ResourceFail < RuntimeError
end
class ResourceError < RuntimeError
end
def klass_name(obj)
return obj.class if obj.class < Object
obj
end
def klass_error(klass)
klass = k... | true |
d80bc489af619dbc248f616e3d020d14171247bf | Ruby | lao9/black-thursday-project | /lib/sales_analyst.rb | UTF-8 | 1,069 | 2.734375 | 3 | [] | no_license | require 'pry'
require_relative '../lib/stats_calculator'
require_relative '../lib/merchant_analytics'
require_relative '../lib/item_analytics'
require_relative '../lib/invoice_analytics'
require_relative '../lib/customer_analytics'
class SalesAnalyst
include StatsCalculator
include MerchantAnalytics
include Item... | true |
9ba9d2c4d8f98b0b003ff0de198ecab6454f0789 | Ruby | tonyr729/boat_rental | /lib/dock.rb | UTF-8 | 833 | 3.328125 | 3 | [] | no_license | class Dock
attr_reader :name, :max_rental_time, :current_rentals, :rental_history
def initialize(name, max_rental_time)
@name = name
@max_rental_time = max_rental_time
@current_rentals = []
@rental_history = []
end
def rent(boat, renter)
@current_rentals << {boat: boat, renter: renter}
e... | true |
2310e0a91f1d40cd1eca71d62b52de3acd4c4710 | Ruby | doubiz/sshez | /lib/sshez/printing_manager.rb | UTF-8 | 713 | 3.0625 | 3 | [
"MIT"
] | permissive | require 'singleton'
module Sshez
# Just a printing service that keeps track by all its output
# Mainly used for testing purposes
class PrintingManager
include Singleton
def initialize
@output = ""
@verbose = false
end
# adds to output then prints
def print(text)
@output +=... | true |
4594edb2950084b2f0c62c983f0b8286dcdfed62 | Ruby | jializhou/undergraduate_projects | /medical_prediction/gene information extraction and analysis/remove.rb | UTF-8 | 267 | 2.578125 | 3 | [] | no_license | require 'rake'
filelist = FileList["*.txt"].reject{|f| f =~ /get/}
filelist.each do |f|
File.open("get_"+f,'w') do |fout|
lines = File.readlines(f)
seen ={}
lines.each do |line|
if !seen[line]
fout.puts line
seen[line] = true
end
end
end
end | true |
a40fa3fed8e2fdd71b8090dd5135a85957a5a02f | Ruby | Alexey-T/lexer_tests | /lexers/Ruby/RBE_scripts/same_time_same_place.rb | UTF-8 | 2,159 | 3.515625 | 4 | [] | no_license | #!/usr/bin/env ruby -w
# same_time_same_place.rb
class SameTimeSamePlace
EPISODE_NAME = 'Same Time, Same Place'
=begin rdoc
This Hash holds various procedure objects. One is formed by the generally
preferred Kernel.lambda method. Others are created with the older Proc.new
method, which has the benefit of allow... | true |
5030c5a2d424c3622f673bf05e254f6e088f96ed | Ruby | anEXPer/counterstring | /spec/thor_spec_helper.rb | UTF-8 | 395 | 2.53125 | 3 | [] | no_license | # For testing thor output, taken from
# https://github.com/erikhuda/thor/blob/master/spec/helper.rb
# as described here http://bokstuff.com/blog/testing-thor-command-lines-with-rspec/
def capture(stream)
begin
stream = stream.to_s
eval "$#{stream} = StringIO.new"
yield
result = eval("$#{stream}").str... | true |
12def1994635fc113e6f90784d5aa00766cb5720 | Ruby | patrick13111993/Ruby-project-week4-5 | /models/pokemon.rb | UTF-8 | 2,065 | 3.296875 | 3 | [] | no_license | require_relative('../db/sql_runner')
require_relative('trainer')
require('date')
class Pokemon
attr_reader(:name, :breed, :date_arrived, :id)
attr_accessor(:trainerid, :picture)
def initialize(options)
@id = options['id'].to_i || 'null'
@name = options['name']
@breed = options['breed']
@date_a... | true |
e20e6e8e9acf1aba68318397d956f507e1755220 | Ruby | suotani/ruby-algorism | /kruskal.rb | UTF-8 | 466 | 2.84375 | 3 | [] | no_license | nodes = [
["a", "b", 5],["a", "c", 3],["a", "d", 4],["a", "e", 2],
["b", "c", 10],
["c", "d", 4],["c", "e", 7],
["d", "e", 2]
]
def unclose?(points, node)
!(points.include?(node[0]) && points.include?(node[1]))
end
points = []
result = []
point_size = 5
sorted = nodes.sort{|a, b| a[2] <=> b[2] }
sorted.eac... | true |
d3a4f1ab34c392db9433a91b594bfbf7136781eb | Ruby | stevehwp87/ar-sunlight-legislator | /app/models/state.rb | UTF-8 | 1,165 | 2.9375 | 3 | [] | no_license | require_relative '../../db/config'
# class State < ActiveRecord::Base
# validates :name, uniqueness: true
# has_many :congressman
# def state
# end
# end
# require_relative '../../db/config'
# class Student < ActiveRecord::Base
# validates :email, format: { with: /\w+@\w+\.\w{2,}/, message: "Valid e... | true |
a479938982f22c5257232d0c9391a439ade399a7 | Ruby | jayczech23/glimmer-dsl-swt | /samples/elaborate/battleship.rb | UTF-8 | 2,416 | 2.546875 | 3 | [
"MIT"
] | permissive | # Copyright (c) 2007-2021 Andy Maleh
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# d... | true |
5d9ab8bd1b87dcc8a1d3f8bfc22d21fd9e214981 | Ruby | msylvestre/csv_img_generator3000 | /csv_img_generator.rb | UTF-8 | 3,004 | 2.78125 | 3 | [] | no_license | require 'fileutils'
# TODO
# - Add img for child
# - Set delimiet as a constant
# Config data
NB_PRODUCTS = 1000
GENERATE_IMG = true
GENERATE_CSV = true
# CSV Parameter
GENERATE_CHILD = true
GENERATE_CHILD_EVERY_X_PRODUCTS = 3 # Enter the value of X
NUMBER_OF_CHILD = 5 # ... | true |
4e3df216260b5ac13aea237aad04396904c2596f | Ruby | brightbox/rspec-rails-extensions | /lib/rspec_rails_extensions/comparable_array.rb | UTF-8 | 734 | 2.609375 | 3 | [
"MIT"
] | permissive | class ComparableArray
attr_reader :array
def initialize array
@array = array.dup
end
def =~ other_array
array.size == other_array.size && array.all? {|e| other_array.include?(e) }
end
def inspect
array.inspect
end
def method_missing method, *args
if array.respond_to?(method)
ar... | true |
05efbecc12bf40e48813ff2344c7fd56bd135149 | Ruby | briecoyle/learn_ruby_the_hard_way | /ex18.rb | UTF-8 | 938 | 4 | 4 | [] | no_license | def print_two(*args)
arg1, arg2 = args
puts "arg1: #{arg1}, arg2: #{arg2}"
end
def print_two_again(arg1, arg2)
puts "arg1: #{arg1}, arg2: #{arg2}"
end
def print_one(arg1)
puts "arg1: #{arg1}"
end
def print_none()
puts "I got nothin'."
end
print_two("Brie", "Coyle")
print_two_again("Zed", "Shaw")
print_one... | true |
fd337b319e49e097e3360ba05b094f9129fdf22f | Ruby | Shopify/money | /lib/money/currency.rb | UTF-8 | 1,987 | 2.8125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # frozen_string_literal: true
require "money/currency/loader"
class Money
class Currency
@@mutex = Mutex.new
@@loaded_currencies = {}
class UnknownCurrency < ArgumentError; end
class << self
def new(currency_iso)
raise UnknownCurrency, "Currency can't be blank" if currency_iso.nil? ||... | true |
43283f40a848ce3c1e68e3901e640f63f5f9e28f | Ruby | ToniRib/binary-search-tree | /spec/tree_test.rb | UTF-8 | 9,678 | 3.1875 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/pride'
require './lib/tree'
class TreeTest < Minitest::Test
def test_can_add_a_head_node
bst = Tree.new
bst.insert(10)
assert_equal 10, bst.head.data
end
def test_inserts_smaller_node_to_left_without_overwriting_head_node
bst = Tree.new
bst.inser... | true |
10a2ebdb59272d089fb29e441b97f978c7918458 | Ruby | Malet/gutterball | /app/models/game.rb | UTF-8 | 420 | 2.703125 | 3 | [] | no_license | class Game < ActiveRecord::Base
has_and_belongs_to_many :players
has_many :frames
FRAMES_PER_GAME = 10
PINS = 10
def start!
raise 'You need 1 or more players to start bowling' unless self.players.count > 0
create_frames
end
private
def create_frames
self.players.each do |player|
F... | true |
946f43df723ba24280a27c1dfb19f924f6dc8e93 | Ruby | ktochow1/Oak-and-Olive | /app/services/authorization_service.rb | UTF-8 | 779 | 2.640625 | 3 | [] | no_license | # extracting authorization logic to service folder = separating concerns
# of VERIFYING AUTHENTICITY OF JWT vs AUTHORIZING HTTP REQ
#AuthorizationService grabs access token in Authorization HTTP header
# and passes it to JsonWebToken for verification
# separation of responsibility can limit future changes to JWT ver... | true |
07e52174fb1316b11d55aa4f7b98390ba657e49c | Ruby | darkbaby123/kata-poker-hands | /lib/poker_hands.rb | UTF-8 | 359 | 2.984375 | 3 | [] | no_license | require_relative 'poker_hands/card'
require_relative 'poker_hands/card_group'
require_relative 'poker_hands/comparer'
require_relative 'poker_hands/hand'
module PokerHands
def self.vs(left, right)
re = Comparer.vs(Hand.new(left), Hand.new(right))
case re
when 0 then 'Tie.'
when 1 then 'Left wins.'
... | true |
ff256cbd1ed954d02e33b1493ae761e6253710b7 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/sum-of-multiples/9c4aa6f184db48c4b064b73e9df29201.rb | UTF-8 | 304 | 3.46875 | 3 | [] | no_license | class SumOfMultiples
def initialize(*n)
@n = n
end
def to(n)
(3...n).to_a.select do |x|
@n.any? { |y| (x % y).zero? }
end.inject(:+)
end
def self.to(n)
sum = (3...n).to_a.select do |x|
(x % 3).zero? || (x % 5).zero?
end.inject(:+)
sum ? sum : 0
end
end
| true |
56ff2973b55cfc44f1c181a74dc33954d9153e2e | Ruby | hschmid516/final_2107 | /spec/auction_spec.rb | UTF-8 | 5,488 | 2.796875 | 3 | [] | no_license | require './lib/item'
require './lib/auction'
require './lib/attendee'
require 'date'
RSpec.describe Auction do
it 'exists' do
auction = Auction.new
expect(auction).to be_a(Auction)
end
it 'can add items' do
item1 = Item.new('Chalkware Piggy Bank')
item2 = Item.new('Bamboo Picture Frame')
au... | true |
3fc4440c324f1d9135ff8bf3ebcd4ef187918c4f | Ruby | shezdev/oyster_card | /lib/journey_log.rb | UTF-8 | 666 | 2.96875 | 3 | [] | no_license | require 'journey'
class JourneyLog
attr_reader :journeys, :entry_station, :journey
def initialize
@journeys = []
@journey = Journey.new
end
def start(station)
journey.start(station)
end
def finish(station)
journey.finish(station)
@journeys << {start: journey.entry_station, end: ... | true |
0f9b55344baaf4942dd8456d471bffcc77cfe6a3 | Ruby | kenta-s/atcoder | /abc040/c01.rb | UTF-8 | 206 | 2.640625 | 3 | [] | no_license | n = gets.to_i
as = gets.split.map(&:to_i)
dp = []
dp << 0
dp << (as[0] - as[1]).abs
(2..n-1).each do |i|
dp[i] = [dp[i-2] + (as[i-2] - as[i]).abs, dp[i-1] + (as[i-1] - as[i]).abs].min
end
puts dp[n-1]
| true |
f4573fd9f4478559983f889a007bc34f44073ac3 | Ruby | RodCardenas/AppAcademyProjects | /Cohort/w1d1/lib/ghost.rb | UTF-8 | 2,253 | 3.90625 | 4 | [] | no_license | class Game
def initialize(player1, player2, dictionary)
@fragment = ""
@dictionary = read_dict(dictionary)
@players = { player1: player1, player2: player2 }
@current_player = player1
end
def read_dict(dictionary)
lines = File.readlines(dictionary)
lines.each_with_index do |line, idx|
... | true |
49eec0f79e250d9b1143c7fdfd592ae6696cf681 | Ruby | AdaoNatalino/ruby-oo-practice-flatiron-zoo-exercise-lon01-seng-ft-042020 | /run.rb | UTF-8 | 465 | 3.078125 | 3 | [] | no_license | require_relative "lib/Animal.rb"
require_relative "lib/Zoo.rb"
require 'pry'
z1 = Zoo.new("GREENFOREVER", "LONDON")
z2 = Zoo.new("FREELAND", "NEWZELAND")
z3 = Zoo.new("ICELAND", "NEWZELAND")
a1 = Animal.new("Dog", 10, "ringo", z1)
a2 = Animal.new("TRex", 20, "bob", z2)
a3 = Animal.new("Pokemon", 57, "lazy", z1)
a4 =... | true |
9fc2b956ebacf5e50ad605e357283f3daf552714 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/word-count/c451aed78e5b438385681d1654301b7e.rb | UTF-8 | 501 | 3.5 | 4 | [] | no_license | class Phrase
def initialize(value)
@string_value = value.to_s
end
def word_count
if @words.nil?
initialize_words
end
@words
end
private
def count_words(word_list)
word_list.each_with_object(@words) do |word, word_hash|
word_hash[word] += 1;
end
end
def initialize_... | true |
5566ef4600772648ba404627db73491c67a1f892 | Ruby | chelofm/SisGePed | /pedidos_factu/app/models/autorizacion.rb | UTF-8 | 504 | 2.53125 | 3 | [] | no_license | class Autorizacion < ActiveRecord::Base
set_table_name "autorizaciones"
belongs_to :pedido
belongs_to :estado_pedido
belongs_to :usuario
#metodo que permite cambiar el estado de las autorizaciones para un
#determinado pedido, cambia el estado a TRUE o FALSE
def self.cambia_estado_autorizaciones(idPedido... | true |
81b93b5a9cd4304c4894a4eed8533c6c6931fb81 | Ruby | hashimoto-atsunori/MyAppRails | /vendor/bundle/ruby/2.6.0/gems/ruby-debug-ide-0.7.0/lib/ruby-debug-ide/helper.rb | UTF-8 | 926 | 3.171875 | 3 | [
"MIT"
] | permissive | module Debugger
module ParseFunctions
# Parse 'str' of command 'cmd' as an integer between
# min and max. If either min or max is nil, that
# value has no bound.
def get_int(str, cmd, min=nil, max=nil, default=1)
return default unless str
begin
int = Integer(str)
if min an... | true |
96119208cdb54deb87c2c2e15ef428e5533c811b | Ruby | wyubin/ex_ruby | /script/intro_1.rb | UTF-8 | 192 | 3.125 | 3 | [] | no_license | #!/usr/bin/ruby
$i = 0
$num = 5
while $i < $num do
puts("Inside the loop i = #$i")
$i +=1
end
## variables and constant
a, _ = 1, 2
c,b = [3,4]
puts(a)
puts('b=%d' % b)
puts("c=#{c}")
| true |
9cfd6216c19b04b142dd80e66e720f92a6e7b2f1 | Ruby | rdp/gitty | /assets/hooks/auto-submodules | UTF-8 | 4,376 | 2.625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
#
# description: |-
# A git hook that automatically updates your submodules for you when you change branches or pull
#
# It works like this:
# - If before you changed branches, your submodule's revision differed from what the master repo specified, your submodule is left alone
# - If a submo... | true |
cd329b5cc5607efd2acb98af19cd5bb8c2237a80 | Ruby | nahi/avl_tree | /bench/bench_thread.rb | UTF-8 | 658 | 2.875 | 3 | [
"BSD-2-Clause",
"Ruby",
"BSD-3-Clause"
] | permissive | require 'benchmark'
require 'red_black_tree'
Benchmark.bmbm do |bm|
bm.report do
h = ConcurrentRedBlackTree.new
num = 100000
max = 1000
threads = []
# writers
2.times do
threads << Thread.new {
num.times do
key = rand(max)
h[key] = key
end
}
end... | true |
37e3f8536f07041896ba374a8e10f6f991f19319 | Ruby | lhoffmanwg/deli-counter-prework | /deli_counter.rb | UTF-8 | 751 | 3.8125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | katz_deli = []
def line(array)
if array == []
puts "The line is currently empty."
else
message = "The line is currently:"
array.each_with_index { | name, index | message = message + " #{index + 1}. #{name}"}
puts message
end
end
def take_a_number(katz_deli, name)
if katz_deli == []
... | true |
57213848e7c2b8de70a79f52d07d343ff1bdc295 | Ruby | chriskottom/fivethirtyeight-tracker | /lib/fivethirtyeight/feed.rb | UTF-8 | 1,338 | 2.859375 | 3 | [
"MIT"
] | permissive | require "json"
require "net/http"
require "uri"
module FiveThirtyEight
class APIResponseError < StandardError; end
class APITimeout < APIResponseError; end
class Feed
SUMMARY_PATH = "http://projects.fivethirtyeight.com/2016-election-forecast/summary.json"
def current_forecast
json_data = fetch_fe... | true |
83ebc5c51b9f3256e39ef1c1c8b864b18626721a | Ruby | ahawkins/decks | /test/packaging/packager_test.rb | UTF-8 | 5,091 | 2.671875 | 3 | [
"MIT"
] | permissive | require_relative '../test_helper'
module Decks
class PackagerTest < MiniTest::Unit::TestCase
class FakeValidator
def valid?
true
end
end
class FakeFileNameGenerator
def release
'Packaging-Tests-RB-2014-ADAM'
end
def nfo
'fake.nfo'
end
d... | true |
fd98af4d1834c9919d02fb7ccb420803ca37a94f | Ruby | Borman8/test- | /Taks 1/sqr_triangle.rb | UTF-8 | 273 | 3.390625 | 3 | [] | no_license | puts 'Введите значение основания треугольника'
a = gets.chomp.to_i
puts 'Введите высоту треугольника'
h = gets.chomp.to_i
squad = (a * h) / 2.0
puts "Площадь треугольника равна #{squad} "
| true |
90386de1ea3e93b4ad59cfe2c54271b7495807bc | Ruby | MAXOPKA/pec_calc_client | /lib/pec_calc_client/region.rb | UTF-8 | 391 | 2.6875 | 3 | [] | no_license | module PecCalcClient
class Region
URL = 'http://pecom.ru/ru/calc/towns.php'
attr_reader :name, :towns
def initialize(name, towns)
@name = name
@towns = towns.collect { |id, name| Town.new id, name }
end
def self.all
@all = Connector.new(self::URL).request.to_hash.collect { |na... | true |
0bdf5d60f82716b213b614378b3bb539bdb7fdcd | Ruby | kennethkalmer/ratpack | /lib/ratpack/response.rb | UTF-8 | 530 | 2.71875 | 3 | [
"MIT"
] | permissive | module Ratpack
# Simple wrapper for the responses from sending methods
class Response
def initialize( message, recipients = [], error = nil )
@message = message
@recipients = recipients.to_a.flatten.compact
@error = error
end
def to_xml
xml = "<response>"
xml << "<message... | true |
717a5763857f728eb1cb2c0c1fec53fa09ad5766 | Ruby | kftwotwo/find_and-_replace | /spec/far_spec.rb | UTF-8 | 264 | 2.515625 | 3 | [] | no_license | require('rspec')
require('pry')
require('./lib/far')
describe("find the specific word and replace it") do
it("will find 'hello world' and replace 'world' with 'universe'")do
expect("hello world".far("world", "universe")).to(eq("hello universe"))
end
end
| true |
788b1e41a1032ed715f4c6eb16ea00616183eff5 | Ruby | stiak/faster_s3 | /lib/faster_s3.rb | UTF-8 | 717 | 2.640625 | 3 | [
"MIT"
] | permissive | require "faster_s3/version"
require "faster_s3/part"
require "faster_s3/download"
module FasterS3
# @param [String] destination File will be written to this destination
# @param [Hash] options
#
# @option options [String] :access_key_id The access key id for the s3 account
#
# @option options [String] :sec... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.