Class: Color::RGB

Inherits:
Object
  • Object
show all
Defined in:
lib/mc_dot_art_maker/extern_lib_extension.rb

Instance Method Summary collapse

Instance Method Details

#==(other) ⇒ Object

Add to check equality



8
9
10
# File 'lib/mc_dot_art_maker/extern_lib_extension.rb', line 8

def ==(other)
  @r == other.r && @g == other.g && @b == other.b
end

#eql?(other) ⇒ Boolean

Add to use this object for hash key

Returns:

  • (Boolean)


12
13
14
# File 'lib/mc_dot_art_maker/extern_lib_extension.rb', line 12

def eql?(other)
  @r.eql?(other.r) && @g.eql?(other.g) && @b.eql?(other.b)
end

#hashObject



15
16
17
18
19
20
21
# File 'lib/mc_dot_art_maker/extern_lib_extension.rb', line 15

def hash
  code = 17
  code = 37*code + @r.hash
  code = 37*code + @g.hash
  code = 37*code + @b.hash
  code
end