Module: Trashinfo

Defined in:
lib/trashinfo.rb

Class Method Summary collapse

Class Method Details

.new(path) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/trashinfo.rb', line 4

def self.new (path)
  trashinfo_string = "    [Trash Info]\n    Path=\#{CGI.escape(File.expand_path path)}\n    DeletionDate=\#{Time.now.strftime('%Y-%m-%dT%H:%M:%S')}\n  DESKTOP\nend\n"

.parse(trashinfo) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/trashinfo.rb', line 12

def self.parse (trashinfo)
  regex = /\A\[Trash Info\]\nPath=(?<path>\S+)\nDeletionDate=(?<deletion_date>\S+)/m

  matches = regex.match trashinfo

  parts = {
    :path => CGI.unescape(matches[:path]),
    :deletion_date => matches[:deletion_date]
  }
end