Class: Stylish::Stylesheet
- Inherits:
-
Tree::SelectorScope
- Object
- Tree::SelectorScope
- Stylish::Stylesheet
- Defined in:
- lib/stylish/stylesheet.rb
Instance Attribute Summary
Attributes inherited from Tree::SelectorScope
Attributes included from Formattable
Instance Method Summary collapse
-
#initialize ⇒ Stylesheet
constructor
Stylesheets are pure aggregate objects; they can contain child nodes, but have no data of their own.
-
#root? ⇒ Boolean
Stylesheets are the roots of selector trees.
-
#to_s(symbols = {}) ⇒ Object
Recursively serialise the tree to a stylesheet.
Methods inherited from Tree::SelectorScope
#<<, #[], #[]=, #comments, #delete, #leaves, #rules, #to_a
Methods included from Tree::Node
Constructor Details
#initialize ⇒ Stylesheet
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.
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 |