Class: Chem::CDX::CDXRectangle

Inherits:
Object
  • Object
show all
Defined in:
lib/chem/db/cdx.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(top, left, bottom, right) ⇒ CDXRectangle

Returns a new instance of CDXRectangle.



587
588
589
# File 'lib/chem/db/cdx.rb', line 587

def initialize top, left, bottom, right
  @top, @left, @bottom, @right = top.to_f, left.to_f, bottom.to_f, right.to_f
end

Instance Attribute Details

#bottomObject (readonly)

Returns the value of attribute bottom.



585
586
587
# File 'lib/chem/db/cdx.rb', line 585

def bottom
  @bottom
end

#leftObject (readonly)

Returns the value of attribute left.



585
586
587
# File 'lib/chem/db/cdx.rb', line 585

def left
  @left
end

#rightObject (readonly)

Returns the value of attribute right.



585
586
587
# File 'lib/chem/db/cdx.rb', line 585

def right
  @right
end

#topObject (readonly)

Returns the value of attribute top.



585
586
587
# File 'lib/chem/db/cdx.rb', line 585

def top
  @top
end

Instance Method Details

#to_binObject



591
# File 'lib/chem/db/cdx.rb', line 591

def to_bin ; [@top.to_i, @left.to_i, @bottom.to_i, @right.to_i].pack('V4') ; end

#to_xmlObject



593
594
595
# File 'lib/chem/db/cdx.rb', line 593

def to_xml
  "%.2f %.2f %.2f %.2f" % [@top / 65536, @left / 65536, @bottom / 65536, @right / 65536]
end