Module: FlickrMocks::Api::Helpers
- Defined in:
- lib/flickr_mocks/api/helpers.rb
Class Method Summary collapse
-
.date(date = nil) ⇒ Object
returns a date string of format YYYY-MM-DD.
-
.valid_date?(date) ⇒ Boolean
returns true when supplied date is of format YYYY-MM-DD.
Class Method Details
.date(date = nil) ⇒ Object
returns a date string of format YYYY-MM-DD. If the supplied date is ambiguous it returns yesterday’s date in the format YYYY-MM-DD. Sample usage:
self.date('2010-10-10')
self.date('yesterday')
9 10 11 |
# File 'lib/flickr_mocks/api/helpers.rb', line 9 def self.date(date=nil) self.valid_date?(date) ? self.parse_date(date) : self.parse_date('yesterday') end |
.valid_date?(date) ⇒ Boolean
returns true when supplied date is of format YYYY-MM-DD. Sample usage:
self.valid_date?('2010-10-10')
16 17 18 19 20 21 22 23 |
# File 'lib/flickr_mocks/api/helpers.rb', line 16 def self.valid_date?(date) begin self.parse_date(date) true rescue false end end |