### Home Classes Methods

### In Files

- lib/chronic/token.rb

### Parent

Object

### Methods

- ::new
- #get_tag
- #inspect
- #tag
- #tagged?
- #to_s
- #untag

### 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::Token

### Attributes

tags[RW]
word[RW]

### Public Class Methods

new(word) click to toggle source

    # File lib/chronic/token.rb, line 7
    def initialize(word)
      @word = word
      @tags = []
    end

### Public Instance Methods

get_tag(tag_class) click to toggle source

tag_class - The tag Class to search for.

Returns The first Tag that matches the given class.

    # File lib/chronic/token.rb, line 38
    def get_tag(tag_class)
      @tags.find { |m| m.kind_of? tag_class }
    end

inspect() click to toggle source

    # File lib/chronic/token.rb, line 47
    def inspect
      to_s
    end

tag(new_tag) click to toggle source

Tag this token with the specified tag.

new_tag - The new Tag object.

Returns nothing.

    # File lib/chronic/token.rb, line 17
    def tag(new_tag)
      @tags << new_tag
    end

tagged?() click to toggle source

Returns true if this token has any tags.

    # File lib/chronic/token.rb, line 31
    def tagged?
      @tags.size > 0
    end

to_s() click to toggle source

Print this Token in a pretty way

    # File lib/chronic/token.rb, line 43
    def to_s
      @word << '(' << @tags.join(', ') << ') '
    end

untag(tag_class) click to toggle source

Remove all tags of the given class.

tag_class - The tag Class to remove.

Returns nothing.

    # File lib/chronic/token.rb, line 26
    def untag(tag_class)
      @tags.delete_if { |m| m.kind_of? tag_class }
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.