class RubySlides::Slide::TextPicSplit

Attributes

content[R]
coords[R]
image_name[R]
image_path[R]
title[R]

Public Class Methods

new(options={}) click to toggle source
# File lib/ruby_slides/slide/text_picture_split.rb, line 13
def initialize(options={})
  require_arguments [:presentation, :title, :image_path, :content], options
  options.each {|k, v| instance_variable_set("@#{k}", v)}
  @coords = default_coords
  @image_name = File.basename(@image_path)
end

Public Instance Methods

file_type() click to toggle source
# File lib/ruby_slides/slide/text_picture_split.rb, line 26
def file_type
  File.extname(image_name).gsub('.', '')
end
save(extract_path, index) click to toggle source
# File lib/ruby_slides/slide/text_picture_split.rb, line 20
def save(extract_path, index)
  copy_media(extract_path, @image_path)
  save_rel_xml(extract_path, index)
  save_slide_xml(extract_path, index)
end

Private Instance Methods

default_coords() click to toggle source
# File lib/ruby_slides/slide/text_picture_split.rb, line 30
def default_coords
  start_x = pixel_to_pt(360)
  default_width = pixel_to_pt(300)

  return {} unless dimensions = FastImage.size(image_path)
  image_width, image_height = dimensions.map {|d| pixel_to_pt(d)}
  new_width = default_width < image_width ? default_width : image_width
  ratio = new_width / image_width.to_f
  new_height = (image_height.to_f * ratio).round
  {x: start_x, y: pixel_to_pt(120), cx: new_width, cy: new_height}
end
save_rel_xml(extract_path, index) click to toggle source
# File lib/ruby_slides/slide/text_picture_split.rb, line 43
def save_rel_xml(extract_path, index)
  render_view('text_picture_split_rel.xml.erb',
              "#{extract_path}/ppt/slides/_rels/slide#{index}.xml.rels",
              index: 2)
end
save_slide_xml(extract_path, index) click to toggle source
# File lib/ruby_slides/slide/text_picture_split.rb, line 50
def save_slide_xml(extract_path, index)
  render_view('text_picture_split_slide.xml.erb',
              "#{extract_path}/ppt/slides/slide#{index}.xml")
end