Class: Roadie::StyleDeclaration
- Inherits:
-
Object
- Object
- Roadie::StyleDeclaration
- Includes:
- Comparable
- Defined in:
- lib/roadie/style_declaration.rb
Instance Attribute Summary collapse
-
#important ⇒ Object
readonly
Returns the value of attribute important.
-
#property ⇒ Object
readonly
Returns the value of attribute property.
-
#specificity ⇒ Object
readonly
Returns the value of attribute specificity.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #important? ⇒ Boolean
-
#initialize(property, value, important, specificity) ⇒ StyleDeclaration
constructor
A new instance of StyleDeclaration.
- #inspect ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(property, value, important, specificity) ⇒ StyleDeclaration
Returns a new instance of StyleDeclaration.
6 7 8 9 10 11 |
# File 'lib/roadie/style_declaration.rb', line 6 def initialize(property, value, important, specificity) @property = property @value = value @important = important @specificity = specificity end |
Instance Attribute Details
#important ⇒ Object (readonly)
Returns the value of attribute important.
4 5 6 |
# File 'lib/roadie/style_declaration.rb', line 4 def important @important end |
#property ⇒ Object (readonly)
Returns the value of attribute property.
4 5 6 |
# File 'lib/roadie/style_declaration.rb', line 4 def property @property end |
#specificity ⇒ Object (readonly)
Returns the value of attribute specificity.
4 5 6 |
# File 'lib/roadie/style_declaration.rb', line 4 def specificity @specificity end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
4 5 6 |
# File 'lib/roadie/style_declaration.rb', line 4 def value @value end |
Instance Method Details
#<=>(other) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/roadie/style_declaration.rb', line 17 def <=>(other) if important == other.important specificity <=> other.specificity else important ? 1 : -1 end end |
#important? ⇒ Boolean
13 14 15 |
# File 'lib/roadie/style_declaration.rb', line 13 def important? @important end |
#inspect ⇒ Object
29 30 31 32 |
# File 'lib/roadie/style_declaration.rb', line 29 def inspect extra = [important ? '!important' : nil, specificity].compact "#{to_s} (#{extra.join(' , ')})" end |
#to_s ⇒ Object
25 26 27 |
# File 'lib/roadie/style_declaration.rb', line 25 def to_s [property, value].join(':') end |