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

Constructor Details

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

Returns a new instance of HeredocExpression.



2667
2668
2669
2670
2671
2672
# File 'lib/puppet/pops/model/ast.rb', line 2667

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)



2664
2665
2666
# File 'lib/puppet/pops/model/ast.rb', line 2664

def syntax
  @syntax
end

#text_exprObject (readonly)



2665
2666
2667
# File 'lib/puppet/pops/model/ast.rb', line 2665

def text_expr
  @text_expr
end

Class Method Details

._pcore_typeObject



2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
# File 'lib/puppet/pops/model/ast.rb', line 2627

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



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

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



2644
2645
2646
2647
2648
2649
2650
2651
# File 'lib/puppet/pops/model/ast.rb', line 2644

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



2640
2641
2642
# File 'lib/puppet/pops/model/ast.rb', line 2640

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



2685
2686
2687
2688
2689
2690
2691
2692
# File 'lib/puppet/pops/model/ast.rb', line 2685

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:



2681
2682
2683
# File 'lib/puppet/pops/model/ast.rb', line 2681

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

#_pcore_init_hashObject



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

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: ==

Returns:

  • (Boolean)


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

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