Module: Synvert::SexpHelper
- Included in:
- BaseConverter
- Defined in:
- lib/synvert/sexp_helper.rb
Instance Method Summary collapse
- #body(node) ⇒ Object
- #contains_statement?(node, statement) ⇒ Boolean
- #message(node) ⇒ Object
- #name(node) ⇒ Object
- #receiver(node) ⇒ Object
- #to_ast(str) ⇒ Object
Instance Method Details
#body(node) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/synvert/sexp_helper.rb', line 11 def body(node) case node.type when :class node.children[1] when :block node.children[2] else end end |
#contains_statement?(node, statement) ⇒ Boolean
41 42 43 44 45 |
# File 'lib/synvert/sexp_helper.rb', line 41 def contains_statement?(node, statement) node && (node.type == :begin ? node.children : [node]).any? { |child_node| child_node == to_ast(statement) } end |
#message(node) ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/synvert/sexp_helper.rb', line 31 def (node) case node.type when :send node.children[1] when :block (node.children[0]) else end end |
#name(node) ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/synvert/sexp_helper.rb', line 3 def name(node) case node.type when :class node.children[0] else end end |
#receiver(node) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/synvert/sexp_helper.rb', line 21 def receiver(node) case node.type when :send node.children[0] when :block receiver(node.children[0]) else end end |
#to_ast(str) ⇒ Object
47 48 49 |
# File 'lib/synvert/sexp_helper.rb', line 47 def to_ast(str) Parser::CurrentRuby.parse(str) end |