Class: FunCi::Tui::LoopingAnimationPlayer
- Inherits:
-
Object
- Object
- FunCi::Tui::LoopingAnimationPlayer
- Defined in:
- lib/fun_ci/tui/looping_animation_player.rb
Instance Method Summary collapse
- #advance! ⇒ Object
- #current_lines(width) ⇒ Object
- #finished? ⇒ Boolean
- #frame ⇒ Object
-
#initialize(data) ⇒ LoopingAnimationPlayer
constructor
A new instance of LoopingAnimationPlayer.
- #total_frames ⇒ Object
Constructor Details
#initialize(data) ⇒ LoopingAnimationPlayer
Returns a new instance of LoopingAnimationPlayer.
8 9 10 11 |
# File 'lib/fun_ci/tui/looping_animation_player.rb', line 8 def initialize(data) @data = data @frame = 0 end |
Instance Method Details
#advance! ⇒ Object
13 14 15 |
# File 'lib/fun_ci/tui/looping_animation_player.rb', line 13 def advance! @frame += 1 end |
#current_lines(width) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/fun_ci/tui/looping_animation_player.rb', line 29 def current_lines(width) frame_lines = @data[:frames][frame] return [] unless frame_lines frame_lines.map { |line| center_line(line, width) } end |
#finished? ⇒ Boolean
21 22 23 |
# File 'lib/fun_ci/tui/looping_animation_player.rb', line 21 def finished? false end |
#frame ⇒ Object
17 18 19 |
# File 'lib/fun_ci/tui/looping_animation_player.rb', line 17 def frame @frame % total_frames end |
#total_frames ⇒ Object
25 26 27 |
# File 'lib/fun_ci/tui/looping_animation_player.rb', line 25 def total_frames @data[:frames].length end |