Class: FunCi::Tui::LoopingAnimationPlayer

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

Instance Method Summary collapse

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

Returns:

  • (Boolean)


21
22
23
# File 'lib/fun_ci/tui/looping_animation_player.rb', line 21

def finished?
  false
end

#frameObject



17
18
19
# File 'lib/fun_ci/tui/looping_animation_player.rb', line 17

def frame
  @frame % total_frames
end

#total_framesObject



25
26
27
# File 'lib/fun_ci/tui/looping_animation_player.rb', line 25

def total_frames
  @data[:frames].length
end