Class: TermuxRubyApi::SubSystems::Location

Inherits:
Base
  • Object
show all
Defined in:
lib/termux_ruby_api/sub_systems/location.rb

Instance Attribute Summary

Attributes inherited from Base

#owner

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from TermuxRubyApi::SubSystems::Base

Instance Method Details

#get(provider: nil, request: nil) ⇒ Hash

Returns the current location

Parameters:

  • provider (:gps, :network, :passive) (defaults to: nil)

    :gps #=> Use GPS :network #=> Use mobile or Wifi network :passive #=> Use a low battery method

  • request (:once, :last, :updates) (defaults to: nil)

    :once #=> Return after the location is obtained :last #=> Return the last obtained location :updates #=> Send repeated updates as location is updated. Doesn’t work in current version.

Returns:

  • (Hash)


14
15
16
17
18
19
20
# File 'lib/termux_ruby_api/sub_systems/location.rb', line 14

def get(provider: nil, request: nil)
  args = owner.generate_args_list([['-p', provider],
                                   ['-r', request]
                                  ])
  res = owner.json_api_command('location', nil, *args)
  TermuxRubyApi::Utils::Xformer.xform(res, provider: :symbol)
end

#gps(request: nil) ⇒ Hash

Returns the current location, using GPS

Parameters:

  • request (:once, :last, :updates) (defaults to: nil)

    :once #=> Return after the location is obtained :last #=> Return the last obtained location :updates #=> Send repeated updates as location is updated. Doesn’t work in current version.

Returns:

  • (Hash)


25
26
27
# File 'lib/termux_ruby_api/sub_systems/location.rb', line 25

def gps(request: nil)
  get(provider: :gps, request: request)
end

#network(request: nil) ⇒ Hash

Returns the current location, using Mobile/Wifi network

Parameters:

  • request (:once, :last, :updates) (defaults to: nil)

    :once #=> Return after the location is obtained :last #=> Return the last obtained location :updates #=> Send repeated updates as location is updated. Doesn’t work in current version.

Returns:

  • (Hash)


32
33
34
# File 'lib/termux_ruby_api/sub_systems/location.rb', line 32

def network(request: nil)
  get(provider: :network, request: request)
end