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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
15f273368fc276e84e3b2a1db47a12ecdb7d247e | Ruby | abbeywaldron/alerter | /app/models/on_mon.rb | UTF-8 | 4,648 | 2.75 | 3 | [
"CC0-1.0",
"LicenseRef-scancode-public-domain"
] | permissive | class GraphData
attr_accessor :data
attr_accessor :errors
attr_accessor :start_time
attr_accessor :end_time
def initialize
@time_format1 = "%Y-%m-%dT%H:%M:%S.000Z"
@time_format2 = "%Y/%m/%d %H:%M:%S"
end
def load(json)
graph_data = Array.new
json['values'].each do |val|
graph_data ... | true |
d61bd1e2191cf54c9b58613f2924026dced01a97 | Ruby | HOT-Media/programming_foundations | /lesson_3/practice_problems_medium_1_1.rb | UTF-8 | 281 | 3.421875 | 3 | [] | no_license |
each iteraion number is 1 -> 10
then " " * number indents the string
the number of spaces that resulted from
multiplying the iteration number and the " " space
10.times { |number| puts (" " * number) + "The Flintstones Rock!" } | true |
6cd568d02c33e5260f86ee95687850e2bf690474 | Ruby | ivanjankovic/e-treehouse | /ruby/address_book/address.rb | UTF-8 | 417 | 3.21875 | 3 | [] | no_license | class Address
attr_accessor :kind, :street_1, :street_2, :city, :state, :postal_code
def to_s(format = 'short')
address = ''
csp = "#{city}, #{state}, #{postal_code}"
case format
when 'short'
address += "#{kind}: #{street_1}#{ street_2 if !street_2.nil?}, #{csp}"
when 'long'
addre... | true |
0c02b2b36247a54e44943459dc37bf9f9da7d851 | Ruby | nacocode/RubyBook | /Exercises/exercise2.rb | UTF-8 | 318 | 4.0625 | 4 | [] | no_license | array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
array.each do |i|
puts i if i > 5
end
=begin
[Launch School's Solution]
arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
# one line version
arr.each { |number| puts number if number > 5 }
# multi-line version
arr.each do |number|
if number > 5
puts number
end
end
=end | true |
028dc85629a00fcc6b4a823329903697dc69e278 | Ruby | carolinecollaco/RubyCodeAcademy | /BlocosSaoComoMetodosSemNome.rb | UTF-8 | 84 | 2.78125 | 3 | [] | no_license | 1.times do
puts "Sou um bloco de código!"
end
1.times { puts "Assim como eu!" }
| true |
e4392c40ee6b81eb6cc39458da3650c8826cc1ca | Ruby | siannopollo/amazon_products | /lib/amazon_products/product.rb | UTF-8 | 6,470 | 2.6875 | 3 | [
"MIT"
] | permissive | module AmazonProducts
# Products are just items brought back by an AmazonProduct::Search.
#
# To find out what methods are available to a particular Product, just
# inspect the #attribute_names method. This can be useful since these
# attributes change with the type of AmazonProducts::ResponseGroup used. So
... | true |
6223a1d3c8603e0e8bd0d4494b15281f6b8de654 | Ruby | rleer/diamondback-ruby | /lib/druby/profile/collector.rb | UTF-8 | 688 | 2.703125 | 3 | [
"BSD-3-Clause"
] | permissive |
module DRuby
class Profile
class Collector
def initialize(file, append)
@entries = {}
@file = file
@append = append
end
def register(name)
fail "tried to add collection #{name} twice" if @entries.key? name
@entries[name] = {}
end
def finali... | true |
901bb8b9883ea58e4c8db65445f0e4bcf6e63a63 | Ruby | krickwix/hailstorm | /CloudForms-Internals/automate/Investigative_Debugging/Discovery/ObjectWalker.class/__methods__/object_walker.rb | UTF-8 | 39,721 | 2.765625 | 3 | [
"Apache-2.0"
] | permissive | #
# object_walker
#
# Can be called from anywhere in the CloudForms/ManageIQ automation namespace, and will walk the automation object structure starting from $evm.root
# and dump (to automation.log) its attributes, any objects found, their attributes, virtual columns, and associations, and so on.
#
# Author: Peter M... | true |
22135ba0fd410d791b20e3c51d125ff0a10e6fb7 | Ruby | david-holtkamp/public_library_1911 | /lib/library.rb | UTF-8 | 494 | 3.09375 | 3 | [] | no_license | class Library
attr_reader :name,
:books,
:authors
def initialize(name)
@name = name
@books = []
@authors = []
end
def add_author(author)
@authors << author
end
def add_book(book)
@books << book
end
def publication_time_frame_for(author)
all_books = books... | true |
8857a65eaa7d23a801054eff818ab79a1074cfba | Ruby | sambostock/toasty-breadis | /test/toaster_test_helper.rb | UTF-8 | 879 | 2.53125 | 3 | [] | no_license | # frozen_string_literal: true
require 'breadis_test_helper'
module ToasterTestHelper
extend ActiveSupport::Concern
include BreadisTestHelper
class_methods do
def each_orderable_toppings
(0..Toaster::SERVED_TOPPINGS.length).flat_map do |length|
Toaster::SERVED_TOPPINGS.permutation(length)
... | true |
d99eed141c38e517b3fb8a0829889b1fb20c6fd4 | Ruby | Tim-2901/mill | /bin/main.rb | UTF-8 | 9,229 | 2.515625 | 3 | [] | no_license | require 'gosu'
require 'bin/client/OfflineGame'
require 'bin/client/Button'
require 'bin/client/TextField'
require 'bin/client/game/ClientGame'
require 'bin/client/game/Connection'
require 'bin/server/server'
require 'bin/client/lobby/Lobby'
require 'bin/server/console'
class Window < Gosu::Window
WIDTH, ... | true |
b8f5560a8da5e8c7e821e323607b86d203786cac | Ruby | Bechev/ruby-collaborating-objects-lab-v-000 | /lib/mp3_importer.rb | UTF-8 | 449 | 2.921875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class MP3Importer
def initialize(test_music_path)
@test_music_path = test_music_path
@files = []
@library = []
end
def path
@test_music_path
end
def files
Dir.foreach(@test_music_path){|filename|
if filename.include? ".mp3"
@files << filename
end
}
return @fi... | true |
fe2e2a3f8c8e4e1c367edfe7486516e2f83a2a32 | Ruby | vinnydiehl/my_rpg | /lib/hero.rb | UTF-8 | 2,233 | 3.375 | 3 | [] | no_license | # encoding: utf-8
class Hero
##Hero info
attr_reader :name
##combat values
attr_accessor :hp, :dam, :crit_chance, :block_chance, :block_value, :crit_value
##Hero armor
attr_accessor :helmet, :breastplate, :trousers, :gloves, :boots
def initialize( name )
@name = name
@hp ... | true |
e056f03ddbda42c8ee3c02329a88444aeb935c0e | Ruby | iacopo-papalini/rubyMIX | /src/core/unit/i_o_unit.rb | UTF-8 | 1,025 | 2.671875 | 3 | [
"MIT"
] | permissive | require 'core/unit/abstract_unit'
require 'devices'
class IOUnit < AbstractUnit
def initialize(cpu, logger)
# Just to let IntelliJ detect the field, otherwise it keeps complaining
@cpu = nil
@logger = nil
super(cpu, logger)
@devices = {}
end
def bind_device(id, first_stream, second_stream)
... | true |
675ef5cbcdd3fbf7d0279f34695bdac8b5846e37 | Ruby | ARERA-it/inviti | /app/helpers/appointees_helper.rb | UTF-8 | 2,280 | 2.515625 | 3 | [
"MIT"
] | permissive | module AppointeesHelper
def appointee_status_label(status)
s = case status
when "proposal", "prop_accepted", "prop_refused"
"proposta"
when "app_waiting", "app_refused", "app_accepted", "app_w_consent"
"incarico"
when "canceled"
"annullato"
end
c = case status
when "prop... | true |
1155ab99a235c497c059995b087d1359deff00a8 | Ruby | janlucaberger/W3D5 | /active_record/lib/04_associatable2.rb | UTF-8 | 858 | 2.59375 | 3 | [] | no_license | require_relative '03_associatable'
# Phase IV
module Associatable
# Remember to go back to 04_associatable to write ::assoc_options
def has_one_through(name, through_name, source_name)
define_method(name) do
through_options = self.class.assoc_options[through_name]
source_options = through_options... | true |
0225b6df31dd65e4993dc41ef0c1f063e5b0ddb3 | Ruby | dieu-detruit/lecture-algorithm | /Week3/1013q2.rb | UTF-8 | 473 | 3.234375 | 3 | [] | no_license | # -*- coding: utf-8 -*-
include(Math)
def make2d(height, width)
Array.new(height){ Array.new(width,0) }
end
def b(s, x, y)
r = s / 2
d = distance(x, y, r, r)
# if を使ってbを計算
if d<=r
(r-d)/r
else
1
end
end
def distance(x, y, p, q)
# 点(x,y)と点(p,q)の間の距離
sqrt( (x-p)**2 + (y-q)**2 )
end
def sphere... | true |
a49c0029eeabc7c44b4052a1ffa97e59d35c740e | Ruby | yutakakinjyo/minitukuRuby | /isa.rb | UTF-8 | 235 | 3.390625 | 3 | [] | no_license | class Foo
def foo
puts "foo"
end
end
class Bar < Foo
def bar
puts "bar"
end
end
class Baz < Bar
def baz
puts "baz"
end
end
baz = Baz.new
p baz.is_a?(Baz)
p baz.is_a?(Bar)
p baz.is_a?(Foo)
p baz.is_a?(String)
| true |
f1fe47186980eefcd96bae6b0e84f5a5bc252988 | Ruby | jjyr/minidown | /lib/minidown/element.rb | UTF-8 | 644 | 2.75 | 3 | [
"MIT"
] | permissive | require 'minidown/html_helper'
module Minidown
class Element
attr_accessor :content, :doc, :nodes, :children
include HtmlHelper
def raw_content
@content
end
def raw_content= str
@content = str
end
def unparsed_lines
doc.lines
end
def initialize doc, cont... | true |
bc9f293753e2c2d2cb15aec3e2f66e8e6fcea95e | Ruby | johnfelixespinosa/key-for-min-value-v-000 | /key_for_min.rb | UTF-8 | 491 | 3.3125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | # prereqs: iterators, hashes, conditional logic
# Given a hash with numeric values, return the key for the smallest value
# group_of_nums = {blake: 500,
# ashley: 2,
# adam: 1 }
def key_for_min_value(friends_iq_scores)
lowest_iq_score = nil
dumb_friend = nil
friends_iq_scor... | true |
49da9efd64940ccd8827eb0bc7955d46e0fcb747 | Ruby | kouno/basic_hooks | /lib/basic_hooks.rb | UTF-8 | 819 | 2.625 | 3 | [] | no_license | require 'basic_hooks/callbacks'
require 'basic_hooks/listener'
module BasicHooks
def self.included(base)
base.extend(BasicHooks::Callbacks)
base.class_eval do
def self.basic_hooks
@basic_hooks ||= BasicHooks::Listener.new
end
end
end
end
class Object
def notify_basic_hooks(*args... | true |
d6303c0bbc65a4905a7810af9bf4d3d8f636ca27 | Ruby | codyruby/cursus_thp | /week3/the_hacking_gossip_ruby_version_POO/lib/gossip.rb | UTF-8 | 771 | 2.921875 | 3 | [] | no_license | class Gossip
attr_reader :author, :content
def initialize(author, content)
@content = content
@author = author
@arr = Hash.new
@arr[@author] = @content
end
def save
header = [
'Author',
'Content'
]
CSV.open('db/gossip.csv'... | true |
d485d81478c843182996787a1d0b4ddbfd52cc40 | Ruby | Alung-0/design-2 | /ruby/academy/4.4.eachloop.rb | UTF-8 | 773 | 3.484375 | 3 | [
"Apache-2.0"
] | permissive |
# Iterating over Hashes
friends = ["Milhouse", "Ralph", "Nelson", "Otto"]
family = { "Homer" => "dad",
"Marge" => "mom",
"Lisa" => "sister",
"Maggie" => "sister",
"Abe" => "grandpa",
"Santa's Little Helper" => "dog"
}
friends.each { |x| puts "#{x}" }
family.each { |x, y| puts "#{x}: #{y}" }
# Iterating... | true |
7992b651560482ca651e2b9559393f6546250179 | Ruby | feigningfigure/WDI_NYC_Apr14_String | /w02/d01/Declan_Van_Welie/class_exercises/main.rb | UTF-8 | 411 | 2.78125 | 3 | [] | no_license | require 'sinatra'
require 'sinatra/reloader'
get '/' do
"Hello World!"
end
#This will interpolate whatever we input after the "/" for the url at localhost: 4567
get '/:name' do
"Hello, my name is #{params[:name]}"
end
get '/:name/:meal' do
"I'm #{params[:name]}, and I love #{params[:meal]}"
end
# # This is equ... | true |
a3c06f3096f96552cedafaebde9e55f18d6e5c3c | Ruby | ayanit1/lrthw | /chap01/ex17.rb | UTF-8 | 1,161 | 3.5 | 4 | [] | no_license | =begin
---BEFORE STUDY DRILLS---
from_file, to_file = ARGV
puts "Copying from #{from_file} to #{to_file}"
# we could do these two on one line, how?
in_file = open(from_file)
indata = in_file.read
puts "The input file is #{indata.length} bytes long"
puts "Does the input file exist? #{File.exist?(to_file)}"
puts "Rea... | true |
4176f6647398ffc79f8f0b0ffe8101e68a1522b7 | Ruby | LMacchi/file_purge | /lib/puppet/type/file_purge.rb | UTF-8 | 859 | 2.515625 | 3 | [] | no_license | # file_purge/lib/puppet/type/file_purge.rb
Puppet::Type.newtype(:file_purge) do
desc "Puppet type that tells Puppet to start monitoring a directory for unwanted files"
ensurable()
newparam(:target, :namevar => true) do
desc "Directory to monitor - Must be a fully qualified path"
validate do |value|
... | true |
6a82ecb2688f55a2460b9ca4e3d634932f6102b6 | Ruby | jd-schmidt/code | /ruby/hard/ex10.rb | UTF-8 | 256 | 2.921875 | 3 | [] | no_license | tabby_cat = "\t I'm tabbed in."
persian_cat = "I'm split\non a line."
backslash_cat = "I'm \\ a \\ cat."
fat_cat = <<END
I'll do a list:
\t* cat food
\t*\a fishies
\t* Catnip\n\t* Grass
END
puts tabby_cat
puts persian_cat
puts backslash_cat
puts fat_cat
| true |
e2257a01eed7660da630475f9fcfe8e46dfd121f | Ruby | reggie-c/vivixx-1 | /challenges/loginsys.rb | UTF-8 | 2,460 | 2.859375 | 3 | [] | no_license | class
$database = [{ name: 'William',
company: 'Vivixx Academy',
reason: 'Coding Bootcamp',
job_position: 'Student/Trainee',
contact_no: 9205107795 ,
time_info: 0 #Timestamp
}, {
name: 'Dea',
company: 'Vivixx Academy',
reason: 'Coding Bootcamp',
job_position: 'Student/Trainee',
contact_no: 9... | true |
659efdfbf1ebdfea321ba6ccfb707f9665860886 | Ruby | brandfolder-archive/jsonapionify | /lib/jsonapionify/structure/helpers/validations.rb | UTF-8 | 10,326 | 2.515625 | 3 | [
"MIT"
] | permissive | require 'unstrict_proc'
require 'active_support/core_ext/class/attribute'
module JSONAPIonify::Structure
module Helpers
module Validations
extend ActiveSupport::Concern
using UnstrictProc
module ClassMethods
# Raise the validation errors
def validation_error(message)
... | true |
947b97833fa44405d99684aaa65a79a47bc452ae | Ruby | dmiz6393/nyc-pigeon-organizer-london-web-060319 | /nyc_pigeon_organizer.rb | UTF-8 | 480 | 3.15625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def nyc_pigeon_organizer(pigeon_data)
new_hash={}
pigeon_data.each do |type_data,data|
data.each do |more_info, name|
name.each do |names|
if new_hash.has_key?(names)
if new_hash[names].has_key?(type_data)
new_hash[names][type_data] << more_info.to_s
else
new_hash[names][type_da... | true |
a0051642bae9ba688556e309bff3f0e965b30218 | Ruby | granparkrb/baseball_count | /hamakn/lib/baseball_count.rb | UTF-8 | 942 | 3.328125 | 3 | [] | no_license | StructBallCount = Struct.new(:s, :b, :o)
class BaseballCount
def initialize
@count = StructBallCount.new(0, 0, 0)
end
def inspect
[@count.o, @count.s, @count.b].join ""
end
def strike
@count.s += 1
judge_swing_out
end
def ball
@count.b += 1
judge_fourball #英語だと BB = Base on bal... | true |
3c661c7b20087a48b068f704897442a51ddfc851 | Ruby | Mackdatascience007/Projet-validant-POO | /lib/player_2.rb | UTF-8 | 2,405 | 3.65625 | 4 | [] | no_license | class Player
attr_accessor :name, :life_points
def initialize(name)
life_points = 10
@name = name
@life_points = life_points.to_i
end
def show_state
return "#{@name} a #{@life_points} points de vie"
end
def gets_damage(damage_received)
@life_points -... | true |
f64825c56bdcd81718e46f19c5063ceefce71fce | Ruby | jesse-spevack/ibotta_turing_job_experience | /lib/purchase_event_queue.rb | UTF-8 | 189 | 2.71875 | 3 | [] | no_license | require 'json'
class PurchaseEventQueue
def initialize
@events = JSON.parse(File.read('./data/purchase_events.json'))
end
def get_next_purchase_event
@events.shift
end
end | true |
a81c833802ce93fbd0c04b1abbde48f39ad40c33 | Ruby | Far-Traveller/THP_projects | /w03_d1_ruby_event_poo/app.rb | UTF-8 | 1,855 | 3.078125 | 3 | [] | no_license | # lignes très pratiques qui appellent les gems du Gemfile. On verra plus tard comment s'en servir ;) - ça évite juste les "require" partout
require 'bundler'
Bundler.require
# lignes qui appellent les fichiers lib/user.rb et lib/event.rb
# comme ça, tu peux faire User.new dans ce fichier d'application. Top.
require_re... | true |
c7216b056cfe667a3cb4f5a10c954e599bf3b313 | Ruby | zongyuwu/RSA_ChosenCiphertextAttack | /rsachosenciphertextattack_api.rb | UTF-8 | 1,583 | 3.140625 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'openssl'
class RSACCA
def initialize(n=nil, e=65537, c=nil)
@N = n.to_i
@E = e.to_i
@C = c.to_i
@r = 3
@rr = nil
@M = nil
raise "Not enough argvment to solve" if sanitycheck == false
end
def chosencipher
@r = 3
@rr = @r.to_bn.mod_inverse(@N).to_i... | true |
f67ea7c1a6f4bfd7add48aeba62e23442b7a2330 | Ruby | lizamuromskaya/ruby_tasks | /task#2/spec/histogram_spec.rb | UTF-8 | 750 | 2.859375 | 3 | [] | no_license | # frozen_string_literal: true
require 'rspec'
require_relative 'spec_helper'
require_relative '../histogram'
RSpec.describe 'histogram' do
describe '#to_histogram' do
context 'when array is empty' do
let(:array) { [] }
it 'returns {}' do
expect(to_histogram(array)).to eq({})
end
e... | true |
fb3ddc8bbb858fbdfee8a7682cc7c0fe17ce5fc1 | Ruby | akshaychanna/all | /data/data/study_material/akshay/ruby/reduce.rb | UTF-8 | 92 | 3.390625 | 3 | [] | no_license | sum = 0
p [1, 2, 3].reduce() do |sum, n|
sum + n
p sum
end
p [1,2,3].reduce(:+)
puts sum
| true |
599876f749e9633f8e532105db8f8e9f216aa74a | Ruby | imaizumi-satoko/travel_task | /travel.rb | UTF-8 | 944 | 3.953125 | 4 | [] | no_license | puts <<~TEXT
旅行プランを選択して下さい。
1. 沖縄旅行(10000円)
2. 北海道旅行(20000円)
3. 九州旅行(15000円)
TEXT
while true do
puts "プランの番号を選択 >"
plan_num = gets.to_i
break if (1..3).include?(plan_num)
puts "1~3の番号を入力してください。"
end
case plan_num
when 1
place = "沖縄"
price = 10000
when 2
place = "北海道"
price = 20000
when ... | true |
9e7d637999396e81e2bfee895a198e66124ec367 | Ruby | jamieberrier/ruby-objects-has-many-through-lab-v-000 | /lib/patient.rb | UTF-8 | 794 | 3.5625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class Patient
attr_accessor
@@all = []
def initialize(name)
@name = name
@@all << self
end
def self.all
@@all
end
# takes in an argument of a doctor and a date and creates a new appointment.
# The appointment should know that it belongs to the patient.
def new_appointme... | true |
135e0d860fc6f5b5ea7142d4badedc5202a2c4a9 | Ruby | emailingmanagement/e2m_kit | /lib/extensions/rails.rb | UTF-8 | 7,906 | 2.578125 | 3 | [] | no_license | ### ActionView
# exception raised if no label found
module ActionView
module Helpers
module TranslationHelper
# Delegates to I18n#translate but also performs two additional functions. First, it'll catch MissingTranslationData exceptions
# and turn them into inline spans that contains the missing key... | true |
fa33b4050b15c86b04c1038eb9cc07af1366e0de | Ruby | jvargas98/game-of-life | /lib/game_of_life.rb | UTF-8 | 1,378 | 3.40625 | 3 | [] | no_license | # frozen_string_literal: true
require 'matrix'
require 'prime'
require_relative 'cell'
require_relative 'board'
class GameOfLive
attr_reader :rows, :cols
def initialize(width, height)
@rows = height
@cols = width
@board = Board.new(width, height)
@matrix_cells = Matrix.build(height, width) { Cell... | true |
859374f034233a0c503e12ccaa5189e5a4e50124 | Ruby | miketlawrence/vita-min | /app/services/standardize_address_service.rb | UTF-8 | 2,116 | 2.78125 | 3 | [] | no_license | require 'net/http'
require 'uri'
# PLEASE do NOT use this service to standardize addresses in bulk (do NOT use in backfills)
# as that violates the terms of agreement with USPS and will result in access being revoked.
class StandardizeAddressService
def initialize(intake)
@_street_address = [intake.street_addres... | true |
053f287f31cdf9f357865c4c8f63b268b0302d72 | Ruby | katmsft/azure-storage-ruby-stress | /ruby_runtime/lib/ruby/gems/2.4.0/gems/ruby_dig-0.0.2/lib/ruby_dig.rb | UTF-8 | 305 | 2.640625 | 3 | [
"BSD-3-Clause",
"Ruby",
"MIT"
] | permissive | module RubyDig
def dig(key, *rest)
if value = (self[key] rescue nil)
if rest.empty?
value
elsif value.is_a?(RubyDig)
value.dig(*rest)
end
end
end
end
if RUBY_VERSION < '2.3'
class Array
include RubyDig
end
class Hash
include RubyDig
end
end
| true |
470b273f149b03fc04dbad8c78fd1970c9206357 | Ruby | inesikhlef/Pair-Programming | /exo_17.rb | UTF-8 | 327 | 3.921875 | 4 | [] | no_license | puts "Quel age as-tu ?"
age = gets.chomp.to_i #age soit x
this_year = 2019
age_times = 0 # il y a tant d'annees soit y
while age > 0
age -=1
age_times +=1
if age == age_times
puts "Il y a #{age} ans, tu avais la moitie de l'age que tu as aujourd'hui"
else
puts "Il y a #{age} ans, tu avais #{age_times} ans"
... | true |
5b712e2be1b281f779016bdbbb1af8b5014357e3 | Ruby | s1nestesia/Ruby | /Lab3 ruby/lab3.2.rb | UTF-8 | 1,204 | 3.53125 | 4 | [] | no_license | def readfile
if File.exist?("Balance.txt")
File.open("Balance.txt") do
balance_file = File.readlines("Balance.txt")
bal = balance_file[0]
@balance = bal.to_i
end
else
@balance = 100.0
end
end
def deposit
puts "Введите сумму"
value=gets.chomp.to_i
dep=@balance
... | true |
0dd20d713b91045583e91d04a686bc4190f193d4 | Ruby | wahyd4/sohub-rails | /lib/weixin/text_util.rb | UTF-8 | 751 | 2.6875 | 3 | [] | no_license | module TextUtil
def is_help(content)
content = content.downcase
content== 'h' || content == 'help'
end
def is_menu(content)
content = content.downcase
content == 'm'||content == 'menu'
end
def is_normal_message(content)
content.match('^[-]{1}[^-+]{1}') != nil
end
def is_notice(conte... | true |
71fa058922ae1efabdcc15553445d030d434af12 | Ruby | ludemeury/desafio-back-end | /app/models/shop.rb | UTF-8 | 352 | 2.53125 | 3 | [] | no_license | # frozen_string_literal: true
class Shop < ApplicationRecord
belongs_to :owner
validates :name,
length: { within: 1..255 },
presence: true,
uniqueness: { scope: %i[owner_id] }
has_many :financial_movements
def balance
financial_movements.sum { |e| e.output? ? -e.value... | true |
f8d9225da9d679ab29fb70c6a31fb6cdf0bdccac | Ruby | alpheios-project/puppet | /site-modules/icinga/files/plugins/check_aws_resources | UTF-8 | 669 | 2.65625 | 3 | [
"Apache-2.0",
"GPL-3.0-only"
] | permissive | #!/usr/bin/ruby
require File.dirname(__FILE__) + '/lib/aws_resources_checker.rb'
require 'optparse'
# Main script
OptionParser.new do |opts|
opts.banner = "Usage: #{$0} [options]\n \
\n\
Checks the number of AWS resources present."
opts.separator ""
opts.separator "Specific options:"
opts.on("-e EC... | true |
f520d8934a8aa5980d0533b324fe7d5b5096d6ad | Ruby | topazproject/topaz | /lib-ruby/stringio.rb | UTF-8 | 13,990 | 2.8125 | 3 | [
"BSD-3-Clause"
] | permissive | class IO
module Writable
end
module Readable
end
end
class StringIO
include Enumerable
include IO::Writable
include IO::Readable
DEFAULT_RECORD_SEPARATOR = "\n" unless defined?(::DEFAULT_RECORD_SEPARATOR)
# This is why we need undefined in Ruby
Undefined = Object.new
class Data
attr_acces... | true |
47e1bf4050b22d692108f83a8504afcab732b7c2 | Ruby | lasanders/ruby-inheritance-lab-v-000 | /lib/user.rb | UTF-8 | 126 | 2.734375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | class User
attr_accessor :first_name, :last_name
def initialize
@fist_name = first_name
@last_name = last_name
end
end
| true |
419f10ef04e4b9294c1ea96ab4f7bd99cafb6b70 | Ruby | crojasu/investigacion | /app/controllers/rols_controller.rb | UTF-8 | 1,909 | 2.5625 | 3 | [] | no_license | require 'csv'
require 'json'
require 'open-uri'
require 'i18n'
class RolsController < ApplicationController
skip_before_action :authenticate_user!
helper_method :import
before_action :generales
def index
@rols= Rol.all
end
def todos
@personajes= Personaje.all
@personajes.map do |rol|
if rol.name=... | true |
786ba4aa66010533dbaa49decbcd62698fd3c631 | Ruby | atchyut-re/expense_manager | /app/helpers/expenses_helper.rb | UTF-8 | 445 | 2.625 | 3 | [
"MIT"
] | permissive | module ExpensesHelper
def current_day
date = Date.today
end
def current_week
date = Date.today
[date.beginning_of_week, date.end_of_week]
end
def current_month
date = Date.today
[date.beginning_of_month, date.end_of_month]
end
def current_year
date = Date.today
[date.beginning_of_year, da... | true |
1377f71977685773902f4c3c8c7b3c424c518ac2 | Ruby | ministryofjustice/laa-apply-for-legal-aid | /app/services/cfe_civil/components/properties.rb | UTF-8 | 1,327 | 2.515625 | 3 | [
"LicenseRef-scancode-proprietary-license",
"MIT"
] | permissive | module CFECivil
module Components
class Properties < BaseDataBlock
delegate :other_assets_declaration, to: :legal_aid_application
def call
{
properties: {
main_home:,
additional_properties: [second_home],
},
}.to_json
end
private
... | true |
78e71d51f9f123c40372e52c72530712ecad5a7f | Ruby | leviorca/flickr_etv | /lib/flickr_etv/collage_maker.rb | UTF-8 | 830 | 2.75 | 3 | [
"MIT"
] | permissive | require 'rmagick'
module FlickrEtv
class CollageMaker
include Magick
def self.build(opts = {})
return if (opts[:photos].nil? or opts[:photos].empty?)
properties = {
width: 1920,
height: 1080,
output: "collage.jpg"
}.merge(opts)
list = photo_list(properties[... | true |
0effaf58c6cae7bf52540dc9bcbab663661b74ff | Ruby | maetl/nanogenmo2015 | /dragon.rb | UTF-8 | 937 | 2.796875 | 3 | [] | no_license | require 'calyx'
class Dragon < Calyx::Grammar
start :spotted_by_dragon
rule :spotted_by_dragon, :dragon_insult, :dragon_sarcasm
rule :dragon_article, 'the dragon'
rule :annoyed_verb, 'grumbles', 'sighs', 'snorts'
rule :insulting_identity, ['murderous hobo', 0.5], ['petty criminal', 0.25], ['ignorant tourist'... | true |
c952ae99f72115381bd7c5cee1e76afb1e9d57ca | Ruby | wathika/Ruby_Beginning | /13-arrays_hashes.rb | UTF-8 | 880 | 4.59375 | 5 | [] | no_license | # Use the each method of Array to iterate over [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
# and print out each value.
nums = [1,2,3,4,5,6,7,8,9,10]
nums.each { |x| puts x if x > 5}
new_arry = nums.select{ |y| y % 2 != 0}
# Append "11" to the end of the original array. Prepend "0" to the beginning.
nums.push(11).unshift(0... | true |
811d40e58caf22d0a5f7febd009c0bd553d9bef7 | Ruby | millisami/oh-my-zsh | /custom/shell-scripts/dumpdb | UTF-8 | 1,977 | 2.6875 | 3 | [
"MIT"
] | permissive | #!/usr/bin/env ruby
# http://gem-session.com/2010/07/dumping-database-from-within-rails-project
fail_gently = ARGV.include?("--fail-gently")
if ARGV.include?("-i")
puts "*******************************************************"
puts
system("du -sh ~/dumps")
puts
puts "***************************************... | true |
52759d239ad7bdf3b52781b3a85e8fd5f468a0b7 | Ruby | mccabe/Budge | /app/models/program_draft.rb | UTF-8 | 1,608 | 2.84375 | 3 | [] | no_license | # == Schema Information
#
# Table name: program_drafts
#
# id :integer(4) not null, primary key
# plaintext :text
# data :text
# version :integer(4)
# user_id :integer(4)
# created_at :datetime
# updated_at :datetime
#
class ProgramDraft < ActiveRecord::Base
serialize :data
belongs... | true |
742f6cccbbbd590c8f839d8a1b2dcdc59845c4e2 | Ruby | royw/watir-test | /spec/network_resource_spec.rb | UTF-8 | 1,746 | 2.6875 | 3 | [] | no_license | require_relative 'spec_helper'
# Create an automation script in watir-webdriver or Capybara that:
# 1. Logs you into the community.
# 2. Make the script click on Networking in the community navigation.
# 3. Verify that ‘Cisco' appears in the ‘Groups’ section exists (this group is toward the center/right side of the pa... | true |
45803e6a22cb39d9178a590db6e2e604477bfd4f | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/difference-of-squares/053a7bc53f08417eabb49d26a18a5d2f.rb | UTF-8 | 490 | 3.453125 | 3 | [] | no_license | class Squares
def initialize(n)
@number = n
end
def square_of_sums # using reduce and abs2 methods saves a net of 2 lines of code
#sum = 0
#(1..@number).each {|i| sum += i}
#sum = sum * sum
(1..@number).reduce(:+).abs2
end
def sum_of_squares # using map and reduce methods saved a net of 2 lines of c... | true |
3104721527ac45dacc7e09640e12aa9cbe4eaadb | Ruby | jeffreydking04/euler-problems | /problems/euler530new.rb | UTF-8 | 790 | 3.484375 | 3 | [] | no_license | # I believe that a solution can be arrived at by
require 'prime'
def prime_factorization(n)
Prime.prime_division(n).flat_map { |factor, power| [factor] * power }
end
NUMBER = 50
limit = Math::sqrt(NUMBER).floor
array = Array.new(limit){Array.new}
for number in (2..limit)
array[number] = prime_factorization(numb... | true |
84af2d5dd3b7499f408303ed11f2efb716005dd6 | Ruby | OwwllMan/Scraping | /ScrapingDep.rb | UTF-8 | 670 | 3.234375 | 3 | [] | no_license | require 'nokogiri'
require 'open-uri'
page = Nokogiri::XML(open("https://www.nosdeputes.fr/deputes/enmandat/xml"))#Récupère le xml
@namel = []#init les array
@namef = []
@emails = []
def first_last(page)
page.css("nom_de_famille").each do |y|#récupère chaque élément de la balise nom_de_famille
y = y.text#le ... | true |
d3947170b5af61fa586456fa4c137a4214f0f6fd | Ruby | Krogglestones/Ruby-Projects | /rock_paper_scissors_larson.rb | UTF-8 | 2,318 | 3.96875 | 4 | [] | no_license | ############################################################
#
# Name: Craig Larson
# Assignment: Rock, Paper, Scissors
# Date: 1/29/17
# Class: CIS 282
# Description: Create a rock, paper, scissors game.
#
############################################################
puts "This is a Rock... | true |
6bddc9cee6c6521bfa70d41b7b92a41b4c7ae9fc | Ruby | szarmes/first_website | /spec/models/message_spec.rb | UTF-8 | 1,296 | 2.625 | 3 | [] | no_license | require 'spec_helper'
describe Message do
before do
@message = Message.new(name: "Example Name", email: "test@example.com",
subject: "test", body:"this is the body")
end
subject { @message }
it { should respond_to(:name) }
it { should respond_to(:email) }
it { should respond_to(:subjec... | true |
b886bb224c676241c489f286db0735e3cb467d33 | Ruby | alansparrow/learningruby | /csvexample4.rb | UTF-8 | 244 | 2.859375 | 3 | [] | no_license | require 'csv'
people = CSV.read('test1.txt')
laura = people.find { |person| person[0] =~ /Laura/ }
laura[0] = 'Laura Smith'
puts CSV.open('test1.txt', 'w')
CSV.open('test1.txt', 'w') do |csv|
people.each do |person|
csv << person
end
end
| true |
240a4a5c2ad7958a743fa28088e474aadbc6819e | Ruby | taynarodrigues/automacao-do-ZERO-Full-Stack-com-foco-em-Ruby | /qaninja/enjoeat/features/support/web/pages/views/cart.rb | UTF-8 | 441 | 2.53125 | 3 | [
"MIT"
] | permissive |
class CartView
include Capybara::DSL # include Capybara::DSL conhece todos os recursos do Capybara
def box #método do carrinho
find("#shopping-cart")
end
def total
box.find('tr', text: 'Total').find('td') #chamando método interno do carrinho
end
def remove_item(item)
... | true |
8ea0f3e49e75cc6d6917c7c8c0fbcb827aa6dea7 | Ruby | StrangeTim/rubyCodeExamples | /parcel/lib/parcel.rb | UTF-8 | 596 | 3.140625 | 3 | [] | no_license | require 'pry'
class Parcel
define_method(:initialize) do |length, width, height, weight|
@length = length
@width = width
@height = height
@weight = weight
end
define_method(:volume) do
volume = @length * @width * @height
end
define_method(:cost) do |distance|
@distance = distance
... | true |
b741e2fafe8f3047f1ded216930a8c117ec48d9e | Ruby | ddollar/distributor | /lib/distributor/server.rb | UTF-8 | 3,701 | 2.828125 | 3 | [
"MIT"
] | permissive | require "distributor"
require "distributor/connector"
require "distributor/multiplexer"
require "distributor/okjson"
require "pty"
require "socket"
class Distributor::Server
def initialize(input, output=input)
@connector = Distributor::Connector.new
@multiplexer = Distributor::Multiplexer.new(output)
... | true |
2684f744ffeb6abf896c3b3803def0ddc02afb9c | Ruby | dlaststark/machine-learning-projects | /Programming Language Detection/Experiment-2/Dataset/Train/Ruby/greatest-subsequential-sum-1.rb | UTF-8 | 217 | 3.125 | 3 | [] | no_license | def subarray_sum(arr)
max, slice = 0, []
arr.each_index do |i|
(i...arr.length).each do |j|
sum = arr[i..j].inject(0, :+)
max, slice = sum, arr[i..j] if sum > max
end
end
[max, slice]
end
| true |
326288c97993a4ed245cdb330a4472fead97f46a | Ruby | danliu277/Leetcode | /3. Longest Substring Without Repeating Characters/solution.rb | UTF-8 | 390 | 3.453125 | 3 | [] | no_license | # @param {String} s
# @return {Integer}
def length_of_longest_substring(s)
result = i = j = 0
len = s.length
set = Set[]
while i < len && j < len do
if !set.include?(s[j])
set.add(s[j])
j+=1
result = [result, j - i].max
else
set.delete... | true |
0af014ae3d75765101b25be5b6ec61bab85d69cd | Ruby | joshmgross/view_components | /test/previews/primer/counter_component_preview.rb | UTF-8 | 726 | 2.515625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
module Primer
# @label CounterComponent
class CounterComponentPreview < ViewComponent::Preview
# @label Default Options
#
# @param count number
# @param limit number
# @param hide_if_zero toggle
# @param round toggle
# @param scheme [Symbol] select [[Defaul... | true |
0843cc76ececab2627e909f3002f78184d2ac6f9 | Ruby | GildedHonour/JobRunner | /app/models/address.rb | UTF-8 | 1,629 | 2.6875 | 3 | [] | no_license | class Address < ActiveRecord::Base
extend Enumerize
include Audited
has_paper_trail
belongs_to :addressable, polymorphic: true, touch: true
enumerize :country, in: [:usa, :canada], default: :usa
validates :address_line_1, presence: true
validates :city, presence: true
validates :state, presence: true
... | true |
0dcec73afb562757f7fdbf8760bd356838492f7f | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/gigasecond/7e6c205c48f442a099e1144179555bc1.rb | UTF-8 | 317 | 3.046875 | 3 | [] | no_license | require 'date'
class Gigasecond
def self.from(date)
new(date).gs
end
def initialize(date)
@date = date
end
def gs
Time.at(unix_timestamp + gigasecond).to_date
end
private
attr_reader :date
def unix_timestamp
date.to_time.to_i
end
def gigasecond
1_000_000_000
end
end
| true |
db79e67cc72415bdf20a5434c0636be2a2efdc1a | Ruby | daewon/til | /quiz/hacker_rank/eval_ex.rb | UTF-8 | 1,643 | 4.03125 | 4 | [] | no_license | # https://www.hackerrank.com/challenges/eval-ex
# The series expansion of is given by:
#
#
#
# Evaluate for given values of by using the above expansion for the first terms.
#
# Input Format
#
# The first line contains an integer , the number of test cases.
# lines follow. Each line contains a value of for... | true |
7a9b39dffab679a66909a6f0d0b861a13abb5062 | Ruby | raghavendra-prithvi/json_data_parsing_ruby | /json_dta_parse_ruby_file.rb | UTF-8 | 1,419 | 2.796875 | 3 | [] | no_license |
############Code Sample #########
require 'rubygems'
require 'json'
require 'net/http'
file = File.open("input_talksinterview.txt", "rb")
File.open("output.txt", "w")
if FileTest::directory?("video")
else
Dir::mkdir("video")
end
contents = file.read
json_data = JSON.parse(contents)
json_data.each do |jd|
output =... | true |
cad215ba21ab0dbb565415709f2dea94aad34132 | Ruby | mental32/ttt-10-current-player-london-fastrack-051119 | /lib/current_player.rb | UTF-8 | 134 | 3.328125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def turn_count(board)
board.length - board.count(" ")
end
def current_player(board)
(turn_count(board) % 2 == 0) ? "X" : "O"
end
| true |
a3c70bb42151458cc75f33018cc16d88fa4bb846 | Ruby | saibabanadh/vss | /lib/vss/tokenizer.rb | UTF-8 | 580 | 3.421875 | 3 | [
"MIT"
] | permissive | require 'stemmer'
module VSS
class Tokenizer
STOP_WORDS = %w[
a b c d e f g h i j k l m n o p q r s t u v w x y z
an and are as at be by for from has he in is it its
of on that the to was were will with upon without among
].inject({}) { |h,v| h[v] = true; h }
def self.tokenize(string... | true |
fe372c5086696c478cae293524596b957af904e9 | Ruby | itiswicked/micro-reddit | /test/models/comment_test.rb | UTF-8 | 488 | 2.515625 | 3 | [] | no_license | require 'test_helper'
class CommentTest < ActiveSupport::TestCase
def setup
@comment = Comment.new(user_id: 1, post_id: 1, body: "Haha I crack me up")
end
test 'comment is valid' do
assert @comment.valid?
end
test 'validates if body is present' do
@comment.body = " "
assert_not @comment.... | true |
135194936b49e62d3ec4f33cf1d8f2f18dba0ea8 | Ruby | Zlatov/lab | /ruby/_tasks/redis/redis.rb | UTF-8 | 4,610 | 2.65625 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'active_support/all'
require 'awesome_print'
require 'redis'
# Расспаралеливание в потоки (для Redis соединения). Не путать с кластеризацией Redis!
require 'connection_pool'
# Распаралеллим в потоки с помощью гема connection_pool
# P.S.:
# Не путать кластеризацию (https://github.com/redis... | true |
b0f23ea45939824520995df9f8efcc6e9aac935c | Ruby | matthewtodd/doily | /lib/doily/types/conditional.rb | UTF-8 | 386 | 3.015625 | 3 | [] | no_license | module Doily
class Conditional
def initialize(conditional, true_block, false_block = Block.new)
@conditional = conditional
@true_block = true_block
@false_block = false_block
end
def to_ruby(binding)
if @conditional.to_ruby(binding)
@true_block.to_ruby(binding)
else... | true |
3535507e3d8000a0add3262468223635979487a2 | Ruby | JWNg/Odin_Ruby | /5_testing/time_travel/CC/lib/CC.rb | UTF-8 | 345 | 3.453125 | 3 | [] | no_license |
def caesar_cipher(string, shift=0)
new_word = ""
shift = shift.to_i
string.each_char do|c|
shift.times do
if c == " "
next
elsif c == "z"
c = "a"
next
elsif c == "Z"
c = "A"
next
else
c.next!
end
end
new_word <<... | true |
20bd3ce160d7437d89a22b3a6f15e695073cc358 | Ruby | dcmorais/uri_problems | /beginner/1017.rb | UTF-8 | 103 | 2.671875 | 3 | [] | no_license | hour = gets.to_f #hours
km_l = gets.to_f #km/h
spent = 12#km/l
puts sprintf("%.3f", km_l/spent*hour)
| true |
b069298cf51bfaa44cedb558b406fa5a79313cc6 | Ruby | JonJarGaa/Ruby-Basics-Exercises | /01_variable_scope/whats_my_value_part_1.rb | UTF-8 | 991 | 4.25 | 4 | [] | no_license | =begin
What will the following code print and why?
Don't run it until you have tried to answer.
=end
a = 7
def my_value(b)
b += 10
end
my_value(a)
puts a
=begin
MY ANSWER:
This should print a as 7. If puts was in line with my_value(a), then it would
print 17. The method only has local scope, so it cannot p... | true |
47e95799e20d7ef9bb43cfeb68eac9351426b74d | Ruby | kanuff/W2D5 | /Hash Map LRU Cache/lib/p03_hash_set.rb | UTF-8 | 2,350 | 3.78125 | 4 | [] | no_license | class HashSet
attr_reader :count
def initialize(num_buckets = 8)
@store = Array.new(num_buckets) { Array.new }
@count = 0
end
def insert(key, resize = false)
hashed = key.hash
if num_buckets == count
resize!
end
if !include?(hashed)
bucket = hashed % num_buckets
@sto... | true |
139c2a331c0f238b77cea51801dc54e0fa1a54f2 | Ruby | wenlilearn/leetcode | /pascal_triangle_2/test.rb | UTF-8 | 317 | 2.59375 | 3 | [] | no_license | require_relative "main"
require "test/unit"
include Main
class MainTest < Test::Unit::TestCase
def test_simple()
assert_equal([1], get_row(0))
assert_equal([1,1], get_row(1))
assert_equal([1,2,1], get_row(2))
assert_equal([1,3,3,1], get_row(3))
assert_equal([1,4,6,4,1], get_row(4))
end
end
| true |
c886e8273ce3229f87a80689b79f2edc5ef92212 | Ruby | efremov/twisent | /app/models/sentiment.rb | UTF-8 | 490 | 2.53125 | 3 | [] | no_license | class Sentiment
include Mongoid::Document
field :category, type: String
has_many :words
has_many :documents
validates_inclusion_of :category, :in => ["positive", "negative", "neutral"]
def self.positive
find_by(category: "positive")
end
def self.negative
find_by(category: "negative")... | true |
42b95a1561deb70414a6122a9f05d8384e6b9c92 | Ruby | sharonjean/phase-0 | /week-6/my_solution.rb | UTF-8 | 1,400 | 3.859375 | 4 | [
"MIT"
] | permissive | # Class Warfare, Validate a Credit Card Number
# I worked on this challenge [by myself, with: ].
# I spent [#] hours on this challenge.
# Pseudocode
# Input: Array with credit card integer
# Output: Array with valid card integer
# Steps:
#Create empty container object that accepts integer
#Create method that double... | true |
710cc6c09fc1a4ad38d550d2e398d6e77c817ddf | Ruby | Bentopi/Week_3_Assignments | /Week_3_Lab/test.rb | UTF-8 | 2,066 | 3.1875 | 3 | [] | no_license | require './department'
require './employee'
require 'minitest/autorun'
class CompanyTesting < MiniTest::Test
def robert
{name: "Robert Dinitro", email: "robzo@gmail.com", phone: "9768938", salary: "100000"}
end
def peter
{name: "Peter Kaplan", email: "imakemorethanrobert@gmail.com", phone: "9768238", sa... | true |
a9c9247726247b907d3b1d2dea2f55606e45e6f3 | Ruby | ga-wdi-boston/wdi_2_ruby_demo_modules | /bin/create_animals.rb | UTF-8 | 277 | 3.4375 | 3 | [] | no_license | require_relative "../lib/animal"
joe = Person.new('Joe Smoe')
puts joe.move
spot = Dog.new('Spot')
puts spot.move
poly = Parrot.new('Polly')
puts poly.move
belfy = Bat.new('Belfry')
puts belfy.move
# Make Joe and poly say something
# Show that poly and belfy can fly, fly
| true |
b4bea1e26ec40a06a4376bc58ae4fe474142c690 | Ruby | gma/nesta | /lib/nesta/static/html_file.rb | UTF-8 | 736 | 2.515625 | 3 | [
"MIT"
] | permissive | module Nesta
module Static
class HtmlFile
def initialize(build_dir, page)
@build_dir = build_dir
@content_path = page.filename
end
def page_shares_path_with_directory?(dir, base_without_ext)
Dir.exist?(File.join(dir, base_without_ext))
end
def filename
... | true |
10689bc9a91276c1d146c050c3e23c88d0797879 | Ruby | 404TeamNameNotFound/ParkingPal | /test/models/lat_lon_test.rb | UTF-8 | 2,857 | 2.53125 | 3 | [] | no_license | require 'test_helper'
class LatLonTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
test "test association" do
p = ParkingMeter.create(:name => 55555, :price => 2, :max_time => 2, :start_time => 0, :end_time => 1000, :is_occupied => false, :is_broken => true)
l = LatLon.create(:... | true |
34cf534be44fc160db96ba88952d934c66b3f86b | Ruby | Mrkishansharma/lms | /lms.rb | UTF-8 | 2,381 | 3.6875 | 4 | [] | no_license | require_relative "./login"
require_relative "./admin"
require_relative "./student"
class Library
def initialize
@books = []
student_books = []
@outerChoice = 0
@innerChoice = 0
@who_am_i = ""
end
def login
while (@outerChoice != 9)
puts "\n\nLIBRARY MANAGEMENT SYSTEM\n\n"
put... | true |
d34410a85807b819ca78a2e2c73de3f3f53f0056 | Ruby | plicjo/codility_study_guide | /spec/cyclic_rotation_spec.rb | UTF-8 | 629 | 3 | 3 | [] | no_license | require 'spec_helper'
require_relative '../cyclic_rotation'
RSpec.describe 'Cyclic Rotation' do
it '3 rotations' do
expect(cyclic_rotation([3, 8, 9, 7, 6], 3)).to eq([9, 7, 6, 3, 8])
end
it 'all zeroes' do
expect(cyclic_rotation([0, 0, 0], 1)).to eq([0, 0, 0])
end
it '4 rotations' do
expect(cyc... | true |
aa1c642df24594fcb52be974f831f98885bc0527 | Ruby | mingoscd/auction-exercise | /auction_site/app/models/item.rb | UTF-8 | 364 | 2.53125 | 3 | [] | no_license | class Item < ActiveRecord::Base
has_many :bids
has_many :users, through: :bids
validates :name, presence: true, length: { maximum: 30 }
validate :proper_date
def assign_winner
self.update_attribute :winner_id, self.bids.last.user_id
end
private
def proper_date
if expire_date < Date.today
errors.add(... | true |
3df5d87200cf5c0f3384b00b3c18298eca31c679 | Ruby | iannguyen/practice | /data_structures/trees_and_graphs/sqroot.rb | UTF-8 | 538 | 4.15625 | 4 | [] | no_license | # Write a function that finds the square root of a number, with basic arithmetic functions, in less than O(n) time. (The number will always be a perfect square)
def square_root(num, nums = nil)
nums ||= (1..num / 2).to_a
mid_point = nums.count / 2
mid = nums[mid_point]
case mid * mid <=> num
when -1
squ... | true |
7c10afc1be1eeab6627d2b15b233cdb3d653da39 | Ruby | johndillon773/intro_to_programming | /other_stuff/3.rb | UTF-8 | 250 | 2.53125 | 3 | [] | no_license | Exception handling is a way of dealing with errors in a program in such a
way that the program does not stop at the error and the error is identified
in the output. It allows programs to continue working even if they encounter
an error along the way. | true |
58b0804eab8e2765e96337f4858bcfe464ecc969 | Ruby | aabbcc456aa/my_test | /vendor/plugins/ajax_scaffold_generator-3.1.11/templates/unit_test.rb | UTF-8 | 2,566 | 2.59375 | 3 | [
"MIT"
] | permissive | require File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../test_helper'
class <%= class_name %>Test < Test::Unit::TestCase
fixtures :<%= plural_name %>
NEW_<%= singular_name.upcase %> = {} # e.g. {:name => 'Test <%= class_name %>', :description => 'Dummy'}
REQ_ATTR_NAMES = %w( ) # name of fields ... | true |
a168eb29491602b45a5b724648e095b2d378e08e | Ruby | MariaWissler/grocery-store | /lib/customer.rb | UTF-8 | 1,100 | 3.359375 | 3 | [] | no_license | #customer
# Create a class called Customer. Each new Customer should include the following attributes:
require_relative "order.rb"
require 'csv'
class Customer
attr_reader :id
attr_accessor :email, :address
def initialize(id, email, address)
@id = id
@email = email
@address = address
... | true |
9fe38cd69b2783366159a865b5dfc4f646dc63e2 | Ruby | veryscarycary/farm-text-adventure | /kernal.rb | UTF-8 | 207 | 2.921875 | 3 | [] | no_license | require 'rubygems'
require 'colorize'
module Kernal
def putsy(string)
puts "\n#{string.yellow}"
end
def putspi(string)
puts "\n#{string.magenta}"
end
end
class Object
include Kernal
end
| true |
655cfc2a36e6834057e9f9a1da9655d7fc8d8183 | Ruby | RISCfuture/VoiceRecognitionProfileGenerator | /generate.rb | UTF-8 | 1,013 | 2.546875 | 3 | [
"Unlicense"
] | permissive | require 'optparse'
require 'pathname'
require 'bundler'
Bundler.require
$LOAD_PATH << __dir__
require 'lib/command_set'
FORMATS = %w[vac voiceattack].freeze
options = {format: 'vac'}
parser = OptionParser.new do |opts|
opts.banner = "Usage: generate.rb [options] /path/to/profile.vacc"
opts.on('-h', '--help', "P... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.