Class: Puppet::Pops::Model::LiteralRegularExpression

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

Returns a new instance of LiteralRegularExpression.



3260
3261
3262
3263
3264
3265
# File 'lib/puppet/pops/model/ast.rb', line 3260

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

Instance Attribute Details

#patternObject (readonly)



3258
3259
3260
# File 'lib/puppet/pops/model/ast.rb', line 3258

def pattern
  @pattern
end

#valueObject (readonly)



3257
3258
3259
# File 'lib/puppet/pops/model/ast.rb', line 3257

def value
  @value
end

Class Method Details

._pcore_typeObject



3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
# File 'lib/puppet/pops/model/ast.rb', line 3221

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

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



3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
# File 'lib/puppet/pops/model/ast.rb', line 3246

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

.from_asserted_hash(init_hash) ⇒ Object



3237
3238
3239
3240
3241
3242
3243
3244
# File 'lib/puppet/pops/model/ast.rb', line 3237

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

.from_hash(init_hash) ⇒ Object



3233
3234
3235
# File 'lib/puppet/pops/model/ast.rb', line 3233

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

Instance Method Details

#_pcore_init_hashObject



3267
3268
3269
3270
3271
3272
# File 'lib/puppet/pops/model/ast.rb', line 3267

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

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

Returns:

  • (Boolean)


3274
3275
3276
3277
3278
# File 'lib/puppet/pops/model/ast.rb', line 3274

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