Class: Qiflib::Money
- Inherits:
-
Object
- Object
- Qiflib::Money
- Defined in:
- lib/qiflib_money.rb
Overview
Instances of this class represent a dollar amount values from within a qif file.
Instance Attribute Summary collapse
-
#string_value ⇒ Object
readonly
Returns the value of attribute string_value.
Instance Method Summary collapse
- #cents ⇒ Object
-
#initialize(s = '0.00') ⇒ Money
constructor
A new instance of Money.
- #to_s ⇒ Object
Constructor Details
#initialize(s = '0.00') ⇒ Money
Returns a new instance of Money.
10 11 12 13 14 15 16 17 18 |
# File 'lib/qiflib_money.rb', line 10 def initialize(s='0.00') @string_value = "#{s}".tr('TBL, ' , '') if @string_value.size < 1 @string_value = '0.00' end if @string_value.end_with?('.') @string_value = "#{string_value}00" end end |
Instance Attribute Details
#string_value ⇒ Object (readonly)
Returns the value of attribute string_value.
8 9 10 |
# File 'lib/qiflib_money.rb', line 8 def string_value @string_value end |
Instance Method Details
#cents ⇒ Object
24 25 26 |
# File 'lib/qiflib_money.rb', line 24 def cents string_value.tr("$.","").to_i end |
#to_s ⇒ Object
20 21 22 |
# File 'lib/qiflib_money.rb', line 20 def to_s @string_value end |