Class: Ubi::Memoria::Site

Inherits:
Base
  • Object
show all
Defined in:
lib/ubi/memorias/site.rb

Overview

A site, url and title?

Instance Attribute Summary

Attributes inherited from Base

#hint, #opts, #text

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

==, extract_text, inherited, #initialize, name, parse, parse!, #parser, plural, #to_s

Constructor Details

This class inherits a constructor from Ubi::Memoria::Base

Class Method Details

.keyObject



35
36
37
# File 'lib/ubi/memorias/site.rb', line 35

def key
  :site
end

.regex(_hint) ⇒ Object

Regex only for *.tld %r?)+)(?:/|.) (?:??)[a-zA-Z0-9-._?,'/\+&%$#=~]+

%rhref="a-zA-Z0-9\-\.">https?://)?(?:www.)?+.[a-zA-Z]{2,3}

((?:https://)|(?:http://)|(?:www.))?(. [a-zA-Z]{2,3}(?:??)[a-zA-Z0-9-._?,'/\&%$#=~]+)

www.regexr.com/3bkne /([(https?)://(www.)?a-zA-Z0-9:@%._+~#=]2,256.[a-z]2,6b (?:[-a-zA-Z0-9@:%_+.~#?&//?=]*))/

without @



27
28
29
30
31
32
33
# File 'lib/ubi/memorias/site.rb', line 27

def regex(_hint)
  %r{
   ([(https?)://(www\.)?a-zA-Z0-9:%\._\+~#=]{2,256}
   \.[a-z]{2,6}\b
   (?:[-a-zA-Z0-9@:%_\+.~#?&//?=]*))
  }x
end

Instance Method Details

#formatObject

Prefix http:// if there isn’t one defined



7
8
9
# File 'lib/ubi/memorias/site.rb', line 7

def format
  text =~ /^http/ ? text : "http://#{text}"
end