class DoctorNinja::Parsers::Drawing
Public Class Methods
applicable_to?(node)
click to toggle source
# File lib/doctor_ninja/parsers/drawing.rb, line 8 def self.applicable_to?(node) node.name == "drawing" end
Public Instance Methods
extent()
click to toggle source
# File lib/doctor_ninja/parsers/drawing.rb, line 28 def extent @extent ||= { x: extent_node.attribute("cx").value.to_i, y: extent_node.attribute("cy").value.to_i } end
extent_node()
click to toggle source
# File lib/doctor_ninja/parsers/drawing.rb, line 35 def extent_node @node.xpath(".//wp:extent") end
parse()
click to toggle source
# File lib/doctor_ninja/parsers/drawing.rb, line 12 def parse width = extent[:x]/DoctorNinja::EMU_PER_PIXEL height = extent[:y]/DoctorNinja::EMU_PER_PIXEL rvg = RVG.new(width,height).viewbox(0,0,width,height) do |canvas| context = @context.dup context[:canvas] = canvas parse_children(context) end format = "png" base64 = Base64.encode64 rvg.draw.to_blob { self.format = format } "<img src=\"data:image/#{format};base64,#{base64}\"/>" end