class Period::StandardPeriod
Public Class Methods
_period()
click to toggle source
# File lib/period/standard_period.rb, line 28 def self._period name.split('::').last.downcase end
new(object)
click to toggle source
Calls superclass method
Period::FreePeriod::new
# File lib/period/standard_period.rb, line 10 def initialize(object) time = time_parse(object, I18n.t(:date_is_invalid, scope: %i[period standard_period]) ) super(time.send("beginning_of_#{_period}")..time.send("end_of_#{_period}")) end
Public Instance Methods
+(duration)
click to toggle source
# File lib/period/standard_period.rb, line 40 def +(duration) self.class.new(to + duration) end
-(duration)
click to toggle source
# File lib/period/standard_period.rb, line 36 def -(duration) self.class.new(from - duration) end
_period()
click to toggle source
# File lib/period/standard_period.rb, line 24 def _period self.class._period end
i18n()
click to toggle source
# File lib/period/standard_period.rb, line 52 def i18n raise NotImplementedError end
i18n_scope()
click to toggle source
# File lib/period/standard_period.rb, line 56 def i18n_scope [:period, :standard_period, _period] end
iso_date()
click to toggle source
# File lib/period/standard_period.rb, line 44 def iso_date from end
next()
click to toggle source
# File lib/period/standard_period.rb, line 15 def next self.class.new(from.send("next_#{_period}")) end
Also aliased as: succ
prev()
click to toggle source
# File lib/period/standard_period.rb, line 20 def prev self.class.new(from.send("prev_#{_period}")) end
to_i()
click to toggle source
# File lib/period/standard_period.rb, line 32 def to_i 1.send(_period) end
to_s()
click to toggle source
# File lib/period/standard_period.rb, line 48 def to_s raise NotImplementedError end