Method: Discordrb::ColourRGB#initialize

Defined in:
lib/discordrb/colour_rgb.rb

#initialize(combined) ⇒ ColourRGB

Make a new colour from the combined value.

Examples:

Initialize a with a base 10 integer

ColourRGB.new(7506394) #=> ColourRGB
ColourRGB.new(0x7289da) #=> ColourRGB

Initialize a with a hexadecimal string

ColourRGB.new('7289da') #=> ColourRGB

Parameters:

  • combined (String, Integer)

    The colour's RGB values combined into one integer or a hexadecimal string



27
28
29
30
31
32
# File 'lib/discordrb/colour_rgb.rb', line 27

def initialize(combined)
  @combined = combined.is_a?(String) ? combined.to_i(16) : combined
  @red = (@combined >> 16) & 0xFF
  @green = (@combined >> 8) & 0xFF
  @blue = @combined & 0xFF
end