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”).
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.
19 20 21 22 23 24 |
# File 'lib/roadie/style_property.rb', line 19 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”.
11 12 13 |
# File 'lib/roadie/style_property.rb', line 11 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
11 12 13 |
# File 'lib/roadie/style_property.rb', line 11 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.
11 12 13 |
# File 'lib/roadie/style_property.rb', line 11 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”).
11 12 13 |
# File 'lib/roadie/style_property.rb', line 11 def value @value 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.
32 33 34 35 36 37 38 |
# File 'lib/roadie/style_property.rb', line 32 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.
26 27 28 |
# File 'lib/roadie/style_property.rb', line 26 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.
44 45 46 |
# File 'lib/roadie/style_property.rb', line 44 def inspect "#{self} (#{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.
40 41 42 |
# File 'lib/roadie/style_property.rb', line 40 def to_s [property, value_with_important].join(":") end |