Class: RTM::Axes::Topic
- Defined in:
- lib/rtm/axes.rb,
lib/rtm/axes/topic.rb
Overview
—- RTM::Axes::Topic —————————————-#
Instance Attribute Summary
Attributes inherited from Proxy
Instance Method Summary collapse
-
#characteristics(type = :any) ⇒ Object
Returns all Names and Occurrences of this Topic.
-
#indicators ⇒ Object
Returns all indicators (subject identifiers) of this Topic.
-
#instances ⇒ Object
(also: #reverse_types)
Returns the Topics which are instances of this Topic.
-
#item ⇒ Object
Returns one item identifier of this Topic or nil if this Topic has no item identifier.
-
#locators ⇒ Object
Returns all subject locators of this Topic.
-
#reifier ⇒ Object
Alias for the TMAPI function getReified.
-
#reverse_players(type = :any) ⇒ Object
Returns all Associations in which this Topic plays a Role.
-
#reverse_roles ⇒ Object
Returns all Associations that have Roles that have this Topic as Role type.
-
#reverse_scope ⇒ Object
Returns all Associations, Names and Occurrences that include this Topic (theme) in their scope.
-
#reverse_traverse ⇒ Object
Always returns an empty Array.
-
#subtypes ⇒ Object
(also: #reverse_supertypes)
Returns all subtypes of this Topic.
-
#supertypes ⇒ Object
(also: #reverse_subtypes)
Returns all supertypes of this Topic.
-
#traverse(type = :any) ⇒ Object
First computes all Associations where this Topic playes a Role.
-
#types ⇒ Object
(also: #reverse_instances)
Returns the Topics this Topic is an instance of.
Methods inherited from Proxy
Constructor Details
This class inherits a constructor from RTM::Axes::Proxy
Instance Method Details
#characteristics(type = :any) ⇒ Object
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
22 23 24 25 |
# File 'lib/rtm/axes/topic.rb', line 22 def characteristics(type=:any) _res = @construct.characteristics(type).map{|r| r.axes} _res.extend(Characteristics) end |
#indicators ⇒ Object
Returns all indicators (subject identifiers) of this Topic.
The result may be empty.
:call-seq:
indicators -> Array of Strings
36 37 38 |
# File 'lib/rtm/axes/topic.rb', line 36 def indicators @construct.indicators #Array of Strings or empty end |
#instances ⇒ Object Also known as: reverse_types
Returns the Topics which are instances of this Topic. Uses the TMAPI TypeInstanceIndex.
The result may be empty.
:call-seq:
instances -> Array of Topics
223 224 225 226 |
# File 'lib/rtm/axes/topic.rb', line 223 def instances _res = @construct.instances.map{|r| r.axes} _res.extend(Topics) end |
#item ⇒ Object
Returns one item identifier of this Topic or nil if this Topic has no item identifier.
:call-seq:
item -> String or nil
48 49 50 |
# File 'lib/rtm/axes/topic.rb', line 48 def item @construct.item #String or nil end |
#locators ⇒ Object
Returns all subject locators of this Topic.
The result may be empty.
:call-seq:
locators -> Array of Strings
61 62 63 |
# File 'lib/rtm/axes/topic.rb', line 61 def locators @construct.locators #Array of Strings or empty end |
#reifier ⇒ Object
Alias for the TMAPI function getReified. Returns the Construct which is reified by this Topic or nil if this Topic does not reify a Construct.
So far, only Associations, Names or Occurrences are returned.
:call-seq:
reifier -> Association, Name, Occurrence or nil
96 97 98 99 100 101 102 103 |
# File 'lib/rtm/axes/topic.rb', line 96 def reifier #TODO: what if the reified construct is a Topic Map? _res = @construct.getReified # Name,Occ,Assoc or nil return RTM::Axes::Name.new(_res,@tm) if _res.is_a?(RTM::Name) return RTM::Axes::Occurrence.new(_res,@tm) if _res.is_a?(RTM::Occurrence) return RTM::Axes::Association.new(_res,@tm) if _res.is_a?(RTM::Association) return nil end |
#reverse_players(type = :any) ⇒ Object
Returns all Associations in which this Topic plays a Role.
The optional identifier specifies the type of the Roles to be considered. The identifier may be a topic reference.
Multiple instances of the same Association are possible. The result may be empty.
:call-seq:
reverse_players -> Array of Associations
reverse_players(identifier) -> Array of Associations
80 81 82 83 |
# File 'lib/rtm/axes/topic.rb', line 80 def reverse_players(type=:any) _res = @construct.reverse_players(type).map{|r| r.axes} _res.extend(Associations) end |
#reverse_roles ⇒ Object
Returns all Associations that have Roles that have this Topic as Role type. Multiple instances of the same Association are possible.
The result may be empty.
:call-seq:
reverse_roles -> Array of Associations
116 117 118 119 120 |
# File 'lib/rtm/axes/topic.rb', line 116 def reverse_roles _res = @tm.type_instance_index.getRoles(@construct).map {|r| r.getParent } _res = _res.map{|r| r.axes} _res.extend(Associations) end |
#reverse_scope ⇒ Object
Returns all Associations, Names and Occurrences that include this Topic (theme) in their scope.
The result may be empty.
:call-seq:
reverse_scope -> Array of Names, Associations and Occurrences
132 133 134 135 136 137 |
# File 'lib/rtm/axes/topic.rb', line 132 def reverse_scope _index = @tm.scoped_index _res = _index.names(@construct).to_a + _index.occurrences(@construct).to_a + _index.associations(@construct).to_a _res = _res.map{|r| r.axes} _res.extend(AssocsNamesOccs) end |
#reverse_traverse ⇒ Object
Always returns an empty Array
:call-seq:
reverse_traverse -> Array of Topics
195 196 197 198 |
# File 'lib/rtm/axes/topic.rb', line 195 def reverse_traverse _res = [] #HARDCODED _res.extend(Topics) end |
#subtypes ⇒ Object Also known as: reverse_supertypes
Returns all subtypes of this Topic. The result includes the direct subtypes and the subtypes of these direct subtypes.
The result may be an empty Array.
:call-seq:
subtypes -> Array of Topics
163 164 165 166 |
# File 'lib/rtm/axes/topic.rb', line 163 def subtypes _res = @construct.transitive_subtypes_with_self.map{|r| r.axes} _res.extend(Topics) end |
#supertypes ⇒ Object Also known as: reverse_subtypes
Returns all supertypes of this Topic. The result includes all direct supertypes and the supertypes of these direct supertypes.
The result may be an empty Array.
:call-seq:
supertypes -> Array of Topics
150 151 152 153 |
# File 'lib/rtm/axes/topic.rb', line 150 def supertypes _res = @construct.transitive_supertypes_with_self.map{|r| r.axes} _res.extend(Topics) end |
#traverse(type = :any) ⇒ Object
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 deducted ones from the returned Array. The result may be empty.
The identifier may be a topic reference.
:call-seq:
traverse(identifier) -> Array of Topics
185 186 187 188 |
# File 'lib/rtm/axes/topic.rb', line 185 def traverse(type=:any) _res = @construct.traverse(type).map{|r| r.axes} _res.extend(Topics) end |
#types ⇒ Object Also known as: reverse_instances
Returns the Topics this Topic is an instance of. Calls the TMAPI getTypes method.
The result may be empty.
:call-seq:
types -> Array of Topics
210 211 212 213 |
# File 'lib/rtm/axes/topic.rb', line 210 def types _res = @construct.types.map{|r| r.axes} _res.extend(Topics) end |