Reputation: 2362
I am trying to make output that should look like this:
I am using this statement:
FILE_TYPES.each_key {|key| printf "%20s %s\n", "--[no]" + key.to_s, FILE_TYPES[key.to_sym]}
Its result looks like this:
Upvotes: 1
Views: 64
Reputation: 168209
If you do not insist on using printf
,
puts "--[no]" + key.to_s.ljust(20) + FILE_TYPES[key.to_sym]
Upvotes: 3
Reputation: 2857
Use \t to give tab spaces for formatting strings. e.g.
printf "Name:\t Shahzad\nGender:\tMale\nAge:\t25\n"
and it would print result as
Name: Shahzad
Gender: Male
Age: 25
=> nil
Upvotes: 2