@return [String] The word this Token represents
# File lib/chronic/token.rb, line 10 def initialize(word) @word = word @tags = [] end
@param [Class] tag_class The tag class to search for @return [Tag] The first Tag that matches the given class
# File lib/chronic/token.rb, line 36 def get_tag(tag_class) @tags.find { |m| m.kind_of? tag_class } end
Tag this token with the specified tag
@param [Tag] new_tag An instance of {Tag} or one of its subclasses
# File lib/chronic/token.rb, line 18 def tag(new_tag) @tags << new_tag end
@return [Boolean] true if this token has any tags
# File lib/chronic/token.rb, line 30 def tagged? @tags.size > 0 end
Print this Token in a pretty way
# File lib/chronic/token.rb, line 41 def to_s @word << '(' << @tags.join(', ') << ') ' end
Remove all tags of the given class
@param [Class] The tag class to remove
# File lib/chronic/token.rb, line 25 def untag(tag_class) @tags.delete_if { |m| m.kind_of? tag_class } end