Sha256: 7cba7f05b43860f2758108c4c6a23c63ca480d4e5fbef6f2159ecd3e99d43712

Contents?: true

Size: 1.18 KB

Versions: 3

Compression:

Stored size: 1.18 KB

Contents

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

module RTM
  module Navigation  
    module Topic
      
      # Returns all Names and Occurrences of this Topic.
      # If an identifier is given, only those Names and Occurrences are returned,
      # whose type or supertypes include the identifier.
      #
      # Identifier may be a topic reference.
      #
      # The result may be empty.
      #
      # :call-seq:
      #   characteristics -> Array of Names and Occurrences
      #   characteristics(identifier) -> Array of Names and Occurrences
      #
      def characteristics(type=:any)
        # FIXME which version of the code?
        return names.to_a + occurrences.to_a if type == :any
        _topic = topic_map.get(type)
        return [] unless _topic
        #names.select{|n| n.type.include?(_topic) || n.type.supertypes.include?(_topic)}.to_a +
        #occurrences.select{|o| o.type.include?(_topic) || o.type.supertypes.include?(_topic)}.to_a
        names.select{|n| n.type.supertypes.include?(_topic)}.to_a +
        occurrences.select{|o| o.type.supertypes.include?(_topic)}.to_a
      end
      
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rtm-0.3.0 lib/rtm/navigation/topic/characteristics.rb
rtm-0.2.1 lib/rtm/navigation/topic/characteristics.rb
rtm-0.2 lib/rtm/navigation/topic/characteristics.rb