Skip to content

Instantly share code, notes, and snippets.

Created April 5, 2013 12:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/5318858 to your computer and use it in GitHub Desktop.
Save anonymous/5318858 to your computer and use it in GitHub Desktop.
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
Copy link

Submitted anonymously, oops. .

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