Class: Worklog::LogEntryFormatters::BaseFormatter
- Inherits:
-
Object
- Object
- Worklog::LogEntryFormatters::BaseFormatter
- Defined in:
- lib/log_entry_formatters.rb
Overview
The base formatter provides common functionality and prints the message including the metadata (ticket, tags, url, project) in a formatted way. It also replaces people handles with their names if known.
Direct Known Subclasses
Instance Method Summary collapse
-
#format(log_entry) ⇒ String
Format the log entry message with metadata.
-
#initialize(known_people = nil) ⇒ BaseFormatter
constructor
Constructor.
Constructor Details
#initialize(known_people = nil) ⇒ BaseFormatter
Constructor
13 14 15 |
# File 'lib/log_entry_formatters.rb', line 13 def initialize(known_people = nil) @known_people = known_people end |
Instance Method Details
#format(log_entry) ⇒ String
Format the log entry message with metadata.
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/log_entry_formatters.rb', line 20 def format(log_entry) # replace all mentions of people with their names. msg = log_entry..dup s = String.new s << epic_prefix if log_entry.epic s << replace_people_handles(log_entry, msg) # Add a space between the message and the metadata if there is any metadata to add. s << ' ' unless (log_entry).empty? s << (log_entry) s end |