Module: Get

Included in:
Core
Defined in:
lib/dotfiles/utils/get.rb

Overview

File: get.rb Project: dotfiles-cli Author: exstnce ([email protected]) Created on Sunday, 8th July 2018 5:53:22 pm

Constant Summary collapse

@@root =

~/

File.expand_path('~')+'/'
@@dotfiles =

~/.dotfiles

@@root+'.dotfiles/'

Class Method Summary collapse

Class Method Details

.answerObject



45
46
47
48
49
50
51
52
# File 'lib/dotfiles/utils/get.rb', line 45

def self.answer
  answer = STDIN.gets.chomp

  if answer.strip.downcase == 'y' || answer.strip == ''
    return true
  end
false
end

.exists(name) ⇒ Object



36
37
38
39
40
41
42
43
# File 'lib/dotfiles/utils/get.rb', line 36

def self.exists(name)
  path = path(name)
  unless File.exists?(path)
    puts "#{"Error".red}: #{name} does not exist"
    exit
  end
  path
end

.nameObject



26
27
28
29
30
# File 'lib/dotfiles/utils/get.rb', line 26

def self.name
  print 'Save as: '
  @name = STDIN.gets.chomp.delete(' ')
  check
end

.path(name) ⇒ Object



32
33
34
# File 'lib/dotfiles/utils/get.rb', line 32

def self.path(name)
  @@dotfiles+name+'/'
end