### Home Classes Methods

### In Files

- lib/chronic/ordinal.rb

### Parent

Tag

### Methods

- ::scan
- #to_s

### Files

- LICENSE

### Class/Module Index

Quicksearch

- Chronic
- Chronic::Date
- Chronic::Grabber
- Chronic::Handler
- Chronic::Handlers
- Chronic::MiniDate
- Chronic::Numerizer
- Chronic::Ordinal
- Chronic::Parser
- Chronic::Pointer
- Chronic::Repeater
- Chronic::Scalar
- Chronic::Season
- Chronic::Separator
- Chronic::Sign
- Chronic::Span
- Chronic::Tag
- Chronic::Time
- Chronic::TimeZone
- Chronic::Token

No matching classes.

# Chronic::Ordinal

### Public Class Methods

scan(tokens, options) click to toggle source

Scan an Array of Token objects and apply any necessary Ordinal tags to each token.

tokens - An Array of tokens to scan. options - The Hash of options specified in Chronic::parse.

Returns an Array of tokens.

    # File lib/chronic/ordinal.rb, line 11
    def self.scan(tokens, options)
      tokens.each_index do |i|
        if tokens[i].word =~ /^(\d+)(st|nd|rd|th|\.)$/
            ordinal = $1.to_i
            tokens[i].tag(Ordinal.new(ordinal))
            tokens[i].tag(OrdinalDay.new(ordinal)) if Chronic::Date::could_be_day?(ordinal)
            tokens[i].tag(OrdinalMonth.new(ordinal)) if Chronic::Date::could_be_month?(ordinal)
            if Chronic::Date::could_be_year?(ordinal)
                year = Chronic::Date::make_year(ordinal, options[:ambiguous_year_future_bias])
                tokens[i].tag(OrdinalYear.new(year.to_i))
            end
        end
      end
    end

### Public Instance Methods

to_s() click to toggle source

    # File lib/chronic/ordinal.rb, line 26
    def to_s
      'ordinal'
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.