Class: Ciphr::Functions::URL::UrlEncoding
- Inherits:
-
InvertibleFunction
- Object
- Function
- InvertibleFunction
- Ciphr::Functions::URL::UrlEncoding
- Defined in:
- lib/ciphr/functions/url.rb
Overview
TODO: differentiate between URL and CGI encoding (with ‘+’ char)
Instance Attribute Summary
Attributes inherited from InvertibleFunction
Attributes inherited from Function
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from InvertibleFunction
Methods inherited from Function
aligned, inherited, #initialize, invertable?, #prepend, #read
Constructor Details
This class inherits a constructor from Ciphr::Functions::Function
Class Method Details
.params ⇒ Object
34 35 36 |
# File 'lib/ciphr/functions/url.rb', line 34 def self.params [:input] end |
.variants ⇒ Object
28 29 30 31 32 |
# File 'lib/ciphr/functions/url.rb', line 28 def self.variants [ [['url','uri','cgi'],{}] ] end |
Instance Method Details
#apply ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/ciphr/functions/url.rb', line 6 def apply input = @args[0] if !invert Proc.new do chunk = input.read(1) chunk && CGI.escape(chunk) end else Proc.new do chunk = input.read(1) if (chunk == "%") chunk += input.read(2) chunk && CGI.unescape(chunk) elsif chunk == '+' ' ' else chunk end end end end |