Class: EPUBMaker::Content

Inherits:
Object show all
Defined in:
lib/epubmaker/content.rb

Overview

EPUBMaker::Content represents a content data for EPUBMaker. EPUBMaker#contents takes an array of Content.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(fileorhash, id = nil, media = nil, title = nil, level = nil, notoc = nil, properties = nil, chaptype = nil) ⇒ Content

:call-seq:

initialize(file, id, media, title, level, notoc)
initialize(hash)

Construct Content object by passing a sequence of parameters or hash. Keys of hash relate with each parameters. file (or hash[“file”]) is required. Others are optional.



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/epubmaker/content.rb', line 40

def initialize(fileorhash, id=nil, media=nil, title=nil, level=nil, notoc=nil, properties=nil, chaptype=nil)
  if fileorhash.instance_of?(Hash)
    @id = fileorhash["id"]
    @file = fileorhash["file"]
    @media = fileorhash["media"]
    @title = fileorhash["title"]
    @level = fileorhash["level"]
    @notoc = fileorhash["notoc"]
    @properties = fileorhash["properties"] || []
    @chaptype = fileorhash["chaptype"]
  else
    @file = fileorhash
    @id = id
    @media = media
    @title = title
    @level = level
    @notoc = notoc
    @properties = properties || []
    @chaptype = chaptype
  end
  complement
end

Instance Attribute Details

#chaptypeObject

Chapter type (pre/post/part/nil(body))



32
33
34
# File 'lib/epubmaker/content.rb', line 32

def chaptype
  @chaptype
end

#fileObject

File path (will accept #<anchor> suffix also)



20
21
22
# File 'lib/epubmaker/content.rb', line 20

def file
  @file
end

#idObject

ID



18
19
20
# File 'lib/epubmaker/content.rb', line 18

def id
  @id
end

#levelObject

Header level (from 1)



26
27
28
# File 'lib/epubmaker/content.rb', line 26

def level
  @level
end

#mediaObject

MIME type



22
23
24
# File 'lib/epubmaker/content.rb', line 22

def media
  @media
end

#notocObject

Show in TOC? nil:No.



28
29
30
# File 'lib/epubmaker/content.rb', line 28

def notoc
  @notoc
end

#propertiesObject

Properties (EPUB3)



30
31
32
# File 'lib/epubmaker/content.rb', line 30

def properties
  @properties
end

#titleObject

Title



24
25
26
# File 'lib/epubmaker/content.rb', line 24

def title
  @title
end

Instance Method Details

#==(other) ⇒ Object



63
64
65
66
67
68
69
# File 'lib/epubmaker/content.rb', line 63

def ==(other)
  if self.class != other.class
    return false
  end
  [self.id, self.file, self.media, self.title, self.level, self.notoc, self.chaptype, self.properties] ==
    [other.id, other.file, other.media, other.title, other.level, other.notoc, other.chaptype, other.properties]
end