lib/healthety/transmission.rb in healthety-0.0.1 vs lib/healthety/transmission.rb in healthety-0.0.2

- old
+ new

@@ -1,18 +1,22 @@ require "socket" require "json" module Healthety class Transmission - def initialize(host, port) - @host = host + def initialize(server, port) + @server = server @port = port + @host = Socket.gethostname @socket = UDPSocket.new end - def send(name, value) - data = {:name => name, :value => value}.to_json - @socket.send(data, 0, @host, @port) + def send(name, value, created_at) + data = { + :name => name, :value => value, + :created_at => created_at, :host => @host + }.to_json + @socket.send(data, 0, @server, @port) $stdout << "#{name}: #{value}\n" end end end