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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
578935855a1af845bb8d3278dff9fa463dc8815f | Ruby | lest/enum_accessor | /spec/enum_accessor_spec.rb | UTF-8 | 1,693 | 2.796875 | 3 | [
"MIT"
] | permissive | # encoding: UTF-8
require 'spec_helper'
ActiveRecord::Base.connection.create_table :users, force: true do |t|
t.column :gender, :integer, default: 0
end
class User < ActiveRecord::Base
enum_accessor :gender, [ :female, :male ]
end
describe EnumAccessor do
before do
@user = User.new
end
it 'adds check... | true |
891c9876c5bd26df6cd70f5f1c80e6288cb68daa | Ruby | brent80/ruby-gem-downloads-badge | /lib/helper.rb | UTF-8 | 5,812 | 2.984375 | 3 | [] | no_license | # module that is used for formatting numbers using metrics
module Helper
# function that makes the methods incapsulated as utility functions
module_function
delegate :settings, :cookie_hash, :set_time_zone , to: :RubygemsDownloadShieldsApp
delegate :logger,:request_cookies, to: :settings
# Returns the display_type fr... | true |
9df2bab057cf26a8a4fc0ca718d52c7bb5e95f82 | Ruby | williamsjs/movie_drink | /app/models/movie.rb | UTF-8 | 1,087 | 2.5625 | 3 | [] | no_license | class Movie < ActiveRecord::Base
belongs_to :user
has_many :beers
validates :year, presence: true
after_create :create_beer
def beer
beers.first.id unless beers.empty?
end
def movie_json
get_movie(name.gsub(" ", "%20"))
end
def redo(user)
movie = movie_json
update(name: get_name(mov... | true |
1d0a30127d0309429543705ceaa1c863656d8a68 | Ruby | lydzb123/learn-co-sandbox | /ifEndPractice.rb | UTF-8 | 103 | 3.28125 | 3 | [] | no_license | puts "You know what year it is??"
this_year = 2019
puts "Hey, it's not 2019!" unless this_year == 2019 | true |
d96fc195afba35f37bf1a878ac28ddbc23cec139 | Ruby | jessegan/oo-student-scraper-onl01-seng-ft-052620 | /lib/scraper.rb | UTF-8 | 1,199 | 3.09375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'open-uri'
require 'pry'
class Scraper
def self.scrape_index_page(index_url)
index = Nokogiri::HTML(open(index_url))
index.css("div.student-card").map do |student_data|
{
name: student_data.css("h4.student-name").text,
location: student_data.css("p.student-location").text,
... | true |
7779208d695c56be216e5fc474d363e2c2c5dcdb | Ruby | bat020/battleships-web | /lib/boardprinter.rb | UTF-8 | 972 | 3.0625 | 3 | [] | no_license |
# module BoardPrinter
# def htmlprint
# letters = 'ABCDEFGHIJ'
# outstring = "<div style= 'font-family: monospace'><p> A B C D E F G H I J</p>"
# [*1..10].each do |row|
# rowstring = row.to_s + ' '
# if row < 10
# rowstring = ' ' + rowstring
# end
# ... | true |
5191937523099fb0c544565004cbdd91942d656a | Ruby | data-design/twitter_gitter | /lib/twitter_gitter.rb | UTF-8 | 4,699 | 2.765625 | 3 | [
"MIT"
] | permissive | require "twitter_gitter/version"
require 'twitter'
require 'hashie'
require 'yaml'
class TwitterGitter
# Set the convention that ENV['TWITTER_CREDS'] points to a YAML filename
DEFAULT_KEY_FILE = ENV['TWITTER_CREDS']
# Set default parameters for a catch-all for what's publicly available on
# any given user's time... | true |
890384f073f591ed0bdfddd6935b48cb37e1d8da | Ruby | tpham20908/LS | /Backend/lesson_4/test.rb | UTF-8 | 180 | 3.15625 | 3 | [] | no_license | # flintstones = ["Fred", "Barney", "Wilma", "Betty", "Pebbles", "BamBam"]
# hsh = Hash.new()
# flintstones.each_with_index do |name, index|
# hsh[name] = index
# end
# puts hsh
| true |
beeb9fdab314ba3815854c264f02f4a23094cd22 | Ruby | german92/iExperience.github.io | /slides/code/4A/petition.rb | UTF-8 | 297 | 2.84375 | 3 | [] | no_license | require 'rest-client'
require 'json'
class Petition
def get_petitions
puts "Loading petitions..."
response = RestClient.get("https://api.whitehouse.gov/v1/petitions.json?limit=5")
petitions = JSON.parse(response)["results"]
petitions.map do |petition|
petition["title"]
end
end
end | true |
b07b8c4bf9d934268d5703a7883f2891c14eaa8a | Ruby | badCompany110/LearningProjectcs | /Projects/Ruby/Blocks/block_method.rb | UTF-8 | 309 | 3.453125 | 3 | [] | no_license | def block_method
puts "this is the first line in block_method."
yield
puts "this statement is after the yield keyword"
end
# Think of the YIELD as the placeholder telling the def/end to go out to the block and insert the code at the yield
block_method {
puts "this is called from the block."
} | true |
20740793219776332628650ab7022ff1e34766e3 | Ruby | evanmac123/UNGC | /app/presenters/library_detail_presenter.rb | UTF-8 | 1,079 | 2.640625 | 3 | [] | no_license | # frozen_string_literal: true
class LibraryDetailPresenter < SimpleDelegator
def links_list
self.links.order(:id).map do |l|
LinkPresenter.new(l)
end
end
def sustainable_development_goals
resource.sustainable_development_goals.order('goal_number asc').select(:id, :name)
end
private
def ... | true |
8af03e0793c21171af4068ba61a4d50f6dd488bc | Ruby | nishidalab/entry_form | /app/models/concerns/account.rb | UTF-8 | 3,031 | 2.75 | 3 | [] | no_license | module Account
extend ActiveSupport::Concern
included do
attr_accessor :remember_token, :activation_token, :reset_token, :email_update_token
before_create :create_activation_token_and_digest
end
class_methods do
# 渡された文字列のハッシュ値を返す
def digest(string)
cost = ActiveModel::SecurePassword.min_... | true |
ec43396a4d128a7b7207dcba45754938c6142f03 | Ruby | fontcuberta/Week1Exercises | /shoppingcart.rb | UTF-8 | 933 | 3.359375 | 3 | [] | no_license | class ItemsShoppingCart
attr_reader(:item, :price)
def initialize
@item = item
@price = price
end
def list_items
items = [
Item.new("apple", 10),
Item.new("oranges", 5),
Item.new("grapes", 15),
Item.new("banana", 20),
Item.new("watermelon", 50)
]
end
class ShoppingCart
def initialize cart
@ca... | true |
4857ec456c5cc158938dd97824049e69af6c631d | Ruby | draxxxeus/dirt | /lib/macro.rb | UTF-8 | 1,047 | 2.515625 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'json'
require 'haml'
module Dirt
class Macro
def self.to_html(text)
data = JSON.load(text)
type = camel_case(data['type']) + 'Macro'
Dirt.const_get(type).new(data).to_html
end
def self.camel_case(str)
str.capitalize.gsub(/_(.)/) { |m| $1.upcase }
... | true |
85bfe0bd79f771c112de2abd458b04a96a53fbbf | Ruby | evettetelyas/module_0_capstone | /day_3/ex30.rb | UTF-8 | 1,514 | 4.1875 | 4 | [] | no_license | people = 1000
cars = 40
trucks = 15
# runs the puts statement if there are more cars than people
if cars > people
puts "We should take the cars."
# runs the puts statement if there are less cars than people
elsif cars < people
puts "We should not take the cars."
# runs the puts statement if the two conditions ... | true |
e27318c70c4cb0e918cc8db7685c12efcabc0b39 | Ruby | drkjc/top_films | /lib/top_films/scraper.rb | UTF-8 | 1,694 | 2.65625 | 3 | [
"MIT"
] | permissive | require_relative './version'
class TopFilms::Scraper
def get_pages
pages = []
pages << page1 = Nokogiri::HTML(open("https://www.imdb.com/search/title?groups=top_250&sort=user_rating")).css("div.lister-item.mode-advanced")
pages << page2 = Nokogiri::HTML(open("https://www.imdb.com/search/title?groups=top... | true |
c14af4ccd7fc81108ebc7f40922caf3799498565 | Ruby | LifeCoaching/wellness | /test/wellness/detailed_report_test.rb | UTF-8 | 3,449 | 2.5625 | 3 | [
"MIT"
] | permissive | require 'test_helper'
require 'wellness/system'
require 'wellness/detailed_report'
module Wellness
class DetailedReportTest < Minitest::Unit::TestCase
def build_report(system)
Wellness::DetailedReport.new(system)
end
def test_call
system = Wellness::System.new('Healthy System')
system ... | true |
39f3e72311b79164c96f1e46d6f6750d37696c23 | Ruby | fireflypulse/time2ghost | /app/models/realtime_bart_departures.rb | UTF-8 | 1,594 | 2.796875 | 3 | [] | no_license | class RealtimeBartDepartures
require 'open-uri'
attr_accessor :endpoint_and_departure_times
def initialize(origin, destination)
@origin = origin
@destination = destination
@url_builder = BartURLBuilder.new(origin, destination)
end
def get_departures
get_route_names
get_name_of_endpoint_s... | true |
4c9418cbc8878160ed73836e8bb087103d532b7a | Ruby | Mendozak/RubyBegin | /HolaMundo.rb | UTF-8 | 1,023 | 3.90625 | 4 | [] | no_license | =begin
Linea de comentarios multiples
To_i -> convierte en entero
To_f -> convierte a flotante
To_s -> convierte a string
To_str -> Convierte a String
To_int -> convierte a Integer
------------------------------------
$ejemplo -> de esta manera declaramos variables globales
----------------------------------... | true |
06538cdc3d423203596672d8b1abf4c75e56a8d5 | Ruby | yefrem/expenses | /app/models/report.rb | UTF-8 | 938 | 2.703125 | 3 | [] | no_license | class Report
include ActiveModel::Model
include ActiveModel::Serialization
attr_accessor :account, :date_from, :date_to
def total_received
calculate
@total_received
end
def total_spent
calculate
@total_spent
end
def average_spending_per_day
calculate
@average_spending_per_day
... | true |
022d74a5e68a9ca17df4550da416cacc360f01aa | Ruby | doloreszhang/lolitado | /lib/lolitado/box.rb | UTF-8 | 985 | 2.859375 | 3 | [] | no_license | require 'rbnacl'
require 'base64'
module Lolitado
class Box
attr_accessor :box
#
# initialize box
#
# @param key [String] ENV key value used for initialize box
#
def initialize key
fail "There's no environment variable #{key}..." if ENV[key].nil?
key = Base64.decode64(E... | true |
83f5f19249ecde2cbffb2c9bdcb0bc10fb35fd0a | Ruby | PetePhx/basic-ruby | /study_group/sample_problems_dec11.rb | UTF-8 | 1,849 | 4.75 | 5 | [] | no_license | =begin
Given an array of primitive values, return an array of subarrays,
where each sub array contains all duplicates of a specific value in the original
array.
[1, 2, 'a', 1, 3, 'a', 3] ===> [ [1,1], [2], [3, 3], ['a', 'a'] ]
=end
=begin
-input: array: primitives: integers, strings
-output: nested array, each subar... | true |
6fd79e4623f398d28fabf72f707880dff653d14f | Ruby | LLLencinas/tadp2013-2c | /tp_aspectos/test/accessor_test.rb | UTF-8 | 1,165 | 2.796875 | 3 | [] | no_license | require_relative '../test/clases_para_probar/solo_accessors'
require_relative '../test/clases_para_probar/accessors_a_mano_y_otros'
require_relative '../src/join_point_metodos_accessor'
require_relative '../test/clases_para_probar/clase_con_operadores_logicos'
require 'test/unit'
class AccessorTest < Test::Unit::TestC... | true |
a966df828c8f94f5a90b49c90d60638030cedeea | Ruby | kigsmtua/project-euler | /ruby/largest_prime_factor.rb | UTF-8 | 630 | 4 | 4 | [] | no_license | # Mathematical definition of prime factor
# Prime factors of a given number are the prime numbers that divide a given number exactly
# Wikipedia https://en.wikipedia.org/wiki/Prime_factor
def largest_prime_factor(num)
counter = 2
biggestFactor = 0
while (counter * counter) <=num
if num % counter == ... | true |
956aa28c7ad5c8143a85fa6aac3d2d0e383a41b6 | Ruby | k28/ruby_sample | /string.rb | UTF-8 | 347 | 3.40625 | 3 | [
"MIT"
] | permissive | #! ruby -Ku
# 文字列操作のTips
# フォーマット文字列
puts '%10.10f'%Math.sqrt(2) # 1.4142135624
# これと一緒
puts sprintf('%10.10f',Math.sqrt(2))
# 正規表現を適応した文字列を取得
puts "3.191592".sub(/\./,'')
# 正規表現を適応した文字列を取得 -> 5文字取得
puts "3.191592".sub(/\./,'')[0..4]
| true |
d1d45ca9926893fe29e40b9408e1ed4a36f3845a | Ruby | barjit/mastermind | /tests/human_player_test.rb | UTF-8 | 646 | 3.25 | 3 | [] | no_license | require 'minitest/autorun'
require_relative '../human_player.rb'
class HumanPlayerTest < Minitest::Test
def test_turn_initialized_as_zero
human = HumanPlayer.new
assert_equal(0, human.turn)
end
def test_guess_valid_returns_true_for_valid_guess
human = HumanPlayer.new
assert_equal(true, huma... | true |
ba922f506e75eb9cbdb002a03836fe09af31c838 | Ruby | lrs8810/brownfield-of-dreams | /app/poros/follower.rb | UTF-8 | 288 | 2.609375 | 3 | [] | no_license | class Follower
attr_reader :handle, :link, :id
def initialize(follower_hash)
@handle = follower_hash[:login]
@link = follower_hash[:html_url]
@id = nil
in_db?
end
private
def in_db?
user = User.find_by(handle: @handle)
@id = user.id if user
end
end
| true |
1055fc368a81e6daa535b9988a49c19be3ca5f2b | Ruby | pwentz/task_manager | /app/models/task.rb | UTF-8 | 137 | 2.671875 | 3 | [] | no_license | class Task
attr_reader :id, :name, :to_do
def initialize(id, name, to_do)
@id = id
@name = name
@to_do = to_do
end
end
| true |
ab2416b91281e6c078bd6c04fe697ceb893e5163 | Ruby | marcosortiz/easy_sockets | /lib/easy_sockets/udp/udp_socket.rb | UTF-8 | 1,140 | 2.9375 | 3 | [
"MIT"
] | permissive | require 'easy_sockets/basic_socket'
module EasySockets
#
# @author Marcos Ortiz
# Subclass of {EasySockets::BasicSocket} that implement a UDP socket.
#
class UdpSocket < EasySockets::BasicSocket
#
# @param [Hash] opts the options to create a socket with.
# @option o... | true |
4b5d33c07c9065b0b39b2f43f3d0378e10bc83c1 | Ruby | osak/Contest | /yukicoder/171.rb | UTF-8 | 441 | 3.765625 | 4 | [] | no_license | # Name: スワップ文字列(Med)
# Level: 3
# Category: 数学
# 任意の隣り合う2つの文字を入れ替えられれば、任意の順列が構成できる。
# あとは重複順列を計算すればよい。
def fac(n)
(1..n).reduce(&:*)
end
s = gets.chomp
cnt = s.chars.reduce({}){|h,c| h[c] ||= 0; h[c] += 1; h}.freeze
dups = cnt.values.reduce(1){|a,c| a * fac(c)}
patterns = fac(s.length) / dups
puts (patterns-1) %... | true |
7ea6cce42048c33c68684043bc2caac1a044a746 | Ruby | ahkian/art_classes_practice | /galleries.rb | UTF-8 | 430 | 3.25 | 3 | [] | no_license | class Gallery
attr_reader :gall_name, :city
ALL = []
def initialize(gall_name, city)
@gall_name = gall_name
@city = city
ALL << self
end
def self.all
ALL
end
def all_owned_pieces
paintings = Painting.all.select do |p|
if p.location == self
p
end
end
pain... | true |
1a844c8196ede996ecbdb9ac3df8928660049960 | Ruby | Ghiftee/oop-school-library | /app.rb | UTF-8 | 1,757 | 3.65625 | 4 | [
"MIT"
] | permissive | require_relative 'classroom'
require_relative 'listings'
require_relative 'create'
require_relative 'input_output'
require_relative 'converter'
class App
attr_accessor :people, :books
def initialize
@people_io = InputOutput.new('people.json')
@books_io = InputOutput.new('books.json')
@rentals_io = Inpu... | true |
405b28e0ea5f3e65dd079d8ad1405a9c29fdb4ea | Ruby | eggyy1224/101-programming-foundation | /lesson3/easy2/q2.rb | UTF-8 | 133 | 2.890625 | 3 | [] | no_license | munsters_description = "The Munsters are creepy in a good way."
arr = munsters_description.split
arr[1].downcase!
p arr.join(' ') | true |
208b5b32a59088ec7d716115627122e5ec50e0bc | Ruby | ababup1192/pizi-paper-list | /new_ndl.rb | UTF-8 | 779 | 2.78125 | 3 | [] | no_license | require 'open-uri'
require 'nokogiri'
all_info = (1..6).map do |num|
index_uri = URI.escape("http://iss.ndl.go.jp/books?ar=4e1f&any=柳町政之助&page=#{num}")
index_doc = Nokogiri::HTML(open(index_uri))
paper_links = index_doc.css('.item_group_wrapper>div>.item_result>div>h3').children.map do |child|
child.attr('h... | true |
0eee546761639398574e4a753914fb1cecc0b760 | Ruby | kfkkail/tic-tac-toe | /lib/game_board.rb | UTF-8 | 1,381 | 3.8125 | 4 | [] | no_license | class GameBoard
attr_reader :pieces
def initialize
@pieces = [1, 2, 3, 4, 5, 6, 7, 8, 9]
end
def draw
puts "\n" +
" #{@pieces[0]} | #{@pieces[1]} | #{@pieces[2]} \n"+
"---|---|---\n"+
" #{@pieces[3]} | #{@pieces[4]} | #{@pieces[5]} \n"+
"---|---|---\n"+
... | true |
f9532e5184b8b38d0ca5e765e88abb730403f991 | Ruby | nhemsley/bonsai | /lib/bonsai/exporter.rb | UTF-8 | 3,858 | 2.515625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require 'fileutils'
require 'less'
module Bonsai
class Exporter
class << self
attr_accessor :path
def path; @path || "output"; end
def process!
setup
copy_public
copy_assets
cleanup
end
def publish!
teardown
setup
... | true |
db6f4867b6f176e7664d91fa479a6f233d1dc2b1 | Ruby | wordpray/100_knocks | /20. JSONデータの読み込み.rb | UTF-8 | 232 | 2.75 | 3 | [] | no_license | require 'json'
main_content = ""
File.open("jawiki-country.json") do |file|
while line = file.gets
buffer = JSON.parse(line)
main_content = buffer["text"] if buffer["title"].match(/イギリス/)
end
end
p main_content
| true |
900c51bb769edb64768b7f0ccefba1e53ceb9040 | Ruby | tmckernan/sp_log_parser | /lib/log_entry.rb | UTF-8 | 143 | 2.640625 | 3 | [] | no_license | # frozen_string_literal: true
class LogEntry
attr_reader :path, :ip
def initialize(log_entry)
@path, @ip = log_entry.split
end
end
| true |
f6e291b15ca5f9c97e83ea0940d179b46e1e7641 | Ruby | jorge13mtb/The-Prime-Factors-Kata | /lib/prime_factors.rb | UTF-8 | 459 | 3.65625 | 4 | [] | no_license |
=begin
Prime Factors Kata Class
=end
FIRST_PRIME = 2
class PrimeFactorsKata
def generate_prime_factors(number)
prime_factors_array = []
posible_prime_factor = FIRST_PRIME
while number >= 2
while number % posible_prime_factor == 0
prime_factors_array << posible_prime_factor
... | true |
d4d2c79d5cebbf404c3d43e6bf5e00affe5f6c15 | Ruby | wizardone/occupator | /lib/occupator/event.rb | UTF-8 | 495 | 2.5625 | 3 | [
"MIT"
] | permissive | require 'securerandom'
module Occupator
class Event
attr_reader :every, :at, :klass, :uuid
def initialize(**args)
@every = args[:every]
@at = args[:at]
@klass = args[:klass]
@uuid = SecureRandom.uuid
end
def register
Occupator::Store.events[every] = self
end
... | true |
7b01e953d617d7992ca6987fdda9f9c97004b607 | Ruby | DouglasAllen/code-Metaprogramming_Ruby | /raw-code/PART_II_Metaprogramming_in_Rails/gems/money-5.1.0/lib/money/currency/loader.rb | UTF-8 | 977 | 2.640625 | 3 | [
"MIT"
] | permissive | #---
# Excerpted from "Metaprogramming Ruby",
# published by The Pragmatic Bookshelf.
# Copyrights apply to this code. It may not be used to create training material,
# courses, books, articles, and the like. Contact us if you are in doubt.
# We make no guarantees that this code is fit for any purpose.
# Visit http:/... | true |
f783f4d81e48b095999330d2231cb0aef4694dd4 | Ruby | edgarpng/advent-of-code | /test/day4_test.rb | UTF-8 | 1,906 | 2.96875 | 3 | [
"MIT"
] | permissive | require "test_helper"
require_relative "../src/day4"
class Day4Test < Minitest::Test
def test_guard_with_most_minutes_asleep
log_entries = lines <<-log
[1500-01-01 00:00] Guard #111 begins shift
[1500-01-01 00:01] falls asleep
[1500-01-01 00:02] wakes up
[1500-01-02 00:00] Guard #666 begi... | true |
d5cb2def81708f6c7cac2db04949986a41d108e0 | Ruby | jeffperrin/brockhill-forecaster | /app/models/project.rb | UTF-8 | 1,874 | 2.671875 | 3 | [] | no_license | require 'httparty'
require 'active_model'
class Project
include HTTParty
include ActiveModel::Conversion
include ActiveModel::Validations
base_uri "https://agilezen.com/api/v1"
attr_accessor :api_key, :id, :name, :description, :forecast_options
validates :api_key, :presence => true
validates :id, :pre... | true |
8eeedb8cbe05f4c0fd5e7f44cdea6645e63689b1 | Ruby | marceltheshell/little_lms | /db/seeds.rb | UTF-8 | 1,119 | 2.578125 | 3 | [] | no_license |
# adds seed data for cohorts, students, homework, teachers and projects.
# checks to see if the relationships are functional (except for the projects_students join table)
# cohorts = Cohort.create([{ name: '24'}, { name: '25'}])
# students = Student.create([{ name: 'Humberto'}, { name: 'Heather'}, { name: 'Peter'}, ... | true |
34f384d6bcd886b3b99106f8e6a83badff537cfb | Ruby | naderae/object_oriented_programming | /cat/paperboy/paperboy.rb | UTF-8 | 1,194 | 3.703125 | 4 | [] | no_license | class Paperboy
def initialize(name)
@name = name
@experience = 0
@earnings = 0
@quota = 50
@total_papers_delivered = 0
end
def name
return @name
end
def experience
return @experience
end
def earnings
return @earnings
end
def quota
@quota += (50 + (@experience... | true |
77e1613988f3ecb1219557ab643230ef2936c018 | Ruby | holderdeord/hdo-site | /app/models/position.rb | UTF-8 | 510 | 2.578125 | 3 | [] | permissive | class Position < ActiveRecord::Base
has_and_belongs_to_many :parties, order: :name
belongs_to :issue
belongs_to :parliament_period
attr_accessible :description, :issue_id, :parties, :title, :priority, :parliament_period_id
validates :parties, presence: true
validates :title, presence: true
def party_... | true |
6f6c10998fdee6a727f9985837cfbe5ea0e19ab6 | Ruby | ysei/overflow | /example/murmurhash.rb | UTF-8 | 694 | 2.875 | 3 | [
"MIT"
] | permissive | #! /usr/bin/env ruby
lib = File.expand_path('../../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'overflow'
def murmur_hash str
data = str.dup.unpack("C*")
m = 0x5bd1e995
r = 16
length = Overflow.new "I", str.bytesize
h = length * m
while 4 <= length
d = data.shift(... | true |
3f7a40a00a8fe2252c792201fc22d5febade9347 | Ruby | msypniewski511/emporium | /test/models/book_test.rb | UTF-8 | 1,810 | 2.53125 | 3 | [] | no_license | require 'test_helper'
class BookTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
test "should fail create without vailid attrybuties" do
book = Book.new
assert_not book.save
assert_equal 10, book.errors.size
assert book.errors[:title].any?
assert book.errors[:publisher]... | true |
5e97875ff6d9a190cd0eee99005098a4300ec6de | Ruby | naasfu/ctrlalt.io | /app/services/stripe_handler/charge.rb | UTF-8 | 450 | 2.546875 | 3 | [] | no_license | module StripeHandler
class Charge
def self.succeeded(order, charge_id)
order.update_attribute(:charge_id, charge_id)
order.transaction_successful! if order.processing_transaction?
end
def self.failed(order)
# Roll it back to unpaid so the user can try again.
order.transaction_fail... | true |
6498990047b5d8c6d7873fbd45704b8856de80b3 | Ruby | faisal-iqbal/bitmap_editor | /spec/bitmap_spec.rb | UTF-8 | 9,839 | 3.171875 | 3 | [] | no_license | require 'spec_helper'
require './lib/bitmap'
describe Bitmap do
context "initilize" do
it "create bitmap data for image of diminsions 5x6" do
bitmap = Bitmap.new(5, 6)
expect(bitmap.data.size).to eq 6
bitmap.data.each do |row|
expect(row.size).to eq 5
... | true |
b5cb1f0068626a8803a5e1a3e8491b8a3e3d68b5 | Ruby | shorrockin/adventofcode2018 | /11.rb | UTF-8 | 3,165 | 3.375 | 3 | [] | no_license | # Advent Boilerplate Start
require 'pry'
class String
def colorize(color_code); "\e[#{color_code}m#{self}\e[0m"; end
def red; colorize(31); end
def green; colorize(32); end
def yellow; colorize(33); end
end
def value_string(val)
value_str = val
value_str = '"' + value_str + '"' if val.is_a?(String)
valu... | true |
0177c5c99a0e87c9767f747053b8d5ce38f2910c | Ruby | borgr/l---l | /where.rb | UTF-8 | 957 | 2.984375 | 3 | [] | no_license | require 'treat'
include Treat::Core::DSL
require_relative 'HelpQuestions'
IN_IGNORE_LIST = ["in time", "in particular"]
par = get_document
#ask where ************
#answer noun ************
counter = 0;
par.each_sentence do |sent|
adj, noun = nil,nil
#need to check which sentences contain PP with the word in at the ... | true |
9a4af53540f0cef9dd173df89828b736aede64f7 | Ruby | gjackson12/dev4acause_2 | /spec/features/user_creates_a_nonprofit_spec.rb | UTF-8 | 4,926 | 2.65625 | 3 | [] | no_license | require 'spec_helper'
feature 'user creates non-profit', %Q{
As an authenticated user
I can create a non-profit
So that I can begin to post opportunities
} do
# Acceptance Criteria
# * I must specify a name, ein_number, state, city, description mission, and
# cause area
# * I am able to specify a date found... | true |
5e8521f1ac13e0a135b330021bd3e16002165be6 | Ruby | AFKoala/rando-pairs | /randompair.rb | UTF-8 | 206 | 3.171875 | 3 | [] | no_license | def pairings(names)
students = []
names = names.shuffle
pairs = names.each_slice(2).to_a
if pairs.count % 2 == 1
over = pairs.pop
over = over.pop
pairs[0] << over
end
p pairs
pairs[0].count
end | true |
3bde7bacad268c2900f6105c0d6961cfdd8d4fc7 | Ruby | alexReshetnyak/ruby-essential-beginning | /13_if_statments.rb | UTF-8 | 1,483 | 4.0625 | 4 | [] | no_license |
if 5 < 7
p 'True'
end
word = 'zebra'
if word.include?('eb')
p 'Yes'
end
if ''
p 'Empty string is true'
end
if 0
p '0 is true'
end
if nil
p 'nil is false'
end
if false
p 'false is false'
end
p '-----------------'
color = 'red'
if color == 'green'
puts 'Color is green'
... | true |
6ea7037bef2b712ef02e27baaabed7f3f0f69324 | Ruby | equinn125/whats-in-my-food | /app/facades/food_facade.rb | UTF-8 | 213 | 2.59375 | 3 | [] | no_license | class FoodFacade
def self.ten_food_search(search_param)
foods_data = FoodService.food_search(search_param)[:foods]
foods_data[0..9].map do |food_data|
Food.new(food_data)
end
end
end
| true |
6e92bf8a7576ccfb61a11d7718f92fd8eaade20a | Ruby | arumoy-shome/ruby_examples | /text_analyzer/spec/analyzer_spec.rb | UTF-8 | 1,940 | 2.703125 | 3 | [] | no_license | require 'spec_helper'
describe Analyzer do
Given(:sample_text){Analyzer.new(string)}
context "total count" do
Given(:string){"Hello World!"}
When(:result){sample_text.count}
# much hacky
Then{expect(result).to be == 12}
end
context "total char w/o space" do
Given(:string){"Hello World!"}
... | true |
5c494ef315824d54e0c356b5643880cbbb784b98 | Ruby | wangjingyi/stream | /stream_test.rb | UTF-8 | 3,887 | 3.125 | 3 | [] | no_license | require File.expand_path(File.dirname(__FILE__) + '/stream')
require 'test/unit'
class TestStream < Test::Unit::TestCase
def test_head
stream = Stream.make 1, 2, 3, 4
assert_equal(1, stream.head)
assert_equal(1, stream.item(0))
assert_equal(2, stream.item(1))
assert_equal(4, stream.item(3))
end... | true |
3cecfc713bab51624e7123620242c304a91ef1c2 | Ruby | mitya/rabotnegi-padrino | /test/lib/gore_test.rb | UTF-8 | 1,226 | 2.515625 | 3 | [] | no_license | require "test_helper"
describe Gore do
describe "helpers" do
test '#object_id?' do
assert Gore.object_id?(1234)
assert Gore.object_id?("1234")
assert Gore.object_id?("1234-hello")
assert !Gore.object_id?("1234hello")
assert Gore.object_id?("4f09f1975a12ae7d50000001")
... | true |
ac562bb7b67d6d34f1370208304686a0fbb2b090 | Ruby | tenesami/sinatra_restaurant_reservation_app | /app/controllers/application_controller.rb | UTF-8 | 1,642 | 2.546875 | 3 | [
"MIT"
] | permissive | require './config/environment'
class ApplicationController < Sinatra::Base
configure do
set :public_folder, 'public'
set :views, 'app/views'
enable :sessions
set :session_secret, "restauran_reservation_app"
register Sinatra::Flash
end
get "/" do
redirect_if_logged_in
erb :Home... | true |
f6ee65233f15b87f04868f665b6613f2ba4c5631 | Ruby | Almnir/rubies | /discord_bot.rb | UTF-8 | 943 | 2.875 | 3 | [] | no_license | require 'discordrb'
file_data = File.readlines("d:\\rubies\\raid_champions.txt").map! {|x| x.delete("\n")}
hash_data = Hash.new
file_data.each do |x|
hash_data[x] = "https://ayumilove.net/raid-shadow-legends-" +
x.split("\t")[1].downcase.gsub(/\s/,"-") +
"-skill-mast... | true |
6988aa8c0e285c929c82d3c002ec2eb0f6a9e54a | Ruby | aydyn-gur/rb101 | /lesson_3/Medium_1/Q_04.rb | UTF-8 | 489 | 3.328125 | 3 | [] | no_license | def rolling_buffer1(buffer, max_buffer_size, new_element)
buffer << new_element
buffer.shift if buffer.size > max_buffer_size
buffer
end
def rolling_buffer2(input_array, max_buffer_size, new_element)
buffer = input_array + [new_element]
buffer.shift if buffer.size > max_buffer_size
buffer
end
# Yes, there... | true |
2223bc828fc0cb254ad561161fde08d7f42f9fe0 | Ruby | JoWseph/rails-simple-airbnb | /db/seeds.rb | UTF-8 | 404 | 2.765625 | 3 | [] | no_license | require 'faker'
puts 'Cleaning database...'
Flat.destroy_all
puts 'We are on the way to create 100 flats..'
100.times do
flat = Flat.new
flat.name = Faker::Artist.name
flat.address = Faker::Address.full_address
flat.description = Faker::Restaurant.description
flat.price_per_night = rand(100..1500)
flat.nu... | true |
2162dd9fed672eb230460ec675d97010abb4cbc4 | Ruby | blackknight75/headcount | /test/statewide_test_repository_test.rb | UTF-8 | 4,179 | 2.78125 | 3 | [] | no_license | require './test/helper'
require_relative '../lib/statewide_test_repository'
require_relative '../lib/district_repository'
require_relative '../lib/headcount_analyst'
class StatewideTestRepositoryTest < Minitest::Test
def test_statewide_test_repo_exists
statewide = StatewideTestRepository.new
assert_instance... | true |
9d07514e65d34224c17f6b53998a359e75e27f96 | Ruby | wilsonj806/ruby-rails-tut | /basics/fixnum.rb | UTF-8 | 130 | 3.21875 | 3 | [] | no_license | # fixnum.rb
3.upto(8) { |val| print val}
puts "\n------------\nNew Section\n------------\n"
5.downto(2) { puts "Hello there!" } | true |
7a4008eb790478bb316d983bdf195a9ac2da07b5 | Ruby | albertosaurus/power_enum_2 | /lib/power_enum/enumerated.rb | UTF-8 | 18,934 | 2.640625 | 3 | [
"MIT"
] | permissive | # Copyright (c) 2005 Trevor Squires
# Copyright (c) 2012 Arthur Shagall
# Released under the MIT License. See the LICENSE file for more details.
module PowerEnum
# Implementation of acts_as_enumerated
module Enumerated
extend ActiveSupport::Concern
# Class level methods injected into ActiveRecord.
m... | true |
4ed8669c0972c1d7fc431e248aa7c8dcbb32c9e9 | Ruby | ohheythere/ruby_challenges | /blog.rb | UTF-8 | 985 | 3.4375 | 3 | [] | no_license | class Blog
@@all_posts = []
@@num_posts = 0
def self.all
@@all_posts
end
def self.add(elements)
@@all_posts << elements
@@num_posts += 1
end
def self.publish
@@all_posts.each do |post|
puts "Title:\n #{post.title}"
puts "Content:\n #{post.content}"
puts "Publish Date:\n #{post.publish_date}"
... | true |
0d6ca0bf59e35b7e8935aa9019215bd29b109f09 | Ruby | cafechen/xyp | /webcli/ws-delete-user | UTF-8 | 1,284 | 2.75 | 3 | [] | no_license | #!/usr/bin/env ruby
FILEDIR = File.dirname(__FILE__)
require "getoptlong"
require FILEDIR + "/ws-config"
require FILEDIR + "/deps/client_utils"
require FILEDIR + "/deps/ws_adapter"
#USAGE = "USAGE: ws-delete-user -e <email>"
command_desc={"cmd"=>"delete-user",
"opts"=> { "email"=>["e",1,""]}}
USAGE ... | true |
768684b4d78c2471729328f910c2cc6b4e98b7fb | Ruby | alexander-mc/ttt-6-position-taken-rb-online-web-sp-000 | /lib/position_taken.rb | UTF-8 | 312 | 3.46875 | 3 | [] | no_license | def position_taken?(board, index)
if board[index] == " " || board[index] == "" || board[index] == nil
false
else
true
end
end
puts position_taken?([" ","X", "",nil], 0)
puts position_taken?([" ","X", "",nil], 1)
puts position_taken?([" ","X", "",nil], 2)
puts position_taken?([" ","X", "",nil], 3) | true |
b90d6de4fe805ee5dba70a05b1c041dd49b74cfc | Ruby | c7/scoped_search | /lib/scoped_search/reg_tokens.rb | UTF-8 | 2,387 | 2.890625 | 3 | [
"MIT"
] | permissive | # Regular expression tokens to be used for parsing.
module RegTokens
WORD = '[\w-]+'
SPACE = '[ ]'
STRING = '["][\w ]+["]'
OR = 'OR'
POSSIBLY_NEGATED = '[-]?'
MONTH = '[\d]{1,2}'
DAY = '[\d]{1,2}'
FULL_YEAR = '[\d]{4}'
LESS_THAN = '[<][ ]'
GREATER_THAN = '[>][ ]'
LESS_THAN_OR_EQUAL_TO = '[<][=... | true |
1dcd3151a08fff3527ef27d31da44cd3e54a7cea | Ruby | nixsticks/isitholiday | /app.rb | UTF-8 | 1,099 | 2.546875 | 3 | [] | no_license | require 'yaml'
require 'bundler'
Bundler.require
# require './lib/scraper'
module Calendar
class App < Sinatra::Application
# Scraper.new("http://www.timeanddate.com/holidays/us").save
set :holidays, YAML::load(File.open('./lib/holidays.yaml'))
Timezone::Configure.begin {|c| c.username = 'nixsticks'}
... | true |
70c4ea31fb965bb7667a4db1d1ab947246105bc0 | Ruby | manu9812/ruby | /bloks.rb | UTF-8 | 115 | 3.015625 | 3 | [
"Apache-2.0"
] | permissive | def ejecutar
if block_given?
yield
else
puts 'no tiene bloque'
end
end
ejecutar{puts 'hola'}
| true |
5e4c8f07be9b0994c0551faa1b3bbeb16d8cf169 | Ruby | mullinska/arrays | /arrays.rb | UTF-8 | 1,236 | 3.96875 | 4 | [] | no_license | def haveThree(a)
x = 0
a.each do |a|
if a == 3
x = x + 1
end
end
if x == 3
return true
end
return false
end
puts haveThree([3, 1, 3, 1, 3])
puts haveThree([3, 4, 3, 4])
def lucky13(a)
a.each do |a|
if a == 3 || a == 1
return false
end
end
return true
end
puts lucky13([... | true |
10ae30090295f709a68f45569ee985c8288d1717 | Ruby | mfeinLearn/ruby-music-library-cli-v-malcome-000111 | /lib/music_library_controller.rb | UTF-8 | 1,350 | 3.375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class MusicLibraryController
def initialize(path = './db/mp3s')
@path = path
@music_importer = MusicImporter.new(path)
@music_importer.import
end
def call
puts "Welcome to your music library!"
puts "To list all of your songs, enter 'list songs'."
puts "To list all of t... | true |
21affd37f6aa8117f8b3fb66ce2184826be89c4d | Ruby | st0n3y/macbook_files | /cx3_4/week2/day3/test.rb | UTF-8 | 336 | 2.953125 | 3 | [] | no_license | require('colorize')
puts "Hello".red
puts "Hello".blue
puts "Hello".green
puts "Hello".yellow
puts "Hello".cyan
puts "Hello".white
puts "Hello".blink
puts String.colors
puts String.modes
puts "////////////////////////////".light_black
puts "Warning! Collision imminent!".red.blink
puts "/////////////////////////... | true |
c37fcc6906efdcb9109c6d8fb73167e1fb5f0c10 | Ruby | vinniburkett1995/memcached-web-monitoring-application | /lib/statistics_collection_helper.rb | UTF-8 | 2,744 | 2.984375 | 3 | [] | no_license | # collect statistical data
module StatisticsHelper
class Collector
@@LOGGER = Logger.new(STDERR)
class << self
def start_collecting
# if any process is already collecting data
locked, lock_file = running_existing_process?
if locked
@@LOGGER.info("since an existing pro... | true |
ce80a6e6df455da9cd6c317749fd1e9616195400 | Ruby | yqwoe/wechat | /app/models/post.rb | UTF-8 | 1,112 | 2.59375 | 3 | [] | no_license | class Post < ApplicationRecord
attr_reader :feed,:blog_title
ATTRIBUTE_NAMES=[:title, :link, :published, :description, :content, :author]
class << self
def feed
@feed ||= FeedParser.new(:url => "http://yqwoe.space/feed.xml").parse
end
def blog_title
@blog_title ||= feed.title
end
... | true |
9338e1bcbf4a997eac2d64e12576a6e1f302010f | Ruby | lbvf50mobile/til | /20211025_Monday/20211025.rb | UTF-8 | 1,007 | 3.875 | 4 | [] | no_license | # Leetcode: 155. Min Stack.
# https://leetcode.com/problems/min-stack/
# = = = = = = =
# Accepted.
# Thanks God!
# = = = = = = =
# Runtime: 145 ms, faster than 30.69% of Ruby online submissions for Min Stack.
# Memory Usage: 213.7 MB, less than 54.46% of Ruby online submissions for Min Stack.
class MinStack
def ini... | true |
fd4e5976a27dd52a3274236fb8ab254b1d061115 | Ruby | xanwerneck/discretas | /2014.2-discretas/anagramas.rb | UTF-8 | 2,203 | 3.859375 | 4 | [] | no_license | # get_anagramas(alphabet, anagrama, anagramas)
# parâmetros:
# - alphabet: (array de caracteres) caracteres do alfabeto.
# - anagrama: (string) anagrama que está sendo formado através das chamadas recursivas. [opcional]
# - anagramas: (array) anagramas que já foram formados [opcional]
# retorno: (array) todos os ana... | true |
b94fcd93afb48e4d0d7fb157f2436d607fd2e508 | Ruby | RameshC1993/programming-univbasics-4-array-concept-review-lab-online-web-prework | /lib/array_methods.rb | UTF-8 | 548 | 3.578125 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def find_element_index(array, value_to_find)
count = 0
while count < array.length do
return array.find_index(value_to_find)
end
end
def find_max_value(array)
counter = 0
max = array[0]
while counter < array.length do
if array[counter] > max
max = array[counter]
end
counter +=... | true |
d9d4cdef062369562798d0f2479456fb3977603d | Ruby | aman199002/Data-Structures-and-Algorithms-in-Ruby | /array/distribute_candies.rb | UTF-8 | 2,228 | 4.25 | 4 | [] | no_license | # Distribute Candies to People
# We distribute some number of candies, to a row of n = num_people people in the following way:
# We then give 1 candy to the first person, 2 candies to the second person, and so on until we give n candies to the last person.
# Then, we go back to the start of the row, giving n + 1 candi... | true |
73033bd98d525b9db189960bae7c1e0845d4281b | Ruby | tamaki8021/line_discord_connect | /app_main.rb | UTF-8 | 1,170 | 2.65625 | 3 | [] | no_license | require 'line/bot'
require 'discordrb'
require 'net/http'
require 'uri'
require 'json'
token = ENV["DISCORD_BOT_TOKEN"]
clientID = ENV["DISCORD_CLIENT_ID"]
bot = Discordrb::Commands::CommandBot.new token: token, client_id: clientID, prefix: "!"
def client
@client ||= Line::Bot::Client.new { |config|
config.cha... | true |
f827ff76a18c65ab30e6cf4249be39f2334b8fad | Ruby | batteries76/code_alongs | /08-ajax/queen_attack/faulty_code.rb | UTF-8 | 364 | 3.265625 | 3 | [] | no_license | white_arr = @white.split('')
black_arr = @black.split('')
black_arr.each do |char|
num_arr = ['0','1','2','3','4','5','6','7','8','9']
if num_arr.include?(char)
@new_black_arr.push(char.to_i)
end
end
white_arr.each do |char|
num_arr = ['0','1','2','3','4','5','6','7','8','9']
if num_arr.include?(char)
... | true |
4a1436de16dd0de29fe46c584d475e2805fb0b50 | Ruby | digital-fabric/polyphony | /examples/performance/switch.rb | UTF-8 | 224 | 2.5625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require 'fiber'
X = 10_000_000
main = Fiber.current
f = Fiber.new do
loop { main.transfer }
end
t0 = Time.now
X.times { f.transfer }
dt = Time.now - t0
puts "#{X / dt.to_f}/s"
puts fs.size | true |
c97fa48d0288a34d53060fed1a91616bd6d80e35 | Ruby | royrenno/reverse-each-word-v-000 | /reverse_each_word.rb | UTF-8 | 121 | 3.0625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def reverse_each_word(sentence)
words=sentence.split
words.collect do |word|
word.reverse!
end
words.join(" ")
end
| true |
6abefaeb66e5f383797506e3ddfbc812767ff0a3 | Ruby | RobbieDumbrell/week3-day3-music_collection | /db/sql_runner.rb | UTF-8 | 552 | 2.796875 | 3 | [] | no_license | require('pg') # requires pg (postgres)
class SqlRunner
def self.run(sql, values = []) # sql code, and values to be put in, default values is empty array.
begin
db = PG.connect({ dbname: 'music_collection', host: 'localhost' }) # connect to database.
db.prepare("query", sql) # prepare query with defin... | true |
3b9f79f7906183e584755b40a338869abc8e52f6 | Ruby | ratdog19336/ruby-music-library-cli-v-000 | /lib/music_importer.rb | UTF-8 | 308 | 2.890625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class MusicImporter
attr_accessor :path #:files
def initialize(file_directory)
@path = file_directory
end
def files
files = Dir["#{@path}/*"].collect{|song_file| song_file.split("mp3s/")[1]}
end
def import
files.collect{|file_name| Song.create_from_filename(file_name)}
end
end
| true |
3a1e873c14858f2088bebab355b88a8b08fdd1ba | Ruby | zexpp5/yizi_crawler | /topics.rb | UTF-8 | 2,451 | 2.65625 | 3 | [] | no_license | require 'nokogiri'
require 'open-uri'
require 'json'
require 'mysql'
require 'watir'
class Topic
def initialize(r_id,title,level,parent,stage,subject)
@r_id = r_id
@title = title
@level =level
@parent =parent
@stage = stage
@subject = subject
end
def r_id
@r_id
end
def title
... | true |
18ede3735e03b66707ac1d30cc43994ff1fe50aa | Ruby | luke-ellison/w1d5 | /knights-travails/knight-path-finder.rb | UTF-8 | 1,524 | 3.65625 | 4 | [] | no_license | require '../poly-tree-node/lib/00_tree_node.rb'
class KnightPathFinder
DELTAS = [
[-2, -1],
[-2, 1],
[-1, -2],
[-1, 2],
[1, -2],
[1, 2],
[2, -1],
[2, 1]
]
BOARD_SIDE_LENGTH = 8
def self.valid_moves(pos)
row, col = pos
valid_moves = []
DELTAS.each do |d|
if (... | true |
8eb0bbd6e77e2817046801e9351b001a2d525858 | Ruby | h4hany/yeet-the-leet | /algorithms/Medium/784.letter-case-permutation.rb | UTF-8 | 979 | 3.578125 | 4 | [] | no_license | #
# @lc app=leetcode id=784 lang=ruby
#
# [784] Letter Case Permutation
#
# https://leetcode.com/problems/letter-case-permutation/description/
#
# algorithms
# Medium (64.85%)
# Total Accepted: 96.3K
# Total Submissions: 148.5K
# Testcase Example: '"a1b2"'
#
# Given a string S, we can transform every letter individ... | true |
47b13c45f877422add5f5d84d9be3ce9da40580b | Ruby | Owenhorner/event_booking_system | /lib/event.rb | UTF-8 | 804 | 3.484375 | 3 | [] | no_license | require 'date'
class Event
attr_reader :start, :end
def initialize(start_datetime:, end_datetime:)
@start = DateTime.parse(start_datetime)
@end = DateTime.parse(end_datetime)
end
def clash?(event)
start_overlaps?(event) || end_overlaps?(event)
end
def start_time
@start.strftime("%H%M%S")... | true |
165f2edacdfdefcde3f762ae3f442c5e79c763ed | Ruby | bethfraser/FlixRatings | /models/film.rb | UTF-8 | 2,762 | 3.375 | 3 | [] | no_license | require_relative '../db/sqlrunner'
require_relative '../models/ranking'
require 'open-uri'
require 'json'
class Film
attr_accessor :id, :title, :year, :imdb_rating, :poster_image, :summary
def initialize(options)
@id = options['id']
@title = options['title'].gsub("'", "’")
@year = options['year... | true |
fd1207ae0c4b1221dad2997b0701243f7f50f447 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/proverb/efb18e3140c44de49ca2b7cd7d73dd56.rb | UTF-8 | 402 | 3.15625 | 3 | [] | no_license | class Proverb
def initialize(*causes, qualifier: nil)
@causes = causes
@clause = qualifier + " " if qualifier
end
def to_s
pairs = @causes.each_cons(2)
proverb = pairs.map do |pair|
cause, effect = pair
"For want of a #{cause} the #{effect} was lost."
end
proverb << "And all... | true |
f5b9eeedf3c8284f4e0a8e776f1559c7c2cb1136 | Ruby | Bangotran/forceofnature_mission_control | /app/models/event.rb | UTF-8 | 559 | 2.546875 | 3 | [] | no_license | class Event < ApplicationRecord
belongs_to :user
has_many :attending, dependent: :destroy
has_many :attendees, through: :attending, source: :user
validates :title, :description, :location, presence: :true
validate :valid_start_date, on: :create
validate :valid_end_date, on: :create
def valid_start_date
... | true |
4cefae78b4d228c6f503105265ec50f8980dc5b5 | Ruby | morganmiller/enigma | /lib/date_offset.rb | UTF-8 | 246 | 3.21875 | 3 | [] | no_license | class DateOffset
def initialize(date = Time.now.strftime("%-d%m%y"))
@date = date.to_i
end
def date
@date
end
def squared_date
@date**2
end
def date_offsets
squared_date.to_s.chars.last(4).map(&:to_i)
end
end
| true |
5ab12c6278e62df9866d363325ea89f17d71b1d7 | Ruby | pboling/stackable_flash | /lib/stackable_flash/stack_layer.rb | UTF-8 | 1,750 | 3 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require "stackable_flash/flash_stack"
module StackableFlash
module StackLayer
def [](key)
if StackableFlash.stacking
#Do it in a non-stacking block so we get normal behavior from flash[:notice] calls
StackableFlash.not_stacked do
actual = super(key)
if actual.nil?
... | true |
ec847e019281570877b2e98aecd881fa1ff1c82c | Ruby | spuder/advent-of-code | /2021/2b-test.rb | UTF-8 | 1,093 | 3.984375 | 4 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
# # commands
# # - forward 1 (horizontal)
# # - down 2 (increase depth)
# # - up 3 (decrease depth)
input = File.read('2a-test.txt').chomp.split("\n")
# split each line of input into key and value splitting on space
# input.each do |line|
# key = line.split(" ")[0]
# value = line.split(" ... | true |
935ff2e2657b164fae0837a262be5e81b049b564 | Ruby | lanceorechovesky/TheIronYard | /homework/misc.../variable_hw.rb | UTF-8 | 3,981 | 4.28125 | 4 | [] | no_license | =begin
find 5 methods for each type of variable
-boolean = anything that gives you back a true or false
-string = words or characters within double or single quotes
-interger = numbers
-float = numbers with a decimal point
write them in to a code
send to nick
get done befoe 9 tomorrow
=end
#booleans
puts "These are m... | true |
206b4bc36f0543e5273c629382963b71de471b85 | Ruby | rxaviers/codeeval | /open_challenges/hard/prefix_expressions.rb | UTF-8 | 912 | 3.578125 | 4 | [] | no_license | #! /usr/bin/env ruby
# CodeEval - Hard 2) Prefix expressions
# http://www.codeeval.com/open_challenges/7
# author: Rafael Xavier <rxaviers at gmail.com>
class Test
def initialize(line)
@tokens = line.split
end
def run
puts @tokens.prefix_exp_eval
end
end
class Array
def prefix_ex... | true |
3606ed6cf37ccd913ec4fc42ac712e400da496ad | Ruby | jonbent/phase-0 | /week-5/acct_groups.rb | UTF-8 | 3,103 | 4.34375 | 4 | [
"MIT"
] | permissive | # 5.6 Create Accountability Groups Challenge
# I will be happy if it outputs the names in groups. Based on time, I have to stop once it works.
# 0. Pseudocode
# What is the input? An array consisting of names
# What is the output? (i.e. What should the code return?) A hash of arrays with each key containing the name... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.