Class: Zelkova::Node

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#edgesObject (readonly)

Returns the value of attribute edges.



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

def edges
  @edges
end

#graphObject (readonly)

Returns the value of attribute graph.



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

def graph
  @graph
end

#metadataObject (readonly)

Returns the value of attribute metadata.



15
16
17
# File 'lib/zelkova/node.rb', line 15

def 
  @metadata
end

#wordObject (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

#inspectObject



26
27
28
# File 'lib/zelkova/node.rb', line 26

def inspect
  "Word: #{self.word}, Number of Edges: #{self.edges.count}, Metadata: #{self.}"
end