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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
57749122f7a002854848d2ec87468f81430d3c23 | Ruby | teresa-m-knowles/backend_prework | /day_7/fizzbuzz.rb | UTF-8 | 605 | 4.59375 | 5 | [] | no_license | puts "This program prints numbers in any range. For any number that is a multiple of 3, it prints 'Frizz'.
For any number that is a multiple of 5, it prints 'Buzz'.
For any number that is a multiple of both 3 and 5, it prints 'FizzBuzz'.
For all other numbers, it prints the number "
puts "If we start at 0, what's the ... | true |
0800856ab207faefea98eb28763dd184e04ca135 | Ruby | spurton/dm-more | /dm-types/spec/unit/epoch_time_spec.rb | UTF-8 | 1,516 | 2.515625 | 3 | [
"MIT"
] | permissive | require 'pathname'
require Pathname(__FILE__).dirname.parent.expand_path + 'spec_helper'
describe DataMapper::Types::EpochTime do
describe ".dump" do
describe "when given Time instance" do
before :all do
@input = Time.now
end
it "returns timestamp" do
DataMapper::Types::EpochT... | true |
15328faebd57753f06c15da95a58dcdc1ad58567 | Ruby | malfix/kata-findLongestSequence | /exercise.rb | UTF-8 | 392 | 3.171875 | 3 | [] | no_license | class Exercise
def find(*list)
prev_element, longest_sequence, current_sequence = list[0], 0, 0
list.sort().each do |current_element|
current_sequence = (prev_element == current_element - 1) ? current_sequence + 1 : 1
prev_element = current_element
longest_sequence = current_sequence if cur... | true |
d33c98536f6c72c006e094a1c2775df31376186b | Ruby | gameda/prfOperativos | /Memoria.rb | UTF-8 | 1,235 | 3.0625 | 3 | [] | no_license | require './Marco'
class Memoria
def initialize(cantBytes, tamPagina)
@cantBytes = Integer(cantBytes)
@tamPagina = Integer(tamPagina)
if @cantBytes <= 0
@cantBytes = 1
end
if @tamPagina <= 0
@tamPagina = 1
end
@cantMarcos = @cantBytes/@tamPagina
if @cantMarcos <= 0
@cantMarcos = 1
end
... | true |
2b6bac3e343275e3e6fe54ceadcc8c5f174db59a | Ruby | cindyn11/ruby_challenges | /hello.rb | UTF-8 | 194 | 3.671875 | 4 | [] | no_license | puts "Hello, Ruby World!!"
if 2 + 2 == 4
puts "All is right with the world!"
elsif 2 + 2 == 5
puts "2 + 2 is more than the sum of its parts"
else
puts "All is NOT right with the world!"
end
| true |
05c4260dbd7f5d5e0bd2f5997c739ca74279bf86 | Ruby | MarcinBalejko/Ruby | /tablecontents.rb | UTF-8 | 392 | 3.34375 | 3 | [] | no_license | toc = ['Table of Contents', 'Chapter 1: Getting Started', 'page 1','Chapter 2: Numbers','page 9',
'Chapter 3: Letters','page 13']
page_width = 60
puts (toc[0].center(page_width))
puts ''
puts (toc[1].ljust(page_width/2) + toc[2].rjust(page_width/2))
puts (toc[3].ljust(page_width/2) + toc[4].rjust(page_width/2))
... | true |
64256c76bd9cae1324b574f7a4c586d506d69f9e | Ruby | mpalmer/puppet-module-dnsquery | /lib/puppet/parser/functions/dns_a.rb | UTF-8 | 582 | 2.546875 | 3 | [
"MIT"
] | permissive | require 'resolv'
module Puppet::Parser::Functions
newfunction(:dns_a, :type => :rvalue, :doc => <<-EOS
Retrieves DNS A records and returns it as an array. Each record in the
array will be an IPv4 address.
EOS
) do |arguments|
res = Resolv::DNS.new
arguments.flatten.map do |name|
unless name.is_a? Str... | true |
d4a27766b440662c97e4659148519f9c842d627b | Ruby | Kyero/vignette | /lib/vignette.rb | UTF-8 | 3,145 | 2.515625 | 3 | [
"MIT"
] | permissive | require "active_support/core_ext/module/attribute_accessors"
require "action_controller"
require "vignette/version"
require "vignette/object_extensions"
require "vignette/filter"
module Vignette
module Errors
class VignetteStandardError < StandardError; end
class ConfigError < VignetteStandardError; end
... | true |
188486dc64b793baae33643da949dbe0e24121f7 | Ruby | Bumsuk/MyRubyBase | /08-013-instance_variable.rb | UTF-8 | 478 | 3.328125 | 3 | [] | no_license | class Duration
def initialize(since, till)
@since = since
@until = till
end
attr_accessor :since, :until # 属性へのgetterとsetterを定義する
end
class Duration # 例7-6の定義を再オープン
def print_since; p @since end
end
duration1 = Duration.new(Time.now-7, Time.now)
duration2 = Duration.new(Time.now+7, Time.now+14)
dur... | true |
d58596c0fbb598075af46d1040b901933ed9448f | Ruby | polfliet/demo-deployer | /src/common/logger/logger_factory.rb | UTF-8 | 909 | 2.859375 | 3 | [
"Apache-2.0"
] | permissive | require './src/common/logger/info_logger'
require './src/common/logger/debug_logger'
require './src/common/logger/error_logger'
module Common
module Logger
class LoggerFactory
def self.set_logging_level(logging_level = "error")
@logging_level = logging_level
@logger = nil
end
... | true |
07a5781bceec84ddb1cb2a983738c559d5797412 | Ruby | harakonan/misc-codes | /Ruby/Exploring_Everyday_Things/Chap4/Restroom_test.rb | UTF-8 | 1,191 | 2.953125 | 3 | [] | no_license | Dir.chdir("./Exploring_Everyday_Things/Chap4")
require './Restroom_class'
DURATION = 60*9
frequency = 3
use_duration = 1
population_size = 10
facilities_per_restroom = 3
restroom = Restroom.new
p restroom
restroom.facilities.each do |facility|
print(facility, " o=", facility.occupier, " d=", facility.... | true |
8d92149ff95efdc8988d2bedbff17da5984e5833 | Ruby | diogolsq/SpaceCobra | /lib/food.rb | UTF-8 | 390 | 3 | 3 | [] | no_license | class Food
attr_accessor :x, :y
def initialize(tile, width, height)
@x = 15
@y = 15
@tile = tile
@width = width
@height = height
end
def update
end
def draw
Gosu.draw_rect(@x * @tile,
@y * @tile,
@tile - 1,
@tile - 1,
Gosu::Color::RED)
end
def respawn
... | true |
98576584ff3946368661e636bf35b7011cd14269 | Ruby | charleshenriponiard/01-Food-Delivery | /router.rb | UTF-8 | 791 | 3.078125 | 3 | [] | no_license | # TODO: implement the router of your app.
require 'pry-byebug'
class Router
def initialize(meals_controller, sessions_controller, orders_controller)
@meals_controller = meals_controller
@sessions_controller = sessions_controller
@orders_constroller = orders_controller
end
def run
puts " > conn... | true |
d88ca869182c916505bffafb5878671ddec7ef47 | Ruby | rymo4/gunslinger | /genetic_optimization.rb | UTF-8 | 2,933 | 3.40625 | 3 | [] | no_license | require 'rubygems'
require 'java'
include_class 'gunslinger.sim.Gunslinger'
class Chromosome
attr_accessor :genes
MUTATION_P = 0.8
def initialize genes, features, eval_f, res, step_sizes
@features = features
@eval_f = eval_f
@genes = genes
@res = res
@fitness = nil
@genes = genes
@s... | true |
bf895191e1da6103ce905b911d05139deebc0082 | Ruby | Chikey1/website | /code/qa_selenium_css.rb | UTF-8 | 12,739 | 2.671875 | 3 | [] | no_license | require 'selenium-webdriver'
require 'nokogiri'
require 'pry'
$username = 'sara.qi'
$password = 'Welcome1234'
class TelevoxQA
attr_accessor :driver_old, :driver_new, :old_domain, :new_domain
def initialize(old_domain, new_domain)
self.driver_old = Selenium::WebDriver.for :chrome
self.driver_n... | true |
2a590e623158ae5dd9038f078dda16c0765677b6 | Ruby | wmwaqas/day-8-codaisseurup | /app/models/event.rb | UTF-8 | 639 | 2.5625 | 3 | [] | no_license | class Event < ApplicationRecord
belongs_to :user, optional: true
has_and_belongs_to_many :categories
has_many :photos, dependent: :destroy
has_many :registrations, dependent: :destroy
has_many :guests, through: :registrations, source: :user
validates :name, presence: true
validates :description, presence:... | true |
deb4f7ad4e32b19b9f7ca5b6fb109a8674deb71f | Ruby | dodona-edu/dodona | /test/renderers/rouge_test.rb | UTF-8 | 1,489 | 2.6875 | 3 | [
"MIT"
] | permissive | require 'test_helper'
require 'builder'
class RougeTest < ActiveSupport::TestCase
include Rails.application.routes.url_helpers
include ApplicationHelper
test 'markdown should have added class for language' do
input_python = "```python3\ndef mysum(a, b, c);\n return a + b + c\n```\n"
input_java = "```... | true |
c455b9db6f5703f8b8ac2146ee37d80f2311576c | Ruby | jadeyen/CS61APrepCourse | /ch14/grandfatherClock.rb | UTF-8 | 274 | 3.4375 | 3 | [] | no_license | def grandfather_clock block
hours = Time.new.hour
if hours > 12
hours -= 12
elsif hours == 0
hours = 12
else
hours = hours
end
hours.times do
block.call
end
end
with_sounds = Proc.new do
puts 'DONG!'
end
puts grandfather_clock(with_sounds)
| true |
ea93a6ae171bdc0a550200e198a8c8c242adc18e | Ruby | thejasonfile/theodinproject | /LearnToProgram/arrays.rb | UTF-8 | 136 | 3.453125 | 3 | [] | no_license | word = gets.chomp
array = []
while word.length > 0
array.push word
word = gets.chomp
if word.length == 0
puts array.sort
end
end
| true |
d44b330ec374b9f2c5d230a57ded7e725ce9923f | Ruby | ayush-amura/Assignments | /assignment_3.rb | UTF-8 | 254 | 3.53125 | 4 | [] | no_license | require 'benchmark'
#Summation
def sum_n(n)
a = n.abs+1
arr = []
sum = 0
0.upto(a) do |index|
n<0 ? sum = sum - index : sum = sum + index
arr << sum
end
return arr
end
p sum_n(5)
p sum_n(-5)
puts Benchmark.measure{ sum_n(5) }
| true |
02b66a5a64b83b77a089aef94464ee25a0a610ea | Ruby | cbrwizard/perfect-s-bot | /bot.rb | UTF-8 | 778 | 2.65625 | 3 | [
"MIT"
] | permissive | require 'hipbot'
require_relative 'sporty_brains'
class PerfectSBot < Hipbot::Bot
class << self
def brains
@brains ||= SportyBrains
end
def bot_mention
@bot_mention ||= self.name
end
def add_brains_to_bot(response)
brains.init(response: response, bot: self)
end
def us... | true |
9ad6a755886cab033f60b1c80a9106ac1ac17bf2 | Ruby | DungSama/Exercise_Ruby | /ruby/basic/b1.rb | UTF-8 | 234 | 2.953125 | 3 | [] | no_license | #Viết chương trình tìm tất cả các số chia hết cho 7 nhưng không phải bội số của 5, nằm trong đoạn 10 và 200 (tính cả 10 và 200).
(10..200).each do |i|
if i % 7 == 0 && i % 5 != 0
puts i
end
end | true |
f1a4d02a93a67c72aa07e312f1372f86b7ada4ec | Ruby | leighhalliday/idioma | /spec/models/phrase_extractor_spec.rb | UTF-8 | 1,501 | 2.515625 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe Idioma::PhraseExtractor do
let(:mocked_translations) {
{
en: {
validations: {presence: "must be present"}
}
}
}
describe "get_translations" do
it "returns the translations in the locales files" do
expect(Idioma::PhraseExtractor.get_translatio... | true |
fe445a01b87a4b8e0fe2b03e20bb7589e609d3ed | Ruby | michaelveloso/LaunchAcademy_challenge_Day26-28 | /spec/features/user_posts_a_question_spec.rb | UTF-8 | 3,095 | 2.625 | 3 | [] | no_license | require 'rails_helper'
LONG_STRING = 'The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation ... | true |
fde24f5620ce7b32154abb88979fa16df5bbce45 | Ruby | dbsk11/ruby-oo-relationships-practice-auto-shop-exercise-nyc01-seng-ft-042020 | /app/models/car.rb | UTF-8 | 872 | 3.09375 | 3 | [] | no_license | class Car
attr_reader :make, :model, :owner, :classification, :mechanic
@@all = []
def initialize(owner, make, model, classification, mechanic)
@owner = owner
@make = make
@model = model
@mechanic = mechanic
@classification = classification
Car.all << self
end
def self.all
@@al... | true |
88d77c96f342ad76281d0b3724bebe42379f193a | Ruby | deepcerulean/vortex | /lib/vortex/models/player.rb | UTF-8 | 1,695 | 2.578125 | 3 | [
"MIT"
] | permissive | module Vortex
class Player < Metacosm::Model
attr_accessor :name, :location, :velocity, :acceleration, :color, :updated_at, :pinged_at
belongs_to :game
before_create :assign_color
def assign_color
self.color ||= %w[ red green blue ].sample
end
def recompute_location
t = Time.now
... | true |
7f3de052f2666e970d1ba8bec517f618a02a61d3 | Ruby | htlcnn/FAMILUG | /ruby/pe003.rb | UTF-8 | 486 | 3.609375 | 4 | [
"BSD-2-Clause"
] | permissive | #!/usr/bin/env ruby
class PE003
def largest_prime_factor_of(n)
# dont check 2 because number given is odd
factor = 3
while n != 1
while n % factor == 0
n /= factor
end
last = factor
factor += 2
end
return last
... | true |
e68b72124fe2932c0a3d7c999089c26b13dfc5f2 | Ruby | vedesh/oracle_chef_repo | /chef-repo/ruby_code/homework.rb | UTF-8 | 508 | 3.796875 | 4 | [] | no_license |
class MyClass
attr_accessor :variable1
attr_accessor :variable2
attr_accessor :variable3
def setterMethod (variable1)
@variable1 = variable1[0]
@variable2 = variable2[1]
@variable3 = variable3[2]
return ["variable1", "variable2" , "variable3"]
end
end
MyClassObj = MyClass.new
#result1 = MyClassObj.se... | true |
c739540d44efb44f5eea11566101df7c5321a8c5 | Ruby | zakkana/sample_repository | /class_sample.rb | UTF-8 | 439 | 4.03125 | 4 | [] | no_license | class Hito
def initialize(h, w)
@height = h
@weight = w
end
def bmi
@weight / (@height ** 2)
end
def hantei
puts "高い" if @height >= 1.6
puts "普通" if @height <1.6 && @height > 1.2
puts "低い" if @height <= 1.2
end
end
hito = Hito.new(1.6, 60)
hito2 = Hito.new(1.7, 89)
hito3 = Hito.new... | true |
9f7791942db8f3dd20d5d473c881392bff2c0673 | Ruby | dianamora/cli_project | /lib/characters.rb | UTF-8 | 778 | 3.234375 | 3 | [
"MIT"
] | permissive | #where objects are created and stored for user display, aka StarWars characters
class Characters
attr_accessor :name, :gender, :url, :birth_year
@@all = []
def initialize(name, url)
@name = name
@url = url
@@all << self
end
# def name #getter
# @name
# end
... | true |
1f50d1dde0ddec7ddfab0df8bcd9cada8c818e1f | Ruby | jbox-web/crono | /lib/crono/cli.rb | UTF-8 | 3,956 | 2.625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | # frozen_string_literal: true
Thread.abort_on_exception = true
# require external dependencies
require 'optparse'
# require ourself
require 'crono'
module Crono
# Crono::CLI - The main class for the crono daemon exacutable `bin/crono`
class CLI
include Singleton
include Util
attr_accessor :config
... | true |
1394ee69b9c763a14c75e478ff2cb4d5770ac0fc | Ruby | ahmad19/gilded_rose_refactoring_kata | /lib/sulfuras.rb | UTF-8 | 202 | 2.75 | 3 | [] | no_license | class Sulfuras
attr_reader :name, :sell_in, :quality
def initialize(name, sell_in, quality)
@name = name
@sell_in = sell_in
@quality = quality
end
def update
quality
end
end
| true |
75be8c0ced0e781f003ffb6fccc1dc6cb31c5c79 | Ruby | vanessasgit/pragmatic_studio_ruby | /studio_game/studio_game.rb | UTF-8 | 612 | 2.625 | 3 | [] | no_license | require_relative 'game'
player1 = Player.new("moe")
player2 = Player.new("larry", 60)
player3 = Player.new("curly", 125)
knuckleheads = Game.new("Knuckleheads")
knuckleheads.add_player(player1)
knuckleheads.add_player(player2)
knuckleheads.add_player(player3)
knuckleheads.play(2)
knuckleheads.print_stats
chipmun... | true |
4979b7518106d05b45cd5993917a04af7cf617b6 | Ruby | diautzi/alphabetize-in-esperanto-chicago-web-career-040119 | /lib/alphabetize.rb | UTF-8 | 254 | 3.546875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # how to sort an array of strings based on a non-standard alphabet!
def alphabetize(arr)
# code here
esperanto_alphabet = "abcĉdefgĝhĥijĵklmnoprsŝtuŭvz"
ascii = "@-\\"
arr.sort_by do |string|
string.tr(esperanto_alphabet, ascii)
end
end
| true |
a6f0434c44e2916aeff7a9fca569b40570783b18 | Ruby | learn-co-students/chicago-web-080320 | /02-intro-to-oo/run.rb | UTF-8 | 1,619 | 3.890625 | 4 | [] | no_license | require 'pry'
class BankAccount
attr_accessor(:balance)
# attr_reader :account_number
# class variable
# class variables are available to class methods, as well as instance methods
@@all = []
def initialize(account_number)
@account_number = account_number
@balance = 1000
@@all << self
e... | true |
b2d868ae76f253cab330e1d4db7a2f01905b17b7 | Ruby | jwass91/flatiron_labs | /hs-oo-stretch-challenges-lab-precollege-se1-nyda-061515-1-master/lib/email_parser.rb | UTF-8 | 460 | 3.5625 | 4 | [] | no_license | # Build a class EmailParser that accepts a string of unformatted
# emails. The parse method on the class should separate them into
# unique email addresses. The delimiters to support are commas (',')
# and spaces (' ').
class EmailParser
def initialize(emails)
@emails = emails
end
def parse
array ... | true |
81930ed859ab72d73eb7b7fd02aba7eda6d7c9be | Ruby | IgnesFatuus/Intro_to_Ruby | /Exercises/Small_Problems/Easy_9/grocery.rb | UTF-8 | 275 | 3.515625 | 4 | [] | no_license | def grocery_list(list)
size = list.size
items = []
for i in 0...size
list[i][1].times { |_| items << list[i][0] }
end
items
end
puts grocery_list([["apples", 3], ["orange", 1], ["bananas", 2]]) ==
["apples", "apples", "apples", "orange", "bananas","bananas"] | true |
b7e351f7d9f940414c1015285ec1c9f18564cb4e | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/bob/7802bb2362544325896d8e4fca249119.rb | UTF-8 | 398 | 4.0625 | 4 | [] | no_license | class Bob
def hey(words)
blank = ->(input_string) { input_string.strip.empty? }
loud = ->(input_string) { input_string == input_string.upcase }
question = ->(input_string) { input_string.end_with? "?" }
case words
when blank
"Fine. Be that way!"
when loud
"Woah, chill out!"... | true |
33f16e2e605db69a86dc91fd4a3a32def1ffd884 | Ruby | ckozus/administrate_me | /lib/administrate_me_base.rb | UTF-8 | 970 | 2.796875 | 3 | [] | no_license | module AdministrateMeBase
# El método set_module toma como parámetros el nombre de módulo a definir y
# opcionalmente un hash de opciones. El hash de opciones permite reemplazar
# los siguientes valores por defecto:
# :caption = Nombre a mostrar en la pestaña. Por defecto se toma el nombre
# del módulo... | true |
9932293ee08fc9f57c2060dc2f774d119b6e96fe | Ruby | itsjayheart/21_shades_of_ruby | /exo_20.rb | UTF-8 | 462 | 3.46875 | 3 | [] | no_license | print "Choisis un nombre d'étages à une pyramide entre 20 et 25 : "
number = gets.chomp.to_i
pyramid_floors = ""
pyramid = [pyramid_floors]
25.times do
if pyramid_floors == ""
pyramid_floors = pyramid_floors + "#"
pyramid[0] = pyramid_floors
else
pyramid_floors = pyramid_floors + "#"
pyramid << py... | true |
23691f71c1f914be88dc23e38a08ffe3dc4e3395 | Ruby | ZsoltFabok/project_euler | /lib/project_euler/problems/problem_17.rb | UTF-8 | 834 | 4.21875 | 4 | [] | no_license | module Problems
# If the numbers 1 to 5 are written out in words: one, two, three, four, five,
# then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total.
#
# If all the numbers from 1 to 1000 (one thousand) inclusive were written out in words,
# how many letters would be used?
#
# NOTE: Do not count spaces o... | true |
f5255dd83fff8dc25ada3d8f726ae8b2eabfa44e | Ruby | manuca/project_tracker | /spec/support/common_repository_examples.rb | UTF-8 | 1,293 | 2.59375 | 3 | [
"MIT"
] | permissive | module ProjectTracker
shared_examples "a repository" do
let(:tennant) { Tennant.new("A tennant") }
let(:client) { Client.new(tennant, "Some client") }
let(:project) { Project.new(tennant, "Project name", client) }
describe "#save" do
it "saves an instance" do
repository.save(project)
... | true |
e3542bdd2cea19f3d13399253739a04392b6f9b8 | Ruby | abarrak/except_nested | /lib/except_nested/core_ext/hash/except_nested.rb | UTF-8 | 1,710 | 3.078125 | 3 | [
"MIT"
] | permissive | require "active_support/core_ext/object/deep_dup"
require "active_support/core_ext/array/wrap"
class Hash
# Returns a hash that includes everything except given nested keys.
# hash = { a: true, b: { x: true, y: false }, c: nil }
# hash.except_nested(:b, :c) # => { a: true }
# hash.except_neste... | true |
ea2c8c1af2b1d70d4506992d67214066c70b048c | Ruby | erik-everardo/proyecto-de-lenguajes-de-progra-ago-dic-18 | /programas/tarea12.rb | UTF-8 | 670 | 3.46875 | 3 | [] | no_license | #Tarea 12
#Nombre: Erik Everardo Cavazos Hernandez
#Matrícula: 1811290
#Clase: Lenguajes de programación V4-V6 Jueves
#Docente: Ismael Pimentel
print("Ingrese la cantidad de numeros deseados: ")
n = gets().to_i
contador_pares = 1
numeros = 0
par_actual = 2
impar_actual = 3
numero_veces_pares=1
while numeros < n
for ... | true |
3bb6a40457c4e9fe3ec1fa9b9df831ba7ac41a55 | Ruby | Tu-tu-tu/fbsd-pentest | /reporting/dradis-nessus/lib/nessus/report_item.rb | UTF-8 | 4,574 | 2.609375 | 3 | [] | no_license | module Nessus
# This class represents each of the /NessusClientData_v2/Report/ReportHost/ReportItem
# elements in the Nessus XML document.
#
# It provides a convenient way to access the information scattered all over
# the XML in attributes and nested tags.
#
# Instead of providing separate methods for ea... | true |
7f4be9550f082ef39ef05ac969d4f52a64635e86 | Ruby | dantelove/101_programming_foundations | /lesson_3_exercises/lesson_3_exercises_medium1_3.rb | UTF-8 | 134 | 3.171875 | 3 | [] | no_license | # lesson_3_exercises_medium1_3.rb
puts "the value of 40 + 2 is #{40 +2}."
puts
puts "the value of 40 + 2 is " + (40 + 2).to_s + "." | true |
010bc4d8bd4ae487e303948a76805e387d33bc59 | Ruby | softscienceprojects/ruby-boating-school-london-web-080519 | /app/models/run.rb | UTF-8 | 671 | 2.6875 | 3 | [] | no_license | #console.rb wouldn't load
require "pry"
require_relative "boatingtest.rb"
require_relative "instructor.rb"
require_relative "student.rb"
#patrick = Student.new("Patrick")
#bt1 # = student, name, status, instructor
#pass_student(student, test)
spongebob = Student.new("Spongebob")
patrick= Student.new("Patrick")
puf... | true |
5c6b97b3b03c9ab2c9bc30ecdff3bee462931158 | Ruby | bsheehy9/ls-challanges | /easy/roman_numerals/roman_numerals.rb | UTF-8 | 1,056 | 4.3125 | 4 | [] | no_license | =begin
Problem:
create a class called RomanNumerals
will need 2 methods:
- initialize method that takes an integer argument
- to_roman which converts integer to string representation
of number
Examples: given as test cases
Data:
- integers
- CONSTANT - hash for roman numberal values
Algorithm:
... | true |
c7819f222430843a6631695443a2c65374dc1c15 | Ruby | sarahtattersall/Othello | /spec_helper.rb | UTF-8 | 392 | 2.84375 | 3 | [] | no_license | require './game' # => consequent classes
class Game
attr_accessor :board, :players
def get_number_human_players
return 2
end
def get_board_size
return 8 # standard size
end
end
class Board
attr_accessor :cells, :size
def change_board( cells )
@cells = cells
end
end
class Player
... | true |
2baa174be13ec3d2778b84df2a13a2987e63ec06 | Ruby | AHdeRojas/dryad-app | /stash/stash-notifier/app/dataset_record.rb | UTF-8 | 2,665 | 2.703125 | 3 | [
"MIT"
] | permissive | require 'active_support/core_ext/object/to_query'
require_relative './config'
require 'nokogiri'
class DatasetRecord
attr_reader :timestamp, :merritt_id, :doi, :version, :title, :raw_xml
# the static method to get records of this DatasetRecord class, this follows an activerecord like pattern
def self.find(star... | true |
795fc5a08e41da31858726a1e21e5e2e721d3f54 | Ruby | nuguidricardo/grit | /lib/open3_detach.rb | UTF-8 | 781 | 2.53125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | module Open3
extend self
def popen3(*cmd)
pw = IO::pipe # pipe[0] for read, pipe[1] for write
pr = IO::pipe
pe = IO::pipe
pid = fork{
# child
fork{
# grandchild
pw[1].close
STDIN.reopen(pw[0])
pw[0].close
pr[0].close
STDOUT.reopen(pr[1... | true |
9f973f44e70415532eca0a0a371c1e1d9ed2aa4f | Ruby | Evelyn651/udemy_ruby_courses | /OOP/project9/manager.rb | UTF-8 | 633 | 3.46875 | 3 | [] | no_license | require "uri"
require "net/http"
require "json"
require "../project9/coin"
class Manager
@@repo = {}
def initialize
initialize_repo
end
def initialize_repo
response = web_scrap
json = JSON.parse(response)
for symbol, values in json
coin = Coin.new(symbol, values['USD'], values['EUR'])
@@repo[symbol... | true |
cf2ec7f040b290d3f68a95480fb691950e36a703 | Ruby | ForensicTools/BTCompare_-475-2151_Herting | /lib/btcompare/result.rb | UTF-8 | 1,918 | 3.125 | 3 | [
"MIT"
] | permissive |
module BTCompare
# Holds the result of a comparison. When Result is created its
# variables are writable. It is strongly encouraged that developers
# using this class run the method lock on the object as soon as
# the data has been set in the object.
class Result
# Files have same piece count
attr_accessor... | true |
6050088712ef4a3efece9544939bd582c024655e | Ruby | James-C-Wilson/launchschool_organized_answers | /easy_1.rb | UTF-8 | 3,007 | 4.96875 | 5 | [] | no_license | # Repeat Yourself
# Write a method that takes two arguments, a string and a positive integer, and prints the string as
# many times as the integer indicates.
=begin
# (Understand the) Problem:
- Identify expected input and output:
- input:
- 2 arguments:
- string
- positive integer
... | true |
12f26bb347fc9dc14228162fbf0bd24c9c652e77 | Ruby | ellehallal/LRTHW | /ex17.rb | UTF-8 | 629 | 3.03125 | 3 | [] | no_license | from_file, to_file = ARGV
puts "Copying from #{from_file} to #{to_file}"
in_file = open(from_file); indata = in_file.read
# in_file = open(from_file)
# indata = in_file.read
# puts "The input file is #{indata.length} bytes long"
#
# puts "Does the output file exist? #{File.exist?(to_file)}"
# puts "Ready, hit RETUR... | true |
68349f12ea86b9fbabe5ea05b1a758f4a055337a | Ruby | Fukkatsuso/AtCoder | /JoinedContest/ABC144B.rb | UTF-8 | 174 | 3.375 | 3 | [] | no_license | n = gets.chomp.to_i
can = false
(1..9).each do |i|
if n % i == 0
if n / i <= 9
can = true
break
end
end
end
if can
puts "Yes"
else
puts "No"
end | true |
8c7c4098eaee4036ce79bd27331bda80453cc9ee | Ruby | niw/rubies | /src/rubies.rb | UTF-8 | 2,126 | 2.8125 | 3 | [
"MIT"
] | permissive | require "yaml"
class Rubies
attr_reader :base_path
def initialize(*base_path)
@base_path = File.expand_path(*base_path)
end
def run!
name = ARGV.shift
if /^-c/ === name
name = load_rcfile(ARGV.shift)
end
select(name)
end
private
def load_rcfile(path)
rcfile = File.read(p... | true |
4971d5629d9f5d4cc680eb19cc08f25fa76ac259 | Ruby | sealink/timely | /lib/timely/date_chooser.rb | UTF-8 | 4,048 | 3.234375 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Timely
class DateChooser
# Where is this used... so far only in one place, _date_range.html.haml
# May be good to refactor this as well, after the class behaviour is refactored.
INTERVALS = [
{ code: 'week', name: 'week(s)', description: 'Weekdays selected will ... | true |
752f1591750679d5b84d7530c0e1e511d38679fb | Ruby | zendesk/curlybars | /spec/integration/presenters/letter_presenter.rb | UTF-8 | 443 | 2.859375 | 3 | [
"Apache-2.0"
] | permissive | module IntegrationTest
class LetterPresenter < Curlybars::Presenter
attr_reader :alphabet
allow_methods :a, :b, :c, :d, :e
def initialize(alphabet)
@alphabet = alphabet
end
%i[a b c d e].each do |m|
define_method(m) do
present(m)
end
end
private
def prese... | true |
897220a95d9e500f831b966c5e9cb70b3472b790 | Ruby | gulfstream15/Week02_Day03_Lab_SnakesLadders | /specs/snakesladders_spec.rb | UTF-8 | 460 | 2.640625 | 3 | [] | no_license | require('minitest/autorun')
require('minitest/rg')
require_relative('../snakesladders.rb')
class SnakesLaddersTest < MiniTest::Test
def test_can_create_board()
snakelad = SnakesLadders.new()
refute_nil(snakelad)
end
def test_create_snake
snake1 = SnakesLadders.new()
assert_equal({17=>3,13=>3}... | true |
5fd66be5acffe15e928dbcfb9bf2bad17ceb6587 | Ruby | pogoseat/api-client-ruby | /lib/pogoseat/api_endpoint.rb | UTF-8 | 873 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | module Pogoseat
class ApiEndpoint
include HTTParty
base_uri Pogoseat::API_BASE_URL
basic_auth ENV["POGOSEAT_API_KEY"], ENV["POGOSEAT_API_SECRET"]
format :json
# A helper function to verify that the API response appears successful.
def self.check_response response
if response.code != 200... | true |
e31b8f7be610fab2d6d243f3c3ae9076a4f73c9c | Ruby | awmcf/hogwarts-lab-sinatra | /specs/hogwarts_spec.rb | UTF-8 | 916 | 2.859375 | 3 | [] | no_license | require("minitest/autorun")
require("minitest/rg")
require_relative("../models/hogwarts")
class TestStudent < MiniTest::Test
def setup
student_1_details = {
"first_name" => "Cho",
"second_name" => "Chang",
"house" => "Ravenclaw",
"age" => "23"
}
student_2_details = {
"firs... | true |
c0796be4957e2558db07327e6ddc0d7d480f4fa2 | Ruby | Thinknetica-SoftProject/SP-test-assignment-4-gleb-kent | /3.rb | UTF-8 | 841 | 2.578125 | 3 | [] | no_license | ## Задача №3:
#
# Джон добрался до этажа с бомбой, но у него на пути стоит дверь с кодовым замком и рядом бумажка с инструкциями (файл data/3.txt)
#
# Чтобы узнать код от замка, ему нужно для каждой строки найти разницу между наибольшим и наименьшим числами и потом сложить полученные значения
#
## Требования к решен... | true |
522648fab6252eba730d2bd917df5cffee37746e | Ruby | joshsoftware/short_circuit | /solutions/auto_eval/solutions/RainerThiel_changed.rb | UTF-8 | 4,798 | 3.515625 | 4 | [] | no_license | =begin
The solution has been generalized to support basic network structures.
The network can be for example a circuitboard as required for this challenge,
or a map of geographical locations, or a network of people, or a model of a molecule...
The network consists of nodes that are associated with one another via ... | true |
bbe35c3242cc06d29785482cae03931afb881bbf | Ruby | coi-gov-pl/revamp | /lib/revamp/cli.rb | UTF-8 | 2,844 | 2.859375 | 3 | [
"Apache-2.0"
] | permissive | require 'micro-optparse'
require 'revamp'
# A command line interface class
class Revamp::CLI
# Executes an Revamp from CLI
#
# @param argv [Array] an argv from CLI
# @return [Integer] a status code for program
def run!(argv = ARGV)
exec = parse_execution(argv)
return -1 unless exec.success?
exec ... | true |
5120364d17ffef1a77d88a5c85c5aaaac663f02f | Ruby | maiyama18/AtCoder | /abc/005/b.rb | UTF-8 | 48 | 3.03125 | 3 | [] | no_license | n = gets.to_i
puts (0...n).map { gets.to_i }.min | true |
f5fb422b487365da801d4c4b7386880166d556de | Ruby | LukasBeaton/bond-metric | /spec/unit/service/benchmark_spec.rb | UTF-8 | 4,042 | 2.703125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require 'spec_helper'
describe Service::Benchmark do
describe '#calculate_spread_to_benchmark' do
before do
@C1 = Struct::Bond.new('C1', 'corporate', 10.3, 530)
@G1 = Struct::Bond.new('G1', 'government', 9.4, 370)
end
context 'success' do
it 'can calculate a positive spread' do
... | true |
499f2769b9c22b6e4c39c3c4640b27e353c8e5dc | Ruby | andres-arana/degree-6620-tp | /tp2/perf/analyze.rb | UTF-8 | 554 | 3.125 | 3 | [] | no_license | require "csv"
class Analyzer
def initialize
@stats = []
end
def analyze
accumulate_stats_on "build/perf/time"
avg = @stats.inject { |s, e| s + e } / @stats.size
puts ""
puts "*************************************"
puts "Average execution time: #{avg}"
end
private
def accumulate_st... | true |
45c3832f20106ca0da7573c55e0d8d367be77003 | Ruby | andie5/assignment_recursion_sprint | /lib/sum_of_digits.rb | UTF-8 | 473 | 4.4375 | 4 | [] | no_license |
# Takes an integer and returns the sum of its digits, for instance sumdig_r(103) => 4.
# Recursive sum of digits
def sumdig_r(n)
# puts "#{n} and n /10 is #{n/10} and n%10 is #{n%10}"
if (n<10)
return n
else
return n%10 + sumdig_r(n/10)
end
end
# Iterative sum of digits
def sumdig_i(n)
# Shortcut f... | true |
50e74eca0b54ed13eb9acdf2bcf26bf99579d6f4 | Ruby | suranyami/abbot-from-scratch | /lib/sproutcore/compiler/entry.rb | UTF-8 | 1,006 | 2.84375 | 3 | [] | no_license | module SproutCore
module Compiler
# The entry is a simple abstraction that takes in a name and a body
# and can extract dependencies from the body based on a pattern
#
# It will automatically assume that dependencies without an extension
# have the same extension as the entry's file name
class... | true |
1595e076e29a36b2cdf309aeb9d07bfa434ef803 | Ruby | kahahope/ROR_Thinknetica | /Lesson_1/ideal_weight.rb | UTF-8 | 317 | 3.453125 | 3 | [] | no_license | puts "Привет, как тебя зовут?"
name = gets.chomp
puts "Какой у тебя рост?"
height = gets.to_i
ideal_weight = height - 110
if ideal_weight >= 0
"#{name}, твой оптимальный вес #{ideal_weight} кг."
else
"#{name}, твой вес уже оптимален."
end
| true |
21f0b4f937949c667752ff4290b5dbbafb643875 | Ruby | TonyCWeng/Practice_Problems | /leetcode/ruby/11_container_with_most_water.rb | UTF-8 | 1,554 | 3.828125 | 4 | [] | no_license | def max_area(height)
left = 0
right = height.length - 1
left_wall = height[left]
right_wall = height[right]
most_water = max_area_helper(height, left, right)
until left >= right
if height[left] < height[right]
until height[left] > left_wall || left >= right
left += 1
end
left_w... | true |
5c2986b7ad80d2c7453f1b6bc5034a62cde470eb | Ruby | 4geru/barby | /test/codabar_test.rb | UTF-8 | 1,179 | 2.796875 | 3 | [
"MIT"
] | permissive | require 'test_helper'
require 'barby/barcode/codabar'
class CodabarTest < Barby::TestCase
describe 'validations' do
before do
@valid = Codabar.new('A12345D')
end
it "should be valid with alphabet rounded numbers" do
assert @valid.valid?
end
it "should not be valid with unsupported... | true |
e3488b923992bc39a9c67d00c7478e412a2f0e6c | Ruby | ong-wei-hong/the-odin-project | /chess/lib/chess/board.rb | UTF-8 | 12,535 | 3.21875 | 3 | [] | no_license | # frozen_string_literal: true
module Chess
# Board handles the board state
class Board
attr_reader :white_pieces, :black_pieces
def initialize(info = [])
@en_passant = nil
initialize_board(info)
initialize_moves
end
def to_s(selected_location = [], moves = [])
to_print = "... | true |
343a152a6310d57f0c086faf1683ab967605d9f7 | Ruby | sladebot/mars-rover | /spec/unit_tests/coordinate_spec.rb | UTF-8 | 512 | 2.671875 | 3 | [] | no_license | require 'spec_helper'
describe Coordinate do
before :each do
@coordinate = Coordinate.new(["10", "20", "N"])
end
it "There should be a valid Coordinate instance" do
expect(@coordinate).to be_an_instance_of Coordinate
end
it "Should have one x coordinate" do
expect(@coordinate.x_element).to eql(... | true |
23bbb747c75f20460f79bd8e0a49bb57f8f04a08 | Ruby | curtp/initiative_tracker | /init_tracker/models/reaction_command.rb | UTF-8 | 2,131 | 2.6875 | 3 | [
"MIT"
] | permissive | module InitTracker
module Models
class ReactionCommand < BaseCommand
NEXT_EMOJI = '▶️'.to_s
REROLL_EMOJI = '🔀'.to_s
RESET_EMOJI = '🔁'.to_s
STOP_EMOJI = '🗑'.to_s
EMOJIS = [NEXT_EMOJI, RESET_EMOJI, REROLL_EMOJI, STOP_EMOJI]
def control_emoji?
InitTracker::Models::Reac... | true |
57a595924d795b3570018fdefe91511a66c21435 | Ruby | richardbobo1/programming-univbasics-nds-green-grocer-dc-web-030920 | /grocer.rb | UTF-8 | 2,528 | 3.234375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def find_item_by_name_in_collection(name, collection)
x = 0
while x < collection.length do
if collection[x][:item] == name
return collection[x]
# else
# nil
end
x += 1
end
# Implement me first!
#
# Consult README for inputs and outputs
end
def consolid... | true |
8bcc522f937305d35be580263a769d3127800cbc | Ruby | Va1da2/programming-languages | /part-c/section9/mixins.rb | UTF-8 | 2,102 | 3.984375 | 4 | [] | no_license | # Programming Languages: Section 9 - Mixins
module Doubler
def double
self + self # uses self's `+` message, not defined in Doubler
end
end
class Pt
attr_accessor :x, :y
include Doubler
def + other
ans = Pt.new
ans.x = self.x + other.x
ans.y = self.y + other.y
... | true |
e198742b96f994c0e16042225007698b02a40318 | Ruby | sinventor/pincode | /app/models/redis/base.rb | UTF-8 | 674 | 2.828125 | 3 | [
"MIT"
] | permissive | class Redis::Base
attr_accessor :value, :key, :expire
class << self
def key_with_prefix(key)
"#{name.downcase}s:#{key}"
end
def get_value_by(key)
Redis.current.get key_with_prefix(key)
end
def create(params = {})
new(params).save
end
def delete(key)
Redis.curr... | true |
c2315dbe25b5f9341446e9e7645caca675764304 | Ruby | adimichele/capybarbecue | /spec/support/test_rack_app.rb | UTF-8 | 2,441 | 2.625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require 'rack'
class TestRackApp
def get_html(request)
<<-HTML % request.path
<html>
<head><title>Test Rack App</title></head>
<body>
<h1>%s</h1>
<div class='divclass1' id='div1'>
<div class='divclass2' id='div2'>
<a href='/link/1' id='link1'>click1</a>
... | true |
7fea86fad6a9e5251754668ae3501e8164c1509c | Ruby | ranjanisrini/guvi | /threemax.rb | UTF-8 | 70 | 3.484375 | 3 | [] | no_license | array = []
3.times do
n = gets.chomp.to_i
array.push(n)
end
array.max
| true |
fe48fe188a5680624589fc08f4280ddde5d882e0 | Ruby | GLaD0S/ruby_view_server | /erb_example.rb | UTF-8 | 617 | 3.828125 | 4 | [] | no_license | require 'erb'
require 'time'
=begin
this method will take in slices, number of times to record the current time and a block which will be what to do with the time.
=end
def time
alltime = Array.new
slices = 10
i = 0
while i < slices.to_i do
alltime.push(Time.now)
i+=1
end
yield
end
puts "How many slices o... | true |
4520d9d693599753b358c8256a1e1cf58d033a1c | Ruby | bronsonholden/kaprella-api | /app/services/filter_humanize_meta_service.rb | UTF-8 | 2,281 | 2.9375 | 3 | [] | no_license | # Generates humanized expressions representing various filter expressions
# to be displayed in the web application.
#
# TODO: Avoid using Keisan to parse expression and generate AST twice. This
# is done in the query service as well.
class FilterHumanizeMetaService
attr_reader :model, :filters
def initialize... | true |
6d7a8055339d49ff967daa1c61f63c6677ed6a21 | Ruby | davidverbustel/hackitten | /app/helpers/links_helper.rb | UTF-8 | 1,429 | 2.53125 | 3 | [] | no_license | require 'embedly'
require 'json'
module LinksHelper
def display(url)
embedly_api = Embedly::API.new(key: ENV['EB_KEY'])
obj = embedly_api.oembed :url => url
if obj.first.type == "video"
raise (obj.first.html).html_safe
elsif obj.first.type == "photo"
clean_url = obj.first.url.sub(/([?]f... | true |
4d126fc1760613b5c81dfcfdfcc5724ac466a111 | Ruby | jessjchang/Ruby-Object-Oriented-Problems | /lesson_1_OO_readings/ruby_oop_book_exercises/2_classes_objects_i/ex_1.rb | UTF-8 | 1,096 | 4.25 | 4 | [] | no_license | class MyCar
def initialize(year, color, model)
@year = year
@color = color
@model = model
@speed = 0
end
def speed_up(num)
@speed += num
puts "You are accelerating by #{num} miles per hour."
end
def brake(num)
@speed -= num
puts "You are decelerating by #{num} miles per hour... | true |
b5ad5746a31bd4bdfb85c9c2ffa50b627f09c1df | Ruby | BakaBBQ/LCraft | /LData/Item System/ - InventoryDisplayer.rb | UTF-8 | 2,746 | 2.609375 | 3 | [] | no_license | class InventoryDisplayer < Window_ItemList
attr_reader :inventory
def initialize(rect, inventory)
super(rect.x,rect.y,rect.width,rect.height)
@inventory = inventory
end
def refresh
super
draw_inventory_size
end
def draw_inventory_size
contents.font.si... | true |
fc99ac924be91b844658d99bce169c790dc0c9d8 | Ruby | ssone95/xport-sim | /xport_simulator.rb | UTF-8 | 1,895 | 3 | 3 | [
"MIT"
] | permissive | require "rubygems"
require "serialport"
require "net/telnet"
class XportSimulator
SERIAL_DATA_BITS = 8
SERIAL_STOP_BITS = 1 # use a stop bit
SERIAL_PARITY = SerialPort::NONE
TELNET_WAITTIME = 2.0
TELNET_PROMPT = /.*/
TELNET_MODE = false
def initialize(serial_port_id, baud_rate=9600)
@serial_por... | true |
8e33f0ba2eacca4e2ddfdcc8a3152d51af68282c | Ruby | gurugu-learning-projects/appacademy---ruby | /recursives/reverse.rb | UTF-8 | 276 | 3.203125 | 3 | [] | no_license | def reverse(string)
return string if string.length <= 1
string[-1] + reverse(string[0...-1])
end
# Test Cases
p reverse("house") # => "esuoh"
p reverse("dog") # => "god"
p reverse("atom") # => "mota"
p reverse("q") # => "q"
p reverse("id") # => "di"
p reverse("") # => ""
| true |
19c8414bc634b40113bb7528e75e6602d0cce816 | Ruby | xenda/curso_rails01 | /rubywarrior/alvaro-beginner/player.rb | UTF-8 | 2,143 | 3.125 | 3 | [] | no_license | class Player
attr_accessor :back_unknown, :health, :battle_spent, :fighting, :max_health, :rest_needed
def taking_damage?
damage = false
damage = true if @health > @warrior.health
end
def close_enemies(list)
list.select{|i| not i.captive? and (i.x - @warrior.x) < 3 }
end
def close_captives(l... | true |
acd2dc25dc9ecfbd6f2e5effe8ffc64440968e28 | Ruby | jdashton/glowing-succotash | /beth/lab3.leap.rb | UTF-8 | 482 | 4.21875 | 4 | [
"MIT"
] | permissive | # frozen_string_literal: true
print 'enter a starting year: '
year1 = gets.to_i
print 'enter an ending year: '
year2 = gets.to_i
# leap years are divisible by 4
# except when they are divisible by 100
# EXCEPT when they are divisible by 400
# puts all_years
# then, we'll make a function to find if it's a leap year
... | true |
369eecace7b030b6ad52e60ee92e9372cbec1f32 | Ruby | wpotratz/tealeaf | /2_ruby_workbook/quiz_1_1/exc_5.rb | UTF-8 | 242 | 3.765625 | 4 | [] | no_license | def number_check(number, lower, upper)
if (lower..upper).cover?(number)
then puts "Yep, that number is in between."
else
puts "Nope it's not"
end
end
number_check(42, 10, 100)
number_check(9, 10, 100)
number_check(101, 10, 100) | true |
f04696c93e053cbb53f5a06f14b666ff0fd978c3 | Ruby | MasatakaKudou/Ruby_intro | /chapter_8/module_mixin.rb | UTF-8 | 650 | 3.65625 | 4 | [] | no_license | # include
module Loggable
private
def log(text)
puts "[LOG] #{text}"
end
end
class Product
include Loggable
def title
log 'title is called.'
'A great movie'
end
end
class User
include Loggable
def name
log 'name is called.'
'Alice'
end
end
product = Product.new
p product.title
u... | true |
412e23c3919dee9b7bef02e385f33a5d015b71c6 | Ruby | davich/toy_robot | /lib/robot.rb | UTF-8 | 817 | 3.578125 | 4 | [] | no_license | require_relative 'direction'
require_relative 'position'
class Robot
def initialize(table)
@table = table
end
def place(position, direction)
return unless valid?(position, direction)
@position = position
@direction = direction
end
def move
return unless valid?
@p... | true |
3ef438fb34aaa469c234468f415eb38089308a1d | Ruby | EclecticKlos/Experimentations | /source/lib/parser.rb | UTF-8 | 763 | 2.828125 | 3 | [] | no_license | require_relative '../../config/application'
class Parse
def initialize(file)
@file = file
@business_list = nil
@sorted_ids = []
end
def parser
@business_list if @business_list != nil
@business_list = []
CSV.foreach(@file) do |row|
@business_list << {business_list: row[0], name: ro... | true |
7e172c1230a1d1182c3ed9f108b6e8efb761032c | Ruby | colinhalexander/ruby-collaborating-objects-lab-denver-web-82619 | /lib/song.rb | UTF-8 | 768 | 3.4375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class Song
attr_accessor :name, :artist
@@all = []
def initialize(name)
@name = name
@@all << self
end
def self.all
@@all
end
def self.new_by_filename(filename)
filename_array = parse_filename(filename)
new_song = self.new(filen... | true |
172183bc363d6ff49c914b42dd56ba681d6f131e | Ruby | cobot/later_dude | /lib/later_dude/month_calendar.rb | UTF-8 | 5,492 | 3.046875 | 3 | [
"MIT"
] | permissive | module LaterDude
class MonthCalendar
include ActionView::Helpers::CaptureHelper
include ActionView::Helpers::TagHelper
include ActionView::Helpers::UrlHelper
attr_accessor :output_buffer, :block
def initialize(year, month, options = {}, &block)
@year, @month, @options = year, month, option... | true |
2a978af4c9071b6ed373a29cea6ad03a7959ada9 | Ruby | sergei-kalugin/rashka | /app/helpers/author_helper.rb | UTF-8 | 1,022 | 2.671875 | 3 | [
"MIT"
] | permissive | # Хелпер для отображения создателей сайта
module AuthorHelper
# Отображает данные о создателе
# @note На вьюхе about/authors_container
# @example
# author("authors/fyodor.jpg", "Фёдор Иванищев", "http://vk.com/cbrwizard", "Разработка и борода")
#
# @param image [String] ссылка на изображение
# @param n... | true |
430e41de21f39da86f04f01957e8bcb2fb3846fe | Ruby | richardrguez/exercises | /projecteuler/07_10001st_prime.rb | UTF-8 | 521 | 4.21875 | 4 | [] | no_license | # By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13,
# we can see that the 6th prime is 13.
#
# What is the 10 001st prime number?
def is_prime?(n)
if n <= 1
return false
elsif n == 2
return true
else
(2..(n-1)).each do |num|
if n % num == 0
return false
end
end
... | true |
3decd5fbe4a0eea704a0a39b03ef47071da79fbb | Ruby | deisy0820/ruby | /collatz.rb | UTF-8 | 348 | 3.9375 | 4 | [] | no_license | #Desarrolle un programa que entregue la secuencia de Collatz de un número entero:
#ingreso de datos
puts "ingrese un numero entero"
n = gets.chomp
#conversion de datos
n = n.to_i
foco = true
while foco
if n%2==0
res = n/2
puts"#{res}"
n = res
else
n%2==1
res=n*3+1
puts"#{res}"
n = res
end
if res ==... | true |
5917ee81c1dba33809bc475067219ce747f1b716 | Ruby | dominicmeddick/oystercard | /spec/oystercard_spec.rb | UTF-8 | 2,404 | 3.125 | 3 | [] | no_license | require 'oystercard'
describe Oystercard do
let(:entry_station) { double :station }
let(:exit_station) { double :station}
describe '#balance' do
it 'responds to balance' do
expect(subject).to respond_to(:balance)
end
it 'has a balance' do
expect(subject.balance).to eq(0)
end
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.