Class: Zelkova::Edge

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/zelkova/edge.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(start_node, end_node, weight) ⇒ Edge

Returns a new instance of Edge.



16
17
18
19
20
# File 'lib/zelkova/edge.rb', line 16

def initialize(start_node, end_node, weight)
  @start_node = T.let(start_node, Zelkova::Node)
  @end_node = T.let(end_node, Zelkova::Node)
  @weight = T.let(weight, Integer)
end

Instance Attribute Details

#end_nodeObject (readonly)

Returns the value of attribute end_node.



11
12
13
# File 'lib/zelkova/edge.rb', line 11

def end_node
  @end_node
end

#start_nodeObject (readonly)

Returns the value of attribute start_node.



9
10
11
# File 'lib/zelkova/edge.rb', line 9

def start_node
  @start_node
end

#weightObject (readonly)

Returns the value of attribute weight.



13
14
15
# File 'lib/zelkova/edge.rb', line 13

def weight
  @weight
end

Instance Method Details

#inspectObject



23
24
25
# File 'lib/zelkova/edge.rb', line 23

def inspect
  "Start Word: #{self.start_node.word}, End Word: #{self.end_node.word}, Weight: #{weight}"
end