Class: RuboCop::Cop::DarkFinger::ModuleAncestorChainExtractor
- Inherits:
-
Object
- Object
- RuboCop::Cop::DarkFinger::ModuleAncestorChainExtractor
- Defined in:
- lib/rubocop/cop/dark_finger/module_ancestor_chain_extractor.rb
Instance Attribute Summary collapse
-
#node ⇒ Object
readonly
Returns the value of attribute node.
Instance Method Summary collapse
-
#initialize(node) ⇒ ModuleAncestorChainExtractor
constructor
A new instance of ModuleAncestorChainExtractor.
- #perform ⇒ Object
Constructor Details
#initialize(node) ⇒ ModuleAncestorChainExtractor
Returns a new instance of ModuleAncestorChainExtractor.
7 8 9 |
# File 'lib/rubocop/cop/dark_finger/module_ancestor_chain_extractor.rb', line 7 def initialize(node) @node = node end |
Instance Attribute Details
#node ⇒ Object (readonly)
Returns the value of attribute node.
5 6 7 |
# File 'lib/rubocop/cop/dark_finger/module_ancestor_chain_extractor.rb', line 5 def node @node end |
Instance Method Details
#perform ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/rubocop/cop/dark_finger/module_ancestor_chain_extractor.rb', line 11 def perform module_chain = [node.children.first.const_name] current_node = node while current_node.parent && current_node.parent.module_type? module_chain << current_node.parent.children.first.const_name current_node = current_node.parent end module_chain.reverse.join("::") end |