虽然我是 Ruby 新手,但我已经通过反复试验为 Ruby 编写了许多插件。
我尝试了许多不同的语法变体,结果是:
Unexpected else or end, expecting }
- 变量没有得到正确评估,即
@reUrl
最终 ="@reUrl2"
任何帮助,将不胜感激。
这是我的代码的摘录:
def initialize(config)
self.reip1 = config["reip1"]
self.reip2 = config["reip2"]
@reUrl1 = "#{self.reip1}:8080/redeye/rooms/0/devices/2/commands/send?commandId="
@reUrl2 = "#{self.reip2}:8080/redeye/rooms/0/devices/2/commands/send?commandId="
@reUrl = @reUrl2
end
.
.
.
.
def change_redeye(redeye)
redeye = "#{redeye}".downcase
redeye = "#{redeye}".strip
redeyeid = "#{@redeyeId["#{redeye}"]}".to_i
if redeyeid > 0
say "OK. Changing to RedEye #{redeye}."
# results in resel = "@reUrl2" Does what I want.
resel = "@reUrl#{redeyeid}"
# FIXIT: need to end up with the URL of the device, but can't find the right syntax.
@reUrl = "#{#{resel}}"
else
say "Sorry, I am not programmed to control RedEye #{redeye}."
end
request_completed
end