Class: MotionOcean::API::Client
- Inherits:
-
Object
- Object
- MotionOcean::API::Client
- Defined in:
- lib/motion_ocean/api/client.rb
Defined Under Namespace
Classes: APIResponse
Instance Attribute Summary collapse
-
#base_url ⇒ Object
readonly
Returns the value of attribute base_url.
Instance Method Summary collapse
- #authorization(options = {}) ⇒ Object
- #header(name, value) ⇒ Object
-
#initialize(base_url, &block) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(base_url, &block) ⇒ Client
Returns a new instance of Client.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/motion_ocean/api/client.rb', line 6 def initialize(base_url, &block) base_url += '/' unless base_url.end_with? '/' @base_url = NSURL.URLWithString(base_url) @headers = {} # yield(self) if block_given? if block_given? case block.arity when 0 instance_eval(&block) when 1 block.call(self) end end end |
Instance Attribute Details
#base_url ⇒ Object (readonly)
Returns the value of attribute base_url.
4 5 6 |
# File 'lib/motion_ocean/api/client.rb', line 4 def base_url @base_url end |
Instance Method Details
#authorization(options = {}) ⇒ Object
33 34 35 |
# File 'lib/motion_ocean/api/client.rb', line 33 def ( = {}) header "Authorization", MotionOcean::API::Authorization.build() end |
#header(name, value) ⇒ Object
29 30 31 |
# File 'lib/motion_ocean/api/client.rb', line 29 def header(name, value) @headers[name] = value end |