Class: Tengai::Client
- Inherits:
-
Object
- Object
- Tengai::Client
- Defined in:
- lib/tengai/client.rb
Constant Summary collapse
- HOST =
'horizons.jpl.nasa.gov'.freeze
- PORT =
'6775'.freeze
- PROMPT =
/Horizons>/.freeze
Instance Method Summary collapse
- #cmd(*args, &blk) ⇒ Object
- #connect! ⇒ Object
- #connection ⇒ Object
- #disconnect ⇒ Object
-
#initialize(telnet = Net::Telnet) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(telnet = Net::Telnet) ⇒ Client
Returns a new instance of Client.
9 10 11 12 |
# File 'lib/tengai/client.rb', line 9 def initialize(telnet=Net::Telnet) @telnet = telnet connect! end |
Instance Method Details
#cmd(*args, &blk) ⇒ Object
30 31 32 |
# File 'lib/tengai/client.rb', line 30 def cmd(*args, &blk) connection.cmd(*args, &blk) end |
#connect! ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/tengai/client.rb', line 14 def connect! @connection = @telnet.new( 'Host' => HOST, 'Port' => PORT, 'Prompt' => PROMPT) @connection.waitfor 'Match' => PROMPT end |
#connection ⇒ Object
26 27 28 |
# File 'lib/tengai/client.rb', line 26 def connection @connection end |
#disconnect ⇒ Object
22 23 24 |
# File 'lib/tengai/client.rb', line 22 def disconnect @connection.close end |