Class: Stylish::Stylesheet

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

Instance Attribute Summary

Attributes inherited from Tree::SelectorScope

#nodes

Attributes included from Formattable

#format

Instance Method Summary collapse

Methods inherited from Tree::SelectorScope

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

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.



8
9
10
11
# File 'lib/stylish/stylesheet.rb', line 8

def initialize
  accept_format(/\s*/m, "\n")
  @nodes = []
end

Instance Method Details

#root?Boolean

Stylesheets are the roots of selector trees.

Returns:

  • (Boolean)


14
15
16
# File 'lib/stylish/stylesheet.rb', line 14

def root?
  true
end

#to_s(symbols = {}) ⇒ Object

Recursively serialise the tree to a stylesheet.



19
20
21
22
# File 'lib/stylish/stylesheet.rb', line 19

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