Class: WialonApi::Client

Inherits:
Object
  • Object
show all
Includes:
Resolver
Defined in:
lib/wialon_api/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Resolver

included, #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

#sidObject (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

Returns:

  • (Boolean)


11
12
13
# File 'lib/wialon_api/client.rb', line 11

def authorized?
  !@sid.nil?
end

#execute(*args) ⇒ Object



15
16
17
# File 'lib/wialon_api/client.rb', line 15

def execute(*args)
  call_method(*args)
end