Class: OMF::OML::NetworkElement
- Inherits:
-
Base::LObject
- Object
- Base::LObject
- OMF::OML::NetworkElement
- Defined in:
- lib/omf_oml/network.rb
Overview
This class represents an abstract network element and shouldn’t be used directly.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#el_id ⇒ Object
readonly
Returns the value of attribute el_id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #[](name) ⇒ Object
- #[]=(name, value) ⇒ Object
-
#describe ⇒ Object
Return the current state of the network element as hash.
-
#initialize(name, attributes, network) ⇒ NetworkElement
constructor
A new instance of NetworkElement.
- #link? ⇒ Boolean
- #node? ⇒ Boolean
-
#update(attributes) ⇒ Object
Update the element’s attributes.
Constructor Details
#initialize(name, attributes, network) ⇒ NetworkElement
Returns a new instance of NetworkElement.
325 326 327 328 329 330 331 332 333 334 335 336 337 338 |
# File 'lib/omf_oml/network.rb', line 325 def initialize(name, attributes, network) super name @attributes = attributes.dup if @name = name @attributes[:name] = name end if attributes.key?(:id) || attributes.key?(:name) raise NetworkElementAttributeException.new("Attributes 'id' and 'name' are reserved attributes") end @el_id = @attributes[:id] = "e#{self.object_id}" @attributes[:name] = name || @el_id @network = network end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
323 324 325 |
# File 'lib/omf_oml/network.rb', line 323 def attributes @attributes end |
#el_id ⇒ Object (readonly)
Returns the value of attribute el_id.
322 323 324 |
# File 'lib/omf_oml/network.rb', line 322 def el_id @el_id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
321 322 323 |
# File 'lib/omf_oml/network.rb', line 321 def name @name end |
Instance Method Details
#[](name) ⇒ Object
340 341 342 |
# File 'lib/omf_oml/network.rb', line 340 def [](name) @attributes[name] end |
#[]=(name, value) ⇒ Object
344 345 346 |
# File 'lib/omf_oml/network.rb', line 344 def []=(name, value) @attributes[name] = _set(value, @attributes[name]) end |
#describe ⇒ Object
Return the current state of the network element as hash
360 361 362 |
# File 'lib/omf_oml/network.rb', line 360 def describe @attributes end |
#link? ⇒ Boolean
368 369 370 |
# File 'lib/omf_oml/network.rb', line 368 def link? false end |
#node? ⇒ Boolean
364 365 366 |
# File 'lib/omf_oml/network.rb', line 364 def node? false end |
#update(attributes) ⇒ Object
Update the element’s attributes. The attributes
argument is expected to be a hash with the key identifying the attribute name and the value being the new value to set that attribute to.
352 353 354 355 356 |
# File 'lib/omf_oml/network.rb', line 352 def update(attributes) attributes.each do |name, value| self[name] = value end end |