class BrewOutdatedFormatter::XMLFormatter
Formatter
for XML
Public Class Methods
new(options)
click to toggle source
Calls superclass method
BrewOutdatedFormatter::Formatter::new
# File lib/brew_outdated_formatter/formatter/xml_formatter.rb, line 7 def initialize(options) super(options) @xml = REXML::Document.new(nil, raw: :all) @xml << REXML::XMLDecl.new('1.0', 'UTF-8') @root = REXML::Element.new('formulas') @xml.add_element(@root) end
Public Instance Methods
convert()
click to toggle source
# File lib/brew_outdated_formatter/formatter/xml_formatter.rb, line 16 def convert @outdated_formulas.each do |formula| add_outdated(formula) end io = StringIO.new xml_formatter.write(@xml, io) io.string.chomp end
Private Instance Methods
add_outdated(formula)
click to toggle source
# File lib/brew_outdated_formatter/formatter/xml_formatter.rb, line 28 def add_outdated(formula) elements = @root.add_element(REXML::Element.new('outdated')) COLUMNS.each do |column| elements.add_element(column).add_text(formula[column]) end end