Class: Pvectl::Presenters::Config::Context
- Defined in:
- lib/pvectl/presenters/config/context.rb
Overview
Presenter for formatting context list output.
Context presenter provides column definitions and row formatting for displaying contexts in table, wide table, JSON, and YAML formats. Inherits from Base to support unified output formatting.
Instance Method Summary collapse
-
#columns ⇒ Array<String>
Returns the column headers for table output.
-
#extra_columns ⇒ Array<String>
Returns additional columns for wide format.
-
#extra_values(context, **context_kwargs) ⇒ Array<String, nil>
Returns additional values for wide format.
-
#to_hash(context) ⇒ Hash
Converts a context to a hash for JSON/YAML output.
-
#to_row(context, current_context: nil, **context_kwargs) ⇒ Array<String>
Converts a context to a table row.
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 the column headers for table output.
30 31 32 |
# File 'lib/pvectl/presenters/config/context.rb', line 30 def columns ["CURRENT", "NAME", "CLUSTER", "USER"] end |
#extra_columns ⇒ Array<String>
Returns additional columns for wide format.
37 38 39 |
# File 'lib/pvectl/presenters/config/context.rb', line 37 def extra_columns ["DEFAULT-NODE"] end |
#extra_values(context, **context_kwargs) ⇒ Array<String, nil>
Returns additional values for wide format.
61 62 63 |
# File 'lib/pvectl/presenters/config/context.rb', line 61 def extra_values(context, **context_kwargs) [context.default_node] end |
#to_hash(context) ⇒ Hash
Converts a context to a hash for JSON/YAML output.
69 70 71 72 73 74 75 76 |
# File 'lib/pvectl/presenters/config/context.rb', line 69 def to_hash(context) { "name" => context.name, "cluster" => context.cluster_ref, "user" => context.user_ref, "default_node" => context.default_node } end |
#to_row(context, current_context: nil, **context_kwargs) ⇒ Array<String>
Converts a context to a table row.
47 48 49 50 51 52 53 54 |
# File 'lib/pvectl/presenters/config/context.rb', line 47 def to_row(context, current_context: nil, **context_kwargs) [ context.name == current_context ? "*" : "", context.name, context.cluster_ref, context.user_ref ] end |