Class: Bankai::Docker::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/bankai/docker/command.rb

Overview

The docker command

Instance Method Summary collapse

Constructor Details

#initialize(type, *args, options: {}, mode: nil) ⇒ Command

Returns a new instance of Command.



7
8
9
10
11
12
# File 'lib/bankai/docker/command.rb', line 7

def initialize(type, *args, options: {}, mode: nil)
  @type = type.to_s.upcase
  @args = args
  @options = options
  @mode = mode
end

Instance Method Details

#argsObject

TODO: Prevent use getter as helper method name



19
20
21
22
23
# File 'lib/bankai/docker/command.rb', line 19

def args
  return @args.to_s if @mode == :array

  @args.join(' ')
end

#optionsObject



25
26
27
28
29
# File 'lib/bankai/docker/command.rb', line 25

def options
  @options.map do |key, value|
    "--#{key}=#{value}"
  end.compact.join(' ')
end

#to_sObject



14
15
16
# File 'lib/bankai/docker/command.rb', line 14

def to_s
  "#{@type} #{options} #{args}"
end