Class: CSSPool::Collection

### Home Classes Methods

### In Files

- lib/csspool/collection.rb

### Parent

Object

### Methods

- ::new
- #<<
- #[]
- #each
- #last
- #length

### Included Modules

- Enumerable

### Files

- CHANGELOG.rdoc
- Manifest.txt
- README.rdoc

### Class/Module Index

Quicksearch

- CSSPool
- CSSPool::CSS
- CSSPool::CSS::Charset
- CSSPool::CSS::Declaration
- CSSPool::CSS::Document
- CSSPool::CSS::DocumentHandler
- CSSPool::CSS::ImportRule
- CSSPool::CSS::Media
- CSSPool::CSS::Parser
- CSSPool::CSS::RuleSet
- 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::Simple
- CSSPool::Selectors::Type
- CSSPool::Selectors::Universal
- CSSPool::Terms
- CSSPool::Terms::Function
- CSSPool::Terms::Hash
- CSSPool::Terms::Ident
- CSSPool::Terms::Number
- 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::Collection

### Public Class Methods

new(&block) click to toggle source

    # File lib/csspool/collection.rb, line 5
    def initialize &block
      @docs   = []
      @block  = block
    end

### Public Instance Methods

<<(string) click to toggle source

    # File lib/csspool/collection.rb, line 10
    def << string
      doc = CSSPool.CSS string

      import_tree = [[doc]]

      imported_urls = {}

      until import_tree.last.all? { |x| x.import_rules.length == 0 }
        level = import_tree.last
        import_tree << []
        level.each do |l|
          l.import_rules.each do |ir|
            next if imported_urls.key? ir.uri

            new_doc = ir.load(&@block)

            imported_urls[ir.uri] = ir.load(&@block)
            import_tree.last << new_doc
          end
        end
      end

      @docs += import_tree.flatten.reverse
      self
    end

[](idx) click to toggle source

    # File lib/csspool/collection.rb, line 40
    def [] idx
      @docs[idx]
    end

each(&block) click to toggle source

    # File lib/csspool/collection.rb, line 44
    def each &block
      @docs.each(&block)
    end

last() click to toggle source

    # File lib/csspool/collection.rb, line 48
    def last; @docs.last; end

length() click to toggle source

    # File lib/csspool/collection.rb, line 36
    def length
      @docs.length
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.