Class: VORuby::STC::V1_30::CoordRefFrameType

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

Overview

A generic CoordReferenceFrame.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SerializableToXml

#element

Constructor Details

#initialize(ref_frame_id = nil, name = nil) ⇒ CoordRefFrameType

Returns a new instance of CoordRefFrameType.



6379
6380
6381
6382
# File 'lib/voruby/stc/1.30/stc.rb', line 6379

def initialize(ref_frame_id=nil, name=nil)
  self.ref_frame_id = ref_frame_id
  self.name = name
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



6377
6378
6379
# File 'lib/voruby/stc/1.30/stc.rb', line 6377

def name
  @name
end

#ref_frame_idObject

Returns the value of attribute ref_frame_id.



6377
6378
6379
# File 'lib/voruby/stc/1.30/stc.rb', line 6377

def ref_frame_id
  @ref_frame_id
end

Class Method Details

.coord_ref_frame_from_xml(root) ⇒ Object



6418
6419
6420
6421
6422
6423
6424
6425
6426
# File 'lib/voruby/stc/1.30/stc.rb', line 6418

def self.coord_ref_frame_from_xml(root)
  name = REXML::XPath.first(root, 'x:Name', {'x' => obj_ns.uri})
  
  rfi = root.attributes.get_attribute_ns(obj_ns.uri, 'ref_frame_id')
  [
    rfi ? IdRef.new(rfi.value) : nil,
    name ? name.text : nil
  ]
end

.from_xml(xml) ⇒ Object



6428
6429
6430
6431
# File 'lib/voruby/stc/1.30/stc.rb', line 6428

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

Instance Method Details

#==(f) ⇒ Object



6399
6400
6401
6402
# File 'lib/voruby/stc/1.30/stc.rb', line 6399

def ==(f)
  self.name == f.name and
  self.ref_frame_id == f.ref_frame_id
end

#to_xml(name = nil) ⇒ Object



6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
# File 'lib/voruby/stc/1.30/stc.rb', line 6404

def to_xml(name=nil)
  el = element(name)
  
  if self.name
    name_el = REXML::Element.new("#{obj_ns.prefix}:Name")
    name_el.text = self.name
    el.add_element(name_el)
  end
  
  el.attributes["#{obj_ns.prefix}:ref_frame_id"] = self.ref_frame_id.to_s if self.ref_frame_id
  
  el
end