Class: Puppet::Pops::Evaluator::LiteralEvaluator

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet/pops/evaluator/literal_evaluator.rb

Overview

QualifiedReference # i.e. File, FooBar

Direct Known Subclasses

Validation::Checker4_0

Constant Summary collapse

COMMA_SEPARATOR =
', '

Instance Method Summary collapse

Constructor Details

#initializeLiteralEvaluator

Returns a new instance of LiteralEvaluator.



22
23
24
# File 'lib/puppet/pops/evaluator/literal_evaluator.rb', line 22

def initialize
  @@literal_visitor ||= Visitor.new(self, "literal", 0, 0)
end

Instance Method Details

#literal(ast) ⇒ Object



26
27
28
# File 'lib/puppet/pops/evaluator/literal_evaluator.rb', line 26

def literal(ast)
  @@literal_visitor.visit_this_0(self, ast)
end

#literal_ConcatenatedString(o) ⇒ Object



70
71
72
73
74
# File 'lib/puppet/pops/evaluator/literal_evaluator.rb', line 70

def literal_ConcatenatedString(o)
  # use double quoted string value if there is no interpolation
  throw :not_literal unless o.segments.size == 1 && o.segments[0].is_a?(Model::LiteralString)
  o.segments[0].value
end

#literal_Factory(o) ⇒ Object



34
35
36
# File 'lib/puppet/pops/evaluator/literal_evaluator.rb', line 34

def literal_Factory(o)
  literal(o.model)
end

#literal_LiteralBoolean(o) ⇒ Object



54
55
56
# File 'lib/puppet/pops/evaluator/literal_evaluator.rb', line 54

def literal_LiteralBoolean(o)
  o.value
end

#literal_LiteralDefault(o) ⇒ Object



62
63
64
# File 'lib/puppet/pops/evaluator/literal_evaluator.rb', line 62

def literal_LiteralDefault(o)
  :default
end

#literal_LiteralHash(o) ⇒ Object



80
81
82
83
84
85
# File 'lib/puppet/pops/evaluator/literal_evaluator.rb', line 80

def literal_LiteralHash(o)
  o.entries.reduce({}) do |result, entry|
    result[literal(entry.key)] = literal(entry.value)
    result
  end
end

#literal_LiteralList(o) ⇒ Object



76
77
78
# File 'lib/puppet/pops/evaluator/literal_evaluator.rb', line 76

def literal_LiteralList(o)
  o.values.map {|v| literal(v) }
end

#literal_LiteralNumber(o) ⇒ Object



50
51
52
# File 'lib/puppet/pops/evaluator/literal_evaluator.rb', line 50

def literal_LiteralNumber(o)
  o.value
end

#literal_LiteralRegularExpression(o) ⇒ Object



66
67
68
# File 'lib/puppet/pops/evaluator/literal_evaluator.rb', line 66

def literal_LiteralRegularExpression(o)
  o.value
end

#literal_LiteralString(o) ⇒ Object



42
43
44
# File 'lib/puppet/pops/evaluator/literal_evaluator.rb', line 42

def literal_LiteralString(o)
  o.value
end

#literal_LiteralUndef(o) ⇒ Object



58
59
60
# File 'lib/puppet/pops/evaluator/literal_evaluator.rb', line 58

def literal_LiteralUndef(o)
  nil
end

#literal_Object(o) ⇒ Object



30
31
32
# File 'lib/puppet/pops/evaluator/literal_evaluator.rb', line 30

def literal_Object(o)
  throw :not_literal
end

#literal_Program(o) ⇒ Object



38
39
40
# File 'lib/puppet/pops/evaluator/literal_evaluator.rb', line 38

def literal_Program(o)
  literal(o.body)
end

#literal_QualifiedName(o) ⇒ Object



46
47
48
# File 'lib/puppet/pops/evaluator/literal_evaluator.rb', line 46

def literal_QualifiedName(o)
  o.value
end