Class: VORuby::STC::V1_30::Vector3CoordinateType

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

Overview

3-D coordinate type. Single CError3, CResolution3, CSize3, CPixSize3 elements indicate definite values; pairs indicate ranges.

Defined Under Namespace

Classes: CError3List, CPixSize3List, CResolution3List, CSize3List

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.



2215
2216
2217
# File 'lib/voruby/stc/1.30/stc.rb', line 2215

def error
  @error
end

#name1Object

Returns the value of attribute name1.



2215
2216
2217
# File 'lib/voruby/stc/1.30/stc.rb', line 2215

def name1
  @name1
end

#name2Object

Returns the value of attribute name2.



2215
2216
2217
# File 'lib/voruby/stc/1.30/stc.rb', line 2215

def name2
  @name2
end

#name3Object

Returns the value of attribute name3.



2215
2216
2217
# File 'lib/voruby/stc/1.30/stc.rb', line 2215

def name3
  @name3
end

#pix_sizeObject

Returns the value of attribute pix_size.



2215
2216
2217
# File 'lib/voruby/stc/1.30/stc.rb', line 2215

def pix_size
  @pix_size
end

#resolutionObject

Returns the value of attribute resolution.



2215
2216
2217
# File 'lib/voruby/stc/1.30/stc.rb', line 2215

def resolution
  @resolution
end

#sizeObject

Returns the value of attribute size.



2215
2216
2217
# File 'lib/voruby/stc/1.30/stc.rb', line 2215

def size
  @size
end

#valueObject

Returns the value of attribute value.



2215
2216
2217
# File 'lib/voruby/stc/1.30/stc.rb', line 2215

def value
  @value
end

Class Method Details

.from_xml(xml) ⇒ Object



2338
2339
2340
2341
# File 'lib/voruby/stc/1.30/stc.rb', line 2338

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

.vector3_coordinate_from_xml(root) ⇒ Object



2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
# File 'lib/voruby/stc/1.30/stc.rb', line 2309

def self.vector3_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
  
  name3 = REXML::XPath.first(root, 'x:Name3', {'x' => obj_ns.uri})
  options[:name3] = name3.text if name2
  
  options[:value] = xml_to_obj(root, CValue3, true)
  
  options[:error] = Vector3CoordinateType::CError3List.new(xml_to_obj(root, CError3))
  options[:error] = nil if options[:error].size == 0
  
  options[:resolution] = Vector3CoordinateType::CResolution3List.new(xml_to_obj(root, CResolution3))
  options[:resolution] = nil if options[:resolution].size == 0
  
  options[:size] = Vector3CoordinateType::CSize3List.new(xml_to_obj(root, CSize3))
  options[:size] = nil if options[:size].size == 0
  
  options[:pix_size] = Vector3CoordinateType::CPixSize3List.new(xml_to_obj(root, CPixSize3))
  options[:pix_size] = nil if options[:pix_size].size == 0
  
  options
end

Instance Method Details

#==(c) ⇒ Object



2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
# File 'lib/voruby/stc/1.30/stc.rb', line 2266

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



2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
# File 'lib/voruby/stc/1.30/stc.rb', line 2278

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
  
  if self.name3
    name3_el = REXML::Element.new("#{obj_ns.prefix}:Name3")
    name3_el.text = self.name3
    el.add_element(name3_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