Class: Banco::Transaction
- Inherits:
-
Object
- Object
- Banco::Transaction
- Defined in:
- lib/banco/transaction.rb
Instance Attribute Summary collapse
-
#csv_row_count ⇒ Object
readonly
Returns the value of attribute csv_row_count.
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#moneyin ⇒ Object
readonly
Returns the value of attribute moneyin.
-
#moneyout ⇒ Object
readonly
Returns the value of attribute moneyout.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #convert(money) ⇒ Object
-
#initialize(date_string, description, type, moneyin, moneyout, csv_row_count) ⇒ Transaction
constructor
A new instance of Transaction.
- #to_s ⇒ Object
Constructor Details
#initialize(date_string, description, type, moneyin, moneyout, csv_row_count) ⇒ Transaction
Returns a new instance of Transaction.
7 8 9 10 11 12 13 14 |
# File 'lib/banco/transaction.rb', line 7 def initialize(date_string, description, type, , moneyout, csv_row_count) @csv_row_count = csv_row_count @moneyin = convert() @moneyout = convert(moneyout) @date = date_string @description = format('%-22.22s', description.upcase.to_s) @type = format('%-8.8s', type.upcase.to_s) end |
Instance Attribute Details
#csv_row_count ⇒ Object (readonly)
Returns the value of attribute csv_row_count.
5 6 7 |
# File 'lib/banco/transaction.rb', line 5 def csv_row_count @csv_row_count end |
#date ⇒ Object (readonly)
Returns the value of attribute date.
5 6 7 |
# File 'lib/banco/transaction.rb', line 5 def date @date end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
5 6 7 |
# File 'lib/banco/transaction.rb', line 5 def description @description end |
#moneyin ⇒ Object (readonly)
Returns the value of attribute moneyin.
5 6 7 |
# File 'lib/banco/transaction.rb', line 5 def @moneyin end |
#moneyout ⇒ Object (readonly)
Returns the value of attribute moneyout.
5 6 7 |
# File 'lib/banco/transaction.rb', line 5 def moneyout @moneyout end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
5 6 7 |
# File 'lib/banco/transaction.rb', line 5 def type @type end |
Instance Method Details
#convert(money) ⇒ Object
16 17 18 |
# File 'lib/banco/transaction.rb', line 16 def convert(money) money.nil? ? BigDecimal('0') : BigDecimal(money) end |
#to_s ⇒ Object
20 21 22 |
# File 'lib/banco/transaction.rb', line 20 def to_s "#{date} #{type} #{description}" end |