class OFX::Builder

Attributes

acct_id[RW]
acct_type[RW]
bal_amt[RW]
bank_id[RW]
dtasof[RW]
dtend[RW]
dtserver[RW]
dtstart[RW]
fi_fid[RW]
fi_org[RW]
transactions[RW]

Public Class Methods

new() { |self| ... } click to toggle source
# File lib/ofx.rb, line 24
def initialize(&block)
  @headers = [
              [ "OFXHEADER", "100" ],
              [ "DATA", "OFXSGML" ],
              [ "VERSION", "103" ],
              [ "SECURITY", "NONE" ],
              [ "ENCODING", "USASCII" ],
              [ "CHARSET", "1252" ],
              [ "COMPRESSION", "NONE" ],
              [ "OLDFILEUID", "NONE" ],
              [ "NEWFILEUID", "NONE" ]
             ]
  @transactions = []
  self.dtserver = Date.today
  if block_given?
    yield self
  end
end

Public Instance Methods

bal_amt=(amt) click to toggle source
# File lib/ofx.rb, line 43
def bal_amt=(amt)
  @bal_amt = BigDecimal.new(amt)
end
format_amount(amount) click to toggle source
# File lib/ofx.rb, line 136
def format_amount(amount)
  if amount > 0
    "+#{amount.to_s('F')}"
  else
    "#{amount.to_s('F')}"
  end
end
format_balance(balance) click to toggle source
# File lib/ofx.rb, line 152
def format_balance(balance)
  balance.to_s('F')
end
format_date(time) click to toggle source
# File lib/ofx.rb, line 132
def format_date(time)
  time.strftime("%Y%m%d")
end
format_datetime(time) click to toggle source
# File lib/ofx.rb, line 128
def format_datetime(time)
  time.strftime("%Y%m%d000000")
end
format_trntype(amount) click to toggle source
# File lib/ofx.rb, line 144
def format_trntype(amount)
  if amount > 0
    "CREDIT"
  else
    "DEBIT"
  end
end
print_body() click to toggle source
print_headers() click to toggle source
to_ofx() click to toggle source
# File lib/ofx.rb, line 53
def to_ofx
  print_headers +
    print_body
end
transaction() { |transaction| ... } click to toggle source
# File lib/ofx.rb, line 47
def transaction(&block)
  transaction = OFX::Transaction.new
  yield transaction
  self.transactions.push transaction
end