Class: Roadie::StyleProperty Private

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#importantBoolean (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”.

Returns:

  • (Boolean)

    the current value of important



11
12
13
# File 'lib/roadie/style_property.rb', line 11

def important
  @important
end

#propertyObject (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.

TODO:

Rename #property to #name



11
12
13
# File 'lib/roadie/style_property.rb', line 11

def property
  @property
end

#specificityInteger (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.

Returns:

  • (Integer)

    the current value of specificity



11
12
13
# File 'lib/roadie/style_property.rb', line 11

def specificity
  @specificity
end

#valueString (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”).

Returns:

  • (String)

    the current value of value



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.

Returns:

  • (Boolean)


26
27
28
# File 'lib/roadie/style_property.rb', line 26

def important?
  @important
end

#inspectObject

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
  "#{to_s} (#{specificity})"
end

#to_sObject

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