Class: I18n::Tasks::Scanners::RubyAstCallFinder
- Inherits:
-
Object
- Object
- I18n::Tasks::Scanners::RubyAstCallFinder
- Includes:
- AST::Processor::Mixin
- Defined in:
- lib/i18n/tasks/scanners/ruby_ast_call_finder.rb
Instance Method Summary collapse
-
#collect_calls(root_node) ⇒ Pair<Parser::AST::Node, method_name as string>
For all nodes with :send type.
- #handler_missing(node) ⇒ Object
- #on_def(node) ⇒ Object
- #on_send(send_node) ⇒ Object
Instance Method Details
#collect_calls(root_node) ⇒ Pair<Parser::AST::Node, method_name as string>
Returns for all nodes with :send type.
11 12 13 14 15 |
# File 'lib/i18n/tasks/scanners/ruby_ast_call_finder.rb', line 11 def collect_calls(root_node) @results = [] process(root_node) @results end |
#handler_missing(node) ⇒ Object
32 33 34 35 |
# File 'lib/i18n/tasks/scanners/ruby_ast_call_finder.rb', line 32 def handler_missing(node) node.children.each { |child| process(child) if child.is_a?(::Parser::AST::Node) } nil end |
#on_def(node) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/i18n/tasks/scanners/ruby_ast_call_finder.rb', line 17 def on_def(node) @method_name = node.children[0] handler_missing(node) ensure @method_name = nil end |
#on_send(send_node) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/i18n/tasks/scanners/ruby_ast_call_finder.rb', line 24 def on_send(send_node) @results << [send_node, @method_name] # always invoke handler_missing to get nested translations in children handler_missing(send_node) nil end |