listen_for /#{Regexp.escape myVar} ([a-z]* ?[a-z]* ?[a-z]* ?[a-z]* ?[a-z]* ?[a-z]*)/i do |event_name|
using a variable in listen command siriproxy
質問
I am setting up a listen command to grab a string of words in my siriproxy project.
The string can be anything, so the easiest way is to make sure the string starts with a special word. I want to set that word in a variable. That way, I can give the user a way to change it.
Here is what I have:
listen_for /Elvis ([a-z]* ?[a-z]* ?[a-z]* ?[a-z]* ?[a-z]* ?[a-z]*)/i do |event_name|
My command will begin with Elvis
, and everything after it becomes the variable event_name
.
What if I wanted Elvis
to be a variable? I tried this with a big fail.
listen_for /#{myVar} ([a-z]* ?[a-z]* ?[a-z]* ?[a-z]* ?[a-z]* ?[a-z]*)/i do |event_name|
解決
所属していません StackOverflow