Class: Swagger::Data::Url
- Inherits:
-
Object
- Object
- Swagger::Data::Url
- Defined in:
- lib/ruby-swagger/data/url.rb
Constant Summary collapse
- SCHEMES =
%w(http https)
Instance Attribute Summary collapse
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(url) ⇒ Url
constructor
A new instance of Url.
- #to_swagger ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(url) ⇒ Url
Returns a new instance of Url.
9 10 11 |
# File 'lib/ruby-swagger/data/url.rb', line 9 def initialize(url) @url = url end |
Instance Attribute Details
#url ⇒ Object (readonly)
Returns the value of attribute url.
7 8 9 |
# File 'lib/ruby-swagger/data/url.rb', line 7 def url @url end |
Instance Method Details
#to_swagger ⇒ Object
20 21 22 |
# File 'lib/ruby-swagger/data/url.rb', line 20 def to_swagger url end |
#valid? ⇒ Boolean
13 14 15 16 17 18 |
# File 'lib/ruby-swagger/data/url.rb', line 13 def valid? parsed = Addressable::URI.parse(url) or return false SCHEMES.include?(parsed.scheme) rescue Addressable::URI::InvalidURIError false end |