Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/dm_core/scio_excel.rb

Instance Method Summary collapse

Instance Method Details

#to_rgbObject

simple (and naive) way to convert html-hex color to array of colors



493
494
495
496
497
498
499
500
# File 'lib/dm_core/scio_excel.rb', line 493

def to_rgb
  raise "Invalid Hex Color" if self.size != 7 || self[0] != 35
  rgb = Hash.new
  rgb[:red]   = self[1,2].to_i(16)
  rgb[:green] = self[3,2].to_i(16)
  rgb[:blue]  = self[5,2].to_i(16)
  rgb
end