Class List Method List File List

# Class: String

Inherits:
  Object
  - Object
  - String
  show all
Defined in:
  src/ruby/osx/objc/ruby_addition.rb,
  src/ruby/osx/objc/ruby_addition.rb

## Overview

Utility methods for String.

## Instance Method Summary (collapse)

- - (Object) nsencoding deprecated Deprecated.

  use NKF.guess.

- - (OSX::NSMutableString) to_nsmutablestring deprecated Deprecated.

  use obj#to_ns.

- - (OSX::NSString) to_nsstring deprecated Deprecated.

  use obj#to_ns.

- - (String) to_sel

  Returns Objective-C selector.

- - (Array) unpack_as_pstring

  Returns an array unpacked from Pascal string.

## Instance Method Details

### - (`Object`) nsencoding

Deprecated.

use NKF.guess.

    2
    # File 'src/ruby/osx/objc/ruby_addition.rb', line 2

    def nsencoding; nil; end

### - (`OSX::NSMutableString`) to_nsmutablestring

Deprecated.

use obj#to_ns.

Returns:

- (`OSX::NSMutableString`)

    24
    25
    26
    27
    # File 'src/ruby/osx/objc/ruby_addition.rb', line 24

    def to_nsmutablestring
      warn "#{caller[0]}: to_nsmutablestring is now deprecated and its use is discouraged, please use to_ns instead."
      OSX::NSMutableString.stringWithRubyString(self)
    end

### - (`OSX::NSString`) to_nsstring

Deprecated.

use obj#to_ns.

Returns:

- (`OSX::NSString`)

    17
    18
    19
    20
    # File 'src/ruby/osx/objc/ruby_addition.rb', line 17

    def to_nsstring
      warn "#{caller[0]}: to_nsstring is now deprecated and its use is discouraged, please use to_ns instead."
      OSX::NSString.stringWithRubyString(self)
    end

### - (`String`) to_sel

Returns Objective-C selector.

Returns:

- (`String`)

    31
    32
    33
    34
    35
    # File 'src/ruby/osx/objc/ruby_addition.rb', line 31

    def to_sel
      s = self.dup
      s.instance_variable_set(:@__is_sel__, true)
      return s
    end

### - (`Array`) unpack_as_pstring

Returns an array unpacked from Pascal string.

Returns:

- (`Array`)

    121
    122
    123
    124
    125
    # File 'src/ruby/osx/objc/ruby_addition.rb', line 121

    def unpack_as_pstring
      ary = [self.length]
      ary.concat(self.unpack('C*'))
      return ary
    end