Class: GetTypeHandler

Inherits:
AbstractCommandHandler show all
Defined in:
lib/javonet-ruby-sdk/core/handler/command_handler/get_type_handler.rb,
lib/javonet-ruby-sdk/Binaries/Ruby/Linux/X64/core/handler/command_handler/get_type_handler.rb,
lib/javonet-ruby-sdk/Binaries/Ruby/MacOs/X64/core/handler/command_handler/get_type_handler.rb,
lib/javonet-ruby-sdk/Binaries/Ruby/Windows/X64/core/handler/command_handler/get_type_handler.rb

Instance Method Summary collapse

Methods inherited from AbstractCommandHandler

#handle_command, #iterate

Constructor Details

#initializeGetTypeHandler

Returns a new instance of GetTypeHandler.



7
8
9
# File 'lib/javonet-ruby-sdk/core/handler/command_handler/get_type_handler.rb', line 7

def initialize
  @required_parameters_count = 1
end

Instance Method Details

#process(ruby_command) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/javonet-ruby-sdk/core/handler/command_handler/get_type_handler.rb', line 10

def process(ruby_command)
  begin
    if ruby_command.payload.length < @required_parameters_count
      raise "Get Type parameters mismatch"
    end
    if ruby_command.payload.length > @required_parameters_count
      return Object::const_get(ruby_command.payload[1])
    else
      return Object::const_get(ruby_command.payload[0])
    end
  rescue Exception => e
    return e
  end
end