Class: UrlAttribute::NormalizedUrl

Inherits:
Url
  • Object
show all
Defined in:
lib/url_attribute/normalized_url.rb

Instance Attribute Summary

Attributes inherited from Url

#uri, #url

Instance Method Summary collapse

Methods inherited from Url

dump, load, #to_s, #valid?

Constructor Details

#initialize(url) ⇒ NormalizedUrl

Returns a new instance of NormalizedUrl.



3
4
5
6
7
8
9
10
11
# File 'lib/url_attribute/normalized_url.rb', line 3

def initialize(url)
  super

  if @uri && @uri.scheme.blank?
    @uri = URI.parse("http://#{url}")
    @url = @uri.to_s
  end
rescue URI::InvalidURIError
end