Class: MagicMirror::CommandCache
- Inherits:
-
Array
- Object
- Array
- MagicMirror::CommandCache
- Defined in:
- lib/magic_mirror/command_cache.rb
Instance Method Summary collapse
- #<<(value) ⇒ Object
- #reset ⇒ Object
-
#to_embedded_javascript ⇒ Object
what if I cached this value?…
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 |
#reset ⇒ Object
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_javascript ⇒ Object
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 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 |