Module: Wikilink::Converter::ArgumentExtractor

Included in:
Wikilink::Converter, Site
Defined in:
lib/wikilink/converter/utils.rb

Instance Method Summary collapse

Instance Method Details

#extract_arguments(*args) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/wikilink/converter/utils.rb', line 7

def extract_arguments(*args)
  options = {}
  options = args.pop if args.last.is_a?(Hash)
  name = args.shift

  if name.nil? || name.is_a?(String) || name.is_a?(Symbol)
    name = name.to_s
    converter = args.shift
  else
    converter = name
    name = nil
  end

  throw ArgumentError, "too many arguments" unless args.empty?

  [name, converter, options]
end