Class: VORuby::STC::V1_30::PosAngleType

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

Overview

Position angles are doubles and include optionally a unit attribute (default deg) and a reference attribute (default X).

Instance Attribute Summary collapse

Attributes included from STCReference

#id, #idref, #ucd, #xlink_href, #xlink_type

Class Method Summary collapse

Instance Method Summary collapse

Methods included from STCReference

#stc_reference_eq, stc_reference_from_xml, #stc_reference_to_xml

Methods included from SerializableToXml

#element

Constructor Details

#initialize(value, options = {}) ⇒ PosAngleType

Returns a new instance of PosAngleType.



190
191
192
193
194
195
196
197
# File 'lib/voruby/stc/1.30/stc.rb', line 190

def initialize(value, options={})
  options[:unit] ||= AngleUnitType.new('deg')
  options[:reference] ||= PosAngleReferenceType.new('X')
  options[:xlink_type] ||= XLink::V1_2::Type.new('simple')
  
  self.value = value
  options.each { |key, value| send("#{key}=", value) }
end

Instance Attribute Details

#referenceObject

Returns the value of attribute reference.



188
189
190
# File 'lib/voruby/stc/1.30/stc.rb', line 188

def reference
  @reference
end

#unitObject

Returns the value of attribute unit.



188
189
190
# File 'lib/voruby/stc/1.30/stc.rb', line 188

def unit
  @unit
end

#valueObject

Returns the value of attribute value.



188
189
190
# File 'lib/voruby/stc/1.30/stc.rb', line 188

def value
  @value
end

Class Method Details

.from_xml(xml) ⇒ Object



244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
# File 'lib/voruby/stc/1.30/stc.rb', line 244

def self.from_xml(xml)
  root = element_from(xml)
  
  value = Float(root.text)
    
  options = STCReference.stc_reference_from_xml(root)
  
  unit_el = root.attributes.get_attribute_ns(obj_ns.uri, 'unit')
  options[:unit] = AngleUnitType.new(unit_el.value) if unit_el
  
  reference_el = root.attributes.get_attribute_ns(obj_ns.uri, 'reference')
  options[:reference] = PosAngleReferenceType.new(reference_el.value) if reference_el
  
  self.new(value, options)
end

Instance Method Details

#==(pa) ⇒ Object



222
223
224
225
226
227
# File 'lib/voruby/stc/1.30/stc.rb', line 222

def ==(pa)
  self.stc_reference_eq(pa) and
  self.value == pa.value and
  self.unit == pa.unit and
  self.reference == pa.reference
end

#to_sObject



240
241
242
# File 'lib/voruby/stc/1.30/stc.rb', line 240

def to_s
  self.value.to_s
end

#to_xml(name = nil) ⇒ Object



229
230
231
232
233
234
235
236
237
238
# File 'lib/voruby/stc/1.30/stc.rb', line 229

def to_xml(name=nil)
  el = stc_reference_to_xml(element(name))
  
  el.attributes["#{obj_ns.prefix}:unit"] = self.unit.to_s if self.unit
  el.attributes["#{obj_ns.prefix}:reference"] = self.reference.to_s if self.reference
  el.text = self.value.to_s
  
  collapse_namespaces(el)
  el
end