Class: PointBlank::Parsing::LineScanner
- Inherits:
-
Object
- Object
- PointBlank::Parsing::LineScanner
- Defined in:
- lib/mmmd/blankshell.rb
Instance Method Summary collapse
-
#initialize(text, doc) ⇒ LineScanner
constructor
A new instance of LineScanner.
-
#scan ⇒ Object
Scan document and return scanned structure.
Constructor Details
#initialize(text, doc) ⇒ LineScanner
Returns a new instance of LineScanner.
199 200 201 202 203 204 205 |
# File 'lib/mmmd/blankshell.rb', line 199 def initialize(text, doc) @text = text @document = doc @stack = [@document] @depth = 0 @topdepth = 0 end |
Instance Method Details
#scan ⇒ Object
Scan document and return scanned structure
208 209 210 211 212 213 214 215 216 217 218 219 |
# File 'lib/mmmd/blankshell.rb', line 208 def scan @text.each_line do |line| # Consume markers from lines to keep the levels open line = consume_markers(line) # DO NOT RHEDEEM line if it's empty line = line&.strip&.empty? ? nil : line # Open up a new block on the line out of all allowed child types while line && (status, line = try_open(line)) && status; end end close_up(0) @stack.first end |