Class: Reek::Name

Inherits:
Object show all
Includes:
Comparable
Defined in:
lib/reek/name.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sym) ⇒ Name

Returns a new instance of Name.



27
28
29
# File 'lib/reek/name.rb', line 27

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

Class Method Details

.resolve(exp, context) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/reek/name.rb', line 5

def self.resolve(exp, context)
  unless Array === exp
    return resolve_string(exp.to_s, context)
  end
  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

.resolve_string(str, context) ⇒ Object



22
23
24
25
# File 'lib/reek/name.rb', line 22

def self.resolve_string(str, context)
  return [context, new(str)] unless str =~ /::/
  resolve(RubyParser.new.parse(str), context)
end

Instance Method Details

#<=>(other) ⇒ Object

:nodoc:



39
40
41
# File 'lib/reek/name.rb', line 39

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

#effective_nameObject



43
44
45
# File 'lib/reek/name.rb', line 43

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

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/reek/name.rb', line 35

def eql?(other)
  self == other
end

#hashObject

:nodoc:



31
32
33
# File 'lib/reek/name.rb', line 31

def hash  # :nodoc:
  @name.hash
end

#inspectObject



47
48
49
# File 'lib/reek/name.rb', line 47

def inspect
  @name.inspect
end

#to_sObject



51
52
53
# File 'lib/reek/name.rb', line 51

def to_s
  @name
end