Class: Hikvision::Streaming

Inherits:
Object
  • Object
show all
Defined in:
lib/hikvision/streaming.rb,
lib/hikvision/streaming/channel.rb

Defined Under Namespace

Classes: Channel

Instance Method Summary collapse

Constructor Details

#initialize(isapi) ⇒ Streaming

Returns a new instance of Streaming.



3
4
5
# File 'lib/hikvision/streaming.rb', line 3

def initialize(isapi)
  @isapi = isapi
end

Instance Method Details

#channel(id) ⇒ Object



11
12
13
# File 'lib/hikvision/streaming.rb', line 11

def channel(id)
  load_channels[id]
end

#channelsObject



7
8
9
# File 'lib/hikvision/streaming.rb', line 7

def channels
  load_channels.values
end

#load_channels(options = {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/hikvision/streaming.rb', line 15

def load_channels(options = {})
  return @channels if options.fetch(:cache, true) && instance_variable_defined?(:@channels)

  @channels = {}
  xml = @isapi.get_xml('/ISAPI/Streaming/channels', options)
  xml.xpath('StreamingChannelList/StreamingChannel').each do |c|
    channel = Channel.new(@isapi, Nokogiri::XML(c.to_s))
    @channels[channel.id] = channel
  end
  @channels
end