vendor/bundle/ruby/1.8/gems/chronic-0.6.7/lib/chronic/chronic.rb
# List of {Handler} definitions. See {parse} for a list of options this
# method accepts
#
# @see parse
# @return [Hash] A Hash of Handler definitions
List of {Handler} definitions. See {parse} for a list of options this
method accepts
List of { Handler } definitions . See { parse } for a list of options this method accepts
def definitions(options={})
      options[:endian_precedence] ||= [:middle, :little]
      @definitions ||= {
        :time => [
          Handler.new([:repeater_time, :repeater_day_portion?], nil)
        ],
        :date => [
          Handler.new([:repeater_day_name, :repeater_month_name, :scalar_day, :repeater_time, :separator_slash_or_dash?, :time_zone, :scalar_year], :handle_rdn_rmn_sd_t_tz_sy),
          Handler.new([:repeater_day_name, :repeater_month_name, :scalar_day], :handle_rdn_rmn_sd),
          Handler.new([:repeater_day_name, :repeater_month_name, :scalar_day, :scalar_year], :handle_rdn_rmn_sd_sy),
          Handler.new([:repeater_day_name, :repeater_month_name, :ordinal_day], :handle_rdn_rmn_od),
          Handler.new([:scalar_year, :separator_slash_or_dash, :scalar_month, :separator_slash_or_dash, :scalar_day, :repeater_time, :time_zone], :handle_sy_sm_sd_t_tz),
          Handler.new([:repeater_month_name, :scalar_day, :scalar_year], :handle_rmn_sd_sy),
          Handler.new([:repeater_month_name, :ordinal_day, :scalar_year], :handle_rmn_od_sy),
          Handler.new([:repeater_month_name, :scalar_day, :scalar_year, :separator_at?, 'time?'], :handle_rmn_sd_sy),
          Handler.new([:repeater_month_name, :ordinal_day, :scalar_year, :separator_at?, 'time?'], :handle_rmn_od_sy),
          Handler.new([:repeater_month_name, :scalar_day, :separator_at?, 'time?'], :handle_rmn_sd),
          Handler.new([:repeater_time, :repeater_day_portion?, :separator_on?, :repeater_month_name, :scalar_day], :handle_rmn_sd_on),
          Handler.new([:repeater_month_name, :ordinal_day, :separator_at?, 'time?'], :handle_rmn_od),
          Handler.new([:ordinal_day, :repeater_month_name, :scalar_year, :separator_at?, 'time?'], :handle_od_rmn_sy),
          Handler.new([:ordinal_day, :repeater_month_name, :separator_at?, 'time?'], :handle_od_rmn),
          Handler.new([:scalar_year, :repeater_month_name, :ordinal_day], :handle_sy_rmn_od),
          Handler.new([:repeater_time, :repeater_day_portion?, :separator_on?, :repeater_month_name, :ordinal_day], :handle_rmn_od_on),
          Handler.new([:repeater_month_name, :scalar_year], :handle_rmn_sy),
          Handler.new([:scalar_day, :repeater_month_name, :scalar_year, :separator_at?, 'time?'], :handle_sd_rmn_sy),
          Handler.new([:scalar_day, :repeater_month_name, :separator_at?, 'time?'], :handle_sd_rmn),
          Handler.new([:scalar_year, :separator_slash_or_dash, :scalar_month, :separator_slash_or_dash, :scalar_day, :separator_at?, 'time?'], :handle_sy_sm_sd),
          Handler.new([:scalar_month, :separator_slash_or_dash, :scalar_year], :handle_sm_sy)
        ],
        :anchor => [
          Handler.new([:grabber?, :repeater, :separator_at?, :repeater?, :repeater?], :handle_r),
          Handler.new([:grabber?, :repeater, :repeater, :separator_at?, :repeater?, :repeater?], :handle_r),
          Handler.new([:repeater, :grabber, :repeater], :handle_r_g_r)
        ],
        :arrow => [
          Handler.new([:scalar, :repeater, :pointer], :handle_s_r_p),
          Handler.new([:pointer, :scalar, :repeater], :handle_p_s_r),
          Handler.new([:scalar, :repeater, :pointer, 'anchor'], :handle_s_r_p_a)
        ],
        :narrow => [
          Handler.new([:ordinal, :repeater, :separator_in, :repeater], :handle_o_r_s_r),
          Handler.new([:ordinal, :repeater, :grabber, :repeater], :handle_o_r_g_r)
        ]
      }
      endians = [
        Handler.new([:scalar_month, :separator_slash_or_dash, :scalar_day, :separator_slash_or_dash, :scalar_year, :separator_at?, 'time?'], :handle_sm_sd_sy),
        Handler.new([:scalar_day, :separator_slash_or_dash, :scalar_month, :separator_slash_or_dash, :scalar_year, :separator_at?, 'time?'], :handle_sd_sm_sy)
      ]
      case endian = Array(options[:endian_precedence]).first
      when :little
        @definitions[:endian] = endians.reverse
      when :middle
        @definitions[:endian] = endians
      else
        raise ArgumentError, "Unknown endian option '#{endian}'"
      end
      @definitions
    end
def definitions ( options = { } ) options [ :endian_precedence ] ||= [ :middle , :little ] @definitions ||= { :time => [ Handler . new ( [ :repeater_time , :repeater_day_portion? ] , nil ) ] , :date => [ Handler . new ( [ :repeater_day_name , :repeater_month_name , :scalar_day , :repeater_time , :separator_slash_or_dash? , :time_zone , :scalar_year ] , :handle_rdn_rmn_sd_t_tz_sy ) , Handler . new ( [ :repeater_day_name , :repeater_month_name , :scalar_day ] , :handle_rdn_rmn_sd ) , Handler . new ( [ :repeater_day_name , :repeater_month_name , :scalar_day , :scalar_year ] , :handle_rdn_rmn_sd_sy ) , Handler . new ( [ :repeater_day_name , :repeater_month_name , :ordinal_day ] , :handle_rdn_rmn_od ) , Handler . new ( [ :scalar_year , :separator_slash_or_dash , :scalar_month , :separator_slash_or_dash , :scalar_day , :repeater_time , :time_zone ] , :handle_sy_sm_sd_t_tz ) , Handler . new ( [ :repeater_month_name , :scalar_day , :scalar_year ] , :handle_rmn_sd_sy ) , Handler . new ( [ :repeater_month_name , :ordinal_day , :scalar_year ] , :handle_rmn_od_sy ) , Handler . new ( [ :repeater_month_name , :scalar_day , :scalar_year , :separator_at? , 'time?' ] , :handle_rmn_sd_sy ) , Handler . new ( [ :repeater_month_name , :ordinal_day , :scalar_year , :separator_at? , 'time?' ] , :handle_rmn_od_sy ) , Handler . new ( [ :repeater_month_name , :scalar_day , :separator_at? , 'time?' ] , :handle_rmn_sd ) , Handler . new ( [ :repeater_time , :repeater_day_portion? , :separator_on? , :repeater_month_name , :scalar_day ] , :handle_rmn_sd_on ) , Handler . new ( [ :repeater_month_name , :ordinal_day , :separator_at? , 'time?' ] , :handle_rmn_od ) , Handler . new ( [ :ordinal_day , :repeater_month_name , :scalar_year , :separator_at? , 'time?' ] , :handle_od_rmn_sy ) , Handler . new ( [ :ordinal_day , :repeater_month_name , :separator_at? , 'time?' ] , :handle_od_rmn ) , Handler . new ( [ :scalar_year , :repeater_month_name , :ordinal_day ] , :handle_sy_rmn_od ) , Handler . new ( [ :repeater_time , :repeater_day_portion? , :separator_on? , :repeater_month_name , :ordinal_day ] , :handle_rmn_od_on ) , Handler . new ( [ :repeater_month_name , :scalar_year ] , :handle_rmn_sy ) , Handler . new ( [ :scalar_day , :repeater_month_name , :scalar_year , :separator_at? , 'time?' ] , :handle_sd_rmn_sy ) , Handler . new ( [ :scalar_day , :repeater_month_name , :separator_at? , 'time?' ] , :handle_sd_rmn ) , Handler . new ( [ :scalar_year , :separator_slash_or_dash , :scalar_month , :separator_slash_or_dash , :scalar_day , :separator_at? , 'time?' ] , :handle_sy_sm_sd ) , Handler . new ( [ :scalar_month , :separator_slash_or_dash , :scalar_year ] , :handle_sm_sy ) ] , :anchor => [ Handler . new ( [ :grabber? , :repeater , :separator_at? , :repeater? , :repeater? ] , :handle_r ) , Handler . new ( [ :grabber? , :repeater , :repeater , :separator_at? , :repeater? , :repeater? ] , :handle_r ) , Handler . new ( [ :repeater , :grabber , :repeater ] , :handle_r_g_r ) ] , :arrow => [ Handler . new ( [ :scalar , :repeater , :pointer ] , :handle_s_r_p ) , Handler . new ( [ :pointer , :scalar , :repeater ] , :handle_p_s_r ) , Handler . new ( [ :scalar , :repeater , :pointer , 'anchor' ] , :handle_s_r_p_a ) ] , :narrow => [ Handler . new ( [ :ordinal , :repeater , :separator_in , :repeater ] , :handle_o_r_s_r ) , Handler . new ( [ :ordinal , :repeater , :grabber , :repeater ] , :handle_o_r_g_r ) ] } endians = [ Handler . new ( [ :scalar_month , :separator_slash_or_dash , :scalar_day , :separator_slash_or_dash , :scalar_year , :separator_at? , 'time?' ] , :handle_sm_sd_sy ) , Handler . new ( [ :scalar_day , :separator_slash_or_dash , :scalar_month , :separator_slash_or_dash , :scalar_year , :separator_at? , 'time?' ] , :handle_sd_sm_sy ) ] case endian = Array ( options [ :endian_precedence ] ) . first when :little @definitions [ :endian ] = endians . reverse when :middle @definitions [ :endian ] = endians else raise ArgumentError , "Unknown endian option '#{endian}'" end @definitions end
List of {Handler} definitions.
List of { Handler } definitions .
# tonight at 7pm # 3 weeks from now, in 2 months # 3rd week in march
A Hash of Handler definitions
A Hash of Handler definitions
Hash
options
see
None