Class: Parser::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/parser/config.rb

Constant Summary collapse

DEFAULTS =
{
  from: '11:00',
  till:  '20:00',
  users: {
    1 => 'Timur Vafin',
    2 => 'Alexey Mamaev',
    3 => 'Oleg Kurnosov'
  }
}.freeze
OPTIONS =
[:from, :till, :users]

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



20
21
22
# File 'lib/parser/config.rb', line 20

def initialize
  reset!
end

Instance Method Details

#load!(file) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/parser/config.rb', line 24

def load!(file)
  config = config_from_file(file)

  OPTIONS.each do |key|
    set_option(key, config[key]) if config.include?(key)
  end
end

#reset!Object



32
33
34
35
36
# File 'lib/parser/config.rb', line 32

def reset!
  OPTIONS.each do |key|
    set_option(key, DEFAULTS[key])
  end
end