Class: Godwit::Buffer

Inherits:
Object
  • Object
show all
Defined in:
lib/godwit/buffer.rb

Overview

This class is used to buffer output. It’s used to help out with view switching in the console.

Class Method Summary collapse

Class Method Details

.bufferObject

Returns the buffer.



11
12
13
14
# File 'lib/godwit/buffer.rb', line 11

def buffer
  @buffer ||= ""
  @buffer
end

.buffer=(string) ⇒ Object

Sets the buffer



18
19
20
21
# File 'lib/godwit/buffer.rb', line 18

def buffer=(string)
  @buffer ||= ""
  @buffer = string
end

.clearObject

Clears the buffer.



39
40
41
# File 'lib/godwit/buffer.rb', line 39

def clear
  self.buffer = ""
end

Outputs text with Kernel#print and stores it in the buffer.



25
26
27
28
# File 'lib/godwit/buffer.rb', line 25

def print(string)
  self.buffer += string
  Kernel.print string
end

.puts(string) ⇒ Object

Outputs text with Kernel#puts and stores it in the buffer.



32
33
34
35
# File 'lib/godwit/buffer.rb', line 32

def puts(string)
  self.buffer += (string + "\n")
  Kernel.puts string
end