Class: WirisPlugin::StringParser
- Inherits:
-
Object
- Object
- WirisPlugin::StringParser
- Includes:
- Wiris
- Defined in:
- lib/com/wiris/util/json/StringParser.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#c ⇒ Object
Returns the value of attribute c.
-
#i ⇒ Object
Returns the value of attribute i.
-
#n ⇒ Object
Returns the value of attribute n.
-
#str ⇒ Object
Returns the value of attribute str.
Class Method Summary collapse
Instance Method Summary collapse
- #getPositionRepresentation ⇒ Object
- #init(str) ⇒ Object
-
#initialize ⇒ StringParser
constructor
A new instance of StringParser.
- #isHexDigit(c) ⇒ Object
- #nextSafeToken ⇒ Object
- #nextToken ⇒ Object
- #skipBlanks ⇒ Object
Constructor Details
#initialize ⇒ StringParser
Returns a new instance of StringParser.
11 12 13 |
# File 'lib/com/wiris/util/json/StringParser.rb', line 11 def initialize() super() end |
Instance Attribute Details
#c ⇒ Object
Returns the value of attribute c.
9 10 11 |
# File 'lib/com/wiris/util/json/StringParser.rb', line 9 def c @c end |
#i ⇒ Object
Returns the value of attribute i.
7 8 9 |
# File 'lib/com/wiris/util/json/StringParser.rb', line 7 def i @i end |
#n ⇒ Object
Returns the value of attribute n.
8 9 10 |
# File 'lib/com/wiris/util/json/StringParser.rb', line 8 def n @n end |
#str ⇒ Object
Returns the value of attribute str.
10 11 12 |
# File 'lib/com/wiris/util/json/StringParser.rb', line 10 def str @str end |
Class Method Details
.isBlank(c) ⇒ Object
39 40 41 |
# File 'lib/com/wiris/util/json/StringParser.rb', line 39 def self.isBlank(c) return ((((c == 32) || (c == 10)) || (c == 13)) || (c == 9)) || (c == 160) end |
Instance Method Details
#getPositionRepresentation ⇒ Object
42 43 44 45 46 47 |
# File 'lib/com/wiris/util/json/StringParser.rb', line 42 def getPositionRepresentation() i0 = WInteger::min(@i,@n) s0 = WInteger::max(0,@i - 20) e0 = WInteger::min(@n,@i + 20) return (("..." + Std::substr(@str,s0,i0 - s0).to_s) + " >>> . <<<") + Std::substr(@str,i0,e0).to_s end |
#init(str) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/com/wiris/util/json/StringParser.rb', line 14 def init(str) self.str = str @i = 0 @n = str::length() nextToken() end |
#isHexDigit(c) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/com/wiris/util/json/StringParser.rb', line 48 def isHexDigit(c) if (c >= 48) && (c <= 58) return true end if (c >= 97) && (c <= 102) return true end if (c >= 65) && (c <= 70) return true end return false end |
#nextSafeToken ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/com/wiris/util/json/StringParser.rb', line 31 def nextSafeToken() if @i < @n @c = Utf8::charCodeAt(Std::substr(@str,@i),0) @i += (Utf8::uchr(@c))::length() else @c = -1 end end |
#nextToken ⇒ Object
25 26 27 28 29 30 |
# File 'lib/com/wiris/util/json/StringParser.rb', line 25 def nextToken() if @c == -1 raise Exception,"End of string" end nextSafeToken() end |
#skipBlanks ⇒ Object
20 21 22 23 24 |
# File 'lib/com/wiris/util/json/StringParser.rb', line 20 def skipBlanks() while (@i < @n) && StringParser.isBlank(@c) nextToken() end end |