Class: HtmlMxmlcErrorFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/formatters/html_mxmlc_error_formatter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(errors, template = nil) ⇒ HtmlMxmlcErrorFormatter

Returns a new instance of HtmlMxmlcErrorFormatter.



8
9
10
11
12
# File 'lib/formatters/html_mxmlc_error_formatter.rb', line 8

def initialize(errors, template = nil)
  @errors = errors
  @template_file = template || File.join(File.dirname(__FILE__), '..', '..', 'templates', 'standard.html.erb')
  @out = format!
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



6
7
8
# File 'lib/formatters/html_mxmlc_error_formatter.rb', line 6

def errors
  @errors
end

#outObject (readonly)

Returns the value of attribute out.



6
7
8
# File 'lib/formatters/html_mxmlc_error_formatter.rb', line 6

def out
  @out
end

Instance Method Details

#format!Object



14
15
16
17
18
19
# File 'lib/formatters/html_mxmlc_error_formatter.rb', line 14

def format!
  template = ''
  File.open(@template_file).each_line { |l| template << l }
  formatted = ERB.new(template, 0, '%<>')
  formatted.result(binding)
end