Class: PmdTester::Location

Inherits:
Object
  • Object
show all
Defined in:
lib/pmdtester/location.rb

Overview

This class represents a location in a source file

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(beginline:, endline:, begincolumn:, endcolumn:) ⇒ Location

Returns a new instance of Location.



8
9
10
11
12
13
# File 'lib/pmdtester/location.rb', line 8

def initialize(beginline:, endline:, begincolumn:, endcolumn:)
  @beginline = beginline
  @endline = endline
  @begincolumn = begincolumn
  @endcolumn = endcolumn
end

Instance Attribute Details

#begincolumnObject (readonly)

Returns the value of attribute begincolumn.



6
7
8
# File 'lib/pmdtester/location.rb', line 6

def begincolumn
  @begincolumn
end

#beginlineObject (readonly)

Returns the value of attribute beginline.



6
7
8
# File 'lib/pmdtester/location.rb', line 6

def beginline
  @beginline
end

#endcolumnObject (readonly)

Returns the value of attribute endcolumn.



6
7
8
# File 'lib/pmdtester/location.rb', line 6

def endcolumn
  @endcolumn
end

#endlineObject (readonly)

Returns the value of attribute endline.



6
7
8
# File 'lib/pmdtester/location.rb', line 6

def endline
  @endline
end

Instance Method Details

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
18
19
20
# File 'lib/pmdtester/location.rb', line 15

def eql?(other)
  beginline == other.beginline &&
    endline == other.endline &&
    begincolumn == other.begincolumn &&
    endcolumn == other.endcolumn
end

#hashObject



22
23
24
# File 'lib/pmdtester/location.rb', line 22

def hash
  [beginline, endline, begincolumn, endcolumn].hash
end

#to_sObject



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/pmdtester/location.rb', line 26

def to_s
  if beginline == endline
    if begincolumn == endcolumn
      "#{beginline}:#{begincolumn}"
    else
      "#{beginline}:#{begincolumn}-#{endcolumn}"
    end
  else
    "#{beginline}:#{begincolumn}-#{endline}:#{endcolumn}"
  end
end