Class: Apache::Log::Directive
- Inherits:
-
Object
- Object
- Apache::Log::Directive
- Defined in:
- lib/aplo/strptime.rb,
lib/aplo/directive.rb,
lib/aplo/directives.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
(also: #format)
readonly
Returns the value of attribute key.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
- .convert(directive, conversion = nil, &converter) ⇒ Object
- .converters ⇒ Object
- .dir(char, name, pattern = nil) ⇒ Object
- .directives ⇒ Object
Instance Method Summary collapse
- #formatted? ⇒ Boolean
-
#initialize(str) ⇒ Directive
constructor
A new instance of Directive.
- #keyed? ⇒ Boolean
- #pattern ⇒ Object
- #process(str) ⇒ Object
Constructor Details
#initialize(str) ⇒ Directive
Returns a new instance of Directive.
18 19 20 21 22 23 24 |
# File 'lib/aplo/directive.rb', line 18 def initialize(str) @name, @pattern, @conversion = @@directives[str[-1, 1]] if /\{(.+)\}/ =~ str @key = $1 end end |
Instance Attribute Details
#key ⇒ Object (readonly) Also known as: format
Returns the value of attribute key.
14 15 16 |
# File 'lib/aplo/directive.rb', line 14 def key @key end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
14 15 16 |
# File 'lib/aplo/directive.rb', line 14 def name @name end |
Class Method Details
.convert(directive, conversion = nil, &converter) ⇒ Object
9 10 11 |
# File 'lib/aplo/directive.rb', line 9 def convert(directive, conversion = nil, &converter) converters[directive] = conversion || converter end |
.converters ⇒ Object
49 50 51 |
# File 'lib/aplo/directive.rb', line 49 def converters @@converters ||= {} end |
.dir(char, name, pattern = nil) ⇒ Object
6 7 8 |
# File 'lib/aplo/directive.rb', line 6 def dir(char, name, pattern = nil) directives[char] = [name, pattern] end |
.directives ⇒ Object
46 47 48 |
# File 'lib/aplo/directive.rb', line 46 def directives @@directives ||= {} end |
Instance Method Details
#formatted? ⇒ Boolean
34 35 36 |
# File 'lib/aplo/directive.rb', line 34 def formatted? @name == :time || @name == :process_id end |
#keyed? ⇒ Boolean
30 31 32 |
# File 'lib/aplo/directive.rb', line 30 def keyed? !@key.nil? end |
#pattern ⇒ Object
26 27 28 |
# File 'lib/aplo/directive.rb', line 26 def pattern @pattern ||= '(.+?)' end |
#process(str) ⇒ Object
38 39 40 |
# File 'lib/aplo/directive.rb', line 38 def process(str) str == '-' ? nil : convert(str) end |