Sha256: 0162fac656c354ebf31dd572132a964f1e31bd040e1a894e64c9e4efb7c63ff6

Contents?: true

Size: 658 Bytes

Versions: 2

Compression:

Stored size: 658 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

2 entries across 2 versions & 1 rubygems

Version Path
gutenberg_rdf-1.0.1 lib/gutenberg_rdf/rdf/media.rb
gutenberg_rdf-1.0.0 lib/gutenberg_rdf/rdf/media.rb