Class: MEACControl::HTTP

Inherits:
Object
  • Object
show all
Defined in:
lib/meac_control/http.rb

Constant Summary collapse

URI_TEMPLATE =
'http://%s/servlet/MIMEReceiveServlet'
DEFAULT_HEADER =
{'Accept' => 'text/xml', 'Content-Type' => 'text/xml'}

Class Method Summary collapse

Class Method Details

.get(host, devices, commands) ⇒ Object

Executes a get request and returns a MEACControl::XML::Response object.

Example:

device = MEACControl::Device.new(23)
command = MEACControl::Command::Drive.request
resp = MEACControl::HTTP.get('127.0.0.1', device, command)
resp.inspect # => "#<MEACControl::XML::Response:0x8bea3ef0 ...>"


19
20
21
# File 'lib/meac_control/http.rb', line 19

def get(host, devices, commands)
  action(host, MEACControl::XML::GetRequest.new(devices, commands))
end

.set(host, devices, commands) ⇒ Object

Executes a set request and returns a MEACControl::XML::Response object.

Example:

device = MEACControl::Device.new(23)
command = MEACControl::Command::Drive.new
command.off
resp = MEACControl::HTTP.set('127.0.0.1', device, command)
resp.inspect # => "#<MEACControl::XML::Response:0x8bea3ef0 ...>"


31
32
33
# File 'lib/meac_control/http.rb', line 31

def set(host, devices, commands)
  action(host, MEACControl::XML::SetRequest.new(devices, commands))
end