Module: RTM::Sugar::Topic::Typed
- Defined in:
- lib/rtm/sugar/topic/typed.rb
Instance Method Summary collapse
-
#topic_is_a?(type) ⇒ Boolean
Determines whether this topic is instance (directly or indirectly) of the argument type.
-
#transitive_typed ⇒ Object
Returns the associations, names, occurrences and roles whose type equals this topic or subtypes of this topic.
-
#transitive_typed_associations ⇒ Object
Returns the associations whose type equals this topic or subtypes of this topic.
-
#transitive_typed_names ⇒ Object
Returns the names whose type equals this topic or subtypes of this topic.
-
#transitive_typed_occurrences ⇒ Object
Returns the occurrences whose type equals this topic or subtypes of this topic.
-
#transitive_typed_roles ⇒ Object
Returns the roles whose type equals this topic or subtypes of this topic.
-
#typed ⇒ Object
Returns the associations, names, occurrences and roles whose type equals this topic.
-
#typed_associations ⇒ Object
Returns the associations whose type equals this topic.
-
#typed_names ⇒ Object
Returns the names whose type equals this topic.
-
#typed_occurrences ⇒ Object
Returns the occurrences whose type equals this topic.
-
#typed_roles ⇒ Object
Returns the roles whose type equals this topic.
-
#used_as_association_type? ⇒ Boolean
States if this topic is used as type of an Association.
-
#used_as_name_type? ⇒ Boolean
States if this topic is used as type of a Name.
-
#used_as_occurrence_type? ⇒ Boolean
States if this topic is used as type of an Occurrence.
-
#used_as_role_type? ⇒ Boolean
States if this topic is used as type of a Role.
-
#used_as_type? ⇒ Boolean
States if this topic is used as type of a typed Construct.
Instance Method Details
#topic_is_a?(type) ⇒ Boolean
Determines whether this topic is instance (directly or indirectly) of the argument type.
Type may be a topic reference.
:call-seq:
topic_is_a?(type)
154 155 156 157 158 |
# File 'lib/rtm/sugar/topic/typed.rb', line 154 def topic_is_a?(type) topic_map.cached self, :is_a?, type do self.transitive_types.include?(topic_map.get(type)) end end |
#transitive_typed ⇒ Object
Returns the associations, names, occurrences and roles whose type equals this topic or subtypes of this topic.
The result may be empty.
:call-seq:
transitive_typed -> Array of Associations, Names, Occurrences and Roles
30 31 32 33 34 35 36 |
# File 'lib/rtm/sugar/topic/typed.rb', line 30 def transitive_typed trans_typed = typed #may be empty transitive_subtypes.each do |subtype| trans_typed.concat(subtype.typed) end trans_typed = trans_typed.uniq #no duplicates outside of tmql mode end |
#transitive_typed_associations ⇒ Object
Returns the associations whose type equals this topic or subtypes of this topic.
The result may be empty.
:call-seq:
transitive_typed_associations -> Array of Associations
57 58 59 60 61 62 63 |
# File 'lib/rtm/sugar/topic/typed.rb', line 57 def transitive_typed_associations trans_types_assocs = typed_associations #may be empty transitive_subtypes.each do |subtype| trans_types_assocs.concat(subtype.typed_associations) end trans_types_assocs = trans_types_assocs.uniq #no duplicates outside of tmql mode end |
#transitive_typed_names ⇒ Object
Returns the names whose type equals this topic or subtypes of this topic.
The result may be empty.
:call-seq:
transitive_typed_names -> Array of Associations
84 85 86 87 88 89 90 |
# File 'lib/rtm/sugar/topic/typed.rb', line 84 def transitive_typed_names trans_types_names = typed_names #may be empty transitive_subtypes.each do |subtype| trans_types_names.concat(subtype.typed_names) end trans_types_names = trans_types_names.uniq #no duplicates outside of tmql mode end |
#transitive_typed_occurrences ⇒ Object
Returns the occurrences whose type equals this topic or subtypes of this topic.
The result may be empty.
:call-seq:
transitive_typed_occurrences -> Array of Associations
111 112 113 114 115 116 117 |
# File 'lib/rtm/sugar/topic/typed.rb', line 111 def transitive_typed_occurrences trans_types_occs = typed_occurrences #may be empty transitive_subtypes.each do |subtype| trans_types_occs.concat(subtype.typed_occurrences) end trans_types_occs = trans_types_occs.uniq #no duplicates outside of tmql mode end |
#transitive_typed_roles ⇒ Object
Returns the roles whose type equals this topic or subtypes of this topic.
The result may be empty.
:call-seq:
transitive_typed_roles -> Array of Associations
138 139 140 141 142 143 144 |
# File 'lib/rtm/sugar/topic/typed.rb', line 138 def transitive_typed_roles trans_types_roles = typed_roles #may be empty transitive_subtypes.each do |subtype| trans_types_roles.concat(subtype.typed_roles) end trans_types_roles = trans_types_roles.uniq #no duplicates outside of tmql mode end |
#typed ⇒ Object
Returns the associations, names, occurrences and roles whose type equals this topic.
The result may be empty.
:call-seq:
typed -> Array of Associations, Names, Occurrences and Roles
16 17 18 19 |
# File 'lib/rtm/sugar/topic/typed.rb', line 16 def typed _index = topic_map.type_instance_index _index.get_associations(self).to_a + _index.get_names(self).to_a + _index.get_occurrences(self).to_a + _index.get_roles(self).to_a end |
#typed_associations ⇒ Object
Returns the associations whose type equals this topic.
The result may be empty.
:call-seq:
typed_associations -> Array of Associations
45 46 47 |
# File 'lib/rtm/sugar/topic/typed.rb', line 45 def typed_associations topic_map.type_instance_index.get_associations(self).to_a end |
#typed_names ⇒ Object
Returns the names whose type equals this topic.
The result may be empty.
:call-seq:
typed_names -> Array of Names
72 73 74 |
# File 'lib/rtm/sugar/topic/typed.rb', line 72 def typed_names topic_map.type_instance_index.get_names(self).to_a end |
#typed_occurrences ⇒ Object
Returns the occurrences whose type equals this topic.
The result may be empty.
:call-seq:
typed_occurrences -> Array of Occurrences
99 100 101 |
# File 'lib/rtm/sugar/topic/typed.rb', line 99 def typed_occurrences topic_map.type_instance_index.get_occurrences(self).to_a end |
#typed_roles ⇒ Object
Returns the roles whose type equals this topic.
The result may be empty.
:call-seq:
typed_roles -> Array of Roles
126 127 128 |
# File 'lib/rtm/sugar/topic/typed.rb', line 126 def typed_roles topic_map.type_instance_index.get_roles(self).to_a end |
#used_as_association_type? ⇒ Boolean
States if this topic is used as type of an Association.
:call-seq:
used_as_association_type? -> true or false
174 175 176 |
# File 'lib/rtm/sugar/topic/typed.rb', line 174 def used_as_association_type? not self.typed_associations.empty? end |
#used_as_name_type? ⇒ Boolean
States if this topic is used as type of a Name.
:call-seq:
used_as_name_type? -> true or false
183 184 185 |
# File 'lib/rtm/sugar/topic/typed.rb', line 183 def used_as_name_type? not self.typed_names.empty? end |
#used_as_occurrence_type? ⇒ Boolean
States if this topic is used as type of an Occurrence.
:call-seq:
used_as_occurrence_type -> true or false
192 193 194 |
# File 'lib/rtm/sugar/topic/typed.rb', line 192 def used_as_occurrence_type? not self.typed_occurrences.empty? end |
#used_as_role_type? ⇒ Boolean
States if this topic is used as type of a Role.
:call-seq:
used_as_role_type? -> true or false
201 202 203 |
# File 'lib/rtm/sugar/topic/typed.rb', line 201 def used_as_role_type? not self.typed_roles.empty? end |
#used_as_type? ⇒ Boolean
States if this topic is used as type of a typed Construct.
:call-seq:
used_as_type? -> true or false
165 166 167 |
# File 'lib/rtm/sugar/topic/typed.rb', line 165 def used_as_type? used_as_name_type? || used_as_occurrence_type? || used_as_association_type? || used_as_role_type? end |