Class: Slk::Formatters::SavedItemFormatter

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

Overview

Formats saved/later items for terminal display

Instance Method Summary collapse

Constructor Details

#initialize(output:, mention_replacer:, text_processor:, on_debug: nil) ⇒ SavedItemFormatter

Returns a new instance of SavedItemFormatter.



7
8
9
10
11
12
# File 'lib/slk/formatters/saved_item_formatter.rb', line 7

def initialize(output:, mention_replacer:, text_processor:, on_debug: nil)
  @output = output
  @mentions = mention_replacer
  @text_processor = text_processor
  @on_debug = on_debug
end

Instance Method Details

#display_item(item, workspace, message: nil, width: nil, truncate: false) ⇒ Object

Display a single saved item

Parameters:

  • truncate (Boolean) (defaults to: false)

    if true, truncate to single line at width instead of wrapping



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/slk/formatters/saved_item_formatter.rb', line 16

def display_item(item, workspace, message: nil, width: nil, truncate: false)
  status_badge = format_status_badge(item)
  due_info = format_due_info(item)

  # First line: status badge and due info
  header_parts = [status_badge, due_info].compact.reject(&:empty?)
  @output.puts header_parts.join(' | ') unless header_parts.empty?

  # Message content
  display_message(message, workspace, width: width, truncate: truncate) if message
  @output.puts # blank line between items
end