diff options
author | Dan Pickett <dpickett@enlightsolutions.com> | 2011-04-29 19:18:10 -0400 |
---|---|---|
committer | Dan Pickett <dpickett@enlightsolutions.com> | 2011-04-29 19:18:10 -0400 |
commit | 1efaed5af13f876833b3acd614e8d0116812f308 (patch) | |
tree | 8b2dd01afee8b4bdcf976d6a082d9fb89b32d43e /railties/guides/source/active_support_core_extensions.textile | |
parent | 85c8d73642f03410b86ee842edcfe0eba1d4252c (diff) | |
parent | 010dbf7a2fd30f8dabebb3f04fed22c661d6bf80 (diff) | |
download | rails-1efaed5af13f876833b3acd614e8d0116812f308.tar.gz rails-1efaed5af13f876833b3acd614e8d0116812f308.tar.bz2 rails-1efaed5af13f876833b3acd614e8d0116812f308.zip |
Merge branch 'master' of github.com:lifo/docrails
Diffstat (limited to 'railties/guides/source/active_support_core_extensions.textile')
-rw-r--r-- | railties/guides/source/active_support_core_extensions.textile | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile index f89c83e4cd..f2170e120b 100644 --- a/railties/guides/source/active_support_core_extensions.textile +++ b/railties/guides/source/active_support_core_extensions.textile @@ -449,9 +449,9 @@ The predicate +in?+ tests if an object is included in another object. An +Argume Examples of +in?+: <ruby> - 1.in?([1,2]) # => true - "lo".in?("hello") # => true - 25.in?(30..50) # => false +1.in?([1,2]) # => true +"lo".in?("hello") # => true +25.in?(30..50) # => false </ruby> NOTE: Defined in +active_support/core_ext/object/inclusion.rb+. @@ -541,9 +541,9 @@ The default value can be also specified with a block, which is called in the con <ruby> class User attr_accessor :name, :surname - attr_accessor_with_default(:full_name) { - [name, surname].compact.join(" ") - } + attr_accessor_with_default(:full_name) do + [name, surname].compact.join(" ") + end end u = User.new @@ -1223,7 +1223,7 @@ NOTE: Defined in +active_support/core_ext/string/output_safety.rb+. h4. +squish+ -The method +String#squish+ strips leading and trailing whitespace, and substitutes runs of whitespace with a single space each: +The method +squish+ strips leading and trailing whitespace, and substitutes runs of whitespace with a single space each: <ruby> " \n foo\n\r \t bar \n".squish # => "foo bar" @@ -1996,11 +1996,11 @@ Active Support augments the API of arrays to ease certain ways of accessing them [].to(7) # => [] </ruby> -Similarly, +from+ returns the tail from the element at the passed index on: +Similarly, +from+ returns the tail from the element at the passed index to the end. If the index is greater than the length of the array, it returns an empty array. <ruby> %w(a b c d).from(2) # => %w(c d) -%w(a b c d).from(10) # => nil +%w(a b c d).from(10) # => [] [].from(0) # => [] </ruby> |