Class: Banalize::Policy::Severity
- Inherits:
-
Object
- Object
- Banalize::Policy::Severity
- Defined in:
- lib/banalize/policy/severity.rb
Constant Summary collapse
- LIST =
{ gentle: 5, stern: 4, harsh: 3, cruel: 2, brutal: 1 }
Class Method Summary collapse
- .default ⇒ Object
- .to_i(severity) ⇒ Object
-
.to_s ⇒ Object
Describe available severities in a taxt format.
Instance Method Summary collapse
-
#initialize(severity) ⇒ Severity
constructor
A new instance of Severity.
Constructor Details
#initialize(severity) ⇒ Severity
Returns 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
.default ⇒ Object
11 12 13 |
# File 'lib/banalize/policy/severity.rb', line 11 def self.default :gentle end |
.to_i(severity) ⇒ Object
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 |
.to_s ⇒ Object
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 |