Class: BrewOutdatedFormatter::HTMLFormatter

Inherits:
Formatter
  • Object
show all
Defined in:
lib/brew_outdated_formatter/formatter/html_formatter.rb

Overview

Formatter for HTML

Constant Summary

Constants inherited from Formatter

Formatter::COLUMNS, Formatter::CURRENT_REGEXP, Formatter::FORMULA_REGEXP, Formatter::INSTALLED_REGEXP, Formatter::PINNED_REGEXP

Instance Method Summary collapse

Methods inherited from Formatter

#read_stdin

Constructor Details

#initialize(options) ⇒ HTMLFormatter

Returns a new instance of HTMLFormatter.



7
8
9
10
11
12
13
# File 'lib/brew_outdated_formatter/formatter/html_formatter.rb', line 7

def initialize(options)
  super(options)

  @html = REXML::Document.new(nil, raw: :all)
  @root = REXML::Element.new('table')
  @html.add_element(@root)
end

Instance Method Details

#convertObject



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/brew_outdated_formatter/formatter/html_formatter.rb', line 15

def convert
  add_header_row

  @outdated_formulas.each do |formula|
    add_data_row(formula)
  end

  io = StringIO.new
  xml_formatter.write(@html, io)
  io.string.chomp
end