Class: VORuby::STC::V1_30::Curve3Type

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

Direct Known Subclasses

Curve3

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SerializableToXml

#element

Constructor Details

#initialize(p1, p2, curve_shape = 'line') ⇒ Curve3Type

Returns a new instance of Curve3Type.



1288
1289
1290
1291
1292
# File 'lib/voruby/stc/1.30/stc.rb', line 1288

def initialize(p1, p2, curve_shape='line')
  self.p1 = p1
  self.p2 = p2
  self.curve_shape = curve_shape || 'line'
end

Instance Attribute Details

#curve_shapeObject

Returns the value of attribute curve_shape.



1286
1287
1288
# File 'lib/voruby/stc/1.30/stc.rb', line 1286

def curve_shape
  @curve_shape
end

#p1Object

Returns the value of attribute p1.



1286
1287
1288
# File 'lib/voruby/stc/1.30/stc.rb', line 1286

def p1
  @p1
end

#p2Object

Returns the value of attribute p2.



1286
1287
1288
# File 'lib/voruby/stc/1.30/stc.rb', line 1286

def p2
  @p2
end

Class Method Details

.from_xml(xml) ⇒ Object



1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
# File 'lib/voruby/stc/1.30/stc.rb', line 1331

def self.from_xml(xml)
  root = element_from(xml)
  
  p1_el = REXML::XPath.first(root, 'x:P1', {'x' => obj_ns.uri})
  p2_el = REXML::XPath.first(root, 'x:P2', {'x' => obj_ns.uri})
  curve_shape = root.attributes.get_attribute_ns(obj_ns.uri, 'curve_shape')
  
  self.new(
    p1_el ? Double3Type.from_xml(p1_el) : nil,
    p2_el ? Double3Type.from_xml(p2_el) : nil,
    curve_shape ? curve_shape.value : nil
  )
end

Instance Method Details

#==(c) ⇒ Object



1314
1315
1316
1317
1318
# File 'lib/voruby/stc/1.30/stc.rb', line 1314

def ==(c)
  self.p1 == c.p1 and
  self.p2 == c.p2 and
  self.curve_shape == c.curve_shape
end

#to_xml(name = nil) ⇒ Object



1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
# File 'lib/voruby/stc/1.30/stc.rb', line 1320

def to_xml(name=nil)
  el = element(name)
  
  el.add_element(self.p1.to_xml('P1')) if self.p1
  el.add_element(self.p2.to_xml('P2')) if self.p2
  el.attributes["#{obj_ns.prefix}:curve_shape"] = self.curve_shape if self.curve_shape
  
  collapse_namespaces(el)
  el
end