Class: I18n::Tasks::Scanners::AstMatchers::MessageReceiversMatcher
- Inherits:
-
BaseMatcher
- Object
- BaseMatcher
- I18n::Tasks::Scanners::AstMatchers::MessageReceiversMatcher
- Defined in:
- lib/i18n/tasks/scanners/ast_matchers/message_receivers_matcher.rb
Instance Method Summary collapse
-
#convert_to_key_occurrences(send_node, method_name, location: send_node.loc) ⇒ nil, [key, Occurrence]
Full absolute key name and the occurrence.
-
#initialize(scanner:, receivers:, message:) ⇒ MessageReceiversMatcher
constructor
A new instance of MessageReceiversMatcher.
Constructor Details
#initialize(scanner:, receivers:, message:) ⇒ MessageReceiversMatcher
Returns a new instance of MessageReceiversMatcher.
8 9 10 11 12 |
# File 'lib/i18n/tasks/scanners/ast_matchers/message_receivers_matcher.rb', line 8 def initialize(scanner:, receivers:, message:) super(scanner: scanner) @receivers = Array(receivers) @message = end |
Instance Method Details
#convert_to_key_occurrences(send_node, method_name, location: send_node.loc) ⇒ nil, [key, Occurrence]
Returns full absolute key name and the occurrence.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/i18n/tasks/scanners/ast_matchers/message_receivers_matcher.rb', line 18 def convert_to_key_occurrences(send_node, method_name, location: send_node.loc) return unless node_match?(send_node) receiver = send_node.children[0] first_arg_node = send_node.children[2] second_arg_node = send_node.children[3] key = extract_string(first_arg_node) return if key.nil? key, default_arg = (node: second_arg_node, key: key) return if key.nil? [ full_key(receiver: receiver, key: key, location: location, calling_method: method_name), I18n::Tasks::Scanners::Results::Occurrence.from_range( raw_key: key, range: location.expression, default_arg: default_arg ) ] end |