lib/page_rankr/site.rb in PageRankr-2.0.4 vs lib/page_rankr/site.rb in PageRankr-3.0.0

- old
+ new

@@ -1,11 +1,9 @@ require 'public_suffix_service' require 'delegate' module PageRankr - class DomainInvalid < StandardError; end - class Site < DelegateClass(PublicSuffixService::Domain) def initialize(site) super(PublicSuffixService.parse(clean(site))) valid? or raise DomainInvalid, "The domain provided is invalid." end @@ -14,8 +12,14 @@ def clean(site) site = site.split("://").last # remove protocol site = site.split("/").first # remove path site.split("?").first # remove params + end + end + + class << self + def Site(site) + site.respond_to?(:domain) ? site : Site.new(site) end end end \ No newline at end of file