Class: LivePaper::WmTrigger
- Inherits:
-
Trigger
- Object
- BaseObject
- Trigger
- LivePaper::WmTrigger
- Defined in:
- lib/live_paper/wm_trigger.rb
Constant Summary collapse
- WATERMARK_RESOLUTION =
75
- WATERMARK_STRENGTH =
10
- DEFAULT_SUBSCRIPTION =
:month
Constants inherited from BaseObject
BaseObject::AUTH_URL, BaseObject::LP_API_HOST
Instance Attribute Summary collapse
-
#watermark ⇒ Object
Returns the value of attribute watermark.
-
#wm_url ⇒ Object
Returns the value of attribute wm_url.
Attributes inherited from Trigger
Attributes inherited from BaseObject
#date_created, #date_modified, #id, #link, #name
Instance Method Summary collapse
Methods inherited from Trigger
api_url, item_key, list_key, parse
Methods inherited from BaseObject
api_url, #assign_attributes, create, #delete, #errors, get, #initialize, item_key, list, list_key, parse, #rel, request_access_token, rest_request, #save, #update
Constructor Details
This class inherits a constructor from LivePaper::BaseObject
Instance Attribute Details
#watermark ⇒ Object
Returns the value of attribute watermark.
5 6 7 |
# File 'lib/live_paper/wm_trigger.rb', line 5 def watermark @watermark end |
#wm_url ⇒ Object
Returns the value of attribute wm_url.
5 6 7 |
# File 'lib/live_paper/wm_trigger.rb', line 5 def wm_url @wm_url end |
Instance Method Details
#download_watermark ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/live_paper/wm_trigger.rb', line 17 def download_watermark response = WmTrigger.rest_request( self.wm_url, :get, accept: "image/jpg", skip: :x_user_info ) response.body.empty? ? nil : response.body rescue Exception => e puts 'Exception!\n' puts e.response end |
#parse(data) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/live_paper/wm_trigger.rb', line 10 def parse(data) data = JSON.parse(data, symbolize_names: true)[:trigger] assign_attributes data self.wm_url=data[:link].select { |item| item[:rel] == "image" }.first[:href] self end |