class ActivePeriod::StandardPeriod
Public Class Methods
_period()
click to toggle source
@return [String] get the name of the standard period
# File lib/active_period/standard_period.rb, line 24 def self._period name.split('::').last.downcase end
new(object)
click to toggle source
Calls superclass method
ActivePeriod::Period::new
# File lib/active_period/standard_period.rb, line 4 def initialize(object) raise I18n.t(:base_class_id_abstract, scope: %i[active_period standard_period]) if self.class == StandardPeriod time = time_parse(object, I18n.t(:date_is_invalid, scope: %i[active_period standard_period]) ) super(time.send("beginning_of_#{_period}")..time.send("end_of_#{_period}")) end
Public Instance Methods
+(duration)
click to toggle source
Shift a period to the past acording to her ending point @return [self] A new period of the same kind
# File lib/active_period/standard_period.rb, line 43 def +(duration) self.class.new(to + duration) end
-(duration)
click to toggle source
Shift a period to the past acording to her starting point @return [self] A new period of the same kind
# File lib/active_period/standard_period.rb, line 37 def -(duration) self.class.new(from - duration) end
_period()
click to toggle source
# File lib/active_period/standard_period.rb, line 19 def _period self.class._period end
i18n_scope()
click to toggle source
# File lib/active_period/standard_period.rb, line 47 def i18n_scope [:active_period, :standard_period, _period] end
next()
click to toggle source
# File lib/active_period/standard_period.rb, line 10 def next self.class.new(from.send("next_#{_period}")) end
Also aliased as: succ
prev()
click to toggle source
# File lib/active_period/standard_period.rb, line 15 def prev self.class.new(from.send("prev_#{_period}")) end
to_i()
click to toggle source
Don't realy return an Integer. ActiveSupport::Duration is a better numeric representation a in time manipulation context @return [ActiveSupport::Duration]
# File lib/active_period/standard_period.rb, line 31 def to_i 1.send(_period) end