Class: Netstats24::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/netstats24-client.rb,
lib/netstats24-client/version.rb

Constant Summary collapse

VERSION =
"0.0.1"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Client

Returns a new instance of Client.



9
10
11
12
13
14
15
16
17
18
# File 'lib/netstats24-client.rb', line 9

def initialize opts = {}
  
  default_server = ENV['RAILS_ENV'] == 'test' ? 
                    'http://localhost:3000/api2' :
                    'http://api.netstats24.ru/api2'
  
  self.server_url = opts[:server_url] || default_server

  self.access_token = opts[:access_token] || ask_for_token(opts)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object



22
23
24
25
# File 'lib/netstats24-client.rb', line 22

def method_missing method, *args
  # warn "method missing: #{method}, #{args.inspect}"
  send_request method, *args
end

Instance Attribute Details

#access_tokenObject

Returns the value of attribute access_token.



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

def access_token
  @access_token
end

#server_urlObject

Returns the value of attribute server_url.



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

def server_url
  @server_url
end