Class: PSD::Util
- Inherits:
-
Object
- Object
- PSD::Util
- Defined in:
- lib/psd/util.rb
Class Method Summary collapse
- .clamp(num, min, max) ⇒ Object
-
.pad2(i) ⇒ Object
Ensures value is a multiple of 2.
-
.pad4(i) ⇒ Object
Ensures value is a multiple of 4.
Class Method Details
.clamp(num, min, max) ⇒ Object
13 14 15 |
# File 'lib/psd/util.rb', line 13 def self.clamp(num, min, max) [min, num, max].sort[1] end |
.pad2(i) ⇒ Object
Ensures value is a multiple of 2
4 5 6 |
# File 'lib/psd/util.rb', line 4 def self.pad2(i) ((i + 1) / 2) * 2 end |
.pad4(i) ⇒ Object
Ensures value is a multiple of 4
9 10 11 |
# File 'lib/psd/util.rb', line 9 def self.pad4(i) i - (i.modulo(4)) + 3 end |