summaryrefslogtreecommitdiffhomepage
path: root/lib/axlsx/util/options_parser.rb
blob: 73faa224866e56cf61fd8313ffdaad9825a69daf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# frozen_string_literal: true

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}="
        send(key, value) if !value.nil? && respond_to?(key)
      end
    end
  end
end