Class: VORuby::STC::V1_30::Vector2CoordinateType

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

Overview

2-D coordinate type. Single CError2, CResolution2, CSize2, CPixSize2 elements indicate definite values; pairs indicate ranges.

Defined Under Namespace

Classes: CError2List, CPixSize2List, CResolution2List, CSize2List

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.



1891
1892
1893
# File 'lib/voruby/stc/1.30/stc.rb', line 1891

def error
  @error
end

#name1Object

Returns the value of attribute name1.



1891
1892
1893
# File 'lib/voruby/stc/1.30/stc.rb', line 1891

def name1
  @name1
end

#name2Object

Returns the value of attribute name2.



1891
1892
1893
# File 'lib/voruby/stc/1.30/stc.rb', line 1891

def name2
  @name2
end

#pix_sizeObject

Returns the value of attribute pix_size.



1891
1892
1893
# File 'lib/voruby/stc/1.30/stc.rb', line 1891

def pix_size
  @pix_size
end

#resolutionObject

Returns the value of attribute resolution.



1891
1892
1893
# File 'lib/voruby/stc/1.30/stc.rb', line 1891

def resolution
  @resolution
end

#sizeObject

Returns the value of attribute size.



1891
1892
1893
# File 'lib/voruby/stc/1.30/stc.rb', line 1891

def size
  @size
end

#valueObject

Returns the value of attribute value.



1891
1892
1893
# File 'lib/voruby/stc/1.30/stc.rb', line 1891

def value
  @value
end

Class Method Details

.from_xml(xml) ⇒ Object



2000
2001
2002
2003
# File 'lib/voruby/stc/1.30/stc.rb', line 2000

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

.vector2_coordinate_from_xml(root) ⇒ Object



1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
# File 'lib/voruby/stc/1.30/stc.rb', line 1974

def self.vector2_coordinate_from_xml(root)
  options = CoordinateType.coordinate_from_xml(root)
  
  name1 = REXML::XPath.first(root, 'x:Name1', {'x' => obj_ns.uri})
  options[:name1] = name1.text if name1
  
  name2 = REXML::XPath.first(root, 'x:Name2', {'x' => obj_ns.uri})
  options[:name2] = name2.text if name2
  
  options[:value] = xml_to_obj(root, CValue2, true)
  
  options[:error] = Vector2CoordinateType::CError2List.new(xml_to_obj(root, CError2))
  options[:error] = nil if options[:error].size == 0
  
  options[:resolution] = Vector2CoordinateType::CResolution2List.new(xml_to_obj(root, CResolution2))
  options[:resolution] = nil if options[:resolution].size == 0
  
  options[:size] = Vector2CoordinateType::CSize2List.new(xml_to_obj(root, CSize2))
  options[:size] = nil if options[:size].size == 0
  
  options[:pix_size] = Vector2CoordinateType::CPixSize2List.new(xml_to_obj(root, CPixSize2))
  options[:pix_size] = nil if options[:pix_size].size == 0
  
  options
end

Instance Method Details

#==(c) ⇒ Object



1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
# File 'lib/voruby/stc/1.30/stc.rb', line 1938

def ==(c)
  super(c) and
  self.name1 == c.name1 and
  self.name2 == c.name2 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



1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
# File 'lib/voruby/stc/1.30/stc.rb', line 1949

def to_xml(name=nil)
  el = super(name)
  
  if self.name1
    name1_el = REXML::Element.new("#{obj_ns.prefix}:Name1")
    name1_el.text = self.name1
    el.add_element(name1_el)
  end
  
  if self.name2
    name2_el = REXML::Element.new("#{obj_ns.prefix}:Name2")
    name2_el.text = self.name2
    el.add_element(name2_el)
  end
  
  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