Class: NumbersInWords::PairParsing
- Inherits:
-
Object
- Object
- NumbersInWords::PairParsing
- Defined in:
- lib/numbers_in_words/parsing/pair_parsing.rb
Instance Attribute Summary collapse
-
#ints ⇒ Object
Returns the value of attribute ints.
-
#only_compress ⇒ Object
readonly
Returns the value of attribute only_compress.
Instance Method Summary collapse
-
#initialize(ints, only_compress) ⇒ PairParsing
constructor
A new instance of PairParsing.
-
#pair_parse ⇒ Object
15,16 85,16.
Constructor Details
#initialize(ints, only_compress) ⇒ PairParsing
Returns a new instance of PairParsing.
8 9 10 11 |
# File 'lib/numbers_in_words/parsing/pair_parsing.rb', line 8 def initialize(ints, only_compress) @ints = ints @only_compress = only_compress end |
Instance Attribute Details
#ints ⇒ Object
Returns the value of attribute ints.
5 6 7 |
# File 'lib/numbers_in_words/parsing/pair_parsing.rb', line 5 def ints @ints end |
#only_compress ⇒ Object (readonly)
Returns the value of attribute only_compress.
6 7 8 |
# File 'lib/numbers_in_words/parsing/pair_parsing.rb', line 6 def only_compress @only_compress end |
Instance Method Details
#pair_parse ⇒ Object
15,16 85,16
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/numbers_in_words/parsing/pair_parsing.rb', line 15 def pair_parse ints = compressed return ints if only_compress return ints[0] if ints.length == 1 sum = 0 ints.each do |n| sum *= n >= 10 ? 100 : 10 sum += n end sum end |