Class/Module Index [+]

Quicksearch

HammerCLIForeman::ListCommand

Constants

DEFAULT_PER_PAGE

Public Class Methods

command_name(name=nil) click to toggle source
# File lib/hammer_cli_foreman/commands.rb, line 218
def self.command_name(name=nil)
  super(name) || "list"
end

Public Instance Methods

adapter() click to toggle source
# File lib/hammer_cli_foreman/commands.rb, line 203
def adapter
  :table
end
execute() click to toggle source
# File lib/hammer_cli_foreman/commands.rb, line 222
def execute
  if respond_to?(:option_page) && respond_to?(:option_per_page)
    self.option_page = (self.option_page || 1).to_i
    self.option_per_page ||= HammerCLI::Settings.get(:ui, :per_page) || DEFAULT_PER_PAGE
    browse_collection
  else
    retrieve_and_print
  end

  return HammerCLI::EX_OK
end
extend_data(record) click to toggle source
# File lib/hammer_cli_foreman/commands.rb, line 214
def extend_data(record)
  record
end
send_request() click to toggle source
# File lib/hammer_cli_foreman/commands.rb, line 207
def send_request
  data = super
  set = HammerCLIForeman.collection_to_common_format(data)
  set.map! { |r| extend_data(r) }
  set
end

Protected Instance Methods

browse_collection() click to toggle source
# File lib/hammer_cli_foreman/commands.rb, line 237
def browse_collection
  list_next = true

  while list_next do
    d = retrieve_and_print

    if (d.size >= self.option_per_page.to_i) && interactive?
      answer = ask(_("List next page? (%s): ") % 'Y/n').downcase
      list_next = (answer == 'y' || answer == '')
      self.option_page += 1
    else
      list_next = false
    end
  end
end
retrieve_and_print() click to toggle source
# File lib/hammer_cli_foreman/commands.rb, line 253
def retrieve_and_print
  d = send_request
  print_data d
  d
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.