Class: WavefrontCli::Subcommand::Import

Inherits:
Object
  • Object
show all
Defined in:
lib/wavefront-cli/subcommands/import.rb

Overview

Stuff to import an object

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(calling_class, options) ⇒ Import

Returns a new instance of Import.



13
14
15
16
17
18
# File 'lib/wavefront-cli/subcommands/import.rb', line 13

def initialize(calling_class, options)
  @calling_class = calling_class
  @wf = calling_class.wf
  @options = options
  @message = 'IMPORTED'
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



11
12
13
# File 'lib/wavefront-cli/subcommands/import.rb', line 11

def options
  @options
end

#wfObject (readonly)

Returns the value of attribute wf.



11
12
13
# File 'lib/wavefront-cli/subcommands/import.rb', line 11

def wf
  @wf
end

Instance Method Details

#run!Object



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/wavefront-cli/subcommands/import.rb', line 20

def run!
  errs = 0

  [raw_input].flatten.each do |obj|
    resp = import_object(obj)
    next if options[:noop]

    errs += 1 unless resp.ok?
    puts import_message(obj, resp)
  end

  exit errs
end