Sha256: 615f5c73aba906c944617e9aa9f4c0f772b06777a5356150a8eb3c221a185aa2

Contents?: true

Size: 539 Bytes

Versions: 4

Compression:

Stored size: 539 Bytes

Contents

require "pathname"

module Rubycritic

  class Location
    attr_reader :pathname, :line

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

    def path
      @pathname.to_s
    end

    def file
      @pathname.basename.to_s
    end

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

    def ==(other)
      self.class == other.class && state == other.state
    end

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

    protected

    def state
      [@pathname, @line]
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubycritic-0.0.4 lib/rubycritic/location.rb
rubycritic-0.0.3 lib/rubycritic/location.rb
rubycritic-0.0.2 lib/rubycritic/location.rb
rubycritic-0.0.1 lib/rubycritic/location.rb