Class: MakeBook::Formats::HTML::Stylesheet
- Defined in:
- lib/makebook/formats/html.rb
Overview
Stylesheet asset
Constant Summary collapse
- TYPES =
{ 'eot' => 'application/vnd.ms-fontobject', 'otf' => 'application/font-sfnt', 'ttf' => 'application/font-sfnt', 'woff' => 'application/font-woff', 'png' => 'image/png', 'jpg' => 'image/jpg', 'jpeg' => 'image/jpg', 'svg' => 'image/svg+xml', 'gif' => 'image/gif', }.freeze
Instance Attribute Summary
Attributes inherited from Asset
Instance Method Summary collapse
- #assets ⇒ Object
-
#initialize(source, mime: 'text/css') ⇒ Stylesheet
constructor
A new instance of Stylesheet.
- #read ⇒ Object
- #to_css ⇒ Object
Methods inherited from Asset
#base64, #build_name, #data_uri, #digest
Constructor Details
#initialize(source, mime: 'text/css') ⇒ Stylesheet
Returns a new instance of Stylesheet.
74 75 76 |
# File 'lib/makebook/formats/html.rb', line 74 def initialize(source, mime: 'text/css') super end |
Instance Method Details
#assets ⇒ Object
78 79 80 81 82 83 84 85 |
# File 'lib/makebook/formats/html.rb', line 78 def assets scan(/url\("([^"]+\.(#{TYPES.keys.join('|')}))"\)/).map do |path, ext| [ Asset.new(source.dirname + path, mime: TYPES[ext]), wrap(Regexp.last_match.begin(1)...Regexp.last_match.end(1)), ] end end |
#read ⇒ Object
91 92 93 |
# File 'lib/makebook/formats/html.rb', line 91 def read @read ||= super end |
#to_css ⇒ Object
87 88 89 |
# File 'lib/makebook/formats/html.rb', line 87 def to_css read end |