Class: Pvectl::Models::HostsFile
- Defined in:
- lib/pvectl/models/hosts_file.rb
Overview
Represents the contents of /etc/hosts on a Proxmox node.
Immutable value object. Created by Repositories::Hosts from API data. /etc/hosts is a per-node raw text file — pvectl does not parse or validate its contents.
Instance Attribute Summary collapse
-
#data ⇒ String
readonly
Raw /etc/hosts content (may be empty).
-
#digest ⇒ String?
readonly
Digest used for optimistic locking on update.
-
#node ⇒ String?
readonly
Node name (not part of API payload — added by repository).
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ HostsFile
constructor
Creates a new HostsFile.
-
#line_count ⇒ Integer
Number of lines in the file (for compact list display).
Constructor Details
#initialize(attributes = {}) ⇒ HostsFile
Creates a new HostsFile.
32 33 34 35 36 37 |
# File 'lib/pvectl/models/hosts_file.rb', line 32 def initialize(attributes = {}) super @node = attributes[:node] || attributes["node"] @data = attributes[:data] || attributes["data"] || "" @digest = attributes[:digest] || attributes["digest"] end |
Instance Attribute Details
#data ⇒ String (readonly)
Returns raw /etc/hosts content (may be empty).
24 25 26 |
# File 'lib/pvectl/models/hosts_file.rb', line 24 def data @data end |
#digest ⇒ String? (readonly)
Returns digest used for optimistic locking on update.
27 28 29 |
# File 'lib/pvectl/models/hosts_file.rb', line 27 def digest @digest end |
#node ⇒ String? (readonly)
Returns node name (not part of API payload — added by repository).
21 22 23 |
# File 'lib/pvectl/models/hosts_file.rb', line 21 def node @node end |
Instance Method Details
#line_count ⇒ Integer
Number of lines in the file (for compact list display).
42 43 44 |
# File 'lib/pvectl/models/hosts_file.rb', line 42 def line_count data.lines.count end |