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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
364c97e2614a60114598a1f570def86293df7796 | Ruby | danielbpc2/GymPass-Kart-Log | /lib/controller/racer_records_controller.rb | UTF-8 | 3,301 | 3.25 | 3 | [] | no_license | class RacerRecordsController
def initialize(csv_file_path = '')
# Load csv and instanciate all race records
# Carrega o csv e instancia todos os RaceRecords
RacerRecord.load_all_records(csv_file_path)
# create view
# Cria a view
@view = RaceView.new
end
# create the results of the race an... | true |
2089c0cdab017fb32a36065a1071902a15aa6f7b | Ruby | geekjuice/artgrabbr | /spec/controllers/buyers_controller_spec.rb | UTF-8 | 5,933 | 2.609375 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
# This spec was generated by rspec-rails when you ran the scaffold generator.
# It demonstrates how one might use RSpec to specify the controller code that
# was generated by Rails when you ran the scaffold generator.
#
# It assumes that the implementation code is generated by the rails scaffold
... | true |
5ad173107cd9c77102d6e744e9bdc011d9ccf59e | Ruby | norkuy/LS_Programming_Foundations | /lesson_4/methods_and_more_methods_ex7.rb | UTF-8 | 288 | 3.578125 | 4 | [] | no_license | [1, 2, 3].any? do |num|
puts num
num.odd?
end
# Block's return value is [true, false, true] and any?
# would return true because atleast one element in the
# block's return value is true. any? only iterates once
# because the first element evaluates to true and can
# therefore stop. | true |
f7e344237256ddf822ace82132cbab2163894b3a | Ruby | irockfern/phase-0-tracks | /ruby/hashes.rb | UTF-8 | 1,419 | 3.59375 | 4 | [] | no_license | #name, age, #children, decor theme, dog?, cat?
#prompt user for information
#convert input to appropriate data type
#print hash to screen
#update information
#if "none" skip
#elsif {key} update
#print updated information
client = {
name:"nil",
age:"nil",
children: "nil",
decor:"nil",
dogs:"nil",
cats:"nil",
}... | true |
ee6509210570bf2ecbd2f96fbb9ae5b3583924b5 | Ruby | glassjoseph/black_thursday | /lib/customer.rb | UTF-8 | 639 | 2.8125 | 3 | [] | no_license | require_relative '../lib/data_access'
require_relative '../lib/item_data_access'
class Customer
include ItemDataAccess
include DataAccess
attr_reader :id,
:first_name,
:last_name,
:created_at,
:updated_at
def initialize(data, parent=nil)
@id = data... | true |
b9a8d3e544b76c30663a6a639a47f821e4c50847 | Ruby | MagicKey23/App-Academy-Exercises-Problems | /blocks_project/lib/part_1.rb | UTF-8 | 643 | 3.828125 | 4 | [] | no_license | def select_even_nums(arr)
arr.select(&:even?)
end
def reject_puppies(arr)
arr.reject do |dog|
if dog["age"] < 3
dog
end
end
end
def count_positive_subarrays(arr)
arr.count {|num| num.sum > 1 }
end
def aba_translate(word)
vowels = "aeiou"
array_word = word.split("")
array_word.each_with_index do |c... | true |
459335d5fa60e6b0593da418a8ea4f15ed43e5a3 | Ruby | 18bytes/whoopee | /courses/saas/assignment1_part5.rb | UTF-8 | 1,703 | 3.90625 | 4 | [] | no_license | class Class
def attr_accessor_with_history(attr_name)
attr_name = attr_name.to_s # make sure it's a string
attr_reader attr_name # create the attribute's getter
attr_reader attr_name+"_history" # create bar_history getter
class_eval "def #{attr_name}= val
@#{attr_name} = val
... | true |
1f1f3bffdcd5162ca7ba6871eb0aee8ef82e91ec | Ruby | dedayog/Learning-Ruby | /Rubyrush.ru/step050.rb | UTF-8 | 2,167 | 3.546875 | 4 | [] | no_license | class Interface
def initialize(ary)
@array_of_heroes = ary
@current_hero = ''
@user_select = ''
@quit = false
end
def user_select
print "Ваш выбор (макс. #{@array_of_heroes.size}) или имя героя > "
@user_select = STDIN.gets.chomp
@quit = true if (@user_select == 'q' || @user_select =... | true |
b91bc39ba4748c390459a1668e7f4971ca0e7b81 | Ruby | Lewington-pitsos/steel_balls | /rubyscripts/logic/state_evaluator/rating_overseer/state_expander/arrangement_generator/ball_generator.rb | UTF-8 | 500 | 3.265625 | 3 | [] | no_license | # generates and returns arrays of unmodified ball objects according to the passed in length or the number passed in to generate_balls
require './rubyscripts/logic/shared/ball_helper'
require_relative './ball_generator/ball'
class BallGenerator
include BallHelper
attr_reader :length
def initialize(length=$DE... | true |
fd22d1e82c50d95c4120da1d997878d847c5712c | Ruby | itggot-jacob-lundberg/standard-biblioteket | /lib/index_of_char.rb | UTF-8 | 552 | 4.15625 | 4 | [] | no_license | # Public: Receive the index of a character in a string if it exists.
#
# string - The String to be searched through.
# character - The String of one character which will be compared to the characters in the string.
#
# Examples
#
# index_of_char("Hej", "e")
# # => 1
#
# Returns the duplicated String.
def index_of_c... | true |
ff3d5ac454e90bb37369fcc70e68039859862707 | Ruby | dombarnes/firelog | /lib/nest.rb | UTF-8 | 1,462 | 2.53125 | 3 | [] | no_license | require 'rubygems'
require 'bundler'
Bundler.require
require './app'
Bundler.require
class NestData
attr_accessor :date, :indoor_temperature, :outdoor_temperature, :status
@@log = Logger.new(STDOUT)
def initialize(params = {})
self.date = params.fetch(:date, DateTime.now)
self.indoor_temperature = par... | true |
f6952f378f8babdf743a99e880a1cd580f7fbc4b | Ruby | ivopashov/algorithms-data-structures | /linked_lists/detect_loop_in_linked_list.rb | UTF-8 | 1,385 | 4.03125 | 4 | [] | no_license | class Node
attr_accessor :data, :next
def initialize(data)
@data = data
end
end
# 1 -> 2 -> 3 -> 4 -> 5
# | |
# |_________|
def loop_present?(head)
return false if head.nil? || head.next.nil?
# what we use here is called runner technique
slower = faster = head
loop do
... | true |
dc87b476f40ab499d5e53406facdb0da21c0700e | Ruby | AntonSynytsia/SketchUp-Ruby-API-Doc | /lib/attributedictionary.rb | UTF-8 | 5,445 | 3.359375 | 3 | [] | no_license | module Sketchup
# The {AttributeDictionary} class allows you to attach arbitrary collections
# of attributes to a SketchUp entity. The attributes are defined by key/value
# pairs where the keys are strings. An {Entity} or {Model} object can have any
# number of {AttributeDictionary} objects.
#
# The {Entit... | true |
ac0fd53bcca7dc71d1ec24486a879dc37f3bf604 | Ruby | LoCodes/ruby-objects-has-many-through-readme-onl01-seng-pt-032320 | /lib/waiter.rb | UTF-8 | 1,007 | 3.546875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Waiter
# #new
# initializes with a name and years of experience
# .all
# is class method that returns the contents of @@all
class Waiter
attr_accessor :name, :yrs_experience
@@all = []
def initialize(name, yrs_experience)
@name = name
@yrs_experience= yrs_experience
@@all << self
... | true |
357ccef3181f7b5567b1c1e0cefc6c805dc18ed9 | Ruby | adedayoominiyi/aws-doc-sdk-examples | /ruby/example_code/dynamodb/GettingStarted/MoviesItemOps01.rb | UTF-8 | 1,734 | 2.984375 | 3 | [
"CC-BY-NC-SA-4.0",
"Apache-2.0"
] | permissive | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
# This code example demonstrates how to add an item to an
# existing table in Amazon DynamoDB named 'Movies'. The
# item includes required values for the composite primary key
# (also known as a hash-range key) c... | true |
eac3eaa8827bec9ba8591f577c1c8545b5da52c1 | Ruby | sundqvistjohan/ITP_Ruby | /hashes.rb | UTF-8 | 1,157 | 4.375 | 4 | [] | no_license | # hash1.merge(hash2) creates a NEW merged hash with contents from hash1 and hash2.
# hash1.merge!(hash2) adds and/or overwrites hash1 with the content from hash2
family = { uncles: ["johan", "erik", "gustaf"],
sisters: ["annelie", "pernilla", "mikaela"],
brothers: ["christer", "mikael", "thom... | true |
ce344286bb04811165e9334c96667f3be724ec7a | Ruby | kvognar/app_academy_exercises | /week2/day2/chess/lib/board.rb | UTF-8 | 3,487 | 3.78125 | 4 | [] | no_license | # encoding: utf-8
require_relative 'pieces'
class Board
attr_accessor :board, :current_turn
def initialize(blank = false, current_turn = "white")
@board = Array.new(8) { Array.new(8) }
@current_turn = current_turn
board_setup unless blank
end
def board_setup
place_royalty("white")
pla... | true |
1878c0ddad403b9f2b4cc956d9488f4aeb52712b | Ruby | raphaelakpan/image_fetcher | /lib/process_file.rb | UTF-8 | 987 | 3.234375 | 3 | [] | no_license | require_relative "./download_image.rb"
require_relative "./logger.rb"
class ProcessFile
attr_reader :errors, :downloaded
def initialize(file_path)
@file_path = file_path
@errors = 0
@downloaded = 0
end
def perform
log_file
File.foreach(@file_path) do |url|
download_file(url)
end... | true |
5031a9471655d76e040f5eedc8912348a3c8f06b | Ruby | RyanZolper/AssignmentsIronYard | /assignment21.rb | UTF-8 | 470 | 3.65625 | 4 | [] | no_license | load 'person.rb'
nameinput = "nothing"
loop do
puts "Hey man, what's your name?"
nameinput = gets.chomp
break if nameinput == '\q'
p = Person.new
p.name(nameinput)
puts "Hello #{p.first_name}"
puts "What is your birthday? (YYYY-MM-DD)"
bdinput = gets.chomp
p.bd(bdinput)
puts "First name: #{p.fir... | true |
924e4c41d6829af75c960e29dc22cb1e939c3c84 | Ruby | acamino/hippocrates | /app/presenters/activity_presenter.rb | UTF-8 | 681 | 2.53125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
class ActivityPresenter < SimpleDelegator
MODELS = {
'Anamnesis' => 'ANAMNESIS',
'Consultation' => 'CONSULTA',
'Patient' => 'PACIENTE'
}.freeze
ACTIONS = {
'viewed' => 'ABRIR',
'created' => 'CREAR',
'updated' => 'EDITAR',
'deleted' => 'ELIMINAR'... | true |
24752b48fbb6a4c7b3694b12cf1e4321809c4024 | Ruby | qatutor/winter_rails | /lesson28/28-5/shop.rb | UTF-8 | 971 | 3.703125 | 4 | [] | no_license | require_relative 'lib/movie'
require_relative 'lib/book'
require_relative 'lib/product_collection'
collection = ProductCollection.from_dir("#{__dir__}/data/")
items_bought = []
choice = nil
total = 0
while choice != 0 do
puts "Что хотите купить: "
collection.to_a.each_with_index do |item, index|
puts "#{index... | true |
ff970a78f9f136c402ffbb55f5b8eda23796ec91 | Ruby | vjoel/redshift | /test/test_connect_parallel.rb | UTF-8 | 703 | 2.53125 | 3 | [
"Ruby"
] | permissive | require "redshift"
include RedShift
class A < Component
input :in
continuous :x => 1
link :comp
state :T
flow T do
diff " x' = in "
end
transition Enter => T do
reset :comp => nil
connect :in => proc {comp.port(:x)}
end
end
#-----#
require 'minitest/autorun'
class TestConnect < ... | true |
02aa49d25868ceb48987ebe3cdf0f770067249ea | Ruby | king4sam/soa2015_hw | /tsv_buddy.rb | UTF-8 | 1,310 | 3.46875 | 3 | [] | no_license | # Module that can be included (mixin) to create and parse TSV data
module TsvBuddy
# @data should be a data structure that stores information
# from TSV or Yaml files. For example, it could be an Array of Hashes.
attr_accessor :data
# take_tsv: converts a String with TSV data into @data
# parameter: tsv - a... | true |
39d662dad384ef12c25eaa7b0231a5cd7e492450 | Ruby | oriolbcn/piet | /lib/piet/runners/runner.rb | UTF-8 | 636 | 2.9375 | 3 | [] | no_license | # Abstract runner to encapsulate common functionality
# To implement a new runner, just create a subclass and implement the methods run and cmd_name
module Piet
class Runner
attr_accessor :path, :global_opts, :tool_opts
def initialize(path, global_opts, tool_opts)
@path = path
@global_opts = glo... | true |
d523ae286863d86463bda710e56d939392dc40d9 | Ruby | ronhearn86/AppAcademy | /rspec_exercise_1/lib/part_2.rb | UTF-8 | 772 | 3.6875 | 4 | [] | no_license | def hipsterfy(word)
vowel = "aeiou"
rev = word.reverse
rev.each_char.with_index do |char, i|
if vowel.include?(char)
rev[i] = ""
return rev.reverse
end
end
return word
end
hipsterfy("tonic")
def vowel_counts(str)
str = str.downcase
arr = str.split("")
hash = Hash.new(0)
vowel = "... | true |
4e36cd7842221ac1eb7dcc9caf5315cb34b021ec | Ruby | guiman/pivotaltracker_sprint_report | /lib/pivotal_extension/params_builder.rb | UTF-8 | 1,030 | 2.640625 | 3 | [
"MIT"
] | permissive | module Pivotal
class ParamsBuilder
AVAILABLE_OPTIONS=[:limit, :offset, :fields, :conditions, :filters]
def initialize(params = {})
@params = params
end
def to_s
unless @params.instance_of? Hash
raise "Can't create params from: #{@params.class.to_s}"
end
AVAILABLE_OP... | true |
49bd6aee2efcb0d9bb45e17403a40cbed96922a0 | Ruby | milo2012/beef | /extensions/console/lib/command_dispatcher/command.rb | UTF-8 | 4,640 | 2.59375 | 3 | [
"Apache-2.0"
] | permissive | #
# Copyright 2012 Wade Alcorn wade@bindshell.net
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applica... | true |
620831d11babf52390f00c5718572053c04a8f46 | Ruby | domo2192/backend_mod_1_prework | /day_4/exercises/learnruby1.rb | UTF-8 | 1,258 | 4.40625 | 4 | [] | no_license | def print_two(*args) # tell ruby we want to make a function using def and give
#give function our name. Than we tell it we want *args ^^
arg1, arg2 = args # indent and these two lines unpack our argument
puts "arg1: #{arg1}, arg2: #{arg2}"
end
def print_two_again (arg1, arg2)
puts "arg1: #{arg1}, arg2: #{arg2... | true |
e4f048103a2cba5cef0cdef62b424fadae9c1e4a | Ruby | carlosparamio/rack-facebook | /lib/rack/facebook.rb | UTF-8 | 4,350 | 2.765625 | 3 | [] | no_license | require 'digest'
require 'rack/request'
module Rack
# This Rack middleware checks the signature of Facebook params and
# converts them to Ruby objects when appropiate. Also, it converts
# the request method from the Facebook POST to the original HTTP
# method used by the client.
#
# If the signature is wro... | true |
41d4845e7ff32a3d8195e5425a8f5e6513287eec | Ruby | mailup/mailup-ruby | /lib/mailup/console/user.rb | UTF-8 | 2,614 | 2.53125 | 3 | [
"MIT"
] | permissive | module MailUp
module Console
class User
attr_accessor :api
def initialize(api)
@api = api
end
# Retrieve the admin console lists for the current user.
#
# @param [Hash] params Optional params or filters:
# @option params [Integer] :pageNumber The page number ... | true |
fd86d53f9f6511a9666b10fd09374b6722d30d92 | Ruby | membrq/bloc-sep-assignments | /02-algorithms/02-searching-algorithms/fibonacci_recursive.rb | UTF-8 | 215 | 3.21875 | 3 | [] | no_license | require 'benchmark'
def fib(n)
if (n == 0)
return 0
elsif (n == 1)
return 1
else
return fib(n-1) + fib(n-2)
end
end
puts Benchmark.measure{fib(20)}
#0.000000 0.000000 0.000000 ( 0.001420)
| true |
263d36cb8e0a995aeb91b19cad09c6473e214a8f | Ruby | onlinecursos/coursera-2016 | /prog-Ruby19-20/chapter02/036a-objects.rb | UTF-8 | 1,340 | 3.984375 | 4 | [] | no_license | # We can take this even further an allow people to assign to our virtual
# attribute, mapping the value to the instance varibla internally.
class BookInStock
attr_reader :isbn
attr_accessor :price
def initialize(isbn, price)
@isbn = isbn
@price = Float(price)
end
def price_in_cents
Int... | true |
095488cb299174a950d82a7d62e845ab03270d65 | Ruby | dwyn/ttt-with-ai-project-v-000 | /lib/game.rb | UTF-8 | 1,436 | 3.875 | 4 | [] | no_license | class Game
attr_accessor :board, :player_1, :player_2
def initialize(player_1=Players::Human.new("X"), player_2=Players::Human.new("O"), board=Board.new)
@board = board
@player_1 = player_1
@player_2 = player_2
end
WIN_COMBINATIONS = [
[0, 1, 2], # Top row
[3, 4, 5], # Middle row
[6, 7, 8], # Bottom ro... | true |
6277d754f841865d21eed7c47e867a17c2df7f70 | Ruby | xzlstc415/japanesekoreanug | /spec/models/episode_spec.rb | UTF-8 | 4,099 | 2.515625 | 3 | [
"MIT"
] | permissive | require 'rails_helper'
describe Episode do
let(:episode) { build(:episode) }
let(:episode_for_publish) { build(:episode_for_publish) }
def stub_youtube_video(episode, youtube_video = nil)
youtube_video = build(:youtube_video) unless youtube_video
expect(episode).to receive(:youtube_video)
... | true |
0ce35ec9d6e6609180ae8fe6f129a0aec5cf284e | Ruby | lsgpimentel/passeme | /app/services/events_service/genetic_algorithm/genetic_search.rb | UTF-8 | 9,676 | 3.28125 | 3 | [] | no_license | require 'descriptive_statistics/safe'
module EventsService
# The GeneticAlgorithm module implements the GeneticSearch and Chromosome
# classes. The GeneticSearch is a generic class, and can be used to solved
# any kind of problems. The GeneticSearch class performs a stochastic search
# of the solution of a ... | true |
61fc07d08e9c22c53d18a8b074c3e74feaeb01b4 | Ruby | coltonstaab1/collections_practice-v-000 | /collections_practice.rb | UTF-8 | 701 | 3.6875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def sort_array_asc(list)
list.sort
end
def sort_array_desc(list)
list.sort.reverse!
end
def sort_array_char_count(list)
list.sort_by! { |value| value.length }
end
def swap_elements(list)
list[1], list[2] = list[2], list[1]
list
end
def reverse_array(array)
array.reverse
end
def kesha_maker(array)
array.coll... | true |
8fdcc6eb5340c9c8a79afaaa3f08d4da1d16f3b9 | Ruby | ashjojo/Luhn | /lib/luhn.rb | UTF-8 | 338 | 3.578125 | 4 | [] | no_license | module Luhn
def self.is_valid?(number)
array = number.to_s.split("").map{|chr| chr.to_i}.reverse
## puts array.inspect
array.each_with_index do | num, i |
if i.odd?
array[i]= num * 2
array[i] = array[i] - 9 if array[i] >= 10
end
end
num = array.inject(:+)
return num % 10 == 0 ? true... | true |
367842ce1acf16cd6fddf9587bc09a3917fce16b | Ruby | tomferreira/hierarchical_clustering | /lib/clustering/fihc/freqitem_tree.rb | UTF-8 | 1,725 | 2.671875 | 3 | [] | no_license |
require 'binary_tree'
module Clustering::Fihc
class FreqItemTree < BinaryTree
def insert(word, value)
if @root.nil?
@root = BinaryTreeNode.new(word, value)
return
end
# used as the superRoot of the real root
super_root = B... | true |
d554d44c39f0932b0159d5664cf09b6a617d37e1 | Ruby | Lorenzo892/Ironhack-bootcamp | /Week1/Day4-Ironhack/cars.rb | UTF-8 | 684 | 3.875 | 4 | [] | no_license |
class Vehicle
attr_reader :wheels, :noise
def initialize (wheels, noise)
@wheels = wheels
@noise = noise
end
def make_noise
@noise
end
end
class VehicleHandeler
def initialize (array)
@array = array
end
def count_wheels
total_weels =@array.reduce(0) do |sum, vehicle|
sum +... | true |
bb9d5f06d36b4b186c2986111a9374d385b1388a | Ruby | pb-pravin/comm_offers | /app/observers/geocode_observer.rb | UTF-8 | 459 | 2.765625 | 3 | [] | no_license | # This can be enabled/disabled with:
# GeocodeObserver.instance.enable!
# or
# GeocodeObserver.instance.disable!
class GeocodeObserver < ActiveRecord::Observer
observe :address
def initialize
$geocode_enabled = true if $geocode_enabled.nil?
super
end
def disable!
$geocode_enabled = fals... | true |
72efd18f77ccf65fe353220f9c12c0c9e7ad0d3a | Ruby | adnankhantech/Dictionary-Mapper | /dictionaty_mapper.rb | UTF-8 | 2,201 | 3.78125 | 4 | [] | no_license | require 'benchmark'
class DictionaryMapper
ELEMENT_PATTERN = [
[3,3,4],
[3,4,3],
[4,3,3],
[5,5],
[4,6],
[6,4],
[7,3],
[3,7],
[10]
]
COMBINATION_LETTERS =
{
"2" => ["A", "B", "C"],
"3" => ["D", "E", "F"],
"4" => ["G", "H", "I"],
"5" => ["J", "K", "L"],
"6" => ["... | true |
fe14c274f9d1f05f5c43fde7fe84c2125d4e10d1 | Ruby | kanzash/ruby | /ex31.rb | UTF-8 | 902 | 3.796875 | 4 | [] | no_license | #LESSON 31: MAKING DECISIONS
puts "You enter room with 2 doors, go through 1 or 2?"
print "> "
door = $stdin.gets.chomp
if door == "1"
puts "There's bear eating cheese cake, what to do?"
puts "1. Take the cake"
puts "2. Scream at bear"
print "> "
bear = $stdin.gets.chomp
if bear == "1"
"You d... | true |
d9c9900c5c202ce34b79afb8e3e85d149ebbe27d | Ruby | wenbo/rubyg | /sample/CHAPTER05/057/str-length.19.rb | EUC-JP | 724 | 3.5625 | 4 | [] | no_license | # -*- coding: euc-jp -*-
# ܸޤޤʤʸʸХȿǤ롣
"abcdef".length # => 6
# ܸʸǤ⤭ʸ֤Ƥ롣
ja = "ܸ"
ja.encoding # => #<Encoding:EUC-JP>
ja.length # => 3
ja.size # => 3
# ΥǥѤǤ뤬Ū٤ʤ롣
ja.split(//).length # => 3
ja.scan(/./).length # => 3
ja.chars.count ... | true |
ad06322525329ebd9445cdf97bf2ccf94a19b855 | Ruby | phfts/vindi | /lib/vindi/charge.rb | UTF-8 | 573 | 2.53125 | 3 | [
"MIT"
] | permissive | module Vindi
# A charge is sent to a customer so he can pay and maintain its subscription
# A charge can have multiple transactions
class Charge < Base
include Vindi::API::Create
include Vindi::API::List
include Vindi::API::Delete
include Vindi::API::Update
include Vindi::API::Get
def sel... | true |
24e95e724f7bd25ea9500e79b9ba3b1ee485b23a | Ruby | djberg96/berger_spec | /test/core/Range/instance/test_hash.rb | UTF-8 | 1,196 | 3.125 | 3 | [
"LicenseRef-scancode-warranty-disclaimer",
"Artistic-2.0"
] | permissive | ######################################################################
# tc_hash.rb
#
# Test case for the Range#hash instance method.
######################################################################
require 'test/helper'
require 'test/unit'
class TC_Range_Hash_InstanceMethod < Test::Unit::TestCase
def setup
... | true |
ae76c32f19b7c1d130addbbfddd18932092a34de | Ruby | mazzastar/borisBikes | /spec/van_spec.rb | UTF-8 | 1,097 | 2.8125 | 3 | [] | no_license | require_relative '../lib/van'
describe Van do
let(:van) {Van.new(:capacity => 10)}
let(:broken_bike) { double(:bike, broken?: true) }
let (:working_bike) { double(:bike, broken?: false) }
def fill_van(van)
10.times {van.dock(Bike.new)}
end
it 'has no bikes' do
expect(van.bike_count).to eq 0
end
it "sho... | true |
c650eb468ef80fd695bf40eafab09765185df0c1 | Ruby | griselda-c/login-exercise | /tests/user_test.rb | UTF-8 | 1,338 | 3.03125 | 3 | [] | no_license | require 'test/unit'
require_relative '../models/user.rb'
class UserTest < Test::Unit::TestCase
def test_initialize_should_create_user_with_username_and_password
# arrange
username = "Nicolas"
password = "PassWorD"
# act
result = User.new(username, password)
... | true |
b4ba7fec45a3b183e1b6ede5c6b7b47ac3a5fb40 | Ruby | LrdVnz/connect_four | /spec/board_spec.rb | UTF-8 | 637 | 2.84375 | 3 | [] | no_license | # frozen_string_literal: true
require './lib/board'
describe Board do
describe '#initialize' do
subject(:board_new) { described_class.new }
it 'should create board as array' do
expect(board_new.board).to be_instance_of(Array)
end
end
describe '#create board' do
subject(:board_create) { d... | true |
b15bf2e20ead207212704d6d8cc0c7e2f7a6bb2c | Ruby | learn-co-students/dc-web-career-010719 | /04-one-to-many/run.rb | UTF-8 | 574 | 3 | 3 | [] | no_license | require_relative "tweet.rb"
require_relative "user.rb"
require 'pry'
coffee_dad = User.new("Coffee Dad")
tweet1 = coffee_dad.post_tweet("I love coffee")
tweet2 = coffee_dad.post_tweet("I need coffee")
puts coffee_dad.is_a? User
puts coffee_dad.username == "Coffee Dad"
puts tweet1.is_a? Tweet
puts tweet1.message == "I... | true |
1a2d8724df3f80df97f4b72e1bea504535424aef | Ruby | AventusM/RoRateBeer | /spec/models/user_spec.rb | UTF-8 | 6,090 | 2.59375 | 3 | [] | no_license | require 'rails_helper'
# APUMETODEJA
def create_beer_with_rating(object, score)
beer = FactoryBot.create(:beer)
FactoryBot.create(:rating, beer: beer, score: score, user: object[:user] )
beer
end
def create_beers_with_many_ratings(object, *scores)
scores.each do |score|
create_beer_with_rating(object, sco... | true |
9629ce28490007197baaa3dabe626adb0fa60a62 | Ruby | Toni-Ty/oo-counting-sentences-v-000 | /lib/count_sentences.rb | UTF-8 | 1,206 | 3.671875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class String
def sentence?
if self.end_with?(".")
true
else
false
end
end
def question?
self.end_with?("?") #Don't need to write true/false because the method appears to return it implicitly
# true
# else
# false
end
# end
def exclamation?
if self.... | true |
f9432a98f43e2a83799ef4094569aad016f9f070 | Ruby | pmarreck/ruby-snippets | /ruby fun.rb | UTF-8 | 154 | 3 | 3 | [] | no_license | # fun ruby stdobj hacks
class Array
def ~
self.sort_by{rand}
end
end
class String
def to_a
self.split(//)
end
end
p ~('peter'.to_a)
| true |
d3f6295f836445f0a52de114430bf0162eec760a | Ruby | mjrkmail/payroll-in-ruby | /change_salaried.rb | UTF-8 | 389 | 2.703125 | 3 | [] | no_license | require_relative "change_classification"
require_relative "salaried_classification"
require_relative "monthly_schedule"
class ChangeSalaried < ChangeClassification
def initialize(empId, salary, database)
super(empId, database)
@salary = salary
end
def make_classification
SalariedClassification.new(@... | true |
26796fbbbb2be7a079e16734975a32a0b94143a8 | Ruby | sharipov-ru/google_images | /lib/google_images/network_requester.rb | UTF-8 | 691 | 2.6875 | 3 | [
"MIT"
] | permissive | require 'http'
require 'google_images/errors/network_error'
module GoogleImages
# This class acts as a facade between http client library `http.rb` and
# our source code for abstracting library's entities and exceptions and using
# only needed part of the http client library API
module NetworkRequester
# P... | true |
acdc71a0e9521e716c93ec5c462a0fa10a1cdc3b | Ruby | ivankukobko/ukrainian | /test/ukrainian_test.rb | UTF-8 | 409 | 2.6875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require 'test_helper'
class UkrainianTest < Test::Unit::TestCase
should "have pluralize method" do
assert Ukrainian.respond_to?(:pluralize)
end
should "pluralize correctrly" do
variants = %w(озеро озера озер)
[['озеро', 1], ['озера', 2], ['озер', 5], ['озеро', 631]].each do |w, n|
assert_equal... | true |
5833bdb5fbcf38ffbb6c115a56666211eb10fc2c | Ruby | rderoldan1/share_files | /Uno/servidor.rb | UTF-8 | 2,221 | 3.34375 | 3 | [] | no_license | require 'socket'
load "compartidos.rb"
load "clientes.rb"
class Server
@server
@compartidos
def initialize(puerto)
@server = TCPServer.new(puerto)
@compartidos = Compartidos.new
puts "Servidor listo, esperando conexiones"
end
def sendM(dir, menssage)
dir.puts(menssage)
end
def getM(dir)
dir.ge... | true |
7824c768e890e691f5cc464fa53395f11255d7ee | Ruby | ericschoettle/firstDayProjects | /queen_attack/lib/queen_attack.rb | UTF-8 | 330 | 2.96875 | 3 | [] | no_license | class Array
define_method(:queen_attack?) do
if self[0][0] == self[1][0]
true
elsif self[0][1] == self[1][1]
true
elsif self[0][1] .-(self[1][1]) == self[0][0] .-(self[1][0])
true
elsif self[0][1] .-(self[1][1]) == -(self[0][0] .-(self[1][0]))
true
else
false
end
... | true |
82d351affae9f375d2d42d5cbf9337971551b357 | Ruby | Tkam13/atcoder-problems | /abc168/a.rb | UTF-8 | 123 | 3.375 | 3 | [] | no_license | n = gets.to_i
a = n % 10
if a == 3
puts "bon"
elsif a == 0 || a == 1 || a == 6 || a == 8
puts "pon"
else
puts "hon"
end | true |
0d0647376dd9b34ea7fa3eb6502bb997ff6414fc | Ruby | jibarra/advent-of-code | /2022/day4/solution.rb | UTF-8 | 1,333 | 3.234375 | 3 | [
"MIT"
] | permissive | lines = File.readlines('./input.txt')
lines.map(&:strip)
# Part 1
def ranges_have_coverage?(first_range, second_range)
# Could be replaced by first_range.cover?(second_range) in Ruby 3
if first_range.first <= second_range.first && first_range.last >= second_range.last
true
elsif second_range.first <= first... | true |
447aad82f53e7e78ea3c3f4aff653f437464aaac | Ruby | Alexis-Trainee/ruby | /computer.rb | UTF-8 | 247 | 3.265625 | 3 | [
"MIT"
] | permissive | class Computer
def turn_on
'turn on the computer'
end
def shutdown
'shutdown the computer'
end
end
#criando um objeto para interagir com a class
computer = Computer.new
# puts computer
puts computer.turn_on
puts computer.shutdown
| true |
85c993ffff252460dd8d975393fed920e2709b16 | Ruby | AvrohomLuban/owntests | /manager.rb | UTF-8 | 321 | 2.59375 | 3 | [] | no_license | class Manager < Employee
include Email
attr_accessor :yearsonjob
def initialize (input_hash)
super
@yearsonjob = input_hash[:yearsonjob]
end
def give_a_raise
@salary = @salary + 2500
end
def send_email
puts "sending email..."
#TODO: code for email
puts "email sent!"
end
en... | true |
661364abcf85615df381a5c74fb9600d0a36548b | Ruby | Kertl14/Introduction-to-Programming-with-Ruby | /the_basics/3.rb | UTF-8 | 155 | 2.9375 | 3 | [] | no_license | movies = {
:indiana_jones => 1981,
:batman => 1989,
:star_wars => 1977,
}
puts movies[:indiana_jones]
puts movies[:batman]
puts movies[:star_wars]
| true |
ca25bd57ee7886a5fea56c97224912eba9bbaa5c | Ruby | josh-works/intermediate_ruby_obstacle_course | /refactoring/test/file_test.rb | UTF-8 | 467 | 2.859375 | 3 | [] | no_license | require 'minitest/autorun'
class FooTest < MiniTest::Test
def test_read_4th_character
contents = File.read('refactoring/test/data.txt')
assert_equal 'd', contents[3,1]
end
def test_read_4th_content_is_2
contents = File.read('refactoring/test/data.txt')
assert_equal 'dm', contents[3,2]
end
... | true |
9d4e4ecf1bb5b63c3e332346f3c95139941963c1 | Ruby | jrhamilton/TicTacToe_ruby | /lib/tic_tac_toe.rb | UTF-8 | 429 | 3.46875 | 3 | [] | no_license | class TicTacToe
def initialize
@players = []
@players << Player.new('X')
@players << Player.new('O')
@board = Board.new()
@player_index = 0
@current_player = @players[@player_index]
end
def board
@board
end
def players
@players
end
def current_player
@current_player... | true |
4b8d2ae0bca3be867df11486b59b40ab1e5a6072 | Ruby | jemise111/chris_pine_learn_to_program | /chapter_13/interactive_baby_dragon.rb | UTF-8 | 2,452 | 4.59375 | 5 | [] | no_license | # Creates interactive game based on baby_dragon class from Text
class Dragon
def initialize name
@name = name
@asleep = false
@stuff_in_belly = 10
@stuff_in_intestine = 0
puts "#{@name} is born."
end
def feed
puts "You feed #{@name}."
@stuff_in_belly = 10
passage_of_time
end
def walk
puts ... | true |
3865015c4caefa629bd1db7932be5c141dcea932 | Ruby | matthewrudy/rudebay | /lib/rudebay/describer.rb | UTF-8 | 734 | 3.234375 | 3 | [
"MIT"
] | permissive | module Rudebay
class Describer
TEMPLATES = [
":time_left out and it's at :current_price", # "1 hour out and it's at £102"
":current_price, and only :time_left to go!", # "141 quid, and only 30 seconds to go"
"that :item_title is at :current_price", # that Peppa Pig pyjamas is at £12.23
... | true |
0bd254e5a2138de50068617a4aac77d0f2606a6f | Ruby | wojkos/rspec_course | /spec/spies_spec.rb.rb | UTF-8 | 591 | 2.53125 | 3 | [] | no_license | RSpec.describe 'spies' do
let(:animal) { spy('animal') }
it 'confirms that a message has been received' do
animal.eat_food
expect(animal).to have_received(:eat_food)
expect(animal).not_to have_received(:eat_human)
end
it 'reset between examples' do
expect(animal).not_to have_received(:eat_food)... | true |
477929d5bf3fb190346d3173effc65aec2cde221 | Ruby | Lorenzo892/Ironhack | /FizzBuzz3.rb | UTF-8 | 214 | 3.984375 | 4 | [] | no_license |
num = []
for i in 1...100
num.push i
end
num.each do |item|
if item % 5==0 && item % 3==0
puts "FizzBuzz"
elsif item % 3 == 0
puts "Fizz"
elsif item % 5 ==0
puts "Buzz"
else
puts item
end
end | true |
9374ddb53f8597d66f04b30bc76aa333fb59c117 | Ruby | HISMalawi/BHT-EMR-API | /spec/services/art_service/regimen_engine_spec.rb | UTF-8 | 7,280 | 2.5625 | 3 | [] | no_license | # frozen_string_literal: true
require 'rails_helper'
RSpec.describe ARTService::RegimenEngine do
let(:regimen_service) { ARTService::RegimenEngine.new program: program('HIV Program') }
let(:patient) { create :patient }
let(:vitals_encounter) { create :encounter_vitals, patient: patient }
let(:dtg_ids) { Drug.... | true |
6fcc0256db7dd8fee59aff5c51b4c6ebd419922a | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/anagram/5fcec1a53afa4cffb9c21d133fb942d5.rb | UTF-8 | 473 | 3.359375 | 3 | [] | no_license | class Anagram
def initialize source
@raw_source = source.downcase
@source = standard_form @raw_source
end
def match targets
targets.select do |target|
raw_target = target.downcase
are_anagrams = @source == standard_form(raw_target)
are_same = (@raw_source == raw_target)
are_an... | true |
180666f3f8692e2cc6060e3da1f57d8e05f49d9f | Ruby | ycbencheng/reimplment_map_reduce | /new_reduce.rb | UTF-8 | 994 | 3.296875 | 3 | [] | no_license | def new_reduce(accumulator = nil, operation = nil, &block)
if accumulator.nil? && operation.nil? && block.nil?
raise ArgumentError, 'you must provide an operation or a block'
end
if operation && block
raise ArgumentError, 'you must provide either an operation symbol or a block, not both'
end
if oper... | true |
ef9bb6da838aafaf27b5a65aa735e0d996a1164b | Ruby | wenbo/rubyg | /sample/CHAPTER05/097/enum2.rb | UTF-8 | 85 | 2.578125 | 3 | [] | no_license | op = :left
case op
when :left then puts "OK"
when :right then puts "NG"
end
# >> OK
| true |
a7286b93dc8cc18148a89d394a5acbce4770d03f | Ruby | scarlettajulia/generasi-GIGIH | /Module-3/Session-2/exercise/web.rb | UTF-8 | 1,326 | 2.640625 | 3 | [] | no_license | require 'sinatra'
require_relative './model/category.rb'
require_relative './model/item.rb'
get '/' do
items = Item.get_all_items_with_category
erb :index, locals:{
items: items
}
end
get '/item/create' do
categories = Category.get_all_categories
erb :create, locals:{
categories: c... | true |
40da89581805c3807216cde394a60c2a2b1ff32b | Ruby | David1Socha/the_odin_project | /tic_tac_toe/spec/tictactoe_spec.rb | UTF-8 | 6,497 | 3.375 | 3 | [] | no_license | require_relative '../lib/tictactoe'
describe "Grid" do
describe "#initialize" do
before(:all) do
@grid = TicTacToe::Grid.new(3)
end
it 'creates a grid with rows of specified size' do
expect(@grid.contents[0].size).to eq 3
end
it 'creates a grid with columns of specif... | true |
35411c0f425062b1880bec4789746ad80726e198 | Ruby | osifoanosike/basicruby | /2/bin/main.rb | UTF-8 | 160 | 2.828125 | 3 | [] | no_license | require_relative '../lib/string.rb'
puts "Please enter a text:"
entry = gets.chomp
puts "the text you entered:#{entry} was modified to #{entry.replace_regex}" | true |
324628557b23e5aec42ca59951e6daf63092facc | Ruby | complikatyed/cal | /cal.rb | UTF-8 | 700 | 3.71875 | 4 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require_relative 'lib/month'
require_relative 'lib/year'
require_relative 'lib/zellers'
def exit_with_error_message
puts "Date not in acceptable format/range\n"
exit
end
if ARGV.length == 1
year = ARGV[0]
exit_with_error_message if year == ''
exit_with_error_message if year.to_i < 1800... | true |
63d7adf6159b5eff64c1a6403d0fc7d100c0f6d4 | Ruby | ACooper5259/jungle | /app/models/user.rb | UTF-8 | 649 | 2.5625 | 3 | [] | no_license | class User < ActiveRecord::Base
has_secure_password
# Verify that email field is not blank and that it doesn't already exist in the db (prevents duplicates):
validates :email, presence: true, uniqueness: { case_sensitive: false }
validates :first_name, presence: true
validates :last_name, presence: true
v... | true |
972ec1620e3597fd79544224df937d97a68c0cd2 | Ruby | darkbaby123/kata-poker-hands | /spec/lib/poker_hands/comparer_spec.rb | UTF-8 | 3,543 | 2.6875 | 3 | [] | no_license | RSpec.describe PokerHands::Comparer do
subject { described_class.vs(left_hand, right_hand) }
let(:left_hand) { create_hand(left) }
let(:right_hand) { create_hand(right) }
describe 'straight flush - one wins' do
let(:left) { '3H 2H 6H 4H 5H' }
let(:right) { '9D QD TD JD KD' }
it { is_expected.to e... | true |
3ca904bfb9204756daec06ac84d1b7515281374f | Ruby | yoshifumi0521/TreeStructureOfCategory | /db/seeds/development/categories.rb | UTF-8 | 2,332 | 2.75 | 3 | [] | no_license | # coding: utf-8
#カテゴリーのシードデータを埋めるためのファイル
#上位階層のデータ
@TopOfcategories = Category.find_or_initialize_by_name("全ジャンル")
@TopOfcategories.parent_id = nil
@TopOfcategories.save
# ① 職種/役職というジャンルをつくる。
@topofposition = Category.find_or_initialize_by_name("職種/役職")
@topofposition.parent_id = @TopOfcategories.id
@topofpositi... | true |
66108d0c0b95b2372274d0ef05d9642c87054327 | Ruby | DanielLyleWilliamWarren/Weekend-homework-week-3 | /db/console.rb | UTF-8 | 1,049 | 2.734375 | 3 | [] | no_license | require('pry')
require_relative('../models/customer.rb')
require_relative('../models/film.rb')
require_relative('../models/ticket.rb')
Ticket.delete_all()
Film.delete_all()
Customer.delete_all()
customer1 = Customer.new({
'name' => 'Dan',
'wallet' => 1000
})
customer1.save()
customer2 = Customer.new({
'name'... | true |
2fa96b263c0083b6f930d9c325c2cc7255ca522c | Ruby | pulliam/persephone | /unit_b/w07/d02/classwork/domain_modeling/assertions.rb | UTF-8 | 884 | 2.90625 | 3 | [] | no_license | require_relative 'db_config'
class Wizard < ActiveRecord::Base
has_and_belongs_to_many :spells
def cast!
@spell = self.spells.sample.name
"#{self.name} casts #{@spell}"
end
def learn!
@sample = Spell.all.sample
if self.spells.include? @sample
puts "nothing to learn today"
else
self.spells.push(@... | true |
f3105b0c370df81dca61ce5f719cf5d474e3839c | Ruby | ARahaman/Task | /Task80.rb | UTF-8 | 529 | 3.234375 | 3 | [] | no_license | def patterns n
i= n-1
1.upto(n-1) {print " *"}
print "\n"
until i < 1 do
space = ''
astrix = ''
i.upto(n-1) { space=space+' '; }
count=0
1.upto(i) do
count =count+1
if(count>1)
astrix=astrix+' '
else
astrix=astrix+'*'
end
end
2.upto(i) do |x|
if(x==i)
astrix=astri... | true |
11ab609862a3d0f68fe3e577f038e17da1c6fbcb | Ruby | MLee21/Fly-Me-Now | /app/services/iata_conversion_service.rb | UTF-8 | 717 | 2.796875 | 3 | [] | no_license | require 'uri'
class IataConversionService
attr_reader :connection
def initialize
@connection = Hurley::Client.new("https://airport.api.aero/")
end
def iata_converter(city)
uri_city = URI.encode(city)
response = connection.get("airport/match/#{uri_city}", {
user_key: "8fdd2f669ad0c36eee5dc... | true |
5e80dc25f3a222a68e763fe900725e2a704b85ce | Ruby | yvoloshin/Coding-challenges | /quiz3.rb | UTF-8 | 280 | 3.828125 | 4 | [] | no_license | class Dog
attr_accessor :name, :breed
def initialize(name, breed)
@name=name
@breed=breed
end
end
new_dog=Dog.new("Fido", "terrier")
puts new_dog.name
puts new_dog.breed
new_dog.name="Buddy"
new_dog.breed="yorkie"
puts new_dog.name
puts new_dog.breed
| true |
7585d24a6e7225b9b09f4ef20fc01b780e922c0f | Ruby | ctrl-alt-lulz/pricemagic | /app/models/concerns/price_test_graph_methods.rb | UTF-8 | 2,450 | 2.75 | 3 | [] | no_license | module PriceTestGraphMethods
## coding practice to refactor below
## move graphing related code to seperate module
def plot_data
price_data.values.map.with_index do |hash, index|
{
y: hash['revenue'],
x: hash['price_points'],
z: variants[index].variant_title,
unit_cost: v... | true |
528bebb67b9e166bd4611815ff2dc1539fbfe062 | Ruby | AlvinDevelopments/trees-graphs | /binarytree.rb | UTF-8 | 1,427 | 3.609375 | 4 | [] | no_license | require 'colorize'
class BinaryTree
Node = Struct.new(:left, :right, :data)
def initialize(data)
@levels = Array.new(data.size){Array.new}
@level_count = 0
@current_node = nil
data.each_with_index do |item, i|
new_node = Node.new(nil, nil, item)
if(i==0)
@root_node = new_node
... | true |
6c28111608c7c5683e221f63f7fb71e4039ec081 | Ruby | jinghewang/RubyBase | /02/2.1.rb | UTF-8 | 848 | 3.421875 | 3 | [] | no_license | # encoding:utf-8
names = ['小林', '林', '高里', '森冈',123]
# puts names[0],names.first,names.last
names.each{|item| print "item:#{item} ";}
puts '------------------------'
names[0] = '王景鹤'
names.push "李海婷"
puts names.size
puts '-------------------'
names.each do |item|
puts item
end
puts '-------------------'
evens = (... | true |
8e5939f391529761df0cefc870b9ea2ecd27cb84 | Ruby | cyb-ahmadh/from_refactoring | /spec/movie_spec.rb | UTF-8 | 1,480 | 2.90625 | 3 | [] | no_license | require 'byebug'
require 'movie'
describe Movie do
describe 'Charge' do
let(:movie) do
movie = Movie.new(movie_name)
movie.price = price_klass
movie
end
subject do
movie.charge(days_rented)
end
context 'For new release' do
let(:movie_name) { 'Avengers - Infinity Wa... | true |
3a9450f2e6f82951f663e88be27b9c2b0368d8aa | Ruby | galuropek/tools | /dev/tools/tool_cr.rb | UTF-8 | 2,193 | 2.734375 | 3 | [] | no_license | require_relative '../../modules/params'
require_relative '../../modules/file_manager'
require_relative '../entities/result'
require_relative '../entities/main_result'
require_relative '../entities/category_result'
require_relative '../utils/utils_cr'
require_relative '../../base_tool'
require 'pry'
class ToolCr < Bas... | true |
58ced98beaaf253a7c9473432244bf408efd04e8 | Ruby | assistunion/tanuki | /lib/tanuki/configurator.rb | UTF-8 | 1,753 | 2.640625 | 3 | [
"MIT"
] | permissive | module Tanuki
# Tanuki::Configurator is a scope for evaluating
# a Tanuki application configuration block.
class Configurator
# Configuration root.
attr_accessor :config_root
# Configurator context.
attr_reader :context
# Creates a new configurator in context +ctx+ and +root+ directory.
... | true |
018960a6c178f103a3f2cce99c091011827c08eb | Ruby | daram79/one_day | /app/models/feed.rb | UTF-8 | 1,230 | 2.515625 | 3 | [] | no_license | class Feed < ActiveRecord::Base
belongs_to :user
has_many :likes, :dependent => :destroy
has_many :comments, :dependent => :destroy
has_many :feed_photos, :dependent => :destroy
has_many :feed_tags, :dependent => :destroy
accepts_nested_attributes_for :feed_photos, reject_if: :feed_photos_attributes.blan... | true |
43a0627bca1ecec37d34c3b4d619953e4d415c80 | Ruby | amckinnell/nutrella | /lib/nutrella/cache.rb | UTF-8 | 1,026 | 2.84375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require "yaml"
module Nutrella
#
# Provides a cache of the most recently used items.
#
class Cache
attr_reader :capacity, :path
def initialize(path, capacity)
@path = path
@capacity = capacity
end
def fetch(key)
value = lookup(key) || yield
... | true |
0232b52b8ae7637d49a7de656b89b8aef9869fc6 | Ruby | gdichicago/gdi-update | /spec/models/newsletter_generator_spec.rb | UTF-8 | 1,257 | 2.671875 | 3 | [] | no_license | require "spec_helper"
describe NewsletterGenerator do
let(:options) { {fetch_meetups: true,
fetch_events: true,
fetch_jobs: true,
gif_url: "http://awesomegif.com",
intro: "Now revamping the newsletter!",
articles: [{url: "http://recode.... | true |
0bf5f5c172cc2c2a92e8e169a4fa3304963f03d3 | Ruby | Galiant/LearningRuby | /CA1/atm.rb | UTF-8 | 2,539 | 4.4375 | 4 | [] | no_license | =begin
Create a program that will simulate an ATM.
This must
Welcome the user and ask them what they want to do:
a. Give them two options Quit or Start
b. If they choose Quit output thank you goodbye
c. If they choose start present them with three additional options
i) Withdraw Funds
ii) Lodge... | true |
35e975231bcd07d9639df8b46fdad6ceede149bd | Ruby | kaspernj/array_enumerator | /lib/array_enumerator.rb | UTF-8 | 6,806 | 3.671875 | 4 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # This class is ment as an enumerator but with a cache that enables it to emulate array-functionality (first, empty and so on). If elements goes out of memory, then the array becomes corrupted and methods like 'first' and 'slice' will no longer work (raise errors).
class ArrayEnumerator
class ArrayCorruptedError < Ru... | true |
4972e7acc5af28d49015644360b9b11761d12392 | Ruby | mcelis13/module-1-code-challenge-round-2-dumbo-web-080618-complete-this-challenge-1535117394 | /app/models/movie.rb | UTF-8 | 1,156 | 3.421875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Movie
attr_accessor :title
@@all = []
def initialize(title)
@title = title
self.class.all << self
end
def self.all
@@all
end
def queue_items
QueueItem.all.select do |queue_obj|
queue_obj.movie == self
end
end
def viewers
queue_items.map do |queue_obj|
que... | true |
c9ffc9f39dbe91eed3bed72b6e6c48f33aca1280 | Ruby | Alu0100673647/prct05 | /tc_racional.rb | UTF-8 | 556 | 2.78125 | 3 | [] | no_license | # Implementar en este fichero las Pruebas Unitarias asociadas a la clase Fraccion
require "./racional.rb"
require "test/unit"
class Test_Fraccion < Test::Unit::TestCase
def test_suma
assert_equal([18,18], Fraccion.new().suma(4,6,1,3))
end
def test_resta
assert_equal([15,20], Fraccion.new()... | true |
07d07fda8226b26ab0b8865dfa342b41b0222e44 | Ruby | kaisershahid/eggtooth | /lib/eggtooth/action-manager/servlet-action.rb | UTF-8 | 1,921 | 2.578125 | 3 | [] | no_license | # A base module for scriptless actions that map to a path or handle resources by
# type, selector, extension, and method. There are some pre-filled methods along
# with hooks that an implementing class can override.
#
# {{svc_activate()}} initializes the following properties: {{@paths}} (`nil` if 0-length),
# {{@types... | true |
948bf5aec6867a0ed83a9fb2c0c8b7ed994b0e19 | Ruby | yusukebe/plainrouter | /example/sinatra_like.ru | UTF-8 | 992 | 2.734375 | 3 | [
"MIT"
] | permissive | $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
require 'plainrouter/method'
require 'rack'
class SinatraLikeFramework
def initialize
@router = PlainRouter::Method.new
self.routes
end
def routes
end
def get(path, &block)
@router.add('GET', path, block)
end
def call(env)
block, ... | true |
36392a70aab4ff49ac3758a012752ae78f3dd640 | Ruby | emosowski/phase-0 | /week-6/bingo_solution.rb | UTF-8 | 9,794 | 4.375 | 4 | [
"MIT"
] | permissive | # A Nested Array to Model a Bingo Board SOLO CHALLENGE
# I spent [9] hours on this challenge.
=begin
# Release 0: Pseudocode
# Outline:
# Create a method to generate a letter ( b, i, n, g, o) and a number (1-100)
#fill in the outline here
-create method call
letter = pick a random letter out of b, i, n, g, ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.