Class: String

### Home Classes Methods

### In Files

- lib/ferret/number_tools.rb

### Parent

Object

### Methods

- #to_date_lex
- #to_date_time_lex
- #to_i_lex
- #to_time_lex

### Files

- MIT-LICENSE
- README
- TODO
- TUTORIAL

### Class/Module Index

Quicksearch

- Ferret
- Ferret::BlankSlate
- Ferret::BoostMixin
- Ferret::Browser
- Ferret::Browser::Controller
- Ferret::Browser::Delegator
- Ferret::Browser::DocumentController
- Ferret::Browser::ErrorController
- Ferret::Browser::HelpController
- Ferret::Browser::HomeController
- Ferret::Browser::TermController
- Ferret::Browser::TermVectorController
- Ferret::Browser::ViewHelper
- Ferret::Document
- Ferret::Field
- Ferret::FieldSymbol
- Ferret::FieldSymbolMethods
- Ferret::FileNotFoundError
- Ferret::Index
- Ferret::Index::FieldInfo
- Ferret::Index::FieldInfos
- Ferret::Index::Index
- Ferret::Index::IndexReader
- Ferret::Index::IndexWriter
- Ferret::Index::LazyDoc
- Ferret::Index::LazyDoc::LazyDocData
- Ferret::Index::TermDocEnum
- Ferret::Index::TermEnum
- Ferret::Index::TermVector
- Ferret::Index::TermVector::TVOffsets
- Ferret::Index::TermVector::TVTerm
- Ferret::ParseError
- Ferret::QueryParser
- Ferret::QueryParser::QueryParseException
- Ferret::Search
- Ferret::Search::BooleanQuery
- Ferret::Search::BooleanQuery::BooleanClause
- Ferret::Search::ConstantScoreQuery
- Ferret::Search::Explanation
- Ferret::Search::Filter
- Ferret::Search::FilteredQuery
- Ferret::Search::FuzzyQuery
- Ferret::Search::Hit
- Ferret::Search::MatchAllQuery
- Ferret::Search::MultiSearcher
- Ferret::Search::MultiTermQuery
- Ferret::Search::PhraseQuery
- Ferret::Search::PrefixQuery
- Ferret::Search::Query
- Ferret::Search::QueryFilter
- Ferret::Search::RangeFilter
- Ferret::Search::RangeQuery
- Ferret::Search::Searcher
- Ferret::Search::Sort
- Ferret::Search::SortField
- Ferret::Search::Spans
- Ferret::Search::Spans::SpanFirstQuery
- Ferret::Search::Spans::SpanMultiTermQuery
- Ferret::Search::Spans::SpanNearQuery
- Ferret::Search::Spans::SpanNotQuery
- Ferret::Search::Spans::SpanOrQuery
- Ferret::Search::Spans::SpanPrefixQuery
- Ferret::Search::Spans::SpanTermQuery
- Ferret::Search::TermQuery
- Ferret::Search::TopDocs
- Ferret::Search::TypedRangeFilter
- Ferret::Search::TypedRangeQuery
- Ferret::Search::WildcardQuery
- Ferret::StateError
- Ferret::Store
- Ferret::Store::Directory
- Ferret::Store::FSDirectory
- Ferret::Store::Lock
- Ferret::Store::Lock::LockError
- Ferret::Store::RAMDirectory
- WEBrick
- WEBrick::FerretBrowserHandler
- Date
- DateTime
- FileUtils
- Float
- Integer
- String
- Symbol
- Time

No matching classes.

# String

### Public Instance Methods

to_date_lex() click to toggle source

Convert a string to a Date. This method will only work on strings that match the format %Y%m%d %H%M%S, otherwise the result will be unpredictable.

    # File lib/ferret/number_tools.rb, line 134
    def to_date_lex
      return Date.strptime(self + "-02-01", "%Y-%m-%d")
    end

to_date_time_lex() click to toggle source

Convert a string to a DateTime. This method will only work on strings that match the format %Y%m%d %H%M%S, otherwise the result will be unpredictable.

    # File lib/ferret/number_tools.rb, line 140
    def to_date_time_lex
      return DateTime.strptime(self + "-01-01", "%Y-%m-%d %H:%M:%S")
    end

to_i_lex() click to toggle source

Convert a string to an integer. This method will only work on strings that were previously created with Integer#to_s_lex, otherwise the result will be unpredictable.

    # File lib/ferret/number_tools.rb, line 115
    def to_i_lex
      if (self[0] == --)
        return self[(Integer::LEN_STR_SIZE + 1)..-1].to_i -
          10 ** (self.size - Integer::LEN_STR_SIZE - 1)
      else
        return self[Integer::LEN_STR_SIZE..-1].to_i
      end
    end

to_time_lex() click to toggle source

Convert a string to a Time. This method will only work on strings that match the format %Y%m%d %H%M%S, otherwise the result will be unpredictable.

    # File lib/ferret/number_tools.rb, line 126
    def to_time_lex
      vals = []
      self.gsub(/(?:^|[- :])(\d+)/) {vals << $1.to_i; $&}
      Time.mktime(*vals)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.