Class: HamdownCore::LineParser

Inherits:
Object
  • Object
show all
Defined in:
lib/hamdown_core/line_parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#filenameObject (readonly)

Returns the value of attribute filename.



4
5
6
# File 'lib/hamdown_core/line_parser.rb', line 4

def filename
  @filename
end

#linenoObject (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

Returns:

  • (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