Class: Termfront::ScenePlayer

Inherits:
Object
  • Object
show all
Defined in:
lib/termfront/scene_player.rb

Instance Method Summary collapse

Constructor Details

#initialize(stdout, audio: nil) ⇒ ScenePlayer

Returns a new instance of ScenePlayer.



5
6
7
8
# File 'lib/termfront/scene_player.rb', line 5

def initialize(stdout, audio: nil)
  @stdout = stdout
  @audio = audio
end

Instance Method Details

#play(actions, title:, stdin: nil) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/termfront/scene_player.rb', line 10

def play(actions, title:, stdin: nil)
  pages = build_pages(actions)
  return if pages.empty?

  if stdin
    play_loop(stdin, pages, title)
  else
    STDIN.raw { |raw| play_loop(raw, pages, title) }
  end
end