Class: Repub::Epub::Content::ContentItem

Inherits:
Struct
  • Object
show all
Defined in:
lib/repub/epub/content.rb

Instance Method Summary collapse

Constructor Details

#initialize(id, href) ⇒ ContentItem

Returns a new instance of ContentItem.



132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/repub/epub/content.rb', line 132

def initialize(id, href)
  super(id, href)
  self.media_type = case href.strip.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'
    else
      raise 'Unknown media type'
  end
end

Instance Method Details

#document?Boolean

Returns:

  • (Boolean)


154
155
156
# File 'lib/repub/epub/content.rb', line 154

def document?
  self.media_type == 'application/xhtml+xml'
end