Module: TipsanityMerchantExtractor::UrlFormatter
- Included in:
- AttributeExtractor
- Defined in:
- lib/tipsanity_merchant_extractor/url_formatter.rb
Instance Method Summary collapse
Instance Method Details
#format_url(url) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/tipsanity_merchant_extractor/url_formatter.rb', line 4 def format_url url URI.unescape url if url.to_s !~ url_regexp && "http://#{url}" =~ url_regexp "http://#{url.gsub(/\A[[:punct:]]*/,'')}" else url end end |
#url_regexp ⇒ Object
13 14 15 |
# File 'lib/tipsanity_merchant_extractor/url_formatter.rb', line 13 def url_regexp /http:|https:/ #[http:|https:] means that any of the charactor inside [] is matching. end |
#valid_url(url) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/tipsanity_merchant_extractor/url_formatter.rb', line 17 def valid_url url if url =~ url_regexp true else false end end |