Class: OptionsChecker

Inherits:
Object
  • Object
show all
Defined in:
lib/options_checker.rb

Overview

module OptionsChecker

VERSION = '0.0.1'

end

Class Method Summary collapse

Class Method Details

.check(options, mandatories) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/options_checker.rb', line 9

def self.check options, mandatories
  raise "options argument must be a Hash" unless options.is_a?(Hash)
  raise "mandatories argument must be an Array" unless mandatories.is_a?(Array)

  for mandatory in mandatories
    raise "Argument #{mandatory} cannot be nil. You provided: #{options.inspect}" if options[mandatory].nil?
  end

  return options
end