Class: WirisPlugin::IntegerTools
- Inherits:
-
Object
- Object
- WirisPlugin::IntegerTools
- Includes:
- Wiris
- Defined in:
- lib/com/wiris/util/type/IntegerTools.rb
Class Method Summary collapse
- .clamp(x, a, b) ⇒ Object
- .inRange(x, start, _end) ⇒ Object
- .isInt(x) ⇒ Object
- .max(x, y) ⇒ Object
- .min(x, y) ⇒ Object
- .sign(value) ⇒ Object
- .signBool(value) ⇒ Object
Instance Method Summary collapse
-
#initialize ⇒ IntegerTools
constructor
A new instance of IntegerTools.
Constructor Details
#initialize ⇒ IntegerTools
Returns a new instance of IntegerTools.
6 7 8 |
# File 'lib/com/wiris/util/type/IntegerTools.rb', line 6 def initialize() super() end |
Class Method Details
.clamp(x, a, b) ⇒ Object
21 22 23 |
# File 'lib/com/wiris/util/type/IntegerTools.rb', line 21 def self.clamp(x, a, b) return IntegerTools.min(IntegerTools.max(a,x),b) end |
.inRange(x, start, _end) ⇒ Object
24 25 26 |
# File 'lib/com/wiris/util/type/IntegerTools.rb', line 24 def self.inRange(x, start, _end) return (x >= start) && (x < _end) end |
.isInt(x) ⇒ Object
27 28 29 |
# File 'lib/com/wiris/util/type/IntegerTools.rb', line 27 def self.isInt(x) return (EReg.new("[\\+\\-]?\\d+",""))::match(x) end |
.max(x, y) ⇒ Object
15 16 17 |
# File 'lib/com/wiris/util/type/IntegerTools.rb', line 15 def self.max(x, y) return (x > y) ? x : y end |
.min(x, y) ⇒ Object
18 19 20 |
# File 'lib/com/wiris/util/type/IntegerTools.rb', line 18 def self.min(x, y) return (x < y) ? x : y end |
.sign(value) ⇒ Object
9 10 11 |
# File 'lib/com/wiris/util/type/IntegerTools.rb', line 9 def self.sign(value) return (value >= 0) ? 1 : -1 end |
.signBool(value) ⇒ Object
12 13 14 |
# File 'lib/com/wiris/util/type/IntegerTools.rb', line 12 def self.signBool(value) return value ? 1 : -1 end |