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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
02332f02554fed69ca10fd761da805bd5c22c22c | Ruby | sarakhandaker/ruby-enumerables-cartoon-collections-lab-seattle-web-030920 | /cartoon_collections.rb | UTF-8 | 899 | 3.65625 | 4 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'pry'
def roll_call_dwarves(array)# code an argument here
# Your code here
array.each_with_index{ | item, index|
puts "#{index+1} #{item}"
}
end
def summon_captain_planet(array)# code an argument here
# Your code here
array.map! {|name| name.capitalize }
array.map! {|name| name+= "!" }
end
def ... | true |
2378cced05fc779fd89e6a1a6ce6c49981eba08f | Ruby | renatosousafilho/ror-senac | /revisao-trabalho/pessoa_crud.rb | UTF-8 | 370 | 3.0625 | 3 | [] | no_license | require_relative './pessoa'
class PessoaCrud
def initialize
@pessoas = []
end
def cadastrar(nome, idade, endereco, telefone)
pessoa = Pessoa.new(nome, idade, endereco, telefone)
@pessoas << pessoa
end
def listar
@pessoas
end
def pesquisar_por_nome(nome)
@pessoas.each do |pessoa|
return pessoa if... | true |
05abda5f1bce6f0cfd15601d8ac73e09b315cf72 | Ruby | this-is-simon/cc_w1d5_weekend_homework | /start_point/pet_shop_simons_answers.rb | UTF-8 | 1,686 | 3.203125 | 3 | [] | no_license | def pet_shop_name(pet_shop)
pet_shop[:name]
end
def total_cash(pet_shop)
pet_shop[:admin][:total_cash]
end
def add_or_remove_cash(pet_shop, added_or_removed_cash)
pet_shop[:admin][:total_cash] += added_or_removed_cash
end
def pets_sold(pet_shop)
return pet_shop[:admin][:pets_sold]
end
def increase_pets_sold... | true |
2ea7e7a043de833c54a304fe6e8fbb06984a2433 | Ruby | aspsa/blocipedia | /app/helpers/wikis_helper.rb | UTF-8 | 925 | 2.546875 | 3 | [] | no_license | module WikisHelper
def wiki_collaboration_link(wiki, user)
return unless wiki.id
# If this wiki entry does not have a user id in the collaborators table, then this user is a potential collaborator.
unless wiki.collaborator?(user)
#link_to "Collaborate", add_collaborator_wiki_path(wiki: wiki, us... | true |
2acfd24266e85b11d1be39e6dfb2b23a0ba94387 | Ruby | eyeseast/pillbox | /pillbox_resource_noko.rb | UTF-8 | 1,380 | 2.578125 | 3 | [] | no_license | require 'nokogiri'
require 'open-uri'
class PillboxResourceNoko
attr_accessor :attrs
def PillboxResourceNoko::find_first_with_img_by_ingredient(ingredient)
prs = PillboxResourceNoko.find_all_by_ingredient(ingredient)
pill = nil
prs.each do |pr|
pill = pr if pr.has_image?
end
pill
end
d... | true |
9f14be62e3aa8246d39276c533833d41aec9cdc0 | Ruby | duykhoa/haythat | /test/test_field.rb | UTF-8 | 1,076 | 2.5625 | 3 | [] | no_license | require 'helper'
class TestField < Minitest::Test
def setup
@wheat = Wheat.new
@field = Field.new
end
def test_wheat_harvest_time
assert_equal(120, @wheat.harvest_time)
end
def test_grow_wheat
@field.grow(@wheat)
assert_equal(@wheat, @field.growing_crop)
assert_equal(true, @field.o... | true |
682db7ad087d746e35e97efdd9dfc2d4faa4f62d | Ruby | adam-patel/stock-trading-ledger | /spec/ledger_spec.rb | UTF-8 | 1,731 | 3.375 | 3 | [] | no_license | require 'ledger'
# 100 shares bought for 10000
# 50 shares sold for 6000
# 200 shares bought for 11000
describe StockTracker do
it 'can add a trade to the trades array' do
account = StockTracker.new
trade = Trade.new("ULVR", 300, 3948.39)
account.trades << trade
expect(account.trades.length).to eq(... | true |
857ff411c8527da276e2d2f6d2cfc89d06acb400 | Ruby | Kimtaro/ve | /lib/misc.rb | UTF-8 | 106 | 2.8125 | 3 | [
"MIT"
] | permissive | class Enumerator
def more?
begin
self.peek
true
rescue
false
end
end
end | true |
391ef38d1d8bd1368d5adebaac866bc97940e860 | Ruby | eliyooy/tic-tac-toe-rb-q-000 | /lib/tic_tac_toe.rb | UTF-8 | 3,003 | 4.0625 | 4 | [] | no_license | WIN_COMBINATIONS = [
[0, 1, 2],
[3, 4, 5],
[6, 7, 8],
[0, 3, 6],
[1, 4, 7],
[2, 5, 8],
[0, 4, 8],
[2, 4, 6]
]
def display_board(board = [" ", " ", " ", " ", " ", " ", " ", " ", " "])
seperator = "-----------"
puts " #{board[0]} | #{board[1]} | #{board[2]} "
puts seperator
puts " #{board[3]} | #... | true |
3187d26af055df7175ba8935cbd0bb0140c435e9 | Ruby | jlblumberg/bank-tech-test | /lib/statement.rb | UTF-8 | 674 | 3.328125 | 3 | [] | no_license | class Statement
HEADER = "date || credit || debit || balance\n"
def initialize(account)
@transactions = account.transactions
end
def print_statement
format_statement
print @transactions
end
private
def add_header
@transactions = HEADER + @transactions
end
def reverse_transactio... | true |
5598fb2f8b2b82ef56d90ef5756dd940ef74e28c | Ruby | codekunoichi/learning-ruby | /method_example.rb | UTF-8 | 795 | 4.5625 | 5 | [
"CC0-1.0"
] | permissive | def prime(n)
puts "That's not an integer." unless n.is_a? Integer
is_prime = true
for i in 2..n-1
if n % i == 0
is_prime = false
end
end
if is_prime
puts "#{n} is prime!"
else
puts "#{n} is not prime."
end
end
prime(2)
prime(9)
prime(11)
prime(51)
prime(97)
def greeter(name)
retu... | true |
0820952f31bd0eeb61f0db87357bbd77644215b1 | Ruby | bmordan/ruby-cli-journal | /lib/journal.rb | UTF-8 | 869 | 2.78125 | 3 | [
"MIT"
] | permissive | require "journal/version"
module Journal
class Instruct
def initialize
puts "Welcome to journal use the --help flag for instructions"
end
end
class Input
def initialize (args)
date, entry = args
entry = entry ? entry : date
case date
when "today"
date = Time.n... | true |
5bb8a5f12414e8fb67592cab0491fe5bb48df592 | Ruby | anitacanita/bananas_airport | /lib/plane.rb | UTF-8 | 209 | 2.765625 | 3 | [] | no_license | class Plane
def initialize
@airborne = true
end
def land!
@airborne = false
end
def take_off!
@airborne = true
end
def flying_status
@airborne ? 'flying' : 'landed'
end
end
| true |
3f1dcaf2551ef5e521cb350123a7bfa165429886 | Ruby | trouni/batch-656 | /livecodes/animals/spec/meerkat_spec.rb | UTF-8 | 578 | 3.03125 | 3 | [] | no_license | require_relative '../meerkat'
describe Meerkat do
describe '#initialize' do
it 'returns an instance of Meerkat' do
meerkat = Meerkat.new('Napoleon')
expect(meerkat).to be_a(Meerkat)
end
end
describe '#name' do
it 'returns the name of the meerkat' do
meerkat = Meerkat.new('Napoleon'... | true |
5fda0cb565aa2ce7d05aa5f9bd5767b17532960b | Ruby | micahbales/Launch-Academy | /challenges/phase-2/online_souq/part1.rb | UTF-8 | 955 | 3.515625 | 4 | [] | no_license | puts "Howdy shopper? What's your name?"
name = gets.chomp
items = ["old paperback book", "potato", "red onion", "dried lemon", "frankincense", "medicinal herbs", "saffron",
"glass spice jar", "red fabric", "orange fabric", "handicrafts", "small Persian rug", "medium Persian rug",
"large Persian rug", "extra large ... | true |
dbd3e3f6a461584a853515267abab3c115116697 | Ruby | ijikeman/Study | /RUBY/EVENTMACHINE/HELLO/timer2.rb | UTF-8 | 276 | 2.546875 | 3 | [] | no_license | require 'eventmachine'
EM.run do
p = EM::PeriodicTimer.new(1) do
puts 'Tick...'
end
EM::Timer.new(3) do
puts 'BOOM'
end
EM::Timer.new(2) do
puts 'Tack...'
end
EM::Timer.new(5) do
puts 'BOOM2'
end
EM::Timer.new(10) do
EM.stop
end
end
| true |
66e958c04de37c77d43723887719e747b120f769 | Ruby | CatalanoWebDevelopment/ttt-8-turn-v-000 | /bin/turn | UTF-8 | 296 | 3.59375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | #!/usr/bin/env ruby
# REQUIRE #turn.rb FILE
require_relative '../lib/turn.rb'
# SET AN EMPTY BOARD AT START
board = [" ", " ", " ", " ", " ", " ", " ", " ", " "]
# OUTPUT A GREETING
puts "Welcome to Tic Tac Toe!"
# DISPLAY THE EMPTY BOARD
display_board(board)
# BEGIN TURN METHOD
turn(board)
| true |
8ef72b7299e6e4db379ee0bce57e86c1f3c5ab90 | Ruby | justonemorecommit/puppet | /lib/puppet/functions/round.rb | UTF-8 | 488 | 3.609375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | # Returns an `Integer` value rounded to the nearest value.
# Takes a single `Numeric` value as an argument.
#
# @example 'rounding a value'
#
# ```puppet
# notice(round(2.9)) # would notice 3
# notice(round(2.1)) # would notice 2
# notice(round(-2.9)) # would notice -3
# ```
#
Puppet::Functions.create_function(:round) ... | true |
841362b7bbc76b17a0fc71177d193cf63324f7d3 | Ruby | M-Munk/programming_with_ruby | /hashes/challenge.rb | UTF-8 | 881 | 4.03125 | 4 | [] | no_license | # problem: determine words that have the same letters and return and array of
# those words
# should return a different array for each set of words with the same letters
# chars method returns an array of characters from a string
# sort orders an array
words = ['demo', 'none', 'tied', 'evil', 'dome', 'mode', 'live',... | true |
fe782ad64c9059e1d63e7e834e7c15d6a4bceeee | Ruby | metchadou/Chess-game | /piece.rb | UTF-8 | 673 | 3.234375 | 3 | [] | no_license | require "byebug"
class Piece
attr_accessor :board
attr_reader :color, :position
def initialize(color, board, position)
@color, @board, @position = color, board, position
end
def to_s
" #{symbol} "
end
def empty?
color.nil?
end
def position=(val)
@position = val
end
def symbol... | true |
debedf325504c49c0f67a379fcea10aa68bab350 | Ruby | sergioschuler/tealeaf-ruby-book-01-basics | /01.basics/01.03_movie_year.rb | UTF-8 | 163 | 2.875 | 3 | [] | no_license | movies = {:matrix => 1999, :blade_runner => 1982, :another_random_movie => 2015}
puts movies[:matrix]
puts movies[:blade_runner]
puts movies[:another_random_movie] | true |
84060834f85bc00719980696058ef6b8e2769dbd | Ruby | GalaxyAstronaut/deli-counter-onl01-seng-ft-012120 | /deli_counter.rb | UTF-8 | 655 | 3.96875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Write your code here.
katz_deli = []
def line(numinline)
line_method_arr = []
if numinline.length == 0
puts "The line is currently empty."
else
numinline.each_with_index do |name,index|
line_method_arr.push("#{index + 1}. #{name}")
end
puts "The line is currently: #{line_method_arr.join(" "... | true |
4293aa412f50e20070df2474118b8207054ecf56 | Ruby | gaohongwei/cs | /offer/oral_offer.rb | UTF-8 | 763 | 2.734375 | 3 | [] | no_license | ### Response to oral offer
### Never negotiate a verbal offer.
Wow! Thank you for the offer, and I look forward to going over the details in the written offer
before I can give my formal acceptance.
When do you expect a response?
### if HR still asks for oral acceptance, say this
As of this time, I see no re... | true |
aac7c1ac4bbe2843cdf6f73ccfa7dd27fd62e1d4 | Ruby | TheLosingEdge/head-first-ruby-exercises | /Exercises/Chp2/dog.rb | UTF-8 | 524 | 4.15625 | 4 | [] | no_license | class Dog
attr_accessor :name, :age
def name=(value)
if value == ""
raise "Name can't be blank idiot"
end
@name = value
end
def move(destination)
puts "#{@name} runs to the #{destination} and goes to sleep"
end
def talk
puts "#{@name} ... | true |
24e08cd2a02b76942e412abcf8a3735e442e4523 | Ruby | akuhn/euler | /problem_14.rb | UTF-8 | 1,232 | 3.734375 | 4 | [] | no_license | require_relative 'euler'
# The following iterative sequence is defined for the set of positive integers:
# n = n/2 (n is even)
# n = 3n + 1 (n is odd)
# Using the rule above and starting with 13, we generate the following sequence:
# 13 40 20 10 5 16 8 4 2 1
# It can be seen that this sequence (starting at 13... | true |
25992227664afb2e055aac0aad09188776510ee6 | Ruby | JenniferGrudi/CCAC_TTT | /app.rb | UTF-8 | 3,242 | 2.84375 | 3 | [] | no_license | require 'sinatra'
require_relative 'sequentialAI.rb'
require_relative 'randomAI.rb'
require_relative 'console_game.rb'
require_relative 'human.rb'
enable :sessions
set :session_secret, 'This is a secret key'
get '/wiki_rules' do
@title = 'Wiki'
erb :wiki_rules
end
get '/how_to' do
@title = 'How To Play'
erb :how... | true |
1a5a60b0b2171816a7f5a423e5b46a6afbb9d8ca | Ruby | jocelynthode/SocialMovies | /app/models/movie.rb | UTF-8 | 1,527 | 2.625 | 3 | [] | no_license | class Movie < ActiveRecord::Base
has_many :movielists
has_many :lists, through: :movielists
attr_accessor :title, :release_date, :actors, :imdb
# Retrieve movie model from datastore and add entry in local DB
def self.retrieve(mid)
q = %Q(
SELECT ?id ?title ?releaseDate ?imdb ?actorName
WHERE ... | true |
d0417b4537cc718fbf87cb91365322ee9a47010f | Ruby | demullane/katy-perry-hash | /06_favorite_food.rb | UTF-8 | 301 | 3.1875 | 3 | [] | no_license | require_relative "person"
# Print Katy's favorite foods. It should read "Katy's favorite foods are sushi, hamburgers, and pho."
puts "Katy's favorite foods are " + KATY_PERRY[:favorite_foods].first.to_s + ", " + KATY_PERRY[:favorite_foods][1] + ", and " + KATY_PERRY[:favorite_foods].last.to_s + "."
| true |
528d8c696b4d4f31e3d7665ae970363ef4dcda2a | Ruby | susd/liberty-sis | /lib/tasks/name_stats.rake | UTF-8 | 1,399 | 2.796875 | 3 | [] | no_license | namespace :stats do
task students: :environment do
fname_size = 3
regex = /(\s|-|\'|\")/
while fname_size < 24
puts "Trying #{fname_size}"
hsh = Hash.new(0)
Aeries::Student.active.pluck(:fn, :fna, :mn, :ln, :gr).each do |fn, fna, mn, ln, gr|
middle = (mn.blank? ? '' : mn[0])... | true |
24ed3751ddaf82da517f8695ce4d599ba7dabf6e | Ruby | Jack2ee/specialsession | /practice2.rb | UTF-8 | 158 | 3.015625 | 3 | [] | no_license | woonjang = '졸림'
if woonjang == '피곤'
puts '공부하자!'
elsif woonjang == '졸림'
puts '더 가르쳐라!'
else
puts '가자!'
| true |
8f91bf074f6fefbe29cbf3e7d315c658898941d1 | Ruby | lucaswilric/frsss | /mongo_cache.rb | UTF-8 | 907 | 2.640625 | 3 | [] | no_license | require 'mongo_connector'
module Cache
class NoDataError < Exception; end
class MongoCache
def initialize(timeout = 600)
@timeout = timeout
mongo_uri = ENV['MONGO_URI'] || ENV["MONGOHQ_URL"]
database = MongoConnector.new(mongo_uri, 'friendly-rss').connection
@collection = database['c... | true |
d552d124ed94667df4dabfb19b2c0bc0d04900c9 | Ruby | dabrorius/dabrorius.github.io | /code_examples/splat-splat-and-double-splat/mix.rb | UTF-8 | 558 | 3.3125 | 3 | [] | no_license | # def can_you_do_this?(*positional, **named)
# puts positional
# puts named
# end
# can_you_do_this?('first', 'second', name: 'john', surname: 'doe')
# def can_you_do_this?(_first, *positional, _second, name:, **named)
# puts positional
# puts named
# puts first
# puts second
# end
# can_you_do_this?('fi... | true |
f6982870bcbfeaeba08bfd7020c3d267a6fa3b76 | Ruby | ngohoaiphuong/ruby-pratices | /examing/15.rb | UTF-8 | 1,372 | 3.703125 | 4 | [] | no_license | Move Zeroes
Create a function which takes an array arr and moves all zeros to the end, preserving the order of the other elements.
Examples
move_zeros([1, 0, 1, 2, 0, 1, 3]) ➞ [1, 1, 2, 1, 3, 0, 0]
move_zeros([0, 1, nil, 2, false, 1, 0]) ➞ [1, nil, 2, false, 1, 0, 0]
move_zeros(['a', 0, 0, 'b', 'c', 'd', 0, 1, 0, 1,... | true |
d01b20ed483fc89a6c814c791d119a676c71b531 | Ruby | gorails-screencasts/http-server-from-scratch | /request.rb | UTF-8 | 607 | 3.15625 | 3 | [] | no_license | class Request
attr_reader :method, :path, :headers, :body, :query
def initialize(request)
lines = request.lines
index = lines.index("\r\n")
@method, @path, _ = lines.first.split
@path, @query = @path.split("?")
@headers = parse_headers(lines[1...index])
@body = lines[(index + 1)..-1].join
... | true |
956e4542ac5d0db5b8ecc830371d7f9689a89cbd | Ruby | hilarysk/daily-feminist-affirmation | /app/models/user.rb | UTF-8 | 1,743 | 2.6875 | 3 | [] | no_license | # Class: User
#
# Creates different users.
#
# Attributes:
# @email - String: User email
# @user_name - String: User name
# @id - Integer: user ID, primary key for users table
# @password - String: user's password
#
# Public Methods:
# #self.user_name_pass_search
# #insert
#
# Private Methods:
# #initiali... | true |
fa25d5aef0edc1fa4c3ecfc3200051295eaca4b8 | Ruby | macsrok/best-attempt-gem-updater | /best_attempt_gem_updater.rb | UTF-8 | 3,496 | 3.234375 | 3 | [] | no_license | class BestAttemptGemUpdater
def initialize(gems)
@gems = gems
@original_commit = ""
@skipped_gems = []
@failed_gems = []
@updated_gems = []
end
def attempt_gem_update
puts 'This is experimental software. Use at your own risk. Any damage to your code base is... | true |
38d5c251ab0e79397a0887ac01d62ca65cb307ad | Ruby | pikonori/auto_sftp | /lib/autosftp/cli.rb | UTF-8 | 2,791 | 2.984375 | 3 | [
"MIT"
] | permissive | # -*- coding: utf-8 -*-
require 'thor'
require 'autosftp/monitor'
require 'autosftp/file_access'
require 'autosftp/connection'
module Autosftp
class CLI < Thor
desc "start [remote name]", "Automatic monitoring start"
option :chmod
def start(*word)
if false == Autosftp::FileAccess.exist?
pu... | true |
8ee203583a699f350e32132049a889d056384ff8 | Ruby | theotherzach/exercism.io | /assignments/ruby/bob/example.rb | UTF-8 | 1,090 | 3.90625 | 4 | [] | no_license | class Bob
def hey(something)
if silent?(something)
'Fine. Be that way.'
elsif question?(something)
'Sure.'
elsif shouting?(something)
'Woah, chill out!'
else
'Whatever.'
end
end
private
def question?(s)
s.end_with?('?')
end
def silent?(s)
s.empty?
en... | true |
0e8d34f046a57d65142619efe7720640efa614a0 | Ruby | hgodinot/hgodinot-Launch_School | /RB130/lesson/car.rb | UTF-8 | 213 | 3.34375 | 3 | [] | no_license | class Vehicle ; end
class Car < Vehicle
attr_accessor :wheels, :name, :colour
def initialize(name)
@wheels = 4
@name = name
end
def ==(other)
other.is_a?(Car) && name == other.name
end
end
| true |
d10fe92e7091277005e8777fa51dfb6a6a281119 | Ruby | Reactician/RubyBuby | /2uzd/2uzd.rb | UTF-8 | 244 | 2.84375 | 3 | [] | no_license | # frozen_string_literal: true
puts 'Įveskite egzamino bala'
a = gets.to_i
if a >= 5 && a < 11
puts 'Egzaminas išlaikytas'
elsif a < 5 && a.positive?
puts 'Egzaminas neišlaikytas'
else
puts 'tokio pazymio negali buti'
end
| true |
1047467140fc7ce6877a09563233cf071746f78d | Ruby | dmdinh22/PreCourse | /exercises_methods.rb | UTF-8 | 310 | 4.15625 | 4 | [] | no_license | #1
def greeting(name)
puts "Hello " + name = "."
end
puts greeting("David")
#2
x = 2
puts x = 2
p name = "Joe"
four = "four"
print something = "nothing"
#3
def multiply(x, y)
x * y
end
puts multiply(3, 5)
#4, 5
def scream(words)
words = words + "!!!!"
puts words
"Hi there"
end
scream("Yippeee") | true |
9c744308821014f1fbd48f0f262d156b32d670e3 | Ruby | tianbymy/relative_time | /lib/relative_time/in_words.rb | UTF-8 | 1,092 | 3.1875 | 3 | [
"MIT"
] | permissive | module RelativeTime
class InWords
def call(date_to, date_from)
diff = date_from.to_time - date_to.to_time
return '1分钟前' if diff.abs.round <= 59
date_string = verb_agreement(resolution(diff.abs.round))
diff >= 0 ? "#{date_string} 前" : "#{date_string}"
end
private
MINUTE = 60
... | true |
70f7fedcdf58e95f67e628501ae94860b558579b | Ruby | heythor/Estudos | /ForWhile/resta5.rb | UTF-8 | 135 | 3.0625 | 3 | [] | no_license | valor = 1001
while valor != 2000
if valor % 11 == 5
puts valor
valor += 1
else
valor += 1
end
end | true |
3fe05dcf06669494525a4bc9b77369330a706642 | Ruby | lucianoq/codejam | /17/round_1C/A_ample-syrup/main.rb | UTF-8 | 1,233 | 3.34375 | 3 | [] | no_license | #!/usr/bin/env ruby
class Pancake
attr_reader :r
attr_reader :h
attr_reader :lsurf
attr_reader :area
attr_reader :syrup
def initialize(r, h)
@r, @h = r.to_f, h.to_f
@lsurf = @h * (2*Math::PI*@r)
@area = @r**2 * Math::PI
@syrup = @lsurf + @area
end
end
def area_gain(new, min, last)
(ne... | true |
a6e9d66e97dc62af5073b5e36da90088278abe93 | Ruby | davemerritt/learn_ruby | /02_calculator/calculator.rb | UTF-8 | 185 | 3.484375 | 3 | [] | no_license | def add(a,b)
return a + b
end
def subtract(a,b)
return a - b
end
def sum(number)
sum = 0
number.each { |x| sum += x }
return sum
end
def multiply(*num)
return num * num
end | true |
34798cecb1d77ce3c09dd70f560b8f76675f7152 | Ruby | tradener/cardinality-br | /lib/brazilian_cardinality/number.rb | UTF-8 | 4,325 | 3.59375 | 4 | [
"MIT"
] | permissive | module BrazilianCardinality
module Number
NumberTooBigError = Class.new(StandardError)
ONES = {
0 => 'zero',
1 => 'um',
2 => 'dois',
3 => 'três',
4 => 'quatro',
5 => 'cinco',
6 => 'seis',
7 => 'sete',
8 => 'oito',
9 => 'nove'
}.freeze
TENS ... | true |
d9e50c3828f8b0ac47fb24a3530e8c7f5d4b0269 | Ruby | savyounts/Netflix_Bestflix | /lib/netflix_bestflix/movie.rb | UTF-8 | 1,150 | 2.71875 | 3 | [
"MIT"
] | permissive | class NetflixBestflix::Movie
attr_accessor :title, :position, :url, :genre, :rt_score, :viewer_score, :description, :rating
@@all = []
def initialize(title = nil, position = nil, url = nil)
@title = title
@position = position
@url = url
@@all << self
end
def self.new_from_scrape(s)
self.... | true |
0ec5f7582ee30399ef1137db0aaaa74e4bc2d585 | Ruby | arrayfire/arrayfire-rb | /test/blas_test.rb | UTF-8 | 928 | 2.703125 | 3 | [
"BSD-3-Clause"
] | permissive | require 'test_helper'
class ArrayFire::BLASTest < Minitest::Test
def setup
@matrix_left = ArrayFire::Af_Array.new 2, [2,2],[ 12, 21,-61, 48]
@matrix_right = ArrayFire::Af_Array.new 2, [2,2],[-15, 41, 30 , 7 ]
@vector_left = ArrayFire::Af_Array.new 2, [4,1],[-15, 41, 30 , 7 ]
@vector_right = ArrayF... | true |
c706e3d466f530b1a5ad55609e94e76789c01680 | Ruby | dgarate/arreglos | /smartwatch1.rb | UTF-8 | 622 | 3.109375 | 3 | [] | no_license | def clear_steps (pasos)
pasos_sin_letras = pasos.select do |paso|
if paso.class == Integer # added this "if" to ensure that program would work if the array contains Integer and String
paso
else
orig_length = paso.length
new_length = paso.to_i.to_s.length
orig_length == new_length
en... | true |
05866548e4e558ce978394fc88a4294825e6cddb | Ruby | rchavesc/ruby_introduction | /05_printing.rb | UTF-8 | 119 | 3.1875 | 3 | [] | no_license | puts 'soy un texto en la terminal'
print 'hola'
print 'soy un texto en print'
#print no crea un salto de linea, puts si | true |
cacd9517fa75cc63a7630a8b40db7f4f6d8388b0 | Ruby | mknicos/coursewareofthefuture | /features/step_definitions/time_steps.rb | UTF-8 | 325 | 2.578125 | 3 | [
"MIT"
] | permissive | Given(/^that it is (\d+)\/(\d+)\/(\d+)$/) do |year, month, day|
t = Time.new(year.to_i, month.to_i, day.to_i)
Timecop.travel(t)
end
Given(/^that it is (\d+)\/(\d+)\/(\d+) (\d+):(\d+)AM$/) do |year, month, day, hour, minute|
t = Time.new(year.to_i, month.to_i, day.to_i, hour.to_i, minute.to_i)
Timecop.travel(t)... | true |
5f4cad3f07250b1a317c840b317ce22e9fb67f67 | Ruby | pomartel/auto_html-contrib | /lib/auto_html/gist.rb | UTF-8 | 421 | 2.546875 | 3 | [
"MIT"
] | permissive | require 'tag_helper'
module AutoHtml
# Gist filter
class Gist
include TagHelper
def call(text)
regex = %r{https?://gist\.github\.com/(\w+/)?(\d+)}
text.gsub(regex) do
gist_id = Regexp.last_match(2)
tag(:script, type: 'text/javascript', src: gist_url(gist_id)) { '' }
end
... | true |
559e11fa897fdfff1fcaa59f6fa14968c042d86d | Ruby | jdwolk/form_io | /spec/output/form_spec.rb | UTF-8 | 1,548 | 2.71875 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe FormIO::Output::Form do
class PhoneReader < Struct.new(:phone)
def value=(model_value)
@value = model_value
end
def value
phone = @value.split('')
area_code = phone.take(3).join
first_three = phone.drop(3).take(3).join
last_four = phone.drop(6... | true |
b489fc0453fd25f77535e24ed6139b1ba39c2619 | Ruby | Redcozmo/gobike | /app/services/closest_stations.rb | UTF-8 | 998 | 3.5 | 4 | [] | no_license | # frozen_string_literal: true
class ClosestStations
#
# Description :
# => Use the ClosestStations class to calculate the closest stations
# to a position with two lon/lat coordinate pairs.
#
# Output :
# => array with <num> closest stations from input coordinate point
#
# Example usage :
# => Cl... | true |
1adb9833579641cd6a831a40f53c5a17da52065a | Ruby | anibha88/Pine | /simple_block_call.rb | UTF-8 | 214 | 2.8125 | 3 | [] | no_license | def profile &block
block.call
end
profile do
p "hi"
end
# def profile &block
# block.call
# end
# profile do
# p "hi"
# 10.times do
# p "HSVJ"
# end
# profile do
# p "Test"
# end
# end | true |
3e16271f4341295c8b1f4e4262f702926c9148e0 | Ruby | taw/paradox-tools | /eu4_trade_graph/trade_graph.rb | UTF-8 | 2,490 | 2.671875 | 3 | [
"MIT"
] | permissive | require_relative "../lib/paradox_mod_file_serializer"
require "rgl/adjacency"
require "rgl/connected_components"
require "rgl/topsort"
class TradeGraph
attr_reader :node
def initialize(node)
@node = node
end
def nodes
@node.keys
end
def edges
result = []
@node.each do |from, trade_node|
... | true |
9f13b722a2aec1394bf5fd6f7c78492184d96462 | Ruby | shixiongjing/D4 | /helper.rb | UTF-8 | 586 | 3.109375 | 3 | [] | no_license | def insert_sort(arr, char)
idx = arr.length
temp = arr.dup
temp << char
until idx.zero? || (temp[idx - 1] <= char)
idx -= 1
temp[idx + 1], temp[idx] = temp[idx], temp[idx + 1]
end
# puts 'adding: ' + char
# puts 'orinigal: ' + arr
# puts 'sorted:' + temp
temp
end
def check_args(argv)
if arg... | true |
772f5430c88399246569d1ce9246cfb27609be49 | Ruby | learn-co-students/seattle-web-031119 | /44-jwt/rainbow.rb | UTF-8 | 154 | 2.796875 | 3 | [] | no_license | require 'bcrypt'
passphrase = "a"
while true
hash = BCrypt::Password.create(passphrase)
puts "#{passphrase} #{hash}"
passphrase = passphrase.next
end
| true |
169270dd2e2d2ba1c233c6d7f227b4ac4de05cb0 | Ruby | bubdm/all-the-structures | /ruby/src/stack/stack.rb | UTF-8 | 225 | 3.546875 | 4 | [] | no_license | #!/usr/bin/env ruby
class Stack
def initialize()
@values = []
end
def push(val)
@values << val
end
def pop()
@values.pop
end
def size
@values.length
end
end
| true |
bcaf73cbfc85c1d4218c289bc6b91f4d51dba332 | Ruby | unrar/midb | /lib/midb/hooks.rb | UTF-8 | 1,405 | 2.96875 | 3 | [] | no_license | # ADDED in midb-2.0.0a by unrar #
#
# The "hooks" part of the MIDB::API module allows programmers to customize their API.
# Hooks are methods that are run in the API; overriding them allows you to run a custom API.
#
# This hooking technology has been developed in its-hookable.
#
module MIDB
module API
class Hoo... | true |
79b9d3404a880368c853372cea279a7d657b81f5 | Ruby | paulinasalem/my-collect-v-000 | /lib/my_collect.rb | UTF-8 | 138 | 3.265625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def my_collect(argument)
i=0
collection=[]
while i<argument.length
collection<<yield(argument[i])
i+=1
end
collection
end
| true |
9101c68a90ef3b8c6521340f697968f3e0351f8c | Ruby | KernelDeimos/tmp-setmonkey | /app/controllers/sets_controller.rb | UTF-8 | 2,535 | 2.71875 | 3 | [] | no_license |
# vim: ts=2 sw=2 expandtab
class SetsController < ApplicationController
def definition
end
def view
# Choose correct behaviour based on which button was pressed
case params[:commit]
when "union"
union
when "intersection"
intersection
when "difference"
difference
when "su... | true |
8967900be263671f95e3437d3c67cbc8e62a0999 | Ruby | mnain/learn-ruby | /servlet.rb | UTF-8 | 1,783 | 2.625 | 3 | [] | no_license | #!/opt/third-party/bin/ruby
#
# $Id: servlet.rb,v 1.1 2005/07/23 00:41:37 madan Exp madan $
#
# SERVLET_RB
#
require 'webrick'
include WEBrick
s = HTTPServer.new(
:Port => 8085
)
# HTTPServer#mount(path, servletclass)
# When a request referring "/hello" is received,
# the HTTPServer get a... | true |
b95a742bc90db6847ea69ff7113ddcef16c91e22 | Ruby | TheNaoX/tic_tac_toe | /lib/game.rb | UTF-8 | 265 | 2.640625 | 3 | [
"MIT"
] | permissive | module Game
@@games = {}
class << self
def store(session)
@@games.merge!(session => Game::Environment.new)
end
def get_instance(session)
@@games[session]
end
def finish(session)
@@games.delete(session)
end
end
end
| true |
9241c794cca33a0914028657313bc57ec81b646d | Ruby | superff/hello-gitlearn | /ruby/Part1-1.rb | UTF-8 | 780 | 4.09375 | 4 | [] | no_license | def palindrome?(string)
# your code here
g = string.downcase.gsub(/[^a-z]/, '')
b = g.reverse
return g == b
end
def count_words(string)
# your code here
str_hash = Hash.new
a = (string.downcase).gsub(/[^a-z\s]/, '').split(/[\b\s]/)
#puts g
a.each do |key|
if key != ''
if !str_hash.has_key?(key)
... | true |
a68fa8ef7a5bf9fc8421db4e8e9cfa466f1e7381 | Ruby | timsalazar/week-02-exercise-timsalazar | /spec/exercise-spec.rb | UTF-8 | 532 | 3.640625 | 4 | [] | no_license | describe "Strings" do
context "when calling strip" do
it "should remove all whitespace from the beginning and the end of the string" do
lyrics = " Hello, is it me you're looking for I can see it in your eyes "
lyrics.strip.should eq "Hello, is it me you're looking for I can see it in your eyes" ... | true |
941f6e77d3e9d5c07a7af0b3bd0a135921ca5488 | Ruby | tdg5/tco_method | /test/unit/tco_method_test.rb | UTF-8 | 1,860 | 2.71875 | 3 | [
"MIT"
] | permissive | require "test_helper"
module TCOMethod
class TCOMethodTest < TCOMethod::TestCase
include TCOMethod::TestHelpers::Assertions
Subject = TCOMethod
# Grab source before it's recompiled for use later
InstanceFibYielderSource = TestClass.instance_method(:instance_fib_yielder).source
subject { Subjec... | true |
0d3e62515e0e487abeeed44ee969b3aaed6dd948 | Ruby | eudaimonious/cyo-revenge | /revenge.rb | UTF-8 | 10,083 | 3.1875 | 3 | [] | no_license | # -*- coding: UTF-8 -*-
from sys import exit
import re
import json
import urllib2
import random
h = {
"self_destruct" => {
:text => "\nIt's 2002 and you are now an 18 year old billionaire with major issues.\nYou're partying like you just got out of juvie and maybe getting into a few bar fights.\nThen pesky, pesky ... | true |
b40d075499de9f95f65d243ea37052ad3ad6b1dc | Ruby | tskupinski/marcus | /lib/treasury.rb | UTF-8 | 924 | 3.453125 | 3 | [] | no_license | require_relative './coin'
require_relative './errors/unsupported_coin_error'
class Treasury
STARTING_COINS = [
Coin.new('1p', 1, 10),
Coin.new('2p', 2, 10),
Coin.new('5p', 5, 10),
Coin.new('10p', 10, 10),
Coin.new('20p', 20, 10),
Coin.new('50p', 50, 10),
Coin.new('1£', 100, 10),
Coin.... | true |
750eb286bce2e93e6ead64926d82b9c34cb60a6c | Ruby | jeesong/compsciwork | /word_complete_redo.rb | UTF-8 | 1,349 | 3.578125 | 4 | [] | no_license | require 'pry'
class AutoCompleteNode
attr_accessor :value, :children, :is_complete_word
def initialize(value)
@value = value
@children = []
@is_complete_word = false
end
def learn(input)
length = input.length
i = 1
parent = self
while i <= length
if parent.children.any? { |... | true |
30d1d4b17d0f2d6ccde2ec4186337e4d1cee6047 | Ruby | take-cheeze/mruby-pack | /test/pack.rb | UTF-8 | 2,089 | 3.125 | 3 | [
"MIT"
] | permissive | # pack & unpack 'm' (base64)
assert('[""].pack("m")') do
ary = ""
str = ""
[ary].pack("m") == str and
str.unpack("m") == [ary]
end
assert('["\0"].pack("m")') do
ary = "\0"
str = "AA==\n"
[ary].pack("m") == str and
str.unpack("m") == [ary]
end
assert('["\0\0"].pack("m")') do
ary = "\0\0"
str = "AAA... | true |
a23d61a1fe68f35d60baa48ab5e714ce336e8297 | Ruby | ALEKUTTY/ruby-challenges-final | /always3_method.rb | UTF-8 | 266 | 3.296875 | 3 | [] | no_license |
def method_3
#ask user for a number
puts "Give me a number"
#define variable to hold number
first_number = gets.to_i
#do maths to get 3 and display result
puts "Always" + (((first_number + 5)*2-4)/2 - first_number).to_s
end
method_3
| true |
c6fbb33ac275919878eab11b8cbde5e350500f3b | Ruby | mooreds/ruby-lambdas | /lambda_pipeline.rb | UTF-8 | 243 | 3.046875 | 3 | [] | no_license | double_it = lambda { |num| num * 2 }
triple_it = lambda { |num| num * 3 }
half_it = lambda { |num| num / 2 }
value = 5
lambda_pipeline = [double_it, triple_it, half_it]
lambda_pipeline.each do |lmb|
value = lmb.call(value)
end
puts value
| true |
de96727637bd856b40a13aa8152aa6d815f8f4fa | Ruby | mdumke/tealeaf_exercises | /course 0 - prep course/intro_programming_1_workbook/quiz1_2/07.rb | UTF-8 | 186 | 3 | 3 | [] | no_license | # See if the name "Dino" appears in the string below
advice = "Few things in life are as important as house training your pet dinosaur."
p !!advice.match('Dino')
p !!(advice =~ /Dino/)
| true |
0dcda60dd7bd02c7c25d603db729d9ec9991a256 | Ruby | davidtadams/advent-of-code | /2019/day14/part1and2.rb | UTF-8 | 2,063 | 3.6875 | 4 | [] | no_license | # frozen_string_literal: true
reactions_input = File.read('input.txt').split("\n")
class Chemical
attr_accessor :name, :result, :inputs
def initialize(name, result, inputs = [])
@name = name
@result = result
@inputs = inputs
end
end
class Reaction
attr_accessor :name, :cost
def initialize(nam... | true |
ff9e987e36c85d003e24be06b8261aa24e094b21 | Ruby | dmillzilla/trello_archiver | /trello_archiver.rb | UTF-8 | 1,198 | 2.765625 | 3 | [] | no_license | require 'trello'
require 'yaml'
require 'date'
config = YAML::load_file(File.join(File.dirname(File.realpath(__FILE__)), ".config"))
@trello_config = config["trello_config"]
trello_board_arr = []
Trello.configure do |c|
c.developer_public_key = @trello_config["APP_KEY"]
c.member_token = @trello_config["TOKEN"]
en... | true |
4e5c4e9d9c776f072758c5d26c4ba204bedbb6b6 | Ruby | cokesnort/readme | /app/services/base64_to_image.rb | UTF-8 | 266 | 2.703125 | 3 | [] | no_license | class Base64ToImage
def initialize(base64)
@base64 = base64
end
def call(path = nil)
image = path.present? ? File.new(path, 'wb') : Tempfile.new('image')
image.binmode
image.write(Base64.decode64(@base64))
image.flush
image
end
end
| true |
0f5e085f332c7ada585ac475e9a24b73fc52adf1 | Ruby | whistler/whistler.github.com | /_plugins/random.rb | UTF-8 | 304 | 2.921875 | 3 | [] | no_license | # Jekyll Liquid Filter to select one from an array
# Eg. display a random post title
# {% assign post = site.posts | random %}
# {{ post.title }}
module Jekyll
module RandomFilter
def random(input)
input.sample
end
end
end
Liquid::Template.register_filter(Jekyll::RandomFilter) | true |
73aea157fdf160352750d5341ab8463a87e916aa | Ruby | shadowmonkey95/AstarForPgrouting | /lib/algorithm/hungarian.rb | UTF-8 | 6,862 | 2.640625 | 3 | [] | no_license | class Hungarian
def initialize
@C = []
@M = []
@rowCover = []
@colCover = []
@C_orig = []
@path = []
@pathChild = []
@nrow = 0;
@ncol = 0;
@step = 1;
@path_row_0 = 0;
@path_col_0 = 0;
@path_count = 0;
@asgn = 0;
@debug = fals... | true |
d87459a3cd5ae8565a198743f568c954ecb031a2 | Ruby | ArunMichaelDsouza/ruby-foundations | /scripts/basics.rb | UTF-8 | 1,000 | 4.53125 | 5 | [
"MIT"
] | permissive | # Variables, user input/output
val = 2
puts "Value : #{val}" # Interpolation
float = 0.99
puts "Float : #{float}"
puts "Enter value"
new_val = gets
puts "New value : #{new_val}"
# Type casting
puts "Enter number"
num = gets.to_i # Convert to integer
puts "Double is : #{num * 2}"
int = 3
puts "This is a number : " +... | true |
ce028477d8a60f30f656e29d3323a9a53a2b74c8 | Ruby | elma635/ruby-objects-has-many-through-lab-nyc-web-051319 | /lib/doctor.rb | UTF-8 | 762 | 3.359375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class Doctor
attr_accessor :name
@@all = []
def initialize(name)
@name = name
@@all << self
end
#instance
#confused on That Appointment should know that it belongs to the doctor
def new_appointment(patient, date)
Appointment.new(patient, self, date)
#binding.pry
end
... | true |
3ceec5a5ea34f5f23f3be3c3acca2c97da8c097b | Ruby | codemilan/old_stuff | /active_point1/RubyExt/module.rb | UTF-8 | 2,296 | 2.5625 | 3 | [] | no_license | class Module
def namespace
if @module_namespace_defined
@module_namespace
else
@module_namespace_defined = true
@module_namespace = Module.namespace_for name
end
end
def each_namespace &block
current = namespace
while current do
block.call current
current = cur... | true |
98419b357ebe21c215b3dc43151d6405bc463630 | Ruby | IlyaMur/ruby_learning | /RubyRush_school/Lesson7/max.rb | UTF-8 | 169 | 3.109375 | 3 | [] | no_license | puts 'Какой длины будет массив случайных чисел?'
num = gets.to_i
arr = Array.new(num) {rand 1..100}
puts arr.to_s
puts arr.max | true |
2b05a1aa49ea65c352de2db7d9b839b9b10eee6b | Ruby | facenord-sud/myl | /lib/parser/tree_parser.rb | UTF-8 | 700 | 2.640625 | 3 | [
"MIT"
] | permissive | class TreeParser
require 'treetop'
Treetop.load(File.expand_path(File.join(File.dirname(__FILE__), 'myl_parser.treetop')))
@@parser = MylReferenceParserParser.new
def self.parse(data)
tree = @@parser.parse(data)
if(tree.nil?)
raise ParseError, "Parse error at offset: #{@@parser.index}"
end
... | true |
c1f2f77b09653359082b85593337686401627136 | Ruby | tbierwirth/monster_shop | /app/models/item.rb | UTF-8 | 1,026 | 2.5625 | 3 | [] | no_license | class Item < ApplicationRecord
belongs_to :merchant
has_many :order_items
has_many :orders, through: :order_items
has_many :reviews, dependent: :destroy
validates_presence_of :name,
:description,
:image,
:price,
:... | true |
f29e7bdd59a18b1d47514c50030b5af393f38004 | Ruby | ept/cotweet-export | /lib/cotweet/download_queue.rb | UTF-8 | 832 | 2.796875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module CoTweet
class DownloadQueue
MAX_CONCURRENCY = 10
def initialize(&block)
@operation = block
@items_seen = Set.new
@active = {}
@queued = []
end
def <<(item)
return if @items_seen.include? item
@items_seen << item
if has_capacity?
start(item)
... | true |
8792a7f14da2ea2a23e9769d394d6a061455cede | Ruby | damoguyan8844/rumoji | /lib/rumoji/emoji/nature.rb | UTF-8 | 5,590 | 2.65625 | 3 | [
"MIT"
] | permissive | # -*- encoding: utf-8 -*-
require 'rumoji/emoji'
require 'set'
module Rumoji
class Emoji
NATURE = Set[
self.new("2600" , [:sunny], "BLACK SUN WITH RAYS"),
self.new("2614" , [:umbrella], "UMBRELLA WITH RAIN DROPS"),
self.new("2601" , [:cloud]),
self.new("2744" , [:snowflake]),
self.... | true |
a382405c7ff4e3eb4e004c1c75bf4eccd8368ae3 | Ruby | timpalpant/bioruby-genomic-file | /spec/utils/parallelizer_spec.rb | UTF-8 | 1,565 | 2.75 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #
# parallelizer_spec.rb
# bioruby-genomic-file
#
# Created by Timothy Palpant on 6/28/11.
# Copyright 2011 UNC. All rights reserved.
#
require 'spec_helper'
require 'utils/parallelizer'
describe Enumerable do
before do
@test = [1, 2, 3, 4, 5, 6, 7, 8]
end
context "#p_each" do
it "should iterate ... | true |
6edb3b8d22d1ac679f20ed0c65b9be1458e2ac81 | Ruby | dan-waters/advent_of_code_2020 | /day1/main.rb | UTF-8 | 254 | 2.703125 | 3 | [] | no_license | require_relative 'expenses_reader'
require_relative 'expenses_calculator'
expenses = ExpensesReader.new.expenses_from_file('inputs.csv')
puts ExpensesCalculator.new.product_of_2(expenses, 2020)
puts ExpensesCalculator.new.product_of_3(expenses, 2020)
| true |
157638e0afc494806c180518c9eef9ace20d642e | Ruby | felipemfp/programacao-de-computadores | /listas/lista-02/exercicio-18.rb | UTF-8 | 958 | 2.859375 | 3 | [] | no_license | test1, work1 = gets.to_f, gets.to_f
w_test1, w_work1 = gets.to_i, gets.to_i
test2, work2 = gets.to_f, gets.to_f
w_test2, w_work2 = gets.to_i, gets.to_i
grade1 = (test1 * w_test1 + work1 * w_work1) / (w_test1 + w_work1)
grade2 = (test2 * w_test2 + work2 * w_work2) / (w_test2 + w_work2)
partial_grade = (grade1 * 2 + gr... | true |
985841a36990147753e971698bea88548ccb7204 | Ruby | secorjeretweaz/als_typograf | /lib/als_typograf/request.rb | UTF-8 | 2,033 | 2.609375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # -*- encoding: utf-8 -*-
require 'net/http'
module AlsTypograf
# The request class
module Request
SERVICE_URL = URI.parse('http://typograf.artlebedev.ru/webservices/typograf.asmx')
SOAP_ACTION = '"http://typograf.artlebedev.ru/webservices/ProcessText"'
RESULT_REGEXP = /<ProcessTextResult>\s*((.|\n)*?... | true |
fb7d91006274870e86ce66b1acbd823d557ac488 | Ruby | lkriffell/whats-in-my-food | /app/facades/food_facade.rb | UTF-8 | 358 | 2.734375 | 3 | [] | no_license | class FoodFacade
def self.dishes_with_ingredient(ingredient)
dishes = FoodService.dishes_with_ingredient(ingredient)[:foods]
@dishes = dishes[0..9].map do |dish_data|
Dish.new(dish_data)
end
end
def self.total_dishes_with_ingredient(ingredient)
total_dishes = FoodService.dishes_with_ingredi... | true |
f5ff4be36d7612cf9865b94c164ed410f8fa937a | Ruby | Benjam-BB/Petbnb-Rails-BDD | /db/seeds.rb | UTF-8 | 1,038 | 2.640625 | 3 | [] | no_license | # This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
require 'faker'
Dog.destroy_all
Dogsitter.destroy_all
Stroll.destroy_all
City.destroy_all
puts "tout... | true |
d610a9bcb4a7bf2ef08a57e912030e149201f033 | Ruby | Sugai-Ayano/Bookers2-debug-5 | /app/models/book.rb | UTF-8 | 465 | 2.640625 | 3 | [] | no_license | class Book < ApplicationRecord
belongs_to :user
validates :title, presence: true
validates :body, presence: true, length: {maximum: 200}
def self.search_for(content,method)
if method == 'perfet'
Book.where(title: content)
elsif method == 'foword'
Book.where('title Like ?', content + '%')
elsif m... | true |
101cd58bc87abb62f3fc66b12a711fa2a10ca886 | Ruby | anilktechie/rb2py | /pyfixes/find.rb | UTF-8 | 315 | 2.53125 | 3 | [
"Zlib"
] | permissive | # array.find {|item| code}
# ==>
# def _block_XXXX(item):
# code
# rb2py.find(_block_XXXX, array)
class FindNode
def pyfix_find
block_def, block_name_node = prepare_new_block
call = make_rb2py_call 'find', block_name_node, target
insert_new_block block_def, call
return call
end
end
| true |
caa3bd93a667d9fb77e53c5306a03772bd229452 | Ruby | TheGuth/launch_school | /launch_school_review/course_120/lesson_4/hard_1.rb | UTF-8 | 1,120 | 3.359375 | 3 | [] | no_license | # Exercises: Hard 1
# Question 1. Alyssa has been assigned a task of modifying a class that was
# initially created to keep track of secret information. The new requirement
# calls for adding logging, when clients of the class attempt to access the
# secret data. Here is the class in its current form:
class Secret... | true |
48476e8b79fae0027400442f3edd35068112a228 | Ruby | ammar/cf_script | /lib/cf_script/command/cf/routes/routes.rb | UTF-8 | 814 | 2.5625 | 3 | [
"MIT"
] | permissive | module CfScript::Command
class Routes::RoutesCommand < CfScript::Command::Base
ROUTES_TABLE = ['space', 'host', 'domain', 'apps']
def initialize
super(:routes, :routes)
end
def run(*args, &block)
run_cf self do |output|
return unless good_run?(output)
if rows = output.ta... | true |
e5d58a16a85dc115b081d0900a54b598e0a1d818 | Ruby | microsoftgraph/msgraph-sdk-ruby | /lib/models/workbook_worksheet.rb | UTF-8 | 8,934 | 2.65625 | 3 | [
"MIT"
] | permissive | require 'microsoft_kiota_abstractions'
require_relative '../microsoft_graph'
require_relative './models'
module MicrosoftGraph
module Models
class WorkbookWorksheet < MicrosoftGraph::Models::Entity
include MicrosoftKiotaAbstractions::Parsable
##
# Returns collection of ... | true |
c782682238319bbaf675d1507512f16d20ff7d33 | Ruby | rgylling/countdown-to-midnight-v-000 | /countdown.rb | UTF-8 | 171 | 3.578125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive |
def countdown(integer)
while integer > 0
puts "#{integer} SECOND(S)!"
integer -=1
end
"HAPPY NEW YEAR!"
end
def countdown_with_sleep(integer)
sleep(integer)
end
| true |
843ab70307bdaad76a98df7769d58cc7b4faa9e7 | Ruby | Yoni-Satat/ruby_project | /controllers/artist_controller.rb | UTF-8 | 685 | 2.609375 | 3 | [] | no_license | require_relative('../models/album.rb')
require_relative('../models/artist.rb')
require_relative('../models/genre.rb')
get '/artist' do
@artist = Artist.all()
erb(:"artist/index")
end
get '/artist/new' do
erb :"artist/create_artist"
end
post '/artist' do
artist = Artist.new(params)
artist.save()
redirec... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.