Module: OBIX::Network

Extended by:
Network
Includes:
Net
Included in:
Network
Defined in:
lib/obix/network.rb

Defined Under Namespace

Classes: Error, Timeout

Instance Method Summary collapse

Instance Method Details

#get(url) ⇒ Object

Make a get request.

url - A String describing where the request should be sent. object - A Objects::Object or derivative thereof describing the OBIX element to send.



13
14
15
16
17
18
# File 'lib/obix/network.rb', line 13

def get url
  url     = URI url
  request = HTTP::Get.new url.path

  dispatch request, to: url
end

#post(url, object = nil) ⇒ Object

Make a post request.

url - A String describing where the request should be sent. object - A Objects::Object or derivative thereof describing the OBIX element to send.



24
25
26
27
28
29
30
31
32
33
# File 'lib/obix/network.rb', line 24

def post url, object = nil
  url     = URI url
  request = HTTP::Post.new url.path

  if object
    request.body = object.to_xml
  end

  dispatch request, to: url
end