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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
055a7f9c080efdc7c3e20b860eed1f61a3a8437e | Ruby | adamakhtar/hightower | /app/models/hightower/track.rb | UTF-8 | 484 | 2.6875 | 3 | [
"MIT"
] | permissive | module Hightower
class Track
def initialize(behaviour)
@behaviour = behaviour
end
def self.perform(behaviour)
new(behaviour).perform
end
def perform
segment = find_or_create_segment(behaviour)
users = behaviour.observe
segment.add_users(users)
users
end
... | true |
240b03e5a901d9858b221c881aeecff42cd52db2 | Ruby | BLSQ/orbf2 | /lib/tasks/data_test.rake | UTF-8 | 4,558 | 2.625 | 3 | [
"MIT"
] | permissive | # frozen_string_literal: true
require "shellwords"
require_relative "../data_test"
def ask_for_confirmation(message)
puts message
puts "Are you sure? y/N"
input = STDIN.gets.chomp
input == "y"
end
def find_test_cases
test_cases = DataTest.all_cases
if test_cases.empty?
abort <<~MSG
Error: No te... | true |
ed38dce29a66fe97745ef2057d2f4a23fcec36d3 | Ruby | matbat99/MindNote | /db/seeds.rb | UTF-8 | 2,087 | 2.8125 | 3 | [] | no_license |
puts "Clearing Database..."
Session.destroy_all
Practice.destroy_all
Song.destroy_all
Artist.destroy_all
User.destroy_all
puts "Creating user..."
u = User.new(email: "user@email.com", name: "user", password: "password", photo: "image/upload/v1559149365/dxf4dzbrhukthuxjkhnx.jpg")
u.save!
puts "Creating artist..."
a =... | true |
233868e07ecd2a71df1acec1837bb4d6323f7cbd | Ruby | kaist-plrg/jstar | /tests/compile/basic/es2018/AssignmentExpression[5,0].Evaluation.spec | UTF-8 | 496 | 2.6875 | 3 | [
"BSD-3-Clause",
"BSD-2-Clause"
] | permissive | 1. Let _lref_ be the result of evaluating |LeftHandSideExpression|.
1. Let _lval_ be ? GetValue(_lref_).
1. Let _rref_ be the result of evaluating |AssignmentExpression|.
1. Let _rval_ be ? GetValue(_rref_).
1. Let _op_ be the `@` where |AssignmentOperator| is `@=`.
1. Le... | true |
ee40290cf45c0ff5e13c2473eba7a478100a4aed | Ruby | tasosh/blackjack | /blackjack1.rb | UTF-8 | 1,014 | 3.828125 | 4 | [] | no_license | puts "welcome to Blackjack"
def calculate_total(cards)
# [['H', '3'], ['S', '5'], ... ]
arr = cards.map{|e| e[1] }
total = 0
arr.each do |value|
if value == "A"
total += 11
elsif value.to_i = 0
total = total + 10
else
total += value.to_i
end
end
#correct for Aces
arr.select{|e| e == "A"}.c... | true |
46541d6757d1d53f8f8bb464c45ef30cccfc2ba2 | Ruby | jackkinsella/crypto-index | /config/initializers/rack_attack.rb | UTF-8 | 923 | 2.5625 | 3 | [
"MIT"
] | permissive | #
# Format:
#
# throttle('<ROUTE NAME>:<THROTTLE PARAMETER>', <THROTTLE OPTIONS>) do
# ...
# end
#
# The list is sorted alphabetically by <ROUTE NAME>.
#
class Rack::Attack
THROTTLE_1_000_PER_1M = {limit: 1_000, period: 1.minute}.freeze
THROTTLE_5_PER_10M = {limit: 5, period: 10.minutes}.freeze
THROTTLE_1... | true |
2ad9223c3012973c5f3151e5682c60a673419ea1 | Ruby | Acb897/ACB_TFM | /Demo/SPO_pattern_class.rb | UTF-8 | 12,054 | 3.078125 | 3 | [] | no_license | =begin
Another thing I think will be useful is to find the URL patterns for each ?s and ?o
(or at least, the most common ones... so maybe grab 10 examples of ?s and ?o and see
what their URLs look like. e.g. http://purl.uniprot.org/P344556.) The reason this may
become useful is that EBI has agreed to resurrect a rea... | true |
85ba94efef2f6de966cf9d129e7264d81987ea02 | Ruby | ht0919/ProgrammingExercises | /D/ruby/d072.rb | UTF-8 | 86 | 3 | 3 | [] | no_license | a = gets.chomp.split(" ")
b = a.map(&:to_i)
c = (b[0] / b[1].to_f).ceil
puts c * b[2]
| true |
9dc73b2e72438837dcde844fb458f07ab5dcd40d | Ruby | metaxnet/tiff-handler | /TifHandler.rb | UTF-8 | 6,443 | 2.6875 | 3 | [] | no_license | require 'tk'
V0 = "1"
HORIZONTAL = "001"
VL1 = "010"
VR1 = "011"
PASS = "0001"
VL2 = "000010"
VR2 = "000011"
VL3 = "0000010"
VR3 = "0000011"
EOL = "000000000001"
CODE_WHITE = 0
CODE_BLACK = 1
VMODES = [V0, VL1, VR1, VL2, VR2, VL3, VR3]
DELTAS = [0, -1, 1, -2, 2, -3, 3]
MODES = [V0, HORIZONTAL, VL1, VR1, VL2, VR2, VL3... | true |
2ea995ea6bee4ade9f4604526c67d71137c69543 | Ruby | melpp/LearningRuby | /Scope.rb | UTF-8 | 1,193 | 4.125 | 4 | [] | no_license | # Another important aspect of Ruby classes is scope.
# The scope of a variable is the context in which it's visible to the program.
# When dealing with classes, you can have variables that are available everywhere (global variables),
# ones that are only available certain methods (local variables),
# others that ar... | true |
8ea894927bdbf91ee073a0952bd6ec076a4f7a05 | Ruby | yratanov/new_game | /lib/player.rb | UTF-8 | 939 | 2.734375 | 3 | [] | no_license | require 'player_view'
require 'level_object/base'
require 'level_object/creature/base'
require 'level_object/mixin/jumper'
require 'geometry_form/collision'
class Player < LevelObject::Creature::Base
include LevelObject::Mixin::Jumper
states :stand, :run_right, :run_left, :jump, :jump_left, :jump_right
view Pl... | true |
e6cafb0c9cc1ff3d88dc3e3b031c6371603f8835 | Ruby | anton-yordanov/keyword-tool | /lib/keyword_tool/keywords.rb | UTF-8 | 935 | 3.203125 | 3 | [
"MIT"
] | permissive | require "json"
module KeywordTool
class Keywords
UNSAFE_CHARACTERS =
Regexp.escape("()!?@%,*\n\t\"^={};~`<>\\|°§ə€£¥¥⁄¶‰′″‴¿–—").freeze
MAX_COLLECTION_SIZE = 800
class CollectionSizeError < StandardError; end
attr_reader :collection
def initialize(collection)
if collection.size > MA... | true |
de83b9cd50943af2b11a69719f68a516b66ef059 | Ruby | jbinto/puckpicks | /test/unit/user_test.rb | UTF-8 | 1,287 | 2.515625 | 3 | [] | no_license | require 'test_helper'
class UserTest < ActiveSupport::TestCase
test "email and username must be unique" do
user1 = FactoryGirl.create(:user)
user2 = FactoryGirl.build(:user, :username => user1.username)
refute user2.save
already_taken = "has already been taken"
assert user2.errors.messages[:em... | true |
c366775effecb8cbba3d9606d3eed48c1a6079ff | Ruby | alexmchale/dotfiles | /bin/brightness-down | UTF-8 | 165 | 2.640625 | 3 | [] | no_license | #!/usr/bin/env ruby
status = `~/bin/brightness -l`
status =~ /brightness (.*)/
level = $1.to_f
level = [ level - 0.1, 0.0 ].max
system "~/bin/brightness #{level}"
| true |
b8c916709b786e08bd70f1d0b0b9fdea03c77d26 | Ruby | Colle11/LC2-compiler-front-end | /sorgenti/test/swap.rb | UTF-8 | 269 | 3.53125 | 4 | [] | no_license | def swapByValue(int *px, int *py)
int temp = 0;
temp = *px;
*px = *py;
*py = temp;
end
def swapByRef(ref int x, ref int y)
int temp = 0;
temp = x;
x = y;
y = temp;
end
def int main()
int a=5; int b=10;
swapByValue(&a, &b)
swapByRef(a, b)
return 0
end | true |
33480df49c97c38192a0b25b5119d8c2af51b13a | Ruby | francoprud/img_fetcher | /lib/img_fetcher/url.rb | UTF-8 | 732 | 2.5625 | 3 | [
"MIT"
] | permissive | require 'down'
module ImgFetcher
class URL
# On sucess: returns a Tempfile. On failure: returns nil.
def self.download(line)
Down.download(line, max_redirects: 0)
# Decided to rescue all Down exceptions since they are all related to connection and URL.
# By rescuing the exceptions, execution w... | true |
4bdd734829cb1112dedf398a7d840d93d25a1efc | Ruby | jesseh/passivedomain | /spec/lib/specification/interface_spec.rb | UTF-8 | 6,071 | 2.515625 | 3 | [] | no_license | require "spec_helper"
require_dependency Rails.root.join('lib', 'specification').to_s
require_dependency Rails.root.join('lib', 'specification', 'signatures', 'query').to_s
describe Specification::Interface do
describe "specifiying the interface" do
let(:specs) { [ Specification::Signatures::Query.new(:a, [], S... | true |
5c71d8213ded17429f59ea28e41bcdc60386b3d7 | Ruby | pstivers3/rubylearn | /dpir/02/bank_account.rb | UTF-8 | 444 | 3.8125 | 4 | [] | no_license | #!/usr/bin/env ruby
class BankAccount
def initialize( account_owner )
@owner = account_owner
@balance = 0
end
def deposit( amount )
@balance = @balance + amount
end
def withdraw( amount )
@balance = @balance - amount
end
attr_reader :balance, :owner
end
my_account=BankAccount.new('Pau... | true |
7062292f08e0bc28a8312bb80cb2c88ea3786d81 | Ruby | mowenpark/minesweeper | /board.rb | UTF-8 | 2,358 | 3.65625 | 4 | [] | no_license | class Board
NEIGHBORS = [
[1, 1],
[1, 0],
[1, -1],
[0, 1],
[0, -1],
[-1, 1],
[-1, 0],
[-1,-1]
]
attr_reader :grid
def initialize
@grid = Array.new(9) {Array.new(9) {Tile.new}}
end
def [](pos)
row, col = pos
@grid[row][col]
end
def []=(pos, value)
row,... | true |
193980ab31a65e5d6e85c2d34fc35310154283e8 | Ruby | deiga/SaaS | /Homework 1/part1.rb | UTF-8 | 470 | 3.8125 | 4 | [] | no_license | def palindrome?(input)
input.gsub(/\W/,'').downcase == input.gsub(/\W/,'').downcase.reverse
end
puts palindrome?("A man, a plan, a canal -- Panama")
puts palindrome?("Madam, I'm Adam!")
puts palindrome?("Abracadabra")
def count_words(string)
count_hash = {}
string.downcase.scan(/\w+/).each { |x| count_hash[x] ||= ... | true |
b8507fe6f68389d1d53b00056de08189a49586d5 | Ruby | zhon/metrics | /lib/comment.rb | UTF-8 | 448 | 3.015625 | 3 | [] | no_license | #
# C/C++/Java (and C#?) Extreme Code Metrics program
# Copyright (c) XPUtah (Jeff Grover and Zhon Johansen) 2000-2005. All rights reserved.
#
class Comment
attr_reader :comment, :starting_line, :line_count
def initialize(comment, starting_line)
@comment = comment
@starting_line = starting_line
@line_... | true |
ddbf30a82c5a184ce3e7dc9d34831273a1bf381a | Ruby | cotneok/Invoice_N3 | /models/invoice.rb | UTF-8 | 881 | 3.171875 | 3 | [] | no_license | class Invoice
attr_accessor :id, :seller, :buyer, :products, :price, :date
def initialize(id, buyer, seller, products, price, vat, hash_products)
@id = id
@buyer = buyer.to_s
@seller = seller.to_s
@products = products
@price = price
@vat = vat
time = Time.now
@date = "#{time.day}/#{time.month}/#{tim... | true |
c9b066c1e145591faccbafd51c3501eadb484110 | Ruby | Equinox-01/MSAMM | /Lab2/spec/algorithm_specs/distributions_specs/simpson_spec.rb | UTF-8 | 816 | 2.703125 | 3 | [] | no_license | # frozen_string_literal: true
require_relative '../../../algorithm/distributions/simpson.rb'
require 'descriptive_statistics'
RSpec.describe Algorithm::Distribution::Simpson do
let(:a) { 10 }
let(:b) { 20 }
subject do
described_class.new('a' => a, 'b' => b)
end
it 'check simpson distribution sequence ... | true |
15175512c55e62f28964e8de46f63196ac224a7a | Ruby | missmaggiemo/debugging_lecture | /roll_your_own_auth/app/models/user.rb | UTF-8 | 849 | 2.59375 | 3 | [] | no_license | class User < ActiveRecord::Base
validates :username, presence: true
validates :password, presence: true, length: { minimum: 6 }
has_many :comments
def password
self.password_digest
end
def password=(plain_text)
if plain_text.empty?
errors.add(:password, "can't be blank")
elsif ... | true |
53db3b9e864b2d324fef5f47901f4b1a7c18763c | Ruby | rtellez700/hw-sinatra-saas-hangperson | /lib/hangperson_game.rb | UTF-8 | 1,679 | 3.40625 | 3 | [] | no_license | class HangpersonGame
# add the necessary class methods, attributes, etc. here
attr_accessor :word
attr_accessor :guesses
attr_accessor :wrong_guesses
# to make the tests in spec/hangperson_game_spec.rb pass.
# Get a word from remote "random word" service
# def initialize()
# end
def initi... | true |
9e78c66e6ab52447c71eb30967c0ce566579985a | Ruby | pierrefourgeaud/bitmap-editor | /lib/bitmap_editor_error.rb | UTF-8 | 876 | 3.03125 | 3 | [] | no_license | class BitmapEditorError < StandardError; end
class NoStackedCommand < BitmapEditorError
def initialize(msg = 'No command on the stack.')
super
end
end
class MissingBitmap < BitmapEditorError
def initialize(msg = 'No bitmap created, create a bitmap before trying to modify it.')
super
end
end
class Out... | true |
092cea0965502ada5415f1185cca5a44c7cea5c5 | Ruby | ChattyCrow/xmpp2s | /lib/xmpp2s/connection.rb | UTF-8 | 7,340 | 2.734375 | 3 | [
"MIT"
] | permissive | require 'socket'
module Xmpp2s
# Class wraps TCP connection to jabber server
class Connection
# TCP Socket
attr_accessor :socket
# Timeout
attr_accessor :timeout
# Jid instance
attr_accessor :jid
# Authorization success?
attr_accessor :authorized
# Intialize Xmpp2s::Connecti... | true |
09ea3f2ef016cdee10a853aec7617eeb89230ad4 | Ruby | ne-ha/wage_slave | /spec/wage_slave/aba/descriptive_record_spec.rb | UTF-8 | 6,414 | 2.625 | 3 | [
"MIT"
] | permissive | require "spec_helper"
describe WageSlave::ABA::DescriptiveRecord do
before :each do
WageSlave::ABA::DescriptiveRecord.class_variable_set :@@reel_sequence, 0
end
describe "#new" do
it "creates a descriptive record based on the WageSlave configuration" do
record = WageSlave::ABA::Descri... | true |
3e5dbac4e0677aba188b88c892c82a33f70d51a1 | Ruby | jaded-burnout/jbot | /jbot/app/contests/gang_tags.rb | UTF-8 | 1,369 | 2.625 | 3 | [] | no_license | # frozen_string_literal: true
require "sa_client"
require "instant_runoff"
module Contests
class GangTags
THREAD_ID = "3903115"
def self.run_ballot(post_to_thread: false)
new.run_ballot(post_to_thread: post_to_thread)
end
def run_ballot(post_to_thread: false)
votes_by_category = vote_p... | true |
d2eaf947a2ab00b3dbac6f8e033b1f9c185dddaa | Ruby | Samkiroko/Algorithms-and-Data-structures | /.history/linkedlist2_20200617091946.rb | UTF-8 | 4,307 | 4.15625 | 4 | [] | no_license | # frozen_string_literal: true
# Instructions from your teacher:
# Linked List
# Implement the following two methods in your own LinkedList class. You should start with your code from yesterday:
# add_at(index, item) - Add an item to a specific location in the list. The index will be a positive integer that represent... | true |
9832a2d7048045a03081bc000f3bbcc890a2eda7 | Ruby | agoddard/eol | /vendor/gems/optiflag-0.7/examples/example_3.rb | UTF-8 | 1,405 | 3.171875 | 3 | [
"MIT"
] | permissive | require 'optiflag'
# Title: Adding validation rules to the value of an input flag
# Description: See the flags "mode", "run_date", and "connection" for examples of both forcing values to be in a set (value_in_set) or to match a particular regexp (value_matches).
module Example extend OptiFlagSet
flag "dir"
... | true |
0e739be934d1fdd1e23bdc68288f74e4e3a4f222 | Ruby | melrudick/ruby-collaborating-objects-lab-v-000 | /lib/song.rb | UTF-8 | 488 | 3.28125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class Song
attr_accessor :name, :artist
def initialize(name)
@name = name
end
def self.new_by_filename(filename)
file_array = filename.split(" - ")
artist_name = file_array[0]
song_name = file_array[1]
song_genre = file_array[2] # song_genre.gsub(".mp3", "") will take .mp3... | true |
f03191f623905b0dfb8f23805d6459d936b82db0 | Ruby | raijin2540/W2D3 | /poker/spec/game_spec.rb | UTF-8 | 1,181 | 3.078125 | 3 | [] | no_license | require 'game'
describe Game do
subject(:game) { Game.new(Player.new("Jonathan", 100), Player.new("Jin", 100), Player.new("Tommy"), 100) }
let(:better) { double("Betting Player") }
describe "#initialize" do
it "creates a new deck" do
expect(game.deck.cards.count).to eq(52)
end
end
describe "... | true |
6571498ff9be5ddb6fb8f292146b7f98cea77e91 | Ruby | cheddar/cookbooks | /cookbooks/kafka/files/default/check_kafka_import.rb | UTF-8 | 459 | 2.59375 | 3 | [] | no_license | #!/usr/bin/env ruby
require 'nagios'
require 'time'
class LastSuccessfulImport < Nagios::Plugin
def measure
raw = %x{/opt/hadoop/bin/hadoop fs -ls /events/*/*/*/*/_SUCCESS | sort -k 8 | tail -1}
Time.now - Time.parse(raw.split(' ')[5..6].join(' '))
end
def warning(m)
m > 1800 #30min
end
def cr... | true |
3407af8707fecc8be3d146231a38668ce3f7b579 | Ruby | ganmacs/eve | /lib/eve/connection/server.rb | UTF-8 | 451 | 2.609375 | 3 | [
"MIT"
] | permissive | require "eve/connection/base"
module Eve
module Connection
class Server < Base
def initialize(io, agent)
super(io)
@agent = agent
end
def send_response(data)
Eve.logger.debug("send response #{data} ")
send_message(data)
end
private
def read_m... | true |
89bbff48805d1071857f8c5e929268d1b5e0ebd6 | Ruby | loliver17/phase-0-tracks | /ruby/iteration.rb | UTF-8 | 2,178 | 4.28125 | 4 | [] | no_license | #method that takes a block of code
def names
puts "what is your name?"
name_1 = gets.chomp
puts "what is your name?"
name_2 = gets.chomp
puts "The names are: #{name_1} and #{name_2}"
yield(name_1, name_2)
puts "The block was successful if you see the message: Hi #{name_1} and #{name_2}!"
end
names { |name_1, na... | true |
4480fdc665ec243b381f22dadaf228efb5731705 | Ruby | Rich-McGrath/TeamTreeHouseRuby | /loop.rb | UTF-8 | 82 | 3.15625 | 3 | [] | no_license | loop do
print "Do you want to continue (y/n)? "
answer = gets.chomp.case
end
| true |
36f57aeedb78ccce4168e53502ddd9a636e2d103 | Ruby | ArcherCraftStore/ArcherVMPeridot | /RailsInstaller_D/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/tzinfo-1.1.0/lib/tzinfo/timezone_transition_definition.rb | UTF-8 | 4,895 | 2.8125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | #--
# Copyright (c) 2013 Philip Ross
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, di... | true |
3e1c01f43671e67e3f55a1470bbf48398c1ad5f9 | Ruby | mark-mackay/initial_ruby_project_wongaware | /models/tag.rb | UTF-8 | 1,590 | 2.96875 | 3 | [] | no_license | require_relative( '../db/sql_runner' )
class Tag
attr_reader :id
attr_accessor :type
def initialize( options )
@id = options['id'].to_i if options['id']
@type = options['type']
end
def save()
sql = "INSERT INTO tags
(
type
)
VALUES
(
$1
)
RETURNING id"
v... | true |
e31e33f5df7afadf079e857236e45ada511898f6 | Ruby | yumojin/Example-Sketches | /samples/external_library/ruby_gem/game_of_life.rb | UTF-8 | 3,564 | 3.5625 | 4 | [
"MIT"
] | permissive | # game_of_life.rb featuring MDArray in ruby-processing
# A ruby-processing implementation of Game of Life
# By Martin Prout after a processing version by Joan Soler-Adillon
#
# Press SPACE BAR to pause and change the cell's values with the mouse
# On pause, click to activate/deactivate cells
# Press R to randomly reset... | true |
def4b7a378bba48a9ae3f0270518c152030a9241 | Ruby | saundracatalina/learn_Ruby_the_hard_way | /ex12.rb | UTF-8 | 518 | 4.375 | 4 | [] | no_license | print "Give me a number: "
number = gets.chomp.to_i
bigger = number * 100
puts "A bigger number is #{bigger}."
print "Give me another number: "
another = gets.chomp
number = another.to_i
smaller = number / (100.to_f)
puts "A smaller number is #{smaller}."
# example below to play with .to_f Ask for $103.4 and return... | true |
b0a591b34facc11bc3270c4138170f8d7cf077f5 | Ruby | epj009/rc | /bin/dexize.rb | UTF-8 | 1,276 | 3.125 | 3 | [] | no_license | #!/usr/bin/env ruby
class CountAndroidMethods
def count(path)
full_folder_path = File.expand_path(path)
total_count = 0
# Traverse the folder
Dir.entries(full_folder_path).each {|file|
# Attempt to read only jars
if file.end_with?('jar')
# Count methods in dex
count = co... | true |
8a3ee05c53a6a789732960780ea108e8c64de922 | Ruby | hainu323/ruby | /ruby/hash.rb | UTF-8 | 73 | 2.84375 | 3 | [] | no_license | tall = {"太郎" =>185,"二郎"=>170, "花子"=>150}
puts tall ["太郎"] | true |
247b7d26dfae0bd6c088d9f42460166c9e108cea | Ruby | jdrew1303/xa-rules | /lib/xa/rules/context.rb | UTF-8 | 2,017 | 2.5625 | 3 | [
"Apache-2.0"
] | permissive | require 'xa/registry/client'
module XA
module Rules
class LocalLogger
def info(m)
# puts "> #{m}"
end
def error(m)
# puts "!! #{m}"
end
def warn(m)
# puts "? #{m}"
end
def debug(m)
# puts ">> #{m}"
end
end
class Context
... | true |
3890919751f0a5c313f7a527502bab8f36c97219 | Ruby | WilfredTA/ruby_basics | /small_problems/easy8/leadingsubstrings.rb | UTF-8 | 1,081 | 4.25 | 4 | [] | no_license | #Write a method that returns a list of all substrings of a string that
#start at the beginning of the original string.
#The return value should be arranged in order from shortest to longest substring.
# input is string
# Output is array
# Algorithm
# turn string into array of chars
# Iterate over array, get objects a... | true |
79d5d792f262adf96949f1395b5233faf3426e43 | Ruby | blake97/phase-0-tracks | /ruby/game/word_guessing_game.rb | UTF-8 | 3,094 | 4.3125 | 4 | [] | no_license | ############################################## Pseudocode #######################
###### 1) One user can enter a word (or phrase, if you would like your game to
# support that), and another user attempts to guess the word.
#------------
# word_to_guess
#
###### 2) Guesses are limited, and the number of guesses ... | true |
330b01c7af9d0e0649ceb0add38ab2ba3e75faf4 | Ruby | jrupinski/app-academy | /ruby/diy_adts/spec/stack_spec.rb | UTF-8 | 1,077 | 3.578125 | 4 | [] | no_license | require "stack"
describe Stack do
it "creates new Stack instance" do
expect { Stack.new }.to_not raise_error
expect(Stack.new.inspect).to eq([])
end
let(:object1) { 1 }
let(:object2) { 2 }
let(:object3) { 3 }
describe "It follows LIFO principle (last-in-first-out)" do
stack = Stack.new
... | true |
5660d79df5ce1c0abb7f145534504718d4c85a8a | Ruby | meganizzo/meganizzo.github.io | /Week 1/Labs/1.rb | UTF-8 | 110 | 3.28125 | 3 | [] | no_license | def temp_convert
f = 100
c = (f.to_f - 32) / 1.8
puts "The temp in celcius is" + c.to_s
end
temp_convert
| true |
e051f71d1b858ca722ca2c0eee213b243ee1e48c | Ruby | invisioblack/norn.rb | /lib/norn/world/room/room.rb | UTF-8 | 2,348 | 2.59375 | 3 | [
"MIT"
] | permissive | require "norn/util/memory-store"
require "norn/parser/tag"
module Norn
class Room < MemoryStore
Tag = Norn::Parser::Tag
##
## increments the number of Rooms seen
## during this session
##
def inc
put(:count,
fetch(:count, 0) + 1)
end
def count
fetch :count, 0
... | true |
e7e0518654af442b361d4bc66191cd41344ab742 | Ruby | lpenzey/interview_exercises | /cracking_the_code_interview/chapter_1/1.1_is_unique/spec/is_unique_spec.rb | UTF-8 | 1,104 | 2.640625 | 3 | [] | no_license | require 'is_unique'
describe IsUnique do
let (:unique) { IsUnique.new }
describe '.check_unique' do
it 'returns true for string \'a\'' do
result = unique.check_unique('a')
expect(result).to be true
end
it 'returns true for string \'ab\'' do
result = unique.check_unique('ab')
... | true |
ca6b0cbdcc4c3182efebdbb43ad45d206056adc1 | Ruby | lilithlotus/apples-and-holidays-v-000 | /holidays_2.rb | UTF-8 | 882 | 3.65625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def all_supplies_in_holidays(holiday_hash)
# iterate through holiday_hash and print items such that your readout resembles:
# Winter:
# Christmas: Lights, Wreath
# New Years: Party Hats
# Summer:
# Fourth Of July: Fireworks, BBQ
# etc.
holiday_hash.each do |season, season_holiday_hash|
season_... | true |
895d7be39558f6b2df8c6cf25231b0e20d8b45d4 | Ruby | Codinglikethecoder/debugging-with-pry-onl01-seng-pt-050420 | /lib/pry_debugging.rb | UTF-8 | 45 | 2.75 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def plus_two(num)
num + 2
end
plus_two (3)
| true |
cb32160cf02d2a7cbb04b7b99a9f221d791b44d1 | Ruby | Scra3/job | /backend/spec/driver_spec.rb | UTF-8 | 839 | 2.96875 | 3 | [] | no_license | require 'driver'
require 'date'
RSpec.describe Driver do
describe "#count_period" do
it "returns the days of the given period" do
three_days_period = Date.today..Date.today + 2
driver = Driver.new(three_days_period, 20)
expect(driver.count_period).to eq 3
end
end
describe "#from_json"... | true |
e8f260bdced16132098d31183b847ec09ab132fb | Ruby | wlu24/referral | /app/models/referral.rb | UTF-8 | 1,688 | 2.75 | 3 | [] | no_license | class Referral < ApplicationRecord
belongs_to :from_user, class_name: "User"
# belongs_to :to_user, class_name: "User"
validates :from_user_id, presence: true
# validates :to_user_id, presence: true
# validates :from_user_id, uniqueness: { scope: :to_user_id }
has_secure_token :referral_token
def sende... | true |
6bb87d0c38e4893b9db85e6319e203c302c3f74e | Ruby | anuragkanungo/test | /lib/gui/text_area.rb | UTF-8 | 342 | 3.0625 | 3 | [] | no_license | #models text_area
class Gui::TextArea
def initialize(x,y,width,height,color,text)
@x = x
@y = y
@width = width
@height = height
@color = color
@text = text
@body = Gui::Rectangle.new(x,y,width,height,color)
end
def draw(graphics)
@body.draw(graphics)
graphics.drawString(@text... | true |
f8e3a36566238a988f0f12f63f776d28e6a2b537 | Ruby | goodviber/arf-tech-test | /lib/page_counter.rb | UTF-8 | 631 | 3.234375 | 3 | [] | no_license | # frozen_string_literal: true
class PageCounter
def initialize(pages_hash)
@pages_hash = pages_hash
end
def sorted_array(hash_data)
hash_data.sort_by { |_k, v| v.length }.reverse
end
def most_page_views
# takes default pages_hash
page_view_calculator('visits')
end
def most_unique_page_... | true |
2c117019e8af511cfa5131cb96ed37173af7fb0a | Ruby | grantmalcolm/poster | /app/models/post.rb | UTF-8 | 788 | 2.515625 | 3 | [] | no_license | class Post < ApplicationRecord
belongs_to :user
has_and_belongs_to_many :tags
default_scope -> { order(created_at: :desc) }
validates :user_id, presence: true
validates :title, presence: true, length: { maximum: 30 }
validates :taglist, length: { maximum: 30 }
validate :one_post_per_day
before_create :... | true |
8b1e9186b3ae27d90b51b2e7ed57029dfb8c050c | Ruby | SettRaziel/ruby_visualization | /lib/output/data_output/scaled_dataset_output.rb | UTF-8 | 1,685 | 3.078125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | module DataOutput
# Child class of {DatasetOutput} to visualize a data set within the dimensions
# of the calling terminal.
class ScaledDatasetOutput < ScaledOutput
# method to print a given dataset scaled by the terminal size
# @param [DataSeries] data_series the data series from which the dataset
... | true |
ab86c36aa8ec82f04dceeccccff3832eb666b243 | Ruby | maccman/socialmod | /ruby/lib/socialmod/callback.rb | UTF-8 | 1,241 | 2.5625 | 3 | [
"MIT"
] | permissive | module Socialmod
class Callback
attr_reader :params,
:id,
:timestamp,
:custom_id,
:state,
:signature,
:time,
:data,
:src
def initialize(params)
@params = pa... | true |
753cbdd90bca3d8a61eac5bd0bb8fd23c146eb71 | Ruby | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/ruby/gigasecond/1f41c31aca5c4cfd8cb76074b129741e.rb | UTF-8 | 216 | 2.953125 | 3 | [] | no_license | class Gigasecond
attr_reader :input
def initialize(input)
@date = input
end
def date
giga_date = @date.to_datetime + (10**9)/86400
return Date.new(giga_date.year, giga_date.month,giga_date.day)
end
end
| true |
a2cf6436020f0a4a4cfed49515da4e624f62f26e | Ruby | tmikeschu/black_thursday | /test/invoice_repository_test.rb | UTF-8 | 4,506 | 2.890625 | 3 | [] | no_license | require_relative 'test_helper'
require_relative '../lib/invoice_repository'
class InvoiceRepositoryTest < Minitest::Test
attr_reader :invoice_repo
def setup
parent = Minitest::Mock.new
@invoice_repo = InvoiceRepository.new('./data/test_invoices.csv', parent)
end
def test_it_exists
assert I... | true |
24cbd0eaf099e11f2af16f76cef14d2fe80534ce | Ruby | indyaah/humidifier | /test/extension_test.rb | UTF-8 | 902 | 2.609375 | 3 | [
"MIT"
] | permissive | require 'test_helper'
class ExtensionTest < Minitest::Test
def test_basic
assert_equal 'foo', Humidifier::Utils.underscore('Foo')
assert_equal 'foo_bar', Humidifier::Utils.underscore('FooBar')
assert_equal 'foo_bar_baz', Humidifier::Utils.underscore('FooBarBaz')
assert_e... | true |
dec1b5a0c53e7fae64bb88ddc2a75d9573512587 | Ruby | patrobinson/linux-hub | /lib/linux-hub/github_team.rb | UTF-8 | 623 | 2.703125 | 3 | [
"MIT"
] | permissive | module LinuxHub
class GithubTeam
def initialize(organisation:, team:)
@org = organisation
@team = team
end
def users
@users ||= fetch_users
end
def team_id
@team_id ||= fetch_team_id
end
private
def fetch_users
client.team_members(team_id).collect do |... | true |
d9f6031920d2ecfcc4b54bec66acc802b428f64b | Ruby | PouDDuoP/Codigo-Faciilito | /Ruby/hasheso.rb | UTF-8 | 1,244 | 3.828125 | 4 | [] | no_license | user = {nombre: "kevin", apodo: "PouD", edad: 22, tutor: "kevin"}
user_info = {tipo: 1, gm: "si"}
# puts user.length #.length este metodo para ver el tamaño del hash
# puts user.has_key?(:nombre) #.has_key? este metodo para ver si existen dentro del arreglo la clave
# puts user.has_value?("kevin") #.has_value este me... | true |
e6bd8bc11a793fe853f42ed07125b994b7a68137 | Ruby | enebo/Purugin | /src/main/resources/bukkit/entity/living_entity.rb | UTF-8 | 753 | 3.03125 | 3 | [] | no_license | require 'java'
module org::bukkit::entity::LivingEntity
# Get the block that the player has targeted. Note: this is a Ruby convenience method
# for Bukkit's LivingEntity getTargetBlock(HashSet<Byte>, int).
#
# === Parameters
# * _blocks_to_ignore_ hash of blocks you wish to ignore (optional, defaults to ... | true |
769f2e3dd1b63eed3dd6f0a5d557f2ad3d962bdf | Ruby | CarlLooksUp/cg-ruby-clean | /lib/tasks/import.rake | UTF-8 | 9,644 | 2.625 | 3 | [] | no_license | require 'csv'
namespace :import do
desc "Import a CSV file full of business names"
task :names, [:filename] => :environment do |t, args|
f = File.open(args.filename)
csv = CSV.new f, col_sep: "\t", headers: :first_row, converters: :all, force_quotes: true
csv.to_a.map do |row|
name_obj = NameObje... | true |
7b7410b4127ce7781f1f60e84914c9391a6716f8 | Ruby | rlavang/launch-school | /101-programming-foundations/small_problems/easy_3_6.rb | UTF-8 | 270 | 3.3125 | 3 | [] | no_license | def xor? (arg1, arg2)
return true if arg1 == true && arg2 != true
return true if arg2 == true && arg1 != true
false
end
puts xor?(5.even?, 4.even?) == true
puts xor?(5.odd?, 4.odd?) == true
puts xor?(5.odd?, 4.even?) == false
puts xor?(5.even?, 4.odd?) == false
| true |
f48cafc17bb2617e12516e4a338fa6d9af24e6a7 | Ruby | samuelreh/tomatoharvest | /lib/tomatoharvest/list.rb | UTF-8 | 1,049 | 2.921875 | 3 | [
"MIT"
] | permissive | require 'yaml'
require 'forwardable'
module TomatoHarvest
class List
extend ::Forwardable
attr_reader :items
def_delegators :items, :count, :map
def self.init_and_load(*args)
new(*args).load!
end
def initialize(path, items = nil)
@path = path
@items = items || []
en... | true |
8d21ccd13beccc76346257410824ce18ee393d40 | Ruby | Johnnie71/ruby-enumerables-reverse-each-word-lab-nyc01-seng-ft-082420 | /reverse_each_word.rb | UTF-8 | 134 | 3.453125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def reverse_each_word(string)
arr = string.split (" ")
new_arr = arr.collect{|string| string.reverse}
new_arr.join(" ")
end | true |
8eb35a97061ce73e0a22711654c465d26d503c5e | Ruby | jyliu17/nyc-web-091420 | /05-many-to-many/run.rb | UTF-8 | 2,645 | 3.90625 | 4 | [] | no_license | require 'pry'
require_relative './app/models/user'
## pets application
## 1. Have a list of all the animals and be able to view a list of all their names
## 2. Be able to view a list of all *dogs*
## 3. Let's be able to search for an animal by name
def run
puts "Welcome, would you like to sign up or log in?"
... | true |
c1e4cf5b16ed431da62db390a10802436c689e4b | Ruby | elderhan/s0203_exercises | /michael_hanscom/d3/reverse.rb | UTF-8 | 180 | 3.515625 | 4 | [] | no_license | def reverse array
new_array = Array.new
array.each do |value|
new_array.unshift(value)
end
new_array
end
fruits = ["apples", "bananas", "kiwis", "pears"]
puts reverse fruits | true |
cc1be926b87a8a9cfbdd66db736995b97c797e39 | Ruby | jimmyle414/regex-lab-online-web-sp-000 | /lib/regex_lab.rb | UTF-8 | 1,300 | 3.71875 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | def starts_with_a_vowel?(word)
if word.match(/^[AEIOU]|^[aeiou]/)
true
else
false
end
end
#word_1 = "afoot"
#word_2 = "chandoo"
#starts_with_a_vowel?(word_2)
def words_starting_with_un_and_ending_with_ing(text)
text.scan(/un\w+ing/)
end
#returns an array with the words starting with 'un' and ending wi... | true |
5668716aa8fcd416b7f4348952670ac14c81096c | Ruby | benburkert/excon | /lib/excon/response.rb | UTF-8 | 1,600 | 2.765625 | 3 | [
"MIT"
] | permissive | module Excon
class Response
def self.parse(socket, params = {}, &block)
if params[:block]
print " \e[33m[WARN] params[:block] is deprecated, please pass the block to the request\e[0m"
block = params[:block]
end
response = if block
new(params[:method], block)
... | true |
cc61d34aca6bcc945413fd148b02ec54eb0d5d04 | Ruby | bigxiang/leetcode | /70.climbing-stairs/fib.rb | UTF-8 | 246 | 3.140625 | 3 | [
"MIT"
] | permissive | #
# @lc app=leetcode id=70 lang=ruby
#
# [70] Climbing Stairs
#
# @lc code=start
# @param {Integer} n
# @return {Integer}
def climb_stairs(n)
n_1 = 0
n_2 = 1
(1..n).each do |i|
n_1, n_2 = n_2, n_1 + n_2
end
n_2
end
# @lc code=end
| true |
99a67e6a64ec2bf201898f31be5f6dbfe4a1a092 | Ruby | Simone-Dominico/APS-01 | /Moving.rb | UTF-8 | 2,349 | 3.46875 | 3 | [] | no_license | require_relative 'Populate'
class Moving
attr_reader :game, :goals
def initialize(game)
@game = game
popular
end
def popular
p = Populate.new(@game)
p.populate_goals
@goals = p.goals
end
def actual
@game.join('')
end
def go_left
moving_to({:row => 0, :col => -1})
end
... | true |
d0347cbeb0ceef78033948fca0ad6f21b876239d | Ruby | balanced/balanced-ruby | /lib/balanced/resources/card.rb | UTF-8 | 1,283 | 2.625 | 3 | [
"MIT"
] | permissive | module Balanced
# A card represents a source of funds for an Account. You may Hold or Debit
# funds from the account associated with the Card.
#
class Card < Balanced::DebitableFundingInstrument
include Balanced::Resource
include Balanced::HypermediaRegistry
define_hypermedia_types [:cards]
# ... | true |
13217baf6cdbc5dfc9f7ecc640bdf83999919220 | Ruby | adriell/EstudandoRubyOnRails | /verificasistema.rb | UTF-8 | 553 | 2.765625 | 3 | [] | no_license | require 'net/http'
require 'colorize'
for k,v in {"Uniplam"=>"http://homologacao.infoway-pi.com.br/uniplam/getRoles.do", "IPMT" => "http://homologacao.infoway-pi.com.br/ipmt66/getRoles.do"}
uri = URI(v)
res = Net::HTTP.get_response(uri)
case res.code
when '200'
puts 'Sistema ' + k + ' ONLINE'.colorize(:g... | true |
754600557383b9ea30416917d02f4410d8b9c8d4 | Ruby | botp/runner | /bin/mktest_runner.rb | UTF-8 | 876 | 2.65625 | 3 | [] | no_license | #-------------------------------------
#!env ruby
# purpose:
# create a test template
# caller(s):
# tddwatcher.rb
# using:
# tddwatcher <pathname_of_testfile>
# expects:
# pathame of testfile
#--------------------------------------
require 'fileutils'
def mktest_runner pathname
dict_ext_w_runner = {
... | true |
ed4f905dad879d832dd44e57a1ac0b9fdb3d9a00 | Ruby | op48/wegotsingles | /spec/helpers/message_helper_spec.rb | UTF-8 | 1,514 | 2.578125 | 3 | [] | no_license | require 'spec_helper'
# Specs in this file have access to a helper object that includes
# the MessageHelper. For example:
#
# describe MessageHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# expect(helper.concat_strings("this","that")).to eq("this that")
# end
# end... | true |
fe2b174a151a109fe00a6ac613d5e751c45a077b | Ruby | matthijsgroen/person-name | /lib/person_name/has_person_name.rb | UTF-8 | 6,495 | 2.78125 | 3 | [
"MIT"
] | permissive | require "active_support/core_ext/class/attribute"
module PersonName
module ActiveRecord
def self.included(base) # :nodoc:
base.extend ClassMethods
base.class_attribute :name_types
end
module ClassMethods
def has_person_names?
false
end
def has_person_name(*name_... | true |
6275171d63ed9e8f1e315c7264d6e598cdeb01cb | Ruby | Dpalazzari/bike-share | /app/models/condition_dashboard/precipitation.rb | UTF-8 | 538 | 2.8125 | 3 | [] | no_license | module Precipitation
def range(floor)
[floor..floor + 0.5]
end
def precipitation_trips(floor)
conditions = where(precipitation: range(floor))
conditions.joins(:trips).group(:date).count("id")
end
def average_number_of_rides_from_precipitation(floor)
average(precipitation_trips(floor).values)
... | true |
c10cc9c0e2c042ea881ee2835d7036a5cbab03eb | Ruby | shoes/shoes-deprecated | /req/hpricot/lib/hpricot/builder.rb | UTF-8 | 6,193 | 2.75 | 3 | [
"MIT"
] | permissive | require 'hpricot/tags'
#require 'fast_xs'
require 'hpricot/blankslate'
require 'hpricot/htmlinfo'
module Hpricot
# XML unescape
def self.uxs(str)
str.to_s.
gsub(/\&(\w+);/) { [NamedCharacters[$1] || ??].pack("U*") }.
gsub(/\&\#(\d+);/) { [$1.to_i].pack("U*") }
end
def self.build(ele = Doc.... | true |
d33c298014d34a82399878a39533ed4fc778d041 | Ruby | pro1es1/connect-four-ruby-project | /ConnectFourConsole.rb | UTF-8 | 3,028 | 3.203125 | 3 | [] | no_license | class ConnectFour
def initialize
@f = Array.new(7) { Array.new(15) }
(0..@f.size-1).each do |i|
(0..@f[i].size-1).each do |j|
if j%2 == 0 then @f[i][j] = "|" else @f[i][j] = " " end
if i == 6 then @f[i][j] = "-" end
end
end
end
def printPattern
(0..@f.size-1).ea... | true |
1d215ca24d873668f9adecc0ac719c7dc78dc32b | Ruby | ishtaka/fun-ruby | /chapter06/6.9_until.rb | UTF-8 | 65 | 3.078125 | 3 | [] | no_license | sum = 0
i = 1
until sum >= 50
sum += i
i += 1
end
puts sum
| true |
ea5dd3b9b341adb19075e3fc3c26681fce8ed9ec | Ruby | davorb/rusers | /rusers-server.rb | UTF-8 | 1,527 | 3.015625 | 3 | [] | no_license | require 'redis'
require 'uri'
require 'yaml'
require "./ParseW.rb"
require "./Connection.rb"
require "./ConfigReader.rb"
Redis_Address = File.read 'config.yaml'
uri = URI.parse(Redis_Address)
REDIS = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password)
Debug = false
##
# Sets the following keys... | true |
c3292bc32893f10a18665f5180babbb4763692fd | Ruby | PatrickJamesHoban/meandralgorithmproof | /driver.rb | UTF-8 | 2,092 | 3.171875 | 3 | [
"MIT"
] | permissive | # DRIVER CODE FOR ALGORITHM.RB
require_relative 'algorithm'
# TEST NODE INSTANCES AND CLASS WORKS
@node = Node.new({a: [0,1]})
test_interest_points = [
{ name: 'a', x: 0, y: 1 },
{ name: 'b', x: 0, y: 2 },
{ name: 'c', x: 2, y: 0 },
{ name: 'd', x: 3, y: 3 },
{ name: 'e', x: 1, y: 0 },
{ name: 'f', x: 3, ... | true |
7e65852d80eb4c3428d5583c32ff3b755ecdae84 | Ruby | LuisHerrera98/cursoRuby | /curso-Ruby/tipoDeDato-Rango.rb | UTF-8 | 22 | 2.890625 | 3 | [] | no_license | x = (1..6).to_a
puts x | true |
f787e6d4285182f0fc89c1a17732a60557dc028f | Ruby | imouaddine/indexing_api | /spec/controllers/pages_controller_spec.rb | UTF-8 | 3,676 | 2.53125 | 3 | [] | no_license | require 'rails_helper'
# This spec was generated by rspec-rails when you ran the scaffold generator.
# It demonstrates how one might use RSpec to specify the controller code that
# was generated by Rails when you ran the scaffold generator.
#
# It assumes that the implementation code is generated by the rails scaffold... | true |
066e071b32ca51168a3c8ffe647d5be298c39a89 | Ruby | marceldegraaf/lita-slack | /lib/lita/adapters/slack.rb | UTF-8 | 2,761 | 2.6875 | 3 | [
"MIT"
] | permissive | require 'lita'
require 'faraday'
require 'json'
module Lita
module Adapters
class Slack < Adapter
# Required Lita config keys (via lita_config.rb)
require_configs :incoming_token, :team_domain
def initialize(robot)
log.debug 'Slack::initialize started'
super
# Set con... | true |
9f11da63f8e4c8d47e9ad1e80e33d9b35eee1376 | Ruby | mjniday/gisterday | /lib/gist.rb | UTF-8 | 2,984 | 2.921875 | 3 | [] | no_license | require "optparse"
require "json"
require "httparty"
module Gisterday
AUTH_URL = "https://api.github.com/authorizations"
GIST_URL = "https://api.github.com/gists"
TOKEN_LOCATION = ENV['HOME'] + "/.gisterday"
class GitHubAuth
attr_accessor :username, :password, :two_factor, :base_request_options
def i... | true |
777bfc7abb0c89fd76740e34b5b5d2cfdd399aff | Ruby | yordanosd/FarMar | /lib/sale.rb | UTF-8 | 3,261 | 3.125 | 3 | [] | no_license | #require_relative '../far_mar'
require 'date'
require 'chronic'
class FarMar::Sale
CSV_FILE = "./support/sales.csv"
@@sale = nil
attr_reader :id, :amount, :purchase_time, :vendor_id, :product_id
def initialize(sales_info)
@id, @amount, @purchase_time, @vendor_id, @product_id = sales_info
# conver... | true |
83a73bf885764a63c7b683d346938c65e65bec60 | Ruby | oneworldcoders/live-katas | /kata-video-store/lib/children_movie.rb | UTF-8 | 257 | 3.125 | 3 | [] | no_license | require "movie"
class ChildrenMovie < Movie
def price(days_rented)
amount = 1.5
if days_rented > 3
amount += (days_rented - 3) * 1.5
end
amount
end
def points(days_rented)
1
end
end | true |
3ca45dddfdf206d82cba133b2f2f235dcee35d62 | Ruby | IDolgirev/solid-principles-ruby | /demo.rb | UTF-8 | 2,601 | 3.953125 | 4 | [] | no_license | require 'io/console'
require_relative 'lib/hero'
require_relative 'lib/monster'
require_relative 'lib/attack_action'
require_relative 'lib/flee_action'
hero = Hero.new strength: 5,
stealth: 5,
health: 15,
actions: {
attack: AttackAction.new,
... | true |
8d7c83b35b1ff63d5bd9075a2793cc5ec389f788 | Ruby | doakcovington/oo-banking-online-web-sp-000 | /lib/bank_account.rb | UTF-8 | 521 | 3.5625 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | require 'pry'
class BankAccount
attr_accessor :balance, :status
attr_reader :name
def initialize(name)
@name = name.freeze
@balance = 1000
@status = "open"
end
def deposit(deposit)
@balance += deposit
end
def display_balance
"Your balance is $#{self.balance}."
end
def valid?
... | true |
a30ab457e01a9853dff0d65d972153dcac22d028 | Ruby | kristianmandrup/geo_units | /lib/geo_units/converter.rb | UTF-8 | 2,608 | 2.90625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module GeoUnits
module Converter
autoload_modules :Normalizer, :Dms, :Units
include Normalizer
# Convert numeric degrees to deg/min/sec latitude (suffixed with N/S)
#
# @param {Number} deg: Degrees
# @param {String} [format=dms]: Return value as 'd', 'dm', 'dms'
# @param {Number} ... | true |
c36a8c1d56cf4a88307d2b706d48dd7c62ef4037 | Ruby | anspfeifer/cursos-ruby | /orientacao-objetos/3-melhores-praticas/text.rb | UTF-8 | 310 | 3.59375 | 4 | [] | no_license | class Cliente
def initialize(nome, idade)
@nome = nome
@idade = idade
debug_me
end
def debug_me
puts "#{@nome},#{@idade}"
end
end
class Cliente
#declarando o metodo agora como privado
private
def debug_me
puts "um outro metodo de debug"
end
end
Cliente.new("carlos", 30) | true |
330a9d64e6df40daed123b54a5655f27ba9d5fa9 | Ruby | KurisuLim/ruby_udemy_lessons | /multiline_strings.rb | UTF-8 | 140 | 2.6875 | 3 | [] | no_license | words = <<MLS
This will be a multi-line string
when it is output.
The tabs will also be preserved.
Just you watch.
Goodbye
MLS
puts words | true |
6e17ec823ea05801c47bf56af26df9b85cc41cf9 | Ruby | cwillems/acfs | /lib/acfs/resource/attributes/list.rb | UTF-8 | 613 | 2.875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | module Acfs::Resource::Attributes
# @api public
#
# List attribute type. Use it in your model as an attribute type:
#
# @example
# class User < Acfs::Resource
# attribute :name, :list
# end
#
class List < Base
# @api public
#
# Cast given object to a list.
#
# @param [Obj... | true |
e6260c5d25b1f0913d148eac4e814c19a498e9f9 | Ruby | jorrel/codes | /experiments/export-externals | UTF-8 | 733 | 2.6875 | 3 | [] | no_license | #! /usr/bin/env ruby
$usage = <<-end_usage
Usage:
export-externals [options] <source_path> <target_path>
Options:
--dry-run: print the export commands only and not run it
end_usage
$dry_run = !!ARGV.delete('--dry-run')
$source_path, $target_path = ARGV[0], ARGV[1]
if $source_path.nil? or $target_path.n... | true |
3013a6e48bb472c06252e82b78986ab696c28630 | Ruby | healthify/mob-bank-ocr | /spec/number_parser_spec.rb | UTF-8 | 724 | 2.640625 | 3 | [] | no_license | require_relative "../lib/number_parser"
describe NumberParser do
context "when reading a file of zeroes" do
it "returns an array of zeroes" do
parsed = NumberParser.parse "data/zeroes.txt"
expect(parsed).to eq "000000000"
end
end
context "when reading a file of ones" do
it "returns an arr... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.