Creating MarkDown documents in ruby
One way is to use multiplication. Multiplying a String by a Fixnum will produce a new String where the original String appears the Fixnum of times. 

"-" * @title.length #=&gt; "---------------" 


Documentation for String#*

Warning: Make sure you put the String first or else you will get a TypeError: String can't be coerced into Fixnum since that would be calling Fixnum#* instead of String#*.