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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
baa6657985fbc060638b9277eb8e95edd9768cc5 | Ruby | Alec-Scully/programming-univbasics-3-build-a-calculator-lab-wdc01-seng-ft-111620 | /lib/math.rb | UTF-8 | 442 | 3.40625 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def addition(num1, num2)
sum = num1 + num2
end
def subtraction(num1, num2)
difference = num1 - num2
end
def division(num1, num2)
quotient = num1 / num2
end
def multiplication(num1, num2)
product = num1 * num2
end
def modulo(num1, num2)
mod = num1 % num2
end
def square_root(num)
Math.sqrt(num)
end
def ... | true |
6725ae070a1baadce454b8dc945a92eac47be13a | Ruby | Pragmaticpraxis37/war_or_peace | /test/deck_test.rb | UTF-8 | 2,255 | 3.203125 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/pride'
require_relative '../lib/card'
require_relative '../lib/deck'
class DeckTest < Minitest::Test
def test_it_exists
card1 = Card.new(:diamond, 'Queen', 12)
card2 = Card.new(:spade, '3', 3)
card3 = Card.new(:heart, "Ace", 14)
cards = [card1, card2, car... | true |
30ccfeb8c12a403c00e19ef8f4840bd678be21d9 | Ruby | unkmas/focus | /lib/focus/http_client.rb | UTF-8 | 927 | 2.65625 | 3 | [
"MIT"
] | permissive | require 'net/http'
require 'json'
require_relative 'http_client/error_handler'
module Focus
class HttpClient
attr_reader :api_key
BASE_URL = "https://focus-api.kontur.ru/api#{API_VERSION}/".freeze
def initialize(api_key)
@api_key = api_key
end
def get(method:, **params)
response = ... | true |
849360c132cf5c0bf7fca9bd03dc16d8fa95da3e | Ruby | cavvia/forgetsy | /spec/set_spec.rb | UTF-8 | 3,201 | 2.84375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'spec_helper'
describe "Forgetsy::Set" do
before(:each) do
@redis = Forgetsy.redis
@set = Forgetsy::Set.create('foo', t: 1.week)
end
describe 'creation' do
it 'creates a redis set with the appropriate name and stores metadata' do
expect(@redis.zcount('foo', '-inf', '+inf')).to eq(2)
... | true |
3cf487ec4e03779c56493ffa90e5bdf510a26925 | Ruby | avanderhook/rubicante | /bin/rubicante | UTF-8 | 822 | 2.65625 | 3 | [
"BSD-3-Clause"
] | permissive | #!/usr/bin/env ruby
require 'rubicante/cli'
require 'trollop'
opts = Trollop::options do
banner <<-EOS
A business natural language for Systems Administrators
Usage:
rubicante [options]
where [options] are:
EOS
opt :cron, "Check the network described in the specified file and exit", :type => :string
opt ... | true |
2e4212c17b263db928673638cca8aecaf8948882 | Ruby | lairtonmendes/daily-scrum | /app/mailers/replies_mailer.rb | UTF-8 | 863 | 2.515625 | 3 | [] | no_license | # responsible class for sending emails daily for responses 'dailies'
class RepliesMailer < ActionMailer::Base
# definition of mail delivery
default :from => 'no-reply@dailies.com'
# method for sending e-mail, receives two parameters user for who can be sent and daily for the answer
def reply_send(user, daily)
@u... | true |
82e70ccfa9f870e64e107d0a1febb1de48a18617 | Ruby | ryuichi7/hello-fresh | /app/importers/importer.rb | UTF-8 | 354 | 2.953125 | 3 | [] | no_license | require 'open-uri'
require 'csv'
class Importer
attr_accessor :path, :translator
def initialize(path, translator = nil)
@path = path
@translator = translator
end
def data
new_path = path.is_a?(String) ? open(path) : path
CSV.read(new_path)
end
def import
data.each { |row| Ingredient.create_and_asso... | true |
d6cabaeb07c728a14c0b31fa97ca4ae3f3c960d3 | Ruby | BernardoMG/line-server-network | /app/interactors/line_retriever.rb | UTF-8 | 1,251 | 3.171875 | 3 | [] | no_license | require_relative '../services/cache/redis_manager'
class LineRetriever
attr_reader :file_manager, :line_number
def initialize(file_manager, line_number)
@file_manager = file_manager
@line_number = line_number
end
def self.run(file_manager, line_number)
self.new(file_manager, line_number).run
en... | true |
052540496c45b904b47af9079a289819f1c2f134 | Ruby | totalbabe13/phase-0-tracks | /ruby/my_solutions.rb | UTF-8 | 4,425 | 3.828125 | 4 | [] | no_license | # Virus Predictor
# I worked on this challenge [by myself, with: ].
# We spent [#] hours on this challenge.
# EXPLANATION OF require_relative
# Required relative, sources data/code from another document, similar to the relationship that css has with HTML
# You can work with a local source class, or data structure, ... | true |
c4dc1b117e0f7f4ac56170479309347ffc6acc4d | Ruby | sharatchandraj/hw-ruby-intro | /lib/ruby_intro.rb | UTF-8 | 1,193 | 3.828125 | 4 | [] | no_license | # When done, submit this entire file to the autograder.
# Part 1
def sum arr
# YOUR CODE HERE
arr.inject(0, :+)
end
def max_2_sum arr
if arr.size < 1
return 0
elsif arr.size == 1
return arr[0]
else
arr=arr.sort()
sum = arr[arr.size-1]+arr[arr.size-2]
return sum
end
end
def sum_to_n? ... | true |
ecb795f7fe7f80c6bc953c1b3570671d70ccf31f | Ruby | shawndromat/chess | /piece.rb | UTF-8 | 1,024 | 3.359375 | 3 | [] | no_license | require 'debugger'
require './board.rb'
require 'colorize'
class Piece
attr_reader :color, :board
attr_accessor :position
def initialize(position, board, color)
@position = position
@board = board
@color = color
end
def opponent?(pos)
return false if @board.rows[pos[0]][pos[1]].nil?
@co... | true |
1ccfb80772df47e40fa934498126bb2409fc8afb | Ruby | cjpillette/ruby_health_routine_plan | /temperature.rb | UTF-8 | 2,226 | 4.03125 | 4 | [] | no_license | #i want to enter in the temperatures for every day of the week and have them presented nicely in Celsius and Fahrenheit
require 'date'
require 'ascii_charts'
require 'colorize'
require 'artii'
class ProgressBar
def initialize(title = "Progress", total = 7, increment = 1, progress = 0)
@title = title
@total ... | true |
d6f42e79b69229d1c4d14a8cc7422976e7e07ac9 | Ruby | KKQueenKing/rails-mister-cocktail | /db/seeds.rb | UTF-8 | 735 | 2.734375 | 3 | [] | no_license | # This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Ch... | true |
8f80df13cc8442cee3e978a69f0c017d529e3170 | Ruby | SirawitN/web_prog_2 | /app/models/post.rb | UTF-8 | 375 | 2.625 | 3 | [] | no_license | class Post < ApplicationRecord
belongs_to :user
def valid_user_id(checkID)
puts "checkID = #{checkID},......... #{self.user_id}"
#puts "#{checkID.class}, #{user_id.class}"
if checkID == self.user_id
return true
else
errors.add(:user_id, "is not matched!! You have no permission to perfo... | true |
79efd93d31f63bbf75054b71b282a03bf0871bb7 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/saddle-points/960771ed716b4d6e9ac09f4a9c5eee7c.rb | UTF-8 | 370 | 3.171875 | 3 | [] | no_license | class Matrix
attr_reader :rows, :columns
def initialize(input)
@rows = input.lines.map{|e| e.split.map(&:to_i)}
@columns = @rows.transpose
end
def saddle_points
@rows.each_with_index.with_object(Array.new) do |(re, ri), result|
@columns.each_with_index do |ce, ci|
result << [ri, ci] ... | true |
b47b0e16cb5833b724d70aeb03014600bc26735c | Ruby | jastaffen/OO-Animal-Zoo-nyc-clarke-web-100719 | /run.rb | UTF-8 | 555 | 3.390625 | 3 | [] | no_license | require_relative "lib/Animal.rb"
require_relative "lib/Zoo.rb"
require 'pry'
#Test your code here
zoo1 = Zoo.new("zoo1", "NY")
zoo2 = Zoo.new("zoo2", "LA")
zoo3 = Zoo.new("zoo3", "NY")
animal1 = Animal.new("cat", 25, "steve", zoo1)
animal2 = Animal.new("dog", 20, "jacob", zoo1)
animal3 = Animal.new("dog", 19, "jack"... | true |
359c9f352603178ec8105c58fa43fa1534459aeb | Ruby | agranado2k/sift_co | /lib/checkout_item.rb | UTF-8 | 242 | 2.765625 | 3 | [] | no_license | module Syft
class CheckoutItem
attr_accessor :code, :price, :name, :quantity
def initialize(item, quantity = 1)
@code = item.code
@name = item.name
@price = item.price
@quantity = quantity
end
end
end
| true |
a9b852c4ddd7e93dd0aea7047001ea4c54f3abce | Ruby | christianRakete/gatorate | /lib/gatorate/door.rb | UTF-8 | 521 | 2.734375 | 3 | [
"MIT"
] | permissive | require 'celluloid'
module Gatorate
class Door
include Celluloid
def initialize(pin=8)
@button_pin = pin
@status = :open
end
def open?
puts status
status == :open
end
def closed?
!open?
end
def status
@status
end
def... | true |
9f0490283ed5ba585bb2e9fb6e56a2d023b62d36 | Ruby | shi-mo/yukicoder | /0098.rb | UTF-8 | 102 | 3.109375 | 3 | [] | no_license | x, y = gets.split.map(&:to_i)
r = Math.sqrt(x*x + y*y) * 2
puts (r.ceil <= r) ? (r.ceil + 1) : r.ceil
| true |
54956082321a4562b359e18bb35639f228948049 | Ruby | AndresRamirezMunoz/Path-Ruby | /Section_14/chapter_179To183.rb | UTF-8 | 1,374 | 4.65625 | 5 | [] | no_license | #Procs II
hi = Proc.new { puts "Hi there!"}
hi.call
2.times(&hi)
puts
#Pass a ruby methods as Proc
p ["1", "2", "3", "4"].map { |number| number.to_i}
p ["1", "2", "3", "4"].map(&:to_i)
p [1, 2, 3, 4, 5, 6,].select{|number| number.even?}
p [1, 2, 3, 4, 5, 6,].select(&:even?)
puts
#Methods with Proc parameters
def ta... | true |
94963df772164dd005a492592853651c5e6b72a0 | Ruby | defunkt/choice | /test/test_writer.rb | UTF-8 | 2,287 | 2.953125 | 3 | [
"MIT"
] | permissive | $:.unshift "../lib:lib"
require 'test/unit'
require 'choice'
class TestWriter < Test::Unit::TestCase
def setup
Choice.reset!
end
HELP_OUT = ''
def test_help
song = Choice::Option.new do
short '-s'
long '--song=SONG'
cast String
desc 'Your favorite GNR song.'
desc '(Defau... | true |
edd8f79199b91429a05777d041d9d72aa31784ec | Ruby | exp-ndrew/cd_organizer | /lib/cd_organizer.rb | UTF-8 | 2,264 | 2.953125 | 3 | [] | no_license | class CD
@@all_cds = {} #{CD => [Artist, Artist]}
@@all_artists = {} #{Artist => [CD, CD]}
attr_reader :cd, :artist
def initialize(album, artist)
@cd = album
@artist = artist
CD.add_cd(self)
CD.add_artist(self)
end
def CD.get_cds
@@all_cds
end
def CD.get_artists
@@all_artists... | true |
fd46f910e37042249657db81894bba389e8ac6df | Ruby | WMudgeEllis/mod_0_assessment | /variables.rb | UTF-8 | 219 | 2.796875 | 3 | [] | no_license | movie = "The Princess Bride"
is_entertaining = true
movie = "Star Wars: a New Hope"
num_4 = 4
num_6 = 6
product = num_4 * num_6
favorite_foods = ["Hashbrowns", "Pizza", "Pasta"]
favorite_foods.shift
puts movie.size
| true |
7b26bc70bf143a23506bf5d80f1b943bdc634ca0 | Ruby | josh-sea/rails-form_tag-lab-nyc-web-111918 | /app/models/student.rb | UTF-8 | 166 | 2.546875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Student < ActiveRecord::Base
def to_s
self.first_name + " " + self.last_name
end
def clear
@students = Student.all
@students.clear
end
end
| true |
762522abec91765c80116e94bddcb9bcb214ee05 | Ruby | gustavo-oo/Ruby | /URI/1180.rb | UTF-8 | 56 | 2.96875 | 3 | [] | no_license | vetor = gets.chomp.split(" ")
puts numero1
puts numero2 | true |
0fa93750ca7de419878e8be4124913eb8110bdcd | Ruby | grantkoji/ruby-oo-object-relationships-has-many-through-nyc01-seng-ft-051120 | /lib/waiter.rb | UTF-8 | 1,378 | 3.296875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class Waiter
attr_accessor :name, :years
@@all = []
def initialize(name, years)
@name = name
@years = years
save
end
def self.all
@@all
end
def save
Waiter.all << self
end
def new_meal(customer, total, tip=0)
Mea... | true |
0ff9359e51df58d0bd71d4f7c43f1f5235aa711b | Ruby | mingchai/custom-broker-CRM | /app/services/twilio_text_messenger.rb | UTF-8 | 337 | 2.578125 | 3 | [] | no_license | class TwilioTextMessenger
attr_reader :message
def initialize(message, phone_number)
@message = message
@phone_number = phone_number
end
def text_client
text = Twilio::REST::Client.new
text.messages.create({
from: ENV["TWILIO_PHONE_NUMBER"],
to: @phone_number,
body: message
... | true |
6368d8bbfe213a22137d62dd6237004b96ba1c00 | Ruby | FajgriIsai/CLASE_RUBY | /perro.rb | UTF-8 | 1,074 | 3.46875 | 3 | [] | no_license | class Perro
def initialize(raza ='chiguagua', nombre = 'firulay', hobbi = nil)
@raza = raza
@nombre = nombre
@hobbi = hobbi
end
def obtiene_raza
@raza
end
def ladra
puts'Guau Guau!!!'
end
def saludar
puts "soy un perrito de raza #{@raza} y mi nombre es #{@nombre}"
end
def hobbi
... | true |
34a61651c4e83d9876f11dd962eccc682a21e7aa | Ruby | huminya/homework | /lrthw/ex13.rb | UTF-8 | 250 | 3.171875 | 3 | [] | no_license | first, second, third = ARGV
puts "The script is called: #{$0}"
puts "The argments called is #{first}, #{second}, #{third}"
puts "Your firt variable is: #{first}"
puts "Your second variable is: #{second}"
puts "Your third variable is: #{third}" | true |
12db29ee0e4f23c36042dc53f41e038df2641f45 | Ruby | timcartwright/pricedropshop | /app/models/product.rb | UTF-8 | 1,160 | 2.828125 | 3 | [] | no_license | class Product < ActiveRecord::Base
has_attached_file :image
validates_attachment_content_type :image, content_type: ["image/jpg", "image/jpeg", "image/png", "image/gif"]
validates :title, :description, :image_file_name, presence: true
validates :quantity, :min_price, :max_price, :start_price, presence: true, ... | true |
15f2e2f85042c61a1bbac9a57446657ef2deca75 | Ruby | vdt/selenium | /selenium-core/branches/experimental/code/ruby/selenium.rb | UTF-8 | 3,129 | 2.796875 | 3 | [] | no_license | # Copyright 2004 ThoughtWorks, Inc
#
# 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 applicable law or agreed to i... | true |
bad2dd8a09611634dbc01c2acac69219188b5fb7 | Ruby | CameronHCouch/Homework | /W1D5/DIY_ADTs.rb | UTF-8 | 1,149 | 3.625 | 4 | [] | no_license | #FILO
class Stack
attr_accessor :stack
def initialize
@stack = []
end
def push(el)
self.stack = [el] + stack
end
def pop
popped = stack.first
self.stack = stack.drop(1)
popped
end
def peek
stack.first
end
end
#FIFO
class Queue
attr_accessor :queue
def initialize
@... | true |
e100d5fd505ec864dd55195f1b3903ed65f57380 | Ruby | harroyo0610/loans | /app/services/service/contract/personal_group.rb | UTF-8 | 3,108 | 2.515625 | 3 | [] | no_license | module Service
module Contract
class PersonalGroup
include ActionView::Helpers::NumberHelper
MONTHS = {
'January' => 'Enero',
'February' => 'Febrero',
'March' => 'Marzo',
'April' => 'Abril',
'May' => 'Mayo',
'June' => 'Junio',
'July' => 'Julio',... | true |
b8e420e8a6159fced4441dbd7fb18a0b28bd59dc | Ruby | Heenawter/SlenderDemake | /bitmap_to_decimal_converter.rb | UTF-8 | 448 | 2.625 | 3 | [] | no_license | lines = []
lines_reversed = []
File.readlines('bitmap').each do |line|
lines << line.to_i(2)
lines_reversed << line.reverse!.to_i(2)
end
chars = lines.each_slice(8).to_a
parsed = []
chars.each do |char|
parsed << "dc.b #{char.join(',')}"
end
chars_reversed = lines_reversed.each_slice(8).to_a
parsed_reveresed =... | true |
6bfbe17e9d0b51c7bef38b0e0e908d2adc9197ce | Ruby | moranja/Cocktailor | /db/seeds.rb | UTF-8 | 1,734 | 2.59375 | 3 | [] | no_license | require 'json'
path = Rails.root + "db/seed_files/iba_recipes.json"
Recipe.destroy_all
Ingredient.destroy_all
RecipeIngredient.destroy_all
User.destroy_all
recipes = JSON.parse(File.read(path))
recipes.each do |recipe|
new_recipe = Recipe.create(name: recipe["name"], glass_type: recipe["glass"], category: recipe[... | true |
35933157ff6b03386004d0d87c31fb6f1c1e28fe | Ruby | aileenperalta/icsbcw18 | /week2/ch07/99_bob.rb | UTF-8 | 1,037 | 3.953125 | 4 | [] | no_license | # Print out the 99 Bottles of Beer lyrics as shown here:
# http://www.99-bottles-of-beer.net/lyrics.html
#i didn't know how else to do when it equaled 2 or 1 bottle since the writing changed.
### Your Code Here ###
number = 99
while number != 2 && number != 1
puts number.to_s + ' bottles of beer on the wall, ' + n... | true |
f85492f69603680d9960e8057abdc4f886e82e21 | Ruby | strika/color-reader | /lib/page_extractor.rb | UTF-8 | 293 | 2.96875 | 3 | [] | no_license | require 'open-uri'
class PageExtractor
def initialize(url)
@doc = Nokogiri::HTML(open(url).read)
end
def text
@doc.xpath('//h1 | //p').reduce("") do |text, node|
text = text + " " + node.text
end
end
def title
@doc.xpath('/html/head/title').text
end
end
| true |
44f14cb5597d7e547bb9e2d8a8d8a353d53d5e0c | Ruby | UltimateCoder00/Codility-Challenges | /lib/Lesson 10 Prime And Composite Numbers/MinPerimeterRectangle/min_perimeter_rectangle.rb | UTF-8 | 450 | 3.421875 | 3 | [
"MIT"
] | permissive | def min_perimeter_rectangle(n)
perimeter_count(n)
end
def perimeter_count(n, count = 2 + 2*n)
for i in 2...n/2
count = 2*i + 2*divide(n, i) if small_perimeter?(count, n, i)
end
count
end
def small_perimeter?(count, a, b)
small_perimeter_condition(count, a, b) && divisible?(a, b)
end
def small_perimet... | true |
508f5347698788ec2e2b439aa32f5b84d692a851 | Ruby | mecampbellsoup/coding-puzzles | /factorial.rb | UTF-8 | 114 | 3.421875 | 3 | [] | no_license | def factorial (num)
return 1 if num <=1
num * factorial(num - 1)
end
p factorial 8736
p factorial(8736).class | true |
ec4fd050f75bcb5711bc36d4b24ebb3a492ead7f | Ruby | din982/char_maker | /app/handlers/weapon_group_proficiency_selector.rb | UTF-8 | 755 | 2.734375 | 3 | [
"MIT"
] | permissive | # -*- encoding : utf-8 -*-
class WeaponGroupProficiencySelector
attr_accessor :weapon_groups
def initialize(character)
@character = character
@statistics = character.calculate_stats_and_store_them_as_a_hash
@weapon_groups = filter_groups_for_profession.sort
end
def filter_groups_for_profession
... | true |
c5de482e1a6eecea2dee5cb5562ff7d78d358e25 | Ruby | ume-0214/rie_espresso | /Corpus.rb | UTF-8 | 1,822 | 2.828125 | 3 | [] | no_license | #!/usr/bin/ruby
require 'kconv'
#require 'CaboCha'
require 'Token'
require 'Chunk'
require 'Tree'
$KCODE = 'u'
class Corpus
# attr_accessor :corp
def initialize
@corp = []
# @c = CaboCha::Parser.new([$0] + ARGV);
end
# 解析結果をcorpに追加
def addTree(trees)
@corp.concat(trees)
end
# 与えられた文をかぼちゃで解析し、解析結果をco... | true |
16b56d26cff336ccee7d2b9ff063477ccac6e75a | Ruby | naigueldev/automated-tests-training | /app/helpers/word_in_number.rb | UTF-8 | 166 | 2.796875 | 3 | [] | no_license | # frozen_string_literal: true
require 'prime'
module Helper
class WordInNumber
def self.prime_number(number = 0)
Prime.prime?(number)
end
end
end
| true |
0343bce9fad35b6765b8d8e6b9dfa354d81d01a3 | Ruby | TomK32/The-Flying-Camera | /Placable.rb | UTF-8 | 572 | 2.90625 | 3 | [] | no_license | #
# Placable.rb
# VectorFighter
#
# Created by Thomas R. Koll on 09.12.10.
# Copyright (c) 2010 Ananasblau. All rights reserved.
#
module Placable
attr_accessor :x, :y, :z
def position(x, y, z)
self.x = x
self.y = y
self.z = z
end
def orientation
@orientation ||= 0
end
def place
... | true |
4fc1daa090e720e29f134cfaa33ab1fb5ee69d90 | Ruby | amhasler/p1 | /db/parse_collection_csv.rb | UTF-8 | 2,922 | 2.6875 | 3 | [] | no_license | require 'net/http'
require "#{Rails.root.join('db')}/utility"
module ParseCollectionCSV
def self.parse_collection(author, resources, dir)
collection_file = File.open(File.join(dir, 'collection.csv'))
# Move to beginning of the data
move_to("INFORMATION", collection_file)
# Get the collection inform... | true |
313232f2a322ad4514582ea4232615691367d21f | Ruby | AltSpace/IqTrainer | /lib/IqTrainer/api.rb | UTF-8 | 1,221 | 2.59375 | 3 | [] | no_license | require 'openssl'
require 'faraday'
module IqTrainer
class Api
def initialize(api_key,api_secret)
@api_key = api_key
@api_secret = api_secret
raise "Api key required" if @api_key.empty?
raise "Api secret required" if @api_secret.empty?
@connection = Faraday.new(url: "http://api.iq... | true |
35c2d219d6133e7199706642d3fc62dd99275288 | Ruby | roalcantara/dojo | /ruby/spec/arrays/rotate_image_spec.rb | UTF-8 | 581 | 3.171875 | 3 | [] | no_license | # frozen_string_literal: true
require 'spec_helper'
require 'arrays/rotate_image'
# You are given an n x n 2D matrix that represents an image.
# Rotate the image by 90 degrees (clockwise).
RSpec.describe Arrays::RotateImage do
let(:instance) { Arrays::RotateImage.new }
describe '#rotate' do
let(:a) do
... | true |
d1f11627ab0e4b4752f029359b9fab18d44158c7 | Ruby | cgoodmac/ruby | /labs/stoq/display_stocks.rb | UTF-8 | 1,042 | 3.15625 | 3 | [] | no_license | def display_stocks
puts `clear`
puts "Stocks Dashboard"
puts "--"
(0..(@logged_in_user.stocks.length-1)).each do |i| # looping through the array of stocks owned by the user
stock = @logged_in_user.stocks[i][:symbol].to_s # value of this key is the ticker. This needs to be converted to a string, hence the to_... | true |
c33dd3742f007534ff1c7b61f52bf529c969056f | Ruby | Mordecailloyd/Big-O-work-and-optimizations | /anagrams.rb | UTF-8 | 1,605 | 3.78125 | 4 | [] | no_license | def anagrams_bad(string1,string2)
string_array = string1.chars.permutation.to_a
return true if string_array.include?(string2.chars)
false
end
# p anagrams_bad("gizmo", "sally")
# p anagrams_bad("elvis", "lives")
def anagrams_better(string1, string2)
string2 = string2.chars
return false if string1.length !=... | true |
2e3986d165d33b125b276563bb6e1ba2015cc154 | Ruby | RORvivak/ds_dp_rec | /unique_path_d_p.rb | UTF-8 | 440 | 2.828125 | 3 | [] | no_license | # @param {Integer} m
# @param {Integer} n
# @return {Integer}
def unique_paths(m, n)
d_p = Array.new(m){ Array.new(n) { 0 } }
rec_call(m,n,0,0,d_p)
end
def rec_call(m,n,c_i,c_j,d_p)
return 0 if c_i > m -1 || c_j > n-1
return 1 if c_i == m -1 && c_j == n-1
count = 0
d_p[c_i][c_j] = re... | true |
15b38a83f8bafdd21bd984e13b687fb841a57017 | Ruby | slothbear/chosen_ailment | /app/models/ailment.rb | UTF-8 | 1,060 | 2.953125 | 3 | [] | no_license | class Ailment < ActiveRecord::Base
validates :name, :presence => true
# Select menus via Koenpunt/Chosen [1] allows user to
# select an existing Ailment or type in a new ailment name.
# * Existing ailments are represented by integers.
# * A new ailment name is passed as a string.
# * If no choice ... | true |
d1e74119207e3a39776ef1cff92cc1899e5ef6fb | Ruby | konradreiche/metadata-harvester | /spec/lib/dump_handler_spec.rb | UTF-8 | 3,874 | 2.640625 | 3 | [] | no_license | require 'spec_helper'
require 'dump_handler'
module MetadataHarvester
describe DumpHandler do
subject { DumpHandler.new }
let(:threshold) { DumpHandler.const_get(:THRESHOLD) }
# Helper method to parse the input and return the result
#
def parsed(input)
Oj.sc_parse(subject, Oj.dump(input... | true |
3151c9637afc2d8d1873481a2545bafd477c8f0c | Ruby | gabrielhicks/ruby-oo-practice-relationships-domains-nyc01-seng-ft-082420 | /app/models/airbnb/trip.rb | UTF-8 | 318 | 2.734375 | 3 | [] | no_license | class Trip
attr
@@all = []
def initialize
@@all << self
end
def self.all
# returns an array of all trips
@@all
end
def listing
# returns the listing object for the trip
end
def guest
# returns the guest object for the trip
end
end | true |
0c9e3922ccf566b4ae10eb746deb49b96c9b9b25 | Ruby | anilika/exercism | /ruby/saddle-points/saddle_points.rb | UTF-8 | 434 | 3.203125 | 3 | [
"MIT"
] | permissive | class Matrix
def initialize(matrix_str)
@matrix_str = matrix_str
end
def rows
@matrix_str.each_line.map do |line|
line.chomp.split.map(&:to_i)
end
end
def columns
rows.transpose
end
def saddle_points
columns.map(&:min).each_with_object([]) do |num, points|
rows.each_with... | true |
21abbc151794e7eecf8f1835cd43f5f394a15f98 | Ruby | imanaa/rprojects | /lib/rprojects/sudoku/cell.rb | UTF-8 | 2,494 | 3.09375 | 3 | [
"MIT"
] | permissive | module Sudoku
class Grid
private
class Cell
include Observable
attr_reader :grid, :row, :col, :cells_in_same_row, :cells_in_same_column, :cells_in_same_square, :attached_cells
def initialize(grid,row,col)
@grid = grid
@row = row
@col = col
@attached_cells =... | true |
73c2d76900d1d5a2a5e7f23cf8552951c7fd0c25 | Ruby | salvi13/Napakalaki | /P5Ruby/NapakalakiRuby/NapakalakiRuby/lib/PruebaNapakalaki.rb | UTF-8 | 5,050 | 2.734375 | 3 | [] | no_license | #encoding: utf-8
require_relative "prize"
require_relative "bad_consequence"
require_relative "monster"
require_relative "treasure_kind"
monsters = Array.new
price = Prize.new(2,1)
bc = BadConsequence.new_level_specific_treasures('Pierdes tu armadura visible y otra oculta',
0, [TreasureKind::ARMOR], [TreasureKind:... | true |
8a46bd29450691839acc534a1bedc60c47d6e0b6 | Ruby | TwP/logging | /test/layouts/test_pattern.rb | UTF-8 | 7,635 | 2.546875 | 3 | [
"MIT"
] | permissive |
require File.expand_path('../../setup', __FILE__)
module TestLogging
module TestLayouts
class TestPattern < Test::Unit::TestCase
include LoggingTestCase
def setup
super
@layout = Logging.layouts.pattern({})
@levels = Logging::LEVELS
@date_fmt = '\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}'... | true |
8bffac57b6c39b9d3913603a3723b2915b911461 | Ruby | 007mike/old_ruby_tuts | /more_stuff/boolean_regex.rb | UTF-8 | 219 | 3.484375 | 3 | [] | no_license | # boolean_regex.rb
def has_a_b?(string)
if string =~ /b/
puts "Yes, it contains a b."
else
puts "No, no b here."
end
end
has_a_b?("basketball")
has_a_b?("nightmare")
has_a_b?("johnson")
has_a_b?("jacob") | true |
92ed0d832e07cdae08295989f0cf3440f116e922 | Ruby | orohellec/drivy-challenge | /backend/level5/option.rb | UTF-8 | 245 | 2.890625 | 3 | [] | no_license | class Option
attr_reader :id, :rental_id, :type, :price
@@instances = []
def initialize(id, rental_id, type)
@id = id
@rental_id = rental_id
@type = type
@@instances << self
end
def self.all
@@instances
end
end | true |
43b06c1741cd145cbb464ac446c2529f76e54c85 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/crypto-square/5a17071373774dbb9dcf208dc8847508.rb | UTF-8 | 1,051 | 3.25 | 3 | [] | no_license | class Crypto
CIPHERTXT_SEG_LEN = 5
PADCHAR = ' '
attr_reader :plaintext
def initialize(plaintext)
@plaintext = clean(plaintext)
pad_plaintext
end
def ciphertext
ptxt_array = plaintext_segments.map {|seg| seg.chars }
ptxt_array.transpose.join.gsub(' ','')
end
def normalize_ciphertext
... | true |
a87ab313b88ff7f8064d0e8a6af3f988015b84be | Ruby | zeeshansajid/rubyonrails-practicecode | /homework2/findingprimes_2.rb | UTF-8 | 7,669 | 3 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'profile'
require 'Prime'
puts "Find all prime numbers between 2 and max number"
printf "Input max number : "
max = gets.to_i;
Prime.each(max) { |prime| p prime }
=begin
Technique used: I used the available class Prime in ruby and was able to find the list of primes in 2 lines.
Here ... | true |
4cf7d431ea0003766da11fc57d7834ef1b99569b | Ruby | LeHongDuc274/HomeWork | /a.rb | UTF-8 | 546 | 3.625 | 4 | [] | no_license | require 'cmath'
puts "Nhap tham so A:"
a = gets()
a = a.to_i
puts "Nhap tham so B:"
b = gets()
b= b.to_i
puts "Nhap tham so C:"
c = gets()
c = c.to_i
a2 = a*2
if a != 0 then
delta = (b*b) - (4*a*c)
sqrt_delta = CMath.sqrt(delta)
if delta > 0 then
x1 = (-b + sqrt_delta)/a2
x2 = (-b - sqrt_delta)/a2
... | true |
477b5e347d209371766a127a69983fee74bfa0af | Ruby | diasks2/confidential_info_redactor_lite | /spec/confidential_info_redactor_lite/extractor_spec.rb | UTF-8 | 12,330 | 2.65625 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
RSpec.describe ConfidentialInfoRedactorLite::Extractor do
let(:corpus) { ['i', 'in', 'you', 'top', 'so', 'are', 'december', 'please', 'viele', 'mitarbeiter', 'arbeitsstelle', 'some', 'there', 'king', 'by', "don't", 'dec', 'at', 'dot', 'and', 'project', 'activity', 'complete', 'prizes', 'build',... | true |
ba41521efd86016c1115c2c893927aeaa3d3c6ef | Ruby | wellcometrust/ticehurst-web | /lib/tasks/ingest_patient_notes.rake | UTF-8 | 1,433 | 2.515625 | 3 | [] | no_license | require 'csv'
namespace :patient_notes do
desc "Ingest Patient Notes from CSV files"
task ingest: :environment do
Dir.glob("#{File.dirname(__FILE__)}/../../patient-names/csv/page-*.csv") do |filepath|
CSV.foreach(filepath, headers: true) do |row|
patient_name = row['Patient Name'].strip
... | true |
ba1c1068e121ffbc7edd634ad91a08a6d671d810 | Ruby | jimytc/91-tdd-budget-service-ruby | /budget_service_test.rb | UTF-8 | 2,722 | 2.53125 | 3 | [] | no_license | # frozen_string_literal: true
require 'minitest/autorun'
require 'rr'
require 'date'
require_relative 'budget'
require_relative 'budget_repo'
require_relative 'budget_service'
require_relative 'period'
class BudgetServiceTest < Minitest::Test
def setup
super
@repo = BudgetRepo.new
@service = BudgetSer... | true |
f827e29f1a126d8137a93b976f215aabc5c56150 | Ruby | beatnikflow/phase-0-tracks | /ruby/gps2_2.rb | UTF-8 | 4,120 | 4.21875 | 4 | [] | no_license | # Method to create a list: Hash
# input: string of items separated by spaces (example: "carrots apples cereal pizza")
# define grocery_list of string of items
# use .split(' ') method to separate into multiple strings which will put it into an array.
# steps:
# put grocery items into a hash and set default quantity... | true |
b2d17ceef36c546481fb487375d86755a2bfca54 | Ruby | sxua/quine-relay | /src/test.rb | UTF-8 | 859 | 2.6875 | 3 | [
"MIT"
] | permissive | # usage:
# ruby test.rb # test all CodeGens
# ruby test.rb Perl # test only Perl CodeGen
require_relative "code-gen"
CodeGen.setup_dir("tmp")
gens = ARGV[0] ? [eval(ARGV[0])] : CodeGen::List[0..-2]
text = ARGV[1] || "Hello"
all_check = true
gens.each do |gen|
puts "test: %p" % gen
code = Class.new.cl... | true |
7dbb85d2fac70838be5863d7dde5be6d0e29fb70 | Ruby | geovanecomp/Studying | /ruby/nasa_challenge/app/helper.rb | UTF-8 | 266 | 2.84375 | 3 | [] | no_license | def is_valid_position (probe_position_x, probe_position_y, plateau_len_x, plateau_len_y)
if probe_position_x > plateau_len_x or probe_position_y > plateau_len_y
puts("The informed position is bigger than plateau size")
return false
end
return true
end
| true |
7a0854ccb8c29eaa68ed979cd2cd359511363613 | Ruby | justonemorecommit/puppet | /lib/puppet/functions/scanf.rb | UTF-8 | 1,290 | 3.359375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | # Scans a string and returns an array of one or more converted values based on the given format string.
# See the documentation of Ruby's String#scanf method for details about the supported formats (which
# are similar but not identical to the formats used in Puppet's `sprintf` function.)
#
# This function takes two ma... | true |
63f50d6445a484825da39fad94885e1521697d71 | Ruby | kaikuchn/teasy | /lib/teasy/time_with_zone.rb | UTF-8 | 6,086 | 2.671875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'tzinfo'
require 'time'
require 'forwardable'
module Teasy
# rubocop:disable Metrics/ClassLength
class TimeWithZone
extend Forwardable
include Comparable
def_delegators :time, :year, :mon, :month, :day, :hour, :min, :minute, :sec,
:usec, :nsec,... | true |
ef5b73181accf46e8b59a8c7f2859a2d54701182 | Ruby | nandayadav/smart-router | /lib/extensions/action_controller.rb | UTF-8 | 5,195 | 2.59375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require File.join(File.dirname(__FILE__), '/../route_segment_hash.rb')
module ActionController
module Routing
class << self
@url_keypair_delimiter = '_'
attr_reader :url_keypair_delimiter
end
def self.add_separator(separator)
SEPARATORS << separator unless SEPARATORS.include?(separato... | true |
8b51c92c4a8958eee21728602ca7dfde632e44e4 | Ruby | jballanc/Evolver | /lib/evolver/environment.rb | UTF-8 | 3,427 | 3.65625 | 4 | [
"MIT"
] | permissive | # Copyright (c) 2009 Joshua Ballanco
#
# class Environment
#
# Abstract: The Environment class contains the entire simulation. It is
# primarily responsible for tracking all of the organisms in the simulation,
# calculating the density dependent death probability, randomly culling
# organisms according to that probabil... | true |
fa17e994f7ea3e99bee2878487dfac1ea458095e | Ruby | maximilien-noal/SMAFightRuby | /MASWithTwoNests/bot_home.rb | UTF-8 | 1,066 | 2.78125 | 3 | [] | no_license | require 'rubygems'
$LOAD_PATH << '../'
require 'lib/point'
include Lib
$LOAD_PATH << './'
require 'agent'
require 'world'
require 'rubygame'
module MASWithTwoNests
class BotHome < Agent
attr_reader :team_id
attr_reader :resource_count
def initialize(world, team_id, color)
super(world)
@resource_count = 0... | true |
fc5baefcd26e4a4d4a8e93e089c26e420acc6221 | Ruby | jim-davis/problem-of-the-year | /node.rb | UTF-8 | 1,604 | 3.359375 | 3 | [] | no_license | # An node in an expression tree.
# The node may be a Digit or and Expression
# To enable quickly constructing trees: We identify a set of leaf nodes
# each node knows the set of all its leaves,
class Node
attr_reader :leaves, :value, :depth, :arboretum, :right_ancestors, :left_ancestors
attr_writer :arboretum
de... | true |
542198085af0b3d78b3166a2fbf3d089d3206303 | Ruby | jonsnyder01/thesis_wikipedia | /lib/candidate_label.rb | UTF-8 | 170 | 2.765625 | 3 | [] | no_license | class CandidateLabel
def initialize(tokens, string)
@tokens = tokens
@string = string
end
def to_s
@string
end
def tokens
@tokens
end
end
| true |
63edaed9cfd26ad32c5999251a13e70593bbcec8 | Ruby | nspecial/ruby_challenges | /fizzbuzz.rb | UTF-8 | 204 | 3.1875 | 3 | [] | no_license | number=1
while (number <= 100)
if (number%5 == 0 && number%3 ==0)
puts "FizzBuzz"
elsif (number%5 == 0)
puts "Buzz"
elsif (number%3 == 0)
puts "Fizz"
else
puts number
end
number += 1
end | true |
92396a9bbde2e744ed34002bba51db4a0039674a | Ruby | cpdundon/sinatra-dynamic-routes-codealong-v-000 | /app.rb | UTF-8 | 437 | 2.8125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require_relative 'config/environment'
class App < Sinatra::Base
# This is a sample static route.
get '/hello' do
"Hello World!"
end
# This is a sample dynamic route.
get "/goodbye/:name" do
@name = params[:name]
erb :goodbye
end
# Code your final two routes here:
get "/multiply/:x/:y" do
... | true |
9ad247686018a22654a46fe07c70090c35631c13 | Ruby | grosser/concern | /spec/examples/pollution.rb | UTF-8 | 433 | 2.578125 | 3 | [
"MIT"
] | permissive | $LOAD_PATH << 'lib'
require 'concern'
class A
class B < Concern
def random_method_name
end
end
concern 'a/b', :delegate => [:random_method_name]
end
class C
class D < Concern
def random_method_name2
end
end
concern 'c/d', :delegate => true
end
if Object.instance_methods.include?("random_m... | true |
8973f7494b968a1fca17a9cb2de291340b4c1241 | Ruby | marcosgz/obfusc | /lib/obfusc/commands/decrypt_command.rb | UTF-8 | 1,291 | 2.71875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'obfusc/commands/concerns/encryptor_command_base'
module Obfusc
# Perform tasks related `decrypt` command
class DecryptCommand < Obfusc::EncryptorCommandBase
# rubocop:disable MethodLength
def show_usage
usage = <<-TEXT.gsub(' ', '')
Usage:
$ ob... | true |
7d58acfb299c88dd374f9e714d04f1cabeea2513 | Ruby | TheRoyalTnetennba/coding_challenges | /project_euler/ruby/problem_2.rb | UTF-8 | 344 | 3.578125 | 4 | [] | no_license | def even_fib_sum(n)
fibs = [1, 2]
while fibs[-1] < n
fibs << fibs[-2] + fibs[-1]
end
fibs.select { |i| i < n && i.even? }.reduce(:+)
end
def even_fib_sum2(n)
fibs = [1, 2]
sum = 2
while fibs[-1] < n
next_fib = fibs[-1] + fibs[-2]
fibs << next_fib
sum += next_fib if next_fib.even? && next_... | true |
b0f0280c85fad536f1a4a61140836434bc6a7e8d | Ruby | soni17/OOP_multi_class_program | /shopping_cart.rb | UTF-8 | 1,023 | 3.8125 | 4 | [] | no_license | require './product.rb'
class Cart
def initialize()
@in_cart = []
end
def in_cart()
return @in_cart
end
def add_to_cart(prod)
@in_cart << prod
end
def remove_from_cart(prod)
@in_cart.delete(prod)
end
def total_before_tax()
total = 0
@in_cart.each do |item|
total = t... | true |
7d44d49dd8727cc8be6c1ed08f9fe199da898284 | Ruby | YuliyaYas/rails-project-mode-web-103017 | /app/models/event.rb | UTF-8 | 1,320 | 2.546875 | 3 | [] | no_license | class Event < ApplicationRecord
# has_many :event_comments
# has_many :comments, through: :event_comments
has_many :attendants
belongs_to :user
belongs_to :category
has_many :comments
validates :date, :location, :age, :capacity, :price, :name, presence: true
validate :current_or_future_date
def host
... | true |
775a590e74a92c2153ad3a22cdf44f990d430e4d | Ruby | nvella/code-folio | /2013-Ruby-rmcclib/lib/rmcclib/chunk_column.rb | UTF-8 | 1,978 | 2.671875 | 3 | [] | no_license | module RMCCLib
class ChunkColumn
attr_accessor :x, :z
def initialize x = 0, z = 0
@x = x
@z = z
@biomes = []
@block_ids = {}
@metadata = {}
@block_light = {}
@sky_light = {}
end
def get_block x, y, z
chunk_y = y / 16
chunk_rel_y = y % 16
... | true |
248012cebf9882f6ce0c4cbca6411e3305945ffc | Ruby | dnuffer/dpcode | /stack/ruby/solution.rb | UTF-8 | 482 | 3.171875 | 3 | [] | no_license | if __FILE__ == $0
exit(system "rspec #{$0}")
end
class Stack
def initialize
@head = nil
end
def push x
@head = [x, @head]
end
def empty
@head == nil
end
def pop
result = @head.first
@head = @head.last
result
end
end
require 'rspec'
describe "Stack" do
it "pushes and pops" ... | true |
0f1315ad1607b8d1f98ef4f3bd7d9c85535d5b36 | Ruby | Katerina-codes/handling_bad_input | /spec/calculator_spec.rb | UTF-8 | 455 | 3.1875 | 3 | [] | no_license | require 'calculator'
describe Calculator do
it "returns 72 if rate == 1" do
calculator = Calculator.new
expect(calculator.years_until_investment_returned(1)).to eq(72)
end
it "returns 36 if rate == 2" do
calculator = Calculator.new
expect(calculator.years_until_investment_returned(2)).to eq(36)
end
it ... | true |
3aea8fd2d64d0581eb054eda1788446fbd9bad60 | Ruby | gangelo/simple_command_dispatcher | /lib/simple_command_dispatcher/klass_transform.rb | UTF-8 | 10,794 | 3.265625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require_relative '../core_extensions/string'
module SimpleCommand
# Handles class and module transformations.
module KlassTransform
# Returns a constantized class (as a Class constant), given the klass and klass_modules.
#
# @param klass [Symbol or String] the class name.... | true |
e01df1ac93bd22d7e24dd3211859930b23aca152 | Ruby | MixMasterT/algorithm_practice | /tries.rb | UTF-8 | 2,446 | 3.546875 | 4 | [] | no_license | class TrieNode
attr_reader :val, :children, :parent
def initialize(val)
@val = val
@parent = nil
@children = {}
end
end
class Trie
attr_accessor :root
def initialize()
@root = TrieNode.new('_')
end
def find_node(char, start_node = self.root)
return start_node.children[char]... | true |
fc66f605fb96d855bbf800bb1845ddc44f8ff7e5 | Ruby | nickell75/phase-0-tracks | /ruby/problem_solving_methods.rb | UTF-8 | 882 | 4.3125 | 4 | [] | no_license | =begin
## Search
arr = [42, 89, 23, 1]
def search_arr(arr, num_value)
count = 0
arr.each do |elements|
if num_value == elements
return count
end
count += 1
end
return nil
end
p search_arr(arr, 12)
## Fibonacci
def fib(length)
arr = [0, 1]
for i in 0...length-2
arr.push... | true |
e5374325dbba157e2424ded542b77f7a41a8aba6 | Ruby | cruznunez/weather_report | /ten_day_forecast.rb | UTF-8 | 868 | 3.078125 | 3 | [] | no_license | class TenDayForecast
attr_reader :zip, :data
def initialize(zip)
@zip = zip
@data = get_data
end
private def get_data
HTTParty.get("http://api.wunderground.com/api/#{ENV['WUNDERGROUND_KEY']}/forecast10day/q/#{@zip}.json")
end
def title(period)
@data["forecast"]["txt_forecast"]["forecastda... | true |
89e3849debff72b714efa74db7a702676e5d8426 | Ruby | bmhasnah/SinatraLab | /lab01/regex_tester.rb | UTF-8 | 2,114 | 3.359375 | 3 | [] | no_license | class RegexTester
def initialize(pattern=nil)
@pattern = pattern unless pattern.nil?
end
attr_accessor :pattern
def statements=(arr)
begin
raise TypeError unless arr.class == Array
raise RuntimeError if arr.empty?
@statements = arr
rescue Run... | true |
159f7d04e64441e259d5a113bd504b9b05932d31 | Ruby | BkBky/ruby_fase0 | /dia_02/ejercicio24_saludar_usuarioString.rb | UTF-8 | 1,088 | 3.828125 | 4 | [] | no_license | #Ejercicio - Detectando la Palabra Visa
#Crea la variable payment y asígnale el valor 'Welcome, your Visa Credit Card has been processed'. Imprime "Credit Card has been Charged si la variable payment incluye la palabra Visa, para cualquier otro caso imprime "We only accept visa credit card".
payment = 'Welcome, your V... | true |
09eee81d00b0496b4bde9eeadd8b9764c37a7be0 | Ruby | elevatemedfit/ruby-collaborating-objects-lab-online-web-pt-061019 | /lib/mp3_importer.rb | UTF-8 | 327 | 2.734375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class MP3Importer
attr_accessor :path
def initialize(path)
@path = path
end
def import(list_of_filenames)
list_of_filenames.each {|filename|
Song.new_by_filename(filename)}
end
def files
Dir.entries(path).reject{|f| f=="." || f==".."}
end
def import
files.each {|f| Song.new_by_filename(f)}
en... | true |
d0463ddcbab89745741dcb4b769251b1a4895656 | Ruby | jmprocopio/ai-homework | /currency/currency.rb | UTF-8 | 1,342 | 3.78125 | 4 | [] | no_license | require './error.rb'
class Currency
def initialize(amount = 0, code="")
@amount = amount
@code = code
end
def amount
if @amount.to_s.scan(/["$"]/).join().to_s == "$"
@amount.scan(/[.0-9]/).join().to_f
elsif @amount.to_s.scan(/["€"]/).join().to_s == "€"
@amount.scan(/[.0-9]/).join().t... | true |
43d824429cf787e0be90aad0e5625535f78c627e | Ruby | rubyworks/dotruby | /lib/dotruby/dsl-old.rb | UTF-8 | 2,983 | 2.78125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"BSD-2-Clause"
] | permissive | module DotRuby
# DotRuby DSL class is used to evaluate the `.ruby` configuration file.
#
class DSL < BasicObject #Module
include ::Kernel
# Initialize new DSL instance.
#
def initialize(file)
@file = file
@@default_tags ||= {}
@@defined_tags ||= {}
@@contants ||= {}
... | true |
a2b7d9ea9868c26bca6c94ec74d6cff7e2561a91 | Ruby | satnegirji/translator | /test/models/discussion_test.rb | UTF-8 | 2,717 | 2.65625 | 3 | [] | no_license | require 'test_helper'
class DiscussionTest < ActiveSupport::TestCase
# put these into fixture
def create_default_user
User.create(email: "joe@example.com", password: "example")
end
def create_defaults(user = create_default_user)
thread1 = Discussion.create_thread( "Example", user )
thread2 = Discus... | true |
c505daec3ca1231f781bc2d603019600fe35529d | Ruby | jaelapen0/W4D2-Classwork | /Chess/pieces/bishop.rb | UTF-8 | 268 | 2.609375 | 3 | [] | no_license | require_relative "./piece.rb"
require_relative ".././slideable.rb"
class Bishop < Piece
include Slideable
def move_dirs
DIAGONAL_DIRS
end
def to_s
"♝".colorize(@color)
end
def inspect
"♝".colorize(@color)
end
end | true |
4c9b9a2017a3854b09f73f7101faa54049d51634 | Ruby | meso-unimpressed/log_syringe | /lib/log_syringe.rb | UTF-8 | 661 | 2.71875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'log_syringe/version'
require 'log_syringe/dsl'
# Top level namespace
module LogSyringe
class << self
# The logger to be passed to log_method blocks
attr_accessor :logger
# Define logging for a class/module
# @param klass [Module] The class or module to define l... | true |
1d69cdc1dae97cac207b37b8e7e46ca6793d9252 | Ruby | alhafiz90/Ruby-Projects | /xlTest/old/xlTest/test_excel.rb | UTF-8 | 4,333 | 2.59375 | 3 | [] | no_license | require 'roo'
load 'error_property.rb'
require 'date'
class TestExcel
attr_reader:error_list
attr_reader:column
def excel_read_to_find_error(config_data, expected_data,file_path)
@error_list=[]
begin
start_line=config_data['start_line'].to_i
source_name=config_data['source_file']
sou... | true |
44f54ce8798843c9991b8327b6d7d1cac6bdcee0 | Ruby | yuzixun/algorithm_exercise | /main/005-20191028.rb | UTF-8 | 533 | 4.0625 | 4 | [] | no_license | # @param {String} s
# @return {String}
def longest_palindrome(s)
size = s.size
result = ''
size.times do |i|
s1 = helper(s, i, i+1)
s2 = helper(s, i, i)
if result.size < s1.size
result = s1
end
if result.size < s2.size
result = s2
end
end
result
... | true |
66b12ba7cf1f0c3ffb96ec0816061a889aafb40e | Ruby | JSalig1/mailer | /listener.rb | UTF-8 | 1,109 | 2.640625 | 3 | [] | no_license | require 'listen'
class Listener
def initialize #(composer)
#@composer = composer
@path = ENV['0_PROJECTS']
end
def watch_folder
listener = Listen.to(@path) do |modified, added, removed|
if modified.size > 0
log(modified, "modified")
end
if added.size > 0
log(added,... | true |
3b98ae09e3e0f82353710830cf2d2bc2ad90cde3 | Ruby | rob-mcgrail/pager | /modules/monkeypatches.rb | UTF-8 | 597 | 2.5625 | 3 | [] | no_license | # Over-riding a warning about #options being deprecated.
#
# Some library is calling #options still.
# Check some time in the future that this is
# still the case.
class Sinatra::Base
def options
settings
end
end
# 1.8.7-head freaks out when it sees
# calls to #id, which is annoying because
# it's a perfectly... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.