Class: NSMutableAttributedString
- Defined in:
- lib/hotcocoa/core_extensions/nsmutable_attributed_string.rb
Overview
HotCocoa extensions to the NSMutableAttributeString class.
Instance Method Summary collapse
-
#+(s) ⇒ Object
Just like
String#+
. -
#<<(s) ⇒ Object
Just like
String#<<
. -
#[](r) ⇒ HotCocoa::NSRangedProxyAttributedString
deprecated
Deprecated.
Who uses this? Removing this in HotCocoa 0.7 unless there are reasonable objections
-
#[]=(r, s) ⇒ Object
Replace an arbitrary range of an attributed string with another string.
-
#attributes ⇒ HotCocoa::NSRangedProxyAttributeHash
Hash of attributes used in the attributed string.
-
#with_attributes(attributes = {}) ⇒ NSMutableAttributedString
Make a new attributed string with the string of the receiver and the attributes passed as arguments.
Instance Method Details
#+(s) ⇒ Object
Should this be declared on NSAttributedString instead
Just like String#+
32 33 34 35 36 |
# File 'lib/hotcocoa/core_extensions/nsmutable_attributed_string.rb', line 32 def + s attributed_string = mutableCopy attributed_string << s attributed_string end |
#<<(s) ⇒ Object
Just like String#<<
19 20 21 22 23 24 25 26 |
# File 'lib/hotcocoa/core_extensions/nsmutable_attributed_string.rb', line 19 def << s case s when String mutableString.appendString s else appendAttributedString s end end |
#[](r) ⇒ HotCocoa::NSRangedProxyAttributedString
Who uses this? Removing this in HotCocoa 0.7 unless there are reasonable objections
Create a range proxy for an arbitrary portion of the receiver.
56 57 58 |
# File 'lib/hotcocoa/core_extensions/nsmutable_attributed_string.rb', line 56 def [] r HotCocoa::NSRangedProxyAttributedString.new self, r end |
#[]=(r, s) ⇒ Object
Replace an arbitrary range of an attributed string with another string.
65 66 67 68 69 70 71 72 |
# File 'lib/hotcocoa/core_extensions/nsmutable_attributed_string.rb', line 65 def []= r, s case s when String replaceCharactersInRange r.to_NSRange(length), withString: s else replaceCharactersInRange r.to_NSRange(length), withAttributedString: s end end |
#attributes ⇒ HotCocoa::NSRangedProxyAttributeHash
Should this be declared on NSAttributedString instead
Hash of attributes used in the attributed string.
44 45 46 |
# File 'lib/hotcocoa/core_extensions/nsmutable_attributed_string.rb', line 44 def attributes HotCocoa::NSRangedProxyAttributedString.new(self, 0..-1).attributes end |
#with_attributes(attributes = {}) ⇒ NSMutableAttributedString
Should this be declared on NSAttributedString instead
Make a new attributed string with the string of the receiver and the attributes passed as arguments.
13 14 15 |
# File 'lib/hotcocoa/core_extensions/nsmutable_attributed_string.rb', line 13 def with_attributes attributes = {} string.with_attributes attributes end |