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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
f4d024ac89d223d0e749fd93811f205c5d9afd10 | Ruby | sergueif/structure_digest | /bin/structure_digest | UTF-8 | 647 | 2.65625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
$LOAD_PATH << File.join(File.dirname(__FILE__), '../lib/')
require 'structure_digest'
require 'tempfile'
require 'optparse'
ARGV << "--help" if ARGV.empty? && STDIN.tty?
tree = false
opt = OptionParser.new do |opt|
opt.banner = "Usage: structure_digest [options] File1[, File2, ...]"
opt.on('-t... | true |
708602e8dee58fac2e8d77d85df14429fe3eacb3 | Ruby | Swati24/parking_lot | /lib/parking_lot.rb | UTF-8 | 2,055 | 3.578125 | 4 | [] | no_license | require_relative 'dependencies'
class ParkingLot
class << self
attr_accessor :input_file_path, :output_file_path
def print_welcome_message
STDOUT.puts "Welcome to parking lot program!! You have entered interactive mode"
end
def message_for_command_prompt
p '============================... | true |
2b0b84599da390805f4375af546f4c5cc8cf0318 | Ruby | chaenich/codeclan_w3d2_lab2 | /console.rb | UTF-8 | 440 | 2.75 | 3 | [] | no_license | require('pry')
require_relative('models/property')
property1 = Property.new(
{
'address'=>'2 Test Lane , Test Town',
'value'=>'10000',
'bedrooms'=>'3',
'year_built'=>'1950'
}
)
property2 = Property.new(
{
'address'=>'5 Test Lane , Test Town',
... | true |
9b943a04d50776051fb85b727da29de7e6a1c856 | Ruby | heaphyg/tic | /lib/tic_tac_toe.rb | UTF-8 | 3,860 | 3.765625 | 4 | [] | no_license | require_relative 'ai'
require_relative 'user'
require_relative 'board'
class TicTacToe
attr_reader :ai
attr_accessor :user,:board
def initialize
@user = User.new
@board = Board.new
@ai = AI.new(@board, @user)
end
# start_game collects input and provides output
def start_game
puts "Welcome ... | true |
e7607243e99ffffe14e4fb94443343e944852767 | Ruby | iMARs57/imsoftball | /app/controllers/members_controller.rb | UTF-8 | 13,537 | 2.78125 | 3 | [] | no_license | class MembersController < ApplicationController
require 'time'
require 'date'
require 'active_support/core_ext/integer/inflections'
def dateEN2CH(date)
if date != nil && date.year >= 1912
chinese_number = ["零","一","二","三","四","五","六","七","八","九"]
# for 'year'
year_minguo = date.year -... | true |
c172743bca080d23920ed5f8cf7f8126869e3df3 | Ruby | edisonesc/Learn_To_Code_With_Ruby | /Classes/Class-variables-across-classes.rb | UTF-8 | 645 | 2.578125 | 3 | [] | no_license | class Product
@@product_counter = 0
def self.counter
@@product_counter
end
def initialize
@@product_counter +=1
end
end
class Widget < Product
@@widget_counter = 0
def self.counter
@@widget_counter
end
def initialize
super
@@widget_counter += 1
end
end
class Thingamajig < ... | true |
c1f462d7fc25291d7e1f9e2a2ec42bcf694f8d94 | Ruby | lcpulzone/adventure_2103 | /lib/trail.rb | UTF-8 | 236 | 2.84375 | 3 | [] | no_license | class Trail
attr_reader :name,
:length,
:level
def initialize(trail_params)
@name = trail_params[:name]
@length = trail_params[:length].to_f
@level = trail_params[:level]
end
end
| true |
92b91a64d7e9bc26af794a825506a98a808084e1 | Ruby | isabella232/lumbergh | /lib/github_client.rb | UTF-8 | 668 | 2.6875 | 3 | [
"CC0-1.0",
"LicenseRef-scancode-public-domain"
] | permissive | # https://gist.github.com/afeld/362e064243a5bf293895
class GithubClient
attr_reader :client
def initialize
@client = Octokit::Client.new(access_token: ENV.fetch('GITHUB_TOKEN'))
end
def org_name
# TODO make this configurable
'18F'
end
def teams
self.client.organization_teams(self.org_name... | true |
b055310e149afb1061406a278f35e37cad6c150e | Ruby | Lukazovic/BreakingBad-characters-cli | /models/Character.rb | UTF-8 | 1,148 | 3.578125 | 4 | [] | no_license | class Character
def initialize(character_info)
@id = character_info["char_id"]
@name = character_info["name"]
@birthday = character_info["birthday"]
@occupation = character_info["occupation"]
@img = character_info["img"]
@status = character_info["status"]
@nickname = character_info["nickna... | true |
6e1dda5a43f1fbe23c7fa8f78bd869c14b036c90 | Ruby | wthompson92/ruby-exercises | /command-query/exercises/leather_chair.rb | UTF-8 | 252 | 2.96875 | 3 | [] | no_license | class LeatherChair
def initialize
@faded = false
@exposure = 0
end
def faded?
if @exposure >= 1
@faded = true
elsif @exposure == 0
@faded = false
end
end
def expose_to_sunlight
@exposure += 1
end
end
| true |
e250895b722dda6e4507c60705929cbab2d96b63 | Ruby | NareshGoudJilla/222 | /Fact.rb | UTF-8 | 181 | 3.171875 | 3 | [] | no_license | $fact = 1
$i = 5
while $i != 0 do
$fact = $fact * $i
$i-=1
end
puts("Result= #$fact" )
#$i = 0
#$num = 5
#while $i < $num do
# puts("Inside the loop i = #$i" )
# $i +=1
#end
| true |
48c652a7c6fd533ffd1a7253e7893d5a6856f840 | Ruby | stephan-nordnes-eriksen/ruby_ship | /bin/shipyard/win_ruby/lib/ruby/gems/2.1.0/gems/listen-0.7.3/lib/listen/multi_listener.rb | UTF-8 | 4,574 | 2.6875 | 3 | [
"MIT"
] | permissive | module Listen
class MultiListener < Listener
attr_reader :directories, :directories_records, :adapter
# Initializes the multiple directories listener.
#
# @param [String] directories the directories to listen to
# @param [Hash] options the listen options
# @option options [Regexp] ignore a pa... | true |
b1ab19f2797ed065cb5dfbc552cd1d91b239a48b | Ruby | GautierBlondel/caesar_cipher | /spec/01_multiples_sum_spec.rb | UTF-8 | 952 | 3.421875 | 3 | [] | no_license | require_relative '../lib/01_multiples_sum.rb'
describe "the is_multiple_of_3_or_5? method" do
it "should return TRUE when an integer is a multiple of 3 or 5" do
expect(is_multiple_of_3_or_5?(3)).to eq(true)
expect(is_multiple_of_3_or_5?(5)).to eq(true)
expect(is_multiple_of_3_or_5?(51)).to eq(true)
e... | true |
2c60a41944c7b3e7b179330e0b50ea555baf3b67 | Ruby | aquinomaps/studious-pancake | /web.rb | UTF-8 | 1,386 | 2.984375 | 3 | [] | no_license | require 'sinatra/base'
require 'json'
require 'pp'
require_relative 'snake'
class BattleSnake < Sinatra::Base
before { content_type "application/json" }
get '/' do
{
"color"=> "#fff000",
"head_url"=> "url/to/your/img/file"
}.to_json
end
post '/start' do
json_string = request.body.read... | true |
9745d41275f40feaeac5381edfddfb6c9bd418cb | Ruby | adrianmarino/calculator | /src/ruby/execute.rb | UTF-8 | 146 | 2.734375 | 3 | [
"MIT"
] | permissive | require 'calculator'
input_path = ARGV[0]
puts "input: #{input_path}\noutput:"
Calculator.eval(input_path).each { |result| puts "=> #{result}" }
| true |
c940190a02072763ef7e60bc2ec2c3102d7115a5 | Ruby | danielcampo1/Homes | /lib/Homes/houses.rb | UTF-8 | 339 | 2.765625 | 3 | [
"MIT"
] | permissive | class Homes::Houses
attr_accessor :price, :address, :overview, :url, :all
@@all =[]
def initialize(price, address, overview, url)
@price =price
@address =address
@overview =overview
@url = url
@@all << self
end
def self.all
@@al... | true |
84c7f92510a56f02e107a90cd34a72ccd15a0bf2 | Ruby | davidhyunlee/discountpriority | /app/models/user.rb | UTF-8 | 578 | 2.53125 | 3 | [] | no_license | class User < ApplicationRecord
enum role: [:customer, :admin]
after_initialize :set_default_role, :if => :new_record?
validates :first_name, :last_name, :presence => true
# using bcrypt
has_secure_password
def set_default_role
# if it already exists it's self.role, if it doesn't exist, it's user.
... | true |
bf983682a6ed2e25a8a3388aea5485fad07fd42a | Ruby | ryanfox1985/99_bottles | /ruby/beer_song.rb | UTF-8 | 952 | 3.8125 | 4 | [
"MIT"
] | permissive | class BeerSong
def bottles_text(bottles)
bottles == 1 ? "bottle" : "bottles"
end
def verse(verse_num)
verse = <<-TEXT
1 bottle of beer on the wall, 1 bottle of beer.
Take it down and pass it around, no more bottles of beer on the wall.
TEXT
return verse if verse_num == 1
verse = <<-TEXT
No more ... | true |
e0e50b7c99df50e8a57611ee3e9d02aaae8b53fc | Ruby | maximkoo/ruby-repo | /Ruby Stuff/meth.rb | UTF-8 | 276 | 3.21875 | 3 | [] | no_license | class C1
def m1
puts :m1
end;
end;
c=C1.new
puts Method.instance_methods.grep /to_/
puts Method.instance_methods.grep /call/
cc=C1.instance_method("m1")
puts cc.class.name #UnboundMethod
ccc=c.method("m1")
ccc.call
# t=Time.now
# sleep(1)
# puts (Time.now-t).round | true |
6bd4b582d7c3fdc7c2d81233b87155937527b838 | Ruby | NZenitram/adhoc-slcsp | /test/slcsp_test.rb | UTF-8 | 413 | 2.609375 | 3 | [] | no_license | require_relative 'test_helper'
require_relative '../lib/slcsp.rb'
class SlcspTest < Minitest::Test
def setup
@file_path = './data/slcsp.csv'
end
def test_slcsp_object_contains_data
data = Slcsp.data
assert_equal "64148", data.first[0]
end
def test_slcsp_returns_zipcodes
zipcodes = Slcsp.zip... | true |
dac4fa5d08cbfafb5feb227d09e6e93ccbd27aaf | Ruby | debbhiesoy/sibyl | /test/graph_test.rb | UTF-8 | 1,074 | 2.78125 | 3 | [] | no_license | require "common"
require "sibyl/graph"
describe "Graph validation" do
def graph(source)
Sibyl::Graph.new(source)
end
it "should translate a metadata line" do
g = graph(%{
metadata ivalue 1660
metadata svalue "foo bar"
})
expected = {
ivalue: 1660,
svalue: "foo bar"
}... | true |
a7b1e43c099a5f094dc90838e416b1e6020f7a5f | Ruby | thewpaney/eventreg | /script/update-workshops-name.rb | UTF-8 | 1,505 | 2.65625 | 3 | [] | no_license | require 'csv'
$workshop_spreadsheet_key = "1Ww5qmj89gYDIdB3OCjpM8fvhkFo50mTADvf3eSAjqLQ"
session = GoogleDrive::Session.from_config("config.json")
puts "Downloading workshops"
workshops = session.spreadsheet_by_key($workshop_spreadsheet_key).worksheets[0]
puts "Downloaded workshops"
puts "Updating workshops by name... | true |
749fc73081fb821940e48aa4d8b78d7492f31640 | Ruby | am1ru1/poortego | /lib/poortego_rails/app/models/entity_type.rb | UTF-8 | 4,550 | 2.625 | 3 | [] | no_license | ###############################################
# EntityType ActiveRecord #
# #
# Description: #
# Store name to values associated with Entity #
# #
# Attributes: ... | true |
a288cd090e1c5ea445e119778328dce6a55d0f4d | Ruby | dScarpino/bioruby-maf | /bin/maf_extract_ranges_count | UTF-8 | 1,056 | 2.71875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #!/usr/bin/env ruby
require 'optparse'
require 'ostruct'
require 'bio-maf'
require 'bio-genomic-interval'
options = OpenStruct.new
options.p = { :threads => 1 }
options.passes = 1
OptionParser.new do |opts|
opts.banner = "Usage: maf_extract_ranges_count [options] <maf> <index>"
opts.separator ""
opts.separato... | true |
9a2e337edcec15521f00d700071b6b3e2519f5ae | Ruby | dylanegan/mittwoch.beer | /lib/mittwoch_beer.rb | UTF-8 | 1,618 | 2.921875 | 3 | [] | no_license | require "json"
require "erb"
require "tilt"
module MittwochBeer
Mittwoch = Struct.new(:date, :time, :venues)
Venue = Struct.new(:id, :name, :foursquare_id, :untappd_id, :url)
class MittwochProxy < Array
def previously
@previously ||= self.select { |mittwoch| mittwoch.date < Date.today }
end
... | true |
693794f5b996d34c8c87c40d568bb2fb301b1fa3 | Ruby | germilasaintjean/countdown-to-midnight-noukod-000 | /countdown.rb | UTF-8 | 375 | 3.265625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def countdown
number = 0
loop do
puts "#{number} SECOND(S)!\n"
number += 1
if number == 12
break
return "HAPPY NEW YEAR!"
end
def countdown_with_sleep(5)
real.to_i = 0
loop do
runtime = Benchmark.measure { countdown_with_sleep(5) }
real.to_i += 1
if (runtime.rea... | true |
2dc5f91f237db148dc35666cf729c5dc820e64f8 | Ruby | swachian/xincheping | /app/models/zixun.rb | UTF-8 | 1,988 | 2.53125 | 3 | [] | no_license | class Zixun < ActiveRecord::Base
validates_uniqueness_of :link
belongs_to :editor
# 对新车评咨询文章进行迭代获取,具体内容的扒取由fetch_one_page执行
# 具体有业界http://news.xincheping.com/yejie和新车两个出发点
def self.fetch
start_url = 'http://news.xincheping.com/yejie'
doc = Nokogiri::HTML(open("#{start_url}/p1.html"), nil, "GBK")
... | true |
6de41b91836ce1e4ecad53412abcb9ef221378ce | Ruby | ydkn/raki | /lib/raki/helpers/format_helper.rb | UTF-8 | 1,447 | 2.609375 | 3 | [] | no_license | # Raki - extensible rails-based wiki
# Copyright (C) 2010 Florian Schwab & Martin Sigloch
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option)... | true |
9f9b2f1a9f64512406c1336ea113521f0aaecd4b | Ruby | mkmiec83/freezing-octo-dubstep | /app.rb | UTF-8 | 192 | 2.59375 | 3 | [] | no_license | def myApp
alaMaKota
aKotMaAle
end
def alaMaKotałke
end
def alaMaKota
puts "Ala ma kota #{a}"
end
def aKotMaAle
puts "A kot ma ale"
end
def jakasNazwa
puts "dodanie nowej nazwy"
end
| true |
84d7fbf3c9034c2221017fc877b394264a6f0a48 | Ruby | railsfactory-selva/string_to_number_conversion | /spec/num_sum_spec.rb | UTF-8 | 734 | 2.875 | 3 | [] | no_license | RSpec.describe NumSum do
it "has a version number" do
expect(NumSum::VERSION).not_to be nil
end
it "Should add two numbers" do
expect(NumSum.sum_numbers('2,3')).to eql(5)
end
it "Shoulr return 0 with empty string" do
expect(NumSum.sum_numbers('')).to eql(0)
end
it "Should work with mu... | true |
e2524260c30977c593d3e16902237d88fbe538df | Ruby | benpolinsky/artvsart | /spec/gateways/google_books_gateway_spec.rb | UTF-8 | 2,867 | 2.671875 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe "Google Books Gateway" do
let(:gateway){GoogleBooksGateway.new}
it "returns general search results" do
search_results = gateway.search("Fahrenheit 451")
expect(search_results.first[:title]).to eq "Fahrenheit 451"
end
it "returns results for a different se... | true |
f6764d75f8ac7a44df275ef42db2c81f64102b3d | Ruby | michaelhayman/dogood-api | /lib/ruby/core-extensions/hash.rb | UTF-8 | 5,606 | 3.328125 | 3 | [] | no_license | # encoding: UTF-8
class ::Hash
include Ruby::CoreExtensions::Traversable
# Merges self with another hash, recursively.
#
# This code was lovingly stolen from some random gem:
# http://gemjack.com/gems/tartan-0.1.1/classes/Hash.html
#
# Thanks to whoever made it.
if !defined?(Rails) || Rails.version < ... | true |
2b673763780bc0e1e37d2eb3f29b98632b00cfe6 | Ruby | justinpodur/ruby_fundamentals1 | /exercise3.rb | UTF-8 | 282 | 4.28125 | 4 | [] | no_license | puts "What is your name?"
name=gets.chomp
puts "Hi #{name}!"
puts "And how old might you be, #{name}?"
age=gets.chomp
puts "And what year is it?"
year=gets.chomp
puts "You are #{age} years old, and that means that you were born in the year of our lord #{year.to_i-age.to_i}." | true |
4de5921e540c032fae21220d782a151b706dba64 | Ruby | PierinaTufillaro/TTP-Ruby | /Practica1/ejercicio20.rb | UTF-8 | 119 | 3.03125 | 3 | [] | no_license | num1 = 0
num2 = 1
loop do
puts num1
puts num2 + num1
num2 = num2 + num1
i = num2 + num1
break if i == 4000000
end | true |
fa9b5db170c1b21e6b1c1783eb59f8ce18d02460 | Ruby | mattbradley/mattlang | /lib/mattlang/interpreter/lambda.rb | UTF-8 | 458 | 2.703125 | 3 | [] | no_license | module Mattlang
class Interpreter
class Lambda
attr_reader :args, :type, :frame, :scope, :context, :body
def initialize(args, type, frame, scope, context, body)
@args = args
@type = type
@frame = frame
@scope = scope
@context = context
@body = body
... | true |
1060e70d9d1f3d7ca8d4f7f1599c6bc831337842 | Ruby | Sayya/shiftworking_scheduler | /Doit.rb | UTF-8 | 513 | 2.515625 | 3 | [] | no_license | module Doit
def apply plan
init_date plan["date"]
plan["unit"].each do |ws, persons|
persons.each do |candid|
@table[candid][:shiftline].line[plan["date"]].shift = ws unless candid == nil
end
end
@table.each do |person, val|
val[:shiftline].line[plan["date"]].shift = 0 if va... | true |
db068369d46e90aed4f7e4fa399a58b0841fcf94 | Ruby | trendwithin/screener | /test/lib/briefings_scripts/fetch_breifings_test.rb | UTF-8 | 3,083 | 2.5625 | 3 | [] | no_license | require 'test_helper'
require 'support/fetch_briefings_support'
require_relative '../../../lib/briefings_scripts/fetch_briefings'
module Briefings
class EarningsTest < ActiveSupport::TestCase
def setup
@count = BriefingsEarning.all.count
VCR.use_cassette('loading-briefings-earnings') do
url =... | true |
b20f5a2f5b5562fcada5fccf3ef3a8ccc64b519e | Ruby | kimosiano/test_video_run_run | /rectangle | UTF-8 | 1,841 | 3.1875 | 3 | [] | no_license | #!/usr/bin/env ruby
#To execute your ruby file as script
##################################################################################
######### Test Technique Lundi 29 Juin 2020 ------By----- Video Run Run-----#####
#########--------------------------------------------------------------------#####
######### Sc... | true |
f0a333d2d288ad20388a1b4441cbf9d660954d7f | Ruby | JonLz/ruby-kickstart | /session1/challenge/7_string.rb | UTF-8 | 459 | 3.75 | 4 | [
"MIT"
] | permissive | # given a string, return the character after every letter "r"
#
# pirates_say_arrrrrrrrr("are you really learning Ruby?") # => "eenu"
# pirates_say_arrrrrrrrr("Katy Perry is on the radio!") # => "rya"
# pirates_say_arrrrrrrrr("Pirates say arrrrrrrrr") # => "arrrrrrrr"
def pirates_say_arrrrrrrrr(string)
str=... | true |
6e43fec03d17fe411d387a7be8cf8fda21be8de9 | Ruby | SnowballSH/HumanScript | /samples/fib/fib.rb | UTF-8 | 222 | 3.59375 | 4 | [] | no_license | def fib(n)
a = 0
b = 1
if n < 0
puts('bad input')
elsif n <= 1
puts n
else
(n - 1).times do
c = a + b
a = b
b = c
end
puts b
end
end
fib 0
fib 1
fib 9
fib 999
fib 123_456
| true |
bc219341b1c649aac3f51e009cee0d4bfe1c0e82 | Ruby | kitkat119/tic_tac_toe | /spec/printer_spec.rb | UTF-8 | 1,072 | 3.078125 | 3 | [] | no_license | describe Printer do
subject(:printer) { described_class.new(checker) }
subject(:printer2) { described_class.new(checker2) }
subject(:printer3) { described_class.new(checker3) }
let(:checker) { double :checker, board: %w[O O O X X O X O X], current_weapon: "O", winning_combo?: true }
let(:checker2) { double :... | true |
2456bf5ac80f93fece1438dbff442afeee6f3f72 | Ruby | ZeddBox/faker_fr | /test/faker/default/test_faker_university.rb | UTF-8 | 863 | 2.640625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require_relative '../../test_helper'
class TestFakerUniversity < Test::Unit::TestCase
def setup
@tester = Faker::University
@alphabet = Faker::University.greek_alphabet
end
def test_prefix
assert @tester.prefix.match(/\w+\.?/)
end
def test_suffix
assert @teste... | true |
34a806ff9f8d4aa0eaf5e56dfe006061d28544ba | Ruby | ga-wolf/WDi14-Homework | /SigmundBautista/week_05/warmup_robot_name/main.rb | UTF-8 | 344 | 3.46875 | 3 | [] | no_license | class Robot
def initialize
@name = generate_name
end
def generate_name
@name = "#{generate_letters} #{generate_numbers}"
end
def generate_letters
letters = ("A" .. "Z").to_a.sample(2)
end
def generate_numbers
numbers = (1 .. 9).to_a.sample(3)
end
def name
@name
end
end
... | true |
5320fd2448c652737b4b83d1b45185c42048b0d9 | Ruby | mariomanzoni/Enterprise-Recipes-with-Ruby-and-Rails | /code/ecommerce/demoshop/vendor/plugins/active_merchant/test/unit/avs_result_test.rb | UTF-8 | 2,006 | 2.953125 | 3 | [
"MIT"
] | permissive | #---
# Excerpted from "Enterprise Recipes for Ruby and Rails",
# published by The Pragmatic Bookshelf.
# Copyrights apply to this code. It may not be used to create training material,
# courses, books, articles, and the like. Contact us if you are in doubt.
# We make no guarantees that this code is fit for any purpose... | true |
7cc6bf3262c02e46ed18685976627bbe109222ff | Ruby | meganho/programming-exercise | /31-hash.rb | UTF-8 | 640 | 3.25 | 3 | [] | no_license | require 'benchmark'
a1 = Array.new(1000000){ rand(100)}
a2 = a1 * 10
def find_dup_v1(arr)
unique_arr = []
dup_arr = []
arr.each do |a| # 0(N)
if unique_arr.include?(a) # 0(N)
dup_arr << a
else
unique_arr << a
end
end
return dup_arr
end
def find_dup_v2(arr)
unique_hash = {}
du... | true |
52b74ac86e925263ce234e0a6c73899d38f0c768 | Ruby | tsykoduk/pssh | /lib/push.rb | UTF-8 | 128 | 2.640625 | 3 | [
"LicenseRef-scancode-warranty-disclaimer",
"Apache-2.0"
] | permissive | def execute_push(file, target)
puts "you attempted to push #{file} to #{target}. Sadly, that function is not written yet."
end | true |
9f26350b8c66c87f7dc1872fb4c220a805761b2a | Ruby | ayush-amura/texi_service | /lib/taxi.rb | UTF-8 | 1,471 | 3.390625 | 3 | [] | no_license | require 'passenger'
require 'guide'
class Taxi
attr_accessor :driver_name,:vehicle_type,:rate,:vehicle_number,:driver_contact
def initialize vehicle_type,vehicle_number,driver_name,driver_contact,rate,km
@vehicle_type = vehicle_type
@vehicle_number = vehicle_number
@driver_name = driver_name
... | true |
8c4ac4f61b43d23105dc7af1a111ddc373fdb159 | Ruby | mogest/prawn-svg | /lib/prawn/svg/font.rb | UTF-8 | 1,821 | 2.796875 | 3 | [
"MIT"
] | permissive | class Prawn::SVG::Font
GENERIC_CSS_FONT_MAPPING = {
"serif" => "Times-Roman",
"sans-serif" => "Helvetica",
"cursive" => "Times-Roman",
"fantasy" => "Times-Roman",
"monospace" => "Courier"
}
attr_reader :name, :weight, :style
def self.weight_for_css_font_weight(weight)
case ... | true |
2e21004e5ee5a74461f84cb44ee75130b5be3865 | Ruby | packsaddle/ruby-env_pull_request | /lib/env_pull_request/base.rb | UTF-8 | 2,741 | 2.796875 | 3 | [
"MIT"
] | permissive | module EnvPullRequest
# Pull request information object from environment variables
class Base
include NaturalNumberString
attr_reader :pull_request_id
# @!attribute [r] pull_request_id
# @return [Integer, nil] pull request id or nil
# Build pull request information object from environment va... | true |
8f57f449e23adb46da10bb536e0ec6d78f067d14 | Ruby | ssiarules/pokemon-scraper-online-web-pt-011419 | /lib/pokemon.rb | UTF-8 | 1,151 | 3.671875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Pokemon
attr_accessor :id, :name, :type, :db, :hp
def initialize (id:, name:, type:, db:, hp: nil)
@id = id
@name = name
@type = type
@db = db
@hp = hp
end
def self.save(name, type, db)
db.execute("INSERT INTO pokemon (name, type) VALUES (?, ?);)", name, type)
end
def self.... | true |
9af78b8599d152b9e353946d00e1e0a24fe813a1 | Ruby | amrabdelwahab/intercom_customers_exercise | /spec/models/customer_spec.rb | UTF-8 | 1,432 | 3.109375 | 3 | [] | no_license | require 'spec_helper'
require './lib/models/customer'
describe Models::Customer do
let(:user_id) { 12 }
let(:name) { 'Christina McArdle' }
let(:location) { Models::Location.new('-6.043701', '52.986375') }
subject { described_class.new(user_id, name, location) }
describe '#<=>' do
context 'when two custo... | true |
c024e7653ff7b26f5023ff7b64d459cd5a678ad1 | Ruby | jk-me/oo-cash-register-v-000 | /lib/cash_register.rb | UTF-8 | 698 | 3.375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class CashRegister
attr_accessor :total, :old_total, :discount, :items
def initialize(discount=0)
@total=0
@discount=discount
@items=[]
end
def total
@total
end
def add_item(item,price,quantity=1)
@old_total=@total
@total+=price*quantity
while quantity >=1
@items << it... | true |
e424f264e7286f9889f397f19f1fa2550b55e2ed | Ruby | brentmulligan/smartystreets-ruby-sdk | /test/smartystreets_ruby_sdk/international_street/test_international_candidate.rb | UTF-8 | 5,717 | 2.796875 | 3 | [
"Apache-2.0"
] | permissive | require 'minitest/autorun'
require './lib/smartystreets_ruby_sdk/international_street'
require './lib/smartystreets_ruby_sdk/native_serializer'
class TestInternationalCandidate < Minitest::Test
def test_all_fields_filled_correctly
response_payload = "[{\"organization\":\"1\",\"address1\":\"2\",\"address2\":\"3\"... | true |
5315859924e1bfacd99ee1f9bb21d30540284571 | Ruby | jplao/super_sports_games | /lib/event.rb | UTF-8 | 1,377 | 3.765625 | 4 | [] | no_license | require 'pry'
class Event
attr_reader :name, :ages
def initialize(name, ages)
@name = name
@ages = ages
end
def max_age
ages.sort.last.to_i
end
def min_age
ages.sort.first.to_i
end
def average_age
sum = ages.sum
number = ages.count
sum/number.to_f.round(2)
end
def s... | true |
5f08e53671d95ba3d3859c638a169c068042dc50 | Ruby | wisq/cache-fm | /bin/service.rb | UTF-8 | 1,983 | 2.671875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
$LOAD_PATH << File.dirname(__FILE__) + '/..'
require 'lib/manager'
$stdout.sync = true
$stderr.sync = true
# This is a daemonised version for running
# as a service via e.g. runit.
class CachefmService
def login_info
# Set $CACHE_FM_LOGIN to "username:md5-of-password"
return ENV['CACHE... | true |
56f7efd116e48eed0afe27c40fea034a1673f0ba | Ruby | pumpchaser/esports | /lib/tasks/scrape.rake | UTF-8 | 1,292 | 2.640625 | 3 | [] | no_license | namespace :scrape do
desc 'Scrape for pros'
task pros: :environment do
require 'nokogiri'
require 'open-uri'
puts "Fetching and updating Players:"
puts "Source: http://dota2.gamepedia.com/Professional_players"
url = "http://dota2.gamepedia.com/Professional_players"
doc = Nokogiri::HTML(ope... | true |
d0509d35b542852e773387ab9bd498bde95d3fdc | Ruby | wardymate/round-two-feb-20 | /spec/wolf_on_commercial_street_spec.rb | UTF-8 | 642 | 3.3125 | 3 | [] | no_license | require 'wolf_on_commercial_street'
describe Wolf do
wolf = Wolf.new
stockprice = [10,2,5,8,9,1,6,7,8,10]
result = {buy_day: 5, sell_day: 9}
stockprice1 = [10,1,5,8,9,1,6,7,8,6]
result1 = {buy_day: 1, sell_day: 4}
it 'should accept an array' do
expect(wolf.input([1,2,3])).to eq [1,2,3]
end
it '... | true |
2c290f2960b47c8c021e2da89bb1563ac064c259 | Ruby | tarasbobak/SoftServeITA | /task3.rb | UTF-8 | 348 | 3.21875 | 3 | [] | no_license | # Task 555
n = 5
i = 0
array = Array.new(1)
array_prev = []
while i < n
k = 0
while k < (i + 1)
if k == 0
array[k] = 1
elsif k == array.length - 1
array[k] = 1
else
array[k] = array_prev[k - 1] + array_prev[k]
end
k += 1
end
puts array.inspect
i += 1
array_prev = array
... | true |
07541c3e0b8ee7ca738eab9bdc680dd3de55efc6 | Ruby | bougyman/BougyBot | /lib/bougy_bot/plugins/topiclock.rb | UTF-8 | 1,108 | 2.515625 | 3 | [] | no_license | require 'cinch'
# Lock the topic for 2 minutes after a topic change
module BougyBot
# Plugin Namespace
module Plugins
# The topiclock functions
class Topiclock
include ::Cinch::Plugin
include ::Cinch::Extensions::Authentication
TIMEOUT = 360
match(/tlock (on|off)$/)
match(/topi... | true |
8c44505e8c0a23bda2110dd069b005ec15e00b88 | Ruby | jhannah/sandbox | /oobbles/rps/rps_driver.rb | UTF-8 | 1,633 | 4.34375 | 4 | [] | no_license | require "./rps_game_class.rb"
puts "Welcome to the game. Let's play Rock Paper Scissors, Spock, Lizard! "
puts "How many games would you like to play? "
#instantiates a new instance of the game class and passes it the number #indicated by the user.
game1 = Game.new(gets.chomp.to_f)
#asks for the name of each player... | true |
562d541ea08ec155b6c2f16a0793afc4dfe1d2fa | Ruby | chwitta9000/blocmetrics | /app.rb | UTF-8 | 2,215 | 2.625 | 3 | [] | no_license | # app.rb
require 'sinatra'
require 'sinatra/activerecord'
require 'sinatra/flash'
require 'sinatra/redirect_with_flash'
require './environments'
require './models/user.rb'
require './models/application.rb'
require './models/event.rb'
enable :sessions
# Helper methods
helpers do
include Rack::Utils
alias_method... | true |
f5c3a993fd5667f834df045ae54eaca05ce2f7de | Ruby | JCNapier/museum_2110 | /spec/exhibit_spec.rb | UTF-8 | 409 | 2.78125 | 3 | [] | no_license | require 'rspec'
require './lib/patron'
require './lib/exhibit'
describe Exhibit do
let(:exhibit) {Exhibit.new({name: "Gems and Minerals", cost: 0})}
let(:patron_1) {Patron.new("Bob", 20)}
it 'exists' do
expect(exhibit).to be_an_instance_of(Exhibit)
end
it 'attributes' do
expect(e... | true |
9910bbceeef3acb587786c0195a03e10bbacf8f0 | Ruby | hassamali/exercism-ruby | /resistor-color/resistor_color.rb | UTF-8 | 169 | 2.75 | 3 | [] | no_license | class ResistorColor
COLORS = %w[black brown red orange yellow green blue violet grey white]
def self.color_code(color_code)
COLORS.index(color_code)
end
end
| true |
3412482f25026d5e68d511f27a36cee4eb43da12 | Ruby | wpenn/nitrous | /Day2/Ruby/Development/Labs/UberX-Calculator/uberX-calculator.rb | UTF-8 | 2,477 | 4.21875 | 4 | [] | no_license | #methods
def calculate_x(minutes, miles, cancel)
if cancel
final_price = 5
else
final_price = 2.55
final_price = final_price + (minutes * 0.35)
final_price = final_price + (1.75 * miles)
end
end
def calculate_suv(minutes, miles, cancel)
if cancel
final_price = 10 #cancellation fee
else
... | true |
a1cf7d3f00f90646b145377849029874baa369ba | Ruby | brandonfang/aa-classwork | /w4d3/chess_part_two/queen.rb | UTF-8 | 276 | 2.875 | 3 | [] | no_license | require_relative "piece.rb"
require_relative "slideable.rb"
class Queen < Piece
include Slideable
# def initialize
# super()
# end
def symbol
:Q
end
private
def move_dirs
horizontal_dirs + diagonal_dirs
end
end | true |
8c709dc1a1c57613e5ae0b82856905db0ab61634 | Ruby | preetiacharya/DCT-ecommerce | /app/models/product.rb | UTF-8 | 1,441 | 2.5625 | 3 | [] | no_license | class Product < ActiveRecord::Base
has_many :reviews
has_many :cart_line_items
belongs_to :category
belongs_to :sub_category
has_many :order_products
#inbuilt validations
validates_presence_of :name, :price, :category_id, :description, :stock, :sub_category_id
validates_numericality_of :price, great... | true |
cc11eff1776a80e07f06cdab3ef3816241026d97 | Ruby | ynonp/ruby-rails-course-june-2019 | /day1/syntax/try_except.rb | UTF-8 | 293 | 3.8125 | 4 | [] | no_license | def read_number_or_retry(prompt = "Please select a number: ")
puts prompt
loop do
return Integer(gets)
rescue ArgumentError
puts "Sorry, not a number. Try again..."
end
end
begin
n1 = read_number_or_retry
n2 = read_number_or_retry
puts "#{n1} / #{n2} = #{n1 / n2}"
end | true |
5c1584e9bb98525cefe5de1923011af222789c06 | Ruby | rozz120/ruby-object-attributes-lab-bootcamp-prep-000 | /lib/dog.rb | UTF-8 | 194 | 3.140625 | 3 | [] | no_license | class Dog
def name=(nameOfDog)
@name = nameOfDog
end
def name
@name
end
def breed=(breedOfDog)
@breed = breedOfDog
end
def breed
@breed
end
end | true |
a177b3941635c6dcea3e5198289a1aad7a566dab | Ruby | erniebrodeur/bini | /lib/bini/optparser.rb | UTF-8 | 1,507 | 3.015625 | 3 | [
"MIT"
] | permissive | require 'optparse'
module Bini
# An extension of [OptionParser] that behaves like a hash, with saving, loading, and
# mashing in other hashs.
class OptionParser < ::OptionParser
def initialize
super
@options = {}
on("-V", "--version", "Print version") { |version| @options[:version] = true}... | true |
6d567b877021ac9aabc6831ca21515ec736d760b | Ruby | zhenkyle/shadowsocks_ruby | /lib/shadowsocks_ruby/protocols/protocol.rb | UTF-8 | 5,694 | 2.8125 | 3 | [
"MIT"
] | permissive | module ShadowsocksRuby
# Protocols are layered. Each layer know nothing about other layers.
# (data) | TOP: HTTP, FTP, STMP ... ^ (data)
# Pack | layer 3 protocol packet | Unpack
# Encrypt | layer 2 protocol cipher | Decrypt
# Obfuscate | layer 1 p... | true |
7ea8be6b374f2bdb6143cf2562f8d006472a1b05 | Ruby | WilliamMurray322/KarelRTuesday | /tasks/t_8_q_3.rb | UTF-8 | 991 | 2.640625 | 3 | [] | no_license | require_relative "../karel/ur_robot"
require_relative "../mixins/move_1"
require_relative "../mixins/sensor_pack"
class Qrandom < UrRobot
include Move1
include SensorPack
def change_row_left
turn_left
move
turn_left
end
def change_row_right
turn_right
move
turn_right
end
def craw... | true |
ab60354c2f702f74623736e3524a0cf61b07048d | Ruby | jtgray6/programming-univbasics-nds-nds-to-insight-with-methods-denver-web-111819 | /lib/nds_extract.rb | UTF-8 | 885 | 3.53125 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'directors_database'
require 'pp'
require 'pry'
# Write a method that, given an NDS creates a new Hash
# The return value should be like:
#
# { directorOne => allTheMoneyTheyMade, ... }
def directors_totals(nds)
result = {}
total=[]
row=0
while row<nds.length do
column=0
total[row]=0
... | true |
fa8310ed2b3e682c4b329b3771571527c622fc52 | Ruby | g33k-chick/seatyourself | /app/models/restaurant.rb | UTF-8 | 420 | 2.546875 | 3 | [] | no_license | class Restaurant < ActiveRecord::Base
has_many :reservations
has_many :users, through: :reservations
validates :name, :address, :website, :phone, :capacity, presence: true
validates :capacity, numericality: {only_integer: true}
def available(party_size, time_slot)
reservations_for_time = reservations.where(t... | true |
eb2758e5f8e1a67015357b7eff13dd33546f64f6 | Ruby | dono-greeff/nonnative | /lib/nonnative/pool.rb | UTF-8 | 1,380 | 2.609375 | 3 | [
"Unlicense"
] | permissive | # frozen_string_literal: true
module Nonnative
class Pool
def initialize(configuration)
@configuration = configuration
end
def start(&block)
[servers, processes].each { |t| process(t, :start, :open?, &block) }
end
def stop(&block)
[processes, servers].each { |t| process(t, :st... | true |
46122db2c7e609780ba406c88b62acb9249bb67d | Ruby | imacbeth/iona_macbeth_pda_evidence | /coding _tests/static_dynamic_testing/specs/card_spec.rb | UTF-8 | 694 | 3.234375 | 3 | [] | no_license | require_relative '../testing_task_2.rb'
require_relative '../card.rb'
require 'minitest/autorun'
require('minitest/rg')
class TestCard < MiniTest::Test
def setup
@card1 = Card.new("Clubs", 1)
@card2 = Card.new("Hearts", 10)
@card_game = CardGame.new
@cards = [@card1, @card2]
end
def test_check_... | true |
5e5b00c5bc87191030b936d04e23b514d6d79596 | Ruby | jaapie/how-many | /spec/integration_spec.rb | UTF-8 | 2,602 | 3.265625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'app'
require 'version'
RSpec.describe 'how-many' do
let(:usage) do
<<~USAGE
Usage:
./how-many <units> in NUMBER <units> [options]
./how-many <units> till <time|date|datetime> [options]
units is one of the following: seconds, minutes, days, w... | true |
e3f6aca77c4e2bc7c8384863d7b421078bee3950 | Ruby | tombh/human-computer | /lib/procesor/simulated_procesor.rb | UTF-8 | 5,960 | 3.515625 | 4 | [] | no_license | module HumanComputer
# Simulate the activities a human would make. Used for *testing* only.
# The Human Processor is completely carried out by humans, so we need this to test that our computer
# and assembler work.
class SimulatedProcessor < Processor
ZERO = '00000000'
ONE = '00000001'
THREE = '0... | true |
ece864e796ebd6a60abf05eea7059c4caaa64c52 | Ruby | petertseng/cryptopals-rb | /23_clone_mt19937.rb | UTF-8 | 1,384 | 3.15625 | 3 | [
"Apache-2.0"
] | permissive | require_relative 'assert'
require_relative 'mt19937'
class Untemper < MT19937
def self.untemper(x)
x = unright(x, L, FULL_MASK)
x = unleft(x, T, C)
x = unleft(x, S, B)
unright(x, U, D)
end
def self.unright(n, shift, nd)
nbits = n.digits(2)
ndbits = nd.digits(2)
bits = nbits.dup
(... | true |
74f90bdbcb5cee1966909b2e81043cf27783dcd4 | Ruby | atarukodaka/fisk8_result_viewer | /app/parsers/competition_parser.rb | UTF-8 | 4,141 | 2.640625 | 3 | [] | no_license | class CompetitionParser < Parser
def parse_summary(site_url, encoding: nil)
page = get_url(site_url, encoding: encoding) || return
city, country = parse_city_country(page)
data = {
name: parse_name(page),
city: city,
country: country,
site_url: site_url,
time_schedule: parse... | true |
6315d1b716bb933745ab5a77a1b2404941230e4c | Ruby | CharleyL94/Pet_store | /models/pets.rb | UTF-8 | 391 | 2.8125 | 3 | [] | no_license | require( 'pg' )
require_relative('../db/sql_runner')
class Pet
attr_reader(:id, :name, :type)
def initialize( options )
@id = options[ 'id' ].to_i
@name = options[ 'name' ]
@type = options[ 'type' ]
end
def save
sql = "INSERT INTO pets (name, type) VALUES (' #{ @name }', '#{ @type }') RETURNING *;"
p... | true |
43171966110b708d893e2cdd93ca206012d8aa1c | Ruby | yendai-vo/keys-of-hash-prework | /lib/keys_of_hash.rb | UTF-8 | 190 | 3.140625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Hash
def keys_of(*arguments)
result = []
self.map { |animal, location|
if arguments.include?(location)
result.push(animal)
end
}
result
end
end
| true |
fb7d4c73d8fc0dec175ee745fad53af375645e99 | Ruby | blitline-dev/commonlogs | /lib/cl_logger.rb | UTF-8 | 1,999 | 2.625 | 3 | [] | no_license | # ------------------
# Custom Logger
# ------------------
class CLLogger
# --------------
# Custom Logger
# This isn't meant to meaningfully handle STDOUT,
# but rather track 'important' items. Avoids problems
# with outputting to STDOUT AND differing log files,
# as well as issues with attaching/detaching ... | true |
8525106b23b261cf6c747a9b817154872d9a833e | Ruby | lemoncurd/RapidFTR | /spec/controllers/checks_authentication_spec.rb | UTF-8 | 3,549 | 2.546875 | 3 | [] | no_license | require 'spec_helper'
describe ChecksAuthentication, :type => :normal do
class FakeController
include ChecksAuthentication
attr_reader :cookies, :request
def initialize
@cookies = {}
@request = OpenStruct.new(:headers => {})
end
end
before :each do
@controller = FakeControlle... | true |
de90b99bf90b30a70c4e7ecca1c26cc783898084 | Ruby | stamppot/cbcl4 | /lib/spss_labels.rb | UTF-8 | 655 | 2.84375 | 3 | [] | no_license | class SpssLabels
attr_accessor :item_choices
# def initialize(item_choices)
# self.item_choices
# end
def variable_labels(codebook)
labels = ["VARIABLE LABELS"]
codebook.codes.each do |code|
labels << " #{code.variable} \"#{code.description}\""
end
labels
end
def value_l... | true |
1b42405332eb7c52e68f913f7cdf4d77a3c03494 | Ruby | mazenswar/green_grocer-dumbo-web-career-010719 | /grocer.rb | UTF-8 | 1,422 | 3.234375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require "pry"
def consolidate_cart(cart)
# code here
conCart = {}
cart.map do |e|
e.map do |k,v|
v[:count] = cart.count(e)
end
end
cart.uniq!
cart.each do |e|
e.each do |k,v|
conCart.merge!(k => v)
end
end
conCart
end
def apply_coupons(cart, coupons)
coupons.each do |h|
... | true |
eae8b5ee70a1a4fdd3086dd35d30b549c8d27a5c | Ruby | villu164/projecteuler | /problem19.rb | UTF-8 | 752 | 3.625 | 4 | [] | no_license | =begin
Counting Sundays
Problem 19
You are given the following information, but you may prefer to do some research for yourself.
1 Jan 1900 was a Monday.
Thirty days has September,
April, June and November.
All the rest have thirty-one,
Saving February alone,
Which has twenty-eight, rain or shine.
And on leap years, t... | true |
36a837228b4aea4ae33fb973b79b89de8c434323 | Ruby | Luftgekuhlt-com/luft | /app/models/concerns/store_with_type.rb | UTF-8 | 2,661 | 3.078125 | 3 | [] | no_license | module StoreWithType
extend ActiveSupport::Concern
TYPES = {
date: ActiveRecord::Type::Date,
boolean: ActiveRecord::Type::Boolean,
integer: ActiveRecord::Type::Integer
}
VALIDATIONS = {
integer: ->(value) { value.present? }
}
class_methods do
#
# .store_accessor_with_type allows y... | true |
1406d2dc74f6bcaf433bb91902c9bba89b850ad1 | Ruby | sambrady0652/poker_checker | /lib/helpers/validator.rb | UTF-8 | 1,277 | 3.6875 | 4 | [] | no_license | module Validator
# These helper methods validate both the inputed string from the form and the hash it eventually becomes
VALID_SUITS = %w(C D H S).freeze
VALID_VALUES = (1..14).freeze
def invalid_input?(card_string)
# Early exit for obvious problems -- no input
return true if ca... | true |
aa2f932b7d474d9b703b2ef050f955f55299ae05 | Ruby | glennmartinez/confluence-ruby-populator | /server.rb | UTF-8 | 983 | 2.671875 | 3 | [] | no_license | require 'xmlrpc/client'
#require 'names'
confluence = XMLRPC::Client.new2("http://localhost:8090/rpc/xmlrpc").proxy("confluence2")
token = confluence.login("admin", "admin")
# user = {
# "name" => user_name,
# "fullname" => full_name,
# "email" => email
# }
# confluence.addUser(token, user, user_name)
f = File.... | true |
a6a90fdf4dc175baae87ac430ae2917071d6f3e6 | Ruby | erikthiem/crud-app | /backend/routes/user.rb | UTF-8 | 1,987 | 2.703125 | 3 | [] | no_license | require_relative "../controllers/authentication.rb"
require 'json'
# Get all users
get '/users' do
users = User.all
return users.to_json
end
# Get a specific user
get '/user/:id' do
id = params[:id]
user = User.get(id)
get_item(user)
end
# Create a new user
post '/users' do
username = ... | true |
04be8810472e1767f85bd615106475d4237338e3 | Ruby | cesarbarone/image_resize_script | /script.rb | UTF-8 | 375 | 2.578125 | 3 | [] | no_license |
def resize
Dir.glob(['*.jpg', '*.JPG' ]).each do |image|
puts "converting #{image}..."
`convert -resize 640X480 #{image} #{image}`
end
end
def merge
Dir.glob(['*.jpg']).each do |image|
puts "merging #{image}..."
`convert bg.jpg #{image} -gravity center -composite -compose over #{image}`
... | true |
2feebd7fad016e48a933f60a4ec019be5eb12f02 | Ruby | nhahn/amcreamery | /app/models/assignment.rb | UTF-8 | 2,805 | 2.640625 | 3 | [] | no_license | class Assignment < ActiveRecord::Base
# ----------------------
before_create :end_previous_assignment
# Relationships
# ----------------------
belongs_to :store
belongs_to :employee
has_many :shifts
# Validations
# ----------------------
# check that all required fields are there
validates_pres... | true |
0f9865d6f7b2446e14b90f2fe5c6af5ca2feb809 | Ruby | nickurban/change | /change_maker_spec.rb | UTF-8 | 1,578 | 3.234375 | 3 | [] | no_license | require_relative 'change_maker'
describe ChangeMaker do
describe ".make_change" do
it "creates change for 1 cent" do
result = ChangeMaker.make_change(1)
expect(result).to match_array([1])
end
it "creates change for 6 cents" do
result = ChangeMaker.make_change(6)
exp... | true |
56e910ce6d0baf14a5d8b75ca50075bb35f468aa | Ruby | jonsuh/jonsuh.com | /_plugins/round_filter.rb | UTF-8 | 630 | 3.359375 | 3 | [
"MIT"
] | permissive | # Round a float to a given precision in decimal digits
#
# Github: https://github.com/freshmango/jekyll-round-filter
#
# input - The number to round
# precision - Precision in decimal digits (default 0 digits)
#
# Returns the rounded number.
#
# Usage:
#
# {{ float | round: precision }}
#
# Examples:
#
# {{ 512.4562 | ... | true |
ba3d72b062c165249f3e8edc06096b19a458525c | Ruby | superedriver/algo_ruby | /src/sorting/heap.rb | UTF-8 | 364 | 3.28125 | 3 | [] | no_license | require './src/data_structures/heap'
def heap_sort_min(array)
heap = Heap_Min.new(array)
result = []
until heap.empty?
result.push(heap.extract_min)
end
result
end
def heap_sort_max(array)
size = array.size
heap = Heap_Max.new(array)
result = Array.new(size)
(size-1).downto(0) do |i|
resu... | true |
55750dff1e15ed52d87405c15eae4ec8d3b68256 | Ruby | DomSheehy/mfpwcg | /spec/sub_tree_node_spec.rb | UTF-8 | 2,825 | 2.984375 | 3 | [] | no_license | require 'spec_helper'
describe SubTreeNode do
describe '#create' do
it 'should create a new node' do
cat_item = ItemNode.new('cats', 0)
dog_item = ItemNode.new('dogs', 0)
node = SubTreeNode.new(cat_item)
expect(node.item_node.item).to eq('cats')
node = SubTreeNode.new(cat_item, Sub... | true |
dc4294c99cdcc52bd2635387e995479b1a4c68db | Ruby | wizardwerdna/juditourney | /app/models/player.rb | UTF-8 | 1,508 | 2.609375 | 3 | [] | no_license | class Player < ActiveRecord::Base
has_many :entries
has_many :tournaments, :through => :entries
has_many :league_tournaments, :through => :entries, :source => :tournament, :include => :league
validates_uniqueness_of :first, :scope => :last
validates_presence_of :last
def self.split_names_from(string)
... | true |
a62cf44975b9815ded54b8f57b8209599706d4fb | Ruby | haanhduclinh/s3-to-ftp | /lib/ftp.rb | UTF-8 | 3,413 | 2.953125 | 3 | [] | no_license | class Ftp
%i[host username password port current_path].each do |attribute|
attr_accessor attribute
end
TYPE_FOLDER = 1
TYPE_FILE = 2
BACK = '.'.freeze
LEVEL_UP = '..'.freeze
def initialize(host:, username:, password:, port: 21)
@current_path = '.'
@host = host
@username = username
@... | true |
0d020a575c323cc0ef7a877a5a4600d9fd22c0e4 | Ruby | elomar/tem-cafe | /command_parser.rb | UTF-8 | 987 | 2.953125 | 3 | [] | no_license | require 'forwardable'
class CommandParser
def initialize(whitelist:)
@whitelist = Whitelist.new(whitelist)
end
def call(command)
@whitelist.each do |action_definition|
args = decompose_command(*action_definition, command)
return args if args
end
nil
end
private
def decompose... | true |
7fc9f315bc5ce223d4923346dfb68d7f8505d442 | Ruby | derekle/ruby-oo-object-relationships-has-many-lab | /lib/song.rb | UTF-8 | 958 | 3.34375 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class Song
attr_accessor :name
attr_reader :artist
@@all = Array.new
def initialize(input)
p "initialize Song with name: [#{input}]"
######################
@name = input
@artist = nil
######################
@@all << self
end
def artist=(input... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.