Class: RubyPowerpoint::Presentation

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_powerpoint/presentation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Presentation

Returns a new instance of Presentation.



10
11
12
13
# File 'lib/ruby_powerpoint/presentation.rb', line 10

def initialize path
  raise 'Not a valid file format.' unless (['.pptx'].include? File.extname(path).downcase)
  @files = Zip::File.open path
end

Instance Attribute Details

#filesObject (readonly)

Returns the value of attribute files.



8
9
10
# File 'lib/ruby_powerpoint/presentation.rb', line 8

def files
  @files
end

Instance Method Details

#closeObject



25
26
27
# File 'lib/ruby_powerpoint/presentation.rb', line 25

def close
  @files.close
end

#slidesObject



15
16
17
18
19
20
21
22
23
# File 'lib/ruby_powerpoint/presentation.rb', line 15

def slides
  slides = Array.new
  @files.each do |f|
    if f.name.include? 'ppt/slides/slide'
      slides.push RubyPowerpoint::Slide.new(self, f.name)
    end
  end
  slides.sort{|a,b| a.slide_num <=> b.slide_num}
end