Sha256: b231161c742713851aa0c1cf360e6664745cd07a30e2b7c43a0cfe33b42038bc

Contents?: true

Size: 1.02 KB

Versions: 4

Compression:

Stored size: 1.02 KB

Contents

module NestConnect
  class Device
    class Protect
      def self.from_hash_collection(hash)
        hash.values.map { |value| new(value) }
      end

      def initialize(api_class: NestConnect::API::Devices::Protect, **args)
        @api_class = api_class
        args.each do |key, value|
          instance_variable_set("@#{key}", value)
        end
      end

      def reload
        api_runner.get.body.each do |key, value|
          instance_variable_set("@#{key}", value)
        end
      end

      attr_reader(
        :battery_health,
        :co_alarm_state,
        :device_id,
        :is_manual_test_active,
        :is_online,
        :last_connection,
        :last_manual_test_time,
        :locale,
        :name,
        :name_long,
        :smoke_alarm_state,
        :software_version,
        :structure_id,
        :ui_color_state,
        :where_id,
        :where_name
      )

      private

        attr_reader :api_class

        def api_runner
          api_class.new(device_id)
        end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
nest_connect-0.1.4 lib/nest_connect/devices/protect.rb
nest_connect-0.1.3 lib/nest_connect/devices/protect.rb
nest_connect-0.1.2 lib/nest_connect/devices/protect.rb
nest_connect-0.1.1 lib/nest_connect/devices/protect.rb