Class: EeePub::OCF::Container

Inherits:
ContainerItem show all
Defined in:
lib/eeepub/ocf.rb

Overview

Class for ‘container.xml’ of OCF

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ContainerItem

#save, #set_values, #to_xml

Constructor Details

#initialize(arg) ⇒ Container

Returns a new instance of Container.

Examples:

# with String
EeePub::OCF::Container.new('container.opf')
# with Array
EeePub::OCF::Container.new(['container.opf', 'other.opf'])
# with Hash
EeePub::OCF::Container.new(
  :rootfiles => [
    {:full_path => 'container.opf', :media_type => 'application/oebps-package+xml'}
  ]
)

Parameters:

  • (String or Array or Hash)


25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/eeepub/ocf.rb', line 25

def initialize(arg)
  case arg
  when String
    set_values(
      :rootfiles => [
        {:full_path => arg, :media_type => guess_media_type(arg)}
      ]
    )
  when Array
    # TODO: spec
    set_values(
      :rootfiles => arg.keys.map { |k|
        filename = arg[k]
        {:full_path => filename, :media_type => guess_media_type(filename)}
      }
    )
  when Hash
    set_values(arg)
  end
end

Instance Attribute Details

#rootfilesObject

Returns the value of attribute rootfiles.



6
7
8
# File 'lib/eeepub/ocf.rb', line 6

def rootfiles
  @rootfiles
end