lib/javonet-ruby-sdk/utils/command.rb in javonet-ruby-sdk-2.1.4 vs lib/javonet-ruby-sdk/utils/command.rb in javonet-ruby-sdk-2.1.5
- old
+ new
@@ -18,10 +18,46 @@
def payload
@payload
end
+
+ def self.create_response(response, runtime_name)
+ return Command.new(runtime_name, CommandType::VALUE, [response])
+ end
+
+ def self.create_reference(guid, runtime_name)
+ return Command.new(runtime_name, CommandType::REFERENCE, [guid])
+ end
+
+ def self.create_array_response(array, runtime_name)
+ return Command.new(runtime_name, CommandType::ARRAY, array)
+ end
+
+ def drop_first_payload_argument
+ payload_args = []
+ payload_args = payload_args + @payload
+ if payload_args.length != 0
+ payload_args.delete_at(0)
+ end
+ return Command.new(@runtime_name, @command_type, payload_args)
+ end
+
+ def add_arg_to_payload(argument)
+ merged_payload = payload + [argument]
+ return Command.new(@runtime_name, @command_type, merged_payload)
+ end
+
+ def prepend_arg_to_payload(current_command)
+ if current_command.nil?
+ return Command.new(@runtime_name, @command_type, @payload)
+ else
+ merged_payload = [current_command] + payload
+ return Command.new(@runtime_name, @command_type, merged_payload)
+ end
+ end
+
def to_string
'Runtime Library: ' + RuntimeName.get_name(@runtime_name).to_s + ' ' + 'Ruby command type: ' + CommandType.get_name(@command_type).to_s + ' ' + 'with parameters: ' + @payload.to_s
end
def eql?(other)
@@ -49,43 +85,8 @@
@is_equal = array_item_equal
else
@is_equal = false
end
return @is_equal
- end
-
- def create_response(response)
- return Command.new(@runtime_name, CommandType::VALUE, [response])
- end
-
- def create_reference(guid)
- return Command.new(@runtime_name, CommandType::REFERENCE, [guid])
- end
-
- def create_array_response(array)
- return Command.new(@runtime_name, CommandType::ARRAY_REFERENCE, [array])
- end
-
- def drop_first_payload_argument
- payload_args = []
- payload_args = payload_args + @payload
- if payload_args.length != 0
- payload_args.delete_at(0)
- end
- return Command.new(@runtime_name, @command_type, payload_args)
- end
-
- def add_arg_to_payload(argument)
- merged_payload = payload + [argument]
- return Command.new(@runtime_name, @command_type, merged_payload)
- end
-
- def add_arg_to_payload_on_beginning(current_command)
- if current_command.nil?
- return Command.new(@runtime_name, @command_type, @payload)
- else
- merged_payload = [current_command] + payload
- return Command.new(@runtime_name, @command_type, merged_payload)
- end
end
end
\ No newline at end of file