Module: Nineflats::Helpers

Defined in:
lib/nineflats-api/helpers.rb

Class Method Summary collapse

Class Method Details

.get_data(url) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/nineflats-api/helpers.rb', line 6

def self.get_data(url)
  data = ""
  begin
    open(url) do |f| 
      data = JSON.parse(f.read)
    end
  rescue => e
    data = "Something went wrong: #{e} --- This means either the data you requested is simply null, the data you entered was wrong, or the API call is broken."
  end
  data
end

.pretty_print(data) ⇒ Object



18
19
20
# File 'lib/nineflats-api/helpers.rb', line 18

def self.pretty_print(data)
  self.ruby_to_html(nil, data) + "</html>"
end