diff options
author | Xavier Noria <fxn@hashref.com> | 2010-08-29 23:50:30 +0200 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2010-08-29 23:52:38 +0200 |
commit | 475ea14fd0a84604158ec30d9c718d3c8ae055d6 (patch) | |
tree | 37fa903848fb4eb623aed26a66abbffb1dafb1f4 /railties/guides | |
parent | a302a333f8edc373e299da4c123bafadcc3a1306 (diff) | |
download | rails-475ea14fd0a84604158ec30d9c718d3c8ae055d6.tar.gz rails-475ea14fd0a84604158ec30d9c718d3c8ae055d6.tar.bz2 rails-475ea14fd0a84604158ec30d9c718d3c8ae055d6.zip |
implements String#strip_heredoc
Diffstat (limited to 'railties/guides')
-rw-r--r-- | railties/guides/source/active_support_core_extensions.textile | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile index 696db30efb..dfc4d38112 100644 --- a/railties/guides/source/active_support_core_extensions.textile +++ b/railties/guides/source/active_support_core_extensions.textile @@ -1296,6 +1296,31 @@ Active Support defines 3rd person aliases of +String#start_with?+ and +String#en NOTE: Defined in +active_support/core_ext/string/starts_ends_with.rb+. +h4. +strip_heredoc+ + +The method +strip_heredoc+ strips indentation in heredocs. + +For example in + +<ruby> +if options[:usage] + puts <<-USAGE.strip_heredoc + This command does such and such. + + Supported options are: + -h This message + ... + USAGE +end +</ruby> + +the user would see the usage message aligned against the left margin. + +Technically, it looks for the least indented line in the whole string, and removes +that amount of leading whitespace. + +NOTE: Defined in +active_support/core_ext/string/strip.rb+. + h4. Access h5. +at(position)+ |