Class: Command
- Inherits:
-
Object
- Object
- Command
- Defined in:
- lib/javonet-ruby-sdk/utils/command.rb,
lib/javonet-ruby-sdk/Binaries/Ruby/Linux/X64/utils/command.rb,
lib/javonet-ruby-sdk/Binaries/Ruby/MacOs/X64/utils/command.rb,
lib/javonet-ruby-sdk/Binaries/Ruby/Windows/X64/utils/command.rb
Class Method Summary collapse
- .create_array_response(array, runtime_name) ⇒ Object
- .create_reference(guid, runtime_name) ⇒ Object
- .create_response(response, runtime_name) ⇒ Object
Instance Method Summary collapse
- #add_arg_to_payload(argument) ⇒ Object
- #command_type ⇒ Object
- #drop_first_payload_argument ⇒ Object
- #eql?(other) ⇒ Boolean
-
#initialize(runtime_name, command_type, payload) ⇒ Command
constructor
A new instance of Command.
- #payload ⇒ Object
- #prepend_arg_to_payload(current_command) ⇒ Object
- #runtime_name ⇒ Object
- #to_string ⇒ Object
Constructor Details
#initialize(runtime_name, command_type, payload) ⇒ Command
Returns a new instance of Command.
6 7 8 9 10 |
# File 'lib/javonet-ruby-sdk/utils/command.rb', line 6 def initialize(runtime_name, command_type, payload) @runtime_name = runtime_name @command_type = command_type @payload = payload end |
Class Method Details
.create_array_response(array, runtime_name) ⇒ Object
33 34 35 |
# File 'lib/javonet-ruby-sdk/utils/command.rb', line 33 def self.create_array_response(array, runtime_name) return Command.new(runtime_name, CommandType::ARRAY, array) end |
.create_reference(guid, runtime_name) ⇒ Object
29 30 31 |
# File 'lib/javonet-ruby-sdk/utils/command.rb', line 29 def self.create_reference(guid, runtime_name) return Command.new(runtime_name, CommandType::REFERENCE, [guid]) end |
.create_response(response, runtime_name) ⇒ Object
25 26 27 |
# File 'lib/javonet-ruby-sdk/utils/command.rb', line 25 def self.create_response(response, runtime_name) return Command.new(runtime_name, CommandType::VALUE, [response]) end |
Instance Method Details
#add_arg_to_payload(argument) ⇒ Object
46 47 48 49 |
# File 'lib/javonet-ruby-sdk/utils/command.rb', line 46 def add_arg_to_payload(argument) merged_payload = payload + [argument] return Command.new(@runtime_name, @command_type, merged_payload) end |
#command_type ⇒ Object
16 17 18 |
# File 'lib/javonet-ruby-sdk/utils/command.rb', line 16 def command_type @command_type end |
#drop_first_payload_argument ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/javonet-ruby-sdk/utils/command.rb', line 37 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 |
#eql?(other) ⇒ Boolean
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/javonet-ruby-sdk/utils/command.rb', line 64 def eql?(other) @is_equal = false if self == other @is_equal = true end if other == nil or self.class != other.class @is_equal = false end if self.command_type == other.command_type and self.runtime_name == other.runtime_name @is_equal = true end if payload.length == other.payload.length i = 0 array_item_equal = false payload.each { |payload_item| if payload_item.eql? other.payload[i] array_item_equal = true else array_item_equal = false end i += 1 } @is_equal = array_item_equal else @is_equal = false end return @is_equal end |
#payload ⇒ Object
20 21 22 |
# File 'lib/javonet-ruby-sdk/utils/command.rb', line 20 def payload @payload end |
#prepend_arg_to_payload(current_command) ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/javonet-ruby-sdk/utils/command.rb', line 51 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 |
#runtime_name ⇒ Object
12 13 14 |
# File 'lib/javonet-ruby-sdk/utils/command.rb', line 12 def runtime_name @runtime_name end |
#to_string ⇒ Object
60 61 62 |
# File 'lib/javonet-ruby-sdk/utils/command.rb', line 60 def to_string 'Runtime Library: ' + RuntimeNameHandler.get_name(@runtime_name) + ' ' + 'Ruby command type: ' + CommandType.get_name(@command_type).to_s + ' ' + 'with parameters: ' + @payload.to_s end |