Sha256: e4278d7382420e82c87707b5566128e05eddd8ec5322a109c89c9f07f9679869

Contents?: true

Size: 637 Bytes

Versions: 9

Compression:

Stored size: 637 Bytes

Contents

require "pathname"

module Rubycritic

  class Location
    attr_reader :pathname, :line

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

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

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

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

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

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

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

    protected

    def state
      [@pathname, @line]
    end
  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rubycritic-2.6.0 lib/rubycritic/core/location.rb
rubycritic-2.5.0 lib/rubycritic/core/location.rb
rubycritic-2.4.1 lib/rubycritic/core/location.rb
rubycritic-2.4.0 lib/rubycritic/core/location.rb
rubycritic-2.3.0 lib/rubycritic/core/location.rb
rubycritic-2.2.0 lib/rubycritic/core/location.rb
rubycritic-2.1.0 lib/rubycritic/core/location.rb
rubycritic-2.0.0 lib/rubycritic/core/location.rb
rubycritic-1.4.0 lib/rubycritic/core/location.rb