Sha256: 665418dae79b720fb0a11e0fe9530901d4318b30efe8a0935697fdf4609ab674

Contents?: true

Size: 657 Bytes

Versions: 4

Compression:

Stored size: 657 Bytes

Contents

module GutenbergRdf
  class Rdf
    class Media
      attr_reader :xml

      def initialize(xml)
        @xml = xml
      end

      def uri
        xml.attributes['about']
      end

      def media_type
        datatype[:type]
      end

      def encoding
        datatype[:encoding]
      end

      def modified
        DateTime.parse(xml.elements['dcterms:modified'].text + '-07:00')
      end

    private

      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

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
gutenberg_rdf-0.4.0 lib/gutenberg_rdf/rdf/media.rb
gutenberg_rdf-0.3.1 lib/gutenberg_rdf/rdf/media.rb
gutenberg_rdf-0.2.3 lib/gutenberg_rdf/rdf/media.rb
gutenberg_rdf-0.2.1 lib/gutenberg_rdf/rdf/media.rb