Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save manishdas/1184461 to your computer and use it in GitHub Desktop.
Save manishdas/1184461 to your computer and use it in GitHub Desktop.
line = CF::Line.create("Bizzcardarmy","Digitization") do |l|
# creation of initial input_formats for line with (Company, Website)
CF::InputFormat.new({:line => l, :name => "Company", :required => true})
CF::InputFormat.new({:line => l, :name => "Website", :required => true, :valid_type => "url"})
# creation of first station with input_format Company and without Website
CF::Station.create({:line => l, :type => "work", :input_formats=> {:station_0 => [{:name => "Company"},{:name => "Website", :except => true}]}}) do |s|
CF::HumanWorker.new({:station => s, :number => 1, :reward => 20})
CF::TaskForm.create({:station => s, :title => "Enter the name of CEO", :instruction => "Describe"}) do |i|
CF::FormField.new({:form => i, :label => "First Name", :field_type => "short_answer", :required => "true"})
CF::FormField.new({:form => i, :label => "Middle Name", :field_type => "short_answer"})
CF::FormField.new({:form => i, :label => "Last Name", :field_type => "short_answer", :required => "true"})
end
end
end
# For example: creation of second station with input_format Website used from line hence use station_0 (line's input_formats acts as input_format of base station) and eliminated Last Name from first station.
# By default second station have (First Name, Middle Name & Last Name) input_formats.
station = CF::Station.new(
{:type => "work", :input_formats => {:station_0 => [{:name => "Website"}], :station_1 => [{:name => "Last Name", :except => true}]}})
line.stations station
# So now the input_formats for second station are (First Name, Middle Name, Website)
worker = CF::HumanWorker.new({:number => 1, :reward => 10})
line.stations.last.worker = worker
form = CF::TaskForm.new({:title => "Enter the address of the given Person", :instruction => "Description"})
line.stations.last.form = form
form_fields_1 = CF::FormField.new({:label => "Street", :field_type => "SA", :required => "true"})
line.stations.last.form.form_fields form_fields_1
form_fields_2 = CF::FormField.new({:label => "City", :field_type => "SA", :required => "true"})
line.stations.last.form.form_fields form_fields_2
form_fields_3 = CF::FormField.new({:label => "Country", :field_type => "SA", :required => "true"})
line.stations.last.form.form_fields form_fields_3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment