Class: IhealthBot::Config
- Inherits:
-
Object
- Object
- IhealthBot::Config
- Defined in:
- lib/ihealth_bot/config.rb
Class Method Summary collapse
Class Method Details
.email ⇒ Object
3 4 5 |
# File 'lib/ihealth_bot/config.rb', line 3 def self.email config_file.dig(:credentials, :email) end |
.password ⇒ Object
7 8 9 |
# File 'lib/ihealth_bot/config.rb', line 7 def self.password config_file.dig(:credentials, :password) end |
.valid? ⇒ Boolean
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/ihealth_bot/config.rb', line 11 def self.valid? return false unless File.exist?("#{Dir.home}/.ihealth_bot") File.open("#{Dir.home}/.ihealth_bot", 'r') do |f| return false unless data = JSON.parse(f.read, symbolize_names: true) rescue nil return false unless data[:credentials] return false unless data[:credentials][:email] return false unless data[:credentials][:password] end true end |