Class: Puppet::Pops::Model::UnaryExpression
- Inherits:
-
Expression
- Object
- PopsObject
- Positioned
- Expression
- Puppet::Pops::Model::UnaryExpression
- Defined in:
- lib/puppet/pops/model/ast.rb
Direct Known Subclasses
NotExpression, ParenthesizedExpression, RenderExpression, TextExpression, UnaryMinusExpression, UnfoldExpression, VariableExpression
Instance Attribute Summary collapse
- #expr ⇒ Object readonly
Attributes inherited from Positioned
Attributes inherited from PopsObject
Class Method Summary collapse
- ._pcore_type ⇒ Object
- .create(locator, offset, length, expr) ⇒ Object
- .from_asserted_hash(init_hash) ⇒ Object
- .from_hash(init_hash) ⇒ Object
Instance Method Summary collapse
- #_pcore_all_contents(path, &block) ⇒ Object
- #_pcore_contents {|@expr| ... } ⇒ Object
- #_pcore_init_hash ⇒ Object
- #eql?(o) ⇒ Boolean (also: #==)
-
#initialize(locator, offset, length, expr) ⇒ UnaryExpression
constructor
A new instance of UnaryExpression.
Methods inherited from Positioned
Methods inherited from PopsObject
Methods included from Types::PuppetObject
Constructor Details
#initialize(locator, offset, length, expr) ⇒ UnaryExpression
Returns a new instance of UnaryExpression.
259 260 261 262 263 |
# File 'lib/puppet/pops/model/ast.rb', line 259 def initialize(locator, offset, length, expr) super(locator, offset, length) @hash = @hash ^ expr.hash @expr = expr end |
Instance Attribute Details
#expr ⇒ Object (readonly)
257 258 259 |
# File 'lib/puppet/pops/model/ast.rb', line 257 def expr @expr end |
Class Method Details
._pcore_type ⇒ Object
226 227 228 229 230 231 232 233 |
# File 'lib/puppet/pops/model/ast.rb', line 226 def self._pcore_type @_pcore_type ||= Types::PObjectType.new('Puppet::AST::UnaryExpression', { 'parent' => Expression._pcore_type, 'attributes' => { 'expr' => Expression._pcore_type } }) end |
.create(locator, offset, length, expr) ⇒ Object
247 248 249 250 251 252 253 254 255 |
# File 'lib/puppet/pops/model/ast.rb', line 247 def self.create(locator, offset, length, 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::UnaryExpression[expr]', attrs['expr'].type, expr) new(locator, offset, length, expr) end |
.from_asserted_hash(init_hash) ⇒ Object
239 240 241 242 243 244 245 |
# File 'lib/puppet/pops/model/ast.rb', line 239 def self.from_asserted_hash(init_hash) new( init_hash['locator'], init_hash['offset'], init_hash['length'], init_hash['expr']) end |
.from_hash(init_hash) ⇒ Object
235 236 237 |
# File 'lib/puppet/pops/model/ast.rb', line 235 def self.from_hash(init_hash) from_asserted_hash(Types::TypeAsserter.assert_instance_of('Puppet::AST::UnaryExpression initializer', _pcore_type.init_hash_type, init_hash)) end |
Instance Method Details
#_pcore_all_contents(path, &block) ⇒ Object
275 276 277 278 279 280 281 282 |
# File 'lib/puppet/pops/model/ast.rb', line 275 def _pcore_all_contents(path, &block) path << self unless @expr.nil? block.call(@expr, path) @expr._pcore_all_contents(path, &block) end path.pop end |
#_pcore_contents {|@expr| ... } ⇒ Object
271 272 273 |
# File 'lib/puppet/pops/model/ast.rb', line 271 def _pcore_contents yield(@expr) unless @expr.nil? end |
#_pcore_init_hash ⇒ Object
265 266 267 268 269 |
# File 'lib/puppet/pops/model/ast.rb', line 265 def _pcore_init_hash result = super result['expr'] = @expr result end |
#eql?(o) ⇒ Boolean Also known as: ==
284 285 286 287 |
# File 'lib/puppet/pops/model/ast.rb', line 284 def eql?(o) super && @expr.eql?(o.expr) end |