Class: FormBuilder

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

Overview

Create custom forms for complete text data extraction stage

Defined Under Namespace

Classes: Field

Instance Method Summary collapse

Constructor Details

#initialize(sr, cd, user) ⇒ FormBuilder

Returns a new instance of FormBuilder.



34
35
36
37
38
39
# File 'lib/form_builder.rb', line 34

def initialize(sr, cd,user)
  @sr=sr
  @cd=cd
  @user=user
  @javascript=[]
end

Instance Method Details

#add_javascript(js) ⇒ Object



45
46
47
# File 'lib/form_builder.rb', line 45

def add_javascript(js)
  @javascript.push(js)
end

#each_fieldObject



40
41
42
43
44
# File 'lib/form_builder.rb', line 40

def each_field
  SrField.where(:systematic_review_id=>@sr[:id]).order(:order).each do |field|
    yield Field.new(field, @sr,@cd, @user,self)
  end
end

#javascriptObject



48
49
50
51
52
53
# File 'lib/form_builder.rb', line 48

def javascript
  return "" unless @javascript.length>0
  "<script type='text/javascript'>
  #{@javascript.join("\n")}
  </script>"
end