lib/tty/terminal.rb in tty-0.0.9 vs lib/tty/terminal.rb in tty-0.0.10
- old
+ new
@@ -24,13 +24,21 @@
attr_reader :default_height
# @api public
attr_reader :color
+ # Output pager
+ #
+ # @return [Pager]
+ #
+ # @api public
+ attr_reader :pager
+
def initialize
@color = TTY::Terminal::Color.new(self.color?)
@echo = TTY::Terminal::Echo.new
+ @pager = TTY::Terminal::Pager
@default_width = 80
@default_height = 24
end
# Set default width of terminal
@@ -147,18 +155,28 @@
# @api public
def color?
%x{tput colors 2>/dev/null}.to_i > 2
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
@@ -166,10 +184,21 @@
#
# @return [String]
#
# @api public
def home
- @home ||= Home.new.home
+ @home ||= Home.new
+ @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