Class: Puppet::Pops::Model::SubLocatedExpression

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, expr, line_offsets = _pcore_type['line_offsets'].value, leading_line_count = nil, leading_line_offset = nil) ⇒ SubLocatedExpression

Returns a new instance of SubLocatedExpression.



2585
2586
2587
2588
2589
2590
2591
2592
# File 'lib/puppet/pops/model/ast.rb', line 2585

def initialize(locator, offset, length, expr, line_offsets = _pcore_type['line_offsets'].value, leading_line_count = nil, leading_line_offset = nil)
  super(locator, offset, length)
  @hash = @hash ^ expr.hash ^ line_offsets.hash ^ leading_line_count.hash ^ leading_line_offset.hash
  @expr = expr
  @line_offsets = line_offsets
  @leading_line_count = leading_line_count
  @leading_line_offset = leading_line_offset
end

Instance Attribute Details

#exprObject (readonly)



2580
2581
2582
# File 'lib/puppet/pops/model/ast.rb', line 2580

def expr
  @expr
end

#leading_line_countObject (readonly)



2582
2583
2584
# File 'lib/puppet/pops/model/ast.rb', line 2582

def leading_line_count
  @leading_line_count
end

#leading_line_offsetObject (readonly)



2583
2584
2585
# File 'lib/puppet/pops/model/ast.rb', line 2583

def leading_line_offset
  @leading_line_offset
end

#line_offsetsObject (readonly)



2581
2582
2583
# File 'lib/puppet/pops/model/ast.rb', line 2581

def line_offsets
  @line_offsets
end

Class Method Details

._pcore_typeObject



2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
# File 'lib/puppet/pops/model/ast.rb', line 2531

def self._pcore_type
  @_pcore_type ||= Types::PObjectType.new('Puppet::AST::SubLocatedExpression', {
    'parent' => Expression._pcore_type,
    'attributes' => {
      'expr' => Expression._pcore_type,
      'line_offsets' => {
        'type' => Types::PArrayType.new(Types::PIntegerType::DEFAULT),
        'value' => []
      },
      'leading_line_count' => {
        'type' => Types::POptionalType.new(Types::PIntegerType::DEFAULT),
        'value' => nil
      },
      'leading_line_offset' => {
        'type' => Types::POptionalType.new(Types::PIntegerType::DEFAULT),
        'value' => nil
      }
    }
  })
end

.create(locator, offset, length, expr, line_offsets = _pcore_type['line_offsets'].value, leading_line_count = nil, leading_line_offset = nil) ⇒ Object



2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
# File 'lib/puppet/pops/model/ast.rb', line 2567

def self.create(locator, offset, length, expr, line_offsets = _pcore_type['line_offsets'].value, leading_line_count = nil, leading_line_offset = 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::SubLocatedExpression[expr]', attrs['expr'].type, expr)
  ta.assert_instance_of('Puppet::AST::SubLocatedExpression[line_offsets]', attrs['line_offsets'].type, line_offsets)
  ta.assert_instance_of('Puppet::AST::SubLocatedExpression[leading_line_count]', attrs['leading_line_count'].type, leading_line_count)
  ta.assert_instance_of('Puppet::AST::SubLocatedExpression[leading_line_offset]', attrs['leading_line_offset'].type, leading_line_offset)
  new(locator, offset, length, expr, line_offsets, leading_line_count, leading_line_offset)
end

.from_asserted_hash(init_hash) ⇒ Object



2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
# File 'lib/puppet/pops/model/ast.rb', line 2556

def self.from_asserted_hash(init_hash)
  new(
    init_hash['locator'],
    init_hash['offset'],
    init_hash['length'],
    init_hash['expr'],
    init_hash.fetch('line_offsets') { _pcore_type['line_offsets'].value },
    init_hash['leading_line_count'],
    init_hash['leading_line_offset'])
end

.from_hash(init_hash) ⇒ Object



2552
2553
2554
# File 'lib/puppet/pops/model/ast.rb', line 2552

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

Instance Method Details

#_pcore_all_contents(path, &block) ⇒ Object



2607
2608
2609
2610
2611
2612
2613
2614
# File 'lib/puppet/pops/model/ast.rb', line 2607

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

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

Yields:



2603
2604
2605
# File 'lib/puppet/pops/model/ast.rb', line 2603

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

#_pcore_init_hashObject



2594
2595
2596
2597
2598
2599
2600
2601
# File 'lib/puppet/pops/model/ast.rb', line 2594

def _pcore_init_hash
  result = super
  result['expr'] = @expr
  result['line_offsets'] = @line_offsets unless _pcore_type['line_offsets'].default_value?(@line_offsets)
  result['leading_line_count'] = @leading_line_count unless @leading_line_count == nil
  result['leading_line_offset'] = @leading_line_offset unless @leading_line_offset == nil
  result
end

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

Returns:

  • (Boolean)


2616
2617
2618
2619
2620
2621
2622
# File 'lib/puppet/pops/model/ast.rb', line 2616

def eql?(o)
  super &&
  @expr.eql?(o.expr) &&
  @line_offsets.eql?(o.line_offsets) &&
  @leading_line_count.eql?(o.leading_line_count) &&
  @leading_line_offset.eql?(o.leading_line_offset)
end