Class: VORuby::STC::V1_10::Coords::TimeCoordinate
- Inherits:
-
CoordinateType
- Object
- CoordinateType
- VORuby::STC::V1_10::Coords::TimeCoordinate
- Includes:
- SerializableToXml
- Defined in:
- lib/voruby/stc/1.10/coords.rb
Overview
Time coordinate type. Single CError, CResolution, CSize, CPixSize elements indicate definite values; pairs indicate ranges.
Instance Attribute Summary collapse
-
#error ⇒ Object
Returns the value of attribute error.
-
#pix_size ⇒ Object
Returns the value of attribute pix_size.
-
#resolution ⇒ Object
Returns the value of attribute resolution.
-
#size ⇒ Object
Returns the value of attribute size.
-
#time_instant ⇒ Object
Returns the value of attribute time_instant.
Attributes inherited from CoordinateType
Class Method Summary collapse
Instance Method Summary collapse
- #==(tc) ⇒ Object
-
#initialize(options = {}) ⇒ TimeCoordinate
constructor
A new instance of TimeCoordinate.
- #to_xml(name = nil) ⇒ Object
- #unit ⇒ Object
- #unit=(u) ⇒ Object
Methods included from SerializableToXml
Constructor Details
#initialize(options = {}) ⇒ TimeCoordinate
Returns a new instance of TimeCoordinate.
774 775 776 |
# File 'lib/voruby/stc/1.10/coords.rb', line 774 def initialize(={}) .each { |key, value| send("#{key}=", value) } end |
Instance Attribute Details
#error ⇒ Object
Returns the value of attribute error.
772 773 774 |
# File 'lib/voruby/stc/1.10/coords.rb', line 772 def error @error end |
#pix_size ⇒ Object
Returns the value of attribute pix_size.
772 773 774 |
# File 'lib/voruby/stc/1.10/coords.rb', line 772 def pix_size @pix_size end |
#resolution ⇒ Object
Returns the value of attribute resolution.
772 773 774 |
# File 'lib/voruby/stc/1.10/coords.rb', line 772 def resolution @resolution end |
#size ⇒ Object
Returns the value of attribute size.
772 773 774 |
# File 'lib/voruby/stc/1.10/coords.rb', line 772 def size @size end |
#time_instant ⇒ Object
Returns the value of attribute time_instant.
772 773 774 |
# File 'lib/voruby/stc/1.10/coords.rb', line 772 def time_instant @time_instant end |
Class Method Details
.from_xml(xml) ⇒ Object
867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 |
# File 'lib/voruby/stc/1.10/coords.rb', line 867 def self.from_xml(xml) root = element_from(xml) = { :name => REXML::XPath.first(root, 'x:Name', {'x' => obj_ns.uri}).text } unit = root.attributes.get_attribute_ns(obj_ns.uri, 'unit') [:unit] = TimeUnit.new(unit.value) if unit time_instant = REXML::XPath.first(root, 'x:TimeInstant', {'x' => obj_ns.uri}) [:time_instant] = AstronTime.from_xml(time_instant) if time_instant [:error] = xml_to_obj(root, CError) [:resolution] = xml_to_obj(root, CResolution) [:size] = xml_to_obj(root, CSize) [:pix_size] = xml_to_obj(root, CPixSize) TimeCoordinate.new() end |
Instance Method Details
#==(tc) ⇒ Object
887 888 889 890 891 892 893 894 895 |
# File 'lib/voruby/stc/1.10/coords.rb', line 887 def ==(tc) super(tc) and self.time_instant == tc.time_instant and self.error == tc.error and self.resolution == tc.resolution and self.size == tc.size and self.pix_size == tc.pix_size and self.unit == tc.unit end |
#to_xml(name = nil) ⇒ Object
848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 |
# File 'lib/voruby/stc/1.10/coords.rb', line 848 def to_xml(name=nil) el = element(name) 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 el.add_element(name) el.add_element(self.time_instant.to_xml('TimeInstant')) if self.time_instant 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 |
#unit ⇒ Object
844 845 846 |
# File 'lib/voruby/stc/1.10/coords.rb', line 844 def unit @unit || TimeUnit.new('s') end |
#unit=(u) ⇒ Object
839 840 841 842 |
# File 'lib/voruby/stc/1.10/coords.rb', line 839 def unit=(u) raise_type_mismatch_error(u, TimeUnit) if u @unit = u end |