Class: Interpreter

Inherits:
Object
  • Object
show all
Defined in:
lib/javonet-ruby-sdk/core/interpreter/interpreter.rb,
lib/javonet-ruby-sdk/Binaries/Ruby/Linux/X64/core/interpreter/interpreter.rb,
lib/javonet-ruby-sdk/Binaries/Ruby/MacOs/X64/core/interpreter/interpreter.rb,
lib/javonet-ruby-sdk/Binaries/Ruby/Windows/X64/core/interpreter/interpreter.rb

Constant Summary collapse

@@handler =
Handler.new

Instance Method Summary collapse

Instance Method Details

#execute(command, connection_type, tcp_connection_data) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/javonet-ruby-sdk/core/interpreter/interpreter.rb', line 8

def execute(command, connection_type, tcp_connection_data)
  message_byte_array = CommandSerializer.new.serialize(command, connection_type, tcp_connection_data)
  if command.runtime_name == RuntimeName::RUBY && connection_type == ConnectionType::IN_MEMORY
    require_relative '../receiver/receiver'
    response_byte_array = Receiver.new.send_command(message_byte_array, message_byte_array.length)
  else
    require_relative '../transmitter/transmitter'
    response_byte_array = Transmitter.send_command(message_byte_array, message_byte_array.length)
  end

  CommandDeserializer.new(response_byte_array).deserialize
end

#process(byte_array, byte_array_len) ⇒ Object



21
22
23
24
# File 'lib/javonet-ruby-sdk/core/interpreter/interpreter.rb', line 21

def process(byte_array, byte_array_len)
  received_command = CommandDeserializer.new(byte_array).deserialize
  CommandSerializer.new.serialize(@@handler.handle_command(received_command))
end