Skip to content

Commit

Permalink
Update docs for Faker::Date with separate examples (#2061)
Browse files Browse the repository at this point in the history
* Update docs for Faker::Date with separate examples

* Correct Active Support spelling
  • Loading branch information
danielTiringer committed Jun 18, 2020
1 parent 2242a97 commit 162e9ba
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
8 changes: 6 additions & 2 deletions doc/default/date.md
Expand Up @@ -3,11 +3,15 @@
```ruby
# Random date between dates
# Keyword arguments: from, to
Faker::Date.between(from: 2.days.ago, to: Date.today) #=> "Wed, 24 Sep 2014"
Faker::Date.between(from: '2014-09-23', to: '2014-09-25') #=> #<Date: 2014-09-24>
# If used with Rails (the Active Support gem), additional options are available:
Faker::Date.between(from: 2.days.ago, to: Date.today) #=> #<Date: 2014-09-24>

# Random date between dates except for certain date
# Keyword arguments: from, to, excepted
Faker::Date.between_except(from: 1.year.ago, to: 1.year.from_now, excepted: Date.today) #=> "Wed, 24 Sep 2014"
Faker::Date.between_except(from: '2014-09-23', to: '2015-09-25', excepted: '2015-01-24') #=> #<Date: 2014-10-03>
# If used with Rails (the Active Support gem), additional options are available:
Faker::Date.between_except(from: 1.year.ago, to: 1.year.from_now, excepted: Date.today) #=> #<Date: 2014-10-03>

# Random date in the future (up to maximum of N days)
# Keyword arguments: days
Expand Down
16 changes: 10 additions & 6 deletions lib/faker/default/date.rb
Expand Up @@ -10,9 +10,11 @@ class << self
# @param to [Date, String] The end of the usable date range.
# @return [Date]
#
# @example
# Faker::Date.between(from: 2.days.ago, to: Date.today)
# #=> #<Date: 2014-09-24>
# @example if used with or without Rails (Active Support)
# Faker::Date.between(from: '2014-09-23', to: '2014-09-25') #=> #<Date: 2014-09-24>
#
# @example if used with Rails (Active Support)
# Faker::Date.between(from: 2.days.ago, to: Date.today) #=> #<Date: 2014-09-24>
#
# @faker.version 1.0.0
def between(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, from:, to:)
Expand All @@ -37,9 +39,11 @@ def between(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, from:, to:)
# @param excepted [Date, String] A date to exclude.
# @return [Date]
#
# @example
# Faker::Date.between_except(from: 1.year.ago, to: 1.year.from_now, excepted: Date.today)
# #=> #<Date: 2014-10-03>
# @example if used with or without Rails (Active Support)
# Faker::Date.between_except(from: '2014-09-23', to: '2015-09-25', excepted: '2015-01-24') #=> #<Date: 2014-10-03>
#
# @example if used with Rails (Active Support)
# Faker::Date.between_except(from: 1.year.ago, to: 1.year.from_now, excepted: Date.today) #=> #<Date: 2014-10-03>
#
# @faker.version 1.6.2
def between_except(legacy_from = NOT_GIVEN, legacy_to = NOT_GIVEN, legacy_excepted = NOT_GIVEN, from:, to:, excepted:)
Expand Down

0 comments on commit 162e9ba

Please sign in to comment.