Module: PrismHelpers
- Included in:
- Deprecool::Finder
- Defined in:
- lib/deprecool/helpers/prism_helpers.rb
Instance Method Summary collapse
-
#unwrap_arguments(node) ⇒ Object
Method arguments are represented as: node.arguments returns a literal array of arguments https://docs.ruby-lang.org/en/master/Prism/ArgumentsNode.html.
- #unwrap_array(node) ⇒ Object
- #unwrap_children(node) ⇒ Object
- #unwrap_class(node) ⇒ Object
-
#unwrap_parentheses(node) ⇒ Object
(1..10)parses as a ParenthesesNode wrapping the real expression.
Instance Method Details
#unwrap_arguments(node) ⇒ Object
Method arguments are represented as: node.arguments returns a literal array of arguments https://docs.ruby-lang.org/en/master/Prism/ArgumentsNode.html
15 16 17 18 19 |
# File 'lib/deprecool/helpers/prism_helpers.rb', line 15 def unwrap_arguments(node) return node unless node.is_a?(Prism::ArgumentsNode) node.arguments end |
#unwrap_array(node) ⇒ Object
22 23 24 25 26 |
# File 'lib/deprecool/helpers/prism_helpers.rb', line 22 def unwrap_array(node) return node unless node.is_a?(Prism::ArrayNode) node.elements end |
#unwrap_children(node) ⇒ Object
34 35 36 37 38 |
# File 'lib/deprecool/helpers/prism_helpers.rb', line 34 def unwrap_children(node) return node unless node.respond_to?(:child_nodes) node.child_nodes end |
#unwrap_class(node) ⇒ Object
28 29 30 31 32 |
# File 'lib/deprecool/helpers/prism_helpers.rb', line 28 def unwrap_class(node) return node unless node.is_a?(Prism::ClassNode) node.body end |
#unwrap_parentheses(node) ⇒ Object
(1..10) parses as a ParenthesesNode wrapping the real expression.
5 6 7 8 9 10 |
# File 'lib/deprecool/helpers/prism_helpers.rb', line 5 def unwrap_parentheses(node) return node unless node.is_a?(Prism::ParenthesesNode) body = node.body&.body body&.length == 1 ? body.first : node end |