Rotates self of x

NOTE: works on letters only

assert 'x'.rot(6) == 'd'
assert 'T'.rot(15) == 'I'
assert '1'.rot(10) == '1'
assert '$'.rot(10) == '$'
assert 'z'.rot(-2) == 'x'

Property definitions

crypto :: basic_ciphers $ Char :: rot
	# Rotates self of `x`
	#
	# NOTE: works on letters only
	#
	#     assert 'x'.rot(6) == 'd'
	#     assert 'T'.rot(15) == 'I'
	#     assert '1'.rot(10) == '1'
	#     assert '$'.rot(10) == '$'
	#     assert 'z'.rot(-2) == 'x'
	fun rot(x: Int): Char do
		if not is_letter then return self
		x = x % 26
		if x < 0 then x += 26
		var up = false
		var val = code_point
		if is_upper then
			up = true
			val += 32
		end
		val += x
		if val > 122 then val -= 26
		if up then val -= 32
		return val.code_point
	end
lib/crypto/basic_ciphers.nit:19,2--42,4