Class: ColorDivider

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

Instance Method Summary collapse

Constructor Details

#initialize(start_color, end_color) ⇒ ColorDivider

Returns a new instance of ColorDivider.



5
6
7
8
# File 'lib/color_divider.rb', line 5

def initialize(start_color, end_color)
  @start_color = start_color
  @end_color   = end_color
end

Instance Method Details

#end_colorObject



14
15
16
# File 'lib/color_divider.rb', line 14

def end_color
  @end_color
end

#middle_colorObject



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/color_divider.rb', line 18

def middle_color
  start_r, start_g, start_b = hex_to_rgb(start_color).rgb
  end_r,   end_g,   end_b   = hex_to_rgb(end_color).rgb

  middle_r = (end_r - start_r + 1)/2
  middle_g = (end_g - start_g + 1)/2
  middle_b = (end_b - start_b + 1)/2

  [middle_r, middle_g, middle_b]

  rgb_to_hex = RgbToHexColor.new(middle_r, middle_g, middle_b)
  rgb_to_hex.hex
end

#start_colorObject



10
11
12
# File 'lib/color_divider.rb', line 10

def start_color
  @start_color
end