Class: LoadLibraryHandler
Constant Summary
collapse
- @@loaded_libraries =
[]
Class Method Summary
collapse
Instance Method Summary
collapse
#handle_command, #iterate
Constructor Details
Returns a new instance of LoadLibraryHandler.
7
8
9
|
# File 'lib/javonet-ruby-sdk/core/handler/load_library_handler.rb', line 7
def initialize
@required_parameters_count = 1
end
|
Class Method Details
.get_loaded_libraries ⇒ Object
46
47
48
|
# File 'lib/javonet-ruby-sdk/core/handler/load_library_handler.rb', line 46
def self.get_loaded_libraries
@@loaded_libraries
end
|
Instance Method Details
#process(command) ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/javonet-ruby-sdk/core/handler/load_library_handler.rb', line 11
def process(command)
begin
if command.payload.length < @required_parameters_count
raise ArgumentError.new "Load library parameters mismatch"
end
assembly_name =
if command.payload.length > @required_parameters_count
command.payload[1]
else
command.payload[0]
end
expanded_path = File.expand_path(assembly_name)
if @@loaded_libraries.include?(expanded_path)
return 0
end
raise LoadError.new("Library not found: #{assembly_name}") unless File.exist?(expanded_path)
require expanded_path
@@loaded_libraries << expanded_path
return 0
rescue Exception => e
return e
end
end
|