Class: ReVIEW::EPUBMaker::Content
- Defined in:
- lib/review/epubmaker/content.rb
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
- #coverimage?(imagefile) ⇒ Boolean
-
#initialize(file:, id: nil, media: nil, title: nil, level: nil, notoc: nil, properties: nil, chaptype: nil) ⇒ Content
constructor
:call-seq: initialize(params) Construct Content object by passing named parameters.
- #inspect ⇒ Object
- #properties_attribute ⇒ Object
Constructor Details
#initialize(file:, id: nil, media: nil, title: nil, level: nil, notoc: nil, properties: nil, chaptype: nil) ⇒ Content
:call-seq:
initialize(params)
Construct Content object by passing named parameters. params
[:file] is required. Others are optional.
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/review/epubmaker/content.rb', line 41 def initialize(file:, id: nil, media: nil, title: nil, level: nil, notoc: nil, properties: nil, chaptype: nil) @id = id @file = file @media = media @title = title @level = level @notoc = notoc @properties = properties || [] @chaptype = chaptype complement end |
Instance Attribute Details
#chaptype ⇒ Object
Chapter type (pre/post/part/nil(body))
31 32 33 |
# File 'lib/review/epubmaker/content.rb', line 31 def chaptype @chaptype end |
#file ⇒ Object
File path (will accept #<anchor> suffix also)
19 20 21 |
# File 'lib/review/epubmaker/content.rb', line 19 def file @file end |
#level ⇒ Object
Header level (from 1)
25 26 27 |
# File 'lib/review/epubmaker/content.rb', line 25 def level @level end |
#media ⇒ Object
MIME type
21 22 23 |
# File 'lib/review/epubmaker/content.rb', line 21 def media @media end |
#notoc ⇒ Object
Show in TOC? nil:No.
27 28 29 |
# File 'lib/review/epubmaker/content.rb', line 27 def notoc @notoc end |
#properties ⇒ Object
Properties (EPUB3)
29 30 31 |
# File 'lib/review/epubmaker/content.rb', line 29 def properties @properties end |
#title ⇒ Object
Title
23 24 25 |
# File 'lib/review/epubmaker/content.rb', line 23 def title @title end |
Instance Method Details
#==(other) ⇒ Object
53 54 55 56 57 58 |
# File 'lib/review/epubmaker/content.rb', line 53 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 |
#coverimage?(imagefile) ⇒ Boolean
60 61 62 |
# File 'lib/review/epubmaker/content.rb', line 60 def coverimage?(imagefile) self.media.start_with?('image') && self.file =~ /#{imagefile}\Z/ end |
#inspect ⇒ Object
33 34 35 |
# File 'lib/review/epubmaker/content.rb', line 33 def inspect "<Content id=#{@id}, file=#{@file}, media=#{@media}, title=#{@title}, level=#{@level}, notoc=#{@notoc}, properties=#{@properties}, chaptype=#{@chaptype}>" end |
#properties_attribute ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/review/epubmaker/content.rb', line 64 def properties_attribute if self.properties.size > 0 %Q( properties="#{self.properties.sort.uniq.join(' ')}") else '' end end |