Class: Roadie::StyleBlock Private
- Inherits:
-
Object
- Object
- Roadie::StyleBlock
- Extended by:
- Forwardable
- Defined in:
- lib/roadie/style_block.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
A style block is the combination of a Selector and a list of StyleProperty.
Instance Attribute Summary collapse
- #media ⇒ Object readonly private
- #properties ⇒ Object readonly private
- #selector ⇒ Object readonly private
Instance Method Summary collapse
-
#initialize(selector, properties, media) ⇒ StyleBlock
constructor
private
A new instance of StyleBlock.
-
#inlinable? ⇒ Boolean
private
Checks whether the media query can be inlined.
- #selector_string ⇒ Object
- #specificity ⇒ Object
-
#to_s ⇒ String
private
String representation of the style block.
Constructor Details
#initialize(selector, properties, media) ⇒ StyleBlock
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of StyleBlock.
15 16 17 18 19 |
# File 'lib/roadie/style_block.rb', line 15 def initialize(selector, properties, media) @selector = selector @properties = properties @media = media.map(&:to_s) end |
Instance Attribute Details
#media ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
8 9 10 |
# File 'lib/roadie/style_block.rb', line 8 def media @media end |
#properties ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
8 9 10 |
# File 'lib/roadie/style_block.rb', line 8 def properties @properties end |
#selector ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
8 9 10 |
# File 'lib/roadie/style_block.rb', line 8 def selector @selector end |
Instance Method Details
#inlinable? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Checks whether the media query can be inlined
31 32 33 |
# File 'lib/roadie/style_block.rb', line 31 def inlinable? inlinable_media? && selector.inlinable? end |
#selector_string ⇒ Object
26 |
# File 'lib/roadie/style_block.rb', line 26 def_delegator :selector, :to_s, :selector_string |
#specificity ⇒ Object
23 |
# File 'lib/roadie/style_block.rb', line 23 def_delegators :selector, :specificity |
#to_s ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
String representation of the style block. This is valid CSS and can be used in the DOM.
38 39 40 41 |
# File 'lib/roadie/style_block.rb', line 38 def to_s # NB - leave off redundant final semicolon - see https://www.w3.org/TR/CSS2/syndata.html#declaration "#{selector}{#{properties.map(&:to_s).join(';')}}" end |