Class: CssParser::Parser
- Inherits:
-
Object
- Object
- CssParser::Parser
- Defined in:
- lib/webpage-archivist/stylesheet_document.rb
Instance Attribute Summary collapse
-
#imports ⇒ Object
readonly
Returns the value of attribute imports.
Instance Method Summary collapse
-
#add_block_archivist(block, options = {}) ⇒ Object
Adapted from add_block! so the imports are listed instead of fetched.
-
#to_s(media_types = :all) ⇒ Object
Add the imports first.
Instance Attribute Details
#imports ⇒ Object (readonly)
Returns the value of attribute imports.
16 17 18 |
# File 'lib/webpage-archivist/stylesheet_document.rb', line 16 def imports @imports end |
Instance Method Details
#add_block_archivist(block, options = {}) ⇒ Object
Adapted from add_block! so the imports are listed instead of fetched
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/webpage-archivist/stylesheet_document.rb', line 29 def add_block_archivist(block, = {}) @imports ||= [] = {:base_uri => nil, :base_dir => nil, :charset => nil, :media_types => :all, :only_media_types => :all}.merge() [:media_types] = [[:media_types]].flatten [:only_media_types] = [[:only_media_types]].flatten block = cleanup_block(block) if [:base_uri] and @options[:absolute_paths] block = CssParser.convert_uris(block, [:base_uri]) end # List @imported CSS block.scan(RE_AT_IMPORT_RULE).each do |import_rule| imports << import_rule[0].to_s.gsub(/['"]*/, '').strip end block.gsub!(RE_AT_IMPORT_RULE, '') parse_block_into_rule_sets!(block, ) end |
#to_s(media_types = :all) ⇒ Object
Add the imports first
19 20 21 22 23 24 25 26 |
# File 'lib/webpage-archivist/stylesheet_document.rb', line 19 def to_s(media_types = :all) out = imports ? "#{imports.collect { |i| "@import url(\"#{i}\");" }.join("\n")}\n\n" : '' each_selector(media_types) do |selectors, declarations, specificity| out << "#{selectors} {\n#{declarations}\n}\n" end out end |