Module: Appium::Core::Base::HasLocation Private

Included in:
Driver
Defined in:
lib/appium_lib_core/common/base/has_location.rb

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Instance Method Details

#location::Appium::Location

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Get the location of the device.

Examples:


driver.location #=> ::Appium::Location.new(10, 10, 10)


30
31
32
# File 'lib/appium_lib_core/common/base/has_location.rb', line 30

def location
  @bridge.location
end

#location=(location) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Set the location of the device.

Examples:


driver.location = ::Appium::Location.new(10, 10, 10)


42
43
44
45
46
47
48
# File 'lib/appium_lib_core/common/base/has_location.rb', line 42

def location=(location)
  unless location.is_a?(::Appium::Location)
    raise TypeError, "expected #{::Appium::Location}, got #{location.inspect}:#{location.class}"
  end

  @bridge.set_location location.latitude, location.longitude, location.altitude
end

#set_location(latitude, longitude, altitude, speed: nil, satellites: nil) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Set the location of the device.

Examples:


driver.location = ::Appium::Location.new(10, 10, 10)


65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/appium_lib_core/common/base/has_location.rb', line 65

def set_location(latitude, longitude, altitude, speed: nil, satellites: nil)
  if speed.nil? && satellites.nil?
    self.location = ::Appium::Location.new(Float(latitude), Float(longitude), Float(altitude))
  else
    loc = ::Appium::Location.new(Float(latitude), Float(longitude), Float(altitude))

    speed = Float(speed) unless speed.nil?
    satellites = Integer(satellites) unless satellites.nil?

    @bridge.set_location loc.latitude, loc.longitude, loc.altitude, speed: speed, satellites: satellites
  end
end