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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
1dac293a1249fbb2fd61b9d92cd9fdd340709642 | Ruby | flum1025/Mocodo | /lib/mocodo/base.rb | UTF-8 | 1,337 | 2.578125 | 3 | [
"MIT"
] | permissive | require 'net/https'
require 'open-uri'
require 'json'
module Mocodo
class Base
BaseURL = "https://api.apigw.smt.docomo.ne.jp"
attr_reader :api_key, :response
def initialize(api_key)
@api_key = api_key
end
private
def build_params(options={})
options.map{|pair|p... | true |
8ae8798ac72a16a0121e7dbe0d7fe42a467e3ee6 | Ruby | yltsrc/targetprocess-ruby | /lib/target_process/api_client.rb | UTF-8 | 1,966 | 2.5625 | 3 | [
"MIT"
] | permissive | require 'active_support/inflector'
require 'httparty'
require 'json'
module TargetProcess
class APIClient
def get(path, options={})
options.merge!(format: 'json')
options = {body: options}
response = perform(:get, path, options)
normalize_response(response.parsed_response)
end
d... | true |
521d44a80ca6b9547e7facf91da593b5aed8b579 | Ruby | indentlabs/ankov | /app/tentacles/tentacle.rb | UTF-8 | 2,620 | 2.515625 | 3 | [] | no_license | class Tentacle
include Sidekiq::Worker
# TODO: pull retort URL out into app config
RETORT_BASE_URL = 'http://www.retort.us'
# TODO: pull dactyl URL out into app config
DACTYL_BASE_URL = 'http://www.dactyl.in'
def perform
startup
scrape
shutdown
end
private
# Methods to override in ten... | true |
acb098b22132b3934d3af57b9240119e489d28f9 | Ruby | Blueibis/oop-farm | /potato.rb | UTF-8 | 183 | 2.953125 | 3 | [] | no_license | require_relative 'crop'
class Potato < Crop
attr_accessor :yield, :type
def initialize(hectares)
super(hectares)
@yield = hectares * 10
@type = "potato"
end
end
| true |
a8dcb5a79e29fe2cd270f8b384dedfd53d6ec50d | Ruby | NicolasHov/THPsemaine3 | /the_bad_array_way.rb | UTF-8 | 659 | 3.828125 | 4 | [] | no_license |
# classe qui gèrera le tableau
def affiche_separateur(n)
n.times do |i|
print ("+ --- ")
end
print ("+")
end
def affiche_tab(tab)
i = 0
tab.each do |elem_ligne|
affiche_separateur(elem_ligne.length)
puts ""
tab[i].each do |elem_colonne|
print ("| #{elem_colonne.to_s} ")
end
... | true |
d8dd7910edb72203b04e40c5a572722aad0f1aaa | Ruby | pharaonick/ls_101 | /ex/easy1/stringy_strings.rb | UTF-8 | 2,168 | 4.75 | 5 | [] | no_license |
def stringy(int)
str = ''
int.times { |i| i.even? ? str += '1' : str += '0'}
str
end
def stringy(int, first = '1')
count = first == '1' ? ['0', '1'] : ['1', '0']
str = ''
int.times do |_|
str += count[1]
count[0], count[1] = count[1], count[0]
end
str
end
# Write a method that takes one ar... | true |
14ac5b41dfe911def5ed0f9d8c155a01d8b4d24f | Ruby | rhhaynes/playlister-sinatra-v-000 | /app/models/concerns/slugifiable.rb | UTF-8 | 244 | 2.734375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | module Slugifiable
module InstanceMethods
def slug
self.name.downcase.gsub(/\s*[^A-Za-z0-9\.]\s*/,"-")
end
end
module ClassMethods
def find_by_slug(slug)
self.all.find{|o| o.slug == slug}
end
end
end | true |
e773eba60990fe59bcc54dc93b21213280829dab | Ruby | itggot-edwin-eliasson/GA_repository | /lib/collision_manager.rb | UTF-8 | 7,048 | 2.828125 | 3 | [] | no_license | class CollisionManager
def initialize(player, map, enemies)
@player = player
@map = map
@enemies = enemies
@hit_sound = Gosu::Sample.new('media/Hit_02.wav')
@values = []
end
# def on_ground
# @map.array.each_with_index do |row, y|
# row.each_with... | true |
9992c868068263a2345bd4b92e09e36504f03ef2 | Ruby | DocRaptor/docraptor-ruby | /examples/sync.rb | UTF-8 | 1,500 | 2.84375 | 3 | [
"MIT"
] | permissive | # This example demonstrates creating a PDF using common options and saving it
# to a place on the filesystem.
#
# It is created synchronously, which means DocRaptor will render it for up to
# 60 seconds. It is slightly simpler than making documents using the async
# interface but making many documents in parallel or ve... | true |
5c8751a3a0ac30bd0416d7567c7b586f23c83cde | Ruby | fiosman/App-Academy | /sql_curriculum/16_active_record_lite/spec/00_attr_accessor_object_spec.rb | UTF-8 | 1,129 | 2.96875 | 3 | [] | no_license | require '00_attr_accessor_object'
describe AttrAccessorObject do
before(:all) do
class MyAttrAccessorObject < AttrAccessorObject
my_attr_accessor :x, :y
end
end
after(:all) do
Object.send(:remove_const, :MyAttrAccessorObject)
end
subject(:obj) { MyAttrAccessorObject.new }
describe '#my... | true |
283e033165b627b3ad5eb42b2f4f4e1df0bf8ff2 | Ruby | hgodinot/hgodinot-Launch_School | /RB101/small_problems/easy_1/9.rb | UTF-8 | 57 | 3.015625 | 3 | [] | no_license | def sum(number)
number.to_s.chars.map(&:to_i).sum
end
| true |
f42c64477ccc43f18a03d8534a0b193cb19f48ca | Ruby | selesse/rc | /lib/rock/climbing/calculator/average_climb_calculator.rb | UTF-8 | 863 | 3.4375 | 3 | [
"MIT"
] | permissive | class AverageClimbCalculator
def initialize(climbing_sessions)
@climbing_sessions = climbing_sessions
end
def print_report
@climbing_sessions.each do |session|
climbs = session.climbs
climb_average = AverageClimbCalculator.get_climb_average(climbs)
puts "Average for climb on #{session.d... | true |
fb8c5f20c91e04fd93ef16653f0b365b4b23636c | Ruby | devbryan0225/ruby-tutorial | /calculator.rb | UTF-8 | 137 | 3.5625 | 4 | [
"MIT"
] | permissive | puts "Enter a number:"
num1 = gets.chomp()
puts "Enter another number"
num2 = gets.chomp()
puts("sum is " + (num1.to_f + num2.to_f).to_s) | true |
f8ece6f0e493d5333a6f36942470306a747b820e | Ruby | eangach/app_env | /lib/app_env.rb | UTF-8 | 1,085 | 2.578125 | 3 | [] | no_license | # Load dotenv files depending on enviornment set in ENV['APP_ENV'].
module AppEnv
class << self
end
class Error < StandardError; end
class MissingKeys < Error # :nodoc:
def initialize(keys)
key_word = "key#{keys.size > 1 ? 's' : ''}"
super("Missing required configuration #{key_word}: #{keys.i... | true |
20785fb80734de3b7bb12b57f0959d44c4e8cd5b | Ruby | alexfalkowski/rfunk | /spec/rfunk/match/match_class.rb | UTF-8 | 964 | 2.578125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class MatchClass
include RFunk::Attribute
include RFunk::Match
fun :something do
match(RFunk.some('YES')) do |p|
p.with :some, ->(v) { "#{v} IT WORKED" }
end
end
fun :nothing do
match(RFunk.none) do |p|
p.with :none, ->(_) { 'IT IS A NONE' }
end
end
fun :nothing_with_error d... | true |
3edc11ead42c9b1959efa7b929ddface4024560e | Ruby | CheezItMan/array-equals | /lib/array_equals.rb | UTF-8 | 412 | 3.53125 | 4 | [] | no_license | # Determines if the two input arrays have the same count of elements
# and the same integer values in the same exact order
def array_equals(array1, array2)
return true if array1.nil? && array2.nil?
return false if array1.nil? || array2.nil?
return false if array1.length != array2.length
array1.length.times do ... | true |
77cb1bb7d79db9774b13dcd55feca0c53cf3a2a3 | Ruby | wencakisa/fmi-ruby | /lecture_04/procs.rb | UTF-8 | 642 | 3.84375 | 4 | [
"MIT"
] | permissive | double = Proc.new { |x| x * 2 }
puts double.call 2
puts double[2]
puts double.(2)
# ----------------------------------------------
p Proc.new { puts 'Hello world' }
p lambda { puts 'Hello world' }
# ----------------------------------------------
p = Proc.new { |x, y| puts "#{x}, #{y}" }
l = lambda { |x, y| puts "#... | true |
dcff64ee5fd3d5fb31255d272ba85da7ace685d0 | Ruby | benjewman/booclub | /app/models/author.rb | UTF-8 | 616 | 2.859375 | 3 | [] | no_license | class Author < ApplicationRecord
has_many :books, dependent: :destroy
accepts_nested_attributes_for :books
validates :first_name, presence: true, length: { minimum: 1 }
validates :last_name, presence: true, length: { minimum: 1 }
def proper_name
self.first_name.capitalize!
self.last... | true |
01be40e970d9eb9b0eb2647f627d6cc0fd60273d | Ruby | dreamlx/giftbase2 | /app/models/order.rb | UTF-8 | 902 | 2.546875 | 3 | [] | no_license | class Order < ActiveRecord::Base
belongs_to :user
attr_accessible :credit_quantity
validates :user, presence: true
before_validation :generate_number, on: :create
state_machine :state, initial: :placed do
state :placed, :paid, :canceled
event :pay do
transition :placed => :paid
end
... | true |
3738d23100fd1509e2947688c6a08701364683e0 | Ruby | Nickolai8/rb101 | /exercises_small_problems/easy7/lettercase_counter.rb | UTF-8 | 395 | 3.390625 | 3 | [] | no_license | ALPHABET = 'abcdefghijklmnopqrstuvwxyz'
def letter_case_count(str)
upper_lower_neither = {lowercase:0, uppercase:0, neither:0}
str.chars.each do |char|
if ALPHABET.upcase.include?(char) then upper_lower_neither[:uppercase] += 1
elsif ALPHABET.include?(char) then upper_lower_neither[:lowercase] += 1
els... | true |
eb41b8d79c5cb7a26ad392423b6b7515971f51b4 | Ruby | michaelscruz/assessment | /db/seeds.rb | UTF-8 | 4,371 | 2.765625 | 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 rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel... | true |
5803931bcfe7c24906686883c94f06c4dd58e2cf | Ruby | Matt--/S-Ware | /app/models/volcoordinator.rb | UTF-8 | 666 | 2.640625 | 3 | [] | no_license |
# Volunteer coordinator model. Used to generate an acknowledgement text to the applicant.
# Supplies an email address and the body of the acknowledgement text.
class Volcoordinator < ActiveRecord::Base
attr_accessible :email_replyto, :email_header, :email_content
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-... | true |
788bd6966b691b86f4696f53bdbfa0c69aab7b51 | Ruby | angmeng/imerp | /app/models/supplier_payment_item.rb | UTF-8 | 335 | 2.515625 | 3 | [] | no_license | class SupplierPaymentItem < ActiveRecord::Base
belongs_to :supplier_payment
belongs_to :purchase_order
def total_amount
amount
end
def total_paid_amount
paid_items = SupplierPaymentItem.where("purchase_order_id = ?", purchase_order_id).all
paid_items.inject(0) {|sum, item| sum += item.paid_amoun... | true |
11f9994fe651ee4dac101238f9987e97f7d4fc82 | Ruby | mystycs/square_array-v-000 | /square_array.rb | UTF-8 | 127 | 3.203125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def square_array(array)
# your code here
array_squared= []
array.each { |x| array_squared << (x * x)}
array_squared
end | true |
7089db8aa737ffc11a7df31f87019b632ff0a748 | Ruby | misterchlee7/Coding-Projects | /Ruby/bank_account/bank_account_spec.rb | UTF-8 | 1,102 | 3.203125 | 3 | [] | no_license | require_relative 'bank_account'
RSpec.describe BankAccount do
before(:each) do
@bank1 = BankAccount.new
@bank2 = BankAccount.new(100,200)
end
# it 'has a getter and setter for name attribute' do
# @project1.name = "Changed Name"
# expect(@project1.name).to eq("Changed Name")
... | true |
22a19a3b0f41dc82004d83b758bfec9f14177ec4 | Ruby | exact-payments/Proxima | /lib/proxima/http_methods.rb | UTF-8 | 643 | 2.546875 | 3 | [
"MIT"
] | permissive |
module Proxima
HTTP_METHODS = [:head, :post, :get, :put, :delete]
module HTTPMethods
HTTP_METHODS.each do |http_method|
define_method http_method do |path, opts = {}, &block|
@response = self.class.api.public_send(http_method, path, opts, &block)
@response
end
end
modul... | true |
bb68cf317ae52cb5fe811e7e202ea4bad08c1936 | Ruby | eliasjpr/poker_time | /lib/hand_ranking.rb | UTF-8 | 2,036 | 3.390625 | 3 | [] | no_license | require './lib/hand'
class HandRanking
Rank = Struct.new(:kind, :rank, :hand)
HAND_RANKINGS = {
royal_flush: 8, four_of_kind: 7, full_house: 6, flush: 5, straight: 4,
three_of_kind: 3, two_pair: 2, one_pair: 1, high_card: 0
}.freeze
def self.rank_hand(hand)
new(hand).rank_hand
end
def initia... | true |
bda2dd047ff1bfd796e25561c6133033686eea18 | Ruby | EmilieAussage/Une_app_Sinatra | /lib/gossip.rb | UTF-8 | 650 | 2.734375 | 3 | [] | no_license | require 'bundler'
Bundler.require
class Gossip
attr_accessor :author, :content, :id
def initialize(author, content)
@author = author
@content = content
end
def save #attention changer en fonction du doc
CSV.open("./db/gossip.csv","ab") do |csv|
csv << [self.author, self.content]
end
e... | true |
89fce1846b8e9dde43776af4169ae1a996aca096 | Ruby | WenYalan/Ruby-code | /hashArray.rb | UTF-8 | 207 | 3.375 | 3 | [] | no_license |
stringcollect = { "red" => "ruby", "white" => "diamond", "green" => "tree"}
#通过with_index来输出hash表的索引
stringcollect.each.with_index{|(key,value),i|
puts "Pair #{i} is: #{key}/#{value}"
} | true |
6a787ab28c8ed30b7689541e39ea5a6872f2d118 | Ruby | ZoeThorne/ironhack-ruby | /Week 1/Day 3/Movie Rater/movies.rb | UTF-8 | 1,037 | 3.578125 | 4 | [] | no_license | require "imdb"
require "pry"
class Movie
attr_reader :title, :rating
def initialize(movie)
@title = Imdb::Search.new(movie).movies[0].title
@rating = Imdb::Search.new(movie).movies[0].rating
end
end
class Ratings
attr_reader :movies
def initialize
@movies = read_movies
end
def add_ratings
... | true |
38680f57bb6e1f3ec15510f01c4aee8e00223e5c | Ruby | Rylon/rybots | /scripts/lib.rb | UTF-8 | 3,743 | 3 | 3 | [] | no_license | require 'yaml'
# Takes a command to execute, streaming output in realtime.
def run_command cmd
output = []
begin
PTY.spawn( cmd ) do |stdout, stdin, pid|
begin
stdout.each { |line| output << line ; print line }
rescue Errno::EIO
# This probably just means that the process has finish... | true |
bda7d250159d93acd3ec8198e3db7a9cb3511906 | Ruby | Kochedykov00/ruby | /new.rb | UTF-8 | 869 | 2.703125 | 3 | [] | no_license | require 'pg'
class New
def initialize(params)
@params = params
return unless valid?
conn.exec("INSERT INTO New(text) VALUES('#{params[:text]}')")
end
def valid?
@params[:text] != ""
end
def self.all
conn = PG.connect :dbname => 'ruby', :user => 'banan4ik', :password => 'password'
... | true |
4598aadb41bc2feb18574b223eb224f819cd871e | Ruby | aslam/test_algolia_angular_require | /lib/force_ssl.rb | UTF-8 | 612 | 2.5625 | 3 | [] | no_license | class ForceSSL
def initialize(app)
@app = app
end
def call(env)
if env['HTTPS'] == 'on' || env['HTTP_X_FORWARDED_PROTO'] == 'https'
puts "I am enforcing HTTPS since the equest is HTTPS*********"
@app.call(env)
else
if env['rack.session'].has_key?('auth_token')
puts "I am enf... | true |
ad548c70ec62e14a491a60beaa4f2e7380280301 | Ruby | selvachezhian/Effortless-Site | /app/models/image.rb | UTF-8 | 2,401 | 2.515625 | 3 | [] | no_license | class Image < ActiveRecord::Base
# Relationships
has_many :image_details
has_many :image_attachments
def generate_image_folder_path
self.id=~/(.{3})(.{3})(.{2})-(.{4})-(.{4})-(.{4})-(.{3})(.{3})(.{3})(.{3})$/
"/IMG/#{$1}/#{$2}/#{$3}/#{$4}/#{$5}/#{$6}/#{$7}/#{$8}/#{$9}/#{$10}"
end
def self.save_im... | true |
e7b44bd7e4f037564ad90746f75df7b869886518 | Ruby | tslater3/fall_dev_15 | /to_do_list.rb | UTF-8 | 1,763 | 4.15625 | 4 | [] | no_license | require 'pry'
class List
attr_accessor :name, :item_array
def initialize(name)
@name = name
@item_array = []
end
def display_menu
loop do
puts """
What would you like to do?
1. Display List
2. Add item
3. Remove item
4. Mark an item complete
5.... | true |
d1eb9238f8daf63427d0601f36c400af53323b66 | Ruby | neves/e-inscricao | /app/models/renting.rb | UTF-8 | 1,035 | 2.5625 | 3 | [] | no_license | class Renting < ApplicationRecord
attr_reader :number_of_days
validates :begin_date, date: true
validates :end_date, date: { after_or_equal_to: :begin_date }
validates :client_name, presence: true, length: { maximum: 50 }
validates_with AvailabilityValidator
def number_of_days=(value)
... | true |
7594740cd54ef4f99b69e1a67f689e3e926a5f1f | Ruby | ngpestelos/misc-ruby | /meta/ctwc/class_extension_mixin.rb | UTF-8 | 196 | 3.140625 | 3 | [] | no_license | module M
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
def my_method
'a class method'
end
end
end
class C
include M
end
puts C.my_method
| true |
90d663191e8b746a109b9896bb50b90b47c7638b | Ruby | michellejanosi/exercism.io | /ruby/hello-world/hello_world.rb | UTF-8 | 185 | 4.09375 | 4 | [] | no_license | # Write a program that greets the user by name, or by saying "Hello, World!"
# if no name is given.
class HelloWorld
def self.hello(name = "World")
p "Hello, #{name}!"
end
end
| true |
67a06f7696f04b4547dcf1f31975df6f72989cf6 | Ruby | tharkness/parser | /main.rb | UTF-8 | 798 | 3.265625 | 3 | [] | no_license | require 'open-uri'
require_relative 'lib/post'
require 'nokogiri'
require 'pry'
html_file = open(ARGV[0])
post = html_file.read
doc = Nokogiri::HTML(post)
def create_post(doc)
title = doc.search('td.title a')[0].inner_text
points = doc.search('td.subtext span')[0].inner_text
id = get_id(doc)
url = doc.xpath... | true |
525c1a691074ae910d1eab3d1642404d364c1850 | Ruby | atp1o2/interview-problems | /4 - Merging Meetings.rb | UTF-8 | 1,376 | 4.03125 | 4 | [] | no_license | # Interview Cake 4
# Merging meeting times
# write a function that will return a condensed array of meetings times
meetings = [ [0, 1], [3, 5], [4, 8], [10, 12], [9, 10] ]
# return => [ [0, 1], [3, 8], [9, 12] ]
# solution
# Note that meeting times are not in order
# Need to check if the end of the meeting bleeds... | true |
d1ee1dac22a96596c8f8818381189bb722d461fe | Ruby | Jsalim/twitter-follower-recommender | /project/.svn/text-base/rearrange.rb.svn-base | UTF-8 | 514 | 2.828125 | 3 | [] | no_license | #!/usr/bin/ruby
file=ARGV[0] #"test.txt"
ofile = ARGV[1] #"out.txt"
cols = ["T","U","W"]
cols.each{|c| `cat #{file} | grep ^#{c} > #{c}.txt`}
`touch #{ofile}`
streams = cols.collect{|c| File.open("#{c}.txt","r")}
output = File.new(ofile,"a")
while(true)
lines = streams.collect{|s| s.gets.chomp.split("\t")[1]}
... | true |
7d7426b0b053711a11cd366d24dbc0f79e059397 | Ruby | jackhayter/exif-gps-extractor | /extract.rb | UTF-8 | 1,369 | 2.84375 | 3 | [] | no_license | #!/usr/bin/env ruby
# frozen_string_literal: true
require 'optparse'
require 'logger'
require 'mimemagic'
require 'exifr/jpeg'
require_relative 'lib/gps_exif_extractor'
# Configure debug logger to output to console, and only show warnings by default
#
logger = Logger.new(STDOUT)
logger.level = Logger::WARN
# Build a... | true |
de80272394d5804ecfa581594dc312c88aa3a217 | Ruby | kunaldesign/Ruby-Program | /8program.rb | UTF-8 | 108 | 3.484375 | 3 | [] | no_license | #8program: user input for float type from to_f.
puts "Enter your area: "
name = gets.chomp.to_f
puts name
| true |
a738cb67519f71b44e5f44333425ed4aba5ca1ea | Ruby | danilobarion1986/recommendable | /lib/recommendable/rater/hider.rb | UTF-8 | 4,616 | 2.765625 | 3 | [
"MIT"
] | permissive | module Recommendable
module Rater
module Hider
# Hide an object. This action is only possible if the user has not yet
# rated or bookmarked the object.
#
# @param [Object] obj the object to be hidden
# @return true if object was hidden successfully
# @raise [ArgumentError] if t... | true |
0b1f197bebb102e1e2e3f85980c7f0db0f74471e | Ruby | marianposaceanu/retriever | /lib/retriever/twitter.rb | UTF-8 | 3,359 | 2.515625 | 3 | [] | no_license | module Retriever
class Twitter
include CustomLogger
attr_reader :rate_status, :id_for_parsing, :users_data
# init twitter user and set acces_token, consumer
# pentru care se vor prelua informatiile
def initialize(tw_user,atc)
@twiter_user = tw_user
@oauth_client = atc
@id_for_par... | true |
6e5feae40d98987c906370a300dcdc35decc5284 | Ruby | vilyapilya/UI-New-York-Times | /exer/recurs.rb | UTF-8 | 1,485 | 3.640625 | 4 | [] | no_license | require "byebug"
class Array
def bubble_sort(&prc)
swapped = true
prc = Proc.new{|x, y| x <=> y} if prc == nil
while swapped
swapped = false
i = 0
while i < self.size - 1
res = prc.call(self[i], self[i+1])
if res == 1
self[i], self[i+1] = self[i+1], self[i]
... | true |
481381e4587bacefb0c249dd42a43a82b926594e | Ruby | dianajohnson13/toy-problems | /ruby/minCoins.rb | UTF-8 | 352 | 3.8125 | 4 | [] | no_license | # You are given 3 types of coins of value 1, 3 and 5.
# You are also given a total which you have to arrive at.
# Find the minimum number of coins to arrive at it.
def min_coins(total)
coin_count = 0
remainder = total
[5, 3, 1].each do |coin|
coin_count += remainder / coin
remainder = remainder % coin... | true |
f7546188574f7ffc4ce70f2ebe50730a0419f187 | Ruby | puppetlabs/puppet-strings | /lib/puppet-strings/yard/handlers/ruby/provider_handler.rb | UTF-8 | 4,978 | 2.546875 | 3 | [
"Apache-2.0"
] | permissive | # frozen_string_literal: true
require 'puppet-strings/yard/handlers/helpers'
require 'puppet-strings/yard/handlers/ruby/base'
require 'puppet-strings/yard/code_objects'
require 'puppet-strings/yard/util'
# Implements the handler for Puppet providers written in Ruby.
class PuppetStrings::Yard::Handlers::Ruby::Provider... | true |
14b7829d7f19c77ad8e08870f36da835aba5a618 | Ruby | idanci/Qif | /lib/qif/reader.rb | UTF-8 | 3,821 | 3.078125 | 3 | [
"MIT"
] | permissive | require 'stringio'
require 'qif/date_format'
require 'qif/transaction'
module Qif
class Reader
include Enumerable
attr_reader :index
SUPPORTED_ACCOUNTS = {
"!Type:Bank" => "Bank account transactions",
"!Type:Cash" => "Cash account transactions",
"!Type:CCard" => "Credit card account t... | true |
efd74c14d9e68ba37fcb08917e863d0edd553b14 | Ruby | Khetti/ruby_functions_lab | /ruby_functions_practice.rb | UTF-8 | 1,252 | 4.125 | 4 | [] | no_license | # Homework for day 2, write the functions for testing here.
def return_10
return 10
end
def add(first_number, second_number)
return first_number + second_number
end
def subtract(first_number, second_number)
return first_number - second_number
end
def multiply(first_number, second_number)
return first_number ... | true |
9b6b8c6f019168ebfa68c172d2f7873d5b6c750e | Ruby | CapsuleCoding/SQL-bear-organizer-lab-onl01-seng-ft-012120 | /lib/sql_queries.rb | UTF-8 | 978 | 3.046875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def selects_all_female_bears_return_name_and_age
"SELECT name, age
FROM bears
WHERE gender = 'F';"
end
def selects_all_bears_names_and_orders_in_alphabetical_order
"SELECT name
FROM bears
ORDER BY name"
end
def selects_all_bears_names_and_ages_that_are_alive_and_order_youngest_to_oldest
"SELECT name,... | true |
06a8ab67d608bf82eb0b47e6b824fed578ac08b2 | Ruby | marcwright/WDI_ATL_1_Instructors | /REPO - DC - Students/w03/d05/Jacob/pair_programming/server.rb | UTF-8 | 605 | 2.8125 | 3 | [] | no_license | require 'sinatra'
require 'sinatra/reloader'
yes_no = ["Do you have a test for that?", "Does the test pass?", "Need to refactor?"]
done = ["Write a test.", "Write just enough code for the test to pass.", "Refactor the code.", "Select a new feature to implement."]
get '/' do
@have_test = yes_no[0]
erb :index
end
... | true |
75a7bcc23bebb56f7b14e7ecdfacb946b518c928 | Ruby | alekssen/plans | /lib/actions.rb | UTF-8 | 1,863 | 3.046875 | 3 | [] | no_license |
$check_key_existence = lambda {
err_msg 'no such key' if !INFO[$hash].has_key? $key.to_sym
}
$check_hash_existence = lambda {
err_msg 'no such hash' if !HASHES.include? $hash
}
def before_action
system "clear"
read_from_file
INFO.map { |key, value| HASHES << key.to_s }
end
def action
err_msg 'too much a... | true |
b3d05f2b8fe2d424382d2f0754e328b307723705 | Ruby | Shopify/measured-rails | /test/active_record_test.rb | UTF-8 | 15,611 | 2.859375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require "test_helper"
class Measured::Rails::ActiveRecordTest < ActiveSupport::TestCase
setup do
reset_db
end
test ".measured raises if called with something that isn't a Measured::Measurable" do
assert_raises Measured::Rails::Error do
Thing.measured(Object, :field)
... | true |
d1b6af099a9a5e7d7dee172ca5a8c496d5511214 | Ruby | jchasse/badges-and-schedules-onl01-seng-ft-070620 | /conference_badges.rb | UTF-8 | 789 | 3.546875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
def badge_maker(name)
"Hello, my name is #{name}."
end
def batch_badge_creator(array)
new_badges = []
array.each do |name|
new_badges << "Hello, my name is #{name}."
end
return new_badges
end
def assign_rooms(array)
room_assign = []
array.each_with_index do |name, room|
room_ass... | true |
16aa1f976d9a9c01600c03e05a59463c666efa2d | Ruby | alejandrodiazpinilla/ruby-plataforma-make | /saluda.rb | UTF-8 | 89 | 2.515625 | 3 | [] | no_license | def saluda(nombre)
"Hola #{nombre}"
end
saluda("Pedro")
saluda("Yu-kai Chou")
saluda("") | true |
0e76c7171b3782cf1963a630ee81c514120ea7c4 | Ruby | ggarra20/wed_class | /ruby_book.rb | UTF-8 | 100 | 3.234375 | 3 | [] | no_license | name = 'Virginia Lynn Garramone'
puts 'My name is ' + name + '.'
puts 'Wow!! ' + name
puts 'is a really long name!'
| true |
a24dcf162f155aca2d7d19c53da6c5b39ae76f02 | Ruby | DrDhoom/RMVXA-Script-Repository | /Dhoom/Petrified State.rb | UTF-8 | 8,638 | 2.59375 | 3 | [
"MIT"
] | permissive | #==============================================================================
#
# • Dhoom Petrified State v1.3a
# -- Last Updated: 2015.07.08
# -- Level: Easy
#
# Aditional Credit :
# - joeyjoejoe (Commission requester)
#
#==============================================================================
$imported ... | true |
fb5e7b2c42e779e2f7097b9e49d49f85c20c5e2c | Ruby | powersjcb/notes | /w1d4/merge_sort.rb | UTF-8 | 484 | 3.65625 | 4 | [] | no_license | class Array
def merge_sort
return self if count < 2
mid = length / 2
right = self.drop(mid)
left = self.take(mid)
sorted_left = left.merge_sort
sorted_right = right.merge_sort
merge(sorted_left, sorted_right)
end
def merge(left,right)
merged_array = []
until left.empty? |... | true |
4f70fa35784a23503cd754e299780313ebe78bca | Ruby | blackknight75/apicurious | /app/models/repo.rb | UTF-8 | 548 | 2.796875 | 3 | [] | no_license | class Repo
attr_reader :name, :description, :language, :updated_at
def initialize(params)
@name = params[:name]
@description = params[:description]
@language = params[:language]
@updated_at = params[:updated_at].split("T")[0]
end
def self.all(current_user)
repo_hashes = GithubService.repos... | true |
410ad463652de56f25d63460e35a158d8ca167e3 | Ruby | backupii/backupii | /lib/backup/binder.rb | UTF-8 | 578 | 2.640625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Backup
class Binder
##
# Creates a new Backup::Notifier::Binder instance. Loops through the
# provided Hash to set instance variables
def initialize(key_and_values)
key_and_values.each do |key, value|
instance_variable_set("@#{key}", value)
end... | true |
f9964ce503e6655f37acd3ea105404464521bcd6 | Ruby | Joel-B-Williams/farkulator | /app/models/game.rb | UTF-8 | 845 | 2.609375 | 3 | [
"MIT"
] | permissive | class Game < ApplicationRecord
has_many :players, dependent: :destroy
validates :running_total, presence: true
validates :rollover_scoring, inclusion: { in: [ true, false ] }
def create_players(num_players)
num_players.times do |i|
players.create(name: "Player #{i+1}")
end
end
def set_a... | true |
844623c7fb5bfcdefdc981fcf969b1149dbd70f7 | Ruby | GTDev87/SkillUp | /app/presenters/user_presenter.rb | UTF-8 | 1,028 | 2.546875 | 3 | [] | no_license | class UserPresenter < BasePresenter
presents :user
delegate :username, to: :user
#NEEDS TESTS
def avatar
if user.avatar?
image_tag(avatar_name, class: "avatar")
else
image_tag("/images/default_avatar.jpg", class: "avatar")
end
end
def full_name
handle_none user.first_name? do... | true |
5ca8af248f83431aff8307a3e463f3cf3edff25a | Ruby | bertanasco/rubyNotes | /Pragmatic book/part1/Ruby.new/symbols.rb | UTF-8 | 187 | 2.625 | 3 | [] | no_license | class SymbolsTest
symbolsMap = {
:bird => 'fly',
:human => 'walk'
}
p symbolsMap[:bird]
p "test " + symbolsMap[:human]
p "sample withint double qoute #{symbolsMap[:human]}"
end | true |
0ef9ff8da2e1ce3f2abba9280b6193412a2c3a5d | Ruby | joffrey7486/ceasar_cipher_ruby- | /lib/ceasar_cipher.rb | UTF-8 | 257 | 3.21875 | 3 | [] | no_license | def ceasar_cipher(string, number=5)
array_lettres = string.split""
number.times do
array_lettres.each do |c|
c.next!
if c == "aa"
c.chop!
end
end
end
result = array_lettres.join("").to_s
result
end
ceasar_cipher("testz", 5) | true |
252a3240c49e3e21b899a7def6586acdef0034f0 | Ruby | JunZhuSecurity/d3-charts | /aggregate_stats.rb | UTF-8 | 6,892 | 2.65625 | 3 | [] | no_license |
require 'csv'
require 'fileutils'
require 'time'
require 'set'
ONE_HOUR = 60 * 60
ONE_DAY = 24 * ONE_HOUR
INTERVAL = 0.5 * ONE_HOUR
S_TIME = 0
S_CPU = 1
S_RAM = 2
S_DISK_IN = 3
S_DISK_OUT = 4
S_NET_IN = 5
S_NET_OUT = 6
METRIC = []
METRIC[S_TIME] = nil
METRIC[S_CPU] = 'cpu.usage.average'
METRIC[S_RAM] = 'mem.active... | true |
8da0bd1a84a61debb2cd6ca3a0d5773b866dfb71 | Ruby | Amrutha-09/III-year-Lab | /SL Lab/Experiment10/exp10.rb | UTF-8 | 191 | 3.109375 | 3 | [] | no_license | s = Hash.new 0
s['English'] = 77
s['Social'] = 79
s['Math'] = 91
total_marks = 0
s.each {|key,value|
total_marks +=value
}
puts "Total Marks: "+total_marks.to_s | true |
23bbc0337fa4f1901e0069837ff6ae7408162202 | Ruby | dinks/toy_robot | /lib/toy_robot/robot.rb | UTF-8 | 4,298 | 3.4375 | 3 | [
"MIT"
] | permissive | require 'state_machine'
module ToyRobot
# The Robot State Machine
class Robot
# List of Valid Orientation
VALID_ORIENTATIONS = %w( NORTH EAST SOUTH WEST ).freeze
# Valid Instructions and the arguments allowed
VALID_INSTRUCTIONS = {
PLACE: {
args_size: 3
},
MOVE: {
... | true |
b73b43493bb5c15957cb8a77ea3e927a40037608 | Ruby | big32mike/cheezme | /lib/cheezme/recipe.rb | UTF-8 | 1,672 | 3.203125 | 3 | [
"MIT"
] | permissive | class Cheezme::Recipe
attr_accessor :name, :url, :description, :stars, :reviews, \
:ingredients, :cook, :cook_url, :prep_time, :cook_time, \
:steps, :color
@@all = []
def initialize(attr_hash)
attr_hash.each do |key, value|
self.send("#{key}=", value)
end
case @stars
when 4.5..999
... | true |
fe8b1287250bab4a66263d45fcc21f5a5961dc9f | Ruby | risgk/DigitalSynthVRA8 | /generate_wave_table.rb | UTF-8 | 2,685 | 2.90625 | 3 | [
"CC0-1.0"
] | permissive | require './common'
$file = File::open("WaveTable.h", "w")
$file.printf("#pragma once\n\n")
def generate_wave_table(max, name, amp)
$file.printf("const uint8_t g_waveTable%sM%d[] PROGMEM = {\n ", name, max)
(0..255).each do |n|
level = 0
(1..max).each do |k|
level += amp * yield(n, k)
end
l... | true |
e7e44b63111164679498338082c9f98fe8221bfc | Ruby | annamm77/FarMar | /lib/farmar_sale.rb | UTF-8 | 836 | 2.96875 | 3 | [] | no_license | class FarMar::Sale
attr_reader :id, :amount, :purchase_time, :vendor_id, :product_id
def initialize(sales_hash)
@id = sales_hash[:id].to_i
@amount = sales_hash[:amount].to_i
@purchase_time = DateTime.parse(sales_hash[:purchase_time])
@vendor_id = sales_hash[:vendor_id].to_i
@product_id = sales_... | true |
9cd1ae0f3bbde7e22a8a8a818e72b4789c007a27 | Ruby | PabloK/Tokii | /models/playerdata.rb | UTF-8 | 842 | 3.15625 | 3 | [] | no_license | class PlayerData
attr_reader :name, :color, :score, :color_points, :last_color, :color_multiplier
def initialize name, color
@name = name
@color = color
@score = 0
@color_points = {}
@color_multiplier = 1
@last_color = :none
end
def collide block
@score += block.scorepoints
... | true |
d8f39525ca1703e7dba99cdf7f6d8fbd5482b666 | Ruby | HoneyryderChuck/codility-exercises | /queues/nesting.rb | UTF-8 | 281 | 3.40625 | 3 | [] | no_license | def solution(s)
return 1 if s.empty?
stack = []
s.each_char do |char|
case char
when '('then stack.push(char)
when ')'
return 0 unless stack.pop.eql?('(')
end
end
return stack.empty? ? 1 : 0
end
puts solution("(()(())())")
puts solution("())")
| true |
fa31bb485860ae325dd8f6310a1fc83c3794f96d | Ruby | jdashton/glowing-succotash | /daniel/HeadFirst/ch15_jda/exercise.rb | UTF-8 | 268 | 3.03125 | 3 | [
"MIT"
] | permissive | require 'sinatra'
get('/form') do
erb :form
end
post('/convert') do
fahrenheit = params['temperature'].to_f
celsius = (fahrenheit - 32) / 1.8
format('%<f>0.1f degrees Fahrenheit is %<c>0.1f degrees Celsius.',
f: fahrenheit,
c: celsius)
end
| true |
f8a62467a76ceb6abead9e6770cac586ffc424b8 | Ruby | rubyunworks/corpus-ruby | /lib/corpus/main.rb | UTF-8 | 13,135 | 3.046875 | 3 | [] | no_license | module Corpus
#
#
def self.new(directory)
Main.new(directory)
end
##
#
#
class Main
# Default maximum word count.
# TODO: Remove this default limit?
MAX_WORDS = 50000
# The taphoic keyboard can show up to eight word predictions.
MAX_BIGRAMS = 8
#
#def self.scan(direc... | true |
99eff889abcbe99e0c758635607435fb6915f68b | Ruby | zhiqiang-yu/RHOSP-deploy | /usr/share/foreman-proxy/modules/puppet_proxy/class_scanner.rb | UTF-8 | 4,897 | 2.671875 | 3 | [] | no_license | require 'puppet_proxy/puppet_class'
module Proxy::Puppet
class ClassScanner
class << self
# scans a given directory and its sub directory for puppet classes
# returns an array of PuppetClass objects.
def scan_directory directory
parser = Puppet::Parser::Parser.new Puppet::Node::Environ... | true |
ea270700f8ce72c91de11e149a9e2e4ea5560950 | Ruby | juan-gm/RB101 | /small_problems/easy_2/greeting_a_user.rb | UTF-8 | 205 | 3.84375 | 4 | [] | no_license | print "What is your name? "
name = gets.chomp
arr = name.chars
message = "Hello #{name.capitalize}."
if arr[arr.size - 1] == '!'
puts "#{message.upcase} WHY ARE WE SCREAMING?"
else
puts message
end
| true |
4ff1a0bb266ba170fb1d8c358d54719b1042ef17 | Ruby | BackupTheBerlios/antargis-svn | /antargis/tags/lastIso/ant_house.rb | UTF-8 | 4,529 | 2.703125 | 3 | [] | no_license | #!/usr/bin/env ruby
#
# Copyright (c) 2005 by David Kamphausen. All rights reserved.
#
# ant_house.rb
# by David Kamphausen (david.kamphausen@web.de)
#
# The "Antargis" project, including all files needed to compile it,
# is free software; you can redistribute it and/or use it and/or modify it
# under the terms of the ... | true |
cc599189ee0d70377d0f175af236e24aceaa1430 | Ruby | bryantomoregie/programming-univbasics-4-square-array-houston-web-030920 | /lib/square_array.rb | UTF-8 | 320 | 3.875 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def square_array(array)
counter = 0
new_array = [ ]
while counter < array.length do
new_array << array[counter] ** 2
counter += 1
end
return new_array
end
# method called square_array
# take an array of numbers
# squares each element in an array of numbers
# and returns a !!!new array!!! of these squared numbers
| true |
107f64fd6f5d1a66a40753cf671c156d99e54c6e | Ruby | PDAHubbard/rubythehardway | /ex8.rb | UTF-8 | 522 | 4.53125 | 5 | [] | no_license | # Exercise 8: Printing, Printing. Using formatters
#
formatter = "%{first} %{second} %{third} %{fourth}"
puts formatter % {first: 1, second: 2, third: 3, fourth: 4}
puts formatter % {first: "first", second: "second", third: "third", fourth: "fourth"}
puts formatter % {first: true, second: false, third: true, fourth: ... | true |
5f274bc45d8fc314591fc587b2bf0691051d6a40 | Ruby | chuchuva/entrain | /test/models/program_test.rb | UTF-8 | 604 | 2.5625 | 3 | [] | no_license | require 'test_helper'
class ProgramTest < ActiveSupport::TestCase
test "adding user to program should grant access" do
program = programs(:two)
user = users(:stew)
assert_not user.has_access?(program)
program.add_user(user)
assert user.has_access?(program)
assert program.users.include?(user)
... | true |
17c25e5bab66b5de4f7fde028e4f817c5962ac75 | Ruby | nakajima/syntaxily | /lib/core_ext/string.rb | UTF-8 | 225 | 2.515625 | 3 | [] | no_license | class String
def syntaxify(lexer)
unless Syntaxily.available_lexers.include?(lexer.to_s)
raise Syntaxily::LexerNotFound.new("No `#{lexer}` lexer found.")
end
Albino.new(self, lexer).colorize
end
end | true |
2734f455eb0a6642e8148d44f23bd2ece716fba4 | Ruby | nathansherburne/ruby_practice | /data_structures/binary_search_tree/node.rb | UTF-8 | 285 | 3.046875 | 3 | [] | no_license | class Node
attr_reader :key
attr_accessor :left
attr_accessor :right
attr_accessor :parent
attr_accessor :height
def initialize(key)
@key = key
@left = nil
@right = nil
@parent = nil
@height = 0
end
def <=>(other)
@key <=> other.key
end
end
| true |
0fedb00595cdbbc0c8b1498189fd4cd3d48f2570 | Ruby | 1debit/sql_enum | /lib/sql_enum/class_methods.rb | UTF-8 | 1,542 | 2.609375 | 3 | [
"MIT"
] | permissive | module SqlEnum
module ClassMethods
def sql_enum(column_name, options = {})
# Query values
enum_column = EnumColumn.new(table_name, column_name)
values_map = enum_column.values.to_h { |value| [value.to_sym, value.to_s] }
# Check option defaults
prefix = options.fetch(:_prefix, !!SqlE... | true |
e1d0957f69371b3dcfd66c8cf62affc44ae86095 | Ruby | tayduivn/EcommerceAPI | /app/models/haravan/vo/total.rb | UTF-8 | 448 | 3.109375 | 3 | [] | no_license | module Haravan
module Vo
class Total
attr_reader :price, :quantity, :orders
def initialize(items)
@price = 0
@quantity = 0
@orders = []
reduce_items(items)
end
private
def reduce_items(items)
items.each do |item|
@price += item.pr... | true |
6f9e7a7683166c9d4f82d9cce40474f2dab0fc2d | Ruby | chiaraAe/lockdown-work-stuff | /app/models/booking.rb | UTF-8 | 1,142 | 2.84375 | 3 | [] | no_license | class Booking < ApplicationRecord
belongs_to :user
belongs_to :item
validates :starting_date, :end_date, presence: true
# validate :validate_dates
# def data_ranges
# # Fetching all Bookings for the item // checked with raise -> works
# bookings = Booking.where(["item_id =?", item_id])
# # Ext... | true |
36f94eae024fb3796cc90c35fe2efce7a9d977f1 | Ruby | req12345/TrainManagment | /instancecounter.rb | UTF-8 | 390 | 2.671875 | 3 | [] | no_license | # frozen_string_literal: true
module InstanceCounter
class << self
def included(base)
base.extend ClassMethods
end
end
private
def register_instance
self.class.increase_instance_counter
end
module ClassMethods
def instances_counter
@counter || 0
end
def increase_inst... | true |
93e5b393361fef74565f453f419d9b3b21f9de38 | Ruby | kuboon/jinro.rb | /spec/jinro_spec.rb | UTF-8 | 1,935 | 2.53125 | 3 | [] | no_license | RSpec.describe Jinro do
it "has a version number" do
expect(Jinro::VERSION).not_to be nil
end
it "creates new village" do
v = Jinro::Village.new(wolf: 1, seer: 1, villager: 3)
json = v.as_json
v2 = Jinro::Village.from_json(json)
expect(json).to eq(vs.as_json)
expect(json).to eq(
pla... | true |
aafae8bb1d6b00b35d8639b1187bed0c24b2469d | Ruby | mikz/Thesis | /examples/tests/example.rb | UTF-8 | 159 | 3.3125 | 3 | [] | no_license | class Example
attr_reader :value
def initialize(value)
@value = value
end
def truthy?
!!@value
end
def falsy?
not truthy?
end
end
| true |
53ee9196758c42e60a7c8ff4ed719c86fafb6a3c | Ruby | Autumn/myanimelist-api | /my_anime_list/character.rb | UTF-8 | 6,420 | 2.8125 | 3 | [] | no_license | module MyAnimeList
class Character
attr_accessor :id, :name, :image_url, :thumb_url, :anime, :manga, :bio, :seiyuu, :eng_name, :jp_name
def self.scrape_character(id, cookie_string = nil)
curl = Curl::Easy.new("http://myanimelist.net/character/#{id}")
curl.headers["User-Agent"] = "MyAnimeList Unof... | true |
e6fa3e81d425a8e43aae0141959680568e89f1a3 | Ruby | mikereinhart/hw | /week1/524/stockManage2.rb | UTF-8 | 1,387 | 3.578125 | 4 | [] | no_license | require 'yahoofinance'
class Firm
attr_reader :clients
attr_writer
attr_accessor :name
def initialize(name)
@name = name
@clients = {}
end
def addClient(name, cash = 0)
#name.to_sym converts the string name to a symbol
@clients[name.to_sym] = Client.new(name,cash)
end
end
class Cli... | true |
d17314a05ef52a9d9836114a93c682dcad51fa91 | Ruby | JoshMacSween/odin | /bubble.rb | UTF-8 | 279 | 3.765625 | 4 | [] | no_license | def bubble(ary)
x = ary.length
loop do
switch = false
(x-1).times do |n|
if ary[n] > ary[n + 1]
ary[n], ary[n + 1] = ary[n + 1], ary[n]
switch = true
end
end
break if switch == false
end
ary
end
n = [5,3,1,2,4]
p bubble(n)
| true |
a23213fb706a368c4327f3308d288d0f0a112354 | Ruby | isabella232/tagfish | /lib/tagfish/docker_uri.rb | UTF-8 | 1,496 | 2.828125 | 3 | [
"MIT"
] | permissive | module Tagfish
class DockerURI
URI_PARSER = %r{
(https?:\/\/)? # Optional protocol
(?:([\w.\-]+\.[\w.\-]+)\/)? # Optional registry
([\w\-]*\/?[\w\-.]+) # Optional namespace, mandatory repository
:? # Optional delimiter between reposito... | true |
ac24ccc0aea09b388165cc57cb1bb6d7d7945176 | Ruby | sbackus/rubyrampup2015 | /week2/hello_world.rb | UTF-8 | 110 | 2.84375 | 3 | [
"Apache-2.0"
] | permissive |
def calculate_rent rent, utils, roommates
(rent+utils)/roommates
end
puts calculate_rent 2000, 55, 4
| true |
988b1b9b20f9ca6a1ec8e355a198f3858b63e63f | Ruby | dremagic/oxford-comma-001 | /lib/oxford_comma.rb | UTF-8 | 173 | 3.109375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def oxford_comma(array)
if array.count == 1
array.join
elsif array.count == 2
array.join(" and ")
else
final = array.pop
array.join(", ") << ", and #{final}"
end
end | true |
5878f8324b1e6ee710387f7b8b0863b3716924c7 | Ruby | TapasTech/sandal | /lib/sandal/enc/alg/direct.rb | UTF-8 | 1,437 | 2.96875 | 3 | [
"MIT"
] | permissive | require "openssl"
module Sandal
module Enc
module Alg
# The direct ("dir") key encryption algorithm, which uses a pre-shared symmetric key.
class Direct
# The JWA name of the algorithm.
NAME = "dir"
# @return [String] The pre-shared symmetric key.
attr_reader :presh... | true |
80cf8398fec71961c9613cee2be7eff89bb511b3 | Ruby | JohnMorales/picturebook | /lib/directory_finder.rb | UTF-8 | 392 | 2.65625 | 3 | [] | no_license | # Identify locations where pictures are stored.
# Create local jobs to check those locations at regular intervals.
# Create weekly job to identify new locations
require 'image_searcher'
class DirectoryFinder
def found_directory(directory)
ImageSearcher.perform_async directory
end
def find(directory)
Dir[... | true |
8bd7d815c7bda79a1a731d9a2ec8b942de5bc7e5 | Ruby | TALlama/Alexandria | /lib/cli.rb | UTF-8 | 2,508 | 2.765625 | 3 | [
"MIT"
] | permissive | require File.expand_path('../helpers/hierarchal_output', __FILE__)
require File.expand_path('../library', __FILE__)
require 'hashie'
module Alexandria
class CLI
ERROR_CODES = {
:bad_cmd => 1,
:bad_arg => 2
}
def initialize(*args)
self.opts = {:out => HierarchalOutput.new}
parse(*args)
end
... | true |
616a7c3a7258dd12416a9002679324006f9539c0 | Ruby | dmoore1989/appacademyprep | /w3d4/lib/hangman.rb | UTF-8 | 2,220 | 3.5625 | 4 | [] | no_license | class Hangman
attr_reader :guesser, :referee, :board
def initialize(players)
@referee = players[:referee]
@guesser = players[:guesser]
end
def setup
secret_length = @referee.pick_secret_word
@guesser.register_secret_length(secret_length)
@board= Array.new(secret_length)
end
def... | true |
4c414b1fe0783c616a7933c00f3f5597fd9cd489 | Ruby | CartoDB/cartodb | /lib/carto/carto_gears_support.rb | UTF-8 | 1,728 | 2.5625 | 3 | [
"LicenseRef-scancode-generic-cla",
"BSD-3-Clause"
] | permissive | # Support to dynamic CartoGears loading
# Inspired by BootInquirer at https://github.com/taskrabbit/rails_engines_example/blob/17b5ee5286c2186951312cbe440b8d21738596eb/lib/boot_inquirer.rb
module Carto
class CartoGearsSupport
# Returns gears found at:
# - `/gears`. Should be "installed" (added to `Gemfile.loc... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.