Class: NSCoder
- Defined in:
- lib/cocoa/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, toSize: 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
33 34 35 |
# File 'lib/cocoa/sugarcube-nscoder/nscoder.rb', line 33 def point(key) CGPointFromString(self.decodeObjectForKey(key.to_s)) end |
#rect(key) ⇒ Object
37 38 39 |
# File 'lib/cocoa/sugarcube-nscoder/nscoder.rb', line 37 def rect(key) CGRectFromString(self.decodeObjectForKey(key.to_s)) end |
#set(key, toSize: value) ⇒ Object
45 46 47 48 |
# File 'lib/cocoa/sugarcube-nscoder/nscoder.rb', line 45 def set(key, toBool: value) self.encodeBool(value, forKey: key.to_s) self end |
#size(key) ⇒ Object
41 42 43 |
# File 'lib/cocoa/sugarcube-nscoder/nscoder.rb', line 41 def size(key) CGSizeFromString(self.decodeObjectForKey(key.to_s)) end |