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.


2485
2486
2487
2488
2489
2490
# File 'lib/puppet/pops/model/ast.rb', line 2485

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)


2482
2483
2484
# File 'lib/puppet/pops/model/ast.rb', line 2482

def syntax
  @syntax
end

#text_exprObject (readonly)


2483
2484
2485
# File 'lib/puppet/pops/model/ast.rb', line 2483

def text_expr
  @text_expr
end

Class Method Details

._pcore_typeObject


2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
# File 'lib/puppet/pops/model/ast.rb', line 2445

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


2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
# File 'lib/puppet/pops/model/ast.rb', line 2471

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


2462
2463
2464
2465
2466
2467
2468
2469
# File 'lib/puppet/pops/model/ast.rb', line 2462

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


2458
2459
2460
# File 'lib/puppet/pops/model/ast.rb', line 2458

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


2503
2504
2505
2506
2507
2508
2509
2510
# File 'lib/puppet/pops/model/ast.rb', line 2503

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:


2499
2500
2501
# File 'lib/puppet/pops/model/ast.rb', line 2499

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

#_pcore_init_hashObject


2492
2493
2494
2495
2496
2497
# File 'lib/puppet/pops/model/ast.rb', line 2492

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)

2512
2513
2514
2515
2516
# File 'lib/puppet/pops/model/ast.rb', line 2512

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