Class: Telein::Server
- Inherits:
-
Object
- Object
- Telein::Server
- Defined in:
- lib/telein/server.rb
Overview
The class that encapsulates all code that build request queries made to Telein servers by the client
Instance Attribute Summary collapse
-
#endpoint ⇒ String
Gets/sets the endpoint (an URL) representing a Telein Server.
Instance Method Summary collapse
-
#initialize(endpoint) ⇒ Server
constructor
A new instance of Server.
-
#query_url_for(phone) ⇒ String
Builds a request URL to be used by the client to fetch the carrier code.
Constructor Details
#initialize(endpoint) ⇒ Server
Returns a new instance of Server.
19 20 21 |
# File 'lib/telein/server.rb', line 19 def initialize(endpoint) self.endpoint = endpoint end |
Instance Attribute Details
#endpoint ⇒ String
Gets/sets the endpoint (an URL) representing a Telein Server
16 17 18 |
# File 'lib/telein/server.rb', line 16 def endpoint @endpoint end |
Instance Method Details
#query_url_for(phone) ⇒ String
Builds a request URL to be used by the client to fetch the carrier code
28 29 30 31 32 33 |
# File 'lib/telein/server.rb', line 28 def query_url_for(phone) url = URI::HTTP.build({:host => self.endpoint, :path => '/sistema/consulta_numero.php', :query => URI::encode_www_form({:numero => phone,:chave => Telein.api_key})}) url.to_s end |