Class: Parser::AST::Node
- Inherits:
-
Object
- Object
- Parser::AST::Node
- Defined in:
- lib/rubycritic/analysers/helpers/ast_node.rb
Constant Summary collapse
- MODULE_TYPES =
[:module, :class].freeze
Instance Method Summary collapse
Instance Method Details
#count_nodes_of_type(*types) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/rubycritic/analysers/helpers/ast_node.rb', line 7 def count_nodes_of_type(*types) count = 0 recursive_children do |child| count += 1 if types.include?(child.type) end count end |
#get_module_names ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/rubycritic/analysers/helpers/ast_node.rb', line 23 def get_module_names children_modules = children .select { |child| child.is_a?(Parser::AST::Node) } .flat_map(&:get_module_names) if MODULE_TYPES.include?(type) if children_modules.empty? [module_name] else children_modules.map do |children_module| "#{module_name}::#{children_module}" end end else children_modules end end |