Class: TrangeFrange::Amount
- Inherits:
-
Object
- Object
- TrangeFrange::Amount
- Defined in:
- lib/trange_frange/amount.rb
Constant Summary collapse
- MAX_AMOUNT_SIZE =
12
- BASES =
[TrangeFrange::Hundred, TrangeFrange::Ten, TrangeFrange::One]
- SUFFIXES =
[TrangeFrange::Thousand, TrangeFrange::Milion, TrangeFrange::Bilion]
Instance Attribute Summary collapse
-
#amount ⇒ Object
readonly
Returns the value of attribute amount.
Instance Method Summary collapse
-
#initialize(amount) ⇒ Amount
constructor
A new instance of Amount.
- #spell!(options = {}) ⇒ Object
Constructor Details
#initialize(amount) ⇒ Amount
Returns a new instance of Amount.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/trange_frange/amount.rb', line 11 def initialize(amount) unless amount.is_a?(Fixnum) || amount.is_a?(Float) raise TypeError, 'Amount must be of type Fixnum or Float.' end if max_amount_size?(amount) raise NotImplementedError, 'I can only work with amounts up to 999 bilions.' end @amount = amount end |
Instance Attribute Details
#amount ⇒ Object (readonly)
Returns the value of attribute amount.
5 6 7 |
# File 'lib/trange_frange/amount.rb', line 5 def amount @amount end |
Instance Method Details
#spell!(options = {}) ⇒ Object
23 24 25 |
# File 'lib/trange_frange/amount.rb', line 23 def spell!(={}) TrangeFrange::Shaper.new(generate_words!, fraction, ).shape! end |