Class: Hahamut::Uploader
- Inherits:
-
Object
- Object
- Hahamut::Uploader
- Defined in:
- lib/hahamut/uploader.rb
Overview
Image Uploader
Constant Summary collapse
- ENDPOINT =
'https://us-central1-hahamut-8888.cloudfunctions.net/' \ 'imagePush?bot_id=%<botid>s' \ '&access_token=%<token>s'
Instance Method Summary collapse
-
#initialize(botid, token) ⇒ Uploader
constructor
A new instance of Uploader.
- #upload(path) ⇒ Object
- #uri ⇒ Object
Constructor Details
#initialize(botid, token) ⇒ Uploader
Returns a new instance of Uploader.
12 13 14 15 |
# File 'lib/hahamut/uploader.rb', line 12 def initialize(botid, token) @botid = botid @token = token end |
Instance Method Details
#upload(path) ⇒ Object
17 18 19 20 21 |
# File 'lib/hahamut/uploader.rb', line 17 def upload(path) http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true create_image http.request(build_request(path)) end |
#uri ⇒ Object
23 24 25 |
# File 'lib/hahamut/uploader.rb', line 23 def uri @uri ||= URI(format(ENDPOINT, botid: @botid, token: @token)) end |