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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
33907a8c775fb6573ec2d61f416ac0f59a09007c | Ruby | machinedogs/Authentication | /app/commands/authorize_api_request.rb | UTF-8 | 949 | 2.59375 | 3 | [] | no_license | # frozen_string_literal: true
# app/commands/authorize_api_request.rb
class AuthorizeApiRequest
prepend SimpleCommand
def initialize(params = {})
@params = params
end
def call
user
end
private
attr_reader :params
def user
@user ||= Host.find(decoded_auth_token[:host_id]) if decoded_a... | true |
2f719391e376f6c72ef4b2550f0636b38d6609a5 | Ruby | KIMJUNGKWON/ProgrammingRuby | /ch3/array.rb | UTF-8 | 2,731 | 4.40625 | 4 | [] | no_license | # 루비는 처음이므로 책에 나온 모든 함수들 다 짚고 넘어가기
# 특히 다른 함수를 사용함으로써 array를 stack과 queue로 활용하는 것 숙지
# Array 의 정의와 생성
# class Array < Object
# Arrays are ordered, integer-indexed collections of any object.
# Array indexing starts at 0, as in C or Java.
# A negative index is assumed to be relative to the end of the array
arr1 = []
... | true |
2ec5517aa911e62da4e10dd98cb5b4f0f075ef2b | Ruby | RReiso/ruby-practice | /Leetcode/single-number.rb | UTF-8 | 886 | 4.15625 | 4 | [] | no_license | #Given a non-empty array of integers nums, every element appears twice except for one.
#Find that single one.
def single_number(num)
hash = num.tally #Returns a hash with the elements of the collection as keys and the corresponding counts as values.
return hash.key(1)
end
puts single_number([4, 1, 2, 1, 2])
def si... | true |
865d0f98e6d1ac275eb25d5fbb8a468cd36231b6 | Ruby | bradrf/rsql | /lib/rsql.rb | UTF-8 | 794 | 2.734375 | 3 | [
"MIT"
] | permissive | # A module encapsulating classes to manage MySQLResults and process
# Commands using an EvalContext for handling recipes.
#
# See the {file:example.rsqlrc.rdoc} file for a simple tutorial and usage
# information.
#
module RSQL
VERSION = [0,3,1]
def VERSION.to_s
self.join('.')
end
# Set up our ... | true |
039d08998f8743f0c759e38468000029cba9eb67 | Ruby | ElaErl/Fundations | /exerc/easy4/2.rb | UTF-8 | 559 | 3.828125 | 4 | [] | no_license | def century(a)
def almost_all(a)
b = a / 100 + 1
if b.digits[0..1] == [3, 1]
puts "#{b}th"
elsif b.digits[0..1] == [2, 1]
puts "#{b}th"
elsif b.digits[0..1] == [1, 1]
puts "#{b}th"
elsif b % 10 == 1
puts "#{b}st"
elsif b % 10 == 2
puts "#{b}nd"
elsif b % 10 == 3
... | true |
0b424560f4092c49c9745a28867db123100f198d | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/word-count/572912c222da48b2b08607d955aff20a.rb | UTF-8 | 384 | 3.53125 | 4 | [] | no_license | class Words
attr_reader :split_cleaned_input
def initialize(raw_input)
@split_cleaned_input = spit_and_clean_input(raw_input)
end
def count
split_cleaned_input.each_with_object({}) do |word, hash|
hash[word] = split_cleaned_input.count(word)
end
end
def spit_and_clean_input(raw_input)
... | true |
1ae6e0990f46fbec8c29c2c7ce619b58ea448c28 | Ruby | palakverma/3-Warmups | /my_benchmark.rb | UTF-8 | 329 | 4 | 4 | [] | no_license |
def my_benchmark(number_of_times, word)
start = (Time.now)
number_of_times.times do
word
end
finish = (Time.now) - start
puts finish
end
puts "Enter the # of times you want this block to run: "
number_of_times = gets.chomp.to_i
puts "Enter your word: "
word = gets.chomp.to_s
my_benchmark(number_of_tim... | true |
fbe4f1553c288c9f4f1f0c56a1ca120c6afa3455 | Ruby | ahoward/openobject | /sample/c.rb | UTF-8 | 186 | 2.734375 | 3 | [] | no_license | require 'openobject'
oo = openobject :foo => 42
oo.bar = 'forty-two'
oo.extend do
fattr :foobar => 42.0
def barfoo
[ foo, bar, foobar ]
end
end
p oo.foobar
p oo.barfoo
| true |
2a491c0f658695cba5c56145eb680f953dffe873 | Ruby | sf-bobolinks-2016/DBC-Overflow-Team-Emerald | /app/models/user.rb | UTF-8 | 740 | 2.78125 | 3 | [
"MIT"
] | permissive | class User < ActiveRecord::Base
has_many :questions
has_many :answers
has_many :comments
validates :email, :hashed_password, presence: true
validates :email, uniqueness: true
include BCrypt
def password
@password ||= Password.new(hashed_password)
end
def password=(pass)
@password = Passwor... | true |
90c9d086276e067bdb5ba590c7843401bc9223ca | Ruby | MichaelHilton/TDDViz | /lib/UniqueId.rb | UTF-8 | 626 | 2.796875 | 3 | [
"MIT"
] | permissive | # mixin
module UniqueId
def unique_id
`uuidgen`.strip.delete('-')[0...10].upcase
end
end
# 10 hex chars gives N possibilities where
# N == 16^10 == 1,099,511,627,776
# which is more than enough as long as
# uuidgen is reasonably well behaved.
#
# 6 hex chars are all that need to be entered
# to enable id-au... | true |
e6f7e8ae13baef6acc81151d44c07ecbc888168e | Ruby | jichen3000/colin-ruby | /test/module_test/many_modules.rb | UTF-8 | 714 | 2.625 | 3 | [] | no_license | require 'testhelper'
module ColinA
def my_p
"ColinA".pt
self.class.pt
__method__.pt
end
def my_call_p
"ColinA".pt
__method__.pt
my_p
end
end
module ColinB
def my_p
"ColinB".pt
self.class.pt
__method__.pt
end
# def my... | true |
e77e40acfb9066f86dc1a3b169922017903da8f5 | Ruby | lfborjas/minimalisp | /norvig/tests.rb | UTF-8 | 4,528 | 3.265625 | 3 | [] | no_license | #Tests for the ruby translation of Peter Norvig's Lispy
#These are also his: http://norvig.com/lispy2.html
require './norvig.rb'
require 'test/unit'
module Test::Unit
class TestCase
alias_method :t?, :assert
def f?(c)
assert c == false
end
def self.must(name, &block)
... | true |
8983f8d10dfc115ae83f8179d9c6c47193963c18 | Ruby | RianaFerreira/ruby-sandbox | /hashes.rb | UTF-8 | 597 | 3.96875 | 4 | [] | no_license | # hash is an unordered collection organized into key/value pairs
# key is the address
# value is the data at that address
# => rocket links a key with a value
produce = {
"apples" => 3,
"oranges" => 5,
"carrots" => 12
}
puts "There are #{produce["oranges"]} oranges in the fridge."
produce["grapes"] = 221
puts pr... | true |
e0a6a446896aeb7570e9f147337518d038060778 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/series/ca3773fe40d94be49299056283c44d44.rb | UTF-8 | 428 | 3.546875 | 4 | [] | no_license | class Series
attr_reader :numbers
def initialize(string)
@numbers = collect_integers_from(string)
end
def slices(scope)
raise ArgumentError if scope > numbers.length
result = []
numbers.length.times do |i|
slice = numbers[i,scope]
result << slice if slice.length == scope
end
... | true |
c5669cd24a4c0887dec93f40b80ffca28d37d292 | Ruby | katietensfeldt/movie-app | /script.rb | UTF-8 | 575 | 3.328125 | 3 | [] | no_license | require "http"
system "clear"
puts "==========================="
puts "Welcome to the Movies App!"
puts "==========================="
puts
puts "Here are some of my favorite movies:"
puts
response = HTTP.get("http://localhost:3000/all_movies")
movies = response.parse
movies.each { |movie| puts movie["title"] }
pu... | true |
dba33869be408a67d5a369ff3d6bb7c2781fd9ac | Ruby | cjeycjey/LiquidPlanner | /examples/create_task.rb | UTF-8 | 1,081 | 2.671875 | 3 | [] | no_license | # Require the LiquidPlanner API.
require File.dirname(__FILE__) + '/../lib/liquidplanner'
# Require support libraries used by this example.
require 'rubygems'
require 'highline/import'
require File.dirname(__FILE__) + '/support/helper'
# Get the user's credentials
email, password, space_id = get_cre... | true |
12b0c4f7aa2b35456321eb210d87fb639d373464 | Ruby | oshou/procon | /Paiza/D/d097.rb | UTF-8 | 133 | 3.140625 | 3 | [] | no_license | arr = gets.chomp.split.map { |i| i.to_i }
cloudy = arr.select { |i| i == 1 }.length
if cloudy >= 5
puts "yes"
else
puts "no"
end
| true |
b699f316ff9a70d14c73a427498d959dcc0610ad | Ruby | siman-man/Ruby | /ryudai_rb/ryudai_rb5/lisp/lib/method_missing.rb | UTF-8 | 208 | 3.234375 | 3 | [] | no_license | class Test
def method_missing(name, *args)
p name
p args
end
def hello(*args)
p "hello"
end
end
@t = Test.new
def test(&block)
@t.instance_eval(&block)
end
@t.test(:+, (:hello, 3))
| true |
9df266a68cc5eb82b31e31a1bda59822e93ca612 | Ruby | MichaelGofron/TDDRuby | /02_calculator/calculator.rb | UTF-8 | 205 | 3.40625 | 3 | [] | no_license | def add(a,b)
a + b
end
def subtract(a,b)
a - b
end
def sum(array)
array.inject(0, :+)
end
def multiply(a,b)
a*b
end
def power(a,b)
a**b
end
def factorial(a)
a <= 1 ? 1 : a * factorial(a-1)
end
| true |
dc6764b38535a1283eff921353c56bd162e6e367 | Ruby | dmytro/capistrano-recipes | /base.rb | UTF-8 | 5,779 | 2.59375 | 3 | [] | no_license | #require 'chef/knife'
require 'chef/application/solo'
require 'chef/data_bag_item'
require 'pathname'
require 'securerandom'
$LOAD_PATH << "#{File.dirname(__FILE__)}/lib"
require "git_tags"
def fatal(str)
sep = "\n\n#{'*' * 80}\n\n"
abort "#{sep}\t#{str}#{sep}"
end
##
# Read databag on local host, using custom ... | true |
2353fd9d5f1251bdb2a5f4dee7be4af42e54aa01 | Ruby | caspg/bitmap_editor | /spec/bitmap_editor_spec.rb | UTF-8 | 3,606 | 3.078125 | 3 | [] | no_license | require 'spec_helper'
require_relative '../app/bitmap_editor'
describe BitmapEditor do
subject { described_class.new(bitmap) }
let(:bitmap) { double(:bitmap) }
describe '#run' do
it 'outputs initial message with prompt sign' do
allow(subject).to receive(:gets).and_return('X')
expect { subj... | true |
ee27bfeacbab645f133f0b21ce007ce3aa9b0cd7 | Ruby | johnofsydney/eulers | /ex4/main.rb | UTF-8 | 536 | 3.984375 | 4 | [] | no_license | puts "ruby"
#
# A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.
#
# Find the largest palindrome made from the product of two 3-digit numbers.
def palin
candidates = []
(100..999).to_a.reverse.each do |x|
(100..999).to_a.rev... | true |
b98ab95198d0728f396a181b6ebe51ad8a8bc972 | Ruby | djdarkbeat/yard-junk | /lib/yard-junk/janitor/resolver.rb | UTF-8 | 3,303 | 2.625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module YardJunk
class Janitor
class Resolver
include YARD::Templates::Helpers::HtmlHelper
include YARD::Templates::Helpers::MarkupHelper
# This one is copied from real YARD output
OBJECT_MESSAGE_PATTERN = "In file `%{file}':%{line}: " \
... | true |
3d009ff199163850001932d50574949bb11c6294 | Ruby | corinnawiesner/knowledge_base | /spec/forms/articles/new_form_spec.rb | UTF-8 | 2,432 | 2.515625 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe Articles::NewForm, type: :form do
context "validations" do
it { is_expected.to validate_presence_of(:title) }
it { is_expected.to validate_length_of(:title).is_at_least(5) }
it { is_expected.to validate_presence_of(:abstract) }
it { is_expected.to validate_presen... | true |
36bda30bc7cdee65ab982447684cb23778ac1db1 | Ruby | theironyard-rails-atl/AndrewHouse | /8-06/widget.rb | UTF-8 | 907 | 3.078125 | 3 | [] | no_license | require 'yaml'
WIDGET_INFO = YAML.load_file('widgets.yml')
class Widget
include Enumerable
attr_reader :widgets
def initialize widgets
@widgets = widgets
end
def each
@widgets.each { |widget| yield widget }
end
def max_price
@widgets.max_by { |widget| widget[:price] }
end
def min_pri... | true |
5662ed8b9b6a27957ee2e9fea3f6825fd7904ccf | Ruby | CiaraAnderson/image_blur | /imageblurtwo.rb | UTF-8 | 1,672 | 3.84375 | 4 | [] | no_license | class Image
def initialize(array)
@image = array
end
def output_image
@image.each do |row|
puts row.join
end
end
def blur_coords!
coords_to_blur = []
@image.each_with_index do |row, row_index|
# [0, 0, 0, 0, 0, 0]
row.each_with_index do |column, column_ind... | true |
d60e454592176b51634cb4ab11f9791a4d09faa3 | Ruby | DumboCL/TL-Course1-Object-Oriented-Programming-Book | /inheritance.rb | UTF-8 | 1,898 | 4.0625 | 4 | [] | no_license | # inheritance.rb
# my_car
module Towable
def can_tow?(pounds)
pounds < 2000 ? true : false
end
end
class Vehicle
@@number_of_vehicles = 0
attr_accessor :color, :model, :current_speed
attr_reader :year
def initialize(year, color, model)
@year = year
@color = color
@model = model
@c... | true |
a4a4c112c317a49c5ef87d07e20cd2634f24073c | Ruby | masahino/mruby-mrbmacs-base | /mrblib/project.rb | UTF-8 | 1,099 | 2.515625 | 3 | [
"MIT"
] | permissive | module Mrbmacs
# Project
class Project
attr_accessor :root_directory, :build_command, :last_build_command
def initialize(root_directory)
@root_directory = root_directory
@build_command = guess_build_command
@last_build_command = nil
end
def guess_build_command
build_types =... | true |
4f27388bc3c8368a842027d7a63403a19f4431fc | Ruby | brucedickey/poly-app | /test/controllers/categories_controller_test.rb | UTF-8 | 2,232 | 2.71875 | 3 | [] | no_license | # frozen_string_literal: true
# SQLite3 DB may become busy locked. Fix is Andrew's answer here:
# https://www.udemy.com/course/the-complete-ruby-on-rails-developer-course/learn/lecture/3852574#questions/9537992
# which is to comment out the parallelize line in test/test_helper.rb.
require "test_helper"
class Categor... | true |
955ad36814bf2433c4f72edeafdb2341818ab393 | Ruby | hboulter/silicon-valley-code-challenge-austin-web-102819 | /app/models/startup.rb | UTF-8 | 1,481 | 2.984375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Startup
attr_accessor :name, :investors
attr_reader :founder, :domain
@@all = []
@@all_domains = []
def initialize(name, founder, domain)
@name = name
@founder = founder
@domain = domain
@@all << self
@@all_domains << domain
end
def pivot(name... | true |
0a2a10410dde86af05094b15c07a1be710dd9bea | Ruby | Geovo/codeeval | /easy/intersect/intersect.rb | UTF-8 | 298 | 2.6875 | 3 | [] | no_license | File.open(ARGV[0]).each_line do |line|
string = []
matches = line.chomp.match(";")
a = matches.pre_match.split(',')
b = matches.post_match.split(',')
a.map{|x| string << x if b.include?(x)}
puts string.join(',')
end
# l = (string.length * (-1))
# p string
#puts string
| true |
4cc4f62f0a259f57f67cdc1f81154dfead9e1bca | Ruby | masao/nextl-util-mailer | /lib/next_l/mailer/logger.rb | UTF-8 | 822 | 2.640625 | 3 | [] | no_license | # -*- coding:utf-8 -*-
# ja: 転送したメールのログを記録・出力するモジュール
module NextL::Mailer::Logger
def setup_logger
@logger ||= ::NextL::Mailer::Logger::Logger.new
end
def log
setup_logger
@logger.log
end
def latest_log
setup_logger
@logger.latest_log
end
def add_log(mail)
setup_logger
@lo... | true |
e5d588345339353c7bd7ff34fb051a5402438999 | Ruby | rikniitt/wadror_beer | /spec/models/user_spec.rb | UTF-8 | 3,867 | 2.578125 | 3 | [] | no_license | require 'spec_helper'
describe User do
it "has the username set correctly" do
user = User.new :username => "Pekka"
user.username.should == "Pekka"
end
it "is not saved without a proper password" do
user = User.create :username => "Pekka69"
expect(user.valid?).to be(false)
expect(User.count).to eq(0)
... | true |
24ea5ecea327b50ae7a36150b6be1707c7b88e1c | Ruby | lassiter/sep-assignments | /01-data-structures/05-hashes-part-2/open_addressing/open_addressing.rb | UTF-8 | 2,328 | 3.484375 | 3 | [] | no_license | require_relative 'node'
class OpenAddressing
def initialize(size)
@items = Array.new(size)
@size = size
end
# Places Key Value pair at an index.
def []=(key, value)
inital_index = index(key,@size)
node = Node.new(key, value)
# Immediate Placement of Key Pair
if @items[inital_index].nil... | true |
a70f1606e3b5544231ac5cbd47df8d40f8645133 | Ruby | joshtkim/ruby-oo-relationships-practice-gym-membership-exercise-nyc01-seng-ft-042020 | /tools/console.rb | UTF-8 | 767 | 2.828125 | 3 | [] | no_license | # You don't need to require any of the files in lib or pry.
# We've done it for you here.
require_relative '../config/environment.rb'
# test code goes here
gym1 = Gym.new("24 hr fitness")
gym2 = Gym.new("Retro")
gym3 = Gym.new("Planet Fitness")
gym4 = Gym.new("Equinox")
lifter1 = Lifter.new("Josh", 150)
lifter2 = Lif... | true |
eeb460be3f67952fbfe337634f87ff81da7884af | Ruby | ed5j4prog-winter/iotex-esp32-mrubyc | /mrblib/models/i2c.rb | UTF-8 | 1,093 | 2.796875 | 3 | [] | no_license | class I2C
# 定数
MASTER = 0
SLAVE = 1
# 初期化
def initialize(port, scl, sda, freq = 400000)
@port = port
@scl = scl
@sda = sda
@freq = freq
self.driver_install
end
# コンストラクタ外からの再初期化
def init(port, scl, sda, freq = 400000)
@port = port
@scl = scl
@sda = sda
@freq = f... | true |
0a9c88d5c51c23fb4b78a14647b4b132b6355b4f | Ruby | arvicco/win_gui | /book_code/guessing/spec_helper.rb | UTF-8 | 1,642 | 2.609375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #---
# Excerpted from "Scripted GUI Testing With 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.
# Vi... | true |
f9c2e49c9de6ac98ff6361e79bb1f1b32d36ba96 | Ruby | Eli017/romanconvertor | /romanconvertor.rb | UTF-8 | 1,911 | 4.1875 | 4 | [] | no_license | def fromRoman(romanNumber)
valid = ["M","D","C","L","X","V","I"]
for c in romanNumber.chars
if !valid.include? c
raise TypeError
end
end
number = 0
number += romanNumber.count("M") * 1000
number += romanNumber.count("D") * 500
number += romanNumber.count("C") * 1... | true |
665c16f9f9c900b4c9662bc2542259809b436708 | Ruby | milenoss/OO-Animal-Zoo-london-web-082619 | /lib/Zoo.rb | UTF-8 | 1,080 | 3.796875 | 4 | [] | no_license | class Zoo
attr_reader :name, :location
@@all = []
def initialize(name,location)
@name = name
@location = location
@@all << self
end
def self.all
@@all
end
# we iterate over animals class to find out all the animals in the zoo.
def animals #instance method soo zo... | true |
0170baad78112161f12f923aaba6389af2a36aa1 | Ruby | bpieck/rubyx | /lib/risc/builtin/word.rb | UTF-8 | 2,788 | 2.625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module Risc
module Builtin
module Word
module ClassMethods
include CompileHelper
# wrapper for the syscall
# io/file currently hardcoded to stdout
# set up registers for syscall, ie
# - pointer in r1
# - length in r2
# - emit_syscall (which does the r... | true |
56447067eb185318b90af2dec01d6e1fbceca47a | Ruby | smallfryy/RaiseYourHand | /app/models/tag.rb | UTF-8 | 1,230 | 2.515625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | # == Schema Information
#
# Table name: tags
#
# id :integer not null, primary key
# name :string
# created_at :datetime not null
# updated_at :datetime not null
#
class Tag < ActiveRecord::Base
has_many :question_tags
has_many :questions, through: :question_tags
valida... | true |
fbe8ed5947543bda59d26d7d5463860ad2b69a59 | Ruby | J-Y/RubyQuiz | /ruby_quiz/quiz68_sols/solutions/Patrick Chanezon/current_temp.rb | UTF-8 | 319 | 2.796875 | 3 | [
"MIT"
] | permissive | require 'net/http'
puts ((ARGV.length != 1) ? "Usage: #$0 <zip code>" : (["The temperature
in"] + (/Weather<\/b> for <b>(.*)<\/b>.*\D(\d+)°F/.match(Net::HTTP.get(
URI.parse("http://www.google.com/search?hl=en&q=temperature+#{ARGV[0]}")))[1,2].collect!
{|x| " is " + x})).to_s.gsub!(/in is /, "in ") + " degree F")
| true |
63f0201d81b38affde1da4413184a4313c24e420 | Ruby | kaleflatbread/cartoon-collections-nyc-web-051418 | /cartoon_collections.rb | UTF-8 | 515 | 3.390625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def roll_call_dwarves(dwarf_names)
index = 1
dwarf_names.each do |name|
puts "#{index}. #{name}"
index +=1
end
end
def summon_captain_planet(list_of_foods)
list_of_foods.collect do |food|
food.split.map(&:capitalize).join('') + "!"
end
end
def long_planeteer_calls(array_of_calls)
array_of_call... | true |
424c7dc3779b02f12230ba69b165d1ebc213f022 | Ruby | thesilentc/square_array-v-000 | /square_array.rb | UTF-8 | 233 | 3.875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # example elements for array [1, 2, 3]
def square_array(array)
squared = [] # create new empty array
array.each { |element| squared << element ** 2 } # 1**1, 2**2, 3**3
squared # reurns new array of squared array [1, 4, 9]
end
| true |
c5ec792b5aede0557f66680ae904f0317a90b891 | Ruby | OthmanAmoudi/cartoon-collections-cb-gh-000 | /cartoon_collections.rb | UTF-8 | 635 | 3.453125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def roll_call_dwarves array# code an argument here
# Your code here
array.each_with_index do |name,index|
puts "#{index+1} #{name}"
end
end
def summon_captain_planet array# code an argument here
# Your code here
array.collect do |item|
"#{item.capitalize}!"
end
end
def long_planeteer_calls array# ... | true |
856305f06450471374c29241d221dc6adcd23c3d | Ruby | EdwinHongCheng/aAHomework | /W4D5/02 Octopus Problems/My Answer/octopus_problems.rb | UTF-8 | 2,956 | 4.15625 | 4 | [] | no_license | # Octopus Problems (W4D5 HW)
# Finished: the day before W4D5
# array of fishes of different string lengths
fishes = ['fish', 'fiiish', 'fiiiiish', 'fiiiish', 'fffish', 'ffiiiiisshh', 'fsh', 'fiiiissshhhhhh']
# 1. Sluggish Octopus
# uses Bubble Sort - O(n^2) time
def sluggish_octopus(arr)
bubble_sort(arr)[-1]
... | true |
04763767aa736298de9829603953e68179748020 | Ruby | Bestra/cso-chorus-page | /app/models/user.rb | UTF-8 | 260 | 2.609375 | 3 | [] | no_license | class User
def self.from_session_token(token)
type = Authenticator.authenticate_type(token)
return unless type
User.new(type == :admin ? true : false)
end
def initialize(admin)
@admin = admin
end
def is_admin?
@admin
end
end
| true |
7e9e176e7c6512af5e6259894e47233f3557bda4 | Ruby | miguelmota/twitter-purge | /purge.rb | UTF-8 | 1,745 | 2.625 | 3 | [
"MIT"
] | permissive | require 'dotenv/load'
require 'twitter'
@client = Twitter::REST::Client.new do |config|
config.consumer_key = ENV['TWITTER_CONSUMER_KEY']
config.consumer_secret = ENV['TWITTER_CONSUMER_SECRET']
config.access_token = ENV['TWITTER_ACCESS_TOKEN_KEY']
config.access_token_secret = ENV['TWITTER_ACCESS_TOKEN_SECRET']
end... | true |
bebb270eeae9da0968223a7aeed0b9f139377e16 | Ruby | BlaneCordes/99bottles | /lib/bottles.rb | UTF-8 | 1,226 | 3.8125 | 4 | [] | no_license | class Bottles
def verse(number_of_bottles)
verse_response(number_of_bottles)
end
def verses(start_of_range, end_of_range)
[*end_of_range..start_of_range].reverse.map do |number_of_bottles|
verse(number_of_bottles)
end.join("\n")
end
def song
[*0..99].reverse.map do |bottles|
vers... | true |
4fc45938ce88387a8889b4806995f06697f9596c | Ruby | somethinrother/bitmaker_lessons | /roll-of-the-die/james_dice/permutations.rb | UTF-8 | 209 | 3.078125 | 3 | [] | no_license | roll1 = 1
roll2 = 1
until roll1 == 7
if roll2 == 7
roll2 = 1
end
if roll2 < 6
puts "#{roll1} #{roll2}"
roll2 += 1
else
puts "#{roll1} #{roll2}"
roll1 += 1
roll2 += 1
end
end
| true |
88b43cb35b1ccfe27e26c701efd3d9cd849fef1b | Ruby | danthompson/seesaw-rb | /lib/seesaw/client/timelines.rb | UTF-8 | 409 | 2.578125 | 3 | [
"MIT"
] | permissive | module Seesaw
class Client
# Client methods for working with timelines
module Timelines
# Get recent decisions from the global timeline.
#
# @param limit [Fixnum] Number of decisions to return.
# @return [Array]
# @example
# Seesaw.recent_decisions
def global_timeli... | true |
85057ded5d2bf4ffc2b307b5f4daf0842abb68e0 | Ruby | VadimVadimVadim1337/ruby4 | /1lab/lib/main2.rb | UTF-8 | 493 | 3.515625 | 4 | [] | no_license | class FK
def otvet(number)
(number - 32) / 1.8 + 273
end
end
class KC
def otvet(number)
number - 273
end
end
class KF
def otvet(number)
(number - 273) * 1.8 + 32
end
end
class CF
def otvet(number)
(number * 9 / 5) + 32
end
end
class CK
def otvet(number)
number + 273
end
end
... | true |
d19b65c07af035aafc73a353090381e82247de16 | Ruby | szareey/ministryDocs | /lib/ministry_docs/math_2007_doc/doc_parser.rb | UTF-8 | 804 | 2.6875 | 3 | [] | no_license | module MinistryDocs
module Math2007Doc
class DocParser < MinistryDocs::BaseDoc::DocParser
PDF_URL = 'https://www.edu.gov.on.ca/eng/curriculum/secondary/math1112currb.pdf'
TXT_URL = 'https://www.edu.gov.on.ca/eng/curriculum/secondary/math1112currb.txt'
protected
def info(courses)
... | true |
02500a3a6075754175a98fafd1d77f9c6f77636c | Ruby | willmoeller/launch-school | /exercises/101-109_small_problems/easy_1/stringy_strings.rb | UTF-8 | 793 | 4.96875 | 5 | [] | no_license | # Write a method that takes one argument, a positive integer, and returns a
# string of alternating 1s and 0s, always starting with 1. The length of the
# string should match the given integer.
def stringy(integer)
binary = []
(1..integer).each do |num|
binary << 0 if num.even?
binary << 1 if num.odd?
en... | true |
529409ce535d52df17a9e9581b9610692b739eac | Ruby | dkubb/axiom-do-adapter | /lib/axiom/adapter/data_objects/statement.rb | UTF-8 | 2,657 | 2.671875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | # encoding: utf-8
module Axiom
module Adapter
class DataObjects
# Executes generated SQL statements
class Statement
include Enumerable, Adamantium::Flat
# Initialize a statement
#
# @param [::DataObjects::Connection] connection
# the database connection
... | true |
5ec62c114e2e3589608486fcaa5d38272ee0805f | Ruby | JKCodes/ttt-with-ai-project-v-000 | /bin/tictactoe | UTF-8 | 3,205 | 3.609375 | 4 | [] | no_license | #!/usr/bin/env ruby
require_relative '../config/environment'
flag = false
until flag
puts "\e[H\e[2J"
puts "Welcome to Tic Tac Toe!\n"
puts "How many human players for this game? (0, 1, or 2)"
puts " Enter -1 to simulate 10000 computer player games"
num_human_players = gets.strip
until num_human_players... | true |
bf925cd1cfe59347ff3eb336ed4fd890101e9a02 | Ruby | yamshim/StockPortal | /lib/clawler/models/credit_deal.rb | UTF-8 | 3,714 | 2.53125 | 3 | [] | no_license | # coding: utf-8
module Clawler
module Models
class CreditDeal < Clawler::Base
extend AllUtils
# include Clawler::Sources
# Initializeは一番最初にスクリプトとして実行する csv化するか、分割化するかなどはまた後で
# sleepを入れる
# エラーバンドリング
# 強化
# 重複データの保存を避ける
# break, next
def self.patrol
cr... | true |
5be843b5a9b7aa203b8864cbcab5fe6754ef9b21 | Ruby | fanjieqi/LeetCodeRuby | /101-200/128. Longest Consecutive Sequence.rb | UTF-8 | 298 | 3.203125 | 3 | [
"MIT"
] | permissive | # @param {Integer[]} nums
# @return {Integer}
def longest_consecutive(nums)
hash = nums.zip(nums).to_h
max = 0
nums.each_with_index do |num, index|
next if hash[num - 1]
count = 0
while hash[num]
count += 1
num += 1
end
max = [max, count].max
end
max
end
| true |
afc863de5252e9b17c2b772ac97f406747871731 | Ruby | ReinaldoAguilar/AT03_API_test | /DanielCabero/practice5/exercise2.rb | UTF-8 | 948 | 3.5625 | 4 | [] | no_license | class Exercise2
def initialize maps
@users= hash
@users = maps
end
def getValuesNumbers
@users.each_key {|key | key=~/1(.*)/
puts "#{key}"
}
end
def numbersGroups
@users.each_key {|key| result = case key
when 0..25 then puts "Use belong Group ... | true |
9a4eec2fb8912780bf97ec48a6e5e5216c69b2e7 | Ruby | rparkerson/launch-school | /RB100/intro_to_ruby/7_hashes/8.rb | UTF-8 | 1,523 | 3.765625 | 4 | [] | no_license | words = ['demo', 'none', 'tied', 'evil', 'dome', 'mode', 'live',
'fowl', 'veil', 'wolf', 'diet', 'vile', 'edit', 'tide',
'flow', 'neon']
# print out groups of words that are anagrams
# print out seperate lines as arrays
# go through each index assign each word to alphabetical compare with
# all ... | true |
386b2d48cc7f1532f69b556d6cd32145bd351d66 | Ruby | ltello/checkout | /spec/lib/promotional_rules/promotion_spec.rb | UTF-8 | 1,998 | 3.09375 | 3 | [] | no_license | # frozen_string_literal: true
describe Promotion do
class MyPromotion < Promotion
DISCOUNT_PER_UNIT = 5
private
def applicable?
item_names.include?("A")
end
def computed_discount
item_names.count("A") * DISCOUNT_PER_UNIT
end
end
class WrongPromotion < Promotion
end
de... | true |
156e91af148f4c34f0156847ab284210c784a27f | Ruby | evantravers/euler | /ruby/40.rb | UTF-8 | 341 | 2.84375 | 3 | [] | no_license | counter = 0
num = 0
targets = [1, 10, 100, 1000, 10000, 100000, 1000000]
solutions = []
until targets.empty?
num.to_s.chars.each do |char|
if targets.include?(counter)
targets.delete(counter)
puts "found a char! #{char}"
solutions << char.to_i
end
counter += 1
end
num += 1
end
puts ... | true |
e6235ee6242b62cb7d837ffc989ae69a17695942 | Ruby | heysaturday/samples | /walker-realty-locomotive-engine-2/lib/rets/syncer.rb | UTF-8 | 1,910 | 2.609375 | 3 | [] | no_license | require_relative '../../app/models/singlefamily'
require_relative '../../app/models/rets_update'
require_relative '../../app/models/mls'
require 'logger'
require 'mongoid'
require 'pathname'
dump = false
ingest = false
dump = true if ARGV.include?("dump")
ingest = true if ARGV.include?("ingest")
if !(dump || ingest... | true |
38ca0a86f1c4040dc5c7c7482479ac83bd2f529b | Ruby | skryl/restforce-db | /lib/restforce/db/tracker.rb | UTF-8 | 1,266 | 2.90625 | 3 | [
"MIT"
] | permissive | module Restforce
module DB
# Restforce::DB::Tracker encapsulates a minimal API to track and configure
# synchronization runtimes. It allows Restforce::DB to persist a "last
# successful sync" timestamp.
class Tracker
attr_reader :last_run
# Public: Initialize a Restforce::DB::Tracker. ... | true |
5046bef5900a4b0095c6bc949023cee60b10f76d | Ruby | ichylinux/banbanlive | /app/models/band_member.rb | UTF-8 | 535 | 2.53125 | 3 | [] | no_license | # coding: UTF-8
module BandMemberConst
INSTRUMENTS = {
VOCAL = 1 => 'ボーカル',
GUITAR = 2 => 'ギター',
BASE = 3 => 'ベース',
KEYBOARD = 4 => 'キーボード',
DRUM = 5 => 'ドラム',
}
end
class BandMember < ActiveRecord::Base
include BandMemberConst
belongs_to :band
belongs_to :member
attr_accessible :... | true |
a9b6f1545c0274fbca1b0bf0cc2b141f39291a6a | Ruby | mose/icallect | /lib/icallect/config.rb | UTF-8 | 829 | 2.65625 | 3 | [
"MIT"
] | permissive | require "yaml"
module Icallect
class Config
CONFIG_DEFAULTFILE = File.expand_path("../../../config.yml.defaults",__FILE__)
attr_reader :feeds
def initialize
@__configfile = nil
@feeds = []
@values = {}
setup
end
def setup
FileUtils.mkdir_p(File.dirname(configfile... | true |
ba7a4c053abab8cd5a66421b837cd12dc44b422e | Ruby | kinsomicrote/gofish-game-api | /app/services/v1/deck_service.rb | UTF-8 | 2,929 | 2.96875 | 3 | [] | no_license | # frozen_string_literal: true
module V1
class DeckService
RANK = { "2" => "two", "3" => "three", "4" => "four", "5" => "five", "6" => "six", "7" => "seven", "8" => "eight",
"9" => "nine", "10" => "ten", "KING" => "king", "ACE" => "ace", "JACK" => "jack", "QUEEN" => "queen" }.freeze
def new_game... | true |
accf7b79bc1249fcade3e654d71ac55e82ceb33e | Ruby | yatinsns/testing-playground | /learn-ruby/mixing-code-data/second.rb | UTF-8 | 162 | 2.625 | 3 | [] | no_license | def print_second_data
puts "Second file\n--------"
puts DATA.read # Won't output anything, since first.rb read the entire file
end
__END__
Second end clause
| true |
6e3679ef3895d7e3f3e3e1af0c02aa4db5851e67 | Ruby | mnain/learn-ruby | /Massmail/mailtest.rb | UTF-8 | 1,710 | 2.515625 | 3 | [] | no_license | require 'net/smtp'
require 'rubygems'
require 'mailfactory'
filename = 'emaillist.csv'
mail = MailFactory.new()
mail.to = "mnain@yahoo.com"
mail.from = "madan@mnain.org"
mail.subject = "DLF Jasola for Lease"
mail.text = <<EOF1
DLF Commercial office Space for Lease in tower A.ready for possession in Jan 09.
... | true |
f988b0cfeccd4c3ec74dc6397978d5894696261d | Ruby | c80609a/improved-adventure | /lib/css_pictures.rb | UTF-8 | 1,392 | 2.671875 | 3 | [] | no_license | require 'base64'
require 'css_parser'
require 'securerandom'
require 'uri_helper'
class CSSPictures
include UriHelper
URL_REGEX = /url\(["']?(?<img>[^"'\)]+)/
BASE64_REGEX = /data:(?<type>[^\/]+)\/(?<ext>[^;]+);base64,(?<base64>.+)/
attr_reader :source, :parser, :download_manager
def initialize(source:, ... | true |
e9505eeedf8fd935d7e3638992aa0fd2084d9563 | Ruby | yndajas/ttt-with-ai-project-online-web-sp-000 | /lib/game.rb | UTF-8 | 1,780 | 3.96875 | 4 | [] | no_license | require 'pry'
class Game
attr_accessor :board, :player_1, :player_2
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 initialize(player_1 = Players::Human.new("X"), player_2 = Players::Human.new("O"), board = Board.new)
self.... | true |
df4de5023f8ee40be278f6b902dfd9f4aac5515c | Ruby | Heybluguy/black_thursday | /test/item_repository_test.rb | UTF-8 | 1,918 | 2.84375 | 3 | [] | no_license | require_relative 'test_helper'
require './lib/item_repository'
class ItemRepositoryTest < MiniTest::Test
attr_reader :ir
def setup
@ir = ItemRepository.new
end
def test_it_exists
assert_instance_of ItemRepository, ir
end
def test_all_returns_all_items_in_array
ir.populate('test/fixtures/it... | true |
8f70093ac744c117f70a57a5f953fca7e8e28a52 | Ruby | jpe442/W2D3 | /poker/spec/player_spec.rb | UTF-8 | 423 | 2.734375 | 3 | [] | no_license | require 'player'
describe Player do
subject(:player) { Player.new }
let(:dealer) { double("dealer") }
let(:card) { double("King of Spades") }
describe "#initialize" do
it "initializes with an empty hand" do
expect(player.hand).to eq([])
end
end
describe "#receive_card" do
it "receives c... | true |
6a2a8cbf652f1ad0e2739d25d2a07c1e4439b01f | Ruby | eoliveiramg/viva_challenge | /app/factory/province_factory.rb | UTF-8 | 476 | 2.625 | 3 | [] | no_license | class ProvinceFactory
def self.build(province_params)
province_params.to_h.map do |key, value|
Province.new(
name: key,
upper_left_x: value.fetch(:boundaries).fetch(:upperLeft).fetch(:x),
upper_left_y: value.fetch(:boundaries).fetch(:upperLeft).fetch(:y),
bottom_right_x: valu... | true |
26ee076d914152a19b4b785e6b6f4348ad6acbf8 | Ruby | JEG2/icfp_2014 | /lib/lambda_lang/lexer.rb | UTF-8 | 633 | 3.234375 | 3 | [] | no_license | require "strscan"
module LambdaLang
class Lexer
TOKEN_REGEX = /(?:==|>=|<=|\w+|[-+*\/(){},&<>#'"])/
def initialize(code)
@code = StringScanner.new(code)
consume_whitespace
end
attr_reader :code
private :code
def next
code.scan(TOKEN_REGEX).tap do
consume_whit... | true |
902b2330f134529d428900b7315dbc4b2c649673 | Ruby | AndreiMotinga/ctci | /arrays_and_strings/urlify.rb | UTF-8 | 113 | 3.046875 | 3 | [] | no_license | # write a method to replace all spaces in a stirng with '%20'.
def urlify(str)
str.strip.gsub(" ", "%20")
end
| true |
c6da8751aee2250118a522eda32f2d570f25e82d | Ruby | myokoym/poker | /poker.rb | UTF-8 | 2,924 | 3.34375 | 3 | [] | no_license | class Poker
# TODO パラメータを柔軟に
def initialize(hand)
@hands = hand.gsub(/A/, "Z").gsub(/T/, "B").gsub(/K/, "Y").split(/ /)
end
def rank
nums = @hands.map {|v| v[0] }
base = nums.sort.reverse
if royal?
"J#{base.join}"
elsif straight_flush?
"I#{base.join}"
elsif four?
hit =... | true |
e4b04f8c8f1173be28d8e16e6bdce842e6026eae | Ruby | mdo5004/oo-student-scraper-v-000 | /lib/scraper.rb | UTF-8 | 1,478 | 2.984375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'open-uri'
require 'nokogiri'
require 'pry'
class Scraper
def self.scrape_index_page(index_url)
doc = Nokogiri::HTML(open(index_url))
page_url = index_url.chomp("index.html")
pages = doc.css("div.student-card")
parsed_hashes = []
pages.each { |page|
nam... | true |
b0cac53e5e510f1b62b9fe12a2b946aeba8cb0cf | Ruby | ParthaviDobariya/Ruby | /Basics/polymorphism.rb | UTF-8 | 367 | 3.390625 | 3 | [] | no_license | class Language
def print
puts "This is Language Class"
end
end
class C < Language
def print
puts "This is C Language Class"
end
end
class Ruby < Language
def print
puts "This is Ruby Language Class"
end
end
C.new.print
Ruby.new.print
puts "\n....C class ancestors...."
puts C.ancestors
puts "\n..... | true |
fcc7f6d8812d1141745fd695bddaf271e5448dcd | Ruby | davidcelis/geocodio | /lib/geocodio/school_district.rb | UTF-8 | 353 | 2.609375 | 3 | [
"MIT"
] | permissive | module Geocodio
class SchoolDistrict
attr_reader :name
attr_reader :lea_code
attr_reader :grade_low
attr_reader :grade_high
def initialize(payload = {})
@name = payload['name']
@lea_code = payload['lea_code']
@grade_low = payload['grade_low']
@grade_high = payload... | true |
80c11c84873a4adf8c8fd7a0102e16489f91d2d6 | Ruby | SultanBS/hw-w10d02-ruby101 | /app.rb | UTF-8 | 832 | 3.3125 | 3 | [] | no_license | i = 1
while i <= 100
if i % 3 ===0
puts "Fizz"
elsif i % 5 === 0
puts "Buzz"
elsif i % 3 ===0 && i % 5 ===0
puts "FizzBuzz"
else
puts i
end
i += 1
end
# planeteers = ["Earth", "Wind", "Captain Planet", "Fire", "Water"]
# puts pla... | true |
b06a22e9c8d24572fb09317bf456be1e3fbc5690 | Ruby | lukaszgryglicki/my_flatten | /array_spec.rb | UTF-8 | 865 | 2.796875 | 3 | [] | no_license | require_relative 'my_flatten'
RSpec.describe Array do
context '.my_flatten' do
# Here we are testing various cases
# We expect that `my_flatten` will transform input into expected output
let(:examples) do
[
{ input: [1, [2], 3, [], [[], [4, [5]]]], output: [1, 2, 3, 4, 5] },
{ input... | true |
6f201b59980c47d6819d77a022d491df42d4f19a | Ruby | PaddyDwyer/ProjectEuler | /ruby/p27/p27.rb | UTF-8 | 1,063 | 3.25 | 3 | [] | no_license | #!/usr/bin/env ruby -wKU -I ../lib
require "util.rb"
#ablist = generatePrimes(1000)
alist = (0..500).map { |n| (n * 2) + 1 }
blist = generatePrimes(1000)
$deflist = generatePrimes(1000000)
def getQuadraticLambda(a,b)
return lambda { |n| n ** 2 + (a * n) + b }
end
def testLambda(a, b)
quad = getQuadraticLambda(a, b... | true |
b540268f597589a7cf09cd966b2a3774125cce1d | Ruby | Rebeliosman/RubyProjectRep | /mail_app/mail_app.rb | UTF-8 | 947 | 2.75 | 3 | [] | no_license | require "pony"
require 'io/console'
my_mail = 'rebeliosman@gmail.com'
puts "Enter password #{my_mail} for sending e-mail:"
password = noecho(&:gets).chomp
puts "Reciever e-mail:"
send_to = STDIN.gets.chomp
puts "Enter subject"
sub = STDIN.gets.chomp
puts "Message test:"
body = STDIN.gets.chomp
success = false
be... | true |
08dab67c8bda76deb58d80e76088266d1233e46c | Ruby | dannyevega/discover | /app/models/user.rb | UTF-8 | 531 | 2.609375 | 3 | [] | no_license | require 'bcrypt'
class User < ActiveRecord::Base
validates_presence_of :name, :email, :password, presence: {
message: "%{value} cannot be left blank." }
validates_format_of :email, :with=> /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i, :on => :create, message: "Email address invalid. Please enter a valid Email address... | true |
93c61a56a73333a626273269f54da7c5d5d615d6 | Ruby | kkburr/homework_assignments | /Warmups/01/warmup_01.rb | UTF-8 | 293 | 3.546875 | 4 | [] | no_license | #!/usr/bin/env ruby
letters = ('a'..'z').to_a
letters = letters.rotate(-7)
print letters[13]
print letters[21]
print letters[21]
print letters[10]
print letters[16]
print letters[21]
print letters[8]
print letters[9]
print letters[21]
print letters[10]
print letters[11]
print letters[24]
| true |
d866694341473f097bdd4571fb4cd17e961dae6c | Ruby | Aissac/radiant-extensions-extension | /lib/tag_binding_extensions.rb | UTF-8 | 743 | 2.5625 | 3 | [] | no_license | module TagBindingExtensions
def self.included(base)
base.send(:include, InstanceMethods)
# base.send(:alias_method, :orig_attr, :attr)
# base.send(:alias_method, :attr, :parsed_attributes)
base.send(:alias_method_chain, :attr, :parsed_attributes)
end
module InstanceMethods
def attr_with_par... | true |
f543628158818d3b24652e118f9806e37190a517 | Ruby | hopkinschris/nightowl | /app/services/bot.rb | UTF-8 | 2,091 | 2.8125 | 3 | [
"MIT"
] | permissive | class Bot
MAX_ATTEMPTS = 3
def initialize(user)
if @user = user
establish_client
end
end
def scour_twitter
num_attempts = 0
begin
num_attempts += 1
@user.keywords.each do |k|
@client.search(k.name, result_type: k.result_type, count: 10).take(k.rate).each do |tweet|
... | true |
c36d3396a611a2d7494c9bbc63ff806fbadcfeca | Ruby | LFDM/gem_polish | /lib/gem_polish/cli.rb | UTF-8 | 3,127 | 2.59375 | 3 | [
"MIT"
] | permissive | require 'thor'
require 'yaml'
module GemPolish
class CLI < Thor
require 'gem_polish/cli/aliases'
require 'gem_polish/gem'
require 'gem_polish/cli/polisher'
require 'gem_polish/cli/versioner'
include Thor::Actions
register(Gem, 'gem', 'gem <action>', 'Manipulates your Gemfile. Call "gem_poli... | true |
f26783174566dc198d680bd417f1241ba5ddcf46 | Ruby | AAMani5/learn-to-program | /chap13/ex4.rb | UTF-8 | 2,588 | 4.46875 | 4 | [] | no_license | #!/usr/bin/env ruby
#Baby dragon - we can feed it, put it to bed, talk it on walks. We can name it(parameter)
#internally Dragon will keep track of if its hungry, needs to go.
class Dragon
def initialize name
@name = name
@asleep = false
@stuffInBelly = 10 #its full
@stuffInIntestine = 0 #it doesn't need to go... | true |
c5c4994e2b48e74ea54ad26d97ccc8911eb7e4d4 | Ruby | kkeppel/shelter_importer | /app/models/organization.rb | UTF-8 | 2,014 | 2.53125 | 3 | [] | no_license | require 'nokogiri'
require 'open-uri'
require 'digest'
class Organization
include Mongoid::Document
field :name, type: String
field :shelter_id, type: String
field :created_at, type: Date
field :address1, type: String
field :address2, type: String
field :city, type: String
field :state, type: String
... | true |
45024b2e3243e4b6a4f75a228fd9ffc4630c8a39 | Ruby | kavinderd/secret_santa | /bin/secret_santa | UTF-8 | 624 | 3.078125 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'highline/import'
require_relative "../lib/secret_santa"
ENTER_NAME = 1
SELECT_SANTAS = 2
begin
ss = SecretSanta.new
loop do
response = ask("1. Enter Name\n2. Select Santas\n3. Quit", Integer) {|r| r.in = [1,2, 3]}
if response == ENTER_NAME
response = ask('Enter First, ... | true |
06dff95932febf324b3e118fe57de24601333fa8 | Ruby | rpl/tiny-slidedown | /tiny-slidedown.rb | UTF-8 | 6,074 | 2.84375 | 3 | [] | no_license | #!/bin/env ruby
# tiny-slidedown: All-in-one SlideDown Fork
#
# original slidedown:
# http://github.com/nakajima/slidedown
# tiny-slidedown fork:
# http://github.com/rpl/tiny-slidedown
require 'rubygems'
require 'open4'
require 'bluecloth'
require 'nokogiri'
require 'optparse'
require 'nokogiri'
require 'erb'
cl... | true |
2310b0035166cddbe8d509ad7fcf9c67bc8dfdd7 | Ruby | jeanettepayne/school-domain-online-web-sp-000 | /lib/school.rb | UTF-8 | 471 | 3.640625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class School
attr_accessor :school_name, :roster
def initialize(school_name)
@school_name = school_name
@roster = {}
end
def add_student(name, grade)
if roster.has_key?(grade)
roster[grade] << name
else
roster[grade] = []
roster[grade] << name
end
end
def grade... | true |
aa76d624bf852d6b6bf5489485727ab775ab6976 | Ruby | haydenlangelier/phase-0-tracks | /ruby/alias_manager.rb | UTF-8 | 501 | 3.59375 | 4 | [] | no_license | answer =""
box={}
until answer === "no"
puts "what is your first name?"
first=gets.chomp
puts "what is your last name?"
last=gets.chomp
originalname = first+" "+last
newfirst= first.downcase.tr('aeioubcdfghjklmnpqrstvwxyz','eiouacdfghjklmnpqrstvwxyzb')
newlast= last.downcase.tr('aeioubcdfghjklmnpqrstvwxyz','ei... | true |
f2150688248fe9bf361db14466716183a46dbdc0 | Ruby | MarcosFortuna/ruby | /Ruby/operadores/Inputs.rb | UTF-8 | 55 | 3.390625 | 3 | [] | no_license | puts "digite algo:"
nome = gets.chomp
puts "#{nome}" | true |
bbbbd753169ce841d1c1de5bb4038edafa35aab3 | Ruby | nupurkapoor/learning-ROR | /ruby-warrior-challenges/beginner-track/level-2.rb | UTF-8 | 688 | 3.9375 | 4 | [] | no_license | ##
# Level 2 challenge
#
# It is too dark to see anything, but you smell sludge nearby.
# Use warrior.feel.empty? to see if there is anything in front of you, and warrior.attack! to fight it.
# Remember, you can only do one action (ending in !) per turn.
#
# Simple if you take the hidden hint, it specifies that "you... | true |
6d2a6d592037f09c77f8115108826fb99c040a86 | Ruby | puyanwei/Tic-Tac-Toe | /spec/game_spec.rb | UTF-8 | 1,004 | 2.8125 | 3 | [] | no_license | RSpec.describe Game do
subject(:game) { described_class.new(board) }
let(:board) { double :board }
let(:win?) { double :win? }
let(:tie?) { double :tie? }
describe "#win?" do
it "sets win to true if there is a win" do
allow(game).to receive(:win?) { true }
expect(game.win?).to be(true)
en... | true |
b065a5c649aae5d3eb3fde8ebb9b76eff6dd4ebb | Ruby | yelber-ride-and-eat-app/api | /test/models/uber_test.rb | UTF-8 | 663 | 2.859375 | 3 | [] | no_license | require 'test_helper'
class UberTest < ActiveSupport::TestCase
test "retreive UberX price range" do
u = Uber.new
assert_equal "$6-8", u.xprice
end
test "retreive UberXL price range" do
u = Uber.new
assert_equal "$9-12", u.xlprice
end
test "retreive UberSELECT price range" do
u = Uber.... | true |
a599b3fa950ed9aad2e5fb636bbe52065ac4918b | Ruby | radarscreen/sinatra | /calc.rb | UTF-8 | 694 | 2.765625 | 3 | [] | no_license | require 'sinatra'
require 'sinatra/reloader'
require 'better_errors'
configure :development do
use BetterErrors::Middleware
BetterErrors.application_root = __dir__
end
get "/add/:num1/:num2" do
sum = params[:num1].to_i + params[:num2].to_i
"The sum is #{sum}"
end
get "/subtr/:num1/:num2" do
leftover = par... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.