这里是什么,我试图做一个例子:有没有办法在Ruby中使用整数作为方法名?
def 9()
run_playback_command(NINE_COMMAND)
end
我喜欢这种方式,因为它应该是这个样子以后使用:
if(channelNumber != nil)
splitChannel = "#{channelNumber}".split(//)
if(splitChannel[3] != nil)
response = "#{splitChannel[3]}"()
end
if(splitChannel[2] != nil)
response = "#{splitChannel[2]}"()
end
if(splitChannel[1] != nil)
response = "#{splitChannel[1]}"()
end
if(splitChannel[0] != nil)
response = "#{splitChannel[0]}"()
end
end
很抱歉的麻烦,如果这是一个简单的问题!我对Ruby很新。
编辑:
这里就是我试图让Siri的做:
if(phrase.match(/(switch to |go to)channel (.+)\s (on)?(the)?(directv|direct tv)(dvr| receiver)?/i))
self.plugin_manager.block_rest_of_session_from_server
response = nil
if(phrase.match(/channel \s([0-9]+|zero|one|two|three|four|five|six|seven|eight|nine)/))
channelNumber = $1
if(channelNumber.to_i == 0)
channelNumber = map_siri_numbers_to_int(channelNumber)
end
channelNumber.to_s.each_char{ |c| run_playback_command(COMMAND[c]) }
end
难怪它不是读取通道。帮帮我?
我这样读了3次,仍然不确定你想要做什么。您不能将9定义为方法,请解释9与代码片段的关系。 – Gazler
我正在尝试为SiriProxy制作DirecTV频道转换器。问题是,您必须将按钮逐个发送到接收器。在底部的代码片段中,它将信道分离并将数字发送到定义,然后运行该命令。 – williammck