Class: HamdownCore::LineParser
- Inherits:
-
Object
- Object
- HamdownCore::LineParser
- Defined in:
- lib/hamdown_core/line_parser.rb
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#lineno ⇒ Object
readonly
Returns the value of attribute lineno.
Instance Method Summary collapse
- #has_next? ⇒ Boolean
-
#initialize(filename, template_str) ⇒ LineParser
constructor
A new instance of LineParser.
- #next_line(in_filter: false) ⇒ Object
Constructor Details
#initialize(filename, template_str) ⇒ LineParser
Returns a new instance of LineParser.
6 7 8 9 10 |
# File 'lib/hamdown_core/line_parser.rb', line 6 def initialize(filename, template_str) @filename = filename @lines = template_str.each_line.map { |line| line.chomp.rstrip } @lineno = 0 end |
Instance Attribute Details
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
4 5 6 |
# File 'lib/hamdown_core/line_parser.rb', line 4 def filename @filename end |
#lineno ⇒ Object (readonly)
Returns the value of attribute lineno.
4 5 6 |
# File 'lib/hamdown_core/line_parser.rb', line 4 def lineno @lineno end |
Instance Method Details
#has_next? ⇒ Boolean
21 22 23 |
# File 'lib/hamdown_core/line_parser.rb', line 21 def has_next? @lineno < @lines.size end |
#next_line(in_filter: false) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/hamdown_core/line_parser.rb', line 12 def next_line(in_filter: false) line = move_next if !in_filter && is_multiline?(line) next_multiline(line) else line end end |