module NexClient::Commands::CubeTemplates
Constants
- TEMPLATES_HEADERS
- TEMPLATES_TITLE
Public Class Methods
display_templates(list)
click to toggle source
# File lib/nex_client/commands/cube_templates.rb, line 28 def self.display_templates(list) table = Terminal::Table.new title: TEMPLATES_TITLE, headings: TEMPLATES_HEADERS do |t| [list].flatten.compact.each do |e| t.add_row(self.format_record(e)) end end puts table puts "\n" end
format_record(record)
click to toggle source
# File lib/nex_client/commands/cube_templates.rb, line 38 def self.format_record(record) [ record.id, record.human_id, record.image, record.tag, record.layer, record.min_pu, record.stack ] end
list(args,opts)
click to toggle source
# File lib/nex_client/commands/cube_templates.rb, line 10 def self.list(args,opts) filters = {} filters[:human_id] = opts.name if opts.name.present? filters[:stack] = opts.stack if opts.stack.present? filters[:image] = opts.image if opts.image.present? # Create table list = NexClient::CubeTemplate.where(filters).order('human_id') self.display_templates(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_templates(list) end end