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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
b29106ab72aa2807550d0a8ebf93170a954b800c | Ruby | levthedev/intro_to_ruby | /oldboobina.rb | UTF-8 | 712 | 4 | 4 | [] | no_license | # Write a Deaf Grandma program.
# Whatever you say to grandma
# (whatever you type in),
# she should respond with HUH?!
# SPEAK UP, SONNY!, unless you
# shout it (type in all capitals).
# If you shout, she can hear you
# (or at least she thinks so)
# and yells back, NO, NOT SINCE
# 1938!
#
# "You can't stop talking to... | true |
7c769851bd23e54f872459a10af062a85f408944 | Ruby | vmetrix/vacuumetrix | /bin/NewrelicThresholds.rb | UTF-8 | 1,930 | 2.53125 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
### grab metrics from newrelic and put them into graphite
### David Lutz
### 2012-06-15
### to use: apt-get install ruby
### apt-get install build-essential
### apt-get install libcurl3 libcurl3-gnutls libcurl4-openssl-dev
### gem install curl curb json xmlsimple --no-ri --no-rdoc
#
$:.unshift File... | true |
8650f8ab1cfe75dbc8212f2cd7e58595c368bc03 | Ruby | marcusfgardiner/student-directory | /source_code_reader.rb | UTF-8 | 345 | 4.0625 | 4 | [] | no_license | #Quines i.e. printing a programs own source code!
#Key is properly escaping characters to reprint code
#The first line of code is very close to the second but with lots of escaping characters e.g. \n, and .inspect is used to escape the string itself.
quine = "\nputs \"quine = \" + quine.inspect + quine"
puts "quine = ... | true |
d043170712de9b2a2ac9f854e086adad9e0984db | Ruby | sbraford/pubrunner | /test/test_octopress_transformer.rb | UTF-8 | 1,432 | 2.609375 | 3 | [
"MIT"
] | permissive | require 'test/unit'
require 'pubrunner'
class OctopressTransformerTest < Test::Unit::TestCase
include Pubrunner
def test_octopress_transform_and_save
wellformatted_path = File.dirname(__FILE__) + '/fixtures/wellformatted.txt'
p = Processor.new(wellformatted_path)
b = p.process
ot = Transformer::... | true |
0d2b5cc41358fdf7ee7d613dc0824355915eaa88 | Ruby | arnelimperial/Ruby-codes | /fib.rb | UTF-8 | 477 | 3.84375 | 4 | [
"Zlib"
] | permissive | #!/usr/bin/env ruby
#Fibonacci function
def fibonacci(int)
if int == 1
return 1
end
if int == 2
return 2
end
# return
return fibonacci(int - 1) + fibonacci(int -2)
end
#print w/o new line
print "Montako kierrosta lasketaan?: "
# convert to int w/out new line
number = gets.ch... | true |
7c2040e89d199a7bda88e87a1bdffdd1093a46fe | Ruby | niligulmohar/ruby_asound | /asound.rb | UTF-8 | 6,745 | 2.59375 | 3 | [] | no_license | require 'forwardable'
require '_asound'
module Snd::Seq
class << self
def open
Snd::Seq::SequencerClient.new
end
end
class SequencerClient
attr_reader :client_id
def initialize
@client_id = client_info.client
end
def create_simple_port(name, caps, type)
port_info = Port... | true |
d38a98739ab48617e1eec2822b7becee752654c4 | Ruby | alpaca-tc/ffaker | /lib/faker/utils/module_utils.rb | UTF-8 | 358 | 2.703125 | 3 | [] | no_license | require 'ffaker/utils/array_utils'
module Faker
module ModuleUtils
def fill_in_string(text, n = nil)
return text if n.nil?
max = n.is_a?(Range) ? n.to_a.shuffle.first : n
until text.length == max
return text[0...max] if text.length >= max
text += text[0...max - text.length]
... | true |
25402e5cb85d3bd06a4abbf7a86b7b97a8a5ff0b | Ruby | dmaster18/learn-co-sandbox | /ruby_past_practice/self.rb | UTF-8 | 303 | 3.78125 | 4 | [] | no_license | class Dog
attr_accessor :name, :owner
def initialize(name)
@name = name
end
def call_on
puts self
end
def get_adopted(owner_name)
self.owner = owner_name
end
end
fido = Dog.new("Fido")
fido.owner = "Sophie"
puts fido.owner
fido.get_adopted("Anthony")
puts fido.owner
| true |
94cd1aebba4efef6be9428172895301c54113d0a | Ruby | message-driver/message-driver | /spec/units/message_driver/middleware/middleware_stack_spec.rb | UTF-8 | 5,813 | 2.765625 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
module MessageDriver
module Middleware
RSpec.describe MiddlewareStack do
class Top < Base; end
class Middle < Base; end
class Bottom < Base; end
let(:top) { Top.new(destination) }
let(:middle) { Middle.new(destination) }
let(:bottom) { Bottom.new(destina... | true |
bb6f8aa0d8b85544cef4d08d71bb9a3ef68db349 | Ruby | AshwiniKumar/learnstreet | /Concentration/concentration.rb | UTF-8 | 2,089 | 3.984375 | 4 | [] | no_license | #Memory Concentration Game
def populate()
# This method populates the concentration game board by
# populating and returning a 5x4 two-dimensional array.
# Initialize all the values to zero (0), then randomly populate
# numbers from 1-10 in different cells of the array, making
#sure each numb... | true |
ba61719945f254ecc3a545bb0427b3322fc2c937 | Ruby | jucoba/TimeTracker | /util.rb | UTF-8 | 501 | 2.78125 | 3 | [] | no_license | require 'Win32API'
class Util
def self.saveToFile(filename,text)
file = File.open(filename,'a')
file.puts text+"\n"
file.close
end
def self.getActiveWindowTitle()
getForegroundWindow = Win32API.new('user32', 'GetForegroundWindow', [], 'L')
getWindowText = Win32API.new('user32', 'GetWindowText', ['L', ... | true |
96d1e982ef938721373b8b18c539e04ca24603a8 | Ruby | kimmiies/rainforest-with-ajax | /app/controllers/sessions_controller.rb | UTF-8 | 987 | 2.65625 | 3 | [] | no_license | class SessionsController < ApplicationController
def new
end
#we don't have to instantiate a user object because we are only logging in, not creating new user
def create
user = User.find_by_email(params[:email]) #find email by email user types in
if user && user.authenticate(params[:password]) #check if... | true |
51f93eb5982ea3f3c5d5c272cb38586e40fd100c | Ruby | jeffwett/craigslist_scraper | /lib/craigslist_scraper/craigslist.rb | UTF-8 | 3,342 | 2.71875 | 3 | [
"MIT"
] | permissive | require 'nokogiri'
require 'open-uri'
require 'cgi'
require_relative 'cities'
require_relative 'util'
require_relative 'common'
module Craigslist
module Scrapers
class SearchScraper
include Craigslist::Cities
include Craigslist::Scrapers::Common
include ClassLevelInheritableAttributes
... | true |
90e206ebb1628af3255b4dc92a8ccb5db2fbdf7b | Ruby | diminishedprime/old-.org | /reading-list/seven_languages_in_seven_weeks/ruby/day_1_finding_a_nanny.rb | UTF-8 | 1,130 | 4.65625 | 5 | [
"MIT"
] | permissive | # Print the string, Hello, world!
(puts 'Hello, world!')
# For the string "Hello, Ruby," find the index of the word "Ruby."
'Hello, Ruby'.index('Ruby')
# Print your name ten times.
10.times do
puts 'Your name'
end
# Print the string "This is sentence number 1," where the number 1 changes from
# 1 to 10.
11.times d... | true |
ee2aa6958c9537c937d5e1b5b85840fe7a9aaf7f | Ruby | Invoca/parameter_substitution | /spec/lib/parameter_substitution/formatters/date_time_strftime_spec.rb | UTF-8 | 1,307 | 2.8125 | 3 | [] | no_license | # frozen_string_literal: true
require_relative '../../../../lib/parameter_substitution/formatters/date_time_strftime'
describe ParameterSubstitution::Formatters::DateTimeStrftime do
context "Date Time Strftime formatter test" do
before do
@format_class = ParameterSubstitution::Formatters::DateTimeStrftime... | true |
f1cdad094b9d8c709ad46674efc82b5bf48ba8bb | Ruby | aislam2018/OO-mini-project-dumbo-web-102918 | /app/models/User.rb | UTF-8 | 660 | 3.015625 | 3 | [] | no_license | class User
@@all = []
attr_accessor :name
def initialize(name)
@name = name
@@all << self
end
def my_recipe_cards
my_recipe_cards = RecipeCard.all.select {|card| card.user == self}
end
def recipes
my_recipe_cards.collect { |card| card.recipe }
end
def add_recipe_card(date, rating, re... | true |
ee02111c73637ad26035d8376c0d1c4facf5a540 | Ruby | robson3999/nurserec | /app/services/admin/medicaments/upload_csv.rb | UTF-8 | 1,469 | 2.625 | 3 | [] | no_license | require 'csv'
module Admin
module Medicaments
class UploadCSV
attr_reader :csv, :status
def initialize(params:)
@csv = CSV.open(params[:file].tempfile)
@status = params[:status]
end
def call
CSV.foreach(csv.path, col_sep: ';').with_index do |row, index|
... | true |
c8d482ee39c44094f30899eb76f3f3caea2786a9 | Ruby | xdkernelx/personality-analyzer | /app/helpers/user_helper.rb | UTF-8 | 772 | 2.625 | 3 | [] | no_license | helpers do
def registration_errors(params)
email_regex = /^[a-zA-Z0-9]+.?[a-zA-Z0-9]*@[a-zA-Z0-9]*.?[a-zA-Z0-9]*.[a-zA-Z]{2,}.?[a-zA-Z]{2,}$/
username_regex = /^[a-zA-Z0-9]{6,}$/
p params[:user]['username']
if User.find_by(email: params[:user]['email'])
return "That e-mail is already taken."
... | true |
198c2ada3fd5f5f549435195859e6a0ec7c0e643 | Ruby | jaredsmithse/DevBootCampWork | /phase_1/assessments/nested_arrays2.rb | UTF-8 | 1,259 | 3.875 | 4 | [] | no_license | ### Tic Tac Toe Solution ###
def generate_tic_tac_toe
x_or_o = ["X","O"]
board_start = (0..9).to_a.map {|square| square = x_or_o[rand(x_or_o.length)]}
final_board = Array.new(3) { board_start.shift(3) }
end
p generate_tic_tac_toe
### Convert Array Solution ###
def convert_roster_format(roster)
array_of_ent... | true |
331e2aa4efd0783210a4e605908b8be095042ab7 | Ruby | baezdiazm/oo-cash-register-onl01-seng-pt-052620 | /lib/cash_register.rb | UTF-8 | 785 | 3.4375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class CashRegister
attr_accessor :discount, :purchases, :total, :transaction
def initialize(discount=0)
@total = 0
@discount = discount
@purchases = []
end
def add_item(name, price, quantity=1)
@transaction = [name, price, quantity]
quantity.times do
@purchases << @transaction[0]
... | true |
5eef99a69327cb0557451d58fbf08cb629e09c03 | Ruby | dmsalomon/upload | /tty.rb | UTF-8 | 1,660 | 2.984375 | 3 | [] | no_license |
# This code is 'stolen' from homebrew package manager for osx :)
class Tty
class << self
def tick
# necessary for 1.8.7 unicode handling since many installs are on 1.8.7
@tick ||= ["2714".hex].pack("U*")
end
def cross
# necessary for 1.8.7 unicode handling since many installs are on 1... | true |
85001a14f6cab1e0fb252312b884fd7df3476b8f | Ruby | mahendhar9/programming_problems | /csv_file_parser/csv_file_parser.rb | UTF-8 | 747 | 3.6875 | 4 | [] | no_license | # Build a CSV File parser in Ruby that converts a CSV file to array values.
# Input
# csv_parser(path_to_file)
# Sample Output
# [
# ["Name", "Email", "City"],
# ["Matt", "matt@example.com", "London"],
# ["Joe", "joe@example.com", "New York"],
# ["Susan", "susan@example.com", "Paris"]
# ]
require 'rspec'
de... | true |
7578739a64a88f506442259284e592671fccba39 | Ruby | eyeced/ruby_problems | /src/radix_sort.rb | UTF-8 | 592 | 3.5625 | 4 | [
"MIT"
] | permissive | class RadixSort
def self.sort(arr)
max = arr.max
max.to_s.length.times do |i|
# initialize bucket
buckets = Array.new(20){[]}
# defining the base for each loop to get the digit at that base increasing it after each loop
bar = 10 ** i
arr.each do |x|
d = get_digit_at(x, b... | true |
de56b4d119ee39f5a11d0cb1d23be10b766e7de9 | Ruby | yumojin/Example-Sketches | /samples/contributed/grapher.rb | UTF-8 | 880 | 2.90625 | 3 | [
"MIT"
] | permissive | # Grapher is based on a context free art design
# by ColorMeImpressed (takes a bit of time to run)
# http://www.contextfreeart.org/gallery/view.php?id=2844
#
load_library :fastmath
CMIN = -2.0 # Important to specify float else get random int from range?
CMAX = 2.0
FUZZ = 0.04
SZ = 5
def setup
size 600, 600
no_st... | true |
4b9bdff6bebe1006c9124be07b4b52e77d230d11 | Ruby | shirleytang0121/AAClasswork | /W2D4/shirley_tang_recap_exercise_3/general_problems/longest_streak.rb | UTF-8 | 599 | 3.734375 | 4 | [] | no_license | def longest_streak(str)
streak=str[0]
count=1
max_length=1
(0...str.length-1).each do |i|
if str[i]==str[i+1]
count+=1
if count>=max_length
max_length=count
streak=str[i]
end
else
count=1
... | true |
918d5a34fb22f901e17fe27d68da3a5782b645f4 | Ruby | seidmanmb/ruby-all | /ruby/meanboss.rb | UTF-8 | 131 | 2.859375 | 3 | [] | no_license | puts ''
puts 'WHAT DO YOU WANT?'
puts ''
want = gets.chomp
puts ''
puts 'WHAT DO YOU MEAN "' + want.upcase + '"?!? YOU\'RE FIRED!!' | true |
0ea809f0dfbb2673c1f5e2d8b68c3a7dff0a7c0a | Ruby | connorpaulstauffer/app-academy | /prep-work/test-first-ruby/lib/03_simon_says.rb | UTF-8 | 472 | 4.03125 | 4 | [] | no_license | def echo message
message
end
def shout message
message.upcase
end
def repeat message, num = 2
("#{message} " * num).chop
end
def start_of_word string, num
string[0..(num - 1)]
end
def first_word string
string.split[0]
end
def titleize string
little_words = ["and", "the", "is", "a", "over"]
string.spl... | true |
2b198d3c98eba079fe7189c6fa46463c3db69690 | Ruby | HatemC/ruby_practice | /can_i_vote.rb | UTF-8 | 276 | 3.265625 | 3 | [] | no_license | require_relative "vote_test"
puts "What is your first name"
first_Name = gets.chomp
puts "What is your last name"
last_Name = gets.chomp
puts 'What is your age'
age = gets.chomp.to_i
name=fullName(first_Name,last_Name)
ageTested=voteAge(age)
puts "#{name}, #{ageTested}"
| true |
bdcbfd1a93ab477b043bf8a231989578008d69ba | Ruby | KOBA789/internet-sampler | /main.rb | UTF-8 | 3,510 | 2.53125 | 3 | [
"CC-BY-4.0"
] | permissive | # -*- coding: utf-8 -*-
require 'bundler/setup'
require 'json'
require 'sinatra'
require 'sinatra/reloader' if development?
require 'sinatra-websocket'
require 'redis'
require 'slim'
class Time
def msec
self.instance_eval { self.to_i * 1000 + (usec/1000) }
end
end
class Subscriber
attr_reader :subscribe... | true |
3106a2c370dc28c348181df4504612b584203b4c | Ruby | onelang/TestArtifacts | /CompilationTest/BigInteger/results/BigInteger.rb | UTF-8 | 580 | 3.765625 | 4 | [
"MIT"
] | permissive | class MathUtils
def self.calc(n)
result = 1
i = 2
while i <= n
result = result * i
if result > 10
result = result >> 2
end
i += 1
end
return result
end
def self.calc_big(n)
result = 1
i = 2
while i <= n
... | true |
b054e9ce461d0c1a5a0291e0e3ed39b47217e43b | Ruby | d3z/product-import_export | /default_file_handler.rb | UTF-8 | 362 | 3.28125 | 3 | [] | no_license | # Simple file handler that reads contents of
# file to string and writes string straight
# to file
class DefaultFileHandler
def read_data_from(filename)
file = File.open(filename, "r")
file.read
end
def write_data_to(filename, data)
File.open(filename, "w") { |file|
... | true |
8365950d1880bccf90b573cf90236331f4399490 | Ruby | mobolaji89/phase-0-tracks | /ruby/gps2_2.rb | UTF-8 | 5,755 | 4.09375 | 4 | [] | no_license | #gps 2.2
#Pseudocode
# Method to create a list
# input: string of items separated by spaces (example: "carrots apples cereal pizza")
# steps:
# Split string on " " = array
# create a hash
# set default quantity = 1
# iterate through array of items
# for each item add to hash
# print the list to ... | true |
90fe2fa51bb5b169f3a419b41790d61d32ada31a | Ruby | Richard-Pentecost/cruise_ships | /spec/ship_spec.rb | UTF-8 | 1,358 | 2.96875 | 3 | [] | no_license | require_relative '../ship'
require_relative '../port'
require_relative '../itinerary'
describe Ship do
before(:each) do
@dover = Port.new('Dover')
@calais = Port.new('Calais')
itinerary = Itinerary.new([@dover, @calais])
@ship = described_class.new(itinerary)
end
context 'ship' do
it 'initia... | true |
f7b486567fc00353c7442533cde194af10be2037 | Ruby | RANA-AKBAR/Karaoke_Bar | /guest.rb | UTF-8 | 312 | 3.140625 | 3 | [] | no_license | class Guest
attr_accessor :name, :money, :fav_song
def initialize(name, money, fav_song)
@name = name
@money = money
@fav_song = fav_song
end
def charge(amount)
return @money -= amount
end
def customer_can_afford_drink(drinks_hash, drink)
return @money <= drinks_hash[drink][:info].price
end
end
| true |
68a4725126bcfd4f7dcd91db1d3c01c4493fae62 | Ruby | JRRS1982/TechTests | /bowling/bowling-scorecard/spec/game_spec.rb | UTF-8 | 3,616 | 3.453125 | 3 | [] | no_license | require 'Game'
require 'pry'
describe 'Game' do
context '.roll' do
it 'increments the score when pins are knocked down' do
my_game = Game.new
my_game.roll(1)
expect(my_game.score).to eq(1)
end
end
context '.frame' do
it 'up when a ten is rolled' do
my_game = Game.new
my... | true |
cc5827b33d724242ef3db3fba642268851b059ac | Ruby | rikitoro/design_patterns_in_ruby | /sec13_Factory/habitat_test/algae.rb | UTF-8 | 132 | 3.484375 | 3 | [] | no_license | class Algae
def initialize(name)
@name = name
end
def grow
puts("藻#{@name}は日光を浴びて育ちます。")
end
end | true |
7e5b0b0277cc32043b6be8d34cd95d7a28585d13 | Ruby | IIIIIIIIll/RubyQuizess | /Quiz12/question10.rb | UTF-8 | 247 | 3.015625 | 3 | [] | no_license | class Book
def initialize(args)
@pages = args.fetch(:pages)
@title = args.fetch(:title)
end
end
class Textbook < Book
def initialize(args)
@chapters = args.fetch(:chapters)
end
end
p textbook = Textbook.new({ chapters: 20 })
| true |
4d4db864bd315a9fabc94d3e4d6b972068ccc876 | Ruby | yourpromotioncode/Numbers | /day8-2.rb | UTF-8 | 346 | 2.8125 | 3 | [] | no_license | puts("[Please enter your ID] \n")
input_id = gets.chomp()
# Master_chief = "mc11"
# Dream_Theater = "dt2002"
ids = ['mc11' , 'dt2002']
# if Master_chief == in_str
# elif Dream_Theater ==in_str:
for id in ids do
if id == input_id
puts("** " + id + "!! Welcome to ITW database hub")
exit
end
end
... | true |
5e1ae8d3de4795c844318458db29a23a9f560e0d | Ruby | EGI-FCTF/rOCCI-core | /lib/occi/core/parsers/json/action_instance.rb | UTF-8 | 1,664 | 2.515625 | 3 | [
"Apache-2.0"
] | permissive | module Occi
module Core
module Parsers
module Json
# Static parsing class responsible for extracting action instances from JSON.
# Class supports 'application/json' via `json`. No other formats are supported.
#
# @author Boris Parak <parak@cesnet.cz>
class ActionInsta... | true |
bb9d962d98bc90af2a55c3c3daf90c3023ded53d | Ruby | manuelguillegil/Examen3 | /P3-Pregunta1.1.rb | UTF-8 | 1,067 | 3.296875 | 3 | [] | no_license | ## MANUEL GUILLERMO GIL 14-10397
class Secuencia
def empty
raise NotImplementedError, "#{self.class} has not implemented method '#{__method__}'"
end
def add
raise NotImplementedError, "#{self.class} has not implemented method '#{__method__}'"
end
def remove
raise NotImplemen... | true |
dfe89fb4d827174da10f5b95594f6abe0598a857 | Ruby | UrsaDK/imdb-search | /api/tasks/models/title_basics.rb | UTF-8 | 1,935 | 2.921875 | 3 | [] | no_license | # frozen_string_literal: true
module Task
module Model
module TitleBasics
class << self
# @yeild [formatted_line] Executes block for each line of the file.
# @yieldparam data [Hash] A hash of the line, with column headers as keys,
# and values as they are ret... | true |
853c1ba6bf00da36e06440559114273846307fe1 | Ruby | bellef/getaround_backend_application | /level1/spec/rental_spec.rb | UTF-8 | 571 | 2.890625 | 3 | [] | no_license | require_relative '../rental'
require_relative '../car'
describe Rental do
describe '#price' do
context 'with a car costing 20€ a day and 10 cents a km' do
let(:car) { Car.new(**{ id: 1, price_per_day: 2000, price_per_km: 10}) }
context 'with a rental lasting 3 days and driving 100km' do
let(... | true |
42bb239aff19ad167a1b99eec9b9e7264da5f457 | Ruby | kikicat-meows/aA_Classwork | /W4D2/chess/board_components/board.rb | UTF-8 | 1,055 | 3.671875 | 4 | [] | no_license | require_relative "piece"
class Board
def initialize
black_back_row = [Array.new(8) {Piece.new}]
black_front_row = [Array.new(8) {Piece.new}]
empty_space = Array.new(4) {Array.new(8) {nil} } ### PH for NullPiece
white_front_row = [Array.new(8) {Piece.new}]
white_back_row = [Array.new(8) {Piece.ne... | true |
2f57a317722de2d24a2cac9c4687bed99015cbd8 | Ruby | gorodish/all_files | /week_10/day_3/ruby_test/race.rb | UTF-8 | 164 | 3.421875 | 3 | [] | no_license | def increment(num)
num + 1
end
sum = 0
threads = (1..10).map do
Thread.new do
100000.times {sum = increment(sum)}
end
end
threads.each(&:join)
puts sum | true |
c62480fd589ff7ba54cea4708d0ed57063c5ae44 | Ruby | samuelgustave/learn_to_program_chis_pine | /chap01/ex01.rb | UTF-8 | 670 | 4.6875 | 5 | [] | no_license | # ex01.rb
# how many hours are in a year
hours_in_a_years = 365 * 24
puts "The are #{hours_in_a_years} hours in a year!"
# how many minutes are in a decade ?
minutes_in_a_decade = 10 * 365 * 24 * 60
puts "The are #{minutes_in_a_decade} minutes in a decade!"
# how many seconds old are you?
seconds_old = 36 * 365 * 24... | true |
b67833288731542e7c6461fbf24531c3954d6365 | Ruby | aristides1000/Ruby_Practices | /Methods/example_methods.rb | UTF-8 | 7,741 | 4.25 | 4 | [
"CC0-1.0"
] | permissive | =begin
p "anything".reverse
=end
# Estows dos códigos hacen lo mismo porque puts es un método y en ruby los Métodos pueden ir entre parentesis o sin ellos
=begin
puts "anything"
puts("anything")
=end
# Con la palabra def realizo la declaración de nuevos métodos
=begin
def my_name
"Joe Smith"
end
puts my_name
=en... | true |
b33b5f279510316ae45fee38b891b683d294cbfe | Ruby | devinpile/summer-field-6995 | /spec/features/movies/show_spec.rb | UTF-8 | 1,968 | 2.578125 | 3 | [] | no_license | require 'rails_helper'
RSpec.describe 'Movies Show Page' do
before do
@studio1 = Studio.create!(name: "Syntax Studios", location: "Burbank")
@movie1 = @studio1.movies.create!(title: "Active Record", creation_year: 2022, genre: "Suspense/Thriller")
# @movie2 = @studio1.movies.create!(title: "Add Foreign K... | true |
f75d721b4c9080790edad4f47a5f981e0b34d616 | Ruby | unasuke/AtCoder | /Regular/12/12-A.rb | UTF-8 | 309 | 3.578125 | 4 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #AtCoder Regular 12 A
week = STDIN.gets.chomp
if week == "Sunday" || week == "Saturday" then
puts "0"
elsif week == "Monday" then
puts "5"
elsif week == "Tuesday" then
puts "4"
elsif week == "Wednesday" then
puts "3"
elsif week == "Thursday" then
puts "2"
elsif week == "Friday" then
puts "1"
end
| true |
4ac4b7cb42fe973a78a839739927e1a26ef417f8 | Ruby | sarah-mosbah/DataStructuresInRuby | /polytree.rb | UTF-8 | 1,057 | 3.6875 | 4 | [] | no_license | class PolyTreeNode
attr_accessor :parent, :children, :value
def initialize(value)
@value=value
@parent=nil
@children=[]
end
def parent=(value)
return if @parent==value
@parent.children.reject! {|node| node==self} unless @parent.nil?
@parent=value
@paren... | true |
d9ef40c3ee07d79bcb07fa84e060df503c07434b | Ruby | nictse500/BEWD_NYC_9_Homework | /_Nicolas_Tse/stocks/runner.rb | UTF-8 | 961 | 3.8125 | 4 | [] | no_license | require_relative 'lib/Portfolio'
def greet
puts "Welcome to your virtual portfolio."
end
def instruction
puts "Commands:"
puts " Add position: [buy|sell] [shares] [stock symbol]"
puts " Current status: status"
puts " Quit: quit"
end
greet
instruction
portfolio = Portfolio.new()
command = []
while command.fi... | true |
7d1b7951eebc9a58a7dfc13b975dea0dbca2d702 | Ruby | NSHipster/nshipster.com | /_plugins/extended-date-filter.rb | UTF-8 | 2,302 | 3.046875 | 3 | [
"MIT",
"CC-BY-NC-4.0"
] | permissive | # frozen_string_literal: true
require 'time'
module Jekyll
module ExtendedDateFilter
# Reformat a date using Ruby's core Time#strftime( string ) -> string
# with additional replacements.
#
# %a - The abbreviated weekday name (``Sun'')
# %A - The full weekday name (``Sunday'')
# %b - Th... | true |
0a7afde3cc75f25ce20c52efc4795568afa0fa30 | Ruby | notmarkmiranda/nfl_suicide_league | /app/models/league_creator.rb | UTF-8 | 269 | 2.5625 | 3 | [] | no_license | class LeagueCreator
attr_reader :league, :user
def initialize(league, user)
@league = league
@user = user
end
def save
if league.save
league.user_leagues.create(user_id: user.id, role: 1)
return true
end
return false
end
end
| true |
b181c8b9bf547131203ca04f8f2b3b9a8fedd0e2 | Ruby | fuadsaud/bis | /lib/bis.rb | UTF-8 | 3,743 | 3.4375 | 3 | [
"MIT"
] | permissive | require 'bis/conversion'
require 'bis/version'
class Bis
include Comparable
include Enumerable
def self.from_enum(enum)
from_string(enum.join)
end
def self.from_string(string)
Bis.new(string.size, value: string.to_i(2))
end
attr_reader :size
alias_method :length, :size
# Future versions o... | true |
75a2a8b48b40941c114355f8ebe0da778b2a5004 | Ruby | Fiveolioo/my-collect-onl01-seng-pt-050420 | /lib/my_collect.rb | UTF-8 | 193 | 3.015625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def my_collect(languages)
counter = 0
collection = []
while counter < languages.length
collection << yield(languages[counter])
counter += 1
end
collection
end
| true |
cf1f09aae80ebe73abb913c5424fa5ba84d3ac16 | Ruby | RossAllenBell/adhoc-slcsp | /slcsp.rb | UTF-8 | 1,213 | 2.75 | 3 | [] | no_license | require 'csv'
require './zipcode_record'
require './plan_record'
require './slcsp_record'
def main
zips_filename = ARGV[0] || fail('expecting: [zips filename] [plans filename] [slcsp filename]')
plans_filename = ARGV[1] || fail('expecting: [zips filename] [plans filename] [slcsp filename]')
slcsp_filename = ARG... | true |
928659d2e618c30dfbd548d7d84f92410efaffe6 | Ruby | fascox/RubyPoker | /lib/Hand.rb | UTF-8 | 1,139 | 3.5 | 4 | [] | no_license | require_relative 'Card'
require_relative 'PokerEngine'
class Hand
attr_accessor :hand, :rank, :rank_score, :rank_desc
def initialize
@rules_engine = PokerEngine.instance
@hand = []
end
def build_from_string(string_hand)
@hand = []
cards_on_hand = string_hand.split
cards_on_hand.each do |o|... | true |
4d43d691f376545ad3d2b3cce5fc15fadad7e80e | Ruby | batteries76/language-tree-react-frontend | /utils/test_path_builder.rb | UTF-8 | 1,618 | 3.09375 | 3 | [] | no_license | tree = {
name: "a",
children: [
{
name: "b",
children: []
},
{
name: "c",
children: [
{
name: "e",
children: []
},
{
name: "f",
... | true |
c55997fbefd4b75049376f244faf0bcbd9fdc6ee | Ruby | danrice92/sep-assignments | /02-algorithms/6-improving-complexity/improving_complexity_version_three.rb | UTF-8 | 1,052 | 4.09375 | 4 | [] | no_license | # Create a version that improves the space complexity. Put the solution in a file named improving_complexity_version_three.rb.
# I attempted to improve the space complexity by using a space-efficient while loop and deleting elements that had already been sorted rather than keeping them in array that would take up more... | true |
cdc456d7d56cb730e1bbc331504c45e219e17ae2 | Ruby | johnsonchmatc/mad_libs_2017_fall | /app/models/bus_stop.rb | UTF-8 | 185 | 3.015625 | 3 | [] | no_license | class BusStop
attr_accessor :stop_id, :route, :lat, :lon
def initialize(stop_id, route, lat, lon)
@stop_id = stop_id
@route = route
@lat = lat
@lon = lon
end
end
| true |
0e2731bdf358ea64b374f41f6dbbc3fc788c1e9d | Ruby | jwpincus/m4-final-starter | /spec/features/mark_as_read_spec.rb | UTF-8 | 1,513 | 2.65625 | 3 | [] | no_license | require "rails_helper"
RSpec.describe "can mark links as read", :js => :true do
before(:each) do
user = create(:user)
allow_any_instance_of(ApplicationController).to receive(:current_user).and_return(user)
@link = Link.create(url:"https://turing.io", title:"Turing")
user.links << @link
end
scenar... | true |
75fa205850bbb3538b9fde297e97b785936ad99d | Ruby | YuukiMAEDA/AtCoder | /Ruby/ABC/B/Palace.rb | UTF-8 | 182 | 2.75 | 3 | [] | no_license | n=gets.to_i
t,a=gets.split.map(&:to_i)
h=gets.split.map(&:to_i)
min,mini=0
h.each_with_index{|hn,i|
tem=(a-t+0.006*hn).abs
if i==0||tem<min then min=tem;mini=i+1 end
}
puts mini
| true |
b0930404d28a3a4e1894b721ea5955844de41aab | Ruby | noma4i/telegrammer | /lib/telegrammer/data_types/voice.rb | UTF-8 | 614 | 2.609375 | 3 | [
"MIT"
] | permissive | module Telegrammer
module DataTypes
# Telegram Voice data type
#
# @attr [String] file_id Unique file identifier
# @attr [Integer] duration Duration of the audio in seconds as defined by sender
# @attr [String] mime_type Optional. Mime type of a file as defined by sender
# @attr [String] file_... | true |
cc040f018805bd22486e150bc0e0771f39e15e45 | Ruby | kchu17/Divvy | /backend/routes/users.rb | UTF-8 | 999 | 2.546875 | 3 | [] | no_license | require_relative 'util'
require_relative '../classes/user'
require_relative '../classes/group'
require 'sinatra'
require 'sinatra/json'
def sanitize_user user
user = user.to_h
user['sanitized'] = true;
# user.delete 'password'
# user.delete 'salt'
user
end
get '/users/:id' do
user = User::from_id(params['id']) ... | true |
1820ed7d2f502224ee9727fbfde95acc36902e65 | Ruby | slbccfl/Ironhack | /Week2/bloginator/spec/blog_spec.rb | UTF-8 | 1,078 | 2.90625 | 3 | [] | no_license | # spec/blog_spec.rb
require_relative "../lib/blog.rb"
require_relative "../lib/post.rb"
RSpec.describe "Blog object tests" do
describe "create a blog" do
it "creates a blog and initializes posts as an empty array" do
test_blog = Blog.new
expect(test_blog.posts).to eq([])
end
it "can add a post to the b... | true |
40c82fbecf8327de02357965dabf2648af40dc21 | Ruby | m-mrcr/pantry_03 | /test/recipe_test.rb | UTF-8 | 957 | 3.171875 | 3 | [] | no_license | require 'minitest/autorun'
require 'minitest/pride'
require './lib/ingredient'
require './lib/recipe'
class RecipeTest < MiniTest::Test
def setup
@bread = Ingredient.new("bread", "slices", 120)
@recipe = Recipe.new("Peanut Butter & Jelly")
end
def test_it_exists
assert_instance_of Recipe, @recipe
... | true |
d541de26b07bb25e69286c29be89ca6eddb568ca | Ruby | robinleoknauth/aa_prep | /lib/02_calculator.rb | UTF-8 | 276 | 3.65625 | 4 | [] | no_license | def add(a, b)
a + b
end
def subtract(a, b)
a - b
end
def multiply(a, b)
a * b
end
def divide(a, b)
a / b
end
def power(a, b)
a ** b
end
def factorial(n)
return 1 if n == 0
n * factorial(n - 1)
end
def sum(arr)
return 0 if arr.empty?
arr.reduce(:+)
end
| true |
d729a04b07dc87da05b52fb5714771a7a3f45a3b | Ruby | sumajirou/ProjectEuler | /p080.rb | UTF-8 | 246 | 2.984375 | 3 | [] | no_license | require 'BigDecimal'
sum = 0
1.upto(100) do |n|
next if n == Math.sqrt(n).floor**2
sqrtn = BigDecimal(n).sqrt(100)
sum += sqrtn.to_s[2..101].chars.map(&:to_i).sum
end
p sum
# 40886
# [Done] exited with code=0 in 0.521 seconds
| true |
69c4d7bbfda618453f742ca844f2568713dad074 | Ruby | scottsek/learn_to_program | /PreCourse/AskQuestion.rb | UTF-8 | 340 | 3.421875 | 3 | [] | no_license | def ask question
while true
puts question
reply = gets.chomp.downcase
if (reply == 'yes' || reply == 'no')
if reply == 'yes'
true
return
else
false
return
end
break
else
puts 'Please answer "yes" or "no".'
end
end # This is what we return (true or false).
end
puts a... | true |
11ffafff295e1e08bedb24b929e9d82f748cb5d4 | Ruby | DouglasAllen/Learning_Ruby-book-code | /ch01/matz_24.rb | UTF-8 | 93 | 3.078125 | 3 | [] | no_license | #!/usr/bin/env ruby
def hello
yield
end
hello { puts "Hello, Matz!" } # => Hello, Matz!
| true |
2f91faba29c066a402611df4a2194d4e7c651222 | Ruby | colorbox/AtCoderLog | /abc/105/d.rb | UTF-8 | 343 | 2.84375 | 3 | [] | no_license | n, m = gets.strip.split.map(&:to_i)
a = gets.strip.split.map {|e| e.to_i%m }
m_a = [a.first]
(1...n).each do |i|
m_a[i] = (m_a[i-1]+a[i])%m
end
numbers = m_a.group_by(&:itself)
result=0
numbers.each do |_, arr|
c = arr.length
next if c<2
result += c*(c-1)/2
#p result
end
result += m_a.count(&:zero?)
#p"--... | true |
4f8ab38d9af0728063f53f06347dce7b4d9345e3 | Ruby | ga-wolf/WDI12_Homework | /TimothyTsui/week_05/games/app/controllers/magic_eight_ball_controller.rb | UTF-8 | 459 | 2.515625 | 3 | [] | no_license | class MagicEightBallController < ApplicationController
def question
end
def answer
@question = params[:question]
answers = ['It is certain', 'It is decidedly so', 'Without a doubt', 'Signs point to yes', 'Yes', 'Outlook good', 'Most likely', 'As I see it, yes', 'You may rely on it', 'Yes, definitely', "D... | true |
62ffc7875f3f79fba99edaad5cf0a8699b11eff7 | Ruby | seokhyungan/lotto_recommend | /app/controllers/home_controller.rb | UTF-8 | 1,776 | 2.921875 | 3 | [] | no_license | require "nokogiri"
require "open-uri"
class HomeController < ApplicationController
$lotto=(1..45).to_a.sample(7).sort
def index
#숫자 랜덤으로 출력 6자리
@lotto = $lotto
end
def numberCheck
#이번주 번호 파싱
url = "http://nlotto.co.kr/gameResult.do?me... | true |
13910ef86e84f6da7267876cdce31619e530fc1f | Ruby | Franerial/Thinknetica_Ruby_Base-Railway | /lesson_8/main.rb | UTF-8 | 13,062 | 3.484375 | 3 | [] | no_license | require_relative "station"
require_relative "route"
require_relative "train"
require_relative "passenger_train"
require_relative "cargo_train"
require_relative "wagon"
require_relative "passenger_wagon"
require_relative "cargo_wagon"
require_relative "exeption_classes"
class Interface
private
attr_accessor :train... | true |
bb46f8d45731b67add59826ff7be7e3e7a685357 | Ruby | adoan91/essential-ruby | /loop_each02.rb | UTF-8 | 180 | 3.796875 | 4 | [] | no_license | list = []
count = 1
while count <= 5
print "Enter a name: "
name = gets.chomp
count += 1
list << name
end
new_list = list.sort
new_list.each do |name|
puts "Hi " + name
end | true |
05b12703d3a36584331c09e7ed307d0a4b94a272 | Ruby | kkelleey/exercism | /ruby/bowling/bowling.rb | UTF-8 | 2,538 | 3.390625 | 3 | [] | no_license | require 'pry'
class Game
def initialize
@current_frame = Frame.new(0)
@finished_frames = []
end
def roll(pins)
raise 'Pins must have a value from 0 to 10' unless pins.between?(0, 10)
raise 'Should not be able to roll after game is over' if game_over?
add_roll(pins)
end
def score
rai... | true |
196770bb5cf53ef05c9a7f925e9c8b84102b4174 | Ruby | pranavtrivedi1993/api_server | /app/models/user.rb | UTF-8 | 446 | 2.71875 | 3 | [] | no_license | class User < ApplicationRecord
has_secure_password
# Validations
validates :first_name, length: { minimum: 2 }, allow_nil: true, allow_blank: true
validates :last_name, length: { minimum: 2 }, allow_nil: true, allow_blank: true
validates :email, presence: true, uniqueness: { case_sensitive: false }
# Inst... | true |
94eb58d47b3b4e34c6c2da84fda08a74d5959190 | Ruby | RickWayne/heartbeat | /Email.rb | UTF-8 | 2,423 | 2.65625 | 3 | [] | no_license | #!/usr/bin/env ruby
# Email.rb
# Handle email parts of heartbeat
require 'net/pop'
require 'net/smtp'
require 'rubygems'
require 'bundler/setup'
require 'mailfactory'
class EmailHeaderChecker
attr_reader :found
attr_writer :verbose
def initialize(server,account='fewayne',pw='Schn0krd',verbosity=false)... | true |
f4359e87dbde19213035f8f3d0734561fb30b63e | Ruby | srobert1953/introduction-to-programming | /variables/variable_scope.rb | UTF-8 | 849 | 4.09375 | 4 | [] | no_license | # Variable can be placed in multiple places in the program and this can be refered as a scope of variable
# !!! If the variable is placed inside a block of code, it is not accesible outside of the block !!!
# But if the variable is created outside of some block, it is accessible inside of any block.
a = 3
3.times do ... | true |
c35972cf4f82a9ccd48977a792bee3508327a563 | Ruby | cpoirier/schemaform | /lib/schemaform/language/schema_definition.rb | UTF-8 | 2,704 | 2.546875 | 3 | [
"Apache-2.0"
] | permissive | #!/usr/bin/env ruby
# =============================================================================================
# Schemaform
# A DSL giving the power of spreadsheets in a relational setting.
#
# [Website] http://schemaform.org
# [Copyright] Copyright 2004-2012 Chris Poirier
# [License] Licensed under the Apache... | true |
338ef1829e79e951549bc5f103d19f6bd9f9de8c | Ruby | semyonovsergey/int-brosayZavod | /lesson 8/eachDemo.rb | WINDOWS-1252 | 151 | 3.25 | 3 | [] | no_license | # encoding: cp866
while true
print ": "
a = gets
print ": "
b = gets
(a...b).each do |x|
puts x
end
puts "====="
end
| true |
869e45fc96dc9ff49d61efcf257e73998b2417c3 | Ruby | lucasDechenier/study-ruby-rails | /modulo_02/06_hashs.rb | UTF-8 | 176 | 3.65625 | 4 | [] | no_license | # Hash é uma lista do tipo chave => valor
# Determinanos qual vai ser a chave, diferente de um array que é fixo
h = {"a" => "Lucas", "r" => "rails"}
puts h["a"]
puts h["r"] | true |
ef382f9367b2a2b98ed0d264e18f37a3018c9c5b | Ruby | oahtpham/keys-of-hash-prework | /lib/keys_of_hash.rb | UTF-8 | 242 | 3.265625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Hash
def keys_of(*arguments)
array = arguments
new_array = []
array.each do |arg|
self.each do |key, value|
if arg == value
new_array.push(key)
end
end
end
new_array
end
end
| true |
50efaca3f2f2092634184609c002c9450e6efc04 | Ruby | todddrinkwater/ruby_hangman | /brute_force/hangman.rb | UTF-8 | 3,069 | 3.921875 | 4 | [] | no_license | def admin_input
print "ADMIN: Please enter your choosen word:"
hangman_word = gets.chomp
letters_remaining = hangman_word.length
return hangman_word
end
def check_input_type(word)
#also check string length is greater than 0
regex_comparison = /[\d\s_\W]+/
type_check = word.scan(regex_comparison)
if ty... | true |
1d4f35a62a428d6c47ba47667c60be22d7b18ccc | Ruby | loganmeetsworld/advent-of-code | /2015/ruby/advent20.rb | UTF-8 | 705 | 3.71875 | 4 | [] | no_license | max_presents = 29000000
div_presents = max_presents / 11
decimal_presents = max_presents / 10
max_houses = 50
house_hash = Hash.new(0)
lowest_number = nil
house_hash_2 = Hash.new(0)
lowest_number_2 = nil
1.upto(decimal_presents) do |e|
1.upto(decimal_presents / e) do |n|
house_hash[n * e] += e * 10
end
end
ho... | true |
df226e4fab290b4d3ba768f2a67619ae64d84fdb | Ruby | RobinWagner/PrepCourse-Book1 | /Chapter8_Files/exercise1.rb | UTF-8 | 435 | 3.359375 | 3 | [] | no_license | # Exercise 1
my_file = File.new("simple_file.txt", "w+")
my_file.close
File.open("simple_file.txt", "w") { |file| file.write("adding first line of text") }
sample = File.open("simple_file.txt", "w+")
sample.puts("another example of writing to a file.")
sample.close
simple = File.read("simple_file.txt")
original = F... | true |
813f2adc95a2fae58c488fb61c3613c84f06246e | Ruby | smileyuichi/gyakuten_Ruby_answer | /q9.rb | UTF-8 | 377 | 3.546875 | 4 | [] | no_license | # 次の配列を用いて,期待通りの出力結果になるようにコードを書いて下さい。
names = ["田中", "佐藤", "佐々木", "高橋"]
names.each.with_index(1) do |name,i|
puts "会員No.#{i} #{name}さん"
end
# 期待結果
# ```
# 会員No.1 田中さん
# 会員No.2 佐藤さん
# 会員No.3 佐々木さん
# 会員No.4 高橋さん
# ``` | true |
373999d728f84185942ec759dc3b757b93301692 | Ruby | johnvoon/launch_school | /exercise_sets_for_101_109/advanced1.rb/select_fibonacci.rb | UTF-8 | 530 | 3.828125 | 4 | [
"MIT"
] | permissive | def return_fibonaccis(array)
fibonacci_array = [1, 1]
first, last = [1, 1]
fibonacci = 0
loop do
fibonacci = first + last
break if fibonacci >= array.length - 1
fibonacci_array << fibonacci
first = last
last = fibonacci
end
fibonacci_array
end
def select_fibonacci(array)
array.sele... | true |
573a01fed36e83e4a24838954765991935d473d6 | Ruby | learn-academy-2021-bravo/week-4-assessment-Vivean28 | /code_challenges.rb | UTF-8 | 3,385 | 4.4375 | 4 | [] | no_license | # ASSESSMENT 4: Ruby Coding Practical Questions
# MINASWAN ✌️
# --------------------1) Create a method that takes in an array of words and a letter and returns all the words that contain that particular letter.
# I need to create a method called my_letters
# that takes in an array of words
# Later, my method needs t... | true |
be21cf51ccdcf77b91ecae87eee74d736feb8a3d | Ruby | kevinrood/simple_record | /lib/simple_record/attributes.rb | UTF-8 | 8,544 | 2.640625 | 3 | [] | no_license | module SimpleRecord
module Attributes
# For all things related to defining attributes.
def self.included(base)
#puts 'Callbacks included in ' + base.inspect
=begin
instance_eval <<-endofeval
def self.defined_attributes
#puts 'class defined_attributes'
... | true |
632f19d97d8bc2e8156ab529b267c45aa16f107a | Ruby | MihaiLiviuCojocar/ruby-practice | /sort_string.rb | UTF-8 | 185 | 3.5 | 4 | [] | no_license |
def sort_string(string)
# arr = []
# for i in (0..string.length-1)
# arr << string.slice(i)
# end
p string.chars.sort.join
# print arr.sort.join
end
sort_string('gergerge')
| true |
a781da421021030e49e3e70261f3f59109045804 | Ruby | NNWaller/parrot-ruby-cb-000 | /parrot.rb | UTF-8 | 88 | 2.859375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def parrot (someString = "Squawk!")
puts "#{someString}"
return "#{someString}"
end
| true |
92038d49614efbb5e4936e5eb579e5e7bcad7762 | Ruby | beachio/hammer-gem | /lib/hammer/parsers/modules/optimizer.rb | UTF-8 | 824 | 3.3125 | 3 | [
"MIT"
] | permissive | # Optimizer module mixin. This goes directly into Parser as all parsers can be optimized.
# This causes an optimize(text) method to be called before parse(). If the parse() method has branches in it for optimizing anyway, you may not need an optimize() method.
# Usage:
# class Thing
# def optimize(text)
# return ... | true |
6b25d205f86018cb38bf99e825054aaa2355eefc | Ruby | leftees/battleship | /lib/ship.rb | UTF-8 | 1,637 | 3.109375 | 3 | [] | no_license | class Ship
attr_reader :location, :type, :xsize
def initialize(matrix, options)
@xsize = options[:size]
@type = options[:type]
@matrix = matrix
@location = []
end
def build
begin
destroy
ship_len = @xsize
mask = []
# random start point
begin
x... | true |
eb36fac29bcd56b140691a1e39bba903728f743a | Ruby | SirRiixz/exercises | /examples/alphabet.rb | UTF-8 | 171 | 3.546875 | 4 | [] | no_license | alphabet = ["a","b","c","d","e","f","g","h","i","j","k","l","m","t","u","v","w","x","y"]
alphabet.push("z")
for letters in alphabet
puts "This letter is #{letters}"
end
| true |
d4c53801ecc491481555fddaf2d40212995090f3 | Ruby | Lakshadeep/MusicSearch | /controllers/Track.rb | UTF-8 | 311 | 2.59375 | 3 | [] | no_license | require 'rest-client'
require 'uri'
class Track
attr_accessor :name,:album,:artist,:wiki,:id,:img_link,:duration
def initialize(name,album,artist,wiki,img_link,duration,id)
@name = name
@album = album
@artist = artist
@wiki = wiki
@img_link = img_link
@id = id
@duration = duration
end
end
| true |
f997bd4ca539440fa2506a592b1efdbfe49799a6 | Ruby | arpodol/ruby_small_problems | /easy7/capitalize_words.rb | UTF-8 | 1,077 | 4 | 4 | [] | no_license | def word_cap(string)
string_array = string.split(' ')
string_array.map! {|word| word.capitalize}
string_array.join(' ')
end
p word_cap('four score and seven') == 'Four Score And Seven'
p word_cap('the javaScript language') == 'The Javascript Language'
p word_cap('this is a "quoted" word') == 'This Is A "quote... | true |
f9d11206d2f121b924fc07b7351ce11f76eb7804 | Ruby | bulletproofMUG/learn_ruby | /05_book_titles/book.rb | UTF-8 | 415 | 3.5 | 4 | [] | no_license | class Book
attr_reader :title
def title=(input)
argv = input.split.map.with_index do |x, i|
if x =~ /[0-9]/
x
elsif i == 0
x.capitalize!
elsif x == "i"
x.capitalize!
elsif %w(the a an and in of).include?(x)
x
else... | true |
c2855e9366e4ad1337572705459fba7f16f9dbd5 | Ruby | ZuhairS/Algorithms-and-Data-Structures | /Assortment/Search_element_in_sorted_rotated_arr.rb | UTF-8 | 1,142 | 3.515625 | 4 | [] | no_license | def search_rotated_sorted_arr(arr, target)
return nil if arr.empty?
mid_idx = arr.length / 2
if arr[mid_idx] == target
return mid_idx
elsif arr.first < arr[mid_idx]
if target < arr[mid_idx] && target >= arr.first
search_rotated_sorted_arr(arr[0...mid_idx], target)
else
rec = search_rot... | true |
1af8a2a4c72dc70136a191d8f192cf551e034965 | Ruby | GreyCat/chie | /spec/recordset_spec.rb | UTF-8 | 1,841 | 2.671875 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
require 'mysql2'
describe RecordSet do
describe '#total_pages' do
it 'should return single page if not pagination requested' do
rs = RecordSet.new(nil, {})
expect(rs.total_pages).to eq(1)
end
it 'should return 1 page if we have less than one page of records' do
r... | true |
c329f02f0f2ba853f2524c91e6e2220b5df7a18a | Ruby | ipresilia/store | /store.rb | UTF-8 | 1,915 | 3.78125 | 4 | [] | no_license | # Helper Methods
def print_divider
puts "*" * 40
puts "\n"
end
# Shopping Cart
@shopping_cart = []
# List of Products
@products = [
{ reference_number: 123, name: "MacBook Air", price: 1200 },
{ reference_number: 124, name: "MacBook Pro", price: 2000 },
{ reference_number: 125, name: "Apple Watch", price: 700 ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.