Class: Haml2Erb::HamlLexer

Inherits:
Object
  • Object
show all
Defined in:
lib/haml2erb/lexer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#inputObject (readonly)

Returns the value of attribute input.



6
7
8
# File 'lib/haml2erb/lexer.rb', line 6

def input
  @input
end

Instance Method Details

#end_input?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/haml2erb/lexer.rb', line 24

def end_input?
  @input.strip.empty? ? true : false
end

#load_input(text) ⇒ Object



8
9
10
# File 'lib/haml2erb/lexer.rb', line 8

def load_input(text)
  @input = text
end

#peek(klass) ⇒ Object



12
13
14
15
# File 'lib/haml2erb/lexer.rb', line 12

def peek(klass)
  #puts "peek #{klass} #{@input}"
  klass.match(@input)
end

#pop(klass) ⇒ Object



17
18
19
20
21
22
# File 'lib/haml2erb/lexer.rb', line 17

def pop(klass)
  #puts "pop #{klass} #{@input}"
  token = klass.match(@input)
  @input.gsub!(/^#{Regexp.escape(token.matched)}/, '') # removed matched portion from the string
  token
end