Class: ActivePeriod::Week

Inherits:
StandardPeriod show all
Includes:
BelongsTo::Month, BelongsTo::Quarter, BelongsTo::Year, HasMany::Days
Defined in:
lib/active_period/week.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 BelongsTo::Year

#year

Methods included from BelongsTo::Quarter

#quarter

Methods included from BelongsTo::Month

#month

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



28
29
30
31
32
33
34
35
# File 'lib/active_period/week.rb', line 28

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

  I18n.t(:default_format,
         scope: i18n_scope,
         week:  strftime('%V'),
         year:  strftime('%G'))
end

#include_dateObject



37
38
39
# File 'lib/active_period/week.rb', line 37

def include_date
  from + 3.days
end

#strftime(format) ⇒ Object



20
21
22
# File 'lib/active_period/week.rb', line 20

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

#to_s(format: '%V - %G') ⇒ Object



24
25
26
# File 'lib/active_period/week.rb', line 24

def to_s(format: '%V - %G')
  strftime(format)
end