Class: Roadie::Stylesheet
- Inherits:
-
Object
- Object
- Roadie::Stylesheet
- Defined in:
- lib/roadie/stylesheet.rb
Overview
Domain object that represents a stylesheet (from disc, perhaps).
It has a name and a list of StyleBlocks.
Constant Summary collapse
- BOM =
(+"\xEF\xBB\xBF").force_encoding('UTF-8').freeze
Instance Attribute Summary collapse
-
#blocks ⇒ Array<StyleBlock>
readonly
The current value of blocks.
-
#name ⇒ String
readonly
the name of the stylesheet (“stylesheets/main.css”, “Admin user styles”, etc.).
Instance Method Summary collapse
-
#each_inlinable_block {|selector, properties| ... } ⇒ Object
deprecated
Deprecated.
Iterate over the ##blocks instead. Will be removed on version 4.0.
-
#initialize(name, css) ⇒ Stylesheet
constructor
Parses the CSS string into a StyleBlocks and stores it.
- #to_s ⇒ Object
Constructor Details
#initialize(name, css) ⇒ Stylesheet
Parses the CSS string into a Roadie::StyleBlocks and stores it.
19 20 21 22 |
# File 'lib/roadie/stylesheet.rb', line 19 def initialize(name, css) @name = name @blocks = parse_blocks(css.sub(BOM, "")) end |
Instance Attribute Details
#blocks ⇒ Array<StyleBlock> (readonly)
Returns the current value of blocks.
10 11 12 |
# File 'lib/roadie/stylesheet.rb', line 10 def blocks @blocks end |
#name ⇒ String (readonly)
the name of the stylesheet (“stylesheets/main.css”, “Admin user styles”, etc.). The name of the stylesheet will be visible if any errors occur.
10 11 12 |
# File 'lib/roadie/stylesheet.rb', line 10 def name @name end |
Instance Method Details
#each_inlinable_block {|selector, properties| ... } ⇒ Object
Deprecated.
Iterate over the ##blocks instead. Will be removed on version 4.0.
28 29 30 31 32 33 34 |
# File 'lib/roadie/stylesheet.rb', line 28 def each_inlinable_block(&block) # #map and then #each in order to support chained enumerations, etc. if # no block is provided inlinable_blocks.map { |style_block| [style_block.selector, style_block.properties] }.each(&block) end |
#to_s ⇒ Object
36 37 38 |
# File 'lib/roadie/stylesheet.rb', line 36 def to_s blocks.join("\n") end |