class UnifiProtect::Camera
Constants
- TIME_FIELDS
Attributes
camera[R]
Public Class Methods
new(client:, camera:)
click to toggle source
# File lib/unifi_protect/camera.rb, line 12 def initialize(client:, camera:) @client = client @camera = camera end
Public Instance Methods
inspect()
click to toggle source
# File lib/unifi_protect/camera.rb, line 21 def inspect to_s end
match(name, matcher)
click to toggle source
# File lib/unifi_protect/camera.rb, line 36 def match(name, matcher) return matcher.match(send(name)) if matcher.is_a?(Regexp) return send(name) == matcher if matcher.is_a?(String) || [true, false].include?(matcher) return matcher.any? { |item| match(name, item) } if matcher.is_a?(Array) if matcher.is_a?(Hash) value = send(name).send(matcher.first[0]) pattern = matcher.first[1] return pattern.match(value) end false end
method_missing(method_name, *args)
click to toggle source
# File lib/unifi_protect/camera.rb, line 29 def method_missing(method_name, *args) value = @camera.send(method_name, *args) return Time.at(value / 1000) if value && TIME_FIELDS.include?(method_name) value end
respond_to_missing?(method_name, include_private = false)
click to toggle source
Calls superclass method
# File lib/unifi_protect/camera.rb, line 25 def respond_to_missing?(method_name, include_private = false) @camera.respond_to?(method_name) || super end
snapshot(local_file: nil)
click to toggle source
# File lib/unifi_protect/camera.rb, line 50 def snapshot(local_file: nil) @client.api.camera_snapshot(camera: id, local_file: local_file) rescue UnifiProtect::API::RequestError => e raise SnapshotError, e end
to_s()
click to toggle source
# File lib/unifi_protect/camera.rb, line 17 def to_s "#<#{self.class.name} id=#{@camera.id.inspect} name=#{@camera.name.inspect}>" end
video_export(start_time:, end_time:, local_file: nil)
click to toggle source
# File lib/unifi_protect/camera.rb, line 56 def video_export(start_time:, end_time:, local_file: nil) @client.api.video_export(camera: id, start_time: start_time, end_time: end_time, local_file: local_file) rescue UnifiProtect::API::RequestError => e raise VideoExportError, e end