【发布时间】:2010-05-23 14:31:31
【问题描述】:
我在 Ruby 中使用 Highline 时遇到了一些问题,并试图让选择元素 detailed here 工作。
- 目前以下代码产生错误 “错误:参数数量错误(0 代表 1)。使用 --trace 查看回溯”
- 如何使变量无法选择?目前我有“做”设置,但我不知道如何将用户选择的变量放入变量中以供其他地方使用。
对不起,如果这有点初学者,我对 ruby 是全新的,这是我的第一个项目,在最深处。
提前致谢。
if agree("Are these files going to be part of a set? ")
set_title = ask("Title: ")
set_desc = ask("Description:")
set_genre = ask("Genre: ")
set_label = ask("Record Label: ")
set_date = ask_for_date("Release Date (yy-mm-dd): ")
set_label = ask("EAN/UPC: ")
set_buy = ask("Buy this set link: ")
set_tags = ask_for_array("Tags (seperated by space): ")
# Sort out license
choose do |menu|
menu.prompt = "Please choose the license for this set? "
menu.choices(:all_rights_reserved, :cc_by) do
# put the stuff in a variable
end
end
end # End setup set
【问题讨论】:
-
究竟哪一行给你带来了问题?
choose部分在 Ruby 1.8 或 1.9 中运行良好。ask_for_date似乎是自定义方法,ask_for_array也是如此,所以无法帮助您... -
这是我的会话记录:Alex-Andrewss-MacBook-Pro:SoundCloud-CLI alex$ ruby sc.rb upload /Users/alex/SoundCloud-CLI 这些文件是否会成为其中的一部分一套? y 标题:你好 描述:你好 类型:你好 唱片标签:你好 发布日期 (yy-mm-dd):09-10-10 EAN/UPC:你好 购买此套装链接:你好 标签(以空格分隔):你好 gello 错误: 参数数量错误(0 代表 1)。使用 --trace 查看回溯非常感谢您迄今为止的帮助。
标签: ruby command-line command-line-interface gem highline