class NumberNameString::Triplet
Accumulates and totals a 3 digit number (with an optional scale) Used internally only.
Attributes
hundreds[RW]
scale[RW]
tens[RW]
Public Class Methods
new(num = 0)
click to toggle source
# File lib/number_name_string/triplet.rb, line 7 def initialize(num = 0) reset num end
Public Instance Methods
<<(num)
click to toggle source
# File lib/number_name_string/triplet.rb, line 11 def <<(num) @hundreds = @tens if @tens > 0 @tens = num % 100 end
reset(num = 0)
click to toggle source
# File lib/number_name_string/triplet.rb, line 20 def reset(num = 0) @hundreds = 0 @tens = num @scale = 1 end
to_i()
click to toggle source
# File lib/number_name_string/triplet.rb, line 16 def to_i (@hundreds * 100 + @tens) * @scale end