lib/tty/terminal.rb in tty-0.0.6 vs lib/tty/terminal.rb in tty-0.0.7

- old
+ new

@@ -26,10 +26,11 @@ # @api public attr_reader :color def initialize @color = TTY::Terminal::Color.new(self.color?) + @echo = TTY::Terminal::Echo.new @default_width = 80 @default_height = 24 end # Set default width of terminal @@ -146,29 +147,29 @@ # @api public def color? %x{tput colors 2>/dev/null}.to_i > 2 end + def echo_on + @echo.on + end + + def echo_off + @echo.off + end + + # @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 ||= if (env_home = ENV['HOME']) - env_home - else - begin - require 'etc' - File.expand_path("~#{Etc.getlogin}") - rescue - if TTY::System.windows? - "C:/" - else - "/" - end - end - end + @home ||= Home.new.home end end # Terminal end # TTY