我试图理解呈现在this site脚本:Ruby中的百分号+管道运算符的含义如“%|”中的含义?
#!/usr/bin/env ruby
require ENV['TM_SUPPORT_PATH'] + '/lib/escape.rb'
def terminal_script_filepath
%|tell application "Terminal"
activate
do script "jsc -i #{e_as(e_sh(ENV['TM_FILEPATH']))}"
end tell|
end
open("|osascript", "w") { |io| io << terminal_script_filepath }
最重要的是,部分在功能terminal_script_filepath
开头:
%| …
… |
...以及它在“分析”:
{ |io| io << terminal_script_filepath }
这里使用了哪些Ruby的概念?
我知道open()
与管道帮我喂输入到程序的标准输入,但如何输入从terminal_script_filepath
到io
?我也知道basic %
operations with strings,如%w
,但管道在这里做什么?
+1对于googleable“百分比”'管道' –