Class: WSLight::Set::SunnySet
- Defined in:
- lib/ws_light/set/weather/sunny_set.rb
Overview
Creates a set with all 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
#frame ⇒ Object
7 8 9 |
# File 'lib/ws_light/set/weather/sunny_set.rb', line 7 def frame @set ||= generate_set end |
#generate_set ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/ws_light/set/weather/sunny_set.rb', line 15 def generate_set set = [] position = sun_position @full_length.times do |i| set << if position.include?(i) Color.by_name(:yellow) else Color.by_name(:blue) end end set end |
#pixel(number, _frame = 0) ⇒ Object
11 12 13 |
# File 'lib/ws_light/set/weather/sunny_set.rb', line 11 def pixel(number, _frame = 0) frame[number] end |
#sun_position ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/ws_light/set/weather/sunny_set.rb', line 28 def sun_position case rand(4) when 0 10..40 when 1 140..170 when 2 190..220 else 300..330 end end |