Class: WirisPlugin::UrlUtils
- Inherits:
-
Object
- Object
- WirisPlugin::UrlUtils
- Includes:
- Wiris
- Defined in:
- lib/com/wiris/util/type/UrlUtils.rb
Constant Summary collapse
- @@charCodeA =
Std::charCodeAt("A",0)
- @@charCodeZ =
Std::charCodeAt("Z",0)
- @@charCodea =
Std::charCodeAt("a",0)
- @@charCodez =
Std::charCodeAt("z",0)
- @@charCode0 =
Std::charCodeAt("0",0)
- @@charCode9 =
Std::charCodeAt("9",0)
Class Method Summary collapse
- .charCode0 ⇒ Object
- .charCode0=(charCode0) ⇒ Object
- .charCode9 ⇒ Object
- .charCode9=(charCode9) ⇒ Object
- .charCodeA ⇒ Object
- .charCodea ⇒ Object
- .charCodeA=(charCodeA) ⇒ Object
- .charCodea=(charCodea) ⇒ Object
- .charCodez ⇒ Object
- .charCodeZ ⇒ Object
- .charCodeZ=(charCodeZ) ⇒ Object
- .charCodez=(charCodez) ⇒ Object
- .isAllowed(c) ⇒ Object
- .urlComponentEncode(uriComponent) ⇒ Object
Instance Method Summary collapse
-
#initialize ⇒ UrlUtils
constructor
A new instance of UrlUtils.
Constructor Details
#initialize ⇒ UrlUtils
Returns a new instance of UrlUtils.
6 7 8 |
# File 'lib/com/wiris/util/type/UrlUtils.rb', line 6 def initialize() super() end |
Class Method Details
.charCode0 ⇒ Object
38 39 40 |
# File 'lib/com/wiris/util/type/UrlUtils.rb', line 38 def self.charCode0 @@charCode0 end |
.charCode0=(charCode0) ⇒ Object
41 42 43 |
# File 'lib/com/wiris/util/type/UrlUtils.rb', line 41 def self.charCode0=(charCode0) @@charCode0 = charCode0 end |
.charCode9 ⇒ Object
45 46 47 |
# File 'lib/com/wiris/util/type/UrlUtils.rb', line 45 def self.charCode9 @@charCode9 end |
.charCode9=(charCode9) ⇒ Object
48 49 50 |
# File 'lib/com/wiris/util/type/UrlUtils.rb', line 48 def self.charCode9=(charCode9) @@charCode9 = charCode9 end |
.charCodeA ⇒ Object
10 11 12 |
# File 'lib/com/wiris/util/type/UrlUtils.rb', line 10 def self.charCodeA @@charCodeA end |
.charCodea ⇒ Object
24 25 26 |
# File 'lib/com/wiris/util/type/UrlUtils.rb', line 24 def self.charCodea @@charCodea end |
.charCodeA=(charCodeA) ⇒ Object
13 14 15 |
# File 'lib/com/wiris/util/type/UrlUtils.rb', line 13 def self.charCodeA=(charCodeA) @@charCodeA = charCodeA end |
.charCodea=(charCodea) ⇒ Object
27 28 29 |
# File 'lib/com/wiris/util/type/UrlUtils.rb', line 27 def self.charCodea=(charCodea) @@charCodea = charCodea end |
.charCodez ⇒ Object
31 32 33 |
# File 'lib/com/wiris/util/type/UrlUtils.rb', line 31 def self.charCodez @@charCodez end |
.charCodeZ ⇒ Object
17 18 19 |
# File 'lib/com/wiris/util/type/UrlUtils.rb', line 17 def self.charCodeZ @@charCodeZ end |
.charCodeZ=(charCodeZ) ⇒ Object
20 21 22 |
# File 'lib/com/wiris/util/type/UrlUtils.rb', line 20 def self.charCodeZ=(charCodeZ) @@charCodeZ = charCodeZ end |
.charCodez=(charCodez) ⇒ Object
34 35 36 |
# File 'lib/com/wiris/util/type/UrlUtils.rb', line 34 def self.charCodez=(charCodez) @@charCodez = charCodez end |
.isAllowed(c) ⇒ Object
51 52 53 54 |
# File 'lib/com/wiris/util/type/UrlUtils.rb', line 51 def self.isAllowed(c) allowedChars = "-_.!~*\'()"::indexOf(Std::fromCharCode(c)) != -1 return ((((c >= @@charCodeA) && (c <= @@charCodeZ)) || ((c >= @@charCodea) && (c <= @@charCodez))) || ((c >= @@charCode0) && (c <= @@charCode9))) || allowedChars end |
.urlComponentEncode(uriComponent) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/com/wiris/util/type/UrlUtils.rb', line 55 def self.urlComponentEncode(uriComponent) sb = StringBuf.new() buf = Bytes::ofData(Utf8::toBytes(uriComponent)) for i in 0..buf::length() - 1 b = buf::get(i)&255 if UrlUtils.isAllowed(b) sb::add(Std::fromCharCode(b)) else sb::add("%") sb::add(StringTools::hex(b,2)) end i+=1 end return sb::toString() end |