Sha256: bae4019e6c89073d2e11bf0b394b63994f743c34a293d7282751b10019d823e1

Contents?: true

Size: 841 Bytes

Versions: 2

Compression:

Stored size: 841 Bytes

Contents

require 'feedbook/factories/notifiers_factory'
require 'feedbook/helpers/time_interval_parser'

module Feedbook
  class Configuration
    attr_reader :interval, :options

    INTERVAL_FORMAT = /\A(\d+)(s|m|h|d)\z/

    # Initializes new Configuration object with configuration for program instance
    # @param opts = {} [Hash] Hash with configuration of interval and suppliers
    # 
    # @return [NilClass] nil
    def initialize(opts = {})
      @interval    = Helpers::TimeIntervalParser.parse opts.delete('interval')
      @options     = opts
    end

    # Load notifiers configuration
    # 
    # @return [NilClass] nil
    def load_notifiers
      options.each do |name, config|
        notifier = Factories::NotifiersFactory.create(name)
        notifier.load_configuration(config) unless notifier.nil?
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
feedbook-1.1.0 lib/feedbook/configuration.rb
feedbook-1.0.0 lib/feedbook/configuration.rb