Class: VagrantPlugins::TimeZone::Config

Inherits:
Vagrant::Plugin::V2::Config
  • Object
show all
Defined in:
lib/vagrant-timezone/config.rb,
lib/vagrant-timezone/config.rb

Overview

Configuration for the Time Zone plugin

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



11
12
13
14
15
# File 'lib/vagrant-timezone/config.rb', line 11

def initialize
  super

  @value = UNSET_VALUE
end

Instance Attribute Details

#valueObject

Returns the value of attribute value.



9
10
11
# File 'lib/vagrant-timezone/config.rb', line 9

def value
  @value
end

Instance Method Details

#finalize!Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/vagrant-timezone/config.rb', line 17

def finalize!
  super

  if @value == UNSET_VALUE
    @value = nil
  elsif @value == :host
    # Get the offset of the current timezone of the host. Ruby doesn't reliably
    # detect the named timezone, so we have to use the hour offset. Note that when
    # DST changes, etc, this offset will change.

    # We set timezone offset negative to match POSIX standards
    # https://github.com/eggert/tz/blob/master/etcetera
    @value = format('Etc/GMT%+d', -(Time.now.utc_offset / 3600))
  end
end