Class: EPUB::Publication::Package::Metadata
- Inherits:
-
Object
- Object
- EPUB::Publication::Package::Metadata
- Includes:
- ContentModel
- Defined in:
- lib/epub/maker/publication.rb
Defined Under Namespace
Classes: Meta
Instance Method Summary collapse
-
#creator=(name) ⇒ Object
Shortcut to set one creator from String.
-
#language=(lang_code) ⇒ Object
Shortcut to set language from String.
- #make {|_self| ... } ⇒ Object
-
#title=(title) ⇒ Object
Shortcut to set title from String.
- #to_xml_fragment(xml) ⇒ Object
Methods included from ContentModel
Instance Method Details
#creator=(name) ⇒ Object
Shortcut to set one creator from String
177 178 179 180 181 182 |
# File 'lib/epub/maker/publication.rb', line 177 def creator=(name) creator = DCMES.new creator.content = name self.dc_creators = [creator] name end |
#language=(lang_code) ⇒ Object
Shortcut to set language from String
168 169 170 171 172 173 |
# File 'lib/epub/maker/publication.rb', line 168 def language=(lang_code) lang = DCMES.new lang.content = lang_code self.dc_languages = [lang] lang_code end |
#make {|_self| ... } ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/epub/maker/publication.rb', line 99 def make yield self if block_given? unless unique_identifier if identifiers.empty? identifier = DCMES.new identifier.id = 'pub-id' identifier.content = UUID.create.to_s self.dc_identifiers << identifier self.unique_identifier = identifier else self.unique_identifier = identifiers.first end end unless .any? {|| .property == 'dcterms:modified'} modified = Meta.new modified.property = 'dcterms:modified' # modified.content = Time.now.utc.strftime('%FT%TZ') modified.content = Time.now.utc.iso8601 self. << modified end self end |
#title=(title) ⇒ Object
Shortcut to set title from String
159 160 161 162 163 164 |
# File 'lib/epub/maker/publication.rb', line 159 def title=(title) t = Title.new t.content = title self.dc_titles = [t] title end |
#to_xml_fragment(xml) ⇒ Object
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/epub/maker/publication.rb', line 124 def to_xml_fragment(xml) xml.('xmlns:dc' => EPUB::NAMESPACES['dc']) { (DC_ELEMS - [:languages]).each do |elems| singular = elems[0..-2] singular += 's' if elems == :rights singular += '_' __send__("dc_#{elems}").each do |elem| node = xml['dc'].__send__(singular, elem.content) to_xml_attribute node, elem, [:id, :dir] node['xml:lang'] = elem.lang if elem.lang end end languages.each do |language| xml['dc'].language language.content end .each do || next unless .valid? # TODO: Consider whther to drop or keep as is node = xml.(.content) to_xml_attribute node, , [:property, :id, :scheme] node['refines'] = "##{.refines.id}" if .refines end links.each do |link| node = xml.link to_xml_attribute node, link, [:href, :id, :media_type] node['rel'] = link.rel.to_a.join(' ') if link.rel node['refines'] = "##{link.refines.id}" if link.refines end } end |