Class: Diamante::Scene::UI

Inherits:
Object
  • Object
show all
Defined in:
lib/diamante/scenes/ui.rb

Instance Method Summary collapse

Constructor Details

#initialize(header, slides) ⇒ UI

Returns a new instance of UI.



10
11
12
13
14
15
16
17
18
# File 'lib/diamante/scenes/ui.rb', line 10

def initialize(header, slides)
  @pastel = Pastel.new
    
  @header = header
  @slides = slides
  @term = ANSI.new
  @height = @term.height
  @width = @term.width
end

Instance Method Details

#renderObject



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/diamante/scenes/ui.rb', line 20

def render
  text = " #{@header} (#{@slides.index + 1}/#{@slides.count}) "
  col = @width - text.length - 1
  text = @pastel.white(text)
  ANSI.print_text_at(1, col, text)
  text = " q|→|← "
  text = @pastel.white(text)
  ANSI.print_text_at(@height - 2, 1, text)
  text = " #{Time.now} "
  col = @width - text.length - 1
  text = @pastel.white(text)
  ANSI.print_text_at(@height - 2, col, text)
end