class BrewOutdatedFormatter::HTMLFormatter
Formatter
for HTML
Public Class Methods
new(options)
click to toggle source
Calls superclass method
BrewOutdatedFormatter::Formatter::new
# 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
Public Instance Methods
convert()
click to toggle source
# 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
Private Instance Methods
add_data_row(formula)
click to toggle source
# File lib/brew_outdated_formatter/formatter/html_formatter.rb, line 37 def add_data_row(formula) elements = @root.add_element(REXML::Element.new('tr')) COLUMNS.each do |column| elements.add_element('td').add_text(formula[column]) end end
add_header_row()
click to toggle source
# File lib/brew_outdated_formatter/formatter/html_formatter.rb, line 29 def add_header_row elements = @root.add_element(REXML::Element.new('tr')) COLUMNS.each do |column| elements.add_element('th').add_text(column) end end