Class: FastHaml::LineParser

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(template_str) ⇒ LineParser

Returns a new instance of LineParser.



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

def initialize(template_str)
  @lines = template_str.each_line.map { |line| line.chomp.rstrip }
  @lineno = 0
end

Instance Attribute Details

#linenoObject (readonly)

Returns the value of attribute lineno.



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

def lineno
  @lineno
end

Instance Method Details

#has_next?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/fast_haml/line_parser.rb', line 19

def has_next?
  @lineno < @lines.size
end

#next_lineObject



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

def next_line
  line = move_next
  if is_multiline?(line)
    next_multiline(line)
  else
    line
  end
end