Class: Pvectl::Presenters::HostsFile
- Defined in:
- lib/pvectl/presenters/hosts_file.rb
Overview
Presenter for per-node /etc/hosts content.
/etc/hosts is raw text — pvectl does not attempt to parse it. In table mode only summary metadata is shown (node, line count, digest). JSON/YAML output exposes the raw ‘data` string. Describe output prints the full content under a “Content” key.
Instance Method Summary collapse
-
#columns ⇒ Array<String>
Returns column headers for standard table output.
-
#to_description(model) ⇒ Hash
Converts HostsFile model to describe format (kubectl-style).
-
#to_hash(model) ⇒ Hash
Converts HostsFile model to hash for JSON/YAML output.
-
#to_row(model, **_context) ⇒ Array<String>
Converts HostsFile model to table row values.
Methods inherited from Base
#extra_columns, #extra_values, #tags_array, #tags_display, #template_display, #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/hosts_file.rb', line 18 def columns %w[NODE LINES DIGEST] end |
#to_description(model) ⇒ Hash
Converts HostsFile model to describe format (kubectl-style).
51 52 53 54 55 56 57 58 |
# File 'lib/pvectl/presenters/hosts_file.rb', line 51 def to_description(model) { "Node" => model.node || "-", "Digest" => model.digest || "-", "Lines" => model.line_count.to_s, "Content" => model.data.empty? ? "(empty)" : model.data } end |
#to_hash(model) ⇒ Hash
Converts HostsFile model to hash for JSON/YAML output.
39 40 41 42 43 44 45 |
# File 'lib/pvectl/presenters/hosts_file.rb', line 39 def to_hash(model) { "node" => model.node, "data" => model.data, "digest" => model.digest } end |
#to_row(model, **_context) ⇒ Array<String>
Converts HostsFile model to table row values.
27 28 29 30 31 32 33 |
# File 'lib/pvectl/presenters/hosts_file.rb', line 27 def to_row(model, **_context) [ model.node || "-", model.line_count.to_s, model.digest || "-" ] end |