Class: Reek::Name
Class Method Summary collapse
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
:nodoc:.
- #effective_name ⇒ Object
- #eql?(other) ⇒ Boolean
-
#hash ⇒ Object
:nodoc:.
-
#initialize(sym) ⇒ Name
constructor
A new instance of Name.
- #inspect ⇒ Object
- #to_s ⇒ Object
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_name ⇒ Object
43 44 45 |
# File 'lib/reek/name.rb', line 43 def effective_name @name.gsub(/^@*/, '') end |
#eql?(other) ⇒ Boolean
35 36 37 |
# File 'lib/reek/name.rb', line 35 def eql?(other) self == other end |
#hash ⇒ Object
:nodoc:
31 32 33 |
# File 'lib/reek/name.rb', line 31 def hash # :nodoc: @name.hash end |
#inspect ⇒ Object
47 48 49 |
# File 'lib/reek/name.rb', line 47 def inspect @name.inspect end |
#to_s ⇒ Object
51 52 53 |
# File 'lib/reek/name.rb', line 51 def to_s @name end |