Created
October 19, 2017 17:01
-
-
Save joshuacronemeyer/eda8aa02f7b6c70979d335447196ffc4 to your computer and use it in GitHub Desktop.
munging SVG seatmaps
This file contains 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
require 'nokogiri' | |
class ProcessSvgVenueMap | |
def initialize(file) | |
@file = file | |
@doc=Nokogiri::XML.parse(@file) | |
end | |
def remove_css | |
@doc.search("svg", "defs").remove | |
background_image = @doc.xpath('//@style') | |
p "The background image you need is here #{background_image.text}" if background_image | |
background_image.remove | |
@doc.xpath('//@data-reactid').remove | |
end | |
def doc_xml | |
@doc.to_xml | |
end | |
end | |
filename = 'air_canada_center_map.svg' | |
file = File.read(filename) | |
process_map = ProcessSvgVenueMap.new(file) | |
process_map.remove_css | |
File.write(filename, process_map.doc_xml) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this doesn't work. i was playing around with nokogiri... it just didn't seem to be able to find the elements i was interested in with xpath or any other selectors. WIP.