Sha256: 2079c098870570765b06027aa2f221079e4161f79ebc665b6ea759e6f74c2db4

Contents?: true

Size: 1.52 KB

Versions: 4

Compression:

Stored size: 1.52 KB

Contents

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

module RTM
  module Navigation
    module Topic
      
      # First computes all Associations where this Topic playes a Role.
      # There, the optional identifier filters the Associations for their type.
      # 
      # Returns all Players of all Roles in these Associations.
      # The current Topic is not included in the result.
      # The result may be empty.
      #
      # The identifier may be a topic reference.
      #
      # :call-seq:
      #   traverse(identifier) -> Array of Topics
      #
      def traverse(type = :any)
        unless type == :any
          _topic = topic_map.get(type)
          return [] unless _topic
        end
        _res = roles_played.map{|r| r.parent} #associations
        _res = _res.select{|a| a.type == _topic} unless type == :any
        _res = _res.map{|a| a.roles.map{ |r| r.player}}.flatten #players of all roles in these associations
        #            unless _res.empty?
        #              _res.each_with_index do |x,i|
        #                if x == self
        #                  _res.delete_at(i)
        #                  break
        #                end
        #              end
        #            end
        _res =_res.reject{|p| p == self}
        return _res
      end
      
      # Always returns an empty Array
      #
      # :call-seq:
      #   reverse_traverse -> Array
      #
      def reverse_traverse 
        Array.new
      end
      
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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