Class: Blinkman::Action

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(color_code, times, during = 1000) ⇒ Action

Returns a new instance of Action.



7
8
9
10
11
# File 'lib/blinkman/action.rb', line 7

def initialize(color_code, times,  during = 1000)
  @color_code = color_code
  @times = times
  @during = during
end

Instance Attribute Details

#color_codeObject (readonly)

Returns the value of attribute color_code.



5
6
7
# File 'lib/blinkman/action.rb', line 5

def color_code
  @color_code
end

#duringObject (readonly)

Returns the value of attribute during.



5
6
7
# File 'lib/blinkman/action.rb', line 5

def during
  @during
end

#timesObject (readonly)

Returns the value of attribute times.



5
6
7
# File 'lib/blinkman/action.rb', line 5

def times
  @times
end

Instance Method Details

#invokeObject



13
14
15
16
17
18
19
20
21
22
# File 'lib/blinkman/action.rb', line 13

def invoke
  color_code = @color_code
  times =  @times.count.to_i
  during = @during

  Blink1.open do |blink1|
    blink1.delay_millis = blink1.millis = during / times
    blink1.blink(color_code[:r], color_code[:g], color_code[:b], times)
  end
end