Sha256: 9fe30b4e978e19318c58b4a7bc617619668bc06dc6b93f7a88edcf998fc0c9fb
Contents?: true
Size: 1.05 KB
Versions: 1
Compression:
Stored size: 1.05 KB
Contents
module Powerpoint module Util def pixle_to_pt(px) px * 12700 end def render_view(template_name, path, variables = {}) view_contents = read_template(template_name) renderer = ERB.new(view_contents) b = merge_variables(binding, variables) data = renderer.result(b) File.open(path, 'w') { |f| f << data.squish!.gsub('> <', '><') } end def read_template(filename) File.read("#{Powerpoint::VIEW_PATH}/#{filename}") end def require_arguments(required_arguements, arguements) raise ArgumentError unless required_arguements.all? {|required_key| arguements.keys.include? required_key} end def copy_media(extract_path, image_path) image_name = File.basename(image_path) dest_path = "#{extract_path}/ppt/media/#{image_name}" FileUtils.copy_file(image_path, dest_path) unless File.exist?(dest_path) end def merge_variables(b, variables) return b if variables.empty? variables.each do |k,v| b.local_variable_set(k, v) end b end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
powerpoint-pro-2.1.0.1 | lib/powerpoint/util.rb |