Skip to content

Instantly share code, notes, and snippets.

Created March 28, 2014 17:28
Show Gist options
  • Save anonymous/9838192 to your computer and use it in GitHub Desktop.
Save anonymous/9838192 to your computer and use it in GitHub Desktop.
def calculate_grid(options)
results = []
(0..options[:width]).each do |n|
gutter = n.to_f
col = (options[:width] - (gutter * (options[:cols] + 1))) / options[: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 cols: 7, width: 1100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment