Sha256: 6b68fa0fbb05a37eeb979101e2da82af69fe26bf18ebdb7c9b3e4e826cd70719
Contents?: true
Size: 612 Bytes
Versions: 1
Compression:
Stored size: 612 Bytes
Contents
module Celerity class ViewerConnection def self.create(host, port) socket = TCPSocket.new(host, port) require "json" new(socket) end def initialize(socket) @socket = socket end def render_html(html, url) send_data({'method' => 'page_changed', 'html' => html, 'url' => url}.to_json) end def save(path = nil) send_data({'method' => 'save', 'path' => path}.to_json) end def close @socket.close end private def send_data(data) @socket.write ["Content-Length: #{data.size}", data].join("\n\n") end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
jarib-celerity-0.0.6.16 | lib/celerity/viewer_connection.rb |