Class: Rubycritic::Location
- Inherits:
-
Object
- Object
- Rubycritic::Location
- Defined in:
- lib/rubycritic/core/location.rb
Instance Attribute Summary collapse
-
#line ⇒ Object
readonly
Returns the value of attribute line.
-
#pathname ⇒ Object
readonly
Returns the value of attribute pathname.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object
- #file_name ⇒ Object
-
#initialize(path, line) ⇒ Location
constructor
A new instance of Location.
- #to_h ⇒ Object
- #to_json(*a) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(path, line) ⇒ Location
Returns a new instance of Location.
7 8 9 10 |
# File 'lib/rubycritic/core/location.rb', line 7 def initialize(path, line) @pathname = Pathname.new(path) @line = line.to_i end |
Instance Attribute Details
#line ⇒ Object (readonly)
Returns the value of attribute line.
5 6 7 |
# File 'lib/rubycritic/core/location.rb', line 5 def line @line end |
#pathname ⇒ Object (readonly)
Returns the value of attribute pathname.
5 6 7 |
# File 'lib/rubycritic/core/location.rb', line 5 def pathname @pathname end |
Instance Method Details
#<=>(other) ⇒ Object
35 36 37 |
# File 'lib/rubycritic/core/location.rb', line 35 def <=>(other) state <=> other.state end |
#==(other) ⇒ Object
31 32 33 |
# File 'lib/rubycritic/core/location.rb', line 31 def ==(other) state == other.state end |
#file_name ⇒ Object
12 13 14 |
# File 'lib/rubycritic/core/location.rb', line 12 def file_name @pathname.basename.sub_ext('').to_s end |
#to_h ⇒ Object
20 21 22 23 24 25 |
# File 'lib/rubycritic/core/location.rb', line 20 def to_h { path: pathname.to_s, line: line } end |
#to_json(*a) ⇒ Object
27 28 29 |
# File 'lib/rubycritic/core/location.rb', line 27 def to_json(*a) to_h.to_json(*a) end |
#to_s ⇒ Object
16 17 18 |
# File 'lib/rubycritic/core/location.rb', line 16 def to_s "#{pathname}:#{line}" end |