Class: NSCoder
- Defined in:
- lib/cocoa/sugarcube-nscoder/nscoder.rb,
lib/ios/sugarcube-nscoder/nscoder.rb,
lib/osx/sugarcube-nscoder/nscoder.rb,
lib/cocoa/sugarcube-nscoder/nscoder.rb
Overview
Hash-like access for NSCoder. Converts the ‘key` argument to a String, because Symbols can mess things up.
Class Method Summary collapse
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #bool(key) ⇒ Object
- #double(key) ⇒ Object
- #float(key) ⇒ Object
- #int(key) ⇒ Object
- #key?(key) ⇒ Boolean
- #point(key) ⇒ Object
- #rect(key) ⇒ Object
- #set(key, toInt: value) ⇒ Object
- #size(key) ⇒ Object
Class Method Details
Instance Method Details
#[](key) ⇒ Object
5 6 7 |
# File 'lib/cocoa/sugarcube-nscoder/nscoder.rb', line 5 def [] key self.decodeObjectForKey(key.to_s) end |
#[]=(key, value) ⇒ Object
9 10 11 |
# File 'lib/cocoa/sugarcube-nscoder/nscoder.rb', line 9 def []= key, value self.encodeObject(value, forKey: key.to_s) end |
#bool(key) ⇒ Object
17 18 19 |
# File 'lib/cocoa/sugarcube-nscoder/nscoder.rb', line 17 def bool(key) self.decodeBoolForKey(key.to_s) end |
#double(key) ⇒ Object
21 22 23 |
# File 'lib/cocoa/sugarcube-nscoder/nscoder.rb', line 21 def double(key) self.decodeDoubleForKey(key.to_s) end |
#float(key) ⇒ Object
25 26 27 |
# File 'lib/cocoa/sugarcube-nscoder/nscoder.rb', line 25 def float(key) self.decodeFloatForKey(key.to_s) end |
#int(key) ⇒ Object
29 30 31 |
# File 'lib/cocoa/sugarcube-nscoder/nscoder.rb', line 29 def int(key) self.decodeIntegerForKey(key.to_s) end |
#key?(key) ⇒ Boolean
13 14 15 |
# File 'lib/cocoa/sugarcube-nscoder/nscoder.rb', line 13 def key?(key) self.containsValueForKey(key.to_s) end |
#point(key) ⇒ Object
3 4 5 |
# File 'lib/ios/sugarcube-nscoder/nscoder.rb', line 3 def point(key) CGPointFromString(self.decodeObjectForKey(key.to_s)) end |
#rect(key) ⇒ Object
7 8 9 |
# File 'lib/ios/sugarcube-nscoder/nscoder.rb', line 7 def rect(key) CGRectFromString(self.decodeObjectForKey(key.to_s)) end |
#set(key, toInt: value) ⇒ Object
15 16 17 18 |
# File 'lib/ios/sugarcube-nscoder/nscoder.rb', line 15 def set(key, toPoint: value) self.encodeObject(NSStringFromCGPoint(value), forKey: key.to_s) self end |
#size(key) ⇒ Object
11 12 13 |
# File 'lib/ios/sugarcube-nscoder/nscoder.rb', line 11 def size(key) CGSizeFromString(self.decodeObjectForKey(key.to_s)) end |