Class: VORuby::STC::V1_10::Region::CircleType
- Inherits:
-
Shape
- Object
- RegionType
- Shape
- VORuby::STC::V1_10::Region::CircleType
- Defined in:
- lib/voruby/stc/1.10/region.rb
Overview
Circle shape: center and radius
Direct Known Subclasses
Instance Attribute Summary collapse
-
#center ⇒ Object
Returns the value of attribute center.
-
#radius ⇒ Object
Returns the value of attribute radius.
Attributes inherited from Shape
Attributes inherited from RegionType
Class Method Summary collapse
Instance Method Summary collapse
- #==(s) ⇒ Object
-
#initialize(options = {}) ⇒ CircleType
constructor
A new instance of CircleType.
- #to_s ⇒ Object
- #to_xml(name = nil) ⇒ Object
Methods included from SerializableToXml
Methods inherited from RegionType
Constructor Details
#initialize(options = {}) ⇒ CircleType
Returns a new instance of CircleType.
117 118 119 120 121 |
# File 'lib/voruby/stc/1.10/region.rb', line 117 def initialize(={}) raise_argument_required_error('center') if !.has_key?(:center) raise_argument_required_error('radius') if !.has_key?(:radius) super() end |
Instance Attribute Details
#center ⇒ Object
Returns the value of attribute center.
113 114 115 |
# File 'lib/voruby/stc/1.10/region.rb', line 113 def center @center end |
#radius ⇒ Object
Returns the value of attribute radius.
113 114 115 |
# File 'lib/voruby/stc/1.10/region.rb', line 113 def radius @radius end |
Class Method Details
.from_xml(xml) ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/voruby/stc/1.10/region.rb', line 157 def self.from_xml(xml) root = element_from(xml) fill_factor = root.attributes.get_attribute_ns(obj_ns.uri, 'fill_factor') note = root.attributes.get_attribute_ns(obj_ns.uri, 'note') unit = root.attributes.get_attribute_ns(obj_ns.uri, 'unit') = { :fill_factor => fill_factor ? Float(fill_factor.value) : nil, :note => note ? note.value : nil, :coord_system_id => IdRef.new(root.attributes.get_attribute_ns(obj_ns.uri, 'coord_system_id').value), :unit => unit ? PosUnit.new(unit.value) : nil, :center => Double2.from_xml(REXML::XPath.first(root, 'x:Center', {'x' => obj_ns.uri})), :radius => Float(REXML::XPath.first(root, 'x:Radius', {'x' => obj_ns.uri}).text) } self.new() end |
.xml_type ⇒ Object
115 |
# File 'lib/voruby/stc/1.10/region.rb', line 115 def self.xml_type; 'circleType' end |
Instance Method Details
#==(s) ⇒ Object
135 136 137 138 139 |
# File 'lib/voruby/stc/1.10/region.rb', line 135 def ==(s) super(s) and self.center == s.center and self.radius == s.radius end |
#to_s ⇒ Object
153 154 155 |
# File 'lib/voruby/stc/1.10/region.rb', line 153 def to_s "CIRCLE #{self.coord_system_id} #{self.center} #{self.radius}" end |
#to_xml(name = nil) ⇒ Object
141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/voruby/stc/1.10/region.rb', line 141 def to_xml(name=nil) el = super(name) el.add_element(self.center.to_xml("Center", obj_ns)) radius = REXML::Element.new("#{obj_ns.prefix}:Radius") radius.text = self.radius.to_s el.add_element(radius) collapse_namespaces(el) el end |