Class: USaidWat::CLI::PostFormatter
- Inherits:
-
BaseFormatter
- Object
- BaseFormatter
- USaidWat::CLI::PostFormatter
- Defined in:
- lib/usaidwat/formatter/post.rb
Instance Method Summary collapse
Methods inherited from BaseFormatter
#initialize, #pattern, #pattern?, #raw?, #relative_dates?
Methods included from TTYFormatter
Constructor Details
This class inherits a constructor from USaidWat::CLI::BaseFormatter
Instance Method Details
#format(post) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/usaidwat/formatter/post.rb', line 4 def format(post) cols = tty.width out = StringIO.new out.write("\n\n\n") unless @count == 0 out.write("#{post.subreddit}\n".color(:green)) out.write("#{post_link(post)}\n".color(:yellow)) out.write("#{post.title.strip.unescape_html}\n".color(:magenta)) out.write("#{post_date(post)}".color(:blue)) out.write("\n#{post.url}") unless post.url.end_with?(post.permalink) @count += 1 out.rewind out.read end |