# Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig. # License: Apache License, Version 2.0 module RTM::Axes module Associations def self.extended(k) k.extend ArrayProxy end def result self.map{|i| i.construct} end alias tmapi :result # ---- players-axis ------------------------------------------------------# # Returns all Role players of Roles in these Associations. # # The optional identifier specifies the type of the Roles to be considered. # The identifier may be a topic reference. # # Multiple instances of the same Topic are possible. # The result may be empty. # # :call-seq: # players -> Array of Topics # players(identifier) -> Array of Topics # def players(type=:any) _res = self.inject([]){|all,containee| all << containee.send(:players,type)}.flatten ### NO UNIQUE ### _res = _res.extend(Topics) _res end # ---- reifier-axis ------------------------------------------------------# # Returns the reifing Topics of these Assocations only # if such Topics exist. # # The result may be empty. # # :call-seq: # reverse_reified -> Array of Topics # def reverse_reifier _res = self.inject([]){|all,containee| all << containee.send(:reverse_reifier)}.flatten _res = _res.select{|i| i} ### NO UNIQUE NEEDED _res = _res.extend(Topics) _res end # ---- roles-axis --------------------------------------------------------# # Returns all Topics that are types of Roles in these Associations. # Multiple instances of the same Topic are possible. # # The result may be empty. # # :call-seq: # roles -> Array of Topics # def roles _res = self.inject([]){|all,containee| all << containee.send(:roles)}.flatten ### NO UNIQUE ### _res = _res.extend(Topics) _res end # ---- scope-axis --------------------------------------------------------# # Returns the scope of these Associations. # # The result may be empty. # # :call-seq: # scope -> Array of Topics # def scope _res = self.inject([]){|all,containee| all << containee.send(:scope)}.flatten ### FLAG UNIQUE ### _res = _res.map{|i| i.construct}.uniq.map{|i| i.axes} ### ### _res = _res.extend(Topics) _res end # # ---- traverse-axis -----------------------------------------------------# # #def reverse_traverse # # # #end end end