Class: Cch::Loggers::Level
- Inherits:
-
Object
- Object
- Cch::Loggers::Level
- Defined in:
- lib/cch/loggers/level.rb
Constant Summary collapse
- LEVELS =
[:debug, :info, :error].freeze
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #allowed?(threshold) ⇒ Boolean
-
#initialize(name) ⇒ Level
constructor
A new instance of Level.
- #to_s ⇒ Object
Constructor Details
#initialize(name) ⇒ Level
Returns a new instance of Level.
16 17 18 |
# File 'lib/cch/loggers/level.rb', line 16 def initialize(name) @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
14 15 16 |
# File 'lib/cch/loggers/level.rb', line 14 def name @name end |
Class Method Details
.all ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/cch/loggers/level.rb', line 6 def self.all return @levels if @levels @levels = {} LEVELS.each { |level| @levels[level] = new(level) } @levels end |
Instance Method Details
#allowed?(threshold) ⇒ Boolean
20 21 22 |
# File 'lib/cch/loggers/level.rb', line 20 def allowed?(threshold) LEVELS.index(threshold) <= LEVELS.index(name) end |
#to_s ⇒ Object
24 25 26 |
# File 'lib/cch/loggers/level.rb', line 24 def to_s name.to_s.upcase.color(color) end |