Class: IMW::Parsers::Flat
- Inherits:
-
Object
- Object
- IMW::Parsers::Flat
- Defined in:
- lib/imw/parsers/flat.rb
Instance Attribute Summary collapse
-
#accumulated ⇒ Object
Returns the value of attribute accumulated.
-
#current ⇒ Object
Returns the value of attribute current.
-
#io ⇒ Object
Returns the value of attribute io.
-
#state ⇒ Object
Returns the value of attribute state.
Instance Method Summary collapse
- #accumulate! ⇒ Object
- #complete? ⇒ Boolean
-
#initialize(io) ⇒ Flat
constructor
A new instance of Flat.
- #parse! ⇒ Object
- #react_to_input! ⇒ Object
- #read_next! ⇒ Object
Constructor Details
#initialize(io) ⇒ Flat
Returns a new instance of Flat.
11 12 13 14 15 16 |
# File 'lib/imw/parsers/flat.rb', line 11 def initialize io self.io = io self.state = nil self.accumulated = [] self.current = nil end |
Instance Attribute Details
#accumulated ⇒ Object
Returns the value of attribute accumulated.
8 9 10 |
# File 'lib/imw/parsers/flat.rb', line 8 def accumulated @accumulated end |
#current ⇒ Object
Returns the value of attribute current.
9 10 11 |
# File 'lib/imw/parsers/flat.rb', line 9 def current @current end |
#io ⇒ Object
Returns the value of attribute io.
6 7 8 |
# File 'lib/imw/parsers/flat.rb', line 6 def io @io end |
#state ⇒ Object
Returns the value of attribute state.
7 8 9 |
# File 'lib/imw/parsers/flat.rb', line 7 def state @state end |
Instance Method Details
#accumulate! ⇒ Object
29 30 31 |
# File 'lib/imw/parsers/flat.rb', line 29 def accumulate! self.accumulated << current end |
#complete? ⇒ Boolean
33 34 35 |
# File 'lib/imw/parsers/flat.rb', line 33 def complete? io.eof? end |
#parse! ⇒ Object
22 23 24 25 26 27 |
# File 'lib/imw/parsers/flat.rb', line 22 def parse! while (! complete?) read_next! react_to_input! end end |
#react_to_input! ⇒ Object
37 38 39 |
# File 'lib/imw/parsers/flat.rb', line 37 def react_to_input! raise IMW::NotImplementedError.new("Override the `react_to_input!' method of the #{self.class} class") end |
#read_next! ⇒ Object
18 19 20 |
# File 'lib/imw/parsers/flat.rb', line 18 def read_next! self.current = io.readline.chomp end |