Class: Geong::Client

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

Constant Summary collapse

DEFAULT_HOST =
'127.0.0.1'
DEFAULT_PORT =
9090

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



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

def initialize(options = {})
  @transport = options[:transport] || self.class.default_transport(options)
  @protocol =  options[:protocol ] || self.class.default_protocol(@transport, options)
  @client = Geong::Geocoder::GeocoderService::Client.new(@protocol)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args, &block) ⇒ Object



45
46
47
# File 'lib/geong/client.rb', line 45

def method_missing(*args, &block)
  @client.send(*args, &block)
end

Instance Attribute Details

#protocolObject (readonly)

Returns the value of attribute protocol.



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

def protocol
  @protocol
end

#transportObject (readonly)

Returns the value of attribute transport.



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

def transport
  @transport
end

Class Method Details

.default_protocol(transport, options) ⇒ Object



19
20
21
# File 'lib/geong/client.rb', line 19

def self.default_protocol(transport, options)
  Thrift::BinaryProtocol.new(transport)
end

.default_transport(options) ⇒ Object



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

def self.default_transport(options)
  Thrift::FramedTransport.new(Thrift::Socket.new(options[:host] || DEFAULT_HOST, options[:port] || DEFAULT_PORT))
end

Instance Method Details

#closeObject



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

def close
  @transport.close
  self
end

#closed?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/geong/client.rb', line 37

def closed?
  @transport.closed?
end

#openObject



23
24
25
26
# File 'lib/geong/client.rb', line 23

def open
  @transport.open
  self
end

#open?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/geong/client.rb', line 28

def open?
  @transport.open?
end

#respond_to_missing?(method, include_private) ⇒ Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/geong/client.rb', line 41

def respond_to_missing?(method, include_private)
  @client.respond_to?(method, include_private)
end