Class: Qif::Transaction::Split
- Inherits:
-
Object
- Object
- Qif::Transaction::Split
- Defined in:
- lib/qif/transaction/split.rb
Defined Under Namespace
Classes: Builder
Constant Summary collapse
- SUPPORTED_FIELDS =
{ :category => {"S" => "Category in split (Category/Transfer/Class)" }, :memo => {"E" => "Memo in split" }, :amount => {"$" => "Dollar amount of split" }, }
Instance Attribute Summary collapse
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#category ⇒ Object
Returns the value of attribute category.
-
#memo ⇒ Object
Returns the value of attribute memo.
Instance Method Summary collapse
-
#to_s ⇒ Object
Returns a representation of the split as it would appear in a qif file.
Instance Attribute Details
#amount ⇒ Object
Returns the value of attribute amount.
8 9 10 |
# File 'lib/qif/transaction/split.rb', line 8 def amount @amount end |
#category ⇒ Object
Returns the value of attribute category.
8 9 10 |
# File 'lib/qif/transaction/split.rb', line 8 def category @category end |
#memo ⇒ Object
Returns the value of attribute memo.
8 9 10 |
# File 'lib/qif/transaction/split.rb', line 8 def memo @memo end |
Instance Method Details
#to_s ⇒ Object
Returns a representation of the split as it would appear in a qif file.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/qif/transaction/split.rb', line 12 def to_s() SUPPORTED_FIELDS.collect do |k,v| next unless current = instance_variable_get("@#{k}") field = v.keys.first case current.class.to_s when "Float" "#{field}#{'%.2f'%current}" when "String" current.split("\n").collect {|x| "#{field}#{x}" } else "#{field}#{current}" end end.flatten.compact.join("\n") end |