Sha256: 4219166d0533c5c89dcbbad3f0848cc75e45d0d7df52f5a7bfbb0da298cea293
Contents?: true
Size: 799 Bytes
Versions: 48
Compression:
Stored size: 799 Bytes
Contents
require_relative 'abstract_command_handler' class ArrayGetSizeHandler < AbstractCommandHandler def initialize @required_parameters_count = 1 end def process(command) begin if command.payload.length < @required_parameters_count raise ArgumentError.new "Array get size parameters mismatch" end if command.payload[0].is_a? Array return get_size_array(command) else return get_size(command) end rescue Exception => e return e end end def get_size_array(command) array = command.payload[0] size = 1 while array.is_a? Array size = size * array.length array = array[0] end size end def get_size(command) command.payload[0].length end end
Version data entries
48 entries across 24 versions & 1 rubygems