Class: Chronic::EndianDefinitions

Inherits:
SpanDefinitions show all
Defined in:
lib/chronic/definition.rb

Instance Attribute Summary

Attributes inherited from Definitions

#options

Instance Method Summary collapse

Methods included from Handlers

day_or_time, dealias_and_disambiguate_times, find_within, get_anchor, get_repeaters, handle_generic, handle_m_d, handle_o_r_g_r, handle_o_r_s_r, handle_od_rm, handle_od_rmn, handle_od_rmn_sy, handle_orr, handle_p_s_r, handle_r, handle_r_g_r, handle_rdn_od, handle_rdn_rmn_od, handle_rdn_rmn_od_sy, handle_rdn_rmn_sd, handle_rdn_rmn_sd_sy, handle_rmn_od, handle_rmn_od_on, handle_rmn_od_sy, handle_rmn_sd, handle_rmn_sd_on, handle_rmn_sd_sy, handle_rmn_sy, handle_s_r_a_s_r_p_a, handle_s_r_p, handle_s_r_p_a, handle_sd_rmn, handle_sd_rmn_sy, handle_sd_sm, handle_sd_sm_sy, handle_sm_rmn_sy, handle_sm_sd, handle_sm_sd_sy, handle_sm_sy, handle_srp, handle_sy_rmn_od, handle_sy_sm, handle_sy_sm_sd, handle_year_and_month, month_overflow?, time_with_rollover

Methods inherited from Definitions

#initialize

Constructor Details

This class inherits a constructor from Chronic::Definitions

Instance Method Details

#definitionsObject


99
100
101
# File 'lib/chronic/definition.rb', line 99

def definitions
  prefered_endian
end

#prefered_endianObject


103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/chronic/definition.rb', line 103

def prefered_endian
  options[:endian_precedence] ||= [:middle, :little]

  definitions = [
    Handler.new([:scalar_month, [:separator_slash, :separator_dash], :scalar_day, [:separator_slash, :separator_dash], :scalar_year, :separator_at?, 'time?'], :handle_sm_sd_sy),
    Handler.new([:scalar_month, [:separator_slash, :separator_dash], :scalar_day, :separator_at?, 'time?'], :handle_sm_sd),
    Handler.new([:scalar_day, [:separator_slash, :separator_dash], :scalar_month, :separator_at?, 'time?'], :handle_sd_sm),
    Handler.new([:scalar_day, [:separator_slash, :separator_dash], :scalar_month, [:separator_slash, :separator_dash], :scalar_year, :separator_at?, 'time?'], :handle_sd_sm_sy),
    Handler.new([:scalar_day, :repeater_month_name, :scalar_year, :separator_at?, 'time?'], :handle_sd_rmn_sy)
  ]

  case endian = Array(options[:endian_precedence]).first
  when :little
    definitions.reverse
  when :middle
    definitions
  else
    raise ArgumentError, "Unknown endian option '#{endian}'"
  end
end