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.
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
#date ⇒ Object
53
54
55
|
# File 'lib/epub/metadata.rb', line 53
def date
dates.first
end
|
#description ⇒ Object
49
50
51
|
# File 'lib/epub/metadata.rb', line 49
def description
descriptions.join(' ')
end
|
#language ⇒ Object
57
58
59
|
# File 'lib/epub/metadata.rb', line 57
def language
languages.first
end
|
#modified ⇒ Object
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
|
75
76
77
|
# File 'lib/epub/metadata.rb', line 75
def primary_metas
metas.select {|meta| meta.primary_expression?}
end
|
#release_identifier ⇒ Object
Also known as:
package_identifier
26
27
28
|
# File 'lib/epub/metadata.rb', line 26
def release_identifier
"#{unique_identifier}@#{modified}"
end
|
#subtitle ⇒ Object
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
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
68
69
70
71
72
73
|
# File 'lib/epub/metadata.rb', line 68
def to_h
DC_ELEMS.inject({}) do |hsh, elem|
hsh[elem] = __send__(elem)
hsh
end
end
|