module NexClient::Commands::Organizations

Constants

ORGS_HEADERS
ORGS_TITLE

Public Class Methods

display_organizations(list) click to toggle source
# File lib/nex_client/commands/organizations.rb, line 23
def self.display_organizations(list)
  table = Terminal::Table.new title: ORGS_TITLE, headings: ORGS_HEADERS do |t|
    [list].flatten.compact.each do |e|
      t.add_row([e.id,e.name,e.handle])
    end
  end
  puts table
  puts "\n"
end
list(args,opts) click to toggle source
# File lib/nex_client/commands/organizations.rb, line 10
def self.list(args,opts)
  # Display list
  list = NexClient::Organization.order('handle')
  self.display_organizations(list)

  # Loop through results
  while (list.pages.links||{})['next']
    return true if ask("Press enter for next page ('q' to quit)") =~ /q/
    list = list.pages.next
    self.display_organizations(list)
  end
end