Sha256: 898218a4beace94f0e49fe10d277088ace33da575056abc64ba4f7a402e70df9
Contents?: true
Size: 941 Bytes
Versions: 3
Compression:
Stored size: 941 Bytes
Contents
module Chronic # Tokens are tagged with subclassed instances of this class when # they match specific criteria class Tag # @return [Symbol] attr_accessor :type # @param [Symbol] type def initialize(type) @type = type end # @param [Time] s Set the start timestamp for this Tag def start=(s) @now = s end class << self private # @param [Token] token # @param [Class] klass The class instance to create # @param [Regexp, Hash] items # @return [Object, nil] either a new instance of `klass` or `nil` if # no match is found def scan_for(token, klass, items={}) case items when Regexp return klass.new(token.word) if items =~ token.word when Hash items.each do |item, symbol| return klass.new(symbol) if item =~ token.word end end nil end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
chronic-0.5.0 | lib/chronic/tag.rb |
chronic-0.4.4 | lib/chronic/tag.rb |
chronic-0.4.3 | lib/chronic/tag.rb |