Class: Flic::Protocol::Primitives::DisconnectTime

Inherits:
BinData::Primitive
  • Object
show all
Defined in:
lib/flic/protocol/primitives/disconnect_time.rb

Overview

Time in seconds after the Flic button may disconnect after the latest press or release. The button will reconnect automatically when it is later pressed again and deliver its enqueued events. Valid values are 0 - 511.

Instance Method Summary collapse

Instance Method Details

#getObject



10
11
12
13
14
15
16
# File 'lib/flic/protocol/primitives/disconnect_time.rb', line 10

def get
  if time == 511
    nil
  else
    time
  end
end

#set(value) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/flic/protocol/primitives/disconnect_time.rb', line 18

def set(value)
  if value == nil
    self.time = 511
  elsif value >= 511
    raise RangeError, 'disconnect_time must be less than 511 seconds (or nil for never)'
  else
    self.time = value
  end
end