【发布时间】:2014-02-16 18:53:22
【问题描述】:
我正在使用 Ruby,我正在尝试使用变量变量名:D
while count < iterationnumber.to_i
@output = testtrim[count].tr(",", " ").delete('{').delete('}').delete('"').delete('[').delete(']')
count +=1
end
我需要在@output 中添加“count”,而不是只为haml 获得一个输出。另外,如果您知道如何更有效地去除所有这些字符,我将不胜感激。
提前致谢!
本尼
更新
get '/test' do
keygen = "#{session["keygen"]}"
puts keygen
template = Addressable::Template.new("http://api.toodledo.com/2/tasks/get.php?key=#{keygen};modafter=1234567890;fields=folder,star,priority")
uri = template7.expand({"keygen" => keygen})
puts uri
responseauth = RestClient.get(uri.to_s)
testtrim = responseauth.split('}')
iterationnumber = testtrim[0][22..-2]
count = 0
while count < iterationnumber.to_i
@output = testtrim[count].tr(",", " ").delete('{}"[]')
count +=1
end
现在的问题是,我不知道如何将“count”数字添加到@output,以将所有这些拆分部分输出到haml。也许有人知道更好的方法来做到这一点......
谢谢
【问题讨论】:
-
你应该包含更多关于你想要做什么的信息。
testtrim是什么?它包含什么?你想从中产生什么?count和iterationnumber是什么?
标签: ruby variables sinatra haml