Class: FunCi::Tui::HeaderAnimationPlayer
- Inherits:
-
Object
- Object
- FunCi::Tui::HeaderAnimationPlayer
- Defined in:
- lib/fun_ci/tui/header_animation_player.rb
Instance Attribute Summary collapse
-
#frame ⇒ Object
readonly
Returns the value of attribute frame.
Instance Method Summary collapse
- #advance! ⇒ Object
- #current_lines(width) ⇒ Object
- #finished? ⇒ Boolean
-
#initialize(data) ⇒ HeaderAnimationPlayer
constructor
A new instance of HeaderAnimationPlayer.
- #total_frames ⇒ Object
Constructor Details
#initialize(data) ⇒ HeaderAnimationPlayer
Returns a new instance of HeaderAnimationPlayer.
10 11 12 13 |
# File 'lib/fun_ci/tui/header_animation_player.rb', line 10 def initialize(data) @data = data @frame = 0 end |
Instance Attribute Details
#frame ⇒ Object (readonly)
Returns the value of attribute frame.
8 9 10 |
# File 'lib/fun_ci/tui/header_animation_player.rb', line 8 def frame @frame end |
Instance Method Details
#advance! ⇒ Object
15 16 17 |
# File 'lib/fun_ci/tui/header_animation_player.rb', line 15 def advance! @frame += 1 end |
#current_lines(width) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/fun_ci/tui/header_animation_player.rb', line 27 def current_lines(width) return [] if finished? frame_lines = @data[:frames][@frame] return [] unless frame_lines frame_lines.map { |line| center_line(line, width) } end |
#finished? ⇒ Boolean
19 20 21 |
# File 'lib/fun_ci/tui/header_animation_player.rb', line 19 def finished? @frame >= total_frames end |
#total_frames ⇒ Object
23 24 25 |
# File 'lib/fun_ci/tui/header_animation_player.rb', line 23 def total_frames @data[:frames].length end |