Class: InlineStyle::Rule
- Inherits:
- 
      Object
      
        - Object
- InlineStyle::Rule
 
- Defined in:
- lib/inline-style/rule.rb
Overview
A simple abstraction of the data we get back from the parsers. CSSPool actually already does this for us but CSSParser does not so we need to create the abstraction ourselves.
Constant Summary collapse
- DYNAMIC_PSEUDO_CLASSES =
- %w(link visited active hover focus target enabled disabled checked) 
- DYNAMIC_PSEUDO_CLASSES_MATCHER =
- /:(#{DYNAMIC_PSEUDO_CLASSES.join('|')})$/
Instance Attribute Summary collapse
- 
  
    
      #declarations  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute declarations. 
- 
  
    
      #dynamic_pseudo_class  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute dynamic_pseudo_class. 
- 
  
    
      #selector  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute selector. 
- 
  
    
      #specificity  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute specificity. 
Instance Method Summary collapse
- 
  
    
      #initialize(selector, declarations, specificity)  ⇒ Rule 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of Rule. 
Constructor Details
#initialize(selector, declarations, specificity) ⇒ Rule
Returns a new instance of Rule.
| 11 12 13 14 15 16 | # File 'lib/inline-style/rule.rb', line 11 def initialize selector, declarations, specificity @specificity = specificity @selector, @dynamic_pseudo_class = selector.split DYNAMIC_PSEUDO_CLASSES_MATCHER @selector.sub! /$^/, '*' @declarations = declarations.scan /\s*([^:]+):\s*([^;]+);/ end | 
Instance Attribute Details
#declarations ⇒ Object (readonly)
Returns the value of attribute declarations.
| 9 10 11 | # File 'lib/inline-style/rule.rb', line 9 def declarations @declarations end | 
#dynamic_pseudo_class ⇒ Object (readonly)
Returns the value of attribute dynamic_pseudo_class.
| 9 10 11 | # File 'lib/inline-style/rule.rb', line 9 def dynamic_pseudo_class @dynamic_pseudo_class end | 
#selector ⇒ Object (readonly)
Returns the value of attribute selector.
| 9 10 11 | # File 'lib/inline-style/rule.rb', line 9 def selector @selector end | 
#specificity ⇒ Object (readonly)
Returns the value of attribute specificity.
| 9 10 11 | # File 'lib/inline-style/rule.rb', line 9 def specificity @specificity end |