Class: R0man::Number
- Inherits:
-
Object
- Object
- R0man::Number
- Includes:
- SimpleValidation
- Defined in:
- lib/r0man/number.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(str) ⇒ Number
constructor
A new instance of Number.
- #value ⇒ Object
Constructor Details
Class Method Details
.parse(str) ⇒ Object
13 14 15 |
# File 'lib/r0man/number.rb', line 13 def parse(str) new(str) end |
Instance Method Details
#value ⇒ Object
23 24 25 |
# File 'lib/r0man/number.rb', line 23 def value @value ||= @valid.each_cons(2).reduce(0) { |result, (d1, d2)| result += d1.value_compared_to(d2) } + @valid.last.value end |