Class: Goodcheck::Issue

Inherits:
Object
  • Object
show all
Defined in:
lib/goodcheck/issue.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(buffer:, range:, rule:, text:) ⇒ Issue

Returns a new instance of Issue.



8
9
10
11
12
13
# File 'lib/goodcheck/issue.rb', line 8

def initialize(buffer:, range:, rule:, text:)
  @buffer = buffer
  @range = range
  @rule = rule
  @text = text
end

Instance Attribute Details

#buffer ⇒ Object (readonly)

Returns the value of attribute buffer.



3
4
5
# File 'lib/goodcheck/issue.rb', line 3

def buffer
  @buffer
end

#range ⇒ Object (readonly)

Returns the value of attribute range.



4
5
6
# File 'lib/goodcheck/issue.rb', line 4

def range
  @range
end

#rule ⇒ Object (readonly)

Returns the value of attribute rule.



5
6
7
# File 'lib/goodcheck/issue.rb', line 5

def rule
  @rule
end

#text ⇒ Object (readonly)

Returns the value of attribute text.



6
7
8
# File 'lib/goodcheck/issue.rb', line 6

def text
  @text
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



31
32
33
34
35
36
# File 'lib/goodcheck/issue.rb', line 31

def ==(other)
  other.is_a?(Issue) &&
    other.buffer == buffer &&
    other.range == range &&
    other.rule == rule
end

#hash ⇒ Object



40
41
42
# File 'lib/goodcheck/issue.rb', line 40

def hash
  self.class.hash ^ buffer.hash ^ range.hash ^ rule.hash
end

#location ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/goodcheck/issue.rb', line 19

def location
  if range
    unless @location
      start_line, start_column = buffer.location_for_position(range.begin)
      end_line, end_column = buffer.location_for_position(range.end)
      @location = Location.new(start_line: start_line, start_column: start_column, end_line: end_line, end_column: end_column)
    end

    @location
  end
end

#path ⇒ Object



15
16
17
# File 'lib/goodcheck/issue.rb', line 15

def path
  buffer.path
end