Class: VORuby::STC::V1_30::BasicCoordinateType

Inherits:
CoordinateType show all
Defined in:
lib/voruby/stc/1.30/stc.rb

Overview

Basic scalar coordinate type. Single Error, Resolution, Size, PixSize elements indicate definite values; pairs indicate ranges.

Instance Attribute Summary collapse

Attributes inherited from CoordinateType

#frame_id, #name

Attributes included from STCReference

#id, #idref, #ucd, #xlink_href, #xlink_type

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from CoordinateType

coordinate_from_xml

Methods inherited from STCBaseType

#initialize, stc_base_from_xml

Methods included from STCReference

#stc_reference_eq, stc_reference_from_xml, #stc_reference_to_xml

Methods included from SerializableToXml

#element

Constructor Details

This class inherits a constructor from VORuby::STC::V1_30::STCBaseType

Instance Attribute Details

#errorObject

Returns the value of attribute error.



1501
1502
1503
# File 'lib/voruby/stc/1.30/stc.rb', line 1501

def error
  @error
end

#pix_sizeObject

Returns the value of attribute pix_size.



1501
1502
1503
# File 'lib/voruby/stc/1.30/stc.rb', line 1501

def pix_size
  @pix_size
end

#resolutionObject

Returns the value of attribute resolution.



1501
1502
1503
# File 'lib/voruby/stc/1.30/stc.rb', line 1501

def resolution
  @resolution
end

#sizeObject

Returns the value of attribute size.



1501
1502
1503
# File 'lib/voruby/stc/1.30/stc.rb', line 1501

def size
  @size
end

#valueObject

Returns the value of attribute value.



1501
1502
1503
# File 'lib/voruby/stc/1.30/stc.rb', line 1501

def value
  @value
end

Class Method Details

.basic_coordinate_from_xml(root) ⇒ Object



1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
# File 'lib/voruby/stc/1.30/stc.rb', line 1562

def self.basic_coordinate_from_xml(root)
  options = CoordinateType.coordinate_from_xml(root)
  
  value = REXML::XPath.first(root, 'x:Value', {'x' => obj_ns.uri})
  options[:value] = Value.from_xml(value) if value
  
  error = REXML::XPath.match(root, 'x:Error', {'x' => obj_ns.uri})
  options[:error] = ErrorList.new(error.collect{ |e| Error.from_xml(e) }) if error
  options[:error] = nil if options[:error].size == 0
  
  resolution = REXML::XPath.match(root, 'x:Resolution', {'x' => obj_ns.uri})
  options[:resolution] = ResolutionList.new(resolution.collect{ |r| Resolution.from_xml(r) }) if resolution
  options[:resolution] = nil if options[:resolution].size == 0
  
  size = REXML::XPath.match(root, 'x:Size', {'x' => obj_ns.uri})
  options[:size] = SizeList.new(size.collect{ |s| Size.from_xml(s) }) if size
  options[:size] = nil if options[:size].size == 0
  
  pix_size = REXML::XPath.match(root, 'x:PixSize', {'x' => obj_ns.uri})
  options[:pix_size] = PixSizeList.new(pix_size.collect{ |p| PixSize.from_xml(p) }) if pix_size
  options[:pix_size] = nil if options[:pix_size].size == 0
  
  options
end

.from_xml(xml) ⇒ Object



1587
1588
1589
1590
# File 'lib/voruby/stc/1.30/stc.rb', line 1587

def self.from_xml(xml)
  root = element_from(xml)
  self.new(basic_coordinate_from_xml(root))
end

Instance Method Details

#==(c) ⇒ Object



1540
1541
1542
1543
1544
1545
1546
1547
# File 'lib/voruby/stc/1.30/stc.rb', line 1540

def ==(c)
  super(c) and
  self.value == c.value and
  self.error == c.error and
  self.resolution == c.resolution and
  self.size == c.size and
  self.pix_size == c.pix_size
end

#to_xml(name = nil) ⇒ Object



1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
# File 'lib/voruby/stc/1.30/stc.rb', line 1549

def to_xml(name=nil)
  el = super(name)
  
  el.add_element(self.value.to_xml) if self.value
  self.error.each{ |e| el.add_element(e.to_xml) } if self.error
  self.resolution.each{ |r| el.add_element(r.to_xml) } if self.resolution
  self.size.each{ |s| el.add_element(s.to_xml) } if self.size
  self.pix_size.each{ |p| el.add_element(p.to_xml) } if self.pix_size
  
  collapse_namespaces(el)
  el
end