Sha256: 19650fa10537c5e06b5f4c64d1ad9090dda7f07463610f2e8418f0862971f0cd

Contents?: true

Size: 661 Bytes

Versions: 1

Compression:

Stored size: 661 Bytes

Contents

# frozen_string_literal: true

module UnifiProtect
  class NVR
    TIME_FIELDS = %i[upSince].freeze

    attr_reader :nvr

    def initialize(client:, nvr:)
      @client = client
      @nvr = nvr
    end

    def to_s
      "#<#{self.class.name} id=#{@nvr.id.inspect} name=#{@nvr.name.inspect}>"
    end

    def inspect
      to_s
    end

    def respond_to_missing?(method_name, include_private = false)
      @nvr.respond_to?(method_name) || super
    end

    def method_missing(method_name, *args)
      value = @nvr.send(method_name, *args)
      return Time.at(value / 1000) if value && TIME_FIELDS.include?(method_name)

      value
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
unifi_protect-0.1.0 lib/unifi_protect/nvr.rb