Class: Limbo::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/limbo/client.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.post(hash) ⇒ Object



6
7
8
# File 'lib/limbo/client.rb', line 6

def self.post(hash)
  new(hash).post
end

Instance Method Details

#postObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/limbo/client.rb', line 22

def post
  headers =  { "X-LIMBO-KEY" => Limbo.key,
               "content-type" => "application/json;charset=utf-8" }
  path = '/log'
  request = Net::HTTP::Post.new(path, headers)

  uri = URI(Limbo.uri)
  port = uri.port || 80
  @response = Net::HTTP.start(uri.host, port) do |http|
    http.open_timeout = 5
    http.request(request, body)
  end

  self
end

#posted?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/limbo/client.rb', line 14

def posted?
  200 == response.code.to_i
end

#responseObject



18
19
20
# File 'lib/limbo/client.rb', line 18

def response
  @response
end

#valid_data?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/limbo/client.rb', line 10

def valid_data?
  @valid_data
end