Class: HamlParser::LineParser

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename, template_str) ⇒ LineParser

Returns a new instance of LineParser.



5
6
7
8
9
# File 'lib/haml_parser/line_parser.rb', line 5

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.



3
4
5
# File 'lib/haml_parser/line_parser.rb', line 3

def filename
  @filename
end

#linenoObject (readonly)

Returns the value of attribute lineno.



3
4
5
# File 'lib/haml_parser/line_parser.rb', line 3

def lineno
  @lineno
end

Instance Method Details

#has_next?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/haml_parser/line_parser.rb', line 20

def has_next?
  @lineno < @lines.size
end

#next_line(in_filter: false) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/haml_parser/line_parser.rb', line 11

def next_line(in_filter: false)
  line = move_next
  if !in_filter && is_multiline?(line)
    next_multiline(line)
  else
    line
  end
end