Class: RubyCritic::Location

Inherits:
Object
  • Object
show all
Defined in:
lib/rubycritic/core/location.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, line) ⇒ Location

Returns a new instance of Location.


9
10
11
12
# File 'lib/rubycritic/core/location.rb', line 9

def initialize(path, line)
  @pathname = Pathname.new(path)
  @line = line.to_i
end

Instance Attribute Details

#lineObject (readonly)

Returns the value of attribute line


7
8
9
# File 'lib/rubycritic/core/location.rb', line 7

def line
  @line
end

#pathnameObject (readonly)

Returns the value of attribute pathname


7
8
9
# File 'lib/rubycritic/core/location.rb', line 7

def pathname
  @pathname
end

Instance Method Details

#<=>(other) ⇒ Object


37
38
39
# File 'lib/rubycritic/core/location.rb', line 37

def <=>(other)
  state <=> other.state
end

#==(other) ⇒ Object


33
34
35
# File 'lib/rubycritic/core/location.rb', line 33

def ==(other)
  state == other.state
end

#file_nameObject


14
15
16
# File 'lib/rubycritic/core/location.rb', line 14

def file_name
  @pathname.basename.sub_ext('').to_s
end

#to_hObject


22
23
24
25
26
27
# File 'lib/rubycritic/core/location.rb', line 22

def to_h
  {
    path: pathname.to_s,
    line: line
  }
end

#to_json(*options) ⇒ Object


29
30
31
# File 'lib/rubycritic/core/location.rb', line 29

def to_json(*options)
  to_h.to_json(*options)
end

#to_sObject


18
19
20
# File 'lib/rubycritic/core/location.rb', line 18

def to_s
  "#{pathname}:#{line}"
end