Class: Stylish::Stylesheet

Inherits:
Tree::SelectorScope show all
Defined in:
lib/stylish/core.rb

Instance Attribute Summary

Attributes inherited from Tree::SelectorScope

#nodes

Instance Method Summary collapse

Methods inherited from Tree::SelectorScope

#<<, #[], #[]=, #comments, #delete, #leaves, #rules, #to_a

Methods included from Formattable

included

Methods included from Tree::Node

#leaf?

Constructor Details

#initializeStylesheet

Stylesheets are pure aggregate objects; they can contain child nodes, but have no data of their own. Their initializer therefore accepts no arguments.



26
27
28
# File 'lib/stylish/core.rb', line 26

def initialize
  @nodes = []
end

Instance Method Details

#root?Boolean

Stylesheets are the roots of selector trees.

Returns:

  • (Boolean)


31
32
33
# File 'lib/stylish/core.rb', line 31

def root?
  true
end

#to_s(symbols = {}) ⇒ Object

Recursively serialise the tree to a stylesheet.



36
37
38
39
# File 'lib/stylish/core.rb', line 36

def to_s(symbols = {})
  return "" if @nodes.empty?
  @nodes.map {|node| node.to_s(symbols) }.join(self.class.format)
end