rtm 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. data/README +38 -3
  2. data/lib/rtm.rb +25 -47
  3. data/lib/rtm/axes.rb +7 -4
  4. data/lib/rtm/axes/association.rb +1 -1
  5. data/lib/rtm/axes/associations.rb +1 -1
  6. data/lib/rtm/axes/characteristic.rb +1 -1
  7. data/lib/rtm/axes/characteristics.rb +1 -1
  8. data/lib/rtm/axes/topic.rb +3 -3
  9. data/lib/rtm/axes/topics.rb +3 -3
  10. data/lib/rtm/engine.rb +48 -5
  11. data/lib/rtm/extensions.rb +58 -8
  12. data/lib/rtm/io.rb +2 -1
  13. data/lib/rtm/io/tmapix_from.rb +155 -0
  14. data/lib/rtm/io/tmapix_to.rb +223 -0
  15. data/lib/rtm/io/to_hash.rb +79 -41
  16. data/lib/rtm/io/to_jtm.rb +1 -1
  17. data/lib/rtm/io/to_rdf.rb +20 -5
  18. data/lib/rtm/io/to_string.rb +13 -2
  19. data/lib/rtm/io/to_yaml.rb +39 -11
  20. data/lib/rtm/navigation.rb +1 -15
  21. data/lib/rtm/navigation/association/players.rb +1 -1
  22. data/lib/rtm/navigation/name/characteristics.rb +1 -1
  23. data/lib/rtm/navigation/occurrence/characteristics.rb +1 -1
  24. data/lib/rtm/navigation/topic/characteristics.rb +1 -1
  25. data/lib/rtm/navigation/topic/players.rb +1 -1
  26. data/lib/rtm/navigation/topic/supertypes.rb +21 -17
  27. data/lib/rtm/navigation/topic/traverse.rb +1 -1
  28. data/lib/rtm/navigation/topic/types.rb +6 -4
  29. data/lib/rtm/psi.rb +6 -0
  30. data/lib/rtm/sugar.rb +42 -29
  31. data/lib/rtm/sugar/association/hash_access.rb +3 -3
  32. data/lib/rtm/sugar/occurrence/dynamic_value.rb +39 -56
  33. data/lib/rtm/sugar/occurrence/external.rb +53 -0
  34. data/lib/rtm/sugar/reifiable/reifier.rb +21 -0
  35. data/lib/rtm/sugar/role/counterparts.rb +12 -6
  36. data/lib/rtm/sugar/topic/best_name.rb +74 -0
  37. data/lib/rtm/sugar/topic/characteristics.rb +10 -10
  38. data/lib/rtm/sugar/topic/counterparts.rb +131 -119
  39. data/lib/rtm/sugar/topic/scoped.rb +102 -53
  40. data/lib/rtm/sugar/topic/topic_ref.rb +63 -12
  41. data/lib/rtm/sugar/topic/typed.rb +50 -2
  42. data/lib/rtm/sugar/topic_map/query_cache.rb +66 -0
  43. data/lib/rtm/sugar/topic_map/themes.rb +53 -0
  44. data/lib/rtm/sugar/typed/types.rb +1 -1
  45. data/lib/rtm/validation.rb +2 -2
  46. data/lib/rtm/version.rb +18 -6
  47. data/spec/rtm/axes/string_spec.rb +7 -7
  48. data/spec/rtm/axes/strings_spec.rb +10 -10
  49. data/spec/rtm/io/tmapix_from_spec.rb +76 -0
  50. data/spec/rtm/io/tmapix_to_spec.rb +159 -0
  51. data/spec/rtm/io/to_hash_spec.rb +90 -0
  52. data/spec/rtm/io/to_rdf_spec.rb +37 -0
  53. data/spec/rtm/io/to_string_spec.rb +122 -0
  54. data/spec/rtm/io/to_yaml_spec.rb +89 -0
  55. data/spec/rtm/sugar/occurrence/dynamic_value_spec.rb +156 -1
  56. data/spec/rtm/sugar/occurrence/external_spec.rb +129 -0
  57. data/spec/rtm/sugar/reifiable/reifier_spec.rb +41 -0
  58. data/spec/rtm/sugar/role/counterparts_spec.rb +174 -172
  59. data/spec/rtm/sugar/topic/best_name_spec.rb +25 -0
  60. data/spec/rtm/sugar/topic/characteristics_spec.rb +20 -5
  61. data/spec/rtm/sugar/topic/counterparts_spec.rb +41 -1
  62. data/spec/rtm/sugar/topic/hash_access_spec.rb +1 -1
  63. data/spec/rtm/sugar/topic/scoped_spec.rb +178 -114
  64. data/spec/rtm/sugar/topic/topic_ref_spec.rb +10 -10
  65. data/spec/rtm/sugar/topic/typed_spec.rb +196 -134
  66. data/spec/rtm/sugar/topic_map/themes_spec.rb +67 -0
  67. data/spec/rtm/sugar/typed/types_spec.rb +1 -1
  68. data/spec/rtm/tmapi/core/association_spec.rb +2 -2
  69. data/spec/rtm/tmapi/core/datatype_aware_spec.rb +236 -0
  70. data/spec/rtm/tmapi/core/name_spec.rb +186 -1
  71. data/spec/rtm/tmapi/core/occurrence_spec.rb +24 -67
  72. data/spec/rtm/tmapi/core/reifiable_spec.rb +2 -2
  73. data/spec/rtm/tmapi/core/scoped_spec.rb +40 -2
  74. data/spec/rtm/tmapi/core/topic_map_spec.rb +98 -30
  75. data/spec/rtm/tmapi/core/topic_spec.rb +558 -82
  76. data/spec/rtm/tmapi/core/variant_spec.rb +3 -3
  77. data/spec/rtm_spec.rb +0 -1
  78. data/spec/spec_helper.rb +7 -2
  79. data/test/javalibs/junit-4.5.jar +0 -0
  80. data/test/javalibs/tmapi-2.0-tests.jar +0 -0
  81. data/test/tmapi_tests.rb +25 -0
  82. metadata +66 -11
  83. data/lib/rtm/io/ontopia_io.rb +0 -25
  84. data/lib/rtm/io/tmapix.rb +0 -234
  85. data/lib/rtm/sugar/occurrence/externalize.rb +0 -31
  86. data/spec/rtm/io/tmapix_spec.rb +0 -85
  87. data/test/base_unit_test.rb +0 -161
  88. data/test/base_unit_test_tmapi.rb +0 -165
data/lib/rtm/io.rb CHANGED
@@ -14,5 +14,6 @@ end
14
14
 
15
15
 
16
16
  require 'rtm/io/to_yaml'
17
- require 'rtm/io/tmapix'
17
+ require 'rtm/io/tmapix_from'
18
+ require 'rtm/io/tmapix_to'
18
19
  require 'rtm/io/to_string'
@@ -0,0 +1,155 @@
1
+ # Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
2
+ # License: Apache License, Version 2.0
3
+
4
+ module RTM::IO
5
+ # Import for TMAPI Topic Maps
6
+ # Utilizing the TMAPIX libary http://code.google.com/p/tmapix/
7
+ # Consequently the deserializers provided here are only wrappers
8
+
9
+ module TmapiXFrom
10
+ module TopicMap
11
+
12
+ def from_anything(reader_class, *args)
13
+ raise "Only supported for TMAPI backends!!" unless self.kind_of?(Java::OrgTmapiCore::TopicMap) || self.kind_of?(Java::OrgTmapiCore::TopicMapSystem)
14
+
15
+ params = {}
16
+ # See if we got a params hash. It must be at the end, if it is given.
17
+ # Take it off, so it won't be unshifted later.
18
+ params = args.pop if args.last.is_a?(Hash)
19
+
20
+ # Take the source as next (i.e. second after the writer) positional parameter or from hash.
21
+ # Leave nil if neither found.
22
+ source = args.shift || params[:source]
23
+
24
+ # Take the base_iri as next (i.e. third after the file) positional parameter or from the hash.
25
+ # Use the topic maps's base_iri if neither found.
26
+ base_iri = args.shift || params[:base_iri]
27
+ unless base_iri
28
+ if self.kind_of?(RTM::TopicMap)
29
+ base_iri = self.base_iri
30
+ else
31
+ base_iri = "imported:FIXME"
32
+ end
33
+ end
34
+
35
+ if self.kind_of?(RTM::TopicMap)
36
+ topic_map = self
37
+ else
38
+ topic_map = create(base_iri)
39
+ end
40
+
41
+ reader_class.new(topic_map, java.io.File.new(source)).read
42
+ topic_map
43
+ end
44
+
45
+ # Reads a Topic Map from an LTM File
46
+ # whose location is given as String parameter.
47
+ #
48
+ # :call-seq:
49
+ # from_ltm(filename)
50
+ #
51
+ def from_ltm(*args)
52
+ from_anything(org.tmapix.io.LTMTopicMapReader, *args)
53
+ end
54
+
55
+ # Reads a Topic Map from an CTM File
56
+ # whose location is given as String parameter.
57
+ #
58
+ # :call-seq:
59
+ # from_ctm(filename)
60
+ #
61
+ def from_ctm(*args)
62
+ from_anything(org.tmapix.io.CTMTopicMapReader, *args)
63
+ end
64
+
65
+ # Reads a JSON Topic Maps (JTM) File
66
+ # whose location is given as String parameter.
67
+ #
68
+ # :call-seq:
69
+ # from_jtm(filename)
70
+ #
71
+ def from_jtm(*args)
72
+ # seems not to acceped all files that are found to be valid by the JTM validator
73
+ from_anything(org.tmapix.io.JTMTopicMapReader, *args)
74
+ end
75
+
76
+ # Reads a Friendly Topic Maps XML (TM/XML) File
77
+ # independent of the version
78
+ # whose location is given as String parameter.
79
+ #
80
+ # :call-seq:
81
+ # from_tmxml(filename)
82
+ #
83
+ def from_tmxml(*args)
84
+ from_anything(org.tmapix.io.TMXMLTopicMapReader, *args)
85
+ end
86
+
87
+ # Reads a XML Topic Maps (XTM) 1.0 File
88
+ # whose location is given as String parameter.
89
+ #
90
+ # :call-seq:
91
+ # from_xtm10(filename)
92
+ #
93
+ def from_xtm10(*args)
94
+ from_anything(org.tmapix.io.XTM10TopicMapReader, *args)
95
+ end
96
+ alias :from_xtm1 :from_xtm10
97
+
98
+ # Reads a XML Topic Maps (XTM) 2.0 File
99
+ # whose location is given as String parameter.
100
+ #
101
+ # :call-seq:
102
+ # from_xtm20(filename)
103
+ #
104
+ def from_xtm20(*args)
105
+ from_xtm(*args)
106
+ end
107
+ alias :from_xtm2 :from_xtm20
108
+
109
+ # Reads a XML Topic Maps (XTM) File
110
+ # independent of the version
111
+ # whose location is given as String parameter.
112
+ #
113
+ # :call-seq:
114
+ # from_xtm(filename)
115
+ #
116
+ def from_xtm(*args)
117
+ from_anything(org.tmapix.io.XTMTopicMapReader, *args)
118
+ end
119
+
120
+ # Reads a Notation3 (N3) File
121
+ # whose location is given as String .
122
+ # The source vocabulary must
123
+ # provide the mapping vocabulary.
124
+ # The syntax of the vocabulary is guessed.
125
+ #
126
+ # :call-seq:
127
+ # from_n3(filename, source vocabulary)
128
+ #
129
+ def from_n3(filename, vocab)
130
+ raise "Only supported for TMAPI backends!!" unless self.kind_of? Java::OrgTmapiCore::TopicMap
131
+ reader = org.tmapix.io.N3TopicMapReader.new self, java.io.File.new(filename)
132
+ reader.setMappingSource(java.io.File.new(vocab))
133
+ reader.read
134
+ end
135
+
136
+ # Reads a RDF/XML File
137
+ # whose location is given as String
138
+ # The source vocabulary must
139
+ # provide the mapping vocabulary.
140
+ # The syntax of the vocabulary is guessed.
141
+ #
142
+ # :call-seq:
143
+ # from_rdfxml(filename, source vocabulary)
144
+ #
145
+ def from_rdfxml(filename, vocab)
146
+ raise "Only supported for TMAPI backends!!" unless self.kind_of? Java::OrgTmapiCore::TopicMap
147
+ reader = org.tmapix.io.RDFXMLTopicMapReader.new self, java.io.File.new(filename)
148
+ reader.setMappingSource(java.io.File.new(vocab))
149
+ reader.read
150
+ end
151
+ end
152
+ TopicMapSystem = TopicMap # We want importers for both, TopicMap and TopicMapSystem
153
+ RTM.register_extension(self)
154
+ end
155
+ end
@@ -0,0 +1,223 @@
1
+ # Copyright: Copyright 2009 Topic Maps Lab, University of Leipzig.
2
+ # License: Apache License, Version 2.0
3
+
4
+ module RTM::IO
5
+ # Export of TMAPI Topic Maps
6
+ # Utilizing the TMAPIX libary http://code.google.com/p/tmapix/
7
+ # Consequently the serializers provided here are only wrappers
8
+
9
+ module TmapiXTo
10
+ module TopicMap
11
+
12
+ private
13
+ # Serializes a Topic Map using the given writer.
14
+ #
15
+ # If the optional file is given (using the positional parameter or the :file keys in the params hash),
16
+ # it is written to that file, otherwise a String will be returned.
17
+ # The file can be provided as a String (which is then interpreted as a filename) or as a java.io.OutputStream.
18
+ # E.g. to_anything(my_writer, "/some/file") # writes to the file
19
+ # to_anything(my_writer, some_output_stream) # writes to the outputstream
20
+ # E.g. to_anything(my_writer, :file => "/some/file") # writes to the file
21
+ # to_anything(my_writer) # returns a string
22
+ #
23
+ # If the optional base_iri is given (using the positional parameter or the :base_iri key in the params hash),
24
+ # the given base_iri will be used during export. Otherwise the topic maps's base_iri will be used.
25
+ # E.g. to_anything(my_writer, "/some/file", "http://example.org/something") # uses the base_iri given
26
+ # to_anything(my_writer) # uses the base_iri of the topic map
27
+ #
28
+ # Please be aware that you cannot leave out the filename positional parameter and just provide the base_iri.
29
+ # If you want to provide a base_iri but no filename provide +nil+ as filename or use the params hash.
30
+ # E.g. to_anything(my_writer, nil, my_base_iri)
31
+ # to_anything(my_writer, :base_iri => my_base_iri)
32
+ #
33
+ # :call-seq:
34
+ # to_anything(writer_class, params = {})
35
+ # to_anything(writer_class, file, params = {})
36
+ # to_anything(writer_class, file, base_iri, params={})
37
+ #
38
+ def to_anything(writer_class, *args)
39
+ raise("Only supported for TMAPI backends.") unless self.kind_of?(Java::OrgTmapiCore::TopicMap)
40
+ params = {}
41
+ # See if we got a params hash. It must be at the end, if it is given.
42
+ # Take it off, so it won't be unshifted later.
43
+ params = args.pop if args.last.is_a?(Hash)
44
+
45
+ # Take the file as next (i.e. second after the writer) positional parameter or from hash.
46
+ # Leave nil if neither found.
47
+ file = args.shift || params[:file]
48
+
49
+ # Take the base_iri as next (i.e. third after the file) positional parameter or from the hash.
50
+ # Use the topic maps's base_iri if neither found.
51
+ base_iri = args.shift || params[:base_iri] || self.base_iri
52
+
53
+ # If a file was provided somehow, we wrap it with output streams
54
+ if file
55
+ if file.is_a?(java.io.OutputStream)
56
+ out_stream = file
57
+ else
58
+ out_stream = java.io.BufferedOutputStream.new(java.io.FileOutputStream.new(file))
59
+ end
60
+ else
61
+ # if no file was given we want to return a string which will be written into a stream by the writer
62
+ out_stream = java.io.ByteArrayOutputStream.new
63
+ end
64
+
65
+ # create the java writer
66
+ writer = writer_class.new(out_stream, base_iri)
67
+ # set params
68
+ params.each do |k,v|
69
+ # skip our params, as they're not of interest for the writer
70
+ next if k == :file || k == :base_iri
71
+ writer.setProperty(k.to_s,v.to_s)
72
+ end if writer.respond_to?(:setProperty)
73
+ # do the actual work
74
+ writer.write(self)
75
+ out_stream.flush
76
+
77
+ # close the file unless we were provided with a stream
78
+ out_stream.close unless file && file.is_a?(java.io.OutputStream)
79
+
80
+ # if there was no file, we have a ByteArrayOutputStream. Get the String out of it (and return it)
81
+ # otherwise, we return true
82
+ return file ? true : out_stream.to_s
83
+ end
84
+
85
+ public
86
+ # Serializes an RTM::TopicMap to XTM v. 2.0.
87
+ #
88
+ # If no argument is given, a String is returned.
89
+ #
90
+ # The argument file can be provided as a String
91
+ # (which is then interpreted as a filename) or as a java.io.OutputStream.
92
+ #
93
+ # The argument base_iri may be used to define a new base_iri, if not, the current
94
+ # one is used. Base_iri may be a String.
95
+ #
96
+ # :call-seq:
97
+ # to_xtm20
98
+ # to_xtm20(file)
99
+ # to_xtm20(file, base_iri)
100
+ #
101
+ def to_xtm20(*args)
102
+ to_anything(org.tmapix.io.XTM20TopicMapWriter, *args)
103
+ end
104
+ alias :to_xtm :to_xtm20
105
+ alias :to_xtm2 :to_xtm20
106
+
107
+ # Serializes an RTM::TopicMap to XTM v. 1.0.
108
+ #
109
+ # If no argument is given, a String is returned.
110
+ #
111
+ # The argument file can be provided as a String
112
+ # (which is then interpreted as a filename) or as a java.io.OutputStream.
113
+ #
114
+ # The argument base_iri may be used to define a new base_iri, if not, the current
115
+ # one is used. Base_iri may be a String.
116
+ #
117
+ # :call-seq:
118
+ # to_xtm10
119
+ # to_xtm10(file)
120
+ # to_xtm10(file, base_iri)
121
+ #
122
+ def to_xtm10(*args)
123
+ to_anything(org.tmapix.io.XTM10TopicMapWriter, *args)
124
+ end
125
+ alias :to_xtm1 :to_xtm10
126
+
127
+ # Serializes an RTM::TopicMap to JTM.
128
+ #
129
+ # If no argument is given, a String is returned.
130
+ #
131
+ # The argument file can be provided as a String
132
+ # (which is then interpreted as a filename) or as a java.io.OutputStream.
133
+ #
134
+ # The argument base_iri may be used to define a new base_iri, if not, the current
135
+ # one is used. Base_iri may be a String.
136
+ #
137
+ # :call-seq:
138
+ # to_jtm
139
+ # to_jtm(file)
140
+ # to_jtm(file, base_iri)
141
+ #
142
+ def to_jtm(*args)
143
+ to_anything(org.tmapix.io.JTMTopicMapWriter, *args)
144
+ end
145
+ alias :to_json :to_jtm
146
+
147
+ # Serializes an RTM::TopicMap to LTM.
148
+ #
149
+ # If no argument is given, a String is returned.
150
+ #
151
+ # The argument file can be provided as a String
152
+ # (which is then interpreted as a filename) or as a java.io.OutputStream.
153
+ #
154
+ # The argument base_iri may be used to define a new base_iri, if not, the current
155
+ # one is used. Base_iri may be a String.
156
+ #
157
+ # :call-seq:
158
+ # to_ltm
159
+ # to_ltm(file)
160
+ # to_ltm(file, base_iri)
161
+ #
162
+ def to_ltm(*args)
163
+ to_anything(org.tmapix.io.LTMTopicMapWriter, *args)
164
+ end
165
+
166
+ # Serializes an RTM::TopicMap to TM/XML.
167
+ #
168
+ # If no argument is given, a String is returned.
169
+ #
170
+ # The argument file can be provided as a String
171
+ # (which is then interpreted as a filename) or as a java.io.OutputStream.
172
+ #
173
+ # The argument base_iri may be used to define a new base_iri, if not, the current
174
+ # one is used. Base_iri may be a String.
175
+ #
176
+ # :call-seq:
177
+ # to_tmxml
178
+ # to_tmxml(file)
179
+ # to_tmxml(file, base_iri)
180
+ #
181
+ def to_tmxml(*args)
182
+ to_anything(org.tmapix.io.TMXMLTopicMapWriter, *args)
183
+ end
184
+
185
+ # Serializes an RTM::TopicMap to CTM.
186
+ #
187
+ # If no argument is given, a String is returned.
188
+ #
189
+ # The argument file can be provided as a String
190
+ # (which is then interpreted as a filename) or as a java.io.OutputStream.
191
+ #
192
+ # The argument base_iri may be used to define a new base_iri, if not, the current
193
+ # one is used. Base_iri may be a String.
194
+ #
195
+ # A property-Hash may be given to set properties of the writer.
196
+ #
197
+ # :call-seq:
198
+ # to_ctm(properties={})
199
+ # to_ctm(file, properties={})
200
+ # to_ctm(file, base_iri, properties={})
201
+ #
202
+ def to_ctm(*args)
203
+ # set default params
204
+ default_params = {
205
+ "writer.features.export.itemidentifier" => false,
206
+ "writer.features.prefixDetection.enabled" => false,
207
+ "writer.features.templateDetection.enabled" => false,
208
+ "writer.features.templateDetection.topicTemplates" => false,
209
+ "writer.features.templateDetection.associationTemplates" => false,
210
+ "writer.features.templateMerger.enabled" => false
211
+ }
212
+ # enhance the args with the default params
213
+ if args.last.is_a?(Hash)
214
+ args.push(default_params.merge(args.pop))
215
+ else
216
+ args.push(default_params)
217
+ end
218
+ to_anything(de.topicmapslab.ctm.writer.core.CTMTopicMapWriter, *args)
219
+ end
220
+ end
221
+ RTM.register_extension(self)
222
+ end
223
+ end
@@ -2,25 +2,39 @@
2
2
  # License: Apache License, Version 2.0
3
3
 
4
4
  module RTM::IO
5
- # HASH Export.
5
+ # Hash Export.
6
6
  # Each Topic Maps Construct gets a to_hash method.
7
- module TOHASH
7
+ module ToHash
8
8
 
9
9
  module TopicMap
10
- # Returns the Hash representation of this RTM::TopicMap
10
+ # Returns the Hash representation of this topic map.
11
+ #
12
+ # The returned Hash holds information about the :reifier,
13
+ # the :item_identifiers, the :topics and :associations.
14
+ #
15
+ # :call-seq:
16
+ # to_hash -> Hash
17
+ #
11
18
  def to_hash
12
19
  h={}
13
- h[:reifier] = reifier.to_ref if reifier
20
+ h[:reifier] = reifier.reference if reifier
14
21
  h[:item_identifiers] = item_identifiers.map{|i| i.reference} unless item_identifiers.empty?
15
22
  h[:topics] = topics.map{|i| i.to_hash} unless topics.empty?
16
23
  h[:associations] = associations.map{|i| i.to_hash} unless associations.empty?
17
24
  h
18
25
  end
19
26
  end
20
-
21
-
27
+
22
28
  module Topic
23
- # Returns the Hash representation of this RTM::Topic
29
+ # Returns the Hash representation of this topic.
30
+ #
31
+ # The returned Hash holds information about the :subject_identifiers,
32
+ # the :item_identifiers, the :subject_locators, the :names and the
33
+ # :occurrences.
34
+ #
35
+ # :call-seq:
36
+ # to_hash -> Hash
37
+ #
24
38
  def to_hash
25
39
  h = {}
26
40
  h[:item_identifiers] = item_identifiers.map{|i| i.reference} unless item_identifiers.empty?
@@ -30,87 +44,111 @@ module RTM::IO
30
44
  h[:occurrences] = occurrences.map{|i| i.to_hash} unless occurrences.empty?
31
45
  h
32
46
  end
33
- # Returns the reference to the Topic
34
- def to_ref
35
- if subject_identifiers.first
36
- return "si:#{subject_identifiers.first.reference.to_s}"
37
- end
38
- if item_identifiers.first
39
- return "ii:#{item_identifiers.first.reference.to_s}"
40
- end
41
- # "t#{id}"
42
- end
43
47
  end
44
48
 
45
49
  module Name
46
- # Returns the Hash representation of this RTM::Name
50
+ # Returns the Hash representation of this name.
51
+ #
52
+ # The returned Hash holds information about the :reifier,
53
+ # the :item_identifiers, the :value, the :type, the :scope and the
54
+ # :variants.
55
+ #
56
+ # :call-seq:
57
+ # to_hash -> Hash
58
+ #
47
59
  def to_hash
48
60
  h={}
49
- h[:reifier] = reifier.to_ref if reifier
61
+ h[:reifier] = reifier.reference if reifier
50
62
  h[:item_identifiers] = item_identifiers.map{|i| i.reference} unless item_identifiers.empty?
51
63
  h[:value] = value if value
52
- h[:type] = type.to_ref if type
53
- h[:scope] = scope.map{|i| i.to_ref} unless scope.empty?
64
+ h[:type] = type.reference if type
65
+ h[:scope] = scope.map{|i| i.reference} unless scope.empty?
54
66
  h[:variants] = variants.map{|i| i.to_hash} unless variants.empty?
55
67
  h
56
68
  end
57
69
  end
58
70
 
59
-
60
71
  module Association
61
- # Returns the Hash representation of this RTM::Association
72
+ # Returns the Hash representation of this association.
73
+ #
74
+ # The returned Hash holds information about the :reifier,
75
+ # the :item_identifiers, the :type, the :scope and the :roles.
76
+ #
77
+ # :call-seq:
78
+ # to_hash -> Hash
79
+ #
62
80
  def to_hash
63
81
  h={}
64
- h[:reifier] = reifier.to_ref if reifier
82
+ h[:reifier] = reifier.reference if reifier
65
83
  h[:item_identifiers] = item_identifiers.map{|i| i.reference} unless item_identifiers.empty?
66
- h[:type] = type.to_ref if type
67
- h[:scope] = scope.map{|i| i.to_ref} unless scope.empty?
84
+ h[:type] = type.reference if type
85
+ h[:scope] = scope.map{|i| i.reference} unless scope.empty?
68
86
  h[:roles] = roles.map{|i| i.to_hash} unless roles.empty?
69
87
  h
70
88
  end
71
89
  end
72
90
 
73
-
74
-
75
91
  module Occurrence
76
- # Returns the Hash representation of this RTM::Occurrence
92
+ # Returns the Hash representation of this occurrence.
93
+ #
94
+ # The returned Hash holds information about the :reifier,
95
+ # the :item_identifiers, the :value, the :datatype, the :type
96
+ # and the :scope.
97
+ #
98
+ # :call-seq:
99
+ # to_hash -> Hash
100
+ #
77
101
  def to_hash
78
102
  h={}
79
- h[:reifier] = reifier.to_ref if reifier
103
+ h[:reifier] = reifier.reference if reifier
80
104
  h[:item_identifiers] = item_identifiers.map{|i| i.reference} unless item_identifiers.empty?
81
105
  h[:value] = value if value
82
106
  h[:datatype] = datatype.reference if datatype
83
- h[:type] = type.to_ref if type
84
- h[:scope] = scope.map{|i| i.to_ref} unless scope.empty?
107
+ h[:type] = type.reference if type
108
+ h[:scope] = scope.map{|i| i.reference} unless scope.empty?
85
109
  h
86
110
  end
87
111
  end
88
112
 
89
113
  module Role
90
- # Returns the Hash representation of this RTM::Role
114
+ # Returns the Hash representation of this role.
115
+ #
116
+ # The returned Hash holds information about the :reifier,
117
+ # the :item_identifiers, the :player, and the :type.
118
+ #
119
+ # :call-seq:
120
+ # to_hash -> Hash
121
+ #
91
122
  def to_hash
92
123
  h={}
93
- h[:reifier] = reifier.to_ref if reifier
124
+ h[:reifier] = reifier.reference if reifier
94
125
  h[:item_identifiers] = item_identifiers.map{|i| i.reference} unless item_identifiers.empty?
95
- h[:player] = player.to_ref if player
96
- h[:type] = type.to_ref if type
126
+ h[:player] = player.reference if player
127
+ h[:type] = type.reference if type
97
128
  h
98
129
  end
99
130
  end
100
131
 
101
132
  module Variant
102
- # Returns the Hash representation of this RTM::Variant
103
- def to_hash(*a)
133
+ # Returns the Hash representation of this variant.
134
+ #
135
+ # The returned Hash holds information about the :reifier,
136
+ # the :item_identifiers, the :value and the :scope.
137
+ #
138
+ # :call-seq:
139
+ # to_hash -> Hash
140
+ #
141
+ def to_hash
104
142
  h={}
105
- h[:reifier] = reifier.to_ref if reifier
143
+ h[:reifier] = reifier.reference if reifier
106
144
  h[:item_identifiers] = item_identifiers.map{|i| i.reference} unless item_identifiers.empty?
107
145
  h[:value] = value if value
108
- h[:scope] = scope.map{|i| i.to_ref} unless scope.empty?
146
+ h[:scope] = scope.map{|i| i.reference} unless scope.empty?
109
147
  h
110
148
  end
111
149
  end
112
150
 
113
- RTM.register_extension self
151
+ RTM.register_extension self
114
152
 
115
153
  end
116
154
  end