class 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