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.


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

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)


1547
1548
1549
# File 'lib/puppet/pops/model/ast.rb', line 1547

def attribute_name
  @attribute_name
end

#operatorObject (readonly)


1548
1549
1550
# File 'lib/puppet/pops/model/ast.rb', line 1548

def operator
  @operator
end

#value_exprObject (readonly)


1549
1550
1551
# File 'lib/puppet/pops/model/ast.rb', line 1549

def value_expr
  @value_expr
end

Class Method Details

._pcore_typeObject


1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
# File 'lib/puppet/pops/model/ast.rb', line 1510

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


1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
# File 'lib/puppet/pops/model/ast.rb', line 1535

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


1525
1526
1527
1528
1529
1530
1531
1532
1533
# File 'lib/puppet/pops/model/ast.rb', line 1525

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


1521
1522
1523
# File 'lib/puppet/pops/model/ast.rb', line 1521

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


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

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:


1567
1568
1569
# File 'lib/puppet/pops/model/ast.rb', line 1567

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

#_pcore_init_hashObject


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

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)

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

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