Class: MoodCube::MoodCube
- Inherits:
-
Monitor
- Object
- Monitor
- MoodCube::MoodCube
- Defined in:
- lib/moodcube.rb
Overview
Instance Attribute Summary collapse
-
#ip_addr ⇒ Object
Returns the value of attribute ip_addr.
-
#max ⇒ Object
readonly
Returns the value of attribute max.
-
#min ⇒ Object
readonly
Returns the value of attribute min.
-
#side ⇒ Object
readonly
Returns the value of attribute side.
Instance Method Summary collapse
-
#initialize(side_switch_proc) ⇒ MoodCube
constructor
A new instance of MoodCube.
- #side_pulse(side) ⇒ Object
Constructor Details
#initialize(side_switch_proc) ⇒ MoodCube
Returns a new instance of MoodCube.
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/moodcube.rb', line 25 def initialize side_switch_proc super() @pulse_time = Time.now @side = @side_pulse = 0 @min = [MOODCUBE_MID_BORDER, MOODCUBE_MID_BORDER, MOODCUBE_MID_BORDER] @max = @min.clone Thread.new do loop do sleep(SIDE_DETECT_INTERVAL) detect_side(side_switch_proc) end end end |
Instance Attribute Details
#ip_addr ⇒ Object
Returns the value of attribute ip_addr.
23 24 25 |
# File 'lib/moodcube.rb', line 23 def ip_addr @ip_addr end |
#max ⇒ Object (readonly)
Returns the value of attribute max.
22 23 24 |
# File 'lib/moodcube.rb', line 22 def max @max end |
#min ⇒ Object (readonly)
Returns the value of attribute min.
21 22 23 |
# File 'lib/moodcube.rb', line 21 def min @min end |
#side ⇒ Object (readonly)
Returns the value of attribute side.
20 21 22 |
# File 'lib/moodcube.rb', line 20 def side @side end |
Instance Method Details
#side_pulse(side) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/moodcube.rb', line 49 def side_pulse side if (1..6).include? side synchronize do if @side_pulse != side @pulse_time = Time.now @side_pulse = side end end else synchronize do @pulse_time = Time.now end end end |