Sha256: 15e9a109fe28582c9239cb9643813778051c2c3d48a7a8785bbde454eda652ba

Contents?: true

Size: 540 Bytes

Versions: 2

Compression:

Stored size: 540 Bytes

Contents

require_relative 'base'

module Semi::Variables
  class Url < Semi::Variables::Base

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

    def validate
      self.validate(@value)
    end
    
    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
    
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
semi-0.3.1 lib/semi/variables/url.rb
semi-0.3.0 lib/semi/variables/url.rb