-
-
Save readingtype/5318876 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment