Class: Expire::RuleBase
- Inherits:
-
Object
show all
- Includes:
- Comparable
- Defined in:
- lib/expire/rule_base.rb
Overview
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(amount:) ⇒ RuleBase
26
27
28
|
# File 'lib/expire/rule_base.rb', line 26
def initialize(amount:)
@amount = amount
end
|
Instance Attribute Details
#amount ⇒ Object
Returns the value of attribute amount.
30
31
32
|
# File 'lib/expire/rule_base.rb', line 30
def amount
@amount
end
|
Class Method Details
.<=>(other) ⇒ Object
8
9
10
|
# File 'lib/expire/rule_base.rb', line 8
def self.<=>(other)
rank <=> other.rank
end
|
.camelized_name ⇒ Object
12
13
14
15
|
# File 'lib/expire/rule_base.rb', line 12
def self.camelized_name
match = to_s.match(/\A.*::(.+)Rule\z/) || return
match[1]
end
|
.name ⇒ Object
17
18
19
|
# File 'lib/expire/rule_base.rb', line 17
def self.name
camelized_name&.underscore
end
|
.option_name ⇒ Object
21
22
23
24
|
# File 'lib/expire/rule_base.rb', line 21
def self.option_name
rule_name = name || return
"--#{rule_name.dasherize}"
end
|
Instance Method Details
#<=>(other) ⇒ Object
45
46
47
|
# File 'lib/expire/rule_base.rb', line 45
def <=>(other)
rank <=> other.rank
end
|
#name ⇒ Object
32
33
34
|
# File 'lib/expire/rule_base.rb', line 32
def name
camelized_name&.underscore
end
|
#numerus_backup ⇒ Object
36
37
38
|
# File 'lib/expire/rule_base.rb', line 36
def numerus_backup
"backup".pluralize(amount)
end
|
#option_name ⇒ Object
40
41
42
43
|
# File 'lib/expire/rule_base.rb', line 40
def option_name
rule_name = name || return
"--#{rule_name.dasherize}"
end
|