Module: Reek::AST::SexpExtensions::ConstantDefiningNodeBase
- Included in:
- CasgnNode, ModuleNodeBase
- Defined in:
- lib/reek/ast/sexp_extensions/module.rb
Overview
Base module for utility methods for nodes that define constants: module definition, class definition and constant assignment.
Instance Method Summary collapse
-
#full_name(outer) ⇒ Object
The full name of the constant, including the name of any module or class it is nested inside of.
-
#simple_name ⇒ String
The final section of the module or class name.
Instance Method Details
#full_name(outer) ⇒ Object
The full name of the constant, including the name of any module or class it is nested inside of.
For example, given code like this:
module Foo
class Bar::Baz
end
end
The full name for the inner class will be ‘Foo::Bar::Baz’. To return the correct name, the name of the outer context has to be passed into this method.
25 26 27 |
# File 'lib/reek/ast/sexp_extensions/module.rb', line 25 def full_name(outer) [outer, name].reject(&:empty?).join('::') end |
#simple_name ⇒ String
The final section of the module or class name. For example, for a module with name ‘Foo::Bar’ this will return ‘Bar’; for a module with name ‘Foo’ this will return ‘Foo’.
34 35 36 |
# File 'lib/reek/ast/sexp_extensions/module.rb', line 34 def simple_name name.split('::').last end |