Class: Chem::CDX::CDXPoint2D
- Inherits:
-
Object
- Object
- Chem::CDX::CDXPoint2D
- Defined in:
- lib/chem/db/cdx.rb
Instance Attribute Summary collapse
-
#x ⇒ Object
readonly
Returns the value of attribute x.
-
#y ⇒ Object
readonly
Returns the value of attribute y.
Instance Method Summary collapse
-
#initialize(x, y) ⇒ CDXPoint2D
constructor
A new instance of CDXPoint2D.
- #to_bin ⇒ Object
- #to_xml ⇒ Object
Constructor Details
#initialize(x, y) ⇒ CDXPoint2D
Returns a new instance of CDXPoint2D.
569 570 571 |
# File 'lib/chem/db/cdx.rb', line 569 def initialize x, y @x, @y = x.to_f, y.to_f end |
Instance Attribute Details
#x ⇒ Object (readonly)
Returns the value of attribute x.
567 568 569 |
# File 'lib/chem/db/cdx.rb', line 567 def x @x end |
#y ⇒ Object (readonly)
Returns the value of attribute y.
567 568 569 |
# File 'lib/chem/db/cdx.rb', line 567 def y @y end |
Instance Method Details
#to_bin ⇒ Object
573 |
# File 'lib/chem/db/cdx.rb', line 573 def to_bin ; [@y, @x].pack('V2') ; end |
#to_xml ⇒ Object
575 576 577 |
# File 'lib/chem/db/cdx.rb', line 575 def to_xml "%.2f %.2f" % [@x / 65536, @y / 65536] end |