Class: Pvectl::Models::TimeConfig

Inherits:
Base
  • Object
show all
Defined in:
lib/pvectl/models/time_config.rb

Overview

Represents the time and timezone settings of a Proxmox node.

Immutable value object holding the response from ‘GET /nodes/node/time`, augmented with the node name (which is not part of the API payload but is the identifying context for the lookup).

Display formatting is handled by Presenters::TimeConfig.

Examples:

Creating from API data

data = { time: 1_715_000_000, localtime: 1_715_007_200, timezone: "Europe/Warsaw" }
model = TimeConfig.new(data.merge(node_name: "pve1"))
model.timezone #=> "Europe/Warsaw"

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ TimeConfig

Creates a new TimeConfig.

Parameters:

  • attributes (Hash) (defaults to: {})

    attribute key-value pairs



38
39
40
41
42
43
44
# File 'lib/pvectl/models/time_config.rb', line 38

def initialize(attributes = {})
  super
  @node_name = @attributes[:node_name]
  @time = @attributes[:time]
  @localtime = @attributes[:localtime]
  @timezone = @attributes[:timezone]
end

Instance Attribute Details

#localtimeInteger? (readonly)

Returns seconds since epoch interpreted as the node’s local wall clock (Proxmox returns the local clock encoded as if it were UTC).

Returns:

  • (Integer, nil)

    seconds since epoch interpreted as the node’s local wall clock (Proxmox returns the local clock encoded as if it were UTC).



30
31
32
# File 'lib/pvectl/models/time_config.rb', line 30

def localtime
  @localtime
end

#node_nameString? (readonly)

Returns node name (identifies which node this config belongs to).

Returns:

  • (String, nil)

    node name (identifies which node this config belongs to)



23
24
25
# File 'lib/pvectl/models/time_config.rb', line 23

def node_name
  @node_name
end

#timeInteger? (readonly)

Returns seconds since epoch (UTC).

Returns:

  • (Integer, nil)

    seconds since epoch (UTC)



26
27
28
# File 'lib/pvectl/models/time_config.rb', line 26

def time
  @time
end

#timezoneString? (readonly)

Returns IANA timezone name (e.g., “Europe/Warsaw”, “UTC”).

Returns:

  • (String, nil)

    IANA timezone name (e.g., “Europe/Warsaw”, “UTC”)



33
34
35
# File 'lib/pvectl/models/time_config.rb', line 33

def timezone
  @timezone
end