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

Inherits:
Base
  • Object
show all
Defined in:
/home/nweiz/code/sass-site/.sass/lib/sass/tree/visitors/set_options.rb

Overview

A visitor for setting options on the Sass tree

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from Base

node_name, #visit_children

Constructor Details

- (SetOptions) initialize(options) (protected)

Returns a new instance of SetOptions



9
10
11
# File '/home/nweiz/code/sass-site/.sass/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 '/home/nweiz/code/sass-site/.sass/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 '/home/nweiz/code/sass-site/.sass/lib/sass/tree/visitors/set_options.rb', line 13

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

- visit_comment(node) (protected)



18
19
20
21
# File '/home/nweiz/code/sass-site/.sass/lib/sass/tree/visitors/set_options.rb', line 18

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

- visit_cssimport(node) (protected)



130
131
132
133
# File '/home/nweiz/code/sass-site/.sass/lib/sass/tree/visitors/set_options.rb', line 130

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

- visit_debug(node) (protected)



23
24
25
26
# File '/home/nweiz/code/sass-site/.sass/lib/sass/tree/visitors/set_options.rb', line 23

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

- visit_directive(node) (protected)



120
121
122
123
# File '/home/nweiz/code/sass-site/.sass/lib/sass/tree/visitors/set_options.rb', line 120

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

- visit_each(node) (protected)



33
34
35
36
# File '/home/nweiz/code/sass-site/.sass/lib/sass/tree/visitors/set_options.rb', line 33

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

- visit_error(node) (protected)



28
29
30
31
# File '/home/nweiz/code/sass-site/.sass/lib/sass/tree/visitors/set_options.rb', line 28

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

- visit_extend(node) (protected)



38
39
40
41
# File '/home/nweiz/code/sass-site/.sass/lib/sass/tree/visitors/set_options.rb', line 38

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

- visit_for(node) (protected)



43
44
45
46
47
# File '/home/nweiz/code/sass-site/.sass/lib/sass/tree/visitors/set_options.rb', line 43

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

- visit_function(node) (protected)



49
50
51
52
53
54
55
56
# File '/home/nweiz/code/sass-site/.sass/lib/sass/tree/visitors/set_options.rb', line 49

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

- visit_if(node) (protected)



58
59
60
61
62
# File '/home/nweiz/code/sass-site/.sass/lib/sass/tree/visitors/set_options.rb', line 58

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

- visit_import(node) (protected)



64
65
66
67
68
69
70
# File '/home/nweiz/code/sass-site/.sass/lib/sass/tree/visitors/set_options.rb', line 64

def visit_import(node)
  # We have no good way of propagating the new options through an Engine
  # instance, so we just null it out. This also lets us avoid caching an
  # imported Engine along with the importing source tree.
  node.imported_file = nil
  yield
end

- visit_media(node) (protected)



125
126
127
128
# File '/home/nweiz/code/sass-site/.sass/lib/sass/tree/visitors/set_options.rb', line 125

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

- visit_mixin(node) (protected)



81
82
83
84
85
86
87
# File '/home/nweiz/code/sass-site/.sass/lib/sass/tree/visitors/set_options.rb', line 81

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

- visit_mixindef(node) (protected)



72
73
74
75
76
77
78
79
# File '/home/nweiz/code/sass-site/.sass/lib/sass/tree/visitors/set_options.rb', line 72

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

- visit_prop(node) (protected)



89
90
91
92
93
# File '/home/nweiz/code/sass-site/.sass/lib/sass/tree/visitors/set_options.rb', line 89

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

- visit_return(node) (protected)



95
96
97
98
# File '/home/nweiz/code/sass-site/.sass/lib/sass/tree/visitors/set_options.rb', line 95

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

- visit_rule(node) (protected)



100
101
102
103
# File '/home/nweiz/code/sass-site/.sass/lib/sass/tree/visitors/set_options.rb', line 100

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

- visit_supports(node) (protected)



135
136
137
138
# File '/home/nweiz/code/sass-site/.sass/lib/sass/tree/visitors/set_options.rb', line 135

def visit_supports(node)
  node.condition.options = @options
  yield
end

- visit_variable(node) (protected)



105
106
107
108
# File '/home/nweiz/code/sass-site/.sass/lib/sass/tree/visitors/set_options.rb', line 105

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

- visit_warn(node) (protected)



110
111
112
113
# File '/home/nweiz/code/sass-site/.sass/lib/sass/tree/visitors/set_options.rb', line 110

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

- visit_while(node) (protected)



115
116
117
118
# File '/home/nweiz/code/sass-site/.sass/lib/sass/tree/visitors/set_options.rb', line 115

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