Class: HttpHelper
- Inherits:
-
Object
- Object
- HttpHelper
- Defined in:
- lib/httpHelper.rb
Instance Method Summary collapse
-
#get_data(requestPath) ⇒ Hash
Perform a HTTP GET request.
-
#initialize ⇒ HttpHelper
constructor
Constructor method for HttpHelper.
-
#post_data(requestPath, data) ⇒ Hash
Perform a HTTP Post request.
Constructor Details
#initialize ⇒ HttpHelper
Constructor method for HttpHelper. Initialize local data.
14 15 16 17 18 |
# File 'lib/httpHelper.rb', line 14 def initialize() @uri = URI.parse 'https://api.thingdom.io' @path = '/1.1' @request_counter = 0; end |
Instance Method Details
#get_data(requestPath) ⇒ Hash
Perform a HTTP GET request.
26 27 28 |
# File 'lib/httpHelper.rb', line 26 def get_data( requestPath ) do_request( requestPath ) end |
#post_data(requestPath, data) ⇒ Hash
Perform a HTTP Post request.
37 38 39 40 41 42 |
# File 'lib/httpHelper.rb', line 37 def post_data( requestPath, data ) @request_counter += 1 data[:counter] = @request_counter data[:time] = Time.now.strftime( '%Y/%m/%d %H:%M:%S' ) do_request( requestPath, data ) end |