我有一个ruby字符串数组值,我想将它作为字符串值。我使用红宝石与厨师食谱。在Windows平台上运行。代码 -Ruby将字符串数组转换为字符串
version_string = Mixlib::ShellOut.new('some.exe -version').run_command
Log.info(version.stdout.to_s)
extract_var = version_string.stdout.to_s.lines.grep(/ver/)
Log.info('version:'+ extract_var.to_s)
输出coming-
version 530
[2016-06-08T07:03:49+00:00] INFO: version ["version 530\r\n"]
我想只提取530串。
你想字符串值或整数? – Ilya
嗨@llya我已更新完整的代码。请考虑一下。 –
您是否看到[我的回答](http://stackoverflow.com/a/37610826/477037)最后一个问题? – Stefan