Class: TreeStand::Range

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/tree_stand/range.rb

Overview

Wrapper around a TreeSitter range. This is mainly used to compare ranges.

Defined Under Namespace

Classes: Point

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(start_byte:, end_byte:, start_point:, end_point:) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:



35
36
37
38
39
40
# File 'lib/tree_stand/range.rb', line 35

def initialize(start_byte:, end_byte:, start_point:, end_point:)
  @start_byte = start_byte
  @end_byte = end_byte
  @start_point = Point.new(start_point.row, start_point.column)
  @end_point = Point.new(end_point.row, end_point.column)
end

Instance Attribute Details

#end_byteInteger (readonly)

Returns:

  • (Integer)


20
21
22
# File 'lib/tree_stand/range.rb', line 20

def end_byte
  @end_byte
end

#end_pointTreeStand::Range::Point (readonly)



24
25
26
# File 'lib/tree_stand/range.rb', line 24

def end_point
  @end_point
end

#start_byteInteger (readonly)

Returns:

  • (Integer)


18
19
20
# File 'lib/tree_stand/range.rb', line 18

def start_byte
  @start_byte
end

#start_pointTreeStand::Range::Point (readonly)



22
23
24
# File 'lib/tree_stand/range.rb', line 22

def start_point
  @start_point
end

Instance Method Details

#==(other) ⇒ Boolean

Parameters:

  • other (Object)

Returns:

  • (Boolean)


43
44
45
46
47
48
49
50
# File 'lib/tree_stand/range.rb', line 43

def ==(other)
  return false unless other.is_a?(TreeStand::Range)

  @start_byte == other.start_byte &&
    @end_byte == other.end_byte &&
    @start_point == other.start_point &&
    @end_point == other.end_point
end