Class: Puppet::Parser::AST::Relationship
- Inherits:
-
Branch
- Object
- Puppet::Parser::AST
- Branch
- Puppet::Parser::AST::Relationship
- Defined in:
- lib/vendor/puppet/parser/ast/relationship.rb
Constant Summary collapse
- RELATIONSHIP_TYPES =
%w{-> <- ~> <~}
Constants inherited from Puppet::Parser::AST
Constants included from Util::Docs
Instance Attribute Summary collapse
-
#arrow ⇒ Object
Returns the value of attribute arrow.
-
#left ⇒ Object
Returns the value of attribute left.
-
#right ⇒ Object
Returns the value of attribute right.
-
#type ⇒ Object
Returns the value of attribute type.
Attributes inherited from Branch
Attributes inherited from Puppet::Parser::AST
Attributes included from Util::Docs
Instance Method Summary collapse
-
#evaluate(scope) ⇒ Object
Evaluate our object, but just return a simple array of the type and name.
-
#initialize(left, right, arrow, args = {}) ⇒ Relationship
constructor
A new instance of Relationship.
- #sides2edge(left, right) ⇒ Object
Methods inherited from Branch
Methods inherited from Puppet::Parser::AST
associates_doc, #evaluate_match, #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
#initialize(left, right, arrow, args = {}) ⇒ Relationship
Returns a new instance of Relationship.
22 23 24 25 26 27 28 |
# File 'lib/vendor/puppet/parser/ast/relationship.rb', line 22 def initialize(left, right, arrow, args = {}) super(args) unless RELATIONSHIP_TYPES.include?(arrow) raise ArgumentError, "Invalid relationship type #{arrow.inspect}; valid types are #{RELATIONSHIP_TYPES.collect { |r| r.to_s }.join(", ")}" end @left, @right, @arrow = left, right, arrow end |
Instance Attribute Details
#arrow ⇒ Object
Returns the value of attribute arrow.
8 9 10 |
# File 'lib/vendor/puppet/parser/ast/relationship.rb', line 8 def arrow @arrow end |
#left ⇒ Object
Returns the value of attribute left.
8 9 10 |
# File 'lib/vendor/puppet/parser/ast/relationship.rb', line 8 def left @left end |
#right ⇒ Object
Returns the value of attribute right.
8 9 10 |
# File 'lib/vendor/puppet/parser/ast/relationship.rb', line 8 def right @right end |
#type ⇒ Object
Returns the value of attribute type.
8 9 10 |
# File 'lib/vendor/puppet/parser/ast/relationship.rb', line 8 def type @type end |
Instance Method Details
#evaluate(scope) ⇒ Object
Evaluate our object, but just return a simple array of the type and name.
12 13 14 15 16 17 18 19 20 |
# File 'lib/vendor/puppet/parser/ast/relationship.rb', line 12 def evaluate(scope) real_left = left.safeevaluate(scope) real_right = right.safeevaluate(scope) source, target = sides2edge(real_left, real_right) scope.compiler.add_relationship Puppet::Parser::Relationship.new(source, target, type) real_right end |
#sides2edge(left, right) ⇒ Object
34 35 36 |
# File 'lib/vendor/puppet/parser/ast/relationship.rb', line 34 def sides2edge(left, right) out_edge? ? [left, right] : [right, left] end |