class Mudguard::Infrastructure::Cli::NotificationAdapter

Forwards Notification to the view for printing

Public Class Methods

new(view:, compressed: false) click to toggle source
# File lib/mudguard/infrastructure/cli/notification_adapter.rb, line 8
def initialize(view:, compressed: false)
  @view = view
  @compressed = compressed
  @printed_texts = Set.new
end

Public Instance Methods

add(location, text) click to toggle source
# File lib/mudguard/infrastructure/cli/notification_adapter.rb, line 14
def add(location, text)
  text = if location.nil? || @compressed
           text
         else
           "#{location} #{text}"
         end
  @view.print(text) unless @printed_texts.include?(text)
  @printed_texts << text
end