class RailsParseHead::Fetch

Constants

CONTENT_TYPES

Public Class Methods

new(url, options = {}) click to toggle source
# File lib/rails_parse_head/fetch.rb, line 7
def initialize(url, options = {})
  @html = document(request(url, options))
end

Private Instance Methods

content_type_valid?(content_type) click to toggle source
# File lib/rails_parse_head/fetch.rb, line 19
def content_type_valid?(content_type)
  CONTENT_TYPES.include?(content_type)
end
request(url, options = {}) click to toggle source
# File lib/rails_parse_head/fetch.rb, line 13
def request(url, options = {})
  response = HTTP.get(url, options)
  return unless content_type_valid?(response.mime_type)
  response.body.to_s
end