Class: RubyPoint::Presentation
- Inherits:
-
Object
- Object
- RubyPoint::Presentation
- Defined in:
- lib/rubypoint/presentation.rb
Defined Under Namespace
Classes: Presentation
Constant Summary collapse
- @@base_pptx =
File.dirname(__FILE__)+'/base.pptx'
Instance Attribute Summary collapse
-
#files ⇒ Object
Returns the value of attribute files.
-
#slides ⇒ Object
PRESENTATION PARTS.
Instance Method Summary collapse
- #add_to_relationships(object) ⇒ Object
- #app_xml ⇒ Object
- #clean_file_directory ⇒ Object
- #content_types_xml ⇒ Object
- #file_directory ⇒ Object
-
#initialize(file_path = @@base_pptx) ⇒ Presentation
constructor
A new instance of Presentation.
- #new_slide ⇒ Object
- #next_slide_id ⇒ Object
- #open(path) ⇒ Object
- #presentation_rel ⇒ Object
- #presentation_xml ⇒ Object
- #save(file_path, force = false) ⇒ Object
- #slide_directory ⇒ Object
- #system(stuff) ⇒ Object
Constructor Details
#initialize(file_path = @@base_pptx) ⇒ Presentation
Returns a new instance of Presentation.
9 10 11 12 13 14 15 |
# File 'lib/rubypoint/presentation.rb', line 9 def initialize(file_path=@@base_pptx) @working_directory = RubyPoint.working_directory @uuid = Time.now.to_i + rand(100) @files = [] @base_file_name = file_path.split('/').last self.open(file_path) end |
Instance Attribute Details
#files ⇒ Object
Returns the value of attribute files.
7 8 9 |
# File 'lib/rubypoint/presentation.rb', line 7 def files @files end |
#slides ⇒ Object
PRESENTATION PARTS
50 51 52 |
# File 'lib/rubypoint/presentation.rb', line 50 def @slides end |
Instance Method Details
#add_to_relationships(object) ⇒ Object
84 85 86 |
# File 'lib/rubypoint/presentation.rb', line 84 def add_to_relationships(object) self.presentation_rel.add_relationship_for(object) end |
#app_xml ⇒ Object
68 69 70 |
# File 'lib/rubypoint/presentation.rb', line 68 def app_xml @app_xml ||= RubyPoint::App.new(self) end |
#clean_file_directory ⇒ Object
44 45 46 |
# File 'lib/rubypoint/presentation.rb', line 44 def clean_file_directory system("rm -r #{file_directory}") end |
#content_types_xml ⇒ Object
72 73 74 |
# File 'lib/rubypoint/presentation.rb', line 72 def content_types_xml @content_types_xml ||= RubyPoint::ContentTypes::XML.new(self) end |
#file_directory ⇒ Object
92 93 94 |
# File 'lib/rubypoint/presentation.rb', line 92 def file_directory "#{@working_directory}#{@uuid}" end |
#new_slide ⇒ Object
76 77 78 |
# File 'lib/rubypoint/presentation.rb', line 76 def RubyPoint::Slide.new(self) end |
#next_slide_id ⇒ Object
80 81 82 |
# File 'lib/rubypoint/presentation.rb', line 80 def self..size + 1 end |
#open(path) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/rubypoint/presentation.rb', line 17 def open(path) system("mkdir #{file_directory}") system("cp #{path} #{@working_directory}#{@uuid}/#{@base_file_name}") system("unzip -q #{@working_directory}#{@uuid}/#{@base_file_name} -d #{@working_directory}#{@uuid}/") system("rm #{@working_directory}#{@uuid}/#{@base_file_name}") @files = Dir.glob("#{@working_directory}#{@uuid}/**/*", ::File::FNM_DOTMATCH) end |
#presentation_rel ⇒ Object
60 61 62 |
# File 'lib/rubypoint/presentation.rb', line 60 def presentation_rel @presentation_rel ||= RubyPoint::PresentationRel.new(self) end |
#presentation_xml ⇒ Object
64 65 66 |
# File 'lib/rubypoint/presentation.rb', line 64 def presentation_xml @presentation_xml ||= RubyPoint::Presentation::Presentation.new(self) end |
#save(file_path, force = false) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rubypoint/presentation.rb', line 30 def save(file_path, force=false) .each do |s| s.write end presentation_rel.write presentation_xml.write app_xml.write content_types_xml.write if ::File.exist?(file_path) force ? system("rm -f #{file_path}") : raise("#{file_path} already exists") end RubyPoint.compress_folder(file_directory, file_path) end |
#slide_directory ⇒ Object
88 89 90 |
# File 'lib/rubypoint/presentation.rb', line 88 def file_directory + '/ppt/slides' end |
#system(stuff) ⇒ Object
25 26 27 28 |
# File 'lib/rubypoint/presentation.rb', line 25 def system(stuff) puts stuff super end |