Sha256: e04b86a7d7f854d2a8ba1440c9dda90cb127656b28f252fd9c15eef420ad1150

Contents?: true

Size: 1.16 KB

Versions: 1

Compression:

Stored size: 1.16 KB

Contents

module Chronic
  class MonthName < Tag

    # Scan an Array of Token objects and apply any necessary MonthName
    # 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.
    def self.scan(tokens, options)
      tokens.each do |token|
        token.tag scan_for(token, self, patterns, options)
      end
    end

    def self.patterns
      @@patterns ||= {
        /^jan[:\.]?(uary)?$/i           => :january,
        /^feb[:\.]?(ruary)?$/i          => :february,
        /^mar[:\.]?(ch)?$/i             => :march,
        /^apr[:\.]?(il)?$/i             => :april,
        /^may$/i                        => :may,
        /^jun[:\.]?e?$/i                => :june,
        /^jul[:\.]?y?$/i                => :july,
        /^aug[:\.]?(ust)?$/i            => :august,
        /^sep[:\.]?(t[:\.]?|tember)?$/i => :september,
        /^oct[:\.]?(ober)?$/i           => :october,
        /^nov[:\.]?(ember)?$/i          => :november,
        /^dec[:\.]?(ember)?$/i          => :december
      }
    end

    def to_s
      'monthname-' << @type.to_s
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
chronic-davispuh-0.10.2.v0.1da32066b3f46f2506b3471e39557497e34afa27 lib/chronic/tags/month_name.rb