Sha256: f4e3f26f11b72bf997063d33557b8c51f248cf4f7b560c4c621f2f4b166e712e

Contents?: true

Size: 762 Bytes

Versions: 1

Compression:

Stored size: 762 Bytes

Contents

module MagicMirror

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

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

    # what if I cached this value?...
    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




  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
magic_mirror-0.1.3 lib/magic_mirror/command_cache.rb