Class: Speedtest::UploadWorker
- Inherits:
-
Object
- Object
- Speedtest::UploadWorker
- Includes:
- Celluloid
- Defined in:
- lib/speedtest/upload_worker.rb
Instance Method Summary collapse
-
#initialize(url, logger) ⇒ UploadWorker
constructor
A new instance of UploadWorker.
- #upload(content) ⇒ Object
Constructor Details
#initialize(url, logger) ⇒ UploadWorker
7 8 9 10 |
# File 'lib/speedtest/upload_worker.rb', line 7 def initialize(url, logger) @url = url @logger = logger end |
Instance Method Details
#upload(content) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/speedtest/upload_worker.rb', line 12 def upload(content) status = ThreadStatus.new(false, 0) page = HTTParty.post(@url, :body => { "content" => content }, timeout: 10) @logger.debug "upload response body = [#{page.body}]" unless page.code / 100 == 2 error "GET #{url} failed with code #{page.code}" status.error = true end status.size = page.body.split('=')[1].to_i status end |