Class: RubyTUI::Span
- Inherits:
-
Object
- Object
- RubyTUI::Span
- Defined in:
- lib/rubytui/text/span.rb
Overview
A Span is a styled fragment of text. It is the atomic unit for rich text rendering.
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#style ⇒ Object
readonly
Returns the value of attribute style.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
Value equality: same content and style.
-
#initialize(content, style = Style::DEFAULT) ⇒ Span
constructor
A new instance of Span.
-
#to_s ⇒ String
The unstyled text (#content).
-
#width ⇒ Integer
Display width of #content in terminal columns (see Unicode.string_width).
Constructor Details
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
10 11 12 |
# File 'lib/rubytui/text/span.rb', line 10 def content @content end |
#style ⇒ Object (readonly)
Returns the value of attribute style.
10 11 12 |
# File 'lib/rubytui/text/span.rb', line 10 def style @style end |
Instance Method Details
#==(other) ⇒ Boolean
Value equality: same content and style.
27 28 29 |
# File 'lib/rubytui/text/span.rb', line 27 def ==(other) other.is_a?(Span) && @content == other.content && @style == other.style end |
#to_s ⇒ String
Returns the unstyled text (#content).
32 |
# File 'lib/rubytui/text/span.rb', line 32 def to_s = @content |
#width ⇒ Integer
Returns display width of #content in terminal columns (see Unicode.string_width).
21 |
# File 'lib/rubytui/text/span.rb', line 21 def width = Unicode.string_width(@content) |