Class: Pvectl::Presenters::NodeOperationResult
- Inherits:
-
OperationResult
- Object
- Base
- OperationResult
- Pvectl::Presenters::NodeOperationResult
- Defined in:
- lib/pvectl/presenters/node_operation_result.rb
Overview
Presenter for node operation results (set/edit).
Formats NodeOperationResult models for table/JSON/YAML output.
Constant Summary
Constants included from Formatters::ColorSupport
Formatters::ColorSupport::STATUS_COLORS
Instance Method Summary collapse
-
#columns ⇒ Array<String>
Returns column headers for standard table output.
-
#to_hash(model) ⇒ Hash
Converts result to hash for JSON/YAML output.
-
#to_row(model, **_context) ⇒ Array<String>
Converts result to table row values.
Methods included from Formatters::ColorSupport
colorize_status, enabled?, pastel
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 standard table output.
18 19 20 |
# File 'lib/pvectl/presenters/node_operation_result.rb', line 18 def columns %w[NODE OPERATION STATUS MESSAGE] end |
#to_hash(model) ⇒ Hash
Converts result to hash for JSON/YAML output.
40 41 42 43 44 45 46 47 |
# File 'lib/pvectl/presenters/node_operation_result.rb', line 40 def to_hash(model) { "node" => model.node_model&.name, "operation" => model.operation&.to_s, "status" => model.status_text, "message" => model. } end |
#to_row(model, **_context) ⇒ Array<String>
Converts result to table row values.
27 28 29 30 31 32 33 34 |
# File 'lib/pvectl/presenters/node_operation_result.rb', line 27 def to_row(model, **_context) [ model.node_model&.name || "-", model.operation&.to_s || "-", status_display(model), model. ] end |