Class: Sass::Tree::Visitors::SetOptions

Inherits:
Base
  • Object
show all
Defined in:
lib/sass/tree/visitors/set_options.rb

Overview

A visitor for setting options on the Sass tree

Constant Summary

Constants inherited from Base

Base::NODE_NAME_RE

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#node_name, #visit_children

Constructor Details

#initialize(options) ⇒ SetOptions (protected)

Returns a new instance of SetOptions.



9
10
11
# File 'lib/sass/tree/visitors/set_options.rb', line 9

def initialize(options)
  @options = options
end

Class Method Details

.visit(root, options)

Parameters:

  • root (Tree::Node)

    The root node of the tree to visit.

  • options ({Symbol => Object})

    The options has to set.



5
# File 'lib/sass/tree/visitors/set_options.rb', line 5

def self.visit(root, options); new(options).send(:visit, root); end

Instance Method Details

#visit(node) (protected)



13
14
15
16
# File 'lib/sass/tree/visitors/set_options.rb', line 13

def visit(node)
  node.instance_variable_set('@options', @options)
  super
end

#visit_debug(node) (protected)



18
19
20
21
# File 'lib/sass/tree/visitors/set_options.rb', line 18

def visit_debug(node)
  node.expr.options = @options
  yield
end

#visit_each(node) (protected)



23
24
25
26
# File 'lib/sass/tree/visitors/set_options.rb', line 23

def visit_each(node)
  node.list.options = @options
  yield
end

#visit_extend(node) (protected)



28
29
30
31
# File 'lib/sass/tree/visitors/set_options.rb', line 28

def visit_extend(node)
  node.selector.each {|c| c.options = @options if c.is_a?(Sass::Script::Node)}
  yield
end

#visit_for(node) (protected)



33
34
35
36
37
# File 'lib/sass/tree/visitors/set_options.rb', line 33

def visit_for(node)
  node.from.options = @options
  node.to.options = @options
  yield
end

#visit_function(node) (protected)



39
40
41
42
43
44
45
# File 'lib/sass/tree/visitors/set_options.rb', line 39

def visit_function(node)
  node.args.each do |k, v|
    k.options = @options
    v.options = @options if v
  end
  yield
end

#visit_if(node) (protected)



47
48
49
50
51
# File 'lib/sass/tree/visitors/set_options.rb', line 47

def visit_if(node)
  node.expr.options = @options if node.expr
  visit(node.else) if node.else
  yield
end

#visit_mixin(node) (protected)



61
62
63
64
65
# File 'lib/sass/tree/visitors/set_options.rb', line 61

def visit_mixin(node)
  node.args.each {|a| a.options = @options}
  node.keywords.each {|k, v| v.options = @options}
  yield
end

#visit_mixindef(node) (protected)



53
54
55
56
57
58
59
# File 'lib/sass/tree/visitors/set_options.rb', line 53

def visit_mixindef(node)
  node.args.each do |k, v|
    k.options = @options
    v.options = @options if v
  end
  yield
end

#visit_prop(node) (protected)



67
68
69
70
71
# File 'lib/sass/tree/visitors/set_options.rb', line 67

def visit_prop(node)
  node.name.each {|c| c.options = @options if c.is_a?(Sass::Script::Node)}
  node.value.options = @options
  yield
end

#visit_return(node) (protected)



73
74
75
76
# File 'lib/sass/tree/visitors/set_options.rb', line 73

def visit_return(node)
  node.expr.options = @options
  yield
end

#visit_rule(node) (protected)



78
79
80
81
# File 'lib/sass/tree/visitors/set_options.rb', line 78

def visit_rule(node)
  node.rule.each {|c| c.options = @options if c.is_a?(Sass::Script::Node)}
  yield
end

#visit_variable(node) (protected)



83
84
85
86
# File 'lib/sass/tree/visitors/set_options.rb', line 83

def visit_variable(node)
  node.expr.options = @options
  yield
end

#visit_warn(node) (protected)



88
89
90
91
# File 'lib/sass/tree/visitors/set_options.rb', line 88

def visit_warn(node)
  node.expr.options = @options
  yield
end

#visit_while(node) (protected)



93
94
95
96
# File 'lib/sass/tree/visitors/set_options.rb', line 93

def visit_while(node)
  node.expr.options = @options
  yield
end