Class: Pvectl::Presenters::Backup
- Defined in:
- lib/pvectl/presenters/backup.rb
Overview
Presenter for Backup models.
Formats backups for table, wide, JSON, and YAML output. Standard columns: VMID, TYPE, CREATED, SIZE, STORAGE, PROTECTED Wide columns add: FORMAT, NOTES, VOLID
Instance Method Summary collapse
-
#columns ⇒ Array<String>
Returns column headers for standard table output.
-
#extra_columns ⇒ Array<String>
Returns additional column headers for wide output.
-
#extra_values(model, **_context) ⇒ Array
Returns additional values for wide output.
-
#to_hash(model) ⇒ Hash
Converts Backup model to hash for JSON/YAML output.
-
#to_row(model, **_context) ⇒ Array
Converts Backup model to table row values.
Methods inherited from Base
#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 standard table output.
23 24 25 |
# File 'lib/pvectl/presenters/backup.rb', line 23 def columns %w[VMID TYPE CREATED SIZE STORAGE PROTECTED] end |
#extra_columns ⇒ Array<String>
Returns additional column headers for wide output.
30 31 32 |
# File 'lib/pvectl/presenters/backup.rb', line 30 def extra_columns %w[FORMAT NOTES VOLID] end |
#extra_values(model, **_context) ⇒ Array
Returns additional values for wide output.
55 56 57 58 59 60 61 |
# File 'lib/pvectl/presenters/backup.rb', line 55 def extra_values(model, **_context) [ model.format, truncate(model.notes, 30), model.volid ] end |
#to_hash(model) ⇒ Hash
Converts Backup model to hash for JSON/YAML output.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/pvectl/presenters/backup.rb', line 67 def to_hash(model) { "vmid" => model.vmid, "type" => format_type(model.resource_type), "volid" => model.volid, "storage" => model.storage, "node" => model.node, "size" => model.size, "size_human" => model.human_size, "created_at" => model.created_at&.iso8601, "format" => model.format, "notes" => model.notes, "protected" => model.protected? } end |
#to_row(model, **_context) ⇒ Array
Converts Backup model to table row values.
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/pvectl/presenters/backup.rb', line 39 def to_row(model, **_context) [ model.vmid, format_type(model.resource_type), format_time(model.created_at), model.human_size, model.storage, format_protected(model.protected?) ] end |