class Bovem::Console

This is a text utility wrapper console I/O.

@attribute indentation

@return [Fixnum] Current indentation width.

@attribute indentation_string

@return [String] The string used for indentation.

@attribute [r] i18n

@return [I18n] A i18n helper.

Attributes

i18n[R]
indentation[RW]
indentation_string[RW]

Public Class Methods

instance() click to toggle source

Returns a unique instance for Console.

@return [Console] A new instance.

# File lib/bovem/console.rb, line 701
def self.instance
  @instance ||= Bovem::Console.new
end
new() click to toggle source

Initializes a new Console.

# File lib/bovem/console.rb, line 706
def initialize
  @indentation = 0
  @indentation_string = " "
  @i18n = Bovem::I18n.new(root: "bovem.console", path: Bovem::Application::LOCALE_ROOT)
end

Public Instance Methods

line_width() click to toggle source

Get the width of the terminal.

@return [Fixnum] The current width of the terminal. If not possible to retrieve the width, it returns `80.

# File lib/bovem/console.rb, line 715
def line_width
  require "io/console" unless defined?($stdin.winsize)
  $stdin.winsize[1]
rescue
  80
end