Class: Puppet::Parser::Lexer::Token

Inherits:
Object
  • Object
show all
Defined in:
lib/vendor/puppet/parser/lexer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(regex, name) ⇒ Token

Returns a new instance of Token.



25
26
27
28
29
30
31
32
# File 'lib/vendor/puppet/parser/lexer.rb', line 25

def initialize(regex, name)
  if regex.is_a?(String)
    @name, @string = name, regex
    @regex = Regexp.new(Regexp.escape(@string))
  else
    @name, @regex = name, regex
  end
end

Instance Attribute Details

#accumulateObject

Returns the value of attribute accumulate.



23
24
25
# File 'lib/vendor/puppet/parser/lexer.rb', line 23

def accumulate
  @accumulate
end

#incr_lineObject

Returns the value of attribute incr_line.



23
24
25
# File 'lib/vendor/puppet/parser/lexer.rb', line 23

def incr_line
  @incr_line
end

#nameObject

Returns the value of attribute name.



23
24
25
# File 'lib/vendor/puppet/parser/lexer.rb', line 23

def name
  @name
end

#regexObject

Returns the value of attribute regex.



23
24
25
# File 'lib/vendor/puppet/parser/lexer.rb', line 23

def regex
  @regex
end

#skipObject

Returns the value of attribute skip.



23
24
25
# File 'lib/vendor/puppet/parser/lexer.rb', line 23

def skip
  @skip
end

#skip_textObject

Returns the value of attribute skip_text.



23
24
25
# File 'lib/vendor/puppet/parser/lexer.rb', line 23

def skip_text
  @skip_text
end

#stringObject

Returns the value of attribute string.



23
24
25
# File 'lib/vendor/puppet/parser/lexer.rb', line 23

def string
  @string
end

Instance Method Details

#acceptable?(context = {}) ⇒ Boolean

Returns:

  • (Boolean)


49
50
51
52
# File 'lib/vendor/puppet/parser/lexer.rb', line 49

def acceptable?(context={})
  # By default tokens are aceeptable in any context
  true
end

#to_sObject



41
42
43
44
45
46
47
# File 'lib/vendor/puppet/parser/lexer.rb', line 41

def to_s
  if self.string
    @string
  else
    @name.to_s
  end
end