Class: VertForm

Inherits:
Object
  • Object
show all
Defined in:
lib/vertform.rb,
lib/vertform/version.rb

Constant Summary collapse

VERSION =

:nodoc:

"0.0.1"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(form_fields = {}) ⇒ VertForm

Returns a new instance of VertForm.



6
7
8
9
10
11
12
13
14
15
# File 'lib/vertform.rb', line 6

def initialize(form_fields = {})
  @table_style = {
    "class" => "table"
  }
  @label_stlye = {
    "class" => "pull-right",
    "style" => "margin-top: 4px;"
  }
  @form_fields = form_fields
end

Instance Attribute Details

#form_fieldsObject

Returns the value of attribute form_fields.



4
5
6
# File 'lib/vertform.rb', line 4

def form_fields
  @form_fields
end

#label_stlyeObject

Returns the value of attribute label_stlye.



4
5
6
# File 'lib/vertform.rb', line 4

def label_stlye
  @label_stlye
end

#table_styleObject

Returns the value of attribute table_style.



4
5
6
# File 'lib/vertform.rb', line 4

def table_style
  @table_style
end

Instance Method Details

#rend_form(form_fields = @form_fields) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/vertform.rb', line 17

def rend_form(form_fields = @form_fields)
  out_string = ""
  out_string .
  concat "<table " .
  concat pair_json(@table_style) .
  concat ">\n"
  form_fields.each { |label,field|
    out_string .
    concat "  <tr>\n    <td>\n      " .
    concat "<span " .
    concat pair_json(@label_stlye) .
    concat ">\n        " .
    concat(label) .
    concat "\n      </span>\n    </td>\n    <td>\n      <%= " .
    concat(field) .
    concat " %>\n    </td>\n  </tr>\n</table>"
  }
  out_string
end