Class: Convert2Ascii::TerminalPlayer
- Inherits:
-
Object
- Object
- Convert2Ascii::TerminalPlayer
- 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
-
#debug ⇒ Object
Returns the value of attribute debug.
-
#play_loop ⇒ Object
Returns the value of attribute play_loop.
-
#step_duration ⇒ Object
Returns the value of attribute step_duration.
Instance Method Summary collapse
- #check_params ⇒ Object
-
#initialize(**args) ⇒ TerminalPlayer
constructor
A new instance of TerminalPlayer.
- #play ⇒ Object
Constructor Details
#initialize(**args) ⇒ TerminalPlayer
Returns a new instance of TerminalPlayer.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/convert2ascii/terminal-player.rb', line 14 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 check_params end |
Instance Attribute Details
#debug ⇒ Object
Returns the value of attribute debug.
12 13 14 |
# File 'lib/convert2ascii/terminal-player.rb', line 12 def debug @debug end |
#play_loop ⇒ Object
Returns the value of attribute play_loop.
12 13 14 |
# File 'lib/convert2ascii/terminal-player.rb', line 12 def play_loop @play_loop end |
#step_duration ⇒ Object
Returns the value of attribute step_duration.
12 13 14 |
# File 'lib/convert2ascii/terminal-player.rb', line 12 def step_duration @step_duration end |
Instance Method Details
#check_params ⇒ Object
29 30 31 32 33 |
# File 'lib/convert2ascii/terminal-player.rb', line 29 def check_params if @frames.length <= 0 raise TerminalPlayerError, "\n[Error] frame's length must be >= 0 " end end |
#play ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/convert2ascii/terminal-player.rb', line 35 def play begin init_screen render rescue => error raise error ensure clean_up end end |