Module: RTM::Sugar::Occurrence::External

Defined in:
lib/rtm/sugar/occurrence/external.rb

Instance Method Summary collapse

Instance Method Details

#external?Boolean

Returns true, if the datatype of this occurrence equals xsd:anyURI.

Returns:



48
49
50
# File 'lib/rtm/sugar/occurrence/external.rb', line 48

def external?
  return self.datatype.reference == RTM::PSI[:IRI] ? true : false
end

#externalizeObject

Creates an association out of this occurrence which represents the occurrence information in relation to the parent topic.

The association is of type “psi.topicmapslab.de/subject-representation”. It includes two roles. The parent topic plays the role of type “psi.topicmapslab.de/represented-subject”. The topic with the subject locator created from the occurrence value plays the role of a type the same as the occurrence type.

The subject locator will be resolved using the get-method of RTM::TopicMap, that means if the occurrence value is stored as String and is not a valid uri the base_iri of the topic map is used to create one.

The occurrence datatype may be xsd:anyURI as well as xsd:String. The occurrence value must be a valid URL.

Example: Creates an association out of the occurrence with value “www.leipzig.de” and type “webpage” of the topic Leipzig:

  • association type: subject_representation

  • role 1: Leipzig plays the role “represented_subject”

  • role 2: topic with subject locator “www.leipzig.de” plays the role “webpage”

:call-seq:

externalize -> Association


32
33
34
# File 'lib/rtm/sugar/occurrence/external.rb', line 32

def externalize
  topic_map.create_association(RTM::PSI[:subject_representation], RTM::PSI[:represented_subject] => parent, self.type => "=#{self.value}")
end

#externalize!(*args) ⇒ Object

Executes externalize and removes this occurrence from the topic map afterwards

:call-seq:

externalize!


41
42
43
44
45
# File 'lib/rtm/sugar/occurrence/external.rb', line 41

def externalize!(*args)
  association = externalize(*args)
  remove
  return association
end