Class: SCSSLint::Location
- Inherits:
-
Object
- Object
- SCSSLint::Location
- Includes:
- Comparable
- Defined in:
- lib/scss_lint/location.rb
Overview
Stores a location of Lint in a source.
Instance Attribute Summary collapse
-
#column ⇒ Object
readonly
Returns the value of attribute column.
-
#length ⇒ Object
readonly
Returns the value of attribute length.
-
#line ⇒ Object
readonly
Returns the value of attribute line.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object (also: #eql?)
-
#initialize(line = 1, column = 1, length = 1) ⇒ Location
constructor
A new instance of Location.
Constructor Details
#initialize(line = 1, column = 1, length = 1) ⇒ Location
Returns a new instance of Location.
11 12 13 14 15 16 17 18 19 |
# File 'lib/scss_lint/location.rb', line 11 def initialize(line = 1, column = 1, length = 1) raise ArgumentError, "Line must be more than 0, passed #{line}" if line < 1 raise ArgumentError, "Column must be more than 0, passed #{column}" if column < 1 raise ArgumentError, "Length must be more than 0, passed #{length}" if length < 1 @line = line @column = column @length = length end |
Instance Attribute Details
#column ⇒ Object (readonly)
Returns the value of attribute column.
6 7 8 |
# File 'lib/scss_lint/location.rb', line 6 def column @column end |
#length ⇒ Object (readonly)
Returns the value of attribute length.
6 7 8 |
# File 'lib/scss_lint/location.rb', line 6 def length @length end |
#line ⇒ Object (readonly)
Returns the value of attribute line.
6 7 8 |
# File 'lib/scss_lint/location.rb', line 6 def line @line end |
Instance Method Details
#<=>(other) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/scss_lint/location.rb', line 29 def <=>(other) [:line, :column, :length].each do |attr| result = send(attr) <=> other.send(attr) return result unless result == 0 end 0 end |
#==(other) ⇒ Object Also known as: eql?
21 22 23 24 25 |
# File 'lib/scss_lint/location.rb', line 21 def ==(other) [:line, :column, :length].all? do |attr| send(attr) == other.send(attr) end end |