Class: Bovem::Console
- Inherits:
-
Object
- Object
- Bovem::Console
- Includes:
- Bovem::ConsoleMethods::Interactions, Bovem::ConsoleMethods::Logging, Bovem::ConsoleMethods::Output, Bovem::ConsoleMethods::StyleHandling, Lazier::I18n
- Defined in:
- lib/bovem/console.rb
Overview
This is a text utility wrapper console I/O.
Instance Attribute Summary (collapse)
-
- (Fixnum) indentation
Current indentation width.
-
- (String) indentation_string
The string used for indentation.
Class Method Summary (collapse)
-
+ (Console) instance
Returns a unique instance for Console.
Instance Method Summary (collapse)
-
- (Console) initialize
constructor
Initializes a new Console.
-
- (Fixnum) line_width
Get the width of the terminal.
Methods included from Bovem::ConsoleMethods::Interactions
Methods included from Bovem::ConsoleMethods::Logging
#begin, #debug, #error, #fatal, #get_banner, #info, #status, #warn, #write, #write_banner_aligned
Methods included from Bovem::ConsoleMethods::Output
#format, #format_right, #indent, #reset_indentation, #set_indentation, #with_indentation, #wrap
Methods included from Bovem::ConsoleMethods::StyleHandling
Constructor Details
- (Console) initialize
Initializes a new Console.
601 602 603 604 605 |
# File 'lib/bovem/console.rb', line 601 def initialize @indentation = 0 @indentation_string = " " i18n_setup(:bovem, ::File.absolute_path(::Pathname.new(::File.dirname(__FILE__)).to_s + "/../../locales/")) end |
Instance Attribute Details
- (Fixnum) indentation
Current indentation width.
583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 |
# File 'lib/bovem/console.rb', line 583 class Console attr_accessor :indentation attr_accessor :indentation_string include Lazier::I18n include Bovem::ConsoleMethods::StyleHandling include Bovem::ConsoleMethods::Output include Bovem::ConsoleMethods::Logging include Bovem::ConsoleMethods::Interactions # Returns a unique instance for Console. # # @return [Console] A new instance. def self.instance @instance ||= ::Bovem::Console.new end # Initializes a new Console. def initialize @indentation = 0 @indentation_string = " " i18n_setup(:bovem, ::File.absolute_path(::Pathname.new(::File.dirname(__FILE__)).to_s + "/../../locales/")) end # Get the width of the terminal. # # @return [Fixnum] The current width of the terminal. If not possible to retrieve the width, it returns `80. def line_width begin require "io/console" if !defined?($stdin.winsize) $stdin.winsize[1] rescue 80 end end end |
- (String) indentation_string
The string used for indentation.
583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 |
# File 'lib/bovem/console.rb', line 583 class Console attr_accessor :indentation attr_accessor :indentation_string include Lazier::I18n include Bovem::ConsoleMethods::StyleHandling include Bovem::ConsoleMethods::Output include Bovem::ConsoleMethods::Logging include Bovem::ConsoleMethods::Interactions # Returns a unique instance for Console. # # @return [Console] A new instance. def self.instance @instance ||= ::Bovem::Console.new end # Initializes a new Console. def initialize @indentation = 0 @indentation_string = " " i18n_setup(:bovem, ::File.absolute_path(::Pathname.new(::File.dirname(__FILE__)).to_s + "/../../locales/")) end # Get the width of the terminal. # # @return [Fixnum] The current width of the terminal. If not possible to retrieve the width, it returns `80. def line_width begin require "io/console" if !defined?($stdin.winsize) $stdin.winsize[1] rescue 80 end end end |
Class Method Details
+ (Console) instance
Returns a unique instance for Console.
596 597 598 |
# File 'lib/bovem/console.rb', line 596 def self.instance @instance ||= ::Bovem::Console.new end |
Instance Method Details
- (Fixnum) line_width
Get the width of the terminal.
610 611 612 613 614 615 616 617 |
# File 'lib/bovem/console.rb', line 610 def line_width begin require "io/console" if !defined?($stdin.winsize) $stdin.winsize[1] rescue 80 end end |