Class: Bormashino::LocalStorage
- Inherits:
-
Object
- Object
- Bormashino::LocalStorage
- Includes:
- Singleton
- Defined in:
- lib/bormashino/local_storage.rb,
lib/bormashino/mock/local_storage.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#store ⇒ Object
readonly
Returns the value of attribute store.
Instance Method Summary collapse
- #clear ⇒ Object
- #get_item(key_name) ⇒ Object
-
#initialize ⇒ LocalStorage
constructor
A new instance of LocalStorage.
- #key(index) ⇒ Object
- #length ⇒ Object
- #remove_item(key_name) ⇒ Object
- #set_item(key_name, key_value) ⇒ Object
Constructor Details
#initialize ⇒ LocalStorage
Returns a new instance of LocalStorage.
9 10 11 |
# File 'lib/bormashino/local_storage.rb', line 9 def initialize @storage = JS.global[:localStorage] end |
Instance Attribute Details
#store ⇒ Object (readonly)
Returns the value of attribute store.
6 7 8 |
# File 'lib/bormashino/mock/local_storage.rb', line 6 def store @store end |
Instance Method Details
#clear ⇒ Object
33 34 35 |
# File 'lib/bormashino/local_storage.rb', line 33 def clear @storage.call(:clear) end |
#get_item(key_name) ⇒ Object
21 22 23 |
# File 'lib/bormashino/local_storage.rb', line 21 def get_item(key_name) @storage.call(:getItem, key_name).to_rb end |
#key(index) ⇒ Object
17 18 19 |
# File 'lib/bormashino/local_storage.rb', line 17 def key(index) @storage.call(:key, index).to_rb end |
#length ⇒ Object
13 14 15 |
# File 'lib/bormashino/local_storage.rb', line 13 def length @storage[:length].to_rb end |
#remove_item(key_name) ⇒ Object
29 30 31 |
# File 'lib/bormashino/local_storage.rb', line 29 def remove_item(key_name) @storage.call(:removeItem, key_name) end |
#set_item(key_name, key_value) ⇒ Object
25 26 27 |
# File 'lib/bormashino/local_storage.rb', line 25 def set_item(key_name, key_value) @storage.call(:setItem, key_name, key_value) end |