class SSHClient::CommandBuilder
Constants
- SEPARATOR
Public Class Methods
new(&blk)
click to toggle source
# File lib/ssh_client/command_builder.rb, line 5 def initialize(&blk) @paths = [] @context = eval 'self', blk.binding instance_eval(&blk) end
Public Instance Methods
run(*args)
click to toggle source
# File lib/ssh_client/command_builder.rb, line 15 def run(*args) @paths << to_path(*args) end
to_a()
click to toggle source
# File lib/ssh_client/command_builder.rb, line 11 def to_a @paths end
Private Instance Methods
/(path)
click to toggle source
# File lib/ssh_client/command_builder.rb, line 30 def /(path) "/#{path}" end
method_missing(*args)
click to toggle source
# File lib/ssh_client/command_builder.rb, line 21 def method_missing(*args) return @context.send(*args) if @context.respond_to?(args.first, true) name = args.shift value = to_path args.map { |a| to_path a } @paths.pop if @paths.last == value @paths << to_path(name, value) @paths.last end
to_path(*args)
click to toggle source
# File lib/ssh_client/command_builder.rb, line 34 def to_path(*args) val = args.is_a?(Hash) ? args.to_a : args Array(val).flatten.compact.join SEPARATOR end