class GutenbergRdf::Rdf::Media

Attributes

xml[R]

Public Class Methods

new(xml) click to toggle source
# File lib/gutenberg_rdf/rdf/media.rb, line 6
def initialize(xml)
  @xml = xml
end

Public Instance Methods

encoding() click to toggle source
# File lib/gutenberg_rdf/rdf/media.rb, line 18
def encoding
  datatype[:encoding]
end
media_type() click to toggle source
# File lib/gutenberg_rdf/rdf/media.rb, line 14
def media_type
  datatype[:type]
end
modified() click to toggle source
# File lib/gutenberg_rdf/rdf/media.rb, line 22
def modified
  DateTime.parse(xml.elements['dcterms:modified'].text + '-07:00')
end
uri() click to toggle source
# File lib/gutenberg_rdf/rdf/media.rb, line 10
def uri
  xml.attributes['about']
end

Private Instance Methods

datatype() click to toggle source
# File lib/gutenberg_rdf/rdf/media.rb, line 28
def datatype
  parts = xml.elements['dcterms:format/rdf:Description/rdf:value'].text.split(/; */)
  t = parts.shift
  e = parts.join(';').sub('charset=', '')
  {type: t, encoding: e}
end