Class: Ibex::Runtime::RepairEdit

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

Overview

One immutable insertion, deletion, or replacement.

Constant Summary collapse

KINDS =

Signature:

  • Array[Symbol]

Returns:

  • (Array[Symbol])
%i[insert delete replace].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(kind:, position:, token_id:, token_name:, cost:) ⇒ RepairEdit

Returns a new instance of RepairEdit.

RBS:

  • (kind: Symbol, position: Integer, token_id: Integer, token_name: String, cost: Integer) -> void

Parameters:

  • kind: (Symbol)
  • position: (Integer)
  • token_id: (Integer)
  • token_name: (String)
  • cost: (Integer)


52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/ibex/runtime/repair.rb', line 52

def initialize(kind:, position:, token_id:, token_name:, cost:)
  raise ArgumentError, "unknown repair edit #{kind.inspect}" unless KINDS.include?(kind)
  raise ArgumentError, "repair edit position must be nonnegative" if position.negative?
  raise ArgumentError, "repair edit cost must be positive" unless cost.positive?

  @kind = kind
  @position = position
  @token_id = token_id
  @token_name = token_name.dup.freeze
  @cost = cost
  freeze
end

Instance Attribute Details

#costInteger (readonly)

Signature:

  • Integer

Returns:

  • (Integer)


49
50
51
# File 'lib/ibex/runtime/repair.rb', line 49

def cost
  @cost
end

#kindSymbol (readonly)

Signature:

  • Symbol

Returns:

  • (Symbol)


45
46
47
# File 'lib/ibex/runtime/repair.rb', line 45

def kind
  @kind
end

#positionInteger (readonly)

Signature:

  • Integer

Returns:

  • (Integer)


46
47
48
# File 'lib/ibex/runtime/repair.rb', line 46

def position
  @position
end

#token_idInteger (readonly)

Signature:

  • Integer

Returns:

  • (Integer)


47
48
49
# File 'lib/ibex/runtime/repair.rb', line 47

def token_id
  @token_id
end

#token_nameString (readonly)

Signature:

  • String

Returns:

  • (String)


48
49
50
# File 'lib/ibex/runtime/repair.rb', line 48

def token_name
  @token_name
end

Instance Method Details

#to_hHash[Symbol, untyped]

RBS:

  • () -> Hash[Symbol, untyped]

Returns:

  • (Hash[Symbol, untyped])


66
67
68
# File 'lib/ibex/runtime/repair.rb', line 66

def to_h
  { kind: @kind, position: @position, token_id: @token_id, token_name: @token_name, cost: @cost }.freeze
end