summaryrefslogtreecommitdiffhomepage
path: root/lib/axlsx/util/options_parser.rb
blob: 9b6d1766a1d1f240463de1f795fc3f7e92ac41f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
module Axlsx
  # This module defines a single method for parsing options in class
  # initializers.
  module OptionsParser

    # Parses an options hash by calling any defined method by the same
    # name of the key postfixed with an '='
    # @param [Hash] options Options to parse.
    def parse_options(options={})
      options.each do |key, value|
        key = :"#{key}="
        self.send(key, value) if !value.nil? && self.respond_to?(key)
      end
    end
  end
end