Class: NSAttributedString

Inherits:
Object show all
Defined in:
ext/accessibility/bridge/bridge.c,
ext/accessibility/bridge/bridge.c

Overview

A 90% drop-in replacement for Cocoa's NSAttributedString class. The most likely to use methods have been bridged. Remaining methods can be bridged upon request.

See Apple's Developer Reference for documentation on the methods available in this class.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.allocObject

LOL, but required to be a drop-in replacement



352
353
354
355
356
357
# File 'ext/accessibility/bridge/bridge.c', line 352

static
VALUE
rb_astring_alloc(VALUE self)
{
  return wrap_nsattributed_string([NSAttributedString alloc]);
}

Instance Method Details

#initWithString(*args) ⇒ Object

TODO: all these methods :(



359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
# File 'ext/accessibility/bridge/bridge.c', line 359

static
VALUE
rb_astring_init_with_string(int argc, VALUE* argv, VALUE self)
{
  if (!argc)
    rb_raise(rb_eArgError, "wrong number of arguments (0 for 1+)");

  NSString*              nsstring = unwrap_nsstring(argv[0]);
  NSAttributedString* old_astring = unwrap_nsattributed_string(self);
  NSAttributedString* new_astring = [old_astring initWithString:nsstring];
  [nsstring release];
  if (old_astring == new_astring)
    return self;
  return wrap_nsattributed_string(new_astring);
}

#isEqualToAttributedString(other) ⇒ Object Also known as: ==

rb_define_method(rb_cAttributedString, "attributesAtIndex", rb_astring_attrs_at_index, -1);



391
392
393
394
395
396
# File 'ext/accessibility/bridge/bridge.c', line 391

static
VALUE
rb_astring_equality(VALUE self, VALUE other)
{
  OBJC_EQUALITY(rb_cAttributedString, unwrap_nsattributed_string);
}

#lengthObject



384
385
386
387
388
389
# File 'ext/accessibility/bridge/bridge.c', line 384

static
VALUE
rb_astring_length(VALUE self)
{
  return ULONG2NUM([unwrap_nsattributed_string(self) length]);
}

#stringObject Also known as: to_s, to_str

rb_define_method(rb_cAttributedString, "initWithAttributedString", rb_astring_init_with_astring, 2);



375
376
377
378
379
380
381
382
# File 'ext/accessibility/bridge/bridge.c', line 375

static
VALUE
rb_astring_string(VALUE self)
{
  NSString* string = [unwrap_nsattributed_string(self) string];
  VALUE     rb_str = wrap_nsstring(string);
  return rb_str;
}