Class: PetriNet::ReachabilityGraph::Node
- Defined in:
- lib/petri_net/node.rb
Instance Attribute Summary collapse
-
#graph ⇒ Object
The graph this node belongs to.
-
#id ⇒ Object
readonly
unique ID.
-
#markings ⇒ Object
readonly
Makking this node represents.
-
#name ⇒ Object
readonly
human readable name.
Attributes inherited from Base
Instance Method Summary collapse
- #==(object) ⇒ Object
- #gv_id ⇒ Object
-
#initialize(options = {}) {|_self| ... } ⇒ Node
constructor
A new instance of Node.
- #to_gv ⇒ Object
- #to_s ⇒ Object
- #validate ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(options = {}) {|_self| ... } ⇒ Node
Returns a new instance of Node.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/petri_net/node.rb', line 11 def initialize( = {}, &block) @id = next_object_id @name = ([:name] or "Node#{@id}") @description = ([:description] or "Node #{@id}") @inputs = Array.new @outputs = Array.new @label = ([:label] or @name) @markings = [:markings] yield self unless block.nil? end |
Instance Attribute Details
#graph ⇒ Object
The graph this node belongs to
9 10 11 |
# File 'lib/petri_net/node.rb', line 9 def graph @graph end |
#id ⇒ Object (readonly)
unique ID
5 6 7 |
# File 'lib/petri_net/node.rb', line 5 def id @id end |
#markings ⇒ Object (readonly)
Makking this node represents
7 8 9 |
# File 'lib/petri_net/node.rb', line 7 def markings @markings end |
#name ⇒ Object (readonly)
human readable name
3 4 5 |
# File 'lib/petri_net/node.rb', line 3 def name @name end |
Instance Method Details
#==(object) ⇒ Object
35 36 37 38 |
# File 'lib/petri_net/node.rb', line 35 def ==(object) return false unless object.class.to_s == "PetriNet::ReachabilityGraph::Node" @markings == object.markings end |
#gv_id ⇒ Object
27 28 29 |
# File 'lib/petri_net/node.rb', line 27 def gv_id "N#{@id}" end |
#to_gv ⇒ Object
31 32 33 |
# File 'lib/petri_net/node.rb', line 31 def to_gv "\t#{self.gv_id} [ label = \"#{@markings}\" ];\n" end |
#to_s ⇒ Object
40 41 42 |
# File 'lib/petri_net/node.rb', line 40 def to_s "#{@id}: #{@name} (#{@markings})" end |
#validate ⇒ Object
23 24 25 |
# File 'lib/petri_net/node.rb', line 23 def validate true end |