Class: FunCi::Tui::HeaderAnimationPlayer

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#frameObject (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

Returns:

  • (Boolean)


19
20
21
# File 'lib/fun_ci/tui/header_animation_player.rb', line 19

def finished?
  @frame >= total_frames
end

#total_framesObject



23
24
25
# File 'lib/fun_ci/tui/header_animation_player.rb', line 23

def total_frames
  @data[:frames].length
end