Class: Pvectl::Presenters::Template
- Defined in:
- lib/pvectl/presenters/template.rb
Overview
Presenter for template listing (mixed VM and Container templates).
Handles both Models::Vm and Models::Container via duck typing. Both models share: vmid, name, type, node, maxdisk, tags.
Instance Method Summary collapse
-
#columns ⇒ Array<String>
Returns column headers for template listing.
-
#to_hash(model) ⇒ Hash
Converts a template model to hash for JSON/YAML.
-
#to_row(model, **_context) ⇒ Array<String>
Converts a template model to table row.
Methods inherited from Base
#extra_columns, #extra_values, #tags_array, #tags_display, #template_display, #to_description, #to_wide_row, #uptime_human, #wide_columns
Instance Method Details
#columns ⇒ Array<String>
Returns column headers for template listing.
22 23 24 |
# File 'lib/pvectl/presenters/template.rb', line 22 def columns %w[ID NAME TYPE NODE DISK TAGS] end |
#to_hash(model) ⇒ Hash
Converts a template model to hash for JSON/YAML.
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/pvectl/presenters/template.rb', line 46 def to_hash(model) { "id" => model.vmid, "name" => model.name, "type" => model.type, "node" => model.node, "disk" => model.maxdisk, "tags" => model. } end |
#to_row(model, **_context) ⇒ Array<String>
Converts a template model to table row.
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/pvectl/presenters/template.rb', line 31 def to_row(model, **_context) [ model.vmid.to_s, model.name || "-", model.type || "-", model.node || "-", format_disk(model.maxdisk), model. || "-" ] end |