Class: SchwabRb::Configuration
- Inherits:
-
Object
- Object
- SchwabRb::Configuration
- Defined in:
- lib/schwab_rb/configuration.rb
Instance Attribute Summary collapse
-
#account_hashes_path ⇒ Object
Returns the value of attribute account_hashes_path.
-
#account_names_path ⇒ Object
Returns the value of attribute account_names_path.
-
#log_file ⇒ Object
Returns the value of attribute log_file.
-
#log_level ⇒ Object
Returns the value of attribute log_level.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#schwab_home ⇒ Object
Returns the value of attribute schwab_home.
-
#silence_output ⇒ Object
Returns the value of attribute silence_output.
Instance Method Summary collapse
- #effective_log_file ⇒ Object
- #has_external_logger? ⇒ Boolean
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #should_create_logger? ⇒ Boolean
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/schwab_rb/configuration.rb', line 8 def initialize @logger = nil @log_file = ENV.fetch("SCHWAB_LOGFILE", nil) @log_level = ENV.fetch("SCHWAB_LOG_LEVEL", "WARN").upcase @silence_output = ENV.fetch("SCHWAB_SILENCE_OUTPUT", "false").downcase == "true" default_home = File.("~/.schwab_rb") @schwab_home = ENV.fetch("SCHWAB_HOME", default_home) @account_hashes_path = ENV.fetch("SCHWAB_ACCOUNT_HASHES_PATH", File.join(@schwab_home, "account_hashes.json")) @account_names_path = ENV.fetch("SCHWAB_ACCOUNT_NAMES_PATH", File.join(@schwab_home, "account_names.json")) end |
Instance Attribute Details
#account_hashes_path ⇒ Object
Returns the value of attribute account_hashes_path.
5 6 7 |
# File 'lib/schwab_rb/configuration.rb', line 5 def account_hashes_path @account_hashes_path end |
#account_names_path ⇒ Object
Returns the value of attribute account_names_path.
5 6 7 |
# File 'lib/schwab_rb/configuration.rb', line 5 def account_names_path @account_names_path end |
#log_file ⇒ Object
Returns the value of attribute log_file.
5 6 7 |
# File 'lib/schwab_rb/configuration.rb', line 5 def log_file @log_file end |
#log_level ⇒ Object
Returns the value of attribute log_level.
5 6 7 |
# File 'lib/schwab_rb/configuration.rb', line 5 def log_level @log_level end |
#logger ⇒ Object
Returns the value of attribute logger.
5 6 7 |
# File 'lib/schwab_rb/configuration.rb', line 5 def logger @logger end |
#schwab_home ⇒ Object
Returns the value of attribute schwab_home.
5 6 7 |
# File 'lib/schwab_rb/configuration.rb', line 5 def schwab_home @schwab_home end |
#silence_output ⇒ Object
Returns the value of attribute silence_output.
5 6 7 |
# File 'lib/schwab_rb/configuration.rb', line 5 def silence_output @silence_output end |
Instance Method Details
#effective_log_file ⇒ Object
28 29 30 |
# File 'lib/schwab_rb/configuration.rb', line 28 def effective_log_file @log_file || (ENV["LOGFILE"] if ENV["LOGFILE"] && !ENV["LOGFILE"].empty?) end |
#has_external_logger? ⇒ Boolean
20 21 22 |
# File 'lib/schwab_rb/configuration.rb', line 20 def has_external_logger? !@logger.nil? end |
#should_create_logger? ⇒ Boolean
24 25 26 |
# File 'lib/schwab_rb/configuration.rb', line 24 def should_create_logger? !has_external_logger? && !@silence_output end |