lib/sesame/sesame.rb in sesame-ruby-0.1.2 vs lib/sesame/sesame.rb in sesame-ruby-1.0.0

- old
+ new

@@ -8,43 +8,33 @@ def device_id @state['device_id'] end - def nickname - @state['nickname'] + def locked? + truthy?(@state['locked']) end + alias locked locked? - def unlocked? - truthy?(@state['is_unlocked']) - end - alias is_unlocked unlocked? - def state - unlocked? ? 'unlocked' : 'locked' + locked? ? 'locked' : 'unlocked' end - def api_enabled? - truthy?(@state['api_enabled']) - end - alias api_enabled api_enabled? - def battery @state['battery'].to_i end def lock - control(type: 'lock') + control(command: 'lock') end def unlock - control(type: 'unlock') + control(command: 'unlock') end def inspect - details = @state.keys.collect { |k| "#{k}: #{send(k.to_sym)}" }.join(', ') - %(#<#{self.class.name}:#{format('0x%.14x', (object_id << 1))} #{details}>) + %(#<#{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 @@ -54,11 +44,11 @@ def truthy?(value) (value == true) || (value == 'true') end - def control(type:) - control_sesame(device_id: device_id, type: type) + def control(command:) + control_sesame(device_id: device_id, command: command) refresh! true end end end