Class: Location

Inherits:
Object show all
Defined in:
flow/location/location.rb

Instance Attribute Summary (collapse)

Class Method Summary (collapse)

Instance Method Summary (collapse)

Instance Attribute Details

- (Float) accuracy

Populated by the location monitoring service

Returns:

  • (Float)

    the current value of accuracy



16
17
18
# File 'flow/location/location.rb', line 16

def accuracy
  @accuracy
end

- (String) address

Populated after reverse geocoding a string

Returns:

  • (String)

    the current value of address



16
17
18
# File 'flow/location/location.rb', line 16

def address
  @address
end

- (Float) altitude

Populated by the location monitoring service

Returns:

  • (Float)

    the current value of altitude



16
17
18
# File 'flow/location/location.rb', line 16

def altitude
  @altitude
end

- (String) area

Populated after reverse geocoding a string

Returns:

  • (String)

    the current value of area



16
17
18
# File 'flow/location/location.rb', line 16

def area
  @area
end

- (String) country

Populated after reverse geocoding a string

Returns:

  • (String)

    the current value of country



16
17
18
# File 'flow/location/location.rb', line 16

def country
  @country
end

- (Float) latitude

Populated by the location monitoring service

Returns:

  • (Float)

    the current value of latitude



16
17
18
# File 'flow/location/location.rb', line 16

def latitude
  @latitude
end

- (String) localiton

Populated after reverse geocoding a string

Returns:

  • (String)

    the current value of localiton



16
17
18
# File 'flow/location/location.rb', line 16

def localiton
  @localiton
end

- (Object) locality

Returns the value of attribute locality



19
20
21
# File 'flow/location/location.rb', line 19

def locality
  @locality
end

- (Float) longitude

Populated by the location monitoring service

Returns:

  • (Float)

    the current value of longitude



16
17
18
# File 'flow/location/location.rb', line 16

def longitude
  @longitude
end

- (String) name

Populated after reverse geocoding a string

Returns:

  • (String)

    the current value of name



16
17
18
# File 'flow/location/location.rb', line 16

def name
  @name
end

- (String) postal_code

Populated after reverse geocoding a string

Returns:

  • (String)

    the current value of postal_code



16
17
18
# File 'flow/location/location.rb', line 16

def postal_code
  @postal_code
end

- (Float) speed

Populated by the location monitoring service

Returns:

  • (Float)

    the current value of speed



16
17
18
# File 'flow/location/location.rb', line 16

def speed
  @speed
end

- (String) sub_area

Populated after reverse geocoding a string

Returns:

  • (String)

    the current value of sub_area



16
17
18
# File 'flow/location/location.rb', line 16

def sub_area
  @sub_area
end

- (Time) time

Populated by the location monitoring service

Returns:

  • (Time)

    the current value of time



16
17
18
# File 'flow/location/location.rb', line 16

def time
  @time
end

Class Method Details

+ (Object) geocode(str, &block)

Reverse geocode a string

Examples:

Location.geocode('apple inc') do |location, err|
  if location
    puts location.address
  else
    puts err
  end
end


64
65
66
# File 'flow/location/location.rb', line 64

def self.geocode(str, &block)
  Location::Geocoder.new(str, block)
end

+ (Boolean) geocode_enabled?

Checks if the geocoder service is accessible

Returns:

  • (Boolean)


51
52
53
# File 'flow/location/location.rb', line 51

def self.geocode_enabled?
  Location::Geocoder.enabled?
end

+ (Monitor) monitor(options = {}, &block)

Starts monitoring for location updates.

Examples:

monitor = Location.monitor do |location, err|
  if location
    puts location.latitude, location.longitude
  else
    puts err
  end
end

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :distance_filter (Fixnum)

    The distance in meters from the previous location that should trigger a monitor update.

Returns:

  • (Monitor)


44
45
46
47
# File 'flow/location/location.rb', line 44

def self.monitor(options={}, &block)
  options[:distance_filter] ||= 0
  Location::Monitor.new(options, block)
end

+ (Boolean) monitor_enabled?

Checks if the location service is accessible

Examples:

Location.monitor_enabled? # => true or false

Returns:

  • (Boolean)


24
25
26
# File 'flow/location/location.rb', line 24

def self.monitor_enabled?
  Location::Monitor.enabled?
end

Instance Method Details

- (Object) geocode(&block)



68
69
70
# File 'flow/location/location.rb', line 68

def geocode(&block)
  Location::Geocoder.new(self, block)
end