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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
ae1da9060738473a3453ebfb85a1f9b200bab9ff | Ruby | changokun/project_euler_work | /055.rb | UTF-8 | 871 | 3.609375 | 4 | [] | no_license | require_relative 'functions.rb'
def is_lychrel?(x, depth = nil)
depth ||= 0
if depth >= 50
return true
end
# it is a lychrel number if you reverse the digits, add it to itself and cannot get a palindrome despite recurse as such (up to fifty times for this problem)
next_x = x.to_s.reverse.to_i + x
# p... | true |
065021492afdbe27c2f4fc064b582fc0fd5332ac | Ruby | Trawais/advent_of_code-2016 | /01/lib/map.rb | UTF-8 | 1,741 | 3.828125 | 4 | [
"MIT"
] | permissive | # class for representing first task of advent of code 2016
class Map
NORTH = 0
EAST = 1
SOUTH = 2
WEST = 3
def initialize(instructions)
@shortest_path = 0
@x_coord = 0
@y_coord = 0
@heading_to = NORTH
@instructions = instructions
@visited = [[@x_coord, @y_coord]]
end
def shortest... | true |
3c9a3360e3009c2484cfbc555e732ce3bace5ff4 | Ruby | Anis0000/EXOW2 | /multiples_3_5.rb | UTF-8 | 213 | 3.625 | 4 | [] | no_license | def multiples()
i = 0
sum=0
while i < 1000 do
if i % 3 == 0 || i % 5 == 0
sum += i
end
i += 1
end
sum
end
puts "Somme des multiples de 3 et 5 inferieurs a 1000 : " + multiples().to_s
| true |
896c4715c8dd5a7e441fcc622e62daf483c2f625 | Ruby | MedNexus/nedocs-online | /app/models/user.rb | UTF-8 | 2,534 | 2.609375 | 3 | [
"MIT"
] | permissive | require 'digest/sha1'
class User < ActiveRecord::Base
attr_reader :password
validates_presence_of [ :username, :password, :first_name, :last_name ], :message => 'is required'
validates_length_of :password, :minimum => 4
validates_uniqueness_of :username, :message => 'already in use'
validates_confirmatio... | true |
71dc7eab55b3454436713d8e092bfb3d3bf88502 | Ruby | emk/rdf | /lib/rdf/cli.rb | UTF-8 | 1,526 | 2.65625 | 3 | [
"LicenseRef-scancode-public-domain",
"Unlicense"
] | permissive | require 'rdf'
require 'optparse'
module RDF
class CLI
##
# @return [String]
def self.basename() File.basename($0) end
##
# @yield [options]
# @yieldparam [OptionParser]
# @return [OptionParser]
def self.options(&block)
options = OptionParser.new
if block_given?
... | true |
9a21c95c931038c37d4a059e0ae5d39b3b357fde | Ruby | nthomson0317/phase-3-object-relations-practice-code-challenge-students-one-many | /db/seeds.rb | UTF-8 | 1,152 | 2.8125 | 3 | [] | no_license | puts "Clearing old data..."
Cohort.destroy_all
Student.destroy_all
# This will create 5 cohorts using a random date
puts "Seeding cohorts..."
c1 = Cohort.create(
name: "nyc-dumbo-web-#{Faker::Date.forward(days: 1).strftime("%m%d%Y")}",
current_mod: rand(1..5)
)
c2 = Cohort.create(
name: "nyc-dumbo-web-#{Faker::D... | true |
3994a6e90f7074af7a9dbc1a948360aad0b627de | Ruby | marian13/basic_temperature | /lib/basic_temperature/temperature/assertions.rb | UTF-8 | 894 | 2.796875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module BasicTemperature
class Temperature
module Assertions
private
def assert_either_positional_arguments_or_keyword_arguments!(positional_arguments, keyword_arguments)
raise_initialization_arguments_error if positional_arguments.any? && keyword_arguments.any?
... | true |
c854957830ec817102d109acc4465981c7e7287e | Ruby | selinaerhabor/oystercard | /lib/oystercard.rb | UTF-8 | 1,058 | 3.6875 | 4 | [] | no_license | class Oystercard
attr_reader :balance, :entry_station
attr_accessor :in_journey
CHARGE = 1.20
MIN_BALANCE = 1
MAX_BALANCE_LIMIT = 90
# Initializes balance to equal 0 and in_journey is false
def initialize
@balance = 0
@in_journey = false
@entry_station != nil
end
# If top up amount is ... | true |
28326c32b6a729990250ece51c258a09bc97d971 | Ruby | sarynm12/sweater_weather | /app/facades/geocoding_facade.rb | UTF-8 | 334 | 2.84375 | 3 | [] | no_license | class GeocodingFacade
attr_reader :location,
:service
def initialize(location)
@location = location
@service = GeocodingService.new
end
def get_latitude_and_longitude
latitude_and_longitude = service.get_location(location)
latitude_and_longitude[:results][0][:locations][0][:latLn... | true |
ed072ea4aa465033c2f20092df68848b9fc0b5c3 | Ruby | Studiosity/fountain-ruby | /lib/fountain/funnel.rb | UTF-8 | 1,551 | 2.53125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Fountain
#
# Fountain Funnel
#
class Funnel
# Raw funnel data
attr_reader :raw_data
#
# @param [Hash] data Raw funnel data
#
def initialize(data)
@raw_data = Util.stringify_hash_keys data
end
# Funnel ID
def id
raw_data['id'... | true |
bad62584023b19a10e20b176f58b6c6a8447be66 | Ruby | Rolave/E6CP2A1 | /3 strings/ejercicio2.rb | UTF-8 | 645 | 4.375 | 4 | [] | no_license | # Construir un arreglo de los nombres de todos sus compañeros y en base a él:
# 1. Imprimir todos los elementos que excedan más de 5 caracteres.
# 2. Crear un arreglo nuevo con todos los elementos en minúscula.
# 3. Crear un método que devuelva un arreglo con la cantidad de caracteres que
# tiene cada nombre.
tde = ['J... | true |
5daccd0bc440683fe8da6c9011c80de8a9ac3338 | Ruby | jhaals/rspec-system | /lib/rspec-system/result.rb | UTF-8 | 458 | 2.796875 | 3 | [
"Apache-2.0"
] | permissive | require 'rspec-system'
require 'ostruct'
module RSpecSystem
# This class represents raw results from a helper command
class Result < OpenStruct
# Returns the value of a member, with hash syntax.
#
# @param name [String, Symbol] name of parameter to retrieve
def [](name)
@table[name.to_sym]
... | true |
063ff2fe7ea6bf6b5ccb17ff93f6a2040f8dc913 | Ruby | ULL-ESIT-LPP-1819/tdd-alu0100977103 | /lib/gema/listas.rb | UTF-8 | 2,902 | 3.59375 | 4 | [] | no_license | #Clase que genera listas doblemente enlazadas
class LinkedList
include Enumerable
attr_accessor :Node
#Constructor de una lista doblemente enlazada
def initialize
@Node = Struct.new(:value, :next, :prev)
@head = nil
@tail = nil
end
#Ver que valores vas a com... | true |
8dde965a5c297c319248eac925dd87155489c611 | Ruby | michaelstucki/introduction_to_programming | /01_basics/ex_4.rb | UTF-8 | 70 | 2.75 | 3 | [] | no_license | dates = [2001, 2002, 2004]
puts dates[0]
puts dates[1]
puts dates[2]
| true |
0d8b59a32c6cb6f36dbbae569e5a8d4e87e60140 | Ruby | glella/primes | /Ruby_Rust_Gem/primes.rb | UTF-8 | 479 | 3.65625 | 4 | [] | no_license | #! /usr/bin/env ruby
# ruby primes.rb
require 'Primesrs'
def prompt(*args)
print(*args)
gets
end
puts "Returns a list of prime numbers from 1 to < n using Rust & Rayon."
n = (prompt "Input limit: ").to_i
start_time = Time.now
list = Primesrs[n]
end_time = Time.now
elapsed_time = end_time - start_time
puts "... | true |
1cb5eebbec40587ea8073671605537b2affe7692 | Ruby | nrk/ironruby | /External.LCA_RESTRICTED/Languages/Ruby/ruby-1.8.6p368/lib/ruby/gems/1.8/gems/activemodel-3.0.pre/lib/active_model/dirty.rb | UTF-8 | 3,844 | 3.171875 | 3 | [
"MIT"
] | permissive | module ActiveModel
# Track unsaved attribute changes.
#
# A newly instantiated object is unchanged:
# person = Person.find_by_name('Uncle Bob')
# person.changed? # => false
#
# Change the name:
# person.name = 'Bob'
# person.changed? # => true
# person.name_changed? # => true
... | true |
715d81bf65367709d1993924434f9ec77c7e1748 | Ruby | laceywalker/hw_week02_day02_bears-river-fish | /specs/river_spec.rb | UTF-8 | 850 | 3.140625 | 3 | [] | no_license | require("minitest/autorun")
require("minitest/rg")
require_relative("../river")
require_relative("../fish")
class RiverTest < MiniTest::Test
def setup
@fish1 = Fish.new("Billy")
@fish2 = Fish.new("TJ")
@river1 = River.new("Amazon", [@fish1, @fish2]) #different object than below (2 different rivers)
... | true |
7ad1b592e50f1755984090c99630d5d0edfc0177 | Ruby | ShaperGZ/ArchProto | /arch_util_apdx_arithmic.rb | UTF-8 | 653 | 2.671875 | 3 | [] | no_license | module ArchUtil
def ArchUtil.vector_scale(v,f,inplace=false)
if inplace
nv=v
else
nv=v.clone
end
for i in 0..2
nv[i]*=f
end
return nv
end
def ArchUtil.vector_scale3d(v,v2,inplace=false)
if inplace
nv=v
else
nv=v.clone
end
... | true |
db06763a4b1bf215e03bdacf2daeb7a0ef843af2 | Ruby | cfanpnk/launchschool | /backend/ruby_foundations/lesson_4/exercise_2/9.rb | UTF-8 | 159 | 3.171875 | 3 | [] | no_license | def titleize(sentence)
title = sentence.split.map do |word|
word.capitalize
end
title.join(" ")
end
words = "the flintstones rock"
p titleize(words) | true |
d86d5d910b1f14b04fd3715c52b7f3b9272a54d8 | Ruby | ravimathya/ruby | /ruby/alpha.rb | UTF-8 | 482 | 3.171875 | 3 | [] | no_license | code_hash = { "www.facebook.com" => 8, "www.google.com" => 19, "Vinh" => 24, "Alberto" => 3, "Rina" => 25 }
url = ""
code = 0
def generate_code(number)
charset = Array('A'..'Z') + Array('a'..'z') + Array(0..9)
Array.new(number) { charset.sample }.join
end
print "Enter a url: "
url = gets.chomp
if code_hash... | true |
e1400bbcc1f1fbd9d64e7619a92ffbbc1c7c2b68 | Ruby | levthedev/conf_talk | /spec/enumerator_spec.rb | UTF-8 | 2,148 | 3.859375 | 4 | [] | no_license | require_relative '../lib/enumerator.rb'
RSpec.describe 'MyEnumerable' do
def expect_enum(array, method_name, *args, expected, &block)
actual = MyEnumerator.new(array).__send__(method_name, *args, &block)
expect(actual).to eq expected
end
describe 'count' do
specify 'returns how many items the block ... | true |
814805ac2473a929b8a22952d0cf23fc826d5038 | Ruby | JASPMobus/debugging-with-pry-online-web-pt-081219 | /lib/pry_debugging.rb | UTF-8 | 34 | 2.90625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def plus_two(num)
num+=2
num
end | true |
699c72c59305bfdd306f71277e2070bd1d2382e7 | Ruby | edwardkimj/phase-0-tracks | /ruby/alias_manager2.rb | UTF-8 | 2,198 | 4.09375 | 4 | [] | no_license | # Take in a name as an argument and swap the first and last name
def swap_name(full_name)
swapped_name = full_name.split(' ').reverse.join(' ')
swapped_name
end
p swap_name('Felicia Torres') === 'Torres Felicia'
# Def a method that will change all vowels to the next vowel. Make an edge case
# so that 'u' will bec... | true |
3fefb0e37aa3a3ca3b76a434db0c09d6bbb70db5 | Ruby | Vasu1105/win32-taskscheduler | /lib/win32/windows/time_calc_helper.rb | UTF-8 | 4,551 | 3.625 | 4 | [
"Artistic-2.0",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | module Windows
module TimeCalcHelper
# Returns actual no of days for given month;
# Array with a 0 is defined to give actual result without
# any manipulation. eg, DAYS_IN_A_MONTH[1] = 31
# 0(NUMBER) is kept to avoid exceptions during calculations
DAYS_IN_A_MONTH = [0, 31, 28, 31, 30, 31, 30, 31,... | true |
173f6520023666591a576f8a5ad17f9682f071df | Ruby | bill-auger/scripts | /ruby/gits | UTF-8 | 1,094 | 2.78125 | 3 | [] | no_license | #!/usr/bin/env ruby
USAGE = "USAGE:\n" +
"\tgits [ <base-dir> ]\n\n" +
"DESCRIPTION:\n" +
"\... | true |
2ae2f31db056297018ddea0945d7e2b056db1e53 | Ruby | dxfl/minmi | /lib/mongo_interface.rb | UTF-8 | 489 | 2.609375 | 3 | [
"MIT"
] | permissive | require 'mongo'
class MongoInterface
MaxBSONSize = 16777216
def initialize(dbname, collectionname)
@dbname = dbname
@collectionname = collectionname
@collection = connectMongo
end
def connectMongo
client = Mongo::Client.new(['127.0.0.1'], :database => @dbname)
db = client.database
... | true |
a68a460cdd6cc466b2f527ac099298859dd1bccc | Ruby | XanderG7/luo-server | /info/src/character_info.rb | UTF-8 | 236 | 2.75 | 3 | [] | no_license | ## This file will contain all available services to gather info
## about a specific character.
# This service will return the character information based on his ID
get '/character/:id' do |id|
"Looking at character <b>#{id}</b>"
end
| true |
11deb3e0217eefebae87834d8007e79f9d8ef4dc | Ruby | JohnClaude/open-by-laws | /lib/support_files.rb | UTF-8 | 1,382 | 2.59375 | 3 | [
"CC-BY-2.5",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module AkomaNtoso
class SupportFile
# on-disk filename of this file
attr_accessor :filename
# path portion of the URL for this file
attr_accessor :url
def self.find(filename, base_url)
return nil unless File.exists?(filename)
SupportFile.new(filename, File.join(base_url, File.basena... | true |
a1e589d2a2f55fdb25d6dce4f9c116ad69be4f16 | Ruby | a2ikm/tremolo | /lib/tremolo/tokenizer.rb | UTF-8 | 4,059 | 3.375 | 3 | [] | no_license | module Tremolo
SINGLE_TOKENS = {
"+" => :plus,
"-" => :minus,
"*" => :asterisk,
"/" => :slash,
"%" => :percent,
"(" => :lparen,
")" => :rparen,
"{" => :lbrace,
"}" => :rbrace,
";" => :semicolon,
"," => :comma,
'"' => :dquote,
"!" => :bang,
}
KEYWORD_TOKENS = {
... | true |
a492c7ceff157af51569eb5179905b4fb9e7b2f2 | Ruby | rafaponzio/Cucumber-Watir | /Teste1/features/pages/tasks_page.rb | UTF-8 | 1,215 | 2.5625 | 3 | [] | no_license | class TaskPage
############################################################################################
###Main Definitions ###
############################################################################################
def task_fill(text)
... | true |
d17960a02cbffbfc60d313ef9c15bdbeda45cc97 | Ruby | kaxla/portfolio | /test/features/posts/delete_post_test.rb | UTF-8 | 2,862 | 2.53125 | 3 | [
"MIT"
] | permissive | require "test_helper"
# ----------INDEX----------------
feature "Deleting a Post" do
scenario "editor can delete an existing post from index" do
# Given a list of existing posts with delete option
sign_in(:editor)
visit posts_path
title = posts(:published).title
# When I select a post and then se... | true |
33927485fe508da7435b4efa3d4f6d7f94813117 | Ruby | EJLarcs/school-domain-with-db-web-0715-public | /lib/student.rb | UTF-8 | 2,745 | 3.375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class Student
attr_accessor :id, :name, :tagline, :github, :twitter, :blog_url, :image_url, :biography
#all methods have def id @id end and def id=(id) @id = id end
def self.create_table
DB[:conn].execute("""CREATE TABLE students (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT,
... | true |
c26088c6a97422b5fd584c36cc90a17ea0ce3e6d | Ruby | puffsun/sinatra_base | /models/song.rb | UTF-8 | 411 | 2.65625 | 3 | [] | no_license | require 'sinatra/activerecord'
module SongHelpers
def find_songs
@songs = Song.all
end
def find_song
Song.get(params[:id])
end
def create_song
@song = Song.create(params[:song])
end
end
helpers SongHelpers
class Song < ActiveRecord::Base
validates_uniqueness_of :title
validates_presence... | true |
da4156f6638aa00eba417a3f105a9dc4e1f44505 | Ruby | anukhambete/model-class-methods-lab-v-000 | /app/models/boat.rb | UTF-8 | 873 | 2.640625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class Boat < ActiveRecord::Base
belongs_to :captain
has_many :boat_classifications
has_many :classifications, through: :boat_classifications
def self.first_five
#where("id >=?", 5)
self.limit(5)
end
def self.dinghy
where("length <=?", 20)
end
def self.ship
where("... | true |
ee7a95f92a0b912a13822f52ff8686cf10afaf2a | Ruby | jfeng702/aa-homework | /W2D4/big_octopus.rb | UTF-8 | 1,602 | 3.6875 | 4 | [] | no_license | fish = ['fish', 'fiiish', 'fiiiiish', 'fiiiish', 'fffish', 'ffiiiiisshh', 'fsh', 'fiiiissshhhhhh']
def quadratic_biggest_fish(fishes)
(0...fish.length).each_with_index do |fish1, idx1|
max_length = true
(0...fish.length).each_with_index do |fish2, idx2|
next if idx1 == idx2
max_length = false ... | true |
f5e2bdafeb45623ca157c64a11dc21139bb9af5f | Ruby | takattty/cherry_book | /practice_codes/chapter2/2.9/2.9.1.rb | UTF-8 | 69 | 2.75 | 3 | [] | no_license | puts (0b11111111111)
puts (0377)
puts (0xff)
#それぞれの進数 | true |
4cfbf9a2ebc4b255a9c9d10d8f0d3c426045f920 | Ruby | tejaswiniR161/Ruby-Rails-Workshop | /ruby/ip.rb | UTF-8 | 224 | 3.046875 | 3 | [] | no_license | puts "Enter your name : "
name= gets
puts "welcome to the workshop "+ name
num=gets #reads as string eds with \n
num = gets.chomp #reads as string but no \n in the end
num=gets.to_i#reads as number
#irb for interactive ruby | true |
b985e1b1c9a54119d5588a04a742455f91fa582d | Ruby | vly/unimelb-webregistry | /spec/data_end_points_spec.rb | UTF-8 | 1,154 | 2.75 | 3 | [] | no_license |
require 'spec_helper.rb'
describe DataEndPoints do
describe '#initalize' do
it "creates neo object" do
data_end_point = DataEndPoints.new
expect(data_end_point.getNeo).to be_an_instance_of(Neography::Rest)
end
end
describe '#get_data_person' do
it "returns d... | true |
1748b2f4f17da0ccd8cb7e6b875bfce11d7938c6 | Ruby | brisag/camping | /app/facades/weather_facade.rb | UTF-8 | 754 | 2.90625 | 3 | [] | no_license | class WeatherFacade
class << self
def get_forecast(location)
weather = WeatherService.get_weather(pull_coordinates(location))
forecast = {
current_weather: CurrentWeather.new(weather[:current]),
daily_weather: weather[:daily].first(5).map do |day|
... | true |
4733fd11f86f966fe93e0e793f4d5bc86f9a5760 | Ruby | pjurgensen/convert-legacy-data | /spec/title_case_spec.rb | UTF-8 | 550 | 3.40625 | 3 | [] | no_license | require("rspec")
require("title_case")
describe("title_case") do
it("capitalizes first letter of inputted words except those blacklisted") do
title_case("sometimes a great notion").should(eq("Sometimes a Great Notion"))
end
it("still capitalizes blacklisted words if they are the first word in the title") do
... | true |
6e97419c2241106e88e58ea07e9d91f5b36a054e | Ruby | mforoni/ruby-launch-plan | /rspec/4.io/game/game.rb | UTF-8 | 127 | 2.90625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
ASK_FOR_NAME = 'Please insert your name'
def capture_name
puts ASK_FOR_NAME
gets.chomp
end
| true |
85f4de76bc044c01dbfc74abc33bfea7713726c8 | Ruby | PRudge/hwrk_wk2_day1_part3-ext | /library_books.rb | UTF-8 | 1,117 | 4 | 4 | [] | no_license | class Library
attr_accessor :books
# need an initialize to grab the input to the class
def initialize(books)
# initialize is a ruby function
@books = books # we have our array of books hashes
end
def get_book_dets(book_title)
for book in @books
# returns the book hash
return book if... | true |
0588b9d9ec5746bdcd7c13889dc48fc4e9fd7a90 | Ruby | MiloTodt/sfuscheduler | /lib/assets/scheduleGenerator.rb | UTF-8 | 13,094 | 3.578125 | 4 | [] | no_license | # Schedule Generator
# Takes in an array of courses in the form of
# [
# ["Course Name", priority, ["Day", Start_Time, End_Time, location], ["Day", Start_Time, End_Time, location], ...[["CO", "Co-req name", ...], ["PRE", "Pre-req name", ...]],
# ["Course Name", priority, ["Day", Start_Time, End_Time, location], ["... | true |
d52ee22dc501dc8ad18e3c2cba57dc010bdb3001 | Ruby | KodaiISHIJIMA/assignment | /final/ruby-ecc/MyTronBot.rb | UTF-8 | 2,970 | 3.75 | 4 | [
"BSD-2-Clause"
] | permissive | # coding: utf-8
# MyTronBot
# Author: Kodai ISHIJIMA
#
# 基本的な作戦として、壁が少ない方へ向かう
#
# # #
# #2###
# #
#
# となっているときは下へと向かう
#
load "map.rb"
load "printing.rb"
#NB: This AI communicates with the contest engine over
#standard out. printing.rb contains convenience methods
#which overload the puts, p and print methods such th... | true |
6b93082463f763e47456059476d879b96d86e166 | Ruby | BelovVladimirO/Lesson-1 | /lesson_3/oop.route.rb | UTF-8 | 404 | 3.359375 | 3 | [] | no_license | class Route
attr_reader :initial, :terminal_station, :station
attr_accessor :stations
def initialize(initial, terminal_station)
@initial = initial
@terminal_station = terminal_station
@stations = [initial, terminal_station]
end
def add(station)
self.stations.insert(-2, station)
end
def delete(station... | true |
322c65b4ab6e9d39fe2938c2b451491771864ba6 | Ruby | ReachAayush/levelup | /ruby_core/dino_dex/runscript.rb | UTF-8 | 251 | 2.78125 | 3 | [] | no_license | # A brief test
require_relative 'dino_dex.rb'
dex = DinoDex.new
dex.read('dinodex.csv')
puts dex.in_period('Cretaceous')
newdex = DinoDex.new
newdex.read('african_dinosaur_export.csv')
puts newdex.carnivores
puts newdex.query(name: 'Afrovenator')
| true |
ec990b724ae71fb6903877f2ebe078ab96f8c2bd | Ruby | THPS07E01/Ski-bi-dibby-dib-yo-da-dub-dub | /spec/scrapules_spec.rb | UTF-8 | 1,139 | 2.6875 | 3 | [] | no_license | require_relative '../lib/scrapules'
describe 'get_scrapules_urls' do
it 'is not nil' do
expect(get_scrapules_urls).not_to be_nil
end
it 'has a certain amount of element in it' do
expect get_scrapules_urls.length > 20
end
end
describe 'get_townhall_email' do
it 'is an array' do
expect get_tow... | true |
95f80a049728a645747d1f222b4ec2b55b08f4f5 | Ruby | kristyh32/hotel | /test/reservation_test.rb | UTF-8 | 999 | 2.515625 | 3 | [] | no_license | require_relative 'test_helper'
describe "Reservation" do
describe "Reservation instantiation" do
before do
room = Hotel::Room.new(4)
date_range = Hotel::DateRange.new("10-22-2019", "10-24-2019")
@reservation = Hotel::Reservation.new(room, date_range)
end
it "is an instance of Reser... | true |
d353562b35e799acc2685017459f6841ffbc302b | Ruby | jiang-yifan/LearningAlgorithms | /D4/computing_SCC.rb | UTF-8 | 2,369 | 3.203125 | 3 | [] | no_license | class Vertex
attr_reader :edges
attr_accessor :added, :seen
attr_accessor :t
def initialize
@edges = []
@added = false
end
end
class Edge
attr_reader :seen, :vertices
def initialize vertex1, vertex2
@vertices = []
@vertices << vertex1
@vertices << vertex2
end
end
def DFS vertex
r... | true |
ee4a472bdec92636e28dc5d9984579341fc5e8e3 | Ruby | batacon/-Ruby | /regular_exp/regular_exp.rb | UTF-8 | 144 | 2.859375 | 3 | [] | no_license | text = <<-TEXT
名前: ああああ
電話: 03-1234-1234
携帯: 09-1111-2222
住所: おおおおお
TEXT
p text.scan /\d\d-\d\d\d\d-\d\d\d\d/
| true |
33ce1dcd46e9dc0a4662ea5a05c5c5620481e7d9 | Ruby | josue804/debunker | /spec/debunker_output_spec.rb | UTF-8 | 3,855 | 2.640625 | 3 | [
"MIT"
] | permissive | require_relative 'helper'
describe Debunker do
describe "output failsafe" do
after do
Debunker.config.print = Debunker::DEFAULT_PRINT
end
it "should catch serialization exceptions" do
Debunker.config.print = lambda { |*a| raise "catch-22" }
expect { mock_debunker("1") }.to_not raise_e... | true |
f58f77f5aac657e2806ffd71524f554f273c16ef | Ruby | oldmoe/Nezal | /shihabd/lib/orchestra/daemonizer.rb | UTF-8 | 2,225 | 2.765625 | 3 | [] | no_license | require 'daemons'
require 'orchestra/configurator'
module Orchestra
class Daemonizer
DEFAULT_PID_FILE = Orchestra::Configurator::DEFAULTS[:pid_file]
def self.start(pid_file = DEFAULT_PID_FILE, &block)
running = self.running?(pid_file)
if running
error = -1
else
s... | true |
dd538e307d328aa6f7c3aa7d847b0f5d0c3af6f3 | Ruby | kristenmills/scrabbli | /lib/scrabbli/generator.rb | UTF-8 | 12,098 | 3.3125 | 3 | [] | no_license | module Scrabble
# Moudule cotaining algorithms to generate next move
module Generator
extend self
# Finds the first word that you should play
#
# @param [Player] player the player whose tiles you are using
# @param [Matrix] board the scrabble board matrix
# @return and array containing the best word a... | true |
df0d55f9d84e10449d66c25db0f28657bfeb3144 | Ruby | Fig77/bubble_sort_microverse | /buble_sort.rb | UTF-8 | 576 | 3.328125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
def bubble_sort(arr)
order = false
until order
order = true
(0...arr.length - 1).each do |k|
if arr[k] > arr[k + 1]
arr[k], arr[k + 1] = arr[k + 1], arr[k]
order = false
end
end
end
arr
end
def bubble_sort_by(array)
swap = false
until s... | true |
7960eef7b3d3491a4955cbf6607a5401ebb4588f | Ruby | g5search/yield_star_client | /lib/yield_star_client/get_properties/response.rb | UTF-8 | 474 | 2.53125 | 3 | [
"MIT"
] | permissive | module YieldStarClient
module GetProperties
class Response
def initialize(soap_response)
@soap_response = soap_response
end
def properties
return @properties if @properties
@properties = @soap_response.to_hash[:get_properties_response]\
[:return][:property]
... | true |
211dc9c02a319353b26342a77cabd1e582b39a06 | Ruby | Crown-Commercial-Service/crown-marketplace | /spec/support/facilities_management/rm6232/admin/file_importer_helper.rb | UTF-8 | 8,249 | 2.546875 | 3 | [
"MIT"
] | permissive | module FacilitiesManagement
module RM6232
class FileImporterHelper
def initialize(**options)
@package = Axlsx::Package.new
@sheets = options[:sheets]
@headers = options[:headers]
@extra_supplier = options[:extra_supplier] || []
@empty = options[:empty] || false
... | true |
c7bf2658e3ec19ad90c9f944334c1f5472b33c1d | Ruby | robbi5/kleineanfragen | /lib/classified_recognizer.rb | UTF-8 | 1,834 | 2.609375 | 3 | [
"MIT"
] | permissive | class ClassifiedRecognizer
attr_accessor :skip
attr_reader :text
attr_writer :debug
def initialize(text, debug: false, skip: nil)
@text = text
@debug = debug
@skip = skip || []
end
def debug?
@debug
end
def recognize
throw 'No text set' if @text.nil?
@probability = 0.0
@g... | true |
6a4b01b0c82d8c6a14eff37305c8244451f56b43 | Ruby | vchoe89/guided-module-one-project-assessment-dc-web-080519 | /lib/interface.rb | UTF-8 | 4,908 | 3.078125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class CommandLineInterface
#Welcomes the User and gives them a list of options to choose from
def welcome
prompt = TTY::Prompt.new
system "clear"
# a = Artii::Base.new :font => 'slant'
# puts a.asciify('GameDestination')
font = TTY::Font.new(:doom)
puts font.write("Gaming Dest... | true |
8f8cb10a985310e05d8b73e4f0df794b3f88c6f7 | Ruby | harry-potter/Azkaban | /learningruby/hashes.rb | UTF-8 | 224 | 2.90625 | 3 | [] | no_license | #Hashes
hash_example = {
'value1' => '1',
'value2' => 2
}
p hash_example[0]
#for symbols
h = { dog: 'canine', cat: 'feline', donkey: 'asinine' }
# same as...
h = { :dog => 'canine', :cat => 'feline', :donkey => 'asinine' }
| true |
fc9241ddcec33abc425dce3e524788a6ed5db1ca | Ruby | Brendao1/debugging-one | /debug2.rb | UTF-8 | 756 | 3.5 | 4 | [] | no_license | def encode(plaintext, key)
cipher = ""
variable = ""
# varibale = cipher.find_index(char)
cipher = key.chars.uniq + (('a'...'z').to_a - key.chars)
ciphertext_chars = plaintext.chars.map do |char|
(65 + cipher.find_index(char)).chr #nil can't be coerced into Integer
end
ciphertext_chars.join
end
def ... | true |
152a0f4cf76aecd883ba5223e2740c33791c0898 | Ruby | jaitheking/learn_ruby | /redacted.rb | UTF-8 | 276 | 3.65625 | 4 | [] | no_license | puts "Enter a sentence"
text = gets.chomp
puts "Enter the word to be REDACTED"
redact = gets.chomp
words = text.split(" ")
words.each do |word|
if word == redact
word.length.times{print "*"}
print " "
else
print word + " "
end
end
| true |
fa3e0292fdb0abec7eb9cbeb0147e8c7c9a1b60b | Ruby | dmitry-solomadin/onemyday | /app/helpers/comments_helper.rb | UTF-8 | 564 | 2.578125 | 3 | [] | no_license | module CommentsHelper
# comments are deletable by owners and by owners of stories on which comment has been posted on.
def comment_deletable?(comment)
current_user && (comment_owner?(comment) || story_owner?(comment))
end
# comments are editable only by users who owns them
def comment_editable?(comment)... | true |
1d6f983a5d61d9bd859adcbeff6521e2c6a0834a | Ruby | loschorts/chess | /lib/pieces/pawn.rb | UTF-8 | 765 | 3.515625 | 4 | [] | no_license | require_relative 'piece.rb'
class Pawn < Piece
WHITE_SYMBOL = "\u2659"
BLACK_SYMBOL = "\u265f"
attr_accessor :moved
attr_reader :step
def initialize(board, position, color, moved = false)
super(board, position, color)
@moved = moved
color == :white ? @step = -1 : @step = 1
end
def moves
... | true |
825a01b593aa68276a2a2b3e2d5611dce46014e3 | Ruby | sarabrandao21/betsy | /test/models/order_test.rb | UTF-8 | 7,102 | 2.625 | 3 | [] | no_license | require "test_helper"
describe Order do
let(:yoga_product) { products(:yogamat) }
let(:drink_product) { products(:juice) }
let(:y_order_item) { order_items(:yogamat_orderitem) }
let(:j_order_item) { order_items(:juice_orderitem) }
let(:g_order_item) { order_items(:gear_orderitem) }
let(:order) { orders(:na... | true |
d258db103c7956a7a9e81ba1a09e3d54134f5e36 | Ruby | johnsudaar/bodybox | /app/controllers/commande_controller.rb | UTF-8 | 3,127 | 2.609375 | 3 | [] | no_license | class CommandeController < ApplicationController
def index
end
def choisir
@session[:proteines_value] = params["commande"]["proteines"]
@session[:glucides_value] = params["commande"]["glucides"]
@session[:legumes_value] = params["commande"]["legumes"]
@session[:box_size] = params["commande"]["box... | true |
4911757fce74e7416fd89e4c8fa63c79b6aa1d67 | Ruby | AndDom/office_clerk | /spec/models/clerk/email_spec.rb | UTF-8 | 2,058 | 2.640625 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
describe Clerk do
it "should create a new instance given a valid attribute" do
create(:clerk)
end
it "should require an email address" do
no_email_clerk = build(:clerk , :email => "")
expect(no_email_clerk).not_to be_valid
end
it "should accept valid email addresses" do
... | true |
7c87601be63e17e21dad0f57d926a9e151e4efa2 | Ruby | Searchinmena/searchinmena | /app/services/registration/storer.rb | UTF-8 | 492 | 2.609375 | 3 | [] | no_license | class Registration::Storer
attr_accessor :handlers
def perform(user, business)
success = if valid?
store
else
copy_errors
end
Registration::Response.new(
success: success, user: user, business: business)
end
private
def valid?
h... | true |
5e6b8e9c79693efd638f00fd8a69db37d0ff6dda | Ruby | tropo/tropo-webapi-ruby | /examples/ask.rb | UTF-8 | 1,329 | 2.859375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | require 'tropo-webapi-ruby'
require 'sinatra'
post '/ask.json' do
t = Tropo::Generator.new
t.ask :name => 'five',
:say => {:value => 'Please say your account number.'},
:choices => {:value => '[5 DIGITS]'}
t.ask :name => 'one',
:say => {:value => 'Please say a digit.'},
:choices => {:value => '[1 DIGI... | true |
2441d69aeacb19d9fbf678f5ef4b843354a6fbbf | Ruby | Tracsell/sendgrid-api | /spec/sendgrid/api/entities/entity_spec.rb | UTF-8 | 8,055 | 2.5625 | 3 | [
"MIT"
] | permissive | require 'spec_helper'
module Sendgrid
module API
module Entities
describe Entity do
subject { described_class }
after do
described_class.clear_attributes
end
describe '.clear_attributes' do
before do
subject.attribute :attr1
end
... | true |
e4810ae958f4bf24324a71dc292824ddb9fd5aba | Ruby | SimonGlancy/takeaway-challenge | /lib/menu.rb | UTF-8 | 617 | 3.6875 | 4 | [] | no_license | require_relative 'dish'
class Menu
M_W = 13
attr_reader :dishes
def initialize(dish_class: Dish)
@dishes = []
@dish_class = dish_class
end
def add_dish(name, price)
@dishes << @dish_class.new(name, price)
end
def show_menu
string = "DISH".ljust(M_W) + "|".center(M_W) + "PRICE ".rjus... | true |
673ee822452574152c1975f514b01974c5a31346 | Ruby | wribln/pmodbase | /test/models/function_code_test.rb | UTF-8 | 4,217 | 2.578125 | 3 | [] | no_license | require 'test_helper'
class FunctionCodeTest < ActiveSupport::TestCase
test 'ensure defaults' do
assert_equal '=', FunctionCode.code_prefix
xc = FunctionCode.new
assert_nil xc.code
assert_nil xc.label
assert xc.active
assert xc.master
assert xc.standard
refute xc.heading
end
... | true |
f455068d60dbe4d58f193a8351da89308944fd2c | Ruby | bad6e/Enigma | /lib/enigma/decrypt/decrypt_current_date.rb | UTF-8 | 376 | 3.046875 | 3 | [] | no_license | require 'date'
require './lib/enigma/encrypt/offset'
class DecryptCurrentDate
attr_accessor :provided_date
def initialize(provided_date)
@provided_date = provided_date
end
def squares_the_date
(@provided_date.to_i ** 2).to_s
end
def takes_last_four_digits
#This outputs a string of four numb... | true |
d0ec1a9a54c1d1a6ea07a57b8bc9475555e2c840 | Ruby | Siocnarff/compiler | /app/controllers/parser/parser.rb | UTF-8 | 2,978 | 3.015625 | 3 | [] | no_license | require 'parser/mapreader.rb'
require 'parser/reducer.rb'
require 'tree/tree.rb'
def parse(token_list)
token_list.push(%w[$ $])
tokenGenerator = TokenGenerator.new
mapReader = MapReader.new("#{Rails.root}/public/parserfiles/data.txt")
reducer = Reducer.new("#{Rails.root}/public/parserfiles/productions.txt")
... | true |
5bdcce0a85834b762f90ae5f889c5debf5e8cbaa | Ruby | Rinity/rinity-backend | /app/models/ride_offer.rb | UTF-8 | 1,619 | 2.59375 | 3 | [] | no_license | class RideOffer < Ride
belongs_to :driver, class_name: Driver
belongs_to :office, inverse_of: :ride_offers
has_many :ride_requests, foreign_key: :ride_id
has_many :passengers, through: :ride_requests, source: :user
validates_presence_of :direction, :time, :type, :user, :office
validates_associated :office,... | true |
b30f304fabcbf2d586160701a03d8f1c9b0cb2e8 | Ruby | itggot-isac-borghed/slutprojektvt19webbserver | /forumsida/model.rb | UTF-8 | 13,815 | 2.546875 | 3 | [] | no_license | module Model
# Opens the database
#
# @return a connection to the database
def connect()
db = SQLite3::Database.new("db/databas.db")
db.results_as_hash = true
return db
end
# Loads an image and gives it a random name
#
# @param [Hash] params form data
# @opti... | true |
fa7bc4c743ac30aaf5d2b194dd51251e19060024 | Ruby | davidpdrsn/dotfiles | /bin/search | UTF-8 | 241 | 2.546875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
require "google-search"
query = if ARGV.size == 0
$stdin.read
else
ARGV.join(" ")
end
search = Google::Search::Web.new do |search|
search.query = query
end
print search.first.uri
| true |
6d6175249c9c962b6ff48f905c8432b5762704bf | Ruby | stewartdesoto/LaunchIntroductoryProgramming | /Methods/greetings.rb | UTF-8 | 74 | 3.125 | 3 | [] | no_license | def greeting(name="Joe")
p "Yo, #{name}"
end
greeting
greeting("sammy") | true |
a12347fe83eb2c1f4f0c69996bac8b8c8a374b60 | Ruby | webmat/git_remote_branch | /lib/state.rb | UTF-8 | 1,336 | 2.75 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | module GitRemoteBranch
include ::CaptureFu
public
def get_current_branch
local_branch_information[0]
end
def local_branches
local_branch_information[1]
end
def git_found?
ret, msg = capture_process_output "#{GIT} --version"
user_version = msg.chomp.split[2]
warn ... | true |
9dad07e5c9f900b630800549b72e5dbf6c9fe0a3 | Ruby | medusa-project/medusa_storage | /test/time_helper.rb | UTF-8 | 112 | 2.671875 | 3 | [
"NCSA",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module TimeHelper
module_function
def time_equal(time_1, time_2)
time_1.to_f == time_2.to_f
end
end | true |
3b6091b961aa23e59cfe8af7259fde1c8bb1bdff | Ruby | yduarte/intro-to-tdd-rspec-and-learn-wework-bc-000 | /how_old_are_you.rb | UTF-8 | 236 | 3.390625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require_relative './current_age_for_birth_year.rb'
puts "What year were you born?"
birth_year=gets.TOPLEVEL_BINDING
users_age=current_age_for_birth_year(birth_year) +(Time.now.year-2003)
puts "You are: " +users_age.to_s + "years old" | true |
7d1c33407288eafa0f9fc3948d8d8676dc3f2e41 | Ruby | shaunabnc/TTS | /Ruby/firstprogram/program2.rb | UTF-8 | 174 | 3.234375 | 3 | [] | no_license | puts "can we go to scratchy land?"
answer = gets.chomp
if answer == "yes"
puts "yaay!!!"
else
puts "please"
end
answer = "yes"
until answer == "yes"
puts "yaaay"
end
| true |
053684728d8ab5843657fd3c9afc22d4854ac481 | Ruby | kryptykphysh/project_euler | /problem_050.rb | UTF-8 | 1,067 | 3.8125 | 4 | [] | no_license | # The prime 41, can be written as the sum of six consecutive primes:
# 41 = 2 + 3 + 5 + 7 + 11 + 13
# This is the longest sum of consecutive primes that adds to a prime below
# one-hundred.
# The longest sum of consecutive primes below one-thousand that adds to a prime,
# contains 21 terms, and is equal to 953.
# ... | true |
bb8345ce05cd283ff2b19de509f9ad497360c216 | Ruby | wongjenn/dynamic-orm-lab-web-1116 | /lib/student.rb | UTF-8 | 432 | 2.5625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require_relative "../config/environment.rb"
require 'active_support/inflector'
require 'interactive_record.rb'
class Student < InteractiveRecord
self.column_names.each do |col_name|
attr_accessor col_name.to_sym
end
def self.find_by(hash)
key = hash.keys[0]
value = hash.values[0]
... | true |
c29f653260b583602a47519ea67e153600819f05 | Ruby | benmathes/ProjectEuler | /9.rb | UTF-8 | 1,059 | 4 | 4 | [] | no_license | =begin
A Pythagorean triplet is a set of three natural numbers, a b c, for which,
a**2 + b**2 = c**2
For example, 3**2 + 4**2 = 9 + 16 = 25 = 5**2.
There exists exactly one Pythagorean triplet for which a + b + c = 1000.
Find the product abc.
=end
cap = 1000
# the really stupid way of doing this, which took ab... | true |
495d6d042da4e5478488d966f01d4cc6d9c01d6d | Ruby | MezzoForBezzo/GildedRose-Refactoring-Kata | /ruby/item/pass.rb | UTF-8 | 762 | 3.171875 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
class Pass < Item
QUALITY_MAX = 50
QUALITY_MIN = 0
CHANGE_OF_QUALITY = 1
CHANGE_OF_SELL_IN = 1
def initialize(name, sell_in, quality)
super(name, sell_in, quality)
end
def update
update_quality
update_days_to_sell
end
private
def update_quality
if s... | true |
b97110f2a2782fa30fd9e68c860d8e7053945654 | Ruby | NoahZinter/battleship | /spec/player_spec.rb | UTF-8 | 1,495 | 3.34375 | 3 | [] | no_license | require './lib/board'
require './lib/cell'
require './lib/game'
require './lib/player'
require './lib/ship'
describe Player do
before(:each) do
board = Board.new(4)
@player = Player.new(board)
end
describe '#initialize' do
it 'exists' do
expect(@player).is_a? Player
end
it 'has a board... | true |
3e57d45dc7c37bfc5b25dfb9ab8a274b9e5a6fba | Ruby | jotonyguerra/connect4 | /lib/board_space.rb | UTF-8 | 294 | 3.171875 | 3 | [] | no_license | require_relative "board"
require_relative "player"
require 'pry'
class BoardSpace
attr_accessor :spot, :player
def initialize(spot = nil)
@spot = spot
end
def printspace
if @spot
"#{@spot} "
else
" "
end
end
def occupied?
!@spot.nil?
end
end
| true |
43bd5e91e31d5abf21af6f63bfdec9c3a342a90d | Ruby | Abhishek87654321/Ruby_task | /admin_login.rb | UTF-8 | 1,011 | 3.140625 | 3 | [] | no_license | require_relative 'admin.rb'
require_relative 'book.rb'
require_relative 'back.rb'
class Admin_Login
def admin_login
puts " please enter admin password "
pwd = gets.chomp.to_i
if( pwd == 123 )
puts " succesfully logged in "
Admin.new.admin_rights
else
puts " please try... | true |
c6c6efc3095bb9d759371837a8e63e9710ab24c7 | Ruby | susanev/advent-of-code | /2017/day25/part1.rb | UTF-8 | 1,098 | 3.375 | 3 | [] | no_license | # susan evans
# last edited 12/24/2017
# advent of code 2017, day 25, part 1
class Part1
def initialize(file_name)
@state = :A
@pos = 0
@tape = {}
@instructions = {A: {zero_dir: 1, zero_state: :B, one_val: 0, one_dir: -1, one_state: :E},
B: {zero_dir: -1, zero_state: :C, one_val: 0, one_dir: 1, one_sta... | true |
1f04de2744332a2b22fbead8a33404ab160f5f71 | Ruby | troessner/reek | /lib/reek/smell_detectors/too_many_methods.rb | UTF-8 | 1,520 | 2.8125 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require_relative 'base_detector'
module Reek
module SmellDetectors
#
# A Large Class is a class or module that has a large number of
# instance variables, methods or lines of code.
#
# +TooManyMethods+ reports classes having more than a configurable number
# of ... | true |
859a0591e92e29f82238138aa55f7ad741a20ecd | Ruby | abyx/ynab-israel-parse | /amex_isracard.rb | UTF-8 | 831 | 2.578125 | 3 | [] | no_license | require_relative './ynab'
lines = File.open(ARGV[0], 'r:windows-1255').read().encode('utf-8').lines()
domestic = lines[4..-1].take_while do |line|
line !~ /^\t/
end.map do |line|
line.split(/\t/)
end.map do |line|
[line[1], line[0], line[3].sub(/,/, '')]
end
abroad = (lines.drop_while do |line|
line !~ /תארי... | true |
e2579b46f5e4d30893654d700fb054de8da5ac97 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/rna-transcription/b9fecbcf82224518bbbb29da26507717.rb | UTF-8 | 474 | 3 | 3 | [] | no_license | class Complement
def self.of_dna(s)
ns = ''
for i in 0...s.length
case s[i]
when 'G' then ns+='C'
when 'C' then ns+='G'
when 'T' then ns+='A'
when 'A' then ns+='U'
end
end
ns
end
def self.of_rna(s)
ns = ''
for i in 0...s.length
case s[i]
... | true |
5e5ca8fee16bb8a045a1bece222ad1bd1918e533 | Ruby | dkackar/project_cli_mastermind | /master_mind.rb | UTF-8 | 2,103 | 3.90625 | 4 | [] | no_license | require_relative './resources.rb'
#runs game
class MasterMind
def initialize
#game_board
@board = GameBoard.new
end
def print_intro
puts
puts "Welcome to Mastermind!"
puts "Pick your opponent: Human or Computer."
puts "Pick your role: Codemaker or Codebreaker"
puts
end
def play... | true |
629fe1d710d4a733eff049f9b669175498af2bca | Ruby | alu0100499377/prct9 | /lib/examen.rb | UTF-8 | 839 | 3.859375 | 4 | [
"MIT"
] | permissive | require "exam/lista.rb"
require "exam/version.rb"
require "exam/pregunta.rb"
require "exam/simpleSelection.rb"
require "exam/trueFalse.rb"
class Examen
attr_reader :num
def initialize(num)
@num = num
end
def rellernar()
Listado = Lista.new()
while var <= @num
puts "¿que tipo de pregunta es? 1-Selecci... | true |
946edbf39040b708d49dd71cb19c19643714f818 | Ruby | csb324/wdi_2_ruby_hw_rspec_apartments | /lib/credit_rating.rb | UTF-8 | 276 | 2.75 | 3 | [] | no_license | module CreditRating
def credit_rating
case self.credit_score
when nil
nil
when (0...560)
"bad"
when (560...660)
"mediocre"
when (660...725)
"good"
when (725...760)
"great"
else
"excellent"
end
end
end
| true |
edb64956913591b1e3f99311b1d02b6de6872418 | Ruby | GIL-GALILEO/alma-invoice-to-ps | /lib/objects/file_handler.rb | UTF-8 | 725 | 2.5625 | 3 | [] | no_license | # frozen_string_literal: true
# Utility class for handling Alma XML files
class FileHandler
DATA_PATH = 'data'
OUTPUT_PATH = 'output'
ARCHIVE_PATH = 'archive'
ORIGINALS_PATH = 'originals'
def self.get_files_from(path)
Dir["#{path}/*.xml"]
end
def self.archive(xml)
output_path = File.join(DATA_P... | true |
5db81dfa240bac9c876374002fef46071f03caf5 | Ruby | AlehandroWar/thinknetica_ruby | /lesson 2/lesson_2_5.rb | UTF-8 | 758 | 3.359375 | 3 | [] | no_license | # frozen_string_literal: true
puts 'введите число дня'
day = gets.chomp.to_i
puts 'введите номер месяца'
month = gets.chomp.to_i
puts 'введите год'
year = gets.chomp.to_i
months = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
leap_year = (year % 4).zero? && year % 100 != 0 || (year % 400).zero?
if leap_year == true... | true |
ce08ed0f98f1be2aba353743340c8b0b35f7f758 | Ruby | maximilianfischer/WebServerInRuby | /Request.rb | UTF-8 | 580 | 2.90625 | 3 | [] | no_license | require 'socket'
require 'uri'
class Request
WEB_ROOT = './public'
def initialize(socket)
@request_line = socket.gets
@path = requested_file()
STDERR.puts "Inside Requset.rb initializer: #{@request_line}"
end
attr_reader :path
def requested_file()
request_uri = @request_line.split(" ")... | true |
9badf4e244f3a07e064716a3ee315c5fe1e7ed46 | Ruby | johanek/puppet-parse | /lib/vendor/puppet/util/storage.rb | UTF-8 | 2,319 | 2.65625 | 3 | [
"MIT"
] | permissive | require 'yaml'
require 'sync'
require 'puppet/util/file_locking'
# a class for storing state
class Puppet::Util::Storage
include Singleton
include Puppet::Util
def self.state
@@state
end
def initialize
self.class.load
end
# Return a hash that will be stored to disk. It's worth noting
# her... | true |
957c4c686b6336c90d1ff80a2c4292e2d6b1584d | Ruby | eduardschaeli/smeargle | /tools/observe_history.rb | UTF-8 | 1,945 | 2.5625 | 3 | [] | no_license | EXECUTION_DIR = `pwd`.chomp
Dir.chdir(`git rev-parse --show-toplevel`.chomp)
def quit commit
`git checkout #{commit}`
`git stash pop`
#refresh the file system incase the execution directory did not exist in one
#of the commits that was checkout out
`cd #{EXECUTION_DIR}`
exit
end
def clean_up
`rm #{TEMP... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.