module Asciidoctor::Diagram::SVG
@private
Constants
- HEIGHT_REGEX
- START_TAG_REGEX
- VIEWBOX_REGEX
- WIDTH_REGEX
Public Class Methods
get_image_size(data)
click to toggle source
# File lib/asciidoctor-diagram/util/svg.rb, line 7 def self.get_image_size(data) if m = START_TAG_REGEX.match(data) start_tag = m[0] if (w = WIDTH_REGEX.match(start_tag)) && (h = HEIGHT_REGEX.match(start_tag)) width = w[:value].to_i * to_px_factor(w[:unit]) height = h[:value].to_i * to_px_factor(h[:unit]) return [width.to_i, height.to_i] end if v = VIEWBOX_REGEX.match(start_tag) width = v[:width] height = v[:height] return [width.to_i, height.to_i] end end nil end
Private Class Methods
to_px_factor(unit)
click to toggle source
# File lib/asciidoctor-diagram/util/svg.rb, line 33 def self.to_px_factor(unit) case unit when 'pt' 1.33 else 1 end end