Class: EpubWorm::ManifestItem

Inherits:
Object
  • Object
show all
Defined in:
lib/epub_worm/manifest_item.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id: nil, reference: nil, media_type: nil, path: nil) ⇒ ManifestItem



7
8
9
10
11
12
# File 'lib/epub_worm/manifest_item.rb', line 7

def initialize(id: nil, reference: nil, media_type: nil, path: nil)
  @id = id
  @reference = reference
  @media_type = media_type
  @path = path
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/epub_worm/manifest_item.rb', line 5

def id
  @id
end

#media_typeObject

Returns the value of attribute media_type.



5
6
7
# File 'lib/epub_worm/manifest_item.rb', line 5

def media_type
  @media_type
end

#referenceObject

Returns the value of attribute reference.



5
6
7
# File 'lib/epub_worm/manifest_item.rb', line 5

def reference
  @reference
end

Instance Method Details

#fileObject



14
15
16
# File 'lib/epub_worm/manifest_item.rb', line 14

def file
  ::EpubWorm::Extractors::File.extract(path, reference)
end

#to_hObject



18
19
20
21
22
23
24
# File 'lib/epub_worm/manifest_item.rb', line 18

def to_h
  {
    id: id,
    reference: reference,
    media_type: media_type
  }
end