Class: Hind::LSIF::Edge

Inherits:
Object
  • Object
show all
Defined in:
lib/hind/lsif/edge.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, label, out_v, in_v, property = nil, document = nil) ⇒ Edge

Returns a new instance of Edge.



8
9
10
11
12
13
14
15
# File 'lib/hind/lsif/edge.rb', line 8

def initialize(id, label, out_v, in_v, property = nil, document = nil)
  @id = id
  @label = label
  @out_v = out_v
  @in_v = in_v
  @property = property
  @document = document
end

Instance Attribute Details

#documentObject (readonly)

Returns the value of attribute document.



6
7
8
# File 'lib/hind/lsif/edge.rb', line 6

def document
  @document
end

#idObject (readonly)

Returns the value of attribute id.



6
7
8
# File 'lib/hind/lsif/edge.rb', line 6

def id
  @id
end

#in_vObject (readonly)

Returns the value of attribute in_v.



6
7
8
# File 'lib/hind/lsif/edge.rb', line 6

def in_v
  @in_v
end

#labelObject (readonly)

Returns the value of attribute label.



6
7
8
# File 'lib/hind/lsif/edge.rb', line 6

def label
  @label
end

#out_vObject (readonly)

Returns the value of attribute out_v.



6
7
8
# File 'lib/hind/lsif/edge.rb', line 6

def out_v
  @out_v
end

#propertyObject (readonly)

Returns the value of attribute property.



6
7
8
# File 'lib/hind/lsif/edge.rb', line 6

def property
  @property
end

Instance Method Details

#to_json(*_args) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/hind/lsif/edge.rb', line 17

def to_json(*_args)
  json = {
    id: @id,
    type: 'edge',
    label: @label,
    outV: @out_v
  }

  if @in_v.is_a?(Array)
    json[:inVs] = @in_v
  else
    json[:inV] = @in_v
  end

  json[:property] = @property if @property
  json[:document] = @document if @document

  json
end