33 lines
654 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2020-08-24 23:51:48 +02:00
# Class corresponding to the `url` stanza.
#
# @api private
class URL
ATTRIBUTES = [
:using,
:tag, :branch, :revisions, :revision,
:trust_cert, :cookies, :referer, :user_agent,
:data
].freeze
2020-08-24 23:51:48 +02:00
private_constant :ATTRIBUTES
2016-08-18 22:11:42 +03:00
2020-07-07 11:29:33 +01:00
attr_reader :uri, :specs, *ATTRIBUTES
2016-08-18 22:11:42 +03:00
extend Forwardable
def_delegators :uri, :path, :scheme, :to_s
2016-08-18 22:11:42 +03:00
def initialize(uri, **options)
@uri = URI(uri)
@user_agent = :default
ATTRIBUTES.each do |attribute|
next unless options.key?(attribute)
2018-09-17 02:45:00 +02:00
instance_variable_set("@#{attribute}", options[attribute])
2016-09-24 13:52:43 +02:00
end
@specs = options
2016-08-18 22:11:42 +03:00
end
end