Ruby error when creating new object: wrong number of arguments (given 5, expected 0)

I am learning Ruby but I am currently stuck here when trying to create a new object inside a method from another class. I have this main 'command.rb' class where I just initialize its arguments:

class Command
 
      attr_accessor :key, :flag, :time, :bytes, :value,

      def initialize(key, flag, expTime, bytes,value)
          @key = key
          @flag = flag
          @expTime = expTime
          @bytes = bytes
          @value = value
      end
end

Then I try to create a Command object inside this other class:

require_relative 'command'

class CommandDAO

    def initialize
        @data_hash = Hash.new
    end

    def set(arrayInfo, value)
        full_key = Command.new(arrayInfo[1],arrayInfo[2],arrayInfo[3],arrayInfo[4],value)
        data_hash.store(key,full_key)
        return "STORED\r\n"
    end
end

The error I am getting at the moment is that the expect number of values is 0. Why is this?

Thanks a lot for your help!!



from Recent Questions - Stack Overflow https://ift.tt/37Jmorf
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Spring Elasticsearch Operations

Network Error and Timeout on Authorize.net JS

Object oriented programming concepts (OOPs)