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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
0ebf2d537c55c6fdc5c39540c5cca9dd0ce10f01 | Ruby | prcaen/psd-reader | /lib/psd/read/sections/header.rb | UTF-8 | 2,126 | 2.640625 | 3 | [
"MIT"
] | permissive | module Psd
module Read
module Sections
class Header
attr_reader :channels, :color_mode, :depth, :height, :version, :width
def initialize(stream)
LOG.info("### HEADER ###")
@stream = stream
end
def parse
signature = BinData::String.new(read_leng... | true |
bdac2b0a10c432f53e745f6b8639c969f8f585d5 | Ruby | Charliemowood/learn-ruby-the-hard-way | /ex3.rb | UTF-8 | 1,254 | 4.5 | 4 | [] | no_license | # the cars variable is assigned the value of 100
cars = 100
# the space_in_a_car variable is assigned the value of 4.0 because the average can be a decimal point. This is called a floating point.
space_in_a_car = 4.0
# ditto drivers without a floating points drivers can only be whole numbers. Also interesting to note t... | true |
11239be1302e891229c9c5203a7b171c697c0f8e | Ruby | evawiedmann/rock-paper-scissors | /lib/rock_paper_scissors.rb | UTF-8 | 1,108 | 3.59375 | 4 | [] | no_license | class Game
@@weapons = {
"1" => "rock",
"2" => "scissors",
"3" => "paper"
}
def initialize(input)
@input = '1'
@input2 = '2'
@input3 = '3'
end
def throw(input)
# @random = rand(1..3).to_s
@random1 = '1'
@random2 = '2'
@random3 = '3'
if (@@weapons.fetch(@input) == ... | true |
9aa969c5a09a6e12f68b9954419c12d6ddb38332 | Ruby | UbuntuEvangelist/therubyracer | /vendor/cache/ruby/2.5.0/gems/fog-rackspace-0.1.6/lib/fog/rackspace/examples/compute_v2/delete_network.rb | UTF-8 | 2,212 | 2.90625 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
# This example demonstrates deletes a private network and attaching it to a new server with the Rackpace Open Cloud
require 'rubygems' #required for Ruby 1.8.x
require 'fog'
def wait_for_server_deletion(server)
begin
server.wait_for { state = 'DELETED' }
rescue Fog::Compute::RackspaceV2::... | true |
6e49135dd5ff6631ef927c3e38f9510c6a55b0d7 | Ruby | emegill/MorningProblems | /MorningProblem23/ruby.rb | UTF-8 | 648 | 4.375 | 4 | [] | no_license | # // A Fibonacci number is the sum of the previous two sequence numbers. Below is an example of the sequence:
#
# // 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, … Notice the sequence pattern is the sum of the previous two numbers?
# //
# // 0 + 1 = 1 1 + 1 = 2 1 + 2 = 3 2 + 3 = 5 3 + 5 = 8 …
#
#
# // Wri... | true |
8f9e59ec5b3bd7e0ceaeafceafdf5191c59c80c9 | Ruby | iachettifederico/trecs | /lib/trecs/strategies/fly_from_right_strategy.rb | UTF-8 | 1,165 | 2.671875 | 3 | [
"MIT"
] | permissive | require "strategies/strategy"
require "strategies/shell_command_strategy"
module TRecs
class FlyFromRightStrategy < Strategy
include ShellCommandStrategy
attr_reader :message
attr_reader :width
def initialize(options={})
@message = options.fetch(:message)
@width = options.fetch(:w... | true |
c4dafc08d79469aa81a209054467c30e071dd0d3 | Ruby | dbravman/phase-0-tracks | /ruby/arrays_drill.rb | UTF-8 | 1,987 | 4.8125 | 5 | [] | no_license | # At the top of your file, add a method that takes three items as parameters and returns an array of those items. So build_array(1, "two", nil) would return [1, "two", nil]. This won't take much code, but the syntax might feel a bit odd.
def build_array(a, b, c)
return_array = []
return_array << a
return_array <... | true |
feef14759927e05b305bc37859ec196928f6ae94 | Ruby | developwithpassion/expansions | /lib/expansions/template_processors.rb | UTF-8 | 697 | 2.921875 | 3 | [
"MIT"
] | permissive | module Expansions
class TemplateProcessors
attr_reader :processors
def initialize(processors={})
@processors = processors
end
def get_processor_for(file_name)
template_type = File.extname(file_name).gsub(/\./,'').to_sym
raise "There is no processor for #{file_name}" unless process... | true |
ef827941dba9ea47df795ce59e8a4399bd3caa7a | Ruby | ryanespin/18xx | /assets/app/view/game/part/track.rb | UTF-8 | 2,866 | 2.59375 | 3 | [
"LicenseRef-scancode-free-unknown",
"MIT"
] | permissive | # frozen_string_literal: true
require 'lib/settings'
require 'view/game/part/track_node_path'
require 'view/game/part/track_offboard'
require 'view/game/part/track_stub'
module View
module Game
module Part
class Track < Snabberb::Component
include Lib::Settings
TRACK = {
color: ... | true |
631d727fd0f4de60204e52769f8719c63c1189a1 | Ruby | kghandhi/JazzCamp | /lib/camp_helpers.rb | UTF-8 | 1,841 | 2.71875 | 3 | [] | no_license | def zipper_split(sorted_students)
grouped = sorted_students.each_with_index.group_by { |student,rank| rank % 2 }
first_half = grouped[0].nil? ? [] : grouped[0].map(&:first)
second_half = grouped[1].nil? ? [] : grouped[1].map(&:first)
[first_half, second_half]
end
def in_groups(students, number)
division = st... | true |
57531a1ddab5190ca14bd892b11f3083330ce539 | Ruby | jtibbertsma/stockfighter-solutions | /lib/stockfighter/request.rb | UTF-8 | 689 | 2.515625 | 3 | [] | no_license | require 'httparty'
module Stockfighter
class Request
include HTTParty
base_uri 'api.stockfighter.io'
headers 'X-Starfighter-Authorization' => Stockfighter::APIKey
class BadRequest < RuntimeError
end
class JSONOnly < HTTParty::Parser
def parse
json
end
end
parser... | true |
a48c7f7590ab06bf53f7ecda76143665eaa6a2d3 | Ruby | christopher-tero/Restaurant_finder_01 | /lib/methods.rb | UTF-8 | 11,211 | 3.53125 | 4 | [] | no_license | require 'pry'
#note to us we have a global variable "$location" and "$name" ***caution***
#/// Intro ///
def intro
loading_2
puts `clear`
puts "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
puts "".center(236).blue_on_green
print "Welcome to Restaurant Sleuth!".center(118).blue_on_green
puts "".center(236).blue_on_green... | true |
9ff936d53b0ccc40a061014ee1d3d2c4a3f85fc6 | Ruby | MidhunSukumaran/Datastructures-with-Ruby | /double_linked_list.rb | UTF-8 | 2,413 | 3.703125 | 4 | [] | no_license | class Node
attr_accessor :key,:next_node,:prev_node
def initialize(k=0)
@key = k
@next_node = nil
@prev_node = nil
end
end
class DoubleLinkedList
attr_accessor :root
def initialize(root)
@root = root
end
def self.create_linear_list(array)
root = Node.new(array.first)
linked ... | true |
08294b275fb18d32d4bf950858c3c08eeddf01ab | Ruby | draganglumac/algo1 | /week6/median/median.rb | UTF-8 | 780 | 3.765625 | 4 | [] | no_license | require 'heap'
class Median
def initialize
reset
end
def reset
@lo_heap = Heap.new { |a, b| b <=> a }
@hi_heap = Heap.new { |a, b| a <=> b }
end
def median
size = (@lo_heap.heap.size + @hi_heap.heap.size)
if size % 2 == 1
m = (size + 1) / 2
else
m = size / 2
end
... | true |
de5366afc024888b545bb67d3fa7bc2e8f7ba9c0 | Ruby | IgnacioEscobar/ProtoCool | /destroy_header.rb | UTF-8 | 758 | 2.890625 | 3 | [] | no_license | require 'json'
# Wrapper
wrapper =%{
#ifndef UTILIDADES_PROTOCOL_DESTROY_H_
#define UTILIDADES_PROTOCOL_DESTROY_H_
}
print wrapper
# Includes
includes =%{
#include <stdint.h>
}
print includes
# Seleccionar la base de conocimiento y parsear JSON
file = File.read("baseConocimiento.json")
hash = JSON.parse(file)
mensaje... | true |
9f2e6bdd6cfa11040785741787970257e1bc54e8 | Ruby | unabl4/AoC | /2017/day17/part1/spinlock.rb | UTF-8 | 229 | 2.921875 | 3 | [] | no_license | def spinlock(step)
pos = 0
buffer = [0]
length = 1
value = 1
2017.times do
m = (pos + step) % length
pos = m+1 # next
buffer.insert(pos, value)
value += 1
length += 1
end
buffer[pos+1]
end
| true |
836b96fe0250e2aaa51741ece2a8a59a67b453da | Ruby | grcdeepak1/project_tdd_minesweeper | /spec/board_spec.rb | UTF-8 | 1,291 | 3 | 3 | [] | no_license | require_relative '../lib/board.rb'
require_relative '../lib/square.rb'
describe Board do
before(:each) do
subject.extend(Enumerable)
end
describe "#initialize" do
it "returns a board" do
expect(subject).to be_a(Board)
end
it "returns a board with 2d array of squares" do
expect(subject.... | true |
de048c9dbbba09a7b2766683a6030bc30bc651c7 | Ruby | alancovarrubias/nba_react | /app/models/builder/quarter/player_stat.rb | UTF-8 | 1,349 | 2.5625 | 3 | [] | no_license | module Builder
module Quarter
class PlayerStat
UPDATE_ATTR = [:sp, :fgm, :fga, :thpm, :thpa, :ftm, :fta, :orb, :drb, :ast, :stl, :blk, :tov, :pf, :pts]
attr_accessor :player, :team, :idstr, :starter, :time
attr_accessor :sp, :fgm, :fga, :thpm, :thpa, :ftm, :fta, :orb, :drb, :ast, :stl, :blk, :to... | true |
9e90d8eb4f3c0c589e891606ac2283d3cc6ff021 | Ruby | Xin00163/oystercard | /spec/journey_spec.rb | UTF-8 | 1,028 | 2.8125 | 3 | [] | no_license | require 'journey'
describe Journey do
let (:station) {double :station, zone: 1}
let (:station2) {double :station, zone: 1}
describe '#fare' do
subject {described_class.new(station)}
it 'should return the fare for the journey if touched in/out' do
journey = Journey.new(station)
journey.end_j... | true |
49fddd5ec8efb9853f31988c6f3916f487a6174b | Ruby | JamesClonk/ruby-sensei | /09_projects/lib/restaurant.rb | UTF-8 | 1,667 | 3.21875 | 3 | [] | no_license | class Restaurant
@@filepath = nil
def self.filepath=(path=nil)
@@filepath = File.join(APP_ROOT, path)
end
attr_accessor :name, :cuisine, :price
def self.file_exists?
if @@filepath && File.exists?(@@filepath)
return true
else
return false
end
end
def self.file_usable?
re... | true |
cd50cbe6d46a1e3dd6a6a850d07d6ec5086a5116 | Ruby | KrzaQ/AdventOfCode2015 | /day03/main.rb | UTF-8 | 795 | 2.8125 | 3 | [] | no_license | T = File.read("data.txt")
def simPath(path)
path.each_char.inject({current: [0,0], total: { [0,0] => 1 }}){ |memo,c|
point = [{
'^' => [ 0, 1],
'>' => [ 1, 0],
'v' => [ 0, -1],
'<' => [-1, 0]
}[c], memo[:current]].transpose.map{ |n| n.inject(:+) }
memo[:total][point] = memo[:total].fetch(point, ... | true |
f7b4bd19138c3fe299e8d0ba78a11b2590583e0d | Ruby | phelanjo/tier_list | /spec/models/list_spec.rb | UTF-8 | 3,107 | 2.8125 | 3 | [] | no_license | require "rails_helper"
RSpec.describe List do
let(:empty_team) { FactoryBot.build_stubbed(:list) }
let(:team_of_one) { FactoryBot.build_stubbed(:list, champions: [champion]) }
let(:team_of_three) { FactoryBot.build_stubbed(:list, champions: [champion, champion, champion]) }
let(:team1) { FactoryBot.build_stubb... | true |
101f1abd4f83975c25cae08f5ee5211ce3ce6f8f | Ruby | ramky/learn_to_program | /chapter14/logger.rb | UTF-8 | 390 | 3.5625 | 4 | [] | no_license | $depth = 0
def log(description, &block)
#puts "Depth: #{$depth}"
puts ("\t" * $depth) + "Beginning #{description}"
$depth += 1
return_value = block.call
$depth -= 1
puts ("\t" * $depth) + "Returning #{return_value}, finished #{description}"
end
log 'outer' do
log 'inner 1' do
log 'inner 12' do
"Inner 12"
... | true |
f315eac1b5b9090b554c613868f9e7089a39f413 | Ruby | fUNCodeUNAL/Proyecto | /app/models/contest.rb | UTF-8 | 1,192 | 2.546875 | 3 | [] | no_license | class Contest < ApplicationRecord
belongs_to :teacher
attr_accessor :contest_running
validates :name, :start_date, :end_date, presence: { message: "es obligatorio" }
validate :dates_are_correct
validate :valid_initial_date, unless: :contest_running
has_many :problem_contest_relationships, dependent: :destroy
... | true |
97df7ef55c90a48d4dc43237c298c4613d0d705c | Ruby | Shahrene/Warmups | /lunch_orders/lunch_orders.rb | UTF-8 | 324 | 3.796875 | 4 | [] | no_license | require 'pry'
all_orders = ["name", "item"]
while true
puts "Enter a name for the order: "
name = gets.chomp
all_orders[name].push(name)
puts "#{name} wants to order: "
item = gets.chomp
all_orders[item].push(item)
puts "Add another item to the order y/n?: "
break if !gets.index ('y')
end
end
puts all_ord... | true |
2538307272d688c2eb60cd7b8172ea0bd4f40dfc | Ruby | srini91/euler-ruby | /prob37.rb | UTF-8 | 999 | 3.796875 | 4 | [] | no_license | # The number 3797 has an interesting property. Being prime itself, it is possible to continuously remove digits from left to right, and remain prime at each stage: 3797, 797, 97, and 7. Similarly we can work from right to left: 3797, 379, 37, and 3.
# Find the sum of the only eleven primes that are both truncatable fr... | true |
c20f65fd3d26776cfa73f644759aea3d3651b038 | Ruby | mick-mehigan/eventq | /eventq_rabbitmq/lib/eventq_rabbitmq/rabbitmq_queue_worker.rb | UTF-8 | 4,134 | 2.875 | 3 | [
"MIT"
] | permissive | class RabbitMqQueueWorker
attr_accessor :is_running
def initialize
@threads = []
@is_running = false
@retry_exceeded_block = nil
end
def start(queue, options = {}, &block)
configure(queue, options)
puts '[QUEUE_WORKER] Listening for messages.'
raise 'Worker is already running.' if... | true |
cabfb00a3a97210b994b761b702797cbeaa13052 | Ruby | skyraseal/cp-learn-to-program | /example.rb | UTF-8 | 335 | 3.765625 | 4 | [] | no_license | #log exercise
#better logger included
$nesting = 0
def log(desc, &block)
puts " "*$nesting + "Starting \"#{desc}\" block..."
$nesting += 2
call_save = block.call
$nesting += -2
puts " "*$nesting + "...\"#{desc}\" finished! It returned: #{call_save}"
end
log("block 1") do
log("block 2") do
2+2
end
... | true |
ffe131b5bc7dbe985c145fd298ef14da50351bc3 | Ruby | wpotratz/LS_3_More_Ruby_Topics | /3_practice/trinary.rb | UTF-8 | 501 | 3.453125 | 3 | [] | no_license | # trinary.rb
require 'pry'
class Trinary
def initialize(numeric_string)
@trinary_number = validate_string(numeric_string)
end
def to_decimal
return 0 if @trinary_number.nil?
reverse_number_str.each_with_index.reduce(0) do |decimal, (value, i)|
decimal + value.to_i*3**i
end
end
priv... | true |
cc696ab5a01b3dabf28be1ced7e1d10db1d30f83 | Ruby | hunaba/journee_test_ruby- | /lib/01_temperature.rb | UTF-8 | 773 | 3.828125 | 4 | [] | no_license | def ftoc(x)
y = (x - 32 ) * 5/9
return y
end
def ctof(y)
y = y.to_f
x = (y * 9/5) + 32
return x
end
=begin
B R O U I L L O N
def temperature
ftoc= (32 - 32) * 5/9
puts "freezing temperature is #{ftoc} °C."
end
puts temperature
def boiling
ftoc=(212 - 32 ) * 5/9
puts "boiling temperature is #{ft... | true |
7a9de0bc2b053b5bebdb2942bb078666caa1d7b3 | Ruby | profh/67275_lecture_code | /rack_files/2-EnvReporter/app_extended.ru | UTF-8 | 780 | 3.21875 | 3 | [] | no_license | class EnvReporter
def initialize(app=nil)
# Allow for another app to be passed in
@app = app
end
def call(env)
# Set up basic output string
output = ""
unless @app.nil?
# if there is an app being passed in, use it's call method and
# get the response (third item in the resp... | true |
c97695ed27f13b986d488d0cfc4b8769a80641b2 | Ruby | romimacca/fullstack-g29 | /introduccion_ruby/desafios_arreglos_p2/grafico.rb | UTF-8 | 656 | 3.671875 | 4 | [] | no_license | data = [5, 3, 2, 5, 10, 19, 20]
def chart(data)
barra = ">"
barra_numero = " "
data.count.times do |i|
print '|'
data[i].times do |j|
if j < 10
print '**'
if data.max == data[i]
barra += '--'
barra_numero +... | true |
646accf7a8aaca93b1f7f2887fadc92a05f76510 | Ruby | ander7en/backend | /app/models/nearest_driver.rb | UTF-8 | 587 | 3.109375 | 3 | [] | no_license | class NearestDriver
def self.getNearestDrivers(originLocation , driverList)
driversWithDistance = Hash.new
driverList.each do |driver|
target_location = {lng: driver.longitude , lat: driver.latitude }
#working on pure distance , later we can change to google api route
#distance = Googl... | true |
7f414660bf71d8218f3225b430c194e0e6bf5ba4 | Ruby | rsanheim/isis | /examples/isis/runner_example.rb | UTF-8 | 3,660 | 2.5625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | require File.join(File.dirname(__FILE__), *%w[.. example_helper])
describe Isis::Runner do
describe "run" do
it "should return the exit code" do
Isis::Runner.stubs(:exit).returns(256)
Isis::Runner.any_instance.stubs(:execute)
Isis::Runner.run.should == 256
end
it "should exit" d... | true |
35ff1a96a83488f420ff16a9ccbfea81d6ce3ee2 | Ruby | dunkelbraun/turbo_test_constant_tracer | /test/unit/constructor_test.rb | UTF-8 | 7,803 | 2.71875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require "test_helper"
describe "Constructor" do
describe "#construct" do
test "constructs class for a string" do
class_constructor = TurboTest::ConstantTracer::Constructor.new(String)
class_constructor.construct
assert defined?(TurboTest::ConstantTracer::ProxyKlas... | true |
dc54c66d434d33f8c53907b4fef596eae53dfe53 | Ruby | ChristophPirringer/AnimalRescueProject | /spec/child_ticket_spec.rb | UTF-8 | 2,861 | 2.53125 | 3 | [] | no_license | require('spec_helper')
describe(ChildTicket) do
it {should belong_to (:good_samaritan)}
###############################################
#############__Object-Creation__###############
###############################################
before() do
@sighting = ChildTicket.new({:animal_type => "Dog", :descri... | true |
ebba20a6b1bf1035d5af5b51574218967bc3755a | Ruby | cjunks94/orm-mapping-to-table-lab-dumbo-web-042318 | /lib/student.rb | UTF-8 | 1,157 | 3.109375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class Student
# Remember, you can access your database connection anywhere in this class
# with DB[:conn]
attr_accessor :name, :grade
attr_reader :id
@@id_count=1
def initialize(name, grade)
@name = name
@grade = grade
end
def self.id_count
@@id_count
end
def self.table_name
self... | true |
98ddff82ac42469c9e3cf3de491eef2a0361d544 | Ruby | wenbo/rubyg | /sample/CHAPTER13/242/use-kirbybase.18.rb | EUC-JP | 5,250 | 3.1875 | 3 | [] | no_license | #!/usr/local/bin/ruby -Ke
require 'rubygems'
require 'kirbybase'
$KCODE='e' # nodisp
db = KirbyBase.new {|kb| kb.path = kb.memo_blob_path = "db" }
# ơ֥
db.drop_table :batters if db.table_exists? :batters # ¸ߤʤк
table = db.create_table(:batters, # battersȤơ֥
:name, :String, # ̾
... | true |
427097cafc2208849795537af56cf11317b997ba | Ruby | SiCuellar/archerdx_challenge | /ruby/dna_seq_finder/lib/runner.rb | UTF-8 | 405 | 2.984375 | 3 | [] | no_license | require "./lib/dna_seq_finder"
puts "Welcome to the DNA sequence finder!"
puts "please place files needed for analysis in the fasta_files directory."
puts "please type in the name of the file you wish to analyze"
puts "\n"
file = gets.chomp
puts "\n"
dna_seq_finder = DnaSequenceFinder.new(file)
dna_seq_finder.file_up... | true |
c0bd365e156a378e1b42d349ffe1ddc22afc82f0 | Ruby | thnukid/facebook_data_analyzer | /classes/analyzeables/contacts.rb | UTF-8 | 1,198 | 2.890625 | 3 | [] | no_license | class Contacts < Analyzeable
def initialize(catalog:)
@catalog = catalog
@directory = "#{catalog}/html/"
@file_pattern = 'contact_info.htm'
@contacts = []
super()
end
def analyze
Dir.chdir(@directory) do
content = File.open(@file_pattern).read
doc = Nokogiri::HTML(content)
... | true |
2eeddf2721ae680efa46bbfe5c6898f38404d755 | Ruby | BenKleinberg/ruby-dominion | /src/Cardlist.rb | UTF-8 | 8,614 | 3.28125 | 3 | [] | no_license | #!/usr/bin/env ruby
class Cardlist
attr_reader :supply
attr_reader :kingdom
attr_reader :back
##
## Setup Methods
##
def initialize
# Load the default cards
@supply = Array.new
supplyInitialize
@kingdom = Array.new
kingdomInitialize
@back = Card.new("Back", 0, 0, :trash)
@back.loadImage if @b... | true |
ec74f195f01ef6b83a32ad0b8ce9013c0c635a3c | Ruby | skyxie/toys | /test_json/a.rb | UTF-8 | 302 | 3.328125 | 3 | [] | no_license | class A
def initialize a, b
@a = a
@b = b
end
def to_json(*args)
{'json_class' => self.class.name, 'a' => @a, 'b' => @b}.to_json(args)
end
def self.json_create(o)
new(o['a'], o['b'])
end
def to_s
"Hey, I'm an object! a=#{@a} b=#{@b}"
end
alias :inspect :to_s
end
| true |
5f2de0325c02d6c486b12b845a03251a9b534a6a | Ruby | bradyswenson/programming_foundations | /lesson_2/rock_paper_scissors.rb | UTF-8 | 1,914 | 3.84375 | 4 | [] | no_license | VALID_CHOICES = { 'r' => 'rock', 'p' => 'paper', 'sc' => 'scissors',
'l' => 'lizard', 'sp' => 'spock' }
score = { player: 0, computer: 0, tie: 0 }
def prompt(message)
Kernel.puts("=> #{message}")
end
def win?(first, second)
(first == 'rock' && second == 'scissors') ||
(first == 'rock' && sec... | true |
3721f063cbd2dc72dfaf0aa13a63f3b410390fee | Ruby | MattRedmon/pragmatic-programming-ruby | /chap_03.rb | UTF-8 | 5,643 | 3.953125 | 4 | [] | no_license | # CHAP 3 - CONTAINTERS, BLOCKS, AND ITERATORS
# ARRAYS
=begin
a = [ 3.14, "pie", 99 ]
a.type # => Array
a.length # => 3
a[0] # => 3.14
a[1] # => "pie"
a[2] # => 99
a[3] # => nil
b = Array.new
b.type # => Array
b.length # => 0
b[0] = "second"
b[1] = "array"
b # => ... | true |
8165d1c6ff08f10a2c1577af3a7bcd4266cf314e | Ruby | ArwaMA/FinalProject | /CloneDetectionToolApproach/host.rb | UTF-8 | 900 | 2.984375 | 3 | [] | no_license | #! /usr/bin/env ruby
## Each commit in the host application is of type Host.
## It contains same as Commit class,
## similarity of clones in the host.
## list of files that have added/changed in the host commit and have clone codes with the donor commit that this host is part of,
## disyance measures, and total num... | true |
f4a25afc383c8e6ca935214ad504910cb5281768 | Ruby | Serummoner/joomlatools | /lib/jdt/manifest/referenced.rb | UTF-8 | 1,769 | 2.90625 | 3 | [
"MIT"
] | permissive | module Jdt
class Manifest
def referenced
list = []
# add files and media
@doc.css("files","media").each do |files|
parent_folder = files['folder']
files.css("filename").each do |file|
list << create_file_ref(file.text,parent_folder)
end
files.css(... | true |
d02929378f2290d25c8b803c8d035da85adbb4a4 | Ruby | nepeanwjdw/makers-bnb | /lib/Users.rb | UTF-8 | 2,004 | 2.984375 | 3 | [
"MIT"
] | permissive | require_relative 'database_connection'
require 'bcrypt'
# top level comment
class User
attr_reader :user_id, :name, :email
def initialize(user_id:, name:, email:)
@user_id = user_id
@name = name
@email = email
end
def self.create(name:, email:, password:)
return nil if User.retrieve_by_email(... | true |
03e2a4051149a492a32d14641a353e4186ea054c | Ruby | sharma7n/HackerRank | /Ruby/enumerables/enumerable_each_with_index.rb | UTF-8 | 226 | 3.09375 | 3 | [
"MIT"
] | permissive | def skip_animals(animals, skip)
# Your code here
filtered = []
animals.each_with_index do |animal, index|
if index >= skip
filtered.push("#{index}:#{animal}")
end
end
filtered
end
| true |
0c0a4fad04baa99b3190743accd8dc30d336b1b2 | Ruby | mzahrada/Rectangles | /lib/rectangles/rectangle.rb | UTF-8 | 2,607 | 3.96875 | 4 | [] | no_license | module Rectangles
# Data object which represents 2D shape rectangle.
class Rectangle
# Error message raised when rectangle cannot be created cos its coordinates are wrong.
NOT_RECTANGLE_TEXT = 'Not rectangle.'
# Error message raised when squares do not overlap.
NO_OVERLAP_TEXT = 'Ctverce se ani ned... | true |
3e98df71e5ffb2e35dad7a1c500be557307ba8bf | Ruby | George-Hudson/CloneWarz | /test/clone_warz/page_test.rb | UTF-8 | 1,565 | 2.84375 | 3 | [
"MIT"
] | permissive | require './test/test_helper'
require './lib/clone_warz/page'
class PageTest < Minitest::Test
def test_it_exists
assert Page
end
def test_it_initializes
data = {
id: 1,
title: "About",
url: "/about",
heading: "About",
img: nil,
body: "The Bike Depot is Denver's only no... | true |
36ddec3d7ba4f3bf968d268e4dadd0c97bbb6c22 | Ruby | jamesdabbs/hydro | /lib/hydro/rule.rb | UTF-8 | 361 | 2.640625 | 3 | [
"MIT"
] | permissive | module Hydro
class Rule
attr_reader :ext, :to
def initialize opts={}
@ext = opts.fetch :ext
@to = opts.fetch :to
FileUtils.mkdir_p @to
end
def matches? object
if ext
object.key.end_with? ext
else
true
end
end
def location_for object
... | true |
1485bccec771841816485977c86d0498b07b2282 | Ruby | brianvh/dry-types | /spec/dry/types/sum_spec.rb | UTF-8 | 1,562 | 2.609375 | 3 | [
"MIT"
] | permissive | RSpec.describe Dry::Types::Sum do
describe '#[]' do
it 'works with two pass-through types' do
type = Dry::Types['int'] | Dry::Types['string']
expect(type[312]).to be(312)
expect(type['312']).to eql('312')
end
it 'works with two strict types' do
type = Dry::Types['strict.int'] | D... | true |
908bd74cc127e1e591d5ca8e2daf06c59772cf36 | Ruby | gadtfly/skilleo.me-challenges | /The Crazy Investor.rb | UTF-8 | 310 | 3.484375 | 3 | [] | no_license | WORD = "SKILLEO"
class SoupLetter
def initialize(s, w=6, h=6)
@s = s
@w, @h = w, h
end
def find(c)
n = @s.index(c)
r = n / @h + 1
c = n % @w + 1
"#{r}#{c}"
end
end
# gets = 'NO70JE3A4Z28X1GBQKFYLPDVWCSHUTM65R9I'
puts WORD.chars.map(&SoupLetter.new(gets).method(:find)).join
| true |
4dcc0033bd9c6932fc5c299e24a6eb6c3c41e431 | Ruby | olliedavis/ruby-cs-projects | /binary_search_tree.rb | UTF-8 | 6,020 | 3.984375 | 4 | [] | no_license | class Node
attr_accessor :data, :left, :right
def initialize(data)
@data = data
@left = nil
@right = nil
end
end
class Tree
attr_accessor :root, :data
def initialize(array)
@data = array
@root = build_tree(data)
end
def build_tree(array)
return nil if array.empty? # repeats rec... | true |
a881d27a6f102b45a6c97b675d0a064b5512d9f1 | Ruby | aminethedream/ruby-intro-to-arrays-lab-001 | /lib/intro_to_arrays.rb | UTF-8 | 479 | 3.609375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def instantiate_new_array
@my_new_array = Array.new
end
def array_with_two_elements
@my_two_array = Array.new
@my_two_array.push("a","b")
end
def first_element(argument)
argument[0]
end
def third_element(argument)
argument[2]
end
def last_element(argument)
argument[-1]
end
def first_element_with_array_... | true |
7ba43521e4e72fcadbc993d0c1246ce7d229b1eb | Ruby | pdrowr/bowling-test | /app/models/frame.rb | UTF-8 | 928 | 2.859375 | 3 | [] | no_license | class Frame < ApplicationRecord
belongs_to :game
include FrameUtils
def roll(pins_number)
raise 'Invalid roll.' if valid_pins?(pins_number)
update_roll(pins_number)
set_mark
set_pins_left(pins_number)
set_score(pins_number)
self.save
end
def get_frame(shift) # method to find a specif... | true |
b80b807f5b93baae031706637b7c08350191ebd0 | Ruby | GentRyan/exenet_navi | /page.rb | UTF-8 | 2,335 | 2.953125 | 3 | [] | no_license | def bbs_mode(client, navi_name)
client_number = 1
puts("BBS being read")
log = File.new("bbslog","a")
log.puts((client_number.to_s) + " " + "Opened Connection")
client.puts("hs")
puts("Hand shake sent")
while true
num = client.gets.chomp()
break if num == "q"
file = File.new("news", "r")
news = file.re... | true |
4cbfd58471d4759981aa789ff1e2697632236c84 | Ruby | DeveloperAlan/WDI_SYD_7_Work | /w01/d01/eugenius/learning_new_strings.rb | UTF-8 | 562 | 3.296875 | 3 | [] | no_license | puts "Hello Scambank at your service, put in your pin please."
pin_number = gets.strip
pin_number.to_s
if pin_number == "000"
puts "Correct! Please stand by for assistance..."
puts "..." * 2000
else
puts "Hahah your PIN is #" + "#{pin_number}, you gonna get hacked!"
puts "Like-a-sumbawdy-fuck-u-bic-boi".upcase
p "Wha... | true |
8431369442df249ee9374c2f758f746021965159 | Ruby | tuzz/vivid | /lib/ease.rb | UTF-8 | 541 | 3.3125 | 3 | [] | no_license | # The different methods for easing are here:
# https://github.com/munshkr/easing-ruby/blob/master/lib/easing.rb
class Ease
attr_accessor :method, :duration
def initialize(method, duration)
self.method = coerce(method.to_s)
self.duration = duration
end
def at(time)
Easing.public_send(method, time... | true |
3deceef54fd0e36996be6872447a2bc22c4888a6 | Ruby | takkkun/peeek | /lib/peeek/supervisor.rb | UTF-8 | 3,030 | 2.90625 | 3 | [
"MIT"
] | permissive | require 'peeek/hooks'
class Peeek
class Supervisor
# Create a supervisor for instance methods.
#
# @return [Peeek::Supervisor] a supervisor for instance methods
def self.create_for_instance
new(:method_added)
end
# Create a supervisor for singleton methods.
#
# @return [Peeek:... | true |
67126a4aeaae81b59e2675b792a1cb2f7f9c0612 | Ruby | JaciBrunning/Waitress | /lib/waitress/kernel.rb | UTF-8 | 6,837 | 2.75 | 3 | [
"MIT"
] | permissive | # The Kernel Module provides global methods that will provide the 'builtins' for .wrb files
# and handlers. This is used to prevent verbose access of a namespace like Waitress::Global,
# and instead provide them here. Because requests are handled in new Processes, these values
# will change in each request and will not... | true |
f4e7465970c8e42448a33769c19de6cb95a00d68 | Ruby | enkessler/cuke_slicer | /testing/file_helper.rb | UTF-8 | 533 | 2.53125 | 3 | [
"MIT"
] | permissive | require 'tmpdir'
module CukeSlicer
# A helper module that create files and directories during testing
module FileHelper
class << self
def created_directories
@created_directories ||= []
end
def create_directory(options = {})
options[:name] ||= 'test_directory'
opt... | true |
1a67365e50f5af223893ea920c03bb0e2d158bd6 | Ruby | patrickcurl/CodeEvalSolutions | /Ruby/beautifulStrings.rb | UTF-8 | 1,968 | 3.84375 | 4 | [] | no_license | # BEAUTIFUL STRINGS
# CHALLENGE DESCRIPTION:
# Credits: This problem appeared in the Facebook Hacker Cup 2013 Hackathon.
# When John was a little kid he didn't have much to do. There was no internet, no Facebook, and no programs to hack on. So he did the only thing he could... he evaluated the beauty of strings ... | true |
a8b4344d14f03e9336c102b82c8b7941c77aac61 | Ruby | grzegorzzajac1989/theOdinProject | /ruby/building_blocks/stock_picker.rb | UTF-8 | 657 | 3.4375 | 3 | [] | no_license | def stock_picker( daily_price_array )
best_profit = 0
low_buy = 0
high_sell = 0
daily_price_array.each_with_index do |buy_price, buy_day|
daily_price_array.each_with_index do |sell_price, sell_day|
if buy_day < sell_day
profit = sell_price - buy_price
if profit > best_profit
best_profit = p... | true |
9849545263730cbcef6511d4221b38af8c52a12f | Ruby | aleandros/aleandros.github.io | /tasks.thor | UTF-8 | 1,201 | 2.78125 | 3 | [] | no_license | require 'time'
require 'fileutils'
class Blog < Thor
include Thor::Actions
desc 'post TITLE', 'Create a new post with current date'
def post(title)
@title = title
template('_templates/post.tt',
"_posts/#{date_string}-#{title_string}.markdown")
end
desc 'draft TITLE', 'Create a draft wi... | true |
d7549f921c5e60760be43beb908f0d102c243f08 | Ruby | cantlin/tfl | /lib/main_line.rb | UTF-8 | 1,596 | 3 | 3 | [] | no_license | require 'date'
require 'uri'
require 'cgi'
class MainLine < App
attr_accessor :num_results
def set_defaults
self.num_results = 5
end
def departures station, num_results = nil
url = "http://ojp.nationalrail.co.uk/service/ldb/liveTrainsJson?departing=true&liveTrainsFrom=#{URI::encode(station)}&liveTrainsTo="
... | true |
c0366e9c644b52708e845b2cbbdc00fd3ba9da52 | Ruby | ralphreid/WDI_LDN_3_Work | /ralphreid/w2d5/classwork/movies_app/model/movie.rb | UTF-8 | 1,241 | 3.0625 | 3 | [] | no_license | class Movie
def initialize connection
@connection = connection
end
def all
@connection.exec "SELECT * FROM movies" #retun is implicit in ruby
end
def find id
@movie = @connection.exec("SELECT * FROM movies WHERE id=#{id }").first
end
def create params # TIP - called the argument params so... | true |
d243d7046e07df14fef4165fb70bba7320a6d029 | Ruby | 18F/identity-idp | /app/components/step_indicator_component.rb | UTF-8 | 898 | 2.6875 | 3 | [
"CC0-1.0",
"LicenseRef-scancode-public-domain"
] | permissive | class StepIndicatorComponent < BaseComponent
attr_reader :current_step, :locale_scope, :tag_options
def initialize(steps:, current_step:, locale_scope: nil, **tag_options)
@steps = steps
@current_step = current_step
@locale_scope = locale_scope
@tag_options = tag_options
end
def css_class
... | true |
e775c36bafdc661da60b376f114409812ecae8f3 | Ruby | aaronjwagener/my_coop | /db/seeds.rb | UTF-8 | 1,183 | 2.75 | 3 | [
"MIT"
] | permissive | # This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
User.create!(name: "Example User",
email: "example@example.com",
password: ... | true |
b803387f27cff5334527e4b0ba6040e0fc5f14c5 | Ruby | cielavenir/procon | /codeforces/tyama_codeforces004C.rb | UTF-8 | 140 | 2.84375 | 3 | [
"0BSD"
] | permissive | #!/usr/bin/ruby
h={}
gets.to_i.times{|i|
x=s=gets.chomp
if !h[s]
h[s]=0
puts :OK
else
h[s]+=1
puts s+h[s].to_s
end
} | true |
6d0173ea6831d1875437bb85b28f7a873d70acea | Ruby | Odebe/Tabi | /baka/paragraph.rb | UTF-8 | 152 | 2.59375 | 3 | [] | no_license | # frozen_string_literal: true
module Baka
class Paragraph
attr_reader :text
def initialize(text)
@text = text.strip
end
end
end
| true |
703ccc976fcdac6614259358fb2ffed67d0f5302 | Ruby | jhbadger/scripts | /parseTIGRCoords | UTF-8 | 328 | 2.65625 | 3 | [] | no_license | #!/usr/bin/env ruby
# converts TIGR coords file to one that PyPhy, etc. can use
if (ARGV.size != 1)
STDERR.printf("usage: %s coord-file\n", $0)
exit(1)
end
file = ARGV.shift
orf = "00001"
File.new(file).each {|line|
start, stop = line.split(" ")
printf("%10s %6s %6s\n", "ORF" + orf, start, stop)
orf = orf... | true |
1792ad150d66ea27d1993eb59f1b5ad8b2471002 | Ruby | bver/GERET | /sample/santa_fe_ant_trail/animate.rb | UTF-8 | 321 | 2.765625 | 3 | [
"MIT"
] | permissive |
$: << 'sample/santa_fe_ant_trail'
require 'ant'
abort "use:\n #$0 ant_code.rb\n" unless ARGV.size==1
code = IO.read ARGV[0]
ant = Ant.new
while ant.steps < Ant::MaxSteps
eval code
puts ant.show_scene
puts "food items consumed: #{ant.consumed_food}"
puts "steps elapsed: #{ant.steps}"
$stdin.gets
end
... | true |
a324a11f492b87f4514ad52310830388b4b8b1a7 | Ruby | carlosmartinez/questions-to-anki-cards | /app.rb | UTF-8 | 208 | 2.578125 | 3 | [] | no_license | input_lines = File.read("./input.txt").split("\n")
output_lines = input_lines.each_slice(3).map do |question, answer, _space|
"#{question};#{answer}"
end
File.write("./output.txt", output_lines.join("\n"))
| true |
1ecdf01f60701934956bf59728b9de500ed75ae1 | Ruby | Kyle-Schiffli/Launch_101 | /lesson_2/rock_paper_scissors.rb | UTF-8 | 888 | 3.71875 | 4 | [] | no_license | def prompt(message)
puts "=> #{message}"
end
def display_results(player, computer)
if (player == 'rock' && computer == "scissors") ||
(player == 'scissors' && computer == "paper") ||
(player == 'paper' && computer == "rock")
prompt('You Win!')
elsif (player == 'rock' && computer == "paper") ||
... | true |
a00469aa8d81416caafe743c525a086a4071ef3b | Ruby | MelahatMindivanli/odev-01ruby | /address_book.rb | UTF-8 | 731 | 3.78125 | 4 | [] | no_license | require 'csv'
require './person.rb'
class AddressBook
attr_accessor :people #Getter ve Setter
def initialize(csv_path) #Constructor
@people = []
#print '#'
CSV.foreach(csv_path,{ :col_sep => ',' }) do |row|
people.push(Person.new(row[0],row[1],row[2],row[3]))
end
end
def print_people
... | true |
97743c705a74a165653b4d6fb572c0c2131cf858 | Ruby | morfious902002/spring_2012 | /petstore/spec/support/basic_data_helpers.rb | UTF-8 | 394 | 2.578125 | 3 | [] | no_license | def get_key
@@key ||= 0
@@key += 1
@@key.to_s
end
def basic_pet_data(options = {})
{:name => "pet#{get_key}", :species => "dog"}.merge(options)
end
def basic_user_data(options = {})
{:email => "b#{get_key}@.test.com", :password_digest => "1234x#{get_key}"}.merge(options)
end
def new_valid_user
u = User.... | true |
5d0e762b4d1220ebe394267f7bda5f16da6f240a | Ruby | lingzhuzi/one_config | /app/models/user.rb | UTF-8 | 852 | 2.71875 | 3 | [] | no_license | require 'digest'
class User < ApplicationRecord
validates :login, presence: true, uniqueness: true
validates :password, confirmation: true, length: { minimum: 6 }
validates :password_confirmation, presence: true
before_save :generate_salt
before_save :encrypt_password
def authenticate(password_text)
... | true |
256e4399f53fcce9f126e1e5658eb9b879965039 | Ruby | tenderlove/concurrent-ruby | /lib/concurrent/exchanger.rb | UTF-8 | 870 | 3.484375 | 3 | [
"Ruby",
"MIT"
] | permissive | module Concurrent
class Exchanger
EMPTY = Object.new
def initialize(opts = {})
@first = MVar.new(EMPTY, opts)
@second = MVar.new(MVar::EMPTY, opts)
end
# @param [Object] value the value to exchange with an other thread
# @param [Numeric] timeout the maximum time in second to wait fo... | true |
5c43aef31cdc80f03488b74d00e326752ebdfe3a | Ruby | bweave/advent-of-code-2017 | /test/day_5_test.rb | UTF-8 | 598 | 2.953125 | 3 | [] | no_license | require "byebug"
require "minitest/autorun"
require "minitest/pride"
require_relative "../day_5"
class Day5Test < Minitest::Test
def test_maze_steps
instructions = [0,3,0,1,-3]
assert 5, Maze.steps(instructions)
instructions = File.readlines("day_5_input.txt").map(&:to_i)
puts "\nsteps: #{Maze.steps... | true |
d00de4c96bd55248adf819d985e81be245a9588c | Ruby | EricLarson2020/futbol | /lib/game_teams.rb | UTF-8 | 862 | 2.640625 | 3 | [] | no_license | class GameTeams
attr_reader :game_id, :team_id, :hoa, :result, :settled_in, :head_coach,
:goals, :shots, :tackles, :pim, :powerplayopportunities, :powerplaygoals,
:faceoffwinpercentage, :giveaways, :takeaways
def initialize(stats)
@game_id = stats[:game_id].to_i
@team_id = stat... | true |
16b8bab46c6d3a53f42775c0b497dd0e70ee4815 | Ruby | jzajpt/persistence | /spec/unit/object_factory_spec.rb | UTF-8 | 1,351 | 2.53125 | 3 | [] | no_license | # encoding: utf-8
require 'spec_helper'
class PersistenceTestObject
attr_accessor :id
end
describe Persistence::ObjectFactory do
describe '#materialize' do
let(:factory) { Persistence::ObjectFactory.new hash }
let(:id) { BSON::ObjectId.new }
let(:hash) { { _type: 'PersistenceTestObject', _id:... | true |
ac2cc4c5d5c5f97978ff93ad1088278045173680 | Ruby | SlipperyJ/rubycode | /cars.rb | UTF-8 | 976 | 4.03125 | 4 | [] | no_license | class Car
#instance variables
@manufacturer = ""
@type = ""
@model = ""
@speed = 0
#Setter method
def set_manufacturer(manufacturer)
@manufacturer = manufacturer
end
#Getter method
def get_manufacturer
@manufacturer
end
def set_type(type)
@type = type
end
def set_type
... | true |
76b44e1b13835aa9d2a874b6b3a11df803732b27 | Ruby | ty-doerschuk/phase-0 | /week-6/guessing-game/my_solution.rb | UTF-8 | 3,485 | 4.5 | 4 | [
"MIT"
] | permissive | # Build a simple guessing game
# I worked on this challenge [by myself, with: ].
# I spent [#] hours on this challenge.
# Pseudocode
# Input: initialized with an integer called 'answer'
# Output: a symbol if the the integer is low, high, or correct
# Steps:
=begin
1. Define class method
2. DEFINE initialize with 'a... | true |
1e31d284150a5c21b5e9ccd67f449851da8fdc16 | Ruby | plato721/head-first-design-ruby | /factory/spec/pizza_examples.rb | UTF-8 | 614 | 2.796875 | 3 | [] | no_license | shared_examples "a pizza" do |pizza|
it "can be cut" do
expect(pizza).to respond_to(:cut)
end
it "can be baked" do
expect(pizza).to respond_to(:bake)
end
it "can be boxed" do
expect(pizza).to respond_to(:box)
end
it "has a settable name" do
pizza.name = "Moses"
expect(pizza.name).to... | true |
634631159f22a4e068a623f5be01b040065481b9 | Ruby | andrewhao/cyclecity-core | /app/models/velocitas_core/gpx_downloader.rb | UTF-8 | 1,664 | 2.578125 | 3 | [] | no_license | # Downloads a URL to a local file on the worker
module VelocitasCore
class GpxDownloader
include Interactor
delegate :url, :filename, :attachment, to: :context
attr_accessor :response
#attr_accessor :url, :response, :filename
# @param [String] url The URL to the GPX file.
# @param [String] f... | true |
9e9ea7261a473a72f3f141abd6df2084a38961b0 | Ruby | vamsipavanmahesh/problem-solving | /factorial.rb | UTF-8 | 162 | 4.03125 | 4 | [] | no_license | def factorial(n)
if n == 1
return 1
else
return n * factorial(n-1)
end
end
puts "enter a number to find the factorial for"
n = gets.to_i
puts factorial(n) | true |
d09878fb53aa190286eb92c0eb799ce0c8d7e1e0 | Ruby | Ingenico-ePayments/connect-sdk-ruby | /lib/ingenico/connect/sdk/defaultimpl/default_marshaller.rb | UTF-8 | 1,124 | 2.75 | 3 | [
"MIT"
] | permissive | require 'json'
require 'singleton'
module Ingenico::Connect::SDK
module DefaultImpl
# marshals objects to and from JSON format.
# Currently supports marshalling and unmarshalling of classes that support class.new_from_hash and class#to_h
class DefaultMarshaller < Ingenico::Connect::SDK::Marshaller
... | true |
726e15288c3eb0c42cce98af7d987aae4cbe3429 | Ruby | Brayan9105/Exercises | /classesExercise/even_fib.rb | UTF-8 | 883 | 3.46875 | 3 | [] | no_license | # frozen_string_literal: true
require 'minitest/autorun'
# Some documentation
class Fibonnaci
attr_reader :fibs_numbers
attr_reader :even_sum
def initialize
@fibs_numbers = [0, 1]
@i = 2
@even_sum = 0
end
def find_sequence(last_element)
if last_element > @i
loop do
@fibs_numb... | true |
b41feea4779fb7eda3d2527b89d7a4752995b540 | Ruby | TerribleDev/zanzibar | /lib/zanzibar/cli.rb | UTF-8 | 5,037 | 2.609375 | 3 | [
"Apache-2.0"
] | permissive | require 'thor'
require 'thor/actions'
require 'zanzibar/version'
require 'zanzibar/cli'
require 'zanzibar/ui'
require 'zanzibar/actions'
require 'zanzibar/error'
require 'zanzibar/defaults'
module Zanzibar
##
# The `zanzibar` binary/thor application main class.
# See http://whatisthor.com/ for information on syn... | true |
edfd5670bbf57f32813ec7053f48fa57c82b83f5 | Ruby | itggot-ludvig-ohlsson/standard-biblioteket | /lib/is_odd.rb | UTF-8 | 240 | 4.03125 | 4 | [] | no_license | # Public: Check if a number is odd.
#
# num - The Integer to be checked.
#
# Examples
#
# is_odd(1337)
# # => true
#
# is_odd(420)
# # => false
#
# Returns if the number is odd or not.
def is_odd(num)
return num % 2 == 1
end | true |
8a25e649b8c678585f68721bc24fc938ac3c638c | Ruby | chrisbrickey/tdd-minesweeper | /lib/game.rb | UTF-8 | 604 | 3.765625 | 4 | [] | no_license | require 'board'
require 'tile'
class Game
def self.prompt_user
puts "What size of board do you want to play on? (type an integer between 3 and 100, inclusive)\n"
size = gets.chomp
while !size.to_i.between?(3, 100)
puts "Please type an integer between 3 and 100, inclusive.\n"
size = gets.chom... | true |
2593b63042775afdad44c62389e0f58c5e1835cd | Ruby | dhaas/limecast | /vendor/plugins/scenarios/lib/scenarios/extensions/symbol.rb | UTF-8 | 325 | 2.75 | 3 | [
"MIT"
] | permissive | class Symbol
# Convert a symbol into the associated scenario class:
#
# :basic.to_scenario #=> BasicScenario
# :basic_scenario.to_scenario #=> BasicScenario
#
# Raises Scenario::NameError if the the scenario cannot be loacated in
# Scenario.load_paths.
def to_scenario
to_s.to_scenario
end
... | true |
ffc566fdbd595b6e2b2c74bffa0dadaacb4c938c | Ruby | DomyDoo/Launch-School-Intro-to-Programming | /the-basics-exercises/exercises.rb | UTF-8 | 1,661 | 4.46875 | 4 | [] | no_license | # The exercises at the end of The Basics section
# Exercise 1
puts "\nAnswer to Exercise 1:"
first_name = "Domenic"
last_name = "Carobine"
puts first_name + " " + last_name
# Exercise 2
puts "\nAnswer to Exercise 2:"
num = 9934
puts "The number in the thousands place is: #{num / 1000}"
puts "The number in the hund... | true |
f4ab3b5c6a62069a80b25c660280b3c574fc4623 | Ruby | dtuite/wordpaths | /lib/string_refinements.rb | UTF-8 | 303 | 3.015625 | 3 | [] | no_license | module StringRefinements
refine String do
def split_before_each_char
0.upto(self.length).map { |i| [self[0...i], self[i..-1]] }
end
def split_around_each_char
self.chars.each_with_index.map do |char, i|
[self[0...i], char, self[(i+1)..-1]]
end
end
end
end
| true |
0cab706cb82259babdb6cfaa1e14b9f294537c9b | Ruby | bayendor/mastermind | /lib/game.rb | UTF-8 | 1,636 | 3.3125 | 3 | [
"MIT"
] | permissive | require_relative 'message_printer'
class Game
attr_accessor :command,
:guess,
:code,
:printer,
:turns,
:guess_checker,
:start_time,
:end_time
def initialize(printer = MessagePrinter.new)
@command = ... | true |
d7683a037707b0a0bac68f0d0565cd8ffde33331 | Ruby | apoc64/black_thursday | /lib/customer_repository.rb | UTF-8 | 834 | 2.90625 | 3 | [] | no_license | require 'csv'
require_relative 'customer'
require_relative 'repository'
# This class is a repo for customers
class CustomerRepository
include Repository
def initialize
@elements = {}
end
def build_elements_hash(elements)
elements.each do |element|
customer = Customer.new(element)
@elements... | true |
7f51c12d2898e8689b060ed044aaa980dee6ec29 | Ruby | mattcaesar/App-Academy | /3 Ruby/2 Ghost/v1 code/game.rb | UTF-8 | 2,096 | 3.8125 | 4 | [] | no_license | require './player.rb'
class Game
attr_reader :fragment
def initialize(player1_name, player2_name)
#@players = []
@player1 = Player.new(player1_name)
@player2 = Player.new(player2_name)
@fragment = []
@current_player = @player1
dictionary_arr = File.open('dicti... | true |
78c3aeca73d3baa4ad00bedb8e2c2e2caa4f8978 | Ruby | AndrewHannigan/studimetrics | /app/models/null_section_completion.rb | UTF-8 | 274 | 2.65625 | 3 | [] | no_license | class NullSectionCompletion
attr_accessor :section
delegate :name, to: :section, prefix: true
def initialize(section=nil)
self.section = section
end
def status
"Not Started"
end
def in_progress?
false
end
def completed?
false
end
end
| true |
7da5deb76e1597429eda1f9e2d8feeaf5eab23d0 | Ruby | mredmond0919/LS1 | /RB100/exercises/intro_book/exercises/loops2.rb | UTF-8 | 137 | 3.4375 | 3 | [] | no_license | while 1
puts "Type what ever you want and it repeats. Type STOP to stop"
text = gets.chomp
if text == "STOP"
break
end
puts text
end
| true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.