Class: Seira::Commands::Gcloud

Inherits:
Object
  • Object
show all
Defined in:
lib/seira/commands/gcloud.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command, context:, clean_output:, format:) ⇒ Gcloud

Returns a new instance of Gcloud.



6
7
8
9
10
11
# File 'lib/seira/commands/gcloud.rb', line 6

def initialize(command, context:, clean_output:, format:)
  @command = command
  @context = context
  @format = format
  @clean_output = clean_output
end

Instance Attribute Details

#clean_outputObject (readonly)

Returns the value of attribute clean_output.



4
5
6
# File 'lib/seira/commands/gcloud.rb', line 4

def clean_output
  @clean_output
end

#commandObject (readonly)

Returns the value of attribute command.



4
5
6
# File 'lib/seira/commands/gcloud.rb', line 4

def command
  @command
end

#contextObject (readonly)

Returns the value of attribute context.



4
5
6
# File 'lib/seira/commands/gcloud.rb', line 4

def context
  @context
end

#formatObject (readonly)

Returns the value of attribute format.



4
5
6
# File 'lib/seira/commands/gcloud.rb', line 4

def format
  @format
end

Instance Method Details

#invokeObject



13
14
15
16
17
18
19
20
21
# File 'lib/seira/commands/gcloud.rb', line 13

def invoke
  puts "Calling: #{calculated_command.green}" unless clean_output

  if format == :boolean
    system(calculated_command)
  elsif format == :json
    `#{calculated_command}`
  end
end