Class: Chem::CDX::CDXColorTable
- Inherits:
-
Object
- Object
- Chem::CDX::CDXColorTable
- Defined in:
- lib/chem/db/cdx.rb
Instance Method Summary collapse
-
#initialize ⇒ CDXColorTable
constructor
A new instance of CDXColorTable.
- #push(r, g, b) ⇒ Object
- #to_bin ⇒ Object
-
#to_s ⇒ Object
fix me.
- #to_xml ⇒ Object
Constructor Details
#initialize ⇒ CDXColorTable
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_bin ⇒ Object
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_s ⇒ Object
fix me
650 651 652 |
# File 'lib/chem/db/cdx.rb', line 650 def to_s #fix me "<colortable>" end |
#to_xml ⇒ Object
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 |