[Solved] Ruby, no implicit conversion of Symbol into Integer

yesterday I already asked you in “no implicit conversion of Symbol into Integer, Ruby“. I think you need further information to answer the question. That’s the reason, why I asked again. I updated my system from ruby 1.8.7 to the newer version of ruby 2.3.1p112.

When I want to run a test, I always get the error: FATAL: no implicit conversion of Symbol into Integer

Here is the code:

def element_switch_wago_do(step)
raise Rutema::ParserError, "Missing DO tag!" unless step.has_do?
raise Rutema::ParserError, "Missing DO value!" unless step.has_value?   
raise Rutema::ParserError, "Used DO value '#{step.value}' not supported [0||1 valid]!" unless ((0 == step.value.to_i) || (step.value.to_i == 1))

step.txt="Switch Wago DIGITAL output-pin #{} to #{step.value}"
ip = "{WAGO_IP}"
port = "{WAGO_PORT}"
step.cmd ="switch_wago_do") do |cmd, context| 
    Litu::subst_template!(ip, context)
    Litu::subst_template!(port, context)
    Litu::subst_template!(, context), port.to_i) do |cl|
cl.with_slave(1) do |slave|
    slave.debug = false                         
    slave.write_single_coil(,step.value.to_i)       end

class RubyCommand
    include Patir::Command
    attr_reader :cmd,:working_directory,:killProc
    def initialize params,&block
        if block_given?
            raise "You need to provide a block"

    #Runs the associated block
    def run context=nil

        cmd = @cmd

        pwd = @working_directory
        p = Dir.pwd 
        puts "######: #{cmd}:"
        Litu::subst_template!(pwd, context)
        puts "before block in dir #{Dir.pwd}"

        Dir.chdir(pwd) do
            p = Dir.pwd 
            puts "in block in dir #{cmd}"
  , context)

        puts ":###### #{p}"

        rescue StandardError
            error << "
            error << "
#{$!.backtrace}" if $DEBUG
        return @status

    def kill! if @killProc

    def to_s
        return @name

If I comment the 3 lines in RubyCommand, I don’t get the error.


The problem is something with array and hash. But I have no idea how to get this code running.

Enquirer: shube


Solution #1:

You create RubyCommandinstance like"switch_wago_do")

and you have

def initialize(params, &block)

So params would be String equal "switch_wago_do".
But you expect it to be Hash instance.

That is why commenting these strings solves problem.

Respondent: Aleksey

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Most Popular

To Top
India and Pakistan’s steroid-soaked rhetoric over Kashmir will come back to haunt them both clenbuterol australia bossier man pleads guilty for leadership role in anabolic steriod distribution conspiracy