Class: RuboCop::Isucon::GDA::NodeLocation

Inherits:
Object
  • Object
show all
Defined in:
lib/rubocop/isucon/gda/node_location.rb

Overview

Location in SQL

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(begin_pos:, end_pos:, body:) ⇒ NodeLocation

Returns a new instance of NodeLocation.

Parameters:

  • begin_pos (Integer)
  • end_pos (Integer)
  • body (String)


20
21
22
23
24
# File 'lib/rubocop/isucon/gda/node_location.rb', line 20

def initialize(begin_pos:, end_pos:, body:)
  @begin_pos = begin_pos
  @end_pos = end_pos
  @body = body
end

Instance Attribute Details

#begin_posInteger (readonly)

Returns:

  • (Integer)


9
10
11
# File 'lib/rubocop/isucon/gda/node_location.rb', line 9

def begin_pos
  @begin_pos
end

#bodyString (readonly)

Returns:

  • (String)


15
16
17
# File 'lib/rubocop/isucon/gda/node_location.rb', line 15

def body
  @body
end

#end_posInteger (readonly)

Returns:

  • (Integer)


12
13
14
# File 'lib/rubocop/isucon/gda/node_location.rb', line 12

def end_pos
  @end_pos
end

Instance Method Details

#==(other) ⇒ Boolean

Parameters:

Returns:

  • (Boolean)


28
29
30
31
32
33
# File 'lib/rubocop/isucon/gda/node_location.rb', line 28

def ==(other)
  other.is_a?(NodeLocation) &&
    begin_pos == other.begin_pos &&
    end_pos == other.end_pos &&
    body == other.body
end

#lengthInteger

Returns:

  • (Integer)


36
37
38
# File 'lib/rubocop/isucon/gda/node_location.rb', line 36

def length
  end_pos - begin_pos
end