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



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/tty/terminal/home.rb', line 12

def 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
end