Module: Applitools::ArgumentGuard
- Extended by:
- ArgumentGuard
- Included in:
- ArgumentGuard
- Defined in:
- lib/applitools/core/argument_guard.rb
Instance Method Summary collapse
- #greater_than_or_equal_to_zero(param, param_name) ⇒ Object
- #greater_than_zero(param, param_name) ⇒ Object
- #hash(param, param_name, required_fields = []) ⇒ Object
- #is_a?(param, param_name, klass) ⇒ Boolean
- #not_nil(param, param_name) ⇒ Object
- #raise_argument_error(error) ⇒ Object
Instance Method Details
#greater_than_or_equal_to_zero(param, param_name) ⇒ Object
21 22 23 |
# File 'lib/applitools/core/argument_guard.rb', line 21 def greater_than_or_equal_to_zero(param, param_name) raise Applitools::EyesIllegalArgument.new "#{param_name} < 0" if 0 > param end |
#greater_than_zero(param, param_name) ⇒ Object
25 26 27 |
# File 'lib/applitools/core/argument_guard.rb', line 25 def greater_than_zero(param, param_name) raise Applitools::EyesIllegalArgument.new "#{param_name} <= 0" if 0 >= param end |
#hash(param, param_name, required_fields = []) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/applitools/core/argument_guard.rb', line 8 def hash(param, param_name, required_fields = []) if param.is_a? Hash missed_keys = required_fields - param.keys = "Expected #{param_name} to include keys #{missed_keys.join ', '}" raise Applitools::EyesIllegalArgument.new if missed_keys.any? else = "#{param_name} expected to be a Hash" = required_fields.any? ? " containing keys #{required_fields.join(', ')}." : '.' << raise Applitools::EyesIllegalArgument.new end end |
#is_a?(param, param_name, klass) ⇒ Boolean
29 30 31 32 33 |
# File 'lib/applitools/core/argument_guard.rb', line 29 def is_a?(param, param_name, klass) return true if param.is_a? klass raise Applitools::EyesIllegalArgument.new "Expected #{param_name} to be" \ " instance of #{klass}" end |
#not_nil(param, param_name) ⇒ Object
4 5 6 |
# File 'lib/applitools/core/argument_guard.rb', line 4 def not_nil(param, param_name) raise Applitools::EyesIllegalArgument.new "#{param_name} is nil!" if param.nil? end |
#raise_argument_error(error) ⇒ Object
35 36 37 |
# File 'lib/applitools/core/argument_guard.rb', line 35 def raise_argument_error(error) raise Applitools::EyesIllegalArgument.new error end |