Class: VORuby::STC::V1_10::Region::Vertex

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

Overview

Vertex is a position with optional SmallCircle element

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SerializableToXml

#element

Constructor Details

#initialize(options = {}) ⇒ Vertex

Returns a new instance of Vertex.



331
332
333
334
# File 'lib/voruby/stc/1.10/region.rb', line 331

def initialize(options={})
  raise_argument_required_error('position') if !options.has_key?(:position)
  options.each { |key, value| send("#{key}=", value) }
end

Instance Attribute Details

#positionObject

Returns the value of attribute position.



329
330
331
# File 'lib/voruby/stc/1.10/region.rb', line 329

def position
  @position
end

#small_circleObject

Returns the value of attribute small_circle.



329
330
331
# File 'lib/voruby/stc/1.10/region.rb', line 329

def small_circle
  @small_circle
end

Class Method Details

.from_xml(xml) ⇒ Object



368
369
370
371
372
373
374
375
376
377
378
379
# File 'lib/voruby/stc/1.10/region.rb', line 368

def self.from_xml(xml)
  root = element_from(xml)
  
  options = {
    :position => Double2.from_xml(REXML::XPath.first(root, 'x:Position', {'x' => obj_ns.uri}))
  }
  
  small_circle = REXML::XPath.first(root, 'x:SmallCircle', {'x' => obj_ns.uri})
  options[:small_circle] = SmallCircle.from_xml(small_circle) if small_circle
  
  Vertex.new(options) 
end

Instance Method Details

#==(v) ⇒ Object



348
349
350
351
# File 'lib/voruby/stc/1.10/region.rb', line 348

def ==(v)
  self.position == v.position and
  self.small_circle == v.small_circle
end

#to_sObject



364
365
366
# File 'lib/voruby/stc/1.10/region.rb', line 364

def to_s
  self.position.to_s
end

#to_xml(name = nil) ⇒ Object



353
354
355
356
357
358
359
360
361
362
# File 'lib/voruby/stc/1.10/region.rb', line 353

def to_xml(name=nil)
  el = element(name)
  
  el.add_element(self.position.to_xml('Position', obj_ns))
  el.add_element(self.small_circle.to_xml('SmallCircle')) if self.small_circle
  
  collapse_namespaces(el)
  
  el
end