Sha256: 68c0af50bca250901a645086b3eb43ef41fc2ea4f8817a9600df0f0af6b0885f

Contents?: true

Size: 831 Bytes

Versions: 10

Compression:

Stored size: 831 Bytes

Contents

module Nytimes
	module Articles
		##
		# If requested in <tt>:fields</tt> for an article search, some articles are returned with a matching thumbnail image. The several thumbnail
		# fields are collected together into a single Thumbnail instance for your convenience. 
		class Thumbnail
			attr_reader :url, :width, :height
			
			def initialize(url, width, height)
				@url = url
				@width = width
				@height = height
			end
			
			def self.init_from_api(api_hash)
				return nil unless !api_hash.nil? && api_hash['small_image_url']
				
				unless api_hash['small_image_width'].nil?
					width = api_hash['small_image_width'].to_i
				end
				
				unless api_hash['small_image_height'].nil?
					height = api_hash['small_image_height'].to_i
				end
				
				new(api_hash['small_image_url'], width, height)
			end
		end
	end
end

Version data entries

10 entries across 10 versions & 3 rubygems

Version Path
harrisj-nytimes-articles-0.1.2 lib/nytimes_articles/thumbnail.rb
harrisj-nytimes-articles-0.1.3 lib/nytimes_articles/thumbnail.rb
harrisj-nytimes-articles-0.2.0 lib/nytimes_articles/thumbnail.rb
harrisj-nytimes-articles-0.2.1 lib/nytimes_articles/thumbnail.rb
harrisj-nytimes-articles-0.3.0 lib/nytimes_articles/thumbnail.rb
harrisj-nytimes-articles-0.4.0 lib/nytimes_articles/thumbnail.rb
taylorbarstow-nytimes-articles-0.2.1 lib/nytimes_articles/thumbnail.rb
taylorbarstow-nytimes-articles-0.3.0 lib/nytimes_articles/thumbnail.rb
nytimes-articles-0.4.1 lib/nytimes_articles/thumbnail.rb
nytimes-articles-0.4.0 lib/nytimes_articles/thumbnail.rb