module Weesked::Configuration

Constants

DEFAULT_AVAILIABLE_DAYS

By default, the whole week

DEFAULT_AVAILIABLE_STEPS

By default, whole day in hours

DEFAULT_STEPS_DAY_SHIFT

By default, we use astonomical day

DEFAULT_TIME_STEP

By default, 1.hour

VALID_OPTIONS_KEYS

Public Class Methods

extended(base) click to toggle source

When this module is extended, set all configuration options to their default values

# File lib/weesked/configuration.rb, line 35
def self.extended(base)
  base.reset
end

Public Instance Methods

configure() { |self| ... } click to toggle source

Convenience method to allow configuration options to be set in a block

# File lib/weesked/configuration.rb, line 40
def configure
  yield self
end
options() click to toggle source

Create a hash of options and their values

# File lib/weesked/configuration.rb, line 45
def options
  VALID_OPTIONS_KEYS.inject({}) do |option, key|
    option.merge!(key => send(key))
  end
end
reset() click to toggle source

Reset all configuration options to defaults

# File lib/weesked/configuration.rb, line 52
def reset
  self.time_step = DEFAULT_TIME_STEP
  self.availiable_days = DEFAULT_AVAILIABLE_DAYS
  self.availiable_steps = DEFAULT_AVAILIABLE_STEPS
  self.steps_day_shift = DEFAULT_STEPS_DAY_SHIFT
end