Module: RCL::URL
- Defined in:
- lib/rcl/url.rb
Class Method Summary collapse
Class Method Details
.decode(url) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/rcl/url.rb', line 18 def self.decode(url) raise ArgumentError, 'nil url' if url.nil? raise ArgumentError, 'invalid url' if url.class != String raise ArgumentError, 'empty url' if url.empty? URI::unescape(url) end |
.encode(url) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/rcl/url.rb', line 10 def self.encode(url) raise ArgumentError, 'nil url' if url.nil? raise ArgumentError, 'invalid url' if url.class != String raise ArgumentError, 'empty url' if url.empty? URI::escape(url, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]")) end |
.encoded?(url) ⇒ Boolean
26 27 28 29 30 31 32 |
# File 'lib/rcl/url.rb', line 26 def self.encoded?(url) raise ArgumentError, 'nil url' if url.nil? raise ArgumentError, 'invalid url' if url.class != String raise ArgumentError, 'empty url' if url.empty? return (url =~ /%/) ? true : false end |