class SitraResponse

Public Class Methods

new() click to toggle source
# File lib/sitra_client/sitra_response.rb, line 7
def initialize
  @json_response = ''
  @response_hash = {}
end

Public Instance Methods

append_line(line) click to toggle source
# File lib/sitra_client/sitra_response.rb, line 12
def append_line(line)
  @json_response += line unless line.nil?
end
as_array(aspect = nil) click to toggle source
# File lib/sitra_client/sitra_response.rb, line 35
def as_array(aspect = nil)
  if as_hash[:objetsTouristiques].nil?
    results = []
  else
    results = as_hash[:objetsTouristiques].collect {|obj_hash| TouristicObject.new(obj_hash, aspect)}
  end
  results
end
as_hash() click to toggle source
# File lib/sitra_client/sitra_response.rb, line 24
def as_hash
  if @response_hash.empty?
    @response_hash = JSON.parse @json_response, :symbolize_names => true
  end
  @response_hash
end
as_raw_json() click to toggle source
# File lib/sitra_client/sitra_response.rb, line 31
def as_raw_json
  @json_response
end
results_count() click to toggle source
# File lib/sitra_client/sitra_response.rb, line 20
def results_count
  as_hash[:numFound]
end
returned_count() click to toggle source
# File lib/sitra_client/sitra_response.rb, line 16
def returned_count
  [as_hash[:query][:count], results_count - as_hash[:query][:first]].min
end