Class: Diamante::Scene::UI

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#update

Constructor Details

#initialize(config) ⇒ UI

Returns a new instance of UI.



13
14
15
16
17
18
19
20
21
# File 'lib/diamante/scenes/ui.rb', line 13

def initialize(config)
  @pastel = Pastel.new
    
  @header = config[:header]
  @slides = slides
  @term = ANSI.new
  @height = @term.height
  @width = @term.width
end

Instance Attribute Details

#slidesObject

Returns the value of attribute slides.



11
12
13
# File 'lib/diamante/scenes/ui.rb', line 11

def slides
  @slides
end

Instance Method Details

#renderObject



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/diamante/scenes/ui.rb', line 23

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