# Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig. # License: Apache License, Version 2.0 module RTM::AR:IO # Each Topic Maps Construct gets a custom to_s method which supports optional :short or :long output. module TOSTRING module TopicMap # Returns different String representations. Try :short (default), :long, :super (original) def to_s(style=:short) case style when :short "#" when :long r = " #{reifier.to_s(:short)}" if reifier i = " iids=#{item_identifiers.to_s}" unless item_identifiers.empty? "#" else super() # these () are needed, otherwise the own parameters are passed in end end end module Topic # Returns different String representations. Try :short (default), :long or something else for the original method. # :name returns one (random) name for the Topic or an empty string if the topic has no name def to_s(style=:short) case style when :short ssid = " sids=#{subject_identifiers.to_s}" unless subject_identifiers.empty? sslo = " slos=#{subject_locators.to_s}" unless subject_locators.empty? siid = " iids=#{item_identifiers.to_s}" unless item_identifiers.empty? "#" when :long ssid = " sids=#{subject_identifiers.to_s}" unless subject_identifiers.empty? sslo = " slos=#{subject_locators.to_s}" unless subject_locators.empty? siid = " iids=#{item_identifiers.to_s}" unless item_identifiers.empty? "#" when :name return names.first.to_s(:short) if names.first return "" else super() # these () are needed, otherwise the own parameters are passed in end end end module Association def to_s(style=:short) case style when :short r = " #{reifier.to_s(:short)}" if reifier i = " iids=#{item_identifiers.to_s}" unless item_identifiers.empty? "#" when :long r = " #{reifier.to_s(:short)}" if reifier i = " iids=#{item_identifiers.to_s}" unless item_identifiers.empty? "#" else super() # these () are needed, otherwise the own parameters are passed in end end end module AssociationRole def to_s(style=:short) case style when :short r = " #{reifier.to_s(:short)}" if reifier i = " iids=#{item_identifiers.to_s}" unless item_identifiers.empty? "#" when :long r = " #{reifier.to_s(:short)}" if reifier i = " iids=#{item_identifiers.to_s}" unless item_identifiers.empty? "#" else super() # these () are needed, otherwise the own parameters are passed in end end end module TopicName def to_s(style=:short) case style when :short value when :long r = " #{reifier.to_s(:short)}" if reifier i = " iids=#{item_identifiers.to_s}" unless item_identifiers.empty? "#" else super() # these () are needed, otherwise the own parameters are passed in end end end module Occurrence def to_s(style=:short) case style when :short value when :long r = " #{reifier.to_s(:short)}" if reifier i = " iids=#{item_identifiers.to_s}" unless item_identifiers.empty? "#" else super() # these () are needed, otherwise the own parameters are passed in end end end module Variant def to_s(style=:short) case style when :short value when :long r = " #{reifier.to_s(:short)}" if reifier i = " iids=#{item_identifiers.to_s}" unless item_identifiers.empty? "#" else super() # these () are needed, otherwise the own parameters are passed in end end end RTM.register_extension self end end