I am new to Ruby, and it seems that Ruby does support variables defined outside the method being accessed just now when I want to do something:
templat
You are declaring local variables, not global ones. See this site for more (simplified) details: http://www.techotopia.com/index.php/Ruby_Variable_Scope