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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
584fafc99d537d867e36431c7211932cc29652f3 | Ruby | nazeemuddin/cs-training | /ruby/adder.rb | UTF-8 | 164 | 3.875 | 4 | [] | no_license | puts("Enter a number:")
op1 = gets()
puts("Enter another number:")
op2 = gets()
result = op1.chomp().to_i() + op2.chomp.to_i()
puts("The sum is " + result.to_s())
| true |
00f9dc960ec153c38cca2bec4a4f036ba988f5d5 | Ruby | wenpp/blog | /app/models/post.rb | UTF-8 | 293 | 2.53125 | 3 | [] | no_license | class Post < ActiveRecord::Base
validates :title, presence: true
validates :content, presence: true
validates_uniqueness_of :title
has_many :comments
before_save :slug
def slug
self.slug = self.title.downcase.gsub(" ","-")
end
def to_param
"#{slug}".parameterize
end
end
| true |
72b25ebf286e468420e69fe282eb210a896be75b | Ruby | RuffWorksTech/RB101-Programming-Foundations | /small_problems/easy_7/multiplicative_average.rb | UTF-8 | 1,221 | 5.28125 | 5 | [] | no_license | ### Write a method that takes an Array of integers as input, multiplies all the numbers together, divides the result by the number of entries in the Array, and then prints the result rounded to 3 decimal places. Assume the array is non-empty. ###
# Input:
# - Single array of integers
# Output:
# - Printout of the res... | true |
5288440dc26cc3a3dd6273c1ad0c25e0ff9261e5 | Ruby | qqdipps/Algorithms | /Algorithms/Ruby/traverse-spiral-matrix.rb | UTF-8 | 1,053 | 4.34375 | 4 | [] | no_license | # Traverse 2D Array in a spiral
# Set 4 variables to define the outer bounds of the matrix - left, right, top, bottom
# Set a direction: 0 -> left to right, 1 -> top to bottom, 2 -> right to left, 3 -> bottom to top
# At each iteration check which direction is set and iterate through those values in the matrix
# Then i... | true |
42bed209efcc946ecd4a76893498219471b18983 | Ruby | Faiza1987/grocery-store | /lib/order.rb | UTF-8 | 2,369 | 3.40625 | 3 | [] | no_license | require 'csv'
require 'awesome_print'
require_relative 'customer'
ORDER_FILEPATH = 'data/orders.csv'
# WAVE 2
class Order
attr_reader :id
attr_accessor :products, :customer, :fulfillment_status
# Constructor
def initialize(id, products, customer, fulfillment_status = :pending)
if (fulfillment_status !=... | true |
c9f8d09e6c288ff0c695cb9a07aa34c3a89d3472 | Ruby | ulbricht/medusa | /app/helpers/tree_view_helper.rb | UTF-8 | 1,034 | 2.546875 | 3 | [] | no_license | # -*- coding: utf-8 -*-
module TreeViewHelper
def tree(hash, key=nil, depth=1, in_list = [], &block)
blank = capture { "" }
return blank unless hash[key]
hash[key].inject(blank) do |str, obj|
tree_nodes = tree(hash, obj.id, depth + 1, in_list, &block)
html = str + tree_node(obj, depth, &block)... | true |
18c67a79b9f20850cc91aa0c4343401fc7b805cf | Ruby | bansalakhil/lex-rubykit | /lib/lex_rubykit/response/dialog_action.rb | UTF-8 | 1,393 | 2.734375 | 3 | [
"MIT"
] | permissive | module LexRubykit
# Handles the bot object in request.
class DialogAction
attr_accessor :type, :fulfillment_state, :message_content_type, :message_content
DIALOG_ACTION_TYPES = {
close: 'Close',
confirm_intent: 'ConfirmIntent',
delegate: 'Delegate',
elicit_intent: 'ElicitIntent',
... | true |
dcf46e893c2a1496bbad8e7206d373493d9fa61e | Ruby | flo-ruby/precourse | /3-Methods/multiply.rb | UTF-8 | 82 | 3.453125 | 3 | [] | no_license | def multiply(a, b)
a * b
end
a = 12
b = 6
puts "#{a} * #{b} = #{multiply(a,b)}" | true |
c6e1518662bedb5a0e83b500937347a36779ce59 | Ruby | TimRobinson1/learn-to-program | /chap-02-letters/escapes.rb | UTF-8 | 213 | 3.171875 | 3 | [] | no_license | # This is about escape characters, which allows the use of special characters
# That would otherwise ruin the code
puts 'You\'re swell!'
puts 'backslash at the end of a string: \\'
puts 'up\\down'
puts 'up\down'
| true |
805c7c79fa7bb8242dc386c69d947fb10a64904e | Ruby | pete/nacreon | /test/int/test_helper.rb | UTF-8 | 3,245 | 2.75 | 3 | [] | no_license | require 'test/unit'
require 'net/http'
require 'json'
TestAdmin = { :username => 'testadmin', :password => rand.to_s }
# Just a set of things to provide easy HTTP access to the server. Copypasta
# from Beekeeper, with some stuff cut out, and assertions added to spot where
# we have failed to comply with the spec.
mo... | true |
638a435e9c661c17f9739297a065969b9709e083 | Ruby | TheWildParamecium/Biomodules | /ComputationalAlgorithm/ComputationalAlgorithm.rb | UTF-8 | 3,537 | 3.953125 | 4 | [] | no_license | #Binary search function. Given a sorted array and a item, it returns the position where the item is in the array
#(if it exist), otherwise it returns nil(null). It runs at O(log n) speed.
def use_binary_search(list, item)
low = 0
high = list.length - 1
while low <= high
mid = (low + high)
... | true |
70aad8eee1a39e6c0cbd47365ca63abee825e70b | Ruby | Useurmind/rokuby | /lib/rokuby/Utility/path_utility.rb | UTF-8 | 2,001 | 2.984375 | 3 | [
"MIT"
] | permissive | module Rokuby
module PathUtility
# Joins several parts of a path to one path.
# Also applies formatting to the paths.
def JoinPaths(paths)
formattedPaths = []
for i in 0..paths.length-1
formattedPath = FormatPath(paths[i])
if(formattedPath != nil)
formattedPaths.p... | true |
8b8b3ad8581ac123d9fcf810e6d1dba7bfcc2c0b | Ruby | kmcphillips/cliftonstudios.ca | /spec/models/event_spec.rb | UTF-8 | 1,718 | 2.609375 | 3 | [] | no_license | require 'spec_helper'
describe Event do
let(:member){ FactoryGirl.create(:member) }
let(:valid_attributes){ {title: "title", member: member, body: "body", starts_at: Time.zone.now, duration: 1} }
describe "ends_at" do
it "should be set on save" do
event = Event.create!(valid_attributes)
expect(e... | true |
1cf08431b313b306ef54973e1065055cf0a1180f | Ruby | rn0rno/kyopro | /aoj/ruby/02_Volume0/0045.rb | UTF-8 | 185 | 3.453125 | 3 | [] | no_license | #!/usr/bin/env ruby
k, sum, ave = 0, 0, 0.0
while line = gets
val, num = line.chomp!.split(",").map(&:to_i)
sum += val * num
ave += num
k += 1
end
puts [sum, (ave/k).round]
| true |
4612f01d89562077e2c00ea8d383dbfe5b78f81d | Ruby | brolim/beats-in-ruby | /src/models/chord.rb | UTF-8 | 3,178 | 3.125 | 3 | [
"MIT"
] | permissive | require_relative 'sound'
require 'byebug'
class Chord < Sound
attr_accessor :note
attr_accessor :chord_type
attr_accessor :octave
attr_accessor :duration
attr_accessor :volume
attr_accessor :times
attr_accessor :release_size
NOTES_BY_CHORD_TYPE = {
major: [0, 4, 7],
minor: [0, 3, 7],
domin... | true |
a705049bf0b4e391d5786fea03be70f0027d8da6 | Ruby | VenueDriver/ruby-plugnpay | /lib/ruby_plugnpay.rb | UTF-8 | 3,018 | 2.78125 | 3 | [
"MIT"
] | permissive | require 'cgi'
require 'httparty'
module PlugNPay
# A Ruby class for remote client use of the PlugNPay HTTP API.
class Service
include HTTParty
format :html
attr_accessor :api_url, :publisher_name, :debug
# Performs a merchant authorization using the PlugNPay HTTP API.
#
# Example:
... | true |
d82930572b1303b15ce920846f6ab88b44719ba9 | Ruby | tojo009/iplt20_data_scraping | /scrap_scripts/collect_innings_data.rb | UTF-8 | 1,193 | 2.625 | 3 | [] | no_license | require 'nokogiri'
require 'watir'
require 'mysql'
connection = Mysql.new('localhost','root','password','ipl_dummy_db')
browser = Watir::Browser.new(:phantomjs)
year_array = (2012..2013)
matches = (76..76).to_a
year_array.each do |year|
matches.each do |match_number|
begin
browser.goto("h... | true |
5aa646787b060b0d7b7d12848439f67a02d54051 | Ruby | pbsmith82/reverse-each-word-onl01-seng-pt-090820 | /reverse_each_word.rb | UTF-8 | 121 | 3.1875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def reverse_each_word(string)
new_array = string.split
new_array.collect(&:reverse!)
new_array.join(" ")
end
| true |
3d9255e9ae226d45a5d3991cb306e6effa11a833 | Ruby | Tyche/teensymud | /cmd/teensy/cmd_get.rb | UTF-8 | 817 | 2.578125 | 3 | [
"LicenseRef-scancode-warranty-disclaimer"
] | no_license | #
# file:: cmd_get.rb
# author:: Jon A. Lambert, Chris Bailey
# version:: 3.0.0
# date:: 02/20/2013
#
# This source code copyright (C) 2005-2013 by Jon A. Lambert
# All rights reserved.
#
# Released under the terms of the TeensyMUD Public License
# See LICENSE file for additional information.
#
module Cmd
# g... | true |
e7f9f88b4c67abcf566707f2eaab096ae23b5359 | Ruby | dtbrad/serious-recipes | /lib/serious_recipes/cli.rb | UTF-8 | 3,387 | 3.671875 | 4 | [
"MIT"
] | permissive | require 'pry'
class SeriousRecipes::CLI
def call
Recipe.make_recipes
greeting
menu
end
def greeting
puts ""
puts ""
puts " WELCOME TO SERIOUS RECIPES."
puts ""
puts "This gem allows you to view and search by ingredient for the latest recipes from the Serious E... | true |
c0ff5eaf06120896cfdc990be6defaf43e136d75 | Ruby | tjnz/oo-email-parser-v-000 | /lib/email_parser.rb | UTF-8 | 478 | 3.390625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Build a class EmailParser that accepts a string of unformatted
# emails. The parse method on the class should separate them into
# unique email addresses. The delimiters to support are commas (',')
class EmailParser
attr_accessor :emails
def initialize(emails)
@emails = emails
end
def parse
self.emails.s... | true |
3da6a6cf10b300ac2af1cbe8aa66432823a6f5e1 | Ruby | marcwinstanley/extreme_startup | /spec/extreme_startup_spec.rb | UTF-8 | 1,631 | 3.296875 | 3 | [] | no_license | require 'spec_helper'
describe Question do
describe 'answering questions' do
subject { Question.new(question).answer }
context 'what is 6 plus 19' do
let(:question) { 'f9380cd0: what is 6 plus 19' }
it 'returns 25' do
expect(subject).to eq 25
end
end
context 'what is x ... | true |
bea76b432fa5616ff3c1ddd3c799874bf8ff16a9 | Ruby | Albin-Willman/robots | /tests/robot_test.rb | UTF-8 | 5,071 | 2.953125 | 3 | [] | no_license | require "minitest/autorun"
require "./app/robot"
require "./app/position"
require "./app/world"
require "./app/round"
require "./app/walls"
class TestRobot < Minitest::Test
def test_basic_position
pos = Position.new(1, 0)
assert_equal(pos, new_robot(pos: pos).position)
end
def test_basic_direction
a... | true |
164d03879ef3088a379fd06005ecc21ac4fcc5b5 | Ruby | megpha/zcdc | /app/models/patient.rb | UTF-8 | 520 | 2.5625 | 3 | [] | no_license | class Patient < ActiveRecord::Base
has_many :appointments
paginates_per 20
fuzzily_searchable :full_name
def full_name
"#{first_name} #{last_name}"
end
def age
return unless date_of_birth.present?
now = Time.now.utc.to_date
now.year - date_of_birth.year - (date_of_birth.to_date.change(year... | true |
ee3d700c4c818f6220db125a4b2fa8ea30bcb08f | Ruby | doanvan0707/Learn-Ruby-3 | /2021-01-22/ruby-use-equal.rb | UTF-8 | 311 | 3.375 | 3 | [] | no_license | # Tinh tuong dong cua cau truc du lieu trong Ruby
first_array, second_array = [1,2,3], [1,2,3]
puts "object id cua first_array: #{first_array.object_id}"
puts "object id cua second_array: #{second_array.object_id}"
puts first_array.object_id == second_array.object_id
puts first_array.equal?(second_array)
| true |
c235703647e27cab835c69298d2eec7c36ac9a1d | Ruby | DouglasAllen/code-Programming_Ruby_3rd_ed | /Part_IV--Ruby_Library_Reference/ch28_Standard_Library/Abbrev/cdesc-Abbrev.rb | UTF-8 | 599 | 3.3125 | 3 | [] | no_license | =begin
Abbrev
(from ruby core)
------------------------------------------------------------------------------
Calculate the set of unique abbreviations for a given set of strings.
require 'abbrev'
require 'pp'
pp Abbrev::abbrev(['ruby', 'rules']).sort
Generates:
[["rub", "ruby"],
["... | true |
52a42c7a1e24d04bda6c72f4d86c6ecc360a1720 | Ruby | YuukiMAEDA/AtCoder | /Ruby/ABC/A/Curtain.rb | UTF-8 | 46 | 2.765625 | 3 | [] | no_license | a,b=gets.split.map(&:to_i)
puts [a-b*2,0].max
| true |
415e7bf28cd7447e8dadb5ef2fd2f7d9074ebeb6 | Ruby | yanap/learning | /ruby/basic/bookshelf.rb | UTF-8 | 748 | 3.59375 | 4 | [] | no_license | # coding: utf-8
class Book
attr_reader :title, :author
def initialize(title, author)
@title = title
@author = author
end
end
class BookShelf
def initialize
@books = []
end
def add(book)
@books << book
end
def search(keyword)
result = search_by_title_or_author(keyword)
if re... | true |
b9c683d8d9b732bf2b718387c54e9cb0cc836d02 | Ruby | Marvalero/LearningRuby | /appendix10-solr/.bundle/ruby/2.1.0/gems/optiflag-0.6.5/testcases/tc_values_as_hash.rb | UTF-8 | 1,209 | 2.6875 | 3 | [] | no_license | require 'optiflag.rb'
require 'test/unit'
module ValuesAsHashArg extend OptiFlag::Flagset
flag "&"
flag "dir"
flag "star" do
alternate_forms "*","aster"
end
keyword "co"
usage_flag "h","help","?"
end
class TC_ValuesAsHashArg < Test::Unit::TestCase
def test_a
cl = %w{ -dir sdsd... | true |
c3decaa3231f0ecfb60efdbbbad23e069e43ba2f | Ruby | emersonmoura/pre-dojo | /app/models/round.rb | UTF-8 | 488 | 2.828125 | 3 | [] | no_license | class Round < ActiveRecord::Base
has_many :gamers
def started(timestamp)
self.start = int_to_time timestamp
end
def finished(timestamp)
self.finish = int_to_time timestamp
end
def gamer(nome)
self.gamers.select { |gamer| gamer.name.eql? nome }.first
end
def add_gamer(gamer)
... | true |
674ddc69cc46e9cd54aede0c3f0f80e7f7d255c7 | Ruby | ianchesal/adventofcode | /2021/bin/day11 | UTF-8 | 2,611 | 3.3125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'pp'
class Flash
attr_accessor :grid
def initialize(test=false)
self.grid = []
puts "START TEST MODE" if test
puts "Loading data..."
row = 0
File.readlines(input_file(test)).each do |line|
self.grid[row] = []
column = 0
line.chomp.chars do |c|
... | true |
4ca9e1c3e077054644c2ac751ae7ac1fbabfd7df | Ruby | vasyl-purchel/alpaca | /lib/alpacabuildtool/entities/solution.rb | UTF-8 | 2,766 | 2.78125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'alpacabuildtool/log/log'
require 'alpacabuildtool/configuration'
require 'alpacabuildtool/entities/project'
require 'alpacabuildtool/versioning/versioning'
module AlpacaBuildTool
##
# Solution provides solution representation and it's configuration storage
class Solution
include Log
attr_reader... | true |
1f5d1ae07cb2721ef93bdd9ada9c4685fb3ba84b | Ruby | nicolefederici/square_array-v-000 | /square_array.rb | UTF-8 | 119 | 3.515625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def square_array(array)
new_array = []
array.each {|number| new_array.push(number * number)}
return new_array
end | true |
17c9b5bf95fcba87c2a0215011fec7802569fc6a | Ruby | angeloxenakis/intro-to-oo-ruby-workshop | /run.rb | UTF-8 | 446 | 4.03125 | 4 | [] | no_license | require "pry"
class Animal
@@all = []
attr_accessor :species, :name
attr_reader :age
def initialize(species, name, age)
@species = species
@name = name
@age = age
@@all << self
end
def say_species
return "Hi! I'm a #{self.species}"
end
def sel... | true |
06b4b48b71fef3906347009f36b08d0c2e7409dd | Ruby | Mciocca/TheOdinProject | /Ruby/enumerable/enumerable.rb | UTF-8 | 2,632 | 3.953125 | 4 | [] | no_license | module Enumerable
def my_each
for i in self
yield(i)
end
end
def my_each_with_index
i = 0
while i < self.count
yield(self[i], i )
i += 1
end
end
def my_select
self.my_each {|num| yield(num) }
end
def my_all?
flag = true
self.my_... | true |
4c2bf734b2ca7f1c4c156114017f73d96bf1e7aa | Ruby | madou2000/cookbook | /test/p47.rb | UTF-8 | 58 | 3.25 | 3 | [] | no_license | valeur_retour=puts 'Ce puts returne: '
puts valeur_retour
| true |
c13220b6dc9e5599974d9400134c9562821484dd | Ruby | iampeternguyen/memory_puzzle | /lib/board.rb | UTF-8 | 1,584 | 3.484375 | 3 | [] | no_license | require_relative("card.rb")
class Board
attr_reader :cards, :game_board
def initialize(size)
@cards = []
@game_board = Array.new(size) {Array.new(size)}
@num_pairs = (size*size) / 2
self.populate
end
def won?
@cards.all? {|card| !card.is_face_down}
end
def reveal(position)
row, ... | true |
5fdd0bb6aea0c19efb7fb524313e75abd414109a | Ruby | evgeniy-trebin/ruby_patterns | /behavioral_patterns/observer/example_2_ticker/warn_high.rb | UTF-8 | 205 | 2.84375 | 3 | [] | no_license | require_relative 'warner'
class WarnHigh < Warner
def update(time, price) # callback for observer
if price > @limit
print "+++ #{time.to_s}: Price above #{@limit}: #{price}\n"
end
end
end | true |
e8e3e729cd8e2a152a29aa14f86e2d5afe4302da | Ruby | hatsu38/cafepedia-api | /db/seeds/create/cities.rb | UTF-8 | 1,051 | 2.8125 | 3 | [] | no_license | require 'open-uri'
now = Time.zone.now
csv = URI.parse('https://raw.githubusercontent.com/geolonia/japanese-addresses/master/data/latest.csv').open { |f| f.read }
# 市区町村コードでユニークする
cities_by_uniqed_city_code = CSV.parse(csv)[1..-1].uniq { |data| data[4] }
# 必要なデータのIndexをとる
data = CSV.parse(csv)[0]
city_code_index = ... | true |
25ba8484814c73bf870ef40ca65ca9b344e01cd5 | Ruby | skwak/hangman | /hangman.rb | UTF-8 | 3,567 | 3.859375 | 4 | [] | no_license | require "colorize"
class Hangman
attr_accessor :word, :guess, :fill
def initialize(word)
@word = word
@guess = guess
@fill = Array.new(word.length, "#")
@all_guesses = []
@wrong_letter_situations = 0
@possible_win = true
@head = ""
@body = ""
@left_arm = ""
@right_arm = ""
... | true |
2bd2239382eb1cabf8266514829b23df89015442 | Ruby | TwilightFoxy/ruby_codes | /lab2/ex2.rb | UTF-8 | 534 | 3.78125 | 4 | [] | no_license | def arr_min(arr)
return arr.min
end
def arr_max(arr)
return arr.max
end
def arr_sum(arr)
sum = 0
arr.each {|a| sum += a.to_i}
return sum
end
def arr_mult(arr)
mult = 1
arr.each {|a| mult *= a.to_i}
return mult
end
puts "0 - exit"
a = 1
arr = Array.new(0)
while a != "0"
a = gets.chomp
if a != "0"
arr.pu... | true |
eaeec3ffa07a082466e34c4778d5ed9d35c0d794 | Ruby | uk-gov-mirror/ministryofjustice.prison-visits | /app/services/healthcheck.rb | UTF-8 | 1,135 | 2.640625 | 3 | [
"MIT"
] | permissive | require 'sidekiq/api'
class Healthcheck
STALENESS_THRESHOLD = 10.minutes
def initialize
@queues = {}
end
def ok?
checks.fetch(:ok)
end
def checks
components = {
database: database,
mailers: mailers,
zendesk: zendesk
}
components.merge(ok: components.values.map { |h|... | true |
bff605c343a43e14579e31323ae364d958a50794 | Ruby | CUXIDUMDUM/gatling-puppet-load-test | /jenkins-integration/lib/puppet/gatling/config.rb | UTF-8 | 2,237 | 2.625 | 3 | [] | no_license | require 'json'
require 'yaml'
## Assumptions:
## 1. CWD is "jenkins-integration"
## 2. Scenario config JSON files in "./config/scenarios/*.json"
## 3. Node config JSON files in "./config/nodes/*.json"
## 4. Hiera config YAML files in "./config/hieras/<hiera>/hiera.yaml"
## 5. Hiera data trees in "./config/hieras/<hier... | true |
ececd817b588dfdad9f9058d9c1a65e52b02b05c | Ruby | spajus/tank_island | /lib/misc/stereo_sample.rb | UTF-8 | 2,102 | 2.78125 | 3 | [
"MIT"
] | permissive | class StereoSample
MAX_POLIPHONY = 16
@@all_instances = []
def self.register_instances(instances)
@@all_instances << instances
end
def self.cleanup
@@all_instances.each do |instances|
instances.each do |key, instance|
unless instance.playing? || instance.paused?
instances.del... | true |
4901a965bb6fe4c2c6cb5791848e7a4045b52652 | Ruby | kilometro28/learningruby | /11_hashes/8_the_each_method_on_a_hash.rb | UTF-8 | 324 | 4.09375 | 4 | [] | no_license | # the each method on a Hash
capitals = {alabama: "Montgomery", alaska: "Juneau",
arizona: "Phoenix", arkansas: "Little Rock"}
capitals.each do |state, capital|
puts "Querying hash..."
puts "The capital of #{state} is #{capital}"
end
capitals.each do |guess|
p guess
end
capitals.each { |guess| p gues... | true |
d0b5ee1554361a2789a623be9c170192a19d152f | Ruby | JSTHoffman/SampleApp | /app/models/user.rb | UTF-8 | 2,767 | 2.734375 | 3 | [] | no_license | # == Schema Information
#
# Table name: users
#
# id :integer not null, primary key
# name :string(255)
# email :string(255)
# created_at :datetime
# updated_at :datetime
#
require 'digest' #used for encrypting passwords
class User < ActiveRecord::Base
attr_accessor :password
attr_a... | true |
d7777467ac54796d0b33409bd4bbbc3cdb774200 | Ruby | rjmintn/address-bloc | /greeting.rb | UTF-8 | 76 | 3.171875 | 3 | [] | no_license | for arg in ARGV
next if ARGV[0] == arg
puts "#{ARGV[0]} #{arg}"
end
| true |
9bfc10bfb482409c2ba912a43e8b228da6d073d1 | Ruby | deliveroo/ravelin-ruby | /lib/ravelin/password.rb | UTF-8 | 815 | 2.703125 | 3 | [
"MIT"
] | permissive | require 'digest'
module Ravelin
class Password < RavelinObject
attr_accessor :success, :failure_reason, :password_hashed
attr_required :success
# Alternative interface, because when the attr is called "password_hashed",
# the end user might think they need to hash the password themselves
def pas... | true |
424295cf6bf4c8e6bda087a9f95cd933b0767393 | Ruby | jkeen/full-feed | /app/models/full_feed.rb | UTF-8 | 2,343 | 2.734375 | 3 | [] | no_license | require 'open-uri'
require 'feedzirra'
require 'nokogiri'
class FullFeed < ActiveRecord::Base
def self.columns() @columns ||= []; end
def self.column(name, sql_type = nil, default = nil, null = true)
columns << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default, sql_type.to_s, null)
end
colum... | true |
07dd1629c9ae2775032d2ee1198bd3340e30e0c2 | Ruby | gabiapple/redes-tcp | /aplicacao/servidor.rb | UTF-8 | 1,793 | 2.65625 | 3 | [] | no_license | # Referencias
# https://blog.appsignal.com/2016/11/23/ruby-magic-building-a-30-line-http-server-in-ruby.html
# https://practicingruby.com/articles/implementing-an-http-file-server
require 'socket'
require 'time'
server = TCPServer.new 10006
begin
displayfile = File.open("index.html", 'r')
content = displayfile.rea... | true |
45bbd1a027c3b4cda8f8bc927275c2f75e8bf1e9 | Ruby | masa21kik/fizzbuzz | /lib/fizz_buzz.rb | UTF-8 | 214 | 3.796875 | 4 | [] | no_license | # -*- mode: ruby; coding: utf-8 -*-
class FizzBuzz
def say(number)
word = ''
word << 'fizz' if number % 3 == 0
word << 'buzz' if number % 5 == 0
return word.empty? ? number.to_s : word
end
end
| true |
7e9088266ee5e8e228a3e60aa16fd7b0d14069db | Ruby | citac/citac | /lib/citac/puppet/patches/graphml_generation.rb | UTF-8 | 890 | 2.765625 | 3 | [] | no_license | require 'puppet/graph/simple_graph'
require_relative '../../commons/utils/graph'
# Extends Puppet to generate graphs in GraphML format in addition to DOT
class Puppet::Graph::SimpleGraph
alias_method :__citac_original_write_graph, :write_graph
def write_graph(name)
return unless Puppet[:graph]
return_va... | true |
6e85fa0586313ec4b8141a9afa97d5667cdacd4c | Ruby | jschairb/statements | /app/models/line_item.rb | UTF-8 | 567 | 2.6875 | 3 | [] | no_license | class LineItem < ActiveRecord::Base
belongs_to :statement
validates_presence_of :description, :price, :quantity, :statement
before_save :calculate_cost
after_create :add_to_statement_total
after_destroy :subtract_from_statement_total
protected
def add_to_statement_total
statement.total_cost = st... | true |
2b7d78579d51c6978866c6fdeb96bc5ac283192f | Ruby | dshorthouse/taxpub | /lib/taxpub/utils.rb | UTF-8 | 384 | 2.53125 | 3 | [
"MIT"
] | permissive | class TaxPub
class Utils
def self.clean_text(text)
text.encode("UTF-8", :undef => :replace, :invalid => :replace, :replace => " ")
.gsub(/[[:space:]]/, " ")
.chomp(",")
.split
.join(" ")
end
def self.expand_doi(doi)
if doi[0..2] == "10."
doi.pr... | true |
56b397f53f421809c1b5fa5247c0898c501e6653 | Ruby | Belkakarro/tasks_ruby | /lesson4/support_text.rb | UTF-8 | 3,658 | 3.015625 | 3 | [] | no_license | module SupportText
def split
puts "----------"
end
def menu_type_train
puts "Выберите тип поезда:"
puts "1 - пассажирский поезд"
puts "2 - грузовой поезд"
end
def menu_type_wagon
puts "Какой создаем вагон?"
puts "1 - пассажирский вaгон"
puts "2 - грузовой вaгон"
end
def questions_show_menu... | true |
d9f226f87415f422df84bdda54082ab86b9dd9b8 | Ruby | oliverfeher/deli-counter-onl01-seng-ft-012120 | /deli_counter.rb | UTF-8 | 690 | 3.890625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Write your code here.
katz_deli = []
def line(array)
if array.length > 0
array1 = []
counter = 1
array.each do |name|
array1.push("#{counter}. #{name}")
counter +=1
end
puts "The line is currently: #{array1.join(" ")}"
else
puts "The line is currently empty."
end
end
def ... | true |
3ae44405ddb50371de78931d9442a8977f0e54b9 | Ruby | stem/alchemy_cms | /lib/alchemy/elements_finder.rb | UTF-8 | 2,233 | 2.765625 | 3 | [
"BSD-3-Clause"
] | permissive | # frozen_string_literal: true
require "alchemy/logger"
module Alchemy
# Loads elements from given page
#
# Used by {Alchemy::Page#find_elements} and {Alchemy::ElementsHelper#render_elements} helper.
#
# If you need custom element loading logic in your views you can create your own finder class and
# tell ... | true |
48d47c22a52188f2f10c3f9561df91c3e9dc17e0 | Ruby | philhartmanonic/Galen_Online | /app/helpers/application_helper.rb | UTF-8 | 1,633 | 2.578125 | 3 | [] | no_license | module ApplicationHelper
require 'redcarpet'
require 'rouge'
require 'rouge/plugins/redcarpet'
class HTML < Redcarpet::Render::HTML
include Rouge::Plugins::Redcarpet
def autolink(link, link_type)
case link_type
when :url then url_link(link)
when :email then email_link(link)
... | true |
43c366559b979d9c68ed16ba65c22426876c2023 | Ruby | jonpstone/portfolio-project-rails-mean-movie-reviews | /vendor/bundle/ruby/2.3.0/gems/sqreen-1.10.5/lib/sqreen/serializer.rb | UTF-8 | 1,501 | 2.890625 | 3 | [
"MIT"
] | permissive | # Copyright (c) 2015 Sqreen. All Rights Reserved.
# Please refer to our terms for more information: https://www.sqreen.io/terms.html
module Sqreen
# Serialization functions: convert Hash -> simple ruby types
module Serializer
# Serialize a deep hash/array to more simple types
def self.serialize(obj, max_de... | true |
bdbb9dc93f63cb04251c651a0c03202c7b18c19e | Ruby | nmoutana/sr | /test/gold.rb | UTF-8 | 1,029 | 2.828125 | 3 | [] | no_license | #!/usr/bin/env ruby
$:.unshift "lib"
require "sr/util"
require "base64"
require "zlib"
@num_revs = Sr::Util.send_message("localhost:7777", "num_revs", {})[:num_revs].to_i
# @num_revs = 500
@seq = 0
result = Hash.new(0)
while @seq < @num_revs
res = Sr::Util.send_message("localhost:7777", "next_rev/#{@seq}", {})
... | true |
12516cabe8af312fcd8b9a2789b7229d28aab79d | Ruby | mobmewireless/url-agent | /lib/url_agent/url.rb | UTF-8 | 1,379 | 2.71875 | 3 | [] | no_license | class URLAgent::Url
attr_accessor :live
def initialize(url, options = {})
@url = url
@dispatcher = options[:dispatcher]
@live = options[:live].nil? ? true : options[:live]
@url_set_identifier = options[:url_set_identifier]
@identifier = options[:identifier]
unless @dispatcher
raise ... | true |
e0bc885fb634eeaabbb1dc7e02f3c21b1e42d6f6 | Ruby | 0xack13/panoptimon | /collectors/disk_free/disk_free | UTF-8 | 424 | 2.640625 | 3 | [
"BSD-3-Clause"
] | permissive | #!/usr/bin/env ruby
require 'json'
df_cmd = 'df -kP' # or without -P on non-gnu...
info = %x{#{df_cmd}}.split(/\n/).drop(1).
map{|l| l.split(/\s+/).values_at(0,2,3,5)} # fs, used, free, mount
.find_all{|x| not(x[0] =~ /^(udev|tmpfs|none)$/)}
out = {}
info.each {|x| out[x[0]] = {
used: (x[1].to_f / 1024**2).rou... | true |
784a07696f2a26311e9c9360b0eb361c9530dfaa | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/hamming/9395add1de964b459143024d82ea4adb.rb | UTF-8 | 1,703 | 3.40625 | 3 | [] | no_license | #!/usr/bin/env ruby
class Hamming
attr_reader :strandA, :strandB
def initialize(strandA, strandB)
@a = strandA
@b = strandB
end
def self.compute(a, b)
@A, @B = a.split(""), b.split("")
diff = []
case
# assert_equal 1, Hamming.compute(
# ['AGAGACTTA', 'AAA']
# ['
... | true |
d44b822d44a1b0416aabd5124cff1630c337e59f | Ruby | andrewrgoss/udemy-learn-ruby | /13_hashes_ii/merge_method_to_combine_hashes.rb | UTF-8 | 742 | 3.9375 | 4 | [] | no_license | #!/usr/bin/env ruby
# This method is called on a hash and accepts a single argument of another
# hash and combines those 2 hashes into one. This is a temporary operation
# so if we need to merge 2 hashes permanently, we need to use a bang
# method.
market = { garlic: '3 cloves', tomatoes: '5 batches', milk: '10 gall... | true |
92beace5efd012c4f47bb1531460f1e630b54584 | Ruby | Bootshoe/NH | /ruby/list/TodoList.rb | UTF-8 | 451 | 3.421875 | 3 | [
"MIT"
] | permissive | class TodoList
attr_accessor :items
def initialize
end
@@items = ["do the dishes", "mow the lawn"]
def get_items
@@items
end
def add_item(item)
@@items = @@items.push("#{item}")
end
def delete_item(item)
@@items.delete("#{item}")
end
def retrieve
@@items
end
end
list... | true |
ad62b77c23770d54769340941d23e5b1216cc12f | Ruby | justcodeitrich/Book-Intro-To-Ruby | /Chapters/9_Exercises/9.16.rb | UTF-8 | 4,419 | 4.3125 | 4 | [] | no_license | # Challenge: In exercise 11, we manually set the contacts hash values one by one.
# Now, programmatically loop or iterate over the contacts hash from exercise 11,
# and populate the associated data from the contact_data array.
# Hint: you will probably need to iterate over ([:email, :address, :phone]),
# and some h... | true |
4b891e89c67de1f97f5eed5eed9e5193e0a12276 | Ruby | ap2322/mini_shop | /spec/features/items/user_can_see_item_info_on_show_spec.rb | UTF-8 | 3,237 | 2.734375 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe "When I visit '/items/:id'" do
it "has the item with that id including the item's:
- name
- active/inactive status
- price
- description
- image
- inventory
- the name of the merchant that sells ... | true |
32d7b25d71af33a97937d9c9be9f0ee358714007 | Ruby | kristjan/code_eval | /first_nonrepeated_character/first_nonrepeated_character.rb | UTF-8 | 363 | 3.53125 | 4 | [] | no_license | #!/usr/bin/env ruby
def histogram(items)
Hash.new(0).tap do |histogram|
items.each {|i| histogram[i] += 1}
end
end
def first_nonrepeated_character(str)
chars = str.split('')
hist = histogram(chars)
chars.find {|ch| hist[ch] == 1}
end
File.readlines(ARGV[0]).each do |line|
result = first_nonrepeated_c... | true |
fe37b4249546636242328e70c86a8c8b2819cc4f | Ruby | norkuy/LS_Programming_Foundations | /101-109 - Small Problems/Easy 3/two.rb | UTF-8 | 425 | 3.90625 | 4 | [] | no_license | puts "Enter a number:"
num_one = gets.chomp.to_f
puts "Enter a number:"
num_two = gets.chomp.to_f
puts "#{num_one} + #{num_two} = #{num_one + num_two}"
puts "#{num_one} - #{num_two} = #{num_one - num_two}"
puts "#{num_one} * #{num_two} = #{num_one * num_two}"
puts "#{num_one} / #{num_two} = #{num_one / num_two}"
puts ... | true |
15d32f8c979b5729f501c2ecc136849415a4a341 | Ruby | palkan/ruby-compatibility-examples | /examples/args_forward.rb | UTF-8 | 165 | 3.109375 | 3 | [] | no_license | class A
def bar(p, k:)
[p, k, yield]
end
def foo(...)
bar(...)
end
end
raise "Assertion failed" unless A.new.foo(1, k: "a") { :x } == [1, "a", :x]
| true |
ee1b2ad32032f4cce22adf0181179679f61a8cf0 | Ruby | miyyuk/fleamarket_sample_75j | /spec/models/user_spec.rb | UTF-8 | 4,790 | 2.671875 | 3 | [] | no_license | require 'rails_helper'
describe User do
describe '#create' do
it "全てのカラムがある場合は登録できること" do
user = build(:user)
expect(user).to be_valid
end
it "nicknameがない場合は登録できないこと" do
user = build(:user, nickname: "")
user.valid?
expect(user.errors[:nickname]).to include("を入力してください")
... | true |
0f9687668017ec05f3cf251b04e5654d42136013 | Ruby | ComunidadTIC/NivelR | /desafio-03/matiasmasca/desafio3_nivelR.rb | UTF-8 | 8,261 | 3.53125 | 4 | [] | no_license | =begin
Arbol de Mandarinas (No injertadas)
- Aplicar los conceptos de Clases y Métodos. Método aleatorio.
Descripción:
Hacer una clase arbolMandarinas . Deberá tener un método altura que devuelve su altura y un método paso365Dias que cuando se le llama aumenta la edad del árbol en un año. Cada año crece el árbol y se ... | true |
619b5afbcc546d075bd7a58479fbc477f110433b | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/beer-song/5c6f2de8dbea42c9ba6ba9bc8ecaaf53.rb | UTF-8 | 890 | 4 | 4 | [] | no_license | class Beer
attr_reader :count
def initialize
end
def verse(count)
@count = count
return last_verse if count == 0
"#{count} #{bottles} of beer on the wall, #{count} #{bottles} of beer.\nTake #{one_or_it} down and pass it around, #{last_beer} of beer on the wall.\n"
end
def sing(x, y=0)
ans... | true |
e02d435c5c3140dfa0bb3641b79bf1b935a7a43c | Ruby | arikast/minimal-bash | /lib/completion.rb | UTF-8 | 1,203 | 2.90625 | 3 | [] | no_license | module CompletionUtils
def min(a, b)
if b < a then
b
else
a
end
end
def commonPrefix(a, b)
len = min(a.length, b.length)
0.upto(len - 1).each {|i|
if a[i] != b [i] then
return a[0..i]
end
}
return a[0..len]
end
def longestCommonPrefix(choices)
... | true |
36d96a5cddc92442ebac11ba2380fa252b7ab7bc | Ruby | owst/advent_of_code_2019 | /day_11/part_1/main.rb | UTF-8 | 4,564 | 3.28125 | 3 | [] | no_license | require 'set'
def read_instructions
File.read(ARGV[0]).split(',').map(&:to_i)
end
class State
ADDRESS_MODES = {
0 => :position,
1 => :immediate,
2 => :relative
}
def initialize(instructions, read, write)
@memory = instructions.each_with_index.map { |x, i| [i, x] }.to_h
@read = read
@w... | true |
97cec69b31794c6573339fcd2d976b7e03512b17 | Ruby | DouglasAllen/My_PDF_Lib | /Learn_Ruby_n7weeks/exercises/rlcr_w01_ex06.rb | UTF-8 | 2,988 | 4.5 | 4 | [] | no_license | # exercise_w0106.rb
=begin
Write a method called convert that takes one argument which is a temperature in degrees Fahrenheit.
This method should return the #temperature in degrees Celsius.
To format the output to say 2 decimal places, we can use the Kernel's format method.
For example, if x = 45.5678 then fo... | true |
c70ab55211a27423d7f2d89a059a7779d6270ffc | Ruby | Engineer-Amgad/anagram-detector-online-web-pt-090819 | /lib/anagram.rb | UTF-8 | 364 | 3.609375 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # Your code goes here!
class Anagram
attr_accessor :anagram_word
def initialize(word)
@anagram_word = word
end
def match(array)
words_array = array
match_array = []
words_array.each do |word|
if anagram_word.split("").sort == word.split("").sort
match_array << word
... | true |
f7855bea5b9a0a2f8ffcc38c67309a40f1091779 | Ruby | lotherk/rarma | /rarmalib/lib/rarmalib/sqf/marker.rb | UTF-8 | 3,176 | 2.65625 | 3 | [
"MIT"
] | permissive | class Rarma::SQF::Marker
attr_accessor :pos, :type, :shape, :color, :dir, :size, :brush, :alpha
attr_reader :this, :name, :local
def initialize _name, _pos, _shape="ICON", _type="Empty", _dir=0
@name = _name
@pos = _pos
@shape = _shape
@type = _type
@dir = _dir
end
__native :create
def... | true |
1f7a245eb14b57b70d60349375bb451efd929540 | Ruby | karlwitek/launch_school_rb101 | /lesson4/practice_problems2.rb | UTF-8 | 705 | 4.03125 | 4 | [] | no_license | # add up all of the ages from the Munster family hash:
ages = { "Herman" => 32, "Lily" => 30, "Grandpa" => 5843,
"Eddie" => 10, "Marilyn" => 22, "Spot" => 237 }
# sum = 0
# ages.map do |key, value|
# sum += value
# end
# puts sum
# works. probably better to use .each
# ages.each do |key, value|
# sum += v... | true |
248078861544d3a5cb562a28eea4914b24e6dfb7 | Ruby | Tmee/SnowMaps | /app/models/vail_scraper.rb | UTF-8 | 4,976 | 2.625 | 3 | [] | no_license | class VailScraper
def initialize
set_documents
generate_mountain
check_open_status
unless closed?
generate_mountain_information
generate_peaks
generate_trails
end
end
def check_open_status
@mountain_doc.xpath("//div[contains(@class, 'snowConditions')]//text()").to_s.inc... | true |
71b30fa7e280532b8a56b490867c326b30c2b1f7 | Ruby | gyjin/hotel | /lib/reserv_system.rb | UTF-8 | 1,187 | 3.0625 | 3 | [] | no_license | RATE_OF_ROOM = 200
NUM_OF_ROOMS = 20
require 'pry'
module Hotel
class ReservSystem
attr_reader :rooms, :reservations
def initialize()
@rooms = Hotel::Room.all
@reservations = []
end
def make_reservation(start_time, end_time)
not_reserved_rooms = not_reserved_on_date_range(... | true |
a9793859c3ffade607893b1ba48e72d4b4c8a16e | Ruby | cha63506/Library-408 | /lib/trg_hatter_library.rb | UTF-8 | 1,669 | 3.453125 | 3 | [] | no_license | require "trg_hatter_library/version"
require "trg_hatter_library/book"
require "trg_hatter_library/author"
require "trg_hatter_library/reader"
require "trg_hatter_library/order"
module TrgHatterLibrary
class Library
attr_reader :books, :orders, :readers, :authors
COUNT_BOOK = 3
def initialize(authors ... | true |
4b731d1cf0418a9d8bba9091639c2f6a1f3ef6e6 | Ruby | aakumykov/virtualbook | /probes/arg.rb | UTF-8 | 133 | 2.546875 | 3 | [] | no_license | #coding: utf-8
def foo arg={}
uri = arg[:uri] || 'хуй'
mode = arg[:mode] || :full
puts "uri: #{uri}, mode: #{mode}"
end
foo
| true |
759661fb0117530d11ac3c28c9f5898ed1132335 | Ruby | praxis/praxis | /lib/praxis/docs/open_api/paths_object.rb | UTF-8 | 2,073 | 2.53125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # frozen_string_literal: true
require_relative 'operation_object'
module Praxis
module Docs
module OpenApi
class PathsObject
# https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#paths-object
attr_reader :resources, :paths
def initialize(resources:)
... | true |
6e867c079b8b78d91d7094e7e537d5558ba39cfb | Ruby | jdunphy/templette | /test/method_collector_test.rb | UTF-8 | 1,090 | 2.6875 | 3 | [] | no_license | require File.expand_path(File.dirname(__FILE__) + '/test_helper.rb')
class MethodCollectorTest < Test::Unit::TestCase
context "A MethodCollector" do
setup do
@template = Templette::Template.new('test')
@template.stubs(:path).returns('test.html')
File.stubs(:exists?).returns(true)
Templ... | true |
7153014f2b3271b8d10ea4f8b09d4023bbe7e3e5 | Ruby | shirleytang0121/AAClasswork | /W4D3/Chess/slideable.rb | UTF-8 | 892 | 3.296875 | 3 | [] | no_license | module Slideable
HORIZONTAL_DIRS = [ [0, -1], [0, 1], [1, 0], [-1, 0] ]
DIAGONAL_DIRS = [ [-1, -1], [-1, 1], [1, -1], [1, 1] ]
def horizontal_dirs
HORIZONTAL_DIRS
end
def diagonal_dirs
DIAGONAL_DIRS
end
def moves
all_moves = []
move_dirs.each do |dx, dy|... | true |
85eb78d4fecdbe0570079d0920a1c4ad62e35913 | Ruby | tjstankus/scrawl_old | /lib/scrawl/entry.rb | UTF-8 | 581 | 2.609375 | 3 | [
"MIT"
] | permissive | require 'metadown'
require 'time'
module Scrawl
class Entry
attr_reader :file_content
def initialize(file_content)
@file_content = file_content
@data = parse
end
def content
@data.output
end
def created_at
@created_at ||= DateTime.parse(@data.metadata['created_at'])... | true |
ae561f489b69bf21265427bf2a42fba81cf72fef | Ruby | jlcapps/verso | /lib/verso/task.rb | UTF-8 | 2,133 | 2.71875 | 3 | [
"MIT"
] | permissive | module Verso
# Task resource
#
# A {Verso::Course} task/competency contained by a {Verso::DutyArea} or
# a {Verso::CorrelationList}.
#
# @!attribute [r] code
# @return [String] Course code
# @!attribute [r] definition
# @return [String] HTML-formatted Task definition
# @!attribute [r] edition
... | true |
ac347aa1c27873e82fef0a53dbc4e08587b6d605 | Ruby | aknishi/aA-homeworks | /W2D3/Rspec_hw/spec/dessert_spec.rb | UTF-8 | 2,190 | 3.515625 | 4 | [] | no_license | require 'rspec'
require 'dessert'
=begin
Instructions: implement all of the pending specs (the `it` statements without blocks)! Be sure to look over the solutions when you're done.
=end
describe Dessert do
let(:chef) { double("chef", name: "Adrian") }
let(:cheesecake) { Dessert.new("cake", 10, chef)}
describe ... | true |
5e49c4342c6932d2aff326276cb0d6c2d7778d07 | Ruby | segan/Lame-Chat | /lame_chat.rb | UTF-8 | 2,144 | 2.6875 | 3 | [] | no_license | #!/usr/bin/env ruby -w
require 'rubygems'
require 'eventmachine'
class CmdExecutor < EM::Connection
include EM::P::LineText2
attr_reader :port
attr_reader :cmd_prompt
attr_reader :rsp_prefix
attr_reader :greetings
attr_reader :chan
attr_accessor :chan_sid
def initialize port, chan, *args
... | true |
2262d6f19fb18740378d3a7537887d2490867b8b | Ruby | eliselin/rubyplayground | /songplay.rb | UTF-8 | 1,501 | 4.0625 | 4 | [] | no_license | class Song
#helper method (getter method)
attr_reader :title, :artist, :filename, :play_count #instance methods
#class variable: set to 0 when the program is loaded
@@total_plays = 0 #class variable
#constructor& attributes
def initialize(title, artist, filename)
@title = title #instance variable
@artist ... | true |
7f0590c0d097d5aa6faee9351abd3b2913edd6e1 | Ruby | controlshift/ruby-salsa_labs | /lib/salsa_labs/salsa_objects_fetcher.rb | UTF-8 | 1,997 | 2.71875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module SalsaLabs
##
# Service object to pull back a collection of objects from the Salsa Labs API.
##
class SalsaObjectsFetcher
def initialize(filter_parameters = {}, credentials = {})
@filter_parameters = SalsaLabs::ApiObjectParameterList.new(filter_parameters)
@c... | true |
bf8e9e0632ee18ba18dc066db1ce8c8b6cd0f957 | Ruby | pranavcode/income-tax | /spec/income_tax/countries/malta_spec.rb | UTF-8 | 4,431 | 2.953125 | 3 | [
"MIT"
] | permissive | describe IncomeTax::Countries::Malta do
subject(:result) { described_class.new(income: income, income_type: type) }
let(:type) { :gross }
describe "from gross income of 0" do
let(:income) { 0 }
its(:rate) { should be == Rational(0, 1) }
... | true |
56e491eeab40507e03bbed4e91dae8fe419b5fdc | Ruby | davidliang781205/ar-exercises | /lib/store.rb | UTF-8 | 351 | 2.515625 | 3 | [] | no_license | class Store < ActiveRecord::Base
validates_length_of :name, minimum: 3
validates_numericality_of :annual_revenue
validate :men_or_women
has_many :employees
def men_or_women
if !(mens_apparel) && !(womens_apparel)
errors.add(:must_be_men_or_women, "Store must carry at least one of the men's or women... | true |
101aa3170ddc0c0f215822af5c6a331c04f574d0 | Ruby | mel-d/web-app__swimming-competition | /app/models/event_model.rb | UTF-8 | 689 | 2.609375 | 3 | [] | no_license | class Event < ActiveRecord::Base
#returns String (name of style of event object)
def display_style_of_event
x = self.style_id
z = Style.find_by_id(x) #returns style object with id of events wanted
return z.style
end
def set_errors
@errors = []
if self.gender == nil
@errors << "Gender ... | true |
1a15ae55de624cbeadb61468dfc91497d5e38501 | Ruby | mrlevitas/deployment_cycle | /app/controllers/welcome_controller.rb | UTF-8 | 1,954 | 2.53125 | 3 | [] | no_license | class WelcomeController < ApplicationController
def index
end
def show
num = rand(1000)
@user = User.create(email: "johnny#{num}@gmail.com", first_name: "Jason", last_name: "Bourne", password: "password")
# binding.pry
@timeline = Timeline.create(title: "Your Awesome Project", description: "Your ... | true |
eed38ff043f82966bf21f488910f359a583a4e0e | Ruby | inspec/inspec-aws | /libraries/aws_lambdas.rb | UTF-8 | 1,256 | 2.515625 | 3 | [
"Apache-2.0"
] | permissive | require "aws_backend"
class AwsLambdas < AwsResourceBase
name "aws_lambdas"
desc "Verifies generic settings for a set of lambdas."
example "
describe aws_lambdas() do
its ('count') { should eq 6}
end
"
attr_reader :table
FilterTable.create
.register_column(:names, field: :name)
.regi... | true |
e633a314eff5b48317cb75905a39c47b2ac5af98 | Ruby | naomimthomas/tts_new_project | /battle.rb | UTF-8 | 1,296 | 4.03125 | 4 | [] | no_license | require_relative 'bear'
require_relative 'ninja'
class Battle
attr_reader :fighter1, :fighter2
def initialize(fighter1, fighter2)
@fighter1 = fighter1
@fighter2 = fighter2
end
def fight
@fighter1.attack(fighter2)
@fighter2.attack(fighter1)
self.battle_status
end
def fighter1_attack
@fighter1.attack(f... | true |
8447acd3be56be7eed5ed63fd3005a685eb154cc | Ruby | narogers/cma-archives | /app/jobs/install_administrative_collections_job.rb | UTF-8 | 2,515 | 2.515625 | 3 | [] | no_license | class InstallAdministrativeCollectionsJob
attr_accessor :collections
def initialize(collections)
self.collections = collections
end
# :nocov:
def queue_name
:install
end
# :nocov:
def run
admin_collections = collections.is_a?(String) ?
load_policies(collections) :
collections
... | true |
1e888fd55c2f1d88512cb29004bdb760a3fe6e23 | Ruby | paolobrasolin/telegram | /gen/telegram/api/bot/types/order_info.rb | UTF-8 | 1,181 | 2.671875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'telegram/core_ext'
module Telegram
module API
module Bot
module Types
# See the {https://core.telegram.org/bots/api#orderinfo official documentation}.
#
# @!attribute [rw] name
# @return [String, nil]
# @!attribute [rw] phone... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.