Module: RTM::AR::IO::TOXTM1::TopicName

Defined in:
lib/rtm/activerecord/io/to_xtm1.rb

Instance Method Summary collapse

Instance Method Details

#to_xtm1Object



104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/rtm/activerecord/io/to_xtm1.rb', line 104

def to_xtm1
  warn("TOXTM1: Warning: outputting invalid TopicName #{self}") unless valid?
  # name = element name { reifiable, type?, scope?, value, variant* }
  x = REXML::Element.new 'name'
  x.add_attribute('reifier', reifier.xtm1_id) if reifier
  item_identifiers.each { |ii| x << TOXTM1.ii(ii) } # itemIdentity
  x << TOXTM1.type(type) if type
  x << TOXTM1.scope(scope) unless scope.empty?
  (x << REXML::Element.new('value')).text = value # adds the value within a value-element
  variants.each { |v| x << v.to_xtm1 }
  x
end