Class: Slideck::Runner Private

Inherits:
Object
  • Object
show all
Defined in:
lib/slideck/runner.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Parse and display slides

Instance Method Summary collapse

Constructor Details

#initialize(screen, input, output, env) ⇒ Runner

Create a Runner instance

Examples:

Slideck::Runner.new(TTY::Screen, $stdin, $stdout, {})

Parameters:

  • screen (TTY::Screen)

    the terminal screen size

  • input (IO)

    the input stream

  • output (IO)

    the output stream

  • env (Hash)

    the environment variables



46
47
48
49
50
51
# File 'lib/slideck/runner.rb', line 46

def initialize(screen, input, output, env)
  @screen = screen
  @input = input
  @output = output
  @env = env
end

Instance Method Details

#run(filename, color: nil, watch: nil) ⇒ void

This method returns an undefined value.

Run the slides in a terminal

Examples:

runner.run("slides.md", color: :always, watch: true)

Parameters:

  • filename (String)

    the filename with slides

  • color (String, Symbol) (defaults to: nil)

    the color display out of always, auto or never

  • watch (Boolean) (defaults to: nil)

    whether to watch for changes in a filename



68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/slideck/runner.rb', line 68

def run(filename, color: nil, watch: nil)
  transformer = build_transformer
  presenter = build_presenter(color) { transformer.read(filename) }

  if watch
    listener = build_listener(filename) { presenter.reload.render }
    listener.start
  end

  presenter.start
ensure
  listener && listener.stop
end