Class: WirisPlugin::WInteger
- Inherits:
-
Object
- Object
- WirisPlugin::WInteger
- Includes:
- Wiris
- Defined in:
- lib/com/wiris/common/WInteger.rb
Class Method Summary collapse
- .isInteger(str) ⇒ Object
- .max(x, y) ⇒ Object
- .min(x, y) ⇒ Object
- .parseHex(str) ⇒ Object
- .toHex(x, digits) ⇒ Object
Instance Method Summary collapse
-
#initialize ⇒ WInteger
constructor
A new instance of WInteger.
Constructor Details
#initialize ⇒ WInteger
Returns a new instance of WInteger.
6 7 8 |
# File 'lib/com/wiris/common/WInteger.rb', line 6 def initialize() super() end |
Class Method Details
.isInteger(str) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/com/wiris/common/WInteger.rb', line 37 def self.isInteger(str) str = StringTools::trim(str) i = 0 n = str::length() if str::startsWith("-") i+=1 end if str::startsWith("+") i+=1 end while i < n c = Std::charCodeAt(str,i) if (c < 48) || (c > 57) return false end i+=1 end return true end |
.max(x, y) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/com/wiris/common/WInteger.rb', line 9 def self.max(x, y) if x > y return x end return y end |
.min(x, y) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/com/wiris/common/WInteger.rb', line 15 def self.min(x, y) if x < y return x end return y end |
.parseHex(str) ⇒ Object
34 35 36 |
# File 'lib/com/wiris/common/WInteger.rb', line 34 def self.parseHex(str) return Std::parseInt("0x" + str) end |
.toHex(x, digits) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/com/wiris/common/WInteger.rb', line 21 def self.toHex(x, digits) s = "" while (x != 0) && ((digits) > 0) digits-=1 d = x&15 s = Std::fromCharCode(d + (d >= 10 ? 55 : 48)).to_s + s x = x >> 4 end while (digits-=1) > 0 s = "0" + s end return s end |