Class: HttpMini

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

Constant Summary collapse

OPEN_TIMEOUT =
2
READ_TIMEOUT =
2
IGNORE_ERROR =
true

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, opts = {}) ⇒ HttpMini

Returns a new instance of HttpMini.



17
18
19
20
# File 'lib/http_mini.rb', line 17

def initialize(url, opts = {})
  self.uri = url
  self.opts = opts
end

Instance Attribute Details

#optsObject

Returns the value of attribute opts.



7
8
9
# File 'lib/http_mini.rb', line 7

def opts
  @opts
end

#uriObject

Returns the value of attribute uri.



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

def uri
  @uri
end

Class Method Details

.VERSIONObject



13
14
15
# File 'lib/http_mini.rb', line 13

def self.VERSION
  '0.1.1'
end

Instance Method Details

#deleteObject



38
39
40
# File 'lib/http_mini.rb', line 38

def delete
  request { |http| http.delete(path) }
end

#getObject



26
27
28
# File 'lib/http_mini.rb', line 26

def get
  request { |http| http.get(path) }
end

#headObject



22
23
24
# File 'lib/http_mini.rb', line 22

def head
  request { |http| http.head(path) }
end

#optionsObject



42
43
44
# File 'lib/http_mini.rb', line 42

def options
  request { |http| http.options(path) }
end

#pingObject



46
47
48
# File 'lib/http_mini.rb', line 46

def ping
  success? head
end

#post(data) ⇒ Object



30
31
32
# File 'lib/http_mini.rb', line 30

def post(data)
  request { |http| http.post(path, data) }
end

#put(data) ⇒ Object



34
35
36
# File 'lib/http_mini.rb', line 34

def put(data)
  request { |http| http.put(path, data) }
end