Class: Goodcheck::Issue
- Inherits:
-
Object
- Object
- Goodcheck::Issue
- Defined in:
- lib/goodcheck/issue.rb
Instance Attribute Summary collapse
-
#buffer ⇒ Object
readonly
Returns the value of attribute buffer.
-
#range ⇒ Object
readonly
Returns the value of attribute range.
-
#rule ⇒ Object
readonly
Returns the value of attribute rule.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(buffer:, rule:, text: nil, text_begin_pos: nil) ⇒ Issue
constructor
A new instance of Issue.
- #location ⇒ Object
- #path ⇒ Object
Constructor Details
#initialize(buffer:, rule:, text: nil, text_begin_pos: nil) ⇒ Issue
Returns a new instance of Issue.
8 9 10 11 12 13 14 |
# File 'lib/goodcheck/issue.rb', line 8 def initialize(buffer:, rule:, text: nil, text_begin_pos: nil) @buffer = buffer @rule = rule @text = text @range = text ? text_begin_pos..(text_begin_pos + text.bytesize - 1) : nil @location = nil 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.
6 7 8 |
# File 'lib/goodcheck/issue.rb', line 6 def range @range end |
#rule ⇒ Object (readonly)
Returns the value of attribute rule.
4 5 6 |
# File 'lib/goodcheck/issue.rb', line 4 def rule @rule end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
5 6 7 |
# File 'lib/goodcheck/issue.rb', line 5 def text @text end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
32 33 34 35 36 37 |
# File 'lib/goodcheck/issue.rb', line 32 def ==(other) other.is_a?(Issue) && other.buffer == buffer && other.range == range && other.rule == rule end |
#hash ⇒ Object
41 42 43 |
# File 'lib/goodcheck/issue.rb', line 41 def hash self.class.hash ^ buffer.hash ^ range.hash ^ rule.hash end |
#location ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/goodcheck/issue.rb', line 20 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
16 17 18 |
# File 'lib/goodcheck/issue.rb', line 16 def path buffer.path end |