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