Module: Prolenea::ClassMethods
- Included in:
- Prolenea
- Defined in:
- lib/prolenea.rb
Instance Attribute Summary collapse
-
#default_timeout ⇒ Object
Returns the value of attribute default_timeout.
Instance Method Summary collapse
- #connect(config = {}) ⇒ Object
- #connected? ⇒ Boolean
- #connection ⇒ Object
- #lookup_number(number, options = {}) ⇒ Object
Instance Attribute Details
#default_timeout ⇒ Object
Returns the value of attribute default_timeout.
16 17 18 |
# File 'lib/prolenea.rb', line 16 def default_timeout @default_timeout end |
Instance Method Details
#connect(config = {}) ⇒ Object
22 23 24 25 |
# File 'lib/prolenea.rb', line 22 def connect(config = {}) @default_timeout = config[:default_timeout] || DEFAULT_TIMEOUT @connection = Connection.new(:uri => config[:uri]) end |
#connected? ⇒ Boolean
27 28 29 |
# File 'lib/prolenea.rb', line 27 def connected? !@connection.nil? end |
#connection ⇒ Object
18 19 20 |
# File 'lib/prolenea.rb', line 18 def connection @connection ? @connection : (raise ProleneaNoConnectionError.new({}), 'Connection is not setup') end |
#lookup_number(number, options = {}) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/prolenea.rb', line 31 def lookup_number(number, = {}) params = {:dial => number} response = self.connection.get '/', params, response.env[:parsed_body] rescue ProleneaError => pe raise ProleneaLookupError.new({:parent_error => pe}), pe. rescue StandardError => se raise ProleneaLookupError.new({:parent_error => se}), se. end |