Class: MrPoole::Config

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

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



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

def initialize
  begin
    if File.exists?('_config.yml')
      yaml = YAML.load(File.read('_config.yml'))
      @config = OpenStruct.new(yaml["poole"])
      @config.srcdir = yaml['source'] if yaml['source']
      check_word_separator
    else
      @config = OpenStruct.new
    end
  rescue TypeError, ::Psych::SyntaxError
    bad_yaml_message
    exit
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args) ⇒ Object



42
43
44
# File 'lib/mr_poole/config.rb', line 42

def method_missing(sym, *args)
  @config.send(sym)
end

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/mr_poole/config.rb', line 34

def empty?
  @config == OpenStruct.new
end

#inspectObject



38
39
40
# File 'lib/mr_poole/config.rb', line 38

def inspect
  @config.inspect
end