Class: USaidWat::CLI::CompactCommentFormatter

Inherits:
BaseFormatter show all
Defined in:
lib/usaidwat/formatter/comment.rb

Instance Method Summary collapse

Methods inherited from BaseFormatter

#initialize, #pattern, #pattern?, #raw?, #relative_dates?

Methods included from TTYFormatter

#tty

Constructor Details

This class inherits a constructor from USaidWat::CLI::BaseFormatter

Instance Method Details

#format(comment) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/usaidwat/formatter/comment.rb', line 61

def format(comment)
  cols = tty.width
  out = StringIO.new
  subreddit = comment.subreddit
  cols -= subreddit.length + 1
  title = comment.link_title.strip.unescape_html
  key = "#{subreddit} #{title}"
  if !seen?(key)
    out.write("#{subreddit}".color(:green))
    out.write(" #{title}\n")
  end
  mark_seen(key)
  out.rewind
  out.read
end