Class: Cheers::Background

Inherits:
Component show all
Defined in:
lib/cheers/background.rb

Instance Attribute Summary collapse

Attributes inherited from Component

#canvas, #randomizer

Instance Method Summary collapse

Methods inherited from Component

#base_image, #colored_image, #composite_with_mask, #extract_background_color, #image_path

Constructor Details

#initialize(canvas, randomizer) ⇒ Background

Returns a new instance of Background.



6
7
8
9
10
# File 'lib/cheers/background.rb', line 6

def initialize(canvas, randomizer)
  super

  @color = Avatar::BACKGROUND_COLORS.sample(random: randomizer)
end

Instance Attribute Details

#colorObject (readonly)

Returns the value of attribute color.



4
5
6
# File 'lib/cheers/background.rb', line 4

def color
  @color
end

Instance Method Details

#applyObject



12
13
14
15
16
17
# File 'lib/cheers/background.rb', line 12

def apply
  # Work around instance_eval wonkiness by declaring local variables:
  color = self.color

  colored_image(color)
end