Class: Ibex::Runtime::RepairEdit
- Inherits:
-
Object
- Object
- Ibex::Runtime::RepairEdit
- Defined in:
- lib/json5/generated_parser.rb
Overview
One immutable insertion, deletion, or replacement.
Constant Summary collapse
- KINDS =
%i[insert delete replace].freeze
Instance Attribute Summary collapse
- #cost ⇒ Object readonly
- #kind ⇒ Object readonly
- #position ⇒ Object readonly
- #token_id ⇒ Object readonly
- #token_name ⇒ Object readonly
Instance Method Summary collapse
-
#initialize(kind:, position:, token_id:, token_name:, cost:) ⇒ RepairEdit
constructor
A new instance of RepairEdit.
- #to_h ⇒ Object
Constructor Details
#initialize(kind:, position:, token_id:, token_name:, cost:) ⇒ RepairEdit
Returns a new instance of RepairEdit.
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
#cost ⇒ Object (readonly)
4518 4519 4520 |
# File 'lib/json5/generated_parser.rb', line 4518 def cost @cost end |
#kind ⇒ Object (readonly)
4514 4515 4516 |
# File 'lib/json5/generated_parser.rb', line 4514 def kind @kind end |
#position ⇒ Object (readonly)
4515 4516 4517 |
# File 'lib/json5/generated_parser.rb', line 4515 def position @position end |
#token_id ⇒ Object (readonly)
4516 4517 4518 |
# File 'lib/json5/generated_parser.rb', line 4516 def token_id @token_id end |
#token_name ⇒ Object (readonly)
4517 4518 4519 |
# File 'lib/json5/generated_parser.rb', line 4517 def token_name @token_name end |
Instance Method Details
#to_h ⇒ Object
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 |