Prev | Current Page 107 | Next

Brad Ediger

"Advanced Rails"

.10).overlaps?(3..15) # => true
>> (1..10).overlaps?(13..15) # => false
String
Inflector core_ext/string/inflections.rb
The methods in this file delegate to the Inflector.
??? String#singularize and String#pluralize do what you would think. Corner cases are
more or less supported; you can add custom rules that override the defaults.
"wug".pluralize # => "wugs"
"wugs".singularize # => "wug"
"fish".pluralize # => "fish"
??? String#camelize is used to convert file names to class names; String#underscore does
the opposite.
"action_controller/filters".camelize # => "ActionController::Filters"
"ActionController::Filters".underscore # => "action_controller/filters"
String
String | 73
??? String#tableize converts class names to table names (as in ActiveRecord).
String#classify converts table names to class names.
"ProductCategory".tableize # => "product_categories"
"product_categories".classify # => "ProductCategory"
??? String#constantize tries to interpret the given string as a constant name. This is useful
for looking up classes returned from String#classify.
"ProductCategory".constantize rescue "no class" # => "no class"
class ProductCategory; end
"ProductCategory".constantize # => ProductCategory
String i18n core_ext/string/unicode.rb, core_ext/string/iterators.rb
These files provide interfaces to ActiveSupport::Multibyte for support for multibyte characters.


Pages:
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119