Class: Rippersnapper::Url
- Inherits:
-
Object
- Object
- Rippersnapper::Url
- Defined in:
- lib/rippersnapper/url.rb
Instance Method Summary collapse
-
#domain ⇒ Object
Pass through to DomainParser object DomainParser#domain see here for more details.
-
#host ⇒ String
convenience method to access URI host See #uri for more information.
-
#initialize(url) ⇒ Url
constructor
A new instance of Url.
-
#path ⇒ String
construct path from uri query and uri path.
-
#port ⇒ String
convenience method to access URI port See #uri for more information.
-
#scheme ⇒ String
convenience method to access URI scheme See #uri for more information.
-
#subdomain ⇒ Object
Pass through to DomainParser object DomainParser#subdomain see here for more details.
-
#suffix ⇒ Object
Pass through to DomainParser object DomainParser#suffix see here for more details.
-
#uri ⇒ URI
URI object from url passed to initialize.
-
#url ⇒ String
If url has a scheme use it if not assume http.
Constructor Details
#initialize(url) ⇒ Url
Returns a new instance of Url.
7 8 9 |
# File 'lib/rippersnapper/url.rb', line 7 def initialize url @url = url.to_s end |
Instance Method Details
#domain ⇒ Object
Pass through to DomainParser object DomainParser#domain see here for more details
40 41 42 |
# File 'lib/rippersnapper/url.rb', line 40 def domain parsed_domain.domain end |
#host ⇒ String
convenience method to access URI host See #uri for more information
64 65 66 |
# File 'lib/rippersnapper/url.rb', line 64 def host uri.host || "" end |
#path ⇒ String
construct path from uri query and uri path
70 71 72 73 |
# File 'lib/rippersnapper/url.rb', line 70 def path return "#{uri.path}?#{uri.query}" if uri.query uri.path end |
#port ⇒ String
convenience method to access URI port See #uri for more information
80 81 82 |
# File 'lib/rippersnapper/url.rb', line 80 def port uri.port end |
#scheme ⇒ String
convenience method to access URI scheme See #uri for more information
55 56 57 |
# File 'lib/rippersnapper/url.rb', line 55 def scheme uri.scheme || "" end |
#subdomain ⇒ Object
Pass through to DomainParser object DomainParser#subdomain see here for more details
46 47 48 |
# File 'lib/rippersnapper/url.rb', line 46 def subdomain parsed_domain.subdomain end |
#suffix ⇒ Object
Pass through to DomainParser object DomainParser#suffix see here for more details
34 35 36 |
# File 'lib/rippersnapper/url.rb', line 34 def suffix parsed_domain.suffix end |
#uri ⇒ URI
URI object from url passed to initialize
19 20 21 |
# File 'lib/rippersnapper/url.rb', line 19 def uri @uri ||= URI.parse url end |
#url ⇒ String
If url has a scheme use it if not assume http
25 26 27 28 29 30 |
# File 'lib/rippersnapper/url.rb', line 25 def url return @url if @url =~ /:\/\// || @url.empty? # sensible default "http://#{@url}" end |