Class: OWNet::Connection
- Inherits:
-
Object
- Object
- OWNet::Connection
- Defined in:
- lib/connection.rb
Overview
Abstracts away the connection to owserver
Instance Attribute Summary collapse
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
Instance Method Summary collapse
- #dir(path) ⇒ Object
-
#initialize(opts = {}) ⇒ Connection
constructor
Create a new connection.
- #read(path) ⇒ Object
- #write(path, value) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Connection
Create a new connection. The default is to connect to localhost on port 4304. opts can contain a server and a port.
For example:
#Connect to a remote server on the default port: Connection.new(:server=>“my.server.com”) #Connect to a local server on a non-standard port: Connection.new(:port=>20200) #Connect to a remote server on a non-standard port: Connection.new(:server=>“my.server.com”, :port=>20200)
106 107 108 109 |
# File 'lib/connection.rb', line 106 def initialize(opts={}) @conn = RawConnection.new(opts) @serialcache = {} end |
Instance Attribute Details
#port ⇒ Object (readonly)
Returns the value of attribute port.
93 94 95 |
# File 'lib/connection.rb', line 93 def port @port end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
93 94 95 |
# File 'lib/connection.rb', line 93 def server @server end |
Instance Method Details
#dir(path) ⇒ Object
112 |
# File 'lib/connection.rb', line 112 def dir(path); do_op(:dir, path); end |
#read(path) ⇒ Object
111 |
# File 'lib/connection.rb', line 111 def read(path); do_op(:read, path); end |
#write(path, value) ⇒ Object
113 |
# File 'lib/connection.rb', line 113 def write(path, value); @conn.send(:write, path, value); end |