Skip to content

Instantly share code, notes, and snippets.

@trotzig
Last active August 29, 2015 14:01
Show Gist options
  • Save trotzig/8d03210b9e5d26da3cc7 to your computer and use it in GitHub Desktop.
Save trotzig/8d03210b9e5d26da3cc7 to your computer and use it in GitHub Desktop.
Conversion script for Face Pile positions
require 'csv'
# Script used to convert the face pile positioning document Nebs put together in
# https://docs.google.com/a/causes.com/spreadsheets/d/1ELRK8J0I8Q-Hu8-mPIYvOxW0_cNDxvg35QNLzSrTIT8/edit
#
# I made a copy of this document and cleaned it to make it easier to parse:
# https://docs.google.com/a/causes.com/spreadsheets/d/1Ye2o-exOj1JsMPeeWiOk3s4HQ7UBtGlO1t2zSEUECbc/edit
# This is the document used in this script.
styles = {}
CSV.foreach('face_pile_positions.csv') do |row|
percentage = row[0]
is_packed = !!row[1]
number = row[2].to_i
left = (row[8].to_f * 100).round(2)
top = (row[9].to_f * 100).round(2)
size = (row[10].to_f * 100).round(2)
style = []
style << " top: #{top}%;"
style << " left: #{left}%;"
style << " width: #{size}%;"
style << " height: #{size}%;"
classes = styles[style.join("\n")] ||= []
classes << ".face-pile__face-#{percentage}-#{number}#{('-packed' if is_packed)}"
end
styles.map do |style, classes|
puts classes.join(",\n") + ' {'
puts style
puts '}'
puts
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment