Class: Financial::Deposit
Instance Attribute Summary collapse
-
#account_name ⇒ Object
readonly
Returns the value of attribute account_name.
-
#account_to_deposit ⇒ Object
readonly
Returns the value of attribute account_to_deposit.
-
#name ⇒ Object
Returns the value of attribute name.
-
#value ⇒ Object
Returns the value of attribute value.
Attributes inherited from Cost
Instance Method Summary collapse
- #deposit_name! ⇒ Object
- #in_account(account_name) ⇒ Object
-
#initialize(value, _account_name) ⇒ Deposit
constructor
A new instance of Deposit.
-
#is_a_received_deposit?(account) ⇒ Boolean
Return true if is a received deposit.
Methods inherited from Cost
#+, #==, #format_value, #in_date
Constructor Details
#initialize(value, _account_name) ⇒ Deposit
Returns a new instance of Deposit.
6 7 8 9 10 11 12 |
# File 'lib/financial/deposit.rb', line 6 def initialize(value, _account_name) @value = value @date = Date.today @account_to_deposit = :anonymous @account_name = _account_name deposit_name! end |
Instance Attribute Details
#account_name ⇒ Object (readonly)
Returns the value of attribute account_name.
4 5 6 |
# File 'lib/financial/deposit.rb', line 4 def account_name @account_name end |
#account_to_deposit ⇒ Object (readonly)
Returns the value of attribute account_to_deposit.
4 5 6 |
# File 'lib/financial/deposit.rb', line 4 def account_to_deposit @account_to_deposit end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/financial/deposit.rb', line 3 def name @name end |
#value ⇒ Object
Returns the value of attribute value.
3 4 5 |
# File 'lib/financial/deposit.rb', line 3 def value @value end |
Instance Method Details
#deposit_name! ⇒ Object
20 21 22 |
# File 'lib/financial/deposit.rb', line 20 def deposit_name! @name = "#{Financial.locale.deposit_name}: #{@account_to_deposit}" end |
#in_account(account_name) ⇒ Object
14 15 16 17 18 |
# File 'lib/financial/deposit.rb', line 14 def in_account(account_name) @account_to_deposit = account_name deposit_name! self end |
#is_a_received_deposit?(account) ⇒ Boolean
Return true if is a received deposit
26 27 28 |
# File 'lib/financial/deposit.rb', line 26 def is_a_received_deposit?(account) (not account.deposits.include?(self)) and (account.name.equal?(account_to_deposit)) end |