| Class | Puppet::Parser::AST::CaseOpt |
| In: |
lib/puppet/parser/ast/caseopt.rb
|
| Parent: | AST::Branch |
| statements | [RW] | |
| value | [RW] |
Are we the default option?
# File lib/puppet/parser/ast/caseopt.rb, line 17
17: def default?
18: # Cache the @default value.
19: if defined? @default
20: return @default
21: end
22:
23: if @value.is_a?(AST::ASTArray)
24: @value.each { |subval|
25: if subval.is_a?(AST::Default)
26: @default = true
27: break
28: end
29: }
30: else
31: if @value.is_a?(AST::Default)
32: @default = true
33: end
34: end
35:
36: unless defined? @default
37: @default = false
38: end
39:
40: return @default
41: end
CaseOpt is a bit special — we just want the value first, so that CaseStatement can compare, and then it will selectively decide whether to fully evaluate this option
# File lib/puppet/parser/ast/caseopt.rb, line 12
12: def each
13: [@value,@statements].each { |child| yield child }
14: end
You can specify a list of values; return each in turn.
# File lib/puppet/parser/ast/caseopt.rb, line 44
44: def eachvalue(scope)
45: if @value.is_a?(AST::ASTArray)
46: @value.each { |subval|
47: yield subval.safeevaluate(scope)
48: }
49: else
50: yield @value.safeevaluate(scope)
51: end
52: end