Class: Pvectl::Presenters::Service
- Defined in:
- lib/pvectl/presenters/service.rb
Overview
Presenter for systemd services on Proxmox nodes.
Defines column layout and formatting for table output of node services. Standard columns show node, name, state, active, enabled, description. Wide adds the systemd unit identifier.
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<String>
Returns additional values for wide output.
-
#to_hash(model) ⇒ Hash{String => String?}
Converts a Service model to hash for JSON/YAML output.
-
#to_row(model, **_context) ⇒ Array<String>
Converts a Service 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/service.rb', line 23 def columns %w[NODE NAME STATE ACTIVE ENABLED DESCRIPTION] end |
#extra_columns ⇒ Array<String>
Returns additional column headers for wide output.
30 31 32 |
# File 'lib/pvectl/presenters/service.rb', line 30 def extra_columns %w[UNIT] end |
#extra_values(model, **_context) ⇒ Array<String>
Returns additional values for wide output.
55 56 57 |
# File 'lib/pvectl/presenters/service.rb', line 55 def extra_values(model, **_context) [model.service || "-"] end |
#to_hash(model) ⇒ Hash{String => String?}
Converts a Service model to hash for JSON/YAML output.
63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/pvectl/presenters/service.rb', line 63 def to_hash(model) { "node" => model.node, "service" => model.service, "name" => model.name, "state" => model.state, "active_state" => model.active_state, "unit_state" => model.unit_state, "desc" => model.desc } end |
#to_row(model, **_context) ⇒ Array<String>
Converts a Service model to table row values.
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/pvectl/presenters/service.rb', line 39 def to_row(model, **_context) [ model.node || "-", model.display_name || "-", model.state || "-", model.active_state || "-", model.unit_state || "-", model.desc || "-" ] end |