Class: Compass::Stats::StatsVisitor
- Inherits:
-
Object
- Object
- Compass::Stats::StatsVisitor
- Defined in:
- lib/compass/stats.rb
Instance Attribute Summary collapse
-
#mixin_count ⇒ Object
Returns the value of attribute mixin_count.
-
#mixin_def_count ⇒ Object
Returns the value of attribute mixin_def_count.
-
#prop_count ⇒ Object
Returns the value of attribute prop_count.
-
#rule_count ⇒ Object
Returns the value of attribute rule_count.
Instance Method Summary collapse
- #down(node) ⇒ Object
- #import?(node) ⇒ Boolean
-
#initialize ⇒ StatsVisitor
constructor
A new instance of StatsVisitor.
- #up(node) ⇒ Object
- #visit(node) ⇒ Object
Constructor Details
#initialize ⇒ StatsVisitor
Returns a new instance of StatsVisitor.
5 6 7 8 9 10 |
# File 'lib/compass/stats.rb', line 5 def initialize self.rule_count = 0 self.prop_count = 0 self.mixin_def_count = 0 self.mixin_count = 0 end |
Instance Attribute Details
#mixin_count ⇒ Object
Returns the value of attribute mixin_count.
4 5 6 |
# File 'lib/compass/stats.rb', line 4 def mixin_count @mixin_count end |
#mixin_def_count ⇒ Object
Returns the value of attribute mixin_def_count.
4 5 6 |
# File 'lib/compass/stats.rb', line 4 def mixin_def_count @mixin_def_count end |
#prop_count ⇒ Object
Returns the value of attribute prop_count.
4 5 6 |
# File 'lib/compass/stats.rb', line 4 def prop_count @prop_count end |
#rule_count ⇒ Object
Returns the value of attribute rule_count.
4 5 6 |
# File 'lib/compass/stats.rb', line 4 def rule_count @rule_count end |
Instance Method Details
#down(node) ⇒ Object
21 22 |
# File 'lib/compass/stats.rb', line 21 def down(node) end |
#import?(node) ⇒ Boolean
23 24 25 26 27 |
# File 'lib/compass/stats.rb', line 23 def import?(node) return false full_filename = node.send(:import) full_filename != Compass.deprojectize(full_filename) end |
#up(node) ⇒ Object
19 20 |
# File 'lib/compass/stats.rb', line 19 def up(node) end |
#visit(node) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/compass/stats.rb', line 11 def visit(node) self.prop_count += 1 if node.is_a?(Sass::Tree::PropNode) && !node.children.any? if node.is_a?(Sass::Tree::RuleNode) self.rule_count += node.rule.reject{|r| r.is_a?(Sass::Script::Tree::Node)}.map{|r| r.split(/,/)}.flatten.compact.size end self.mixin_def_count += 1 if node.is_a?(Sass::Tree::MixinDefNode) self.mixin_count += 1 if node.is_a?(Sass::Tree::MixinNode) end |