Class: Puppet::Pops::Model::LiteralString

Inherits:
LiteralValue show all
Defined in:
lib/puppet/pops/model/ast.rb

Direct Known Subclasses

RenderStringExpression

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, value) ⇒ LiteralString

Returns a new instance of LiteralString.



3318
3319
3320
3321
3322
# File 'lib/puppet/pops/model/ast.rb', line 3318

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

Instance Attribute Details

#valueObject (readonly)



3316
3317
3318
# File 'lib/puppet/pops/model/ast.rb', line 3316

def value
  @value
end

Class Method Details

._pcore_typeObject



3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
# File 'lib/puppet/pops/model/ast.rb', line 3283

def self._pcore_type
  @_pcore_type ||=
    Types::PObjectType
      .new('Puppet::AST::LiteralString', {
             'parent' => LiteralValue._pcore_type,
             'attributes' => {
               'value' => Types::PStringType::DEFAULT
             }
           })
end

.create(locator, offset, length, value) ⇒ Object



3306
3307
3308
3309
3310
3311
3312
3313
3314
# File 'lib/puppet/pops/model/ast.rb', line 3306

def self.create(locator, offset, length, value)
  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::LiteralString[value]', attrs['value'].type, value)
  new(locator, offset, length, value)
end

.from_asserted_hash(init_hash) ⇒ Object



3298
3299
3300
3301
3302
3303
3304
# File 'lib/puppet/pops/model/ast.rb', line 3298

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

.from_hash(init_hash) ⇒ Object



3294
3295
3296
# File 'lib/puppet/pops/model/ast.rb', line 3294

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

Instance Method Details

#_pcore_init_hashObject



3324
3325
3326
3327
3328
# File 'lib/puppet/pops/model/ast.rb', line 3324

def _pcore_init_hash
  result = super
  result['value'] = @value
  result
end

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

Returns:

  • (Boolean)


3330
3331
3332
3333
# File 'lib/puppet/pops/model/ast.rb', line 3330

def eql?(o)
  super &&
  @value.eql?(o.value)
end