Class: Mayu::Resources::Transformers::Haml::MutationVisitor
- Inherits:
-
SyntaxTree::Visitor::MutationVisitor
- Object
- SyntaxTree::Visitor::MutationVisitor
- Mayu::Resources::Transformers::Haml::MutationVisitor
- Defined in:
- lib/mayu/resources/transformers/haml.rb
Class Method Summary collapse
-
.build(&block) ⇒ Object
This class visits more nodes than the parent class.
Instance Method Summary collapse
- #visit_aref(node) ⇒ Object
- #visit_assign(node) ⇒ Object
- #visit_assoc(node) ⇒ Object
- #visit_assoc_splat(node) ⇒ Object
- #visit_binary(node) ⇒ Object
- #visit_if_op(node) ⇒ Object
- #visit_opassign(node) ⇒ Object
Class Method Details
.build(&block) ⇒ Object
This class visits more nodes than the parent class. This should probably be fixed in the syntax_tree gem, but I don't know what other nodes need to be fixed.
24 25 26 |
# File 'lib/mayu/resources/transformers/haml.rb', line 24 def self.build(&block) new.tap { yield _1 } end |
Instance Method Details
#visit_aref(node) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/mayu/resources/transformers/haml.rb', line 40 def visit_aref(node) node.copy( collection: visit(node.collection), index: visit(node.index) ) end |
#visit_assign(node) ⇒ Object
28 29 30 |
# File 'lib/mayu/resources/transformers/haml.rb', line 28 def visit_assign(node) node.copy(target: visit(node.target), value: visit(node.value)) end |
#visit_assoc(node) ⇒ Object
36 37 38 |
# File 'lib/mayu/resources/transformers/haml.rb', line 36 def visit_assoc(node) node.copy(key: visit(node.key), value: visit(node.value)) end |
#visit_assoc_splat(node) ⇒ Object
32 33 34 |
# File 'lib/mayu/resources/transformers/haml.rb', line 32 def visit_assoc_splat(node) node.copy(value: visit(node.value)) end |
#visit_binary(node) ⇒ Object
51 52 53 |
# File 'lib/mayu/resources/transformers/haml.rb', line 51 def visit_binary(node) node.copy(left: visit(node.left), right: visit(node.right)) end |
#visit_if_op(node) ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/mayu/resources/transformers/haml.rb', line 55 def visit_if_op(node) node.copy( predicate: visit(node.predicate), truthy: visit(node.truthy), falsy: visit(node.falsy) ) end |
#visit_opassign(node) ⇒ Object
47 48 49 |
# File 'lib/mayu/resources/transformers/haml.rb', line 47 def visit_opassign(node) node.copy(target: visit(node.target), value: visit(node.value)) end |