Class: Rbankgiro::Transactions
- Inherits:
-
Array
- Object
- Array
- Rbankgiro::Transactions
- Defined in:
- lib/rbankgiro.rb
Instance Attribute Summary collapse
-
#file_date ⇒ Object
readonly
Returns the value of attribute file_date.
Instance Method Summary collapse
-
#initialize(file) ⇒ Transactions
constructor
Parses an reference_number transaction file from Rbankgirocentralen Creates Rbankgiro::Transaction objects for each transaction.
- #inspect ⇒ Object
- #select_with(bankgiro_number) ⇒ Object
- #sum ⇒ Object
Constructor Details
#initialize(file) ⇒ Transactions
Parses an reference_number transaction file from Rbankgirocentralen Creates Rbankgiro::Transaction objects for each transaction
64 65 66 67 68 69 |
# File 'lib/rbankgiro.rb', line 64 def initialize(file) File.read(file).each_line do |row| next if row.strip.empty? # Skip empty rows parse_row(row) end end |
Instance Attribute Details
#file_date ⇒ Object (readonly)
Returns the value of attribute file_date.
60 61 62 |
# File 'lib/rbankgiro.rb', line 60 def file_date @file_date end |
Instance Method Details
#inspect ⇒ Object
75 76 77 78 |
# File 'lib/rbankgiro.rb', line 75 def inspect sprintf("#<%s:0x%x %s>", self.class.name, __id__, "@sum=#{self.sum}, @length=#{self.length}, @file_date=#{self.file_date}") end |
#select_with(bankgiro_number) ⇒ Object
80 81 82 |
# File 'lib/rbankgiro.rb', line 80 def select_with(bankgiro_number) self.dup.replace(self.select {|t| t.bankgiro_number == bankgiro_number }) end |
#sum ⇒ Object
71 72 73 |
# File 'lib/rbankgiro.rb', line 71 def sum self.collect {|t| t.amount }.inject {|s,n| s + n } end |