Class: YouGotListed::Listings::SearchResponse
- Defined in:
- lib/you_got_listed/listings.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
-
#limit ⇒ Object
Returns the value of attribute limit.
Attributes inherited from Response
Instance Method Summary collapse
-
#initialize(response, client, limit = 20, raise_error = false) ⇒ SearchResponse
constructor
A new instance of SearchResponse.
- #mls_results? ⇒ Boolean
- #paginator ⇒ Object
- #properties ⇒ Object
Methods inherited from Response
Constructor Details
#initialize(response, client, limit = 20, raise_error = false) ⇒ SearchResponse
68 69 70 71 72 |
# File 'lib/you_got_listed/listings.rb', line 68 def initialize(response, client, limit = 20, raise_error = false) super(response, raise_error) self.limit = limit self.client = client end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class YouGotListed::Response
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
66 67 68 |
# File 'lib/you_got_listed/listings.rb', line 66 def client @client end |
#limit ⇒ Object
Returns the value of attribute limit.
66 67 68 |
# File 'lib/you_got_listed/listings.rb', line 66 def limit @limit end |
Instance Method Details
#mls_results? ⇒ Boolean
90 91 92 |
# File 'lib/you_got_listed/listings.rb', line 90 def mls_results? @has_mls_properties ||= properties.any?{|property| property.mls_listing?} end |
#paginator ⇒ Object
94 95 96 97 98 99 100 101 |
# File 'lib/you_got_listed/listings.rb', line 94 def paginator @paginator_cache ||= WillPaginate::Collection.create( (self.ygl_response.page_index ? self.ygl_response.page_index : 1), self.limit, (self.ygl_response.total ? self.ygl_response.total : properties.size)) do |pager| pager.replace properties end end |
#properties ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/you_got_listed/listings.rb', line 74 def properties @cached_properties ||= begin props = [] if self.success? && !self.ygl_response.listings.blank? if self.ygl_response.listings.listing.is_a?(Array) self.ygl_response.listings.listing.each do |listing| props << YouGotListed::Listing.new(listing, self.client) end else props << YouGotListed::Listing.new(self.ygl_response.listings.listing, self.client) end end props end end |