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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
31c129a3398471859d8734b808f18abd4bbb4b24 | Ruby | avincentLoyco/yalty-backend | /app/services/export/employee/generate_spreadsheet.rb | UTF-8 | 1,376 | 2.796875 | 3 | [] | no_license | module Export
module Employee
class GenerateSpreadsheet
pattr_initialize :account, :archive_dir_path
def self.call(account, archive_dir_path)
new(account, archive_dir_path).call
end
def call
FileUtils.touch(file_path)
attributes = Export::Account::DataBuilder.cal... | true |
a66273a0a27c454f865cdea094b2e5275c725f8b | Ruby | manleyac/ruby-poker | /tests/deck_test.rb | UTF-8 | 800 | 2.90625 | 3 | [] | no_license | require "minitest/autorun"
require_relative "../deck.rb"
require_relative "../card.rb"
class DeckTest < Minitest::Test
describe Deck do
before do
@deck = Deck.new
end
describe "#initialized" do
it "creates instances of Card" do
@deck.cards.all? { |c... | true |
c8f98433cb69c205ef534e524cf67eaafc06796a | Ruby | thekindofme/shorty | /shorty/lib/bijective_base_n.rb | UTF-8 | 645 | 3.015625 | 3 | [] | no_license | class BijectiveBaseN
# ref/sources/based on:
#
# http://ruby-doc.org/stdlib-2.0.0/libdoc/base64/rdoc/Base64.html
# http://stackoverflow.com/questions/742013/how-to-code-a-url-shortener
# https://gist.github.com/zumbojo/1073996
# http://rosettacode.org/wiki/Non-decimal_radices/Convert#Ruby
def self.enco... | true |
5f0bc97dfa46070ef47fd2ba267e28aec2c81c4f | Ruby | mronauli/market_1911 | /lib/market.rb | UTF-8 | 982 | 3.484375 | 3 | [] | no_license | class Market
attr_reader :name, :vendors
def initialize(name)
@name = name
@vendors = []
end
def add_vendor(vendor)
@vendors << vendor
end
def vendor_names
@vendors.flat_map do |vendor|
vendor.name
end
end
def vendors_that_sell(item)
@vendors.find_all do |vendor|
v... | true |
b14f5abcf66b214bec4071b3ebeb57931418c4a2 | Ruby | santiago-rodrig/coding_challenges | /valid_anagram.rb | UTF-8 | 356 | 3.671875 | 4 | [] | no_license | # challenge: https://leetcode.com/problems/valid-anagram/
# @param {String} s
# @param {String} t
# @return {Boolean}
def is_anagram(s, t)
return false if s.length != t.length
h1 = Hash.new(0)
h2 = Hash.new(0)
(0...s.length).each do |i|
h1[s[i]] += 1
h2[t[i]] += 1
end
h1.each do |k, v|
return f... | true |
9a23a3996a44a180b317dc6c09aac32e2ccc50cf | Ruby | mannut2014/Leetcode | /ruby/easy/find_anagram_mappings.rb | UTF-8 | 250 | 3.1875 | 3 | [
"MIT"
] | permissive | # @param {Integer[]} a
# @param {Integer[]} b
# @return {Integer[]}
def anagram_mappings(a, b)
map = {}
res = []
b.each_with_index do |n, i|
map[n] = i
end
a.each do |n|
res.push(map[n])
end
return res
end
| true |
469b03eb708cdc7f6e068e70afc46b70c53fe561 | Ruby | dustMason/exercism | /ruby/pangram/pangram.rb | UTF-8 | 202 | 2.859375 | 3 | [] | no_license | module BookKeeping
VERSION = 4
end
require 'set'
class Pangram
def self.pangram? sentence
letters = ("a".."z").to_set
letters.subtract sentence.downcase.chars
letters.empty?
end
end
| true |
bd1f317fa05157dff35f54cd2e99aa5fc66cc0a8 | Ruby | andrewroycarter/WebAlert | /webalert.rb | UTF-8 | 1,936 | 2.625 | 3 | [] | no_license | require 'rubygems'
require 'sms_fu'
require 'yaml'
require 'digest/md5'
require 'open-uri'
# The new YAML parser won't handle the @ symbols sms_fu.yml uses
YAML::ENGINE.yamler = 'syck'
@config = YAML::load(File.open('config.yml'))
def write_digest(digest)
File.open('snapshot', 'w') { |f| f.write(digest)}
end
def ... | true |
6297e1615a1d9829900d674c3a38c2d5288321c8 | Ruby | aka-mo/ddmerukari | /spec/models/user_spec.rb | UTF-8 | 2,867 | 2.5625 | 3 | [] | no_license | require 'rails_helper'
describe User do
describe '#create' do
it "is valid with a nickname, email, password, password_confirmation, first_name, last_name, first_name_kana, last_name_kana, birth_year, birth_month, birth_day" do
user = build(:user)
expect(user).to be_valid
end
it "is invali... | true |
e01dc9f5005c76f8e46f2e7223b7164b9767d482 | Ruby | taichi-sato36/dmm-lessons | /Ruby/ruby-confirmation_problem/lesson7.rb | UTF-8 | 613 | 3.90625 | 4 | [] | no_license | puts "計算を始めます"
puts "2つの値を入力してください"
a = gets.to_i
b = gets.to_i
puts "計算結果を出力します"
puts "a*b= #{a*b}"
puts "計算を終了します"
puts "計算をはじめます"
puts "何回繰り返しますか?"
any = gets.to_i
i = 0
while i do
if i == any
break
end
puts "#{i+1}回目の計算"
puts "2つの値を入力してください"
a = gets.to_i
b = gets.to_i
puts "a = #{a}"
puts "b = #{b}"
puts "計算... | true |
6f6a9808a67b520801bac65963fd4f7384920b1e | Ruby | healthypackrat/edupa-math-vlc | /lib/format_helper.rb | UTF-8 | 212 | 2.796875 | 3 | [] | no_license | module FormatHelper
def hms(sec)
min, sec = sec.divmod(60)
hour, min = min.divmod(60)
if hour.zero?
'%02d:%02d' % [min, sec]
else
'%d:%02d:%02d' % [hour, min, sec]
end
end
end
| true |
fe6a26bbd53bfa63b467e0ebc334a397a3c6a158 | Ruby | JeffreyMJordan/W2D4 | /two_sum.rb | UTF-8 | 839 | 3.625 | 4 | [] | no_license | require 'byebug'
require 'set'
def brute_force(arr, target)
arr.each_with_index do |el, idx|
second_idx = idx+1
while second_idx<arr.length
return true if el+arr[second_idx]==target
second_idx += 1
end
end
false
end
def okay_two_sum?(arr, target)
arr = arr.sort
arr.each do |el|
... | true |
7753b633546c54e3094b89ea23acc0420575b80f | Ruby | PhilThom85/parrot_tn | /lib/google/google_translate.rb | UTF-8 | 3,345 | 2.703125 | 3 | [] | no_license | require 'rubygems'
require 'mechanize'
# Google translator utility
module Google
# Manage google translation and access to webserver
class Translate < Mechanize
# List conversion code from google result for several languages
LANG = { :bg => { :in => 'iso-8859-5', :out => 'utf-8', :lang => 'Bulgarian' },
... | true |
729efc367454efac7c2322c356427aaf1389a6eb | Ruby | brianmichel/muzak.me | /lib/models/genre.rb | UTF-8 | 278 | 2.5625 | 3 | [] | no_license | class Genre < ActiveRecord::Base
has_many :songs
def self.songs(args = {})
genres = Genre.all
genres = genres.where(:mood => args[:mood]) if args[:mood]
genres = genres.where(:style => args[:style]) if args[:style]
genres.songs
end
end
| true |
b4402e974d0fd0148a150c0312f9329ccd140d47 | Ruby | apesoncode/slidr | /lib/slidr/commands/slide_command.rb | UTF-8 | 844 | 2.6875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | require 'slidr/commands/base_command'
module Slidr
module Commands
class SlideCommand < BaseCommand
def initialize(pattern, slides, filters={})
@pattern = pattern
@slides = slides
@publish = filters[:publish]
@draft = filters[:draft]
end
def go(content)
... | true |
ce295eb1f003cbb23e01a74be4abfd1786cc8670 | Ruby | trizen/corvinus2 | /scripts/Introducere/Suma cifrelor.cv | UTF-8 | 158 | 2.828125 | 3 | [
"Artistic-2.0"
] | permissive | #!/usr/bin/ruby
var numar = 1234
var suma = 0
cat_timp (numar > 0) {
suma += (numar % 10)
numar = intreg(numar / 10)
}
spune ("Suma este: ", suma)
| true |
8eb56b4656779de4c9de305c8b958369b71fc84c | Ruby | malditogeek/redisrecord | /spec/basic_spec.rb | UTF-8 | 1,685 | 2.65625 | 3 | [
"MIT"
] | permissive | require File.dirname(__FILE__) + '/spec_helper'
describe "RedisRecord" do
before(:each) do
@c = Customer.new
end
after do
r = Redis.new
#r.select_db 15
r.flush_db
end
it "should allow to add any attribute to an instance" do
@c.name = 'foo'
@c.age = 25
@c.name.should == 'foo'
... | true |
f46eb9497b8bdbd67e306116f58d1f2aa6ac4f81 | Ruby | YasminM11/dynamic-programming | /lib/max_subarray.rb | UTF-8 | 770 | 3.828125 | 4 | [
"MIT"
] | permissive |
# Time Complexity: o(n)
# Space Complexity: o(1)
def max_sub_array(nums)
return 0 if nums == nil
# raise NotImplementedError, "Method not implemented yet!"
max_so_far = nums[0]
max_ending_here = 0
nums.each do |num|
max_ending_here = max_ending_here + num
if max_ending_here < num
max_ending... | true |
c7c656252ad62c484fee17fa9e9d0553e6647a35 | Ruby | anglinchristina/interpolation-super-power-ruby-intro-000 | /lib/display_rainbow.rb | UTF-8 | 687 | 4.03125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Write your #display_rainbow method here
=begin #First attempt
def display_rainbow(color_array)
i=0
print "R: #{color_array[i]}, "
i+=1
print "O: #{color_array[i]}, "
i+=1
print "Y: #{color_array[i]}, "
i+=1
print "G: #{color_array[i]}, "
i+=1
print "B: #{color_array[i]}, "
i+=1
print "I: #{co... | true |
297c6c9fdd016263f43a690f768c338ee9e4632d | Ruby | cinthyabrito80/challenge | /qa-test/Creditas_Cintia_Brito/features/step_definitions/login1_step.rb | UTF-8 | 1,573 | 2.734375 | 3 | [] | no_license | #Foi feito duas funcionalidade da tela de login, essa é a opção 1 com mais informações
Dado("que estou na pagina principal") do
pending # Write code here that turns the phrase above into concrete actions
end
Quando("coloco um email cadastrado") do
pending # Write code here that turns the phrase above into concret... | true |
1551b056e6a3843b966d75762f3a3ddbdca77c44 | Ruby | oorja/ce-challenges | /easy/juggling_with_zeros.rb | UTF-8 | 188 | 2.921875 | 3 | [
"BSD-3-Clause"
] | permissive | File.open(ARGV[0]).each_line do |line|
r, s = 0, line.chomp.split.map(&:length)
(s.length/2).times do |i|
r *= 2**s[i*2+1]
r += 2**s[i*2+1]-1 if s[i*2] == 2
end
puts r
end
| true |
5e2cc2baaab70c0bfbf9abcfef73cb2573bb7e22 | Ruby | ihollander/collections_practice-nyc-web-100818 | /collections_practice.rb | UTF-8 | 837 | 3.859375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def sort_array_asc(array)
array.sort{|a,b|
a <=> b
}
end
def sort_array_desc(array)
array.sort{|a,b|
b <=> a
}
end
def sort_array_char_count(array)
array.sort{|a,b|
a.length <=> b.length
}
end
def swap_elements_from_to(array,index,destination)
swap = array[index]
array[index] = array[dest... | true |
6f6042b6177104396cb0b50bf5ee67a746e7539d | Ruby | DalavanCloud/zpng | /spec/image_spec.rb | UTF-8 | 1,407 | 2.546875 | 3 | [
"MIT"
] | permissive | require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
NEW_IMG_WIDTH = 20
NEW_IMG_HEIGHT = 10
describe ZPNG::Image do
describe "new" do
let!(:img){ ZPNG::Image.new :width => NEW_IMG_WIDTH, :height => NEW_IMG_HEIGHT }
it "returns ZPNG::Image" do
img.should be_instance_of(ZPNG::Image)
e... | true |
f7b10330dc02f81f56cccc229f331a3e371056df | Ruby | sneeu-leeu/OOP-Bookstore | /spec/rental_spec.rb | UTF-8 | 1,670 | 3.203125 | 3 | [
"MIT"
] | permissive | require_relative 'required_files'
describe Rental do
describe '#instance' do
classroom = Classroom.new('Math')
student = Student.new(age: 17, name: 'Ana', classroom: classroom)
teacher = Teacher.new(age: 50, name: 'Jim', specialization: 'English')
book = Book.new('Harry Potter', 'J.K. Rowling')
... | true |
d27632e307200bdf652dd2fc1b997c80faa2d097 | Ruby | Wonderlux-Labs/confessional_booth | /lib/confessional.rb | UTF-8 | 3,161 | 2.859375 | 3 | [] | no_license | require 'rubygems'
require 'wisper'
require 'piface'
require 'pry'
require_relative 'controllers_and_functions'
require_relative 'event_commanders'
PHONE_HOOK_SWITCH = 5
DIALER_SWITCH = 6
PULSE_SWITCH = 7
PROGRAM_DIR = File.expand_path(File.join(File.dirname(__FILE__), '../'))
# Main runner object
class EventDispatch... | true |
dd89c5b6bc6d0db23f5d4d82ad1c665e5f1a7768 | Ruby | anbupro/chessdb | /lib/repository.rb | UTF-8 | 6,884 | 2.578125 | 3 | [] | no_license | require 'yaml'
require 'sequel'
require 'logger'
# Repository for database access
class Repository
def initialize(config)
@db = Sequel.connect(adapter: 'postgres', **config.database[:development])
@db.loggers = [Logger.new($stdout)]
end
def game(id:)
@db[:games].where(id: id).first
end
def move... | true |
8a11f894f6180499655b2e9e532051d58c6b3edd | Ruby | bocalo/ruby_projects | /Taxi/lib/taxi_station.rb | UTF-8 | 1,539 | 2.84375 | 3 | [] | no_license | # require_relative "cars_collection"
# require_relative "driver_collection"
# require_relative "order_collection"
require_relative "base_collection"
require_relative "current_taxis_collection"
class TaxiStation
attr_reader :orders_collection, :cars_collection, :drivers_collection, :current_taxis_collection
def in... | true |
4c670074a127718628651b65217de365d47d7f11 | Ruby | sulababa001/rb100_ch_7_hashes | /family_1.rb | UTF-8 | 463 | 3.71875 | 4 | [] | no_license | # Use Ruby's in-built select method to gather only immediate family members' names into
# a new array.
family = { uncles: ["bob", "joe", "steve"],
sisters: ["jane", "jill", "beth"],
brothers: ["frank", "rob", "david"],
aunts: ["mary", "sally", "susan"]}
immediate_family = famil... | true |
8f1c873c7a815bfdb45efc38d9b87c1f030839c5 | Ruby | zygzagZ/rbelftools | /lib/elftools/elf_file.rb | UTF-8 | 15,366 | 2.8125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'elftools/constants'
require 'elftools/exceptions'
require 'elftools/lazy_array'
require 'elftools/sections/sections'
require 'elftools/segments/segments'
require 'elftools/structs'
module ELFTools
# The main class for using elftools.
class ELFFile
attr_reader :stream # @... | true |
744b3d2b72be3ef8849e6f8e4211892e92d2dc8c | Ruby | tomasotosolini/p0002 | /test/t02_views_render.rb | UTF-8 | 2,096 | 2.78125 | 3 | [
"MIT"
] | permissive | #
# StHtml
#
# Il presente file fa parte del progetto StHtml che viene distribuito
# secondo le clausole della licenza MIT. Nella directory base(root) del
# progetto è presente una copia della licenza.
#
# For non italian speakers, please be able to translate into your native
# language the license ... | true |
b86b2e97aec03135d240f5830adddce8de7c12b1 | Ruby | YoheiEguchi/furima-35429 | /spec/models/item_spec.rb | UTF-8 | 4,615 | 2.515625 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe Item, type: :model do
describe '#create' do
before do
@item = FactoryBot.build(:item)
end
context '商品出品ができる時' do
it '全ての値(:item_name, :item_text, :category_id, :condition_id, :shipping_charge_id, :shipping_area_id, :day_to_ship_id, :price, :image, :user_... | true |
8c001ce84f11c32057c1c4e48858c6ade946acfd | Ruby | TheMetalCode/jenkins-ruby-scripts | /jenkins_hipchat_notifier.rb | UTF-8 | 3,077 | 2.984375 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'rubygems'
require 'getopt/long'
require 'yaml'
opt = Getopt::Long.getopts(
["--job_name", "-j", Getopt::REQUIRED],
["--build_url", "-b", Getopt::REQUIRED],
["--job_status", "-s", Getopt::REQUIRED],
["--last_committer", "-c", Getopt::OPTIONAL],
["--hipchat_token", "-t", Getopt::RE... | true |
063e063088358853606190bdda494db927866bf6 | Ruby | ddzz/ruby-challenge | /lib/ruby_challenge.rb | UTF-8 | 758 | 3.53125 | 4 | [] | no_license | class RubyChallenge
def initialize
@paths = []
file = File.open(File.dirname(__FILE__) + "/support/paths2.txt").read
file.each_line do |line|
new_line = line.chomp.split(",")
if new_line.length > 3
@paths << new_line
end
end
end
def find_most_common_path
new_arr = []... | true |
9c0f6d3fa4f309458bf08af493ec8ae39f1a234b | Ruby | flippyhead/linked_in | /lib/linked_in/request.rb | UTF-8 | 2,334 | 2.671875 | 3 | [
"MIT"
] | permissive | module LinkedIn
class Request
extend Forwardable
def self.get(client, path, options = {})
new(client, :get, path, options).perform
end
def self.post(client, path, options = {})
new(client, :post, path, options).perform
end
def self.put(client, path, options = {})
... | true |
7b2a6fd2f60e0cbf20a833e09bdc00609459343e | Ruby | Kay-Lander/ruby_august_2017 | /keith_sanders/OOP/project.rb | UTF-8 | 359 | 3.359375 | 3 | [] | no_license | class Project
attr_reader :name
attr_reader :description
def initialize(name, description)
@name = name
@description = desc
end
def elevator_pitch
return "#{@name}", "#{@description}"
end
end
project1 = Project.new("CodeMaster", "Being a Boss at programming!")
puts proj... | true |
1bae488fda798afeb785bd20ddb9a43af344196d | Ruby | mocchi0420/project-euler | /euler046.rb | UTF-8 | 1,040 | 3.359375 | 3 | [] | no_license | # coding: utf-8
# Problem 46 「もうひとつのゴールドバッハの予想」
#
# 簡単な方針
#
# 最小の奇数の合成数であるn=9からスタートして、以下のアルゴリズムを試す
# (1)nが素数であるか偶数である場合、処理をすっ飛ばして次に行く
# (2)nが奇数の合成数である場合、1<=k<=√((n-3)/2)までを対象としてn - 2*k**2が素数かどうかをジャッジする。
# (3)kの値域にn - 2*k**2を素数にする数値が1つでも存在していたらbreakして次の数をさがす。
# (4)もしもkの値域にn - 2*k**2を素数にする数値が1つもなかったら、それが今回探すべきnなのでそれを出力... | true |
4c8c7f1be0e72e775e4e9692f8e2cd03a3ad86a5 | Ruby | thib123/TPJ | /Notes/Ruby/sample_code/ex0325.rb | UTF-8 | 371 | 3.5 | 4 | [
"MIT"
] | permissive | # Sample code from Programing Ruby, page 136
require 'monitor'
class Counter
attr_reader :count
def initialize
@count = 0
end
def tick
@count += 1
end
end
c = Counter.new
lock = Monitor.new
t1 = Thread.new { 10000.times { lock.synchronize { c.tick } } }
t2 = Thread.new { 10000.times { lock.synchron... | true |
0c710c16d0ac728f2ed3bb9e282f803bc71aa773 | Ruby | Nazib3/ttt-game-status-cb-gh-000 | /lib/game_status.rb | UTF-8 | 1,367 | 3.859375 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # Helper Method
def position_taken?(board, index)
!(board[index].nil? || board[index] == " ")
end
# Define your WIN_COMBINATIONS constant
WIN_COMBINATIONS = [
[0, 1, 2], # Top rows
[3, 4, 5], # Middle rows
[6, 7, 8],
[0, 3, 6],
[1, 4, 7],
[2, 5, 8],
[0, 4, 8],
[2, 4, 6]
# ETC, an array for each ... | true |
5ee1373ad3c6ca5d265c7e91969a888fef323098 | Ruby | julioalucero/equal_to | /lib/image_processing.rb | UTF-8 | 355 | 2.8125 | 3 | [] | no_license | module ImageProcessing
def sum_2_images(image_one, image_two, result_path, geometry)
first_image = MiniMagick::Image.open(image_one.current_path)
equal_to = MiniMagick::Image.open(image_two)
result = equal_to.composite(first_image) do |i|
i.compose 'atop'
i.geometry geometry
end
... | true |
5a63fa09a4dc80ad906db3419b949d9f51a250e2 | Ruby | mgheith/calculator | /features/step_definitions/calculator_subtraction_steps.rb | UTF-8 | 802 | 3.390625 | 3 | [
"MIT"
] | permissive | When /^I subtract 2 integers$/ do
@sub = Calculator.new.sub(8, 5)
end
Then /^an integer is returned$/ do
expect(@sub).to be_an Integer
end
When /^I subtract the 2 integers$/ do
@sub = Calculator.new.sub(8, 5)
end
Then /^the first number is subtracted by the second$/ do
expect(@sub).to eq 3
end
... | true |
b6d9cd2eaddb8f83f7e10c5905a649644bfc9aa7 | Ruby | yasyars/yabb-gigih | /Modul 6/session-3/data_class.rb | UTF-8 | 289 | 3.25 | 3 | [] | no_license | def average_income_in(date_range)
total_days = (date_range.end_date - date_range.start_date).to_i
total_income / total_days
end
class date_range
attr_reader :start_date, :end_date
def initialize(start_date,end_date)
@start_date = start_date
@end_date = end_date
end
end | true |
c045a9eb4ad62e63f16ccd13976eabeda80d6f6e | Ruby | mmmries/rrobots | /lib/rrobots/numeric.rb | UTF-8 | 284 | 3.0625 | 3 | [] | no_license | ##
# Numeric extensions for rrobots.
class Numeric
TO_RAD = Math::PI / 180.0 # :nodoc:
TO_DEG = 180.0 / Math::PI # :nodoc:
##
# Convert degrees to radians.
def to_rad
self * TO_RAD
end
##
# Convert radians to degrees.
def to_deg
self * TO_DEG
end
end
| true |
3a372b0ffdc99ef7a5c8280a6b20f82549066038 | Ruby | svobom57/log_parser | /bin/parse_logs | UTF-8 | 495 | 2.703125 | 3 | [] | no_license | #! /usr/bin/env ruby
abort 'Please supply path to log file' if ARGV.length.zero?
require_relative '../lib/log_parser'
log_path = ARGV.first
log_path = if log_path[0] == '/'
log_path
else
File.expand_path(File.join(File.dirname(__FILE__), '..', log_path))
end
parser = ... | true |
1109a74013a4da158694b46fc49ef8f793b302ba | Ruby | deliveroo/ravelin-ruby | /lib/ravelin/payment_methods.rb | UTF-8 | 276 | 2.546875 | 3 | [
"MIT"
] | permissive | module Ravelin
class PaymentMethods < RavelinObject
attr_reader :methods
def initialize(methods)
@methods = methods.map { |method| Ravelin::PaymentMethod.new method }
end
def serializable_hash
methods.map(&:serializable_hash)
end
end
end
| true |
276c19205c306648e9937377db7e51f2acff94ac | Ruby | jimmy2/launchschool_101_programming_fundamentals | /101_109_small_problems/medium_2/exercise_05.rb | UTF-8 | 1,559 | 4.4375 | 4 | [] | no_license | # 101-109 - Small Problems > Medium 2 > Triangle Sides
# A triangle is classified as follows:
# - equilateral All 3 sides are of equal length
# - isosceles 2 sides are of equal length, while the 3rd is different
# - scalene All 3 sides are of different length
# To be a valid triangle, the sum of the lengths of the t... | true |
fa118db9abae4412055554c166503c965ba2c410 | Ruby | triedman99/assignment_ruby_warmup | /dice_outcomes.rb | UTF-8 | 255 | 3.375 | 3 | [] | no_license | def dice_outcomes(dice=1, rolls=1)
counts = Hash.new(0)
rolls.times do
counts[rand(dice..6*dice)] += 1
end
counts = counts.to_a.sort
counts.each do |key, value|
puts "#{key}:".ljust(4) + "#{'#' * value}"
end
end
dice_outcomes(3, 100) | true |
22cbb1616759d480d6103a89e893e29560b9a4ad | Ruby | ranizilpelwar/TicTacToeRuby | /TicTacToeRuby.Core.UnitTests/Validators/tc_tie_game_validation.rb | UTF-8 | 1,389 | 3.046875 | 3 | [] | no_license | require 'test/unit'
require_relative '../../TicTacToeRuby.Core/Validators/tie_game_validator.rb'
require_relative '../../TicTacToeRuby.Core/GamePlay/game_board.rb'
require_relative '../../TicTacToeRuby.Core/Exceptions/nil_reference_error.rb'
class TestTieGameValidation < Test::Unit::TestCase
def test_tie_game_raises... | true |
b778a26a5a6c3ff68e0d84f7b593ea4392f940ff | Ruby | jonathanhds/petals-around-the-rose | /lib/algorithms.rb | UTF-8 | 305 | 3.296875 | 3 | [] | no_license | class DoubleLast
def execute(die)
die[4] * 2
end
end
class AlwaysFirst
def execute(die)
die[0]
end
end
class PowMiddle
def execute(die)
die[2] * die[2]
end
end
class AnyAnswer
def execute(die)
result = Object.new
def result.==(comparison_object)
true
end
result
end
end | true |
51842fe8a828efee569b0cafccdf6e75acffb62c | Ruby | JeffreyMJordan/W4D5 | /music_app/app/models/user.rb | UTF-8 | 877 | 2.65625 | 3 | [] | no_license | require 'bcrypt'
class User < ApplicationRecord
validates :email, :password_digest, presence: true
after_initialize :ensure_session_token
attr_reader :password
def password=(password)
@password = password
self.password_digest = BCrypt::Password.create(password)
end
def reset_session_token
se... | true |
cd53798d442dc23e526774ea592b743af1b704ee | Ruby | hiyamamo/konki-anime | /app/helpers/application_helper.rb | UTF-8 | 425 | 2.734375 | 3 | [] | no_license | require 'open-uri'
require 'json'
module ApplicationHelper
def programs(season, sort = nil)
season.programs_with_rank(sort)
end
# ページ毎のタイトルを返す
def full_title(title)
base_title = "今期アニメ"
if title.empty?
base_title
else
"#{base_title} | #{title}"
end
end
def strftime(time)
if time.blank?
... | true |
58ff59630ee1f14f7229057004b1d8b10d011a11 | Ruby | tianyuduan/algorithms | /algpractice4.rb | UTF-8 | 934 | 3.578125 | 4 | [] | no_license | Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.
An input string is valid if:
Open brackets must be closed by the same type of brackets.
Open brackets must be closed in the correct order.
Note that an empty string is also considered valid.
Example 1:... | true |
0f27b744f1140e2207285f920418a67eb1385861 | Ruby | NickTerrafranca/movie_index | /server.rb | UTF-8 | 876 | 3.0625 | 3 | [] | no_license | require 'sinatra'
require 'csv'
MOVIES = 'public/movies.csv'
def read_movie_data(file_name)
movies = []
CSV.foreach(file_name, headers: true, header_converters: :symbol) do |row|
movies << row.to_hash
end
movies.sort_by { |movie| movie[:title] }
end
def parse_movie_titles(file_name)
movie_title = []
f... | true |
e8d4216ff7bfc66e6181b185108fc47c718f82bb | Ruby | tdtds/kindlizer | /cropbox.rb | UTF-8 | 535 | 2.90625 | 3 | [] | no_license | #!/usr/bin/env ruby
#
# cropbox.rb: trim white spaces in (non image) PDF file by changing CropBox
#
# usage: cropbox.rb source.pdf > out.pdf
#
# ADJUST FOR EACH PDF FILES
# left, bottom, right, top
OFFSET = [60, 50, -60, -70]
print( ARGF.read.force_encoding( 'ASCII-8BIT' ).gsub( %r|(/CropBox\s*\[\s*([^\[]+?)\])| ) do... | true |
7dd5ce43261866d303081b831ff9992c08c4c6b6 | Ruby | Jaymon/chef-cookbooks | /postgres/libraries/postgres_helper.rb | UTF-8 | 14,702 | 2.71875 | 3 | [
"MIT"
] | permissive | # https://docs.chef.io/libraries.html
# https://blog.chef.io/2014/03/12/writing-libraries-in-chef-cookbooks/
include ::Chef::Mixin::ShellOut
module PostgresHelper
# handles reading/writing the pg_hba.conf file
class PostgresHba
attr_reader :path
def initialize(version)
@path = Postgres.get_hba_... | true |
b80596cd5fd5db26cda3f855d8254cd5a1fde79a | Ruby | Hetano-Yokozuki/rg-exam | /chap3/310proc/t10.rb | UTF-8 | 91 | 3.09375 | 3 | [] | no_license | def test x
Proc.new{|y| x/y}
end
z = test(200)
p z.call(1)
p z.call(10)
p z.call(100)
| true |
d8eb1ce6fd2ec2921c87d6c4b4a70cd1c45a34ba | Ruby | sirbikealot/regex-golf | /regex_golf_data.rb | UTF-8 | 1,821 | 3.5625 | 4 | [] | no_license | # regex_golf_data.rb
WELCOME = <<-TEXT
Hello, and thank you for using my regex_golf tool.
If you've played Regex Golf <regex.golf.au> you've probably found yourself
testing different Regexps in a REPL. You have to type in all the "to match"
and "to reject" words. This tool does that work for you.
After verifying... | true |
1786b3b05dd4403d3fe1b2662f90210c89c24e75 | Ruby | eebbesen/minutes_maid | /vendor/cache/ruby/2.5.0/gems/mail-2.7.1/lib/mail/fields/content_type_field.rb | UTF-8 | 4,906 | 2.625 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
# frozen_string_literal: true
require 'mail/fields/common/parameter_hash'
module Mail
class ContentTypeField < StructuredField
FIELD_NAME = 'content-type'
CAPITALIZED_FIELD = 'Content-Type'
def initialize(value = nil, charset = 'utf-8')
self.charset = charset
if value.clas... | true |
fba833ee94a2cf397585845ce813252f80ccaa13 | Ruby | SethPerna/backend_mod_1_prework | /section4/exercises/good_dog3.rb | UTF-8 | 1,231 | 4 | 4 | [] | no_license | class GoodDog
attr_accessor :name, :height, :weight
def initialize(n, h, w)
@name = n
@height = h
@weight = w
end
def speak
"#{name} says arf!"
end
def change_info(n, h, w)
@name = n
@height = h
@weight = w
end
def info
"#{name} weighs #{weight} and is #{height} tall.... | true |
4a2bf2672955b553585738784998dd5cb5feab34 | Ruby | 2009IE04/errs | /db/Purchase_description_import.rb | UTF-8 | 370 | 2.578125 | 3 | [] | no_license | arr = Array.new
PurchaseDescription.transaction do
File.open("data/Purchases_description.csv").each_line do |line|
line = line.strip
arr = line.split(",")
#0:id 1:supplier_id 2:purchase_date 3:arrival_date
p = PurchaseDescription.new
p.purchase_id = arr[0]
p.product_id = arr[1]
p.quantity ... | true |
fe6f674bda323c6c22129c1578db2fa5ae687e63 | Ruby | dmitrysharkov/calculable_attrs | /lib/calculable_attrs/model_calculable_attrs_scope.rb | UTF-8 | 1,473 | 2.765625 | 3 | [
"MIT"
] | permissive | class CalculableAttrs::ModelCalculableAttrsScope
attr_reader :model, :ids, :attrs
def initialize(model)
@model = model
@attrs = []
@ids = []
end
def add_attrs(attrs)
if attrs == true || attrs == [ true ]
add_all_attrs
else
attrs.each { |attr| add_attr(attr) }
end
end
d... | true |
9af58d41e70f9afe9d12a2b8c83d922325044ecb | Ruby | veralizeth/array-string-practice | /lib/practice_exercises.rb | UTF-8 | 1,172 | 3.78125 | 4 | [] | no_license |
# Time Complexity: O(n) -> It runs (n = string.lenght) times depends on the string length.
# Space Complexity: O(1) -> Constant variables.
def is_palindrome(string)
# raise NotImplementedError, "Not implemented yet"
string = string.downcase
string = string.gsub(/[\s,:;]/ ,"")
i = 0
j = string.length - 1... | true |
9f8d92aff0e904d2f7d107ecd87023ac4dc9a8fd | Ruby | anchor8/RMS-Application | /app/models/product.rb | UTF-8 | 952 | 2.609375 | 3 | [] | no_license | # Product Model
class Product < ApplicationRecord
# Relationships
has_many :order_lines
# Validations
validates :product_name, allow_blank: false, presence: true
validates :price, allow_blank: false, presence: true, :numericality => true, :format => { :with => /\A^\d{1,10}(\.\d{0,2})?$\z/, :message => "Only ... | true |
ed57efb815cef1c6bb17ffce5caff79c33e69f5d | Ruby | TheCraftedGem/sweater_weather | /app/services/giphy_service.rb | UTF-8 | 457 | 2.5625 | 3 | [] | no_license | class GiphyService
def initialize(summary)
@summary = summary.gsub(' ', '+').gsub('.', '')
@conn = Faraday.new(url: 'https://api.giphy.com') do |faraday|
faraday.headers["api_key"] = ENV["GIPHY_KEY"]
faraday.adapter Faraday.default_adapter
end
end
def search
get_url("/v1/gifs/sear... | true |
b8b13c3da6f468ab196ab6209d5b8a9062ce4fe0 | Ruby | adamjweil/phase-0-tracks | /ruby/shout.rb | UTF-8 | 632 | 3.75 | 4 | [] | no_license | module Shout
def yell_angrily(words)
puts "#{words}, grrr!!! :("
end
def yelling_happily(words)
puts "#{words}! Woo Hoooo! ;-)"
end
end
class Animals
include Shout
end
class Zombies
include Shout
end
# ------>DRIVER CODE<-------
# --->Release: 2<-----------
# p Shout.yelling_happily("yayyyy")
# p Shou... | true |
05ec8aae2e07529ab1bf475343183f57380455d8 | Ruby | waldoswify93/bolt-3 | /lib/bolt/module_installer.rb | UTF-8 | 6,203 | 2.53125 | 3 | [
"Apache-2.0"
] | permissive | # frozen_string_literal: true
require 'bolt/error'
require 'bolt/logger'
module Bolt
class ModuleInstaller
def initialize(outputter, pal)
@outputter = outputter
@pal = pal
@logger = Bolt::Logger.logger(self)
end
# Adds a single module to the project.
#
def add(name, m... | true |
bd5e6e73bcb7b68d390f932990ef0aa47d4a4816 | Ruby | QuantiModo/quantimodo-sdk-ruby | /lib/swagger_client/api/variable_user_source_api.rb | UTF-8 | 12,750 | 2.5625 | 3 | [
"Apache-2.0"
] | permissive | require "uri"
module SwaggerClient
class VariableUserSourceApi
attr_accessor :api_client
def initialize(api_client = nil)
@api_client = api_client || Configuration.api_client
end
# Get all VariableUserSources
# Get all VariableUserSources
# @param [Hash] opts the optional parameters
... | true |
3084733d47254aaa25b1c4352c2a5eca0a7f086b | Ruby | alexbtlv/tic_tac_toe | /spec/board.rb | UTF-8 | 3,280 | 3.46875 | 3 | [
"MIT"
] | permissive | require "spec_helper"
module TicTacToe
describe Board do
context "#initialize" do
it "initilizes the board with a grid" do
expect{ Board.new(grid: "grid") }.to_not raise_error
end
it "sets the grid with three rows by default" do
board = Board.new
expect(board.grid.size).to eq(3)
end
... | true |
97f47e547bbcf3edcc388abad84ef32c33edee2b | Ruby | binarydrew/seatyourself | /app/controllers/restaurants_controller.rb | UTF-8 | 2,363 | 2.703125 | 3 | [] | no_license | class RestaurantsController < ApplicationController
before_filter :ensure_logged_in, only: [:new, :create, :edit, :update, :destroy]
def index
@title = "Restaurants"
@restaurants = Restaurant.all
end
def show
@restaurant = Restaurant.find(params[:id])
end
def create
@restaurant = Restau... | true |
3832e3d17de4acb942db7f299810a94d48eba1ef | Ruby | Eileenandrea/Everyday | /test/models/user_test.rb | UTF-8 | 1,185 | 2.765625 | 3 | [] | no_license | require "test_helper"
class UserTest < ActiveSupport::TestCase
def setup
@user = User.new(firstname: 'Juan', lastname: 'Cruz', username: 'juan.cruz', email: 'juan@email.com', password: 'password')
end
test 'valid user' do
assert @user.valid?
end
test 'should not save User without firstname' do
... | true |
3095ffd0c4b6e864947ae0dec4b31d5a1ec0c28f | Ruby | RubyCamp/rc2016w_g1 | /rubycamp1g/sunshine.rb | UTF-8 | 1,263 | 3.5625 | 4 | [] | no_license | # coding: utf-8
=begin
太陽に関するクラスである。
メソッド update はセンサの状態を読取り、認知回数を更新する。
メソッド statue は指定の値を超えた時 true を返し、認知回数を初期化する。
メソッド draw は太陽を描写する。
=end
class Sunshine
SENSER_UPPER = 300
SENSER_DOWNER = 225
SLEEP_TIME = 0.1
RECOG_COUNT = 100 # ゲームバランス調整可能
SUN_X = 352
SUN_Y = -16
def initialize
@senser = 0
... | true |
6dcb9e10f506e8e1960a7fd8fbd5e58e4cdfef10 | Ruby | bokor/shelter-exchange | /spec/models/status_history_spec.rb | UTF-8 | 6,971 | 2.65625 | 3 | [] | no_license | require "rails_helper"
describe StatusHistory do
it "has a default scope" do
expect(StatusHistory.scoped.to_sql).to eq(StatusHistory.order('status_histories.status_date DESC, status_histories.created_at DESC').to_sql)
end
end
# Class Methods
#-----------------------------------------------------------------... | true |
d77758908ae7968b15ec7503ae57d32d50087f92 | Ruby | oxenprogrammer/Enumerable_Methods | /lib/enumerable_method.rb | UTF-8 | 4,463 | 3.203125 | 3 | [] | no_license | # This is our custom fake enumerables
module Enumerable
# my_each
def my_each(&block)
return enum_for(:my_each) unless block_given?
for item in self
block.call item
end
self
end
# my_each_with_index
def my_each_with_index
return to_enum(:my_each_with_index) unless block_given?
... | true |
25c012f3dcc26b3e92dc4c508d1b05436b1560ad | Ruby | C-Mike576/sql-crowdfunding-lab-online-web-ft-110419 | /lib/sql_queries.rb | UTF-8 | 1,661 | 3.125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Write your sql queries in this file in the appropriate method like the example below:
#
# def select_category_from_projects
# "SELECT category FROM projects;"
# end
# Make sure each ruby method returns a string containing a valid SQL statement.
def selects_the_titles_of_all_projects_and_their_pledge_amounts_alphabe... | true |
733e67e5cf0e094d3fb6f327234e67d670e344ef | Ruby | bgreg/ruby_security | /async_last.rb | UTF-8 | 993 | 2.71875 | 3 | [] | no_license | def async_last_only(&block)
# establish a mutually exclusive section for the main logic of this class.
@last_only_sync_queue.async {
@counter_queue.async { # NOTE ?? looks broken.
self.increment
pe_debug "#{self} queue count incremented to #{self.counter}"
# queue block o... | true |
c146b9e48d6f4b23d120e84a63d0c7bff6318237 | Ruby | zagpro1408/tasks | /29.rb | UTF-8 | 184 | 2.875 | 3 | [] | no_license | # Дан целочисленный массив.
# Упорядочить его по возрастанию.
srand 123
array = Array.new(20) { rand -100..100 }
array.sort!
p array
| true |
27ef895e5f6674217cecac11a637db0ba195466a | Ruby | crievinator/ls_rb101_programming_foundations | /small_problems/easy_3/palindrome.rb | UTF-8 | 437 | 3.5625 | 4 | [] | no_license | def real_palindrome?(string)
string.gsub!(/[^a-zA-Z0-9]/,'')
string.downcase == string.downcase.reverse
end
p real_palindrome?('madam') == true
p real_palindrome?('Madam') == true # (case does not matter)
p real_palindrome?("Madam, I'm Adam") == true # (only alphanumerics matter)
p real_palindrome?('3566... | true |
b38c0d6aea4fb679ea0a05b3e55136fc217f2dac | Ruby | Brendao1/debugging-two | /week-2/extracting_a_class/solution/spec/motor_spec.rb | UTF-8 | 677 | 3.0625 | 3 | [] | no_license | require 'motor'
RSpec.describe Motor do
let(:top_speed) { 80 }
subject(:motor) { described_class.new(top_speed) }
describe '#accelerate' do
it 'increases speed' do
expect { motor.accelerate(1, 15) }.to change { motor.speed }.by(15)
end
it 'does not go over top speed' do
motor.accelerate... | true |
fd94ff31b82e79e926b97fc6f48f879ff693fd2e | Ruby | nickitza/ruby_casino | /classes/hangman.rb | UTF-8 | 5,993 | 3.6875 | 4 | [] | no_license | #-for future to do's: add difficult level in both word arrays, guesses_left and
# introduce a bet multiplier for those difficulties.
# -add ability to add money without going back to cashier.
# -add gradual ascii print outs (head on first wrong guess, then body 2/3 wrong)
require 'colorize'
require 'pry'
class Hangm... | true |
4c90e8bc64a960ad099a664b4314ee10a6cdde6d | Ruby | lorrocha/food_inventory | /spec/features/user_can_record_an_inventory_spec.rb | UTF-8 | 1,776 | 2.765625 | 3 | [] | no_license | require 'spec_helper'
feature 'Users can recieve an inventory', %q{
As a food service employee
I want to receive inventory
So that it can be recorded that we have food items
} do
# I must specify a title, description, and quantity of the food item
# If I do not specify the required information, I am prompt... | true |
458552b00f8f13e2aa753908aeaca9218bf2eecc | Ruby | Rtax/openhab-dashboard | /openHAB/OH2.0/oh2dashing.rb | UTF-8 | 2,054 | 2.59375 | 3 | [] | no_license | #!/usr/bin/ruby -w
require 'em-eventsource'
require 'json'
DASHING_AUTH_TOKEN="openH4b"
OPENHAB_URL = "http://localhost:7070"
DASHING_URL = "http://127.0.0.1:3030"
VERBOSE = 0 #0, 1, 2
def postToDashing(widget,content,state)
body = { auth_token: DASHING_AUTH_TOKEN}
body["state"] = state
bodyJson = body... | true |
ca85b825895a7cbd7d4e505c1b6e08eb554b5ed3 | Ruby | collabro2017/goshadow_v2 | /app/services/note_formater.rb | UTF-8 | 1,675 | 2.59375 | 3 | [] | no_license | class NoteFormater
attr_reader :ordered_notes
def initialize(experience, status, segment=nil)
@experience = experience
@segment = segment
@notes = filter_notes(status)
@references = @experience.references
@ordered_notes = []
end
def filter_notes(status)
if @segment && status
@se... | true |
3261ad4dfa08062229bd6fb79f06180fb18f1acc | Ruby | swanson/ferrara | /lib/ferrara/itunes_finder.rb | UTF-8 | 662 | 2.65625 | 3 | [
"MIT"
] | permissive | module Ferrara
class ItunesFinder
def initialize
@endpoint = "https://itunes.apple.com/search"
@media = "media=tvShow"
@entity = "entity=tvEpisode"
@attr = "attribute=tvSeasonTerm"
end
def fetch(show, season, episode)
term = "?term=" + build_term(show, season)
url = @e... | true |
a59ff30e6d4bc00e0175e32beb5ad46e02cc02e7 | Ruby | dstotz/25_words_or_less | /lib/team.rb | UTF-8 | 179 | 2.953125 | 3 | [] | no_license | class Team
attr_reader :team_name, :players
def initialize(team_name, players)
@team_name = team_name
@players = players.reject { |e| e.nil? || e == '' }
end
end
| true |
33b51a421b71adf82c46b61c3b1552e60b81c58a | Ruby | tonynguyenrubify/kara_app | /app/presenter/users_presenter.rb | UTF-8 | 708 | 2.578125 | 3 | [] | no_license | class UsersPresenter < BasePresenter
def initialize(user, params)
super(user)
@params = params
end
def extract_data_of_index
page = @params[:page] || 1
@users = User.search.paginate(:page => page, :per_page => 10)
@users_data = {page: page, users: extract_users_data(@users), total_page... | true |
1c17a622e7844bbae7d1a21fb5feb4d193111996 | Ruby | kishore-mohan/Twitter_fetcher_analytics | /app/models/tweet.rb | UTF-8 | 1,729 | 2.703125 | 3 | [] | no_license | ##
#Tweet carries all the tweets from twitter which related to the retailer.
# when tweets added automatically tweets counts will increase in the retailer account
# all the attributes are related to the tweet. and each row carries one tweet detail
# tweet_id is maintained to use since_id the maximum since_id can be l... | true |
e15c830184134310e67ef97813165dfa2d0d8b75 | Ruby | Alaanzr/rps-challenge | /app.rb | UTF-8 | 1,302 | 2.65625 | 3 | [] | no_license | require 'sinatra/base'
require './lib/game'
require './lib/player'
require './lib/computer'
require './lib/multi_game'
class RPS < Sinatra::Base
enable :sessions
get '/' do
erb :index
end
get '/single_player_sign_in' do
erb :single_player
end
post '/play' do
player = Player.new(params[:usern... | true |
bd0c20570acea00b504e74c426624cabc717c172 | Ruby | tylerweng/AA | /w4/w4d4/music_app/db/seeds.rb | UTF-8 | 3,210 | 2.8125 | 3 | [] | no_license | # This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... | true |
ce06382d26d7d7741cf55a9d8e7ea19b8098771a | Ruby | ratamabahata/lesson_3 | /train.rb | UTF-8 | 1,752 | 3.34375 | 3 | [] | no_license | #Класс Train (Поезд)
class Train
attr_accessor :speed
attr_reader :wagon_count, :current_station, :number, :type_wagon
#Имеет номер (произвольная строка) и тип (грузовой, пассажирский) и количество вагонов
def initialize(number, type, wagon_count)
@number = number
@type = type
@wagon_count = wagon_count
... | true |
f3a1bf0a76598de2873314a13f46fa607844e7a1 | Ruby | DanFan1988/Algorithms_and_Data_Structures | /DataStructures/set.rb | UTF-8 | 790 | 3.59375 | 4 | [] | no_license | class Set
attr_accessor :set
def initailize
@set = {}
end
def add(item)
@set[item] = true
end
def remove(item)
@set.delete(item)
end
def subset?(item)
!!@set[item]
end
def merge(items)
#can handle both Sets or Arrays, but only those
if items.is_a?(Set)
items.set.each_key do |item|
self... | true |
c76cca2635d9e3d1bfc6d24ad8c09d9e6029e5cb | Ruby | JonathonMA/zippo | /lib/zippo/zip_member.rb | UTF-8 | 2,398 | 3.140625 | 3 | [
"MIT"
] | permissive | require 'zippo/local_file_header'
require 'zippo/filter/uncompressors'
require 'zippo/filter/compressors'
require 'forwardable'
module Zippo
# A member of a Zip archive file.
class ZipMember
def initialize(io, header)
@io = io
@header = header
end
# @return [String] the name of the member... | true |
0986865093fde9c4beca46bb86ffdf1f3e739274 | Ruby | elizsutherland/Metis | /Week_1/flashcards/flashcards_master.rb | UTF-8 | 320 | 3.3125 | 3 | [] | no_license | class FlashcardGame
def play
loop do
deck=ask_user_which_deck
if deck == ""
break
else
puts "OK Playing #{deck}"
end
end
end
private
def ask_user_which_deck
print "What deck would you like?"
response = gets.chomp
end
end
flashcard_game = FlashcardGame.new
flashcard_game.play | true |
4580b569bccc2aa92669e262b7e338db89479854 | Ruby | alfanick/xbee868-routing | /src/simulator.rb | UTF-8 | 1,517 | 2.609375 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'logger'
require 'optparse'
$logger = Logger.new(STDERR)
$logger_start = Time.now
$logger.formatter = proc do |severity, datetime, progname, msg|
"#{severity[0]} [#{'%8.03f' % (datetime - $logger_start)}] #{progname}: #{msg}\n"
end
require_relative 'simulator/frame'
require_relative 'si... | true |
d5acc027b6010f210231bba2671ad3abf7b8381e | Ruby | canales101/REPL_game | /repl.rb | UTF-8 | 1,128 | 3.5625 | 4 | [] | no_license | "Which Dragonball Super character are you?"
puts "What race are you?"
puts "Options: Human, Saiyan, Namekian, Other"
option1 = gets.chomp.capitalize
case option1
when "Human"
puts "Bald, Full head of hair"
when "Saiyan"
puts "Prince, Strong low class warrior, Time traveler"
when "Namekian"
puts "Gaurdian ... | true |
d821a7721e7646b04afb2fc5fd8f64fe8e8a4856 | Ruby | njpa/launchschool-ruby-basics | /05_loops_2/03_conditional_loop.rb | UTF-8 | 1,007 | 4.3125 | 4 | [] | no_license | # EXERCISE 3
# ==========
# Using an `if/else` statement, run a loop that prints
# `"The loop was processed!"` one time if `process_the_loop` equals `true`.
# Print `"The loop wasn't processed!"` if `process_the_loop` equals `false`.
# process_the_loop = [true, false].sample
# ANSWER
# ======
# The `Array#sample` me... | true |
70544fef03b69fe35e6fe27bb9ee43f413f3890c | Ruby | Kirouw/BoucleRuby | /lib/02_password.rb | UTF-8 | 636 | 3.40625 | 3 | [] | no_license | passwordsave = ""
def signup
puts "Bonjour, veuillez définir un mot de passe..."
print "> "
passwordsave = gets.chomp
return passwordsave
end
def login(password)
puts "Pour accéder à la zone secrète, veuillez taper votre mot de passe..."
print "> "
password_login = gets.chomp
if (password_login != password)
... | true |
45d837a39b9dfb5d8024fb9cf3f8052750525797 | Ruby | ebsco/mixlibrary-core | /lib/mixlibrary/core/shell/scripts/powershell.rb | UTF-8 | 5,524 | 2.53125 | 3 | [
"Apache-2.0"
] | permissive | #Runs powershell scripts with the least amount of intrusion possible. We do some syntax checking and validation that the script did not end badly, but other than that, we
#try to leave the executing script in the hands of the developer.
require "chef"
require "mixlibrary/core/shell/scripts/windows_script"
module Mix... | true |
861250922e5b0ee5d9e5d73dbd6a0bd48b9a579e | Ruby | CanIGetAPickle/Intro-to-Programming | /exercise3.rb | UTF-8 | 204 | 3.875 | 4 | [] | no_license | arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
# newarr = []
# arr.each do |element|
# if element.odd?
# newarr.push(element)
# end
# end
# puts newarr
newarr = arr.select {|odd| odd % 2 != 0}
puts newarr
| true |
f1e85992a0d7deab9176130cee7d8b2175d96330 | Ruby | haracane/kajax | /lib/symbol_extensions.rb | UTF-8 | 213 | 2.59375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive |
module SymbolExtensions
module Symbol
module Conversions
def to_proc
Proc.new{|x| x.send(self)}
end
end
end
end
class Symbol
include SymbolExtensions::Symbol::Conversions
end
| true |
f6cbb4224390cf71b00d5008264cea3e2dceb68c | Ruby | blaet/messagebird-sms-api-ruby | /lib/messagebird/http/response_code.rb | UTF-8 | 1,785 | 2.890625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module MessageBird::HTTP
class ResponseCode
def initialize(symbol, description)
@symbol = symbol
@description = description
end
def to_sym
@symbol
end
def to_s
@description
end
def ==(other)
if other.is_a? Symbol
self.to_sym == other
els... | true |
4bfa5e9e57dec7b00457ac5b943259b876cdebc4 | Ruby | ericmarcmartin/refactoring-exercise | /ruby/funding_raised_spec.rb | UTF-8 | 5,241 | 2.65625 | 3 | [] | no_license | require_relative 'funding_raised'
RSpec.configure do |config|
config.color = true
end
RSpec.describe FundingRaised do
describe '.where' do
describe 'company_name is Facebook' do
let(:rows) { FundingRaised.where(company_name: 'Facebook') }
let(:row) { rows[0] }
it 'returns the fund raising e... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.