Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Silly script that generates widths of cols and margins. Run ruby col-widther.rb
@colwidth = 100
@margin = 10
@total = 0
def spanwidth(cols)
[(cols * @colwidth.to_i), (@margin.to_i * (cols-1))]
end
def calculate
(1..@cols.to_i).each do | i |
width = spanwidth(i)
puts "-- #{@total} --"
puts "-- #{@total + @margin.to_i} --"
puts " [#{i}] #{width[0] + width[1]}"
@total += (@colwidth.to_i + @margin.to_i)
end
puts "-- #{@margin.to_i} --"
end
puts "Column width: "
@colwidth = gets
puts "Margin width: "
@margin = gets
puts "Total columns: "
@cols = gets
puts ". . . . . ."
if @colwidth.to_i > 1 && @margin.to_i > 1 && @cols.to_i > 1
calculate
puts "Total: #{@total}"
else
puts "Oops."
end
@readingtype

This comment has been minimized.

Copy link

@readingtype readingtype commented Apr 5, 2013

Submitted anonymously, oops. .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment