Class: Puppet::Parser::AST::CaseOpt
- Inherits:
-
Branch
- Object
- Puppet::Parser::AST
- Branch
- Puppet::Parser::AST::CaseOpt
- Defined in:
- lib/vendor/puppet/parser/ast/caseopt.rb
Overview
Each individual option in a case statement.
Constant Summary
Constants inherited from Puppet::Parser::AST
Constants included from Util::Docs
Instance Attribute Summary collapse
-
#statements ⇒ Object
Returns the value of attribute statements.
-
#value ⇒ Object
Returns the value of attribute value.
Attributes inherited from Branch
Attributes inherited from Puppet::Parser::AST
Attributes included from Util::Docs
Instance Method Summary collapse
-
#default? ⇒ Boolean
Are we the default option?.
-
#each ⇒ Object
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.
- #eachopt ⇒ Object
-
#eachvalue(scope) ⇒ Object
You can specify a list of values; return each in turn.
-
#evaluate(scope) ⇒ Object
Evaluate the actual statements; this only gets called if our option matched.
Methods inherited from Branch
Methods inherited from Puppet::Parser::AST
associates_doc, #evaluate_match, #initialize, #inspect, #parsefail, #parsewrap, #safeevaluate, settor?, #use_docs
Methods included from Util::Docs
#desc, #dochook, #doctable, #markdown_definitionlist, #markdown_header, #nodoc?, #pad, scrub
Methods included from Util::MethodHelper
#requiredopts, #set_options, #symbolize_options
Methods included from Util::Errors
#adderrorcontext, #devfail, #error_context, #exceptwrap, #fail
Constructor Details
This class inherits a constructor from Puppet::Parser::AST::Branch
Instance Attribute Details
#statements ⇒ Object
Returns the value of attribute statements.
6 7 8 |
# File 'lib/vendor/puppet/parser/ast/caseopt.rb', line 6 def statements @statements end |
#value ⇒ Object
Returns the value of attribute value.
6 7 8 |
# File 'lib/vendor/puppet/parser/ast/caseopt.rb', line 6 def value @value end |
Instance Method Details
#default? ⇒ Boolean
Are we the default option?
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/vendor/puppet/parser/ast/caseopt.rb', line 17 def default? # Cache the @default value. return @default if defined?(@default) @value.each { |subval| if subval.is_a?(AST::Default) @default = true break end } @default ||= false @default end |
#each ⇒ Object
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
12 13 14 |
# File 'lib/vendor/puppet/parser/ast/caseopt.rb', line 12 def each [@value,@statements].each { |child| yield child } end |
#eachopt ⇒ Object
40 41 42 43 44 |
# File 'lib/vendor/puppet/parser/ast/caseopt.rb', line 40 def eachopt @value.each { |subval| yield subval } end |
#eachvalue(scope) ⇒ Object
You can specify a list of values; return each in turn.
34 35 36 37 38 |
# File 'lib/vendor/puppet/parser/ast/caseopt.rb', line 34 def eachvalue(scope) @value.each { |subval| yield subval.safeevaluate(scope) } end |
#evaluate(scope) ⇒ Object
Evaluate the actual statements; this only gets called if our option matched.
48 49 50 |
# File 'lib/vendor/puppet/parser/ast/caseopt.rb', line 48 def evaluate(scope) @statements.safeevaluate(scope) end |