### Home Classes Methods

### In Files

- lib/facets/date.rb
- lib/facets/tuple.rb
- lib/facets/random.rb

### Parent

Object

### Methods

- #to_date
- #to_datetime
- #to_t
- #to_time

### Included Modules

- Random::StringExtensions

### Files

- README.rdoc

### Class/Module Index

Quicksearch

- Random
- Random::ArrayExtensions
- Random::HashExtensions
- Random::IntegerExtensions
- Random::NumericExtensions
- Random::RangeExtensions
- Random::StringExtensions
- Random::StringExtensions::Self
- FileUtils
- FileUtils::DryRun
- FileUtils::NoWrite
- FileUtils::Verbose
- Digest
- Digest::Class
- Digest::Instance
- Multiton
- Multiton::Inclusive
- Multiton::MetaMethods
- URI
- URI::Hash
- URI::Kernel
- Argvector
- Argvector
- ERB
- ERB::OpenTemplate
- Enumerable
- Enumerable::Arguments
- GetoptLong
- GetoptLong::DSL
- Memoizable
- Memoizable::Copy
- Numeric
- Numeric::Multipliers
- Object
- Object::ArgVector
- Timer
- Timer::Dummy
- Array
- BasicObject
- CGI
- Cloneable
- Continuation
- Date
- DateTime
- Equitable
- File
- Find
- Hash
- Instantiable
- Integer
- Interval
- Kernel
- Math
- Module
- Net
- NilClass
- NullClass
- OpEsc
- OpenStruct
- Pathname
- Platform
- Range
- RbConfig
- Set
- Shellwords
- String
- StringScanner
- Time
- Tuple
- YAML
- Zlib

No matching classes.

# String

### Public Instance Methods

to_date() click to toggle source

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

to_datetime() click to toggle source

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

to_t( &yld ) click to toggle source

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

to_time(form = :utc) click to toggle source

    # File lib/facets/date.rb, line 416
    def to_time(form = :utc)
      ::Time.__send__("#{form}_time", *::Date._parse(self, false).values_at(:year, :mon, :mday, :hour, :min, :sec).map{|arg| arg || 0 })
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.