Class: Fdoc::ResponseCodePresenter

Inherits:
BasePresenter show all
Defined in:
lib/fdoc/presenters/response_code_presenter.rb

Overview

An BasePresenter for ResponseCodes

Instance Attribute Summary collapse

Attributes inherited from BasePresenter

#options

Instance Method Summary collapse

Methods inherited from BasePresenter

#css_path, #get_binding, #html_directory, #index_path, #render_erb, #render_markdown, #tag_with_anchor

Constructor Details

#initialize(response_code, options) ⇒ ResponseCodePresenter

Returns a new instance of ResponseCodePresenter.



5
6
7
8
# File 'lib/fdoc/presenters/response_code_presenter.rb', line 5

def initialize(response_code, options)
  super(options)
  @response_code = response_code
end

Instance Attribute Details

#response_codeObject (readonly)

Returns the value of attribute response_code.



3
4
5
# File 'lib/fdoc/presenters/response_code_presenter.rb', line 3

def response_code
  @response_code
end

Instance Method Details

#descriptionObject



33
34
35
# File 'lib/fdoc/presenters/response_code_presenter.rb', line 33

def description
  render_markdown(description_raw)
end

#description_rawObject



37
38
39
# File 'lib/fdoc/presenters/response_code_presenter.rb', line 37

def description_raw
  response_code["description"]
end

#statusObject



29
30
31
# File 'lib/fdoc/presenters/response_code_presenter.rb', line 29

def status
  response_code["status"]
end

#successful?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/fdoc/presenters/response_code_presenter.rb', line 25

def successful?
  response_code["successful"]
end

#to_htmlObject



10
11
12
13
14
15
16
17
18
19
# File 'lib/fdoc/presenters/response_code_presenter.rb', line 10

def to_html
  <<-EOS
    <div class="response-code">
      <span class="status">
        #{status}
      </span>
      #{description}
    </div>
  EOS
end

#to_markdownObject



21
22
23
# File 'lib/fdoc/presenters/response_code_presenter.rb', line 21

def to_markdown
  "__#{status}__: #{description_raw}"
end