class YeelightCli::TCPSocketClient

The class simply wrapes the TCPSocket client

Public Class Methods

new(host, port) click to toggle source
# File lib/yeelight_cli/tcp_socket_client.rb, line 5
def initialize(host, port)
  @host = host
  @port = port
end

Public Instance Methods

request(cmd) click to toggle source
# File lib/yeelight_cli/tcp_socket_client.rb, line 10
def request(cmd)
  socket = TCPSocket.open(@host, @port)
  socket.puts(cmd)
  json_data = socket.gets.chomp
  socket.close

  JSON.parse(json_data)
end