Module: Powerpoint::Util
- Included in:
- Presentation, Slide::DescriptionPic, Slide::Intro, Slide::Pictorial, Slide::TextPicSplit, Slide::Textual
- Defined in:
- lib/powerpoint/util.rb
Instance Method Summary collapse
- #copy_media(extract_path, image_path) ⇒ Object
- #pixle_to_pt(px) ⇒ Object
- #read_template(filename) ⇒ Object
- #render_view(template_name, path) ⇒ Object
- #require_arguments(required_argements, argements) ⇒ Object
Instance Method Details
#copy_media(extract_path, image_path) ⇒ Object
24 25 26 27 28 |
# File 'lib/powerpoint/util.rb', line 24 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 |
#pixle_to_pt(px) ⇒ Object
4 5 6 |
# File 'lib/powerpoint/util.rb', line 4 def pixle_to_pt(px) px * 12700 end |
#read_template(filename) ⇒ Object
16 17 18 |
# File 'lib/powerpoint/util.rb', line 16 def read_template(filename) File.read("#{Powerpoint::VIEW_PATH}/#{filename}") end |
#render_view(template_name, path) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/powerpoint/util.rb', line 8 def render_view(template_name, path) view_contents = read_template(template_name) renderer = ERB.new(view_contents) data = renderer.result(binding) File.open(path, 'w') { |f| f << data } end |
#require_arguments(required_argements, argements) ⇒ Object
20 21 22 |
# File 'lib/powerpoint/util.rb', line 20 def require_arguments(required_argements, argements) raise ArgumentError unless required_argements.all? {|required_key| argements.keys.include? required_key} end |