Sha256: 5b59275b2d44c69aede22d9e036ad7fe8b7b8bc0769ecf57fccbe6e32880dbea

Contents?: true

Size: 417 Bytes

Versions: 3

Compression:

Stored size: 417 Bytes

Contents

module Nytimes
	module Articles
		class FacetHash
			def initialize(hash)
				@facets = hash
			end
			
			def [](key)
				case key
				when Symbol
					key = Facet.symbol_name(key)
				when String
					# do nothing
				else
					raise ArgumentError, "Argument to facets hash must be a symbol or string name"
				end
				
				@facets[key]
			end
			
			def self.init_from_api(hash)
				new(hash)
			end
		end
	end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
harrisj-nytimes-articles-0.4.0 lib/nytimes_articles/facet_hash.rb
nytimes-articles-0.4.1 lib/nytimes_articles/facet_hash.rb
nytimes-articles-0.4.0 lib/nytimes_articles/facet_hash.rb