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

#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