class ShellB::Command
Attributes
block[R]
downstream[RW]
name[R]
opts[R]
shell[R]
Public Class Methods
new(shell, name, *opts)
click to toggle source
# File lib/shellb/command.rb, line 8 def initialize(shell, name, *opts) @shell = shell @name = name @opts = opts end
Public Instance Methods
<(from)
click to toggle source
# File lib/shellb/command.rb, line 29 def <(from) @input = from self end
>(to)
click to toggle source
# File lib/shellb/command.rb, line 19 def >(to) @output = to self end
>>(to)
click to toggle source
# File lib/shellb/command.rb, line 24 def >>(to) @append = to self end
pretty_print(pp)
click to toggle source
# File lib/shellb/command.rb, line 57 def pretty_print(pp) pp.object_group(self) do pp.breakable pp.text "@name=" pp.pp @name pp.breakable pp.text "@opts=" pp.pp @opts end end
redirection_parts()
click to toggle source
# File lib/shellb/command.rb, line 34 def redirection_parts return [">", @output.to_s] if @output return [">>", @append.to_s] if @append return ["<", @input.to_s] if @input return [] end
to_s()
click to toggle source
# File lib/shellb/command.rb, line 41 def to_s "<Command: #{name} #{opts.join(" ")}>" end
to_sh()
click to toggle source
# File lib/shellb/command.rb, line 45 def to_sh parts = [] parts << Shellwords.shelljoin([name, *opts]) unless (rd_parts = redirection_parts.join(" ")).empty? parts.last << " " + rd_parts end parts << downstream.to_sh if downstream parts.join(" | ") end
|(command)
click to toggle source
# File lib/shellb/command.rb, line 14 def |(command) shell.drop_command(command) self.downstream = command end