Class: VORuby::STC::V1_10::Coords::StringCoordinate

Inherits:
CoordinateType show all
Includes:
Coordinate
Defined in:
lib/voruby/stc/1.10/coords.rb

Overview

Generic string coordinate element

Instance Attribute Summary collapse

Attributes inherited from CoordinateType

#name

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SerializableToXml

#element

Methods inherited from CoordinateType

#initialize

Constructor Details

This class inherits a constructor from VORuby::STC::V1_10::Coords::CoordinateType

Instance Attribute Details

#unitObject

Returns the value of attribute unit.



1269
1270
1271
# File 'lib/voruby/stc/1.10/coords.rb', line 1269

def unit
  @unit
end

#valueObject

Returns the value of attribute value.



1269
1270
1271
# File 'lib/voruby/stc/1.10/coords.rb', line 1269

def value
  @value
end

Class Method Details

.from_xml(xml) ⇒ Object



1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
# File 'lib/voruby/stc/1.10/coords.rb', line 1303

def self.from_xml(xml)
  root = element_from(xml)
  
  options = {
   :name => REXML::XPath.first(root, 'x:Name', {'x' => obj_ns.uri}).text,
   :value => REXML::XPath.first(root, 'x:Value', {'x' => obj_ns.uri}).text
  }
  unit = root.attributes.get_attribute_ns(obj_ns.uri, 'unit')
  options['unit'] = unit.value if unit
  
  StringCoordinate.new(options)
end

Instance Method Details

#==(c) ⇒ Object



1279
1280
1281
1282
1283
# File 'lib/voruby/stc/1.10/coords.rb', line 1279

def ==(c)
  super(c) and
  self.value == c.value and
  self.unit == c.unit
end

#to_xmlObject



1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
# File 'lib/voruby/stc/1.10/coords.rb', line 1285

def to_xml
  el = element()
  el.attributes["#{obj_ns.prefix}:unit"] = self.unit.to_s if self.unit
  
  name = REXML::Element.new("#{obj_ns.prefix}:Name")
  name.text = self.name
  
  value = REXML::Element.new("#{obj_ns.prefix}:Value")
  value.text = self.value
  
  el.add_element(name)
  el.add_element(value)
  
  collapse_namespaces(el)
  
  el
end