Class: Ibex::Impact::Edge

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

Overview

A grammar dependency edge with enough origin information for a witness.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source:, target:, kind:, production: nil, position: nil) ⇒ Edge

Returns a new instance of Edge.



17
18
19
20
21
22
23
24
# File 'lib/ibex/impact/graph.rb', line 17

def initialize(source:, target:, kind:, production: nil, position: nil)
  @source = source
  @target = target
  @kind = kind.to_sym
  @production = production
  @position = position
  freeze
end

Instance Attribute Details

#kindObject (readonly)

: Symbol



12
13
14
# File 'lib/ibex/impact/graph.rb', line 12

def kind
  @kind
end

#positionObject (readonly)

: Integer?



14
15
16
# File 'lib/ibex/impact/graph.rb', line 14

def position
  @position
end

#productionObject (readonly)

: Integer?



13
14
15
# File 'lib/ibex/impact/graph.rb', line 13

def production
  @production
end

#sourceObject (readonly)

: Integer



10
11
12
# File 'lib/ibex/impact/graph.rb', line 10

def source
  @source
end

#targetObject (readonly)

: Integer



11
12
13
# File 'lib/ibex/impact/graph.rb', line 11

def target
  @target
end

Instance Method Details

#sort_keyObject



27
28
29
# File 'lib/ibex/impact/graph.rb', line 27

def sort_key
  [@source, @target, @production || -1, @position || -1, @kind]
end