Class: Semi::Variables::Url

Inherits:
Base
  • Object
show all
Defined in:
lib/semi/variables/url.rb

Constant Summary collapse

@@url_re =
Regexp.new('^(?<proto>https?|ftp|file):\/\/(?<host>[a-z\.0-9\-_]+)?(?::(?<port>\d{1,5}))?\/?(?<path>.*?)\/?(?<file>[^\/\?]+)?(?:\?(?<params>.*?))?$', Regexp::IGNORECASE)

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize, #set, #to_s

Constructor Details

This class inherits a constructor from Semi::Variables::Base

Class Method Details

.validate(value) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/semi/variables/url.rb', line 12

def self.validate(value)
  if ['String', 'Semi::Variables::Url'].include? value.class.to_s
    if @@url_re.match(value)
      return true
    end
  end
  false
end

Instance Method Details

#validateObject



8
9
10
# File 'lib/semi/variables/url.rb', line 8

def validate
  self.validate(@value)
end