Class: Slk::Formatters::ReactionFormatter
- Inherits:
-
Object
- Object
- Slk::Formatters::ReactionFormatter
- Defined in:
- lib/slk/formatters/reaction_formatter.rb
Overview
Formats reaction data for terminal display
Instance Method Summary collapse
-
#format_inline(reactions, options = {}) ⇒ Object
Format reactions inline for simple display: “ [2 👍, 1 ❤️]”.
-
#format_summary(reactions, options = {}) ⇒ Object
Format reactions as a single line: “[2 👍 1 ❤️]”.
-
#format_with_timestamps(reactions, workspace, options = {}) ⇒ Object
Format reactions with timestamps, one per line.
-
#initialize(output:, emoji_replacer:, cache_store:) ⇒ ReactionFormatter
constructor
A new instance of ReactionFormatter.
Constructor Details
#initialize(output:, emoji_replacer:, cache_store:) ⇒ ReactionFormatter
Returns a new instance of ReactionFormatter.
7 8 9 10 11 |
# File 'lib/slk/formatters/reaction_formatter.rb', line 7 def initialize(output:, emoji_replacer:, cache_store:) @output = output @emoji = emoji_replacer @cache = cache_store end |
Instance Method Details
#format_inline(reactions, options = {}) ⇒ Object
Format reactions inline for simple display: “ [2 👍, 1 ❤️]”
14 15 16 17 18 19 20 |
# File 'lib/slk/formatters/reaction_formatter.rb', line 14 def format_inline(reactions, = {}) parts = reactions.map do |r| emoji = resolve_emoji(r.name, ) "#{r.count} #{emoji}" end " [#{parts.join(', ')}]" end |
#format_summary(reactions, options = {}) ⇒ Object
Format reactions as a single line: “[2 👍 1 ❤️]”
23 24 25 26 27 28 29 30 |
# File 'lib/slk/formatters/reaction_formatter.rb', line 23 def format_summary(reactions, = {}) reaction_text = reactions.map do |r| emoji = resolve_emoji(r.name, ) "#{r.count} #{emoji}" end.join(' ') @output.yellow("[#{reaction_text}]") end |
#format_with_timestamps(reactions, workspace, options = {}) ⇒ Object
Format reactions with timestamps, one per line
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/slk/formatters/reaction_formatter.rb', line 33 def (reactions, workspace, = {}) workspace_name = workspace&.name lines = [] reactions.each do |reaction| emoji = resolve_emoji(reaction.name, ) user_strings = (reaction, workspace_name, ) lines << @output.yellow(" ↳ #{emoji} #{user_strings.join(', ')}") end lines end |