class NSString

Shamelessly extracted from sugarcube github.com/rubymotion/sugarcube/blob/master/lib/cocoa/sugarcube-files/nsstring.rb

Public Instance Methods

document_path() click to toggle source
# File lib/project/ext/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?() click to toggle source
# File lib/project/ext/ns_string.rb, line 19
def file_exists?
  path = self.hasPrefix('/') ? self : self.document_path
  NSFileManager.defaultManager.fileExistsAtPath(path)
end
remove_file!() click to toggle source
# File lib/project/ext/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?() click to toggle source
# File lib/project/ext/ns_string.rb, line 31
def resource_exists?
  self.resource_path.file_exists?
end
resource_path() click to toggle source
# File lib/project/ext/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