Class: SelectPdfApi::EnvConfig
- Inherits:
-
Object
- Object
- SelectPdfApi::EnvConfig
- Defined in:
- lib/select_pdf_api/env_config.rb
Overview
Config class using the ENV variable or the API key.
Constant Summary collapse
- API_OPTIONS =
API Options list
%w{ key page_size page_orientation pdf_name margin_top margin_right margin_bottom margin_left page_numbers user_password owner_password web_page_width web_page_height }
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
API Options Hash.
Instance Method Summary collapse
-
#configure_options ⇒ Hash
Sets the initial values for the API options.
-
#initialize(env_var) ⇒ Object
constructor
SelectPdfApi::EnvConfig.
-
#options ⇒ Hash
Required by all config classes as the common interface for the main class.
Constructor Details
#initialize(env_var) ⇒ Object
Returns SelectPdfApi::EnvConfig.
17 18 19 20 |
# File 'lib/select_pdf_api/env_config.rb', line 17 def initialize(env_var='SELECT_PDF_KEY') @env_var = env_var end |
Instance Attribute Details
#data ⇒ Object (readonly)
API Options Hash
6 7 8 |
# File 'lib/select_pdf_api/env_config.rb', line 6 def data @data end |
Instance Method Details
#configure_options ⇒ Hash
Sets the initial values for the API options. The API key is set from the environment variable.
26 27 28 29 30 31 |
# File 'lib/select_pdf_api/env_config.rb', line 26 def @data = {} API_OPTIONS.each {|option| @data[option] = ''} @data['key'] = ENV[@env_var] @data end |
#options ⇒ Hash
Required by all config classes as the common interface for the main class.
36 37 38 |
# File 'lib/select_pdf_api/env_config.rb', line 36 def @data.delete_if{|k, v| v.empty?} end |