Class: Tina4::GraphNode

Inherits:
Object
  • Object
show all
Defined in:
lib/tina4/graph.rb

Overview

An engine-neutral vertex: id, labels, properties.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, labels: nil, properties: nil) ⇒ GraphNode

Returns a new instance of GraphNode.



126
127
128
129
130
# File 'lib/tina4/graph.rb', line 126

def initialize(id:, labels: nil, properties: nil)
  @id = id
  @labels = Array(labels)
  @properties = properties || {}
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



124
125
126
# File 'lib/tina4/graph.rb', line 124

def id
  @id
end

#labelsObject (readonly)

Returns the value of attribute labels.



124
125
126
# File 'lib/tina4/graph.rb', line 124

def labels
  @labels
end

#propertiesObject (readonly)

Returns the value of attribute properties.



124
125
126
# File 'lib/tina4/graph.rb', line 124

def properties
  @properties
end

Instance Method Details

#inspectObject



136
137
138
# File 'lib/tina4/graph.rb', line 136

def inspect
  "#<Tina4::GraphNode id=#{@id.inspect} labels=#{@labels.inspect}>"
end

#to_hObject



132
133
134
# File 'lib/tina4/graph.rb', line 132

def to_h
  { "id" => @id, "labels" => @labels, "properties" => @properties }
end