module Selenium::WebDriver::Interactions::PointerEventProperties

Constants

VALID

Public Instance Methods

process_opts() click to toggle source
# File lib/selenium/webdriver/common/interactions/pointer_event_properties.rb, line 34
def process_opts
  raise ArgumentError, "Unknown options found: #{@opts.inspect}" unless (@opts.keys - VALID.keys).empty?

  VALID.each_with_object({}) do |(key, val), hash|
    next unless @opts.key?(key)

    name = val.keys.first
    values = val.values.first
    hash[name] = assert_number(@opts[key], values[:min], values[:max])
  end
end

Private Instance Methods

assert_number(num, min, max = nil) click to toggle source
# File lib/selenium/webdriver/common/interactions/pointer_event_properties.rb, line 48
def assert_number(num, min, max = nil)
  return if num.nil?

  klass = min.is_a?(Integer) ? Integer : Numeric
  raise TypeError, "#{num} is not a #{klass}" unless num.is_a?(klass)

  raise ArgumentError, "#{num} is not greater than or equal to #{min}" if num < min

  raise ArgumentError, "#{num} is not less than or equal to #{max}" if max && num > max

  num
end