class Angband::Formatter

Public Class Methods

new(accept_headers) click to toggle source
# File lib/angband/formatter.rb, line 5
def initialize(accept_headers)
  @accept_headers = accept_headers
end

Public Instance Methods

call(features) click to toggle source
# File lib/angband/formatter.rb, line 9
def call(features)
  case @accept_headers.media_type.best_of(['application/vnd.gherkin', 'text/html'])
  when 'text/html'
    [
      {'Content-Type' => 'text/html'},
      render('templates/html.mustache', features)
    ]
  else
    [
      {'Content-Type' => 'application/vnd.gherkin'},
      render('templates/plain.mustache', features)
    ]
  end
end

Private Instance Methods

render(file, features) click to toggle source
# File lib/angband/formatter.rb, line 26
def render(file, features)
  Mustache.render(
    File.read(File.expand_path("../../#{file}", __FILE__)),
    :features => features
  ).strip
end