This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Letters = { | |
'0' => %w(0), | |
'1' => %w(1), | |
'2' => %w(a b c), | |
'3' => %w(d e f), | |
'4' => %w(g h i), | |
'5' => %w(j k l), | |
'6' => %w(m n o), | |
'7' => %w(p q r s), | |
'8' => %w(t u v), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# - Konfeo.com | |
# - Mail wysyłany jako organizator | |
# - ~ 15 000 wysyłanych maili miesięcznie | |
# ------------------------------------------------------------ | |
# Kodowanie nagłówków maili | |
require 'mail' | |
m = Mail.new |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Arc | |
def initialize(from, to) | |
raise ArgumentError if invalid?(from) || invalid?(to) | |
@from = from | |
@to = to | |
end | |
def to_s | |
"#{arc} degrees from #{@from} to #{@to}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'test_helper' | |
class ArcTest < ActiveSupport::TestCase | |
test 'arguments are valid' do | |
assert_raises(ArgumentError) { Arc.new(0, 400) } | |
assert_raises(ArgumentError) { Arc.new(-10, 200) } | |
assert_raises(ArgumentError) { Arc.new(0, 360) } | |
assert_nothing_raised { Arc.new(0, 90) } | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Light | |
COLORS = %i[white green red yellow].freeze | |
TYPES = %i[unbroken flashing].freeze | |
attr_reader :color, :type, :arc | |
def initialize(color, type, arc) | |
raise ArgumentError unless COLORS.include?(color) | |
raise ArgumentError unless TYPES.include?(type) | |
raise ArgumentError unless arc.is_a?(Arc) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'test_helper' | |
class LightTest < ActiveSupport::TestCase | |
test 'arguments are valid' do | |
assert_raises(ArgumentError) { Light.new(:pink, :unbroken, Arc.new(0, 90)) } | |
assert_raises(ArgumentError) { Light.new(:white, :test, Arc.new(0, 90)) } | |
assert_raises(ArgumentError) { Light.new(:white, :unbroken, 10) } | |
assert_nothing_raised { Light.new(:white, :unbroken, Arc.new(0, 90)) } | |
end |