class Console::Terminal::Text

Public Class Methods

new(output) click to toggle source
# File lib/console/terminal/text.rb, line 27
def initialize(output)
        @output = output
        @styles = {reset: self.reset}
end

Public Instance Methods

[](key) click to toggle source
# File lib/console/terminal/text.rb, line 32
def [] key
        @styles[key]
end
[]=(key, value) click to toggle source
# File lib/console/terminal/text.rb, line 36
def []= key, value
        @styles[key] = value
end
colors?() click to toggle source
# File lib/console/terminal/text.rb, line 40
def colors?
        false
end
print(*arguments) click to toggle source

Print out the given arguments. When the argument is a symbol, look up the style and inject it into the output stream. When the argument is a proc/lambda, call it with self as the argument. When the argument is anything else, write it directly to the output.

print_line(*arguments) click to toggle source

Print out the arguments as per {#print}, followed by the reset sequence and a newline.

puts(*arguments, style: nil) click to toggle source
# File lib/console/terminal/text.rb, line 60
def puts(*arguments, style: nil)
        if style and prefix = self[style]
                @output.write(prefix)
                @output.puts(*arguments)
                @output.write(self.reset)
        else
                @output.puts(*arguments)
        end
end
reset() click to toggle source
# File lib/console/terminal/text.rb, line 47
def reset
end
style(foreground, background = nil, *attributes) click to toggle source
# File lib/console/terminal/text.rb, line 44
def style(foreground, background = nil, *attributes)
end
write(*arguments, style: nil) click to toggle source
# File lib/console/terminal/text.rb, line 50
def write(*arguments, style: nil)
        if style and prefix = self[style]
                @output.write(prefix)
                @output.write(*arguments)
                @output.write(self.reset)
        else
                @output.write(*arguments)
        end
end