Class: NSString

Inherits:
Object
  • Object
show all
Defined in:
lib/project/ns_string.rb

Overview

Instance Method Summary collapse

Instance Method Details

#document_pathObject



5
6
7
8
9
10
# File 'lib/project/ns_string.rb', line 5

def document_path
  @@motionconcierge_docs ||= NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, true)[0]
  return self if self.hasPrefix(@@motionconcierge_docs)

  @@motionconcierge_docs.stringByAppendingPathComponent(self)
end

#file_exists?Boolean

Returns:

  • (Boolean)


19
20
21
22
# File 'lib/project/ns_string.rb', line 19

def file_exists?
  path = self.hasPrefix('/') ? self : self.document_path
  NSFileManager.defaultManager.fileExistsAtPath(path)
end

#remove_file!Object



24
25
26
27
28
29
# File 'lib/project/ns_string.rb', line 24

def remove_file!
  ptr = Pointer.new(:id)
  path = self.hasPrefix('/') ? self : self.document_path
  NSFileManager.defaultManager.removeItemAtPath(path, error:ptr)
  ptr[0]
end

#resource_exists?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/project/ns_string.rb', line 31

def resource_exists?
  self.resource_path.file_exists?
end

#resource_pathObject



12
13
14
15
16
17
# File 'lib/project/ns_string.rb', line 12

def resource_path
  @@motionconcierge_resources ||= NSBundle.mainBundle.resourcePath
  return self if self.hasPrefix(@@motionconcierge_resources)

  @@motionconcierge_resources.stringByAppendingPathComponent(self)
end