Method: Period#to_s

Defined in:
lib/fat_core/period.rb

#to_sObject

[View source]

191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
# File 'lib/fat_core/period.rb', line 191

def to_s
  if first.beginning_of_year? && last.end_of_year? && first.year == last.year
    "#{first.year}"
  elsif first.beginning_of_quarter? &&
      last.end_of_quarter? &&
      first.year == last.year &&
      first.quarter == last.quarter
    "#{first.year}-#{first.quarter}Q"
  elsif first.beginning_of_month? &&
      last.end_of_month? &&
      first.year == last.year &&
      first.month == last.month
    "#{first.year}-%02d" % first.month
  else
    "#{first.iso} to #{last.iso}"
  end
end