Sha256: ff90ee50f70401f9b8c717dde9ae90e8aadd0db898d55a8e1484c4de5848045b
Contents?: true
Size: 918 Bytes
Versions: 1
Compression:
Stored size: 918 Bytes
Contents
module Sesame class Sesame include Api def initialize(attrs = {}) @state = attrs end def device_id @state['device_id'] end def locked? truthy?(@state['locked']) end alias locked locked? def state locked? ? 'locked' : 'unlocked' end def battery @state['battery'].to_i end def lock control(command: 'lock') end def unlock control(command: 'unlock') end def inspect %(#<#{self.class.name}:#{format('0x%<object_id>.14x', object_id: (object_id << 1))} device_id: #{device_id}>) end def refresh! @state.merge!(get_sesame(device_id: device_id)) self end private def truthy?(value) (value == true) || (value == 'true') end def control(command:) control_sesame(device_id: device_id, command: command) refresh! true end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sesame-ruby-1.0.0 | lib/sesame/sesame.rb |