Class: Pipl::Image
Instance Attribute Summary collapse
-
#thumbnail_token ⇒ Object
Returns the value of attribute thumbnail_token.
-
#url ⇒ Object
Returns the value of attribute url.
Attributes inherited from Field
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ Image
constructor
A new instance of Image.
- #thumbnail_url(params = {}) ⇒ Object
Methods inherited from Field
base_params_from_hash, extra_metadata, from_hash, #is_searchable?, #to_hash
Methods included from Utils
alnum_chars, alpha_chars, date_to_str, is_valid_url?, str_to_date, titleize, to_utf8
Constructor Details
#initialize(params = {}) ⇒ Image
Returns a new instance of Image.
389 390 391 392 393 |
# File 'lib/pipl/fields.rb', line 389 def initialize(params={}) super params @url = params[:url] @thumbnail_token = params[:thumbnail_token] end |
Instance Attribute Details
#thumbnail_token ⇒ Object
Returns the value of attribute thumbnail_token.
387 388 389 |
# File 'lib/pipl/fields.rb', line 387 def thumbnail_token @thumbnail_token end |
#url ⇒ Object
Returns the value of attribute url.
387 388 389 |
# File 'lib/pipl/fields.rb', line 387 def url @url end |
Instance Method Details
#thumbnail_url(params = {}) ⇒ Object
395 396 397 398 399 400 401 402 |
# File 'lib/pipl/fields.rb', line 395 def thumbnail_url(params={}) return unless @thumbnail_token opts = {width: 100, height: 100, favicon: true, zoom_face: true, use_https: false}.merge(params) schema = opts.delete(:use_https) ? 'https': 'http' query_params = ["token=#{@thumbnail_token}"] + opts.map { |k, v| "#{k}=#{v}" unless v.nil? } "#{schema}://thumb.pipl.com/image?#{query_params.compact.join('&')}" end |