Class: MiniRuby::Position
- Inherits:
-
Object
- Object
- MiniRuby::Position
- Extended by:
- T::Sig
- Defined in:
- lib/miniruby/position.rb
Overview
A position of a single character in a piece of text
Constant Summary collapse
- ZERO =
Position.new(0)
Instance Attribute Summary collapse
-
#char_index ⇒ Object
readonly
: Integer.
Instance Method Summary collapse
-
#==(other) ⇒ Object
: (Object other) -> bool.
-
#initialize(char_index) ⇒ Position
constructor
: (Integer char_index) -> void.
-
#inspect ⇒ Object
: -> String.
Constructor Details
#initialize(char_index) ⇒ Position
: (Integer char_index) -> void
13 14 15 |
# File 'lib/miniruby/position.rb', line 13 def initialize(char_index) @char_index = char_index end |
Instance Attribute Details
#char_index ⇒ Object (readonly)
: Integer
10 11 12 |
# File 'lib/miniruby/position.rb', line 10 def char_index @char_index end |
Instance Method Details
#==(other) ⇒ Object
: (Object other) -> bool
20 21 22 23 24 |
# File 'lib/miniruby/position.rb', line 20 def ==(other) return false unless other.is_a?(Position) @char_index == other.char_index end |
#inspect ⇒ Object
: -> String
27 28 29 |
# File 'lib/miniruby/position.rb', line 27 def inspect "P(#{char_index.inspect})" end |