Class: EPUBMaker::Content
Overview
EPUBMaker::Content represents a content data for EPUBMaker. EPUBMaker#contents takes an array of Content.
Instance Attribute Summary collapse
-
#chaptype ⇒ Object
Chapter type (pre/post/part/nil(body)).
-
#file ⇒ Object
File path (will accept #<anchor> suffix also).
-
#id ⇒ Object
ID.
-
#level ⇒ Object
Header level (from 1).
-
#media ⇒ Object
MIME type.
-
#notoc ⇒ Object
Show in TOC? nil:No.
-
#properties ⇒ Object
Properties (EPUB3).
-
#title ⇒ Object
Title.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(fileorhash, id = nil, media = nil, title = nil, level = nil, notoc = nil, properties = nil, chaptype = nil) ⇒ Content
constructor
:call-seq: initialize(file, id, media, title, level, notoc) initialize(hash) Construct Content object by passing a sequence of parameters or hash.
- #inspect ⇒ Object
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.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/epubmaker/content.rb', line 42 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
#chaptype ⇒ Object
Chapter type (pre/post/part/nil(body))
30 31 32 |
# File 'lib/epubmaker/content.rb', line 30 def chaptype @chaptype end |
#file ⇒ Object
File path (will accept #<anchor> suffix also)
18 19 20 |
# File 'lib/epubmaker/content.rb', line 18 def file @file end |
#level ⇒ Object
Header level (from 1)
24 25 26 |
# File 'lib/epubmaker/content.rb', line 24 def level @level end |
#notoc ⇒ Object
Show in TOC? nil:No.
26 27 28 |
# File 'lib/epubmaker/content.rb', line 26 def notoc @notoc end |
#properties ⇒ Object
Properties (EPUB3)
28 29 30 |
# File 'lib/epubmaker/content.rb', line 28 def properties @properties end |
Instance Method Details
#==(other) ⇒ Object
65 66 67 68 69 |
# File 'lib/epubmaker/content.rb', line 65 def ==(other) return false unless self.class == other.class [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 |
#inspect ⇒ Object
32 33 34 |
# File 'lib/epubmaker/content.rb', line 32 def inspect "<Content id=#{@id}, file=#{@file}, media=#{@media}, title=#{@title}, level=#{@level}, notoc=#{@notoc}, properties=#{@properties}, chaptype=#{@chaptype}>" end |