Class: KeynoteDriver::Presentation

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

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Presentation

Returns a new instance of Presentation.



5
6
7
8
9
10
11
# File 'lib/keynote_driver/presentation.rb', line 5

def initialize(path)
  if not File.exists?(path)
    raise PresentationException.new("#{path} doesn't exists.")
  end

  @path = path
end

Instance Method Details

#exec(delays) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/keynote_driver/presentation.rb', line 20

def exec(delays)
  load_file_in_keynote

  begin
    @system.processes['Keynote'].menu_bars[1].menu_bar_items[10].menus.menu_items[3].click
  rescue Appscript::CommandError
    retry
  end

  delays.each do |delay|
    Kernel.sleep(delay)
    @app.show_next
  end

  @app.stop_slideshow
end

#load_file_in_keynoteObject



13
14
15
16
17
18
# File 'lib/keynote_driver/presentation.rb', line 13

def load_file_in_keynote
  @system = find_system
  @app = find_keynote
  @app.activate
  @app.open(@path)
end