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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
6b2e7dd123fa212c66b6634c15dfac2a43918194 | Ruby | mscottford/shotgun | /lib/shotgun.rb | UTF-8 | 2,274 | 2.578125 | 3 | [
"MIT"
] | permissive | require 'rack'
require 'rack/utils'
require 'thread'
if RUBY_PLATFORM =~ /(win|w)32$/
require 'win32/process'
end
class Shotgun
include Rack::Utils
attr_reader :rackup_file
def initialize(rackup_file, wrapper=nil)
@rackup_file = rackup_file
@wrapper = wrapper || lambda { |inner_app| inner_app }
en... | true |
68e1fbe18b80245c8d06e061dfc6f652fc5a8ca1 | Ruby | bghalami/black_thursday | /test/item_repository_test.rb | UTF-8 | 3,296 | 3.125 | 3 | [] | no_license | require_relative '../test/test_helper.rb'
require_relative '../lib/item_repository'
class ItemRepositoryTest < Minitest::Test
def setup
@item_repo = ItemRepository.new
@item_1 = Item.new({
:id => "263395237",
:name => "Pencil",
:description => "Best Pencil EVER!",
:uni... | true |
99e3545b4950acf74149a8201bdc394e0b9e01b3 | Ruby | Jonesyd/ls_101_programming_foundations | /04_lessons/02_08_conversion.rb | UTF-8 | 271 | 3.453125 | 3 | [] | no_license | p str = 'Practice'
p arr = str.chars
p arr.join
p str = 'How do you get to Carnegie Hall?'
p arr = str.split
p arr.join(" ")
p hsh = { sky: "blue", grass: "green" }
p arr = hsh.to_a
p arr.to_h
p arr = [[:name, 'Joe'], [:age, 10], [:favorite_color, 'blue']]
p arr.to_h
| true |
be6a05629373df8bb746f44c6e050bb26789154f | Ruby | basantos/ProjectEuler | /001/001.rb | UTF-8 | 283 | 4.15625 | 4 | [] | no_license | # If we list all the natural numbers below 10 that are multiples of 3 or 5,
# we get 3, 5, 6 and 9. The sum of these multiples is 23.
# Find the sum of all the multiples of 3 or 5 below 1000.
i = 1
sum = 0
while i < 1000
sum = sum + i if i%3==0 or i%5==0
i = i+1
end
puts sum
| true |
432cac2946f0632d9b297750c3159701a22cf40f | Ruby | SevenSecrets/boris_bikes_thursday | /lib/docking_station.rb | UTF-8 | 698 | 3.28125 | 3 | [] | no_license | require './lib/Bike'
class DockingStation
attr_reader :bike_rack, :capacity
DEFAULT_CAPACITY = 20
def initialize(capacity=DEFAULT_CAPACITY)
@bike_rack = []
@capacity = capacity
end
def release_bike
raise "No bikes available" if empty?
released_bike = @bike_rack.pop
if released_bike.broke... | true |
b05626046a2b2a57c36c6194bf913edcd035326a | Ruby | mic-css/rps-challenge | /spec/bot_spec.rb | UTF-8 | 538 | 2.703125 | 3 | [] | no_license | require 'bot'
describe Bot do
subject(:bot) { described_class.new('ExampleBot', weapon_klass) }
let(:weapon_klass) { double :weapon_klass, new: rock }
let(:rock) { double :weapon }
describe '#name' do
it 'returns the bot\'s name' do
expect(bot.name).to eq 'ExampleBot'
end
end
... | true |
d5b244a8a10e60f92d1653fffbcb046b289bf19e | Ruby | Zolotovmega/rover-challenge | /lib/rover_challenge/control_center.rb | UTF-8 | 1,061 | 3.484375 | 3 | [
"MIT"
] | permissive | module RoverChallenge
class ControlCenter
LEFT = 'L'.freeze
RIGHT = 'R'.freeze
MOVE = 'M'.freeze
RoverOutOfBounds = Class.new(RuntimeError)
attr_reader :plateau, :rover
# @param [RoverChallenge::Plateau] plateau
# @param [RoverChallenge::Rover] rover
def initialize(plateau, rover)
... | true |
191aea8319dc193e2eac01cef8d7de3af26a0d46 | Ruby | learn-co-students/nyc04-seng-ft-120720 | /09-ruby-and-the-internet/starter_kit/app/tools/themes.rb | UTF-8 | 790 | 3.1875 | 3 | [] | no_license | module Themes
def alert_theme(str_args_arr)
# iterate over the array of strings and colorize each one
str_args_arr.each do |str|
puts str.colorize(:color => :black, :background => :yellow)
end
end
def mix_theme(str_args_arr)
# iterate over the array of strings a... | true |
9936b2aa49b3ee4fb85a6cc35234504da489a515 | Ruby | LafayetteCollegeLibraries/spot | /app/services/spot/importers/csv/work_type_validator.rb | UTF-8 | 1,091 | 2.6875 | 3 | [] | no_license | # frozen_string_literal: true
module Spot::Importers::CSV
# Validator for CSV files to ensure that if the file contains a "work_type" field,
# the values for that field can all be interpreted as valid work types.
class WorkTypeValidator < ::Darlingtonia::Validator
def self.valid?(value)
Hyrax.config.cur... | true |
3e80d3f7d961d32caca0ea13bcf8cb1eeb007b9c | Ruby | franklindch/exercices_lifen | /level1/main.rb | UTF-8 | 3,086 | 3.234375 | 3 | [] | no_license | require 'json'
require 'date'
class LifenPayCalculator
def initialize(filepath_input, filepath_output)
@filepath_input = filepath_input
@filepath_output = filepath_output
end
def calculate
shifts_grouped_by_worker = group_shifts_per_worker(parse_data)
smart_hash = calculate_pay(parse_data, shift... | true |
50a1112c8f6bd2647a80dabdb24ef908fc308841 | Ruby | khamilowicz/Project_Euler | /18and67/funTree.rb | UTF-8 | 5,803 | 3.78125 | 4 | [] | no_license | class Branch < Array
attr_accessor :line_number
def initialize line_number
@line_number = line_number
end
end
class Tree
def initialize
@branches = []
end
def getBranch line_number
branch = @branches[line_number]
if branch.nil?
max_line_number = ... | true |
dacc9c2ed03a0fd00fb97d20fc295d783b7c5e58 | Ruby | samgranieri/overcommit | /lib/overcommit/configuration.rb | UTF-8 | 3,788 | 2.734375 | 3 | [
"MIT"
] | permissive | module Overcommit
# Stores configuration for Overcommit and the hooks it runs.
class Configuration
# Creates a configuration from the given hash.
def initialize(hash)
@hash = ConfigurationValidator.new.validate(hash)
end
def ==(other)
super || @hash == other.hash
end
alias_metho... | true |
d4a129b0f179111e891f77fc39fde06981cdf35f | Ruby | cucumber/docs | /themes/cucumber-hugo/tools/htmlproofer/htmlproofer.rb | UTF-8 | 2,768 | 2.625 | 3 | [
"MIT"
] | permissive | require 'bundler/setup'
require 'html-proofer'
# TODO: Check that depth increases by only 1 for each header,
# And that we always start with h1 (ignore the title h1)
class HeaderCheck < HTMLProofer::Check
IGNORE_PATHS = [
'public/admin/index.html',
'public/index.html'
]
def run
return if IGNORE_PATH... | true |
f4a204852de9c78e10b09b5e182700dce1db8130 | Ruby | christycui/Intro-Course-L1-L2 | /PRS_game.rb | UTF-8 | 795 | 4.1875 | 4 | [] | no_license | # Paper Rock Scissors
def win(ans1,ans2)
if ans1 == ans2
puts "It's a tie."
elsif (ans1 == 'paper' and ans2 == 'rock') || (ans1 == 'rock' and ans2 == 'scissor') || (ans1 == 'scissor' and ans2 == 'paper')
puts "You won!"
else
puts "The computer won!"
end
end
ans = 'Y'
until ans.upcase == 'N'
p... | true |
14a2227abc5ffc1c53b0ee13f424a1209a300de1 | Ruby | mirfath/codingbee-articles | /Vagrant/vagrant-singlemulti-box-environments-i-e-config-vm-box-verses-config-vm-define | UTF-8 | 1,696 | 2.734375 | 3 | [] | no_license | So far we have come across:
<pre>
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box ="puppetlabs/ubuntu-14.04-32-nocm"
end
</pre>
Using "config.vm.box" means that your vagrantfile is limited to be able to only spin up a sing... | true |
af1b7e8b956e59f9a042cb41029e8e0a44ad18a4 | Ruby | kalashnikovisme/kabal | /lib/kabal/languages/russian/fractional_numbers.rb | UTF-8 | 1,461 | 2.859375 | 3 | [
"MIT"
] | permissive | module Kabal
module RussianRules
module FractionalNumbers
def fractional_number_name(number)
join_with_spaces whole_part_name(number), fractional_part_name(number)
end
def fractional_part_name(number)
fractional_part = (number % 1).round(fractional_part_order(number))
fr... | true |
962aa3ba05c76863fd1be9acdc8e5bc0a9f7c78d | Ruby | shoppersaysso/intro-to-tdd-rspec-and-learn-bootcamp-prep-000 | /current_age_for_birth_year.rb | UTF-8 | 56 | 2.796875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def current_age_for_birth_year(x)
return 2016 - x
end
| true |
262bf9f3e58c5a3eacfebf79d83334871279df18 | Ruby | dtingg/interviews | /LeetCode/roman _to_int.rb | UTF-8 | 769 | 4.59375 | 5 | [] | no_license | # LeetCode: Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999.
# Time: O(n)
# Space: O(n)
def roman_to_int(s)
total = 0
length = s.length
index = -1
roman_hash = {"I"=>1, "V"=>5, "X"=>10, "L"=>50, "C"=>100, "D"=>500, "M"=>1000}
while index >= -l... | true |
814a25ee4e65b0b7ea22a8020ba4639481c072f6 | Ruby | grosser/share_man | /config/initializers/__hacks.rb | UTF-8 | 904 | 2.5625 | 3 | [] | no_license | # ActionView text helpers
# http://grosser.it/2009/05/30/all-actionview-helpers-on-strings/
class String
%w[auto_link excerpt highlight sanitize simple_format strip_tags word_wrap].each do |method|
define_method method do |*args|
ActionController::Base.helpers.send method, self, *args
end
end
def t... | true |
11b46a1980433d726a287a5688ee6047d4bee861 | Ruby | regiefe/jogo_forca | /ui.rb | UTF-8 | 2,553 | 3.65625 | 4 | [] | no_license | def da_boas_vindas
puts "*************************"
puts "* Jogo da forca *"
puts "*************************"
puts "Qual é o seu nome?"
nome = gets.strip
puts "\n\n\n\n"
puts "Começaremos o jogo para você #{nome}"
nome
end
def desenha_forca(erros)
cabeca = " "
corpo = " "
pernas = " "
... | true |
bbc05b7d28c3deaab19b89a4305ef0db89f403ce | Ruby | mgiacomini/aliexpress-crawler-app | /app/models/product.rb | UTF-8 | 1,839 | 2.71875 | 3 | [
"MIT"
] | permissive | class Product < ActiveRecord::Base
has_many :product_types, dependent: :destroy
belongs_to :wordpress
def self.import(products_data, wordpress)
products_data.each do |data|
#Criando produto
products = wordpress.products
product = products.find_or_initialize_by(id_at_wordpress: data["id"])
... | true |
b5698b53031eb738c95c52668499ad7b2c3a6a93 | Ruby | dmbf29/food-delivery-471 | /app/views/base_view.rb | UTF-8 | 92 | 2.796875 | 3 | [] | no_license | class BaseView
def ask_for(thing)
puts "Whats the #{thing}?"
gets.chomp
end
end
| true |
2b8acdb5fc824265ce42b14208b0fe9f2423cf3a | Ruby | sweinstein27/ruby-objects-has-many-through-lab-v-000 | /lib/artist.rb | UTF-8 | 344 | 3.34375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class Artist
attr_accessor :name, :song, :genre
@@all = []
def initialize(name)
@name = name
@@all << self
@songs = []
@genres = []
end
def self.all
@@all
end
def new_song(name, genre)
song = Song.new(name, self, genre)
@songs << song
@genres << genre
song
end
def songs
@songs
end
def ... | true |
eef02bcf569a25e51fe9b2dcaa36033bc34bb730 | Ruby | morizyun/aoj-ruby-python | /ruby/0004.rb | UTF-8 | 237 | 3.078125 | 3 | [] | no_license | while str = gets
a, b, c, d, e, f = str.split(' ').map(&:to_f)
x = (b*f - e*c)/(b*d - e*a)
y = (c - a*x)/b
x = 0.0 if x.round(3) == -0.000
y = 0.0 if y.round(3) == -0.000
puts sprintf('%.3f %.3f', x.round(3), y.round(3))
end
| true |
a23fcffd70de066a1bd4b05c2141189daa9260d2 | Ruby | spartalisdigital/lotu | /lib/lotu/helpers/vector2d.rb | UTF-8 | 2,419 | 3.234375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # -*- coding: utf-8 -*-
module Lotu
class Vector2d
attr_reader :x, :y
def self.up
@up ||= new(0, -1)
end
def initialize(x=0, y=0)
clear_cache
@x = Float(x)
@y = Float(y)
end
def clear_cache
@length = nil
@length_sq = nil
@normalized = false
end
... | true |
affd159fb72ee7128548d89c6b995cc82a523001 | Ruby | TheObtuseAutodidact/exercism | /ruby/word-count/word_count.rb | UTF-8 | 782 | 3.59375 | 4 | [] | no_license | # Given a phrase, count the occurrences of each word in that phrase.
class Phrase
def initialize(string_o_words)
@words = split_and_sanitize_to_word_list(string_o_words)
end
def word_count
@words.each_with_object(Hash.new(0)) { |word, my_hash| my_hash[word] += 1 }
end
private
def strip_quotes(str... | true |
4f39e80ee29ea52c2026dadec8180fc6941c6622 | Ruby | wlonkly/advent-of-code | /2017/09/09_spec.rb | UTF-8 | 921 | 3 | 3 | [] | no_license | require_relative "./09.rb"
describe Advent do
describe "#clean!" do
cases = {
'<>' => 0,
'<random characters>' => 17,
'<<<<>' => 3,
'<{!>}>' => 2,
'<!!>' => 0,
'<!!!>>' => 0,
'<{o"i!a,<{i<a>' => 10
}
cases.each do |c, v|
it "cleans '#{c}' with score ... | true |
7933d9d9a7ff20ffb841ea4241333ad878c7d169 | Ruby | learn-co-students/yale-web-2019 | /03-oo-many-to-many/run.rb | UTF-8 | 466 | 2.578125 | 3 | [] | no_license | require 'pry'
require_relative './tweet.rb'
require_relative './user.rb'
require_relative './like.rb'
prince = User.new("prince3000")
matt = User.new("matt04")
jenna = User.new("jz70")
jenna.post_tweet("Hi")
matt.post_tweet("Hi jz70")
prince.post_tweet("Rad")
prince.post_tweet("\"Send Tweet\"")
new_tweet = matt.pos... | true |
276ccc2a03c8b6838c34ecb60975626792bc30df | Ruby | fanjieqi/LeetCodeRuby | /901-1000/933. Number of Recent Calls.rb | UTF-8 | 374 | 3.34375 | 3 | [
"MIT"
] | permissive | class RecentCounter
def initialize()
@queue = []
end
=begin
:type t: Integer
:rtype: Integer
=end
def ping(t)
@queue << t
@queue.shift while !@queue.empty? && t - 3000 > @queue[0]
@queue.size
end
end
# Your RecentCounter object will be instantiated and called as such... | true |
40b0dcf75dd26714fc2da0755deed0de29a9c9c4 | Ruby | kramerkeller/launch | /03_lesson/2_Practice_Problems_Easy_1/04_Question.rb | UTF-8 | 358 | 3.890625 | 4 | [] | no_license | # Question 4
numbers = [1, 2, 3, 4, 5]
numbers.delete_at(1)
puts numbers
puts
numbers = [1, 2, 3, 4, 5]
numbers.delete(1)
puts numbers
# Both are destructive methods as expected with a name like delete.
# delete_at() deletes the value at the index number passed as a parameter
# delete() deletes all the values in th... | true |
083d5bf2adec3248db72a506684880824dc9d7df | Ruby | abhinavm24/2048 | /ruby/main.rb | UTF-8 | 1,260 | 3.546875 | 4 | [
"MIT"
] | permissive | $LOAD_PATH << File.expand_path('lib')
require 'game'
require 'human'
require 'bot'
puts "what kind of player? (human or bot)"
player_type = gets
if player_type.strip == 'human'
player = Human.new
highest_tile = player.play
else
player = Bot.new
tiles = []
1000.times do
tiles << player.play
end
highe... | true |
ce0c89e2c0806392c4962b05c31b84276cfac1a3 | Ruby | BiggerPockets/iterable_migrator | /bin/intersection | UTF-8 | 1,042 | 2.71875 | 3 | [] | no_license | #!/usr/bin/env ruby
require "bundler"
require_relative "../lib/iterable_migrator"
str = File.read(File.join("data", "mailchimp", "subscribed_emails.csv")).scrub
mailchimp_emails = CSV.parse(str, headers: true).map do |row|
row["Email Address"].downcase.strip
end
iterable_emails = CSV.read(File.join("data", "iterab... | true |
0fc80c54d347314266a847b5e530b4d3419c64a6 | Ruby | ADStrovers/2015-02-03-mini-programs | /paragraph_truncator/paragraph_truncator.rb | UTF-8 | 285 | 2.765625 | 3 | [] | no_license | require 'pry'
require 'active_support'
require 'active_support/core_ext/string/filters'
class ParagraphTruncator
def initialize(text)
@text = text
@trunc_text = ""
end
def truncate_text(size = 100)
@trunc_text = @text.truncate(size)
end
end
binding.pry | true |
9f532124133ee52b8382efebf14bffca93bf9957 | Ruby | coldiron/advent | /2020/18/order_of_operations.rb | UTF-8 | 1,283 | 3.46875 | 3 | [] | no_license | INNERMOST_PARENTHESES_RX = /\([^()]*[^()]*\)/.freeze
ADDITION_RX = /(\d+\+\d+\+\d+\+\d+|\d+\+\d+)/.freeze
def calculate(string)
parenth = string.match(INNERMOST_PARENTHESES_RX).to_s
until string.scan(/[()]/).first.nil?
string.gsub!("#{parenth}", reduce(parenth).to_s)
parenth = string.match(INNERMOST_PARENTH... | true |
ee4377f033f15c535c4f278e56444c3b68a4d518 | Ruby | reallygooday/Erlang | /app.rb | UTF-8 | 1,153 | 2.734375 | 3 | [] | no_license | require "sinatra"
get "/" do
erb :home
end
post "/" do
@questionNumber = params[:questionNumber]
if params[:selection] == "earth"
erb :earth
elsif params[:selection] == "erlang"
erb :erlang
elsif params[:selection] == "saturn"
erb :saturn
elsif params[:selection] == "jupiter"
erb :jupiter
elsif para... | true |
aedbf55683c0dc6eccda06b0ddd437a7ec22e78a | Ruby | eugene-yzm/etc | /geo.rb | UTF-8 | 1,654 | 3.25 | 3 | [] | no_license | require 'roo'
require 'spreadsheet'
require 'enumerator'
include Math
s = Roo::Spreadsheet.open('./CA.xls')
zipcode = s.column(1)
city = s.column(2)
state = s.column(3)
latitude = s.column(4)
longitude = s.column(5)
county = s.column(6)
# current zipcode
in1 = "94027"
# distance (in miles) to search
in2 = "3"
clas... | true |
6ecf0489cb3f73dc4b4f4563512a2b9f192fd583 | Ruby | coffeeexistence/project-euler-largest-palindrome-product-q-000 | /lib/oo_largest_palindrome_product.rb | UTF-8 | 446 | 3.578125 | 4 | [] | no_license | # Implement your object-oriented solution here!
class LargestPalindromeProduct
def palindrome?(number)
number.to_s == number.to_s.reverse
end
def answer
start = 100
limit = 999
palindromes = []
(start..limit).each do |var_1|
(start..limit).each do |var_2|
var_product = var_1 *... | true |
77bec353a578e115cd794e4a257aef7f795758dc | Ruby | daniero/code-challenges | /aoc2019/ruby/intcode.rb | UTF-8 | 2,365 | 3.15625 | 3 | [] | no_license | PositionMode = 0
ImmediateMode = 1
RelativeMode = 2
class IntcodeComputer
attr_accessor :memory, :ip, :relative_base, :input, :output
def initialize(program,
input: [],
output: []
)
@memory = program.dup
@input = input
@output = output
@ip = 0
... | true |
dd25112143134e0bad890e2b4d4bbadc089214ec | Ruby | iksflow/PS | /ruby/leetcode/problems/P0509.rb | UTF-8 | 275 | 3.671875 | 4 | [] | no_license | # 509. Fibonacci Number
#
# @param {Integer} n
# @return {Integer}
def fib(n)
memo = [31]
memo[0] = 0
memo[1] = 1
n.times do |idx|
if memo[idx].nil?
memo[idx] = memo[idx - 1] + memo[idx - 2]
end
end
memo[n]
end
5.times do |n|
puts "hi #{n}"
end
| true |
23589b915bd58dbbbb70c28bbfb1659f8e3b80b1 | Ruby | wzshiming/novice_bookworm | /model.rb | UTF-8 | 1,204 | 2.53125 | 3 | [] | no_license | #!/usr/bin/env ruby2.0
require './database'
require './puts'
require 'digest/md5'
if __FILE__ == $0
conn=Database.new host: 'localhost',
port: 27017,
database: 'test',
username: 'test',
password: 'test'
conn.remove_data 'user'
... | true |
be8f473a1a52ec3d57f46814b2737af3f7bec67c | Ruby | sequra/norma43_parser | /lib/norma43/line_parsers/line_parser.rb | UTF-8 | 977 | 2.90625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Norma43
module LineParsers
class LineParser
attr_reader :line
def initialize(line)
@line = line
end
def attributes
self.class.field_names.each_with_object({}) do |field, attrs|
attrs[field] = self.public_send(field)
e... | true |
2dcc50cdbdb1add3f796e39482b7a211cf346b9d | Ruby | jaythomas/blitz3d-ng | /lib/blitz3d/translator/node/prog.rb | UTF-8 | 1,109 | 2.59375 | 3 | [
"Zlib"
] | permissive | module Blitz3D
module AST
class ProgNode < Node
attr_accessor :modules, :globals, :locals, :stmts, :funcs, :structs
def initialize(json)
@globals = json['globals'].map { |global| Decl.new(global) }
@locals = json['locals'].map { |local| Decl.new(local) }
@modules = json['modul... | true |
4908d5f9a656b5a26a00905cf78441be370c350c | Ruby | yang1107/Napakalaki | /Napakalakiruby/lib/card_dealer.rb | UTF-8 | 11,773 | 2.59375 | 3 | [] | no_license | # To change this license header, choose License Headers in Project Properties.
# To change this template file, choose Tools | Templates
# and open the template in the editor.
require "singleton"
require_relative "monster.rb"
require_relative "treasure_kind.rb"
require_relative "prize.rb"
require_relative "treasure.rb"
... | true |
8246670a408a7d75ae220844bd1154d192c4ffb8 | Ruby | LukisKhan/Homeworks | /W7D1/board_day_two/partner_a.rb | UTF-8 | 1,674 | 3.296875 | 3 | [] | no_license |
class WhatIsSelf
def test
puts "At the instance level, self is #{self}"
end
def self.test
puts "At the class level, self is #{self}"
end
end
me = WhatIsSelf.new
"At the class level, self is <WhatIsSelf... obj sadfsd>"
WhatIsSelf.test
"At the class level, self is WhatIsSelf"
class JukeBox
def initia... | true |
5d931b115cf55176676a2efb214a261db009bebc | Ruby | tnoda/scorm2004-sequencing | /lib/scorm2004/sequencing/objective_rollup_using_default_rule_process.rb | UTF-8 | 1,391 | 2.515625 | 3 | [
"MIT"
] | permissive | require 'scorm2004/sequencing'
require 'ostruct'
module Scorm2004
module Sequencing
# Objective Rollup Using Default Rule Process derived from
# Objective Rollup Using Rules Process [RB.1.2b] line 1.
#
# @example
# ObjectiveRollupUsingDefaultRule.new.call(activity)
class ObjectiveRollupUsin... | true |
f91448aa367c3b4e3601cb79781279370a218255 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/proverb/16dbf16299db4ea999c66f76c1e928cf.rb | UTF-8 | 556 | 3.390625 | 3 | [] | no_license | class Proverb
def initialize(*things, qualifier: nil)
@things = things
@qualifier = qualifier
end
def to_s
@proverb ||= proverb
end
private
def statement(desired, lost)
"For want of a #{desired} the #{lost} was lost.\n"
end
def conclusion
vanity_object = " #{@qualifier} #{@things... | true |
8563f318045310bfe99bc7e49d81e6f2c31024d8 | Ruby | Noah2610/text-adventure | /src/keyword.rb | UTF-8 | 1,189 | 3.1875 | 3 | [] | no_license |
KEYWORDS_TALK = [
[:hello,:hi,:hey,:bonjour],
[:bye,:goodbye,:cya,:leave],
[:tell,:talk,:explain],
[:take,:give],
[:about]
]
KEYWORDS_TALK_PHRASES = [
[[
"see you",
"have a good day","have a nice day","have a great day",
"have a good night","have a nice night","have a great night",
"have a good evening... | true |
47f61058eb2add34b8b47c466ec59bf64c9c1b86 | Ruby | Nicholas-Maxwell/ruby-class-variables-and-class-methods-lab-v-000 | /lib/song.rb | UTF-8 | 1,233 | 3.921875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive |
require 'pry'
class Song
@@count = 0 #Class Variable
@@artists = []
@@genres = []
attr_accessor :name, :artist, :genre
def initialize( name, artist, genre) #Song class takes in 3 arguments: name, arist, genre
@name = name
@artist = artist #Instance Variables
@genre = genre
@@count += 1 #EV... | true |
2f88955b63b2886c5f1e1d11a308a3f312e52a65 | Ruby | carlababa/ruby_codes | /my_store/product.rb | UTF-8 | 258 | 3.421875 | 3 | [] | no_license | class Product
attr_accessor :name, :quantity, :price
def initialize(name, quantity, price)
@name = name
@quantity = quantity
@price = price
end
def price
@price
end
def name
@name
end
def quantity
@quantity
end
end
| true |
4058101661da5b7c343180c83aaeee1251e5f8f4 | Ruby | mconover4/cli-data-gem-assessment-v-000 | /movie-finder/lib/movie/finder.rb | UTF-8 | 933 | 3.5 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive |
#this is after getting an input in which genre to find from. need to make a cli class
#update : Finder isnt needed by itself, I'm merging it with Genre
#class Finder
#attr_accessor :name, :rating, :genre
#@@all = []
#def initialize(name = nil, rating = nil)
#@name = name
#@rating = rating
#@@all << ... | true |
c41cb4cb3de2d6a63579ad15662ac45f547665fe | Ruby | Lanzhou-J/DinnerChoice | /lib/DinnerChoice.rb | UTF-8 | 977 | 3.09375 | 3 | [] | no_license | # version
require_relative "DinnerChoice/version"
# heading ascii art & style
require_relative "../lib/DinnerChoice/utils/heading_ascii"
require_relative "../lib/DinnerChoice/utils/wine_logo_ascii"
require_relative "../lib/DinnerChoice/utils/line_separator"
# main menu and functions
require_relative "../lib/DinnerChoi... | true |
3562aa5ea577f9c0c3a8c2d2bd5c178a43006cae | Ruby | markfranciose/drops_of_knowledge | /ruby/well_grounded_rubyist/5-3-singleton.rb | UTF-8 | 96 | 3.15625 | 3 | [
"MIT"
] | permissive | class Dog
end
fido = Dog.new
def fido.bark
puts "woof woof, self is #{self}"
end
fido.bark
| true |
a2305db6d9fdb965aa0d341a1c9ef71b30663aca | Ruby | markus851/eddy | /lib/definitions/elements/manual/96.number_of_included_segments.rb | UTF-8 | 811 | 2.859375 | 3 | [
"MIT"
] | permissive | module Eddy
module Elements
# ### Element Summary:
#
# - Id: 96
# - Name: Number of Included Segments
# - Type: N0
# - Min/Max: 1/10
# - Description: Total number of segments included in a transaction set including ST and SE segments
class E96 < Eddy::Models::Element::N
# @param ... | true |
0a4b3fc3553c006a10e82c366f3d45a17da2f915 | Ruby | rjammal/AppAcademy | /wk01/d4/xml.rb | UTF-8 | 793 | 2.875 | 3 | [] | no_license | class XmlDocument
def initialize(indented = false)
@indented = indented
@depth = 1
end
def method_missing(*name, &prc)
method_name = name[0]
if @indented
newline = "\n"
start_indent = " " * @depth
end_indent = " " * (@depth - 1)
else
newline = ""
start... | true |
1c9e0fa27511631f66a052f8c79445a4baa2425d | Ruby | ream88/mongoid-encrypted_string | /spec/encrypted_string_spec.rb | UTF-8 | 1,255 | 2.546875 | 3 | [
"MIT"
] | permissive | require_relative 'spec_helper'
describe Mongoid::EncryptedString do
let(:string) { 'foo' }
subject { Mongoid::EncryptedString.new(string) }
describe 'not setting a key' do
it 'raises an error' do
key = Mongoid::EncryptedString.config.key
Mongoid::EncryptedString.config.key = nil
Mongoid::... | true |
682e91c7faa759f233a050f3a0da36aa9424bffc | Ruby | rranshous/cellularsource | /cycle_source.rb | UTF-8 | 798 | 2.671875 | 3 | [] | no_license | require 'json'
require 'uri'
require 'httparty'
class CycleSource
class Client
def start image
puts "cycle start [#{base_url}]: #{image}"
data = { image: image }
url = URI.join base_url, '/start'
r = HTTParty.post(url, body: data.to_json)
return false if r['running'] == false
... | true |
b8760f40551a76f3c7a3ca6c24393c5093363f88 | Ruby | mattdeutsch/mattdeutsch-project-euler | /p6/squaresum.rb | UTF-8 | 161 | 3.25 | 3 | [] | no_license | def diffsquaresum(k)
sqaureofsum = ((k*(k+1))/2) ** 2
sumofsquare = (k*(k+1)*(2*k+1))/6
return sqaureofsum - sumofsquare
end
puts diffsquaresum(ARGV[0].to_i) | true |
0cd2fcf436d87f4f25c5f294781af6f49dabbc5d | Ruby | GuiRokk/Aquecimento-ruby | /lib/study_item.rb | UTF-8 | 3,295 | 3.453125 | 3 | [] | no_license | require 'colorize'
class StudyItem
attr_reader :id, :title, :category
attr_accessor :done
@@next_id = 1
@@item_collection = []
def initialize(title:, category:, done:"x")
@id = @@next_id
@title = title
@category = category
@done = done
@@next_id += 1
... | true |
031446ef461dc1345de5b0f9c618766b077a0098 | Ruby | jonsnyder01/thesis_wikipedia | /spec/cosine_similarity_spec.rb | UTF-8 | 719 | 2.65625 | 3 | [] | no_license | $LOAD_PATH.unshift( File.join( File.dirname( File.dirname(__FILE__)), 'lib' ) )
require 'cosine_similarity'
describe CosineSimilarity do
it "works with orthogonal vectors" do
CosineSimilarity.call([1, 0], [0, 1]).should == 0.0
end
it "works with matching vectors" do
CosineSimilarity.call([15, 0], [0.5... | true |
f05c72fb7252b033526514e84c6592fcab3817b7 | Ruby | yuri-val/HomeTasks_LITS | /ruby/lesson12_0/mini_ar.rb | UTF-8 | 1,937 | 2.59375 | 3 | [] | no_license | require './db'
class MiniActiveRecord
# сохраним список сгенерированных классов в переменной класса
class << self; attr_reader :generated_classes, :table_name; end
@generated_classes = []
@@table_name = ""
def initialize(attributes = nil)
if !@@table_name.empty?
@@db.list_fields(@@table_name).eac... | true |
e707dab7c6f13fa8344d50906ccce73356da0968 | Ruby | thebravoman/software_engineering_2015 | /hm_count_words/A_3_Antonio_Mindov.rb | UTF-8 | 721 | 2.953125 | 3 | [] | no_license | require 'word_counter'
def site? str
str.start_with?("http://") || str.start_with?("https://")
end
def get_result input
if site? input
WordCounter.parse_webpage input
else
WordCounter.parse_file input
end
end
def print_result result, format
if format == 'json'
puts result.to_json
elsif format == 'xml'
... | true |
1e5aba20c625fc6d332678afc149bbd1330741bf | Ruby | avinashrahul/Data-Structures-Algorithms | /bubble_sort.rb | UTF-8 | 798 | 4.59375 | 5 | [] | no_license | # Every element in an array compares with adjacent element and if it is greater it swaps the two adjacent elements
# Ex: array = [1, 4, 2, 5, 3]
# [1, 2, 4, 5, 3]
# [1, 2, 4, 3, 5]
# [1, 2, 3, 4, 5]
def bubble_sort(array)
array_length = array.length
loop do
swapped = false
... | true |
01bf5b60ad3b1bf640f0425385aa1f908c939b98 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/word-count/ed886badf0364040889995d0d91404c0.rb | UTF-8 | 252 | 3.390625 | 3 | [] | no_license | class Phrase
def initialize(phrase)
@phrase = phrase.to_s
end
def phrase_array
@phrase.downcase.scan(/\w+/)
end
def word_count
phrase_array.each_with_object(Hash.new(0)) do |word, hash|
hash[word] += 1
end
end
end
| true |
1b6fbd8a4f546749529fefe1a270146174173b94 | Ruby | Robert-G-J/codewars | /getmiddle.rb | UTF-8 | 218 | 3.84375 | 4 | [] | no_license | def get_middle(s)
#find the length
n = s.length
#is it odd or even
puts n.even? ? s[(n/2)-1..(n/2)] : s[n/2]
#true returns the middle two characters
#odd returns the middle character
end
get_middle("Robosiod")
| true |
9c5b6ffccae612768b64fe9262fa147115dced6b | Ruby | miguelrosato/101_programming_foundations | /00 Lesson 2 Small Programs/00 Small Problems Exercises/05 Easy 5/07_letter_counter2.rb | UTF-8 | 687 | 4.1875 | 4 | [] | no_license | # Small Problems Exercises. Easy 5.
# 7.- Letter Counter. Part 2
# Write a method that takes a string with one or more space separated words and
# returns a hash that shows the number of words of different sizes, excluding non letters.
def word_sizes(str)
words_sizes = Hash.new(0)
str.split.each do |word|
c... | true |
d7bb7e32b633a0d65c6c16f7821de1de442bcf25 | Ruby | BaobabHealthTrust/lims_pre_post_analytical | /app/models/ward.rb | UTF-8 | 584 | 2.640625 | 3 | [] | no_license | class Ward < ApplicationRecord
def self.retrieve_wards
wards = Ward.find_by_sql("SELECT * FROM wards")
return wards
end
def self.add_ward(ward,category)
wrd = Ward.new
wrd.name = ward
wrd.category = category
wrd.save()
end
def self.check_ward(ward,category)
rst = Ward.find_by_sql("... | true |
60cc8c9030ea7f9108cf60f7826a6d407f67f05f | Ruby | sonyapieklik/kwk-l1-dance-instructions-kwk-students-l1-austin-072318 | /dance_instructions.rb | UTF-8 | 697 | 3.3125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive |
# Code your methods below
def starting_stance
puts "Plant legs far apart, bend knees slightly and keep posture loose"
end
def base_footwork
puts "Lift right foot
Return right foot to the ground
Finishing with a small skip-step backward"
end
def skip_step(name)
puts "Lower"
puts "Bounce"
... | true |
30a300ce37f148a9931dc06d6376bff765bb911e | Ruby | MeEgor/SmartSpace-1st-task | /db/seeds.rb | UTF-8 | 5,927 | 2.78125 | 3 | [] | no_license | # не нашел нормального способа сгенерировать seed
# В одном из проектов была задача по щелчку на карте яндекс определить адрес и координаты
# Немного переделав код получил удобный полуавтоматический инструмент для наполнения базы данных
addresses = [
{lat: 55.756277809171170 , lon: 37.594999519529540 , address: "Ска... | true |
eb55abc428aea133ef47a32aa2b81dc0e4780968 | Ruby | eslcomputertraining/nokogiri | /always_three_refactored.rb | UTF-8 | 121 | 3.1875 | 3 | [] | no_license | puts "What is your number?"
user_num = gets.chomp.to_i
gets = user_num
puts "the result is #{user_num+5*2-4/2-user_num}." | true |
706b16efeaed25d4c49b39fd7d4d570939280ce8 | Ruby | romansklenar/forecaster | /app/models/company.rb | UTF-8 | 2,054 | 2.53125 | 3 | [] | no_license | class Company < ActiveRecord::Base
include ActionView::Helpers
has_many :messages, dependent: :destroy
has_many :stocks, dependent: :destroy
has_many :classifications, dependent: :destroy
validates :name, :code, :messages_url, :stocks_url, presence: true
validates :code, uniqueness: true
... | true |
b0cc48a04642c57ff5abd7fa4ec4d91226d28281 | Ruby | crywolfe/buggy-bus-app | /spec/models/gotobus_scraper_spec.rb | UTF-8 | 886 | 2.5625 | 3 | [] | no_license | require 'spec_helper'
describe GotobusScraper do
let(:scraper) { GotobusScraper.new }
it "returns an array of schedules" do
url = 'spec/test_sources/apostrophe_test.html'
scraper.url = url
# results = GoToBusScraper.search({date: "2014-04-30", bus_to: "New York", bus_from: "Philadelphia"})
results ... | true |
187e133bb01594d6cf3ebdf2f82e2ffd8865eab3 | Ruby | Davidslv/bitrunner | /lib/bitmap_editor/errors/out_of_boundaries_error.rb | UTF-8 | 436 | 2.640625 | 3 | [] | no_license | # frozen_string_literal: true
module BitmapEditor
module Errors
class OutOfBoundariesError < StandardError
def initialize(bitmap, x, y)
super(
%(
Coordinates X: #{x} and Y: #{y} are out of the bitmap boundaries,
coordinate X should be between 0 and #{bitmap.width}
... | true |
fd923fc34d09dc718e65d81c7aa2a53897687adf | Ruby | javrodri42/discovery_piscine_ruby | /ruby06/ex00/hello_all.rb | UTF-8 | 74 | 2.640625 | 3 | [] | no_license | #!/usr/bin/env ruby
def hello
puts "¡Hola a todos!"
end
hello() | true |
e1888c22c199f2d0795a119fa65c8e837cb3a8d6 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/cs169/combine_anagrams_latest/2521.rb | UTF-8 | 280 | 3.28125 | 3 | [] | no_license | def combine_anagrams(words)
result = []
sorted_words = {}
words.map do |word|
key = word.downcase.chars.sort.join
if sorted_words.has_key?(key)
sorted_words[key] << word
else
sorted_words[key] = [word]
end
end
sorted_words.values
end
| true |
37fd030a0dc31137f9fc8697207fd8ce7819fbfb | Ruby | mconiglio/memcached_ruby_server | /lib/memcached/connection.rb | UTF-8 | 1,347 | 3 | 3 | [] | no_license | require File.expand_path('../request_parser', __FILE__)
require File.expand_path('../commands', __FILE__)
# This class accepts and responds the incoming requests of
# the clients and stores the timestamp of each get/gets
# request
class Connection
attr_accessor :memcached, :client, :fetched_records_time
# Creates... | true |
e55a12d6565fe8443d2ad81a5db0854547873fa9 | Ruby | jjromeo/boris_bikes | /spec/bike_container_spec.rb | UTF-8 | 1,494 | 3.265625 | 3 | [] | no_license | require 'bike_container'
class ContainerHolder; include BikeContainer; end
describe BikeContainer do
let(:bike) { double "bike", class: Bike}
let(:holder) { ContainerHolder.new }
let(:van) {double "van"}
it "should accept a bike" do
expect(holder.bike_count).to eq(0)
holder.dock(bike)
expect(holder.bike... | true |
a0314f348a91c2019e35e0e61b134689398ff6f8 | Ruby | huezoaa/SimonSays | /game_mo_memory.rb | UTF-8 | 2,315 | 4.09375 | 4 | [] | no_license |
#The computer's sequence of lights.
#Does not clear through execution
mo = []
#The player's sequence of lights. Clears on every loop
your_entry = []
#Counter that increases with every loop.
#used to display level and add new index to mo array.
level = 0
# the colors array holds the names of th... | true |
46971592f21d2a15f1cb96f8c71075b87dd64cbe | Ruby | Mervodactyl/bejeweled | /learn_to_programme/loops/grandma.rb | UTF-8 | 504 | 3.59375 | 4 | [] | no_license |
# def grandma
puts "Say Hello to your Grandmother:"
hello = gets.chomp
while hello != hello.upcase
puts "HUH?! SPEAK UP SONNY!!!!"
hello = gets.chomp
end
puts "NOT SINCE " + rand(1929..1950).to_s + "!!!!"
puts "ITS'S NICE TO SEE YOU LASS!!! BUT TIME TO SAY GOODBYE!!! SO SAY BYE!!!"
far... | true |
140465d213cb691bf6121db0f48d3677ef9c69e9 | Ruby | brettshollenberger/ruby_challenges | /square_code/lib/square_encoder.rb | UTF-8 | 611 | 3.546875 | 4 | [] | no_license | class SquareEncoder
attr_accessor :msg, :count, :line_length, :square
def initialize(msg)
@msg = msg.split.join
@count ||= @msg.length
@line_length ||= Math.sqrt(@count).ceil
@square ||= (1..@line_length).to_a.map { |line| take_line unless @msg.length == 0 }.compact!
end
def take_line
@ms... | true |
7ffc523885ec2f0bfe81e800098071d90a3e2d73 | Ruby | crazydays/crazydays | /ruby.edu/deck/eval/card_sort.rb | UTF-8 | 1,441 | 3.265625 | 3 | [] | no_license | require 'card'
module CardSort
def CardSort.by_suit(unsorted)
by_suit = Hash.new {|h, k| h[k] = []}
unsorted.each {|c| by_suit[c.suit] << c }
by_suit
end
def CardSort.by_value(unsorted)
by_value = Hash.new {|h, k| h[k] = []}
unsorted.each {|c| by_value[c.value] << c }
by_value
end
d... | true |
38fad46d139465390afbf13c34de65e2b5e10750 | Ruby | jacahn/landlord | /app.rb | UTF-8 | 1,354 | 2.65625 | 3 | [] | no_license | require 'sinatra'
require 'sinatra/reloader'
require "pg" # postgres db library
require "active_record" # the ORM
require "pry"
require_relative "db/connection"
require_relative "models/apartment"
require_relative "models/tenant"
get '/' do
redirect '/apartments'
end
# List out all apts
get '/apartments' do
@apa... | true |
ccc843442c517b523e5eee2ccd954dae005842f7 | Ruby | bbatsov/volt | /lib/volt/extra_core/hash.rb | UTF-8 | 489 | 2.984375 | 3 | [
"MIT"
] | permissive | # module Hash
# class Indifferent < Hash
# def []=(key, value)
# super(convert_key(key), value)
# end
#
# def [](key)
# super(convert_key(key))
# end
#
# def key?(key)
# super(convert_key(key))
# end
#
# def fetch(key, *args)
# super(convert_key(key), *args)
# e... | true |
1bdfe63a1b810a8d5b435fd03b5711bdbdc63750 | Ruby | ashleywchu/test-first-ruby-master | /lib/12_rpn_calculator.rb | UTF-8 | 1,493 | 4.40625 | 4 | [] | no_license | class RPNCalculator
attr_accessor :stack
def initialize
@stack = []
end
# adds a number to the end of @stack
def push(n)
@stack << n.to_f
end
# takes the last element of the array and returns it
# if there is no element, returns "calculator is empty"
def pop
num = @stack.pop
raise "calculator is em... | true |
f9e8c08c949c825fee3628bcd87525c1db639db4 | Ruby | mindaslab/ilrx | /yaml_write.rb | UTF-8 | 151 | 2.6875 | 3 | [] | no_license | #!/usr/bin/ruby
# yaml_write.rb
require 'yaml'
require 'square_class'
s = Square.new 17
s1 = Square.new 34
squares = [s, s1]
puts YAML::dump squares
| true |
961235019b6a45f73882e884cb157da12b087e39 | Ruby | ArmandoSarmina/pingpong | /app/models/game.rb | UTF-8 | 1,059 | 2.765625 | 3 | [] | no_license | class Game < ActiveRecord::Base
belongs_to :player, class_name: "User", foreign_key: "player_id"
belongs_to :opponent, class_name:"User", foreign_key: "opponent_id"
MINIMUM_WINNING_POINTS = 21.freeze
WINNING_DIFFERENCE = 2.freeze
validates :date_played,
:opponent,
:player,
:other_score,
:my_score,
pres... | true |
e9d1f38228701612e2e8309cdae5751fcb942cb1 | Ruby | gmosx/nitro_ruby | /lib/web/mixins/pager.rb | UTF-8 | 1,027 | 2.671875 | 3 | [] | no_license | require "stdx/uri/update_query"
module Web
# A simple pagination helper. Calculates the sql limit clause.
# We avoid count(*) for scalability reasons.
module Pager
PAGER_PARAM = "po"
private
#--
# We check if the collection has limit+1 objects (show prev then).
#++
def paginate(collection_... | true |
119f7428f0127696d7dcf87d9d52e180aa129363 | Ruby | MeganeFu/exercices_ruby2 | /lib/01_pyramids.rb | UTF-8 | 863 | 3.734375 | 4 | [] | no_license | puts "Salut, bienvenue dans ma super pyramide ! Combien d'étages veux-tu ? (entre 1 et 25)"
print ">"
nb = gets.chomp.to_i
puts "Voici la pyramide :"
i = 1
while i < nb + 1 || nb >= 25 do
print " "*(nb-i)
puts "#"*i
i = i + 1
end
puts "Salut, bienvenue dans ma super pyramide ! Combien d'étages veux-tu ?"
prin... | true |
bfac22167cee94922a6450ca18a543ed3381f3c3 | Ruby | piromi0940/crawling_task | /app/models/concerns/crawling_tool.rb | UTF-8 | 600 | 2.609375 | 3 | [] | no_license | module CrawlingTool
class << self
def set_url_to_nokogiri(url)
Nokogiri::HTML(HTTParty.get(url))
end
def make_volunteer_element(vol,title,group,content,http,url,number)
{title: vol.css(title).text , group: vol.css(group).text,
content: vol.css(content).text, url: http + vol.css(url)[n... | true |
24102c65e177707aa5b46a126154b2f53036e149 | Ruby | jimlindstrom/InteractiveMidiImproviser | /improv/lib/beat_position_symbol.rb | UTF-8 | 1,226 | 3.234375 | 3 | [] | no_license | #!/usr/bin/env ruby
module Music
class BeatPosition
def to_symbol
validate
v = @beat
v *= [0, 1, 2, 3].length
v += [0, 1, 2, 3].index(@subbeat)
v *= Array(2..6).length
v += Array(2..6).index(@beats_per_measure)
v *= [1, 2, 4].length
v += [1, 2, ... | true |
8fd43d648f2d9fbd93a9c8d9f853e6a56171a6a6 | Ruby | joeworkmn/residence | /app/helpers/sessions_helper.rb | UTF-8 | 1,120 | 2.515625 | 3 | [] | no_license | module SessionsHelper
def sign_in(account)
cookies.permanent[:id] = account.id
if account.instance_of?(Staff)
cookies.permanent[:signed_in_as_staff?] = true
else
cookies.permanent[:signed_in_as_tenant?] = true
end
self.current_user = account
# Only staff can ... | true |
2ec3af02a019b14d80b6d5e1db087e032d54d385 | Ruby | preetishukla/oyster_card_problem | /spec/oyster_card/card_spec.rb | UTF-8 | 3,524 | 3.09375 | 3 | [] | no_license | require 'spec_helper'
describe Card do
let(:card) { described_class.new }
describe "initial state for card" do
it "should have default balance of 0" do
expect(card.balance).to eq(0)
end
end
describe "top up(amount)" do
before { card.top_up(30) }
it 'should successfully ... | true |
2de600d6010ac547b0ea8929a936f3cc4ddcaf53 | Ruby | PoloPro/flatiron_reads | /db/seeds.rb | UTF-8 | 2,117 | 2.609375 | 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 |
ef42c3397b43b5ead5af564d2de10f454d077ede | Ruby | MBennettLowe/RoR-Prepwork | /quiz_exercise2.rb | UTF-8 | 1,114 | 4.28125 | 4 | [] | no_license | #Describe the difference between ! and ? in Ruby. And explain what would happen in the following scenarios:
1. what is != and where should you use it?
#This symbol represents not equal. This comparison operator should be used when comparing if two operands are equal or not.
2. put ! before something, like !user_n... | true |
3770960b5e05f93e90fe52c82de5819064a2b712 | Ruby | johnSerrano/holbertonschool-higher_level_programming | /discover_ruby/manipulate_the_data.rb | UTF-8 | 390 | 2.59375 | 3 | [] | no_license | require 'httpclient'
require 'uri'
require 'json'
extheaders = {
'User-Agent' => 'Holberton_School',
'Authorization' => 'token f4f6caa6a3e5f5da491e42d6ee14708f325ad655'
}
client = HTTPClient.new
uri = URI.parse("https://api.github.com/search/repositories?q=language:ruby&sort=stars&order=desc")
result = client.get... | true |
30a62de960c4cc44b5f48daf31d34a7659545e10 | Ruby | kstephens/ss | /tool/asm-source | UTF-8 | 1,025 | 2.96875 | 3 | [] | no_license | #!/usr/bin/env ruby
class AsmSource
def initialize
@lines = { }
@files = { }
end
def file fileno
@files[fileno] or raise "no file number #{fileno}"
end
def file_lines file
@lines[file] ||= File.open(file).readlines
end
def show_line! file, lineno, pos
o = $stdout
o.puts " # #{fil... | true |
23c3e0c31fb3b3dfb35f6f8a1c69c5202a0b65a4 | Ruby | davidSoutarson/FIn-exercice-de-1-20-THP-plus-pyramide.rb | /thp_ruby/exo_12.rb | UTF-8 | 109 | 3.25 | 3 | [] | no_license | print "Entrée un nombre :"
nombre = gets.chomp.to_i
for nombre in 0..nombre
print "#{nombre}; "
end
| true |
1034c0a50c17a3ee0ac4058f13503410b6c46e3b | Ruby | Shanker511/pugbot-satellite | /robot/sphero-2.0/sdks/ruby-sphero-master/lib/sphero.rb | UTF-8 | 16,512 | 2.65625 | 3 | [
"MIT"
] | permissive | require 'sphero/request'
require 'sphero/response'
require 'thread'
require 'rubyserial'
class Sphero
FORWARD = 0
RIGHT = 90
BACKWARD = 180
LEFT = 270
DEFAULT_RETRIES = 3
attr_accessor :connection_types, :messages, :packets, :response_queue, :responses
class << self
def start(dev, &block)
re... | true |
ef7915f957d3571be57c9d499da22eba4e6afc51 | Ruby | Runefire32/rubypreparcours | /exo_09.rb | UTF-8 | 196 | 3.0625 | 3 | [] | no_license | puts "comment tu tapelles?"
print "> "
user_name = gets.chomp.capitalize
puts "quel est ton nom de famille?"
print "> "
last_name = gets.chomp.capitalize
puts "Bonjour #{user_name} #{last_name} !" | true |
a2e4d6bf699312bcee8c2ac6cb293fc5ea90fe2b | Ruby | igmarin/dynamic-programming | /lis_test.rb | UTF-8 | 401 | 3.09375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: false
require 'minitest/autorun'
require_relative 'lis'
describe 'LIS algorithm' do
it 'Should return 3' do
result = lis([3, 1, 8, 2, 5])
assert_equal 3, result
end
it 'Should return 5' do
result = lis([10, 22, 9, 33, 21, 50, 41, 60])
assert_equal 5, result
end
it ... | true |
4151597bc9ea8dca172810503919cd48605c6315 | Ruby | dblinn/shortly | /spec/short_url_spec.rb | UTF-8 | 2,978 | 2.609375 | 3 | [] | no_license | require_relative './spec_helper'
require_relative './mongoid_spec_helper'
require_relative '../models/short_url'
module Shortly
describe 'ShortUrl' do
let(:source_url) { 'http://www.nytimes.com' }
let(:short_url) { ShortUrl.find_or_create_by(source_url: source_url) }
describe '#scopes' do
it 'shou... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.