Class: Html2rss::RequestService::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/html2rss/request_service/context.rb

Overview

Holds information needed to send requests to websites. To be passed down to the RequestService’s strategies.

Constant Summary collapse

SUPPORTED_URL_SCHEMES =
%w[http https].to_set.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url:, headers: {}) ⇒ Context

Returns a new instance of Context.

Parameters:

  • url (String, Addressable::URI)

    the URL to request

  • headers (Hash) (defaults to: {})

    HTTP request headers



16
17
18
19
20
21
# File 'lib/html2rss/request_service/context.rb', line 16

def initialize(url:, headers: {})
  @url = Addressable::URI.parse(url)
  assert_valid_url!

  @headers = headers
end

Instance Attribute Details

#headersHash (readonly)

Returns the HTTP request headers.

Returns:

  • (Hash)

    the HTTP request headers



27
28
29
# File 'lib/html2rss/request_service/context.rb', line 27

def headers
  @headers
end

#urlAddressable::URI (readonly)

Returns the parsed URL.

Returns:

  • (Addressable::URI)

    the parsed URL



24
25
26
# File 'lib/html2rss/request_service/context.rb', line 24

def url
  @url
end