Class: Colordom::Color

Inherits:
Object
  • Object
show all
Defined in:
lib/colordom/color.rb

Overview

Color object with RGB and HEX values implemented in Rust.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(r, g, b) ⇒ Color

A new instance of Color.



# File 'lib/colordom/color.rb', line 6

Instance Attribute Details

#bInteger (readonly)

Blue color value.

Returns:

  • (Integer)


# File 'lib/colordom/color.rb', line 18

#gInteger (readonly)

Green color value.

Returns:

  • (Integer)


# File 'lib/colordom/color.rb', line 14

#rInteger (readonly)

Red color value.

Returns:

  • (Integer)


# File 'lib/colordom/color.rb', line 10

Instance Method Details

#==(other) ⇒ Boolean

Compare with other color value.

Parameters:

  • other (Color, Array<Integer>, String)

Returns:

  • (Boolean)


36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/colordom/color.rb', line 36

def ==(other)
  case other
  when Array
    rgb == other
  when String
    hex == other
  when self.class
    rgb == other.rgb
  else
    false
  end
end

#hexString Also known as: to_hex

Get the hex representation of the color.

Returns:

  • (String)


# File 'lib/colordom/color.rb', line 27

#rgbArray<Integer> Also known as: to_rgb

Get the RGB representation of the color.

Returns:

  • (Array<Integer>)


# File 'lib/colordom/color.rb', line 22