Class: RETerm::Components::AsciiText

Inherits:
RETerm::Component show all
Defined in:
lib/reterm/components/ascii_text.rb

Overview

Renders specified text via ascii graphics.

This Component depends on the ‘artii’ gem.

Constant Summary

Constants included from LogHelpers

LogHelpers::LOG_FILE

Instance Attribute Summary

Attributes inherited from RETerm::Component

#activatable, #activate_focus, #highlight_focus, #window

Instance Method Summary collapse

Methods inherited from RETerm::Component

#activatable?, #activate!, #activate_focus?, #cdk?, #colored?, #colors=, #deactivate!, #deactivate?, #distance_from, #extra_padding, #finalize!, #highlight_focus?, #reactivate!, #resize, #sync!, #sync_getch

Methods included from KeyBindings

#bind_key, #invoke_key_bindings, #key_bindings, #key_bound?

Methods included from LogHelpers

#logger

Methods included from EventDispatcher

#dispatch, #handle

Constructor Details

#initialize(args = {}) ⇒ AsciiText

Initialize the AsciiText component

Parameters:

  • args (Hash) (defaults to: {})

    ascii text params

Options Hash (args):

  • :text (String)

    actual text to render, default empty string

  • :font (String)

    font to use



14
15
16
17
18
# File 'lib/reterm/components/ascii_text.rb', line 14

def initialize(args={})
  super
  @text = args[:text] || ""
  @font = args[:font]
end

Instance Method Details

#draw!Object



28
29
30
# File 'lib/reterm/components/ascii_text.rb', line 28

def draw!
  refresh_win
end

#requested_colsObject



24
25
26
# File 'lib/reterm/components/ascii_text.rb', line 24

def requested_cols
  lines.max { |l1, l2| l1.size <=> l2.size }.size + 1
end

#requested_rowsObject



20
21
22
# File 'lib/reterm/components/ascii_text.rb', line 20

def requested_rows
  lines.size + 1
end