Class: Reporter::Record::Response::Location

Inherits:
Location show all
Includes:
BaseModule
Defined in:
lib/reporter/record/response/location.rb

Overview

Public: Represents a response to a question with a location

-based answer.

Call #location to get the Reporter::Record::Location object representing the location.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from BaseModule

#question_prompt

Methods inherited from Location

#course, #horizontal_accuracy, #latitude, #longitude, #speed, #timestamp, #vertical_accuracy

Constructor Details

#initialize(data = Hash.new) ⇒ Location

Public: Initialize a new Location Record from a data hash.

data - A Hash mapping String field names to their values

(optional; defaults to an empty hash)

25
26
27
28
29
30
# File 'lib/reporter/record/response/location.rb', line 25

def initialize(data = Hash.new)
  location = data["locationResponse"] || Hash.new
  @data = location["location"]
  @text = location["text"]
  @foursquare_venue_id = location["foursquareVenueId"]
end

Instance Attribute Details

#foursquare_venue_idObject (readonly)

Public: Represents the Foursquare venue ID for this location.


19
20
21
# File 'lib/reporter/record/response/location.rb', line 19

def foursquare_venue_id
  @foursquare_venue_id
end

#textObject (readonly)

Public: Represents the text entered naming the location.


16
17
18
# File 'lib/reporter/record/response/location.rb', line 16

def text
  @text
end

Instance Method Details

#==(other_record) ⇒ Object Also known as: eql?

Public: Determines if two records are equal.

Returns true if the records are equal, otherwise returns

false.

43
44
45
46
47
# File 'lib/reporter/record/response/location.rb', line 43

def ==(other_record)
  super(other_record) &&
    other_record.text == @text &&
    other_record.foursquare_venue_id == @foursquare_venue_id
end

#hashObject

Public: Retrieves the hash for this record.

Returns the hash.


35
36
37
# File 'lib/reporter/record/response/location.rb', line 35

def hash
  [@data, @text, @foursquare_venue_id, self.class].hash
end