defmodule RotationalCipher do
  @doc """
  Given a plaintext and amount to shift by, return a rotated string.

  Example:
  iex> RotationalCipher.rotate("Attack at dawn", 13)
  "Nggnpx ng qnja"
  """
  @next_upper %{A: "B", B: "C", C => "D", D => "E", E => "F", }

  @spec rotate(text :: String.t(), shift :: integer) :: String.t()
  def rotate(text, shift) do
  	String.codepoints(text)
  	|> Enum.map(fn(x) -> rotate_upper(x, shift) end)
  	|> Enum.map(fn(x) -> rotate_lower(x, shift) end)
  	|> to_string
  end

  def rotate_upper(text, shift) do
  	# map(text, (fn x -> if(is_uppercase(x) do

  	# 	|> IO.chardata_to_string
  	# end))
  end

  def is_uppercase(letter) do
  	letter =~ ~r/^\p{Lu}$/u
  	end

  def rotate_lower(text, shift) do
  	String.to_charlist("łł")
  end 
end

