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
893236cac36898750e1bcd3aa964244b00a00c66
Ruby
RomanSipyak/learn_ruby
/12_rpn_calculator/rpn_calculator.rb
UTF-8
1,107
3.96875
4
[]
no_license
class RPNCalculator def initialize @stack = [] end def value @stack[@stack.size - 1] end def push(value) @stack.push(value) end def plus if @stack.empty? raise 'calculator is empty' else @stack.push(@stack.pop + @stack.pop) end end def minus if @stack.empty?...
true
b47094533dd27268fc32a7bdf65762c572540a92
Ruby
aug92326/xipxy
/db/seeds.rb
UTF-8
540
2.65625
3
[]
no_license
puts "Seeding data" def load_rb(seed) require 'yaml' puts "#{Time.now} | Execute seed #{seed.inspect}" require "#{seed}" klass_name = ("seed_" + File.basename("#{seed}", '.rb').split('-').last).classify klass = klass_name.constantize klass.send(:seed) end if ENV['SEED_FILES'].present? seed_files = ENV['...
true
d44226d215b6acb09eb11e5256d6221de74d2fde
Ruby
ULL-ESIT-LPP-1819/tdd-Zanuro
/spec/Persona_spec.rb
UTF-8
3,953
2.984375
3
[]
no_license
RSpec.describe Etiqueta do before :each do @in1 = Individuo.new("Juan") @in2 = Individuo.new("Maria") @et1 = Paciente.new("Juan",72.3,182.3,'1',43,84.2,95.5) @et2 = Paciente.new("Maria",62.2,167.2,'0',38,70.2,74) @et3 = Paciente.new("Jose",97.3,178.2,'1',31,88,98.4) @et4 = Paciente.new("...
true
04b6e1aeceabc95bfae9cde8c96363d058a4b50a
Ruby
ryohorie/jasrac-report
/jasrac-report.rb
UTF-8
2,109
2.546875
3
[]
no_license
require "google/cloud/bigquery" require 'net/http' require 'uri' if ARGV.size() < 2 then print "Usage: script.rb year month\n" return end master = JSON.parse(Net::HTTP.get URI.parse('https://song-book.info/v3/prod-master-detail.json')) songs = master["songs"] bigquery = Google::Cloud::Bigquery.new( project: "son...
true
122c538006bb4881380fb1b26cb3c1b11dc07a5f
Ruby
jakeheft/whether_sweater
/spec/facades/forecasts_facade_spec.rb
UTF-8
2,797
2.515625
3
[]
no_license
require 'rails_helper' describe ForecastsFacade do it '.get_forecasts()' do location = 'fairbanks,ak' forecast = ForecastsFacade.get_forecasts(location) expect(forecast).to be_a(Forecast) expect(forecast.current_weather).to be_a(CurrentWeather) expect(forecast.daily_weather).to be_an(Array) expect(foreca...
true
d7f5eda547f804fe20f4ef0ac2c73ce4f1ff9cfe
Ruby
jwperry/mod2_ruby_challenges
/pig_latin_translator/lib/pig_latin_translator.rb
UTF-8
573
4.1875
4
[]
no_license
require 'pry' def translate(phrase) if is_a_vowel?(phrase[0]) phrase + "-way" else convert(phrase) end end def is_a_vowel?(phrase) ["a", "e", "i", "o", "u"].include?(phrase[0].downcase) end def convert(phrase) leading_consonants = [] leading_consonants << phrase.slice!(0) until is_a_vowel?(phrase...
true
90f480d68286cb54631cd81f06bf8142c37d0f37
Ruby
amandamfielding/chess
/sliding_piece.rb
UTF-8
1,247
3.1875
3
[]
no_license
require 'byebug' require_relative 'piece' module SlidingPiece def moves(start_pos) possible_moves = [] self.class::MOVES_DIRECTIONS.each do |move| end_pos = (start_pos[0] + move[0]), (start_pos[1] + move[1]) until @grid[end_pos].class != NullPiece || end_pos.all? { |el| el.between?(0, 7)}...
true
ce72f45fbcface814e623d1a8e29582a6e53b1af
Ruby
JParrales/sololearn
/ruby/namespacing.rb
UTF-8
438
4.125
4
[]
no_license
module Mammal class Dog def speak puts "Woof!" end end class Cat def speak puts "Meow" end end end a = Mammal::Dog.new b = Mammal::Cat.new a.speak b.speak module MyMath PI = 3.14 def self.square(x) x*x end def self.negat...
true
2cd9bbeca39462ea02c67671c8d111255df1a9bf
Ruby
AnkurGel/Backup
/codechef/algothica/algfact.rb
UTF-8
90
2.984375
3
[]
no_license
c=gets.to_i while(c>0) do n=gets.to_i; prod=1 n.downto(1){|x| prod*=x} puts prod c-=1 end
true
d83ef85f2719a798b8bd3544d7a2d79db1b7ec2a
Ruby
murkbGitH/32bit-microprocessor
/add4/add4.rb
UTF-8
1,124
3.234375
3
[]
no_license
#!/usr/bin/ruby # -*- coding: utf-8 -*- # # NOTE: 第1引数で gensec を指定した際には,SECONDSスクリプトを生成 # arg1 = ARGV.shift A = 0..15 # 入力 a の値の範囲 B = 0..15 # 入力 b の値の範囲 C = 0..1 # 入力 cin の値の範囲 time = 1 # 時刻 for a in A for b in B for cin in C sum = a + b + cin # 出力値の計算 if sum > 15 # sum が15より大きい場合は,下の4ビ...
true
35b02543e41491a5aa25dd7ed9204a38f52f4199
Ruby
kiizerd/chess
/lib/event_bus/event_handler.rb
UTF-8
225
2.953125
3
[]
no_license
class Handler attr_reader :token def initialize token, proc @token = token @block = proc end def call args=nil case args when nil @block.call else @block.call args end end end
true
e93fd1943f8e9f1127d45fd45f7b827f56da1a96
Ruby
cjmanetta/footie-sinatra
/app/helpers/user_helper.rb
UTF-8
429
2.609375
3
[]
no_license
helpers do def login(user) session[:id] = user.id end # def logout! # session[:id] = nil # end def current_user if session[:id] @current_user ||= User.where(id: session[:id]).first else session[:id] = nil end end def logged_in? !!current_user end def is_coach? ...
true
f48266e866394f1519f098c5d5b138bb7f118531
Ruby
pearlzhuzeng/exercism
/ruby/poker/spec/card_test.rb
UTF-8
628
3.15625
3
[]
no_license
require 'rspec' require_relative '../card' RSpec.describe Card do it "can be initialized" do c1 = Card.new('7D') c2 = Card.new('10H') expect(c1.number).to eq (7) expect(c1.suit).to eq ('D') expect(c2.number).to eq (10) end it "can replace J with 11" do c = Card.new('JH') expect(c.num...
true
8d4a82cbb5d982759e927449cc4ed8bfcb2930d1
Ruby
aindrayana/codecore-oct-2015
/day3/06_oop_blog_post.rb
UTF-8
1,013
3.9375
4
[]
no_license
# Model a blog post and comments # Model a blog post and comments with classes and make it # so a blog have many comments. # Add the ability for me to add and remove comments from a blog. class Blog def initialize @comments = [] end def display @comments.each {|comment| puts "#{comment}"} puts "-----...
true
d224bffd9993d810458efa16a07b836c25cfdbac
Ruby
AntonFagerberg/BM-Elite-Force
/entities/projectiles/enemy_bullet.rb
UTF-8
184
2.5625
3
[]
no_license
require 'entities/projectiles/bullet' class EnemyBullet < Bullet def initialize(window, x, y, entity) super(window, x, y, entity) @angle = 180 @speed = -@speed end end
true
d13f996887cf2c772c6b4e29dfc0146ab4f279a3
Ruby
Aerilius/OnScreen-GUI
/test_QML_syntax.rb
UTF-8
2,295
3.1875
3
[]
no_license
# This is an experiment of a QML-like syntax. # # At the moment, the usage is a bit like classic toolkit: # b1 = Button.new("OK") # b2 = Button.new("Cancel") # h = HBox.new # h.add(b1,b2) # window.add(h) # # QML (from QT) has a different approach, more like CSS: # # Window{ # HBox{ # Button("OK") # Button("C...
true
6cb59c533685b2e62c66b18e9c06c6a05d7aa011
Ruby
ander/habits
/whip_config.rb
UTF-8
604
2.546875
3
[ "BSD-3-Clause" ]
permissive
# # a habits whip config file # # Store in $HOME/.habits/whip_config.rb # def dialog(title, txt) system %Q(say '#{title}') system %Q(osascript -e 'tell app "System Events" to display dialog "#{txt}"') # or if you have 'ruby-growl' gem installed # system "growl -h localhost -m '#{txt}'" end Habits::Whip.on(:ye...
true
8bf32be466fe74df869ed45b086c91569d36f66b
Ruby
amalagaura/camunda-workflow
/lib/camunda/poller.rb
UTF-8
1,214
2.71875
3
[ "CC0-1.0", "LicenseRef-scancode-public-domain" ]
permissive
# The poller will run as an infinite loop with long polling to fetch tasks, queue, and run them. # Topic is the process definition key. Below will run the poller to fetch, lock, and queue a task for the # example process definition with an id of CamundaWorkflow. # @example # Camunda::Poller.fetch_and_queue %w[Camunda...
true
d0ce9b64ef72e734a6a4337ff65623cd76c28ac5
Ruby
ShawnAukstak/problems
/elements_of_programming_interviews/5_7_raise_to_power.rb
UTF-8
299
3.921875
4
[]
no_license
#given x float/double, and y integer.. return x^y #O(n) where n = y def raise_to_power_brute(x, y) result = x while y > 1 result *= x y -= 1 end result end #3^3 = 27 #4^2 = 16 def raise_to_power(x, y) #every shift left is like a * 2 #11000 end puts raise_to_power_brute(3, 3)
true
5d78a6a12a811c455c8f36dbaf2db5c0c54c1d78
Ruby
arnabc74/arnabc74.github.io
/vid/index.rb
UTF-8
7,557
2.609375
3
[]
no_license
@{<NOTE> <UPDT>SAT SEP 11 IST 2021</UPDT> <HEAD1>The video production system</HEAD1> Download the <LINK to="https://drive.google.com/file/d/1evOYEtx1sWj5kaK1sC58Bv0s1IpxSy-i/view?usp=sharing">bundle from here</LINK>, and uncompress it. It will create a folder structure like this: <PRE> vidbase (root folder) | +---f...
true
22bdfa600ff50c572edaea0fe4c54e9b683e8ddf
Ruby
prostojchelovek/Ruby
/task5.2/station.rb
UTF-8
1,260
3.4375
3
[]
no_license
require_relative 'instance_counter' class Station include InstanceCounter attr_reader :name, :trains NAME_FORMAT = /^[a-z]+-?[a-z]+$/i @@all = [] def self.all @@all end def initialize(name) #Инизиализация конструктора @name = name validate! @trains = [] ...
true
8398e8ff718d530f4131f74bae9d8100afee1ccf
Ruby
jude-lawson/bike-share
/app/models/station.rb
UTF-8
1,715
2.5625
3
[]
no_license
class Station < ApplicationRecord validates_presence_of :name, :dock_count, :city, :installation_date has_many :start_trips, class_name: 'Trip', foreign_key: 'start_station_id', dependent: :destroy has_many :end_trips, class_name: 'Trip',...
true
f99425e1f3748baeb954daa5de2a9d61794ae32f
Ruby
jcasimir/charity-chain
/spec/helpers/token_helper_spec.rb
UTF-8
493
2.546875
3
[]
no_license
require 'spec_helper' # Specs in this file have access to a helper object that includes # the ChainsHelper. For example: # # describe ChainsHelper do # describe "string concat" do # it "concats two strings with spaces" do # helper.concat_strings("this","that").should == "this that" # end # end # end ...
true
85c78d232711d0bfa10ba3bf7e074e2650d6b793
Ruby
andydna/todo
/todo.rb
UTF-8
523
2.546875
3
[]
no_license
#!/usr/bin/env ruby class Todo class << self def exec_vim exec "vim #{ File.expand_path(caller_locations.first.path) }" end def puts_list puts DATA.readlines exit end def add_new task DATA.send(:open, __FILE__, 'a') { |data| data.puts task } end end end unless AR...
true
99295978602f6380771278aec0158980a1f01b90
Ruby
andrescachero/algorithms
/ruby/perm_missing_elem.rb
UTF-8
256
3.671875
4
[]
no_license
# The sum for [1..(N + 1)] = n(n+1)/2 def solution(a) # write your code in Ruby 1.9.3 sum = 0 a.each {|el| sum += el} full = (a.length + 1)*(a.length + 2) / 2 return full - sum end res = solution([2,3,1,5]) puts "Solution: #{res}"
true
d1e797ce5a8dcdf5005d68bbc70b24e7d25e1c1d
Ruby
rjspencer/phase_0_unit_2
/week_4/2_creative/create_accountability_groups/create_groups_spec.rb
UTF-8
916
3.546875
4
[]
no_license
# Code to test require_relative "my_solution" # Test Data students = ['John Smith', 'Jane Doe', 'Henry Winkler', 'Carrie Fisher', 'Gerald Ford', 'Mitt Romney', 'Ben Stiler', 'George Washington', 'John Smith', 'Jane Doe', 'Henry Winkler', 'Carrie Fisher', 'Gerald Ford', 'Mitt Romney', 'Ben Stiler', 'George Washington'...
true
1a4d8f523364837baf673f32699e46e4bf85f11e
Ruby
brennx0r/manager-situations
/incoming-scenario.rb
UTF-8
492
3.328125
3
[ "MIT" ]
permissive
require 'io/console' filename = "scenarios.txt" if ARGV[0] == nil ARGV[0] = 1 end # read in the text file and save values as an array def arraycreate(filename) array = IO.readlines(filename) selector(array, filename) end # select the scenario using sample method def selector(array, filename) selected = array.s...
true
abceb3405a1693560f1537e40fe715956deabe30
Ruby
zklamm/ruby-small-problems
/exercises/first_pass/medium_02/03_lettercase_ratio.rb
UTF-8
511
3.78125
4
[]
no_license
def letter_percentages(str) avg = {} avg[:lowercase] = str.count('a-z') avg[:uppercase] = str.count('A-Z') avg[:neither] = str.count('^a-zA-Z') avg.each do |letter_case, count| avg[letter_case] = count * 100 / str.length.to_f end avg end p letter_percentages('abCdef 123') == { lowercase: 50, upperc...
true
e078a58e5413e38206d62924af40b08aeb8fb3bc
Ruby
singsang2/greeting-cli-atl-fasttrack-082918
/lib/greeting.rb
UTF-8
97
3.328125
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
# code the #greeting method here! def greeting(name) puts "Welcome to the program #{name}!" end
true
e8c0cbb6e1f3dc77bf8bf7e9b50d8054c8e84013
Ruby
Zlatov/lab
/ruby/sprintf/sprintf.rb
UTF-8
6,422
3.625
4
[]
no_license
require 'awesome_print' puts 'Форматирование целочисленных значений.'.green # b | Как двоичное. Отрицательное - префикс 1. # B | Как двоичное. Отрицательное - префикс 0B в альтернативном форматировании (#). a = -7 b = sprintf "%#B", a print 'b: '.red; puts b # d | Как десятеричное. # i | Как десятеричн...
true
75c86c2938724d006208ca8ea59fb5a85ce9ae46
Ruby
adamski10/w_2_d_1_classess_homework-lab
/specs/spec_student.rb
UTF-8
1,141
2.640625
3
[]
no_license
require('minitest/autorun') require('minitest/reporters') require_relative('../student') Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new class TestStudents < Minitest::Test def test_student_name student = Students.new("Adam", "E40") assert_equal("Adam", student.student_name()) end def te...
true
03d6c50103c48ac8b3909f930a41e1b704bd8981
Ruby
slaterson1/T3new
/TTT333.rb
UTF-8
3,998
3.921875
4
[]
no_license
module TicTacToe class Run def initialize puts "Welcome to Tic Tac Toe!" puts "" puts "Please Select An Option" puts "------------------------------" puts "1: Human vs Human" puts "2: Human vs Computer" puts "3: Exit" puts "------------------------------" puts "" response = gets.chomp...
true
7b4ae18fc65de85ab5a49c775d3134c53400aad4
Ruby
jarapova/MW_revolve_ariat_venus
/features/pages/ST/ST_search_modal_page.rb
UTF-8
3,649
2.703125
3
[]
no_license
# In this module we collecting methods for search modal page of ST require 'capybara/cucumber' module ST_SearchModalPage extend Capybara::DSL extend RSpec::Matchers def self.open_search_modal page.assert_selector(:xpath, "//button[@aria-label='Search']") # assert search btn in header find(:xpath, "//butt...
true
8e2d00cef2e0e8eada1ce499b0108a5d196d9cc1
Ruby
jacobdmartin/RoleModel_Prep_Work
/Intro-to-Ruby/making_choices/ruby_script.rb
UTF-8
1,602
3.734375
4
[ "MIT" ]
permissive
#!/usr/bin/ruby require './lib/ruby_logic' puts "How many options" option_number = gets.chomp.to_i while option_number > 10 do puts "Number of options cannot be less then 0 or greater then 10" puts "How many options" option_number = gets.chomp.to_i end choice_list = [] i = 0 while i != option_number do put...
true
34dcb0f62e0f2cbec816474023079c71e96ce9b2
Ruby
dustingooding/utilrb
/lib/utilrb/hash/slice.rb
UTF-8
106
2.75
3
[ "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
class Hash def slice(*keys) keys.inject({}) { |h, k| h[k] = self[k] if has_key?(k); h } end end
true
3c8616dc109c929eed611b7dec8f40f41a3f7edf
Ruby
andrewtrent/oo-cash-register-v-000
/lib/cash_register.rb
UTF-8
769
3.28125
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class CashRegister attr_accessor :total, :discount, :items, :delete_history def initialize(disc = 0) @total = 0 @discount = disc @items = [] end def total @total end def add_item(title, cost, quantity=1) @total += cost*quantity quantity.times { @items << title } @delete_hist...
true
25c66790de7fd929142aca6329e071b1b36b0e7d
Ruby
addriv/algorithms
/hackerrank/tracks/algorithms/medium/hackerland_radio_transmitters/radio_transmitters.rb
UTF-8
811
3.765625
4
[]
no_license
Hackerland is a one-dimensional city with houses, where each house is located at some on the -axis. The Mayor wants to install radio transmitters on the roofs of the citys houses. Each transmitter has a range, , meaning it can transmit a signal to all houses units of distance away. Given a map of Hackerland and th...
true
81afd681a36a31271e8aa633c2fd72e0020dd6f1
Ruby
Lastbastian/Ruby-me
/Week_12/hpricot.cgi
UTF-8
1,293
3.171875
3
[]
no_license
#!/usr/local/bin/ruby # Name: Chris Bastian # File: hpricot.cgi # ASSN: Week 12 Lab --- hpricot cgi script # Desc: Using open-uri and hpricot to capture html. $:.unshift File.dirname(__FILE__) ENV['GEM_HOME']='/students/cbastian/mygems' require 'cgi_helper' include CgiHelper require 'rubygems' require 'cgi' require 'h...
true
3930ce683087b9c3c377f37efc45b4619cc0109a
Ruby
RJ-Ponder/RB101
/exercises/easy_4/century.rb
UTF-8
1,402
4.65625
5
[]
no_license
=begin Problem Write a method that takes a year as input and returns the century The return value should be a string that begins with the century number and ends with st, nd, rd, or th as appropriate New centuries begin with 01. (1901 - 2000 is 20th century) Examples/Test Cases century(2000) == '20th' centu...
true
f4801e81a2d2af29b4f62ef3c04a6623e5cb0253
Ruby
Pathgather/plus-plus
/lib/plus_plus/base.rb
UTF-8
3,536
2.71875
3
[ "MIT" ]
permissive
module PlusPlus module Base def plus_plus(*args) options = args.extract_options! association, column = args self.after_create(&-> { self.plus_plus_on_create_or_destroy(association, column, options) }) self.after_destroy(&-> { self.plus_plus_on_create_or_destroy(association, column, option...
true
5c292ea7da3092469bd10c18854c7bdaf8dfce7f
Ruby
iwadon/text-hatena
/lib/text/hatena/auto_link/hatena_group.rb
UTF-8
3,276
2.546875
3
[ "Ruby" ]
permissive
require "text/hatena/auto_link/scheme" module Text class Hatena class AutoLink class HatenaGroup < Scheme @@pattern_group_archive = /\[?(g:([a-z][a-z0-9\-]{2,23}))(:id:([A-Za-z][a-zA-Z0-9_\-]{2,14}))(:(archive)(?::(\d{6}))?)\]?/i @@pattern_group_diary = /\[?(g:([a-z][a-z0-9\-]{2,23}))(:id:(...
true
3cb21d15b51e2a7db76e62329f4dc0cfe8be7a8d
Ruby
marcmo/rlooper
/lib/handler.rb
UTF-8
2,154
2.6875
3
[ "BSD-2-Clause" ]
permissive
require 'looper' require 'message' module Looper class Handler def initialize_empty p "handler initialize_empty" _looper = Looper::my_looper() raise "looper should exist" if _looper.nil? @message_queue = _looper.queue end def initialize_with_looper(_looper) p "handler initi...
true
eff9bfa4195677d6a57ef6d172b530e111928cc6
Ruby
NicciTheNomad/Ruby-Coding-Dojo-Class
/RubyAssignments/Ruby_OOP/MathDojo/mathdojo.rb
UTF-8
1,783
4.6875
5
[]
no_license
# HINT: To do this exercise, you will probably have to use 'return self'. If the method returns itself (an instance of itself), we can chain methods. # # Develop a ruby class called MathDojo that has the following functions: add, subtract. Have these 2 functions take at least 1 parameter. MathDojo.new.add(2).add(2...
true
464599e6b247594b39093a1abb23731d017eb5b2
Ruby
zerolive/ithreesports
/app/models/exam.rb
UTF-8
560
2.65625
3
[ "MIT" ]
permissive
class Exam < ActiveRecord::Base YOUTUBE_SORT = 'youtu.be' YOUTUBE_LONG = 'youtube.' LEVELS = ['User', 'Admin'] validates :title, presence: true validates :level, presence: true, inclusion: LEVELS has_many :questions, :dependent => :destroy belongs_to :course def self.levels LEVELS end def video_id res...
true
6034e25f38a76e6ff8865b5b238dd945c264c4a4
Ruby
ruby/tk
/sample/tktimer.rb
UTF-8
922
2.84375
3
[ "BSD-2-Clause", "Ruby" ]
permissive
#!/usr/bin/env ruby # frozen_string_literal: false # This script generates a counter with start and stop buttons. require "tk" $label = TkLabel.new { text '0.00' relief 'raised' width 10 pack('side'=>'bottom', 'fill'=>'both') } TkButton.new { text 'Start' command proc { if $stopped $stopped = fa...
true
bb026d6d497bcaafe30abcc9bd195153120cfd19
Ruby
leandromoreira/ruby_meta_programming
/friday/spec/person.rb
UTF-8
422
2.984375
3
[]
no_license
class Class def checked_attribute(attribute,&validation) define_method "#{attribute}=" do |value| raise 'Invalid attribute' unless validation.call(value) instance_variable_set("@#{attribute}",value) end define_method attribute do instance_variable_get "@#{attribute}" end end end class Person c...
true
90f26812df7677a4e150ba2d72c4d8ebae90062c
Ruby
nerzh/web_sha256
/app/services/chain_net.rb
UTF-8
978
2.734375
3
[]
no_license
require 'json' require 'net/http' require 'uri' module ChainNet class Http def self.send_post_data(url, data, ct='application/x-www-form-urlencoded') uri = URI.parse(url) header = {'Content-Type'=> ct} http = Net::HTTP.new(uri.host, uri.port) request = Net::HTTP::Post.new(uri.re...
true
329bb88c76121832e7886802041ac558ce16f43c
Ruby
lsegal/yard
/lib/yard/logging.rb
UTF-8
6,259
2.796875
3
[ "LicenseRef-scancode-free-unknown", "MIT", "GPL-2.0-only", "Ruby", "BSD-2-Clause" ]
permissive
# encoding: utf-8 # frozen_string_literal: true require 'logger' require 'thread' module YARD # Handles console logging for info, warnings and errors. # Uses the stdlib Logger class in Ruby for all the backend logic. class Logger < ::Logger # The list of characters displayed beside the progress bar to indica...
true
dc0886f4b33afbcdf4bb507f42a5baef7a7d63ba
Ruby
sr/statig
/statig.rb
UTF-8
3,254
2.609375
3
[ "WTFPL" ]
permissive
require 'yaml' class SerializableProc def initialize(block) @block = block to_proc end def to_proc eval "Proc.new{ #{@block} }" end def method_missing(*args) to_proc.send(*args) end end class Statig < Thor desc 'build', 'Build website in DIRECTORY' method_options :...
true
5cb087a80daace707ea765ce9b85c82f8f787766
Ruby
terrywin/Lesson-1
/dis2.rb
UTF-8
562
3.46875
3
[]
no_license
puts "Введите значение a" a = gets.chomp puts "Введите значение b" b = gets.chomp puts "Введите значение c" c = gets.chomp d = ((b.to_f)**2 )- ((a.to_f * c.to_f) * 4) puts "d = #{d}" if d < 0 puts "Корней нет!" elsif d == 0 # ## puts "Дискриминант равен 0 ,корни равны!x1,x2 = #{(-b.to_f) / (2 * a.to_f)}" els...
true
a963283481cccceed35cfb867c93b3bb6417ce7d
Ruby
sungchoi/topics-in-cs
/data-structures/ruby/linked_list_node.rb
UTF-8
1,437
3.4375
3
[]
no_license
class LinkedListNode def self.append(value) LinkedListNode.new(value) end def self.each end def self.empty? true end def self.length 0 end def self.next :__empty__ end def self.peek nil end def self.prepend(value) LinkedListNode.new(value) end def self.repla...
true
6dbdb55cee46abb740cafcc6b9d748e280d64725
Ruby
slemsvamp/adventofcode2015
/day04/problem.rb
UTF-8
309
2.84375
3
[]
no_license
require 'digest' TEST = ARGV.delete('-t') input = if TEST 'abcdef' else ARGV.empty? ? INPUT : ARGF.read end i = 0 p1 = nil while true do i+=1 d = Digest::MD5.hexdigest(input + i.to_s()) if p1 == nil && d[0..4] == '00000' then p1 = i end break if d[0..5] == '000000' end puts "P01: #{p1} -///- P02: #{i}"
true
6ef6ff4f5dc5d7b3cc95fa39863d3168d8ecda1c
Ruby
georgehwho/ruby-exercises
/command-query/exercises/clock.rb
UTF-8
140
2.96875
3
[]
no_license
class Clock attr_reader :time def initialize @time = 6 end def wait @time += 1 @time = 1 if self.time == 13 end end
true
f85d2913ac92c509f7e03c0a03f30e8531f46742
Ruby
funidata/grok-test
/lib/grok-test.rb
UTF-8
2,170
2.953125
3
[ "MIT" ]
permissive
require 'logger' require 'grok-pure' class GrokTest PATTERNS_PATH = File.expand_path '..', File.dirname(__FILE__) class Error < StandardError end class Input def self.stdin new($stdin, path: '<stdin') end def self.open(path) new(File.open(path), path: path) end def initial...
true
99ac16af8a30601736df954f1f90a4162b7c30b2
Ruby
danascheider/databasedestroyer
/lib/helpers/database_helper.rb
UTF-8
797
2.6875
3
[]
no_license
require 'mysql2' module Sinatra module DatabaseHelper # Truncate all tables in the database using the Mysql2 client passed as an argument def nuke! client client.query('SET FOREIGN_KEY_CHECKS = 0') client.query('SHOW TABLES', as: :array).each do |table| client.query("TRUNCATE TABLE #{...
true
de2f7d0b918325b3b79d126cae3965994a14b8c5
Ruby
yu1k/competitive-programming
/atcoder/abc158/c.rb
UTF-8
134
2.828125
3
[ "MIT" ]
permissive
a, b = gets.split.map(&:to_i) for i in 1..1010 if a == (i * 0.08).to_i && b == (i * 0.1).to_i puts i exit end end puts -1
true
d9deec127d7545fe58082c0b3788c24e42d9ecf3
Ruby
JonasKVJ/SFSU-Ruby-Small-Assignments
/Problem3_Mean&StdDev.rb
UTF-8
906
4
4
[]
no_license
#Problem 3 - mean and standard deviation def mean(a) sum = 0.0; i = 0; a.each{|n|; a[i] = n.to_f; i += 1;} #convert array to float to avoid accuracy loss during division a.each{|n|; sum += n;} mean = sum/a.length.to_f; return mean; end #Method to find and return both the mean and the standard deviation de...
true
5978d999af8c12a2fc2fec7c1135a25f874f2ffb
Ruby
jchabra/ruby
/quizzes/quiz3.rb
UTF-8
1,076
4.59375
5
[]
no_license
#Quiz 3: Student require 'pry' #create a class called Student #student will have these properties: name, dob, gender, gpa, major class Student attr_accessor :name, :dob, :gender, :gpa, :major #initialize this student: s1 = Student.new(name, dob, gender, gpa, major) def initialize(n, d, g, gpa, m) @name = n @...
true
b146b20160cec395c4644d7f6cc8e8d1538913df
Ruby
alu0100696585/prct05
/racional.rb
UTF-8
723
3.734375
4
[]
no_license
# Implementar en este fichero la clase para crear objetos racionales require "./gcd.rb" class Fraccion attr_accessor :x , :y def initialize (x,y) raise RuntimeError unless x.is_a? Integer and y.is_a? Integer @x=x @y=y end def to_s "#{@x} / #{@y}" end def suma (other) ...
true
32f856fc257d73f55219447d9e8858ef13cd5de9
Ruby
h3rald/redbook
/spec/parser_spec.rb
UTF-8
4,769
2.578125
3
[]
no_license
#!/usr/bin/env ruby require File.join(File.dirname(__FILE__),'..','lib', 'redbook') describe RedBook::Parser do before(:each) do @p = RedBook::Parser.new end it "should define log operation" do op= RedBook.operations[:log] op.should_not == nil op.name.should == :log op.parameters[:log].should_not == n...
true
6802caef54e02696e6930ec6e959646c2d3965a7
Ruby
tenderlove/elefaint
/lib/elefaint/parser.rb
UTF-8
702
2.90625
3
[ "MIT" ]
permissive
module Elefaint class Parser def parse io x = io.readchar case x when '+' then Nodes::Status.new io.readline.chomp when '-' then raise(NotImplementedError) when ':' then Nodes::Integer.new io.readline.chomp when '$' then parse_bulk(io) when '*' then parse_multi_bulk(io) ...
true
d11816ccf3b77ea6e010192217bf1f90c11be042
Ruby
Evelyn651/udemy_ruby_courses
/string_operations/udemy_strings.rb
UTF-8
1,885
4.15625
4
[]
no_license
# string operation name = "John" puts "Hello #{name}" puts "Result #{5 + 9}" puts message = "ruby is your best friend.\n" puts message.length puts message.size puts message[0] puts message[-1] puts message[0,4] # exclusive puts message[5..20] # inclusive puts message.slice(0) puts message.slice(0,4) puts message.slice...
true
9f3eaf7ca07445e9fefd86b731a8ad66d72fe072
Ruby
123JackCole/The-Haunted-House
/lib/commandlineinterface.rb
UTF-8
4,216
3.46875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class CommandLineInterface def run intro while true puts "\nType 'help' to see the list of available commands. Type 'quit' to exit.".magenta print "Enter command: ".cyan input = gets.chomp.downcase break if input == "quit" if input.inc...
true
d88c2b3957642605037b0c767e168a519c05a289
Ruby
ehaselwanter/poolparty
/lib/poolparty/resources/service.rb
UTF-8
607
2.578125
3
[ "MIT" ]
permissive
module PoolParty module Resources =begin rdoc == Service The service resource specifies a service that must be running on the nodes == Usage has_service(:name => '...') do # More options. # This block is optional end == Options * <tt>name</tt> Name of the service to be running == Examp...
true
44b75e725bd6f7f867d335892d7dafe9b517044e
Ruby
bbpink/nonoshitter
/lib/util/DB.rb
UTF-8
671
2.890625
3
[ "BSD-3-Clause" ]
permissive
require "rubygems" require "sqlite3" class DB def initialize(path) @dbobj = SQLite3::Database.new(path) end def execute(sql) @dbobj.execute(sql) end def insert(table, values) sql = "INSERT INTO #{table} VALUES( null," q = [].fill("?", 0, values.length) sql = sql + q.join(",") + ")" ...
true
ec3834eb55156370140c269e3fb7b57fe52489c4
Ruby
rhysbowenharries/first-weekend-home-work
/pet_shop.rb
UTF-8
2,027
3.40625
3
[]
no_license
def pet_shop_name(name) return name[:name] end def total_cash(name) name[:admin][:total_cash] end def add_or_remove_cash(name, monies) new_ballance = name[:admin][:total_cash] += monies return new_ballance end def pets_sold(name) name[:admin][:pets_sold] end def increase_pets_sold(name, number) new_pets...
true
255b04765cfb5328f74fc5db8d83d4bb5a9dfd7b
Ruby
CodiTramuntana/decidim-erc-app
/app/exporters/decidim/exporters/amendment_excel.rb
UTF-8
1,742
2.9375
3
[]
no_license
# frozen_string_literal: true require "spreadsheet" module Decidim module Exporters # Exports any serialized object (Hash) into a readable Excel file. It transforms # the columns using slashes in a way that can be afterwards reconstructed # into the original nested hash. # # For example, `{ name...
true
540c034ef88bf356a07166899a296916d30b2e31
Ruby
jorgex10/problems
/sum_of_intervals/solution.rb
UTF-8
938
3.265625
3
[]
no_license
# frozen_string_literal: true def sum_of_intervals(intervals) intervals.sort! intervals = overlapping_intervals(intervals) sum = 0 intervals.each do |array| sum += (array[1] - array[0]) end sum end def overlapping_intervals(intervals) max_value = 0 indexes_to_delete = [] array_to_be_insented =...
true
ebdce28fb6e095764a5ad8fa77259924d2d7fcdd
Ruby
snex/election_results_benford
/sim.rb
UTF-8
1,229
2.953125
3
[]
no_license
#!/usr/bin/env ruby require 'rubystats' require_relative 'benford' can_A = 'Alice' can_B = 'Bob' avg_can_A = 0.8 stddev_can_A = 0.1 num_precincts = 2000 avg_precinct_size = 1000 stddev_precinct_size = 300 avg_precinct_turnout = 0.8 stddev_precinct_turnout = 0.1 precincts = {} 1.upto(num_precincts) do |precinct| ...
true
e5c3a51846ea2a5a05d76359f4499770798a7fc1
Ruby
s-espinosa/sorting_suite
/lib/sorting_suite.rb
UTF-8
1,421
3.40625
3
[]
no_license
require_relative 'bubble_sort' require_relative 'insertion_sort' require_relative 'selection_sort' require_relative 'merge_sort' class SortingSuite class Benchmark def initialize base_array =* (1..1000) @unsorted_array = base_array.shuffle end def time(sort_type, array = @unsorted_array) ...
true
ae28baf8b1962a0e2591915eb47ad7ba146e9eb1
Ruby
fsosa/interview-practice
/permutation.rb
UTF-8
283
3.71875
4
[]
no_license
#! /usr/bin/env ruby # Find all the permutations of a string def permute (prefix, string) if string.empty? puts prefix end string.chars.each_with_index do |char, index| permute(prefix + char, string[0, index] + string [index+1, string.length]) end end permute "", "dog"
true
147a899270eee794d8c458721b7f4aeda82918c3
Ruby
awagner85/tealeaf_book
/capital.rb
UTF-8
150
3.9375
4
[]
no_license
def capital(word) if word.length > 10 puts word.capitalize else puts "That word is too short!" end end capital("hello") capital("masochistic")
true
d44517f812a1468cbb594fc6d562a1c4d64a111b
Ruby
chiragagrawal/asm-deployer-jenkins
/lib/asm/service/component/resource.rb
UTF-8
5,702
2.921875
3
[]
no_license
module ASM class Service class Component class Resource attr_accessor :service attr_accessor :configuration def initialize(component, resource, decrypt=true, service=nil) @component = component @resource = resource @configuration = ASM::PrivateUtil.buil...
true
43eaf1de752d058a55c2fec99614554f52000a40
Ruby
stungeye/solr_schema
/lib/solr_schema.rb
UTF-8
1,581
2.953125
3
[]
no_license
require "nokogiri" class Record attr_reader :nodeset # nodeset getter is never accessed from the specs. Is it required? def initialize(data) if data[:schema] == "dc" @root_element = "//metadata/dc" elsif data[:schema] == "mods" @root_element = "//mods" else @root_element = data[:root...
true
10cf96fca73db03421ebb34e1ca40982f79ca421
Ruby
joemaidman/lrthw
/exercises/ex3b.rb
UTF-8
1,631
4.46875
4
[]
no_license
# Prints a string of text to the screen puts "I will now count my chickens:" # Prints a string to the screen and uses interpolation to count hens: 25 plus 30 divided by 6 puts "Hens #{25 + 30 / 6}" # Prints a string to the screen and uses interpolation to count roosters: 100 minus 25 multiplied by 3 modulus 4 puts "Roo...
true
8a50a9338301ff78b191e2d0a3773b50ed2e8f0d
Ruby
jjenkins120/cli-applications-guessing-game-chi01-seng-ft-080320
/guessing_game_cli.rb
UTF-8
449
3.78125
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
require "pry" def run_guessing_game random_number = rand(6) + 1 puts "Guess a number between 1 and 6." user_input = gets.chomp binding.pry if user_input.to_i == random_number puts "You guessed the correct number!" elsif user_input.to_i != random_number puts "Sorry! The computer guessed #{random_num...
true
121316fe30dec6ca8bdcf50363f2cbcf9294d030
Ruby
AndresLeiva93/arreglos
/Tarea/tarea1.rb
UTF-8
431
4.15625
4
[]
no_license
#Muestra el valor 0 a = [1,2,3,4,5] puts a.at(0) #Elimino un valor dentro del arreglo a.delete(3) puts a #Muestro el arreglo en orden inverso puts a.reverse #contar objetos dentro del arreglo puts a.length #Ordenar alfebeticamente b = [3,4,2,5] puts b.sort #Corta un arreglo puts b.slice(1,2) #Desordenar un arreg...
true
7224c653aa005efadf3324681a249a837d50cac2
Ruby
chris-groves/bank-tech-test
/lib/account.rb
UTF-8
767
3.375
3
[]
no_license
class Account attr_reader :balance, :transaction_history CURRENT_DATE = Time.now.strftime("%d/%m/%Y") def initialize @balance = 0 @transaction_history = [] end def deposit(amount) @balance += amount @transaction_history.prepend("#{CURRENT_DATE} || #{'%.2f' % amount} || || #{'%.2f' % @balanc...
true
b593590054ca55456b6745f999e6041dfa689b5f
Ruby
josebuinat/ampsports-server
/app/services/request_signature_calculator.rb
UTF-8
547
2.6875
3
[]
no_license
class RequestSignatureCalculator # used to secure our API from unauthorized usage of 3rd parties def self.call(request, app_name) new(request, app_name).call end def initialize(request, app_name) @request = request @app_name = app_name end # returns calculates signature for given request / app...
true
2deec3a2ebdba51fa8854d2edfd4c43416fa47ee
Ruby
angelmore/ISW2
/09-TusLibros.com/Ruby/cart_tests.rb
UTF-8
2,025
2.796875
3
[]
no_license
require 'minitest/autorun' require 'minitest/reporters' require './cart' require './factory' MiniTest::Reporters.use! class CartTests < Minitest::Test def test_01_new_cart_is_empty cart = Cart.new Factory.empty_catalog assert cart.empty? end def test_02_cannot_add_a_book_with_an_invalid_isbn_to_a_cart...
true
c3b69fe5b5e42407514dcfffda56811c64db4849
Ruby
mickeysanchez/checkers
/piece.rb
UTF-8
767
3.609375
4
[]
no_license
class Piece attr_reader :color attr_accessor :current_pos, :king, :icon def initialize(color, pos) @color = color @current_pos = pos @king = false @icon = (@color == :white) ? "\u25CB" : "\u25CF" end def slide_to(y, x) @current_pos = [y, x] end def jump_to(y, x) @current_pos = [...
true
b6d6772bac25e7bbb4258f5fdc34a71830a7eba9
Ruby
aleph-naught2tog/ruby_exercises
/src/calculations/paint_calculator.rb
UTF-8
1,117
4.21875
4
[]
no_license
require "utils" def get_area_equation(kind) case kind when :round lambda { |radius, _| Math::PI * (radius ** 2) } when :square lambda { |length, width| length * width } end end def get_width() result = Utils.to_number(Utils.prompt("What is the width?")) end def get_length() result = Utils.to_num...
true
ac40c183814a3e494c52fe0ea5744b634e4165a9
Ruby
jbarcia/scripts
/batch_sslscan.rb
UTF-8
581
2.59375
3
[]
no_license
#!/usr/bin/env ruby binary='sslscan' ERROR_MESSAGE = File.basename($PROGRAM_NAME) + " <file_of_ip_addresses> <port>" if ARGV.size != 2 puts ERROR_MESSAGE exit end input_file = ARGV[0] port = ARGV[1] if not File.exists?(input_file) puts "'#{input_file}' does not exist!" puts ERROR_MESSAGE exit end server...
true
05ed073dcd77fbebe439028703461e0b2c98e7b5
Ruby
en-604-pionNeers/clueLess-server
/lib/board.rb
UTF-8
1,315
3.28125
3
[]
no_license
require 'rooms' require 'hall' class Board attr_accessor :halls attr_accessor :rooms def initialize @rooms = {} ROOM_LAYOUT[:rooms].each do |room| @rooms[Integer(room[:id])] = Room.new(room) end @halls = {} HALLS.each do |hall| @halls[@rooms.count + @halls.count] = Hall.new(...
true
65f1d72dc120912eb56451150badf6c6a184dd1f
Ruby
EzraChiang/phase-0-tracks
/ruby/gps6/my_solution.rb
UTF-8
3,849
3.671875
4
[]
no_license
# Virus Predictor # I worked on this challenge [by myself, with: ]. # We spent [#] hours on this challenge. # EXPLANATION OF require_relative #require_relative accesses a file that you have created. #Require uses built in methods already installed require_relative 'state_data' class VirusPredictor #initi...
true
38a0f52de08c2ce5de178f7108268c3e91b1702e
Ruby
rafayet-monon/github-repo-searcher
/app/services/repository_searcher_service.rb
UTF-8
864
2.578125
3
[]
no_license
# frozen_string_literal: true class RepositorySearcherService include Pagy::Backend MAX_SEARCH_RESULTS = 1000 attr_reader :result, :total_count, :pagination, :error def initialize(query, page) @query = query @page = page || 1 end def self.perform(query, page) new(query, page).perform end ...
true
58be4a7eb7b422fdd176c48e1ae8b10ae5ab2d72
Ruby
soroz30/Launch
/Exercises 1/easy2/room.rb
UTF-8
263
3.5
4
[]
no_license
p "Enter the length of the room in meters:" length = gets.chomp.to_f p "Enter the width of the room in meters:" width = gets.chomp.to_f p "The area of the room is " + (length * width).to_s + " square meters (" + (length * width * 10.7639).to_s + " square feet)."
true
5f5b2f562eceb4bcb700eca05f4656c96fec5137
Ruby
KoushikDasika/ProjectEuler
/problem19.rb
UTF-8
242
3.21875
3
[]
no_license
#!/usr/bin/env ruby require 'date' start = Date.new(1901, 1, 1) last = Date.new(2000, 12, 31) pointer = start counter = 0 while pointer < last if pointer.wday == 0 counter += 1 end pointer = pointer.next_month end puts counter
true
fbe70f590ba9badba9bc786bb96925b217be6dec
Ruby
mbj/mapper
/lib/mapper/transformer.rb
UTF-8
1,821
2.65625
3
[ "MIT" ]
permissive
class Mapper # Base class for loader and dumper classes class Transformer extend ReaderDefiner # Return source of transformation # # @return [Object] # # @api private # def source @source end # Return key # # @return [Object] # # @api private # ...
true
462019c6174784c419dcce5afd1ec42a2ef0db83
Ruby
moinvirani/learn_ruby
/02_calculator/calculator.rb
UTF-8
439
4.15625
4
[]
no_license
def add(num_1, num_2) return num_1+num_2 end def subtract(num_1, num_2) return num_1 - num_2 end def sum(array) sum = 0 array.each { |x| sum += x } return sum end def multiply(array) array.inject(:*) # :* knows you want to multiply values of an array each time # array.inject(1) { |y, x| x * y } end d...
true
64b7153f54fe32327398d97a2e48078f99b31e61
Ruby
J-Y/RubyQuiz
/ruby_quiz/quiz141_sols/solutions/come/dice.rb
UTF-8
571
2.90625
3
[ "MIT" ]
permissive
dice, n = ARGV.grep(/\d+/) verbose = true if ARGV.include?("-v") sample = true if ARGV.include?("-s") max=("5"*dice.to_i).to_i(6) n=n.to_i resultat= (0..max).inject(0) do |sum,i| output = verbose || (sample && i % 50_000 == 0) print i+1,"\t",("%#{dice}s" % i.to_s(6)).split(//).map{|e| e.to_i+1}.inspect if output ...
true
c23ca3da95de0df4070069e98c6361c97b8b0164
Ruby
jadercorrea/sos
/spec/helpers/event_helper_spec.rb
UTF-8
1,359
3
3
[]
no_license
require 'spec_helper' describe EventHelper do describe ".todays_events" do before do @events = [ FactoryGirl.create(:event, start_datetime: 1.day.ago), FactoryGirl.create(:event, start_datetime: Time.new), FactoryGirl.create(:event, start_datetime: 1.day.from_now) ] end ...
true
cbc720ef38398266f6eabe20321731366bb3e113
Ruby
Timbinous/jsonery
/lib/iterator.rb
UTF-8
864
3.5625
4
[ "MIT" ]
permissive
class Iterator attr_accessor :tables def initialize @tables = [] end def iterate json if json.class == Array array json elsif json.class == Hash hash json end end def array json json.each do |obj| iterate obj end end def hash json json.each do |key, val...
true
63d9afda73159b5f6bd9d4241b8d14b762840a2c
Ruby
diogobenica/meudinheiro_old
/app/models/transaction.rb
UTF-8
825
2.640625
3
[]
no_license
# encoding: UTF-8 class Transaction < ActiveRecord::Base attr_accessible :category_id, :description, :transaction_date, :user_id, :value validate :transaction_date_is_a_time_object def initialize(attributes = {}) super @category_id = attributes[:category_id] @description = attributes[:description] ...
true
cf2f040717c33a6aa30b5a22d9da5c0ae054a376
Ruby
podoglyph/homework
/calculator/test/calculator_test.rb
UTF-8
1,934
4.1875
4
[]
no_license
# Build a calculator class from scratch using TDD # Start with whiteboarding and pseudocode # Write pseudocode in the test file first for a few methods # Your calculator should be able to handle the following methods: # .new # #total # #add # #clear # #subtract #Pseudocode: #1. create a calculator class #2. create me...
true
0437788a25c49d711a371dcc4d6bf245c565f48f
Ruby
jojohannsen/suffix_tree
/spec/location_spec.rb
UTF-8
5,589
2.734375
3
[]
no_license
require 'rspec' require_relative '../lib/location' require_relative '../lib/node' require_relative '../lib/node_factory' require_relative '../lib/data/string_data_source' describe 'Location class' do let(:dataSource) { StringDataSource.new("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")} let(:nodeFactory...
true
6dbd2425ded23c08e229099d833164f027b3178a
Ruby
matthewjf/active_record_material
/model/user.rb
UTF-8
2,130
2.71875
3
[]
no_license
class User < Model attr_accessor :fname, :lname def self.find_by_name(fname, lname) User.new(QuestionsDBConnection.instance.execute(<<-SQL, fname: fname, lname: lname).first) SELECT * FROM users WHERE fname = :fname AND lname = :lname SQL end def create ra...
true
72ec1efb55388a6a4f007750e24d76c6c0647956
Ruby
tonytonyjan/q_and_a
/app/entities/pagination.rb
UTF-8
530
3.09375
3
[]
no_license
# frozen_string_literal: true class Pagination def initialize(total_items:, per:, page:) @total_items = total_items @per = per @page = page end def current_page if @page < 1 then 1 elsif @page > total_pages then total_pages else @page end end def total_pages pages = @total_i...
true
02b5ad43c4c94980b2a1857206e85acd6ffc1c1b
Ruby
choltz/fiddle
/refector_db_pull/db_pull2.rb
UTF-8
1,184
2.859375
3
[ "MIT" ]
permissive
require 'rubygems' require 'bundler/setup' require 'fog' require 'progressbar' require 'yaml' # require 'debugger' class Pull def initialize # Connect to S3 s3_config = YAML.load_file 'config/s3.yml' @s3_connection = Fog::Storage.new( :provider => 'AWS', :aws_access_key_i...
true
70e551d31c2ec742b5ac91bfc5f13b6947d54224
Ruby
happymelonbox/flatiron-bnb-methods
/app/models/reservation.rb
UTF-8
1,011
2.609375
3
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-public-domain" ]
permissive
class Reservation < ActiveRecord::Base belongs_to :listing belongs_to :guest, :class_name => "User" has_one :review validates :checkin, :checkout, presence: true validate :host_cannot_stay, :is_available, :checkin_before_checkout def duration if checkin && checkout checkout.mjd - checkin.mjd ...
true