Parent

Log4r::Log4rTools

Some common functions

Public Class Methods

comma_split(string) click to toggle source

Splits comma-delimited lists with arbitrary s padding

    # File lib/log4r/base.rb, line 70
70:     def self.comma_split(string)
71:       string.split(/\s*,\s*/).collect {|s| s.strip}
72:     end
decode_bool(hash, symbol, default) click to toggle source

Shortcut for decoding ‘true’, ‘false’, true, false or nil into a bool from a hash parameter. E.g., it looks for true/false values for the keys ‘symbol’ and :symbol.

    # File lib/log4r/base.rb, line 59
59:     def self.decode_bool(hash, symbol, default)
60:       data = hash[symbol]
61:       data = hash[symbol.to_s] if data.nil?
62:       return case data
63:         when 'true',true then true
64:         when 'false',false then false
65:         else default
66:         end
67:     end
valid_level?(lev) click to toggle source
    # File lib/log4r/base.rb, line 45
45:     def self.valid_level?(lev)
46:       not lev.nil? and lev.kind_of?(Numeric) and lev >= ALL and lev <= OFF
47:     end
validate_level(level, depth=0) click to toggle source

Raises ArgumentError if level argument is an invalid level. Depth specifies how many trace entries to remove.

    # File lib/log4r/base.rb, line 38
38:     def self.validate_level(level, depth=0)
39:       unless valid_level?(level)
40:         raise ArgumentError, "Log level must be in 0..#{LEVELS}",
41:               caller[1..-(depth + 1)]
42:       end
43:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.