Class: EeePub::OCF::Container

Inherits:
ContainerItem show all
Defined in:
lib/eeepub/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)


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

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.



8
9
10
# File 'lib/eeepub/lib/eeepub/ocf.rb', line 8

def rootfiles
  @rootfiles
end