Class: Logsly::ColorsData
- Inherits:
-
Object
- Object
- Logsly::ColorsData
- Includes:
- NsOptions::Proxy
- Defined in:
- lib/logsly/colors.rb
Instance Method Summary collapse
-
#initialize(*args, &build) ⇒ ColorsData
constructor
A new instance of ColorsData.
- #to_scheme_opts ⇒ Object
Constructor Details
#initialize(*args, &build) ⇒ ColorsData
Returns a new instance of ColorsData.
59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/logsly/colors.rb', line 59 def initialize(*args, &build) self.instance_exec(*args, &build) @properties = properties.map{|p| self.send(p)} @method = self.method_name @level_settings = levels.map{|l| self.send(l)} @line_settings = levels.map{|l| self.send("#{l}_line")} if has_level_settings? && has_line_settings? raise ArgumentError, "can't set line and level settings in the same scheme" end end |
Instance Method Details
#to_scheme_opts ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/logsly/colors.rb', line 72 def to_scheme_opts Hash.new.tap do |opts| # set general properties properties.each_with_index do |property, idx| opts[property] = @properties[idx] if @properties[idx] end # set special properties (reserved names) opts[:method] = @method if @method # set level settings - only add :levels key if one exists if has_level_settings? opts[:levels] = {} levels.each_with_index do |level, idx| opts[:levels][level] = @level_settings[idx] if @level_settings[idx] end end # set line-level settings - only :lines key if one exists if has_line_settings? opts[:lines] = {} levels.each_with_index do |level, idx| opts[:lines][level] = @line_settings[idx] if @line_settings[idx] end end end end |