Class: TuiTui::Span

Inherits:
Data
  • Object
show all
Defined in:
lib/tui_tui/span.rb

Overview

A run of text sharing one Style. Width is terminal-column aware via DisplayText.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#styleObject (readonly)

Returns the value of attribute style

Returns:

  • (Object)

    the current value of style



8
9
10
# File 'lib/tui_tui/span.rb', line 8

def style
  @style
end

#textObject (readonly)

Returns the value of attribute text

Returns:

  • (Object)

    the current value of text



8
9
10
# File 'lib/tui_tui/span.rb', line 8

def text
  @text
end

Class Method Details

.[](text, style = nil) ⇒ Object

Convenience constructor: Span[“hi”, style] (style optional).



10
# File 'lib/tui_tui/span.rb', line 10

def self.[](text, style = nil) = new(text: text.to_s, style: style)

Instance Method Details

#widthObject



12
# File 'lib/tui_tui/span.rb', line 12

def width = DisplayText.new(text).width