class DryCss::CSS
Attributes
parser[R]
Public Class Methods
new(*uris)
click to toggle source
# File lib/dry_css/css.rb, line 4 def initialize(*uris) @parser = load_uris(uris) end
Public Instance Methods
colors()
click to toggle source
# File lib/dry_css/css.rb, line 8 def colors @colors ||= scan_for(CssParser::RE_COLOUR) end
sorted(scan)
click to toggle source
# File lib/dry_css/css.rb, line 12 def sorted(scan) scan.sort_by{|k,v| v }.reverse end
Private Instance Methods
load_uris(uris)
click to toggle source
# File lib/dry_css/css.rb, line 18 def load_uris(uris) parser = DryCss::Parser.new threads = [] uris.each do |u| threads << Thread.new(u) do |uri| begin parser.load_uri!(uri) rescue CssParser::RemoteFileError end end end threads.each{|thr| thr.join } return parser end
scan_for(property)
click to toggle source
# File lib/dry_css/css.rb, line 33 def scan_for(property) values_hash = {:counts => Hash.new(0), :total => 0} @parser.each_selector do |selector, declarations, specificity| declarations.scan(/([\.\w:]+)?(#{property})/) do |prop,val| values_hash[:counts][val.to_sym] += 1 values_hash[:total] += 1 end end return values_hash end