Class: ConfigLoader

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

Constant Summary collapse

CONFIG_FILE =
File.expand_path('~/.load_shedding_config')

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.load_groupObject

Loads the group data



5
6
7
8
9
10
11
# File 'lib/config_loader.rb', line 5

def load_group
  klass =  File.exists?(CONFIG_FILE) ? self : Interfacer
  obj = klass.new
  group = obj.find_group
  obj.persist(group, CONFIG_FILE) if obj.respond_to?(:persist)
  group
end

.set_groupObject

sets the group data after asking form user



14
15
16
17
18
# File 'lib/config_loader.rb', line 14

def set_group
  obj = Interfacer.new
  group = obj.find_group
  obj.persist(group,CONFIG_FILE)
end

Instance Method Details

#find_groupObject

loads the group information form the file



22
23
24
# File 'lib/config_loader.rb', line 22

def find_group
  File.read(CONFIG_FILE)
end