Class: YDIM::Client

Inherits:
Object
  • Object
show all
Includes:
DRb::DRbUndumped
Defined in:
lib/ydim/client.rb,
lib/ydim/config.rb

Constant Summary collapse

CONFIG =
config

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Client

Returns a new instance of Client.



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

def initialize(config)
	@config = config
	DRb.start_service(config.client_url)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &block) ⇒ Object



25
26
27
# File 'lib/ydim/client.rb', line 25

def method_missing(meth, *args, &block)
	@session.send(meth, *args, &block)
end

Instance Attribute Details

#sessionObject (readonly)

Returns the value of attribute session.



9
10
11
# File 'lib/ydim/client.rb', line 9

def session
  @session
end

Instance Method Details

#login(server, private_key) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/ydim/client.rb', line 14

def (server, private_key)
	@server = server
	@session = @server.(self, @config.user) { |challenge|
		if(private_key.respond_to?(:syssign))
			private_key.syssign(challenge)
		end
	}
end

#logoutObject



22
23
24
# File 'lib/ydim/client.rb', line 22

def logout
	@server.logout(@session) if(@server)
end