Class: Chem::CDX::CDXColorTable

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

Instance Method Summary collapse

Constructor Details

#initializeCDXColorTable

Returns a new instance of CDXColorTable.


642
643
644
# File 'lib/chem/db/cdx.rb', line 642

def initialize
  @colors = []
end

Instance Method Details

#push(r, g, b) ⇒ Object


646
647
648
# File 'lib/chem/db/cdx.rb', line 646

def push r, g, b
  @colors.push([r, g, b])
end

#to_binObject


654
655
656
657
658
659
660
# File 'lib/chem/db/cdx.rb', line 654

def to_bin
  str = [@colors.length].pack('v')
  @colors.each do |color|
    str += color.pack('v3')
  end
  str
end

#to_sObject

fix me


650
651
652
# File 'lib/chem/db/cdx.rb', line 650

def to_s #fix me
  "<colortable>"
end

#to_xmlObject


662
663
664
665
666
667
668
# File 'lib/chem/db/cdx.rb', line 662

def to_xml
  str = "<colortable>\n"
  @colors.each do |c|
    str += "<color r=\"%d\" g=\"%d\" b=\"%d\"/>\n" % c.collect{|cc| cc/65535.0}
  end
  str + "</colortable>\n"
end