Class: RubyGraphWalker::Edge
- Inherits:
-
Object
- Object
- RubyGraphWalker::Edge
- Defined in:
- lib/graph.rb
Instance Attribute Summary collapse
-
#error_count ⇒ Object
Returns the value of attribute error_count.
-
#from ⇒ Object
Returns the value of attribute from.
-
#name ⇒ Object
Returns the value of attribute name.
-
#proc ⇒ Object
Returns the value of attribute proc.
-
#to ⇒ Object
Returns the value of attribute to.
-
#visited ⇒ Object
Returns the value of attribute visited.
-
#weight ⇒ Object
Returns the value of attribute weight.
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ Edge
constructor
A new instance of Edge.
- #run ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ Edge
Returns a new instance of Edge.
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/graph.rb', line 32 def initialize(args = {}) [:name, :to, :proc].each { |key| raise "#{key} is not defined for Edge #{args}" unless args[key] } @name = args[:name] @from = args[:from] @to = args[:to] @weight = args[:weight] || 1 @visited = args[:visited] || false @proc = args[:proc] @error_count = 0 end |
Instance Attribute Details
#error_count ⇒ Object
Returns the value of attribute error_count.
31 32 33 |
# File 'lib/graph.rb', line 31 def error_count @error_count end |
#from ⇒ Object
Returns the value of attribute from.
31 32 33 |
# File 'lib/graph.rb', line 31 def from @from end |
#name ⇒ Object
Returns the value of attribute name.
31 32 33 |
# File 'lib/graph.rb', line 31 def name @name end |
#proc ⇒ Object
Returns the value of attribute proc.
31 32 33 |
# File 'lib/graph.rb', line 31 def proc @proc end |
#to ⇒ Object
Returns the value of attribute to.
31 32 33 |
# File 'lib/graph.rb', line 31 def to @to end |
#visited ⇒ Object
Returns the value of attribute visited.
31 32 33 |
# File 'lib/graph.rb', line 31 def visited @visited end |
#weight ⇒ Object
Returns the value of attribute weight.
31 32 33 |
# File 'lib/graph.rb', line 31 def weight @weight end |
Instance Method Details
#run ⇒ Object
43 44 45 46 |
# File 'lib/graph.rb', line 43 def run @proc.call @visited = true end |