Sha256: bb5fa22e5826be088f00a5f0d4163a077c28e8536ecc06fb7aca3c3d7a7eeaac

Contents?: true

Size: 1.37 KB

Versions: 1

Compression:

Stored size: 1.37 KB

Contents

require 'zip/filesystem'
require 'fileutils'
require 'fastimage'
require 'erb'

module Powerpoint
  module Slide
    class Custom
      include Powerpoint::Util

      attr_reader :title, :subtitle, :properties, :coords

      def initialize(options={})
        require_arguments [:title, :properties], options
        options.each {|k, v| instance_variable_set("@#{k}", v)}
        @coords = default_coords unless @coords.present?
        properties
      end

      def save(extract_path, index)
        properties.each do |property|
          if property[:type] == 'image'
            copy_media(extract_path, property[:file_path]) 
          end
        end
        save_rel_xml(extract_path, index)
        save_slide_xml(extract_path, index)
      end

      def file_type
        File.extname(image_name).gsub('.', '')
      end

      def default_coords
        {x: 0, y: 0, cx: pixle_to_pt(50), cy: pixle_to_pt(50)}
      end
      private :default_coords

      def save_rel_xml(extract_path, index)
        render_view('custom_rel.xml.erb', "#{extract_path}/ppt/slides/_rels/slide#{index}.xml.rels", index: index)
      end
      private :save_rel_xml

      def save_slide_xml(extract_path, index)
        render_view('custom.xml.erb', "#{extract_path}/ppt/slides/slide#{index}.xml")
      end
      private :save_slide_xml
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
powerpoint-pro-2.1.0.1 lib/powerpoint/slide/custom.rb