Class: Puppet::Pops::Model::ReservedWord

Inherits:
LiteralValue 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

#_pcore_all_contents, #_pcore_contents, #to_s

Methods included from Types::PuppetObject

#_pcore_all_contents, #_pcore_contents, #_pcore_type, #to_s

Constructor Details

#initialize(locator, offset, length, word, future = nil) ⇒ ReservedWord

Returns a new instance of ReservedWord


3836
3837
3838
3839
3840
3841
# File 'lib/puppet/pops/model/ast.rb', line 3836

def initialize(locator, offset, length, word, future = nil)
  super(locator, offset, length)
  @hash = @hash ^ word.hash ^ future.hash
  @word = word
  @future = future
end

Instance Attribute Details

#futureObject (readonly)


3834
3835
3836
# File 'lib/puppet/pops/model/ast.rb', line 3834

def future
  @future
end

#wordObject (readonly)


3833
3834
3835
# File 'lib/puppet/pops/model/ast.rb', line 3833

def word
  @word
end

Class Method Details

._pcore_typeObject


3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
# File 'lib/puppet/pops/model/ast.rb', line 3796

def self._pcore_type
  @_pcore_type ||= Types::PObjectType.new('Puppet::AST::ReservedWord', {
    'parent' => LiteralValue._pcore_type,
    'attributes' => {
      'word' => Types::PStringType::DEFAULT,
      'future' => {
        'type' => Types::POptionalType.new(Types::PBooleanType::DEFAULT),
        'value' => nil
      }
    }
  })
end

.create(locator, offset, length, word, future = nil) ⇒ Object


3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
# File 'lib/puppet/pops/model/ast.rb', line 3822

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

.from_asserted_hash(init_hash) ⇒ Object


3813
3814
3815
3816
3817
3818
3819
3820
# File 'lib/puppet/pops/model/ast.rb', line 3813

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

.from_hash(init_hash) ⇒ Object


3809
3810
3811
# File 'lib/puppet/pops/model/ast.rb', line 3809

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

Instance Method Details

#_pcore_init_hashObject


3843
3844
3845
3846
3847
3848
# File 'lib/puppet/pops/model/ast.rb', line 3843

def _pcore_init_hash
  result = super
  result['word'] = @word
  result['future'] = @future unless @future == nil
  result
end

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


3850
3851
3852
3853
3854
# File 'lib/puppet/pops/model/ast.rb', line 3850

def eql?(o)
  super &&
  @word.eql?(o.word) &&
  @future.eql?(o.future)
end