class Dogscaler::State
Public Class Methods
new()
click to toggle source
# File lib/dogscaler/state.rb, line 4 def initialize @state = self.load @config = '/tmp/dogscaler.yaml' end
Public Instance Methods
get(asg)
click to toggle source
# File lib/dogscaler/state.rb, line 17 def get(asg) @state[asg] || Time.parse("2017-01-31 12:00:00") end
load()
click to toggle source
# File lib/dogscaler/state.rb, line 9 def load begin YAML.load_file(@config) rescue {} end end
save!()
click to toggle source
# File lib/dogscaler/state.rb, line 27 def save! logger.debug "Saving state to #{@config}" File.open( @config, 'w' ) do |out| YAML.dump( @state, out ) end end
update(asg)
click to toggle source
# File lib/dogscaler/state.rb, line 21 def update(asg) t = Time.now logger.debug "Updating the timestamp for #{asg} to #{t}" @state[asg] = t end