Class: WSLight::Set::FlowerbedSet

Inherits:
ColorSet
  • Object
show all
Defined in:
lib/ws_light/set/flowerbed_set.rb

Overview

Creates a green set with some random colors

Constant Summary

Constants inherited from ColorSet

ColorSet::DEFAULT_LENGTH, ColorSet::DEFAULT_TYPE

Instance Attribute Summary

Attributes inherited from ColorSet

#color, #full_length, #length, #type

Instance Method Summary collapse

Methods inherited from ColorSet

#frame_data, #init, #initialize, #next_frame

Constructor Details

This class inherits a constructor from WSLight::Set::ColorSet

Instance Method Details

#frameObject



7
8
9
# File 'lib/ws_light/set/flowerbed_set.rb', line 7

def frame
  @set ||= generate_set
end

#generate_setObject



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/ws_light/set/flowerbed_set.rb', line 15

def generate_set
  set = []
  @full_length.times do
    set << if rand(8).zero?
             Color.random_from_set
           else
             Color.by_name(:green)
           end
  end
  set
end

#pixel(number, _frame = 0) ⇒ Object



11
12
13
# File 'lib/ws_light/set/flowerbed_set.rb', line 11

def pixel(number, _frame = 0)
  frame[number]
end