Class: VORuby::STC::V1_30::PosAngleType
- Inherits:
-
Object
- Object
- VORuby::STC::V1_30::PosAngleType
- 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
-
#reference ⇒ Object
Returns the value of attribute reference.
-
#unit ⇒ Object
Returns the value of attribute unit.
-
#value ⇒ Object
Returns the value of attribute value.
Attributes included from STCReference
#id, #idref, #ucd, #xlink_href, #xlink_type
Class Method Summary collapse
Instance Method Summary collapse
- #==(pa) ⇒ Object
-
#initialize(value, options = {}) ⇒ PosAngleType
constructor
A new instance of PosAngleType.
- #to_s ⇒ Object
- #to_xml(name = nil) ⇒ Object
Methods included from STCReference
#stc_reference_eq, stc_reference_from_xml, #stc_reference_to_xml
Methods included from SerializableToXml
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, ={}) [:unit] ||= AngleUnitType.new('deg') [:reference] ||= PosAngleReferenceType.new('X') [:xlink_type] ||= XLink::V1_2::Type.new('simple') self.value = value .each { |key, value| send("#{key}=", value) } end |
Instance Attribute Details
#reference ⇒ Object
Returns the value of attribute reference.
188 189 190 |
# File 'lib/voruby/stc/1.30/stc.rb', line 188 def reference @reference end |
#unit ⇒ Object
Returns the value of attribute unit.
188 189 190 |
# File 'lib/voruby/stc/1.30/stc.rb', line 188 def unit @unit end |
#value ⇒ Object
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) = STCReference.stc_reference_from_xml(root) unit_el = root.attributes.get_attribute_ns(obj_ns.uri, 'unit') [:unit] = AngleUnitType.new(unit_el.value) if unit_el reference_el = root.attributes.get_attribute_ns(obj_ns.uri, 'reference') [:reference] = PosAngleReferenceType.new(reference_el.value) if reference_el self.new(value, ) 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_s ⇒ Object
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 |