Class: RSAC::StyleSheet::Rule

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/antisamy/csspool/rsac/stylesheet/rule.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(selector, index, properties = []) ⇒ Rule

Returns a new instance of Rule.



8
9
10
11
12
# File 'lib/antisamy/csspool/rsac/stylesheet/rule.rb', line 8

def initialize(selector, index, properties = [])
  @selector = selector
  @properties = Set.new(properties)
  @index = index
end

Instance Attribute Details

#indexObject

Returns the value of attribute index.



7
8
9
# File 'lib/antisamy/csspool/rsac/stylesheet/rule.rb', line 7

def index
  @index
end

#propertiesObject

Returns the value of attribute properties.



7
8
9
# File 'lib/antisamy/csspool/rsac/stylesheet/rule.rb', line 7

def properties
  @properties
end

#selectorObject

Returns the value of attribute selector.



7
8
9
# File 'lib/antisamy/csspool/rsac/stylesheet/rule.rb', line 7

def selector
  @selector
end

Instance Method Details

#<=>(other) ⇒ Object



14
15
16
17
# File 'lib/antisamy/csspool/rsac/stylesheet/rule.rb', line 14

def <=>(other)
  comp = selector.specificity <=> other.selector.specificity
  comp == 0 ? index <=> other.index : comp
end