Class: VORuby::STC::V1_10::Coords::ScalarCoordinate

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

Overview

Generic scalar coordinate element

Instance Attribute Summary collapse

Attributes inherited from ScalarCoordinateType

#error, #pix_size, #resolution, #size, #value

Attributes inherited from CoordinateType

#name

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SerializableToXml

#element

Methods inherited from ScalarCoordinateType

#initialize

Methods inherited from CoordinateType

#initialize

Constructor Details

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

Instance Attribute Details

#unitObject

Returns the value of attribute unit.



1226
1227
1228
# File 'lib/voruby/stc/1.10/coords.rb', line 1226

def unit
  @unit
end

Class Method Details

.from_xml(xml) ⇒ Object



1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
# File 'lib/voruby/stc/1.10/coords.rb', line 1243

def self.from_xml(xml)
  root = element_from(xml)
  
  options = {
   :name => REXML::XPath.first(root, 'x:Name', {'x' => obj_ns.uri}).text
  }
  unit = root.attributes.get_attribute_ns(obj_ns.uri, 'unit')
  options[:unit] = unit.value if unit
  options[:value] = xml_to_obj(root, CValue, true)
  options[:error] = xml_to_obj(root, CError)
  options[:resolution] = xml_to_obj(root, CResolution)
  options[:size] = xml_to_obj(root, CSize)
  options[:pix_size] = xml_to_obj(root, CPixSize)
  
  ScalarCoordinate.new(options)
end

Instance Method Details

#==(c) ⇒ Object



1232
1233
1234
# File 'lib/voruby/stc/1.10/coords.rb', line 1232

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

#to_xmlObject



1236
1237
1238
1239
1240
1241
# File 'lib/voruby/stc/1.10/coords.rb', line 1236

def to_xml
  el = super('ScalarCoordinate')
  el.attributes["#{obj_ns.prefix}:unit"] = self.unit.to_s if self.unit
  collapse_namespaces(el)
  el
end