Sha256: 20986fe8d884675413b7adb7bcf905542dc711aeb277825799ade0d04581084f

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 KB

Contents

# encoding: utf-8

module TTY
  class Terminal
    # Return access to color terminal
    #
    # @return [TTY::Terminal::Color]
    #
    # @api public
    attr_reader :color

    # Output pager
    #
    # @return [TTY::Terminal::Pager]
    #
    # @api public
    attr_reader :pager

    # Initialize a Terminal
    #
    # @api public
    def initialize(options = {})
      @color = Pastel.new
      @echo  = TTY::Terminal::Echo.new
      @pager = TTY::Terminal::Pager
      @home  = Home.new
    end

    # Switch echo on
    #
    # @api public
    def echo_on
      @echo.on
    end

    # Switch echo off
    #
    # @api public
    def echo_off
      @echo.off
    end

    # Echo given block
    #
    # @param [Boolean] is_on
    #
    # @api public
    def echo(is_on = true, &block)
      @echo.echo(is_on, &block)
    end

    # Find user home directory
    #
    # @return [String]
    #
    # @api public
    def home
      @home.home
    end

    # Run text through a dynamically chosen pager
    #
    # @param [String] text
    #   the text to page
    #
    # @api public
    def page(text)
      @pager.page(text)
    end
  end # Terminal
end # TTY

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tty-0.1.1 lib/tty/terminal.rb