class RETerm::Components::Label

Simply renders text to window

Attributes

text[RW]

Public Class Methods

new(args={}) click to toggle source

Initialize the Label component

@param [Hash] args label params @option args [String] :text text of the label

Calls superclass method RETerm::Component::new
# File lib/reterm/components/label.rb, line 12
def initialize(args={})
  super
  @text    = args[:text] || ""
end

Public Instance Methods

draw!() click to toggle source
# File lib/reterm/components/label.rb, line 25
def draw!
  padding = " " * [0, window.cols - @text.size-2].max
  window.mvaddstr(0, 0, @text + padding)
end
erase() click to toggle source
# File lib/reterm/components/label.rb, line 30
def erase
  padding = " " * [0, window.cols - @text.size-2].max
  window.mvaddstr(0, 0, " " * (@text + padding).size)
  window.refresh
end
requested_cols() click to toggle source
# File lib/reterm/components/label.rb, line 21
def requested_cols
  @text.size + 1
end
requested_rows() click to toggle source
# File lib/reterm/components/label.rb, line 17
def requested_rows
  2
end