class Roadie::StyleProperty
@api private Domain object for a CSS property such as “color: red !important”.
@attr_reader [String] property name of the property (such as “font-size”). @attr_reader [String] value value of the property (such as “5px solid green”). @attr_reader [Boolean] important if the property is “!important”. @attr_reader [Integer] specificity specificity of parent {Selector}. Used to compare/sort.
Attributes
important[R]
property[R]
@todo Rename property to name
specificity[R]
value[R]
Public Class Methods
new(property, value, important, specificity)
click to toggle source
# File lib/roadie/style_property.rb, line 17 def initialize(property, value, important, specificity) @property = property @value = value @important = important @specificity = specificity end
Public Instance Methods
<=>(other)
click to toggle source
Compare another {StyleProperty}. Important styles are “greater than” non-important ones; otherwise the specificity declares order.
# File lib/roadie/style_property.rb, line 30 def <=>(other) if important == other.important specificity <=> other.specificity else important ? 1 : -1 end end
important?()
click to toggle source
# File lib/roadie/style_property.rb, line 24 def important? @important end
inspect()
click to toggle source
# File lib/roadie/style_property.rb, line 42 def inspect "#{to_s} (#{specificity})" end
to_s()
click to toggle source
# File lib/roadie/style_property.rb, line 38 def to_s [property, value_with_important].join(':') end
Private Instance Methods
value_with_important()
click to toggle source
# File lib/roadie/style_property.rb, line 47 def value_with_important if important "#{value} !important" else value end end