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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
cdbc924969886f1c45ce48934ea6f4e73487511c | Ruby | DaniyarKulmanov/thinknetica | /Lesson_2/task6.rb | UTF-8 | 730 | 3.609375 | 4 | [] | no_license | products = {}
# busket = {}
loop do
puts 'Введите название товара:'
name = gets.chomp
break if name == 'стоп'
puts 'Введите цену за единицу:'
cost = gets.chomp.to_f
puts 'Введите количество купленного товара:'
count = gets.chomp.to_f
# busket[cost] = count
products[name] = { cost => count }
end
su... | true |
792cb73344cbfbadacb18b5a5b22fa96206676ba | Ruby | alexeyeva/katas | /perfect_power.rb | UTF-8 | 302 | 2.984375 | 3 | [] | no_license | n = gets.to_i
# def existing_a(n, b)
# end
def isPP(n)
for b in 2..(Math.log2(n) + 1) do
a = n ** (b ** -1)
a.floor.to_i ** b == n ? a = a.foor.to_i : a = a.ceil.to_i
return [a, b] if a ** b == n
break if b == (Math.log2(n) + 1).to_i
b +=1
end
end
puts isPP(n) | true |
d39d56585f8018c31eaa1385a862c6c9c34bda17 | Ruby | ncbo/ncbo_ontology_recommender | /test/evaluators/test_detail_evaluator.rb | UTF-8 | 2,053 | 2.53125 | 3 | [
"BSD-2-Clause"
] | permissive | require_relative '../test_case'
require_relative '../../lib/ncbo_ontology_recommender/evaluators/detail_evaluator'
require_relative '../../lib/ncbo_ontology_recommender/helpers/general_helper'
class TestSpecializationEvaluator < TestCase
def self.before_suite
top_defs = OntologyRecommender.settings.top_defs
... | true |
78fcefadc8f3dc12b1786c284ae0c467f74fa7f6 | Ruby | Batou99/mongo_ticckle | /models/static_collection.rb | UTF-8 | 4,674 | 2.9375 | 3 | [] | no_license | class StaticCollection
class Item
def self.name
@name
end
def self.id
@id
end
def self.eql?(other_item)
other_item.superclass.__id__ == self.superclass.__id__ and other_item.id == self.id
end
def self.==(other_item)
self.eql? other_item
end
def self.hash
... | true |
ee308374ab06b832250b1bdcf6bb50c59dc3aca7 | Ruby | wehttamclan/star_party | /app/models/party_search_result.rb | UTF-8 | 358 | 2.75 | 3 | [] | no_license | class PartySearchResult
def initialize(zip_code)
@zip_code = zip_code
end
def parties
@parties ||= (Party.where('date >= ?', Date.today).near(@zip_code, 15)).to_a
exact_zip = (Party.where('zip_code = ? AND date >= ?', @zip_code, Date.today)).to_a
exact_zip.each do |party|
@parties << party... | true |
3b505d70e6ff17d5502acd72a245b6f1fd7aa2e8 | Ruby | kalgibhatt-btc/ruby_exercise | /gigasecond/gigasecond.rb | UTF-8 | 78 | 2.5625 | 3 | [] | no_license | class Gigasecond
def self.from(time)
return (time+1000000000)
end
end
| true |
949f752712412d9c90915abf5c5cfd4111d58c38 | Ruby | saouddk/CommunityBase | /app/models/question.rb | UTF-8 | 1,151 | 2.765625 | 3 | [] | no_license | class Question < ActiveRecord::Base
has_many :answers
before_create :generate_keywords
def as_json(options={})
#Initialize with default values
number_of_answers = 0
number_of_upvotes_for_top_answer = 'No Answers Yet'
if self.answers.count > 0
#If our question has answers, set variables ac... | true |
5230b902a95dbde06c4741b6669c411c97e68b71 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/roman-numerals/2d0e59256faf4c8d92640d2d4fc59204.rb | UTF-8 | 936 | 3.53125 | 4 | [] | no_license | class Fixnum
def to_roman
roman = ''
roman << char_n_times('M', self / 1000)
rest = self % 1000
if rest / 100 == 9
roman << 'CM'
rest -= 900
end
roman << char_n_times('D', rest / 500)
rest = rest % 500
if rest / 100 == 4
roman << 'CD'
rest -= 400
end
... | true |
397da761d4f259ed2d63f2b7e9f25333a752e3cc | Ruby | jermspeaks/Personal-Media-Project | /Movies/combine_db.rb | UTF-8 | 1,341 | 3.5625 | 4 | [] | no_license | require 'csv'
db_file = "./watched-movies.csv"
other_db_file = "./new-watched-movies.csv"
new_db_file = "./new-sample.csv"
movie_array = []
# Movie Object
class Movie
attr_accessor :title, :imdb_link, :date
def initialize(args = {})
@title = args['movie_title']
@imdb_link = args['imdb_link']
@date = a... | true |
67739a7ce5f393709e35e22cc60d694dd2afd9d7 | Ruby | IlyaMur/ruby_learning | /Simdyanov_exercises/Chapter 7/1.rb | UTF-8 | 360 | 3.125 | 3 | [] | no_license | Monday = 'Понедельник'
Tuesday = 'Вторник'
Wednesday = 'Среда'
Thursday = 'Четверг'
Friday = 'Пятница'
Saturday = 'Суббота'
Sunday = 'Воскресенье'
WEEK = []
WEEK << Monday
WEEK << Tuesday
WEEK << Wednesday
WEEK << Thursday
WEEK << Friday
WEEK << Saturday
WEEK << Sunday
puts WEEK.to_s | true |
3a39ef9f7a614871e376cbd1f3041a2d69487d11 | Ruby | add2point71dots/exercism-exercises | /ruby/series/series.rb | UTF-8 | 260 | 3.390625 | 3 | [] | no_license | class Series
attr_reader :series
def initialize(series)
@series = series
end
def slices(num)
raise ArgumentError.new("Slice cannot be > series length") if num > series.length
(0..series.length-num).map { |n| series[n...n+num] }
end
end
| true |
081b0c91684283930d76509bc4b3d55c0cf33642 | Ruby | mattmcquinn/dg-scorecard | /db/seeds.rb | UTF-8 | 1,173 | 3.046875 | 3 | [] | no_license | # Create a user
user = User.create(name: Faker::Name.name,
email: Faker::Internet.email,
password: "password",
password_confirmation: "password")
User.create(name: "Matthew McQuinn",
email: "mmcquinn77@gmail.com",
password: "password",
... | true |
9ab654f6f8087bee4b07c6e8340e3bf59d667299 | Ruby | darthjee/danica | /spec/support/shared_examples/operator/single_input.rb | UTF-8 | 1,855 | 2.71875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
shared_examples 'a operator with a single input value' do |arguments|
include_context 'when variables are initialized', arguments, 'variable_value', 'expected_number', 'expected_tex', 'expected_number_tex', 'expected_gnu', 'expected_number_gnu'
subject { described_class.new(variable) ... | true |
9c4918706bbb704d4a13aa6c1700a5e937bc23ef | Ruby | HMoreira2020/sinatra-mvc-lab-onl01-seng-pt-032320 | /models/piglatinizer.rb | UTF-8 | 716 | 3.65625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class PigLatinizer
attr_reader :words
def piglatinize(words)
words_arr = words.split()
words_arr.collect do |word|
if word.downcase.start_with?("a","e","i","o","u")
vowels(word)
elsif !word.downcase.start_with?("a","e","i","o","u")
c... | true |
4349c8812b5f25294d25130143b3b233eebaf7e5 | Ruby | samimehadji/DEVOIR-A-RENDRE-RUBY | /exo13.rb | UTF-8 | 183 | 3.28125 | 3 | [] | no_license | i = 1
email_list = Array.new()
while (i <= 50)
if (i < 10)
email = "jean.dupont.0#{i}@email.fr"
else
email = "jean.dupont.#{i}@email.fr"
end
email_list.push(email)
i = i +1
end
puts email_list | true |
28d0e273c03c4bc8d579d95a812920407e732817 | Ruby | emcooper/Not-Here-to-Make-Friends | /db/seeds/permanent_data.rb | UTF-8 | 4,871 | 2.640625 | 3 | [] | no_license | # creates plays and qualities that will exist as permanent unchanging data
require 'database_cleaner'
DatabaseCleaner.strategy = :truncation
DatabaseCleaner.clean
bachelor_plays = {
"show_milestones" => {"Rose Ceremony Rose" => 10,
"Group Date Rose" => 20,
"First Impression ... | true |
864978fe071c26c85b81e27435076fb21b430a19 | Ruby | chirdeepshetty/Social-Media-Browser | /app/gateway/youtube.rb | UTF-8 | 934 | 2.609375 | 3 | [] | no_license | require 'cgi'
module Gateway
class Youtube
DEVELOPER_KEY = "AI39si7JjLiwreKlHp_skHcs9RM2TwXiTSopdRCD8u6mhBmtwrwa06ccpnDWuBbpypciqfOVA6pV1RuTqfqtazjIbiKeODlpfg"
GDATA_URL = "http://gdata.youtube.com/feeds/api/videos/"
def initialize
@client = GData::Client::YouTube.new
... | true |
8116486d1e7395af01465ee1f5d87e37e73d62ef | Ruby | pezcalona/Modulo6_Ruby | /ejercicio3/metodos.rb | UTF-8 | 562 | 4.15625 | 4 | [] | no_license | # def dividir_entre_digitos(numeros)
# resultado = numeros.each do |n|
# n / n.to_slength
# end
# end
# print dividir_entre_digitos([5,2,3,6,4,9,7])
#Definir un método que pueda generar un arreglo de 10 posiciones con números de forma aleatoria entre el 0..100
#ejercicio Banco
def multiplos5(numeros... | true |
959c04f21dc4f3b1b7b7ab9da9284eec98de7ac4 | Ruby | NachoPal/trading | /app/models/market_service/monitorize.rb | UTF-8 | 1,931 | 2.75 | 3 | [] | no_license | require 'array_stats'
module MarketService
class Monitorize
def fire!
result = {}
markets = Bittrex.client.get('public/getmarketsummaries')
result[:markets] = exclude(markets)
result[:percentile_volume] = calculate_volume_percentile(result[:markets])
result[:cache_population_fi... | true |
692bef12126c817b685d522a0ab4c1fd23f1c8eb | Ruby | randrews/urlshort | /app/controllers/api_controller.rb | UTF-8 | 1,381 | 2.578125 | 3 | [] | no_license | class ApiController < ApplicationController
before_action :find_link, only: [:delete, :update]
def create
url = get_url
# Finally we have a URL! Let's make a link
# (or return one that already exists)
link = Link.find_or_create_by!(url: url)
render json: { hash: link.code }
rescue => err
... | true |
54a8061805cf7c33d3d94292d81125b71d199f26 | Ruby | NikolayStoyanov87/oyster_cards | /lib/oystercard.rb | UTF-8 | 946 | 3.109375 | 3 | [] | no_license | # Oystercard
class Oystercard
attr_reader :balance, :entry_station, :journeys
DEFAULT_MAXIMUM_AMOUNT = 90
DEFAULT_MINIMUM_AMOUNT = 1
def initialize
@balance = 0
@max_amount = DEFAULT_MAXIMUM_AMOUNT
@min_amount = DEFAULT_MINIMUM_AMOUNT
@entry_station = nil
@journeys = []
end
def top_up(... | true |
191b958d19ca16bd2d0f5fbd47d8c6551011f504 | Ruby | lucyconklin/international_space_station | /app/models/reminder.rb | UTF-8 | 801 | 2.53125 | 3 | [] | no_license | class Reminder < ApplicationRecord
validates :timestamp, presence: true
validates :phone_number, presence: true
after_create :reminder
@@REMINDER_TIME = 5.minutes
def reminder
@twilio_number = ENV['TWILIO_NUMBER']
@client = Twilio::REST::Client.new ENV['TWILIO_ACCOUNT_SID'], ENV['TWILIO_AUTH_TOKEN'... | true |
6203d0669c30048d14e6610cce6012b777d36cc2 | Ruby | mrphishxxx/revily | /app/models/incident/assignment.rb | UTF-8 | 2,254 | 2.625 | 3 | [
"MIT"
] | permissive | class Incident::Assignment
include Revily::Model
# @!attribute [rw] incident
# @return [Incident] The incident for assignment
attribute :incident, type: Object
# !@group Validations
validate :ensure_service
validate :ensure_policy
validate :ensure_policy_rules
validate :loop_limit_not_reached
# ... | true |
4e884b52cf7685225f4af86a09efa0743dffa1f1 | Ruby | ishibashi-futos/learn-ruby | /section04/4.8.6/sample.rb | UTF-8 | 170 | 3.03125 | 3 | [] | no_license |
# Blocks will automatically be discarded (It's like 'using' in C#?)
File.open('./sample.txt', 'w') do |file|
file.puts("Hello, World!")
file.puts("Hello, Ruby!")
end | true |
006089f9ee0c52d05c9c8fe4f93ddcb4a1275bd2 | Ruby | zendesk/mail | /spec/mail/multibyte_spec.rb | UTF-8 | 385 | 2.515625 | 3 | [
"MIT"
] | permissive | # encoding: utf-8
require 'spec_helper'
describe "multibyte/chars" do
Chars = Mail::Multibyte::Chars
it "should upcase" do
chars = Chars.new('Laurent, où sont les tests ?')
expect(chars.upcase).to eq("LAURENT, OÙ SONT LES TESTS ?")
end
it "should downcase" do
chars = Chars.new('VĚDA A VÝZKUM')
... | true |
e19bbb4d6a3c29ae61c87bb1e42fc691002100b7 | Ruby | CinnaBomb/mastermind-sinatra | /game.rb | UTF-8 | 871 | 2.75 | 3 | [] | no_license | require 'sinatra'
require 'sinatra/reloader' if development?
require './mastermind'
p = PlayerGame.new
get '/' do
code = p.code
puts code
guesses_left = p.max_guess_count - p.guess_count
if !params['guess'].nil?
guess = params['guess'].downcase.chomp.split(" ")
if p.valid_guess(guess)
gam... | true |
233e3b96d744c7092d4a24ffc770092b31c3bd44 | Ruby | cruth544/boggle_solver | /boggle_solver/boggle_char.rb | UTF-8 | 180 | 2.90625 | 3 | [] | no_license | class Boggle_Char
attr_accessor :char
attr_accessor :used
def initialize char
self.char = char.downcase
self.used = false
end
def to_s
self.char
end
end
| true |
41f02c9f4c52fb94b4e98add883dacb980d43007 | Ruby | ForSetGeorgia/StoryBuilder | /app/models/language.rb | UTF-8 | 3,105 | 2.640625 | 3 | [] | no_license | class Language < ActiveRecord::Base
validates :locale, :presence => true
validates :name, :presence => true
has_many :stories, :primary_key => :locale, :foreign_key => :story_locale
attr_accessor :percent
# default_scope { where(locale:['az','en','hy','ka','ru']) }
def self.sorted
order('name asc... | true |
299f2423a1e878d868223e2f42a881d1708b7dd9 | Ruby | alexaltair/coding-challenges | /bottles_and_kegs.rb | UTF-8 | 2,465 | 3.609375 | 4 | [] | no_license | module Model
CONDITIONS = [
lambda {|number, turn_number| turn_number % number == 0},
lambda do |number, turn_number|
digits = turn_number.to_s.split('')
digits.include?(number.to_s)
end,
lambda do |number,... | true |
6de2722c9fe4cd5590942a622d2bb216ce636d6f | Ruby | edanaher/advent-solutions | /7/sol.7a.pretty.rb | UTF-8 | 1,185 | 3.453125 | 3 | [] | no_license | #!/usr/bin/env ruby
gates = STDIN.each_line.map do |s|
parts = s.split(" ")
if parts[0] == "NOT"
next [parts[3], "NOT", parts[1]]
elsif parts[1] == "->"
next [parts[2], "GET", parts[0]]
end
[parts[4], parts[1], parts[0], parts[2]]
end
values = {}
# Annoyingly, locals aren't available inside function... | true |
3152644597d6f0211e2fb1b3e0c01780a138dc88 | Ruby | arssy/hcipher | /lib/hcipher/cipher.rb | UTF-8 | 4,175 | 3.515625 | 4 | [
"MIT"
] | permissive | module Hcipher
class Cipher
# define characters here
# below is default defined characters
CHARS = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789,.:;?/\\'\"()<>[]{}|`~!@#$%^&*-_=+".split("").freeze
# generate key
# only integer is allowed as parameter
# sending n as paramete... | true |
f33fb087e3ca4812423939f0c08d9f9408921ba6 | Ruby | nzmshaik7/ft | /app/helpers/customers_helper.rb | UTF-8 | 941 | 2.765625 | 3 | [] | no_license | module CustomersHelper
# A customer may or may not be a User. Try Customer field
# first, then try User.
def customerName2(cust)
return '' if cust.nil?
if cust.first_name and cust.first_name.length > 1
return cust.first_name + ' ' + cust.last_name
elsif cust.user
... | true |
890be1be64aae77980b91d6afbc987d52ca45588 | Ruby | itsolutionscorp/AutoStyle-Clustering | /assignments/ruby/hamming/src/489.rb | UTF-8 | 220 | 2.796875 | 3 | [] | no_license | def compute(strandA,strandB)
if strandA.length != strandB.length
end
compares = 0
for i in 0..strandA.length
if strandA.getbyte(i) != strandB.getbyte(i) then
compares+=1
end
end
return compares
end | true |
3928f2b78b11fa9fe4630f3e03c971087a308786 | Ruby | gjanee/advent-of-code-2020 | /21.rb | UTF-8 | 4,022 | 3.796875 | 4 | [] | no_license | # --- Day 21: Allergen Assessment ---
#
# You reach the train's last stop and the closest you can get to your
# vacation island without getting wet. There aren't even any boats
# here, but nothing can stop you now: you build a raft. You just need
# a few days' worth of food for your journey.
#
# You don't speak the l... | true |
cfaf956302e8f6f1255961f7e0150a3529182dd3 | Ruby | cielavenir/procon | /codeforces/tyama_codeforces633A.rb | UTF-8 | 284 | 3.15625 | 3 | [
"0BSD"
] | permissive | #!/usr/bin/ruby
def egcd(x,y)
return [x,1,0] if y==0
g,a,b=egcd(y,x%y)
[g,b,a-x/y*b]
end
a,b,c=gets.split.map(&:to_i)
g=a.gcd(b)
if c%g!=0
puts :No
else
a/=g
b/=g
c/=g
_,z1,z2=egcd(a,b)
n=[a,b].max+c
puts (-n..n).find{|i|z1*c+b*i>=0 && z2*c-a*i>=0} ? :Yes : :No
end | true |
112051fd97dec371381653bbedd6c80b223750cf | Ruby | cloudaffair/subtitle | /lib/utils/cue_info.rb | UTF-8 | 656 | 3 | 3 | [
"MIT"
] | permissive | class CueInfo
def initialize(type)
@type = type
@start = @end = @sequence = nil
@message = ""
@start_time_units = []
@end_time_units = []
@index = 1
end
attr_reader :type, :start, :end, :sequence, :message, :start_time_units, :end_time_units, :index
def start=(start)
@start = start... | true |
0f557f3d164c804d13af26746990b863a55627a4 | Ruby | benaclarkson/Ruby_Challenges | /Easy_Challenges/perfect_numbers.rb | UTF-8 | 1,647 | 4.6875 | 5 | [] | no_license | # Perfect Number
# The Greek mathematician Nicomachus devised a classification scheme for natural numbers (1, 2, 3, ...), identifying each as belonging uniquely to the categories of abundant, perfect, or deficient based on a comparison between the number and the sum of its positive divisors (the numbers that can be eve... | true |
d2cc253b03197d4082e6fa02516c42e2bdfbaf5d | Ruby | notCalle/workflow-tools | /git-hooks/enforce-workflow/workflow_enforcer.rb | UTF-8 | 10,521 | 2.640625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require 'rugged'
require 'gpgme'
require 'yaml'
class WorkflowEnforcer
# :call-seq:
# WorkflowEnforcer.new [<option>: true, ...]
#
# Create a new WorkflowEnforcer object, modifying its behaviour
# according to the supplied options.
#
# Recognized options are:
#
# [+ignore_collabo... | true |
ed4e941839ad67e753d0a8f0447f1f795e2402e9 | Ruby | dockit0/Ruby_Basics | /Strings/strings7.rb | UTF-8 | 236 | 4.0625 | 4 | [] | no_license | # Given the following code, invoke a destructive method on greeting so that Goodbye! is printed instead
# of Hello!.
greeting = 'Hello!'
puts greeting
# answer:
greeting = 'Hello!'
greeting.gsub!('Hello', 'Goodbye')
puts greeting | true |
fcffa9870109cc73da0257f56d0de120d4c53fb6 | Ruby | memcmahon/market_st_apartments_1911 | /lib/building.rb | UTF-8 | 1,317 | 3.203125 | 3 | [] | no_license | class Building
attr_reader :units
def initialize
@units = []
# @occupied_units = nil
end
def add_unit(apartment)
# @units << apartment
@units.push(apartment)
end
def average_rent
return "No Units in this Building" if @units.empty?
# total = 0
# @units.each do |unit|
# t... | true |
124b4a4f4260e9fa7bf89ded221bc7d55cae5668 | Ruby | rikai/ShowGap | /app/models/ability.rb | UTF-8 | 1,668 | 2.625 | 3 | [
"MIT"
] | permissive | class Ability
include CanCan::Ability
def initialize(user)
user ||= User.new # guest user (not logged in)
if user.admin?
can :manage, :all
elsif user.host?
can :read, :all
can :manage, [Episode, Discussion, Reply]
elsif user.listener?
can :read, :all
can [:create, :vo... | true |
b010614d2ee91c810fbc8ca2a4b0c7ddb0bf5f41 | Ruby | sashafklein/meatup | /lib/animal_bundler.rb | UTF-8 | 634 | 2.625 | 3 | [] | no_license | class AnimalBundler
attr_reader :animal
delegate :purchasers, :packages, :lines, :available_cuts, :sold_out_cuts, :sold_cuts, to: :animal
def initialize(animal)
@animal = animal
end
def labels_by_cut
bundle_array = []
sold_cuts.each do |rc|
rc.lines.group_by{ |l| l.notes }.each do |lin... | true |
3403e5a4b98cfc2726b6a2f4db7718b78135b4e6 | Ruby | Lucx14/Exercism-Ruby | /sum-of-multiples/sum_of_multiples.rb | UTF-8 | 444 | 3.765625 | 4 | [] | no_license | class SumOfMultiples
attr_reader :divisors
def initialize(*divisors)
@divisors = divisors
end
def to(n)
multiples = []
numbers = build_array(n)
numbers.each do |num|
divisors.each { |divisor| multiples << num if num % divisor == 0 }
end
multiples.uniq.sum
end
private
de... | true |
06284e51ce29dc238239f72204d2a10759fb565f | Ruby | GTDev87/LikeHive | /app/models/users/user_container.rb | UTF-8 | 207 | 2.875 | 3 | [] | no_license | class UserContainer
def initialize(user_list)
@user_list = user_list
end
def accept_user_visitor(user_visitor)
@user_list.each do |user|
user_visitor.visit_user(user)
end
end
end | true |
2e846cba9f35e97ab7b8e8584ab7671d0039b606 | Ruby | eiphyllis/ruby-oo-relationships-practice-art-gallery-exercise-hou01-seng-ft-042020 | /app/models/artist.rb | UTF-8 | 966 | 3.34375 | 3 | [] | no_license | class Artist
@@all = []
attr_reader :name, :years_experience
def initialize(name, years_experience)
@name = name
@years_experience = years_experience
self.class.all << self
end
def self.all
@@all
end
def paintings
Painting.all.select {|painting| painting.artist == self }
end
... | true |
9affcb11bc4c015a135cfdb8b921662d5b4f66bc | Ruby | shotasan/RubyPractices | /practice_ruby No.71~No.80.rb | UTF-8 | 15,532 | 4.34375 | 4 | [] | no_license | # No.71
# You need to write regex that will validate a password to make sure it meets the following criteria:
# At least six characters long
# contains a lowercase letter
# contains an uppercase letter
# contains a number
# Valid passwords will only be alphanumeric characters.
# Example:
# (regex=~'fjd3IR9')==0, true
#... | true |
db2f856095c0e0500f36faf91c4911fdb59f8740 | Ruby | florentlienard/florentlienard | /reboot/christmas-list/method.rb | UTF-8 | 912 | 3.640625 | 4 | [] | no_license | require 'csv'
def display_list(array)
puts
puts "My giftlist:"
array.each_with_index do |gift, index|
check = gift[:bought] ? "X" : " "
puts "#{index + 1} - #{gift[:name]} [#{check}]"
end
puts
end
def get_number
puts "which item do you want to delete?"
# => delete the item from giftlist
... | true |
17ca4254755341fdedfb0d03ad4f036bf65626e3 | Ruby | Viacheslav-Korytov/GPS_distance_exercise | /app/customers_within_100km_Dublin.rb | UTF-8 | 631 | 2.71875 | 3 | [] | no_license | #!/usr/bin/env ruby
#############################################################################
#
# Usage: ruby customer_within_100km_Dublin [input_file|'data/gistfile1.txt']
#
# slvkorytov@gmail.com
#############################################################################
require_relative '../lib/cust... | true |
3fb2a50b6aff2488b7f0cd9b6de6b6b8cd611ffb | Ruby | burkhart-andrew/Launch_School | /101/lesson_3/med_1.rb | UTF-8 | 519 | 3.9375 | 4 | [] | no_license | 1.
10.times {|n| puts (" " * number) + "The Flintstones Rock!"}
The Flintstones Rock!
2.
statement = "The Flintstones Rock"
result = {}
letters = ('A'..'Z').to_a + ('a'..'z').to_a
letters.each do |letter|
letter_frequency = statement.scan(letter).count
result[letter] = letter_frequency if letter_frequency >... | true |
c15185511d1ddc0a92c498b9407e1c8bb20a3c96 | Ruby | teachermugabo/saas-class | /hw1-part1.rb | UTF-8 | 246 | 3.375 | 3 | [] | no_license | def palindrome?(string)
prep_str(string) == prep_str(string).reverse
end
def prep_str(string)
string.gsub(/[\W]/,"").downcase
end
def count_words(string)
freq = Hash.new(0)
string.scan(/\b\w+\b/) {|m| freq[m.downcase] += 1}
return freq
end
| true |
19fc083f7d24a0aefa3a7a2fe662ecdbdd461fc0 | Ruby | tannerwelsh/code-training | /ruby/Learn to Program/ask.rb | UTF-8 | 472 | 3.328125 | 3 | [
"MIT"
] | permissive | def ask question
while true
puts question
reply = gets.chomp.downcase
if (reply == 'yes' || reply == 'no')
if reply == 'yes'
return true
else
return false
end
else
puts 'Please answer "yes" or "no".'
end
end
end
puts 'Hello, and thank you for...'
put... | true |
2384eaedc7766aa06144edeb3540cd080698439b | Ruby | mrstebo/slack-message-animator | /lib/animations/pokemon_theme_song_lyrics_animation.rb | UTF-8 | 2,247 | 3.046875 | 3 | [
"MIT"
] | permissive | class PokemonThemeSongLyricsAnimation
def ask_questions
end
def frames
animation = []
animation.push(create_frame(4, start_gif))
lyrics.each_with_index do |lyric, index|
animation.push(create_frame(2, "#{notes} #{lyric} #{notes}", index > 0))
end
animation.push(create_frame(0.2, "#{meta... | true |
d1a6c79d9ba19446390e3f116ee19c03e3990aa8 | Ruby | cmacaulay/interview | /xor_strings.rb | UTF-8 | 414 | 3.109375 | 3 | [] | no_license | def xor_strings a, b
(a.to_i(16) ^ b.to_i(16)).to_s 16
end
{
%w{1c0111001f010100061a024b53535009181c 686974207468652062756c6c277320657965} =>
'746865206b696420646f6e277420706c6179'
}.each do |(in_a, in_b), output|
result = xor_strings in_a, in_b
if result == output
puts "pass"
else
puts "fail"
... | true |
abb4e3faa2aa5f50e4cfa02781e29fed01c58304 | Ruby | matao0214/Demo | /0919.rb | UTF-8 | 46 | 2.65625 | 3 | [] | no_license | n=gets.to_i
a=[*"A".."E"].reverse
puts a[n-1]
| true |
efbc22ace7ea12dbf9782597cdb07c3814a0743f | Ruby | raphyduck/media_librarian | /lib/library_bus.rb | UTF-8 | 1,696 | 2.59375 | 3 | [
"MIT"
] | permissive | class LibraryBus
@buses = {}
def self.bus_get(thread = Thread.current, omni = 0)
t = thread
while t[:parent] && (t[:parent][:base_thread].nil? || omni > 0)
t = t[:parent]
end
t
end
def self.bus_id(thread = Thread.current)
bus_get(thread)[:jid].to_s == '' ? 'nodaemon' : bus_get(threa... | true |
e31162794600774b68e7259fc6ddfd1e5dcd55aa | Ruby | luisfta17/El_Refugio | /controllers/user_controller.rb | UTF-8 | 1,550 | 2.53125 | 3 | [] | no_license | require('sinatra')
require('sinatra/contrib/all')
require('pry-byebug')
require_relative('../models/adopted_animal')
require_relative('../models/animal')
require_relative('../models/owner')
require_relative('../models/type_of_animal')
require_relative('../models/user')
require_relative('../models/request')
# USER SID... | true |
d52bd15fe7a3468b5f443d8a9d8b836db4cd95b6 | Ruby | threefunkymonkeys/shop_list | /spec/models/list_spec.rb | UTF-8 | 1,810 | 2.6875 | 3 | [] | no_license | require File.expand_path('../../spec_helper', __FILE__)
describe List do
it "should have a name" do
list = List.new
list.should_not be_valid
list.name = "Groceries"
list.should be_valid
end
it "should have a total of zero if is has no items" do
list = List.new
list.total.should == 0
e... | true |
ab628d1106f5aba016b91f1da736bd5d1fb473fb | Ruby | PayamBen/projectEuler | /ruby/pe-problem17/NumLetterCnt.rb | UTF-8 | 1,690 | 3.828125 | 4 | [] | no_license | #NumLetterCnt.rb
# problem 17 - project euler
# If all the numbers from 1 to 1000 (one thousand) inclusive were written
# out in words, how many letters would be used?
# created by payam behjat
#
def numTranslate(val)
#0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19
letterCntLwr = [0,3,3,5,4,4,3,5,5,4, 3, ... | true |
4fcf93f5eca3918665524772bfcc41b7c4e4a73c | Ruby | connorryanbaker/tcp_sockets | /basic_server/2.rb | UTF-8 | 1,181 | 2.921875 | 3 | [] | no_license | require 'socket'
# Server Lifecycle
# 1. create
# 2. bind
# 3. listen
# 4. accept
# 5. close
# bind?
# We bind a socket to a port where it will listen for connections
# create new socket, ruby allows these symbols instead of
# Socket::AF_INET and Socket::SOCK_STREAM
# socket = Socket.new(:INET, :STREAM)
# create a... | true |
4d04ff1b3ac76c0b75a9990582b9346892dc7e58 | Ruby | mgm702/RSpec-Practice | /methods_and_flow_control/string_practice.rb | UTF-8 | 340 | 3.953125 | 4 | [] | no_license | #!/usr/bin/env ruby
string_var = 'this is a string to practice with'
puts string_var
puts string_var.capitalize
puts string_var.upcase
puts string_var.gsub('string', "'string'").capitalize
puts "The string '#{string_var}' has #{string_var.length} characters"
puts string_var.reverse
puts string_var.replace('practice p... | true |
e821c05ee86ea97343d2cfbe992f332d1bbbbecb | Ruby | davidjlopez19/image_blur_challenges | /image_blur3.rb | UTF-8 | 1,527 | 3.890625 | 4 | [] | no_license | class Image
attr_accessor :picture
def initialize(image)
@image = image
end
def get_location_of_ones
#store addresses of 1s in array
locations = []
@image.each_with_index do |row, image_index|
row.each_with_index do |item, row_index|
if item == 1
... | true |
52c8f0efe3137013e2c446aab5568942abcc8740 | Ruby | jamesoddy8/advent_of_code | /day_2/task2.rb | UTF-8 | 1,861 | 3.703125 | 4 | [] | no_license | class PasswordFile
def initialize(file_path)
@file = File.open(file_path, "r")
end
def lines
unless @lines
@lines = []
@file.each_line { |line| @lines << PasswordLine.new(line.chomp) }
end
@lines
end
end
class PasswordLine
def initialize(line)
# split the entire line into sep... | true |
293d580d96ca374d5d2bacd87fed6335c2570f48 | Ruby | DEFRA/waste-exemptions-front-office | /app/models/stats/stats_formatter.rb | UTF-8 | 1,022 | 2.53125 | 3 | [
"OGL-UK-3.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # frozen_string_literal: true
module Stats
class StatsFormatter
def initialize
# test this by creating some registrations and checking output
@current_reg = retrieve_reg(from: 7, to: 1)
@previous_reg = retrieve_reg(from: 14, to: 8)
end
def json
new_reg = NewRegistrations.new(@cur... | true |
0c4d22d1aaf12c53b2169df429ed28dc3dc22f18 | Ruby | RamseyNjire/tic-tac-toe | /lib/player.rb | UTF-8 | 169 | 2.8125 | 3 | [] | no_license | class Player
attr_reader :symbol, :name
def initialize(player_details)
@name = player_details.fetch(:name)
@symbol = player_details.fetch(:symbol)
end
end
| true |
56d1eff2631f2daed9a5c4c348e5ccc62ac4728d | Ruby | Chewie23/sturdy-train | /Battleship/Tests/test_grid.rb | UTF-8 | 3,784 | 3.109375 | 3 | [] | no_license | require "../grid_coordinates.rb"
require "../grid.rb"
require "../ship.rb"
require "test/unit"
class TestGrid < Test::Unit::TestCase
def test_constructor
my_grid = Grid.new 5
expected_size = 5
assert_equal(expected_size, my_grid.size)
assert_equal(5, my_grid.row_num_for_alp... | true |
74e81911a4dcbc1fb4a6dc235c545f867d48161a | Ruby | Eric-Guo/wechat | /lib/wechat/cipher.rb | UTF-8 | 1,672 | 2.640625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Wechat
module Cipher
BLOCK_SIZE = 32
CIPHER = 'AES-256-CBC'
def encrypt(plain, encoding_aes_key)
cipher = OpenSSL::Cipher.new(CIPHER)
cipher.encrypt
cipher.padding = 0
key_data = Base64.decode64("#{encoding_aes_key}=")
cipher.key = key_... | true |
02ca8b34bef6150e638af7ccba49799116b33c7a | Ruby | hectorcorrea/binary-tree | /test/tc_height.rb | UTF-8 | 832 | 2.921875 | 3 | [] | no_license | $: << File.expand_path(File.dirname(__FILE__) + "/../lib")
require "test/unit"
require "binarytree.rb"
class TestBinaryTree < Test::Unit::TestCase
def test_root_only
tree = BinaryTree.new(40)
assert_equal(0, tree.height)
end
def test_one_child
tree = BinaryTree.new(40)
tree.add(30)
assert_equal(1, tre... | true |
257758dff8eaa500a13761ddd2c909cb206b098d | Ruby | lihuazhang/ruby_practice | /parse_multiple_word_with_hypen.rb | UTF-8 | 1,180 | 2.859375 | 3 | [] | no_license | #! /usr/bin/ruby
def add_gram_to_multi_word(token)
pron = token.split("-").collect {| w | w.chomp.strip}.join(" ")
stories = Dir.glob('stories/*')
stories.each do |story|
story_changed = false
File.open story do |file|
arr = file.collect do |line|
if line =~ /<w .* t="#{token}" .*\/... | true |
38b6f9840273fe377a31087d2e1a921432752648 | Ruby | robinjoseph08/mishalandsamuel-rails | /lib/tasks/guest.rake | UTF-8 | 5,745 | 2.8125 | 3 | [] | no_license | require 'csv'
namespace :guest do
desc "Internal import from CSV"
task :_import, [:label] => [:environment] do |t, args|
path = File.expand_path("../../../data/#{args[:label]}.csv", __FILE__)
num = nil
party = nil
CSV.foreach path do |row|
name = row.shift.try(:strip)
party_num... | true |
bc28cc02d56d3a89a2c120eab6740084e37e4b24 | Ruby | ZJUguquan/Leetcode | /Timus-acm/1306.rb | UTF-8 | 1,033 | 3.59375 | 4 | [
"MIT"
] | permissive | # 1306 Sequence Median
class Scanner {
InputStream in;
char c;
Scanner(InputStream in) {
this.in = in;
nextChar();
}
void asserT(boolean e) {
if (!e) {
throw new Error();
}
}
void nextChar() {
try {
c = (char)in.read();
} catch (IOException e)... | true |
77cc2d975f3bfec298a024651ab1478eacf7fa3a | Ruby | sjlee3157/TaskList | /app/controllers/tasks_controller.rb | UTF-8 | 1,740 | 2.59375 | 3 | [] | no_license | class TasksController < ApplicationController
def index
@tasks = Task.all.order(:id)
end
def show
@id = params[:id].to_i
@task = Task.find_by(id: @id)
end
def new
@task = Task.new
@message = "What's your next task?"
end
def create
# other invalid params?
name = params[:task... | true |
e58a9b1ca60505bda90d3bb868a36cbec40dd8e9 | Ruby | carlosonunez/faa-ois-api | /lib/faa_ois_api/helpers/time.rb | UTF-8 | 1,144 | 2.84375 | 3 | [] | no_license | # frozen_string_literal: true
require 'time'
module FAAOISAPI
module Helpers
module Time
def self.parse(time_string)
return nil if time_string.nil?
if !time_string.match?(/^[0-9]{4}$/)
FAAOISAPI.logger.error "Invalid time: #{time_string}"
else
time_string.gsub(... | true |
a454ed202d24ee7c344a24620c9828def51bd11b | Ruby | oheyjesse/toy_rubot | /spec/toy_robot/robot_spec.rb | UTF-8 | 1,393 | 2.90625 | 3 | [] | no_license | RSpec.describe ToyRobot::Robot do
let(:robot) { ToyRobot::Robot.new(x: 0, y: 0, facing: :north) }
describe 'init' do
it 'can instantiate an instance of Robot' do
expect(robot).to be_an_instance_of(ToyRobot::Robot)
end
end
describe 'position / move' do
it 'can return it\'s position' do
... | true |
0a55d67dc5374cc4af09a4437355410332d5bea4 | Ruby | termtter/termtter | /lib/plugins/yhara.rb | UTF-8 | 3,004 | 2.921875 | 3 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
if RUBY_VERSION < "1.8.7"
class Array
def choice
at(rand(size))
end
end
end
# based on new-harizon.rb
module Yharian
VOICES =
%w(Agnes Albert Bad\ News Bahh Bells Boing Bruce Bubbles Cellos Deranged Fred Hysterical Junior Kathy Pipe\ Organ Princess Ralph Trinoids Vick... | true |
0157eccdfbce3cd23604c0df932018b68c98d936 | Ruby | ajaysinghj8/gurunode | /inheritance.rb | UTF-8 | 322 | 3.53125 | 4 | [] | no_license | class A
attr_accessor :name
attr_accessor :no
def initialize a
@name = "Ajay"
@no = 10
@@a=a
end
def show
puts "in parent class"
end
end
class B < A
def initialize a,b
super a
@@b=b
end
def show
A.show
puts @@a
puts @@b
end
end
obj = B.new 5,10
obj.sh... | true |
1368002861ed07342c13295951a75fabf190a8be | Ruby | SciMed/vision_mate | /spec/vision_mate/rack_spec.rb | UTF-8 | 2,052 | 3.03125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require_relative "../../lib/vision_mate/rack"
require_relative "../../lib/vision_mate/tube"
require_relative "../../lib/vision_mate/no_tube"
describe VisionMate::Rack do
subject { VisionMate::Rack.new(one_tube_string) }
let(:position_with_tube) { "H1" }
let(:position_without_tube) { "A1" }
let(:out_of_range_po... | true |
028b4913fd44930fda734e311e87f3244298e10f | Ruby | sous-chefs/mariadb | /libraries/helpers.rb | UTF-8 | 11,724 | 2.59375 | 3 | [
"Apache-2.0"
] | permissive | #
# Cookbook:: mariadb
# Library:: helpers
#
# 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 t... | true |
ad15af303179fb9206f2928843e99684784a951f | Ruby | cheald/shadowcraft-ui | /lib/wow_armory/relic.rb | UTF-8 | 3,850 | 2.59375 | 3 | [] | no_license | module WowArmory
class Relic
unloadable
include Constants
include Document
# This is terrible.
ARTIFACT_TRAIT_IDS = [214368,192657,192326,192923,192323,192428,192759,192329,192318,192349,192376,192315,192422,192345,192424,192310,192384,216230,202507,202628,202897,202769,202665,202463,202521,202... | true |
6dcafebdbed22e3003fec1f339522e2314d70926 | Ruby | tmurrell2020/collections_practice-onl01-seng-pt-090820 | /collections_practice.rb | UTF-8 | 1,032 | 3.828125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
def sort_array_asc(integers)
integers.sort do |a, b|
a <=> b
end
end
def sort_array_desc(integers)
integers.sort do |a, b|
if a == b
0
elsif a < b
1
elsif a > b
-1
end
end
end
def sort_array_char_count(array)
... | true |
8192ed0e917bc3619496ed5b0e94a1c86d74df3f | Ruby | FlorentinPerezGonzalez/Travis-Coveralls | /lib/food/plate.rb | UTF-8 | 7,976 | 3.546875 | 4 | [] | no_license | #:nodoc:
module Food
# La clase +Plate+ permite recrear un plato de un menú alimenticio.
# El plato se consituye por sus ingredientes, la cantidad de estos, y un nombre.
class Plate
include Comparable
#Lista de ingredientes. Se corresponde con un objeto +List+ de +Food+.
attr_reader... | true |
ce6fd749d5a24db4396e28955459373af4c2ec5b | Ruby | trungvuh/Data_Structures_and_Algorithms | /Heaps_Sort/lib/heap.rb | UTF-8 | 2,640 | 3.75 | 4 | [] | no_license | class BinaryMinHeap
attr_reader :store, :prc
def initialize(&prc)
@store = Array.new { [] }
@prc = prc || Proc.new { |a, b| a <=> b }
end
def count
@store.length
end
def extract
#swap the first and last item
@store[0], @store[count - 1] = @store[count - 1], @store[0]
#extract the ... | true |
92e11300784f351db3ccdd417a81ba62fd6d69fb | Ruby | mmohsen/extractr | /extractr.rb | UTF-8 | 1,707 | 2.984375 | 3 | [
"BSD-3-Clause"
] | permissive | #!/usr/bin/env ruby
#
# extractr - A simple utility to extract emails and domain names from text
#
# Developer: Mustafa Mohsen <mustafamohsen@tutanota.com>
# Version: 0.2.0
# Licence: BSD 3-Clause
#
require 'trollop'
def uniqify(text)
text.map{|i| i.downcase}.uniq.sort
end
def extract_domains(data)
... | true |
a5c3b15ba05c3fc2614bda75b3fcee1862c21b05 | Ruby | BaseXdb/basex | /basex-api/src/main/ruby/CreateExample.rb | UTF-8 | 658 | 2.6875 | 3 | [
"BSD-3-Clause"
] | permissive | # This example shows how new databases can be created.
# Documentation: https://docs.basex.org/wiki/Clients
#
# (C) BaseX Team 2005-23, BSD License
require './BaseXClient.rb'
begin
# create session
session = BaseXClient::Session.new("localhost", 1984, "admin", "admin")
# create new database
s... | true |
96db0e376db132a77984be713035c043af07cf67 | Ruby | treyx/dinner_dash | /app/models/order.rb | UTF-8 | 561 | 2.53125 | 3 | [] | no_license | class Order < ActiveRecord::Base
validates :user_id, :cart_items, presence: true
belongs_to :user
enum status: %w(ordered paid cancelled completed)
def created_at_formatted
created_at.strftime("%A, %d %b %Y %l:%M %p")
end
def updated_at_formatted
updated_at.strftime("%A, %d %b %Y %l:%M %p")
end
... | true |
3550d0b174836d7e4282ad5c98510b50f19591b3 | Ruby | drtrem/spoj_tasks | /ONP.rb | UTF-8 | 555 | 3.578125 | 4 | [] | no_license | def to_rpn(expression)
if expression.length <= 400
rpn = ""
operators = []
expression.each_char do |char|
if char == "("
# nope
elsif char =~ /[*^+-\/]/
operators << char
elsif char == ")"
rpn << operators.pop
else
rpn << char
end
end
... | true |
e9bb2b2c764916d62e35ebb803a2346db3db0a05 | Ruby | eadouglas10/Employee-Reviews-w-Database | /department.rb | UTF-8 | 657 | 3.609375 | 4 | [] | no_license | require_relative "employee"
class Department
attr_accessor :name
def initialize(name)
@name = name
@employees = []
end
def add(employee)
@employees.push(employee) unless @employees.include?(employee)
end
def has(employee)
@employees.include?(employee)
end
def total_sal
sal = 0
... | true |
5fa89e887644f30ad08527dd45628af42d261962 | Ruby | jdbernardi/prep_ruby_challenges | /factorial.rb | UTF-8 | 572 | 4.25 | 4 | [] | no_license | =begin
Write a method factorial which takes a number and returns the product of every number up to the current number multiplied together.
=end
#PROGRAM factorial(NUMBER)
def factorial(number)
#create an array
factorial_array = Array.new
#starting at 1 and ending at the number
for i in 1..number
#push... | true |
6ad9e0cd572742450c8b3c91f6e9585f2b603b89 | Ruby | sylwiavargas/square_array-dumbo-web-career-040119 | /square_array.rb | UTF-8 | 122 | 3.09375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def square_array(array)
a = []
array.each { |i| a << i ** 2 }
return a
end
#I would like to go over it with someone | true |
4de0b8a4a26b5f6502d3f440010b634816d4f0e8 | Ruby | rkudlar/Patterns_in_Ruby | /singleton.rb | UTF-8 | 245 | 3.15625 | 3 | [] | no_license | require 'singleton'
class Klass
include Singleton
attr_accessor :value
def initialize(i=0)
@value = i
end
def increment
@value += 1
end
end
a, b = Klass.instance, Klass.instance
puts a == b
puts a.object_id == b.object_id
| true |
fc97512ad563c98d41f7a118a85cfc42724d2e6c | Ruby | ap-hughes/weblog-statistics | /lib/weblog/csv_writer.rb | UTF-8 | 473 | 2.75 | 3 | [] | no_license | # frozen_string_literal: true
module Weblog
# Outputs results to a CSV file
class CsvWriter
require 'csv'
def initialize(records, title)
@records = records
@title = title
end
def write
CSV.open("stats/#{@title}_stats.csv", 'wb') do |csv|
formatted_data.each { |elem| csv ... | true |
fb02b5b1f1ba58fe05ff26efed82e782ce5cad9d | Ruby | Scott-Borecki/enigma | /lib/encrypt.rb | UTF-8 | 804 | 3.03125 | 3 | [] | no_license | require_relative 'modules/alphabetable'
require_relative 'modules/dateable'
require_relative 'modules/positionable'
require_relative 'modules/shiftable'
require_relative 'cipher'
require_relative 'enigma'
require_relative 'key'
require_relative 'offset'
handle = File.open(ARGV[0], 'r')
message = handle.read.downcase.... | true |
3bcc71e54ef2579b548377f7851998d454edd0e5 | Ruby | RubyCamp/rc2012w_g1 | /lib/scene.rb | UTF-8 | 636 | 2.875 | 3 | [] | no_license | require 'ostruct'
class Scene
def self.scenes; @@scenes end
class<<self
def common; @common ||= make_common() end
end
@@scenes = {}
@@current_scene_name = nil
def self.add_scene(scene_obj, scene_name)
@@scenes[scene_name.to_sym] = scene_obj
end
def self.set_current_scene(scene_name)
... | true |
aef9659b1ea7bb169d04c48aba0f0449fb21d1ae | Ruby | wkoszek/sivers | /sivers.org/toc.rb | UTF-8 | 2,050 | 2.515625 | 3 | [
"BSD-2-Clause"
] | permissive | # toc.rb = Table of Contents for books
# The values are URIs from sivers.org
# For example, itunes = sivers.org/itunes
AYW = %w(ayw1 ayw2 ayw3 ayw4 ayw5 ayw6 hitswitch hellyeah changeplan nofund startnow multiply formalities blc exclude2 noads more-than-one noplan the-mob grade caremore dontneed punish real unclear cd... | true |
8f039e9b4cf9748de6fa38fc5675bb188e092bcf | Ruby | jameszhan/rhea | /codes/ruby/rubygems/activesupport/concern.rb | UTF-8 | 1,403 | 3.171875 | 3 | [] | no_license |
module Foo
class << self
def included(base)
p "Foo included by #{base}"
# base.send(:do_host_something)
end
end
def foo
puts "foo method invoked."
end
end
module Bar
include Foo
def self.included(base)
p "Bar included by #{base}"
# base.send(:do_host_something)
end
... | true |
9fb060b1c00a7a55f788e083ab4eb7b740313e11 | Ruby | desoleary/blocks_course | /03 - enumerable/flyer.rb | UTF-8 | 306 | 3.15625 | 3 | [] | no_license | class Flyer
attr_reader :name, :email, :miles_flown
attr_accessor :status
def initialize(name, email, miles_flown, status=:bronze)
@name = name
@email = email
@miles_flown = miles_flown
@status = status
end
def to_s
"#{name} (#{email}): #{miles_flown} - #{status}"
end
end | true |
6036b040d6dbc5e959857bdb9485678348b80f3d | Ruby | Mattc007/data-structures | /test/singly_linked_list_test.rb | UTF-8 | 1,381 | 3.03125 | 3 | [] | no_license | require 'test/unit'
require_relative '../lib/data_structures'
class SinglyLinkedListTest < Test::Unit::TestCase
def setup
@list = DataStructures::SinglyLinkedList.new
@another_list = DataStructures::SinglyLinkedList.new
end
def test_singly_linked_list
assert @list.empty?
assert_nil @list.head
... | true |
44ffad42a3ec66a1335b854770550e0e1cfc081c | Ruby | mwynholds/wineflash | /app/models/parser/wtso_parser.rb | UTF-8 | 922 | 2.59375 | 3 | [] | no_license | class Parser::WTSOParser < Parser::Base
def source
'WTSO'
end
def self.supports?(mime)
mime.from[0] == 'wines@wtso.com'
end
def valid?
! @dom.xpath("//td[text() = 'Appellation:']").empty?
end
def deals
[ Deal.new(:wine => wine, :country => country, :vintage => vintage,
:... | true |
263855f9348e552b316970856b00a33342a9d753 | Ruby | rubyworks/functor | /lib/functor/version.rb | UTF-8 | 292 | 2.546875 | 3 | [
"BSD-2-Clause",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class Functor
#
def self.index
@index ||= (
require 'yaml'
YAML.load_file(File.dirname(__FILE__) + '/functor.yml')
)
end
#
def self.const_missing(const_name)
name = const_name.to_s.downcase
index.key?(name) ? index[name] : super(const_name)
end
end
| true |
42f956cc035450b7b29c311bfe4f33679ba440c8 | Ruby | prochas/RubyThirdTask | /testas.rb | UTF-8 | 522 | 2.703125 | 3 | [] | no_license | # Aprasoma klase
class TestasMetodas
def skaiciavimas(n, a1, a, test1, test)
# Prasukamas while ciklas
while test1 > 0.00001
# Panaudota formule is uzduoties
s = Math.sqrt((n + 1) * (n + 1) + 1)
a = (n + 1) / (s * Math.sqrt((n + 1) * (n + 1) - 1))
# Panaudota formule is uzduoties
... | true |
7bc10d55b80e28d4186e306f41824011c0aeb373 | Ruby | andykingking/http_stub | /spec/lib/http_stub/server/stub/response/attribute/headers_spec.rb | UTF-8 | 2,138 | 2.65625 | 3 | [
"MIT"
] | permissive | describe HttpStub::Server::Stub::Response::Attribute::Headers do
let(:stub_headers) { (1..3).each_with_object({}) { |i, result| result["key#{i}"] = "value #{i}" } }
let(:headers) { described_class.new(stub_headers) }
describe "#with_values_from" do
let(:request) { HttpStub::Server::Request::Request }
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.