Class: Fletcher::Data

Inherits:
Object
  • Object
show all
Defined in:
lib/fletcher/data.rb

Overview

This class is responsible for fetching and parsing data.

Class Method Summary collapse

Class Method Details

.read(url, options = {}) ⇒ Object

Get read url and get data object



8
9
10
11
12
13
14
15
16
17
# File 'lib/fletcher/data.rb', line 8

def self.read(url, options = {})
  response = open(url, "User-Agent" => Fletcher::USER_AGENT)
  doc = ::Nokogiri::HTML(response.read)
  
  # Save contents of URL/Remote File for debugging
  # response.rewind
  # last_response_file = File.expand_path(File.join("..", "..", "last_response"), File.dirname(__FILE__))        
  # File.new(last_response_file, "w+").write(response.read)
  return doc
end