Class: VertForm
- Inherits:
-
Object
- Object
- VertForm
- Defined in:
- lib/vertform.rb,
lib/vertform/version.rb
Constant Summary collapse
- VERSION =
:nodoc:
"0.0.1"
Instance Attribute Summary collapse
-
#form_fields ⇒ Object
Returns the value of attribute form_fields.
-
#label_stlye ⇒ Object
Returns the value of attribute label_stlye.
-
#table_style ⇒ Object
Returns the value of attribute table_style.
Instance Method Summary collapse
-
#initialize(form_fields = {}) ⇒ VertForm
constructor
A new instance of VertForm.
- #rend_form(form_fields = @form_fields) ⇒ Object
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_fields ⇒ Object
Returns the value of attribute form_fields.
4 5 6 |
# File 'lib/vertform.rb', line 4 def form_fields @form_fields end |
#label_stlye ⇒ Object
Returns the value of attribute label_stlye.
4 5 6 |
# File 'lib/vertform.rb', line 4 def label_stlye @label_stlye end |
#table_style ⇒ Object
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 |