lib/fat_period/period.rb
# Return the chunk symbol represented by this period if it covers a single
# calendar period; otherwise return :irregular.
#
# @example
#   Period.new('2016-02-01', '2016-02-29').chunk_sym #=> :month
#   Period.new('2016-02-01', '2016-02-28').chunk_sym #=> :irregular
#   Period.new('2016-02-01', '2017-02-28').chunk_sym #=> :irregular
#   Period.new('2016-01-01', '2016-03-31').chunk_sym #=> :quarter
#   Period.new('2016-01-02', '2016-04-01').chunk_sym #=> :irregular
#
# @return [Symbol]
Return the chunk symbol represented by this period if it covers a single
calendar period; otherwise return :irregular.
Return the chunk symbol represented by this period if it covers a single calendar period ; otherwise return : irregular .
def chunk_sym
    if first.beginning_of_year? && last.end_of_year? &&
       CHUNK_RANGE[:year].cover?(size)
      :year
    elsif first.beginning_of_half? && last.end_of_half? &&
          CHUNK_RANGE[:half].cover?(size)
      :half
    elsif first.beginning_of_quarter? && last.end_of_quarter? &&
          CHUNK_RANGE[:quarter].cover?(size)
      :quarter
    elsif first.beginning_of_bimonth? && last.end_of_bimonth? &&
          CHUNK_RANGE[:bimonth].cover?(size)
      :bimonth
    elsif first.beginning_of_month? && last.end_of_month? &&
          CHUNK_RANGE[:month].cover?(size)
      :month
    elsif first.beginning_of_semimonth? && last.end_of_semimonth &&
          CHUNK_RANGE[:semimonth].cover?(size)
      :semimonth
    elsif first.beginning_of_biweek? && last.end_of_biweek? &&
          CHUNK_RANGE[:biweek].cover?(size)
      :biweek
    elsif first.beginning_of_week? && last.end_of_week? &&
          CHUNK_RANGE[:week].cover?(size)
      :week
    elsif first == last
      :day
    else
      :irregular
    end
  end
def chunk_sym if first . beginning_of_year? && last . end_of_year? && CHUNK_RANGE [ :year ] . cover? ( size ) :year elsif first . beginning_of_half? && last . end_of_half? && CHUNK_RANGE [ :half ] . cover? ( size ) :half elsif first . beginning_of_quarter? && last . end_of_quarter? && CHUNK_RANGE [ :quarter ] . cover? ( size ) :quarter elsif first . beginning_of_bimonth? && last . end_of_bimonth? && CHUNK_RANGE [ :bimonth ] . cover? ( size ) :bimonth elsif first . beginning_of_month? && last . end_of_month? && CHUNK_RANGE [ :month ] . cover? ( size ) :month elsif first . beginning_of_semimonth? && last . end_of_semimonth && CHUNK_RANGE [ :semimonth ] . cover? ( size ) :semimonth elsif first . beginning_of_biweek? && last . end_of_biweek? && CHUNK_RANGE [ :biweek ] . cover? ( size ) :biweek elsif first . beginning_of_week? && last . end_of_week? && CHUNK_RANGE [ :week ] . cover? ( size ) :week elsif first == last :day else :irregular end end
Return the chunk symbol represented by this period if it covers a single
calendar period; otherwise return :irregular.
Return the chunk symbol represented by this period if it covers a single calendar period ; otherwise return : irregular .
None
Symbol
example
None