aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorFrancesco Rodriguez <lrodriguezsanc@gmail.com>2012-09-14 23:02:37 -0500
committerFrancesco Rodriguez <lrodriguezsanc@gmail.com>2012-09-14 23:02:37 -0500
commit00fef0a76c589bd69c1048e8bae7d66e0a8b7457 (patch)
tree19166df52dc996764a6c59b6162d1f05f4a80664 /activesupport/lib
parentb0e943381becdb882c93fe699e324bf0e6c99806 (diff)
downloadrails-00fef0a76c589bd69c1048e8bae7d66e0a8b7457.tar.gz
rails-00fef0a76c589bd69c1048e8bae7d66e0a8b7457.tar.bz2
rails-00fef0a76c589bd69c1048e8bae7d66e0a8b7457.zip
update AS/values and AS/xml_mini docs [ci skip]
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/values/time_zone.rb87
-rw-r--r--activesupport/lib/active_support/xml_mini/libxml.rb2
-rw-r--r--activesupport/lib/active_support/xml_mini/nokogiri.rb2
-rw-r--r--activesupport/lib/active_support/xml_mini/rexml.rb2
4 files changed, 54 insertions, 39 deletions
diff --git a/activesupport/lib/active_support/values/time_zone.rb b/activesupport/lib/active_support/values/time_zone.rb
index cc3e6a4bf3..231d61da96 100644
--- a/activesupport/lib/active_support/values/time_zone.rb
+++ b/activesupport/lib/active_support/values/time_zone.rb
@@ -2,29 +2,36 @@ require 'active_support/core_ext/object/blank'
require 'active_support/core_ext/object/try'
module ActiveSupport
- # The TimeZone class serves as a wrapper around TZInfo::Timezone instances. It allows us to do the following:
+ # The TimeZone class serves as a wrapper around TZInfo::Timezone instances.
+ # It allows us to do the following:
#
- # * Limit the set of zones provided by TZInfo to a meaningful subset of 142 zones.
- # * Retrieve and display zones with a friendlier name (e.g., "Eastern Time (US & Canada)" instead of "America/New_York").
+ # * Limit the set of zones provided by TZInfo to a meaningful subset of 142
+ # zones.
+ # * Retrieve and display zones with a friendlier name
+ # (e.g., "Eastern Time (US & Canada)" instead of "America/New_York").
# * Lazily load TZInfo::Timezone instances only when they're needed.
- # * Create ActiveSupport::TimeWithZone instances via TimeZone's +local+, +parse+, +at+ and +now+ methods.
+ # * Create ActiveSupport::TimeWithZone instances via TimeZone's +local+,
+ # +parse+, +at+ and +now+ methods.
#
- # If you set <tt>config.time_zone</tt> in the Rails Application, you can access this TimeZone object via <tt>Time.zone</tt>:
+ # If you set <tt>config.time_zone</tt> in the Rails Application, you can
+ # access this TimeZone object via <tt>Time.zone</tt>:
#
# # application.rb:
# class Application < Rails::Application
- # config.time_zone = "Eastern Time (US & Canada)"
+ # config.time_zone = 'Eastern Time (US & Canada)'
# end
#
- # Time.zone # => #<TimeZone:0x514834...>
- # Time.zone.name # => "Eastern Time (US & Canada)"
- # Time.zone.now # => Sun, 18 May 2008 14:30:44 EDT -04:00
+ # Time.zone # => #<TimeZone:0x514834...>
+ # Time.zone.name # => "Eastern Time (US & Canada)"
+ # Time.zone.now # => Sun, 18 May 2008 14:30:44 EDT -04:00
#
- # The version of TZInfo bundled with Active Support only includes the definitions necessary to support the zones
- # defined by the TimeZone class. If you need to use zones that aren't defined by TimeZone, you'll need to install the TZInfo gem
- # (if a recent version of the gem is installed locally, this will be used instead of the bundled version.)
+ # The version of TZInfo bundled with Active Support only includes the
+ # definitions necessary to support the zones defined by the TimeZone class.
+ # If you need to use zones that aren't defined by TimeZone, you'll need to
+ # install the TZInfo gem (if a recent version of the gem is installed locally,
+ # this will be used instead of the bundled version.)
class TimeZone
- # Keys are Rails TimeZone names, values are TZInfo identifiers
+ # Keys are Rails TimeZone names, values are TZInfo identifiers.
MAPPING = {
"International Date Line West" => "Pacific/Midway",
"Midway Island" => "Pacific/Midway",
@@ -175,8 +182,8 @@ module ActiveSupport
UTC_OFFSET_WITH_COLON = '%s%02d:%02d'
UTC_OFFSET_WITHOUT_COLON = UTC_OFFSET_WITH_COLON.sub(':', '')
- # Assumes self represents an offset from UTC in seconds (as returned from Time#utc_offset)
- # and turns this into an +HH:MM formatted string.
+ # Assumes self represents an offset from UTC in seconds (as returned from
+ # Time#utc_offset) and turns this into an +HH:MM formatted string.
#
# TimeZone.seconds_to_utc_offset(-21_600) # => "-06:00"
def self.seconds_to_utc_offset(seconds, colon = true)
@@ -193,8 +200,8 @@ module ActiveSupport
# Create a new TimeZone object with the given name and offset. The
# offset is the number of seconds that this time zone is offset from UTC
- # (GMT). Seconds were chosen as the offset unit because that is the unit that
- # Ruby uses to represent time zone offsets (see Time#utc_offset).
+ # (GMT). Seconds were chosen as the offset unit because that is the unit
+ # that Ruby uses to represent time zone offsets (see Time#utc_offset).
def initialize(name, utc_offset = nil, tzinfo = nil)
self.class.send(:require_tzinfo)
@@ -228,7 +235,7 @@ module ActiveSupport
result
end
- # Compare #name and TZInfo identifier to a supplied regexp, returning true
+ # Compare #name and TZInfo identifier to a supplied regexp, returning +true+
# if a match is found.
def =~(re)
return true if name =~ re || MAPPING[name] =~ re
@@ -239,33 +246,37 @@ module ActiveSupport
"(GMT#{formatted_offset}) #{name}"
end
- # Method for creating new ActiveSupport::TimeWithZone instance in time zone of +self+ from given values.
+ # Method for creating new ActiveSupport::TimeWithZone instance in time zone
+ # of +self+ from given values.
#
- # Time.zone = "Hawaii" # => "Hawaii"
- # Time.zone.local(2007, 2, 1, 15, 30, 45) # => Thu, 01 Feb 2007 15:30:45 HST -10:00
+ # Time.zone = 'Hawaii' # => "Hawaii"
+ # Time.zone.local(2007, 2, 1, 15, 30, 45) # => Thu, 01 Feb 2007 15:30:45 HST -10:00
def local(*args)
time = Time.utc_time(*args)
ActiveSupport::TimeWithZone.new(nil, self, time)
end
- # Method for creating new ActiveSupport::TimeWithZone instance in time zone of +self+ from number of seconds since the Unix epoch.
+ # Method for creating new ActiveSupport::TimeWithZone instance in time zone
+ # of +self+ from number of seconds since the Unix epoch.
#
- # Time.zone = "Hawaii" # => "Hawaii"
+ # Time.zone = 'Hawaii' # => "Hawaii"
# Time.utc(2000).to_f # => 946684800.0
# Time.zone.at(946684800.0) # => Fri, 31 Dec 1999 14:00:00 HST -10:00
def at(secs)
Time.at(secs).utc.in_time_zone(self)
end
- # Method for creating new ActiveSupport::TimeWithZone instance in time zone of +self+ from parsed string.
+ # Method for creating new ActiveSupport::TimeWithZone instance in time zone
+ # of +self+ from parsed string.
#
- # Time.zone = "Hawaii" # => "Hawaii"
- # Time.zone.parse('1999-12-31 14:00:00') # => Fri, 31 Dec 1999 14:00:00 HST -10:00
+ # Time.zone = 'Hawaii' # => "Hawaii"
+ # Time.zone.parse('1999-12-31 14:00:00') # => Fri, 31 Dec 1999 14:00:00 HST -10:00
#
- # If upper components are missing from the string, they are supplied from TimeZone#now:
+ # If upper components are missing from the string, they are supplied from
+ # TimeZone#now:
#
- # Time.zone.now # => Fri, 31 Dec 1999 14:00:00 HST -10:00
- # Time.zone.parse('22:30:00') # => Fri, 31 Dec 1999 22:30:00 HST -10:00
+ # Time.zone.now # => Fri, 31 Dec 1999 14:00:00 HST -10:00
+ # Time.zone.parse('22:30:00') # => Fri, 31 Dec 1999 22:30:00 HST -10:00
def parse(str, now=now)
date_parts = Date._parse(str)
return if date_parts.empty?
@@ -282,8 +293,8 @@ module ActiveSupport
end
end
- # Returns an ActiveSupport::TimeWithZone instance representing the current time
- # in the time zone represented by +self+.
+ # Returns an ActiveSupport::TimeWithZone instance representing the current
+ # time in the time zone represented by +self+.
#
# Time.zone = 'Hawaii' # => "Hawaii"
# Time.zone.now # => Wed, 23 Jan 2008 20:24:27 HST -10:00
@@ -296,23 +307,27 @@ module ActiveSupport
tzinfo.now.to_date
end
- # Adjust the given time to the simultaneous time in the time zone represented by +self+. Returns a
- # Time.utc() instance -- if you want an ActiveSupport::TimeWithZone instance, use Time#in_time_zone() instead.
+ # Adjust the given time to the simultaneous time in the time zone
+ # represented by +self+. Returns a Time.utc() instance -- if you want an
+ # ActiveSupport::TimeWithZone instance, use Time#in_time_zone() instead.
def utc_to_local(time)
tzinfo.utc_to_local(time)
end
- # Adjust the given time to the simultaneous time in UTC. Returns a Time.utc() instance.
+ # Adjust the given time to the simultaneous time in UTC. Returns a
+ # Time.utc() instance.
def local_to_utc(time, dst=true)
tzinfo.local_to_utc(time, dst)
end
- # Available so that TimeZone instances respond like TZInfo::Timezone instances
+ # Available so that TimeZone instances respond like TZInfo::Timezone
+ # instances.
def period_for_utc(time)
tzinfo.period_for_utc(time)
end
- # Available so that TimeZone instances respond like TZInfo::Timezone instances
+ # Available so that TimeZone instances respond like TZInfo::Timezone
+ # instances.
def period_for_local(time, dst=true)
tzinfo.period_for_local(time, dst)
end
diff --git a/activesupport/lib/active_support/xml_mini/libxml.rb b/activesupport/lib/active_support/xml_mini/libxml.rb
index 26556598fd..47a2824186 100644
--- a/activesupport/lib/active_support/xml_mini/libxml.rb
+++ b/activesupport/lib/active_support/xml_mini/libxml.rb
@@ -37,7 +37,7 @@ module LibXML #:nodoc:
module Node #:nodoc:
CONTENT_ROOT = '__content__'.freeze
- # Convert XML document to hash
+ # Convert XML document to hash.
#
# hash::
# Hash to merge the converted element into.
diff --git a/activesupport/lib/active_support/xml_mini/nokogiri.rb b/activesupport/lib/active_support/xml_mini/nokogiri.rb
index bb0a52bdcf..7398d4fa82 100644
--- a/activesupport/lib/active_support/xml_mini/nokogiri.rb
+++ b/activesupport/lib/active_support/xml_mini/nokogiri.rb
@@ -40,7 +40,7 @@ module ActiveSupport
module Node #:nodoc:
CONTENT_ROOT = '__content__'.freeze
- # Convert XML document to hash
+ # Convert XML document to hash.
#
# hash::
# Hash to merge the converted element into.
diff --git a/activesupport/lib/active_support/xml_mini/rexml.rb b/activesupport/lib/active_support/xml_mini/rexml.rb
index a2a87337a6..5c7c78bf70 100644
--- a/activesupport/lib/active_support/xml_mini/rexml.rb
+++ b/activesupport/lib/active_support/xml_mini/rexml.rb
@@ -8,7 +8,7 @@ module ActiveSupport
CONTENT_KEY = '__content__'.freeze
- # Parse an XML Document string or IO into a simple hash
+ # Parse an XML Document string or IO into a simple hash.
#
# Same as XmlSimple::xml_in but doesn't shoot itself in the foot,
# and uses the defaults from Active Support.