Class: Foxynews::Parser

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
app/services/foxynews/parser.rb

Class Method Summary collapse

Class Method Details

.data(end_of_path = '', options = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/services/foxynews/parser.rb', line 9

def data(end_of_path = '', options = {})
  if Rails.env.test?

    end_of_path.gsub!('/', '_')
    begin
      file = File.read("../dummy_responses/pressrooms_id#{end_of_path}")
    rescue
      return {}
    else
      return JSON.parse file
    end
  else
    http_obj = get(end_of_path, options)
    return http_obj
  end
end