Sha256: 6b4288db79e8e212d0f478a0f0d3a6d7f04df1d8dde52ecc75a38d86fdcdd43d

Contents?: true

Size: 1.12 KB

Versions: 2

Compression:

Stored size: 1.12 KB

Contents

# Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
# License:   Apache License, Version 2.0

module RTM::IO

  # RDF Export.
  # RTM::TopicMap gets a to_rdf method.
  module ToRDF
    module TopicMap

      # If this topic map is an Ontopia tmapi2 topic map to_rdf_ontopia is
      # called and the RDF reprensentation is returned.
      #
      # Else, a "Not supported" error is raised.
      #
      # :call-seq:
      #   to_rdf -> String
      #
      def to_rdf
        case self
          when Java::NetOntopiaTopicmapsImplTmapi2::TopicMapImpl then to_rdf_ontopia
          else raise "Not supported for #{self}"
        end
      end

      # Returns the RDF representation according to RDF2TM
      # of this topic map as String.
      #
      # @see http://www.ontopia.net/topicmaps/materials/rdf2tm.html
      #
      # :call-seq:
      #   to_rdf_ontopia -> String
      #
      def to_rdf_ontopia
        @out = java.io.StringWriter.new
        w=Java::NetOntopiaTopicmapsUtilsRdf::RDFTopicMapWriter.new @out
        w.write self.getWrapped
        @out.to_s
      end
    end

    RTM.register_extension self

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rtm-0.3.1 lib/rtm/io/to_rdf.rb
rtm-0.3.0 lib/rtm/io/to_rdf.rb