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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
ee6ec9eaec29a73e6003811feade87d857ba8156 | Ruby | alfo/arpm | /lib/arpm/vendor/ruby-git/git.rb | UTF-8 | 4,556 | 2.6875 | 3 | [
"MIT"
] | permissive | # Add the directory containing this file to the start of the load path if it
# isn't there already.
$:.unshift(File.dirname(__FILE__)) unless
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
require 'git/author'
require 'git/base'
require 'git/branch'
require 'git/branches... | true |
355001fb4c4e639ae3b4076d950a0ae6891e98e6 | Ruby | artemasmith/bard | /app/models/activity.rb | UTF-8 | 789 | 2.59375 | 3 | [] | no_license | # == Schema Information
#
# Table name: activities
#
# id :integer not null, primary key
# amount_debet :decimal(, ) default(0.0)
# amount_credit :decimal(, ) default(0.0)
# payment_system_id :integer
# state :string(255)
# user_id :integer
# creat... | true |
f38388a8c2000e3630d78f8e3597a797a68506a3 | Ruby | jeanlinux/query_report | /lib/query_report/column_module/dsl.rb | UTF-8 | 5,397 | 2.875 | 3 | [
"MIT"
] | permissive | # Author:: A.K.M. Ashrafuzzaman (mailto:ashrafuzzaman.g2@gmail.com)
# License:: MIT-LICENSE
# The purpose of the column module is to define columns that are displayed in the views
require 'query_report/column_module/column'
module QueryReport
module ColumnModule
module DSL
attr_accessor :columns
... | true |
6b4aeee622dffcc428c835786dc888353822d00d | Ruby | ldgarber/ttt-10-current-player-002 | /lib/current_player.rb | UTF-8 | 217 | 3.515625 | 4 | [] | no_license | def turn_count(board)
counter = 0
board.each do |square|
counter += 1 if !(square == " ")
end
counter
end
def current_player(board)
if (turn_count(board) % 2) == 0
"X"
else
"O"
end
end
| true |
cd51de3b34ed02f59f5d036961308ed53f3c3d2b | Ruby | RachelAbaniwo/mini-estore-api | /app/lib/number.rb | UTF-8 | 105 | 2.859375 | 3 | [] | no_license | module Number
def self.is_integer?(some_string)
true if Integer(some_string) rescue false
end
end | true |
c1b417b69d1b6c22f08e08a4637a65b3314dc300 | Ruby | Jordana2210/fatec | /LISTA2/exercicio4.rb | UTF-8 | 1,370 | 2.75 | 3 | [] | no_license | class Livro
def initialize(tipo, preco)
@tipo = tipo
@preco = preco
end
def exibir_livro
puts "INFORMAÇÕES LIVRO"
puts "Tipo do livro: #{@tipo}"
puts "Preço do livro: #{@preco}"
end
end
class Loja
def initialize
@livros = []
end
def ad... | true |
c5784f52a103ebbcf7184d2a9358aca199be787d | Ruby | rrrene/yt | /lib/yt/models/snippet.rb | UTF-8 | 1,369 | 2.765625 | 3 | [
"MIT"
] | permissive | require 'yt/models/description'
module Yt
class Snippet
def initialize(options = {})
@data = options[:data]
end
# Return the title of the YouTube resource.
#
# @return [String] Title of the YouTube resource
def title
@title ||= @data.fetch 'title', ''
end
# Return the de... | true |
55104fd504780d39e2dc8942681be76872720fac | Ruby | hugopeixoto/hugopeixoto.net | /src/build.rb | UTF-8 | 3,691 | 2.546875 | 3 | [] | no_license | require 'yaml'
require 'mustache'
require 'kramdown'
require 'kramdown-syntax-coderay'
require 'rouge'
require 'date'
class YAMLFrontMatter
PATTERN = /\A(---\r?\n(.*?)\n?^---\s*$\n?)/m.freeze
class << self
def extract(content)
if content =~ PATTERN
[YAML.load(Regexp.last_match(2), permitted_clas... | true |
4b722b8aeaee020ef2c3e35312452602d01be55a | Ruby | carlosjhr64/base_convert | /lib/base_convert/entropia.rb | UTF-8 | 741 | 2.953125 | 3 | [
"MIT"
] | permissive | module BaseConvert
class Entropia < Number
def Entropia.bits_length_entropy(bits_request, base)
n,e,entropy = 0,1,2**bits_request
while e < entropy
n += 1
e *= base
end
b=Math.log(e,2)
# Actual bits, length, and entropy
return b,n,e
end
attr_reader :bits, :length, :entropy
d... | true |
19cf779bf5b2271d960c0b2e18f61d325b2a75f6 | Ruby | ashawhat/Parcel-Shipment-Calculator | /spec/parcels_spec.rb | UTF-8 | 494 | 2.65625 | 3 | [] | no_license | require 'rspec'
require 'parcels.rb'
describe Parcel do
it 'creates an instance of a class "Parcel"' do
test_parcel = Parcel.new(7, 2, 2, 2)
test_parcel.should be_an_instance_of Parcel
end
it "creates an instance of a parcel's dimensions" do
test_parcel = Parcel.new(7, 2, 2, 2)
test_parcel.volume.shoul... | true |
6513f42f695d8c8e50f9bcd95788924104f9fe54 | Ruby | askldjd/caseflow | /app/models/task.rb | UTF-8 | 1,321 | 2.609375 | 3 | [] | no_license | class Task < ActiveRecord::Base
belongs_to :user
belongs_to :appeal
COMPLETION_STATUS_MAPPING = {
0 => "Completed",
1 => "Cancelled",
# Establish Claim completion codes
2 => "Routed to RO"
}.freeze
class << self
def unassigned
where(user_id: nil)
end
def newest_first
... | true |
7dd451b31f34e96ee844a1ba6c348c577b3698b0 | Ruby | mcspach/lewagon_mx | /batch_465/01_Ruby/02_Flow_Array/Livecode/acronymize.rb | UTF-8 | 550 | 4 | 4 | [] | no_license | def acronymize(sentence)
return nil if sentence == '' # GUARDS
acronym = ''
# Break sentence into words
words = sentence.split(' ')
# Take the first letter of each word.
# From each element in the array, we take [0] of each word.
words.each do |word|
# All to uppercase
acronym += word[0].capitali... | true |
f0a51b2e29ff857e13d8b15eabe3008a41bfe311 | Ruby | sensu-plugins/sensu-plugins-network-checks | /bin/check-netfilter-conntrack.rb | UTF-8 | 1,827 | 2.765625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
# frozen_string_literal: true
#
# check-netfilter-conntrack
#
# DESCRIPTION:
# Check netfilter connection tracking table condition
#
# OUTPUT:
# plain text
#
# PLATFORMS:
# Linux
#
# DEPENDENCIES:
# gem: sensu-plugin
#
# USAGE:
# $ ./check-netfilter-conntrack.rb --warning 60 --critical ... | true |
b28fe99ae38ce20a60587546ca3d9c5db24fb7a7 | Ruby | d11wtq/rdo | /lib/rdo/driver.rb | UTF-8 | 4,332 | 3.09375 | 3 | [
"MIT"
] | permissive | ##
# RDO: Ruby Data Objects.
# Copyright © 2012 Chris Corbyn.
#
# See LICENSE file for details.
##
module RDO
# Abstract class that is subclassed by each specific driver.
#
# Driver developers should be able to subclass this, then write specs and
# override the behaviours they need to change.
#
# Ideally a... | true |
a8a700b3bcf937c76667616a707fc0080748912d | Ruby | zikarad/hand_dryer | /lib/hand_dryer.rb | UTF-8 | 167 | 2.515625 | 3 | [
"MIT"
] | permissive | require "hand_dryer/version"
module HandDryer
class Dryer
def dry
puts "Hands wet?"
puts "Drying ...!"
end
end
# Your code goes here...
end
| true |
0af9fbb7aa0aad30af60a8f128333b015ea746fe | Ruby | DavidOKeefe/learn_ruby | /08_book_titles/book.rb | UTF-8 | 452 | 3.546875 | 4 | [] | no_license | class Book
EXCEPTIONS = %w(a an and in of the)
attr_reader :title
def title=(title)
@title = titleize(title)
end
private
def titleize(title)
titleized_sentence = []
title.split.map do |word|
if EXCEPTIONS.include?(word)
titleized_sentence << word.downcase
else
title... | true |
14e07c1bbc918d0ce490622095992fffed6d9fb4 | Ruby | rizabarone/intro_to_programming_basics | /answerthree.rb | UTF-8 | 516 | 4.5 | 4 | [] | no_license | #3. Write a program that uses a hash to store a list of movie titles with the year they came out. Then use the puts command to make your program print out the year of each movie to the screen. The output for your program should look something like this.
movies = { nashville: 1975,
closer: 2004,
... | true |
c0e111706a7d938c144bb030fda98a8c3e566c57 | Ruby | nkhil/ruby-calendar | /src/calendar.rb | UTF-8 | 2,132 | 3.984375 | 4 | [] | no_license | #!/usr/bin/env ruby
require 'date'
time = Time.new
year = time.year
month = time.month
day_map = {
'Su' => 1,
'Mo' => 2,
'Tu' => 3,
'We' => 4,
'Th' => 5,
'Fr' => 6,
'Sa' => 7,
}
def abbreviate_day(day)
day.slice(0, 2)
end
def days_in_month(month, year)
Date.new(year, month, -1).day
end
def crea... | true |
681391cc9153c566ea5b9cef274b6081f6bdcef3 | Ruby | ftrafael/movies | /app/models/serie.rb | UTF-8 | 475 | 2.703125 | 3 | [] | no_license | class Serie
attr_reader :name, :overview, :poster_path
API_KEY = 'e2e6c0526e3737f2381684d2fd63d354'
def initialize(args)
args.each do |key, value|
instance_variable_set("@#{key.to_s}", value)
end
end
def self.populares
response = Themoviedb.client.get do |req|
req.url "tv/popular?... | true |
471d63b7ee90cb8dbbdb202df7280b88b27e0f92 | Ruby | garyf/prairie | /app/models/checkbox_boolean_field.rb | UTF-8 | 204 | 2.515625 | 3 | [
"MIT"
] | permissive | class CheckboxBooleanField < ChoiceField
def choice_new_able?
choices.count < 2
end
def type_human(downcase_p = false)
str = 'Checkbox field'
downcase_p ? str.downcase : str
end
end
| true |
af5fbbf3dbc6e38695f4701fa6e7901148e3683b | Ruby | sundayspecial/ita | /hw14/lib/script14_01.rb | UTF-8 | 555 | 2.5625 | 3 | [] | no_license | # ========================================================================
# Script = script14_01
# ========================================================================
# Description = "This script retrieves Mac address from users machine"
# Name = "Kristina Rudzinskaya"
# Email = "kristina.rudzinskaya@gmai... | true |
0cf8cc50b76f2e74fb1b588442e8fcc326114e8c | Ruby | HTGovdocs/deprecated_etl | /etl_solo_threaded.rb | UTF-8 | 1,103 | 2.515625 | 3 | [] | no_license | #for duplicate clusters without oclc numbers
require 'thread'
require 'collator'
@fin = open(ARGV.shift)
@fout = open(ARGV.shift, 'w')
@num_collators = ARGV.shift
@log = open(@num_collators+'.log','w')
@count = 0
start = Time.now
q = Queue.new
foreman = Thread.new do
@fin.each_with_index do |line, line_num|
q... | true |
11fef28f4b33e6a8b780a33a22a4dc0a114a53fe | Ruby | rejnowicz281/binary_tree | /node.rb | UTF-8 | 586 | 3.828125 | 4 | [] | no_license | class Node
attr_accessor :root, :left, :right
def initialize(root,left = nil,right = nil)
@root = root
@left = left
@right = right
end
def is_leaf_node?
left == nil && right == nil
end
def has_only_right?
left == nil && right != nil
end
d... | true |
37b11be0aa7b54956dd4830b1e68761622aac523 | Ruby | codingalpaca/ruby-tutorial | /guess.rb | UTF-8 | 423 | 4.46875 | 4 | [] | no_license | # 1. 產生一個數字
# 2. 讓使用者猜
# 3. 如果猜對了 -> 輸出 '猜對了'
# 不然 -> 輸出 '猜錯了'
number = Random.rand(99) + 1
while true
print '請猜一個 1 ~ 100 之間的數字:'
guess = gets.chomp.to_i
if guess == number
puts '你猜對了,答案是 ' + number.to_s
break
elsif guess > number
puts '猜太大了!'
else
puts '猜太小了!'
end
end
| true |
d5412f2dba7aae9c302886f3b78702858e6c23c6 | Ruby | trondiz/aoc2017 | /day6p12.rb | UTF-8 | 1,038 | 3.078125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/ruby
n = Array.new
i = 0
sum = 0
File.open("data", "r") do |f|
f.each_line do |l|
m=l.split(" ")
m.each_with_index do |v,i|
n[i]=v.to_i
end
i += 1
end
end
reg=false
history=Array.new
rec=1
str = false
while not str do
n.each_with_index do |a,i|
if a == n.max
o=a
n... | true |
56a93852de9fc9553b54a79085b892e0abf98f5f | Ruby | ged/arrow | /docs/manual/lib/editorial-filter.rb | UTF-8 | 1,440 | 2.890625 | 3 | [] | no_license | #!/usr/bin/ruby
#
# A manual filter to highlight content that needs editorial help.
#
# Authors:
# * Michael Granger <ged@FaerieMUD.org>
#
#
### Avoid declaring the class if the tasklib hasn't been loaded yet.
unless Object.const_defined?( :Manual )
raise LoadError, "not intended for standalone use: try the 'man... | true |
9ecd72f588637d3432b1d270dab264c794e231ad | Ruby | ylebedeva/ruby-labs | /course03/module01/assignment-MongoDB-Ruby-Driver-and-Rails/raceday/app/models/racer.rb | UTF-8 | 1,984 | 2.53125 | 3 | [] | no_license | class Racer
include ActiveModel::Model
attr_accessor :id, :number, :first_name, :last_name, :gender, :group, :secs
def initialize(params={})
@id = params[:_id].nil? ? params[:id] : params[:_id].to_s
@number = params[:number].to_i
@first_name = params[:first_name]
@last_name = params[:last_name]
@gender ... | true |
d3e3d50717ea0c68daeb34c3af5fdfde6f9b53da | Ruby | sateendradey/rottenpotatoes-rails-intro | /app/models/movie.rb | UTF-8 | 416 | 2.84375 | 3 | [] | no_license | class Movie < ActiveRecord::Base
def self.rating_values #gets all available rating values from db
Movie.uniq.pluck(:rating)
end
def self.with_ratings(ratings_list) #filters movies according to ratings
if (ratings_list)
Movie.where(:rating => ratings_list).all
else #i... | true |
a6de481c3445d35a118a4d25d4e1eff1c1292ef0 | Ruby | Markhenn/LS-RB101 | /Exercises/Easy 1/ex1.rb | UTF-8 | 565 | 4.9375 | 5 | [] | no_license | # Write a method that takes two arguments, a string and a positive integer, and prints the string as many times as the integer indicates.
=begin
Output:
Hello
Hello
Hello
=end
=begin
Problem: create a method that loops a give amount of time and that prints a string
input: string, integer
output: print to c... | true |
ad302a8bd392153bd0271545a3a345a6ed9d9270 | Ruby | kumpelblase2/RubyUniversityExercises | /Aufgabe_2/lib/larger_sum_square.rb | UTF-8 | 1,650 | 3.40625 | 3 | [] | no_license | $LOAD_PATH.unshift File.join(File.dirname(__FILE__),'../..','Extensions/lib')
require "ext_checks_v1"
require "ext_elems_v2"
require "ext_modules_v2"
require "ext_lists_v2"
require "min_max"
# Calculates the sum of the biggest two square numbers
# larger_sum_square ::= Int x Int x Int -> Nat ::
# Test (1, 2, 3) => 13,... | true |
0da75930b64a072627a172d3916d9bf0ef11b1c4 | Ruby | kojix2/ruby-edlib | /lib/edlib.rb | UTF-8 | 2,165 | 2.546875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require_relative 'edlib/edlibext'
module Edlib
class Aligner
def initialize(k: -1, mode: 'NW', task: 'DISTANCE', additional_equalities: nil)
mode = mode.to_s if mode.is_a? Symbol
task = task.to_s if task.is_a? Symbol
mode = mode.upcase if mode.is_a? String
t... | true |
2e2b288ba77c5537b1cbdeae2bcb36a0f40434e2 | Ruby | Mzril/Chess | /display.rb | UTF-8 | 946 | 3.359375 | 3 | [] | no_license | require 'colorize'
require_relative 'cursor.rb'
require_relative 'board.rb'
class Display
def initialize(board)
@board = board
@cursor = Cursor.new([0,0], board)
end
def render
@board.rows.each_with_index do |row,i|
row.each_with_index do |col,j|
if @cursor.cursor_pos == [i,j]
... | true |
db443df387656117827667a29b5b0835ade4e520 | Ruby | vesselinv/glove | /lib/glove/workers/cooccurrence_worker.rb | UTF-8 | 1,679 | 2.921875 | 3 | [
"MIT"
] | permissive | module Glove
module Workers
# Constructs the co-occurrence matrix for {Glove::Model}
class CooccurrenceWorker
extend ::Forwardable
# @!attribute [r] token_index
# @return [Hash{String=>Integer}] Clone of @caller.token_index
# @!attribute [r] word_biases
# @return [Array<(Glo... | true |
f828592e0668d175619af63ad796b215be58b0a1 | Ruby | AJOsmaston/student-directory | /directory.rb | UTF-8 | 3,720 | 4 | 4 | [] | no_license | require 'csv'
@students = [] # an empty array accessable to all methods
@students_by_cohort = {} # an empty hash accessable to all methods
@name = " "
@cohort = "September"
def print_header
puts "The students of Villains Academy".center(100)
puts "-------------".center(100)
end
def print_student_list
@students... | true |
7ea354e1aec4b0d3542dcc57096f74597babb768 | Ruby | QueirozMirella/TDD-ruby | /spec/matchers/atributos/atributos_spec.rb | UTF-8 | 823 | 3.0625 | 3 | [] | no_license | require 'pessoa'
describe 'Atributos' do
before(:context) do
puts ">>>>>>>>>> ANTES DE TODOS OS TESTES"
end
after(:all) do
puts ">>>>>>>>>> DEPOIS DE TODOS OS TESTES"
end
#before(:each) do
# @pessoa = Pessoa.new
#end
#after(:each) do
# @pessoa.nome = "Sem nome!"
# puts ">>>> #{@pessoa.inspect}"
... | true |
f0d6fcfbfe3613ed1f6cef376586a3ac85ccde11 | Ruby | chakeresa/sweater_weather | /app/facades/road_trips_create_facade.rb | UTF-8 | 508 | 2.53125 | 3 | [] | no_license | class RoadTripsCreateFacade
include Directionable
include Forecastable
def initialize(parameters)
@origin = parameters[:origin]
@destination = parameters[:destination]
end
def summary
forecast_at_destination[:summary]
end
def temperature
forecast_at_destination[:temperature]
end
... | true |
c7f6c85fc366eef79424c379273453cbddc47c94 | Ruby | ajh/speaky_csv | /spec/readme_spec.rb | UTF-8 | 1,995 | 2.78125 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
require 'support/active_record'
describe "Examples in README.md", :db do
it "has working examples" do
# For example ...
# in app/models/book.rb
class Book < ActiveRecord::Base
# ...
end
# in app/csvs/book_csv.rb
class BookCsv < SpeakyCsv::Base
define_csv_fi... | true |
fa4aa688cc98af6dd4497db5b64e67dec378f802 | Ruby | srycyk/in_order | /app/models/in_order/aux/sort_elements.rb | UTF-8 | 573 | 2.9375 | 3 | [
"MIT"
] | permissive |
module InOrder
module Aux
module SortElements
module_function \
def sort_elements(elements)
index = elements.size
sorted = Array.new(index)
element_id = nil
while index > 0
index -= 1
element = elements.find do |element|
... | true |
2010f22f48ced5c1d7ea3ef644549d83f1e05a92 | Ruby | LayllaRodrigues/ruby_start | /hashs.rb | UTF-8 | 269 | 3.359375 | 3 | [] | no_license | # coleção semelhante ao array, porem é feita com chave e valor.
carro = Hash[nome: 'Civic', marca: 'Honda', cor: 'Vermelho']
#{chamando apenas a marca do hash carro}
puts carro [:marca]
#{adicionando nova chave no hash carro}
carro[:modelo] = 'SI'
puts carro | true |
5ae61c567ab656c142b6f1ba06ad56ff8e490103 | Ruby | richardmable/ruby_adventure | /ruby_adventure.rb | UTF-8 | 1,448 | 4.09375 | 4 | [] | no_license | # Richard Mable
# Ruby Adventure
# Create a "choose your own adventure" style game using Ruby. Store characters as classes with unique attributes and methods.
# Use methods and recursive methods to simplify the logical
# flow of the game and the gets method to get user input.
# Use this exercise to be sure you're fami... | true |
e8c74970972c12e10df1d3588de495e01b4672d0 | Ruby | cul/ldpd-dcv | /lib/tasks/deduplication.rake | UTF-8 | 6,165 | 2.5625 | 3 | [] | no_license | namespace :dcv do
namespace :deduplication do
# Example usage:
# Let's say you have three directories that you want to search through, to find duplicates:
# 1. /digital/ingest/RBML/Oral_History_Digitized/mellon-audio-pres/corrie-oral-history-staging
# 2. /ifs/cul/ldpd/fstore/archive/mellon-audio-pres... | true |
b75316718e143da2ccbfb3a0f9dd2f5087e00d8c | Ruby | timeout/jpts_extractor | /lib/jpts_extractor/stack.rb | UTF-8 | 729 | 3.4375 | 3 | [] | no_license | require 'jpts_extractor/exceptions'
module JPTSExtractor
class Stack
include Enumerable
def initialize
@data = Array.new
end
def empty?
@data.empty?
end
def size
@data.size
end
def [](n)
if (n < 0 or n >= self.size)
raise StackIndexOutOfBoundsError.... | true |
09c9e01cdfe42636b9b588ed7364c67f1380f193 | Ruby | Dale-R-Harrison/RB101 | /small_problems/easy3/squaring_argument.rb | UTF-8 | 235 | 3.59375 | 4 | [] | no_license |
def multiply(num1, num2)
num1 * num2
end
def exponent(num, power)
i = 2
result = num
loop do
result = multiply(result, num)
i += 1
if i > power
return result
end
end
end
puts exponent(5, 5) == 3125
| true |
57bae0ff24ed1debaeca0d1000358884eed7da3d | Ruby | DouglasAllen/ruby-kickstart-4-rdoc | /session3/notes/17-variable-lengthed-params.rb | UTF-8 | 1,290 | 3.828125 | 4 | [] | no_license | class Session03Notes
=begin
=== variable lenght params
# After listing your ordinal and optional parameters, you can take
# a variable length of arguments. To do this, you use '*' before
# the parameter. In Ruby 1.8, it must be the last parameter.
# The parameters that match it will be put into an array.
def... | true |
1dddb07942e2f55ccb157fee24cd04f3f33fa493 | Ruby | kangethe12/starting-ruby | /numtoarray.rb | UTF-8 | 53 | 2.96875 | 3 | [] | no_license | x = 1234
y = x.to_s.scan(/\d/)
z= y.map {|i| i.to_i}
| true |
8eacd828bf544186218be1ee34d47e25a58a76df | Ruby | FelixCoutinho/tamer | /test/unit/account_test.rb | UTF-8 | 1,149 | 2.75 | 3 | [] | no_license | require 'test_helper'
class AccountTest < ActiveSupport::TestCase
test "account attributes must not be empty" do
account = Account.new
assert account.invalid?
assert account.errors[:name].any?
assert account.errors[:opening_balance].any?
end
test "account name must not be empty" do
acco... | true |
0912bd589caaaa05a01b864c1d9051732f413ddc | Ruby | gatperdut/chatomud | /app/lib/chato_mud/controllers/inventories/inventory_controller.rb | UTF-8 | 2,778 | 2.65625 | 3 | [] | no_license | require "chato_mud/mixins/inventories/ingredients_container"
require "chato_mud/mixins/inventories/light_sources_container"
require "chato_mud/mixins/inventories/boards_container"
require "chato_mud/mixins/inventories/weight_bearer"
require "chato_mud/controllers/items/item_controller"
module ChatoMud
module Contr... | true |
098d0c0826ca98a41ccff55fb7c13dd39b360594 | Ruby | tamarabolmanac/rails_merchant | /merchant/app/models/order.rb | UTF-8 | 176 | 2.625 | 3 | [] | no_license | class Order < ApplicationRecord
has_many :order_items,dependent: :destroy
def total
sum = 0;
self.order_items.each do |item|
sum+=item.subtotal
end
return sum
end
end
| true |
2e2c3883f83aed5bddfc027e29effd829dc153e4 | Ruby | jae-mon/bike-tour | /spec/models/slogan_spec.rb | UTF-8 | 1,054 | 2.546875 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe Slogan, :type => :model do
subject {
described_class.new(firstname: "John",
lastname: "Doe",
email:"john.doe@example.com" ,
slogan: "Lorem ipsum")
}
it "is valid with valid att... | true |
adc4887e80ee616f258df407a8cd27ece5be2cc9 | Ruby | CamiloYate09/vagrant | /lib/vagrant/util/network_ip.rb | UTF-8 | 1,028 | 3.015625 | 3 | [
"MIT"
] | permissive | require "ipaddr"
module Vagrant
module Util
module NetworkIP
# Returns the network address of the given IP and subnet.
#
# If the IP address is an IPv6 address, subnet should be a prefix
# length such as "64".
#
# @return [String]
def network_address(ip, subnet)
... | true |
09359f2cebed950dd18562b40271738ab9bb5d0c | Ruby | yoshinari-nomura/enumdate | /lib/enumdate/date_helper.rb | UTF-8 | 1,242 | 3.3125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Enumdate
# Helper for date-calculation.
module DateHelper
private
# Make a date by DAY like ``1st Wed of Nov, 1999''.
# caller must make sure:
# YEAR and MONTH must be valid
# NTH must be < 0 or > 0
# WDAY must be 0:Sun .. 6:Sat
#
# raise ... | true |
6e72670883e34947e85905e6a6b8a790fad68b8b | Ruby | pjambet/redis-in-ruby | /code/chapter-4/pttl_command.rb | UTF-8 | 639 | 2.734375 | 3 | [
"MIT"
] | permissive | class PttlCommand
def initialize(data_store, expires, args)
@logger = Logger.new(STDOUT)
@logger.level = LOG_LEVEL
@data_store = data_store
@expires = expires
@args = args
end
def call
if @args.length != 1
"(error) ERR wrong number of arguments for 'PTTL' command"
else
ke... | true |
e758f9a6862c1595b8f85a75102e0a5d38108979 | Ruby | kaochenlong/programming_basic | /010-if_else_elsif.rb | UTF-8 | 208 | 3.796875 | 4 | [] | no_license | # 如果...不然就...要不然就
# if ... elsif ... else ...
weather = "下雨"
if weather == "下雨"
puts "待在家!"
elsif weather == "出太陽"
puts "出去玩!"
else
puts "在家睡覺!"
end | true |
0e9a27c5f1f4e92ccba556546d99a7fe014cb3b5 | Ruby | teleological/active_access | /lib/active_access/attribute_methods.rb | UTF-8 | 1,969 | 2.703125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive |
require 'active_support/core_ext'
module ActiveAccess
module AttributeMethods
extend ActiveSupport::Concern
included do
class_attribute :_attribute_access, :instance_writer => false
self._attribute_access = {}
end
module ClassMethods
def attr_private(*attrs)
update_attr... | true |
1b83a220508ef5c6fd054e7d66c509d48ff218b4 | Ruby | omardelarosa/ruby_euler_lab | /lib/mathy.rb | UTF-8 | 199 | 3.578125 | 4 | [] | no_license | def sum_of_list(list)
list.inject {|sum,x| sum+x }
end
def is_n_multiple_of_x(n,x)
# int,int -> bool
if n % x == 0
#is a multiple
true
else
false
end
end | true |
6cd2d5030f5ed5bec174f39bbab7bd40cdee5321 | Ruby | finalbout/programming-univbasics-3-methods-scope-lab-sfo01-seng-ft-042020 | /lib/catch_phrases.rb | UTF-8 | 352 | 2.921875 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def mario
status = 'Thank You Mario! But Our Princess Is In Another Castle!'
puts phrase = "It's-a me, Mario!"
end
def toadstool
puts status = 'Thank You Mario! But Our Princess Is In Another Castle!'
end
def link
puts cool = "It's Dangerous To Go Alone! Take This."
end
def all_phrases
puts together = "#{... | true |
37d94649bd4c0f3ebb08ede13086b631022f322f | Ruby | TrentonZero/gruesome | /web.rb | UTF-8 | 2,225 | 2.5625 | 3 | [] | no_license | require 'sinatra'
require 'mongo'
require 'uri'
$log = ""
$seq = 0
get '/' do
response = "<p>Welcome to herokuGruesome.</p>"
response += "<form name=\"input\" action=\"/\" method=\"post\">"
response += "Game Key: <input type=\"text\" name=\"gamekey\">"
response += "<input type=\"submit\" value=\"... | true |
9024504f7a807ec8757229207a12c461db6aafbf | Ruby | CelineKaslin/Ruby_Codewars | /spec/Dee_generous_tipper_spec.rb | UTF-8 | 747 | 2.921875 | 3 | [] | no_license | require "./kata_rank_7kyu/Dee_generous_tipper"
describe "Dee the generous tipper" do
it "returns the tip with a rate of 0" do
expect(calc_tip(25, 0)).to eq 2
expect(calc_tip(54, 0)).to eq 4
end
it "returns the tip with a rate of 1" do
expect(calc_tip(115, 1)).to eq 13
expect(calc_tip(5, 1)).to eq 2
expect... | true |
a9d83cebc4aeec82bb92ca8099dbda7115d813ee | Ruby | Brian-Triplett/tts_wilmington | /homework/steven/homework_2.2/shufflecards.rb | UTF-8 | 1,202 | 4.25 | 4 | [] | no_license | #Create a program that will shuffle a deck of cards and assign a number of players two cards.
#Make sure to ask the user for the number of players who are playing and that there are no duplicate cards in the deck!
puts "How many players?"
num_players = gets.chomp.to_i
suit = [ D, S, C, H]
deck = [0, 1, 2, 3, 4, 5... | true |
51dc2ffca5f370982537817ac689e827501bc58c | Ruby | stevenistan/fa16-hw1 | /foobar.rb | UTF-8 | 250 | 3.390625 | 3 | [] | no_license | class Foobar
def self.baz(a)
# Class method
# Call with `Foobar.baz`
a.map! {|b| b.to_i}
a.map! {|b| b + 2}
a.delete_if {|b| (b % 2) != 0}
a.uniq!
a.delete_if {|b| b > 10}
a.inject(0) {|sum, b| sum + b}
end
end
| true |
206bef36e93ba3b0c6755113baa8ba2d6e30a1b2 | Ruby | mgurbanzade/simpler | /lib/simpler/router/route.rb | UTF-8 | 1,200 | 2.984375 | 3 | [] | no_license | module Simpler
class Router
class Route
attr_reader :controller, :action, :params
def initialize(method, path, controller, action)
@method = method
@path = path
@controller = controller
@action = action
@params = {}
end
def match?(method, path)
... | true |
7ede6dbc56c720f44ca85c6aa08573b24c9f3b6e | Ruby | intfrr/raidit | /app/interactors/list_raids.rb | UTF-8 | 324 | 2.625 | 3 | [] | no_license | ##
# Returns the full list of raids that given user is allowed to see.
##
class ListRaids
def self.for_guild(guild)
for_guild_on_date(guild, nil)
end
def self.for_guild_on_date(guild, date)
Repository.for(Raid).find_raids_for_guild_and_day(guild, date).
sort {|r1, r2| r2.when <=> r1.when }
end
... | true |
f2ee71380240650e3b23944fce5efcdf8e0c6e7c | Ruby | 0000marcell/shoes4 | /spec/shoes/widget_spec.rb | UTF-8 | 480 | 2.640625 | 3 | [
"MIT"
] | permissive | require 'shoes/spec_helper'
class Smile < Shoes::Widget
def initialize(caption)
banner caption
end
end
describe Shoes::Widget do
let(:app) { Shoes::App.new }
it "creates dsl method on App" do
app.should respond_to(:smile)
end
it "generates instances of its subclass" do
app.smile("Cheese!").s... | true |
7d94bbc709e15d999718c20d5700afb81bf7e302 | Ruby | mdudzinski/sugarcube | /spec/cocoa/nsattributedstring_spec.rb | UTF-8 | 3,920 | 2.921875 | 3 | [
"BSD-2-Clause"
] | permissive | describe 'NSAttributeString' do
describe "should support all attribute names" do
before do
@subject = 'test'.attrd
end
it "should be sane" do
@subject.isEqualToAttributedString('test'.attrd).should == true
end
# don't care about:
# it 'should have `attachment`' do
# @subjec... | true |
da74869ea6c9f45675517e9d516c1530c2667aad | Ruby | takaxyz/atcoder | /ABC135/D.rb | UTF-8 | 505 | 2.859375 | 3 | [] | no_license | MOD=10**9+7
s=gets.chomp.split("").reverse
dp=Array.new(s.size+1).map{Array.new(13,0)}
dp[0][0] = 1
l = 1
s.each_with_index do |c,i|
if c == '?'
0.upto(9) do |k|
m = k.to_i * l % 13
0.upto(12) do |j|
mm = (j + m) % 13
dp[i+1][mm] += dp[i][j]
dp[i+1][mm] %= MOD
end
end... | true |
1d85cb0291ebabba25dc17cf399517abf86a181e | Ruby | chao-mu/Exhumer | /lib/exhumer/module/bot.rb | UTF-8 | 648 | 2.640625 | 3 | [] | no_license | require 'exhumer/module'
class Exhumer::Module::Bot
def add_retrieval_method(*schemes, &f)
schemes.each do |scheme|
if retrieval_methods.has_key? scheme
warn "WARNING: add_retrieval_method overriding scheme #{scheme}"
end
retrieval_methods[scheme] = f
end
end
def retrieval_met... | true |
dd89d39bea23b3b8e6eb569e9a37dcba0f48fdef | Ruby | kevxo/my_team_avatar | /app/facades/avatar_facade.rb | UTF-8 | 258 | 2.65625 | 3 | [] | no_license | class AvatarFacade
def self.all_avatars
data = AvatarService.all_avatars
data.map do |avatar_data|
Avatar.new(avatar_data)
end
end
def self.avatar(avatar_id)
data = AvatarService.avatar(avatar_id)
Avatar.new(data)
end
end | true |
b7655468cae035d0e050fdf2fc820bb2fd98082b | Ruby | jweather/sonic-pi | /app/server/vendor/hamster/spec/hamster/set/hash_spec.rb | UTF-8 | 430 | 2.578125 | 3 | [
"MIT"
] | permissive | require "spec_helper"
require "hamster/set"
describe Hamster::Set do
describe "#hash" do
describe "on an empty set" do
before do
@result = Hamster.set.hash
end
it "returns 0" do
@result.should == 0
end
end
it "values are sufficiently distributed" do
(1..400... | true |
38f3a8bc78a53a4f59e7d4ca874f415b37b72d25 | Ruby | jthagerman/binary_search | /binary_search.rb | UTF-8 | 1,041 | 3.890625 | 4 | [] | no_license | #Assumes array is sorted!
def binary_search(array, target)
midpoint = array[array.length/2]
if(target == midpoint)
return true
elsif(array.length <= 1)
return false
elsif(target < midpoint)
binary_search(array[0..((array.length/2)-1)], target)
else
binary_s... | true |
224052d24447fbe39cdea4076bebe87bae11d3be | Ruby | aleDVM/Experiencia15 | /ejercicio3.rb | UTF-8 | 944 | 4.0625 | 4 | [] | no_license | # Crear un metodo que reciba el archivo peliculas.txt, lo abra y
# cuente la cantidad total de palabras. El metodo debe devolver este valor.
def read(text)
file = File.open(text, 'r')
data = file.read
file.close
print data.split(' ').size
end
read('peliculas.txt')
# Crear un metodo similar para que ademas recib... | true |
7d3ec34366125a28fd0f809c1839cedbf2cf080c | Ruby | kxhitiz/cf_jukebox | /raunaktridev.rb | UTF-8 | 332 | 3.1875 | 3 | [] | no_license | class Jukebox
attr_accessor :playlist
def initialize(playlist)
@playlist = playlist
end
def next_track
current_track = @playlist.shift()
@playlist.push(current_track)
print current_track
end
def pre_track
current_track=@playlist.pop()
@playlist.unshift(current_track)
print current_tr... | true |
2499a207bd788d61c45d3360a286ff9b23302b3f | Ruby | YaEvan/ruby_study | /self_class.rb | UTF-8 | 875 | 3.890625 | 4 | [] | no_license | #class << Hello
# def hello(name)
# puts "#{name} said hello"
# end
#end
#Hello.hello("Jhon")
#class HelloWorld
# class << self
# def hello(name)
# puts "#{name}"
# end
# end
#end
#HelloWorld.hello("haha")
=begin
class Point
attr_accessor :x, :y
protected :x=, :y= # ss
def initi... | true |
4c1562494835b3a79ae5733ced896cab8f8bb4f1 | Ruby | Catkin92/week2_weekend_homework | /specs/karaoke_spec.rb | UTF-8 | 1,970 | 3.203125 | 3 | [] | no_license | require('minitest/autorun')
require('minitest/rg')
require_relative('../karaoke.rb')
require_relative('../room.rb')
require_relative('../guest.rb')
require_relative('../song.rb')
class TestKaraokeClub < MiniTest::Test
def setup
@guest1 = Guest.new("John", 25.00, "Love Shack")
@guest2 = Guest.new("Eugene", ... | true |
b0a359e8f76e28e5ab5b51f39f742788f39c1e86 | Ruby | AdamClemons/news_reader | /lib/news_reader/scraper.rb | UTF-8 | 3,119 | 3.03125 | 3 | [
"MIT"
] | permissive | class NewsReader::Scraper
ARTICLES_PER_SECTION = 10 # Number of articles per section to download
# Gets the Sections
def self.scrape_sections(home_url)
html = open(home_url)
page = Nokogiri::HTML(html)
# The drop(2).first(5) is due to selecting the sections we want. The first ... | true |
a81216bf2d630c5059d09a8d192a612388c020cb | Ruby | abwlprg/vets-api | /lib/workflow/base.rb | UTF-8 | 807 | 2.515625 | 3 | [
"CC0-1.0",
"LicenseRef-scancode-public-domain"
] | permissive | # frozen_string_literal: true
module Workflow
class Base
# For subclasses, store the list of Tasks to run in the order defined
class << self
attr_accessor :chain
def run(task, **args)
@chain ||= []
@chain << { mod: task, args: args }
end
end
def start!(trace: nil)
... | true |
d551e521b5d93d786259d7a5f6284199b632bb1e | Ruby | Senjai/SCPRv4 | /app/models/program.rb | UTF-8 | 2,633 | 2.984375 | 3 | [] | no_license | # Public API for Programs
#
# When you pass in episodes, it has to be either an Array or a Relation
# This is to prevent accidental loading of hundreds of episodes.
class Program
include Concern::Methods::AbstractModelMethods
class << self
def all
(KpccProgram.all + ExternalProgram.all).map(&:to_program)... | true |
0c9898492f10c736e7f069070760ea0d289d5949 | Ruby | wdhorton/whales | /whales_actions/lib/whales_dispatch/params.rb | UTF-8 | 1,245 | 2.625 | 3 | [
"MIT"
] | permissive | require 'uri'
module WhalesDispatch
class Params
def initialize(req, route_params = {})
parsed_query_string = parse_www_encoded_form(req.query_string)
parsed_req_body = parse_www_encoded_form(req.body)
@params = parsed_query_string.merge(parsed_req_body).merge(route_params)
end
def []... | true |
f296b500704f7d7b1dc11aaefb9e42b95989a842 | Ruby | kipcole9/calendrical-ruby | /lib/calendrical/roman_numerals.rb | UTF-8 | 4,398 | 3.8125 | 4 | [
"MIT"
] | permissive | #
# Roman numerals
#
# Generates roman numerals from integers and vice-versa
#
# Author: Dave Burt <dave at burt.id.au>
#
# Fine print: Provided as is. Use at your own risk. Credit's appreciated if you use my code.
#
# http://media.pragprog.com/titles/fr_quiz/code/roman_numerals/roman_numerals.rb
# Contains methods... | true |
8395c237f18373120a76c6d3f926c4a62789076c | Ruby | jackclarkeparker/RB101 | /lesson_6/tictactoe/ai_defense.rb | UTF-8 | 7,623 | 3.90625 | 4 | [] | no_license | =begin
Aim:
The computer currently picks a square at random. That's not very interesting.
Let's make the computer defensive minded, so that if there's an immediate
threat, then it will defend the 3rd square. We'll consider an "immediate threat"
to be 2 squares marked by the opponent in a row. If there's no immediate ... | true |
f73be2ca1dc9575ab7c6db6a15a1360d28116981 | Ruby | mnhollandplum/back-end | /app/facades/weather_facade.rb | UTF-8 | 226 | 2.71875 | 3 | [] | no_license | class WeatherFacade
class << self
def forecast(city)
data = WeatherService.get_3_day_forecast_data(city)
data[:forecast][:forecastday].map do |info|
WeatherInfo.new(info)
end
end
end
end
| true |
79594d83c82be4dd45bc48261282741080eeda72 | Ruby | pocari/algorithm | /chap3/q_3_3.rb | UTF-8 | 397 | 3.46875 | 3 | [] | no_license | $max_value = 100
def get_answer(ary)
min1 = $max_value + 1
min2 = min1 + 1
ary.each do |v|
if min1 < v && v < min2
min2 = v
elsif v < min1
min2 = min1
min1 = v
end
end
p [:min2, min2]
min2
end
ary = 2.upto($max_value).to_a.shuffle.take(10).map {_1 + 2}
p ary
p [:expected, ar... | true |
e81e22d5999d73c9ffba17734fef418f4bc81aee | Ruby | 4llankayan/curso_ruby_puro | /decrease_request.rb | UTF-8 | 314 | 3.78125 | 4 | [] | no_license | word = ""
decreased_word = []
puts "Digite a palavra que quer ver ao contrário"
word = gets.chomp
word.split # transformar string em array
puts word
for i in (word.length - 1).downto(0)
decreased_word.push(word[i])
end
puts "A palavra ao contrario fica: #{decreased_word.join}" #transformar array em string | true |
e2394f1e3248a582a848b7795c2b2292162dd086 | Ruby | Alex223124/OrdersApp | /app/services/service_combination.rb | UTF-8 | 971 | 2.890625 | 3 | [] | no_license | class ServiceCombination
def initialize(params)
@start_day = Date.parse(params[:start_date])
@end_day = Date.parse(params[:end_date])
end
def calculate
Order.new do |order|
order.start_date = @start_day
order.end_date = @end_day
order.days_amount = order_days_amount
order.ord... | true |
4b764b0b5b04adaa6c376c37aaf8e0cfbd9b9ad3 | Ruby | JoeyLemur/dupcheck | /dupcheck.rb | UTF-8 | 3,021 | 3.09375 | 3 | [] | no_license | require 'find'
require 'digest'
require 'sqlite3'
# Used when storing database
DBNAME = "dupcheck.db"
# First argument is a directory to start searching at
startPoint = ARGV[0]
if startPoint.nil? then
STDERR.puts "Feed me a start directory!"
Kernel.exit(1)
end
# Second (or more) are dot-extensions (case-insensit... | true |
11237eafca890118484125a66510fa877dcf08e0 | Ruby | RubyCamp/rc2012w_g1 | /scenes/stages/characters/advent_map.rb | UTF-8 | 428 | 3.265625 | 3 | [] | no_license |
AdventPos = Struct.new(:layer, :x, :y, :mx, :my)
class AdventMap
attr_reader :adv_pos
def initialize(adv_pos)
@adv_pos = adv_pos.map do|n|
[n[3], n[4], n[1], n[2], layer_to_z_index(n[0])]
end
end
def get_random
@adv_pos[rand(@adv_pos.size)]
end
def layer_to_z_index(layer)
c... | true |
92bd3d406675035248879723ba4d0f74ffbc2676 | Ruby | techashish12/cbba | /test/unit/article_test.rb | UTF-8 | 4,039 | 2.53125 | 3 | [] | no_license | require File.dirname(__FILE__) + '/../test_helper'
class ArticleTest < ActiveSupport::TestCase
def test_last_articles_for_main_subcategory
article = Factory(:article)
assert_not_nil article.main_subcategory
article.last_articles_for_main_subcategory
article.subcategories.delete_all
assert_n... | true |
a234e8c279e06bc94acf2d40257e242da450ccb6 | Ruby | pocke/steep | /stdlib/builtin.rbi | UTF-8 | 2,213 | 2.71875 | 3 | [] | no_license | class BasicObject
def __id__: -> Integer
end
class Object <: BasicObject
include Kernel
def tap: { (self) -> any } -> self
def to_s: -> String
def hash: -> Integer
def eql?: (any) -> _Boolean
def ==: (any) -> _Boolean
def ===: (any) -> _Boolean
def !=: (any) -> _Boolean
def class: -> class
def to... | true |
52e3aff40df2af30aa9cd92661e8da05729044e7 | Ruby | testsvr01/first_rb_repro | /hw3.rb | UTF-8 | 325 | 3.609375 | 4 | [] | no_license | puts "gave me a name"
name=gets.chomp
a_w=[name]
#for names in a_w[name]
#puts "#{names}, "
#end
#name.each_char {|c| print c, ' ' }
#name.split("\r\n").each do |i|
#puts ""
#end
#name.split("").each do |i|
# puts i
#end
a_w[0].split("").each do |n|
puts "#{n}, "
end
print a_w[0].spli... | true |
7c314b8d9c06615b2fb17fb35a8ab9b82d170aa8 | Ruby | zhuliangyu/9-23-2016 | /class/square.rb | UTF-8 | 287 | 3.75 | 4 | [] | no_license | class Square
attr_accessor :width
attr_accessor :height
def initialize(width,height)
@width=width
@height=height
end
def area
return @width*@height
end
def is_square?
return @width==@height?true:false
end
end
s=Square.new(3,4)
p s.area
p s.is_square? | true |
26eb1201664796b100a6bff8803071297b0fc2a5 | Ruby | ga-wolf/WDI10-Homework | /chris-purcell/week_04/intro/loops.rb | UTF-8 | 529 | 3.734375 | 4 | [] | no_license | i = 10
while i >= 0
puts "i is currently : #{ i }"
i = i - 1 # or i -= 1
#sleep 0.4
end
puts "Blast"
puts "=" * 80
i = 10
until i == 0
puts "i is currently: #{ i }"
i -= 1
end
# Iterator / ennumerables (THIS IS THE PREF METHOD FOR LOOPS)
(1..10).each do |num| ## this 'num' only lives inside the loop itself. ... | true |
e70136581536f4a111fc4465aea13563e3fe978a | Ruby | abak-press/redis_counters | /lib/redis_counters/unique_values_lists/base.rb | UTF-8 | 2,104 | 2.734375 | 3 | [] | no_license | # coding: utf-8
require 'redis_counters/base_counter'
require 'redis_counters/clusterize_and_partitionize'
module RedisCounters
module UniqueValuesLists
# Базовый класс списка уникальных значений,
# с возможностью кластеризации и партиционирования.
class Base < RedisCounters::BaseCounter
include ... | true |
513ce6f8280402bbd11c6ec6841076d067b1810d | Ruby | marynn/RubyTraining | /Exercises/numbers_ex1.rb | UTF-8 | 823 | 4.53125 | 5 | [] | no_license | # Mathematical operations with numbers entered by the user
puts 'What do you want the first number to be?'
first_number = gets.chomp
puts 'What do you want the second number to be?'
second_number = gets.chomp
# As gets.chomp returns a String, it needs to be converted to a float number,
# in order for division result... | true |
31b59b9fd2b920a3bd12495436e0b61900e01b13 | Ruby | enkessler/cuke_slicer | /testing/rspec/spec/slicer_integration_spec.rb | UTF-8 | 12,353 | 2.578125 | 3 | [
"MIT"
] | permissive | require_relative '../../environments/rspec_env'
RSpec.describe 'Slicer, Integration' do
let(:clazz) { CukeSlicer::Slicer }
let(:slicer) { clazz.new }
let(:test_file) { "#{@default_file_directory}/a_test.feature" }
let(:test_file_text) do
"Feature: Test feature
@tag
Scenario: Test scenario
... | true |
a3a52151864a332c243740c1f5605620b119237e | Ruby | alielashram/salaam_gem | /test/test_salaam.rb | UTF-8 | 350 | 2.859375 | 3 | [
"MIT"
] | permissive | require 'test/unit'
require 'salaam'
class SalaamTest < Test::Unit::TestCase
def test_english_peace
assert_equal "peace",
Salaam.hi("english")
end
def test_any_peace
assert_equal "peace",
Salaam.hi("ruby")
end
def test_arabic_peace
assert_equal "Salaam 'alayka ya RasulAllah",
... | true |
c38f05ef6846eaaeb72c8278494cf549001ac228 | Ruby | GovTechSG/micropurchase | /app/view_models/confirm_bid_view_model.rb | UTF-8 | 509 | 2.859375 | 3 | [
"CC0-1.0",
"LicenseRef-scancode-public-domain"
] | permissive | class ConfirmBidViewModel
attr_reader :auction, :bid
def initialize(auction:, bid:)
@auction = auction
@bid = bid
end
def auction_id
auction.id
end
def bid_amount
bid.amount
end
def title
auction.title
end
def time_left
"Ends in #{distance_of_time_to_now}"
end
def h... | true |
089ea82e2949c1952c06adb7a99f2e79211f04f4 | Ruby | ujihisa/asd2 | /copy_write.rb | UTF-8 | 228 | 2.828125 | 3 | [] | no_license |
class Copy
def initialize(reader, writer)
@reader = reader
@writer = writer
end
def copy
writer.write(reader.read)
end
end
class ReadKeyboard
def read
end
end
class WritePrinter
def write
end
end
| true |
9ba148576ec669ddade1bbade301244e625540fb | Ruby | bergerjosh11/week7 | /pokr/hands/base_hand.rb | UTF-8 | 1,074 | 3.203125 | 3 | [] | no_license | class BaseHand
attr_reader :cards
def initialize(cards)
@cards = cards
end
def valid?
false
end
private
def flush?
cards.map(&:suit)uniq.count == 1
end
def straight?
straight_range.to_a == cards.map(&:rank).sort
#sorted_ranks = ranks.sort
#if sorted_ranks.uniq.count =... | true |
be2ef0fb08e4a120fc127bd0458dc76a0aced73f | Ruby | dangxuanvuong98/ebnf | /spec/ll1/scanner_spec.rb | UTF-8 | 5,901 | 2.515625 | 3 | [
"Unlicense",
"LicenseRef-scancode-public-domain"
] | permissive | # coding: utf-8
$:.unshift ".."
require 'spec_helper'
require 'ebnf'
describe EBNF::LL1::Scanner do
describe ".new" do
it "initializes with a StringIO" do
scanner = EBNF::LL1::Scanner.new(StringIO.new("line1\nline2\n"))
expect(scanner.rest).to eq "line1\nline2\n"
expect(scanner).not_to be_eos
... | true |
82a4dc4ad4b157cd4008d05ae82ae4ff3640ea45 | Ruby | fmancinelli/cloud-templates-ruby | /lib/aws/templates/utils/parametrized/constraint/depends_on_value.rb | UTF-8 | 1,770 | 2.6875 | 3 | [
"Apache-2.0"
] | permissive | require 'aws/templates/utils'
module Aws
module Templates
module Utils
module Parametrized
class Constraint
##
# Switch-like variant check
#
# Recursive check implementing switch-based semantics for defining
# checks need to be performed depending o... | true |
3b01ee4aa0d331685e79d0560bff7072550f800c | Ruby | neontuna/assignment_rspec_ruby_tdd | /lib/stockpicker.rb | UTF-8 | 564 | 3.5 | 4 | [] | no_license | def stockpicker(prices)
raise ArgumentError unless prices.is_a?(Array)
raise ArgumentError unless prices.length > 2
raise ArgumentError unless prices.all? { |v| v.is_a?(Integer) }
best_profit = 0
answer = []
prices.each_with_index do |value, test_day|
test_day.upto(prices.length-1) do |compare_day|
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.