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.



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

#lineObject (readonly)

Returns the value of attribute line.



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

def line
  @line
end

#pathnameObject (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_nameObject



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

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

#to_hObject



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_sObject



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

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