Class: RubySlides::Presentation
- Inherits:
-
Object
- Object
- RubySlides::Presentation
show all
- Includes:
- Util
- Defined in:
- lib/ruby_slides/presentation.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
-
#chart_slide(title, series = [{}]) ⇒ Object
-
#charts ⇒ Object
-
#file_types ⇒ Object
-
#initialize ⇒ Presentation
constructor
A new instance of Presentation.
-
#introduction_slide(title, subtitle) ⇒ Object
-
#pictorial_slide(title, image_path, coords = {}) ⇒ Object
-
#picture_description_slide(title, image_path, content = []) ⇒ Object
-
#save(path) ⇒ Object
-
#table_slide(title, content = []) ⇒ Object
-
#text_picture_slide(title, image_path, content = []) ⇒ Object
-
#textual_slide(title, content = []) ⇒ Object
Methods included from Util
#copy_media, #merge_variables, #pixel_to_pt, #read_template, #render_view, #require_arguments
Constructor Details
Returns a new instance of Presentation.
11
12
13
|
# File 'lib/ruby_slides/presentation.rb', line 11
def initialize
@slides = []
end
|
Instance Attribute Details
#slides ⇒ Object
Returns the value of attribute slides.
9
10
11
|
# File 'lib/ruby_slides/presentation.rb', line 9
def slides
@slides
end
|
Instance Method Details
#chart_slide(title, series = [{}]) ⇒ Object
53
54
55
56
57
|
# File 'lib/ruby_slides/presentation.rb', line 53
def chart_slide(title, series = [{}])
@slides << RubySlides::Slide::Chart.new(presentation: self,
title: title,
series: series)
end
|
#charts ⇒ Object
99
100
101
102
103
|
# File 'lib/ruby_slides/presentation.rb', line 99
def charts
slides.map {|slide|
slide.class == RubySlides::Slide::Chart
}.count
end
|
#file_types ⇒ Object
93
94
95
96
97
|
# File 'lib/ruby_slides/presentation.rb', line 93
def file_types
slides.map {|slide|
slide.file_type if slide.respond_to? :file_type
}.compact.uniq
end
|
#introduction_slide(title, subtitle) ⇒ Object
15
16
17
18
|
# File 'lib/ruby_slides/presentation.rb', line 15
def introduction_slide(title, subtitle)
@slides << RubySlides::Slide::Introduction.new(title: title,
subtitle: subtitle)
end
|
#pictorial_slide(title, image_path, coords = {}) ⇒ Object
26
27
28
29
30
31
|
# File 'lib/ruby_slides/presentation.rb', line 26
def pictorial_slide(title, image_path, coords = {})
@slides << RubySlides::Slide::Pictorial.new(presentation: self,
title: title,
image_path: image_path,
coords: coords)
end
|
#picture_description_slide(title, image_path, content = []) ⇒ Object
40
41
42
43
44
45
|
# File 'lib/ruby_slides/presentation.rb', line 40
def picture_description_slide(title, image_path, content = [])
@slides << RubySlides::Slide::DescriptionPic.new(presentation: self,
title: title,
image_path: image_path,
content: content)
end
|
#save(path) ⇒ Object
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# File 'lib/ruby_slides/presentation.rb', line 59
def save(path)
Dir.mktmpdir do |dir|
= "#{dir}/extract_#{Time.now.strftime("%Y-%m-%d-%H%M%S")}"
FileUtils.copy_entry(TEMPLATE_PATH, )
Dir.glob("#{}/**/.keep").each do |keep_file|
FileUtils.rm_rf(keep_file)
end
render_view('content_type.xml.erb',
"#{}/[Content_Types].xml")
render_view('presentation.xml.rel.erb',
"#{}/ppt/_rels/presentation.xml.rels")
render_view('presentation.xml.erb',
"#{}/ppt/presentation.xml")
render_view('app.xml.erb',
"#{}/docProps/app.xml")
slides.each_with_index do |slide, index|
slide.save(, index + 1)
end
File.delete(path) if File.exist?(path)
RubySlides.compress_pptx(, path)
end
path
end
|
#table_slide(title, content = []) ⇒ Object
47
48
49
50
51
|
# File 'lib/ruby_slides/presentation.rb', line 47
def table_slide(title, content = [])
@slides << RubySlides::Slide::Table.new(presentation: self,
title: title,
content: content)
end
|
#text_picture_slide(title, image_path, content = []) ⇒ Object
33
34
35
36
37
38
|
# File 'lib/ruby_slides/presentation.rb', line 33
def text_picture_slide(title, image_path, content = [])
@slides << RubySlides::Slide::TextPicSplit.new(presentation: self,
title: title,
image_path: image_path,
content: content)
end
|
#textual_slide(title, content = []) ⇒ Object
20
21
22
23
24
|
# File 'lib/ruby_slides/presentation.rb', line 20
def textual_slide(title, content = [])
@slides << RubySlides::Slide::Textual.new(presentation: self,
title: title,
content: content)
end
|