Skip to content

Instantly share code, notes, and snippets.

@pedrozath
Forked from anonymous/grid-calculator.rb
Last active August 29, 2015 13:57
Show Gist options
  • Save pedrozath/9838214 to your computer and use it in GitHub Desktop.
Save pedrozath/9838214 to your computer and use it in GitHub Desktop.
def calculate_grid(width, cols)
results = []
(0..width).each do |n|
gutter = n.to_f
col = (width - (gutter * (cols + 1))) / cols
break if col < 0
results << "col: #{col.to_i}px / gutter: #{gutter.to_i}px" if col % 1 == 0
end
results
end
puts calculate_grid ARGV[0].to_i, ARGV[1].to_i
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment