Class: BrewOutdatedFormatter::XMLFormatter
- Defined in:
- lib/brew_outdated_formatter/formatter/xml_formatter.rb
Overview
Formatter for XML
Constant Summary
Constants inherited from Formatter
Formatter::COLUMNS, Formatter::CURRENT_REGEXP, Formatter::FORMULA_REGEXP, Formatter::INSTALLED_REGEXP, Formatter::PINNED_REGEXP
Instance Method Summary collapse
- #convert ⇒ Object
-
#initialize(options) ⇒ XMLFormatter
constructor
A new instance of XMLFormatter.
Methods inherited from Formatter
Constructor Details
#initialize(options) ⇒ XMLFormatter
Returns a new instance of XMLFormatter.
7 8 9 10 11 12 13 14 |
# File 'lib/brew_outdated_formatter/formatter/xml_formatter.rb', line 7 def initialize() super() @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 |
Instance Method Details
#convert ⇒ Object
16 17 18 19 20 21 22 23 24 |
# 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 |