Sha256: f08d7f4d7b62af8bd63a03aa98f507e4b8c8da02667d40b3b5b56f491c421c44

Contents?: true

Size: 756 Bytes

Versions: 6

Compression:

Stored size: 756 Bytes

Contents

module Reek
  class Name
    include Comparable

    def self.resolve(exp, context)
      return [context, new(exp)] unless Array === exp
      name = exp[1]
      case exp[0]
      when :colon2
        return [resolve(name, context)[0], new(exp[2])]
      when :const
        return [ModuleContext.create(context, exp), new(name)]
      when :colon3
        return [StopContext.new, new(name)]
      else
        return [context, new(name)]
      end
    end

    def initialize(sym)
      @name = sym.to_s
    end

    def hash  # :nodoc:
      @name.hash
    end

    def <=>(other)  # :nodoc:
      @name <=> other.to_s
    end

    alias eql? <=>

    def effective_name
      @name.gsub(/^@*/, '')
    end

    def to_s
      @name
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
kevinrutherford-reek-0.3.1.4 lib/reek/name.rb
kevinrutherford-reek-0.3.1.5 lib/reek/name.rb
kevinrutherford-reek-0.3.1.6 lib/reek/name.rb
kevinrutherford-reek-1.0.0 lib/reek/name.rb
kevinrutherford-reek-1.0.1 lib/reek/name.rb
reek-1.0.0 lib/reek/name.rb