summaryrefslogtreecommitdiffhomepage
path: root/lib/axlsx/util/options_parser.rb
blob: 01a1b29b57a8c7d44a14005ee0d893de4d5f4099 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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