ruby - How to escape # in ruby_expect? -
i want automatize config sessions ruby_expect. there 1 problem. have session prompt console#
.
so have code block:
expect /console#/ send "foobar" end
you see, there # in expect header, , ruby treats / do
comment now, , fails. searched in documentation of ruby regexps, , seems # non-control char, , may not escaped because parser won't understand this.
how can realize code block working block, without # being interpreted comment indicator?
works me:
def expect(*patterns, &block) p patterns end expect /console#/ end
output (1.8.7, 1.9.3, 2.0.0, jruby, rbx):
[/console#/]
from editors, vim gets syntax highlighting right.
Comments
Post a Comment