Q:

Ruby Cipher If statements not working

I was wondering if someone could correct the things I have done wrong in my code. I am attempting to make a 1 time pad with Ruby. 
Every time I run the code, and provide input to be put into the cipher, it returns a nil or a doesn't return the exact amount of characters (I enter in a 4 character word and it returns 2 characters). 
h = {}
v = 0

('A'..'Z').each do |c|
  v+=1
  h[c] = v
end 

puts "Provide Input:"
input = gets
input.downcase!

if input.include?("a") 
    n = h["A"] + rand(26)
    puts h.index(n) 
    end
if input.include?("b")
    n = h["B"] + rand(26)
    puts h.index(n) 
    end
if input.include?("c")
    n = h["C"] + rand(26)
    puts h.index(n)  
    end
if input.include?("d")
    n = h["D"] + rand(26)
    puts h.index(n) 
    end
if input.include?("e")
    n = h["E"] + rand(26)
    puts h.index(n) 
    end
if input.include?("f")
    n = h["F"] + rand(26)
    puts h.index(n) 
    end
if input.include?("g")
    n = h["G"] + rand(26)
    puts h.index(n) 
    end
if input.include?("h")
    n = h["H"] + rand(26)
    puts h.index(n) 
    end
if input.include?("i")
    n = h["I"] + rand(26)
    puts h.index(n) 
    end
if input.include?("j")
    n = h["J"] + rand(26)
    puts h.index(n) 
    end
if input.include?("k")
    n = h["K"] + rand(26)
    puts h.index(n) 
    end
if input.include?("l")
    n = h["L"] + rand(26)
    puts h.index(n) 
    end
if input.include?("m")
    n = h["M"] + rand(26)
    puts h.index(n) 
    end
if input.include?("n")
    n = h["N"] + rand(26)
    puts h.index(n) 
    end
if input.include?("o")
    n = h["O"] + rand(26)
    puts h.index(n) 
    end
if input.include?("p")
    n = h["P"] + rand(26)
    puts h.index(n) 
    end
if input.include?("q")
    n = h["Q"] + rand(26)
    puts h.index(n) 
    end
if input.include?("r")
    n = h["R"] + rand(26)
    puts h.index(n) 
    end
if input.include?("s")
    n = h["S"] + rand(26)
    puts h.index(n) 
    end
if input.include?("t")
    n = h["T"] + rand(26)
    puts h.index(n) 
    end
if input.include?("u")
    n = h["U"] + rand(26)
    puts h.index(n) 
    end
if input.include?("v")
    n = h["V"] + rand(26)
    puts h.index(n) 
    end
if input.include?("w")
    n = h["W"] + rand(26)
    puts h.index(n)
    end
if input.include?("x")
    n = h["X"] + rand(26)
    puts h.index(n) 
    end
if input.include?("y")
    n = h["Y"] + rand(26)
    puts h.index(n) 
    end
if input.include?("z")
    n = h["Z"] + rand(26)
    puts h.index(n) 
    end

What is wrong with my code? Is there a better way I can do this, and/or is there a way I can make it more effective and efficient. 
Quick final question, is there a better place to run my code than in TextMate on a Mac running OS X 10.9.3? 
Most Recent Version:
h = {}
v = 0

('A'..'Z').each do |c|
  v+=1
  h[c] = v
end 

puts "Provide Input:"
input = gets
input.downcase!
input.each_char {|n| puts n, ' ' }

if input.include?("a") 
    n = h["A"] + rand(26)
    puts h.index(n % 26) 
    end
if input.include?("b")
    n = h["B"] + rand(26)
    puts h.index(n n % 26) 
    end
if input.include?("c")
    n = h["C"] + rand(26)
    puts h.index(n % 26)  
    end
if input.include?("d")
    n = h["D"] + rand(26)
    puts h.index(n % 26) 
    end
if input.include?("e")
    n = h["E"] + rand(26)
    puts h.index(n) 
    end
if input.include?("f")
    n = h["F"] + rand(26)
    puts h.index(n % 26) 
    end
if input.include?("g")
    n = h["G"] + rand(26)
    puts h.index(n % 26) 
    end
if input.include?("h")
    n = h["H"] + rand(26)
    puts h.index(n % 26) 
    end
if input.include?("i")
    n = h["I"] + rand(26)
    puts h.index(n % 26) 
    end
if input.include?("j")
    n = h["J"] + rand(26)
    puts h.index(n % 26) 
    end
if input.include?("k")
    n = h["K"] + rand(26)
    puts h.index(n) 
    end
if input.include?("l")
    n = h["L"] + rand(26)
    puts h.index(n % 26) 
    end
if input.include?("m")
    n = h["M"] + rand(26)
    puts h.index(n % 26) 
    end
if input.include?("n")
    n = h["N"] + rand(26)
    puts h.index(n % 26) 
    end
if input.include?("o")
    n = h["O"] + rand(26)
    puts h.index(n % 26) 
    end
if input.include?("p")
    n = h["P"] + rand(26)
    puts h.index(n % 26) 
    end
if input.include?("q")
    n = h["Q"] + rand(26)
    puts h.index(n % 26) 
    end
if input.include?("r")
    n = h["R"] + rand(26)
    puts h.index(n % 26) 
    end
if input.include?("s")
    n = h["S"] + rand(26)
    puts h.index(n % 26) 
    end
if input.include?("t")
    n = h["T"] + rand(26)
    puts h.index(n % 26) 
    end
if input.include?("u")
    n = h["U"] + rand(26)
    puts h.index(n % 26) 
    end
if input.include?("v")
    n = h["V"] + rand(26)
    puts h.index(n % 26) 
    end
if input.include?("w")
    n = h["W"] + rand(26)
    puts h.index(n % 26)
    end
if input.include?("x")
    n = h["X"] + rand(26)
    puts h.index(n % 26) 
    end
if input.include?("y")
    n = h["Y"] + rand(26)
    puts h.index(n % 26) 
    end
if input.include?("z")
    n = h["Z"] + rand(26)
    puts h.index(n % 26) 
    end

A:

As I understand your code, h["Z"] == 26.  If you then add a random number up to 26, (let's say 4), you have 30.  h.index(30) would be nil.  I would wager you want to h.index(n%26).
EDIT:
complete code, based partially on the other answer given:
h = {}
v = 0

('A'..'Z').each do |c|
    h[c] = v
    v+=1
end

puts "Provide Input:"
input = gets

input.chomp.each_char do |c|
    next if c.upcase !~ /^[A-Z]$/
    n = h[c.upcase] + rand(26)
    puts h.key(n % 26)
end

