class Cloud::Sh::Helpers::Commands::CmdChain

Public Class Methods

new(base) click to toggle source
# File lib/cloud/sh/helpers/commands.rb, line 13
def initialize(base)
  @cmd = [base]
end

Public Instance Methods

execute() click to toggle source
# File lib/cloud/sh/helpers/commands.rb, line 44
def execute
  cloud_sh_exec(@cmd)
end
map(*fields) click to toggle source
# File lib/cloud/sh/helpers/commands.rb, line 33
def map(*fields)
  execute.lines.map do |line|
    values = line.split.first(fields.size)
    OpenStruct.new(fields.zip(values).to_h)
  end
end
method_missing(name, *args) click to toggle source
# File lib/cloud/sh/helpers/commands.rb, line 22
def method_missing(name, *args)
  if args.empty?
    @cmd << name.to_s.tr("_", "-")
  elsif args.first.is_a?(TrueClass)
    @cmd << "--#{name.to_s.tr("_", "-")}"
  else
    @cmd << "--#{name.to_s.tr("_", "-")}=#{args.first}"
  end
  self
end
replace_current_process() click to toggle source
# File lib/cloud/sh/helpers/commands.rb, line 40
def replace_current_process
  exec(@cmd.join(" "))
end
to_s() click to toggle source
# File lib/cloud/sh/helpers/commands.rb, line 48
def to_s
  @cmd.join(" ")
end
with(val) click to toggle source
# File lib/cloud/sh/helpers/commands.rb, line 17
def with(val)
  @cmd << val
  self
end