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.
319 320 321 322 323 324 325 326 327 328 329 330 331 332 |
# File 'lib/omf_oml/network.rb', line 319 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.
317 318 319 |
# File 'lib/omf_oml/network.rb', line 317 def attributes @attributes end |
#el_id ⇒ Object (readonly)
Returns the value of attribute el_id.
316 317 318 |
# File 'lib/omf_oml/network.rb', line 316 def el_id @el_id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
315 316 317 |
# File 'lib/omf_oml/network.rb', line 315 def name @name end |
Instance Method Details
#[](name) ⇒ Object
334 335 336 |
# File 'lib/omf_oml/network.rb', line 334 def [](name) @attributes[name] end |
#[]=(name, value) ⇒ Object
338 339 340 |
# File 'lib/omf_oml/network.rb', line 338 def []=(name, value) @attributes[name] = _set(value, @attributes[name]) end |
#describe ⇒ Object
Return the current state of the network element as hash
354 355 356 |
# File 'lib/omf_oml/network.rb', line 354 def describe @attributes end |
#link? ⇒ Boolean
362 363 364 |
# File 'lib/omf_oml/network.rb', line 362 def link? false end |
#node? ⇒ Boolean
358 359 360 |
# File 'lib/omf_oml/network.rb', line 358 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.
346 347 348 349 350 |
# File 'lib/omf_oml/network.rb', line 346 def update(attributes) attributes.each do |name, value| self[name] = value end end |