Class: Orthotypo::Analyzer

Inherits:
Object
  • Object
show all
Defined in:
lib/orthotypo/analyzer.rb

Class Method Summary collapse

Class Method Details

.email?(string) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/orthotypo/analyzer.rb', line 11

def self.email?(string)
  string =~ /\A#{URI::MailTo::EMAIL_REGEXP}\z/ ? true : false
end

.precious?(string) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/orthotypo/analyzer.rb', line 15

def self.precious?(string)
  email?(string) || url?(string)
end

.url?(string) ⇒ Boolean

Returns:

  • (Boolean)


4
5
6
7
8
9
# File 'lib/orthotypo/analyzer.rb', line 4

def self.url?(string)
  uri = URI.parse(string)
  uri.class != URI::Generic
rescue URI::InvalidURIError
  false
end