Class: Roadie::StyleDeclaration

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/roadie/style_declaration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#importantObject (readonly)

Returns the value of attribute important


4
5
6
# File 'lib/roadie/style_declaration.rb', line 4

def important
  @important
end

#propertyObject (readonly)

Returns the value of attribute property


4
5
6
# File 'lib/roadie/style_declaration.rb', line 4

def property
  @property
end

#specificityObject (readonly)

Returns the value of attribute specificity


4
5
6
# File 'lib/roadie/style_declaration.rb', line 4

def specificity
  @specificity
end

#valueObject (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

Returns:

  • (Boolean)

13
14
15
# File 'lib/roadie/style_declaration.rb', line 13

def important?
  @important
end

#inspectObject


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_sObject


25
26
27
# File 'lib/roadie/style_declaration.rb', line 25

def to_s
  [property, value].join(':')
end