Parse data from string.
# File lib/facets/date.rb, line 427 def to_date #::Date::civil(*ParseDate.parsedate(self)[0..2]) ::Date.new(*::Date._parse(self, false).values_at(:year, :mon, :mday)) end
Convert string to DateTime.
# File lib/facets/date.rb, line 421 def to_datetime date = ::Date._parse(self, false).values_at(:year, :mon, :mday, :hour, :min, :sec).map { |arg| arg || 0 } ::DateTime.civil(*date) end
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/tuple.rb, line 266 def to_t( &yld ) Tuple.cast_from_string( self, &yld ) end
Generated with the Darkfish Rdoc Generator 2.