Class: Ibex::Impact::Edge

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

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.

RBS:

  • (source: Integer, target: Integer, kind: Symbol, production: Integer?, position: Integer?) -> void

Parameters:

  • source: (Integer)
  • target: (Integer)
  • kind: (Symbol)
  • production: (Integer, nil) (defaults to: nil)
  • position: (Integer, nil) (defaults to: nil)


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

#kindSymbol (readonly)

Signature:

  • Symbol

Returns:

  • (Symbol)


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

def kind
  @kind
end

#positionInteger? (readonly)

Signature:

  • Integer?

Returns:

  • (Integer, nil)


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

def position
  @position
end

#productionInteger? (readonly)

Signature:

  • Integer?

Returns:

  • (Integer, nil)


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

def production
  @production
end

#sourceInteger (readonly)

Signature:

  • Integer

Returns:

  • (Integer)


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

def source
  @source
end

#targetInteger (readonly)

Signature:

  • Integer

Returns:

  • (Integer)


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

def target
  @target
end

Instance Method Details

#sort_keyArray[Integer | Symbol | nil]

RBS:

  • () -> Array[Integer | Symbol | nil]

Returns:

  • (Array[Integer | Symbol | nil])


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

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