lib/nytimes_articles/base.rb in harrisj-nytimes-articles-0.1.3 vs lib/nytimes_articles/base.rb in harrisj-nytimes-articles-0.2.0
- old
+ new
@@ -50,9 +50,26 @@
def self.date_field(value)
return nil unless value =~ /^\d{8}$/
Date.strptime(value, "%Y%m%d")
end
+
+ def self.boolean_field(value)
+ case value
+ when nil
+ false
+ when TrueClass
+ true
+ when FalseClass
+ false
+ when 'Y'
+ true
+ when 'N'
+ false
+ else
+ false
+ end
+ end
def self.invoke(params={})
begin
if @@api_key.nil?
raise AuthenticationError, "You must initialize the API key before you run any API queries"
\ No newline at end of file