Class: Teems::Formatters::MarkdownFormatter
- Inherits:
-
Object
- Object
- Teems::Formatters::MarkdownFormatter
- Defined in:
- lib/teems/formatters/markdown_formatter.rb
Overview
Formats chat messages as a Markdown document for local storage. Groups messages by date with human-readable formatting.
Constant Summary collapse
- REACTION_EMOJI =
{ 'like' => "\u{1F44D}", 'heart' => "\u{2764}\u{FE0F}", 'laugh' => "\u{1F602}", 'surprised' => "\u{1F62E}", 'sad' => "\u{1F622}", 'angry' => "\u{1F620}", 'yes-tone1' => "\u{1F44D}\u{1F3FB}", 'yes-tone2' => "\u{1F44D}\u{1F3FC}", 'support' => "\u{1F91D}", 'heartblue' => "\u{1F499}", 'computer' => "\u{1F4BB}", '1f37f_popcorn' => "\u{1F37F}", '1f440_eyes' => "\u{1F440}", 'thumbsdown' => "\u{1F44E}" }.freeze
Instance Method Summary collapse
-
#format(messages) ⇒ Object
Format an array of Message objects into a Markdown string.
-
#initialize(chat_name:, chat_type: nil, synced_at: nil) ⇒ MarkdownFormatter
constructor
A new instance of MarkdownFormatter.
Constructor Details
#initialize(chat_name:, chat_type: nil, synced_at: nil) ⇒ MarkdownFormatter
Returns a new instance of MarkdownFormatter.
18 19 20 21 22 |
# File 'lib/teems/formatters/markdown_formatter.rb', line 18 def initialize(chat_name:, chat_type: nil, synced_at: nil) @chat_name = chat_name @chat_type = chat_type @synced_at = synced_at end |
Instance Method Details
#format(messages) ⇒ Object
Format an array of Message objects into a Markdown string. Messages should be in chronological order (oldest first).
26 27 28 29 30 31 32 |
# File 'lib/teems/formatters/markdown_formatter.rb', line 26 def format() lines = [build_header, ''] return (lines << '_No messages_').join("\n") if .empty? (, lines) lines.join("\n") end |