Class: Ibex::Runtime::RepairEdit
- Inherits:
-
Object
- Object
- Ibex::Runtime::RepairEdit
- Defined in:
- lib/ibex/runtime/repair.rb,
sig/ibex/runtime/repair.rbs
Overview
One immutable insertion, deletion, or replacement.
Constant Summary collapse
- KINDS =
%i[insert delete replace].freeze
Instance Attribute Summary collapse
- #cost ⇒ Integer readonly
- #kind ⇒ Symbol readonly
- #position ⇒ Integer readonly
- #token_id ⇒ Integer readonly
- #token_name ⇒ String readonly
Instance Method Summary collapse
-
#initialize(kind:, position:, token_id:, token_name:, cost:) ⇒ RepairEdit
constructor
A new instance of RepairEdit.
- #to_h ⇒ Hash[Symbol, untyped]
Constructor Details
#initialize(kind:, position:, token_id:, token_name:, cost:) ⇒ RepairEdit
Returns a new instance of RepairEdit.
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
#cost ⇒ Integer (readonly)
49 50 51 |
# File 'lib/ibex/runtime/repair.rb', line 49 def cost @cost end |
#kind ⇒ Symbol (readonly)
45 46 47 |
# File 'lib/ibex/runtime/repair.rb', line 45 def kind @kind end |
#position ⇒ Integer (readonly)
46 47 48 |
# File 'lib/ibex/runtime/repair.rb', line 46 def position @position end |
#token_id ⇒ Integer (readonly)
47 48 49 |
# File 'lib/ibex/runtime/repair.rb', line 47 def token_id @token_id end |
#token_name ⇒ String (readonly)
48 49 50 |
# File 'lib/ibex/runtime/repair.rb', line 48 def token_name @token_name end |
Instance Method Details
#to_h ⇒ 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 |