Class: VORuby::STC::V1_10::STC::CoordFlavorType

Inherits:
Object
  • Object
show all
Includes:
SerializableToXml
Defined in:
lib/voruby/stc/1.10/stc.rb

Overview

Provides the coordinate definitions: number of axes, SPHERICAL, CARTESIAN, or UNITSPHERE, presence of velocities

Direct Known Subclasses

Cartesian, Geographic, Spherical, UnitSphere

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SerializableToXml

#element

Constructor Details

#initialize(naxes = 2, vel = false) ⇒ CoordFlavorType

Returns a new instance of CoordFlavorType.



989
990
991
992
# File 'lib/voruby/stc/1.10/stc.rb', line 989

def initialize(naxes=2, vel=false)
  self.coord_naxes = naxes
  self.coord_vel = vel
end

Instance Attribute Details

#coord_velObject

Returns the value of attribute coord_vel.



987
988
989
# File 'lib/voruby/stc/1.10/stc.rb', line 987

def coord_vel
  @coord_vel
end

Class Method Details

.from_xml(xml) ⇒ Object



1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
# File 'lib/voruby/stc/1.10/stc.rb', line 1019

def self.from_xml(xml)
  root = element_from(xml)
  
  coord_naxes = root.attributes.get_attribute_ns(obj_ns.uri, 'coord_naxes')
  coord_vel = root.attributes.get_attribute_ns(obj_ns.uri, 'coord_vel')
  
  self.new(
    coord_naxes ? Integer(coord_naxes.value) : nil,
    coord_vel ? (coord_vel.value == 'true' ? true : false) : nil
  )
end

Instance Method Details

#==(f) ⇒ Object



1031
1032
1033
1034
# File 'lib/voruby/stc/1.10/stc.rb', line 1031

def ==(f)
  self.coord_naxes == f.coord_naxes and
  self.coord_vel == f.coord_vel
end

#coord_naxesObject



1000
1001
1002
# File 'lib/voruby/stc/1.10/stc.rb', line 1000

def coord_naxes
  @coord_naxes || 2
end

#coord_naxes=(n) ⇒ Object

Raises:

  • (ArgumentError)


994
995
996
997
998
# File 'lib/voruby/stc/1.10/stc.rb', line 994

def coord_naxes=(n)
  n = Integer(n)
  raise ArgumentError, 'number of axes must be between 1 and 3' if n and (n < 1 or n > 3)
  @coord_naxes = n
end

#to_xml(name = nil) ⇒ Object



1012
1013
1014
1015
1016
1017
# File 'lib/voruby/stc/1.10/stc.rb', line 1012

def to_xml(name=nil)
  el = element(name)
  el.attributes["#{obj_ns.prefix}:coord_naxes"] = self.coord_naxes.to_s
  el.attributes["#{obj_ns.prefix}:coord_vel"] = self.coord_vel.to_s
  el
end