Class: EPUB::Publication::Package::Metadata
Defined Under Namespace
Modules: Refinee
Classes: DCMES, Identifier, Link, Meta, Title
Constant Summary
collapse
- DC_ELEMS =
[:identifiers, :titles, :languages] +
[:contributors, :coverages, :creators, :dates, :descriptions, :formats, :publishers,
:relations, :rights, :sources, :subjects, :types]
Inspector::PublicationModel::TEMPLATE
Instance Method Summary
collapse
included, #inspect
Constructor Details
Returns a new instance of Metadata.
19
20
21
22
23
|
# File 'lib/epub/publication/package/metadata.rb', line 19
def initialize
(DC_ELEMS + [:metas, :links]).each do |elem|
__send__ "#{elem}=", []
end
end
|
Instance Method Details
#date ⇒ Object
47
48
49
|
# File 'lib/epub/publication/package/metadata.rb', line 47
def date
dates.first
end
|
#description ⇒ Object
43
44
45
|
# File 'lib/epub/publication/package/metadata.rb', line 43
def description
descriptions.join(' ')
end
|
#language ⇒ Object
51
52
53
|
# File 'lib/epub/publication/package/metadata.rb', line 51
def language
languages.first
end
|
#modified ⇒ Object
55
56
57
|
# File 'lib/epub/publication/package/metadata.rb', line 55
def modified
metas.find {|meta| meta.property == 'dcterms:modified'}
end
|
66
67
68
|
# File 'lib/epub/publication/package/metadata.rb', line 66
def primary_metas
metas.select {|meta| meta.primary_expression?}
end
|
#subtitle ⇒ Object
39
40
41
|
# File 'lib/epub/publication/package/metadata.rb', line 39
def subtitle
titles.select {|title| title.title_type.to_s == 'subtitle'}.sort.join(' ')
end
|
#title ⇒ Object
25
26
27
28
29
30
31
|
# File 'lib/epub/publication/package/metadata.rb', line 25
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
59
60
61
62
63
64
|
# File 'lib/epub/publication/package/metadata.rb', line 59
def to_h
DC_ELEMS.inject({}) do |hsh, elem|
hsh[elem] = __send__(elem)
hsh
end
end
|