Class: Cmxl::Fields::AccountBalance
Constant Summary
Constants inherited
from Cmxl::Field
Cmxl::Field::DATE
Instance Attribute Summary
Attributes inherited from Cmxl::Field
#data, #match, #modifier, #source, #tag
Instance Method Summary
collapse
Methods inherited from Cmxl::Field
#add_meta_data, #initialize, #method_missing, parse, parsers, #to_amount, #to_amount_in_cents, #to_date, #to_hash, #to_json
Constructor Details
This class inherits a constructor from Cmxl::Field
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Cmxl::Field
Instance Method Details
#amount ⇒ Object
19
20
21
|
# File 'lib/cmxl/fields/account_balance.rb', line 19
def amount
to_amount(data['amount'])
end
|
#amount_in_cents ⇒ Object
27
28
29
|
# File 'lib/cmxl/fields/account_balance.rb', line 27
def amount_in_cents
to_amount_in_cents(data['amount'])
end
|
#credit? ⇒ Boolean
11
12
13
|
# File 'lib/cmxl/fields/account_balance.rb', line 11
def credit?
data['funds_code'].to_s.casecmp('C').zero?
end
|
#date ⇒ Object
7
8
9
|
# File 'lib/cmxl/fields/account_balance.rb', line 7
def date
to_date(data['date'])
end
|
#debit? ⇒ Boolean
15
16
17
|
# File 'lib/cmxl/fields/account_balance.rb', line 15
def debit?
!credit?
end
|
#sign ⇒ Object
23
24
25
|
# File 'lib/cmxl/fields/account_balance.rb', line 23
def sign
credit? ? 1 : -1
end
|
#to_h ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/cmxl/fields/account_balance.rb', line 31
def to_h
super.merge(
'date' => date,
'funds_code' => funds_code,
'credit' => credit?,
'debit' => debit?,
'currency' => currency,
'amount' => amount,
'amount_in_cents' => amount_in_cents,
'sign' => sign
)
end
|