top, top_middle, bottom_middle and bottom are four long strings.
How can I DRY up the following given that current's string values are the same as the name of the variable being used by the_line - but not its actual variable.
Is there some sort of "variable.variable_name" for what it is?
[top,top_middle,bottom_middle,bottom].each_with_index do |the_line, i|
current=
case i
when 0 then "top"
when 1 then "top_middle"
when 2 then "bottom_middle"
when 3 then "bottom"
end
puts current
puts the_line
end
Output is okay as is:
top
―― | ―― ―― | | ―― | ―― ―― ――
top_middle
| | | __| __| |__| |__ |__ | |__| |__|
bottom_middle
| | | | | | | | | | | | |
bottom
―― | ―― ―― | ―― ―― | ―― |