Class: TTY::Terminal::Home

Inherits:
Object
  • Object
show all
Defined in:
lib/tty/terminal/home.rb

Overview

A class responsible for locating user home

Instance Method Summary collapse

Instance Method Details

#homeObject

Find user home



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/tty/terminal/home.rb', line 10

def home
  if (env_home = ENV['HOME'])
    env_home
  else
    begin
      require 'etc'
      File.expand_path("~#{Etc.getlogin}")
    rescue
      TTY::System.windows? ?  'C:/' : '/'
    end
  end
end