Class: ActivePeriod::Year

Inherits:
StandardPeriod show all
Includes:
HasMany::Days, HasMany::Months, HasMany::Quarters, HasMany::Weeks
Defined in:
lib/active_period/year.rb

Overview

Note:

One of the StandardPeriod defined in the gem

Author:

  • Lucas Billaudot <billau_l@modulotech.fr>

Instance Method Summary collapse

Methods included from HasMany::Quarters

#quarters

Methods included from HasMany::Months

#months

Methods included from HasMany::Weeks

#weeks

Methods included from HasMany::Days

#days

Methods inherited from StandardPeriod

#+, #-, #_period, _period, #i18n_scope, #initialize, #next, #prev, #to_i

Methods inherited from Period

#&, #+, #-, #==, #===, #beginless?, #boundless?, #calculated_begin, #calculated_end, #endless?, #infinite?, #initialize, #next, #prev, #to_i, #|

Methods included from HasMany::Holidays

#holidays

Methods included from Comparable

#<=>, #include?

Methods inherited from Range

#to_period

Constructor Details

This class inherits a constructor from ActivePeriod::StandardPeriod

Instance Method Details

#i18n(&block) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/active_period/year.rb', line 25

def i18n(&block)
  return yield(from, to) if block.present?

  I18n.t(:default_format,
         scope: i18n_scope,
         year:  from.year)
end

#strftime(format) ⇒ Object



17
18
19
# File 'lib/active_period/year.rb', line 17

def strftime(format)
  from.strftime(format)
end

#to_s(format: '%Y') ⇒ Object



21
22
23
# File 'lib/active_period/year.rb', line 21

def to_s(format: '%Y')
  strftime(format)
end