Sha256: 9f8a1dbc62737fb467d28a25ce9f6dbf064776b967f3ed91d9659c1bb3f4c9c1

Contents?: true

Size: 855 Bytes

Versions: 62

Compression:

Stored size: 855 Bytes

Contents

class NSString

  # @return [NSURL]
  def nsurl
    @url ||= NSURL.alloc.initWithString(self)
  end

  # @return [NSURL]
  def fileurl
    @fileurl ||= NSURL.fileURLWithPath(self)
  end

  def escape_url
    CFURLCreateStringByAddingPercentEscapes(
            nil,
            self,
            nil,
            "!*'();:@&=+$,/?%#[]",
            CFStringConvertNSStringEncodingToEncoding(NSUTF8StringEncoding)
            )
  end

  def unescape_url
    CFURLCreateStringByReplacingPercentEscapes(
            nil,
            self,
            ""
            )
  end

  def remove_accents
    # removes diacritics by using a lossy conversion
    ascii = self.dataUsingEncoding(NSASCIIStringEncoding, allowLossyConversion: true)

    # turn it back into a string
    return NSString.alloc.initWithData(ascii, encoding: NSASCIIStringEncoding)
  end

end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
sugarcube-2.12.2 lib/cocoa/sugarcube-foundation/nsstring.rb
sugarcube-2.12.1 lib/cocoa/sugarcube-foundation/nsstring.rb
sugarcube-2.12.0 lib/cocoa/sugarcube-foundation/nsstring.rb
sugarcube-2.11.1 lib/cocoa/sugarcube-foundation/nsstring.rb
sugarcube-2.11.0 lib/cocoa/sugarcube-foundation/nsstring.rb
sugarcube-2.10.0 lib/cocoa/sugarcube-foundation/nsstring.rb
sugarcube-2.9.1 lib/cocoa/sugarcube-foundation/nsstring.rb
sugarcube-2.8.2 lib/cocoa/sugarcube-foundation/nsstring.rb
sugarcube-2.8.1 lib/cocoa/sugarcube-foundation/nsstring.rb
sugarcube-2.8.0 lib/cocoa/sugarcube-foundation/nsstring.rb
sugarcube-2.7.1 lib/cocoa/sugarcube-foundation/nsstring.rb
sugarcube-2.7.0 lib/cocoa/sugarcube-foundation/nsstring.rb
sugarcube-2.6.0 lib/cocoa/sugarcube-foundation/nsstring.rb
sugarcube-2.5.0 lib/cocoa/sugarcube-foundation/nsstring.rb
sugarcube-2.4.2 lib/cocoa/sugarcube-foundation/nsstring.rb
sugarcube-2.4.1 lib/cocoa/sugarcube-foundation/nsstring.rb
sugarcube-2.4.0 lib/cocoa/sugarcube-foundation/nsstring.rb
sugarcube-2.3.0 lib/cocoa/sugarcube-foundation/nsstring.rb
sugarcube-2.2.0 lib/cocoa/sugarcube-foundation/nsstring.rb
sugarcube-2.1.5 lib/cocoa/sugarcube-foundation/nsstring.rb