Class: Astrolabe::Node
- Inherits:
-
Object
- Object
- Astrolabe::Node
- Extended by:
- RuboCop::NodePattern::Macros
- Defined in:
- lib/rubocop/ast_node.rb
Overview
RuboCop's extensions to Astrolabe::Node (which extends Parser::AST::Node)
Contribute as much of this as possible to the astrolabe
gem
If any of it is accepted, it can be deleted from here
Class Method Summary collapse
-
.def_matcher(method_name, pattern_str) ⇒ Object
define both Node.method_name(node), and also node.method_name.
Instance Method Summary collapse
- #asgn_method_call? ⇒ Boolean
-
#method_name ⇒ Object
Destructuring.
-
#multiline? ⇒ Boolean
Predicates.
- #single_line? ⇒ Boolean
Methods included from RuboCop::NodePattern::Macros
def_node_matcher, def_node_search
Class Method Details
.def_matcher(method_name, pattern_str) ⇒ Object
define both Node.method_name(node), and also node.method_name
17 18 19 20 |
# File 'lib/rubocop/ast_node.rb', line 17 def def_matcher(method_name, pattern_str) singleton_class.def_node_matcher method_name, pattern_str class_eval("def #{method_name}; Node.#{method_name}(self); end") end |
Instance Method Details
#asgn_method_call? ⇒ Boolean
40 41 42 |
# File 'lib/rubocop/ast_node.rb', line 40 def asgn_method_call? method_name != :== && method_name.to_s.end_with?('=') end |
#method_name ⇒ Object
Destructuring
25 |
# File 'lib/rubocop/ast_node.rb', line 25 def_matcher :method_name, '{(send _ $_ ...) (block (send _ $_ ...) ...)}' |
#multiline? ⇒ Boolean
Predicates
31 32 33 34 |
# File 'lib/rubocop/ast_node.rb', line 31 def multiline? expr = loc.expression expr && (expr.first_line != expr.last_line) end |
#single_line? ⇒ Boolean
36 37 38 |
# File 'lib/rubocop/ast_node.rb', line 36 def single_line? !multiline? end |