Class: ExtendedLogger::Serializer::TextFormatter
- Inherits:
-
Object
- Object
- ExtendedLogger::Serializer::TextFormatter
- Defined in:
- lib/extended_logger/serializer/text_formatter.rb
Instance Attribute Summary collapse
-
#prose ⇒ Object
readonly
Returns the value of attribute prose.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(prose) ⇒ TextFormatter
constructor
A new instance of TextFormatter.
- #lines ⇒ Object
Constructor Details
#initialize(prose) ⇒ TextFormatter
Returns a new instance of TextFormatter.
6 7 8 |
# File 'lib/extended_logger/serializer/text_formatter.rb', line 6 def initialize prose @prose = prose end |
Instance Attribute Details
#prose ⇒ Object (readonly)
Returns the value of attribute prose.
4 5 6 |
# File 'lib/extended_logger/serializer/text_formatter.rb', line 4 def prose @prose end |
Class Method Details
.call(prose) ⇒ Object
10 11 12 13 |
# File 'lib/extended_logger/serializer/text_formatter.rb', line 10 def self.call prose instance = new prose instance.() end |
Instance Method Details
#call ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/extended_logger/serializer/text_formatter.rb', line 15 def call return [ExtendedLogger.] if prose.nil? or prose.empty? lines.map do |line| line.chomp! if line.match %r{(?<!\r)\n} if line.empty? "\\n" else line = line.inspect line.slice! 0, 1 line.slice! -1, 1 line.gsub! '\\"', '"' line end end end |
#lines ⇒ Object
33 34 35 |
# File 'lib/extended_logger/serializer/text_formatter.rb', line 33 def lines @lines ||= prose.each_line $INPUT_RECORD_SEPARATOR end |