Class | String |
In: |
lib/facets/supplemental/facets/tuple.rb
|
Parent: | Object |
Translates a string in the form on a set of numerical and/or alphanumerical characters separated by non-word characters (eg \W+) into a Tuple. The values of the tuple will be converted to integers if they are purely numerical.
'1.2.3a'.to_t #=> [1,2,"3a"]
It you would like to control the interpretation of each value as it is added to the tuple you can supply a block.
'1.2.3a'.to_t { |v| v.upcase } #=> ["1","2","3A"]
This method calls Tuple.cast_from_string.
# File lib/facets/supplemental/facets/tuple.rb, line 266 def to_t( &yld ) Tuple.cast_from_string( self, &yld ) end