Class: Puppet::Parser::AST::Leaf

Inherits:
Puppet::Parser::AST show all
Defined in:
lib/puppet/parser/ast/leaf.rb

Overview

The base class for all of the leaves of the parse trees. These basically just have types and values. Both of these parameters are simple values, not AST objects.

Direct Known Subclasses

HostName, PopsBridge::Expression, Regex

Constant Summary

Constants inherited from Puppet::Parser::AST

AST

Instance Attribute Summary collapse

Attributes inherited from Puppet::Parser::AST

#file, #line, #parent, #pos, #scope

Instance Method Summary collapse

Methods inherited from Puppet::Parser::AST

#inspect, #safeevaluate

Methods included from Util::Errors

#adderrorcontext, #devfail, #error_context, error_location, error_location_with_space, error_location_with_unknowns, #exceptwrap, #fail

Constructor Details

#initialize(value: nil, file: nil, line: nil, pos: nil) ⇒ Leaf

Returns a new instance of Leaf.



21
22
23
24
# File 'lib/puppet/parser/ast/leaf.rb', line 21

def initialize(value: nil, file: nil, line: nil, pos: nil)
  @value = value
  super(file: file, line: line, pos: pos)
end

Instance Attribute Details

#typeObject

Returns the value of attribute type.



7
8
9
# File 'lib/puppet/parser/ast/leaf.rb', line 7

def type
  @type
end

#valueObject

Returns the value of attribute value.



7
8
9
# File 'lib/puppet/parser/ast/leaf.rb', line 7

def value
  @value
end

Instance Method Details

#evaluate(scope) ⇒ Object

Return our value.



9
10
11
# File 'lib/puppet/parser/ast/leaf.rb', line 9

def evaluate(scope)
  @value
end

#match(value) ⇒ Object



13
14
15
# File 'lib/puppet/parser/ast/leaf.rb', line 13

def match(value)
  @value == value
end

#to_sObject



17
18
19
# File 'lib/puppet/parser/ast/leaf.rb', line 17

def to_s
  @value.to_s unless @value.nil?
end