Class: EPUB::Metadata
Defined Under Namespace
Modules: Refinee
Classes: DCMES, Identifier, Link, Meta, Title, UnsupportedModel
Constant Summary
collapse
- DC_ELEMS =
[:identifiers, :titles, :languages] +
[:contributors, :coverages, :creators, :dates, :descriptions, :formats, :publishers,
:relations, :rights, :sources, :subjects, :types]
Instance Attribute Summary collapse
Instance Method Summary
collapse
included, #inspect, #template
Constructor Details
Returns a new instance of Metadata.
[View source]
19
20
21
22
23
24
|
# File 'lib/epub/metadata.rb', line 19
def initialize
(DC_ELEMS + [:metas, :links]).each do |elem|
__send__ "#{elem}=", []
end
@children = []
end
|
Instance Attribute Details
#children ⇒ Object
11
12
13
|
# File 'lib/epub/metadata.rb', line 11
def children
@children
end
|
Instance Method Details
Cover image used in EPUB 2
[View source]
70
71
72
73
74
|
# File 'lib/epub/metadata.rb', line 70
def cover_image
cover_image_meta = metas.find {|meta| meta.name == "cover"}
return unless cover_image_meta
package.manifest[cover_image_meta.meta_content]
end
|
#date ⇒ Object
[View source]
53
54
55
|
# File 'lib/epub/metadata.rb', line 53
def date
dates.first
end
|
#description ⇒ Object
[View source]
49
50
51
|
# File 'lib/epub/metadata.rb', line 49
def description
descriptions.join(' ')
end
|
#language ⇒ Object
[View source]
57
58
59
|
# File 'lib/epub/metadata.rb', line 57
def language
languages.first
end
|
#modified ⇒ Object
[View source]
61
62
63
64
65
66
|
# File 'lib/epub/metadata.rb', line 61
def modified
metas.find {|meta|
meta.property == 'dcterms:modified' &&
meta.refiners.empty?
}
end
|
[View source]
83
84
85
|
# File 'lib/epub/metadata.rb', line 83
def primary_metas
metas.select {|meta| meta.primary_expression?}
end
|
#release_identifier ⇒ Object
Also known as:
package_identifier
[View source]
26
27
28
|
# File 'lib/epub/metadata.rb', line 26
def release_identifier
"#{unique_identifier}@#{modified}"
end
|
#subtitle ⇒ Object
[View source]
45
46
47
|
# File 'lib/epub/metadata.rb', line 45
def subtitle
titles.select {|title| title.title_type.to_s == 'subtitle'}.sort.join(' ')
end
|
#title ⇒ Object
[View source]
31
32
33
34
35
36
37
|
# File 'lib/epub/metadata.rb', line 31
def title
return extended_title unless extended_title.empty?
compositted = titles.select {|title| title.display_seq}.sort.join("\n")
return compositted unless compositted.empty?
return main_title unless main_title.empty?
titles.sort.join("\n")
end
|
#to_h ⇒ Object
[View source]
76
77
78
79
80
81
|
# File 'lib/epub/metadata.rb', line 76
def to_h
DC_ELEMS.inject({}) do |hsh, elem|
hsh[elem] = __send__(elem)
hsh
end
end
|