Class: Ibex::Runtime::RepairEdit

Inherits:
Object
  • Object
show all
Defined in:
lib/json5/generated_parser.rb

Overview

One immutable insertion, deletion, or replacement.

Constant Summary collapse

KINDS =

RBS:

  • type document_value = Symbol | Integer | String
%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

Raises:

  • (ArgumentError)


4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
# File 'lib/json5/generated_parser.rb', line 4521

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

#costObject (readonly)

Signature:

  • Integer



4518
4519
4520
# File 'lib/json5/generated_parser.rb', line 4518

def cost
  @cost
end

#kindObject (readonly)

Signature:

  • Array[Symbol]



4514
4515
4516
# File 'lib/json5/generated_parser.rb', line 4514

def kind
  @kind
end

#positionObject (readonly)

Signature:

  • Integer



4515
4516
4517
# File 'lib/json5/generated_parser.rb', line 4515

def position
  @position
end

#token_idObject (readonly)

Signature:

  • Integer



4516
4517
4518
# File 'lib/json5/generated_parser.rb', line 4516

def token_id
  @token_id
end

#token_nameObject (readonly)

Signature:

  • String



4517
4518
4519
# File 'lib/json5/generated_parser.rb', line 4517

def token_name
  @token_name
end

Instance Method Details

#to_hObject

RBS:

  • () -> Hash[Symbol, document_value]



4535
4536
4537
# File 'lib/json5/generated_parser.rb', line 4535

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