"Fossies" - the Fresh Open Source Software Archive 
Member "selenium-selenium-4.8.1/rb/lib/selenium/webdriver/common/interactions/pointer_event_properties.rb" (17 Feb 2023, 2475 Bytes) of package /linux/www/selenium-selenium-4.8.1.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Ruby source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
1 # frozen_string_literal: true
2
3 # Licensed to the Software Freedom Conservancy (SFC) under one
4 # or more contributor license agreements. See the NOTICE file
5 # distributed with this work for additional information
6 # regarding copyright ownership. The SFC licenses this file
7 # to you under the Apache License, Version 2.0 (the
8 # "License"); you may not use this file except in compliance
9 # with the License. You may obtain a copy of the License at
10 #
11 # http://www.apache.org/licenses/LICENSE-2.0
12 #
13 # Unless required by applicable law or agreed to in writing,
14 # software distributed under the License is distributed on an
15 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 # KIND, either express or implied. See the License for the
17 # specific language governing permissions and limitations
18 # under the License.
19
20 module Selenium
21 module WebDriver
22 module Interactions
23 module PointerEventProperties
24 VALID = {width: {'width' => {min: 0.0}},
25 height: {'height' => {min: 0.0}},
26 pressure: {'pressure' => {min: 0.0, max: 1.0}},
27 tangential_pressure: {'tangentialPressure' => {min: -1.0, max: 1.0}},
28 tilt_x: {'tiltX' => {min: -90, max: 90}},
29 tilt_y: {'tiltY' => {min: -90, max: 90}},
30 twist: {'twist' => {min: 0, max: 359}},
31 altitude_angle: {'altitudeAngle' => {min: 0.0, max: (Math::PI / 2)}},
32 azimuth_angle: {'azimuthAngle' => {min: 0.0, max: (Math::PI * 2)}}}.freeze
33
34 def process_opts
35 raise ArgumentError, "Unknown options found: #{@opts.inspect}" unless (@opts.keys - VALID.keys).empty?
36
37 VALID.each_with_object({}) do |(key, val), hash|
38 next unless @opts.key?(key)
39
40 name = val.keys.first
41 values = val.values.first
42 hash[name] = assert_number(@opts[key], values[:min], values[:max])
43 end
44 end
45
46 private
47
48 def assert_number(num, min, max = nil)
49 return if num.nil?
50
51 klass = min.is_a?(Integer) ? Integer : Numeric
52 raise TypeError, "#{num} is not a #{klass}" unless num.is_a?(klass)
53
54 raise ArgumentError, "#{num} is not greater than or equal to #{min}" if num < min
55
56 raise ArgumentError, "#{num} is not less than or equal to #{max}" if max && num > max
57
58 num
59 end
60 end # PointerEventProperties
61 end # Interactions
62 end # WebDriver
63 end # Selenium