Class: HexletCode::FormPresenter
- Inherits:
-
Object
- Object
- HexletCode::FormPresenter
- Defined in:
- lib/hexlet_code/form_presenter.rb
Instance Method Summary collapse
-
#initialize(form, options = {}) ⇒ FormPresenter
constructor
A new instance of FormPresenter.
- #render_html ⇒ Object
Constructor Details
#initialize(form, options = {}) ⇒ FormPresenter
Returns a new instance of FormPresenter.
5 6 7 8 9 10 |
# File 'lib/hexlet_code/form_presenter.rb', line 5 def initialize(form, = {}) @form = form @url = [:url] || '#' @method = [:method] || 'post' @class = [:class] || '' end |
Instance Method Details
#render_html ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/hexlet_code/form_presenter.rb', line 12 def render_html result = "<form action=\"#{@url}\" method=\"#{@method}\"" result << " class=\"#{@class}\"" unless @class.nil? || @class.empty? result << '>' result << content unless @form.nil? || @form.empty? result << "\n</form>" end |