Class: Zoopla::ZedIndex

Inherits:
API
  • Object
show all
Defined in:
lib/zoopla/zed_index.rb

Instance Method Summary collapse

Methods inherited from API

#actual_location, #initialize, #reset!

Constructor Details

This class inherits a constructor from Zoopla::API

Instance Method Details

#in(location) ⇒ ZedIndex

Defines the search area. All possible params are described at developer.zoopla.com/docs/

Parameters:

  • Location (Hash)

    hash

Returns:



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/zoopla/zed_index.rb', line 8

def in(location)
  check_output_type location
  @request.merge! location
  reply = fetch_data(@request)
  fields = %w(area_url zed_index zed_index_3month zed_index_6month zed_index_1year zed_index_2year zed_index_3year zed_index_4year zed_index_5year)
  filtered = fields.inject({:latest => reply["zed_index"].to_i}) do |result, field|
    reply[field] = reply[field].to_i if field =~ /zed_index/ && reply[field]
    result[field] = reply[field]
    result
  end
  Hashie::Mash.new.update filtered
end