Class: DOM::LocalStorage
- Inherits:
-
Object
- Object
- DOM::LocalStorage
- Defined in:
- opal/opal-jquery/local_storage.rb
Instance Method Summary (collapse)
- - (Object) [](key)
- - (Object) []=(key, value)
- - (Object) clear
- - (Object) delete(key)
-
- (LocalStorage) initialize(storage)
constructor
A new instance of LocalStorage.
Constructor Details
- (LocalStorage) initialize(storage)
Returns a new instance of LocalStorage
3 4 5 |
# File 'opal/opal-jquery/local_storage.rb', line 3 def initialize(storage) @storage = storage end |
Instance Method Details
- (Object) [](key)
14 15 16 17 18 19 |
# File 'opal/opal-jquery/local_storage.rb', line 14 def [](key) %x{ var value = #@storage.getItem(key); return value == null ? nil : value; } end |
- (Object) []=(key, value)
7 8 9 10 11 12 |
# File 'opal/opal-jquery/local_storage.rb', line 7 def []=(key, value) %x{ #@storage.setItem(key, value); return value; } end |
- (Object) clear
25 26 27 |
# File 'opal/opal-jquery/local_storage.rb', line 25 def clear `#@storage.clear()` end |
- (Object) delete(key)
21 22 23 |
# File 'opal/opal-jquery/local_storage.rb', line 21 def delete(key) `#@storage.removeItem(key)` end |