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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
9013a9519a297a07b265ab79a9cf1f24710f16a8 | Ruby | JustinData/GA-WDI-Work | /w03/d03/Ann/user.rb | UTF-8 | 486 | 2.9375 | 3 | [] | no_license | class User
def initialize(id, name, address, email)
@id = id
@name = Faker::Name.name
@street_address = Faker::Address.street_address
@email_address = Faker::Internet.email
end
def name
@name
end
def street_address
@street_address
end
def email_address
@email_address ... | true |
62ac3b366235f69454f36dab69d6febfccc6c785 | Ruby | george-carlin/abroaders | /spec/support/application_survey_macros.rb | UTF-8 | 2,388 | 2.609375 | 3 | [] | no_license | module ApplicationSurveyMacros
# The apply 'button' is actually a link styled like a button
def self.included(base)
base.include DatepickerMacros
base.extend ClassMethods
base.instance_eval do
# some of these buttons have different text for different survey stages,
# so you'll have to overr... | true |
c82239eae70445905bc0703232dd3abc2fdb1095 | Ruby | bmwest/P.E. | /ruby/sum_square_difference.rb | UTF-8 | 375 | 3.84375 | 4 | [] | no_license | def sum_of_squares(x, y)
num = (x..y).to_a
sum = 0
num.each do |n|
sum += (n ** 2)
end
sum
end
def square_of_sum(x, y)
num = (x..y).to_a
sum = 0
num.each do |n|
sum += n
end
sum ** 2
end
x = 1
y = 100
sosq = sum_of_squares(x, y)
sosu = square_of_sum(x, y)
sum_square_difference = sosu - sos... | true |
0d8e37f400678db1298996c251fa7e14a7900b26 | Ruby | GrowMoi/moi | /lib/neo_importer/neuron_node.rb | UTF-8 | 2,081 | 2.71875 | 3 | [
"MIT"
] | permissive | class NeoImporter
class NeuronNode
attr_reader :node, :parent
def initialize(node, parent=nil)
@node = node
@parent = parent
end
def create!
create_neuron!.tap do |neuron|
levels.each do |level|
kinds.each do |kind|
attributes = content_attributes_for(... | true |
4df310c460a07305aa9d676e94bf1c1afc52f471 | Ruby | rab/sport.db | /sportdb-config/lib/sportdb/config/config.rb | UTF-8 | 2,896 | 2.609375 | 3 | [
"LicenseRef-scancode-public-domain",
"CC0-1.0"
] | permissive | # encoding: utf-8
module SportDb
module Import
class Configuration
##
## todo: allow configure of countries_dir like clubs_dir
## "fallback" and use a default built-in world/countries.txt
## todo/check: rename to country_mappings/index - why? why not?
## or countries_by_code or countries_b... | true |
7f5c96d65881ce31b97a031d73ece5faaf6890ec | Ruby | rlister/auger | /lib/auger/config.rb | UTF-8 | 338 | 2.578125 | 3 | [
"MIT"
] | permissive | module Auger
class Config
attr_accessor :projects
def self.load(filename)
config = new
config.instance_eval(File.read(filename), filename)
config
end
def initialize
@projects = []
self
end
def project(name, &block)
@projects << Project.load(name, &block)
... | true |
12a69a4d264125eb95a5f3ec9860833d7c141840 | Ruby | shaunakv1/masters_course_work | /cps/ardunio/app/jobs/collect_data.rb | UTF-8 | 1,976 | 3.421875 | 3 | [] | no_license | require 'reading'
require 'serialport'
#params for serial port
port_str = "COM4" #may be different for you
baud_rate = 57600
data_bits = 8
stop_bits = 1
parity = SerialPort::NONE
@@sp = SerialPort.new(port_str, baud_rate, data_bits, stop_bits, parity)
def read_sp
reading = ""
check_ti... | true |
28960ec772ee8c1a9221492c3b978d557dd5a721 | Ruby | markjeee/activefacts | /lib/activefacts/cql/compiler/reading.rb | UTF-8 | 40,842 | 2.5625 | 3 | [
"Zlib"
] | permissive | module ActiveFacts
module CQL
class Compiler < ActiveFacts::CQL::Parser
class Reading
attr_reader :phrases
attr_accessor :qualifiers, :context_note
attr_reader :fact_type, :reading, :role_sequence # These are the Metamodel objects
attr_reader :side_effects
attr_wr... | true |
73a571791a58f166c5c323100fa1bd458d80071f | Ruby | DannyBen/jossh | /lib/jossh/bin_handler.rb | UTF-8 | 2,805 | 2.578125 | 3 | [
"MIT"
] | permissive | require 'etc'
require 'docopt'
require 'colsole'
require 'fileutils'
module Jossh
class BinHandler
include Colsole
def handle(args)
begin
execute Docopt::docopt(doc, argv: args)
rescue Docopt::Exit => e
puts e.message
end
end
private
def execute(args)
... | true |
447f8ca5645a3b6eebefc51e48fb6eb13e9c75ca | Ruby | kharumax/rails-realtime-talkapp | /app/models/user.rb | UTF-8 | 777 | 2.703125 | 3 | [] | no_license | class User < ApplicationRecord
validates :name,presence: true,length: {minimum: 3,maximum: 20}
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
validates :email,presence: true,format: {with: VALID_EMAIL_REGEX},uniqueness: true
validates :password,presence: true,length: {minimum: 6}
has_secure_passwo... | true |
d90b81afcd03efb99fbf33652261d691f0d62011 | Ruby | mmpatel/global_settings | /global_setting.rb | UTF-8 | 802 | 2.75 | 3 | [] | no_license | class GlobalSetting < ActiveRecord::Base
validates :key_name, uniqueness: true, presence: true
validate :has_valid_key_type
def value=(obj)
self.key_type = obj.class.to_s
write_attribute(:key_value, obj)
@key_value = obj
end
def value
return @key_value unless @key_value.nil?
@key_value... | true |
c17d92ef04d0e0de2b4b6348819aadde71c31635 | Ruby | senthilkumarv/retail_analytics | /lib/simple_customer.rb | UTF-8 | 4,828 | 2.625 | 3 | [] | no_license | require 'set'
require 'date'
require 'sqlite3'
require './database'
def p(product, quantity)
{:product => product, :quantity => quantity}
end
def by_description(name, db)
row = db.get_first_row("select * from spree_products where name='#{name}'")
product = {:id => row[0], :name => row[1]}
variant = db.get_first_r... | true |
cea565af6b22c5b6dd27c1a74a4d3f6e9499c933 | Ruby | mcgain/computationbook | /the_meaning_of_programs/big_step/add.rb | UTF-8 | 193 | 2.859375 | 3 | [
"CC0-1.0"
] | permissive | require_relative '../syntax/add'
require_relative 'number'
class Add
def evaluate(environment)
Number.new(left.evaluate(environment).value + right.evaluate(environment).value)
end
end
| true |
329c1db8e7315ffd21f32cab33f665fe25b6fa76 | Ruby | AshleyRapone/programming_foundations | /small_problems_exercises/Easy7Q5.rb | UTF-8 | 1,938 | 4.65625 | 5 | [] | no_license | # Write a method that takes a String as an argument, and returns a new String that contains
# the original value using a staggered capitalization scheme in which every other character is capitalized,
# and the remaining characters are lowercase.
# Characters that are not letters should not be changed, but count as char... | true |
d331de875c215560bd850a503169fe6162f8e879 | Ruby | elizabrock/NSS-futureperfect-CLI | /app/models/project.rb | UTF-8 | 1,362 | 2.59375 | 3 | [
"MIT"
] | permissive | class Project < ActiveRecord::Base
validates_presence_of :name
validates_uniqueness_of :name, message: "must be unique"
default_scope order("completed_at ASC, last_worked_at ASC, id ASC")
scope :finished, where("completed_at IS NOT NULL")
scope :unfinished, where("completed_at IS NULL")
scope :currentl... | true |
c64fb52f5897790abcbd50dd74d177618d92c38a | Ruby | Agould94/Crypto_prices_app | /lib/User/portfolio/Portfolio.rb | UTF-8 | 2,053 | 3.484375 | 3 | [
"MIT"
] | permissive | class Portfolio
attr_accessor :name, :coin_value, :total_value, :num, :user
@@all = []
def initialize(currency, num, name = nil)
@name = currency.name
@coin_value = currency.price
@num = num
@user = User.find_by_username(name)
@@all<<self
end
def self.all
... | true |
abf91cd940691c83ee61f0696d41cf8dcbcbf92c | Ruby | mm86/Ruby101 | /Hashes/ex3.rb | UTF-8 | 166 | 3.21875 | 3 | [] | no_license | years = { "a" => 1981, "b" => 1876 }
years.keys.each { |key| puts key }
years.values.each { |val| puts val }
years.each do |key, value|
puts "#{key}, #{value}"
end | true |
39143d6e7d0813257f1aa6aa718550154dddfda4 | Ruby | michaelphines/chirb-mastermind | /spec/mastermind/game_starting_spec.rb | UTF-8 | 1,230 | 2.546875 | 3 | [] | no_license | require File.join(File.dirname(__FILE__), "/../spec_helper")
module Mastermind
describe Game do
context "starting up" do
before(:each) do
@messenger = mock("messenger").as_null_object
@game = Game.new(@messenger)
end
describe "#start" do
it "should generate a rand... | true |
ad916ca5a65d710aec6fe3801d56ca6722b47695 | Ruby | nicholaslemay/adventofcode2016 | /day1/part_two/hq_distance_tracker.rb | UTF-8 | 1,062 | 3.25 | 3 | [] | no_license | class HqDistanceTracker
def initialize
@current_direction = :north
@x_axis_position = 0
@y_axis_position = 0
@visited_coordinates = []
end
def distance_from_hq(moves_to_perform)
move = moves_to_perform.first
@current_direction = move.target_direction_after_facing(@current_direction)
... | true |
fcc1cc523eb2a5fdc4d96d3f7347e692c0966bad | Ruby | marcusrussi/yo-tools | /process.rb | UTF-8 | 992 | 2.71875 | 3 | [] | no_license | system('rm -f email\*; rm -f yale\*')
line = ""
emails = []
yale_emails = []
bad_emails = []
f = File.open('bad_emails')
while true
line = f.gets
break if line.nil?
b = line.split(', ')
b.each do |e|
bad_emails << e.strip
end
end
f = File.open('bad_emails_line', 'w')
bad_emails.each do |e|
f.puts e
en... | true |
94935a0699507130c2d07ca35c03cfba5d2c56b6 | Ruby | hochardga/DecksterRails | /lib/application/geo.rb | UTF-8 | 240 | 3.3125 | 3 | [
"MIT"
] | permissive | class Geo
attr_accessor :lat, :long
def initialize lat, long
@lat = lat
@long = long
end
def self.parse value
values = value.split ','
Geo.new values[0], values[1]
end
def to_s
"#{@lat},#{@long}"
end
end | true |
b494042bfdc5dd10470f39283dc494a559d8d268 | Ruby | nathanworden/100-Programming-Back-end-Prep | /100 Ruby Basics/13. Debugging/01. Reading Error Messages.rb | UTF-8 | 1,792 | 4.4375 | 4 | [] | no_license | # Reading Error Messages
# You come across the following code. What errors does it raise for the given examples and what exactly do the error messages mean?
def find_first_nonzero_among(numbers)
numbers.each do |n|
return n if n.nonzero?
end
end
# # Examples
find_first_nonzero_among(0, 0, 1, 0, 2, 0)
find_fi... | true |
41b200967af83b6cb1162c4a35168ea455714667 | Ruby | shkfnly/appacademy | /w2d2/rubychess/lib/chess.rb | UTF-8 | 1,186 | 2.765625 | 3 | [
"MIT"
] | permissive | require 'colorize'
require 'byebug'
require_relative "./chess/tile.rb"
require_relative "./chess/piece.rb"
require_relative "./chess/board.rb"
require_relative "./chess/pieces/bishop.rb"
require_relative "./chess/pieces/king.rb"
require_relative "./chess/pieces/knight.rb"
require_relative "./chess/pieces/pawn.rb"
requ... | true |
31ea61b72751dd2905d754fc54690378c8093b81 | Ruby | marcbobson2/lessons | /ch10_final/problem3.rb | UTF-8 | 86 | 3.03125 | 3 | [] | no_license | num=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
x_array=num.select {|val| val.odd?}
p x_array
| true |
9878453f35a6feaeb99925666afba58930975198 | Ruby | mach1010/odin | /ruby/data_structures/show_nodes.rb | UTF-8 | 1,167 | 3.25 | 3 | [] | no_license |
def levels(current, parents = [current], level_ary = [[current]])
if parents.compact.empty?
level_ary.pop
return level_ary.map {|x| x.map{|y| y ? y.value.to_s : 'x'}}
end
level = []
parents.each do |parent|
if parent
level << (parent.left ? parent.left : nil)
level << (parent.right ? ... | true |
65e02dd0d728c619c9efc0cace917f3e30c754c1 | Ruby | 7Joe7/TaskManager | /app/modules/data_helper.rb | UTF-8 | 408 | 2.640625 | 3 | [] | no_license | module DataHelper
def load_data(address, klass)
structure = []
JSON.parse(load_file_text(address), {:symbolize_names => true}).each do |name, pars|
structure << klass.new({name: name.to_s}.merge(pars))
end
structure
end
def save_data(data, address)
hash = {}
data.each { |entry| has... | true |
9ede49f8758f16a5614875a85bf14ca18bac54fc | Ruby | jywei/didactic-enigma | /lib/core_ext/datetime.rb | UTF-8 | 103 | 2.703125 | 3 | [] | no_license | class DateTime
def self.mil(modifier = 0)
(now + modifier.seconds).strftime('%Q').to_i
end
end
| true |
63e74d7794ba739f87132d5abb470d0362561e69 | Ruby | bc-luke/panier | /lib/panier/domain/product_service.rb | UTF-8 | 1,499 | 3.15625 | 3 | [
"MIT"
] | permissive | require 'money'
module Panier
module Domain
##
# The product service provides a means of finding and retrieving products
# from the product catalog.
#
# This is an in-memory implementation, useful for testing, which contains
# only the products from the given input data. A real-world implemen... | true |
aed92b8ba449097e5f13af98196e611d81fdf9fe | Ruby | juanriglos/trabajo_final | /app/models/turn.rb | UTF-8 | 1,358 | 2.640625 | 3 | [] | no_license | class Turn < ApplicationRecord
belongs_to :user
has_many :turn_resources
has_many :resources, through: :turn_resources
validates :start_date, presence: true
validates :end_time, presence: true
validate :controlar_que_un_recurso_no_esta_asociado_a_un_turno_en_ese_horario
validate :controlar_fecha_de_fin_... | true |
5cd2e132bebc3b23cd186b6857abfafef164a4a9 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/cs169/800/feature_try/whelper_source/18125.rb | UTF-8 | 251 | 3.15625 | 3 | [] | no_license | def combine_anagrams(words)
word_cat = {}
words.each do |w|
s = w.downcase.split(//).sort
word_cat[s] ? (word_cat[s].push(w)) : (word_cat[s] = [w])
end
result = []
word_cat.each { |cat, wrds| result.push(wrds) }
return result
end
| true |
3545d30567c93db346782b0b13a2c83f75cb76a2 | Ruby | abe196201/fhss | /app/models/transaction.rb | UTF-8 | 193 | 2.546875 | 3 | [] | no_license | class Transaction
# Methods
def self.amount_for_type(type)
case type
when 'monthly' then 3995
when 'monthly_monitoring' then 2000
when 'purchase' then 700
end
end
end
| true |
da6cba8bafa6505f798a08d85b9127f32b877c79 | Ruby | IanDCarroll/workbookExercises | /Learn_Ruby_the_Hard_Way/ex44/ex44e.rb | UTF-8 | 518 | 3.265625 | 3 | [] | no_license | class Hammer
def override
puts "OTHER override()"
end
def implicit
puts "OTHER implicit()"
end
def altered
puts "OTHER altered()"
end
end
class Child
def initialize
@hammer = Hammer.new
end
def implicit
@hammer.implicit
end
def override
puts "CHILD override()"
end
... | true |
6f7237e908be211329248554ef634d36d4a212d1 | Ruby | jhbadger/scripts | /buildOneWayVennCsv | UTF-8 | 1,018 | 2.8125 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'optparse'
require 'ostruct'
require 'Btab'
require 'csv'
opt = OpenStruct.new
o = OptionParser.new
o.banner << " btab [..btab...]"
o.on("-v", "--verbose", "Run verbosely") {opt.verbose = true}
begin
o.parse!
rescue
STDERR << $!.message << "\n"
STDERR << o
exit(1)
end
if (ARGV.size... | true |
71f8eb033c7d5dd1e8402ae7a04545d8177e3a97 | Ruby | TSMMark/homophone | /spec/routing/word_sets_spec.rb | UTF-8 | 2,166 | 2.65625 | 3 | [] | no_license | require 'spec_helper'
describe "short word_set path" do
let(:word_set) do
WordSet.create do |word_set|
word_set.words = %w(wh wha what)
end
end
it "default path helper uses #id" do
expect(word_set_path(word_set)).to eq("/h/#{word_set.id}")
end
it "routes to show" do
expect(:get => "/... | true |
e6331d57afa8d70f57e0b86bb3ed14d9ea1cb826 | Ruby | aidenmendez/sweater-weather | /app/poros/short_forecast.rb | UTF-8 | 184 | 3 | 3 | [] | no_license | class ShortForecast
attr_reader :temperature, :conditions
def initialize(temperature = nil, conditions = nil)
@temperature = temperature
@conditions = conditions
end
end | true |
3ff0c375a4976ef1ff5f5709811a9bd210c21c20 | Ruby | medericgb/16-08-2021 | /post-api/main.rb | UTF-8 | 1,287 | 2.71875 | 3 | [] | no_license | require "rest-client"
require "json"
require "csv"
# Get all posts from remote url
posts_url = "https://jsonplaceholder.typicode.com/posts?_start=0&_limit=20"
comments_url = "https://jsonplaceholder.typicode.com/post/5/comments"
list_comments = Array.new
all_comments = Array.new
comments_array = Array.new
for i in 1... | true |
0ef09c52b31bcaedfae6ef715117c2901e30642d | Ruby | larrytheliquid/rack-client | /lib/rack/client/http.rb | UTF-8 | 1,759 | 2.734375 | 3 | [
"MIT"
] | permissive | require 'net/http'
class Rack::Client::HTTP
def self.call(env)
new(env).run
end
def initialize(env)
@env = env
end
def run
case request.request_method
when "HEAD"
head = Net::HTTP::Head.new(request.path, request_headers)
http.request(head) do |response|
return parse(resp... | true |
d7474ae38fcf758249f9447db1d6eae4121e09ac | Ruby | stuartc/marsbot | /bin/marsbot | UTF-8 | 590 | 2.796875 | 3 | [] | no_license | #!/usr/bin/env ruby
# frozen_string_literal: true
$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/../lib")
require 'marsbot'
input =
if STDIN.tty?
begin
filename = ARGV[-1]
File.read(filename)
rescue Errno::ENOENT
puts("File doesn't exist")
exit(1)
rescue TypeError... | true |
1f1dc12ee97d2f90a0ff25ccad741bb78612ebdd | Ruby | huyphung1602/ddd_example | /app/domains/order_taking/domain_types/unvalidated_order.rb | UTF-8 | 705 | 2.5625 | 3 | [] | no_license | # typed: strict
# Example:
# OrderTaking::DomainTypes::UnvalidatedOrder.new({ id: 1, customer_info: ci, shipping_address: '181 Cao Thang', billing_address: '181 Cao Thang', order_lines: ols})
# ol1 = OrderTaking::DomainTypes::OrderLine.new({ id: 1, order_id: 1, product_code: 'G001', order_quantity: 1.5, price: 0 })
# ... | true |
fe839118c57834b17922968d3b7443912b0bb1eb | Ruby | tommy-russoniello/pantry-buddy | /lib/fdc.rb | UTF-8 | 3,451 | 2.546875 | 3 | [] | no_license | module Fdc
API_HOST = 'api.nal.usda.gov'.freeze
API_KEY = ENV.fetch('FDC_API_KEY')
SEARCH_PATH = '/fdc/v1/foods/search'.freeze
class << self
def get_data_from_upc(upc)
data = send_request(
host: API_HOST,
method: :get,
name: 'UPC lookup',
path: SEARCH_PATH,
que... | true |
90abd42e36f408046b08fdb4ddc43dbd7538fe2a | Ruby | krlawrence/SVG | /generators/svg-manycircles.rb | UTF-8 | 648 | 2.8125 | 3 | [
"Apache-2.0"
] | permissive | puts "<html>"
puts "<head>"
puts "<meta name='description' content='Machine generated SVG using a Ruby script.' />"
puts "<meta name='author' content='Kelvin R. Lawrence' />"
puts "<meta name='created' content='#{Time.now}' />"
puts "</head>"
puts "<body>"
puts"<svg xmlns='http://www.w3.org/2000/svg' version='1.1' widt... | true |
616bd6f878c3305814cffcab789169c050dd175a | Ruby | drabelpdx/Epi_W2_vehicles | /lib/vehicle.rb | UTF-8 | 837 | 3.109375 | 3 | [] | no_license | require('pry')
class Vehicle
@@vehicles = []
define_method(:initialize) do |make, model, year|
@make = make
@model = model
@year = year
@id = @@vehicles.length.+(1)
end
define_method(:make) do
@make
end
define_method(:model) do
@model
end
define_method(:id) do
@id
... | true |
a5cec23cb93d55581e031db8bd0ece68e614e075 | Ruby | allizad/pig_latin | /spec/piglatin_spec.rb | UTF-8 | 769 | 3.078125 | 3 | [
"MIT"
] | permissive |
require "./lib/pig_latin.rb"
# require 'pry-byebug'
describe PigLatin do
before do
@glove = "glove"
@egg = "egg"
@yellow = "yellow"
@rhythm = "rhythm"
@integer = 13
@hash = 'wrong'
@array = [1, 2, 3, 4]
end
# test test test
describe '#translate' do
it 'translates a vowel-st... | true |
509cb830cdef744e695e7b8b5a6e3afb9bfb6e20 | Ruby | milanoid/LRTHW | /ex45/map.rb | UTF-8 | 462 | 3.34375 | 3 | [] | no_license | require_relative 'main_corridor'
require_relative 'bathroom'
require_relative 'death'
class Map
# class variable of type Hash
@@rooms = {
'main_corridor' => MainCorridor.new(),
'bathroom' => Bathroom.new(),
'death' => Death.new()
}
def initialize(start_room)
@start_room = start_room
end
... | true |
2e46fe7d212565c46676186993fdb3eb3144aca5 | Ruby | guorui9016/ruby | /task9.rb | UTF-8 | 515 | 4.3125 | 4 | [] | no_license | # method take 2 argument
# Interchange value of there argment
# - With using 3rd variable
# - Without using 3rd variable
def interchange_with_3rd_variable(a,b)
puts "a = #{a} and b = #{b}"
temp = a
a = b
b = temp
puts "After interchange, a = #{a} and b = #{b}"
end
def interchange_without_3rd_vari... | true |
cc5eec8fe44d459c9a857b1028ef9d3bb40213d0 | Ruby | BenEddy/ruby_golf | /spec/hole_0_spec.rb | UTF-8 | 688 | 2.84375 | 3 | [] | no_license | require "spec_helper"
require "0/hole_0.rb"
describe HoleZero do
describe ".play" do
it "should display the first fibonacci number" do
when_implemented do
expect(HoleZero.play(1)).to eq("1")
end
end
it "should display the second fibonacci numbers" do
when_implemented do
... | true |
ec9a15f951503d2f29dc956abd0975387f4070bb | Ruby | eargollo/Quizzer | /test/test_dictionary.rb | UTF-8 | 3,166 | 2.671875 | 3 | [
"MIT"
] | permissive | require File.dirname(__FILE__) + '/test_helper.rb'
class TestDictionary < Test::Unit::TestCase
DB_FILE = File.dirname(__FILE__) + "/fixtures/temp-dictionary.pstore"
DB_WORDS = [["eins", "one"],
["zwei", "two"],
["drei", "three"],
["vier", "four"],
["fuenf", ... | true |
ec620f9c0fa7a124122584cb2bc4f1d3bfdd2b8d | Ruby | DavidMah/tv_renamer | /spec/data_operations_spec.rb | UTF-8 | 975 | 2.84375 | 3 | [] | no_license | require 'data_operations'
class Obj
include DataOperations
end
describe DataOperations do
before :each do
@obj = Obj.new
end
describe "#find_filename" do
it "should return right away if name isn't taken" do
File.should_receive(:exists?).once.with("39").and_return(false)
@obj.find_filename(... | true |
439683e752f731126a641e21f07e1aba4c8ad3e7 | Ruby | riboseinc/ribose-cli | /spec/acceptance/member_spec.rb | UTF-8 | 2,517 | 2.53125 | 3 | [
"MIT"
] | permissive | require "spec_helper"
RSpec.describe "Space Member" do
describe "list" do
it "retrieves the list of space members" do
command = %w(member list --space-id 123456)
stub_ribose_space_member_list(123456)
output = capture_stdout { Ribose::CLI.start(command) }
expect(output).to match(/| Name ... | true |
afbe4af6aafc9571d0da12b1d46ba8fb22065927 | Ruby | duritong/puppet-hiera | /lib/hiera/scope.rb | UTF-8 | 915 | 2.65625 | 3 | [
"Apache-2.0"
] | permissive | class Hiera
class Scope
attr_reader :real
def initialize(real)
@real = real
end
def [](key)
if key == "calling_class"
ans = @real.resource.name.to_s.downcase
elsif key == "calling_module"
ans = @real.resource.name.... | true |
8e6c795bbdb533c4dac9a121c70636dea092c40a | Ruby | masacheung/Perilous-Procs | /Phase_1.rb | UTF-8 | 6,952 | 4.4375 | 4 | [] | no_license | # some?
# Write a method some? that accepts an array and a block as arguments.
# The method should return a boolean indicating whether or not at least one of the elements of the array
# returns true when given to the block. Solve this using Array#each.
p "----------"
p "some?"
p "----------"
def some?(array, &proc)
... | true |
7a7b5753084deb8e2244333d3e2c0deb5b13f299 | Ruby | pwl-webdev/203_project_ruby_oop | /01_tictactoe/lib/board.rb | UTF-8 | 2,125 | 3.75 | 4 | [] | no_license | class Board
require_relative 'player.rb'
attr_reader :board
def initialize()
@board = [[" ", " "," "],[" ", " "," "],[" ", " "," "]]
end
def reset()
@board = [[" ", " "," "],[" ", " "," "],[" ", " "," "]]
end
def display()
puts " 1 | 2 | 3 "
@board.each_with_index do |x, xi|
print xi+1
x.each_w... | true |
e0e76fdfb468f832f27cf0e87aa287555d769c84 | Ruby | rohan484909/Training | /Ruby Training/TestHase1.rb | UTF-8 | 565 | 3.90625 | 4 | [] | no_license | #declaration of hashes
class Test
student_detail={ 1=>"Rajesh Rai",
2=>"Rakesh Rai",
3=>"Ashi Rai",
4=>"Gulshan Rai"
}#declaration of hash
puts student_detail[3]
puts student_detail[2]
puts student_detail[4]
employee=Hash.new #ano... | true |
d7414d2089c080a382e10cf49432bf1100242e7f | Ruby | semliko/blackjack | /round.rb | UTF-8 | 1,503 | 3.5 | 4 | [] | no_license | class Round
attr_reader :player, :dealer, :players, :winner, :deck, :show_cards, :finish_game
def initialize(player, dealer, deck)
@player = player
@dealer = dealer
@deck = deck
@players = [@player, @dealer]
end
def start
2.times { deal_card_to_player }
2.times { deal_card_to_dealer }
... | true |
c10e69a3600c69ad10f96ad3030e5f40fe73f93c | Ruby | leonimanuel/reverse-each-word-online-web-sp-000 | /reverse_each_word.rb | UTF-8 | 345 | 3.578125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # def reverse_each_word(sentence)
# sentence_array = sentence.split
# reversed_words = []
# sentence_array.each do |word|
# reversed_words << word.reverse
# end
# reversed_words.join(" ")
# end
def reverse_each_word(sentence)
sentence.split.collect {|word| word.reverse}.join(" ")
end
# print reverse_ea... | true |
d4e859cfb71c83e7f919c2151f8d398c93dde34a | Ruby | jose-luis-ramos-olivares/arreglos | /promedio2.rb | UTF-8 | 419 | 3.796875 | 4 | [] | no_license | def compara_arrays(grades, grades1)
average = 0
average1 = 0
lenght = grades.count
lenght1 = grades1.count
grades.each do |grade|
average += grade/lenght.to_f
end
grades1.each do |grade|
average1 += grade/lenght1.to_f
end
if average > average1
print average
... | true |
03db5e723c5c97ba614d26496422075322b55dd5 | Ruby | dianajyoo/emoticon-translator-dumbo-web-091718 | /lib/translator.rb | UTF-8 | 852 | 3.484375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # require modules here
require 'yaml'
def load_library(file_path)
# code goes here
emoticons = YAML.load_file(file_path)
hash = {"get_emoticon" => {}, "get_meaning" => {}}
emoticons.each do |k, v|
hash["get_emoticon"][v[0]] = v[1]
hash["get_meaning"][v[1]] = k
end
hash
end
def get_japanese_emotic... | true |
21cdc487dc393fb4ea94d118f4992d55f648c663 | Ruby | ahmetefeoglu/my-first-ruby-exercise | /check_number.rb | UTF-8 | 92 | 3.28125 | 3 | [] | no_license | arr=[1,3,5,7,9]
number=3
if arr.include?(number)
puts "true"
else
puts "false"
end
| true |
8c84f105d9d7b1bd8b03b1efab85a36fa331c2fa | Ruby | chalmie/Random_Ruby | /fib_checker.rb | UTF-8 | 215 | 3.609375 | 4 | [] | no_license | def fib_checker(num)
fib = [0,1]
while fib.max <= num
next_fib = fib[-1] + fib[-2]
fib << next_fib
end
if fib.include?(num)
return true
else
return false
end
end
p fib_checker(13) | true |
dc53f3523c5ed81e2df21fbd03e11e6db3fe7d32 | Ruby | breadbear/learn_ruby | /01_temperature/temperature.rb | UTF-8 | 89 | 3 | 3 | [] | no_license | def ftoc(f)
(f.to_f - 32.0) * (5.0 / 9.0)
end
def ctof(c)
(c.to_f * 1.8) + 32.0
end
| true |
ef4a6b911dcd17779a3bc46eb48fb705a522aa2d | Ruby | uchihara/word-finder | /lib/word_finder/cell.rb | UTF-8 | 206 | 3.03125 | 3 | [] | no_license | class Cell
attr_reader :char
def initialize char
@char = char
unmark!
end
def marked?
@marked
end
def mark!
@marked = true
end
def unmark!
@marked = false
end
end
| true |
9f67ec2ee2b3de0245d8058155c9b1099135154f | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/filtered-submissions/90f0624e081f43f1846ddbaf32d47afd.rb | UTF-8 | 149 | 3.328125 | 3 | [] | no_license | def compute(x, y)
hamming = 0
x.each_char.with_index do |char, idx|
hamming += 1 unless char == y[idx]
end
return hamming
end | true |
99324c4c39c7c3027096d6f4ab0a7039bf355c1c | Ruby | evanphx/talon | /lib/talon/resolver.rb | UTF-8 | 969 | 2.90625 | 3 | [] | no_license | module Talon
module AST
class Node
attr_accessor :target
end
class Identifier
def resolve_under(res)
@target = res.find(name)
end
end
class Number
def resolve_under(res)
@target = MachineInteger.new(res)
end
end
class Assignment
def r... | true |
bcb5606946a380b92f9c33a3112708012daf1807 | Ruby | VladFiliucov/rspec_playground | /spec/lib/count_constraint_spec.rb | UTF-8 | 750 | 3.03125 | 3 | [] | no_license | context "with message count constraints" do
it "allows constraints on message count" do
class Cart
def initialize
@items = []
end
def add_item(id)
@items << id
end
def restock_item(id)
@items.delete(id)
end
def empty
@items.each {|id| r... | true |
6f6a41632fa11fe8bdce1b4cfae66f3b0220f35d | Ruby | MaryBobs/movie_lab | /models/casting.rb | UTF-8 | 888 | 3.078125 | 3 | [] | no_license | require_relative("../db/sql_runner.rb")
class Casting
attr_reader :id
attr_accessor :movie_id, :star_id, :fee
def initialize(options)
@id = options['id'].to_i if options['id']
@movie_id = options['movie_id']
@star_id = options['star_id']
@fee = options['fee']
end
def save()
sql = "INSERT INTO castings
(... | true |
7a7e7bf76fb88b361d7dbd21140f52cd950bd925 | Ruby | aokiji/jenkins_api_client | /lib/jenkins_api_client/job_build.rb | UTF-8 | 2,410 | 2.609375 | 3 | [
"MIT"
] | permissive | module JenkinsApi
class Client
#
# This class represents a build with an assingned id. This includes
# jobs already built or that are currently active.
#
class JobBuild
VALID_PARAMS = ['id', 'name', 'params'].freeze
attr_accessor :id, :name
... | true |
dbae575b61d4fb2201146d8d40458adbcb86b4b2 | Ruby | faketrees/alpaca | /w3/w3d1/solutions/Simon Kroeger/word_chain2.rb | UTF-8 | 491 | 2.53125 | 3 | [] | no_license | dict, len = Hash.new{|h,k|h[k] = []}, ARGV[0].size
IO.foreach(ARGV[2] || 'words.txt') do |w| w.chomp!
if w.size != len then next else s = w.dup end
(0...w.size).each{|i|s[i]=?.; dict[s] << w; s[i]=w[i]}
end
t, known = {ARGV[1] => 0}, {}
while !known.merge!(t).include?(ARGV[0])
t = t.keys.inject({}){|h, w|(0...w.s... | true |
bccceba83e545590aac1cbce8f324f0b190343c2 | Ruby | bandeirabeto/secretarytest | /app/models/student.rb | UTF-8 | 664 | 2.609375 | 3 | [] | no_license | class Student < ActiveRecord::Base
has_many :classrooms
has_many :courses, class_name: 'Course', dependent: :destroy, through: :classrooms
validates :name,
presence: true,
length: { maximum: 44, minimum: 3 }
validates :register_number,
presence: true,
length: { ... | true |
3a2afee77105702e2f9ecf75438f3e377de71793 | Ruby | AJ8GH/rspec-udemy | /subjects-examples-context/overwriting_let_spec.rb | UTF-8 | 981 | 3.40625 | 3 | [] | no_license | class ProgrammingLanguage
attr_reader :name
def initialize(name = 'Ruby')
@name = name
end
end
# scope:
# each let is available to all lower level examples - children and descendents
# doesn't work the other way around
# rspec first looks in current scope, then looks at each level above until the top.
# won'... | true |
878ce4edde10e7dbf59be46d8e624cf6c0977754 | Ruby | Sanbornh/object_oriented_programming | /parser.rb | UTF-8 | 1,367 | 4.125 | 4 | [] | no_license | # Accepts a string of the form: "x objects at price",
# with optional input of imported and/or basic tax exempt
# and then returns a hash with the number of items, the price
# the object name, whether it is imported and whether
# it is exempt from basic tax.
# EX: if provided the string : "3 blue water bottle at 10"
... | true |
e26f5ea06f7d036d0c14721cc9454f5d5a250a81 | Ruby | rebeccaswebsite/SQL-bear-organizer-lab-london-web-career-040119 | /lib/sql_queries.rb | UTF-8 | 1,467 | 3.265625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def selects_all_female_bears_return_name_and_age
# selects all of the female bears and returns their name and age
"SELECT name, age FROM bears WHERE gender IS 'F'"
end
def selects_all_bears_names_and_orders_in_alphabetical_order
# selects all of the bears names and orders them in alphabetical order
"SELECT nam... | true |
bdfddcb7c4acc2b6b02ffee3a57ec75a233263bd | Ruby | hshinde/cheftools | /scripts/aws/newsubnet.rb | UTF-8 | 1,673 | 2.71875 | 3 | [] | no_license | require 'open-uri'
require 'aws-sdk'
require 'pp'
require 'optparse'
options = {}
opts = OptionParser.new do |parser|
parser.banner = "Usage: newvpc.rb [options]"
parser.on('-c', '--cidr CIDR', 'CIDR block, IP range from ') { |v| options[:cidr] = v }
parser.on('-v', '--vpc VPC_ID', 'VPC ID') { |v| options[:vpc_... | true |
03be995e60a4bd91efd0d91ae44f51065e45e574 | Ruby | Koki-Shimizu/PlanningPokerDomainModel | /gamemaker.rb | UTF-8 | 588 | 2.703125 | 3 | [] | no_license | # To change this template, choose Tools | Templates
# and open the template in the editor.
require "./group"
require "./user"
require "./story"
class Game_Maker
def initialize( product_name )
@product_name = product_name
@group = Group.new( "GroupA" )
end
def make_user( id, name )
user = User.ne... | true |
117e747fabdccf66cc22cfc7c31fbd5f15c1a5d5 | Ruby | syahmiibrahim/toyrobot | /lib/robot.rb | UTF-8 | 1,310 | 3.8125 | 4 | [] | no_license | class Robot
DEFAULT_LOCATION = 0
DEFAULT_DIRECTION = 'N' #NORTH
def initialize(x = DEFAULT_LOCATION, y = DEFAULT_LOCATION, direction = DEFAULT_DIRECTION)
@orientation = ['N', 'E', 'S', 'W' ]
x < 0 ? @x_location = DEFAULT_LOCATION : @x_location = x
y < 0 ? @y_location = DEFAULT_LOCATION : @y_location ... | true |
985a69ac97eac6a4d56d0ff8a30c8e83d9b3f1ef | Ruby | bassdb1/Ruby | /HashBracketNotation.rb | UTF-8 | 680 | 2.796875 | 3 | [] | no_license | grace_hopper = {
full_name: "Grace Hopper",
date_of_birth: "December 9, 1906",
occupations: ["computer scientist", "US Navy rear admiral"],
achievements: ["led the team responsible for releasing some of the first compiled languages", "received more than 40 honorary degrees", "popularized the idea of... | true |
c3372c1e9d8f8032dc4bddd32277b35df13deb89 | Ruby | Aifear/free-ruby | /task3.rb | UTF-8 | 991 | 3.921875 | 4 | [] | no_license | #Сложение временных промежутков
def hour(hours)
case hours
when 0
return ""
when 1
return (hours.to_s + " час ")
when 2,3,4
return (hours.to_s + " часа ")
else
return (hours.to_s + " часов ")
end
end
def min(minutes)
case minutes
when 0
return ""
when 1
return (minutes.to_s + " минут... | true |
7ed95ac15190b7ce6fe406f917e21a9900844f3a | Ruby | sekoudosso82/ruby_interview_prep | /rubyMetho.rb | UTF-8 | 1,585 | 4.625 | 5 | [] | no_license | # RUBY METHODS
# Prime checker
def prime? (arg)
if arg < 2
return false
end
for i in 2...arg do
if arg%i == 0
return false
end
end
return true
end
or
def prime?(arg)
Prime.prime?(arg)
end
# argument Default value
# assign default values t... | true |
729ab3b51a86007d846c24acce9b83e62bc52e2b | Ruby | markrickert/PromotionTwoScreensInOne-Example | /app/models/state.rb | UTF-8 | 1,300 | 3.046875 | 3 | [] | no_license | class State
attr_accessor :name
def self.all
[
new("Alabama"),
new("Alaska"),
new("Arizona"),
new("Arkansas"),
new("California"),
new("Colorado"),
new("Connecticut"),
new("Delaware"),
new("Florida"),
new("Georgia"),
new("Hawaii"),
new("I... | true |
5597ac1bcbef94e947ea22c7ad8e5ed3105853b6 | Ruby | Sam-Serpoosh/twitter_client | /spec/tweet/parser_spec.rb | UTF-8 | 2,580 | 2.765625 | 3 | [] | no_license | require_relative "../../lib/tweet/parser"
require_relative "./data"
module Twitter
describe Parser do
let(:all_tweets) { Data.timeline }
let(:friends) { Data.friends }
let(:parser) { Parser.new(Factory.new) }
context "tweets" do
it "parses a collection of tweets" do
tweets = parser.get... | true |
a13c85e036cda8946ca033191b49006a7e47930b | Ruby | mattlistor/module-one-final-project-guidelines-nyc-web-071519 | /app/models/customer.rb | UTF-8 | 3,000 | 3.328125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Customer < ActiveRecord::Base
has_many :orders
has_many :books, through: :orders
def name
"#{self.first_name}" + " #{self.last_name}"
end
def get_orders
Order.all.select{|o| o.customer_id == self.id}
end
def get_books
self.get_orders.map{|o| o.get_books_from_... | true |
e491f4c1cadd1c4d716ff711cfa8ebca1fb9d07f | Ruby | OrlandyAriel/prct10 | /lib/referencia/referencia.rb | UTF-8 | 982 | 3.171875 | 3 | [
"MIT"
] | permissive | class ReferenciaBase
include Comparable
attr_accessor:m_autores, :m_titulo, :m_anio
def initialize(a_autores, a_titulo, a_anio)
@m_autores,@m_titulo,@m_anio = a_autores,a_titulo,a_anio
end
#Uso 3 criterios para comparar, primero comprueba si los autores son iguales
#si lo son, comprobarí... | true |
b049ce339de3b5c8ebf46d4890dd3dd71682c662 | Ruby | kschumy/hotel | /old_version/lib/bookings_manager_old_f_ed_up_version.rb | UTF-8 | 3,288 | 3.34375 | 3 | [] | no_license | # # QUESTION: is it better to check if valid date immediately or wait until making
# # reservation?
#
# module Hotel
# class BookingsManager
# # attr_reader :room, :reservations
#
# def initialize
# @rooms = []
# @reservations = []
# load_rooms
# end
#
# # Throws ArgumentError if i... | true |
0b544df2255b4c84df39abf0d9b3ba53c19725ca | Ruby | jasonpilz/ctci-6th-edition-ruby | /lib/chapter_01/1.07.rb | UTF-8 | 153 | 2.59375 | 3 | [] | no_license | # frozen_string_literal: true
module One
module Seven
module_function
def call(input)
input.transpose.map(&:reverse)
end
end
end
| true |
926a983a022126b9275847455afcb99d8205d471 | Ruby | masked-rpgmaker/RGSS3 | /MBS/sprites-below-player.rb | UTF-8 | 1,396 | 2.546875 | 3 | [] | no_license | #==============================================================================
# MBS - Imagens debaixo do player
#------------------------------------------------------------------------------
# por Masked
#==============================================================================
#================================... | true |
1b5cb008d29e4559b84faf923deadc7b35cec8c6 | Ruby | andrewls/mysql-replayer | /lib/mysql_replayer/prepared_statement_cache.rb | UTF-8 | 2,211 | 2.921875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module MysqlReplayer
class PreparedStatementCache
def initialize(db)
@db = db
# probably the simplest way to manage these is just by using the SQL
# strings as keys in a big hash
@statements = {}
# In a twist of fate that's also super weird, we have no ... | true |
82c411f8ff1bf852fb977a10557a90b46bea1975 | Ruby | ylee12/ruby_reference | /enumerable_reduce.rb | UTF-8 | 449 | 3.734375 | 4 | [] | no_license | [1,2,3].reduce do |accumulator, current|
puts "Accumulator: #{accumulator}, Current: #{current}"
accumulator + current
end
puts()
puts "Second pass ..."
[1,2,3].reduce(0) do |accumulator, current|
puts "Accumulator: #{accumulator}, Current: #{current}"
accumulator + current
end
puts()
puts "Third pass ..."
... | true |
9072d9b3b15986bffbaf487b31924d5824053a60 | Ruby | SergeiHrenovsky/summer-2018 | /2309/2/rap-battles/versus.rb | UTF-8 | 8,446 | 2.984375 | 3 | [] | no_license | require 'terminal-table'
# This method smells of :reek:IrresponsibleModule
# This method smells of :reek:TooManyInstanceVariables
# This method smells of :reek:TooManyMethods
# rubocop:disable Style/GlobalVars
# rubocop:disable Metrics/MethodLength
# rubocop:disable Lint/UnneededCopDisableDirective
# rubocop:disable M... | true |
34a870042c1fa42a35b1e9849493a13f652fbc65 | Ruby | pipivybin/simple-loops-online-web-prework | /simple_looping.rb | UTF-8 | 811 | 4.21875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # REMEMBER: print your output to the terminal using 'puts'
def loop_iterator(number_of_times)
phase = "Welcome to Flatiron School's Web Development Course!"
number = 0
loop do
puts phase
number += 1
break if number == number_of_times
end
end
def times_iterator(number)
number.times do
puts "W... | true |
2ff7519e3b8830e57a21f884c2ae20658d7e99f3 | Ruby | PetushovaE/my-collect-wdf-000 | /lib/my_collect.rb | UTF-8 | 401 | 3.140625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def my_collect(languages)
# 1st version:
# new_array = []
# counter = 0
# while counter < languages.length
# new_array << yield(languages[counter])
# counter += 1
# end
# empty_array
# end
# 2nd version:
new_collection = []
counter = 0
while counter < languages.length
new_... | true |
ed9ef3f240dfd2a37b2845243533c69b29e1ec75 | Ruby | DBuckley0126/deli-counter-online-web-ft-090919 | /deli_counter.rb | UTF-8 | 623 | 3.90625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
# binding.pry
def line(array)
if array.empty?
puts "The line is currently empty."
else
string = "The line is currently:"
array.each_with_index do |name, index|
string << " #{index + 1}. #{name}"
end
puts string
end
end
def take_a_number(queue_array, name)
next_position = queue... | true |
f5e4e5fd55470f2a8eba366759f4059f75390735 | Ruby | shadabahmed/leetcode-problems | /nested-list-weight-sum.rb | UTF-8 | 286 | 3.453125 | 3 | [] | no_license | # @param {NestedInteger[]} nested_list
# @return {Integer}
def depth_sum(nested_list, depth = 1)
nested_list.reduce(0) do |sum, elem|
if elem.is_a?(Array)
sum += depth_sum(elem, depth + 1)
else
sum += elem * depth
end
end
end
p depth_sum [[1,1],2,[1,1]] | true |
ef32afdb52a11a13d1ec84c5cc1d17262ded282d | Ruby | kwin555/ruby-code-and-algorithm-practice | /ruby_class_bug.rb | UTF-8 | 303 | 3.75 | 4 | [] | no_license | class Person
attr_reader :age
def initialize(first_name, last_name, age)
@first_name = first_name
@last_name = last_name
@age = age
end
def full_name
"#{@first_name} #{@last_name}"
end
end
person = Person.new('Yukihiro', 'Matsumoto', 47)
puts person.full_name
puts person.age
| true |
32ec07e3ccd284f353f06559648634e0b2533bc0 | Ruby | mjuettne/optimizer22 | /app/models/cmas_import.rb | UTF-8 | 1,295 | 2.65625 | 3 | [] | no_license | class CmasImport
include ActiveRecord::Model
require 'roo'
attr_accessor :file
def initialize(attributes={})
attributes.each { |name, id, exp_ret, std_dev, skew, kurt, _yield| send("#{name}=", id, exp_ret, std_dev, skew, kurt, _yield) }
end
def persisted?
false
end
def open_spreadsheet
c... | true |
a7e8e48c78e534d07931704213328a18168e25f1 | Ruby | etdev/algorithms | /4_custom/bubble_sort.rb | UTF-8 | 1,695 | 3.6875 | 4 | [
"MIT"
] | permissive | require_relative "./testable"
class BubbleSort
include Testable
def solution(arr)
return [] unless (arr && arr.is_a?(Array))
return arr if arr.size < 2
swapped = true
until !swapped
swapped = false
0.upto(arr.size-2) do |i|
a, b = arr[i], arr[i+1]
if b < a
arr... | true |
b5e695bfa578d30ef79fd8118d8ff8eb6e55b623 | Ruby | feigningfigure/WDI_NYC_Apr14_String | /w02/d01/Christopher_Bajorin/homework/part_2_pair_programming_bot/pair_programmer.rb | UTF-8 | 1,098 | 2.765625 | 3 | [] | no_license | require 'sinatra'
require 'sinatra/reloader'
require_relative 'styles'
# buttons aren't working.
get '/' do
<<-HTML
<link rel="stylesheet" type="text/css" href="/styles.css">
<h1>Does The Test Pass?</h1>
<input type="submit" value=" YES " href="http://localhost:4567/yespass"><br>
<input type="submit" value=... | true |
7ebf84409db87cde85da90d3fbb379323d849338 | Ruby | Atilla106/multiboard | /lib/weather.rb | UTF-8 | 1,877 | 2.921875 | 3 | [] | no_license | require 'json'
require 'net/http'
require 'time'
class Weather
attr_reader :weather, :weather_icon, :temperature, :min_temperature, :max_temperature, :wind_speed, :sunrise, :sunset, :morning_forecast, :afternoon_forecast
def initialize
owp_current
owp_forecast
end
def to_s
"#{@weather} #{weather_... | true |
e75ef294ba77871360a907a1f78e5c69d5d71ebf | Ruby | h4hany/yeet-the-leet | /algorithms/Easy/1441.build-an-array-with-stack-operations.rb | UTF-8 | 1,798 | 3.828125 | 4 | [] | no_license | #
# @lc app=leetcode id=1441 lang=ruby
#
# [1441] Build an Array With Stack Operations
#
# https://leetcode.com/problems/build-an-array-with-stack-operations/description/
#
# algorithms
# Easy (69.57%)
# Total Accepted: 23K
# Total Submissions: 33.1K
# Testcase Example: '[1,3]\r\n3\r'
#
# Given an array target and ... | true |
6d6af4602b25e842e7d1829e178d994c2ddb46cb | Ruby | evanaaron26/weekend_work | /week3_work/sum_of_range.rb | UTF-8 | 1,216 | 4.6875 | 5 | [] | no_license | # Complete the method called sum_of_range, which will accept an array containing
# two numbers, and return the sum of all of the whole numbers within the range of those
# numbers, inclusive.
# number = 0
def sum_of_range(array)
#here I set range to 0 in order to count the range of array
range = 0
#here ... | true |
ff1d01dcc4f08a9b5351516ab831fa60b2f848b3 | Ruby | tlowrimore/ghost_phone | /lib/ghost_phone.rb | UTF-8 | 2,929 | 2.953125 | 3 | [] | no_license | require 'pathname'
require 'logger'
require 'ghost_phone/message'
require 'ghost_phone/serial'
require 'ghost_phone/sound'
require 'ghost_phone/state_manager'
module GhostPhone
SERIAL_PORT = '/dev/serial0'
BAUD_RATE = 115200
# -----------------------------------------------------
# Class Methods
# ------... | true |
3d8343cdd1d9153e1a8fbd14ac7cb24b0349991d | Ruby | galejscott/OO-Get-Swole-london-web-051319 | /tools/console.rb | UTF-8 | 838 | 3.078125 | 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
#gym
uber = Gym.new("Uber")
twitter = Gym.new("Twitter")
airbnb = Gym.new("AirBnb")
#lifter
bill = Lifter.new("Bill", 3000000000)
warren = Lifter.new("Warren", 9... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.