Module: PSD::Util
Instance Method Summary collapse
- #clamp(num, min, max) ⇒ Object
- #pad2(i) ⇒ Object
-
#pad4(i) ⇒ Object
Ensures value is a multiple of 4.
Instance Method Details
#clamp(num, min, max) ⇒ Object
14 15 16 17 18 |
# File 'lib/psd/util.rb', line 14 def clamp(num, min, max) return max if num > max return min if num < min num end |
#pad2(i) ⇒ Object
5 6 7 |
# File 'lib/psd/util.rb', line 5 def pad2(i) (i + 1) & ~0x01 end |
#pad4(i) ⇒ Object
Ensures value is a multiple of 4
10 11 12 |
# File 'lib/psd/util.rb', line 10 def pad4(i) ((i + 4) & ~0x03) - 1 end |