Class: Banalize::Policy::Severity
- Inherits:
-
Object
- Object
- Banalize::Policy::Severity
- Defined in:
- lib/banalize/policy/severity.rb
Constant Summary
- LIST =
{ gentle: 5, stern: 4, harsh: 3, cruel: 2, brutal: 1 }
Class Method Summary (collapse)
- + (Object) default
- + (Object) to_i(severity)
-
+ (Object) to_s
Describe available severities in a taxt format.
Instance Method Summary (collapse)
-
- (Severity) initialize(severity)
constructor
A new instance of Severity.
Constructor Details
- (Severity) initialize(severity)
A new instance of Severity
7 8 9 |
# File 'lib/banalize/policy/severity.rb', line 7 def initialize severity @severity = self.to_i severity end |
Class Method Details
+ (Object) default
11 12 13 |
# File 'lib/banalize/policy/severity.rb', line 11 def self.default :gentle end |
+ (Object) to_i(severity)
15 16 17 18 19 20 21 22 |
# File 'lib/banalize/policy/severity.rb', line 15 def self.to_i severity case severity when Symbol, String LIST[severity.to_sym] when Fixnum severity end end |
+ (Object) to_s
Describe available severities in a taxt format
26 27 28 29 30 31 32 |
# File 'lib/banalize/policy/severity.rb', line 26 def self.to_s format = "%-20s%s" LIST.map do |k,v| sprintf format , k.to_s.humanize, v end.join "\n" end |