class Sortme::Path
Public Class Methods
custom()
click to toggle source
# File lib/sortme/path.rb, line 31 def self.custom puts "Enter video path" video_path = gets.chomp puts "Enter music path" music_path = gets.chomp puts "Enter picture path" picture_path = gets.chomp save video_path, music_path, picture_path end
default_mac()
click to toggle source
# File lib/sortme/path.rb, line 51 def self.default_mac picture_path = "#{@@mac_home}/Pictures" video_path = "#{@@mac_home}/Movies" music_path = "#{@@mac_home}/Music" save video_path, music_path, picture_path end
default_windows()
click to toggle source
# File lib/sortme/path.rb, line 66 def self.default_windows picture_path = video_path = music_path = save video_path, music_path, picture_path end
get()
click to toggle source
# File lib/sortme/path.rb, line 44 def self.get home = File.expand_path("~") settings = "#{home}/sortme_settings.json" json = File.read(settings) JSON.parse(json) end
mac?()
click to toggle source
# File lib/sortme/path.rb, line 23 def self.mac? /darwin/ =~ RUBY_PLATFORM end
save(video_path, music_path, picture_path)
click to toggle source
# File lib/sortme/path.rb, line 59 def self.save(video_path, music_path, picture_path) home = File.expand_path("~") system "echo '{\"video\":\"#{video_path}\",\"picture\":\"#{picture_path}\" ,\"music\":\"#{music_path}\"}' > #{home}/sortme_settings.json" end
set()
click to toggle source
# File lib/sortme/path.rb, line 5 def self.set puts "Do you want to use default paths? (type y if you are unsure) (y/n) " choice = gets.chomp.downcase @@mac_home = home = File.expand_path("~") if choice=="y" && mac? default_mac elsif choice=="y" && windows? default_windows elsif choice=="custom" custom else p "oops! run again" exit end end
windows?()
click to toggle source
# File lib/sortme/path.rb, line 27 def self.windows? /cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM end