Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #8848 (new enhancement)

Opened 11 months ago

Last modified 5 months ago

[PATCH][DOCS] ActiveSupport::CoreExtensions::Numeric::Time examples

Reported by: dlehman Assigned to: core
Priority: normal Milestone: 2.x
Component: ActiveSupport Version: edge
Severity: normal Keywords: docs, documentation, activesupport
Cc:

Description

This patch improves the Numeric Time documentation.

Attachments

docs_numeric_time.diff (3.2 kB) - added by dlehman on 07/03/07 06:02:02.
docs_numeric_time.2.diff (5.9 kB) - added by jeremymcanally on 11/08/07 05:18:31.
Fixed markup and added some niceties

Change History

07/03/07 06:02:02 changed by dlehman

  • attachment docs_numeric_time.diff added.

07/03/07 09:51:52 changed by Henrik N

I don't like the pseudo return values – you have

# Returns the number of days for the specified number of fortnights 
# 
# 2.fortnights 
# # => 28 days

but in script/console:

>> 2.fortnights
=> 2419200

Perhaps instead something like

# => 2419200 # seconds == 28 days

?

11/08/07 05:18:03 changed by jeremymcanally

+1

Looks good just needed some markup fixes and a fix in accordance with the above comment.

11/08/07 05:18:31 changed by jeremymcanally

  • attachment docs_numeric_time.2.diff added.

Fixed markup and added some niceties

(follow-up: ↓ 4 ) 12/05/07 14:58:12 changed by marcel

I agree with Henrik N about the pseudo values being misleading. Would apply this if the changes his proposed are made.

(in reply to: ↑ 3 ) 12/05/07 15:03:16 changed by jeremymcanally

Replying to marcel:

I agree with Henrik N about the pseudo values being misleading. Would apply this if the changes his proposed are made.

The problem is that "28 days" or whatever is what irb and script/console give you when you run the examples.

>> 2.fortnights
=> 28 days

This is because #inspect returns the "pseudo-value" rather than the real value like #to_s does.

>> x = 2.fortnights
=> 28 days
>> x
=> 28 days
>> x.to_s
=> "2419200"
>> x.inspect
=> "28 days"

Perhaps the real value should be indicated also, similar to Henriks suggestions but in reverse.