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.



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

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

Instance Attribute Details

#lineObject (readonly)

Returns the value of attribute line.



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

def line
  @line
end

#pathnameObject (readonly)

Returns the value of attribute pathname.



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

def pathname
  @pathname
end

Instance Method Details

#<=>(other) ⇒ Object



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

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

#==(other) ⇒ Object



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

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

#file_nameObject



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

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

#to_hObject



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

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

#to_json(*a) ⇒ Object



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

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

#to_sObject



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

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