Class: FunCi::Tui::BoardRenderer

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

Constant Summary collapse

HEADER_HEIGHT =
HeaderAnimationManager::HEADER_HEIGHT

Instance Method Summary collapse

Constructor Details

#initialize(screen:, spinner:, animation_renderer:, height_provider:) ⇒ BoardRenderer

Returns a new instance of BoardRenderer.



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

def initialize(screen:, spinner:, animation_renderer:, height_provider:)
  @screen = screen
  @spinner = spinner
  @animation_renderer = animation_renderer
  @height_provider = height_provider
end

Instance Method Details

#animation_renderer? ⇒ Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/fun_ci/tui/board_renderer.rb', line 51

def animation_renderer?
  !!@animation_renderer
end

#begin_frame ⇒ Object



38
39
40
41
# File 'lib/fun_ci/tui/board_renderer.rb', line 38

def begin_frame
  @screen.move_cursor_home
  @spinner.advance!
end

#clear ⇒ Object



43
44
45
# File 'lib/fun_ci/tui/board_renderer.rb', line 43

def clear
  @screen.clear
end

#render(runs:, streak:, cursor_index:, confirming:) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/fun_ci/tui/board_renderer.rb', line 19

def render(runs:, streak:, cursor_index:, confirming:)
  update_height
  render_header_area(runs, streak)

  if runs.empty?
    @screen.render_empty_state
    @screen.render_footer(empty: true)
  else
    rows = runs.map { |run| format_run(run) }
    rows = truncate_rows_to_height(rows)
    @screen.render_board(rows, cursor_index: cursor_index)
    @screen.println unless rows.empty?
    @screen.render_footer(empty: false, confirming: confirming)
  end

  @screen.clear_below
  render_animations(runs)
end

#resize(new_width) ⇒ Object



47
48
49
# File 'lib/fun_ci/tui/board_renderer.rb', line 47

def resize(new_width)
  @screen.width = new_width
end