Class: Rex::Parser::GraphML::Element::Node
- Inherits:
-
AttributeContainer
- Object
- AttributeContainer
- Rex::Parser::GraphML::Element::Node
- Defined in:
- lib/rex/parser/graphml.rb
Overview
A node element defines an object within the graph that can have zero or more edges connecting it to other nodes. A node element may contain a graph element.
Constant Summary collapse
- ELEMENT_NAME =
'node'.freeze
Instance Attribute Summary collapse
-
#edges ⇒ Object
Returns the value of attribute edges.
-
#id ⇒ Object
Returns the value of attribute id.
-
#subgraph ⇒ Graph?
A subgraph contained within this node.
Attributes inherited from AttributeContainer
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(id) ⇒ Node
constructor
A new instance of Node.
-
#source_edges ⇒ Array
An array of all edges for which this node is the target.
-
#target_edges ⇒ Array
An array of all edges for which this node is the source.
Constructor Details
#initialize(id) ⇒ Node
Returns a new instance of Node.
362 363 364 365 366 367 |
# File 'lib/rex/parser/graphml.rb', line 362 def initialize(id) @id = id @edges = [] @subgraph = nil super() end |
Instance Attribute Details
#edges ⇒ Object
Returns the value of attribute edges.
393 394 395 |
# File 'lib/rex/parser/graphml.rb', line 393 def edges @edges end |
#id ⇒ Object
Returns the value of attribute id.
390 391 392 |
# File 'lib/rex/parser/graphml.rb', line 390 def id @id end |
#subgraph ⇒ Graph?
Returns A subgraph contained within this node.
396 397 398 |
# File 'lib/rex/parser/graphml.rb', line 396 def subgraph @subgraph end |
Class Method Details
.from_xml_attributes(xml_attrs) ⇒ Object
369 370 371 372 373 374 |
# File 'lib/rex/parser/graphml.rb', line 369 def self.from_xml_attributes(xml_attrs) id = xml_attrs['id'] raise Error::InvalidAttributeError.new('node', 'id') if id.nil? new(id) end |
Instance Method Details
#source_edges ⇒ Array
Returns An array of all edges for which this node is the target.
377 378 379 380 |
# File 'lib/rex/parser/graphml.rb', line 377 def source_edges # edges connected to this node @edges.select { |edge| edge.target == @id || !edge.directed } end |
#target_edges ⇒ Array
Returns An array of all edges for which this node is the source.
383 384 385 386 |
# File 'lib/rex/parser/graphml.rb', line 383 def target_edges # edges connecting this to other nodes @edges.select { |edge| edge.source == @id || !edge.directed } end |