Class: Puppet::Pops::Model::SelectorEntry

Inherits:
Positioned 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, matching_expr, value_expr) ⇒ SelectorEntry

Returns a new instance of SelectorEntry


4589
4590
4591
4592
4593
4594
# File 'lib/puppet/pops/model/ast.rb', line 4589

def initialize(locator, offset, length, matching_expr, value_expr)
  super(locator, offset, length)
  @hash = @hash ^ matching_expr.hash ^ value_expr.hash
  @matching_expr = matching_expr
  @value_expr = value_expr
end

Instance Attribute Details

#matching_exprObject (readonly)


4586
4587
4588
# File 'lib/puppet/pops/model/ast.rb', line 4586

def matching_expr
  @matching_expr
end

#value_exprObject (readonly)


4587
4588
4589
# File 'lib/puppet/pops/model/ast.rb', line 4587

def value_expr
  @value_expr
end

Class Method Details

._pcore_typeObject


4552
4553
4554
4555
4556
4557
4558
4559
4560
# File 'lib/puppet/pops/model/ast.rb', line 4552

def self._pcore_type
  @_pcore_type ||= Types::PObjectType.new('Puppet::AST::SelectorEntry', {
    'parent' => Positioned._pcore_type,
    'attributes' => {
      'matching_expr' => Expression._pcore_type,
      'value_expr' => Expression._pcore_type
    }
  })
end

.create(locator, offset, length, matching_expr, value_expr) ⇒ Object


4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
# File 'lib/puppet/pops/model/ast.rb', line 4575

def self.create(locator, offset, length, matching_expr, value_expr)
  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::SelectorEntry[matching_expr]', attrs['matching_expr'].type, matching_expr)
  ta.assert_instance_of('Puppet::AST::SelectorEntry[value_expr]', attrs['value_expr'].type, value_expr)
  new(locator, offset, length, matching_expr, value_expr)
end

.from_asserted_hash(init_hash) ⇒ Object


4566
4567
4568
4569
4570
4571
4572
4573
# File 'lib/puppet/pops/model/ast.rb', line 4566

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

.from_hash(init_hash) ⇒ Object


4562
4563
4564
# File 'lib/puppet/pops/model/ast.rb', line 4562

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

Instance Method Details

#_pcore_all_contents(path, &block) ⇒ Object


4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
# File 'lib/puppet/pops/model/ast.rb', line 4608

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

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

Yields:


4603
4604
4605
4606
# File 'lib/puppet/pops/model/ast.rb', line 4603

def _pcore_contents
  yield(@matching_expr) unless @matching_expr.nil?
  yield(@value_expr) unless @value_expr.nil?
end

#_pcore_init_hashObject


4596
4597
4598
4599
4600
4601
# File 'lib/puppet/pops/model/ast.rb', line 4596

def _pcore_init_hash
  result = super
  result['matching_expr'] = @matching_expr
  result['value_expr'] = @value_expr
  result
end

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


4621
4622
4623
4624
4625
# File 'lib/puppet/pops/model/ast.rb', line 4621

def eql?(o)
  super &&
  @matching_expr.eql?(o.matching_expr) &&
  @value_expr.eql?(o.value_expr)
end