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:) ⇒ Range

Returns a new instance of Range.



38
39
40
41
42
43
# File 'lib/tree_stand/range.rb', line 38

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_byteObject (readonly)

Returns the value of attribute end_byte.



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

def end_byte
  @end_byte
end

#end_pointObject (readonly)

Returns the value of attribute end_point.



27
28
29
# File 'lib/tree_stand/range.rb', line 27

def end_point
  @end_point
end

#start_byteObject (readonly)

Returns the value of attribute start_byte.



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

def start_byte
  @start_byte
end

#start_pointObject (readonly)

Returns the value of attribute start_point.



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

def start_point
  @start_point
end

Instance Method Details

#==(other) ⇒ Object



46
47
48
49
50
51
52
53
# File 'lib/tree_stand/range.rb', line 46

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