### Home Classes Methods

### In Files

- lib/chronic/scalar.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::Scalar

### Constants

DAY_PORTIONS

### Public Class Methods

scan(tokens, options) click to toggle source

Scan an Array of Token objects and apply any necessary Scalar 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/scalar.rb, line 12
    def self.scan(tokens, options)
      tokens.each_index do |i|
        token = tokens[i]
        post_token = tokens[i + 1]
        if token.word =~ /^\d+$/
            scalar = token.word.to_i
            token.tag(Scalar.new(scalar))
            token.tag(ScalarSubsecond.new(scalar)) if Chronic::Time::could_be_subsecond?(scalar)
            token.tag(ScalarSecond.new(scalar)) if Chronic::Time::could_be_second?(scalar)
            token.tag(ScalarMinute.new(scalar)) if Chronic::Time::could_be_minute?(scalar)
            token.tag(ScalarHour.new(scalar)) if Chronic::Time::could_be_hour?(scalar)
            unless post_token and DAY_PORTIONS.include?(post_token.word)
              token.tag(ScalarDay.new(scalar)) if Chronic::Date::could_be_day?(scalar)
              token.tag(ScalarMonth.new(scalar)) if Chronic::Date::could_be_month?(scalar)
              if Chronic::Date::could_be_year?(scalar)
                year = Chronic::Date::make_year(scalar, options[:ambiguous_year_future_bias])
                token.tag(ScalarYear.new(year.to_i))
              end
            end
        end
      end
    end

### Public Instance Methods

to_s() click to toggle source

    # File lib/chronic/scalar.rb, line 35
    def to_s
      'scalar'
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.