Class: FullscreenTui::Footer

Inherits:
Object
  • Object
show all
Defined in:
lib/fullscreen_tui/footer.rb

Constant Summary collapse

SEPERATOR =
' | '

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeFooter

Returns a new instance of Footer.



8
9
10
# File 'lib/fullscreen_tui/footer.rb', line 8

def initialize
  self.message = ''
end

Instance Attribute Details

#messageObject

Returns the value of attribute message.



5
6
7
# File 'lib/fullscreen_tui/footer.rb', line 5

def message
  @message
end

Instance Method Details

#output(width:, lines:, current_line:) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/fullscreen_tui/footer.rb', line 12

def output width:, lines:, current_line:
  parts = [
    message,
    "#{(current_line + 1).to_s.rjust lines.to_s.size}/#{lines}",
  ]
  part_width = width - parts[1].size - SEPERATOR.size
  parts[0] = if parts[0].size > part_width
    "#{parts[0][0...part_width - 3]}..."
  else
    parts[0].ljust part_width
  end
  parts.join SEPERATOR
end