fork download
  1. module Color
  2. Red = 1
  3. Green = 2
  4. Blue = 3
  5. Rgb = Struct.new(:r, :g, :b)
  6. end
  7.  
  8. color = Color::Rgb.new(255, 255, 255)
  9. puts case color
  10. when Color::Red; "#FF000"
  11. when Color::Green; "#00FF00"
  12. when Color::Blue; "#0000FF"
  13. when Color::Rgb; "#%02X%02X%02X" % [color.r, color.g, color.b]
  14. end
Success #stdin #stdout 0.06s 9656KB
stdin
Standard input is empty
stdout
#FFFFFF