class Polites::Convert

Convert a Polites file to another format.

Public Class Methods

new(parser: Polites::Parser.new, formatter: Polites::HtmlFormatter.new) click to toggle source

@param [Polites::Parser] parser @param [Polites::HtmlFormatter] formatter

# File lib/polites/convert.rb, line 12
def initialize(parser: Polites::Parser.new, formatter: Polites::HtmlFormatter.new)
  @parser = parser
  @formatter = formatter
end

Public Instance Methods

call(filename) click to toggle source

Convert the contents of `filename` to HTML and return the result as a String.

@param [#to_s, to_path] filename @return [String]

# File lib/polites/convert.rb, line 21
def call(filename)
  File.open(filename) do |f|
    f.content
     .then { |c| @parser.parse_sheet(c) }
     .then { |c| @formatter.call(c) }
  end
end