Module: RTM::AR::IO::TOXTM1::Topic
- Defined in:
- lib/rtm/activerecord/io/to_xtm1.rb
Instance Method Summary collapse
-
#to_xtm1 ⇒ Object
returns the XTM 2.0 representation of this topic as an REXML::Element.
-
#to_xtm1_ref ⇒ Object
returns the an (internal) XTM 2.0 reference to this topic.
-
#xtm1_id ⇒ Object
this is a helper-method for the to_xtm1 amd to_xtm1_ref methods.
Instance Method Details
#to_xtm1 ⇒ Object
returns the XTM 2.0 representation of this topic as an REXML::Element
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/rtm/activerecord/io/to_xtm1.rb', line 63 def to_xtm1 #topic = element topic { id, # (itemIdentity | subjectLocator | subjectIdentifier)*, # instanceOf?, (name | occurrence)* } x = REXML::Element.new('topic') x.add_attribute('id', xtm1_id ) item_identifiers.each { |ii| x << TOXTM1.locator(ii) } # itemIdentity subject_identifiers.each { |si| x << TOXTM1.locator(si, "subjectIdentifier") } # subjectIdentifier if item_identifiers.empty? && subject_identifiers.empty? TOXTM1.locator(xtm1_id) # itemIdentity end subject_locators.each { |sl| x << TOXTM1.locator(sl, "subjectLocator") } # subjectLocator # I guess we won't create instanceOf-Elements but instead type-instance associations. names.each { |n| x << n.to_xtm1 } occurrences.each { |o| x << o.to_xtm1 } x end |
#to_xtm1_ref ⇒ Object
returns the an (internal) XTM 2.0 reference to this topic
81 82 83 84 85 |
# File 'lib/rtm/activerecord/io/to_xtm1.rb', line 81 def to_xtm1_ref x = REXML::Element.new 'topicRef' x.add_attribute('href', "##{xtm1_id}") x end |
#xtm1_id ⇒ Object
this is a helper-method for the to_xtm1 amd to_xtm1_ref methods
59 60 61 |
# File 'lib/rtm/activerecord/io/to_xtm1.rb', line 59 def xtm1_id "t#{id}" end |