这是我要做的一个示例:
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
难怪它没有读取到频道。需要帮助吗?