Class: RubyPowerpoint::Slide
- Inherits:
-
Object
- Object
- RubyPowerpoint::Slide
- Defined in:
- lib/ruby_powerpoint/slide.rb
Instance Attribute Summary collapse
-
#presentation ⇒ Object
readonly
Returns the value of attribute presentation.
-
#slide_file_name ⇒ Object
readonly
Returns the value of attribute slide_file_name.
-
#slide_number ⇒ Object
readonly
Returns the value of attribute slide_number.
Instance Method Summary collapse
- #content ⇒ Object
- #images ⇒ Object
-
#initialize(presentation, slide_xml_path) ⇒ Slide
constructor
A new instance of Slide.
- #notes_content ⇒ Object
- #paragraphs ⇒ Object
- #parse_relation ⇒ Object
- #parse_slide ⇒ Object
- #parse_slide_notes ⇒ Object
- #slide_num ⇒ Object
- #title ⇒ Object
Constructor Details
#initialize(presentation, slide_xml_path) ⇒ Slide
Returns a new instance of Slide.
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/ruby_powerpoint/slide.rb', line 12 def initialize presentation, @presentation = presentation @slide_xml_path = @slide_number = @slide_notes_xml_path = "ppt/notesSlides/notesSlide#{@slide_number}.xml" @slide_file_name = parse_relation end |
Instance Attribute Details
#presentation ⇒ Object (readonly)
Returns the value of attribute presentation.
7 8 9 |
# File 'lib/ruby_powerpoint/slide.rb', line 7 def presentation @presentation end |
#slide_file_name ⇒ Object (readonly)
Returns the value of attribute slide_file_name.
7 8 9 |
# File 'lib/ruby_powerpoint/slide.rb', line 7 def @slide_file_name end |
#slide_number ⇒ Object (readonly)
Returns the value of attribute slide_number.
7 8 9 |
# File 'lib/ruby_powerpoint/slide.rb', line 7 def @slide_number end |
Instance Method Details
#content ⇒ Object
42 43 44 |
# File 'lib/ruby_powerpoint/slide.rb', line 42 def content content_elements @slide_xml end |
#images ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/ruby_powerpoint/slide.rb', line 55 def images image_elements(@relation_xml) .map.each do |node| @presentation.files.file.open( node['Target'].gsub('..', 'ppt')) end end |
#notes_content ⇒ Object
46 47 48 |
# File 'lib/ruby_powerpoint/slide.rb', line 46 def notes_content content_elements @slide_notes_xml end |
#paragraphs ⇒ Object
67 68 69 |
# File 'lib/ruby_powerpoint/slide.rb', line 67 def paragraphs paragraph_element @slide_xml end |
#parse_relation ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/ruby_powerpoint/slide.rb', line 34 def parse_relation @relation_xml_path = "ppt/slides/_rels/#{@slide_file_name}.rels" if @presentation.files.file.exist? @relation_xml_path relation_doc = @presentation.files.file.open @relation_xml_path @relation_xml = Nokogiri::XML::Document.parse relation_doc end end |
#parse_slide ⇒ Object
24 25 26 27 |
# File 'lib/ruby_powerpoint/slide.rb', line 24 def = @presentation.files.file.open @slide_xml_path @slide_xml = Nokogiri::XML::Document.parse end |
#parse_slide_notes ⇒ Object
29 30 31 32 |
# File 'lib/ruby_powerpoint/slide.rb', line 29 def = @presentation.files.file.open @slide_notes_xml_path rescue nil @slide_notes_xml = Nokogiri::XML::Document.parse() if end |
#slide_num ⇒ Object
63 64 65 |
# File 'lib/ruby_powerpoint/slide.rb', line 63 def @slide_xml_path.match(/slide([0-9]*)\.xml$/)[1].to_i end |
#title ⇒ Object
50 51 52 53 |
# File 'lib/ruby_powerpoint/slide.rb', line 50 def title title_elements = title_elements(@slide_xml) title_elements.join(" ") if title_elements.length > 0 end |