Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ci skip] Update documentation for Range#to_formatted_s #19128

Merged
merged 1 commit into from
Feb 28, 2015

Conversation

davydovanton
Copy link
Contributor

Added information about default :db format and added information about custom formats 馃帀

@kaspth
Copy link
Contributor

kaspth commented Feb 28, 2015

I don't think we should tell people to replace and break the RANGE_FORMATS, but extend it. Instead your example could be Range::RANGE_FORMATS[:example] = ->(start, stop) { ... }.

@davydovanton
Copy link
Contributor Author

@kaspth yes, you're right, thanks! 鉂わ笍

@davydovanton
Copy link
Contributor Author

@kaspth fixed this

@davydovanton davydovanton force-pushed the update-doc-range-to-s branch 2 times, most recently from d63eb23 to 5b8ed45 Compare February 28, 2015 16:15
@kaspth
Copy link
Contributor

kaspth commented Feb 28, 2015

I'd love it if we could make the documentation here more consistent with Date's to_formatted_s:

# Convert to a formatted string. See DATE_FORMATS for predefined formats.
#
# This method is aliased to <tt>to_s</tt>.
#
# date = Date.new(2007, 11, 10) # => Sat, 10 Nov 2007
#
# date.to_formatted_s(:db) # => "2007-11-10"
# date.to_s(:db) # => "2007-11-10"
#
# date.to_formatted_s(:short) # => "10 Nov"
# date.to_formatted_s(:long) # => "November 10, 2007"
# date.to_formatted_s(:long_ordinal) # => "November 10th, 2007"
# date.to_formatted_s(:rfc822) # => "10 Nov 2007"
# date.to_formatted_s(:iso8601) # => "2007-11-10"
#
# == Adding your own date formats to to_formatted_s
# You can add your own formats to the Date::DATE_FORMATS hash.
# Use the format name as the hash key and either a strftime string
# or Proc instance that takes a date argument as the value.
#
# # config/initializers/date_formats.rb
# Date::DATE_FORMATS[:month_and_year] = '%B %Y'
# Date::DATE_FORMATS[:short_ordinal] = ->(date) { date.strftime("%B #{date.day.ordinalize}") }
def to_formatted_s(format = :default)
鉂わ笍

@davydovanton
Copy link
Contributor Author

@kaspth fixed this too 馃槂

# == Adding your own range formats to to_formatted_s
# You can add your own formats to the Range::RANGE_FORMATS hash.
# Use the format name as the hash key and either a Proc instance
# that takes a start and stop arguments as the value.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove a: that takes a start and stop arguments as the value.

@davydovanton
Copy link
Contributor Author

@kaspth fixed all. Thanks for review! 馃挌 馃挍 鉂わ笍

@kaspth
Copy link
Contributor

kaspth commented Feb 28, 2015

No problem, 馃憤. The documentation here is way better because of your work 鉂わ笍

kaspth added a commit that referenced this pull request Feb 28, 2015
[ci skip] Update documentation for Range#to_formatted_s
@kaspth kaspth merged commit 1db5ecf into rails:master Feb 28, 2015
@kaspth
Copy link
Contributor

kaspth commented Feb 28, 2015

Holy crap! You got the 50000th commit to Rails 馃槈

@davydovanton davydovanton deleted the update-doc-range-to-s branch February 28, 2015 16:43
@davydovanton
Copy link
Contributor Author

WOW! 馃帀 thanks! 馃専

@vipulnsward
Copy link
Member

馃帀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants