Class: Gobstones::HtmlRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/render/html_renderer.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ HtmlRenderer

Returns a new instance of HtmlRenderer.



5
6
7
# File 'lib/render/html_renderer.rb', line 5

def initialize(options)
  @options = options
end

Instance Method Details

#render_error_check_error_failed_another_reason(result) ⇒ Object



50
51
52
53
54
# File 'lib/render/html_renderer.rb', line 50

def render_error_check_error_failed_another_reason(result)
  bind_result error: :check_error_failed_another_reason,
              expected_code: I18n.t("code_#{result[:expected_code]}"),
              reason: prepare_reason(result[:reason])
end

#render_error_check_error_failed_expected_boom(result) ⇒ Object



32
33
34
35
# File 'lib/render/html_renderer.rb', line 32

def render_error_check_error_failed_expected_boom(result)
  bind_result error: :check_error_failed_expected_boom,
              boards: prepare_boards([:initial, :expected, :final], result)
end

#render_error_check_failed_unexpected_boom(result) ⇒ Object



26
27
28
29
30
# File 'lib/render/html_renderer.rb', line 26

def render_error_check_failed_unexpected_boom(result)
  bind_result error: :check_failed_unexpected_boom,
              boards: prepare_boards([:initial, :expected, :actual], result),
              reason: prepare_reason(result[:reason])
end

#render_error_check_final_board_failed_different_boards(result) ⇒ Object



16
17
18
19
# File 'lib/render/html_renderer.rb', line 16

def render_error_check_final_board_failed_different_boards(result)
  bind_result error: :check_final_board_failed_different_boards,
              boards: prepare_boards([:initial, :expected, :actual], result)
end

#render_error_check_final_board_failed_different_headers(result) ⇒ Object



21
22
23
24
# File 'lib/render/html_renderer.rb', line 21

def render_error_check_final_board_failed_different_headers(result)
  bind_result error: :check_final_board_failed_different_headers,
              boards: prepare_boards([:initial, :expected, :actual], result)
end

#render_error_check_return_failed_different_values(result) ⇒ Object



43
44
45
46
47
48
# File 'lib/render/html_renderer.rb', line 43

def render_error_check_return_failed_different_values(result)
  bind_result error: :check_return_failed_different_values,
              boards: prepare_boards([:initial], result),
              expected_value: result[:expected_value],
              actual_value: result[:actual_value]
end

#render_error_check_return_failed_no_return(result) ⇒ Object



37
38
39
40
41
# File 'lib/render/html_renderer.rb', line 37

def render_error_check_return_failed_no_return(result)
  bind_result error: :check_return_failed_no_return,
              boards: prepare_boards([:initial], result),
              expected_value: result[:expected_value]
end

#render_success(result) ⇒ Object



9
10
11
12
13
14
# File 'lib/render/html_renderer.rb', line 9

def render_success(result)
  board_types = [:initial, :final]
  board_types.reject!{ |it| it === :initial } unless @options[:show_initial_board]
  bind_result boards: prepare_boards(board_types, result),
              reason: prepare_reason(result[:reason])
end