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

Constructor Details

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

Returns a new instance of ReservedWord.



3713
3714
3715
3716
3717
3718
# File 'lib/puppet/pops/model/ast.rb', line 3713

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)



3711
3712
3713
# File 'lib/puppet/pops/model/ast.rb', line 3711

def future
  @future
end

#wordObject (readonly)



3710
3711
3712
# File 'lib/puppet/pops/model/ast.rb', line 3710

def word
  @word
end

Class Method Details

._pcore_typeObject



3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
# File 'lib/puppet/pops/model/ast.rb', line 3673

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



3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
# File 'lib/puppet/pops/model/ast.rb', line 3699

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



3690
3691
3692
3693
3694
3695
3696
3697
# File 'lib/puppet/pops/model/ast.rb', line 3690

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



3686
3687
3688
# File 'lib/puppet/pops/model/ast.rb', line 3686

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



3720
3721
3722
3723
3724
3725
# File 'lib/puppet/pops/model/ast.rb', line 3720

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

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

Returns:

  • (Boolean)


3727
3728
3729
3730
3731
# File 'lib/puppet/pops/model/ast.rb', line 3727

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