Class: Expire::KeepAdjectiveForRuleBase

Inherits:
FromNowKeepAdjectiveForRuleBase show all
Defined in:
lib/expire/keep_adjective_for_rule_base.rb

Overview

Hold backups for a period

Constant Summary collapse

ADJECTIVE_FOR =
{
  "week" => "weekly",
  "month" => "monthly",
  "year" => "yearly"
}.freeze
PRIMARY_RANK =
30

Constants included from FromRangeValue

FromRangeValue::FROM_VALUE_REGEX

Constants inherited from KeepAdjectiveRuleBase

Expire::KeepAdjectiveRuleBase::NOUN_FOR, Expire::KeepAdjectiveRuleBase::SECONDARY_RANK_FOR

Instance Attribute Summary

Attributes inherited from FromNowKeepAdjectiveForRuleBase

#unit

Attributes inherited from RuleBase

#amount

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from FromNowKeepAdjectiveForRuleBase

#initialize

Methods included from FromRangeValue

#from_value

Methods included from NumerusUnit

#numerus_unit

Methods inherited from KeepAdjectiveRuleBase

#adjective, from_value, #rank, secondary_rank, #secondary_rank, #spacing

Methods inherited from RuleBase

<=>, #<=>, camelized_name, #initialize, name, #name, #numerus_backup, #option_name, option_name

Constructor Details

This class inherits a constructor from Expire::FromNowKeepAdjectiveForRuleBase

Class Method Details

.primary_rankObject



14
15
16
# File 'lib/expire/keep_adjective_for_rule_base.rb', line 14

def self.primary_rank
  PRIMARY_RANK
end

.rankObject



18
19
20
# File 'lib/expire/keep_adjective_for_rule_base.rb', line 18

def self.rank
  primary_rank + secondary_rank
end

Instance Method Details

#apply(backups, _) ⇒ Object



22
23
24
# File 'lib/expire/keep_adjective_for_rule_base.rb', line 22

def apply(backups, _)
  super(backups, backups.newest)
end

#primary_rankObject



26
27
28
# File 'lib/expire/keep_adjective_for_rule_base.rb', line 26

def primary_rank
  self.class.primary_rank
end

#reason_to_keepObject



30
31
32
# File 'lib/expire/keep_adjective_for_rule_base.rb', line 30

def reason_to_keep
  "keep #{amount} #{ADJECTIVE_FOR[spacing]} #{numerus_backup}"
end