Module: MyCore::File::ClassMethods

Defined in:
lib/my_core/file.rb

Instance Method Summary collapse

Instance Method Details

#creation_time(file) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/my_core/file.rb', line 15

def creation_time(file)
  require 'open3'
  require 'time'
   Time.parse( Open3.popen3("mdls", 
    "-name","kMDItemContentCreationDate", 
    "-raw", file)[1].read)
end

#string_to_file(string, file) ⇒ Object

Writes string to file.



10
11
12
# File 'lib/my_core/file.rb', line 10

def string_to_file(string,file)
  File.open(file,'w') {|f| f.write(string) }
end

#to_string(file) ⇒ Object

Converts file to string.



5
6
7
# File 'lib/my_core/file.rb', line 5

def to_string(file)
  IO.read(file)
end