Class: HexletCode::FormPresenter

Inherits:
Object
  • Object
show all
Defined in:
lib/hexlet_code/form_presenter.rb

Instance Method Summary collapse

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, options = {})
  @form = form
  @url = options[:url] || '#'
  @method = options[:method] || 'post'
  @class = options[:class] || ''
end

Instance Method Details

#render_htmlObject



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