Class: AprsIs::Client

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

Defined Under Namespace

Classes: Error

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hostname:, port:, version: "AprsIs::Client v#{VERSION}") ⇒ Client

Returns a new instance of Client.



9
10
11
12
13
# File 'lib/aprs_is/client.rb', line 9

def initialize(hostname:, port:, version: "AprsIs::Client v#{VERSION}")
  @hostname = hostname
  @port = port
  @version = version
end

Instance Attribute Details

#hostnameObject (readonly)

Returns the value of attribute hostname.



5
6
7
# File 'lib/aprs_is/client.rb', line 5

def hostname
  @hostname
end

#portObject (readonly)

Returns the value of attribute port.



5
6
7
# File 'lib/aprs_is/client.rb', line 5

def port
  @port
end

#versionObject (readonly)

Returns the value of attribute version.



5
6
7
# File 'lib/aprs_is/client.rb', line 5

def version
  @version
end

Instance Method Details

#apply_filter(filter) ⇒ Object



20
21
22
# File 'lib/aprs_is/client.rb', line 20

def apply_filter(filter)
  send_message(filter_message(filter))
end

#login(call_sign, filters = []) ⇒ Object



15
16
17
18
# File 'lib/aprs_is/client.rb', line 15

def (call_sign, filters = [])
  send_message((call_sign, filters))
  return self
end

#read(&block) ⇒ Object



24
25
26
27
28
# File 'lib/aprs_is/client.rb', line 24

def read(&block)
  while line = socket.gets
    yield line
  end
end

#send_message(message) ⇒ Object

:nocov:



38
39
40
# File 'lib/aprs_is/client.rb', line 38

def send_message(message)
  socket.puts message
end

#stream(&block) ⇒ Object

:nocov:



31
32
33
34
35
# File 'lib/aprs_is/client.rb', line 31

def stream(&block)
  loop do
    read(&block)
  end
end