class Object

Public Instance Methods

break_output() click to toggle source
# File lib/utility.rb, line 38
def break_output
  puts ''
end
check_update_message(app) click to toggle source
# File lib/utility.rb, line 30
def check_update_message(app)
  puts "| Checking #{app} for updates...".bold
end
cleanup_message(app) click to toggle source
# File lib/utility.rb, line 34
def cleanup_message(app)
  puts "| Cleaning up #{app}".bold
end
file_or_folder_exists?(file) click to toggle source
# File lib/utility.rb, line 24
def file_or_folder_exists?(file)
  home = ENV['HOME']
  path = "#{home}" "#{file}"
  File.exist?(path)
end
indent(count, char = ' ') click to toggle source
# File lib/utility.rb, line 12
def indent(count, char = ' ')
  gsub(/([^\n]*)(\n|$)/) do
    last_iteration = (Regexp.last_match(1) == '' && Regexp.last_match(2) == '')
    line = ''
    line << (char * count) unless last_iteration
    line << Regexp.last_match(1)
    line << Regexp.last_match(2)
    line
  end
end
run?() click to toggle source
# File lib/utility.rb, line 57
def run?
  return true if System::Update::AUTO_RUN == '--auto'

  print '  - Do you want to perform this action? (y/n) '
  yes_or_no
end
yes_or_no() click to toggle source
# File lib/utility.rb, line 42
def yes_or_no
  str = gets.chomp

  if str == 'y'
    puts '  - Performing...'.colorize(:light_cyan)
    return true
  elsif str == 'n'
    return false
  else
    puts '  - Invalid choice!'.colorize(:red).bold
    print '  - Options are "y" or "n" - Please try again! (y/n) '
    yes_or_no
  end
end