Method: Client#initialize

Defined in:
lib/text_tunnel/client.rb

#initialize(port, file_path) ⇒ Client

Establishes initial connection to text_tunneld server



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/text_tunnel/client.rb', line 27

def initialize(port, file_path)
  @file_path = file_path

  file_name = File.basename(@file_path)
  file_data = File.exist?(@file_path) ? File.read(@file_path) : ""

  response = RestClient.post "http://localhost:#{port}/files",
    :name => file_name,
    :data => file_data
  raise UnexpectedResponseError.new(response) unless response.code == 201
  @location = response.headers[:location]
  @etag = response.headers[:etag]
end