Class: BarcodeValidation::DigitSequence
- Inherits:
-
Array
- Object
- Array
- BarcodeValidation::DigitSequence
show all
- Extended by:
- Forwardable
- Includes:
- Mixin::ValueObject
- Defined in:
- lib/barcodevalidation/digit_sequence.rb
Constant Summary
collapse
- ArgumentError =
Error::ArgumentErrorClass.new(DigitSequence)
Class Method Summary
collapse
Instance Method Summary
collapse
#eql?, included, #inspect, #pretty_print
Constructor Details
Returns a new instance of DigitSequence.
20
21
22
23
24
25
|
# File 'lib/barcodevalidation/digit_sequence.rb', line 20
def initialize(values)
values = cast(values)
raise ArgumentError, values unless values.respond_to? :map
super(values.map { |value| BarcodeValidation::Digit.new(value) })
end
|
Class Method Details
.cast(input) ⇒ Object
14
15
16
17
18
|
# File 'lib/barcodevalidation/digit_sequence.rb', line 14
def self.cast(input)
input = input.to_s if input.is_a? Integer
input = input.chars if input.is_a? String
input
end
|
Instance Method Details
#*(other) ⇒ Object
34
35
36
|
# File 'lib/barcodevalidation/digit_sequence.rb', line 34
def *(other)
self.class.new(super)
end
|
#==(other) ⇒ Object
27
28
29
30
31
32
|
# File 'lib/barcodevalidation/digit_sequence.rb', line 27
def ==(other)
case other
when String, Numeric then super(self.class.new(other))
else super
end
end
|