Class: Thepub::Epub::Item
- Inherits:
-
Object
- Object
- Thepub::Epub::Item
- Includes:
- ContainerItem
- Defined in:
- lib/thepub/epub/container_item.rb
Overview
Wrapper class for ePub items that do not have specialized classes e.g. HTML files, CSSs etc.
Instance Attribute Summary
Attributes included from ContainerItem
Instance Method Summary collapse
-
#initialize(file_path, media_type = nil) ⇒ Item
constructor
A new instance of Item.
Methods included from ContainerItem
Constructor Details
#initialize(file_path, media_type = nil) ⇒ Item
Returns a new instance of Item.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/thepub/epub/container_item.rb', line 23 def initialize(file_path, media_type = nil) @file_path = file_path.strip @media_type = media_type || case @file_path.downcase when /.*\.html?$/ 'application/xhtml+xml' when /.*\.css$/ 'text/css' when /.*\.(jpeg|jpg)$/ 'image/jpeg' when /.*\.png$/ 'image/png' when /.*\.gif$/ 'image/gif' when /.*\.svg$/ 'image/svg+xml' when /.*\.ncx$/ 'application/x-dtbncx+xml' when /.*\.opf$/ 'application/oebps-package+xml' else raise 'Unknown media type' end end |