Class: OpenAgent::Zone
- Inherits:
-
Object
- Object
- OpenAgent::Zone
- Defined in:
- lib/openagent/zone.rb
Instance Method Summary collapse
- #connection ⇒ Object
- #create_request(msg) ⇒ Object
- #host ⇒ Object
- #path ⇒ Object
- #port ⇒ Object
- #send_message(msg) ⇒ Object
- #send_request(request) ⇒ Object
- #url ⇒ Object
Instance Method Details
#connection ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/openagent/zone.rb', line 19 def connection @connection ||= Net::HTTP.new(host, port).tap do |conn| ssl.configure(conn) if ssl conn.read_timeout = timeout if timeout conn.open_timeout = open_timeout if open_timeout end end |
#create_request(msg) ⇒ Object
43 44 45 46 47 48 |
# File 'lib/openagent/zone.rb', line 43 def create_request(msg) Net::HTTP::Post.new(path).tap do |post| post.body = msg.to_s post.content_type = "application/xml" end end |
#host ⇒ Object
31 32 33 |
# File 'lib/openagent/zone.rb', line 31 def host url.host end |
#path ⇒ Object
39 40 41 |
# File 'lib/openagent/zone.rb', line 39 def path url.path == "" ? "/" : url.path end |
#port ⇒ Object
35 36 37 |
# File 'lib/openagent/zone.rb', line 35 def port url.port end |
#send_message(msg) ⇒ Object
54 55 56 |
# File 'lib/openagent/zone.rb', line 54 def (msg) send_request(create_request(msg)) end |
#send_request(request) ⇒ Object
50 51 52 |
# File 'lib/openagent/zone.rb', line 50 def send_request(request) connection.request(request) end |
#url ⇒ Object
27 28 29 |
# File 'lib/openagent/zone.rb', line 27 def url @url ||= URI.parse(uri) end |