Class: WialonApi::Client
- Inherits:
-
Object
- Object
- WialonApi::Client
- Includes:
- Resolver
- Defined in:
- lib/wialon_api/client.rb
Instance Attribute Summary collapse
-
#sid ⇒ Object
readonly
Returns the value of attribute sid.
Instance Method Summary collapse
- #authorized? ⇒ Boolean
- #execute(*args) ⇒ Object
-
#initialize(sid = nil) ⇒ Client
constructor
A new instance of Client.
-
#method_missing(*args, &block) ⇒ Object
If the called method is a namespace, it creates and returns a new
WialonApi::Namespaceinstance.
Methods included from Resolver
Constructor Details
#initialize(sid = nil) ⇒ Client
Returns a new instance of Client.
7 8 9 |
# File 'lib/wialon_api/client.rb', line 7 def initialize(sid = nil) @sid = sid end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*args, &block) ⇒ Object
If the called method is a namespace, it creates and returns a new WialonApi::Namespace instance.
Otherwise it creates a WialonApi::Method instance and calls it passing the arguments and a block.
21 22 23 24 25 26 27 |
# File 'lib/wialon_api/client.rb', line 21 def method_missing(*args, &block) if Namespace.exists?(args.first) create_namespace(args.first) else call_method(args, &block) end end |
Instance Attribute Details
#sid ⇒ Object (readonly)
Returns the value of attribute sid.
5 6 7 |
# File 'lib/wialon_api/client.rb', line 5 def sid @sid end |
Instance Method Details
#authorized? ⇒ Boolean
11 12 13 |
# File 'lib/wialon_api/client.rb', line 11 def !@sid.nil? end |
#execute(*args) ⇒ Object
15 16 17 |
# File 'lib/wialon_api/client.rb', line 15 def execute(*args) call_method(*args) end |