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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
f80d3fdcc773601854c967f29a68f19016db7ee1 | Ruby | TonyBoy56/dad_jokes | /app/models/user.rb | UTF-8 | 895 | 2.515625 | 3 | [] | no_license | class User < ApplicationRecord
attr_accessor :password
validates_confirmation_of :password
validates :password, :format => {:with => /\A(?=.*\d)(?=.*([a-z]|[A-Z]))([\x20-\x7E]){8,}\z/,
message: "must be at least 8 characters and include one number, one letter, and a special character."}
validates :email,
... | true |
0e92af2108ac3c50f3316b434566383c8a30658c | Ruby | ehq/euler | /02.rb | UTF-8 | 287 | 3.640625 | 4 | [] | no_license | # Problem 2
# Find the sum of all the even-valued terms in the Fibonacci sequence which do not exceed four million.
require 'euler.rb'
result = 0
n = 0
next_term = 0
while next_term < 4000000
result += next_term if next_term.even?
n += 1
next_term = fibonacci(n)
end
puts result
| true |
c07c808e87fec35d22a2ee77226d934a0a420499 | Ruby | Disco-Chef/quiz | /ruby_parts.rb | UTF-8 | 2,714 | 3.359375 | 3 | [] | no_license | # Question: 1
"A database of tables that are linked with a system of primary
and foreign keys"
# Question: 2
"1:N, (1:1), N:N"
# Question: 5
"Structured QUERY Language"
# Question: 8
"Active Record is what we call an Object-Relational Mapping.
It’s purpose is to map the instance variables of our models
in our Ruby p... | true |
8243b12e7ace104b4c2ecb21f23942bbf422f2bc | Ruby | devudilip/Sales-Problem | /lib/calculator.rb | UTF-8 | 2,737 | 3.859375 | 4 | [] | no_license | class Calculator
attr_reader :items, :total_all, :sales_tax
def initialize(items)
@items = items
@good_tax_rate = 0.10
@import_tax_rate = 0.05
@nearest_cent = 1 / 0.05
@total_all = 0.0
@sales_tax = 0.0
end
def execute
update_amounts
set_totals
end
# Tax Calculations
## ... | true |
1d378cc189ca817aa0e0f9ee206d9cb1c8317a41 | Ruby | lucaminudel/TDDwithMockObjectsAndDesignPrinciples | /TDDMicroExercises.YoursSolutions/Ruby-Sam-Serpoosh/code/telemetry_system/telemetry_diagnostic_controls.rb | UTF-8 | 940 | 2.890625 | 3 | [] | no_license | require_relative "./telemetry_client"
class TelemetryDiagnosticControls
DIAGNOSTICCHANNELCONNECTIONSTRING = "*111#"
NUMBEROFRETRIES = 3
attr_accessor :diagnostic_info
def initialize(telemetry_client=TelemetryClient.new)
@telemetry_client = telemetry_client
@diagnostic_info = ""
end
def check_t... | true |
2fa9a381f0055298ec4ec2a7f9883dc61b92b217 | Ruby | lutsyshyn/polyhedron | /chem.rb | UTF-8 | 1,381 | 3.046875 | 3 | [] | no_license | # �� �������� � 10 ��� ���� �� ����� ���� � ���. ����� ����� ���� 2.530 � �.�.
# Se AgI 0.2530
# Se AgI 0.2530
# Se AgIII 0.2779
# Se AgIII 0.2889
# Se AgIII 0.2923
# Se AgI 0.2986
# Se AgII 0.3065
# Se AgII 0.3068
require "./atom.rb"
require "./symmetry.rb"
require "./symmetry_operation.rb"
require "... | true |
487ac45e0083ce5f81bdc154072772d26c675250 | Ruby | afinebojangle/finance | /db/seeds.rb | UTF-8 | 714 | 2.53125 | 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 rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel... | true |
a0fe009b3bfb201165e49b3c824b2e9e8dac3593 | Ruby | dcprime/Tealeaf-Prep | /Chapter_10_wordsort3.rb | UTF-8 | 809 | 4.21875 | 4 | [] | no_license | puts ''
puts 'Word sorting program'
puts 'Type as many words as you like and hit [enter] after each one'
puts 'When you are finished entering words, press [enter] on a blank line'
puts 'The program will then list the words in alphabetical order'
wordsort = []
unsorted_array = []
def sort unsorted_array
sort... | true |
028c5616bf5d39689872294ecd9b450415d4240a | Ruby | naaaaate/sample_rails_app2 | /app/models/user.rb | UTF-8 | 1,787 | 2.75 | 3 | [
"MIT"
] | permissive | class User < ActiveRecord::Base
attr_accessor :remember_token
before_save { self.email = email.downcase }
validates :name, presence: true, length: { maximum: 50 }
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
validates :email, presence: true, length: { maximum: 255 },
format: {... | true |
3d4b6a50e180cc03f6a14fe1a83c62608dda2861 | Ruby | yhidetoshi/Ruby_Study | /basic_confirm/each_test1.rb | UTF-8 | 77 | 2.75 | 3 | [] | no_license | names = ["Java", "Ruby", "HOGE", "HUGA"]
names.each do |name|
puts name
end
| true |
e7550ba06df1c0a415cebde00b686a498f1721ee | Ruby | hujewelz/bean | /lib/bean/colored.rb | UTF-8 | 514 | 3.1875 | 3 | [] | no_license | #!/usr/bin/env ruby -W
class String
def method_missing(m, *args)
color(m)
end
private
def color(key)
color_map = {
black: "\033[30m#{self}\033[0m",
red: "\033[31m#{self}\033[0m",
green: "\033[32m#{self}\033[0m",
yellow: "\033[33m#{self}\033[0m",
blue: ... | true |
f11cb93e68708b38f640854997c771bfff5781f0 | Ruby | badibadiola/prank | /keymouse/mouse.rb | UTF-8 | 1,863 | 3.640625 | 4 | [] | no_license | #!/usr/bin/env ruby
require "rumouse"
# how much the mouse can move at first
range = 1000
mouse = RuMouse.new
while true
# increase how much the mouse can move each time max
range += 250
# move the mouse a random int between 0 and the range for x and y
x_change = rand(range)
y_change = rand(range)
x_total_mov... | true |
c2ebcc8c73677eb98fa3875340d979e73555217b | Ruby | batteries76/code_alongs | /04-ruby/intro/fail_life.rb | UTF-8 | 448 | 3.75 | 4 | [] | no_license | secret = 42
puts 'please enter a number'
guess = gets.chomp
name = 'dt'
puts('Your guess is ' + guess.to_s)
puts "your name is #{name} guess is #{guess}" #interpolation
# if guess.to_i == secret
# puts 'blah'
# else
# puts 'you fail life'
# end
while (guess.to_i != secret)
puts('you fail life')
if (guess.to... | true |
8e2bd10502b3dbbbf0221b50cbc27f2e391545b5 | Ruby | siva-bandi/assignment | /1-squarer.rb | UTF-8 | 172 | 3.6875 | 4 | [] | no_license | def squarer(arr)
arr.map { |e| e * e }
end
puts "Enter integers separated by space"
input = gets
arr = input.split(' ')
arr = arr.collect { |e| e.to_i }
puts squarer(arr) | true |
8aab7b844f14cbf8c624dfd7410e0a3e5e952912 | Ruby | krtsato/ruby-rails-rspec-prac-archived | /db/seeds/production/staff_events.rb | UTF-8 | 407 | 2.65625 | 3 | [] | no_license | staff_members = StaffMember.all
256.times do |n|
staff = staff_members.sample # staff_members 配列から要素1つをランダム抽出
event = staff.events.build
if staff.active?
if n.even? # 偶数のとき
event.type = "logged_in"
else
event.type = "logged_out"
end
else
event.type = "rejected"
end
event.occur... | true |
13c8d4dcd8c2e765847a6d71278b887d4e318c65 | Ruby | dankleiman/chutes_and_ladders | /board.rb | UTF-8 | 220 | 3.171875 | 3 | [] | no_license | class Board < Array
attr_reader :board
def initialize
@board = [0,0,0,-3,0,0,0,2,1,-4,0,-5,3,0,0]
end
def length
@board.length
end
def current_square_value(position)
@board[position]
end
end
| true |
7a90d038591b5a857fdcc6fa151a858c6d71d627 | Ruby | melissajk/ruby_exercises | /oop_exercises/easy_1/exer_3.rb | UTF-8 | 1,080 | 4.3125 | 4 | [] | no_license | ## Fix the Program - Books (Part 1)
class Book
attr_reader :author, :title
def initialize(author, title)
@author = author
@title = title
end
def to_s
%("#{title}", by #{author})
end
end
book = Book.new("Neil Stephenson", "Snow Crash")
puts %(The author of "#{book.title}" is #{book.author}.) # T... | true |
1da7fb972204c0cb013dc6c9b89a815fd26ae0df | Ruby | spencer897/Chess- | /rook_bishop_queen.rb | UTF-8 | 423 | 2.75 | 3 | [] | no_license | require_relative "slideable.rb"
require_relative "piece.rb"
class Rook < Piece
include Slideable
def symbol
end
def move_dirs
1
end
end
class Bishop < Piece
include Slideable
def symbol
end
def move_dirs
2
end
end
class Queen < Pie... | true |
b72901c98f8919b85060fadac79f29124a6b3160 | Ruby | al2o3cr/mocktail | /lib/mocktail/verifies_call.rb | UTF-8 | 968 | 2.546875 | 3 | [
"MIT"
] | permissive | require_relative "records_demonstration"
require_relative "verifies_call/finds_verifiable_calls"
require_relative "verifies_call/raises_verification_error"
module Mocktail
class VerifiesCall
def initialize
@records_demonstration = RecordsDemonstration.new
@finds_verifiable_calls = FindsVerifiableCall... | true |
7b8a3b39c714c7ef5849506a8b85a6fbf4626e1d | Ruby | daxadax/meteorologist | /lib/meteorologist.rb | UTF-8 | 1,229 | 2.671875 | 3 | [] | no_license | Dir.glob(File.expand_path('../meteorologist/*.rb', __FILE__)) { |f| require f }
class Meteorologist
def initialize(location, options = {})
validate_environment
@location = location
@forecaster_class = options.fetch(:forecaster) { ::Forecaster }
@navigator_class = options.fetch(:navigator) { ::Naviga... | true |
c719dc97a3e1860cc7a15a8aba48cf84017c9e12 | Ruby | jwolfe890/sinatra-mvc-lab-v-000 | /app.rb | UTF-8 | 276 | 2.53125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require_relative 'config/environment'
class App < Sinatra::Base
get '/' do
"<form>Pig Latinizer! Enter your phrase: user_phrase</form>"
end
post '/piglatinize' do
@text = params[:user_phrase]
@analyzed_text = PigLatinizer.new
erb :text
end
end
| true |
796b7eee427645307fe83e1cf4c9d82826940686 | Ruby | fernandesleticia/cache-api | /app/models/transaction.rb | UTF-8 | 852 | 2.53125 | 3 | [] | no_license | class Transaction < ApplicationRecord
validates_presence_of :account, :date, :description, :reference
belongs_to :account, touch: true
after_save :clear_cache
EXPIRATION_TIME = 10.minute.to_i.freeze
scope :for_account_in_range, ->(account_id, range_in_days) { where(account_id: account_id).where("date >= cu... | true |
efa401ec0f8e28a00a0155f350f39fa838177af2 | Ruby | timnallen/museo | /lib/curator.rb | UTF-8 | 2,334 | 3.390625 | 3 | [] | no_license | require_relative 'photograph'
require_relative 'artist'
require 'CSV'
class Curator
attr_reader :artists,
:photographs
def initialize
@artists = []
@photographs = []
end
def load_photographs(file)
CSV.foreach(file, headers: true, header_converters: :symbol) do |row|
photo = Ph... | true |
9b59dc2a0063b720248eadb0032c2da5f7907e3a | Ruby | sawangupta92/VTAPP | /Ruby_exercise/pascal/bin/main.rb | UTF-8 | 100 | 2.953125 | 3 | [] | no_license | require_relative '../lib/pascal_triangle'
pascal = Pascal.new
pascal.series(5) { |val| puts val }
| true |
a075b91f0c940ebbc4a190e7bcfb51b9d0605410 | Ruby | pinzolo/cf_sim | /lib/cf_sim/portal_map.rb | UTF-8 | 1,204 | 3.296875 | 3 | [
"MIT"
] | permissive | require 'cblxy'
require 'cf_sim/cordination_system'
require 'cf_sim/point'
class CfSim::PortalMap
attr_reader :portals, :points
def initialize(*portals)
@portals = portals.flatten.dup.freeze
@cordination_system = CfSim::CordinationSystem.new(@portals.first.latitude, @portals.first.longitude)
@portal_... | true |
53770cc18d60d222aa6bed296fc669ba3e8074dd | Ruby | remcopeereboom/aoc2017 | /day14/puzzle2.rb | UTF-8 | 1,179 | 3.21875 | 3 | [] | no_license | ################################################################################
# Takes a hash describing a disk and then returns the number of regions in the #
# disk that are in use. #
# ... | true |
278efc825f2be80dd3798e8fbc5c3c06e77dd507 | Ruby | whosAle/collections_practice-nyc-web-career-031119 | /collections_practice.rb | UTF-8 | 606 | 3.84375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def sort_array_asc(array)
array.sort
end
def sort_array_desc(array)
array.sort { |a, b| b <=> a}
end
def sort_array_char_count(array)
array.sort_by { |word| word.length}
end
def swap_elements(array)
array[1], array[2] = array[2], array[1]
array
end
def reverse_array(array)
array.reverse
end
def kesha_m... | true |
1f4a5f1726b87b8d76cfdeeecda1a99cf2c3f25e | Ruby | FireBlade1999/RubyLearning | /lib/Arrays_And_Hashmaps/UsingTheHashMapModule_example.rb | UTF-8 | 766 | 3.640625 | 4 | [] | no_license |
# use the Dict module you created to demonstrate how a hashmap is built
require './MakingAHashMapModule_example.rb'
# test it works
jazz = Dict.new()
# set(aDict, k, v)
Dict.set(jazz, 'Miles Davis', 'Flamenco Sketches')
# confirm set will replace previous one
Dict.set(jazz, 'Miles Davis', 'Kind Of Blue')
Dict.set... | true |
993c0000d06e4f8b912993a9bc4ad16bbf8cd042 | Ruby | rahulshah7/makers-5day-coding-challenge | /src/6_display_even_numbers.rb | UTF-8 | 135 | 3.671875 | 4 | [] | no_license | # Iterate over an array of numbers and only
# display even numbers
[1,2,3,4,5].each do |num|
if num % 2 == 0
puts num
end
end
| true |
5ad54eb0dd6ac1c24a6aa99985827f0982c2c2c5 | Ruby | ippei94da/weightedpicker | /lib/weightedpicker.rb | UTF-8 | 7,867 | 2.875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # coding: utf-8
require 'yaml'
class WeightedPicker; end
require 'weightedpicker/tree.rb'
# TODO
# initialize.指定したファイル内のデータが WeightedPicker 的に
# 解釈できなければ例外。
#= 概要
# 要素群の中から、優先度に応じた重み付きランダムで、
# どれか1つを選択する。
# たとえば、以下の用途に使える。
#* 音楽ファイルの再生(好みのものは多い頻度で、
# そうでないものは少ない頻度で)
#* クイズゲームの問題選択
#* 画像
# * 写真で壁紙,... | true |
51595c1040d638721aee5c86f1e7ab8a555b09d5 | Ruby | Mattens15/Inline-LASESI | /vendor/bundle/gems/database_cleaner-1.7.0/lib/database_cleaner/safeguard.rb | UTF-8 | 1,595 | 2.546875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"Apache-2.0"
] | permissive | module DatabaseCleaner
class Safeguard
class Error < Exception
class RemoteDatabaseUrl < Error
def initialize
super("ENV['DATABASE_URL'] is set to a remote URL. Please refer to https://github.com/DatabaseCleaner/database_cleaner#safeguards")
end
end
class ProductionEnv... | true |
549353f18ff2318956d72728779e5425c1a3587b | Ruby | youchan/gohra | /samples/web/app/views/board_view.rb | UTF-8 | 924 | 2.53125 | 3 | [
"MIT"
] | permissive | require_relative 'opponents_view'
require_relative 'layout_view'
require_relative 'hands_view'
require_relative '../controllers/application_controller'
class BoardView
include Hyalite::Component
include Hyalite::Component::ShortHand
def initial_state
{ account: nil, opponents: [] }
end
def component_di... | true |
7005382bf07fdf597d8882bc33f0feb0713dbb3b | Ruby | nmgokhale/Ruby-Programming | /src/Software Engineering Foundations/Advanced Ruby/inject.rb | UTF-8 | 1,264 | 4.46875 | 4 | [] | no_license | # Ruby has both an inject and a reduce method. Both are functionally identical.
#
# inject will iterate through the array, passing in the current element to the block.
# inject will maintain an accumulator that will change over time, depending on our block.
# The block should return what the new accumulator should be... | true |
982065f9e97996e84376ffca5847c3374bef8a16 | Ruby | iceykohnn/phase_0_unit_2 | /week_5/6_validate_credit_card/my_solution.rb | UTF-8 | 2,617 | 4.3125 | 4 | [] | no_license |
# U2.W5: Class Warfare, Validate a Credit Card Number
# I worked on this challenge [by myself, with: Angela Kosek, Marek Pyczkowski.
# 2. Pseudocode
# Input: Credit card number
# Output: Returns true if credit card number is valid, flase otherwise
# Steps:
#We initialize the class with the CreditCard number first.... | true |
2a5f50a69d885a9c8f21c4a85c044753ecd2d706 | Ruby | michaelsimon/flatiron-bnb-methods-v-000 | /app/models/city.rb | UTF-8 | 1,670 | 2.53125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class City < ActiveRecord::Base
has_many :neighborhoods
has_many :listings, :through => :neighborhoods
def city_openings(start_date, end_date)
@start_date = start_date
@end_date = end_date
self.listings.where ("listings.id not IN (SELECT listing_id from reservations WHERE (@start_date <= checkout) ... | true |
cd94be438928c105b50dbba4e49c28af6c9b7d13 | Ruby | tfwright/incite | /lib/incite/citation.rb | UTF-8 | 838 | 2.921875 | 3 | [
"MIT"
] | permissive | module Incite
class Citation
REQUIRED_SOURCE_ATTRS = %w(authors title publisher year)
attr_accessor :source
def initialize(source)
self.source = source
raise ArgumentError, "Source lacks attributes required to construct citation" unless source.has_attributes?(REQUIRED_SOURCE_ATTRS)
e... | true |
597fa23857c90b321b9220882295098829223c99 | Ruby | Lanaed/snippets | /SQL/recipes/postgresql.rb | UTF-8 | 4,559 | 3.234375 | 3 | [] | no_license | # ---------------------------------------
# ---------------------------------------
# Introduction:
#
# this file is all you need to create a database, setup that database,
# connect to it and interact with it using PostgresSQL (assuming you've
# already installed PostgreSQL and the server is running, of course)
#
# if... | true |
e7b1527d617523de5c23fdce60bbbf6a381deb68 | Ruby | splattael/structr | /spec/structr_spec.rb | UTF-8 | 4,920 | 2.65625 | 3 | [] | no_license | require 'spec_helper'
describe Structr do
let(:klass) do
Class.new do
include Structr
end
end
subject { klass.new }
it 'raises ArgumentError w/o field name' do
assert_raises ArgumentError do
klass.field
end
end
it 'raise ArgumentError w/o arg' do
assert_raises ArgumentErr... | true |
a441cdda81c9f86e13d16e9b09e5a7c43406e757 | Ruby | jamez01/rubis | /lib/server.rb | UTF-8 | 1,723 | 2.609375 | 3 | [] | no_license | #!/usr/bin/env ruby
## rubis server
require 'drb'
require './lib/store.rb'
require './lib/version.rb'
require './lib/dumper.rb'
# Rubis is a key/value. The store can be any object in the ruby standard library.
module Rubis
# The Rubis server leverages druby and listens on port 9594 by default.
module Server
c... | true |
552d7703b65f48e57142522bff4b78ddf22adeee | Ruby | 4llankayan/curso_ruby_puro | /birth_month.rb | UTF-8 | 774 | 3.921875 | 4 | [] | no_license | puts "Qual seu nome?"
name = gets.chomp
puts "Em qual mês você nasceu?"
month = gets.chomp.to_i
case month
when 1
puts "Você nasceu em Janeiro, #{name}."
when 2
puts "Você nasceu em Fevereiro, #{name}."
when 3
puts "Você nasceu em Março, #{name}."
when 4
puts "Você nasceu em Abril, #{name}."
when 5
... | true |
cdd751d9120f4ccaf0b27e0c6283469b1fb8a8d6 | Ruby | philographer/Coderbyte | /AlphabetSoup.rb | UTF-8 | 237 | 3.09375 | 3 | [] | no_license | def AlphabetSoup(str)
str = str.split(" ")
str = str.to_s.split("").sort
return str.to_s
end
# keep this function call here
# to see how to enter arguments in Ruby scroll down
AlphabetSoup(STDIN.gets)
| true |
cb50b8b2c8d54af0d73ded26726c1051d398084b | Ruby | kipcole9/calendrical-ruby | /lib/calendrical/calendars/thirteen_week_quarter.rb | UTF-8 | 868 | 2.546875 | 3 | [
"MIT"
] | permissive | require File.expand_path("../thirteen_week_quarter/config.rb", __FILE__)
require File.expand_path("../thirteen_week_quarter/day.rb", __FILE__)
require File.expand_path("../thirteen_week_quarter/year.rb", __FILE__)
require File.expand_path("../thirteen_week_quarter/quarter.rb", __FILE__)
require File.expand_path("../thi... | true |
f8565d8348005cde9eb3e278a9165a47e026c6ba | Ruby | belindalei/ruby-intro-to-arrays-lab-nyc-web-062419 | /lib/intro_to_arrays.rb | UTF-8 | 585 | 3.734375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def instantiate_new_array
my_new_array = []
return my_new_array
end
def array_with_two_elements
my_two_array = ["apple", "banana"]
end
def first_element(array)
array.first
end
def third_element(array)
newArray = array[2]
return newArray
end
def last_element(array)
newArray = array.last
return newArr... | true |
fd61aa7099b17167d7f733b06afe44e1b87a7122 | Ruby | lukefraenza/LearnRuby | /Part1/2_Ruby.new/symbols.rb | UTF-8 | 772 | 3.65625 | 4 | [] | no_license | def walk(direction)
if direction == :north
puts "north!"
end
end
walk(:south)
walk(:north)
inst_section = {
'cello' => 'string',
'clarinet' => 'woodwind',
'drum' => 'percussion',
'oboe' => 'woodwind',
'trumpet' => 'brass',
'violin' => 'string'
}
p inst_section['cello']
p inst_section['oboe']
p inst... | true |
15c50d6c7aca9eae4f67b04a0e02e7853638994d | Ruby | JeremyEllingham/exercism | /ruby/pangram/pangram.rb | UTF-8 | 455 | 2.921875 | 3 | [] | no_license | class Pangram
ALPHABET = 'abcdefghijklmnopqrstuvwxyz'
# Check if a string contains every letter of the alphabet
# Case insensitive
# Returns a boolean
def self.pangram?(input)
ALPHABET.each_char { |char| return false unless input.downcase.include?(char) }
return true
end
end
# Required for Exerc... | true |
0071cb545ec620dee2d5d4f6c69c78767e673522 | Ruby | mendicant-original/mendibot | /plugins/acl.rb | UTF-8 | 994 | 2.625 | 3 | [] | no_license | module Mendibot
module Plugins
module ACL
PermissionDenied = Class.new(StandardError)
def self.included(base)
base.extend ClassMethods
end
module ClassMethods
def abilities
@abilities ||= {}
end
def can(method, filter)
hook(:pre, meth... | true |
9530f5f88fb3b826d263bff47f524400ed502a8a | Ruby | Shopify/money | /spec/null_currency_spec.rb | UTF-8 | 1,289 | 2.65625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe "NullCurrency" do
let (:null_currency) {Money::NULL_CURRENCY}
it 'exposes the same public interface as Currency' do
expect(Money::NullCurrency).to quack_like Money::Currency
end
describe "#initialize" do
it "has a valid XXX iso4217 cu... | true |
5bedb84aeb6a6cb5e7ce3065b650b3393df2f75f | Ruby | darkn3rd/oop-tut | /ruby/b00.instvar/demo.rb | UTF-8 | 321 | 4.1875 | 4 | [] | no_license | #!/usr/bin/ruby
require 'Person' # include Person.rb
# initialize data through mutator (set)
person = Person.new # instantiate new object
person.setName "Jean-Luc" # mutator
# access and print data through accessor (get)
name = person.getName # accessor
puts "Name of the Person:\n\t" + nam... | true |
b5fbaa712a1141fa6b02f8068ffa8cb69faea547 | Ruby | alawadh/lab | /rps_game_winner.rb | UTF-8 | 1,429 | 3.65625 | 4 | [] | no_license | class WrongNumberOfPlayersError < StandardError ; end
class WrongNumberOfGamesError < StandardError ; end
class NoSuchStrategyError < StandardError ; end
def rps_game_winner(game)
raise WrongNumberOfPlayersError unless game.length == 2
m1 = game[0][1].downcase
m2 = game[1][1].downcase
rai... | true |
80205c68325ebca87525a1b8ba18460121c1a48d | Ruby | ismo1/ruby_dijkstra_algorithm | /test.rb | UTF-8 | 2,957 | 2.796875 | 3 | [] | no_license | $LOAD_PATH.unshift(File.dirname(__FILE__))
require 'test/unit'
require 'node'
require 'graph'
require 'dijkstra_algorithm'
class TestDijkstra < Test::Unit::TestCase
def test_create_node_with_name
paris = Node.new('Paris')
assert_equal paris.name, 'Paris'
end
def test_node_with_same_names_are_equal
... | true |
dbc9faee4143551a0d13b885c62ec79bf5b86a51 | Ruby | gitter-badger/fron | /opal/fron/core_ext/kernel.rb | UTF-8 | 474 | 2.796875 | 3 | [] | no_license | # Kernel
module Kernel
# Requests an animation frame from the browser
# and runs the givel block if given.
def requestAnimationFrame
return unless block_given?
return unless `!!window.requestAnimationFrame`
`window.requestAnimationFrame(function(){ #{yield} })`
end
# Runs the given block after th... | true |
53ccba6a315589836e32ffb266a59e2c45405c41 | Ruby | drakeltheryuujin/looping-times-001-prework-web | /times.rb | UTF-8 | 103 | 2.8125 | 3 | [] | no_license | def using_times
spell = "Wingardium Leviosa"
7.times do
puts spell
sleep 1
end
end
using_times
| true |
1f1a03e8c2884d1e07833cd178b3206de1db0081 | Ruby | elizagamedev/ally-birthday-game | /game.rb | UTF-8 | 7,685 | 3.453125 | 3 | [] | no_license | require 'gosu'
require_relative 'graphic'
class Buttons
def initialize
@pressed = {}
end
def reset
@pressed = {}
end
def press(name)
@pressed[name] = true if name
end
def release(name)
@pressed[name] = false if name
end
def pressed?(name)
return @pressed[name] ? true : false
... | true |
c52925ce17ca8cb913dba365ab0f5df24396b3f0 | Ruby | Kevin8428/new_dragons | /05_ruby101/kevin_deutscher/ruby_intro/arrays_cheatsheet.rb | UTF-8 | 1,307 | 3.921875 | 4 | [] | no_license | teachers = ["james","jim","adriana"]
# teachers.each{|teacher| p teacher}
# teachers.each do |teacher| # this does same as teachers.each{|teacher| p teacher} -- 3 line method is better for many interations
# p teacher
# end
teachers.each{|teacher| p teacher.upcase}#.each doesn't affect original
# p teachers
teacher... | true |
ec583a83d5127956b2e71b9f54aec0b744a97f8e | Ruby | Laaronhooper/Yahtzee | /views/scorecard/new.rb | UTF-8 | 1,648 | 3 | 3 | [] | no_license | require 'tty-table'
module Views
module Scorecard
def self.scorecard(scores)
table = TTY::Table.new(['index',"Challenges",scores.current_player.name, scores.other_player.name],[])
table << ["1","Ones",scores.current_player.ones,scores.other_player.ones]
table << ["2",'Tw... | true |
8ee7530e08f3fffdd840458dbdeefa1808fb4baf | Ruby | softscienceprojects/OO-Auto-Shop-london-web-080519 | /app/models/car_owner.rb | UTF-8 | 577 | 3.390625 | 3 | [] | no_license | class CarOwner
attr_reader :name
@@all = []
def initialize(name)
@name = name
@@all << self
end
def self.all
@@all
end
def get_my_cars
Car.all.select{|car| car.owner == self}
end
def show_my_cars
get_my_cars.map{|car| "#{car.make} - #{car.model}, #{car.classification}."}
end... | true |
21cdb6824429c27dbb2405c85f59ad8ebed03778 | Ruby | martintomas/RubyMonkTasks | /Problems/problem14.rb | UTF-8 | 376 | 3.546875 | 4 | [
"MIT"
] | permissive | # Problem Statement
# Given a 3 or 4 digit number with distinct digits,
# return a sorted array of all the unique numbers
# that can be formed with those digits.
def number_shuffle(number)
digits = number.to_s.split(//).uniq
factorial = (1..digits.length).inject(:*) || 1
res = []
res << digits.shuffle.join.to... | true |
fb188f10d8d97685c257eb05701fc650cb581329 | Ruby | alu0100502053/prct09 | /lib/b_good/matrices/matriz.rb | UTF-8 | 1,644 | 3.28125 | 3 | [
"MIT"
] | permissive | class Matriz
def initialize(*args) #args recogerá en un array las filas de nuestra matriz.
@matriz = Array.new()
for i in args do
if i.size == args.size then #controlamos que es una matriz cuadrada.
@matriz.push(i)
else
raise "La matriz debe ser cuadrada"
end
end
@dimension = args.size #G... | true |
b7169badf01fce820fc9fbb3769982b1ec642a0f | Ruby | jstrocel/gameplaydate | /app/models/reminder.rb | UTF-8 | 1,124 | 2.546875 | 3 | [] | no_license | class Reminder < ActiveRecord::Base
belongs_to :event
before_save :set_time
after_create :send_reminder
def time_number
end
def time_unit
end
def time_number=(time_number)
@time_number = time_number.to_i
puts "Time number is " + @time_number.to_s
end
def time_unit=... | true |
47f29331b9f9d7c7551cfd479ee298f777bc88f5 | Ruby | ej2015/pcwr | /countdown_latch.rb | UTF-8 | 255 | 2.921875 | 3 | [] | no_license |
require 'java'
java_import 'java.util.concurrent.CountDownLatch'
latch = CountDownLatch.new(4);
4.times do
Thread.new do
sleep rand(3)
latch.count_down
latch.await
puts "[#{Time.now.to_i}]#{Thread.current} boo!"
end
end
sleep(5)
| true |
3cf8180134bfb1f07bd8024be5d615f1f4315379 | Ruby | ecargiohc/oo-kickstarter-seattle-web-071519 | /lib/backer.rb | UTF-8 | 383 | 2.625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | #paired with Nick
require_relative "project.rb"
class Backer
attr_reader :backed_projects, :name
attr_writer :backed_projects
# attr_accessor :backed_projects, :name
def initialize(name)
@name = name
@backed_projects = []
end
def back_project(project)
@backed_pro... | true |
b72f5e2964e22d35ee791aef172548b325697ca4 | Ruby | kruczjak/distributed-systems-4 | /server/lib/hospital_handler.rb | UTF-8 | 1,058 | 2.765625 | 3 | [] | no_license | class HospitalHandler
def getPatient(id)
puts "Getting patient with id:#{id}"
patient = find_patient(id).to_struct
puts "Patient #{patient.inspect} fetched"
patient
end
def createPatient(name)
Patient.create!(name: name).id
end
def addExamination(patient_id, date, doctor_name)
Examin... | true |
1ab0d309ca1df564fed2094e4c96295501020e5a | Ruby | neboweb/draftpunk | /lib/activerecord_class_methods.rb | UTF-8 | 10,108 | 2.640625 | 3 | [
"MIT"
] | permissive | require 'activerecord_instance_methods'
require 'draft_diff_instance_methods'
module DraftPunk
module Model
module ActiveRecordClassMethods
# Call this method in your model to setup approval. It will recursively apply to its associations,
# thus does not need to be explicity called on its associated ... | true |
5e04c01d774431b6a35845eeaf5313e9ca179240 | Ruby | patulka/catbnb | /db/seeds.rb | UTF-8 | 1,412 | 2.515625 | 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 |
9ba187830787ab5cbd8c69e96a547c21dde47577 | Ruby | mcarson1111/BankAccounts | /BankAccount.rb | UTF-8 | 9,526 | 4.09375 | 4 | [] | no_license | require 'csv'
#require money ?* (gonna do printf instead)
module Bank
#this is WAVE 1:
class Account
attr_accessor :id, :balance, :creation_date #these are like the instance variables, but now methods!
def initialize (account_hash) #initialize is actually a class method
@id = account_hash[:id].... | true |
56e7fbac84203afdbc2bde91d0bc988530ee96c1 | Ruby | calicanadian/case_tabs_assessment | /app/models/component.rb | UTF-8 | 3,161 | 2.84375 | 3 | [] | no_license | class Component < ApplicationRecord
validates_uniqueness_of :name
validates_presence_of :name, :command
validates :name, uniqueness: {case_sensitive: false}, length: {maximum: 10}
validates :command, length: {maximum: 80}
has_many :relationships
has_many :dependents, through: :relationships
def self.par... | true |
4349ced0a16cde33f04ffd3aa970ec64d3462623 | Ruby | xarisd/ruby-basics-ii | /presentation/code/type_system/01_dynamicaly_typed_c.rb | UTF-8 | 70 | 2.53125 | 3 | [
"MIT"
] | permissive | a = 1
a = 'I am a string now'
a = ['Now', 'I', 'am', 'an', 'Array']
| true |
16b0ce2a769eb613f7226e3c0d0cd26e8594351b | Ruby | alokpradhan/assignment_rspec_viking | /spec/warmup_spec.rb | UTF-8 | 1,346 | 3.25 | 3 | [] | no_license | require 'warmup'
#require 'pry'
describe Warmup do
let(:a){Warmup.new}
describe '#gets_shout' do
it 'accepts an input through gets' do
#stub gets with lowercase
#expect an upcase return
allow(a).to receive(:gets).and_return("hello")
expect(a.gets_shout).to eq("HELLO")
end
end
describe '#double_si... | true |
8196adade999f763669cb6854f2f5f0f76ab9099 | Ruby | alfuken/bowling_sample | /last_frame.rb | UTF-8 | 1,180 | 3.03125 | 3 | [] | no_license | class LastFrame < Frame
def initialize(game)
super(10, game)
end
def description
string = ""
string << (strike? ? "X" : roll_as_string(first_roll)) + ' '
string << (spare? ? "/" : (second_strike? ? "X" : roll_as_string(second_roll))) + ' '
string << (third_strike? ? "X" : roll_as_string(thi... | true |
43ccbc146b54396225722b4d3f068d109b36ee68 | Ruby | Lakost/Lakosting | /New_phone.rb | UTF-8 | 457 | 3.71875 | 4 | [] | no_license | puts "You decided to buy yourself a new phone and before you there is a choice of two phones. Which one do you choose?
1. Lenovo
2. Iphone"
choice = gets.chomp
if choice == "1"
abort "You brought the latest model phone Lenovo."
else
puts "You are asked how many GB you need a phone: 32 or 64?
1. 32
2. 64"
choiсe... | true |
508fd796f126a7c981af0741a9030eda9d4ee97b | Ruby | ruby/typeprof | /smoke/rescue1.rb | UTF-8 | 215 | 2.984375 | 3 | [
"MIT"
] | permissive | def foo(x)
42
end
def bar
x = 1
x = "str"
x = :sym
rescue
foo(x)
end
bar
__END__
# Classes
class Object
private
def foo: ((:sym | Integer | String)? x) -> Integer
def bar: -> (:sym | Integer)
end
| true |
3969576001586071d7e9e2ebf58fe53483c1c9d0 | Ruby | CanaryTek/rasca | /lib/rasca/duplicity/check_duplicity.rb | UTF-8 | 5,254 | 2.84375 | 3 | [] | no_license | module Rasca
# TODO:
# Checks DuplicityVolume generated data (persists)
# Run DuplicityVolume's col command and check result. Check against configured data
# A Simple Template
class CheckDuplicity < Check
DEFAULT={
:warning_limit => 36*60*60,
:critical_limit => 50*60*60,
:nobackup_status => "CRITICAL"
... | true |
66905baf32a52f6bb2ba7a79ec4b3caf70e72eae | Ruby | vonnenaut/codewars | /build_tower.rb | UTF-8 | 2,261 | 4.625 | 5 | [] | no_license | # build_tower.rb
# PEDAC practice #8
# Problem
# Examples/Test Cases
# Data Structure
# Algorithm
# Code
# coding with intent
# Problem & Examples
#####################
# Build Tower by the following given argument:
# number of floors (integer and always greater than 0).
# Tower block is represented as *
# Rub... | true |
bb5651b7289a86ec95cb0ae7092d7bdfdf0115d5 | Ruby | fanninggg/smart-pension-ruby | /router.rb | UTF-8 | 1,228 | 3.515625 | 4 | [] | no_license | # frozen_string_literal: true
# Class to act as a menu loop for users in the terminal
class Router
def initialize(controller)
@controller = controller
@running = true
end
def run
puts 'Welcome to the logfile parser, discover what wonderful secrets your logfile holds!'
puts '====='
while @ru... | true |
c754647206c5a6c2189bcdef65d32f2b222c2ffc | Ruby | psyomn/threefortyfour | /server/domain/UserSession.rb | UTF-8 | 2,320 | 3.046875 | 3 | [] | no_license | require_relative 'NormalUserFacade.rb'
require_relative 'BookingCatalogue.rb'
require_relative 'EventSpecificationCatalogue.rb'
module Domain
#Author::Simon Symeonidis
# The user session object.
# Responsible for checking up the users
# and making sure that they exist.
#
# If they don't, then the connection
# is ... | true |
a4412e90bb083604d47c3dde740b1aaf7ce4bb87 | Ruby | loyaldev03/meteor-app | /script/custom/upload_products.rb | UTF-8 | 1,776 | 2.78125 | 3 | [] | no_license | #!/bin/ruby
require 'rubygems'
require 'rails'
require 'active_record'
require 'csv'
ActiveRecord::Base.configurations["phoenix"] = {
:adapter => "mysql2",
:database => "sac_platform_development",
:host => "127.0.0.1",
:username => "root",
:password => ""
}
#########################################... | true |
8ece9ea80a31167429c760544ce743118b4c7cee | Ruby | fulldemo13/Discovery_pPiscine | /rb05/ex14/free_range.rb | UTF-8 | 158 | 2.859375 | 3 | [] | no_license | #!/usr/bin/ruby
if ARGV.length != 2
puts "none"
else
array = (ARGV[0].to_i..ARGV[1].to_i).to_a
if array.length == 0
puts "none"
else
p array
end
end | true |
e5b05f3939a12acad791aba77771c379bf437463 | Ruby | robyparr/adjourn | /test/helpers/meetings_helper_test.rb | UTF-8 | 2,639 | 2.609375 | 3 | [
"MIT"
] | permissive | # typed: false
require 'test_helper'
class MeetingsHelperTest < ActionView::TestCase
setup do
@recent_meeting = create(:meeting).tap do |meeting|
meeting.start_date = Time.zone.now - 2.days
meeting.end_date = meeting.start_date + 1.hour
end
@upcoming_meeting = create(:meeting).tap do |meetin... | true |
128dd08043b05b21c8a38d87467e4e43a4587647 | Ruby | zangrafx/code-standards-jekyll | /_plugins/section_page.rb | UTF-8 | 1,645 | 2.515625 | 3 | [] | no_license | # file name: section_page.rb
# description: generate the section of _sections/xx(language)/
# author: alswl
# update at: 2012-08-02
module Jekyll
class SectionPage < Page
def initialize(site, base, sections, language)
@site = site
@base = base
@dir = ''
@name = language + '.html'
... | true |
2b04277730d8136089bceda93c474c4ba3cb99b8 | Ruby | adaveniprashanth/MyData | /ruby_training/prachi_work_with_ruby/final_data/4_count_the_data.rb | UTF-8 | 6,404 | 2.84375 | 3 | [] | no_license | require 'csv'
=begin
pass = fail = warn = error = notrun = total = 0;
Emulation_Compare_2x4x8 = [pass,fail,warn,error,notrun,total]
Emulation_Lockup_2x4x8 = [pass,fail,warn,error,notrun,total]
Renderfulsim_2x4x8 = [pass,fail,warn,error,notrun,total]
Rendermill_2x4x8 = [pass,fail,warn,error,notrun,total]
Fulsim_Tests =... | true |
4a54fcdee9a27b72c8d06fc096e266e66f416b09 | Ruby | SettRaziel/nginx_statistics | /bin/nginx_statictics.rb | UTF-8 | 1,561 | 3.015625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require "ruby_utils/string"
require_relative "../lib/data/data_repository"
require_relative "../lib/parameter"
require_relative "../lib/output/help_output"
require_relative "../lib/event/repository_listener"
require_relative "../lib/menu/menu"
# call to print version number and author
def print_version
puts "nginx_s... | true |
81ce137383a564ca5b8c899365f0b9cc668a2c36 | Ruby | scallear/Lesson1 | /calc_app/basic_calc.rb | UTF-8 | 1,081 | 4.125 | 4 | [] | no_license | def say(msg)
puts "\n=> #{msg}"
end
def check_number(number)
number =~ /\d/
end
def check_operator(operator)
operator =~ /[+\-*\/]/
end
number
system 'clear'
puts "Welcome to my first Ruby calculator!\nLet's build an expression and solve it."
begin
begin
say "What's the first number?"
number1 = get... | true |
278b49f7e458e3e4eda69fdc8cea376209f930ff | Ruby | kurwitz3/learn-co-sandbox | /cli_project/lib/mexican_dishes/dishes.rb | UTF-8 | 257 | 3.046875 | 3 | [
"MIT"
] | permissive | class MexicanDishes::Dishes
@@all = []
attr_accessor :dish, :recipe
def initialize(dish, recipe)
@dish = dish
@recipe = recipe
@@all << self
end
def self.all
@@all
end
end
| true |
96e2feef3d2ff893e2d937829e32345b29e91c76 | Ruby | alloy/ssalleyware | /t.rb | UTF-8 | 3,063 | 2.625 | 3 | [] | no_license | require 'rubygems'
require 'eventmachine'
require 'openssl'
class OpenSSL::X509::Certificate
def ==(other)
other.respond_to?(:to_pem) && to_pem == other.to_pem
end
# A serial *must* be unique for each certificate. Self-signed certificates,
# and thus root CA certificates, have the same `issuer' as `subje... | true |
21f15dcbcd5a38c3b7ac46e1b99b7043d81ec349 | Ruby | averagealloy/programming-univbasics-4-square-array-online-web-prework | /lib/square_array.rb | UTF-8 | 178 | 3.046875 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def square_array(square_array)
counter = 0
new_numbers = []
while counter < square_array.count do
new_numbers << (square_array[counter] ** 2)
counter += 1
end
new_numbers
end
| true |
73f8d62285e6e47af96f9731dfb67e83dca7283a | Ruby | sergeypedan/rails-template | /app/helpers/oauth_helper.rb | UTF-8 | 1,262 | 2.515625 | 3 | [] | no_license | # frozen_string_literal: true
module OauthHelper
# extracts `?redirect_to=` value from social nets callback URL (request.env['omniauth.origin'])
# @returns nil if not found
def redirect_path_from_oauth(request_env)
return unless request_env.is_a? Hash
# Some social nets may pass the whole URL including... | true |
1a76fcc31ca6602bf9ba03ef532665df1d7122cd | Ruby | nate00/arium | /lib/arium/point.rb | UTF-8 | 305 | 3 | 3 | [] | no_license | module Arium
class Point
attr_reader :row, :col
def initialize(row, col)
@row, @col = row, col
end
def ==(other)
self.id == other.id
end
def eql?(other)
self == other
end
def hash
id.hash
end
def id
[row, col]
end
end
end
| true |
6a7c1af221123a33227e15a0210c5db6d9a1a23e | Ruby | gadial/project-euler | /problem56.rb | UTF-8 | 437 | 3.625 | 4 | [] | no_license | # A googol (10100) is a massive number: one followed by one-hundred zeros; 100100 is almost unimaginably large: one followed by two-hundred zeros. Despite their size, the sum of the digits in each number is only 1.
#
# Considering natural numbers of the form, a^b, where a, b 100, what is the maximum digital sum?
requ... | true |
df91fc0a030d1854395071253449b8bc6f25b60f | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/gigasecond/2d25572c71e041bd9f8c2a6c886c55e7.rb | UTF-8 | 199 | 2.796875 | 3 | [] | no_license | require 'time'
require 'date'
class Gigasecond
def self.from(date)
start_time = Time.parse(date.to_s)
giga_time = 10**9
start_time+=giga_time
Date.parse(start_time.to_s)
end
end
| true |
fbccfbbf0c20828f044178e49f3b1d17e6f3fe6b | Ruby | Inglorion-G/rpg | /test/player_test.rb | UTF-8 | 440 | 2.515625 | 3 | [] | no_license | require 'minitest/spec'
require 'minitest/autorun'
require_relative '../src/models/player'
describe Player do
before do
@player = Player.new
end
describe "initialization" do
it "is initialized with a default name" do
assert_equal "player_1", @player.name
end
it "can be initialized with a ... | true |
c3074cf6dda756f011306fa86184f980ff4059de | Ruby | berundis/green_grocer-prework | /grocer.rb | UTF-8 | 1,422 | 3.21875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def consolidate_cart(cart)
items = []
compact_cart = {}
cart.each do |item|
item.each do |name, details|
if items.include?(name)
compact_cart[name][:count] += 1
else
compact_cart[name] = {}
details.each do |key, val|
compact_cart[name][key] = val
end
... | true |
3e10bb177deb8822d85be3a3c07623ee34456484 | Ruby | ShaheensWeb/CodeWars-Ruby | /Jan24thCodeWars-Ruby.rb | UTF-8 | 757 | 4.46875 | 4 | [] | no_license | #Problem set 7, Ruby
'''To complete this kata remove any hash whose two keys sum to an odd number.
example:
remove_odd_hashes(
[ {a: 5, b: 5},
{a: 3, b: 4},
{a: 2, b: 0},
{a: 2, b: 1}],
:a, :b)
# returns [{a: 5, b: 5}, {a: 2, b: 0}] '''
#Solution to problem set 7
def remove_odd_hashes(array, key... | true |
be1b33e5022ad375d72452a2ce8fcf9db7b94e87 | Ruby | alexbartlow/secure_rails | /lib/secure_rails.rb | UTF-8 | 3,458 | 2.6875 | 3 | [] | no_license | class Object
def metaclass ; class << self ; self ; end ; end
end
module SecureRails
class PolicyDeclarationError < StandardError ; end
class InvalidAuthenticator < ArgumentError ; end
def self.included(base)
base.send :include, SecureRails::InstanceMethods
end
module InstanceMethods
def ... | true |
cff99690d18b6ed4c9fa63cbe803bcb27be3954d | Ruby | emacip/pebblewatch | /lib/pebble/watch/app_message_event.rb | UTF-8 | 1,456 | 2.625 | 3 | [
"MIT"
] | permissive | module Pebble
class Watch
class AppMessageEvent < Event
module TupleType
ByteArray = 0
String = 1
UnsignedInteger = 2
Integer = 3
end
attr_accessor :transaction_id
attr_accessor :uuid
attr_accessor :data
def self.parse(ra... | true |
069790723625ebd27c7d08947e087161c8a6722a | Ruby | old-account/gimei | /spec/name_spec.rb | UTF-8 | 2,542 | 2.875 | 3 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
require_relative 'spec_helper'
describe Gimei do
describe '.male' do
before { @name = Gimei.male }
it '男性の名前が返ること' do
@name.male?.must_equal true
end
end
describe '.female' do
before { @name = Gimei.female }
it '女性の名前が返ること' do
@name.female?.must_equal tr... | true |
59d49824eb05754b02307f835d3240c130233bb0 | Ruby | lczapparolli/gestor-financeiro | /app/helpers/breadcrumb_helper.rb | UTF-8 | 1,382 | 2.578125 | 3 | [] | no_license | module BreadcrumbHelper
def breadcrumb
#if is home page, we do not need breadcrumbs
unless current_page? root_path
content_tag(:div, class: "breadcrumbs") do
link_to("Home", root_path, class: "link link-default") <<
controller_tag() <<
current_action_tag()
end
end
e... | true |
aed25209a562a922e65ec847e2db976ea378c954 | Ruby | jamieberrier/ruby-collaborating-objects-lab-v-000 | /lib/song.rb | UTF-8 | 1,554 | 3.828125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
# Class variables store information regarding the class as a whole and
# class methods enact behaviors that belong to the whole class, not just to individual instances of that class.
class Song
# give individual songs an artist attribute
attr_accessor :name, :artist
def initialize(name)
@name =... | true |
dc1b0686e8a532197d60d2a463fc0f849b1d71bf | Ruby | redding/sanford | /test/support/fake_server_connection.rb | UTF-8 | 1,114 | 2.984375 | 3 | [
"MIT"
] | permissive | require 'sanford-protocol'
class FakeServerConnection
attr_reader :request, :response
attr_reader :write_closed
attr_accessor :raise_on_write, :write_exception
attr_writer :read_data
def self.with_request(name, params = nil)
self.new.tap{ |c| c.add_request(name, params) }
end
def initialize(read_d... | true |
a769b9f53da83a0a2f2ea8709086cecc1bd7e603 | Ruby | JasonRodriguez1/ruby_factorials | /factorial_calc_spec.rb | UTF-8 | 257 | 2.609375 | 3 | [] | no_license | require 'rspec'
require 'factorial_calc'
describe 'factorial' do
it "returns the factorial of 0" do
factorial(0).should eq 1
end
it 'returns the result of a number multiplied by each previous number' do
factorial(5).should eq 120
end
end
| true |
132b843baa172a4eb1a35b0d0ba28ecc65e46394 | Ruby | Anthony-Mendola/ttt-3-display_board-example-bootcamp-prep-000 | /lib/display_board.rb | UTF-8 | 243 | 3 | 3 | [] | no_license | # Define display_board that accepts a board and prints
# out the current state.
def display_board
puts " " "|" " " "|" " "
puts "-----------"
puts " " "|" " " "|" " "
puts "-----------"
puts " " "|" " " "|" " "
end
| true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.