Class: NSAttributedString

Inherits:
Object show all
Defined in:
lib/hotcocoa/core_extensions/nsattributed_string.rb

Overview

HotCocoa extensions to the NSAttributedString class.

Instance Method Summary collapse

Instance Method Details

#+(s) ⇒ Object

Just like String#+



17
18
19
20
21
# File 'lib/hotcocoa/core_extensions/nsattributed_string.rb', line 17

def + s
  attributed_string = mutableCopy
  attributed_string << s
  attributed_string
end

#[](r) ⇒ Object

Similar to String#[], but only supports ranges at the moment.



35
36
37
# File 'lib/hotcocoa/core_extensions/nsattributed_string.rb', line 35

def [] r
  attributedSubstringFromRange r.relative_to(length)
end

#attributesHotCocoa::NSRangedProxyAttributeHash

Hash of attributes used in the attributed string.



27
28
29
# File 'lib/hotcocoa/core_extensions/nsattributed_string.rb', line 27

def attributes
  HotCocoa::NSRangedProxyAttributedString.new(self, 0..-1).attributes
end

#with_attributes(attributes = {}) ⇒ NSMutableAttributedString

Make a new attributed string with the string of the receiver and the attributes passed as arguments.



11
12
13
# File 'lib/hotcocoa/core_extensions/nsattributed_string.rb', line 11

def with_attributes attributes = {}
  string.with_attributes attributes
end