class Eyecare::Config
Constants
- ASSETS_PATH
- AUDIOS_PATH
- DEFAULTS
- IMAGES_PATH
Attributes
options[R]
Public Class Methods
load_from_file(filename)
click to toggle source
# File lib/eyecare/config.rb, line 42 def self.load_from_file(filename) self.new(YAML.load_file(File.open(filename))) end
load_from_text(text)
click to toggle source
# File lib/eyecare/config.rb, line 46 def self.load_from_text(text) self.new(YAML.load(text)) end
new(options = {})
click to toggle source
# File lib/eyecare/config.rb, line 33 def initialize(options = {}) @options = DEFAULTS if options.respond_to?(:deep_symbolize_keys) options = options.deep_symbolize_keys.deep_compact options = parse_duration_values(options) @options = @options.deep_merge(options) end end
Public Instance Methods
[](key)
click to toggle source
# File lib/eyecare/config.rb, line 50 def [](key) @options[key] end
Private Instance Methods
parse_duration_values(options)
click to toggle source
# File lib/eyecare/config.rb, line 55 def parse_duration_values(options) return options unless options.is_a?(Hash) if options[:alert].is_a?(Hash) [:interval, :timeout].each do |k| if options[:alert][k] options[:alert][k] = ChronicDuration.parse(options[:alert][k]) if options[:alert][k].is_a?(String) options[:alert][k] = options[:alert][k].to_i options[:alert].delete(k) if options[:alert][k] == 0 end end end options end