Class: MagicMirror::CommandCache

Inherits:
Array
  • Object
show all
Defined in:
lib/magic_mirror/command_cache.rb

Instance Method Summary collapse

Instance Method Details

#<<(value) ⇒ Object



4
5
6
7
8
# File 'lib/magic_mirror/command_cache.rb', line 4

def <<(value)
  #puts "you pushed"
  MagicMirror.mirror.speak_into(value)
  super
end

#resetObject



10
11
12
13
14
# File 'lib/magic_mirror/command_cache.rb', line 10

def reset
  self.clear
  MagicMirror.mirror.speak_into("MagicMirror.clearCommandCache();")
  self
end

#to_embedded_javascriptObject

what if I cached this value?…



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/magic_mirror/command_cache.rb', line 17

def to_embedded_javascript
  string = ""

  string += "<script>"

  time_offset = 40
  self.each_slice(100) do |a|
    string += "setTimeout(function(){"
    string += "z(#{a.to_json});"
    if time_offset == 40
      string += "}, #{0});"
      time_offset+=5
    else
      string += "}, #{time_offset+=5});"
    end
  end

  string += "</script>"
  string
end