Class: Slk::Formatters::ReactionFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/slk/formatters/reaction_formatter.rb

Overview

Formats reaction data for terminal display

Instance Method Summary collapse

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, options = {})
  parts = reactions.map do |r|
    emoji = resolve_emoji(r.name, options)
    "#{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, options = {})
  reaction_text = reactions.map do |r|
    emoji = resolve_emoji(r.name, options)
    "#{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 format_with_timestamps(reactions, workspace, options = {})
  workspace_name = workspace&.name
  lines = []

  reactions.each do |reaction|
    emoji = resolve_emoji(reaction.name, options)
    user_strings = format_user_timestamps(reaction, workspace_name, options)
    lines << @output.yellow("#{emoji} #{user_strings.join(', ')}")
  end

  lines
end