Sha256: 4b3225d5744192e5f12c8fa305d1f58e0582dd030c0f46e2c6f49a90e2237f58

Contents?: true

Size: 1.18 KB

Versions: 1

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 or 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

1 entries across 1 versions & 1 rubygems

Version Path
rtm-0.2.0 lib/rtm/navigation/topic/characteristics.rb