Class: MiniRuby::Span
- Inherits:
-
Object
- Object
- MiniRuby::Span
- Extended by:
- T::Sig
- Defined in:
- lib/miniruby/span.rb
Overview
A collection of two positions: start and end
Constant Summary collapse
Instance Attribute Summary collapse
-
#end ⇒ Object
readonly
: Position.
-
#start ⇒ Object
readonly
: Position.
Instance Method Summary collapse
-
#==(other) ⇒ Object
: (Object other) -> bool.
-
#initialize(start, end_pos) ⇒ Span
constructor
: (Position start, Position end_pos) -> void.
-
#inspect ⇒ Object
: -> String.
-
#join(other) ⇒ Object
Create a new span that includes the area of two spans.
Constructor Details
#initialize(start, end_pos) ⇒ Span
: (Position start, Position end_pos) -> void
16 17 18 19 |
# File 'lib/miniruby/span.rb', line 16 def initialize(start, end_pos) @start = start @end = end_pos end |
Instance Attribute Details
#end ⇒ Object (readonly)
: Position
13 14 15 |
# File 'lib/miniruby/span.rb', line 13 def end @end end |
#start ⇒ Object (readonly)
: Position
10 11 12 |
# File 'lib/miniruby/span.rb', line 10 def start @start end |
Instance Method Details
#==(other) ⇒ Object
: (Object other) -> bool
30 31 32 33 34 |
# File 'lib/miniruby/span.rb', line 30 def ==(other) return false unless other.is_a?(Span) @start == other.start && @end == other.end end |
#inspect ⇒ Object
: -> String
37 38 39 |
# File 'lib/miniruby/span.rb', line 37 def inspect "S(#{@start.inspect}, #{@end.inspect})" end |