Class: Grumlin::Vertex

Inherits:
Object
  • Object
show all
Defined in:
lib/grumlin/vertex.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(label:, id:, properties: nil) ⇒ Vertex

Returns a new instance of Vertex.



6
7
8
9
10
# File 'lib/grumlin/vertex.rb', line 6

def initialize(label:, id:, properties: nil)
  @label = label
  @id = Grumlin::Typing.cast(id)
  @properties = properties&.transform_values { |v| Grumlin::Typing.cast(v) }
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



4
5
6
# File 'lib/grumlin/vertex.rb', line 4

def id
  @id
end

#labelObject (readonly)

Returns the value of attribute label.



4
5
6
# File 'lib/grumlin/vertex.rb', line 4

def label
  @label
end

#propertiesObject (readonly)

Returns the value of attribute properties.



4
5
6
# File 'lib/grumlin/vertex.rb', line 4

def properties
  @properties
end

Instance Method Details

#==(other) ⇒ Object



12
13
14
# File 'lib/grumlin/vertex.rb', line 12

def ==(other)
  self.class == other.class && @label == other.label && @id == other.id
end

#inspectObject



16
17
18
# File 'lib/grumlin/vertex.rb', line 16

def inspect
  "v[#{@id}]"
end

#to_sObject



20
21
22
# File 'lib/grumlin/vertex.rb', line 20

def to_s
  inspect
end