Sha256: 99e7b3ec2aed1d1b9c7e822f012d6592288e65a82ab406f3bb9502cd6717f550

Contents?: true

Size: 522 Bytes

Versions: 6

Compression:

Stored size: 522 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 ==(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

6 entries across 6 versions & 1 rubygems

Version Path
rubycritic-0.0.14 lib/rubycritic/core/location.rb
rubycritic-0.0.13 lib/rubycritic/core/location.rb
rubycritic-0.0.12 lib/rubycritic/location.rb
rubycritic-0.0.11 lib/rubycritic/location.rb
rubycritic-0.0.10 lib/rubycritic/location.rb
rubycritic-0.0.9 lib/rubycritic/location.rb