Class: UnifiProtect::NVR

Inherits:
Object
  • Object
show all
Defined in:
lib/unifi_protect/nvr.rb

Constant Summary collapse

TIME_FIELDS =
i[upSince].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:, nvr:) ⇒ NVR



9
10
11
12
# File 'lib/unifi_protect/nvr.rb', line 9

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

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args) ⇒ Object



26
27
28
29
30
31
# File 'lib/unifi_protect/nvr.rb', line 26

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

Instance Attribute Details

#nvrObject (readonly)

Returns the value of attribute nvr.



7
8
9
# File 'lib/unifi_protect/nvr.rb', line 7

def nvr
  @nvr
end

Instance Method Details

#inspectObject



18
19
20
# File 'lib/unifi_protect/nvr.rb', line 18

def inspect
  to_s
end

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean



22
23
24
# File 'lib/unifi_protect/nvr.rb', line 22

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

#to_sObject



14
15
16
# File 'lib/unifi_protect/nvr.rb', line 14

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