Sha256: b5de9e851e16354d84331e019f2874c5388b74ef645c909c80ddd42ca674ddfc

Contents?: true

Size: 548 Bytes

Versions: 5

Compression:

Stored size: 548 Bytes

Contents

# -*- encoding: utf-8 -*-

module TTY
  class Terminal

    # A class responsible for locating user home
    class Home

      # Find user home
      #
      # @api public
      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

    end #Home
  end # Terminal
end # TTY

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
tty-0.0.11 lib/tty/terminal/home.rb
tty-0.0.10 lib/tty/terminal/home.rb
tty-0.0.9 lib/tty/terminal/home.rb
tty-0.0.8 lib/tty/terminal/home.rb
tty-0.0.7 lib/tty/terminal/home.rb