Class: SelectPdfApi::YamlFileConfig

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

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ YamlFileConfig

Returns a new instance of YamlFileConfig.



4
5
6
7
# File 'lib/select_pdf_api/yaml_file_config.rb', line 4

def initialize(filename)
  @data = {}
  load_config filename
end

Instance Method Details

#load_config(filename) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/select_pdf_api/yaml_file_config.rb', line 9

def load_config(filename)
  config_file = File.join(File.expand_path(File.join('config')), filename)

  raise SelectPdfApi::ConfigError, "Config file #{config_file} does not exist." unless
    File.exist? config_file

  @data = YAML::load_file(config_file)

  raise SelectPdfApi::ConfigError, "Error loading values from #{config_file}" unless @data
end

#optionsObject



20
21
22
# File 'lib/select_pdf_api/yaml_file_config.rb', line 20

def options
  @data
end