Class: Quicken::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/quicken/parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file, date_format = nil) ⇒ Parser

Returns a new instance of Parser.



6
7
8
9
10
11
# File 'lib/quicken/parser.rb', line 6

def initialize(file, date_format=nil)
  @date_format = date_format
  @file = file
  @transactions_attrs = []
  @account_attrs = {}
end

Instance Attribute Details

#accountObject

Returns the value of attribute account.



4
5
6
# File 'lib/quicken/parser.rb', line 4

def 
  @account
end

#date_formatObject

Returns the value of attribute date_format.



4
5
6
# File 'lib/quicken/parser.rb', line 4

def date_format
  @date_format
end

#fileObject

Returns the value of attribute file.



4
5
6
# File 'lib/quicken/parser.rb', line 4

def file
  @file
end

#transactionsObject

Returns the value of attribute transactions.



4
5
6
# File 'lib/quicken/parser.rb', line 4

def transactions
  @transactions
end

Instance Method Details

#parse!Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/quicken/parser.rb', line 13

def parse!
  section = nil

  File.foreach(@file) do |line|
    if line =~ /^\!(\S+)/
      section = extract_section($1)
      next
    end

    (section == :account) ? (line) : parse_transactions(line)
  end

  build_objects
  self
end