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.
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
#account ⇒ Object
Returns the value of attribute account.
4 5 6 |
# File 'lib/quicken/parser.rb', line 4 def account @account end |
#date_format ⇒ Object
Returns the value of attribute date_format.
4 5 6 |
# File 'lib/quicken/parser.rb', line 4 def date_format @date_format end |
#file ⇒ Object
Returns the value of attribute file.
4 5 6 |
# File 'lib/quicken/parser.rb', line 4 def file @file end |
#transactions ⇒ Object
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) ? parse_account(line) : parse_transactions(line) end build_objects self end |