Class: Factual::PlacesResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/factual/places_response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ PlacesResponse

Returns a new instance of PlacesResponse.



6
7
8
# File 'lib/factual/places_response.rb', line 6

def initialize(response)
    @body = rash_response(response)
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



4
5
6
# File 'lib/factual/places_response.rb', line 4

def body
  @body
end

Instance Method Details

#dataObject



42
43
44
45
46
# File 'lib/factual/places_response.rb', line 42

def data
    if !@body.response.data.blank?
        @body.response.data
    end
end

#error?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/factual/places_response.rb', line 22

def error?
    @body.status == "error"
end

#error_messageObject



26
27
28
# File 'lib/factual/places_response.rb', line 26

def error_message
   @body.message if error?
end

#error_typeObject



30
31
32
# File 'lib/factual/places_response.rb', line 30

def error_type
   @body.error_type if error?
end

#included_rowsObject



34
35
36
# File 'lib/factual/places_response.rb', line 34

def included_rows
    @body.included_rows
end

#resolved?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/factual/places_response.rb', line 48

def resolved?
    success? && data.present? && data[0].resolved
end

#resolved_venueObject



52
53
54
# File 'lib/factual/places_response.rb', line 52

def resolved_venue
    data[0] if resolved?
end

#statusObject



14
15
16
# File 'lib/factual/places_response.rb', line 14

def status
    @body.status
end

#success?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/factual/places_response.rb', line 18

def success?
    @body.status == "ok" 
end

#total_rowsObject



38
39
40
# File 'lib/factual/places_response.rb', line 38

def total_rows
    @body.total_row_count
end

#versionObject



10
11
12
# File 'lib/factual/places_response.rb', line 10

def version
    @body.version
end