Class: Warg::Console::Content
- Inherits:
-
Object
- Object
- Warg::Console::Content
- Defined in:
- lib/warg.rb
Instance Method Summary collapse
-
#initialize(text, console) ⇒ Content
constructor
A new instance of Content.
- #inspect ⇒ Object
- #last_line_length ⇒ Object
- #newline_count ⇒ Object
- #text=(value) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(text, console) ⇒ Content
Returns a new instance of Content.
389 390 391 392 |
# File 'lib/warg.rb', line 389 def initialize(text, console) @text = text.to_s.freeze @console = console end |
Instance Method Details
#inspect ⇒ Object
418 419 420 |
# File 'lib/warg.rb', line 418 def inspect %{#<#{self.class.name} newline_count=#{newline_count} last_line_length=#{last_line_length} text=#{@text.inspect}>} end |
#last_line_length ⇒ Object
404 405 406 407 408 409 410 411 412 |
# File 'lib/warg.rb', line 404 def last_line_length if @text.empty? || @text.end_with?("\n") 0 else # Remove CSI sequences so they don't count against the length of the line because # they are invisible in the terminal @text.lines.last.gsub(/\e\[\d+;\d+;\d+m/, "").length end end |
#newline_count ⇒ Object
400 401 402 |
# File 'lib/warg.rb', line 400 def newline_count @text.count("\n") end |
#text=(value) ⇒ Object
394 395 396 397 398 |
# File 'lib/warg.rb', line 394 def text=(value) @text = value.to_s.freeze @console.reprint_content(self) value end |
#to_s ⇒ Object
414 415 416 |
# File 'lib/warg.rb', line 414 def to_s @text end |