Class: Goodcheck::Location
- Inherits:
-
Object
- Object
- Goodcheck::Location
- Defined in:
- lib/goodcheck/location.rb
Overview
In the example below, each attribute is:
-
start_line: 2
-
start_column: 3
-
end_line: 2
-
end_column: 9
Instance Attribute Summary collapse
-
#end_column ⇒ Object
readonly
Returns the value of attribute end_column.
-
#end_line ⇒ Object
readonly
Returns the value of attribute end_line.
-
#start_column ⇒ Object
readonly
Returns the value of attribute start_column.
-
#start_line ⇒ Object
readonly
Returns the value of attribute start_line.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #column_size ⇒ Object
- #hash ⇒ Object
-
#initialize(start_line:, start_column:, end_line:, end_column:) ⇒ Location
constructor
A new instance of Location.
- #one_line? ⇒ Boolean
Constructor Details
#initialize(start_line:, start_column:, end_line:, end_column:) ⇒ Location
Returns a new instance of Location.
22 23 24 25 26 27 |
# File 'lib/goodcheck/location.rb', line 22 def initialize(start_line:, start_column:, end_line:, end_column:) @start_line = start_line @start_column = start_column @end_line = end_line @end_column = end_column end |
Instance Attribute Details
#end_column ⇒ Object (readonly)
Returns the value of attribute end_column.
20 21 22 |
# File 'lib/goodcheck/location.rb', line 20 def end_column @end_column end |
#end_line ⇒ Object (readonly)
Returns the value of attribute end_line.
19 20 21 |
# File 'lib/goodcheck/location.rb', line 19 def end_line @end_line end |
#start_column ⇒ Object (readonly)
Returns the value of attribute start_column.
18 19 20 |
# File 'lib/goodcheck/location.rb', line 18 def start_column @start_column end |
#start_line ⇒ Object (readonly)
Returns the value of attribute start_line.
17 18 19 |
# File 'lib/goodcheck/location.rb', line 17 def start_line @start_line end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
37 38 39 40 41 42 43 |
# File 'lib/goodcheck/location.rb', line 37 def ==(other) other.is_a?(Location) && other.start_line == start_line && other.start_column == start_column && other.end_line == end_line && other.end_column == end_column end |
#column_size ⇒ Object
33 34 35 |
# File 'lib/goodcheck/location.rb', line 33 def column_size end_column - start_column + 1 end |
#hash ⇒ Object
47 48 49 |
# File 'lib/goodcheck/location.rb', line 47 def hash self.class.hash ^ start_line.hash ^ start_column.hash ^ end_line.hash ^ end_column.hash end |
#one_line? ⇒ Boolean
29 30 31 |
# File 'lib/goodcheck/location.rb', line 29 def one_line? start_line == end_line end |