Class: ONVIF::Action

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_onvif_client/action.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Action

Returns a new instance of Action.



5
6
7
# File 'lib/ruby_onvif_client/action.rb', line 5

def initialize client
    @client = client
end

Instance Method Details

#attribute(xml_doc, xpath) ⇒ Object



25
26
27
28
29
# File 'lib/ruby_onvif_client/action.rb', line 25

def attribute xml_doc, xpath
    node = xml_doc[xpath]
    return node unless node.nil?
    ''
end

#callback(cb, *args) ⇒ Object



15
16
17
18
# File 'lib/ruby_onvif_client/action.rb', line 15

def callback cb, *args
    return if cb.class != Proc
    cb.call *args
end

#create_media_onvif_message(options = {}) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/ruby_onvif_client/action.rb', line 31

def create_media_onvif_message options = {}
    namespaces = {
        :'xmlns:wsdl' => "http://www.onvif.org/ver10/media/wsdl"
    }.merge(options[:namespaces] || {})
    options[:namespaces] = namespaces
    Message.new options
end

#send_message(message) ⇒ Object



9
10
11
12
13
# File 'lib/ruby_onvif_client/action.rb', line 9

def send_message message
    @client.send message.to_s do |success, result|
        yield success, result
    end
end

#value(xml_doc, xpath) ⇒ Object



20
21
22
23
24
# File 'lib/ruby_onvif_client/action.rb', line 20

def value xml_doc, xpath
    node = xml_doc.at_xpath(xpath)
    return node.content unless node.nil?
    ''
end