diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2008-05-25 12:29:00 +0100 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2008-05-25 12:29:00 +0100 |
commit | 98dc582742779081e71e697fcdf8d9ae2b421b16 (patch) | |
tree | f5680eef86e689a10d0f75434ba6a4e94829e439 /activesupport/lib/active_support/core_ext | |
parent | 6277fd91133a3566333612857510d74de60d67f4 (diff) | |
download | rails-98dc582742779081e71e697fcdf8d9ae2b421b16.tar.gz rails-98dc582742779081e71e697fcdf8d9ae2b421b16.tar.bz2 rails-98dc582742779081e71e697fcdf8d9ae2b421b16.zip |
Merge docrails.
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
Diffstat (limited to 'activesupport/lib/active_support/core_ext')
6 files changed, 28 insertions, 24 deletions
diff --git a/activesupport/lib/active_support/core_ext/hash/conversions.rb b/activesupport/lib/active_support/core_ext/hash/conversions.rb index a023118885..2c606b401b 100644 --- a/activesupport/lib/active_support/core_ext/hash/conversions.rb +++ b/activesupport/lib/active_support/core_ext/hash/conversions.rb @@ -212,7 +212,7 @@ module ActiveSupport #:nodoc: nil # If the type is the only element which makes it then # this still makes the value nil, except if type is - # a xml node(where type['value'] is a Hash) + # a XML node(where type['value'] is a Hash) elsif value['type'] && value.size == 1 && !value['type'].is_a?(::Hash) nil else diff --git a/activesupport/lib/active_support/core_ext/integer/even_odd.rb b/activesupport/lib/active_support/core_ext/integer/even_odd.rb index cfc6b4c6d6..b1d1e28062 100644 --- a/activesupport/lib/active_support/core_ext/integer/even_odd.rb +++ b/activesupport/lib/active_support/core_ext/integer/even_odd.rb @@ -3,10 +3,14 @@ module ActiveSupport #:nodoc: module Integer #:nodoc: # For checking if a fixnum is even or odd. # - # 1.even? # => false - # 1.odd? # => true - # 2.even? # => true - # 2.odd? # => false + # 2.even? # => true + # 2.odd? # => false + # 1.even? # => false + # 1.odd? # => true + # 0.even? # => true + # 0.odd? # => false + # -1.even? # => false + # -1.odd? # => true module EvenOdd def multiple_of?(number) self % number == 0 diff --git a/activesupport/lib/active_support/core_ext/object/misc.rb b/activesupport/lib/active_support/core_ext/object/misc.rb index a3637d7a8a..8384a12327 100644 --- a/activesupport/lib/active_support/core_ext/object/misc.rb +++ b/activesupport/lib/active_support/core_ext/object/misc.rb @@ -48,7 +48,7 @@ class Object yield ActiveSupport::OptionMerger.new(self, options) end - # A duck-type assistant method. For example, ActiveSupport extends Date + # A duck-type assistant method. For example, Active Support extends Date # to define an acts_like_date? method, and extends Time to define # acts_like_time?. As a result, we can do "x.acts_like?(:time)" and # "x.acts_like?(:date)" to do duck-type-safe comparisons, since classes that diff --git a/activesupport/lib/active_support/core_ext/string/unicode.rb b/activesupport/lib/active_support/core_ext/string/unicode.rb index ba16d4d866..5e20534d1d 100644 --- a/activesupport/lib/active_support/core_ext/string/unicode.rb +++ b/activesupport/lib/active_support/core_ext/string/unicode.rb @@ -17,17 +17,17 @@ module ActiveSupport #:nodoc: # string overrides can also be called through the +chars+ proxy. # # name = 'Claus Müller' - # name.reverse #=> "rell??M sualC" - # name.length #=> 13 + # name.reverse # => "rell??M sualC" + # name.length # => 13 # - # name.chars.reverse.to_s #=> "rellüM sualC" - # name.chars.length #=> 12 + # name.chars.reverse.to_s # => "rellüM sualC" + # name.chars.length # => 12 # # # All the methods on the chars proxy which normally return a string will return a Chars object. This allows # method chaining on the result of any of these methods. # - # name.chars.reverse.length #=> 12 + # name.chars.reverse.length # => 12 # # The Char object tries to be as interchangeable with String objects as possible: sorting and comparing between # String and Char work like expected. The bang! methods change the internal string representation in the Chars diff --git a/activesupport/lib/active_support/core_ext/time/conversions.rb b/activesupport/lib/active_support/core_ext/time/conversions.rb index edca5b8a98..9054008309 100644 --- a/activesupport/lib/active_support/core_ext/time/conversions.rb +++ b/activesupport/lib/active_support/core_ext/time/conversions.rb @@ -59,7 +59,7 @@ module ActiveSupport #:nodoc: # Converts a Time object to a Date, dropping hour, minute, and second precision. # # my_time = Time.now # => Mon Nov 12 22:59:51 -0500 2007 - # my_time.to_date #=> Mon, 12 Nov 2007 + # my_time.to_date # => Mon, 12 Nov 2007 # # your_time = Time.parse("1/13/2009 1:13:03 P.M.") # => Tue Jan 13 13:13:03 -0500 2009 # your_time.to_date # => Tue, 13 Jan 2009 diff --git a/activesupport/lib/active_support/core_ext/time/zones.rb b/activesupport/lib/active_support/core_ext/time/zones.rb index cf28d0fa95..079ecdd48e 100644 --- a/activesupport/lib/active_support/core_ext/time/zones.rb +++ b/activesupport/lib/active_support/core_ext/time/zones.rb @@ -10,21 +10,21 @@ module ActiveSupport #:nodoc: attr_accessor :zone_default # Returns the TimeZone for the current request, if this has been set (via Time.zone=). - # If Time.zone has not been set for the current request, returns the TimeZone specified in config.time_zone + # If <tt>Time.zone</tt> has not been set for the current request, returns the TimeZone specified in <tt>config.time_zone</tt>. def zone Thread.current[:time_zone] || zone_default end - # Sets Time.zone to a TimeZone object for the current request/thread. + # Sets <tt>Time.zone</tt> to a TimeZone object for the current request/thread. # # This method accepts any of the following: # - # * a Rails TimeZone object - # * an identifier for a Rails TimeZone object (e.g., "Eastern Time (US & Canada)", -5.hours) - # * a TZInfo::Timezone object - # * an identifier for a TZInfo::Timezone object (e.g., "America/New_York") + # * A Rails TimeZone object. + # * An identifier for a Rails TimeZone object (e.g., "Eastern Time (US & Canada)", <tt>-5.hours</tt>). + # * A TZInfo::Timezone object. + # * An identifier for a TZInfo::Timezone object (e.g., "America/New_York"). # - # Here's an example of how you might set Time.zone on a per request basis -- current_user.time_zone + # Here's an example of how you might set <tt>Time.zone</tt> on a per request basis -- <tt>current_user.time_zone</tt> # just needs to return a string identifying the user's preferred TimeZone: # # class ApplicationController < ActionController::Base @@ -38,7 +38,7 @@ module ActiveSupport #:nodoc: Thread.current[:time_zone] = get_zone(time_zone) end - # Allows override of Time.zone locally inside supplied block; resets Time.zone to existing value when done + # Allows override of <tt>Time.zone</tt> locally inside supplied block; resets <tt>Time.zone</tt> to existing value when done. def use_zone(time_zone) old_zone, ::Time.zone = ::Time.zone, get_zone(time_zone) yield @@ -46,7 +46,7 @@ module ActiveSupport #:nodoc: ::Time.zone = old_zone end - # Returns Time.zone.now when config.time_zone is set, otherwise just returns Time.now. + # Returns <tt>Time.zone.now</tt> when <tt>config.time_zone</tt> is set, otherwise just returns <tt>Time.now</tt>. def current ::Time.zone_default ? ::Time.zone.now : ::Time.now end @@ -65,16 +65,16 @@ module ActiveSupport #:nodoc: end end - # Returns the simultaneous time in Time.zone. + # Returns the simultaneous time in <tt>Time.zone</tt>. # # Time.zone = 'Hawaii' # => 'Hawaii' # Time.utc(2000).in_time_zone # => Fri, 31 Dec 1999 14:00:00 HST -10:00 # - # This method is similar to Time#localtime, except that it uses Time.zone as the local zone + # This method is similar to Time#localtime, except that it uses <tt>Time.zone</tt> as the local zone # instead of the operating system's time zone. # # You can also pass in a TimeZone instance or string that identifies a TimeZone as an argument, - # and the conversion will be based on that zone instead of Time.zone. + # and the conversion will be based on that zone instead of <tt>Time.zone</tt>. # # Time.utc(2000).in_time_zone('Alaska') # => Fri, 31 Dec 1999 15:00:00 AKST -09:00 def in_time_zone(zone = ::Time.zone) |