Class: MelissaData::Client::TCP

Inherits:
Base
  • Object
show all
Defined in:
lib/melissadata/client/tcp.rb

Direct Known Subclasses

Vagrant

Instance Attribute Summary

Attributes inherited from Base

#rpc

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#process, #process_address, #process_email, #process_geo, #process_ip, #process_name, #process_phone, #version

Constructor Details

#initialize(host = self.class.host, port = self.class.port) ⇒ TCP

Returns a new instance of TCP.



21
22
23
24
25
# File 'lib/melissadata/client/tcp.rb', line 21

def initialize(host=self.class.host, port=self.class.port)
  @host = host
  @port = port
  @rpc = MessagePack::RPC::Client.new(@host, @port)
end

Class Method Details

.available?Boolean

Returns:

  • (Boolean)


5
6
7
8
9
10
# File 'lib/melissadata/client/tcp.rb', line 5

def available?
  TCPSocket.new(host, port)
  true
rescue Errno::ECONNREFUSED
  false
end

.hostObject



12
13
14
# File 'lib/melissadata/client/tcp.rb', line 12

def host
  '127.0.0.1'
end

.portObject



16
17
18
# File 'lib/melissadata/client/tcp.rb', line 16

def port
  MelissaData::DEFAULT_TCP_PORT
end