Class: Bormashino::LocalStorage

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/bormashino/local_storage.rb,
lib/bormashino/mock/local_storage.rb

Direct Known Subclasses

SessionStorage

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeLocalStorage

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

#storeObject (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

#clearObject



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

#lengthObject



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