Class: Roadie::StyleProperty Private
- Inherits:
-
Object
- Object
- Roadie::StyleProperty
- Includes:
- Comparable
- Defined in:
- lib/roadie/style_property.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.
Domain object for a CSS property such as “color: red !important”.
Instance Attribute Summary collapse
-
#important ⇒ Boolean
readonly
private
if the property is “!important”.
- #property ⇒ Object readonly private
-
#specificity ⇒ Integer
readonly
private
specificity of parent Selector.
-
#value ⇒ String
readonly
private
value of the property (such as “5px solid green”).
Class Method Summary collapse
-
.parse(declaration, specificity) ⇒ Object
private
Parse a property string.
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
private
Compare another StyleProperty.
- #important? ⇒ Boolean private
-
#initialize(property, value, important, specificity) ⇒ StyleProperty
constructor
private
A new instance of StyleProperty.
- #inspect ⇒ Object private
- #to_s ⇒ Object private
Constructor Details
#initialize(property, value, important, specificity) ⇒ StyleProperty
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 StyleProperty.
28 29 30 31 32 33 |
# File 'lib/roadie/style_property.rb', line 28 def initialize(property, value, important, specificity) @property = property @value = value @important = important @specificity = specificity end |
Instance Attribute Details
#important ⇒ Boolean (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.
if the property is “!important”.
9 10 11 |
# File 'lib/roadie/style_property.rb', line 9 def important @important end |
#property ⇒ 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.
Rename #property to #name
9 10 11 |
# File 'lib/roadie/style_property.rb', line 9 def property @property end |
#specificity ⇒ Integer (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.
specificity of parent Roadie::Selector. Used to compare/sort.
9 10 11 |
# File 'lib/roadie/style_property.rb', line 9 def specificity @specificity end |
#value ⇒ String (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.
value of the property (such as “5px solid green”).
9 10 11 |
# File 'lib/roadie/style_property.rb', line 9 def value @value end |
Class Method Details
.parse(declaration, specificity) ⇒ Object
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.
Parse a property string.
24 25 26 |
# File 'lib/roadie/style_property.rb', line 24 def self.parse(declaration, specificity) allocate.send :read_declaration!, declaration, specificity end |
Instance Method Details
#<=>(other) ⇒ Object
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.
Compare another Roadie::StyleProperty. Important styles are “greater than” non-important ones; otherwise the specificity declares order.
41 42 43 44 45 46 47 |
# File 'lib/roadie/style_property.rb', line 41 def <=>(other) if important == other.important specificity <=> other.specificity else important ? 1 : -1 end end |
#important? ⇒ 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.
35 36 37 |
# File 'lib/roadie/style_property.rb', line 35 def important? @important end |
#inspect ⇒ Object
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.
53 54 55 |
# File 'lib/roadie/style_property.rb', line 53 def inspect "#{to_s} (#{specificity})" end |
#to_s ⇒ Object
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.
49 50 51 |
# File 'lib/roadie/style_property.rb', line 49 def to_s [property, value_with_important].join(':') end |