Class: Sass::Tree::Visitors::DeepCopy
- Defined in:
- lib/sass/tree/visitors/deep_copy.rb
Overview
A visitor for copying the full structure of a Sass tree.
Constant Summary
Constants inherited from Base
Instance Method Summary collapse
- #visit(node) protected
- #visit_children(parent) protected
- #visit_debug(node) protected
- #visit_each(node) protected
- #visit_extend(node) protected
- #visit_for(node) protected
- #visit_function(node) protected
- #visit_if(node) protected
- #visit_mixin(node) protected
- #visit_mixindef(node) protected
- #visit_prop(node) protected
- #visit_return(node) protected
- #visit_rule(node) protected
- #visit_variable(node) protected
- #visit_warn(node) protected
- #visit_while(node) protected
Methods inherited from Base
Instance Method Details
#visit(node) (protected)
5 6 7 |
# File 'lib/sass/tree/visitors/deep_copy.rb', line 5
def visit(node)
super(node.dup)
end
|
#visit_children(parent) (protected)
9 10 11 12 |
# File 'lib/sass/tree/visitors/deep_copy.rb', line 9
def visit_children(parent)
parent.children = parent.children.map {|c| visit(c)}
parent
end
|
#visit_debug(node) (protected)
14 15 16 17 |
# File 'lib/sass/tree/visitors/deep_copy.rb', line 14
def visit_debug(node)
node.expr = node.expr.deep_copy
yield
end
|
#visit_each(node) (protected)
19 20 21 22 |
# File 'lib/sass/tree/visitors/deep_copy.rb', line 19
def visit_each(node)
node.list = node.list.deep_copy
yield
end
|
#visit_extend(node) (protected)
24 25 26 27 |
# File 'lib/sass/tree/visitors/deep_copy.rb', line 24
def visit_extend(node)
node.selector = node.selector.map {|c| c.is_a?(Sass::Script::Node) ? c.deep_copy : c}
yield
end
|
#visit_for(node) (protected)
29 30 31 32 33 |
# File 'lib/sass/tree/visitors/deep_copy.rb', line 29
def visit_for(node)
node.from = node.from.deep_copy
node.to = node.to.deep_copy
yield
end
|
#visit_function(node) (protected)
35 36 37 38 |
# File 'lib/sass/tree/visitors/deep_copy.rb', line 35
def visit_function(node)
node.args = node.args.map {|k, v| [k.deep_copy, v && v.deep_copy]}
yield
end
|
#visit_if(node) (protected)
40 41 42 43 44 |
# File 'lib/sass/tree/visitors/deep_copy.rb', line 40
def visit_if(node)
node.expr = node.expr.deep_copy if node.expr
node.else = visit(node.else) if node.else
yield
end
|
#visit_mixin(node) (protected)
51 52 53 54 55 |
# File 'lib/sass/tree/visitors/deep_copy.rb', line 51
def visit_mixin(node)
node.args = node.args.map {|a| a.deep_copy}
node.keywords = Hash[node.keywords.map {|k, v| [k, v.deep_copy]}]
yield
end
|
#visit_mixindef(node) (protected)
46 47 48 49 |
# File 'lib/sass/tree/visitors/deep_copy.rb', line 46
def visit_mixindef(node)
node.args = node.args.map {|k, v| [k.deep_copy, v && v.deep_copy]}
yield
end
|
#visit_prop(node) (protected)
57 58 59 60 61 |
# File 'lib/sass/tree/visitors/deep_copy.rb', line 57
def visit_prop(node)
node.name = node.name.map {|c| c.is_a?(Sass::Script::Node) ? c.deep_copy : c}
node.value = node.value.deep_copy
yield
end
|
#visit_return(node) (protected)
63 64 65 66 |
# File 'lib/sass/tree/visitors/deep_copy.rb', line 63
def visit_return(node)
node.expr = node.expr.deep_copy
yield
end
|
#visit_rule(node) (protected)
68 69 70 71 |
# File 'lib/sass/tree/visitors/deep_copy.rb', line 68
def visit_rule(node)
node.rule = node.rule.map {|c| c.is_a?(Sass::Script::Node) ? c.deep_copy : c}
yield
end
|
#visit_variable(node) (protected)
73 74 75 76 |
# File 'lib/sass/tree/visitors/deep_copy.rb', line 73
def visit_variable(node)
node.expr = node.expr.deep_copy
yield
end
|
#visit_warn(node) (protected)
78 79 80 81 |
# File 'lib/sass/tree/visitors/deep_copy.rb', line 78
def visit_warn(node)
node.expr = node.expr.deep_copy
yield
end
|
#visit_while(node) (protected)
83 84 85 86 |
# File 'lib/sass/tree/visitors/deep_copy.rb', line 83
def visit_while(node)
node.expr = node.expr.deep_copy
yield
end
|