Class: Puppet::Pops::Model::HeredocExpression

Inherits:
Expression show all
Defined in:
lib/puppet/pops/model/ast.rb

Instance Attribute Summary collapse

Attributes inherited from Positioned

#length, #locator, #offset

Attributes inherited from PopsObject

#hash

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Positioned

#file, #line, #pos

Methods inherited from PopsObject

#to_s

Methods included from Types::PuppetObject

#_pcore_type, #to_s

Constructor Details

#initialize(locator, offset, length, text_expr, syntax = nil) ⇒ HeredocExpression

Returns a new instance of HeredocExpression


2675
2676
2677
2678
2679
2680
# File 'lib/puppet/pops/model/ast.rb', line 2675

def initialize(locator, offset, length, text_expr, syntax = nil)
  super(locator, offset, length)
  @hash = @hash ^ syntax.hash ^ text_expr.hash
  @syntax = syntax
  @text_expr = text_expr
end

Instance Attribute Details

#syntaxObject (readonly)


2672
2673
2674
# File 'lib/puppet/pops/model/ast.rb', line 2672

def syntax
  @syntax
end

#text_exprObject (readonly)


2673
2674
2675
# File 'lib/puppet/pops/model/ast.rb', line 2673

def text_expr
  @text_expr
end

Class Method Details

._pcore_typeObject


2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
# File 'lib/puppet/pops/model/ast.rb', line 2635

def self._pcore_type
  @_pcore_type ||= Types::PObjectType.new('Puppet::AST::HeredocExpression', {
    'parent' => Expression._pcore_type,
    'attributes' => {
      'syntax' => {
        'type' => Types::POptionalType.new(Types::PStringType::DEFAULT),
        'value' => nil
      },
      'text_expr' => Expression._pcore_type
    }
  })
end

.create(locator, offset, length, text_expr, syntax = nil) ⇒ Object


2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
# File 'lib/puppet/pops/model/ast.rb', line 2661

def self.create(locator, offset, length, text_expr, syntax = nil)
  ta = Types::TypeAsserter
  attrs = _pcore_type.attributes(true)
  ta.assert_instance_of('Puppet::AST::Positioned[locator]', attrs['locator'].type, locator)
  ta.assert_instance_of('Puppet::AST::Positioned[offset]', attrs['offset'].type, offset)
  ta.assert_instance_of('Puppet::AST::Positioned[length]', attrs['length'].type, length)
  ta.assert_instance_of('Puppet::AST::HeredocExpression[syntax]', attrs['syntax'].type, syntax)
  ta.assert_instance_of('Puppet::AST::HeredocExpression[text_expr]', attrs['text_expr'].type, text_expr)
  new(locator, offset, length, text_expr, syntax)
end

.from_asserted_hash(init_hash) ⇒ Object


2652
2653
2654
2655
2656
2657
2658
2659
# File 'lib/puppet/pops/model/ast.rb', line 2652

def self.from_asserted_hash(init_hash)
  new(
    init_hash['locator'],
    init_hash['offset'],
    init_hash['length'],
    init_hash['text_expr'],
    init_hash['syntax'])
end

.from_hash(init_hash) ⇒ Object


2648
2649
2650
# File 'lib/puppet/pops/model/ast.rb', line 2648

def self.from_hash(init_hash)
  from_asserted_hash(Types::TypeAsserter.assert_instance_of('Puppet::AST::HeredocExpression initializer', _pcore_type.init_hash_type, init_hash))
end

Instance Method Details

#_pcore_all_contents(path, &block) ⇒ Object


2693
2694
2695
2696
2697
2698
2699
2700
# File 'lib/puppet/pops/model/ast.rb', line 2693

def _pcore_all_contents(path, &block)
  path << self
  unless @text_expr.nil?
    block.call(@text_expr, path)
    @text_expr._pcore_all_contents(path, &block)
  end
  path.pop
end

#_pcore_contents {|@text_expr| ... } ⇒ Object

Yields:


2689
2690
2691
# File 'lib/puppet/pops/model/ast.rb', line 2689

def _pcore_contents
  yield(@text_expr) unless @text_expr.nil?
end

#_pcore_init_hashObject


2682
2683
2684
2685
2686
2687
# File 'lib/puppet/pops/model/ast.rb', line 2682

def _pcore_init_hash
  result = super
  result['syntax'] = @syntax unless @syntax == nil
  result['text_expr'] = @text_expr
  result
end

#eql?(o) ⇒ Boolean Also known as: ==


2702
2703
2704
2705
2706
# File 'lib/puppet/pops/model/ast.rb', line 2702

def eql?(o)
  super &&
  @syntax.eql?(o.syntax) &&
  @text_expr.eql?(o.text_expr)
end