Class: Cinc::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/cinc/client.rb

Defined Under Namespace

Classes: Command

Instance Method Summary collapse

Constructor Details

#initialize(host: 'localhost', port: 9001) ⇒ Client

Returns a new instance of Client.



7
8
9
10
# File 'lib/cinc/client.rb', line 7

def initialize(host: 'localhost', port: 9001)
  @host = host
  @port = port
end

Instance Method Details

#connectObject



12
13
14
15
16
# File 'lib/cinc/client.rb', line 12

def connect
  @socket = Socket.tcp(@host, @port, connect_timeout: 10)
  rescue StandardError => e
    raise ConnectionError.new(e.message)
end

#get_airbasesObject



18
19
20
21
22
# File 'lib/cinc/client.rb', line 18

def get_airbases
  command = Command.new('get_airbases', {})

  return process_command(command)
end