Class: WSLight::Set::ColorSet

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

Overview

Base set with one color

Constant Summary collapse

DEFAULT_LENGTH =
160
DEFAULT_TYPE =
:double

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(length = DEFAULT_LENGTH, type = DEFAULT_TYPE) ⇒ ColorSet

Returns a new instance of ColorSet.



12
13
14
15
16
17
18
19
# File 'lib/ws_light/set/color_set.rb', line 12

def initialize(length = DEFAULT_LENGTH, type = DEFAULT_TYPE)
  @length = length
  @type = type
  @full_length = (@type == :double ? @length * 2 : @length)
  @color = Color.random
  @frame_count = 0
  init
end

Instance Attribute Details

#colorObject

Returns the value of attribute color.



10
11
12
# File 'lib/ws_light/set/color_set.rb', line 10

def color
  @color
end

#full_lengthObject

Returns the value of attribute full_length.



10
11
12
# File 'lib/ws_light/set/color_set.rb', line 10

def full_length
  @full_length
end

#lengthObject

Returns the value of attribute length.



10
11
12
# File 'lib/ws_light/set/color_set.rb', line 10

def length
  @length
end

#typeObject

Returns the value of attribute type.



10
11
12
# File 'lib/ws_light/set/color_set.rb', line 10

def type
  @type
end

Instance Method Details

#frameObject



25
26
27
28
29
30
31
32
# File 'lib/ws_light/set/color_set.rb', line 25

def frame
  length = type == :double ? @length * 2 : @length
  set = []
  length.times do
    set << @color
  end
  set
end

#frame_dataObject



21
22
23
# File 'lib/ws_light/set/color_set.rb', line 21

def frame_data
  frame.collect{|color| color.to_a}.flatten
end

#initObject



42
43
44
# File 'lib/ws_light/set/color_set.rb', line 42

def init
  # do some initializing stuff here
end

#next_frameObject



34
35
36
# File 'lib/ws_light/set/color_set.rb', line 34

def next_frame
  # reimplement if necessary, please :)
end

#pixel(_number, _frame = 0) ⇒ Object



38
39
40
# File 'lib/ws_light/set/color_set.rb', line 38

def pixel(_number, _frame = 0)
  @color
end