Class: CSSPool::CSS::Document

### Home Classes Methods

### In Files

- lib/csspool/css/document.rb

### Parent

Node

### Methods

- ::new
- ::parse
- #[]

### Files

- CHANGELOG.rdoc
- Manifest.txt

### Class/Module Index

Quicksearch

- CSSPool
- CSSPool::CSS
- CSSPool::CSS::Charset
- CSSPool::CSS::Declaration
- CSSPool::CSS::Document
- CSSPool::CSS::DocumentHandler
- CSSPool::CSS::DocumentQuery
- CSSPool::CSS::FontfaceRule
- CSSPool::CSS::ImportRule
- CSSPool::CSS::KeyframesBlock
- CSSPool::CSS::KeyframesRule
- CSSPool::CSS::MediaFeature
- CSSPool::CSS::MediaQuery
- CSSPool::CSS::MediaQueryList
- CSSPool::CSS::MediaType
- CSSPool::CSS::NamespaceRule
- CSSPool::CSS::Parser
- CSSPool::CSS::RuleSet
- CSSPool::CSS::SupportsRule
- CSSPool::CSS::Tokenizer
- CSSPool::CSS::Tokenizer::ScanError
- CSSPool::Collection
- CSSPool::Node
- CSSPool::SAC
- CSSPool::SAC::Document
- CSSPool::SAC::Parser
- CSSPool::Selector
- CSSPool::Selectors
- CSSPool::Selectors::Additional
- CSSPool::Selectors::Attribute
- CSSPool::Selectors::Class
- CSSPool::Selectors::Id
- CSSPool::Selectors::PseudoClass
- CSSPool::Selectors::PseudoElement
- CSSPool::Selectors::Simple
- CSSPool::Selectors::Type
- CSSPool::Selectors::Universal
- CSSPool::Terms
- CSSPool::Terms::Function
- CSSPool::Terms::Hash
- CSSPool::Terms::Ident
- CSSPool::Terms::Math
- CSSPool::Terms::Number
- CSSPool::Terms::Ratio
- CSSPool::Terms::Resolution
- CSSPool::Terms::Rgb
- CSSPool::Terms::String
- CSSPool::Terms::URI
- CSSPool::Visitors
- CSSPool::Visitors::Children
- CSSPool::Visitors::Comparable
- CSSPool::Visitors::Iterator
- CSSPool::Visitors::ToCSS
- CSSPool::Visitors::ToMinifiedCSS
- CSSPool::Visitors::Visitor

No matching classes.

# CSSPool::CSS::Document

### Attributes

charsets[RW]
document_queries[RW]
fontface_rules[RW]
import_rules[RW]
keyframes_rules[RW]
namespaces[RW]
parent[RW]
parent_import_rule[RW]
rule_sets[RW]
supports_rules[RW]

### Public Class Methods

new() click to toggle source

    # File lib/csspool/css/document.rb, line 32
    def initialize
      @rule_sets    = []
      @charsets     = []
      @import_rules = []
      @document_queries = []
      @supports_rules = []
      @namespaces   = []
      @parent       = nil
      @parent_import_rule = nil
      @keyframes_rules = []
      @fontface_rules = []
    end

parse(string) click to toggle source

    # File lib/csspool/css/document.rb, line 4
    def self.parse string
      # If a File object gets passed in, via functions like File.open
      # or Kernel::open
      if string.respond_to? :read
        string = string.read
      end

      unless string && string.length > 0
        return CSSPool::CSS::Document.new
      end

      handler = CSSPool::CSS::DocumentHandler.new
      parser = CSSPool::SAC::Parser.new(handler)
      parser.parse(string)
      handler.document
    end

### Public Instance Methods

[](selector) click to toggle source

    # File lib/csspool/css/document.rb, line 45
    def [] selector
      selectors = CSSPool.CSS("#{selector} {}").rule_sets.first.selectors
      rule_sets.find_all { |rs| rs.selectors == selectors }
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.