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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
c7afbd9973ce22ca7f7f5d02ca4ff453f3203d95 | Ruby | joshpson/guided-module-one-final-project-dc-web-042318 | /lib/tenant.rb | UTF-8 | 4,299 | 3.234375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain",
"MIT"
] | permissive | class Tenant < ActiveRecord::Base
has_many :leases
has_many :units, through: :leases
#CLASS METHODS
# Called by Lease.self_by_cli
# Allows user to choose tenant for new lease
# Prompts user to use an existing tenant or to create a new one.
def self.find_or_create_for_lease
puts "\n** Select Tenant f... | true |
f9dbbeb33d7c72d87a902755daecf1450a2a6e5d | Ruby | ysei/Pico | /lib/pico/bdb.rb | UTF-8 | 2,498 | 2.734375 | 3 | [] | no_license | require 'pico/tc_bdb'
module Pico
class InBDB < PicoTable
def self.read(*srcs)
picos = srcs.collect {|name| self.new(name, 'r')}
yield(*picos)
ensure
picos.each {|pico| pico.close}
end
def self.create(name)
pico = self.new(name)
pico.clear
yield(pico)
ensu... | true |
3c5eb1626002a44534f188856aa1a6f0889b4e6c | Ruby | mjroose/collections_practice-cb-000 | /collections_practice.rb | UTF-8 | 715 | 3.90625 | 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 {|a, b| a.length <=> b.length}
end
def swap_elements(array, index = 1, destination_index = 2)
first = array[index]
array[index] = array[destination_index]
array[... | true |
bd7ea56af33ab547134ececb34f61570f77d4a35 | Ruby | dgrebenyuk/courses | /softgroup/spec/lib/array_spec.rb | UTF-8 | 451 | 3.109375 | 3 | [] | no_license | require 'rails_helper'
require 'array.rb'
describe Array do
subject { [1, 2, 3, 1, 4, 5, 6, 1, 2, 3, 1, 2, 3, 3] }
it 'should return most frequent element' do
expect(subject.top).to be 1
end
it 'should return most frequent element if negative count was passed' do
expect(subject.top(-5)).to be 1
end... | true |
306753d6f68aeb778309e9afa2cacd4d0e293fdb | Ruby | seantarzy/ruby-object-initialize-lab-nyc-web-111819 | /lib/dog.rb | UTF-8 | 292 | 3.578125 | 4 | [] | no_license | require "pry"
class Dog
def initialize(dog_name, dog_breed = "Mutt")
@name = dog_name
@breed = dog_breed
end
def name=(dog_name)
@name = dog_name
end
def name
@name
end
def breed= (dog_breed)
@breed = dog_breed
end
def breed
@breed
end
end
spot = Dog.new("spot") | true |
737366ddbf2e05d5fe424ff21ec5f5789fba426d | Ruby | samhammond87/dlConstruction | /db/seeds.rb | UTF-8 | 1,458 | 2.578125 | 3 | [
"MIT"
] | permissive | # 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).
# timesheet_name = ["Sam", "Yee", "Tracy"]
if User.count == 0 && Timesheet.all.length == 0
User.creat... | true |
ef6fc8d358cdbf1949ad4fca5e5b48b60571e886 | Ruby | jcbantuelle/genderinfinity | /app/services/location_searcher.rb | UTF-8 | 892 | 2.765625 | 3 | [] | no_license | class LocationSearcher
attr_reader :address_coordinates
def initialize(search_form)
@address_coordinates = Geocoder.coordinates search_form.address
@search_radius = search_form.search_radius
@specialties = search_form.specialties
@service = search_form.service
end
def search
locations = L... | true |
551b517de544184ac6ceb27f24b2aae77e181e1e | Ruby | rails-decal/fa19-hw3-adinachen | /app/controllers/main_controller.rb | UTF-8 | 738 | 2.828125 | 3 | [] | no_license | require_relative '../services/weather_service'
class MainController < ApplicationController
def index
# Uncomment and pass a parameter to the get function
@w = WeatherService.get(params[:city])
if @w
@city = @w[:city].capitalize
@temperature = (9.0/5) * (@w[:temperature] - 273) + 32
end
... | true |
f70b6f52aeebdb57e5e89bdef848b403fe352ecc | Ruby | nofxx/chronic18n | /lib/chronic18n/translator.rb | UTF-8 | 675 | 2.84375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module Chronic18n
DICS = Dir[File.join(File.dirname(__FILE__), 'dics', '') + "*.yml"].reduce({}) do |h,y|
h.merge YAML.load(File.read(y))
end
class UnknownLanguage < StandardError; end
class Translator
def initialize(txt, lang)
@txt, @lang = txt, lang.to_s
end
def work
# Return... | true |
8c76584ac25745eede360ced2ac1a809977181df | Ruby | jzeimen/csci568 | /project04/similarity_metrics/distance.rb | UTF-8 | 3,943 | 3.84375 | 4 | [] | no_license | # Joe Zeimen
# Sept 17, 2011
# Data Mining CSCI568
#Project 4
# This file contains functions to measure distance between objects.
# Each function looks at 2 objects instance variables and calculates the distance between the
# values in those variables in different ways depending on the function.
#Given two object... | true |
c7fed3244c249118bd1a5f3b844394e338d2bebb | Ruby | alexpeattie/nitlink | /lib/nitlink/param_extractor.rb | UTF-8 | 1,357 | 3.109375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | module Nitlink
class ParamExtractor
QUOTED_VALUE = /\A"(.*)"\Z/m
QUOTED_PAIR = /\\./m
LEADING_OWS = /\A[\x09\x20]+/
TRAILING_OWS = /[\x09\x20]+\Z/
def extract(rest)
@rest = rest
parameter_strings = Splitter.new(rest).split_on_unquoted(';')
raw_params = parameter_strings.map do ... | true |
ce43c6e942e1b35fd8de31a5f54fe84d0c20a88e | Ruby | diego-sh/RubyOnRails | /ToaSystem2/app/models/usuario.rb | UTF-8 | 849 | 2.640625 | 3 | [] | no_license | require 'digest/sha1'
class Usuario < ApplicationRecord
before_save :upperCase
belongs_to :perfil, inverse_of: :usuario
has_one :persona, inverse_of: :usuario
#:encryptar password
def encrypt
self.Password= Digest::SHA1.hexdigest(self.Password)
end
def estadoActivo
self.Estado= "... | true |
80664676d85ed0a1fcb4ea5fa5d6262ffd7c3322 | Ruby | troessner/reek | /lib/reek/context/code_context.rb | UTF-8 | 5,461 | 2.65625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require_relative '../code_comment'
require_relative '../ast/object_refs'
require_relative 'statement_counter'
require 'forwardable'
module Reek
module Context
#
# Superclass for all types of source code context. Each instance represents
# a code element of some kind, and e... | true |
a024222274f68e5f8540a128fed87fb24c16ba28 | Ruby | sgg2123/dice-roll-ruby-prework | /dice_roll.rb | UTF-8 | 57 | 2.703125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def roll
arr = Array (1..6)
arr[rand(arr.length)]
end | true |
e7e2f79e6cceb1a682af65100b66d78b518320a6 | Ruby | rammazzoti2000/Advanced-Building-Blocks---Enumerables | /enumerables.rb | UTF-8 | 2,858 | 3.296875 | 3 | [
"MIT"
] | permissive | module Enumerable
def my_each
return to_enum(:my_each) unless block_given?
i = 0
size = self.size
while i < size
is_a?(Range) ? yield(min + i) : yield(self[i])
i += 1
end
self
end
def my_each_with_index
return to_enum(:my_each_with_index) unless block_given?
i = 0
... | true |
961255c953bd6fc7388bcab32254f77f76029f01 | Ruby | srahimi1/my-retail-api-endpoint-rails-sr | /app/models/current_price.rb | UTF-8 | 221 | 3.421875 | 3 | [] | no_license | class CurrentPrice
attr_accessor :value, :currency_code
def initialize(value, currency_code)
@value = value
@currency_code = currency_code
end
def is_numeric(value)
sprintf("%.2f",value.to_f) == value
end
end | true |
ddd08ea105559d4f1dc60757eca27e9439db1ac6 | Ruby | teixeir3/W2D2 | /employee/employee.rb | UTF-8 | 1,062 | 3.296875 | 3 | [] | no_license | class Employee
attr_reader :name, :title, :salary
attr_accessor :boss
def initialize(attributes = {})
defaults = {
:title => "Coder",
:salary => 100_000
}
attributes = defaults.merge(attributes)
@name = attributes[:name]
@title = attributes[:title]
@salary = attributes[:sal... | true |
3a6ae8249bad2c49d17a7b5d79f942b1bb75ee2c | Ruby | jacobkagon/ruby-oo-relationships-practice-blood-oath-exercise | /app/cult.rb | UTF-8 | 1,035 | 3.359375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Cult
attr_reader :name, :location, :founding_year, :slogan
@@all = []
def initialize(name, location, founding_year)
@name = name
@location = location
@founding_year = founding_year
@slogan = nil
@@all << self
end
def slogan=(slogan)
@... | true |
9b6264e39ceb63f1eda644b1045cea6f11be6268 | Ruby | dmhernandez2525/aA_homeworks | /w7/d3/HOMEWORK.RB | UTF-8 | 607 | 3.265625 | 3 | [] | no_license | class LruCache
attr_reader :cache, :max_length
def initialize(max_length)
@cache = []
@max_length = max_length
end
def count
@cache.count
end
def add(el)
if count < @max_length
add_with_room(el)
else
add_without_room(el)
end
end
def show
p @cache
end
def add_w... | true |
0bed12cccdb0ce2e68a7de4c5f1daafca314b190 | Ruby | NANCYVALDEBENITO/E9CP1A1 | /Ejercicio4.rb | UTF-8 | 270 | 3.96875 | 4 | [] | no_license | propiedades = { nombre: 'Beethoven', raza: 'San Bernardo', color: 'Café' }
class Dog
attr_reader :hash
def inizialize
@hash = hash
end
def ladrar(hash)
puts "#{hash[:nombre]} está ladrando!"
end
end
dog_name = Dog.new
dog_name.ladrar(propiedades)
| true |
19b9447e26be1468e1ccc206b8f0a88cfc32b02c | Ruby | QBFreak/NightMAREbot | /sbin/newsbot/plugins/status.rb | UTF-8 | 1,169 | 2.515625 | 3 | [] | no_license | =begin
These plugins deal with monitoring status
as well as changing notification levels.
=end
Command.new do
name "Status"
desc "Shows basic status"
help <<-eof
This command shows you your basic status, including your notification and
message levels.
eof
syntax "+news status"
match(/^status/)
trigger do... | true |
44a96b8de531aae7a878eb3c758a0135e4591277 | Ruby | NicolePell/backgammon | /lib/board.rb | UTF-8 | 157 | 3.078125 | 3 | [] | no_license | class Board
attr_reader :points, :point
def initialize
@points = []
@point = point
end
def add_point(point)
points << point
end
end
| true |
29149d4ea4a6322c3d37c5e2fb6970282fb53840 | Ruby | solds-zz/programming-foundations | /lesson6/blackjack.rb | UTF-8 | 6,963 | 3.78125 | 4 | [] | no_license | # Twenty-One Game
def prompt(message)
puts "=> #{message}"
end
def reshuffle(deck)
deck.clear
faces = %w[Ace Two Three Four Five Six Seven Eight Nine Ten Jack Queen King]
suits = {
'Spades' => '♠',
'Clubs' => '♣',
'Diamonds' => '♦',
'Hearts' => '♥'
}
values = {
'Ace' => [1, 11], 'Two'... | true |
37823f4938dec923a65105c136b4a2ca29aa5f97 | Ruby | wordjames/learn-to-program | /chapter_6/deaf_grandma.rb | UTF-8 | 312 | 3.765625 | 4 | [] | no_license | bye = 0
while bye < 3
puts "What do you want to say to Grandma"
tell_grandma = gets.chomp
if tell_grandma == "BYE"
bye += 1
end
if tell_grandma != tell_grandma.upcase
puts "HUH!? SPEAK UP SONNY!"
else
puts "NO, NOT SINCE #{1929..1950}!"
end
end
while bye == 3
puts "BYE BYE, SONNY!"
break
end
| true |
5d050d695fc28a72960c0b3308f74a6436341e8c | Ruby | marsiox/math | /spec/perfect_spec.rb | UTF-8 | 582 | 3.265625 | 3 | [] | no_license | require 'spec_helper'
require_relative '../perfect'
describe Perfect do
describe "#divisors" do
it "returns all divisors of the number" do
perfect = Perfect.new
expect(perfect.divisors(36)).to eq([1,2,3,4,6,9,12,18])
end
end
describe "#summarize" do
it "sum all numbers in an array" do
... | true |
9118e6a1d315ed123f42d91b948d879091086317 | Ruby | ericirel/word_counter | /hw8.rb | UTF-8 | 6,376 | 4.15625 | 4 | [] | no_license | ###returns the text block in hashes w/ word count###
####################################################
def number_of_words(text_block)
words = text_block.split(' ')
frequency = Hash.new(0)
words.each { |word| frequency[word.downcase] += 1 }
return frequency
end
puts number_of_words("You know the first attra... | true |
a979f02a0fd5d6b12c5d5b157de1dbf0a0ffa938 | Ruby | virtual-void/mars-rovers | /lib/mars_rovers/position.rb | UTF-8 | 450 | 3.28125 | 3 | [] | no_license | module MarsRovers
module Compass
class Position
attr_accessor :x, :y
def initialize(x, y)
@x = x
@y = y
end
def add(position)
@x += position.x
@y += position.y
self
end
def to_s
"#{@x} #{@y}"
end
end
TO_NORTH = P... | true |
ae0081ad49073c6b0a6eac7d3b14000715f37ede | Ruby | glebmasyutka/ascii-table-converter | /lib/formatter.rb | UTF-8 | 779 | 3.21875 | 3 | [] | no_license | class Formatter
attr_reader :parser
FORMAT_TYPES = %w(
int
string
money
).freeze
def initialize(parser:)
@parser = parser
end
def format
validate_types
parser.each_row.to_a.each do |row|
types.each do |type|
row[type] = send("format_#{type}_type", row[type])
e... | true |
2981eb133b24cb42025956f399a904b41b307f68 | Ruby | sumoist/basic_course | /Lesson_6/train.rb | UTF-8 | 2,016 | 3.46875 | 3 | [] | no_license | class Train
include Company
include Validator
attr_reader :number, :carriages, :speed
@@trains = {}
TRAIN_NUMBER = /^[а-яёa-z0-9]{3}-?[а-яёa-z0-9]{2}$/i
def initialize(number)
@number = number
@carriages = []
@speed = 0
@@trains[@type] = { number => self }
validate!
end
def spee... | true |
b76b9ae01f63f4e70016233b6033747c74911cca | Ruby | aravi3/Projects | /W2D4/time_complexity.rb | UTF-8 | 976 | 3.71875 | 4 | [] | no_license | def my_min(list)
list.each_index do |i|
smallest = true
list.each_index do |j|
next if i == j
smallest = false if list[j] < list[i]
end
return list[i] if smallest
end
end
def my_min2(list)
min = Float::INFINITY
list.each do |num|
if num < min
min = num
end
end
m... | true |
f21f1a1567cb7a69c3fa084d18fb170dcf248ae0 | Ruby | katelyn-jms302/JMS-302 | /exercises/mid term/grades.rb | UTF-8 | 479 | 3.859375 | 4 | [] | no_license |
def get_grade
puts "Enter a grade or type 'done'."
grade= gets.chomp
grade
end
def calculate_average(grades)
total = 0
grades.each do |grade|
total += grade = total = total + grade
end
total/grades.size
end
puts "Please enter your name"
name= gets.chomp
grades = []
while true
... | true |
bf5d3afd51f640a0250924c2218e337021fcd26a | Ruby | abdrasulov/sales-taxes | /taxes_manager.rb | UTF-8 | 367 | 2.890625 | 3 | [] | no_license | class TaxesManager
def self.get_tax_rate(product)
import_duty = product.include?('imported') ? 0.05 : 0
product.sub! /imported\s+/, ''
basic_sales_tax = is_exempt?(product) ? 0 : 0.1
(basic_sales_tax + import_duty).round(2)
end
def self.is_exempt?(product)
['book', 'food', 'medical product'... | true |
6afbe482f009307f76953cc12e7721f70e396449 | Ruby | fujitatks/movie_review | /scraping_title.rb | UTF-8 | 209 | 2.515625 | 3 | [] | no_license | require 'mechanize'
agent = Mechanize.new
pagen1 = "http://review-movie.herokuapp.com"
page = agent.get(pagen1)
elements = page.search('h2.entry-title a')
elements.each do |ele|
puts ele.inner_text
end
| true |
fff0bee8ede55f3f546a34f1591ece2ba9e8b8c7 | Ruby | Aidanmills03/Launch-Ruby-Book | /Chapter_1/Exercise_1.rb | UTF-8 | 525 | 3.390625 | 3 | [] | no_license | # puts "Aidan " + "Mills"
# puts 15.0 / 3.0
movies = { Step_Brothers: 2008,
Austin_Powers: 1999,
Waynes_World: 1992 }
puts movies [:Step_Brothers]
puts movies [:Austin_Powers]
puts movies [:Waynes_World]
dates = [2008, 1999, 1992]
puts dates [0]
puts dates [1]
puts da... | true |
a5f57fad6d973d2f4f0a14e39b2cfe31f3947671 | Ruby | lucanioi/exercism-ruby | /poker/hand.rb | UTF-8 | 731 | 3.53125 | 4 | [] | no_license | require_relative 'poker_hands'
require_relative 'card'
class Hand
include Comparable
attr_reader :cards, :str_array, :score
def initialize(str_array)
@cards = create_cards(str_array).map(&:freeze)
validate_size!
@score = PokerHands.calculate_score(self)
freeze
end
def <=>(other)
score ... | true |
10c85cfecafa04f13c6a0591d2b5968a16edfc82 | Ruby | musgravejw/compiler | /src/semantic.rb | UTF-8 | 1,337 | 3.296875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/ruby
# semantic.rb
# John Musgrave
# Abstract: Creates a symbol table for use in scope and type checking
dir = File.dirname(__FILE__)
require "#{dir}/runtime.rb"
class SymbolTable
def initialize
r = Runtime.new
@table = []
@table << r.load_runtime_symbol_table
@table << {}
... | true |
70a83cfc0271fca12ed8f3da438ea849eb529320 | Ruby | masayasviel/algorithmAndDataStructure | /EducationalDPContest/mainA_get.rb | UTF-8 | 309 | 2.875 | 3 | [] | no_license | INF = 1 << 50
N = gets.chomp.to_i
h = gets.chomp.split.map(&:to_i)
dp = Array.new(N+1, INF)
dp[0] = dp[1] = 0
dp[2] = (h[1] - h[0]).abs
(3..N).each do |cur|
dp[cur] = [
dp[cur],
(h[cur-1] - h[cur-3]).abs + dp[cur-2],
(h[cur-1] - h[cur-2]).abs + dp[cur-1]
].min
end
puts dp[N] | true |
e2f28cfa030881fd97dce26e451cf032fefcd6b7 | Ruby | soffes/where-archive | /app.rb | UTF-8 | 1,192 | 2.515625 | 3 | [] | no_license | require 'sinatra'
require 'sinatra/content_for'
require 'json'
require 'date'
class Application < Sinatra::Base
helpers Sinatra::ContentFor
get '/' do
erb :index
end
get '/points.json' do
content_type :json
{
type: 'FeatureCollection',
features: [
{
type: 'Feature',... | true |
f42fabf479471433bbfef6c6de586b0983f0d2ad | Ruby | tylergreen/leapfrogAPI | /spec/customer_spec.rb | UTF-8 | 352 | 2.71875 | 3 | [
"MIT"
] | permissive | require 'minitest/spec'
require 'minitest/autorun'
require 'leapFrogAPI/customer'
describe Customer do
describe "initialize" do
it "should have accessors for income, zipcode, and age" do
c = Customer.new(100, 60606, 29)
assert_equal(c.income, 100)
assert_equal(c.zipcode, 60606)
assert_equ... | true |
c31e44f6b193f648e0156d2aeec5f6c1de283785 | Ruby | liftiuminc/dashboard | /app/models/event_recorder.rb | UTF-8 | 2,069 | 2.90625 | 3 | [] | no_license | class EventRecorder
MEMCACHE_READ_OPTIONS = {:raw => true}
MEMCACHE_CONFIG_PATH = File.join(File.dirname(__FILE__), '../../config/memcached.yml')
class << self
def read(key)
get_cache.read(key, MEMCACHE_READ_OPTIONS)
end
def record(event, rotation = "hour", lifetime = nil)
ensure_cache_k... | true |
f860910554980a05c150f53b2c0f08857bb109db | Ruby | jamestunnell/oopm | /spec/assembly/send_msg_spec.rb | UTF-8 | 1,211 | 2.671875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe OOPM::Assembly::SendMsg do
it "should take expected values for reciever and method" do
a = OOPM::Assembly::SendMsg.new :x, :do_this
a.reciever.should eq(:x)
a.method.should eq(:do_this)
end
it "should convert method argume... | true |
256fa7f6c118d05f1a3f7111c5015fc6cb5462ab | Ruby | uranussg/aA_classwork | /W4D2/chess/board.rb | UTF-8 | 967 | 3.71875 | 4 | [] | no_license | require_relative "piece"
class Board
attr_reader :board
def initialize
@board = Board.new_board
end
def self.new_board
top_pieces = Array.new(2) {Array.new(8) {Piece.new}}
bo_pieces = Array.new(2) {Array.new(8) {Piece.new}}
middle = Array.new(4) {Array.new(8) {NullPiece.new}}
top_p... | true |
ff606f72e38dff177c21c47a77545dfded5a59eb | Ruby | memunyawiri/commandos | /spec/mv_spec.rb | UTF-8 | 3,923 | 2.65625 | 3 | [] | no_license | require 'mv'
describe Mv do
subject(:mv) { described_class.new }
let!(:filename) { 'tips/mv.txt' }
let!(:tips) { mv.tips }
describe 'initialization' do
it 'throws an error if the tip file does not exist' do
expect { Mv.new('nonexistent_mv.txt') }.to raise_error(Errno::ENOENT)
end
it 'loads ... | true |
1ccf666bc9293160df8b71dfea4c11835da3174f | Ruby | Frapso/Ruby_on_Rails2.1 | /Ruby2.1.0/lib/ruby/gems/2.1.0/gems/sprockets-3.0.0.beta.8/lib/sprockets/autoload_processor.rb | UTF-8 | 1,197 | 2.796875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module Sprockets
# Internal: Used for lazy loading processors.
#
# Libraries should not use lazily loaded processors. They are only needed
# internally by Sprockets since it has optionally dependencies such as
# CoffeeScript that may not be available in the gem environment.
class AutoloadProcessor
# Ini... | true |
a3543bb6342e454a35356ab00423f2a85713353d | Ruby | ryanoglesby08/BootCamp | /Rectangle/square_test.rb | UTF-8 | 209 | 2.734375 | 3 | [] | no_license | require 'test/unit'
require 'square'
class SquareTest < Test::Unit::TestCase
def test_should_get_area_of_square
side = 2
square = Square.new(side)
assert_equal 4, square.area
end
end | true |
14c5a8276fe274dbbb0ea2f0ac96afc156a99284 | Ruby | CoderlikeTea/aiLog | /log/software/logstash/logstash-2.4.1/vendor/bundle/jruby/1.9/gems/logstash-filter-syslog_pri-2.0.4/lib/logstash/filters/syslog_pri.rb | UTF-8 | 2,755 | 2.546875 | 3 | [
"Apache-2.0"
] | permissive | # encoding: utf-8
require "logstash/filters/base"
require "logstash/namespace"
# Filter plugin for logstash to parse the `PRI` field from the front
# of a Syslog (RFC3164) message. If no priority is set, it will
# default to 13 (per RFC).
#
# This filter is based on the original `syslog.rb` code shipped
# with logsta... | true |
519c201d173c063137e22507d8213e9d5b97bb86 | Ruby | pathbox/A-bit-of-ruby-code | /grape_trailblazer_carrierware.rb | UTF-8 | 1,941 | 2.578125 | 3 | [] | no_license | gem 'grape' # or web framework you use
gem 'trailblazer'
gem 'carrierwave'
# app/api/v1/endpoints/user.rb
module V1
module Endpoints
class Users < Grape::API
desc 'Upload profile picture for the Current User'
params do
requires :picture, type: Rack::Multipart::UploadedFile, desc: 'Profile picture'... | true |
32e4d6ad577b402b3e0eeaee7b942246e0626824 | Ruby | Woumpousse/KHL | /Algo1/exercises/test-based/binary/minify.rb | UTF-8 | 123 | 2.984375 | 3 | [] | no_license | def minify(str)
str.gsub(%r{/\*.*?\*/}m, "").gsub(/\s{2,}/, ' ').gsub(/ ?(\W) ?/) do $1 end
end
puts minify(STDIN.read)
| true |
088fc5a3250f1ea6991ebfa84d81847658740492 | Ruby | xpac27/SeekThemUp | /game/text.rb | UTF-8 | 1,640 | 2.96875 | 3 | [] | no_license | class Text
def initialize file
sfont = SFont.new file
@letters = {}
SFont::default_glyphs.each{|item|
surface = sfont.render(item)
#surface.set_colorkey [0,0,0,255] # attempt to force colorkey
#surface = surface.to_display_alpha # attempt to force alpha
@letters[item] = {
... | true |
10eff6a448db9162e74bf884c17381091844a73c | Ruby | harpreetsingh500/challenges | /sieve/sieve.rb | UTF-8 | 266 | 3.59375 | 4 | [] | no_license | class Sieve
attr_reader :numbers
def initialize(range)
@numbers = [*2..range]
end
def primes
primes = [2]
while numbers != []
numbers.keep_if { |num| num % primes.last != 0 }
primes << numbers.shift
end
primes
end
end
| true |
83286aa9e5494193280954f84cca86e450162929 | Ruby | tk0358/Refactoring_Ruby | /chapter7/7.5/sample1_after1.rb | UTF-8 | 466 | 3.421875 | 3 | [] | no_license | class Person
attr_accessor :department
def manager
@department.manager
end
attr_reader :name
def initialize(name)
@name = name
end
end
class Department
attr_reader :manager
def initialize(manager)
@manager = manager
end
#...
end
john = Person.new('John')
bri... | true |
09017005ed8a7ff8049748fc0e0334c877d1afa7 | Ruby | bcgianni/roomba | /spec/roomba/hoover_spec.rb | UTF-8 | 9,145 | 2.84375 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe Roomba::Hoover do
let(:initial_position) { [1, 2] }
let(:expected_ini_position) { { x: 1, y: 2 } }
let(:set_of_commands) { ['NNEESSWW'] }
let(:dimension) { [3, 3] }
let(:list_of_dirt) { [%w(1 2), %w(2 1)] }
let(:room) { Roomba::Room.new(dimension, list_of_dirt) }
let(:hoove... | true |
a4f9c9be3bcd6a2cf225609f8e1fff2ab2cb489c | Ruby | philipnrmn/Advent-Of-Code-Polyglot | /ruby/03/part1.rb | UTF-8 | 460 | 3.71875 | 4 | [] | no_license | #!/usr/bin/env ruby
require 'set'
# monkey-path the Array class
class Array
def move!(c)
if c == '^'
self[1] = self[1] + 1
elsif c == 'v'
self[1] = self[1] - 1
elsif c == '>'
self[0] = self[0] + 1
elsif c == '<'
self[0] = self[0] - 1
end
end
end
set = Set.new
input = ... | true |
4f20902d28636c6eacddd25e60849a88a06e7733 | Ruby | thiagoramos23/growing-oo-software-in-ruby | /src/11-passing-first-test/external/swing.rb | UTF-8 | 478 | 2.734375 | 3 | [] | no_license | module SwingUtilities
def self.invoke_and_wait(&block)
thread = Thread.new do
block.call
end
thread.join
end
def self.invoke_later(&block)
Thread.new do
Thread.pass # This is the "later" part.
block.call
end
end
end
class JFrame
Widget_map = {}
def name=(name)
... | true |
8311e207ca3a652cdcea18db27da31edbc889006 | Ruby | antani/grabber | /app/models/topmovies.rb | UTF-8 | 3,739 | 2.734375 | 3 | [
"Apache-2.0"
] | permissive | class Topmovies
class << self
#@@logger = Logger.new(STDOUT)
def parse_flipkart(page)
begin
prices=[]
#@@logger.info("Parse Flipkart")
##@@logger.info(page)
name_text = page.search("div.lastUnit div... | true |
38861573bc1a48818e34f98c5df350f1885f2676 | Ruby | jrobertson/gogreen | /lib/gogreen.rb~ | UTF-8 | 2,447 | 2.6875 | 3 | [] | no_license | #!/usr/bin/env ruby
# file: gogreen.rb
require 'rscript'
require 'dynarex'
require 'acronym'
require 'polyrex'
require 'tempfile'
class GoGreenException < Exception
end
class GoGreen
def initialize(alias_file, site=nil, subdomain=nil, shell_execute: true)
@shell_execute = shell_execute
buffer = RXFHelp... | true |
2e5c730058eb311fbaba278f35d9ee7f726dc308 | Ruby | jsanchy/launch-school-exercises | /small_problems_ruby/easy6/delete_vowels.rb | UTF-8 | 532 | 3.875 | 4 | [] | no_license | VOWELS = %w(a e i o u A E I O U)
def remove_vowels(strings)
strings.map do |string|
no_vowels = ''
counter = 0
loop do
no_vowels << string[counter] unless VOWELS.include?(string[counter])
counter += 1
break if counter == string.length
end
no_vowels
end
end
puts... | true |
0c1792cc934febd043814da1d32ada0dcee99e75 | Ruby | Arique1104/enigma_v2 | /test/enigma_test.rb | UTF-8 | 969 | 2.921875 | 3 | [] | no_license | require "./test/test_helper"
require "./lib/enigma"
require "./lib/offset"
require "./lib/key"
class EnigmaTest < Minitest::Test
def setup
@enigma = Enigma.new
end
def test_it_exists
assert_instance_of Enigma, @enigma
end
def test_it_has_alphabet_array
expect = ["a", "b", "c", "d", "e", "f"... | true |
c501b2bd947c47db46161463e877e8b6303265de | Ruby | kadrianne/algorithm-practice | /linked-list/LinkedList.rb | UTF-8 | 481 | 3.65625 | 4 | [] | no_license | require 'pry'
class Node
attr_reader :value
attr_accessor :next
def initialize(value)
@value = value
@next = nil
end
end
class LinkedList
attr_reader :head, :tail
def initialize
@head = nil
@tail = nil
end
def append(value)
new_node = Node.new... | true |
d0210b48e2dbdd2d5745a8ec2f52965a80778de3 | Ruby | 0x000000/advocate | /spec/contract_violation_spec.rb | UTF-8 | 2,031 | 2.609375 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe Advocate::ContractViolation do
context 'when constructed' do
context 'for messages without additional data' do
let(:error) { Advocate::ContractViolation.new :should_be_present, :result, nil, nil }
let(:expected_reason) { /Result should be present./ }
let(:expected... | true |
9c123dbbbb4e5b5aaaf2aeb45895cf17b2bb33f3 | Ruby | kclunie/ruby-advanced-class-methods-lab-v-000 | /lib/song.rb | UTF-8 | 1,072 | 3.140625 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class Song
attr_accessor :name, :artist_name
@@all = []
def self.all
@@all
end
def save
self.class.all << self
end
def self.create
s = self.new
s.save
s
end
def self.new_by_name(string)
s = self.new
s.name = string
s
end
def self.create_by_name(string)
s... | true |
b4a500b67db895769544c8f5ec529cc6eae1a503 | Ruby | abmcdubb/troop_hub | /app/models/official_badge_parser.rb | UTF-8 | 658 | 2.6875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class OfficialBadgeParser
html = File.read('./gs_site.html')
badge_list = Nokogiri::HTML(html)
badge_list.css("li").each do |b|
if b.attr('thetitle') != nil
badge = Badge.new
badge.logo = b.css('img').attr('src').text
if b.attr("thetitle") == "Women’s Health"
badge.na... | true |
37133f0c69e7a992632c73a2edeb3a6dcf41a87c | Ruby | yaauie/PFTT | /lib/options_hash.rb | UTF-8 | 940 | 3.15625 | 3 | [
"MIT",
"MS-PL"
] | permissive | # Lazily store things, build the hash as we go using
# multi-argument keys
class OptionsHash < Hash
def []= *key,value
key.map!{|i|i.to_s}
if key.size > 1
ky = key.shift
self[ky]||= self.class.new
self[ky][*key] = value
else
super *key,value
end
end
def [] *key
key.map!... | true |
eb3b0671a93968df2607447783aa9179f9787cf4 | Ruby | mathieujobin/murky_waters | /lib/murky/dict.rb | UTF-8 | 2,172 | 2.984375 | 3 | [] | no_license | module Murky
class Dict
include Enumerable
attr_reader :root
def initialize(data: {}, digest: Digest::SHA256.new)
@root = nil
@digest = digest
@changed = !data.size.zero?
define_singleton_method(:data, ->{data})
end
def ==(other)
other.respond_to?(:data) && data... | true |
def90c8165b5d5ba23c9738e23b5e8e6342460fd | Ruby | bhabig/food-stand | /lib/food_truck.rb | UTF-8 | 663 | 3.34375 | 3 | [] | no_license | class FoodTruck
attr_accessor :name, :hours
@@all = []
def initialize(name, items=nil, hours)
@name = name
@items = []
self.add_to_menu(items) if items
@hours = hours
@orders = []
@@all << self if @@all.include?(self)
end
def self.all
@@all
end
def add_to_menu(items)
i... | true |
be1519c2baab9a0397f6f6de8e2c64ac9b9eaf8f | Ruby | dharnitski/7lang | /ruby/day102.rb | UTF-8 | 239 | 3.6875 | 4 | [] | no_license | #!/usr/bin/env ruby
if __FILE__ == $0
r = rand(10)
puts "Enter number from 0 to 9"
i = gets.to_i
puts "higher" if r > i
puts "you won" if r == i
puts "lower" if r < i
puts "Just in case. Number was #{r}"
end | true |
2269571382b26ef65f40a284524011d35b284676 | Ruby | jochambo/TicTacToe | /runner.rb | UTF-8 | 631 | 2.671875 | 3 | [
"MIT"
] | permissive | require 'dispel'
require_relative 'lib/ai'
require_relative 'lib/game'
require_relative 'lib/view'
Dispel::Screen.open do |screen|
game = Game.new
ai = AI.new(game)
view = View.new(game)
screen.draw(view.draw_screen)
Dispel::Keyboard.output do |key|
case key
when :up then view.move(0,-1)
when :... | true |
cf8497e65fc8034a5a5ef7244242c67fae98c2f2 | Ruby | albertbahia/wdi_june_2014 | /w02/d02/gadi_gottlieb/GoT_inheritance/lib/knight.rb | UTF-8 | 576 | 3.71875 | 4 | [] | no_license | require_relative 'human.rb'
class Knight < Human
attr_reader(:sword)
def initialize(name, house, sword)
super(name, house, 50)
@sword = sword
@hp = 500
@loyal = nil
end
def pledge_loyalty(king)
if king.class == King
@loyal = king
true
else
false
end
end
def... | true |
b5d93efc8c3456715e3a61d619a32ffb0d117ca3 | Ruby | spiceee/ifttt-api-example-with-tandas | /controllers/mobile_api_controller.rb | UTF-8 | 4,198 | 2.671875 | 3 | [
"MIT"
] | permissive | # This controller implements an API to be used by the example mobile apps. They
# need to be able to authenticate with a username and ask for a user token that
# they can then use to make calls to the IFTTT API.
class MobileAPIController < ApplicationController
# The mobile apps authenticate with a bearer token; for ... | true |
dc876dabcacb25b7d231dca3c9f96d3a1ff453c2 | Ruby | sooo-s/AtCoder | /dp/d/main.rb | UTF-8 | 485 | 2.828125 | 3 | [] | no_license | N, W = gets.chomp.split.map(&:to_i) # n = 10, m = 20
W_N = N.times.map { gets.split.map(&:to_i) } # [[1, 2], [3, 4], [5, 6]]
dp = (N + 1).times.map { [0] * (10**5 + 10) }
(1..N).each do |n|
(1...(10**5 + 10)).each do |w|
prev_v = dp[n - 1][w]
now_w, now_v = W_N[n - 1]
selectable = w < now_w
dp[n][w]... | true |
2be8f51235211254376936f2ba89eb14e5f9a564 | Ruby | fijiaaron/agilemetrics | /app/helpers/open_defects_helper.rb | UTF-8 | 2,243 | 2.671875 | 3 | [] | no_license | module OpenDefectsHelper
@@OPEN_DEFECTS_REPORT_NUMBER_OF_WEEKS = 52
@@DEFAULT_SPRINT_WEEKS = 2
# return all open defects reports for a project up to number (default is 52 weeks)
def open_defects_for_project(project, number=@@OPEN_DEFECTS_REPORT_NUMBER_OF_WEEKS)
OpenDefect.where(:project_id => project.id... | true |
34dba43d27b38bcdfe9e5ea60342f300ae924b2a | Ruby | schmurfy/guard-tilt | /lib/guard/tilt.rb | UTF-8 | 2,067 | 2.515625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'guard/guard'
require 'guard/watcher'
require 'tilt'
module Guard
class Tilt < Guard
DEFAULT_CONTEXT = Struct.new(:path)
DEFAULT_LOCALS = Hash.new({})
def self.output_path=(klass) @@path = klass; end
def self.root=(root) @@root = root; end
def self.root; @@root; end
def initialize... | true |
3a3649a1610742f167173ebc2fe503d10937a864 | Ruby | tedpark/TextToSqlite | /sql.rb | UTF-8 | 316 | 3.125 | 3 | [
"Apache-2.0"
] | permissive | require 'sqlite3'
file = File.new('books.txt') //sample
string = []
file.each_line do |line|
string << line
puts (line)
end
db = SQLite3::Database.new('books.sqlite') //sample
ins = db.prepare('insert into text (article) values (?)') //text = table, article = entity
string.each {
|s| ins.execute(s)
}
| true |
43cbe24b11d2434f3511453259517d438f8e4b6a | Ruby | amandamfielding/chess | /display.rb | UTF-8 | 784 | 3.390625 | 3 | [] | no_license | require_relative 'board'
require 'colorize'
require_relative 'cursor'
require 'byebug'
class Display
attr_reader :board
def initialize(board)
@cursor = Cursor.new([0,0],board)
@board = board
end
def render
puts " 0 1 2 3 4 5 6 7"
puts " ------------------------"
letters = (0..7... | true |
8db0e806a95e96f89017c572f48331797d475949 | Ruby | JamesKoenig/Aa_classWork | /W3D5/poly_tree_node/lib/00_tree_node.rb | UTF-8 | 1,221 | 3.703125 | 4 | [] | no_license | class PolyTreeNode
attr_reader :parent,:value, :children
def initialize(str)
@parent = nil
@children = []
@value = str
end
# reassign parent for children (children given )
def parent=(parent1)
if @parent == parent1
return
end
if @parent !=... | true |
91514ea9170e9610e109af0365ad54c40b733499 | Ruby | rich/dev-intro-to-ruby | /examples/three.rb | UTF-8 | 128 | 3.53125 | 4 | [] | no_license | [1,2,3].each do |i|
puts i
end
# => 1
# => 2
# => 3
[1,2,3,4].reject {|i| i.even?}.each do |i|
puts i
end
# => 1
# => 3 | true |
84b34c5575e8cd70ca9dcb61c170dcdf9f7471b7 | Ruby | ykz1/LS_101_foundations | /109_assessment_prep/lesson_5_examples/ex1.rb | UTF-8 | 1,248 | 4.59375 | 5 | [] | no_license | [[1, 2], [3, 4]].each do |arr|
puts arr.first
end
=begin
In `line1`, a nested array is intialized. Though the array object is created, there is no variable assigned to point to it.
Instead, we are immediately calling the method `each` on this array object. The block between `do/end` in `lines1-3` is passed as an ar... | true |
b165ff6efc86fbb9bca36f98adcb6ad4a139ea1c | Ruby | thinkybeast/ruby-exercises | /small_problems/med_2/med_2_5.rb | UTF-8 | 812 | 4.25 | 4 | [] | no_license |
# Write a method that takes the lengths of the 3 sides of a triangle as arguments, and returns a symbol :equilateral, :isosceles, :scalene, or :invalid depending on whether the triangle is equilateral, isosceles, scalene, or invalid.
def sum_of_sides(one, two)
one + two
end
def invalid?(sides)
sides.any? { |sid... | true |
4ded7d491e5edaef36e3a6cedc1e58237e61a5fc | Ruby | antoniojh10/integer-to-roman | /solution_for_leetcode.rb | UTF-8 | 921 | 3.5625 | 4 | [] | no_license | # @param {Integer} num
# @return {String}
def int_to_roman(num)
def to_roman_number(number, min_mid_max)
min = min_mid_max[0]
mid = min_mid_max[1]
max = min_mid_max[2]
case number.to_i
when 1..3
return min*number.to_i
when 4
return min + ... | true |
152188dcd4417fd70e2807b8835a3e397d0d3026 | Ruby | seijihg/ruby-objects-has-many-through-lab-london-web-060319 | /lib/run.rb | UTF-8 | 437 | 2.953125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require_relative "appointment.rb"
require_relative "patient.rb"
require_relative "doctor.rb"
require "pry"
jack = Doctor.new("Jack")
kelly = Doctor.new("Kelly")
aruna = Patient.new("Aruna")
annie = Patient.new("Anniemaria")
lawrence = Doctor.new("Lawrence")
scott = Patient.new("Scott")
jack.new_appointment(aruna, "Mo... | true |
f43017acf77ec9cac732b5b78937972db258859d | Ruby | adriacustico/RubyOnRails | /curso68/clase.rb | UTF-8 | 1,137 | 4.03125 | 4 | [] | no_license | class Usuario
#getters y setters
attr_accessor :nombre #getters and setters (obtener y setear)
attr_reader :apellido #getter
attr_writer :apellido, :password #setter
#def apellido=(valor)
# @apellido = valor
#end
#def apellido
# @apellido
#end
end
#i... | true |
81eedeb85ed18971182175aff713a1f978b7bf4c | Ruby | Atiqullah-Naemi/RubyonRailsCMS | /app/policies/user_policy.rb | UTF-8 | 192 | 2.578125 | 3 | [] | no_license | class UserPolicy
attr_reader :current_user, :model
def initialize(current_user, model)
@current_user = current_user
@user = model
end
def index?
@current_user.try(:admin?)
end
end | true |
ef84be44e0f7c595012808e909846d08604dd828 | Ruby | kbrock/freemium | /lib/freemium/gateways/brain_tree.rb | UTF-8 | 5,813 | 2.75 | 3 | [
"MIT"
] | permissive | require 'net/http'
require 'net/https'
module Freemium
module Gateways
# = Setup and Configuration
# In your config/initializers/freemium.rb, configure Freemium to use BrainTree:
#
# Freemium.gateway = Freemium::Gateways::BrainTree.new
# Freemium.gateway.username = "my_username"
# Freemi... | true |
a1dcddbc50912f15fa8a8f35117f494c33d265c2 | Ruby | LeniaMarga/weekend_homework_10_11_17 | /song.rb | UTF-8 | 135 | 2.984375 | 3 | [] | no_license | class Song
attr_accessor :song_name, :artist
def initialize (name, artist)
@song_name = name
@artist = artist
end
end
| true |
58034bfc9ed8d232aff8dd4615af54d55fcb65b0 | Ruby | leodcs/active_record_survey | /lib/active_record_survey/node/answer.rb | UTF-8 | 5,494 | 2.65625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module ActiveRecordSurvey
class Node::Answer < Node
# Answer nodes are valid if their questions are valid!
# Validate this node against an instance
def validate_node(instance)
# Ensure each parent node to this node (the goal here is to hit a question node) is valid
... | true |
2df6cdb1532776f31dddb7a2ec5123eb8c2d4cc7 | Ruby | torfri/NTI_PrrPrr01-Uppg5.1-5.16 | /raknare/num_to_int.rb | UTF-8 | 299 | 3.140625 | 3 | [] | no_license | require_relative 'isnumber'
def converter(talArr)
tal = []
while talArr.length > 0
if isOperator(talArr[0]) || isParantes(talArr[0])
tal.push(talArr[0])
else
tal.push(talArr[0].to_i)
end
talArr.delete_at(0)
end
return tal
end
| true |
6541a4b78b342300a0483884033f442b66a1749b | Ruby | botanicus/now-task-manager | /lib/pomodoro/formats/today.rb | UTF-8 | 1,651 | 2.625 | 3 | [] | no_license | # frozen_string_literal: true
require 'parslet'
# require 'parslet/convenience' # parse_with_debug
module Pomodoro
module Formats
# {include:file:doc/formats/today.md}
module Today
# TODO: spec me.
class DataInconsistencyError < StandardError
end
# The entry point method for parsing... | true |
86ef8f86c0698302303f42b6291b2a8de08f7698 | Ruby | estryker/MSS | /geo_event.rb | UTF-8 | 2,219 | 2.59375 | 3 | [] | no_license | class GeoEvent < ActiveRecord::Base
belongs_to :user, :primary_key => :user_email
numeric_regex = /^-?[0-9.]+$/
validates :latitude, :presence => true,
:format => {:with => numeric_regex},
:numericality => {:greater_than_or_equal_to => -90,:less_than_or_equal_to => 90}
validates :longitude, :p... | true |
01ea2bc9bf41040782fa84570fc8b9f37cbcbd4e | Ruby | jinzhu/enconverter | /lib/enconverter/enconverter.rb | UTF-8 | 1,787 | 2.765625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'iconv'
module Rack
class Enconverter
def initialize(app, options={})
@app, @convert = app, options[:convert]
end
def convert?(env)
@convert.is_a?(Proc) ? @convert.call(env) : true
end
def call(env)
convert = convert?(env)
scrub(env) if convert
status, hea... | true |
fa49379fba62754ae63791e6b80db6f939fd7096 | Ruby | Hossamhassancs/ruby-practice-problem-solving- | /rspec_exercise_2/lib/part_2.rb | UTF-8 | 815 | 3.875 | 4 | [] | no_license | def palindrome?(str)
len=str.length
(0...len/2).each do |i|
if str[i] != str[len-i-1]
return false
end
end
return true
end
def substrings(str)
new_arr=[]
str.each_char.with_index do |ch1,i1|
str.each_char.with_index do |ch2,i2|
if i2 == i1
... | true |
1dcafd900c8dcdfa5c0254550e9d278dc5f56281 | Ruby | cwy007/depot | /app/models/user.rb | UTF-8 | 1,690 | 2.71875 | 3 | [] | no_license | # == Schema Information
#
# Table name: users
#
# id :integer not null, primary key
# name :string
# hashed_password :string
# salt :string
# created_at :datetime not null
# updated_at :datetime not null
#
require 'digest/sha2'
class User < A... | true |
2abca09598db831e08a3b2eca93687bd4dfc1868 | Ruby | sa00445/fullstack-challenges-post-bootcamp | /01-Ruby/03-Iterators-Blocks/03-About-blocks/lib/block_gym.rb | UTF-8 | 407 | 2.875 | 3 | [] | no_license | def timer_for
# TODO: Return time taken to execute the given block
end
def my_map(array)
# TODO: Re-implement the same behavior as `Enumerable#map` without using it! You can use `#each` though.
end
def tag(tag_name, attributes = nil)
# TODO: Build HTML tags around content given in the block
# The method... | true |
0a8dc0aa7f189ada8b9a25d20f0ca14d9b6d7949 | Ruby | jasonkylemorse/exercism | /ruby/food-chain/food_chain.rb | UTF-8 | 207 | 2.890625 | 3 | [] | no_license | # assignment 14: food-chain
# author: Jason Morse
# date: June 14, 2015
#
class FoodChain
VERSION = 1
def self.song
song = File.open('song.txt').read
song.each_line { |line| "#{line}" }
end
end
| true |
b8e8e06d38c9801912f4c214e076d209c1b2d6cf | Ruby | greytape/backend | /101-109 /advanced_3.rb | UTF-8 | 944 | 4.59375 | 5 | [] | no_license | # # Problem
# - Creata a method that transposes a matrix, swapping the rows and columns
# - the original matrix should be unaffected
# - method should return new matrix
# # I/O
# input: array
# output: array
# # Logic
# - size of matrix is key
# - initialise new array with same number of nested arrays as input arr... | true |
332e469758d80862d2cfa5c878b2946c5fffcc8e | Ruby | channiemills/dcaf_case_management | /app/helpers/budget_bar_helper.rb | UTF-8 | 2,611 | 2.953125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # Functions to process data in the budget bar.
module BudgetBarHelper
def progress_bar_color(type)
color = type == :pledged ? 'warning' : 'success'
"bg-#{color}"
end
def progress_bar_width(value, cash_ceiling = Config.budget_bar_max)
"width: #{to_pct(value, cash_ceiling)}%"
end
def budget_bar_ex... | true |
b8cf6b71fab8cfc5e796305309d6cd321d49a92a | Ruby | jeremy04/poker_hand | /lib/app.rb | UTF-8 | 1,046 | 3.265625 | 3 | [] | no_license | require 'pp'
require './lib/royal_flush'
require './lib/straight_flush'
require './lib/four_of_kind'
require './lib/full_house'
require './lib/flush'
require './lib/straight'
require './lib/three_of_kind'
require './lib/two_pair'
require './lib/pair'
require './lib/high_card'
require './lib/player'
require 'byebug'
cl... | true |
480178e13a55023f8bb0b5d66cc43b585067e6db | Ruby | petermeglis/ruby | /theodinproject/mastermind/row.rb | UTF-8 | 1,480 | 3.328125 | 3 | [] | no_license | require_relative "peg"
class Row
SIZE = 4
HEIGHT = 1 + SIZE + 1 + (SIZE / 2) + 1
def initialize(pegs: Array.new(SIZE) { Peg.new(filled: false) }, feedback: Array.new(SIZE) { Peg.new(filled: false) })
@pegs = pegs
@feedback = feedback
@row_a = row_to_a
end
def update_pegs(pegs)
@pegs = pegs... | true |
ded4b8424969beb60e07620e1aef8fa42ef1a0ef | Ruby | fela/rlid | /lib/rlid/tmp.rb | UTF-8 | 824 | 2.921875 | 3 | [
"MIT-0"
] | permissive | module Rlid
def self.tmp_methods
@@tmp_methods
end
def self.tmp_methods= (val)
@@tmp_methods = val
end
@@tmp_methods = {}
end
class Module
def rlid_tmp_methods
Rlid.tmp_methods[self] = all_methods
end
def all_methods
public_methods + private_methods + protected_methods
end
end
class... | true |
df079386e1213531c3a5e4fbf07d7beb6972307d | Ruby | dmbf29/flow_array_543 | /bank.rb | UTF-8 | 516 | 3.03125 | 3 | [] | no_license | puts "What option would you like to do?"
puts "balance|hours|operator"
choice = gets.chomp
# if choice == 'balance'
# puts "checking..."
# elsif choice == 'hours'
# puts "checking..."
elsif choice == 'operator'
# puts "checking..."
# else
# puts "wrong option"
# end
case choice
when 'balance' then puts "check... | true |
0839254b0893b2277ee0879bdbcf7be88e47dd4f | Ruby | JordanHatch/colloquy-transcript-converter | /convert | UTF-8 | 936 | 2.53125 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'rubygems'
require 'bundler/setup'
require 'nokogiri'
require 'ostruct'
require 'time'
file_name = ARGV[0]
raise "Please specify a filename" if file_name.nil?
transcript_file = File.read(File.expand_path(file_name, File.dirname(__FILE__)))
transcript = Nokogiri::XML(transcript_file)
@ou... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.