Class: OFX::Statement::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/ofx/statement/base.rb

Direct Known Subclasses

CreditCard, CurrentAccount

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(format = :ofx2) ⇒ Base

Returns a new instance of Base.



13
14
15
16
17
18
19
20
# File 'lib/ofx/statement/base.rb', line 13

def initialize(format = :ofx2)
  case format
  when :ofx1
    @builder_class = OFX::Statement::Output::Builder::OFX1
  when :ofx2
    @builder_class = OFX::Statement::Output::Builder::OFX2
  end
end

Instance Attribute Details

#account_numberObject

Returns the value of attribute account_number.



10
11
12
# File 'lib/ofx/statement/base.rb', line 10

def 
  @account_number
end

#builder_classObject (readonly)

Returns the value of attribute builder_class.



8
9
10
# File 'lib/ofx/statement/base.rb', line 8

def builder_class
  @builder_class
end

#currencyObject



22
23
24
# File 'lib/ofx/statement/base.rb', line 22

def currency
  @currency ||= 'GBP'
end

#dateObject

Returns the value of attribute date.



10
11
12
# File 'lib/ofx/statement/base.rb', line 10

def date
  @date
end

#end_dateObject

Returns the value of attribute end_date.



10
11
12
# File 'lib/ofx/statement/base.rb', line 10

def end_date
  @end_date
end

#languageObject



26
27
28
# File 'lib/ofx/statement/base.rb', line 26

def language
  @language ||= 'ENG'
end

#ledger_balanceObject

Returns the value of attribute ledger_balance.



10
11
12
# File 'lib/ofx/statement/base.rb', line 10

def ledger_balance
  @ledger_balance
end

#server_response_timeObject



30
31
32
# File 'lib/ofx/statement/base.rb', line 30

def server_response_time
  @server_response_time ||= Time.now
end

#start_dateObject

Returns the value of attribute start_date.



10
11
12
# File 'lib/ofx/statement/base.rb', line 10

def start_date
  @start_date
end

Instance Method Details

#<<(transaction) ⇒ Object



34
35
36
37
# File 'lib/ofx/statement/base.rb', line 34

def <<(transaction)
  transaction.statement = self
  transactions << transaction
end

#fitid_for(transaction) ⇒ Object



43
44
45
46
# File 'lib/ofx/statement/base.rb', line 43

def fitid_for(transaction)
  index = transactions.index(transaction)
  Digest::SHA1.hexdigest(self.date.strftime('%Y%m%d') + transaction.date.strftime('%Y%m%d') + index.to_s)
end

#serialise(format = :ofx2) ⇒ Object



48
49
50
# File 'lib/ofx/statement/base.rb', line 48

def serialise(format = :ofx2)
  output.new.serialise(self, format)
end

#transactionsObject



39
40
41
# File 'lib/ofx/statement/base.rb', line 39

def transactions
  @transactions ||= []
end