Class: RubyAi::Search::Edge
- Inherits:
-
Object
- Object
- RubyAi::Search::Edge
- Defined in:
- lib/ruby_ai/search/edge.rb
Instance Attribute Summary collapse
-
#cost ⇒ Object
readonly
Returns the value of attribute cost.
-
#end_vertex ⇒ Object
readonly
Returns the value of attribute end_vertex.
-
#start_vertex ⇒ Object
readonly
Returns the value of attribute start_vertex.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(start_vertex:, end_vertex:, cost:) ⇒ Edge
constructor
A new instance of Edge.
- #to_s ⇒ Object
Constructor Details
#initialize(start_vertex:, end_vertex:, cost:) ⇒ Edge
Returns a new instance of Edge.
6 7 8 9 10 |
# File 'lib/ruby_ai/search/edge.rb', line 6 def initialize(start_vertex:, end_vertex:, cost:) @start_vertex = start_vertex @end_vertex = end_vertex @cost = cost end |
Instance Attribute Details
#cost ⇒ Object (readonly)
Returns the value of attribute cost.
4 5 6 |
# File 'lib/ruby_ai/search/edge.rb', line 4 def cost @cost end |
#end_vertex ⇒ Object (readonly)
Returns the value of attribute end_vertex.
4 5 6 |
# File 'lib/ruby_ai/search/edge.rb', line 4 def end_vertex @end_vertex end |
#start_vertex ⇒ Object (readonly)
Returns the value of attribute start_vertex.
4 5 6 |
# File 'lib/ruby_ai/search/edge.rb', line 4 def start_vertex @start_vertex end |
Instance Method Details
#==(other) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/ruby_ai/search/edge.rb', line 12 def ==(other) self.class == other.class && @start_vertex == other.start_vertex && @end_vertex == other.end_vertex && @cost == other.cost end |
#to_s ⇒ Object
19 20 21 |
# File 'lib/ruby_ai/search/edge.rb', line 19 def to_s "edge: #{@start_vertex} (#{@cost}) #{@end_vertex}" end |