Class: Quicken::Parser
- Inherits:
-
Object
- Object
- Quicken::Parser
- Defined in:
- lib/quicken/parser.rb
Instance Attribute Summary collapse
-
#account ⇒ Object
Returns the value of attribute account.
-
#date_format ⇒ Object
Returns the value of attribute date_format.
-
#file ⇒ Object
Returns the value of attribute file.
-
#transactions ⇒ Object
Returns the value of attribute transactions.
Instance Method Summary collapse
-
#initialize(file, date_format = nil) ⇒ Parser
constructor
A new instance of Parser.
- #parse! ⇒ Object
Constructor Details
#initialize(file, date_format = nil) ⇒ Parser
Returns a new instance of Parser.
9 10 11 12 13 14 |
# File 'lib/quicken/parser.rb', line 9 def initialize(file, date_format=nil) @date_format = date_format @file = file @transactions_attrs = [] @account_attrs = {} end |
Instance Attribute Details
#account ⇒ Object
Returns the value of attribute account.
7 8 9 |
# File 'lib/quicken/parser.rb', line 7 def account @account end |
#date_format ⇒ Object
Returns the value of attribute date_format.
7 8 9 |
# File 'lib/quicken/parser.rb', line 7 def date_format @date_format end |
#file ⇒ Object
Returns the value of attribute file.
7 8 9 |
# File 'lib/quicken/parser.rb', line 7 def file @file end |
#transactions ⇒ Object
Returns the value of attribute transactions.
7 8 9 |
# File 'lib/quicken/parser.rb', line 7 def transactions @transactions end |
Instance Method Details
#parse! ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/quicken/parser.rb', line 16 def parse! section = nil File.foreach(@file) do |line| line = convert_to_utf8(line) if line =~ /^\!(\S+)/ section = extract_section($1) next end (section == :account) ? parse_account(line) : parse_transactions(line) end build_objects self end |