Class: Zelkova::Node
Instance Attribute Summary collapse
-
#edges ⇒ Object
readonly
Returns the value of attribute edges.
-
#graph ⇒ Object
readonly
Returns the value of attribute graph.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#word ⇒ Object
readonly
Returns the value of attribute word.
Instance Method Summary collapse
- #add_edge(node, weight) ⇒ Object
-
#initialize(word, graph, metadata = {}) ⇒ Node
constructor
A new instance of Node.
- #inspect ⇒ Object
Constructor Details
#initialize(word, graph, metadata = {}) ⇒ Node
Returns a new instance of Node.
18 19 20 21 22 23 |
# File 'lib/zelkova/node.rb', line 18 def initialize(word, graph, = {}) @word = T.let(word, String) @graph = T.let(graph, Zelkova::Graph) @edges = T.let([], T::Array[Zelkova::Edge]) @metadata = T.let(T.must(), T::Hash[T.untyped, T.untyped]) end |
Instance Attribute Details
#edges ⇒ Object (readonly)
Returns the value of attribute edges.
11 12 13 |
# File 'lib/zelkova/node.rb', line 11 def edges @edges end |
#graph ⇒ Object (readonly)
Returns the value of attribute graph.
13 14 15 |
# File 'lib/zelkova/node.rb', line 13 def graph @graph end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
15 16 17 |
# File 'lib/zelkova/node.rb', line 15 def @metadata end |
#word ⇒ Object (readonly)
Returns the value of attribute word.
9 10 11 |
# File 'lib/zelkova/node.rb', line 9 def word @word end |
Instance Method Details
#add_edge(node, weight) ⇒ Object
31 32 33 |
# File 'lib/zelkova/node.rb', line 31 def add_edge(node, weight) @edges << Zelkova::Edge.new(self, node, weight) end |
#inspect ⇒ Object
26 27 28 |
# File 'lib/zelkova/node.rb', line 26 def inspect "Word: #{self.word}, Number of Edges: #{self.edges.count}, Metadata: #{self.}" end |