Class: RailsGraph::Graph::Node

Inherits:
Entity
  • Object
show all
Defined in:
lib/rails_graph/graph/node.rb

Instance Attribute Summary collapse

Attributes inherited from Entity

#id, #name, #properties

Instance Method Summary collapse

Methods inherited from Entity

#identifier

Constructor Details

#initialize(labels: [], **opts) ⇒ Node

Returns a new instance of Node.



10
11
12
13
14
# File 'lib/rails_graph/graph/node.rb', line 10

def initialize(labels: [], **opts)
  @labels = Array(labels)

  super(**opts)
end

Instance Attribute Details

#labelsObject (readonly)

Returns the value of attribute labels.



8
9
10
# File 'lib/rails_graph/graph/node.rb', line 8

def labels
  @labels
end

Instance Method Details

#as_json(_options = nil) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/rails_graph/graph/node.rb', line 16

def as_json(_options = nil)
  {
    id: id,
    labels: labels,
    name: name,
    properties: properties
  }
end