# Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig. # License: Apache License, Version 2.0 module RTM::IO # JTM Export. # Each Topic Maps Construct gets a to_jtm method. module TOJTM begin require 'json/ext' rescue LoadError require 'json/pure' end unless Object.const_defined?(:JSON) module TopicMap # Returns the JTM representation of this RTM::TopicMap def to_jtm_str # only for export with no file and base_iri otherwise TMAPIX h = to_hash h[:version] = "1.0" h[:item_type] = "topicmap" h.to_json end # alias :to_json :to_jtm_str end module Topic # Returns the JTM representation of this RTM::Topic def to_jtm h = to_hash h[:version] = "1.0" h[:item_type] = "topic" h.to_json end alias :to_json :to_jtm end module Association # Returns the JTM representation of this RTM::Association def to_jtm h = to_hash h[:version] = "1.0" h[:item_type] = "association" h.to_json end alias :to_json :to_jtm end module Name # Returns the JTM representation of this RTM::Name def to_jtm h = to_hash h[:version] = "1.0" h[:item_type] = "name" h.to_json end alias :to_json :to_jtm end module Occurrence # Returns the JTM representation of this RTM::Occurrence def to_jtm h = to_hash h[:version] = "1.0" h[:item_type] = "occurrence" h.to_json end alias :to_json :to_jtm end module Role # Returns the JTM representation of this RTM::Role def to_jtm h = to_hash h[:version] = "1.0" h[:item_type] = "role" h.to_json end alias :to_json :to_jtm end module Variant # Returns the JTM representation of this RTM::Variant def to_jtm h = to_hash h[:version] = "1.0" h[:item_type] = "variant" h.to_json end alias :to_json :to_jtm end RTM.register_extension self end end