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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
e491293ff9e3cbecaaf90eedd3d43b5005acc335 | Ruby | ccMehdi/august-2015-ruby | /classwork/day_1/number_to_100.rb | UTF-8 | 266 | 4.03125 | 4 | [] | no_license | puts "Let's count to a 100, enter a number less than 100"
number = gets.to_i
# This will keep prompting the user to enter a number that
# is less than a 100
while number >= 100
puts "too big, try again"
number = gets.to_i
end
for x in number..100
puts x
end
| true |
f641043a2a843cabd1d8141e7eae5d2f6389710f | Ruby | zarifrahat/W4D2-Chess | /Chess/Pieces/piece.rb | UTF-8 | 192 | 3.328125 | 3 | [] | no_license |
class Piece
def initialize
@name
@color
@board
@pos = []
end
def moves
#returns an array of possible places a piece can move
end
end | true |
dff8ceebbef00e485ae416a4c3e19ac806c14872 | Ruby | ruthmesfun/aaqfeedback-cli-app | /lib/aaq_feedback/cli.rb | UTF-8 | 2,451 | 3.40625 | 3 | [] | no_license | class AaqFeedback::CLI
#responsible for getting data from the user and displaying data
def call
puts "Welcome to the AAQ Feedback Report Gem."
puts ""
menu
end
def menu
puts "Please select a number to select your choice"
puts "1. Overall data"
puts "2. Technical Coach"
input = gets.... | true |
ccade9d4f103f964f43bdc7442371e5a31c94fd2 | Ruby | dc3671/lkp-tests | /lib/property.rb | UTF-8 | 1,449 | 2.75 | 3 | [] | no_license | LKP_SRC ||= ENV['LKP_SRC']
require "#{LKP_SRC}/lib/common.rb"
class Module
alias prop_reader attr_reader
def prop_accessor(*props)
attr_reader *props
props.each { |prop|
class_eval %Q{
def #{prop}_set?
instance_variable_defined? :"@#{prop}"
end
def set_#{prop}(value)
@#{prop} = value
self
end
def unset... | true |
2a7915751a2c0d203dbd904c07351bbace79cf9a | Ruby | derwiki/muni | /server.rb | UTF-8 | 490 | 2.515625 | 3 | [] | no_license | require 'sinatra'
require 'muni'
require 'haml'
RS = {
r48: Muni::Route.find(48),
r10: Muni::Route.find(10),
}
STOPS = [
RS[:r10].inbound.stop_at('Wisconsin St & Madera St'),
RS[:r48].inbound.stop_at('25th St & Wisconsin St'),
]
get '/' do
begin
routes = {}
STOPS.map {|stop| routes[stop.route_tag] ... | true |
565b9955a4d7d925bcaa0083730f44bda98a1bb6 | Ruby | abchinguk/fio | /fio.rb | UTF-8 | 151 | 2.765625 | 3 | [] | no_license | puts "Как зовут?"
name = gets.chomp
otchestvo = gets.chomp
fameli = gets.chomp
puts "Ну здорово " + name + otchestvo + fameli +" | true |
1d064375006df2337da3f726ebb941ea50844530 | Ruby | hipe/hipe-assess | /lib/assess/util/uber-alles-array.rb | UTF-8 | 1,584 | 2.96875 | 3 | [] | no_license | module Hipe
module Assess
#
# Two sorta unrelated array-like things ended up in here
#
#
# classes can register all of their instances easily
#
module UberAllesArray
def self.extended klass
klass.instance_variable_set('@all', [] ) unless
klass.instance_variable_de... | true |
acce8d1764bdb1ee90d05b28756597a8fbf14b40 | Ruby | rsheehan/iFizzToyCreator | /app/models/toy_physics_body.rb | UTF-8 | 5,337 | 3.5625 | 4 | [] | no_license | # To create the physics body from a toy I am going to generate the convex hulls of each part,
# except for circles which are separate.
# If the convex hull of one part is completely inside the convex hull of another part it is
# ignored. NOT YET.
# Any line segments "close" to each other should be regarded as connected... | true |
2ad446bca3eb67485caba02ac8deaf247338b569 | Ruby | piktur/solargraph | /lib/solargraph/library.rb | UTF-8 | 10,532 | 2.515625 | 3 | [
"MIT"
] | permissive | module Solargraph
# A library handles coordination between a Workspace and an ApiMap.
#
class Library
# @param workspace [Solargraph::Workspace]
def initialize workspace = Solargraph::Workspace.new(nil)
@workspace = workspace
api_map
end
# Open a file in the library. Opening a file wi... | true |
122540f1bb28f5139b84e51039607dff8c5d0a69 | Ruby | johnjvaughn/myflix | /spec/features/user_interacts_with_queue_spec.rb | UTF-8 | 1,391 | 2.5625 | 3 | [] | no_license | require "spec_helper"
feature "User interacts with queue" do
scenario "user adds and reorders videos in the queue" do
comedies = Fabricate(:category)
monk = Fabricate(:video, title: "Monk", category: comedies)
sp = Fabricate(:video, title: "South Park", category: comedies)
fut = Fabricate(:video, tit... | true |
9df0b3364d9fc8d3239ec5fd47993ae42b18f0f2 | Ruby | sourabh3110/work | /practice/hash.rb | UTF-8 | 333 | 3.65625 | 4 | [] | no_license | class Hash
def store_values(k,v)
x = {}
for i in 0...k.size
x.store(k[i],v[i])
puts x
end
end
def insert_values(k,v)
x = {}
for i in 0...k.size
x[k[i]] = v[i]
puts x
end
end
end
Hash.new.insert_values([1,... | true |
7d8afd152e09c43a68489b544f97b28b2cef8786 | Ruby | no-relation/OO-Art-Gallery-houston-web-100818 | /app/models/gallery.rb | UTF-8 | 879 | 3.34375 | 3 | [] | no_license | class Gallery
attr_reader :name, :city
@@all = []
def initialize(name, city)
@name = name
@city = city
@@all << self
end
def self.all
@@all
end
def self.cities
Gallery.all.map do | gallery |
gallery.city
end.uniq
end
# ...then the gallery can display it
def hang_painting(display_painting)
fo... | true |
2305d6547dc6e3445a71254ccd385e3628cb016d | Ruby | Qoosim/Solve-challenges-tutorials | /array.rb | UTF-8 | 878 | 4.5625 | 5 | [] | no_license | ## Transforming Arrays
# The use of map method: It's used to transform arrays
p [1, 2, 3, 4, 5].map { |i| i * 3 } # collect & map methods used interchangeably
## Filtering Arrays
# select method is used to filter array elements based on specified condition
# select even numbers
p [1, 2, 3, 4, 5, 6].select { |number|... | true |
07449b14ff7839f865c7746cfbe0f3f1e896a15c | Ruby | eugeniobruno/logica | /test/predicates/examples/is_greater_than.rb | UTF-8 | 576 | 3.03125 | 3 | [
"MIT"
] | permissive | class IsGreaterThan < Logica::Predicates::Base
attr_reader :threshold
def initialize(threshold)
@threshold = threshold
end
def satisfied_by?(number)
number > threshold
end
def specialization_of?(other)
other.generalization_of_is_greater_than?(self)
end
def generalization_of_is_greater_th... | true |
a55c63379227eb92f8accf81de650629b9325479 | Ruby | chaosdorf/paweb | /lib/pulseaudio.rb | UTF-8 | 2,952 | 2.515625 | 3 | [
"MIT"
] | permissive | require 'dbus'
class PulseAudio
def initialize(dbus_address)
bus = DBus::Connection.new(dbus_address)
bus.connect
@pulseaudio_service = bus.service('org.PulseAudio.Core1')
@pulseaudio_service.introspect
pulseaudio_core_object = @pulseaudio_service.object('/org/pulseaudio/core1')
@pulseaudi... | true |
af73dc6c4b788c04a595645532f32d9bf887d770 | Ruby | hpetersen1217/Hollys-rails-app | /db/seeds.rb | UTF-8 | 1,821 | 2.890625 | 3 | [] | no_license | require 'faker'
topics = []
15.times do
topics << Topic.create(
name: Faker::Lorem.words(rand(1..10)).join(" "),
description: Faker::Lorem.paragraph(rand(1..4))
)
end
# 4 to 10 users
rand(4..10).times do
password = Faker::Lorem.characters(10)
u = User.new(
name: Faker::Name... | true |
ea3164c8c5fc1e48481c5af6b814c4bba92b376c | Ruby | alicenara/atm | /atm.rb | UTF-8 | 2,660 | 3.921875 | 4 | [] | no_license | class Atm # A class name always starts with capital letter
STARTING_BALANCE = 100.0
def initialize(filename = 'balance.txt')
# Read from a file
@filename = filename
begin
@actual_balance = IO.readlines(filename)
rescue
@actual_balance = STARTING_BALANCE
end
# @instance variable... | true |
04734d46436284bbaf517fbc232ee6c3a9a1db72 | Ruby | roomorama/concierge | /lib/concierge/suppliers/ciirus/mappers/property_permissions.rb | UTF-8 | 2,340 | 2.59375 | 3 | [] | no_license | module Ciirus
module Mappers
class PropertyPermissions
# Maps hash representation of Ciirus API GetPropertyPermissions response
# to +Ciirus::Entities::PropertyPermissions+
def build(hash)
permissions_hash = hash.get('get_property_permissions_response.get_property_permissions_result')
... | true |
7c23b23f206701a3468890166237d228e52221a1 | Ruby | priviere42/ruby | /exos_1_à_10/exo_10.rb | UTF-8 | 109 | 3.53125 | 4 | [] | no_license | puts "Quelle est ton année de naissance ?"
yearofbirth = gets.chomp.to_i
age = 2017 - yearofbirth
puts age
| true |
107695916d13358e2abee70dd716ec96e4f54563 | Ruby | eyeman/test-first-ruby | /Ruby/test-first-ruby-master/lib/01_temperature.rb | UTF-8 | 107 | 3.0625 | 3 | [] | no_license | def ftoc(tempf)
return (tempf-32.0)*(5.0/9.0)
end
def ctof(tempc)
return tempc * (9.0/5.0) + 32.0
end
| true |
a93ba40f586e77562ce07c842a362c0e02bd5d18 | Ruby | s-espinosa/trains_planes_and_automobiles | /taxi/lib/taxi.rb | UTF-8 | 168 | 2.953125 | 3 | [] | no_license | class Taxi
attr_reader :medallion_number,
:trips
def initialize(medallion_number)
@medallion_number = medallion_number
@trips = []
end
end
| true |
9e864f43547ffebc255ad8147b78d053c012ab31 | Ruby | LumiDoll50/my-first-repository | /learn_to_program/calc.rb | UTF-8 | 1,188 | 4.34375 | 4 | [] | no_license | # bottles = 5
# while bottles > 1
# puts "#{bottles} bottles of beer on the wall, #{bottles} bottles of beer, take one down, pass it around, #{bottles -= 1} bottles of beer on the wall."
# end
# Deaf Grandma program
# bye = 0
# while bye < 3
# my_words = gets.chomp
# if my_words == "BYE"
# bye += 1
# puts... | true |
8bccc65236b0b115d9866f5a82164406f701906f | Ruby | recrudescence/PA2 | /movie_test.rb | UTF-8 | 1,675 | 3.390625 | 3 | [] | no_license | class MovieTest
attr_accessor :list_of_results
# A tuple structure that stores user, movie, rating, and prediction information.
Test = Struct.new(:user, :movie, :rating, :prediction)
def initialize
@list_of_results = Array.new
@mean_error = -1
end
##
# Insert a tuple into MovieTest with user, movie, rat... | true |
bd4d709452a31eeec441aebed674bf1c8cd20bd2 | Ruby | crichey/ActiveDocument | /src/lib/ActiveDocument/search_result.rb | UTF-8 | 2,115 | 2.53125 | 3 | [] | no_license | # Copyright 2010 Mark Logic, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agree... | true |
972af03a55311a97e354e1988dd3612bfa70d6da | Ruby | ToTenMilan/Well-Grounded-Rubyist | /ruby/part2/music.rb | UTF-8 | 248 | 2.875 | 3 | [] | no_license | module Muslalala
class Scale
NOTES = ["c", "c#", "d", "d#", "e", "f", "f#", "g", "a", "a#", "b"]
def play
NOTES.each {|note| yield note}
end
end
end
scale = Music::Scale.new
scale.play {|note| puts "nastepna nuta to #{note}"} | true |
0ef3f1f772ba911ff1d5874d466f787b8e10dcaa | Ruby | Officialbella/mycodes | /main.rb | UTF-8 | 2,622 | 4.34375 | 4 | [] | no_license | # variable and interger
a=3
b=5
print a+b+10
# inheritance
f=5
d=f
puts d
weight=150
# if statement
puts "you need to eat some cheeseburger" if weight==150
health=300
puts "you are healthy" if health>100 && health <=300
healthy=54
print "you are not well" if healthy<100 || healthy>500
# loops
8.times do puts "bacon... | true |
91d2bc095e8731c73c831f21b58f1280026dc7e0 | Ruby | amandeep1420/RB101 | /RB101/Small Problems/E5/5_clean.rb | UTF-8 | 585 | 3.53125 | 4 | [] | no_license | ALPHABET = ('a'..'z').to_a
def letter?(char)
ALPHABET.include?(char)
end
def cleanup(string)
string.split('').map do |char|
letter?(char) ? char : " "
end.join.squeeze(" ")
end
puts cleanup("---what's my +*& line?") == ' what s my line '
# eventually found the #squeeze method, thank goodness
# couldn't fi... | true |
1768eb62224ceca1aa383b7115b9349b1b92e510 | Ruby | ddeleon267/programming-univbasics-4-array-concept-review-lab-online-web-prework | /lib/array_methods.rb | UTF-8 | 494 | 3.453125 | 3 | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | def find_element_index(array, value_to_find)
# array.find_index(value_to_find)
i = 0
while i < array.length
return i if array[i] == value_to_find
i += 1
end
end
def find_max_value(array)
#array.max
max = 0
i = 0
while i < array.length
max = array[i] if array[i] > max
i += 1
end
... | true |
a64a57eab031fb8adb37f335110b40c6461d8d4f | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/cs169/1130/source/9522.rb | UTF-8 | 442 | 3.5 | 4 | [] | no_license | def combine_anagrams(words)
anagram_hash = {}
words.each do |word|
transformed_word = word.downcase.chars.sort.join
anagram_hash.has_key?(transformed_word) ? anagram_hash[transformed_word] << word : anagram_hash[transformed_word] = [word]
end
anagram_hash.inject([]) {|memo, val| memo << val[1] }
end
an... | true |
694872b0422832854ba5c02a3f4b9f8120f77d92 | Ruby | MaharsheeRoy/ruby-intro-to-arrays-lab-prework | /lib/intro_to_arrays.rb | UTF-8 | 554 | 3.546875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def instantiate_new_array
array = []
return array
end
def array_with_two_elements
array = [1,2]
return array
end
def first_element(array)
array = ["Welcome to New York",2,3,4]
return array[0]
end
def third_element(array)
array = [1,2,"Style",4]
return array[2]
end
def last_element(array)
array = [1,2... | true |
5bd270858757c0b3625d198c57139876c4ca17a5 | Ruby | niyoko/keisan | /lib/keisan/ast/logical_greater_than_or_equal_to.rb | UTF-8 | 375 | 2.859375 | 3 | [
"MIT"
] | permissive | module Keisan
module AST
class LogicalGreaterThanOrEqualTo < LogicalOperator
def self.symbol
:">="
end
def evaluate(context = nil)
children[0].evaluate(context) >= children[1].evaluate(context)
end
def value(context = nil)
children.first.value(context) >= ch... | true |
30c59bf6dc8fd5e330112b66f0567cea37ef8196 | Ruby | innovia/mor | /spec/models/address_spec.rb | UTF-8 | 1,143 | 2.5625 | 3 | [] | no_license | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
module AddressSpecHelper
def valid_address_attributes
{
:person_id => 1,
:street => "abc123",
:zip_code_id => "11209"
}
end
end
describe Address do
include AddressSpecHelper
fixtures :zip_codes, :people
before(:e... | true |
9b57f44f64d967fb957c3171f305f80be36328c8 | Ruby | makandra/geordi | /lib/geordi/commands/shell.rb | UTF-8 | 774 | 2.6875 | 3 | [
"MIT"
] | permissive | desc 'shell TARGET', 'Open a shell on a Capistrano deploy target'
long_desc <<-LONGDESC
Example: `geordi shell production`
Selecting the server: `geordi shell staging -s` shows a menu with all available
servers. When passed a number, directly connects to the selected server.
LONGDESC
# This option is duplicated in co... | true |
6022a369a6a337cab815edbaee783d4b451f0c79 | Ruby | tamu222i/ruby01 | /tech-book/6/6-1.rb | UTF-8 | 122 | 2.578125 | 3 | [] | no_license | # 添付ライブラリの使用にはrequireによる呼び出しが必要
require "stringio"
io = StringIO.new("hoge")
| true |
94a987c3b52e66fc17dbd18bf3159dd5115b763d | Ruby | JeJones21/backend_mod_1_prework | /section2/else.rb | UTF-8 | 1,470 | 3.953125 | 4 | [] | no_license | people = 20
cars = 10
trucks = 40
# if 1st statement is true, it prints the next line
if cars > people
puts "We should take the cars."
# if the above is false and elsif is true it runs
elsif cars < people
puts "We should not take the cars."
# if the first 2 lines are false else runs
else
puts "We can't decide."... | true |
051b4f2408e583cc41f53ecc9865a520ab6d69aa | Ruby | lsegal/jamespath | /lib/jamespath/parser.rb | UTF-8 | 3,208 | 2.984375 | 3 | [
"MIT"
] | permissive | require_relative 'tokenizer'
module Jamespath
# # Grammar
#
# ```abnf
# expression : sub_expression | index_expression
# | or_expression | identifier | '*'
# | multi_select_list | multi_select_hash;
# sub_expression : expression '.' expression;
# or_express... | true |
13466dfc6baca269366a93bcd59cc7a279d3f997 | Ruby | ffaker/ffaker | /lib/ffaker/nato_alphabet.rb | UTF-8 | 679 | 2.75 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # frozen_string_literal: true
module FFaker
module NatoAlphabet
extend ModuleUtils
extend self
STOP_CODE = 'STOP'
CODES = ALPHABET_CODES + NUMERIC_CODES + [STOP_CODE]
def code
fetch_sample(CODES)
end
def alphabetic_code
fetch_sample(ALPHABET_CODES)
end
def numeric_... | true |
d6309d1e79e538f5c932f17e253e1c27635dce0d | Ruby | yashka713/on_money_back | /app/services/category_destroyer_service.rb | UTF-8 | 606 | 2.53125 | 3 | [] | no_license | # TODO: finishing category destroyer
#
class CategoryDestroyerService
attr_accessor :category
def initialize(category, params)
@category = category
@params = params
end
def destroy
case @params[:type]
when 'full'
full_destroy
when 'hide'
hide_category
when 'change'
# ... | true |
88ed323b70a057e42341900ea16adaede185d75e | Ruby | JonahMoses/web_guesser | /lib/web_guesser/server.rb | UTF-8 | 1,627 | 2.953125 | 3 | [
"MIT"
] | permissive | require 'sinatra'
require 'sinatra/reloader'
set :secret, rand(100)
set :guesses, 5
get '/' do
decrement_guesses
guess = params[:guess].to_i
message = feedback_for(settings.secret, guess)
output_style = style_for(settings.secret, guess)
if correct_guess(settings.secret, guess) || settings.guesses == 0
... | true |
6acb72395eb485f3f96703f9b4b125cab59885d1 | Ruby | HaiTo/plot_api | /app/server.rb | UTF-8 | 685 | 2.578125 | 3 | [] | no_license | class Server < Sinatra::Base
# @PARAM json {
# "title": "String",
# "datas" = [
# {"category": "string", "points": [float...]}
# ],
# "labels" = {
# {"Integer": "string"...}
# },
# "size" = "string" # "0000x0000" # NOT RQEUIRED
# @RETURN json {img: blob}
post '... | true |
bcff4b9f0426d5bfadd9aa10730c4adf4c50c80b | Ruby | gerflomo/SmartTools3 | /app/helpers/aws_sqs_helper.rb | UTF-8 | 1,854 | 2.578125 | 3 | [] | no_license | require 'aws-sdk'
module AwsSqsHelper
# envia mensajes a una cola de aws
def send_msg_to_queue(message)
Rails.logger.info(" #{Time.now} Ide video: " + message)
Rails.logger.info(" #{Time.now} url sqs: " + ENV['AWS_SQS_ORIGINAL_VIDEOS'])
sqs = Aws::SQS::Client.new(region: ENV['AWS_REGION'])
resp = sqs.sen... | true |
fabff3097ce11b1840dd1eba8304be31b529bf5b | Ruby | xfbs/euler | /src/018-maximum-path-sum-i/ruby/test/solver_test.rb | UTF-8 | 509 | 2.703125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require 'minitest/autorun'
require_relative '../src/solver'
class SolverTest < MiniTest::Test
def test_solution
assert_equal 22, Solver.solve([[11], [11, 10]])
assert_equal 23, Solver.solve([[10], [12, 13]])
assert_equal 65, Solver.solve([[10], [50, 9], [5, 4, 10]])
end
def test_reduce
assert_eq... | true |
d76c6558e8cd23db76ba793960a69c2d3ba37c02 | Ruby | DataKinds/the-citation-needed-bible | /CleanDB.rb | UTF-8 | 749 | 3.3125 | 3 | [] | no_license | #!/usr/bin/env ruby
require_relative "BibleTwitter.rb"
require "pp"
if __FILE__ == $0
puts "Opening database..."
db = JSON.parse(File.read("db.json"))
puts "Sorting..."
db = sort_child_hash_by_key(db)
db = db.map do |bookName, book|
{bookName => sort_child_hash_by_key(book)}
end.reduce... | true |
f445ca3cc896886aaff472124542ce4b02d722d1 | Ruby | caioamaralgit/stuffs | /universidad-veracruzana/programacion-red/practica-9/read_with_length.rb | UTF-8 | 220 | 2.71875 | 3 | [] | no_license | require "socket"
one_kb = 1024 #bytes
Socket.tcp_server_loop(4481) do |connection|
# Leer datos en bloques de 1 one_kb
while data = connection.read(one_kb) do
puts data
end
connection.close
end | true |
b76a7c26e18e1ac45eb10a24d53f8bada7b36b8f | Ruby | krutman1/rail_studio | /prices.rb | UTF-8 | 526 | 3.640625 | 4 | [] | no_license | def total(prices)
amount = 0
index = 0
while index < prices.length
amount += prices [index]
index += 1
end
amount
end
prices = [3.99,25.00,8.99]
puts format("%.2f", total(prices))
def refund(prices)
amount = 0
index = 0
while index < prices.length
amount -= prices [index]
index += 1
end
amount
end
puts format(... | true |
295213e7e2c90d6c14fb3b53928630b30f2ae182 | Ruby | vai0/coderbytes | /ThirdGreatest.rb | UTF-8 | 440 | 3.3125 | 3 | [] | no_license | def ThirdGreatest(strArr)
lengths = []
strArr.each do |str|
lengths << str.length
end
values = lengths.sort
answer_length = values[-3]
answer = ""
strArr.each do |str|
answer = str if str.length == answer_length
end
answer
end
def ThirdGreatestII(strArr)
third_largest_length = strArr.sort_by(&:length)[-... | true |
3e24bfa452683bb619e9e0080da136c393c5fefd | Ruby | T-monius/ruby_small_problems | /easy_8/madlibs.rb | UTF-8 | 2,245 | 4.53125 | 5 | [] | no_license | # madlibs.rb
# Mad libs are a simple game where you create a story template with blanks
# for words. You, or another player, then construct a list of words and
# place them into the story, creating an often silly or funny story as a
# result.
# Create a simple mad-lib program that prompts for a noun, a verb, an
# adv... | true |
5c61ba20dc2cdc7cb01cfddd6fe6fd4a99581398 | Ruby | nkhem/coding_challenges | /rb/codewars-rb/lib/codewars.rb | UTF-8 | 381 | 4.125 | 4 | [] | no_license | # ----------
# ~ 7 kyu ~
# ----------
# Given a number as a parameter, return an array containing strings
# which form a box.
# Ex:
# box(5) => [
# '-----',
# '- -',
# '- -',
# '- -',
# '-----'
# ]
def box(n)
arr = []
n.times do |i|
midline = ((i == 0 || i == (n - 1)) ? '-' : ' '... | true |
0a9679c52dd849dda76e41a26e7b8527503ca212 | Ruby | hori-eiji/sawaranu_romance | /test/resources/roman_numeral_test.rb | UTF-8 | 676 | 2.765625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require File.dirname(__FILE__) + '/../test_helper'
require_relative '../../app/resources/roman_numeral'
class RomanNumeralTest < ActiveSupport::TestCase
test '#to_s, ⅩⅠⅠ' do
roman_numeral = RomanNumeral.new(numeral: 12)
assert_equal 'ⅩⅠⅠ', roman_numeral.to_s
end
test '式展開,... | true |
ceed4a6821cee62462ee9afde5bd356ca31b9662 | Ruby | beaucouplus/launchschool_ruby_more_topics | /challenges/beer_song.rb | UTF-8 | 953 | 3.90625 | 4 | [] | no_license | require 'pry'
class BeerSong
def lyrics
verses(99, 0)
end
def verses(highest, lowest)
(lowest..highest).to_a.reverse.map { |verse_num| verse(verse_num) }.join("\n")
# binding.pry
end
def verse(number)
case number
when (3..99)
"#{number} bottles of beer on the wall, #{number} bottl... | true |
999b9a79f971b9d59a079b966a127b15e23f9e3b | Ruby | frod25/reading-errors-and-debugging-using-pry-nyc04-seng-ft-041920 | /lib/pry_debugging.rb | UTF-8 | 52 | 2.734375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
def plus_two(num)
sum = num + 2
end
| true |
20f820792c39155f23c1115d33c1e2498fa5366e | Ruby | Eden-Eltume/120 | /120_Exercises3/5_Easy 1/09_complete_the_program_-_cats!.rb | UTF-8 | 452 | 4.03125 | 4 | [] | no_license | class Pet
attr_reader :name, :age
def initialize(name, age)
@name = name
@age = age
end
end
class Cat < Pet
attr_reader :colors
def initialize(name, age, colors)
super(name, age)
@colors = colors
end
def to_s
"My cat #{name} is #{age} years old and has #{colors}"
end
end
pudding... | true |
3af7fae35f86765ddff0d42a58195e05a7efe542 | Ruby | KevinSia/Sample-App | /test/models/user_test.rb | UTF-8 | 3,235 | 2.84375 | 3 | [] | no_license | require 'test_helper'
class UserTest < ActiveSupport::TestCase
def setup
@user = User.new(name: "Example User" , email: "user@example.com" ,
password: "foobar" , password_confirmation: "foobar")
end
test "should be valid" do
assert @user.valid?
end
#assert_not passes if statement is false
test "nam... | true |
8c9c6788b110f811b744005137acd607de10d2c0 | Ruby | ap-hughes/weblog-statistics | /lib/weblog/terminal_writer.rb | UTF-8 | 793 | 3.0625 | 3 | [] | no_license | # frozen_string_literal: true
module Weblog
# Writes out results to the terminal, presenting them in a table
class TerminalWriter
def initialize(records, table_heading)
@records = records.to_h
@table_heading = table_heading
end
def write
tabulate do
@records.each do |k, v|
... | true |
5e006b6bb389b34e28cbdab7853d51f1bb1ae336 | Ruby | CodingDojoDallas/ruby_dec_16 | /Jerrod/Assignments/oop/puzzles.rb | UTF-8 | 1,466 | 4.03125 | 4 | [] | no_license |
def firstPuzzle(arr)
sum = 0
arr.each{|i| sum += i}
puts sum
return arr.find_all{|i| i > 10}
end
puts firstPuzzle([3, 5, 1, 2, 7, 9, 8, 13, 25, 32])
# Second Puzzle*************************
def second(arr)
arr.shuffle.each{|i| puts i}
puts 'SPACE ************' #so i can tell the difference in the terminal... | true |
3b7c8c6537ecee172eafc9e2feb53dde17f6f36c | Ruby | ivanionut/old-study | /ruby/regular-expressions/classes_test.rb | UTF-8 | 2,286 | 3.25 | 3 | [] | no_license | require 'test/unit'
require_relative 'show'
class ClassesTest < Test::Unit::TestCase
def setup
@show = Show.new
end
def test_1
@show.regex('price 12 dollari', /[aeiou]/) # il primo match
@show.regex('price 12 dollari', /[\s]/) # questi li prende
@show.regex('price 12$ dollaroni', /[$]/) #quelli ... | true |
b5c055ac089f10ecfb3320ebd8d02232b482a208 | Ruby | avila22/prueba | /numeros/falso.rb | UTF-8 | 814 | 3.640625 | 4 | [] | no_license | def hacerHastaQueSeaFalso primeraentrada, unProc
entrada = primeraentrada
salida = primeraentrada
while salida
entrada = salida
salida = unProc.call entrada
end
entrada
end
construirMatrizDeCuadrados = Proc.new do |array|
ultimonumero = array.last
if ultimonumero <= 0
false
else
arr... | true |
692fae3c0573006e879a0480e0ceb49a7e574378 | Ruby | quintel/atlas | /lib/atlas/util.rb | UTF-8 | 3,224 | 2.921875 | 3 | [
"MIT"
] | permissive | module Atlas
module Util
module_function
# Public: Given a hash which itself contains hashes, flattens the
# structure so that the values in each nested hash are moved -- with
# namespace-style dots -- to the top-level hash.
#
# hash - The hash to be flattened.
# ns - The current namesp... | true |
23cac3c219ac362d2cdcb6036f636befd579426a | Ruby | jcobian/resident_matching | /seeds.rb | UTF-8 | 3,212 | 3.359375 | 3 | [
"MIT"
] | permissive | APPLICANT_LIMIT = 25 # roughly how many applicants in the universe
PROGRAM_LIMT = 4 # roughly how many programs in the universe
PROGRAM_RANGE = (2..6).freeze # range of how many spots a program has
# range of applicants a program will interview
# for now, 5 times the lowe and upper limits of number of spots a program ... | true |
5e23b51f90502fa60da017c661bf0f282dc7bf80 | Ruby | bibendi/cells | /lib/cell/rendering.rb | UTF-8 | 3,942 | 2.859375 | 3 | [
"MIT"
] | permissive | module Cell
module Rendering
extend ActiveSupport::Concern
# Invoke the state method for +state+ which usually renders something nice.
def render_state(state, *args)
process(state, *args)
end
# Renders the view for the current state and returns the markup.
# Don't forget to ret... | true |
87bfed0ab5a3a362680ba4c82a3d52103d60604e | Ruby | iliabylich/typed-ruby | /lib/typed_ruby/signatures/module.rb | UTF-8 | 1,326 | 2.78125 | 3 | [] | no_license | module TypedRuby
module Signatures
class Module < ::TypedRuby::Type
attr_reader :name, :own_methods, :included_modules, :prepended_modules
def initialize(name:)
@name = name
@included_modules = []
@prepended_modules = []
@own_methods = []
@sclass_methods = []
... | true |
e724b549ca454a916fb7063c4b716c2f613b0432 | Ruby | Jlawlzz/personal-project | /soiree/app/models/worker.rb | UTF-8 | 1,285 | 2.625 | 3 | [] | no_license | class Worker
def self.update_personal_playlists
playlists = find_expired_playlists
refresh_playlists(playlists)
end
def self.update_group_playlists
groups = find_expired_groups
refresh_groups(groups)
end
def self.find_expired_playlists
time = Time.now - 7.days
time2 = time - 7.day... | true |
39328f91f45f66d2d5a55d31e2a31944f7c5746b | Ruby | maass77627/programming-univbasics-4-intro-to-hashes-lab-online-web-prework | /intro_to_ruby_hashes_lab.rb | UTF-8 | 447 | 2.890625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def new_hash
hash = {}
hash
end
def my_hash
my_hash = { "bread" => 1 "drink" => 2}
my_hash
end
def pioneer
pioneer = {:name => grasshopper}
pioneer
end
def id_generator
id_generator = {:id => 5 }
id_generator
end
def my_hash_creator(key, value)
hash= { "key"=> value }
hash
end
def read_from_hash(... | true |
e5cc9754f7813f95bf7cca4084cf322a620fbd42 | Ruby | jcreiff/exercism | /ruby/all-your-base/all_your_base.rb | UTF-8 | 630 | 3.3125 | 3 | [] | no_license | class BaseConverter
def self.convert(input_base, digits, output_base)
raise ArgumentError unless digits.all? { (0...input_base).cover?(_1) }
raise ArgumentError if input_base < 2 || output_base < 2
value = find_value(input_base, digits.reverse)
new_digits(value, output_base)
end
def self.find_val... | true |
6634c14c355d78b32c5ceecf39c7c6c13be41b87 | Ruby | edisonesc/Learn_To_Code_With_Ruby | /rdoc/album.rb | UTF-8 | 465 | 3.921875 | 4 | [] | no_license | #ALBUM THAT STORES ARRAY OF SONGS
class Album
include Enumerable
#array of songs
attr_reader :songs
#creates a new album w/ empty array
def initialize
@songs = []
end
#add songs
def add_songs (song)
@songs << song
end
#yield each song in the album to a black
def each
songs.each do |i|... | true |
62884a6adc02464c0c9a8cdbfc02cfe6a8129d79 | Ruby | diogolsq/batch-409 | /reboot/calculator/calculator.rb | UTF-8 | 277 | 3.734375 | 4 | [] | no_license | def calculator(x, y, operation)
if operation == "+"
result = x + y
elsif operation == "-"
result = x - y
elsif operation == "*"
result = x * y
elsif operation == "/"
result = x / y.to_f
else
result = "Invalid operation"
end
return result
end
| true |
306f016528da6e17885b0dcb8bbe53448cb81d2e | Ruby | JaredShay/rails_one_file_repro | /mysql/template.rb | UTF-8 | 1,658 | 2.53125 | 3 | [] | no_license | # Specify gems versions you want to test
gem 'activerecord', "4.2.10"
gem "mysql2", "0.4.10"
require 'active_record'
require 'mysql2'
require 'logger'
require 'uri'
if ARGV[0] == '--debug'
class Logger
alias :original_debug :debug
def debug(*args, &block)
original_debug(*args, &block)
basename ... | true |
92180acbcff616e71cc637f0f36e9d6ebcc063ce | Ruby | sonsongithub/YouTubeGetVideoInfoAPIParser | /YouTubeGetVideoInfoAPIParserTests/test.rb | UTF-8 | 672 | 2.6875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require "cgi"
require "uri"
require 'json'
buf = STDIN.gets
queries = CGI.parse(buf)
buf = queries
buf.each{|k,v|
throw if v.length != 1
queries[k] = v[0]
}
output = {}
puts queries["url_encoded_fmt_stream_map"]
puts queries["url_encoded_fmt_stream_map"].split(",")
fmt = queries["url_encode... | true |
1a9f1e716fcb733a78b3658090a39e81ff27c7cc | Ruby | pierre-pat/ruby-gol | /world.rb | UTF-8 | 1,144 | 3.5625 | 4 | [] | no_license | require 'cell'
class World
attr_accessor :grid
def initialize size_world, size_cell
@size_world, @size_cell = size_world, size_cell
@num_cells = @size_world / @size_cell
@grid = Array.new(@num_cells) do |x|
Array.new(@num_cells) do |y|
state = rand(6) < 2 ? 1 : 0
Cell.new(x, y, state)
... | true |
74ca85850d2ec509966eb88359ccf1056a5b653c | Ruby | panitanp11/thaimutualfunds | /app/models/fund.rb | UTF-8 | 776 | 2.578125 | 3 | [] | no_license | class Fund < ActiveRecord::Base
attr_accessible :name, :abbr, :management_firm
has_many :unit_prices
belongs_to :management_firm
validates :abbr, presence: true
validates :management_firm, presence: true
before_validation :prepare_funds
def to_s
"#{name}: #{abbr}"
end
def nav_at(date)
if ... | true |
7d30e9e8c0aaba4a86dbdae22aabf8aedf8ef5aa | Ruby | moneytrackio/tezos_client | /lib/tezos_client/tools/convert_to_hash/pair.rb | UTF-8 | 1,627 | 2.625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
class TezosClient
module Tools
class ConvertToHash < ActiveInteraction::Base
class Pair < Base
def decode
raise "Not a 'Pair' type" unless normalized_data[:prim] == "Pair"
raise "Difference detected between data and type \nDATA: #{normalized_data} \... | true |
b5eeb740ede3540d5d497a9a28fb7f7ac66b2a94 | Ruby | aboisvert/s3cp | /lib/s3cp/s3tree.rb | UTF-8 | 4,907 | 2.828125 | 3 | [
"Apache-2.0"
] | permissive | # Copyright (C) 2010-2012 Alex Boisvert and Bizo Inc. / All rights reserved.
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file... | true |
092afffd51c2eb45ad91efc1b0f4c88d1fd71291 | Ruby | hgodinot/hgodinot-Launch_School | /RB_challenges_new/easy/2.rb | UTF-8 | 174 | 3.171875 | 3 | [] | no_license | class DNA
def initialize(dna)
@dna = dna.chars
end
def hamming_distance(str)
@dna.select.with_index { |chr, idx| str[idx] && chr != str[idx] }.size
end
end | true |
213facdd2a9d671d4f8f2b09085dc49b10f40d66 | Ruby | bezrukavyi/design_patterns | /behavioral/command/save_order_command.rb | UTF-8 | 543 | 2.8125 | 3 | [] | no_license | require 'yaml'
class SaveOrderCommand < Command
attr_reader :path, :order
attr_accessor :orders
def initialize(order)
@order = order
@path = File.join(File.dirname(__FILE__), 'data/orders.yml')
@orders = load || []
end
def execute
orders << order.form
write_orders
end
def unexecute... | true |
8ea900b443f2a1d9620def3b71eeafc7fa4387e7 | Ruby | dronky/ror_samurai | /ruby_lesson2/ruby2.5.rb | UTF-8 | 1,027 | 3.59375 | 4 | [] | no_license | #Год високосный, если он делится на четыре без остатка, но если он делится на 100 без остатка, это не високосный год. Однако,
#если он делится без остатка на 400, это високосный год. Таким образом, 2000 г. является особым високосным годом,
#который бывает лишь раз в 400 лет.
#дано: nn,mm,yy. Найти порядковый номер да... | true |
5fc8c2cbaf69f20494d443578d8eff60c74605dd | Ruby | quackingduck-archive/redis-examples | /examples.rb | UTF-8 | 1,028 | 2.75 | 3 | [] | no_license | require 'redis-server'
require 'redis'
require 'exemplor'
eg.helpers do
def db
@db ||= Redis.new(:port => 6389).tap(&:flushdb)
end
end
eg 'basic' do
db[:foo] = "bar"
Show(db[:foo])
end
eg 'incrementing & decrementing a counter' do
Show(db.incr('counter'))
Show(db.incr('counter'))
Show(db.incr('cou... | true |
d355ff732610c136fef5890c8d8e8c0abcaa71b6 | Ruby | villesundberg/sauli | /sauli.rb | UTF-8 | 2,148 | 2.609375 | 3 | [
"MIT"
] | permissive | require 'selenium-webdriver'
require 'nokogiri'
require 'capybara'
require 'capybara/dsl'
# Configurations
Capybara.register_driver :selenium do |app|
Capybara::Selenium::Driver.new(app, browser: :chrome, options: Selenium::WebDriver::Chrome::Options.new(args: %w[headless disable-gpu window-size=1024,768]))
end
Cap... | true |
f08a03610f300588589297086ce54e7a63a10cfe | Ruby | alaxsawe/mukif | /app/models/topic/callbacks.rb | UTF-8 | 977 | 2.5625 | 3 | [
"MIT"
] | permissive |
class Topic < ActiveRecord::Base
# callbacks concern
before_create :init_record
after_create :create_fulltext!, :after_create_routine
before_save :trim_body
after_update :update_fulltext!
after_destroy :after_destroy_routine
private
def init_record
self.last_post_at = Time.now
... | true |
c45c637d57300d28daf21da8aa9c1f21769125f6 | Ruby | mharris717/lsl | /lib/lsl/command/execution.rb | UTF-8 | 3,637 | 2.65625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | class Array
def each_with_expansion(&b)
return if empty?
first.array_aware_each do |x|
if size == 1
yield([x])
else
self[1..-1].each_with_expansion do |args|
yield([x] + args)
end
end
end
end
end
class Object
def to_array_if_not
kind_of?(Array) ... | true |
13f0019d2ce87515a6d13169c7f0eba93517fcab | Ruby | vinnyalfieri/jukebox-cli-web-0615-public | /spec/jukebox_spec.rb | UTF-8 | 1,654 | 3.09375 | 3 | [] | no_license | require_relative 'spec_helper'
require 'pry'
songs = [
"Phoenix - 1901",
"Tokyo Police Club - Wait Up",
"Sufjan Stevens - Too Much",
"The Naked and the Famous - Young Blood",
"(Far From) Home - Tiga",
"The Cults - Abducted",
"Phoenix - Consolation Prizes",
"Harry Chapman - Cats in the Cradle",
"Amos L... | true |
8bf7b3840fdf413841c085cfc622cfac6525aaf1 | Ruby | nbrew/minitest-sequel | /spec/minitest/sequel_associations_spec.rb | UTF-8 | 12,897 | 2.65625 | 3 | [
"MIT"
] | permissive | require_relative "../spec_helper"
class Minitest::SequelAssociationsTest < Minitest::Spec
describe Minitest::Spec do
describe 'associations' do
describe "#assert_association() & .must_have_association()" do
before do
@c = Class.new(::Post) do
one_to_many :comments
... | true |
0cafb622a40c00bfa0b892a480137410fdc2af82 | Ruby | NicolayD/ruby-chess | /spec/chess_spec.rb | UTF-8 | 5,007 | 3.53125 | 4 | [] | no_license | require 'spec_helper'
require 'chess'
describe Chess do
let(:game) { Chess.new }
context '#initialize' do
it 'creates a chess board' do
expect(game.board).to be_a(Array)
end
it 'has 8 board rows and 1 index row' do
expect(game.board.size).to eq(9)
end
it 'has 8 board columns and 1 index column' ... | true |
c0c12c25502b8275e9d7795e9ae83c0238aa1e0c | Ruby | jordanholtkamp/real_estate_1909 | /lib/house.rb | UTF-8 | 1,771 | 3.65625 | 4 | [] | no_license | # pry(main)> house = House.new("$400000", "123 sugar lane")
# #=> #<House:0x00007fccd30375f8...>
#
# pry(main)> room_1 = Room.new(:bedroom, 10, 13)
# #=> #<Room:0x00007fccd29b5720...>
#
# pry(main)> room_2 = Room.new(:bedroom, 11, 15)
# #=> #<Room:0x00007fccd2985f48...>
#
# pry(main)> room_3 = Room.new(:living_room, 25... | true |
2216feec22d5c84760d92dc2c0c60f05c637900e | Ruby | genephoenix/robot-rspec-testing | /lib/robot.rb | UTF-8 | 1,500 | 3.59375 | 4 | [] | no_license | class Robot
class RobotAlreadyDeadError < StandardError
end
class UnattackableEnemy < StandardError
end
attr_reader :position, :items, :health
attr_accessor :equipped_weapon
def initialize
@position =[0,0]
@items = []
@items_weight = 0
@health = 100
@equipped_weapon = nil
end
... | true |
436ac52842fa318719b02b9115b27255ccad2072 | Ruby | mlibrary/regal_bird | /spec/plan_spec.rb | UTF-8 | 4,526 | 2.546875 | 3 | [
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | # frozen_string_literal: true
require "regal_bird/plan"
RSpec.describe RegalBird::Plan do
let(:empty_plan) { described_class.new("empty_plan") }
describe "#name" do
it "returns the name" do
expect(empty_plan.name).to eql("empty_plan")
end
end
describe "#define" do
before(:each) { described_... | true |
602f2ba50b373d0ead68bcb35e79879aa21ce33e | Ruby | unrealities/code-eval | /easy/029_UniqueElements/ruby/lib/unique_elements.rb | UTF-8 | 222 | 3.046875 | 3 | [] | no_license | class UniqueElements
def initialize(string_inputs = ARGV[0])
IO.foreach(string_inputs) do |line|
array = line.strip.split(",")
array.uniq!
puts array.join(",")
end
end
end
#UniqueElements.new | true |
0414d2811e77d2a87267cea1e2209c1146060495 | Ruby | MostlyFocusedMike/guessing-cli-prework | /guessing_cli.rb | UTF-8 | 448 | 4.09375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def check_guess(guess)
rand_num = rand(1..6)
if rand_num == guess.to_i
puts "You guessed the correct number!"
else
puts "The computer guessed #{rand_num}."
end
end
def run_guessing_game
loop do
puts "Guess a number between 1 and 6."
guess = gets.strip
if guess.to_i != 0
check_guess(... | true |
3b9ea945ddf97fc0137c73e2a1d232bb327c4fe6 | Ruby | Epictetus/cpp | /rxbyak/test.rb | UTF-8 | 276 | 2.84375 | 3 | [] | no_license | require 'RXbyak'
rx = RXbyak.new
def rx.code
mov eax, [esp, 8]
movq xmm0, [eax]
mov eax, [esp, 12]
movq xmm1, [eax]
L:loop
divsd xmm0, xmm1
mov eax, [esp, 4]
movq [eax], xmm0
ret
end
rx.code
puts rx.float_call(256.0, 256.0)
puts rx.float_call(123.45, 678.9)
| true |
ca05eb05b2d263655aa30a0b750a03be5e5d7c1f | Ruby | jsuabur/libro-de-actividades | /actividades/prog/files/ruby/mil-ejemplos/code/rubygems-0.8.11/test/test_check_command.rb | UTF-8 | 797 | 2.515625 | 3 | [
"CC0-1.0",
"CC-BY-SA-3.0"
] | permissive | #!/usr/bin/env ruby
#---
# Excerpted from "Everyday Scripting in Ruby"
# We make no guarantees that this code is fit for any purpose.
# Visit http://www.pragmaticprogrammer.com/titles/bmsft for more book information.
#---
require 'test/unit'
require 'rubygems/cmd_manager'
require 'rubygems/user_interaction'
require '... | true |
b05f2230111b26a7cff039b9e1c84401bce69ca7 | Ruby | oahmet/twol | /twol.rb | UTF-8 | 1,747 | 2.703125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/ruby
require 'rubygems'
require 'twitter'
require 'htmlentities'
require 'getoptlong'
require_relative 'twol/func'
user, keyword, outfile = nil
friend_list = Hash.new
opts = GetoptLong.new(
[ '--help', '-h', GetoptLong::NO_ARGUMENT ],
[ '--user', '-u', GetoptLong::OPTIONAL_ARGUMENT... | true |
815ffe3dfed2fddaefe50d74b63827d140d0af2f | Ruby | ChaelCodes/HuntersKeepers | /app/models/improvement.rb | UTF-8 | 1,949 | 2.515625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
# Improvements are associated with Playbooks
# These are the options the Hunter can choose
# from when upgrading their character.
# == Schema Information
#
# Table name: improvements
#
# @!attribute id
# @return []
# @!attribute advanced
# @return [Boolean]
# @!attribute description
#... | true |
7e23aa864f9e0742c91f8cc3271151d52c1b45bc | Ruby | ThomasMcP/w1_d4_lab | /friends.rb | UTF-8 | 938 | 3.34375 | 3 | [] | no_license | def get_name(person)
return person[:name]
end
def get_tv_show(person)
return person[:favourites][:tv_show]
end
def likes_to_eat(person, food)
return true if person[:favourites][:snacks].include?(food)
end
def new_friend(person, friend)
person[:friends].push(friend)
end
def remove_friend(person, friend)
pe... | true |
756c9ddc69bef2f04bc694241003dccfeb841a0e | Ruby | Se7endz/j5Ruby | /exo_05.rb | UTF-8 | 3,085 | 3.828125 | 4 | [] | no_license | # Le symbole #{} correspond à une interpolation de chaines de caractéres, elle permet de rajouter des données dans une chaine
# on utilise #{} et on ajoute la ou les variables que l'on veut rajouter à une string. On peut effectué des opérations à l'intérieur etc...
puts "On va compter le nombre d'heures de travail à TH... | true |
ad715922bc9bc3163e5a81aa13700361ca466610 | Ruby | CodyFrank/tweet-shortener-online-web-prework | /tweet_shortener.rb | UTF-8 | 1,219 | 3.609375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # Write your code here.
require "pry"
def dictionary
shorter_words = {
"hello" => "hi",
"to" => "2",
"two" => "2",
"too" => "2",
"for" => "4",
"four" => "4",
"be" => "b",
"you" => "u",
"at" => "@",
"and" => "&"
}
end
def word_substituter (tweet)
tweet_array = tweet.split("... | true |
a6495c38f9b88edfa62cf2ff233ad489e8904397 | Ruby | ahrke/Launch_School | /RB101_RB109/small_problems/easy_9.rb | UTF-8 | 6,160 | 4.5625 | 5 | [] | no_license | # Question 1
# Welcome Stranger
# Create a method that takes 2 arguments, an array and a hash. The array will
# contain 2 or more elements that, when combined with adjoining spaces, will
# produce a person's name. The hash will contain two keys, :title and :occupation,
# and the appropriate values. Your method should... | true |
1b9c040f173e7d57c27d16ae5b4f12930aa2f8c1 | Ruby | j-7/jp-textbook.github.io | /xlsx2ttl-rc.rb | UTF-8 | 1,799 | 2.515625 | 3 | [] | no_license | #!/usr/bin/env ruby
require "csv"
require "roo"
require "nkf"
require "logger"
require_relative "util.rb"
if $0 == __FILE__
include Textbook
SHEET_NAME = "教科書研究センターデータ"
if ARGV.size < 1
puts "USAGE: #$0 data.xls [sheet_name]"
puts
puts " Note: default sheet_name is \"#{ SHEET_NAME }\""
exit
... | true |
6b347c47821aaf094ec56c772ada33f55f55b7fa | Ruby | deployable/deployable-patch | /lib/deployable/patch/string/quoting.rb | UTF-8 | 401 | 3.0625 | 3 | [
"MIT"
] | permissive | class String
def quote char
# improve this to escape chars, if they aren't already escaped
raise if match char
"#{char}#{self}#{char}"
end
def quote_escape char
#if m = match char
# m.
#end
"#{char}#{self}#{char}"
end
def single_quote
quote "'"
end
def double_quote
... | true |
7d51f932df81f883ec0fd1a415332c5d70bddeb1 | Ruby | stoeffel/hosts_alias | /lib/hosts_alias.rb | UTF-8 | 1,506 | 2.71875 | 3 | [] | no_license |
require 'fileutils'
require 'tempfile'
require 'ipaddr'
class Hosts_alias
HOSTS_PATH = "/etc/hosts"
def initialize(arguments)
@args = []
@alias
@ip = "127.0.0.1"
@add_or_remove = :+
get_args arguments
parse_arg @args[0]
case @add_or_remove
when :+
puts "added alias(#{@alias}) for #{@ip}"
wh... | true |
bd6f0a14cb6635f215bb947f65a866d3e978a36b | Ruby | petertseng/rebellion_g54 | /spec/action/socialist_spec.rb | UTF-8 | 3,540 | 2.546875 | 3 | [
"Apache-2.0"
] | permissive | require 'spec_helper'
require 'rebellion_g54/action/socialist'
RSpec.describe RebellionG54::Action::Socialist do
let(:users) { game.users }
let!(:u1) { users[0] }
let!(:u2) { users[1] }
let!(:u3) { users[2] }
context 'when using socialist' do
let(:game) { example_game(3, roles: :socialist) }
before... | true |
eaa51f9da3c741440e8783cb6236344d40f81b6c | Ruby | georgecode/restCrudTry2 | /app/controllers/channels.rb | UTF-8 | 2,096 | 2.75 | 3 | [] | no_license |
get '/channels' do
@channels = Channel.all #define instance variable for view
erb :'channels/index' #show all channels view (index)
end
get '/channels/new' do
erb :'channels/new' #show new channels view
end
post '/channels' do
#below works with properly formatted params in HTML form
@channel = Ch... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.