Class: Md2key::Keynote
- Inherits:
-
Object
- Object
- Md2key::Keynote
- Defined in:
- lib/md2key/keynote.rb
Constant Summary collapse
- COVER_SLIDE_INDEX =
1- TEMPLATE_SLIDE_INDEX =
2
Class Method Summary collapse
- .activate ⇒ Object
- .create_slide(title, content) ⇒ Object
-
.delete_extra_slides ⇒ Object
All slides after a second slide are unnecessary and deleted.
- .delete_template_slide ⇒ Object
- .ensure_template_slide_availability ⇒ Object
-
.insert_image(path) ⇒ Object
Insert image to the last slide.
-
.update_cover(title, sub) ⇒ Object
You must provide a first slide as a cover slide.
Class Method Details
.activate ⇒ Object
9 10 11 12 13 |
# File 'lib/md2key/keynote.rb', line 9 def activate tell_keynote(<<-APPLE.unindent) activate APPLE end |
.create_slide(title, content) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/md2key/keynote.rb', line 61 def (title, content) tell_keynote(<<-APPLE.unindent) tell document 1 -- Workaround to select correct master slide. In spite of master slide can be selected by name, -- name property is not limited to be unique. -- So move the focus to second slide and force "make new slide" to use the exact master slide. move slide #{TEMPLATE_SLIDE_INDEX} to before slide #{TEMPLATE_SLIDE_INDEX} set newSlide to make new slide tell newSlide set object text of default title item to "#{title}" set object text of default body item to "#{content}" end tell end tell APPLE end |
.delete_extra_slides ⇒ Object
All slides after a second slide are unnecessary and deleted.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/md2key/keynote.rb', line 38 def tell_keynote(<<-APPLE.unindent) set theSlides to slides of document 1 set n to #{} repeat with theSlide in theSlides if n > 2 then delete slide n of document 1 end if set n to n - 1 end repeat APPLE end |
.delete_template_slide ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/md2key/keynote.rb', line 53 def tell_keynote(<<-APPLE.unindent) tell document 1 delete slide #{TEMPLATE_SLIDE_INDEX} end tell APPLE end |
.ensure_template_slide_availability ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/md2key/keynote.rb', line 27 def return if >= 2 tell_keynote(<<-APPLE.unindent) tell document 1 make new slide end APPLE end |
.insert_image(path) ⇒ Object
Insert image to the last slide
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/md2key/keynote.rb', line 79 def insert_image(path) tell_keynote(<<-APPLE.unindent) tell document 1 set theSlide to slide #{} set theImage to POSIX file "#{path}" set docWidth to its width set docHeight to its height tell slide #{TEMPLATE_SLIDE_INDEX} set imgFile to make new image with properties { file: theImage, width: docWidth / 3 } tell imgFile set imgWidth to its width set imgHeight to its width end tell end tell tell theSlide make new image with properties { file: theImage, width: imgWidth, position: { docWidth - imgWidth - 60, docHeight / 2 - imgHeight / 2} } end tell end tell APPLE end |
.update_cover(title, sub) ⇒ Object
You must provide a first slide as a cover slide.
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/md2key/keynote.rb', line 16 def update_cover(title, sub) tell_keynote(<<-APPLE.unindent) tell document 1 tell slide #{COVER_SLIDE_INDEX} set object text of default title item to "#{title}" set object text of default body item to "#{sub}" end tell end tell APPLE end |