Class: Puppet::Pops::Model::AttributeOperation

Inherits:
AbstractAttributeOperation 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, attribute_name, operator, value_expr) ⇒ AttributeOperation

Returns a new instance of AttributeOperation.



1583
1584
1585
1586
1587
1588
1589
# File 'lib/puppet/pops/model/ast.rb', line 1583

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

Instance Attribute Details

#attribute_nameObject (readonly)



1579
1580
1581
# File 'lib/puppet/pops/model/ast.rb', line 1579

def attribute_name
  @attribute_name
end

#operatorObject (readonly)



1580
1581
1582
# File 'lib/puppet/pops/model/ast.rb', line 1580

def operator
  @operator
end

#value_exprObject (readonly)



1581
1582
1583
# File 'lib/puppet/pops/model/ast.rb', line 1581

def value_expr
  @value_expr
end

Class Method Details

._pcore_typeObject



1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
# File 'lib/puppet/pops/model/ast.rb', line 1540

def self._pcore_type
  @_pcore_type ||=
    Types::PObjectType
      .new('Puppet::AST::AttributeOperation', {
             'parent' => AbstractAttributeOperation._pcore_type,
             'attributes' => {
               'attribute_name' => Types::PStringType::DEFAULT,
               'operator' => Types::PEnumType.new(['+>', '=>']),
               'value_expr' => Expression._pcore_type
             }
           })
end

.create(locator, offset, length, attribute_name, operator, value_expr) ⇒ Object



1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
# File 'lib/puppet/pops/model/ast.rb', line 1567

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

.from_asserted_hash(init_hash) ⇒ Object



1557
1558
1559
1560
1561
1562
1563
1564
1565
# File 'lib/puppet/pops/model/ast.rb', line 1557

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

.from_hash(init_hash) ⇒ Object



1553
1554
1555
# File 'lib/puppet/pops/model/ast.rb', line 1553

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

Instance Method Details

#_pcore_all_contents(path, &block) ⇒ Object



1603
1604
1605
1606
1607
1608
1609
1610
# File 'lib/puppet/pops/model/ast.rb', line 1603

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

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

Yields:



1599
1600
1601
# File 'lib/puppet/pops/model/ast.rb', line 1599

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

#_pcore_init_hashObject



1591
1592
1593
1594
1595
1596
1597
# File 'lib/puppet/pops/model/ast.rb', line 1591

def _pcore_init_hash
  result = super
  result['attribute_name'] = @attribute_name
  result['operator'] = @operator
  result['value_expr'] = @value_expr
  result
end

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

Returns:

  • (Boolean)


1612
1613
1614
1615
1616
1617
# File 'lib/puppet/pops/model/ast.rb', line 1612

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