Class: Vcloud::Query

Inherits:
Object
  • Object
show all
Defined in:
lib/vcloud/core/query.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type = nil, options = {}) ⇒ Query

Returns a new instance of Query.



9
10
11
12
13
14
15
# File 'lib/vcloud/core/query.rb', line 9

def initialize(type=nil, options={})
  @type = type
  @options = options
  @options[:output_format] ||= 'tsv'
  Fog.mock! if ENV['FOG_MOCK'] || options[:mock]
  @fsi = Vcloud::Fog::ServiceInterface.new
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



7
8
9
# File 'lib/vcloud/core/query.rb', line 7

def options
  @options
end

#typeObject (readonly)

Returns the value of attribute type.



6
7
8
# File 'lib/vcloud/core/query.rb', line 6

def type
  @type
end

Instance Method Details

#fieldsObject



25
26
27
# File 'lib/vcloud/core/query.rb', line 25

def fields
  options[:fields]
end

#filterObject



17
18
19
# File 'lib/vcloud/core/query.rb', line 17

def filter
  options[:filter]
end

#get_all_resultsObject



41
42
43
44
45
46
47
# File 'lib/vcloud/core/query.rb', line 41

def get_all_results
  results = []
  (1..get_num_pages).each do |page|
    results += get_results_page(page) || []
  end
  results
end

#output_formatObject



21
22
23
# File 'lib/vcloud/core/query.rb', line 21

def output_format
  options[:output_format]
end

#runObject



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/vcloud/core/query.rb', line 29

def run()

  puts "options:" if @options[:debug]
  pp @options if @options[:debug]

  if @type.nil?
    output_potential_query_types
  else
    output_query_results
  end
end