Class: Openapi3Parser::SourceInput::Url
- Inherits:
-
Openapi3Parser::SourceInput
- Object
- Openapi3Parser::SourceInput
- Openapi3Parser::SourceInput::Url
- Defined in:
- lib/openapi3_parser/source_input/url.rb
Overview
An input of a URL to an OpenAPI file
Defined Under Namespace
Classes: RelativeUrlDifference
Instance Attribute Summary collapse
-
#request_url ⇒ String
readonly
The URL that will be requested.
-
#resolved_url ⇒ String
readonly
The eventual URL of the file that was accessed, this may differ to the request_url in the case of redirects.
Attributes inherited from Openapi3Parser::SourceInput
Instance Method Summary collapse
- #==(other) ⇒ Boolean
-
#initialize(request_url) ⇒ Url
constructor
A new instance of Url.
-
#inspect ⇒ Object
return [String].
- #relative_to(source_input) ⇒ String
- #resolve_next(reference) ⇒ SourceInput
- #to_s ⇒ String
-
#url ⇒ Object
return [String].
Methods inherited from Openapi3Parser::SourceInput
Constructor Details
#initialize(request_url) ⇒ Url
Returns a new instance of Url.
18 19 20 21 |
# File 'lib/openapi3_parser/source_input/url.rb', line 18 def initialize(request_url) @request_url = request_url.to_s super() end |
Instance Attribute Details
#request_url ⇒ String (readonly)
The URL that will be requested
14 15 16 |
# File 'lib/openapi3_parser/source_input/url.rb', line 14 def request_url @request_url end |
#resolved_url ⇒ String (readonly)
The eventual URL of the file that was accessed, this may differ to the request_url in the case of redirects
14 15 16 |
# File 'lib/openapi3_parser/source_input/url.rb', line 14 def resolved_url @resolved_url end |
Instance Method Details
#==(other) ⇒ Boolean
33 34 35 36 37 38 |
# File 'lib/openapi3_parser/source_input/url.rb', line 33 def ==(other) return false unless other.instance_of?(self.class) [request_url, resolved_url].include?(other.request_url) || [request_url, resolved_url].include?(other.resolved_url) end |
#inspect ⇒ Object
return [String]
46 47 48 |
# File 'lib/openapi3_parser/source_input/url.rb', line 46 def inspect %{#{self.class.name}(url: #{url})} end |
#relative_to(source_input) ⇒ String
56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/openapi3_parser/source_input/url.rb', line 56 def relative_to(source_input) other_url = if source_input.respond_to?(:url) source_input.url elsif source_input.respond_to?(:base_url) source_input.base_url end return url unless other_url other_url ? RelativeUrlDifference.call(other_url, url) : url end |
#resolve_next(reference) ⇒ SourceInput
26 27 28 |
# File 'lib/openapi3_parser/source_input/url.rb', line 26 def resolve_next(reference) ResolveNext.call(reference, self, base_url: resolved_url) end |
#to_s ⇒ String
51 52 53 |
# File 'lib/openapi3_parser/source_input/url.rb', line 51 def to_s request_url end |
#url ⇒ Object
return [String]
41 42 43 |
# File 'lib/openapi3_parser/source_input/url.rb', line 41 def url resolved_url || request_url end |