Class: Convert2Ascii::TerminalPlayer

Inherits:
Object
  • Object
show all
Defined in:
lib/convert2ascii/terminal-player.rb

Constant Summary collapse

SAFE_SLOW_DELTA =

seconds

0.9
SAFE_FAST_DELTA =

seconds

0.2

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**args) ⇒ TerminalPlayer

Returns a new instance of TerminalPlayer.



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/convert2ascii/terminal-player.rb', line 11

def initialize(**args)
  @debug = false
  @audio = args[:audio]
  @frames = args[:frames]
  @play_loop = args[:play_loop]
  @step_duration = args[:step_duration]

  @total_duration = @frames.length * @step_duration
  @first_frame = true
  @backspace_adjust = "\033[A" * (@frames.length + 1)

  regist_hook
end

Instance Attribute Details

#debugObject

Returns the value of attribute debug.



10
11
12
# File 'lib/convert2ascii/terminal-player.rb', line 10

def debug
  @debug
end

#play_loopObject

Returns the value of attribute play_loop.



10
11
12
# File 'lib/convert2ascii/terminal-player.rb', line 10

def play_loop
  @play_loop
end

#step_durationObject

Returns the value of attribute step_duration.



10
11
12
# File 'lib/convert2ascii/terminal-player.rb', line 10

def step_duration
  @step_duration
end

Instance Method Details

#playObject



25
26
27
28
29
30
31
32
33
34
# File 'lib/convert2ascii/terminal-player.rb', line 25

def play
  begin
    init_screen
    render
  rescue => error
    raise error
  ensure
    clean_up
  end
end