Parent

Forgery::Date

Public Class Methods

date(options={}) click to toggle source
# File lib/forgery/forgery/date.rb, line 45
def self.date(options={})
  options = {:future => false, :past => false, :min_delta => 0, :max_delta => 7300}.merge(options)

  #Apply our delta to today
  ::Date.today + delta(options)
end
day() click to toggle source
# File lib/forgery/forgery/date.rb, line 41
def self.day
  1 + rand(31)
end
day_of_week(options={}) click to toggle source
# File lib/forgery/forgery/date.rb, line 9
def self.day_of_week(options={})
  options = {:abbr => false}.merge(options)

  if (options[:abbr])
    DAYS_ABBR.random.unextend
  else
    DAYS.random.unextend
  end
end
month(options={}) click to toggle source
# File lib/forgery/forgery/date.rb, line 19
def self.month(options={})
  options = {:abbr => false, :numerical => false}.merge(options)

  if (options[:numerical])
    1 + rand(12)
  else
    if (options[:abbr])
      MONTHS_ABBR.random.unextend
    else
      MONTHS.random.unextend
    end
  end

end
year(options={}) click to toggle source
# File lib/forgery/forgery/date.rb, line 34
def self.year(options={})
  options = {:future => false, :past => false, :min_delta => 0, :max_delta => 20}.merge(options)

  #Apply our delta to this year
  DateTime.now.year + delta(options)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.