Class: FunCi::Tui::HeaderAnimationManager

Inherits:
Object
  • Object
show all
Defined in:
lib/fun_ci/tui/header_animation_manager.rb

Constant Summary collapse

HEADER_HEIGHT =
14

Instance Method Summary collapse

Constructor Details

#initialize(animation_library:) ⇒ HeaderAnimationManager

Returns a new instance of HeaderAnimationManager.



11
12
13
14
15
16
# File 'lib/fun_ci/tui/header_animation_manager.rb', line 11

def initialize(animation_library:)
  @idle_player = LoopingAnimationPlayer.new(animation_library.idle)
  @running_player = nil
  @header_player = nil
  @animation_library = animation_library
end

Instance Method Details

#advance!Object



39
40
41
42
43
# File 'lib/fun_ci/tui/header_animation_manager.rb', line 39

def advance!
  @idle_player.advance!
  @running_player&.advance!
  @header_player&.advance!
end

#any_active_event?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/fun_ci/tui/header_animation_manager.rb', line 49

def any_active_event?
  @header_player && !@header_player.finished?
end

#current_lines(width) ⇒ Object



34
35
36
37
# File 'lib/fun_ci/tui/header_animation_manager.rb', line 34

def current_lines(width)
  lines = active_player.current_lines(width)
  pad_to_height(lines, HEADER_HEIGHT)
end

#expire_if_finished!Object



45
46
47
# File 'lib/fun_ci/tui/header_animation_manager.rb', line 45

def expire_if_finished!
  @header_player = nil if @header_player&.finished?
end

#start_runningObject



26
27
28
# File 'lib/fun_ci/tui/header_animation_manager.rb', line 26

def start_running
  @running_player ||= LoopingAnimationPlayer.new(@animation_library.running)
end

#stop_runningObject



30
31
32
# File 'lib/fun_ci/tui/header_animation_manager.rb', line 30

def stop_running
  @running_player = nil
end

#trigger_failureObject



18
19
20
# File 'lib/fun_ci/tui/header_animation_manager.rb', line 18

def trigger_failure
  @header_player = HeaderAnimationPlayer.new(@animation_library.random_failure)
end

#trigger_successObject



22
23
24
# File 'lib/fun_ci/tui/header_animation_manager.rb', line 22

def trigger_success
  @header_player = HeaderAnimationPlayer.new(@animation_library.random_success)
end