Sha256: f18c74ce062cb34016d60ce1479aa63101be256cee6eb655dc7e54e6286f2eb0

Contents?: true

Size: 649 Bytes

Versions: 3

Compression:

Stored size: 649 Bytes

Contents

class NSString

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

    @@sugarcube_docs.stringByAppendingPathComponent(self)
  end

  def exists?
    NSFileManager.defaultManager.fileExistsAtPath(self.document)
  end

  def resource
    @@sugarcube_resources ||= NSBundle.mainBundle.resourcePath
    return self if self.hasPrefix(@@sugarcube_resources)

    @@sugarcube_resources.stringByAppendingPathComponent(self)
  end

  def resource_exists?
    NSFileManager.defaultManager.fileExistsAtPath(self.resource)
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sugarcube-0.11.3 lib/sugarcube/nsstring_files.rb
sugarcube-0.11.2 lib/sugarcube/nsstring_files.rb
sugarcube-0.11.1 lib/sugarcube/nsstring_files.rb