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
Returns the value of attribute end.
-
#start ⇒ Object
readonly
Returns the value of attribute start.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(start, end_pos) ⇒ Span
constructor
A new instance of Span.
- #inspect ⇒ Object
- #join(other) ⇒ Object
Constructor Details
#initialize(start, end_pos) ⇒ Span
Returns a new instance of Span.
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)
Returns the value of attribute end.
13 14 15 |
# File 'lib/miniruby/span.rb', line 13 def end @end end |
#start ⇒ Object (readonly)
Returns the value of attribute start.
10 11 12 |
# File 'lib/miniruby/span.rb', line 10 def start @start end |
Instance Method Details
#==(other) ⇒ Object
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
37 38 39 |
# File 'lib/miniruby/span.rb', line 37 def inspect "S(#{@start.inspect}, #{@end.inspect})" end |