Class: Dinero::Account
- Inherits:
-
Object
- Object
- Dinero::Account
- Defined in:
- lib/dinero/account.rb
Instance Attribute Summary collapse
-
#account_type ⇒ Object
readonly
Returns the value of attribute account_type.
-
#available ⇒ Object
readonly
Returns the value of attribute available.
-
#balance ⇒ Object
readonly
Returns the value of attribute balance.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#name_other ⇒ Object
readonly
Returns the value of attribute name_other.
-
#number ⇒ Object
readonly
Returns the value of attribute number.
Instance Method Summary collapse
-
#initialize(account_type, name, number, balance, available) ⇒ Account
constructor
A new instance of Account.
Constructor Details
#initialize(account_type, name, number, balance, available) ⇒ Account
Returns a new instance of Account.
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/dinero/account.rb', line 6 def initialize account_type, name, number, balance, available @account_type = account_type name_parts = name.split("\n") @name = name_parts.shift @name_other = name_parts.join("\n") @number = number @balance = balance.scan(NUMERIC_REGEXP).join.to_f @available = available.scan(NUMERIC_REGEXP).join.to_f @balance *= -1 if @account_type == :loan end |
Instance Attribute Details
#account_type ⇒ Object (readonly)
Returns the value of attribute account_type.
5 6 7 |
# File 'lib/dinero/account.rb', line 5 def account_type @account_type end |
#available ⇒ Object (readonly)
Returns the value of attribute available.
5 6 7 |
# File 'lib/dinero/account.rb', line 5 def available @available end |
#balance ⇒ Object (readonly)
Returns the value of attribute balance.
5 6 7 |
# File 'lib/dinero/account.rb', line 5 def balance @balance end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/dinero/account.rb', line 5 def name @name end |
#name_other ⇒ Object (readonly)
Returns the value of attribute name_other.
5 6 7 |
# File 'lib/dinero/account.rb', line 5 def name_other @name_other end |
#number ⇒ Object (readonly)
Returns the value of attribute number.
5 6 7 |
# File 'lib/dinero/account.rb', line 5 def number @number end |