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
#current, #inferred, #last_seen, #valid_since
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, extract_rate_limits, is_valid_url?, str_to_date, titleize, to_utf8
Constructor Details
#initialize(params = {}) ⇒ Image
Returns a new instance of Image.
397 398 399 400 401 |
# File 'lib/pipl/fields.rb', line 397 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.
395 396 397 |
# File 'lib/pipl/fields.rb', line 395 def thumbnail_token @thumbnail_token end |
#url ⇒ Object
Returns the value of attribute url.
395 396 397 |
# File 'lib/pipl/fields.rb', line 395 def url @url end |
Instance Method Details
#thumbnail_url(params = {}) ⇒ Object
403 404 405 406 407 408 409 410 411 412 |
# File 'lib/pipl/fields.rb', line 403 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' tokens = @thumbnail_token.gsub(/&dsid=.*/,'') tokens += ',' + opts.delete(:fallback).thumbnail_token.gsub(/&dsid=.*/,'') if opts[:fallback] query_params = ["tokens=#{tokens}"] + opts.map { |k, v| "#{k}=#{v}" unless v.nil? } "#{schema}://thumb.pipl.com/image?#{query_params.compact.join('&')}" end |