query
stringlengths 7
9.55k
| document
stringlengths 10
363k
| metadata
dict | negatives
sequencelengths 0
101
| negative_scores
sequencelengths 0
101
| document_score
stringlengths 3
10
| document_rank
stringclasses 102
values |
---|---|---|---|---|---|---|
DELETE /part_time_employees/1 DELETE /part_time_employees/1.json | def destroy
@part_time_employee.destroy
respond_to do |format|
format.html { redirect_to part_time_employees_url, notice: 'Part time employee was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deleteEntityEmployee( entity_id, gen_id)\n params = Hash.new\n params['entity_id'] = entity_id\n params['gen_id'] = gen_id\n return doCurl(\"delete\",\"/entity/employee\",params)\n end",
"def destroy\n @hisd_employee = HisdEmployee.find(params[:id])\n @hisd_employee.destroy\n\n respond_to do |format|\n format.html { redirect_to hisd_employees_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @employee_events = EmployeeEvent.with_deleted.find(params[:id])\n if params[:type]=='normal'\n @employee_event.delete\n elsif params[:type]=='restore'\n @employee_event.restore\n @employee_event.update(deleted_at: nil)\n end\n\n @employee_event.destroy\n respond_to do |format|\n format.html { redirect_to :back, notice: 'Host was successfully removed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @scheduled_employee = ScheduledEmployee.find(params[:id])\n @scheduled_employee.destroy\n\n respond_to do |format|\n format.html { redirect_to employees_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @employee.destroy\n respond_to do |format|\n format.html { redirect_to employees_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @employee.destroy\n respond_to do |format|\n format.html { redirect_to employees_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @employee.destroy\n respond_to do |format|\n format.html { redirect_to employees_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @employee.destroy\n respond_to do |format|\n format.html { redirect_to employees_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @employee.destroy\n respond_to do |format|\n format.html { redirect_to employees_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @employee.destroy\n respond_to do |format|\n format.html { redirect_to employees_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @employee.destroy\n respond_to do |format|\n format.html { redirect_to employees_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @time_off_request = TimeOffRequest.find(params[:id])\n @time_off_request.destroy\n \n respond_to do |format|\n format.html { redirect_to admin_time_off_requests_url}\n format.json { head :ok }\n end\n end",
"def destroy\n Tools.write2log(current_user.id, 'Удаление', 'Сотрудники', 0, '# ' + @employee.id.to_s)\n @employee.destroy\n respond_to do |format|\n format.html { redirect_to employees_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @time_period.destroy\n format.json { head :no_content }\n end",
"def destroy\n @employee = Employee.find(params[:id])\n @employee.destroy\n\n respond_to do |format|\n format.html { redirect_to employees_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @employee = Employee.find(params[:id])\n @employee.destroy\n\n respond_to do |format|\n format.html { redirect_to employees_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @employee = Employee.find(params[:id])\n @employee.destroy\n\n respond_to do |format|\n format.html { redirect_to employees_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @employee = Employee.find(params[:id])\n @employee.destroy\n\n respond_to do |format|\n format.html { redirect_to employees_url }\n format.json { head :no_content }\n end\n end",
"def repair_order_employees_delete\n @repair_order_employee = current_business_user.employee_users_repair_orders.find(params[:id])\n\n @repair_order_employee.destroy\n if @repair_order_employee\n render json: { repair_order_employees: @repair_order_employee.as_json },\n status: :ok\n else\n render json: { errors: @repair_order_employee.errors.full_messages },\n status: :unprocessable_entity\n end\n end",
"def destroy\n @employe.destroy\n respond_to do |format|\n format.html { redirect_to employes_path(api_id: @employe.organisme_id), notice: 'Employe was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @employee = current_owner.employees.find(params[:id])\n @employee.destroy\n\n respond_to do |format|\n format.html { redirect_to employees_url }\n format.json { head :no_content }\n end\n end",
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def destroy\n @employe = Employe.find(params[:id])\n @employe.destroy\n\n respond_to do |format|\n format.html { redirect_to employes_url }\n format.json { head :no_content }\n end\n end",
"def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end",
"def destroy\n @officehour = Officehour.find(params[:id])\n @officehour.destroy\n\n respond_to do |format|\n format.html { redirect_to officehours_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @emp_date_detail = EmpDateDetail.find(params[:id])\n @emp_date_detail.destroy\n\n respond_to do |format|\n format.html { redirect_to emp_date_details_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @program_employee.destroy\n respond_to do |format|\n format.html { redirect_to program_employees_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @empolyee.destroy\n respond_to do |format|\n format.html { redirect_to empolyees_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @employee_workinghour.destroy\n respond_to do |format|\n format.html { redirect_to employee_workinghours_url, notice: 'Employee workinghour was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @employ = Employ.find(params[:id])\n @employ.destroy\n\n respond_to do |format|\n format.html { redirect_to employs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @employee_week_off.destroy\n respond_to do |format|\n format.html { redirect_to employee_week_offs_url, notice: 'Employee week off was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(path)\n RestClient.delete request_base+path\n end",
"def deleteEntityOpening_times( entity_id)\n params = Hash.new\n params['entity_id'] = entity_id\n return doCurl(\"delete\",\"/entity/opening_times\",params)\n end",
"def destroy\n @daytime = Daytime.find(params[:id])\n @daytime.destroy\n\n respond_to do |format|\n format.html { redirect_to daytimes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @employee.destroy\n\n respond_to do |format|\n format.html { redirect_to :back }\n format.json { head :no_content }\n end\n end",
"def destroy\n @time_entry = TimeEntry.with_deleted.find(params[:id])\n @time_entry.destroy\n\n respond_to do |format|\n format.html { redirect_to time_entries_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @office_hour_detail.destroy\n respond_to do |format|\n format.html { redirect_to office_hour_details_url, notice: 'Office hour detail was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @employment.destroy\n respond_to do |format|\n format.html { redirect_to employments_url }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @time_clock.destroy\n respond_to do |format|\n format.html { redirect_to time_sheet_index_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @aga_employee.destroy\n respond_to do |format|\n format.html { redirect_to @aga_employee, notice: 'Aga employee was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @employee_physical.destroy\n respond_to do |format|\n format.html { redirect_to employee_physicals_url, notice: 'Employee physical was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @employee_personal.destroy\n respond_to do |format|\n format.html { redirect_to employee_personals_url, notice: 'Employee personal was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n puts @iot_datum.count\n if @iot_datum.count > 0\n @deleted_rec = IotDatum.new\n @deleted_rec.workbench_number = @iot_datum.workbench_number\n @deleted_rec.part_number = @iot_datum.part_number\n @deleted_rec.target = @iot_datum.target\n @deleted_rec.lot_size = @iot_datum.lot_size\n @deleted_rec.employee_name = @iot_datum.employee_name\n @deleted_rec.shift = @iot_datum.shift\n @deleted_rec.device_id = @iot_datum.device_id\n @deleted_rec.count = @iot_datum.count\n @deleted_rec.status = 'Deleted'\n @deleted_rec.save!\n @iot_datum.destroy\n else\n @iot_datum.destroy\n end\n respond_to do |format|\n format.html { redirect_to iot_data_url, notice: 'Planner was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @company = Company.find(params[:company_id]) \n @employee = @company.employees.find(params[:id])\n \n @employee.destroy\n respond_to do |format|\n format.html { redirect_to company_employees_url, notice: 'Employee was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @time_of_day.destroy\n respond_to do |format|\n format.html { redirect_to time_of_days_url, notice: 'Time of day was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @employee_master.destroy\n respond_to do |format|\n format.html { redirect_to employee_masters_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @meal_time = MealTime.find(params[:id])\n @meal_time.destroy\n\n respond_to do |format|\n format.html { redirect_to meal_times_url }\n format.json { head :no_content }\n end\n end",
"def delete(path_part, additional_headers = {}, &block)\n api_request { @rest.delete('/REST/' + path_part, \"\", additional_headers, &block) }\n end",
"def destroy\n @emp_job = EmpJob.find(params[:id])\n @emp_job.destroy\n\n respond_to do |format|\n format.html { redirect_to emp_jobs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @daily_exercise = DailyExercise.find(params[:id])\n @daily_exercise.destroy\n\n respond_to do |format|\n format.html { redirect_to daily_exercises_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @education_service_provided_typology.destroy\n respond_to do |format|\n format.html { redirect_to education_service_provided_typologies_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @estimated_hour.destroy\n respond_to do |format|\n format.html { redirect_to estimated_hours_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @employee_task.destroy\n respond_to do |format|\n format.html { redirect_to employee_tasks_url, notice: 'Employee task was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @big_time_entry.destroy\n respond_to do |format|\n format.html { redirect_to big_time_entries_url, notice: 'Big time entry was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @timesheet.destroy\n respond_to do |format|\n format.html { redirect_to timesheets_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @employee_insentive.destroy\n respond_to do |format|\n format.html { redirect_to employee_insentives_url, notice: 'Employee insentive was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @rowempl = Rowempl.find(params[:id])\n @rowempl.destroy\n\n respond_to do |format|\n format.html { redirect_to rowempls_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @employee.destroy\n respond_to do |format|\n format.html { redirect_to employees_path, notice: 'Employee was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @employee.destroy\n respond_to do |format|\n format.html { redirect_to employees_url, notice: 'Employee was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @employee.destroy\n respond_to do |format|\n format.html { redirect_to employees_url, notice: 'Employee was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\r\n @officehour.destroy\r\n respond_to do |format|\r\n format.html { redirect_to officehours_url, notice: 'Officehour was successfully destroyed.' }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @employee.destroy\n respond_to do |format|\n format.html { redirect_to employees_url, notice: \"Employee was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @employee.destroy\n respond_to do |format|\n format.html { redirect_to employees_url, notice: \"Employee was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @employee.destroy\n respond_to do |format|\n format.html { redirect_to employees_url, notice: 'Employee was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @employee.destroy\n respond_to do |format|\n format.html { redirect_to employees_url, notice: 'Employee was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @employee.destroy\n respond_to do |format|\n format.html { redirect_to employees_url, notice: 'Employee was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @employee.destroy\n respond_to do |format|\n format.html { redirect_to employees_url, notice: 'Employee was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @employee.destroy\n respond_to do |format|\n format.html { redirect_to employees_url, notice: 'Employee was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @employee.destroy\n respond_to do |format|\n format.html { redirect_to employees_url, notice: 'Employee was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @employee.destroy\n respond_to do |format|\n format.html { redirect_to employees_url, notice: 'Employee was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @employee.destroy\n respond_to do |format|\n format.html { redirect_to employees_url, notice: 'Employee was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @employee.destroy\n respond_to do |format|\n format.html { redirect_to employees_url, notice: 'Employee was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @employee.destroy\n respond_to do |format|\n format.html { redirect_to employees_url, notice: 'Employee was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @employee.destroy\n respond_to do |format|\n format.html { redirect_to employees_url, notice: 'Employee was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @poi_time.destroy\n respond_to do |format|\n format.html { redirect_to poi_times_url, notice: 'Poi time was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @employee.occupational_histories.each do |oh|\n oh.destroy\n end\n @employee.absenteeisms.each do |a|\n a.destroy\n end\n @employee.destroy\n respond_to do |format|\n format.html { redirect_to employees_url, notice: 'Employee was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @employee = Employee.find(params[:id])\n @employee.destroy\n respond_with(@employee)\n end",
"def destroy\n @employee_type.destroy\n respond_to do |format|\n format.html { redirect_to employee_types_url, notice: 'Employee type was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @employed.destroy\n respond_to do |format|\n format.html { redirect_to employeds_url, notice: 'Employed was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @elective_day.destroy\n respond_to do |format|\n format.html { redirect_to elective_days_url }\n format.json { head :no_content }\n end\n end",
"def delete(*rest) end",
"def destroy\n @weekly_expectation = WeeklyExpectation.find(params[:id])\n @weekly_expectation.destroy\n\n respond_to do |format|\n format.html { redirect_to weekly_expectations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user_hour_requirement = UserHourRequirement.find(params[:id])\n @user_hour_requirement.destroy\n\n respond_to do |format|\n format.html { redirect_to user_hour_requirements_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @titletime.destroy\n respond_to do |format|\n format.html { redirect_to titletimes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @master_employe.destroy\n respond_to do |format|\n format.html { redirect_to master_employes_url, notice: 'Employe was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @timesheet = Timesheet.find(params[:id])\n @date = @timesheet.day\n @timesheet.destroy\n\n @timesheets = current_user.timesheets\n @title = \"My Timesheets\"\n\n respond_to do |format|\n format.html { render :index }\n format.json { head :ok }\n end\n end",
"def destroy\n @time_line.destroy\n respond_to do |format|\n format.html { redirect_to time_lines_url, notice: 'Time line was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @meeting_time.destroy\n respond_to do |format|\n format.html { redirect_to meeting_times_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n\n @employee.destroy\n respond_to do |format|\n format.html { redirect_to employees_url, notice: 'Employee was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @time_section = TimeSection.find(params[:id])\n @time_section.destroy\n\n respond_to do |format|\n format.html { redirect_to time_sections_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @timesheet_entry = TimesheetEntry.find(params[:id])\n @timesheet_entry.destroy\n\n respond_to do |format|\n format.html { redirect_to timesheet_entries_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @employee.destroy\n respond_to do |format|\n format.html { redirect_to employees_url, notice: 'El empleado ha sido eliminado con éxito.' }\n format.json { head :no_content }\n end\n end",
"def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_response.ok?\n\n get \"/traces/#{id}\"\n\n contents = JSON.parse last_response.body\n assert_kind_of(Hash, contents, 'Response contents is not a hash')\n assert contents.key? 'description'\n assert(!last_response.ok?)\n end",
"def destroy\n @emp1.destroy\n respond_to do |format|\n format.html { redirect_to emp1s_url, notice: 'Emp1 was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @employee.destroy\n respond_to do |format|\n format.html { redirect_to dashboard_path, notice: 'Employee was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @time_record = TimeRecord.find(params[:id])\n @time_record.destroy\n\n respond_to do |format|\n format.html { redirect_to time_records_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @time_record = TimeRecord.find(params[:id])\n @time_record.destroy\n\n respond_to do |format|\n format.html { redirect_to time_records_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contract_employee.destroy\n respond_to do |format|\n format.html { redirect_to contract_employees_url, notice: 'Contract employee was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @wing_employee.destroy\n respond_to do |format|\n format.html { redirect_to wing_employees_url, notice: 'Wing employee was successfully destroyed.' }\n format.json { head :no_content }\n end\n end"
] | [
"0.6858969",
"0.6697969",
"0.66694945",
"0.664149",
"0.6633967",
"0.6633967",
"0.6633967",
"0.6633967",
"0.6633967",
"0.6633967",
"0.6633967",
"0.6623983",
"0.66137403",
"0.66059476",
"0.6593751",
"0.6593751",
"0.6593751",
"0.6593751",
"0.6576537",
"0.6573103",
"0.65705514",
"0.6555293",
"0.6542103",
"0.65414435",
"0.6521715",
"0.6521691",
"0.651902",
"0.6513452",
"0.65116745",
"0.65085036",
"0.65005434",
"0.6454646",
"0.64398164",
"0.64230484",
"0.6419338",
"0.6417853",
"0.6417765",
"0.6401386",
"0.64001006",
"0.63933444",
"0.63909745",
"0.63833517",
"0.63832486",
"0.6381145",
"0.6380945",
"0.6367431",
"0.63619685",
"0.63565916",
"0.6355855",
"0.63405013",
"0.6339874",
"0.63369834",
"0.6335565",
"0.63327116",
"0.63269466",
"0.6326589",
"0.6325528",
"0.6321861",
"0.6321064",
"0.63205",
"0.63200897",
"0.63197017",
"0.6319091",
"0.6319091",
"0.63189274",
"0.63189274",
"0.63189274",
"0.63189274",
"0.63189274",
"0.63189274",
"0.63189274",
"0.63189274",
"0.63189274",
"0.63189274",
"0.63189274",
"0.6314564",
"0.6312112",
"0.6311091",
"0.63104916",
"0.63080466",
"0.63066196",
"0.63055813",
"0.6304865",
"0.6303378",
"0.63025934",
"0.630227",
"0.63022053",
"0.6301892",
"0.6299009",
"0.62984884",
"0.6298324",
"0.6291275",
"0.62912333",
"0.6290431",
"0.6287134",
"0.6286849",
"0.62820154",
"0.62820154",
"0.6281631",
"0.6278655"
] | 0.7205989 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_part_time_employee
@part_time_employee = PartTimeEmployee.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def setup_handler\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def workflow\n end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup\n # override and do something appropriate\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def after_set_callback; end",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def save_action; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def setup(&blk)\n @setup_block = blk\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def duas1(action)\n action.call\n action.call\nend",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend"
] | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576",
"0.53124547",
"0.529654",
"0.5296262",
"0.52952296",
"0.52600986",
"0.52442724",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.5232394",
"0.523231",
"0.5227454",
"0.52226824",
"0.52201617",
"0.5212327",
"0.52079266",
"0.52050185",
"0.51754695",
"0.51726824",
"0.51710224",
"0.5166172",
"0.5159343",
"0.51578903",
"0.51522785",
"0.5152022",
"0.51518047",
"0.51456624",
"0.51398855",
"0.5133759",
"0.5112076",
"0.5111866",
"0.5111866",
"0.5110294",
"0.5106169",
"0.509231",
"0.50873137",
"0.5081088",
"0.508059",
"0.50677156",
"0.50562143",
"0.5050554",
"0.50474834",
"0.50474834",
"0.5036181",
"0.5026331",
"0.5022976",
"0.5015441",
"0.50121695",
"0.5000944",
"0.5000019",
"0.4996878",
"0.4989888",
"0.4989888",
"0.49864885",
"0.49797225",
"0.49785787",
"0.4976161",
"0.49683493",
"0.4965126",
"0.4958034",
"0.49559742",
"0.4954353",
"0.49535993",
"0.4952725",
"0.49467874",
"0.49423352",
"0.49325448",
"0.49282882",
"0.49269363",
"0.49269104",
"0.49252945",
"0.4923091",
"0.49194667",
"0.49174926",
"0.49173003",
"0.49171105",
"0.4915879",
"0.49155936"
] | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def part_time_employee_params
params.require(:part_time_employee).permit(:dateOfHire, :dateOfTermination, :hourlyRate)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def param_whitelist\n [:role, :title]\n end",
"def expected_permitted_parameter_names; end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def permitted_params\n []\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params; true; end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def quote_params\n params.permit!\n end",
"def valid_params?; end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend",
"def filtered_parameters; end",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def filtering_params\n params.permit(:email, :name)\n end",
"def check_params\n true\n end",
"def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end",
"def active_code_params\n params[:active_code].permit\n end",
"def filtering_params\n params.permit(:email)\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end",
"def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end",
"def list_params\n params.permit(:name)\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def url_whitelist; end",
"def admin_social_network_params\n params.require(:social_network).permit!\n end",
"def filter_params\n params.require(:filters).permit(:letters)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end",
"def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def permit_request_params\n params.permit(:address)\n end",
"def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end",
"def secure_params\n params.require(:location).permit(:name)\n end",
"def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end",
"def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end",
"def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def url_params\n params[:url].permit(:full)\n end",
"def backend_user_params\n params.permit!\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end",
"def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end",
"def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end",
"def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end",
"def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end"
] | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",
"0.62894756",
"0.6283177",
"0.6242471",
"0.62382483",
"0.6217549",
"0.6214457",
"0.6209053",
"0.6193042",
"0.6177802",
"0.6174604",
"0.61714715",
"0.6161512",
"0.6151757",
"0.6150663",
"0.61461",
"0.61213595",
"0.611406",
"0.6106206",
"0.6105114",
"0.6089039",
"0.6081015",
"0.6071004",
"0.60620916",
"0.6019971",
"0.601788",
"0.6011056",
"0.6010898",
"0.6005122",
"0.6005122",
"0.6001556",
"0.6001049",
"0.59943926",
"0.5992201",
"0.59909594",
"0.5990628",
"0.5980841",
"0.59669393",
"0.59589154",
"0.5958826",
"0.5957911",
"0.5957385",
"0.5953072",
"0.59526145",
"0.5943361",
"0.59386164",
"0.59375334",
"0.59375334",
"0.5933856",
"0.59292704",
"0.59254247",
"0.5924164",
"0.59167904",
"0.59088355",
"0.5907542",
"0.59064597",
"0.5906243",
"0.5898226",
"0.589687",
"0.5896091",
"0.5894501",
"0.5894289",
"0.5891739",
"0.58860534",
"0.5882406",
"0.587974",
"0.58738774",
"0.5869024",
"0.58679986",
"0.5867561",
"0.5865932",
"0.5864461",
"0.58639693",
"0.58617616",
"0.5861436",
"0.5860451",
"0.58602303",
"0.5854586",
"0.58537364",
"0.5850427",
"0.5850199"
] | 0.0 | -1 |
sox $(ls .wav | sort n) out.wav | def execute(speed = false, repeat = 10)
folder = "/Users/THAO-NUS/Music/ProcessingMp3/Processing"
origin_folder = "public/audio/#{self.vol_aulm.name}"
speed = speed.present? ? "tempo #{speed}" : ''
each_durations.each_with_index do |arr, index|
duration = arr[1].to_i - arr[0].to_i
start = arr[0].to_i
name = "#{sprintf('%02d',index + 1)}.mp3"
full_name = "#{folder}/#{name}"
origin_full_name = Shellwords.shellescape "#{origin_folder}/#{self.name}"
command = "sox -e ima-adpcm #{origin_full_name} #{full_name} trim #{start} #{duration} repeat #{repeat} #{speed}"
system(command)
end
outname = Shellwords.shellescape("/Users/THAO-NUS/Music/ProcessingMp3/Results/#{self.name}")
command = "sox $(ls /Users/THAO-NUS/Music/ProcessingMp3/Processing/*.mp3 | sort -d) #{outname}"
system(command)
FileUtils.rm_rf("/Users/THAO-NUS/Music/ProcessingMp3/Processing/.", secure: true)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scribe\n raise 'bork' unless ARGV.any?\n\n name, type = ARGV.first.split('.')\n name_bits = name.to_s.ljust(64, ' ').to_bits\n type_bits = type.to_s.ljust(5, ' ').to_bits\n data_bits = File.open(ARGV.first) { |file| file.read }.to_bits\n size = data_bits.count / 8\n size_bits = (\"%032b\" % size).split('').map(&:to_i)\n prelude_bits = SYNC.map { |byte| \"%08b\" % byte }.join.split('').map(&:to_i)\n\n sample \"#{ name }.wav\", prelude_bits + name_bits + type_bits + size_bits + data_bits\nend",
"def 500_files(input)\n # naive solution is to flatten and sort\n\n \nend",
"def natural_sort_bitstreams\n filenames = self.bitstreams.map(&:filename)\n NaturalSort.sort!(filenames)\n self.bitstreams.each do |bs|\n bs.update!(bundle_position: filenames.index(bs.filename))\n end\n end",
"def make_sliced_file(flist)\n flist_sliced = []\n flist.each_with_index do |v, i|\n # 開始時のファイルはスライスしない\n if i == 0\n flist_sliced << v\n else\n tmp_file = \"/tmp/sound_#{i}.mp3\"\n silent_files = (Sound::SILENT_FILE_PATH + \" \") * i\n cmd = \"sox #{silent_files} #{v} #{tmp_file}\"\n result = `#{cmd}`\n flist_sliced << tmp_file\n end\n end\n return flist_sliced\n end",
"def files\n array_full_names = Dir.glob(\"#{@path}/*.mp3\")\n array_full_names.collect do |full_name|\n full_name[21..-1]\n end\n end",
"def audio_file_from_list(idx)\n @audio_file_list[idx]\n end",
"def sounds_for_digits(num)\n result = []\n num.to_s.each_char do |c|\n result << sound_path(\"#{c}.ul\")\n end\n result\n end",
"def music_shuffle filenames\n #Shuffle twice, cut once, like cards \n #Sort beforehand \n filenames = filenames.sort \n len = filenames.length \n\n 2.times do \n l_idx = 0 \n r_idx = len/2 \n shuf = []\n\n while shuf.length < len\n if shuf.length%2==0\n shuf.push(filenames[r_idx])\n r_idx = r_idx + 1 \n else \n shuf.push(filenames[l_idx])\n l_idx = l_idx + 1\n end \n end \n filenames = shuf \n end \n arr = []\n cut = rand(len)\n idx = idx + 1 \n while idx < len \n arr.push (filenames[(idx+cut)%len])\n idx = idx +1 \n end \n arr\nend",
"def files\n files = Dir[\"#{path}/*.mp3\"].each {|file_name| next if File.directory? file_name}\n norm_files = files.collect {|filename| File.basename(filename)}\n norm_files\n end",
"def get_audio_samples \n send_cmd(\"get_audio_samples\")\n end",
"def ex1\n WaveFile::Reader.new(\n File.expand_path('../440Hz,441samples.wav', File.dirname(__FILE__))\n ) do |reader|\n samples = reader.read(441).samples.to_a\n #puts samples.map(&:inspect).join(\",\")\n samples_to_graph!(samples, '440constant')\n embiggen_and_imgcat!('440constant')\n end\nend",
"def extract_audio(infile)\n\n infile = Path[infile]\n \n p infile\n \n unless infile.exists?\n STDERR.puts \"Couldn't find #{infile}\"\n return\n end\n\n #unless VALID_EXTS.include? infile.ext\n # STDERR.puts \"Unrecognized video format: #{infile.ext}\"\n # return\n #end\n \n if infile =~ %r{^/dev/fd/}\n outfile = Path.pwd/\"#{infile.filename}.mp3\" \n else \n outfile = infile.with(:ext=>\"mp3\")\n end\n\n if outfile.exists?\n puts \"Error: #{outfile} exists!\"\n return\n end \n \n puts\n puts \"Input: #{infile}\"\n puts \"Output: #{outfile}\"\n puts\n \n # -lameopts q=5\n cmd = %w[mencoder -of rawaudio -oac mp3lame -ovc copy -o] + [outfile.to_s, infile.to_s]\n system(*cmd)\n \nend",
"def bytes_wav\n IO.popen(espeak_command(command_options, '--stdout'), 'r', &:read)\n end",
"def sort_files!; end",
"def top_songs(n = 3)\n top_list = @tracks.sort_by {|s| s.play_count}.reverse\n return top_list[0..n-1].compact\n end",
"def music_shuffle filenames\n\n number_of_songs = filenames.length\n\n #shuffle twice\n 2.times do\n left_index = 0\n right_index = number_of_songs/2\n shuffled = []\n\n while shuffled.length < number_of_songs\n if shuffled.length % 2 == 0\n #take track from right\n shuffled << filenames[right_index]\n right_index += 1\n else\n #take track from left\n shuffled << filenames[left_index]\n left_index += 1\n end\n end\n\n shuffled = filenames\n end\n\n final = []\n cut = rand(number_of_songs) #index of card to cut at\n counter = 0\n\n while counter < number_of_songs\n final << filenames[(counter+cut)%number_of_songs]\n counter += 1\n end\n\n final\nend",
"def list(songs)\n songs.each_with_index { |song, index| puts \"#{index+1}. #{song}\" }\nend",
"def analise_audio\n ads_file_paths = []\n videos_with_ads_from_files = []\n\n Find.find('.') do |path|\n if path =~ /.*-ads\\.wav$/\n $file_name = ads_file_paths << path[2..-1].to_s\n end\n end\n if !$file_name.nil?\n videos_with_ads_from_files.push(\"'#{$file_name}': 'true'\")\n puts \"List of audio files with ads based on file names #{videos_with_ads_from_files[0]}\"\n end\n\n if $file_name.nil?\n puts 'No audio files with ads found'\n end\n #another way how we can check if ads displayed\n #here we can get a length of audio file in seconds by `sox file_name.wav -n stat 2>&1| grep 'Length'| awk '{print $3}'\n #if ads were displayed length of audio file will be like ads.length + original_video.length in seconds\n #if total audio file length > then RECORD_TIME in seconds it means that audio file contains ads\nend",
"def music_shuffle filenames\r\n # dont want a perfectly random shuffle . shuffle like card shuffling\r\n #shuffle the deck twice, then cut it once ..\r\n # actually *sort* the input\r\n filenames = filenames.sort\r\n len = filenames.length\r\n\r\n # shuffle twice\r\n 2.times do\r\n l_idx = 0 # index of next card in the left pile\r\n r_idx = len/2 # index of next card in the right pile\r\n shuf = []\r\n # NOTE: if we have a odd number of \"cards\", then the\r\n #right pile will be larger\r\n\r\n while shuf.length < len\r\n if shuf.length%2 == 0\r\n # take card from the right pile\r\n shuf.push(filenames[r_idx])\r\n r_idx = r_idx + 1\r\n else\r\n # take card from the left pile\r\n shuf.push(filenames[l_idx])\r\n l_idx = l_idx + 1\r\n end\r\n end\r\n\r\n filenames = shuf\r\n end\r\n # cut the deck\r\n arr = []\r\n cut = rand(len) # index of card to cut at\r\n idx = 0\r\n\r\n while idx < len\r\n arr.push(filenames[(idx+cut)%len])\r\n idx = idx + 1\r\n end\r\n\r\n arr\r\nend",
"def music_shuffle filenames\r\n # dont want a perfectly random shuffle . shuffle like card shuffling\r\n #shuffle the deck twice, then cut it once .. \r\n # actually *sort* the input\r\n filenames = filenames.sort\r\n len = filenames.length\r\n\r\n # shuffle twice\r\n 2.times do\r\n l_idx = 0 # index of next card in the left pile\r\n r_idx = len/2 # index of next card in the right pile\r\n shuf = []\r\n # NOTE: if we have a odd number of \"cards\", then the \r\n #right pile will be larger\r\n\r\n while shuf.length < len\r\n if shuf.length%2 == 0\r\n # take card from the right pile\r\n shuf.push(filenames[r_idx])\r\n r_idx = r_idx + 1\r\n else\r\n # take card from the left pile\r\n shuf.push(filenames[l_idx])\r\n l_idx = l_idx + 1\r\n end\r\n end\r\n\r\n filenames = shuf\r\n end\r\n # cut the deck\r\n arr = []\r\n cut = rand(len) # index of card to cut at\r\n idx = 0\r\n\r\n while idx < len\r\n arr.push(filenames[(idx+cut)%len])\r\n idx = idx + 1\r\n end\r\n\r\n arr\r\nend",
"def sort_by_encoding_index(files)\n files.sort_by do |file|\n token_pairs = file.scan(/(\\D+)|(\\d+)/)\n\n sort_key = token_pairs.map do |letters, digits|\n if letters\n letters\n else\n padded_numeric_sort_key(digits)\n end\n end\n\n sort_key.flatten\n end\nend",
"def homophonic\n smallest = 1\n return @voices.map { |voice| voice.split_into(smallest) }\n end",
"def print_menu\n Dir.glob('*.mz').sort.each_with_index{|f,i|puts\"#{(i+1).to_s.rjust(2)} - #{f}#{\"\\n\"+(i+2).to_s.rjust(2)+' - exit'if i==Dir.glob('*.mz').size-1}\"}\nend",
"def sort_files(files)\n files.sort! { |x,y| x[1] <=> y[1] }\n end",
"def files\n filename = Dir.entries(@path).find_all {|file| file.include?(\".mp3\")}\n # binding.pry\n # [[\"Thundercat - For Love I Come - dance.mp3\",\n # \"Real Estate - It's Real - hip-hop.mp3\",\n # \"Action Bronson - Larry Csonka - indie.mp3\",\n # \"Real Estate - Green Aisles - country.mp3\"]]\n\n #binding.pry\n end",
"def files\n Dir.glob(self.path + '**/*.mp3').collect {|file| File.basename(file)}\n end",
"def list_songs\n # print songs out in alphabetical order with index\n # 'each.with_index' allows for index to start at 1\n Song.all.uniq.sort { |title1, title2| title1.name <=> title2.name }.each.with_index(1) do |song, i|\n puts \"#{i}. #{song.artist.name} - #{song.name} - #{song.genre.name}\"\n end\n end",
"def audio_files(folder_name)\n Dir.glob(\"./audio/#{folder_name}/**/*\")\n end",
"def list(songs)\n songs.each_with_index {|song, i| puts \"#{i+1}. #{song}\"} #or start each_with_index with counting at 1\nend",
"def list_songs\n temp = Song.all.sort{|songA, songB| songA.name <=> songB.name} #sorting lab, refactor with .with_index(offset=1)?\n counter = 1\n temp.each do |song|\n puts \"#{counter}. #{song.artist.name} - #{song.name} - #{song.genre.name}\"\n counter += 1\n end\n end",
"def split(interval_in_min_dot_seconds, basename=File.basename(path, '.*'), dest=dir)\n #We have to cd into the wrapfile directory and do everything\n #there because old/packaged versions of mp3splt were\n #retarded at handling absolute directory paths\n ::Dir.chdir(dir.path) do\n Utility.system_quietly('mp3splt', '-t', interval_in_min_dot_seconds, '-o', \"#{basename}.@m.@s\", File.basename(path)) \n end\n files = Filer::Files::Audio.new(dir.select{|file| File.basename(file.path).match(/^#{Regexp.escape(basename) }\\.\\d+\\.\\d+\\.mp3$/) })\n if files.to_a.empty?\n raise Error::Shell, \"Could not find output from `mp3splt` on #{path}\"\n end\n if dest.path != dir.path\n files.mv!(dest)\n end\n files.sort\n end",
"def audio_gen(slide)\n term = slide['term']\n kind = slide['kind'] || nil\n index = slide['index'] || nil\n file_name = file_name_gen(slide, \".WAV\")\n say = command_arg('[[slnc 1000]]' + slide['script'] + '[[slnc 1000]]')\n output = command_arg(file_name)\n `say -v Jill #{say} -o #{output}`\n slide['audio'] = file_name\nend",
"def music_shuffle filenames\n\n return [] if filenames.empty? # get the empty case out of the way\n \n # initialise shuffle\n filenames.sort!\n len = filenames.length\n \n # do the shuffle\n 2.times do\n leftpile = filenames[0..(len/2 - 1)]\n rightpile = filenames[len/2..-1]\n filenames = []\n while !leftpile.empty? do\n filenames << rightpile.shift\n filenames << leftpile.shift\n end\n filenames = filenames + rightpile # adds final 'card' if len is odd\n end\n\n #cut the 'deck' at random\n cutpoint = rand(len)\n filenames = filenames[cutpoint..-1] + (cutpoint == 0 ? [] : filenames[0..(cutpoint-1)])\n \nend",
"def files\n Dir.glob(\"#{path}/*.mp3\").collect {|file| file.gsub(\"#{path}/\",\"\")}\n end",
"def audio(filename, opts = {})\n n = input(filename, opts)\n @audios << n\n n\n end",
"def speak(title)\n\n a = KjReading.verses title\n\n a.each do |x|\n\n filename = download_ogg(x.title)\n command = @audio_player + ' ' + filename\n system command\n\n end\n\n end",
"def files\n files = Dir[\"#{path}/*.mp3\"].each {|file_name| next if File.directory? file_name}\n files.each {|filename| filename.gsub!(/\\A(.....................)/, \"\")}\n files\n end",
"def sounds_for_number(number)\n number = number.to_i\n result = []\n thousands = (number / 1000).floor\n if thousands > 0\n result << \"#{thousands}.ul\" << \"thousand.ul\"\n end\n rest = number % 1000\n hundreds = (rest / 100).floor\n if hundreds > 0\n result << \"#{hundreds}.ul\" << \"hundred.ul\"\n end\n rest = rest % 100\n if rest <= 19\n result << \"#{rest}.ul\"\n else\n tens = (rest / 10).floor\n units = rest % 10\n result << \"#{tens}0.ul\" \n result << \"#{units}.ul\" if units > 0\n end\n result.map {|r| sound_path(r) }\n end",
"def list_files\n @synth_files = CreatedFile.find_all_by_content_type(\"synthesis\",\n :include => :researcher, \n :order => \"created_at DESC, created_file DESC\")\n end",
"def find_most_played_songs\n top_songs_with_play_count_pair = self.lib.songs.reject do |song|\n #this line is describing records it will get rid of\n (!song.metadata.has_key?('play_count')) or (song.metadata['play_count'] == nil)\n end\n\n top_songs_played_sorted = top_songs_with_play_count_pair.sort do |a, b| \n b.metadata['play_count'].to_i <=> a.metadata['play_count'].to_i\n end\n\n top_songs_played = top_songs_played_sorted.first(5)\n song_names_of_top_played = top_songs_played.collect {|song| song.metadata['name']} \n end",
"def dominant_octopus\n FISH_ARR.sort_by(&:length)[-1]\nend",
"def copy_audio(stream, index)\n disposition = (index == 0) ? 'default' : 'none'\n title = (stream[:channels] > 2) ? 'Surround Track' : 'Stereo Track'\n return [ \"-map 0:a:#{stream[:index]}\",\n \"-metadata:s:a:#{index} title='#{title}'\",\n \"-metadata:s:a:#{index} language=#{stream[:language]}\",\n \"-disposition:a:#{index} #{disposition}\",\n \"-codec:a:#{index} copy\" ]\nend",
"def list(songs)\n song_list = []\n counter = 1\n songs.each do |song|\n song_list.push(\"#{counter}. #{song}\")\n counter += 1\n end\n puts song_list\nend",
"def sort_files(list_files = [])\n list_files.map{|j| [j, (j.match(/(\\d+)/) && $1).to_i ] }.sort{|v1,v2| v1.last <=> v2.last }.map(&:first)\n end",
"def read_tracks music_file\n\tcount = music_file.gets().to_i\n tracks = Array.new\n track = File.open(\"input.txt\")\n i = 0\n while (i < count)\n track = read_track(music_file)\n tracks << track\n i += 1\n end \ntracks\nend",
"def sort_file\n File.open(file_name) do |line|\n line.each do |x|\n puts \"#{x.to_textual}\"\n end\n end\n end",
"def created_mp3s(splitter = @splitter)\n Dir.glob(\"#{splitter.output_folder}/*.mp3\").map { |f| File.basename f }\nend",
"def my_music_shuffle filenames\n \n return [] if filenames.empty? # get the empty case out of the way\n \n # split each filename into [path, file]\n filenames.map! {|name| Pathname.new(name).split}\n filenames.map! {|name| [name[0].to_s, name[1].to_s]}\n\n # initialise shuffle\n shufflednames = []\n tailend_flag = false\n pick = rand(filenames.length)\n \n # do the shuffling\n while !(filenames == []) do\n \n # stick pick on the end unless tailend flag is raised, in which case insert randomly\n if !tailend_flag then shufflednames << filenames[pick] else\n shufflednames.insert(rand(shufflednames.length), filenames[pick])\n end\n filenames.delete_at(pick)\n \n # set 'masknames' to list everything of a different genre\n masknames = filenames.select {|name| name[0] != shufflednames[-1][0]} \n \n # find a new pick, raising the tailend flag if we only have one genre left\n if !filenames.empty? then\n if !masknames.empty? then\n pickname = masknames.sample # pick a tune from a different genre\n pick = filenames.index(pickname) # find it in 'filenames' and point 'pick' to it\n else\n pick = rand(filenames.length) # pick any tune\n tailend_flag = true\n end\n end\n \n end # ends while loop\n \n #output the filenames merged back into strings\n shufflednames.map! {|name| name[0].to_s + '/' + name[1].to_s} \n \nend",
"def bynum results, num=1000\r\n\tfiles = []\r\n\t\r\n\tresults.to_a.each_slice(num).with_index do |res, i|\r\n\t\tnums = \"#{num*i+1}-#{num*i+res.length}\"\r\n\t\t\r\n\t\tfname = \"out-#{nums}.txt\"\r\n\t\tfiles << fname\r\n\t\t\r\n\t\tout = File.open(fname,'w')\r\n\t\t\r\n\t\tres.each do |k,v|\r\n\t\t\tname, images, interwikimap = k, *v\r\n\t\t\t\r\n\t\t\tout.puts \"* [[#{name}]]\" unless images.empty?\r\n\t\t\tout.puts images.to_a.map{|img, langs| \r\n\t\t\t\t\"** [[:commons:File:#{img}|]] na #{langs.uniq.map{|l| \"[[:#{l}:#{interwikimap[l.to_s]}|#{l}]]\"}.join ','}\"\r\n\t\t\t}\r\n\t\tend\r\n\t\t\r\n\t\tout.close\r\n\t\t\r\n\t\tputs nums\r\n\tend\r\n\t\r\n\treturn files\r\nend",
"def files\n Dir.glob(\"#{path}/*.mp3\").collect do\n |file| file.gsub(\"#{path}/\",\"\")\n end\n end",
"def files\n filename = Dir.glob(\"#{path}/*.mp3\")\n filename = filename.collect{|a_string| a_string.sub(\"#{path}/\", \"\")}\n end",
"def humongous_sort\n list = File.readlines(file_name)\n full_list = list.sort_by { |x| x.downcase }\n end",
"def combine_tracks_from_origin\n begin\n tracks = \"\"\n offsets = []\n # This is disgusting, but I want to get this concept working\n # and my brain isn't cooperating. I'm trying to account for\n # any tracks that both have offsets by subtracting the lower offset\n # from the higher one, and reassigning the higher one with the new value\n # and setting the lower one to 0. That way there are no pauses before the track begins\n os = origins.sort_by(&:offset).reverse\n os.each {|o| offsets << o.offset}\n os.first.offset = offsets[0] - offsets[1]\n os.last.offset = 0\n os.each do |o|\n unless File.exist?(o.jingle.latest_path)\n sox_logger.info(\"#{o.jingle.latest_path} does not exist.\")\n raise Errno::ENOENT, \"#{o.jingle.latest_path} not processed yet\"\n end\n sox_logger.info(\"Added track: #{o.jingle.latest_path}\")\n if o.offset > 0\n tracks += (\" -v 0.8 \" + o.jingle.latest_path + \" -p pad \" + o.offset.to_s + \" 0 | sox - -m\")\n elsif o.offset == 0\n #tracks += (\" -v 1 \" + o.jingle.latest_path + \" pad \" + o.offset.to_s + \" 0 | sox - -m\")\n tracks += (\" -v 0.8 \" + o.jingle.latest_path)\n end\n end\n output = assets_path\n #tracks = tracks[0..-11] # Remove the trailing command\n puts \"sox #{tracks} #{output}original.mp3\"\n m = os.first.offset == 0 ? \"-m \" : \"\"\n result = `sox #{m}#{tracks} #{output}original.mp3`\n duration = `soxi -D #{output}original.mp3`\n stat_data = `soxi #{output}original.mp3`\n # TO FIX\n # Stat data with non-UTF-8 stuff won't save in the DB.\n #stat_data = `sox #{output}original.mp3 -n stat`\n update_attributes(\n track_duration: duration,\n state: \"complete\",\n track_file_name: \"origin.mp3\",\n track_content_type: \"audio/mpeg\",\n track_file_size: (File.size(\"#{output}original.mp3\") rescue 0),\n stat: stat_data #.encode(\"UTF-8\").force_encoding('UTF-8')\n )\n rescue => error\n sox_logger.debug(\"Encountered error:\\n\")\n sox_logger.debug($!.backtrace)\n return false\n end\n end",
"def mono_files2stereo(new_name, chan1_name, chan2_name)\n ind1 = open_sound(chan1_name)\n ind2 = open_sound(chan2_name)\n ind3 = mono2stereo(new_name, ind1, 0, ind2, 0)\n close_sound(ind1)\n close_sound(ind2)\n ind3\n end",
"def make_inventory\n Dir.glob('**/*').sort.each {|f| puts f}\nend",
"def call\n files.each do |file|\n parts = parse_filename(file)\n build_song(parts)\n end \n end",
"def file_list(group)\n return Dir[File.join(@dir, group, FILE_EXT)].sort\nend",
"def files\n\t\t@array_of_mp3s = Dir[\"#{@path}/*.mp3\"]\n\t\t@array_of_mp3s.map do |mp3|\n\t\t\tmp3.slice!(\"#{@path}/\")\n\t\t\tmp3\n\t\tend\n\tend",
"def load_wav filename\n sample_rate = nil\n fmt = nil\n data = ''\n File.open(filename) do |file|\n head = file.read(12)\n until file.eof?\n type = file.read(4)\n size = file.read(4).unpack(\"V\")[0].to_i\n case type\n when 'fmt '\n fmt = file.read(size)\n fmt = {\n :id => fmt.slice(0,2).unpack('c')[0],\n :channel => fmt.slice(2,2).unpack('c')[0],\n :hz => fmt.slice(4,4).unpack('V').join.to_i,\n :byte_sec => fmt.slice(8,4).unpack('V').join.to_i,\n :block_size => fmt.slice(12,2).unpack('c')[0],\n :bit_sample => fmt.slice(14,2).unpack('c')[0]\n }\n when 'data'\n data += file.read size\n else\n raise type\n end\n end\n end\n [fmt, data]\nend",
"def files\n Dir.entries(\"#{path}\").select {|song_filename| song_filename.include?(\"mp3\")}\n end",
"def audio_codecs\n Codec.where(:codec_type => 'audio').order(\"id ASC\")\n end",
"def generate_wav_source(source)\n ext = File.extname(source)\n ext_gsubbed = ext.gsub(/\\./, '')\n\n if ext != \".wav\"\n input_options = { type: ext_gsubbed }\n output_options = { type: \"wav\" }\n source_filename_without_extension = File.basename(source, ext)\n output_file_path = File.join File.dirname(source), \"tmp_#{source_filename_without_extension}_#{Time.now.to_i}.wav\"\n converter = Sox::Cmd.new\n converter.add_input source, input_options\n converter.set_output output_file_path, output_options\n converter.run\n output_file_path\n else\n source\n end\n rescue Sox::Error => e\n raise e unless e.message.include?(\"FAIL formats:\")\n raise RuntimeError.new(\"Source file #{source} could not be converted to .wav by Sox (Sox: #{e.message})\")\n end",
"def get_syneths\n \t\tres = []\n \t\timages.order(\"updated_at DESC\").each do |image|\n \t\t\tres << [image, image.sounds[0]]\n \t\tend\n \t\tputs res\n \t\treturn res\n \tend",
"def best_song_from_en(songs)\n best_song = songs.first\n songs.each do |s|\n best_song = if s.tracks.size > best_song.tracks.size\n s\n else\n best_song\n end\n end\n best_song\n end",
"def random_media_file_list_from_list(filename_list)\n media_file_list_from_list(filename_list).shuffle\nend",
"def files\n files = Dir.glob(\"#{@path}/*.mp3\")\n normalized = files.map do |file|\n file.split(\"./spec/fixtures/mp3s/\") \n end\n why = normalized.map do |file|\n file.reject {|c| c.empty?}\n end.flatten\n end",
"def manageAudioFiles(maxNumFiles, folder)\n\n fileNumber = Dir[(Rails.root.to_s + \"/public/audio/#{folder}/*\")].count\n keepSeconds = 7200\n\n while fileNumber > maxNumFiles\n keepSeconds *= 0.5\n Dir[(Rails.root.to_s + \"/public/audio/#{folder}/*\")].each do |filename| \n deleteOldFile(filename, keepSeconds)\n end\n fileNumber = Dir[(Rails.root.to_s + \"/public/audio/#{folder}/*\")].count\n end\n\n end",
"def chunks\n Dir[\"#{model.file}-*\"].sort\n end",
"def files\n Dir[\"#{@path}/*.mp3\"].collect {|path| path.split('/')[-1]}\n end",
"def read_tracks music_file\n count = music_file.gets().to_i\n tracks = Array.new\n\n while count > 0\n count -= 1\n \n track = read_track(music_file)\n tracks << track\n end\n tracks\nend",
"def get_source_movs(path)\n files = []\n Find.find(path) do |filename|\n if !FileTest.directory?(filename)\n if filename =~ MOV_PATTERN\n files << Pathname.new(filename)\n end\n end\n end\n\n files.sort\nend",
"def decorate(files)\n files.sort\n end",
"def sort_array\n a = File.readlines(file_name)\n b = a.sort\n end",
"def list(songs)\n songs.each_with_index{|song,i|\n puts \"#{i+1}. #{song}\" \n }\nend",
"def files\n # fetch the appropriate files\n filenames = Dir.glob(@path + \"/*.mp3\")\n filenames.map { |filename| @files << File.basename(filename) }\n @files\n end",
"def sounds_list(params = {})\n get \"sounds\", params\n end",
"def play_file(file)\n system(\"ogg123 #{file}\")\n end",
"def data_file_names\n Dir.glob(File.join(@dir, '*.data')).sort! do |a, b|\n a.to_i <=> b.to_i\n end\n end",
"def music_shuffle filenames\n\t# Slice the array into three sets i.e. [[],[],[]]\n\tthree_sets = filenames.each_slice(3).to_a\n\t# Let's shuffle the outer array\n\tthree_sets.shuffle!\n\t# Now let's suffle the inner arrays\n\tthree_sets.each {|set| set.shuffle!}\n\t# Now let's get back to having just one array of file names\n\tthree_sets.flatten!\nend",
"def wav\n @wav ||= @info_file.sub(/txt$/, 'wav')\n end",
"def make\n App.out.make_audio_file\nend",
"def download(s, outfile=nil)\n\n puts 'downloading ...' if @debug\n\n a = KjReading.verses s\n\n downloads = a.map do |x|\n download_ogg(x.title)\n end\n\n puts 'converting to wav: ' + downloads.inspect if @debug\n\n dir = File.dirname(Tempfile.new.path)\n\n wavfiles = downloads.map do |oggfile|\n\n wavfile = oggfile.sub(/\\.ogg$/,'.wav')\n EasyAudioUtils.new(oggfile, wavfile, working_dir: dir).convert\n sleep 1.4\n File.basename(wavfile)\n\n end\n\n puts 'concatenating wav files ...' if @debug\n\n # concat wav files\n #\n fullwavfile = Tempfile.new('kva').path + '.wav'\n puts 'creating fullwavfile:' + fullwavfile.inspect if @debug\n EasyAudioUtils.new(out: fullwavfile, working_dir: dir).concat(wavfiles,\n sample_rate: 22050)\n\n # convert wav to ogg\n #\n fulloggfile = outfile || fullwavfile.sub(/\\.wav$/, '.ogg')\n puts 'creating fulloggfile: ' + fulloggfile.inspect if @debug\n EasyAudioUtils.new(fullwavfile, fulloggfile).convert\n\n 'downloaded ' + fulloggfile\n\n end",
"def save(filename)\n speech = bytes_wav\n res = IO.popen(lame_command(filename, command_options), 'r+') do |process|\n process.write(speech)\n process.close_write\n process.read\n end\n res.to_s\n end",
"def files\n @files_array ||= Dir.glob(\"#{@path}/*.mp3\").collect do |filename|\n filename.rpartition(\"/\").last \n end \n end",
"def filter_samples(files)\n files.reject { |f| sample?(f) }\n end",
"def list_songs\n#.sort iterates through each song in library and sorts them a-z, alphabetical order\n#.each_with_index iterates through each song and puts them in numerical order\n#<=> is the spaceship operator useful for sorting an array. compares, <, >, = in a single operation\n Song.all.sort{|a, b| a.name <=> b.name}.each_with_index do |s, i|\n puts \"#{i+1}. #{s.artist.name} - #{s.name} - #{s.genre.name}\"\n # ex: expect($stdout).to receive(:puts).with(\"1. Thundercat - For Love I Come - dance\")\n end\n end",
"def sort_by_popularity\n @song_data = @song_data.sort_by {|x| [-x[:plays], x[:index]] }\n end",
"def play_random_clip_fx_random()\n 0.upto(8){\n\tid = rand($full_sample_filelist.size)\n\t# Theses variables are used by the sample playing - affected to the last line of knobs\n\t$my_sample_volume = 0.2 + rand() * 0.8\n\tif($my_sample_volume > $sample_volume) then\n\t\t$my_sample_volume = $sample_volume\n\tend\n\n\t$my_sample_speed = 0.1 + rand(0.9)\n\t$my_sample_reverse = rand(2) < 1 ? false : true\n\t$my_sample_sampling_rate = 44100\n\t$my_sample_start_pos = 0.0 + rand(0.0..1.0)\n\t$my_sample_phaser = [ rand(2) < 1 ? false : true, \n\t\t\t\t0.95, 0.95, 3, 0.6, 2, \"-t\" ] # active gain-in gain-out delay decay speed [-s(inusoid)|-t(riangle)]\n\t$my_sample_flanger = [ rand(2) < 1 ? false : true, \n\t\t\t\t3, 9.5, 0, 70, 2, \"sin\", 100, \"quadratic\" ] # [active, delay depth regen width speed shape phase interp]\n\t$my_sample_reverb = [ rand(2) < 1 ? false : true, \n\t\t\t\t99, 99, 100, 100, 0, 0, ] # active, reverb, HF-damping, room-scale, stereo-depth, pre-delay, wet-gain\n\n\tcmd = \"play -v #{$my_sample_volume * 0.2} \\\"#{$full_sample_filelist[id]}\\\" \"\n\tcmd += \"rate #{$my_sample_sampling_rate} \"\n\tcmd += \"speed #{$my_sample_speed.round(2)} \"\n\tcmd += \"#{$my_sample_reverse == true ? \"reverse\" : \"\"} \"\n#=begin \n## TODO fix trim\n\tlength = get_sample_length($full_sample_filelist[id])\n\tputs \"l: #{length}\"\n\tputs \"sample_start_pos: #{$my_sample_start_pos}\"\n\tstart_pos = $my_sample_start_pos.round(2) * length.round(2)\n\tstart_pos_HMS = Time.at(start_pos).utc.strftime(\"%H:%M:%S.%L\")\n\tcmd += \"trim =#{start_pos_HMS} \"\n#=end\t\n\tcmd += $my_sample_phaser[0] == true ? \"phaser #{$my_sample_phaser[1].round(2)} #{$my_sample_phaser[2].round(2)} #{$my_sample_phaser[3].round(2)} #{$my_sample_phaser[4].round(2)} #{$my_sample_phaser[5].round(2)} #{$my_sample_phaser[6]} \" : \"\"\n\tcmd += $my_sample_flanger[0] == true ? \"flanger #{$my_sample_flanger[1].round(2)} #{$my_sample_flanger[2].round(2)} #{$my_sample_flanger[3].round(2)} #{$my_sample_flanger[4].round(2)} #{$my_sample_flanger[5].round(2)} #{$my_sample_flanger[6]} #{$my_sample_flanger[7].round(2)} #{$my_sample_flanger[8]} \" : \"\"\n\tcmd += $my_sample_reverb[0] == true ? \"reverb #{$my_sample_reverb[1].round(2)} #{$my_sample_reverb[2].round(2)} #{$my_sample_reverb[3].round(2)} #{$my_sample_reverb[4].round(2)} #{$my_sample_reverb[5].round(2)} #{$my_sample_reverb[6].round(2)} \" : \"\"\n\n\tcmd += \" > /dev/null 2>&1\" #[ false, 3, 9.5, 0, 70, 2, \"sin\", 100, \"quadratic\" ]\n\n\tputs cmd\n\tThread.new(){\n\t\tif(rand(2) < 1) then # thread it and jump to next sample instantly\n\t\t\tThread.new(){\n\t\t\t\tsystem(cmd)\n\t\t\t}\n\t\telse\n\t\t\tsystem(cmd)\n\t\tend\n \t####sleep(rand(1.0))\n\t}\n\n }\nend",
"def media_list\n source_media.sort{|x,y| x.medium <=> y.medium }.map{ |x| x.medium }.join(', ')\n end",
"def unique\n list = File.readlines(file_name)\n full_list = list.sort_by { |x| x.to_textual }\n #uniques = full_list.uniq\n uniques = full_list.uniq\n puts uniques\n end",
"def combine(file,chapter)\n\t`ffmpeg -f concat -i \"#{file}\" -c copy chapters/Chapter\"#{chapter}\".aiff`\nend",
"def frames(index)\n @data.map { |sound_data| sound_data[index] }\n end",
"def list_songs\n self.sorted_list_songs.each_with_index do |song, idx|\n puts \"#{(idx + 1).to_s}. #{song.artist.name} - #{song.name} - #{song.genre.name}\"\n end\n end",
"def list(songs)\n i = 1\n songs.each do |song|\n puts \"#{i} #{song}\"\n i = i+1\n end\nend",
"def files\n @files ||= Dir.glob(\"#{path}/*.mp3\").collect{|file|\n#normalize the filename to just the MP3 filename with no path\n file.gsub(\"#{path}/\", \"\")}\n end",
"def special_make_song (oldFile, oldFile2, newFile, cmd)\n #http://superuser.com/questions/271986/execute-a-command-from-another-directory-in-bash magic line (first bit)\n #http://stackoverflow.com/questions/4534372/get-lengh-of-wav-from-sox-output magic line source (end bit)\n dir = `cd`\n dir = dir[0..dir.index(\"remixer\")]\n dir += \"/remixer/app/assets/audios\"\n length = Integer(`#{dir} && sox #{newFile} -n stat 2>&1 | sed -n 's#^Length (seconds):[^0-9]*\\([0-9.]*\\)$#\\1#p'`) #returns length\n file = oldFile\n old = Song.find(:file)\n if cmd.index(\"reverse\") != nil #reverse\n Song.new(newFile[0...newFile.lenth-5], artist: (old.artist), description: ('Backwards:'+old.description), file: (newfile), length: (length))\n elsif cmd.index(\"speed\") != nil #speed altering\n Song.new(newFile[0...newFile.lenth-5], artist: (old.artist), description: ('Morphed:'+old.description), file: (newfile), length: (length))\n elsif cmd.index(\"-t\") != nil #trimming\n Song.new(newFile[0...newFile.lenth-5], artist: (old.artist), description: ('Shortened:'+old.description), file: (newfile), length: (length))\n else\n file = file2\n old2 = Song.find(:file)\n if cmd.index(\"-m\") == nil #combining\n Song.new(title: (\"#{old.title}and#{old2.title}1\"), artist: (\"#{old.artist} and #{old2.artist}\"), description: (\"Back to back: #{old.description} #{old2.description}\"), file: (newFile), length: (length))\n else #mixing\n Song.new(title: (old.title+old2.title+\"1\"), artist: (old.artist+\" and \"+old2.artist), description: (\"All at once: \"+old.description+\" \"+old2.description), file: (newFile), length: (length))\n end\n end\n end",
"def display_saves\n Dir.children('./saves').each_with_index { |name, idx| puts \"#{idx}. #{name}\" }\nend",
"def music_shuffle(filenames_array)\n filenames_array.each do |song|\n song_path = song.split '/'\n\n end\nend",
"def read_tracks music_file\n\tcount = music_file.gets.to_i\n\ttracks = Array.new\n\t\n\ti = 0\n\twhile i < count\n\t\ttrack = read_track(music_file)\n\t\ttracks << track\n\t\ti = i + 1\n\tend\n\ttracks\nend",
"def files_500(files)\n prc = Proc.new { |x, y| x[0] <=> y[0] }\n heap = BinaryMinHeap.new()\n result = []\n\n files.length.time do |i|\n heap.push([files[i][0], i, 0])\n end\n\n while heap.count > 0\n min = heap.extract\n result << min[0]\n\n next_arr_i = min[1]\n next_idx = min[2] + 1\n next_el = files[next_arr_i][next_idx]\n\n heap.push([next_el, next_arr_i, next_idx]) if next_el\n end\n result\nend",
"def all_chans_zipped\n new_list = []\n Snd.sounds.each do |snd|\n channels(snd).times do |chn|\n new_list.push([snd, chn])\n end\n end\n new_list\n end"
] | [
"0.60384905",
"0.590835",
"0.582267",
"0.5712577",
"0.5697814",
"0.567468",
"0.561638",
"0.5577669",
"0.5565335",
"0.5553919",
"0.55359274",
"0.5440316",
"0.54380584",
"0.54294443",
"0.53794223",
"0.5376741",
"0.53297716",
"0.5295352",
"0.52881324",
"0.5286454",
"0.5275517",
"0.52694964",
"0.52598",
"0.5252002",
"0.5249491",
"0.5248341",
"0.52469015",
"0.524489",
"0.5237469",
"0.5201123",
"0.5196146",
"0.5180836",
"0.5166325",
"0.5163064",
"0.51501805",
"0.5144692",
"0.51341915",
"0.51292133",
"0.5114414",
"0.51134235",
"0.50998074",
"0.50936687",
"0.5091654",
"0.5090972",
"0.50884056",
"0.508417",
"0.50707245",
"0.5068327",
"0.50600225",
"0.50513077",
"0.5049221",
"0.50395244",
"0.50382537",
"0.5031814",
"0.5031152",
"0.50272626",
"0.50078017",
"0.50013256",
"0.5000684",
"0.4992679",
"0.49919227",
"0.4989474",
"0.49696207",
"0.49688944",
"0.49648714",
"0.49621412",
"0.49612054",
"0.4959169",
"0.49589783",
"0.49566543",
"0.49482578",
"0.4946942",
"0.49394256",
"0.49321586",
"0.49184665",
"0.49125358",
"0.49017155",
"0.48967564",
"0.48950475",
"0.48912174",
"0.488468",
"0.48796052",
"0.48770508",
"0.4871723",
"0.48711365",
"0.4871117",
"0.4862752",
"0.48576507",
"0.485407",
"0.48534307",
"0.48528588",
"0.4851661",
"0.4843551",
"0.48421305",
"0.4839614",
"0.4823437",
"0.48180702",
"0.4818059",
"0.48145694",
"0.4813243",
"0.4812881"
] | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_pre_total_party_num
@pre_total_party_num = PreTotalPartyNum.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def set_actions\n actions :all\n end",
"def define_action_helpers?; end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def setup_handler\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def workflow\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def setup\n # override and do something appropriate\n end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def after_set_callback; end",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def save_action; end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def setup(&blk)\n @setup_block = blk\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def callback_phase\n super\n end",
"def advice\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def duas1(action)\n action.call\n action.call\nend",
"def _handle_action_missing(*args); end"
] | [
"0.6164095",
"0.6046031",
"0.5945298",
"0.59179014",
"0.58890367",
"0.58341795",
"0.5776118",
"0.5700777",
"0.5700777",
"0.5656277",
"0.56218207",
"0.5423995",
"0.5411516",
"0.5411516",
"0.5411516",
"0.5395004",
"0.53783494",
"0.53593004",
"0.53412604",
"0.534078",
"0.5332865",
"0.53135896",
"0.52999926",
"0.5297309",
"0.5296569",
"0.5261449",
"0.5247048",
"0.52376497",
"0.52376497",
"0.52376497",
"0.52376497",
"0.52376497",
"0.52323204",
"0.52310973",
"0.523081",
"0.5225785",
"0.5219039",
"0.52136266",
"0.5208033",
"0.520763",
"0.5177365",
"0.5175224",
"0.5173357",
"0.5166104",
"0.5162502",
"0.51573396",
"0.5154547",
"0.5153531",
"0.51502854",
"0.51436496",
"0.5142863",
"0.51330835",
"0.5115634",
"0.5115634",
"0.511527",
"0.5109693",
"0.51076853",
"0.5093146",
"0.5090683",
"0.50829846",
"0.50819314",
"0.50670373",
"0.5055505",
"0.5053398",
"0.50504035",
"0.50504035",
"0.5037765",
"0.5027292",
"0.5024484",
"0.50150335",
"0.5014069",
"0.50022113",
"0.5001542",
"0.49981874",
"0.49915564",
"0.49915564",
"0.49880967",
"0.4982312",
"0.49787375",
"0.49786067",
"0.49687737",
"0.49676532",
"0.49602765",
"0.49565676",
"0.49550772",
"0.495342",
"0.49522525",
"0.49463704",
"0.49447197",
"0.49362713",
"0.49328062",
"0.49280638",
"0.49272856",
"0.4927058",
"0.49221697",
"0.4919526",
"0.49185994",
"0.49184805",
"0.49170163",
"0.49168405",
"0.49167764"
] | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def pre_total_party_num_params
params.require(:pre_total_party_num).permit(:result_no, :generate_no, :e_no, :count_type, :party_num)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def filtered_parameters; end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def valid_params?; end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def filter_parameters; end",
"def filter_parameters; end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def check_params; true; end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def list_params\n params.permit(:name)\n end",
"def check_params\n true\n end",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def additional_permitted_params\n []\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def resource_params\n params[resource_singular_name].try(:permit, self.class.param_whitelist)\n end",
"def allow_params_authentication!; end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def param_params\n params.require(:param).permit(:param_category_id, :param_table_id, :name, :english_name, :weighting, :description)\n end",
"def quote_params\n params.permit!\n end",
"def list_params\n params.permit(:list_name)\n end",
"def allowed_params(parameters)\n parameters.select do |name, values|\n values.location != \"path\"\n end\n end",
"def all_params; end",
"def permitted_resource_params\n params[resource.object_name].present? ? params.require(resource.object_name).permit! : ActionController::Parameters.new\n end",
"def source_params\n params.require(:source).permit(all_allowed_params)\n end",
"def user_params\n end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def get_allowed_parameters\n return _get_specific_action_config(:allowed_action_parameters, :allowed_parameters)&.map(&:to_s)\n end",
"def permitted_params\n @wfd_edit_parameters\n end",
"def user_params\r\n end",
"def param_whitelist\n whitelist = [\n :comment,\n :old_progress, :new_progress,\n :metric_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:metric_id)\n end\n \n whitelist\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def get_params\n\t\t\n\t\treturn ActionController::Parameters.new(self.attributes).permit(:first_name, :last_name, :email, :provider)\n\n\tend",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def valid_parameters\n sort_symbols(@interface.allowed_parameters)\n end",
"def params_permit\n params.permit(:id)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def filter_params\n params.permit(*resource_filter_permitted_params)\n end",
"def community_params\n params.permit(:profile_image, :name, :description, :privacy_type, :viewed_by, {tags: []}, {features: []}, {admins: []}, :members, :location, :beacon, :creator, :ambassadors, :current_events, :past_events, :feed, :category, :address, :allow_member_post_to_feed, :allow_member_post_to_events)\n end",
"def specialty_params\n\t\tparams.require(:specialty).permit(*Specialty::DEFAULT_ACCESSIBLE_ATTRIBUTES)\n\tend",
"def authorize_params\n super.tap do |params|\n %w[display scope auth_type].each do |v|\n if request.params[v]\n params[v.to_sym] = request.params[v]\n end\n end\n end\n end",
"def feature_params_filter\n params.require(:feature).permit(:name, :cat, :lower, :upper, :opts, :category, :description, :company, :active, :unit, :icon)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def argument_params\n params.require(:argument).permit(:name)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def property_params\n params.permit(:name, :is_available, :is_approved, :owner_id)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def sponsor_params\n params.require(:sponsor).permit(WHITE_LIST)\n end",
"def whitelist_person_params\n params.require(:person).permit(:family, :pre_title, :given_name, :dates, :post_title, :epithet, :dates_of_office, same_as: [], related_authority: [], altlabel: [], note: []) # Note - arrays need to go at the end or an error occurs!\n end",
"def parameters\n nil\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def sequence_param_whitelist\n default_param_whitelist << \"show_index\"\n end",
"def resource_filter_permitted_params\n raise(NotImplementedError, 'resource_filter_permitted_params method not implemented')\n end",
"def normal_params\n reject{|param, val| param_definitions[param][:internal] }\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def special_device_list_params\n params.require(:special_device_list).permit(:name)\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end"
] | [
"0.7121987",
"0.70541996",
"0.69483954",
"0.6902367",
"0.6733912",
"0.6717838",
"0.6687021",
"0.6676254",
"0.66612333",
"0.6555296",
"0.6527056",
"0.6456324",
"0.6450841",
"0.6450127",
"0.6447226",
"0.6434961",
"0.64121825",
"0.64121825",
"0.63913447",
"0.63804525",
"0.63804525",
"0.6373396",
"0.6360051",
"0.6355191",
"0.62856233",
"0.627813",
"0.62451434",
"0.6228103",
"0.6224965",
"0.6222941",
"0.6210244",
"0.62077755",
"0.61762565",
"0.61711127",
"0.6168448",
"0.6160164",
"0.61446255",
"0.6134175",
"0.6120522",
"0.6106709",
"0.60981655",
"0.6076113",
"0.60534036",
"0.60410434",
"0.6034582",
"0.6029977",
"0.6019861",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.60184896",
"0.60157263",
"0.6005857",
"0.6003803",
"0.60012573",
"0.59955895",
"0.5994598",
"0.5993604",
"0.5983824",
"0.5983166",
"0.5977431",
"0.597591",
"0.5968824",
"0.5965953",
"0.59647584",
"0.59647584",
"0.59566855",
"0.59506303",
"0.5950375",
"0.59485626",
"0.59440875",
"0.5930872",
"0.5930206",
"0.5925668",
"0.59235454",
"0.5917905",
"0.59164816",
"0.5913821",
"0.59128743",
"0.5906617",
"0.59053683",
"0.59052664",
"0.5901591",
"0.58987755",
"0.5897456",
"0.58970183",
"0.58942604"
] | 0.0 | -1 |
Deepens elements through a Copier. | def deepen_copy! copier, src
@a = @a.map { | x | copier[x] }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deep_clone; end",
"def __deep_copy__\n map { |value| value.__deep_copy__ }\n end",
"def deep_dup; end",
"def deep_copy\n answer = []\n %w[1 2 3 4 5 6].each do |elem|\n answer << elem.dup\n end\n answer\nend",
"def __deep_copy__\n self.class.new(aliases) do |copy|\n each do |entry|\n copy.push(entry.__deep_copy__)\n end\n end\n end",
"def deep_copy\n deep_transform_values(&method(:_deep_copy))\n end",
"def deep_copy\n @new_package = self.copy\n self.profiles.each do |profile|\n @new_profile = profile.copy\n @new_package.profiles << @new_profile\n \n profile.time_segments.each do |ts|\n @new_time_segment = ts.copy\n @new_profile.time_segments << @new_time_segment\n \n ts.routings.each do |routing|\n @new_routing = routing.copy\n @new_time_segment.routings << @new_routing\n \n routing.routing_exits.each do |re|\n #THIS IS GROWING EXPONENTIALLY\n @new_routing_exit = re.copy\n @new_routing.routing_exits << @new_routing_exit\n end\n end\n end\n end\n \n @new_package\n end",
"def deep_each\n \n end",
"def cop; end",
"def cop; end",
"def deep_copy(obj); end",
"def deep_copy\r\n Marshal.load(Marshal.dump(self))\r\n end",
"def deep_dup(arr)\n\nend",
"def deep_dup(arr)\n\nend",
"def deep_dup(arr)\n\nend",
"def reproduce(amount)\n children = Array.new\n children << self\n amount.times do |i|\n child = self.clone\n child.mutate(i)\n children << child\n end\n children\n end",
"def deep_clone; Marshal::load(Marshal.dump(self)); end",
"def deep_copy\n Sass::Tree::Visitors::DeepCopy.visit(self)\n end",
"def deep_dup\n map(&:deep_dup)\n end",
"def forward\n recursive_set(*@out) { |n| n.out }\n end",
"def deep_copy\n Marshal.load(Marshal.dump(self))\n end",
"def deep_copy\n Marshal.load(Marshal.dump(self))\n end",
"def deep_copy\n algorithm_copy = self.dup\n self.general_fields.each{ |field| algorithm_copy.general_fields << field.deep_copy }\n self.input_parameters.each{ |input_parameter| algorithm_copy.input_parameters << input_parameter.deep_copy }\n self.method_fields.each{ |field| algorithm_copy.method_fields << field.deep_copy }\n algorithm_copy.generate_secure_id(true) # Overwrite secure id\n algorithm_copy.save(validate: false) # Can't do validations before the fields are saved(created!) the first time\n self.zip_file.copy_file(algorithm_copy.id) # Need to copy the file, since CarrierWave won't do that for us...\n algorithm_copy.save! # Save it for real!\n algorithm_copy\n end",
"def make_copy(company, fix_ref = true)\n #puts company\n dup = super(company)\n #dup.parent_project = project\n #dup = find_copied_or_make_copy(page_to_attach)\n #pb = AzPageAzProjectBlock.new\n #pb.az_project_block = dup\n #pb.az_page = page_to_attach\n #pb.az_project_block.parent_project = page_to_attach.az_base_project\n #pb.az_project_block.parent_project_id = page_to_attach.az_base_project_id\n #pb.save!\n #dup.az_page = page_to_attach\n\n dup.parent_project_id = nil\n\n commons = [AzCommonsFunctionality,\n AzCommonsRequirementsHosting]\n\n commons.each do |cmc|\n cms = eval(\"#{cmc.to_s.underscore.pluralize}\")\n cms.each do |cm|\n cm.make_copy_common(company, dup)\n end\n end\n\n dup.save!\n\n if fix_ref\n full_pages_list = dup.get_full_pages_list\n dup.fix_page_structure(full_pages_list)\n dup.fix_page_references(full_pages_list)\n end\n\n return dup\n end",
"def each_copy(&block)\n @by_copy.each(&block)\n end",
"def __copy_on_write__(*)\n index = @parent_proxy.instance_variable_get(:@set).index(__getobj__) if @parent_proxy\n super.tap do\n CowProxy.debug { \"replace #{index} with proxy obj in parent #{@parent_proxy.name}\" } if index\n @parent_proxy.instance_variable_get(:@set)[index] = self if index\n new_set = __getobj__.instance_variable_get(:@set).dup\n __getobj__.instance_variable_set(:@set, new_set)\n end\n end",
"def deep_dup\n puts \"warning: #{self.class}: deep_dup not implement\"\n end",
"def __deep_copy__\n self.class.new(aliases, serializers, associations, aliased_associations) do |copy|\n each_pair do |key, value|\n copy.merge!(key => value.__deep_copy__)\n end\n end\n end",
"def deep_copy\n Marshal.load(Marshal.dump(self))\n end",
"def deep_copy\n Marshal.load(Marshal.dump(self))\n end",
"def each\n @source.each do |elem|\n yield DropDelegation.wrap_element(elem)\n end\n end",
"def initialize_copy(orig)\n super\n @delegated_to_object = @delegated_to_object.map do |institution|\n institution.clone\n end\n end",
"def __deep_copy__\n self.class.new(aliases, serializers) do |copy|\n each_pair do |key, value|\n copy.store(key, value.__deep_copy__)\n end\n end\n end",
"def to_pdfs_by_copy(options = {}, &block)\n self.class.pdf_from_iterator(each_copy, options, &block)\n end",
"def children\n out_edges.each{|e| e.dest}\n end",
"def copy_tree\n new_car = if car.kind_of? Cons\n car.copy_tree\n else\n car\n end\n new_cdr = if cdr.kind_of? Cons\n cdr.copy_tree\n else\n cdr\n end\n Cons[new_car,new_cdr]\n end",
"def deep_clone\n Marshal.load(Marshal.dump(self))\n end",
"def deep_copy_for account\n\n\t\tarticle_copy = Article.new(self.get_params)\n\t\tarticle_copy.update_attribute(\"account_id\", account.id)\n\t\tunless self.image == nil\n\t\t\tarticle.build_image(self.image.get_params)\t\n\t\tend\n\t\tself.segments.each do |s|\n\t\t\t\n\t\t\ts_copy = article_copy.segments.build(s.get_params)\n\t\t\ts.contents.each do |c|\n\t\t\t\tc_copy = s_copy.contents.build(c.get_params)\n\t\t\t\t\n\t\t\t\t\n\t\t\tend\n\t\tend\n\n\t\tself.tips.each do |t|\n\t\t\tt_copy = article_copy.tips.build(t.get_params)\n\t\t\tt.contents.each do |tc|\n\t\t\t\ttc_copy = t_copy.contents.build(tc.get_params)\n\t\t\tend \n\n\t\tend\n\t\tself.warnings.each do |w|\n\t\t\tw_copy = article_copy.warnings.build(w.get_params)\n\t\t\tw.contents.each do |wc|\n\t\t\t\twc_copy = w_copy.contents.build(wc.get_params)\n\t\t\tend \n\t\t\t\n\t\tend\n\n\t\treturn article_copy\n\t\n\tend",
"def bc_cloner(item, bc, entity, source, target, replace, options={})\n options = {:debug => false}.merge! options\n debug = options[:debug] or ENV['DEBUG'] === \"true\"\n puts \"DEBUG: bc_cloner method called with debug option enabled\" if debug\n puts \"DEBUG: bc_cloner args: item=#{item}, bc=#{bc}, entity=#{entity}, source=#{source}, target=#{target}, replace=#{replace}\" if debug\n \n files = []\n new_item = (replace ? bc_replacer(item, bc, entity, :debug => debug) : item)\n puts \"DEBUG: new_item=#{new_item}\" if debug\n new_file = File.join target, new_item\n puts \"DEBUG: new_file=#{new_file}\" if debug\n new_source = File.join(source, item)\n puts \"DEBUG: new_source=#{new_source}\" if debug\n if File.directory? new_source\n puts \"DEBUG: \\tcreating directory #{new_file}.\" if debug\n FileUtils.mkdir new_file unless File.directory? new_file\n clone = Dir.entries(new_source).find_all { |e| !e.start_with? '.'}\n clone.each do |recurse|\n files += bc_cloner(recurse, bc, entity, new_source, new_file, replace, :debug => debug)\n end\n else\n #need to inject into the file\n unless replace\n puts \"DEBUG: \\t\\tcopying file #{new_file}.\" if debug\n FileUtils.cp new_source, new_file\n files << new_file\n else\n puts \"DEBUG: \\t\\tcreating file #{new_file}.\" if debug\n t = File.open(new_file, 'w')\n File.open(new_source, 'r') do |f|\n s = f.read\n t.write(bc_replacer(s, bc, entity))\n end\n t.close\n files << new_file\n end\n end\n return files\nend",
"def deep_clone\n Marshal::load(Marshal.dump(self))\n end",
"def clone_deep\n c = self.clone :include => collection_details\n c.updated_at = nil\n c.created_at = nil\n self.collection_details.each do |detail|\n c.send(detail).each do |d|\n d.created_at = nil\n d.updated_at = nil\n d.person_id = nil\n end\n end\n c\n end",
"def deep_dup\n dup\n end",
"def cop_registry; end",
"def transfer(node, ins) ; ins ; end",
"def deep_copy(obj)\n super\n n = obj.first\n until n.nil? do\n if n.value.is_a? Linkedlist\n k = Linkedlist.new\n self.addToList(k.deep_copy(n.value))\n else\n self.addToList(n.value)\n end\n n = n.next\n end\n return self\n end",
"def deep_dup\n Marshal.load(Marshal.dump(self))\n end",
"def initialize_copy( other )\n\t\t\t@elem = other.elem.dup\n\t\t\tsuper\n\t\tend",
"def deepcopy\n\t\tMarshal.load(Marshal.dump(self))\n\tend",
"def items; @items.clone end",
"def unpack_slice!\n app_slice_root = app_dir_for(:root)\n copied, duplicated = [], []\n Dir.glob(self.root / \"**/*\").each do |source|\n relative_path = source.relative_path_from(root)\n mirror_file(source, app_slice_root / relative_path, copied, duplicated) if unpack_file?(relative_path)\n end\n public_copied, public_duplicated = mirror_public!\n [copied + public_copied, duplicated + public_duplicated]\n end",
"def deep_dup(arr)\n duper_arr = arr.dup.map { |item| item * 1 }\nend",
"def execute\n\n copiedCounter = 0\n failedCounter = 0\n skippedCounter = 0\n \n # traverse all srcfiles\n FiRe::filesys.find(@source) { |srcItem|\n \n # give some feedback\n FiRe::log.info \"searching #{srcItem}...\" if FiRe::filesys.directory?(srcItem)\n \n # skip this subtree if it matches ignored-items\n FiRe::filesys.prune if ignore?(srcItem) \n \n # transform srcpath to destpath\n destItem = srcItem.gsub(@source, @destination)\n\n # do not copy if item already exists and looks OK\n if needCopy(destItem,srcItem)\n copyWentWell = copyItem(srcItem, destItem)\n copiedCounter += 1 if copyWentWell\n failedCounter += 1 if !copyWentWell\n else\n skippedCounter += 1 \n end\n \n }\n \n # give some feedback\n FiRe::log.info \"copied #{copiedCounter} items, while #{failedCounter} items failed. #{skippedCounter} items did not need to be copied today.\"\n\n end",
"def deeper_dup(arr)\n duper_deeper_arr = arr.dup.map do |item|\n if item.kind_of?(Array)\n deeper_dup(item)\n else\n item = item * 1\n end\n end\n duper_deeper_arr \nend",
"def copy_list \n\n\tend",
"def copy_list\n new_cdr = if cdr.kind_of? Cons\n cdr.copy_list\n else\n cdr\n end\n Cons[@car,new_cdr]\n end",
"def deep_copy(obj)\n if obj.is_a?(Hash)\n obj.inject({}) { |h, kv| h.merge(kv[0] => deep_copy(kv[1])) }\n elsif obj.is_a?(Array)\n obj.map { |el| deep_copy(el) }\n else\n obj\n end\n end",
"def deep_clone\n Marshal.load(Marshal.dump(self))\n end",
"def loop_through\n self.map! do |element| \n if !element.is_a?(Array)\n element\n elsif element.is_a?(Array)\n element = element.dup\n element = element.loop_through\n end\n end\n end",
"def initialize_copy(list)\n @nodes = @nodes.map { |node|\n node2 = node.clone\n node2.parent = self\n node2\n }\n end",
"def deep_freeze\n @steps.freeze\n @children.freeze\n freeze\n self\n end",
"def copyitem\n\n\t\terrors = []\n\n\t\t@binder = Binder.find(params[:id])\n\n\t\t@inherited = inherit_from(params[:folid])\n\n\t\t@parenthash = @inherited[:parenthash]\n\t\t@parentsarr = @inherited[:parentsarr]\n\t\t@parentperarr = @inherited[:parentperarr]\n\n\t\t# src = Mongo.log(current_teacher.id.to_s,\n\t\t# \t\t\t\t__method__.to_s,\n\t\t# \t\t\t\tparams[:controller].to_s,\n\t\t# \t\t\t\[email protected]_s,\n\t\t# \t\t\t\tparams)\n\n\t\tif @inherited[:parent].get_access(current_teacher.id.to_s) == 2\n\n\t\t\t# fork will only be set if there is a teacher id mismatch\n\t\t\tfav = !params[:favorite].nil?\n\t\t\tfork = @inherited[:parent].owner != @binder.owner\n\n\t\t\t@parent_child_count = @inherited[:parent_child_count]\n\n\t\t\t@ppers = @binder.parent_permissions\n\n\t\t\t@new_parent = Binder.new(\t:title\t\t\t\t=> @binder.title,\n\t\t\t\t\t\t\t\t\t\t:body\t\t\t\t=> @binder.body,\n\t\t\t\t\t\t\t\t\t\t:type\t\t\t\t=> @binder.type,\n\t\t\t\t\t\t\t\t\t\t:format\t\t\t\t=> @binder.type == 2 ? @binder.format : nil,\n\t\t\t\t\t\t\t\t\t\t:files\t\t\t\t=> @binder.files,\n\t\t\t\t\t\t\t\t\t\t:folders\t\t\t=> @binder.folders,\n\t\t\t\t\t\t\t\t\t\t:forked_from\t\t=> fork ? @binder.id.to_s : nil,\n\t\t\t\t\t\t\t\t\t\t:fork_stamp\t\t\t=> fork ? Time.now.to_i : nil,\n\t\t\t\t\t\t\t\t\t\t:total_size\t\t\t=> @binder.total_size,\n\t\t\t\t\t\t\t\t\t\t:fav_total\t\t\t=> @binder.fav_total,\n\t\t\t\t\t\t\t\t\t\t:pub_size\t\t\t=> @binder.pub_size,\n\t\t\t\t\t\t\t\t\t\t:priv_size\t\t\t=> @binder.priv_size,\n\t\t\t\t\t\t\t\t\t\t:order_index\t\t=> @parent_child_count,\n\t\t\t\t\t\t\t\t\t\t:parent\t\t\t\t=> (fav ? { 'id'=>'-2', 'title'=>'' } : @parenthash),#@parenthash,\n\t\t\t\t\t\t\t\t\t\t:parents\t\t\t=> (fav ? [{ 'id'=>'-2', 'title'=>'' }] : @parentsarr),#@parentsarr,\n\t\t\t\t\t\t\t\t\t\t:permissions\t\t=> (fav ? [{\"type\"=>3, \"auth_level\"=>1}] : @binder.permissions),#@binder.permissions,\n\t\t\t\t\t\t\t\t\t\t:parent_permissions\t=> (fav ? [] : @parentperarr),#@parentperarr,\n\t\t\t\t\t\t\t\t\t\t:owner\t\t\t\t=> current_teacher.id,\n\t\t\t\t\t\t\t\t\t\t:username\t\t\t=> current_teacher.username,\n\t\t\t\t\t\t\t\t\t\t:fname\t\t\t\t=> current_teacher.fname,\n\t\t\t\t\t\t\t\t\t\t:lname\t\t\t\t=> current_teacher.lname,\n\t\t\t\t\t\t\t\t\t\t:last_update\t\t=> Time.now.to_i,\n\t\t\t\t\t\t\t\t\t\t:last_updated_by\t=> current_teacher.id,\n\t\t\t\t\t\t\t\t\t\t:thumbimgids\t\t=> @binder.thumbimgids)\n\n\t\t\t#@new_parent.format = @binder.format if @binder.type == 2\n\n\t\t\t# @new_parent.versions << Version.new(:owner\t\t=> @binder.current_version.owner,\n\t\t\t# \t\t\t\t\t\t\t\t\t\t:file_hash\t=> @binder.current_version.file_hash,\n\t\t\t# \t\t\t\t\t\t\t\t\t\t:timestamp\t=> @binder.current_version.timestamp,\n\t\t\t# \t\t\t\t\t\t\t\t\t\t:remote_imgfile_url\t=> @binder.current_version.imgfile.url.to_s,\n\t\t\t# \t\t\t\t\t\t\t\t\t\t:size\t\t=> @binder.current_version.size,\n\t\t\t# \t\t\t\t\t\t\t\t\t\t:ext\t\t=> @binder.current_version.ext,\n\t\t\t# \t\t\t\t\t\t\t\t\t\t:data\t\t=> @binder.current_version.data,\n\t\t\t# \t\t\t\t\t\t\t\t\t\t:croc_uuid \t=> @binder.current_version.croc_uuid,\n\t\t\t# \t\t\t\t\t\t\t\t\t\t:remote_file_url\t\t=> @binder.format == 1 ? @binder.current_version.file.url.to_s : nil) if @binder.type == 2\n\n\t\t\t@new_parent.versions << @binder.current_version\n\n\t\t\t#TODO: copy related images?\n\n\t\t\tif @new_parent.save\n\n\t\t\t\t# due to shared functionality, define method var\n\n\t\t\t\tif fav\n\t\t\t\t\tmethod = \"favorite\"\n\n\t\t\t\t\[email protected](:fav_total, 1)\n\t\t\t\telsif fork\n\t\t\t\t\tmethod = \"forkitem\"\n\t\t\t\t\t# fork_total is\n\t\t\t\t\[email protected](:fork_total, 1)\n\n\t\t\t\t\tBinder.delay(:queue => \"email\").sendforkemail(@binder.id.to_s, @new_parent.id.to_s)\n\n\t\t\t\t\t# cascade upwards\n\t\t\t\t\[email protected] do |f|\n\t\t\t\t\t\tBinder.find(f['id'].to_s).inc(:owned_fork_total,1) if f['id'].to_i>0\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tmethod = __method__.to_s\n\t\t\t\tend\n\n\t\t\t\tsrc = Mongo.log(current_teacher.id.to_s,\n\t\t\t\t\t\t\t\tmethod.to_s,\n\t\t\t\t\t\t\t\tparams[:controller].to_s,\n\t\t\t\t\t\t\t\[email protected]_s,\n\t\t\t\t\t\t\t\tparams)\n\n\t\t\t\tMongo.log(\tcurrent_teacher.id.to_s,\n\t\t\t\t\t\t\tmethod.to_s,\n\t\t\t\t\t\t\tparams[:controller].to_s,\n\t\t\t\t\t\t\t@new_parent.id.to_s,\n\t\t\t\t\t\t\tparams,\n\t\t\t\t\t\t\t{ :copy => @binder.id.to_s, :src => src })\n\n\t\t\t\t@new_parent.tag = Tag.new(\t:node_tags => @binder.tag.node_tags)\n\n\t\t\t\t@new_parent.update_parent_tags()\n\n\t\t\t\t#Hash table for oldid => newid lookups\n\t\t\t\t@hash_index = {params[:id] => @new_parent.id.to_s}\n\n\n\t\t\t\t#If directory, deal with the children\n\t\t\t\tif @binder.type == 1 #Eventually will apply to type == 3 too\n\n\t\t\t\t\t@index = @binder.parents.length\n\n\t\t\t\t\t#Select old children, order by parents.length\n\t\t\t\t\t@children = @binder.subtree.sort_by {|binder| binder.parents.length}.reject{|binder| binder.id == @new_parent.id}\n\n\t\t\t\t\t#Spawn new children, These children need to have updated parent ids\n\t\t\t\t\[email protected] do |h|\n\n\t\t\t\t\t\tMongo.log(\tcurrent_teacher.id.to_s,\n\t\t\t\t\t\t\t\t\tmethod.to_s,\n\t\t\t\t\t\t\t\t\tparams[:controller].to_s,\n\t\t\t\t\t\t\t\t\th.id.to_s,\n\t\t\t\t\t\t\t\t\tparams,\n\t\t\t\t\t\t\t\t\t{ :src => src })\n\n\t\t\t\t\t\t@node_parent = {\"id\"\t=> @hash_index[h.parent[\"id\"]],\n\t\t\t\t\t\t\t\t\t\t\"title\"\t=> h.parent[\"title\"]}\n\n\t\t\t\t\t\t@node_parents = Binder.find(@hash_index[h.parent[\"id\"]]).parents << @node_parent\n\n\t\t\t\t\t\t@old_permissions = h.parent_permissions\n\n\t\t\t\t\t\[email protected] {|p| @old_permissions.delete(p)}\n\n\t\t\t\t\t\t#Swap old folder ids with new folder ids\n\t\t\t\t\t\t@old_permissions.each {|op| op[\"folder_id\"] = @hash_index[op[\"folder_id\"]]}\n\n\t\t\t\t\t\th.inc(:fork_total, 1) if fork\n\n\t\t\t\t\t\t@new_node = Binder.new(\t:title\t\t\t\t=> h.title,\n\t\t\t\t\t\t\t\t\t\t\t\t:body\t\t\t\t=> h.body,\n\t\t\t\t\t\t\t\t\t\t\t\t:parent\t\t\t\t=> @node_parent,\n\t\t\t\t\t\t\t\t\t\t\t\t:parents\t\t\t=> fav ? [{ 'id'=>'-2', 'title'=>'' }] + (h.parents - {'id'=>'0','title'=>''}) : @node_parents,\n\t\t\t\t\t\t\t\t\t\t\t\t:permissions\t\t=> fav ? [] : h.permissions,\n\t\t\t\t\t\t\t\t\t\t\t\t:parent_permissions\t=> fav ? @parentperarr : @parentperarr + @old_permissions,\n\t\t\t\t\t\t\t\t\t\t\t\t:owner\t\t\t\t=> current_teacher.id,\n\t\t\t\t\t\t\t\t\t\t\t\t:username\t\t\t=> current_teacher.username,\n\t\t\t\t\t\t\t\t\t\t\t\t:fname\t\t\t\t=> current_teacher.fname,\n\t\t\t\t\t\t\t\t\t\t\t\t:lname\t\t\t\t=> current_teacher.lname,\n\t\t\t\t\t\t\t\t\t\t\t\t:last_update\t\t=> Time.now.to_i,\n\t\t\t\t\t\t\t\t\t\t\t\t:last_updated_by\t=> current_teacher.id,\n\t\t\t\t\t\t\t\t\t\t\t\t:type\t\t\t\t=> h.type,\n\t\t\t\t\t\t\t\t\t\t\t\t:format\t\t\t\t=> (h.type != 1 ? h.format : nil),\n\t\t\t\t\t\t\t\t\t\t\t\t:files\t\t\t\t=> h.files,\n\t\t\t\t\t\t\t\t\t\t\t\t:folders\t\t\t=> h.folders,\n\t\t\t\t\t\t\t\t\t\t\t\t:forked_from\t\t=> fork ? h.id.to_s : nil,\n\t\t\t\t\t\t\t\t\t\t\t\t:fork_stamp\t\t\t=> fork ? Time.now.to_i : nil,\n\t\t\t\t\t\t\t\t\t\t\t\t:total_size\t\t\t=> h.total_size,\n\t\t\t\t\t\t\t\t\t\t\t\t:pub_size\t\t\t=> h.pub_size,\n\t\t\t\t\t\t\t\t\t\t\t\t:priv_size\t\t\t=> h.priv_size,\n\t\t\t\t\t\t\t\t\t\t\t\t:fav_total\t\t\t=> h.fav_total,\n\t\t\t\t\t\t\t\t\t\t\t\t:thumbimgids\t\t=> @binder.thumbimgids,)\n\n\t\t\t\t\t\t# @new_node.versions << Version.new(\t:owner\t\t=> h.current_version.owner,\n\t\t\t\t\t\t# \t\t\t\t\t\t\t\t\t:file_hash\t=> h.current_version.file_hash,\n\t\t\t\t\t\t# \t\t\t\t\t\t\t\t\t:timestamp\t=> h.current_version.timestamp,\n\t\t\t\t\t\t# \t\t\t\t\t\t\t\t\t:size\t\t=> h.current_version.size,\n\t\t\t\t\t\t# \t\t\t\t\t\t\t\t\t:ext\t\t=> h.current_version.ext,\n\t\t\t\t\t\t# \t\t\t\t\t\t\t\t\t:data\t\t=> h.current_version.data,\n\t\t\t\t\t\t# \t\t\t\t\t\t\t\t\t:croc_uuid\t=> h.current_version.croc_uuid,\n\t\t\t\t\t\t# \t\t\t\t\t\t\t\t\t:imgfile\t=> h.current_version.imgfile,\n\t\t\t\t\t\t# \t\t\t\t\t\t\t\t\t:file\t\t=> h.format == 1 ? h.current_version.file : nil) if h.type == 2\n\n\n\t\t\t\t\t\t@new_node.versions << h.current_version\n\n\t\t\t\t\t\t#TODO: copy related images?\n\n\t\t\t\t\t\t@new_node.save\n\n\t\t\t\t\t\tMongo.log(\tcurrent_teacher.id.to_s,\n\t\t\t\t\t\t\t\t\tmethod.to_s,\n\t\t\t\t\t\t\t\t\tparams[:controller].to_s,\n\t\t\t\t\t\t\t\t\t@new_node.id.to_s,\n\t\t\t\t\t\t\t\t\tparams,\n\t\t\t\t\t\t\t\t\t{ :copy => h.id.to_s, :src => src })\n\n\t\t\t\t\t\t@new_node.tag = Tag.new(:node_tags => h.tag.node_tags)\n\n\t\t\t\t\t\t@new_node.update_parent_tags()\n\n\t\t\t\t\t\t@hash_index[h.id.to_s] = @new_node.id.to_s\n\t\t\t\t\tend\n\n\t\t\t\tend\n\n\t\t\t\t#Update parents' folder/file/size counts\n\t\t\t\t@parents = @new_parent.parents.collect {|x| x[\"id\"] || x[:id]}\n\n\t\t\t\[email protected] do |pid|\n\t\t\t\t\tif pid != \"0\"\n\t\t\t\t\t\tparent = Binder.find(pid)\n\n\t\t\t\t\t\tparent.update_attributes(\t:files\t\t=> parent.files + @new_parent.files,\n\t\t\t\t\t\t\t\t\t\t\t\t\t:folders\t=> parent.folders + @new_parent.folders + (@new_parent.type == 1 ? 1 : 0),\n\t\t\t\t\t\t\t\t\t\t\t\t\t:total_size\t=> parent.total_size + @new_parent.total_size,\n\t\t\t\t\t\t\t\t\t\t\t\t\t:pub_size\t=> parent.pub_size + @new_parent.pub_size,\n\t\t\t\t\t\t\t\t\t\t\t\t\t:priv_size\t=> parent.priv_size + @new_parent.priv_size)\n\t\t\t\t\tend\n\t\t\t\tend\n\n\t\t\t\t# DELAYTAG\n\t\t\t\tBinder.delay(:queue => 'thumbgen').generate_folder_thumbnail(@new_parent.id)\n\n\t\t\telse\n\n\t\t\tend\n\n\t\telse\n\n\t\t\terrors << \"You do not have permissions to write to #{@inherited[:parent].title}\"\n\n\t\tend\n\n\t\trescue BSON::InvalidObjectId\n\t\t\terrors << \"Invalid Request\"\n\t\trescue Mongoid::Errors::DocumentNotFound\n\t\t\terrors << \"Invalid Request\"\n\t\tensure\n\t\t\trespond_to do |format|\n\t\t\t\tformat.html {render :text => errors.empty? ? 1 : errors.map{|err| \"<li>#{err}</li>\"}.join.html_safe}\n\t\t\tend\n\tend",
"def forward_all(collection)\r\n newcollection = collection.dup.clear\r\n collection.each do |point|\r\n newcollection << forward(point)\r\n end\r\n newcollection\r\n end",
"def deep_clone\n Marshal::load(Marshal.dump(self))\n end",
"def collect_preserve\n\t\tcopy = @arr.clone[0...@last]\n\tend",
"def traverse(parent, &block)\n @source_elements.traverse(self, &block)\n yield parent, self\n end",
"def inject_deep_flat(list, remaining_path, multiplicity)\n return inject_deep(list, remaining_path) if multiplicity == 0\n\n flat_input = list.flat_map { |v| v.nil? ? [] : v }\n flat_output = inject_deep_flat(flat_input, remaining_path, multiplicity - 1)\n item_index = -1\n list.map { |v| v&.map { flat_output[item_index += 1] } }\n end",
"def through\n dup\n end",
"def index\n @copied_categories = CopiedCategory.all\n end",
"def traverse(start_elements, relation_filter, stop_filter, from_path = [])\n return [] if from_path.size > 100\n start_elements.each_with_object([]) do |el, relations|\n concrete_rels = concrete_relationships(el, relation_filter, from_path)\n relations.concat(\n concrete_rels,\n *derived_relationship_paths(concrete_rels, relation_filter, stop_filter, from_path)\n )\n end\n end",
"def deep_clone\n b = dup\n b.generate_token\n b.save\n basket_items.each {|i| b.basket_items << i.dup}\n b\n end",
"def deep_copy\n rule = map {|r| r.deep_copy } \n Rule.new( rule, @recursivity, @sn_altering, @min_depth )\n end",
"def visited\n clone.visit!\n end",
"def deep_clone!(options = {})\n processed_options = Para::Cloneable::IncludeTreeBuilder.new(self, cloneable_options).build\n options = options.reverse_merge(processed_options)\n callback = build_clone_callback(options.delete(:prepare))\n \n deep_clone(options) do |original, clone|\n Para::Cloneable::AttachmentsCloner.new(original, clone).clone!\n callback&.call(original, clone)\n end\n end",
"def iterate_and_prep_hash\n self.input_ticket_arr.each do |src_destination_arr|\n src_node = node_for_key(src_destination_arr[0], :src)\n destination_node = node_for_key(src_destination_arr[1], :destn)\n src_node.next_node = destination_node\n end\n end",
"def bc_cloner(item, bc, entity, source, target, replace)\n files = []\n new_item = (replace ? bc_replacer(item, bc, entity) : item)\n new_file = File.join target, new_item\n new_source = File.join(source, item)\n if File.directory? new_source\n puts \"\\tcreating directory #{new_file}.\" if DEBUG\n FileUtils.mkdir new_file unless File.directory? new_file\n clone = Dir.entries(new_source).find_all { |e| !e.start_with? '.'}\n clone.each do |recurse|\n files += bc_cloner(recurse, bc, entity, new_source, new_file, replace)\n end\n else\n #need to inject into the file\n unless replace\n puts \"\\t\\tcopying file #{new_file}.\" if DEBUG\n FileUtils.cp new_source, new_file\n files << new_file\n else\n puts \"\\t\\tcreating file #{new_file}.\" if DEBUG\n t = File.open(new_file, 'w')\n File.open(new_source, 'r') do |f|\n s = f.read\n t.write(bc_replacer(s, bc, entity))\n end\n t.close\n files << new_file\n end\n end\n return files\n end",
"def copy(from, to)\n @parent.gemset_copy(from, to)\n end",
"def deep_clone\n bi = dup\n bi.save\n feature_selections.each { |fs| bi.feature_selections << fs.dup }\n bi\n end",
"def deep_copy(o)\n Marshal.load(Marshal.dump(o))\nend",
"def deep_copy(o)\n Marshal.load(Marshal.dump(o))\nend",
"def deep_clone\n cloned = self.clone\n cloned.initialize_from_copy(self)\n cloned\n end",
"def circulating_copies\n copies.count(&:circulates?)\n end",
"def each\n @node_set.each do |c|\n yield NodeProxy.new(c, parent)\n end\n end",
"def dup\n super.tap do |instance|\n instance.instance_variable_set(:@chain, instance.chain.dup)\n end\n end",
"def copy_of *without, &block\n JrdObj.from self, *without, &block\n end",
"def forward_all!(collection)\r\n collection.each do |point|\r\n forward!(point)\r\n end\r\n collection\r\n end",
"def deepcompact\n ASE::deepcompact(self)\n end",
"def update_coercions!\n return if @coercions_updated\n\n if superclass.respond_to? :property_coercions\n @property_coercions = superclass.property_coercions.dup.merge(@property_coercions || {})\n end\n\n if superclass.respond_to? :sys_coercions\n @sys_coercions = superclass.sys_coercions.dup.merge(@sys_coercions || {})\n end\n\n if superclass.respond_to? :fields_coercions\n @fields_coercions = superclass.fields_coercions.dup.merge(@fields_coercions || {})\n end\n\n @coercions_updated = true\n end",
"def traverse; end",
"def calculate_copies\n # no copies if we don't have an ancestor.\n # no copies if we're going backwards.\n # no copies if we're overwriting.\n return {} unless ancestor && !(backwards? || overwrite?)\n # no copies if the user says not to follow them.\n return {} unless @repo.config[\"merge\", \"followcopies\", Boolean, true]\n\n \n dirs = @repo.config[\"merge\", \"followdirs\", Boolean, false]\n # calculate dem hoes!\n copy, diverge = Amp::Graphs::Mercurial::CopyCalculator.find_copies(self, local, remote, ancestor, dirs)\n \n # act upon each divergent rename (one branch renames to one name,\n # the other branch renames to a different name)\n diverge.each {|of, fl| divergent_rename of, fl }\n \n copy\n end",
"def each\n @node_set.each do |c|\n yield NodeProxy.new(c, parent)\n end\n end",
"def deep_dup\n # noinspection RubyMismatchedReturnType\n dup\n end",
"def demolish\n @children.each_value(&:demolish)\n end",
"def copy_depdencies(source_dir, target_dir, &block)\n\tdependecyManager = DependencyManager.new(source_dir, target_dir)\n\tdependecyManager.instance_eval(&block)\n\tdependecyManager.perform_file_copy\nend",
"def create_balanced_copy_subtree(elements:)\n return nil if elements.empty?\n\n\n centre_ix = (elements.size / 2).floor\n return Node.new(\n elements[centre_ix][0],\n elements[centre_ix][1],\n create_balanced_copy_subtree(elements: elements[0...(centre_ix)]),\n create_balanced_copy_subtree(elements: elements[(centre_ix+1)..-1]),\n )\n end",
"def copy(entity)\n entity.components.each do |component|\n add(component.as_inheritance)\n end\n end",
"def onCopied(src_item, item)\n @object.copied(import(src_item), import(item));\n end",
"def deep_dup(arr)\n copy = arr.dup\n copy.each_with_index do |el, i|\n copy[i] = deep_dup(el) if el.is_a?(Array)\n end\nend",
"def deep_copy(object)\n Marshal.load(Marshal.dump(object))\nend",
"def clone\n copy = super\n transaction do\n copy.save!\n\n %w[\n registration_information support information_source advance_directive\n ].each do |assoc|\n copy.send(\"#{assoc}\\=\", send(assoc).clone) if send(assoc)\n end\n\n %w[\n patient_identifiers languages providers medications allergies conditions\n all_results immunizations encounters procedures medical_equipments social_history insurance_providers\n ].each do |assoc|\n send(assoc).each do |item|\n copy.send(assoc) << item.clone\n end\n end\n\n end\n copy\n end",
"def recursive_deep_dup(arr)\n # # does arr contain anymore arrays?\n # if !(arr.is_a? Array)\n # arr\n # else\n # arr[recursive_deep_dup(arr)].dup\n # arr_copy = arr.dup\n arr_copy = []\n arr.each do |sub|\n if sub.is_a? Array\n # sub_copy = sub.dup\n # p sub_copy\n # recursive_deep_dup(sub_copy)\n arr_copy << recursive_deep_dup(sub)\n else\n arr_copy << sub\n end\n end\n arr_copy\n # end\nend"
] | [
"0.53555644",
"0.5301371",
"0.52057594",
"0.516215",
"0.5143115",
"0.50753987",
"0.50435585",
"0.49854043",
"0.4959328",
"0.4959328",
"0.49462602",
"0.4929271",
"0.49226788",
"0.49226788",
"0.49226788",
"0.491132",
"0.49070835",
"0.49054265",
"0.49022087",
"0.4898465",
"0.48814636",
"0.48683015",
"0.48523176",
"0.48479676",
"0.48358154",
"0.48246902",
"0.4806768",
"0.48038185",
"0.4801929",
"0.4801929",
"0.4757795",
"0.47565705",
"0.47536767",
"0.47468936",
"0.47201577",
"0.4705593",
"0.46961316",
"0.46642634",
"0.46496326",
"0.46460515",
"0.46456325",
"0.46423107",
"0.46409407",
"0.4640683",
"0.463717",
"0.46327463",
"0.46281797",
"0.46261972",
"0.46227968",
"0.46191242",
"0.46179235",
"0.4617897",
"0.46169457",
"0.4612496",
"0.45980862",
"0.4589818",
"0.45780623",
"0.4576238",
"0.4575637",
"0.45685825",
"0.45502776",
"0.4548201",
"0.45324343",
"0.45308855",
"0.45298958",
"0.45166183",
"0.45105827",
"0.44990286",
"0.44938907",
"0.44811165",
"0.44752964",
"0.44673336",
"0.44616425",
"0.44488457",
"0.4446181",
"0.44450158",
"0.44416755",
"0.44369653",
"0.44369653",
"0.4436599",
"0.44293112",
"0.44279972",
"0.44230124",
"0.44214526",
"0.44108677",
"0.44104832",
"0.4408779",
"0.44048247",
"0.44043702",
"0.44019443",
"0.43947533",
"0.43885878",
"0.4380783",
"0.43802968",
"0.4378011",
"0.43699798",
"0.43665496",
"0.43657064",
"0.43624663",
"0.4357804"
] | 0.68174386 | 0 |
Updates the priviledges of a user | def update_user_role(params)
self.link.update_attributes(role: params[:rolname], active: params[:active_link])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_user_overrides(token, channel_id, user_id, allow, deny)\n request(\n __method__,\n :put,\n \"#{api_base}/channels/#{channel_id}/permissions/#{user_id}\",\n { type: 'member', id: user_id, allow: allow, deny: deny }.to_json,\n Authorization: token,\n content_type: :json\n )\n end",
"def update_user\n end",
"def update!(**args)\n @user_access = args[:user_access] if args.key?(:user_access)\n end",
"def admin_update_permissions\n @user = User.find(params[:id])\n authorize @user\n\n perms_ids = permission_params[:perm_ids].blank? ? [] : permission_params[:perm_ids].map(&:to_i)\n perms = Perm.where(id: perms_ids)\n privileges_changed = false\n current_user.perms.each do |perm|\n if @user.perms.include? perm\n unless perms.include? perm\n @user.perms.delete(perm)\n @user.remove_token! if perm.id == Perm.use_api.id\n privileges_changed = true\n end\n elsif perms.include? perm\n @user.perms << perm\n if perm.id == Perm.use_api.id\n @user.keep_or_generate_token!\n privileges_changed = true\n end\n end\n end\n\n if @user.save\n if privileges_changed\n deliver_if(recipients: @user, key: 'users.admin_privileges') do |r|\n UserMailer.admin_privileges(r).deliver_now\n end\n end\n render(json: {\n code: 1,\n msg: success_message(perms.first_or_initialize, _('saved')),\n current_privileges: render_to_string(partial: 'users/current_privileges',\n locals: { user: @user }, formats: [:html])\n })\n else\n render(json: { code: 0, msg: failure_message(@user, _('updated')) })\n end\n end",
"def update\n privs = []\n privs << \"r\" if params[:r] == \"1\"\n privs << \"w\" if params[:w] == \"1\"\n privs << \"a\" if params[:a] == \"1\"\n @priv = privs.join(\"\")\n @project_user.priv = @priv\n @project = @project_user.project\n respond_to do |format|\n if @project_user.save\n format.html { redirect_to project_project_users_path(@project), notice: 'User setting was successfully updated.' }\n format.json { render :show, status: :ok, location: @project_user }\n else\n format.html { render :edit }\n format.json { render json: @project_user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize(@user)\n user_params = permitted_attributes(@user)\n if @user.update(user_params)\n users = policy_scope(User)\n render json: { users: users}\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end",
"def update_user_mute(token, server_id, user_id, state)\n request(\n __method__,\n :patch,\n \"#{api_base}/guilds/#{server_id}/members/#{user_id}\",\n { mute: state }.to_json,\n Authorization: token,\n content_type: :json\n )\n end",
"def update_user\n current_user.update_last_access if current_user && signed_in?\n end",
"def update_administrators\n if user_id_changed?\n if (user_id)\n Membership.find_by_user_id_and_network_id(user_id, id).try(:destroy) # delete membership of new owner\n end \n if (user_id_was)\n Membership.create(:user_id => user_id_was, :network_id => id,\n :administrator => true, :invited_by => User.find(user_id)).accept! # create membership for old owner\n end\n end\n end",
"def update\n\n authorize! :manage, @user\n \n respond_to do |format|\n\n if (current_user.id == @user.id) \n # Don't let a non-administrator assign themselves admin/download/viewing priviledges.\n # (Also) Don't let the current user disable their own admin account!\n params[:user].delete \"is_administrator\"\n if ! current_user.is_administrator\n params[:user].delete \"is_data_downloader\"\n params[:user].delete \"is_data_viewer\"\n end\n end \n \n\n if @user.update(user_params)\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n # format.json { render :show, status: :ok, location: @user }\n format.json { respond_with_bip(@user) }\n else\n format.html { render :edit }\n # format.json { render json: @user.errors, status: :unprocessable_entity }\n format.json { respond_with_bip(@user) }\n end\n end\n end",
"def update\n @user = User.find(params[:id])\n logger.tagged(\"update current user: \") {logger.debug @current_user.attributes}\n can_edit_hash = Permissions.currentLoggedInOrHasMorePermissions(@current_user,@user)\n logger.tagged(\"update user perm hash: \") {logger.debug can_edit_hash}\n if can_edit_hash[:has_permission]\n user_params = params[:user]\n logger.tagged(\":user\") {logger.debug user_params}\n @user.first_name = user_params[:first_name]\n @user.last_name = user_params[:last_name]\n @user.email = user_params[:email]\n @user.phone_number = user_params[:phone_number]\n @user.password_confirmation = @user.password\n\n can_change_roles_hash = Permissions.hasMorePermissions(@current_user,@user)\n @can_change_roles = can_change_roles_hash[:has_permission]\n if @can_change_roles\n @user.role = user_params[:role]\n else\n flash[:warning] = \"Don't have permission to promote/demote\"\n end\n\n if @user.save\n redirect_to user_path(@user)\n else\n\n @user.errors.full_messages.each do |msg|\n logger.tagged(\"error: \") {logger.debug msg}\n end\n flash[:warning] = \"Couldn't save changes\"\n redirect_to user_path(@user)\n end\n else\n flash[:warning] = can_edit_hash[:permission_message]\n redirect_to user_path(@user)\n end\n end",
"def update!(**args)\n @disabled_user_deletion = args[:disabled_user_deletion] if args.key?(:disabled_user_deletion)\n @disabled_user_signup = args[:disabled_user_signup] if args.key?(:disabled_user_signup)\n end",
"def update!(**args)\n @disabled_user_deletion = args[:disabled_user_deletion] if args.key?(:disabled_user_deletion)\n @disabled_user_signup = args[:disabled_user_signup] if args.key?(:disabled_user_signup)\n end",
"def change_privilege\n if Merb::Config[:user] && Merb::Config[:group]\n Merb.logger.verbose! \"About to change privilege to group \" \\\n \"#{Merb::Config[:group]} and user #{Merb::Config[:user]}\"\n _change_privilege(Merb::Config[:user], Merb::Config[:group])\n elsif Merb::Config[:user]\n Merb.logger.verbose! \"About to change privilege to user \" \\\n \"#{Merb::Config[:user]}\"\n _change_privilege(Merb::Config[:user])\n else\n return true\n end\n end",
"def update_display_user_access_level(display_id, user_id, access_level)\n put \"commandcenter/displays/#{display_id}/users/#{user_id}/access/#{access_level}\"\n end",
"def change_privilege(user, group=user)\n Merb.logger.info \"Changing privileges to #{user}:#{group}\"\n \n uid, gid = Process.euid, Process.egid\n target_uid = Etc.getpwnam(user).uid\n target_gid = Etc.getgrnam(group).gid\n \n if uid != target_uid || gid != target_gid\n # Change process ownership\n Process.initgroups(user, target_gid)\n Process::GID.change_privilege(target_gid)\n Process::UID.change_privilege(target_uid)\n end\n rescue Errno::EPERM => e\n Merb.logger.error \"Couldn't change user and group to #{user}:#{group}: #{e}\"\n end",
"def set_privacy(user=nil,level=0)\n # TODO finish and test\n # currently 0 = public, 1 = public but read only, 2 = private, 3 = private and read only\n # in all cases if you are a member you can see it\n end",
"def set_user_permission(id, level)\n @permissions[:users][id] = level\n end",
"def update\n if current_user.moderator?\n unauthorized_access if user_params[:role].eql? :admin\n end\n\n respond_to do |format|\n if @user.update(user_params)\n format.html { redirect_to @user, notice: 'Benutzer wurde erfolgreich aktualisiert.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def modify_guild_member(guild_id, user_id, reason: nil, nick: nil, roles: nil, mute: nil, deaf: nil, channel_id: nil)\n request(\n :guilds_gid_members_uid, guild_id,\n :patch,\n \"guilds/#{guild_id}/members/#{user_id}\",\n {nick: nick, roles: roles, mute: mute, deaf: deaf, channel_id: channel_id},\n 'X-Audit-Log-Reason': reason,\n )\n end",
"def update\n if any_unsub? && @user.update(user_updatable_params)\n # In case of Request #3 (unsubscriptions)\n # redirect_to confirmation for this request.\n redirect_to limit_right_confirmation_requests_path(user: @user)\n else\n #flash[:danger] = \"Erreur.\"\n if !any_unsub?\n flash[:danger]=\"Vous devez sélectionner au moins un choix\"\n end\n redirect_to limit_right_requests_path(user_id: @user.id)\n end\n end",
"def update\n modified_params = user_params\n modified_params.delete(\"password\") if modified_params[\"password\"].empty?\n if @user.update(modified_params)\n @users = current_user.users\n end\n end",
"def update_user_data!(owner_user_ids)\n owner_user_ids.each do|user_id|\n ::User.recalculate_item_count_of!(user_id)\n end\n end",
"def update_user_balance\n user.decrement(:loyalty_points_balance, loyalty_points)\n user.save!\n end",
"def downvote_and_update(user)\n self.disliked_by user\n self.save\n end",
"def update?\n @current_user.permission('Bid', :clerk)\n end",
"def change_privilege(user, group)\n begin\n if group\n log \"Changing group to #{group}.\"\n Process::GID.change_privilege(Etc.getgrnam(group).gid)\n end\n\n if user\n log \"Changing user to #{user}.\" \n Process::UID.change_privilege(Etc.getpwnam(user).uid)\n end\n rescue Errno::EPERM\n log \"FAILED to change user:group #{user}:#{group}: #$!\"\n exit 1\n end\n end",
"def update\n #@auth_assign_permit = Auth::AssignPermit.find(params[:id])\n if current_user.admin_group?\n @admin_user = current_user\n @owner_user = User.find(params[:id])\n\n respond_to do |format|\n if @owner_user.update_attributes(params[:user])\n format.html { redirect_to auth_assign_permit_path(@owner_user), notice: 'Assign permit was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @auth_assign_permit.errors, status: :unprocessable_entity }\n end\n end\n end\n end",
"def update_user(user, role = 'Member')\n self.users.update(id: user.id, role: role)\n end",
"def update\n \n @user = User.find(params[:id])\n authorize! :manage, User\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to :controller=>'admin/user_profiles', :action => 'index' }\n format.json { head :no_content }\n else\n format.html \n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user = User.find(params[:id])\n unless changing_his_own_role?(@user)\n User.update_all(params[:user], {:id => @user.id})\n # if @user.update_attribute(:role, params[:user][:role])\n # if @user.send(:attributes=, {:role => params[:user][:role]})\n flash[:notice] = \"User role updated!\"\n redirect_to admin_users_path\n # else\n # flash[:notice] = \"didn`t work\"\n # redirect_to admin_users_path\n # end\n else\n flash[:notice] = \"Can`t overwrite your own rights!\"\n redirect_to admin_users_path\n end\n end",
"def alter_user_level(user_level)\n \tself.user_level = user_level\n \tself.save\n end",
"def update\n if current__user.isAdmin || current__user == @user\n if @user.update(user_update_params)\n # setToken\n # UserNotifierMailer.send_signup_email(@user).deliver\n render :show, status: :ok\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n else\n render json: 'Sorry you are not allowed to perform this operation.', status: :unprocessable_entity\n end\n end",
"def update_user_points(user)\n user.update_attributes(:points => User.update_points(user.id))\n end",
"def update_user_deafen(token, server_id, user_id, state)\n request(\n __method__,\n :patch,\n \"#{api_base}/guilds/#{server_id}/members/#{user_id}\",\n { deaf: state }.to_json,\n Authorization: token,\n content_type: :json\n )\n end",
"def update\n if params[:id] != current_user.id && current_user.is_admin == false\n \traise \"You are not authorized to access this function\"\n end \n @user = current_user\n @user.update_attributes(params[:user])\n respond_with(@user)\n end",
"def update\n\t\tbegin\n\t\t\tif(session[:user][\"id\"][email protected] and session[:user][\"admin\"]==false)\n\t\t\t\traise \"No_ACCESS\"\n\t\t\telse\n\t\t\t\tputs \"1\"\n\n\t\t\t\tputs \"3\"\n\t\t\t\trespond_to do |format|\n\t\t\t\t\tif @user.update(user_params)\n\t\t\t\t\t\tif(@user.super)\n\t\t\t\t\t\t\[email protected]=true\n\t\t\t\t\t\t\[email protected]\n\t\t\t\t\t\t\tputs \"2\"\n\t\t\t\t\t\tend\n\t\t\t\t\t\tformat.html { redirect_to @user, notice: 'User was successfully updated.' }\n\t\t\t\t\t\tformat.json { render :show, status: :ok, location: @user }\n\t\t\t\t\telse\n\t\t\t\t\t\tformat.html { render :edit }\n\t\t\t\t\t\tformat.json { render json: @user.errors, status: :unprocessable_entity }\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\trescue\n\t\t\trender \"error\"\n\t\telse\n\t\tend\n\tend",
"def _change_privilege(user, group=user)\n Merb.logger.warn! \"Changing privileges to #{user}:#{group}\"\n\n uid, gid = Process.euid, Process.egid\n\n begin\n target_uid = Etc.getpwnam(user).uid\n rescue ArgumentError => e\n Merb.fatal!(\"Failed to change to user #{user}, does the user exist?\", e)\n return false\n end\n\n begin\n target_gid = Etc.getgrnam(group).gid\n rescue ArgumentError => e\n Merb.fatal!(\"Failed to change to group #{group}, does the group exist?\", e)\n return false\n end\n\n if (uid != target_uid) || (gid != target_gid)\n # Change process ownership\n Process.initgroups(user, target_gid)\n Process::GID.change_privilege(target_gid)\n Process::UID.change_privilege(target_uid)\n end\n true\n rescue Errno::EPERM => e\n Merb.fatal! \"Permission denied for changing user:group to #{user}:#{group}.\", e\n false\n end",
"def update\n authorized_user_params = user_params\n authorized_user_params.delete(:role_ids) unless policy(@user).manager?\n\n if @user.update(authorized_user_params)\n respond_successfully I18n.t('integral.backend.users.notification.edit_success'), backend_user_path(@user)\n else\n respond_failure I18n.t('integral.backend.users.notification.edit_failure'), 'edit'\n end\n end",
"def update\n load_user\n build_user\n assign_roles\n save_user or render :edit\n end",
"def update\n @user.annual = @user.user_id.slice(1..4)\n respond_to do |format|\n if @user.update(user_params)\n format.html { redirect_to @user, notice: 'ユーザーの更新が完了しました。' }\n format.json { render :show, status: :ok, location: @user }\n else\n format.html { render :edit }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def permits?( priv, user = User.current )\n (priv, associate) = disassemble_priv( priv )\n check_user_set!(user, priv, associate)\n user.can?( priv, associate )\n end",
"def update\n if check_user_write_access\n respond_to do |format|\n if user.update_attributes(params[:user])\n format.html { redirect_to user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :edit }\n format.json { render json: user.errors, status: :unprocessable_entity }\n end\n end\n end\n end",
"def update_board_permissions\n @board = Board.find(params[:board_id])\n @us = User.find_by_login(params[:user][:login]) \n @ac = params[:level]\n #debugger\n @board.allow!( @us, @ac.to_sym )\n end",
"def permitUser\n @member_permitted_name=Member.where(:id=>params[:id]).first.first_name\n Member.update(params[:id], :permitted => 1)\n flash[:notice] = \"User #{@member_permitted_name} allowed to book multiple rooms\"\n redirect_to(:action => 'index' )\n end",
"def update\n\n available_users\n \n #assign users to mission\n if params[:user_ids].present?\n user = params[:user_ids].delete_if{ |x| x.empty? }\n @mission.users = []\n @mission.users << User.find(params[:user_ids]) \n end\n respond_to do |format|\n if @mission.update(mission_params)\n format.html { redirect_to [:admin, @mission], notice: 'Mission was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @mission.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_member(auth, server_id, user_id, reason = nil, nick: nil, roles: nil, mute: nil, deaf: nil, channel_id: nil)\n MijDiscord::Core::API.request(\n :guilds_sid_members_uid,\n server_id,\n :patch,\n \"#{MijDiscord::Core::API::APIBASE_URL}/guilds/#{server_id}/members/#{user_id}\",\n { roles: roles, nick: nick, mute: mute, deaf: deaf, channel_id: channel_id }.delete_if {|_,v| v.nil? }.to_json,\n Authorization: auth,\n content_type: :json,\n 'X-Audit-Log-Reason': reason\n )\n end",
"def update!(**args)\n @admin_users = args[:admin_users] if args.key?(:admin_users)\n end",
"def update\n\n #Make sure only logged in admins can manipulate users\n\n if @loggedinuser && @loggedinuser.authorizationlevel >= 4\n #return render :text => params\n @user = User.find(params[:user][:id])\n if @user.update_attributes(params[:user])\n redirect_to :action => 'index'\n else\n render 'edit'\n end\n else \n redirect_to '/'\n end\n end",
"def permits_write_access_for(user)\n end",
"def update\n @user = @person.user \n can_manage_user!\n\n [:password, :password_confirmation].each do |password_key|\n params[:user].delete(password_key) if params[:user][password_key].blank?\n end\n\n # user.role\n if can? :assign_roles, User\n @user.role = params[:user][:role]\n elsif can_only_manage_crew_roles\n role = params[:user][:role] \n @user.role = role if User::USER_ROLES.include? role\n end\n params[:user].delete(:role)\n\n # user.conference_users\n if can_only_manage_crew_roles and params[:user][:conference_users_attributes].present?\n filter_conference_users(params[:user][:conference_users_attributes])\n end\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to(person_user_path(@person), notice: 'User was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render action: \"edit\" }\n format.xml { render xml: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def change_privilege(user, group=user)\n log \">> Changing process privilege to #{user}:#{group}\"\n \n uid, gid = Process.euid, Process.egid\n target_uid = Etc.getpwnam(user).uid\n target_gid = Etc.getgrnam(group).gid\n\n if uid != target_uid || gid != target_gid\n # Change process ownership\n Process.initgroups(user, target_gid)\n Process::GID.change_privilege(target_gid)\n Process::UID.change_privilege(target_uid)\n end\n rescue Errno::EPERM => e\n log \"Couldn't change user and group to #{user}:#{group}: #{e}\"\n end",
"def update_user(options)\n patch(\"/user\", options, 3)\n end",
"def moderator!(user, level: 50)\n return true if moderator?(user, target_level: level)\n\n user = user.id if user.is_a? User\n user = MXID.new(user.to_s) unless user.is_a? MXID\n raise ArgumentError, 'Must provide a valid user or MXID' unless user.user?\n\n modify_user_power_levels({ user.to_s.to_sym => level })\n end",
"def update\n if current_user.update(user_params)\n set_tags current_user\n redirect_to current_user, notice: 'User was successfully updated.'\n else\n render :edit\n end\n end",
"def update\n @users = User.find(params[:id])\n if params[:approved]\n if current_user && current_user.is_admin?\n if @users.update(user_params)\n # Tell the UserMailer to send a welcome email after approval\n UserMailer.user_approved(@users).deliver_later\n render json: { status: 200, msg: 'User details have been updated.' }\n end\n else\n render json: { error: 'You are not authorized to modify this data'} , status: 401\n end\n else\n if @users.update(user_params)\n render json: { status: 200, msg: 'User details have been updated.' }\n end\n end\n end",
"def update\n @user = User.find(params[:id])\n\n params[:user].reject!{|key, _| key.to_sym != :profile_text } if !current_user_is_admin?\n raise \"admins only\" if current_user != @user and !current_user_is_admin?\n\n if @user.update_attributes(params[:user])\n @user.update_attribute :admin, true if params[:user][:admin] == \"1\" and current_user_is_admin?\n redirect_to(user_path(@user), :notice => 'Your changes were saved.')\n else\n render :action => \"edit\"\n end\n end",
"def update\n @user.update(user_params)\n respond_with( [ :admin, @user] )\n end",
"def update_user_roles(token, server_id, user_id, roles)\n request(\n __method__,\n :patch,\n \"#{api_base}/guilds/#{server_id}/members/#{user_id}\",\n { roles: roles }.to_json,\n Authorization: token,\n content_type: :json\n )\n end",
"def deny_users(deny_ids)\n deny_ids.each do |id|\n user = User.find(id)\n if user.update_attributes({approval: -1}, as: :admin)\n @@message = \"The users have been denied.\"\n end\n end\n end",
"def update\n @user = User.find(params[:id])\n if @user == current_user\n @user.update_attributes user_params\n redirect_to user_path(@user)\n else\n flash[:alert] = \"You do not have permission to edit this account\"\n redirect_to posts_path\n end\n end",
"def update!(**args)\n @user_list = args[:user_list] if args.key?(:user_list)\n end",
"def update!(**args)\n @added_permissions = args[:added_permissions] if args.key?(:added_permissions)\n @removed_permissions = args[:removed_permissions] if args.key?(:removed_permissions)\n end",
"def update!(**args)\n @added_permissions = args[:added_permissions] if args.key?(:added_permissions)\n @removed_permissions = args[:removed_permissions] if args.key?(:removed_permissions)\n end",
"def update!(**args)\n @added_permissions = args[:added_permissions] if args.key?(:added_permissions)\n @removed_permissions = args[:removed_permissions] if args.key?(:removed_permissions)\n end",
"def update!(**args)\n @is_private = args[:is_private] if args.key?(:is_private)\n end",
"def update!(**args)\n @is_private = args[:is_private] if args.key?(:is_private)\n end",
"def update!(**args)\n @user_info = args[:user_info] if args.key?(:user_info)\n end",
"def update\n puts \"current user\"\n puts @user.id\n puts current_user.id\n if current_user.admin || @user.id == current_user.id\n if user_params['is_disabled']\n @user.tokens = nil\n end\n if @user.update(user_params)\n render json: @user\n else\n puts @user.errors.full_messages\n render json: @user.errors, status: :unprocessable_entity\n end\n else\n render json: @user.errors, status: :bad_request\n end\n end",
"def modify_user(user)\n query_api_object Model::User, '/rest/user', user.to_hash, 'PUT'\n end",
"def update!(**args)\n @has_access = args[:has_access] if args.key?(:has_access)\n end",
"def update!(**args)\n @has_access = args[:has_access] if args.key?(:has_access)\n end",
"def update\n @user = User.find(params[:id])\n authorize! :update, @user, :message => 'You are not authorized to perform this operation.'\n if @user.update_attributes(params[:user])\n redirect_to user_path(@user), :notice => \"You updated your account successfully. #{undo_link}\"\n else\n redirect_to user_path(@user), :alert => \"Unable to update user.\"\n end\n end",
"def update\n @user = User.find(params[:id])\n flag = !params[:user][:fellow_flag].nil? ? true :false\n #raise flag.inspect\n respond_to do |format|\n if @user.update_attributes(params[:user])\n if flag\n @access = Accessability.find_or_create_by_user_id(@user.id)\n @access.role_1 = params[:user][:create_certificates_and_reports]\n @access.role_2 = params[:user][:signoff_certificates_and_reports]\n @access.role_3 = params[:user][:access_account_settings]\n @access.save\n end\n format.html { redirect_to(settings_path, :notice => 'User was successfully updated.') }\n format.xml { head :ok }\n else\n redirect_to settings_path\n end\n end\n end",
"def update\n @user = User.find(params[:id])\n if current_user.admin\n @user.assign_attributes(params[:user], :without_protection => true)\n else\n @user.assign_attributes(params[:user])\n end\n respond_to do |format|\n if @user.save()\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user = User.find(params[:id])\n redirect_to user_path @user if @user.update(permit_update_params)\n end",
"def update_current_user_points\n current_user.update_attributes(:points => User.update_points(current_user.id))\n end",
"def edit\n @user = User.find(params[:id])\n logger.tagged(\"edit current user: \") {logger.debug @current_user.attributes}\n #TODO : make sure permissions are handled correctly\n can_edit_hash = Permissions.currentLoggedInOrHasMorePermissions(@current_user,@user)\n logger.tagged(\"edit user perm hash: \") {logger.debug can_edit_hash}\n if can_edit_hash[:has_permission]\n can_destroy_hash = Permissions.hasMorePermissions(@current_user,@user)\n @can_destroy = can_destroy_hash[:has_permission]\n else\n flash[:warning] = can_edit_hash[:permission_message]\n redirect_to user_path(@user)\n end\n\n end",
"def update\n authorize @user\n respond_to do |format|\n if @user.update(permitted_attributes(@user))\n format.html { redirect_to edit_user_path(@user), notice: 'User was successfully updated.' }\n format.json { render :show, status: :ok, location: @user }\n else\n format.html { render :edit }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def privilege(channel, user)\n user = user[:nick] if user.kind_of? Hash\n @chan_mutex.synchronize { @channel_members[channel] && @channel_members[channel][user] }\n end",
"def update_user(user)\n @users[user]=Hash.new if !@users[user]\n \n vmpool=OpenNebula::VirtualMachinePool.new(@client, user)\n vmpool.info\n \n one_ids=vmpool.map {|vm| vm.id }\n vms=@users[user]\n user_ids=vms.keys\n \n deleted_vms=user_ids-one_ids\n added_vms=one_ids-user_ids\n \n deleted_vms.each {|vmid| vms.delete(vmid) }\n \n added_vms.each do |vmid|\n vm=OpenNebula::VirtualMachine.new(\n OpenNebula::VirtualMachine.build_xml(vmid), @client)\n vm.info\n \n usage=VmUsage.new(vm['TEMPLATE/CPU'].to_f,\n vm['TEMPLATE/MEMORY'].to_i)\n vms[vmid.to_i]=usage\n end\n end",
"def admin_update_permissions\n @user = User.includes(:perms).find(params[:id])\n authorize @user\n perms_ids = params[:perm_ids].blank? ? [] : params[:perm_ids].map(&:to_i)\n perms = Perm.where( id: perms_ids)\n current_user.perms.each do |perm|\n if @user.perms.include? perm\n if ! perms.include? perm\n @user.perms.delete(perm)\n if perm.id == Perm.use_api.id\n @user.remove_token!\n end\n end\n else\n if perms.include? perm\n @user.perms << perm\n if perm.id == Perm.use_api.id\n @user.keep_or_generate_token!\n end\n end\n end\n end\n\n if @user.save!\n redirect_to({controller: 'users', action: 'admin_index'}, {notice: _('Information was successfully updated.')}) # helpers.success key does not exist, replaced with a generic string\n else\n flash[:notice] = failed_update_error(@user, _('user'))\n end\n end",
"def update\n @user = User.find(params[:id])\n @user.person.attributes = (params[:person])\n @roles = [Role.find_by_name(params[:user]['role'])]\n @user.roles = @roles\n respond_to do |format|\n if @user.update_attributes(params[:user]) && @user.person.save\n if params[:user][:password].length > 0\n UserNotifier.deliver_password_changed(@user, params[:user][:password]) \n end\n flash[:notice] = 'User was successfully updated.'\n format.html { redirect_to admin_users_url }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @user.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_access_controls!\n update!(edit_users: permission_template.agent_ids_for(access: 'manage', agent_type: 'user'),\n edit_groups: permission_template.agent_ids_for(access: 'manage', agent_type: 'group'))\n end",
"def modify_user \n logger.info(\"-------------------Called modyfy user with id: \"+params[:id])\n @user = User.find(params[:id])\n end",
"def authorize\n render json: { status: 200, msg: 'You are not allowed to do this update' } unless current_user && current_user.can_modify_user?(params[:id])\n end",
"def update_guild_member(data)\n server_id = data['guild_id'].to_i\n server = self.server(server_id)\n\n member = server.member(data['user']['id'].to_i)\n member.update_roles(data['roles'])\n member.update_nick(data['nick'])\n member.update_boosting_since(data['premium_since'])\n member.update_communication_disabled_until(data['communication_disabled_until'])\n end",
"def update!(**args)\n @permissions = args[:permissions] if args.key?(:permissions)\n end",
"def update!(**args)\n @permissions = args[:permissions] if args.key?(:permissions)\n end",
"def update!(**args)\n @permissions = args[:permissions] if args.key?(:permissions)\n end",
"def update!(**args)\n @permissions = args[:permissions] if args.key?(:permissions)\n end",
"def update!(**args)\n @permissions = args[:permissions] if args.key?(:permissions)\n end",
"def update!(**args)\n @permissions = args[:permissions] if args.key?(:permissions)\n end",
"def update!(**args)\n @permissions = args[:permissions] if args.key?(:permissions)\n end",
"def update!(**args)\n @permissions = args[:permissions] if args.key?(:permissions)\n end",
"def update!(**args)\n @permissions = args[:permissions] if args.key?(:permissions)\n end",
"def update!(**args)\n @permissions = args[:permissions] if args.key?(:permissions)\n end",
"def update!(**args)\n @permissions = args[:permissions] if args.key?(:permissions)\n end",
"def update!(**args)\n @permissions = args[:permissions] if args.key?(:permissions)\n end",
"def update!(**args)\n @permissions = args[:permissions] if args.key?(:permissions)\n end",
"def update!(**args)\n @permissions = args[:permissions] if args.key?(:permissions)\n end"
] | [
"0.65377885",
"0.63686997",
"0.63251936",
"0.63216645",
"0.61685115",
"0.61518425",
"0.6149679",
"0.61387736",
"0.61376715",
"0.61340845",
"0.6132937",
"0.6023069",
"0.6023069",
"0.6010269",
"0.5987902",
"0.5957384",
"0.59471345",
"0.59446675",
"0.5924825",
"0.589664",
"0.5855804",
"0.5844619",
"0.58267564",
"0.58204067",
"0.5814004",
"0.5806541",
"0.58016944",
"0.57973236",
"0.5791265",
"0.577695",
"0.577376",
"0.5769209",
"0.57684773",
"0.5767306",
"0.5753997",
"0.5733606",
"0.5705191",
"0.56845003",
"0.56784475",
"0.56721175",
"0.5668544",
"0.5663573",
"0.5645561",
"0.56446683",
"0.56443924",
"0.56406677",
"0.5636246",
"0.56310964",
"0.56214386",
"0.561319",
"0.56010014",
"0.5588495",
"0.55777085",
"0.5575555",
"0.55588716",
"0.5555046",
"0.5543862",
"0.55435073",
"0.5529174",
"0.55270004",
"0.552638",
"0.55247736",
"0.5524452",
"0.5524452",
"0.5524452",
"0.55244166",
"0.55244166",
"0.55240196",
"0.5519333",
"0.55180985",
"0.5510239",
"0.5510239",
"0.5507142",
"0.5503305",
"0.54992414",
"0.54951566",
"0.54940426",
"0.548678",
"0.5481553",
"0.5481295",
"0.5479307",
"0.547929",
"0.54766065",
"0.54731464",
"0.5471082",
"0.54704547",
"0.5461227",
"0.5459498",
"0.5459498",
"0.5459498",
"0.5459498",
"0.5459498",
"0.5459498",
"0.5459498",
"0.5459498",
"0.5459498",
"0.5459498",
"0.5459498",
"0.5459498",
"0.5459498",
"0.5459498"
] | 0.0 | -1 |
Build instance of model from fixture's DEFAULTS. | def build(model_name, attributes = {}) # rubocop:disable AbcSize, MethodLength
hash = begin
path = fixtures_path + '/' + model_name.to_s.pluralize + '.yml'
line = YAML.load(ERB.new(File.read(path)).result)['DEFAULTS'] # rubocop:disable YAMLLoad
instance_eval(ERB.new(line.to_s.gsub('$LABEL', 'sample')).result)
end
attributes.each { |key, value| hash[key] = value }
if model_name == :account
hash[:password] = APP::DEFAULT_PASSWORD
hash[:password_confirmation] = APP::DEFAULT_PASSWORD
end
##
correction = lambda do |ref|
if hash[ref].present?
hash["#{ref}_id"] = accounts(hash[ref].to_sym).id if ref == 'account'
hash["#{ref}_id"] = users(hash[ref].to_sym).id if ref == 'user'
hash["#{ref}_id"] = targets(hash[ref].to_sym).id if ref == 'target'
hash.delete(ref)
end
end
correction.call('account')
correction.call('user')
correction.call('target')
##
model_name.to_s
.classify
.constantize.new(hash)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_default_attributes\n self.config_params ||= DEFAULT_CONFIG_PARAMS\n self.has_inventory = true\n end",
"def default_model_attrs\n @default_model_attrs ||= begin\n config[:model].constantize.netzke_attributes.map do |attr| \n attr.merge(\n :label => attr[:label] || attr[:name].humanize,\n :attr_type => attr[:attr_type].to_s\n )\n end\n end\n end",
"def default_card_model_for_spec\n model = CardModel.where(short_name: \"basic\").first\n unless model\n attrs = FactoryGirl.attributes_for(:card_model, name: \"SRS Collector Basic\",\n short_name: \"basic\")\n model = create_default_card_model_from_attrs(attrs)\n end\n model\nend",
"def new_model_defaults\n end",
"def default_cloze_card_model_for_spec\n model = CardModel.where(short_name: \"cloze\").first\n unless model\n attrs = FactoryGirl.attributes_for(:card_model, name: \"SRS Collector Cloze\",\n short_name: \"cloze\", cloze: true)\n model = create_default_card_model_from_attrs(attrs)\n end\n model\nend",
"def new_model(defaults = {})\n if parent_model\n # is it a has_many\n if parent_model.respond_to?(plural_model_name)\n new_model = parent_model.send(plural_model_name).build(defaults)\n # is is a has_one\n elsif parent_model.respond_to?(model_name)\n new_model = parent_model.send(\"build_#{model_name}\", defaults)\n else\n raise \"can't find association #{model_name} or #{plural_model_name} for #{parent_model.class.name}\"\n end\n else\n new_model = model_name.camelize.constantize.new(defaults)\n end\n return new_model\n end",
"def set_default_values\n # set_new_record_default_values\n set_attr_accessor_default_values\n end",
"def initialize_model\n # let's create our new empty model\n @model = OpenStudio::Model::Model.new if @model.nil?\n end",
"def load_default\n load DEFAULT\n end",
"def build_default_nutrients\n DEFAULT_NUTRIENT_NAMES.each do |name|\n nutrients.build(name: name)\n end\n end",
"def model\n obj = versionable.class.new\n YAML::load( self.yaml ).each do |var_name,var_value|\n obj.__send__( \"#{var_name}=\", var_value )\n end\n obj\n end",
"def build(*args)\n model = generate(*args)\n model.save\n model\n end",
"def build_model\n self.model = nil # set up the model\n end",
"def setup\n # Retrieve fixtures via their name\n # @first = contacts(:first)\n end",
"def defaults\n self.class.defaults\n end",
"def initialize_default_values!\n Marshal.load(Marshal.dump(self.class.default_values)).each do |k, v|\n self[k] ||= v\n end\n end",
"def model(options = nil)\n if options.is_a?(Class)\n @klass = options\n elsif options\n type = options.fetch(:type) { DEFAULT_TYPE }\n @builder = ModelBuilder[type].new(options)\n end\n\n build_class unless options\n end",
"def create_default_templates\n UseCaseTemplate.create_default self\n end",
"def defaults\n self.class.defaults #.merge(@defaults || {})\n end",
"def default_values\n # always uses the same elevator system\n self.elevator_system ||= ElevatorSystem.first\n # always starts on the first floor\n self.floor ||= Floor.where(number: 1).first\n end",
"def defaults\n parse({})\n end",
"def setup_default_fixtures(files = ['sample_actors' , 'users', 'wiki_entries'])\n Fixtures.reset_cache\n files.each do |f|\n Fixtures.create_fixtures( File.dirname(__FILE__) + '/../fixtures' , File.basename( f , '.*'))\n end\nend",
"def setup\n # Retrieve fixtures via their name\n # @first = gizmo_types(:first)\n end",
"def set_default_properties\n keys = @resource_config[:model].keys\n if keys.include?(\"_id\")\n property :id, :w => :nobody\n end\n if keys.include?(\"created_at\")\n property :created_at, :w => :nobody\n end\n if keys.include?(\"updated_at\")\n property :updated_at, :w => :nobody\n end\n end",
"def default_attributes\n @default_attributes ||= {}\n end",
"def initialize_model\n { :def_class => BaseDefinition,\n :processes => [],\n :process_class => nil, :process_class_name => nil,\n :controller_class => nil, :controller_class_name => nil }\n end",
"def default_attributes\n cfg_get(:default_attributes)\n end",
"def default_attributes\n cfg_get(:default_attributes)\n end",
"def init_default_settings!\n self.class.default_settings.dup.each do |var, vals|\n setting_objects.detect { |s| s.var == var.to_s } || setting_objects.create(var: var.to_s, value: vals, target: self)\n end\n end",
"def default\n by_id(default_id)\n end",
"def random_fixture\n @fixtures_path = File.dirname(__FILE__) + '/../fixtures/models'\n fixtures = []\n Dir.foreach(@fixtures_path) do |item|\n next if item == '.' or item == '..' or item.end_with?('_glitched.obj') or !item.end_with?('.obj')\n fixtures << @fixtures_path + '/' + item\n end\n fixtures.sample\n end",
"def use_default_user_model def_model\n def_model\n end",
"def init(*args)\n if Hash === options = args.last\n for field in self.class.fields\n instance_variable_set \"@#{field}\", field.default_value(self, options)\n end\n end\n end",
"def set_default_attrs\n self.state = 'Texas' if self.respond_to? :state\n self.origin = 'hunted' if self.respond_to? :origin\n self.gender = 'male' if self.respond_to? :gender\n if self.respond_to? :parts\n parts = Part::NAMES.map { |part_name| {name: part_name} }\n parts << { other: true }\n self.parts = parts\n end\n if self.respond_to? :taxidermy_parts\n taxidermy_parts = self.class::DEFAULT_TAXIDERMY_PARTS.map { |part_name| {name: part_name} }\n taxidermy_parts << { other: true }\n self.taxidermy_parts = taxidermy_parts\n end\n self\n end",
"def default\n attributes.default\n end",
"def factory( *args, &block )\n\t\treturn FluentFixtures::Factory.new( self, *args, &block )\n\tend",
"def default\n game = self.new\n game.state = 'Texas' if game.respond_to? :state\n game.origin = 'hunted' if game.respond_to? :origin\n game.gender = 'male' if game.respond_to? :gender\n if game.respond_to? :parts\n parts = Part::NAMES.map { |part_name| {name: part_name} }\n parts << { other: true }\n game.parts = parts\n end\n game\n end",
"def setup\n # Retrieve fixtures via their name\n # @first = vr_cc_solicituds(:first)\n end",
"def setup\n # Retrieve fixtures via their name\n # @first = <%= plural_name %>(:first)\n end",
"def set_defaults\n unless persisted?\n end\n end",
"def assign_default_template\n self.variant ||= Variant.default.first\n end",
"def set_default_attributes\n self.attributes = default_attributes\n self.attributes.each do |key, value|\n # Scrub the attributes if there's no value\n attr_clean!(key) unless value\n end\n end",
"def setup\r\n # Retrieve fixtures via their name\r\n # @first = category(:first)\r\n end",
"def initialize(defaults={})\n unless ActiveRecord::Base.connection.table_exists?('entity_storage')\n\t\t\t\tAddEntitiesTable.create\n end\n\n self.defaults = defaults\n end",
"def default_attributes\n {}\n end",
"def default_attributes\n {}\n end",
"def create_model\n app = options[:app]\n return unless valid_model_for?(app)\n\n include_component_module_for(:test)\n migration_name = \"create_#{name.pluralize.underscore}\"\n apply_default_fields fields\n create_model_file(name, :fields => fields, :app => app)\n generate_model_test(name) if test?\n create_model_migration(migration_name, name, fields) unless options[:skip_migration]\n end",
"def preset_default_values( params_hash = {} )\n # XXX AmbGest 1.10 does not have a Firm entity:\n# unless self.firm\n# begin\n# if self.user_id and (default_firm_id = LeUser.find(self.user_id).firm_id)\n# self.firm_id = default_firm_id\n# end\n# rescue\n# self.firm_id = nil\n# end\n# end\n # Set default date for this entry:\n# self.date_last_met = Time.now unless self.date_last_met\n self\n end",
"def default_fields\n defaults = {}\n defaults = defaults.merge(@user.default_fields_with_name(:user)) if @user\n defaults = defaults.merge(@person.default_fields_with_name(:person)) if @person\n defaults = defaults.merge(@person.default_fields_with_name(:person_business_address_attributes)) if @person.business_address\n defaults = defaults.merge(@voucher.default_fields_with_name(:voucher)) if @voucher\n defaults\n end",
"def setup\r\n # Retrieve fixtures via their name\r\n # @first = categories(:first)\r\n end",
"def generate_default_values\n self.created_at = DateTime.now unless self.created_at\n end",
"def initialize(attrs = {})\n run_callbacks :initialize do\n @new_record = true\n @attributes ||= {}\n @associations ||= {}\n @attributes_before_type_cast ||= {}\n\n attrs_with_defaults = self.class.attributes.each_with_object({}) do |(attribute, options), res|\n if attrs.key?(attribute)\n res[attribute] = attrs[attribute]\n elsif options.key?(:default)\n res[attribute] = evaluate_default_value(options[:default])\n end\n end\n\n attrs_virtual = attrs.slice(*(attrs.keys - self.class.attributes.keys))\n\n load(attrs_with_defaults.merge(attrs_virtual))\n end\n end",
"def default_attributes\n {}\n end",
"def deferred_defaults\n set_default_path\n set_default_properties\n end",
"def set_defaults\n self.created_at ||= DateTime.now.utc\n self.keyword ||= nil\n self.extra ||= nil\n end",
"def initialize(param)\n if param.is_a?(Hash)\n @fields = build_model(param)\n @fields.default = ''\n else\n @fields = Hash.new('')\n @fields['cff-version'] = DEFAULT_SPEC_VERSION\n @fields['message'] = DEFAULT_MESSAGE\n @fields['title'] = param\n end\n\n %w[authors contact keywords references].each do |field|\n @fields[field] = [] if @fields[field].empty?\n end\n end",
"def test_default_value_in_just_create_model\n assert_equal 'new default value', ModelSecond.new.custom_field_renamed\n end",
"def create_defaults!\n Preference.reset_column_information\n conf = File.join( File.expand_path('../../', __FILE__), 'config', 'defaults.yml' )\n YAML.load( File.open(conf) ).each do |pref|\n Preference.where(key: pref['key'])\n .first_or_create(pref)\n end\n end",
"def test_basic_functionality\n u = DefaultSettings.create!\n end",
"def initialize_defaults\n self.data = {} if data.blank?\n end",
"def defaults\n {}\n end",
"def defaults\n {}\n end",
"def default_data\n end",
"def meta_default_data\n get_default_association_values.present? ? { :association_values => get_default_association_values.literalize_keys } : {}\n end",
"def set_default_values\n @mappings ||= {}\n @attr_methods ||= []\n @search_mappings ||= {}\n @value_blocks ||= {}\n @missing_blocks ||= {}\n @primary_key ||= :id\n end",
"def defaults\n {}\n end",
"def default_fauxture_name\n :default\n end",
"def build(attributes = {}, &block)\n attributes = defaults.merge!(attributes)\n\n model = new(attributes)\n\n if block_given?\n model.deputy(attributes[:client]).instance_eval(&block)\n end\n\n model\n end",
"def defaults\n fields.inject({}) do |defs, (field_name,field)|\n next(defs) if field.default.nil?\n defs[field_name.to_s] = field.default\n defs\n end\n end",
"def default_model()\n nil\n end",
"def seed\n @data = {}\n\n SEEDED_MODELS.each do |model_name|\n pluralized_model_name = model_name.underscore + 's'\n\n filename = \"app/data/#{pluralized_model_name}.yml\"\n\n # Load data as an array of objects\n models_data = YAML.safe_load(File.read(filename)).deep_symbolize_keys\n\n # Constantize model klass\n model_klass = Class.const_get(\"CodeWars::#{model_name}\")\n\n # Map models data to new Instances\n models_data.each_with_index do |model_data, i|\n model = model_klass.new\n\n model.load_attributes(model_data || {})\n\n model.indexed_at = i\n\n # Push to DataStore memory\n\n @data[pluralized_model_name.to_sym] ||= []\n @data[pluralized_model_name.to_sym] << model\n end\n end\n end",
"def setup\n # Retrieve fixtures via their name\n # @first = vr_cc_solicitudes(:first)\n end",
"def initialize\n super\n self.class.attributes.reject { |attr| attr.default.nil? }.each do |attr|\n send(\"#{attr.method_name}=\", attr.default)\n end\n end",
"def default_attributes\n @attributes = {\n :project => @name,\n :prefix => @prefix,\n :repositories => @repositories,\n :source => @source_project,\n :target => @target_project,\n :creation_date => \"#{Time.now}\",\n :last_mirror => \"0\",\n :date => \"#{Time.now}\",\n }\n end",
"def create_default_record(company_id, user_id)\n label = Label.new\n label.company_id = company_id\n label.created_by = user_id\n label.estimate_label = \"Estimate\"\n label.warehouse_label = \"Warehouse\"\n label.customer_label = \"Customer\"\n label.save!\n end",
"def set_uninitialized_defaults_as_instance_variables\n DEFAULTS.each do |k, v|\n var_name = \"@#{k}\".to_sym\n if instance_variable_get(var_name).nil?\n self.instance_variable_set(var_name, v)\n end\n end\n end",
"def set_default_values\n self.points_log ||= POINTS_LOG\n self.points_log_first_of_day ||= POINTS_LOG_FIRST_OF_DAY\n self.points_peer_assessment ||= POINTS_PEER_ASSESSMENT\n self.points_peer_assessment_first_of_team ||= POINTS_PEER_ASSESSMENT_FIRST_OF_TEAM\n self.points_project_evaluation ||= POINTS_PROJECT_EVALUATION\n self.points_project_evaluation_first_of_team ||= POINTS_PROJECT_EVALUATION_FIRST_OF_TEAM\n self.max_logs_per_day ||= MAX_LOGS_PER_DAY\n self.points_project_evaluation_submitted_first_day ||= POINTS_PROJECT_EVALUATION_SUBMITTED_FIRST_DAY\n self.points_peer_assessment_submitted_first_day ||= POINTS_PEER_ASSESSMENT_SUBMITTED_FIRST_DAY\n self.marking_algorithm_id ||= MARKING_ALGORITHM_ID\n end",
"def default_model_class=(model) #:nodoc:\n init_columns_of_table(model) unless key?(model)\n @default_model_class = model\n end",
"def default_attributes\n data.klass.stored_attributes[:data].map(&:to_s)\n end",
"def load_defaults\n @project_root ||= default_project_root\n @packaging_root ||= default_packaging_root\n\n Pkg::Params::DEFAULTS.each do |v|\n unless self.instance_variable_get(\"@#{v[:var]}\")\n self.instance_variable_set(\"@#{v[:var]}\", v[:val])\n end\n end\n end",
"def with_defaults(defaults); end",
"def generate_default_test(tests, title)\n tests[:default_default] = {\n desc: \"1.1 Apply default manifest with 'default' as a string in attributes\",\n title_pattern: title,\n manifest_props: {\n ensure: 'present',\n groups: 'default',\n method: 'default',\n },\n resource: {\n ensure: 'present',\n method: 'local',\n },\n code: [0, 2],\n }\n\n tests[:default_absent] = {\n desc: '1.2 Test resource absent manifest',\n title_pattern: title,\n manifest_props: {\n ensure: 'absent',\n },\n # can't *actually* remove authorization, that would crater the box,\n # but check to see if defaults have been restored\n resource: {\n ensure: 'present',\n method: 'local',\n },\n code: [0, 2],\n }\nend",
"def defaults\n @defaults\n end",
"def generate_model m\n # Model class, unit test, and fixtures.\n m.template 'model.rb', File.join('app/models', class_path, \"#{file_name}.rb\")\n m.template 'unit_test.rb', File.join('test/unit', class_path, \"#{file_name}_test.rb\")\n \n unless options[:skip_fixture] \n m.template 'fixtures.yml', File.join('test/fixtures', \"#{table_name}.yml\")\n end\n \n unless options[:skip_migration]\n m.migration_template 'migration.rb', 'db/migrate', :assigns => {\n :migration_name => \"Create#{class_name.pluralize.gsub(/::/, '')}\"\n }, :migration_file_name => \"create_#{file_path.gsub(/\\//, '_').pluralize}\"\n end\n \n # add has_many to referenced\n attributes.find_all{|a| a.type.to_s == \"references\"}.each do |parent|\n gsub_file \"app/models/#{parent.name}.rb\", \"class #{parent.name.camelize} < ActiveRecord::Base\" do |match|\n \"#{match}\\n has_many :#{table_name}\"\n end\n end\n end",
"def set_creation_defaults\n # Only run this before_validation because rails fires this before save/create\n if self.id.nil?\n self.title = \"My plan (#{self.template.title})\" if self.title.nil? && !self.template.nil?\n end\n end",
"def create_defaults\n @parameters[:date] = Time.parse(\"00:00\").to_s\n @parameters[:period] = \"24\"\n @parameters[:default] = true\n end",
"def default_attributes(custom = {})\n {}\n end",
"def defaults(params)\n @defaults = @defaults.merge(params)\n end",
"def use_default_user_model def_model\n def_model\nend",
"def model(make_of_model: T.unsafe(nil)); end",
"def initialize_model\n end",
"def create_default_database_yml\n db_class = RailsInstaller::Database.dbs[config['database']]\n db_class.database_yml(self)\n end",
"def set_defaults\n\t\tself.outside_agency_staff\t= DEFAULT_FIELD_TEXT\t\t\tif outside_agency_staff.nil?\n\t\tself.overview \t\t\t\t\t\t= DEFAULT_FIELD_TEXT\t\t \tif overview.nil?\n\t\tself.ratio \t\t\t\t\t\t\t\t= DEFAULT_FIELD_TEXT\t\t \tif ratio.nil?\n\t\tself.trainings_needed \t\t= DEFAULT_FIELD_TEXT\t\t \tif trainings_needed.nil?\n\t\tself.medication_times \t\t= DEFAULT_FIELD_TEXT\t\t \tif medication_times.nil?\n\t\tself.waivers \t\t\t\t\t\t\t= DEFAULT_FIELD_TEXT\t\t \tif waivers.nil?\n\t\tself.keys \t\t\t\t\t\t\t\t= DEFAULT_FIELD_TEXT\t\t \tif keys.nil?\n\t\tself.schedule_info \t\t\t\t= DEFAULT_FIELD_TEXT \t\t\tif schedule_info.nil?\n\t\tself.phone_numbers \t\t\t\t= DEFAULT_FIELD_TEXT \t\t\tif phone_numbers.nil?\n\t\tself.behavior_plans \t\t\t= DEFAULT_FIELD_TEXT \t\t\tif behavior_plans.nil?\n\t\tself.name\t\t\t\t\t\t\t\t\t= \"Untitled\"\t\t\t\t \t\t\tif name.nil?\n self.address_street\t\t\t\t= DEFAULT_ADDRESS_STREET \tif address_street.nil?\n self.address_city\t\t\t\t\t= DEFAULT_ADDRESS_CITY \t\tif address_city.nil?\n self.address_state\t\t\t\t= DEFAULT_ADDRESS_STATE \tif address_state.nil?\n self.address_zip\t\t\t\t\t= DEFAULT_ADDRESS_ZIP \t\tif address_zip.nil?\n self.phone_1\t\t\t\t\t\t\t= DEFAULT_PHONE_1 \t\t\t\tif phone_1.nil?\n self.phone_2\t\t\t\t\t\t\t= DEFAULT_PHONE_2 \t\t\t\tif phone_2.nil?\n self.fax\t\t\t\t\t\t\t\t\t= DEFAULT_FAX \t\t\t\t\t\tif fax.nil?\n self.bu_code\t\t\t\t\t\t\t= DEFAULT_BU_CODE\t\t \t\t\tif bu_code.nil?\n\tend",
"def initialize_models\n @models = {}\n @models[:required] = parse_models(@spec.files) if @spec.files\n end",
"def default_attrs\n @default_attrs\n end",
"def build_test_fixtures \n \n return if skip_method(__method__)\n \n puts \"build Rails fixture for #{model_name} in test/fixtures\"\n \n filename = \"#{plural_table_name}.yml\"\n template = File.read(template(\"rails/test/fixtures.yml\"))\n # #text = ERB.new(template, nil, '-').result(binding)\n text = Erubis::Eruby.new(template).evaluate( self )\n\n path = File.join(\"test\",\"fixtures\",filename)\n write_artifact(path,text) \n end",
"def create_default_variant\n unless self.variant?\n variant = self.variants.new\n variant.name = self.color_name\n product_name = self.name.squish.gsub(\" \", \"-\")\n # variant.permalink = \"#{product_permalink}-default\"\n variant.permalink = [product_name, \"-\", SecureRandom.hex(3)].join\n variant.sku = \"sku\"\n variant.color = self.color\n variant.sizes = self.sizes\n variant.price = self.price\n variant.old_price = self.old_price\n variant.default = true\n variant.save\n\n self.attachments.each do |attachment|\n attachment.update_column(:parent_id, variant.id)\n end\n end\n end",
"def initialize_from_builder(&block)\n builder = Class.new(Builder)\n builder.setup\n \n builder.instance_eval &block\n \n unless @model.descends_from_active_record?\n stored_class = @model.store_full_sti_class ? @model.name : @model.name.demodulize\n builder.where(\"#{@model.quoted_table_name}.#{quote_column(@model.inheritance_column)} = '#{stored_class}'\")\n end\n\n @fields = builder.fields\n @attributes = builder.attributes\n @conditions = builder.conditions\n @groupings = builder.groupings\n @delta_object = ThinkingSphinx::Deltas.parse self, builder.properties\n @options = builder.properties\n \n # We want to make sure that if the database doesn't exist, then Thinking\n # Sphinx doesn't mind when running non-TS tasks (like db:create, db:drop\n # and db:migrate). It's a bit hacky, but I can't think of a better way.\n rescue StandardError => err\n case err.class.name\n when \"Mysql::Error\", \"ActiveRecord::StatementInvalid\"\n return\n else\n raise err\n end\n end",
"def setup\n # Retrieve fixtures via their name\n # @first = accounts(:first)\n end",
"def default_fields\n # @kase.default_fields_with_name(:kase) if @kase\n defaults = {}\n defaults = defaults.merge(@review.default_fields_with_name(:review)) if @review\n defaults = defaults.merge(@comment.default_fields_with_name(:comment)) if @comment\n defaults\n end"
] | [
"0.5761208",
"0.5693238",
"0.5670357",
"0.5561082",
"0.5439651",
"0.5435143",
"0.5305661",
"0.52687776",
"0.52553135",
"0.52140546",
"0.5160349",
"0.51529276",
"0.51505506",
"0.5137352",
"0.5136639",
"0.5120106",
"0.51023155",
"0.50991195",
"0.5077334",
"0.5076242",
"0.5067461",
"0.50613886",
"0.5054791",
"0.5050818",
"0.50452167",
"0.50435805",
"0.50413626",
"0.5014606",
"0.4993488",
"0.498262",
"0.49716613",
"0.49608386",
"0.49544498",
"0.49530262",
"0.49500263",
"0.49472314",
"0.49371344",
"0.49302313",
"0.49299663",
"0.49238107",
"0.49132088",
"0.4907254",
"0.49072316",
"0.4907042",
"0.49045837",
"0.49045837",
"0.48843488",
"0.48814175",
"0.48806402",
"0.48648822",
"0.4864196",
"0.48619753",
"0.48608598",
"0.4859324",
"0.48545837",
"0.4851732",
"0.48459917",
"0.48390037",
"0.4832348",
"0.48323476",
"0.48236945",
"0.48229656",
"0.48214135",
"0.4819478",
"0.48193422",
"0.48171383",
"0.48123333",
"0.4807488",
"0.47997352",
"0.47989768",
"0.479099",
"0.47909603",
"0.4784219",
"0.47820887",
"0.47738126",
"0.47715324",
"0.47666264",
"0.4766557",
"0.47540772",
"0.47410956",
"0.4734919",
"0.47342026",
"0.47279215",
"0.47162053",
"0.47096452",
"0.47081473",
"0.47001103",
"0.46995956",
"0.46977597",
"0.46958873",
"0.4695829",
"0.46821284",
"0.46798044",
"0.46760255",
"0.46732405",
"0.46730894",
"0.46683118",
"0.4667905",
"0.4664068",
"0.46610877"
] | 0.609392 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_match
@match = Match.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def setup_handler\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def workflow\n end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup\n # override and do something appropriate\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def after_set_callback; end",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def save_action; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def setup(&blk)\n @setup_block = blk\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def duas1(action)\n action.call\n action.call\nend",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend"
] | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576",
"0.53124547",
"0.529654",
"0.5296262",
"0.52952296",
"0.52600986",
"0.52442724",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.5232394",
"0.523231",
"0.5227454",
"0.52226824",
"0.52201617",
"0.5212327",
"0.52079266",
"0.52050185",
"0.51754695",
"0.51726824",
"0.51710224",
"0.5166172",
"0.5159343",
"0.51578903",
"0.51522785",
"0.5152022",
"0.51518047",
"0.51456624",
"0.51398855",
"0.5133759",
"0.5112076",
"0.5111866",
"0.5111866",
"0.5110294",
"0.5106169",
"0.509231",
"0.50873137",
"0.5081088",
"0.508059",
"0.50677156",
"0.50562143",
"0.5050554",
"0.50474834",
"0.50474834",
"0.5036181",
"0.5026331",
"0.5022976",
"0.5015441",
"0.50121695",
"0.5000944",
"0.5000019",
"0.4996878",
"0.4989888",
"0.4989888",
"0.49864885",
"0.49797225",
"0.49785787",
"0.4976161",
"0.49683493",
"0.4965126",
"0.4958034",
"0.49559742",
"0.4954353",
"0.49535993",
"0.4952725",
"0.49467874",
"0.49423352",
"0.49325448",
"0.49282882",
"0.49269363",
"0.49269104",
"0.49252945",
"0.4923091",
"0.49194667",
"0.49174926",
"0.49173003",
"0.49171105",
"0.4915879",
"0.49155936"
] | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def match_params
params.require(:match).permit(:meatcut_id, :technique_id, :good_idea, :notes)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def param_whitelist\n [:role, :title]\n end",
"def expected_permitted_parameter_names; end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def permitted_params\n []\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params; true; end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def quote_params\n params.permit!\n end",
"def valid_params?; end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend",
"def filtered_parameters; end",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def filtering_params\n params.permit(:email, :name)\n end",
"def check_params\n true\n end",
"def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end",
"def active_code_params\n params[:active_code].permit\n end",
"def filtering_params\n params.permit(:email)\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end",
"def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end",
"def list_params\n params.permit(:name)\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def url_whitelist; end",
"def admin_social_network_params\n params.require(:social_network).permit!\n end",
"def filter_params\n params.require(:filters).permit(:letters)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end",
"def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def permit_request_params\n params.permit(:address)\n end",
"def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end",
"def secure_params\n params.require(:location).permit(:name)\n end",
"def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end",
"def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end",
"def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def url_params\n params[:url].permit(:full)\n end",
"def backend_user_params\n params.permit!\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end",
"def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end",
"def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end",
"def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end",
"def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end"
] | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",
"0.62894756",
"0.6283177",
"0.6242471",
"0.62382483",
"0.6217549",
"0.6214457",
"0.6209053",
"0.6193042",
"0.6177802",
"0.6174604",
"0.61714715",
"0.6161512",
"0.6151757",
"0.6150663",
"0.61461",
"0.61213595",
"0.611406",
"0.6106206",
"0.6105114",
"0.6089039",
"0.6081015",
"0.6071004",
"0.60620916",
"0.6019971",
"0.601788",
"0.6011056",
"0.6010898",
"0.6005122",
"0.6005122",
"0.6001556",
"0.6001049",
"0.59943926",
"0.5992201",
"0.59909594",
"0.5990628",
"0.5980841",
"0.59669393",
"0.59589154",
"0.5958826",
"0.5957911",
"0.5957385",
"0.5953072",
"0.59526145",
"0.5943361",
"0.59386164",
"0.59375334",
"0.59375334",
"0.5933856",
"0.59292704",
"0.59254247",
"0.5924164",
"0.59167904",
"0.59088355",
"0.5907542",
"0.59064597",
"0.5906243",
"0.5898226",
"0.589687",
"0.5896091",
"0.5894501",
"0.5894289",
"0.5891739",
"0.58860534",
"0.5882406",
"0.587974",
"0.58738774",
"0.5869024",
"0.58679986",
"0.5867561",
"0.5865932",
"0.5864461",
"0.58639693",
"0.58617616",
"0.5861436",
"0.5860451",
"0.58602303",
"0.5854586",
"0.58537364",
"0.5850427",
"0.5850199"
] | 0.0 | -1 |
TODO: add mode attr_accessor :mode | def initialize(string, project_id: nil, **keyword_args)
@query_string = ::ApplicationRecord.sanitize_sql(string)&.delete("\u0000") # remove null bytes
@project_id = project_id
build_terms # TODO - should remove this for accessors
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mode; end",
"def mode; end",
"def mode; end",
"def mode; end",
"def mode() end",
"def mode\n @mode\n end",
"def modes; end",
"def mode() @mode ||= detect_mode end",
"def get_mode()\n end",
"def mode\n Initialize() if @_mode == nil\n\n @_mode\n end",
"def mode=(_arg0); end",
"def mode=(_arg0); end",
"def mode=(_arg0); end",
"def mode\n raise \"Not implemented\"\n end",
"def mode\n options[:mode]\n end",
"def in_mode(mode)\n @mode = mode\n self\n end",
"def in_mode(mode)\n\t\t@mode = mode\n\t\tself\n\tend",
"def mode\n\t\treturn self.modes[0]\n\tend",
"def mode=(type)\n @mode = type.to_s\n end",
"def mode\n params['mode']\n end",
"def mode=(mode)\n @mode = mode ? mode.to_sym : nil\n end",
"def selected_mode\n @selected_mode\n end",
"def type\n params['mode']\n end",
"def set_mode(m)\n @mode = m\n end",
"def type\n params['mode']\n end",
"def mode=(a_mode)\n @@mode = a_mode.to_sym\n end",
"def name\n return mode_desc\n end",
"def set_mode(new)\n @mode = new\n end",
"def mode=(mode)\n super(0100000 | (mode & 07777))\n end",
"def mode=(m)\n @mode = m.to_sym\n end",
"def mode=(mode)\n \n write(\"++mode 1\" ) if mode==:Device \n write(\"++mode 0\" ) if mode==:Controller\n @mode = write(\"++mode\",true).to_i==1 ? :Controller : :Device\n end",
"def mode\n @mode ||= :smart \n end",
"def usermode; @user_mode; end",
"def mode\n TflApi::Client::Mode.new(self)\n end",
"def mode\n \"%o\" % (self.stat(:mode) & 007777)\n end",
"def mode=(mode)\n Nitro.mode = mode.to_sym\n end",
"def mode=(val)\n if val.blank? or val.kind_of? Fixnum then\n write_attribute(:mode, val)\n else\n write_attribute(:mode, Mode[val])\n end\n end",
"def mode=(mode)\n super(040000 | (mode & 07777))\n end",
"def mode=(mode)\n super(0120000 | (mode & 07777))\n end",
"def mode=(new_mode)\n handle_old_mode\n @mode = new_mode\n handle_new_mode\n end",
"def mode\n attributes.fetch(:mode) do\n Ably::Util::Crypto::DEFAULTS.fetch(:mode)\n end.downcase\n end",
"def set_mode\n @mode = Mode.find(params[:id])\n end",
"def game_mode; end",
"def mode?\n return @mode\n end",
"def mode=(mode)\n request.mode = mode\n end",
"def mode_name=(value)\n @mode_name = Mode.new value\n end",
"def set_mode\n @mode = Mode.find(params[:id])\n end",
"def mode_name\n if mode >= 0 && mode <= 15\n MODES[mode]\n else\n \"(#{mode})\"\n end\n end",
"def get_modes\n @_modes\n end",
"def current_mode\n self.say \"The current mode is: #{@config[:mode]}\"\n end",
"def mode\n request.mode\n end",
"def mode=(new_mode)\n LOGGER.mode = new_mode\n end",
"def mode=(new_mode)\n LOGGER.mode = new_mode\n end",
"def get_mode()\n session['mode'] = session['mode'] || 'edit'\n return session['mode']\n end",
"def init\n \tself.mode = \"Manual\"\n \tself.status = \"Off\"\n end",
"def modes\n fix_mode.modes\n end",
"def flags; end",
"def mode= new_mode\n @gapi.update! mode: verify_mode(new_mode)\n end",
"def mode\n @gapi.mode\n end",
"def target_mode\n return nil if resource.mode.nil?\n (resource.mode.respond_to?(:oct) ? resource.mode.oct : resource.mode.to_i) & 007777\n end",
"def mode\n modes(false)[0]\n end",
"def mode\n modes(false)[0]\n end",
"def set_Mode(value)\n set_input(\"Mode\", value)\n end",
"def set_Mode(value)\n set_input(\"Mode\", value)\n end",
"def mode=(new_mode)\n @mode , @previous_mode = new_mode, @mode\n build_chains() if @mode != @previous_mode && @previous_mode != nil && @previous_mode != \"\"\n end",
"def mode\n\t\t@mode || (proxy_owner.mode if proxy_owner.respond_to?(:mode))\n\tend",
"def initialize(mode = MODE_HIGH, version = 1)\n @mode = mode\n @version = version\n end",
"def mode\n Mode.new(ENV).mode\n end",
"def initialize(mode = :bottom)\n super(self.class.name)\n @mode = mode\n end",
"def initialize(mode = :bottom)\n super(self.class.name)\n @mode = mode\n end",
"def modes\n mode_codes.keys\n end",
"def authorization_mode=(mode); end",
"def file_mode\n super | 0o111\n end",
"def mode\n site.mode\n end",
"def mode name, &b\n mode_definitions << [name, b]\n end",
"def next_mode new_mode\n if has_mode? new_mode\n @mode = new_mode\n else\n warn \"Robot #{self.class} switched to unknown mode :#{new_mode}!\"\n @mode = :idle\n end\n end",
"def mode\n case @data_list\n when QRNumeric\n :mode_number\n when QRAlphanumeric\n :mode_alpha_numk\n else\n :mode_8bit_byte\n end\n end",
"def initialize(mode = 0)\n super(88, 148, 368, 248)\n @mode = mode\n @index = 0\n refresh\n update_cursor\n end",
"def mode_sym\n (mode || :off).to_sym\n end",
"def restore_mode; end",
"def restore_mode; end",
"def start(mode)\n end",
"def set_Mode(value)\n set_input(\"Mode\", value)\n end",
"def set_mode(mode)\n @mode = mode\n\n if mode == 'w'\n File.open(\"#{ GPIO_PATH }/gpio#{ pin_num }/direction\", \"w\") { |f| f.write(GPIO_DIRECTION_WRITE) }\n @pin_file = File.open(\"#{ GPIO_PATH }/gpio#{ pin_num }/value\", \"w\")\n elsif mode =='r'\n File.open(\"#{ GPIO_PATH }/gpio#{ pin_num }/direction\", \"w\") { |f| f.write(GPIO_DIRECTION_READ) }\n @pin_file = File.open(\"#{ GPIO_PATH }/gpio#{pin_num}/value\", \"r\")\n end\n end",
"def edit(mode=@mode) # not sure if you can use an instance variable like this\n\told_mode = @mode\n\t\t@mode = mode\n\t\t\n\t\tself.tap |mode_handle|\n\t\t\tyield mode_handle\n\t\tend",
"def get_mode\n send_request(FUNCTION_GET_MODE, [], '', 1, 'C')\n end",
"def mode\n defined? @mode and @mode or @mode='sandbox'\n end",
"def set_mode(mode)\n send_request(FUNCTION_SET_MODE, [mode], 'C', 0, '')\n end",
"def with_mode(id, _options = {})\n orig = mode\n self.mode = id\n yield\n self.mode = orig\n end",
"def describe_mode(mode, desc, banner)\n fail \"Undefined mode: #{mode}\" unless defined_modes.include? mode\n described_modes[mode] = { desc: _t(desc), banner: _t(banner) }\n end",
"def set_mode(mode)\n puts \"Setting mode to #{mode}\" if $verbose\n m='MD'+mode.to_s+';'\n puts m if $verbose\n ret=send_cmd(m,'MD;',m,0.1,0.5,3)\n if(ret)\n return(ret.gsub(/^MD/,'').gsub(/;$/,'').to_i)\n else\n return(nil)\n end\nend",
"def binmode\n self\n end",
"def binmode\n end",
"def binmode\n end",
"def set_mode\n\t\tif @year.nil? and @month.nil?\n\t\t\t@mode = :all\n\t\tend\n\n\t\tif /\\d{4}/ === @year.to_s\n\t\t\t@mode = :year\n\t\telse\n\t\t\t@year = nil\n\t\tend\n\n\t\tif /[12]H/ === @month.to_s\n\t\t\t@mode = :half\n\t\telsif /[1-4]Q/ === @month.to_s\n\t\t\t@mode = :quarter\n\t\telsif (1..12).include?(@month.to_i)\n\t\t\t@mode = :month\n\t\telse\n\t\t\t@month = nil\n\t\tend\n\n\tend",
"def mode\n \"%o\" % (File.stat(@resource[:name]).mode & 007777)\n end",
"def modes= m\n m.instance_eval \"def to_s; self.join(','); end\" if m.is_a?(Array) #override to_s\n @modes = m\n end",
"def one_player_mode\nend",
"def edit(mode=@mode)\n\told_mode = @mode unless @mode == mode\n\t\n\t\t@mode = mode\n\t\t\n\t\tself.tap |mode_handle|\n\t\t\tyield mode_handle\n\t\tend",
"def engine_mode\n data[:engine_mode]\n end",
"def mode_params\n params.require(:mode).permit(:name)\n end"
] | [
"0.8569273",
"0.8569273",
"0.8569273",
"0.8569273",
"0.8052261",
"0.79392755",
"0.792404",
"0.7699949",
"0.75456685",
"0.74582523",
"0.74266803",
"0.74266803",
"0.74266803",
"0.73595005",
"0.7313339",
"0.71546894",
"0.71342623",
"0.70657176",
"0.6966283",
"0.69587773",
"0.6818009",
"0.6810897",
"0.67219216",
"0.672152",
"0.6702345",
"0.66741246",
"0.6673812",
"0.66701484",
"0.66503364",
"0.6648899",
"0.66357315",
"0.6614993",
"0.66146207",
"0.65997946",
"0.6594179",
"0.6591632",
"0.65780306",
"0.65506977",
"0.6544693",
"0.6531228",
"0.6524728",
"0.65145046",
"0.64862365",
"0.6484164",
"0.64588237",
"0.64413345",
"0.64364624",
"0.6429654",
"0.6406198",
"0.6368792",
"0.6368359",
"0.63585615",
"0.63585615",
"0.6315657",
"0.6301964",
"0.6287643",
"0.6255115",
"0.62511444",
"0.62507904",
"0.6249272",
"0.6242474",
"0.6242474",
"0.62389535",
"0.62389535",
"0.62380534",
"0.62324643",
"0.62267244",
"0.6225173",
"0.61865723",
"0.61865723",
"0.6179799",
"0.61788446",
"0.61692643",
"0.6155215",
"0.6154511",
"0.6141779",
"0.61385703",
"0.6130829",
"0.61270565",
"0.61087084",
"0.61087084",
"0.6106877",
"0.6095371",
"0.60023904",
"0.60012674",
"0.59940726",
"0.5993178",
"0.59681976",
"0.5958041",
"0.5945286",
"0.59350747",
"0.59308946",
"0.5922698",
"0.5922698",
"0.59147424",
"0.59018695",
"0.5899044",
"0.5892089",
"0.586347",
"0.5857207",
"0.5852277"
] | 0.0 | -1 |
Match at two levels, for example, 'wa te" will match "Washington Co., Texas" | def parent_child_where
a,b = query_string.split(/\s+/, 2)
return table[:id].eq(-1) if a.nil? || b.nil?
table[:name].matches("#{a}%").and(parent[:name].matches("#{b}%"))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def match_string( tree, string )\n # puts \"Checking for `#{string}` in tree (#{tree}).\"\n\n if tree.empty?\n # puts \"Tree is empty, returning empty\"\n return [ ]\n\n elsif string.empty?\n # puts \"No search string, returning empty\"\n return [ ]\n\n else\n matches = [ ]\n\n tree.each do |key,val|\n # puts \"Checking for `#{string}` in `#{key}` branch.\"\n\n simdex = string.simdex(key)\n\n if 0 < simdex\n if string == key\n # puts \"Matched full word! #{string} is #{key}\"\n # matches = collect_keys(val, key).unshift(key)\n return collect_keys(val, key).unshift(key)\n # puts \"Got matches: #{matches}\"\n\n else\n leaf = string.leaf(simdex)\n # puts \"Got leaf #{leaf}\"\n\n check = match_string(val, leaf)\n # puts \"Got check: #{check}\"\n\n if !check.empty?\n # matches = (check.map { |m| key + m })\n return check.map { |m| key + m }\n # puts \"New matches: #{matches}\"\n end\n end\n\n # break\n\n else\n check = match_string(val, string)\n\n if !check.empty?\n matches += check\n end\n end\n end\n\n # if matches.empty?\n # # puts \"No matches (#{string})\"\n # else\n # # puts \"Returning matches (#{string}): #{matches}\"\n # end\n\n return matches\n end\n end",
"def test_match_case_sensitive_depth\r\n\t\t#content with exact match\r\n\t\tcontent = \"123MyMatch and some more\"\r\n\t\tsnort_rule_content = SnortRuleContent.new\r\n\t\tsnort_rule_content.unescaped_string = \"MyMatch\"\r\n\t\tsnort_rule_content.depth = 10\r\n\t\tsnort_rule_content.nocase = false\r\n\t\tmatch = snort_rule_content.match(content,0)\r\n\t\tassert_equal(3, match,\"no match on content with depth.\")\r\n\tend",
"def test_strict_match_criteria\n entry = BigramEntry.new\n entry.parse_line(\"8\t工作\t18904\t6.89133239246\t213454\")\n cedict_entry = CEdictEntry.new\n cedict_entry.parse_line(\"工作 工作 [gong1 zuo4] /job/work/construction/task/CL:個|个[ge4],份[fen4],項|项[xiang4]/\")\n \n result = entry.default_match_criteria.call(cedict_entry,entry)\n assert(true,result)\n end",
"def create_match(nominee)\n names = []\n pname = nominee[:name]\n names << pname\n names << pname.sub(%r{ [A-Z]\\. }, ' ') # drop initial\n personname = ASF::Person.find(nominee[:id]).public_name\n names << personname if personname\n list = names.uniq.map{|name| Regexp.escape(name)}.join('|')\n # N.B. \\b does not match if it follows ')', so won't match John (Fred)\n # TODO: Work-round is to also look for EOS, but this needs to be improved\n %r{\\b(#{list})(\\b|$)}i\nend",
"def test_match_case_sensitive_depth_no_match\r\n\t\t#content with exact match\r\n\t\tcontent = \"123MyMatch and some more\"\r\n\t\tsnort_rule_content = SnortRuleContent.new\r\n\t\tsnort_rule_content.unescaped_string = \"MyMatch\"\r\n\t\tsnort_rule_content.depth = 9\r\n\t\tsnort_rule_content.nocase = false\r\n\t\tassert(!snort_rule_content.match(content,0),\"incorrect match on content with depth.\")\r\n\tend",
"def great_matches\n filtered_matches(partial_or_perfect: [:family_name, :first_name], perfect: [:street, :city])\n end",
"def found_match(str)\n\tif dictionary.include?(str) # returns true if found in the dictionary\n\t\treturn str # don't stop the recursion, but return the word ?\n\tend\n\tfalse\nend",
"def match(keyword); end",
"def maybe_matching(ingredient_long_name,item)\n return (item.downcase.split(\" \") & ingredient_long_name.split(\" \")).size >= 1\nend",
"def case_insensitive_match; end",
"def commonChild(s1, s2)\n #ABCDEFG\n #ABDCLFG\n # regex search using * between each character and see what is the longest match you can make\n #A*B*C*D*E*F*G\n #ABCFG\n \nend",
"def test_like_two_search_condition\n search_conditions = [[\"Wes\", :like],[\"Hays\", :like]]\n query_fields = {'some_table.first_name' => :string,'some_table.last_name' => :string} \n conditions = build_query(search_conditions, query_fields) \n \n fields = ['first_name','last_name']\n regExs = [build_regex_for_like(fields,'keyword_0'), \n build_regex_for_like(fields,'keyword_1')].join('[ ]AND[ ]')\n \n assert_match /^#{regExs}$/, conditions.first\n assert_equal '%Wes%', conditions.last[:keyword_0]\n assert_equal '%Hays%', conditions.last[:keyword_1]\n end",
"def submatcher; end",
"def submatcher; end",
"def family_name_matches\n filtered_matches(ignore: [:first_name], partial_or_perfect: [:family_name], perfect: [:street, :city])\n end",
"def taxamatch(str1, str2, return_boolean = true)\n preparsed_1 = @parser.parse(str1)\n preparsed_2 = @parser.parse(str2)\n match = taxamatch_preparsed(preparsed_1, preparsed_2) rescue nil\n return_boolean ? (!!match && match['match']) : match\n end",
"def taxamatch_preparsed(preparsed_1, preparsed_2)\n result = nil\n if preparsed_1[:uninomial] && preparsed_2[:uninomial]\n result = match_uninomial(preparsed_1, preparsed_2)\n end\n if preparsed_1[:genus] && preparsed_2[:genus]\n result = match_multinomial(preparsed_1, preparsed_2)\n end\n if result && result['match']\n result['match'] = match_authors(preparsed_1, preparsed_2) == -1 ?\n false : true\n end\n return result\n end",
"def match(tt)\n \ttt = \"#{tt}\"\n tt = tt.to_s.split(',')\n out = Cites.match(tt)\n puts out\n end",
"def test_compare_string_overlap_defs\n v1 = Vertex.new(\"speech\", 2, 1, 0, 0, 1, \"NN\")\n v2 = Vertex.new(\"delivering\", 2, 1, 0, 0, 1, \"VB\")\n assert_equal(1, instance.compare_strings(v1, v2, speller))#no POS is considered for hypernyms and hyponyms\n end",
"def match_states(query); end",
"def element_match(tree, exp, bindings); end",
"def match(str)\n d, m = str.split(\" \")\n _match(d, m) \n end",
"def case_insensitive_match=(_arg0); end",
"def test_parentheses_also_capture_matched_content_by_number\n assert_equal \"Gray\", \"Gray, James\"[/(\\w+), (\\w+)/, 1]\n assert_equal \"James\", \"Gray, James\"[/(\\w+), (\\w+)/, 2]\n end",
"def match choice\n choice.select { |entry| entry if entry.downcase.split(//).sort == self.word.downcase.split(//).sort && entry.downcase != self.word.downcase} \n end",
"def find_place(match)\n find = proc do |node|\n if node.text?\n formatted_text = node.text.strip\n unless formatted_text.empty?\n res = formatted_text.match?(\n /^[a-záàâãéèêíïóôõöúçñ\\-\\s]+ - [a-záàâãéèêíïóôõöúçñ\\s\\-]+ - [A-Z]{2}$/i\n )\n next formatted_text if res\n end\n end\n nil\n end\n\n depth_search(match, find)\n end",
"def test_parentheses_also_capture_matched_content_by_number\n assert_equal 'Gray', \"Gray, James\"[/(\\w+), (\\w+)/, 1]\n assert_equal 'James', \"Gray, James\"[/(\\w+), (\\w+)/, 2]\n end",
"def bubble_up_exact_matches(affil_list:, term:)\n matches_at_beginning = []\n matches_within = []\n other_items = []\n match_term = term.downcase\n affil_list.each do |affil_item|\n name = affil_item[:name].downcase\n if name.start_with?(match_term)\n matches_at_beginning << affil_item\n elsif name.include?(match_term)\n matches_within << affil_item\n else\n other_items << affil_item\n end\n end\n matches_at_beginning + matches_within + other_items\n end",
"def probable_matching(ingredient_long_name,item)\n return (item.downcase.split(\" \") & ingredient_long_name.split(\" \")).size >= 2\nend",
"def nest_get_match(level, child_data, local_nesting, expected, match_value)\n case level[:type]\n when 'single' then\n nest_match_attributes(child_data, local_nesting, expected, match_value)\n when 'multiple' then\n child_check(level, child_data, local_nesting, expected, match_value)\n when 'list' then\n child_is_list(level, child_data)\n else\n raise %(Unknown nested data type: #{level[:type]})\n end\nend",
"def myfind (str)\n if str.match(/^[[:graph:]]+$/)\n Provider.where(\"lower(name) like ?\", \"%#{str}%\")\n end\n end",
"def match?(given_names); end",
"def match_query(query); end",
"def is_match_b(s, p, i = 0, j = 0)\n return i == s.length if j == p.length\n first = i < s.length && [s[i], '.'].include?(p[j])\n if p[j+1] == '*'\n is_match_b(s, p, i, j+2) || (first && is_match_b(s, p, i+1, j))\n else\n first && is_match_b(s, p, i+1, j+1)\n end\nend",
"def outward_match(match)\n if match == \"word\"\n return \"kanji\"\n elsif match == \"reading\"\n return \"romaji\"\n else\n return match\n end\n end",
"def matching_the_word_and\n /WRITE ME/\n end",
"def match_mixed(test)\n case test\n when 'hello'\n 'hello'\n in [a, b]\n \"a: #{a}, b: #{b}\"\n end\nend",
"def check_if_present(word)\n chars = word.downcase.split('')\n match = false\n char_count = 0\n crawl = root\n\n chars.each do |a_char|\n char_count += 1\n child = crawl.children\n if child.keys.include?(a_char)\n crawl = child[a_char]\n if crawl.is_end && (char_count == chars.length)\n match=true\n end\n else\n break;\n end\n end\n match # returns if the word is in dictionary or not.\n end",
"def find_subgenre(subgenres, subgenre_titles, description) \n description.downcase!\n subgenres.each_with_index do |subgenre, index|\n subgenre.each do |word|\n if description.include?(word)\n return subgenre_titles[index]\n end\n end\n end\n return \"other\"\n end",
"def check_in(word)\n if /lab/ =~ word\n puts word\n else\n puts \"No match\"\n end\nend",
"def check_in(word)\n if /lab/ =~ word\n puts word\n else\n puts \"No match\"\n end\nend",
"def check_in(word)\n if /lab/ =~ word\n puts word\n else\n puts \"No match\"\n end\nend",
"def bubble_up_exact_matches(result_list:, term:)\n matches_at_beginning = []\n matches_within = []\n other_items = []\n match_term = term.downcase\n result_list.each do |result_item|\n next if result_item.blank?\n\n name = result_item['name'].downcase\n if name.start_with?(match_term)\n matches_at_beginning << result_item\n elsif name.include?(match_term)\n matches_within << result_item\n else\n other_items << result_item\n end\n end\n matches_at_beginning + matches_within + other_items\n end",
"def nested(s)\n return true if s == \"\"\n return false if s.length % 2 != 0\n return s[0] == \"(\" && s[-1] == \")\" && nested(s[1,s.length - 2])\nend",
"def match_a_string(name)\n case name\n in \"ruby\"\n puts \"https://www.ruby-lang.org/en/\"\n in \"python\"\n puts \"https://www.python.org/\"\n in \"elixir\"\n puts \"https://elixir-lang.org/\"\n else\n puts \"no match\"\n end\nend",
"def search(word)\n return true if @isend && word.length == 0\n if word[0] == \".\"\n @childs.any? { |key, child| child.search(word[1..-1]) }\n elsif @childs[word[0]]\n @childs[word[0]].search(word[1..-1])\n else\n false\n end\n end",
"def is_match(s, p)\n dp = Array.new(s.length+1) { Array.new(p.length+1, false) }\n m, n = s.length, p.length\n dp[m][n] = true\n m.downto(0) do |i|\n (n-1).downto(0) do |j| \n first = i < m && (s[i] == p[j] || p[j] == '.')\n if p[j+1] == '*'\n dp[i][j] = dp[i][j+2] || (first && dp[i+1][j])\n else\n dp[i][j] = first && dp[i+1][j+1]\n end\n end\n end\n dp[0][0]\nend",
"def search(word)\n nodes = [@root]\n word.each_char do |c| \n if c == '.'\n children = nodes.map do |node|\n node.children.values\n end.flatten.compact\n nodes = children\n else\n children = nodes.map do |node|\n node.children[c]\n end.compact\n return false if children.empty?\n nodes = children\n end\n end\n nodes.any?(&:is_end)\n end",
"def article_match? (query, article_title)\n found = false\n return true if query.empty?\n temp_article = article_title.downcase\n query.each do |kw|\n pattern = Regexp.new /.*#{kw.downcase}.*/\n found = true if temp_article =~ pattern\n end\n found\nend",
"def include?(searchstring, substring)\n\nend",
"def find_matching_parentheses(level, match_level)\n split_string.each_with_index do |c,i| \n if c == \"(\"\n match_level = level if i == @start_parentheses_position\n level += 1 \n elsif c == \")\"\n level -= 1\n return i + 1 if level == match_level && i >= @start_parentheses_position\n end\n end\n end",
"def strict_matching(ingredient_name,item)\n return item.downcase.include?(ingredient_name)\nend",
"def nested(string, first = 0, last = (string.length - 1))\n if string == \"\" || first > last #if first index is greater than the last, all () were checked, that is the base case. \n return true \n elsif (string.length % 2 != 0) \n return false \n elsif string[first] != \"(\" || string[last] != \")\"\n return false \n else \n return nested(string, first + 1, last - 1)\n end \nend",
"def nested(s)\n # return nested_helper(s[1..-1])\n paren_end = s.index(')')\n return !s.include?('(') if paren_end.nil? \n\n paren_start = s[0...paren_end].rindex('(')\n\n return false if paren_start.nil?\n\n return nested(s[1..paren_start]+s[paren_end+1..-1])\n\nend",
"def match_rawname(name, rawlist)\n rawlist.each { |r| return r if name == r }\n rawlist.each { |r| return r if name.downcase == r.downcase }\n may = rawlist.find_all { |r| r.downcase.index(name.downcase) }\n may.first if may.length == 1\n end",
"def match_rawname(name, rawlist)\n rawlist.each { |r| return r if name == r }\n rawlist.each { |r| return r if name.downcase == r.downcase }\n may = rawlist.find_all { |r| r.downcase.index(name.downcase) }\n may.first if may.length == 1\n end",
"def nested(s)\n if s == \"\"\n return true\n elsif (s.length % 2) != 0\n return false\n elsif s[0] == \"(\" && s[-1] == \")\"\n return nested(s[1..-2])\n end\n\n return false\nend",
"def nested(s)\n if s.length == 0\n return true\n else \n if s[0] == \"(\" && s[-1] == \")\"\n return nested(s[1..-2])\n else\n return false\n end\n end\nend",
"def match(p0) end",
"def match(p0) end",
"def nested(s, low = 0, high = s.length - 1)\n return false if s.length % 2 != 0\n \n if low >= high #base case\n return true\n elsif s[low] != '(' || s[high] != ')'\n return false\n else\n return nested(s, low + 1, high - 1)\n end\nend",
"def matches? (search)\n if (search.nil? || search == \"\")\n return true\n end\n search = search.gsub(/[^0-9a-z ]/i, '').downcase\n searches = search.split(' ')\n \n searches.each do |word|\n word += ' '\n title = self.title.nil? ? ' ' : self.title.gsub(/[^0-9a-z ]/i, '').downcase + ' '\n description = self.description.nil? ? ' ' : self.description.gsub(/[^0-9a-z ]/i, '').downcase + ' '\n venue_name = self.venue.name.nil? ? ' ' : self.venue.name.gsub(/[^0-9a-z ]/i, '').downcase + ' '\n if !(title.include?(word) || description.include?(word) || venue_name.include?(word))\n return false\n end\n end\n\n return true\n end",
"def nested(s)\n return true if s == \"\"\n return false if !s.include?(\"(\")\n return false if !s.include?(\")\")\n s.sub!(\"(\", \"\")\n s.sub!(\")\", \"\")\n return nested(s)\nend",
"def linear_search(input)\n \n search_name = input.downcase.split(' ')\n search_name.each do |name_el|\n \n entries.each do |entry|\n \n name_array = entry.name.downcase.split(' ')\n \n if name_array.include?(name_el)\n return entry\n end\n end\n end\n return nil\n end",
"def is_match_c(s, p, i = 0, j = 0, memo = {})\n return i == s.length if j == p.length\n return memo[[i,j]] if memo.has_key?([i,j])\n first = i < s.length && [s[i], '.'].include?(p[j])\n if p[j+1] == '*'\n is_match_c(s, p, i, j+2, memo) || (first && is_match_c(s, p, i+1, j, memo))\n else\n first && is_match_c(s, p, i+1, j+1, memo)\n end\nend",
"def nested(s)\n return true if s.empty?\n return false if s.length.odd?\n\n if (s[0] == \"(\" && s[-1] == \")\") && nested(s[1..-2])\n return true\n else\n return false\n end\nend",
"def is_match(s, p)\n m, n = s.length, p.length\n dp = Array.new(m+1) { Array.new(n+1, false) }\n dp[m][n] = true\n m.downto(0) do |i|\n (n-1).downto(0) do |j|\n first = i < m && (s[i] == p[j] || p[j] == '.')\n if p[j+1] == '*'\n dp[i][j] = dp[i][j+2] || (first && dp[i+1][j])\n else\n dp[i][j] = first && dp[i+1][j+1]\n end\n end\n end\n dp[0][0]\nend",
"def xpath_contains(node, selector, value)\n node.xpath(\"#{selector}//text()[contains(translate(., \\\"#{value.upcase}\\\", \\\"#{value}\\\"), \\\"#{value}\\\")]\")\n end",
"def match?(string)\n bigrams = get_bigrams(string)\n while bigrams.length > 1\n pair = bigrams.shift\n return true if bigrams[1..-1].include?(pair)\n end\nend",
"def nested(s)\n # if empty string, return true\n # if length == 1, return false\n # if left char == right char return false, if \"(()(\"\n # if left char != right char, return nested(s[1..-2])\n if s == \"\" # base case\n return true\n elsif s.length == 1 # base case\n return false\n elsif s[0] == s[-1] # base case\n return false\n else\n return nested(s[1..-2])\n end\n raise NotImplementedError, \"Method not implemented\"\nend",
"def ancestor_score\n return NULL_SCORE unless first_letter_match\n sub_word = \"#{reference}\" #dup\n chops = 0\n while sub_word != \"\" do\n chops += 1\n sub_word.chop!\n sub_ref = query[0..sub_word.length - 1]\n break if sub_word == sub_ref\n end\n\n score = ANCESTOR_SCORE / chops\n return score\n end",
"def nested(s)\n return true if s == \"\"\n return false if (s.length == 1 || s[0] != \"(\" || s[-1] != \")\" )\n return nested(s[1..-2])\nend",
"def exact_match?(name1:, name2:)\n return false unless name1.present? && name2.present?\n\n a = name_without_alias(name: name1.downcase)\n b = name_without_alias(name: name2.downcase)\n a == b\n end",
"def match?(name); end",
"def abbr_match?(str1, str2)\n build_middlename_regexp(str1) =~ str2\n end",
"def nested(s)\n if s == \"\"\n return true\n elsif s.length == 1 || s[0] != \"(\" || s[-1] != \")\"\n return false\n else\n return nested(s[1..-2])\n end\nend",
"def search(needle)\n tmp = @root\n needle.split(\"\").each do |char|\n if (tmp.childrens.key?(char))\n tmp = tmp.childrens[char]\n if (tmp.childrens.empty? && tmp.final == true)\n return true\n else\n return false\n end\n else\n return false\n end\n end\n end",
"def test_find_words_multiple\n words = ['apple','candy','bat']\n dict = Set['apple','bat','candy','cat']\n assert_equal Set[\"apple\",\"candy\"], @grapher.find_words(words, dict)\n end",
"def lab_check(word)\n if /lab/ =~ word\n puts word\n else\n puts \"no match\"\n end\nend",
"def matches_specs(text)\n text = text.downcase\n matches = false\n\n # some of Terri's terms were redundant so I removed them\n matches = true if text =~ /\\bsid|pakistan[.]* rendition|apartheid|apart[.]* regime|apart[.]* state|palestin[.]*/\n matches = true if text =~ /israel/ and text =~ /human rights violations/\n\n matches\nend",
"def nested(s)\n return true if s.empty?\n return nested(s[1..-2]) if s[0] == \"(\" && s[-1] == \")\"\n return false\nend",
"def bubble_up_exact_matches(result_list:, term:)\n exact_match = []\n matches_at_beginning = []\n matches_within = []\n other_items = []\n match_term = term.downcase\n result_list.each do |result_item|\n name = result_item[:title].downcase\n if name == match_term\n exact_match << result_item\n elsif name.start_with?(match_term)\n matches_at_beginning << result_item\n elsif name.include?(match_term)\n matches_within << result_item\n else\n other_items << result_item\n end\n end\n exact_match + matches_at_beginning + matches_within + other_items\n end",
"def myfind (str)\n if str.match(/^[[:graph:]]+$/) # name of the vaccine\n Vaccine.where(\"lower(name) like ?\", \"%#{str.downcase}%\")\n end\n end",
"def test_string_match\n s = \"a\"\n assert_equal(0, string_match(\"a\", s))\n assert_equal(0, string_match(/a/, s))\n assert_equal(0, string_match('\\(a\\|\\b\\)', s))\n assert_equal(0, string_match(/a|b/, s))\n assert_equal(0, string_match(/^a/, s))\n assert_equal(0, string_match(/a$/, s))\n assert_equal(0, string_match(/.*/, s))\n assert_equal(nil, string_match(/not-match/, s))\n \n end",
"def is_match(s, p)\n # . matches a single character\n # * matches any number of the preceding character including 0\n # match to the entire string\n\n # s can be empty, only lowercase\n # p can be empty, only lowercase, plus . and *\n\n return false if p[0] == '*'\n return false if p.length == 0\n\n left_i = 0\n left_j = 0\n\n i = p.length - 1\n j = s.length - 1\n\n while i >= 0\n run = false\n letter = p[i]\n\n if letter == '*'\n i -= 1\n letter = p[i]\n run = true\n end\n\n if run\n while (s[j] == letter || letter == '.') && j >= 0\n j -= 1\n end\n else\n return false if j == -1\n return false unless s[j] == letter || letter == '.'\n j -= 1\n end\n\n i -= 1\n end\n\n j == -1\n\nend",
"def check_in(word)\n\tif /lab/ =~ word\n\t\tputs word\n\telse\n\t\tputs \"No match\"\n\tend\nend",
"def match(array)\n array.select {|word| word.chars.sort.join == self.word.chars.sort.join}\n \n\nend",
"def nested(s)\n if s == \"\"\n return true\n end\n if s[0] != \"(\" || s[-1] != \")\"\n return false\n end\n return nested(s[1...-1])\nend",
"def test_slash_b_anchors_to_a_word_boundary\n assert_equal 'vines', \"bovine vines\"[/\\bvine./]\n end",
"def test_the_left_most_match_wins\n assert_equal \"a\", \"abbccc az\"[/az*/]\n end",
"def test_the_left_most_match_wins\n assert_equal \"a\", \"abbccc az\"[/az*/]\n end",
"def has_lab?(word)\n if /lab/.match(word)\n puts word\n else\n puts \"No match here.\"\n end\nend",
"def look_for_a_match(array)\n tree_match = false\n array.each do |x|\n (1...x.size).each do |i|\n if x[0] != x[i] || x[i] == \" \"\n return false\n end\n end\n return true\n end\n end",
"def match?(wordA, wordB)\n wordA == wordB.each_char.sort.join('') \nend",
"def search(word)\n current = @root\n word.chars.each do |c|\n current = current.siblings.find { |node| node.val == c }\n return false unless current\n end\n\n current.end\n end",
"def nested(s, low = 0, high = s.length - 1)\n if s.empty? || low >= high\n return true \n elsif s.length.odd?\n return false \n end \n\n return (s[low] == \"(\" && s[high] == \")\") && nested(s, low + 1, high - 1)\nend",
"def nested(s, low = 0, high = (s.length - 1))\n if s.length.odd?\n return false \n elsif low < high \n if s[low] != \"(\" && s[high] != \")\"\n return false \n end \n return nested(s, low + 1, high - 1)\n else \n return true \n end \nend",
"def match_text text\n @lookups.each do |rx_curr|\n return true if text =~ rx_curr\n end\n false\n end",
"def match(input); end",
"def starring(whazzername)\n # Find the movies with an actor who had a name like `whazzername`.\n # A name is like whazzername if the actor's name contains all of the\n # letters in whazzername, ignoring case, in order.\n\n # ex. \"Sylvester Stallone\" is like \"sylvester\" and \"lester stone\" but\n # not like \"stallone sylvester\" or \"zylvester ztallone\"\n\nend",
"def test_the_left_most_match_wins\n assert_equal 'a', \"abbccc az\"[/az*/]\n end"
] | [
"0.5746868",
"0.57285446",
"0.568868",
"0.5543908",
"0.5459666",
"0.5459211",
"0.54466236",
"0.5395936",
"0.5356025",
"0.5349556",
"0.5347985",
"0.5330886",
"0.53215265",
"0.53215265",
"0.5320119",
"0.52464145",
"0.5221318",
"0.5215134",
"0.51807195",
"0.51771665",
"0.51735073",
"0.51712644",
"0.5169822",
"0.5169666",
"0.5152047",
"0.51489943",
"0.5126636",
"0.5120437",
"0.5120204",
"0.511794",
"0.51145554",
"0.5114371",
"0.5104231",
"0.50990987",
"0.5080771",
"0.50712365",
"0.5058788",
"0.50428534",
"0.50344306",
"0.5025732",
"0.5025732",
"0.5025732",
"0.50251263",
"0.502355",
"0.5019503",
"0.5017233",
"0.50157493",
"0.50120103",
"0.50083905",
"0.5006109",
"0.5003177",
"0.5001941",
"0.49950084",
"0.49917728",
"0.49890637",
"0.49890637",
"0.4973771",
"0.49670836",
"0.49652928",
"0.49652928",
"0.49576843",
"0.49527067",
"0.49467975",
"0.49437276",
"0.4942558",
"0.49338812",
"0.49320006",
"0.49306175",
"0.4927781",
"0.49260178",
"0.49158624",
"0.49141145",
"0.49073285",
"0.49069697",
"0.48956662",
"0.48883832",
"0.48834535",
"0.48825133",
"0.48811573",
"0.48785898",
"0.4878324",
"0.48620516",
"0.48607525",
"0.4860062",
"0.48575255",
"0.48568448",
"0.48544145",
"0.48487514",
"0.48465216",
"0.48448756",
"0.48448756",
"0.48443857",
"0.4841433",
"0.4839122",
"0.48376724",
"0.48374748",
"0.48350018",
"0.4834863",
"0.48347566",
"0.4833553",
"0.4829955"
] | 0.0 | -1 |
TODO: nil/or clause this | def with_project_id
if project_id.present?
table[:project_id].eq_any(project_id)
else
nil
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def maybe so, maybe: self\n so\n end",
"def or_d\n end",
"def or_c\n end",
"def or_b\n end",
"def or_e\n end",
"def maybe so, maybe: self\n maybe\n end",
"def or_l\n end",
"def or_a\n end",
"def conditionally(*) end",
"def conditionally(*) end",
"def offences_by=(_arg0); end",
"def select; end",
"def select; end",
"def first?; end",
"def or(other)\n other\n end",
"def frame(criteria = T.unsafe(nil)); end",
"def or(other)\n if self && !self.nil?\n self\n else\n other\n end\n end",
"def maybe; end",
"def m_ar_or_chain_1\n Rows.where(:x || :y)\n end",
"def or( *args ); { $or => args } end",
"def multiple?; end",
"def or_h\n end",
"def or_hl\n end",
"def condition; end",
"def or_nil\n get_or_else(nil)\n end",
"def maybe\n self\n end",
"def conditions; end",
"def conditions; end",
"def optional; end",
"def private; end",
"def base(criteria = T.unsafe(nil)); end",
"def offences_by; end",
"def null?; false end",
"def select(*) end",
"def cond; end",
"def cond; end",
"def cond; end",
"def option(criteria = T.unsafe(nil)); end",
"def expr\n or_expr\n end",
"def anchored; end",
"def one_or_more\n -2\n end",
"def optional_positionals; end",
"def otherwise\n self\n end",
"def and_d\n end",
"def n_plus_one_query_enable=(_arg0); end",
"def multi?; end",
"def multi?; end",
"def first() end",
"def select_by(how, what); end",
"def first; end",
"def first; end",
"def any; end",
"def field(criteria = T.unsafe(nil)); end",
"def or_d8\n end",
"def semact?; false; end",
"def apply\n\t\t\n\tend",
"def apply\n\t\t\n\tend",
"def select_none; end",
"def probers; end",
"def where(input, property, target_value = T.unsafe(nil)); end",
"def right?; end",
"def whiny=(_arg0); end",
"def and_c\n end",
"def required_positionals; end",
"def result?; end",
"def hit_condition()\n #This is a stub, used for indexing\n end",
"def selected?; end",
"def selected?; end",
"def Filter=(arg0)",
"def union(lb)\n\n\n\n\n\n end",
"def and_e\n end",
"def probers=(_arg0); end",
"def query_def; (x = @hits.first) ? x.query_def : nil; end",
"def suivre; end",
"def maybe! so, maybe: -> { self }\n maybe.call\n end",
"def * other\n #This is a stub, used for indexing\n end",
"def operation; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def single?; false; end",
"def single?; false; end",
"def first_object(arg1, arg2, arg3)\n arg1 || arg2 || arg3 || nil\nend",
"def caar; first.first end",
"def restriction \n end",
"def mathtex(*)\n super\n end",
"def isolated?; end",
"def isolated?; end",
"def ignores; end",
"def or\n @conjuncted_restriction_type = :any_of\n @conjuncted_restriction = Restriction.new(@column)\n end",
"def restriction\n end",
"def and_l\n end",
"def statement; end",
"def rep\n rep ||= Person.where(\"title = ?\", \"Rep\")[0].id\nend",
"def |(parslet); end",
"def |(parslet); end",
"def select_one(sql, name = nil) end",
"def apply; nil; end",
"def child_condition; end",
"def qv\n end"
] | [
"0.6419483",
"0.6408589",
"0.62934476",
"0.617495",
"0.6129299",
"0.6068851",
"0.602242",
"0.59848434",
"0.58939224",
"0.58939224",
"0.5744425",
"0.57355857",
"0.57355857",
"0.5687191",
"0.56871563",
"0.5669496",
"0.5650502",
"0.56458306",
"0.56374633",
"0.56013143",
"0.557704",
"0.55556184",
"0.5554886",
"0.55243725",
"0.5506618",
"0.549112",
"0.5452333",
"0.5452333",
"0.5442704",
"0.54369855",
"0.54363805",
"0.5418374",
"0.53795165",
"0.53786683",
"0.5373877",
"0.5373877",
"0.5373877",
"0.5347181",
"0.5334847",
"0.5318219",
"0.5305408",
"0.5289924",
"0.5264638",
"0.5261445",
"0.5258561",
"0.52398574",
"0.52398574",
"0.5232032",
"0.52313066",
"0.52273643",
"0.52273643",
"0.52145094",
"0.52010834",
"0.5194415",
"0.51871765",
"0.5182935",
"0.5182935",
"0.5165627",
"0.5145382",
"0.5134897",
"0.512077",
"0.5113702",
"0.51136386",
"0.5110275",
"0.51079446",
"0.5096898",
"0.5087468",
"0.5087468",
"0.507768",
"0.5076499",
"0.5070642",
"0.5051128",
"0.5047305",
"0.50459594",
"0.5042576",
"0.5040393",
"0.5037949",
"0.5028235",
"0.5028235",
"0.5028235",
"0.5028235",
"0.5021371",
"0.5021371",
"0.5019707",
"0.5013386",
"0.5013128",
"0.50113845",
"0.500831",
"0.500831",
"0.50079334",
"0.50059414",
"0.4994662",
"0.49930623",
"0.49914378",
"0.49841395",
"0.49841243",
"0.49841243",
"0.49801606",
"0.49778944",
"0.49777",
"0.4975349"
] | 0.0 | -1 |
match ALL wildcards, but unordered, if 2 6 pieces provided | def match_wildcard_end_in_cached
table[:cached].matches(end_wildcard)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def match(pattern); end",
"def match(*list)\n @match.concat(makelist(list)) unless list.empty?\n @match\n end",
"def imatches_all others, escape = nil\n grouping_all :imatches, others, escape, escape\n end",
"def matches\n m = (1..9).map { |i| ss[i] }\n m.pop until m[-1] or m.empty?\n m\n end",
"def matches\n m = (1..9).map { |i| ss[i] }\n m.pop until m[-1] or m.empty?\n m\n end",
"def matches\n m = (1..9).map { |i| ss[i] }\n m.pop until m[-1] or m.empty?\n m\n end",
"def matches\n m = (1..9).map { |i| ss[i] }\n m.pop until m[-1] or m.empty?\n m\n end",
"def matches\n m = (1..9).map { |i| ss[i] }\n m.pop until m[-1] or m.empty?\n m\n end",
"def matches\n m = (1..9).map { |i| ss[i] }\n m.pop until m[-1] or m.empty?\n m\n end",
"def pre_match() end",
"def define_match_any_of\n klass.send(:define_method, :match_any_of) do |tags|\n if tags.empty?\n str(\"\")\n else\n tags.map { |tag| str(tag) }.inject do |tag_chain, tag|\n tag_chain.send :|, tag\n end\n end\n end\n end",
"def submatcher; end",
"def submatcher; end",
"def patterns; end",
"def matches(ext); end",
"def test_extended_patterns_no_flags\n [\n [ \".*\", \"abcd\\nefg\", \"abcd\" ],\n [ \"^a.\", \"abcd\\naefg\", \"ab\" ],\n [ \"^a.\", \"bacd\\naefg\", \"ae\" ],\n [ \".$\", \"bacd\\naefg\", \"d\" ]\n ].each do |reg, str, result|\n m = RustRegexp.new(reg).match(str)\n puts m.inspect\n unless m.nil?\n assert_equal result, m[0]\n end\n end\n end",
"def repeat_matcher *pattern\n submatcher = MatchWrapper.new(pattern_matcher(*pattern), SplatExpression)\n\n lambda do |string, index = 0, counts:|\n result = []\n\n while nonempty_match?(found = submatcher.call(string, index, counts: counts))\n index += found.size\n result.push(*found)\n end\n\n result unless result.empty?\n end\n end",
"def extract(pattern); end",
"def is_multimatch(s)\n return s.match(/[*?]/)\n end",
"def all_matches( re, what )\n matches = []\n m = true\n\n matches << OpenStruct.new({\n :match => \"!fake!\",\n :start => 0,\n :end => 0,\n :fake => true\n })\n\n while m\n if matches.size == 1\n m = what.match(re)\n else\n m = (@@allMatchesSpecialChar + what).match(re)\n end\n\n if m\n pos = what.index(m[0])\n\n if pos > 0\n matches << OpenStruct.new({\n :match => what[0, pos],\n :start => matches.last.end,\n :end => matches.last.end + pos,\n :plain => true\n })\n end\n\n matches << OpenStruct.new({\n :match => m[0],\n :start => matches.last.end,\n :end => matches.last.end + m[0].length\n })\n\n what = what[pos + m[0].length..-1]\n end\n end\n\n if what.length > 0\n matches << OpenStruct.new({\n :match => what,\n :start => matches.last.end,\n :end => matches.last.end + what.length,\n :plain => true\n })\n end\n\n matches\n end",
"def match(input); end",
"def matches(_ext); end",
"def matches(_ext); end",
"def globs_match_strings_anywhere? globs, strings\n while (!globs.empty? && !strings.empty? && \n globs.length <= strings.length)\n if globs_match_strings? globs, strings\n return true\n end\n strings.shift\n end\n\n return false\n end",
"def test_scan_is_like_find_all\n ##assert_equal __, \"one two-three\".scan(/\\w+/)\n assert_equal [\"one\", \"two\", \"three\"], \"one two-three\".scan(/\\w+/)\n end",
"def scan(pattern); end",
"def match(p0) end",
"def match(p0) end",
"def compound_match(fragments, target)\n match_set = fragments.map.with_index{|word, idx| [target.split(word), idx]}.select{|item| item[0].include?(\"\")}\n match_set = match_set.select{ |item| fragments.index(item.first&.last) != nil}\n index1 = match_set.first&.last\n index2 = fragments.index(match_set&.first&.first&.last) || nil\n return nil if index2.nil?\n\n if fragments[index1] + fragments[index2] == target\n if index1 < index2\n return [fragments[index1], fragments[index2], [index1, index2]]\n else\n return [fragments[index2], fragments[index1], [index1, index2]]\n end\n else\n if index1 < index2\n return [fragments[index1], fragments[index2], [index2, index1]]\n else\n return [fragments[index2], fragments[index1], [index2, index1]]\n end\n end\nend",
"def match; end",
"def match; end",
"def glob_match (filenames, pattern)\n\t# Escape the '*', '?', and '.' characters\n\tpattern.gsub!(/[\\*\\?\\.]/, '*' => '.*', '?' => '.', '.' => '\\.') \t\n\tregex = Regexp.new(pattern)\n\t#select returns a new array\n\tfilenames.select do |filename|\n\t\tfilename =~ regex\n\tend\nend",
"def methods_matching(re); end",
"def match a, pattern, out = {}\n return false if a.length != pattern.length\n pattern.length.times do |i|\n if pattern[i].class == Array\n if a[i].class == Array\n res = match a[i], pattern[i], out\n return false if not res\n else\n return pattern[i][0] == :op\n end\n else\n if not (pattern[i].class == Symbol or pattern[i].lower?) or\n pattern[i] == '_' or\n /\\$/.match(pattern[i])\n if out[pattern[i]] and pattern[i] != '_'\n return false if a[i] != out[pattern[i]]\n else\n out[pattern[i]] = a[i]\n end\n else\n return false if a[i] != pattern[i]\n end\n end\n end\n return out\nend",
"def matches?(pattern); end",
"def match(tokens, definitions)\n token_index = 0\n @pattern.each do |elements|\n was_optional = false\n elements = [elements] unless elements.is_a?(Array)\n\n elements.each_index do |i|\n name = elements[i].to_s\n optional = name[-1, 1] == '?'\n name = name.chop if optional\n\n case elements[i]\n when Symbol\n if tags_match?(name, tokens, token_index)\n token_index += 1\n break\n else\n if optional\n was_optional = true\n next\n elsif i + 1 < elements.count\n next\n else\n return false unless was_optional\n end\n end\n\n when String\n return true if optional && token_index == tokens.size\n\n if definitions.key?(name.to_sym)\n sub_handlers = definitions[name.to_sym]\n else\n raise \"Invalid subset #{name} specified\"\n end\n\n sub_handlers.each do |sub_handler|\n return true if sub_handler.match(tokens[token_index..tokens.size], definitions)\n end\n else\n raise \"Invalid match type: #{elements[i].class}\"\n end\n end\n\n end\n\n return false if token_index != tokens.size\n return true\n end",
"def match(path, *rest, &block); end",
"def fnmatch(matcher); end",
"def match_captures; end",
"def match(tokens, definitions); end",
"def on_match_pattern(node); end",
"def test_scan_is_like_find_all\n assert_equal [\"one\", \"two\", \"three\"], \"one two-three\".scan(/\\w+/)\n end",
"def test_scan_is_like_find_all\n assert_equal [\"one\", \"two\", \"three\"], \"one two-three\".scan(/\\w+/)\n end",
"def matching_lines(regex); end",
"def nonstrict_match(tokens)\n matchset = MatchSet.new()\n index = 0;\n tokens.each do |token|\n break unless pattern[index]\n tagger_name = pattern[index].to_s\n klass = constantize(tagger_name)\n match = token.has_tag?(klass) \n if match\n matchset << token.get_tag(klass);\n index += 1; \n next; \n else\n next\n end\n end\n\n return false if matchset.size != pattern.size\n return matchset\n end",
"def matching_sets(path, type); end",
"def split(pattern=$;, limit=0) end",
"def split(pattern=$;, limit=0) end",
"def expand_square(strings)\n # look for [...]\n out = [] \n strings.each do |string| \n string.match(/(.*)\\[([\\w\\d]*)\\](.*)/)\n\n pre = $1\n mid = $2\n post = $3\n\n if mid\n mid.split('').each do |opt|\n out.push \"#{pre || ''}#{opt}#{post}\"\n end\n end\n end\n\n out\n end",
"def split_arnd_0_1_n_find_matches(num_str=self.num)\n # split given number_string at 0's and 1's\n splits = num_str.gsub(/[^01]/, \"\").split(\"\")\n split_num_str = num_str.split(/[01]/)\n # obtain patterns for each sub_number_string\n split_results = split_num_str.map do |sub_num_str|\n find_all_matches(sub_num_str)\n end\n # obtain combined result\n combined_splits_and_split_results = []\n split_results.each_index do |index|\n combined_splits_and_split_results << split_results[index]\n combined_splits_and_split_results << [splits[index]] if index <= splits.length - 1\n end\n combined_splits_and_split_results.select!{ |x| x.length > 0 }\n results = self.class.concat_array_of_lists_of_strings(combined_splits_and_split_results)\n # join numbers togeter in each results element\n results.map!{ |str| self.class.join_numbers_together_in_str(str) }\n # set num_patterns\n self.num_patterns = results\n\n results\n end",
"def matches\n parse\n end",
"def test_scan_is_like_find_all\n assert_equal ['one', 'two', 'three'], \"one two-three\".scan(/\\w+/)\n end",
"def post_match() end",
"def regexps; end",
"def glob_match(filenames, pattern)\n\t\n\tnewPattern = pattern.gsub( '*', '.*').gsub( '?', '.')\n\n\treturn filenames.select{|i| i.match(/#{newPattern}/)}\n\t\nend",
"def matches(input)\n (0...input.length).reduce([]) do |memo, offset|\n memo + matches_at_offset(input, offset)\n end\n end",
"def match_wildcard_in_cached\n b = fragments\n return nil if b.empty?\n table[:cached].matches_all(b)\n end",
"def check_wildcards(e)\n # The quarter-final wildcard, if any, must be a Round 2B winner.\n # (And it must be an addition.)\n if round(:QuarterFinal) and (qfwc = round(:QuarterFinal).wildcard)\n e.unless (qfwc[1] == :added),\n \"Quarter final wildcard must be an _addition_\"\n e.unless (round(:Round2B).wins.include? qfwc[0]),\n \"Quarter final wildcard must be a Round 2B winner\"\n end\n # The Round 2A wildcard, if any, must be a Round 1 loser. (Must be :added)\n # If it exists, it must also exist in Round 2B.\n if round(:Round2A) and (r2awc = round(:Round2A).wildcard)\n e.unless (r2awc[1] == :added),\n \"Round 2A wildcard must be an _addition_\"\n e.unless (round(:Round1).losses.include? r2awc[0]),\n \"Round 2A wildcard must be a Round 1 loser\"\n end\n # The Round 2B wildcard, if any, must be the same as Round 2A, but :removed.\n if round(:Round2B) and (r2bwc = round(:Round2B).wildcard)\n e.unless (r2bwc[1] == :removed),\n \"Round 2B wildcard must be a _removal_\"\n if r2awc\n e.unless (r2awc[0] == r2bwc[0]),\n \"Round2B wildcard must be same school as Round2A wildcard\"\n else\n e.error \"Round2B wildcard exists but Round2A wildcard does not\"\n end\n end\n end",
"def super_match(*args)\n return unless match = match(args.first) \n returning match do |m|\n args[1..-1].each_with_index { |name, index| m.meta_def(name) { self[index+1] } }\n end\n end",
"def glob!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 7 )\n\n type = GLOB\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 42:5: ( '?' | '*' )+\n # at file 42:5: ( '?' | '*' )+\n match_count_12 = 0\n while true\n alt_12 = 2\n look_12_0 = @input.peek( 1 )\n\n if ( look_12_0 == 0x2a || look_12_0 == 0x3f )\n alt_12 = 1\n\n end\n case alt_12\n when 1\n # at line \n if @input.peek(1) == 0x2a || @input.peek(1) == 0x3f\n @input.consume\n else\n mse = MismatchedSet( nil )\n recover mse\n raise mse\n end\n\n\n\n else\n match_count_12 > 0 and break\n eee = EarlyExit(12)\n\n\n raise eee\n end\n match_count_12 += 1\n end\n\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 7 )\n\n end",
"def maybe_matcher *pattern\n submatcher = pattern_matcher(*pattern)\n\n lambda do |string, index = 0, counts:|\n found = submatcher.call(string, index, counts: counts)\n\n if match? found\n found\n else\n []\n end\n end\n end",
"def pre_match\n end",
"def compound_match(fragments, target)\r\n a = fragments.uniq.combination(2).find { |a, b| a + b == target || b + a == target }\r\n return unless a\r\n b = [fragments.index(a[0]), fragments.index(a[1])]\r\n [a[0], a[1], target.start_with?(a[0]) ? b : b.reverse]\r\n end",
"def process_match3(exp)\n right = exp.shift\n left = exp.shift \n return process(s(:call, left, :=~, s(:array, right)))\n end",
"def get_matching_for_pages(pattern:, pages:)\n pages.map {|page|\n uids = get_matching_for_page(pattern: pattern, page: page)\n uids.any? ?\n [ page['title'], uids ] :\n nil\n }.compact\nend",
"def primer_match (primer = \"\")\n match = \"\"\n primer.each_char.each do |base|\n base_array = to_list(base)\n if base_array.size == 1\n match += base_array[0]\n else\n pattern = \"[\" + base_array.join(\"|\") + \"]\"\n match += pattern\n end\n end\n return match\nend",
"def globs_match_strings? globs, strings\n globs.zip(strings).all? do |glob, string|\n File.fnmatch(glob, string)\n end\n end",
"def multireg(regpexp, str)\n result = []\n while regpexp.match(str)\n result.push regpexp.match(str)\n str = regpexp.match(str).post_match\n end\n result\n end",
"def process_globs(globs); end",
"def match(*strings)\n result = []\n @tags.each do |tag|\n strings.each do |string|\n if string.downcase =~ /#{tag.downcase}/\n strings.delete string\n result << tag\n break\n end\n end\n end\n return result\n end",
"def match(words)\n#iterate over the array of words that the .match method takes as an argument.\n words.select do |word|\n is_anagram?(word)\n end\n end",
"def match(regexp); end",
"def each_match_range(range, regex); end",
"def create_match(nominee)\n names = []\n pname = nominee[:name]\n names << pname\n names << pname.sub(%r{ [A-Z]\\. }, ' ') # drop initial\n personname = ASF::Person.find(nominee[:id]).public_name\n names << personname if personname\n list = names.uniq.map{|name| Regexp.escape(name)}.join('|')\n # N.B. \\b does not match if it follows ')', so won't match John (Fred)\n # TODO: Work-round is to also look for EOS, but this needs to be improved\n %r{\\b(#{list})(\\b|$)}i\nend",
"def bubble_up_exact_matches(affil_list:, term:)\n matches_at_beginning = []\n matches_within = []\n other_items = []\n match_term = term.downcase\n affil_list.each do |affil_item|\n name = affil_item[:name].downcase\n if name.start_with?(match_term)\n matches_at_beginning << affil_item\n elsif name.include?(match_term)\n matches_within << affil_item\n else\n other_items << affil_item\n end\n end\n matches_at_beginning + matches_within + other_items\n end",
"def split_sql(rest_of_query, *regexs)\n results = Array.new\n\n regexs.each do |regex|\n if position = (regex =~ rest_of_query)\n # Extract the matched string and chop the rest_of_query\n matched = rest_of_query[position..-1]\n rest_of_query = rest_of_query[0...position]\n else\n matched = nil\n end\n\n results << matched\n end\n results << rest_of_query\n\n results\n end",
"def glob_match(filenames, pattern)\n pattern = pattern.gsub(/[\\*\\?\\.]/, '*' => '.*', '.' => '\\.', '?' => '.')\n regex = Regexp.new(pattern)\n filenames.select do |filename|\n filename =~ regex\n end\nend",
"def matches(smarts_or_string, uniq=true)\n each_match(smarts_or_string, uniq).map.to_a\n end",
"def match(argv1)\n return nil unless argv1\n regex = %r{(?>\n Account[ ]disabled[ ]temporarly[ ]for[ ]exceeding[ ]receiving[ ]limits\n |account[ ]is[ ](?:\n exceeding[ ]their[ ]quota\n |over[ ]quota\n |temporarily[ ]over[ ]quota\n )\n |Boite[ ]du[ ]destinataire[ ]pleine.+[A-Z]{3}.+417\n |delivery[ ]failed:[ ]over[ ]quota\n |disc[ ]quota[ ]exceeded\n |does[ ]not[ ]have[ ]enough[ ]space\n |exceeded[ ]storage[ ]allocation\n |exceeding[ ]its[ ]mailbox[ ]quota\n |full[ ]mailbox\n |is[ ]over[ ](?:\n disk[ ]quota\n |quota[ ]temporarily\n )\n |mail[ ](?:\n file[ ]size[ ]exceeds[ ]the[ ]maximum[ ]size[ ]allowed[ ]for[ ]mail[ ]delivery\n |quota[ ]exceeded\n )\n |mailbox[ ](?:\n exceeded[ ]the[ ]local[ ]limit\n |full\n |has[ ]exceeded[ ]its[ ]disk[ ]space[ ]limit\n |is[ ]full\n |over[ ]quota\n |quota[ ]usage[ ]exceeded\n |size[ ]limit[ ]exceeded\n )\n |maildir[ ](?:\n delivery[ ]failed:[ ](?:User|Domain)disk[ ]quota[ ]?.*[ ]exceeded\n |over[ ]quota\n )\n |mailfolder[ ]is[ ]full\n |not[ ]enough[ ]storage[ ]space[ ]in\n |over[ ]the[ ]allowed[ ]quota\n |quota[ ](?:\n exceeded\n |violation[ ]for\n )\n |recipient[ ](?:\n reached[ ]disk[ ]quota\n |rejected:[ ]mailbox[ ]would[ ]exceed[ ]maximum[ ]allowed[ ]storage\n )\n |The[ ](?:\n recipient[ ]mailbox[ ]has[ ]exceeded[ ]its[ ]disk[ ]space[ ]limit\n |user[']s[ ]space[ ]has[ ]been[ ]used[ ]up\n |user[ ]you[ ]are[ ]trying[ ]to[ ]reach[ ]is[ ]over[ ]quota\n )\n |too[ ]much[ ]mail[ ]data # @docomo.ne.jp\n |user[ ](?:\n has[ ](?:\n exceeded[ ]quota,[ ]bouncing[ ]mail\n |too[ ]many[ ]messages[ ]on[ ]the[ ]server\n )\n |is[ ]over[ ](?:the[ ])?quota\n |over[ ]quota\n |over[ ]quota[.][ ][(][#]5[.]1[.]1[)] # qmail-toaster\n )\n |was[ ]automatically[ ]rejected:[ ]quota[ ]exceeded\n |would[ ]be[ ]over[ ]the[ ]allowed[ ]quota\n )\n }ix\n\n return true if argv1 =~ regex\n return false\n end",
"def any_wildcard?\n split.any? do |element|\n wildcard? element\n end\n end",
"def is_match_b(s, p, i = 0, j = 0)\n return i == s.length if j == p.length\n first = i < s.length && [s[i], '.'].include?(p[j])\n if p[j+1] == '*'\n is_match_b(s, p, i, j+2) || (first && is_match_b(s, p, i+1, j))\n else\n first && is_match_b(s, p, i+1, j+1)\n end\nend",
"def filterTutorials(x)\n x =~ %r{topics/.*/tutorials/.*/tutorial.*\\.md}\nend",
"def matches?( filts = [ ], incluv = nil )\n ret = nil\n\n self.mlim = (incluv.nil?) ? filts.length : 1\n self.add_mar\n\n if !self.val.str.empty?\n if filts.empty?\n ret = true\n\n else\n pos = 0\n\n if incluv.nil? # Strict.\n pattern_brackets = '\\W'\n match_mode = :strict\n else # Loose.\n pattern_brackets = '.*'\n match_mode = :loose\n end\n\n str_dc = (self.val.str.is_a?(String)) ? self.val.str.downcase : nil\n ttl_dc = (self.val.title.is_a?(String)) ? self.val.title.downcase : nil\n\n filts.each do |filt|\n filt_dc = filt.downcase\n regex = pattern_brackets + filt_dc + pattern_brackets\n\n if str_dc.is_a?(String) && ((str_dc == filt_dc) || (str_dc.match(regex)))\n mar = filt.length.to_f / self.val.str.length.to_f\n self.add_mar(pos, mar)\n else\n self.add_mar(pos)\n end\n\n if ttl_dc.is_a?(String) && ((ttl_dc == filt_dc) || (ttl_dc.match(regex)))\n mar = filt.length.to_f / self.val.title.length.to_f\n self.add_mar(pos, mar)\n end\n\n if !self.tags.pool.empty?\n self.tags.pool.each do |tag|\n test = (match_mode == :strict) ? filt : regex\n\n if tag.downcase.mode_match(match_mode, test)\n mar = filt.length.to_f / tag.length.to_f\n self.add_mar(pos, mar)\n else\n self.add_mar(pos)\n end\n end\n end\n\n pos += 1\n end\n\n if self.match_lim?(incluv)\n self.avg_mars!\n ret = true\n # puts \"mars: #{self.mars} // avgmar: #{self.mar} // val: (#{self.val.str})\"\n end\n end\n end\n\n return ret\n end",
"def filterTutorials(x)\n return x =~ /topics\\/.*\\/tutorials\\/.*\\/tutorial.*\\.md/\nend",
"def add_matching(pattern)\n self.class.glob(pattern).each do |fn|\n self << fn unless excluded_from_list?(fn)\n end\n end",
"def solve_two_vs_three_vs_five\n return if @arr[1].nil? || @arr[6].nil?\n\n #p \"1,6: #{@arr[1]},#{@arr[6]}\"\n\n @words.filter{|x| x.length == 5 && @hash[x].nil?}.each{|w|\n if @arr[1].chars.all?{|c| w.chars.include?(c)}\n solved(3, w)\n elsif w.chars.all?{|c2| @arr[6].chars.include?(c2)}\n solved(5, w)\n else\n solved(2, w)\n end\n }\n end",
"def match(tt)\n \ttt = \"#{tt}\"\n tt = tt.to_s.split(',')\n out = Cites.match(tt)\n puts out\n end",
"def has_subpattern_x?(s)\n return false if s.size == 1\n 0.upto(s.size-1) do |i|\n if s[i..-1].include?(s[0..i])\n rpp = s.size / s[0..i].size\n return true if s[0..i] * rpp == s\n else\n return false\n end\n end\nend",
"def expand_ic(xs, pattern)\n re1 = /\\A#{Regexp.quote(pattern)}/i\n result1 = xs.select {|x| x.name_match?(re1) }\n return [] if result1.empty?\n return result1 if result1.size == 1\n re2 = /\\A#{Regexp.quote(pattern)}\\z/i\n result2 = result1.select {|x| x.name_match?(re2) }\n return result1 if result2.empty?\n return result2 if result2.size == 1 # no mean\n result2\n end",
"def search pattern\n\t\tresults = all.map {|key|\n\t\t\tkey if key.to_s =~ /#{pattern}/i\n\t\t}\n\t\tresults.delete nil\n\t\tresults\n\tend",
"def queue_matches\n\n end",
"def reduce_anything(_production, _range, _tokens, _children)\n wildcard\n end",
"def find_all(name, prefix = T.unsafe(nil), partial = T.unsafe(nil), details = T.unsafe(nil), key = T.unsafe(nil), locals = T.unsafe(nil)); end",
"def matches(max_mismatches)\n out = []\n\n (0..text_len-patt_len).each do |i|\n out << i if quasi_match?(i, max_mismatches)\n end\n\n out\n end",
"def match_with(pattern)\n offset = 0\n conditions = [pattern]\n conditions << pattern[0..-2] if pattern != \"/\" && pattern.end_with?(\"/\")\n loop.with_object([]) do |_, candidacies|\n return candidacies unless conditions.any?{ |x| @regexps[offset] === x }\n route = @routes[offset..-1].detect{ |route| Regexp.last_match[\"_#{route.index}\"] }\n candidacies << route\n offset = route.index + 1\n end\n end",
"def pattern_matcher *pattern\n lambda do |string, index = 0, counts:|\n original_counts = counts.dup\n\n pattern.inject([]) do |memo, part|\n found = part.call(string, index, counts: counts)\n\n if match? found\n index += found.size\n memo.push(*found)\n else\n counts.replace(original_counts)\n return found\n end\n end\n end\n end",
"def match?(given_names); end",
"def match(array_of_words)\n matches = [] #Flag\n anagram_execute = anagram.split(//)\n anagram_execute = anagram_execute.sort!\n array_of_words.each do |possible_match|\n array_of_letters = possible_match.split(//)\n array_of_letters = array_of_letters.sort!\n matches << possible_match if array_of_letters == anagram_execute\n #use truncated, cleaner if statement\n end\n matches #return the matches array\n end",
"def great_matches\n filtered_matches(partial_or_perfect: [:family_name, :first_name], perfect: [:street, :city])\n end",
"def match=(_); end",
"def test_match()\r\n assert_equal(match([['direction', 'north']],'direction'), ['direction', 'north'])\r\n assert_equal(match([['direction', 'north']],'verb'), nil)\r\n\r\n test = ([['direction', 'north'], ['verb', 'go'], ['noun', 'bear']])\r\n assert_equal(match(test, 'direction'), ['direction', 'north'])\r\n assert_equal(test.length, 2) # checks that match is removing elements from the array\r\n assert_equal(match(test, 'verb'), ['verb', 'go'])\r\n assert_equal(test.length, 1)\r\n assert_equal(match(test, 'noun'), ['noun', 'bear'])\r\n\r\n test = ([['direction', 'north'], ['verb', 'go'], ['noun', 'bear']])\r\n assert_equal(match(test, 'verb'), nil)\r\n assert_equal(test.length, 2) # checks that match is removing elements from the array\r\n assert_equal(match(test, 'noun'), nil)\r\n assert_equal(test.length, 1)\r\n assert_equal(match(test, 'direction'), nil)\r\n # assert_equal(match([],'verb'), nil) # not sure how to test this\r\n end"
] | [
"0.61320627",
"0.59943676",
"0.5917876",
"0.5862174",
"0.5862174",
"0.5862174",
"0.5862174",
"0.5862174",
"0.5862174",
"0.5823603",
"0.58092517",
"0.5697889",
"0.5697889",
"0.56527233",
"0.5644001",
"0.5605667",
"0.5603727",
"0.55845654",
"0.5583268",
"0.55739975",
"0.5553339",
"0.554702",
"0.554702",
"0.5490484",
"0.54842526",
"0.54826176",
"0.5472916",
"0.5472916",
"0.5466981",
"0.54636127",
"0.54636127",
"0.5457699",
"0.5457146",
"0.5447103",
"0.54407066",
"0.5427888",
"0.54184234",
"0.53859824",
"0.53840846",
"0.53808194",
"0.5343095",
"0.5332381",
"0.5332381",
"0.5329504",
"0.5325371",
"0.5318303",
"0.53169155",
"0.53169155",
"0.53091043",
"0.53034306",
"0.53004736",
"0.5295285",
"0.5283508",
"0.5267457",
"0.52665854",
"0.52594733",
"0.5255392",
"0.5246085",
"0.52333975",
"0.5226155",
"0.52180856",
"0.5213845",
"0.5207889",
"0.52063465",
"0.51866454",
"0.51815975",
"0.51746124",
"0.5142824",
"0.51388305",
"0.513667",
"0.5135218",
"0.51177645",
"0.51164526",
"0.511615",
"0.511108",
"0.5103772",
"0.510355",
"0.5098436",
"0.5093759",
"0.5089058",
"0.50811136",
"0.5080084",
"0.50757086",
"0.5073866",
"0.50722116",
"0.5057738",
"0.5046121",
"0.5034612",
"0.50281584",
"0.5026823",
"0.5022846",
"0.5022721",
"0.5021205",
"0.5020189",
"0.50194293",
"0.5017463",
"0.5016443",
"0.5008502",
"0.50023365",
"0.50019306",
"0.49898383"
] | 0.0 | -1 |
match ALL wildcards, but unordered, if 2 6 pieces provided | def match_wildcard_in_cached
b = fragments
return nil if b.empty?
table[:cached].matches_all(b)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def match(pattern); end",
"def match(*list)\n @match.concat(makelist(list)) unless list.empty?\n @match\n end",
"def imatches_all others, escape = nil\n grouping_all :imatches, others, escape, escape\n end",
"def matches\n m = (1..9).map { |i| ss[i] }\n m.pop until m[-1] or m.empty?\n m\n end",
"def matches\n m = (1..9).map { |i| ss[i] }\n m.pop until m[-1] or m.empty?\n m\n end",
"def matches\n m = (1..9).map { |i| ss[i] }\n m.pop until m[-1] or m.empty?\n m\n end",
"def matches\n m = (1..9).map { |i| ss[i] }\n m.pop until m[-1] or m.empty?\n m\n end",
"def matches\n m = (1..9).map { |i| ss[i] }\n m.pop until m[-1] or m.empty?\n m\n end",
"def matches\n m = (1..9).map { |i| ss[i] }\n m.pop until m[-1] or m.empty?\n m\n end",
"def pre_match() end",
"def define_match_any_of\n klass.send(:define_method, :match_any_of) do |tags|\n if tags.empty?\n str(\"\")\n else\n tags.map { |tag| str(tag) }.inject do |tag_chain, tag|\n tag_chain.send :|, tag\n end\n end\n end\n end",
"def submatcher; end",
"def submatcher; end",
"def patterns; end",
"def matches(ext); end",
"def test_extended_patterns_no_flags\n [\n [ \".*\", \"abcd\\nefg\", \"abcd\" ],\n [ \"^a.\", \"abcd\\naefg\", \"ab\" ],\n [ \"^a.\", \"bacd\\naefg\", \"ae\" ],\n [ \".$\", \"bacd\\naefg\", \"d\" ]\n ].each do |reg, str, result|\n m = RustRegexp.new(reg).match(str)\n puts m.inspect\n unless m.nil?\n assert_equal result, m[0]\n end\n end\n end",
"def repeat_matcher *pattern\n submatcher = MatchWrapper.new(pattern_matcher(*pattern), SplatExpression)\n\n lambda do |string, index = 0, counts:|\n result = []\n\n while nonempty_match?(found = submatcher.call(string, index, counts: counts))\n index += found.size\n result.push(*found)\n end\n\n result unless result.empty?\n end\n end",
"def extract(pattern); end",
"def is_multimatch(s)\n return s.match(/[*?]/)\n end",
"def all_matches( re, what )\n matches = []\n m = true\n\n matches << OpenStruct.new({\n :match => \"!fake!\",\n :start => 0,\n :end => 0,\n :fake => true\n })\n\n while m\n if matches.size == 1\n m = what.match(re)\n else\n m = (@@allMatchesSpecialChar + what).match(re)\n end\n\n if m\n pos = what.index(m[0])\n\n if pos > 0\n matches << OpenStruct.new({\n :match => what[0, pos],\n :start => matches.last.end,\n :end => matches.last.end + pos,\n :plain => true\n })\n end\n\n matches << OpenStruct.new({\n :match => m[0],\n :start => matches.last.end,\n :end => matches.last.end + m[0].length\n })\n\n what = what[pos + m[0].length..-1]\n end\n end\n\n if what.length > 0\n matches << OpenStruct.new({\n :match => what,\n :start => matches.last.end,\n :end => matches.last.end + what.length,\n :plain => true\n })\n end\n\n matches\n end",
"def match(input); end",
"def matches(_ext); end",
"def matches(_ext); end",
"def globs_match_strings_anywhere? globs, strings\n while (!globs.empty? && !strings.empty? && \n globs.length <= strings.length)\n if globs_match_strings? globs, strings\n return true\n end\n strings.shift\n end\n\n return false\n end",
"def test_scan_is_like_find_all\n ##assert_equal __, \"one two-three\".scan(/\\w+/)\n assert_equal [\"one\", \"two\", \"three\"], \"one two-three\".scan(/\\w+/)\n end",
"def scan(pattern); end",
"def match(p0) end",
"def match(p0) end",
"def compound_match(fragments, target)\n match_set = fragments.map.with_index{|word, idx| [target.split(word), idx]}.select{|item| item[0].include?(\"\")}\n match_set = match_set.select{ |item| fragments.index(item.first&.last) != nil}\n index1 = match_set.first&.last\n index2 = fragments.index(match_set&.first&.first&.last) || nil\n return nil if index2.nil?\n\n if fragments[index1] + fragments[index2] == target\n if index1 < index2\n return [fragments[index1], fragments[index2], [index1, index2]]\n else\n return [fragments[index2], fragments[index1], [index1, index2]]\n end\n else\n if index1 < index2\n return [fragments[index1], fragments[index2], [index2, index1]]\n else\n return [fragments[index2], fragments[index1], [index2, index1]]\n end\n end\nend",
"def match; end",
"def match; end",
"def methods_matching(re); end",
"def glob_match (filenames, pattern)\n\t# Escape the '*', '?', and '.' characters\n\tpattern.gsub!(/[\\*\\?\\.]/, '*' => '.*', '?' => '.', '.' => '\\.') \t\n\tregex = Regexp.new(pattern)\n\t#select returns a new array\n\tfilenames.select do |filename|\n\t\tfilename =~ regex\n\tend\nend",
"def match a, pattern, out = {}\n return false if a.length != pattern.length\n pattern.length.times do |i|\n if pattern[i].class == Array\n if a[i].class == Array\n res = match a[i], pattern[i], out\n return false if not res\n else\n return pattern[i][0] == :op\n end\n else\n if not (pattern[i].class == Symbol or pattern[i].lower?) or\n pattern[i] == '_' or\n /\\$/.match(pattern[i])\n if out[pattern[i]] and pattern[i] != '_'\n return false if a[i] != out[pattern[i]]\n else\n out[pattern[i]] = a[i]\n end\n else\n return false if a[i] != pattern[i]\n end\n end\n end\n return out\nend",
"def matches?(pattern); end",
"def match(tokens, definitions)\n token_index = 0\n @pattern.each do |elements|\n was_optional = false\n elements = [elements] unless elements.is_a?(Array)\n\n elements.each_index do |i|\n name = elements[i].to_s\n optional = name[-1, 1] == '?'\n name = name.chop if optional\n\n case elements[i]\n when Symbol\n if tags_match?(name, tokens, token_index)\n token_index += 1\n break\n else\n if optional\n was_optional = true\n next\n elsif i + 1 < elements.count\n next\n else\n return false unless was_optional\n end\n end\n\n when String\n return true if optional && token_index == tokens.size\n\n if definitions.key?(name.to_sym)\n sub_handlers = definitions[name.to_sym]\n else\n raise \"Invalid subset #{name} specified\"\n end\n\n sub_handlers.each do |sub_handler|\n return true if sub_handler.match(tokens[token_index..tokens.size], definitions)\n end\n else\n raise \"Invalid match type: #{elements[i].class}\"\n end\n end\n\n end\n\n return false if token_index != tokens.size\n return true\n end",
"def match(path, *rest, &block); end",
"def fnmatch(matcher); end",
"def match_captures; end",
"def match(tokens, definitions); end",
"def on_match_pattern(node); end",
"def test_scan_is_like_find_all\n assert_equal [\"one\", \"two\", \"three\"], \"one two-three\".scan(/\\w+/)\n end",
"def test_scan_is_like_find_all\n assert_equal [\"one\", \"two\", \"three\"], \"one two-three\".scan(/\\w+/)\n end",
"def matching_lines(regex); end",
"def nonstrict_match(tokens)\n matchset = MatchSet.new()\n index = 0;\n tokens.each do |token|\n break unless pattern[index]\n tagger_name = pattern[index].to_s\n klass = constantize(tagger_name)\n match = token.has_tag?(klass) \n if match\n matchset << token.get_tag(klass);\n index += 1; \n next; \n else\n next\n end\n end\n\n return false if matchset.size != pattern.size\n return matchset\n end",
"def matching_sets(path, type); end",
"def split(pattern=$;, limit=0) end",
"def split(pattern=$;, limit=0) end",
"def expand_square(strings)\n # look for [...]\n out = [] \n strings.each do |string| \n string.match(/(.*)\\[([\\w\\d]*)\\](.*)/)\n\n pre = $1\n mid = $2\n post = $3\n\n if mid\n mid.split('').each do |opt|\n out.push \"#{pre || ''}#{opt}#{post}\"\n end\n end\n end\n\n out\n end",
"def split_arnd_0_1_n_find_matches(num_str=self.num)\n # split given number_string at 0's and 1's\n splits = num_str.gsub(/[^01]/, \"\").split(\"\")\n split_num_str = num_str.split(/[01]/)\n # obtain patterns for each sub_number_string\n split_results = split_num_str.map do |sub_num_str|\n find_all_matches(sub_num_str)\n end\n # obtain combined result\n combined_splits_and_split_results = []\n split_results.each_index do |index|\n combined_splits_and_split_results << split_results[index]\n combined_splits_and_split_results << [splits[index]] if index <= splits.length - 1\n end\n combined_splits_and_split_results.select!{ |x| x.length > 0 }\n results = self.class.concat_array_of_lists_of_strings(combined_splits_and_split_results)\n # join numbers togeter in each results element\n results.map!{ |str| self.class.join_numbers_together_in_str(str) }\n # set num_patterns\n self.num_patterns = results\n\n results\n end",
"def matches\n parse\n end",
"def test_scan_is_like_find_all\n assert_equal ['one', 'two', 'three'], \"one two-three\".scan(/\\w+/)\n end",
"def post_match() end",
"def regexps; end",
"def glob_match(filenames, pattern)\n\t\n\tnewPattern = pattern.gsub( '*', '.*').gsub( '?', '.')\n\n\treturn filenames.select{|i| i.match(/#{newPattern}/)}\n\t\nend",
"def matches(input)\n (0...input.length).reduce([]) do |memo, offset|\n memo + matches_at_offset(input, offset)\n end\n end",
"def check_wildcards(e)\n # The quarter-final wildcard, if any, must be a Round 2B winner.\n # (And it must be an addition.)\n if round(:QuarterFinal) and (qfwc = round(:QuarterFinal).wildcard)\n e.unless (qfwc[1] == :added),\n \"Quarter final wildcard must be an _addition_\"\n e.unless (round(:Round2B).wins.include? qfwc[0]),\n \"Quarter final wildcard must be a Round 2B winner\"\n end\n # The Round 2A wildcard, if any, must be a Round 1 loser. (Must be :added)\n # If it exists, it must also exist in Round 2B.\n if round(:Round2A) and (r2awc = round(:Round2A).wildcard)\n e.unless (r2awc[1] == :added),\n \"Round 2A wildcard must be an _addition_\"\n e.unless (round(:Round1).losses.include? r2awc[0]),\n \"Round 2A wildcard must be a Round 1 loser\"\n end\n # The Round 2B wildcard, if any, must be the same as Round 2A, but :removed.\n if round(:Round2B) and (r2bwc = round(:Round2B).wildcard)\n e.unless (r2bwc[1] == :removed),\n \"Round 2B wildcard must be a _removal_\"\n if r2awc\n e.unless (r2awc[0] == r2bwc[0]),\n \"Round2B wildcard must be same school as Round2A wildcard\"\n else\n e.error \"Round2B wildcard exists but Round2A wildcard does not\"\n end\n end\n end",
"def super_match(*args)\n return unless match = match(args.first) \n returning match do |m|\n args[1..-1].each_with_index { |name, index| m.meta_def(name) { self[index+1] } }\n end\n end",
"def glob!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 7 )\n\n type = GLOB\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 42:5: ( '?' | '*' )+\n # at file 42:5: ( '?' | '*' )+\n match_count_12 = 0\n while true\n alt_12 = 2\n look_12_0 = @input.peek( 1 )\n\n if ( look_12_0 == 0x2a || look_12_0 == 0x3f )\n alt_12 = 1\n\n end\n case alt_12\n when 1\n # at line \n if @input.peek(1) == 0x2a || @input.peek(1) == 0x3f\n @input.consume\n else\n mse = MismatchedSet( nil )\n recover mse\n raise mse\n end\n\n\n\n else\n match_count_12 > 0 and break\n eee = EarlyExit(12)\n\n\n raise eee\n end\n match_count_12 += 1\n end\n\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 7 )\n\n end",
"def maybe_matcher *pattern\n submatcher = pattern_matcher(*pattern)\n\n lambda do |string, index = 0, counts:|\n found = submatcher.call(string, index, counts: counts)\n\n if match? found\n found\n else\n []\n end\n end\n end",
"def pre_match\n end",
"def compound_match(fragments, target)\r\n a = fragments.uniq.combination(2).find { |a, b| a + b == target || b + a == target }\r\n return unless a\r\n b = [fragments.index(a[0]), fragments.index(a[1])]\r\n [a[0], a[1], target.start_with?(a[0]) ? b : b.reverse]\r\n end",
"def process_match3(exp)\n right = exp.shift\n left = exp.shift \n return process(s(:call, left, :=~, s(:array, right)))\n end",
"def get_matching_for_pages(pattern:, pages:)\n pages.map {|page|\n uids = get_matching_for_page(pattern: pattern, page: page)\n uids.any? ?\n [ page['title'], uids ] :\n nil\n }.compact\nend",
"def primer_match (primer = \"\")\n match = \"\"\n primer.each_char.each do |base|\n base_array = to_list(base)\n if base_array.size == 1\n match += base_array[0]\n else\n pattern = \"[\" + base_array.join(\"|\") + \"]\"\n match += pattern\n end\n end\n return match\nend",
"def globs_match_strings? globs, strings\n globs.zip(strings).all? do |glob, string|\n File.fnmatch(glob, string)\n end\n end",
"def multireg(regpexp, str)\n result = []\n while regpexp.match(str)\n result.push regpexp.match(str)\n str = regpexp.match(str).post_match\n end\n result\n end",
"def process_globs(globs); end",
"def match(*strings)\n result = []\n @tags.each do |tag|\n strings.each do |string|\n if string.downcase =~ /#{tag.downcase}/\n strings.delete string\n result << tag\n break\n end\n end\n end\n return result\n end",
"def match(words)\n#iterate over the array of words that the .match method takes as an argument.\n words.select do |word|\n is_anagram?(word)\n end\n end",
"def match(regexp); end",
"def each_match_range(range, regex); end",
"def create_match(nominee)\n names = []\n pname = nominee[:name]\n names << pname\n names << pname.sub(%r{ [A-Z]\\. }, ' ') # drop initial\n personname = ASF::Person.find(nominee[:id]).public_name\n names << personname if personname\n list = names.uniq.map{|name| Regexp.escape(name)}.join('|')\n # N.B. \\b does not match if it follows ')', so won't match John (Fred)\n # TODO: Work-round is to also look for EOS, but this needs to be improved\n %r{\\b(#{list})(\\b|$)}i\nend",
"def bubble_up_exact_matches(affil_list:, term:)\n matches_at_beginning = []\n matches_within = []\n other_items = []\n match_term = term.downcase\n affil_list.each do |affil_item|\n name = affil_item[:name].downcase\n if name.start_with?(match_term)\n matches_at_beginning << affil_item\n elsif name.include?(match_term)\n matches_within << affil_item\n else\n other_items << affil_item\n end\n end\n matches_at_beginning + matches_within + other_items\n end",
"def glob_match(filenames, pattern)\n pattern = pattern.gsub(/[\\*\\?\\.]/, '*' => '.*', '.' => '\\.', '?' => '.')\n regex = Regexp.new(pattern)\n filenames.select do |filename|\n filename =~ regex\n end\nend",
"def split_sql(rest_of_query, *regexs)\n results = Array.new\n\n regexs.each do |regex|\n if position = (regex =~ rest_of_query)\n # Extract the matched string and chop the rest_of_query\n matched = rest_of_query[position..-1]\n rest_of_query = rest_of_query[0...position]\n else\n matched = nil\n end\n\n results << matched\n end\n results << rest_of_query\n\n results\n end",
"def matches(smarts_or_string, uniq=true)\n each_match(smarts_or_string, uniq).map.to_a\n end",
"def match(argv1)\n return nil unless argv1\n regex = %r{(?>\n Account[ ]disabled[ ]temporarly[ ]for[ ]exceeding[ ]receiving[ ]limits\n |account[ ]is[ ](?:\n exceeding[ ]their[ ]quota\n |over[ ]quota\n |temporarily[ ]over[ ]quota\n )\n |Boite[ ]du[ ]destinataire[ ]pleine.+[A-Z]{3}.+417\n |delivery[ ]failed:[ ]over[ ]quota\n |disc[ ]quota[ ]exceeded\n |does[ ]not[ ]have[ ]enough[ ]space\n |exceeded[ ]storage[ ]allocation\n |exceeding[ ]its[ ]mailbox[ ]quota\n |full[ ]mailbox\n |is[ ]over[ ](?:\n disk[ ]quota\n |quota[ ]temporarily\n )\n |mail[ ](?:\n file[ ]size[ ]exceeds[ ]the[ ]maximum[ ]size[ ]allowed[ ]for[ ]mail[ ]delivery\n |quota[ ]exceeded\n )\n |mailbox[ ](?:\n exceeded[ ]the[ ]local[ ]limit\n |full\n |has[ ]exceeded[ ]its[ ]disk[ ]space[ ]limit\n |is[ ]full\n |over[ ]quota\n |quota[ ]usage[ ]exceeded\n |size[ ]limit[ ]exceeded\n )\n |maildir[ ](?:\n delivery[ ]failed:[ ](?:User|Domain)disk[ ]quota[ ]?.*[ ]exceeded\n |over[ ]quota\n )\n |mailfolder[ ]is[ ]full\n |not[ ]enough[ ]storage[ ]space[ ]in\n |over[ ]the[ ]allowed[ ]quota\n |quota[ ](?:\n exceeded\n |violation[ ]for\n )\n |recipient[ ](?:\n reached[ ]disk[ ]quota\n |rejected:[ ]mailbox[ ]would[ ]exceed[ ]maximum[ ]allowed[ ]storage\n )\n |The[ ](?:\n recipient[ ]mailbox[ ]has[ ]exceeded[ ]its[ ]disk[ ]space[ ]limit\n |user[']s[ ]space[ ]has[ ]been[ ]used[ ]up\n |user[ ]you[ ]are[ ]trying[ ]to[ ]reach[ ]is[ ]over[ ]quota\n )\n |too[ ]much[ ]mail[ ]data # @docomo.ne.jp\n |user[ ](?:\n has[ ](?:\n exceeded[ ]quota,[ ]bouncing[ ]mail\n |too[ ]many[ ]messages[ ]on[ ]the[ ]server\n )\n |is[ ]over[ ](?:the[ ])?quota\n |over[ ]quota\n |over[ ]quota[.][ ][(][#]5[.]1[.]1[)] # qmail-toaster\n )\n |was[ ]automatically[ ]rejected:[ ]quota[ ]exceeded\n |would[ ]be[ ]over[ ]the[ ]allowed[ ]quota\n )\n }ix\n\n return true if argv1 =~ regex\n return false\n end",
"def any_wildcard?\n split.any? do |element|\n wildcard? element\n end\n end",
"def is_match_b(s, p, i = 0, j = 0)\n return i == s.length if j == p.length\n first = i < s.length && [s[i], '.'].include?(p[j])\n if p[j+1] == '*'\n is_match_b(s, p, i, j+2) || (first && is_match_b(s, p, i+1, j))\n else\n first && is_match_b(s, p, i+1, j+1)\n end\nend",
"def filterTutorials(x)\n x =~ %r{topics/.*/tutorials/.*/tutorial.*\\.md}\nend",
"def matches?( filts = [ ], incluv = nil )\n ret = nil\n\n self.mlim = (incluv.nil?) ? filts.length : 1\n self.add_mar\n\n if !self.val.str.empty?\n if filts.empty?\n ret = true\n\n else\n pos = 0\n\n if incluv.nil? # Strict.\n pattern_brackets = '\\W'\n match_mode = :strict\n else # Loose.\n pattern_brackets = '.*'\n match_mode = :loose\n end\n\n str_dc = (self.val.str.is_a?(String)) ? self.val.str.downcase : nil\n ttl_dc = (self.val.title.is_a?(String)) ? self.val.title.downcase : nil\n\n filts.each do |filt|\n filt_dc = filt.downcase\n regex = pattern_brackets + filt_dc + pattern_brackets\n\n if str_dc.is_a?(String) && ((str_dc == filt_dc) || (str_dc.match(regex)))\n mar = filt.length.to_f / self.val.str.length.to_f\n self.add_mar(pos, mar)\n else\n self.add_mar(pos)\n end\n\n if ttl_dc.is_a?(String) && ((ttl_dc == filt_dc) || (ttl_dc.match(regex)))\n mar = filt.length.to_f / self.val.title.length.to_f\n self.add_mar(pos, mar)\n end\n\n if !self.tags.pool.empty?\n self.tags.pool.each do |tag|\n test = (match_mode == :strict) ? filt : regex\n\n if tag.downcase.mode_match(match_mode, test)\n mar = filt.length.to_f / tag.length.to_f\n self.add_mar(pos, mar)\n else\n self.add_mar(pos)\n end\n end\n end\n\n pos += 1\n end\n\n if self.match_lim?(incluv)\n self.avg_mars!\n ret = true\n # puts \"mars: #{self.mars} // avgmar: #{self.mar} // val: (#{self.val.str})\"\n end\n end\n end\n\n return ret\n end",
"def filterTutorials(x)\n return x =~ /topics\\/.*\\/tutorials\\/.*\\/tutorial.*\\.md/\nend",
"def add_matching(pattern)\n self.class.glob(pattern).each do |fn|\n self << fn unless excluded_from_list?(fn)\n end\n end",
"def solve_two_vs_three_vs_five\n return if @arr[1].nil? || @arr[6].nil?\n\n #p \"1,6: #{@arr[1]},#{@arr[6]}\"\n\n @words.filter{|x| x.length == 5 && @hash[x].nil?}.each{|w|\n if @arr[1].chars.all?{|c| w.chars.include?(c)}\n solved(3, w)\n elsif w.chars.all?{|c2| @arr[6].chars.include?(c2)}\n solved(5, w)\n else\n solved(2, w)\n end\n }\n end",
"def match(tt)\n \ttt = \"#{tt}\"\n tt = tt.to_s.split(',')\n out = Cites.match(tt)\n puts out\n end",
"def has_subpattern_x?(s)\n return false if s.size == 1\n 0.upto(s.size-1) do |i|\n if s[i..-1].include?(s[0..i])\n rpp = s.size / s[0..i].size\n return true if s[0..i] * rpp == s\n else\n return false\n end\n end\nend",
"def search pattern\n\t\tresults = all.map {|key|\n\t\t\tkey if key.to_s =~ /#{pattern}/i\n\t\t}\n\t\tresults.delete nil\n\t\tresults\n\tend",
"def expand_ic(xs, pattern)\n re1 = /\\A#{Regexp.quote(pattern)}/i\n result1 = xs.select {|x| x.name_match?(re1) }\n return [] if result1.empty?\n return result1 if result1.size == 1\n re2 = /\\A#{Regexp.quote(pattern)}\\z/i\n result2 = result1.select {|x| x.name_match?(re2) }\n return result1 if result2.empty?\n return result2 if result2.size == 1 # no mean\n result2\n end",
"def reduce_anything(_production, _range, _tokens, _children)\n wildcard\n end",
"def queue_matches\n\n end",
"def find_all(name, prefix = T.unsafe(nil), partial = T.unsafe(nil), details = T.unsafe(nil), key = T.unsafe(nil), locals = T.unsafe(nil)); end",
"def match_with(pattern)\n offset = 0\n conditions = [pattern]\n conditions << pattern[0..-2] if pattern != \"/\" && pattern.end_with?(\"/\")\n loop.with_object([]) do |_, candidacies|\n return candidacies unless conditions.any?{ |x| @regexps[offset] === x }\n route = @routes[offset..-1].detect{ |route| Regexp.last_match[\"_#{route.index}\"] }\n candidacies << route\n offset = route.index + 1\n end\n end",
"def matches(max_mismatches)\n out = []\n\n (0..text_len-patt_len).each do |i|\n out << i if quasi_match?(i, max_mismatches)\n end\n\n out\n end",
"def match?(given_names); end",
"def pattern_matcher *pattern\n lambda do |string, index = 0, counts:|\n original_counts = counts.dup\n\n pattern.inject([]) do |memo, part|\n found = part.call(string, index, counts: counts)\n\n if match? found\n index += found.size\n memo.push(*found)\n else\n counts.replace(original_counts)\n return found\n end\n end\n end\n end",
"def match(array_of_words)\n matches = [] #Flag\n anagram_execute = anagram.split(//)\n anagram_execute = anagram_execute.sort!\n array_of_words.each do |possible_match|\n array_of_letters = possible_match.split(//)\n array_of_letters = array_of_letters.sort!\n matches << possible_match if array_of_letters == anagram_execute\n #use truncated, cleaner if statement\n end\n matches #return the matches array\n end",
"def match=(_); end",
"def great_matches\n filtered_matches(partial_or_perfect: [:family_name, :first_name], perfect: [:street, :city])\n end",
"def test_match()\r\n assert_equal(match([['direction', 'north']],'direction'), ['direction', 'north'])\r\n assert_equal(match([['direction', 'north']],'verb'), nil)\r\n\r\n test = ([['direction', 'north'], ['verb', 'go'], ['noun', 'bear']])\r\n assert_equal(match(test, 'direction'), ['direction', 'north'])\r\n assert_equal(test.length, 2) # checks that match is removing elements from the array\r\n assert_equal(match(test, 'verb'), ['verb', 'go'])\r\n assert_equal(test.length, 1)\r\n assert_equal(match(test, 'noun'), ['noun', 'bear'])\r\n\r\n test = ([['direction', 'north'], ['verb', 'go'], ['noun', 'bear']])\r\n assert_equal(match(test, 'verb'), nil)\r\n assert_equal(test.length, 2) # checks that match is removing elements from the array\r\n assert_equal(match(test, 'noun'), nil)\r\n assert_equal(test.length, 1)\r\n assert_equal(match(test, 'direction'), nil)\r\n # assert_equal(match([],'verb'), nil) # not sure how to test this\r\n end"
] | [
"0.61340636",
"0.5994068",
"0.5918028",
"0.58611745",
"0.58611745",
"0.58611745",
"0.58611745",
"0.58611745",
"0.58611745",
"0.582654",
"0.5809954",
"0.56997716",
"0.56997716",
"0.5654367",
"0.5645336",
"0.56065375",
"0.5602922",
"0.55860627",
"0.55830467",
"0.5574353",
"0.5555407",
"0.55484766",
"0.55484766",
"0.5489811",
"0.5485312",
"0.5484828",
"0.5474958",
"0.5474958",
"0.5466378",
"0.5465763",
"0.5465763",
"0.5458861",
"0.5458405",
"0.5447278",
"0.5441795",
"0.54287213",
"0.5420495",
"0.53878534",
"0.53854173",
"0.5383146",
"0.5345717",
"0.5333351",
"0.5333351",
"0.53306323",
"0.5325955",
"0.5320036",
"0.53165424",
"0.53165424",
"0.53073967",
"0.53023535",
"0.53023505",
"0.52961856",
"0.5286034",
"0.52690387",
"0.5267204",
"0.5258268",
"0.5248585",
"0.5234591",
"0.522787",
"0.52175075",
"0.5216373",
"0.5207635",
"0.5206009",
"0.51871413",
"0.51812285",
"0.5174146",
"0.5141313",
"0.5139614",
"0.51360697",
"0.5135326",
"0.51197",
"0.51177186",
"0.5117142",
"0.51115865",
"0.51041615",
"0.510344",
"0.5097403",
"0.5094893",
"0.5089737",
"0.50815916",
"0.5081527",
"0.5077212",
"0.507523",
"0.5073177",
"0.50574905",
"0.5046817",
"0.5033481",
"0.5028158",
"0.5028014",
"0.5024581",
"0.5022981",
"0.5022663",
"0.5019684",
"0.50188684",
"0.5017678",
"0.50175387",
"0.5007134",
"0.50041664",
"0.50038195",
"0.49895516"
] | 0.5256435 | 56 |
Autocomplete !! All methods must return nil of a scope | def autocomplete
all.to_a
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def autocomplete; end",
"def auto_complete\n @query = params[:auto_complete_query]\n @auto_complete = self.controller_name.classify.constantize.scoped(:limit => 10).search(@query)\n render :template => \"common/auto_complete\", :layout => nil\n end",
"def findorsuggest()\n \n end",
"def auto_complete\n @query = params[:term] || ''\n @auto_complete = hook(:auto_complete, self, query: @query, user: current_user)\n if @auto_complete.empty?\n exclude_ids = auto_complete_ids_to_exclude(params[:related])\n @auto_complete = klass.my(current_user).text_search(@query).ransack(id_not_in: exclude_ids).result.limit(10)\n else\n @auto_complete = @auto_complete.last\n end\n\n session[:auto_complete] = controller_name.to_sym\n respond_to do |format|\n format.any(:js, :html) { render partial: 'auto_complete' }\n format.json do\n results = @auto_complete.map do |a|\n {\n id: a.id,\n text: a.respond_to?(:full_name) ? a.full_name : a.name\n }\n end\n render json: {\n results: results\n }\n end\n end\n end",
"def autocomplete?\n true\n end",
"def auto_complete_for_keyword_list\n auto_complete_responder_for_keyword params[:keyword][:list]\n end",
"def get_autocomplete_items(parameters)\n super(parameters).active rescue nil\n end",
"def auto_complete\n type = params[:type].to_s\n string = CGI.unescape(params[:id].to_s).strip_squeeze\n if string.blank?\n render(text: \"\\n\\n\")\n else\n auto = AutoComplete.subclass(type).new(string, params)\n results = auto.matching_strings.join(\"\\n\") + \"\\n\"\n render(text: results)\n end\n end",
"def get_autocomplete_items(parameters)\r\n super(parameters).active rescue nil\r\n end",
"def get_autocomplete_items(parameters)\r\n super(parameters).active rescue nil\r\n end",
"def get_autocomplete_items(parameters)\r\n super(parameters).active rescue nil\r\n end",
"def auto_complete(editor)\n editor.cursor.read do |word|\n sword = word.to_sym \n if word == \"\\n\"\n throw :eol\n elsif editor.template.user_classes.include?(sword)\n build_suggestion(Editor.const_get(word).methods)\n elsif editor.template.context.methods.include?(sword)\n build_suggestion(editor.template.context.method(sword).parameters)\n end\n\tend\nend",
"def autocomplete_name\n @tags = Tag.where([\"name ILIKE ?\", \"*#{params[:term]}*\".to_escaped_for_sql_like]).order('LENGTH(name)', :name).limit(20).pluck(:name)\n respond_to do |format|\n format.json { render :json => @tags }\n end\n end",
"def suggest\n end",
"def auto_complete\n @users = if params[:term] =~ /(@[^\\s]+)\\s.*/\n elsif user_name = params[:term].match(/(@[^\\s]+)/)\n users = User.select('name').where('name LIKE ?', \"%#{user_name[1].to_s[1..-1]}%\")\n\n users.map {|user| {name: \"#@{user.name}\"} }\n end\n render json: @users.to_json\n end",
"def getAutocomplete(query, type)\n request('getAutocomplete', {'query' => query, 'type' => type})\nend",
"def autocomplete(name)\n self.class.get(\"/cards/autocomplete?q=#{name}\")\n end",
"def auto_complete_for_user_name\n @users = session[:user].get_available_users(params[:user][:name])\n render inline: \"<%= auto_complete_result @users, 'name' %>\", layout: false\n end",
"def auto_complete(controller, context = {})\n query, tags = parse_query_and_tags(context[:query])\n klass = controller.controller_name.classify.constantize\n if tags.empty?\n klass.my(:user => context[:user], :limit => 10).search(query)\n else\n klass.my(:user => context[:user], :limit => 10).search(query).tagged_with(tags, :on => :tags)\n end\n end",
"def auto_complete_for_ces\r\n value = params[:term]\r\n field = %w(collectors locality mthd verbatim_method macro_habitat micro_habitat).include?(params[:field]) && params[:field]\r\n\r\n if field && value\r\n @ids = Ce.select(field.downcase).where([ \"ces.proj_id = ? AND LOWER(ces.#{field.downcase}) LIKE (?)\", params[:proj_id], '%' + value.downcase + '%' ])\r\n .group(field.downcase).order(\"#{field.downcase} ASC\").limit(100).map {|v| v.send(field.downcase.to_sym)}\r\n\r\n render :json => Json::simple_autocomplete(@ids)\r\n elsif value\r\n @ces = Ce.find_for_auto_complete(value)\r\n render :json => Json::format_for_autocomplete_with_display_name(:entries => @ces, :method => params[:method])\r\n else\r\n head(:bad_request)\r\n end\r\n end",
"def autocomplete\r\n# return '' unless session[:edit_mode] > 0 # \r\n return render text: t('drgcms.not_authorized') unless dc_user_can(DcPermission::CAN_VIEW)\r\n# TODO Double check if previous line works as it should.\r\n table = params['table'].classify.constantize\r\n id = [params['id']] || '_id'\r\n# call method in class if search parameter has . This is for user defined searches\r\n# result must be returned as array of [id, search_field_value]\r\n a = if params['search'].match(/\\./)\r\n name, method = params['search'].split('.')\r\n table.send(method, params['input']).inject([]) do |r,v|\r\n r << { label: v[0], value: v[0], id: v[1].to_s }\r\n end\r\n# simply search which will search and return field_name defined in params['search']\r\n else\r\n table.where(params['search'] => /#{params['input']}/i).limit(20).inject([]) do |r,v|\r\n r << { label: v[params['search']], value: v[params['search']], id: v.id.to_s }\r\n end\r\n end\r\n\r\n render inline: a.to_json, formats: 'js'\r\nend",
"def autocomplete\n render :json => end_of_association_chain.ordered.search(params[:term]).limit(params[:limit] || 10).to_autocomplete\n end",
"def ajax_auto_complete\n type = params[:type].to_s\n instr = params[:id].to_s\n letter = ' '\n scientific = false\n user = login_for_ajax\n if user\n scientific = (user.location_format == :scientific)\n end\n @items = []\n if instr.match(/^(\\w)/)\n letter = $1\n case type\n\n when 'location'\n @items = Observation.connection.select_values(%(\n SELECT DISTINCT `where` FROM observations\n WHERE `where` LIKE '#{letter}%' OR\n `where` LIKE '% #{letter}%'\n )) + Location.connection.select_values(%(\n SELECT DISTINCT `name` FROM locations\n WHERE `name` LIKE '#{letter}%' OR\n `name` LIKE '% #{letter}%'\n ))\n if scientific\n @items.map! {|i| Location.reverse_name(i)}\n end\n @items.sort!\n\n when 'name'\n @items = Name.connection.select_values %(\n SELECT text_name FROM names\n WHERE text_name LIKE '#{letter}%'\n AND correct_spelling_id IS NULL\n ORDER BY text_name ASC\n )\n\n when 'name2'\n @items = Name.connection.select_values(%(\n SELECT text_name FROM names\n WHERE text_name LIKE '#{instr}%'\n AND correct_spelling_id IS NULL\n ORDER BY text_name ASC\n )).sort_by {|x| (x.match(' ') ? 'b' : 'a') + x}\n # This sort puts genera and higher on top, everything else on bottom,\n # and sorts alphabetically within each group.\n letter = ''\n\n when 'project'\n @items = Project.connection.select_values %(\n SELECT title FROM projects\n WHERE title LIKE '#{letter}%'\n OR title LIKE '%#{letter}%'\n ORDER BY title ASC\n )\n\n when 'species_list'\n @items = SpeciesList.connection.select_values %(\n SELECT title FROM species_lists\n WHERE title LIKE '#{letter}%'\n OR title LIKE '%#{letter}%'\n ORDER BY title ASC\n )\n\n when 'user'\n @items = User.connection.select_values %(\n SELECT CONCAT(users.login, IF(users.name = \"\", \"\", CONCAT(\" <\", users.name, \">\")))\n FROM users\n WHERE login LIKE '#{letter}%'\n OR name LIKE '#{letter}%'\n OR name LIKE '% #{letter}%'\n ORDER BY login ASC\n )\n end\n end\n\n # Result is the letter requested followed by results, one per line. (It\n # truncates any results that have newlines in them -- that's an error.)\n render(:layout => false, :inline => letter +\n %(<%= @items.uniq.map {|n| h(n.gsub(/[\\r\\n].*/,'')) + \"\\n\"}.join('') %>))\n end",
"def autocomplete(q:)\n return unless String(q).length > 1\n\n result = Geocoder.search(q, autocomplete: true)\n result&.data\n end",
"def autocomplete(line, namespace)\n raise NotImplementedError, \"autocomplete\"\n end",
"def generate_autocomplete\n # we'll martial brand into the autocomplete field since it's\n # natural to search by brand\n s = \"#{ brand } #{ name } #{ model_number }\".squish\n s = s.truncate(45, omission: \"\", separator: \" \") if s.length > 45\n self.autocomplete = self.class.normalize(s)\n end",
"def handle_autocomplete\n if (query = request.params['q'].to_s).empty?\n ''\n else\n model.autocomplete(:type=>@subtype, :request=>request, :association=>params_association, :query=>query, :exclude=>request.params['exclude']).join(\"\\n\")\n end\n end",
"def autocomplete\n keyword = params[:keyword]\n gs = Api::Google.new\n results = gs.autocomplete(keyword)\n render json: results # Return to frontend (-> results injected by spot_autocomplete_dropdown.js)\n end",
"def bu_autocomplete\n search_term = params[:term]\n\n species_id = Specie.find_by_scientificname(params[:species])\n\n cultivars = Cultivar.where(\"specie_id = ?\", species_id)\n\n logger.debug(\"cultivars for autocompletion: #{cultivars.inspect}\")\n\n filtered_cultivars = cultivars.where(\"LOWER(name) LIKE LOWER(?)\", '%' + search_term + '%')\n\n if filtered_cultivars.size > 0 || search_term.size > 1\n cultivars = filtered_cultivars\n # else if there are no matches and the user has only typed one letter, just return every cultivar associated with the chosen species\n end\n\n cultivars = cultivars.to_a.map do |item|\n item.name.squish\n end\n\n # don't show rows where name is null or empty\n # TO-DO: eliminate these from the database and prevent them with a constraint\n cultivars.delete_if { |item| item.nil? || item.empty? }\n\n if cultivars.empty?\n cultivars = [ { label: \"No matches\", value: \"\" }]\n end\n\n respond_to do |format|\n format.json { render :json => cultivars }\n end\n end",
"def auto_complete_for_person_name\n \tname = params[:person][:name].downcase\n \tnames = name.strip.split(' ')\n \t\n find_options = {\n :order => \"last_name, first_name ASC\",\n\t :limit => 10 }\n\n\t\tif names.size > 1\n\t\t\t# there are two names provided\n\t\t\tfind_options[:conditions] = \"LOWER(first_name) LIKE '%#{names[0]}%' AND LOWER(last_name) LIKE '%#{names[1]}%' OR LOWER(first_name) LIKE '%#{names[1]}%' AND LOWER(last_name) LIKE '%#{names[0]}%'\"\n\t\telse\n\t\t\t# only the first name or last name has been provided\n\t\t\tfind_options[:conditions] = \"LOWER(first_name) LIKE '%#{names[0]}%' OR LOWER(last_name) LIKE '%#{names[0]}%'\"\n\t\tend\n\t\n\t\t@items = Person.find(:all, find_options)\n\t\n\t\tRails.logger.info(\"@items.size = #{@items.size}\")\n\n render :inline => \"<%= auto_complete_result @items, 'name' %>\"\n end",
"def autocomplete(term)\n get(\"/catalog/titles/autocomplete?term=#{term}\")\n end",
"def autocomplete\n @leader = Leaders.find(:all, :conditions => [\"name like ?\",\"%\" + params[:term].upcase + \"%\"])\n render json: @leader \n end",
"def setupAutocomplete(commands)\n cmdAuto = proc { |s| commands.map{|cmd, _desc| cmd}.flatten.grep(/^#{Regexp.escape(s)}/) }\n Readline::completion_append_character = \" \"\n Readline::completion_proc = cmdAuto\nend",
"def autocomplete\r\n # table parameter must be defined. If not, get it from search parameter\r\n if params['table'].nil? && params['search'].match(/\\./)\r\n name = params['search'].split('.').first\r\n params['table'] = name.underscore\r\n end\r\n if params['table'].match('_control')\r\n # it must be at least logged on\r\n return render json: { label: t('drgcms.not_authorized') } unless dc_user_can(DcPermission::CAN_VIEW, 'dc_memory')\r\n else\r\n return render json: { label: t('drgcms.not_authorized') } unless dc_user_can(DcPermission::CAN_VIEW)\r\n end\r\n\r\n table = params['table'].classify.constantize\r\n input = params['input'].gsub(/\\(|\\)|\\[|\\]|\\{|\\|\\.|\\,}/, '')\r\n # call method in class if search parameter contains . This is for user defined searches\r\n a = if params['search'].match(/\\./)\r\n #method, additional_params = params['search'].split('.')\r\n #data = additional_params ? table.send(method, input, additional_params, self) : table.send(method, input)\r\n name, method = params['search'].split('.')\r\n data = table.send(method, input)\r\n data.map do |v|\r\n { label: v[0], value: v[0], id: (v[1] || v[0]).to_s }\r\n end\r\n # will search and return field_name defined in params['search']\r\n else\r\n table.where(params['search'] => /#{input}/i).limit(20).map do |v|\r\n { label: v[params['search']], value: v[params['search']], id: v.id.to_s }\r\n end\r\n end\r\n\r\n render json: a\r\nend",
"def auto_complete_for_friend_name\n friend = params[:term]\n #@associates = current_user.associates.find(:all, :conditions => \"name like '%\" + friend + \"%'\")\n\n @associates = current_user.associates.find_by_name_like(friend)\n if @associates.present?\n render :json => @associates.map(&:name), :status => :ok\n else\n render :json => params[:term], :status => :ok\n end\n end",
"def complete_tags\n unless request.post?\n render_404\n return\n end\n @tags = Tag.for_autocomplete params[:tag]\n render :partial => \"auto_completed\"\n end",
"def auto_complete_model_for_person_fullname\n @result = Person.non_student.find_all{|p| p.fullname.downcase.include?(params[:person][:fullname].downcase)}[0..10]\n render :partial => \"auto_complete\", :object => @result, :locals => { :highlight_phrase => params[:person][:fullname] }\n end",
"def auto_complete_for_customer\n render :json => {} and return if (terms_string = params[:term].to_s).length < 2\n terms = terms_string.split( /\\s+/ )\n max_matches = 60\n exact_name_matches = Customer.exact_name_matches(terms).limit(max_matches/3)\n partial_name_matches = Customer.partial_name_matches(terms).limit(max_matches/3) - exact_name_matches\n other_term_matches = Customer.other_term_matches(terms).limit(max_matches/3) - exact_name_matches - partial_name_matches\n\n if (exact_name_matches.size + partial_name_matches.size + other_term_matches.size) == 0\n render :json => [{'label' => '(no matches)', 'value' => nil}] and return\n end\n show_all_matches = [{\n 'label' => \"List all matching '#{terms_string}'\",\n 'value' => customers_path(:customers_filter => terms_string)}]\n result =\n exact_name_matches.map { |c| {'label' => c.full_name, 'value' => customer_path(c)} } +\n partial_name_matches.map { |c| {'label' => c.full_name, 'value' => customer_path(c)} } +\n other_term_matches.map { |c| {'label' => \"#{c.full_name} (#{c.field_matching_terms(terms)})\", 'value' => customer_path(c)} } +\n show_all_matches\n render :json => result.uniq\n end",
"def autocomplete\n\t\tcond = get_search_conditions(params[:term], {\n\t\t\t'vacancies.exec_approval_no' => :like,\n\t\t\t'vacancies.org_no' => :like,\n\t\t\t'vacancies.cost_center' => :like,\n\t\t\t'vacancies.position_no' => :like,\n\t\t\t'vacancies.position' => :like,\n\t\t\t'vacancies.last_incumbent' => :like\n\t\t})\n\t\tcond << 'vacancies.exec_decision = \"Approved\"'\n\t\tuser_limited = @current_user.agency_level? && !@current_user.allow_vacancy_omb && !@current_user.allow_vacancy_admin\n\t\tagency_id = user_limited && @current_user.agency_id || params[:agency_id]\n\t\tdepartment_id = user_limited && @current_user.department_id || params[:department_id]\n\t\tdivision_id = user_limited && @current_user.division_id || params[:division_id]\n\t\tcond << 'vacancies.agency_id = %d' % agency_id.to_i if !agency_id.blank?\n\t\tcond << 'vacancies.department_id = %d' % department_id.to_i if !department_id.blank?\n\t\tcond << 'vacancies.division_id = %d' % division_id.to_i if !division_id.blank?\n\t\tobjs = @model.find(:all, :include => :vacancy_data, :conditions => get_where(cond), :limit => 10, :order => 'vacancies.id desc').map { |o|\n\t\t\to.autocomplete_json_data\n\t\t}\n\t\trender :json => objs.to_json\n\tend",
"def autocomplete\n @design_methods = DesignMethod.where(['name LIKE ?', \"#{params[:term]}%\"])\n @design_hash = []\n @design_methods.each do |d|\n @design_hash << { label: d.name }\n end\n respond_to do |format|\n format.json { render json: @design_hash}\n end\n end",
"def suggestions\n suggest(search_suggestions)\n end",
"def get_field_autocomplete_class(model,term)\n if (not model.is_a? String) and (not model.is_a? Symbol)\n model=ActiveSupport::Inflector.tableize(model.class.to_s)\n end\n\n if term\n if term.to_s=='based_near' || term.to_s=='subject' || term.to_s=='contributor'\n return ['autocomplete']\n end\n end\n\n dt=DomainTerm.find_by(model: model, term: term)\n if not dt or dt.local_authorities.empty?\n return []\n else\n return ['autocomplete']\n end\n end",
"def autocomplete_name\n base = \"#{object_name}[#{attribute_name}_language]\"\n\n return base unless multiple_method? && multiple?\n\n \"#{base}[]\"\n end",
"def causeautocomplete\n searchtext = params['searchText']\n\n if session[:roleid] == ADMIN_ROLE\n # this will do a like search ignoring case\n @searchcauseresults = Charity.where(\"charityname ILIKE ?\", \"%\" + searchtext + \"%\")\n \n else\n \n # this will do a like search ignoring case\n @searchcauseresults = Charity.where(\"charityname ILIKE ?\", \"%\" + searchtext + \"%\")\n .where(isapproved: true)\n \n end\n\n \n\n #if @searchcauseresults.count == 0\n # @searchcauseresults = Charity.new\n #end\n \n render :json => @searchcauseresults\n\n end",
"def highlight_in_autocomplete\n\t\t\ttrue\n\t\tend",
"def auto_complete_for_ingredient_name\n value = params[:ingredient][:name]\n @ingredients = Ingredient.find(:all, \n :conditions => [ 'LOWER(name) LIKE ?',\n '%' + value.downcase + '%' ], \n :order => 'name ASC',\n :limit => 8)\n render :partial => 'ingredient_name_matches'\n end",
"def auto_complete(word)\n completion_list.grep(/^#{ Regexp.escape(word) }/)\n end",
"def complete(search); Bond::DefaultMission.completions; end",
"def fast_suggestions query\n return []\n end",
"def autocomplete_on\n\t\tconditions = if params[:name]\n [\"name LIKE :name\", { :name => \"%#{params['name']}%\"} ]\n else\n {}\n end\n\t\t @objects = params[:model_name].classify.constantize.find(:all, :conditions => conditions)\n\t\t render :text => '<ul>'+ @objects.map{ |e| '<li>' + e.name + '</li>' }.join(' ')+'</ul>'\n\tend",
"def suggest\n @suggestions = suggestions_service.suggestions\n render 'suggest', layout: false\n end",
"def autocomplete\n\t\tquery_params = QueryFormat.autocomplete_format()\n\t\tbegin\n\t\t\tQueryFormat.transform_raw_parameters(params)\n\t\t\tquery = QueryFormat.create_solr_query(query_params, params, request.remote_ip)\n\t\t\tquery['field'] = \"content_auto\" if query['field'].blank?\n\t\t\tis_test = Rails.env == 'test' ? :test : :live\n\t\t\tis_test = :shards if params[:test_index]\n\t\t\tsolr = Solr.factory_create(is_test)\n\t\t\tmax = query['max'].to_i\n\t\t\tquery.delete('max')\n\t\t\twords = solr.auto_complete(query)\n\t\t\twords.sort! { |a,b| b[:count] <=> a[:count] }\n\t\t\twords = words[0..(max-1)]\n\t\t\t@results = words.map { |word|\n\t\t\t\t{ :item => word[:name], :occurrences => word[:count] }\n\t\t\t}\n\n\t\t\trespond_to do |format|\n\t\t\t\tformat.html # index.html.erb\n\t\t\t\tformat.json { render json: { results: @results } }\n\t\t\t\tformat.xml\n\t\t\tend\n\t\trescue ArgumentError => e\n\t\t\trender_error(e.to_s)\n\t\trescue SolrException => e\n\t\t\trender_error(e.to_s, e.status())\n\t\trescue Exception => e\n\t\t\tExceptionNotifier.notify_exception(e, :env => request.env)\n\t\t\trender_error(\"Something unexpected went wrong.\", :internal_server_error)\n\t\tend\n\tend",
"def auto_complete_result(entries, field, phrase = nil)\n return unless entries\n render :partial => '/admin/orders/autocomplete', :locals => { :entries => entries, :field => field, :phrase => phrase }\n end",
"def scaffold_use_auto_complete\n @scaffold_use_auto_complete ||= scaffold_auto_complete_options[:enable]\n end",
"def autocomplete(opts={})\n type, request, assoc, query, exclude = opts.values_at(:type, :request, :association, :query, :exclude)\n if assoc\n if exclude && association_type(assoc) == :edit\n ref = model.association_reflection(assoc)\n block = lambda do |ds|\n ds.exclude(S.qualify(ref.associated_class.table_name, ref.right_primary_key)=>model.db.from(ref[:join_table]).where(ref[:left_key]=>exclude).select(ref[:right_key]))\n end\n end\n return associated_model_class(assoc).autocomplete(opts.merge(:type=>:association, :association=>nil), &block)\n end\n opts = autocomplete_options_for(type, request)\n callback_opts = {:type=>type, :request=>request, :query=>query}\n ds = all_dataset_for(type, request)\n ds = opts[:callback].call(ds, callback_opts) if opts[:callback]\n display = opts[:display] || S.qualify(model.table_name, :name)\n display = display.call(callback_opts) if display.respond_to?(:call)\n limit = opts[:limit] || 10\n limit = limit.call(callback_opts) if limit.respond_to?(:call)\n opts[:filter] ||= lambda{|ds1, _| ds1.where(S.ilike(display, \"%#{ds.escape_like(query)}%\"))}\n ds = opts[:filter].call(ds, callback_opts)\n ds = ds.select(S.join([S.qualify(model.table_name, model.primary_key), display], ' - ').as(:v)).\n limit(limit)\n ds = yield ds if block_given?\n ds.map(:v)\n end",
"def auto_complete\n q = params[:term].gsub(/\\s/, \"\").gsub(\" \", \"\")\n uri = Addressable::URI.parse(\"https://www.googleapis.com/books/v1/volumes?q=#{q}&country=JP&maxResults=40&orderBy=relevance\")\n begin\n response = Net::HTTP.get_response(uri)\n result = JSON.parse(response.body)\n book_result = result[\"items\"]\n .select{|item| item.has_key?(\"volumeInfo\") && item[\"volumeInfo\"].has_key?(\"title\")}\n .take(40)\n .map{|item|\n {\n title: item[\"volumeInfo\"][\"title\"],\n subtitle: item[\"volumeInfo\"][\"subtitle\"],\n authors: item[\"volumeInfo\"][\"authors\"],\n categories: item[\"volumeInfo\"][\"categories\"],\n google_books_id: item[\"id\"],\n info: item[\"volumeInfo\"][\"industryIdentifiers\"]\n }\n }\n @results = Book.auto_complete_map(book_result)\n\n render json: @results.to_json\n rescue => e\n p e.message\n end\n end",
"def scaffold_use_auto_complete\n scaffold_auto_complete_options[:enable]\n end",
"def get_autocomplete_items(parameters)\n HsCode.where(\"hs_codes.code like :search or hs_codes.description like :search\", :search => \"%#{params[:term]}%\").select('description, code').limit(100)\n end",
"def model_auto_completer(tf_name, tf_value, hf_name, hf_value, options={}, tag_options={}, completion_options={})\n rand_id = Digest::SHA1.hexdigest(Time.now.to_s.split(//).sort_by {rand}.join)\n hf_id = \"model_auto_completer_hf_#{rand_id}\"\n tf_id = \"model_auto_completer_tf_#{rand_id}\"\n options = {\n :regexp_for_id => '(\\d+)$',\n :allow_nil => false,\n :allow_free_text => false,\n :send_on_return => false,\n :controller => controller.controller_name,\n :action => 'auto_complete_model_for_' + tf_name.sub(/\\[/, '_').gsub(/\\[\\]/, '_').gsub(/\\[?\\]$/, ''),\n :after_update_element => 'Prototype.emptyFunction'\n }.merge(options)\n\n tag_options.update({\n :id => tf_id,\n :onfocus => 'this.model_auto_completer_cache = this.value'\n })\n tag_options[:onblur] = if options[:allow_nil]\n \"if (this.value != this.model_auto_completer_cache) {this.value = ''; $('#{hf_id}').value = ''}\"\n elsif options[:allow_free_text]\n \"if (this.value != this.model_auto_completer_cache) {$('#{hf_id}').value = ''}\"\n else\n 'this.value = this.model_auto_completer_cache' \n end\n # The following test is based on http://techpatterns.com/downloads/scripts/javascript_browser_detection_basic.txt\n tag_options[:onkeypress] = \"if (navigator.userAgent.indexOf('Safari') != -1) {return event.keyCode == Event.KEY_RETURN ? false : true } else { return true }\" unless options[:send_on_return]\n \n after_update_element_js = <<-JS.gsub(/\\s+/, ' ')\n function(element, value) {\n var model_id = /#{options[:regexp_for_id]}/.exec(value.id)[1];\n $(\"#{hf_id}\").value = model_id;\n element.model_auto_completer_cache = element.value;\n (#{options[:after_update_element]})(element, value, $(\"#{hf_id}\"), model_id);\n }\n JS\n completion_options.update({\n :url => url_for(\n :controller => options[:controller],\n :action => options[:action]\n ),\n :after_update_element => after_update_element_js\n })\n \n completion_options[:indicator] = \"loader\"\n\n return <<-HTML\n #{auto_complete_stylesheet unless completion_options[:skip_style]}\n #{hidden_field_tag(hf_name, hf_value, :id => hf_id)}\n #{text_field_tag tf_name, tf_value, tag_options}\n #{content_tag(\"div\", \"\", :id => \"#{tf_id}_auto_complete\", :class => \"auto_complete\")}\n #{auto_complete_field tf_id, completion_options}\n HTML\n end",
"def scaffold_auto_complete_for(klass, association=nil)\n meth = \"scaffold_auto_complete_for_#{klass.scaffold_name}\"\n (self.scaffolded_auto_complete_associations[klass] ||= Set.new).add(association.to_s)\n allowed_associations = scaffolded_auto_complete_associations[klass]\n unless instance_methods.include?(meth)\n scaffold_define_method(meth) do\n association = scaffold_request_param(:association).to_s\n if scaffold_request_param(:association) && !allowed_associations.include?(association)\n scaffold_method_not_allowed\n else\n @items = klass.scaffold_auto_complete_find(scaffold_request_id.to_s, :association=>(association.to_sym if scaffold_request_param(:association)), :session=>scaffold_session)\n scaffold_render_template(meth, {}, :inline => \"<%= scaffold_auto_complete_result(@items) %>\")\n end\n end\n end\n end",
"def autocomplete_sn\n render :partial => 'autocomplete', :object => Scientificname.find(:all, :conditions => ['name ILIKE ?', params[:sn] + '%' ])\n end",
"def auto_complete_for_category_name_with_security\n Category.with_user_scope(current_user) do\n auto_complete_for_category_name_without_security\n end\n end",
"def auto_complete_for(object, association, method, options={}) #:nodoc:\n conditions = \"\"\n conditions = \" AND \"+options[:and_conditions].to_s unless options[:and_conditions].nil?\n options.delete(:and_conditions)\n if object.to_s.camelize.constantize.reflections[association].class_name.constantize.columns_hash[\"company_id\"].nil?\n define_method(\"auto_complete_belongs_to_for_#{object}_#{association}_#{method}\") do\n find_options = {\n :conditions => [\"LOWER(#{method}) LIKE ? #{conditions}\", '%' + params[association][method].downcase + '%'],\n :order => \"#{method} ASC\",\n :limit => 10\n }.merge!(options)\n klass = object.to_s.camelize.constantize.reflect_on_association(association).options[:class_name].constantize\n @items = klass.find(:all, find_options)\n render :inline => \"<%= model_auto_complete_result @items, '#{method}' %>\"\n end\n else\n define_method(\"auto_complete_belongs_to_for_#{object}_#{association}_#{method}\") do\n find_options = {\n :conditions => [\"LOWER(#{method}) LIKE ? AND company_id=? #{conditions}\", '%' + params[association][method].downcase + '%', @current_company_id],\n :order => \"#{method} ASC\",\n :limit => 10\n }.merge!(options)\n klass = object.to_s.camelize.constantize.reflect_on_association(association).options[:class_name].constantize\n @items = klass.find(:all, find_options)\n render :inline => \"<%= model_auto_complete_result @items, '#{method}' %>\"\n end\n end\n end",
"def autocomplete_doctor_name\n\n if params[:term].present?\n items = get_autocomplete_items(:model => Doctor, \n :method => :name,\n :term => params[:term], \n :options => { :full => true, :where => { :hospital_id => params[:id] } })\n end\n\n render :json => json_for_autocomplete(items || {}, :name)\n end",
"def autocomplete\n @lists = Listing.verification\n @lists = @lists.starts_with(filter_params[:country]) if filter_params[:country].present? \n \n respond_to do |format|\n format.json {render json:@lists}\n end\n end",
"def autocomplete_venue_name\n term = params[:term]\n if term && !term.empty?\n items = Venue.verified.select(\"name\").\n where(\"name like ?\", '%' + term.downcase + '%').\n limit(10).order(:name)\n else\n items = {}\n end\n render :json => json_for_autocomplete(items, :name)\n end",
"def default_autocomplete\n [\n { label: \"My Profile settings\", url: profile_path },\n { label: \"My SSH Keys\", url: profile_keys_path },\n { label: \"My Dashboard\", url: root_path },\n { label: \"Admin Section\", url: admin_root_path },\n ]\n end",
"def autocomplete\n render json: Post.search(params[:query],operator: \"or\", autocomplete: true,limit: 10,boost_by_distance: {field: :location, origin: [current_user.lat, current_user.lon]}).map {|post| {title: post.title, value: post.id}}\n end",
"def index\n\n #this for auto-complete search for places\n @places = (params[:q].blank?)? Place.all : Place.where(\"name ilike ?\", \"%#{params[:q]}%\")\n\n respond_to do |format|\n #format.html #index.html.erb\n format.json { render json: @places }\n format.xml { render :xml => @places }\n end\n end",
"def autocomplete\n respond_to do |format|\n format.json do\n # Only get non-soft deleted Donations and Donations where the available until datetime is after the current datetime.\n @donations = Donation.kept.available\n\n # Ensure the User has permission to perform this action.\n authorize @donations\n\n # Search the Donations based on the current term typed into the search bar.\n @donations = @donations.search(params[:term])\n\n # Only return the name and description of the Donation, as a single array.\n @donation_names_and_descriptions = []\n @donations.map(&:name).zip(@donations.map(&:description)).each do |name, description|\n @donation_names_and_descriptions << \"#{name}: #{description}\"\n end\n\n render json: @donation_names_and_descriptions.to_json\n end\n end\n end",
"def autocomplete_clase_nombre \n respond_to do |format|\n @clases = Clase.joins(:partida_parcial => [:partida_principal]).where(\"clases.fecha_de_baja IS NULL AND clases.nombre ILIKE ?\", \"%#{params[:term]}%\").order(\"partidas_principales.codigo\").order(\"partidas_parciales.codigo\").order(\"clases.codigo\").paginate(:page => params[:page], :per_page => 30) \n render :json => @clases.map { |clase| {:id => clase.id, :label => clase.nombre, :value => clase.nombre} } \n format.js { } \n end \n end",
"def set_university_autocomplete\n render json: {\"course_tags\": @course_tags, \"program_tags\": @program_tags}\n end",
"def autocomplete\n statement = Statement.new(VIM::cursor_word, VIM::cursor_sentence, VIM::get_line)\n\n if statement.cursor.class?\n tag = Tags.klass(statement.cursor)\n unless tag\n # Try to create class if it doesn't exists\n package = @current_scope.package\n package += (!package.empty? ? \".\" : '') + statement.cursor\n create_new_class(package)\n else\n # Try to import class if it isn't present on this scope\n @current_scope.reindex_headers!\n unless @current_scope.package_imported?(tag.full_package)\n @current_scope.import!(tag.full_package)\n end\n end\n\n elsif statement.cursor.const?\n # If statement doesn't exists, try to create it\n unless Tags.variable(statement.cursor, :file => @current_scope.path)\n if access_level_selected = self.ask_access_level(\"Define constant '#{statement.cursor}' with access level:\")\n @current_scope.reindex_headers!\n $curbuf.append(@current_scope.class_line, \"\\t\\t#{access_level_selected} static var #{statement.cursor} : String = \\\"#{statement.cursor.downcase}\\\";\")\n cursor = @current_scope.cursor\n VIM::set_cursor_position(cursor[0]+1, cursor[1])\n end\n end\n\n elsif (statement.sentence.function? && !Tags.function(statement.cursor, :file => @current_scope.path))\n\n # Show options to generate a function if isn't defined on current scope\n if access_level_selected = self.ask_access_level(\"Create function '#{statement.cursor}' with access level:\")\n next_function_line = @current_scope.next_function_line(@current_scope.cursor[0])\n function = statement.function\n $curbuf.append(next_function_line, \"\\t\\t#{access_level_selected} function #{function[:name]}(#{function[:args]}) : * {\")\n $curbuf.append(next_function_line+1, \"\\t\\t}\")\n $curbuf.append(next_function_line+2, \"\")\n end\n\n elsif statement.cursor == \"override\"\n # Show parent class function list, to select for override\n @current_scope.reindex_headers!\n\n if @current_scope.extends\n function_tags = Tags.functions(:full_package => @current_scope.extends)\n\n # Ignore constructor method\n function_tags = function_tags.select {|tag| tag.name != Parser::Package.class_name(@current_scope.extends) }\n\n tag_selected = if function_tags.length > 1\n idx = VIM::input_list(\"Select a function to override:\", function_tags.collect { |tag| \"#{tag.name} (#{tag.access_level})\" } )\n (idx >= 0) ? function_tags[idx] : nil\n elsif function_tags.length == 1\n function_tags.first\n else\n VIM::echoerr(\"Cannot find any function on '#{@current_scope.extends}' to override.\")\n end\n if tag_selected\n $curbuf[@current_scope.cursor[0]] = tag_selected.definition.gsub(/(private|protected|public )/, 'override \\1')\n $curbuf.append(@current_scope.cursor[0], \"\\t\\t}\")\n end\n else\n VIM::echoerr(\"Cannot override a base class.\")\n end\n end\n\n #puts statement.cursor.inspect\n end",
"def autocomplete\n @taxa = Taxon.order(:scientific_name).search(params[:term])\n list = @taxa.map {|t| Hash[id: t.id, label: t.label, value: t.scientific_name]}\n respond_to do |format|\n format.html { render :index }\n format.json do\n render json: list.to_json\n end\n end\n end",
"def as_json_for_autocomplete\n {id: id, value: full_name, link: autocomplete_link}\n end",
"def scaffold_auto_complete_find(phrase, options = {})\n session = options.delete(:session)\n if association = options.delete(:association)\n if meth = scaffold_method_override(:auto_complete_find, association, phrase, options)\n meth.call\n else\n scaffold_associated_class(association).scaffold_auto_complete_find(phrase, :session=>session)\n end\n else\n find_options = { :limit => scaffold_auto_complete_results_limit,\n :conditions => [scaffold_auto_complete_conditions(phrase), scaffold_session_conditions(session)],\n :order => scaffold_select_order(:auto_complete),\n :include => scaffold_include(:auto_complete)}.merge(options)\n scaffold_get_objects(find_options)\n end\n end",
"def suggester_name(url_params = nil)\n blacklight_config.autocomplete_suggester ||= DEF_AUTOCOMPLETE_SUGGESTER\n super\n end",
"def quest_autocomplete\n render json: Quest.search(params[:query], where: { :group_id => @user.wrapper_group.id})\n end",
"def scaffold_auto_complete_search_operator\n scaffold_auto_complete_options[:search_operator]\n end",
"def search_scope\n super\n end",
"def get_autocomplete_items(parameters)\n items = super(parameters)\n if current_user.admin?\n items\n else\n items.includes(:users).where(users:{id: current_user.id})\n end\n end",
"def auto_complete_for_headline_tag_list_without_areas\n auto_complete_for_tag_list_first_beginning_then_the_rest(params[:headline][:tag_list_without_areas])\n if @tags.length > 0\n render :inline => \"<%= content_tag(:ul, @tags.map {|t| content_tag(:li, t.name)}.join.html_safe) %>\"\n else\n render :nothing => true\n end\n end",
"def auto_complete_for_technician_enquiry_from\n re = Regexp.new(\"^#{params[:technician][:name]}\", \"i\")\n find_options = { :order => \"name ASC\" }\n @technicians = Technician.find(:all, find_options).collect(&:name).select { |org| org.match re }\n render :template => 'sales/auto_complete_for_technician_name',:layout=>false\n end",
"def search_account\n data=params\n search_result =[]\n unless data[:q].blank?\n search_result = @company.accounts.search data[:q], :star => true, :limit => 10000\n else\n search_result = @company.accounts.all(:order => 'name ASC')\n end\n render :partial=> 'account_auto_complete', :locals => {:search_result => search_result}\n end",
"def fill_auto_complete(field, filter = nil, full_text)\n fill_in field, with: filter unless filter\n\n page.execute_script %Q{ $('##{field}').trigger('focus') }\n page.execute_script %Q{ $('##{field}').trigger('keydown') }\n\n selector = %Q{ul.ui-autocomplete li.ui-menu-item a:contains(\"#{full_text}\")}\n\n sleep 5\n page.execute_script %Q{ $('#{selector}').trigger('mouseenter').click() }\n sleep 5\n end",
"def autocomplete_book_author\n# re = Regexp.new(\"^#{params[:user][:favorite_language]}\" , \"i\" )\n # @books= Book.find_all do |book|\n # book.title.match re\n # end\n # render :layout=>false\n end",
"def autosuggest(object, name, options={})\n options[:display] ||= name\n options[:limit] ||= 10\n options[:name] = name\n options[:search_in] ||= [name]\n options[:order] ||= \"#{options[:search_in].first} ASC\"\n\n define_method \"autosuggest_#{object}_#{name}\" do\n options.merge!(:query => params[:query], :object => object.to_s.camelize.constantize)\n query = ''\n values = []\n\n for column in options[:search_in]\n query += \"#{column} ILIKE ? OR \"\n values.push(\"#{options[:query]}%\")\n end\n results = options[:object].where(query[0..-4], *values).order(options[:order]).limit(options[:limit])\n render :json => Yajl::Encoder.encode(results.map{|r| {:name => r.send(options[:display]), :value => r.id.to_s}})\n end\n end",
"def scaffold_auto_complete_find(phrase, options = {})\n find_options = { :limit => scaffold_auto_complete_results_limit,\n :conditions => scaffold_auto_complete_conditions(phrase), \n :order => scaffold_select_order,\n :include => scaffold_include}.merge(options)\n find(:all, find_options)\n end",
"def auto_complete_for_filename_name\n auto_complete_responder_for_filename params[:filename][:name]\n end",
"def autocomplete_station\n term = params[:term]\n stations = Station.where('name LIKE ?', \"%#{term}%\").select(\"distinct(name)\").order(:name).limit(10)\n render :json => stations.map { |s| {:id => s.id, :label => s.name, :value => s.name} }\n end",
"def keyword_autocomplete\n search_keyword = params[\"search\"]\n similar_keywords =\n Keyword.get_similar_keywords(search_keyword, [])\n similar_keywords.map! { |keyword| keyword.name }\n render json: similar_keywords\n end",
"def scaffold_auto_complete_for(object, options = {})\n define_method(\"scaffold_auto_complete_for_#{object}\") do\n @items = object.to_s.camelize.constantize.scaffold_auto_complete_find(params[:id], options)\n render :inline => \"<%= scaffold_auto_complete_result(@items) %>\"\n end\n end",
"def auto_search\n\t\t@city=ActiveRecord::Base.connection.execute(\"select c.id, c.name,co.name from City c, Country co where c.name like '%\"+params[:search]+\"%' and c.countrycode=co.code\")\n\t\trender :json =>@city\n\t\treturn\n\t\tend",
"def autocomplete_known_uri_search\n @known_uris = params[:term].blank? ? [] : search_known_uris_by_name_or_uri(params[:term])\n render_autocomplete_results\n end",
"def autocomplete_agente_apellido\n agente_activo = 1\n respond_to do |format|\n @agentes = Agente.where(\"agentes.estado_agente_id = ? AND agentes.apellido ILIKE ?\", agente_activo, \"%#{params[:term]}%\")\n render :json => @agentes.map { |agente| {:id => agente.id, :value => agente.apellido + \" \"+ agente.nombre } } \n format.js { } \n end\n end",
"def auto_complete_for_journal_title\n # Don't search on blank query.\n query = params['rft.jtitle']\n search_type = params[\"umlaut.title_search_type\"] || \"contains\"\n unless ( query.blank? )\n (context_objects, total_count) = find_by_title\n @titles = context_objects.collect do |co|\n metadata = co.referent.metadata\n {:object_id => metadata[\"object_id\"], :title => (metadata[\"jtitle\"] || metadata[\"btitle\"] || metadata[\"title\"])}\n end\n end\n render :text => @titles.to_json, :content_type => \"application/json\"\n end",
"def suggestions\n response.try(:[], \"suggest\").try(:[], @suggest_key).try(:[], request_params[:q]).try(:[], \"suggestions\") || []\n end",
"def autocomplete\n results = AttributeAutocomplete.new(\n attribute: params[:attribute],\n term: params[:term],\n year: year\n ).perform\n render json: results\n end",
"def scaffold_auto_complete_search_operator\n scaffold_auto_complete_options[:search_operator]\n end",
"def auto_complete_belongs_to_for_record_client_id\n auto_param = params[:record][:client][:text]\n @results = Client.find(:all,\n :conditions => [\"LOWER(name) LIKE ?\", \"%#{auto_param.downcase}%\"],\n :limit => 10\n )\n render :inline => '<%= model_auto_completer_result(@results, :name) %>'\n end"
] | [
"0.82597834",
"0.7440826",
"0.7344279",
"0.7231499",
"0.7136554",
"0.708994",
"0.7024913",
"0.7002947",
"0.6929823",
"0.6929823",
"0.6929823",
"0.6903167",
"0.68102777",
"0.67807907",
"0.6771609",
"0.6759399",
"0.67557424",
"0.6754824",
"0.6750441",
"0.67503244",
"0.6746515",
"0.6720438",
"0.67139935",
"0.67132145",
"0.6699948",
"0.6657263",
"0.656963",
"0.6565411",
"0.6563665",
"0.6477343",
"0.6432203",
"0.64085615",
"0.63747907",
"0.63742775",
"0.63432825",
"0.6342128",
"0.6339468",
"0.63154286",
"0.631443",
"0.6310269",
"0.6298724",
"0.627522",
"0.62699914",
"0.6269786",
"0.6268519",
"0.6267706",
"0.6260737",
"0.6251384",
"0.62466466",
"0.6243317",
"0.6198821",
"0.6195629",
"0.61859864",
"0.61781317",
"0.6173257",
"0.6163562",
"0.6157463",
"0.615545",
"0.6150988",
"0.6141831",
"0.61347413",
"0.6133709",
"0.6120644",
"0.6111458",
"0.61055136",
"0.61013865",
"0.6097404",
"0.6034394",
"0.6021372",
"0.5971631",
"0.5968824",
"0.5967587",
"0.59593725",
"0.59579784",
"0.5957011",
"0.5949966",
"0.5945648",
"0.59452534",
"0.59418595",
"0.59416217",
"0.5935424",
"0.59271413",
"0.59139204",
"0.5909585",
"0.5907594",
"0.5902564",
"0.5898296",
"0.58953214",
"0.5885783",
"0.58843565",
"0.5882251",
"0.58784664",
"0.5876952",
"0.58728355",
"0.58670825",
"0.5851238",
"0.5848648",
"0.58283263",
"0.5826365",
"0.5823685"
] | 0.6569784 | 26 |
Calculate the levenshtein distance for a value across multiple columns, and keep the smallest. | def least_levenshtein(fields, value)
levenshtein_sql = fields.map {|f| levenshtein_distance(f, value).to_sql }
Arel.sql("least(#{levenshtein_sql.join(", ")})")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def distance_score(*args)\n rows = args.first\n # if there's only one word, everyone wins!\n if rows[0].size <= 2\n rows.to_hash { |row| [row[0], 1,0] }\n else\n min_dist = rows.to_hash { |row| [row[0], 1000000] }\n\n rows.each do |row|\n dist = 0\n (2..row.size).each do |i|\n dist += (row[i].to_i - row[i - 1].to_i).abs\n end\n\n if dist < min_dist[row[0]]\n min_dist[row[0]] = dist\n end\n end\n normalize_scores(min_dist, true)\n end\n end",
"def levenshtein(first, second)\n m, n = first.length, second.length\n return m if n == 0\n return n if m == 0\n\n # Create our distance matrix\n d = Array.new(m+1) {Array.new(n+1)}\n 0.upto(m) { |i| d[i][0] = i }\n 0.upto(n) { |j| d[0][j] = j }\n\n 1.upto(n) do |j|\n 1.upto(m) do |i|\n d[i][j] = first[i-1] == second[j-1] ? d[i-1][j-1] : [d[i-1][j]+1,d[i][j-1]+1,d[i-1][j-1]+1,].min\n end\n end\n d[m][n]\nend",
"def levenshtein_distance(first, second)\n matrix = [(0..first.length).to_a]\n (1..second.length).each do |j|\n matrix << [j] + [0] * first.length\n end\n\n (1..second.length).each do |i|\n (1..first.length).each do |j|\n matrix[i][j] = if first[j - 1] == second[i - 1]\n matrix[i - 1][j - 1]\n else\n [\n matrix[i - 1][j],\n matrix[i][j - 1],\n matrix[i - 1][j - 1]\n ].min + 1\n end\n end\n end\n matrix.last.last\n end",
"def levenshtein_distance(str1, str2)\n s = str1\n t = str2\n n = s.length\n m = t.length\n\n return m if (0 == n)\n return n if (0 == m)\n\n d = (0..m).to_a\n x = nil\n\n str1.each_char.each_with_index do |char1,i|\n e = i + 1\n\n str2.each_char.each_with_index do |char2,j|\n cost = (char1 == char2) ? 0 : 1\n x = min3(\n d[j + 1] + 1, # insertion\n e + 1, # deletion\n d[j] + cost # substitution\n )\n d[j] = e\n e = x\n end\n\n d[m] = x\n end\n\n return x\n end",
"def levenshtein_distance(str1, str2)\n s = str1\n t = str2\n n = s.length\n m = t.length\n\n return m if (0 == n)\n return n if (0 == m)\n\n d = (0..m).to_a\n x = nil\n\n str1.each_char.each_with_index do |char1,i|\n e = i+1\n\n str2.each_char.each_with_index do |char2,j|\n cost = (char1 == char2) ? 0 : 1\n x = min3(\n d[j+1] + 1, # insertion\n e + 1, # deletion\n d[j] + cost # substitution\n )\n d[j] = e\n e = x\n end\n\n d[m] = x\n end\n\n return x\n end",
"def levenshtein_distance str1, str2\n s = str1\n t = str2\n n = s.length\n m = t.length\n max = n/2\n\n return m if (0 == n)\n return n if (0 == m)\n return n if (n - m).abs > max\n\n d = (0..m).to_a\n x = nil\n\n n.times do |i|\n e = i+1\n\n m.times do |j|\n cost = (s[i] == t[j]) ? 0 : 1\n x = [\n d[j+1] + 1, # insertion\n e + 1, # deletion\n d[j] + cost # substitution\n ].min\n d[j] = e\n e = x\n end\n\n d[m] = x\n end\n\n return x\n end",
"def levenshtein_distance(str1, str2)\n s = str1\n t = str2\n n = s.length\n m = t.length\n\n return m if n.zero?\n return n if m.zero?\n\n d = (0..m).to_a\n x = nil\n\n str1.each_char.with_index do |char1, i|\n e = i + 1\n\n str2.each_char.with_index do |char2, j|\n cost = (char1 == char2 ? 0 : 1)\n x = [\n d[j + 1] + 1, # insertion\n e + 1, # deletion\n d[j] + cost # substitution\n ].min\n d[j] = e\n e = x\n end\n\n d[m] = x\n end\n\n x\n end",
"def levenshtein_distance_to(other)\n levenshtein_distance(self, other)\n end",
"def edit_distance(v,w)\n <<-DOC\n In 1966, Vladimir Levenshtein introduced the notion of the edit distance between two strings as the minimum number of edit operations \n needed to transform one string into another.\n Sample Input:\n PLEASANTLY\n MEANLY\n Sample Output:\n 5\n\n # http://en.wikipedia.org/wiki/Levenshtein_distance\n DOC\n\n\n s = []\n (0..(v.length)).each {|i| s[i] = []}\n (0..(v.length)).each {|i| s[i][0] = i}\n (0..(w.length)).each {|j| s[0][j] = j}\n\n (1..(v.length)).each do |i|\n (1..(w.length)).each do |j|\n if v[i] == w[j] \n s[i][j] = s[i-1][j-1]\n else\n s[i][j] = [s[i-1][j]+1, s[i][j-1]+1, s[i-1][j-1]+1].min\n end\n end\n end\n puts s[v.length][w.length]\n end",
"def levenshtein_distance_to(other)\n String::Similarity.levenshtein_distance(self, other)\n end",
"def string_distance(word1, word2, max: 3, th: 3)\n d = DamerauLevenshtein.distance(word1, word2, 1, max)\n (d - [word1.length, word2.length].min).abs < th ? nil : d\nend",
"def rlevenshtein(str1, str2)\n return 0 if (str1 == \"\" || str2 == \"\")\n return ([str1.length, str2.length].max - levenshtein(str1, str2)) / [str1.length, str2.length].min.to_f\n end",
"def levenshtein_distance(s, t)\n m = s.length\n n = t.length\n return m if n == 0\n return n if m == 0\n d = Array.new(m+1) {Array.new(n+1)}\n\n (0..m).each {|i| d[i][0] = i}\n (0..n).each {|j| d[0][j] = j}\n (1..n).each do |j|\n (1..m).each do |i|\n d[i][j] = if s[i-1] == t[j-1] # adjust index into string\n d[i-1][j-1] # no operation required\n else\n [ d[i-1][j]+1, # deletion\n d[i][j-1]+1, # insertion\n d[i-1][j-1]+1, # substitution\n ].min\n end\n end\n end\n d[m][n]\nend",
"def damerau_levenshtein(other)\n n, m = self.length, other.length\n return m if n == 0\n return n if m == 0\n matrix = Array.new(n+1) do |i|\n Array.new(m+1) do |j|\n if i == 0 then j\n elsif j == 0 then i\n else 0 end\n end\n end\n (1..n).each do |i|\n (1..m).each do |j|\n cost = (self[i] == other[j]) ? 0 : 1\n delete = matrix[i-1][j] + 1\n insert = matrix[i][j-1] + 1\n substitution = matrix[i-1][j-1] + cost\n matrix[i][j] = [delete, insert, substitution].min\n if (i > 1) && (j > 1) && (self[i] == other[j-1]) && (self[i-1] == other[j])\n matrix[i][j] = [matrix[i][j], matrix[i-2][j-2] + cost].min\n end\n end\n end\n return matrix.last.last\n end",
"def levenshtein_distance(s, t)\n m = s.length\n n = t.length\n return m if n == 0\n return n if m == 0\n d = Array.new(m+1) { Array.new(n+1) }\n\n (0..m).each { |i| d[i][0] = i }\n (0..n).each { |j| d[0][j] = j }\n (1..n).each do |j|\n (1..m).each do |i|\n d[i][j] = if s[i-1] == t[j-1] # adjust index into string\n d[i-1][j-1] # no operation required\n else\n [d[i-1][j]+1, # deletion\n d[i][j-1]+1, # insertion\n d[i-1][j-1]+1, # substitution\n ].min\n end\n end\n end\n d[m][n]\nend",
"def nearest_by_levenshtein(compared_string = nil, column = 'verbatim_locality', limit = 10)\n return CollectingEvent.none if compared_string.nil?\n order_str = CollectingEvent.send(:sanitize_sql_for_conditions, [\"levenshtein(collecting_events.#{column}, ?)\", compared_string])\n CollectingEvent.where('id <> ?', id.to_s).\n order(Arel.sql(order_str)).\n limit(limit)\n end",
"def levenshtein_distance(s, t)\n m = s.length\n n = t.length\n return m if n == 0\n return n if m == 0\n d = Array.new(m + 1) { Array.new(n + 1) }\n\n (0..m).each { |i| d[i][0] = i }\n (0..n).each { |j| d[0][j] = j }\n (1..n).each do |j|\n (1..m).each do |i|\n d[i][j] = if s[i - 1] == t[j - 1] # adjust index into string\n d[i - 1][j -1] # no operation required\n else\n [d[i - 1][j]+1, # deletion\n d[i][j - 1]+1, # insertion\n d[i - 1][j - 1]+1, # substitution\n ].min\n end\n end\n end\n\n d[m][n]\n end",
"def dynamicEditDistance(str1, str2)\n matrix = Array.new(str1.length + 1) { Array.new(str2.length + 1) }\n\n # Set up first row of matrix\n (0...matrix[0].length).each do |i|\n matrix[0][i] = i\n end\n\n # Set up first column of matrix\n (0...matrix.length).each do |i|\n matrix[i][0] = i\n end\n\n # Build the matrix\n (1..str1.length).each do |i|\n (1..str2.length).each do |j|\n # If the current letters are the same, we take the old value\n # since there is no edit distance. Otherwise, we take the minimum\n # of the three values of substituion, deletion, or insertion\n if str1[i-1] == str2[j-1]\n matrix[i][j] = matrix[i-1][j-1]\n else\n matrix[i][j] = 1 + min(matrix[i-1][j-1], matrix[i-1][j], matrix[i][j-1])\n end\n end\n end\n\n return matrix[str1.length][str2.length]\nend",
"def invert_levenshtein1(a, b)\n row\t= (0..a.length).to_a\n 1.upto(b.length) do |y|\n prow = row\n row = [y]\n\n 1.upto(a.length) do |x|\n row[x] = [\n prow[x],\n row[x-1],\n prow[x-1] - (a[x-1] == b[y-1] ? 1 : 0)\n ].min\n end\n end\n\n row[-1]\n end",
"def levenshtein_distance(str1, str2)\n n = str1.length\n m = str2.length\n return m if n.zero?\n return n if m.zero?\n\n d = (0..m).to_a\n x = nil\n\n # to avoid duplicating an enumerable object, create it outside of the loop\n str2_codepoints = str2.codepoints\n\n str1.each_codepoint.with_index(1) do |char1, i|\n j = 0\n while j < m\n cost = (char1 == str2_codepoints[j]) ? 0 : 1\n x = min3(\n d[j + 1] + 1, # insertion\n i + 1, # deletion\n d[j] + cost # substitution\n )\n d[j] = i\n i = x\n\n j += 1\n end\n d[m] = x\n end\n\n x\n end",
"def levenshtein(str1, str2)\n m = str1.length\n n = str2.length\n return m if n == 0\n return n if m == 0\n d = Array.new(m+1) {Array.new(n+1)}\n (0..m).each { |i| d[i][0] = i}\n (0..n).each { |j| d[0][j] = j}\n (1..n).each do |j|\n (1..m).each do |i|\n d[i][j] = if str1[i-1] == str2[j-1] # adjust index into string\n d[i-1][j-1] # no operation required\n else\n [ d[i-1][j]+1, # deletion\n d[i][j-1]+1, # insertion\n d[i-1][j-1]+1, # substitution\n ].min\n end\n end\n end\n return d[m][n]\n end",
"def levenshtein_distance(s, t)\n m = s.length\n n = t.length\n return m if n == 0\n return n if m == 0\n d = Array.new(m+1) {Array.new(n+1)}\n\n (0..m).each {|i| d[i][0] = i}\n (0..n).each {|j| d[0][j] = j}\n (1..n).each do |j|\n (1..m).each do |i|\n d[i][j] = if s[i-1] == t[j-1] # adjust index into string\n d[i-1][j-1] # no operation required\n else\n [ d[i-1][j]+1, # deletion\n d[i][j-1]+1, # insertion\n d[i-1][j-1]+1, # substitution\n ].min\n end\n end\n end\n d[m][n]\n end",
"def levenshtein_distance(string1, string2)\n ld = Class.new.extend(Gem::Text).method(:levenshtein_distance)\n\n ld.call(string1, string2)\n end",
"def get_score(arr1, arr2)\n score = 0\n\n min = arr1\n\n if arr2.length < arr1.length\n min = arr2\n end\n\n for i in 0..min.length\n if !arr1[i].nil? && !arr2[i].nil?\n score += Levenshtein.distance(arr1[i], arr2[i]) \n end\n end\n\n return score\n end",
"def min_distance(word1, word2)\n dp = Array.new(word1.size + 1) { Array.new(word2.size + 1) }\n\n # increment values in 1st row and col\n (0...dp.size).each do |i|\n dp[i][0] = i\n end\n (0...dp[0].size).each do |j|\n dp[0][j] = j\n end\n\n (1...dp.size).each do |i|\n (1...dp[0].size).each do |j|\n dp[i][j] = if word1[i - 1] == word2[j - 1]\n # if chars are same, value will be from diagonal upward\n dp[i - 1][j - 1]\n else\n [\n dp[i - 1][j - 1],\n dp[i][j - 1],\n dp[i - 1][j]\n ].min + 1\n end\n end\n end\n dp[-1][-1]\nend",
"def levenshtein_similarity_to(other)\n String::Similarity.levenshtein(self, other)\n end",
"def min_distance(word1, word2)\n edit = Array.new(word1.size + 1) {\n Array.new(word2.size + 1)\n }\n \n (0..word1.size).each { |i|\n edit[i][0] = i\n }\n\n (0..word2.size).each { |i|\n edit[0][i] = i\n }\n\n (1..word1.size).each { |i|\n (1..word2.size).each { |j|\n if word1[i - 1] == word2[j - 1]\n edit[i][j] = edit[i - 1][j - 1]\n else\n edit[i][j] = 1 + [edit[i - 1][j] || 0, edit[i][j - 1] || 0, edit[i - 1][j - 1] || 0].min\n end\n }\n }\n\n edit[word1.size][word2.size]\nend",
"def compute_distance\n if exercise_rows\n exercise_rows.sort_by_part_order.inject(0) do |sum, row|\n actual_row_distance = row.compute_displayable_distance(distance).to_i\n actual_row_distance = distance if actual_row_distance == 0\n sum + actual_row_distance\n end\n else\n distance\n end\n end",
"def calculate_distance(translated_text, answer)\n DamerauLevenshtein.distance(prepare(translated_text), prepare(answer))\n end",
"def suggest_other_query(items, query)\n query = query.gsub(/_/,\" \").downcase\n\n distance_levenshtein = 100\n longest_subseq = 0\n word = \"\"\n\n matcher1 = Amatch::Levenshtein.new(query)\n matcher2 = Amatch::LongestSubsequence.new(query)\n\n items.each{ |item|\n name_array = item.name.downcase.split\n name_array.push(item.name.downcase)\n\n new_distance_array_levenshtein = matcher1.match(name_array).sort\n new_longest_subseq_array = matcher2.match(name_array).sort.reverse\n\n if new_distance_array_levenshtein[0] < distance_levenshtein and new_longest_subseq_array[0] >= longest_subseq\n word = item.name\n distance_levenshtein = new_distance_array_levenshtein[0]\n longest_subseq = new_longest_subseq_array[0]\n end\n\n }\n\n if distance_levenshtein <= 3 and longest_subseq >=2\n self.closest_string = word\n end\n\n end",
"def min_distance(word1, word2)\n dp = Array.new(word1.size + 1) { Array.new(word2.size + 1) }\n \n for i in 0...dp.size\n dp[i][0] = i \n end\n for j in 0...dp[0].size\n dp[0][j] = j\n end\n \n for i in 1...dp.size\n for j in 1...dp[0].size\n if word1[i - 1] == word2[j - 1]\n dp[i][j] = dp[i-1][j-1]\n else\n dp[i][j] = [\n dp[i - 1][j],\n dp[i][j - 1],\n dp[i - 1][j - 1],\n ].min + 1\n end\n end\n end\n \n dp[-1][-1]\nend",
"def nonCacheEditDistance(word1, word2)\n if (defined?(MAX_LEVENSHTEIN_DISTANCE) && MAX_LEVENSHTEIN_DISTANCE)\n return nonCacheEditDistanceHelper(word1, word2, 0, MAX_LEVENSHTEIN_DISTANCE)\n else\n return nonCacheEditDistanceHelper(word1, word2, 0, 999)\n end\n end",
"def for_cs_sake(string)\n words = string.delete(\"!.,?;:\").split(\" \")\n words = words.select { |word| word.include?(\"c\") }\n c_distances = []\n words.each do |word|\n c_distances << find_c_distance(word)\n end\n c_distances\n lowest_c_distance = c_distances.min\n p words.select { |word| find_c_distance(word) == lowest_c_distance }[0]\nend",
"def similar_cells\n prefix = ssdeep.split(':').first.to_i\n prefixes = [prefix, prefix * 2]\n prefixes.push(prefix / 2) unless prefix.odd?\n prefix_where = prefixes.map {|p| \"ssdeep LIKE '#{p}:%'\"}.join(' OR ')\n CodeCell\n .includes(:notebook)\n .where(prefix_where)\n .where.not(id: id)\n .map {|cell| [cell, Ssdeep.compare(ssdeep, cell.ssdeep)]}\n .reject {|_cell, score| score.zero?}\n .sort_by {|_cell, score| -score}\n end",
"def correct(reference_value)\n similarities = []\n\n dictionary.each do |row|\n current_value = row.value\n\n next if current_value.to_s.empty? ||\n (current_value.length > max_length ||\n current_value.length < min_length)\n\n gap = (current_value.length * 100 / reference_value.length)\n next if gap < min_interval || max_interval < gap\n\n # Levenshtein counts the number of edits (insertions, deletions, or\n # substitutions) needed to convert one string to the other.\n # Damerau-Levenshtein is a modified version that also considers\n # transpositions as single edits\n distance = DamerauLevenshtein.distance(reference_value, current_value)\n rank = (1 - (distance.to_f /\n (reference_value.length + current_value.length))).round(2)\n\n similar = case comparison\n when :strict\n distance == threshold\n else\n distance <= threshold\n end\n\n next unless similar\n\n row.distance = distance\n row.rank = rank\n\n similarities << row\n end\n\n similarities\n end",
"def for_fs_sake(string)\n words = string.split\n min_f_distance = nil\n min_f_word = \"\"\n\n words.each do |word|\n current_f_distance = find_f_distance(word)\n if current_f_distance && (min_f_distance.nil? || current_f_distance < min_f_distance)\n min_f_distance = current_f_distance\n min_f_word = word\n end\n end\n\n min_f_word\nend",
"def similarity_to other, threshold = nil\n Babushka::Levenshtein.distance self, other, threshold\n end",
"def edit_distance_similarity (target)\n return 1-(self.edit_distance(target) / [self.length, target.length].max.to_f)\n end",
"def find_closest_distance\n closest_distance = 1\n closest_clusters = [nil, nil]\n\n @clusters.combination(2) do |c|\n dist = c[0].distance_to(c[1])\n if dist < closest_distance\n closest_distance = dist\n closest_clusters = [c[0], c[1]]\n end\n end\n\n return closest_distance, closest_clusters[0], closest_clusters[1]\n end",
"def distance(str1, str2, max_distance = T.unsafe(nil)); end",
"def shortest(word1, word2)\n ans = @M\n for i in @d[word1]\n for j in @d[word2]\n ans = [ans, (i-j).abs].min\n end\n end\n return ans\n end",
"def similar?(a, b) # rubocop:disable Naming/UncommunicativeMethodParamName\n Levenshtein.normalized_distance(a.downcase, b.downcase) < 0.3 # chosen quasi-randomly ;)\n end",
"def edit_distance(str1, str2)\n m = str1.length\n n = str2.length\n\n i = 0\n dp = []\n while i < m do\n j = 0\n while j < n do\n if i == 0\n dp[i][j] = j\n elsif j == 0\n dp[i][j] = i\n elsif str1[i-1] == str2[j-1]\n dp[i][j] = dp[i-1][j-1]\n else\n dp[i][j] = [dp[i-1][j-1], dp[i-1][j], dp[i][j-1] ].min + 1\n end\n j += 1\n end\n i += 1\n end\n puts dp[m][n]\nend",
"def string_distance_chunked(word, phrase, max: 3, th: 3)\n phrase.split(/\\W|_/i).reject{ |chunk| chunk.strip.empty? }.map{ |chunk|\n string_distance(word, chunk, max: max, th: th)\n }.compact.min\nend",
"def transformation_distance(str1, str2)\n # puts \"#{@count += 1}\"\n\n str1,str2 = str1.downcase, str2.downcase\n # Dont need to compute if it has already been computed earlier, return from the aux hash.\n return @aux[\"#{str1}_#{str2}\"] if !(@aux[\"#{str1}_#{str2}\"].nil?)\n\n # if one string is empty, return the length of other string - obviously!\n return (@aux[\"#{str1}_#{str2}\"] = str2.size) if str1.empty?\n return (@aux[\"#{str1}_#{str2}\"] = str1.size) if str2.empty?\n\n \n # reduced_str denotes the last character removed from the original string.\n reduced_str1 = str1.size==1 ? \"\" : str1[0..-2]\n reduced_str2 = str2.size==1 ? \"\" : str2[0..-2]\n\n # Levenshtein algorithm:\n cost = (str1[-1] == str2[-1]) ? 0 : 1\n return (@aux[\"#{str1}_#{str2}\"] = [transformation_distance(reduced_str1,str2) + 1,\n transformation_distance(str1,reduced_str2) + 1,\n transformation_distance(reduced_str1, reduced_str2) + cost].min)\nend",
"def percent_match(other)\n max = [length, other.length].max\n 1.0 - levenshtein_distance_to(other).to_f / max\n end",
"def shortest_string(list_of_words)\n\tshortest_string.each {|x1| x1.length}\n\t\tshortest_string.each {|x2| x2.length.to_i} #iterrates over each string in array, counts the string's length \n\t\tif shortest_string|x1.length| > shortest_string|x2.length| #compares the 2 pulled string lenghts\n\t\t\tshortest_string|x1| , shortest_string|x2| = shortest_string|x2| > shortest_string|x1| #keeps putting the smallest one to the front\n\t\tend\n\t\treturn shortest_string[0] #returns the first stirng in the array which should be the smallest one\nend\n\n# was getting some errors I could not resolve in order to get this to run. ",
"def str_sim(other)\n max = Math.max(self.size, other.size)\n min = (self.size - other.size).abs.to_f\n 1 - (self.levenshtein(other)-min) / (max - min)\n end",
"def shortest_word_in_array(array)\n array.min{ | x, y | x.length <=> y.length }\nend",
"def shortest(word1, word2)\n \n end",
"def similar_two(str, best_dist = 2)\n best_pair = str.first(2)\n # Arbitrarily large distance\n best_so_far = str.map(&:length).max * 42\n\n str.combination(2).each do |a, b|\n next if a.length != b.length\n\n dist = Levenshtein.distance(a, b)\n\n return [a, b] if dist == best_dist\n\n if dist < best_so_far\n best_pair = [a, b]\n best_so_far = dist\n end\n end\n\n best_pair\n end",
"def shortest_string(list_of_words)\n list_of_words.min {|x,y| x.size <=> y.size}\nend",
"def nearest_driver(map,user)\n driver_pos=[]\n\n for i in 0..map.length-1\n for j in 0..map.length-1\n if map[i][j] == \" D \"\n driver_pos << [i,j]\n end\n end\n end\n @driver_pos=driver_pos\n\n nearest_driver_position = driver_pos[0]\n distance = driver_pos[0].zip(user).map { |x| x.reduce(:-).abs }.sum\n\n for i in 1..driver_pos.length-1\n temp = driver_pos[i].zip(user).map { |x| x.reduce(:-).abs }.sum\n if temp < distance\n distance = temp\n nearest_driver_position = driver_pos[i]\n end\n end\n nearest_driver_position\n end",
"def euclidean_distance(s1, s2)\n d2 = 0.0\n get_features.each do |f|\n if s1.has_key? f and s2.has_key? f\n d2 += (s1[f]-s2[f])**2\n end\n end\n \n Math.sqrt(d2)\n end",
"def str_distance(str1, str2)\n end",
"def str_distance(str1, str2)\n end",
"def get_distance(s1, s2)\n a1 = s1.split(//)\n a2 = s2.split(//)\n\n max, min = s1.size > s2.size ? [a1, a2] : [a2, a1]\n\n range = [(max.size / 2 - 1), 0].max\n indexes = Array.new(min.size, -1)\n flags = Array.new(max.size, false)\n\n matches = 0\n (0...min.size).each do |mi|\n c1 = min[mi]\n ([mi - range, 0].max...[mi + range + 1, max.size].min).each do |i|\n next unless !flags[i] && c1 == max[i]\n\n indexes[mi] = i\n flags[i] = true\n matches += 1\n break\n end\n end\n\n ms1 = Array.new(matches, nil)\n ms2 = Array.new(matches, nil)\n\n si = 0\n (0...min.size).each do |i|\n if indexes[i] != -1\n ms1[si] = min[i]\n si += 1\n end\n end\n\n si = 0\n (0...max.size).each do |i|\n if flags[i]\n ms2[si] = max[i]\n si += 1\n end\n end\n\n transpositions = 0\n (0...ms1.size).each do |mi|\n transpositions += 1 if ms1[mi] != ms2[mi]\n end\n\n prefix = 0\n (0...min.size).each do |mi|\n prefix += 1 if s1[mi] == s2[mi]\n break unless s1[mi] == s2[mi]\n end\n\n if 0 == matches\n 0.0\n else\n m = matches.to_f\n t = (transpositions / 2)\n j = ((m / s1.size) + (m / s2.size) + ((m - t) / m)) / 3.0\n return j < THRESHOLD ? j : j + [0.1, 1.0 / max.size].min * prefix * (1 - j)\n end\n end",
"def similarity(user, row)\n (user.transpose.dot(row.transpose)) / (row.norm * user.norm)\nend",
"def shortest_string(list_of_words)\n list_of_words.min { |a, b| a.size <=> b.size }\nend",
"def test_separator_distance_immunity\n assert_score 0.5768, 'abc/d', 'axxbcx/dxxxxxx'\n assert_score 0.5262, 'abc/d', 'axxbcx/xxxxbc/dxxxxxx'\n end",
"def full_row_distance\n @full_row_distance ||= compute_distance\n end",
"def shortest(word1, word2)\n word1_indices = @hash[word1]\n word2_indices = @hash[word2]\n\n dis = @size\n i, j = 0, 0\n while word1_indices[i] && word2_indices[j]\n dis = [dis, (word1_indices[i] - word2_indices[j]).abs].min\n if word1_indices[i] < word2_indices[j]\n i += 1\n else\n j += 1\n end\n end\n\n return dis\n end",
"def find(str1, str2)\n min_distance = 999\n return min_distance unless @hash.has_key?(str1) && @hash.has_key?(str2)\n\n pos1, pos2 = @hash[str1], @hash[str2]\n # Given two sorted arrays of equal length, how do you find a\n # pair of numbers, one from each array, such that the absolute\n # difference between the two numbers is minimum.\n\n i, j = 0, 0\n until i == pos1.size || j == pos2.size\n diff = (pos1[i] - pos2[j]).abs\n min_distance = diff if diff < min_distance\n if pos1[i] < pos2[j]\n i += 1\n else\n j += 1\n end\n end\n\n min_distance\n end",
"def string_distance_list_mixed(word, list, min: 1, max: 3, max2: 2, th: 3, soft_limit: 10, hard_limit: 20)\n matches1 = string_distance_list(word, list, max: max, th: th, chunked: false)\n matches2 = string_distance_list(word, list, max: max2, th: th, chunked: true)\n max = [max, max2].max\n matches = (0..max).map{ |i| [i, ((matches1[i] || []) + (matches2[i] || [])).uniq(&:first)] }.to_h\n keepies = matches.select{ |k, v| k <= min }.values.map(&:size).sum\n to_take = [[keepies, soft_limit].max, hard_limit].min\n matches.values.flatten(1).take(to_take)\nend",
"def match_countries\n long = []\n File.readlines(\"data/countries_long_codes.txt\").each do |l|\n t = l.chomp.split(\",\")\n long << {code: t[0], name: t[1]}\n end\n\n short = []\n File.readlines(\"data/countries_short_codes.txt\").each do |l|\n t = l.chomp.split(\",\")\n short << {code: t[0], name: t[1]}\n end\n\n countries = []\n long.each do |x|\n min = 1000\n match = short[0]\n short.each do |y|\n d = Levenshtein.distance(x[:name], y[:name])\n if d < min\n min = d\n match = y\n end\n end\n c = {\n name: x[:name],\n names: [],\n long_code: x[:code],\n short_code: match[:code]\n }\n countries << c\n end\n countries\nend",
"def min_match_for_cjk(solr_parameters)\n return unless blacklight_params &&\n blacklight_params[:q].present? &&\n cjk_unigrams_size(blacklight_params[:q]) > 2\n solr_parameters[:mm] =\n calc_min_match_for_cjk(num_non_cjk_tokens(blacklight_params[:q]))\n end",
"def dist_to(operand,k=3)\n matches = 0\n @@counter += 1\n temp_hash = Hash.new\n @word_array[0..k-1].each {|word| temp_hash[word.word] = 1}\n operand.word_array[0..k-1].each {|word| matches += 1 if !temp_hash[word.word].nil? }\n #min_possible_count = [k, @word_array[0..k-1].length, operand.word_array[0..k-1].length].max\n\n dist = k - matches\n #puts \"#{@word_array[0..k-1]}\\n#{operand.word_array[0..k-1]}\\n#{dist}\"\n \n return dist \n end",
"def location_score(*args)\n rows = args.first\n locations = rows.to_hash { |row| [row[0], 1000000] }\n rows.each do |row|\n loc = row[1..row.size].inject(0) { |memo, value| memo += value.to_i; memo }\n if loc < locations[row[0]]\n locations[row[0]] = loc\n end\n end\n \n normalize_scores(locations, true)\n end",
"def for_cs_sake(string)\n string = string.gsub(/[[:punct:]]/, '')\n string = string.split\n string = string.reject { |word| c_distance(word) == nil }\n string.sort_by { |word| c_distance(word) }[0]\n\n #too long\n # closest = \"\"\n # split_string = string.split\n # c_distance = 0\n #\n # (0...split_string.length).each do |idx|\n # next if c_distance(split_string[idx]) == nil\n # if c_distance(split_string[idx]) > c_distance\n # c_distance = c_distance(split_string[idx])\n # closest = split_string[idx]\n # end\n # end\n # closest\nend",
"def string_distance_list(word, list, max: 3, th: 3, chunked: false)\n # Determine if IDs have been provided\n ids = list[0].is_a?(Array)\n # Sort and group by distance, rejecting invalids\n list = list.each_with_index.map{ |n, i|\n if chunked\n [string_distance_chunked(word, ids ? n[1] : n, max: max, th: th), n]\n else\n [string_distance(word, ids ? n[1] : n, max: max, th: th), n]\n end\n }\n .reject{ |d, n| d.nil? || d > max || (!th.nil? && (d - (ids ? n[1] : n).length).abs < th) }\n .group_by{ |d, n| d }\n .sort_by{ |g| g[0] }\n .map{ |g| [g[0], g[1].map(&:last)] }\n .to_h\n # Complete the hash with the distance values that might not have appeared\n # (this allows for more consistent use of the list, e.g., when zipping)\n (0..max).each{ |i| list[i] = [] if !list.key?(i) }\n list\nend",
"def linear_distance(tile_a, tile_b)\n x1, y1 = tile_a.x, tile_a.y\n x2, y2 = tile_b.x, tile_b.y\n Math.sqrt((x2 - x1)**2 + (y2 - y1)**2).abs\n end",
"def str_distance(str1, str2)\n return @str_cache[str1][str2] if @str_cache[str1][str2]\n return str1.length if str2.nil?\n return str2.length if str1.nil?\n\n if str1 == str2\n @str_cache[str1][str2] = 0\n return 0\n end\n\n if str1[0] == str2[0]\n @str_cache[str1][str2] = str_distance(str1[1..-1], str2[1..-1])\n else\n replace_dist = 1 + str_distance(str1[1..-1], str2[1..-1])\n delete_dist = 1 + str_distance(str1[1..-1], str2)\n insert_dist = 1 + str_distance(str1, str2[1..-1])\n @str_cache[str1][str2] = [replace_dist, delete_dist, insert_dist].min\n end\n @str_cache[str1][str2]\n end",
"def closest_pair1(points)\n min_distance = Float::MAX\n best_pair = nil\n (0...points.length).each do |i|\n (i...points.length).each do |j|\n if i != j\n curr_distance = distance1(points[i], points[j])\n if curr_distance < min_distance\n min_distance = curr_distance\n best_pair = [points[i], points[j]]\n end\n end\n end\n end\n best_pair\nend",
"def suggest_fuzzy(str, results=@max_results, strict=@strict_fuzzy_matching)\n str_mul = alphabet_only(str).size\n str_soundex_code = compute_soundex_code(str)\n str_2grams = ngram_list(str, 2)\n candidates = []\n\n @ngrams.sunion(*ngram_list(str)).each do |candidate|\n candidate = candidate.split(\":\")\n candidate_str = candidate[0]\n candidate_soundex_code = candidate[1]\n candidate_score = 1.0\n\n # Levenshtein distance\n lev_dist = Levenshtein.distance(str, candidate_str)\n candidate_score *= Math.exp([str_mul - lev_dist, 1].max)\n\n # Soundex\n if str_soundex_code == candidate_soundex_code\n candidate_score *= str_mul\n elsif str_soundex_code[1..-1] == candidate_soundex_code[1..-1]\n candidate_score *= (str_mul / 2).ceil\n end\n\n # Compute n-grams of size 2 shared between the two strings\n same_2grams = str_2grams & ngram_list(candidate_str, 2)\n candidate_score *= Math.exp(same_2grams.size)\n\n if candidate_score > 1\n candidates << {\n str: candidate_str,\n score: candidate_score\n }\n end\n end\n # Sort results by score and return the highest scoring candidates\n candidates = candidates.sort { |a, b| b[:score] <=> a[:score] }\n # puts candidates.take(10).map { |cand| \"#{cand[:str]} => #{cand[:score]}\" }\n # If strict fuzzy matching is used, only suggestion items with scores\n # above a certain threshold will be returned.\n if strict\n suggestions = []\n candidates.each do |cand|\n # threshold ||= candidates[0][:score] / 10\n threshold = Math.exp(str.size)\n break if suggestions.size > results || cand[:score] < threshold\n suggestions << cand\n end\n else\n suggestions = candidates.take(results)\n end\n return suggestions.map { |cand| cand[:str] }\n end",
"def jaro_winkler_distance(s1, s2, long_tolerance = false)\n result = C::jaro_winkler_distance(s1, s2, long_tolerance)\n raise(\"memory allocation error\") if result < 0.0\n result\n end",
"def distance(str1, str2)\n\t\twords1 = str1.downcase.split\n\t\twords2 = str2.downcase.split\n\t\tlen1 = words1.count.to_f\n\t\tlen2 = words2.count.to_f\n\t\tadded = (words2 - words1).count.to_f\n\t\tkept = len1 - (words1 - words2).count.to_f\n\t\treturn 0 if kept == 0\n\t\td = kept/len1\n\t\td *= 1 - (added/len2) unless added == 0\n\t\treturn d\n\tend",
"def calculate_distance(vals1, vals2)\n vals1_sum = vals1.inject(:+)\n vals2_sum = vals2.inject(:+)\n\n (0..11).map { |i| ((vals1[i].to_f/vals1_sum)-(vals2[i].to_f/vals2_sum))**2 }.inject(:+)\nend",
"def shortest_distance()\n min = 1000000\n s = \"\"\n @edges.each do |city, dests|\n dests.each do |dest|\n if min > dest.distance\n min = dest.distance\n s = \"#{city} to #{dest.name}\"\n end\n end\n end\n \"Shortest distance is #{min} from #{s}\"\n end",
"def score\n @score ||= phonetic_levenshtein_distance + penalties\n end",
"def closest_s(v)\n @nodes_s.map { |s| [s, v.distance_to(s)] }.min_by { |a| a[1] }.first\n end",
"def hamming_distance str1, str2\n result = 0\n \n str1.split('').each_index do |i|\n result += 1 if str1[i] != str2[i]\n end\n\n p result\nend",
"def euclidean_distance(a, b)\n Math.sqrt ( a.zip(b).map { |n| n.reduce(:-) }.map { |n| n**2 }.reduce(:+) )\nend",
"def corrections\n candidates = paths.flat_map(&:all_template_paths).uniq\n\n if partial\n candidates.select!(&:partial?)\n else\n candidates.reject!(&:partial?)\n end\n\n # Group by possible prefixes\n files_by_dir = candidates.group_by(&:prefix)\n files_by_dir.transform_values! do |files|\n files.map do |file|\n # Remove prefix\n File.basename(file.to_s)\n end\n end\n\n # No suggestions if there's an exact match, but wrong details\n if prefixes.any? { |prefix| files_by_dir[prefix]&.include?(path) }\n return []\n end\n\n cached_distance = Hash.new do |h, args|\n h[args] = -DidYouMean::Jaro.distance(*args)\n end\n\n results = Results.new(6)\n\n files_by_dir.keys.index_with do |dirname|\n prefixes.map do |prefix|\n cached_distance[[prefix, dirname]]\n end.min\n end.sort_by(&:last).each do |dirname, dirweight|\n # If our directory's score makes it impossible to find a better match\n # we can prune this search branch.\n next unless results.should_record?(dirweight - 1.0)\n\n files = files_by_dir[dirname]\n\n files.each do |file|\n fileweight = cached_distance[[path, file]]\n score = dirweight + fileweight\n\n results.add(File.join(dirname, file), score)\n end\n end\n\n if partial\n results.to_a.map { |res| res.sub(%r{_([^/]+)\\z}, \"\\\\1\") }\n else\n results.to_a\n end\n end",
"def best_cruise_column_for_query(query, col_multiplier={})\n cur_max = 0\n best_column = nil\n for column in @@cruise_columns\n next if column == 'id'\n ncruises = Cruise.count(:all, :conditions => [\"`#{column}` regexp ?\", query])\n multiplier = col_multiplier[column] || 1\n if ncruises * multiplier > cur_max\n cur_max = ncruises\n best_column = column\n end\n end\n contacts = Contact.find(:all, :conditions => [\"LastName LIKE ?\", query])\n for contact in contacts\n count = contact.cruises.length\n if count > cur_max\n cur_max = count\n best_column = 'Chief_Scientist'\n end\n end\n\n best_column || 'Group'\n end",
"def min_distance_away(truth_points, up)\n truth_points.inject([]){|arr, p| arr << [up.sqd_distance(p), p]; arr}.min{|a, b| a.first <=> b.first}\n end",
"def gmaps_distance(row, index)\n row[:elements][index] ? row[:elements][index][:distance][:value] : 0\n end",
"def edit_distance_dp(str1, str2, m, n)\n\n mtrx = Array.new(m+1){Array.new(n+1)}\n\n mtrx[0][0] = 0\n\n for i in 1...m+1\n mtrx[i][0] = i\n end\n\n for i in 1...n+1\n mtrx[0][i] = i\n end\n\n for i in 1...m+1\n for j in 1...n+1\n\n if(str1[i-1] == str2[j-1])\n mtrx[i][j] = mtrx[i-1][j-1]\n else\n mtrx[i][j] = [mtrx[i-1][j-1], mtrx[i-1][j], mtrx[i][j-1]].min + 1\n end\n\n end\n end\n\n puts mtrx[m][n]\n\nend",
"def closest_points(points)\n distances = points.map { |point| [manhattan_distance(point), point] }\n distance_hash = Hash[distances.group_by(&:first).map { |k, a| [k, a.map(&:last)] }]\n # p distance_hash\n # p distance_hash.keys.min\n distance_hash[distance_hash.keys.min]\n end",
"def closest_match(token, library, cache)\n if cache.has_key?(token)\n return cache[token]\n end\n closest_tokens = []\n closest_token_score = 999\n library.each do |entity|\n ld_score = levenshtein_distance(token, entity)\n if ld_score < closest_token_score\n closest_token_score = ld_score\n closest_tokens = [entity]\n elsif ld_score == closest_token_score\n closest_tokens << entity\n end\n end\n cache[token] = {closest_token_score => closest_tokens}\n {closest_token_score => closest_tokens}\nend",
"def shortest_string(list_of_words)\n\n for x in 0..list_of_words.length - 1\n if x == 0\n currentSmallest = list_of_words[x]\n else\n if list_of_words[x].length < currentSmallest.length\n currentSmallest = list_of_words[x]\n end\n end\n end\n\n return currentSmallest\nend",
"def find_most_similar(term)\n\n match_scores = @words.map { |word|\n\n index = 0\n possibilities = [term.dup]\n\n while index < word.length\n new_possibilities = []\n possibilities.each { |poss|\n\n if word[index] == poss[index]\n new_possibilities.push(poss.dup)\n else\n # '!' stands for inserted character'\n # '?' stands for replaced character'\n char_inserted = poss.dup.insert(index, '!')\n char_replaced = poss.dup\n char_replaced[index] = '?'\n new_possibilities.push(char_inserted)\n new_possibilities.push(char_replaced)\n end\n\n }\n\n possibilities = new_possibilities\n index += 1\n\n end\n\n possibilities.map { |poss|\n\n poss.scan(/\\?/).count + poss.scan(/!/).count\n }.min\n }\n\n return @words[match_scores.index(match_scores.min)]\n\n end",
"def compute_smallest_edit_distance(eval_stream, ref_stream)\n m_sz, n_sz = eval_stream.size, ref_stream.size\n arr = Matrix.build(n_sz+1, m_sz+1) do |row, col|\n if row == 0\n col\n elsif col == 0\n row\n else\n 0\n end\n end.to_a\n puts \"[INFO] DP Matrix generated: #{arr.size} x #{arr.first.size}\"\n progress_dots = 0\n puts \"[INFO] Start computing\"\n for j in 1..m_sz\n for i in 1..n_sz\n replace_cost = arr[i-1][j-1] + (eval_stream[j] == ref_stream[i] ? 0 : 1)\n insert_cost = arr[i][j-1] + 1\n delete_cost = arr[i-1][j] + 1\n arr[i][j] = [replace_cost, insert_cost, delete_cost].min\n end\n print \".\"\n progress_dots += 1\n print \" #{(progress_dots.to_f/m_sz * 100).round(3)}%\\n\" if (0 == progress_dots % ProgressDotsPerLine)\n end\n print \"\\n\"\n arr[n_sz][m_sz]\nend",
"def n_squared(fish)\n long_boi = \"\"\n fish.each_with_index do |fish1, idx1|\n fish.each_with_index do |fish2, idx2|\n if idx2 > idx1\n long_boi = fish2 if fish2.length > fish1.length\n end\n end\n end\n long_boi\nend",
"def score(s, d)\n i, j, k = deflate(s).length, deflate(d).length, deflate(s + d).length\n # how to calculate significance of similarity?\n k < (i + j)\n end",
"def resolve_duplicates(rows_as_strings)\n\trows_as_arrays = rows_as_strings.map{|row| row.split(' ')}\n\tmerged_row = rows_as_arrays.first[0..10] # first 11 elements are selected from the first row\n\t(11..rows_as_arrays.first.length-1).each do |col_idx|\n\t\talleles = []\n\t\trows_as_arrays.each do |row|\n\t\t\talleles << row[col_idx]\n\t\tend\n\t\tmerged_allele = resolve_alleles(alleles)\n\t\tmerged_row << merged_allele\n\tend\n\treturn merged_row.join(\" \")\nend",
"def shortest_string(list_of_words)\n\treturn list_of_words.min{|a,b| a.size <=> b.size}\nend",
"def distance(arrListe)\n km = 0\n arrListe.each_with_index do |val, index|\n km += dist @poi[val], @poi[arrListe[index.next]] unless arrListe[index.next] == nil\n end\n return km.round(3)\n end",
"def longest_distance()\n max = 0\n s = \"\"\n @edges.each do |city, dests|\n dests.each do |dest|\n if max < dest.distance\n max = dest.distance\n s = \"#{city} to #{dest.name}\"\n end\n end\n end\n \"Longest distance is #{max} from #{s}\"\n end",
"def shortest_word_in_array(array)\n array.min_by{|word|word.length}\nend",
"def analogy(a, b, c, word_to_id, id_to_word, word_matrix, top: 5, answer: nil)\n all_found = true\n [a, b, c].each do |word|\n unless word_to_id.include?(word)\n puts(\"#{word} not found.\")\n all_found = false\n end\n end\n\n return unless all_found\n\n puts(\"\\n[analogy] #{a}:#{b} = #{c}:?\")\n a_vec = word_matrix[word_to_id[a], true]\n b_vec = word_matrix[word_to_id[b], true]\n c_vec = word_matrix[word_to_id[c], true]\n query_vec = b_vec - a_vec + c_vec\n query_vec = normalize(query_vec)\n\n similarity = word_matrix.dot(query_vec).to_a\n\n if answer\n puts(\"===>#{answer}:#{word_matrix[word_to_id[answer]].dot(query_vec)}\")\n end\n\n count = 0\n\n sorted_indexes = similarity.map.with_index.sort.map(&:last).reverse\n\n sorted_indexes.each do |i|\n # TODO: Deal with NaNs\n next if [a, b, c].include?(id_to_word[i])\n\n puts(\" #{id_to_word[i]}: #{similarity[i]}\")\n\n count += 1\n break if count >= top\n end\nend"
] | [
"0.69780916",
"0.68045384",
"0.6780291",
"0.66444075",
"0.6601021",
"0.65644115",
"0.6548052",
"0.6448385",
"0.6367415",
"0.6362948",
"0.63607544",
"0.6348901",
"0.62991655",
"0.6265237",
"0.6261299",
"0.62290937",
"0.6214679",
"0.6208014",
"0.6188738",
"0.61671233",
"0.61473787",
"0.61431044",
"0.6114349",
"0.60814863",
"0.606152",
"0.6050232",
"0.6043155",
"0.5721781",
"0.5713488",
"0.56130624",
"0.55832124",
"0.5573491",
"0.5521842",
"0.5501271",
"0.54846776",
"0.5452847",
"0.5448832",
"0.54342043",
"0.5412796",
"0.5404499",
"0.5370672",
"0.5368627",
"0.5354895",
"0.5345012",
"0.53229463",
"0.52967167",
"0.524867",
"0.52222806",
"0.5176582",
"0.51728064",
"0.5151766",
"0.5140392",
"0.51282585",
"0.5123409",
"0.51129955",
"0.51129955",
"0.51085687",
"0.50719804",
"0.50560516",
"0.50422937",
"0.50366795",
"0.5028119",
"0.501614",
"0.49599463",
"0.49569964",
"0.49326208",
"0.49283424",
"0.49280542",
"0.49221987",
"0.490425",
"0.4892571",
"0.48869866",
"0.4886943",
"0.48720837",
"0.48632905",
"0.48631853",
"0.48619938",
"0.4854251",
"0.4844432",
"0.48385534",
"0.4828389",
"0.48265648",
"0.481747",
"0.4810109",
"0.47961253",
"0.47944102",
"0.47851938",
"0.47805128",
"0.47787583",
"0.47744784",
"0.47648647",
"0.4763228",
"0.4759593",
"0.47579283",
"0.47533154",
"0.474805",
"0.47429958",
"0.47410908",
"0.47387752",
"0.471613"
] | 0.7554327 | 0 |
TEMPORARY PATCH TO GET THE GRID ROW FILTER FUNCTION. NEED TO REVIEW THIS. Implementation for the "get_data" endpoint | def get_data(*args)
params = args.first || {} # params are optional!
params["limit"] = nil if (params.empty? == false and config[:enable_pagination] == false)
session_name = (config[:item_id].to_s + "_filter").to_sym
if (params[:filter1] || component_session[session_name])
component_session[session_name] = params[:filter1] || component_session[session_name]
params[:filter] = component_session[session_name]
end
if !config[:prohibit_read]
{}.tap do |res|
records = get_records(params)
res[:data] = records.map{|r| r.netzke_array(columns(:with_meta => true))}
res[:total] = count_records(params) if config[:enable_pagination]
end
else
flash :error => "You don't have permissions to read data"
{ :netzke_feedback => @flash }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prepare_data_for_filters\n self.data_grid.columns.each do |col|\n next if col.filter.nil? # if no filter\n\n # Prepare auto filters\n if col.filter == :auto\n self.data_grid.in_data.each do |d|\n if col.sort_by.class == Symbol\n col.filter_data << d.send(col.sort_by)\n else\n # Call lambda\n col.filter_data << col.field.call(d, self.data_grid)\n end\n end\n\n col.filter_data.uniq!\n col.filter_data.sort!\n end\n end\n end",
"def prepare_orm_filters\n filters = [[]]\n date_format = I18n.t(:\"date.formats.default\", {:locale => I18n.locale })\n self.data_grid.columns.each_with_index do |col, col_index|\n if col.filter and !col.filter_value.blank?\n case col.filter\n when :boolean\n filters[0] << \"#{col.filter_by} = ?\"\n filters << (col.filter_value == '1') ? true : false\n when :auto\n filters[0] << \"#{col.filter_by} = ?\"\n filters << col.filter_value\n when :text\n filters[0] << \"#{col.filter_by} #{ActiveRecord::Base.connection.adapter_name.downcase.to_sym == :postgresql ? 'ILIKE' : 'LIKE'} ?\"\n filters << \"%#{col.filter_value}%\"\n when :number\n filters[0] << \"#{col.filter_by} = ?\"\n filters << col.filter_value.to_i\n when :range\n range = col.filter_value.split(DataGrid.range_separator)\n\n if !range[0].blank? and !range[1].blank?\n begin\n range[0] < 2\n rescue\n range[0] = range[0].to_f\n range[1] = range[1].to_f\n end\n filters[0] << \"#{col.filter_by} >= ? AND #{col.filter_by} <= ?\"\n filters << range[0]\n filters << range[1]\n elsif range[0].blank? and !range[1].blank?\n begin\n range[1] < 2\n rescue\n range[1] = range[1].to_f\n end\n filters[0] << \"#{col.filter_by} <= ?\"\n filters << range[1]\n elsif range[1].blank? and !range[0].blank?\n begin\n range[0] < 2\n rescue\n range[0] = range[0].to_f\n end\n filters[0] << \"#{col.filter_by} >= ?\"\n filters << range[0]\n end\n\n when :date\n range = col.filter_value.split(DataGrid.range_separator)\n\n if !range[0].blank? and !range[1].blank?\n begin\n range[0] < 2\n rescue\n range[0] = DateTime.strptime(range[0], date_format)\n range[1] = DateTime.strptime(range[1], date_format)\n end\n filters[0] << \"#{col.filter_by} >= ? AND #{col.filter_by} <= ?\"\n filters << range[0]\n filters << range[1]\n elsif range[0].blank? and !range[1].blank?\n begin\n range[1] < 2\n rescue\n range[1] = DateTime.strptime(range[1], date_format)\n end\n filters[0] << \"#{col.filter_by} <= ?\"\n filters << range[1]\n elsif range[1].blank? and !range[0].blank?\n begin\n range[0] < 2\n rescue\n range[0] = DateTime.strptime(range[0], date_format)\n end\n filters[0] << \"#{col.filter_by} >= ?\"\n filters << range[0]\n end\n end\n end\n end\n \n filters[0] = filters[0].join(' AND ')\n filters\n end",
"def wire_filters(table = @jqgrid_id)\n filter_partial = url_for_event(:filterDisplay)\n subfilter_open = url_for_event(:setFilter)\n filter_counts = url_for_event(:filterCounts)\n javascript_tag <<-JS\n jQuery('##{table}_filters').load('#{filter_partial}', function() {\n jQuery(this).find('input[type=checkbox]').click(function() {\n var options = {\n dataType:'script'\n }\n jqgw_beginReq('##{table}');\n jQuery(this).closest('form').ajaxSubmit(options); // uses jQuery Form plugin\n return true;\n });\n jQuery('##{table}_filters').find('.jqgw-filter-category')\n .hover(function(){jQuery(this).addClass('ui-state-hover');},\n \t\t function(){jQuery(this).removeClass('ui-state-hover');})\n .click(function() {\n jqgw_beginReq('##{table}');\n jQuery.getScript('#{subfilter_open}&catid='+jQuery(this).attr('id'));\n });\n jQuery.getScript('#{subfilter_open}&init=yes'); // open the default filter\n jQuery.getScript('#{filter_counts}'); // fill in the filter counts\n });\n JS\n end",
"def get_a_heat_image_given_its_floorplan_id_and_filter_parameters(args = {}) \n get(\"/resource.json/heat/#{args[:floorplanId]}/#{args[:filename]}\", args)\nend",
"def get_data_by_filters(filters, csv)\r\n\r\n filters_a = filters.to_s.split(',')\r\n csv_tmp = Array.new\r\n csv_tmp = csv\r\n\r\n for i in 0..(filters_a.size - 1)\r\n\r\n filter = filters_a[i].to_s.downcase.strip\r\n filter_data = get_filter_data filter\r\n #The array is cleaned\r\n data_filtered = Array.new\r\n\r\n csv_tmp.each_with_index do |(record), index|\r\n\r\n #Add csv headers\r\n if index == 0\r\n #data_filtered.push(record)\r\n end\r\n\r\n case filter_data[:operador].to_s.strip\r\n when '='\r\n if record[filter_data[:key].to_s.to_sym] == filter_data[:value].to_s\r\n data_filtered.push(record)\r\n end\r\n when '!='\r\n if record[filter_data[:key].to_s.to_sym] != filter_data[:value].to_s\r\n data_filtered.push(record)\r\n end\r\n when '>'\r\n if record[filter_data[:key].to_s.to_sym].to_s.to_f > filter_data[:value].to_s.to_f\r\n data_filtered.push(record)\r\n end\r\n when '>='\r\n if record[filter_data[:key].to_s.to_sym].to_s.to_f >= filter_data[:value].to_s.to_f\r\n data_filtered.push(record)\r\n end\r\n when '<'\r\n if record[filter_data[:key].to_s.to_sym].to_s.to_f < filter_data[:value].to_s.to_f\r\n data_filtered.push(record)\r\n end\r\n when '<='\r\n if record[filter_data[:key].to_s.to_sym].to_s.to_f <= filter_data[:value].to_s.to_f\r\n data_filtered.push(record)\r\n end\r\n when 'contains'\r\n if record[filter_data[:key].to_s.to_sym].to_s.downcase.include? filter_data[:value].to_s.downcase\r\n data_filtered.push(record)\r\n end\r\n end\r\n\r\n end\r\n\r\n #The data of the 1st filter is added to 'csv_tmp' to reduce the filtered records\r\n csv_tmp = data_filtered\r\n\r\n end\r\n\r\n return data_filtered\r\n\r\nend",
"def prepare_data\n initial_data_eval \n initial_sorting if self.data_grid.sorting?\n filter\n global_summary_array\n pagination\n summary_array\n self.data_grid.row_styler\n prepare_data_for_filters\n end",
"def preview\n get_filtered_dataset false, 10\n end",
"def data_grid_filter(data_grid, column)\n hidden_submit_input = '<input type=\"submit\" value=\"\" style=\"width:0px; height: 0px; border: none; padding: 0px; font-size: 0px\">'.html_safe\n output = ''\n col_index = data_grid.columns.index(column)\n case column.filter\n when :boolean\n filter_select_name = \"filter_#{data_grid.name}_#{col_index}\"\n base_url = url_for(data_grid.params.merge(filter_select_name => nil))\n output = select_tag(filter_select_name,\n options_for_select([[I18n.t('data_grid.all_options'), ''], [I18n.t('data_grid.option_true'), '1'], [I18n.t('data_grid.option_false'), '0']], column.filter_value),\n :onchange => \"window.location.href='#{base_url}#{(base_url.include?('?')) ? '&' : '?' }#{filter_select_name}=' + this.value\")\n when :auto\n filter_select_name = \"filter_#{data_grid.name}_#{col_index}\"\n base_url = url_for(data_grid.params.merge(filter_select_name => nil))\n output = select_tag(filter_select_name,\n options_for_select([[I18n.t('data_grid.all_options'), '']] + column.filter_data.map{|fd| [column.auto_filter_hash.nil? ? fd : column.auto_filter_hash[fd.to_s.to_sym], fd]}, column.filter_value),\n :onchange => \"window.location.href='#{base_url}#{(base_url.include?('?')) ? '&' : '?' }#{filter_select_name}=' + this.value\")\n \n when :text\n filter_input_name = \"filter_#{data_grid.name}_#{col_index}\"\n base_url = url_for(data_grid.params.merge(filter_input_name => nil))\n output = form_tag(base_url, :method => 'GET') do\n text_field_tag(filter_input_name, column.filter_value) + \n data_grid_dump_as_hidden_fields(data_grid, [filter_input_name]) + \n hidden_submit_input\n end\n when :number\n filter_input_name = \"filter_#{data_grid.name}_#{col_index}\"\n base_url = url_for(data_grid.params.merge(filter_input_name => nil))\n output = form_tag(base_url, :method => 'GET') do\n text_field_tag(filter_input_name, column.filter_value, :class => 'data_grid_filter_input') + \n data_grid_dump_as_hidden_fields(data_grid, [filter_input_name]) + \n hidden_submit_input\n end\n when :range\n filter_input_name_from = \"filter_#{data_grid.name}_#{col_index}_from\"\n filter_input_name_to = \"filter_#{data_grid.name}_#{col_index}_to\"\n base_url = url_for(data_grid.params.merge(filter_input_name_from => nil, filter_input_name_to => nil))\n output = form_tag(base_url, :method => 'GET') do\n data_grid_dump_as_hidden_fields(data_grid, [filter_input_name_from, filter_input_name_to]) + \n text_field_tag(filter_input_name_from, column.filter_value.to_s.split(DataGrid.range_separator)[0], :class => 'data_grid_filter_input') + \n ' - ' + \n text_field_tag(filter_input_name_to, column.filter_value.to_s.split(DataGrid.range_separator)[1], :class => 'data_grid_filter_input') +\n hidden_submit_input\n end\n \n when :date \n date_format = I18n.t(:\"date.formats.default\", {:locale => I18n.locale })\n filter_input_name_from = \"filter_#{data_grid.name}_#{col_index}_from\"\n filter_input_name_to = \"filter_#{data_grid.name}_#{col_index}_to\"\n form_id = \"filter_#{data_grid.name}_#{col_index}_form\"\n \n base_url = url_for(data_grid.params.merge(filter_input_name_from => nil, filter_input_name_to => nil))\n output = \"<form method='get' action='#{base_url}' id='#{form_id}'>\"\n output << data_grid_dump_as_hidden_fields(data_grid, [filter_input_name_from, filter_input_name_to])\n \n date_picker, datepicker_placeholder_id, trigger_id, dom_id, date_span_id = select_date_datetime_common(\n {:id => \"filter_#{data_grid.name}_#{col_index}_from\", :name => filter_input_name_from}, data_grid.params[filter_input_name_from], form_id)\n\n output << \"#{I18n.t('data_grid.filter_date_from')}: <span id=\\\"#{datepicker_placeholder_id}\\\">#{date_picker}</span>\"\n output << %(<script type=\"text/javascript\">\\n)\n output << %( Calendar.setup\\({\\n)\n output << %( button : \"#{trigger_id}\",\\n )\n output << %( ifFormat : \"#{date_format}\",\\n )\n output << %( inputField : \"#{dom_id}\",\\n )\n output << %( include_blank : true,\\n )\n output << %( singleClick : true,\\n)\n output << %( onClose : function(cal){handleCalendarClose(cal, \"#{dom_id}\", \"#{form_id}\");}\\n)\n output << %( }\\);\\n)\n output << %(</script><br />\\n)\n \n date_picker, datepicker_placeholder_id, trigger_id, dom_id, date_span_id = select_date_datetime_common(\n {:id => \"filter_#{data_grid.name}_#{col_index}_to\", :name => filter_input_name_to}, data_grid.params[filter_input_name_to], form_id)\n\n output << \"#{I18n.t('data_grid.filter_date_to')}: <span id=\\\"#{datepicker_placeholder_id}\\\">#{date_picker}</span>\"\n output << %(<script type=\"text/javascript\">\\n)\n output << %( Calendar.setup\\({\\n)\n output << %( button : \"#{trigger_id}\",\\n )\n output << %( ifFormat : \"#{date_format}\",\\n )\n output << %( inputField : \"#{dom_id}\",\\n )\n output << %( include_blank : true,\\n )\n output << %( singleClick : true,\\n)\n output << %( onClose : function(cal){handleCalendarClose(cal, \"#{dom_id}\", \"#{form_id}\");}\\n)\n output << %( }\\);\\n)\n output << %(</script>\\n)\n \n output << hidden_submit_input\n output << '</form>'\n \n else\n output = ' '\n end\n\n raw output\n end",
"def apply_filter(data, filter_model)\n filter_type = filter_model.filter_type\n variable_name = filter_model.variable_name;\n value1 = filter_model.value1\n value2 = filter_model.value2\n\n case filter_type\n when 'equals'\n filter_hash = Hash.new\n filter_hash[variable_name] = value1\n data = data.where(filter_hash)\n\n when 'not_equals'\n filter_hash = Hash.new\n filter_hash[variable_name] = value1\n data = data.where.not(filter_hash)\n\n when 'greater_than'\n data = data.where(\"#{variable_name} > ?\", value1)\n\n when 'greater_than_or_equal'\n data = data.where(\"#{variable_name} >= ?\", value1)\n\n when 'less_than'\n data = data.where(\"#{variable_name} < ?\", value1)\n\n when 'less_than_or_equal'\n data = data.where(\"#{variable_name} <= ?\", value1)\n\n when 'from_to'\n data = data.where(\"#{variable_name} >= ? AND #{variable_name} <= ?\", value1, value2)\n\n else\n data\n end\n end",
"def get_filtered_data(data)\n self.get_filter_backends.each do |filter_class|\n filter = filter_class.new(controller: self)\n data = filter.get_filtered_data(data)\n end\n\n return data\n end",
"def get_value(table, field_val, field_ftr, filter_val)\n #print filter_val\n sql_statement = \"SELECT \" + field_val + \" FROM \" + table + \" WHERE \" + \\\n field_ftr + \" = '\" + filter_val + \"';\"\n db = get_db()\n stm = db.prepare sql_statement\n rs = stm.execute\n retun_val = nil\n rs.each do |row|\n retun_val = row[field_val]\n end\n return retun_val\nend",
"def datasource_params\n {\n # We want to make sure we don't load the collection record, but only\n # records that belong to that collection record.\n fq: 'sm_collection_code:theliberator',\n\n rows: rows,\n sort: 'id asc',\n start: start,\n wt: 'json'\n }\n end",
"def show_row\n @dataset = Dataset.find(params[:dataset_id])\n if params[:row_id].gsub(/[0-9]/,\"\").length == 0 #il n'y a que des chiffres\n @data = ActiveRecord::Base.connection.select_one(\"SELECT * from dataset_#{@dataset.id} WHERE id = #{params[:row_id]} LIMIT 1\")\n render :inline => @data.to_json \n else\n render :text => 'Invalid parameters'\n end\n end",
"def index\n @cell_filterings = []\n @project = Project.where(:key => params[:project_key]).first\n\n @cell_filterings = CellFiltering.where(:project_id => @project.id).all\n # get_cluster_data() \n render :partial => 'index'\n end",
"def get_full_data(data)\n case @client.api_version\n when \"1.2\"\n # in this version returned id=>{...}\n result = @client.api_request(:method => \"template.get\", :params => {:filter => data, :output => \"extend\"})\n result.empty? ? [] : result.values \n else\n @client.api_request(:method => \"template.get\", :params => {:filter => data, :output => \"extend\"})\n end\n end",
"def filtered_dataset\n filter_args_from_query.inject(@dataset) do |filter, cond|\n filter.filter(cond)\n end\n end",
"def apply_filter\n offset = (params[:page].to_i - 1) * params[:perpage].to_i\n limit = params[:perpage]\n\n results = get_results(offset, limit)\n result_list = get_fields_to_show(results['elements'])\n \n data = Hash.new\n data['total'] = results['total']\n data['result'] = result_list\n respond_to do |format|\n format.json { render :json => data.to_json }\n end\n end",
"def get_filtered_dataset(count = false, limit = 10000)\n selector = if count\n ' count(*) '\n else\n get_columns_visible_sql\n end\n\n query = \"select #{selector}\"\n query += \" from #{self.api_table_name}\"\n query += ' where ' + get_filters_sql unless self.filters.blank? || JSON.parse(self.filters).blank?\n query += \" limit #{limit}\" if limit\n\n DatasetService.get_filtered_dataset self.dataset_id, query\n end",
"def index\n respond_to do |format|\n format.html\n format.json do\n types = { name: \"string\" }\n custom_field = { name: lambda do |name|\n \"(`items`.`name` like '%#{name}'%)\"\n end\n }\n items = Batch.resolve(current_user).joins(:item)\n items, total = KendoFilter.filter_grid(params,items, types)\n items = items.map do |e|\n {\n id: e.id,\n name: e.item.name,\n item_id: e.item.id,\n batch_count: e.count,\n have_weight: e.item.have_weight,\n last_added: e.created_at,\n price: e.price,\n supplier_price: e.supplier_price,\n amount: e.item.have_weight ? (e.count / 1000) : e.count\n } if e.item\n end\n render json: {data:items, total: total }\n end\n end\n end",
"def filter\n do_authorize_class\n\n filter_response, opts = Settings.api_response.response_advanced(\n api_filter_params,\n Access::ByPermission.dataset_items(current_user, dataset_id: params[:dataset_id]),\n DatasetItem,\n DatasetItem.filter_settings(:reverse_order)\n )\n\n respond_filter(filter_response, opts)\n end",
"def get_filtered_data(data)\n filter_params = self._get_filter_params\n unless filter_params.blank?\n return data.where(**filter_params)\n end\n\n return data\n end",
"def prepare_orm_data_for_filters\n self.data_grid.columns.each do |col|\n next if col.filter.nil? # if no filter\n\n # Prepare auto filters\n if col.filter == :auto\n col.filter_data = self.data_grid.data_class.select(\"DISTINCT (#{col.filter_by}) as fc\").to_a.to_a.map(&:fc)\n end\n\n col.filter_data.uniq!\n col.filter_data.sort!\n end\n end",
"def get_filtered_dataset(count = false, limit = 10_000)\n selector = if count\n ' count(*) '\n else\n columns_visible_sql\n end\n\n query = \"select #{selector}\"\n query += \" from #{api_table_name}\"\n query += ' where ' + filters_sql unless filters.blank? || JSON.parse(filters).blank?\n query += \" limit #{limit}\" if limit\n\n DatasetService.get_filtered_dataset dataset_id, query\n end",
"def get_table(scaffold, **filters)\n get_url = \"#{@device_address}/admin/scaffolds/#{scaffold}/index.json?api_key=#{@device_api_key}\"\n json_body = JSON.parse(Excon.get(get_url).body)\n\n if filters.any?\n filters.each do |name, value|\n json_body.keep_if { |return_item| return_item[name.to_s] == value.to_s }\n end\n end\n\n json_body\n end",
"def datasource_params\n {\n start: start,\n rows: rows,\n wt: 'json'\n }\n end",
"def filter_data\n case params[:filter][:info]\n when 'Public'\n @tag = Tag.find_by(tag: 'Public')\n when 'Basketball Courts'\n @tag = Tag.find_by(tag: 'Basketball Courts')\n when 'Book Store'\n @tag = Tag.find_by(tag: 'Book Store')\n end\n\n @joins = Tagtoilet.where('tag_id = ?', @tag.id)\n @toilets = @joins.map{|join| Toilet.find(join.toilet_id)}\n @toilets.to_json\n end",
"def filters=(_arg0); end",
"def filters=(_arg0); end",
"def filters\n end",
"def filters; end",
"def filters; end",
"def api_filter(params, options = {})\n new_params = {}\n params.each{|param, value| new_params[param.to_s] = value} \n params = new_params\n\n api_validate params\n \n skip = Proc.new do |key|\n options[:only_filter] && !options[:only_filter].include?(key)\n end\n \n dataset = self\n dataset = dataset.api_include params unless skip.call(:include)\n dataset = dataset.api_sort params unless skip.call(:sort)\n dataset = dataset.api_limit params unless skip.call(:limit)\n dataset = dataset.api_offset params unless skip.call(:offset)\n\n # Prepare the records for serialization\n records = dataset.all\n\n if params['include'] && !skip.call(:include)\n records.each do |record|\n MF::API::IncludeNode.serialize_attrs(record, params['include'], options[:proc])\n end\n end\n \n records\n end",
"def get_filtered_data(data)\n ordering = self._get_ordering\n reorder = [email protected](:ordering_no_reorder)\n\n if ordering && !ordering.empty?\n return data.send(reorder ? :reorder : :order, _get_ordering)\n end\n\n return data\n end",
"def apply_filter\n end",
"def filtered_dataset\n dataset\n end",
"def handle_row(business, row)\n\n end",
"def get_preview\n get_filtered_dataset false, 10\n end",
"def filtered_entries; end",
"def index\n session[:search_filter_info] = {}\n\t\t@screen = Screen.find(params[:id])\n @action_source = params[:action_source] || 'index'\n @quick_operation = params[:quick_operation] || 'index'\n @filtered_reference = params[:filtered_reference] || {}\n @row_ids = []\n @row_pattern = Row.find(params[:row_pattern_id].to_i) unless params[:row_pattern_id].nil?\n\n rpp = ApplicationController.current_user.rows_per_page\n @pageno = (!@action_source.include?('page_')) ? 1 : params[:pageno].gsub('/','')\n\n case @action_source\n when 'index'\n options = @quick_operation == 'index' ? Row.filter_by_custom_fields(params[:id].to_i, {}, 'index', false) : {}\n\n @row_ids = options[:filtered_row_ids] || []\n @row_ids_wo_limit = options[:filtered_row_ids_wo_limit] || []\n @row_pattern = Row.find(options[:row_pattern_id]) unless options[:row_pattern_id].nil?\n session[:sort_field_id_order] = options[:sort_field_id_order] || []\n\n RowsController.store_session_row_ids(session.session_id, @screen.id, @row_ids, @row_ids_wo_limit)\n\n when 'search', 'page_search', 'page_index'\n\n session[:search_filter_info] = {}\n\n @filtered_reference.each do |key, other|\n cf = CustomField.find(key)\n case cf\n when CustomFields::TextField\n fieldValue = other\n session[:search_filter_info][cf.name] = fieldValue\n when CustomFields::Reference\n fieldValue = Cell.find(:first, :conditions => {:row_id => other.values}).value\n session[:search_filter_info][cf.name] = fieldValue\n when CustomFields::DateTimeField\n count = other.length\n i=0\n for i in 0..(count-1)\n fieldDate = other.keys[i]\n fieldValue = other.values[i]\n session[:search_filter_info][fieldDate] = fieldValue\n end\n else\n fieldValue = other\n a=10\n end\n end\n\n\n\n screen_id = params[:request_id] || @screen.id\n purge = !params[:request_id].nil?\n @row_ids = RowsController.get_session_row_ids(session.session_id, screen_id.to_i, purge)\n \n if params.has_key?(:sort_field_id)\n session[:sort_field_id_order] = Row.reorder_field_sorting(session[:sort_field_id_order], params[:sort_field_id])\n\n @row_ids = Row.sort(@row_ids, session[:sort_field_id_order])\n\n RowsController.store_session_row_ids(session.session_id, @screen.id, @row_ids)\n end\n end\n\n @sort_field_id_order = session[:sort_field_id_order]\n \n @row_ids ||= []\n\n @row_count = @row_ids.size\n\n #Page generator\n pageno_from = (rpp*(@pageno.to_i-1))\n pageno_to = ((rpp*@pageno.to_i)-1)\n\n @maxpage = (@row_ids.size.to_f / rpp).ceil\n @row_ids = @row_ids[pageno_from..pageno_to] || []\n\n @rows = @screen.rows.find(:all,\n :conditions => {\n :rows => { :id => @row_ids }\n }\n )\n\n @rows.sort!{|a, b| @row_ids.index(a.id) <=> @row_ids.index(b.id)}\n\n GC.start\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @rows }\n end\n end",
"def get_flows_datatable_rows_with_http_info(datatable_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: ArchitectApi.get_flows_datatable_rows ...\"\n end\n \n \n # verify the required parameter 'datatable_id' is set\n fail ArgumentError, \"Missing the required parameter 'datatable_id' when calling ArchitectApi.get_flows_datatable_rows\" if datatable_id.nil?\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n # resource path\n local_var_path = \"/api/v2/flows/datatables/{datatableId}/rows\".sub('{format}','json').sub('{' + 'datatableId' + '}', datatable_id.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'pageNumber'] = opts[:'page_number'] if opts[:'page_number']\n query_params[:'pageSize'] = opts[:'page_size'] if opts[:'page_size']\n query_params[:'showbrief'] = opts[:'showbrief'] if opts[:'showbrief']\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/json']\n local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result\n\n # HTTP header 'Content-Type'\n local_header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n auth_names = ['PureCloud OAuth']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'DataTableRowEntityListing')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ArchitectApi#get_flows_datatable_rows\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def filter\n end",
"def render_grid_data_row(item, **opt)\n decorate(item).grid_row(**opt)\n end",
"def row_filters?(table)\n !@config[table.to_s]['rows'].nil? && @config[table.to_s]['rows'].any?\n end",
"def html_filters(table = @jqgrid_id)\n <<-HTML\n\t\t<div id=\"#{table}_filters\" class=\"scroll\" style=\"text-align:center;\"></div>\n\t\tHTML\n end",
"def get_rows(solrparams, params)\n params.key?(:rows) ? solrparams.merge!(:rows => params[:rows]) : solrparams.merge!(:rows => 100000000) # if user passes in the rows they want, use that, else just return everything\n end",
"def getFilterEmpresa\n empresa = Enterprise.find(params[:idEmp].to_i)\n content = []\n # ES: El primer registro valida si la empresa tiene logo o no:\n # EN: The first record validates if the enterprise has logo or not:\n if empresa.logo.blank?\n content[0] = 'NO_LOGO'\n else\n content[0] = 'SI_LOGO'\n end\n\n\n # ES: Mapas de decision:\n # EN: Decision Maps:\n mapasFormateados = view_context.mapasListDecisionMaps(empresa.id)\n # ES: Agrega los mapas formateados:\n # EN: Add the formated maps\n content.concat(mapasFormateados)\n\n # ES: Escenarios de Evaluacion de Riesgos:\n # EN: Risk Assessment Scenarios:\n riesgosFormateados = view_context.escenariosListRiskEscenarios(empresa.id)\n # ES: Agrega los escenarios formateados:\n # EN: Add the formated scenarios:\n content.concat(riesgosFormateados)\n\n # ES: Escenarios de Evaluacion de Objetivos:\n # EN: Goal Assessment Scenarios:\n goalsFormateados = view_context.escenariosListGoalEscenarios(empresa.id)\n # ES: Agrega los escenarios formateados:\n # EN: Add the formated scenarios:\n content.concat(goalsFormateados)\n\n # ES: Escenarios de Priorizacion:\n # EN: Prioritization Scenarios:\n priorsFormateados = view_context.escenariosListPriorEscenarios(empresa.id)\n # ES: Agrega los escenarios formateados:\n # EN: Add the formated scenarios:\n content.concat(priorsFormateados)\n\n respond_to do |format|\n format.json {render json: content}\n end\n \n end",
"def filter_index\n filter\n end",
"def set_cell_filtering\n @cell_filtering = CellFiltering.find(params[:id])\n end",
"def get_by_show_filter(filter_by)\n filters = Constants::ProjectsIndexFilters\n filters = filters.merge(Constants::AdminProjectsIndexFilters) if current_user.role? :booktrope_staff\n @grid_title = \"The Grid\"\n\n unless filter_by.nil? || !filters.has_key?(filter_by.to_sym)\n if filter_by.to_sym == :all\n @projects = ProjectGridTableRow.includes(project: [:cover_template])\n .not_archived\n .all\n elsif filter_by.to_sym == :my_books\n get_my_projects\n elsif filter_by.to_sym == :not_published\n get_unpublished_books\n else\n @grid_title = filters[filter_by.to_sym][:label]\n @grid_title = filters[filter_by.to_sym][:task_name] if @grid_title.empty?\n pgtr_meta_hash = filters[filter_by.to_sym]\n @projects = ProjectGridTableRow.includes(project: [:cover_template])\n .where(\"#{pgtr_meta_hash[:workflow_name]}_task_name = ?\", pgtr_meta_hash[:task_name])\n .not_archived\n end\n end\n end",
"def index\n\n get_header_details if !request.xhr?\n columns = ['id', 'name_of_person','lastname_of_person','name_of_organization','email_id', 'no_of_license_required' ,\n 'phone_no1','phone_no2','state','country','zipcode','status']\n \n clients = Client.select(\"*\").paginate(\n :page => params[:page],\n :per_page => params[:rows],\n :order => order_by_from_params(params))\n\n \n \n if request.xhr? \n render :json => json_for_jqgrid(clients, columns)\n end\n\n end",
"def query\n respond_to do |format|\n format.html{ redirect_to root_path }\n format.json{\n render :json => @filter.run(params)\n }\n end\n end",
"def index\n @received_filter = FilterPresenter.new(['true', 'false'], 'all')\n @received_filter.current = params[:received]\n @graded_filter = FilterPresenter.new(['true', 'false'], 'all')\n @graded_filter.current = params[:graded]\n @patient = if patient_signed_in?\n current_patient\n elsif params[:patient_id]\n Patient.find(params[:patient_id])\n end\n\tgraded_flag = (@graded_filter.active == 'true')\n\treceived_flag = (@received_filter.active == 'true')\n\n\tif @graded_filter.active == 'all' and @received_filter.active == 'all'\n\t\t@records = (@patient ? @patient.records : Record.includes(:patient)).includes(:grade).order('created_at DESC')#.page(params[:page])\n\telsif @graded_filter.active == 'all'\n\t\t@records = (@patient ? @patient.records : Record.includes(:patient)).includes(:grade).where(received: received_flag).order('created_at DESC')#.page(params[:page])\n\telsif @received_filter.active == 'all'\n\t\t@records = (@patient ? @patient.records : Record.includes(:patient)).includes(:grade).where(graded: graded_flag).order('created_at DESC')#.page(params[:page])\n\telse\n\t\t@records = (@patient ? @patient.records : Record.includes(:patient)).includes(:grade).where(graded: graded_flag, received: received_flag).order('created_at DESC')#.page(params[:page])\n\tend\n\n respond_to do |format|\n format.html # index.html.erb\n format.json do\n render json: @records.to_json(\n include: {\n grade: {\n only: [:grade, :comment]\n }\n },\n only: [:id, :device, :comment, :status, :patient_id,\n :created_at, :updated_at, :meta, :pill_time_at, :received],\n methods: [:is_excuse?])\n end\n format.csv\n end\n end",
"def filter\n conditions = [\"isEstimate = ?\"]\n values = [ 0 ]\n if(params[:filter])\n session[:filter] = params[:filter]\n end\n if(session[:filter])\n if(session[:filter][:date_max])\n conditions << \"moment <= ?\"\n values << session[:filter][:date_max]\n end\n if(session[:filter][:date_min])\n conditions << \"moment >= ?\"\n values << session[:filter][:date_min]\n end\n if(session[:filter][:name] && session[:filter][:name] != \"\") \n conditions << \"name LIKE ?\"\n values << \"%\" + session[:filter][:name] + \"%\"\n end\n end\n conditions = values.insert(0, conditions.join(\" AND \"))\n\n \n session[:event_results] = getResults(conditions, params[:event_page])\n conditions[1] = 1\n session[:estimate_results] = getResults(conditions, params[:estimate_page])\n \n session[:event_time] = Time.now.to_f\n #raise session[:event_time].to_s + \" \" + Event.last_update.to_s\n end",
"def lookup_data\n \n # Note: At least one query parameter is required\n render :json => {\n :success => false,\n :message => \"No query parameters\",\n :apps_data => []\n } unless request.query_parameters\n \n # Get query parameters\n query = get_query\n \n # Get list of fields to return\n fields = get_fields\n \n # Get list of fields to remove\n without = get_without_fields\n\n # Check if sorting method is specified\n sort_field = get_sorting('popularity_weight')\n \n # If the limit is specified set it otherwise default to 100\n limit_num = get_limit\n\n apps = AppData.where(query)\n .sort(sort_field)\n .fields(fields)\n .limit(limit_num)\n .all\n \n # Apply interests weighting if interests exist \n apps = weight_interests(apps, request.query_parameters['interests'])\n \n # Return result as json\n render :json => {\n :success => true,\n :message => \"Success\",\n :apps_data => apps.as_json(:only => fields, :except => without)\n }\n \n end",
"def get_row(values, second = 5)\n condition = \"\"\n values.each do |header, value|\n unless condition.empty?\n condition += \" and \"\n end\n lastpart = \"\"\n if header != \"[unnamed]\" and header != \"\"\n lastpart = \"/@column-id=preceding::thead[1]/tr/th/div[.//text()=#{$browser.generate_concat_for_xpath_text header} \" +\n \"or normalize-space(.//text())=#{$browser.generate_concat_for_xpath_text header}]/@column-id\"\n end\n if value =~ /^\\[img\\](.*)$/ # For the image processing\n condition += \"td/div[.//img[contains(@src,#{$browser.generate_concat_for_xpath_text $1})]]#{lastpart}\"\n elsif value == \"[spark]\" # For the spark line processing\n condition += \"td/div[.//canvas]#{lastpart}\"\n elsif value =~ /^\\[fuzzy\\](.*)$/\n condition += \"td/div[.//*[contains(text(),#{$browser.generate_concat_for_xpath_text $1})]]#{lastpart}\"\n elsif value =~ /^\\[fuzzy\\](.*)$/\n condition += \"td/div[.//*[contains(text(),#{$browser.generate_concat_for_xpath_text $1})]]#{lastpart}\"\n elsif ['[selected]', '[unselected]'].include?(value)\n condition += \"contains(@class,'SelectedRow')\"\n else\n condition += \"td/div[.//*[contains(text(), #{$browser.generate_concat_for_xpath_text value})]]#{lastpart}\"\n end\n end\n\n while true\n row = GridWcfTableRow.new(\"#{@locator}/tr[#{condition}]\")\n\n $browser.wait_for_body_text\n\n if row.wait(second, false)\n return row\n else\n if is_scrollbar_reach_bottom?\n return nil\n else\n drop_vscrollbar\n end\n end\n end\n end",
"def get_row(values, second = 5)\n condition = \"\"\n values.each do |header, value|\n unless condition.empty?\n condition += \" and \"\n end\n lastpart = \"\"\n if header != \"[unnamed]\" and header != \"\"\n lastpart = \"/@column-id=preceding::thead[1]/tr/th/div[.//text()=#{$browser.generate_concat_for_xpath_text header} \" +\n \"or normalize-space(.//text())=#{$browser.generate_concat_for_xpath_text header}]/@column-id\"\n end\n if value =~ /^\\[img\\](.*)$/ # For the image processing\n condition += \"td/div[.//img[contains(@src,#{$browser.generate_concat_for_xpath_text $1})]]#{lastpart}\"\n elsif value == \"[spark]\" # For the spark line processing\n condition += \"td/div[.//canvas]#{lastpart}\"\n elsif value =~ /^\\[fuzzy\\](.*)$/\n condition += \"td/div[.//*[contains(text(),#{$browser.generate_concat_for_xpath_text $1})]]#{lastpart}\"\n elsif value =~ /^\\[fuzzy\\](.*)$/\n condition += \"td/div[.//*[contains(text(),#{$browser.generate_concat_for_xpath_text $1})]]#{lastpart}\"\n elsif ['[selected]', '[unselected]'].include?(value)\n condition += \"contains(@class,'SelectedRow')\"\n else\n condition += \"td/div[.//text()=#{$browser.generate_concat_for_xpath_text value}]#{lastpart}\"\n end\n end\n\n while true\n row = GridWcfTableRow.new(\"#{@locator}/tbody/tr[#{condition}]\")\n\n path = \"#{@locator}/tbody/tr[#{condition}]\"\n puts path\n\n $browser.wait_for_body_text\n\n if row.wait(second, false)\n return row\n else\n if is_scrollbar_reach_bottom?\n return nil\n else\n drop_vscrollbar\n end\n end\n end\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def cell_filtering_params\n params.fetch(:cell_filtering, {})\n end",
"def get_basic_hospitals_data(i, params)\n # Attribute Filters\n must_filter = []\n\n # Search by single or multiple ids (comma separated)\n if params[:id]\n if params[:id].include? ','\n ids = params[:id].split(\",\").map { |s| s.to_i }\n must_filter.push({ terms: { id: ids }})\n else\n must_filter.push({term: { id: params[:id] }})\n end\n end\n\n # Search by name (autocomplete)\n must_filter.push(match_phrase_prefix: { name: params[:name] }) if params[:name]\n\n # Page filters\n perpage = params[:perpage] ? params[:perpage].to_i : 10\n page = params[:page] ? ((params[:page].to_i - 1) * perpage.to_i) : 0\n\n # Sort filters\n sort_filter = basic_hospitals_data_sort_filter(params[:sort_order], params[:sort_by])\n\n # Elasticsearch DSL Query\n search_query = {\n query: {\n bool: {\n must: must_filter\n }\n },\n sort: sort_filter,\n from: page,\n size: perpage\n }\n\n client = Elasticsearch::Client.new #host:'https://search-kulcare-search-a5gec72fgr3kghfjyvb3anac74.ap-southeast-1.es.amazonaws.com'\n results = client.search index: i, body: search_query\n results[\"hits\"].to_json\n end",
"def rows\n RowCollection.new(@data)\n end",
"def filter_data(data, action)\n params_combinator = ParamsOperators::Retriever.new(data, action)\n params_combinator.run\n end",
"def request_filter(data)\n flt = Stopwatch.new\n flt.watch('start')\n if !request_valid?(data)\n sql = \"SELECT 1;\"\n return sql\n end\n guid = Tools::guid\n cols, vals = String.new, String.new\n lkey, rkey = String.new, String.new\n sql_ua, json_data_pieces = String.new, String.new\n t = 0\n json_data_hdr = '{ \"http\": { '\n json_data_ftr = \" } }\"\n sql = \"INSERT INTO #{@reqtable} (recv_time,recv_date,guid,json_data) \"\n data.each_line {|n|\n unless n.strip == \"\"\n if t > 0 # Don't processes GET / POST Line\n lkey, rkey = lkey_strip(n), rkey_strip(n)\n puts \"LKEY: #{lkey} RKEY: #{rkey}\" if @debug == true\n rkeyenc = filter_header?(lkey)\n if rkeyenc == false\n rkeyenc = rkey_decode(rkey)\n if lkey == \"useragent\"\n ua = Tools::ua_parser(rkeyenc)\n sql_ua = \"INSERT INTO #{@reqtableua} (family, \"\n sql_ua << \"major, minor, \" unless ua.version == nil\n sql_ua << \"os, guid) \"\n sql_ua << \"VALUES ('#{ua.family}', \"\n sql_ua << \"'#{ua.version.major}', '#{ua.version.minor}', \" unless ua.version == nil\n sql_ua << \"'#{ua.os.to_s}', '#{guid}');\"\n end\n else \n rkey = \"ommited\"\n end\n if rkey != \"\" or lkey != \"\"\n prerkeyins = rkey.gsub('\"', '') # Strip Quotes\n prerkeyins = \"blank\" if prerkeyins.strip == \"\" # Seems JSON values can't be \"accept\":\"\"\n puts \"Found Blank Value!!!\" if prerkeyins == \"blank\"\n json_data_pieces << %Q{\"#{lkey}\": \"#{prerkeyins}\",} if lkey != \"useragent\"\n end\n end\n t += 1\n end\n }\n # Store the URL in the JSON unless its blank\n # Build JSON Manually as i bet its faster than using some JSON encoder where it has to convert from Array etc.\n json_data_pieces << %Q{\"url\":\"#{@makeurl_last}\",\"} unless @makeurl_last == \"\"\n # SQL for Datastore\n begin\n # Remove last , to fix hash table\n json_data_pieces.sub!(%r{,\"$}, \"\")\n json_data = \"#{json_data_hdr}#{json_data_pieces}#{json_data_ftr}\"\n puts \"\\e[4;36mJSON Data:\\e[0m\\ \\n#{json_data}\"\n puts \"JSON Data: #{json_data}\" if @debug == true\n # Added GUID as i could extend TCP/IP capture suites in the future for HTTP traffic \n sql = \"#{sql}VALUES (NOW(), NOW(), '#{guid}', '#{json_data}');\"\n flt.watch('stop')\n print \"\\e[4;36mFilter Time Taken:\\e[0m\\ \"\n flt.print_stats\n return [sql, sql_ua]\n rescue => e\n pp e\n end\n end",
"def Filter=(arg0)",
"def get_flows_datatable_row_with_http_info(datatable_id, row_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: ArchitectApi.get_flows_datatable_row ...\"\n end\n \n \n # verify the required parameter 'datatable_id' is set\n fail ArgumentError, \"Missing the required parameter 'datatable_id' when calling ArchitectApi.get_flows_datatable_row\" if datatable_id.nil?\n \n \n \n \n \n \n # verify the required parameter 'row_id' is set\n fail ArgumentError, \"Missing the required parameter 'row_id' when calling ArchitectApi.get_flows_datatable_row\" if row_id.nil?\n \n \n \n \n \n \n \n \n \n \n \n # resource path\n local_var_path = \"/api/v2/flows/datatables/{datatableId}/rows/{rowId}\".sub('{format}','json').sub('{' + 'datatableId' + '}', datatable_id.to_s).sub('{' + 'rowId' + '}', row_id.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'showbrief'] = opts[:'showbrief'] if opts[:'showbrief']\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/json']\n local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result\n\n # HTTP header 'Content-Type'\n local_header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n auth_names = ['PureCloud OAuth']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Hash<String, Object>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ArchitectApi#get_flows_datatable_row\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def get_data\n raise \"This method should be overriden to return the JSON data for a concrete table\"\n end",
"def parse_line line,header,options,bedfilter,samples,template,stats=nil\n fields = VcfLine.parse(line)\n rec = VcfRecord.new(fields,header)\n r = rec # alias\n\n filter = options[:filter]\n sfilter = options[:sfilter]\n efilter = options[:efilter]\n ifilter = options[:ifilter]\n add_filter = options[:add_filter] # contains a filter name (soft filter)\n seval = options[:seval]\n ignore_missing = options[:ignore_missing]\n quiet = options[:quiet]\n set_filter_field = nil\n\n if sfilter or efilter or ifilter or seval\n # check for samples\n header_samples = header.column_names[9..-1]\n raise \"Empty sample list, can not execute query!\" if not header_samples\n end\n\n # --------------------------\n # Filtering and set analysis\n if bedfilter\n bed = bedfilter.contains(rec)\n return if not bed\n end\n\n skip = lambda { |&m|\n matched = m.call\n if add_filter\n set_filter_field = true if matched\n false # always continue processing with an add-filter\n else\n not matched\n end\n }\n\n if filter\n return if skip.call { rec.gfilter(filter,ignore_missing_data: ignore_missing,quiet: quiet) }\n end\n \n if sfilter # sample 'or' filter\n rec.each_sample(options[:sfilter_samples]) do | sample |\n return if skip.call { sample.sfilter(sfilter,ignore_missing_data: ignore_missing,quiet: quiet) }\n end\n end\n\n if ifilter # include sample filter\n found = false\n rec.each_sample(options[:ifilter_samples]) do | sample |\n if sample.ifilter(ifilter,ignore_missing_data: ignore_missing,quiet: quiet)\n found = true\n break\n end\n end\n # Skip if there are no matches\n return if skip.call {found}\n end\n\n if efilter # exclude sample filter\n rec.each_sample(options[:efilter_samples]) do | sample |\n return if skip.call{ sample.efilter(efilter,ignore_missing_data: ignore_missing,quiet: quiet) }\n end\n end\n\n stats.add(rec) if stats\n\n # -----------------------------\n # From here on decide on output\n \n rec.add_to_filter_field(add_filter) if set_filter_field\n\n if samples\n # Select certain samples for output\n newfields = fields[0..8]\n samples.each do |s|\n newfields << fields[s+9] \n end\n fields = newfields\n end\n if options[:eval] or seval\n begin\n results = nil # result string\n if options[:eval] \n res = rec.eval(options[:eval],ignore_missing_data: ignore_missing,quiet: quiet)\n results = res if res\n end\n if seval\n list = (results ? [] : [rec.chr,rec.pos])\n rec.each_sample(options[:sfilter_samples]) { | sample |\n list << sample.eval(seval,ignore_missing_data: ignore_missing,quiet: quiet)\n }\n results = (results ? results.to_s + \"\\t\" : \"\" ) + list.join(\"\\t\")\n end\n rescue => e\n $stderr.print \"\\nLine: \",line\n $stderr.print \"ERROR evaluating --eval <#{options[:eval]}> #{e.message}\\n\"\n raise if options[:verbose]\n exit 1\n end\n return results.to_s+\"\\n\" if results\n else\n if options[:rdf]\n # Output Turtle RDF\n VcfRdf::record(options[:id],rec,options[:tags])\n elsif options[:template]\n # Use ERB template\n begin\n template.body(binding)\n rescue Exception => e\n $stderr.print e,\": \",fields,\"\\n\"\n $stderr.print e.backtrace.inspect if options[:verbose]\n raise \n end\n elsif options[:rewrite]\n # Default behaviour prints VCF line, but rewrite info\n eval(options[:rewrite]) \n (fields[0..6]+[rec.info.to_s]+fields[8..-1]).join(\"\\t\")+\"\\n\"\n elsif stats\n # do nothing\n else\n # Default behaviour prints VCF line\n fields.join(\"\\t\")+\"\\n\"\n end\n end\nend",
"def rows\n @rows\n end",
"def index\n if params[:lightweight] != \"yes\" \n get_header_details\n end\n columns = ['id','sm_bay_id', 'cl_bay_id','description','client_id','sm_aisle_id','cl_aisle_id',\n 'aisle_id','sm_zone_id','cl_zone_id','sm_warehouse_id','cl_warehouse_id','no_of_level_bay',\n 'no_of_level_bay_hidden','attribute1', 'attribute2', 'attribute3', 'attribute4','attribute5',\n 'attribute6', 'attribute7','attribute8']\n \n selectParam = params[\"bayid\"].blank? ? {:aisle_id => params[:id]} : {:id => params[\"bayid\"].to_i}\n \n bays = Bay.select(\" id , sm_bay_id , cl_bay_id ,description, client_id , sm_aisle_id ,\n cl_aisle_id , aisle_id , sm_zone_id , cl_zone_id ,sm_warehouse_id , \n cl_warehouse_id , no_of_level_bay , no_of_level_bay as no_of_level_bay_hidden,\n attribute1 , attribute2 , attribute3 , attribute4 , attribute5 , attribute6 ,\n attribute7 , attribute8 \").where(selectParam).paginate(\n :page => params[:page],\n :per_page => params[:rows],\n :order => order_by_from_params(params))\n \n if request.xhr?\n render :json => json_for_jqgrid(bays, columns)\n end\n \n \nend",
"def rows()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::Rows::RowsRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def getRows\n return @grid.getRows\n end",
"def search\n col_dict = {\n :unit_code => \"0\",\n :name => \"1\",\n :email => \"2\"\n }\n \n if params[:filter]\n col_dict.keys.each do |k|\n search = params[:filter][ col_dict[k] ]\n next if search.blank?\n \n if k == :name\n fn, ln = search.split(\" \", 2)\n \n if !ln.blank?\n params[:first_name] = fn\n params[:last_name] = ln\n \n else\n params[:first_name] = fn\n end\n \n else\n params[k] = search\n end\n \n end\n end\n \n # tablesorter page index start with 0\n params[:page] = params[:page].to_i + 1\n \n filter_residents(10)\n \n #render :json => {:resident_path => @resident ? property_resident_path(@property, @resident, :anchor => \"addTicket\") : nil }\n \n render template: \"residents/table.json.rabl\" \n \n end",
"def grid_row(r)\n {\n :id => r.id,\n :cell => @columns.collect do |c|\n c[:custom] ? call_custom(c[:custom], r) : (r.attributes)[c[:field]]\n end\n }\n end",
"def index\n set_url_params\n \n p \"***********************\"\n p @sCols\n\n respond_to do |format|\n format.html # index.html.erb\n format.json {render :json => InstitutionsDatatable.new(view_context,eval(@sCols),@sFilter)}\n end\n end",
"def reloadTableOnFilteredData(notification)\n self.filteredData = notification.object.filteredData\n reloadTable\n end",
"def autofilter(*args)\n # Check for a cell reference in A1 notation and substitute row and column\n if args[0] =~ /^\\D/\n args = substitute_cellref(*args)\n end\n\n return if args.size != 4 # Require 4 parameters\n\n row1, col1, row2, col2 = args\n\n # Reverse max and min values if necessary.\n if row2 < row1\n tmp = row1\n row1 = row2\n row2 = tmp\n end\n if col2 < col1\n tmp = col1\n col1 = col2\n col2 = col1\n end\n\n # Store the Autofilter information\n @filter_area = [row1, row2, col1, col2]\n @filter_count = 1 + col2 -col1\n end",
"def filter_header?(lkey)\n puts \"MY LKEY: |#{lkey}|\" if @debug == true\n case \n when lkey == \"cookie\"\n catch_header(lkey) if @debug == true\n return true\n when lkey == \"range\"\n catch_header(lkey) if @debug == true\n return true\n when lkey =~ %r=^get |^post |^head =\n catch_header(lkey, \"Seen this unsure why it even occurs yet !\") if @debug == true\n return true\n else\n return false\n end\n end\n \n # Right Cell eval\n def rkey_decode(rkey)\n rkeyenc = URI.decode(rkey)\n end\n \n # Filter lkey = header, rkey = requestdata\n def lkey_strip(hdrs)\n hdrs.split(\": \")[0].downcase.gsub(\"-\", \"\").to_s.strip\n end\n \n def rkey_strip(data)\n data.split(\": \")[1].to_s.strip #to_s.gsub(\",\", \"\").gsub(\";\", \"\").gsub(\"=\", \"\").strip\n end\n \n # Filter request data and build query\n def request_filter(data)\n flt = Stopwatch.new\n flt.watch('start')\n if !request_valid?(data)\n sql = \"SELECT 1;\"\n return sql\n end\n guid = Tools::guid\n cols, vals = String.new, String.new\n lkey, rkey = String.new, String.new\n sql_ua, json_data_pieces = String.new, String.new\n t = 0\n json_data_hdr = '{ \"http\": { '\n json_data_ftr = \" } }\"\n sql = \"INSERT INTO #{@reqtable} (recv_time,recv_date,guid,json_data) \"\n data.each_line {|n|\n unless n.strip == \"\"\n if t > 0 # Don't processes GET / POST Line\n lkey, rkey = lkey_strip(n), rkey_strip(n)\n puts \"LKEY: #{lkey} RKEY: #{rkey}\" if @debug == true\n rkeyenc = filter_header?(lkey)\n if rkeyenc == false\n rkeyenc = rkey_decode(rkey)\n if lkey == \"useragent\"\n ua = Tools::ua_parser(rkeyenc)\n sql_ua = \"INSERT INTO #{@reqtableua} (family, \"\n sql_ua << \"major, minor, \" unless ua.version == nil\n sql_ua << \"os, guid) \"\n sql_ua << \"VALUES ('#{ua.family}', \"\n sql_ua << \"'#{ua.version.major}', '#{ua.version.minor}', \" unless ua.version == nil\n sql_ua << \"'#{ua.os.to_s}', '#{guid}');\"\n end\n else \n rkey = \"ommited\"\n end\n if rkey != \"\" or lkey != \"\"\n prerkeyins = rkey.gsub('\"', '') # Strip Quotes\n prerkeyins = \"blank\" if prerkeyins.strip == \"\" # Seems JSON values can't be \"accept\":\"\"\n puts \"Found Blank Value!!!\" if prerkeyins == \"blank\"\n json_data_pieces << %Q{\"#{lkey}\": \"#{prerkeyins}\",} if lkey != \"useragent\"\n end\n end\n t += 1\n end\n }\n # Store the URL in the JSON unless its blank\n # Build JSON Manually as i bet its faster than using some JSON encoder where it has to convert from Array etc.\n json_data_pieces << %Q{\"url\":\"#{@makeurl_last}\",\"} unless @makeurl_last == \"\"\n # SQL for Datastore\n begin\n # Remove last , to fix hash table\n json_data_pieces.sub!(%r{,\"$}, \"\")\n json_data = \"#{json_data_hdr}#{json_data_pieces}#{json_data_ftr}\"\n puts \"\\e[4;36mJSON Data:\\e[0m\\ \\n#{json_data}\"\n puts \"JSON Data: #{json_data}\" if @debug == true\n # Added GUID as i could extend TCP/IP capture suites in the future for HTTP traffic \n sql = \"#{sql}VALUES (NOW(), NOW(), '#{guid}', '#{json_data}');\"\n flt.watch('stop')\n print \"\\e[4;36mFilter Time Taken:\\e[0m\\ \"\n flt.print_stats\n return [sql, sql_ua]\n rescue => e\n pp e\n end\n end\n \n include TextProcessing\n\n end",
"def email_price_filter\n email_price_list = EmailPriceList.admin_search(params)\n\n render json: email_price_list\n end",
"def index\n #@microarraygals = Microarraygal.all\n @title = \"List of micro arrays GAL files\"\n\n if !signed_in?\n\t flash.now[:notice] = \"No Partner found!! Login with authenticated partner credentials!!!\"\n\t redirect_to experiments_path\n else\n\n #\t microarraygals = Microarraygal.find(:all, :joins=>[:partner]) do\n #\t\t#if params[:_search] == \"true\"\n #\n #\t # end\n\t#\tpaginate :page => params[:page], :per_page => params[:rows] \n\t# \n\t# end\n #\n\t# respond_to do |format|\n\t#\tformat.html # index.html.erbs directly,\n\t#\t#format.xml { render :xml => @samplings }\n\t# format.json { render :json => microarraygals.to_jqgrid_json([:id,\"act\",\"gal_f_code\",\"partner_name\",\"title\",\"bcode\",\"gal_upload_date\",\"edit\"], params[:page], params[:rows], microarraygals.total_entries) }\t\t\t\n\t# end\n \n \n index_columns ||= [:id,:act,:gal_f_code,:partner_name,:title,:bcode,:gal_upload_date,:edit]\n current_page = params[:page] ? params[:page].to_i : 1\n rows_per_page = params[:rows] ? params[:rows].to_i : 10\n\n conditions={:page => current_page, :per_page => rows_per_page}\n conditions[:order] = params[\"sidx\"] + \" \" + params[\"sord\"] unless (params[:sidx].blank? || params[:sord].blank?)\n \n if params[:_search] == \"true\"\n conditions[:conditions]=filter_by_conditions(index_columns)\n end\n \n @microarraygals=Microarraygal.paginate(conditions)\n [email protected]_entries\n \n respond_with(@microarraygals) do |format|\n format.json { render :json => @microarraygals.to_jqgrid_json(index_columns, current_page, rows_per_page, total_entries)} \n end\n\n end\n\n end",
"def filter (data)\n # leave the data untouched if we don't support the required filter\n return data if @filter.nil?\n\n # decode the data\n self.send(@filter, data)\n end",
"def filter_overResistanceBorsaItaliana\r\n @overResistanceStocksBorsaItaliana = @@SJA.select(\"stocks.isin, name, last_price, borsa_italiana_resistance\").where(\"borsa_italiana_resistance > 0 AND last_price > borsa_italiana_resistance\").order(:name) \r\n render json: @overResistanceStocksBorsaItaliana\r\n end",
"def apply_filter(type, request, ds)\n if filter = filter_for\n ds = filter.call(ds, type, request)\n end\n ds\n end",
"def ajax_filters\n @_ajax_table_filters ||= []\n end",
"def colrow() @records.get_data(GRT_COLROW); end",
"def list_filters\n {\n track_end_date: 'TrkEndDate gt VALUE',\n track_first_submitted: 'TrkFirstSubmitted gt VALUE',\n app_no: 'AppNo eq VALUE',\n first_name: 'AppFirstName eq VALUE',\n last_name: 'AppLastName eq VALUE',\n email: 'AppEmailAddress eq VALUE'\n }\n end",
"def check_filter_options() #:nodoc:\r\n table_name = @tables.first[1]\r\n model = @tables.first[0]\r\n session[table_name] ||= {}\r\n# process page\r\n session[table_name][:page] = params[:page] if params[:page]\r\n# new filter is applied\r\n if params[:filter]\r\n set_session_filter(table_name)\r\n session[table_name][:page] = 1\r\n end\r\n# if data model has field dc_site_id ensure that only documents which belong to the site are selected.\r\n site_id = dc_get_site._id if dc_get_site\r\n# dont't filter site if no dc_site_id field or user is ADMIN\r\n site_id = nil if !model.method_defined?('dc_site_id') or dc_user_can(DcPermission::CAN_ADMIN)\r\n# \r\n if @records = DcFilter.get_filter(session[table_name][:filter])\r\n @records = @records.and(dc_site_id: site_id) if site_id\r\n else\r\n @records = if site_id\r\n model.where(dc_site_id: site_id)\r\n else\r\n model\r\n end\r\n end\r\n=begin \r\n# TODO Use only fields requested. Higly experimental but necessary in some scenarios\r\n if (columns = @form['result_set']['columns'])\r\n cols = []\r\n columns.each { |k,v| cols << v['name'] }\r\n p '*',cols,'*'\r\n @records = @records.only(cols)\r\n end\r\n=end \r\n# pagination if required\r\n per_page = (@form['result_set']['per_page'] || 30).to_i\r\n if per_page > 0\r\n @records = @records.page(session[table_name][:page]).per(per_page)\r\n end\r\nend",
"def filter\n @filter_params.each do |key, val|\n # Strip empty values from the array if the given value is an array.\n val.select!{ |val| !val.to_s.empty? } if val.is_a?(Array)\n\n # Convert key if it starts with a column name.\n key = key.slice(@model_method_name.length + 1, key.length) if key.start_with?(\"#{@model_method_name}_\")\n\n if @force_filter_for && @force_filter_for.include?(key)\n ret = @args[:filter].call(:key => key, :val => val, :query => @query)\n @query = ret if ret\n elsif @model.column_names.include?(key)\n if val.is_a?(Array) && val.empty?\n # Ignore.\n else\n @query = @query.where(key => val)\n end\n elsif match = key.to_s.match(/^(.+)_like$/) and @model.column_names.include?(match[1])\n next if val.blank?\n table = @model.arel_table\n \n val.to_s.strip.split(/\\s+/).each do |str|\n @query = @query.where(table[match[1].to_sym].matches(\"%#{escape(str)}%\"))\n end\n elsif @args[:filter]\n ret = @args[:filter].call(:key => key, :val => val, :query => @query)\n @query = ret if ret\n else\n raise \"Dont know what to do regarding filter with key: '#{key}'.\"\n end\n end\n end",
"def getRentBurdens(db, facets, partition)\n throw 'A partition must be specified' if partition.empty?\n partitionFilters = getFilters(partition)\n partitionColumns = partitionFilters.map { |filter| filter[:column] }\n\n\n whereSql = getWhereSql(db, facets)\n partitionSql = getWhereSql(db, partition)\n\n andWhere = whereSql.empty? ? '' : ' AND ' + whereSql\n\n sqlQuery = \"select #{columnNames[:rentburden]},\n sum(CASE WHEN #{partitionSql} THEN n END) as match,\n sum(CASE WHEN NOT #{partitionSql} THEN n END) as no_match\n FROM (select \n sum(perwt) as n, #{columnNames[:rentburden]}, #{partitionColumns.join(',')} \n from #{tableName}\n where #{columnNames[:rentburden]} is not null #{andWhere} \n group by #{columnNames[:rentburden]}, #{partitionColumns.join(',')}) grpip_by_partition\n group by #{columnNames[:rentburden]};\";\n\n puts sqlQuery #DELETE ME\n\n sqlResult = db.exec(sqlQuery)\n\n asArray = sqlResult.values()\n\n # totals for every column, the first is 0\n totals = Array.new(sqlResult.num_fields(), 0)\n\n # total each column \n asArray.each do |row|\n (1..row.length-1).each do |col|\n totals[col] += row[col].to_i\n end\n end\n\n #calculate percentages for each population\n asArray.map! do |row|\n (1..row.length-1).each do |col|\n colTotal = totals[col]\n if colTotal == 0\n row[col] = 0\n else\n row[col] = row[col].to_f/colTotal * 100\n end\n end\n row\n end\n\n\n {\n :results => asArray,\n :populationSize => totals[1..-1],\n :fields => sqlResult.fields, \n # :query => sqlQuery,\n :citation => 'American Community Survey 2010-2012, processed by BFAMFAPhD'\n }\n end",
"def do_params_filter scope\n filter_params.each do |k,value|\n if value.present?\n if self.class.custom_filter_fields[k].present?\n scope = self.class.custom_filter_fields[k].call scope, value\n elsif resource_class.column_names.include? k\n if resource_class.columns_hash[k].type == :boolean\n if value == '0'\n puts \"Should filter\"\n scope = scope.where(k => [false,nil])\n else\n scope = scope.where(k => true)\n end\n else\n scope = scope.where(k => value)\n end\n elsif resource_class.reflect_on_association(k.to_sym).present?\n klass = resource_class.reflect_on_association(k.to_sym).klass\n scope = do_inner_params_filter klass, value, scope\n else\n Rails.logger.warn(\"No filter is available for field #{k}\")\n end\n end\n end\n scope\n end",
"def data_rows\n @rows[@num_header_rows..-1]\n end",
"def get_fields\n DatasetService.get_fields self.dataset_id, self.api_table_name\n end",
"def server_get_data(vmid,field)\n @site[\"nodes/#{@nodename}/openvz/#{vmid}/status/current\"].get @auth_params do |response, request, result, &block|\n data = (field.match(\"all\"))?JSON.parse(response.body)['data'] : JSON.parse(response.body)['data'][field]\n end\nend",
"def gv_filter_node\n @gv_filter_node\n end",
"def index\n @users_grid = initialize_grid(User.where('email != ? and id != ?','[email protected]',current_user.id))\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users_grid }\n end\n end",
"def filter\n res = RResponse.new\n \n # if no filter params exists, then we're in presentation mode of an existing query (and possibly paging). in this case\n # the set of order ids must exist in session[:order_filter]\n if (params[\"filter\"].nil?)\n raise RException.new(\"order/query call with neither a filter nor a resultset in session\") if session[:order_filter].nil? \n res.data[:rs] = Order.filter(session[:order_filter], params[\"limit\"], params[\"start\"]) \n res.data[:total] = session[:order_filter].length \n res.success = true \n \n # filter params were found -- this means we're building a new query\n else\n # build a criteria hash.\n c = {}\n params[\"filter\"].each_pair do |k,v|\n if (v == 'on')\n filter = {} \n params[k].each_pair do |name, value|\n filter[name.to_sym] = value\n end \n filter[:location] = params[\"location\"] if (k == 'airport') \n filter[:role] = params[\"role\"] if (k == 'company') \n c[k.to_sym] = filter \n end\n end \n LOG.info('filter: ' + c.to_yaml)\n res.data[:total] = 0 \n if (rs = Order.prepare_filter(c))\n session[:order_filter] = rs \n res.data[:total] = rs.length\n res.msg = \"Found #{rs.length} orders\" \n else \n res.msg = \"No orders found with that criteria\"\n end \n res.success = true\n end \n \n respond(res)\n \n end",
"def filter(param, type:, operation:, column: nil, required: false, format_value: nil)\n query_param = param.to_s.underscore\n column ||= param.to_s.underscore\n op = operations.fetch(operation.to_sym) { raise ArgumentError, \"unknown operation #{operation}\" }\n sql = op.call(column, query_param, type)\n raw_filter(param, sql:, required:, format_value:, query_param:, array: op.array)\n end",
"def filter\n filter_type = params[:filter][:type]\n case filter_type\n when \"last_seven\", \"weekly\"\n @filter = \"Weekly\"\n @filtered_runs = current_user.runs.in_the_last_week\n when \"last_thirty\", \"monthly\"\n @filter = \"Monthly\"\n @filtered_runs = current_user.runs.in_the_last_thirty_days\n when \"year\", \"yearly\"\n @filter = \"Yearly\"\n @filtered_runs = current_user.runs.in_the_last_year\n when \"lifetime\"\n @filter = \"Lifetime\"\n @filtered_runs = current_user.runs.most_recent_by_date\n end\n\n respond_to do |format|\n format.js\n end\n\n end",
"def list\n year = params[:year].blank? ? 0 : params[:year].to_i\n pgnum = params[:pgnum].blank? ? 1 : params[:pgnum].to_i\n pgsize = params[:pgsize].blank? ? 0 : params[:pgsize].to_i\n sortcolumn = params[:sortcolumn].blank? ? OvertimeRateHelper::DEFAULT_SORT_COLUMN : \n params[:sortcolumn]\n sortdir = params[:sortdir].blank? ? OvertimeRateHelper::DEFAULT_SORT_DIR : \n params[:sortdir]\n \n sort = ApplicationHelper::Sort.new(sortcolumn, sortdir)\n \n filters = { :year => year }\n \n if year == 0\n @data = OvertimeRateHelper.get_all(pgnum, pgsize, sort)\n \n else\n @data = OvertimeRateHelper.get_filter_by(filters, pgnum, pgsize, sort)\n end\n \n respond_to do |fmt|\n fmt.html { render :partial => 'list' }\n fmt.json { render :json => @data }\n end\n end",
"def filtering_params\n params.slice(:country, :data_source, :vaccine,\n :date_updated_start_date, :date_updated_end_date,\n :first_vaccine_date_start, :first_vaccine_date_end)\n end",
"def set_filters\n filter_param_keys = [\n 'brand', 'color',\n 'size', 'department', 'keywords'\n ]\n @filters = []\n filter_param_keys.each do |key|\n if !params[key].blank?\n params[key].split(',').each do |val|\n @filters << {:key => key, :val => val}\n end\n end\n end\n \n \n if params[:price]\n params[:price].split(',').each_slice(2).to_a.each do |range|\n @filters << {:key => 'price', :val => range.join(',')}\n end\n end\n\n if @products\n @brands = @products.facet('brand_facet').rows.sort_by{ |brand| brand.value.capitalize}\n @departments = @products.facet('department_facet').rows\n end\n \n @colors = ['green', 'blue', 'purple', 'red', 'pink', 'beige', 'brown', 'yellow', 'orange', 'black', 'white', 'gray', 'teal', 'glowing', 'gold', 'silver']\n \n if [email protected]? && @taxon.has_size?\n sizes = (Spree::Product.sizes.sort_by{|size| size.position}.map(&:presentation) & @products.facet(\"size_facet\").rows.map(&:value))\n end\n end"
] | [
"0.6162527",
"0.6090875",
"0.5870674",
"0.5672842",
"0.5644906",
"0.5632053",
"0.56187004",
"0.5609423",
"0.55813223",
"0.55688494",
"0.5558987",
"0.5553622",
"0.5519427",
"0.5518594",
"0.55093014",
"0.55067664",
"0.549222",
"0.54846996",
"0.54448706",
"0.5444231",
"0.5440396",
"0.54296243",
"0.5415769",
"0.5415748",
"0.5395863",
"0.53880167",
"0.53644437",
"0.53644437",
"0.53602195",
"0.535997",
"0.535997",
"0.53380215",
"0.5335597",
"0.5334278",
"0.53156346",
"0.5278249",
"0.52724624",
"0.525431",
"0.5241577",
"0.5229647",
"0.5226211",
"0.5222469",
"0.5216064",
"0.5214152",
"0.52105",
"0.5207126",
"0.5192142",
"0.51884794",
"0.5185761",
"0.518117",
"0.51761734",
"0.51733786",
"0.51726896",
"0.5159574",
"0.5155117",
"0.5153657",
"0.5153587",
"0.5153587",
"0.51535773",
"0.5144266",
"0.513897",
"0.51298696",
"0.5122874",
"0.51152223",
"0.5112598",
"0.509783",
"0.5094633",
"0.5083576",
"0.50821525",
"0.506744",
"0.5066071",
"0.50591075",
"0.505676",
"0.5054716",
"0.5049398",
"0.50476766",
"0.5046219",
"0.50281346",
"0.50280166",
"0.50239444",
"0.5020478",
"0.5018919",
"0.50186354",
"0.50057423",
"0.5005649",
"0.5000143",
"0.49971607",
"0.49839097",
"0.49702173",
"0.49679056",
"0.49672824",
"0.49522504",
"0.49516463",
"0.494383",
"0.4942363",
"0.49422422",
"0.49419793",
"0.49382827",
"0.49316418",
"0.4925318"
] | 0.60250616 | 2 |
main method magic at the bottom makes it run | def process
# here is a starting directory
main_dir = '/home/john/code/ruby/files'
# let's go to the directory we want
Dir.chdir(main_dir)
#print the present working directory (pwd)
puts Dir.pwd
# glob is stolen from Perl - list all the
# matches for the wildcard pattern "*"
listing = Dir.glob("*")
# put out the list
puts listing.inspect
#let's process the subdirectories and discard other files
listing.each do |f|
if File.directory? f
processDirectory f
else
puts "ignoring file: " + f
end
end
puts @power.inspect
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main; end",
"def run_main\n end",
"def main\n\n end",
"def main\n end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run() end",
"def run\n end",
"def run\n end",
"def run\n end",
"def run\n end",
"def run\n end",
"def run\n end",
"def run\n end",
"def run\n end",
"def run\n end",
"def run\n end",
"def run\n end",
"def run\n \n end",
"def run\n \n end",
"def main(argv)\n # override this; no default action in main\n end",
"def main\n\nend",
"def run(_); end",
"def run(_); end",
"def runner; end",
"def run()\n end",
"def run\n end",
"def program; end",
"def main_run\n raise NotImplementedError\n end",
"def execute\n setup\n begin\n data = main\n rescue ArgumentError => e\n warn e.message\n exit 1\n end\n puts format_data(data)\n end",
"def run\n raise \"Not implemented yet.\"\n end",
"def main_end ; end",
"def runs; end",
"def start_run; end",
"def main\n self\n end",
"def main\n\n # test\n\n # Console.new\n console_start\n end",
"def main\n puts \"computor\"\nend",
"def run_all()\n end",
"def run(*args); end",
"def run(*args); end",
"def run(*args); end",
"def run(*args); end",
"def run(*args); end",
"def run(*args); end",
"def run(*args); end",
"def run(*args); end",
"def run_program()\n final_words()\n segmented_output()\n end",
"def run\n log \"Nothing to do.\"\n end",
"def run_all\n end",
"def run_all\n end",
"def program() @program end",
"def run\n # Change the working directory to the directory of this script.\n Dir.chdir(File.dirname(__FILE__)) \n\n # if LIST_TECHNIQUES is true, just output available evasion techniques.\n if datastore['LIST_TECHNIQUES'] == true\n print_available_techniques()\n else\n payload = datastore['PAYLOAD']\n payload_options = datastore['PAYLOAD_OPTIONS']\n output_directory = datastore['OUTPUT_DIRECTORY']\n executable_name = datastore['EXECUTABLE_NAME']\n evasion_stack = datastore['EVASION_STACK']\n msfvenom_path = datastore['MSFVENOM_PATH']\n\n if payload == nil\n print_error(\"PAYLOAD must be set.\")\n return \n end\n if output_directory == nil \n print_error(\"OUTPUT_DIRECTORY must be set.\")\n return\n end\n if executable_name == nil \n print_error(\"EXECUTABLE_NAME must be set.\") \n return\n end\n if msfvenom_path == \"\"\n # Guess at path to msfvenom\n msfvenom_path = Dir.pwd[0..(Dir.pwd.index(\"pro\")+3)]+\"msf3/msfvenom\"\n print_status(\"MSFVENOM_PATH not specified. Hoping msfvenom can be found at \"+msfvenom_path+\".\")\n end\n\n binary_generated = generate_binary(msfvenom_path, payload, payload_options)\n if binary_generated\n print_status(\"Payload binary generated successfully.\")\n print_status(\"Generating evasive source from generated binary.\")\n\n generate_evasive_source(evasion_stack)\n\n executable_generated = generate_executable(output_directory+\"/\"+executable_name)\n\n if executable_generated\n print_status(\"Executable successfully generated.\")\n else\n print_error(\"Unable to generate executable.\")\n end\n else\n print_error(\"Payload generation with msfvenom failed.\")\n end\n\n print_status(\"Cleaning up temporary files.\")\n\n if File.exist?('tmp/bin'+self.uuid+'.c')\n File.delete('tmp/bin'+self.uuid+'.c')\n end\n if File.exist?('tmp/evasive'+self.uuid+'.c')\n File.delete('tmp/evasive'+self.uuid+'.c')\n end\n\n end\n end",
"def run(*args)\n end",
"def standalone; end",
"def main\n @app.main\n end",
"def run; new.run; end",
"def running; end",
"def running; end",
"def setup\r\n end",
"def main\n @workspace.main\n end",
"def run(*args)\n end",
"def setup\n \n end",
"def setup\n \n end",
"def setup\n \n end",
"def setup\n \n end",
"def setup\n \n end",
"def setup\n \n end",
"def setup\n \n end",
"def exec; end",
"def exec; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def run\n setup\n fuzzing_loop\n end",
"def main\r\n operations.make\r\n \r\n intro\r\n \r\n # Prepares tubes, buffers, and other equiptment to extract RNA either mechanical/enzymaticall and takes into account the RNA kit used(RNeasy/miRNeasy)\r\n rna_extraction_prepartion(INPUT, OUTPUT, METHOD, CELL_LYSIS)\r\n \r\n # Fresh overnights/cells need to be quenched and pelleted before extraction\r\n over_ops = operations.select { |op| op.input(INPUT).object_type.name == 'Yeast Overnight Suspension'}\r\n (!over_ops.empty?) ? quenching(over_ops, INPUT) : nil\r\n \r\n # Assumption is that samples that are not overnights will be in the -80 freezer - this gathers the remaining samples that will be processed in this experiment\r\n remaining_ops = operations.select { |op| op.input(INPUT).object_type.name != 'Yeast Overnight Suspension'}\r\n \r\n # Retrieves the remaining operations that are NOT overnights\r\n (!remaining_ops.empty?) ? show {warning \"<b> If you are gathering your samples from the freezer, keep them on ice from this step until noted.</b>\"} : nil\r\n (!remaining_ops.empty?) ? (take remaining_ops.map {|op| op.input(INPUT).item}, interactive: true): nil\r\n \r\n # Groups operations by cell lysing method and processes them by method\r\n group_by_lysis = operations.map.group_by {|op| op.input(CELL_LYSIS).val}.sort\r\n group_by_lysis.each {|lys_arr| cell_lysis(lys_arr) }\r\n \r\n # Return chemicals back to appropriate storage\r\n clean_fumehood\r\n \r\n # Directs tech to use Qiagen kits - Once cell have been processed to lysates \r\n qiagen_kit\r\n \r\n delete_input_items \r\n \r\n nanodrop_rna_extracts(INPUT, OUTPUT)\r\n \r\n delete_input_items\r\n \r\n operations.store\r\n return {}\r\n end",
"def main\n\n\n operations.running.retrieve interactive: false\n save_user operations\n debug_setup(operations) if debug\n \n if KIT_NAME == \"uw kit\"\n if debug\n labels = \"ABCDEF\".split('')\n operations.each.with_index do |op, i|\n op.input(INPUT).item.associate(SAMPLE_KEY, labels[i]) \n op.input(INPUT).item.associate(COMPONENT_KEY, \"\") \n end\n end\n end\n \n save_temporary_input_values(operations, INPUT)\n operations.each do |op|\n op.temporary[:pack_hash] = PACK_HASH\n end\n save_temporary_output_values(operations)\n \n # reassign labels to sample numbers if uw kit\n if KIT_NAME == \"uw kit\"\n operations.each do |op|\n op.temporary[:output_sample] = {\"A\"=>1, \"B\"=>2}[op.temporary[:output_sample]]\n end \n end\n \n run_checks operations\n if KIT_NAME == \"uw kit\"\n uw_kit_introduction operations.running\n else\n kenya_kit_introduction operations.running\n end\n area_preparation \"pre-PCR\", MATERIALS, POST_PCR\n get_pcr_packages operations.running\n open_pcr_packages operations.running\n debug_table operations.running\n check_for_tube_defects sorted_ops.running\n # nuttada thaw\n # nuttada needs vortex + centrigure\n centrifuge_samples sorted_ops.running\n resuspend_pcr_mix sorted_ops.running\n add_template_to_master_mix sorted_ops.running\n cleanup sorted_ops\n start_thermocycler sorted_ops.running\n conclusion sorted_ops\n return {}\n end",
"def run\n puts \"Hello world\"\n end",
"def start\n end"
] | [
"0.8372393",
"0.82667977",
"0.82236934",
"0.82036453",
"0.79371434",
"0.79371434",
"0.79371434",
"0.79371434",
"0.79371434",
"0.79371434",
"0.79371434",
"0.79371434",
"0.79371434",
"0.7652363",
"0.76128864",
"0.76128864",
"0.76128864",
"0.76128864",
"0.76128864",
"0.76128864",
"0.76128864",
"0.7580152",
"0.7580152",
"0.7556517",
"0.7548783",
"0.7517526",
"0.7517526",
"0.74978906",
"0.745968",
"0.7353111",
"0.7353111",
"0.72758555",
"0.726",
"0.72107345",
"0.7190083",
"0.70904285",
"0.7051158",
"0.703271",
"0.698241",
"0.6924861",
"0.6924304",
"0.6789657",
"0.6785587",
"0.6735766",
"0.67289686",
"0.6690227",
"0.6690227",
"0.6690227",
"0.6690227",
"0.6690227",
"0.6690227",
"0.6690227",
"0.6690227",
"0.6652767",
"0.66394967",
"0.6638934",
"0.6638934",
"0.66312754",
"0.65939564",
"0.65881634",
"0.65815485",
"0.6573281",
"0.65642464",
"0.6540193",
"0.6540193",
"0.6516705",
"0.6482302",
"0.6468748",
"0.6460408",
"0.6460408",
"0.6460408",
"0.6460408",
"0.6460408",
"0.6460408",
"0.6460408",
"0.64565605",
"0.64565605",
"0.6453184",
"0.6453184",
"0.6453184",
"0.6453184",
"0.6453184",
"0.6453184",
"0.6453184",
"0.6453184",
"0.6453184",
"0.6453184",
"0.6453184",
"0.6453184",
"0.6453184",
"0.6453184",
"0.6453184",
"0.6453184",
"0.6453184",
"0.6453184",
"0.6453184",
"0.64530843",
"0.64505416",
"0.6437221",
"0.6432548",
"0.6428055"
] | 0.0 | -1 |
Is the user logged in or not? | def authenticate
if signed_in? == false
flash.now[:error] = "User not logged in."
respond_with(flash)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_is_logged_in()\n user = get_user()\n if user != nil\n true\n else\n false\n end\n end",
"def logged_in?\n !!logged_user\n end",
"def logged_in?\n if current_user\n true\n else\n false\n end\n end",
"def user_is_logged_in?\n !!session[:user_id]\n end",
"def logged_in?\n if current_user\n true\n else \n false\n end\n end",
"def logged_in?\n current_user.present? # True neu user login\n end",
"def logged_in?\n\t\t\tcurrent_user.is_a? User\n\t\tend",
"def logged_in?\n current_user.present?\n end",
"def logged_in?\n current_user != :false\n end",
"def logged_in?\n current_user != :false\n end",
"def logged_in?\n\t\tcurrent_user.present?\n\tend",
"def logged_in?\n current_user != :false \n end",
"def logged_in?\n user._logged_in?\n end",
"def logged_in?\n if !session[:user_id].nil?\n return true\n else\n return false\n end\n end",
"def logged_in?\r\n current_user != :false\r\n end",
"def logged_in?\n current_user ? true : false;\n end",
"def logged_in\n current_user != nil\n end",
"def logged_in?\n (current_user ? login_access : false).is_a?(User)\n end",
"def is_logged_in?\n !session[:user_id].nil?\n end",
"def user_logged_in?\n current_user.present?\n end",
"def user_logged_in?\n current_user.present?\n end",
"def user_is_logged_in?\n !!session[:user_id]\n end",
"def logged_in?\n\t\t !!current_user\n end",
"def logged_in?\n @logged_in\n end",
"def logged_in?\n @logged_in\n end",
"def logged_in?\n @logged_in\n end",
"def logged_in?\n @logged_in\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n @logged_in == true\n end",
"def logged_in?\n @logged_in == true\n end",
"def logged_in?\n !session[:user_id].nil?\n end",
"def logged_in?\n !session[:user_id].nil?\n end",
"def logged_in?\n !session[:user_id].nil?\n end",
"def logged_in?\n !session[:user_id].nil?\n end",
"def is_logged_in?\n\t\t!session[:user_id].nil?\n\tend",
"def logged_in?\n if session[:username]\n if session[:logged_in?]\n return true\n end\n else\n return false\n end\n end",
"def logged_in?()\n if session[:user_id]\n return true\n else \n return false\n end\n end",
"def logged_in?\n !!logged_in_user \n end",
"def logged_in?\n\n if session[:current_user_id]\n return true\n end\n \n #Default return false\n false\n \n end",
"def logged_in?\n current_user_id.to_i > 0\n end",
"def logged_in?\n !current_user.blank?\n end",
"def logged_in?\n return false unless session[:user_id]\n\n User.find_by_id(session[:user_id]).present?\n end",
"def is_logged_in_user?\n session[:user_authenticated]\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n current_user\n end",
"def logged_in?\n current_user\n end",
"def logged_in?\n\t\t!current_user.nil?\n \tend",
"def logged_in?\n return session[:user_id].present?\n end",
"def is_logged_in?\n session[:user_id].present?\n end",
"def logged_in?\r\n\t\t!current_user.nil?\r\n\tend",
"def logged_in?\n @logged_in ? true : false\n end",
"def logged_in?\n \t\t!current_user.nil?\n \tend",
"def logged_in?\n !!session[:user_id]\n # !!@current_user\n end",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n\t\t!current_user.nil?\n\tend",
"def logged_in?\n current_user != nil ? true : false\n end",
"def logged_in?\n current_user.is_a? User\n end",
"def logged_in?\n return session['current_user']\n end",
"def logged_in?\n !current_user.nil?\n end",
"def logged_in?\n !current_user.nil?\n end",
"def logged_in?\n \t!current_user.nil? && session[:user_id]\n\tend",
"def logged_in?\n return true if self.current_user\n return false\n end",
"def logged_in?\n\t !current_user.nil?\n\t end",
"def _is_login\n p session[:user]\n session[:user] ? true : false\n end",
"def logged_in?\n \t!current_user.nil?\n \tend",
"def logged_in?\n #boolean return\t\n \tcurrent_user != nil\n end",
"def user_logged_in?\n session[:user_id].present?\n end",
"def logged_in?\n !!session[:logged_in]\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n !!current_user\n end",
"def logged_in?\n \t\tcurrent_user.is_a? User\n \tend"
] | [
"0.9070548",
"0.8805575",
"0.8769474",
"0.87556773",
"0.8705976",
"0.8703326",
"0.8696083",
"0.8695365",
"0.86890256",
"0.86890256",
"0.8683884",
"0.86760247",
"0.8675657",
"0.8672885",
"0.8658672",
"0.8652611",
"0.8648053",
"0.86465716",
"0.8641195",
"0.8636966",
"0.8636966",
"0.8620608",
"0.86192083",
"0.8618509",
"0.8618509",
"0.8618509",
"0.8618509",
"0.86166656",
"0.86166656",
"0.86166555",
"0.86166555",
"0.8616133",
"0.8616133",
"0.8616133",
"0.8616133",
"0.86149985",
"0.86143535",
"0.8610186",
"0.86020744",
"0.8601629",
"0.860108",
"0.8592591",
"0.858791",
"0.8584629",
"0.85790396",
"0.85790396",
"0.85790396",
"0.85790396",
"0.85790396",
"0.85790396",
"0.85790396",
"0.85790396",
"0.85790396",
"0.8577126",
"0.8577126",
"0.8572931",
"0.85653675",
"0.85628444",
"0.85606796",
"0.8555564",
"0.85541856",
"0.85514706",
"0.854787",
"0.8547089",
"0.85465276",
"0.85465276",
"0.85465276",
"0.85465276",
"0.85465276",
"0.85465276",
"0.85465276",
"0.85465276",
"0.85465276",
"0.85465276",
"0.85465276",
"0.85465276",
"0.85465276",
"0.85465276",
"0.85465276",
"0.85465276",
"0.85465276",
"0.85465276",
"0.85465276",
"0.8546139",
"0.8543309",
"0.8540859",
"0.8538519",
"0.8538519",
"0.8537407",
"0.8534675",
"0.8530803",
"0.8527681",
"0.85229397",
"0.8511562",
"0.8504017",
"0.8490708",
"0.84874684",
"0.84874684",
"0.84874684",
"0.84874684",
"0.8480087"
] | 0.0 | -1 |
Write a method that takes an Array as an argument, and returns two Arrays (as a pair of nested Arrays) that contain the first half and second half of the original Array, respectively. If the original array contains an odd number of elements, the middle element should be placed in the first half Array. | def halvsies(arr)
halfway = arr.size / 2
halfway += 1 if arr.size.odd?
first_half = arr[0..(halfway - 1)]
second_half = arr[halfway..-1]
[first_half, second_half]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def halvsies(array)\n if array.size.even?\n arr1 = array.slice(0, (array.size / 2))\n arr2 = array.slice(array.size / 2, array.size)\n else\n arr1 = array.slice(0, (array.size / 2) + 1 )\n arr2 = array.slice((array.size / 2) + 1, array.size)\n end \n [arr1, arr2]\nend",
"def first_half(array)\n\n new_arr = []\n even_arr = array.length / 2\n odd_arr = even_arr + 1\n \n i = 0\n \n if array.length % 2 == 0\n \t \n while i < even_arr\n \t \n \tnew_arr << array[i] \n i += 1\n \n end\n elsif array.length % 2 == 1\n \t\n\twhile i < odd_arr\n \t\n \tnew_arr << array[i]\n \ti += 1\n \n end\n \n end\n \n return new_arr\nend",
"def halvsies(arr)\n \n left_array = []\n right_array = []\n middle_index = arr.size / 2\n if arr.size.even?\n left_array = arr[0...middle_index]\n right_array = arr[middle_index..-1]\n elsif\n left_array = arr[0..middle_index]\n right_array = arr[(middle_index + 1)..-1]\n end\n [left_array, right_array]\nend",
"def halvsies(array)\n second_half, middle_element = array.size.divmod(2)\n first_half_size = second_half + middle_element\n output_array = []\n first_half_array = []\n second_half_array = []\n\n array.each_with_index do |el, idx|\n if idx <= first_half_size - 1\n first_half_array << el\n else\n second_half_array << el\n end\n end\n\n output_array << first_half_array << second_half_array\nend",
"def create_inner_arrays(array)\n size = array.size\n array = [array.first((size + 1) / 2), array.last(size / 2)]\nend",
"def halvsies(arr)\n if arr.size.odd?\n first = arr[0..(arr.size/2)]\n second = arr[(arr.size/2 + 1)..-1]\n else\n first = arr[0..(arr.size/2 - 1)]\n second = arr[(arr.size/2)..-1]\n end\n final_arr = [first, second]\nend",
"def halvsies(array)\n result = []\n size = array.size\n if size.even?\n result << first_half = array.shift(size/2)\n result << second_half = array.shift(size/2)\n else\n result << first_half = array.shift(size/2+1)\n result << second_half = array.shift(size/2)\n end\nend",
"def halvsies(array)\r\n middle = (array.size / 2.0).ceil\r\n first_half = array.slice(0, middle)\r\n second_half = array.slice(middle, array.size - middle)\r\n [first_half, second_half]\r\nend",
"def halvsies(arr)\n arr_1 = []\n arr_2 = []\n\n if arr.size.odd?\n arr_1 = arr.shift((arr.size / 2) + 1)\n arr_2 = arr\n else\n arr_1 = arr.shift(arr.size / 2 )\n arr_2 = arr\n end\n\n [arr_1, arr_2]\nend",
"def first_half(array)\n \ti = 0\n \tnewArray = []\n\twhile i < (array.length / 2.0)\n newArray << array[i]\n i += 1\n end\n \treturn newArray\nend",
"def halvsies(array)\n new_array = [[],[]]\n half_way = array.length / 2.0\n array.each_with_index do | element, index |\n if index < half_way\n new_array[0] << element\n else\n new_array[1] << element\n end\n end\n new_array\nend",
"def halvsies(array)\n half = []\n middle = (array.length / 2.0 ).ceil\n half << array.slice(0,middle) #start, # of elements\n half << array.slice(middle, array.length) #can use middle and not middle+1 because middle equals the index of the element after middle.\n half\nend",
"def halvsies(array)\n new_array = []\n array_size = array.size\n left_array_size = if array_size.odd?\n array_size / 2 + 1\n else\n array_size / 2\n end\n new_array[0] = array.slice!(0, left_array_size)\n new_array[1] = array\n # new_array[0] = array.slice(0, left_array_size)\n # new_array[1] = array.slice(left_array_size, array_size - left_array_size)\n new_array\nend",
"def first_half(array)\n\tnew_array = []\n \n\ti = 0\n\twhile i < (array.length / 2.0)\n\t\tnew_array << array[i]\n\t\ti += 1\n end\n \n\treturn new_array\nend",
"def first_half(array)\n i = 0\n newArr = []\n while i < array.length / 2.0\n newArr << array[i]\n i += 1\n end\n return newArr\n end",
"def halve array\n middle = (array.length / 2.0).round\n left = [0..middle]\n right = [middle..(array.last)]\n [left,right]\nend",
"def halvsies(original_array)\n if original_array.size.even?\n halfway = original_array.size / 2\n first_half = original_array[0, halfway]\n second_half = original_array[halfway, original_array.size - halfway]\n return [first_half, second_half]\n else\n halfway = (original_array.size / 2) + 1\n first_half = original_array[0, halfway]\n second_half = original_array[halfway, original_array.size - halfway]\n return [first_half, second_half]\n end\nend",
"def halve array\n middle = (array.size / 2.0).round - 1\n left = array[0..middle]\n right = array[(middle+1)..(array.last)]\n [left,right]\nend",
"def halvsies(arr)\n midpoint = arr.length.even? ? arr.length / 2 : (arr.length / 2) + 1\n arr1 = arr[0,midpoint]\n arr2 = arr[midpoint..-1]\n [arr1, arr2]\nend",
"def halvsies(array)\n first_half = []\n second_half = []\n array.each_with_index do |elem, idx|\n if idx < (array.length/2.0).ceil\n first_half << elem\n else\n second_half << elem\n end\n end\n [first_half, second_half]\nend",
"def halvsies(array)\n first_half = array.slice(0, (array.size / 2.0).ceil)\n second_half = array.slice(first_half.size, array.size - first_half.size)\n [first_half, second_half]\nend",
"def halvsies(array)\n first_half = array.slice(0, (array.size / 2.0).ceil)\n second_half = array.slice(first_half.size, array.size - first_half.size)\n [first_half, second_half]\nend",
"def halvsies(array)\n first_half = array.slice(0, (array.size / 2.0).ceil)\n second_half = array.slice(first_half.size, array.size - first_half.size)\n [first_half, second_half]\nend",
"def halvsies(array)\n first_half = array.slice(0, (array.size / 2.0).ceil)\n second_half = array.slice(first_half.size, array.size - first_half.size)\n [first_half, second_half]\nend",
"def halvsies(array)\n first_half = array.slice(0, (array.size / 2.0).ceil)\n second_half = array.slice(first_half.size, array.size - first_half.size)\n [first_half, second_half]\nend",
"def first_half(array)\n half_arr = []\n\n i = 0\n\n while i < array.length / 2.0\n half_arr << array[i]\n i += 1\n end\n return half_arr\nend",
"def halvsies(arr)\n first_half = arr.slice(0, (arr.size / 2.0).ceil)\n second_half = arr.slice(first_half.size, arr.size - first_half.size)\n [first_half, second_half]\nend",
"def halvsies(array)\n first_half = []\n both_halves = []\n\n if array.size == 1 || array.size == 0\n both_halves << array\n both_halves << first_half\n elsif array.size / 2 == 0\n ((array.size) / 2).times do\n first_half << array.shift\n end\n both_halves << first_half\n both_halves << array\n else\n (((array.size - 1) / 2) + 1).times do\n first_half << array.shift\n end\n both_halves << first_half\n both_halves << array\n end\n both_halves\nend",
"def halve array\n middle = (array.size / 2.0).round\n left = array[0..middle]\n right = array[middle..(array.size)]\n return [left,right] # explicit return for clarity :P\nend",
"def halvsies(ary)\n first_half, second_half = [], []\n return first_half, second_half if ary.empty? # handle empty array\n half = ary.length.odd? ? (ary.length / 2) + 1 : ary.length / 2\n first_half = ary[0...half]\n second_half = ary[half..-1]\n\n [first_half, second_half]\nend",
"def halvsies(array)\n arr1 = []\n arr2 = []\n half_length_round_down = array.length/2\n \n index = 0\n index2 = half_length_round_down\n index2 += 1 if array.length.odd?\n \n loop do\n break if index == half_length_round_down\n arr1 << array[index]\n arr2 << array[index2]\n index += 1\n index2 += 1\n end\n \n if array.length.odd?\n arr1 << array[index]\n # because break statement is after index increases we don't have to increase it again\n end\n \n [arr1, arr2]\nend",
"def first_half(array)\n\ti = 0\n \tarry = []\n while i < (array.length / 2.0)\n arry << array[i]\n i += 1\n end\n return arry\nend",
"def first_half(array)\n\n\ti = 0\n\n\tnew_array = []\n\n\twhile i < array.length / 2.0 # This is makes sure that the loop runs while i is less than half of the length; thus the divided by two expression. This will always include the middle element since the index value is still less than half the whole array length value.\n\n\t\tnew_array << array[i] # Array of i is important here or else it wont add the specific array value into the new array variable\n\n\t\ti += 1\n\t\t\n\tend\n\treturn new_array\nend",
"def halvsies(array)\n length = array.length\n new_array = []\n\n if length.odd?\n new_array << array.first(length / 2 + 1)\n new_array << array.last(length / 2)\n else\n new_array << array.first(length / 2)\n new_array << array.last(length / 2)\n end\n\n new_array\nend",
"def halvsies(arr)\n return_array = [[],[]]\n arr.each_with_index do |item, index|\n if arr.size.even?\n index < (arr.size) /2 ? return_array[0] << item : return_array[1] << item\n else\n index <= (arr.size) /2 ? return_array[0] << item : return_array[1] << item\n end\n end\n return_array\nend",
"def halvsies(arr)\n middle = (arr.size/2.0).ceil\n first = arr.slice(0, middle)\n second = arr.slice(middle, arr.size - middle)\n [first, second]\nend",
"def halvsies(array)\n array1 = []\n array2 = []\n n = 0\n array.size.odd? ? m = 1 : m = 0\n\n (array.size / 2 + m).times do\n array1 << array[n]\n n += 1\n end\n\n (array.size / 2).times do\n array2 << array[n]\n n += 1\n end\n\n [array1, array2]\nend",
"def halvsies(arr)\n index = (arr.length) / 2\n if arr.length.odd?\n [arr[0..index], arr[index+1..-1]]\n else\n [arr[0..index-1], arr[index..-1]]\n end\nend",
"def halvsies(arr)\n sliced_arr = []\n half = arr.length / 2.0\n if arr.size.even?\n sliced_arr << arr[0..half - 1] << arr[half..-1]\n else\n sliced_arr << arr[0..half] << arr[half+1..-1]\n end\n sliced_arr\nend",
"def halvsies(arr)\n size = arr.size\n first_half_size = size.odd? ? (size / 2) + 1 : size / 2\n\n result_arr = []\n\n result_arr << arr.slice(0, first_half_size)\n result_arr << arr.slice(first_half_size, size / 2)\n\n result_arr\nend",
"def first_half(array)\n half = []\n i = 0\n max = array.length - (array.length / 2)\n while i < max\n half << array[i]\n i += 1\n end\n return half\n \n end",
"def halvsies (arr)\n midpoint = (arr.size/2.0).ceil\n first_half = (0...midpoint)\n second_half = (midpoint..-1)\n\n return [arr[first_half], arr[second_half]]\nend",
"def halvsies(array)\n result = [[],[]]\n array.each_index do |i|\n if i < (array.size / 2.0)\n result[0] << array[i]\n else\n result[1] << array[i]\n end\n end\n result\nend",
"def halvsies(arr)\n middle = arr.size / 2\n cut = arr.size.even? ? middle : middle + 1\n a = arr.take(cut)\n b = arr.drop(cut)\n [a, b]\nend",
"def halvsies(array)\n half1 = array.slice(0, (array.size / 2.0).ceil)\n half2 = array.slice(half1.size, array.size - half1.size)\n [half1, half2]\nend",
"def first_half(array)\n new_array = []\n max = array.length / 2.0\n i = 0\n while i < max\n new_array << array[i]\n i += 1\n end\n\n return new_array\nend",
"def halvsies(array)\n result = []\n if array.size.odd?\n result << array[0..(array.size / 2)] << array[(array.size / 2 + 1)..-1]\n elsif array.size.even?\n result << array[0..((array.size / 2) - 1)] << array[(array.size / 2)..-1]\n end\n result\nend",
"def first_half(array)\n elements = []\n \n i = 0\n while i <= array.length / 2.0\n elements << array[i]\n \n i += 1\n end\n \n return elements\nend",
"def first_half(arr)\n original_arr_length = arr.length/2\n split1 = arr.reverse\n first_half = []\n while (split1.length > original_arr_length)\n first_half << split1.pop \n end\n first_half.reverse\nend",
"def halvsies(array)\n first_half = array.slice(0, (array.size / 2.0).ceil)\n [first_half, (array - first_half)]\nend",
"def halvsies(array)\n halvs = []\n first_half_size = array.size % 2 == 0 ? array.size / 2 : array.size / 2 + 1\n halvs[0] = array[0...first_half_size]\n halvs[1] = array[first_half_size..-1]\n halvs\nend",
"def halvsies(arr)\n first_halve_length = (arr.size / 2.0).round\n first_halve = arr[0, first_halve_length]\n second_halve = arr[first_halve_length, arr.size - first_halve_length]\n [first_halve, second_halve]\nend",
"def merge_sort_two(array)\n size = array.size\n return array if size < 2\n\n ##Find the mid_point\n mid_point = size / 2\n\n ##Divide\n left = (array.slice(0, mid_point))\n right = (array.slice(mid_point, array.size)) ##the right part may be odd\n\n merge_two(merge_sort_two(left), merge_sort_two(right))\nend",
"def halvsies(arr)\n num_in_first_half = (arr.size / 2.0).ceil\n [arr[0, num_in_first_half], arr[num_in_first_half, arr.size - num_in_first_half]]\nend",
"def first_half(array)\n\tarr = [] # initialize arr\n \ti = 0 # start at first indice\n\n while i < (array.length / 2.0) # while indice is less than the length of the array rounded up by half\n push_this = array[i] # add corresponding item into variable \n arr << push_this # add variable into the array\n\n i += 1 # iterate next\n end\n\n return arr\nend",
"def halvsies(array)\n half = (array.length / 2.0).round\n [array.take(half), array.drop(half)]\nend",
"def halvsies(arr)\n first_half_el = (arr.size / 2.0).round - 1 \n second_half_el = arr.size == 1 ? 0 : (arr.size / 2.0).to_i * -1\n first_half = arr[0..first_half_el]\n second_half = second_half_el == 0 ? [] : arr[second_half_el..-1]\n\n halvsies = [first_half, second_half]\nend",
"def halvsies(arr)\n if arr.size == 0 then\n return [[], []]\n else\n split_point = (arr.size / 2.0).ceil - 1\n return [arr[(0..split_point)], arr[split_point+1..arr.length-1]]\n end \nend",
"def merge_sort(array)\n return array if array.length < 2\n middle_idx = array.length / 2\n first_half = array.take middle_idx\n last_half = array.drop middle_idx\n\n merge_helper(merge_sort(first_half), merge_sort(last_half))\nend",
"def middle_in_array(array)\n array[array.length / 2]\nend",
"def halvsies(array)\n first = []\n second = []\n \n first_of_last_array = (array.size/2.0).round(0)\n\n array.each_with_index do |num, index|\n if index < first_of_last_array\n first << num\n else\n second << num\n end\n end\n [first, second]\n\nend",
"def first_half(array)\n max = array.length / 2.0 \n puts max\n half = [] \n index = 0 \n \n while index < max\n half << array[index]\n index += 1 \n end \n \n return half\n \nend",
"def merge_sort(array)\n return array if array.length <= 1\n\n first_half = array.take(array.length / 2)\n second_half = array.drop(first_half.length)\n\n merge( merge_sort(first_half), merge_sort(second_half) )\nend",
"def halvsies(arr)\n sizing = (arr.size.to_f / 2).ceil\n first, second = arr[0..sizing-1], arr[sizing.. -1]\nend",
"def separate_array_into_even_and_odd_numbers(array)\n #Find out if each element even or odd\n # if even, put into one array\n # if odd, put into other array\n # combine arrays\n even_array = Array.new\n odd_array = Array.new\n final_array = Array.new\n array.each{|number|\n if number.odd?\n odd_array << number\n else\n even_array << number\n end\n }\n final_array = [even_array,odd_array]\nend",
"def stretch(array)\n\n stretched_array = []\n\n for element in array\n if element % 2 == 0\n stretched_array << element/2\n stretched_array << element/2\n else\n stretched_array << element/2 + 1\n stretched_array << element/2\n end\n end\n\n return stretched_array\n\nend",
"def halvsies(ary)\r\n length = ary.size\r\n ary2 = []\r\n (length / 2).times{ ary2.unshift(ary.pop) }\r\n results = [ary, ary2]\r\nend",
"def stretch(array)\n new_arr = []\n # can assign array to an variable and do only /2 once\n for i in 0...array.length\n # if element is a even number\n if array[i] % 2 == 0\n # add 1/2 value of the element for twice into the new array\n new_arr << array[i]/2\n # if element is an odd number\n else\n new_arr << array[i]/2 + 1\n end\n new_arr << array[i]/2\n end\n return new_arr\nend",
"def stretch(arr)\n # new empty array\n new_arr = []\n # go through each element\n arr.each do |number|\n # if even, divide by two\n if number % 2 == 0\n new_arr << (number / 2)\n new_arr << (number / 2) # this isn't DRY, I think\n # if odd, subtract one, divide by two. Add one to the first half\n else\n new_arr << (((number - 1) / 2) + 1)\n new_arr << ((number - 1) / 2) # DRY-ness issue here, maybe\n # store both halves\n end\n end\n # return new array\n return new_arr\nend",
"def evenities1(array)\n index = 1\n even_array = []\n while index < array.length\n even_array << array[index]\n index += 2\n end\n even_array\nend",
"def halvsies(arr)\n midpoint = (arr.length / 2.0).ceil\n [arr[0...midpoint], arr[midpoint..-1]]\nend",
"def oddities(array)\n elements = []\n index = 0\n while index < array.size\n elements << array[index]\n index += 2\n end\n elements\nend",
"def merge_sort(array) # ***\n return array if array.length <= 1\n mid_idx = (array.length - 1) / 2\n\n first_half = merge_sort(array[0..mid_idx])\n second_half = merge_sort(array[mid_idx + 1..-1])\n\n merge(first_half, second_half)\n # merge(merge_sort(array[0..mid_idx]), merge_sort(array[mid_idx + 1..-1]))\nend",
"def oddities(array)\n new_array = []\n i = 0\n while i < array.size\n new_array << array[i]\n i += 2\n end\n new_array\nend",
"def merge_sort(array)\n if array.length < 2\n return array\n end\n first_half = array[0...array.length / 2]\n second_half = array[array.length / 2..-1]\n\n merge(merge_sort(first_half), merge_sort(second_half))\nend",
"def halvsies(ary)\n ary.size.even? ? [ary[0...(ary.size/2)], ary[(ary.size/2)..-1]] : [ary[0..(ary.size/2)], ary[(ary.size/2 + 1)..-1]]\nend",
"def oddities(array)\n odd_elements = []\n index = 0\n while index < array.size\n odd_elements << array[index]\n index += 2\n end\n odd_elements\nend",
"def oddities(array)\n odd_elements = []\n index = 0\n while index < array.size\n odd_elements << array[index]\n index += 2\n end\n odd_elements\nend",
"def odd_elements(array)\n res = []\n (1...array.length).step(2).each do |idx|\n elem = array[idx]\n elem = yield elem if block_given?\n res.push(elem)\n end\n\n res\nend",
"def oddities(array)\n new_array = []\n\n index = 0\n while index < array.size\n new_array << array[index] if index.even?\n index += 1\n end\n new_array\nend",
"def halvsies(arr)\n halvsies_arr1 = []\n halvsies_arr2 = []\n halves = arr.length / 2\n arr.length % 2 == 0 ? halves -= 1 : halves\n arr.each_with_index do |item, index|\n if index <= (halves)\n halvsies_arr1.push(item)\n else\n halvsies_arr2.push(item)\n end\n end\n [halvsies_arr1, halvsies_arr2]\nend",
"def merge_sort(array)\n middle_index = (array.length - 1) / 2\n if array.length == 0 || array.length == 1\n return array\n end\n first_half = merge_sort(array[0..middle_index])\n last_half = merge_sort(array[middle_index + 1..array.length - 1])\n return merge(first_half, last_half)\nend",
"def oddities(array)\n result = []\n index = 0\n\n while index < array.size\n result << array[index]\n index += 2\n end\n\n result\nend",
"def merge_sort(arr)\n return arr if arr.length <= 1\n # define middle element where array will be split\n case arr.length % 2 == 0\n when true\n middle_index = (arr.length - 1) / 2\n when false\n middle_index = arr.length / 2\n end\n\n left_half = arr[0..middle_index]\n right_half = arr[middle_index + 1..-1]\n sorted_left = merge_sort(left_half)\n sorted_right = merge_sort(right_half)\n merge(sorted_left, sorted_right)\nend",
"def oddities(array)\n new_array = []\n array.each_with_index { |val, idx| new_array << val if idx.even? }\n new_array\nend",
"def halvsies(array)\n array.partition do |e|\n array.size.even? ? array.take(array.size/2).include?(e) : array.take(array.size/2 + 1).include?(e)\n end\nend",
"def group(array)\n\t\tif (array.length%2) == 0 \n\t\t\tarray2=array[0..(array.length-1)/2]\n\t\t\tarray=array[(array.length)/2..array.length]\n\t\t\treturn array.zip(array2)\n\t\telse\n\t\t\todd_man = array[-1]\n\t\t\tarray = array[0..array.length-2]\n\t\t\tgrouped = group(array)\n\t\t\tgrouped[-1] = grouped[-1].push(odd_man)\n\t\t\tgrouped\n\t\tend\nend",
"def merge_sort(arr)\n return arr if arr.length <= 1\n\n if arr.length.odd?\n mid_idx = arr.length / 2\n else\n mid_idx = arr.length / 2 - 1\n end\n\n first_half = arr[0..mid_idx]\n second_half = arr[mid_idx + 1..-1]\n\n fh_split = merge_sort(first_half)\n sh_split = merge_sort(second_half)\n\n merge(fh_split, sh_split)\nend",
"def odds(arr)\n\tret = []\n\tarr.each_index { |i|\n\t\tif i % 2 == 1\n\t\t\tret << arr[i]\n\t\tend\n\t}\n\tret\nend",
"def eveness(array)\n new_array = []\n index = 1\n while index < array.size\n new_array << array[index]\n index += 2\n end\n new_array\nend",
"def merge_sort(array)\n return array if array.length == 1\n\n mid_index = array.length / 2\n end_index = array.length - 1\n\n left_half = array[0..mid_index - 1]\n right_half = array[mid_index..end_index]\n\n left_half_sorted = merge_sort(left_half)\n right_half_sorted = merge_sort(right_half)\n\n sorted = []\n until left_half_sorted.empty? || right_half_sorted.empty?\n sorted << (left_half_sorted.first < right_half_sorted.first ? left_half_sorted.shift : right_half_sorted.shift)\n end\n sorted + left_half_sorted + right_half_sorted\nend",
"def first_even\n\t@array[0]\n\t\t#returns 30\n\t\tarray_2 = @array.split(',')\n\t\t#splits apart the original array\n\t\t\tarray_3 =[]\n\t\t\t#creates a new array, in which I can shove in whatever I want\n\t\t\t\tarray_3 << [50, 3, 5, 15, 16, 23, 42, 300, 22, 1, 55, 42, 30, 17, 77, 102, 5, 11]\n\t\t\t\t\tarray_3.flatten!\n\t\t\t\t\t\n\n\nend",
"def oddities(array)\n return_array =[]\n array.each_with_index do |element, index|\n return_array << element if index.even?\n end\n return_array\nend",
"def oddities(array)\n ret_array = []\n array.each_with_index do |value, index|\n if index.even?\n ret_array << value\n end\n end\n ret_array\nend",
"def oddities(array)\n result = []\n index = 0\n\n loop do\n result << array[index]\n index += 2\n break if index >= array.size\n end\n\n result\nend",
"def oddities(array)\n\n result = [] # empty array to push each item in the array to.\n index = 0 # creates a counter called index\n\n while index < array.size\n result << array[index] # array index is the number in the array.\n index += 2 # += 2 iterates over and returns even items.\n end\n result # again with loops put the result outside of the loop.\nend",
"def merge_sort(arr)\n return arr if arr.length < 2\n middle_index = arr.length / 2\n one_half = arr[0...middle_index]\n two_half = arr[middle_index..-1]\n merge(merge_sort(one_half), merge_sort(two_half))\nend",
"def merge_sort arr\n\tif arr.length <= 1\n\t\tarr\n\telse\n\t\tmid = arr.length/2\n\t\tfirst_half = arr.slice(0...mid)\n\t\tsecond_half = arr.slice(mid...arr.length)\n\t\tmerge merge_sort(first_half), merge_sort(second_half)\n\tend\nend",
"def merge_sort(array)\n return array if array.length <= 1\n\n mid_idx = (array.length/2)\n left_side = array[0...mid_idx]\n right_side = array[mid_idx..-1]\n\n sort_left = merge_sort(left_side)\n sort_right = merge_sort(right_side)\n\n merge_halves(sort_left, sort_right)\nend",
"def merge_sort(array)\n\treturn [] if array.length == 0\n\treturn array if array.length == 1\n\n\tmidpoint = array.length / 2\n\tleft_side = array[0..midpoint].take(midpoint)\n\tright_side = array.drop(midpoint)\n\n\tmerge(merge_sort(left_side), merge_sort(right_side))\n\t# merge_sort(merge(left_side, right_side))\n\nend"
] | [
"0.77604485",
"0.7758353",
"0.7709774",
"0.7699967",
"0.7678196",
"0.76556075",
"0.7619841",
"0.76069474",
"0.75140005",
"0.75077814",
"0.7506743",
"0.74859536",
"0.74795204",
"0.7472657",
"0.7471359",
"0.7451214",
"0.7443248",
"0.74424607",
"0.74252826",
"0.74070036",
"0.740481",
"0.740481",
"0.740481",
"0.740481",
"0.740481",
"0.7404783",
"0.73905313",
"0.73869514",
"0.73869216",
"0.7386702",
"0.73800665",
"0.7354829",
"0.7349389",
"0.7340047",
"0.73260933",
"0.73180574",
"0.7290679",
"0.7271927",
"0.7255927",
"0.7250015",
"0.724952",
"0.72443944",
"0.72203445",
"0.7199328",
"0.71786445",
"0.71708024",
"0.7158624",
"0.71478695",
"0.6983458",
"0.69821835",
"0.69419485",
"0.69305307",
"0.6925271",
"0.6906832",
"0.69023335",
"0.6883507",
"0.6875145",
"0.68641025",
"0.68578124",
"0.6847901",
"0.6846353",
"0.6834107",
"0.68192714",
"0.6807934",
"0.67897946",
"0.6760219",
"0.6708225",
"0.6697039",
"0.6674636",
"0.6672552",
"0.6632421",
"0.66205406",
"0.660583",
"0.66031057",
"0.65971315",
"0.6587734",
"0.6582035",
"0.65818965",
"0.65708524",
"0.65687525",
"0.65647984",
"0.6561738",
"0.6549059",
"0.65484494",
"0.65126383",
"0.6475749",
"0.6474324",
"0.64686525",
"0.64624107",
"0.6461811",
"0.6460344",
"0.6456324",
"0.6448495",
"0.6440605",
"0.6413366",
"0.64082855",
"0.63898736",
"0.6384723",
"0.6380504",
"0.63745093"
] | 0.73730475 | 31 |
GET /items GET /items.json | def index
@search = Item.search(params[:q])
@search.sorts = 'name asc' if @search.sorts.empty?
@items = @search.result
if params[:q].present?
params[:q].each do |k, v|
if v == 'name asc'
@items = @search.result.sort { |p1, p2| p1.name.downcase <=> p2.name.downcase }
elsif v == 'name desc'
@items = @search.result.sort { |p2, p1| p1.name.downcase <=> p2.name.downcase }
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @items = Item.find(params[:id])\n render json: @items\n end",
"def items\n\t\tresponse = self.get('items').body\n\t\titems = JSON.parse(response)\n\t\tparse_items(items)\n\t\treturn items\n\tend",
"def getItems()\n return mergeWithAPI(@item_json)['data']\n end",
"def index\n @items = current_user.items\n respond_to do |format|\n format.html\n format.json { render json: @items }\n end\n end",
"def index\n #@items = Item.find_by_user_id(Session[user_id])\n @items = Item.all\n render json: @items\n end",
"def index\n @items = Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def index\n @items = Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def index\n @items = Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def index\n @items = Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def index\n @items = Item.found\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def index\n @items = Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @items }\n end\n end",
"def items\n \tbegin\n \t@categories = Category.all.includes(items: [:dimensions])\n \t@ingredients = Ingredient.actives\n \trender 'api/v1/home/items', status: :ok\n \trescue Exception => e\n \t\terror_handling_bad_request(e)\n \tend\n\n\tend",
"def index\n @items = Item.find(:all, :order => 'id ASC')\n # @items = Item.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def index\n @api_v1_items = Item.all\n render json: @api_v1_items\n end",
"def list_items( args={} )\n @session.base_url = \"http://my.cl.ly\"\n \n url = \"/items\"\n args.each do |k, v|\n # probably a nicer way to do this\n if url == \"/items\"\n url << \"?#{k.to_s}=#{v.to_s}\"\n else\n url << \"&#{k.to_s}=#{v.to_s}\"\n end\n end\n resp = @session.get( url )\n \n raise AuthorizationError if resp.status == 401\n Crack::JSON.parse(resp.body)\n end",
"def show\n item = Item.find(params[:id])\n render json: item\n end",
"def get_item( item )\n @session.base_url = \"http://cl.ly\"\n resp = @session.get( \"/\" + item )\n \n raise ItemNotFound if resp.status == 404\n Crack::JSON.parse(resp.body)\n end",
"def show\n authenticate\n list = List.find(params[:id])\n items = list.items\n render json: {\n items: items,\n id: list.id\n }\n end",
"def items\n response[\"items\"]\n end",
"def show\n render json: Item.find(params[:id])\n end",
"def index\n @items = @deal.items\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def show\n render json: Item.find(params[\"id\"])\n end",
"def item(uuid)\n http.get \"/items/#{uuid}\"\n end",
"def items\n @items ||= items_from_response\n end",
"def get_items\n @items\n end",
"def index\n @items = Item.includes(:user).order(created_at: :desc).all\n render json: @items\n end",
"def get_items\n response_xml = http_get(@client, \"#{xero_url}/Items\")\n parse_response(response_xml, {}, {:request_signature => 'GET/items'})\n end",
"def my\n items = current_user.items\n render json: items\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item.to_json() }\n end\n end",
"def index\n render json: RequestItem.all\n end",
"def show\n render json: @item\n end",
"def show\n @item = Item.all.where(collection_id: params[:id])\n render :json => @item\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n# @item = Item.get(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def items(); @items || CrateAPI::Items.new(); end",
"def index\n if params[:uid]\n @current_user = User.find_by(uid: params[:uid])\n render json: {\n status: 'SUCCESS',\n message: 'Loaded users',\n value: @current_user.items\n }\n else\n items = Item.order(created_at: :desc)\n render json: { status: 'SUCCESS', message: 'Loaded items', value: items }\n end\n end",
"def index\n @items = Admin::Item.by_agency(@current_agency.id)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @admin_items }\n end\n end",
"def get_items(product_id, params={})\n self.client.get(\"products/#{product_id}/items\", params)\n end",
"def index\n @section = Section.find(params[:section_id])\n @items = @section.items\n render json: ItemSerializer.new(@items)\n end",
"def index\n respond_to do |format|\n format.html\n format.json { render :json => Item.all}\n end\n\n end",
"def index\n @items = @user.items\n end",
"def index\n @rentable_items = RentableItem.all\n render json: @rentable_items\n end",
"def get_item\n @item = Item.find_by_id(params[:id])\n if @item\n return @item\n else \n render json: {\"message\": {\"type\": \"error\", \"content\": \"The item could not be found!\"}}\n end\n end",
"def show\n @item = @deal.items.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def items\n @beverages = Beverage.available\n respond_to do |format|\n format.json { render :json => @beverages.to_json(methods: :image_url)}\n end\n end",
"def get_books(response)\n response[\"items\"]\nend",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n @budget = Budget.find params[:budget_id]\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def items\n response = @client.request :get, \"#{LISTS_PATH}/#{@id}\"\n raise(StandardError, 'unexpected response') unless response\n response['items']&.map { |i| TodoableItem.new self, i, @client }\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json\n end\n end",
"def index\n if params[:cart_id]\n get_cart\n @items = Item.where(cart: @cart)\n elsif params[:order_id]\n get_order\n @items = Item.where(order: @order)\n end\n render json: @items, status: 200\n end",
"def index\n @active_items = Item.select(&:active?).sort_by(&:name)\n @inactive_items = Item.select(&:inactive?).sort_by(&:name)\n\n @item = Item.new\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def show\n \n render status: 200, :json => @item\n\n end",
"def index\n @items = Item.all\n\n end",
"def index\n @items = @channel.items\n @items = @query.search(@items)\n @items = @items.order_by_published_at_desc\n @items = @items.page(params[:page]).per(10)\n\n respond_to do |format|\n format.html\n format.json { render json: @items }\n end\n end",
"def items\n @items = current_user.items.paginate(:page => params[:page])\n end",
"def index\n self.identify_user\n @items = @user.items\n @itemlist = @items.map do |item|\n convert_to_json(item)\n end\n respond_to do |format|\n format.json { render :json => @itemlist }\n format.xml { render :xml => @items }\n format.html { render text: \"Unsupported Format\", status: 404 }\n end\n end",
"def fetch\n result = WebApi.json!('ITFItems_440', 'GetPlayerItems', 1, { :SteamID => @steam_id64 })\n\n @items = []\n result[:items][:item].each do |item_data|\n unless item_data.nil?\n item = TF2Item.new(item_data)\n @items[item.backpack_position - 1] = item\n end\n end\n end",
"def index\n @items = Item.accessible_by(current_ability)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n format.xml { render xml: @items }\n end\n end"
] | [
"0.79562956",
"0.7546286",
"0.74375594",
"0.7434485",
"0.73975587",
"0.7358414",
"0.7358414",
"0.7358414",
"0.7358414",
"0.7357372",
"0.7313286",
"0.73129123",
"0.7311041",
"0.7306297",
"0.7281173",
"0.7273615",
"0.72629416",
"0.72484964",
"0.72301924",
"0.71767205",
"0.7118192",
"0.70924455",
"0.7085656",
"0.7080955",
"0.7067216",
"0.7009283",
"0.6977327",
"0.69725746",
"0.69630706",
"0.6939082",
"0.6898775",
"0.68567353",
"0.68541014",
"0.68541014",
"0.68541014",
"0.68541014",
"0.68541014",
"0.68541014",
"0.68541014",
"0.68541014",
"0.68541014",
"0.68541014",
"0.68541014",
"0.68541014",
"0.68541014",
"0.68541014",
"0.68541014",
"0.68541014",
"0.68541014",
"0.68541014",
"0.68541014",
"0.6849963",
"0.6849224",
"0.68373597",
"0.683049",
"0.67957854",
"0.67643034",
"0.67557514",
"0.67521715",
"0.67499214",
"0.673109",
"0.6710735",
"0.6705887",
"0.67042756",
"0.66965467",
"0.66965467",
"0.66965467",
"0.66965467",
"0.66965467",
"0.66965467",
"0.66965467",
"0.66965467",
"0.66965467",
"0.66965467",
"0.66965467",
"0.66965467",
"0.66965467",
"0.66965467",
"0.66965467",
"0.66965467",
"0.66965467",
"0.66965467",
"0.66965467",
"0.66965467",
"0.66965467",
"0.66965467",
"0.66965467",
"0.66965467",
"0.66965467",
"0.669466",
"0.66917354",
"0.6686135",
"0.6674154",
"0.66694057",
"0.66563886",
"0.66466695",
"0.6638935",
"0.6629286",
"0.66234785",
"0.66168797",
"0.6604739"
] | 0.0 | -1 |
GET /items/1 GET /items/1.json | def show
@item = Item.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @items = Item.find(params[:id])\n render json: @items\n end",
"def get_item( item )\n @session.base_url = \"http://cl.ly\"\n resp = @session.get( \"/\" + item )\n \n raise ItemNotFound if resp.status == 404\n Crack::JSON.parse(resp.body)\n end",
"def show\n item = Item.find(params[:id])\n render json: item\n end",
"def item(uuid)\n http.get \"/items/#{uuid}\"\n end",
"def show\n render json: Item.find(params[:id])\n end",
"def index\n @api_v1_items = Item.all\n render json: @api_v1_items\n end",
"def show\n render json: Item.find(params[\"id\"])\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item.to_json() }\n end\n end",
"def index\n @items = Item.find(:all, :order => 'id ASC')\n # @items = Item.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def get_item\n @item = Item.find_by_id(params[:id])\n if @item\n return @item\n else \n render json: {\"message\": {\"type\": \"error\", \"content\": \"The item could not be found!\"}}\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def index\n @items = Item.found\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def show\n# @item = Item.get(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def index\n @items = Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def index\n @items = Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def index\n @items = Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def index\n @items = Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def show\n @item = Item.all.where(collection_id: params[:id])\n render :json => @item\n end",
"def index\n @items = Item.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @items }\n end\n end",
"def index\n #@items = Item.find_by_user_id(Session[user_id])\n @items = Item.all\n render json: @items\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json\n end\n end",
"def show\n @item = @deal.items.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def item\n @item = Item.find(params[:id])\n end",
"def show\n authenticate\n list = List.find(params[:id])\n items = list.items\n render json: {\n items: items,\n id: list.id\n }\n end",
"def index\n @items = current_user.items\n respond_to do |format|\n format.html\n format.json { render json: @items }\n end\n end",
"def index\n @items = @deal.items\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def show\n render json: @item\n end",
"def show\n \n render status: 200, :json => @item\n\n end",
"def getItems()\n return mergeWithAPI(@item_json)['data']\n end",
"def get(item)\n run(\"show #{ item }\")\n end",
"def show\n @feed_item = Item.find(params[:id])\n\n render json: @feed_item\n end",
"def index\n @items = Item.all\n @budget = Budget.find params[:budget_id]\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end",
"def index\n render json: RequestItem.all\n end",
"def items\n \tbegin\n \t@categories = Category.all.includes(items: [:dimensions])\n \t@ingredients = Ingredient.actives\n \trender 'api/v1/home/items', status: :ok\n \trescue Exception => e\n \t\terror_handling_bad_request(e)\n \tend\n\n\tend",
"def show\n render json: @item, status: :ok\n end",
"def findItem\n item = Item.find(params[:id])\n if item\n return item\n else\n return render json: {data: \"Failure, could not find this item.\"}, status: :not_found\n end\n end",
"def show\n @itemstable = Itemstable.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @itemstable }\n end\n end",
"def show\n @item_info = ItemInfo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item_info }\n end\n end",
"def get_single_item(item_id, payload = {})\n payload = payload.merge('ItemID' => item_id)\n request('GetSingleItem', payload)\n end",
"def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @item }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n @user = @item.user_id\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @item }\n end\n end",
"def index\n respond_to do |format|\n format.html\n format.json { render :json => Item.all}\n end\n\n end",
"def show\n @admin_item = Admin::Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @admin_item }\n end\n end",
"def show\n @admin_item = Admin::Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @admin_item }\n end\n end",
"def path\n \"/{databaseId}/items/list/\"\n end",
"def index\n @items = Admin::Item.by_agency(@current_agency.id)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @admin_items }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @item }\n end\n end",
"def show\n @item = TodoItem.find(params[:id])\n \n respond_to do |format|\n format.html\n format.json {render json: {\n success:true, \n data: [@item],\n message: \"TodoItem found.\"\n }}\n end\n end",
"def show\n @item = ActiveRecord::Base.connection.execute(\"\n SELECT * \n FROM items \n WHERE iid = #{params[:id]} \n LIMIT 1\").first\n\n @games = ActiveRecord::Base.connection.execute(\"\n SELECT g.*\n FROM games g\n JOIN game_items gi\n ON g.gid = gi.gid\n WHERE iid = #{params[:id]}\")\n\n respond_to do |format|\n format.html\n format.json {render json: Item.find(@item[0])}\n end\n end",
"def index\n @items = Item.includes(:user).order(created_at: :desc).all\n render json: @items\n end",
"def show \n #get the item id from the url params\n item_id = params[:id]\n #use `item_id` to find the item in the database\n #and save it to an instance variable\n @item = Item.find_by_id(item_id)\n render json: @item\n # @item = City.find(params[:id])\n # @item = Item.joins(:posts).includes(:posts).find(params[:id])\n # puts @item\n # render json: {\n # item: @item\n # }\n end",
"def get_item(course_id, item_id)\r\n relative_url = PATH_COURSES_ITEMS_ % [course_id, item_id]\r\n get(relative_url)\r\n end",
"def my\n items = current_user.items\n render json: items\n end",
"def get_item(item_id, params = {})\n url = build_url('item', item_id)\n params = params.merge(item_id: item_id)\n\n http.headers(build_headers).get(url, params: params)\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @item }\n format.json { render :json => @item }\n end\n end",
"def list_items( args={} )\n @session.base_url = \"http://my.cl.ly\"\n \n url = \"/items\"\n args.each do |k, v|\n # probably a nicer way to do this\n if url == \"/items\"\n url << \"?#{k.to_s}=#{v.to_s}\"\n else\n url << \"&#{k.to_s}=#{v.to_s}\"\n end\n end\n resp = @session.get( url )\n \n raise AuthorizationError if resp.status == 401\n Crack::JSON.parse(resp.body)\n end",
"def show\n render json: @request_item\n end",
"def show\n @potluck_item = PotluckItem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @potluck_item }\n end\n end",
"def show\n @list = List.find(params[:list_id])\n @list_items = @list.list_items.find(params[:list_id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @list_item }\n end\n end",
"def show\n @item = Item.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @item }\n format.xml { render xml: @item }\n end\n end",
"def index\n @item_type = params[:type] = \"C\"\n \n params[:id] = nil\n \n # 찜한 상품, 콜렉션\n @collections = Collection.itemList(params)\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @collections }\n end\n \n end",
"def item_show\n @item = Item.find(params[:id])\n end",
"def show\n @itemstatus = Itemstatus.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @itemstatus }\n end\n end",
"def get_items(product_id, params={})\n self.client.get(\"products/#{product_id}/items\", params)\n end",
"def items\n\t\tresponse = self.get('items').body\n\t\titems = JSON.parse(response)\n\t\tparse_items(items)\n\t\treturn items\n\tend",
"def index\n if params[:cart_id]\n get_cart\n @items = Item.where(cart: @cart)\n elsif params[:order_id]\n get_order\n @items = Item.where(order: @order)\n end\n render json: @items, status: 200\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end",
"def index\n @items = Item.all\n end"
] | [
"0.77359843",
"0.75480026",
"0.7493958",
"0.7370239",
"0.73272145",
"0.72927445",
"0.7286665",
"0.7132088",
"0.712437",
"0.7119644",
"0.70877594",
"0.70877594",
"0.70877594",
"0.70877594",
"0.70877594",
"0.70877594",
"0.70877594",
"0.70877594",
"0.70877594",
"0.70877594",
"0.70877594",
"0.70877594",
"0.70877594",
"0.70877594",
"0.70877594",
"0.70877594",
"0.70877594",
"0.70877594",
"0.70877594",
"0.70685595",
"0.70470786",
"0.7046294",
"0.7046294",
"0.7046294",
"0.7046294",
"0.70214605",
"0.7006118",
"0.6999563",
"0.696822",
"0.6909028",
"0.69052255",
"0.6902806",
"0.6859885",
"0.68377876",
"0.6836758",
"0.681646",
"0.67921937",
"0.675132",
"0.6706213",
"0.66938",
"0.6664771",
"0.6648441",
"0.66378874",
"0.6636145",
"0.66216135",
"0.6607305",
"0.6603626",
"0.6594954",
"0.6574022",
"0.65637296",
"0.6563249",
"0.6562803",
"0.6562803",
"0.6559425",
"0.65540653",
"0.65428764",
"0.6531462",
"0.65254176",
"0.65111023",
"0.6510988",
"0.65006626",
"0.64919704",
"0.64791435",
"0.64789265",
"0.6470903",
"0.6468325",
"0.64678425",
"0.64501673",
"0.64493793",
"0.6436029",
"0.6435546",
"0.6431455",
"0.64243263",
"0.6418016",
"0.64177334",
"0.64127463",
"0.64127463",
"0.64127463",
"0.64127463",
"0.64127463",
"0.64127463",
"0.64127463",
"0.64127463",
"0.64127463"
] | 0.65272504 | 72 |
POST /items POST /items.json | def create
@item = Item.new(item_params)
vendor = Vendor.find(item_params[:vendor_id])
@item.build_vendor(:id => vendor.id)
@item.save!
@current_item = @item
@items = Item.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n item = list.items.create!(item_params)\n render json: item, status: 201\n end",
"def create\n\t\titem = Item.create(item_params)\n\t\trender json: item\n\tend",
"def create\n @item = @client.items.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully added.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @request_item = RequestItem.new(request_item_params)\n @request_item.item = Item.new(name: params[:request_item][:item][:name])\n\n if @request_item.save\n render json: @request_item \n else\n render json: @request_item.errors, status: :bad_request\n end\n end",
"def create\n item = Item.new(item_params)\n item.user = current_user\n if item.save\n render json: item\n else\n render json: {errors: item.errors}, status: :unprocessable_entity\n end\n end",
"def create\n @item = Item.new(item_params)\n if @item.save\n @items = Item.all\n render status: 201, :json => @item\n \n else\n render status: 404, json: { message: @item.errors}.to_json\n end\n \n \n end",
"def create\n item = Item.new(item_params)\n item.done = \"0\"\n item.trash = \"0\"\n\n if item.save\n render json: {data:item}, status: :created\n else\n render json: {data:item}, status: :unprocessable_entity\n end\n end",
"def create\n create_params = item_params\n item = Item.new(\n name: create_params[:name], \n is_complete: false, #create_params[:is_complete], \n list_id: create_params[:list_id])\n\n item.save!\n render json: item\n end",
"def create\n @item = Item.new(item_params)\n\n if @item.save\n render json: @item\n else\n render json: { error: t('story_create_error') }, status: :unprocessable_entity\n end\n end",
"def create\n \n #debug\n write_log(\n Const::SL::LOG_PATH_SL,\n \"items_controller#create(params[:item] => #{params[:item]})\",\n # __FILE__,\n __FILE__.split(\"/\")[-1],\n __LINE__.to_s)\n\n \n @item = Item.new(params[:item])\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render json: @item, status: :created, location: @item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(params[:item])\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to root_url, notice: 'Item was successfully created.' }\n format.json { render json: @item, status: :created, item: @item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = current_owner.items.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to items_path, notice: 'Item was created successfully' }\n format.json { render :show, status: :created, location: items_path }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(params[:item])\n @item.save\n respond_with @item\n end",
"def create\n @item = Item.new(params[:item])\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render json: @item, status: :created, location: @item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(params[:item])\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render json: @item, status: :created, location: @item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(params[:item])\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render json: @item, status: :created, location: @item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(params[:item])\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render json: @item, status: :created, location: @item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(params[:item])\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render json: @item, status: :created, location: @item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(params[:item])\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render json: @item, status: :created, location: @item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(params[:item])\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render json: @item, status: :created, location: @item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(params[:item])\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render json: @item, status: :created, location: @item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to '/items', notice: 'Item was successfully created.' }\n format.json { render action: 'show', status: :created, location: @item }\n else\n format.html { render action: 'new' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.find(current_user.id)\n @item = @user.items.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to '/items', notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = build_item\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to items_path, notice: 'アップロードしたでー' }\n format.json { render action: 'show', status: :created, location: @item }\n else\n format.html { render action: 'new' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @api_v1_item = Item.new(api_v1_item_params)\n\n if @api_v1_item.save\n render json: @api_v1_item\n else\n render json: @api_v1_item.errors\n end\n end",
"def create\n @item = Item.new(item_params)\n if @item.save\n render json: ItemSerializer.new(@item)\n else\n render json: @section.errors, status: :unprocessable_entity\n end\n end",
"def create\n @item = Item.new(params[:item])\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to lists_path, :notice => 'Item was successfully created.' }\n format.json { render :json => lists_path, :status => :created, :location => lists_path }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(item_params)\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(params[:item])\n\n get_relations_from_params\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render json: @item, status: :created }\n else\n format.html { render action: \"new\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: \"Item was successfully created.\" }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(params[:item])\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to :items, notice: 'Item was successfully created.' }\n format.json { render json: @item, status: :created, location: @slot }\n else\n format.html { render action: 'new' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = @list.items.create(item_params)\n redirect_to @list\n end",
"def create \n #whitelist params and save them to a variable \n item_params = params.require(:item).permit(:name, :category, :image, :price)\n #create a new item from 'item_params'\n @item = Item.new(item_params)\n #if item saves, render the new item in JSON\n if @item.save \n render json: @item\n end\n end",
"def create\n @item = Item.new(item_params)\n \n respond_to do |format|\n if @item.save \n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def item_params\n params.require(:item).permit(:item, :body)\n end",
"def create\n @item = current_user.items.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: \"Item was successfully created.\" }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = current_user.items.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to root_path, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n @item = Item.new(params[:item])\n @item.user_id = current_user.id\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to '/main', :notice => 'Item was successfully created.' }\n format.json { render :json => @item, :status => :created, :location => @item }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(item_save_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render action: 'show', status: :created, location: @item }\n else\n format.html { render action: 'new' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render action: 'show', status: :created, location: @item }\n else\n format.html { render action: 'new' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render action: 'show', status: :created, location: @item }\n else\n format.html { render action: 'new' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render action: 'show', status: :created, location: @item }\n else\n format.html { render action: 'new' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render action: 'show', status: :created, location: @item }\n else\n format.html { render action: 'new' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(params[:item])\n @item.user = current_user\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, :notice => 'Item was successfully created.' }\n format.json { render :json => @item, :status => :created, :location => @item }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n # defined object to receive strict item_params including :description, :price, :stockQty ; else return 400\n @item = Item.new(item_params)\n \n if @item.save\n render json: @item.to_json, status: 201\n else\n head 400\n end\n end",
"def create\n @item = current_user.items.new(params[:item])\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render json: @item, status: :created, location: @item }\n else\n format.html do\n flash[:alert] = 'Something went wrong while creating an item.'\n render action: \"new\"\n end\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_item()\n\n request_body = {\n 'name' => 'Milkshake',\n 'variations' => [\n {\n 'name' => 'Small',\n 'pricing_type' => 'FIXED_PRICING',\n 'price_money' => {\n 'currency_code' => 'USD',\n 'amount' => 400\n }\n }\n ]\n }\n\n response = Unirest.post CONNECT_HOST + '/v1/' + LOCATION_ID + '/items',\n headers: REQUEST_HEADERS,\n parameters: request_body.to_json\n\n if response.code == 200\n puts 'Successfully created item:'\n puts JSON.pretty_generate(response.body)\n return response.body\n else\n puts 'Item creation failed'\n puts response.body\n return nil\n end\nend",
"def add_item_to_project\n @project = Project.find(params[:id])\n @item = Item.find(params[:item_id])\n\n @project.items << @item\n\n render json: @project, include: :items\n end",
"def save\n @items.to_json\n end",
"def create\n @item = Item.new(item_params)\n # @item.build_note\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render json: @item, status: :created, location: @item }\n else\n respond_with(@items)\n end\n end\n end",
"def item_create\n @item = Item.new(item_params)\n respond_to do |format|\n if @item.save\n format.html { redirect_to item_index_path, notice: 'O item foi criado com sucesso.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :item_new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def item_params\n params.require(:item).permit(:title, :body)\n end",
"def writeItem(app, repo_url, item)\n headers = defaultHeaders(app[\"token\"])\n data = item.to_json\n response = HTTParty.post(repo_url,\n headers: headers,\n body: data)\n response\nend",
"def create\n @item = Item.new(params[:item])\n @item.user = current_user\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render json: @item, status: :created, location: @item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n ListItem.transaction do\n item = Item.new(item_params)\n item.save\n\n @list_item = ListItem.new(list_item_params)\n @list_item.item_id = item.id\n @list_item.list_id = params[:list_id]\n\n\n if @list_item.save\n render json: @list_item, status: :created\n else\n render json: @list_item.errors, status: :unprocessable_entity\n end\n end\n end",
"def create\n cart_uuid = params[:cart_id]\n @item = Item.new(item_params.merge(cart_uuid: cart_uuid))\n if @item.save\n render json: @item, status: 201\n else\n render_errors 400, @item.errors.full_messages\n end\n end",
"def create\n @item = Item.new(params[:item])\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to(items_path) }\n format.xml { render :xml => @item, :status => :created, :location => @item }\n else\n format.html { redirect_to(items_path)}\n format.xml { render :xml => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post(payload, request_opts={})\n if payload.is_a?(Hash)\n payload = self.class.item_class.new(payload) # apply data type conversion\n end\n qs = payload.query_string_params\n payload = payload.as_hash\n response = http(request_opts).post(resolved_path + qs, payload)\n new_item = self.class.item_class.new\n new_item.store_result(response)\n new_item\n end",
"def create\n @item = Item.new(item_params)\n @item.save\n redirect_to @item\n end",
"def create\n puts params\n item_data = {\n :title => params[:title],\n :description => params[:description]\n }\n @item = current_user.items.build(item_data)\n if params[:attachments]\n params[:attachments].each do |att_id|\n @att = Attachment.find(att_id)\n @item.attachments.push(@att)\n if @att.att_type == 'photo'\n @item.photos.build(\n photo_url: @att.url\n )\n end\n end\n end\n if @item.save\n respond_to do |format|\n format.json { render :json => @item.to_json, :status => 200 }\n format.xml { head :ok }\n format.html { redirect_to :action => :index }\n end\n else\n respond_to do |format|\n format.json { render :text => \"Could not create item\", :status => :unprocessable_entity } # placeholder\n format.xml { head :ok }\n format.html { render :action => :new, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n json_response(current_restaurant.restaurant_food_items.create!(food_item_params), :created)\n end",
"def create\n if !self.auth_admin\n @item = Item.new(item_params)\n respond_to do |format|\n if @item.save\n format.html { redirect_to item_path(@item), notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n end\n end\n end\n end",
"def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n @item.save_info\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end \n end",
"def create\n @itemtipo = Itemtipo.new(itemtipo_params)\n\n if @itemtipo.save\n render json: @itemtipo, status: :created, location: @itemtipo\n else\n render json: @itemtipo.errors, status: :unprocessable_entity\n end\n end",
"def create\n @item = @deal.items.new(params[:item])\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to deal_items_url(@deal), notice: 'Item was successfully created.' }\n format.json { render json: @item, status: :created, location: @item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create(item_attrs = {})\n body = { value: item_attrs }\n Iterable.request(conf, base_path).put(body)\n end",
"def api_post(method: nil, item: [], params: {})\n raise ArgumentError, 'Missing method in API request' unless method\n\n login(@host) if Time.new.to_i > @session_timeout\n\n request = {}\n request[:method] = method\n request[:params] = [[item || []], params.to_h]\n # This is how we create request params once all methods use structs\n # request[:params] = [[item || []], params.to_h]\n # We use a StandardError since it is based on the HTTP response code with a JSON payload definition\n begin\n resp = @http.post(@uri, request.to_json, @headers)\n JSON.parse(resp.body)['result']['result']\n rescue StandardError\n puts \"The following error has occurred #{JSON.parse(resp.body)['error']['message']}\"\n end\n end",
"def item_params\n params.require(:item).permit!\n end",
"def create\n @item = Item.new(item_params)\n @item.user = current_user\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item = Item.new(item_params)\n @item.user_id = current_user.id\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @admin_item = Admin::Item.new(params[:admin_item])\n\n respond_to do |format|\n if @admin_item.save\n format.html { redirect_to @admin_item, notice: 'Item was successfully created.' }\n format.json { render json: @admin_item, status: :created, location: @admin_item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @admin_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_item(user_id, data) \n data = data.just(SETTABLE_ITEM_FIELDS)\n data[:user_id] = user_id\n data[:title] ||= 'item'\n data[:price] ||= 5\n data[:price] = data[:price].to_i\n data[:slug] = get_unique_slug($items,:slug,data[:title])\n\n data[:imgs] = data[:imgs].to_a.map {|link| {link: link}}\n data[:videos] = data[:videos].to_a.map {|link| {link: link}}\n data[:status] = :pending\n item = $items.add(data)\nend",
"def create(attributes)\n response = JSON.parse(@client.post('items', attributes).body)\n Promisepay::Item.new(@client, response['items'])\n end",
"def create\n @item = Item.new(item_params) #Remember to add Session[user_id]\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def item_params\n params.require(:item).permit(:name, :value)\n end",
"def create\n # @item = Item.new(item_params)\n @item = current_user.items.build(item_params)\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def item_params\n params.require(:item).permit(:name, :tag_list, :type_list, :description)\n end",
"def item_params\n params.require(:item).permit(:name)\n end",
"def item_params\n params.require(:item).permit(:name)\n end",
"def create\n @item = Item.new(item_params)\n \n if @item.save\n redirect_to @item\n else\n render :new\n end\n end",
"def create\n @item = @list.items.build(item_params)\n @item.user = current_user\n\n if @item.save\n return success_item_create\n else\n return error_item_save\n end\n end",
"def item_params\n params.require(:item).permit(:name, :type_id, :user_id)\n end",
"def create\n @part_types = Constants::PART_TYPES\n @item = Item.new(item_params.merge(user_id: current_user.id))\n \n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: \"Item was successfully created.\" }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @apiv1_item = Item.new(apiv1_item_params)\n\n respond_to do |format|\n if @apiv1_item.save\n format.html { redirect_to @apiv1_item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @apiv1_item }\n else\n format.html { render :new }\n format.json { render json: @apiv1_item.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.7971939",
"0.7285761",
"0.7231758",
"0.721958",
"0.71792215",
"0.71131957",
"0.7062943",
"0.7053179",
"0.6988855",
"0.69712186",
"0.6903009",
"0.68806237",
"0.6871792",
"0.6840092",
"0.6840092",
"0.6840092",
"0.6840092",
"0.6840092",
"0.6840092",
"0.6840092",
"0.6839645",
"0.68317765",
"0.68232363",
"0.6818633",
"0.6804524",
"0.68023956",
"0.6771504",
"0.6767946",
"0.6759613",
"0.67544657",
"0.67544657",
"0.67544657",
"0.67544657",
"0.67544657",
"0.67544657",
"0.67544657",
"0.67544657",
"0.67544657",
"0.67544657",
"0.67544657",
"0.67544657",
"0.67544657",
"0.67544657",
"0.67544657",
"0.67544657",
"0.67514557",
"0.67230386",
"0.6718678",
"0.67137235",
"0.67128444",
"0.6703868",
"0.6700709",
"0.6672411",
"0.66721815",
"0.666588",
"0.6654199",
"0.6654199",
"0.6654199",
"0.6654199",
"0.6654199",
"0.6608128",
"0.6572419",
"0.6571165",
"0.6570305",
"0.6558312",
"0.65502524",
"0.65315026",
"0.6528123",
"0.6520262",
"0.6516721",
"0.65085787",
"0.65081066",
"0.65060544",
"0.65043217",
"0.6482899",
"0.6469886",
"0.6467142",
"0.6455747",
"0.64434516",
"0.6438017",
"0.6436506",
"0.64340466",
"0.64243186",
"0.64219195",
"0.6408983",
"0.64060813",
"0.64010036",
"0.6399356",
"0.63970554",
"0.639478",
"0.63763726",
"0.63742554",
"0.6369031",
"0.6368939",
"0.63629377",
"0.63622326",
"0.6354672",
"0.63543826",
"0.6351369",
"0.6346357",
"0.63163006"
] | 0.0 | -1 |
PATCH/PUT /items/1 PATCH/PUT /items/1.json | def update
@item.update!(item_params)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n render json: Item.update(params[\"id\"], params[\"item\"])\n end",
"def update\n\n if @api_v1_item.update(api_v1_item_params)\n render json: @api_v1_item\n else\n render json: @api_v1_item.errors\n end\n end",
"def update\n\n #update the item of request_item\n if (params[:request_item].present?)\n @request_item.item = params[:request_item][:item].present? ? Item.new(name: params[:request_item][:item][:name]) : @request_item.item\n end\n #update all other parameters\n if @request_item.update(request_item_params)\n render json: @request_item\n else\n render json: @request_item.errors, status: :bad_request\n end\n\n end",
"def update\n if @item.update_attributes(item_params)\n render json: @item, status: :ok\n else\n render_error(@item, :unprocessable_entity)\n end\n end",
"def update\n if @item.update(item_params)\n render json: @item, status: :ok\n else\n render json: @item.errors, status: :unprocessable_entity\n end\n end",
"def update\n @item = @client.items.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n Rails.logger.debug params.inspect\n @item = Item.find(params[:id])\n respond_to do |format|\n if @item.update_attributes(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n respond_with(@items)\n end\n end\n end",
"def update\n \n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, :notice => 'Item was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n @item.update_attributes(params[:item])\n respond_with @item\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to items_path, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, :notice => 'Item was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @items = args[:items] if args.key?(:items)\n @request_id = args[:request_id] if args.key?(:request_id)\n end",
"def update!(**args)\n @items = args[:items] if args.key?(:items)\n @request_id = args[:request_id] if args.key?(:request_id)\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to '/items', notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def change_multiple_items\n @items = params[:items]\n\n @items.each do |item|\n @current_item = Item.find(item[:id])\n @current_item.update(quantity: item[:quantity])\n end\n\n render :json => @items.to_json\n end",
"def update\n @item = Item.find(params[:id])\n\n get_relations_from_params\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n# @item = Item.get(params[:id])\n\n respond_to do |format|\n if @item.update(params[:item])\n format.html { redirect_to({action: :show, id: @item}, notice: 'Item was successfully updated.') }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to lists_path, :notice => 'Item was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def updateItem(app, repo_url, item, id)\n headers = defaultHeaders(app[\"token\"])\n data = id.merge(item).to_json\n response = HTTParty.post(repo_url,\n headers: headers,\n body: data)\n response \nend",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { respond_with_bip(@item) }\n else\n format.html { render action: 'edit' }\n format.json { respond_with_bip(@item) }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n respond_to do |format|\n if @item.update_attributes(params[:item])\n flash[:notice] = \"Item has been updated\"\n format.json { render :json => @item.to_json, :status => 200 }\n format.xml { head :ok }\n format.html { render :action => :edit }\n else\n format.json { render :text => \"Could not update item\", :status => :unprocessable_entity } #placeholder\n format.xml { render :xml => @item.errors, :status => :unprocessable_entity }\n format.html { render :action => :edit, :status => :unprocessable_entity }\n end\n end\n end",
"def update\r\n @item = Item.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @item.update_attributes(params[:item])\r\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\r\n format.json { head :ok }\r\n else\r\n format.html { render action: \"edit\" }\r\n format.json { render json: @item.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def update\n item = Item.find(params[:id])\n if item.user == current_user\n if item.update(item_params)\n render json: item\n else\n render json: {errors: item.errors}, status: :unprocessable_entity\n end\n else\n render json: {errors: \"you can't do it\"}, status: :unprocessable_entity\n end\n end",
"def update_item(item_id)\n request_body = {\n 'name' => 'Malted Milkshake'\n }\n\n response = Unirest.put CONNECT_HOST + '/v1/' + LOCATION_ID + '/items/' + item_id,\n headers: REQUEST_HEADERS,\n parameters: request_body.to_json\n\n if response.code == 200\n puts 'Successfully updated item:'\n puts JSON.pretty_generate(response.body)\n return response.body\n else\n puts 'Item update failed'\n puts response.body\n return nil\n end\nend",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to items_path, notice: 'Item was updated successfully' }\n format.json { render :show, status: :ok, location: items_path }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n json_response(@food_item.update!(food_item_params))\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to items_path, notice: 'Item ' + @item.name + ' was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to items_url, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @apiv1_item.update(apiv1_item_params)\n format.html { redirect_to @apiv1_item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @apiv1_item }\n else\n format.html { render :edit }\n format.json { render json: @apiv1_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to root_path, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = @user.items.find(params[:id])\n\n @item.update(:type_list => \"\", :tag_list => \"\")\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to [@user, @item], notice: 'item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n\n\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: t('controller.successfully_updated', model: t('activerecord.models.item')) }\n format.json { head :no_content }\n else\n prepare_options\n format.html { render action: \"edit\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: \"Item was successfully updated.\" }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: \"Item was successfully updated.\" }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: \"Item was successfully updated.\" }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: \"Item was successfully updated.\" }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(params[:id])\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n\n\n end",
"def item_update\n @item = Item.find(params[:id])\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to item_show_path(@item), notice: 'O item foi atualizado com sucesso.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(item_attrs = {})\n body = { update: item_attrs }\n Iterable.request(conf, base_path).patch(body)\n end",
"def update\n item = @list.list_items.find(params[:id])\n\n if item.update_attributes(params[:list_item])\n render json: item\n else\n error(t('messages.list_item.errors.update'))\n end\n end",
"def update\n task\n if @item.update(item_params)\n render json: @list.as_json, status: :ok\n else\n render json: {list: @item.errors, status: :unprocessable_entity}\n end\n end",
"def update\n @item = Item.find(params[:id])\n\n logger.info \"Item: #{@item}\\nw/ param attr: #{params[:item].inspect}\"\n respond_to do |format|\n @item.attributes = params[:item].select{|k,v| ![:item_photos, :item_photos_attributes, :location].include?(k.to_sym) }\n\n @item.load_item_photos_with_params(params[:item] )\n\n if @item.save\n\n @item.set_by_user(auth_user)\n\n logger.info \" C) after save: attr: #{@item.attributes}\"\n\n if manage_item_photos(@item).present? || @item.changed?\n @item.save\n logger.info \" D) attr: #{@item.attributes}\"\n end\n\n format.html {\n redirect_to inventory_approve_item_path(:user_id => \"#{@item.owner.id}\")\n }\n format.json { render json:{ item: @item, success: true} }\n else\n set_flash_messages_from_errors(@item)\n format.html { render action: \"edit\" }\n format.json { render json: { error: @item.errors.first.join(' ') }, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = Item.find(item_params)\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.name, status: :unprocessable_entity }\n # format.html { render json: @item, notice: 'Item was not successfully updated.' }\n end\n end\n end",
"def update\n @item = current_user.items.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:item])\n format.html { redirect_to @item, notice: \"#{@item.name} was successfully updated.\" }\n format.json { head :no_content }\n else\n format.html do\n flash[:alert] = 'Something went wrong while updating an item.'\n render action: \"edit\"\n end\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to user_item_path(current_user, @item), notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_save_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to [@item.user, @item], notice: t('.notice') }\n format.json { render :show, status: :ok, location: @item }\n else\n format.html { render :edit }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item = TodoItem.find(params[:id])\n\n respond_to do |format|\n if @item.update_attributes(params[:todo_item])\n format.html { redirect_to @item, notice: 'TodoItem was successfully updated.' }\n format.json {render json: {\n success: true,\n data: [],\n message: \"TodoItem was successfully updated.\"\n }}\n else\n format.html { render action: \"edit\" }\n format.json { render json: {\n success: false,\n data: [],\n message: @item.errors\n }}\n end\n end\n end",
"def update\n respond_to do |format|\n if @item.update(item_params)\n format.html { redirect_to @item, notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.7442021",
"0.71437544",
"0.7139624",
"0.70251447",
"0.70026696",
"0.69958323",
"0.6980672",
"0.69373846",
"0.69218457",
"0.68723136",
"0.6832834",
"0.68177253",
"0.6805765",
"0.6805765",
"0.6794939",
"0.67887527",
"0.67887527",
"0.67887527",
"0.67887527",
"0.67887527",
"0.67887527",
"0.67887527",
"0.67887527",
"0.67887527",
"0.67887527",
"0.67887527",
"0.6772659",
"0.6772659",
"0.6762792",
"0.6758238",
"0.67457247",
"0.6735191",
"0.6730021",
"0.67282605",
"0.67282605",
"0.67282605",
"0.67282605",
"0.67282605",
"0.67282605",
"0.67282605",
"0.67282605",
"0.67282605",
"0.67241544",
"0.6723788",
"0.6709251",
"0.670301",
"0.66984326",
"0.6667349",
"0.66516906",
"0.6644987",
"0.66378874",
"0.66364",
"0.6613821",
"0.65892816",
"0.6587059",
"0.65864897",
"0.65864897",
"0.65864897",
"0.65864897",
"0.65864897",
"0.65864897",
"0.65864897",
"0.65864897",
"0.65864897",
"0.65864897",
"0.65864897",
"0.65864897",
"0.65864897",
"0.65864897",
"0.65864897",
"0.65864897",
"0.65864897",
"0.65864897",
"0.65864897",
"0.65864897",
"0.65864897",
"0.65864897",
"0.65864897",
"0.65864897",
"0.6583046",
"0.6576206",
"0.657075",
"0.6565839",
"0.6565839",
"0.6565839",
"0.6565839",
"0.6560937",
"0.6556025",
"0.6538576",
"0.6527549",
"0.65190315",
"0.6513063",
"0.6504536",
"0.6499179",
"0.64968973",
"0.6493183",
"0.64589465",
"0.64588577",
"0.64562833",
"0.6439813"
] | 0.6681448 | 47 |
DELETE /items/1 DELETE /items/1.json | def destroy
@item.destroy!
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n render json: Item.delete(params[\"id\"])\n end",
"def delete(items)\n item_ids = items.collect { |item| item.id }\n args = {ids: item_ids.to_json}\n return @client.api_helper.command(args, \"item_delete\")\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def delete_item(item_id)\n response = Unirest.delete CONNECT_HOST + '/v1/' + LOCATION_ID + '/items/' + item_id,\n headers: REQUEST_HEADERS\n\n if response.code == 200\n puts 'Successfully deleted item'\n return response.body\n else\n puts 'Item deletion failed'\n puts response.body\n return nil\n end\nend",
"def destroy\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def delete_item(id)\n record \"/todos/delete_item/#{id}\"\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :ok }\n format.xml { head :ok }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @api_v1_item.destroy\n render json: {message: 'deletado com sucesso'}\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url}\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = @client.items.find(params[:id])\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully removed from Inventory.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n# @item = Item.get(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to({action: :index}, notice: 'Item was successfully deleted.') }\n format.json { head :ok }\n end\n end",
"def destroy\n @apiv1_item.destroy\n respond_to do |format|\n format.html { redirect_to apiv1_items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = @user.items.find(params[:id])\n @item.destroy\n\n\n respond_to do |format|\n format.html { redirect_to user_items_path(@user) }\n format.json { head :no_content }\n end\n end",
"def destroy\n item = @item.name\n @item.deleted = true\n @item.deleted_at = Time.now\n @item.save\n\n respond_to do |format|\n format.html { redirect_to items_url, notice: \"#{item} was successfully deleted.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item ||= Item.find_by_id_or_name(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to(items_url) }\n format.xml { head :ok }\n format.json { head :ok }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to '/items', notice: 'Item was successfully updated.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to tasks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to(items_url) }\n format.xml { head :ok }\n format.json { head :ok }\n end\n end",
"def delete_item\n item_id = params[\"item_id\"]\n\n item = TextItem.find_by_id(item_id)\n item = Image.find_by_id(item_id) if item.nil?\n item = Collection.find_by_id(item_id) if item.nil?\n render_json :status => :not_found, :messages => \"Could not find the item with id #{item_id}.\" and return if item.nil?\n\n if item.class == Collection\n if params[\"id\"].nil?\n render_json :status => :bad_request, :messages => \"Can't delete a collection reference without providing the parent collection id. Please use the longer url for item deletion.\" and return\n end\n collection = Collection.find_by_id(params[\"id\"])\n else\n collection = Ownership.find_by_item_id(item_id).parent\n end\n;\n render_json :status => :not_found, :messages => \"Could not find parent collection for the item.\" and return if (collection.nil?)\n render_json :status => :forbidden, :messages => \"The user is not allowed to delete from this collection.\" and return if (!collection.delete?(@user, @client))\n\n collection.delete_item(item_id)\n render_json :entry => {} and return\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to lists_url }\n format.json { head :ok }\n end\n end",
"def destroy\n render status: 200, json: @request_item.destroy\n end",
"def delete_item(item)\n @get_items.delete(item)\n end",
"def destroy\n @item = current_user.items.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def item_destroy\n @item = Item.find(params[:id])\n @item.destroy\n respond_to do |format|\n format.html { redirect_to item_index_path, notice: 'O item foi removido com sucesso.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin_item = Admin::Item.find(params[:id])\n @admin_item.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin_item = Admin::Item.find(params[:id])\n @admin_item.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to(items_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to(items_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to(items_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to(items_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to(items_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to(items_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_path, notice: 'Item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: '削除に成功しました。' }\n format.json { head :no_content }\n end\n end"
] | [
"0.7906849",
"0.76885504",
"0.7604411",
"0.7585917",
"0.758546",
"0.758546",
"0.758546",
"0.758546",
"0.758546",
"0.758546",
"0.758546",
"0.758546",
"0.758546",
"0.758546",
"0.758546",
"0.758546",
"0.758546",
"0.758546",
"0.758546",
"0.7547388",
"0.7539847",
"0.7528851",
"0.7509601",
"0.7498011",
"0.74881107",
"0.74881107",
"0.74881107",
"0.74881107",
"0.74881107",
"0.74881107",
"0.74881107",
"0.74881107",
"0.74881107",
"0.74881107",
"0.7458705",
"0.7455512",
"0.7431493",
"0.7417056",
"0.74064195",
"0.73827004",
"0.73556334",
"0.73521996",
"0.7334829",
"0.7322859",
"0.7318489",
"0.7316946",
"0.7299613",
"0.72877073",
"0.7247646",
"0.7245776",
"0.7244305",
"0.7227808",
"0.7223437",
"0.7196988",
"0.7196988",
"0.7196767",
"0.7196767",
"0.7196767",
"0.7196767",
"0.7196767",
"0.7196767",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196719",
"0.7196451",
"0.7195314"
] | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_item
@item = Item.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def set_actions\n actions :all\n end",
"def define_action_helpers?; end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def setup_handler\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def workflow\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def setup\n # override and do something appropriate\n end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def after_set_callback; end",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def save_action; end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def setup(&blk)\n @setup_block = blk\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def callback_phase\n super\n end",
"def advice\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def duas1(action)\n action.call\n action.call\nend",
"def _handle_action_missing(*args); end"
] | [
"0.6164095",
"0.6046031",
"0.5945298",
"0.59179014",
"0.58890367",
"0.58341795",
"0.5776118",
"0.5700777",
"0.5700777",
"0.5656277",
"0.56218207",
"0.5423995",
"0.5411516",
"0.5411516",
"0.5411516",
"0.5395004",
"0.53783494",
"0.53593004",
"0.53412604",
"0.534078",
"0.5332865",
"0.53135896",
"0.52999926",
"0.5297309",
"0.5296569",
"0.5261449",
"0.5247048",
"0.52376497",
"0.52376497",
"0.52376497",
"0.52376497",
"0.52376497",
"0.52323204",
"0.52310973",
"0.523081",
"0.5225785",
"0.5219039",
"0.52136266",
"0.5208033",
"0.520763",
"0.5177365",
"0.5175224",
"0.5173357",
"0.5166104",
"0.5162502",
"0.51573396",
"0.5154547",
"0.5153531",
"0.51502854",
"0.51436496",
"0.5142863",
"0.51330835",
"0.5115634",
"0.5115634",
"0.511527",
"0.5109693",
"0.51076853",
"0.5093146",
"0.5090683",
"0.50829846",
"0.50819314",
"0.50670373",
"0.5055505",
"0.5053398",
"0.50504035",
"0.50504035",
"0.5037765",
"0.5027292",
"0.5024484",
"0.50150335",
"0.5014069",
"0.50022113",
"0.5001542",
"0.49981874",
"0.49915564",
"0.49915564",
"0.49880967",
"0.4982312",
"0.49787375",
"0.49786067",
"0.49687737",
"0.49676532",
"0.49602765",
"0.49565676",
"0.49550772",
"0.495342",
"0.49522525",
"0.49463704",
"0.49447197",
"0.49362713",
"0.49328062",
"0.49280638",
"0.49272856",
"0.4927058",
"0.49221697",
"0.4919526",
"0.49185994",
"0.49184805",
"0.49170163",
"0.49168405",
"0.49167764"
] | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def item_params
params.require(:item).permit(:name, :price, :category)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def param_whitelist\n [:role, :title]\n end",
"def expected_permitted_parameter_names; end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def valid_params_request?; end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def permitted_params\n []\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params; true; end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def quote_params\n params.permit!\n end",
"def valid_params?; end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend",
"def filtered_parameters; end",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def filtering_params\n params.permit(:email, :name)\n end",
"def check_params\n true\n end",
"def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def active_code_params\n params[:active_code].permit\n end",
"def filtering_params\n params.permit(:email)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end",
"def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end",
"def list_params\n params.permit(:name)\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def url_whitelist; end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def admin_social_network_params\n params.require(:social_network).permit!\n end",
"def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def filter_params\n params.require(:filters).permit(:letters)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def permit_request_params\n params.permit(:address)\n end",
"def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end",
"def secure_params\n params.require(:location).permit(:name)\n end",
"def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end",
"def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end",
"def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end",
"def url_params\n params[:url].permit(:full)\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def backend_user_params\n params.permit!\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end",
"def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end",
"def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end",
"def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end",
"def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end"
] | [
"0.6979893",
"0.6781746",
"0.6746611",
"0.6742344",
"0.6735229",
"0.6592651",
"0.65027124",
"0.6498011",
"0.648163",
"0.647716",
"0.64556813",
"0.64386255",
"0.63784456",
"0.63756156",
"0.636574",
"0.6319542",
"0.63004524",
"0.6299559",
"0.62925464",
"0.62923217",
"0.6289894",
"0.6289475",
"0.62831545",
"0.6242381",
"0.6240358",
"0.6217451",
"0.6214354",
"0.62098235",
"0.61918235",
"0.6177287",
"0.61755854",
"0.61712915",
"0.61620486",
"0.6151379",
"0.61510575",
"0.6145169",
"0.61207956",
"0.6115647",
"0.6107701",
"0.61030304",
"0.60909295",
"0.60797",
"0.60701567",
"0.6062068",
"0.60203075",
"0.60167485",
"0.60125494",
"0.6009718",
"0.6007027",
"0.6007027",
"0.6000283",
"0.59990394",
"0.5996995",
"0.59915864",
"0.59914654",
"0.59912056",
"0.5979621",
"0.596686",
"0.5959418",
"0.59585625",
"0.59583765",
"0.5958032",
"0.5952298",
"0.5951678",
"0.5941885",
"0.59378815",
"0.59376645",
"0.59376645",
"0.5933908",
"0.59302104",
"0.5924862",
"0.5923981",
"0.59165645",
"0.5909916",
"0.590986",
"0.5908378",
"0.5904956",
"0.5897421",
"0.58970135",
"0.5894611",
"0.5893914",
"0.58927566",
"0.5891277",
"0.5885355",
"0.58825094",
"0.58783555",
"0.58728755",
"0.58686864",
"0.5867015",
"0.58660764",
"0.58659357",
"0.5864526",
"0.58634263",
"0.5861585",
"0.5861255",
"0.5858771",
"0.58579147",
"0.5854071",
"0.5853147",
"0.58498794",
"0.58492327"
] | 0.0 | -1 |
Method to create a list input: string of items separated by spaces (example: "carrots apples cereal pizza") steps: "read the items" set default quantity store the items print the list to the console "p" visualize without making it nil output: [hash] Method to add an item to a list input: item name and optional quantity steps: create a key and assign its value output: hash Method to remove an item from the list input: ask which item? steps: used built in delete method to delete the key output: hash Method to update the quantity of an item input: ask which key and update the value steps: within the assigned key update value output:hash Method to print a list and make it look pretty input: our wondeful hash steps: iterate through the hash output: all the keyvalue pairs. | def create_a_list(list)
shopping_list = {}
split_list = list.split(" ")
split_list.each do |item, value|
shopping_list[item] = 1
end
shopping_list
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_list(user_list)\n# input: string of items separated by spaces (example: \"carrots apples cereal pizza\")\n# puts \"\"\n# steps:\n # [fill in any steps here]\n list_array = user_list.split(\",\")\n # set default quantity\n quanity = 1\n # print the list to the console [can you use one of your other methods here?]\n p list_array.collect { |item| [item, quanity] }\n $list_hash = Hash[list_array.collect { |item| [item, quanity] } ]\n# output: [what data type goes here, array or hash?] Print result in hash\n p $list_hash\n $list_hash\nend",
"def createlist(str)\r\n# steps:\r\n# break the string into an array\r\n items = str.split\r\n item_list = {}\r\n\r\n\t# iterate through array and build hash\r\n items.each do |item|\r\n\r\n\t\t# iterate through array and build hash\r\n\t\t# set default quantity to 1\r\n \titem_list[item] = 1\r\n end\r\n # print the list to the console [the last method that print a list and make it look pretty]\r\n print_list(item_list)\r\n\r\n # output: the hash\r\n return item_list\r\nend",
"def create_list_items(input_string)\n \n hsh = {}\n \n # create an array containing each item \n array_input = input_string.split(' ')\n \n # create a hash from the array (iterate), containing the information of key/value pairs \n array_input.each do |item|\n # set default quantity as value\n hsh[item] = 0\n end \n \n # print the list to the console (we will use the last method)\n print_list(hsh)\n \n # output: hash data structure of key/value pairs\n return hsh\nend",
"def create_list(string)\n puts \"What is the default item quantity?\"\n default_quantity = gets.chomp.to_s\n list_array = string.split(' ')\n list_hash = {}\n list_array.each do |item|\n list_hash[item] = default_quantity\n end\n\n print_list(list_hash)\n\n list_hash\nend",
"def shopping_list(items)\n\t# separate the items into an array\n\titems = items.split\n\tputs \"Here are the items you entered.\"\n\tputs items\t\n\t# create the list to add items into.\n\t$list = Hash.new\n\t# enter quantity of each item.\n\titems.each_index do |x|\n\t\tputs \"Enter quantity with no spaces for #{items[x]}.\"\n\t\tquantity = gets.chomp\n\t\t# assign each quantity to the item and add to list\n\t\t$list[:\"#{items[x]}\"] = quantity\n\tend\n\tputs \"Here is your shopping list.\"\n\tputs $list\nend",
"def add_item(list, item, quantity=1)\r\n# input: item name and optional quantity\r\n# steps: \r\n # Use shopping list as input\r\n # Use the item to be added as 2nd input\r\n # Use the item quantity as a 3rd input (look up whether optional input is possible)\r\n # Add the item and quantity to the shopping list\r\n list[item] = quantity\r\n# output: shopping list with the added item and quantity\r\n printlist(list)\r\nend",
"def create_list(input)\n grocery_list = {}\n # convert items in string to hash keys:\n input_array = input.split\n # convert string into array using\n # iterate through array assign each string item to a hash key with default value of x\n # set default quantity\n # iteration loop\n # grocery_list[\"key_name1\"] => 3\n input_array.each do |i|\n grocery_list[i] = 3\n end\n # print the list to the console [can you use one of your other methods here?]\n # call the method for printing a list *below*\n # output: [what data type goes here, array or hash?]\n # make output return hash\n # grocery_list, call the hash so that the last evaluated item is the hash.. and then that is returned\n grocery_list\nend",
"def create_list(input_string)\n grocery_list = {}\n items = input_string.split(' ')\n items.each do |item|\n add_item_to_list(grocery_list, item, 1)\n end\n\n print_list(grocery_list)\n\n add_item_to_list(grocery_list, \"milk\", 1)\n update_item_from_list(grocery_list, \"Lemonade\", 2)\n update_item_from_list(grocery_list, \"Tomatoes\", 3)\n update_item_from_list(grocery_list, \"Onions\", 10)\n update_item_from_list(grocery_list, \"iceCream\", 20)\n\n print_list(grocery_list)\n\n remove_item_from_list(grocery_list, \"IceCream\")\n\n print_list(grocery_list)\n\nend",
"def create_list(items)\n\titem_list = {}\n\titem_array = items.split(\" \")\n\tdefault_quantity = 1\n\titem_array.each do |item|\n\t\titem_list[item] = default_quantity\n\tend\n\tpretty_list(item_list) \nend",
"def add_item(list_name, item, quantity=1)\r\n# input: list, item name, and optional quantity\r\n# steps: add item and its quantity to the hash\r\n list_name.store(item, quantity)\r\n# output: hash with new item\r\n p list_name\r\nend",
"def create_list(items_string)\r\n\tdefault_quantity = 1\r\n\r\n\tgrocery_list = Hash.new{|hash, key| hash[key] = default_quantity}\r\n\titems_array = items_string.split(\" \")\r\n\t\r\n\titems_array.each do |item| \r\n\t\tgrocery_list[item.to_sym]\r\n\tend\r\n\tprint_list(grocery_list)\r\n\tgrocery_list\r\nend",
"def create_list(title, list_arr)\n # grocery_list will be a string from user\n # assign an empty hash (will eventually be the list)\n final_list = {}\n # use split method to get list items\n list_arr = list_arr.split\n # Iterate through the elements of the array and insert to hash\n # set default quantity\n list_arr.each { |item| final_list[item]=1}\n # print the list to the console [can you use one of your other methods here?]\n puts print_list(title,final_list)\n final_list\nend",
"def create_grocery_list(shopping_items)\n # steps:\n # create an empty hash\n grocery_list = {}\n # add items\n # convert input into separate items\n shopping_items = shopping_items.split\n # add items to hash and set default quantity\n shopping_items.each do |item_name|\n grocery_list[item_name.to_sym] = 1\n end\n # print the list to the console [can you use one of your other methods here?]\n print_grocery_list(grocery_list)\n# output: explicit return the hash\n grocery_list\nend",
"def print_list(my_list)\r\n# input: \r\n \r\n# steps:\r\n# print to screen: iterate through hash item - quantity\r\n puts '------'\r\n puts \"Grocery list:\"\r\n my_list.each do |item, qty|\r\n puts \"#{item} - #{qty}\"\r\n end\r\n puts '-------'\r\n# output: each k,v pair printed surrounded by dashes\r\nend",
"def createlist(items)\n new_items = items.split(\" \")\n list = Hash.new\n new_items.each {|item| list[item] = 1}\n prettylist(list)\n # use print_list method\nend",
"def add_item(my_list, item, quantity)\r\n #input: a string seperated by an integer \r\n #steps: use a method that adds an item and quantity to the hash.\r\n my_list.store(item, quantity)\r\n # use a hash or store method hash.merge!(key => value) \r\n #output = hash with the updated item/quantity. \r\n my_list\r\n \r\nend",
"def list_of_items(userinput)\n itemlist = []\n final_list = {}\n itemlist = userinput.split(' ')\n p itemlist\n quantity = 1\n itemlist.each do |value|\n final_list[value] = 1\n end\n puts final_list\n final_list\nend",
"def grocery_list(grocery_items)\n # input: string of items separated by spaces (example: \"carrots apples cereal pizza\") \n # steps: \n # Create a new empty data structure (Hash) \n grocery = {}\n # Convert the string parameter into an array of words.\n item = grocery_items.split(\" \")\n # Iterate through the array and get the element.\n item.each do |product|\n # Store the element as a key in the hash.\n # set default quantity an integer with value 3. This is the default value of the keys in the hash.\n grocery[product] = 3\n display_list(grocery)\n end\n # print the list to the console [can you use one of your other methods here?]\n # output: Hash \n grocery\nend",
"def add_item(list, add_item, add_quantity=1)\n# steps:\n # Add item as key and quantity as value to final_list hash(item and quantity will be user inputs)\n list[add_item] = add_quantity\n # Return updated hash\n list\nend",
"def create_list\n\tgrocery_list = {}\n\tprint \"Please enter the items you need to buy seperated by spaces(example: 'carrots apples cereal'): \"\n\tarr_food = gets.chomp.split\n\tarr_food.each do |item|\n\t\tgrocery_list[item] = 1\n\tend\n\tprint_list(grocery_list)\nend",
"def create_list(list, grocery_hash={})\n\tlist_array = list.split(\" \")\n\tquantity = 0\n\tlist_array.each do |item|\n\t\tgrocery_hash[item]=quantity\n\tend\n\tprint_list(grocery_hash)\n\treturn grocery_hash\nend",
"def create_list(items)\n\tlist = {}\n\titems = items.split(' ')\n\tquantity = 0\n\tlist = Hash.new\n\n\titems.each do |item| \n\t\tlist[item] = quantity\n\tend\n\tlist\nend",
"def create_list(item, quantity = 1)\n\tlist = {}\n\tsplit_item = item.split(\" \")\n\tsplit_item.each do |item_name|\n\t\tlist[item_name] = quantity\n\tend\n\treturn list\nend",
"def add_item(list, name, quantity = 1) \r\n# input: item name and optional quantity\r\n# steps: \r\n# create add method with name and optional quantity arguments\r\n# add name and quantity to hash\r\n list[name] = quantity\r\n# output: print \"your item has been added to the hash\"\r\n return list\r\nend",
"def create_list(items, quantity=1)\r\n item_array = items.split(' ')\r\n item_hash = {}\r\n item_array.each do |items|\r\n item_hash[items] = quantity\r\n end \r\n p item_hash # p will both print and return # puts will print but will not return. It will return nil.\r\nend",
"def create_list(items)\n\tnew_list = {}\n\titem_arr = items.split\n\titem_arr.each do |item|\n\t\tadd_item(new_list, item)\n\tend\n\tprint_list(new_list)\n\t\nend",
"def add_item(list, item, quantity = 1)\r\n# input: list, item name, and optional quantity\r\n# steps: \r\n # check for optional quantity. if not present, set to default (1)\r\n list[item] = quantity\r\n # update list with input\r\n puts \"#{item.upcase} has been added to your grocery list!\"\r\n p list\r\n# output: complete list, updated\r\nend",
"def print_list(title,list)\n# steps:\n # print title of list (will ask user for this input)\n puts \"**********************\"\n puts \" #{title.upcase}:\"\n puts \"**********************\"\n # print headers of item and quantity\n puts \" # ITEM\"\n puts \"----------------------\"\n # print each item and it's quantity, bulleted if possible\n list.each {|item,quantity| puts \" #{quantity} #{item}\"}\n puts \"**********************\"\n # print today's date\n date = Time.new\n puts \" Made on: #{date.month}/#{date.day}/#{date.year}\"\nend",
"def create_list(items)\r\n\r\n\tshopping_list ={}\r\n\r\n\titems.split(\" \").each do |item|\r\n\t\tshopping_list[item] = 1\r\n\tend\r\n\r\n\t# will put a method call\r\n\tprint_list(shopping_list)\r\n\treturn shopping_list\r\n\r\nend",
"def create_a_list(name, quantity)\n #list = name.split(\", \")\n list_items = {}\n #list.each do |name|\n list_items[name] = quantity\n #end\n p list_items\n return list_items\nend",
"def create_list(grocery_items)\n grocery_list = {}\n grocery_items = grocery_items.split(\" \")\n grocery_items.each do |item| \n grocery_list.store(item, 1)\n end\n puts \"This is your grocery list:\"\n print_list(grocery_list)\n return grocery_list\nend",
"def create_list(string)\n item_array = string.split(\" \")\n shopping_list = {}\n item_array.each do |item|\n shopping_list[item] = 1\n end\n list_print(shopping_list)\n shopping_list\nend",
"def create_list(list_name,list_of_items)\n # create empty array\n list_name = []\n # for each item in string, use add item method to add item to grocery list (set default quantity to 1)\n shopping_items = list_of_items.split(' ')\n shopping_items.each do |thing_to_add|\n add_item_to_list(list_name,thing_to_add,1)\n end\n # print the list to the console\n print_list(list_name)\nend",
"def create_list(str, default_quantity=1)\n list = {}\n item_array = str.split\n item_array.each do |item|\n list[item] = default_quantity\n end\n print_list(list)\n return list\nend",
"def print_list(list)\r\n# input: completed list\r\n# steps:\r\n # iterate over list and print formatted list\r\n puts \"Your Grocery List\"\r\n list.each do |item, quantity|\r\n puts \"#{item}, qty: #{quantity}\"\r\n end\r\n # format: each item with its own line\r\n # \"item - quantity\"\r\n# output: implicit return of list\r\nend",
"def list_create(items)\n hash_items = Hash.new\n default_quantity = 1\n\n # adding a slick way to initialize hash in one line, but not as readable\n # return items.split(' ').product([1]).to_h\n\n items.split(' ').each do |x|\n hash_items[x] = default_quantity\n end\n\n return hash_items\nend",
"def create_list(items_str)\r\n items_hash={}\r\n items_array=items_str.split(\" \")\r\n items_array.each do |it|\r\n items_hash[it]=1\r\n end\r\n print_list(items_hash)\r\nend",
"def create_list(items_string, quantity = 0)\n list = {}\n items = items_string.split(\" \")\n items.each do |item|\n list[item] = quantity\n end\n list\nend",
"def new_list(item_String, quantity = 1)\n $list = []\n array_strings = item_String.split\n array_strings.each do |element|\n \tlist_item = {\n \t\tquantity: quantity,\n \t\titem: element\n \t}\n \t $list.push(list_item) \n \tend\nend",
"def make_list(item_list)\r\n item_list = item_list.split(' ')\r\n list = {}\r\n item_list.each do | item |\r\n list[item] = 1\r\n end\r\n print_list(list)\r\n list\r\nend",
"def printlist(list)\r\n# input: shopping list\r\n# steps:\r\nlist.each {|item, quantity| puts \"Please buy #{quantity} #{item}\"}\r\n # Print each item on the shopping list in a readable fashion\r\nend",
"def create_list\n \n list = {}\n \n puts \"Please enter items for list:\"\n \n items = gets.chomp\n\n items = items.split(' ')\n \n items.each do |key| \n \n list[key.to_sym] = \"1\"\n \n end\n \n list\n\nend",
"def initial_list(string_of_items)\n grocery_list = {}\n quantity = 1\n items_array = string_of_items.split(\" \")\n items_array.each do |item|\n grocery_list.store(item, quantity)\n end\n grocery_list\nend",
"def add_item(grocery,item_name,quantity)\n # input: list, item name, and optional quantity\n # steps: insert item_name as a key and quantity as a value to the hash \n grocery[item_name] = quantity\n # output:display the latest list\n display_list(grocery)\nend",
"def create_shopping_list\n print \"whats the name of your list: \"\n list_name = gets.chomp\n #create new hash \n hash = {\"name\" => list_name, \"items\" => Array.new}\n return hash\nend",
"def create_list(items, qty=1)\n items = items.split(\" \")\n list = Hash.new\n\n items.each do |item|\n if list.has_key?(item)\n list[item] += qty\n elsif\n list[item] = qty\n end\n end\n\n return list.each {|k,v| puts \"#{k}: #{v}\"}\nend",
"def shopping_list(string)\n\tgrocery_list = {}\n# steps: \n \t# separate string into array\n\tarray = string.split(' ')\n\t# loop through array to create hash with items in array as key and set default quantity to \"\"\n\tarray.map {|item| grocery_list[item] = \"\"}\n\t# print the list to the console [can you use one of your other methods here?]\n\t# output: [what data type goes here, array or hash?]\n\tputs grocery_list\n\treturn grocery_list\nend",
"def create_list(items)\n grocery_list = {}\n item_array = items.split(\" \")\n item_array.each do |item|\n grocery_list[item] = 1\n end\n print_list(grocery_list)\n grocery_list\nend",
"def create_list(items)\n $list = {}\n items.split(\" \").each do |item|\n $list[item] = 3\n end\n p $list\nend",
"def create_list(items)\n $list = {}\n items.split(\" \").each do |item|\n $list[item] = 3\n end\n p $list\nend",
"def new_list(items)\r\n list = {}\r\n split_items = items.split(' ')\r\n split_items.each { |item|\r\n list[item] = 1\r\n }\r\n print_list(list)\r\n list\r\nend",
"def create_list(items)\n list = {}\n item_array = items.split(\" \")\n item_array.each do |item|\n list[item] = 1\n end\n print_list(list)\nend",
"def create_list(string_of_items)\n string_ary = string_of_items.split(\" \")\n string_hash = {}\n string_ary.each { |item| string_hash[item] = 1 }\n print_grocery_list(string_hash)\n return string_hash\nend",
"def create_list(items = '')\n list = {}\n items.split(' ').each {|item| list[item.to_sym] = 1}\n print_list(list)\n list\nend",
"def create_list(items)\n list = {}\n items = items.split(' ')\n items.each do |item|\n list[item] = 1\n end\n print_list(list)\nend",
"def input (list, item, quantity)\n\tlist[item] = quantity\nend",
"def create_list(list)\n quantity = 1\n items = list.split(' ')\n grocery_list = { }\n\n items.each do |item|\n grocery_list[item] = quantity\n end\n grocery_list\nend",
"def create_list(items)\n\n\tgrocery_list_hash = {}\n\tlist_array = items.split(\" \")\n\n\tlist_array.each do |item|\n\t\tgrocery_list_hash.store(item.to_sym, 1)\n\tend\n\n\tgrocery_list_hash\nend",
"def creation_list (user_input)\r\n grocery_list = {}\r\n user_input_array = user_input.split(' ')\r\n user_input_array.each do |list_item|\r\n grocery_list[list_item] = 1\r\n end\r\n grocery_list\r\nend",
"def create_list_of(string_of_items)\n\tary_of_items = string_of_items.split(' ')\n\titem_list = {}\n\tary_of_items.each {|x| item_list[x] = 1}\n\tprint_list(item_list)\nend",
"def create_list\n item_array = []\n puts \"Enter items, type done when finished\"\n item = gets.chomp\n while item != \"done\"\n \titem_array << item\n \titem = gets.chomp\n end\n grocery_list = {}\n item_array.each { |item| grocery_list[item.to_sym] = 1 }\n puts grocery_list\n grocery_list\nend",
"def create_list(items_string)\n list = {}\n items_array = items_string.split(\",\")\n\n items_array.each do |item|\n list[item] = 1\n end\n print_pretty_list(list)\nend",
"def create_list(items)\n grocery_list = {}\n list_items = items.split\n list_items.each do |item|\n grocery_list[item] = 1\n end\n p print_list(grocery_list)\n end",
"def list_creation(items_string)\r\n\tshopping_list = {}\r\n\tintit_list = items_string.split(' ')\r\n\tintit_list.each do|item|\r\n\t\tshopping_list[item] = 1\r\n\tend\r\n\tshopping_list\r\nend",
"def additem(list, item, number = 1)\n# input: hash, item name and optional quantity\n# steps: push an item into the hash\n list.store(item, number)\nend",
"def add_item(item, quantity, list)\r\n list[item] = quantity\r\n p list\r\n list\r\nend",
"def create_list(input_string)\n input_arr = input_string.split(\" \")\n new_shopping_list = Hash.new\n new_shopping_list = Hash[input_arr.collect{|item, | [item, 1]}]\nend",
"def create_a_list(items)\n item_array = items.split\n shopping_list = {}\n item_array.each do |x|\n shopping_list[x] = 1\n end\n #shopping_list.store(items)\n shopping_list\nend",
"def add_item(list, item_name, optional_quantity)\n\nlist[item_name] = optional_quantity\n\n# input: list, item name, and optional quantity\n# steps:\n # Add new hash key based on item name\n # Tell method there may or may not be a argument passed in for quantity\n # assign quantity to 'optional-quantity' argument in method definition\n # Access method that contains initialized hash def add_item(create_list, item_name, quantity = 3)\n# output:\n # updated grocery list\nend",
"def create_list(new_items)\n\tshopping_list = new_items.split(\" \")\n\titems_hash = Hash.new\n\tshopping_list.each do |item| \n\titems_hash[item] = 1\n\tend\n\treturn items_hash\nend",
"def add_an_item(list_hash,item_name)\n puts 'Adding the item: #{item_name}.'\n puts 'Specify a quantity or type \"default\".'\n quantity = gets.chomp.to_s\n\n if quantity.downcase == 'default'\n quantity = '1'\n end\n\n puts list_hash\n\n if !list_hash[item_name]\n puts 'Added the item: #{item_name}.'\n list_hash[item_name] = quantity\n else\n puts 'Item already exists.'\n end\n\n list_hash\n\nend",
"def create_list(list)\n grocery_list = Hash.new\n default_quantity = 1 \n list.split(\" \").each {|x| grocery_list[x] = default_quantity }\n p grocery_list\nend",
"def create_list(items)\n\tshopping_list={}\n\titems.split.each do |item|\n\t\tshopping_list[item] = 1\n\tend\n\tp shopping_list\nend",
"def create_list(items)\n items = items.split(\" \")\n list = Hash.new\n items.each do |item|\n list[item] = 1\n end\n p list\nend",
"def print(list)\n# steps: \n\t# make a new string\n\tstring = \"This is the shopping list: \\n\"\n\t# iterate through the list\n\tlist.each do |item, quantity|\n\t\t# add the items and quantities to the string and end with a newline\n\t\tstring = string + \"#{item}: #{quantity} \\n\"\n\tend\n# output: the string\n\tputs string\nend",
"def add(list)\n puts \"add which item?\"\n item=gets.chomp\n puts \"how many\"\n qty=gets.chomp\n list[item]=qty\n return list\nend",
"def update_item(list, item, quantity)\r\n add_item(list, item, quantity)\r\n# input: Shopping list, item to be updated, new quantity\r\n# steps:\r\n # Use shopping list as input\r\n # Use item to be updated as input\r\n # Use new quantity to be updated as input\r\n # Update the quantity of the item on the list\r\n # list[item] = quantity\r\n# output: shopping list with updated quantity\r\n # printlist(list)\r\nend",
"def add_item(list, item, quantity)\n\tlist[item] = quantity\n\tp list\nend",
"def list_maker(items, *quantities)\r\n list_hash = {}\r\n list_array = items.split(' ')\r\n for i in 0..(list_array.length - 1)\r\n list_hash[list_array[i]] = quantities[i]\r\n end\r\n list_hash.map do |item, quantity|\r\n if quantity == nil \r\n list_hash[item] = 1 \r\n end\r\n end\r\n list_hash\r\nend",
"def make_list (list, quantity = $default_quantity)\r\n list_arr = list.split\r\n list_arr.each do |list_item|\r\n $grocery_list[list_item] = quantity\r\n end\r\nend",
"def create_list(string_of_items, default_quantity)\n grocery_array = string_of_items.split(' ')\n grocery_hash = {}\n grocery_array.each { |item| grocery_hash[item] = default_quantity }\n grocery_hash\nend",
"def shopping_list(user_input)\r\n grocery_list = {}\r\n list = user_input.split(\" \")\r\n list.each do |item|\r\n grocery_list[item] = 1\r\n end\r\n p grocery_list\r\nend",
"def generate_list(string_of_items)\n grocery_list={}\n default_value=1\n items=string_of_items.split(' ')\n items.each do |item|\n #Transfer items into hash\n grocery_list[item]=default_value\n end\n return grocery_list\n print(grocery_list)\nend",
"def add_item(name, quantity, list)\n list[name] = quantity\n p list\n return list\nend",
"def create_list(input)\n items = {}\n input.split(' ').each do |item|\n items[item] = 0\n end\n print_list(items)\nend",
"def create_list(items)\n\tgrocery_list = {}\n\tkey_array = items.split(' ')\n\n\tkey_array.each do |item|\n\t\tgrocery_list[item] = 1\n\tend\n\tprint_list(grocery_list)\n\tgrocery_list\nend",
"def grocery_list(items)\n\t#items string into an array\n\t#create hash named LIST \n\t#LIST << items[0]\n\t#LIST[:carrots] = 2\n\n\titem_array = items.split(\" \")\n\tfood_list = {}\n\t\n\n\titem_array.each do |fooditem|\n\t\tfood_list[fooditem] = 2\n\tend\n\n\tfood_list\n\t# p food_list\n\nend",
"def add_item(list_item,user_list)\n#user_list is later defined/used to store a new list of information created when create_list method is called.\n#Uses create_list method to format information properly before allowing edits and updates to be done. \n#user_list = create_list(string) \n user_list[list_item] = 1\n user_list\nend",
"def create_list(items)\n items = items.split(' ')\n grocery_list = {}\n items.each do |item|\n grocery_list[item] = 1\n end\n p grocery_list\n grocery_list\nend",
"def create_list(items)\n list = items.split\n shopping_list = {}\n list.each do |item|\n shopping_list[item] = 1\n end\n shopping_list\nend",
"def print_list(list)\n# input:list\n# steps: iterate through the list\n list.each do |item, number|\n puts \"we have #{number} #{item}\"\n end\n puts \"in our grocery list\"\nend",
"def create_list(items=\"\")\n grocery_list = Hash.new()\n list = items.split(\" \")\n list.each {|item| grocery_list[item] = 1 }\n grocery_list\nend",
"def create_list(items)\r\n\tgrocery_list = {}\r\n\tlist_of_items = items.split(' ')\r\n\r\n\tlist_of_items.each { |item| grocery_list[item] = 1}\r\n\tgrocery_list.each {|item, quantity| puts item, quantity}\r\nend",
"def create_list(items)\r\n\r\n\tgrocery_list = {}\r\n\r\n\tlist_items = items.split(\" \")\r\n\r\n\t#best practice...\r\n\tlist_items.each do |item_name|\r\n\t\tgrocery_list = add_item(grocery_list, item_name)\r\n\tend\r\n\r\n\treturn grocery_list\r\nend",
"def create_list(groceries)\n shopping_list = {}\n grocery_array = groceries.split(\" \")\n grocery_array.each do | item |\n add_item(item, 1, shopping_list)\n end\n print_list(shopping_list)\nend",
"def print_hash(list)\nputs \"Current grocery list:\"\nputs \"---------------------\"\nlist.each do |item_name, item_quant|\n puts \" #{item_name}: #{item_quant}\"\nend\nend",
"def create_list(string_of_items)\n hash_of_items = {}\n array_of_items = string_of_items.split(\" \")\n \n array_of_items.each do |item|\n hash_of_items[item] = 1\n end\n hash_of_items\nend",
"def add_item(list, item, quantity)\n list[item] = quantity\n p list\nend",
"def add_item_to_list(list_name,item_to_add,quantity_to_add = 1)\n#create a hash element with the item name and the quantity, if specified\n#if no quantity is specified, default value = 1\n new_item = { \n item_name: item_to_add,\n quantity: quantity_to_add\n }\n# insert the hash into array \n list_name.push(new_item)\n new_item\nend",
"def create_list(list_of_items)\n groc_list = Hash.new\n list_array = list_of_items.split(' ')\n list_array.each do |item|\n groc_list[item] = 1\n end\n p groc_list\nend",
"def create_list(list_input)\n list_input_array = list_input.split(' ')\n list = {}\n list_input_array.each do |item|\n list[item] = 1\n end\n p list\nend"
] | [
"0.80289197",
"0.79332864",
"0.780832",
"0.7738323",
"0.7700039",
"0.76259136",
"0.7519497",
"0.7492596",
"0.74637675",
"0.7453621",
"0.73946893",
"0.7376693",
"0.7369323",
"0.73631585",
"0.73361844",
"0.73173",
"0.7307453",
"0.72594804",
"0.71793735",
"0.71606386",
"0.71465033",
"0.7137402",
"0.7133821",
"0.71246636",
"0.71243715",
"0.7092896",
"0.7075514",
"0.70634717",
"0.70483494",
"0.70417815",
"0.70378596",
"0.7031612",
"0.7025889",
"0.7015674",
"0.7000053",
"0.6990466",
"0.69809735",
"0.6978044",
"0.69688356",
"0.69362867",
"0.6913898",
"0.6897716",
"0.6897665",
"0.6893717",
"0.6872617",
"0.686503",
"0.68588567",
"0.68345034",
"0.68144375",
"0.68144375",
"0.67959416",
"0.6784967",
"0.67807955",
"0.6777909",
"0.6762363",
"0.6757752",
"0.6755675",
"0.6755202",
"0.6754234",
"0.6743444",
"0.6736469",
"0.6731797",
"0.6719536",
"0.6692677",
"0.6687461",
"0.66750336",
"0.6660244",
"0.6657514",
"0.66559863",
"0.6648242",
"0.66469735",
"0.6645066",
"0.6644478",
"0.6641545",
"0.6638426",
"0.6634466",
"0.662981",
"0.6625412",
"0.66188055",
"0.6613983",
"0.6613726",
"0.6610928",
"0.66105455",
"0.66074485",
"0.6603869",
"0.66007096",
"0.6590595",
"0.65885377",
"0.6584443",
"0.6584067",
"0.6583104",
"0.65762126",
"0.65724766",
"0.6567001",
"0.655658",
"0.6553643",
"0.6551129",
"0.6547825",
"0.65475345",
"0.65471727",
"0.6544498"
] | 0.0 | -1 |
Merge Sort Use this method if you want to sort. | def merge_sort(list)
length = list.length
if length <= 1
return list
end
mid = length/2
a = list.slice(0...mid)
b = list.slice(mid..-1)
ma = merge_sort(a)
mb = merge_sort(b)
merge(ma, mb)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merge_sort(&prc)\n end",
"def merge_print_sort\n @merge.print_sort\n end",
"def merge_sort\n if self.length <= 1\n return self\n else\n mid = self.length/2\n return merge(self[0...mid].merge_sort, self[mid..-1].merge_sort)\n end\n end",
"def merge_sort(&prc)\n prc || = proc { |num1, num2| num1 <=> num2 }\n return self if length <= 1\n mid = length / 2\n left = self.take(mid).merge_sort(&prc)\n right = self.drop(mid).merge_sort&prc)\n Array.merge(left, right, &prc)\nend",
"def merge_sort(&prc)\n prc ||= Proc.new { |x, y| x <=> y }\n return self if length <= 1\n\n midpoint = self.length / 2\n left = self.take(midpoint).merge_sort(&prc)\n right = self.drop(midpoint).merge_sort(&prc)\n\n Array.merge(left, right, &prc)\n end",
"def mergeSort(ia)\n mergeSortHelper(ia, 0, ia.length-1)\nend",
"def merged_sort(arr)\n return arr if arr.length <= 1\n left_arr = arr[0...arr.length/2]\n right_arr = arr[arr.length/2..-1]\n \n combine(merged_sort(left_arr), merged_sort(right_arr))\nend",
"def merge_sort(arr)\n \n midpoint = arr.size/2\n sub_list_a = arr[0, midpoint]\n sub_list_b = arr[(midpoint + 1)..(arr.size - 1)]\n \n sub_list_a = merge_sort(sub_list_a) \n sub_list_b = merge_sort(sub_list_b) \n \n merge(sub_list_a, sub_list_b)\n \nend",
"def do_merge_sort(first, last)\n return if first >= last\n \n mid = (first + last)/2\n do_merge_sort(first, mid)\n do_merge_sort(mid+1, last)\n do_simple_merge(first,mid,last)\n end",
"def merge_sort(s1, s2, sorter)\n (s1 + s2).sort(&sorter)\n end",
"def merge_sort(arr)\n return arr if arr.size < 2\n middle = arr.size / 2\n left = merge_sort(arr[0...middle])\n right = merge_sort(arr[middle..arr.size])\n merge(left, right)\n end",
"def mergesort lst\n _mergesort_ lst.dup\nend",
"def merge_sort(arr)\n return arr if arr.size < 2\n middle = arr.size / 2\n # cut in half for sort selection\n arr1 = merge_sort(arr[0...middle])\n arr2 = merge_sort(arr[middle..-1])\n merge(arr1, arr2)\nend",
"def merge_sort(array1, array2)\n # write your code here\n sorted_array = []\n i = 0\n j = 0\n\n while i < array1.size && j < array2.size\n if array1[i] < array2[j]\n sorted_array << array1[i]\n i += 1\n else\n sorted_array << array2[j]\n j += 1\n end\n end\n\n sorted_array.concat(array1[i..-1]) if i < array1.size\n\n sorted_array.concat(array2[j..-1]) if j < array2.size\n\n sorted_array\nend",
"def merge_sort_merge(left, right)\n sorted = []\n until left.empty? || right.empty?\n if left[0] <= right[0]\n sorted << left.shift\n else\n sorted << right.shift\n end\n end\n sorted += left + right\n sorted\n end",
"def m_merge_sort(duration)\n\t\t\tMultiThreadedSort.msort(duration, self)\n\t\tend",
"def merged(first, second)\n first.concat(second).sort!\nend",
"def merge_sort(&predicate)\n return self.dup if size <= 1\n mid = size / 2\n left = self[0, mid].dup\n right = self[mid, size].dup\n merge(left.merge_sort(&predicate), right.merge_sort(&predicate), &predicate)\n end",
"def merge_sort(&predicate)\n return self.dup if size <= 1\n mid = size / 2\n left = self[0, mid].dup\n right = self[mid, size].dup\n merge(left.merge_sort(&predicate), right.merge_sort(&predicate), &predicate)\n end",
"def merge_sort numbers, si=0, ei=nil\n\n # TODO: your cool code goes here\n\nend",
"def mergeSort(arr, left, right)\n mid = left + ((right - left) / 2)\n if left >= right\n return arr[left..right]\n end\n left_arr = mergeSort(arr, left, mid)\n right_arr = mergeSort(arr, mid + 1, right)\n #puts \"arrays to be merged = #{left_arr} with #{right_arr}\"\n #puts \"#{left} #{mid} #{right}\"\n j = merge(left_arr, right_arr)\n return j\n end",
"def merge_sort(arr)\n \n puts \"\\n\\n\\n==WELCOME TO MERGE SORT==\\n\\n\\n\"\n \n local_arr = arr\n\n=begin\n local_arr.each do |f|\n puts f.title\n puts f.content\n puts f.position\n puts f.temp_position\n puts \"insider merge sort\\nThe length of arr = #{local_arr.length}\\n\\n\"\n end\n=end\n\n if(local_arr.length == 1)\n local_arr.each do |f|\n puts \"\\n\\nTHIS IS INSIDE MERGE SORT\"\n puts f.title\n puts f.content\n puts f.position\n puts f.temp_position\n puts \"This is right before the return statement\\n\\n\"\n end\n return local_arr\n end\n \n length = local_arr.length\n cut_length = length.to_i / 2\n \n=begin\n local_arr.each do |f|\n puts f.title\n puts f.content\n puts f.position\n puts f.temp_position\n puts \"Hello from inside mergesort \\n\\n\"\n end\n=end\n\n puts \"The length of local_arr = #{local_arr.length}\\n\\n\"\n arr1 = Array.new\n arr2 = Array.new\n sorted = Array.new\n \n count = 0\n while count < cut_length do\n arr1.push(arr[count])\n count += 1\n end\n \n while count < arr.length do\n arr2.push(arr[count])\n count += 1\n end\n \n arr1.each do |f|\n puts f.title\n puts f.content\n puts f.position\n puts f.temp_position\n puts \"Hello from inside mergesort (arr1) \\n\\n\"\n end\n \n arr2.each do |f|\n puts f.title\n puts f.content\n puts f.position\n puts f.temp_position\n puts \"Hello from inside mergesort (arr2) \\n\\n\"\n end\n \n \n=begin\n count = 0\n arr1_count = 0\n arr2_count = 0\n while count < arr.length\n puts \"Count: #{count}\\tarr1_count: #{arr1_count}\\tarr2_count: #{arr2_count}\"\n \n temp1 = arr1[arr1_count]\n temp2 = arr2[arr2_count]\n if(arr1_count < arr1.length - 1 && arr2_count < arr2.length - 1)\n if(temp1.temp_position < temp2.temp_position)\n sorted.push(temp1)\n arr1_count += 1\n else\n sorted.push(temp2)\n arr2_count += 1\n end\n end\n \n count += 1\n end\n \n return sorted\n=end\n\n count = 0\n while count < local_arr.length\n if(!arr1.empty? && !arr2.empty?)\n temp1 = arr1[0]\n temp2 = arr2[0]\n \n puts \"temp1\\tposition: #{temp1.position}\\ttemp_position: #{temp1.temp_position}\\n\"\n puts \"temp2\\tposition: #{temp2.position}\\ttemp_position: #{temp2.temp_position}\\n\"\n \n if(temp1.temp_position < temp2.temp_position)\n sorted.push(temp1)\n arr1.delete(temp1)\n puts \"Count: #{count}\\tPosition: #{temp1.position}\\n\\n\"\n else\n sorted.push(temp2)\n puts \"Count: #{count}\\tPosition: #{temp2.position}\\n\\n\"\n arr2.delete(temp2)\n end\n elsif\n sorted.push(arr2[0])\n arr2.delete(arr2[0])\n elsif\n sorted.push(arr1[0])\n arr1.delete(arr1[0])\n end\n=begin\n if(arr1.empty?)\n sorted.push(arr2[0])\n arr2.delete(arr2[0])\n else\n sorted.push(arr1[0])\n arr1.delete(arr1[0])\n end\n=end\n \n count += 1\n end\n \n puts \"\\n\\nSorted length: #{sorted.length}\"\n \n sorted.each do |f|\n puts \"Position: #{f.position}\"\n end\n \n return sorted\n end",
"def merge_sort(collection)\n if collection.length <= 1\n collection\n else\n mid = (collection.length / 2).floor\n left = merge_sort(collection[0..mid - 1])\n right = merge_sort(collection[mid..collection.length])\n merge(left, right)\n end\n end",
"def merge_sort(arr)\n return arr if arr.length < 2\n\n arr1 = merge_sort(arr.take(arr.length/2))\n arr2 = merge_sort(arr.drop(arr.length/2))\n\n return merge(arr1,arr2)\nend",
"def merge_sort(array1, array2)\n # write your code here\n complete_array = array1 + array2\n return complete_array if complete_array.length < 2\n \n switch = true \n while switch do\n switch = false\n (0...complete_array.length - 1).each do |i|\n if complete_array[i] > complete_array[i + 1]\n complete_array[i], complete_array[i + 1] = complete_array[i + 1], complete_array[i]\n switch = true\n end\n end\n end\n complete_array\nend",
"def merge_sort!(&block)\n become_clone_of merge_sort(&block)\n end",
"def merge_sort(nums)\n len = nums.length\n return nums if len < 2\n mid_index = len / 2\n\n left_sorted = merge_sort(nums[0...mid_index])\n right_sorted = merge_sort(nums[mid_index...len])\n merge(left_sorted, right_sorted)\nend",
"def mergesort!(src, dst, lo, hi, metadata)\n return if hi <= lo\n\n mid = lo + (hi - lo) / 2\n mergesort! dst, src, lo, mid, metadata\n mergesort! dst, src, mid+1, hi, metadata\n merge! src, dst, lo, mid, hi, metadata\nend",
"def sort_merge(a, b)\n return a if (b.length==0)\n left=a.length-b.length-1\n right=b.length\n current=a.length-1\n \n \n while(left>=0 && right>=0){\n if a[left]>b[right]\n a[current]=a[left]\n left-=1\n \n else \n a[current]=a[right]\n right-=1\n end\n current-=1;\n end\n \n while(right>=0)\n a[current]=a[right]\n right-=1\n current-=1\n end \nend",
"def merge_sort(fishes)\n return fishes if self.length <= 1\n mid = fishes.length / 2\n sort_left = fishes.take(mid).merge_sort(fishes)\n sort_right = fishes.drop(mid).merge_sort(fishes)\n merge(sort_left, sort_right)\nend",
"def mergesort(elements)\n\t#Base Case \n return elements if elements.size == 1\n\n #Divide \n mid = elements.size / 2\n left = elements[0, mid]\n right = elements[mid, elements.size]\n \n left_sorted = mergesort(left)\n right_sorted = mergesort(right)\n\n #Conquer\n merge(left_sorted,right_sorted)\nend",
"def merge_sort(array=@base)\n return array if array.size < 2\n mid = array.size/2\n left = array[0..mid-1]\n right = array[mid..-1]\n\n left_merge = merge_sort(left)\n right_merge = merge_sort(right)\n merge_sort_merge(left_merge, right_merge)\n end",
"def mergesort(array = @array)\n if array.length < 2\n return array\n end\n left_array = mergesort(array[0, array.length/2])\n right_array = mergesort(array[array.length/2, array.length])\n\n new_array = merge(left_array, right_array)\n return new_array\n end",
"def merge_sort(a)\n\tif n == 1\n\t\treturn a\n\tend\n\n\tm = n/2\n\n\tb = merge_sort(a)\n\tc = merge_sort(c)\n\t\n\tresult = merge(b,c)\n\n\treturn result\nend",
"def mergeSort(arr)\n\tif arr.length == 1\n\t\treturn arr\n\tend\n\n\tmidpoint = arr.length/2.round\n\tleft = arr[0...midpoint]\n\tright = arr[midpoint..-1]\n\tleft = mergeSort(left) #[4,6]\n\tright = mergeSort(right) #[8, 2]\n\n\treturn merge(left, right)\nend",
"def merge_sort arr\n if arr.size > 1\n mid = arr.size / 2\n left = arr[0, mid]\n right = arr[mid, arr.size-mid]\n \n merge_sort(left)\n merge_sort(right)\n\n i,j,k = 0,0,0\n\n while (i < left.size and j < right.size) do\n if left[i] < right[j]\n arr[k] = left[i]\n i+=1\n else\n arr[k] = right[j]\n j+=1\n end\n k+=1\n end\n\n while i < left.size do\n arr[k] = left[i]\n i+=1\n k+=1\n end\n\n while j < right.size do\n arr[k] = right[j]\n j+=1\n k+=1\n end\n\n end\nend",
"def mergeSort(arr)\r\n # if we have an array that only contains one element or nothing, theres nothing to sort then\r\n if(arr == nil)\r\n return []\r\n end\r\n if(arr.length <= 1)\r\n return arr # simply just return what we got\r\n else\r\n # else we have an array that is sortable, split up the arrays down the midpoint and send them into the driver function\r\n midpoint = arr.length/2\r\n half1 = mergeSort(arr.slice(0...midpoint))\r\n half2 = mergeSort(arr.slice(midpoint...arr.length))\r\n mergeHelper(half1,half2)\r\n end\r\n\r\n end",
"def merge_sort array\n size = array.size\n if size < 2\n array\n else\n merge_array = array.each_slice((size/2.0).round).to_a\n array_a = merge_sort(merge_array[0])\n array_b = merge_sort(merge_array[1])\n new_array = []\n a = 0\n b = 0\n while new_array.size != size\n if array_a.nil? || array_a[a].nil?\n return new_array += array_b[b..-1]\n elsif array_b.nil? || array_b[b].nil?\n return new_array += array_a[a..-1]\n elsif array_a[a] < array_b[b]\n new_array << array_a[a]\n a += 1\n else\n new_array << array_b[b]\n b += 1\n end\n end\n end\nend",
"def merge_sort(arr) # rubocop:disable Metrics/AbcSize\n if arr.size < 2 || (arr.size == 2 && arr[0] < arr[1])\n arr\n elsif arr.size == 2\n [arr[1], arr[0]]\n else\n mid = arr.size / 2\n first = arr.slice(0, mid)\n second = arr.slice(mid, arr.size)\n merge(merge_sort(first), merge_sort(second))\n end\n end",
"def mergeSortHelper(ia, left, right)\n if(left < right)\n mid = ((left + right) / 2).to_i\n\n mergeSortHelper(ia, left, mid)\n mergeSortHelper(ia, mid + 1, right)\n\n merge(ia, left, mid, right)\n end\nend",
"def merge_sort(arr)\n return arr if arr.length <= 1\n mid = arr.length / 2\n left, right= arr.take(mid), arr.drop(mid)\n sorted_left, sorted_right = merge_sort(left), merge_sort(right)\n\n merge(sorted_left, sorted_right)\nend",
"def mergeHelper(l,r)\r\n #puts 'inside mergeHelper'\r\n sortedStorage = []\r\n # while the arrays still have elements in them, execute this loop\r\n while !l.empty? && !r.empty?\r\n if(l[0] < r[0])\r\n sortedStorage.push(l.shift)\r\n else\r\n sortedStorage.push(r.shift)\r\n end\r\n end\r\n # now that we merged the arrays, concat and return\r\n sortedStorage.concat(l,r)\r\n return sortedStorage\r\n end",
"def merge_sort(arr)\n return arr if arr.length == 1 \n mid = (arr.length/2).floor\n left = merge_sort(arr[0..mid - 1])\n right = merge_sort(arr[mid..-1])\n merge(left, right)\nend",
"def merge_sort(arr)\n return arr if arr.length <= 1\n\n mid_idx = arr.length / 2 # this is really for breaking down the array into singletons\n left_side = arr[0...mid_idx]\n right_side = arr[mid_idx..-1]\n\n left = merge_sort(left_side)\n right = merge_sort(right_side)\n\n merge(left, right) # this does the actual sorting\nend",
"def merge_sort(arr)\n if arr.length <= 1\n return arr\n else \n mid = arr.length/2\n left = merge_sort(arr.slice(0...mid))\n right = merge_sort(arr.slice(mid...arr.length))\n merge(left, right)\n end \nend",
"def mergeSort(arr,l,r)\n # Merges two subarrays of arr[].\n # First subarray is arr[l..m]\n # Second subarray is arr[m+1..r]\n def merge(arr, l, m, r)\n n1 = m - l + 1\n n2 = r- m\n \n # create temp arrays\n aL = Array.new(n1, 0)\n aR = Array.new(n2, 0)\n \n # Copy data to temp arrays L[] and R[]\n for i in 0..n1\n aL[i] = arr[l + i]\n end\n \n for j in 0..n2\n aR[j] = arr[m + 1 + j]\n end\n \n # Merge the temp arrays back into arr[l..r]\n i = 0 # Initial index of first subarray\n j = 0 # Initial index of second subarray\n k = l # Initial index of merged subarray\n \n while i < n1 and j < n2 do\n if aL[i] <= aR[j] then\n arr[k] = aL[i]\n i += 1\n else\n arr[k] = aR[j]\n j += 1\n end\n k += 1\n end\n \n # Copy the remaining elements of L[], if there\n # are any\n while i < n1 do\n arr[k] = aL[i]\n i += 1\n k += 1\n end\n \n # Copy the remaining elements of R[], if there\n # are any\n while j < n2 do\n arr[k] = aR[j]\n j += 1\n k += 1\n end\n end # merge \n \n # l is for left index and r is right index of the\n # sub-array of arr to be sorted\n if l < r then\n # Same as (l+r)/2, but avoids overflow for\n # large l and h\n m = (l+(r-1))/2\n\n # Sort first and second halves\n mergeSort(arr, l, m)\n mergeSort(arr, m+1, r)\n merge(arr, l, m, r)\n end\n return arr\n end",
"def merge(list1, list2)\n new_list = list1 + list2\n new_list.sort\n\nend",
"def merge_and_sort_array(array_one, array_two)\n return (array_one + array_two).sort\nend",
"def merge_sort(array)\n length_of_array = array.length\n\n if length_of_array < 2\n sorted_array = array\n return sorted_array\n end\n\n array_half_a = array.slice(0, (length_of_array.to_f / 2).round)\n array_half_b = array.slice((length_of_array.to_f / 2).round, length_of_array / 2)\n sorted_array_a = merge_sort(array_half_a)\n sorted_array_b = merge_sort(array_half_b)\n merged_sorted_array = []\n index_array_a = 0\n index_array_b = 0\n\n while index_array_a < sorted_array_a.length && index_array_b < sorted_array_b.length\n if sorted_array_a[index_array_a] < sorted_array_b[index_array_b]\n merged_sorted_array << sorted_array_a[index_array_a]\n index_array_a += 1\n else\n merged_sorted_array << sorted_array_b[index_array_b]\n index_array_b += 1\n end\n end\n\n merged_sorted_array += if index_array_a == sorted_array_a.length\n sorted_array_b.slice(index_array_b, sorted_array_b.length)\n else\n sorted_array_a.slice(index_array_a, sorted_array_a.length)\n end\n\n merged_sorted_array\nend",
"def merge_sort(numbers)\n return numbers if numbers.size == 1\n mid = numbers.size / 2\n left = numbers[0...mid]\n right = numbers[mid..-1]\n merge(merge_sort(left), merge_sort(right))\nend",
"def merge_sort(numbers)\n return numbers if numbers.size == 1\n mid = numbers.size / 2\n left = numbers[0...mid]\n right = numbers[mid..-1]\n merge(merge_sort(left), merge_sort(right))\nend",
"def merge_sort(ary)\n# base case\n return ary if ary.size < 2\n\n# divide(recursively dividing the array)\n left = merge_sort(ary[0...ary.size/2])\n right = merge_sort(ary[ary.size/2...ary.size])\n\n sorted = []\n# conquer(sort)\n while left.length > 0 && right.length > 0\n# until left.empty? || right.empty? # until one array is empty. In other words, when both are not empty.\n sorted << (left.first > right.first ? right.shift : left.shift)\n end\n\n# if one of the array is empty, add the other array to the sorted list\n left.empty? ? sorted += right : sorted += left\nend",
"def merge_sort(array)\n return array if array.length <= 1 \n mid = array.length / 2\n sorted_left = merge_sort(array.take(mid))\n sorted_right = merge_sort(array.drop(mid))\n \n merge(sorted_left, sorted_right)\n \nend",
"def merge_sort(array)\n p array\n return array if array.length < 2\n\n mid_i = array.length / 2\n left_arr = array[0...mid_i] \n right_arr = array[mid_i..-1] \n\n sorted_left = merge_sort(left_arr)\n sorted_right = merge_sort(right_arr)\n\n merge(sorted_left, sorted_right)\n\nend",
"def merge_sort arr\n\tif arr.length <= 1\n\t\tarr\n\telse\n\t\tmid = arr.length/2\n\t\tfirst_half = arr.slice(0...mid)\n\t\tsecond_half = arr.slice(mid...arr.length)\n\t\tmerge merge_sort(first_half), merge_sort(second_half)\n\tend\nend",
"def merge(list,list2)\n i = 0\n merged = []\n finalmerged = []\n usmerged = []\n while i < list.length - 1\n if list[i] > list2[i]\n merged.push(list2[i] , list[i])\n else\n merged.push(list[i] , list2[i])\n end\n i += 1\n sort = true\n end\n (merged.length - 1).times do |i|\n if merged[i] <= merged[i+1]\n usmerged.push(merged[i],merged[i+1])\n else\n usmerged.push(merged[i+1],merged[i])\n end\n end\n return usmerged\nend",
"def merge(list1,list2)\n mixed = []\n list1.size.times do |n|\n mixed.push(list1[n])\n end\n list2.size.times do |n|\n mixed.push(list2[n])\n end\nreturn mixed.sort\nend",
"def merge_sort(arr)\n if arr.length <= 2\n return merge(arr[0], arr[-1])\n end\nend",
"def merge_sort(array)\n return array if array.size == 1\n left_array,right_array = array.each_slice( (array.size/2.0).round ).to_a\n arr1 = merge_sort(left_array)\n arr2 = merge_sort(right_array)\n arr = merge(arr1, arr2)\n arr\nend",
"def merge_sort(arr)\n if arr.length < 2\n arr\n else\n sorted = []\n left = merge_sort(arr[0..arr.length / 2 - 1])\n right = merge_sort(arr[arr.length / 2..-1])\n while left[0] && right[0]\n sorted << (left[0] > right[0] ? right.shift : left.shift)\n end\n sorted += left + right\n end\nend",
"def merge_sort(arr)\n return arr if arr.length <= 1\n \n mid = arr.length / 2\n left, right = arr[0...mid], arr[mid..-1]\n left, right = merge_sort(left), merge_sort(right)\n\n merge(left, right)\nend",
"def mergeSort array\n if array.count <= 1\n return array\n end\n\n middle = array.count / 2\n left = mergeSort array.slice(0, middle)\n right = mergeSort array.slice(middle, array.count)\n\n left_offset = 0\n right_offset = 0\n\n while left_offset < left.count && right_offset < right.count\n a = left[left_offset]\n b = right[right_offset]\n\n if a <= b\n array.push a\n left_offset += 1\n else\n array.push b\n right_offset += 1\n end\n end\n return merge(left, right)\nend",
"def mergesort(container)\n return container if container.size <= 1\n\n mid = container.size / 2\n left = container[0...mid]\n right = container[mid...container.size]\n merge(mergesort(left), mergesort(right))\n end",
"def merge_sort(arr)\n return arr if arr.length <= 1\n left_half = arr[0...arr.length/2]\n right_half = arr[arr.length/2..-1]\n\n left = merge_sort(left_half) \n right = merge_sort(right_half)\n merge(left, right)\n \nend",
"def merge_sort(arr)\n return arr if arr.length <= 1\n\n middle_idx = arr.length / 2\n\n left = arr[0...middle_idx]\n right = arr[middle_idx..-1]\n\n merge(merge_sort(left), merge_sort(right))\n\nend",
"def merge_sort(arr)\n return arr if arr.length <= 1\n mid = arr.length / 2\n left = merge_sort(arr[0...mid])\n right = merge_sort(arr[mid..-1])\n merge(left, right)\nend",
"def sort_and_merge( arr1, arr2 )\n\n sorted_array = []\n\n while arr1.any? && arr2.any?\n if arr1[0] < arr2[0]\n sorted_array.push( arr1[0] )\n arr1.shift\n else\n sorted_array.push( arr2[0] )\n arr2.shift\n end\n end\n\n while arr1.any?\n sorted_array.push( arr1[0] )\n arr1.shift\n end\n\n while arr2.any?\n sorted_array.push( arr2[0] )\n arr2.shift\n end\n\n return sorted_array\nend",
"def merge_sort( arr )\n return arr if arr.length == 1\n\n mid = arr.length / 2\n\n arr1 = merge_sort( arr[0...mid] )\n arr2 = merge_sort( arr[mid..-1] )\n\n sort_and_merge( arr1, arr2 )\nend",
"def merge_sort(array)\n return [] if array.empty?\n return array if array.count == 1\n retu_arr = []\n left = array[0...(array.length/2)]\n right = array[(array.length/2)..-1]\n left_sort = merge_sort(left)\n right_sort = merge_sort(right)\n \n puts \"left sort is #{left_sort}\"\n puts \"right sort is #{right_sort}\"\n \n while left_sort.empty? == false && right_sort.empty? == false\n if left_sort.first < right_sort.first\n retu_arr << left_sort.shift\n else\n retu_arr << right_sort.shift\n end\n end\n if left_sort.empty? == false\n retu_arr.concat(left_sort)\n elsif right_sort.empty? == false\n retu_arr.concat(right_sort)\n end\n puts \"retu arr is : #{retu_arr}\"\n retu_arr\n\nend",
"def merge_sort list\n midpoint = list.length/2\n\n if list.length < 2\n return list\n else\n list_left = list[0..(midpoint - 1)]\n list_right = list[midpoint..-1]\n\n list_left = merge_sort(list_left)\n list_right = merge_sort(list_right)\n\n return result = merge_lists(list_left, list_right)\n end\nend",
"def merge_sort(arr)\n return arr if arr.length <= 1\n mid = arr.length / 2\n left = merge_sort(arr[0...mid])\n right = merge_sort(arr[mid..-1])\n\n merge(left, right)\nend",
"def merge(list1,list2)\n list = []\n list = list1 + list2\n return list.sort\nend",
"def merge_sort (array, &prc)\n return array if array.length <= 1\n\n mid_idx = array.length / 2\n merge(\n merge_sort(array.take(mid_idx), &prc),\n merge_sort(array.drop(mid_idx), &prc),\n &prc\n )\nend",
"def merge_sort(array)\n split_index = array.size / 2\n arr1 = array[0..split_index]\n arr2 = array[split_index..-1]\n binding.pry\n merged_array = merge(arr1, arr2)\n # check to see if array is sorted; otherwise recursively call merge_sort on merged_array.\n sorted = false\n merged_array.each_with_index do |el, indx|\n sorted = true if !merged_array[indx + 1] \n if el < merged_array[indx + 1] then next\n else break\n end\n end\n sorted ? merged_array : merge_sort(merged_array)\nend",
"def merge_sort(list)\n if list.length <= 1\n list\n else\n mid = (list.length / 2).floor\n left = merge_sort(list[0..mid - 1])\n right = merge_sort(list[mid..list.length])\n merge(left, right)\n end\nend",
"def merge_sort(arr)\n return arr if arr.length < 2\n mid_idx = arr.length/2\n left = arr[0...mid_idx]\n right = arr[mid_idx..-1]\n return merge(merge_sort(left), merge_sort(right))\nend",
"def MergeSort(a)\n if a.length <= 1\n return a\n end\n middle = a.length/2\n left = a[0..middle-1]\n right = a[middle..-1]\n\n left = MergeSort(left)\n right = MergeSort(right)\n sorted_array = merge(left,right)\nend",
"def merge_sort(list)\n return list if list.length <= 1\n\n middle = list.length / 2\n left = list[0..middle - 1]\n right = list[middle..-1]\n left = merge_sort(left)\n right = merge_sort(right)\n merge(left, right)\nend",
"def merge_sort(array)\r\n return array if array.length <= 1\r\n\r\n mid = array.length / 2\r\n\r\n left = merge_sort(array.take(mid)),\r\n right = merge_sort(array.drop(mid))\r\n merge(left, right)\r\nend",
"def merge_sort(arr)\n # [6]\n # arr[0] > arr[1]\n # arr[0], arr[1] = arr[1], arr[0]\n return arr if arr.length <= 1\n middle = arr.length / 2\n left = arr[0...middle]\n right = arr[middle..-1]\n a = merge_sort(left) \n b = merge_sort(right)\n merge(a,b)\nend",
"def merge_sort(arr)\n return arr if arr.length <= 1\n\n mid = arr.length / 2\n\n left = arr[0...mid]\n right = arr[mid..-1]\n\n my_merge(merge_sort(left), merge_sort(right))\nend",
"def merge_sort(array)\n # p array\n return array if array.size == 1\n\n sub_array_1 = array[0...array.size / 2]\n sub_array_2 = array[array.size / 2...array.size]\n\n sub_array_1 = merge_sort(sub_array_1)\n sub_array_2 = merge_sort(sub_array_2)\n\n merge(sub_array_1, sub_array_2)\nend",
"def merge_sort(arr)\n if arr.length == 1\n return arr\n end\n mid = arr.length / 2\n left = arr[0...mid]\n right = arr[mid..-1]\n\n left_half = merge_sort(left)\n right_half = merge_sort(right)\n merge(left_half,right_half)\nend",
"def merge_sort(array)\n return array if array.length <= 1\n\n mid_point = array.length / 2\n\n left_hand = merge_sort(array.take(mid_point))\n right_hand = merge_sort(array.drop(mid_point))\n\n merge_sort_compare(left_hand, right_hand)\n #left_hand + right_hand\nend",
"def merge_sort(array1, array2)\n # third array to store the merged elements\n result = []\n # index for the first array\n i = 0\n # index for the second array\n j = 0\n # iterate until one of them is completely traversed\n while i < array1.length && j < array2.length\n # if the first array holds the smaller element in its current index,\n # store it in the result array then increment the index of the first array\n if array1[i] <= array2[j]\n result << array1[i]\n i += 1\n # otherwise, store the element from the second array in the result array,\n # then increment the index of the second array\n else\n result << array2[j]\n j += 1\n end\n end\n # after the loop above, one of the arrays is completely traversed but the other is not\n # this means that elements remain\n \n # append all remaining elements from the first array to the result array, if they exist\n while i < array1.length\n result << array1[i]\n i += 1\n end\n\n # append all remaining elements from the second array to the result array, if they exist\n while j < array2.length\n result << array2[j]\n j += 1\n end\n result\nend",
"def merge(ary, indice)\n \n #you hit a base case & account for outliers\n\n while (indice) < (ary.count)\n if ary[indice][0] < ary[indice + 1][0]\n current_sort = ary[indice] + ary[indice+1]\n indice = indice + 2\n elsif ary[indice][0] > ary[indice+1][0]\n current_sort= ary[indice+1] + ary[indice]\n indice = indice + 2\n end\n \n @final_ary.push(current_sort)\n p @final_ary, \"current\"\n @ult_ary = current_sort\n end\n if @ult_ary.count == ary.count\n return @final_ary\n p @final_ary\n end\n \n p @ult_ary\n merge(@final_ary, 0)\n\n end",
"def merge_sort(arr)\n return arr if arr.length <= 1\n\n middle = arr.length / 2\n left = arr[0...middle]\n right = arr[middle..-1]\n merge(merge_sort(left), merge_sort(right))\nend",
"def merge_sort(arr)\n cr_size = 1\n while cr_size <= arr.size - 1\n left = 0\n while left < arr.size - 1\n mid = [(left + cr_size - 1), (arr.size - 1)].min\n right = if (2 * cr_size + left - 1) < (arr.size - 1)\n 2 * cr_size + left - 1\n else\n arr.size - 1\n end\n arr[left..right] = merge(arr[left..mid], arr[mid+1..right])\n left += cr_size * 2\n end\n cr_size *= 2\n end\n arr\nend",
"def merge; end",
"def merge_sort(array, p, r)\n return array if p >= r\n q = (p + r) / 2\n merge_sort(array, p, q)\n merge_sort(array, q + 1, r)\n merge(array, p, q, r)\nend",
"def merge_sort(fishes)\n return fishes if fishes.length == 1\n\n mid = fishes.length / 2\n\n left = merge_sort(fishes[0...mid])\n right = merge_sort(fishes[mid..-1])\n\n merge(left, right)\nend",
"def merge_sort(array)\n if array.length <= 1\n return array\n end\n merge(merge_sort(array[0...array.length/2]), merge_sort(array[array.length/2...array.length]))\nend",
"def merge_sort(array)\n # we split the array into 1 element long arrays\n return array if array.length <= 1\n\n mid = array.length / 2\n left = merge_sort(array[0..mid - 1])\n right = merge_sort(array[mid..-1])\n # once we have 1 element long arrays we start merging them\n if left.last <= right.first\n left + right\n else\n merge(left, right)\n end\n end",
"def merge_sort(arr)\n return arr if arr.length <= 1\n first_half = arr[0...(arr.length / 2)]\n second_half = arr[(arr.length / 2)..-1]\n merge(merge_sort(first_half), merge_sort(second_half))\nend",
"def mergeSort(arr)\n puts \"Running merge sort on array: \" + arr.to_s\n temp = copyArr(arr)\n #this block determines what the subproblems that should be merged are\n splitMerge(temp, 1, arr) do |a, t, n|\n if n == 1\n return a\n end\n jump = a.length/n\n i = 0\n while i < a.length\n lo = i\n mid = (i + jump) - 1\n hi = mid + jump\n merge(a, lo, mid, hi, t)\n i = i + (jump*2)\n end\n t\n end\nend",
"def merge_sort(unordered_list)\n p unordered_list\n \n if unordered_list.size < 2\n return unordered_list\n else\n middle = unordered_list.size / 2\n left = merge_sort(unordered_list[0,middle])\n right = merge_sort(unordered_list[middle,unordered_list.size])\n together = merge(left,right)\n puts \"merged: #{together.inspect}\"\n return together\n end \nend",
"def merge_sort(lst)\n if lst.length <= 1\n lst\n else\n mid = (lst.length / 2).floor\n left = merge_sort(lst[0..mid - 1])\n right = merge_sort(lst[mid..lst.length])\n merge(left, right)\n end\nend",
"def merge_sort(arr)\n return arr if arr.length < 2\n middle_index = arr.length / 2\n left_arr = merge_sort(arr[0...middle_index])\n right_arr = merge_sort(arr[middle_index..-1])\n merge_fn(left_arr,right_arr)\nend",
"def merge_sort(a)\n return a if a.length == 1\n\n n = divide(a, a.length / 2)\n\n half_1 = n.shift\n half_2 = n\n\n return merge(merge_sort(half_1), merge_sort(half_2))\nend",
"def merge_sort(arr)\n return arr if arr.length < 2\n middle = arr.length / 2\n half1 = arr[0...middle]\n half2 = arr[middle..-1]\n merge(merge_sort(half1), merge_sort(half2))\nend"
] | [
"0.7736465",
"0.7735201",
"0.74303526",
"0.73996294",
"0.72023076",
"0.71895605",
"0.71866834",
"0.7141702",
"0.7137038",
"0.7131655",
"0.7127414",
"0.7122761",
"0.71124804",
"0.70826566",
"0.7075958",
"0.70707476",
"0.7040145",
"0.6997403",
"0.6997403",
"0.69971067",
"0.6975115",
"0.69659555",
"0.69564885",
"0.6956138",
"0.6952099",
"0.6948589",
"0.69387597",
"0.6936467",
"0.6935535",
"0.6935128",
"0.6924462",
"0.69155055",
"0.6895202",
"0.68836594",
"0.68814415",
"0.68743825",
"0.684926",
"0.6845414",
"0.6845035",
"0.68450177",
"0.6834788",
"0.68327105",
"0.6829613",
"0.68259794",
"0.68252504",
"0.68170404",
"0.68049705",
"0.6803375",
"0.6797838",
"0.67968535",
"0.67968535",
"0.6795892",
"0.67932826",
"0.6787036",
"0.67822134",
"0.6779988",
"0.6775793",
"0.67601323",
"0.67549556",
"0.674571",
"0.6740909",
"0.6729158",
"0.6728565",
"0.6712592",
"0.67122084",
"0.6701922",
"0.67018104",
"0.66781634",
"0.66695803",
"0.6669532",
"0.66693044",
"0.6664583",
"0.6664092",
"0.6663927",
"0.6663872",
"0.66566545",
"0.6651914",
"0.6651195",
"0.66447604",
"0.6631356",
"0.66311985",
"0.6630937",
"0.66304535",
"0.66266143",
"0.66256404",
"0.662559",
"0.66164947",
"0.6610824",
"0.66061777",
"0.6601797",
"0.6598136",
"0.6593163",
"0.6588058",
"0.65876746",
"0.6578318",
"0.65763646",
"0.6575654",
"0.65738416",
"0.6565986",
"0.6561182"
] | 0.70619637 | 16 |
between the square of the sum of the first n positive integers and the sum of the squares of the first n positive integers. | def sum_square_difference(num)
arr = (1..num).to_a
square_of_arr_summed = (arr.sum) ** 2
square_of_each_num = arr.reduce(0) { |sum, n| sum + n**2 }
# Alternatively
# square_of_each_num = 0
# arr.each { |element| square_of_each_num += element **2 }
return square_of_arr_summed - square_of_each_num
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def difference_between_sum_sq_and_sq_sum(n)\n square_sum(n) - sum_squares(n)\nend",
"def sum_of_squares(n)\n sum = 0\n (1..n).each {|i| sum = sum + (i*i)}\n sum\n end",
"def square_of_sums\n return (@n * (@n + 1) / 2)**2\n end",
"def sum_sq_diff(n)\n nums_in_range = (1..n)\n # square_sums = nums_in_range.sum ** 2\n square_sums = nums_in_range.sum.pow(2)\n sums_square = nums_in_range.map { |n| n ** 2 }.sum\n square_sums - sums_square\nend",
"def sum_square_difference(n)\n sum = 0\n sums_squared = 0\n 1.upto(n) do |num|\n sum += num\n sums_squared += num**2\n end\n sum**2 - sums_squared\nend",
"def sum_square_difference(n)\n ((1..n).reduce(:+)**2) - (1..n).reduce{ |sum, i| sum + i**2 }\nend",
"def sum_square_diff(n)\r\n sq_of_sum = (1..n).to_a.sum ** 2\r\n sum_of_sq = (1..n).to_a.map{ |num| num *= num }.sum\r\n (sq_of_sum - sum_of_sq).abs\r\nend",
"def sum_of_squares\n return @n * (@n + 1) * (2 * @n + 1) / 6\n end",
"def sum_square_difference(n)\n integers = (1..n).to_a\n\n square_of_sum = integers.sum ** 2\n sum_of_squares = integers.map { |n| n ** 2 }.sum\n\n square_of_sum - sum_of_squares\nend",
"def sum_of_squares n\n (n**3)/3 + (n**2)/2 + n/6 \nend",
"def sum_square_difference(n)\n \n sum = 0 \n for i in 0..n\n sum += i\n end\n \n sq_sum = 0\n for i in 0..n\n sq_sum += (i**2)\n end \n \n (sum*sum) - sq_sum\nend",
"def sum_square_difference(n)\r\n square_total = 0\r\n sum_square = 0\r\n 1.upto(n) {|x| square_total += x}\r\n 1.upto(n) {|x| sum_square += (x**2)}\r\n square_sum = square_total**2\r\n square_sum - sum_square\r\nend",
"def square_of_sum(n)\n sum = 0\n (1..n).each {|i| sum = sum + i}\n sum * sum\n end",
"def sum_square_difference(n)\n # square_of_sum = (1..n).reduce(:+) ** 2\n # sum_of_squares = (1..n).reduce { |sum, num| sum + num * num }\n # square_of_sum - sum_of_squares\n # (1..n).reduce(:+)**2 - (1..n).reduce { |sum, num| sum + num * num }\n\n (1..n).sum**2 - (1..n).sum { |num| num**2 }\nend",
"def sum_squares(n)\nsums = [] \n for i in (1..n)\n i_squared = i**2\n sums.push i_squared \n end\n p sums.reduce(:+)\nend",
"def sum_square_difference(n)\n n_integers = (1..n).to_a\n square_of_sum = n_integers.inject(:+)**2\n sum_of_squares = n_integers.map {|n|n**2}.inject(:+)\n square_of_sum - sum_of_squares\nend",
"def sum_up_to_squared n=100\r\n (2 * n + 1) * (n + 1) * n / 6\r\nend",
"def square_of_sum\n\t\t@n**2*(@n+1)**2/4\n\tend",
"def sum_of_squares(n)\n sum = 0\n for i in 1..n\n sum+= i*i\n end \n sum\nend",
"def num_squares2(n)\n helper = [0, 1]\n (2..n).each do |i| \n helper[i] = i\n (1..Math.sqrt(i).to_i).each do |j|\n helper[i] = [helper[i - j ** 2] + 1, helper[i]].min\n end \n end \n helper[n]\nend",
"def num_squares1(n)\n helper = [0, 1]\n (2..n).each do |i|\n helper << (1..Math.sqrt(i).to_i).map do |j|\n helper[i - j ** 2] + 1\n end.min\n end\n helper[n]\nend",
"def sum_square_difference(int)\n first_n_ints = (1..int).to_a\n\n sum_1 = first_n_ints.sum\n\n sum_2 = first_n_ints.map{|int| int**2}.sum\n\n (sum_1**2) - sum_2\nend",
"def square_sums(n)\n Array(1..n).sum**2\nend",
"def sum_of_squares\n @number_range.sum {|n| n**2}\n end",
"def sum_square_difference(n)\n square_of_sums = (1..n).inject(:+) ** 2\n sum_of_squares = (1..n).inject {|sum, num| sum + (num ** 2)}\n square_of_sums - sum_of_squares\nend",
"def sum_square_difference(n)\n square_of_sum = ((1..n).sum) ** 2\n sum_of_square = (1..n).map{|i| i * i}.sum\n p difference = square_of_sum - sum_of_square\nend",
"def sum_of_squares\n @range.sum { |n| n**2 }\n end",
"def square_sum_up_to n=100\r\n (n * (n + 1) / 2)**2\r\nend",
"def solve( n = 100 )\n # Sum of squares is given by n(n + 1)(2n + 1) / 6, while square of sums\n # is [n(n + 1)][n(n + 1)] / 4. Subtracting and simplifying the result\n # gives n(n + 1)(n - 1)(3n + 2) / 12.\n n * (n + 1) * (n - 1) * (3*n + 2) / 12\n end",
"def sum_of_squares\n range.reduce { |a, e| a + e**2 }\n end",
"def sums num\n\tsum_of_squares = 0\n\tsum = 0\n\t1.upto num do |n|\n\t\tsum_of_squares += n*n\n\t\tsum += n\n\tend\n\tsum**2 - sum_of_squares \nend",
"def num_squares3(n)\n n /= 4 while n % 4 == 0\n return 4 if n % 8 == 7\n (0..Math.sqrt(n).to_i).each do |a|\n b = Math.sqrt(n - a ** 2).to_i\n if a * a + b * b == n\n if a > 0 && b > 0\n return 2\n elsif a == 0 && b == 0\n return 0\n else\n return 1\n end\n end\n end\n return 3\nend",
"def findDiffSquares(n)\n sum = 0\n (1..n).each { |i|\n (1..n).each { |j|\n sum += i*j unless i == j\n }\n }\n sum\nend",
"def arith_sum_squares(max)\n max * (max+1) * (2*max+1) / 6\nend",
"def sum_of_the_squares\n sum = 0\n (1..self).each do |n|\n sum += n**2\n end\n sum\n end",
"def sum_of_squares(n)\n (1..n).inject(0) do |total, i|\n total += i**2\n end\nend",
"def sum_square_difference(num)\n 1.upto(num).sum**2 - 1.upto(num).reduce(0) { |total, n| total + n**2 }\nend",
"def square_of_sums\n range.reduce(:+)**2\n end",
"def p6\n\trange = (1..100).to_a\n\tsquare_of_sum = range.reduce(:+) ** 2\n\tsum_of_square = (range.map{|x| x ** 2}).reduce(:+)\n\tsquare_of_sum - sum_of_square\nend",
"def solution(num)\n sum_of_squares = 0\n\n (1..num).each do |number|\n sum_of_squares += number**2\n end\n\n square_of_sums = (1..num).inject(:+) ** 2\n\n p (square_of_sums - sum_of_squares).abs\nend",
"def sum_of_square(range)\n\trange.inject(0) { |sum, i| sum + i**2 }\nend",
"def diff_squares(num)\r\n sum_of_nums = (1..num).inject { |sum, x| sum + x }\r\n sum_of_sq = (1..num).inject { |sum, x| sum + x**2 }\r\n sum_of_nums**2 - sum_of_sq\r\nend",
"def square_of_n_integers n\n ((n/2) * (n+1))**2\nend",
"def squareOfSum n\n return triangularNumber(n)**2\nend",
"def sum_square_difference(num)\n (1..num).sum ** 2 - (1..num).map {|num| num ** 2 }.sum\nend",
"def sum_of_squares\n self.inject(0) { |sos, n| sos + n**2 }\n end",
"def sum_squares(n)\n (1..n).inject { |sum, i| sum += i**2 }\nend",
"def sum_square_difference(num)\n square_of_sum = 0\n sum_of_squares = 0\n\n 1.upto(num) do |i| \n square_of_sum += i\n sum_of_squares += i**2\n end\n\n square_of_sum**2 - sum_of_squares\nend",
"def sum_of_the_squares max_number\n sum = 0\n (1..max_number).each { |i| sum += (i ** 2) }\n sum\nend",
"def sum_of_squares\n\t\t\tinject(0) do |sum, elem|\n\t\t\t\tsum + (elem ** 2)\n\t\t\tend\n\t\tend",
"def squares_diff(n)\n (1..n).inject(:+)**2 - (1..n).map{|i| i*i}.inject(:+)\nend",
"def square_of_sum\n @number_range.sum**2\n end",
"def sum_of_squares(max)\n sum = 0\n (1..max).each do|current|\n sum = sum + current**2\n end\n return sum\nend",
"def sum_square_difference(num)\n square_of_sum = ((1..num).sum)**2\n sum_of_squares = (1..num).map { |n| n**2}.sum\n square_of_sum - sum_of_squares\nend",
"def sum_square_difference(num)\n sum = 0\n square_sum = 0\n\n 1.upto(num) do |n|\n sum += n\n square_sum += n**2\n end\n\n sum**2 - square_sum\nend",
"def sum_square_difference(num)\n (1..num).inject(:+)**2 - (1..num).map{|x| x**2}.inject(:+)\nend",
"def square_of_sums\n sum=((@num**2+@num)/2)**2\n end",
"def sum_square_difference(num)\n square_of_sum = 1.upto(num).to_a.reduce(:+) ** 2\n sum_of_squares = 1.upto(num).to_a.map{ |n| n ** 2 }.reduce(:+)\n square_of_sum - sum_of_squares\nend",
"def sum_square_difference(num)\n square_of_the_sum = 0\n sum_of_the_squares = 0\n \n 1.upto(num) do |num|\n square_of_the_sum += num\n sum_of_the_squares += (num ** 2)\n end\n\n total = (square_of_the_sum ** 2) - sum_of_the_squares\n total\nend",
"def sum_of_squares(numbers)\n numbers.map { |x| x * x }.reduce(0) { |acc, x| acc + x }\nend",
"def sum_square_difference(num)\n\n sum_squared = (1..num).to_a.sum ** 2\n\n squares = []\n\n (1..num).each { |n| squares << n ** 2 }\n\n squared_sum = squares.sum\n\n sum_squared - squared_sum\nend",
"def sum_of_squares\n sum(square(sequence))\n end",
"def squareSum(numbers)\n numbers.map { |n| n*n}.reduce(:+)\nend",
"def sum_square_difference(int)\n # square_of_sums = (0..int).inject(:+) ** 2\n # sum_of_squares = (0..int).inject(0) { |memo, value| memo + value ** 2 }\n # return square_of_sums - sum_of_squares\n\n (0..int).inject(:+) ** 2 - (0..int).inject(0) { |sum, n| sum + n ** 2 }\nend",
"def sum_square_difference(integer)\n (1..integer).reduce(:+)**2 - 1.upto(integer).map { |i| i**2 }.reduce(:+)\nend",
"def squareSum(numbers)\n numbers.map { |n| n*n }.reduce(:+)\nend",
"def sum_square_difference(number)\n squared_sum = 1.upto(number).inject(:+)**2\n sum_squares = 0\n 1.upto(number).each {|num| sum_squares += num**2}\n squared_sum - sum_squares\nend",
"def inclusive_squares(a, b)\n first_square = (a ** 0.5).ceil\n count = 0\n while (first_square ** 2) <= b\n count += 1\n first_square += 1\n end\n count\nend",
"def sum_square_diff(num)\n sum_of_squares = 0\n square_of_sum = 0\n\n (1..num).each do |i|\n squared = i**2\n sum_of_squares += squared\n square_of_sum += i\n end\n\n square_of_sum **= 2\n\n difference = square_of_sum - sum_of_squares\n\n puts difference\nend",
"def sum_sq(n)\n cnt = 1\n sum = 0\n while cnt <= n\n sum += cnt * cnt\n cnt += 1\n end \n puts sum\nend",
"def sumOfSquares(max)\n out = 0\n max.times do |i|\n out += (i+1)**2\n end\n out\nend",
"def squareSum(numbers)\n numbers.map { |i| i ** 2 }.reduce(:+)\nend",
"def sum_square_difference(num)\n square_of_sum = (0..num).inject(:+) ** 2\n sum_of_square = (0..num).map { |num| num ** 2}.inject(:+)\n square_of_sum - sum_of_square\nend",
"def sum_of_squares(number)\n \n result = 0\n i = 1\n while i <= number\n result += (i ** 2) \n i += 1\n end\n\n result\nend",
"def square_of_sum\n @range.sum**2\n end",
"def square_of_sums\n square(sum(sequence))\n end",
"def perfects (n)\n return (1..n).select { |x| x==(1...x).select { |i| x%i==0 }.inject(:+) }\nend",
"def sum_square_difference(a_num)\r\n first_block = (1..a_num).to_a.reduce(&:+)\r\n first_block **=2\r\n\r\n second_block = (1..a_num).to_a.map { |number| number ** 2 }\r\n second_block = second_block.reduce(&:+)\r\n\r\n first_block - second_block\r\nend",
"def squareSum(numbers)\n numbers.reduce(0){|sum, x| sum + (x ** 2)}\nend",
"def nice_square(num)\n (1..500).each do |i|\n (1..500).each do |j|\n sum = Math.sqrt(i**2 + j**2)\n (return [i, j, sum]) if (((i + j + sum) == num) && (i**2 + j**2 == sum**2))\n end\n end\nend",
"def all_squared_pairs(num)\n 0.upto(num).take_while { |n| n * n <= num / 2 }.\n map { |n| [n, Math.sqrt(num - n * n)] }.\n select { |n, m| m == m.to_i }\nend",
"def sum_of_squares(x)\n sum_of_squares = 0\n (1..x).each do |f|\n sum_of_squares += f**2\n end\n return sum_of_squares\nend",
"def sum_square_difference(integer)\n array = []\n 1.upto(integer) { |num| array << num }\n sum_squared = array.reduce(:+)**2\n\n array = []\n 1.upto(integer) { |num| array << num**2 }\n squared_sums = array.reduce(:+)\n\n sum_squared - squared_sums\nend",
"def sum_square_difference(integer)\n sum = 0\n square_sum = 0\n 1.upto(integer) { |i| sum += i }\n 1.upto(integer) { |i| square_sum += i**2 }\n sum**2 - square_sum\nend",
"def square_sum(numbers)\n squares = numbers.map{|number| number * number}\n squares.reduce(0){|num, sum| num + sum}\nend",
"def sum_of_multiples_3_5_below(n)\n (1...n).select {|x| x%3==0 || x%5==0}.inject(&:+)\nend",
"def each_value_square_sum(range)\n (1..range).inject {|sum, num| sum += num * num }\n end",
"def solution(n)\n sum = 0\n (1...n).each do |elem|\n sum += elem if elem % 3 == 0 or elem % 5 == 0\n end\n sum\nend",
"def squareSum(numbers)\n numbers.inject(0) { |sum, n| sum + n*n }\nend",
"def solve(n)\n\ttotal = 1\n\t(3...n+1).step(2) do |x|\n\t\t# Upper right corner is x**, the other corners are each x-1 less. Simplify and we've got:\n\t\ttotal += 4*x**2 - 6*x + 6\n\tend\n\treturn total\nend",
"def sum_square_difference(num)\r\n arr = (1..num).to_a\r\n sum1 = arr.sum ** 2\r\n sum2 = arr.inject { |sum, number| sum + number**2 }\r\n sum1 - sum2\r\nend",
"def sum_of_squares\n end",
"def six\n square_of_sum(100) - sum_of_squares(100)\nend",
"def compute_sums(n)\n return compute1_sum if n == 1\n pivot_index = n/2-1\n target_value = total_value/3\n num_souvenirs = souvenirs.size\n\n indexes = []\n skip = false\n while indexes = next_indexes(indexes, n, skip)\n skip = false\n val = nil\n sum(*indexes) do |arr, i|\n val = sum(*indexes[0..pivot_index]) + sum(*indexes[pivot_index+1..-1])\n arr[i] = val\n print \"indexes: #{indexes}, val=#{val}, sum(#{indexes[0..pivot_index].inspect})=#{sum(*indexes[0..pivot_index])}, sum(#{indexes[pivot_index+1..-1]})=#{sum(*indexes[pivot_index+1..-1])}\"\n print \"good indexes found=#{indexes}, pivot=#{pivot_index}\" if val == target_value\n @good_sums << i+1 if val == target_value\n skip = val > target_value\n end\n end\n end",
"def sums_three_five (n)\n\n sum = 0\n #find sum of all 3s\n # 3 to 999 = 3 * (1 .. n/3) = 3 * 333/2 * (1 + 333)\n last_three = (n/3)\n sum += 3 * ((last_three) * (1 + last_three))/2\n\n #find sum of all 5s\n # 1..200\n last_five = (n/5)\n last_five -= 1 if n % 5 == 0 # -1 because n is not included\n sum += 5 * ((last_five) * (1+last_five))/2\n\n #subtract intersection of 5s and 3s\n last_fifteen = (n/15)\n sum -= 15 * ((last_fifteen) * (1+last_fifteen))/2\n\nend",
"def triplet_of_sum(sum)\n (1..sum).each do |a|\n b = a\n while b < sum - b\n c = Math.sqrt(a.abs2 + b.abs2)\n return a * b * c if a + b + c == 1000\n b += 1\n end\n end\nend",
"def square_of_sum\n\tsquare_of = 0\n\n\t(1..100).each do |x|\n\t\tsquare_of += x\n\tend\n\tsquare_of = square_of**2\n\tsquare_of\nend",
"def triangle_sum(n)\n (n * (n + 1))/2\nend",
"def sum_integers_up_to(n)\n (n * ( n + 1 ) ) / 2\nend",
"def square_of_the_sum\n (1..self).inject(&:+)**2\n end"
] | [
"0.793197",
"0.7931715",
"0.7897907",
"0.78956383",
"0.7857072",
"0.77559835",
"0.77504843",
"0.7740316",
"0.77225846",
"0.77178925",
"0.7686875",
"0.7667874",
"0.765986",
"0.7632239",
"0.76199853",
"0.7618291",
"0.7582311",
"0.7550638",
"0.75415814",
"0.753873",
"0.7516909",
"0.7506509",
"0.7484728",
"0.748461",
"0.7474442",
"0.7459125",
"0.7445429",
"0.74395245",
"0.74370396",
"0.7327883",
"0.73054737",
"0.7278539",
"0.72540253",
"0.7247829",
"0.72475815",
"0.7235745",
"0.72244215",
"0.72137314",
"0.72114307",
"0.7172389",
"0.7153555",
"0.7148752",
"0.71321046",
"0.71263915",
"0.71196467",
"0.71161133",
"0.71114784",
"0.70862836",
"0.70851225",
"0.70678",
"0.70672965",
"0.699391",
"0.69834423",
"0.69785607",
"0.6977525",
"0.6973155",
"0.69633496",
"0.6944031",
"0.6939844",
"0.6926147",
"0.6870225",
"0.68544906",
"0.6835679",
"0.68350065",
"0.6829685",
"0.6819522",
"0.6798192",
"0.6796137",
"0.6794404",
"0.6785339",
"0.67703176",
"0.6758376",
"0.675681",
"0.67522615",
"0.67434424",
"0.67399275",
"0.6732923",
"0.67304343",
"0.6721633",
"0.67202437",
"0.67166173",
"0.6702115",
"0.66915184",
"0.6675128",
"0.6663955",
"0.6659095",
"0.6653355",
"0.66525376",
"0.66525066",
"0.6650433",
"0.6642193",
"0.6640291",
"0.6633367",
"0.6614516",
"0.66004235",
"0.6591584",
"0.65795225",
"0.6554617",
"0.65533715",
"0.65326136"
] | 0.6526799 | 100 |
arr3.to_s.each_char do |char| p char end | def arr_sum(array)
num_list = []
array.to_s.each_char do |char|
p char
if char.match(/[0-9]/) #== true
num_list << char
end
end
sum = 0
num_list.each do |s|
sum += s.to_i
end
return num_list, sum
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_output()\n\t#print \"$array= \\n\"\n\t$array.each { |i| i.each {\n\t\t\t\t\t |j|\n\t\t\t\t\t case j\n\t\t\t\t\t when 4\n\t\t\t\t\t \tprint \"•\"\n\t\t\t\t\t when 3\n\t\t\t\t\t \tprint \"x\"\n\t\t\t\t\t when 2\n\t\t\t\t\t \tprint \"*\"\n\t\t\t\t\t when 1\n\t\t\t\t\t \tprint \"█\"\n\t\t\t\t\t when 0\n\t\t\t\t\t \tprint \" \"\n\t\t\t\t\t end }\n\t\t\t\t print \"\\n\"}\nend",
"def arrayfun(array) #BROKEN\n string=\"\"\n for i in 0..array.length-1\n string << \"&\"\n is=array[i].to_s\n for q in 0..(is.length-1)/3\n puts is[q,3].to_i.chr\n end\n end\nend",
"def to_array_of_char(toarray)\n\n\ttoarray.split(//)\n\nend",
"def puts_each(array)\n array.each do |letter|\n puts letter\n end \nend",
"def assembled_characters\n characters_in_split_arrays.map {|array| array.join}\n end",
"def c(array = [])\n str = \"\"\n\n for a in array\n str += a + \" \"\n end\n\n str.strip\n end",
"def to_s\n array.map { |x| x.map { |y| y.zero? ? ' ' : '█' }.join }.join(\"\\n\")\n end",
"def printArray(arr) \n\tarr.each do |e|\n\t\tputs e\n\tend\nend",
"def string(arr)\n arr.join(\" \")\nend",
"def printArray(array)\n array.flatten!\n string = \"\"\n array.each {|letter| string << \"#{letter},\"}\n string.chomp(\",\")\nend",
"def stringify(arr)\n arr.map { |s| s.to_s }.join(\"<br>\")\n end",
"def nth_char(arr)\n str = ''\n 0.upto(arr.size - 1) do |idx|\n str += arr[idx][idx]\n end\n str\nend",
"def printArray()\n index = 0\n print \"-------\"\n (0...array[0].length).each do |row|\n print \"------\"\n end\n puts \"\"\n print \"| - \"\n characters = 65\n (0...array[0].length).each do |row|\n print \"| #{characters.chr} \"\n characters += 1\n end\n puts \"|\"\n for rows in array\n print \"-------\"\n for value in rows\n print \"------\"\n end\n puts \"\"\n print \"| #{index} |\"\n index += 1\n for value in rows\n print \" #{value.to_i} |\"\n end\n puts \"\"\n end\n print \"-------\"\n (0...array[0].length).each do |row|\n print \"------\"\n end\n puts \"\"\n end",
"def process_text arr\n puts arr.map { |s| s.strip }.join(\" \") \nend",
"def printarr\n\t\[email protected]_with_index do |element, index|\n\t\t\tprint element.empty? ? \".\t\" : \"#{element}\t\"\n\t\t\tputs \"\" if (index == 2)||(index == 5)\n\t\tend\n\t\tputs \"\"\n\tend",
"def print_array(array)\n puts '[' + array.join(',') + ']'\nend",
"def array_translate(array)\n new_str = ''\n i = 0\n while i < array.length\n ele = array[i]\n num = array[i+1]\n num.times {new_str += ele}\n i += 2\n end\n return new_str\nend",
"def chars\n map { |b| b.chr }\n end",
"def printList(arr)\n\tfor i in 0..arr.length() - 1 do\n\tputs(arr[i].to_s)\n\tend\n\tputs()\nend",
"def puts_array(array)\n array.each {|item| puts item}\n end",
"def list_apt(arr)\n for i in (0...arr.length)\n puts \"#{i+1}. #{arr[i][0]}\"\n puts arr[i][1]\n puts arr[i][2]\n puts \"\"\n end\nend",
"def imprimer(array)\n array.each do |element|\n print(\"#{element} \")\n end\n puts\nend",
"def nice_list(arr)\n\tarr.each { |i| puts \"* \" + i.to_s }\nend",
"def printarray(array)\n print'{'\n array.each_index do |i|\n print \"#{array[i]}\"\n if i < array.length - 1\n print ', '\n end\n end\n print\"}\\n\\n\"\n end",
"def merge_arr(arr)\n merged_arr = [\"\",\"\",\"\",\"\",\"\",\"\"]\n for i in 0...arr[0].length() \n for j in 0...arr.length() \n font_character = arr [j]\n merged_arr[i] += font_character[i]\n end\n end \n return merged_arr\nend",
"def print_arr_1(arr)\n arr.each do |idx|\n puts el\n end\nend",
"def print_array(array)\n len = length(array)\n i = 0\n while i < len\n print array[i]\n print \" \"\n i += 1\n end\n puts\nend",
"def print_arr(arr)\n # TODO 1\n (0...arr.length).each do |x|\n (0...arr.length).each do |y|\n print arr[x][y]\n print \" \"\n end\n print \"\\n\"\n end\nend",
"def puzzle7\narr=[]\n\tfor i in 0..9\n\t\tstr = \"\"\n\t\tfor i in 0..4\n\t\t\tstr += (65+rand(26)).chr\n\t\tend\n\t\tarr.push(str)\n\tend\n\tprint arr, \"\\n\"\nend",
"def encode_array(arr)\n arr.join ','\n end",
"def convert_guesses_to_str(arr)\n str = \"\"\n arr.each do |char|\n if char.nil?\n str << \"_\"\n else\n str << char\n end\n end\n str\nend",
"def to_s\n output = []\n @letters.values.each_slice(@letters.column_size) do |row|\n output << row.map{ |x| self.class.i_to_s(x) }.join(' ')\n end\n output.join(\"\\n\\n\").upcase.gsub('#', ' ')\n end",
"def back_to_s(array)\n array.join(\"\")\nend",
"def print_numbers(array)\n puts array.join \", \"\nend",
"def convert\n ocr_arr = build_ocr_arr\n # puts \"ocr_arr == #{ocr_arr}\"\n ocr_arr.map do |ocr_char|\n # puts \"ocr_char ==\\n#{ocr_char}\"\n raise InvalidInputError unless valid?(ocr_char)\n if OCR_CHARS.include?(ocr_char)\n ocr_char == ',' ? ocr_char : OCR_CHARS.index(ocr_char).to_s\n else\n '?'\n end\n end.join\n end",
"def to_s\n @chars.join\n end",
"def to_s\n \t#Create an empty string\n \tletter_array = @spaces\n \t# puts letter_array.to_s\n \tletter_array.map!{|char| char == \"Q\" ? char = \"Qu \" : char = char + \" \"}\n\n \toutput_string = String.new()\n\n \t# output_string = output_string.split('').map!{|char| char = char + \" \"}.join('')\n \t4.times do\n \t\toutput_string << letter_array.shift(4).join('') + \"\\n\"\n \tend\n\n\n output_string\n end",
"def print(array)\r\n arr = array.transpose\r\n width = arr.flatten.max.to_s.size + 2\r\n #=> 4\r\n puts(arr.map { |a| a.map { |i| i.round(3).to_s.rjust(width) }.join })\r\n end",
"def byte_arr_to_string arr\n arr.pack(\"c*\")\nend",
"def nth_char(arr)\n arr.map.with_index { |word, idx| word[idx] }.join\nend",
"def array_translate(array)\n translated = \"\"\n i = 0\n while i < array.length\n \tarray[i+1].times do\n \ttranslated += array[i]\n end\n i += 2\n end\n return translated\nend",
"def print_array(a, word_length)\r\n a.each{|x|\r\n x.each{|y| print y.to_s.rjust(word_length)}\r\n puts \r\n }\r\n puts\r\nend",
"def print_board\r\n\t\t@board_array.each do |char|\r\n\t\t\tprint \"#{char} \"\r\n\t\tend\r\n\t\tputs \"\"\r\n\t\t@board_array\r\n\tend",
"def separate_comma(digits_array)\n\n formatted_digits = digits_array.to_s.split(//)\n #p formatted_digits\n\n reverse_digits = formatted_digits.reverse\n #p reverse_digits\n\n slice_three = []\n reverse_digits.each_slice(3) {|slice| slice_three.push(slice)}\n #p slice_three\n\n join_subarrays = slice_three.map(&:join)\n #p join_subarrays\n\n insert_commas = []\n insert_commas = join_subarrays.join(',')\n #p insert_commas\n\n final = insert_commas.reverse\n p final\n\nend",
"def letter_array (name)\n\tname.chars\nend",
"def convertObjectsArrToStringArr(arr)\r\n i = 0\r\n stringArr = []\r\n while i < arr.length\r\n holder = arr[i].to_s\r\n if(holder != \"\")\r\n if(holder[0] != \"#\")\r\n if(!holder.include? \"::\")\r\n stringArr.append(holder)\r\n end\r\n end\r\n end\r\n #p holder\r\n # puts stringArr[i]\r\n i += 1\r\n end\r\n return stringArr\r\n end",
"def decrypt(arr)\n arr.map do |name|\n name.chars.map do |char|\n if (('a'..'m').to_a + ('A'..'M').to_a).include?(char)\n (char.ord + 13).chr\n elsif (('l'..'z').to_a + ('L'..'Z').to_a).include?(char)\n (char.ord - 13).chr\n else\n char\n end\n end.join\n end\nend",
"def puzzle_7\n arr = []\n for i in 0...10\n str = (0...5).map{ (65+rand(26)).chr }.join\n arr << str\n end\n puts arr\nend",
"def output_array(array)\n counter = 0 \n while counter < array.length do \n puts array[counter]\n counter += 1\n end \nend",
"def greet_characters(array)\n array.each do |title|\n puts \"Hello #{title}!\"\n end\nend",
"def output_array(array)\n counter = 0\n while counter < array.length do\n puts array\n counter += 1\n end\nend",
"def to_ascii(l)\r\n [l[0].ord, l[1].ord, l[2].ord]\r\nend",
"def printArray(arr, type)\n puts \"#{type}: \" +arr.join(\", \")\nend",
"def lengths (arr)\n new_arr = []\n arr.each do |str| \n new_arr.push (str.length)\n end\n p new_arr\nend",
"def convertFinalArrayToString\n string = \"\"\n @arrayOfElements.each { |row| \n rowString = \"\"\n row.each { |word|\n if \"\" == rowString\n rowString = rowString + word\n else\n rowString = rowString + \" \" + word\n end\n }\n if \"\" == string\n string = rowString\n else\n string = string + \"\\n\" + rowString\n end\n }\n return string\nend",
"def repeater(string)\n doubled_arr = []\n string.each_char{ |char| doubled_arr << char *= 2} \n p doubled_arr.join\nend",
"def yell(arr)\n result = [];\n i = 0;\n while i < arr.length\n result[i] = arr[i] + '!';\n i += 1;\n end\n return result\nend",
"def converter( array)\n #define hash to convert binary to pixel \n pixels = { \"1\" => \"*\", \"0\" => \" \" }\n output = Array.new\n #iterate to input array \n for i in array\n #populate output array with converted hex to binary values\n #use string hex function to convert input array of hex characters to binary\n output.push(array.to_s[i].hex.to_s(2)) \n end\n #iterate to output array\n for i in output\n # use puts to ouput each element of the output array on a new line\n #use gsub function to replaces binary representation of hex input to pixel hash representation \n puts output.to_s[i].gsub(/[01]/, '1' => '*', '0' => ' ')\n end\nend",
"def printBoard(arr)\n puts \" \" + arr[0].to_s + \" | \" + arr[1].to_s + \" | \" + arr[2].to_s\n puts \"-----------------------\"\n puts \" \" + arr[3].to_s + \" | \" + arr[4].to_s + \" | \" + arr[5].to_s\n puts \"-----------------------\"\n puts \" \" + arr[6].to_s + \" | \" + arr[7].to_s + \" | \" + arr[8].to_s\nend",
"def to_s\n @chars.map { |row| row.join }.join(\"\\n\")\n end",
"def printNums (char, quant)\n\n\ttemp = []\n\tquant.times do \n\t\ttemp << char\n\tend\n\n\ttemp << \"/\"\n\n\ttemp = temp.join\n\treturn temp\n\nend",
"def convert_array(str)\n return \"*invalid input*\" if (str.length < 3) || (str.length % 3 != 0)\n\n set = str.length / 3 # determines number of iterations for a full set\n ary = str.split('')\n\n n = str.length / 3 # track the number of chars remaining in the sets\n a = 0\n i = 0\n\n for i in (1...set)\n ## insert method puts char BEFORE current index\n ## i represents the number of sets that have been itterated\n b = a + n\n b_value = ary.slice!(b)\n ary.insert(a + 1, b_value)\n\n c = b + n\n c_value = ary.slice!(c)\n ary.insert(a + 2, c_value)\n\n n -= 1 # all sets reduced by 1\n a += 3\n end\n\n ary.join\n\nend",
"def print_each(array)\n array.each { |x| puts x.inspect }\nend",
"def next_letter(array)\n array.map! do |letter|\n next_character(letter)\n end\n array = array.join('')\nend",
"def print_arr(arr)\n (0...arr.size).each do |row|\n (0...arr.size).each do |col|\n if arr[row][col]\n print \"X\"\n else\n print \".\"\n end\n end\n puts\n end\n arr.size.times { print \"*\" }\n puts\nend",
"def array_looper(array)\n\tarray.each do |a|\n\t\tputs a\n\tend\nend",
"def arrFlatten(array)\n\ts = []\n\ti = 0\n\tarray.to_s.split(\"\").each do |number|\n\t\tif number.to_i != 0\n\t\t\ts.push(number.to_i)\n\t\tend\n\t\ti += 1\n\tend\n\tputs \"#{s}\"\nend",
"def return_string_array(array)\n array.collect do |element|\n element.to_s\n end\nend",
"def array_method(string)\n string.join(\" \")\nend",
"def to_s\n pretty = @board.each_slice(9).to_a.each do |array|\n puts array\n end\n end",
"def to_chars( numbers )\r\n numbers.collect {|x| x + 64}.pack(\"C*\")\r\n end",
"def process_text(array)\n array.map { |c| c.chomp.strip }.join(' ')\nend",
"def to_array\n\[email protected] \nend",
"def return_string_array(array)\n count = 0\n # create new array to store converted elements\n new_array = []\n # iterate over a provided array\n while count < array.length do\n # add each converted element to the end of a new array with Shovel Method\n new_array << array[count].to_s\n count += 1\n end\n # return new array\n new_array\nend",
"def printArray(anArray)\n\tprint \"\\nHere are the elements in your array: \"\n\tanArray.each {| item | print \"#{ item } \"}\nend",
"def print_array(array)\n for i in 0..array.size - 1 do\n print \"#{array[i]} \"\n end\nend",
"def double_char(str)\n characters = []\n str.split(\"\").each do |x|\n characters << x*2\n end\n p characters.join\nend",
"def combine(str, arr)\n out = ''\n arr.each do |el|\n out += el\n end\n out + str\nend",
"def repeater(str)\n temp_arr = []\n str.chars do |letter|\n temp_arr << letter * 2\n end\n \n temp_arr.join('')\nend",
"def format_comb(arr)\n ret = []\n arr.each do |sub_arr|\n if sub_arr.size > 1\n # use dash to connect the multiple strings \n ret << sub_arr.inject('') {|acc, e| acc + e + '-' }[0..-2]\n elsif sub_arr.size == 1\n ret << sub_arr[0]\n else\n # do nothing...\n end\n end\n return ret\n end",
"def to_s\r\n self.each do |r|\r\n puts r.each { |p| p }.join(\" \")\r\n end\r\n end",
"def printChars(str)\n i = 0\n while i < str.length\n puts str[i]\n i += 1\n end\nend",
"def printChars(str)\n i = 0\n while i < str.length\n puts str[i]\n i += 1\n end\nend",
"def to_s\n # @board.each_char.with_index do |char|\n # p \"#{char} \"\n # p \"\\n\" if\n string = \"\"\n (0..8).each do |row|\n @board.slice(row*9,9).each_char {|char| string << \"#{char} \"}\n string << \"\\n\"\n end\n\n return string\n\n end",
"def replace_with_ascii(input)\n\tints = input.split\n\toutput = \"\"\n\tints.each do |t|\n\t\tt = t.to_i\n\t\toutput += t.chr \n\tend\n\tputs output\nend",
"def to_s\n \n each {|x| puts x}\n \n end",
"def array_translate(array)\n string = ''\n i = 0 \n while i < array.length\n word = array[i]\n num = array[i + 1]\n string += (word * num)\n\n i += 2\n end\n\n string\nend",
"def array_to_sentence_string(array, connector = T.unsafe(nil)); end",
"def print_array(arr) # define method with one parameter\n\ti = 0 # set starting index value\n\twhile i < arr.length\n\t\tputs arr[i] # Returns the value in the array at index value iteration\n\n\t\ti += 1\n\tend\nend",
"def array_of_3_char_substrings\n @array_of_3_char_substrings ||= array_of_2_char_substrings.map do |a|\n array_of_single_char_substrings.map {|b| \"#{a}#{b}\" }\n end#.flatten\n end",
"def double_char(str)\n str = \"String\"\n arr = str.split('')\n arr.map do |letter|\n letter * 2\n end.join\n \nend",
"def filter_repeated_character_strings(arr)\nend",
"def to_chars(str)\r\n c = ''\r\n str.split(',').each do |i|\r\n c += i.to_i.chr\r\n end\r\n c\r\nend",
"def array_list(array) \t\t\t\t\t\t\n\tarray.each {|item| puts \"* #{item}\"}\nend",
"def printArr(arr)\n i = 0\n while i < arr.length\n puts arr[i]\n i += 1\n end\nend",
"def printChars(str)\n i = 0\n while i < str.length\n puts str[i]\n\n i += 1\n end\nend",
"def to_digit_array\n self.to_s.each_char.map(&:to_i)\n end",
"def displayLettersFound()\n\n @lettersDisplayArr.each do |i| \n print i\n end\n print \"\\n\"\n end",
"def arr_to_hc(arr)\n return arr.to_s.gsub(\"\\\"\", \"\\'\")\n end",
"def interesting_number(number)\n number.each_char.map {|c| c.to_i}\n puts number\nend"
] | [
"0.6965731",
"0.6939056",
"0.6824498",
"0.67705745",
"0.6763379",
"0.66111684",
"0.6567642",
"0.6543147",
"0.65339977",
"0.6520474",
"0.651896",
"0.6423507",
"0.62692755",
"0.6260665",
"0.62372744",
"0.61934906",
"0.61292994",
"0.61099064",
"0.61079377",
"0.6084064",
"0.60377204",
"0.6019059",
"0.6011112",
"0.59785163",
"0.5970777",
"0.5969306",
"0.5963757",
"0.59385556",
"0.5922964",
"0.59187466",
"0.5884724",
"0.5884343",
"0.5879069",
"0.5862688",
"0.5824986",
"0.5818018",
"0.57840216",
"0.5780275",
"0.57795125",
"0.57675195",
"0.57579774",
"0.57477856",
"0.57357174",
"0.5720673",
"0.5719476",
"0.5696223",
"0.5694915",
"0.5694379",
"0.569148",
"0.56883997",
"0.5682429",
"0.5676775",
"0.5676459",
"0.5670472",
"0.56668836",
"0.5664418",
"0.5658893",
"0.5655083",
"0.56378734",
"0.56354123",
"0.5625186",
"0.56228596",
"0.5621711",
"0.5615193",
"0.56113964",
"0.56092453",
"0.5607592",
"0.5604806",
"0.5601047",
"0.55978304",
"0.55964553",
"0.5596327",
"0.5594394",
"0.5591954",
"0.558626",
"0.5582368",
"0.55698985",
"0.55661136",
"0.5565746",
"0.55642647",
"0.5558214",
"0.5543802",
"0.5543802",
"0.55437756",
"0.5540152",
"0.5536282",
"0.5536031",
"0.5527204",
"0.552286",
"0.5521684",
"0.5510501",
"0.55057025",
"0.55049515",
"0.55022526",
"0.55009335",
"0.54999745",
"0.549851",
"0.54959285",
"0.54931074",
"0.54926026"
] | 0.5619675 | 63 |
Checks that the move is valid by making sure it is within the range of possible moves | def valid_move? (board, index)
if (0..8) === index && board[index] === " "
return true
else
return false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validates_move move\n\t\[email protected]?(move) && move.index.between?(1,10)\n\tend",
"def valid_move?(move)\n move.to_i.between?(1,9) && !taken?(move)\n end",
"def is_move_valid(move)\n @moves.include? move\n end",
"def valid_move?\n\t\tvalid_1 = (0..2).include? (@take_from)\n\t\tvalid_2 = (0..2).include? (@move_to)\n\t\tif valid_1 == false || valid_2 == false\n\t\t\tputs \"I'm sorry, please input your move in a 'x,y' format, ensuring that you are selecting numbers between 1 and 3!\"\n\t\t\tmove_input\n\t\telsif @pegs[@take_from][0] == nil\n\t\t\tputs \"I'm sorry, I'm not in the mood for a philosophical debate so let's just agree that you cannot move nothing and you can try again.\"\n\t\t\tmove_input\n\t\tend\n\tend",
"def valid_move?(input)\n #checks that the attempted move is within the bounds of the game board\n input.between?(0, 8) && !position_taken?(input)\n end",
"def valid_move?(move)\n move = move.to_i if move.is_a? String\n return false unless move.is_a? Integer\n move.between?(1, 9) && !position_taken?(move-1) \n end",
"def valid_move?(board, position)\n position.between?(0, 8) && !position_taken?(board, position)\nend",
"def valid_move?(board, position)\n !position_taken?(board, position) && position.between?(0,8)\nend",
"def valid_move?(board, position)\n position.to_i.between?(1,9) && !position_taken?(board, position.to_i-1)\nend",
"def valid_moves\n moves.reject { |end_pos| move_into_check?(end_pos) }\n end",
"def valid_move?(move_index)\r\n #valid if position is NOT taken\r\n valid = !self.position_taken?(move_index)\r\n if valid == true\r\n if move_index.between?(0,8)\r\n valid = true\r\n else\r\n valid = false\r\n end\r\n end\r\n valid\r\n end",
"def valid_move?(move)\n # Array of all posiible moves , check the board and map out the possible moves from there.\n end",
"def valid_move?(number_entered, board)\n number_entered.between?(0, 8) && !(position_taken?(board, number_entered))\nend",
"def valid_move?(position)\n position.between?(0,8) && !position_taken?(position)\n end",
"def valid_move?(input)\n (0..8).include?(input) && !position_taken?(input)\n end",
"def valid_move? (board, position)\n position = position.to_i - 1\n (position.between?(0,8)) && (position_taken?(board, position) == false)\nend",
"def valid_move?(board, position)\n # position = position.to_i \n position.to_i. between?(1, 9) && !position_taken?(board, position.to_i-1)\nend",
"def valid_move?(board, index)\n index.between?(0,8) && !position_taken?(board, index) #if the position isn't taken and is on the board, the move must be valid\nend",
"def check_valid(move)\n\n\t\tif @board[move[0]][move[1]] != \"-\"\n\t\t\treturn false\n\t\telse\n\t\t\treturn true\n\t\tend\n\n\tend",
"def check_if_moveisvalid(move)\n @all_available_moves.each do |avail_move|\n return true if move.is_equal_to?(avail_move)\n end\n return false\n end",
"def valid_move?(position)\n !taken?(position) && position.to_i >0 && position.to_i <=9\n end",
"def valid_move?(board, position)\n position.to_i.between?(1,9) && !position_taken?(board,position.to_i-1)\n\nend",
"def valid_move?(board, position)\n position = position.to_i - 1\n position_taken?(board, position) == false && position.between?(0,8) == true\nend",
"def valid_move?(board, position)\n if !(position_taken?(board, position)) && position.between?(0, 8)\n return true\n else\n return false\n end\nend",
"def valid_move?(input_position)\n num = self.convert_to_i(input_position)\n num.between?(1, 9) && !self.taken?(num)\n end",
"def valid_move?(board, position)\n position_taken?(board, position) == false && position.between?(0, 8) ? true : false\nend",
"def valid_move?(destination)\n possible_moves.select do |move|\n on_board?(move) && open?(move)\n end\n\n possible_moves.include?(destination)\n end",
"def valid?(move)\n @board.valid_move?(move)\n end",
"def valid_move?(board, index)\n if !position_taken?(board, index) && index.between?(0, 8)\n true #is valid move\n else\n false\n end\nend",
"def valid_move?(board, position)\n if position_taken?(board, position) == false && position.to_i.between?(0,8)\n true\n else\n false\n end\n end",
"def valid_move?(input)\n !taken?(input) && input.to_i.between?(1, 9)\n end",
"def valid_move?(board, position)\n position = position.to_i\n \n if (position_taken?(board, position) ==false) && position.between?(1,9)\n return true\n else\n return false\n end\nend",
"def valid_move?(board, position)\n position = position.to_i - 1\n if position.between?(0, 8) && !position_taken?(board, position)\n true\n end\nend",
"def valid_move?(position)\n if !position_taken?(position) && position.between?(0,8)\n true\n else\n false\n end\n end",
"def valid_move?(board, position)\n indexed_position = position.to_i - 1\n indexed_position.between?(0,8) && !position_taken?(board, indexed_position)\nend",
"def valid_move?(input)\n (1..9).include?(input.to_i) && !taken?(input)\n end",
"def valid_moves\n valid = []\n all_moves = self.moves\n\n all_moves.each do |end_pos|\n valid << end_pos unless move_into_check(end_pos)\n end\n \n valid\n end",
"def valid_move?(board, position)\n position = (position.to_i - 1)\n\n if position.between?(0, 8) && !position_taken?(board, position)\n true\n else false\n end\nend",
"def valid_moves\n moves.reject {|move| move_into_check?(move)}\n end",
"def valid_move?(board, position)\n position = position.to_i\n \n if !(position_taken?(board, position-1)) && position.between?(1,9)\n return true\n else\n return false\n end\nend",
"def valid_move? (board, index)\n if index.between?(0,8) && position_taken?(board, index) == true\n #position is between 0-8 (1-9) AND the position is available (#position_taken)\n true\n else\n false\n end\nend",
"def valid_move?(board, index)\n !position_taken?(board, index) && index.between?(0, 8)\nend",
"def valid_move?(board,position)\n if position.to_i.between?(1,9) && !position_taken?(board,position.to_i-1)\n true\n else\n end\nend",
"def valid_move?(index)\n puts \"Turn #{turn_count}\"\n index.between?(0,8) && !position_taken?(index)\n end",
"def valid_move?( board, position )\n position_int = position.to_i\n position_ary = position_int - 1\n if !(position_taken?( board, position_ary )) && position_ary.between?( 0, 8 )\n true\n else\n false\n end\nend",
"def valid_move?( board, position )\n position_int = position.to_i\n position_ary = position_int - 1\n if !(position_taken?( board, position_ary )) && position_ary.between?( 0, 8 )\n true\n else\n false\n end\nend",
"def valid_move?(board,pos)\n if !position_taken?(board,pos.to_i-1) && pos.to_i.between?(1,9)\n return true\n elsif position_taken?(board,pos.to_i-1) && pos.to_i.between?(1,9)\n return false\n end\nend",
"def valid_move?(input)\n input.to_i.between?(1,9) && !taken?(input)\n end",
"def valid_move?(input)\n input.to_i.between?(1,9) && !taken?(input)\n end",
"def valid_move?(input)\n input.to_i.between?(1,9) && !taken?(input)\n end",
"def valid_move?( player_input )\n player_input.to_i >= 1 && player_input.to_i <= 9 && !taken?( player_input )\n end",
"def valid_move?(move)\n\t\tif in_bounds?(move) && empty_space?(move) && any_converted_pieces?(move)\n\t\t\treturn true\n\t\telse \n\t\t\treturn false\n\t\tend \n\tend",
"def valid_move?(location)\n location.to_i.between?(1,9) && !position_taken?(location.to_i-1)\n end",
"def valid_move?(board, index)\n !(position_taken?(board,index)) && index.between?(0, 8)\nend",
"def valid_move?(input)\n input.to_i.between?(1, 9) && !taken?(input)\n end",
"def valid_move?(board, index)\n !position_taken?(board, index) && index.between?(0, 8)\nend",
"def valid_moves\n (slide_moves + jump_moves).select { |move| valid_move_seq?([move]) }\n end",
"def valid_move?(board, position)\n position = position.to_i - 1\n if position_taken?(board, position) == false && position.to_i.between?(0, 8)\n return true\nelsif position_taken?(board, position) == true\n return false\nelse \n return false\nend\nend",
"def valid_move?(board, index)\n index.between?(0,8) && !position_taken?(board, index)\n end",
"def valid_move?(board, index)\n index.between?(0,8) && !position_taken?(board, index)\n end",
"def valid_move?(input)\n (input.to_i.between?(1,9) && !taken?(input))\n end",
"def valid_move?(input)\n\t\tinput.to_i.between?(1,9) && !taken?(input)\n\tend",
"def valid_move? (board, index)\n index.between?(0, 8) && !position_taken?(board, index)\nend",
"def valid_move?(board, i)\n if i.between?(0,8) && !position_taken?(board, i)\n true\n end\n end",
"def valid_move?(board, index)\n if index.between?(0,8) && !position_taken?(board, index)\n puts \"this is a valid move\"\n return true\n else\n return false\n end\nend",
"def valid_move?(board, index)\n index.between?(0, 8) && !position_taken?(board, index)\nend",
"def valid_move?(board, index)\n index.between?(0, 8) && !position_taken?(board, index)\nend",
"def valid_move?(board, index)\n index.between?(0, 8) && !position_taken?(board, index)\nend",
"def valid_move?(board, position)\n position = position.to_i\n if(position.between?(1,9))\n position -=1\n if(position_taken?(board, position))\n false\n else\n true\n end\n end\nend",
"def valid_move?(board, input)\n position = (input.to_i)-1\n if (position.between?(0,8))\n return !(position_taken?(board, position))\n else\n return false\n end\nend",
"def valid_move?(board,position)\n position=position.to_i-1\n if position.between?(0,8) && !position_taken?(board, position)\n true\n else\n false\n end\nend",
"def check_move(start_pos, end_pos)\n # p start_pos\n # puts end_pos\n\n if self[[start_pos[0], start_pos[1]]].valid_move?(start_pos, end_pos, self)\n self[[start_pos[0], start_pos[1]]].move(start_pos, end_pos, self)\n end\n end",
"def valid_move?(board, position)\n position = position.to_i\n return false if !valid_position?(position)\n return false if position_taken?(board, position)\n return true\nend",
"def valid_move?(input)\ninput.to_i.between?(1,9) && !position_taken?(input.to_i-1)\nend",
"def valid_move?(position)\n index=position.to_i - 1\n index.between?(0, 8) && !(position_taken?(index))\n end",
"def valid_move?(board, index)\n index.between?(0,8) && !position_taken?(board, index)\nend",
"def valid_move?(board, index)\n index.between?(0,8) && !position_taken?(board, index)\nend",
"def valid_move?(board, index)\n index.between?(0,8) && !position_taken?(board, index)\nend",
"def valid_move?(board, index)\n index.between?(0,8) && !position_taken?(board, index)\nend",
"def valid_move?(board, index)\n index.between?(0,8) && !position_taken?(board, index)\nend",
"def valid_move?(board, index)\n index.between?(0,8) && !position_taken?(board, index)\nend",
"def valid_move?(board, index)\n index.between?(0,8) && !position_taken?(board, index)\nend",
"def valid_move?(board, index)\n index.between?(0,8) && !position_taken?(board, index)\nend",
"def valid_move?(board, index)\n index.between?(0,8) && !position_taken?(board, index)\nend",
"def valid_move?(board, index)\n index.between?(0,8) && !position_taken?(board, index)\nend",
"def valid_move?(board, index)\n index.between?(0,8) && !position_taken?(board, index)\nend",
"def valid_move?(board, index)\n index.between?(0,8) && !position_taken?(board, index)\nend",
"def valid_move?(board, index)\n index.between?(0,8) && !position_taken?(board, index)\nend",
"def valid_move?(board, position)\n index = position.to_i\n if position_taken?(board, index) == false && index.between?(0, 8)\n return true\n else\n return false\n end\nend",
"def valid_move?(input)\n puts \"#{input}\"\n input.to_i.between?(1,9) && !taken?(input)\n end",
"def valid_move?(board,index)\n index.between?(0,8) && !position_taken?(board,index)\nend",
"def valid_move?(board, index)\n index.between?(0,8) && !position_taken?(board,index)\nend",
"def valid_move?(board,index)\n if index.between?(0, 8) && !(position_taken?(board, index))\n true\n else \n false\n end\nend",
"def valid_move?(board, index)\r\n index.between?(0,8) && !position_taken?(board, index)\r\nend",
"def valid_move?(board, index)\n index.between?(0, 8) && position_taken?(board, index) == false\n\nend",
"def valid_move?(board, index)\n if !position_taken?(board, index) && index.between?(0, 8)\n true\n end\nend",
"def valid_move?(board, index)\n if !(position_taken?(board, index)) && index.between?(0,8)\n true\n else\n false\n end\nend",
"def valid_moves\n valid_moves = moves.reject do |move|\n move_into_check?(move)\n end\n\n valid_moves\n end",
"def valid_move?(board, index)\n if !(index.between?(0,8))\n return false\n end\n if (position_taken?(board,index))\n return false\n end\n true\nend",
"def valid_move_seq?(move_seq)\n test_board = @board.dup_board\n # debugger\n if test_board[@position].perform_moves!(move_seq)\n return true\n else\n raise InvalidMoveError\n end\n end",
"def valid_move?(board, position)\n if position.to_i>=1 && position.to_i<=9 && !position_taken?(board, position.to_i-1)\n return true\n else\n return false\n end\nend"
] | [
"0.82396686",
"0.81439435",
"0.7931976",
"0.7853597",
"0.78374326",
"0.78251886",
"0.77923495",
"0.77881753",
"0.77776957",
"0.77742714",
"0.7764888",
"0.77590144",
"0.7751034",
"0.7747991",
"0.7716483",
"0.77114975",
"0.7703074",
"0.7697626",
"0.76874596",
"0.76863134",
"0.7686055",
"0.76720166",
"0.76652694",
"0.76608574",
"0.76589483",
"0.7625327",
"0.7621046",
"0.76174575",
"0.7616459",
"0.76002145",
"0.7594148",
"0.75925624",
"0.75921744",
"0.7576322",
"0.75751555",
"0.75738657",
"0.7572061",
"0.7564822",
"0.7560842",
"0.7559708",
"0.7559064",
"0.7558024",
"0.7555806",
"0.7553488",
"0.75507903",
"0.75507903",
"0.7550461",
"0.75491184",
"0.75491184",
"0.75491184",
"0.75431764",
"0.75420445",
"0.7537379",
"0.7537318",
"0.7533493",
"0.75319535",
"0.7526735",
"0.7522657",
"0.75204724",
"0.75204724",
"0.7518157",
"0.751706",
"0.75048417",
"0.7502945",
"0.74992704",
"0.74920833",
"0.74920833",
"0.74920833",
"0.74896306",
"0.74844635",
"0.74843097",
"0.7478864",
"0.74784565",
"0.74758554",
"0.7473681",
"0.7471461",
"0.7471461",
"0.7471461",
"0.7471461",
"0.7471461",
"0.7471461",
"0.7471461",
"0.7471461",
"0.7471461",
"0.7471461",
"0.7471461",
"0.7471461",
"0.7471461",
"0.7467572",
"0.7461969",
"0.74594754",
"0.7458933",
"0.74501884",
"0.7447223",
"0.74431956",
"0.74415034",
"0.74382734",
"0.74372417",
"0.7434591",
"0.7434477",
"0.74309987"
] | 0.0 | -1 |
Sets the position of the board to "X" or "O" | def move (board, index, token)
#token = current_player(board)
board[index] = token
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move(board, position, xo = \"X\")\n board[position] = xo\nend",
"def move(index, character = \"X\")\n if character == \"X\"\n @board[index] = \"X\"\n else character == \"O\"\n @board[index] = \"O\"\nend\nend",
"def move(board, index, character)\n character = \"X\"\nend",
"def move(board, index, character = \"X\")\n if character == \"X\"\n board[index] = \"X\"\n else character == \"O\"\n board[index] = \"O\"\nend\nend",
"def move(board, position, char=\"X\")\n board[position] = char\nend",
"def move(board, position, character = \"X\")\n board[position] = character\nend",
"def move(board, place, char=\"X\")\n board[place] = char\nend",
"def move(board, pos, mark=\"X\")\n board[pos.to_i-1] = mark\nend",
"def move(board,position,choice=\"X\")\n iPosition = position.to_i\n board[iPosition-1] = choice\nend",
"def move(board, location, char=\"X\")\n location = location.to_i\n board[location - 1] = char\nend",
"def move(board, position, token=\"X\")\n board[position.to_i - 1] = token \nend",
"def move (board, position, character = \"X\")\n board[(position.to_i - 1)] = character\n return board\nend",
"def move(position, token='X')\n @board[position] = token\n end",
"def move(board, input ,char=\"X\")\n board[input.to_i-1] = char\n display_board(board)\nend",
"def move(board, index, char = \"X\")\n board[index.to_i] = char\nend",
"def move(board,cell,char=\"X\")\n board[cell.to_i-1] = char\n puts board\nend",
"def move(board, index, char = \"X\")\n board[index] = char\nend",
"def move (board, index, character = \"X\")\n board[index] = character\nend",
"def make_move(symbol, row, column)\n if(symbol != @@X_SYMBOL && symbol != @@O_SYMBOL)\n raise ArgumentError, \"symbol must either be an X or an O\"\n end\n\n if(@board[row][column] != @@X_SYMBOL && @board[row][column] != @@O_SYMBOL)\n @board[row][column] = symbol\n return true\n end\n return false\n end",
"def move(board,index,symbol=\"X\")\n board[index]=symbol\nend",
"def move(board, input_to_index, character = \"X\")\n board[input_to_index] = character\nend",
"def move(board, position, current_player= \"X\")\n board[position.to_i - 1] = current_player\nend",
"def set_obstacle(y, x)\n @board[y][x] = '#'\n end",
"def move(position,token=\"X\")\n position=position.to_i - 1\n @board[position]=token\n end",
"def move(board, index, character = \"X\")\n board[index] = character\nend",
"def move(board, index, character = \"X\")\n board[index] = character\nend",
"def move(location, token =\"X\")\r\n @board[(location.to_i) -1 ]=token\r\n end",
"def move(board, location, character = \"X\")\n int_location = location.to_i - 1\n board[int_location] = character\nend",
"def move(user_input, character = \"X\")\n @board[user_input] = character\n end",
"def move(board, position, current_player = \"X\")\n board[position.to_i-1] = current_player\nend",
"def move(board, input, character = \"X\")\n board[input] = character\n display_board(board)\nend",
"def move(location, token = \"X\")\n #this sets the correct index value of the chosen position on the board equal to the token \n #(i.e., puts an X or O where you chose, if valid)\n @board[location.to_i-1]= token\n end",
"def move(board, position , player= \"X\" )\n\tposition = position.to_i\n\tboard[position -1] = player\n\tdisplay_board(board)\nend",
"def move(board, position, marker='X')\n board[position.to_i - 1] = marker.upcase\nend",
"def move(position,player_letter = \"X\")\r\n #input logic here\r\n @board[position] = player_letter\r\n end",
"def filler(y, x)\n screen.board[y][x].state = \"o\"\n self\n end",
"def move(position, char)\n @board[position] = char\n end",
"def position_taken?(board, index)\n board[index]==\"X\"||board[index]==\"O\"\n\nend",
"def move(index, token = 'X')\n @board[index] = token\nend",
"def move (board, index, token = \"X\")\n board[index] = token\nend",
"def move(board, converted_input, user_marker = \"X\")\n board[converted_input] = user_marker\nend",
"def move(board, index, char = \"X\")\n board[index] = char\n return board\nend",
"def move(board, position, value = \"X\")\n\n board[position.to_i - 1] = value\n\n return board\nend",
"def move\n index = board.data.split(\"\").index { |c| c == ' ' }\n board.data[index] = 'o'\n end",
"def move(board, index, char=\"X\")\n update_array_at_with(board, index, char)\nend",
"def move(board, index, token = \"X\")\n board[index] = token\nend",
"def move(board, index, token = \"X\")\n board[index] = token\nend",
"def move(board, pos, character= \"X\")\n update_array_at_with(board, pos, character)\nend",
"def move(board, index, value = 'X')\n board[index] = value\nend",
"def move(board, index, token = \"X\")\r\n board[index] = token\r\nend",
"def move(board, input_to_index, player_character = \"X\")\n board[input_to_index] = player_character\nend",
"def move(board, user_input, charac = \"X\")\n board[user_input] = charac \nend",
"def place_symbol(x, y, symbol)\n @board[y][x] = symbol\n end",
"def move (board,index,character=\"X\")\n board[index]=character\nend",
"def move(board, index, token = \"X\")\n board[index] = token\n display_board(board)\nend",
"def move(location, token=\"X\") # move( 0 , O ) \n @board[location] = token\n #binding.pry\n end",
"def move(index, value = \"X\")\n @board[index] = value\n end",
"def move(board, index, token = \"X\")\n board[index] = token\nend",
"def move(board, position, char)\n board[position] = char\nend",
"def move(board, position, char)\n board[position] = char\nend",
"def update_board(move)\n for i in [email protected]\n if move == @board[i]\n # replaces number with either X or O\n @board[i] = @taken[move]\n end\n end\n end",
"def move(index, value=\"X\")\n @board[index] = value\nend",
"def make_move(board)\n puts \"Opponent is thinking...\\n\"\n minimax(board, @char, 0)\n if board.update('O', @choice[0], @choice[1])\n board.draw\n puts \"Opponent chose coordinates (#{@choice[0]+1}, #{@choice[1]+1})\\n\"\n else\n puts \"Something went wrong. The opponent made an illegal move.\\n\"\n end\n end",
"def move(board, index, player_choice = \"X\")\n board[index] = player_choice\nend",
"def move(board, location, current_player = \"X\")\n board[location.to_i-1] = current_player\nend",
"def move(board, location, current_player = \"X\")\n board[location.to_i-1] = current_player\nend",
"def move(input, value = \"X\")\n @board[input.to_i - 1] = value\n end",
"def switch_player\n @letter == :X ? 'O' : 'X'\n end",
"def move(board, index, character = \"X\")\n board[index] = character\n return board\nend",
"def move(board, index, character = \"X\")\n board[index] = character\n return board\nend",
"def move(board, index, character = \"X\")\n board[index] = character\n return board\nend",
"def move(board, index, player_character = \"X\")\n board[index] = player_character\nend",
"def move(board, index, value = \"X\")\n board[index] = value\nend",
"def move(row, col, letter=nil)\n @squares[row][col] = letter\n end",
"def move(board, input_to_index, x = \"X\")\n board[input_to_index] = x\n return board\nend",
"def move(index, token = \"X\")\n @board[index] = token\n end",
"def turn\n marker = @turn_count.even? ? marker = \"X\" : marker = \"O\"\n move\n print \"Current board: \"\n show_board\n @player +=1\n end",
"def move(board, index, current_player = 'X')\n board[index] = current_player\nend",
"def mark (input)\n @@board = mark_input(@@board, input, @@player_turn)\n #switch player after input\n @@player_turn == \"O\" ? @@player_turn = \"X\" : @@player_turn = \"O\"\n end",
"def move pos\n new_board = nil\n next_player = @current_player == :x ? :o : :x\n new_board = @board.make_move @current_player, pos\n State.new new_board, next_player, @computer_player\n end",
"def set(x,y)\n @board[x][y] = 1\n return self\n end",
"def move(move_position, player=\"X\")\n @board[move_position] = player\n end",
"def move(index, token = \"X\")\n\t\t@board[index] = token\n\t\tdisplay_board\n\tend",
"def []=(pos, value)\n @board[pos[0]][pos[1]] = value\n end",
"def position_taken?(index)\n @board[index]==\"X\" || @board[index] == \"O\"\nend",
"def switch_player_position\n if @position == 1\n @symbol = \"\\u{274C}\"\n @position = 2\n elsif @position == 2\n @symbol = \"\\u{2705}\"\n @position = 1\n end\n end",
"def o_board_change (num)\n def space_check (space,board_state)\n if board_state.include?(space)\n return true\n else\n puts \"You've entered an invalid space option.\"\n $i -= 1\n return false\n end\n end\n \n puts \" #{num[0]} | #{num[1]} | #{num[2]}\\n-----------\\n #{num[3]} | #{num[4]} | #{num[5]}\\n-----------\\n #{num[6]} | #{num[7]} | #{num[8]}\"\n \n puts \"Player one, please choose a location for your O.\"\n \n o = gets.chomp\n o_int = o.to_i\n \n if space_check(o_int,num) == true\n space_index = num.index(o_int)\n num[space_index] = \"O\"\n $j = 0\n end\n return num\n end",
"def move(board, index, current_player)\n board[index] = current_player\n if current_player = \"X\" || \"O\"\n return true\n else\n return false\n end\nend",
"def place_x(space)\n \tchoice = to_space_sym(space)\n \t@spaces[choice] = \"X\"\n end",
"def move(board, new_index, position = \"X\")\n\nboard[new_index] = position\n\nend",
"def move(board_index, player_token = \"X\")\n @board[board_index] = player_token\n end",
"def move( index, current_player = \"X\" )\n @board[index] = current_player\n end",
"def move(board , location , player_character = \"X\")\n location = location.to_i\n board[location-1] = player_character\n return board\nend",
"def move(board , location , player_character = \"X\")\n location = location.to_i\n board[location-1] = player_character\n return board\nend",
"def player_one(board, choice)\n\n if choice == 1 \n board[0] = \"X \"\n elsif choice == 2\n board[1] = \" X \"\n elsif choice == 3 \n board[2] = \" X \" \n elsif choice == 4 \n board[3] = \" X \"\n elsif choice == 5\n board[4] = \" X \"\n elsif choice == 6\n board[5] = \" X \"\n elsif choice == 7\n board[6] = \" X \"\n elsif choice == 8 \n board[7] = \" X \"\n elsif choice == 9\n board[8] = \" X \" \n end\nend",
"def move\n\tputs \"Where would you like to move this king? Enter the coords as a 2-digit number\"\n\tnew_pos=gets.chomp\n\tx=new_pos[0].to_i\n\ty=new_pos[1].to_i\n\tif @moves.include? ([x,y])\n\t board[x][y]=self.sym\n\t board[self.pos[0]][self.pos[1]]=\"___\"\n\t self.pos=[x,y]\n\telse\t \n\t move\n\tend\nend",
"def current_player\n x_moves = @board.select {|position| position == \"X\"}\n o_moves = @board.select {|position| position == \"O\"}\n\n if x_moves.size == o_moves.size\n character = \"X\"\n else\n character = \"O\"\n end\n end",
"def make_move!\n return false if get_cell_value(row, column).present?\n\n self.send cell_column(row, column, false), icon\n win? || drawn?\n\n self.save\n end",
"def move(board, index, token=\"X\")\n board[index] = token\n return board\nend",
"def set_position(row, col)\n if row.between?(0, 7) && col.between?(0, 7)\n @position[:row] = row\n\t @position[:col] = col\n\tend\n end",
"def move(board, num, mark=\"X\")\n num = num.to_i\n board[num-1]=mark\nend"
] | [
"0.7539639",
"0.7498335",
"0.74851763",
"0.74424577",
"0.74150425",
"0.7159376",
"0.7153838",
"0.71064365",
"0.70961285",
"0.7075321",
"0.70524573",
"0.7024819",
"0.70148015",
"0.7008469",
"0.6980267",
"0.69736",
"0.6938956",
"0.6911046",
"0.689789",
"0.68960243",
"0.68895584",
"0.68788093",
"0.6855626",
"0.6843268",
"0.6841595",
"0.6841595",
"0.68285406",
"0.68212426",
"0.6818623",
"0.6800205",
"0.67581725",
"0.67514527",
"0.6746229",
"0.6740593",
"0.67398363",
"0.6734413",
"0.6724707",
"0.67202944",
"0.6717697",
"0.67013526",
"0.6700544",
"0.6696457",
"0.6688626",
"0.6674404",
"0.66718554",
"0.66648066",
"0.66648066",
"0.6657772",
"0.66558135",
"0.6654624",
"0.6650426",
"0.66390383",
"0.6638576",
"0.66385645",
"0.663478",
"0.66341496",
"0.662751",
"0.6625526",
"0.6621084",
"0.6621084",
"0.66201514",
"0.6614195",
"0.6588709",
"0.65815973",
"0.65432507",
"0.65432507",
"0.65404373",
"0.6532127",
"0.6531469",
"0.65312344",
"0.65312344",
"0.6518577",
"0.65148425",
"0.6505814",
"0.6499561",
"0.6497491",
"0.6476516",
"0.64631",
"0.64329666",
"0.6428677",
"0.6427992",
"0.6413092",
"0.64040864",
"0.64003605",
"0.6400113",
"0.6396864",
"0.63956136",
"0.6386077",
"0.63659316",
"0.63566613",
"0.6346454",
"0.6340513",
"0.63326895",
"0.63326895",
"0.6315336",
"0.63141835",
"0.63125354",
"0.63007164",
"0.62945175",
"0.62889767",
"0.62880373"
] | 0.0 | -1 |
Converts the user input of board position (from 19) to the correct position in the zeroindexed array (08) | def input_to_index(user_input)
if user_input.to_i.class != Fixnum
return -1
end
user_input = user_input.to_i
user_input -=1
return user_input
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def input_to_index(user_input)\n #take the user's input (\"1\"-\"9\") and convert it to the index of the board array (0-8)\n user_input.to_i - 1\nend",
"def input_to_index(user_input) #this method converts the user_input into the 0-8 index, AKA the position on the board\n user_input = user_input.to_i # assign user_input to (user_input.to_i), which converts the user_input to an integer\n user_input = user_input-1 # assign user_input to (user_input-1), which substracts 1 from the user_input\n #the above line with the (user_input-1) also returns -1 for strings without integers\n end",
"def initialize_board(input)\n board = Array.new(9) {Array.new(9) {Array.new(10, 0)}}; \n for y in (0...9)\n for x in (0...9)\n board[y][x][0] = Integer(input[y*9+x]) \n for p in (1...10)\n if board[y][x][0] == 0\n board[y][x][p] = p\n else\n board[y][x][p] = 0\n end\n end\n end\n end\n return board\n end",
"def input_to_index(board_position)\n if board_position.to_i >= 1 && board_position.to_i <= 9\n index = board_position.to_i - 1\n else\n index = -1\n end\nend",
"def board\n @board_string = @board_string.to_s.split(//).each_slice(9).to_a.map!{|array| array.map!{|string| string.to_i}}\n\n end",
"def map_position(position)\n coords = position.split(\"\")\n col, row = coords\n\n unless coords.length == 2 && ChessGame::LETTER_MAP[col] && row.to_i.between?(1,8)\n raise RuntimeError.new \"Invalid Input - Please use A-H and 1-8\"\n end\n\n [ChessGame::LETTER_MAP[col], (row.to_i)-1]\n end",
"def fen_board_as_array\n map = get_board_to_fen_map\n board=[0]*64\n fen_board = self.board.split(\",\").map{|s| s.to_i}\n map.each { |k, v|\n board[k] = fen_board[v-1]\n }\n board.each_slice(8).to_a\n end",
"def input_to_index(user_input)\n user_input.to_1 - 1 #they are entering a number we have to translate that to the board speak\nend",
"def numbers\n @board.map!.with_index do |e, i|\n e == AIR ? i.to_s : e\n end\n draw_board\nend",
"def turn(board)\n puts \"Please enter 1-9:\"\n input = gets.strip #get user input and store in variable 'input'\n index = input_to_index(input) #convert user response into an integer and subtract 1\n\n\n # maybe need something (like an IF stmt) to check for if the position is not occupied with an X or O,\n # make the move, otherwise run the Turn method again.\n if valid_move?(board, index) #check if user input is in correct range of array 0-8, and position taken is true.\n move(board, index)\n display_board(board) #display the board after all these above checks\n else\n turn(board)\n end\n\nend",
"def turn (board)\n#Ask the user to tell you where they want to move on the board\n puts \"Please enter 1-9:\"\n#Get the user input\n user_input=gets.strip\n index=input_to_index(user_input)\n # If the move is a valid move, then make the move and display the board\n if valid_move?(board,index)\n move(board,index,\"X\")\n display_board(board)\n#If the user puts in an invalid answer or the space in the array is not free, go back to turn and start over\n else turn(board)\nend\nend",
"def gen_board\n\n (\"A\"..\"I\").each do |row|\n (0..8).each_with_index { |column, value| @board.merge!( { \"#{row}#{column}\".to_sym => @board_array.shift.to_i } ) }\n end\n return @board\n end",
"def newposition(input, player)\r\n input = input.to_i\r\n cells[input -1] = player.token\r\n end",
"def position(input)\n if input.to_i.between?(1,9)\n @cells[input.to_i - 1]\n end\n end",
"def getBaseBoard\n baseBoard = Array.new(9) {Array.new(9)}\n for i in 0..8 do\n for j in 0..8 do\n if(@board[i][j].isEditable)\n baseBoard[i][j] = 0\n else\n baseBoard[i][j] = @board[i][j].getValue\n end\n end\n end\n return baseBoard\n end",
"def read_input()\n @board = []\n (1..9).each do\n @board << gets.scan(/./).map(&:to_i)\n end\n end",
"def board_reset(board)\n (0..8).to_a.each { |num| board[num] = INITIAL_MARKER }\nend",
"def convert_to_board_coordinates(position)\n alpha = ('a'..'h').to_a\n\n x_coordinate, y_coordinate = position.split('')\n\n [alpha.index(x_coordinate)+1, y_coordinate.to_i]\n end",
"def move(board, converted_input, value = \"X\")\n def update_array_at_with(array, index, value)\n array[index] = value\n end\n update_array_at_with(board, converted_input, value)\n end",
"def move(board, input ,char=\"X\")\n board[input.to_i-1] = char\n display_board(board)\nend",
"def input_to_index(user_input) \n #converts the user's input (a string) into an integer / would use .to_i\n #converts the user's input from the user-friendly format (on a 1-9 scale) to the array-friendly format (where the first index starts at 0) \n user_input.to_i - 1\n end",
"def move(board, converted_input, user_marker = \"X\")\n board[converted_input] = user_marker\nend",
"def blank_board\n 0b111111100000100000100000100000100000100000100000100000100000100000\nend",
"def board_new\n\t\n\t@board1 = [1, 2, 3]\n\t@board2 = [4, 5, 6]\n\t@board3 = [7, 8, 9]\n\t@board_index = [@board1, @board2, @board3]\n\n\n\tputs \"| #{@board_index [0] [0]} | #{@board_index [1] [0]} | #{@board_index [2] [0]} |\"\n\tputs \"| #{@board_index [0] [1]} | #{@board_index [1] [1]} | #{@board_index [2] [1]} |\"\n\tputs \"| #{@board_index [0] [2]} | #{@board_index [1] [2]} | #{@board_index [2] [2]} |\"\n\treturn @board_index\nend",
"def move(board, input, player = \"X\")\n input = input.to_i - 1\n board[input] = player\nend",
"def mark_input (board, input, player_choice)\n row_input, column_input = split_input(input)[0], split_input(input)[1]\n board[row_input][column_input] = player_choice\n return board\n end",
"def input_to_index(input)\n #converts the user's input (a string) into an integer\n #converts the user's input from the user-friendly format (on a 1-9 scale) to the array-friendly format (where the first index starts at 0)\n input.to_i - 1\n end",
"def make_board\n board = Array.new(8) { Array.new(8) { Array.new(2) } }\n board.each_with_index do |row, row_i|\n row.each_with_index { |column, column_i| column[0], column[1] = row_i, column_i }\n end\n end",
"def input_to_index(user_input) #this method takes one argument (the users input)\n new_user_input = user_input.to_i #this specific .to converts the string into an intergeer\n new_user_input -= 1 #this subtracts it by 1 since arrays start with 0\nend",
"def getCurrentBoard\n currentBoard = Array.new(9) {Array.new(9)}\n for i in 0..8 do\n for j in 0..8 do\n currentBoard[i][j] = @board[i][j].getValue\n end\n end\n return currentBoard\n end",
"def possibleMoves(position)\n moves = []\n for x in 0..2\n for y in 0..2\n if position[x][y]==0\n moves << 3*x + y + 1 #board labeled 1 - 9\n end\n end\n end\n return moves\n end",
"def move(board, input, team = \"X\")\n board[input.to_i - 1] = team\n return board\nend",
"def move(board , location , player_character = \"X\")\n location = location.to_i\n board[location-1] = player_character\n return board\nend",
"def move(board , location , player_character = \"X\")\n location = location.to_i\n board[location-1] = player_character\n return board\nend",
"def update_board(board_arr, position, marker)\r\n\t#takes the board (as an array)\r\n\t#the position (as an integer for the index position)\r\n\t#and a marker\r\n\tboard_arr[position] = marker\r\n\tboard_arr\r\nend",
"def create_empty_board(position)\n 9.times { |i| position[i] = \" \"}\nend",
"def build_current_board\n i = 0\n @state_of_board = []\n while i < @word_array.length.to_i - 2\n \n if @correct_index_list.include?(i)\n @state_of_board[i] = @word_array[i]\n else\n @state_of_board[i] = \"_\"\n end\n i += 1\n end \n return @state_of_board\n end",
"def move(board, index, char=\"X\")\n update_array_at_with(board, index, char)\nend",
"def position(user_input)\n cells[user_input.to_i - 1]\n end",
"def move(board,cell,char=\"X\")\n board[cell.to_i-1] = char\n puts board\nend",
"def gen_board\n \tboard = {}\n (\"A\"..\"I\").each do |row|\n (0..8).each_with_index { |column, value| board.merge!( { \"#{row}#{column}\".to_sym => @board_array.shift.to_i } ) }\n end\n return board\n end",
"def create_board\n cols = Array.new(7) { Array.new(6, 0) }\n cols\n end",
"def turn(board)\n puts \"Please enter 1-9:\"\n input = gets.strip\n index = input_to_index(input)\n if valid_move?(board, index) == true\n move(board, index)\n else\n puts \"Not a valid entry, position must be between 1 and 9 and not be currently occupied\"\n turn(board)\n end\n display_board(board)\nend",
"def set_board\n arr = []\n arr << [\"\\u2656\",\"\\u2658\",\"\\u2657\",\"\\u2655\",\"\\u2659\",\"\\u2657\",\"\\u2658\",\"\\u2656\"]\n arr << (\"\\u2659 \"* 8).split()\n 4.times do\n arr << (\". \" * 8).split()\n end\n arr << (\"\\u265f \"* 8).split()\n arr << [\"\\u265c\",\"\\u265e\",\"\\u265d\",\"\\u265b\",\"\\u265f\",\"\\u265d\",\"\\u265e\",\"\\u265c\"]\n #test cases\n arr[4][1] = \"\\u2654\"\n arr[3][5] = \"\\u265a\"\n arr\n end",
"def users_turn\n puts \"Please choose a square to play (1-9): \"\n # take in users input and assign to a variable\n users_choice = gets.chomp.to_i\n # subtract 1 from the choice to match the array\n users_choice -= 1\n # assign the choice integer to i for index\n i = users_choice\n # check that the index is blank \n if @board[i] == \" \"\n # assign \"X\" to the index of array space chosen\n @board[i] = @symbol\n # otherwise start over\n else users_turn\n end\n check_game_status\n play_game\n end",
"def initialize_board\n init_board = \"-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1\"\n if self.update(board: init_board)\n return [[ 0,-1,0,-1,0,-1, 0,-1 ],[-1,0,-1,0,-1,0,-1,0],[0,-1,0,-1,0,-1,0,-1],\n [0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0],\n [1,0,1,0,1,0,1,0],[0,1,0,1,0,1,0,1],[1,0,1,0,1,0,1,0]]\n end\n end",
"def new_board\n (\"1\"..\"7\").to_a.each_with_object({}) do |key, hash|\n hash[key] = Array.new(6) { |i| (i + 1).to_s }\n end\n end",
"def move(board,position,value)\n index = input_to_index(position)\n board[index] = value\n\nend",
"def input_to_row(row)\n 8 - row.to_i\n end",
"def position\n [ChessBoard.col_index(pos[0]), pos[1].to_i]\n end",
"def turn\n character = current_player\nputs \"Please enter 1-9:\"\nuser_input = gets.strip\nuser_input = user_input.to_i\nindex = input_to_index(user_input)\n if valid_move?(index) == true\n move(index, character)\n display_board\n else \n turn\n end\nend",
"def turn(board)\n character = \"X\"\nputs \"Please enter 1-9:\"\nuser_input = gets.strip\nuser_input = user_input.to_i\nindex = input_to_index(user_input)\n if valid_move?(board, index) == true\n move(board, index, character = \"X\")\n display_board(board)\n else \n turn(board)\n end\nend",
"def move(board, input_to_index, character)\n board[input_to_index] = character\nend",
"def new_board\n board = []\n 8.times do |row|\n board << case row\n when 0\n add_back_row(\"white\", row)\n when 1\n add_pawn_row(\"white\", row)\n when 6\n add_pawn_row(\"black\", row)\n when 7\n add_back_row(\"black\", row)\n else\n Array.new(8)\n end\n end \n board\n end",
"def move(board, input_to_index, x = \"X\")\n board[input_to_index] = x\n return board\nend",
"def setup\n (1..12).each do |num|\n @board[num] = %W[_ _ _ _]\n end\n end",
"def turn(array)\r\n puts \"Please enter 1-9:\"\r\n user_input = gets.strip\r\n user_move = input_to_index(user_input)\r\n if valid_move?(array,user_move)\r\n move(array,user_move,current_player(array))\r\n display_board(array)\r\n else \r\n turn(array)\r\n end\r\nend",
"def set_board(position, length, w_pos, w_mov, a_pos, a_mov)\n board = []\n # space setup\n for i in 0..length\n board.push(SPACE)\n end\n # moon and earth setup\n board[0] = EARTH\n board[length] = MOON\n # check for warp and alien positions\n w_pos.each {|i| board[i] = WARP}\n a_pos.each {|i| board[i] = ALIEN}\n # collision with warp or alien\n if board[position] == WARP\n puts \"Warp +#{w_mov} spaces forward.\"\n position += w_mov\n elsif board[position] == ALIEN\n puts \"Alien pushes back -#{a_mov}.\"\n position -= a_mov\n end\n position = 0 if position < 0\n position = length + 1 if position >= length\n # setting position of emoji\n if position < 0\n position = 0\n board[position] = ROCKET\n elsif position >= length\n position = length + 1\n board[position] = ROCKET\n position = length\n else\n board[position] = ROCKET\n end\n board.each {|i| print i}\n puts ''\n return position\nend",
"def possible_moves(position, board, color)\n out_array = []\n\n x = position[0]\n y = position[1]\n\n #going right\n while y < 7\n y += 1\n if board[x][y] && board[x][y].color != color\n out_array.push([x, y])\n break\n elsif board[x][y] && board[x][y].color == color\n break\n end\n out_array.push([x, y])\n end\n\n y = position[1]\n while y > 0\n y -= 1\n if board[x][y] && board[x][y].color != color\n out_array.push([x, y])\n break\n elsif board[x][y] && board[x][y].color == color\n break\n end\n out_array.push([x, y])\n end\n\n y = position[1]\n while x > 0\n x -= 1\n if board[x][y] && board[x][y].color != color\n out_array.push([x, y])\n break\n elsif board[x][y] && board[x][y].color == color\n break\n end\n out_array.push([x, y])\n end\n\n x = position[0]\n while x < 7\n x += 1\n if board[x][y] && board[x][y].color != color\n out_array.push([x, y])\n break\n elsif board[x][y] && board[x][y].color == color\n break\n end\n out_array.push([x, y])\n end\n\n\n out_array\n end",
"def move(board,index,char)\n\n board[index]=char\n\n return board\nend",
"def display_board\n @board.map.with_index do |playermove, index|\n if index == 0 && playermove.nil?\n print(\"#{index} |\") \n elsif index == 2 && playermove.nil?\n print(\"| #{index}\")\n elsif index == 3 && playermove.nil?\n print(\"#{index} |\") \n elsif index == 5 && playermove.nil?\n print(\"| #{index}\")\n elsif index == 6 && playermove.nil?\n print(\"#{index} |\")\n elsif index == 8 && playermove.nil?\n print(\"| #{index}\")\n elsif playermove.nil?\n print(\" #{index} \")\n else\n print(\" #{playermove} \")\n end\n if (index + 1) % 3 == 0 && index < 7\n print \"\\n---------\\n\"\n end\n end\n end",
"def position(input)\n player_position = input.to_i - 1\n @cells[player_position]\n end",
"def input_to_index( position )\n position = position.to_i\n position = position - 1\nend",
"def move(board,index,char)\n board[index] = char\n return board\nend",
"def rotate_board\n\t\t@board[70] = @board[[7,0]]\n\t\t@board[71] = @board[[7,1]]\n\t\t@board[72] = @board[[7,2]]\n\t\t@board[73] = @board[[7,3]]\n\t\t@board[74] = @board[[7,4]]\n\t\t@board[75] = @board[[7,5]]\n\t\t@board[76] = @board[[7,6]]\n\t\t@board[77] = @board[[7,7]]\n\t\t@board[60] = @board[[6,0]]\n\t\t@board[61] = @board[[6,1]]\n\t\t@board[62] = @board[[6,2]]\n\t\t@board[63] = @board[[6,3]]\n\t\t@board[64] = @board[[6,4]]\n\t\t@board[65] = @board[[6,5]]\n\t\t@board[66] = @board[[6,6]]\n\t\t@board[67] = @board[[6,7]]\t\n\t\t@board[50] = @board[[5,0]]\n\t\t@board[51] = @board[[5,1]]\n\t\t@board[52] = @board[[5,2]]\n\t\t@board[53] = @board[[5,3]]\n\t\t@board[54] = @board[[5,4]]\n\t\t@board[55] = @board[[5,5]]\n\t\t@board[56] = @board[[5,6]]\n\t\t@board[57] = @board[[5,7]]\t\n\t\t@board[40] = @board[[4,0]]\n\t\t@board[41] = @board[[4,1]]\n\t\t@board[42] = @board[[4,2]]\n\t\t@board[43] = @board[[4,3]]\n\t\t@board[44] = @board[[4,4]]\n\t\t@board[45] = @board[[4,5]]\n\t\t@board[46] = @board[[4,6]]\n\t\t@board[47] = @board[[4,7]]\t\t\t\t\n\t\t@board[[7,0]] = @board[[0,7]]\n\t\t@board[[7,1]] = @board[[0,6]]\n\t\t@board[[7,2]] = @board[[0,5]]\n\t\t@board[[7,3]] = @board[[0,4]]\n\t\t@board[[7,4]] = @board[[0,3]]\n\t\t@board[[7,5]] = @board[[0,2]]\n\t\t@board[[7,6]] = @board[[0,1]]\n\t\t@board[[7,7]] = @board[[0,0]]\n\t\t@board[[6,0]] = @board[[1,7]]\n\t\t@board[[6,1]] = @board[[1,6]]\n\t\t@board[[6,2]] = @board[[1,5]]\n\t\t@board[[6,3]] = @board[[1,4]]\n\t\t@board[[6,4]] = @board[[1,3]]\n\t\t@board[[6,5]] = @board[[1,2]]\n\t\t@board[[6,6]] = @board[[1,1]]\n\t\t@board[[6,7]] = @board[[1,0]]\n\t\t@board[[5,0]] = @board[[2,7]]\n\t\t@board[[5,1]] = @board[[2,6]]\n\t\t@board[[5,2]] = @board[[2,5]]\n\t\t@board[[5,3]] = @board[[2,4]]\n\t\t@board[[5,4]] = @board[[2,3]]\n\t\t@board[[5,5]] = @board[[2,2]]\n\t\t@board[[5,6]] = @board[[2,1]]\n\t\t@board[[5,7]] = @board[[2,0]]\n\t\t@board[[4,0]] = @board[[3,7]]\n\t\t@board[[4,1]] = @board[[3,6]]\n\t\t@board[[4,2]] = @board[[3,5]]\n\t\t@board[[4,3]] = @board[[3,4]]\n\t\t@board[[4,4]] = @board[[3,3]]\n\t\t@board[[4,5]] = @board[[3,2]]\n\t\t@board[[4,6]] = @board[[3,1]]\n\t\t@board[[4,7]] = @board[[3,0]]\t\n\t\t@board[[3,0]] = @board[47]\n\t\t@board[[3,1]] = @board[46]\n\t\t@board[[3,2]] = @board[45]\n\t\t@board[[3,3]] = @board[44]\n\t\t@board[[3,4]] = @board[43]\n\t\t@board[[3,5]] = @board[42]\n\t\t@board[[3,6]] = @board[41]\n\t\t@board[[3,7]] = @board[40]\t\n\t\t@board[[2,0]] = @board[57]\n\t\t@board[[2,1]] = @board[56]\n\t\t@board[[2,2]] = @board[55]\n\t\t@board[[2,3]] = @board[54]\n\t\t@board[[2,4]] = @board[53]\n\t\t@board[[2,5]] = @board[52]\n\t\t@board[[2,6]] = @board[51]\n\t\t@board[[2,7]] = @board[50]\t\n\t\t@board[[1,0]] = @board[67]\n\t\t@board[[1,1]] = @board[66]\n\t\t@board[[1,2]] = @board[65]\n\t\t@board[[1,3]] = @board[64]\n\t\t@board[[1,4]] = @board[63]\n\t\t@board[[1,5]] = @board[62]\n\t\t@board[[1,6]] = @board[61]\n\t\t@board[[1,7]] = @board[60]\n\t\t@board[[0,0]] = @board[77]\n\t\t@board[[0,1]] = @board[76]\n\t\t@board[[0,2]] = @board[75]\n\t\t@board[[0,3]] = @board[74]\n\t\t@board[[0,4]] = @board[73]\n\t\t@board[[0,5]] = @board[72]\n\t\t@board[[0,6]] = @board[71]\n\t\t@board[[0,7]] = @board[70]\n\t\[email protected](40)\n\t\[email protected](41)\n\t\[email protected](42)\n\t\[email protected](43)\n\t\[email protected](44)\n\t\[email protected](45)\n\t\[email protected](46)\n\t\[email protected](47)\n\t\[email protected](50)\n\t\[email protected](51)\n\t\[email protected](52)\n\t\[email protected](53)\n\t\[email protected](54)\n\t\[email protected](55)\n\t\[email protected](56)\n\t\[email protected](57)\n\t\[email protected](60)\n\t\[email protected](61)\n\t\[email protected](62)\n\t\[email protected](63)\n\t\[email protected](64)\n\t\[email protected](65)\n\t\[email protected](66)\n\t\[email protected](67)\t\n\t\[email protected](70)\n\t\[email protected](71)\n\t\[email protected](72)\n\t\[email protected](73)\n\t\[email protected](74)\n\t\[email protected](75)\n\t\[email protected](76)\n\t\[email protected](77)\t\t\t\t\t\n\t\t@board\t\t\t\t\t\t\t\t\t\t\n\tend",
"def valid_move?(board,index)\n# The user_input was accepted, converted to an integer and reduced by 1 in #input_to_index. Now you are testing to make sure\n# that the value of the index is within the confines of the board array whose elements are 0-8. It also requires NOT #position_taken\n# which means that the test that was done in position_taken which resulted in TRUE is turned into a NOT by using !position_taken\nif index .between?(0,8) && !position_taken?(board,index)\n true\nend\n\nend",
"def new_board_grid\n unicode = 65\n @board_matrix.each do |array|\n @board_matrix.each_with_index do |_element, i|\n array[i] = \" #{unicode.chr} \"\n unicode += 1\n end\n end\n end",
"def turn(array)\r\n puts \"Please enter 1-9:\"\r\n input = gets.strip\r\n index = input_to_index(input)\r\n if valid_move?(array,index) == true\r\n move(array, index, \"X\")\r\n display_board(array)\r\n else\r\n puts \"This move is not correct.\"\r\n turn(array)\r\n end\r\nend",
"def position(input)\n cell_index_taken = input.to_i-1\n cells[cell_index_taken]\n end",
"def normalize_positions(pos_array)\n pos_array.map do |x, y|\n \"#{ChessBoard::COLUMN_CODES[x-1]}#{y}\"\n end\n end",
"def initialize_board\n b = []\n 9.times { b << ' ' } \n b\nend",
"def move(board,position,choice=\"X\")\n iPosition = position.to_i\n board[iPosition-1] = choice\nend",
"def player board_new\n\tputs \"Player turn: \\n\n\tPlease Select a board option 1-9\"\n\tanswer_player = gets.chomp\n\twhile true\n\t\tif answer_player == \"1\"\n\t\t\t# key = @board_index[0][0]\n\t\t\t# puts @board_index[0][0]\n\t\t\t# puts key\n\t\t\ttrash = @board_index.at(0).at(0)\n\t\t\tdelete_if(trash.include?(1))\n\n\t\t\t# delete.at(0).insert(0, \"X\")\n\t\t\t# @board_index.insert(key, \"X\")\n\t\t\t# @board_index.insert(0 0, \"X\")\n\t\t\t@board1\n\t\t\t\n\n\t\t\tputs \"| #{@board_index [0] [0]} | #{@board_index [1] [0]} | #{@board_index [2] [0]} |\"\n\t\t\tputs \"| #{@board_index [0] [1]} | #{@board_index [1] [1]} | #{@board_index [2] [1]} |\"\n\t\t\tputs \"| #{@board_index [0] [2]} | #{@board_index [1] [2]} | #{@board_index [2] [2]} |\"\n\t\t\tbreak\n\t\telsif answer_player == \"2\"\n\t\telsif answer_player == \"3\"\n\t\telsif answer_player == \"4\"\n\t\telsif answer_player == \"5\"\n\t\telsif answer_player == \"6\"\n\t\telsif answer_player == \"7\"\n\t\telsif answer_player == \"8\"\n\t\telsif answer_player == \"9\"\t\n\t\telse \n\t\t\tputs \"That is not a valid option\"\n\t\tend\n\tend\n\n\n\n\nend",
"def move(board, index, user_char)\n board[index] = user_char\nend",
"def create_board(size)\n return (0...size).map{|b| (0...size).map{|bb| 0}}\n end",
"def input_move(move, color)\n move = move.to_i\n index = 0\n until @board[move][index] == 0\n index += 1\n end\n @board[move][index] = color\n end",
"def prepare_board\n\t\t(1..15).each do |number|\n\t\t\t(\"a\"..\"o\").each do |letter|\n\t\t\t\t@board[(letter + number.to_s).to_sym] = \" \"\n\t\t\tend\n\t\tend\n\tend",
"def valid_move?(board,position)\n position = position.to_i #convert string to integer\n position = position-1 #translate position to array location\n\n if position >= 0 and position < 9 #check for legal position\n if board[position].strip.empty?\n return true\n elsif position_taken?(board,position)\n return false #position is occupied\n end\n else\n return false #illegal position\n end\nend",
"def turn(board)\n puts \"Please enter 1-9:\"\n user_input = gets.chomp\n int_input = input_to_index(user_input) #convert user_input to int\n move_okay = valid_move?(board, int_input)\n\n if move_okay == true\n move(board, int_input)\n display_board(board)\n else\n turn(board)\n end\nend",
"def move(board, location, char=\"X\")\n location = location.to_i\n board[location - 1] = char\nend",
"def move(board, input_to_index, player_character = \"X\")\n board[input_to_index] = player_character\nend",
"def input_to_index(player_move)\n input = player_move.to_i\n final_move = input - 1\nend",
"def position(input)\n\t\tcells[input.to_i - 1]\n\tend",
"def convert_pieces(array)\n\t\tarray.each{|x| @board[x]=$current_player}\n\tend",
"def move(board, pos, character= \"X\")\n update_array_at_with(board, pos, character)\nend",
"def move_to(piece)\r\n cols = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']\r\n rows = [1, 2, 3, 4, 5, 6, 7, 8]\r\n counter = 0; x = ''; y = ''\r\n until counter == 1\r\n print \"Enter destination coordinates: \"\r\n coordinate = STDIN.gets.chomp\r\n x = coordinate[0]; y = coordinate[1].to_i\r\n counter+=1 if ((cols.include? x) && (rows.include? y))\r\n end\r\n puts ''\r\n puts \"#{piece.class} to #{x}#{y}.\"\r\n stop = []\r\n stop[0] = cols.index(x)\r\n stop[1] = rows.index(y)\r\n stop \r\n end",
"def turn(board)\r\n puts \"Please enter 1-9:\"\r\n input = gets.strip\r\n index = input_to_index(input)\r\n if valid_move?(board, index)\r\n move(board, index)\r\n display_board(board)\r\n else\r\n turn(board)\r\n end\r\nend",
"def next_turn(board)\r\n new_board = Array.new(board.size) {Array.new (board[0].size)}\r\n\r\n #iterate over each cell in the board and calculate it's value by calling next_cell_value\r\n board.each_with_index do |cells, row|\r\n cells.each_with_index do |cell, column|\r\n new_board[row][column] = next_cell_value(board, row, column)\r\n end\r\n end\r\n new_board\r\n end",
"def turn(board)\n puts \"Please enter 1-9:\"\n user_input = gets.strip\n index = input_to_index(user_input)\n if valid_move?(board, index)\n move(board, index, character = current_player(board))\n display_board(board)\n else\n turn(board)\n end\nend",
"def turn(board)\n puts \"Please enter 1-9:\"\n position = gets.strip\n index = input_to_index(position)\n if valid_move?(board, index)\n current_player = current_player(board)\n move(board, index, current_player)\n display_board(board)\n else\n turn(board)\n end\nend",
"def move(board, input_to_index, character = \"X\")\n board[input_to_index] = character\nend",
"def turn\n puts \"Please enter 1-9:\"\n user_input = gets.strip\n index = input_to_index(user_input)\n if valid_move?(index) == true\n move(index, current_player)\n else\n turn\n end\n display_board\n end",
"def o_board_change (num)\n def space_check (space,board_state)\n if board_state.include?(space)\n return true\n else\n puts \"You've entered an invalid space option.\"\n $i -= 1\n return false\n end\n end\n \n puts \" #{num[0]} | #{num[1]} | #{num[2]}\\n-----------\\n #{num[3]} | #{num[4]} | #{num[5]}\\n-----------\\n #{num[6]} | #{num[7]} | #{num[8]}\"\n \n puts \"Player one, please choose a location for your O.\"\n \n o = gets.chomp\n o_int = o.to_i\n \n if space_check(o_int,num) == true\n space_index = num.index(o_int)\n num[space_index] = \"O\"\n $j = 0\n end\n return num\n end",
"def turn()\n puts \"Please enter 1-9:\"\n input = gets.strip\n intger=input.to_i\n #position = intger.to_i -1\n if valid_move?(input)\n move( intger,current_player())\n display_board()\n else\n turn()\n end\nend",
"def position(input)\n @cells[input.to_i - 1]\n end",
"def turn(board)\n puts \"Please enter 1-9:\"\n user_input = gets.strip\n index = input_to_index(user_input)\nif valid_move?(board,index)\n move(board, index, current_player(board))\n display_board(board)\nelse\n turn(board)\nend\nend",
"def move(position,player_letter = \"X\")\r\n #input logic here\r\n @board[position] = player_letter\r\n end",
"def turn(board)\n puts \"Please enter 1-9:\"\n input = gets.strip\n index = input_to_index(input)\n if valid_move?(board, index)\n move(board, index)\n display_board(board)\n else\n turn(board)\n end\nend",
"def turn(board)\n puts \"Please enter 1-9:\"\n input = gets.strip\n index = input_to_index(input)\n if valid_move?(board, index)\n move(board, index)\n display_board(board)\n else\n turn(board)\n end\nend",
"def convert_input_into_location(input)\n\t\tx = input[0]\n\t\tcase x\n\t\twhen 'a'\n\t\t\tx = 1\n\t\twhen 'b'\n\t\t\tx = 2\n\t\twhen 'c'\n\t\t\tx = 3\n\t\twhen 'd'\n\t\t\tx = 4\n\t\twhen 'e'\n\t\t\tx = 5\n\t\twhen 'f'\n\t\t\tx = 6\n\t\twhen 'g'\n\t\t\tx = 7\n\t\twhen 'h'\n\t\t\tx = 8\n\t\telse\n\t\t\treturn false\n\t\tend\n\t\ty = input[1]\n\t\tcase y\n\t\twhen '1'\n\t\t\ty = 8\n\t\twhen '2'\n\t\t\ty = 7\n\t\twhen '3'\n\t\t\ty = 6\n\t\twhen '4'\n\t\t\ty = 5\n\t\twhen '5'\n\t\t\ty = 4\n\t\twhen '6'\n\t\t\ty = 3\n\t\twhen '7'\n\t\t\ty = 2\n\t\twhen '8'\n\t\t\ty = 1\n\t\telse\n\t\t\treturn false\n\t\tend\n\t\t[x,y]\n\tend",
"def pos_to_index(position)\n position[1] * 8 + position[0]\n end"
] | [
"0.7440147",
"0.70697844",
"0.68589056",
"0.6848182",
"0.6550733",
"0.64466286",
"0.63977313",
"0.6328134",
"0.63238525",
"0.6311314",
"0.6238591",
"0.6218867",
"0.621603",
"0.61983496",
"0.6166908",
"0.61593604",
"0.61370987",
"0.6128387",
"0.61195743",
"0.6094401",
"0.6013159",
"0.59992254",
"0.59969795",
"0.5996674",
"0.5985714",
"0.5946699",
"0.59460276",
"0.59428644",
"0.5919711",
"0.589646",
"0.5891018",
"0.58894867",
"0.5882128",
"0.5882128",
"0.5880769",
"0.5880446",
"0.58777887",
"0.5868046",
"0.5859309",
"0.5857332",
"0.58571756",
"0.5856038",
"0.5853936",
"0.5853405",
"0.58510065",
"0.58505297",
"0.58485246",
"0.5847794",
"0.58451086",
"0.5811302",
"0.5800867",
"0.5798751",
"0.57872117",
"0.57858557",
"0.5784947",
"0.5783186",
"0.57814044",
"0.5780882",
"0.57715",
"0.57685125",
"0.57590884",
"0.5758063",
"0.57381356",
"0.57365835",
"0.5728229",
"0.5727816",
"0.57274693",
"0.57255656",
"0.5724191",
"0.572067",
"0.57198256",
"0.5719496",
"0.5718877",
"0.57112867",
"0.5710254",
"0.570799",
"0.5705615",
"0.569027",
"0.5690225",
"0.56838876",
"0.5680605",
"0.5679849",
"0.5679384",
"0.5677675",
"0.56770086",
"0.56737894",
"0.5673046",
"0.5672339",
"0.5660271",
"0.5660215",
"0.56586933",
"0.56581527",
"0.5653642",
"0.5644445",
"0.5644125",
"0.56424296",
"0.5641657",
"0.5641154",
"0.5641154",
"0.56406945",
"0.56384695"
] | 0.0 | -1 |
checks how many turns have been played | def turn_count(board)
turn_counter = 0
board.each do |spot|
if spot == "X" || spot.upcase == "O"
turn_counter +=1
end
end
return turn_counter
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def turn_count\n turns_played = 0\n @board.each do |index|\n if index != \" \"\n turns_played += 1\n end\n end\n return turns_played\n end",
"def number_correct\n turns.count do |each_turn|\n each_turn.correct?\n end\n end",
"def turn_count\r\n turns_so_far = 0\r\n @board.each do |arr_item|\r\n if arr_item == \"X\" || arr_item ==\"O\"\r\n turns_so_far += 1\r\n end\r\n end\r\n return turns_so_far\r\n end",
"def turn_count(board)\n turn_counter = 0\n (board.length).times do |i|\n if position_taken?(board, i)\n turn_counter += 1\n end\n end\n\n return turn_counter\nend",
"def game_tied?\n if @number_of_turns == 9\n true\n else\n false\n end\n end",
"def turn_count\n @board.count{|position| position != \" \"}\n end",
"def turn_count()\n count = 0\n index = 0\n loop do\n if position_taken?(index)\n count += 1\n end\n index += 1\n if index > 9 \n break\n end\n end\n return count\n end",
"def turn_count\n turns = 0\n @board.each do |spot|\n if spot==\"X\" || spot==\"O\"\n turns += 1\n end\n end\n return turns\n end",
"def full?\n turn_count == 9\n end",
"def turn_count()\n turns = 0\n \n @board.each do |position|\n if position.eql?(\"X\") || position.eql?(\"O\")\n turns += 1\n end\n end\n \n return turns\n end",
"def turn_count\n num_turns = 0\n @board.each do |space|\n if space == \"X\" || space == \"O\"\n num_turns += 1\n end\n end\n return num_turns\n end",
"def turn_count\n turns = 0\n @board.each do |position|\n if position == \"X\" || position == \"O\"\n turns += 1\n end\n end\n return turns\n end",
"def turn_count\n @board.count{|i| i != \" \"}\n end",
"def check_win\n\t\t\tif win\n\t\t\t\tputs \"\\n You win!\" \n\t\t\telse\n\t\t\t\t# shows how many turns remain\n\t\t\t\tputs \"\\n You have #{TURNS - @turns} turns left\"\n\t\t\tend\n\t\tend",
"def number_correct\n @turns.count do |turn|\n turn.correct?\n end\n end",
"def turn_count\n turn = @board.reject {|position| position == \" \"}\n turn.size\n end",
"def turn_count\n counter = 0\n @board.each do |index_taken|\n if index_taken == \"X\" || index_taken == \"O\"\n counter += 1\n end\n end\n counter\n end",
"def player_turn\n # if the board has more x's then it is the computer's turn\n if @board.count(@symbol) > @board.count(@computer_symbol)\n computer_turn\n else\n users_turn\n end\n end",
"def turn_count\r\n turn_count = 0\r\n @board.each do |space|\r\n if space != \" \"\r\n turn_count += 1\r\n end\r\n end\r\n turn_count\r\n end",
"def number_of_turns_taken(board)\r\n counter = 0\r\n board.each do |token|\r\n if token == \"X\" || token ==\"O\"\r\n counter +=1\r\n end\r\n end\r\n counter\r\nend",
"def initial_turn?(turn)\n max_turn = @players_count\n turn <= max_turn\n end",
"def turn_count\n count = 0\n @board.each do |player|\n if player == 'X' || player == 'O'\n count += 1\n end\n end\n return count\n end",
"def turn_count(board)\n count = 0\n\n board.each_with_index do |location, index|\n if position_taken?(board, index)\n count = count + 1\n end\n end\n\n count\nend",
"def turn_count(board)\n count = 0;\n board.each do |square|\n if square == \"X\" || square == \"O\"\n count +=1\n end\n end\n return count #return number of turns that have been played\nend",
"def turn_count \n count = 0\n @board.each do |board_item|\n if board_item != \" \"\n count += 1\n end\n end\n count\n end",
"def regular_turn?(turn)\n min_turn = @players_count * 2 + 1\n turn >= min_turn\n end",
"def turn_count\n turns = @board.count { |i| i == 'X' || i == 'O' }\n turns\nend",
"def turn_count(board)\n\n\toccupied_spaces = 0\n\n\tcounter = 0\n\twhile counter < board.size\n\t if position_taken?(board, counter)\n\t\t occupied_spaces += 1\t\t \nend \ncounter += 1\nend\noccupied_spaces\nend",
"def turn_count\n turns = 0\n @board.each do |position| #can use .count here: board.count{|token| token == \"X\" || token == \"O\"}\n if position == \"X\" || position == \"O\"\n turns += 1\n end\n end\n turns\n end",
"def turn_count\n count = 0\n @board.each do |space|\n if space == \"X\" || space == \"O\"\n count +=1\n end\n end\n count\n end",
"def turn_count\n x_turns = @board.count(\"X\")\n o_turns = @board.count(\"O\")\n turn_count = x_turns + o_turns\n return turn_count\nend",
"def turn_count\n counter = 0\n @board.each do |space|\n if space == \"X\" || space == \"O\"\n counter += 1\n end\n end\n counter\n end",
"def turn_count\n counter = 0\n @board.each do |position|\n\n if position == \"X\" || position == \"O\"\n counter += 1\n end\n\n end\n counter\n end",
"def turn_count(board)\n spaces_taken = 0\n board.each do |board_space|\n if board_space == \"X\" || board_space == \"O\"\n spaces_taken += 1 \n end\n end\n return spaces_taken\nend",
"def turn_count\n @board.count{|token| token == \"X\" || token == \"O\"}\n end",
"def turn_count #counts occupied positions!\n turn = 0 #start at position 0.\n @board.each do |index| #iterating through each spot on the board. Is it occupied?\n if index == \"X\" || index == \"O\" #if there is an X or O in that spot,\n turn += 1 #then you must turn!\n end\n end\n return turn #if there is not an X or O in that spot, take your turn and put your X or O there.\nend",
"def number_correct\n count_of_correct_turns = 0\n\n @turns.each do |turn|\n if turn.correct? == true\n count_of_correct_turns += 1\n end\n end\n count_of_correct_turns\n end",
"def turn_count\n @board.count{|token| token == \"X\" || token == \"O\"} # << tweaked\n end",
"def turn_count\n @board.count{|value| (value==\"X\" || value==\"O\")}\n #counter = 0\n #@board.each do |value|\n # if value ==\"X\" || value == \"O\"\n # counter+=1\n # end\n #end\n #counter\n end",
"def turn_count\n @board.count{|token| token == \"X\" || token == \"O\"}\n end",
"def turn_count()\n current_turn = 0\n @board.each do |space|\n if space != \" \"\n current_turn += 1\n end\n end\n return current_turn\n end",
"def turn_count\n\t\[email protected]{|token| token == \"X\" || token == \"O\"}\n\tend",
"def turn_count(board)\n counter = 0\n board.each do | move |\n if move == \"X\" || move == \"O\"\n puts counter += 1\n end\n end\n counter #This should be the number of turns\nend",
"def turn_count\n counter = 0\n @board.each do |positions|\n if positions == \"X\" || positions == \"O\"\n counter += 1\n end\n end\n counter.to_i\n end",
"def check_phase\n if @turn == Turn_Player\n if $game_system.acted.size >= (friends_of(Battler_Actor).select {|mem| !mem.death_state?}).size\n @phase_count += 1\n if @active_battler == nil\n $game_system.acted.clear\n set_turn( Turn_Enemy)\n next_enemy\n end\n end\n elsif @turn == Turn_Enemy\n if $game_system.acted.size >= (friends_of(Battler_Enemy).select {|mem| !mem.death_state?}).size\n @phase_count += 1\n if @active_battler == nil\n $game_system.acted.clear\n set_turn( Turn_Player)\n @cursor.moveto( tactics_actors.first)\n end\n end\n end\n end",
"def game_started?\n [email protected]? # count_tiles(WALL) >= 45 + 23 + 23\n end",
"def game_over\n remaining_player.count == 1\n end",
"def turn_count(board)\n play_count = 0\n board.each do |play|\n if play == \"X\" || play == \"O\"\n play_count += 1\n end\n end\n play_count\nend",
"def turn_count(board)\r\n #returns the number of of turns that have been played\r\n counter = 0\r\n board.each do|element|\r\n if (element == \"X\") || (element == \"O\")\r\n counter += 1 \r\n end\r\n end\r\n return counter\r\nend",
"def turn_count(board)\n turns = 0\n board.each do |spot|\n if spot==\"X\" || spot==\"O\"\n turns += 1\n end\n end\n return turns\nend",
"def finished?\n @turns_allowed < 0\n end",
"def num_games win_condition\n total_games = 0\n @game_objects.each do |game|\n total_games += 1 if game_meets_win_cond?(win_condition, game)\n end \n total_games\n end",
"def turn_count\n count = 0\n @board.each do |token|\n if token.downcase == \"x\" || token.downcase == \"o\"\n count += 1\n end\n end\n count\nend",
"def turn_count\n counter = 0\n @board.each do|position|\n if position == \"X\" || position == \"O\"\n counter += 1 \n end\n end\n return counter\nend",
"def won_set\n if @opponent.games_won == 6 && @games_won == 7\n @games_won = 0\n @sets_won += 1\n elsif @games_won > 4 && @games_won > @opponent.games_won + 1\n @games_won = 0\n @sets_won += 1\n end\n\n @matches_won += 1 if won_match?\n end",
"def set_won?\n if @games_won == 6 && @opponent.games_won < 5\n @sets_won += 1\n @games_won = 0\n @opponent.games_won = 0\n end\n if @games_won == 7 && @opponent.games_won < 7\n @sets_won += 1\n @games_won = 0\n @opponent.games_won = 0\n end\n end",
"def finished?\n symbols_count = PLAYER_SYMBOLS.map{|s| board_state.count(s)}.inject(&:+)\n symbols_count == 9 || !winner.nil?\n end",
"def games_played\n self.results.to_a.count\n end",
"def player_win?(n)\n self.wins.each do |win| \n return true if (player_moves(\"#{n}\") & win).count == self.win_length\n end\n return false\n end",
"def turn_count\n counter = 0\n @board.each do|element|\n\tif (element == \"X\") || (element == \"O\")\n \tcounter += 1\n\tend\n end\n return counter\nend",
"def remaining_guesses()\n if $turns > 1\n puts \"You have #{$turns} incorrect guesses left!\"\n elsif $turns == 1\n puts \"You have 1 incorrect guess left!\"\n else\n puts \"GAME OVER\"\n end\n end",
"def turn_count(board)\n num_of_turns = 0\n board.each do |spot|\n if (spot == 'X' || spot == 'O')\n num_of_turns += 1\n end\n end\n num_of_turns\nend",
"def turn_count(board)\n turns = 0\n board.each do | space |\n if space == \"X\" || space == \"O\"\n turns += 1\n end\n end\n return turns\nend",
"def turns(count)\n puts count\nend",
"def games_played\n games.size\n end",
"def games_played\n games.size\n end",
"def play_game\n turns = 0\n begin\n hash = WarAPI.play_turn(@player1, @player1.hand.deal_card, @player2, @player2.hand.deal_card)\n cards = hash.flatten\n @player1.hand.add_card(cards[1])\n @player2.hand.add_card(cards[3])\n puts \"#{turns}\"\n turns += 1\n end until (@player1.hand.addhand.length == 0 && @player1.hand.unshuffled_deck[-1] == nil && cards[1].length == 0) || (@player2.hand.addhand.length == 0 && @player2.hand.unshuffled_deck[-1] == nil && cards[3].length == 0)\n puts \"#{@player1.name} wins!\" if @player1.hand.deal_card != nil\n puts \"#{@player2.name} wins!\" if @player2.hand.deal_card != nil\n end",
"def turn_count(board)\n count = 0\n board.each do |occupied|\n if occupied == \"X\" || occupied == \"O\"\n #if count is =< to 9\n count = count + 1\n end\n end\n return count\nend",
"def turn_count(board)\n counter = 0;\n board.each do |slot|\n if(slot == \"X\" || slot == \"O\")\n counter += 1;\n end\n end\n return counter;\nend",
"def check_if_lost\n\t\tif @guess_count == @number_guess + 1\n\t\t\t@game_over = 2\n\t\tend\n\t\t@game_over\n\tend",
"def turn_count(board)\n #this counter keeps track of how many occupied spcaes there are\n counter = 0\n board.each do |turn|\n if turn == \"X\" || turn == \"O\"\n counter += 1\n end\n end\nreturn counter\nend",
"def match_won?\n if @sets_won == 3\n @match_won = 1\n @sets_won = 0\n @opponent.sets_won = 0\n end\n if @opponent.sets_won == 3\n @match_won = 1\n @sets_won = 0\n @opponent.sets_won = 0\n end\n end",
"def next_turn\n @turns += 1\n end",
"def turn_count(board)\n counter = 0\n board.each do |box|\n if box == \"X\" || box == \"O\"\n counter += 1\nend\nend\n return counter\nend",
"def did_player_win\n (@purses[@current_player] != 6)\n end",
"def check_win\n if @game_board.return_count == 5 and @timer.return_time >= 0\n @win = true\n end\n if @game_board.return_count < 5 and @timer.return_time == 0\n @lose = true\n end\n end",
"def turn_count(board)\n counter = 0\n turns = 0\n board.each do |idx|\n if idx != \" \" && idx != \"\"\n turns += 1\n end\n counter += 1\n end\n return turns\nend",
"def out_of_turns?\n result = !@data[@data.length-1][:key].nil?\n puts \"Out of turns!\" if result\n @out_of_turns = result\n result\n end",
"def turn_count(board)\n count_moves = 0 \n board.each do |check|\n if (check == \"X\" || check == \"O\")\n count_moves += 1 \n end\n end\n return count_moves\nend",
"def who_win?\n count_turn = 0\n\n while count_turn <= 0 \n \n if @A1.content == \"O\" && @A2.content == \"O\" && @A3.content == \"O\" && @A1.content == \"X\" && @A2.content == \"X\" && @A3.content == \"X\"\n @winning_game = true \n end\n\n if @B1.content == \"O\" && @B2.content == \"O\" && @B3.content == \"O\" && @B1.content == \"X\" && @B2.content == \"X\" && @B3.content == \"X\"\n @winning_game = true \n end\n\n if @C1.content == \"O\" && @C2.content == \"O\" && @C3.content == \"O\" && @C1.content == \"X\" && @C2.content == \"X\" && @C3.content == \"X\"\n @winning_game = true \n end\n\n if @A1.content == \"O\" && @B1.content == \"O\" && @C1.content == \"O\" && @A1.content == \"X\" && @B1.content == \"X\" && @C1.content == \"X\"\n @winning_game = true \n end\n\n if @A2.content == \"O\" && @B2.content == \"O\" && @C2.content == \"O\" && @A2.content == \"X\" && @B2.content == \"X\" && @C2.content == \"X\"\n @winning_game = true \n end\n\n if @A3.content == \"O\" && @B3.content == \"O\" && @C3.content == \"O\" && @A3.content == \"X\" && @B3.content == \"X\" && @C3.content == \"X\"\n @winning_game = true \n end\n\n if @A1.content == \"O\" && @B2.content == \"O\" && @C3.content == \"O\" && @A1.content == \"X\" && @B2.content == \"X\" && @C3.content == \"X\"\n @winning_game = true \n end\n\n if @A3.content == \"O\" && @B2.content == \"O\" && @C1.content == \"O\" && @A3.content == \"X\" && @B2.content == \"X\" && @C1.content == \"X\"\n @winning_game = true \n end\n\n count_turn += 1\n end\n\n if count_turn == 9 \n equality_game = true\n end\n end",
"def turn_count(board)\n turn_count = 0\n \n board.each do |counter|\n if counter == \"X\" || counter == \"O\"\n turn_count += 1\n end\n end\n \n turn_count\n end",
"def game_over?\n remaining_players == 1\n end",
"def won_match?\n @sets_won == 3\n end",
"def turn_count(board)\n counter = 0\n board.each do |turns|\n if turns == \"X\" || turns == \"O\"\n counter += 1\n end\n end\n counter\nend",
"def turn_count(board)\n count = 0\n board.each { |element|\n element == \"X\" || element == \"O\" ? count += 1 : false\n }\n count\nend",
"def turn_count(board)\n turn_counter = 0\n board.each do |turn|\n if turn == \"X\" || turn == \"O\"\n turn_counter += 1\n end\n end\n turn_counter\nend",
"def won_game?\n @points > @opponent.points + 1 && @points >= 3\n end",
"def turn_count\n\t\tcells.count {|cell| cell == \"X\" || cell == \"O\"}\t\n\tend",
"def team_player_count\n\t\tif team.players.size >= 5\n\t\t\terrors.add(:team, \"error, team already has 5 players\")\n\t\tend\n\tend",
"def turn_count(board)\n counter = 0\n board.each do |count_turn|\n if count_turn == \"X\" || count_turn == \"O\"\n counter += 1\n end\n end\n counter\nend",
"def turn_count(board)\n count = 0\n board.each do |entry|\n if (entry == \"X\" || entry == \"O\")\n count += 1\n end\n end\n count\nend",
"def turn_count(board)\ncurrent_turn = 0\nboard.each do |space|\n if space != \" \"\n current_turn += 1\n end\nend\nreturn current_turn\nend",
"def turn_count(board)\n count=0\n board.each do |position|\n if(position==\"X\"||position==\"O\")\n count+=1\n end\n end\n return count\nend",
"def game_over?\n if $board.has_value?(\"none\") == false then\n puts \"No more turns available\"\n return true\n else\n return false\n end\n end",
"def wins()\n\t\tself.as_regular_contestants.select{|c| c.win()}.size()\n\tend",
"def games_played\n @games_played = @games_played += 1\n end",
"def check_winner\n count = 0\n index = -1\n 0.upto(3) {|i|\n if @playing[i] \n if @score[i] == 0 and @started[i]\n @playing[i] = false\n @players.delete_if { |p| p.id == i} \n else\n count += 1\n index = i\n end\n end \n }\n @winner = index if count < 2 \n return count < 2 ? index : -1\n end",
"def turn_count(board)\n counter = 0 #counter is set to 0 before the for each loop interation begins\n board.each do |turn_count| # the variable turn_count can be called anything, this is a new local variable\n #puts \"Loop number #{counter} gets tuuurn: #{turn_count}\"\n if (turn_count == \"X\") || (turn_count == \"O\") # this if statement is within the loop iteration\n #puts \"Loop number #{counter} gets turn: #{turn_count}\"\n #puts turn_count # i'm outputing the turn_count to see it, but the 'return counter' below is what passes the test\n counter += 1 #adding 1 to the counter for each \"X\" and \"O\" in the board array\n end #end if statement\n end #end for...each loop iteration\n return counter # the counter holds the number of turns, and is what passes the test\nend",
"def turn_count(board)\n count = 0\n board.each do |value|\n if value ==\"X\" || value == \"O\"\n count +=1\n end\n end\n return count\nend",
"def turn_count(board)\n turns = 0\n board.each do |x|\n if x != \" \"\n turns+=1\n end\n end\n turns\nend",
"def turn_count(board)\n count = 0\n board.each do |space|\n if (space == 'X' || space == 'O')\n count += 1\n end\n end\n return count\nend"
] | [
"0.7793495",
"0.7577511",
"0.7561987",
"0.754469",
"0.7528732",
"0.7509197",
"0.74699503",
"0.74318963",
"0.7415337",
"0.7413886",
"0.7375327",
"0.73628116",
"0.7354928",
"0.7340143",
"0.73315424",
"0.7300869",
"0.7284414",
"0.7263449",
"0.7253604",
"0.7239764",
"0.7224517",
"0.721717",
"0.7198272",
"0.71944374",
"0.7184976",
"0.71739084",
"0.7155976",
"0.715109",
"0.71029544",
"0.7095492",
"0.70697874",
"0.7049651",
"0.70491415",
"0.70386046",
"0.7034424",
"0.70247823",
"0.7020647",
"0.70170224",
"0.69990206",
"0.6993802",
"0.69913596",
"0.6986503",
"0.6983554",
"0.6980902",
"0.69496644",
"0.69443464",
"0.69392747",
"0.69338214",
"0.6927284",
"0.69247293",
"0.6921377",
"0.6915129",
"0.6901589",
"0.6900838",
"0.6900064",
"0.68958515",
"0.6877329",
"0.6864564",
"0.68381476",
"0.683775",
"0.6833315",
"0.68277335",
"0.6813647",
"0.68097687",
"0.68061703",
"0.68061703",
"0.6805495",
"0.67982095",
"0.6785655",
"0.6779785",
"0.6770805",
"0.6750626",
"0.6747989",
"0.674301",
"0.67313373",
"0.6719864",
"0.6710083",
"0.67038995",
"0.67014337",
"0.6699771",
"0.668709",
"0.6686975",
"0.66753393",
"0.6671748",
"0.6659429",
"0.6640196",
"0.663376",
"0.6630866",
"0.6628321",
"0.66226876",
"0.66212445",
"0.6617635",
"0.66153693",
"0.66113335",
"0.6604941",
"0.660411",
"0.6603362",
"0.65993387",
"0.6591158",
"0.6584953",
"0.65836114"
] | 0.0 | -1 |
tells us who the current player is, X or O | def current_player(board)
if turn_count(board) % 2 == 0
return "X"
else
return "O"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_player\n\t\tturn_count % 2 == 0 ? \"X\" : \"O\"\n\tend",
"def current_player\n turn_count % 2 == 0 ? \"X\" : \"O\"\n end",
"def current_player\n return turn_count%2==0 ? \"X\" : \"O\"\n end",
"def current_player\r\n if turn_count % 2 != 0\r\n return \"O\"\r\n else\r\n return \"X\"\r\n end\r\n end",
"def current_player\n turn_count%2==0 ? \"X\" : \"O\"\n end",
"def current_player()\n # Assume player X goes first\n return turn_count() % 2 == 0 ? \"X\" : \"O\"\n end",
"def current_player\n if turn_count % 2 == 0\n return \"X\"\n else\n return \"O\"\n end\n end",
"def current_player\n turn = turn_count\n if turn%2 == 0\n return \"X\"\n else\n return 'O'\n end\n end",
"def current_player\n turn_count % 2 == 0 ? \"X\" : \"O\"\n end",
"def current_player\n turn_count % 2 == 0 ? \"X\" : \"O\"\n end",
"def current_player\n player = nil\n if turn_count() % 2 == 0\n player = 'X'\n else\n player = 'O'\n end\n return player\n end",
"def current_player()\n current_turn = turn_count()\n if current_turn == 0 || current_turn % 2 == 0\n return \"X\"\n else\n return \"O\"\n end\n end",
"def current_player\n turn_count % 2 == 0 ? \"X\" : \"O\" # << tweaked\n end",
"def current_player\r\n if self.turn_count == 0\r\n return \"X\"\r\n elsif self.turn_count.odd?\r\n return \"O\"\r\n else\r\n return \"X\"\r\n end\r\n end",
"def current_player\n x_moves = @board.select {|position| position == \"X\"}\n o_moves = @board.select {|position| position == \"O\"}\n\n if x_moves.size == o_moves.size\n character = \"X\"\n else\n character = \"O\"\n end\n end",
"def switch_current_player\n\t\tif @playerx\n\t\t\t@playerx = false\n\t\t\t@current_player.set_text(\"Player: O\")\n\t\telse\n\t\t\t@playerx = true\n\t\t\t@current_player.set_text(\"Player: X\")\n\t\tend\t\t\n\tend",
"def current_player \n turn_count % 2 == 0 ? \"X\" : \"O\"\n end",
"def current_player\n turn_count == 0 || turn_count % 2 == 0 ? \"X\" : \"O\"\n end",
"def switch_player\n @current_player = (@current_player == 'x' ? 'o' : 'x')\n end",
"def current_player\r\n turn_count\r\n if turn_count % 2 == 0\r\n return \"X\"\r\n else\r\n return \"O\"\r\n end\r\n end",
"def opposing_player(cur_player)\n cur_player == \"X\"? \"O\" : \"X\"\n end",
"def current_player\n turns_played = turn_count()\n if turns_played % 2 == 0\n return \"X\"\n else\n return \"O\"\n end\n end",
"def current_player\n turn_count.even? ? \"X\" : \"O\"\n end",
"def current_player\n turn_count.even? ? \"X\" : \"O\"\n end",
"def winner\n if current_player.marker == \"X\"\n return \"O\"\n else\n return \"X\"\n end\n end",
"def current_player\n return turn_count.even? ? \"X\" : \"O\"\n end",
"def switch_player\n @letter == :X ? 'O' : 'X'\n end",
"def current_player\n x_count = self.board.cells.count {|token| token == \"X\"}\n o_count = self.board.cells.count {|token| token == \"O\"}\n if (x_count + o_count).even?\n player_1\n elsif (x_count + o_count).odd?\n player_2\n end\n end",
"def current_player\n (turn_count % 2 == 0)? \"X\" : \"O\"\nend",
"def current_player\n turn_count.even? ? \"X\" : \"O\"\n end",
"def current_player\n turn_count.even? ? \"X\" : \"O\"\n end",
"def current_player\n turn_count.even? ? \"X\" : \"O\"\n end",
"def current_player\n if (turn_count % 2) == 0\n player = \"X\"\n elsif (turn_count % 2) != 0\n player = \"O\"\n end\nend",
"def current_player\n\n @number = turn_count\n\n if (@number % 2 == 0)\n return \"X\"\n else\n return \"O\"\n end\n\n end",
"def current_player\n turn_count.even? ? \"X\" : \"O\"\n\n end",
"def current_player\n if turn_count % 2 == 0\n \"X\"\n else\n \"O\"\n end\nend",
"def current_player\n if turn_count % 2 == 0\n \"X\"\n else\n \"O\"\n end\nend",
"def winner\r\n if self.won? != false\r\n if self.current_player == \"X\"\r\n return \"O\"\r\n else\r\n return \"X\"\r\n end\r\n end\r\n end",
"def switch_player!\n return @player = 'X' unless @player == 'X'\n @player = 'O'\n end",
"def current_player\n if turn_count % 2 == 0\n return \"X\"\n else\n return \"O\"\n end\nend",
"def current_player(board)\n counter_turn = turn_count(board)\n if counter_turn % 2 == 0\n \"X\"\n else\n \"O\"\n end\n end",
"def current_player\n turn_count.even? ? \"X\" : \"O\"\n end",
"def current_player\n\tif $turn == 0\n\t\tplayerone\n\telse\n\t\tplayertwo\n\tend\nend",
"def current_player(board)\n turn_count(board) % 2 == 0 ? \"X\" : \"O\"\n end",
"def get_next_turn\n\n # Using an X?\n if @current_player == 'X'\n\n # Yes, change to O\n @current_player = 'O'\n\n else\n\n # No, change to X\n @current_player = 'X'\n\n end\n\n return @current_player\n\n end",
"def current_player(board)\n if turn_count(board) == 0\n return \"X\"\n elsif\n turn_count(board) % 2 == 0 \n return \"X\"\n else\n return \"O\"\n end \n end",
"def current_player(board)\n if turn_count(board) == 0\n return \"X\"\n elsif\n turn_count(board) % 2 == 0 \n return \"X\"\n else\n return \"O\"\n end \n end",
"def choose_symbol_for_player\n if @@players.count == 0\n return \"X\"\n else\n return \"O\"\n end\n end",
"def current_player(board)\n #is turn count divisible by 2 then return X, if not, return O. \n turn_count(@board) % 2 == 0? \"X\" : \"O\"\n end",
"def current_player(board)\n\t\tif board.turn_count.odd?\n\t\t\t\"O\" # If the number of turns is an odd number it is Player two with the \"O\" token\n\t\telse\n\t\t\t\"X\" # If the number of turns is an even number it is Player one with the \"X\" token\n\t\tend\n\tend",
"def get_player\n\t\tputs \"Will player 1 be X or O?\"\n\t\tplayer = gets.chomp\n\t\tputs \"\"\n\n\t\tif player == \"x\" || player == \"X\"\n\t\t\tputs \"Player 1: X\"\n\t\t\tputs \"Player 2: O\"\n\n\t\t\treturn \"X\", \"O\"\n\t\telsif player == \"o\" or player == \"O\"\n\t\t\tputs \"Player 1: O\"\n\t\t\tputs \"Player 2: X\"\n\n\t\t\treturn \"O\", \"X\"\n\t\telse\n\t\t\tputs \"Input not valid.\"\n\t\t\tputs\n\t\t\tputs \"Player 1: X\"\n\t\t\tputs \"Player 2: O\"\n\n\t\t\treturn \"X\", \"O\"\n\t\tend\n\tend",
"def current_player\n turn_count \n if turn_count%2 != 0 \n \"O\"\n else\n \"X\"\n end\nend",
"def turn(player)\n if player == 'X'\n print \"\\nPlayer X turn >> \"\n @x_move = gets.chomp\n elsif player == 'O'\n print \"\\nPlayer O turn >> \"\n @o_move = gets.chomp\n end\n end",
"def winner\n winning_conditions_met? == \"x\" ? \"#{@player_one} won!\" : \"#{@player_two} won!\"\n end",
"def current_player(board)\n turn_count(board).even? ? \"X\" : turn_count(board).odd? ? \"O\" : \"X\"\n end",
"def computer_choice\n if @player_choice == \"X\"\n @computer_choice = \"O\"\n puts \"Computer will play #{@computer_choice}\"\n else\n @computer_choice = \"X\"\n puts \"Computer will play #{@computer_choice}\"\n end\n end",
"def current_player(board)\n\tcount = turn_count(board)\n\tcount % 2 == 0 ? \"X\" : \"O\"\nend",
"def switch_player\nif @player == PIECE[:x]\n@player = PIECE[:o]\nelse\n@player = PIECE[:x]\nend\nend",
"def current_player(board)\r\n (turn_count(board) % 2 == 0)? \"X\" : \"O\"\r\nend",
"def current_player(board)\n turn = turn_count(board)\n if turn == 0\n return \"X\"\n elsif turn == 1\n return \"O\"\n elsif turn == 2\n return \"X\"\n end\nend",
"def player\n\t\t@current_player\n\tend",
"def current_player_switch()\n if @current_player == 0 \n @current_player = 1\n elsif @current_player == 1 \n @current_player = 0\n end\n end",
"def current_player(board)\n if (turn_count(board) % 2) == 0\n player = \"X\"\n elsif (turn_count(board) % 2) != 0\n player = \"O\"\n end\nend",
"def players\n puts \"Player 1, would you like to be X or O? \"\n player1 = gets.chomp\n # puts \"Great! Player 1 is #{player1}\"\n # player1 = \"X\"\n if player1 == \"X\"\n player2 = \"O\"\n else\n player2 = \"X\"\n end\n # puts \"Great! Player 1 is #{player1} and Player 2 is #{player2}\"\nend",
"def setplayer1\r\n\t\t\t@player1 = \"O\"\r\n\t\tend",
"def show\n #show the game grid\n #determine the current player symbol given the fact that first player will always get (X) symbol\n @current_player_symbol = @game.current_round.current_player == @game.first_player ? \"X\" : \"O\"\n end",
"def determine_turn\n @player = if @player1_turn\n puts \"It is #{@player1}'s turn\"\n \"X\"\n\n else\n puts \"It is #{@player2}'s turn\"\n \"O\"\n\n end\n\n end",
"def current_player(board)\n#player = \"X\"\nif (turn_count(board) % 2) == 0\n player = \"X\"\nelsif (turn_count(board) % 2) != 0\n player = \"O\"\nend\nend",
"def opponent\n @player == :human ? :computer : :human\n end",
"def current_player\n turn_count % 2 == 0 ? \"X\" : \"O\"\nend",
"def current_player(board)\n if turn_count(board)&1==0 || turn_count(board) == 0;\n return \"X\"\n else\n return \"O\"\n end\nend",
"def other_turn\n\t\t@turn == \"x\" ? \"o\" : \"x\"\n\tend",
"def current_player(board)\n if turn_count(board)%2 == 0\n current_player = \"X\"\n else\n current_player = \"O\"\n end\n return current_player\nend",
"def computer_symbol\n\t\tputs @player_symbol \n\t\tif(@player_symbol == :O)\n\t\t :X\n\t\telse\n\t\t :O\n\t\tend\n \tend",
"def current_player(board)\n player = \"\"\n if turn_count(board) % 2 == 0\n player= \"X\"\n else\n player = \"O\"\n end\n player\nend",
"def taken?( player_input )\n position( player_input ) =~ /[XO]/ ? true : false\n end",
"def current_player(board)\n turns=turn_count(board)\n if(turns%2==0)\n \"X\"\n else\n \"O\"\n end\nend",
"def setplayer2\r\n\t\t\t@player2 = \"X\"\r\n\t\tend",
"def current_player #removed (board) argument\n turn_count % 2 == 0 ? \"X\" : \"O\" \nend",
"def players\n puts \"Player 1, would you like to be X or O? \"\n $player1 = gets.chomp\n\n if $player1 == \"X\"\n $player2 = \"O\"\n else\n $player2 = \"X\"\n end\n\n puts \"Great! Player 1 is #{$player1} and Player 2 is #{$player2}\"\n puts \"\"\n \nend",
"def current_player\n @players.each do |name, letter|\n if letter == whose_turn\n return name\n end\n end\n end",
"def switch_player\n @current_player = if @current_player == @player_o\n @player_x\n else\n @player_o\n end\n\n @number_of_turns += 1\n end",
"def current_player(board)\n if turn_count(board) % 2 == 0\n \"X\"\n elsif turn_count(board) % 2 == 1\n \"O\"\n end\nend",
"def current_player(board)\n (turn_count(board) % 2 == 0) ? \"X\" : \"O\"\nend",
"def current_player(board)\n if turn_count(board) % 2 == 0\n character = \"X\"\n else\n character = \"O\"\n end\n return character\nend",
"def change_player \n if @current_player == 0\n @current_player = 1\n elsif @current_player == 1\n @current_player = 0\n end\n end",
"def opponent_token \n self.token == 'X' ? 'O' : 'X'\n end",
"def x_player_turn\n print \"Player X:\"\n @x_player_choice = gets.chomp\n #Make sure that the player inputs a correct input\n if check_coord_marked?(@x_player_choice)\n print \"Already marked please try again\\n\"\n self.x_player_turn\n elsif @coordinates.any?{|i| i==@x_player_choice}\n self.place_mark(@x_player_choice, \"x\")\n else\n print \"Not a valid Coordinate try again \\n\"\n self.x_player_turn\n end\n end",
"def current_player(board)\n if turn_count(board) % 2 == 0\n \"X\"\n else\n \"O\"\n end\nend",
"def current_player(board)\n current_turn = turn_count(board)\n if current_turn == 0 || current_turn % 2 == 0\n return \"X\"\n else\n return \"O\"\n end\nend",
"def current_player(board)\n return turn_count(board)%2==0 ? \"X\" : \"O\"\nend",
"def current_player(board)\nif turn_count(board) % 2 == 0\n \"X\"\nelsif turn_count(board) % 2 == 1\n \"O\"\n end\nend",
"def active_player\n @playing_player.active? ? @playing_player : opponent\n end",
"def declare_winner(board_model, pos)\n board_model[pos] == \"X\" ? \"Player 1 won\" : \"Player 2 won\"\nend",
"def current_player(board)\n if turn_count(board) % 2 == 0 \n \"X\"\n else\n \"O\"\n end\nend",
"def current_player(board)\n if (turn_count(board) % 2 == 0)\n return \"X\"\n elsif !(turn_count(board) % 2 == 0)\n return \"O\"\n end\nend",
"def symbol_for_player(player)\n case player\n when player1\n \"X\"\n when player2\n \"O\"\n else\n raise \"Oi, That's not one of my players\"\n end\n end",
"def current_player\n turn_count.even? ? \"X\" : \"O\"\nend",
"def current_player_move\n @on_move == HUMAN_PLAYER ? human.move : computer.move\n end",
"def current_player(board)\n current_player = turn_count(board) % 2 == 0 ? \"X\" : \"O\"\n\nend",
"def current_player(board)\n if turn_count(board).even?\n current_player = \"X\"\n else\n current_player = \"O\"\n end\nend"
] | [
"0.7785548",
"0.77685636",
"0.7745381",
"0.7736633",
"0.7711894",
"0.7707101",
"0.7688385",
"0.7650499",
"0.75848806",
"0.75848806",
"0.758063",
"0.75792843",
"0.75531393",
"0.7549586",
"0.75310326",
"0.7529044",
"0.75264955",
"0.7519843",
"0.7494961",
"0.7493004",
"0.74884707",
"0.74882174",
"0.7425346",
"0.7425346",
"0.7410824",
"0.7362581",
"0.7346821",
"0.7295117",
"0.7247941",
"0.7230482",
"0.7230482",
"0.7230482",
"0.72007614",
"0.71465826",
"0.71356016",
"0.7127097",
"0.7127097",
"0.70895934",
"0.7080511",
"0.7053135",
"0.7052227",
"0.70436317",
"0.7042953",
"0.69837546",
"0.6940605",
"0.6863914",
"0.6863914",
"0.6852464",
"0.68272966",
"0.6826395",
"0.681334",
"0.6812429",
"0.6811833",
"0.6782871",
"0.67757887",
"0.6772557",
"0.67616236",
"0.6761073",
"0.67470396",
"0.67449677",
"0.6723206",
"0.67184544",
"0.6685037",
"0.6671491",
"0.666967",
"0.66657966",
"0.6663999",
"0.66573364",
"0.664597",
"0.6645745",
"0.66400623",
"0.66372645",
"0.66305715",
"0.6629168",
"0.6625703",
"0.6582474",
"0.6577885",
"0.65655446",
"0.6558218",
"0.6558054",
"0.6548965",
"0.65392816",
"0.65361345",
"0.6531526",
"0.65292734",
"0.65268505",
"0.6519981",
"0.65145016",
"0.6512949",
"0.65090936",
"0.6497612",
"0.6486348",
"0.64861107",
"0.6478789",
"0.64783746",
"0.64737844",
"0.6467138",
"0.64638084",
"0.6458459",
"0.64581954",
"0.64538705"
] | 0.0 | -1 |
Define your play method below | def play(board)
9.times {turn(board)}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def play\n \n end",
"def play; end",
"def play \n end",
"def play\n end",
"def play\n end",
"def play\n end",
"def play\n end",
"def play\n end",
"def play\n\tend",
"def play\n #calls to all the methods that produce game!\n end",
"def play\n self\n end",
"def get_play() \n # \n end",
"def play\n puts 'Playing'\n end",
"def after_play\n\n end",
"def run \n Engine::play(Beginning)\nend",
"def play\n\t\tgame_loop\n\tend",
"def play()\n @ole.Play()\n end",
"def play()\n @ole.Play()\n end",
"def play\n #tho I am sure there is a better way to define a virtual method... just gonna throw something\n raise 'Method play cannot be called directly. It must be overridden in a child class first.'\n end",
"def play\n @hungry = true\n #p \"play method called\" #print notification to console\n end",
"def play\n\t\t\"playing #{title}\"\n\tend",
"def play socket\n end",
"def play\n \"We're rockiinnggg\"\n end",
"def play\n render layout: 'player'\n end",
"def play\r\n\t\t[FOLD]\r\n\tend",
"def startPlayback\n end",
"def play(&blk)\n start_playing\n blk.call\n ensure\n stop_playing\n end",
"def play\n greeting\n get_tiles\n move_sequence\n end",
"def play_sports\n end",
"def play\n puts \"buzz\"\n end",
"def play\n board_setup\n gameplay_setup\n end",
"def play(*args)\n sleep(duration)\n end",
"def process_ok\n Sound.play_ok\n super\n end",
"def playAction _obj, _args\n \"_obj playAction _args;\" \n end",
"def play\n\temulate do |emulator|\n\t\temulator.play(self)\n\tend\nend",
"def play_as_master_second\r\n \r\n end",
"def play\n @@plays += 1\n end",
"def play\n each do |playable|\n if playable.respond_to?(:play)\n playable.play\n end\n end\n end",
"def play\n take_turn until @master.game_over?\n @master.show_board\n @robot.speak\n end",
"def play\n synchronize do\n @starved = false\n @source.play\n end\n end",
"def play(cmd)\n play_game(cmd)\n end",
"def play\r\n return if self.finished?\r\n self.update\r\n end",
"def play\n\t\twelcome\n\t\task_name\n\t\task_name2 \n\t\task_input\n\t\tturns\n\tend",
"def play\r\n display_welcome_message\r\n init_players\r\n\r\n loop do\r\n play_match\r\n break unless play_again?\r\n end\r\n\r\n display_goodbye_message\r\n end",
"def buz; Sound.play_buzzer; end",
"def sound; end",
"def player; end",
"def player; end",
"def player; end",
"def player; end",
"def player; end",
"def player; end",
"def player; end",
"def beginGameLoop\n @gameLoop.play\n end",
"def play_game\n # WarAPI.play_turn()\n end",
"def play\n if (RUBY_PLATFORM == \"java\")\n java_play\n else\n ruby_play\n end\n end",
"def show_play_complete_player\n # nothing\n end",
"def play\n must_be_ready!\n stop if running?\n \n info \"PLAY: #{opts[:path]}\"\n worker.startup!\n end",
"def play()\n @files.shuffle.each do |file|\n play_file(file)\n end\n end",
"def on_play(track)\n end",
"def play\n wake\n puts \"You play fetch with #{@name}.\"\n time_passed\n end",
"def playActionNow _obj, _args\n \"_obj playActionNow _args;\" \n end",
"def set_player\n\n end",
"def play\n Audio::Out.add @cpg\n @is_playing = true\n #Audio::Out.add @actuator\n end",
"def play\n @play_mode = true\n session[:cards] = @tarot.cards.map(&:id).shuffle\n @tname = @tarot.name\n @tauthor = @tarot.author\n @draw_path = draw_one_tarot_cards_path(@tarot)\n @shuffle_path = play_tarot_cards_path(@tarot)\n # シャッフルでは画面リドローした方がいいので描画しなおす\n # respond_to do |format|\n # format.html\n # format.js\n # end\n end",
"def main_audio\r\n super\r\n # Stop BGM and BGS\r\n $game_system.bgm_play(nil)\r\n $game_system.bgs_play(nil)\r\n # Play game over ME\r\n $game_system.me_play($data_system.gameover_me)\r\n end",
"def perform\n\tgame_menu\n\tgameplay\nend",
"def playSound _args\n \"playSound _args;\" \n end",
"def play\n init_player()\n init_board()\n puts \"Test game play\"\n end",
"def play\n @game.start if @game.waiting_to_start?\n if @game.active?\n play_cards if params[:commit] # play submitted cards, if a form submit occurred\n @sets = @game.fill_gamefield_with_sets\n end\n if @game.finished?\n publish_if_finished_and_promoted\n redirect_to :action => 'archive'\n else\n render :action => 'play'\n end\n end",
"def change_player\n\n end",
"def play_action\n @status.playback_state = :playing\n update_status\n end",
"def play\n @sound += 1\n @sound %= @overlap\n `#{@sounds[@sound]}.play()`\n end",
"def play_title_music\r\n\r\n$data_system.title_bgm.play\r\n\r\nRPG::BGS.stop\r\n\r\nRPG::ME.stop\r\n\r\nend",
"def play(song)\n # artist = Artist.find_by(id: song.artist_id)\n puts \"Playing #{song}\"\n end",
"def show_play_complete_player\n\t\t# nothing\n\tend",
"def next_player!\n end",
"def run(player)\n puts \"Hello!\"\n end",
"def play!\n if @file\n fork do\n begin\n system \"play #{@file}\" # exec\n rescue\n \t puts \"error playing sound\"\n end\n end\n end\n end",
"def play\r\n display_welcome_message\r\n human_choose_move\r\n computer_choose_move\r\n display_winner\r\n display_goodbye_message\r\nend",
"def run\n @music.play(:repeats => -1)\n\thook_run()\n\thook_quit()\n\t# Handling input\n\tloop do\n\t @queue.each do |event|\n\t\thandle(event)\n end\n\t# Draw the image to screen\n\t@intro_screen.blit(@screen,[0,0])\n\[email protected]()\n end\n end",
"def call\n if context.dj.player.stopped?\n related = context.dj.add_related\n if related\n context.dj.switch!\n context.message = [ \"Autoplaying.. #{ related }\" ].join(\" \")\n else\n context.errors = \"Failed getting related video.\"\n context.fail!\n end\n else\n current_video = context.dj.current_video\n context.message = \"Skipping!\"\n next_title = context.dj.switch!\n if next_title\n context.message = [ context.message, \"Playing #{ next_title }\" ].join(\" \")\n else\n context.message = \"Nothing to play, add some songs to playlist.\"\n end\n end\n end",
"def playback file, &block\n application \"playback\", file, &block\n end",
"def play\n @hungry = true\n end",
"def play\n @hungry = true\n end",
"def play\n @hungry = true\n end",
"def play!\n @playlist.shift\n end",
"def show\n\n \t\t\trespond_with @play\n\n \t\tend",
"def main_audio ; end",
"def play\n @game = Game.find_by_id(@id)\n raise RecordNotFound, 'Not found' if @game.nil?\n\n @game.increment_access\n render 'play', formats: 'json', handlers: 'jbuilder'\n end",
"def play_sound \n system\"play #{@sound_file}\"\n end",
"def audio; end",
"def main_audio\r\n super\r\n # Play title BGM\r\n $game_system.bgm_play($data_system.title_bgm)\r\n # Stop playing ME and BGS\r\n Audio.me_stop\r\n Audio.bgs_stop\r\n end",
"def play\n return_value = yield self\n\n save_board!\n\n return_value\n end",
"def play\n # unless the game is over players take turns\n take_turn until game_over?\n\n #start a new game if the game is over\n new_game_or_quit\n end",
"def process_x\n if current_item_enabled?\n Sound.play_ok\n super\n else\n Sound.play_buzzer\n end\n end",
"def play_special player\n\t\t\tif @spec_action\n\t\t\t\t@spec_action.call player, self\n\t\t\tend\n\t\t\t\n\t\t\ttrue\n\t\tend",
"def play!\n update_attributes!(:status => :playing, :played_at => Time.now)\n self\n end",
"def playable_action\n raise NotImplementedError\n end",
"def playMove _obj, _args\n \"_obj playMove _args;\" \n end",
"def play\n puts \"#{name} got zoomies playing fetch!\"\n @hungry = true\n end"
] | [
"0.91277385",
"0.9031555",
"0.90065134",
"0.900332",
"0.900332",
"0.900332",
"0.900332",
"0.8978301",
"0.88647234",
"0.8184945",
"0.80578035",
"0.79240173",
"0.78456163",
"0.7765175",
"0.77345335",
"0.76989305",
"0.7611273",
"0.7611273",
"0.7528091",
"0.74453044",
"0.74384725",
"0.74071074",
"0.7361055",
"0.73219633",
"0.73183304",
"0.7305947",
"0.7276433",
"0.727489",
"0.72664",
"0.72488713",
"0.7223312",
"0.71886545",
"0.71801096",
"0.7177513",
"0.7167901",
"0.71595836",
"0.71479374",
"0.71467835",
"0.6938487",
"0.6910191",
"0.6897485",
"0.68842834",
"0.6873398",
"0.68341005",
"0.68210787",
"0.68046623",
"0.67788917",
"0.67788917",
"0.67788917",
"0.67788917",
"0.67788917",
"0.67788917",
"0.67788917",
"0.6764783",
"0.6757064",
"0.6756813",
"0.6755827",
"0.6750558",
"0.6749177",
"0.67485446",
"0.67396295",
"0.6733066",
"0.6730967",
"0.67230797",
"0.67202306",
"0.67108464",
"0.6694557",
"0.6693444",
"0.6684301",
"0.667619",
"0.6634668",
"0.66228515",
"0.662045",
"0.66192347",
"0.6612572",
"0.6606098",
"0.656401",
"0.656184",
"0.6534731",
"0.65318584",
"0.65292335",
"0.651808",
"0.65143067",
"0.6502987",
"0.6502987",
"0.6502987",
"0.6486641",
"0.647975",
"0.6467687",
"0.6443099",
"0.64334816",
"0.6428434",
"0.6426544",
"0.6416904",
"0.6416639",
"0.6411488",
"0.64010864",
"0.6396464",
"0.63943255",
"0.63736016",
"0.6371055"
] | 0.0 | -1 |
method to find out if the board contains any of the win combinations | def won?(board)
WIN_COMBINATIONS.each do |combo|
win_combination = [combo[0], combo[1], combo[2]]
windex1 = win_combination[0]
windex2 = win_combination[1]
windex3 = win_combination[2]
pos1 = board[windex1]
pos2 = board[windex2]
pos3 = board[windex3]
win_combo = [pos1,pos2,pos3]
if pos1 == "X" && pos2 == "X" && pos3 == "X" || pos1 =="O" && pos2 == "O" && pos3 == "O"
return win_combination
end
end
return false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def won?(board)\n res = false\n WIN_COMBINATIONS.each do |win_combination|\n board_entries = [board[win_combination[0]], board[win_combination[1]], board[win_combination[2]]]\n board_entries == [\"X\", \"X\", \"X\"] || board_entries == [\"O\", \"O\", \"O\"] ? res = win_combination : false\n end\n res\n\nend",
"def won?(board)\n WIN_COMBINATIONS.detect do |combination| #ex: [0,1,2]\n board[combination[0]] == board[combination[1]] &&\n board[combination[1]] == board[combination[2]] &&\n position_taken?(board, combination[0])\n end\nend",
"def won?(board)\n WIN_COMBINATIONS.detect do |combo|\n board[combo[0]] == board[combo[1]] &&\n board[combo[1]] == board[combo[2]] &&\n position_taken?(board, combo[0])\n end\nend",
"def won?(board)\n WIN_COMBINATIONS.detect do |combination|\n board[combination[0]] == board[combination[1]] &&\n board[combination[1]] == board[combination[2]] &&\n position_taken?(board, combination[0])\n end\nend",
"def won?(board)\n WIN_COMBINATIONS.detect do |win_combination|\n board[win_combination[0]] == board[win_combination[1]] &&\n board[win_combination[1]] == board[win_combination[2]] &&\n position_taken?(board, win_combination[0])\n end\nend",
"def won?(board)\n WIN_COMBINATIONS.detect do |win_combo|\n board[win_combo[0]] == board[win_combo[1]] &&\n board[win_combo[0]] == board[win_combo[2]] &&\n position_taken?(board, win_combo[0])\n end\nend",
"def won?(board)\n WIN_COMBINATIONS.detect do | combination |\n board[combination[0]] == board[combination[1]] &&\n board[combination[1]] == board[combination[2]] &&\n position_taken?(board,combination[0])\n end\nend",
"def won?\n if @board.all?{|position|position == \" \"}\n return false\n end\n no_combinations = true\n WIN_COMBINATIONS.each do |combination|\n if combination1 = @board[combination[0]] == \"X\" && @board[combination[1]] == \"X\" && @board[combination[2]] == \"X\" ||\n combination2 = @board[combination[0]] == \"O\" && @board[combination[1]] == \"O\" && @board[combination[2]] == \"O\"\n no_combinations = false\n return combination\n end\n end\n if no_combinations == true\n return false\n end\n end",
"def won?(board)\n WIN_COMBINATIONS.detect do |combo|\n board[combo[0]] == board[combo[1]] &&\n board[combo[1]] == board[combo[2]] &&\n position_taken?(board, combo[0])\n end\nend",
"def won?(board)\n WIN_COMBINATIONS.detect do |combo|\n board[combo[0]] == board[combo[1]] &&\n board[combo[1]] == board[combo[2]] &&\n position_taken?(board, combo[0])\n end\nend",
"def won?(board)\n WIN_COMBINATIONS.detect do |combo|\n board[combo[0]] == board[combo[1]] &&\n board[combo[1]] == board[combo[2]] &&\n position_taken?(board, combo[0])\n end\nend",
"def won?(board)\n WIN_COMBINATIONS.detect do |combo|\n board[combo[0]] == board[combo[1]] && board[combo[2]] == board[combo[1]] && position_taken?(board,combo[0])\n end\nend",
"def won?(board)\n WIN_COMBINATIONS.detect do |win_combination|\n\n # check each win combination for win\n win_X = win_combination.all? {|cell| board[cell] == \"X\"}\n win_O = win_combination.all? {|cell| board[cell] == \"O\"}\n\n if win_X or win_O\n return win_combination\n else\n false\n end\n end\nend",
"def won?(board)\n WIN_COMBINATIONS.detect do |win|\n board[win[0]] == board[win[1]] && board[win[0]] == board[win[2]] &&\n position_taken?(board, win[0])\n end\nend",
"def won?(board)\n WIN_COMBINATIONS.detect do |win|\n board[win[0]] == board[win[1]] && board[win[0]] == board[win[2]] &&\n position_taken?(board, win[0])\n end\nend",
"def won?(board)\n WIN_COMBINATIONS.each do |win|\n if [board[win[0]], board[win[1]], board[win[2]]] == [\"X\", \"X\", \"X\"] ||\n [board[win[0]], board[win[1]], board[win[2]]] == [\"O\", \"O\", \"O\"]\n return win\n end\n end\n return false\nend",
"def won?(board)\n WIN_COMBINATIONS.detect do |win_index|\n board[win_index[0]] == board[win_index[1]] && \n board[win_index[0]] == board[win_index[2]] &&\n position_taken?(board, win_index[0])\n end\nend",
"def won?(board)\n # !won?(board)\n WIN_COMBINATIONS.detect do |combo| # [0,1,2]\n if position_taken?(board, combo[0]) && board[combo[0]] == board[combo[1]] && board[combo[1]] == board[combo[2]]\n combo\n end\n end\nend",
"def won?\n WIN_COMBINATIONS.detect { |combo|\n @board.cells[combo[0]] == @board.cells[combo[1]] &&\n @board.cells[combo[0]] == @board.cells[combo[2]] &&\n @board.taken?(combo[0] + 1)\n }\n # x = \"X\";\n # o = \"O\";\n #\n # WIN_COMBINATIONS.each do |win_combination|\n # win_index_1 = win_combination[0];\n # win_index_2 = win_combination[1];\n # win_index_3 = win_combination[2];\n #\n # position_1 = @board.cells[win_index_1];\n # position_2 = @board.cells[win_index_2];\n # position_3 = @board.cells[win_index_3];\n #\n # if ((position_1 == x && position_2 == x && position_3 == x) ||\n # (position_1 == o && position_2 == o && position_3 == o))\n # return win_combination;\n # else\n # false;\n # end\n # end\n # false; #explicitly tell ruby to return false if we've cycled through the board and no win combinations can be found\n end",
"def won?(board)\n WIN_COMBINATIONS.detect do |win1|\n win1.all? { |number| board[number] == \"X\"} || win1.all? { |number| board[number] == \"O\"}\n end\n end",
"def won?(board)\n WIN_COMBINATIONS.detect do |win_combination|\n if win_combination.all? do |win_position|\n board[win_position] == \"X\"\n end\n true\n elsif win_combination.all? do |win_position|\n board[win_position] == \"O\"\n end\n true\n else\n false\n end\n end\nend",
"def won?(board)\n WIN_COMBINATIONS.each do |c|\n if c.all?{|pos| board[pos]==\"X\"} || c.all?{|pos| board[pos]==\"O\"}\n return c\n else\n false\n end\n end\n false #If win combo not found return false\nend",
"def won?(board)\n game = false\n WIN_COMBINATIONS.each do |win_combination|\n if !game\n if win_combination.all?{|i| board[i]==\"X\"} || win_combination.all?{|i| board[i]==\"O\"}\n game = win_combination\n end\n end\n end\n game\n end",
"def won?(board)\n WIN_COMBINATIONS.detect do |wc|\n board[wc[0]] == board[wc[1]] && board[wc[1]] == board [wc[2]] && position_taken?(board, wc[0])\n end \n end",
"def won?\n WIN_COMBINATIONS.detect do |win_combination|\n @board[win_combination[0]] == @board[win_combination[1]] &&\n @board[win_combination[1]] == @board[win_combination[2]] &&\n position_taken?(win_combination[0])\n end\nend",
"def won?(board)\n WIN_COMBINATIONS.detect do |combinations|\n index_1 = combinations[0]\n index_2 = combinations[1]\n index_3 = combinations[2]\n\n position_1 = board[index_1]\n position_2 = board[index_2]\n position_3 = board[index_3]\n\n position_1 == position_2 && position_2 == position_3 && position_3 != \" \"\n end\nend",
"def won?(board)\n WIN_COMBINATIONS.each do |win_index| #interates thru list of win combinations array\n\n x_win = win_index.all? do |spot| #interates thru individual win array\n\n board[spot] == \"X\"\n\n end\n\n o_win = win_index.all? do |spot|\n\n board[spot] == \"O\"\n\n end\n\n if x_win || o_win\n\n return win_index\n\n end\n end\n else\n return false\nend",
"def won?(board)\n WIN_COMBINATIONS.detect {|x| \n board[x[0]] ==board[x[1]] && board[x[1]] == board[x[2]] &&\n position_taken?(board, x[0]) }\nend",
"def won?(board)\n WIN_COMBINATIONS.each do |win_combination|\n if board[win_combination[0]]==board[win_combination[1]]&&board[win_combination[0]]==board[win_combination[2]]&&board[win_combination[0]]!=\" \"\n return win_combination\n end\n end\n false\nend",
"def won? (board)\n #for each row, column and diagnonal combination\n WIN_COMBINATIONS.each do | win_combination |\n #grab the winning combinaation of indices we are looking for\n win_index_1 = win_combination[0]\n win_index_2 = win_combination[1]\n win_index_3 = win_combination[2]\n\n #extract the value of these winning indices from the board\n position_1 = board[win_index_1]\n position_2 = board[win_index_2]\n position_3 = board[win_index_3]\n\n\n #check if either team has won\n if (position_1 == \"X\" && position_2 == \"X\" && position_3 == \"X\") ||\n (position_1 == \"O\" && position_2 == \"O\" && position_3 == \"O\")\n #we break out of here if we have a winning row, col, or diagnonal\n return win_combination\n end #end if\n end #end for each\n\n #if we get here the board may be empty\n #if we get here the board may be filled, but no winning combos\n return false\nend",
"def won?(board)\n WIN_COMBINATIONS.detect do | win_combination |\n # win_combination = [0,1,2], [3,4,5], [0,4,8], ... [2,4,6]\n\n win_index_1 = win_combination[0] # 0, 3\n win_index_2 = win_combination[1] # 1, 4\n win_index_3 = win_combination[2] # 2, 5\n\n position_1 = board[win_index_1] # \"X\", \"O\"\n position_2 = board[win_index_2] # \"O\", \"X\"\n position_3 = board[win_index_3] # \"X\", \"O\"\n\n if position_1 == position_2 && position_2 == position_3 && position_1 != \" \"\n return win_combination # return the win_combination indexes that won.\n else\n false\n end\n end\nend",
"def won?(board)\nWIN_COMBINATIONS.each do |combination|\n combination.all? do |occupied|\n if position_taken?(board, occupied) == true\n if board[combination[0]] == board[combination[1]] && board[combination[0]] == board[combination[2]]\n return combination\n end\n end\n end\nend\n return false\nend",
"def won?(board)\n WIN_COMBINATIONS.detect do | win_combination |\n (board[win_combination[0]] == \"X\" && board[win_combination[1]] == \"X\" && board[win_combination[2]] == \"X\")||\n (board[win_combination[0]] == \"O\" && board[win_combination[1]] == \"O\" && board[win_combination[2]] == \"O\")\n end\nend",
"def won?(board)\n # cycle through WIN_COMBINATIONS\n WIN_COMBINATIONS.detect { |winning_combo|\n # print win_index\n # print '\\n'\n position_taken?(board,winning_combo[0]) &&\n position_taken?(board,winning_combo[1]) &&\n position_taken?(board,winning_combo[2]) &&\n board[winning_combo[0]] == board[winning_combo[1]] &&\n board[winning_combo[1]] == board[winning_combo[2]]\n }\nend",
"def won?(board)\n WIN_COMBINATIONS.each do | winning_combination |\n if board[winning_combination[0]] == \"X\" &&\n board[winning_combination[1]] == \"X\" &&\n board[winning_combination[2]] == \"X\" ||\n board[winning_combination[0]] == \"O\" &&\n board[winning_combination[1]] == \"O\" &&\n board[winning_combination[2]] == \"O\"\n return winning_combination\n end\n end\n false\nend",
"def won?(board)\n WIN_COMBINATIONS.find do |winning_combo|\n board[winning_combo[0]] == board[winning_combo[1]] &&\n board[winning_combo[1]] == board[winning_combo[2]] &&\n position_taken?(board, winning_combo[0])\n end\nend",
"def won?(board)\n WIN_COMBINATIONS.each do |win_combo|\n # win_combo is a 3 element array of indexes that compose a win, [0,1,2]\n if (board[win_combo[0]] == \"X\" && board[win_combo[1]] == \"X\" && board[win_combo[2]] == \"X\") || (board[win_combo[0]] == \"O\" && board[win_combo[1]] == \"O\" && board[win_combo[2]] == \"O\")\n return win_combo # return the win_combo indexes that won.\n end\n end\n false\nend",
"def won?\n WIN_COMBINATIONS.detect do |combo|\n @board[combo[0]] == @board[combo[1]] &&\n @board[combo[1]] == @board[combo[2]] &&\n position_taken?(combo[0])\n end\nend",
"def won?\n WIN_COMBINATIONS.detect{|win| @board[win[0]] == @board[win[1]] && @board[win[1]] == @board[win[2]] && position_taken?(win[2])}\nend",
"def won?(board)\n WIN_COMBINATIONS.each do |win_combination|\n # get indices of each win_combination\n win_index_1 = win_combination[0]\n win_index_2 = win_combination[1]\n win_index_3 = win_combination[2]\n # get values from board that map to each index in each win_combination\n position_1 = board[win_index_1]\n position_2 = board[win_index_2]\n position_3 = board[win_index_3]\n # Are all values X's?\n if (position_1 == \"X\" && position_2 == \"X\" && position_3 == \"X\") || (position_1 == \"O\" && position_2 == \"O\" && position_3 == \"O\")\n return win_combination\n end # else not a win_combination\n\n end # WIN_COMBINATIONS.each iteration\n\n return false\nend",
"def won?\n TicTacToe::WIN_COMBINATIONS.each do |combinations|\n position_1 = @board[combinations[0]]\n position_2 = @board[combinations[1]]\n position_3 = @board[combinations[2]]\n\n if (position_1 == \"X\" && position_2 == \"X\" && position_3 == \"X\") || \n (position_1 == \"O\" && position_2 == \"O\" && position_3 == \"O\")\n return combinations\n else\n false\n end\n end\n false\n end",
"def won?\n WIN_COMBINATIONS.any? do |combo|\n @board.cells[combo[0]] == @board.cells[combo[1]] && @board.cells[combo[0]] == @board.cells[combo[2]] && @board.cells[combo[0]] != \" \"\n end\n end",
"def won?\n WIN_COMBINATIONS.detect do |combo|\n @board.cells[combo[0]] == @board.cells[combo[1]] &&\n @board.cells[combo[1]] == @board.cells[combo[2]] &&\n @board.taken?(combo[0]+1)\n end\n end",
"def won?\n ::WIN_COMBINATIONS.detect do |combo|\n board.cells[combo[0]] == @board.cells[combo[1]] &&\n board.cells[combo[1]] == @board.cells[combo[2]] &&\n board.taken?(combo[0]+1)\n end\n end",
"def won?(board)\n fin = false\n WIN_COMBINATIONS.each do |win_combination|\n win_index_1 = win_combination[0]\n win_index_2 = win_combination[1]\n win_index_3 = win_combination[2]\n\n position_1 = board[win_index_1]\n position_2 = board[win_index_2]\n position_3 = board[win_index_3]\n\n if (position_1 == \"X\" && position_2 == \"X\" && position_3 == \"X\") || (position_1 == \"O\" && position_2 == \"O\" && position_3 == \"O\")\n return win_combination #returns the winning index combinations\n else\n fin = false\n end\n end\n return fin\nend",
"def won?(board_array)\r\n #logic to check for a winning combination\r\n WIN_COMBINATIONS.detect do |combo|\r\n board_array[combo[0]] == board_array[combo[1]] && board_array[combo[2]] == board_array[combo[1]]&&position_taken?(board_array,combo[0])\r\n #winner_for_game = board_array[combo[0]]\r\n #return true\r\n end\r\n end",
"def won?(board)\r\n sam_ex = []\r\n sam_oh = []\r\n i = 0\r\n board.each do |index|\r\n if index == \"X\"\r\n sam_ex.push(i)\r\n elsif index == \"O\"\r\n sam_oh.push(i)\r\n end\r\n i+=1\r\n end\r\n WIN_COMBINATIONS.each do |combination|\r\n if combination&sam_oh == combination || combination&sam_ex ==combination\r\n return combination\r\n end\r\n end\r\n nil\r\nend",
"def won?\n WIN_COMBINATIONS.detect do |wc|\n @board[wc[0]] == @board[wc[1]] && @board[wc[1]] == @board[wc[2]] && position_taken?(wc[0])\n end \n end",
"def won?(board)\n win_set = nil\n win_set = WIN_COMBINATIONS.detect do |combo|\n board[combo[0]] == \"X\" && board[combo[1]] == \"X\" && board[combo[2]] == \"X\"\n end\n if win_set == nil\n win_set = WIN_COMBINATIONS.detect do |combo|\n board[combo[0]] == \"O\" && board[combo[1]] == \"O\" && board[combo[2]] == \"O\"\n end\n end\n return win_set\nend",
"def won?\n WIN_COMBINATIONS.any? do |win_array|\n board.cells[win_array[0]] == \"X\" && board.cells[win_array[1]] == \"X\" && board.cells[win_array[2]] == \"X\" ||\n board.cells[win_array[0]] == \"O\" && board.cells[win_array[1]] == \"O\" && board.cells[win_array[2]] == \"O\"\n end\n end",
"def won?(board)\n empty_board = board.all? do |element|\n element.nil? || element == \" \"\n end\n if empty_board\n return false\n end\n # For each win_combination in WIN_COMBINATIONS\n # win_combination is a 3 element array of indexes that compose a win, [0,1,2]\n WIN_COMBINATIONS.each do |win_combination|\n # grab each index from the win_combination that composes a win.\n win_index_1 = win_combination[0]\n win_index_2 = win_combination[1]\n win_index_3 = win_combination[2]\n\n position_1 = board[win_index_1] # load the value of the board at win_index_1\n position_2 = board[win_index_2] # load the value of the board at win_index_2\n position_3 = board[win_index_3] # load the value of the board at win_index_3\n\n # puts \"#{win_combination}\"\n if (position_1 == \"X\" && position_2 == \"X\" && position_3 == \"X\") ||\n (position_1 == \"O\" && position_2 == \"O\" && position_3 == \"O\")\n return win_combination # return the win_combination indexes that won.\n else\n false\n end\n end\n\n return false\n\nend",
"def won?(board)\n WIN_COMBINATIONS.each do |combo|\n if board[combo[0]] == board[combo[1]] && board[combo[1]] == board[combo[2]]\n return combo unless board[combo[0]] == \" \"\n end\n end\n false\nend",
"def won?(board)\nempty_board = board.all? {|empty| empty == \" \"}\ndraw = board.all? {|token| token == \"X\" || token == \"O\"}\nWIN_COMBINATIONS.any? do |win_combo|\n if win_combo.all? {|index| board[index] ==\"X\" } || win_combo.all? {|index| board[index] ==\"O\"}\n return win_combo\n else empty_board || draw\n false\n end\n end\nend",
"def won?(board)\nempty_board = board.all? {|empty| empty == \" \"}\ndraw = board.all? {|token| token == \"X\" || token == \"O\"}\nWIN_COMBINATIONS.any? do |win_combo|\n if win_combo.all? {|index| board[index] ==\"X\" } || win_combo.all? {|index| board[index] ==\"O\"}\n return win_combo\n else empty_board || draw\n false\n end\n end\nend",
"def won?\n # iteration returns 3 winning cells as win_combo array; or nil\n win_combo = WIN_COMBINATIONS.detect do |combo|\n board.cells[combo[0]] == board.cells[combo[1]] &&\n board.cells[combo[1]] == board.cells[combo[2]] &&\n board.cells[combo[2]] != \" \"\n end\n # won? returns winning array if found; or false\n win_combo == nil ? false : win_combo\n end",
"def won?(board)\n WIN_COMBINATIONS.each do |win_combo|\n win_in_1 = win_combo[0]\n win_in_2 = win_combo[1]\n win_in_3 = win_combo[2]\n\n position_1 = board[win_in_1]\n position_2 = board[win_in_2]\n position_3 = board[win_in_3]\n\n if position_1 == position_2 && position_2 == position_3 && position_taken?(board, win_in_1)\n return win_combo\n end\n end\n return false\nend",
"def won?\r\n WIN_COMBINATIONS.detect do | win_combination |\r\n # win_combination = [0,1,2], [3,4,5], [0,4,8], ... [2,4,6]\r\n\r\n win_index_1 = win_combination[0] # 0, 3\r\n win_index_2 = win_combination[1] # 1, 4\r\n win_index_3 = win_combination[2] # 2, 5\r\n\r\n position_1 = @board[win_index_1] # \"X\", \"O\"\r\n position_2 = @board[win_index_2] # \"O\", \"X\"\r\n position_3 = @board[win_index_3] # \"X\", \"O\"\r\n\r\n if position_1 == position_2 && position_2 == position_3 && position_1 != \" \"\r\n return win_combination # return the win_combination indexes that won.\r\n else\r\n false\r\n end\r\n end\r\n end",
"def won?(board)\n \n # Iterates through WIN_COMBINATIONS and finds first matching win_combination and returns the winning array.\n WIN_COMBINATIONS.detect do |win_combination|\n \n # Each 'win_index' returns the first, second, and third elements of each winning combo array.\n win_index_1 = win_combination[0]\n win_index_2 = win_combination[1]\n win_index_3 = win_combination[2]\n \n # Each 'position' uses the indices from the winning combos and applies them to the 'board' array.\n position_1 = board[win_index_1]\n position_2 = board[win_index_2]\n position_3 = board[win_index_3]\n \n # Takes first win_combination and checks to see if they are all \"X\"'s or \"O\"'s and that the string is not empty.\n position_1 == position_2 && position_2 == position_3 && position_taken?(board, win_index_1)\n end\nend",
"def won?\n\n WIN_COMBINATIONS.find do |win_combination|\n # puts \"This is win combination #{win_combination}\"\n win_index_1 = win_combination[0]\n win_index_2 = win_combination[1]\n win_index_3 = win_combination[2]\n\n position_1 = @board[win_index_1]\n position_2 = @board[win_index_2]\n position_3 = @board[win_index_3]\n\n position_1 == position_2 && position_2 == position_3 && position_taken?(win_index_1)\n end\n end",
"def won?(board)\n\n WIN_COMBINATIONS.each do |win_combination|\n win_index_1 = win_combination[0]\n win_index_2 = win_combination[1]\n win_index_3 = win_combination[2]\n \n position_1 = board[win_index_1]\n position_2 = board[win_index_2]\n position_3 = board[win_index_3]\n \n if ((position_1 == \"X\" && position_2 == \"X\" && position_3 == \"X\") || (position_1 == \"O\" && position_2 == \"O\" && position_3 == \"O\"))\n return win_combination\n end\n end\n return FALSE\nend",
"def won? (board)\n WIN_COMBINATIONS.detect do |win_combination|\n # Check if the win_combination is ocupied/not empty.\n valid_win_combination = position_taken?(board, win_combination[0])\n char1 = board[win_combination[0]]\n char2 = board[win_combination[1]]\n char3 = board[win_combination[2]]\n valid_win_combination && char1 == char2 && char2 == char3\n end\nend",
"def won?\n if @board.all? { |i| i == \"\" || i == \" \"} == true\n return false\n end\n WIN_COMBINATIONS.detect do |win_cond|\n @board[win_cond[0]] == @board[win_cond[1]]&&\n @board[win_cond[0]] == @board[win_cond[2]]&&\n position_taken?(win_cond[0])\n end\n end",
"def won?(board)\n if board == [\" \", \" \", \" \", \" \", \" \", \" \", \" \", \" \", \" \"]\n return false\n end\n\n#counting so we don't return false until we have looked at all of the combinations.\ncount = 0\n\n WIN_COMBINATIONS.each do |combo|\n count = count + 1\n if board[combo[0]] == \"X\" && board[combo[1]] == \"X\" && board[combo[2]] == \"X\"\n return combo\n elsif board[combo[0]] == \"O\" && board[combo[1]] == \"O\" && board[combo[2]] == \"O\"\n return combo\n elsif count == 8\n return false\n end\n end\nend",
"def won?(board)\n WIN_COMBINATIONS.detect do |item|\n board[item[0]] == board[item[1]] && board[item[1]] == board[item[2]] && position_taken?(board, item[0])\n end\nend",
"def won?(board)\n WIN_COMBINATIONS.each do |combination|\n if board[combination[0]] == \"X\" && board[combination[1]] == \"X\" && board[combination[2]] == \"X\" || board[combination[0]] == \"O\" && board[combination[1]] == \"O\" && board[combination[2]] == \"O\"\n return combination\n end\n end\n return false\nend",
"def won?(board)\n WIN_COMBINATIONS.detect do |win_combo|\n position_1 = board[win_combo[0]]\n position_2 = board[win_combo[1]]\n position_3 = board[win_combo[2]]\n\n position_1 == \"X\" && position_2 == \"X\" && position_3 == \"X\" ||\n position_1 == \"O\" && position_2 == \"O\" && position_3 == \"O\"\n end\nend",
"def won?(board)\n winner = []\n won=WIN_COMBINATIONS.any? do |arr|\n arr.all? {|position| position_taken?(board,position,\"X\")} || arr.all? {|position| position_taken?(board,position,\"O\")}\n if arr.all? {|position| position_taken?(board,position,\"X\")} || arr.all? {|position| position_taken?(board,position,\"O\")}\n winner = arr\n end\n end\n if won\n return winner\n else\n return false\n end\nend",
"def won?(board)\n win_combination = []\n WIN_COMBINATIONS.each do |line|\n if line.all? { |pos| board[pos] == \"X\" }\n win_combination = line\n end\n if line.all? { |pos| board[pos] == \"O\" }\n win_combination = line\n end\n end\n if win_combination != []\n win_combination\n else\n false\n end\nend",
"def won?(board)\n if board.all? == \" \" || board.all? == nil\n return nil\n else\nWIN_COMBINATIONS.detect do |win|\n board[win[0]] == \"X\" && board[win[1]] == \"X\" && board[win[2]] == \"X\" ||\n board[win[0]] == \"O\" && board[win[1]] == \"O\" && board[win[2]] == \"O\"\n\n end\n end\nend",
"def won?(board)\n if board.all? == \" \" || board.all? == nil\n return nil\n else\nWIN_COMBINATIONS.detect do |win|\n board[win[0]] == \"X\" && board[win[1]] == \"X\" && board[win[2]] == \"X\" ||\n board[win[0]] == \"O\" && board[win[1]] == \"O\" && board[win[2]] == \"O\"\n\n end\n end\nend",
"def won?\n WIN_COMBINATIONS.each do |win_combination|\n win_index_1 = win_combination[0]\n win_index_2 = win_combination[1]\n win_index_3 = win_combination[2]\n\n position_1 = @board[win_index_1]\n position_2 = @board[win_index_2]\n position_3 = @board[win_index_3]\n\n if position_1 == position_2 && position_2 == position_3 && position_taken?(win_index_1)\n return win_combination\n end\n end\n return false\n end",
"def won?(board)\n WIN_COMBINATIONS.each do|win|\n if (board[win[0]] == 'X' && board[win[1]] == 'X' && board[win[2]] == 'X') || (board[win[0]] == 'O' && board[win[1]] == 'O' && board[win[2]] == 'O')\n return win\n end\n end\n false\nend",
"def won?()\n WIN_COMBINATIONS.detect do |e|\n @board[e[0]] == @board[e[1]] && @board[e[1]] == @board[e[2]] && position_taken?( e[0])\n end\nend",
"def won?\n WIN_COMBINATIONS.detect do |combo|\n @board[combo[0]] == @board[combo[1]] &&\n @board[combo[1]] == @board[combo[2]] &&\n position_taken?(combo[0])\n end\n end",
"def won?\n WIN_COMBINATIONS.detect do |combo|\n @board[combo[0]] == @board[combo[1]] &&\n @board[combo[1]] == @board[combo[2]] &&\n position_taken?(combo[0])\n end\n end",
"def won?(board)\n \nWIN_COMBINATIONS.detect do |a|\n (a.all?{|position| board[position] == \"X\"}) || (a.all?{|position| board[position] == \"O\"})\n\nend\n\nend",
"def won?(board)\n \n WIN_COMBINATIONS.each {|i|\n #get win combinations at each loops\n win_1= i[0]\n win_2 = i[1]\n win_3 = i[2]\n \n \n pos_1 = board[win_1]\n pos_2 = board[win_2]\n pos_3 = board[win_3]\n \n if(pos_1 == \"O\" && pos_2 == \"O\" && pos_3 == \"O\")\n return i\n elsif (pos_1 == \"X\" && pos_2 == \"X\" && pos_3 == \"X\")\n return i\n end\n }\n return false\n end",
"def won?(board)\n\n win_array = []\n WIN_COMBINATIONS.any? do |win_combination|\n if win_combination.all? {|win_index| board[win_index] == 'X'} || win_combination.all? {|win_index| board[win_index] == 'O'}\n return win_combination\n end\n end\nend",
"def won?(board)\n\nWIN_COMBINATIONS.find do |combo|\n board[combo[0]] == board[combo[1]] &&\n board[combo[1]] == board[combo[2]] &&\n position_taken?(board, combo[0])\n end\nend",
"def won?(board)\n\n WIN_COMBINATIONS.detect do | win_combination |\n\nlocation1 = win_combination[0]\nlocation2 = win_combination[1]\nlocation3 = win_combination[2]\n\nboard[location1] == board[location2] && board[location2] == board[location3] && board[location1] != \" \"\n end\nend",
"def won?(board)\n \n WIN_COMBINATIONS.each do |win_combo|\n p1 = board[win_combo[0]]\n p2 = board[win_combo[1]]\n p3 = board[win_combo[2]]\n \n if (p1 == \"X\" && p2 == \"X\" && p3 == \"X\") || (p1 == \"O\" && p2 == \"O\" && p3 == \"O\")\n return win_combo\n end\n \n end\n return false\n end",
"def won?\n won = false\n WIN_COMBINATIONS.each do |win_combination|\n board_entries = [@board.cells[win_combination[0]], @board.cells[win_combination[1]], @board.cells[win_combination[2]]]\n board_entries == [\"X\", \"X\", \"X\"] || board_entries == [\"O\", \"O\", \"O\"] ? won = win_combination : false\n end\n won\n end",
"def won?(board)\n WIN_COMBINATIONS.each do |combo|\n if (board[combo[0]] == board[combo[1]] && board[combo[0]] == board[combo[2]] && board[combo[0]] != \" \" && board[combo[0]] != \"\" && !board[combo[0]].nil?)\n return combo\n break\n end\n end\n return false\nend",
"def won?\n the_win_combination = false\n WIN_COMBINATIONS.each do |win_combination|\n win_index_1 = win_combination[0]\n win_index_2 = win_combination[1]\n win_index_3 = win_combination[2]\n\n position_1 = @board[win_index_1]\n position_2 = @board[win_index_2]\n position_3 = @board[win_index_3]\n\n if (position_1 == \"X\" && position_2 == \"X\" && position_3 == \"X\") ||\n (position_1 == \"O\" && position_2 == \"O\" && position_3 == \"O\")\n the_win_combination = win_combination\n break\n end\n end\n the_win_combination\n end",
"def won?(board)\n if board.all? { |place| place == ' ' }\n return false\n end\n for combo in WIN_COMBINATIONS\n if combo.all? { |index| board[index] == 'X' }\n return combo\n elsif combo.all? { |index| board[index] == 'O' }\n return combo\n end\n end\n false\nend",
"def won?(board)\n WIN_COMBINATIONS.each do |indices|\n result = indices.map { |i| board[i] }\n if result == [\"X\", \"X\", \"X\"] || result == [\"O\", \"O\", \"O\"]\n return indices\n end\n end\n false\nend",
"def won?\r\n WIN_COMBINATIONS.detect do |combo|\r\n @board[combo[0]] == @board[combo[1]] &&\r\n @board[combo[1]] == @board[combo[2]] && @board[combo[0]] != \" \"\r\n end\r\n end",
"def won?\n WIN_COMBINATIONS.detect do |combo|\n combo.all? { |c| position_taken?( c ) && @board[c] == @board[ combo[0] ] }\n end\n end",
"def won?\n WIN_COMBINATIONS.find do |combination|\n win_index_1 = combination[0]\n win_index_2 = combination[1]\n win_index_3 = combination[2]\n position_1 = @board[win_index_1]\n\n position_2 = @board[win_index_2]\n position_3 = @board[win_index_3]\n\n position_taken?(win_index_1) && position_1 == position_2 && position_2 == position_3\n end\n end",
"def won?\n WIN_COMBINATIONS.any? do |win_combo|\n win_index_1 = win_combo[0]\n win_index_2 = win_combo[1]\n win_index_3 = win_combo[2]\n\n position_1 = @board[win_index_1]\n position_2 = @board[win_index_2]\n position_3 = @board[win_index_3]\n\n if position_taken?(win_index_1) && position_1 == position_2 && position_2 == position_3\n #binding.pry\n return win_combo\n end\n end\n end",
"def won?(board)\n WIN_COMBINATIONS.each do |single_win_combo|\n win_index_1 = single_win_combo[0]\n win_index_2 = single_win_combo[1]\n win_index_3 = single_win_combo[2]\n\n # Pos 1,2,3 will cycle thru all 9 spaces on board\n position_1 = board[win_index_1]\n position_2 = board[win_index_2]\n position_3 = board[win_index_3]\n\n if position_1 == position_2 && position_2 == position_3 && position_taken?(@board, win_index_1)\n return single_win_combo\n end\n end\n return false\n end",
"def won?(board)\n WIN_COMBINATIONS.each do |combo|\n if position_taken?(board,combo[0]) && position_taken?(board,combo[1]) && position_taken?(board,combo[2])\n if board[combo[0]] == board[combo[1]] && board[combo[1]] == board[combo[2]]\n return combo\n end\n end\n end\n return false\nend",
"def won?(board)\n # for each win_combo in WIN_COMBINATIONS\n WIN_COMBINATIONS.each do |win_combo|\n # win_combination is a 3 element array of indexes that compose a win, eg. [0,1,2]\n # grab each index from the win_combo that composes a win.\n win_index_1 = win_combo[0]\n win_index_2 = win_combo[1]\n win_index_3 = win_combo[2]\n # If/else that declares a winner if all three spots in a winning array have\n # either an \"X\" or an \"O\", respectively.\n if board[win_index_1] == \"X\" && board[win_index_2] == \"X\" && board[win_index_3] == \"X\"\n return win_combo\n elsif board[win_index_1] == \"O\" && board[win_index_2] == \"O\" && board[win_index_3] == \"O\"\n return win_combo\n end\n end\n return false\nend",
"def check_win(b)\n\n\t\tboard_columns = b.transpose\n\t\tboard_diagonals = [[b[0][0],b[1][1],b[2][2]],[b[0][2],b[1][1],b[2][0]]]\n\n\t\tcase\n\n\t\twhen b.include?([\"X\",\"X\",\"X\"]) || b.include?([\"O\",\"O\",\"O\"])\n\t\t\treturn true\n\t\twhen board_diagonals.include?([\"X\",\"X\",\"X\"]) || board_diagonals.include?([\"O\",\"O\",\"O\"])\n\t\t\treturn true\n\t\twhen board_columns.include?([\"X\",\"X\",\"X\"]) || board_columns.include?([\"O\",\"O\",\"O\"])\n\t\t\treturn true\n\t\tend\n\n\tend",
"def won?\r\n WIN_COMBINATIONS.each do |combination|\r\n occupied = true\r\n if @board[combination[0]] == \" \" || @board[combination[1]] == \" \" ||\r\n @board[combination[2]] == \" \"\r\n occupied = false\r\n end\r\n if occupied\r\n if @board[combination[0]] == @board[combination[1]] && \r\n @board[combination[1]] == @board[combination[2]]\r\n return combination\r\n end\r\n end\r\n end\r\n false\r\n end",
"def won?(board)\n x = \"X\";\n o = \"O\";\n\n WIN_COMBINATIONS.each do |win_combination|\n win_index_1 = win_combination[0];\n win_index_2 = win_combination[1];\n win_index_3 = win_combination[2];\n\n position_1 = board[win_index_1];\n position_2 = board[win_index_2];\n position_3 = board[win_index_3];\n\n if ((position_1 == x && position_2 == x && position_3 == x) ||\n (position_1 == o && position_2 == o && position_3 == o))\n return win_combination;\n else\n false\n end\n end\n return false;\nend",
"def won?\n \n # Iterates through WIN_COMBINATIONS and finds first matching win_combination and returns the winning array.\n WIN_COMBINATIONS.detect do |win_combination|\n \n # Each 'win_index' returns the first, second, and third elements of each winning combo array.\n win_index_1 = win_combination[0]\n win_index_2 = win_combination[1]\n win_index_3 = win_combination[2]\n \n # Each 'position' uses the indices from the winning combos and applies them to the 'board' array.\n position_1 = @board[win_index_1]\n position_2 = @board[win_index_2]\n position_3 = @board[win_index_3]\n \n # Takes first win_combination and checks to see if they are all \"X\"'s or \"O\"'s and that the string is not empty.\n position_1 == position_2 && position_2 == position_3 && position_taken?(win_index_1)\n end\n end",
"def won?\n WIN_COMBINATIONS.any? { |currentBoard| \n if position_taken?( currentBoard[0] ) && @board[currentBoard[0]] == @board[currentBoard[1]] && @board[currentBoard[1]] == @board[currentBoard[2]]\n return currentBoard\n end\n }\n end",
"def won?(board)\n WIN_COMBINATIONS.each do |win_combo|\n pos_one = win_combo[0]\n pos_two = win_combo[1]\n pos_three = win_combo[2]\n\n if board[pos_one] != \" \" && board[pos_one] == board[pos_two] && board[pos_two] == board[pos_three]\n return win_combo\n end\n end\n false\nend",
"def won?(board)\n WIN_COMBINATIONS.detect do |combo|\n board[combo[0]] == board[combo[1]] &&\n board[combo[1]] == board[combo[2]] &&\n position_taken?(board, combo[0])\n end\n end"
] | [
"0.86590326",
"0.86038566",
"0.85727125",
"0.85500234",
"0.853805",
"0.8537946",
"0.8521563",
"0.85176927",
"0.85156965",
"0.85156965",
"0.85156965",
"0.8508075",
"0.8491223",
"0.84568334",
"0.84568334",
"0.84557843",
"0.84549016",
"0.8442815",
"0.84313375",
"0.84222704",
"0.8415375",
"0.84143907",
"0.8414376",
"0.84100556",
"0.8393075",
"0.83880264",
"0.8386831",
"0.8384908",
"0.83824575",
"0.8368662",
"0.8367264",
"0.83619714",
"0.83513814",
"0.8346106",
"0.83420044",
"0.8326911",
"0.83232516",
"0.8303459",
"0.82896245",
"0.8278638",
"0.82780856",
"0.827741",
"0.8273031",
"0.8269141",
"0.82616085",
"0.82592356",
"0.8255987",
"0.8254818",
"0.8250919",
"0.82490766",
"0.82455313",
"0.8241407",
"0.8240375",
"0.8240375",
"0.8239361",
"0.8239188",
"0.82329",
"0.82309335",
"0.8230623",
"0.8229955",
"0.8225496",
"0.8222438",
"0.8213385",
"0.8213267",
"0.8211576",
"0.8211273",
"0.8208934",
"0.82078665",
"0.82070345",
"0.82070345",
"0.82002646",
"0.8198629",
"0.8198581",
"0.8196979",
"0.8196979",
"0.8194691",
"0.8194663",
"0.81932586",
"0.8192068",
"0.8191769",
"0.8187836",
"0.81862324",
"0.8185362",
"0.8173808",
"0.8172734",
"0.8168034",
"0.81659603",
"0.8165884",
"0.8165882",
"0.8162401",
"0.81594056",
"0.8154408",
"0.8153211",
"0.81500804",
"0.8144522",
"0.8134455",
"0.8132501",
"0.81294805",
"0.81229806",
"0.81214654"
] | 0.81455946 | 94 |
Preview this email at | def shipped
OrderMailer.shipped
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def preview\n @email = Email.find(params[:id])\n render :text => @email.body\n end",
"def preview\n @email = DirectEmail.find(params[:id])\n render :text => @email.body\n end",
"def preview\n @email = EventEmail.find(params[:id])\n render :text => @email.body\n end",
"def preview_email\r\n invitation = Invitation.new(:user => current_user, :code => Code.new)\r\n mail = Mailers::Debate.create_invitation(current_user, @resource, invitation)\r\n @mail_body = mail.body.sub('No message provided', 'YOUR PERSONALIZED NOTE GOES HERE')\r\n\r\n render :inline => %Q{<%= simple_format(@mail_body, {:style => 'margin: 8px 0px'}) %>}\r\n end",
"def demo\n preview(DemoMailer.demo)\n end",
"def demo\n preview(DemoMailer.demo)\n end",
"def call(email, params = {})\n preview = new(params)\n message = preview.public_send(email)\n inform_preview_interceptors(message)\n message\n end",
"def call(email)\n preview = self.new\n preview.public_send(email)\n end",
"def preview_newsletter\n @newsletter = @structure.newsletters.friendly.find params[:id]\n\n # Send email to no recipients to generate mail object\n mail = NewsletterMailer.send_newsletter(@newsletter, nil)\n @body = MailerPreviewer.preview(mail)\n\n render layout: false\n end",
"def preview\n task = MailTasks::Task.new( params[:task] )\n recipient = StoreUser.find( params[:id], :include => \"customer\", :readonly => true )\n mail = task.generate_mails( [recipient], false, mail_layout_options ).first\n render :text => mail.content_with_layout( mail_layout_options ), :layout => false\n # rescue => exception\n # headers[\"Content-Type\"] = \"text/plain\"\n # render :text => exception.to_yaml, :layout => false\n end",
"def preview_to(recipient)\n @newsletter = build_newsletter\n mail = build_mail\n mail.to = recipient.email\n replace_and_send_mail_safely(mail, recipient)\n end",
"def show_body\n I18n.with_locale @email_locale do\n @mail_body = mail_body(@preview, @part_type)\n render :show_body, layout: 'rails_email_preview/email'\n end\n end",
"def process_explanation_mail\n petition = Petition.where(status: 'live').first\n PetitionMailer.process_explanation_mail(Petition.live.first)\n end",
"def content_for_preview( layout_options )\r\n content = self.body.dup\r\n content.gsub!( /<%=\\s?(@[^%]+)\\s?%>/, '<code>\\1</code>' )\r\n mail = Mail.new( :token => \"\" )\r\n mail.content = Render::Base.new( content ).mail_content\r\n template = IO.read(\"#{RAILS_ROOT}/app/views/mail_tasks/mailer/this_mail.text.html.rhtml\")\r\n \r\n render = Render::Base.new( template, layout_options.merge( :mail => mail ) )\r\n render.mail_content\r\n end",
"def preview\n frm.button(:value=>\"Preview\").click\n PreviewAnnouncements.new(@browser)\n end",
"def compose_email\n @title = t 'conclusion_draft_review.send_by_email'\n end",
"def preview\n end",
"def preview\n end",
"def show\n @decrypted = @autocrypt.decrypt(@email)\n @reply_params = {\n to: @email.from,\n subject: 'Re: ' + @email.subject,\n body: (@decrypted || @email.body).gsub(/^/, '> ')\n }\n end",
"def preview\n attachments.first.file.url(:preview)\n rescue StandardError => exc\n logger.error(\"Message for the log file while retrieving preview #{exc.message}\")\n 'empty_file.png'\n end",
"def preview\n redirect_to preview_url\n end",
"def preview\n @text = params[:deliverable][:description]\n render :partial => 'common/preview'\n end",
"def preview_announcement(subject)\n frm.link(:text=>subject).click\n PreviewAnnouncements.new(@browser)\n end",
"def show\n if @sent_email.photo.nil?\n @display_name = ''\n @title = ''\n @flickr_url = ''\n else\n @display_name = @sent_email.photo.member.display_name\n @title = @sent_email.photo.title\n @flickr_url = @sent_email.photo.get_flickr_url\n end\n end",
"def preview\n frm.button(:value=>\"Preview\").click\n AssignmentsPreview.new(@browser)\n end",
"def preview\n frm.button(:value=>\"Preview\").click\n AssignmentsPreview.new(@browser)\n end",
"def send_preview(recipients, personalize=\"fallback\")\n options = { :body => {\n :PreviewRecipients => recipients.kind_of?(String) ? [ recipients ] : recipients,\n :Personalize => personalize }.to_json }\n response = post \"sendpreview\", options\n end",
"def create\n @mail = Mail.new(params[:mail])\n @mail.user = current_user\n \n if params[:preview_button] || [email protected]\n render :action => \"new\"\n else\n flash[:notice] = 'Mail was successfully created.'\n redirect_to(@mail)\n end\n end",
"def last_message_preview=(value)\n @last_message_preview = value\n end",
"def edit\n yield @editor\n @mail = @editor.mail\n @message = @mail.to_s\n end",
"def preview_text\n return @preview_text\n end",
"def preview_text\n return @preview_text\n end",
"def preview\n return @preview\n end",
"def inspect\n \"#<Envelope::Message to=#{formatted_to} from=#{formatted_from} cc=#{formatted_cc} bcc=#{formatted_bcc} reply_to=#{formatted_reply_to} subject=\\\"#{subject}\\\" text_part=\\\"#{preview = (text_part || html_part); (preview && preview.gsub(/\\s+/, ' ') || 'No preview available')[0..50]}...\\\">\"\n end",
"def petition_announcement_mail\n petition = Petition.where(status: 'live').first\n PetitionMailer.petition_announcement_mail(Petition.live.first)\n end",
"def preview\n frm.link(:text=>\"Preview\").click\n PreviewOverview.new(@browser)\n end",
"def preview() @page.find(input_elements[:preview]) end",
"def preview(channel_id, msg_id, data)\n channel_config, message_config, text =\n prepare_message(channel_id, msg_id, data)\n chats = channel_config.chat_ids\n connector = channel_config.connector\n\n if message_allowed?(message_config, data)\n connector.preview(chats, text, message_config)\n else\n puts \"No message sent beacuse it's not allowed\"\n end\n end",
"def improve_and_reopen_mail\n petition = Petition.where(status: 'live').first\n PetitionMailer.improve_and_reopen_mail(Petition.live.first)\n end",
"def hand_over_to_office_mail\n petition = Petition.where(status: 'live').first\n PetitionMailer.hand_over_to_office_mail(Petition.live.first)\n end",
"def content_preview\n self.send(content_preview_method)\n end",
"def write_about_hand_over_mail\n petition = Petition.where(status: 'live').first\n PetitionMailer.write_about_hand_over_mail(Petition.live.first)\n end",
"def preview\n order = current_user.orders.find_by_cookbook_id(params[:id])\n @cookbook = (order) ? order.cookbook : current_cookbook\n preview_path = \"#{PDF_PREVIEW_FOLDER}/preview_cookbook-#{@cookbook.id}_#{Time.now.to_i}.pdf\"\n session[:preview_filename] = preview_path\n preview = CookbookPreviewWorker.new(\n cookbook: @cookbook, \n filename: preview_path\n )\n preview.cookbook\n render \"previews/preview\"\n end",
"def preview=(value)\n @preview = value\n end",
"def preview_path_for_attachment(attachment)\n preview_attachment_path(id: attachment.attachment_data.id, file: attachment.filename.split('.').first, extension: attachment.file_extension)\n end",
"def preview(attachment, options)\n Rails.application.routes.url_helpers.rails_representation_path(attachment.preview(options), only_path: true)\n end",
"def preview_doc\n @tpl = Template.find(params[\"template_id\"]) \n output = @tpl.render_by_model_id(params[:id], 'print', 'www.freightoperations.com:8080')\n render(:text => output, :layout => false) \n end",
"def preview\n frm.button(:value=>\"Preview\").click\n @@file_number=0\n AssignmentStudentPreview.new(@browser)\n end",
"def preview\n frm.button(:value=>\"Preview\").click\n @@file_number=0\n AssignmentStudentPreview.new(@browser)\n end",
"def last_message_preview\n return @last_message_preview\n end",
"def preview\n @preview ||= Preview.new(self) #if has_preview?\n end",
"def tweet_reviewed_by_influencer(tweet)\n @tweet = tweet\n\n set_attachments\n\n mail(to: tweet.campaign.advertiser.user.email, subject: \"Notificaciones @ Social Target - Uno de tus tweets fue revisado/modificado por una empresa\")\n end",
"def body_preview=(value)\n @body_preview = value\n end",
"def preview\n content[0..19]\n end",
"def view(review, recipient)\n @review = review\n\n mail(to: recipient.email, subject: \"#{@review.review_type == \"cto\" ? @review.booking.user.first_name : @review.booking.offer.user.first_name} vous a laissé un commentaire\")\n end",
"def new_review_email (review)\n\t@book = review.book\n\t@review = review\n\tmail :to => @book.readers.collect{|r| r.email},\n\t :subject=>\"New review for #{@book.title}\"\n end",
"def preview(element_key)\n parameter = { basic_auth: @auth }\n self.class.get(\"/elements/#{element_key}/preview\", parameter)\n end",
"def open\n mail = MailTasks::Mail.find_by_token( params[:id] )\n raise ActiveRecord::RecordNotFound unless mail # raise 404 if mail is not found\n \n options = {\n :post_back_url => url_for( :controller => \"/email\", :action => \"red_logo\" ),\n :base => [request.protocol, request.host].join\n }\n render :text => mail.content_with_layout( options ), :layout => false\n end",
"def emailOnMetareview(revieweeId)\r\n puts \"in Metareview\"\r\n participant = Participant.find_by_id(revieweeId).user_id\r\n asstId = Participant.find_by_id(revieweeId).parent_id\r\n user=User.find_by_id(participant)\r\n assignment=Assignment.find_by_id(asstId).name\r\n partialName=\"email_on_review_of_review\"\r\n if(user.email_on_review_of_review)\r\n email(user.email,\"Metareview\",ApplicationHelper::get_user_first_name(user),assignment,partialName)\r\n end\r\n end",
"def body_preview\n return @body_preview\n end",
"def preview(*)\n nil\n end",
"def preview(*)\n nil\n end",
"def preview\n preview_path = \"#{PDF_PREVIEW_FOLDER}/preview_extra_page-#{@extra_page.id}_#{Time.now.to_i}.pdf\"\n session[:preview_filename] = preview_path\n preview = CookbookPreviewWorker.new(\n cookbook: current_cookbook, \n filename: preview_path\n )\n preview.extra_page @extra_page.id\n render \"previews/preview\"\n end",
"def reference_number_mail\n petition = Petition.where(status: 'live').first\n PetitionMailer.reference_number_mail(Petition.live.first)\n end",
"def ask_office_for_answer_mail\n petition = Petition.where(status: 'live').first\n PetitionMailer.ask_office_for_answer_mail(Petition.live.first)\n end",
"def show\n set_retail\n end",
"def preview_name\n name.sub(/Preview$/, '').underscore\n end",
"def preview\n mixpanel_tab_event(\"View Item\", \"Get Preview URL\")\n begin\n embed_url = user_client.embed_url(params[:id])\n redirect_to embed_url\n rescue\n redirect_to no_support_url\n end\n\n end",
"def blog_preview\n object._challenge\n end",
"def show\n session[:applicant_token] = params[:id] unless current_user\n @email = ERB.new(Settings.email_template).result(get_binding)\n p EMAIL: @email\n end",
"def ping_reviewer(review)\n\n to_list = [review[:user].email]\n cc_list = []\n subject = 'Your unresolved Design Review(s)'\n\n @user = review[:user]\n @result = review[:results]\n \n if review[:urgent]\n attachments.inline['warning.png'] = File.read('app/assets/images/warning.png')\n headers['Importance'] = 'high'\n headers['X-Priority'] = '1'\n headers['X-MSMail-Priority'] = 'High'\n end\n\n mail( :to => to_list,\n :subject => subject,\n :cc => cc_list,\n ) \n end",
"def preview_text(maxlength = 30)\n return \"\" if description.blank?\n my_contents = description[\"contents\"]\n return \"\" if my_contents.blank?\n content_flagged_as_preview = my_contents.select { |a| a[\"take_me_for_preview\"] }.first\n if content_flagged_as_preview.blank?\n content_to_take_as_preview = my_contents.first\n else\n content_to_take_as_preview = content_flagged_as_preview\n end\n preview_content = self.contents.select { |content| content.name == content_to_take_as_preview[\"name\"] }.first\n return \"\" if preview_content.blank? || preview_content.essence.blank?\n text = preview_content.essence.preview_text(maxlength)\n text.size > maxlength ? \"#{text[0..maxlength]}...\" : text\n end",
"def link_to_preview(text, type_id, *args)\n link_to_function text, \"CCPEVE.showPreview(#{type_id.inspect})\", *args\n end",
"def preview_text=(value)\n @preview_text = value\n end",
"def preview_text=(value)\n @preview_text = value\n end",
"def resume_confirm(email, username, filename)\n subject 'You have uploaded your resume to YouIntern'\n recipients email\n from '[email protected]'\n sent_on Time.now\n \n body :username => username, :filename => filename\n end",
"def preview_text(max_length = 30)\n attachment&.name.to_s[0..max_length - 1]\n end",
"def display_resume\n\t profile_resume = Profile.find_by_id(params[:id]).resume\n send_data(profile_resume.attachment_binary.data,\n\t\t\t\t :filename => profile_resume.name,\n\t\t\t\t :type => profile_resume.content_type,\n\t\t\t\t :disposition => \"attachment\"\n\t\t\t\t )\n end",
"def generate_complete_timeline_preview_url(given_timeline_id)\n tl_entry_to_use = Timeline.find(given_timeline_id)\n target_page_path = timeline_path(tl_entry_to_use)\n \n protocol_host_port = \"#{request.protocol}#{request.host_with_port}\"\n main_url = \"#{protocol_host_port}#{target_page_path}?preview=true\"\n \n url_to_return = URI::encode(main_url)\n return url_to_return\n end",
"def preview(article)\n unless article.published_at.nil?\n article_path(article)\n else\n preview_path(article.preview_hash)\n end\n end",
"def post_edit_email\n NotificationMailer.post_edit_email('[email protected]')\n end",
"def reviewed(inquiry)\n @inquiry = inquiry\n mail to: inquiry.email, subject: 'Verteo Biopharma Inquiry Reviewed'\n end",
"def update\n @mail = Mail.find(params[:id]) \n if [email protected]_attributes(params[:mail]) || params[:preview_button]\n \n render :action => \"edit\"\n else\n flash[:notice] = 'Mail was successfully updated.'\n redirect_to(@mail)\n end\n end",
"def to_s\n \"Last Modified: #{@modifiedAt}\\nStatus: #{@status}\\nAssigned to: #{@owner}\\nSubject: #{@subject}\\n#{@preview}\"\n end",
"def show\n #TRACKER.track(current_user['email'], \"READ_EMAIL\", {\"email_id\" => @email.id, \"email_reference\" => @email.reference_id})\n TRACKER.track(current_user['email'], \"READ_EMAIL\", @email.id, @email.reference_id)\n end",
"def preview!(purchase)\n post(purchase, \"#{collection_path}/preview\")\n end",
"def preview!(purchase)\n post(purchase, \"#{collection_path}/preview\")\n end",
"def preview\n begin\n page = Comatose::Page.new(params[:page])\n page.author = current_user\n if params.has_key? :version\n content = page.to_html( {'params'=>params.stringify_keys, 'version'=>params[:version]} )\n else\n content = page.to_html( {'params'=>params.stringify_keys} )\n end\n rescue SyntaxError\n content = \"<p>There was an error generating the preview.</p><p><pre>#{$!.to_s.gsub(/\\</, '<')}</pre></p>\"\n rescue\n content = \"<p>There was an error generating the preview.</p><p><pre>#{$!.to_s.gsub(/\\</, '<')}</pre></p>\"\n end\n render :text=>content, :layout => false\n end",
"def show\n # notification_email\n end",
"def preview\n self.content.split(' ')[0...5].join(' ') + '...'\n end",
"def apply(interviewee,interviewer)\n @interviewee = interviewee\n @interviewer = interviewer\n mail(to: @interviewee.email + \",\" + @interviewer.email, subject: '面接日程承認のお知らせ')\n end",
"def to_s\n '#<Twilio::REST::Preview>'\n end",
"def to_s\n '#<Twilio::REST::Preview>'\n end",
"def email_approved_proposal\n ProposalMailer.email_approved_proposal\n end",
"def preview_submit\n @story = Story.find(params[:submission])\n @story_slam_preview = true # to hide/show certain things in the header\n end",
"def set_preview\n @preview = Preview.find(params[:id])\n end",
"def preview_msg(msg_params_with_name)\n uri = 'cgi-bin/operate_appmsg?sub=preview&t=ajax-appmsg-preview'\\\n \"&type=10&token=#{@token}&lang=zh_CN\"\n headers = {\n referer: 'https://mp.weixin.qq.com/cgi-bin/appmsg?t=media/appmsg_edit'\\\n \"&action=edit&type=10&isMul=0&isNew=1&lang=zh_CN&token=#{@token}\",\n host: 'mp.weixin.qq.com',\n x_requested_with: 'XMLHttpRequest'\n }\n resource = RestClient::Resource.new(@home_url, headers: headers, cookies: @cookies)\n\n res = resource[uri].post msg_params_with_name\n # \"ret\":\"0\", \"msg\":\"preview send success!\", \"appMsgId\":\"201796045\", \"fakeid\":\"\"\n JSON.parse res.to_s\n end",
"def review_posted(email,permalink) \n @service_permalink = permalink \n subject = \"A review was posted for your service\"\n setup_email(email, subject)\n end",
"def preview_cover\n preview_path = \"#{PDF_PREVIEW_FOLDER}/preview_cover-#{current_cookbook.id}_#{Time.now.to_i}.pdf\"\n session[:preview_filename] = preview_path\n preview = CookbookPreviewWorker.new(\n cookbook: current_cookbook, \n filename: preview_path\n )\n preview.cover\n render \"previews/preview\"\n end",
"def emailOnReview(revieweeId)\r\n puts \"we are in email on review\"\r\n @team_member = TeamsUser.find_all_by_team_id(revieweeId)\r\n asstId = Team.find_by_id(revieweeId).parent_id\r\n assignment=Assignment.find_by_id(asstId).name\r\n partialName=\"email_on_review\"\r\n @team_member.each do |team_Member|\r\n # get parameters for sending mail\r\n user=User.find_by_id(team_Member.user_id)\r\n puts \"teammate name = #(user.name)\"\r\n if(user.email_on_review)\r\n email(user.email,\"Review\",ApplicationHelper::get_user_first_name(user),assignment,partialName)\r\n end\r\n end\r\n end",
"def preview_edit\n\n layout_style = nil\n if (params[:layout])\n layout_style = params[:layout]\n end\n\n\n begin\n @bulletin = Bulletin.find(params[:id])\n @bulletin_layout = @bulletin.layout_for_editing(layout_style, self)\n headers[\"Content-Type\"] = @bulletin_layout.filetype + \"; charset=\" + @bulletin_layout.charset\n render :text => @bulletin_layout.rendered, :layout => 'bulletin'\n return\n rescue SyntaxError\n @error = _('A fatal error has occurred while compiling the temlpate!') + \n '<br /><br />ERROR: '+$!\n end\n render :action => 'error', :layout => 'bulletin'\n end"
] | [
"0.71475905",
"0.71186084",
"0.70552814",
"0.6985626",
"0.6848472",
"0.6848472",
"0.6832406",
"0.6663229",
"0.64324814",
"0.631654",
"0.6304366",
"0.6181875",
"0.6167911",
"0.61338973",
"0.61305445",
"0.6115152",
"0.61100966",
"0.61100966",
"0.60882556",
"0.60132533",
"0.5982547",
"0.5970752",
"0.5921947",
"0.5854165",
"0.58256847",
"0.58256847",
"0.5801412",
"0.5798907",
"0.57861274",
"0.5756108",
"0.57435614",
"0.57311475",
"0.5694853",
"0.5693586",
"0.56733876",
"0.56689703",
"0.5667859",
"0.56230783",
"0.5584482",
"0.5580056",
"0.556691",
"0.5565034",
"0.553256",
"0.55282027",
"0.5521174",
"0.55182135",
"0.54865557",
"0.54802716",
"0.54802716",
"0.5475045",
"0.54698133",
"0.5462231",
"0.54592174",
"0.5457588",
"0.54561025",
"0.5434102",
"0.54326165",
"0.5418592",
"0.5416024",
"0.5406969",
"0.5398783",
"0.5398783",
"0.5390498",
"0.53865004",
"0.53677875",
"0.5354904",
"0.53483963",
"0.53450906",
"0.53428084",
"0.5339015",
"0.5331245",
"0.5324016",
"0.5320464",
"0.52986485",
"0.52971554",
"0.52956325",
"0.52885884",
"0.52866477",
"0.52858466",
"0.52848935",
"0.5274558",
"0.52651525",
"0.5261375",
"0.5255958",
"0.52543974",
"0.52372897",
"0.52372897",
"0.5235101",
"0.522828",
"0.5226132",
"0.5213765",
"0.52118236",
"0.52118236",
"0.52064675",
"0.5192629",
"0.5186882",
"0.5167913",
"0.51622766",
"0.5158241",
"0.515572",
"0.5152641"
] | 0.0 | -1 |
GET /mensajes or /mensajes.json | def index
@mensajes = Mensaje.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @mesasredondas = Mesasredonda.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @mesasredondas }\n end\n end",
"def index\n @mentor_messages = MentorMessage.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @mentor_messages }\n end\n end",
"def show\n @mensaje = Mensaje.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mensaje }\n end\n end",
"def index\n @mencions = Mencion.order(\"escuela_id\").paginate(:page => params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @mencions }\n end\n end",
"def index\n messages = Message.all\n render json: messages\n end",
"def index\n @messies = Messy.all\n\n render json: @messies\n end",
"def index\n @messages = Message.all\n render json: @messages\n end",
"def index\n @messages = Message.all\n render json: @messages\n end",
"def index\n @messages = Message.all\n\n render json: @messages\n end",
"def get_modelos\n marca = Marca.find(params[:marca_id])\n @modelos = Modelo.of_marca(marca.id)\n\n render json: @modelos\n\n end",
"def index\n @messages = Message.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @messages }\n end\n end",
"def index\n @messages = Message.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @messages }\n end\n end",
"def index\n @messages = Message.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @messages }\n end\n end",
"def index\n @messages = message.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @messages }\n end\n end",
"def index\n render json: Message.all\n end",
"def index\n @mensagens = Mensagem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @mensagens }\n end\n end",
"def index\n @municipios = Municipio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @municipios }\n end\n end",
"def index\n @mod_messages = ModMessage.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @mod_messages }\n end\n end",
"def index\n\t\t@messages = Message.all.order('created_at DESC')\n\t\trespond_to do |format|\n\t\t\tformat.html\n\t\t\tformat.json { render json: @messages }\n\t\tend\n\tend",
"def index\n @mensagems = Mensagem.all\n end",
"def index\n @mensagens = Mensagem.all\n end",
"def index\n render json: { \"Exercice Technique\" => \"Transporter Organizations Colisweb backend developer exercise\", \"Poste visé\" => \"Développeur Back Ruby, Alternance\", \"Candidat\" => \"Gressier Jimmy\"}\n end",
"def index\n @messages = Message.all\n respond_to do |format|\n format.html { render :index }\n format.json { render :json => @messages}\n end\n end",
"def index\n @empresas = Empresa.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @empresas }\n end\n end",
"def index\n @listes = Liste.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @listes }\n end\n end",
"def show\n @mensaje_usuario = MensajeUsuario.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mensaje_usuario }\n end\n end",
"def index\n @messages = current_user.received_messages.paginate(:page => params[:page])\n @title = \"Входящие сообщения\"\n @path = \"index\"\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @messages }\n end\n end",
"def index\n @materias = Materia.paginate(:page => params[:page], :per_page => 10)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @materias }\n end\n end",
"def new\n @mensaje_usuario = MensajeUsuario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mensaje_usuario }\n end\n end",
"def index\n @jokes = Joke.all\n flash[:notice] = '测试消息'\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @jokes }\n end\n end",
"def new\n @motivobaja = MotivoBaja.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @motivobaja }\n end\n end",
"def index\n @languages = Language.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @languages }\n end\n end",
"def index\n @projetos = Projeto.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projetos }\n end\n end",
"def index\n @majors = majors\n respond_to do |format|\n format.json{\n return render json: ret\n }\n end\n end",
"def index\n @mercado_meta = MercadoMetum.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @mercado_meta }\n end\n end",
"def index\n @ores = Ore.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ores }\n end\n end",
"def index\r\n @imobiliarias = Imobiliaria.all\r\n\r\n respond_to do |format|\r\n # format.html # index.html.erb\r\n format.json { render json: @imobiliarias }\r\n end\r\n end",
"def index\n @postos = Posto.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @postos }\n end\n end",
"def index\n @detalles = Detalle.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @detalles }\n end\n end",
"def index\n @unidade_medidas = UnidadeMedida.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @unidade_medidas }\n end\n end",
"def index\n @palestrantes = Palestrante.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @palestrantes }\n end\n end",
"def index\n raise ApiAccessEvanta::PermissionDenied unless AppSettings::Value.new(:messages, user: current_user).on?\n @messages = Message.get_message_list(current_user)\n render json: @messages\n end",
"def index\n @clientes = Cliente.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clientes }\n end\n end",
"def index\n @relaciones_articulos_medida = RelacionArticuloMedida.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @relaciones_articulos_medida }\n end\n end",
"def show\n @motivobaja = MotivoBaja.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @motivobaja }\n end\n end",
"def get_all\n if @messages = Message.all\n render json: @messages\n else\n render json: \"Error!\"\n end\n\n end",
"def index\n @programmes = Programme.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @programmes }\n end\n end",
"def get_messages\n \tuser = User.find(params[:user_id]);\n \tif user\n \t\tmessages = Message.where(message_type: user.user_type)\n \t\tconversation = Conversation.where(request_id: params[:request_id])\n texts = []\n conversation.each{ |msg| texts.push(Message.find_by(id: msg.message_id) ? Message.find(msg.message_id) : {})}\n \t\trender json: {messages: messages, conversation: conversation, texts: texts}\n \telse\n\t\trender json: {error: 'User not found.'}\n \tend\n end",
"def index\n autentica_especial\n authorize! :read, Sal7711Gen::Articulo\n prepara_meses\n @muestraid = params[:muestraid].to_i\n if params.to_unsafe_h.count > 2\n # 2 params que siempre estan son controller y action si hay\n # más sería una consulta iniciada por usuario\n prepara_pagina\n Sal7711Gen::Bitacora.a( request.remote_ip, current_usuario, \n 'index', params)\n end\n respond_to do |format|\n format.html { }\n format.json { head :no_content }\n format.js { render 'resultados' }\n end\n end",
"def index\n @vehicule_persos = VehiculePerso.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @vehicule_persos }\n end\n end",
"def index\n @message_posts = MessagePost.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @message_posts }\n end\n end",
"def index\n @kraje = Kraj.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @kraje }\n end\n end",
"def index\n @conseilles = Conseille.all\n respond_to do |format|\n format.html\n format.json { render json: @conseilles}\n end\n end",
"def index\n @jogos = Jogo.por_titulo(params[:titulo])\n end",
"def index\n #@messages = Message.all\n \n @messages = Message.page(params[:page]).order(\"created_at DESC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @messages }\n end\n end",
"def index\n @ultimo_grado_de_estudios = UltimoGradoDeEstudio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ultimo_grado_de_estudios }\n end\n end",
"def index\n @mensagens = Mensagem.where campanha: @campanha\n end",
"def index\n @deporte_usuarios = DeporteUsuario.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @deporte_usuarios }\n end\n end",
"def messages\n get_json('messages.json')\n end",
"def index\n @programa_de_interes = ProgramaDeIntere.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @programa_de_interes }\n end\n end",
"def index\n @puntajes = Puntaje.order('created_at DESC').all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @puntajes }\n end\n end",
"def index\n @replies = Reply.all\n\n render json: @replies\n end",
"def index\n @replies = Reply.all\n\n render json: @replies\n end",
"def index\n\t\trender json: { prueba: 'Funciona'}\n\tend",
"def index\n @messages = Message.order(\"time desc\").page params[:page]\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @messages }\n end\n end",
"def show\n @mesasredonda = Mesasredonda.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mesasredonda }\n end\n end",
"def index\n @reprogramaciones = Reprogramacion.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reprogramaciones }\n end\n end",
"def index\n\n if params[:user_id]\n @messages = Message.where(:user_id => params[:user_id].to_i)\n else\n @messages = Message.all\n end\n if params[:page] and params[:per_page]\n @messages = @messages.paginate(:per_page=>params[:per_page].to_i,:page=>params[:page].to_i).order(\"id desc\")\n @page = params[:page]\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :messages }\n end\n end",
"def index\n @adversaires = Adversaire.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @adversaires }\n end\n end",
"def show\n @respuesta = Respuesta.find(params[:id])\n\n render json: @respuesta\n end",
"def index\n @you_owe_mes = YouOweMe.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @you_owe_mes }\n end\n end",
"def index\n seleccionarMenu(:juzgados)\n @juzgados = Juzgado.order(:ciudad_id)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @juzgados }\n end\n end",
"def index\n @contas = Conta.all\n respond_to do |format|\n format.json { render json: @contas.to_json, status: :ok }\n end\n end",
"def index \n @lancamentorapido = Lancamentorapido.new \n @lancamentorapidos = Lancamentorapido.all\n \n @categorias = Category.all\n @centrosdecusto = Centrodecusto.all \n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @lancamentorapidos }\n end\n end",
"def index\n @articles = Article.all\n\n respond_to do |format|\n format.json { render json: @articles }\n end\n end",
"def index\n @municipio_de_la_preparatoria_o_universidad_de_origens = MunicipioDeLaPreparatoriaOUniversidadDeOrigen.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @municipio_de_la_preparatoria_o_universidad_de_origens }\n end\n end",
"def index\n @jidos = Jido.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @jidos }\n end\n end",
"def index\n @minicursos = Minicurso.all\n\t\t#@minicursos = Minicurso.scoped\n\t\t#@users = Minicurso.inscritos(params[:id]) if params[:id].present?\n\n respond_to do |format|\n\t\t\t format.html # index.html.erb\n\t\t\t format.json { render json: @minicursos }\n end\n end",
"def index\n @articles = Article.all\n raise if @articles.blank?\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @articles }\n end\n end",
"def list\n if params[:search]\n articles = Article.where(status: \"accepted\")\n .where('lower(title) LIKE ?', \"%#{params[:search].downcase}%\")\n .paginate(page: params[:page], per_page: params[:limit] || 10)\n else\n articles = Article.where(status: \"accepted\")\n .paginate(page: params[:page], per_page: params[:limit] || 10)\n end\n render json: articles, \n only: [ :id, :title, :created_at, :tags ], \n methods: [ :pictures, :created_by ], \n status: :ok\n end",
"def mens\n mens = Inventory.where(mens == true)\n render json: mens\n end",
"def show\n @mecanicacomplejo = Mecanicacomplejo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mecanicacomplejo }\n end\n end",
"def new\n @respuesta = Respuesta.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @respuesta }\n end\n end",
"def index\n @pedidos = Pedido.find(:all, :conditions => [\"cliente_id=?\", session[:usuario_id]])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pedidos }\n end\n end",
"def new\n @personaje_mision = PersonajeMision.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @personaje_mision }\n end\n end",
"def index\n @pagamentos = Pagamento.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pagamentos }\n end\n end",
"def new\n @jornada = Jornada.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @jornada }\n end\n end",
"def index\n @tutorados = Tutorado.all\n\n render json: @tutorados, status: :ok\n end",
"def index\n @rooms = Room.all\n respond_to do | format |\n format.html\n format.json\n end\n \n end",
"def new\n @ejercicio = Ejercicio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ejercicio }\n end\n end",
"def index\n @powiadomienia = Powiadomienie.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @powiadomienia }\n end\n end",
"def index\n @puntajes = Puntaje.paginate(:page => params[:page], :per_page => 10)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @puntajes }\n end\n end",
"def index\n @listas_contato = ListaContato.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @listas_contato }\n end\n end",
"def index\n @ativo_outros = AtivoOutro.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ativo_outros }\n end\n end",
"def show\n @respuesta = Respuesta.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @respuesta }\n end\n end",
"def index\n respond_to :html, :json\n @organismes = Organisme.all\n end",
"def show\n @article = Article.find(params[:id])\n\n @memos = Memo.find_all_by_article_id(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @article }\n end\n end",
"def emergencias_en_curso\n @emergencies = Emergency.where(:estado => 'f')\n render json: @emergencies\n end",
"def new\n @musique = Musique.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @musique }\n end\n end",
"def new\n seleccionarMenu(:juzgados)\n @juzgado = Juzgado.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @juzgado }\n end\n end"
] | [
"0.6474655",
"0.64470345",
"0.6349967",
"0.6340613",
"0.6273685",
"0.6273383",
"0.6195066",
"0.6195066",
"0.6179346",
"0.6155237",
"0.6123657",
"0.611505",
"0.61145943",
"0.61027575",
"0.60651505",
"0.6064412",
"0.60322434",
"0.60308146",
"0.6023947",
"0.6022994",
"0.60214525",
"0.60125875",
"0.60017836",
"0.5994963",
"0.5985871",
"0.59809655",
"0.5964489",
"0.5959593",
"0.5950151",
"0.59453803",
"0.5930876",
"0.5915245",
"0.59079295",
"0.5901464",
"0.5896576",
"0.5895651",
"0.589353",
"0.58818495",
"0.5873211",
"0.58587384",
"0.58569527",
"0.5856534",
"0.58562815",
"0.58520156",
"0.58433324",
"0.5836932",
"0.58269745",
"0.582421",
"0.58191574",
"0.58167416",
"0.5804028",
"0.5802061",
"0.57981104",
"0.5794666",
"0.5790862",
"0.5786169",
"0.5782862",
"0.57770807",
"0.5775174",
"0.5773707",
"0.57721394",
"0.57461923",
"0.57461923",
"0.57362455",
"0.5735194",
"0.5722996",
"0.5710393",
"0.5705251",
"0.57047987",
"0.57045573",
"0.570037",
"0.56971717",
"0.56883126",
"0.5678445",
"0.56767493",
"0.5674409",
"0.567402",
"0.5672658",
"0.5666944",
"0.56654596",
"0.5661883",
"0.56569326",
"0.56560165",
"0.5653352",
"0.564997",
"0.5647178",
"0.5635839",
"0.5631991",
"0.5627891",
"0.5617133",
"0.5615763",
"0.56146806",
"0.56140864",
"0.5612838",
"0.56119347",
"0.56076825",
"0.56076014",
"0.5606566",
"0.560546",
"0.5605146"
] | 0.64247584 | 2 |
GET /mensajes/1 or /mensajes/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @mensaje = Mensaje.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mensaje }\n end\n end",
"def show\n @motivobaja = MotivoBaja.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @motivobaja }\n end\n end",
"def index\n @mesasredondas = Mesasredonda.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @mesasredondas }\n end\n end",
"def index\n @mencions = Mencion.order(\"escuela_id\").paginate(:page => params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @mencions }\n end\n end",
"def show\n @mensaje_usuario = MensajeUsuario.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mensaje_usuario }\n end\n end",
"def show\n @respuesta = Respuesta.find(params[:id])\n\n render json: @respuesta\n end",
"def get_modelos\n marca = Marca.find(params[:marca_id])\n @modelos = Modelo.of_marca(marca.id)\n\n render json: @modelos\n\n end",
"def index\n @messies = Messy.all\n\n render json: @messies\n end",
"def show\n @mecanicacomplejo = Mecanicacomplejo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mecanicacomplejo }\n end\n end",
"def index\n @majors = majors\n respond_to do |format|\n format.json{\n return render json: ret\n }\n end\n end",
"def new\n @motivobaja = MotivoBaja.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @motivobaja }\n end\n end",
"def show\n @musique = Musique.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @musique }\n end\n end",
"def show\n @respuesta = Respuesta.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @respuesta }\n end\n end",
"def show\n @metodo = Metodo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @metodo }\n end\n end",
"def show\n @jm_verse = JmVerse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @jm_verse }\n end\n end",
"def show\n @jugador = Jugador.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @jugador }\n end\n end",
"def show\n @jornada = Jornada.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @jornada }\n end\n end",
"def show\n @mesasredonda = Mesasredonda.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mesasredonda }\n end\n end",
"def index\n render json: { \"Exercice Technique\" => \"Transporter Organizations Colisweb backend developer exercise\", \"Poste visé\" => \"Développeur Back Ruby, Alternance\", \"Candidat\" => \"Gressier Jimmy\"}\n end",
"def index\n @materias = Materia.paginate(:page => params[:page], :per_page => 10)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @materias }\n end\n end",
"def show\n @mapeamento = Mapeamento.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mapeamento }\n end\n end",
"def show\n @personaje_mision = PersonajeMision.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @personaje_mision }\n end\n end",
"def index\n messages = Message.all\n render json: messages\n end",
"def index\n @mensajes = Mensaje.all\n end",
"def index\n @projetos = Projeto.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projetos }\n end\n end",
"def show\n @minimessage = Minimessage.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @minimessage }\n end\n end",
"def index\n @mentor_messages = MentorMessage.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @mentor_messages }\n end\n end",
"def index\n @answers = Answer.where(url_params)\n if @answers.size == 1\n @answers.first!\n end\n render json: @answers\n end",
"def index\n @mercado_meta = MercadoMetum.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @mercado_meta }\n end\n end",
"def new\n @mensaje_usuario = MensajeUsuario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mensaje_usuario }\n end\n end",
"def show\n if not @mission = Mission.find(params[:id])\n render json: \"Mission not found for id: \" + params[:id]\n else\n respond_to do |format|\n format.json { render json: @mission }\n format.xml { render xml: @mission }\n end\n end\n end",
"def show\r\n @imobiliaria = Imobiliaria.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.json { render json: @imobiliaria }\r\n end\r\n end",
"def index\n @jogos = Jogo.por_titulo(params[:titulo])\n end",
"def show\n @article = Article.find(params[:id])\n\n @memos = Memo.find_all_by_article_id(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @article }\n end\n end",
"def show\n @modelo = Modelo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @modelo }\n end\n end",
"def index\n @messages = Message.all\n render json: @messages\n end",
"def index\n @messages = Message.all\n render json: @messages\n end",
"def index\r\n @imobiliarias = Imobiliaria.all\r\n\r\n respond_to do |format|\r\n # format.html # index.html.erb\r\n format.json { render json: @imobiliarias }\r\n end\r\n end",
"def index\n @messages = Message.all\n\n render json: @messages\n end",
"def new\n @jamaat = Jamaat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @jamaat }\n end\n end",
"def show\n @v1_message = V1::Message.find(params[:id])\n\n render json: @v1_message\n end",
"def show\n @mision = Mision.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mision }\n end\n end",
"def index\n @mensagens = Mensagem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @mensagens }\n end\n end",
"def show\n @jamaat = Jamaat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @jamaat }\n end\n end",
"def index\n @messages = Message.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @messages }\n end\n end",
"def index\n @messages = Message.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @messages }\n end\n end",
"def new\n @musique = Musique.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @musique }\n end\n end",
"def index\n autentica_especial\n authorize! :read, Sal7711Gen::Articulo\n prepara_meses\n @muestraid = params[:muestraid].to_i\n if params.to_unsafe_h.count > 2\n # 2 params que siempre estan son controller y action si hay\n # más sería una consulta iniciada por usuario\n prepara_pagina\n Sal7711Gen::Bitacora.a( request.remote_ip, current_usuario, \n 'index', params)\n end\n respond_to do |format|\n format.html { }\n format.json { head :no_content }\n format.js { render 'resultados' }\n end\n end",
"def index\n @programmes = Programme.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @programmes }\n end\n end",
"def index\n @municipios = Municipio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @municipios }\n end\n end",
"def index\n @clientes = Cliente.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clientes }\n end\n end",
"def new\n @personaje_mision = PersonajeMision.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @personaje_mision }\n end\n end",
"def index\n @messages = Message.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @messages }\n end\n end",
"def show\n @monnaie = Monnaie.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @monnaie }\n end\n end",
"def show\n @mensaje = Mensaje.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @mensaje }\n end\n end",
"def index\n @detalles = Detalle.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @detalles }\n end\n end",
"def new\n @jornada = Jornada.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @jornada }\n end\n end",
"def new\n @respuesta = Respuesta.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @respuesta }\n end\n end",
"def show\n @mencion = Mencion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mencion }\n end\n end",
"def index\n @ores = Ore.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ores }\n end\n end",
"def index\n @listes = Liste.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @listes }\n end\n end",
"def show\n @personaje = Personaje.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @personaje }\n end\n end",
"def show\n @mission = Mission.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mission }\n end\n end",
"def index\n @mod_messages = ModMessage.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @mod_messages }\n end\n end",
"def show\n @materia = Materia.find(params[:id])\n\n render json: @materia\n end",
"def new\n @personaje = Personaje.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @personaje }\n end\n end",
"def index\n render json: Message.all\n end",
"def index\n @messages = message.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @messages }\n end\n end",
"def new\n @metodo = Metodo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @metodo }\n end\n end",
"def index\n @kraje = Kraj.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @kraje }\n end\n end",
"def index\n @programa_de_interes = ProgramaDeIntere.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @programa_de_interes }\n end\n end",
"def index\n @unidade_medidas = UnidadeMedida.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @unidade_medidas }\n end\n end",
"def index\n\t\trender json: { prueba: 'Funciona'}\n\tend",
"def show\n @mission = Mission.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @mission }\n end\n end",
"def show\n seleccionarMenu(:juzgados)\n @juzgado = Juzgado.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @juzgado }\n end\n end",
"def show\n @mutacao = Mutacao.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mutacao }\n end\n end",
"def show\n @ejercicio = Ejercicio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ejercicio }\n end\n end",
"def show\n @lieu = Lieu.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lieu }\n end\n end",
"def show\n @kolegij = Kolegij.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kolegij }\n end\n end",
"def new\n @ejercicio = Ejercicio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ejercicio }\n end\n end",
"def show\n @nominee = Nominee.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @nominee }\n end\n end",
"def index\n @empresas = Empresa.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @empresas }\n end\n end",
"def show\n @messege = Messege.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @messege }\n end\n end",
"def new\n @jm_verse = JmVerse.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @jm_verse }\n end\n end",
"def show\n @mensagem = Mensagem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @mensagem }\n end\n end",
"def show\n @mensagem = Mensagem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @mensagem }\n end\n end",
"def show\n @message = Message.find(params[:id])\n render json: @message\n\n end",
"def new\n @servicio = Servicio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @servicio }\n end\n end",
"def show\n @kolegiji = Kolegiji.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kolegiji }\n end\n end",
"def index\n @relaciones_articulos_medida = RelacionArticuloMedida.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @relaciones_articulos_medida }\n end\n end",
"def show\n \n respond_to do |format|\n format.html\n #format.json {render json: @jiras}\n\n end\n end",
"def find_client\n cliente = get_cliente(params[:id])\n\n respond_to do |format|\n format.json {render json: {client: cliente}}\n end\n end",
"def index\n @ultimo_grado_de_estudios = UltimoGradoDeEstudio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ultimo_grado_de_estudios }\n end\n end",
"def show\n @cerveja = Cerveja.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cerveja }\n end\n end",
"def show\n @materia = Materia.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @materia }\n end\n end",
"def index\n @conseilles = Conseille.all\n respond_to do |format|\n format.html\n format.json { render json: @conseilles}\n end\n end",
"def show\n @mercado_metum = MercadoMetum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mercado_metum }\n end\n end",
"def index\n @jidos = Jido.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @jidos }\n end\n end",
"def show\n @puntaje = Puntaje.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @puntaje }\n end\n end",
"def show\n @puntaje = Puntaje.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @puntaje }\n end\n end",
"def mens\n mens = Inventory.where(mens == true)\n render json: mens\n end"
] | [
"0.6719897",
"0.63115054",
"0.6285699",
"0.6268227",
"0.62421393",
"0.6217299",
"0.6213858",
"0.6188329",
"0.613486",
"0.6119665",
"0.6099896",
"0.6078144",
"0.606392",
"0.6054196",
"0.6044381",
"0.601308",
"0.60050523",
"0.6003318",
"0.59999484",
"0.5986368",
"0.5976768",
"0.5967718",
"0.59332967",
"0.5932887",
"0.5927944",
"0.5927531",
"0.59249693",
"0.59244007",
"0.591622",
"0.5907322",
"0.5901904",
"0.5887197",
"0.58845335",
"0.58826166",
"0.58820856",
"0.5870357",
"0.5870357",
"0.5867277",
"0.5867077",
"0.58549243",
"0.5852777",
"0.58505994",
"0.5847748",
"0.58440685",
"0.58382386",
"0.5838118",
"0.58374107",
"0.58365357",
"0.5835802",
"0.5835297",
"0.5829221",
"0.5828226",
"0.58276916",
"0.5821516",
"0.5817961",
"0.58172536",
"0.5813665",
"0.5811229",
"0.5805655",
"0.5802587",
"0.5801225",
"0.5797581",
"0.5794665",
"0.57944363",
"0.5789614",
"0.5786798",
"0.5786054",
"0.57824886",
"0.57813567",
"0.57727176",
"0.5772509",
"0.5765966",
"0.5763452",
"0.5756594",
"0.5755245",
"0.5753412",
"0.575251",
"0.5745858",
"0.57370687",
"0.57355845",
"0.57354575",
"0.5734213",
"0.57301366",
"0.5727144",
"0.57223225",
"0.57223225",
"0.57213587",
"0.5716641",
"0.57131726",
"0.57127917",
"0.571226",
"0.571208",
"0.570766",
"0.57059574",
"0.57053113",
"0.5704307",
"0.5702106",
"0.5700627",
"0.5700441",
"0.5700441",
"0.57000345"
] | 0.0 | -1 |
POST /mensajes or /mensajes.json | def create
@mensaje = Mensaje.new(mensaje_params)
respond_to do |format|
if @mensaje.save
format.html { redirect_to @mensaje, notice: "Mensaje was successfully created." }
format.json { render :show, status: :created, location: @mensaje }
else
format.html { render :new, status: :unprocessable_entity }
format.json { render json: @mensaje.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @mensagem = Mensagem.new(params[:mensagem])\n @mensagem.autor = session[:current_user]\n id_to_post = String.new\n \n case @mensagem.recebedor_type\n when \"Turma\"\n aux = Turma.find(@mensagem.recebedor_id)\n id_to_post = aux.group_id\n end\n \n @mensagem.post_id = api_client.put_wall_post(@mensagem.conteudo, {}, id_to_post)['id']\n\n respond_to do |format|\n if @mensagem.save\n #format.html { redirect_to(@mensagem, :notice => 'Mensagem was successfully created.') }\n format.xml { render :xml => @mensagem, :status => :created, :location => @mensagem }\n format.js {}\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @mensagem.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @mensagem = Mensagem.new(mensagem_params)\n\n respond_to do |format|\n if @mensagem.save\n format.html { redirect_to @mensagem.presente.lista, notice: 'Mensagem Adicionada. Após aprovação do proprietário da lista será exibida.' }\n format.json { render action: 'show', status: :created, location: @mensagem }\n else\n format.html { render action: 'new' }\n format.json { render json: @mensagem.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @mensagem = @campanha.mensagens.create(mensagem_params)\n\n @mensagem.enviada = false\n\n respond_to do |format|\n if @mensagem.save\n format.html do\n redirect_to campanha_mensagem_path(@campanha, @mensagem), notice: {\n type: 'info',\n message: 'Mensagem adicionada com sucesso.'\n }\n end\n format.json { render :show, status: :created, location: @mensagem }\n else\n format.html { render :new }\n format.json { render json: @mensagem.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @respuesta = Respuesta.new(params[:respuesta])\n\n if @respuesta.save\n render json: @respuesta, status: :created, location: @respuesta\n else\n render json: @respuesta.errors, status: :unprocessable_entity\n end\n end",
"def create\n @mensaje_usuario = MensajeUsuario.new(params[:mensaje_usuario])\n\n respond_to do |format|\n if @mensaje_usuario.save\n format.html { redirect_to @mensaje_usuario, notice: 'Mensaje usuario was successfully created.' }\n format.json { render json: @mensaje_usuario, status: :created, location: @mensaje_usuario }\n else\n format.html { render action: \"new\" }\n format.json { render json: @mensaje_usuario.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @mensagem = Mensagem.new(params[:mensagem])\n\n respond_to do |format|\n if @mensagem.save\n flash[:notice] = 'Mensagem was successfully created.'\n format.html { redirect_to(@mensagem) }\n format.xml { render :xml => @mensagem, :status => :created, :location => @mensagem }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @mensagem.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def moip_post\n @nasp_rail = NaspRail.new(params[:nasp_rail])\n\n format.html { redirect_to @nasp_rail, :notice => 'Nova entrada criada com sucesso.' }\n format.json { render :json => @nasp_rail, :status => :created, :location => @nasp_rail }\n end",
"def create\n @jornada = Jornada.new(params[:jornada])\n\n respond_to do |format|\n if @jornada.save\n format.html { redirect_to jornadas_path, notice: 'La jornada se ha creado correctamente' }\n format.json { render json: @jornada, status: :created, location: @jornada }\n else\n format.html { render action: \"new\" }\n format.json { render json: @jornada.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @misione = Misione.new(misione_params)\n\n respond_to do |format|\n if @misione.save\n format.html { redirect_to @misione, notice: 'Misione was successfully created.' }\n format.json { render :show, status: :created, location: @misione }\n else\n format.html { render :new }\n format.json { render json: @misione.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @motivobaja = MotivoBaja.new(motivo_baja_params)\n\n respond_to do |format|\n if @motivobaja.save\n format.html { redirect_to @motivobaja, notice: 'Motivo Baja was successfully created.' }\n format.json { render json: @motivobaja, status: :created, location: @motivobaja }\n else\n format.html { render action: \"new\" }\n format.json { render json: @motivobaja.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @objetos_mensura = ObjetosMensura.new(objetos_mensura_params)\n\n respond_to do |format|\n if @objetos_mensura.save\n format.html { redirect_to @objetos_mensura, notice: 'Objetos mensura was successfully created.' }\n format.json { render :show, status: :created, location: @objetos_mensura }\n else\n format.html { render :new }\n format.json { render json: @objetos_mensura.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post(content)\n post_to(\"/api/v1/messages/\", {:body => content})\n end",
"def create\n @respuesta = Respuesta.new(params[:respuesta])\n\n respond_to do |format|\n if @respuesta.save\n format.html { redirect_to @respuesta, notice: 'Respuesta was successfully created.' }\n format.json { render json: @respuesta, status: :created, location: @respuesta }\n else\n format.html { render action: \"new\" }\n format.json { render json: @respuesta.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @mensaje_usuario = MensajeUsuario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mensaje_usuario }\n end\n end",
"def POST; end",
"def create\n # @answer = Answer.new\n # @answer.user_id = current_user.もid\n # @answer.question_id = params[:question_id]\n # @answer.content = params[:content]\n # @answer.save\n # 一個保存できれば、何個でも保存できる\n if !params[:answer][:content]\n render json: {errors: \"未入力の項目があります。\"}, status: 422\n\n end\n @answer = current_user.answers.build(answer_params)\n @answer.save\n end",
"def create\n @metodo = Metodo.new(params[:metodo])\n\n respond_to do |format|\n if @metodo.save\n format.html { redirect_to metodos_url }\n format.json { render json: @metodo, status: :created, location: @metodo }\n else\n format.html { render action: \"new\" }\n format.json { render json: @metodo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @personaje_mision = PersonajeMision.new(params[:personaje_mision])\n\n respond_to do |format|\n if @personaje_mision.save\n format.html { redirect_to @personaje_mision, notice: 'Personaje mision was successfully created.' }\n format.json { render json: @personaje_mision, status: :created, location: @personaje_mision }\n else\n format.html { render action: \"new\" }\n format.json { render json: @personaje_mision.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n params.permit(:intitule, :estObligatoire, :nombreDeCaractere, :ordre, :sondage_id)\n ajout = QuestionOuverteService.instance.creerQuestionOuverte(params[:intitule], params[:estObligatoire], params[:nombreDeCaractere], params[:ordre], params[:sondage_id])\n (ajout != nil) ? (render json: ajout, status: :ok) : (render json: nil, status: :not_found)\n end",
"def create\n @posto = Posto.new(params[:posto])\n\n respond_to do |format|\n if @posto.save\n format.html { redirect_to @posto, notice: 'Posto de Saude cadastrado com sucesso' }\n format.json { render json: @posto, status: :created, location: @posto }\n else\n format.html { render action: \"new\" }\n format.json { render json: @posto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @marca = Marca.new(marca_params)\n if @marca.save\n render json: @marca\n else\n render json: @marca.errors, status: :unprocessable_entity \n end\n end",
"def create\n params.permit(:pseudo_administrateur, :email_administrateur, :motDePasse_administrateur)\n ajout = AdministrateurService.instance.creerNouveauAdmin(params[:pseudo_administrateur], params[:email_administrateur], params[:motDePasse_administrateur])\n (ajout != nil) ? (render json: ajout, status: :ok) : (render json: nil, status: :not_found)\n end",
"def create\n @mencion = Mencion.new(params[:mencion])\n\n respond_to do |format|\n if @mencion.save\n format.html { redirect_to @mencion, notice: 'Mencion creada' }\n format.json { render json: @mencion, status: :created, location: @mencion }\n else\n format.html { render action: \"new\" }\n format.json { render json: @mencion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @municao = Municao.new(municao_params)\n\n respond_to do |format|\n if @municao.save\n format.html { redirect_to @municao, notice: 'A Munição foi criada com sucesso!' }\n format.json { render :show, status: :created, location: @municao }\n else\n format.html { render :new }\n format.json { render json: @municao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @manteni = Manteni.new(manteni_params)\n\n respond_to do |format|\n if @manteni.save\n format.html { redirect_to @manteni, notice: 'Manteni was successfully created.' }\n format.json { render :show, status: :created, location: @manteni }\n else\n format.html { render :new }\n format.json { render json: @manteni.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @metodologia = Metodologia.new(metodologia_params)\n\n respond_to do |format|\n if @metodologia.save\n format.html { redirect_to @metodologia, notice: 'Metodologia was successfully created.' }\n format.json { render action: 'show', status: :created, location: @metodologia }\n else\n format.html { render action: 'new' }\n format.json { render json: @metodologia.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @mijnwerknemer = Mijnwerknemer.new(mijnwerknemer_params)\n\n respond_to do |format|\n if @mijnwerknemer.save\n format.html { redirect_to @mijnwerknemer, notice: 'Mijnwerknemer was successfully created.' }\n format.json { render action: 'show', status: :created, location: @mijnwerknemer }\n else\n format.html { render action: 'new' }\n format.json { render json: @mijnwerknemer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @motivobaja = MotivoBaja.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @motivobaja }\n end\n end",
"def create\n @mundo = Mundo.new(mundo_params)\n\n respond_to do |format|\n if @mundo.save\n format.html { redirect_to @mundo, notice: 'Mundo was successfully created.' }\n format.json { render :show, status: :created, location: @mundo }\n else\n format.html { render :new }\n format.json { render json: @mundo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @mapeamento = Mapeamento.new(params[:mapeamento])\n\n respond_to do |format|\n if @mapeamento.save\n format.html { redirect_to @mapeamento, notice: 'Mapeamento was successfully created.' }\n format.json { render json: @mapeamento, status: :created, location: @mapeamento }\n else\n format.html { render action: \"new\" }\n format.json { render json: @mapeamento.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @mensaje = Mensaje.new(params[:mensaje])\n \n respond_to do |format|\n if @mensaje.save\n flash[:notice] = 'Mensaje creada correctamente.'\n format.html { params[:oper].nil? ? redirect_to(@mensaje) : render(:text => \"Ok\")}\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @mensaje.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @motivo = Motivo.new(motivo_params)\n\n respond_to do |format|\n if @motivo.save\n format.html { redirect_to @motivo, notice: 'Motivo was successfully created.' }\n format.json { render :show, status: :created, location: @motivo }\n else\n format.html { render :new }\n format.json { render json: @motivo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @mantenimiento = Mantenimiento.new(mantenimiento_params)\n\n respond_to do |format|\n if @mantenimiento.save\n format.html { redirect_to @mantenimiento, notice: 'Mantenimiento was successfully created.' }\n format.json { render action: 'show', status: :created, location: @mantenimiento }\n else\n format.html { render action: 'new' }\n format.json { render json: @mantenimiento.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @apertura_moneda = AperturaMoneda.new(apertura_moneda_params)\n\n respond_to do |format|\n if @apertura_moneda.save\n format.html { redirect_to @apertura_moneda, notice: 'Apertura moneda was successfully created.' }\n format.json { render :show, status: :created, location: @apertura_moneda }\n else\n format.html { render :new }\n format.json { render json: @apertura_moneda.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @message = Message.new(post_params)\n respond_to do |format|\n if @message.save\n flash[:success] = \"문자가 성공적으로 업로드 되었습니다.\"\n format.html { render :show}\n else\n flash[:error] = \"부족한 곳을 채워주세요\"\n format.html { render :new}\n format.json { render json: @message.errors }\n end\n end\n end",
"def create\n @midia = Midia.new(midia_params)\n\n respond_to do |format|\n if @midia.save\n format.html { redirect_to @midia, notice: 'Um novo tipo de mídia foi criado com sucesso.' }\n format.json { render json: @midia, status: :created, location: @midia }\n else\n format.html { render action: \"new\" }\n format.json { render json: @midia.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n params.permit(:id_groupe, :id_question)\n ajout = GroupeService.instance.ajouterQuestion(params[:id_groupe], params[:id_question])\n (ajout != nil) ? (render json: ajout, status: :ok) : (render json: nil, status: :not_found)\n end",
"def mensagem_params\n params.require(:mensagem).permit(:envio, :texto)\n end",
"def create\n @mision = Mision.new(mision_params)\n\n respond_to do |format|\n if @mision.save\n format.html { redirect_to @mision, notice: 'La misión se creó correctamente.' }\n format.json { render :show, status: :created, location: @mision }\n else\n format.html { render :new }\n format.json { render json: @mision.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @message = Message.new\n @message.create_one!(params[:message])\n #Juggernaut.publish(1, parse_chat_message(params[:message][:message], current_user))\n respond_to do |format|\n format.html { redirect_to :index }\n format.js\n end\n end",
"def create\n authorize! :create, @mesasredonda\n @mesasredonda = Mesasredonda.new(params[:mesasredonda])\n\n respond_to do |format|\n if @mesasredonda.save\n format.html { redirect_to @mesasredonda, notice: 'Mesa redonda cadastrada com sucesso.' }\n format.json { render json: @mesasredonda, status: :created, location: @mesasredonda }\n else\n format.html { render action: \"new\" }\n format.json { render json: @mesasredonda.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @mensaje = Mensaje.new(:titulo => params[:mensaje][:titulo], :cuerpo => params[:mensaje][:cuerpo], :caracter => params[:mensaje][:caracter])\n\n respond_to do |format|\n if @mensaje.save\n params[:user_ids].each do |user_id|\n MensajeUsuario.create(:usuario_id => user_id, :mensaje_id => @mensaje.id)\n end\n puts URI(request.referer).path\n if URI(request.referer).path == '/mensajes'\n format.html { redirect_to mensajes_path }\n else\n user = User.find(params[:user_ids][0])\n format.html { redirect_to resumen_formularios_path, notice: 'El mensaje ha sido enviado a ' + user.name }\n end\n else\n format.html { render action: \"new\" }\n format.json { render json: @mensaje.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @mestre = Mestre.new(mestre_params)\n\n respond_to do |format|\n if @mestre.save\n format.html { redirect_to @mestre, notice: 'Mestre was successfully created.' }\n format.json { render :show, status: :created, location: @mestre }\n else\n format.html { render :new }\n format.json { render json: @mestre.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @mission = Mission.new(params[:mission])\n\n respond_to do |format|\n if @mission.save\n format.html { redirect_to @mission, :notice => 'La mission est cree.' }\n format.json { render :json => @mission, :status => :created, :location => @mission }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @mission.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @jamaat = Jamaat.new(params[:jamaat])\n\n respond_to do |format|\n if @jamaat.save\n format.html { redirect_to @jamaat, notice: 'Jamaat was successfully created.' }\n format.json { render json: @jamaat, status: :created, location: @jamaat }\n else\n format.html { render action: \"new\" }\n format.json { render json: @jamaat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @enquete = Enquete.new(enquete_params)\n\n respond_to do |format|\n if @enquete.save\n format.html { redirect_to @enquete, notice: 'Enquete was successfully created.' }\n format.json { render :show, status: :created, location: @enquete }\n else\n format.html { render :new }\n format.json { render json: @enquete.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.create(post_params)\n puts \"LLLLLOOOOOOOLLLLLL\"\n puts current_usuario.to_json\n @post = current_usuario.posts.create(post_params)\n \n @post.sangre = current_usuario.tipoDeSangre\n\n\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @message = Message.new(params[:message])\n respond_to do |format|\n if @message.save\n format.js {}\n format.html{ redirect_to noticias_messages_path, notice: 'Mensaje creado correctamente.'}\n else\n format.js{}\n format.html{ render action: \"new\"}\n end\n end\n end",
"def create\n @jednani = Jednani.new(jednani_params)\n\n respond_to do |format|\n if @jednani.save\n format.html { redirect_to @jednani, notice: 'Jednani was successfully created.' }\n format.json { render action: 'show', status: :created, location: @jednani }\n else\n format.html { render action: 'new' }\n format.json { render json: @jednani.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @materia = Materia.new(params[:materia])\n\n if @materia.save\n render json: @materia, status: :created, location: @materia\n else\n render json: @materia.errors, status: :unprocessable_entity\n end\n end",
"def create\n @novedad_mecanica = @unidad.novedades_mecanicas.build(novedad_mecanica_params)\n\n respond_to do |format|\n if @novedad_mecanica.save\n format.html { redirect_to [@unidad,@novedad_mecanica], notice: 'Novedad mecanica was successfully created.' }\n format.json { render :show, status: :created, location: @novedad_mecanica }\n else\n format.html { render :new }\n format.json { render json: @novedad_mecanica.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @respuesta = Respuesta.new(respuesta_params)\n\n respond_to do |format|\n if @respuesta.save\n format.html { redirect_to @respuesta, notice: 'Respuesta was successfully created.' }\n format.json { render :show, status: :created, location: api_v1_respuesta_url(@respuesta) }\n else\n format.html { render :new }\n format.json { render json: @respuesta.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ejemplo = Ejemplo.new(ejemplo_params)\n\n respond_to do |format|\n if @ejemplo.save\n format.html { redirect_to @ejemplo, notice: 'Ejemplo was successfully created.' }\n format.json { render :show, status: :created, location: @ejemplo }\n else\n format.html { render :new }\n format.json { render json: @ejemplo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @responsavel = Responsavel.new(responsavel_params)\n\n if @responsavel.save\n render json: @responsavel, status: :created, location: @responsavel\n else\n render json: @responsavel.errors, status: :unprocessable_entity\n end\n end",
"def create\n @mutacao = Mutacao.new(params[:mutacao])\n\n respond_to do |format|\n if @mutacao.save\n format.html { redirect_to mutacaos_path, notice: 'Mutacao was successfully created.' }\n format.json { render json: @mutacao, status: :created, location: @mutacao }\n else\n format.html { render action: \"new\" }\n format.json { render json: @mutacao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @questionario_resposta = QuestionarioResposta.new(questionario_resposta_params)\n\n respond_to do |format|\n if @questionario_resposta.save\n format.html { redirect_to @questionario_resposta, notice: 'Questionario resposta was successfully created.' }\n format.json { render :show, status: :created, location: @questionario_resposta }\n else\n format.html { render :new }\n format.json { render json: @questionario_resposta.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @peserta_jkbm = PesertaJkbm.new(params[:peserta_jkbm])\n\n respond_to do |format|\n if @peserta_jkbm.save\n format.html { redirect_to(@peserta_jkbm, :notice => 'Peserta jkbm was successfully created.') }\n format.xml { render :xml => @peserta_jkbm, :status => :created, :location => @peserta_jkbm }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @peserta_jkbm.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @repuesto = Repuesto.new(repuesto_params)\n\n respond_to do |format|\n if @repuesto.save\n format.html { redirect_to @repuesto, notice: 'Repuesto was successfully created.' }\n format.json { render :show, status: :created, location: @repuesto }\n else\n format.html { render :new }\n format.json { render json: @repuesto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @matriz = Matriz.new(matriz_params)\n\n respond_to do |format|\n if @matriz.save\n format.html { redirect_to @matriz, notice: 'Matriz was successfully created.' }\n format.json { render :show, status: :created, location: @matriz }\n else\n format.html { render :new }\n format.json { render json: @matriz.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @personaje = Personaje.new(params[:personaje])\n\n respond_to do |format|\n if @personaje.save\n format.html { redirect_to @personaje, notice: 'Personaje was successfully created.' }\n format.json { render json: @personaje, status: :created, location: @personaje }\n else\n format.html { render action: \"new\" }\n format.json { render json: @personaje.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @enquete = Enquete.new(enquete_params)\n\n respond_to do |format|\n if @enquete.save\n format.html { redirect_to @enquete, notice: 'Enquete criada com sucesso!' }\n format.json { render :show, status: :created, location: @enquete }\n else\n format.html { render :new }\n format.json { render json: @enquete.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @puntaje = Puntaje.new\n atributos\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @puntaje }\n end\n end",
"def new\n @puntaje = Puntaje.new\n atributos\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @puntaje }\n end\n end",
"def create\n seleccionarMenu(:juzgados)\n @juzgado = Juzgado.new(params[:juzgado])\n\n respond_to do |format|\n if @juzgado.save\n format.html { redirect_to @juzgado, notice: 'Juzgado fue creado satisfactoriamente.' }\n format.json { render json: @juzgado, status: :created, location: @juzgado }\n else\n format.html { render action: \"new\" }\n format.json { render json: @juzgado.errors, status: :unprocessable_entity }\n end\n end\n end",
"def mensagem_params\n params.require(:mensagem).permit(:remetente, :texto, :aprovada, :presente_id)\n end",
"def create\n @repuesto = Repuesto.new(repuesto_params)\n\n respond_to do |format|\n if @repuesto.save\n format.html { redirect_to @repuesto, notice: 'Repuesto creado exitosamente' }\n format.json { render :show, status: :created, location: @repuesto }\n else\n format.html { render :new }\n format.json { render json: @repuesto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @objetivo = Objetivo.new(objetivo_params)\n @objetivo.mision= @mision\n\n respond_to do |format|\n if @objetivo.save\n format.html { redirect_to [@mision, @objetivo], notice: 'Objetivo was successfully created.' }\n format.json { render :show, status: :created, location: [@mision, @objetivo] }\n else\n format.html { render :new }\n format.json { render json: [@mision, @objetivo].errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @mote = Mote.new(params[:mote])\n\n respond_to do |format|\n if @mote.save\n format.html { redirect_to @mote, notice: 'Mote was successfully created.' }\n format.json { render json: @mote, status: :created, location: @mote }\n else\n format.html { render action: \"new\" }\n format.json { render json: @mote.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n @respuestum = Respuestum.new(respuestum_params)\n # @comentario = Comentario.find(params[:id])\n #nombre = params[:nombre]\n #correo = params[:correo]\n #comentario = params[:comentario]\n\n #@respuestum = Respuestum.create(:nombre => string, :correo => string, :descripcion => text,:comentario_id => @comentario.id)\n\n respond_to do |format|\n if @respuestum.save\n format.html { redirect_to comentarios_url}\n format.json { render :show, status: :created, location: @respuestum }\n else\n format.html { render :new }\n format.json { render json: @respuestum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @m_answer = @m_question.m_answers.build(m_answer_params)\n respond_to do |format|\n if @m_answer.save\n format.html { redirect_to m_question_path(@m_question) }\n format.json { render action: 'show', status: :created, location: @m_answer }\n else\n format.html { render action: 'new' }\n format.json { render json: @m_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n puts request.body.string\n\n if request.body.string.include? %q[\"id\"]\n render json: %q[{\"error\": \"No se puede crear usuario con id\"}], status: 400\n else\n @usuario = Usuario.new(usuario_params)\n #Tuve que hacerlo asi, pq por alguna razon no me dejaba de la forma tradicional!\n #@usuario = Usuario.new\n #@usuario.usuario = params[:usuario]\n #@usuario.nombre = params[:nombre]\n #@usuario.apellido = params[:apellido]\n #@usuario.twitter = params[:twitter]\n\n\n respond_to do |format|\n if @usuario.save\n #format.html { redirect_to @usuario, notice: 'Usuario was successfully created.' }\n format.json { render :show, status: :created, location: @usuario }\n else\n #format.html { render :new }\n format.json { render json: @usuario.errors, status: 404}# status: :unprocessable_entity }\n end\n end\n end\n end",
"def new\n @respuesta = Respuesta.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @respuesta }\n end\n end",
"def create\n @news = News.new(params[:news])\n\n respond_to do |format|\n if @news.save\n format.html { redirect_to @news, notice: 'Новость добавлена.' }\n format.json { render json: @news, status: :created, location: @news }\n else\n format.html { render action: \"new\" }\n format.json { render json: @news.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @puntaje = Puntaje.new(params[:puntaje])\n\n respond_to do |format|\n if @puntaje.save\n format.html { redirect_to @puntaje, notice: 'Puntaje was successfully created.' }\n format.json { render json: @puntaje, status: :created, location: @puntaje }\n else\n atributos\n format.html { render action: \"new\" }\n format.json { render json: @puntaje.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @muneco = Muneco.new(muneco_params)\n\n respond_to do |format|\n if @muneco.save\n format.html { redirect_to @muneco, notice: 'Muneco was successfully created.' }\n format.json { render :show, status: :created, location: @muneco }\n else\n format.html { render :new }\n format.json { render json: @muneco.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @quinto = Quinto.new(quinto_params)\n \n @quinto.anio = params[:anio]\n @quinto.mes = params[:mes]\n \n \n respond_to do |format|\n if @quinto.save\n format.html { redirect_to @quinto, notice: 'Quinto was successfully created.' }\n format.json { render :show, status: :created, location: @quinto }\n else\n format.html { render :new }\n format.json { render json: @quinto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @mwod_post = MwodPost.new(params[:mwod_post])\n\n respond_to do |format|\n if @mwod_post.save\n format.html { redirect_to @mwod_post, notice: 'Mwod post was successfully created.' }\n format.json { render json: @mwod_post, status: :created, location: @mwod_post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @mwod_post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n p \"## TESTE #\" \n @mural_post = MuralPost.new( user_id: params[:user_id], \n latitude: params[:latitude], \n longitude: params[:longitude], \n message: params[:message],\n anonymous: params[:anonymous]\n )\n \n respond_to do |format|\n if @mural_post.save\n format.html { redirect_to @mural_post, notice: 'Mural post was successfully created.' }\n format.json { render action: 'show', status: :created, location: @mural_post }\n else\n p \"## ERRO #\" \n format.html { render action: 'new' }\n format.json { render json: @mural_post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def mensaje_params\n params.require(:mensaje).permit(:usuario_id, :comentario_id)\n end",
"def create\n @nominee = Nominee.new(nominee_params)\n\n respond_to do |format|\n if @nominee.save\n format.html { redirect_to @nominee, notice: 'Nominee was successfully created.' }\n format.json { render action: 'show', status: :created, location: @nominee }\n #format.js\n else\n format.html { render action: 'new' }\n format.json { render json: @nominee.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\r\n @motivo_movimiento_caja = MotivoMovimientoCaja.new(motivo_movimiento_caja_params)\r\n\r\n respond_to do |format|\r\n if @motivo_movimiento_caja.save\r\n format.html { redirect_to @motivo_movimiento_caja, success: 'Creaste un motivo correctamente.' }\r\n format.json { render :show, status: :created, location: @motivo_movimiento_caja }\r\n format.js { render action: 'show', status: :created, location: @motivo_movimiento_caja }\r\n else\r\n format.html { render :new }\r\n format.json { render json: @motivo_movimiento_caja.errors, status: :unprocessable_entity }\r\n format.js { render json: @motivo_movimiento_caja.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def create\n @municipio = Municipio.new(params[:municipio])\n\n respond_to do |format|\n if @municipio.save\n format.html { redirect_to @municipio, notice: 'Municipio was successfully created.' }\n format.json { render json: @municipio, status: :created, location: @municipio }\n else\n format.html { render action: \"new\" }\n format.json { render json: @municipio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @empresas = Empresa.new(empresa_params)\n\n respond_to do |format|\n if @empresas.save\n format.html { redirect_to @empresas, notice: 'Empresa was successfully created.' }\n format.json { render :show, status: :created, location: @empresas }\n else\n format.html { render :new }\n format.json { render json: @empresas.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @medico = Medico.new(medico_params)\n\n respond_to do |format|\n if @medico.save\n format.html { redirect_to @medico, notice: \"Medico criado com SUCESSO.\" }\n format.json { render :show, status: :created, location: @medico }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @medico.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @minnpaku = Minnpaku.new(minnpaku_params)\n\n respond_to do |format|\n if @minnpaku.save\n format.html { redirect_to @minnpaku, notice: 'Minnpaku was successfully created.' }\n format.json { render :show, status: :created, location: @minnpaku }\n else\n format.html { render :new }\n format.json { render json: @minnpaku.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @new_message = Message.find(params[:message_id]).responses.build\n @options = {:url => message_responses_path(:id => params[:message_id]), :method => :post}\n respond_to do |format| \n format.html\n format.js\n end\n end",
"def create\n @policeman = Policeman.new(policeman_params)\n\n respond_to do |format|\n if @policeman.save\n format.html { redirect_to @policeman, notice: \"Policía creado con éxito.\" }\n format.json { render :show, status: :created, location: @policeman }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @policeman.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @uang_masuk = UangMasuk.new(uang_masuk_params)\n\n respond_to do |format|\n if @uang_masuk.save\n format.html { redirect_to uang_masuks_path, notice: 'Uang masuk was successfully created.' }\n else\n format.html { render :new }\n format.json { render json: @uang_masuk.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @mision = Mision.new(params[:mision])\n\n respond_to do |format|\n if @mision.save\n format.html { redirect_to @mision, notice: 'Mision was successfully created.' }\n format.json { render json: @mision, status: :created, location: @mision }\n else\n format.html { render action: \"new\" }\n format.json { render json: @mision.errors, status: :unprocessable_entity }\n end\n end\n end",
"def mensagem_params\n params.require(:mensagem).permit(:user_id, :content, :email,:all, :title)\n end",
"def create\n @posto = Posto.new(posto_params)\n\n respond_to do |format|\n if @posto.save\n format.html { redirect_to @posto, notice: 'Posto was successfully created.' }\n format.json { render :show, status: :created, location: @posto }\n else\n format.html { render :new }\n format.json { render json: @posto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @message = Message.new(message_params)\n\n respond_to do |format|\n if @message.save\n format.html { redirect_to @message, notice: 'Message crée avec succès.' }\n format.json { render :show, status: :created, location: @message }\n else\n format.html { render :new }\n format.json { render json: @message.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @muestra = Muestra.new(muestra_params)\n\n respond_to do |format|\n if @muestra.save\n format.html { redirect_to @muestra, notice: 'Muestra was successfully created.' }\n format.json { render :show, status: :created, location: @muestra }\n else\n format.html { render :new }\n format.json { render json: @muestra.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n seleccionarMenu(:juzgados)\n @juzgado = Juzgado.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @juzgado }\n end\n end",
"def create\n @municipio = Municipio.new(params[:municipio])\n\n respond_to do |format|\n if @municipio.save\n format.html { redirect_to @municipio, notice: 'Municipio criado com sucesso!' }\n format.json { render json: @municipio, status: :created, location: @municipio }\n else\n format.html { render action: \"new\" }\n format.json { render json: @municipio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @marque = Marque.new(marque_params)\n\n respond_to do |format|\n if @marque.save\n format.html { redirect_to @marque, notice: \"Marque was successfully created.\" }\n format.json { render :show, status: :created, location: @marque }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @marque.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @mecanicacomplejo = Mecanicacomplejo.new(params[:mecanicacomplejo])\n\n respond_to do |format|\n if @mecanicacomplejo.save\n format.html { redirect_to @mecanicacomplejo, notice: 'Mecanicacomplejo was successfully created.' }\n format.json { render json: @mecanicacomplejo, status: :created, location: @mecanicacomplejo }\n else\n format.html { render action: \"new\" }\n format.json { render json: @mecanicacomplejo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n message = Message.new(message_params)\n message.message = params[:message_text]\n message.display_name = params[:display_name]\n message.save!\n render json: message\n end",
"def create\n @survey = Survey.new(params[:survey])\n\n respond_to do |format|\n if @survey.save\n format.html { redirect_to @survey, notice: 'Тест добавлен.' }\n format.json { render json: @survey, status: :created, location: @survey }\n else\n format.html { render action: \"new\" }\n format.json { render json: @survey.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ejercicio = Ejercicio.new(params[:ejercicio])\n\n respond_to do |format|\n if @ejercicio.save\n format.html { redirect_to @ejercicio, notice: 'Ejercicio was successfully created.' }\n format.json { render json: @ejercicio, status: :created, location: @ejercicio }\n else\n format.html { render action: \"new\" }\n format.json { render json: @ejercicio.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.66093904",
"0.6364882",
"0.63566566",
"0.62934035",
"0.62187797",
"0.6175252",
"0.6107447",
"0.6086889",
"0.6086532",
"0.60295355",
"0.6029447",
"0.6013697",
"0.60066587",
"0.59801626",
"0.5974442",
"0.594035",
"0.59205973",
"0.5899924",
"0.5899279",
"0.58917725",
"0.588069",
"0.58751476",
"0.5874329",
"0.5863919",
"0.58610404",
"0.58508563",
"0.5834422",
"0.5834116",
"0.5832237",
"0.5820875",
"0.5799478",
"0.57954544",
"0.57702214",
"0.57612693",
"0.576083",
"0.5758748",
"0.5757742",
"0.5752982",
"0.5752402",
"0.5726042",
"0.57237303",
"0.5719474",
"0.5712657",
"0.56967795",
"0.5689748",
"0.5689159",
"0.5684154",
"0.5682469",
"0.5673354",
"0.56726384",
"0.5667355",
"0.56660104",
"0.5663532",
"0.5663294",
"0.56555545",
"0.5653917",
"0.5652763",
"0.5651754",
"0.5648634",
"0.5643409",
"0.5630608",
"0.5628955",
"0.5628955",
"0.5628852",
"0.5622422",
"0.5617404",
"0.5614554",
"0.56110895",
"0.5608093",
"0.5607755",
"0.5606713",
"0.56062204",
"0.56035686",
"0.5599467",
"0.55961245",
"0.559425",
"0.55889887",
"0.55808383",
"0.55740845",
"0.5573715",
"0.55735356",
"0.55710185",
"0.55686045",
"0.55657417",
"0.5563066",
"0.55577654",
"0.5552978",
"0.55488604",
"0.5547872",
"0.5542046",
"0.55417854",
"0.5540687",
"0.55383235",
"0.55364376",
"0.5533989",
"0.55327946",
"0.5532347",
"0.5531997",
"0.5531903",
"0.5531502"
] | 0.65233135 | 1 |
PATCH/PUT /mensajes/1 or /mensajes/1.json | def update
respond_to do |format|
if @mensaje.update(mensaje_params)
format.html { redirect_to @mensaje, notice: "Mensaje was successfully updated." }
format.json { render :show, status: :ok, location: @mensaje }
else
format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @mensaje.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @mensagem.update(mensagem_params)\n format.html { redirect_to @mensagem, notice: 'Mensagem was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @mensagem.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @mensagem = Mensagem.find(params[:id])\n\n respond_to do |format|\n if @mensagem.update_attributes(params[:mensagem])\n format.html { redirect_to('', :notice => 'Nota atualizada com sucesso!') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @mensagem.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @mensagem.update(mensagem_params)\n format.html do\n redirect_to campanha_mensagem_path(@campanha, @mensagem), notice: {\n type: 'info',\n message: 'Mensagem atualizada com sucesso.'\n }\n end\n format.json { render :show, status: :ok, location: @mensagem }\n else\n format.html { render :edit }\n format.json { render json: @mensagem.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @metodologia.update(metodologia_params)\n format.html { redirect_to @metodologia, notice: 'Metodologia was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @metodologia.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @metodo = Metodo.find(params[:id])\n\n respond_to do |format|\n if @metodo.update_attributes(params[:metodo])\n format.html { redirect_to metodos_url }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @metodo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @mensagem = Mensagem.find(params[:id])\n\n respond_to do |format|\n if @mensagem.update_attributes(params[:mensagem])\n flash[:notice] = 'Mensagem was successfully updated.'\n format.html { redirect_to(@mensagem) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @mensagem.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @prueba_json.update(prueba_json_params)\n format.html { redirect_to @prueba_json, notice: 'Prueba json was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @prueba_json.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @respuesta = Respuesta.find(params[:id])\n\n if @respuesta.update(params[:respuesta])\n head :no_content\n else\n render json: @respuesta.errors, status: :unprocessable_entity\n end\n end",
"def update\n @mensaje = Mensaje.find(params[:id])\n\n respond_to do |format|\n if @mensaje.update_attributes(:titulo => params[:mensaje][:titulo], :cuerpo => params[:mensaje][:cuerpo], :caracter => params[:mensaje][:caracter])\n @mensaje.eliminar_receptores\n if params[:user_ids] != nil && params[:user_ids].kind_of?(Array)\n params[:user_ids].each do |user_id|\n MensajeUsuario.create(:usuario_id => user_id, :mensaje_id => @mensaje.id)\n end\n end\n format.html { redirect_to mensajes_path }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @mensaje.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @objetos_mensura.update(objetos_mensura_params)\n format.html { redirect_to @objetos_mensura, notice: 'Objetos mensura was successfully updated.' }\n format.json { render :show, status: :ok, location: @objetos_mensura }\n else\n format.html { render :edit }\n format.json { render json: @objetos_mensura.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @jornada = Jornada.find(params[:id])\n\n respond_to do |format|\n if @jornada.update_attributes(params[:jornada])\n format.html { redirect_to jornadas_path, notice: 'La jornada se ha actualizado correctamente' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @jornada.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @mensaje = Mensaje.find(params[:id])\n \n respond_to do |format|\n if @mensaje.update_attributes(params[:mensaje])\n flash[:notice] = 'Mensaje actualizado correctamente.'\n format.html { redirect_to(@mensaje) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @mensaje.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @mensaje_usuario = MensajeUsuario.find(params[:id])\n\n respond_to do |format|\n if @mensaje_usuario.update_attributes(params[:mensaje_usuario])\n format.html { redirect_to @mensaje_usuario, notice: 'Mensaje usuario was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @mensaje_usuario.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @midia.update_attributes(midia_params)\n format.html { redirect_to @midia, notice: 'O tipo de mídia foi atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @midia.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @municao.update(municao_params)\n format.html { redirect_to @municao, notice: 'A Munição foi editada com sucesso!' }\n format.json { render :show, status: :ok, location: @municao }\n else\n format.html { render :edit }\n format.json { render json: @municao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @misione.update(misione_params)\n format.html { redirect_to @misione, notice: 'Misione was successfully updated.' }\n format.json { render :show, status: :ok, location: @misione }\n else\n format.html { render :edit }\n format.json { render json: @misione.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @usuario = Usuario.find_by_id(params[:id])\n if @usuario.nil?\n render :json => {:error => \"Usuario no encontrado\"}.to_json, :status => 404\n\n #render :json => {:error => \"id no es modificable\"}.to_json, :status => 400\n else\n if usuario_params.count==1\n respond_to do |format|\n # format.json { render json: usuario_params.count}\n if @usuario.update(usuario_params)\n #format.json { render json: @usuario}\n\n #format.html { redirect_to @usuario, notice: 'Usuario was successfully updated.' }\n #el segundo\n format.json { render :show, status: :ok, location: @usuario }\n end\n end\n elsif usuario_params.count==0\n # JSON.parse(usuario_params)\n respond_to do |format|\n format.json { render :json => {:error => \"id no es modificable\"}.to_json, :status => 400 }\n end\n else\n respond_to do |format|\n format.json { render :json => {:error => \"La modificación ha fallado\"}.to_json, :status => 500 }\n end\n end\n end\n end",
"def update\n respond_to do |format|\n if @modelo.update(modelo_params)\n format.html { redirect_to @modelo, notice: 'Modelo foi editado com sucesso.' }\n format.json { render :show, status: :ok, location: @modelo }\n else\n format.html { render :edit }\n format.json { render json: @modelo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @responsavel = Responsavel.find(params[:id])\n\n if @responsavel.update(responsavel_params)\n head :no_content\n else\n render json: @responsavel.errors, status: :unprocessable_entity\n end\n end",
"def update\n @personaje_mision = PersonajeMision.find(params[:id])\n\n respond_to do |format|\n if @personaje_mision.update_attributes(params[:personaje_mision])\n format.html { redirect_to @personaje_mision, notice: 'Personaje mision was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @personaje_mision.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @mission.update(mission_params)\n MissionMailer.update_mission_b(Mission.last).deliver_now\n MissionMailer.update_mission_e(Mission.last).deliver_now\n format.html { redirect_to @mission.etablissement, notice: 'La Proposition a bien été modifiée.' }\n format.json { render :show, status: :ok, location: @mission.etablissement }\n else\n format.html { render :edit }\n format.json { render json: @mission.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @jamaat = Jamaat.find(params[:id])\n\n respond_to do |format|\n if @jamaat.update_attributes(params[:jamaat])\n format.html { redirect_to @jamaat, notice: 'Jamaat was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @jamaat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @minimessage = Minimessage.find(params[:id])\n\n respond_to do |format|\n if @minimessage.update_attributes(params[:minimessage])\n format.html { redirect_to @minimessage, notice: 'Minimessage was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @minimessage.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @motivobaja = MotivoBaja.find(params[:id])\n\n respond_to do |format|\n if @motivobaja.update(motivo_baja_params)\n format.html { redirect_to @motivobaja, notice: 'Motivo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @motivobaja.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @modelo = Modelo.find(params[:id])\n\n respond_to do |format|\n if @modelo.update_attributes(params[:modelo])\n format.html { redirect_to @modelo, notice: 'Modelo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @modelo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @respuesta = Respuesta.find(params[:id])\n\n respond_to do |format|\n if @respuesta.update_attributes(params[:respuesta])\n format.html { redirect_to @respuesta, notice: 'Respuesta was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @respuesta.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @mensagem.all\n get_all_mensagem('sistema')\n else \n get_all_mensagem\n end \n \n if @mensagem.update(mensagem_params)\n render 'mensagems/admin/admin' \n else\n render :edit \n end\n \n end",
"def update\n @materia = Materia.find(params[:id])\n\n if @materia.update(params[:materia])\n head :no_content\n else\n render json: @materia.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @jugadore.update( jugadore_params )\n format.html { redirect_to @jugadore, notice: 'Jugadore was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @jugadore.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @matriz.update(matriz_params)\n format.html { redirect_to @matriz, notice: 'Matriz was successfully updated.' }\n format.json { render :show, status: :ok, location: @matriz }\n else\n format.html { render :edit }\n format.json { render json: @matriz.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @mission = Mission.find(params[:id])\n\n respond_to do |format|\n if @mission.update_attributes(params[:mission])\n format.html { redirect_to @mission, :notice => 'Changements bien pris en compte' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @mission.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @personaje = Personaje.find(params[:id])\n\n respond_to do |format|\n if @personaje.update_attributes(params[:personaje])\n format.html { redirect_to @personaje, notice: 'Personaje was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @personaje.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @loja = Loja.find(params[:id])\n\n respond_to do |format|\n if @loja.update_attributes(params[:loja])\n format.html { redirect_to @loja, notice: 'Loja actualizada com sucesso' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @loja.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @nombr_comune.update(nombr_comune_params)\n format.html { redirect_to @nombr_comune, notice: 'Nombre comun was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @nombr_comune.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_mod\n if params[:title] != nil && params[:content] != nil\n @question.title = params[:title]\n @question.content = params[:content]\n\n question_json = @question.to_h.to_json\n\n url = @httpIp+'/pet.com/api/question/updateQuestion'\n uri = URI(url)\n res = Net::HTTP.post(uri, question_json, \"Content-Type\" => \"application/json\")\n puts res.body\n flash[:notice] = \"successfully updated\"\n redirect_to questions_path\n end\n end",
"def update\n respond_to do |format|\n if @jednani.update(jednani_params)\n format.html { redirect_to @jednani, notice: 'Jednani was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @jednani.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @manutencao.update(manutencao_params)\n format.html { redirect_to ajudas_path, notice: 'Manutencao was successfully updated.' }\n format.json { render :show, status: :ok, location: @manutencao }\n else\n format.html { render :edit }\n format.json { render json: @manutencao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @alumno = Alumno.find(params[:id])\n\n respond_to do |format|\n if @alumno.update_attributes(params[:alumno])\n head :no_content\n else\n render json: @alumno.errors, status: :unprocessable_entity\n end\n end\n end",
"def update\n respond_to do |format|\n if @mess.update(mess_params)\n format.html { redirect_to @mess, notice: 'Mess was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @mess.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @jogo.update(jogo_params)\n format.html { redirect_to @jogo, notice: 'Jogo was successfully updated.' }\n format.json { render :show, status: :ok, location: @jogo }\n else\n format.html { render :edit }\n format.json { render json: @jogo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ejemplo.update(ejemplo_params)\n format.html { redirect_to @ejemplo, notice: 'Ejemplo was successfully updated.' }\n format.json { render :show, status: :ok, location: @ejemplo }\n else\n format.html { render :edit }\n format.json { render json: @ejemplo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @mae.update(mae_params)\n format.html { redirect_to @mae, notice: 'Mae was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @mae.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @mijnwerknemer.update(mijnwerknemer_params)\n format.html { redirect_to @mijnwerknemer, notice: 'Mijnwerknemer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @mijnwerknemer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @mou.update(mou_params)\n format.html { redirect_to @mou, notice: 'Mou was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @mou.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @message = Message.find(params[:id])\n @message.update(text: params[\"_json\"])\n render json: @message\n end",
"def update\n respond_to do |format|\n if @m1.update(m1_params)\n format.html { redirect_to @m1, notice: 'M1 was successfully updated.' }\n format.json { render :show, status: :ok, location: @m1 }\n else\n format.html { render :edit }\n format.json { render json: @m1.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @momsg = Momsg.find(params[:id])\n\n respond_to do |format|\n if @momsg.update_attributes(params[:momsg])\n format.html { redirect_to @momsg, notice: 'Momsg was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @momsg.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @mecanicacomplejo = Mecanicacomplejo.find(params[:id])\n\n respond_to do |format|\n if @mecanicacomplejo.update_attributes(params[:mecanicacomplejo])\n format.html { redirect_to @mecanicacomplejo, notice: 'Mecanicacomplejo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @mecanicacomplejo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @enquete.update(enquete_params)\n format.html { redirect_to @enquete, notice: 'Enquete editada com sucesso!' }\n format.json { render :show, status: :ok, location: @enquete }\n else\n format.html { render :edit }\n format.json { render json: @enquete.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @mutacao = Mutacao.find(params[:id])\n\n respond_to do |format|\n if @mutacao.update_attributes(params[:mutacao])\n format.html { redirect_to @mutacao, notice: 'Mutacao was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @mutacao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @mundo.update(mundo_params)\n format.html { redirect_to @mundo, notice: 'Mundo was successfully updated.' }\n format.json { render :show, status: :ok, location: @mundo }\n else\n format.html { render :edit }\n format.json { render json: @mundo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize! :update, @mesasredonda\n @mesasredonda = Mesasredonda.find(params[:id])\n\n respond_to do |format|\n if @mesasredonda.update_attributes(params[:mesasredonda])\n format.html { redirect_to @mesasredonda, notice: 'Mesa redonda modificada com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @mesasredonda.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @minor.update(minor_params)\n format.html { redirect_to :show, notice: 'Minor was successfully updated.' }\n format.json { render :show, status: :ok, location: @minor }\n else\n format.html { render :edit }\n format.json { render json: @minor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @minnpaku.update(minnpaku_params)\n format.html { redirect_to @minnpaku, notice: 'Minnpaku was successfully updated.' }\n format.json { render :show, status: :ok, location: @minnpaku }\n else\n format.html { render :edit }\n format.json { render json: @minnpaku.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @kolegij = Kolegij.find(params[:id])\n\n respond_to do |format|\n if @kolegij.update_attributes(params[:kolegij])\n format.html { redirect_to @kolegij, notice: 'Kolegij was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @kolegij.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @matome.update(matome_params)\n format.html { redirect_to @matome, notice: 'Matome was successfully updated.' }\n format.json { render :show, status: :ok, location: @matome }\n else\n format.html { render :edit }\n format.json { render json: @matome.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @matome.update(matome_params)\n format.html { redirect_to @matome, notice: 'Matome was successfully updated.' }\n format.json { render :show, status: :ok, location: @matome }\n else\n format.html { render :edit }\n format.json { render json: @matome.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @mantenimiento.update(mantenimiento_params)\n format.html { redirect_to @mantenimiento, notice: 'Mantenimiento was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @mantenimiento.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize! :edit, @questionnaire\n\n @questionnaire.load_JSON(params[:questionnaire], current_user)\n\n respond_to do |format|\n# if @questionnaire.update_attributes(params[:questionnaire])\n format.html { redirect_to @questionnaire, notice: 'Kysymyslomakkeen muokkaaminen onnistui.' }\n format.json { head :no_content }\n# else\n# format.html { render action: \"edit\" }\n# format.json { render json: @questionnaire.errors, status: :unprocessable_entity }\n# end\n\n end\n end",
"def update\n respond_to do |format|\n if @mision.update(mision_params)\n format.html { redirect_to @mision, notice: 'La misión se actualizó correctamente.' }\n format.json { render :show, status: :ok, location: @mision }\n else\n format.html { render :edit }\n format.json { render json: @mision.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n respond_to do |format|\n if @model.update(model_params)\n format.html { redirect_to @model, flash: {success:_(\"Modello modificato con successo!\")} }\n format.json { head :no_content }\n else\n format.html { render \"forms/new_edit\" }\n format.json { render json: @model.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @modelos_contadore.update(modelos_contadore_params)\n format.html { redirect_to @modelos_contadore, notice: 'Modelos contadore was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @modelos_contadore.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @joseph_memo.update(joseph_memo_params)\n format.html { redirect_to @joseph_memo, notice: 'Joseph memo was successfully updated.' }\n format.json { render :show, status: :ok, location: @joseph_memo }\n else\n format.html { render :edit }\n format.json { render json: @joseph_memo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @joa.update(joa_params)\n format.html { redirect_to @joa, notice: 'Joa was successfully updated.' }\n format.json { render :show, status: :ok, location: @joa }\n else\n format.html { render :edit }\n format.json { render json: @joa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @minuman.update(minuman_params)\n format.html { redirect_to @minuman, notice: 'Minuman was successfully updated.' }\n format.json { render :show, status: :ok, location: @minuman }\n else\n format.html { render :edit }\n format.json { render json: @minuman.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @servico_pacote.update(servico_pacote_params)\n format.html { redirect_to @servico_pacote, notice: 'Pacote was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @servico_pacote.errors, status: :unprocessable_entity }\n end\n end\n end",
"def activo_update\n respond_to do |format|\n activo = params[:laboratorio][:activo]\n id = params[:id]\n Laboratorio.where(id: id).update_all(activo: activo )\n msg = { :status => \"ok\", :message => \"Actualizado!\" }\n format.json { render :json => msg }\n end\n end",
"def update\n respond_to do |format|\n if @motivo.update(motivo_params)\n format.html { redirect_to @motivo, notice: 'Motivo was successfully updated.' }\n format.json { render :show, status: :ok, location: @motivo }\n else\n format.html { render :edit }\n format.json { render json: @motivo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @kolegiji = Kolegiji.find(params[:id])\n\n respond_to do |format|\n if @kolegiji.update_attributes(params[:kolegiji])\n format.html { redirect_to @kolegiji, notice: 'Kolegiji was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @kolegiji.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @api_v1_todo.update(api_v1_todo_params)\n format.json { render json: @api_v1_todo, status: :ok }\n else\n format.json { render json: @api_v1_todo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\r\n respond_to do |format|\r\n if @sivic_ministerio.update(sivic_ministerio_params)\r\n format.html { redirect_to @sivic_ministerio, notice: 'Registro alterado com sucesso.' }\r\n format.json { head :no_content }\r\n else\r\n format.html { render action: 'edit' }\r\n format.json { render json: @sivic_ministerio.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def update\n respond_to do |format|\n if @enemigo.update(enemigo_params)\n format.html { redirect_to @enemigo, notice: 'Enemigo was successfully updated.' }\n format.json { render :show, status: :ok, location: @enemigo }\n else\n format.html { render :edit }\n format.json { render json: @enemigo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @vo2maximo.update(vo2maximo_params)\n format.html { redirect_to @vo2maximo, notice: 'Vo2maximo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @vo2maximo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n answer = Answer.find(params[:answer_id])\n if answer.update(content: params[:content])\n render json: {answer: answer, success: true} \n else\n render json: @answer.errors, success: false \n end\n end",
"def update\n @mapeamento = Mapeamento.find(params[:id])\n\n respond_to do |format|\n if @mapeamento.update_attributes(params[:mapeamento])\n format.html { redirect_to @mapeamento, notice: 'Mapeamento was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @mapeamento.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @projeto.update(projeto_params)\n format.html { redirect_to @projeto, notice: 'Projeto alterado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @projeto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n @news.title = news_params[\"title\"]\n @news.content = news_params[\"content\"]\n @news.user_id = @current_user.id\n if @news.save\n format.html { redirect_to @news, notice: 'News was successfully updated.' }\n format.json { head :no_content }\n end\n end\n end",
"def update\n @oferta = Oferta.find(params[:id])\n\n respond_to do |format|\n if @oferta.update_attributes(params[:oferta])\n format.html { redirect_to [:admin, @oferta], :notice => 'Exemplo was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @oferta.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @nominee = Nominee.find(params[:id])\n\n respond_to do |format|\n if @nominee.update_attributes(params[:nominee])\n format.html { redirect_to @nominee, notice: 'Nominee was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @nominee.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n message = Message.find(params[:id])\n message.update(message_params)\n render json: message\n end",
"def update\n respond_to do |format|\n if @enquete.update(enquete_params)\n format.html { redirect_to @enquete, notice: 'Enquete was successfully updated.' }\n format.json { render :show, status: :ok, location: @enquete }\n else\n format.html { render :edit }\n format.json { render json: @enquete.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @kela.update(kela_params)\n format.html { redirect_to @kela, notice: 'Kela was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @kela.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @mision = Mision.find(params[:id])\n\n respond_to do |format|\n if @mision.update_attributes(params[:mision])\n format.html { redirect_to @mision, notice: 'Mision was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @mision.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @muneco.update(muneco_params)\n format.html { redirect_to @muneco, notice: 'Muneco was successfully updated.' }\n format.json { render :show, status: :ok, location: @muneco }\n else\n format.html { render :edit }\n format.json { render json: @muneco.errors, status: :unprocessable_entity }\n end\n end\n end",
"def edit\n render json: Passage.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @objetivo.update(objetivo_params)\n format.html { redirect_to [@mision, @objetivo], notice: 'Objetivo was successfully updated.' }\n format.json { render :show, status: :ok, location: [@mision, @objetivo] }\n else\n format.html { render :edit }\n format.json { render json: [@mision, @objetivo].errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @proyecto_minero_exam.update(proyecto_minero_exam_params)\n format.html { redirect_to @proyecto_minero_exam, notice: 'Proyecto minero exam was successfully updated.' }\n format.json { render :show, status: :ok, location: @proyecto_minero_exam }\n else\n format.html { render :edit }\n format.json { render json: @proyecto_minero_exam.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @mencion = Mencion.find(params[:id])\n\n respond_to do |format|\n if @mencion.update_attributes(params[:mencion])\n format.html { redirect_to @mencion, notice: 'Mencion actualizada' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @mencion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @chatcontent = Chatcontent.find(params[:id])\n\n respond_to do |format|\n if @chatcontent.update_attributes(params[:chatcontent])\n format.html { redirect_to @chatcontent, notice: 'Chatcontent was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @chatcontent.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\r\n respond_to do |format|\r\n if @motivo_movimiento_caja.update(motivo_movimiento_caja_params)\r\n format.html { redirect_to @motivo_movimiento_caja, success: 'Editaste un motivo correctamente.' }\r\n format.json { render :show, status: :ok, location: @motivo_movimiento_caja }\r\n else\r\n format.html { render :edit }\r\n format.json { render json: @motivo_movimiento_caja.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def update\n respond_to do |format|\n if @opiskelija.update(opiskelija_params)\n format.html { redirect_to @opiskelija, notice: 'Opiskelija was successfully updated.' }\n format.json { render :show, status: :ok, location: @opiskelija }\n else\n format.html { render :edit }\n format.json { render json: @opiskelija.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @apertura_moneda.update(apertura_moneda_params)\n format.html { redirect_to @apertura_moneda, notice: 'Apertura moneda was successfully updated.' }\n format.json { render :show, status: :ok, location: @apertura_moneda }\n else\n format.html { render :edit }\n format.json { render json: @apertura_moneda.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n question = Question.find_by!(id: params[:id])\n if question\n question.name = params[:name]\n question.description = params[:description]\n question.user_id = params[:user_id]\n question.category_id = params[:category_id]\n question.zavrseno = params[:zavrseno]\n question.uposlenik_id = params[:uposlenik_id]\n question.save\n render json: question, status: 200 \n else\n render json: { errors: \"This link is invalid.\"}, status: 404\n end\n end",
"def update\n respond_to do |format|\n if @adminmatrixgenu.update(adminmatrixgenu_params)\n format.html { redirect_to @adminmatrixgenu, notice: 'Adminmatrixgenu was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @adminmatrixgenu.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @kodomo.update(kodomo_params)\n format.html { redirect_to @kodomo, notice: 'Kodomo was successfully updated.' }\n format.json { render :show, status: :ok, location: @kodomo }\n else\n format.html { render :edit }\n format.json { render json: @kodomo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @msg.update(msg_params)\n format.html { redirect_to @msg, notice: 'Msg was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @msg.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @clientes_servico.update(clientes_servico_params)\n format.html { redirect_to @clientes_servico, notice: 'Clientes servico was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @clientes_servico.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @materia.update(materia_params)\n format.html { redirect_to @materia, notice: 'Materia was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @materia.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @jugador.update(jugador_params)\n format.html { redirect_to @jugador, notice: 'Jugador was successfully updated.' }\n format.json { render :show, status: :ok, location: @jugador }\n else\n format.html { render :edit }\n format.json { render json: @jugador.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @jean.update(jean_params)\n format.html { redirect_to @jean, notice: 'Jean was successfully updated.' }\n format.json { render :show, status: :ok, location: @jean }\n else\n format.html { render :edit }\n format.json { render json: @jean.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.6980855",
"0.6486283",
"0.64420754",
"0.64306116",
"0.6394283",
"0.63912404",
"0.63697994",
"0.63569194",
"0.62643397",
"0.62565565",
"0.6241376",
"0.623684",
"0.62282264",
"0.62063974",
"0.6185084",
"0.61837757",
"0.6170775",
"0.61664444",
"0.615576",
"0.6150362",
"0.6135351",
"0.6127484",
"0.6122052",
"0.61077553",
"0.6103779",
"0.60998017",
"0.6099557",
"0.60956156",
"0.60923314",
"0.6088979",
"0.6082626",
"0.6078689",
"0.6059645",
"0.6048348",
"0.60449296",
"0.6044389",
"0.60417885",
"0.6031807",
"0.60228765",
"0.60078186",
"0.6001286",
"0.5998457",
"0.599477",
"0.599254",
"0.5990172",
"0.5986691",
"0.5977393",
"0.5976033",
"0.59691304",
"0.59578645",
"0.5947423",
"0.59444565",
"0.59431493",
"0.5942321",
"0.59410185",
"0.59410053",
"0.59410053",
"0.5935788",
"0.5932068",
"0.5930879",
"0.5919515",
"0.59177774",
"0.59164166",
"0.5909349",
"0.59071356",
"0.59028757",
"0.5902337",
"0.5902011",
"0.5901991",
"0.5899025",
"0.5897865",
"0.5889055",
"0.58875906",
"0.58837926",
"0.5882761",
"0.588173",
"0.588062",
"0.58788306",
"0.5876678",
"0.5875384",
"0.58746135",
"0.58722013",
"0.58706236",
"0.58690304",
"0.5859258",
"0.5851985",
"0.58394146",
"0.5835271",
"0.5832256",
"0.5827868",
"0.5824116",
"0.5823822",
"0.58223337",
"0.5821775",
"0.58190817",
"0.5818521",
"0.58177024",
"0.5814128",
"0.5814074",
"0.5811151"
] | 0.64758664 | 2 |
DELETE /mensajes/1 or /mensajes/1.json | def destroy
@mensaje.destroy
respond_to do |format|
format.html { redirect_to mensajes_url, notice: "Mensaje was successfully destroyed." }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @mensagem = Mensagem.find(params[:id])\n api_client.delete_object(@mensagem.post_id)\n @mensagem.destroy\n\n respond_to do |format|\n format.xml { head :ok }\n format.js { head :ok }\n end\n end",
"def destroy\n @mensaje = Mensaje.find(params[:id])\n @mensaje.destroy\n\n respond_to do |format|\n format.html { redirect_to(mensajes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @mensagem.destroy\n respond_to do |format|\n format.html do\n redirect_to campanha_mensagens_path(@campanha), notice: {\n type: 'info',\n message: 'Mensagem removida com sucesso.'\n }\n end\n format.json { head :no_content }\n end\n end",
"def destroy\n @mensagem = Mensagem.find(params[:id])\n @mensagem.destroy\n\n respond_to do |format|\n format.html { redirect_to(mensagens_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @mensaje_usuario = MensajeUsuario.find(params[:id])\n @mensaje_usuario.destroy\n\n respond_to do |format|\n format.html { redirect_to mensaje_usuarios_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @prueba_json.destroy\n respond_to do |format|\n format.html { redirect_to prueba_jsons_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @respuesta = Respuesta.find(params[:id])\n @respuesta.destroy\n\n respond_to do |format|\n format.html { redirect_to respuestas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @jednani.destroy\n respond_to do |format|\n format.html { redirect_to jednanis_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @metodologia.destroy\n respond_to do |format|\n format.html { redirect_to metodologias_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @jornada = Jornada.find(params[:id])\n @jornada.destroy\n\n respond_to do |format|\n format.html { redirect_to jornadas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @jamaat = Jamaat.find(params[:id])\n @jamaat.destroy\n\n respond_to do |format|\n format.html { redirect_to jamaats_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @mision.destroy\n respond_to do |format|\n format.html { redirect_to misions_url, notice: 'La misión se eliminó correctamente.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ajudante.destroy\n respond_to do |format|\n format.html { redirect_to ajudantes_url, notice: \"Ajudante foi apagado com sucesso.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @mantenimiento.destroy\n respond_to do |format|\n format.html { redirect_to mantenimientos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @jugadore.destroy\n respond_to do |format|\n format.html { redirect_to jugadores_url }\n format.json { head :no_content }\n format.js\n end\n end",
"def destroy\r\n @motivo_movimiento_caja.destroy\r\n respond_to do |format|\r\n format.html { redirect_to motivo_movimiento_cajas_url, success: 'Eliminaste un motivo correctamenteed.' }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @enquete.destroy\n respond_to do |format|\n format.html { redirect_to enquetes_url, notice: 'Enquete removida com sucesso!' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @metodo = Metodo.find(params[:id])\n @metodo.destroy\n\n respond_to do |format|\n format.html { redirect_to metodos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @matriz.destroy\n respond_to do |format|\n format.html { redirect_to matrizs_url, notice: 'Matriz was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @personaje_mision = PersonajeMision.find(params[:id])\n @personaje_mision.destroy\n\n respond_to do |format|\n format.html { redirect_to personaje_misions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @nominee.destroy\n respond_to do |format|\n format.html { redirect_to nominees_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n string = \"DELETE FROM notes WHERE famille_id = #{@famille.id}\"\n connection = Demande.connection\n connection.delete(string)\n @famille.destroy\n respond_to do |format|\n format.html { redirect_to familles_url, notice: 'Famille was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @respuesta = Respuesta.find(params[:id])\n @respuesta.destroy\n\n head :no_content\n end",
"def destroy\n @apertura_moneda.destroy\n respond_to do |format|\n format.html { redirect_to apertura_monedas_url, notice: 'Apertura moneda was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @personaje = Personaje.find(params[:id])\n @personaje.destroy\n\n respond_to do |format|\n format.html { redirect_to personajes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @midia.destroy\n\n respond_to do |format|\n format.html { redirect_to midias_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n respond_to do |format|\n if @apertura_caja.destroy\n format.html { redirect_to apertura_cajas_url }\n format.json { head :no_content }\n else\n format.html { redirect_to apertura_cajas_url, notice: 'No se puede eliminar.' }\n format.json { head :no_content }\n end\n end\n end",
"def destroy\n @policeman.destroy\n respond_to do |format|\n format.html { redirect_to policemen_url, notice: \"Policía eliminado con éxito.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @misione.destroy\n respond_to do |format|\n format.html { redirect_to misiones_url, notice: 'Misione was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @mecanicacomplejo = Mecanicacomplejo.find(params[:id])\n @mecanicacomplejo.destroy\n\n respond_to do |format|\n format.html { redirect_to mecanicacomplejos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @unidad.destroy\n respond_to do |format|\n format.html { redirect_to unidades_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ejemplo.destroy\n respond_to do |format|\n format.html { redirect_to ejemplos_url, notice: 'Ejemplo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @municao.destroy\n respond_to do |format|\n format.html { redirect_to municaos_url, notice: 'A Munição foi deletada com sucesso!' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @datosgenerale.destroy\n respond_to do |format|\n format.html { redirect_to datosgenerales_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @medico.destroy\n respond_to do |format|\n format.html { redirect_to medicos_url, notice: \"Medico deletado com SUCESSO.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @content.destroy\n respond_to do |format|\n format.html { redirect_to contents_url, notice: \"Файл #{@content.title} был удалён\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @asignatura.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @mijnwerknemer.destroy\n respond_to do |format|\n format.html { redirect_to mijnwerknemers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @musique = Musique.find(params[:id])\n @musique.destroy\n\n respond_to do |format|\n format.html { redirect_to musiques_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @receita_medica = ReceitaMedica.find(params[:id])\n @receita_medica.destroy\n\n respond_to do |format|\n format.html { redirect_to receita_medicas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @repuestum = Repuestum.find(params[:id])\n @repuestum.destroy\n\n respond_to do |format|\n format.html { redirect_to repuesta_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @datos_de_pasaje.destroy\n respond_to do |format|\n format.html { redirect_to datos_de_pasajes_url, notice: 'Datos de pasaje was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @objetos_mensura.destroy\n respond_to do |format|\n format.html { redirect_to objetos_mensuras_url, notice: 'Objetos mensura was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @mutacao = Mutacao.find(params[:id])\n @mutacao.destroy\n\n respond_to do |format|\n format.html { redirect_to mutacaos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n \t @motivobaja = MotivoBaja.find(params[:id])\n @motivobaja.destroy\n respond_with(@motivobaja)\n end",
"def destroy\n seleccionarMenu(:juzgados)\n @juzgado = Juzgado.find(params[:id])\n @juzgado.destroy\n\n respond_to do |format|\n format.html { redirect_to juzgados_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @lista_desejo.destroy\n respond_to do |format|\n format.html { redirect_to back_uri, warning: 'Removido da lista de desejos.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @kolegij = Kolegij.find(params[:id])\n @kolegij.destroy\n\n respond_to do |format|\n format.html { redirect_to kolegijs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @conta.destroy\n params[:id] = nil\n respond_to do |format|\n format.html { redirect_to contas_path, notice: @@titulo + t('msg.remove') }\n format.json { head :no_content }\n end\n end",
"def destroy\n @mapeamento = Mapeamento.find(params[:id])\n @mapeamento.destroy\n\n respond_to do |format|\n format.html { redirect_to mapeamentos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @novedad_mecanica.destroy\n respond_to do |format|\n format.html { redirect_to unidad_url(@unidad), notice: 'Novedad mecanica was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @humanidades1 = Humanidades1.find(params[:id])\n @humanidades1.destroy\n\n respond_to do |format|\n format.html { redirect_to humanidades1s_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @documentacion.destroy\n respond_to do |format|\n format.html { redirect_to @mem, notice: 'Documentación eliminada correctamente.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @motivo.destroy\n respond_to do |format|\n format.html { redirect_to motivos_url, notice: 'Motivo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @objetivo.destroy\n respond_to do |format|\n format.html { redirect_to mision_objetivos_url, notice: 'Objetivo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @etiquetum.destroy\n respond_to do |format|\n format.html { redirect_to etiqueta_url, notice: 'Etiqueta borrada!' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @modelos_contadore.destroy\n respond_to do |format|\n format.html { redirect_to modelos_contadores_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ficha = Ficha.find(params[:id])\n @ficha.destroy\n\n respond_to do |format|\n format.html { redirect_to fichas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @adm_noticia.destroy\n respond_to do |format|\n format.html { redirect_to adm_noticias_url, notice: t('noticias.destroy_success') }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ejercicio.destroy\n respond_to do |format|\n format.html { redirect_to ejercicios_url, notice: 'Ejercicio eliminado con exito.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @mundo.destroy\n respond_to do |format|\n format.html { redirect_to mundos_url, notice: 'Mundo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @puntaje = Puntaje.find(params[:id])\n @puntaje.destroy\n\n respond_to do |format|\n format.html { redirect_to puntajes_url }\n format.json { head :no_content }\n end\n end",
"def delete\n render json: Alien.delete(params[\"id\"])\n end",
"def destroy\n @cliente.destroy\n respond_to do |format|\n format.html { redirect_to clientes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @mensaje = Mensaje.find(params[:id])\n @mensaje.destroy\n\n receptores_ids = MensajeUsuario.where(:mensaje_id => params[:id]).select(:usuario_id).group(:usuario_id).collect{|p| p.usuario_id}\n receptores_ids.each do |receptor_id|\n MensajeUsuario.where(:usuario_id => receptor_id, :mensaje_id => params[:id]).destroy_all\n end\n\n respond_to do |format|\n format.html { redirect_to mensajes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @orcamento.destroy\n respond_to do |format|\n format.html { redirect_to orcamentos_url, notice: 'Orçamento apagado com sucesso!' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @lectura.destroy\n respond_to do |format|\n format.html { redirect_to lecturas_url, notice: 'La lectura fue eliminada.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @lectura.destroy\n respond_to do |format|\n format.html { redirect_to lecturas_url, notice: 'La lectura fue eliminada.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pregoestitulo.destroy\n respond_to do |format|\n format.html { redirect_to pregoestitulos_url, notice: 'Título excluído com sucesso.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @reconocimiento = Reconocimiento.find(params[:id])\n @reconocimiento.destroy\n\n respond_to do |format|\n format.html { redirect_to reconocimientos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @questionnaire.destroy\n respond_to do |format|\n format.html { redirect_to questionnaires_url, notice: 'Тест успешно удален.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @detalle = Detalle.find(params[:id])\n @detalle.destroy\n\n respond_to do |format|\n format.html { redirect_to detalles_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n respond_to do |format|\n if @nivel_mall.destroy\n format.html { redirect_to nivel_malls_path, notice: \"El nivel #{@nivel_mall.nombre} eliminado satisfactoriamente\" }\n format.json { head :no_content }\n else\n format.html { redirect_to nivel_malls_path, alert: \"El nivel #{@nivel_mall.nombre} no puede ser eliminado porque tiene locales asociados\" }\n format.json { head :no_content }\n end\n end\n end",
"def destroy\n @loja = Loja.find(params[:id])\n @loja.destroy\n\n respond_to do |format|\n format.html { redirect_to lojas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @saida.destroy\n respond_to do |format|\n format.html { redirect_to saidas_url, notice: 'Saida foi apagado com sucesso.' }\n format.json { head :no_content }\n end\n end",
"def delete\n supprimer = QuestionOuverteService.instance.supprimerQuestion(params[:id])\n (supprimer) ? (render json: true, status: :ok) : (render json: false, status: :not_found)\n end",
"def destroy\n @tipo_plan.destroy\n respond_to do |format|\n msg = { :status => \"ok\", :message => \"Eliminado!\" }\n format.json { render :json => msg }\n end\n end",
"def destroy\n @movimentacao.destroy\n respond_to do |format|\n format.html { redirect_to movimentacaos_url, notice: \"Movimentação Apagada com Sucesso.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @requerimiento = Requerimiento.find(params[:id])\n @requerimiento.destroy\n\n respond_to do |format|\n format.html { redirect_to requerimientos_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @cliente = Cliente.find(params[:id])\n @cliente.destroy\n\n respond_to do |format|\n format.html { redirect_to clientes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cliente = Cliente.find(params[:id])\n @cliente.destroy\n\n respond_to do |format|\n format.html { redirect_to clientes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cliente = Cliente.find(params[:id])\n @cliente.destroy\n\n respond_to do |format|\n format.html { redirect_to clientes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\r\n @cambiar_tema.destroy\r\n respond_to do |format|\r\n format.html { redirect_to cambiar_temas_url, notice: 'Su petición para cambiar de tema de tesis fue eliminada.' }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @kolegiji = Kolegiji.find(params[:id])\n @kolegiji.destroy\n\n respond_to do |format|\n format.html { redirect_to kolegijis_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @medida_talla.destroy\n respond_to do |format|\n format.html { redirect_to fichatecnica_medida_tallas_url(@fichatecnica), notice: 'Medida talla was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @jugadore.destroy\n respond_to do |format|\n format.html { redirect_to jugadores_url, notice: 'Jugadore was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cliente.destroy\n respond_to do |format|\n format.html { redirect_to clientes_url, notice: 'Cliente removido com sucesso.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @unidad_medida.destroy\n respond_to do |format|\n format.html { redirect_to unidad_medidas_url, notice: 'Unidad medida was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @adminmatrixgenu.destroy\n respond_to do |format|\n format.html { redirect_to adminmatrixgenus_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @rango_fecha.destroy\n respond_to do |format|\n format.html { redirect_to rango_fechas_url, notice: 'Rango fecha was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ejercicio = Ejercicio.find(params[:id])\n @ejercicio.destroy\n\n respond_to do |format|\n format.html { redirect_to ejercicios_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @lista = @mensagem.presente.lista\n @mensagem.destroy\n respond_to do |format|\n format.html { redirect_to @lista }\n format.json { head :no_content }\n end\n end",
"def destroy\n @questao.destroy\n respond_to do |format|\n format.html { redirect_to questaos_url, notice: 'Questao was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @jour.destroy\n respond_to do |format|\n format.html { redirect_to jours_url, notice: 'Jour was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @subject.delete\n respond_to do |format|\n format.html { redirect_to subjects_url, notice: 'La matière a été supprimée' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @imovel.destroy\n respond_to do |format|\n format.html { redirect_to imovels_url, notice: 'Imóvel excluído com sucesso.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @mae.destroy\n respond_to do |format|\n format.html { redirect_to maes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @servico_pacote.destroy\n respond_to do |format|\n format.html { redirect_to servico_pacotes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @article.destroy\n respond_to do |format|\n format.html { redirect_to articles_url, notice: 'Članek je bil uspešno izbrisan!' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @seguidore = Seguidore.find(params[:id])\n @seguidore.destroy\n\n respond_to do |format|\n format.html { redirect_to seguidores_url }\n format.json { head :ok }\n end\n end"
] | [
"0.7568959",
"0.7388924",
"0.7284272",
"0.72007215",
"0.7189235",
"0.71758914",
"0.7164094",
"0.7153764",
"0.71487385",
"0.7112125",
"0.7111706",
"0.7098437",
"0.70939046",
"0.70911866",
"0.70823276",
"0.7066904",
"0.7056552",
"0.7046564",
"0.70450073",
"0.70429957",
"0.7026979",
"0.7018438",
"0.70164293",
"0.7014401",
"0.7011708",
"0.7010914",
"0.700959",
"0.70090604",
"0.7007383",
"0.70069015",
"0.700665",
"0.7004552",
"0.69981885",
"0.69888306",
"0.6987596",
"0.698115",
"0.6979619",
"0.6978397",
"0.697755",
"0.6973169",
"0.69609886",
"0.6959056",
"0.6949801",
"0.6948206",
"0.69460064",
"0.69430405",
"0.6942212",
"0.69395983",
"0.6937288",
"0.6928942",
"0.69277817",
"0.6927364",
"0.69271255",
"0.6924015",
"0.691887",
"0.691714",
"0.69125205",
"0.69006705",
"0.6897176",
"0.6893501",
"0.68850106",
"0.68849105",
"0.6884099",
"0.6880933",
"0.6879072",
"0.68778217",
"0.6875286",
"0.6875286",
"0.6871341",
"0.68682575",
"0.6861765",
"0.6860908",
"0.6859773",
"0.6858382",
"0.6857422",
"0.685695",
"0.68555504",
"0.68523383",
"0.6852108",
"0.68506724",
"0.68506724",
"0.68506724",
"0.6848886",
"0.6848498",
"0.6847689",
"0.6846611",
"0.68445563",
"0.6843062",
"0.68430465",
"0.6842277",
"0.6841724",
"0.68412524",
"0.68409276",
"0.68407506",
"0.6840626",
"0.6837511",
"0.6836557",
"0.68338686",
"0.6831086",
"0.68302995"
] | 0.71788293 | 5 |
Use callbacks to share common setup or constraints between actions. | def set_mensaje
@mensaje = Mensaje.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def setup_handler\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def workflow\n end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup\n # override and do something appropriate\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def after_set_callback; end",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def save_action; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def setup(&blk)\n @setup_block = blk\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def duas1(action)\n action.call\n action.call\nend",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend"
] | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576",
"0.53124547",
"0.529654",
"0.5296262",
"0.52952296",
"0.52600986",
"0.52442724",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.5232394",
"0.523231",
"0.5227454",
"0.52226824",
"0.52201617",
"0.5212327",
"0.52079266",
"0.52050185",
"0.51754695",
"0.51726824",
"0.51710224",
"0.5166172",
"0.5159343",
"0.51578903",
"0.51522785",
"0.5152022",
"0.51518047",
"0.51456624",
"0.51398855",
"0.5133759",
"0.5112076",
"0.5111866",
"0.5111866",
"0.5110294",
"0.5106169",
"0.509231",
"0.50873137",
"0.5081088",
"0.508059",
"0.50677156",
"0.50562143",
"0.5050554",
"0.50474834",
"0.50474834",
"0.5036181",
"0.5026331",
"0.5022976",
"0.5015441",
"0.50121695",
"0.5000944",
"0.5000019",
"0.4996878",
"0.4989888",
"0.4989888",
"0.49864885",
"0.49797225",
"0.49785787",
"0.4976161",
"0.49683493",
"0.4965126",
"0.4958034",
"0.49559742",
"0.4954353",
"0.49535993",
"0.4952725",
"0.49467874",
"0.49423352",
"0.49325448",
"0.49282882",
"0.49269363",
"0.49269104",
"0.49252945",
"0.4923091",
"0.49194667",
"0.49174926",
"0.49173003",
"0.49171105",
"0.4915879",
"0.49155936"
] | 0.0 | -1 |
Only allow a list of trusted parameters through. | def mensaje_params
params.require(:mensaje).permit(:usuario_id, :comentario_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def param_whitelist\n [:role, :title]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def allow_params_authentication!; end",
"def whitelisted_args\n args.select &:allowed\n end",
"def safe_list_sanitizer; end",
"def safe_list_sanitizer; end",
"def safe_list_sanitizer; end",
"def filtered_parameters; end",
"def sanitize_params_for user, params, allowed_params\n params.each do |key, val|\n #if allowed_params.include?(key)\n #sanitize!(user, params, key) if key =~ /_attributes|_ids$/\n #else\n #params.delete(key)\n #end\n params.delete(key) unless allowed_params.include?(key.to_sym)\n end\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def expected_permitted_parameter_names; end",
"def sanitize_parameters!(sanitizer, params)\n # replace :readwrite with :onlyif\n if params.has_key?(:readwrite)\n warn \":readwrite is deprecated. Replacing with :onlyif\"\n params[:onlyif] = params.delete(:readwrite)\n end\n\n # add default parameters\n bindata_default_parameters.each do |k,v|\n params[k] = v unless params.has_key?(k)\n end\n\n # ensure mandatory parameters exist\n bindata_mandatory_parameters.each do |prm|\n if not params.has_key?(prm)\n raise ArgumentError, \"parameter ':#{prm}' must be specified \" +\n \"in #{self}\"\n end\n end\n\n # ensure mutual exclusion\n bindata_mutually_exclusive_parameters.each do |param1, param2|\n if params.has_key?(param1) and params.has_key?(param2)\n raise ArgumentError, \"params #{param1} and #{param2} \" +\n \"are mutually exclusive\"\n end\n end\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def safe_list_sanitizer=(_arg0); end",
"def safe_list_sanitizer=(_arg0); end",
"def safe_list_sanitizer=(_arg0); end",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def check_params; true; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def allowed?(*_)\n true\n end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def allowed_params(parameters)\n parameters.select do |name, values|\n values.location != \"path\"\n end\n end",
"def secure_params\n return @secure_params if @secure_params\n\n defn = implementation_class.definition\n field_list = [:master_id] + defn.field_list_array\n\n res = params.require(controller_name.singularize.to_sym).permit(field_list)\n res[implementation_class.external_id_attribute.to_sym] = nil if implementation_class.allow_to_generate_ids?\n @secure_params = res\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permit( params, whitelist, name = nil )\n raise 'Parametrization not yet configured' unless @configured\n whitelist ||= []\n px = params.respond_to?( :permit ) ? params : ActionController::Parameters.new( params )\n px = dig(px, name)\n px.permit( *whitelist )\n end",
"def valid_params?; end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def url_allowlist=(_arg0); end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def list_params\n params.permit(:list_name)\n end",
"def valid_params_request?; end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def param_list(param_type, name, type, required, description = nil, allowed_values = [], hash = {})\n hash.merge!({allowable_values: {value_type: \"LIST\", values: allowed_values}})\n param(param_type, name, type, required, description, hash)\n end",
"def safelists; end",
"def authorize_own_lists\n authorize_lists current_user.lists\n end",
"def listed_params\n params.permit(:listed, :list_id, :listable_id, :listable_type, :campsite_id)\n end",
"def lists_params\n params.require(:list).permit(:name)\n\n end",
"def list_params\n params.require(:list).permit(:name, :user_id)\n end",
"def list_params\n params.require(:list).permit(:name, :description, :type, :privacy, :allow_edit, :rating, :votes_count, :user_id)\n end",
"def check_params\n true\n end",
"def authorize_own_or_shared_lists\n authorize_lists current_user.all_lists\n end",
"def user_pref_list_params\n\t\tparams.require(:user).permit(:preference_list)\n\tend",
"def may_contain!(*keys)\n self.allow_only_permitted = true\n self.permitted_keys = [*permitted_keys, *keys].uniq\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def whitelist; end",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def list_params\n params.permit(:name)\n end",
"def recipient_list_params\n params.require(:recipient_list).permit(:name, :list, :references)\n end",
"def cancan_parameter_sanitizer\n resource = controller_name.singularize.to_sym\n method = \"#{resource}_params\"\n params[resource] &&= send(method) if respond_to?(method, true)\n end",
"def list_params\n params.require(:list).permit(:name).merge(user_id: current_user.id)\n end",
"def whitelist_place_params\n params.require(:place).permit(:place_name, :unlock, :auth, :is_deep_checked, :parent_ADM4, :parent_ADM3, :parent_ADM2, :parent_ADM1, :parent_country, feature_code: [], same_as: [], related_authority: [], altlabel: [], note: []) # Note - arrays need to go at the end or an error occurs!\n end",
"def list_params\n params.fetch(:list, {}).permit(:user_id, :name, :active)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def secure_params(require_param, permit_keys)\n params.require(require_param).permit(*permit_keys)\n end",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def permitted_params\n []\n end",
"def price_list_params\n params.fetch(:price_list, {}).permit(:name, :valid_from, :valid_to, :active,\n :all_warehouses, :all_users, :all_contact_groups,\n warehouse_ids: [], price_lists_user_ids: [], contact_group_ids: [])\n end",
"def params(list)\n @declared_params = list\n end",
"def admin_review_params\n params.fetch(:review, {}).permit(whitelisted_params)\n end",
"def saved_list_params\n params.require(:saved_list).permit(:user_id)\n end",
"def allow(ids); end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def filter_params(param_set, **kwargs)\r\n begin\r\n key = kwargs[:key]\r\n params.require(key).permit(*param_set)\r\n rescue Exception\r\n params.permit(*param_set)\r\n end\r\n end",
"def valid_parameters\n sort_symbols(@interface.allowed_parameters)\n end",
"def validate_paramified_params\n self.class.paramify_methods.each do |method|\n params = send(method)\n transfer_errors_from(params, TermMapper.scope(params.group)) if !params.valid?\n end\n end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def secure_params\n return @secure_params if @secure_params\n\n @implementation_class = implementation_class\n resname = @implementation_class.name.ns_underscore.gsub('__', '_').singularize.to_sym\n @secure_params = params.require(resname).permit(*permitted_params)\n end",
"def refine_permitted_params(param_list)\n res = param_list.dup\n\n ms_keys = res.select { |a| columns_hash[a.to_s]&.array }\n ms_keys.each do |k|\n res.delete(k)\n res << { k => [] }\n end\n\n res\n end",
"def recipient_list_params\n params.require(:recipient_list).permit(:name, :description, recipient_id_array: [])\n end",
"def safelist; end",
"def sponsor_params\n params.require(:sponsor).permit(WHITE_LIST)\n end",
"def valid_for_params_auth?; end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def shopping_list_params\n params.require(:shopping_list).permit!\n end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def permitters\n @_parametrizr_permitters || {}\n end",
"def allow_params(action, keys: nil, except: nil, &blk)\n keys &&= Array.wrap(keys)\n keys ||= User.field_names\n except &&= Array.wrap(except)\n except ||= %i[id email]\n devise_parameter_sanitizer.permit(action, keys: keys, except: except, &blk)\n end",
"def list_params\n if current_user && current_user.role == 'admin'\n params.require(:list).permit(:name, :url, :description, :user_id,\n ideas_attributes: [:id, :list_id, :body, :due_date, :completion_status, :_destroy])\n else\n params.require(:list).permit(:name, :description,\n ideas_attributes: [:body, :due_date, :completion_status]) \n end\n end",
"def whitelist(params)\n send_request_of_type(GlobalConstant::PrivateOpsApi.private_ops_api_type, 'post', '/token-sale/whitelist', params)\n end",
"def valid_access_params\n params.require(:valid_access).permit(:wish_list_id, :user_id)\n end",
"def url_allowlist; end",
"def ensure_redirected_params_are_safe!(passed_params)\n unless passed_params.is_a?(ActionController::Parameters) && passed_params.permitted?\n error_message = if passed_params.is_a?(ActionController::Parameters)\n unsafe_parameters = passed_params.send(:unpermitted_keys, params)\n \"[Rails::Prg] Error - Must use permitted strong parameters. Unsafe: #{unsafe_parameters.join(', ')}\"\n else\n \"[Rails::Prg] Error - Must pass strong parameters.\"\n end\n raise error_message\n end\n end",
"def data_collection_params\n allow = [:name,:description,:institution,:collection_name,:country_id,:province_id,:city_id]\n params.require(:data_collection).permit(allow)\n end",
"def quote_params\n params.permit!\n end"
] | [
"0.69497335",
"0.6812623",
"0.6803639",
"0.6795365",
"0.67448795",
"0.67399913",
"0.6526815",
"0.6518771",
"0.64931697",
"0.6430388",
"0.6430388",
"0.6430388",
"0.63983387",
"0.6356042",
"0.63535863",
"0.63464934",
"0.63444513",
"0.6337208",
"0.6326454",
"0.6326454",
"0.6326454",
"0.63140553",
"0.6299814",
"0.62642586",
"0.626006",
"0.62578833",
"0.6236823",
"0.6227561",
"0.6221758",
"0.62200165",
"0.620879",
"0.61983657",
"0.6195055",
"0.6172993",
"0.6156856",
"0.61558664",
"0.61521494",
"0.6135789",
"0.6121145",
"0.61118174",
"0.60736513",
"0.6071645",
"0.60632104",
"0.60549796",
"0.6043906",
"0.6034662",
"0.60207325",
"0.6018568",
"0.6016575",
"0.60103434",
"0.60084206",
"0.600763",
"0.6007443",
"0.6003619",
"0.6003619",
"0.5995791",
"0.5993301",
"0.5993231",
"0.5984926",
"0.597122",
"0.5968121",
"0.5965808",
"0.59640145",
"0.59632224",
"0.59602356",
"0.59332967",
"0.5927556",
"0.5922805",
"0.5909745",
"0.5905083",
"0.5904304",
"0.5893434",
"0.58888215",
"0.58823985",
"0.58823985",
"0.58823985",
"0.5873434",
"0.58619875",
"0.58533794",
"0.5845531",
"0.58426666",
"0.58360124",
"0.583218",
"0.5828041",
"0.5827927",
"0.5816121",
"0.5814705",
"0.5812719",
"0.581121",
"0.5803423",
"0.5803423",
"0.57995003",
"0.5794207",
"0.5784923",
"0.5781365",
"0.5776385",
"0.5774859",
"0.57671493",
"0.5766998",
"0.57618684",
"0.5758038"
] | 0.0 | -1 |
METHODS Input file structure: PatientIDMutStartMutStopChr 267369 53186624 138826345 X | def load_file(file_name)
patients_info = {}
File.open(file_name).each do |line|
line.chomp!
fields = line.split("\t")
chrom_number = fields.delete_at(1)
fields = fields[0..2]
fields.map!{|a| a.to_i}
query = patients_info[chrom_number]
if query.nil?
patients_info[chrom_number] = [fields]
else
query << fields
end
end
return patients_info
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read\n $t1 = Time.now # Init procedure timestamp\n person = []\n IO.foreach(\"data_500.txt\") do |line| # Get all patients from file iterate each line\n line.chomp! # Remove trailing whitespace.\n person.push(line.split(\":\")) # Saving data split :\n end\n group(person) # Get blood type\n end",
"def initialize(line)\n cols = line.chomp.split \"\\t\"\n name = [ cols[0], cols[2,4] ]\n @readName = name.flatten.join(':') + '#' + cols[6] + '/' + cols[ 7 ] \n @seq = cols[ 8 ]\n @qvList = cols[ 9 ].each_byte.map {|i| i - 64 }\n @chrom = cols[ 10 ]\n @offset = cols[ 12 ].to_i\n @strand = cols[ 13 ]\n @filter = cols[ 21 ]\n end",
"def read_genotypes (filename, people)\n file = File.open(filename)\n\n header = file.readline.strip.split(/\\s+/)\n header.shift # omit the first field, \"Marker\"\n\n file.readlines.each do |line|\n marker = line[0..8].gsub(/\\s/, \"\")\n line = line[9..-1]\n header.each_with_index do |person, i|\n start = i*7\n people[person].gen[marker] = parse_genotype line[start..(start+6)]\n end\n end\nend",
"def read_mrp\n $MRP_FILE = $PRJ_NAME + \"_map.mrp\"\n f = open($MRP_FILE,\"r\")\n while line = f.gets\n if /ERROR/ =~ line\n /LOC=(.*)\\)/ =~ line # pick up Slice name\n $ERROR_SLICE << $1\n end\n end\n f.close\n $ERROR_SLICE.uniq!\nend",
"def from_io(io)\n io.pos = 0 if io.pos != 0 \n st = io.read(148)\n (@start_time, @start_mass, @end_mass, @num_dta_files, @group_scan, @min_group_count, @min_ion_threshold, @start_scan, @end_scan) = st.unpack('x36ex12ex4ex48Ix12IIIII')\n self\n end",
"def import_a_igcfile(file)\n\n columns = [ :lat_lon, :baro_alt, :gps_alt, :enl, :seq_secs, :igcfile_id, :rlat, :rlon, :x, :y]\n options = { :validate => false }\n save_obj=Hash.new\n sma=[]\n\n objects = []\n num_recs=1 # to prevent divide by zero\n counter=0\n\n begin\n igcfile = Igcfile.new()\n igcfile.filename=file\n igcfile.save!\n rescue\n next\n end\n\n start = Time.now\n\n # I033638FXA3941ENL4247REX an I record defines B record extensions\n counter=0\n time=0\n fp = File.open(file, \"r\")\n contents = fp.read\n\n # get I record\n b_extensions2 = Hash.new\n contents.each_line do |line|\n a=line.unpack('a1a2a7a7a7a7a7a7a7') # hopefully enough\n if a[0]=='A'\n next\n end\n if a[0]=='H'\n next\n end\n if a[0]=='I'\n if not a[1].nil?\n 0.upto(a[1].to_i){|n|\n b=a[n+2].unpack('a2a2a3')\n b_extensions2[b[2]]={:start => b[0], :finnish => b[1]}\n }\n end\n break\n end\n break\n end\n\n if b_extensions2.length == 0\n puts 'No I record'\n end\n\n if b_extensions2['ENL'].nil?\n puts 'No ENL in I record'\n else\n # puts b_extensions2['ENL'].inspect\n end\n\n # last_time=0\n contents.each_line do |line|\n # 0(1)=rec, 1(6)=time, 2(8)=lat, 3(9)=lon, 4(1)=validity, 5(5)=baro_alt, 6(5)=gps_alt\n # optional see Irec 7(3)=fix_accuracy, 8(2)=num_satelites, 9(3)=enl\n\n a=line.unpack('a1a6a8a9a1a5a5a')\n if a[0].to_s == 'B'\n\n num_recs=num_recs+1\n\n # time B0915235535648N01340869EA-006900049000\n h,m,s = a[1].scan(%r{(\\d{2})(\\d{2})(\\d{2})}).flatten\n time = h.to_i * 3600 + m.to_i * 60 + s.to_i\n # if last_time==0\n # last_time=time\n # end\n\n # enl\n if hv=b_extensions2['ENL']\n enl=line[hv[:start].to_i..hv[:finnish].to_i]\n else\n enl='0'\n end\n\n dd,mm,mmm,ns = a[2].scan(%r{(\\d{2})(\\d{2})(\\d{3})(\\w{1})}).flatten #Latitude DDMMMMMN Valid characters N, S, 0-9\n rlat = ((dd.to_f + mm.to_f/60 + (mmm.to_f/1000)/60))*RAD_PER_DEG\n rlat = - rlat unless ns=='N'\n\n ddd,mm,mmm,ew = a[3].scan(%r{(\\d{3})(\\d{2})(\\d{3})(\\w{1})}).flatten #Longitude DDDMMMMME Valid characters E,W, 0-9\n rlon = ((ddd.to_f + mm.to_f/60 + (mmm.to_f/1000)/60))*RAD_PER_DEG\n rlon = - rlon unless ew=='E'\n\n # cartesian\n x = (RADIUS * Math.cos(rlat) * Math.cos(rlon)).to_i\n y = (RADIUS * Math.cos(rlat) * Math.sin(rlon)).to_i\n\n #columns = [ :lat_lon, :baro_alt, :gps_alt, :enl, :seq_secs, :igcfile_id, :rlat, :rlon, :x, :y]\n #objects << [ a[2]+','+a[3],a[5].to_i,a[6].to_i,enl.to_i, time, igcfile.id,rlat,rlon,x.to_i,y.to_i]\n obj = { :lat_lon => a[2]+','+a[3], :baro_alt => a[5].to_i, :gps_alt => a[6].to_i,\n :enl => enl.to_i, :seq_secs => time, :igcfile_id => igcfile.id, :rlat => rlat, :rlon => rlon,\n :x => x, :y => y}\n\n if not save_obj.empty?\n #puts \"one time\"\n\n #speed\n obj[:ms] = (((obj[:x] - save_obj[:x])**2 + (obj[:y] - save_obj[:y])**2)**0.5)/(obj[:seq_secs] - save_obj[:seq_secs])\n #obj[:ms] = (obj[:seq_secs] - save_obj[:seq_secs])\n #obj[:ms] = (obj[:seq_secs] - save_obj[:seq_secs])\n # if obj[:ms] == 0\n # puts obj[:ms]\n # end\n # energy change\n obj[:pe] = GLIDER_MASS * GRAV_CONST * (obj[:baro_alt] )\n #obj[:pe] = GLIDER_MASS * GRAV_CONST * (obj[:baro_alt] + Polar_sink[obj[:ms]] * (obj[:seq_secs] - save_obj[:seq_secs]))\n obj[:ke] = 0.5 * GLIDER_MASS * (obj[:ms])**2 # should compensate speed for wind component here\n #obj[:te]= obj[:ke] + obj[:pe]\n obj[:dedt]=((obj[:pe] - save_obj[:pe]) + (obj[:ke] - save_obj[:ke])) / (obj[:seq_secs] - save_obj[:seq_secs])\n\n\n #moving average speed in 2 dimnsions. could be moved out of this loop\n max=0\n may=0\n avg_cnt=0\n objects.reverse_each {|item|\n break if item[:seq_secs] < obj[:seq_secs]-30\n avg_cnt+=1\n max=max+item[:x]\n may=may+item[:y]\n }\n\n if avg_cnt > 0\n obj[:max]=(max/avg_cnt).to_i\n obj[:may]=(may/avg_cnt).to_i\n else\n obj[:max]=obj[:x]\n obj[:may]=obj[:y]\n end\n\n obj[:mams] = (((obj[:max] - save_obj[:max])**2 + (obj[:may] - save_obj[:may])**2)**0.5)/(obj[:seq_secs] - save_obj[:seq_secs]).to_i\n #obj[:mams] = (obj[:seq_secs] - save_obj[:seq_secs]) * 100\n # if obj[:mams] == 0\n # obj[:mams]=10\n # else\n # end\n #obj[:mams] = save_obj[:seq_secs]\n #obj[:mams]=0\n\n objects << obj\n else\n obj[:ms]=0\n obj[:pe]=0\n obj[:ke]=0\n obj[:max]=obj[:x]\n obj[:may]=obj[:y]\n end\n\n save_obj=obj\n end\n end\n\n #\n objects.each_with_index do |object,index|\n\n avg_cnt=0\n objects[0..index].reverse_each {|item|\n break if item[:seq_secs] < object[:seq_secs]-40\n avg_cnt+=1\n\n # te = (object[:te] - save_obj[:te]) unless save_obj[:te].nil?\n # tt = (object[:seq_secs] - save_obj[:seq_secs]) unless save_obj[:seq_secs].nil?\n # dedt = te/tt - ()\n\n # max=max+item[:x]\n # may=may+item[:y]\n }\n\n # if avg_cnt > 0\n # obj[:max]=(max/avg_cnt).to_i\n # obj[:may]=(may/avg_cnt).to_i\n # obj[:mams] = (((obj[:max] - item[:max])**2 + (obj[:may] - item[:may])**2)**0.5)/(obj[:seq_secs] -item[:seq_secs]).to_i\n # else\n # obj[:mams]=0\n # #obj[:max]=obj[:x]\n # #obj[:may]=obj[:y]\n # end\n # the import bogs down if there are too many records so chop it up\n counter=counter+1\n # if counter > 100\n # Igcpoint.import(columns, objects, options)\n # objects=[]\n # counter=0\n # end\n end\n\n ary = []\n objects.each do |obj|\n ary << [ obj[:lat_lon], obj[:baro_alt], obj[:dedt], obj[:enl], obj[:seq_secs], obj[:igcfile_id], obj[:rlat], obj[:rlon], obj[:x], obj[:y]]\n #ary << [ obj[:lat_lon], obj[:baro_alt], obj[:gps_alt], obj[:enl], obj[:seq_secs], obj[:igcfile_id], obj[:rlat], obj[:rlon], obj[:x], obj[:y]]\n end\n\n Igcpoint.import(columns, ary, options) unless ary.length==0\n secs = Time.now - start\n puts file.to_s + ' ' + num_recs.to_s + ' ' + (num_recs/secs).to_i.to_s\n STDOUT.flush\n\n fp.close\n num_recs\n end",
"def parse_claim(claim)\n cid, coords = claim.split('@')\n orig, size = coords.split(':')\n tx, ty = orig.strip.split(',')\n tdx, tdy = size.strip.split('x')\n x1 = tx.to_i\n y1 = ty.to_i\n x2 = x1 + tdx.to_i\n y2 = y1 + tdy.to_i\n [cid, x1...x2, y1...y2 ]\nend",
"def annotate\n genes={}\n File.open(ANNOTATION,'r').each do |line|\n temp=line.split\n genes[temp[9]]={}\n genes[temp[9]][\"start\"]=temp[3].to_i\n genes[temp[9]][\"end\"]=temp[4].to_i\n genes[temp[9]][\"strand\"]=temp[6]\n genes[temp[9]][\"length\"]=temp[4].to_i - 1 - temp[3].to_i\n end\n return genes\nend",
"def parse(line)\n @pattern, *@owners = line.split(/\\s+/)\n @whitespace = line.split('@').first.count(' ') - 1\n @spec = parse_spec(@pattern)\n end",
"def read_shift(single_line)\r\n#\treturn \"Wrong line\" unless single_line =~/^(\\d{2})\\/(\\d{2})\\/(\\d{4})/\r\n shift_date=single_line.split(',')[0].split[0]\r\n shift=single_line.split(',')[1]\r\n cg=shift.split(':')[0]\r\n shift_start=shift.split('-')[0].split(':')\r\n if shift =~ /(\\d{2})\\/(\\d{2})\\/(\\d{4})/ \r\n startTime=Time.strptime(shift_start[1]+\":\"+shift_start[2], ' %m/%d/%Y %I:%M %p')\r\n endTime=Time.strptime(shift.split('-')[1], ' %m/%d/%Y %I:%M %p')\r\n else\r\n startTime=Time.strptime(shift_date+shift_start[1]+\":\"+shift_start[2], ' %m/%d/%Y %I:%M %p')\r\n endTime=Time.strptime(shift_date+shift.split('-')[1], ' %m/%d/%Y %I:%M %p')\r\n end\r\n [shift_date, cg, startTime, endTime]\r\nend",
"def from_file line\n\t\tvals = line.split(\"-\")\n\t\t@type = vals[0].to_i\n\t\t@obj = vals[1]\n\t\tif vals[2] != nil\n\t\t\t@sensor = vals[2]\n\t\tend\n\t\tif vals[3] != nil\n\t\t\t@value = vals[3].to_f\n\t\tend\n\tend",
"def test_read_file\n begin\n File.open('test.txt', 'w') { |f| f.write('0|0|SYSTEM>569274(100)|1553184699.650330000|288d') }\n end\n assert_equal [['569274', 100]], @verify.read('test.txt')\n end",
"def readIDSFile(filename, char_hash)\n File.open(filename) do |f|\n while (line = f.gets)\n next if line.match(/^;;/) # line commented out?\n a = line.strip.split(\"\\t\")\n char_hash[a[0]] = Hash.new() unless char_hash.has_key? a[0]\n char_hash[a[0]][:ids] = a[2].to_u\n end\n end\nend",
"def parse_annotation_file filename\n lines = File.open(filename,'r').read.split(\"\\n\")\n puts lines.size\n bad_header = lines.shift.split(\"\\t\")\n header = %w'seq_id reciprocal_id reciprocal_rank sp_symbol sp_evalue sp_description pfam_ids go_ids'\n data = []\n lines.each do |line|\n fields = line.split(\"\\t\")\n fields = fields.collect {|f| (f == \"#N/A\") ? nil : f}\n d = Hash[header.zip(fields)]\n d['pfam_ids'] = (d['pfam_ids']) ? d['pfam_ids'].split(\";\") : []\n\n d['go_ids'] = (d['go_ids']) ? d['go_ids'].split(\";\") : []\n data << d\n end\n data\nend",
"def uniqueSequences file\n\n seqIDs = {}\n printSeq = 1\n File.open(file,\"r\") do |f|\n while l = f.gets\n if l[0] == \">\"\n key = l.split(\"\\n\")[0].split(\" \")[0]\n if seqIDs.has_key? key\n printSeq = 0\n else\n seqIDs[\"#{key}\"] = 0\n printSeq = 1\n puts l\n end\n elsif printSeq == 1\n puts l\n end\n end\n end\n\n end",
"def read_synthesisview_file(synthfile, chromlist, glisthash, highlighted_group=\"\",\n\t\t\tsnpTags=nil)\n defaultkey = GroupList.get_default_name\n firstline = true\t\t\n begin\n File.open(synthfile, \"r\") do |file|\n # read in all lines\n lines = Array.new\n #file.each_line(\"\\r\") do |line|\n file.each_line(\"\\n\") do |line|\n line.each_line(\"\\r\") do |splitline|\n lines << splitline unless splitline =~ /^\\n$/\n end\n end\n group_column, subgroup_column = check_subgroup(lines[0]) \n unless subgroup_column || group_column\n set_groups(glisthash, lines[0], defaultkey, highlighted_group, snpTags)\n else\n set_groups_subgroup(glisthash, lines, defaultkey, group_column, subgroup_column, \n\t\t\t\t\thighlighted_group,snpTags)\n end\n\n # if there is built-in MySQL support for looking up position\n # information\n snp_positions = get_locations(lines, synthfile, :has_positions=>@location)\n\n lines.each do |line|\n # skip blank lines\n next if line !~ /\\w/\n\n # read column headers to create groups\n if firstline\n firstline = false\n next\n end\n\n # split line and check whether need to create new chromosome\n data = strip_and_split(line)\n\n # if no location information present skip\n\t\t\t\t@snpid ? snpid = data[@snpid] : snpid = data[@snp1] + '_' + data[@snp2]\n\t\t\t\t# if no SNP name in file set SNP name to be same as SNPID\n\t\t\t\t@snpname == -1 ? snpname = snpid : snpname = data[@snpname]\n next if !snp_positions.has_key?(snpid)\n chrnum = snp_positions[snpid]['chr']\n chrname = chrnum.to_s\n if chrnum =~ /mt/i\n chrnum = \"26\"\n elsif chrnum =~ /y/i\n chrnum = \"24\"\n elsif chrnum =~ /x/i\n chrnum = \"23\"\n end\n \n if (chromosome = chromlist.get_chrom(chrnum.to_i)) == nil\n # create a new SNP\n newchrom = Chromosome.new(chrnum.to_i, chrname)\n chromlist.add_chrom(newchrom)\n chromosome = chromlist.get_chrom(chrnum.to_i)\n end\n\n # location will be first num listed\n location = snp_positions[snpid]['pos']\n location = location.to_i\n snp = chromosome.snp_list.get_snp(snpid) \n unless snp\n\t\t\t\t\tunless @anccol.empty?\n\t\t\t\t\t\tanc_array = Array.new\n\t\t\t\t\t\tanc_array << data[@anccol[0]].to_f\n\t\t\t\t\t\tanc_array << data[@anccol[1]].to_f\n\t\t\t\t\t\tanc_array << data[@anccol[2]].to_f\n\t\t\t\t\tend\n snp = SNP.new(snpname, location, anc_array)\n chromosome.snp_list.add_snp(snp)\n snp = chromosome.snp_list.get_snp(snpname)\n end\n\t\t\t\tsnp.text_color = data[@snpcolorcol] if @snpcolorcol and data[@snpcolorcol] =~ /\\w/\n # add results to SNP\n if !subgroup_column and !group_column\n glisthash.each_value do |glist|\n glist.groups.each do |group|\n read_group_data(snp, group, data)\n end\n end\n elsif subgroup_column and group_column\n glisthash.each do |name, glist|\n if name == data[subgroup_column]\n glist.groups.each do |group|\n if group.name == data[group_column] + \":\" + data[subgroup_column]\n read_group_data(snp, group, data)\n end\n end\n end\n end \n elsif group_column\n glisthash.each_value do |glist|\n glist.groups.each do |group|\n if group.name == data[group_column]\n read_group_data(snp, group, data)\n end\n end\n end\n end\n end\n end\n rescue StandardError => e\n puts e\n exit(1)\n end\n end",
"def genome(liszt)\n=begin\n[samopen] SAM header is present: 2 sequences\n7621912 reads; of these:\n 4009241 (52.60%) were paired; of these:\n 1983557 (49.47%) aligned concordantly 0 times\n 1818685 (45.36%) aligned concordantly exactly 1 time\n 206999 (5.16%) aligned concordantly >1 times\n ----\n 1983557 pairs aligned concordantly 0 times; of these:\n 409503 (20.64%) aligned discordantly 1 time\n ----\n 1574054 pairs aligned 0 times concordantly or discordantly; of these:\n 3148108 mates make up the pairs; of these:\n 1009275 (32.06%) aligned 0 times\n 35392 (1.12%) aligned exactly 1 time\n 2103441 (66.82%) aligned >1 times\n 3612671 (47.40%) were unpaired; of these:\n 498719 (13.80%) aligned 0 times\n 2246121 (62.17%) aligned exactly 1 time\n 867831 (24.02%) aligned >1 times\n=end\n #puts(liszt);exit\n dict={}; liszt.shift\n dict[\"total\"]=liszt.shift.split[0]; #liszt.shift\n dict[\"paired\"]=liszt.shift.split[0]; liszt.shift #conc 0\n dict[\"conc_once\"]=liszt.shift.split[0]\n dict[\"conc_mult\"]=liszt.shift.split[0]\n liszt.shift(2); dict[\"disc_once\"]=\"\"; dict[\"disc_mult\"]=\"\"\n line=liszt.shift\n line.include?(\">1 times\") ? dict[\"disc_mult\"]=line.split[0] : dict[\"disc_once\"]=line.split[0]\n liszt.shift\n dict[\"unaligned_pairs\"]=liszt.shift.split[0]\n liszt.shift\n dict[\"unmates\"]=liszt.shift.split[0] #unaligned mates\n dict[\"mate_once\"]=liszt.shift.split[0]\n dict[\"mate_mult\"]=liszt.shift.split[0]\n dict[\"unpaired\"]=liszt.shift.split[0]\n dict[\"unpair_unaligned\"]=liszt.shift.split[0]\n dict[\"unpair_once\"]=liszt.shift.split[0]\n dict[\"unpair_mult\"]=liszt.shift.split[0]\n dict\nend",
"def read_elements(line)\n # comment\n return if line =~ /^#/\n\n # id, name, password, e-mail(encrypted), swn, sls, gwn, gls\n elements = line.chomp.split(',')\n return unless elements.length.between?(8, 9) # invalid line\n\n dec = OpenSSL::Cipher.new('AES-256-CBC')\n dec.decrypt\n (id, name, passwd, encemail) = elements\n # id = elements[0]\n @names[id] = name # elements[1]\n @passwords[id] = passwd # elements[2]\n @emails[id] = UserInfoFileContent.decode_mail(dec, encemail)\n @stats[id] = UserInfoFileContent.hash_stats(elements)\n end",
"def parse_input(input_file); end",
"def parse_input(input_file); end",
"def parse_claim(str)\n Claim.new(*/^\\#(\\d+) \\@ (\\d+),(\\d+): (\\d+)x(\\d+)$/.match(str).captures.map(&:to_i))\nend",
"def ReadStuData(id,scores)\n #read file Chp9gm2i.txt and get the student id and scores read into an array\n @line = 0\n File.open('Chp9Pgm2i.txt','r') do |f1|\n while line = f1.gets\n @temp_line = line.split(' ')\n id [@line] = @temp_line[0] #Student's ID\n scores[@line] = @temp_line[1].to_i #Exam Score\n @line = @line +1\n end #ends while\n end #ends file.open\n return id, scores\nend",
"def readGpr(file_path)\n begin \n read = IO.read(file_path)\n #logger.debug read.to_s + \"====================================================\"\n\n\tif !read.valid_encoding?\n \t \tread = read.encode(\"UTF-16be\", :invalid=>:replace, :undef => :replace, :replace=>\"\").encode('UTF-8')\n\tend\n\n\t#read.encode!('UTF-8', :invalid => :replace, :undef => :replace)\n\t#logger.debug read.to_s + \"====================================================\"\n\tread_array = []\n\tread_array = read.split(\"\\n\") \n\t#logger.debug read_array.to_s + \"====================================================\"\n # if read.valid_encoding?\n #read_array = read.split(\"\\n\")\n # \n # else\n # read_array = read.encode!(\"ASCII-8BIT\",\"ASCII-8BIT\", invalid: :replace, :undef => :replace).split(\"\\n\")\n # end\n \n\tmod_array = read_array.map {|e| e.chomp.split(\"\\t\")} \n\t#logger.debug mod_array.to_s + \"================================================\"\n\n\telement_stabilized = mod_array.map {|element| element.join(\",\").gsub(\"\\\"\",\"\").split(\",\")} \n\t#logger.debug element_stabilized.to_s + \"====================================================\"\n\n\theader_removed, column_array = [], []\n\tif element_stabilized[0].include?(\"ATF\")\n\t\theader_removed = element_stabilized.drop_while {|i| i unless i.include?(\"Block\")}\n\t\t#logger.debug header_removed.to_s + \"====================================================\"\n\telse\n\t\traise NoGprError, \"File does not seem to be GPR formatted. Check the file\"\n\tend\n\n\t#logger.debug \"@#@#@##@#@#@#@#@#@#@#\" + header_removed.kind_of?(Array).to_s + \"@#@#@##@#@#@#@#@##@#@#@\"\t\n\n\tcolumn_array = header_removed.transpose\n\t#logger.debug column_array.to_s + \"#########################################################\"\t\n\n\t@name, @dia, @f633_mean, @b633_mean = getColumns(column_array)\n\t@probeNames, @sorted_tsi, @sorted_snr = calTotalSignalIntensity(@name, @dia, @f633_mean, @b633_mean)\n \n\treturn @probeNames, @sorted_tsi, @sorted_snr\n\n rescue Exception => e\n e.message\n e.backtrace.inspect\n end \n\n end",
"def parse_header\n @snp, @line, @type, @in, @polymorphism, @chromosome, @orientation = self.sequence_id.split(\" \") \n @type = @type.to_sym\n if @in\n @in = @in.to_sym == :exon \n else\n @exon = false\n end\n\n if @polymorphism.to_sym == :homoeologous\n @homoeologous = true\n else\n @homoeologous = false\n end\n @parsed = true\n @orientation = @orientation.to_sym\n end",
"def process_irc message\n res = message.scan(/\\00314\\[\\[\\00307(.*)\\00314\\]\\]\\0034\\s+(.*)\\00310\\s+\\00302.*(diff|oldid)=([0-9]+)&(oldid|rcid)=([0-9]+)\\s*\\003\\s*\\0035\\*\\003\\s*\\00303(.*)\\003\\s*\\0035\\*\\003\\s*\\((.*)\\)\\s*\\00310(.*)\\003/).first\n #get rid of the diff/oldid and oldid/rcid groups\n res.delete_at(4)\n res.delete_at(2)\n res\n end",
"def initialize(file_line, pid_dictionary)\n line_elements = file_line.split(\" \")\n \n @t0 = line_elements.shift.to_i\n @process_name = line_elements.shift\n @tf = line_elements.shift.to_i\n @number_of_bytes = line_elements.shift.to_i\n @pid = assign_pid(pid_dictionary)\n\n @memory_accesses = []\n until line_elements.empty?\n @memory_accesses << [line_elements.shift.to_i, line_elements.shift.to_i]\n end\n end",
"def read_trim_params\n # compensation parameter register mapping\n Calibration = Struct.new(\n # Register Address Register content Data type\n :dig_T1, # 0x88 / 0x89 dig_T1 [7:0] / [15:8] unsigned short\n :dig_T2, # 0x8A / 0x8B dig_T2 [7:0] / [15:8] signed short\n :dig_T3, # 0x8C / 0x8D dig_T3 [7:0] / [15:8] signed short\n :dig_P1, # 0x8E / 0x8F dig_P1 [7:0] / [15:8] unsigned short\n :dig_P2, # 0x90 / 0x91 dig_P2 [7:0] / [15:8] signed short\n :dig_P3, # 0x92 / 0x93 dig_P3 [7:0] / [15:8] signed short\n :dig_P4, # 0x94 / 0x95 dig_P4 [7:0] / [15:8] signed short\n :dig_P5, # 0x96 / 0x97 dig_P5 [7:0] / [15:8] signed short\n :dig_P6, # 0x98 / 0x99 dig_P6 [7:0] / [15:8] signed short\n :dig_P7, # 0x9A / 0x9B dig_P7 [7:0] / [15:8] signed short\n :dig_P8, # 0x9C / 0x9D dig_P8 [7:0] / [15:8] signed short\n :dig_P9, # 0x9E / 0x9F dig_P9 [7:0] / [15:8] signed short\n :dig_H1, # 0xA1 dig_H1 [7:0] unsigned char\n :dig_H2, # 0xE1 / 0xE2 dig_H2 [7:0] / [15:8] signed short\n :dig_H3, # 0xE3 dig_H3 [7:0] unsigned char\n :dig_H4, # 0xE4 / 0xE5[3:0] dig_H4 [11:4] / [3:0] signed short\n :dig_H5, # 0xE5[7:4] / 0xE6 dig_H5 [3:0] / [11:4] signed short\n :dig_H6, # 0xE7 dig_H6 signed char\n :t_fine\n )\n calib = [] \n\n # data addresses\n dig_t_reg = 0x88\n dig_p_reg = 0x8E\n dig_h_reg1 = 0xA1\n dig_h_reg2 = 0xE1\n \n data = read(dig_t_reg, 6)\n calib << ((data[1] << 8) | data[0]) # uint16_t dig_T1 [1][0] \n calib << int16(data[3], data[2]) # int16_t dig_T2 [3][2]\n calib << int16(data[5], data[4]) # int16_t dig_T3 [5][4]\n\n data = read(dig_p_reg, 18)\n calib << ((data[1] << 8) | data[0]) # uint16_t dig_P1 [1][0]\n calib << int16(data[3], data[2]) # int16_t dig_P2 [3][2]\n calib << int16(data[5], data[4]) # int16_t dig_P3 [5][4]\n calib << int16(data[7], data[6]) # int16_t dig_P4 [7][6]\n calib << int16(data[9], data[8]) # int16_t dig_P5 [9][8]\n calib << int16(data[11], data[10]) # int16_t dig_P6 [11][10]\n calib << int16(data[13], data[12]) # int16_t dig_P7 [13][12]\n calib << int16(data[15], data[14]) # int16_t dig_P8 [15][14]\n calib << int16(data[17], data[16]) # int16_t dig_P9 [17][16]\n\n data = read(dig_h_reg1, 1)\n calib << data[0] # uint8_t dig_H1 [0]\n \n data = read(dig_h_reg2, 7)\n calib << int16(data[1], data[0]) # int16_t dig_H2 [1],[0]\n calib << data[2] # uint8_t dig_H3 [2] \n\n # 109876543210 bit[11:0]\n # xxxxxxxx.... dig_H4_msb [11:4] [3]\n # ....xxxx dig_H4_lsb [3:0] [4]\n # xxxxxxxxxxxx dig_H4 [11:0] \n dig_H4_msb = (data[3] >> 4) & 0x0F\n dig_H4_lsb = ((data[3] << 4) & 0xF0) | (data[4] & 0x0F) \n calib << int16(dig_H4_msb, dig_H4_lsb) # int16_t dig_H4 [3][4]\n \n # 109876543210 bit[11:0]\n # xxxxxxxx.... dig_H5_msb [11:4] [5]\n # xxxx.... dig_H5_lsb [7:4] [4]\n # xxxxxxxxxxxx dig_H5 [11:0]\n dig_H5_msb = (data[5] >> 4) & 0x0F\n dig_H5_lsb = ((data[5] << 4) & 0xF0) | (data[4] >> 4) \n calib << int16(dig_H5_msb, dig_H5_lsb) # int16_t dig_H5 [4][5]\n \n calib << int8(data[6]) # int8_t dig_H6 [6]\n\n @calib = Calibration.new(*calib)\n end",
"def carma_facs_parse_header(line, id_map)\n m = line.match(/=(\\d+)/) \n if m.nil?\n STDERR.puts \"No id found\"\n exit 1\n end \n id = m[1]\n m = line.match (/SOURCE_1=\\\"(.*)\\\"/) \n if m.nil?\n STDERR.puts \"No name found\"\n exit 1\n end \n name=m[1]\n identifier_map(id, name, id_map)\nend",
"def compass_convert\n file = File.open('data_imu.txt', 'r')\n file.readlines.each do |line|\n next unless line =~ /compass:/\n array = line.split(', ')\n capture_raw(array)\n end # end of loop\n file.close\nend",
"def loci\n CSV.read(@file).map do |row|\n {\n :name => row[@columns[:name]],\n :target => row[@columns[:target]],\n :strand => STRAND_TOKENS[row[@columns[:strand]]],\n :start => row[@columns[:start]].to_i - 1, # This arithmetic gives\n :stop => row[@columns[:stop]].to_i, # inclusive, one-indexed\n # slices\n }\n end\n end",
"def initialize(filename)\n @metadata = {}\n @char_metrics = {}\n @char_metrics_by_code = {}\n @kern_pairs = []\n File.open(filename) do |file|\n mode = :meta\n file.each_line do |line|\n case(line)\n when /^StartFontMetrics/ ; mode = :meta\n when /^StartCharMetrics/ ; mode = :char_metrics\n when /^EndCharMetrics/ ; mode = :meta\n when /^StartKernData/ ; mode = :kern_data\n when /^StartKernPairs/ ; mode = :kern_pairs\n when /^EndKernPairs/ ; mode = :kern_data\n when /^EndKernData/ ; mode = :meta\n else\n case(mode)\n when :meta\n if match = line.match(/^([\\w]+) (.*)$/)\n @metadata[match[1]] = match[2]\n end\n when :char_metrics\n metrics = {}\n metrics[:charcode] = match[1].to_i if match = line.match(/C (-?\\d+) *?;/)\n metrics[:wx] = match[1].to_i if match = line.match(/WX (-?\\d+) *?;/)\n metrics[:name] = match[1] if match = line.match(/N ([.\\w]+) *?;/)\n if match = line.match(/B (-?\\d+) (-?\\d+) (-?\\d+) (-?\\d+) *?;/)\n metrics[:boundingbox] = [match[1].to_i, match[2].to_i, match[3].to_i, match[4].to_i] \n end\n @char_metrics[metrics[:name]] = metrics if metrics[:name]\n @char_metrics_by_code[metrics[:charcode]] = metrics if metrics[:charcode] && metrics[:charcode] > 0\n when :kern_pairs\n if match = line.match(/^KPX ([.\\w]+) ([.\\w]+) (-?\\d+)$/)\n @kern_pairs << [match[1], match[2], match[3].to_i]\n end\n end\n end\n end\n end\n end",
"def patentToInventor(patent_id, inventor_line)\n\tinventor_line.split(')#').each do |inventor_info|\n\t\tinventor, inventor_loc = inventor_info.split(' (')\n\t\tputs inventor, inventor_loc\n\t\t# insert into inventor (`patent_id`, `inventor_name`, `inventor_location`) values (patent_id, inventor, inventor_loc)\n\tend\nend",
"def initialize(filename, info_line) \n @filename = filename\n revision = info_line[0...info_line.index(' ')]\n @revision = Integer(revision[1..-1]) # remove #\n datetime = info_line.scan(/\\d\\d\\d\\d\\/\\d\\d\\/\\d\\d \\d\\d:\\d\\d:\\d\\d/)[0]\n @datetime = DateTime.strptime(datetime, '%Y/%m/%d %H:%M:%S')\n end",
"def split_refseq\n # prepare output files\n system(%Q[cut -f4 #{$prepare_dir}/refseq_genes_result.tsv | cut -c1-5 | sort | uniq > #{$prepare_dir}/refp_prefix_list.txt ]) # get exist prefix list of protein_id\n FileUtils.mkdir_p(\"#{$prepare_dir}/refp\") unless File.exist?(\"#{$prepare_dir}/refp\")\n refp_output = {}\n File.open(\"#{$prepare_dir}/refp_prefix_list.txt\") do |f|\n f.each_line do |line|\n prefix = line.chomp.strip\n refp_output[prefix] = File.open(\"#{$prepare_dir}/refp/#{prefix}.dat\", \"w\")\n end\n end\n refp_output[\"no_protein_id\"] = File.open(\"#{$prepare_dir}/refp/no_protein_id.dat\", \"w\") # protein_id is optional\n\n File.open(\"#{$prepare_dir}/refseq_genes_result.tsv\") do |f|\n f.each_line do |line|\n columns = line.chomp.strip.split(\"\\t\")\n prefix = (columns[3].nil? || columns[3] == \"\") ? \"no_protein_id\" : columns[3][0..4] # protein_id is optional\n refp_output[prefix].puts line.chomp.strip\n end\n end\n refp_output.each do |k, v|\n v.flush\n v.close\n end\nend",
"def process_fna(fna_file)\n fna_hash = Hash.new\n input = File.new(fna_file,'r')\n first_loop = true\n dna_seq = \"\"\n id = \"\"\n count = 0\n while(line = input.gets)\n if(line[0..0] == '>')\n if(first_loop == false)\n fna_hash[id] = dna_seq\n end\n position=line.split(\"|\")\n id = position[3][0..-3]\n dna_seq = \"\"\n first_loop = false\n else\n count = count+1\n dna_seq.concat(line[0..-2])\n end\n end\n fna_hash[id] = dna_seq\n return(fna_hash)\nend",
"def detect_marc_fields\r\n @mrk_fields_to_a = @mrk_file.scan /\\=[0-9][0-9][0-9]/\r\n @mrk_fields_to_a.each do |field|\r\n @mrk_fields_with_index[field] = (@mrk_file.index(field))\r\n end\r\n end",
"def initialize(line, qfasta_file, tfasta_file)\n a = line.split\n @qid = a[0]\n @qstart = a[1].to_i\n @qend = a[2].to_i\n @qstrand = a[3]\n @tid = a[4]\n @tstart = a[5].to_i\n @tend = a[6].to_i\n @tstrand = a[7]\n @score = a[8]\n @cigar = a[9..-1].each_slice(2).to_a.map{|a, b| [a, b.to_i]}\n\n @qfasta_file = qfasta_file\n @tfasta_file = tfasta_file\n end",
"def read_file(path)\n struct=Struct.new(:u_id, :m_id,:rating,:time)\n puts path\n return [] if !File.exists? path\n File.open(path, \"r\") do |f|\n #splits each line by ws and convert to integer and build structures from values\n return f.each_line.map { |line| struct.new(*line.split.map {|x| x.to_i}) }\n end\n end",
"def initialize myfile\n\t\t@file_read = false # can we read the file and is it in the expected format\n\t\t@dat_file = myfile\n\n\t\tif (!@file_read = read_file?)\n\t\t\tputs \"'#{@dat_file}' has invalid input. It must have integers seperated by new line chars.\"\n\t\tend\n\tend",
"def index_commands\n File.foreach \"#{$userfile}\" do |line|\n\tline = line.chomp\n\tif !$unique_seq.include?(line)\n\t $unique_seq << line\n\tend\n end\n File.foreach \"#{$userfile}\" do |line|\n\tline = line.chomp\n\t$observation_seq << $unique_seq.index(line)\n end\nend",
"def initialize(file)\n @gps_out_file = file\n @lines = File.open(@gps_out_file).readlines\n @header = @lines.shift\n\n @num_of_conditions = num_of_conditions\n @num_of_events = num_of_events\n end",
"def refseq_sequence\n \"NC_0000\" + chrom.sub(/X/, \"23\").sub(/Y/, \"24\")\n end",
"def sampling\n\t\t@input_ary.each_with_index { |line,i|\n\t\t\tif line =~ /^SAMPLING=([0-9]*)\\s*/\n\t\t\t\t@fileinfo[:sampling] = $1.to_i \n\t\t\t\tat = i+1\n\t\t\tend\n\t\t}\n\t\traise DTA_ReaderErr, \"Cannot find sampling time!\" unless @fileinfo[:sampling]\n\t\traise DTA_ReaderErr, \"Error parsing sampling time :: #{@input_file}:#{at} :: SAMPLING=\" + $1.inspect if @fileinfo[:count] == 0\n\tend",
"def sigs(file, line, col); end",
"def sigs(file, line, col); end",
"def test_parse_mdc_snp_data\n column_headings = []\n snp_data = []\n File.open(\"#{RAILS_ROOT}/test/mocks/#{@mdc_filename}\",\"r\") do |file|\n while (f = file.gets)\n\n next if f =~ /^#/ # ignore lines that start with a hash - comments\n f.strip! # remove any whitespace, linefeeds, etc.\n\n # if this line has the column headings, extract and do the next line\n if f =~ /^a1_External_ID/\n column_headings = f.split(/\\t/)\n next\n end\n\n # Split the mdc file based on tabs\n snp_data = f.split(/\\t/)\n\n # load_hapmap_snp_data(column_headings,snp_data)\n break # jump out after first line as we're just testing the parsing\n end # end of file_array.each loop\n\n # test that we're parsing the headings and the SNP data correctly\n assert_equal 235, snp_data.size\n assert_equal \"a2_RGSCv3.4_chr\",column_headings[1]\n assert_equal \"rat105_009_k11.p1ca_226\",snp_data[0]\n assert_equal \"2283252\",snp_data[2]\n assert_equal '6',snp_data[233] # penultimate entry\n assert_equal '6',snp_data[234] # last entry\n assert_equal nil,snp_data[235] # shouldnt exist\n end\n end",
"def from_file(filename, opts)\n @resident_dir = File.dirname(File.expand_path(filename))\n opts = { :filter_by_precursor_mass_tolerance => true, :read_pephits => true}.merge(opts)\n\n (@params, after_params_io_pos) = Mspire::Sequest::Srf.get_sequest_params_and_finish_pos(filename)\n return unless @params\n\n dup_references = 0\n dup_refs_gt_0 = false\n\n dup_references = @params.print_duplicate_references.to_i\n if dup_references == 0\n # warn %Q{\n #*****************************************************************************\n #WARNING: This srf file lists only 1 protein per peptide! (based on the\n #print_duplicate_references parameter in the sequest.params file used in its\n #creation) So, downstream output will likewise only contain a single protein\n #for each peptide hit. In many instances this is OK since downstream programs\n #will recalculate protein-to-peptide linkages from the database file anyway.\n #For complete protein lists per peptide hit, .srf files must be created with\n #print_duplicate_references > 0. HINT: to capture all duplicate references, \n #set the sequest parameter 'print_duplicate_references' to 100 or greater.\n #*****************************************************************************\n # }\n else\n dup_refs_gt_0 = true\n end\n\n File.open(filename, 'rb') do |fh|\n @header = Mspire::Sequest::Srf::Header.from_io(fh)\n @version = @header.version\n\n unpack_35 = case @version\n when '3.2'\n false\n when '3.3'\n false\n when '3.5'\n true\n end\n\n if @header.combined\n @base_name = File.basename(filename, '.*')\n # I'm not sure why this is the case, but the reported number is too\n # big by one on the 2 files I've seen so far, so we will correct it here!\n @header.dta_gen.num_dta_files = @header.dta_gen.num_dta_files - 1\n if opts[:read_pephits] == false\n raise NotImplementedError, \"on combined files must read everything right now!\"\n end\n (@dta_files, @out_files) = read_dta_and_out_interleaved(fh, @header.num_dta_files, unpack_35, dup_refs_gt_0)\n else\n @base_name = @header.raw_filename.scan(/[\\\\\\/]([^\\\\\\/]+)\\.RAW$/).first.first\n\n @dta_files = read_dta_files(fh, @header.num_dta_files, unpack_35)\n if opts[:read_pephits]\n # need the params file to know if the duplicate_references is set > 0\n raise NoSequestParamsError, \"no sequest params info in srf file!\\npass in path to sequest.params file\" if @params.nil?\n @out_files = read_out_files(fh,@header.num_dta_files, unpack_35, dup_refs_gt_0)\n\n # FOR DISPLAY ONLY!\n #@out_files.each do |f|\n # if f.num_hits == 10\n # p f.hits.last\n # end\n #end\n\n if fh.eof?\n #warn \"FILE: '#{filename}' appears to be an abortive run (no params in srf file)\\nstill continuing...\"\n @params = nil\n @index = []\n end\n end\n end\n\n fh.pos = after_params_io_pos\n\n # This is very sensitive to the grab_params method in sequest params\n fh.read(12) ## gap between last params entry and index \n\n @index = read_scan_index(fh,@header.num_dta_files)\n end\n\n\n ### UPDATE SOME THINGS:\n # give each hit a base_name, first_scan, last_scan\n if opts[:read_pephits] && [email protected]\n @index.each_with_index do |ind,i|\n mass_measured = @dta_files[i][0]\n outfile = @out_files[i]\n outfile.first_scan = ind[0]\n outfile.last_scan = ind[1]\n outfile.charge = ind[2]\n\n pep_hits = @out_files[i].hits\n @peptide_hits.push( *pep_hits )\n pep_hits.each do |pep_hit|\n pep_hit[15] = @base_name\n pep_hit[16] = ind[0]\n pep_hit[17] = ind[1]\n pep_hit[18] = ind[2]\n # add the deltamass\n pep_hit[12] = pep_hit[0] - mass_measured # real - measured (deltamass)\n pep_hit[13] = 1.0e6 * pep_hit[12].abs / mass_measured ## ppm\n pep_hit[19] = self ## link with the srf object\n end\n end\n\n filter_by_precursor_mass_tolerance! if params\n end\n\n self\n end",
"def main()\n input = ARGV[0] # original sample sheet\n sccout = ARGV[1] # SCC formatted sample sheet\n\n infile = File.new(input, \"r\")\n sccfile = File.new(sccout, \"w\") # SCC samplesheet for cellRanger\n\n # counter for headers\n flag = 1\n\n infile.each {\n |line|\n\n cols = line.chomp.split(/,/)\n if flag ==2\n \n sccfile.write \"Lane,Sample,Index\" +\"\\n\"\n end\n \n \n if (flag >= 2)\n\n sequenceLength = cols[9].split(\"_\")\n arrlength=sequenceLength.length() \n num = sequenceLength[arrlength-2].split(\"E\") \n # identify single cell projects\n if cols[9].include? \"_SCC_\"\n sccfile.write cols[1]+ \",\" + cols[2] + \",\" + cols[4] + \"\\n\"\n end\n end\n flag = flag + 1\n \n }\n\n infile.close()\n sccfile.close()\nend",
"def parse(line)\n params = line.split(/\\s+/)\n return nil unless params[0] == 'instruction'\n\n spec_defs = params[2..-1]\n specs = parse_specs(spec_defs)\n\n specs\n end",
"def parse_file!(input_file)\r\n File.open(input_file, \"rb:UTF-8\").each(LOCSTR_END_OF_LINE + \"\\n\") do |line|\r\n strings << line.chomp(LOCSTR_END_OF_LINE + \"\\n\") + \"\\x00\"\r\n end\r\n\r\n @number_of_strings = @strings.size\r\n @offset_to_strings = 8 + 8 * @number_of_strings\r\n end",
"def test_validate_file\n file_list = [\n '0|0|SYSTEM>569274(100)|1553184699.650330000|288d',\n '1|288d|569274>735567(12):735567>561180(3):735567>689881(2):SYSTEM>532260(100)|1553184699.652449000|92a2',\n '2|92a2|569274>577469(9):735567>717802(1):577469>402207(2):SYSTEM>794343(100)|1553184699.658215000|4d25'\n ]\n assert validate_file file_list, [0, 0], '0'\n end",
"def processFile(file)\n lines = IO.readlines(file)\n lines.sort!\n\n shifts = Array.new\n newshift = false\n lines.each{ |line|\n nums = line.scan(/\\d+/)\n nums.map! {|n| n.to_i}\n year, month, day, hour, minute, guard = nums\n if guard \n shifts.push(Shift.new(guard))\n else\n if line =~ /wakes up/\n shifts.last.addWake(minute)\n elsif line =~ /asleep/\n shifts.last.addSleep(minute)\n end\n end \n }\n return shifts\nend",
"def read_tsbs(line)\n case line\n when TSBS::DefaultATK\n @attack_id = $1.to_i\n when TSBS::DefaultDEF\n @guard_id = $1.to_i\n when TSBS::SBS_Start\n @load_tsbs = true\n when TSBS::SBS_Start_S\n @load_tsbs = true\n @battler_name = $1.to_s\n when TSBS::SBS_End\n @load_tsbs = false\n end\n super(line)\n end",
"def lex_line\n @chunks = @line.scan(/#{BRACKET_RE}|#{DATE_RE}|#{MOD_RE}|#{ATTR_REGEX}|#{OTHER_RE}/).chunk do |seg|\n case seg\n when BRACKET_RE then :bracket\n when MOD_RE then :modifier\n when DATE_RE then :date\n when ATTR_REGEX then :attr\n when OTHER_RE then :other\n else :error\n end\n end.to_a\n # it should be impossible to encounter errors, but cry if they happen\n check_for_errors\n @chunks\n end",
"def read_wire_points(str)\n points = []\n point_dists = {}\n x, y, len = 0, 0, 0\n\n str\n .split(',')\n .map { |s| m=s.match(/([LRUD])(\\d+)/); point(m[1], m[2].to_i) }\n .each do |dir, dist|\n while dist > 0\n case dir\n when \"L\" then x -= 1\n when \"R\" then x += 1\n when \"U\" then y -= 1\n when \"D\" then y += 1\n end\n dist -= 1\n len += 1\n p = point(x,y)\n points << p\n point_dists[p] = len\n end\n end\n\n Wire.new(points, point_dists)\nend",
"def parse_input (input_file)\nend",
"def sequence(chr, start = nil, stop = nil)\n raise SequenceFileError, \"Do not now how to query for sequences from #{File.basename(@data_file)}!\"\n end",
"def readParams(fname)\n begin\n f = File.open(fname)\n rescue Exception => e\n puts e\n $stdout.flush\n exit(1)\n end\n\n section = nil\n f.each_line{|line|\n\n line.chomp!\n line.strip!\n if line == \"\" || line =~ /^%/\n # skip blank lines & lines beginning with %\n\n elsif line == $headerPorts || line == $headerShips ||\n line == $headerTraveler || line == $headerOutput\n section = line\n\n elsif section == $headerPorts\n parts = line.split(' ')\n name = parts[0]\n size = parts[1].to_i\n $starport.push(Starport.new(name,size))\n \n elsif section == $headerShips\n parts = line.split(' ')\n name = parts[0]\n size = parts[1].to_i\n $starship.push(Starship.new(name,size))\n\n elsif section == $headerTraveler\n parts = line.split(' ')\n name = parts.shift\n itinerary = []\n parts.each { |p| itinerary.push(find_name($starport,p)) }\n person = Traveler.new(name,itinerary)\n $traveler.push(person)\n find_name($starport,parts.first).arrive(person)\n\n elsif section == $headerOutput\n $simOut.push(line)\n\n else\n puts \"ERROR: simFile format error at #{line}\"\n $stdout.flush\n exit(1)\n end\n }\nend",
"def update\n# read the first 2 lines - it should be enough\n# lsvob starts with \"Tag: \\BARABOOM\"\n# both lsreplica and lsepoch start with \"For VOB replica \"\\BARABOOM\":\"\n# the second line in lsreplica is \"replica \"name\"\"\n# the second line in lsepoch is \"Oplog IDs for row...\" or \"Actual oplog IDs for...\"\n# sometimes lsepcoh has multiple lines in the beginning with \"For VOB replica...\"\n parsed_line = Hash[ :vob => \"Tag: \",\n :lsepoch => \"For VOB replica \",\n :replica => \"replica \",\n :epoch => \"Oplog IDs for row \",\n :epoch_actual => \"Actual oplog IDs for \"]\n\n if params[:lslog].size > 0\n _line1 = params[:lslog].gets\n _line2 = params[:lslog].gets\n params[:lslog].rewind\n if !(_line1.nil? || _line2.nil?)\n if _line1.match(parsed_line[:vob].to_s)\n Site.lsvob_scan(params)\n elsif _line2.match(parsed_line[:epoch].to_s) || \n _line2.match(parsed_line[:epoch_actual].to_s) || \n _line2.match(parsed_line[:lsepoch].to_s)\n Site.lsepoch_scan(params)\n elsif _line2.match(parsed_line[:replica].to_s)\n Site.lsreplica_scan(params)\n else\n # error message\n flash[:notice] = \"INVALID FORMAT! - check the input file!\"\n end\n else\n # error message\n flash[:notice] = \"INVALID FORMAT! - check the input file!\"\n end\n end\n super\n end",
"def read_data stream=STDIN\n\tdata = {}\n\tstream.each do |line|\n\t\tline =~ /^([0-9]*)\\|(.*)/;\n\t\tid, name_addr = $1.to_i, $2\n\t\traise \"duplicate id #{id}?\" if data[id]\n\t\tdata[id] = name_addr\n\tend\n\tdata\nend",
"def initialize\n @original_line = \"\"\n @id = -1\n @pos = []\n @grade = \"\"\n @classifier = false\n @headword_trad = \"\"\n @headword_simp = \"\"\n @headword_en = \"\"\n @pinyin = \"\"\n @pinyin_diacritic = \"\"\n @meanings = []\n @is_erhua_variant = false\n @is_archaic_variant = false\n @variant_of = false\n @priority_word = false\n \n # There can be more than one of these\n @references = []\n end",
"def process()\n\n\t\t# first byte holds the address\n\t\ti = @sBuffer[0]\n\n\t\t# nil == i that would mean buffer is empty -> should never happen\n\t\treturn super if i.nil?\n\n\t\t# convert byte-value to natural-value\n\t\ti = i.chr.to_i\n\n\t\t# no broadcast possible as we are using natural chars instead of byte-value\n\t\t# and are looking at only 1 char\n#TODO: allow 0 to 9 and map eg 9 to broadcast\n\t\t# abort if not a valid ID\n\t\treturn super if !((0..3).member?(i)) # if invalid ID\n\n\t\t# target serial ID\n\t\tiFDD = i\n\n\t\tsBasename = File::basename(@sPathFile)\n\n\t\t# second byte holds the command\n\t\ti = @sBuffer[1]\n\n\t\tcase i.chr\n\t\t\twhen 'u'\n\t\t\t\t# set duration\n\t\t\t\tsData = 'u'\n\n\t\t\t\t# read duration\n\t\t\t\ti = @sBuffer[2..-1].to_i\n\n\t\t\t\t# if not a valid duration, clear buffer\n\t\t\t\treturn super if (1 > i)\n\n\t\t\t\tputs 'OK:ft:Got set-timer-duration-signal from Trigger ' << sBasename + ' for FDD ' << iFDD.to_s << ' value: ' << i.to_s\n\n\t\t\t\t# append 4 bytes\n\t\t\t\tsData << ((i >> 24) & 0xFF) << ((i >> 16) & 0xFF)\n\t\t\t\tsData << ((i >> 8) & 0xFF) << (i & 0xFF)\n\n\t\t\twhen 'v'\n\t\t\t\t# start timer\n\t\t\t\tputs 'OK:ft:Got start-timer-signal from Trigger ' << sBasename + ' for FDD ' << iFDD.to_s\n\n\t\t\t\tsData = 'v'\n\n\t\t\twhen 'V'\n\t\t\t\t# stop timer\n\t\t\t\tputs 'OK:ft:Got stop-timer-signal from Trigger ' << sBasename + ' for FDD ' << iFDD.to_s\n\n\t\t\t\tsData = 'V'\n\n\t\t\telse\n\n\t\t\t\t# if not a valid command, clear buffer\n\t\t\t\tputs 'KO:ft: Got invalid-timer signal from Trigger ' << sBasename\n\t\t\t\treturn super\n\n\t\tend # switch case\n\n\t\tSssSEMapp.oIOframeHandler.writeFramed(iFDD, sData)\n\n\t\t# clear buffer and return self\n\t\tsuper\n\n\tend",
"def parse_line(line)\n ln, fn, mi, sex, fav_color, dob = line.split(' | ')\n LineParser.to_h(fn, ln, mi, sex, fav_color, parse_dob(dob))\n end",
"def load_raw_line opts = OPTS_REGEX.keys\n self.raw_line.chomp!\n opts.each do |xfield|\n pattern = OPTS_REGEX[xfield]\n did_set = raw_setter xfield, pattern\n #puts did_set\n end\n end",
"def parse_bsr_line(line)\n finish_current_train\n @current_train = TrainSchedule.new\n @current_train.update_from_cif line\n @current_train_action = :update\n end",
"def handle_rover_position_instruction(file)\n\t\tline_reader = self.read_instruction_line(file, \" \")\n\t\tself.set_rover_start_coordinates(line_reader)\n\tend",
"def get_data_from_file(file)\r\n f = File.open(file, \"r\")\r\n gene = Array.new\r\n f.each_line do |line|\r\n gene << line.delete(\"\\n\") # We remove end of line \\n \r\n end\r\n return gene\r\nend",
"def getFtProtID\n protein_id = ARGV[1]\n protId = \"\"\n @gbkObj.each_cds do |ft|\n ftH = ft.to_hash\n ftloc = ft.locations\n if ftH[\"protein_id\"][0].include? protein_id\n gene = []\n product = []\n gene = ftH[\"gene\"] if !ftH[\"gene\"].nil?\n product = ftH[\"product\"] if !ftH[\"product\"].nil?\n protId = ftH[\"protein_id\"][0] if !ftH[\"protein_id\"].nil?\n locustag = ftH[\"locus_tag\"][0] if !ftH[\"locus_tag\"].nil?\n if ftloc[0].strand == -1\n location = \"c#{ftloc[0].from}..#{ftloc[0].to}\"\n else\n location = \"#{ftloc[0].from}..#{ftloc[0].to}\"\n end\n dna = getDna(ft,@gbkObj.to_biosequence)\n seqout = dna.output_fasta(\"#{@accession}|#{location}|#{protId}|#{locustag}|#{gene[0]}|#{product[0]}\",60)\n puts seqout\n end\n end\n end",
"def compile_metadata(path = \"PBS/metadata.txt\")\r\n GameData::Metadata::DATA.clear\r\n GameData::MapMetadata::DATA.clear\r\n # Read from PBS file\r\n File.open(path, \"rb\") { |f|\r\n FileLineData.file = path # For error reporting\r\n # Read a whole section's lines at once, then run through this code.\r\n # contents is a hash containing all the XXX=YYY lines in that section, where\r\n # the keys are the XXX and the values are the YYY (as unprocessed strings).\r\n pbEachFileSection(f) { |contents, map_id|\r\n schema = (map_id == 0) ? GameData::Metadata::SCHEMA : GameData::MapMetadata::SCHEMA\r\n # Go through schema hash of compilable data and compile this section\r\n for key in schema.keys\r\n FileLineData.setSection(map_id, key, contents[key]) # For error reporting\r\n # Skip empty properties, or raise an error if a required property is\r\n # empty\r\n if contents[key].nil?\r\n if map_id == 0 && [\"Home\", \"PlayerA\"].include?(key)\r\n raise _INTL(\"The entry {1} is required in {2} section 0.\", key, path)\r\n end\r\n next\r\n end\r\n # Compile value for key\r\n value = pbGetCsvRecord(contents[key], key, schema[key])\r\n value = nil if value.is_a?(Array) && value.length == 0\r\n contents[key] = value\r\n end\r\n if map_id == 0 # Global metadata\r\n # Construct metadata hash\r\n metadata_hash = {\r\n :id => map_id,\r\n :home => contents[\"Home\"],\r\n :wild_battle_BGM => contents[\"WildBattleBGM\"],\r\n :trainer_battle_BGM => contents[\"TrainerBattleBGM\"],\r\n :wild_victory_ME => contents[\"WildVictoryME\"],\r\n :trainer_victory_ME => contents[\"TrainerVictoryME\"],\r\n :wild_capture_ME => contents[\"WildCaptureME\"],\r\n :surf_BGM => contents[\"SurfBGM\"],\r\n :bicycle_BGM => contents[\"BicycleBGM\"],\r\n :player_A => contents[\"PlayerA\"],\r\n :player_B => contents[\"PlayerB\"],\r\n :player_C => contents[\"PlayerC\"],\r\n :player_D => contents[\"PlayerD\"],\r\n :player_E => contents[\"PlayerE\"],\r\n :player_F => contents[\"PlayerF\"],\r\n :player_G => contents[\"PlayerG\"],\r\n :player_H => contents[\"PlayerH\"]\r\n }\r\n # Add metadata's data to records\r\n GameData::Metadata.register(metadata_hash)\r\n else # Map metadata\r\n # Construct metadata hash\r\n metadata_hash = {\r\n :id => map_id,\r\n :outdoor_map => contents[\"Outdoor\"],\r\n :announce_location => contents[\"ShowArea\"],\r\n :can_bicycle => contents[\"Bicycle\"],\r\n :always_bicycle => contents[\"BicycleAlways\"],\r\n :teleport_destination => contents[\"HealingSpot\"],\r\n :weather => contents[\"Weather\"],\r\n :town_map_position => contents[\"MapPosition\"],\r\n :dive_map_id => contents[\"DiveMap\"],\r\n :dark_map => contents[\"DarkMap\"],\r\n :safari_map => contents[\"SafariMap\"],\r\n :snap_edges => contents[\"SnapEdges\"],\r\n :random_dungeon => contents[\"Dungeon\"],\r\n :battle_background => contents[\"BattleBack\"],\r\n :wild_battle_BGM => contents[\"WildBattleBGM\"],\r\n :trainer_battle_BGM => contents[\"TrainerBattleBGM\"],\r\n :wild_victory_ME => contents[\"WildVictoryME\"],\r\n :trainer_victory_ME => contents[\"TrainerVictoryME\"],\r\n :wild_capture_ME => contents[\"WildCaptureME\"],\r\n :town_map_size => contents[\"MapSize\"],\r\n :battle_environment => contents[\"Environment\"]\r\n }\r\n # Add metadata's data to records\r\n GameData::MapMetadata.register(metadata_hash)\r\n end\r\n }\r\n }\r\n # Save all data\r\n GameData::Metadata.save\r\n GameData::MapMetadata.save\r\n Graphics.update\r\n end",
"def parse\n @file_data.each {|line|\n h = {}\n data_elements = line.split('|').collect(&:strip)\n #LastName | FirstName | MiddleInitial | Gender | FavoriteColor | DateOfBirth\n @data_collection << {:last_name => data_elements[0], :first_name => data_elements[1], :middle_initial => data_elements[2], :gender => (data_elements[3] == 'M') ? 'Male' : 'Female', :favorite_color => data_elements[4], :dob => data_elements[5].gsub('-', '/'), :dob_year => data_elements[5][-4,4]}\n }\n end",
"def read(str)\n return unless str\n force_binary(str)\n self[:timestamp].read str[0,8]\n self[:incl_len].read str[8,4]\n self[:orig_len].read str[12,4]\n self[:data].read str[16,self[:incl_len].to_i]\n self\n end",
"def processraw str, keys\n str.readlines.collect do |l|\n spltline = l.chomp.split \"|\"\n returning Hash.new do |h|\n keys.each_index do |i|\n h[keys[i]] = spltline[i] unless keys[i] == :ignore\n end\n end\n end\n end",
"def initialize (file)\n \n if file.is_a? String\n file = File.read(file)\n end\n \n super file\n \n @noCertificado = '';\n # Normalmente son strings de tipo:\n # 3230303031303030303030323030303030323933\n # por eso sólo tomamos cada segundo dígito\n self.serial.to_s(16).scan(/.{2}/).each {|v| @noCertificado += v[1]; }\n @data = self.to_s.gsub(/^-.+/, '').gsub(/\\n/, '')\n \n end",
"def readRaw\n puts \"Reading raw data..\"\n # data = {uid => {iid => [hour1, hour2, ...]}}}\n data = {}\n while line = $stdin.gets do\n uid, iid, hour = line.chomp.split(',').map {|e| e.to_i}\n data[uid] = {} unless data.key?(uid)\n data[uid][iid] = [] unless data[uid].key?(iid)\n data[uid][iid] += [hour]\n end\n data.each_pair do |u, ihs|\n ihs.each_key {|i| ihs[i].uniq.sort}\n end\n return data\nend",
"def parse_hash\n \thash = {}\n \t# Remove the first five lines of the file\n \ttemp_array = @readin[5, @readin.length]\n \t# Split the input at the semicolon: the left hand side is a timestamp and the right hand side\n \t# is the value (either power in W, or energy in Wh depending on the file type).\n \t# This is committed to a hash with time as the key and the W/Wh as the value.\n \ttemp_array.each do |s|\n \t\tk,v = s.split(/;/)\n \t\t# the Aurora reports time as seconds since 1/1/0000 and Ruby reports time utilizing an epoch\n \t\t# that began on 1/1/1970. The time stamp is adjusted for the time in seconds between these\n \t\t# two dates.\n \t\thash[Time.at(k.to_i - 62167104000)] = v.to_f\n \tend\n \treturn hash\n end",
"def read filename\n # Open file, Read in and process data.\n file = File.open(filename)\n file.each do |line|\n # Comma seperated data.\n # E.g. 1,2,1 => x=1, y=2, output=1\n line = line.chomp\n if line.size > 0\n # If the line is not empty, then it has data\n line = line.split \",\"\n @x << line[0].to_i\n @y << line[1].to_i\n @output << line[2].to_i\n end\n end\n end",
"def format_data data\r\n\tresult = []\r\n\t#split entry to array\r\n\tarr = data.read.split '>'\r\n\tarr.each do |item|\r\n\t\tname = item.split('|')[0]\r\n\t\tnext if !name\r\n\r\n\t\tprotein = []\r\n\t\t#format name\r\n\t\tname.delete! ' '\r\n\t\tname.tr! '|', ''\r\n\r\n\t\t#format sequence\r\n\t\ttmp = item.split \"\\n\"\r\n\t\ttmp.shift\r\n\t\tsequence = tmp.join\r\n\r\n\t\tprotein.push name, sequence\r\n\r\n\t\tresult.push protein\r\n\tend\t\r\n\tresult\r\n\r\nend",
"def get_file_events(filename)\n lines = []\n File.open(filename, 'rb') {|f| lines = f.read.split(/\\n+/)}\n pid = \"unkown PID\"\n if filename =~ /trace_gpu_(\\d+)/\n pid = $1\n end\n to_return = []\n lines.each do |line|\n next if line !~ /\\d+,\\d+/\n # Remove arguments to functions in (), since they'll contain commas.\n line.gsub!(/\\([^\\)]+\\)/, \"()\")\n line.gsub!(/\\[[^\\]]+\\]/, \"[]\")\n columns = line.split(\",\")\n start_time = columns[0].to_f\n duration = columns[1].to_f\n event = columns[-1].gsub(/\"/, \"\")\n stream = \"PID #{pid}, stream #{columns[-2].to_s}\"\n to_return << [start_time, duration, event, stream]\n end\n to_return\nend",
"def decode(line)\n split = line.split(/[<>,]/)\n return {pos: [split[1].to_i, split[2].to_i], vel: [split[4].to_i, split[5].to_i]}\nend",
"def record_attendance_barcode( db )\n puts \"Recording attendance from barcode file\"\n \n filename = UI.enter( \"Enter the name of your file\" )\n attfile = File.new(filename,'r')\n \n sess = db.table( 'lab_sessions' )\n\n while line = attfile.gets\n \tstuff = line.split(',')\n \t#The barcode scanner uses an American date format, mm/dd/yy. This is stupid. We shall turn it into a REAL format.\n \tdateComps = stuff[3].split('/')\n \tdateComps[2] = dateComps[2].to_i+2000\n \tdate = dateComps[1]+'/'+dateComps[0]+'/'+dateComps[2].to_s\n \t#It also uses a 12 hour format for time, which needs to go away\n \ttime = DateTime.strptime(stuff[2], '%I:%M:%S %p')\n \ttime = time.strftime('%H:%M:%S')\n \ttheD = DateTime.parse(time+' '+date)\n \t#time to insert attendance into sessions!\n \tfor s in sess.all\n \t\tif (theD>DateTime.parse(s.to_hash['start_date']) && theD<DateTime.parse(s.to_hash['end_date']))\n \t\t\tunless s.to_hash['attended'].split(',').include? stuff[0]\n \t\t\t\tputs 'importing attendance'\n \t\t\t\ts.set 'attended' => s.to_hash['attended']+','+stuff[0]\n \t\t\tend\n \t\tend\n \tend\n end\nend",
"def chrom\n @data[:chrom]\n end",
"def _parse_unit_output(line)\n line_match = /^\\[([AB])\\:([A-Z]+)\\#(\\d+)\\@(\\d+)\\](.*)$/.match line\n return nil unless line_match\n {\n :team => line_match[1],\n :unit_type => line_match[2],\n :unit_id => line_match[3].to_i,\n :round => line_match[4].to_i,\n :output => line_match[5]\n }\n end",
"def parse_line( line )\n\tline.chomp!\n\tvalues = []\n\t#BEGIN_STUDENT\n\twords = line.split(',')\n words.each do |word|\n\t\tvalues += [word]\n end\n\treturn values\n\t#END_STUDENT\nend",
"def kp_get_modid(data)\n return data.map{|d| d.scan(/(?<m>M\\d{5})/)}.flatten.sort\nend",
"def parse_actl(len, file)\n return -1 if len != 8\n framedata = file.read(4)\n if framedata.nil? || framedata.length != 4\n return -1\n end\n\n framedata.unpack1(\"N\".freeze)\n end",
"def parse_input (input_string)\n lines = input_string.split(/\\n/)\n\n state = :reading_map\n\n rover_x_start = 0\n rover_y_start = 0\n rover_facing_start = 0\n\n lines.each do |line|\n # drop empty lines\n next unless /(\\w)+/ =~ line\n\n case state\n when :reading_map\n match = /^\\s*(\\d+)\\s+(\\d+)\\s*$/.match(line)\n raise ArgumentError.new(\"Invalid map data >>#{line}<<\") unless match\n\n x_size = $1.to_i\n y_size = $2.to_i\n\n # the format is not the size, it's the greatest valid index\n init_map(x_size,y_size)\n\n state = :reading_rover_init\n\n when :reading_rover_init\n match = /^\\s*(\\d+)\\s+(\\d+)\\s+([NSWE])\\s*$/.match(line)\n # match = line.match /^\\s*(\\d+)\\s+(\\d+)\\s+([NSWE])\\s*$/\n raise ArgumentError.new(\"Invalid rover init >>#{line}<<\") unless match\n\n rover_x_start = $1.to_i\n rover_y_start = $2.to_i\n rover_facing_start = $3\n\n state = :reading_rover_instructions\n when :reading_rover_instructions\n match = /^\\s*([LRM]+)\\s*$/.match(line)\n raise ArgumentError.new(\"Invalid rover init >>#{line}<<\") unless match\n\n rover_instructions = $1\n\n add_rover(rover_x_start,rover_y_start,rover_facing_start,rover_instructions)\n\n state = :reading_rover_init\n end\n end\n\n end",
"def recordize line\n line.split(\"\\t\") rescue nil\n end",
"def identifier(file)\n\t\tlineNum = 0\n\t\tcommline = 0 \n\t\tcommcol = 0 \n\t\terrComm = false #pen\n\n\t\tfile.each_line do |line|\n\t\t\t# En cada iteracion (salto de linea), el numero de linea aumenta.\n\t\t\t# y el numero de columna vuelve a 1.\n\t\t\tlineNum += 1\n\t\t\tcolNum = 1\n\t\t\t# Cuando lo que queda de la linea es un salto de pagina, pasamos a la\n\t\t\t# proxima linea (arriba)\n\t\t\twhile line != \"\"\n\n\t\t\t\t#Revisa que no esta leyendo dentro de un comentario.\n\t\t\t\tif errComm == true then\t\n\t\t\t\t\tcase line\n\t\t\t\t\t#Si encuentra el fin del comentario no da error. \t\n\t\t\t\t\twhen /(.*?)\\-}/\t\t\n\t\t\t\t\t\terrComm = false\n\t\t\t\t\t\tword = line[/(.*?)\\-}/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\tcolNum += word.size\n\n\t\t\t\t\telse \t\n\t\t\t\t\t\t#Sigue buscando en lineas el fin del comentario\n\t\t\t\t\t\tif line =~ /^[\\s]+/\n\t\t\t\t\t\t\tword = line[/^[\\s]+/] \n\t\t\t\t\t\telse\t\n\t\t\t\t\t\t\tword = line[/(.*)/] \n\t\t\t\t\t\tend\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\tcolNum += word.size\n\t\t\t\t\t\tnext \n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\t# Este case sirve para matchear regexs con los 'when' en lo que quede de linea.\n\t\t\t\t\tcase line\n\n\t\t\t\t\t#Si encuentra {- ignora todo hasta encontrar -}, si no lo encuentra da error. \n\t\t\t\t\twhen /^{\\-/\t\t\n\t\t\t\t\t\terrComm = true\n\t\t\t\t\t\tword = line[/^{\\-/]\n\t\t\t\t\t\tcommcol = colNum\n\t\t\t\t\t\tline = line.partition(word).last\t\n\t\t\t\t\t\tcolNum += word.size\t\t\n\t\t\t\t\t\tcommline = lineNum\n\n\t\t\t\t\t# Este es para las tabulaciones, las cuenta como 4 espacios. \n\t\t\t\t\twhen /^\\t+/\n\t\t\t\t\t\tword = line[/^\\t+/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\tcolNum += 4\n\t\t\t\t\n\t\t\t\t\t# Este es para los espacios en blanco o saltos de linea.\n\t\t\t\t\twhen /^\\s+/\n\t\t\t\t\t\tword = line[/^\\s+/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\tcolNum += word.size\n\n\t\t\t\t\t# AGREGANDO TOKENS LIST.\n\t\t\t\t\t# Va a matchear con read. \n\t\t\t\t\twhen /^read/\n\t\t\t\t\t\tword = line[/^read/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:READ, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\n\n\t\t\t\t\t# Va a matchear con write. \n\t\t\t\t\twhen /^write/\n\t\t\t\t\t\tword = line[/^write/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:WRITE, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\n\n\t\t\t\t\t# Va a matchear con true, tipo boolean llamado TRUE. \n\t\t\t\t\twhen /^true/\n\t\t\t\t\t\tword = line[/^true/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:TRUE, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\n\n\t\t\t\t\t# Va a matchear con false, tipo boolean llamado FALSE. \n\t\t\t\t\twhen /^false/\n\t\t\t\t\t\tword = line[/^false/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:FALSE, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\t\n\n\t\t\t\t\t# Va a matchear todas las palabras, son de tipo IDENTIFIER. \n\t\t\t\t\t# \\w = [a-zA-Z0-9_]\n\t\t\t\t\twhen /^[a-zA-Z]\\w*/\n\t\t\t\t\t\tword = line[/^[a-zA-Z]\\w*/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:IDENTIFIER, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\n\n\t\t\t\t\t# Va a matchear todos los numeros, son de tipo NUMBER.\n\t\t\t\t\t# \\d = [0-9]. En caso de exceder el limite es un token no valido. \n\t\t\t\t\twhen /^\\d+/\n\t\t\t\t\t\tword = line[/\\d+/]\n\t\t\t\t\t\tif word.to_i > 2147483647\n\t\t\t\t\t\t\t@errList << Token.new(\"\", word, [lineNum, colNum])\n\t\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t\t@tokensList << Token.new(:NUMBER, word, [lineNum, colNum])\n\t\t\t\t\t\tend\n\t\t\t\t\t\tcolNum += word.size\n\n\t\t\t\t\t# Va a matchear los @, son de tipo AT. \n\t\t\t\t\twhen /^[@]/\n\t\t\t\t\t\tword = line[/^[@]/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:AT, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\n\n\t\t\t\t\t# Va a matchear todos !, son de tipo EXCLAMATION MARK. \n\t\t\t\t\twhen /^[!]/\n\t\t\t\t\t\tword = line[/^[!]/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:EXCLAMATION_MARK, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\n\n\t\t\t\t\t# Va a matchear todos los .., son de tipo TWO POINTS.\n\t\t\t\t\twhen /^\\.\\./\n\t\t\t\t\t\tword = line[/^\\.\\./]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:TWO_POINTS, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\t\n\t\t\t\t\t\t\n\t\t\t\t\t# Va a matchear todos }, es de tipo LCURLY. \n\t\t\t\t\twhen /^[{]/\n\t\t\t\t\t\tword = line[/^[{]/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:LCURLY, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\t\t\t\t\t\n\n\t\t\t\t\t# Va a matchear todos }, es de tipo RCURLY. \n\t\t\t\t\twhen /^[}]/\n\t\t\t\t\t\tword = line[/^[}]/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:RCURLY, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\t\t\t\t\t\t\n\n\t\t\t\t\t# Va a matchear todos ), es de tipo RPARENTHESIS. \n\t\t\t\t\twhen /^[)]/\n\t\t\t\t\t\tword = line[/^[)]/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:RPARENTHESIS, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\t\n\n\t\t\t\t\t# Va a matchear todos (, es de tipo LPARENTHESIS. \n\t\t\t\t\twhen /^[(]/\n\t\t\t\t\t\tword = line[/^[(]/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:LPARENTHESIS, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\t\n\n\t\t\t\t\t# Va a matchear todos ], es de tipo RBRACKET\n\t\t\t\t\twhen /^(\\])/\n\t\t\t\t\t\tword = line[/(\\])/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:RBRACKET, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\t\n\n\t\t\t\t\t# Va a matchear todos [, es de tipo LBRACKET. \n\t\t\t\t\twhen /^\\[/\n\t\t\t\t\t\tword = line[/^\\[/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:LBRACKET, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\t\t\n\n\t\t\t\t\t# Va a matchear todos |, es de tipo PIPE. \n\t\t\t\t\twhen /^[|]/\n\t\t\t\t\t\tword = line[/^[|]/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:PIPE, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\n\n\t\t\t\t\t# Va a matchear todos ;, es de tipo SEMICOLON. \n\t\t\t\t\twhen /^[;]/\n\t\t\t\t\t\tword = line[/^[;]/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:SEMICOLON, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\t\n\n\t\t\t\t\t# Va a matchear todos ?, es de tipo QUESTIONMARK. \n\t\t\t\t\twhen /^[\\?]/\n\t\t\t\t\t\tword = line[/^[\\?]/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:QUESTION_MARK, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\n\n\t\t\t\t\t# Va a matchear todos -, es de tipo MINUS. \n\t\t\t\t\twhen /^[-]/\n\t\t\t\t\t\tword = line[/^[-]/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:MINUS, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\n\n\t\t\t\t\t# Va a matchear todos $, es de tipo ROTATION. \n\t\t\t\t\twhen /^\\$/\n\t\t\t\t\t\tword = line[/^\\$/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:ROTATION, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\t\n\n\t\t\t\t\t# Va a matchear todos ', es de tipo TRANSPOSITION. \n\t\t\t\t\twhen /^'/\n\t\t\t\t\t\tword = line[/^'/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:TRANSPOSITION, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\n\n\t\t\t\t\t# Va a matchear todos ^, es de tipo boolean, llamado NEGATION. \n\t\t\t\t\twhen /^\\^/\n\t\t\t\t\t\tword = line[/^\\^/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:NEGATION, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\t\n\n\t\t\t\t\t# Va a matchear todos \\/, es de tipo boolean, llamado OR. \n\t\t\t\t\twhen /^\\\\\\//\n\t\t\t\t\t\tword = line[/^\\\\\\//]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:OR, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\t\t\n\n\t\t\t\t\t# Va a matchear todos /\\, es de tipo boolean, llamado AND. \n\t\t\t\t\twhen /^\\/\\\\/\n\t\t\t\t\t\tword = line[/^\\/\\\\/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:AND, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\t\t\n\t\n\n\t\t\t\t\t# Va a matchear todos los lienzos menos el vacio, es de tipo CANVAS. \n\t\t\t\t\twhen /^<->/ , /^<\\|>/ , /^<\\_>/ , /^<\\s>/ , /^<\\/>/ , /^<\\\\>/\n\t\t\t\t\t\tword = line[/^<.>/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:CANVAS, word[1], [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\t\n\n\t\t\t\t\t# Va a matchear con #(lienzo vacio), es de tipo CANVAS. \n\t\t\t\t\twhen /^#/ \n\t\t\t\t\t\tword = line[/^#/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:CANVAS, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\t\n\n\t\t\t\t\t# Va a matchear los &, es de tipo ET\n\t\t\t\t\twhen /^&/\n\t\t\t\t\t\tword = line[/^&/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:ET, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\n\n\t\t\t\t\t# Va a matchear los ~, es de tipo TILDE\n\t\t\t\t\twhen /^~/\n\t\t\t\t\t\tword = line[/^~/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:TILDE, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\t\n\n\t\t\t\t\t# Va a matchear LOS <=, es de tipo GREATER OR EQUAL. \n\t\t\t\t\twhen /^>=/\n\t\t\t\t\t\tword = line[/^>=/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:GREATER_OR_EQUAL, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\t\n\n\t\t\t\t\t# Va a matchear LOS <=, es de tipo LESS OR EQUAL. \n\t\t\t\t\twhen /^<=/\n\t\t\t\t\t\tword = line[/^<=/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:LESS_OR_EQUAL, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\t\n\t\t\t\t\t\n\t\t\t\t\t# Va a matchear LOS >, es de tipo GREATER THAN.\n\t\t\t\t\twhen /^>/\n\t\t\t\t\t\tword = line[/^>/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:GREATER_THAN, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\t\t\t\n\n\t\t\t\t\t# Va a matchear LOS <, es de tipo LESS THAN. \n\t\t\t\t\twhen /^</\n\t\t\t\t\t\tword = line[/^</]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:LESS_THAN, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\t\t\n\n\t\t\t\t\t# Va a matchear todos =, es de tipo NOT EQUAL. \n\t\t\t\t\twhen /^\\/=/\n\t\t\t\t\t\tword = line[/^\\/=/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:NOT_EQUAL, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\t\n\n\t\t\t\t\t# Va a matchear todos =, es de tipo EQUALS. \n\t\t\t\t\twhen /^=/\n\t\t\t\t\t\tword = line[/^=/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:EQUALS, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\t\n\n\t\t\t\t\t# Va a matchear todos :, es de tipo COLON. \n\t\t\t\t\twhen /^:/\n\t\t\t\t\t\tword = line[/^:/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:COLON, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\t\t\n\n\n\t\t\t\t\t# Va a matchear todos ;, es de tipo PERCENT. \n\t\t\t\t\twhen /^[%]/\n\t\t\t\t\t\tword = line[/^[%]/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:PERCENT, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\t\n\n\t\t\t\t\t# Va a matchear todos +, es de tipo PLUS. \n\t\t\t\t\twhen /^[+]/\n\t\t\t\t\t\tword = line[/^[+]/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:PLUS, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\n\n\t\t\t\t\t# Va a matchear todos +, es de tipo PLUS. \n\t\t\t\t\twhen /^[*]/\n\t\t\t\t\t\tword = line[/^[*]/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:MULTIPLY, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\t\t\t\t\t\t\t\t\t\n\n\t\t\t\t\t# Va a matchear todos /, es de tipo DIVISION. \n\t\t\t\t\twhen /^[\\/]/\n\t\t\t\t\t\tword = line[/^[\\/]/]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@tokensList << Token.new(:DIVISION, word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\n\n\t\t\t\t\t# y esto es para todo lo que no sean palabras validas (letras en este ejemplo).\n\t\t\t\t\telse\n\t\t\t\t\t\tword = line[/^./]\n\t\t\t\t\t\tline = line.partition(word).last\n\t\t\t\t\t\t@errList << Token.new(\"\", word, [lineNum, colNum])\n\t\t\t\t\t\tcolNum += word.size\n\t\t\t\t\tend\n\t\t\t\tend\t\n\t\t\tend\n\t\tend\n\t\t# Si hubo un comentario sin cerrarse, la funcion devuelve false\n\t\tif errComm == true \n\t\t\tputs \"ERROR: Comment section opened but not closed at line: \" \\\n\t\t\t\t\t\t\"#{commline}, column: #{commcol} \\n\"\n\t\t\treturn false\n\t\telse \n\t\t# Si hubo algun caracter invalido, se devuelve .\n\t\t\tif (@errList.length > 0)\n\t\t\t\[email protected](@tokensList.length)\n\t\t\t\tfor err in @errList\n\t\t\t\t\tputs \"ERROR: Unexpected character: '#{err.symbol}' at line: \" \\\n\t\t\t\t\t\t\t\t\"#{err.position[0]}, column: #{err.position[1]} \\n\"\n\t\t\t\tend\n\t\t\t\treturn false\n\t\t\t# Si todos los caracteres son validos, se retorna true.\n\t\t\telse\n\t\t\t\treturn true\n\t\t\tend\n\t\tend\t\n\tend",
"def signatures_at(filename, line, column); end",
"def decode_file file\n base = File.basename(file)\n # add the timestamp\n $results[file] = { values: {}, timestamp: Util.cdr2stamp(base) }\n\tcmd = $dec_cmd + \" \" + file + \" | tail -n 40\"\n\tres = `#{cmd} `\n if !$?.success?\n $stderr.puts \"Decoder failed.\"; \n abort; \n end;\n\tres.split(\"\\n\").each do |line|\n\t\tnext unless line.match $re\n\t\t$results[file][:values][$1] = $2\n\tend\nend",
"def candidates2fa(input_file, fasta, read_length, output_file, exoncov=8)\n\t\tchromosomes = {}\n\t\tpositions = []\n\t\t\n\t\t# Input into hash sorted by chromosomes\n\t\tFile.open(input_file, 'r').readlines.each do |line|\n\t\t\tline = line.strip.split(\"\\t\")[0..-2]\n\t\t\tchr_a, pos_a, strand_a, chr_b, pos_b, strand_b = line[0..5]\n\t\t\tpos = [chr_a, pos_a, chr_b, pos_b].join(':')\n\t\n\t\t\tchromosomes[chr_a] = {} if !chromosomes.has_key?(chr_a)\n\t\t\t\n\t\t\tif !chromosomes.has_key?(chr_b)\n\t\t\t\tchromosomes[chr_a][chr_b] = [line]\n\t\t\n\t\t\t# 2nd elsif to exclude reads that map on same junction but opposite ends\t\t\n\t\t\telsif chromosomes[chr_a].has_key?(chr_b) && !positions.include?(pos)\n\t\t\t\tchromosomes[chr_a][chr_b].push(line)\n\t\t\t\tpositions << pos\n\t\t\tend\n\t\tend\n\n\t\t# Output\n\t\toutput = File.open(output_file, 'w') do |output|\n\t\t\tchromosomes.each do |chr_a, values|\n\t\t\t\tfasta_file = File.open(\"#{fasta}#{chr_a}.fa\", 'r')\n\t\t\t\theader = fasta_file.gets.strip\n\t\t\t\tdna_a = fasta_file.read.gsub(/\\n/, '')\n\t\t\t\t\n\t\t\t\tvalues.each do |chr_b, values|\n\t\t\t\t fasta_file = File.open(\"#{fasta}#{chr_b}.fa\", 'r')\n\t\t\t\t\theader = fasta_file.gets.strip\n\t\t\t\t\tdna_b = fasta_file.read.gsub(/\\n/, '')\n\n\t\t\t\t\tvalues.each do |v|\n\t\t\t\t\t\tbp_a, bp_b = v[1].to_i, v[4].to_i\n\t\t\t\t\t\tstrand_a, strand_b = v[2], v[5]\n\t\t\t\t\t\toverlap = v[-1].to_i - read_length\n\t\t\t\t\t\tl = read_length - exoncov \n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\tupstream = dna_a[bp_a..bp_a + overlap + l].upcase\t\n\t\t\t\t\t\tdownstream = dna_b[bp_b - l - overlap + 1..bp_b - overlap].upcase\n\t\t\t\t\t\n\t\t\t\t\t\tif strand_a == '1' && strand_b == '-1'\n\t\t\t\t\t\t\tdownstream = Alignment.reverse_complement(dna_b[bp_b..bp_b + l].upcase)\n\t\t\t\t\t\telsif strand_a == '-1' && strand_b == '1'\n\t\t\t\t\t\t\tupstream = Alignment.reverse_complement(dna_a[bp_a - l + 1..bp_a].upcase)\n\t\t\t\t\t\tend\n\t\t\n\t\t\t\t\t\tid = [v[0..1], v[3..4]].join(':')\n\t\t\t\t\t\toutput.puts [\">#{id}\", downstream + upstream].join(\"\\n\")\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t$logfile.puts \"#{Time.new.strftime(\"%c\")}: Wrote loci to fasta-file.\"\n\tend",
"def find_start(line, len)\n (stream,answer) = line.split(':')\n return if stream.nil?\n stream.chars.each_with_index do |c, i|\n # take slice of array starting at i\n # check if uniq.\n sub = stream[i..i+len-1]\n \n if sub.chars.uniq.length == len\n puts \"sub=#{sub}\" \n puts \"found at index=#{i} chars recv=#{i+len} answer=#{answer}\"\n return\n end\n end \nend",
"def parse(line)\n\t\titems = line.split(' ')\n\t\trecord = {}\n\t\t# debugger\n\t\trecord[:event] = items[0]\n\t\trecord[:time] = items[1]\n\t\trecord[:fnode] = items[2]\n\t\trecord[:tnode] = items[3]\n\t\trecord[:pktype] = items[4]\n\t\trecord[:pktsize] = items[5]\n\t\trecord[:fid] = items[7]\n\t\trecord[:srcadd] = items[8]\n\t\trecord[:desadd] = items[9]\n\t\trecord[:seqnum] = items[10]\n\t\trecord[:pktid] = items[11]\n\t\trecord\n\tend",
"def recordize line\n line.split(\"\\t\")\n end",
"def import_google_transit_stops_file( stops_file )\n return nil if not stops_file or stops_file.header.empty?\n print \"Importing stops.txt file\\n\"\n\n stop_lat_index = stops_file.format.index(\"stop_lat\")\n stop_lon_index = stops_file.format.index(\"stop_lon\")\n stop_id_index = stops_file.header.index(\"stop_id\")\n\n header_len = stops_file.format.length\n\n #process each line of the file\n stops_file.each_line do |row|\n shape_wkt = \"SRID=#{WGS84_LATLONG_EPSG};POINT(#{row[stop_lon_index]} #{row[stop_lat_index]})\"\n #Check if stop_id has already a namespace, if not, add the agency_id as namespace\n row[stop_id_index] = add_namespace( row[stop_id_index], @namespace )\n row += [\"\"] * (header_len - row.length) if row.length != header_len #added this to parse trimet\n row.collect! do |item| if item.empty? then \"\\\\N\" else item end end\n #Add a rescue statement to the copy process\n begin\n conn.exec \"COPY gtf_stops ( #{stops_file.format.join(\",\")}, location ) FROM STDIN\"\n conn.putline \"#{row.join(\"\\t\")}\\t#{shape_wkt}\\n\"\n conn.endcopy\n rescue\n #In case that a stop with the same u_id (namespace + stop_id) already existed\n #we consider that it is the same stop (a stop shared between different agencies)\n puts \"The stop #{row[stop_id_index]} already exists, ignoring stop\"\n end\n end\n\n end",
"def initialize(filename)\n file = File.open(filename, \"r\")\n self.data = file.read\n file.close\n\n # inicializacia atributov\n self.skip_spaces = true\n self.errors = []\n self.line = [0]\n self.length = data.length\n self.position = self.last_position = 0\n\n # zoznam terminalov a operatorov\n self.terminals = [\n 'BEGIN',\n 'END',\n ':=',\n ';',\n '(',\n ')',\n 'WRITE',\n 'READ',\n 'IF',\n 'THEN',\n 'ELSE',\n 'IDENT',\n '+',\n '-',\n 'NOT',\n 'AND',\n 'OR',\n 'TRUE',\n 'FALSE',\n ','\n ]\n\n end",
"def initialize(s)\n s.gsub(/Line (\\d*) of \"(.*)\" starts at address (0x[0-9a-f]*) <(.*)> and ends at (0x[0-9a-f]*)/).to_a\n @line = $1\n @filename = $2\n @startaddress = $3.hex if $3\n @symbol = $4\n @endaddress = $5.hex if $3\n end",
"def read_m\n Integer(@file.gets)\n end",
"def bam_seqi(s, i)\n (s[i >> 1].read_uint8 >> ((~i & 1) << 2)) & 0xf\n end",
"def structured_parts(line_86)\n line_86.split(/(>\\d{2})/)\n end"
] | [
"0.5320008",
"0.5305712",
"0.5243399",
"0.51444024",
"0.51398295",
"0.5089928",
"0.5044294",
"0.5038991",
"0.5015203",
"0.49416864",
"0.49401143",
"0.49243936",
"0.4893",
"0.48817113",
"0.48132303",
"0.47845253",
"0.476123",
"0.4760243",
"0.47430584",
"0.47430584",
"0.4734734",
"0.47085094",
"0.46981412",
"0.46392897",
"0.4638614",
"0.463304",
"0.46181583",
"0.4612527",
"0.4606559",
"0.45994085",
"0.45883957",
"0.4588122",
"0.45799837",
"0.4577499",
"0.4575137",
"0.45708504",
"0.45609662",
"0.45554942",
"0.45538428",
"0.45530194",
"0.45480072",
"0.453317",
"0.45323557",
"0.45313567",
"0.45313567",
"0.45264888",
"0.45244235",
"0.4518554",
"0.4511343",
"0.45075524",
"0.4506105",
"0.45009458",
"0.44861263",
"0.44822976",
"0.44807342",
"0.44806883",
"0.4472519",
"0.44607267",
"0.44436345",
"0.44433108",
"0.4441988",
"0.44401702",
"0.4428875",
"0.44275558",
"0.4425469",
"0.44247168",
"0.4413254",
"0.44124612",
"0.44057485",
"0.44039872",
"0.44020808",
"0.4401916",
"0.43951717",
"0.43845943",
"0.43840575",
"0.4379745",
"0.4372534",
"0.43698767",
"0.4368167",
"0.43621415",
"0.4361761",
"0.4356894",
"0.43560624",
"0.43547666",
"0.4350582",
"0.43462145",
"0.4342653",
"0.43424043",
"0.4340495",
"0.43346822",
"0.43336034",
"0.43210936",
"0.4313069",
"0.43061757",
"0.42997816",
"0.4297847",
"0.42955738",
"0.42935845",
"0.42925674",
"0.42920426"
] | 0.4965524 | 9 |
a config object with the default configuration | def config_default
lock(:c) do
@cache[:c][:default] ||= config_new
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def default_config\n {}\n end",
"def default_config\n self.class.config[:default_config].nil? ? {} : {}.merge(self.class.config[:default_config])\n end",
"def default_config\n self.class.default_config\n end",
"def default_config\n <<~CONFIG\n defaults: &defaults\n data_root: data\n candidates_root: zzz_candidates\n departed_root: zzz_departed\n project_root: projects\n editor: code\n feedback_polarity_default: positive\n meeting_location_default: alcove\n log_filename: log.adoc\n overview_filename: overview.adoc\n pto_default: vacation\n voip_meeting_default: Zoom\n\n development:\n # <<: *defaults\n data_root: data\n candidates_root: zzz_candidates\n departed_root: zzz_departed\n project_root: projects\n editor: code\n feedback_polarity_default: positive\n meeting_location_default: alcove\n log_filename: log.adoc\n overview_filename: overview.adoc\n pto_default: vacation\n voip_meeting_default: Zoom\n\n test:\n # <<: *defaults\n data_root: data\n candidates_root: zzz_candidates\n departed_root: zzz_departed\n project_root: projects\n editor: code\n feedback_polarity_default: positive\n meeting_location_default: alcove\n log_filename: log.adoc\n overview_filename: overview.adoc\n pto_default: vacation\n voip_meeting_default: Zoom\n\n production:\n # <<: *defaults\n data_root: data\n candidates_root: zzz_candidates\n departed_root: zzz_departed\n project_root: projects\n editor: code\n feedback_polarity_default: positive\n meeting_location_default: alcove\n log_filename: log.adoc\n overview_filename: overview.adoc\n pto_default: vacation\n voip_meeting_default: Zoom\n CONFIG\n end",
"def default_configuration\n {}\n end",
"def initialize\n @config = DEFAULT_CONFIG.deep_dup\n end",
"def default_configuration\n configuration[:_default] || {}\n end",
"def configDefaults(config)\n end",
"def config\n @config ||= {}\n end",
"def config\n @config ||= {}\n end",
"def default_configuration=(_arg0); end",
"def init_default_config\n configuration.project_id ||= Debugger.default_project_id\n configuration.credentials ||= Debugger.default_credentials\n configuration.service_name ||= Debugger.default_service_name\n configuration.service_version ||= Debugger.default_service_version\n end",
"def config\n (null_config? ? NoConfig.instance : actual_config)\n end",
"def config\n @config ||= Config.new\n end",
"def config\n @config ||= Config.new\n end",
"def config\n @config ||= Config.create ConfigLoader.new(root, CONFIG_FILE).to_hash, options.merge_config\n end",
"def default_config\n config = {}\n config['webhook_url'] = nil\n\n return config\n end",
"def configuration\n {}\n end",
"def initial_config\n default_config.deep_merge(@passed_config)\n end",
"def defaults\n Hash(@config[:defaults])\n end",
"def config\n @config ||= load_config\n end",
"def config\n @default_args || Surrealist::HashUtils::EMPTY_HASH\n end",
"def load_config\n # Nothing in base class. This should be used to load the configuration from\n # disk if saved to a file.\n configuration || {}\n end",
"def init_default_config\n configuration.project_id ||= (Cloud.configure.project_id || ErrorReporting::Project.default_project_id)\n configuration.credentials ||= Cloud.configure.credentials\n configuration.service_name ||= ErrorReporting::Project.default_service_name\n configuration.service_version ||= ErrorReporting::Project.default_service_version\n configuration.ignore_classes = Array(configuration.ignore_classes)\n end",
"def create_config\n self.config = {} if !self.config\n end",
"def create_config\n self.config = {} if !self.config\n end",
"def config(opts=nil)\n if opts\n @config = @config.merge(get_subhash(opts, DEFAULTS.keys))\n else\n @config\n end\n end",
"def config\n @config ||= Configuration.new\n end",
"def config\n @config ||= multi_config || single_config\n end",
"def config\n @config || QuestBack.default_configuration || fail(QuestBack::Error, 'No configuration given or found on QuestBack.default_configuration.')\n end",
"def config\n @config ||= OpenStruct.new(YAML.load_file(self.config_path))\n end",
"def config\n @configuration ||= Configuration.new\n end",
"def config\n @configuration ||= Configuration.new\n end",
"def set_defaults!\n __load_config( DEFAULTS )\n end",
"def defaults\n return @config if @config\n\n @config = Configatron::Store.new\n file_path = File.expand_path('../../../config/xpaths.yml', __FILE__)\n hash_config = YAML::load_file(file_path)\n\n @config.configure_from_hash(hash_config)\n @config.lock!\n @config\n end",
"def load_config!\n if options[:config]\n config_inst = Config.new(options[:config])\n elsif self.class.const_defined?(:DEFAULT_CONFIGURATION_FILES)\n path = self.class.const_get(:DEFAULT_CONFIGURATION_FILES).detect do |check|\n full_check = File.expand_path(check)\n File.exists?(full_check)\n end\n config_inst = Config.new(path) if path\n end\n if config_inst\n options.delete(:config)\n defaults_inst = Smash[\n config_class.new(\n defaults.to_smash\n ).to_smash.find_all do |key, value|\n defaults.key?(key)\n end\n ]\n config_data = config_inst.data\n config_inst = Smash[\n config_inst.to_smash.find_all do |key, value|\n config_data.key?(key)\n end\n ]\n options_inst = Smash[\n config_class.new(\n options.to_smash\n ).to_smash.find_all do |key, value|\n options.key?(key)\n end\n ]\n @options = config_class.new(\n defaults_inst.to_smash.deep_merge(\n config_inst.to_smash.deep_merge(\n options_inst.to_smash\n )\n )\n ).to_smash\n else\n @options = config_class.new(\n defaults.to_smash.deep_merge(\n options.to_smash\n )\n ).to_smash\n end\n options\n end",
"def initialize(config, default=Config::BasicAuth)\n check_init(config)\n @config = default.dup.update(config)\n end",
"def config\n @config ||= { :force => false, :quiet => false }\n end",
"def config\n @config ||= read_config\n end",
"def config\n @_config ||= self.class.config.inheritable_copy\n end",
"def default_configuration!\n # Overwriting Sinatra defaults\n set :app_file, caller_files.first || $0 # Assume app file is first caller\n set :environment, Padrino.env\n set :raise_errors, true if development?\n set :logging, false # !test?\n set :sessions, true\n set :public, Proc.new { Padrino.root('public', self.uri_root) }\n # Padrino specific\n set :uri_root, \"/\"\n set :reload, development?\n set :app_name, self.to_s.underscore.to_sym\n set :default_builder, 'StandardFormBuilder'\n set :flash, defined?(Rack::Flash)\n set :authentication, false\n # Padrino locale\n set :locale_path, Proc.new { Dir[File.join(self.root, \"/locale/**/*.{rb,yml}\")] }\n set :auto_locale, false\n # Plugin specific\n set :padrino_mailer, defined?(Padrino::Mailer)\n set :padrino_helpers, defined?(Padrino::Helpers)\n end",
"def initialize\n @config = config_from_file || empty_config\n end",
"def config\n unless @config\n @config = Configuration.new\n @config.reset\n end\n @config\n end",
"def configuration_defaults(&block)\n @configuration_defaults = block\n end",
"def config=(config); end",
"def load_default_config\n self[:disable_html] ||= true\n self[:url_target] ||= \"_BLANK\"\n self[:image_alt] ||= \"Posted Image\"\n self[:table_width] ||= \"100%\"\n self[:syntax_highlighter] ||= :raw\n self[:coderay_options] ||= {}\n end",
"def default_settings\n {}\n end",
"def parse_default_config\n default_config_path = 'config/default.yml'\n @default_config = ( YAML.load_file(default_config_path) if File.exist?(default_config_path) ) || {}\n end",
"def load_default_config\n # Load the default\n path = File.join(::Lyricli.root, \"config\", @defaults_path)\n\n if File.exist?(path)\n file = File.new(path, \"r\")\n @config = MultiJson.decode(file.read)\n else\n @config = {}\n end\n end",
"def object_config\n config_for(nil)\n end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def default_config=(config)\n unless config.is_a? Hash\n raise ArgumentError.new('Configuration has to be a Hash')\n end\n\n @default_config = config\n end",
"def config\n @config ||= Smartgen::Configuration.new\n end",
"def object_config\n config_for(nil)\n end",
"def load_config!\n if(options[:config])\n config_inst = config_class.new(options[:config])\n elsif(self.class.const_defined?(:DEFAULT_CONFIGURATION_FILES))\n path = self.class.const_get(:DEFAULT_CONFIGURATION_FILES).detect do |check|\n full_check = File.expand_path(check)\n File.exists?(full_check)\n end\n config_inst = config_class.new(path) if path\n end\n if(config_inst)\n options.delete(:config)\n @options = config_class.new(\n defaults.to_smash.deep_merge(\n config_inst.to_smash.deep_merge(\n options.to_smash\n )\n )\n ).to_smash\n else\n @options = config_class.new(\n defaults.to_smash.deep_merge(\n options.to_smash\n )\n ).to_smash\n end\n options\n end",
"def config\r\n Configuration\r\n end",
"def config\r\n Configuration\r\n end",
"def config\r\n Configuration\r\n end",
"def config\r\n Configuration\r\n end",
"def config\r\n Configuration\r\n end",
"def config\r\n Configuration\r\n end",
"def default_config\n {\n db_type: 'sqlite', # Any database connector supported by the Sequel gem\n db_name: 'data.db', # The name of the database (or file) to use\n db_user: nil, # The database user and optional password (user:password)\n db_host: 'localhost' # The database host and options port (host:port)\n }\n end",
"def default_config # including inherited defaults \n calling_class = klass = self\n my_defaults = @@default_config[klass.to_s.downcase.to_sym] ||\n HashWithIndifferentAccess.new\n inherited_defaults = HashWithIndifferentAccess.new\n\n until ancestor_class(klass) == NilClass\n ancestor_defaults = @@default_config[ancestor_class(klass).to_s.downcase.to_sym] ||\n HashWithIndifferentAccess.new\n inherited_defaults.merge!(ancestor_defaults)\n klass = ancestor_class(klass)\n end\n inherited_defaults.merge(my_defaults)\n end",
"def config\n\t\t\t@config ||= begin\n\t\t\t\tfile = File.join(self.location, \"config.yaml\")\n\t\t\t\tif File.exists?(file)\n\t\t\t\t\tYAML::load_file(file)\n\t\t\t\telse\n\t\t\t\t\t{}\n\t\t\t\tend\n\t\t\tend\n\t\tend",
"def config\n @config ||= begin\n conf = Bolt::Config.new(Bolt::Project.default_project, config_data)\n conf.modulepath = [modulepath].flatten\n conf\n end\n end",
"def genPiledDefaultConf(klass = self.class())\n if(klass == WithConfParam) then\n return klass::DefaultConf.dup() ;\n else\n newConf = genPiledDefaultConf(klass.superclass()) ;\n if(klass.const_defined?(:DefaultConf)) \n newConf.update(klass::DefaultConf) ;\n end\n \n return newConf ;\n end\n end",
"def initialize(config = nil)\n self.config = config || Cartage::Config.load(:default)\n end",
"def config\n @config ||= yaml_content || {\n 'apiVersion' => 'v1',\n 'clusters' => [],\n 'contexts' => [],\n 'current-context' => nil,\n 'kind' => 'Config',\n 'preferences' => {},\n 'users' => []\n }\n end",
"def set_conf_default(conf)\n end",
"def set_conf_default(conf)\n end",
"def configuration\n cfg = {:default_policy => @default_policy.to_s, :disabled_prompt => @disabled_prompt, :delimiter => @delimiter, :ip => @ip,\n :log_accounting => @log_accounting, :log_authentication => @log_authentication, :log_authorization => @log_authorization,\n :log_level => @logger_level, :login_prompt => @login_prompt, :max_clients => @max_clients, :password_expired_prompt => @password_expired_prompt,\n :password_prompt => @password_prompt, :port => @port, :sock_timeout => @sock_timeout, :testing => @testing }\n cfg[:dump_file] = @dump_file if (@dump_file)\n cfg[:key] = @key if (@key)\n cfg[:logger] = @logger if (@logger)\n cfg[:name] = @name if (@name)\n return(cfg)\n end",
"def default_value\n config[:default]\n end",
"def configuration\n @configuration ||= deep_merge(default_configuration, @factory_config)\n end",
"def init_config()\n options_apply_filter(\"DEFAULT\")\n end",
"def configuration\n @config ||= setup\n end",
"def initialize\n @config = OpenStruct.new\n end",
"def config(opts=nil)\n return @@config if opts.nil?\n @@config = Config.new opts\n end",
"def default_settings()\n @default_settings ||= {}\n end",
"def config_data\n {}\n end",
"def default_options\n if Object.const_defined?('Rails')\n {\n :file => Rails.root.join('config', 'config.yml'),\n :reload => Rails.env.development?,\n :env => Rails.env\n }\n else\n {\n :file => File.expand_path(\"config.yml\"),\n :reload => false,\n :env => \"development\"\n }\n end\n end",
"def to_config\n require_relative '../../puppet/util/docs'\n # Scrub any funky indentation; comment out description.\n str = Puppet::Util::Docs.scrub(@desc).gsub(/^/, \"# \") + \"\\n\"\n\n # Add in a statement about the default.\n str << \"# The default value is '#{default(true)}'.\\n\" if default(true)\n\n # If the value has not been overridden, then print it out commented\n # and unconverted, so it's clear that that's the default and how it\n # works.\n value = @settings.value(self.name)\n\n if value != @default\n line = \"#{@name} = #{value}\"\n else\n line = \"# #{@name} = #{@default}\"\n end\n\n str << (line + \"\\n\")\n\n # Indent\n str.gsub(/^/, \" \")\n end",
"def default_blacklight_config\n @default_blacklight_config ||= begin\n config = Spotlight::Engine.blacklight_config.deep_copy\n add_exhibit_specific_fields(config)\n config\n end\n end",
"def config\n self\n end"
] | [
"0.86144465",
"0.8302287",
"0.8281043",
"0.8212024",
"0.81273854",
"0.79296815",
"0.7816127",
"0.771636",
"0.76702875",
"0.76702875",
"0.7637694",
"0.762037",
"0.75607115",
"0.7452792",
"0.7452792",
"0.7431353",
"0.73758",
"0.72866136",
"0.7270108",
"0.725861",
"0.72493464",
"0.72243273",
"0.7218493",
"0.72161967",
"0.7202838",
"0.7202838",
"0.7191207",
"0.7189585",
"0.7181918",
"0.71815366",
"0.71534216",
"0.7124204",
"0.7124204",
"0.71057165",
"0.7096785",
"0.70899445",
"0.708261",
"0.7081546",
"0.70811003",
"0.7048495",
"0.7039625",
"0.70315003",
"0.701668",
"0.7003598",
"0.6984839",
"0.69684637",
"0.6962518",
"0.6951969",
"0.6919932",
"0.6912899",
"0.69093657",
"0.69093657",
"0.69093657",
"0.69093657",
"0.69093657",
"0.69093657",
"0.69093657",
"0.69093657",
"0.69093657",
"0.69093657",
"0.69093657",
"0.69093657",
"0.69093657",
"0.69093657",
"0.69093657",
"0.69093657",
"0.69093657",
"0.69093657",
"0.6904502",
"0.69012815",
"0.6899969",
"0.688748",
"0.68872887",
"0.68872887",
"0.68872887",
"0.68872887",
"0.68872887",
"0.68872887",
"0.6878845",
"0.68780774",
"0.68743145",
"0.6872783",
"0.6855208",
"0.6843026",
"0.68394923",
"0.6838655",
"0.6838655",
"0.6837649",
"0.68339884",
"0.6824116",
"0.6820642",
"0.68198127",
"0.6809879",
"0.68092644",
"0.680608",
"0.6801388",
"0.67975867",
"0.67955583",
"0.6781321",
"0.67465323"
] | 0.7103115 | 34 |
delete a config object from the cache and return it (or nil if this did not exist) | def config_uncache(key)
cnf = nil
lock(:c) do
cnf = @cache[:c].delete(key)
end
log cnf ?
"config #{key} deleted" :
"config #{key} not cached, not deleted"
cnf
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cache_delete(ck)\n cache_op(:delete, ck)\n nil\n end",
"def delete(key)\n ref = @cache.delete(key)\n ref.__getobj__ rescue nil\n end",
"def destroy_cache(obj)\n storage.del(key(obj))\n end",
"def cache_delete\n model.send(:cache_delete, cache_key)\n end",
"def cache_delete(key)\n @cache_store.delete(key)\n nil\n end",
"def delete(key)\n load_config unless @config\n @config.delete(key)\n save_config\n end",
"def cache_delete\n model.cache_delete_pk(pk)\n end",
"def clear_cache\n $redis.del self.id\n end",
"def clear_cache\n $redis.del self.id\n end",
"def delete key\n File.delete( cache_file(key) ) if File.exists?( cache_file(key) )\n end",
"def delete(key)\n self.config.delete(key)\n end",
"def delete(arg_)\n @config.lock\n\n @mutex.synchronize do\n if (objdata_ = _get_objdata(arg_))\n @objects.delete(objdata_[0].object_id)\n objdata_[2].each_key{ |tup_| _remove_tuple(objdata_, tup_) }\n end\n end\n self\n end",
"def cfg_delete(cfg)\n obj_delete cfg, ZoneConfiguration\n end",
"def del(key)\n log(\"remove :Cache, #{key}\")\n connection.remove(:Cache, key)\n end",
"def delete_cache(url, json: true)\n filename = cache_filename(url, json)\n if File.exist?(filename)\n logger.debug(\"Deleting cache #{filename}\")\n File.delete(filename)\n end\n end",
"def delete(key)\n @backend.delete(key)\n rescue ::Memcached::Error\n nil\n end",
"def destroy\n @ddconfig.destroy\n end",
"def delete(key)\n File.unlink cache_path(key)\n rescue Errno::ENOENT\n end",
"def delete(key)\n @config.delete(key.to_s)\n end",
"def remove(thing)\n @cache[section(thing)].delete(key(thing))\n end",
"def del_old_redis_cfg\n redis.del(old_redis_cfg_key)\n end",
"def remove(key)\n File.unlink cache_path(key)\n rescue Errno::ENOENT\n end",
"def delete(key, options = nil)\n Rails.cache.delete(key, options)\n rescue => exc\n Rails.logger.error { \"MEMCACHE-ERROR: delete: K: #{key.inspect}. M: #{exc.message}, I: #{exc.inspect}\" }\n nil\n end",
"def delete(key, options = nil)\n Rails.cache.delete(key, options)\n rescue => exc\n Rails.logger.error { \"MEMCACHE-ERROR: delete: K: #{key.inspect}. M: #{exc.message}, I: #{exc.inspect}\" }\n nil\n end",
"def delete( )\n File.delete(@configFileDNE)\n self.clear\n self\n end",
"def remove_cache_path\n cache_path.run_action(:delete)\n end",
"def delete(_url)\n # do nothing since we can't find the key by url\n end",
"def delete\n cache_delete\n super\n end",
"def delete\n cache_delete\n super\n end",
"def remove_config(key, options={})\n unless config_registry.has_key?(key)\n raise NameError.new(\"#{key.inspect} is not a config on #{self}\")\n end\n \n options = {\n :reader => true,\n :writer => true\n }.merge(options)\n \n config = config_registry.delete(key)\n cache_configurations(@configurations != nil)\n \n undef_method(config.reader) if options[:reader]\n undef_method(config.writer) if options[:writer]\n end",
"def delete_cache\n Rails.cache.delete(\"user_#{self.user_id.to_s}_provider_#{self.provider}\") \n end",
"def cache_delete_pk(pk)\n cache_delete(cache_key(pk))\n end",
"def remove_highest(var)\n @configs.each do |c|\n if c.key?(var)\n return c.delete(var)\n end\n end\n\n # return nil if we haven't returned a value yet\n nil\n end",
"def delete(entry)\n if index = @cache.delete(entry)\n entries.delete_at(index)\n end\n end",
"def delete(instance)\n @cache[mapped_class(instance.class)].delete(instance.key)\n end",
"def cache_delete(key: cache_key, **)\n Rails.cache.delete(key, namespace: namespace) if validate_key(key)\n end",
"def delete(key)\n configuration.delete(key)\n end",
"def cache_get(key)\n nil\n end",
"def delete_site_cache\n Rails.cache.delete([\"Site\", self.id])\n end",
"def remove(key)\n\t\t\tvalue = @config.shift(key)\n\t\t\treturn value\n\t\tend",
"def test_delete_existing\n @cache.add('Key', 'Data_to_delete', 0, Time.now.to_i + 60)\n result = @cache.delete('Key')\n retrieval = @cache.get('Key')\n\n assert_true result.success\n assert_equal 'SUCCESS', result.message.chomp.split(\"\\s\")[0]\n assert_false retrieval.success\n assert_equal 'NOT_FOUND', retrieval.message.chomp.split(\"\\s\")[0]\n end",
"def cache_get(key)\n cache_file = @config[:cache_directory] / \"#{key}.cache\"\n if File.file?(cache_file)\n _data, _expire = Marshal.load(cache_read(cache_file))\n if _expire.nil? || Time.now < _expire\n Merb.logger.info(\"cache: hit (#{key})\")\n return _data\n end\n FileUtils.rm_f(cache_file)\n end\n Merb.logger.info(\"cache: miss (#{key})\")\n nil\n end",
"def destroy\n @setting = Setting.find_cached(params[:id])\n @setting.destroy\n respond_to do |format|\n format.html { redirect_to settings_url, notice: 'Setting was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def free\n cache.clear\n nil\n end",
"def destroy\n @cdn_config = CdnConfig.find(params[:id])\n @cdn_config.destroy\n\n respond_to do |format|\n format.html { redirect_to cdn_configs_url }\n format.json { head :ok }\n end\n end",
"def delete(o)\n @hash.delete(o)\n self\n end",
"def delete(o)\n @hash.delete(o)\n self\n end",
"def clean\n # exists? will automatically call deconfigure if necessary\n @instance_cache.map!{ |dev| dev if dev.exists? }\n end",
"def cleanup(config_store, verbose, cache_root = T.unsafe(nil)); end",
"def destroy\n delete!(get, phase: :destroyed) if get && !cache.uploaded?(get)\n end",
"def find(id)\n hash = @hashes[id]\n hash ? hash[:deletehash] : nil\n end",
"def rm_r_cached(path)\n invoke(:rm, '-r', '--cached', path)\n true\n end",
"def after_destroy(entry)\n expire_cache_for(entry)\n end",
"def getcached(url)\n _cached = instance_variable_get \"@cached_#{hashed(url)}\"\n return _cached unless _cached.nil?\n path = CACHE_FILE + \"#{hashed(url)}.json\"\n if File.exists?(path)\n f = File.open(path)\n _cached = JSON.parse(f.read)\n instance_variable_set(\"@cached_#{hashed(url)}\", _cached)\n return _cached\n end\n return nil\n end",
"def getcached(url)\n _cached = instance_variable_get \"@cached_#{hashed(url)}\"\n return _cached unless _cached.nil?\n path = CACHE_FILE + \"#{hashed(url)}.json\"\n if File.exists?(path)\n f = File.open(path)\n _cached = JSON.parse(f.read)\n instance_variable_set(\"@cached_#{hashed(url)}\", _cached)\n return _cached\n end\n return nil\n end",
"def getcached(url)\n _cached = instance_variable_get \"@cached_#{hashed(url)}\"\n return _cached unless _cached.nil?\n path = CACHE_FILE + \"#{hashed(url)}.json\"\n if File.exists?(path)\n f = File.open(path)\n _cached = JSON.parse(f.read)\n instance_variable_set(\"@cached_#{hashed(url)}\", _cached)\n return _cached\n end\n return nil\n end",
"def getcached(url)\n _cached = instance_variable_get \"@cached_#{hashed(url)}\"\n return _cached unless _cached.nil?\n path = CACHE_FILE + \"#{hashed(url)}.json\"\n if File.exists?(path)\n f = File.open(path)\n _cached = JSON.parse(f.read)\n instance_variable_set(\"@cached_#{hashed(url)}\", _cached)\n return _cached\n end\n return nil\n end",
"def getcached(url)\n _cached = instance_variable_get \"@cached_#{hashed(url)}\"\n return _cached unless _cached.nil?\n path = CACHE_FILE + \"#{hashed(url)}.json\"\n if File.exists?(path)\n f = File.open(path)\n _cached = JSON.parse(f.read)\n instance_variable_set(\"@cached_#{hashed(url)}\", _cached)\n return _cached\n end\n return nil\n end",
"def getcached(url)\n _cached = instance_variable_get \"@cached_#{hashed(url)}\"\n return _cached unless _cached.nil?\n path = CACHE_FILE + \"#{hashed(url)}.json\"\n if File.exists?(path)\n f = File.open(path)\n _cached = JSON.parse(f.read)\n instance_variable_set(\"@cached_#{hashed(url)}\", _cached)\n return _cached\n end\n return nil\n end",
"def getcached(url)\n _cached = instance_variable_get \"@cached_#{hashed(url)}\"\n return _cached unless _cached.nil?\n path = CACHE_FILE + \"#{hashed(url)}.json\"\n if File.exists?(path)\n f = File.open(path)\n _cached = JSON.parse(f.read)\n instance_variable_set(\"@cached_#{hashed(url)}\", _cached)\n return _cached\n end\n return nil\n end",
"def getcached(url)\n _cached = instance_variable_get \"@cached_#{hashed(url)}\"\n return _cached unless _cached.nil?\n path = CACHE_FILE + \"#{hashed(url)}.json\"\n if File.exists?(path)\n f = File.open(path)\n _cached = JSON.parse(f.read)\n instance_variable_set(\"@cached_#{hashed(url)}\", _cached)\n return _cached\n end\n return nil\n end",
"def getcached(url)\n _cached = instance_variable_get \"@cached_#{hashed(url)}\"\n return _cached unless _cached.nil?\n path = CACHE_FILE + \"#{hashed(url)}.json\"\n if File.exists?(path)\n f = File.open(path)\n _cached = JSON.parse(f.read)\n instance_variable_set(\"@cached_#{hashed(url)}\", _cached)\n return _cached\n end\n return nil\n end",
"def destroy\n @global_config = AppConfig.find(params[:id])\n @global_config.destroy\n\n respond_to do |format|\n format.html { redirect_to global_configs_url }\n format.json { head :no_content }\n end\n end",
"def delete(key)\n @configuration.delete(key)\n end",
"def delete(key)\n @configuration.delete(key)\n end",
"def delete(key)\n @configuration.delete(key)\n end",
"def delete_cache_files; end",
"def delete_cache_files; end",
"def get(key)\n # Return nothing if not in the cache or it has expired.\n return if key.nil?\n\n entry = @cache[key]\n return unless entry\n return if entry.expired?\n\n # Otherwise return the cached object.\n # We don't delete the cached entry because we might need to force its use if its expired and offline\n entry.object\n end",
"def destroy\n @app_config = AppConfig.find(params[:id])\n @app_config.destroy\n\n respond_to do |format|\n format.html { redirect_to app_configs_url }\n format.json { head :no_content }\n end\n end",
"def reload_config\n @config = nil\n end",
"def borra_cache(recurso)\n Rails.cache.delete(\"#{recurso}_#{id}\")\n end",
"def delete(key)\n value = self[key]\n\n @memcached.delete key\n\n value\n end",
"def delete(*args)\n args.each do |arg|\n @cache.delete(\"#{@cache_name}:#{arg}\")\n end\n end",
"def clear_cache; end",
"def invalidate!\n @cache = MiniCache::Store.new\n return nil\n end",
"def destroy\n @app_config = AppConfig.find(params[:id])\n @app_config.destroy\n\n respond_to do |format|\n format.html { redirect_to(app_configs_url) }\n format.xml { head :ok }\n end\n end",
"def unload!\n cache.save if @__cache\n __send__ :unloaded if respond_to? :unloaded\n\n @__cache = nil\n end",
"def destroy\n @config.destroy\n respond_to do |format|\n format.html { redirect_to configs_url, notice: \"Config was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def finalize\n return unless cache = self[:cache]\n\n finalize_settings.each do |meth, key|\n next if has_key?(key)\n\n send(meth)\n self[key] = cache.delete(key) if cache.has_key?(key)\n end\n\n nil\n end",
"def getcached(url)\n _cached = instance_variable_get \"@cached_#{hashed(url)}\"\n return _cached unless _cached.nil?\n path = CACHE_FILE + \"#{hashed(url)}.json\"\n if File.exists?(path)\n File.open(path, \"r:UTF-8\") do |f|\n _cached = JSON.parse(f.read)\n instance_variable_set(\"@cached_#{hashed(url)}\", _cached)\n return _cached\n end \n end\n return nil\n end",
"def clear_cache(uri)\n if last_cached(uri) > 0\n cache_store.delete(cache_key([uri, last_cached(uri)]))\n cache_store.delete(cache_key(uri))\n end\n end",
"def clear_cache() @cache = {}; end",
"def delete(entry)\n deleted_index = @cache.delete(key_for(entry))\n if deleted_index\n @cache.each do |key, index|\n @cache[key] -= 1 if index > deleted_index\n end\n end\n deleted_index\n end",
"def cache_clear\n @store.delete\n end",
"def delete\n result = Base.redis.hdel(:sources, name)\n if result == 1\n delete_all_inputs\n Log.info \"Deleting Source object from Redis: #{name}\"\n else\n raise UnknownSource, \"Cannot delete non-existent Source object in Redis: #{name}\"\n end\n result\n end",
"def uncache(options)\n raise 'todo'\n end",
"def delete(key, opts = {})\n opts.symbolize_keys!\n result = nil\n getMutex(key).synchronize do\n result = read_from_cache_or_cookies(key, opts)\n cookies.delete(key)\n cache.delete(key)\n end\n return result\n end",
"def remove_exy_cached(x,y,id)\n if list = @exy_cache[[x,y]]\n list.delete(id)\n end\n end",
"def destroy\n @configuracion = Configuracion.find(params[:id])\n\t@temp = @configuracion.dup\n @configuracion.destroy\n\tguardar_log(session[:usuario_id], self.class.name,__method__.to_s, @temp,nil )\n respond_to do |format|\n format.html { redirect_to configuraciones_url }\n format.json { head :ok }\n end\n end",
"def cfg_remove(cfg,member)\n obj_remove(cfg,ZoneConfiguration,member)\n end",
"def destroy\n @config_value = ConfigValue.find(params[:id])\n @config_value.destroy\n\n redirect_to config_values_url\n end",
"def cache_clear\n @store.flush_all\n rescue ::MemCache::MemCacheError => e\n Log.error(e)\n nil\n end",
"def config_delete(name)\n Bundler.settings.set_local(name, nil)\n Bundler.settings.set_global(name, nil)\n end",
"def delete\n if self.class.exists?(handle.address, handle.use_ssl?, handle.port)\n self.class.session_store.delete(self.class.key(handle.address, handle.use_ssl?, handle.port))\n end\n end",
"def destroy\n @kf_global_config = Kf::GlobalConfig.find(params[:id])\n @kf_global_config.destroy\n\n respond_to do |format|\n format.html { redirect_to kf_global_configs_url({:page => params[:page]}) }\n format.json { head :no_content }\n end\n end",
"def delete(session, context = Context.current)\n digest = session.instance_variable_get(\"@digest\")\n @cache.delete(digest)\n super\n end",
"def destroy\n @cach = Cache.find(params[:id])\n @cach.destroy\n\n respond_to do |format|\n format.html { redirect_to caches_url }\n format.json { head :ok }\n end\n end",
"def unset_config(key)\n store :delete, \"configs/#{key}\"\n end",
"def destroy\n conf.delete 'dashboard'\n end"
] | [
"0.63203675",
"0.6216962",
"0.6187307",
"0.6120253",
"0.6072019",
"0.5821527",
"0.57268876",
"0.5697902",
"0.5697902",
"0.5688667",
"0.5678976",
"0.5660041",
"0.5633941",
"0.56315655",
"0.56236655",
"0.56235796",
"0.56131256",
"0.5610702",
"0.55546546",
"0.5499076",
"0.5496465",
"0.5482084",
"0.5465932",
"0.5463906",
"0.54372764",
"0.54188657",
"0.5413069",
"0.5387601",
"0.5387601",
"0.53795606",
"0.53640765",
"0.5360534",
"0.53436816",
"0.5342748",
"0.53391623",
"0.53296876",
"0.53282964",
"0.5326923",
"0.53204095",
"0.53154653",
"0.5305688",
"0.5293383",
"0.5277497",
"0.5277469",
"0.52761906",
"0.5272627",
"0.5272627",
"0.5267649",
"0.526082",
"0.525535",
"0.5248393",
"0.52471286",
"0.523755",
"0.5232188",
"0.5232188",
"0.5232188",
"0.5232188",
"0.5232188",
"0.5232188",
"0.5232188",
"0.5232188",
"0.5232188",
"0.5231255",
"0.5212694",
"0.5212694",
"0.5212694",
"0.5208684",
"0.5208684",
"0.5188413",
"0.51784456",
"0.5177486",
"0.51561934",
"0.51553196",
"0.5151932",
"0.5150842",
"0.5140208",
"0.5135654",
"0.51252913",
"0.5118427",
"0.5115048",
"0.51121753",
"0.51047397",
"0.51030463",
"0.51006156",
"0.5100283",
"0.50986964",
"0.5098219",
"0.5096772",
"0.5094333",
"0.5091758",
"0.5085501",
"0.50825447",
"0.5078932",
"0.50781256",
"0.5071661",
"0.5065387",
"0.5064149",
"0.50640804",
"0.5062675",
"0.5057325"
] | 0.6778379 | 0 |
does the cache contain a config object for this key? | def config_cached?(key)
lock(:c) do
@cache[:c].has_key?(key)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_key?(key)\n @cache.has_key?(key)\n end",
"def cache?(key)\n auth_objects_cache.key? key\n end",
"def cached?(key)\n false\n end",
"def cached?(key)\n not @memcache.get(key).nil?\n end",
"def include?(key)\n File.exist?(cache_path(key))\n end",
"def has_key?(key)\n @config.has_key? key\n end",
"def include?(entry)\n @cache.has_key?(key_for(entry))\n end",
"def cached? *key\n @cache.has_key? key\n end",
"def exist?(key)\n File.exist?(cache_path(key))\n end",
"def key?(key)\n @configuration.key?(key)\n end",
"def has_key?(key)\n @configuration.has_key?(key.to_sym)\n end",
"def key?(key)\n configuration.key?(key)\n end",
"def cached?\n cache_path.exist?\n end",
"def cached?\n cache_path.exist?\n end",
"def has_key?(key)\n configs.has_key?(key) || store.has_key?(key) \n end",
"def cached?\n Cache.has? plist\n end",
"def has_key? name\n name_str = name.to_s\n name_sym = name.to_sym\n\n @config.each do |configfile|\n if configfile[:config][name_str] or configfile[:config][name_sym]\n return true\n end\n end\n return false\n end",
"def cached?(key)\n if @cache.key?(key)\n _data, _expire = *cache_read(key)\n return true if _expire.nil? || Time.now < _expire\n expire(key)\n end\n false\n end",
"def has?(key)\n [cache, values].any? { |store| store.keys.include?(key.to_sym) }\n end",
"def cache_exist?\n File.exist?(@cache_file)\n end",
"def has_key?(key); end",
"def has_key?(key); end",
"def include?(key = nil)\n key ||= BasicCache.caller_name\n key = key.to_sym\n @store.include?(key) && Time.now - @store[key].stamp < @lifetime\n end",
"def configured?(key)\n assert_explanation(key)\n @configuration.has_key?(key)\n end",
"def style_cached?(key)\n lock(:s) do\n @cache[:s].has_key?(key)\n end\n end",
"def cache?\n caching && true\n end",
"def include?(key)\n key = key.to_sym\n cache.keys.include?(key) || values.keys.include?(key)\n end",
"def enabled?\n @config[:caching][:enabled]\n end",
"def cached?(key)\n cache_file = @config[:cache_directory] / \"#{key}.cache\"\n _data = _expire = nil\n if File.file?(cache_file)\n _data, _expire = Marshal.load(cache_read(cache_file))\n return true if _expire.nil? || Time.now < _expire\n FileUtils.rm_f(cache_file)\n end\n false\n end",
"def include?(key)\n key = key.to_sym\n cache.keys.include?(key) || values.keys.include?(key)\n end",
"def cached?\n options[:cache] == true\n end",
"def is_key_exist(key)\r\n (@redis.exists key) ? true : false \r\n end",
"def has key, expire_time = nil\n return false unless CACHE.has_key? key\n return true unless expire_time\n return false if Time.at(CACHE[key][1]) < (Time.now - expire_time)\n true\n end",
"def _in_cache?(field)\n return false if self.class._cache.blank?\n cached_obj = self.class._cache[\"#{object.id}.#{object.updated_at.to_i}\"]\n cached_obj.present? && cached_obj[field].present?\n end",
"def cacheable?\n @cacheable\n end",
"def existe_cache?(recurso)\n if Rails.cache.exist?(\"#{recurso}_#{id}\")\n cache = Rails.cache.read(\"#{recurso}_#{id}\")\n\n begin\n (cache[:created_at] + cache[:expires_in]) > Time.now.to_f\n rescue\n false\n end\n\n else\n false\n end\n end",
"def cached?(controller, action)\n controller, action = stringify_params controller, action\n @config.has_key?(controller) && \n @config[controller].respond_to?(:has_key?) && \n @config[controller].has_key?(action)\n end",
"def cache_exists?\n File.exist?(cached_file)\n end",
"def is_in_cache(var)\n Rails.cache.exist?(var)\nend",
"def expire_cache_key?\n true\n end",
"def has_key?(key)\n @stored[key] && !@stored[key].empty? ? true : false\n end",
"def exist?(key, options = nil)\n Rails.cache.exist?(key, options)\n rescue => exc\n Rails.logger.error { \"MEMCACHE-ERROR: exists?: K: #{key.inspect}. M: #{exc.message}, I: #{exc.inspect}\" }\n nil\n end",
"def has_key?(key)\n return self.fetch(key) ? true : false\n end",
"def key?(key)\n config.resolver.key?(_container, key)\n end",
"def exists?\n retrieve\n true\n rescue Error::NoSuchKey\n false\n end",
"def cacheable?\n true\n end",
"def record_cached?(id)\n _record_cache.has_key?(id.to_s)\n end",
"def exist(key)\n check_return_code(\n Lib.memcached_exist(@struct, key),\n key\n )\n end",
"def cached?\n !(!@cached)\n end",
"def configured?(key)\n if _configured.include?(key) && _settings[key].cloneable?\n return _values[key] != _settings[key].to_value\n end\n\n _configured.include?(key)\n end",
"def cache?\n false\n end",
"def exists?\n conf.has_key? 'dashboard'\n end",
"def configuration_for?(key)\n key = resolver.resolve(key) unless key == :default\n configurations.key?(key)\n end",
"def cache?\n persisted?\n end",
"def should_cache?(key_with_locale, options, had_key)\n if had_key\n return false unless options[:default] && !options[:default].is_a?(Array)\n end\n\n _, key_without_locale = ::Lit::Cache.split_key(key_with_locale)\n return false if is_ignored_key(key_without_locale)\n\n true\n end",
"def read_from_cache?\n raise NotImplementedError, \"You must implement #{self.class}##{__method__}\"\n end",
"def exists?\n conf.has_key? 'api'\n end",
"def key?(key)\n self.reload if @should_reload\n return @data.key?(key.to_sym)\n end",
"def img_exists?(key)\n lock(:img) do\n @cache[:img].has_key?(key)\n end\n end",
"def exists?(key)\n @redis.exists(prefix(key))\n end",
"def cache_hit?\n @gapi.cache_hit\n end",
"def key?(key)\n configuration.key?(key.to_sym) || config_contexts.key?(key.to_sym)\n end",
"def cached?(name, *args)\n return false if Rails.env == 'development'\n cache = Cacheable.cache[self][name.to_sym]\n return false unless cache.key?(args)\n params = cache[args]\n !(params[:force] && (params[:time] < (Time.new - params[:ttl])))\n end",
"def cacheable?\n return false if method != :get && method != :head\n return false if cache_control.no_store?\n true\n end",
"def has_key? key\n @lock.read_sync{ @data.has_key? key }\n end",
"def has_key?(key)\n !!fetch(key)\n rescue ContextMiss\n false\n end",
"def exist?(key)\n store.key?(key)\n end",
"def enabled?\n @cache_enabled\n end",
"def enabled?\n @cache_enabled\n end",
"def is_cached_entity?\n # Set in initialize via marshal_load\n @loaded_from_cache\n end",
"def from_cache?\n @from_cache\n end",
"def include? key\n\t\t@data_base.has_key? key\n\tend",
"def should_cache?\n false\n end",
"def has_key?(key)\n\t\tmust_be_in_synchronize_block\n\t\treturn @collection.has_key?(key)\n\tend",
"def has_key? key; key? key; end",
"def cached?\n @rules = cached_rules if cached_rules? && caching_on?\n end",
"def cacheable?\n last.nil? || last.cacheable\n end",
"def exists?(key)\n key.present? && manager.key?(key)\n end",
"def exists?(cache_key)\n @pg.exec_prepared(@exists_statement_name, [object_to_cache_key(cache_key)]).ntuples.eql?(1)\n end",
"def exist?(key)\n\n end",
"def expire_application_cache_key?\n true\n end",
"def check_cache(key)\n checksum = Digest::MD5.hexdigest(key)\n node['data-bag-cache'][node['data-bag-cache']['__checksums__'][checksum]]\n end",
"def cache?\n val = @gapi.configuration.query.use_query_cache\n return false if val.nil?\n val\n end",
"def use_cache?\n super && !against_head?\n end",
"def use_cache?\n super && !against_head?\n end",
"def cache_attribute?(attr_name)\n cached_attributes.include?(attr_name)\n end",
"def in_progress?\n $redis.keys(redis_key).present?\n end",
"def cache_hit?\n @gapi.statistics.query.cache_hit\n end",
"def has_key?(p0) end",
"def cached?; end",
"def _cached?(field)\n self.class._cacheable_fields.present? && self.class._cacheable_fields.include?(field.to_sym)\n end",
"def include_key?(key)\n\t\t\ttrue\n\t\tend",
"def cached?\n Dir.exist?(cached_repo_path)\n end",
"def include?(value)\n File.exist?(File.join(cache_path, value))\n end",
"def caching?\n @params.key?(:cache) ? @params[:cache] : @@caching\n end",
"def exists?\n get_lxd_config_value(resource[:config]) != nil\n end",
"def cache_enabled?(opts)\n # only gets ever get cached\n return false unless opts[:method] == :get\n return false if opts[:cache_key].nil?\n return false unless Tml.cache.enabled?\n true\n end",
"def performing_caching?\n @config ? @config.perform_caching : Rails.application.config.action_controller.perform_caching\n end",
"def is_cache_expired?(key)\n raise 'The is_cache_expired method must be implemented'\n end",
"def cache?\n return false if endpoint.options.nil?\n endpoint.options.fetch(:route_options, {}).fetch(:cache, false)\n end"
] | [
"0.79252887",
"0.79077",
"0.7853994",
"0.7634765",
"0.7555837",
"0.7480635",
"0.7450861",
"0.74242336",
"0.7378295",
"0.7224839",
"0.71877193",
"0.7150397",
"0.71482897",
"0.71304995",
"0.70795715",
"0.70012224",
"0.6922986",
"0.68965566",
"0.68965226",
"0.68949485",
"0.68761826",
"0.68761826",
"0.68740755",
"0.6870046",
"0.6841275",
"0.68272007",
"0.68268967",
"0.6812659",
"0.68083584",
"0.6805274",
"0.67947215",
"0.67916083",
"0.6782021",
"0.67817277",
"0.67780477",
"0.6771318",
"0.6770628",
"0.6769281",
"0.6766427",
"0.6754297",
"0.6725457",
"0.67172253",
"0.67054594",
"0.6704693",
"0.6695564",
"0.66895527",
"0.66793483",
"0.6667733",
"0.6637494",
"0.66349036",
"0.66200495",
"0.661017",
"0.65994525",
"0.6597149",
"0.658396",
"0.65390885",
"0.65341204",
"0.65337855",
"0.6530134",
"0.65285295",
"0.6526895",
"0.65100944",
"0.6508138",
"0.65012765",
"0.6500996",
"0.6500052",
"0.6498758",
"0.64860255",
"0.64860255",
"0.64738023",
"0.64516926",
"0.6446127",
"0.6430434",
"0.6424124",
"0.6421724",
"0.6421233",
"0.6403594",
"0.63950527",
"0.63935465",
"0.63894564",
"0.6387835",
"0.63746214",
"0.63698673",
"0.636376",
"0.636376",
"0.6362022",
"0.6361448",
"0.63562846",
"0.63554984",
"0.6354215",
"0.63324237",
"0.63317704",
"0.63308424",
"0.6327151",
"0.63230354",
"0.63189656",
"0.63172376",
"0.6312161",
"0.62987524",
"0.62931937"
] | 0.8443401 | 0 |
a new config object with settings from config/default.style | def config_new
cnf = GT::Style.new
style_file = File.expand_path("config/default.style",
"#{File.dirname(__FILE__)}/../..")
log "new config, trying to load #{style_file}", 2
cnf.load_file style_file
log "new config, default.style loaded", 2
return cnf
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def style_new\n st = GT::Style.new\n style_file = File.expand_path(\"config/default.style\",\n \"#{File.dirname(__FILE__)}/../..\")\n log \"new style, trying to load #{style_file}\", 2\n st.load_file style_file\n log \"new style, default.style loaded\", 2\n return st\n end",
"def set_config_defaults\n @config['style'] ||= ''\n @config['output_path'] ||= 'public/sass/mixins/sprites'\n @config['image_output_path'] ||= 'public/images/sprite/'\n @config['source_path'] ||= ''\n @config['default_format'] ||= 'png'\n @config['class_separator'] ||= '_'\n end",
"def initialize\n load_default_styles\n end",
"def default_config\n {}\n end",
"def use_default_style!\n @use_default_style = true\n end",
"def style_default\n lock(:s) do\n @cache[:s][:default] ||= style_new\n end\n end",
"def default_config\n <<~CONFIG\n defaults: &defaults\n data_root: data\n candidates_root: zzz_candidates\n departed_root: zzz_departed\n project_root: projects\n editor: code\n feedback_polarity_default: positive\n meeting_location_default: alcove\n log_filename: log.adoc\n overview_filename: overview.adoc\n pto_default: vacation\n voip_meeting_default: Zoom\n\n development:\n # <<: *defaults\n data_root: data\n candidates_root: zzz_candidates\n departed_root: zzz_departed\n project_root: projects\n editor: code\n feedback_polarity_default: positive\n meeting_location_default: alcove\n log_filename: log.adoc\n overview_filename: overview.adoc\n pto_default: vacation\n voip_meeting_default: Zoom\n\n test:\n # <<: *defaults\n data_root: data\n candidates_root: zzz_candidates\n departed_root: zzz_departed\n project_root: projects\n editor: code\n feedback_polarity_default: positive\n meeting_location_default: alcove\n log_filename: log.adoc\n overview_filename: overview.adoc\n pto_default: vacation\n voip_meeting_default: Zoom\n\n production:\n # <<: *defaults\n data_root: data\n candidates_root: zzz_candidates\n departed_root: zzz_departed\n project_root: projects\n editor: code\n feedback_polarity_default: positive\n meeting_location_default: alcove\n log_filename: log.adoc\n overview_filename: overview.adoc\n pto_default: vacation\n voip_meeting_default: Zoom\n CONFIG\n end",
"def configDefaults(config)\n end",
"def initialize\n @config = DEFAULT_CONFIG.deep_dup\n end",
"def load_default_config\n self[:disable_html] ||= true\n self[:url_target] ||= \"_BLANK\"\n self[:image_alt] ||= \"Posted Image\"\n self[:table_width] ||= \"100%\"\n self[:syntax_highlighter] ||= :raw\n self[:coderay_options] ||= {}\n end",
"def default_settings\n {}\n end",
"def default_config\n self.class.default_config\n end",
"def default_config\n self.class.config[:default_config].nil? ? {} : {}.merge(self.class.config[:default_config])\n end",
"def set_defaults!\n __load_config( DEFAULTS )\n end",
"def config_file_defaults\n Chef::Config[:knife].save(true) # this is like \"dup\" to a (real) Hash, and includes default values (and user set values)\n end",
"def default_configuration=(_arg0); end",
"def config_file_settings\n Chef::Config[:knife].save(false) # this is like \"dup\" to a (real) Hash, and does not include default values (just user set values)\n end",
"def default_settings()\n @default_settings ||= {}\n end",
"def config=(config); end",
"def init_config()\n options_apply_filter(\"DEFAULT\")\n end",
"def to_config\n require_relative '../../puppet/util/docs'\n # Scrub any funky indentation; comment out description.\n str = Puppet::Util::Docs.scrub(@desc).gsub(/^/, \"# \") + \"\\n\"\n\n # Add in a statement about the default.\n str << \"# The default value is '#{default(true)}'.\\n\" if default(true)\n\n # If the value has not been overridden, then print it out commented\n # and unconverted, so it's clear that that's the default and how it\n # works.\n value = @settings.value(self.name)\n\n if value != @default\n line = \"#{@name} = #{value}\"\n else\n line = \"# #{@name} = #{@default}\"\n end\n\n str << (line + \"\\n\")\n\n # Indent\n str.gsub(/^/, \" \")\n end",
"def configure()\n origConfig = @site.config['svgo'] || {}\n generatedConfig = origConfig.clone\n generatedConfig.delete_if {|k, v| k.end_with?('.svg')}\n\n if origConfig.key?(@name)\n generatedConfig.merge!(origConfig[@name])\n end\n\n generatedConfig\n end",
"def defaults\n {\n colour: {},\n style: [],\n text: '',\n width: nil,\n align: :left,\n parent: nil,\n }\n end",
"def apply_default_config\n return unless DEFAULT_CONFIG.is_a?(Hash)\n DEFAULT_CONFIG.each do |k, v|\n apply_config(k, v)\n end\n end",
"def defaults\n return @config if @config\n\n @config = Configatron::Store.new\n file_path = File.expand_path('../../../config/xpaths.yml', __FILE__)\n hash_config = YAML::load_file(file_path)\n\n @config.configure_from_hash(hash_config)\n @config.lock!\n @config\n end",
"def config_default\n lock(:c) do\n @cache[:c][:default] ||= config_new\n end\n end",
"def defaults\n {\n colour: {},\n name: '',\n repository: Vedeu::Repositories::RepositoryTestModule,\n style: [],\n }\n end",
"def populate_defaults(config)\n new_config = DEFAULT_CEEDLING_CONFIG.deep_clone\n new_config.deep_merge!(config)\n config.replace(new_config)\n\n @configurator_builder.populate_defaults( config, DEFAULT_TOOLS_TEST )\n @configurator_builder.populate_defaults( config, DEFAULT_TOOLS_TEST_PREPROCESSORS ) if (config[:project][:use_test_preprocessor])\n @configurator_builder.populate_defaults( config, DEFAULT_TOOLS_TEST_DEPENDENCIES ) if (config[:project][:use_deep_dependencies])\n\n @configurator_builder.populate_defaults( config, DEFAULT_TOOLS_RELEASE ) if (config[:project][:release_build])\n @configurator_builder.populate_defaults( config, DEFAULT_TOOLS_RELEASE_ASSEMBLER ) if (config[:project][:release_build] and config[:release_build][:use_assembly])\n @configurator_builder.populate_defaults( config, DEFAULT_TOOLS_RELEASE_DEPENDENCIES ) if (config[:project][:release_build] and config[:project][:use_deep_dependencies])\n end",
"def defaults\n {\n background: Vedeu::Colours::Background.coerce(:default),\n base_path: base_path,\n colour_mode: detect_colour_mode,\n compression: true,\n debug: false,\n drb: false,\n drb_host: nil,\n drb_port: nil,\n drb_height: 25,\n drb_width: 80,\n foreground: Vedeu::Colours::Foreground.coerce(:default),\n height: nil,\n interactive: true,\n log: nil,\n log_only: [],\n mouse: true,\n once: false,\n profile: false,\n renderers: [Vedeu::Renderers::Terminal.new],\n root: nil,\n stdin: nil,\n stdout: nil,\n stderr: nil,\n terminal_mode: :raw,\n width: nil,\n }\n end",
"def defined_styles\n default_styles = {\n detail: '100X100#',\n blurred: {\n size: '640x256',\n offset: '+0+0',\n raduis_sigma: '12x5',\n tint: '40',\n processors: [:blur]\n },\n home: '640X640#'\n }\n default_styles\n end",
"def merge_with_default(config, config_file, unset_nil:)\n default_configuration = ConfigLoader.default_configuration\n\n disabled_by_default = config.for_all_cops['DisabledByDefault']\n enabled_by_default = config.for_all_cops['EnabledByDefault']\n\n if disabled_by_default || enabled_by_default\n default_configuration = transform(default_configuration) do |params|\n params.merge('Enabled' => !disabled_by_default)\n end\n end\n\n config = handle_disabled_by_default(config, default_configuration) if disabled_by_default\n\n opts = { inherit_mode: config['inherit_mode'] || {},\n unset_nil: unset_nil }\n Config.new(merge(default_configuration, config, **opts), config_file)\n end",
"def defaults()\n\t\t@height ||= 200\n\t\t@width ||= 350\n\t\t@title ||= \"Savable Settings Demo\"\n\t\t@text ||= \"Try changing the window size, title and text in this window. You will see that it saves its state \" +\n\t\t\t\"to a file named settings.yaml. So when you run this program again, it will be the same as \" +\n\t\t\t\"when you left. To see this file, click the 'Refresh' button. To reset to \" +\n\t\t\t\"defaults, just delete settings.yaml.\"\n\tend",
"def create_config\n Time.use_zone(screen.time_zone) do\n self.start_time ||= Time.zone.parse(ConcertoConfig[:content_default_start_time], Clock.time + ConcertoConfig[:start_date_offset].to_i.days)\n self.end_time ||= Time.zone.parse(ConcertoConfig[:content_default_end_time], Clock.time + ConcertoConfig[:start_date_offset].to_i.days + ConcertoConfig[:default_content_run_time].to_i.days)\n end\n \n self.config = {} if !self.config\n self.config = default_config().merge(self.config)\n self.config\n end",
"def create_defaults\n import_layout(self.layout_dir(:absolute => true))\n import_content(self.content_dir(:absolute => true))\n end",
"def defaults\n {\n colour: nil,\n name: nil,\n style: nil,\n value: '',\n position: [1, 1],\n }\n end",
"def default_configuration\n {}\n end",
"def config(opts=nil)\n if opts\n @config = @config.merge(get_subhash(opts, DEFAULTS.keys))\n else\n @config\n end\n end",
"def starter_stylesheet\n {\n :header => [:bold, :yellow],\n :add => [:bold, :green],\n :remove => [:bold, :red],\n :range => [:bold, :magenta],\n :trailing_whitespace => [:background, :red]\n }\n end",
"def parse_default_config\n default_config_path = 'config/default.yml'\n @default_config = ( YAML.load_file(default_config_path) if File.exist?(default_config_path) ) || {}\n end",
"def load_config!\n if options[:config]\n config_inst = Config.new(options[:config])\n elsif self.class.const_defined?(:DEFAULT_CONFIGURATION_FILES)\n path = self.class.const_get(:DEFAULT_CONFIGURATION_FILES).detect do |check|\n full_check = File.expand_path(check)\n File.exists?(full_check)\n end\n config_inst = Config.new(path) if path\n end\n if config_inst\n options.delete(:config)\n defaults_inst = Smash[\n config_class.new(\n defaults.to_smash\n ).to_smash.find_all do |key, value|\n defaults.key?(key)\n end\n ]\n config_data = config_inst.data\n config_inst = Smash[\n config_inst.to_smash.find_all do |key, value|\n config_data.key?(key)\n end\n ]\n options_inst = Smash[\n config_class.new(\n options.to_smash\n ).to_smash.find_all do |key, value|\n options.key?(key)\n end\n ]\n @options = config_class.new(\n defaults_inst.to_smash.deep_merge(\n config_inst.to_smash.deep_merge(\n options_inst.to_smash\n )\n )\n ).to_smash\n else\n @options = config_class.new(\n defaults.to_smash.deep_merge(\n options.to_smash\n )\n ).to_smash\n end\n options\n end",
"def override_defaults_based_on_config(config)\n config ||= {}\n config['commands'] ||= {}\n\n override_default(flags,config)\n override_default(switches,config)\n\n commands.each do |command_name,command|\n command_config = config['commands'][command_name] || {}\n\n override_default(command.flags,command_config)\n override_default(command.switches,command_config)\n end\n end",
"def configure_styles(event)\n return {} if event.metadata[:name].nil?\n\n STYLES.fetch(event.metadata[:name].to_sym, {})\n .dup\n .merge!(@styles[event.metadata[:name].to_sym] || {})\n end",
"def create_config\n self.config = {} if !self.config\n end",
"def create_config\n self.config = {} if !self.config\n end",
"def default_blacklight_config\n @default_blacklight_config ||= begin\n config = Spotlight::Engine.blacklight_config.deep_copy\n add_exhibit_specific_fields(config)\n config\n end\n end",
"def defaults\n {\n client: nil,\n colour: nil,\n parent: nil,\n style: nil,\n value: [],\n }\n end",
"def defaults\n {\n client: nil,\n colour: nil,\n parent: nil,\n style: nil,\n value: [],\n }\n end",
"def styles\n @styles ||= Hash.new{ |h, k| h[k] = {} }\n end",
"def initial_config\n default_config.deep_merge(@passed_config)\n end",
"def set_style()\n style = @yaml['html']['style'] || @yaml['style']\n case\n when style.nil? then ''\n when style.class == String then \"style=\\\"#{style}\\\"\"\n when style.class == Hash then\n value = style.to_a.inject([]) {|r,v| r << \"#{v[0]}: #{v[1]}\" }.join(';')\n \"style=\\\"#{value}\\\"\" \n else ''\n end \nend",
"def set_style()\n style = @yaml['html']['style'] || @yaml['style']\n case\n when style.nil? then ''\n when style.class == String then \"style=\\\"#{style}\\\"\"\n when style.class == Hash then\n value = style.to_a.inject([]) {|r,v| r << \"#{v[0]}: #{v[1]}\" }.join(';')\n \"style=\\\"#{value}\\\"\" \n else ''\n end \nend",
"def init_default_config\n configuration.project_id ||= Debugger.default_project_id\n configuration.credentials ||= Debugger.default_credentials\n configuration.service_name ||= Debugger.default_service_name\n configuration.service_version ||= Debugger.default_service_version\n end",
"def defaults\n {\n client: nil,\n colour: nil,\n parent: nil,\n style: nil,\n value: '',\n }\n end",
"def recreate_default_config(test_to_run = 3)\n File.delete('config/prefs.yml') if File.exist?('config/prefs.yml')\n newPrefFile = File.new('config/prefs.yml', 'w+')\n newPrefFile.puts(\"#[1]- Operational\n#[2]- Functionnal\n#[3]- All\ntests_to_run: #{test_to_run}\")\n newPrefFile.close\nend",
"def merge_with_default(config, config_file, unset_nil:); end",
"def process_config(widget_name)\n system_config = Ruhoh::Utils.parse_yaml_file(@system_path, widget_name, \"config.yml\") || {}\n user_config = Ruhoh::Utils.parse_yaml_file(@path, widget_name, \"config.yml\") || {}\n config = Ruhoh::Utils.deep_merge(system_config, user_config)\n config['layout'] ||= widget_name\n config['stylesheet'] ||= widget_name\n config\n end",
"def merge_defaults(skin)\n DEFAULTS.each do |k,v|\n skin[k] = v if skin[k].nil?\n end\n end",
"def config\n @config ||= Config.create ConfigLoader.new(root, CONFIG_FILE).to_hash, options.merge_config\n end",
"def defaults\n {\n base_path: base_path,\n colour_mode: detect_colour_mode,\n compression: true,\n debug: false,\n drb: false,\n drb_host: nil,\n drb_port: nil,\n drb_height: 25,\n drb_width: 80,\n interactive: true,\n log: nil,\n log_only: [],\n once: false,\n renderers: [Vedeu::Renderers::Terminal.new],\n root: nil,\n stdin: nil,\n stdout: nil,\n stderr: nil,\n terminal_mode: :raw,\n }\n end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def config; end",
"def linter_config\n @linter_config ||= base_config.merge(engine_config.to_linter_config)\n end",
"def configuration_file_options\n file_path = @parsed_options.config_file || DEFAULT_CONFIG\n\n # if the file is 0 bytes, then this is illegal and needs\n # to be overwritten.\n if not File.exists?(file_path) or File.size(file_path) == 0 then\n determine_color_scheme\n FileUtils.mkdir_p(File.dirname(file_path))\n File.open(file_path,\"w\") do |f|\n YAML.dump(default_options.marshal_dump,f)\n end\n end\n YAML.load_file(file_path) || Hash.new\n end",
"def genPiledDefaultConf(klass = self.class())\n if(klass == WithConfParam) then\n return klass::DefaultConf.dup() ;\n else\n newConf = genPiledDefaultConf(klass.superclass()) ;\n if(klass.const_defined?(:DefaultConf)) \n newConf.update(klass::DefaultConf) ;\n end\n \n return newConf ;\n end\n end",
"def setup(settings = {})\n @config = defaults.merge(settings)\n end",
"def config(app)\n file = app.root.join('config/autoprefixer.yml')\n options = file.exist? ? YAML.load_file(file).symbolize_keys : { }\n options = { browsers: nil }.merge(options)\n [options.delete(:browsers), options]\n end",
"def reload\n colors = Config.colors\n\n foreground = Config.foreground\n background = Config.background\n\n Styles[:clear] = Qt::TextCharFormat.new { |fmt|\n fmt.foreground = Qt::Brush.new(foreground)\n fmt.background = Qt::Brush.new(background)\n\n fmt.font_weight = Qt::Font::Normal\n fmt.font_italic = false\n fmt.font_underline = false\n }\n\n Styles[:normal] = Qt::TextCharFormat.new { |fmt|\n fmt.foreground = Qt::Brush.new(foreground)\n fmt.background = Qt::Brush.new(background)\n\n fmt.font_weight = Qt::Font::Normal\n fmt.font_underline = false\n }\n\n Styles[:bold] = Qt::TextCharFormat.new { |fmt|\n fmt.font_weight = Qt::Font::Bold\n }\n\n Styles[:no_bold] = Qt::TextCharFormat.new { |fmt|\n fmt.font_weight = Qt::Font::Normal\n }\n\n Styles[:light] = Qt::TextCharFormat.new { |fmt|\n fmt.font_weight = Qt::Font::Light\n }\n\n Styles[:italic] = Qt::TextCharFormat.new { |fmt|\n fmt.font_italic = true\n }\n\n Styles[:no_italic] = Qt::TextCharFormat.new { |fmt|\n fmt.font_italic = false\n }\n\n Styles[:underline] = Qt::TextCharFormat.new { |fmt|\n fmt.font_underline = true\n }\n\n Styles[:color] = Array.new(256) do |i|\n Qt::TextCharFormat.new { |fmt|\n fmt.foreground = Qt::Brush.new(colors[i])\n }\n end\n\n Styles[:default_color] = Qt::TextCharFormat.new { |fmt|\n fmt.foreground = Qt::Brush.new(foreground)\n }\n\n Styles[:background] = Array.new(256) do |i|\n Qt::TextCharFormat.new { |fmt|\n fmt.background = Qt::Brush.new(colors[i])\n }\n end\n\n Styles[:default_background] = Qt::TextCharFormat.new { |fmt|\n fmt.background = Qt::Brush.new(background)\n }\n end",
"def load_default_config\n # Load the default\n path = File.join(::Lyricli.root, \"config\", @defaults_path)\n\n if File.exist?(path)\n file = File.new(path, \"r\")\n @config = MultiJson.decode(file.read)\n else\n @config = {}\n end\n end",
"def options\n original_options = super\n defaults = Thor::CoreExt::HashWithIndifferentAccess.new(\n {\n width: 72,\n count: 200,\n },\n )\n\n config_path = File.expand_path(ENV.fetch('AUGURY_CFG_PATH', '~/.augury.yml'))\n if File.file?(config_path)\n config_options = Thor::CoreExt::HashWithIndifferentAccess.new(YAML.load_file(config_path) || {})\n defaults = defaults.merge(config_options)\n end\n\n # Enforce implied options\n defaults[:links] = true if original_options[:remove_links] || defaults[:remove_links]\n\n Thor::CoreExt::HashWithIndifferentAccess.new(defaults.merge(original_options))\n end",
"def config(opts)\n if opts.reset\n Config.instance.reset\n else\n Config.instance.edit\n end\n end",
"def config_defaults(asset_host: nil, mode: ENV.fetch('RACK_ENV', 'development'), root: Dir.pwd)\n {\n 'asset_host' => option_from_env('asset_host') || asset_host,\n 'config_path' => option_from_env('config_path') || DEFAULT_CONFIG.fetch('config_path'),\n 'mode' => option_from_env('mode') || mode,\n 'root' => option_from_env('root') || root,\n }\n end",
"def config\n params = {}\n\n roots.each do |root|\n file = File.join(root, \"config/autoprefixer.yml\")\n\n next unless File.exist?(file)\n\n parsed = ::YAML.load_file(file)\n next unless parsed\n\n params = parsed\n\n break\n end\n\n params = params.symbolize_keys\n params[:env] ||= Rails.env.to_s\n params\n end",
"def default_configuration\n configuration[:_default] || {}\n end",
"def defaults\n Hash(@config[:defaults])\n end",
"def predefined_styles\r\n @predefined_styles ||=\r\n begin\r\n tmp = {}\r\n styles do |s|\r\n tmp = {\r\n bold: s.add_style(b: true, alignment: { vertical: :top }),\r\n date: s.add_style(format_code: 'mm/dd/yyyy', alignment: { vertical: :top }),\r\n float: s.add_style(format_code: '#,##0.00', alignment: { vertical: :top }),\r\n integer: s.add_style(format_code: '#,##0', alignment: { vertical: :top }),\r\n percent: s.add_style(num_fmt: 9, alignment: { vertical: :top }),\r\n currency: s.add_style(num_fmt: 7, alignment: { vertical: :top }),\r\n text: s.add_style(format_code: '@', alignment: { vertical: :top }),\r\n wrapped: s.add_style(alignment: { wrap_text: true, vertical: :top }),\r\n normal: s.add_style(alignment: { vertical: :top })\r\n }\r\n end\r\n tmp\r\n end\r\n end",
"def merge_configs\n # Update our original_config - if someone has created a knife command\n # instance directly, they are likely ot have set cmd.config values directly\n # as well, at which point our saved original config is no longer up to date.\n @original_config = config.dup\n # other code may have a handle to the config object, so use Hash#replace to deliberately\n # update-in-place.\n config.replace(config_file_defaults.merge(default_config).merge(config_file_settings).merge(config))\n end",
"def generate\n FileUtils.cp DEFAULT_CONFIG, File.join(@path, 'config/rails_best_practices.yml')\n end",
"def create_file_config\n template \"config/smart_editor.yml\", \"config/smart_editor.yml\"\n end",
"def config\n @config ||= {}\n end",
"def config\n @config ||= {}\n end",
"def default_configuration!\n # Overwriting Sinatra defaults\n set :app_file, caller_files.first || $0 # Assume app file is first caller\n set :environment, Padrino.env\n set :raise_errors, true if development?\n set :logging, false # !test?\n set :sessions, true\n set :public, Proc.new { Padrino.root('public', self.uri_root) }\n # Padrino specific\n set :uri_root, \"/\"\n set :reload, development?\n set :app_name, self.to_s.underscore.to_sym\n set :default_builder, 'StandardFormBuilder'\n set :flash, defined?(Rack::Flash)\n set :authentication, false\n # Padrino locale\n set :locale_path, Proc.new { Dir[File.join(self.root, \"/locale/**/*.{rb,yml}\")] }\n set :auto_locale, false\n # Plugin specific\n set :padrino_mailer, defined?(Padrino::Mailer)\n set :padrino_helpers, defined?(Padrino::Helpers)\n end",
"def initialize\n @config = config_from_file || empty_config\n end",
"def reload_config\n @config = Configuration.new(@editor.path_to_current_file)\n end",
"def config=(_arg0); end"
] | [
"0.6772796",
"0.6758644",
"0.6638874",
"0.65170556",
"0.65158147",
"0.6425024",
"0.6389434",
"0.6209163",
"0.6183277",
"0.6170434",
"0.6106677",
"0.6085679",
"0.60800856",
"0.60750633",
"0.60426366",
"0.60343635",
"0.6034086",
"0.60013926",
"0.59797233",
"0.5952553",
"0.5944396",
"0.5934191",
"0.5925779",
"0.59046733",
"0.5891947",
"0.58846766",
"0.5884658",
"0.58839816",
"0.5863238",
"0.58628005",
"0.58581287",
"0.5857867",
"0.58487827",
"0.5847684",
"0.5818723",
"0.5797379",
"0.57840127",
"0.57769",
"0.57693994",
"0.57532424",
"0.57521516",
"0.5747591",
"0.5741655",
"0.5741655",
"0.57182586",
"0.5707187",
"0.5707187",
"0.57050604",
"0.56904864",
"0.56893027",
"0.56893027",
"0.56846267",
"0.5676948",
"0.56739974",
"0.5672012",
"0.56659925",
"0.5662325",
"0.5658991",
"0.5654823",
"0.5647897",
"0.5647897",
"0.5647897",
"0.5647897",
"0.5647897",
"0.5647897",
"0.5647897",
"0.5647897",
"0.5647897",
"0.5647897",
"0.5647897",
"0.5647897",
"0.5647897",
"0.5647897",
"0.5647897",
"0.5647897",
"0.5647897",
"0.5647897",
"0.5644743",
"0.5638314",
"0.56382436",
"0.5635126",
"0.5613977",
"0.56114846",
"0.55941874",
"0.5591949",
"0.5590858",
"0.55899626",
"0.5589266",
"0.55870837",
"0.55851233",
"0.5583922",
"0.557601",
"0.55733055",
"0.55708635",
"0.55684507",
"0.55684507",
"0.5558252",
"0.55504113",
"0.55412614",
"0.5538273"
] | 0.7639467 | 0 |
a new color object | def color_new
return GT::Color.malloc
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @color = Color.new\n end",
"def dup\n Colorist::Color.from_rgb(@r,@g,@b)\n end",
"def color\n Color.new\n end",
"def initialize(color)\n @color = color\n end",
"def color=(c)\n @color = Color.new(c)\n end",
"def initialize(color=0x000000)\n string = \"%.6x\" % color\n @r = string[0..1].hex\n @g = string[2..3].hex\n @b = string[4..5].hex\n end",
"def color(color); end",
"def initialize(color)\n\t\t\tself.color = color\n\n\t\t\tif self.color.kind_of?(Array)\n\t\t\t\tself.l, self.a, self.b = self.color\n\t\t\telsif self.color.kind_of?(String)\n\t\t\t\tself.l, self.a, self.b = to_array\n\t\t\tend\n\t\t\t\n\t\t\tbegin\n\t\t\t\tif is_cielab? \n\t\t\t\t\tself.color = to_s\n\t\t\t\telse\n\t\t\t\t\traise ExceptionHandler::ColorFormatError, ErrorMessage.wrong_color_format\n\t\t\t\tend \n\t\t\trescue Exception => e\n\t\t\t\traise ExceptionHandler::ColorFormatError, ErrorMessage.wrong_color_format\n\t\t\tend\n\t\tend",
"def new_extended_color(*color)\n Sketchup::Color.new(*color).extend(AE::Color) # TODO: test this, changed from AE::Color\n end",
"def initialize(color) \n @color = color #instance variable\n end",
"def initialize(color = COLOR_CLEAR)\n @color = color\n end",
"def initialize(red, green, blue, alpha=255)\n set red, green, blue, alpha\n end",
"def initialize(*c)\n if !c[0] then @color = pick_color else @color = c[0] end\n end",
"def initialize(color)\n\t\t\tself.color = color\n\n\t\t\tif self.color.kind_of?(Array)\n\t\t\t\tself.h, self.s, self.l = self.color\n\t\t\telsif self.color.kind_of?(String)\n\t\t\t\tself.h, self.s, self.l = to_array\n\t\t\tend\n\t\t\t\n\t\t\tbegin\n\t\t\t\tif is_hsl? \n\t\t\t\t\tself.color = to_s\n\t\t\t\telse\n\t\t\t\t\traise ExceptionHandler::ColorFormatError, ErrorMessage.wrong_color_format\n\t\t\t\tend \n\t\t\trescue Exception => e\n\t\t\t\traise ExceptionHandler::ColorFormatError, ErrorMessage.wrong_color_format\n\t\t\tend\n\t\tend",
"def initialize(x, y, c=\"red\")\n\t\tsuper(x, y)\n\t\t@color = c\n\tend",
"def <<(color)\n r = [1.0, color.red * color.alpha + self.red].min\n g = [1.0, color.green * color.alpha + self.green].min\n b = [1.0, color.blue * color.alpha + self.blue].min\n a = self.alpha\n UIColor.colorWithRed(r, green:g, blue:b, alpha:a)\n end",
"def initialize(color_or_red=nil,green=nil,blue=nil)\n @color=color_or_red\n @color=[color_or_red.to_f,green.to_f,blue.to_f] if color_or_red.is_a? Numeric\n @color=DEFAULT_RGB.merge(color_or_red) if color_or_red.is_a? Hash\n \n end",
"def initialize(name, color) \n @name = name \n @color = color \n end",
"def initialize color, position\n @color = color\n @position = position\n end",
"def initialize(color, position)\n self.color = color\n self.position = position\n end",
"def initialize(red, green, blue, alpha = 1.0); end",
"def initialize(number, color)\n @number = number\n @color = color\n end",
"def initialize(pos, color)\n if color == 0\n @color = \"B\"\n else\n @color = \"W\"\n end\n @pos = pos\n end",
"def initialize(name, color) \r\n @name = name \r\n @color = color \r\n end",
"def mk_color(offset)\n COLORS[offset]\n end",
"def initialize color, size\n @color = color\n @size = size\n end",
"def set(*args)\n val = Color.parse(*args)\n unless val.nil?\n self.r = val.r\n self.g = val.g\n self.b = val.b\n self.a = val.a\n end\n self\n end",
"def rgb_color; end",
"def +(other_color)\n other_color = Colorist::Color.from(other_color)\n color = self.dup\n color.r += other_color.r\n color.g += other_color.g\n color.b += other_color.b\n color\n end",
"def initialize(name, color)\n @name = name\n @color = color\n end",
"def initialize(colour) #position, colour)\n #@position = position\n @colour = colour\n red = Pointer.new(:float)\n green = Pointer.new(:float)\n blue = Pointer.new(:float)\n alpha = Pointer.new(:float)\n colour.getRed(red, green: green, blue: blue, alpha: alpha)\n @red = red[0]\n @green = green[0]\n @blue = blue[0]\n end",
"def initialize\r\n\t\t@color =\"platinum\"\r\n\tend",
"def add_color\n if !color\n self.color = %w(\n #000000 #0000FF #00FF00 #FF0000 #FFFF00 #9900CC\n #CC0066 #00FFFF #FF00FF #C0C0C0 #00008B #FFD700\n #FFA500 #FF1493 #FF00FF #F0FFFF #EE82EE #D2691E\n #C0C0C0 #A52A2A #9ACD32 #9400D3 #8B008B #8B0000\n #87CEEB #808080 #800080 #008B8B #006400\n ).sample\n end\n end",
"def initialize(r, g, b, a = ALPHA_OPAQUE)\n r = self.class.normalize(r, RGB_MAX, :red)\n g = self.class.normalize(g, RGB_MAX, :green)\n b = self.class.normalize(b, RGB_MAX, :blue)\n a = self.class.normalize(a, ALPHA_MAX, :alpha)\n\n init_with_rgba(self.class.pack(r, g, b, a))\n end",
"def initialize(color={:cyan=> 1 ,:magenta => 0, :yellow => 0, :black => 0})\n @color=color\n end",
"def r; self.color.r end",
"def initialize(color)#recibe el color de brown\n p super# trae el comportamiento de la superclase con los valores de name\n p @color = color #el valor de colo lo declaramos como variable de instancia\n end",
"def +(other, a=255)\n r = [@red + other.red, 255].min\n g = [@green + other.green, 255].min\n b = [@blue + other.blue, 255].min\n Color.new(r, g, b, a)\n end",
"def new_rgba(r, g, b, a)\n self << Pruim::Color.rgba(r, g, b, a)\n return self.size - 1\n end",
"def color\n filter << 'Color:Color'\n self\n end",
"def back_color2\n Color.new(0, 0, 0, 0)\n end",
"def back_color2\n Color.new(0, 0, 0, 0)\n end",
"def initialize(r,g,b,a = \"FFFF\", name = nil)\n @red = r.length == 2 ? r : r[0..1]\n @green = g.length == 2 ? g : g[0..1]\n @blue = b.length == 2 ? b : b[0..1]\n @alpha = a.length == 2 ? a : a[0..1]\n @rgba = [@red,@green,@blue,@alpha]\n @xyz = rgb_to_xyz\n @lab = xyz_to_lab\n @name = name\n end",
"def initialize(color:, **opts)\n super(**opts)\n @color = color\n end",
"def back_color1\n Color.new(0, 0, 0, 192)\n end",
"def back_color1\n Color.new(0, 0, 0, 192)\n end",
"def color(*args)\n @instructions << Instruction.new(:color, args)\n self\n end",
"def normal_color\n #return Color.new(255,255,255)\n end",
"def colour\n @colour ||= Colour.new(attributes[:colour])\n end",
"def initialize(r,g,b,a)\n @r=r\n @b=b\n @g=g\n @a=a\n @opacity=a\n @color= @a > 0 ? \"rgb(#{r.to_i},#{g.to_i},#{b.to_i})\" : \"none\"\n end",
"def initialize(color, display)\n @color = color\n @display = display\n end",
"def +( other )\n return Color[ self.r + other.r,\n self.g + other.g,\n self.b + other.b,\n self.a + other.a ]\n end",
"def color; end",
"def color; end",
"def color; end",
"def initialize(color, name, type)\n @color = color\n @name = name\n @type = type\n end",
"def color=(new_color)\n\t\t@color = new_color\n\tend",
"def a\n\t\t\tColor.a(@color)\n\t\tend",
"def initialize(x,y,c=\"clear\")\n super(x,y) # keyword super calls same method in superclass\n @color = c\n end",
"def recolor(color)\n @color = color\n self\n end",
"def -(other_color)\n other_color = Colorist::Color.from(other_color)\n color = self.dup\n color.r -= other_color.r\n color.g -= other_color.g\n color.b -= other_color.b\n color\n end",
"def rgb_color(red, green, blue, alpha = nil)\n attrs = {:red => red, :green => green, :blue => blue}\n attrs[:alpha] = alpha if alpha\n Color.new(attrs)\n end",
"def initialize(color, type, position = Coordinates.origin, height = 1)\n @color = color\n @type = type\n @position = position\n @height = height\n end",
"def rgb(red, green, blue, alpha = Shoes::Color::OPAQUE)\n Shoes::Color.new(red, green, blue, alpha)\n end",
"def rgb(red, green, blue, alpha = Shoes::Color::OPAQUE)\n Shoes::Color.new(red, green, blue, alpha)\n end",
"def lbColor _obj, _args\n \"_obj lbColor _args;\" \n end",
"def from_rgb(red, green, blue)\n Inker.color(\"rgb(#{red}, #{green}, #{blue})\")\n end",
"def initialize(color, make)\n @color = color\n @make = make\n end",
"def spray_paint(new_color)\n self.color = new_color\n end",
"def back_color2\n Color.new(0, 0, 0, 0)\n end",
"def initialize (x, y, char, color)\n @x = x\n @y = y\n @char = char\n @color = color\n end",
"def binary\n r, g, b, a = self.to_a\n sum = r + g + b\n return (sum < 382)? self.new_extended_color([0,0,0,a]) : self.new_extended_color([255,255,255,a])\n end",
"def color=(new_color) #<---- = sign means same as variable. means assignment.\n # writer method - assigns new value to that @instance variable\n @color = new_color\n end",
"def generate_random_color\n gen = ColorGenerator.new saturation: COLOR_SATURATION,\n lightness: COLOR_LIGHTNESS\n self.color = \"##{gen.create_hex}\"\n self\n end",
"def get_color\n @color\n end",
"def from_hsl(*color)\n h, s, l, a = *( (color[0].is_a?(Sketchup::Color))? color[0].to_a : color.to_a.flatten )\n s /= 100.0\n l /= 100.0\n chroma = (1 - (2*l - 1).abs) * s\n m = l - 0.5*chroma\n h1 = (h%360)/60\n x = chroma * (1 - (h1.divmod(2)[1]-1).abs)\n rgb1 = case\n when (0..1) === h1 then [chroma, x, 0]\n when (1..2) === h1 then [x, chroma, 0]\n when (2..3) === h1 then [0, chroma, x]\n when (3..4) === h1 then [0, x, chroma]\n when (4..5) === h1 then [x, 0, chroma]\n else [chroma, 0, x] # when (5..6) === h1\n end\n r, g, b = *(rgb1.collect{|c| (255*(c + m)).to_i})\n return self.new_extended_color([r, g, b, a||255])\n end",
"def setcolorrep(*)\n super\n end",
"def rgb_color\n [self.color_red, self.color_green, self.color_blue]\n end",
"def register_color name, r, g, b, a = 255\n color[name] = screen.format.map_rgba r, g, b, a\n end",
"def initialize(make, color)\n\t\t@make = make #instance variables @make. They are accesible throught the class and your objects\n\t\t@color = color\n\t\tput self.color\n\tend",
"def initialize(color)\n\t\t@color = color\n\t\t@pieces = []\n\tend",
"def r\n\t\t\tColor.r(@color)\n\t\tend",
"def fill_color(color)\n end",
"def color=(value)\n @color = value\n end",
"def color=(value)\n @color = value\n end",
"def color(*values); end",
"def color(*values); end",
"def color\n @color ||= COLORS[label.length%COLORS.length].to_sym\n end",
"def initialize(r, g, b, a = 255)\n @r = r\n @g = g\n @b = b\n @a = a\n end",
"def initialize (x_coordinate,y_coordinate,color)\n\t\t@x_coordinate=x_coordinate\n\t\t@y_coordinate=y_coordinate\n\t\t@color=color\n\tend",
"def back_color1\n Color.new(0, 0, 0, 192)\n end",
"def lerp( target_color, coefficient )\n new_color = Brewfish::Color.new\n\n new_color.red = ( self.red + ( ( target_color.red - self.red ) * coefficient ) )\n new_color.green = ( self.green + ( ( target_color.green - self.green ) * coefficient ) )\n new_color.blue = ( self.blue + ( ( target_color.blue - self.blue ) * coefficient ) )\n new_color.alpha = ( self.alpha + ( ( target_color.alpha - self.alpha ) * coefficient ) )\n\n return new_color\n end",
"def initialize(position, color, value= \"B\")\n @position = position\n @color = color\n @value = value\n end",
"def normal_color\n return Color.new(255, 255, 255)\n end",
"def color(options)\n set RGhost::Color.create(options)\n end",
"def initialize(color,opacity)\n @color=color\n @opacity=opacity\n end",
"def initialize(color = \"white\", name = \"n\")\n @color = COLORS[color]\n @name = name\n @selected = false\n end",
"def rgb\n self\n end",
"def hsla_color; end"
] | [
"0.8007219",
"0.78093153",
"0.7280795",
"0.71924376",
"0.7184077",
"0.7170981",
"0.70304453",
"0.7011994",
"0.70032996",
"0.698195",
"0.69520444",
"0.69393486",
"0.69140613",
"0.6905236",
"0.68898904",
"0.68514836",
"0.6843216",
"0.6811877",
"0.6809771",
"0.67883414",
"0.67871344",
"0.67790675",
"0.67601204",
"0.6758032",
"0.67190546",
"0.6716883",
"0.6677618",
"0.66773254",
"0.66702443",
"0.66358703",
"0.65972793",
"0.6588731",
"0.65872204",
"0.65798414",
"0.65677595",
"0.65441597",
"0.65352666",
"0.6519265",
"0.65151286",
"0.6497957",
"0.64943",
"0.64943",
"0.6492043",
"0.6486394",
"0.64754474",
"0.64754474",
"0.64466554",
"0.6438507",
"0.64281124",
"0.64229095",
"0.6421095",
"0.64060247",
"0.64004976",
"0.64004976",
"0.64004976",
"0.6383968",
"0.6379519",
"0.6374685",
"0.637316",
"0.63725805",
"0.636899",
"0.6318833",
"0.63017124",
"0.62968224",
"0.62968224",
"0.62884456",
"0.6288009",
"0.6287662",
"0.62864155",
"0.6270567",
"0.6269478",
"0.6261104",
"0.62562567",
"0.62541634",
"0.62311155",
"0.6222101",
"0.62089074",
"0.6204938",
"0.6183504",
"0.6181537",
"0.6175313",
"0.61748606",
"0.61700666",
"0.616897",
"0.61682564",
"0.61676747",
"0.61676747",
"0.61668235",
"0.616021",
"0.61393696",
"0.61380005",
"0.61373806",
"0.61314535",
"0.6125067",
"0.61247826",
"0.61246854",
"0.6112237",
"0.60911685",
"0.6088096"
] | 0.823423 | 1 |
Serialize timeline entry to a hash | def to_hash
# fields
result = {
'rcpt' => @timeline.recipient_id,
'routing' => @routing_kind,
'activity' => @activity.to_hash,
}
result['meta'] = @meta.stringify_keys unless @meta.blank?
result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_hash\n hsh = {\n id: id,\n status: status.to_sym,\n connect: running? ? connect.to_h : nil,\n time: info.wallclock_time.to_i / 60 # only update every minute\n }\n Digest::SHA1.hexdigest(hsh.to_json)\n end",
"def hash\n @data.dup.concat([@ts]).hash\n end",
"def to_h\n { data: @data, timestamp: @timestamp }.freeze\n end",
"def hash\n [duration, rrule, start].hash\n end",
"def serialize\n JSON.dump(@hash)\n end",
"def entry_as_json(entry)\n data = {}\n set_attribute(data, @time_key, entry.time) unless @time_key.nil?\n set_attribute(data, @severity_key, entry.severity_label) unless @severity_key.nil?\n set_attribute(data, @progname_key, entry.progname) unless @progname_key.nil?\n set_attribute(data, @pid_key, entry.pid) unless @pid_key.nil?\n set_attribute(data, @message_key, entry.message) unless @message_key.nil?\n\n tags = entry.tags\n if @custom_keys.size > 0\n tags = (tags.nil? ? {} : tags.dup)\n @custom_keys.each do |name, key|\n set_attribute(data, key, tags.delete(name.to_s))\n end\n end\n\n unless @tags_key.nil?\n tags ||= {}\n set_attribute(data, @tags_key, tags)\n end\n\n data = @formatter.format(data) if @formatter\n data\n end",
"def hash\n [from, timezone, to].hash\n end",
"def get_user_timeline_as_hash( id=nil, login=@login, password=@password )\n json_data = get_user_timeline( login, password, id, 'json', count )\n hash_data = JSON.parse( json_data )\n timeline = Array.new\n i = 0\n\n #debugger\n hash_data.each do |data|\n timeline[i] = Hash.new\n timeline[i][:name] = data['user']['name']\n timeline[i][:icon_url] = data['user']['profile_image_url']\n timeline[i][:text] = data['text']\n i += 1\n end\n timeline\n end",
"def makeEntry(hash, e)\n hash[e.id] = {\n name: e.public_name,\n createTimestamp: e.createTimestamp,\n }\n if e.banned?\n hash[e.id][:noLogin] = true\n else\n # Don't publish urls for banned logins\n unless e.urls.empty?\n # need to sort to avoid random changes which seem to occur for urls\n hash[e.id][:urls] = e.urls.sort\n end\n # only add entry if there is a fingerprint\n unless e.pgp_key_fingerprints.empty?\n # need to sort to avoid random changes which seem to occur for fingerprints\n hash[e.id][:key_fingerprints] = e.pgp_key_fingerprints.sort\n end\n end\nend",
"def hash\n [@offset, @previous_offset, @timestamp_value].hash\n end",
"def to_h\n return {\n value: @value,\n timestamp: @timestamp,\n timestamp_nsec: @timestamp_nsec,\n timestamp_tiebreaker: @timestamp_tiebreaker,\n tiebreaker: @tiebreaker,\n }\n end",
"def to_hash\n {\n :time => @time,\n :event => @event\n }\n end",
"def hash\n [day, from, to].hash\n end",
"def to_h\n {\n event: event,\n subject: subject,\n mentions: mentions,\n tags: tags,\n time: time\n }\n end",
"def serializable_hash\n {to: to, text: text}.tap {|hash| hash[:from] = from if from}\n end",
"def to_hash() end",
"def serialize\n data = manifest.dup\n data[:run_data] = {\n timestamp: Time.now.to_s\n }\n Yajl::Encoder.encode(data, nil, pretty: true)\n end",
"def to_hash\n\t\tlog_hash = {\n\t\t\t'date'\t\t=> @date,\n\t\t\t'duration' \t=> @duration,\n\t\t\t'contents' \t=> @contents,\n\t\t\t'notes' => {\n\t\t\t\t'q1' => @q1,\n\t\t\t\t'q2' => @q2,\n\t\t\t\t'q3' => @q3\n\t\t\t}\n\t\t}\n\t\treturn log_hash\n\tend",
"def hash\n @events.hash\n end",
"def to_h\n {\n data: data,\n nonce: nonce,\n time: time,\n hash: hash,\n index: index,\n prev_hash: prev_hash\n }\n end",
"def to_h\n {timestamp: @timestamp.to_i, changes: @records.map(&:to_h)}\n end",
"def to_h\n @entry.each_with_object({}) { |(k, v), h| h[k] = v.dup }\n end",
"def hash\n [id, next_send, rrule, session, last_sent, contact_name, parameters, type, summary, text_parameters, first_occurrence, last_occurrence, recipients_count, timezone, completed, avatar, created_at].hash\n end",
"def to_h\n {\n map_id: @map_id,\n round: @round,\n link: @link,\n start_at: @start_at,\n end_at: @end_at,\n created_at: @created_at,\n updated_at: @updated_at,\n total_time: @total_time\n }\n end",
"def to_hash\n if not @goal.nil? and @goal.user.enforce_timezone?\n @timestamp = @goal.user.convert_to_timezone @timestamp\n end\n \n {\n \"timestamp\" => @timestamp.strftime('%s'),\n \"value\" => @value || 0,\n \"comment\" => @comment || \"\",\n }\n end",
"def to_hash\n entry_hash = {}\n entry_hash['codes'] = codes\n unless values.empty?\n entry_hash['value'] = values\n end\n \n if is_date_range?\n entry_hash['start_time'] = start_time\n entry_hash['end_time'] = end_time\n else\n entry_hash['time'] = as_point_in_time\n end\n \n if status\n entry_hash['status'] = status\n end\n \n if description\n entry_hash['description'] = description\n end\n\n if specifics\n entry_hash['specifics'] = specifics\n end\n \n entry_hash\n end",
"def hash\n [from_ts, group_by, groups, monitors, overall, series, thresholds, to_ts, type, type_id].hash\n end",
"def hash\n [calendar_name, description, name, next_fire_time, previous_fire_time, state].hash\n end",
"def hash\n [event_count, hour, index_id, index_name, org_name, public_id, retention].hash\n end",
"def hash\n to_s.hash\n end",
"def to_hash; end",
"def to_hash; end",
"def to_hash; end",
"def to_hash; end",
"def to_hash; end",
"def to_hash; end",
"def to_redis\r\n\r\n # Hash representation\r\n representation = {\r\n finish_time: finish_time,\r\n description: description\r\n }\r\n\r\n representation.to_json.to_s\r\n\r\n end",
"def write_entry(key, entry, **options)\n write_serialized_entry(key, serialize_entry(entry, **options), **options)\n end",
"def to_h\n @hash\n end",
"def to_h\n @hash\n end",
"def to_h\n # use a flat hash here so we can't errors from intermediate values being nil\n { node: node,\n success: success?,\n start_time: start_time,\n end_time: end_time,\n elapsed_time: elapsed_time,\n all_resources: all_resources,\n updated_resources: updated_resources,\n exception: formatted_exception,\n backtrace: backtrace,\n run_id: run_id }\n end",
"def to_h\n Hash[all_entries]\n end",
"def hash\n [status, rating, title, url, publisher_date, business_id, comments, content, date, author_name, author_email, location_id, last_yext_update_time, publisher_id, id].hash\n end",
"def entry2hash(entry)\n hash = Hash.new('')\n entry.each_line do |line|\n tag = tag_get(line)\n next if tag == 'XX'\n tag = 'R' if tag =~ /^R./\t# Reference lines\n hash[tag] += line\n end\n return hash\n end",
"def save\n raise \"Unhashed entry during save\" unless @hash\n raise \"Entry without mime type during save\" unless @mimetype\n @data[:mimetype] = @mimetype\n @data[:ctime] = @ctime.utc.to_i\n @data[:mtime] = @mtime.utc.to_i\n @data[:name] = @name\n @data[:size] = @size\n @data[:tags] = @tags\n @data[:locations] ||= Array.new\n unless @data[:locations].include? @location\n @data[:locations] << @location\n end\n if ::Ordnung.database.read @hash\n ::Ordnung.database.update @hash, @data\n else\n ::Ordnung.database.create @hash, @data\n end\n @hash\n end",
"def hash\n [start_offset_seconds, end_offset_seconds, scheduled_activity_code_id, scheduled_activity_category, actual_activity_category, system_presence, routing_status, impact, secondary_presence_lookup_id].hash\n end",
"def to_h; end",
"def to_h; end",
"def to_h; end",
"def to_h; end",
"def hash\n to_s.hash\n end",
"def hash\n to_s.hash\n end",
"def to_h\r\n {\r\n \"name\": @body[:_key],\r\n \"id\": @body[:_id],\r\n \"rev\": @body[:_rev],\r\n \"from\": @body[:_from],\r\n \"to\": @body[:_to],\r\n \"body\": @body,\r\n \"cache_name\": @cache_name,\r\n \"collection\": @collection.name,\r\n \"graph\": @graph&.name\r\n }.delete_if{|k,v| v.nil?}\r\n end",
"def to_hash\n self.hash.merge!(:errors => self.errors)\n self.hash.merge!(:valid? => self.valid)\n self.hash\n # binding.pry\n Stamps.format.to_s.downcase == 'hashie' ? Hashie::Trash.new(@hash) : self.hash\n end",
"def hash\r\n return to_s.hash\r\n end",
"def to_hash\n @hash\n end",
"def to_hash\n @hash\n end",
"def to_hash\n @hash\n end",
"def hash\n [description, routing_number, account_number, account_type, signatory, metadata, id, signature_url, bank_name, verified, date_created, date_modified, deleted, object].hash\n end",
"def to_h\n h = {\n :rev => rev,\n :log => message,\n :author => author,\n :timestamp => timestamp,\n :has_children? => has_children?,\n }\n h[:changed_paths] = changed_paths if changed_paths\n h\n end",
"def hash\n [schedule_id, retention_period, schedule_interval_type, repeat_interval, start_date, start_time, end_time, days_of_week, day_of_month, weekday_of_month].hash\n end",
"def to_h\n {\n level: @level,\n entries: @entries.map(&:to_h)\n }\n end",
"def hash\n [name, value, timestamp, source_id, source_label, source, selected_by_user, selected_by_user_timestamp, source_vid, source_metadata, request_id, updated_by_user_id, persistence_timestamp, use_timestamp_as_persistence_timestamp].hash\n end",
"def serialize\n Serializer.serialize(PATH, @history)\n end",
"def entry2hash(entry)\n hash = Hash.new('')\n\n fields = toptag2array(entry)\n\n fields.each do |field|\n tag = tag_get(field)\n hash[tag] += field\n end\n return hash\n end",
"def hash\n [activity_id, activity_type_code, subject, actual_start, actual_end, state_code, status_code, scheduled_start, scheduled_end, owner_id, description, regarding_object_id, regarding_object_id_name, regarding_object_logical_name, owner_full_name, contact_id, contact_full_name, call_reason_status_name, decline_reason_status_name, call_result_status_name, party_id, activity_party_id, party_id_name, party_object_type_code, is_phone_call, next_call_date, campaign_name, cust_name, product_name, owner_avatar].hash\n end",
"def hash\n return to_s.hash\n end",
"def hash\n [id, task_id, name, workflow_type, workflow_action, source_type, destination_type, status, log_time, job_started, job_finished, to_process_size, processed_size, to_process_files, processed_files, finalized_files, estimation_time, bandwidth].hash\n end",
"def to_hash\n h = super\n h['uid'] = @uid\n h\n end",
"def to_hash\n @_hash_\n end",
"def to_hash\n r_hash = {}\n r_hash['meta'] = self.meta\n r_hash['payload'] = {\n 'id' => self.id,\n 'asset' => self.asset,\n 'time' => self.time,\n 'bs' => self.bs,\n 'type' => self.type,\n 'reason' => self.reason\n }\n r_hash.delete_if { |k, v| v.nil? }\n end",
"def as_hash\n as_json.with_indifferent_access.tap do |rec|\n rec.transform_values! do |value|\n if value.is_a?(Time) || value.is_a?(DateTime)\n ymdhms = value.utc.strftime(\"%Y-%m-%d %H:%M:%S\")\n subseconds = value.utc.strftime(\".%6N\").to_f.to_s.sub(/^0\\./, \"\")\n \"#{ymdhms}.#{subseconds}\"\n else\n value.as_json\n end\n end\n end\n end",
"def output_hash; end",
"def hash\n [mti, stan, transmission_time, acquiring_institution_id, network_reference_id, forwarding_institution_id, transaction_token].hash\n end",
"def to_h\n @_hash.dup\n end",
"def serialize(hash)\n hash.inspect\n end",
"def to_h\n {\n name: @name,\n start: @start_time,\n end: @end_time,\n duration: duration\n }\n end",
"def serializable_hash\n hash = {}\n each_pair { |key, value| hash[key] = value }\n hash\n end",
"def hash\n [id, sender, receiver, text, status, contact_id, session_id, message_time, avatar, deleted, charset, charset_label, first_name, last_name, country, phone, price, parts_count, from_email, from_number].hash\n end",
"def to_h\n @hash.dup\n end",
"def hash\n [class_id, object_type, msg_type, path, stream].hash\n end",
"def calculate_hash!\n entry_hash = to_hash\n entry_hash['description']=nil\n @hash = entry_hash.hash\n end",
"def serialize\n JSON.generate(to_h)\n end",
"def to_h\n @hash.dup\n end",
"def hash\n [class_id, object_type, action, cache_state, cached_time, last_access_time, md5sum, original_sha512sum, path, registered_workflows, used_count, file, network_element].hash\n end",
"def hash\n data.hash\n end",
"def to_h\n @raw.reduce(Hash.new(0)) do |acc, elem|\n acc.merge(elem.date => elem.score)\n end\n end",
"def hash\n [created, changed_by, updated, id, domain, action, organization_id, webhook_id, entity_id, destination_url, format, ack_enabled, entity, changes, last_send_attempt, next_send_attempt, final_send_attempt, total_send_attempts, state, acked].hash\n end",
"def hash\n to_a.hash\n end",
"def to_hash\n data.to_hash\n end",
"def to_hash\n data.to_hash\n end",
"def to_h\n Hash[ self ]\n end",
"def save_hashes_for_write\n \n end",
"def hash\n self.to_f.hash\n end",
"def to_mash; end",
"def to_h\n array = []\n array << @header.to_h if @header\n @entries.each do |entry|\n array << entry.to_h\n end\n array\n end",
"def redisFormat(tag,time,record)\n redis_entry = Hash.new\n redis_entry.store(RedislistOutput::TagAttributeLabel,tag.to_s)\n redis_entry.store(RedislistOutput::TimeAttributeLabel,time.to_i)\n redis_entry.store(RedislistOutput::RecordAttributeLabel,record.to_s)\n redis_out = JSON.generate(redis_entry)\n return redis_out\n end",
"def to_h\n {\n :name => @name,\n :type => @type,\n :metaData => @meta_data,\n :timestamp => @timestamp.iso8601(3)\n }\n end",
"def to_hash\n @trace\n end",
"def will_store_timeline_entry(timeline_entry)\n if timeline_entry.activity[:foo] == 'bar'\n timeline_entry.activity[:foo] = 'tag'\n end\n end"
] | [
"0.6373876",
"0.62850106",
"0.6173977",
"0.61097634",
"0.6107942",
"0.60595894",
"0.6034601",
"0.6006015",
"0.60057294",
"0.5999017",
"0.5990471",
"0.5976088",
"0.59152186",
"0.5902666",
"0.5889972",
"0.58891016",
"0.58292323",
"0.5819369",
"0.58082813",
"0.57998794",
"0.5797548",
"0.5796217",
"0.5788006",
"0.5779185",
"0.5778856",
"0.57602483",
"0.57532984",
"0.57299185",
"0.5701861",
"0.5701723",
"0.56979305",
"0.56979305",
"0.56979305",
"0.56979305",
"0.56979305",
"0.56979305",
"0.56941783",
"0.5691656",
"0.568948",
"0.568948",
"0.5684618",
"0.5684313",
"0.5674411",
"0.5670935",
"0.56649476",
"0.56488526",
"0.5636614",
"0.5636614",
"0.5636614",
"0.5636614",
"0.56296736",
"0.56296736",
"0.56204623",
"0.5617026",
"0.5601158",
"0.558022",
"0.558022",
"0.55741006",
"0.555987",
"0.55536836",
"0.5547522",
"0.5544154",
"0.55352956",
"0.5527282",
"0.55266947",
"0.5514469",
"0.5514106",
"0.5511584",
"0.55105966",
"0.5502935",
"0.5500708",
"0.5495079",
"0.5493087",
"0.54811263",
"0.54782397",
"0.54752105",
"0.54748386",
"0.54734385",
"0.5471793",
"0.5470061",
"0.5455946",
"0.54488903",
"0.54443073",
"0.54442364",
"0.544405",
"0.5441032",
"0.5440387",
"0.54402506",
"0.5432901",
"0.5430416",
"0.5430416",
"0.5416111",
"0.54154646",
"0.54128915",
"0.54082745",
"0.5408229",
"0.540672",
"0.5405484",
"0.53887254",
"0.5387587"
] | 0.65883416 | 0 |
Get the corresponding timeline route | def timeline_route
@timeline_route ||= begin
result = @timeline.route_for_kind(Activr::Timeline::Route.kind_for_routing_and_activity(@routing_kind, @activity.kind))
raise "Failed to find a route for #{@routing_kind} / #{@activity.kind}: #{self.inspect}" if result.nil?
result
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def route\n @route\n end",
"def route_for(**url_details)\n @routes.select { |rt| url_details <= rt.url_details }.first\n end",
"def get_route\n data = {\n visits: visits,\n fleet: fleet\n }\n\n data[:options] = options if options\n result = Util.send_request(\"POST\", \"vrp\", Routific.token, data)\n RoutificApi::Route.parse(result)\n end",
"def route\n return @children['route'][:value]\n end",
"def came_from_route\n @came_from_route\n end",
"def getDirectRoute(startStation, endStation)\n routesFrom = getRoutesFrom(startStation)\n \n routesFrom.each do |route|\n if (route.endStation == endStation)\n return route\n end\n end\n \n return nil\n end",
"def route\n @route ||= self.route_id ? Route.find_by_id(self.route_id) : nil\n end",
"def route\n @route ||= self.route_id ? Route.find_by_id(self.route_id) : nil\n end",
"def route\n @route ||= Role.available_routes.find {|r| r.conditions[:path_info].to_s == path_info && r.conditions[:request_method].to_s == request_method}\n end",
"def getRoutesTo(station)\n routeList = @toNodeMap[station]\n \n return routeList == nil ? [] : routeList\n end",
"def first\n @routes[0]\n end",
"def extract_route\n Xhive::Router::Route.find(request.path)\n end",
"def find_timeline match_id\n DynamicModel.new perform_request api_url \"timelines/by-match/#{match_id}\"\n end",
"def timeline\n request('timeline')\n end",
"def tfl_journey_planner\n Tube.display_lines\n get_start_line\n Station.list_all_stations(@start_line)\n get_start_station\n Tube.display_lines\n get_end_line\n get_end_station\n print_stations_en_route\n end",
"def find_optimal_route(origin:, destination:, arrival_deadline:)\n params = { origin: origin, destination: destination, deadline: arrival_deadline }\n to_transit_path(client.get(API_PATH, params))\n end",
"def get_routes from, to, options = {}\n options[:start_type] = check_point_type(from) || options[:start_type]\n options[:target_type] = check_point_type(to) || options[:target_type]\n # default options\n options = {\n :time => Time.now, \n :depth => 0, \n :include_coords => true, \n :limit => 2,\n :time_relation => :depature,\n :identify_part_prices => :none }.merge(options)\n\n options[:time] = options[:time].in_time_zone(\"Berlin\") #+ 10.minutes # Ansonsten liegt die erste Verbindung in der Vergangenheit\n page = @agent.get @@options[:url_route]\n \n result = submit_form page.forms.first, from, to, options\t\t\n routes = []\n links = result.links_with(:href => /details=opened!/).select { |l| l.to_s.size > 0} # only select connection links, no warning links\n links.reverse! if options[:time_relation] == :arrival # respect :time_relation for route processing\n \n link_threads = Array.new\n links.each_index do |idx|\n link_threads[idx] = Thread.new {\n # maybe we are too fast in requesting :-)\n (1..5).each do |i|\n page = links[idx].click \n break unless page.title.match(/Fehler/)\n # puts \"link.click error: %i\" % i\n sleep(1)\n end\n Thread.current[:route] = Route.new(page, options)\n }\n break if idx == options[:limit]\n end\n\n link_threads.each { |t| t.abort_on_exception = true}\n routes = link_threads.map { |t| t.join; t[:route] }\n\n # Keine Station gefunden also suchen wir nach der nächstbesten Adresse/Station\n if links.count == 0 && options[:depth] == 0\n if options[:start_type] == :address\n from = find_address(from, options)\n options[:start_type] = from.station_type\n from = from.name\n elsif options[:start_type] == :station\n from = find_station(from, options)\n options[:start_type] = from.station_type\n from = from.name\n end\n \n if options[:target_type] == :address\n to = find_address(to, options)\n options[:target_type] = to.station_type\n to = to.name\n elsif options[:target_type] == :station\n to = find_station(to, options)\n options[:target_type] = to.station_type\n to = to.name\n end\n \n return get_routes from, to, options.merge(:depth => options[:depth]+1)\n end\n \n raise \"no_route\" if routes.count == 0 || links.count == 0\t\t\t\n\n # attach price information for each routepart if necessary\n identify_part_prices(routes, options) unless options[:identify_part_prices] == :none\n \n return routes\n end",
"def getRoutesFrom(station)\n routeList = @fromNodeMap[station]\n \n return routeList == nil ? [] : routeList\n end",
"def route_by_id(route_id)\n get \"/gtfs/routes/#{route_id}\"\n end",
"def flight_route(origin, destination, date=nil, params={})\n args = [origin, 'departures', destination, format(date)].compact.join('/')\n perform_get(\"/airports/#{args}.xml\", params)\n end",
"def route_for_current_step\n steps_routes_mapping[state] || steps_routes_mapping[:pending]\n end",
"def route_name; end",
"def route_name; end",
"def route_by_stop_id(stop_id)\n get \"/gtfs/routes/stopid/#{stop_id}\"\n end",
"def set_route\n #zeroday is probably the day you seeded your DB\n zeroday = DateTime.parse('2015-12-02')\n params[:end] ||= params[:start].to_i + 1\n\n if params[:end].to_i < params[:start].to_i\n params[:end] = params[:start].to_i + 1\n end\n\n @whichRoute = params[:id]\n @startHour = params[:start].to_i\n @endHour = params[:end].to_i\n\n # @whichRoute = 10867\n # @startHour = 12\n # @endHour = 13\n\n allStops = StopTime.includes({trip: :route}, :stop).where( arrival_time: (zeroday.change( { hour: @startHour } )..zeroday.change( { hour: @endHour } )) )\n myRoutesTrips = Array.new\n #only look at trips that happen on the weekdays (serivce_id == 1)\n Trip.where(route_id: @whichRoute, service_id: 1).each do |trip|\n myRoutesTrips.push(trip.id)\n end\n\n @stoptimesOnMyRoute = allStops.where(trip_id: myRoutesTrips)\n\n end",
"def timeline\n index\n new\n end",
"def get_route request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_get_route_request request_pb\n query_string_params = if query_string_params.any?\n query_string_params.to_h { |p| p.split \"=\", 2 }\n else\n {}\n end\n\n response = @client_stub.make_http_request(\n verb,\n uri: uri,\n body: body || \"\",\n params: query_string_params,\n options: options\n )\n operation = ::Gapic::Rest::TransportOperation.new response\n result = ::Google::Cloud::Datastream::V1alpha1::Route.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end",
"def get_route request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_get_route_request request_pb\n query_string_params = if query_string_params.any?\n query_string_params.to_h { |p| p.split \"=\", 2 }\n else\n {}\n end\n\n response = @client_stub.make_http_request(\n verb,\n uri: uri,\n body: body || \"\",\n params: query_string_params,\n options: options\n )\n operation = ::Gapic::Rest::TransportOperation.new response\n result = ::Google::Cloud::Datastream::V1::Route.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end",
"def show\n route_id = params.require(:route_id)\n\n route = Disraptor::RouteStore.get_route(route_id)\n\n if route.nil?\n error_message = \"Couldn’t find route for the ID '#{route_id}'.\"\n Rails.logger.error('❌ Disraptor: Error: ' + error_message)\n\n return render json: { error: error_message }, status: 404\n end\n\n render json: { 'disraptor/route': route }\n end",
"def show\r\n @route_schedule = RouteSchedule.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @route_schedule }\r\n end\r\n end",
"def airports_normal\n return @routes[:extra_airports]\n end",
"def route\n #TODO\n end",
"def direction_on_path(t)\n getDirectionOnPath(view_path_coordinates[\"LonLat\"], average_speed, t)\n end",
"def obs_route\n obs_domain_list\n expect(SYM_COLON)\n end",
"def routes\n @db[:routes].\n select(:route_id, :route_long_name).\n where(:route_id => routes_for_today).\n order(:route_long_name).\n all\n end",
"def show\n @completed_route = CompletedRoute.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @completed_route }\n end\n end",
"def timeline_url(timeline)\n case timeline\n when AgendaItem\n agenda_item_url(timeline.id, host: ActionMailer::Base.default_url_options[:host])\n when Deliverable\n deliverable_url(timeline.id, host: ActionMailer::Base.default_url_options[:host])\n when Conversation\n conversation_url(timeline.id, host: ActionMailer::Base.default_url_options[:host])\n else\n raise ArgumentError, \"Only urls to Conversations, Deliverables or AgendaItems are supported but got: #{timeline}\"\n end\n end",
"def knight_path(start, finish)\n\nend",
"def route_name_for_padrino(request)\n request.route_obj.original_path\n rescue\n nil\n end",
"def show\n @routes = @mountain.routes.order(\"name\")\n end",
"def route(name, group = nil)\n @sets.each { |set|\n if r = set[1].route(name, group)\n return r\n end\n }\n\n raise MissingRoute, \"Could not find route '#{name}'\"\n end",
"def get_routes\n raise \"Method not implemented\"\n end",
"def route_config(direction)\n stops_xml = MbtaWrapper::BusLine.get_xml('routeConfig', line.to_i)\n stops = []\n stops_xml.elements.each('body/route/stop') do |stop|\n stops << stop.attributes['title']\n end\n stops\n end",
"def show\n timeline\n end",
"def generate_timeline_view_url(given_tags, # search words\n given_timeline_id, # IF it is direct search by giving timeline-id ..future\n given_from_date, given_to_date, # date conditions\n is_fullscreen, # is it fullscreen display? 'true' means yes.\n events_on_page, # Expected values 'default' or 'more'\n tl_container_path)\n generate_list_or_tl_view_url(true,given_tags,given_timeline_id,given_from_date, given_to_date,is_fullscreen,events_on_page,tl_container_path)\n end",
"def get_route_description(route, params)\n @descriptions = {} # Hash to store station code along with station names.\n route.each do |station|\n @stations.each do |line_stations|\n line_stations.each do |line_station|\n if line_station[0] == station\n station_name = line_station[1]\n @descriptions.store(station, station_name)\n end\n end\n end\n end\n route_description = []\n description_index = 0\n @descriptions.each do |key, value|\n route_description << \"Take #{key[0, 2]} line from #{value} to \" unless key == params[:destination]\n unless description_index.zero?\n if route_description[description_index - 1].include? value\n if key == params[:destination] # Checks whether the destination station is a interchange station\n route_description[description_index - 1] = ''\n @timeline.each do |train_line|\n if train_line[0] == params[:destination][0, 2]\n @total_travel_time = (@total_travel_time - train_line[3])\n end\n end\n else\n route_description[description_index - 1] = \"Change from #{@descriptions.keys[description_index - 1][0, 2]} to #{key[0, 2]} line\"\n end\n else\n route_description[description_index - 1] = route_description[description_index - 1] + value\n end\n end\n description_index += 1\n end\n route_description.reject(&:empty?)\n end",
"def index\n info = ScheduleProcessor.headway_info\n query = params[:text]\n workspace = params[:enterprise_name] || params[:team_domain]\n user_id = params[:user_id]\n\n if query == 'help'\n result = help_response(info[:routes])\n elsif (data = info[:routes].find { |r| r[:id] == query})\n track_event('slash', \"route/#{query}\", user_id, workspace)\n result = route_response(data)\n elsif query == 'delays'\n track_event('slash', 'delays', user_id, workspace)\n result = delays_response(info[:routes])\n else\n track_event('slash', 'default', user_id, workspace)\n result = default_response(info)\n end\n \n render json: result\n end",
"def get_routes(params)\n graph_data = create_data(params)\n if graph_data.is_a?(Array)\n graph_data.each do |data|\n add_vertex(data[0][0], data[0][1])\n end\n path_array = shortest_path(params[:source], params[:destination])\n if path_array.is_a?(Array)\n get_path_description(path_array, params)\n else\n path_array\n end\n else\n graph_data\n end\n end",
"def shortest_route_by_duration_to!(place_or_object_place_was_built_from)\n routes_for!(place_or_object_place_was_built_from).min_by(&:duration_in_seconds)\n end",
"def routes\r\n RoutesController.instance\r\n end",
"def point_on_path(t)\n coord = getPointOnPath(view_path_coordinates[\"LonLat\"], average_speed, t)\n if !isOnRoute(coord, 60)\n raise \"Not on Route\"\n end\n coord\n end",
"def inspect\n route.to_s\n end",
"def getRoutes\n # [[\"MTA NYCT_B65\", \"B65\", \"Downtown Brooklyn - Crown Heights\", \"via Bergen St & Dean St\"]...]\n url = \"http://bustime.mta.info/api/where/routes-for-agency/MTA%20NYCT.xml?key=#{APIKEY}\"\n xml_str = Net::HTTP.get URI(url)\n xml = Nokogiri::XML(xml_str)\n xml.css(\"response data list route\").to_a.map{|rte| [rte.css('id').text, rte.css('shortName').text, rte.css('longName').text, rte.css('description').text]}\nend",
"def full_route\n @parent ? (ancestors.reverse + [self]).map(&:route).join('/').squeeze('/') : route\n end",
"def route_to(oth)\n parser.__send__(:convert_to_uri, oth).route_from(self)\n end",
"def shortest_route_by_duration_in_traffic_to!(place_or_object_place_was_built_from)\n ensure_driving_and_departure_time_or_fail!\n\n routes_for!(place_or_object_place_was_built_from).min_by(&:duration_in_traffic_in_seconds)\n end",
"def routing_number; end",
"def route\n index = @possible_distances.index(@possible_distances.min)\n @array_of_city_arrangements[index]\n end",
"def routes\n routes = get('/gtfs/routes')\n routes.map do |route|\n Route.from_json(route)\n end\n end",
"def last\n @routes[-1]\n end",
"def show\n @route_line = RouteLine.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @route_line }\n end\n end",
"def get_route(start_arr, end_arr)\n root = Position.new(start_arr[0], start_arr[1])\n target = Position.new(end_arr[0], end_arr[1])\n solution = get_target_value(target, root)\n\n route = []\n route.unshift([target.x, target.y])\n location = solution.parent\n until location == nil\n route.unshift [location.x, location.y]\n location = location.parent\n end\n return route\nend",
"def index\n event = Event.find(params[:event_id])\n render json: event.route, status: :ok\n end",
"def route_for(options = {})\n options = options.with_indifferent_access\n\n origin = ensure_place options[:origin]\n destination = ensure_place options[:destination]\n\n raise ArgumentError, 'Must provide origin and destination' if origin.nil? || destination.nil?\n\n routes_for(origin).detect { |route| route.destination == destination }\n end",
"def getRouteId\n @user_route_ids = []\n stop_routes_array = JSON.parse(File.read(STOP_ROUTES))\n for stop in stop_routes_array\n if stop[\"stop_id\"] == @user_stop_id\n @user_route_ids = stop[\"route_ids\"]\n end\n end\n\n for route in @user_route_ids\n @one_user_route = route\n puts \"user route is #{@one_user_route}\"\n return getAllTripIds(route)\n end\n end",
"def journey_start\n @entry_station\n end",
"def record_route(departure_time, arrival_time, from, to)\n from ||= \"\"\n to ||= \"\"\n @routes[@current_route] ||= {}\n @routes[@current_route][from] ||= {}\n @routes[@current_route][from][:departures] ||= []\n @routes[@current_route][from][:departures] << {:to => to, :time => departure_time, :days => @current_days}\n @routes[@current_route][to] ||= {}\n @routes[@current_route][to][:arrivals] ||= []\n @routes[@current_route][to][:arrivals] << {:from => from, :time => arrival_time, :days => @current_days}\n @routes\nend",
"def path_to(destination, options = {})\n Gdirections::Route.find(self, destination, options)\n end",
"def route_end\n inheritable_setting.route_end\n end",
"def shortest_route_by_duration_to(place_or_object_place_was_built_from)\n routes = routes_for place_or_object_place_was_built_from\n select_ok_routes(routes).min_by(&:duration_in_seconds)\n end",
"def get_route( request )\n return nil unless defined?( RAILS_ENV ) \n ::ActionController::Routing::Routes.recognize_path( request.path, {:method => request.request_method.downcase.to_sym } )\n end",
"def resource_tuple \n routelist = self.routes.sort { |x, y| x.length <=> y.length }\n if routelist.length == 1 #TODO: maybe should deal with a case where there's a simplest route that all the others contain.\n routelist.first\n else\n []\n end\n end",
"def show\n id = params[:id]\n init_core_tl_display_vars()\n get_timeline_data_for_display(id)\n \n @local_page_title = @timeline.title\n if @timeline.desc.present?\n @local_page_desc = @timeline.desc\n else\n @local_page_desc = @timeline.title\n end \n \n @complete_page_url = \"#{request.protocol}#{request.host_with_port}#{request.fullpath}\"\n logger.debug(\"Complete page path: \" + @complete_page_url)\n \n @tl_container_page_path = timeline_path(@timeline)\n if signed_in?\n if !current_user.nil?\n # remember query key in session. We'll need if user edits/delets event\n #session[:qkey] = query_key\n \n # Remember listviewurl , we need it in edit func.\n if @viewstyle == 'list'\n tmp_list_url = generate_list_view_url(nil,@tlid, @fromdate, @todate, @fullscr== 'true'?true:false, @events_on_a_page, @tl_container_page_path)\n session[:listviewurl] = tmp_list_url\n end\n end\n end\n record_activity(\"t=#{@timeline.title}\")\n\n if @fullscr == \"true\"\n render :template => \"timelines/tl-fullscr\", :formats => [:html], :handlers => :haml,\n :layout => \"tl\"\n elsif @embeddedview == \"true\"\n #\n #Preview case is also covered here.\n #\n render :template => \"events/tl\", :formats => [:html], :handlers => :haml,\n :layout => \"tl\"\n else\n # Normal timeline page rendering with default layout etc.\n # ...\n end\n end",
"def routes\n context[:routes]\n end",
"def route_name\n @route_name || default_route_name\n end",
"def timeline\n twitter.home_timeline\n end",
"def is_route?\n self.object_type.downcase.to_s == \"route\"\n end",
"def set_route\n @route = Route.find(params[:id])\n end",
"def set_route\n @route = Route.find(params[:id])\n end",
"def set_route\n @route = Route.find(params[:id])\n end",
"def routes_path(source = nil)\n path = '/the_one/routes'\n path += '?' + URI.encode_www_form(source: source, passphrase: Leo.passphrase) if source\n path\n end",
"def route_sets; end",
"def routes_list\n Route.all.each.with_index(1) do |(route), index|\n puts \"#{index}. Маршрут: #{route.stations.first.name} - #{route.stations.last.name}\"\n end\n end",
"def timeline(action=nil)\n timelines.mine.all(action)\n end",
"def route_by_long_name(route_long_name)\n get \"/gtfs/routes/routeLongName/#{route_long_name}\"\n end",
"def set_route\n @route = Route.find(params[:id])\n end",
"def to_detail(route)\n # get park info\n park_id = route.params['park_id']\n park_info = Service::Park.new.call({ park_id: park_id })\n park_info_result = park_info.value!\n\n # get timetable\n direction = route.params['direction']\n direction = '0' if direction.nil?\n\n direction_text = 'Southward'\n direction_text = 'Northward' if direction == '1'\n\n timetable_made = Service::Timetable.new.call({\n 'city_name': park_info_result['result']['city'],\n 'date': Date.today,\n 'direction': direction\n })\n\n if timetable_made.failure?\n flash[:error] = timetable_made.failure\n route.redirect '/'\n end\n\n timetables = timetable_made.value!\n\n # get restaurants\n park_id = route.params['park_id']\n restaurant_made = Service::RestaurantAround.new.call({ park_id: park_id, radius: '500'})\n if restaurant_made.failure?\n flash[:error] = restaurant_made.failure\n route.redirect '/'\n end\n results = restaurant_made.value!\n flash.now[:notice] = 'No match result' if results[:restaurants].length.zero?\n first_location = {\n 'lat': park_info_result['result'].latitude,\n 'lng': park_info_result['result'].longitude\n }\n\n # views\n view_timetable = Views::Timetable.new(timetables) # turn into view object\n view_restaurants = Views::Restaurant.new(results[:restaurants]) # turn into view object\n restaurant_length = results[:restaurants].length\n\n view 'detail', locals: {\n direction: direction_text,\n first_location: first_location,\n restaurants: view_restaurants,\n restaurant_length: restaurant_length,\n timetable: view_timetable\n }\n end",
"def timeline(options={})\n parse_post_timeline(request(singular(id) + \"timeline\", options))\n end",
"def getVideoFromPolylineAS\n\t\t\n\t\tif !params[:poly_id]\n\t\t\trender :text => \"Failed. (Parameters set improperly)\"\n\t\t\treturn false\n\t\tend\n\t\t\n\t\tspeed = Syncronisation.find_by_sql([\"select time, distance from syncronisations where route_id in (select id from routes where polyline_id = ?) order by time\", params[:poly_id]])\n\t\troute = Route.find(:first, :conditions => [ \"polyline_id = ?\", params[:poly_id] ]);\n\t\t\n\t\trender :json => {:video_id => route.video_id, :sync => speed}.to_json\n\tend",
"def getVideoFromPolylineAS\n\t\t\n\t\tif !params[:poly_id]\n\t\t\trender :text => \"Failed. (Parameters set improperly)\"\n\t\t\treturn false\n\t\tend\n\t\t\n\t\tspeed = Syncronisation.find_by_sql([\"select time, distance from syncronisations where route_id in (select id from routes where polyline_id = ?) order by time\", params[:poly_id]])\n\t\troute = Route.find(:first, :conditions => [ \"polyline_id = ?\", params[:poly_id] ]);\n\t\t\n\t\trender :json => {:video_id => route.video_id, :sync => speed}.to_json\n\tend",
"def print_stations_en_route\n\n start_station_sym = @start_station.gsub(\" \", \"_\").to_sym\n\n end_station_sym = @end_station.gsub(\" \", \"_\").to_sym\n\n start_line_sym = @start_line.to_sym\n\n end_line_sym = @end_line.to_sym\n \n if start_line_sym == :victoria\n start_line_sym_index = 0\n elsif start_line_sym == :bakerloo\n start_line_sym_index = 0\n elsif start_line_sym == :central\n start_line_sym_index = 0\n end\n\n stations_on_start_line = Tube.new.lines.values_at(start_line_sym)\n stations_on_end_line = Tube.new.lines.values_at(end_line_sym)\n \n stations_start = stations_on_start_line[start_line_sym_index]\n\n start_index = stations_start.find_index(start_station_sym) \n\n if start_line_sym != end_line_sym\n\n intersection = (stations_on_start_line[0] & stations_on_end_line[0])[0] \n\n start_int_index = stations_on_start_line[0].index(intersection)\n stops_between = (start_index.to_i - start_int_index.to_i).abs \n\n end_index = stations_on_end_line[0].find_index(end_station_sym)\n\n end_int_index = stations_on_end_line[0].index(intersection)\n between = (end_index.to_i - end_int_index.to_i).abs\n\n stations_on_first = stations_on_start_line[0][start_index, (start_int_index - 1)]\n stations_on_second = stations_on_end_line[0][end_int_index, (end_index + 1)]\n\n number_of_stops = (end_index - start_index).abs\n\n puts \"\\nThere are #{number_of_stops} stations till your final destination\"\n\n stations_en_route = stations_on_first + stations_on_second\n \n print_stations_en_route = stations_en_route.join(\", \").gsub(\"_\", \" \").split.map(&:capitalize).join(\" \")\n\n puts \"\\nThe stations en route are #{print_stations_en_route}\"\n\n else\n\n end_index = stations_start.find_index(end_station_sym)\n\n number_of_stops = ((end_index.to_i - start_index.to_i).abs + 1)\n\n puts \"\\nThere are #{number_of_stops} stations till your final destination\"\n #Use indexes to print stations between and including\n #\n stations_en_route = stations_start.slice(start_index..end_index)\n #Generate list and make print print ready\n #\n print_stations_en_route = stations_en_route.join(\", \").gsub(\"_\", \" \").split.map(&:capitalize).join(\" \")\n\n puts \"\\nThe stations en route are #{print_stations_en_route}\"\n\n end\n end",
"def index\n @routes = Route.get_active\n end",
"def set_route\n @route = Route.find(params[:id])\n end",
"def set_route\n @route = Route.find(params[:id])\n end",
"def set_route\n @route = Route.find(params[:id])\n end",
"def set_route\n @route = Route.find(params[:id])\n end",
"def set_route\n @route = Route.find(params[:id])\n end",
"def set_route\n @route = Route.find(params[:id])\n end",
"def set_route\n @route = Route.find(params[:id])\n end",
"def set_route\n @route = Route.find(params[:id])\n end"
] | [
"0.66756177",
"0.63129956",
"0.6282473",
"0.61637825",
"0.6088629",
"0.6059778",
"0.6047729",
"0.6047729",
"0.6034971",
"0.59549046",
"0.59533983",
"0.58815783",
"0.5819056",
"0.58077365",
"0.5727245",
"0.57205427",
"0.5720095",
"0.5711996",
"0.5710896",
"0.5709491",
"0.56802094",
"0.562408",
"0.562408",
"0.55604935",
"0.55540526",
"0.5522832",
"0.5519207",
"0.55075777",
"0.55014527",
"0.54936934",
"0.5484832",
"0.54844135",
"0.54590005",
"0.5458281",
"0.545599",
"0.5452076",
"0.5451661",
"0.5448186",
"0.54475933",
"0.54396975",
"0.54339594",
"0.542559",
"0.541251",
"0.5403444",
"0.5403085",
"0.5396722",
"0.53916496",
"0.5388416",
"0.5380918",
"0.5377785",
"0.53673124",
"0.5359472",
"0.5358456",
"0.53534704",
"0.5351793",
"0.5341646",
"0.533882",
"0.5334395",
"0.5331668",
"0.53156775",
"0.5309143",
"0.53090966",
"0.5303761",
"0.52976173",
"0.5291647",
"0.5290224",
"0.52792597",
"0.5275174",
"0.52735656",
"0.5270433",
"0.52694017",
"0.5268394",
"0.5268034",
"0.52646315",
"0.52547354",
"0.52507794",
"0.5249826",
"0.5239969",
"0.5239969",
"0.5239969",
"0.52342397",
"0.52182984",
"0.5212261",
"0.52107596",
"0.51937366",
"0.5193569",
"0.5192981",
"0.51910394",
"0.5187612",
"0.5187612",
"0.51822",
"0.51805335",
"0.5179516",
"0.5179516",
"0.5179516",
"0.5179516",
"0.5179516",
"0.5179516",
"0.5179516",
"0.5179516"
] | 0.8354507 | 0 |
Humanize that timeline entry | def humanize(options = { })
if !self.timeline_route.settings[:humanize].blank?
# specialized humanization
Activr.sentence(self.timeline_route.settings[:humanize], self.humanization_bindings(options))
else
# default humanization
@activity.humanize(options)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def timeline_title\n if completed?\n \"Hearing type converted from #{appeal.readable_previous_hearing_request_type_for_task(id)}\"\\\n \" to #{appeal.readable_current_hearing_request_type_for_task(id)}\"\n end\n end",
"def parse_timeline\n\nend",
"def show\n # trying to place things on timeline\n # (D / T) * (# of pixels in the line)\n if @timeline.events.where(\"user_id > 0\").count > 0\n events = @timeline.events.where(\"user_id > 0\").order(\"date ASC\")\n @start_date = events.first.date\n end_date = events.last.date\n @total_time_length = end_date - @start_date\n end\n end",
"def public_timeline\n Chirpy.public_timeline\n end",
"def class_timeline\n\t\tif self.state==0\n \treturn \"info\"\n elsif self.state==4\n \t\treturn \"success\"\n \telsif self.state==2\n \treturn \"success\"\n elsif self.state==6\n \treturn \"danger\"\n elsif self.state==5\n \treturn \"danger-circle\"\n elsif self.state >= 10\n return \"info\"\n else\n \treturn \"warning\"\n end\n\tend",
"def humanize\n MotionSupport::Inflector.humanize(self)\n end",
"def timeline\n twitter.home_timeline\n end",
"def display_timeline\n timeline_search_results = []\n TWITTER.home_timeline.each do |tweet|\n timeline_search_results << [tweet.user.name, tweet.text]\n # binding.pry\n end\n timeline_search_results\n end",
"def title\n # Title of the tracker line\n case obj_type\n when \"Post\"\n obj.subject\n when \"Comment\"\n obj.subj\n end\n end",
"def feed_status_summary feed\n entry_report =\n case nmatches = feed.feed_entries.size\n when 0\n \"No entries\"\n when 1\n \"One entry\"\n else\n \"#{nmatches} entries\"\n end\n time_report = (feed.updated_at.today?) ? \"Today\" : \"#{time_ago_in_words feed.updated_at} ago\"\n update_button = feed_update_button feed\n \"#{entry_report}/<br>#{time_report} #{update_button}\".html_safe\n end",
"def on_timeline(tweet)\n end",
"def timeline\n config = create_or_find_config\n \n timeline = :friends\n timeline = ARGV.shift.intern if ARGV.size > 0 && Twitter::Base.timelines.include?(ARGV[0].intern)\n \n puts\n Twitter::Base.new(config['email'], config['password']).timeline(timeline).each do |s|\n puts \"#{s.text}\\n-- #{s.user.name} at #{s.created_at}\"\n puts\n end\n end",
"def description\n text = ['A']\n text << [duration, 'minute'] if duration.present?\n text << [format, 'publication']\n text << [ 'from', pretty_date(published_on) ] if published_on.present?\n text << ['by', presentations.first.speaker_names] if presentations.present?\n text.join(' ')\n end",
"def timeline\n configure\n # Twitter.home_timeline returns a list of Twitter::Status\n # We can get the body of a Twitter::Status by writing status.text,\n # The poster's real name via status.user.name\n # and the poster's screen name via status.user.screen_name\n Twitter.home_timeline.map { |item|\n twitter_id = item.id.to_s\n if not Tweet.find_by_twitter_id twitter_id # Avoid saving duplicates\n Tweet.create! :text => Twitter::Autolink.auto_link(item.text),\n :tweeter => item.user.name,\n :tweeter_screen_name => item.user.screen_name,\n :published_at => item.created_at,\n :twitter_id => twitter_id,\n :user => @user\n end\n }.compact\n end",
"def print_timeline(tweets)\n \n puts tweets [0][\"user\"][\"screen_name\"]\n puts tweets [0][\"text\"]\n\n \n\nend",
"def humanize_recording(rec)\n opts = {\n :user => rec.user.full?(&:name),\n :object_class => t(\"activerecord.models.#{rec.item_type.underscore}\"),\n :object_link => link_to_item(rec.item),\n }\n t(\"recordings.#{rec.action}\", opts)\n end",
"def get_full_name\n \"#{get_scheduled_date} #{get_event_type}: #{rank}) #{athlete_name}, #{get_timing}\"\n end",
"def race_at_display\n \"#{try(:year)}-#{try(:month)}-#{try(:day)} #{post_time}\".to_s\n end",
"def human_event; end",
"def short_description\n \"#{self.meeting_start_time.to_s} to #{self.meeting_end_time.to_s}\"\n end",
"def details\n format_description(@description, 25) + \"event dates: \" + format_date(@start_date,@end_date)\n end",
"def describe\n if twilight?\n \"[#{time.capitalize}], day #{day_number}\"\n else\n \"#{time.capitalize}time (day #{day_number})\"\n end\n end",
"def show_object_time_info(object)\n object.completed ? \"Date of completion: \" + object.completion_time : \"added on: \" + object.created_at.strftime(\"%m/%d/%Y\").to_s\n end",
"def describe\n I18n.l(event_time, format: :short) + ' - ' + event_name\n end",
"def time_category\n # ActionController::Base.helpers.time_ago_in_words Groupify.groupify([self], Proc.new {|ep| ep.aired_at || ep.phile.file_created_at })[0][0]\n ActionController::Base.helpers.time_ago_in_words self.aired_at\n end",
"def pretty_created_at(clock=Time.now)\n a = (clock-self.created_at).to_i\n\n return 'just now' if a == 0\n return 'a second ago' if a == 1\n return a.to_s+' seconds ago' if a >= 2 && a <= 59\n return 'a minute ago' if a >= 60 && a <= 119 #120 = 2 minutes\n return (a/60).to_i.to_s+' minutes ago' if a >= 120 && a <= 3540\n return 'an hour ago' if a >= 3541 && a <= 7100 # 3600 = 1 hour\n return \"Today at#{self.created_at.strftime(\"%l:%M%p\")}\" if a >= 7101 && a <= 82800\n return \"Yesterday at#{self.created_at.strftime(\"%l:%M%p\")}\" if a >= 82801 && a <= 165600\n if clock.strftime(\"%A\") == \"Sunday\"\n return \"This #{self.created_at.strftime(\"%A\")} at #{self.created_at.strftime(\"%l:%M%p\")}\" if a >= 165601 && a <= 579600\n return \"#{self.created_at.strftime(\"%A %B %e\")} at #{self.created_at.strftime(\"%l:%M%p\")}\" if a >= 579601\n elsif clock.strftime(\"%A\") == \"Saturday\"\n return \"This #{self.created_at.strftime(\"%A\")} at#{self.created_at.strftime(\"%l:%M%p\")}\" if a >= 165601 && a <= 496800\n return \"#{self.created_at.strftime(\"%A %B %e\")} at#{self.created_at.strftime(\"%l:%M%p\")}\" if a >= 496801\n elsif clock.strftime(\"%A\") == \"Friday\"\n return \"This #{self.created_at.strftime(\"%A\")} at#{self.created_at.strftime(\"%l:%M%p\")}\" if a >= 165601 && a <= 414000\n return \"#{self.created_at.strftime(\"%A %B %e\")} at#{self.created_at.strftime(\"%l:%M%p\")}\" if a >= 414001\n elsif clock.strftime(\"%A\") == \"Thursday\"\n return \"This #{self.created_at.strftime(\"%A\")} at#{self.created_at.strftime(\"%l:%M%p\")}\" if a >= 165601 && a <= 331200\n return \"#{self.created_at.strftime(\"%A %B %e\")} at#{self.created_at.strftime(\"%l:%M%p\")}\" if a >= 331201\n elsif clock.strftime(\"%A\") == \"Wednesday\"\n return \"This #{self.created_at.strftime(\"%A\")} at#{self.created_at.strftime(\"%l:%M%p\")}\" if a >= 165601 && a <= 248400\n return \"#{self.created_at.strftime(\"%A %B %e\")} at#{self.created_at.strftime(\"%l:%M%p\")}\" if a >= 248401\n else\n return \"#{self.created_at.strftime(\"%A %B %e\")} at#{self.created_at.strftime(\"%l:%M%p\")}\" if a >= 165600\n end\n end",
"def calc_statuses\n def date_str_fmt(dt)\n case dt\n when nil\n \"N/A\"\n when Date.today\n \"Today at \" + dt.strftime(\"%H:%M\")\n when Date.today.prev_day\n \"Yesterday\"\n else\n dt.strftime(\"%Y-%m-%d\")\n end\n end\n def duration_fmt(t)\n if t < 2\n \"%0.2f hrs\" % (t.to_f.abs*24.0)\n else\n \"%i days ago\" % t.round\n end\n end\n def status_fmt(s)\n color = case s\n when AimsProject::RUNNING\n :green\n when AimsProject::COMPLETE\n :yellow\n when AimsProject::CANCELED\n :red\n else\n nil\n end\n HighLine.color(s,color)\n end\n project_obj_files = Dir[\"*.yaml\"]\n project = AimsProject::Project.load(project_obj_files.first)\n format = \"%-40s\\t%-30s\\t%-15s\\t%-15s\\t%-15s\\t%-15s\"\n puts format % [\"GEOMETRY\", \"CONTROL\", \"STATUS\", \"CREATED_AT\", \"UPDATED_AT\", \"SINCE_UPDATE\"]\n project.calculations.sort{|a, b| a.updated_at <=> b.updated_at}.each{|c|\n puts format % [c.geometry[0..40], c.control[0..30], status_fmt(c.status), date_str_fmt(c.created_at), date_str_fmt(c.updated_at), duration_fmt(DateTime.now - c.updated_at)]\n }\nend",
"def print_timeline(response)\n \n tweets = response[\"statuses\"]\n \n for tweet in tweets\n puts tweet[\"user\"][\"screen_name\"]\n puts tweet[\"text\"]\n end\n \nend",
"def retun_time_entry_msg(slatime)\n new_status = slatime.issue_sla_status.issue_status.name\n pre_status = slatime.old_status.issue_status.name #unless slatime.count == 1\n pre_status = pre_status == new_status ? 'New' : pre_status\n \"Status was changed from #{pre_status} to #{new_status}\"\n end",
"def print_timeline(tweets)\n # ADD CODE TO ITERATE THROUGH EACH TWEET AND PRINT ITS TEXT\n tweets.each do |tweet| puts tweet['text'] end\n \n\nend",
"def humanize\n # TODO\n # Inflector.humanize(self)\n end",
"def show\n timeline\n end",
"def release_summary title = nil\n datestamp_title = title ? Time.now.strftime(\"(%-m/%d) #{title}:\") : Time.now.strftime(\"%-m/%d:\")\n\n if done_cards.empty?\n datestamp_title + \" Nada. 😢\"\n else\n ([datestamp_title] + done_cards.map { |card| '- ' + card['note'] }).join \"\\n\"\n end\nend",
"def and_i_add_a_new_timeline_entry\n click_on(I18n.t(\"coronavirus.pages.show.timeline_entries.add\"))\n end",
"def display_object type\n\t\t\thorizontal_border = \"+-------+-#{'-'*@name_width}-+-#{'-'*@elapsed_time_width}-+\"\n\t\t\tcase type\n\t\t\twhen :top\n\t\t\t\tputs horizontal_border\n\t\t\t\tif TrackingConfig[:show_header]\n\t\t\t\t\tputs \"| start | #{pad('task', @name_width, :center)} | #{pad('elapsed', @elapsed_time_width, :center)} |\"\n\t\t\t\t\tputs horizontal_border\n\t\t\t\tend\n\t\t\twhen :bottom\n\t\t\t\tputs horizontal_border\n\t\t\twhen :intro\n\t\t\t\tintro_text = <<-EOF\nYou haven't started any tasks yet! :(\n\nRun this to begin your first task:\n tracking starting some work\n\t\t\t\tEOF\n\t\t\t\tintro_text.each_line do |line|\n\t\t\t\t\tputs \"| | #{pad(line.chomp, @name_width)} | #{pad(nil, @elapsed_time_width)} |\"\n\t\t\t\tend\n\t\t\tend\n\t\tend",
"def timeline\n tweets = []\n following.merge(my_info).each do |nick,url|\n tweets.concat timeline_for_user(nick,url)\n end\n tweeets = tweets[-timeline_limit, timeline_limit].sort_by { |h| h[:date] }\n (timeline_sort == 'descending') ? tweets.reverse : tweets\nend",
"def display_entry\n\t\tputs user.username + \" \" + date.to_s\n\t\tputs text\n\tend",
"def get_verbose_name\n \"#{get_meeting_program_verbose_name}: #{rank}) #{athlete_name} (#{year_of_birth}), #{get_timing}\"\n end",
"def display_weekend_activity_name\n i = 0\n while i < 10\n puts weekend_activities[i][:title]\n i += 1 \n end\n end",
"def episode_title; end",
"def timelines_quickview\n @total_timelines = Timeline.count()\n @total_users = User.count()\n @total_events = Event.count()\n @total_tags = Tag.count()\n @timelines_authors_summary = Timeline.select(\"owner_id as his_id, count(*) as his_count\").group(\"owner_id\").order(\"his_count DESC\")\n @authors_details = Hash.new\n \n @timelines_authors_summary.each do |each_author_summary|\n user_entry = nil\n begin\n user_entry = User.find(each_author_summary.his_id)\n rescue\n end\n @authors_details[each_author_summary.his_id] = user_entry\n end\n \n render :template => \"timelines/timelines_quickview\", :formats => [:html], :handlers => :haml \n end",
"def timelines_quickview\n @total_timelines = Timeline.count()\n @total_users = User.count()\n @total_events = Event.count()\n @total_tags = Tag.count()\n @timelines_authors_summary = Timeline.select(\"owner_id as his_id, count(*) as his_count\").group(\"owner_id\").order(\"his_count DESC\")\n @authors_details = Hash.new\n \n @timelines_authors_summary.each do |each_author_summary|\n user_entry = nil\n begin\n user_entry = User.find(each_author_summary.his_id)\n rescue\n end\n @authors_details[each_author_summary.his_id] = user_entry\n end\n \n render :template => \"timelines/timelines_quickview\", :formats => [:html], :handlers => :haml \n end",
"def get_when_text(event)\n start_text = DateService.new.convert_to_readable_date_time(event.startDate, event.startTime)\n end_text = DateService.new.convert_to_readable_date_time(event.endDate, event.endTime)\n if !start_text.blank? && !end_text.blank?\n \"#{start_text}—#{end_text}\"\n else\n \"#{start_text}#{end_text}\"\n end\n end",
"def short_display_time\n\t\tself.timestamp.strftime(\"%b %d %-l:%M %p\") + (self.is_full? ? \" (Waitlist)\" : \"\")\n\tend",
"def titre\n \"Links Analysis du #{Time.now.strftime('%d %m %Y à %H:%M')}\"\n end",
"def time_to_show\n \n end",
"def report_time_spent(entry)\n if Setting.plugin_redmine_spent_time_in_issue_description['time_format'].eql? 'human'\n humanized_time(entry.hours)\n else\n entry.hours\n end\n end",
"def timeline\n []\n end",
"def activity_header(activity_name)\n clear\n puts HEADER_LINE\n puts \"Activity: #{activity_name}\".upcase.center(HEADER_LENGTH)\n puts HEADER_LINE\nend",
"def timeline\n request('timeline')\n end",
"def display_schedules\n puts label\n puts scheduled_meetings\n end",
"def parse_post_timeline(result)\n parse_type(result, \"post_timeline\")\n end",
"def pretty_status\r\n status.titleize\r\n end",
"def audithelp_changes( record )\n type = record.auditable_type\n changes = record.audited_changes\n\n if ( changes.blank? )\n if ( type == 'Timesheet' )\n return 'Added or removed rows, or edited hours within rows'\n else\n return 'No other details available'\n end\n end\n\n output = '<table class=\"list audit_changes\">'\n output << '<tr><th class=\"audit_changes_field\">Field</th><th class=\"audit_changes_from\">From</th><th class=\"audit_changes_to\">To</th></tr>'\n\n changes.keys.each do | key |\n cdata = changes[ key ]\n\n if ( cdata.instance_of?( Array ) )\n cfrom = to_descriptive_s( cdata[ 0 ] )\n cto = to_descriptive_s( cdata[ 1 ] )\n else\n cfrom = '–'.html_safe()\n cto = cdata.to_s()\n end\n\n # Try to get clever :-) and see if we have \"[foo_]id\" in a string. If\n # so, extract \"foo\" and see if the item can be found.\n\n array = key.split( '_' )\n\n if ( array.size > 1 )\n check = array.pop()\n\n if ( check == 'id' )\n type = array[ 0 ].capitalize\n\n if ( type == 'User' or type == 'Project' or type == 'Customer' or type == 'Task' )\n field = ( type == 'User' ) ? 'name' : 'title'\n\n begin\n const = type.constantize\n\n if ( cfrom.to_i.to_s == cfrom )\n item = const.find_by_id( cfrom )\n cfrom = \"#{ cfrom } (#{ item[ field ] })\" unless ( item.nil? )\n end\n\n if ( cto.to_i.to_s == cto )\n item = const.find_by_id( cto )\n cto = \"#{ cto } (#{ item[ field ] })\" unless ( item.nil? )\n end\n rescue\n # Do nothing - just ignore errors\n end\n end\n end\n end\n\n output << \"<tr><td>#{ h( key ) }</td><td>#{ h( cfrom ) }</td><td>#{ h( cto ) }</td></tr>\"\n end\n\n return ( output << '</table>' ).html_safe\n end",
"def tweet_status_explanation(status)\n case status\n when 'created'\n 'Pendiente de aprobación por la celebridad'\n when 'influencer_reviewed'\n 'Pendiente de aprobación por el anunciante'\n when 'influencer_rejected'\n 'Rechazado por la celebridad'\n when 'advertiser_reviewed'\n 'Pendiente de aprobación por la celebridad'\n when 'advertiser_rejected'\n 'Rechazado por el anunciante'\n when 'accepted'\n 'Aceptado, se publicara en la fecha y hora convenidas'\n when 'activated'\n 'Activo, el Tweet ya fue públicado'\n when 'expired'\n 'Vencido, el Tweet no fue aceptado ni rechazado'\n end\n end",
"def event_headline\n self.label.to_s.strip\n end",
"def render_entry(entry)\n %{<div class=\"hentry\" id=\"#{entry[:id]}\">\n <h2 class=\"entry-title\">#{entry[:title]}</h2>\n <span class=\"entry-content\">#{entry[:content]}</span>\n #{entry[:published_at].to_html}\n <span class=\"byline\">Posted by <span class=\"author vcard\"><span class=\"fn\"\n }\n end",
"def classify_time_span(dt, style=:simple)\n return \"Unknown\" if dt.nil?\n \n case style\n when :simple\n if dt > (Time.now - 7.days)\n return \"Last 7 days\"\n else\n return \"Older\"\n end\n when :detailed\n return \"#{distance_of_time_in_words_to_now(dt).capitalize} ago\"\n else\n return \"Unknown\"\n end\n end",
"def display_time_for_tweet\n created_at.strftime(\"%B #{created_at.day.ordinalize}, %Y\")\n end",
"def human_time(time)\n time = time.utc.strftime(\"%a, %d %b %Y %H:%M:%S GMT\")\n %|<span class=\"human_time\" title=\"#{time}\">#{time}</span>| \n end",
"def briefing\n \"#{date.min} #{date.hour} #{date.day} #{date.month} 0 #{ab_command}\"\n end",
"def print_event\n clear\n @talks.sort_by {|task| task.start_time }.each do |t|\n puts \"#{t.start_time.strftime(\"%I:%M%p\").delete_prefix(\"0\").downcase} - #{t.end_time.strftime(\"%I:%M%p\").delete_prefix(\"0\").downcase}\"\n puts \" #{t.name} presented by #{t.speaker.name}\"\n end\n puts\n end",
"def convert_message_line(line)\n line_array = line.split(' ')\n human_timestamp = Time.parse(line_array[0..2].join(' '))\n format(human_timestamp, line_array, 3)\nend",
"def update\n @timeline = Timeline.find(params[:id])\n if @timeline.update_attributes(params[:timeline])\n record_activity(\"t=#{@timeline.title}\")\n flash[:notice] =\n \"<strong>#{@timeline.title}</strong> was successfully updated\".html_safe\n redirect_to timeline_path(@timeline)\n else\n setup_vars_for_edit(@timeline)\n render :template => \"timelines/edit\", :formats => [:html], :handlers => :haml\n end\n end",
"def scanned_at_human_time\n format = object.scanned_at.today? ? '%H:%M' : '%d/%m %H:%M'\n\n I18n.l card_scan.scanned_at, format: format\n end",
"def timeline\n\t\t\t\tbookmarks_loader(Time.now, doorkeeper_token.resource_owner_id) \n\t\t\t\tbookmarks_formatter\t\t\t\t\n\t\t\tend",
"def user_tweets screen_name\n\t\tTwitter.user_timeline(screen_name.to_s)\n\tend",
"def to_text\n result = ''\n if ! @start_time.nil?\n result += $config.get_abbreviation( 'Start time' ) + ':'\n result += @start_time.strftime( '%Y-%m-%d-%H:%M' ) + \" \"\n end\n if ! @end_time.nil?\n result += $config.get_abbreviation( 'End time' ) + ':'\n result += @end_time.strftime( '%Y-%m-%d-%H:%M' ) + \" \"\n end\n @categories.each { |k,v| result += $config.get_abbreviation(k) + \":#{v} \" }\n result += @description\n end",
"def humanize_time(time)\n humanize_date(time.to_date) + (time.to_date.cweek == Date.today.cweek ? \" at \" + time.strftime(\"%l:%M %p\") : \"\")\n end",
"def humanize\n @fields.collect do |_, field|\n field.meaning\n end.join(\"; \").chomp(\"; \")\n end",
"def title\n zone = Timezone::Zone.new :zone => group.due_timezone\n due = date_due.to_time.localtime(zone.utc_offset)\n due.strftime('%A, %B %-d, %Y')\n end",
"def changelog_entry_display(shaped_changes)\n shaped_changes.map do |entry|\n field = t(\"activerecord.attributes.patient.#{entry[0]}\")\n field = content_tag('strong') { \"#{field}:\" }.freeze\n orig = entry[1][:original]\n separator = '->'.freeze\n mod = entry[1][:modified]\n\n safe_join([field, orig, separator, mod], ' ').freeze\n end\n end",
"def group_entries entries\n entries.group_by do |title, _|\n begin\n Time.parse(title).strftime '%Y-%m-%d'\n rescue NoMethodError, ArgumentError\n time, = title.split ' ', 2\n Time.parse(time).strftime '%Y-%m-%d'\n end\n end\n end",
"def timeline(action=nil)\n timelines.mine.all(action)\n end",
"def timeline(options={})\n self.class.parse_user_timeline(request(singular(user_id) + \"/timeline\", options))\n end",
"def will_store_timeline_entry(timeline_entry)\n if timeline_entry.activity[:foo] == 'bar'\n timeline_entry.activity[:foo] = 'tag'\n end\n end",
"def humanize(normalized)\n\t\t\t\tnormalized.to_s\n\t\t\tend",
"def title\n punched_at.strftime(DATE_FORMAT)\n end",
"def display_time_at\n gm = self.good_memories.count\n bm = self.bad_memories.count\n lifespan = (Time.now.to_i - self.created_at.to_i)\n unless gm == 0\n shift = (lifespan * (bm + 1)) / gm\n return (Time.now.to_i - shift)\n else\n shift = lifespan * (bm + 1)\n return (Time.now.to_i - shift)\n end\n end",
"def details\n format_description(@description) + \"event dates: \" + format_date(start_date:@start_date, end_date: @end_date)\n end",
"def kase_type_posted_time_ago_in_words(kase)\n \"%{type} posted %{time} ago\" % {:type => kase.class.human_name, \n :time=> time_ago_in_words_span_tag(kase.created_at)}\n end",
"def anatomy_past_tense; end",
"def name\n meet_on.to_s(:long)\n end",
"def render_time_span event\n\t\t# return time.strftime(\"%c\")\n\t\ts = render_date( event.starts_at ) + ' ' + render_time( event.starts_at );\n\t\ts << ' <span class=\"slash\">/</span> '\n\t\tif event.ends_at\n\t\t\tif event.starts_at.month == event.ends_at.month and event.starts_at.year == event.ends_at.year\n\t\t\t\ts << render_time( event.ends_at )\n\t\t\telse\n\t\t\t\ts << render_date( event.ends_at ) + ' ' + render_time( event.ends_at )\n\t\t\tend\n\t\telse\n\t\t\ts << \"N/A\"\n\t\tend\n\t\t\n\t\treturn s.html_safe;\n\tend",
"def timeinfo(model, options = {})\n created = model.created_at\n updated = model.updated_at\n if created.distance_in_words == updated.distance_in_words ||\n options[:updated_string] == false\n relative_date created\n else\n updated_string = options[:updated_string] || 'updated'\n \"Created #{relative_date created}, #{updated_string} #{relative_date updated}\".html_safe\n end\n end",
"def event_headlines_for(_date,_show_ids=false)\n if !_show_ids\n events_on(_date).map(&:event_headline).join(' + ').strip\n else\n events_on(_date).map{|e|\n \"%16.16s: %s\" % [e.respond_to?(:id) ? e.id : 'n/a' ,e.event_headline]\n }.join(\"\\n\").gsub(/\\s*$/,'')\n end\n end",
"def format_text(title, url, url_title_time_ary)\n s = \"Title: #{title}¥nURL: #{url}¥n¥n\"\n url_title_time_ary.each do |aurl, atitle, atime|\n s << \"* (#{atime})#{atitle}¥n\"\n s << \" #{aurl}¥n\"\n end\n s\nend",
"def public_timeline\n call( 'statuses/public_timeline.json' )\n end",
"def search_result_label item\n label = item.id\n unless item[\"title_display\"].blank?\n label = truncate(item[\"title_display\"], length: 35)\n end\n \n if ! item['duration_t'].nil? && ! item['duration_t'].empty? \n item_duration = item['duration_t'].first\n if item_duration.respond_to?(:to_i)\n formatted_duration = milliseconds_to_formatted_time(item_duration.to_i)\n label += \"(#{formatted_duration})\"\n end\n end\n\n label\n end",
"def convert_nagios_line(line)\n line_array = line.split(' ')\n epoch_timestamp = line_array[0].gsub(/\\D/, '')\n human_timestamp = Time.at(epoch_timestamp)\n format(human_timestamp, line_array, 1)\nend",
"def timeline(options={})\n self.class.parse_post_timeline(request(singular(question_id) + \"/timeline\", options))\n end",
"def display_task(task)\n\t\t\tsplit_task(task.name).each_with_index do |name_line, line_index|\n\t\t\t\tcol_1 = pad((task.start_time if line_index==0), 5)\n\t\t\t\tcol_2 = pad(name_line, @name_width)\n\t\t\t\tcol_3 = pad((task.elapsed_time if line_index==0), @elapsed_time_width)\n\n\t\t\t\tif task.current? and TrackingConfig[:color_current_task]\n\t\t\t\t\tcurrent_task_color = TrackingConfig[:current_task_color]\n\t\t\t\t\tcurrent_task_color = TrackingConfig.defaults[:current_task_color] unless String.colors.include? current_task_color\n\n\t\t\t\t\tcol_1 = col_1.colorize current_task_color\n\t\t\t\t\tcol_2 = col_2.colorize current_task_color\n\t\t\t\t\tcol_3 = col_3.colorize current_task_color\n\t\t\t\tend\n\n\t\t\t\tputs \"| #{col_1} | #{col_2} | #{col_3} |\"\n\t\t\tend\n\t\tend",
"def kase_type_and_time_in_words(kase)\n \"%{type} %{verb} %{time}\" % {\n :type => kase.class.human_name,\n :verb => case kase.kind \n when :problem then \"reported\".t\n when :question then \"asked\".t\n when :praise then \"praised\".t\n when :idea then \"shared\".t\n else \"posted\".t\n end,\n :time => \"%{time} ago\".t % {:time => time_ago_in_words_span_tag(kase.created_at)}\n }\n end",
"def date_as_label\n date_played.to_s\n end",
"def deadline_pretty\n self.deadline.strftime \"%A, %B %d, %Y at %I:%M %p\"\n end",
"def humanize(lang = :en)\n t = object.strftime(\"%r\")\n if timezone?\n z = @zone == '+00:00' ? \"UTC\" : @zone\n t += \" #{z}\"\n end\n t\n end",
"def display_today_activity_name\n i = 0\n while i < 10\n puts today_activities[i][:title]\n i += 1 \n end\n end",
"def display_time_for_appointment\n date.strftime(\"%I:%M:%S %p, %B #{date.day.ordinalize}, %Y\")\n end",
"def get_full_name\n \"#{get_scheduled_date}, #{get_event_type}: #{rank}) #{get_team_name}, #{get_timing}\"\n end",
"def time_detail(options = {})\n default_options = {\n :use_words => true,\n :date_format => :date_with_day_of_week,\n :time_format => :time12,\n :use_relative_dates => true,\n :audience => nil\n }\n options = default_options.merge(options)\n audience = options[:audience]\n separator = options[:use_words] ? { :to => \" to\", :from => \" from\", :at => \" at\" } : { :to => \" -\", :from => \"\", :at => \"\" }\n _start_date = date.to_date.to_s(options[:date_format]).strip\n _start_date = \"Today\" if date.to_date == Time.now.to_date && options[:use_relative_dates]\n _start_date = \"Tomorrow\" if date.to_date == 1.day.from_now.to_date && options[:use_relative_dates]\n _start_time = start_time(audience).to_time.to_s(options[:time_format]).strip if start_time(audience)\n _end_date = end_time(audience).to_date.to_s(options[:date_format]).strip if end_time(audience)\n _end_date = \"today\" if end_time(audience) && end_time(audience).to_date == Time.now.to_date && options[:use_relative_dates]\n _end_date = \"tomorrow\" if end_time(audience) && end_time(audience).to_date == 1.day.from_now.to_date && options[:use_relative_dates]\n _end_time = end_time(audience).to_time.to_s(options[:time_format]).strip if end_time(audience)\n return \"Time TBA\" if options[:time_only] && time_tba?\n return \"#{_start_date}\" if (options[:date_only] && (end_time(audience).blank? || start_time(audience).to_date == end_time(audience).to_date)) || start_time(audience).blank? || time_tba?\n return \"#{_start_time}\" if options[:time_only] && !end_time(audience)\n return \"#{_start_time}#{separator[:to]} #{_end_time}\" if options[:time_only] && start_time(audience).to_date == end_time(audience).to_date\n return \"#{_start_date}#{separator[:at]} #{_start_time}\" if start_time(audience) && end_time(audience).nil?\n return \"#{_start_date}#{separator[:from]} #{_start_time}#{separator[:to]} #{_end_time}\" if start_time(audience).to_date == end_time(audience).to_date\n return \"#{_start_date}#{separator[:at]} #{_start_time}#{separator[:to]} #{_end_date}#{separator[:at]} #{_end_time}\"\n end"
] | [
"0.7449541",
"0.65076625",
"0.61750156",
"0.58942235",
"0.5781432",
"0.5688995",
"0.56507516",
"0.55781966",
"0.55637515",
"0.55538285",
"0.5551372",
"0.5539719",
"0.5511138",
"0.54902947",
"0.5484185",
"0.5470789",
"0.54601717",
"0.5450992",
"0.54507565",
"0.54473513",
"0.54243577",
"0.53993976",
"0.5387641",
"0.53865725",
"0.53846467",
"0.5367775",
"0.5363498",
"0.53501236",
"0.5337995",
"0.53377354",
"0.53350025",
"0.53310394",
"0.53295726",
"0.5324172",
"0.5324031",
"0.53160465",
"0.5307096",
"0.5306408",
"0.52968246",
"0.5293743",
"0.5286313",
"0.5286313",
"0.52831197",
"0.52829474",
"0.52756447",
"0.52582586",
"0.52507263",
"0.52481097",
"0.52398926",
"0.5236727",
"0.5231144",
"0.5231134",
"0.5230619",
"0.52241635",
"0.52176565",
"0.52138406",
"0.5202895",
"0.52010983",
"0.5199984",
"0.51968354",
"0.51930445",
"0.51923984",
"0.5186081",
"0.5185713",
"0.51856756",
"0.5183852",
"0.5177241",
"0.51750594",
"0.5173523",
"0.5172885",
"0.51722103",
"0.51693785",
"0.51638335",
"0.51591945",
"0.5151217",
"0.5143218",
"0.514293",
"0.5137432",
"0.512015",
"0.51150274",
"0.51142144",
"0.51139086",
"0.5110019",
"0.5095663",
"0.5093077",
"0.50793546",
"0.507542",
"0.50741285",
"0.50739294",
"0.50697446",
"0.5066022",
"0.5065803",
"0.5062698",
"0.50623435",
"0.5062257",
"0.5057423",
"0.50534075",
"0.50533223",
"0.5052281",
"0.50488716"
] | 0.6533922 | 1 |
Is it already stored | def stored?
!@_id.nil?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stored?\n !@_id.nil?\n end",
"def store?\n true\n end",
"def store?\n false\n end",
"def already_stored?\n !file_uniqueness\n end",
"def is_to_be_stored?\n any?(&:is_to_be_stored?)\n end",
"def store?\n true\n end",
"def store?\n false\n end",
"def store?\n false\n end",
"def previously_existed?\n true\n end",
"def stored?\n !attributes['e_tag'].nil?\n end",
"def saved?\n self.class.exists?(self.hash)\n end",
"def saved_already?\n @id != \"\" && @id != nil\n end",
"def already_persisted?\n false\n end",
"def persisted?\n [email protected]?\n end",
"def seen?\n @seen\n end",
"def registered?(name)\n return false if empty?\n\n storage.include?(name)\n end",
"def store?; end",
"def persisted?\n true\n end",
"def registered?(name)\n return false if storage.empty?\n\n storage.include?(name)\n end",
"def persisted?\n !new?\n end",
"def saved?\n !new? && !@content\n end",
"def persisted?\n !new?\n end",
"def persisted?\n !new?\n end",
"def persisted?\n !new?\n end",
"def persisted?\n true\n end",
"def persisted?\n true\n end",
"def registered?(name)\n return false if storage.empty?\n\n storage.include?(name)\n end",
"def persistent?\n true\n end",
"def exists?\n storage.exists?(id)\n end",
"def persistent?\n persistent\n end",
"def persist\n !!self.class.store.add?(self)\n end",
"def can_save?\n @key != '1'\n end",
"def persisting?\n persisting == true\n end",
"def saved?\n !!@saved\n end",
"def has_been_seen\n return false if self.new_record?\n self.seen = true\n self.save\n end",
"def cache?\n persisted?\n end",
"def saved?\n return @saved\n end",
"def persists_state_via_data_import?\n false\n end",
"def persisted?\r\n false\r\n end",
"def persisted?\r\n false\r\n end",
"def has_key?(key)\n @stored[key] && !@stored[key].empty? ? true : false\n end",
"def persisted? # :nodoc:\n false\n end",
"def exist?(key)\n store.key?(key)\n end",
"def persisted?\n self[:id].present?\n end",
"def saved?\n @saved\n end",
"def existing?\n @existing\n end",
"def persisted?\n !id.nil?\n end",
"def persistent?\n false\n end",
"def persisted?\n !new? && !destroyed?\n end",
"def persisted?\n @persisted == true\n end",
"def persisted?\n !@attributes['id'].nil?\n end",
"def persisted?\n !@attributes['id'].nil?\n end",
"def persisted?\n @saved\n end",
"def persisted?\n return false\n end",
"def persistent?\n\t\treturn true\n\tend",
"def persistent?\n\t\treturn true\n\tend",
"def autosaved?\n Threaded.autosaved?(self)\n end",
"def previously_persisted?\n !new_record? && destroyed?\n end",
"def persisted?\n false\n end",
"def persisted?\n false\n end",
"def persisted?\n false\n end",
"def persisted?\n false\n end",
"def persisted?\n false\n end",
"def persisted?\n false\n end",
"def persisted?\n false\n end",
"def persisted?\n false\n end",
"def persisted?\n false\n end",
"def persisted?\n false\n end",
"def persisted?\n false\n end",
"def persisted?\n false\n end",
"def persisted?\n false\n end",
"def persisted?\n !self.id.nil?\n end",
"def persisted?\n \[email protected]?\n end",
"def persisted?\n !new_record?\n end",
"def persisted?\n !!persisted\n end",
"def cached_write?\n [email protected]?\n end",
"def persisted?\n !(@new_record || @destroyed)\n end",
"def dirty?\n\t\treturn self.identify.dirty?\n\tend",
"def persisted? ; false ; end",
"def already_uploaded?\n false\n seen_before = Zaphod::PhotoStorage.get(\"seen_id_#{@post_id}\",\"recommendation\")\n if seen_before && seen_before == @post_id\n @log.debug(\"already uploaded ID #{seen_before}... skipping\")\n true\n end\n end",
"def stored?\n car_id.present?\n end",
"def persisted?\n true\n end",
"def persisted?\n true\n end",
"def persisted?\n true\n end",
"def persisted?\n true\n end",
"def persisted?\n true\n end",
"def persisted?\n true\n end",
"def persisted?\n @persisted ||= false\n @persisted\n end",
"def persisted?\n !new_record?\n end",
"def persistent?\n raise \"Not yet implemented\"\n end",
"def persisted?\n !!@persisted\n end",
"def persisted?\n\t\t!(self.id.nil?)\n\tend",
"def live?\n\t\[email protected]?\n\tend",
"def saved?\n res = uri.nil?\n !res\n end",
"def persisted?\n \[email protected]?\n end",
"def persisted?\n !new_record?\n end",
"def persisted?\n !new_record?\n end",
"def persisted? \n false\n end",
"def persist\n true\n end",
"def persisted?\n !!id\n end"
] | [
"0.8003325",
"0.7999743",
"0.7850456",
"0.77591544",
"0.75428426",
"0.75012016",
"0.7455423",
"0.7455423",
"0.7176047",
"0.71278393",
"0.7103778",
"0.70197487",
"0.6997889",
"0.6943841",
"0.68439096",
"0.6842603",
"0.6841437",
"0.6836831",
"0.68290454",
"0.6796294",
"0.6790604",
"0.6788896",
"0.6788896",
"0.6788896",
"0.6785553",
"0.6785553",
"0.67457694",
"0.67144644",
"0.6706012",
"0.6703486",
"0.66981286",
"0.66841745",
"0.6681316",
"0.6676385",
"0.6654866",
"0.6648493",
"0.66329014",
"0.66297996",
"0.66294914",
"0.66294914",
"0.662766",
"0.66088563",
"0.66009384",
"0.65911996",
"0.6590298",
"0.65765005",
"0.65656775",
"0.6559594",
"0.6559014",
"0.65537655",
"0.6553053",
"0.6553053",
"0.65524197",
"0.6549057",
"0.6546212",
"0.6546212",
"0.6533287",
"0.6533103",
"0.6532863",
"0.6532863",
"0.6532863",
"0.6532863",
"0.6532863",
"0.6532863",
"0.6532863",
"0.6532863",
"0.6532863",
"0.6532863",
"0.6532863",
"0.6532863",
"0.6532863",
"0.6531665",
"0.6519662",
"0.6515357",
"0.65033376",
"0.6502319",
"0.64932036",
"0.64925665",
"0.6485604",
"0.6485318",
"0.64827985",
"0.6478406",
"0.6478406",
"0.6478406",
"0.6478406",
"0.6478406",
"0.6478406",
"0.6473532",
"0.6468577",
"0.6468314",
"0.6466349",
"0.64653623",
"0.6465093",
"0.6464134",
"0.6455604",
"0.645134",
"0.645134",
"0.64508754",
"0.6446643",
"0.64451784"
] | 0.76488566 | 4 |
unsing a while loop | def palindrome(string)
result = []
new_string = string.chars
loop do
result << new_string.pop
break if new_string.size == 0
end
result.join
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def while(&block)\n\t\t\t\t\trepeat &block\n\t\t\t\tend",
"def loop; end",
"def while(&blk)\n loop{ !blk[] }\n end",
"def endless_loop?; end",
"def using_while\n\tlevitation_force = 6\n\twhile levitation_force < 10\n puts \"Wingardium Leviosa\"\n levitation_force += 1\n end\nend",
"def using_while\nlevitation_force = 6\nwhile levitation_force < 10\n puts \"Wingardium Leviosa\"\n levitation_force += 1\nend\nend",
"def loop_forever; end",
"def modify_while\n x = 0\n puts x += 1 while x<10\nend",
"def do_while(&blk)\n s = self.ensure_enum\n Enumerator.new do |out|\n while s.has_next?\n break unless blk.call(s.peek)\n out.yield s.next\n end\n end\n end",
"def myloop\n while true\n yield\n end\nend",
"def while_block\n @while_block || nil\n end",
"def while\n\t\t\tprogram = pop\n\t\t\tcond = pop\n\t\t\traise ArgumentError, \"WHILE: first element is not an Array.\" unless cond.is_a? Array\n\t\t\traise ArgumentError, \"WHILE: second element is not an Array.\" unless program.is_a? Array\n\t\t\tsave_stack\n\t\t\t~cond\n\t\t\tres = pop\n\t\t\trestore_stack\n\t\t\tif res then \n\t\t\t\t~program\n\t\t\t\t[cond, program].each {|e| push e }\n\t\t\t\tself.while\n\t\t\tend\n\t\tend",
"def in_while\n return unless block_given?\n @scope.push_while\n result = yield\n @scope.pop_while\n\n result\n end",
"def pre_loop; end",
"def while_stmt \n\t\n\t$cst.add_branch(\"WhileStatement\")\n\t\n\tmatch_token(\"T_WHILE\", $tokens[$index])\n\tboolexpr\n\tblock\n\t\n\t$cst.ascend\n\t\nend",
"def loop\n end",
"def my_loop\n while true\n yield\n end\nend",
"def endless_loop\n loop { yield }\n end",
"def my_while(cond, &body)\n while cond.call\n body.call\n end\nend",
"def loop\n end",
"def loop\n end",
"def setup_while\n return TSBS.error(@acts[0], 2, @used_sequence) if @acts.size < 3\n cond = @acts[1]\n action_key = @acts[2]\n actions = (action_key.class == String ? TSBS::AnimLoop[action_key] :\n action_key)\n if actions.nil?\n show_action_error(action_key)\n end\n begin\n while eval(cond)\n exe_act = actions.clone\n until exe_act.empty? || @break_action\n @acts = exe_act.shift\n execute_sequence\n end\n end\n rescue StandardError => err\n display_error(\"[#{SEQUENCE_WHILE},]\",err)\n end\n end",
"def compilewhile\n\n end",
"def while!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 80 )\n\n type = WHILE\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 201:9: 'while'\n match( \"while\" )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 80 )\n\n end",
"def while_statement\n i = 1\n result = 1\n while i <= 10\n result = result * i\n i += 1\n end\nend",
"def while!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 23 )\n\n type = WHILE\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 325:9: 'while'\n match( \"while\" )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 23 )\n\n end",
"def run\n while 1\n if step == 1 then break end\n end\n end",
"def take_while list, &block\n # your solution here\n list.take_while &block\n \nend",
"def infinite_loop?; end",
"def opn_while\n -> do\n if mem[dp].zero?\n @ff += 1\n elsif @call_stack.last != ip\n @call_stack.push(ip)\n end\n end\n end",
"def func_while(args)\n p1 = car(args)\n p2 = cdr(args)\n\n while _eval(p1) != @o_man.nil\n func_progn(p2)\n end\n\n return @o_man.nil\n end",
"def while!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 46 )\n\n\n\n type = WHILE\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 224:8: 'while'\n match( \"while\" )\n\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 46 )\n\n\n end",
"def check_for_infinite_loop(processed_source, offenses_by_iteration); end",
"def another_main_loop\n t = Thread.new do\n while true\n a = @ios.keys\n ret = select(a,[],a,1)\n if ret.nil?\n @sec.each do |k,v|\n v.call\n end\n else\n r,w,e = ret\n\n remove_queue = Array.new\n\n r.each do |x|\n ret = @ios[x].call(x)\n if ret == false\n remove_queue.push(x)\n end\n end\n\n remove_queue.each do |x|\n puts 'removing ' + x.to_s\n @ios.delete(x)\n end\n \n e.each do |x|\n puts 'error: ' + x.to_s\n raise\n end\n end\n end\n end\n return t\n end",
"def setup_while\n return unless PONY::ERRNO::check_sequence(current_act)\n cond = @acts[1]\n action_key = @acts[2]\n actions = (action_key.class == String ? TSBS::AnimLoop[action_key] : action_key)\n if actions.nil?\n show_action_error(action_key)\n end\n begin\n while eval(cond)\n exe_act = actions.clone\n until exe_act.empty? || @break_sequence\n @acts = exe_act.shift\n execute_sequence\n end\n end\n rescue StandardError => err\n display_error(\"[#{SEQUENCE_WHILE},]\",err)\n end\n end",
"def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\n end # fix\nend",
"def untilFalse firstInput, someProc\n input = firstInput\n output = firstInput\n\n while output\n input = output\n output = someProc.call input\n\n end\n\n input\n\nend",
"def post_loop; end",
"def while_count(num)\n while num >=0\n puts num\n num-=1\n end\nend",
"def take_all\n take_while { true }\n end",
"def destroy_for_reals!(arr)\n arr.pop until arr.empty?\nend",
"def takeWhile(&blk)\n Rubylude.new ->() {\n while value = @generator.resume\n return unless blk.call(value)\n Fiber.yield value\n end\n }\n end",
"def while_loop_function(start)\n i = start\n numbers = []\n loop_limit = 6\n increment = 1\n\n while i < loop_limit\n puts \"At the top i is #{i}\"\n numbers.push(i)\n \n i += increment\n puts \"Numbers now: \", numbers\n puts \"At the bottom i is #{i}\"\n end\n \n puts \"The numbers: \"\n\n numbers.each {|num| puts num }\nend",
"def preloop\n end",
"def foreverize\n loop do\n run\n end\n end",
"def drop_while list, &block\n list.drop_while(&block)\nend",
"def cartman_hates(thing)\nwhile true\n puts \"What's there to hate about #{thing}?\"\n end\nend",
"def wait_while\n while yield\n wait\n end\n end",
"def while!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 22 )\n\n\n\n type = WHILE\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 43:8: 'mientras'\n match( \"mientras\" )\n\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 22 )\n\n\n end",
"def loop\n puts \"Diet Manager 3000!\"\n puts \"Created by Jesse Jurman\"\n check = 1\n while check != 0\n print \"> \"\n check = step\n end\n end",
"def keep_looping?\n true\n end",
"def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\n end\nend",
"def jugando_jugador_1(matriz)\n jugador_1_no_ha_fallado = true\n\n while jugador_1_no_ha_fallado\n jugador_1_no_ha_fallado = turno_jugador_1(matriz)\n end\nend",
"def wait_while\n while yield\n\twait\n end\n end",
"def do_till_false(numbers) \r\n numbers.each do |x|\r\n while numbers.length > 3\r\n numbers.pop\r\n end\r\n end\r\np numbers\r\nend",
"def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\n end\nend",
"def run_while!\n\n before_run\n\n i=1\n\n while yield i do\n\n break if maximum_round? i\n\n before_round i\n\n if i == 1\n # some things are different for the first round, namely nodes with activation = start\n run_first_round!\n else\n run_round!\n end\n\n after_round i\n i+=1\n end\n\n after_run\n\n self\n\n end",
"def while_statement(fn)\n bgn = fn.new_label\n @loop_begin_label = bgn\n match(Token.new(:reserved, 'while'))\n match(Token.new(:symbol, '('))\n fn.code << \"#{bgn}:;\\n\"\n tf = condition_expression(fn)\n @loop_exit_label = tf[1]\n match(Token.new(:symbol, ')'))\n fn.code << \"#{tf[0]}:;\\n\"\n block_statements(fn)\n fn.code << \"goto #{bgn};\\n\"\n fn.code << \"#{tf[1]}:;\\n\"\n\n end",
"def wait_while(cycle)\n while yield\n sleep(cycle)\n end\n end",
"def game_loop\n again = true\n\n while again\n bet\n deal\n player_action\n dealer_action\n reveal_final_hand\n print_player_outcomes\n remove_players\n\n again = play_again?\n linebreak\n end\n\n exit_message\n\n end",
"def test_while_loop\n $i = 1\n $counter = 5\n while $i < $counter do\n assert_equal ($i >= 0), true\n assert_equal ($i < $counter), true\n $i += 1\n end\n end",
"def run()\n while(true)\n cycle() ;\n sleep(2) ;\n end\n end",
"def test_0800_take_while\n @@log.debug \"test_0800_take_while starts\" if @@log.debug?\n assert_respond_to(@list, :take_while, \"test_0800_take_while_respond\")\n # Type check\n enum = @list.take_while\n result = enum.is_a? Enumerator\n assert(result,\"test_0800_take_while_class\") \n # Take while true\n result = @list.take_while {|obj|\n obj == @cab ? false : true\n }\n assert_equal(result, [@aen, @bsb], \"test_0800_take_while_first2\")\n #\n @@log.debug \"test_0800_take_while ends\" if @@log.debug?\n end",
"def loop\n evict_all\n br = get_local\n l = local\n yield(br,l)\n evict_all\n jmp(l)\n local(br)\n end",
"def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\n end\nend",
"def test_hammer_time(r)\n flag = true\n ntime = $ntime_max - 100000\n pair = $result[r].values[0].pairs[0] # just pick one pair ????\n \n while (ntime > 0 and flag)\n # puts ntime\n hammer_row(r, pair[0], pair[1], ntime)\n ntime -= 100000\n end\nend",
"def pausa\n# while line=gets\n while gets\n break\n end\nend",
"def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\n end # Add an \"end\" here\nend",
"def while(sexp, level)\n expr, stmt = sexp\n stmt_level = (level == :expression ? :statement_closure : :statement)\n\n code = \"while (#{process expr, :expression}){\"\n\n in_while { code += process(stmt, :statement) }\n code += \"}\"\n\n if stmt_level == :statement_closure\n code = \"(function() {\\n#{code}})()\"\n end\n\n code\n end",
"def using_until\n levitation_force = 6\n until levitation_force == 10 \n puts \"Wingardium Leviosa\"\n levitation_force += 1 \nend\nend",
"def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\nend\nend",
"def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\nend\nend",
"def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\nend\nend",
"def yield_with_while_loop(array, &block)\n i = 0\n while i < array.length\n yield array[i]\n i += 1\n end\nend",
"def recycle\n recycling = true\n while recycling \n while @total_caps >= 4 \n recycle_caps\n end\n while @empty_bottles >= 2 \n recycle_bottles\n end\n if @empty_bottles < 2 && @total_caps < 4 \n recycling = false\n end\n end\nend",
"def drop_while(arr)\n new_arr = []\n none_false = nil\n for el in arr\n next if (yield el) && none_false.nil?\n\n none_false ||= true\n new_arr << el\n end\n new_arr\nend",
"def virtual_while(&block)\n virtualize_keyword(:while, @while_rewriter, block)\n end",
"def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\nend; end",
"def pop &use\n #Thread.pass while self.empty?\n sleep 0.01 while self.empty?\n self.pop! &use\n end",
"def yield_with_while_loop(array, &block)\n i = 0\n while i < array.length\n block.call(array[i])\n#yield array[i]\ni+=1\nend\nend",
"def loop\n measurement = yield @position\n\n while true do\n position = control measurement\n\n measurement = yield position\n end\n end",
"def process_input_loop\n lines = nil\n while true\n # Only synchronize long enough to copy and clear the input buffer.\n @input_buffer_mutex.synchronize do\n lines = @input_buffer.dup\n @input_buffer.clear\n end\n\n if (lines)\n # Now actually handle the data we copied, secure in the knowledge\n # that our reader thread is no longer going to wait on us.\n while lines.empty? == false\n process_input(lines.shift)\n end\n\n lines = nil\n end\n\n sleep 0.05\n end\n end",
"def print_1_forever\n while true do\n puts 1\n end\nend",
"def using_until\nlevitation_force= 6\nuntil levitation_force == 10 do\n puts \"Wingardium Leviosa\"\n levitation_force += 1\n end\nend",
"def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\n end\nend",
"def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\n end\nend",
"def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\n end\nend",
"def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\n end\nend",
"def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\n end\nend",
"def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\n end\nend",
"def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\n end\nend",
"def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\n end\nend",
"def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\n end\nend",
"def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\n end\nend",
"def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\n end\nend",
"def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\n end\nend",
"def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\n end\nend",
"def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\n end\nend",
"def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\n end\nend",
"def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\n end\nend",
"def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\n end\nend"
] | [
"0.7346873",
"0.68713546",
"0.67927545",
"0.6670351",
"0.6620793",
"0.65875137",
"0.6484291",
"0.64283484",
"0.6363932",
"0.63264674",
"0.6313584",
"0.6262427",
"0.6255061",
"0.6245796",
"0.6233771",
"0.61369324",
"0.612633",
"0.6111101",
"0.61053693",
"0.61007506",
"0.61007506",
"0.6096935",
"0.6078104",
"0.60755223",
"0.60462546",
"0.6026666",
"0.60106844",
"0.6009136",
"0.6005234",
"0.5994704",
"0.5970414",
"0.59699124",
"0.595353",
"0.58868796",
"0.5881298",
"0.58354217",
"0.58302695",
"0.5817452",
"0.579223",
"0.578728",
"0.57290375",
"0.5721614",
"0.56999266",
"0.5696809",
"0.5673818",
"0.5669687",
"0.56687224",
"0.56614125",
"0.5653996",
"0.5629345",
"0.5609502",
"0.55749786",
"0.55645424",
"0.5563957",
"0.5558664",
"0.5536186",
"0.55334514",
"0.55312985",
"0.55310017",
"0.5530546",
"0.552832",
"0.5517139",
"0.5516187",
"0.5516056",
"0.5515758",
"0.5514301",
"0.5510896",
"0.5509922",
"0.54924846",
"0.5488154",
"0.54828894",
"0.54828894",
"0.54828894",
"0.54823804",
"0.54730844",
"0.5465303",
"0.5463598",
"0.5462253",
"0.5458657",
"0.5455569",
"0.54555404",
"0.54496163",
"0.5448489",
"0.5448287",
"0.54481226",
"0.54481226",
"0.54481226",
"0.54481226",
"0.54481226",
"0.54481226",
"0.54481226",
"0.54481226",
"0.54481226",
"0.54481226",
"0.54481226",
"0.54481226",
"0.54481226",
"0.54481226",
"0.54481226",
"0.54481226",
"0.54481226"
] | 0.0 | -1 |
using the times method and pop to quickly iterate the array. | def palindrome(string)
result = Array.new
new_string = string.chars
string.size.times { result << new_string.pop }
result.join
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pop_from_array(arr)\n arr.size.times do\n puts arr.pop\n end\nend",
"def times\n\t\t\tprogram = pop\n\t\t\tn = pop\n\t\t\traise ArgumentError, \"TIMEs: second element is not an Array.\" unless program.is_a? Array\n\t\t\tn.times { ~program.dup }\n\t\tend",
"def pop(time)\n index = bisect_left(@sequence, time)\n \n @sequence.pop(@sequence.size - index)\n end",
"def using_pop(array)\n array.pop()\nend",
"def \n \n using_pop(array)\n \n\n array.pop()\n \nend",
"def pop(time)\n @entries.shift.item if [email protected]? && before_eq(@entries.first.time, time)\n end",
"def using_pop(array)\n array.pop\nend",
"def pop\r\n @arr.shift\r\n end",
"def using_pop(array)\n array.pop\nend",
"def using_pop(array)\n element = array.pop\n element\nend",
"def using_pop(array)\n array.pop\nend",
"def using_pop(array)\n array.pop\nend",
"def using_pop(array)\n array.pop\nend",
"def using_pop(array)\n array.pop\nend",
"def using_pop(array)\n array.pop\nend",
"def using_pop(array)\n array.pop\nend",
"def using_pop(array)\n array.pop\nend",
"def using_pop(array)\n array.pop\nend",
"def using_pop(array)\n array.pop\nend",
"def pop()\n # O(1) time\n @arr.pop\n @min.pop\n end",
"def using_pop (array)\n return array.pop\nend",
"def \n \n pop_with_args(array)\n # {...}(pop_x_times)\n\n\n array.pop(2)\n \n \n #-X-\n # array.pop()\n # array.pop()\n \nend",
"def pop()\n return if @a.empty?\n @a.pop\n @mins.pop\n @min = @mins.last\n end",
"def remove_retrieve_last\n # @array.pop\n @array.slice!(0)\n end",
"def using_pop(arr)\n arr.pop\nend",
"def time\n\talltime = Array.new\n\tslices = 10\n\ti = 0\n\twhile i < slices.to_i do\n\t\talltime.push(Time.now)\n\t\ti+=1\n\tend\n\tyield\nend",
"def pop\n @mut.synchronize{@array.sort!.pop}\n end",
"def pop_from_array(arr)\n l=arr.length\n l.each do\n num=arr.pop\n puts \"#{num} is removed!\"\n end\nend",
"def pop &use\n #Thread.pass while self.empty?\n sleep 0.01 while self.empty?\n self.pop! &use\n end",
"def pop\n @mutex.synchronize do\n traces = @traces\n @traces = []\n\n measure_pop(traces)\n\n return traces\n end\n end",
"def using_pop(array)\n array = array.pop(1)\n array.pop\n\n\nend",
"def times()\n \t\terror?\n \t\t@stack << (@stack.pop * @stack.pop)\n end",
"def pop_next_available\n unused_entries = []\n result = nil\n while (entry = pop)\n if entry.run_at <= Time.now\n result = entry\n break\n else\n unused_entries << entry\n end\n end\n unused_entries.each {|e| push(e) }\n result\n end",
"def pop\n traces = @traces.pop(VERY_LARGE_INTEGER)\n\n measure_pop(traces)\n\n traces\n end",
"def destroy_for_reals!(arr)\n arr.pop until arr.empty?\nend",
"def pop()\n v, _ = @array.pop\n v\n end",
"def pop\n @a.pop\n end",
"def mutate(arr)\n arr.pop\n end",
"def mutate(array)\n array.pop \nend",
"def rm_index\n\tarray = [0, 2, 4, 6, 8]\n\twhile array.length > 2\n\t\tputs array.pop\n\tend\nend",
"def next_times(count)\n\n next_time ? [ next_time ] : []\n end",
"def remove_item(array, num_items)\n while array.length > num_items\n array.pop\n end\n array\nend",
"def remove_times(event)\n\t\tevent.times.each do |t|\n\t\t\tif t[1].to_i-t[0].to_i < event.length\n\t\t\t\tevent.times.delete(t)\n\t\t\tend\n\t\tend\n\tend",
"def mutate(array)\n array.pop\nend",
"def mutate(array)\n array.pop\nend",
"def mutate(array)\n array.pop\nend",
"def mutate(array)\n array.pop\nend",
"def mutate(array)\n array.pop\nend",
"def mutate(array)\n array.pop\nend",
"def mutate(array)\n array.pop\nend",
"def mutate(array)\n array.pop\nend",
"def mutate(array)\n array.pop\nend",
"def mutate(array)\n array.pop\nend",
"def * times\n result = self.slice 0, 0\n frames = self.slice 0..-1\n times.times do\n result.concat frames\n end\n result\n end",
"def remove_item(elective_array)\n elective_array.pop\n puts elective_array\nend",
"def pop\n @tape.pop()\n end",
"def each_pop(options = {}, &block) #:yields: QueuePop\n while _pop = pop(options)\n yield _pop\n end\n end",
"def pop; end",
"def pop; end",
"def pop; end",
"def pop; end",
"def pop; end",
"def repeat(item, times)\n\tarr = []; arr += [item] * times; return arr\nend",
"def pop_with_args(array)\n array.pop(2)\n end",
"def delete_every_2(array)\n end",
"def pop\n delete_at(0)\n end",
"def test_mutate_array_pop\n numbers = [1, 2, 3, 4]\n output = capture_io do\n numbers.each do |number|\n p number\n numbers.pop(1)\n end\n end\n assert_equal [\"1\\n2\\n\", \"\"], output\n assert_equal [1, 2], numbers\n=begin\nthis follows the same pattern as the last example but since\nelements are take from the back end of the array, the first\ntwo p statement do print the first two elements of the array.\nafter 2 pop operations the array index exceeds the index of\nthe last element in the array.\n=end\n end",
"def pop\r\n # What does array.pop do? It takes the last \r\n # item of a list. We want this method to return\r\n # the last item. So maybe we can do something like:\r\n # return @data.last\r\n end",
"def pop()\n @size -= 1 \n @queue.shift\n end",
"def pop() end",
"def pop\n if @count > 0\n last_item_index = @count - 1\n\n # stores last element\n last_item = @items[last_item_index]\n\n # remove last item from array\n @items[last_item_index] = nil\n\n # reduces size by 1\n @count -= 1\n\n last_item\n else\n raise \"There are no items in the stack\"\n end\n end",
"def repeat(item, times)\n\treturn_array = []\n\ttimes.times { return_array.push(item) }\n\treturn_array\nend",
"def substracted_array(array)\n sub_array = array.clone\n\n (sub_array.length).step(0, -1) do |i|\n sub_array[i] -= 9 if sub_array[i] > 9\n end \n\n sub_array\n end",
"def fire(time)\n pop(time).reverse_each do |handle|\n handle.fire(time)\n end\n end",
"def reverse_array(array)\n output = []\n (array.length).times do |_|\n output << array.pop \n end\n output\nend",
"def pop_with_args(array)\narray = array.pop(2)\narray.pop(2)\nend",
"def pop \r\n @data.pop\r\n end",
"def fire(time)\n pop(time).reverse_each do |handle|\n handle.fire(time)\n end\n end",
"def pop\n end",
"def next_time_slots\n\t\ttime_slot_array = self.timeslots\n\t\ttime_slot_array.drop_while do |x|\n\t\t\tx[0].split(\"-\")[0].to_time < Time.now\n\t\tend\n\tend",
"def pop()\n \n end",
"def pop()\n \n end",
"def pop()\n \n end",
"def my_times\n\t\tfor i in 1..self\n\t\t\tyield\n\t\tend\n\tend",
"def take(array, index=1)\n p array.drop(index)\nend",
"def pop()\n (@arr1.size-1).times { @arr2.push(@arr1.shift) }\n result = @arr1.shift\n @arr1, @arr2 = @arr2, @arr1\n result\n end",
"def clear\n loop do\n @data.each { |key, val|\n if val['time'] <= Time.now.to_i\n @data.delete(key) \n p 'Remove: ' + key\n end\n }\n\n sleep(5) \n end\n end",
"def no_mutate(array)\n\tarray.last\nend",
"def reverse(array)\n new_array = []\n array.length.times do \n new_array << array.pop\n end\n new_array\nend",
"def pop_with_args(array)\n array = array.pop(2)\n array.pop(2)\n \nend",
"def fire(time)\n\t\t\tmerge!\n\t\t\t\n\t\t\twhile handle = @sequence.peek and handle.time <= time\n\t\t\t\[email protected]\n\t\t\t\thandle.fire(time)\n\t\t\tend\n\t\tend",
"def pop()\n @data.pop\n end",
"def pop\n raise 'No such element' if @elements.length == 0\n @elements.slice!(-1)\n end",
"def each_pop #:yields: popped\n until empty?\n yield pop\n end\n nil\n end",
"def mutate(arr)\n arr.pop # => 6\nend",
"def drop_while(array)\n index = 0\n while index < array.size && yield(array[index])\n index += 1\n end\n array[index..-1]\n end",
"def delete\n @array_roses.pop\nend",
"def cut_down\n until @zombie_apocalypse_supplies.length <= 5\n @zombie_apocalypse_supplies.pop\nend\np @zombie_apocalypse_supplies\nend",
"def remove_element_from_end_of_array(array)\n array.pop\nend",
"def remove_element_from_end_of_array(array)\n array.pop\nend",
"def take (arr, index = 1)\n arr.drop(index)\n end"
] | [
"0.70497787",
"0.6836621",
"0.67655873",
"0.64888424",
"0.64249843",
"0.64110243",
"0.63647074",
"0.6362134",
"0.6361268",
"0.63419086",
"0.63011676",
"0.63011676",
"0.63011676",
"0.63011676",
"0.63011676",
"0.63011676",
"0.63011676",
"0.63011676",
"0.63011676",
"0.6298405",
"0.62732244",
"0.6267714",
"0.61714596",
"0.60796195",
"0.6068906",
"0.60579467",
"0.60517937",
"0.6048079",
"0.60386723",
"0.6008634",
"0.5991441",
"0.59525067",
"0.59490967",
"0.5931992",
"0.59273773",
"0.5902437",
"0.58960754",
"0.58856046",
"0.58638924",
"0.5832455",
"0.5826709",
"0.57943964",
"0.5793775",
"0.5772197",
"0.5772197",
"0.5772197",
"0.5772197",
"0.5772197",
"0.5772197",
"0.5772197",
"0.5772197",
"0.5772197",
"0.5772197",
"0.57461476",
"0.5685148",
"0.5672216",
"0.56297266",
"0.5628753",
"0.5628753",
"0.5628753",
"0.5628753",
"0.5628753",
"0.561079",
"0.5609319",
"0.5606583",
"0.5589224",
"0.55865955",
"0.5578733",
"0.55745155",
"0.5568587",
"0.55543345",
"0.5551671",
"0.55445176",
"0.55375385",
"0.55348396",
"0.5473774",
"0.5466276",
"0.546614",
"0.5458318",
"0.5455689",
"0.5428619",
"0.5428619",
"0.5428619",
"0.5427814",
"0.5423654",
"0.5417666",
"0.54136395",
"0.54089564",
"0.5394438",
"0.5387705",
"0.5380245",
"0.5378852",
"0.5369235",
"0.5364973",
"0.53630066",
"0.53570473",
"0.53534245",
"0.5334677",
"0.53307194",
"0.53307194",
"0.5321944"
] | 0.0 | -1 |
using times method as well as delete_at to remove last item from array. | def palindrome(string)
result = Array.new
new_string = string.chars
string.size.times { result << new_string.delete_at(-1) }
result.join
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_retrieve_last\n # @array.pop\n @array.slice!(0)\n end",
"def remove_times(event)\n\t\tevent.times.each do |t|\n\t\t\tif t[1].to_i-t[0].to_i < event.length\n\t\t\t\tevent.times.delete(t)\n\t\t\tend\n\t\tend\n\tend",
"def pop(time)\n @entries.shift.item if [email protected]? && before_eq(@entries.first.time, time)\n end",
"def pop(time)\n index = bisect_left(@sequence, time)\n \n @sequence.pop(@sequence.size - index)\n end",
"def delete_every_2(array)\n end",
"def remove(element, new_time)\n @remove_set[element] = new_time.to_i\n self\n end",
"def remove_element_from_end_of_array(array)\n array.pop\nend",
"def remove_element_from_end_of_array(array)\n array.pop\nend",
"def using_delete_at(array,integer)\n array.delete_at(integer)\n end",
"def remove_element_from_end_of_array(array)\n return array.pop\nend",
"def using_delete_at(array, num)\n array.delete_at(num)\nend",
"def using_delete_at(array, num)\n array.delete_at(num)\nend",
"def using_delete_at (array,integer)\n array.delete_at(integer)\nend",
"def using_delete_at(array, index)\n array.delete_at(index)\nend",
"def using_delete_at (array, integer)\n return array.delete_at(integer)\nend",
"def using_delete_at(array, index)\n array.delete_at(index)\nend",
"def using_delete_at(arr, i)\n arr.delete_at(i)\nend",
"def using_delete_at(arr, index)\n arr.delete_at(index)\nend",
"def remove_from_end(arr)\n arr.pop\nend",
"def using_delete_at(array, integer)\n \n array.delete_at(integer)\n \nend",
"def remove_item(array, num_items)\n while array.length > num_items\n array.pop\n end\n array\nend",
"def using_delete_at(array, integer)\n array.delete_at(integer)\nend",
"def using_delete_at(array, integer)\n array.delete_at(integer)\nend",
"def delete_stop_by_index(stops_array, stop_to_delete)\n index_of_stop = find_index_of_stop(stops_array, stop_to_delete)\n stops_array.delete_at(index_of_stop)\n return stops_array\nend",
"def end_arr_delete(arr)\n # delete the element from the end of the array and return the deleted element\n arr.pop\nend",
"def delete\n @array_roses.pop\nend",
"def remove_by_index(index)\n @items.delete_at(index-1)\n end",
"def no_mutate(array)\n array.last #returns array with last item removed, no mutation of array\nend",
"def end_arr_delete(arr)\n # delete the element from the end of the array and return the deleted element\n return arr.pop\nend",
"def using_delete_at(array, integer)\n deleted_robot = array.delete(array[integer])\nend",
"def using_delete_at(array, int)\n array.delete_at(int)\nend",
"def using_delete_at(array, int)\n array.delete_at(int)\nend",
"def delete_at n\n self.slice! n\n end",
"def remove_item(elective_array)\n elective_array.pop\n puts elective_array\nend",
"def check_single_calling_core(time_between)\n time_between.delete_at(0)\n time_between = [0] if time_between == []\n time_between\nend",
"def using_delete_at(array,integer)\n array.delete(array[integer])\nend",
"def delete_last()\n \n end",
"def delete_max\n return -1 if @count == 0\n data = @array[0]\n @array[0] = @array.pop\n @count = @array.size\n percolate_down(0)\n data\n end",
"def delete_at_arr(arr, index)\n # delete the element at the position #index\n return arr.delete_at(index)\nend",
"def exclude_last(arr)\n arr.slice!(arr.length-1,1)\n return arr\n end",
"def remove_at(idx)\n @todos.delete(item_at(idx))\n end",
"def destroy_for_reals!(arr)\n arr.pop until arr.empty?\nend",
"def remove_item_at(index)\n @list.slice!(index)\n end",
"def randRemove(array)\n array.delete array.sample\nend",
"def remove(item)\n # TODO\n # - removes first occurence of `item` in list.\n # - uses '==', so beware if expecting eql? or equals? logic instead\n # - shifts element in array to fill in spot\n\n ([email protected]).each do |i|\n if @array[i] == item\n @array[i] = nil\n\n # TODO\n # - consider resizing array if load is under some threshold (maybe 0.25?)\n\n shift_elements\n break\n end\n end\n\n end",
"def array_remove_at(array, index)\n if index<0 || index>=array.length\n return array\n end\n return array.slice(0,index) + array.slice(index+1,array.length)\n end",
"def remove_element_from_start_of_array(array)\n array.shift\nend",
"def remove_element_from_start_of_array(array)\n array.shift\nend",
"def pop_next_available\n unused_entries = []\n result = nil\n while (entry = pop)\n if entry.run_at <= Time.now\n result = entry\n break\n else\n unused_entries << entry\n end\n end\n unused_entries.each {|e| push(e) }\n result\n end",
"def test_delete_arbitrary_repetion_from_array3\n a = [2, 2, 2, 1, 5]\n a = a.each{|n|\n 3.times{a.delete_at(a.index(n))} if a.count(n) >= 3\n }.reject{|i|\n i == 1 or i == 5\n }\n assert_equal [], a\n end",
"def start_arr_delete(arr)\n # delete the element at the beginning of the array and return the deleted element\n return arr.shift\nend",
"def remove_time\n ticket_time = [self.ticket.actual_time - self.time, 0].max\n self.ticket.update_column :actual_time, ticket_time\n end",
"def exclude_last (array)\n array[0..-2]\nend",
"def cleanup\n redis.zremrangebyscore(key, '-inf', time - timespan)\n end",
"def random_item (array)\n item_index = rand(0...array.length)\n array[item_index]\n array.delete_at(item_index)\nend",
"def test_last_three\n array = [1,2,3,4,5]\n array = array.last(3)\n assert_equal [3,4,5], array\n end",
"def remove_items(arr)\n counter = arr.length\n new_array = []\n arr.each do |item|\n if new_array.length < 5\n new_array << item\n counter -= 1\n end\n end\n new_array\nend",
"def delete_finals(arr)\n arr[0..4]\nend",
"def delete_at(index)\t\n\t\tif index==1\n\t\t\t@first = tmp.front\n\t\t\[email protected] = nil\n\t\telsif @length==index\n\t\t\tpop;\n\t\telse\n\t\t\ttmp = get(index)\n\t\t\ttmp.back.front = tmp.front \n\t\t\ttmp.front.back = tmp.back\n\t\tend\n\t\t@length-=1\n\tend",
"def no_mutate(array)\n\tarray.last\nend",
"def watch_movie (array)\n array.delete(\"Minions\")\n array\nend",
"def delete_matches(to_delete, array)\n to_delete = to_delete.reverse # so indexes don't shift down as items are being deleted\n to_delete.each do |num|\n array.delete_at(num)\n end\n array\n end",
"def remove\n @instantiations.dup.each(&:remove)\n @instantiations[0..-1] = []\n true\n end",
"def pop\n delete_at(0)\n end",
"def delete_at(index)\n return nil if index >= @size || index < 0\n element = self[index]\n if direct_index = @map[index]\n @added.delete_at(direct_index)\n @map.delete(index)\n @map.keys.sort.each do |key|\n if key > index\n value = @map.delete(key)\n value -= 1 if value > direct_index\n @map[key-1] = value\n else\n if (value = @map[key]) > direct_index\n @map[key] -= 1\n end\n end\n end\n else\n lazy_index = lazy_index(index)\n position = @deleted.bsearch_upper_boundary{|e| e <=> lazy_index }\n @deleted.insert(position,lazy_index)\n @map.keys.sort.each do |key|\n if key > index\n @map[key-1] = @map.delete(key)\n end\n end\n end\n #@commands << [:delete,[index]]\n @size -= 1\n element\n end",
"def delete_at (i)\n\n outlen_op(:tclistremove, i)\n end",
"def delete_at(i)\n\t\[email protected]_at i\n\tend",
"def remove_element_from_start_of_array(array)\n return array.shift\nend",
"def clear\n loop do\n @data.each { |key, val|\n if val['time'] <= Time.now.to_i\n @data.delete(key) \n p 'Remove: ' + key\n end\n }\n\n sleep(5) \n end\n end",
"def my_array_deletion_method!(source, thing_to_delete)\n\n indexChange = 0\n for x in 0..(source.length - 1)\n sourceString = source[x - indexChange].to_s\n\n if sourceString.include? thing_to_delete\n source[x - indexChange,source.length] = source[x + 1 - indexChange, source.length]\n indexChange = indexChange + 1\n end\n end\n # p source\n return source\nend",
"def my_but_last(array)\n\tarray.size - 1\nend",
"def remove_item(electives)\n electives.pop #removes last item\n puts electives\nend",
"def exclude_last(arr)\n arr[0..-2]\n end",
"def delete_at(p0) end",
"def rm_index\n\tarray = [0, 2, 4, 6, 8]\n\twhile array.length > 2\n\t\tputs array.pop\n\tend\nend",
"def delete_item(index)\n LIST.delete_at(index)\nend",
"def remove_time_slot\n\n end",
"def take (arr, index = 1)\n arr.drop(index)\n end",
"def any_time\n times(-1)\n end",
"def no_mutate(array)\n array.last #returns the last element of the array but does not actually permanently modify the array in any way\nend",
"def eliminar_ult_elem_arr(arreglo)\n arreglo.pop\n arreglo\nend",
"def remove(a, value)\n write_index = 0\n occurences = 0\n 0.upto(a.length-1).each {|i|\n if a[i] == value\n occurences += 1\n else\n a[write_index] = a[i]\n write_index += 1\n end\n }\n\n return a[0, a.length - occurences]\nend",
"def unsafe_forget_past!\n slices.values.map(&:history).each{|h| h.recent(memory_size)}\n\n if multi_slices?\n to_delete = slices.values.reject{|s| keep_slice?(s)}\n to_delete.map(&:rack_id).map do |rack_id| \n slices.delete(rack_id)\n end\n end\n end",
"def remove\n return @exact.shift unless @exact.empty?\n @list.shift\n end",
"def remove_first(array)\n array.delete_at(0)\n array\nend",
"def pop_from_array(arr)\n l=arr.length\n l.each do\n num=arr.pop\n puts \"#{num} is removed!\"\n end\nend",
"def pop_from_array(arr)\n arr.size.times do\n puts arr.pop\n end\nend",
"def next_time_slots\n\t\ttime_slot_array = self.timeslots\n\t\ttime_slot_array.drop_while do |x|\n\t\t\tx[0].split(\"-\")[0].to_time < Time.now\n\t\tend\n\tend",
"def no_mutate(array)\n array.last\nend",
"def no_mutate(array)\n array.last\nend",
"def no_mutate(array)\n array.last\nend",
"def no_mutate(array)\n array.last\nend",
"def no_mutate(array)\n array.last\nend",
"def pop()\n return if @a.empty?\n @a.pop\n @mins.pop\n @min = @mins.last\n end",
"def my_array_deletion_method!(source, thing_to_delete)\n source.dup\ndel=[]\nsource.each do |item|\n if item.is_a? Integer\n del << item\n next\n elsif item.include?(thing_to_delete)\n next\n else\n del << item\n end\n end\n return source=del\nend",
"def delete_item(unwanted)\r\n @arr.delete(unwanted)\r\n end",
"def delete(array, length, value_to_delete)\r\n i = 0;\r\n while i < array.length\r\n if array[i] == value_to_delete\r\n spaces = (array.length - 1) - i;\r\n moved = 0;\r\n until moved == spaces\r\n array[i] = array[i+1];\r\n i++;\r\n moved++;\r\n end\r\n array[array.length - 1] = 'SPECIAL_VALUE';\r\n end\r\n i++;\r\n end\r\nend",
"def delete(arr,index)\n # res = arr.clone;\n res = arr[0,index] + arr[index+1,arr.size-(index+1)];\n return res;\nend",
"def mutate(array)\n array.pop \nend",
"def using_pop(array)\n array.pop()\nend",
"def deleting(arr, min, max)\n arr.delete(min)\n arr.delete(max)\n arr\n end"
] | [
"0.67091775",
"0.6673182",
"0.6656268",
"0.6628504",
"0.64877486",
"0.64794046",
"0.6456301",
"0.6456301",
"0.630479",
"0.62594247",
"0.62507254",
"0.62507254",
"0.6231363",
"0.62235665",
"0.62207985",
"0.62206256",
"0.62171066",
"0.6160276",
"0.6159519",
"0.6153257",
"0.6144198",
"0.61287576",
"0.61287576",
"0.6117434",
"0.6100001",
"0.60903406",
"0.60836375",
"0.6069823",
"0.6057074",
"0.60295606",
"0.6026049",
"0.6019877",
"0.60033065",
"0.60013384",
"0.59612906",
"0.59489554",
"0.5933283",
"0.5930421",
"0.5928922",
"0.59234893",
"0.59069484",
"0.58651173",
"0.58578306",
"0.58572906",
"0.58497804",
"0.5849306",
"0.58480084",
"0.58480084",
"0.5844233",
"0.5839213",
"0.5837953",
"0.57980484",
"0.5773837",
"0.57599056",
"0.57369435",
"0.5725701",
"0.5725471",
"0.57225335",
"0.5719788",
"0.5695745",
"0.5694425",
"0.5685541",
"0.5685333",
"0.567398",
"0.56698364",
"0.5661234",
"0.5656935",
"0.56533486",
"0.5644409",
"0.56420434",
"0.56315196",
"0.5626001",
"0.56090236",
"0.55982596",
"0.5597649",
"0.5558943",
"0.5558941",
"0.5558897",
"0.5550506",
"0.55450076",
"0.55376124",
"0.55329657",
"0.5527448",
"0.5514136",
"0.5503378",
"0.55016327",
"0.5500313",
"0.54983985",
"0.5497413",
"0.5497413",
"0.5497413",
"0.5497413",
"0.5497413",
"0.5492799",
"0.5489394",
"0.54807955",
"0.5479943",
"0.5476362",
"0.54684556",
"0.54665214",
"0.546383"
] | 0.0 | -1 |
GET /products/1 GET /products/1.json | def show
@category = Category.find(params[:category_id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def product(name)\n get(\"/apiproducts/#{name}\")\n end",
"def show\n product = Product.find_by_id(params[:id])\n\n render json: product\n end",
"def show\n @product = Product.find(params[:id])\n\n render json: @product\n end",
"def index\n @api_v1_products = Product.all\n json_response(@api_v1_products)\n end",
"def show\n @product = Product.find(params[:id])\n json_response(params)\n end",
"def get_products()\n\tputs \"Getting products\"\n\tresponse = request_get(\"/api/product\")\n\tputs response.body\nend",
"def show\n @product = Product.find(params[:id])\n render json: @product, status: :ok\n end",
"def show\n result = Product.find(params[:id])\n render json: {\n status: :ok,\n product: result\n } \n end",
"def show\n @products = Product.find_by_id(params[:id])\n msg = { status: 200 , product: @products }\n respond_to do |format|\n format.html { render json: msg }\n format.json { render json: msg }\n end\n end",
"def index\n @products = Product.all\n render json: @products\n end",
"def show\n render json: @product, status: 200\n end",
"def show\n @product = Product.find(params[:id])\n\n render json: @product\n end",
"def show\n json_response(@api_v1_product)\n end",
"def index\n @products = Product.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @products }\n end\n end",
"def index\n @products = Product.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @products }\n end\n end",
"def index\n @products = Product.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @products }\n end\n end",
"def index\n @products = Product.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @products }\n end\n end",
"def show\n render :json => Producto.find(params[:id])\n end",
"def index\n begin\n @products = Product.all\n render json: @products, status: 200\n rescue => exception\n render json: { errors: exception }\n end\n end",
"def show\n @product = ProductProduct.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end",
"def show\n render json: @product\n end",
"def index\n \tproducts = Product.all\n \trender json: products\n \tend",
"def products\n request :public, :get, :products\n end",
"def show\n @product = Product.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end",
"def index\n @products = Product.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @products }\n end\n end",
"def index\n @products = Product.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @products }\n end\n end",
"def index\n @products = Product.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @products }\n end\n end",
"def index\n @products = Product.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @products }\n end\n end",
"def show\n render json: @product\n end",
"def show\n @product = Product.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end",
"def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end",
"def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end",
"def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end",
"def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end",
"def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end",
"def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end",
"def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end",
"def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end",
"def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end",
"def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end",
"def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end",
"def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end",
"def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end",
"def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end",
"def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end",
"def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end",
"def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end",
"def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end",
"def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end",
"def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end",
"def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end",
"def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end",
"def index\n @products = Product.all\n respond_to do |format|\n format.html\n format.json { render :json => @product }\n end\n end",
"def show\n @product = @person.products.find(params[:id])\n\n respond_to do |format|\n format.json { render :json => @product }\n end\n end",
"def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @product }\n end\n end",
"def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @product }\n end\n end",
"def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @product }\n end\n end",
"def show\n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json=> @product }\n end\n end",
"def index\n @products = Product.all\n msg = { status: 200 , product: @products }\n respond_to do |format|\n format.html { render json: msg }\n format.json { render json: msg }\n end\n end",
"def index\n @products = Product.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @inventories }\n end\n end",
"def index\n @products = @user.products\n # was @products = Product.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @products }\n end\n end",
"def index\n limit = params[:limit]&.to_i || 10\n page = params[:page]&.to_i || 0\n if params[:available] == \"1\"\n @products = Product.paginate(page, limit).available\n else\n @products = Product.paginate(page, limit)\n end\n render json: @products\n end",
"def index\n render :json => Producto.all\n end",
"def show\n respond_to do |format|\n format.html\n format.json { render :json => @product }\n end\n end",
"def show\n puts \"the params are #{params}\" \n @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end",
"def getKind\n @products = Product.where(\"kind = ?\", params[:kind]).available.PriceOrder.paginate(page: params[:page], per_page: 5)\n render json: @products\n end",
"def show\n @product_item = ProductItem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @product_item }\n end\n end",
"def index\n @food_products = FoodProduct.all\n render json: @food_products\n end",
"def index\n #@products = Product.all\n @products = Product.paginate( :page => params[:page],\n :per_page => 40\n )\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @products }\n end\n end",
"def index\n @ordered_products = OrderedProduct.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ordered_products }\n end\n end",
"def index\n products = Product.all\n render json: {message: \"ok\", data: products}\n puts \"hello\"\n\n end",
"def user_products\n @products = current_user.products\n\n respond_to do |format|\n format.html\n format.json { render json: @products }\n end\n end",
"def show\n @shopifyproduct = Shopifyproduct.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @shopifyproduct }\n end\n end",
"def show\n @product = @user.products.find(params[:id])\n # was @product = Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end",
"def show\n @ordered_product = OrderedProduct.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ordered_product }\n end\n end",
"def show\n @products = Product.find(params[:id])\n end",
"def index\n @products = Product.order('item_code ASC').page(params[:page]).per(25)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @products }\n end\n end",
"def index\n if is_my_resource(params[:prossumer_id])\n @products = Product.where(prossumer_id: params[:prossumer_id]).as_json({\n cycle_id: params[:cycle_id],\n include: {\n prossumer: {\n except: [:encrypted_password, :salt, :confirm_hash]\n },\n product_category: {}\n }\n })\n render json: @products\n end\n end",
"def get_product\n json_response({ message: 'NOT IMPLEMENTED' })\n end",
"def show\n @onecompany_product = Onecompany::Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @onecompany_product }\n end\n end",
"def index\n @tipo_products = TipoProduct.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tipo_products }\n end\n end",
"def index\n begin\n \n products = Product.all\n render json: {\n success: true,\n totalRecords: products.length,\n data: (ActiveModel::ArraySerializer.new(products, each_serializer: ProductSerializer))\n }, status: 200\n rescue ActiveRecord::RecordNotFound => e\n render json: {\n success: false,\n errors: e.message\n }, status: 404\n rescue Exception => e\n render json: {\n success: false,\n errors: e.message\n }, status: 500\n end\n end",
"def index\n @products = Product.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @products }\n format.json { render :json => @products }\n end\n end",
"def index\n @products = Product.all\n render json: {is_success: true, error_code: 200, message: \"Products Found Successfully\", result: @products}, status: 200\n end",
"def show\n render json: @product_management\n end",
"def show\n @product2 = Product2.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product2 }\n end\n end",
"def index\n #@products = Product.all\n @products = Product.order('created_at ASC').page(params[:page]).per(12)\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @products }\n end\n end",
"def index\n @product_images = ProductImage.where(product_uuid: params[:product_id])\n render json: @product_images, status: 200\n end",
"def show\n @prod = Prod.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @prod }\n end\n end",
"def set_api_v1_product\n begin\n @api_v1_product = Product.find(params[:id])\n rescue => ex\n json_response({error: ex.message}, :not_found)\n end\n end",
"def getProduct( product_id)\n params = Hash.new\n params['product_id'] = product_id\n return doCurl(\"get\",\"/product\",params)\n end",
"def show\n respond_to do |format|\n format.html {render \"products/show\"}\n format.json {\n product = Product.where(id: params[:id]).includes(:category).first\n render json: product.as_json(include: [:category, :photo])\n }\n end\n end",
"def show\n @items = cart.items\n @products = @items.collect(&:product)\n \n respond_to do |format|\n format.html { render layout: false } \n format.json { render json: @items }\n end\n end",
"def show\n @star_product = Star::Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @star_product }\n end\n end",
"def show\n render json: @food_product\n end",
"def show\n @producto = Producto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @producto }\n end\n end",
"def show\n # is_my_resource(params[:id])\n\n # prossumerProductsIds = Prossumer.find(params[:id]).products.ids\n render json: ProductAuth.where({product_id: params[:id], group_id: params[:group_id]}).first.as_json(:include => :product)\n end",
"def show\n @home_searches_product = Home::Searches::Product.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @home_searches_product }\n end\n end",
"def show\n @magento_product = MagentoProduct.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @magento_product }\n end\n end",
"def show\n @product_price = ProductPrice.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product_price }\n end\n end",
"def show\n @prod = Prod.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @prod }\n end\n end"
] | [
"0.77224106",
"0.76329553",
"0.76313764",
"0.7607208",
"0.75760156",
"0.7552171",
"0.7506385",
"0.7484625",
"0.745622",
"0.74501616",
"0.74376804",
"0.7421124",
"0.7362056",
"0.7318765",
"0.73185545",
"0.73185545",
"0.73185545",
"0.7316062",
"0.7311976",
"0.73088664",
"0.72941",
"0.729187",
"0.7291441",
"0.7276286",
"0.7272662",
"0.7272662",
"0.7272662",
"0.7272662",
"0.72700304",
"0.7255538",
"0.7233478",
"0.72326964",
"0.72326964",
"0.72326964",
"0.72326964",
"0.72326964",
"0.72326964",
"0.72326964",
"0.72326964",
"0.72326964",
"0.72326964",
"0.72326964",
"0.72326964",
"0.72326964",
"0.72326964",
"0.72326964",
"0.72326964",
"0.72326964",
"0.72326964",
"0.72326964",
"0.72326964",
"0.7232629",
"0.7211553",
"0.7191871",
"0.71728355",
"0.71728355",
"0.71728355",
"0.717033",
"0.71582985",
"0.7140302",
"0.70848453",
"0.7072449",
"0.70673674",
"0.706432",
"0.7038531",
"0.7004358",
"0.69840044",
"0.69693065",
"0.6968406",
"0.6964786",
"0.6959802",
"0.695388",
"0.6943222",
"0.69415545",
"0.6939184",
"0.6928706",
"0.69022006",
"0.6888529",
"0.68479115",
"0.6837828",
"0.683746",
"0.6822597",
"0.6821544",
"0.6817213",
"0.68145454",
"0.6811117",
"0.67925274",
"0.678835",
"0.6788051",
"0.67867345",
"0.67776203",
"0.6769408",
"0.67637855",
"0.6759666",
"0.6751121",
"0.67510307",
"0.6748587",
"0.6746096",
"0.6745283",
"0.67408913",
"0.6733844"
] | 0.0 | -1 |
POST /products POST /products.json | def create
@category = Category.find(params[:category_id])
@product = Product.new(product_params)
@product.category_id = params[:category_id]
respond_to do |format|
if @product.save
binding.pry
UserMailer.send_email(@product.name,current_user).deliver
flash[:notice] = t('prod_message_create')
format.html { redirect_to category_products_path }
format.json { render :show, status: :created, location: @product }
else
format.html { render :new }
format.json { render json: @product.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @product = Product.new(product_args)\n\n if @product.save\n render json: Product.all, status: :created\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end",
"def create\n if params[:products]\n params[:products].each do |product|\n @product = Product.new(name: product[:name],\n brand: product[:brand],\n model: product[:model],\n sku: product[:sku],\n price: product[:price],\n desc: product[:desc])\n if [email protected]\n render json: @product.errors.full_messages, status: 422\n end\n end\n render 'api/products/index'\n else\n @product = Product.new(product_params)\n if @product.save\n render 'api/products/show'\n else\n render json: @product.errors.full_messages, status: 422\n end\n end\n end",
"def create\n @product = Product.new(product_params)\n\n if @product.save\n render json: @product, status: :created, location: @product\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end",
"def create\n @product = @collection.products.build(product_params)\n\n if @product.save\n render json: @product, status: :created#, location: @collection\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end",
"def create\n @product = Product.new(product_params)\n\n if @product.save\n render json: @product, status: :created\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end",
"def create\n @product = Product.create!(product_params)\n json_response(@product, :created)\n end",
"def create\n newProduct = Product.new(products_params)\n if newProduct.save\n msg = { status: 201 , product: newProduct }\n respond_to do |format|\n format.html { render json: msg }\n format.json { render json: msg }\n end\n else\n msg = { status: 422 }\n respond_to do |format|\n format.html { render json: msg }\n format.json { render json: msg }\n end\n end\n end",
"def create\n @product = Product.new(product_params)\n\n if @product.save\n render json: @product, status: :created, location: @product\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end",
"def create\n\n product_details = params.permit(:title, :inventory_count, :price)\n success = Product.create(product_details)\n\n render json: { success: success }\n end",
"def create\n @product = Product.new(product_params)\n\n if @product.save\n render json: @product, status: :created\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end",
"def create\n product = Product.new(product_params)\n if product.save\n render json: ProductSerializer.new(product).serialized_json\n end\n end",
"def create\n @product = Product.new(product_params)\n if @product.save\n render json: {id: @product.id}\n else\n render json: {msg: @product.errors.full_messages.first}, status: :unprocessable_entity\n end\n end",
"def create\n @product = Product.create(product_params)\n if @product.save\n # Respond to html with a redirect and json\n respond_to do |format|\n format.html do\n flash[:notice] = 'Product added'\n redirect_to products_path\n end\n format.json do\n render json: product.to_json\n end\n end\n else\n # Respond to html with a redirect and json\n respond_to do |format|\n format.html do\n flash.now[:error] = 'Error adding product'\n render :new\n end\n format.json do\n render json: { errors: @product.errors.full_messages }, status: 422\n end\n end\n end\n end",
"def create\n @product = Product.new(product_params)\n @product.user = current_api_v1_user\n respond_to do |format|\n if @product.save\n params[:product][:properties].try(:each) do |k,v|\n @product.product_properties.create(property: Property.find(k), value: v)\n end\n params[:product][:colors].try(:each) do |c|\n @product.colors.create(name: c[:name].downcase, code: c[:code])\n end\n params[:product][:photos].try(:each) do |c|\n @product.photos.create(image: c)\n end\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created}\n else\n format.html { render :new }\n format.json { render json: @product.errors.full_messages, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product,\n :notice=> 'Product was successfully created.' }\n format.json { render :json=> @product, :status=> :created,\n :location=> @product }\n else\n format.html { render :action=> \"new\" }\n format.json { render :json=> @product.errors,\n :status=> :unprocessable_entity }\n end\n end\n end",
"def create\n if @product.save\n render :show, status: :created, location: api_v1_product_path(@product)\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end",
"def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, :notice => 'Product was successfully created.' }\n format.json { render :json => @product, :status => :created, :location => @product }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @product.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, :notice => 'Product was successfully created.' }\n format.json { render :json => @product, :status => :created, :location => @product }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @product.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, :notice => 'Product was successfully created.' }\n format.json { render :json => @product, :status => :created, :location => @product }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @product.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to products_path, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: t(:product_created) }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n return unless product_params\n render json: Product.create_product(\n @product_params,\n category_list,\n @current_user.id\n ).simple_info, status: :created\n rescue => e\n render json: { error: e }, status: :bad_request\n end",
"def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to products_url, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: products_url }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(params[:product])\n respond_to do |format|\n if @product.save\n current_user.user_info.products.push @product\n Shopify.create @product\n format.html { redirect_to :action => 'index' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n \n end",
"def send_product(product)\n request(product, \"product\", :post, {method: \"add\"})\n end",
"def create\n @product = Product.new(product_params)\n \n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to products_url, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(product_params)\n @product.save\n set_products\n end",
"def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to products_url, notice: \"Product was successfully created.\" }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n ActiveRecord::Base.transaction do\n begin\n @api_v1_product = Product.create!(api_v1_product_params)\n\n json_response @api_v1_product, :created\n rescue => ex\n json_response({error: ex.message}, :unprocessable_entity)\n raise ActiveRecord::Rollback\n end\n end\n end",
"def create\n\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(product_params)\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product,\n notice: 'Product was successfully created.' }\n format.json { render :show, status: :created,\n location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors,\n status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: \"Product was successfully created.\" }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def addProd()\n if(!authenticateAdmin(params[:admin_id], params[:admin_auth_key]))\n render json: {status: false, reason: \"Authentication Failed\", data: \"\"}\n return\n end\n p = Product.new(name: params[:name], price: params[:price].to_f, category_id: params[:cat_id], picture_list: '[]')\n status = p.save\n error = \"\"\n if(p.errors.full_messages.count > 0)\n error = c.errors.full_messages[0]\n end\n render json: {status: status, reason: error, data: \"\"}\n end",
"def create\n @product = Product.new(params[:product])\n\n if @product.save\n \n respond_with(@product, :location=>products_url)\n else\n respond_with(@product, :head=>:bad_request)\n end\n end",
"def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product }\n format.js { render status: :ok }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n format.js { render status: :unprocessable_entity }\n end\n end\n end",
"def create\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(product_params)\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render action: 'show', status: :created, location: @product }\n else\n format.html { render action: 'new' }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render action: 'show', status: :created, location: @product }\n else\n format.html { render action: 'new' }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render action: 'show', status: :created, location: @product }\n else\n format.html { render action: 'new' }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render action: 'show', status: :created, location: @product }\n else\n format.html { render action: 'new' }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render action: 'show', status: :created, location: @product }\n else\n format.html { render action: 'new' }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create(product)\n validate_type!(product)\n\n attributes = sanitize(product)\n _, _, root = @client.post(\"/products\", attributes)\n\n Product.new(root[:data])\n end",
"def create\n # @order = Order.new() \n total = 0\n \n @order = Order.new()\n for product in params[:_json]\n \n if (product[:quantity].nil? || product[:quantity].to_f < 1 || !isint(product[:quantity]))\n # Handle case when order invalid quantity\n render json: \"\", status: :bad_request\n return\n end\n\n @product = Product.find_by_name_and_size_id(product[:product], product[:size]) \n if @product.nil?\n # Handle case when order invalid products\n render json: \"\", status: :not_found\n return\n end \n total = total + @product.price * product[:quantity].to_f \n @order.orders_products << OrdersProduct.new(:product => @product, :hot => product[:hot], :quantity => product[:quantity]) \n end \n\n @order.total = total\n\n if @order.save\n render json: @order, status: :created, location: @order\n else\n render json: @order.errors, status: :unprocessable_entity\n end\n end",
"def create\n @product = Product.new(params[:product])\n @product.shop = Shop.find_by_uuid params[:shop_id]\n\n respond_to do |format|\n if @product.save!\n format.html { redirect_to shop_products_path(@product.shop.uuid), notice: 'Product was successfully created.' }\n format.json { render json: @product.to_json(:include => {:product_variants => {:include => [:option_types,:pictures]}})}\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @product = Product.new\n\n render json: @product\n end",
"def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Продукт успешно создан.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @admin_product = Admin::Product.new(admin_product_params)\n\n respond_to do |format|\n if @admin_product.save\n format.html { redirect_to admin_products_url }\n format.json { render :show, status: :created, location: @admin_product }\n else\n format.html { render :new }\n format.json { render json: @admin_product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: t('.message') }\n format.json { render action: 'show', status: :created, location: @product }\n else\n format.html { render action: 'new' }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(params[:product])\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to admin_products_url, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else # save fails due to validation error -> show errors\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = @person.products.build(params[:model])\n\n respond_to do |format|\n if @product.save\n format.json { render :json => @product, :status => :created}\n else\n format.json { render :json => @product.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Изделие успешно создано.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(product_params)\n respond_to do |format|\n if @product.save\n format.html {redirect_to @product, notice: 'Producto creado.'}\n format.json {render :show, status: :created, location: @product}\n\n else\n format.html {render :new}\n format.json {render json: @product.errors, status: :unprocessable_entity}\n end\n\n end\n end",
"def create\n @add_product = AddProduct.new(params[:add_product])\n\n respond_to do |format|\n if @add_product.save\n format.html { redirect_to @add_product, notice: 'Add product was successfully created.' }\n format.json { render json: @add_product, status: :created, location: @add_product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @add_product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = Product.new(params[:product].merge :user_id => current_user.id)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to root_url, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_product\n @user = User.find_by(id: params['user'])\n products = params['products'].split(',')\n products.each do |product_id|\n @user.cart.products << Product.find_by(id: product_id)\n end \n render json: {data: @user.cart.products }\n end",
"def create\n @product = Product.new(product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render action: 'show', status: :created, location: @product }\n else\n format.html { render action: 'new' }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.7674954",
"0.7589692",
"0.756074",
"0.7531862",
"0.7531213",
"0.7507928",
"0.7420413",
"0.7391407",
"0.7374718",
"0.7355908",
"0.73231804",
"0.72869605",
"0.7144144",
"0.7050259",
"0.7047559",
"0.70415026",
"0.7037288",
"0.7037288",
"0.7037288",
"0.70322204",
"0.70255643",
"0.6992655",
"0.69766444",
"0.69545984",
"0.69545984",
"0.69545984",
"0.69545984",
"0.69545984",
"0.69545984",
"0.69545984",
"0.69545984",
"0.69545984",
"0.69545984",
"0.69545984",
"0.69545984",
"0.6945448",
"0.6941314",
"0.69375795",
"0.69284433",
"0.6927765",
"0.6926225",
"0.6924957",
"0.68977845",
"0.68903667",
"0.6888921",
"0.6884899",
"0.6881634",
"0.6881634",
"0.6881634",
"0.6881634",
"0.6881634",
"0.6881634",
"0.6881634",
"0.6881634",
"0.6881634",
"0.6881634",
"0.6881634",
"0.6881634",
"0.6881634",
"0.6881634",
"0.6881634",
"0.6881634",
"0.6881634",
"0.6881634",
"0.6881634",
"0.6881634",
"0.6881634",
"0.6881634",
"0.6881634",
"0.6881634",
"0.6881634",
"0.6881634",
"0.6881634",
"0.6881634",
"0.68810374",
"0.6880909",
"0.6875918",
"0.68446535",
"0.68419653",
"0.6827102",
"0.6825376",
"0.68205744",
"0.6810749",
"0.6810749",
"0.6810749",
"0.6810749",
"0.6801166",
"0.67984277",
"0.67804384",
"0.67599255",
"0.6741211",
"0.6736925",
"0.6734706",
"0.67305225",
"0.6714831",
"0.6688717",
"0.66845196",
"0.66810054",
"0.6675035",
"0.6662443",
"0.66591614"
] | 0.0 | -1 |
PATCH/PUT /products/1 PATCH/PUT /products/1.json | def update
@category = Category.find(params[:category_id])
respond_to do |format|
if @product.update(product_params)
flash[:notice] =t('prod_message_update')
format.html { redirect_to category_products_path }
format.json { render :show, status: :ok, location: @product }
else
format.html { render :edit }
format.json { render json: @product.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n begin\n @api_v1_product.update!(api_v1_product_params)\n head :no_content\n rescue => ex\n json_response({error: ex.message}, :unprocessable_entity)\n end\n end",
"def update\n if @product.update(product_params)\n render json: @product, status: :ok#, location: @collection\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end",
"def update\n updateProduct = Product.find_by_id(params[:id])\n updateProduct.update(products_params)\n if updateProduct != nil\n msg = { status: 200 , product: updateProduct }\n respond_to do |format|\n format.html { render json: msg }\n format.json { render json: msg }\n end\n else\n msg = { status: 422 }\n respond_to do |format|\n format.html { render json: msg }\n format.json { render json: msg }\n end\n end\n end",
"def update\n return unless product_params\n render json: @product.simple_info, status: :ok if @product.update!(@product_params)\n rescue => e\n render json: { error: e }, status: :ok\n end",
"def update\n @product = Product.find(params[:id])\n\n if @product.update(product_params)\n head :no_content\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end",
"def update\n if @product.update(product_params)\n render json: @product\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end",
"def update\n @product.assign_attributes object_params.reject{|_, v| v.blank?}\n # In a normal app we have a pre filled form of the object to update,\n # so when we do a PATCH (or PUT) we send all the attributes again,\n # in the API we permit to send any field to update, so we need to remove\n # all the blank params of the object to prevent validations triggers of\n # attributes that we don't send to update\n if @product.save\n render json: @product.to_json\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end",
"def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end",
"def update\n product = Product.find(params[:id])\n product_details = params.permit(:title, :inventory_count, :price)\n\n product.update(product_details)\n\n render json: product\n end",
"def update\n \n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @record = Product.find(params[:id])\n @record.update_attributes(params[:product])\n \n respond_to do |format|\n format.json {\n render json: {}\n }\n end\n end",
"def update\n respond_to do |format|\n if @product.update!(product_params)\n format.html { redirect_to products_url, notice: 'Product was successfully updated.' }\n format.json { render json: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: t(:product_updated) }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @product = Product.find(params[:id])\n \n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, :notice => 'Product was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @product.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, :notice => 'Product was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @product.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to products_path, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, :notice => 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @product.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, :notice => 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @product.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product,\n :notice=> 'Product was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action=> \"edit\" }\n format.json { render :json=> @product.errors,\n :status=> :unprocessable_entity }\n end\n end\n end",
"def update\n @product = Product.find(params[:id])\n\n if @product.update_attributes(params[:product])\n respond_to do |format|\n format.html { redirect_to products_path, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n end\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end",
"def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @product = Product.find(params[:id])\n\t\trespond_to do |format|\n\t\t if @product.update_attributes(params[:product])\n\t\t\tif @product.photo.nil?\n\t\t\t\tphoto = Photo.find_by_product_id(@product.id)\n\t\t\t\[email protected]_attributes(:photo_id => photo.id) if !photo.nil?\n\t\t\tend\n\t\t\tformat.html { redirect_to @product, :notice => 'Успешно обновлено' }\n\t\t\tformat.json { head :no_content }\n\t\t else\n\t\t\tformat.html { render :action => \"edit\" }\n\t\t\tformat.json { render :json => @product.errors, :status => :unprocessable_entity }\n\t\t end\n\t\tend\n end",
"def update\n @product = Product.find(params[:id])\n\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to edit_product_path(@product), notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @product = Product.find(params[:id])\n @product.name_prefix = @product.name.first.upcase\n respond_to do |format|\n if @product.update_attributes(params[:product])\n\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @product.update(product_params)\n set_products\n end",
"def update\n if @product.update(product_params)\n render :show, status: :ok, location: api_v1_product_path(@product)\n else\n render json: @product.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @product = Product.find(params[:id])\n respond_to do |format|\n @product.edit\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to action: 'show', notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def editProd()\n if(!authenticateAdmin(params[:admin_id], params[:admin_auth_key]))\n render json: {status: false, reason: \"Authentication Failed\", data: \"\"}\n return\n end\n p = Product.find(params[:id])\n status = p.update(name: params[:name], price: params[:price].to_f, category_id: params[:cat_id])\n error = \"\"\n if(p.errors.full_messages.count > 0)\n error = c.errors.full_messages[0]\n end\n render json: {status: status, reason: error, data: \"\"}\n end",
"def update\n @product = Product.eager_loading.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to shop_products_path(@product.shop.uuid), notice: 'Product was successfully updated.' }\n format.json { render json: @product.to_json(:include => {:product_variants => {:include => [:option_types,:pictures]}})}\n else\n format.html { render action: \"edit\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n #Find product by productID\n @product = Product.find_by(productID: params[:id])\n \n respond_to do |format|\n if @product.update_attributes(product_params)\n format.html { redirect_to products_path, notice: 'Product has been updated.' }\n format.json { render :index, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @angular = Product.find(params[:id])\n \n @angular.update_attributes(title: params[:products][:title], description: params[:products][:description])\n respond_to do |format|\n if @angular.valid?\n format.html { redirect_to store_index_path, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @angular.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @product = Product.find(params[:id])\n if @product\n if @product.update(price: params[:price])\n render 'api/products/show'\n else\n render json: [\"Can only update price\"], status: 422\n end\n else\n render json: [\"Product not found\"], status: 422\n end\n end",
"def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: t('.message') }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @product = Product.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:product])\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.xml { head :ok }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.xml { render :xml => @product.errors, :status => :unprocessable_entity }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n \n end",
"def set_api_v1_product\n begin\n @api_v1_product = Product.find(params[:id])\n rescue => ex\n json_response({error: ex.message}, :not_found)\n end\n end",
"def update # PATCH\n raise NotImplementedError\n end",
"def update\n respond_to do |format|\n if @product1.update(product1_params)\n format.html { redirect_to @product1, notice: \"Product1 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @product1 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @product1.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok}\n else\n format.html { render :edit }\n format.json { render json: @product.errors.full_messages, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Your product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: t('update_success') }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @product_spec.update(product_spec_params)\n format.html { redirect_to @product_spec, notice: 'Product spec was successfully updated.' }\n format.json { render :show, status: :ok, location: @product_spec }\n else\n format.html { render :edit }\n format.json { render json: @product_spec.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch!\n request! :patch\n end",
"def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: \"Product was successfully updated.\" }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @product = @person.products.find(params[:id])\n\n respond_to do |format|\n if @product.update_attributes(params[:model])\n flash[:notice] = 'Product was successfully updated.'\n format.json { render :json=>nil }\n else\n format.json { render :json => @product.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end",
"def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @product.update(product_params)\n format.html { redirect_to @product, notice: 'Product was successfully updated.' }\n format.json { render :show, status: :ok, location: @product }\n else\n format.html { render :edit }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.72706324",
"0.69353855",
"0.6868726",
"0.6846583",
"0.68131363",
"0.6768224",
"0.67510056",
"0.6743048",
"0.6715245",
"0.67010957",
"0.6686189",
"0.6659919",
"0.665496",
"0.6653816",
"0.66409653",
"0.66409653",
"0.66386145",
"0.6631324",
"0.6631324",
"0.6627554",
"0.66209936",
"0.66041505",
"0.6604122",
"0.6604122",
"0.6604122",
"0.6604122",
"0.6604122",
"0.6604122",
"0.6604122",
"0.6604122",
"0.6604122",
"0.6604122",
"0.6604122",
"0.6604122",
"0.6604122",
"0.6604122",
"0.6604122",
"0.6604122",
"0.6604122",
"0.66030496",
"0.6593889",
"0.65937006",
"0.6587147",
"0.6560764",
"0.6557223",
"0.6557223",
"0.6557223",
"0.6557223",
"0.6557223",
"0.65564966",
"0.6540365",
"0.65276545",
"0.64983803",
"0.64903253",
"0.6486119",
"0.64776295",
"0.64761376",
"0.6474146",
"0.6455121",
"0.6453107",
"0.64431745",
"0.6435512",
"0.64352924",
"0.64297795",
"0.6424379",
"0.6420262",
"0.64153826",
"0.64095974",
"0.640807",
"0.6407766",
"0.64058924",
"0.6404031",
"0.6403699",
"0.6403699",
"0.6403699",
"0.6403699",
"0.6403699",
"0.6403699",
"0.6403699",
"0.6403699",
"0.6403699",
"0.6403699",
"0.6403699",
"0.6403699",
"0.6403699",
"0.6403699",
"0.6403699",
"0.6403699",
"0.6403699",
"0.6403699",
"0.6403699",
"0.6403699",
"0.6403699",
"0.6403699",
"0.6403699",
"0.6403699",
"0.6403699",
"0.6403699",
"0.6403699",
"0.6403699",
"0.6403699"
] | 0.0 | -1 |
DELETE /products/1 DELETE /products/1.json | def destroy
if @product.destroy
respond_to do |format|
format.js
flash[:notice] = t('cat_message_delete')
format.html { redirect_to category_products_url }
format.json { head :no_content }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n product = Product.find(params[:id])\n product.destroy\n\n render json: { deleted: params[:id] }\n end",
"def delete_product(name)\n delete(\"/apiproducts/#{name}\")\n end",
"def destroy\n p @product.destroy!\n render json: { result: 'deleted' }, status: :ok\n end",
"def destroy\n @product.destroy\n render json: {}\n end",
"def destroy\n @product.destroy\n\n render json: @product, status: :ok#, location: @collection\n end",
"def delete_product(id)\n @client.raw('delete', \"/ecommerce/products/#{id}\")\n end",
"def destroy\n product = Product.find(params[:id])\n product.destroy\n render json: {id: product.id}\n end",
"def destroy\n @product = Product.find(params[:id])\n @product.delete!\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end",
"def delete(options = nil)\n request = Request.new(@client)\n path = \"/products/\" + CGI.escape(@id) + \"\"\n data = {\n\n }\n\n response = Response.new(request.delete(path, data, options))\n return_values = Array.new\n \n return_values.push(response.success)\n\n \n return_values[0]\n end",
"def destroy\n unread\n\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n begin\n @api_v1_product.destroy!\n head :no_content\n rescue => ex\n json_response({error: ex.message}, :unprocessable_entity)\n end\n end",
"def destroy\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to root_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n puts(\"you are in destroy \")\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product.destroy\n render json: {is_success: true, error_code: 200, message: \"Deleted Successfully\", result: @product}, status: 200\n end",
"def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to root_url(:item => 3), notice: 'Product was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @record = Product.find(params[:id])\n @record.trash\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def deleteProd()\n if(!authenticateAdmin(params[:admin_id], params[:admin_auth_key]))\n render json: {status: false, reason: \"Authentication Failed\", data: \"\"}\n return\n end\n p = Product.find(params[:id])\n status = p.destroy\n error = \"\"\n if(p.errors.full_messages.count > 0)\n error = c.errors.full_messages[0]\n end\n render json: {status: true, reason: error, data: \"\"}\n end",
"def destroy\n @product1.destroy\n respond_to do |format|\n format.html { redirect_to product1s_url, notice: \"Product1 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to admin_products_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @onecompany_product = Onecompany::Product.find(params[:id])\n @onecompany_product.destroy\n\n respond_to do |format|\n format.html { redirect_to onecompany_products_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url, notice: t('destroy_success') }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url, notice: t('.message') }\n format.json { head :no_content }\n end\n end",
"def delete\n render json: Item.delete(params[\"id\"])\n end",
"def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_products_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_products_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @producto = Producto.find(params[:id])\n @producto.destroy\n\n respond_to do |format|\n format.html { redirect_to productos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @producto = Producto.find(params[:id])\n @producto.destroy\n\n respond_to do |format|\n format.html { redirect_to productos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @producto = Producto.find(params[:id])\n @producto.destroy\n\n respond_to do |format|\n format.html { redirect_to productos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url, notice: 'Product was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\nend",
"def destroy \n @product = current_user.user_info.products.find(params[:id])\n Shopify.delete @product\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product = Product.find(params[:id]).delete\n respond_to do |format|\n if @product.delete\n format.html {redirect_to @product, notice: \"Product was successfully deleted.\" }\n else\n format.json {render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url, notice: 'Your product was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @shopifyproduct = Shopifyproduct.find(params[:id])\n @shopifyproduct.destroy\n\n respond_to do |format|\n format.html { redirect_to shopifyproducts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product = @person.products.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.json { render :json=>true }\n end\n end",
"def destroy\n #@product = Product.find(params[:id]) #하단에서 미리 선언\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n respond_to do |format|\n format.html { redirect_to(products_url) }\n format.xml { head :ok }\n format.json { head :ok }\n end\n end",
"def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product.destroy\n\n head :no_content\n end",
"def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to root_path, notice: 'Product was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin_product.destroy\n respond_to do |format|\n format.html { redirect_to admin_products_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url, notice: 'Продукт успешно удален.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product = Product.find(params[:id])\n @product.destroy\n\n head :no_content\n end",
"def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url, notice: \"Product was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url, notice: \"Product was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url, notice: \"Product was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @prod = Prod.find(params[:id])\n @prod.destroy\n\n respond_to do |format|\n format.html { redirect_to prods_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url, notice: 'Product was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url, notice: 'Product was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url, notice: 'Product was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url, notice: 'Product was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url, notice: 'Product was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url, notice: 'Product was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url, notice: 'Product was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url, notice: 'Product was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url, notice: 'Product was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url, notice: 'Product was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url, notice: 'Product was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url, notice: 'Product was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url, notice: 'Product was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url, notice: 'Product was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product.destroy\n respond_to do |format|\n format.html { redirect_to products_url, notice: 'Product was successfully destroyed.' }\n format.json { head :no_content }\n end\n end"
] | [
"0.77170193",
"0.7592065",
"0.7548574",
"0.75031716",
"0.750253",
"0.7473131",
"0.74397856",
"0.7417868",
"0.7408511",
"0.73704934",
"0.7352473",
"0.73480946",
"0.73359036",
"0.73359036",
"0.73359036",
"0.73310447",
"0.73310447",
"0.73310447",
"0.73310447",
"0.73310447",
"0.73310447",
"0.7313243",
"0.7313243",
"0.7313243",
"0.7313243",
"0.7313243",
"0.7313243",
"0.7313243",
"0.7313243",
"0.7313243",
"0.7313243",
"0.7313243",
"0.7313243",
"0.7313243",
"0.7313243",
"0.7313243",
"0.7313243",
"0.7313243",
"0.7313243",
"0.7313243",
"0.7313243",
"0.7313243",
"0.7313243",
"0.7313243",
"0.7313243",
"0.7313243",
"0.7313243",
"0.7313243",
"0.7313014",
"0.72990006",
"0.72793394",
"0.7266149",
"0.7265518",
"0.7259493",
"0.72525394",
"0.72506374",
"0.72295445",
"0.7226073",
"0.72209114",
"0.72148764",
"0.7203848",
"0.7203059",
"0.72025245",
"0.72025245",
"0.7188699",
"0.7188699",
"0.7188699",
"0.71857435",
"0.7185019",
"0.71712303",
"0.71685237",
"0.7157093",
"0.7152346",
"0.7146412",
"0.7142441",
"0.7135723",
"0.7130449",
"0.71280587",
"0.7125754",
"0.71252656",
"0.7111239",
"0.7109649",
"0.7079214",
"0.7079214",
"0.7079214",
"0.70785356",
"0.70763236",
"0.70763236",
"0.70763236",
"0.70763236",
"0.70763236",
"0.70763236",
"0.70763236",
"0.70763236",
"0.70763236",
"0.70763236",
"0.70763236",
"0.70763236",
"0.70763236",
"0.70763236",
"0.70763236"
] | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_product
@product = Product.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def setup_handler\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def workflow\n end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup\n # override and do something appropriate\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def after_set_callback; end",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def save_action; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def setup(&blk)\n @setup_block = blk\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def duas1(action)\n action.call\n action.call\nend",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend"
] | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576",
"0.53124547",
"0.529654",
"0.5296262",
"0.52952296",
"0.52600986",
"0.52442724",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.5232394",
"0.523231",
"0.5227454",
"0.52226824",
"0.52201617",
"0.5212327",
"0.52079266",
"0.52050185",
"0.51754695",
"0.51726824",
"0.51710224",
"0.5166172",
"0.5159343",
"0.51578903",
"0.51522785",
"0.5152022",
"0.51518047",
"0.51456624",
"0.51398855",
"0.5133759",
"0.5112076",
"0.5111866",
"0.5111866",
"0.5110294",
"0.5106169",
"0.509231",
"0.50873137",
"0.5081088",
"0.508059",
"0.50677156",
"0.50562143",
"0.5050554",
"0.50474834",
"0.50474834",
"0.5036181",
"0.5026331",
"0.5022976",
"0.5015441",
"0.50121695",
"0.5000944",
"0.5000019",
"0.4996878",
"0.4989888",
"0.4989888",
"0.49864885",
"0.49797225",
"0.49785787",
"0.4976161",
"0.49683493",
"0.4965126",
"0.4958034",
"0.49559742",
"0.4954353",
"0.49535993",
"0.4952725",
"0.49467874",
"0.49423352",
"0.49325448",
"0.49282882",
"0.49269363",
"0.49269104",
"0.49252945",
"0.4923091",
"0.49194667",
"0.49174926",
"0.49173003",
"0.49171105",
"0.4915879",
"0.49155936"
] | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def product_params
params.require(:product).permit(:name, :description, :price)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def param_whitelist\n [:role, :title]\n end",
"def expected_permitted_parameter_names; end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def permitted_params\n []\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params; true; end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def quote_params\n params.permit!\n end",
"def valid_params?; end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend",
"def filtered_parameters; end",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def filtering_params\n params.permit(:email, :name)\n end",
"def check_params\n true\n end",
"def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end",
"def active_code_params\n params[:active_code].permit\n end",
"def filtering_params\n params.permit(:email)\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end",
"def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end",
"def list_params\n params.permit(:name)\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def url_whitelist; end",
"def admin_social_network_params\n params.require(:social_network).permit!\n end",
"def filter_params\n params.require(:filters).permit(:letters)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end",
"def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def permit_request_params\n params.permit(:address)\n end",
"def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end",
"def secure_params\n params.require(:location).permit(:name)\n end",
"def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end",
"def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end",
"def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def url_params\n params[:url].permit(:full)\n end",
"def backend_user_params\n params.permit!\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end",
"def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end",
"def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end",
"def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end",
"def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end"
] | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",
"0.62894756",
"0.6283177",
"0.6242471",
"0.62382483",
"0.6217549",
"0.6214457",
"0.6209053",
"0.6193042",
"0.6177802",
"0.6174604",
"0.61714715",
"0.6161512",
"0.6151757",
"0.6150663",
"0.61461",
"0.61213595",
"0.611406",
"0.6106206",
"0.6105114",
"0.6089039",
"0.6081015",
"0.6071004",
"0.60620916",
"0.6019971",
"0.601788",
"0.6011056",
"0.6010898",
"0.6005122",
"0.6005122",
"0.6001556",
"0.6001049",
"0.59943926",
"0.5992201",
"0.59909594",
"0.5990628",
"0.5980841",
"0.59669393",
"0.59589154",
"0.5958826",
"0.5957911",
"0.5957385",
"0.5953072",
"0.59526145",
"0.5943361",
"0.59386164",
"0.59375334",
"0.59375334",
"0.5933856",
"0.59292704",
"0.59254247",
"0.5924164",
"0.59167904",
"0.59088355",
"0.5907542",
"0.59064597",
"0.5906243",
"0.5898226",
"0.589687",
"0.5896091",
"0.5894501",
"0.5894289",
"0.5891739",
"0.58860534",
"0.5882406",
"0.587974",
"0.58738774",
"0.5869024",
"0.58679986",
"0.5867561",
"0.5865932",
"0.5864461",
"0.58639693",
"0.58617616",
"0.5861436",
"0.5860451",
"0.58602303",
"0.5854586",
"0.58537364",
"0.5850427",
"0.5850199"
] | 0.0 | -1 |
GET /user_follow_tags/1 GET /user_follow_tags/1.json | def show
@user_follow_tag = UserFollowTag.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @user_follow_tag }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tag_follow(tag)\n tag_follows.create(tag_id: tag.id)\n end",
"def create\n name_normalized = ActsAsTaggableOn::Tag.normalize(params['name'])\n\n if name_normalized.nil? || name_normalized.empty?\n render :nothing => true, :status => 403\n else\n @tag = ActsAsTaggableOn::Tag.find_or_create_by_name(name_normalized)\n @tag_following = current_user.tag_followings.new(:tag_id => @tag.id)\n\n if @tag_following.save\n render :json => @tag.to_json, :status => 201\n else\n render :nothing => true, :status => 403\n end\n end\n end",
"def get_user_tags username, password\n do_request 'get_user_tags', username: username, password: password\n end",
"def list(user_id)\n @_client.get(\"/users/#{user_id}/tags\")\n end",
"def new\n @user_follow_tag = UserFollowTag.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user_follow_tag }\n end\n end",
"def get_tags( params )\n secure = !params.include?(:user)\n LastFM.requires_authentication if secure\n LastFM.post( \"track.getTags\", params, secure )\n end",
"def index\n if params[:tag]\n @things = Thing.tagged_with(params[:tag]).page params[:page]\n else\n @things = Thing.all.search_and_order(params[:search], params[:page])\n end\n @followed_things_ids = current_user.followed_things.map(&:to_i)\n end",
"def tags\n return head :unauthorized unless current_user\n @tags = current_user.owned_tags.where(\"name like ?\", \"%#{params[:tag]}%\").\n page(params[:page]).per(20)\n if @tags.empty?\n @tags = [current_user.owned_tags.new(name: I18n.t('record.tag_list.no_tags'))]\n end\n respond_with(@tags)\n end",
"def index\n tags_list = []\n @user.tags.find_each do |tag|\n tags_list << tag_as_hash(tag, false)\n end\n\n render :status => 200,\n :json => {\n status: 200,\n tags: tags_list\n }\n end",
"def tags(options={})\n self.class.parse_tags(request(singular(user_id) + \"/tags\", options))\n end",
"def destroy\n @user_follow_tag = UserFollowTag.find(params[:id])\n @user_follow_tag.destroy\n\n respond_to do |format|\n format.html { redirect_to user_follow_tags_url }\n format.json { head :ok }\n end\n end",
"def create\n @user_follow_tag = UserFollowTag.new(params[:user_follow_tag])\n\n respond_to do |format|\n if @user_follow_tag.save\n format.html { redirect_to @user_follow_tag, notice: 'User follow tag was successfully created.' }\n format.json { render json: @user_follow_tag, status: :created, location: @user_follow_tag }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user_follow_tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def tags\n get('tags')\n end",
"def tags\n @tags = User.tag_counts_on(:tags, :conditions => \"name LIKE '\" + (params[:query] || \"\") + \"%'\").limit(50).order('count desc')\n respond_to do |format|\n format.html # tags.html.erb\n format.json { render json: @tags }\n format.xml { render xml: @tags }\n end\n end",
"def tags\n response[\"tags\"]\n end",
"def get_tag_list\n # body = {\n # cmd: \"get_tag_list\"\n # }\n\n end",
"def tags\n @tags_with_count = Asset.tag_counts_on(:tags)\n \n @tags = @tags_with_count.map{|tag_hash| tag_hash = tag_hash.name }\n \n respond_to do |format|\n format.html\n format.json { render :json => @tags }\n end\n end",
"def tag_following?(tag)\n tag_follows.exists?(tag_id: tag.id)\n end",
"def top_tags(user, options={})\n get(:standard, {:method => \"user.getTopTags\", :user => user}.merge(options))\n end",
"def index\n @tags, @tags_attached = TagService.list(current_user.id)\n end",
"def tag\n @favors = Favor.tagged_with(params[:tag], :order => @order)\n @tag = params[:tag]\n\n respond_to do |format|\n format.html # tag.html.erb\n format.json { render json: @favors }\n end\n end",
"def show\n @user_tag = UserTag.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user_tag }\n end\n end",
"def follow\n user = User.find(params[:user_id])\n @follow = current_user.follow(user)\n render json: @follow\n end",
"def follow_by_tag(num_to_follow, tag, tweets = [])\n # Break if recursion hits rate limit\n if (sr = self.tweet_searches_remaining) < 10 || (fl = self.follower_lookups_remaining) < 2\n p \"Returning hitting rate limit #{sr}, #{fl}\"\n return\n end\n tweets = @client.search(tag, count: 100).to_a.reverse! if tweets.count == 0\n num_to_retry = 0\n popped_tweets = tweets.pop(num_to_follow)\n popped_tweets.each do |tweet|\n remote_user = tweet.user\n screen_name = remote_user.screen_name\n twitter_id = remote_user.id\n local_user = TwitterUser.where(\n twitter_id: twitter_id, twitter_client: self.id).first_or_initialize\n if local_user.new_record? && screen_name != self.username\n local_user.tag_followed = tag\n local_user.followed_at = DateTime.now\n begin\n @client.follow(screen_name)\n p \"#{screen_name} followed\"\n local_user.save! \n update_twitter_user(local_user, remote_user, 1)\n p \"**** Following for #{self.username} --> #{screen_name}: #{tweet.text} #{tweet.created_at}\"\n rescue Exception => e\n p \"Error following #{screen_name} for #{self.username} - #{e.to_s}\"\n return\n end\n else\n num_to_retry += 1\n end\n end\n # If user has already been followed, attempt to follow another user by retrieving more tweets\n if num_to_retry > 0 && !(tweets_to_retry = tweets[num_to_retry..tweets.count]).nil?\n p \"Follow more people for #{self.username}: #{num_to_retry}\"\n follow_by_tag(num_to_retry, tag, tweets_to_retry)\n end\n p \"Done following\"\n end",
"def taggings(user)\n user = Access::Validate.user(user, false)\n Tagging\n .where('(audio_events_tags.creator_id = ? OR audio_events_tags.updater_id = ?)', user.id, user.id)\n .order('audio_events_tags.updated_at DESC')\n end",
"def tagsFor(user)\n if user.nil?\n []\n else\n tags.select{|x| x.user_id == user.id}\n end\n end",
"def tags\n @tags = ActsAsTaggableOn::Tag.where(\"tags.name LIKE ?\", \"%#{params[:q]}%\") \n #@tags = Node.tag_counts(:limit => 50, :order => \"count desc\")\n #@tags = Node.tag_counts_on(:tag, :limit => 50, :order => \"count desc\")\n @out = @tags.map{|b| {:id => b.id, :name => b.name }}\n \n\n \n respond_to do |format|\n format.json { render :json => @out }\n end\n\n end",
"def taglist\n @tags = Note.tag_counts.map {|tag| tag.name}\n\n respond_to do |format|\n format.json { render json: @tags }\n end\n end",
"def tags(client)\n client.get(\"#{PATH}/tags\")\n end",
"def tags(artist, track)\n get(:session, {:method => \"track.getTags\", :artist => artist, :track => track})\n end",
"def tags\n _get(\"/query/image/tags\") { |json| json }\n end",
"def show_follows\n \t@user = User.find(params[:id])\n \t\n \trender json: @user.follows\n end",
"def show\n @twitter_user = TwitterUser.find(params[:id])\n @follower_ids = Twitter.follower_ids(@twitter_user.twitter_username).collection\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @twitter_user }\n end\n end",
"def show\n @taggable = current_user.taggables.find(params[:id])\n @tags = @taggable.tags\n @url_no_path = URI.parse(@taggable.photo.url).path[%r{[^/]+\\z}]\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @taggable }\n end\n end",
"def get_tags_by_url\n url = Url.find_by(id: params[:id])\n tags = url.tags\n render json: {code: 200, tags: tags}\n end",
"def tags\n @tags = ActsAsTaggableOn::Tag.where(\"tags.name LIKE ?\", \"%#{params[:q]}%\") \n #@tags = Video.tag_counts(:limit => 50, :order => \"count desc\")\n #@tags = Video.tag_counts_on(:tag, :limit => 50, :order => \"count desc\")\n @out = @tags.map{|b| {:id => b.id, :name => b.name }}\n \n\n \n respond_to do |format|\n format.json { render :json => @out }\n end\n\n end",
"def tags\n tags = get_user_tags\n # prevents resource from being applied on every run if clearing tags with ''\n tags = [''] if tags == []\n tags\n end",
"def tags\n @tags ||= begin\n resp = @client.access_token.get('/reader/api/0/tag/list?output=json')\n raise \"unable to retrieve the list of tags for user \\\"#{user_id}\\\": #{resp.inspect}\" unless resp.code_type == Net::HTTPOK\n JSON.parse(resp.body)['tags'].collect do |hash|\n Google::Reader::Tag.new(hash.merge({:client => @client}))\n end\n end\n end",
"def my_follows\n follows = paginate Follow.where(follower_id: params[:user_id])\n\n render json: follows.to_json(:include => :following)\n end",
"def show\n @tag = Tag.find(params[:id])\n\n @tweets = @tag.tweets.paginate(:page => params[:page], :per_page => 20)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @tag }\n end\n end",
"def tags(params = {})\n @api.get(\"#{@api.path}/List/#{@id}/Tags\", params: params)\n end",
"def update\n @user_follow_tag = UserFollowTag.find(params[:id])\n\n respond_to do |format|\n if @user_follow_tag.update_attributes(params[:user_follow_tag])\n format.html { redirect_to @user_follow_tag, notice: 'User follow tag was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user_follow_tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def follow\n @data = {:user_id => params[:follow_user_id], :follow_user_id => current_user.id, :followed => 1}\n status = UserFollower.follow(@data)\n render json: {:status => status}\n end",
"def activities_tags\n\t\ttags = ActivityTag.tags_for_teacher(@current_teacher_user.id)\n\n\t\trender json: {status: \"success\" , tags: tags}\n\tend",
"def pulled_tags\n @list.pullin ? @list.taggings.where(user_id: @list.owner_id).includes(:tag).map(&:tag) : []\n end",
"def show_follows\n\t@user = User.find(params[:id])\n\n\trender json: @user.follows\n\tend",
"def index\n timeline = Tweet.where(user_id: User.find(@current_user_id).follows).or(Tweet.where(user_id: @current_user_id))\n render json: {timeline: timeline}\n end",
"def index\n unless params[:tag].blank?\n @recipes = current_user.recipes.tagged_with(params[:tag]).order(\"created_at desc\").page(params[:page]).per(10)\n else\n @recipes = current_user.recipes.order(\"created_at desc\").page(params[:page]).per(10) \n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @recipes }\n end\n end",
"def tags\n get.tagGuids\n end",
"def index\n @tags = current_user.tags\n .order(links_count: :desc)\n .page(params[:page])\n end",
"def destroy\n tag_following = current_user.tag_followings.find_by_tag_id( params['id'] )\n \n if tag_following && tag_following.destroy\n respond_to do |format|\n format.any(:js, :json) { render :nothing => true, :status => 204 }\n end\n else\n respond_to do |format|\n format.any(:js, :json) {render :nothing => true, :status => 403}\n end\n end\n end",
"def related\n @related ||= begin\n response = Fleakr::Api::MethodRequest.with_response!('tags.getRelated', :tag => value)\n (response.body/'rsp/tags/tag').map {|e| Tag.new(e) }\n end\n end",
"def followed_tips\n # @followedTips = current_user.reverse_user_connections.map do |user|\n # User.find(user.tipster_id).to_json(:include => [:tips => {:include => {:predictions => {:include => {:type_of_bet => {:only => :name}}}}}])\n # end\n # @followedTips = current_user.reverse_user_connections.map do |user|\n # tips = Tip.where(user_id:user.tipster_id).to_json(:include => [:predictions => {:include => {:type_of_bet => {:only => :name}}}])\n # tips\n # end\n @followedTips = current_user.reverse_user_connections.map do |user|\n # get the people the current user follows\n User.find(user.tipster_id).tips.map do |tip|\n tip.predictions.map do |prediction|\n attrs = prediction.attributes #.attributes converts the object to a hash\n attrs[:type_of_bet_name] = prediction.type_of_bet.name\n # attrs[:user] = user.attributes \n # attrs[:tip] = tip.attributes\n # if attrs[\"date\"].to_date > Date.today\n attrs\n # end\n end\n end \n end.flatten\n render json: { data: @followedTips }.to_json\n end",
"def show\n user = Api::V1::User.find(params[:id])\n unless user.nil?\n render json: user.followings.all\n end\n end",
"def show\n user = Api::V1::User.find(params[:id])\n unless user.nil?\n render json: user.followings.all\n end\n end",
"def index\n @users = User.where(banned: false, public_profile: true).order(:name).includes(:skills)\n\n @users = @users.ilike(:name, params[:query]) unless params[:query].blank?\n @users = @users.tagged_with(params[:skills]) unless params[:skills].blank?\n\n @tags = User.tag_counts_on(:skills).order('taggings_count DESC')\n end",
"def robotags\n object.tags User.super_id\n end",
"def follow\n current_user.follow_user(@user)\n render json: {ok: 1}\n end",
"def follower\n @users = User.find(params[:id]).followers\n render json: @users\n end",
"def tags(artist)\n get(:session, {:method => \"artist.getTags\", :artist => artist})\n end",
"def index\n @taggables = current_user.taggables\n @taggable_center = current_user.taggables.first\n \n\n if !@taggable_center.nil?\n @url_no_path = URI.parse(@taggable_center.photo.url(:editable)).path[%r{[^/]+\\z}]\n @url_path = URI.parse(@taggable_center.photo.url(:editable)).path\n @tags = @taggable_center.tags\n end\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @taggables }\n end\n end",
"def top_tagged(user_id)\n from_instagram = retrieve_last_10_photos(user_id)\n\n number_of_photos = from_instagram[\"data\"].size\n\n all_people_you_tag = []\n users_per_photo = []\n i = 0\n while i < number_of_photos\n x = 0\n people_per_photo = from_instagram[\"data\"][i][\"users_in_photo\"].size\n people_you_tag = from_instagram[\"data\"][i][\"users_in_photo\"]\n while x < people_per_photo\n username = from_instagram[\"data\"][i][\"users_in_photo\"][x][\"user\"][\"username\"]\n array = users_per_photo.push(username)\n x = x + 1\n end\n i = i + 1\n end\n\n if array\n\n b = Hash.new(0)\n array.each do |v|\n b[v] += 1\n end\n\n sorted_b = b.sort_by {|k, v| v}\n sorted_b = sorted_b.reverse\n\n sorted_b.map do |k, v|\n puts \"#{k}: #{v} tags\"\n end\n\n return sorted_b\n\n else \n return \"No users tagged\"\n end\n\n end",
"def top_tagged(user_id)\n from_instagram = retrieve_last_10_photos(user_id)\n\n number_of_photos = from_instagram[\"data\"].size\n\n all_people_you_tag = []\n users_per_photo = []\n i = 0\n while i < number_of_photos\n x = 0\n people_per_photo = from_instagram[\"data\"][i][\"users_in_photo\"].size\n people_you_tag = from_instagram[\"data\"][i][\"users_in_photo\"]\n while x < people_per_photo\n username = from_instagram[\"data\"][i][\"users_in_photo\"][x][\"user\"][\"username\"]\n array = users_per_photo.push(username)\n x = x + 1\n end\n i = i + 1\n end\n\n if array\n\n b = Hash.new(0)\n array.each do |v|\n b[v] += 1\n end\n\n sorted_b = b.sort_by {|k, v| v}\n sorted_b = sorted_b.reverse\n\n sorted_b.map do |k, v|\n puts \"#{k}: #{v} tags\"\n end\n\n return sorted_b\n\n else\n return \"No users tagged\"\n end\n\n end",
"def new\n @taggable = current_user.taggables.new(:user_id => current_user.id)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @taggable }\n end\n end",
"def followers(options = {})\n Tinybucket::Resource::User::Followers.new(username, options)\n end",
"def index\n user = find_user\n\n expose user.favorite_tags\n end",
"def tags()\n return MicrosoftGraph::Me::JoinedTeams::Item::Tags::TagsRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def tweets_by_tag\n @tag = Tag.find(params[:id])\n @tweets = @tag.tweets.order(created_at: :desc) # order the tweets according to when they were created, with the most recent tweet at the top.\n end",
"def follow\n if request.post?\n fo_ids = params[:follow] \n #fo_str = \"\"\n #fo_cnt = fo_ids.length - 1\n #for i in 0..fo_cnt\n # fo_str +=fo_ids[i].to_s\n # fo_str += \",\" unless fo_cnt == i\n #end\n \n fo_ids.each do |fid|\n hydra = Typhoeus::Hydra.new\n uri = \"http://api.twitter.com/1/friendships/create.json\"\n req = Typhoeus::Request.new(uri,\n :method =>\"post\",\n :params =>{:user_id=>fid, :include_entities=>\"true\"})\n \n sign_request(req,uri)\n hydra.queue(req)\n hydra.run\n #puts req.response.inspect\n end\n end\n redirect_to :action=>\"index\", :page=>\"1\" \n end",
"def follow_list(options)\n session.options = adapt_to_dev_env(options)\n session.get('/follows')\n end",
"def index\n authorize @user\n render :json => @user.tags\n end",
"def find_tagged_with_by_user(tags, user, options = {})\n options.assert_valid_keys([:match])\n find_tagged_with(tags, {:match => options[:match], :user => user})\n end",
"def find_tagged_with_by_user(tags, user, options = {})\n options.assert_valid_keys([:match])\n find_tagged_with(tags, {:match => options[:match], :user => user})\n end",
"def tags(track)\n response = client.get(\"2.0/tracks/#{track}/tags\")\n\n response.map { |tag| Struct::Tag.new(tag) }\n end",
"def following\n @users = User.find(params[:id]).all_following\n render json: @users\n end",
"def add(user_id, tag)\n @_client.post(\"/users/#{user_id}/tags\", value: tag)\n end",
"def all_following_topics\n topics = User.find(params[:user_id]).following_topics\n render :json => topics\n end",
"def followed\n\t\t@user = User.find(params[:id])\n\t\tcurrent_user.create_rel(\"FOLLOWING\", @user) \n\t\tif request.xhr?\n\t\t\trender json: { count: @user.following.count, id: @user.id }\n\t\telse\n\t\t\tredirect_to @user\n\t\tend\n\n\tend",
"def index\n @tagihans = Tagihan.all\n @tagihans = @tagihans.select { |x| x.user_id == params[:user_id].to_i }\n render json: { items: @tagihans }\n end",
"def index\n @users = User.where(banned: false).order(:name).includes(:skills)\n\n @users = @users.ilike(:name, params[:query]) unless params[:query].blank?\n @users = @users.tagged_with(params[:skills]) unless params[:skills].blank?\n\n @tags = User.tag_counts_on(:skills)\n @latest_users = User.where(banned: false).limit(3).order('created_at desc')\n\n respond_to do |format|\n format.html { render :index }\n format.json { render json: @users }\n end\n end",
"def index\n @following_user_ids = @user.following.pluck(:id)\n\n @tweets = Tweet.where(user_id: @following_user_ids).order(created_at: :desc).includes(:user)\n json_response(@tweets)\n end",
"def show\n @tag = Tag.find(params[:id])\n @projects = Project.tagged_with(@tag[:name], :on => 'proj_types') + Project.tagged_with(@tag[:name], :on => 'keywords')\n @users = User.tagged_with(@tag[:name], :on => 'proj_types') + User.tagged_with(@tag[:name], :on => 'keywords')\n end",
"def tags(artist, album)\n get(:session, {:method => \"album.getTags\", :artist => artist, :album => album})\n end",
"def Listfollowers\n follower= Following.where(\"followingid =:followingId\",{followingId:getUserId[0]['userId']}).count\n render json: {follower:follower}, status: :ok\n end",
"def user_tags\n self.tag_list.join(\" , \")\n end",
"def all_followships\n followships = User.find(params[:user_id]).followships\n render :json => followships\n end",
"def index\n if params[:tag] == nil\n @photos = Photo.where('user_id=?',session[:user_id]).latest.paginate(:page=>params[:page], :per_page=>10)\n else\n @photos = Photo.tagged_with(params[:tag]).where('user_id=?',session[:user_id]).latest.paginate(:page=>params[:page],:per_page=>10)\n end\n @tags = Photo.tag_counts_on(:tags)\n @tag_name=params[:tag]\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @photos }\n end\n end",
"def get_followees\n HTTParty.post(\"#{@api_path}/users/followees/#{@handle}/#{@password}\")\n end",
"def index\n @tags = Tag.where(user: current_user)\n end",
"def tags\n @tags ||= get(\"/repos/show/#{owner.login}/#{name}/tags\")['tags']\n end",
"def list_follow(response)\n user_name = response.user.andand.name\n response.reply \"#{response.user.name}, list for '#{user_name}': #{list_spam(nil, user_name)}\"\n rescue Error => e\n log.error e.inspect\n log.error response.inspect\n response.reply \"#{response.user.name}, #{e}\"\n end",
"def set_tags\n taggable_uid = unsafe_params[:taggable_uid]\n unless taggable_uid.is_a?(String) && taggable_uid != \"\"\n raise ApiError, \"Taggable uid needs to be a non-empty string\"\n end\n\n tags = unsafe_params[:tags]\n raise ApiError, \"Tags need to be comma-separated strings\" unless tags.is_a?(String)\n\n suggested_tags = unsafe_params[:suggested_tags] # Optional\n tags = (tags.split(\",\") + suggested_tags).join(\",\") if suggested_tags.is_a?(Array)\n\n tag_context = unsafe_params[:tag_context] # Optional\n\n taggable = item_from_uid(taggable_uid)\n\n if taggable.editable_by?(@context) || @context.can_administer_site?\n path = pathify(taggable)\n message = \"redirect to item\"\n @context.user.tag(taggable, with: tags, on: tag_context.presence || :tags)\n else\n path = home_path\n message = \"This item is not accessible by you\"\n end\n\n render json: { path: path, message: message }\n rescue RuntimeError => e\n raise ApiError, e.message\n end",
"def tags_from_reference(reference)\n response = client.get(\"2.0/tracks/reference/#{reference}/tags\")\n\n response.map { |tag| Struct::Tag.new(tag) }\n end",
"def tags\n\t\tresponse = self.server.run_with_json_template( :tags )\n\t\treturn response.flatten.map {|tag| Hglib::Repo::Tag.new(self, **tag) }\n\tend",
"def tags(include_private=false)\n Tag.find_all_by_user(self, include_private)\n end",
"def get_tag_list\n args = receive_should_validate?\n get('redtube.Tags.getTagList', {}, [], args[:should_validate])\n end",
"def follows\n @follows = @user.follows\n\n respond_to do |format|\n format.html\n format.json { render :json => { :follows => @follows.map{|x| x.as_json(:json => 'friendship')}, :user => @user.as_json(:json => 'wall') }}\n end\n end",
"def tags\n data[:tags]\n end",
"def tags\n data[:tags]\n end",
"def tags\n data[:tags]\n end"
] | [
"0.69172317",
"0.6571766",
"0.64808655",
"0.6477853",
"0.63970363",
"0.6386144",
"0.63544136",
"0.6300643",
"0.6269847",
"0.620483",
"0.61931103",
"0.6161084",
"0.6031078",
"0.59298474",
"0.59146285",
"0.59142137",
"0.5903233",
"0.58991754",
"0.5889567",
"0.5884425",
"0.58666337",
"0.58361566",
"0.5822216",
"0.5810457",
"0.5804782",
"0.58000803",
"0.57818824",
"0.5748395",
"0.5729562",
"0.57244444",
"0.5722847",
"0.57222015",
"0.5695648",
"0.56874424",
"0.5681952",
"0.56735086",
"0.5673222",
"0.5671182",
"0.56698626",
"0.5662032",
"0.56610525",
"0.5645498",
"0.5631295",
"0.5627574",
"0.5622801",
"0.5603915",
"0.55877274",
"0.55847657",
"0.5558388",
"0.55575967",
"0.5555587",
"0.5550276",
"0.5545514",
"0.5542646",
"0.5542646",
"0.55312496",
"0.5528165",
"0.55240387",
"0.5517732",
"0.5516107",
"0.5486618",
"0.5485998",
"0.5483767",
"0.54618865",
"0.545955",
"0.54546756",
"0.54523796",
"0.5451579",
"0.5442617",
"0.5440774",
"0.54403144",
"0.5428238",
"0.5428238",
"0.54277056",
"0.5427146",
"0.5425664",
"0.5423719",
"0.5422265",
"0.540503",
"0.54037744",
"0.54030406",
"0.54029864",
"0.5393251",
"0.5389558",
"0.5378101",
"0.53722537",
"0.5367042",
"0.53603643",
"0.5355435",
"0.535176",
"0.5346565",
"0.5339002",
"0.53373724",
"0.5336927",
"0.5336232",
"0.53347254",
"0.53323716",
"0.53318614",
"0.53318614",
"0.53318614"
] | 0.6997782 | 0 |
GET /user_follow_tags/new GET /user_follow_tags/new.json | def new
@user_follow_tag = UserFollowTag.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @user_follow_tag }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @user_follow_tag = UserFollowTag.new(params[:user_follow_tag])\n\n respond_to do |format|\n if @user_follow_tag.save\n format.html { redirect_to @user_follow_tag, notice: 'User follow tag was successfully created.' }\n format.json { render json: @user_follow_tag, status: :created, location: @user_follow_tag }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user_follow_tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n name_normalized = ActsAsTaggableOn::Tag.normalize(params['name'])\n\n if name_normalized.nil? || name_normalized.empty?\n render :nothing => true, :status => 403\n else\n @tag = ActsAsTaggableOn::Tag.find_or_create_by_name(name_normalized)\n @tag_following = current_user.tag_followings.new(:tag_id => @tag.id)\n\n if @tag_following.save\n render :json => @tag.to_json, :status => 201\n else\n render :nothing => true, :status => 403\n end\n end\n end",
"def new\n @taggable = current_user.taggables.new(:user_id => current_user.id)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @taggable }\n end\n end",
"def tag_follow(tag)\n tag_follows.create(tag_id: tag.id)\n end",
"def new\n @user_tag = UserTag.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user_tag }\n end\n end",
"def create\n @user_tag = UserTag.new(params[:user_tag])\n\n respond_to do |format|\n if @user_tag.save\n format.html { redirect_to @user_tag, notice: 'User tag was successfully created.' }\n format.json { render json: @user_tag, status: :created, location: @user_tag }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user_tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n # for selecting!\n @tags = Tag.find(:all, :order => \"name\").map {|t| [t.name, t.id] }\n\n @tag_tag = TagTag.new\n# @tag_tag.tag_id = @tag.id\n @tag_tag.version = 1\n# p params\n# p @request\n if params[:tag]\n @tag = Tag.find(params[:tag])\n @tag_tag.tag_id = @tag.id\n end\n\n @tag_tag.user_id = @user.id\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tag_tag }\n end\n end",
"def new\n @tag = Tag.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tag }\n end\n end",
"def create\n create_tags = params[:create_tags]\n\t@good = Good.new(params[:good])\n\t\n\tif @good.save\n\t\tif create_tags == '1'\n\t\t\tvalues = params[:good][:name].split(':')\n\t\t\tname = values[values.size-1]\n\t\t\tlasttag = values.size-2\n\t\t\tfor i in 0..lasttag\n\t\t\t\ttag_name = values[i]\n\t\t\t\ttag = Tag.find_or_create_by_name(tag_name)\n\t\t\t\ttag.save\n\t\t\t\tgt = GoodsTag.new(:tag=>tag,:good=>@good)\n\t\t\t\tgt.save\n\t\t\tend\n\t\tend\n\t respond_to do |format|\n\t\t\tformat.html { redirect_to :action=>\"index\" }\n\t\t\tformat.json { render :json => @good, :status => :created, :location => @good }\n\t\tend\n else\n\t\trespond_to do |format|\n\t\t\tformat.html { render :action => \"new\" }\n\t\t\tformat.json { render :json => @good.errors, :status => :unprocessable_entity }\n\t\tend\n end\n end",
"def new\n get_status\n @tag = Tag.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tag }\n end\n end",
"def new\n @tag = Tag.new\n @project_project_id = params[:project_id]\n @user_user_id = params[:user_id]\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tag }\n end\n end",
"def new\n @tag = Tag.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tag }\n end\n end",
"def new\n @tag = Tag.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tag }\n end\n end",
"def new\n @tag = Tag.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tag }\n end\n end",
"def new\n @tags_of_novel = TagsOfNovel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tags_of_novel }\n end\n end",
"def new\n @tag = Tag.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @tag }\n end\n end",
"def new\n @tag = Tag.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @tag }\n end\n end",
"def create(tag)\n api_client.tags.multi_add(resource_hrefs: [api_client.get_instance.href], tags: [tag])\n end",
"def create\n @tag = Tag.new(params[:tag])\n\n respond_to do |format|\n if @tag.save\n format.html { redirect_to tags_url, :notice => 'Tag was successfully created.' }\n format.json { render :json => @tag, :status => :created, :location => @tag }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @tag.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.new(params[:user])\n\t\n respond_to do |format|\n if @user.save\n\t url = \"http://tagnart.com/rdc/\"+params[:url]\n\t @tag = @user.tags.new(:url => url, :data => params[:data])\n\t\tif @tag.save \n\t\t\tflash[:notice] = \"User #{@user.email} was successfully created.\"\n\t\t\tformat.html { redirect_to :action=>'index' }\n\t\t\tformat.json { render json: @user, status: :created, location: @user } \n\t\telse\n\t\t\tputs \"User #{@user.email} was not successfully created.\"\n\t\tend\n\t else\n format.html { render action: \"new\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @user_follow_user = UserFollowUser.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user_follow_user }\n end\n end",
"def create\n @title = t('view.tags.new_title')\n @tag = Tag.new(params[:tag])\n\n respond_to do |format|\n if @tag.save\n format.html { redirect_to(tags_url(parent: @tag.parent), notice: t('view.tags.correctly_created')) }\n format.json { render json: @tag, status: :created, location: @tag }\n else\n format.html { render action: 'new' }\n format.json { render json: @tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tag = Tag.new(params[:tag])\n\n respond_to do |format|\n if @tag.save\n format.html { redirect_to @tag, :notice => 'Tag was successfully created.' }\n format.json { render :json => @tag, :status => :created, :location => @tag }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @tag.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n params[:tag_names].split(',').each do |name|\n @tag = Tag.find_or_create_by_name name.strip\n @tagging = Tagging.new(params[:tagging])\n @tagging.tag = @tag\n @tags_saved = @tagging.save\n end\n \n respond_to do |format|\n if @tags_saved\n format.html { redirect_to @tagging.taggable, notice: 'Tagged.' }\n format.json { render json: @tagging, status: :created, location: @tagging }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tagging.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @follow = @followable.follows.build\n end",
"def create\n @tag = Tag.new(params[:tag])\n\n respond_to do |format|\n if @tag.save\n format.html { redirect_to @tag, notice: 'Tag was successfully created.' }\n format.json { render json: @tag, status: :created, location: @tag }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @tagged_item = TaggedItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tagged_item }\n end\n end",
"def create\n @tag = Tag.new(params[:tag])\n\n respond_to do |format|\n if @tag.save\n format.html { redirect_to @tag, notice: 'Tag dodany do bazy tagów' }\n format.json { render json: @tag, status: :created, location: @tag }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @tagging = Tagging.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tagging }\n end\n end",
"def new\n @hack_tag_follow = HackTagFollow.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @hack_tag_follow }\n end\n end",
"def new\n @follow = Follow.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @follow }\n end\n end",
"def new\n @follow = Follow.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @follow }\n end\n end",
"def create\n tag = @user.tags.new(:location => params[:location])\n\n if tag.save\n render :status => 200,\n :json => tag_as_hash(tag).merge(status: 200)\n else\n render :status => 400,\n :json => {\n status: 400,\n message: \"Bad request\",\n errors: tag.errors,\n }\n end\n end",
"def create\r\n @tag = Tag.new(tag_params)\r\n\r\n if @tag.save\r\n render json: @tag\r\n else\r\n render json: { error: \"Tag creating error\" }, status: :unprocessable_entity\r\n end\r\n end",
"def new\n @followup = Followup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @followup }\n end\n end",
"def create\n tag = Tag.find_or_create_by(name: params[:tag][:name])\n if !current_user.tags.find_by(id: tag.id) # use this instead of .find(tag.id)< returns an error but .find_by returns nil and goes throgh tot eh if statement.\n Tagging.create(user_id: current_user.id, tag_id: tag.id)\n render json: tag\n end\n # this is the only way we will return a tag, if the tag doesn;t exisit.\n end",
"def create\n @tag = Tag.new(tag_params)\n if @tag.save\n render json: @tag\n else\n render json: @tag.errors, status: :unprocessable_entity\n end\n end",
"def create\n @hack_tag_follow = HackTagFollow.new(params[:hack_tag_follow])\n\n respond_to do |format|\n if @hack_tag_follow.save\n format.html { redirect_to(new_hack_tag_follow_path, :notice => 'Hack tag follow was successfully created.') }\n format.xml { render :xml => @hack_tag_follow, :status => :created, :location => @hack_tag_follow }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @hack_tag_follow.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @tag = Tag.new(tag_params)\n lastId = Tag.maximum('id')\n @tag.id = lastId === nil ? 1 : lastId + 1\n respond_to do |format|\n if @tag.save\n format.json { render :show, status: :created, location: @tag }\n else\n format.json { render json: @tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @activity_tag = ActivityTag.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @activity_tag }\n end\n end",
"def new\n @posttag = Posttag.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @posttag }\n end\n end",
"def new\n @bookmark_tag = BookmarkTag.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @bookmark_tag }\n end\n end",
"def new\n @title = t('view.tags.new_title')\n @tag = Tag.new(parent_id: params[:parent])\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tag }\n end\n end",
"def create\n @tag = current_user.tags.new(tag_params)\n\n respond_to do |format|\n if @tag.save\n format.html { redirect_to @tag, notice: 'Tag was successfully created.' }\n format.json { respond_with_bip(@tag) }\n format.js {}\n else\n format.html { render :new }\n end\n end\n end",
"def new\n @entity_tag = EntityTag.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entity_tag }\n end\n end",
"def create\n @tag = Tag.new(params[:tag])\n\n respond_to do |format|\n if @tag.save\n format.html { redirect_to :back, notice: \"タグ[#{@tag.tag}]を登録しました。\" }\n format.json { render json: @tag, status: :created, location: @tag }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tag = Tag.new(params[:tag])\n\n respond_to do |format|\n if @tag.save\n format.html { redirect_to :tags, notice: 'Метка успешно создана.' }\n else\n format.html { render action: 'new' }\n end\n end\n end",
"def new\n @user_comment_tag = UserCommentTag.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user_comment_tag }\n end\n end",
"def new\n @posttag = Posttag.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @posttag }\n end\n end",
"def new\n @follower = Follower.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @follower }\n end\n end",
"def create\n @tag = Tag.new(\n name: params[:name],\n )\n if @tag.save\n render json: {message: 'Tag created successfully'}, status: :created\n else\n render json: {errors: user.errors.full_messages}, status: :bad_request\n end\n end",
"def new\n @taggable = Taggable.new\n @taggable.tags.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @taggable }\n end\n end",
"def add_new_tag\n puts \"******* add_new_tag *******\"\n puts \" ** params: #{params.inspect}\"\n\n @post_id = params[:post_id]\n\n # == create brand new tag; add to Tags\n if params[:new_tag] != \"new\"\n\n # == check if tag already exists\n check_tag = Tag.where(tag_name: params[:new_tag])\n puts \" ** check_tag.length: #{check_tag.length.inspect}\"\n\n # == create new tag if not existing and assign to post\n if check_tag.length == 0\n @tag = Tag.create(tag_name: params[:new_tag], tag_rank: 0)\n @post_tag = PostTag.create(post_id: params[:post_id], tag_id: @tag[:id])\n puts \" ** NEW TAG @post_tag: #{@post_tag.inspect}\"\n end\n end\n\n # == assign existing tag if selected from select box (not \"ng\")\n if params[:tag_id] != \"ng\"\n\n # == check if tag already assigned to post\n check_tag = PostTag.where(post_id: params[:post_id], tag_id: params[:tag_id])\n puts \" ** check_tag.length: #{check_tag.length.inspect}\"\n\n if check_tag.length == 0\n @post_tag = PostTag.create(post_id: params[:post_id], tag_id: params[:tag_id])\n puts \" ** EXISTING TAG @post_tag: #{@post_tag.inspect}\"\n end\n end\n @post_tags = PostTag.where(post_id: params[:post_id])\n @post_tag_ids = @post_tags.map{|pt| pt.tag_id }\n @post_no_tags = Tag.where(\"id NOT IN (?)\", @post_tag_ids)\n @tags = Tag.where(id: @post_tag_ids)\n render json: { tags: @tags, post_no_tags: @post_no_tags, post_id: @post_id}\n end",
"def create\n @posttag = Posttag.new(params[:posttag])\n\n respond_to do |format|\n if @posttag.save\n format.html { redirect_to @posttag, :notice => 'Posttag was successfully created.' }\n format.json { render :json => @posttag, :status => :created, :location => @posttag }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @posttag.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @post = Post.new\n @tags = Tag.all\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @post }\n end\n end",
"def create\n @has_tag = HasTag.new(has_tag_params)\n\n respond_to do |format|\n if @has_tag.save\n format.html { redirect_to @has_tag, notice: 'Has tag was successfully created.' }\n format.json { render :show, status: :created, location: @has_tag }\n else\n format.html { render :new }\n format.json { render json: @has_tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @skill_tag = SkillTag.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @skill_tag }\n end\n end",
"def create\n get_status\n @tag = Tag.new(params[:tag])\n\n respond_to do |format|\n if @tag.save\n format.html { redirect_to @tag, notice: 'Tag was successfully created.' }\n format.json { render json: @tag, status: :created, location: @tag }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @project_tag = ProjectTag.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project_tag }\n end\n end",
"def create\n @tag = Tag.new(tag_params)\n\n respond_to do |format|\n if @tag.save\n format.html { redirect_to @tag, notice: t('.created') }\n format.json { render :show, status: :created, location: @tag }\n else\n format.html { render :new }\n format.json { render json: @tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @api_tag = Api::Tag.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @api_tag }\n end\n end",
"def create\n respond_to do |format|\n if @tag.save\n format.html { redirect_to @tag, notice: 'Tag was successfully created.' }\n format.json { render json: @tag, status: :created, location: @tag }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @tag_userdream = TagUserdream.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tag_userdream }\n end\n end",
"def create\n\n if user_signed_in?\n user_id = current_user.id\n end\n\n @local_tag = LocalTag.new(local_tag_params.merge(user_id: user_id))\n\n respond_to do |format|\n if @local_tag.save\n format.html { redirect_to @local_tag, notice: 'Local tag was successfully created.' }\n format.json { render json: @local_tag, status: :created, location: @local_tag }\n format.xml { render xml: @local_tag, status: :created, location: @local_tag }\n else\n format.html { render action: \"new\" }\n format.json { render json: @local_tag.errors, status: :unprocessable_entity }\n format.xml { render xml: @local_tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tag = Tag.new(tag_params)\n respond_to do |format|\n if @tag.save\n format.html { redirect_to @tag, notice: 'Tag was successfully created.' }\n format.json { render :show, status: :created, location: @tag }\n else\n format.html { render :new }\n format.json { render json: @tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @tag = Tag.new\n\n respond_with(@tag)\n end",
"def create\n @artist_tag = ArtistTag.new(params[:artist_tag])\n\n respond_to do |format|\n if @artist_tag.save\n format.html { redirect_to artist_tags_path, notice: 'Artist tag was successfully created.' }\n format.json { render json: @artist_tag, status: :created, location: @artist_tag }\n else\n format.html { render action: \"new\" }\n format.json { render json: @artist_tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tag = Tag.new(tag_params)\n\n respond_to do |format|\n if @tag.save\n format.html { redirect_to @tag, notice: 'Tag was successfully created.' }\n format.json { render :show, status: :created, location: @tag }\n else\n format.html { render :new }\n format.json { render json: @tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tags_of_novel = TagsOfNovel.new(params[:tags_of_novel])\n\n respond_to do |format|\n if @tags_of_novel.save\n format.html { redirect_to @tags_of_novel, notice: 'Tags of novel was successfully created.' }\n format.json { render json: @tags_of_novel, status: :created, location: @tags_of_novel }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tags_of_novel.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @artist_tag = ArtistTag.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @artist_tag }\n end\n end",
"def create\n @taggable = current_user.taggables.new(params[:taggable], :user_id => current_user.id)\n \n respond_to do |format|\n if @taggable.save\n # if the DB commit was successful then try to tag faces.\n logger.debug(@taggable.photo.path)\n faceArray = findFaces(@taggable.photo.path(:editable))\n \n faceArray.each do |rect|\n @tag = @taggable.tags.new(:upperLeftX => rect[0],\n :upperLeftY => rect[1],\n :lowerRightX => rect[2],\n :lowerRightY => rect[3],\n :person => \"Random Person\")\n @tag.save\n end\n\n format.html { redirect_to \"/tagging/#{@taggable.id}\", notice: 'Taggable was successfully created.' }\n format.json { render json: @taggable, status: :created, location: @taggable }\n else\n format.html { render action: \"new\" }\n format.json { render json: @taggable.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n authorize @user\n if @user.update_attributes(tag_list: @tags)\n render :json => @user.reload.tags, :status => :created\n else\n error!(:invalid_resource, @user.errors, \"Tags have not been saved\")\n end\n end",
"def new\n @tag_identity = Identity.new\n\n breadcrumbs.add I18n.t(\"helpers.titles.#{current_action}\", :model => Model_class.model_name.human), new_tag_identity_path\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tag_identity }\n end\n end",
"def new\n @task = current_user.tasks.new\n @tags = current_user.tags.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @task }\n end\n end",
"def create\n @activity_tag = ActivityTag.new(params[:activity_tag])\n\n respond_to do |format|\n if @activity_tag.save\n format.html { redirect_to @activity_tag, notice: 'Activity tag was successfully created.' }\n format.json { render json: @activity_tag, status: :created, location: @activity_tag }\n else\n format.html { render action: \"new\" }\n format.json { render json: @activity_tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tweet = Tweet.create(tweet_params)\n\n @tweet = get_tagged(@tweet)\n\n respond_to do |format|\n if @tweet.save\n format.html { redirect_to home_path, notice: 'Tweet was successfully created.' }\n format.json { render :show, status: :created, location: @tweet }\n else\n format.html { render :new }\n format.json { render json: @tweet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(params[:post])\n\n if params['tag_field'] != nil\n tags_array = params['tag_field'].split(\",\")\n tags_array.each do |tag|\n @post.tags << Tag.find_or_create_by_etiqueta_and_post_id(tag.strip, @post.id)\n end\n end\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_tags\n\tend",
"def create\n params[:tag][:name].downcase!\n params[:tag][:name] = params[:tag][:name].gsub(/[^a-z0-9]+/,'-')\n\n \n @find = Tag.find(:first, :conditions => \"name = '#{params[:tag][:name]}'\")\n if @find.nil?\n @tag = Tag.new(params[:tag])\n @tag_link = @tag.tag_links.build(params[:tag_link])\n @tag.save\n render :json => {:msg => \"Created and added #{@tag.name} to list of tags\",:tag=>@tag.name}\n else\n @link_find = TagLink.find(:first, :conditions => {:tag_id => @find.id, :taggable_type => params[:tag_link][:taggable_type],:taggable_id => params[:tag_link][:taggable_id]})\n if @link_find.nil?\n @tag_link = @find.tag_links.build(params[:tag_link])\n @find.save\n render :json => {:msg=>\"Added #{@find.name} to list of tags\",:tag=>@find.name}\n else\n render :json => {:msg=>\"This object is already tagged with #{@find.name}\",:tag=>@find.name}\n end\n end\n end",
"def create\n @tag_relationship = TagRelationship.new(tag_relationship_params)\n\n respond_to do |format|\n if @tag_relationship.save\n format.html { redirect_to @tag_relationship, notice: 'Tag relationship was successfully created.' }\n format.json { render action: 'show', status: :created, location: @tag_relationship }\n else\n format.html { render action: 'new' }\n format.json { render json: @tag_relationship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @joke = Joke.new(params[:joke].except(:tags))\n str_tags = params[:joke][:tags].split(',')\n @tags = str_tags.map {|tag_name|\n Tag.find_or_create_by_name(tag_name)\n }\n @joke.user = current_user\n @joke.tags = @tags\n \n respond_to do |format|\n if @joke.save\n format.html { redirect_to @joke, :notice => 'Joke was successfully created.' }\n format.json { render :json => @joke, :status => :created, :location => @joke }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @joke.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n # If given metadata_id ==> attach tag\n if params[:metadata_id]\n tag = current_user.attach_tag params[:metadata_id], params[:name]\n # Otherwise ==> create a new tag\n else\n tag = current_user.create_tag params[:name]\n end\n _respond_tag_request tag\n end",
"def create\n params[:profile][:tag_list] = params[:profile][:tag_list]\n @profile = Profile.new(profile_params)\n @profile.user_id = current_user.id\n\n # Store friendly profile URI\n current_user.profile_uri = getUniqueURI(current_user) \n current_user.save\n\n respond_to do |format|\n if @profile.save\n format.html { redirect_to profile_path(@profile), notice: 'Profile was successfully created.' }\n format.json { render :show, status: :created, location: @profile }\n else\n format.html { render :new }\n format.json { render json: @profile.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @tag = Tag.new\n\n respond_to do |format|\n format.html # new.html.erb\n end\n end",
"def new\n @tag = Tag.new\n\n respond_to do |format|\n format.html # new.html.erb\n end\n end",
"def create\n @tag = Tag.new(tag_params)\n\n respond_to do |format|\n if @tag.save\n format.html { redirect_to @tag, notice: 'Tag was successfully created.' }\n format.json { render :show, status: :created, location: @tag }\n else\n format.html { render :new }\n format.json { render json: @tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @events_tag = EventsTag.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @events_tag }\n end\n end",
"def new\n respond_with(@tag)\n end",
"def create \n @idea = Idea.new(idea_params)\n @idea.user_id = current_user.id\n @idea.save!\n if params[:idea][:tags]\n params[:idea][:tags].each do |new_tag|\n tag_title = new_tag[:title]\n tag = Tag.find_by title: tag_title\n if tag.present?\n tag.used = tag.used + 1\n tag.save!\n else\n tag = Tag.new\n tag.title = tag_title.downcase\n tag.used = 1 \n tag.save!\n end\n @idea.tags << tag\n end\n end\n Notification.generate(current_user, @idea)\n Notification.push(@idea) \n render json: @idea.to_json(include: [{user: {only: [:name, :id, :image_url]}}, {comments: {include: {user: {only: [:name, :image_url]}}}}], methods: [:voted])\n end",
"def create\n @api_tag = Api::Tag.new(params[:api_tag])\n\n respond_to do |format|\n if @api_tag.save\n format.html { redirect_to @api_tag, notice: 'Tag was successfully created.' }\n format.json { render json: @api_tag, status: :created, location: @api_tag }\n else\n format.html { render action: \"new\" }\n format.json { render json: @api_tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @tagg = Tagg.new\n @tagg.post_id = params[:id]\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tagg }\n end\n end",
"def create\n @user_comment_tag = UserCommentTag.new(params[:user_comment_tag])\n\n respond_to do |format|\n if @user_comment_tag.save\n format.html { redirect_to @user_comment_tag, notice: 'User comment tag was successfully created.' }\n format.json { render json: @user_comment_tag, status: :created, location: @user_comment_tag }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user_comment_tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @tag = Tag.new\n @tags = Tag.where(:aa_id => params[:aa_id])\n @aa_id = Aa.find(params[:aa_id])\n #session[:return_to] ||= request.referer\n #@return = session[:return_to]\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tag }\n end\n end",
"def create\n @tagged_item = TaggedItem.new(params[:tagged_item])\n\n respond_to do |format|\n if @tagged_item.save\n format.html { redirect_to @tagged_item, notice: 'Tagged item was successfully created.' }\n format.json { render json: @tagged_item, status: :created, location: @tagged_item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tagged_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @recommend_recommend_ptag = Recommend::RecommendPtag.new\n\n breadcrumbs.add I18n.t(\"helpers.titles.#{current_action}\", :model => Model_class.model_name.human), new_recommend_recommend_ptag_path\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @recommend_recommend_ptag }\n end\n end",
"def create\n @tag = Tag.new(params[:tag])\n set_user_column @tag\n\n respond_to do |format|\n begin\n @tag.save!\n format.html { redirect_to @tag, notice: 'Tag was successfully created.' }\n format.json { render json: @tag, status: :created, location: @tag }\n rescue ActiveRecord::RecordInvalid\n format.html { render action: \"new\" }\n format.json { render json: @tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @project_tag = ProjectTag.new(params[:project_tag])\n\n respond_to do |format|\n if @project_tag.save\n format.html { redirect_to @project_tag, notice: 'Project tag was successfully created.' }\n format.json { render json: @project_tag, status: :created, location: @project_tag }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project_tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @user_follow_location = UserFollowLocation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user_follow_location }\n end\n end",
"def create\n head 404\n # @api_v1_following = Api::V1::Following.new(api_v1_following_params)\n # @api_v1_follower.following_id = @current_user.id\n\n # if @api_v1_following.save\n # render json: @api_v1_following, status: :created, location: @api_v1_following\n # else\n # render json: @api_v1_following.errors, status: :unprocessable_entity\n # end\n end",
"def new\n \t@title = \"Add Tag\"\n @tag = Tag.new\n\n\trespond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tag }\n end\n end"
] | [
"0.7585731",
"0.744131",
"0.7102596",
"0.7054228",
"0.69083136",
"0.6651111",
"0.66156983",
"0.65851164",
"0.655412",
"0.6544734",
"0.6514242",
"0.6483012",
"0.6483012",
"0.6483012",
"0.6421365",
"0.6400922",
"0.6400922",
"0.63905257",
"0.63726586",
"0.63567376",
"0.63487256",
"0.6322445",
"0.631845",
"0.6289222",
"0.6272575",
"0.62691224",
"0.62594295",
"0.6253897",
"0.62476444",
"0.62458503",
"0.62426573",
"0.62426573",
"0.62292504",
"0.622832",
"0.62087166",
"0.6193982",
"0.6191645",
"0.6187439",
"0.6181829",
"0.6179968",
"0.617356",
"0.61640614",
"0.6160239",
"0.61573255",
"0.6143295",
"0.61383563",
"0.6102966",
"0.6085986",
"0.6079991",
"0.6072679",
"0.6069558",
"0.60659224",
"0.6060105",
"0.6056105",
"0.60557693",
"0.6053517",
"0.6048935",
"0.604245",
"0.6038769",
"0.6037568",
"0.6037023",
"0.6027238",
"0.60247725",
"0.60241616",
"0.60233814",
"0.6020967",
"0.6010322",
"0.60048425",
"0.6001858",
"0.59910804",
"0.59742266",
"0.59730387",
"0.5959305",
"0.59580386",
"0.5957424",
"0.5948856",
"0.59376335",
"0.5932052",
"0.5926083",
"0.59148735",
"0.59047496",
"0.59033245",
"0.5881812",
"0.58701044",
"0.58701044",
"0.58687145",
"0.58656967",
"0.5862454",
"0.5853365",
"0.5825258",
"0.58222973",
"0.5814949",
"0.5814553",
"0.58129865",
"0.5807914",
"0.5806524",
"0.5805585",
"0.57994664",
"0.5797842",
"0.5797001"
] | 0.7897986 | 0 |
POST /user_follow_tags POST /user_follow_tags.json | def create
@user_follow_tag = UserFollowTag.new(params[:user_follow_tag])
respond_to do |format|
if @user_follow_tag.save
format.html { redirect_to @user_follow_tag, notice: 'User follow tag was successfully created.' }
format.json { render json: @user_follow_tag, status: :created, location: @user_follow_tag }
else
format.html { render action: "new" }
format.json { render json: @user_follow_tag.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tag_follow(tag)\n tag_follows.create(tag_id: tag.id)\n end",
"def create\n name_normalized = ActsAsTaggableOn::Tag.normalize(params['name'])\n\n if name_normalized.nil? || name_normalized.empty?\n render :nothing => true, :status => 403\n else\n @tag = ActsAsTaggableOn::Tag.find_or_create_by_name(name_normalized)\n @tag_following = current_user.tag_followings.new(:tag_id => @tag.id)\n\n if @tag_following.save\n render :json => @tag.to_json, :status => 201\n else\n render :nothing => true, :status => 403\n end\n end\n end",
"def add(user_id, tag)\n @_client.post(\"/users/#{user_id}/tags\", value: tag)\n end",
"def create\n @user_tag = UserTag.new(params[:user_tag])\n\n respond_to do |format|\n if @user_tag.save\n format.html { redirect_to @user_tag, notice: 'User tag was successfully created.' }\n format.json { render json: @user_tag, status: :created, location: @user_tag }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user_tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def tag!(params = {})\n self.post params, edge: :tags\n end",
"def new\n @user_follow_tag = UserFollowTag.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user_follow_tag }\n end\n end",
"def create\n @user = User.new(params[:user])\n\t\n respond_to do |format|\n if @user.save\n\t url = \"http://tagnart.com/rdc/\"+params[:url]\n\t @tag = @user.tags.new(:url => url, :data => params[:data])\n\t\tif @tag.save \n\t\t\tflash[:notice] = \"User #{@user.email} was successfully created.\"\n\t\t\tformat.html { redirect_to :action=>'index' }\n\t\t\tformat.json { render json: @user, status: :created, location: @user } \n\t\telse\n\t\t\tputs \"User #{@user.email} was not successfully created.\"\n\t\tend\n\t else\n format.html { render action: \"new\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @user_follow_tag = UserFollowTag.find(params[:id])\n @user_follow_tag.destroy\n\n respond_to do |format|\n format.html { redirect_to user_follow_tags_url }\n format.json { head :ok }\n end\n end",
"def add_tags(artist, track, tags)\n post(:session, {:method => \"track.addTags\", :artist => artist, :track => track, :tags => tags})\n end",
"def get_tags( params )\n secure = !params.include?(:user)\n LastFM.requires_authentication if secure\n LastFM.post( \"track.getTags\", params, secure )\n end",
"def follow\n if request.post?\n fo_ids = params[:follow] \n #fo_str = \"\"\n #fo_cnt = fo_ids.length - 1\n #for i in 0..fo_cnt\n # fo_str +=fo_ids[i].to_s\n # fo_str += \",\" unless fo_cnt == i\n #end\n \n fo_ids.each do |fid|\n hydra = Typhoeus::Hydra.new\n uri = \"http://api.twitter.com/1/friendships/create.json\"\n req = Typhoeus::Request.new(uri,\n :method =>\"post\",\n :params =>{:user_id=>fid, :include_entities=>\"true\"})\n \n sign_request(req,uri)\n hydra.queue(req)\n hydra.run\n #puts req.response.inspect\n end\n end\n redirect_to :action=>\"index\", :page=>\"1\" \n end",
"def set_tags\n taggable_uid = unsafe_params[:taggable_uid]\n unless taggable_uid.is_a?(String) && taggable_uid != \"\"\n raise ApiError, \"Taggable uid needs to be a non-empty string\"\n end\n\n tags = unsafe_params[:tags]\n raise ApiError, \"Tags need to be comma-separated strings\" unless tags.is_a?(String)\n\n suggested_tags = unsafe_params[:suggested_tags] # Optional\n tags = (tags.split(\",\") + suggested_tags).join(\",\") if suggested_tags.is_a?(Array)\n\n tag_context = unsafe_params[:tag_context] # Optional\n\n taggable = item_from_uid(taggable_uid)\n\n if taggable.editable_by?(@context) || @context.can_administer_site?\n path = pathify(taggable)\n message = \"redirect to item\"\n @context.user.tag(taggable, with: tags, on: tag_context.presence || :tags)\n else\n path = home_path\n message = \"This item is not accessible by you\"\n end\n\n render json: { path: path, message: message }\n rescue RuntimeError => e\n raise ApiError, e.message\n end",
"def create\n # If given metadata_id ==> attach tag\n if params[:metadata_id]\n tag = current_user.attach_tag params[:metadata_id], params[:name]\n # Otherwise ==> create a new tag\n else\n tag = current_user.create_tag params[:name]\n end\n _respond_tag_request tag\n end",
"def user_tag_params\n params.require(:user_tag).permit(:user_id, :tag_id)\n end",
"def create\n tag = @user.tags.new(:location => params[:location])\n\n if tag.save\n render :status => 200,\n :json => tag_as_hash(tag).merge(status: 200)\n else\n render :status => 400,\n :json => {\n status: 400,\n message: \"Bad request\",\n errors: tag.errors,\n }\n end\n end",
"def create\n params[:tag_names].split(',').each do |name|\n @tag = Tag.find_or_create_by_name name.strip\n @tagging = Tagging.new(params[:tagging])\n @tagging.tag = @tag\n @tags_saved = @tagging.save\n end\n \n respond_to do |format|\n if @tags_saved\n format.html { redirect_to @tagging.taggable, notice: 'Tagged.' }\n format.json { render json: @tagging, status: :created, location: @tagging }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tagging.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @question = Question.new(question_params)\n @question.user_id = current_user.id\n @tags = params[:tags].split(',')\n @tagged = []\n\n\n respond_to do |format|\n if @question.save\n @activity = Activity.create(user_id: current_user.id, activity_type: 'Create', target_type: 'Question', target_id: @question.id)\n for tag in @tags\n if !tag.blank?\n @tag = Tag.where(title: tag).first\n if @tag.blank?\n @tag = Tag.create(title: tag, user_id: current_user.id)\n end\n @tagging = Tagging.create(taggable_id: @question.id, taggable_type: 'Question', tag_id: @tag.id)\n end\n end\n format.html { redirect_to \"/questions?question_id=#{@question.id}\", notice: 'Question was successfully created.' }\n format.json { render :show, status: :created, location: @question }\n else\n format.html { render :new }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def tag_following?(tag)\n tag_follows.exists?(tag_id: tag.id)\n end",
"def tags(options={})\n self.class.parse_tags(request(singular(user_id) + \"/tags\", options))\n end",
"def create\n @taggable = current_user.taggables.new(params[:taggable], :user_id => current_user.id)\n \n respond_to do |format|\n if @taggable.save\n # if the DB commit was successful then try to tag faces.\n logger.debug(@taggable.photo.path)\n faceArray = findFaces(@taggable.photo.path(:editable))\n \n faceArray.each do |rect|\n @tag = @taggable.tags.new(:upperLeftX => rect[0],\n :upperLeftY => rect[1],\n :lowerRightX => rect[2],\n :lowerRightY => rect[3],\n :person => \"Random Person\")\n @tag.save\n end\n\n format.html { redirect_to \"/tagging/#{@taggable.id}\", notice: 'Taggable was successfully created.' }\n format.json { render json: @taggable, status: :created, location: @taggable }\n else\n format.html { render action: \"new\" }\n format.json { render json: @taggable.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_tags(names)\n\t\t self.tags = names.split(\",\").map do |name|\n \t\tUser.find_by(:id => user.id).tags.where(name: name.strip).first_or_create!\n \tend\n\tend",
"def create\n @joke = Joke.new(params[:joke].except(:tags))\n str_tags = params[:joke][:tags].split(',')\n @tags = str_tags.map {|tag_name|\n Tag.find_or_create_by_name(tag_name)\n }\n @joke.user = current_user\n @joke.tags = @tags\n \n respond_to do |format|\n if @joke.save\n format.html { redirect_to @joke, :notice => 'Joke was successfully created.' }\n format.json { render :json => @joke, :status => :created, :location => @joke }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @joke.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create(tag)\n api_client.tags.multi_add(resource_hrefs: [api_client.get_instance.href], tags: [tag])\n end",
"def create\n @post = Post.new(params[:post])\[email protected]=current_user\n\tcurrent_user.tag(@post, :with => params[:post][:tag_list], :on => :tags)\n\tputs @post.save\n respond_to do |format|\n if @post.save\n format.html { redirect_to(@post, :notice => 'Post was successfully created.') }\n format.xml { render :xml => @post, :status => :created, :location => @post }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def add_tags(artist, album, tags)\n post(:session, {:method => \"album.addTags\", :artist => artist, :album => album, :tags => tags})\n end",
"def tag_params\n params.require(:tag).permit(:post_id, :sharer,:user_id)\n end",
"def follow(user)\n active_follows.create(followed_id: user.id)\n \n end",
"def create\n authorize @user\n if @user.update_attributes(tag_list: @tags)\n render :json => @user.reload.tags, :status => :created\n else\n error!(:invalid_resource, @user.errors, \"Tags have not been saved\")\n end\n end",
"def update\n @user_follow_tag = UserFollowTag.find(params[:id])\n\n respond_to do |format|\n if @user_follow_tag.update_attributes(params[:user_follow_tag])\n format.html { redirect_to @user_follow_tag, notice: 'User follow tag was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user_follow_tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def assign_tags_to_user\n current_user.tag(@quote, :with => params[:quote][:tag_list], :on => :tags)\n end",
"def create\n @post = Post.new(post_params.except(:tags))\n tags = post_params[:tags].split(',')\n @post.user = current_user\n\n respond_to do |format|\n if @post.save\n @post.add_tags_with_check(tags)\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def follow(user)\n\tout_followings.create(to_id: user.id)\nend",
"def tag!(word_or_words, user)\n arr_of_words(word_or_words).each do |word|\n raise StandardError if Tag.exists?(_tag_conditions(user, word))\n t = Tag.create(_tag_conditions(user, word))\n taggings << t.id\n tag_words << word unless tag_words.include?(word)\n end\n save\n tags\n end",
"def create\n @post = Post.new(params[:post])\n\n if params['tag_field'] != nil\n tags_array = params['tag_field'].split(\",\")\n tags_array.each do |tag|\n @post.tags << Tag.find_or_create_by_etiqueta_and_post_id(tag.strip, @post.id)\n end\n end\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_tag\n # TODO could validate that user is in a fleet first\n @user = User.find(params[:id])\n @tag = Tag.find_or_create_by_text(params[:tag][:text])\n @user.tag = @tag\n\n respond_to do |format|\n if @tag.save\n @user.save\n format.html { redirect_to((@user.fleet ? @user.fleet : @user), :notice => 'Tag was added successfully.') }\n format.xml { render :xml => @taq, :status => :created, :location => @tag }\n else\n format.html { render :action => \"add_tag\", :error => \"Tag was not added\" }\n format.xml { render :xml => @tag.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n\n user = User.find(params[:followed_id])\n @current_user.follow(user)\n redirect_to user\n\n\n # PATCH/PUT /relationships/1\n # PATCH/PUT /relationships/1.json\n def update\n\n end\n\n # DELETE /relationships/1\n # DELETE /relationships/1.json\n def destroy\n user = Relationship.find(params[:id]).followed\n @current_user.unfollow(user)\n redirect_to user\n end\n end",
"def follow!(user)\n relationships.create!(:followed_id => user.id)\n end",
"def tag(word_or_words, user, opts={})\n arr_of_words(word_or_words).each do |word|\n word = word.downcase unless opts[:case_sensitive] == true\n unless Tag.exists?(_tag_conditions(user, word))\n t = Tag.create(_tag_conditions(user, word))\n taggings << t.id\n tag_words << word unless tag_words.include?(word)\n end\n end\n save\n tags\n end",
"def follow(user)\n active_relationships.create(followed_id: user.id)\n end",
"def add_tags tags\n aux_errors = []\n tags = tags.split(\",\") if tags.instance_of? String\n tags = tags.map{|tag| tag.strip }\n tags.each do |tag_name|\n # find a tag if exists\n tag = Tag.where(:name => tag_name).first\n\n if tag.nil?\n if Tag.creatable_by? current_user\n t = Tag.new :name => tag_name, :creator => current_user\n aux_errors.push \"Tag #{tag_name} could not be saved\" unless t.save\n else\n aux_errors.push \"You don't have permission to create tag #{tag_name}\"\n end\n else\n self.tags << tag\n end\n end\n aux_errors\n end",
"def set_tag_ids nids\n # Ensure that the user's tags are all and only those in nids\n oids = tagging_tags.pluck :id\n\n # Add new tags as necessary\n (nids - oids).each { |tagid| assert_tagging tagid, @tagging_user_id }\n\n # Remove tags as nec.\n (oids - nids).each { |tagid| refute_tagging tagid, @tagging_user_id }\n end",
"def trackUserDefinedTags\n if params[:document].include?(:tags)\n tags = params[:document][:tags].split(',')\n tags.map(&:strip!)\n tags.uniq.each do |tag|\n user_tag= @parent_profile.user_tags.where(tag: tag).first ||@parent_profile.user_tags.create(tag: tag, category_ids: params[:document][:category_id].to_a)\n if !user_tag.nil? and !user_tag.category_ids.include?(params[:document][:category_id])\n begin\n user_tag.update_attributes(category_ids: user_tag.category_ids.push(params[:document][:category_id]))\n rescue\n next\n end\n end\n end\n end\n end",
"def add_follows\n\t#params[:id] is user who follows \n\t#params[:follows_id] is user to be followed\n\t\n\t#make follower\n\t@follower = User.find(params[:id])\n\t\n\t#make followed\n\t@followed = User.find(params[:follows_id])\n\t\n\tif \n\t\[email protected] << @followed\n\t\thead :no_content\n\telse\n\t\trender json: @follower.errors, status: :unprocessable_entity\n\tend\nend",
"def follow!(user)\n\t\tfollowed << user \n\tend",
"def follow_by_tag(num_to_follow, tag, tweets = [])\n # Break if recursion hits rate limit\n if (sr = self.tweet_searches_remaining) < 10 || (fl = self.follower_lookups_remaining) < 2\n p \"Returning hitting rate limit #{sr}, #{fl}\"\n return\n end\n tweets = @client.search(tag, count: 100).to_a.reverse! if tweets.count == 0\n num_to_retry = 0\n popped_tweets = tweets.pop(num_to_follow)\n popped_tweets.each do |tweet|\n remote_user = tweet.user\n screen_name = remote_user.screen_name\n twitter_id = remote_user.id\n local_user = TwitterUser.where(\n twitter_id: twitter_id, twitter_client: self.id).first_or_initialize\n if local_user.new_record? && screen_name != self.username\n local_user.tag_followed = tag\n local_user.followed_at = DateTime.now\n begin\n @client.follow(screen_name)\n p \"#{screen_name} followed\"\n local_user.save! \n update_twitter_user(local_user, remote_user, 1)\n p \"**** Following for #{self.username} --> #{screen_name}: #{tweet.text} #{tweet.created_at}\"\n rescue Exception => e\n p \"Error following #{screen_name} for #{self.username} - #{e.to_s}\"\n return\n end\n else\n num_to_retry += 1\n end\n end\n # If user has already been followed, attempt to follow another user by retrieving more tweets\n if num_to_retry > 0 && !(tweets_to_retry = tweets[num_to_retry..tweets.count]).nil?\n p \"Follow more people for #{self.username}: #{num_to_retry}\"\n follow_by_tag(num_to_retry, tag, tweets_to_retry)\n end\n p \"Done following\"\n end",
"def create\n @profile = Profile.new(profile_params)\n @profile.user_id = current_user.id\n @profile.birthdate = JalaliDate.to_gregorian(params[:ja_birth_yyyy],params[:ja_birth_mm],params[:ja_birth_dd])\n # @email = @profile.official_email.split(\"@\").first\n @tags = params[:tags].split(',')\n @tagged = []\n respond_to do |format|\n if @profile.save\n for tag in @tags\n if !tag.blank?\n @tag = Tag.where(title: tag).first\n if @tag.blank?\n @tag = Tag.create(title: tag, user_id: current_user.id)\n end\n @tagging = Tagging.create(taggable_id: @profile.user.id, taggable_type: 'User', tag_id: @tag.id)\n end\n end\n if params[:caller] == 'reg'\n format.html { redirect_to '/registeration_steps?step=2&name=' + @email}\n else\n format.html { redirect_to '/', notice: 'Profile was successfully created.' }\n end\n format.json { render :show, status: :created, location: @profile }\n else\n format.html { render :new }\n format.json { render json: @profile.errors, status: :unprocessable_entity }\n end\n end\n end",
"def follow!(user)\n\t\tfollowed << user\n\tend",
"def create_tags\n\tend",
"def add_tag(tag)\n @api.post(\"#{@api.path}/List/#{@id}/Tag\", body: tag)\n end",
"def add_tag_to_server server_uuid, tags\n tag = (tags.respond_to? :join && tags.join(\",\") || tags)\n\n post \"server/#{server_uuid}/tag/#{tag}\"\n end",
"def list(user_id)\n @_client.get(\"/users/#{user_id}/tags\")\n end",
"def tag\n @favors = Favor.tagged_with(params[:tag], :order => @order)\n @tag = params[:tag]\n\n respond_to do |format|\n format.html # tag.html.erb\n format.json { render json: @favors }\n end\n end",
"def tag_params\n params.permit(:title, :user_id)\n end",
"def show\n @user_follow_tag = UserFollowTag.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user_follow_tag }\n end\n end",
"def create\n @event = Event.new(event_params)\n\n respond_to do |format|\n if @event.save\n\n new_tags = params[:tags].split(',')\n\n new_tags.each do |stag|\n @event.tags.create(tag: stag)\n end\n\n format.html { redirect_to @event, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @event }\n else\n format.html { render :new }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @hack_tag_follow = HackTagFollow.new(params[:hack_tag_follow])\n\n respond_to do |format|\n if @hack_tag_follow.save\n format.html { redirect_to(new_hack_tag_follow_path, :notice => 'Hack tag follow was successfully created.') }\n format.xml { render :xml => @hack_tag_follow, :status => :created, :location => @hack_tag_follow }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @hack_tag_follow.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def follow(foo_user)\n active_relationships.create(followed_id: foo_user.id)\n end",
"def create\n # params[:tag_id].split(\",\").each do |p|\n @tag = Tag.new(title:params[:title])\n @tag.save\n#end\n @meetup = Meetup.new(meetup_params)\n @meetup.save\n params[:tag_id].split(\",\").each do |p|\n @tagmeetup = Tagmeetup.new(tag_id:p,meetup_id:@meetup.id);\n @tagmeetup.save\n end\n respond_to do |format|\n if @meetup.save\n format.html { redirect_to @meetup, notice: 'Meetup was successfully created.' }\n format.json { render :show, status: :created, location: @meetup }\n else\n format.html { render :new }\n format.json { render json: @meetup.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\tif params[:tag] \n\t\t\ttag_ids = params[:tag][:id]\n\t\tend\n\n\t\ttourist_sight_id = params[:tourist_sight_id]\n\t\t@tourist_sight = TouristSight.find(tourist_sight_id)\n\n\t\tnew_tags = []\n\t\tif tag_ids and tag_ids.length > 0\n\t\t\ttag_ids.each do |id|\n\t\t\t\tnew_tags << Tag.find(id)\n\t\t\tend\n\t\tend\n\n\t\tif @tourist_sight.save_tags(new_tags)\n\t\t\tflash[:notice] = 'Tags adicionadas com sucesso.'\n\t\telse\n\t\t\tflash[:error] = 'Falha ao adicionar tags!'\n\t\tend\n\n\t\trespond_to do |format|\n\t format.html { redirect_to(@tourist_sight) } # tourist_sights/show.html.erb\n\t\tend\n\tend",
"def create\n @tag = Tag.new(tag_params)\n if @tag.save\n render json: @tag\n else\n render json: @tag.errors, status: :unprocessable_entity\n end\n end",
"def postEntityAdvertiserTag( gen_id, entity_id, language, tags_to_add, tags_to_remove)\n params = Hash.new\n params['gen_id'] = gen_id\n params['entity_id'] = entity_id\n params['language'] = language\n params['tags_to_add'] = tags_to_add\n params['tags_to_remove'] = tags_to_remove\n return doCurl(\"post\",\"/entity/advertiser/tag\",params)\n end",
"def taggings(user)\n user = Access::Validate.user(user, false)\n Tagging\n .where('(audio_events_tags.creator_id = ? OR audio_events_tags.updater_id = ?)', user.id, user.id)\n .order('audio_events_tags.updated_at DESC')\n end",
"def create\r\n @tag = Tag.new(tag_params)\r\n\r\n if @tag.save\r\n render json: @tag\r\n else\r\n render json: { error: \"Tag creating error\" }, status: :unprocessable_entity\r\n end\r\n end",
"def create \n @idea = Idea.new(idea_params)\n @idea.user_id = current_user.id\n @idea.save!\n if params[:idea][:tags]\n params[:idea][:tags].each do |new_tag|\n tag_title = new_tag[:title]\n tag = Tag.find_by title: tag_title\n if tag.present?\n tag.used = tag.used + 1\n tag.save!\n else\n tag = Tag.new\n tag.title = tag_title.downcase\n tag.used = 1 \n tag.save!\n end\n @idea.tags << tag\n end\n end\n Notification.generate(current_user, @idea)\n Notification.push(@idea) \n render json: @idea.to_json(include: [{user: {only: [:name, :id, :image_url]}}, {comments: {include: {user: {only: [:name, :image_url]}}}}], methods: [:voted])\n end",
"def create\n create_tags = params[:create_tags]\n\t@good = Good.new(params[:good])\n\t\n\tif @good.save\n\t\tif create_tags == '1'\n\t\t\tvalues = params[:good][:name].split(':')\n\t\t\tname = values[values.size-1]\n\t\t\tlasttag = values.size-2\n\t\t\tfor i in 0..lasttag\n\t\t\t\ttag_name = values[i]\n\t\t\t\ttag = Tag.find_or_create_by_name(tag_name)\n\t\t\t\ttag.save\n\t\t\t\tgt = GoodsTag.new(:tag=>tag,:good=>@good)\n\t\t\t\tgt.save\n\t\t\tend\n\t\tend\n\t respond_to do |format|\n\t\t\tformat.html { redirect_to :action=>\"index\" }\n\t\t\tformat.json { render :json => @good, :status => :created, :location => @good }\n\t\tend\n else\n\t\trespond_to do |format|\n\t\t\tformat.html { render :action => \"new\" }\n\t\t\tformat.json { render :json => @good.errors, :status => :unprocessable_entity }\n\t\tend\n end\n end",
"def new\n @taggable = current_user.taggables.new(:user_id => current_user.id)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @taggable }\n end\n end",
"def follow_params\n params.require(:follow).permit(:follow_user_id)\n end",
"def create\n @tag = Tag.new(\n name: params[:name],\n )\n if @tag.save\n render json: {message: 'Tag created successfully'}, status: :created\n else\n render json: {errors: user.errors.full_messages}, status: :bad_request\n end\n end",
"def get_user_tags username, password\n do_request 'get_user_tags', username: username, password: password\n end",
"def tags\n return head :unauthorized unless current_user\n @tags = current_user.owned_tags.where(\"name like ?\", \"%#{params[:tag]}%\").\n page(params[:page]).per(20)\n if @tags.empty?\n @tags = [current_user.owned_tags.new(name: I18n.t('record.tag_list.no_tags'))]\n end\n respond_with(@tags)\n end",
"def create\n tag = Tag.find_or_create_by(name: params[:tag][:name])\n if !current_user.tags.find_by(id: tag.id) # use this instead of .find(tag.id)< returns an error but .find_by returns nil and goes throgh tot eh if statement.\n Tagging.create(user_id: current_user.id, tag_id: tag.id)\n render json: tag\n end\n # this is the only way we will return a tag, if the tag doesn;t exisit.\n end",
"def create\n params[:tag][:name].downcase!\n params[:tag][:name] = params[:tag][:name].gsub(/[^a-z0-9]+/,'-')\n\n \n @find = Tag.find(:first, :conditions => \"name = '#{params[:tag][:name]}'\")\n if @find.nil?\n @tag = Tag.new(params[:tag])\n @tag_link = @tag.tag_links.build(params[:tag_link])\n @tag.save\n render :json => {:msg => \"Created and added #{@tag.name} to list of tags\",:tag=>@tag.name}\n else\n @link_find = TagLink.find(:first, :conditions => {:tag_id => @find.id, :taggable_type => params[:tag_link][:taggable_type],:taggable_id => params[:tag_link][:taggable_id]})\n if @link_find.nil?\n @tag_link = @find.tag_links.build(params[:tag_link])\n @find.save\n render :json => {:msg=>\"Added #{@find.name} to list of tags\",:tag=>@find.name}\n else\n render :json => {:msg=>\"This object is already tagged with #{@find.name}\",:tag=>@find.name}\n end\n end\n end",
"def follow\n @data = {:user_id => params[:follow_user_id], :follow_user_id => current_user.id, :followed => 1}\n status = UserFollower.follow(@data)\n render json: {:status => status}\n end",
"def tag(word_or_words, user, opts={})\n arr_of_words(word_or_words).each do |word|\n word = word.downcase unless opts[:case_sensitive] == true\n unless tag_words_by_user(user).include?(word)\n #First add Tag/Tagging\n t = Tag.first(:word => word) || Tag.create!(:word => word)\n t.taggings << Tagging.new(:user => user, :taggable => self)\n t.save\n\n #Now add ModelTag/User/tag_word\n model_tag = model_tags.detect{|tag| tag.word == word}\n unless model_tag\n model_tag = ModelTag.new(:word => word, :tag => t)\n self.model_tags << model_tag\n self.tag_words << word\n end\n model_tag.users << user\n end\n end\n save\n tags\n end",
"def create_follow_params\n params.require(:follow).permit(:user_id, :game_id, :follow_user_id, :delete_flag, :created_at, :updated_at)\n end",
"def add_follows\n \t@follower = User.find(params[:id])\n \t@followed = User.find(params[:follows_id])\n \t\n \tif @follower.follows << @followed\n \t\t\n \telse\n \t\trender json @follower.errors\n \tend\n end",
"def follow(user_id)\n followee_relationships.create(followee_id: user_id)\n end",
"def tag!(word_or_words, user)\n arr_of_words(word_or_words).each do |word|\n raise StandardError if tag_words_by_user(user).include?(word)\n\n #First add Tag/Tagging\n t = Tag.first(:word => word) || Tag.create!(:word => word)\n t.taggings << Tagging.new(:user => user, :taggable => self)\n t.save!\n\n #Now add ModelTag/User/tag_word\n model_tag = model_tags.detect{|tag| tag.word == word}\n unless model_tag\n model_tag = ModelTag.new(:word => word, :tag => t)\n self.model_tags << model_tag\n self.tag_words << word\n end\n model_tag.users << user\n end\n save!\n tags\n end",
"def follow\n user = User.find(params[:user_id])\n @follow = current_user.follow(user)\n render json: @follow\n end",
"def follow(user_id)\n follower.create(followed_id: user_id)\n end",
"def update\n begin\n entity = Tagger::EntityTag.create_entity_tags(params)\n render json: { \"#{Tagger.tagged_resource}\": entity, tags: entity.tags }, status: 201\n rescue Exception => e\n render json: { error: \"Unprocessable entity\" }, status: 422\n end\n end",
"def follow_params\n params.require(:follow).permit(:user_id, :following)\n end",
"def user_tags=(value)\n @user_tags = value\n end",
"def add_or_remove_tags(task)\n if params[:task][:tags].respond_to? 'each'\n params[:task][:tags].each do |tag|\n if tag[:status] == 'remove'\n task.tags.destroy(current_user_tags.find_by(name: tag[:name]))\n task.touch\n elsif tag[:status] == 'new'\n new_tag = Tag.find_or_initialize_by name: tag[:name], user_id: task.user_id\n if new_tag.new_record?\n new_tag.save\n task.tags << new_tag\n task.touch\n elsif !task.tags.exists?(name: new_tag.name)\n task.tags << new_tag\n task.touch\n end\n end\n end\n end\n end",
"def create\n\n if user_signed_in?\n user_id = current_user.id\n end\n\n @local_tag = LocalTag.new(local_tag_params.merge(user_id: user_id))\n\n respond_to do |format|\n if @local_tag.save\n format.html { redirect_to @local_tag, notice: 'Local tag was successfully created.' }\n format.json { render json: @local_tag, status: :created, location: @local_tag }\n format.xml { render xml: @local_tag, status: :created, location: @local_tag }\n else\n format.html { render action: \"new\" }\n format.json { render json: @local_tag.errors, status: :unprocessable_entity }\n format.xml { render xml: @local_tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @question = current_user.questions.new(question_params)\n\n respond_to do |format|\n if @question.save\n \t# add tags\n @question.tag_with(params[:question][:tag_list])\n format.html { redirect_to @question, notice: 'Question was successfully created.' }\n format.json { render action: 'show', status: :created, location: @question }\n else\n format.html { render action: 'new' }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n #Refactor maybe is this the best way to associate a post with the current user?\n @post = current_user.posts.build(post_params.slice(:content, :user_id, :asset))\n #@post.tag_list = @post.extract_tags\n @post.build_tags(params[:tag_list])\n\n if @post.save\n render json: @post, status: :created\n else\n render json: @post.errors, status: :unprocessable_entity\n end\n end",
"def index\n tags_list = []\n @user.tags.find_each do |tag|\n tags_list << tag_as_hash(tag, false)\n end\n\n render :status => 200,\n :json => {\n status: 200,\n tags: tags_list\n }\n end",
"def create\n @user_comment_tag = UserCommentTag.new(params[:user_comment_tag])\n\n respond_to do |format|\n if @user_comment_tag.save\n format.html { redirect_to @user_comment_tag, notice: 'User comment tag was successfully created.' }\n format.json { render json: @user_comment_tag, status: :created, location: @user_comment_tag }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user_comment_tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def follow(other_user)\n active_follows.create(followed_id: other_user.id)\n end",
"def tags\n send_tags('tags', @handle, @security)\n end",
"def create\n @tag = current_user.tags.new(tag_params)\n\n respond_to do |format|\n if @tag.save\n format.html { redirect_to @tag, notice: 'Tag was successfully created.' }\n format.json { respond_with_bip(@tag) }\n format.js {}\n else\n format.html { render :new }\n end\n end\n end",
"def follow(user)\n\t self[:following].push(user.id)\n\t\tself.save\n end",
"def apply_tag(email, tag)\n data = { \"email\" => email, \"tag\" => tag }\n make_json_api_request :post, \"v2/#{account_id}/tags\", private_generate_resource(\"tags\", data)\n end",
"def create\n @user=User.find(params[:user_id])\n @follower = @user.followers.create(follower_params)\n if @follower.save\n render json: @follower, status: :created\n else\n render json: @follower.errors, status: :unprocessable_entity\n end\n end",
"def update_tags(tags)\n rescue_extra_data\n tags = tags.split(\",\").strip\n post_tags = post_type.post_tags\n post_tags = post_tags.where.not(name: tags) if tags.present?\n term_relationships.where(\"term_taxonomy_id in (?)\", post_tags.pluck(\"#{CamaleonCms::TermTaxonomy.table_name}.id\")).destroy_all\n tags.each do |f|\n post_tag = post_type.post_tags.where({name: f}).first_or_create(slug: f.parameterize)\n term_relationships.where({term_taxonomy_id: post_tag.id}).first_or_create\n end\n update_counters(\"tags\")\n end",
"def follow\n check_user_id_is_present\n\n user = User.find_by_id(params[:user_id])\n\n if params[:movie].present?\n movie = Movie.find_by_title(params[:movie])\n\n if user.movies.include? movie\n render json: { response: 'Already followed' }, status: :ok\n end\n\n user.movies << movie\n elsif params[:genre].present?\n genre = Genre.find_by_name(params[:genre])\n\n if genre.nil?\n render json: { response: 'Genre not found' }, status: :not_found\n end\n\n user.genres << genre\n elsif params[:star].present?\n star = Star.find_by_name(params[:star])\n\n if star.nil?\n render json: { response: 'Movie not found' }, status: :bad_request\n end\n\n star.users << user\n end\n\n render json: { response: 'Done' }, status: :ok\n end",
"def destroy\n tag_following = current_user.tag_followings.find_by_tag_id( params['id'] )\n \n if tag_following && tag_following.destroy\n respond_to do |format|\n format.any(:js, :json) { render :nothing => true, :status => 204 }\n end\n else\n respond_to do |format|\n format.any(:js, :json) {render :nothing => true, :status => 403}\n end\n end\n end",
"def update\n authorize @user\n @user.tag_list.add @tags\n if @user.save\n render :json => @user.reload.tags\n else\n error!(:invalid_resource, @user.errors, \"Tags have not been saved\")\n end\n end",
"def tag\n params.require(:tag).permit(:example_id, :tag)\n end"
] | [
"0.7481366",
"0.7256622",
"0.6269165",
"0.62230766",
"0.6091537",
"0.6078135",
"0.59749514",
"0.5971757",
"0.5845161",
"0.58338755",
"0.58264333",
"0.58204836",
"0.5818444",
"0.5779157",
"0.57690245",
"0.5765219",
"0.5748843",
"0.57465994",
"0.56996894",
"0.569636",
"0.569202",
"0.569025",
"0.5654034",
"0.5648048",
"0.56445014",
"0.5643847",
"0.56423604",
"0.5641428",
"0.5630471",
"0.5623658",
"0.5619312",
"0.56158143",
"0.55933475",
"0.55607516",
"0.5559432",
"0.55412334",
"0.553915",
"0.553849",
"0.55375147",
"0.5531109",
"0.55310756",
"0.55206543",
"0.5514901",
"0.5507646",
"0.55020446",
"0.5501114",
"0.550022",
"0.5496203",
"0.548326",
"0.5476242",
"0.5460619",
"0.54500425",
"0.54429954",
"0.54348046",
"0.5423253",
"0.54190105",
"0.5418511",
"0.5395021",
"0.53936875",
"0.5393237",
"0.5391737",
"0.5391394",
"0.53904176",
"0.5389732",
"0.5386874",
"0.538336",
"0.5382842",
"0.53817636",
"0.53808415",
"0.5376009",
"0.5370688",
"0.5365855",
"0.53643674",
"0.53639287",
"0.53475255",
"0.5345867",
"0.5341767",
"0.53377193",
"0.5326962",
"0.5326101",
"0.5325292",
"0.5320334",
"0.53169036",
"0.5313071",
"0.52965266",
"0.52961284",
"0.5293181",
"0.5292924",
"0.52907836",
"0.5285626",
"0.52788246",
"0.527784",
"0.52776206",
"0.52765465",
"0.5272929",
"0.52721894",
"0.52683705",
"0.5266761",
"0.5262939",
"0.5243692"
] | 0.7134189 | 2 |
PUT /user_follow_tags/1 PUT /user_follow_tags/1.json | def update
@user_follow_tag = UserFollowTag.find(params[:id])
respond_to do |format|
if @user_follow_tag.update_attributes(params[:user_follow_tag])
format.html { redirect_to @user_follow_tag, notice: 'User follow tag was successfully updated.' }
format.json { head :ok }
else
format.html { render action: "edit" }
format.json { render json: @user_follow_tag.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tag_follow(tag)\n tag_follows.create(tag_id: tag.id)\n end",
"def create\n name_normalized = ActsAsTaggableOn::Tag.normalize(params['name'])\n\n if name_normalized.nil? || name_normalized.empty?\n render :nothing => true, :status => 403\n else\n @tag = ActsAsTaggableOn::Tag.find_or_create_by_name(name_normalized)\n @tag_following = current_user.tag_followings.new(:tag_id => @tag.id)\n\n if @tag_following.save\n render :json => @tag.to_json, :status => 201\n else\n render :nothing => true, :status => 403\n end\n end\n end",
"def create\n @user_follow_tag = UserFollowTag.new(params[:user_follow_tag])\n\n respond_to do |format|\n if @user_follow_tag.save\n format.html { redirect_to @user_follow_tag, notice: 'User follow tag was successfully created.' }\n format.json { render json: @user_follow_tag, status: :created, location: @user_follow_tag }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user_follow_tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_tags\n if self.tags.any?\n self.tags.each do |tag|\n tag.update(owner: User.first)\n end\n end\n end",
"def update\n @user = User.find(:id)\n @tag_list = configure_account_update_params[:tag_name].split(nil)\n if @user.update_attributes(configure_account_update_params)\n @user.save_tags(@tag_list)\n render json: {status: :success}\n end\n end",
"def destroy\n @user_follow_tag = UserFollowTag.find(params[:id])\n @user_follow_tag.destroy\n\n respond_to do |format|\n format.html { redirect_to user_follow_tags_url }\n format.json { head :ok }\n end\n end",
"def update\n authorize @user\n @user.tag_list.add @tags\n if @user.save\n render :json => @user.reload.tags\n else\n error!(:invalid_resource, @user.errors, \"Tags have not been saved\")\n end\n end",
"def update\n begin\n entity = Tagger::EntityTag.create_entity_tags(params)\n render json: { \"#{Tagger.tagged_resource}\": entity, tags: entity.tags }, status: 201\n rescue Exception => e\n render json: { error: \"Unprocessable entity\" }, status: 422\n end\n end",
"def create\n\n user = User.find(params[:followed_id])\n @current_user.follow(user)\n redirect_to user\n\n\n # PATCH/PUT /relationships/1\n # PATCH/PUT /relationships/1.json\n def update\n\n end\n\n # DELETE /relationships/1\n # DELETE /relationships/1.json\n def destroy\n user = Relationship.find(params[:id]).followed\n @current_user.unfollow(user)\n redirect_to user\n end\n end",
"def set_tags\n taggable_uid = unsafe_params[:taggable_uid]\n unless taggable_uid.is_a?(String) && taggable_uid != \"\"\n raise ApiError, \"Taggable uid needs to be a non-empty string\"\n end\n\n tags = unsafe_params[:tags]\n raise ApiError, \"Tags need to be comma-separated strings\" unless tags.is_a?(String)\n\n suggested_tags = unsafe_params[:suggested_tags] # Optional\n tags = (tags.split(\",\") + suggested_tags).join(\",\") if suggested_tags.is_a?(Array)\n\n tag_context = unsafe_params[:tag_context] # Optional\n\n taggable = item_from_uid(taggable_uid)\n\n if taggable.editable_by?(@context) || @context.can_administer_site?\n path = pathify(taggable)\n message = \"redirect to item\"\n @context.user.tag(taggable, with: tags, on: tag_context.presence || :tags)\n else\n path = home_path\n message = \"This item is not accessible by you\"\n end\n\n render json: { path: path, message: message }\n rescue RuntimeError => e\n raise ApiError, e.message\n end",
"def add(user_id, tag)\n @_client.post(\"/users/#{user_id}/tags\", value: tag)\n end",
"def update\n @user_tag = UserTag.find(params[:id])\n\n respond_to do |format|\n if @user_tag.update_attributes(params[:user_tag])\n format.html { redirect_to @user_tag, notice: 'User tag was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user_tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def modify_tag tag\n data = {\n \"tag\" => params\n }\n temp = data[\"servers\"]\n data[\"servers\"] = { \"server\" => temp }\n\n json = JSON.generate data\n\n response = put \"tag/#{tag}\", json\n return response unless response.code == 200\n\n body = JSON.parse response.body\n body[\"tag\"]\n end",
"def update_tag_profile\n # body = {\n # cmd: \"update_tag_profile\"\n # }\n\n end",
"def update_tags(tags)\n rescue_extra_data\n tags = tags.split(\",\").strip\n post_tags = post_type.post_tags\n post_tags = post_tags.where.not(name: tags) if tags.present?\n term_relationships.where(\"term_taxonomy_id in (?)\", post_tags.pluck(\"#{CamaleonCms::TermTaxonomy.table_name}.id\")).destroy_all\n tags.each do |f|\n post_tag = post_type.post_tags.where({name: f}).first_or_create(slug: f.parameterize)\n term_relationships.where({term_taxonomy_id: post_tag.id}).first_or_create\n end\n update_counters(\"tags\")\n end",
"def update\n @hack_tag_follow = HackTagFollow.find(params[:id])\n\n respond_to do |format|\n if @hack_tag_follow.update_attributes(params[:hack_tag_follow])\n format.html { redirect_to(@hack_tag_follow, :notice => 'Hack tag follow was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @hack_tag_follow.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n # creates tag objects for photos\n tag_array = tag_params['tags'].split(',').each do |x|\n x.strip!\n end\n tag_array.each do |x| \n if Tag.find_by(name: x)\n @tag = Tag.find_by(name: x)\n else\n @tag = Tag.create(name: x)\n end\n Tagging.create(photo_id: @photo.id, tag_id: @tag.id)\n end\n\n respond_to do |format|\n if @photo.update(photo_params)\n format.html { redirect_to @photo, notice: 'Photo was successfully updated.' }\n format.json { render :show, status: :ok, location: @photo }\n else\n format.html { render :edit }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @joke = Joke.find(params[:id])\n\n respond_to do |format|\n str_tags = params[:joke][:tags].split(',')\n @tags = str_tags.map {|tag_name|\n Tag.find_or_create_by_name(tag_name)\n }\n @joke.tags = @tags\n \n if @joke.update_attributes(params[:joke].except(:tags))\n format.html { redirect_to @joke, :notice => 'Joke was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @joke.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n current_user.tag(@post, :with => params[:post][:tag_list], :on => :tags)\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to(@post, :notice => 'Post was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_tags!\n return unless @params.key?(:tags)\n\n tags_to_remove.each do |tag_title|\n TaskTag.where(task: task).joins(:tag).merge(Tag.where(title: tag_title)).destroy_all\n end\n\n tags_to_add.each do |tag_title|\n TaskTag.where(task: task, tag: tag_from_title(tag_title)).first_or_create!\n end\n end",
"def update!(**args)\n @tags = args[:tags] if args.key?(:tags)\n end",
"def update!(**args)\n @tags = args[:tags] if args.key?(:tags)\n end",
"def new\n @user_follow_tag = UserFollowTag.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user_follow_tag }\n end\n end",
"def follow!(user)\n\t\tfollowed << user \n\tend",
"def tag!(params = {})\n self.post params, edge: :tags\n end",
"def update\n\n tags = params[:tags]\n @piece.taggings.destroy_all\n\n tags.downcase.split(',').each do |tag_name|\n tag = Tag.find_or_create_by(name: tag_name.strip)\n @piece.taggings.create(user_id: current_user.id, tag_id: tag.id)\n end\n\n if @piece.update(piece_params)\n redirect_to @piece, notice: 'Piece was successfully updated.'\n else\n render :edit\n end\n end",
"def update\n update_and_respond(@tag, tag_params)\n end",
"def update\n @record = user_records.find(params[:id])\n current_user.tag(@record, with: double_escape_quotes(params[:record][:tag_list]), on: :tags)\n respond_with(@record)\n end",
"def update\n tag = @user.tags.find_by_tid(params[:id])\n if tag.nil?\n render json_status_response(404, \"Tag not found\")\n return\n end\n\n if not tag.update_attributes(params[:location])\n render json_status_response(400, \"Could not update tag location\")\n return\n end\n\n render json_status_response(200, \"Successfully updated tag\")\n end",
"def update\n @task.tags.each { |t| t.delete}\n\n respond_to do |format|\n if @task.update(task_params)\n create_multiple_tags(task_params[\"tag\"], @task.id)\n\n format.html { redirect_to @task.list, notice: 'Task was successfully updated.' }\n format.json { render :show, status: :ok, location: @task }\n else\n format.html { render :edit }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_conversation_tags(id, tags)\n data = { tags: tags }\n put(\"conversations/#{id}/tags\", { body: data })\n end",
"def follow!(user)\n\t\tfollowed << user\n\tend",
"def follow(user)\n active_follows.create(followed_id: user.id)\n \n end",
"def follow\n id_s = params[:format]\n id = id_s.to_i\n current_user.followed_things_will_change!\n if current_user.followed_things.nil? \n current_user.update_attribute(:followed_things, [id])\n current_user.create_activity :thing_followed, owner: current_user\n else\n unless current_user.followed_things.include? id_s\n current_user.update_attributes(followed_things: current_user.followed_things.push(id))\n #set target type to the object being followed\n current_user.create_activity action: 'thing_followed', owner: current_user, relevant_obj_id: id\n end\n end\n current_user.save\n redirect_to things_path \n end",
"def create\n @user_tag = UserTag.new(params[:user_tag])\n\n respond_to do |format|\n if @user_tag.save\n format.html { redirect_to @user_tag, notice: 'User tag was successfully created.' }\n format.json { render json: @user_tag, status: :created, location: @user_tag }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user_tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def follow_params\n params.require(:follow).permit(:follow_user_id)\n end",
"def update\n respond_to do |format|\n if @expert_tag.update_attributes(:tag_name => params[:tag_name], :user_id => params[:user_id])\n format.html { redirect_to @expert_tag, notice: 'Expert tag was successfully updated.' }\n format.json { render :show, status: :ok, location: @expert_tag }\n else\n format.html { render :edit }\n format.json { render json: @expert_tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def user_tag_params\n params.require(:user_tag).permit(:user_id, :tag_id)\n end",
"def follow\n @cookbook.cookbook_followers.create(user: current_user)\n Supermarket::Metrics.increment \"cookbook.followed\"\n\n render_follow_button\n end",
"def add_or_remove_tags(task)\n if params[:task][:tags].respond_to? 'each'\n params[:task][:tags].each do |tag|\n if tag[:status] == 'remove'\n task.tags.destroy(current_user_tags.find_by(name: tag[:name]))\n task.touch\n elsif tag[:status] == 'new'\n new_tag = Tag.find_or_initialize_by name: tag[:name], user_id: task.user_id\n if new_tag.new_record?\n new_tag.save\n task.tags << new_tag\n task.touch\n elsif !task.tags.exists?(name: new_tag.name)\n task.tags << new_tag\n task.touch\n end\n end\n end\n end\n end",
"def tag_params\n params.permit(:title, :user_id)\n end",
"def mf_api_user_update_tags\n\n # Get User From DB with client_id\n user = User.where(clientid: params[:client_id]).first\n\n # If user not found, return error response\n if user.empty?\n response = {\n success: false,\n message: 'User with ClientID not found'\n }\n\n render json: response\n end\n\n # Get the Infusionsoft contact info\n contact = Infusionsoft.data_load('Contact', user.clientid, [:Groups])\n\n # Update User Tags\n user.put('', {\n :client_tags => contact['Groups']\n })\n\n\n response = {\n success: true,\n message: 'User Tags Updated'\n }\n\n render json: response\n\n end",
"def tag_params\n params.require(:tag).permit(:post_id, :sharer,:user_id)\n end",
"def update_tags(tags = nil)\n set_tags(tags)\n write_tags_to_repo\n read_tags_from_repo\n save!\n end",
"def set_tags(tags)\n @tags.update(tags)\n end",
"def set_tag_ids nids\n # Ensure that the user's tags are all and only those in nids\n oids = tagging_tags.pluck :id\n\n # Add new tags as necessary\n (nids - oids).each { |tagid| assert_tagging tagid, @tagging_user_id }\n\n # Remove tags as nec.\n (oids - nids).each { |tagid| refute_tagging tagid, @tagging_user_id }\n end",
"def add_tags(artist, track, tags)\n post(:session, {:method => \"track.addTags\", :artist => artist, :track => track, :tags => tags})\n end",
"def update\n respondent = SurveyRespondent.find(params[:respondent_id])\n tag_context = params[:context] # tag context\n tag_list = params[:tags] # comma seperated list of tags\n\n if getTagOwner\n getTagOwner.tag(respondent, :with => tag_list, :on => tag_context)\n else\n respondent.set_tag_list_on(tag_context, tag_list) # set the tag list on the respondent for the context\n end\n \n respondent.save\n \n render :layout => 'content'\n end",
"def follow(user)\n\t self[:following].push(user.id)\n\t\tself.save\n end",
"def show\n @user_follow_tag = UserFollowTag.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user_follow_tag }\n end\n end",
"def add_follows\n\t#params[:id] is user who follows \n\t#params[:follows_id] is user to be followed\n\t\n\t#make follower\n\t@follower = User.find(params[:id])\n\t\n\t#make followed\n\t@followed = User.find(params[:follows_id])\n\t\n\tif \n\t\[email protected] << @followed\n\t\thead :no_content\n\telse\n\t\trender json: @follower.errors, status: :unprocessable_entity\n\tend\nend",
"def update(options: {}, **data)\n\n refresh_with(parse(client.put(\"/tags/#{gid}\", body: data, options: options)).first)\n end",
"def update\n if @tag.update(tag_params)\n render json: @tag\n else\n render json: @tag.errors, status: :unprocessable_entity\n end\n end",
"def set_tag\n @tag = current_user.tags.find(params[:id])\n end",
"def follow\n if request.post?\n fo_ids = params[:follow] \n #fo_str = \"\"\n #fo_cnt = fo_ids.length - 1\n #for i in 0..fo_cnt\n # fo_str +=fo_ids[i].to_s\n # fo_str += \",\" unless fo_cnt == i\n #end\n \n fo_ids.each do |fid|\n hydra = Typhoeus::Hydra.new\n uri = \"http://api.twitter.com/1/friendships/create.json\"\n req = Typhoeus::Request.new(uri,\n :method =>\"post\",\n :params =>{:user_id=>fid, :include_entities=>\"true\"})\n \n sign_request(req,uri)\n hydra.queue(req)\n hydra.run\n #puts req.response.inspect\n end\n end\n redirect_to :action=>\"index\", :page=>\"1\" \n end",
"def update\n @taggable = current_user.taggables.find(params[:id])\n\n respond_to do |format|\n logger.debug(params)\n if @taggable.update_attributes(params[:taggable])\n format.html { redirect_to @taggable, notice: 'Taggable was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @taggable.errors, status: :unprocessable_entity }\n end\n end\n end",
"def tag_names=(tags)\n tag_array = tags.split(\",\").map{|tag| tag.strip}\n tag_array.each do |tag|\n new_tag = Tag.find_or_create_by(name: tag)\n if self.tags.include?(new_tag)\n next\n end\n self.tags << new_tag\n self.owner.tags << new_tag\n end\n end",
"def follow!(user)\n relationships.create!(:followed_id => user.id)\n end",
"def update_tags(metricDefinition)\n @client.http_put(\"/#{@resource}/#{metricDefinition.id}/tags\",metricDefinition.hash[:tags])\n end",
"def follow_params\n params.require(:follow).permit(:user_id, :following)\n end",
"def create(tag)\n api_client.tags.multi_add(resource_hrefs: [api_client.get_instance.href], tags: [tag])\n end",
"def set_user_tag\n @user_tag = UserTag.find(params[:id])\n end",
"def update\n story = Story.find(params[:id])\n authorize story # check policies/story_policy.rb for auth rules\n\n if story_params[:tags]\n story_params[:tags].each do |tag|\n # If tag exists then use existing tag name\n if Tag.exists?(tag)\n story.tags << Tag.find_by_name(tag[\"name\"])\n else\n story.tags << Tag.new(tag)\n end\n end\n end\n\n if story.update(story_params.except(:tags)) && story.save\n response_with('Story successfully saved', 200)\n else\n response_with('Could not update story', 400)\n end\n end",
"def create_tag\n # TODO could validate that user is in a fleet first\n @user = User.find(params[:id])\n @tag = Tag.find_or_create_by_text(params[:tag][:text])\n @user.tag = @tag\n\n respond_to do |format|\n if @tag.save\n @user.save\n format.html { redirect_to((@user.fleet ? @user.fleet : @user), :notice => 'Tag was added successfully.') }\n format.xml { render :xml => @taq, :status => :created, :location => @tag }\n else\n format.html { render :action => \"add_tag\", :error => \"Tag was not added\" }\n format.xml { render :xml => @tag.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_tag\n\t\t\t@tag = current_user.tags.find(params[:id])\n end",
"def add_tag(tag)\n @api.post(\"#{@api.path}/List/#{@id}/Tag\", body: tag)\n end",
"def tag\n params.require(:tag).permit(:example_id, :tag)\n end",
"def create\n authorize @user\n if @user.update_attributes(tag_list: @tags)\n render :json => @user.reload.tags, :status => :created\n else\n error!(:invalid_resource, @user.errors, \"Tags have not been saved\")\n end\n end",
"def update\n @song = Song.find(params[:id])\n\n params[:song].each do |tag, value|\n if TagInfo::USEFULL_TAGS.include?(tag)#tag on file is a useful tag\n @song[tag] = value #update the useful tag in DB\n end\n end\n respond_to do |format|\n begin\n Song.transaction do #update both file and DB or neither\n @song.update_tags_on_file(params[:song])\n @song.save!\n end\n format.html { redirect_to @song, notice: 'Song was successfully updated.' }\n format.json { head :ok }\n rescue Exception=>e\n format.html { render action: \"edit\" }\n format.json { render json: @song.errors, status: :unprocessable_entity }\n end\n end\n end",
"def follow(user)\n active_relationships.create(followed_id: user.id)\n end",
"def add_tag_to_server server_uuid, tags\n tag = (tags.respond_to? :join && tags.join(\",\") || tags)\n\n post \"server/#{server_uuid}/tag/#{tag}\"\n end",
"def update\n raise \"あなたのノートではありません。\" unless @note.user_notes[0].user_id == current_user.id\n note_attr = note_params\n tag_names = note_params[:tag].split(\" \")\n note_attr[:tag] = tag_names\n\n ActiveRecord::Base.transaction do\n Tag.add_count(tag_names, @note.tag)\n raise \"ノートの更新ができませんでした。\" unless @note.update_attributes(note_attr)\n end\n\n respond_to do |format|\n format.html { redirect_to @note, notice: 'Note was successfully updated.' }\n format.json { render :show, status: :ok, location: @note }\n end\n rescue => e\n respond_to do |format|\n format.html { render :edit }\n format.json { render json: @note.errors, status: :unprocessable_entity }\n end\n end",
"def update\n tag_array = event_params2['tags'].split(',')\n tag_array.each do |x|\n if Tag.find_by(desc: x)\n @tag = Tag.find_by(desc: x)\n else\n @tag = Tag.create(desc: x)\n end\n @event.tags << @tag\n # EventTag.create(event_id: @event.id, tag_id: @tag.id)\n end\n\n\n respond_to do |format|\n store_photos\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_tags(names)\n\t\t self.tags = names.split(\",\").map do |name|\n \t\tUser.find_by(:id => user.id).tags.where(name: name.strip).first_or_create!\n \tend\n\tend",
"def update\n\n old_tags = @event.tags.pluck(:tag)\n new_tags = params[:tags].split(',')\n\n #logger.debug old_tags\n #logger.debug new_tags\n #logger.debug (old_tags - new_tags)\n #logger.debug (new_tags - old_tags)\n\n (old_tags - new_tags).each do |stag|\n @event.tags.where(tag: stag).first.destroy\n end\n\n (new_tags - old_tags).each do |stag|\n @event.tags.create(tag: stag)\n end\n\n respond_to do |format|\n if @event.update(event_params)\n format.html { redirect_to @event, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @event }\n else\n format.html { render :edit }\n format.json { render json: @event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def follow\n @data = {:user_id => params[:follow_user_id], :follow_user_id => current_user.id, :followed => 1}\n status = UserFollower.follow(@data)\n render json: {:status => status}\n end",
"def assign_tags_to_user\n current_user.tag(@quote, :with => params[:quote][:tag_list], :on => :tags)\n end",
"def set_tag\n @tag = current_user.tags.find(params[:id])\n end",
"def update\n @tag = Tag.find(params[:id])\n @tag.attributes = params[:tag]\n set_user_column @tag\n\n respond_to do |format|\n begin\n @tag.save!\n format.html { redirect_to @tag, notice: 'Tag was successfully updated.' }\n format.json { head :no_content }\n rescue ActiveRecord::RecordInvalid\n format.html { render action: \"edit\" }\n format.json { render json: @tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @experience = current_user.experiences.find(params[:id])\n respond_to do |format|\n if @experience.update_attributes(params[:experience])\n current_user.tag(@experience, :with => @experience.tag_list.to_s, :on => :tags)\n\n flash[:notice] = I18n.t('action.update_successfully')\n format.html { \n redirect_to user_home_path(current_user) \n }\n format.xml { head :ok }\n else\n flash[:error] = I18n.t('action.update_fail')\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @experience.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def follow(user)\n self.following << user\n ActionLog.log_other(self.id, \"follow\", user) \n end",
"def user_follow_params\n params.require(:user_follow).permit(:follower_id, :user_followed_id)\n end",
"def follow(user)\n\tout_followings.create(to_id: user.id)\nend",
"def tag!(word_or_words, user)\n arr_of_words(word_or_words).each do |word|\n raise StandardError if Tag.exists?(_tag_conditions(user, word))\n t = Tag.create(_tag_conditions(user, word))\n taggings << t.id\n tag_words << word unless tag_words.include?(word)\n end\n save\n tags\n end",
"def follow_params\n params.require(:follow).permit(:user_id, :espace_id)\n end",
"def follow_by_tag(num_to_follow, tag, tweets = [])\n # Break if recursion hits rate limit\n if (sr = self.tweet_searches_remaining) < 10 || (fl = self.follower_lookups_remaining) < 2\n p \"Returning hitting rate limit #{sr}, #{fl}\"\n return\n end\n tweets = @client.search(tag, count: 100).to_a.reverse! if tweets.count == 0\n num_to_retry = 0\n popped_tweets = tweets.pop(num_to_follow)\n popped_tweets.each do |tweet|\n remote_user = tweet.user\n screen_name = remote_user.screen_name\n twitter_id = remote_user.id\n local_user = TwitterUser.where(\n twitter_id: twitter_id, twitter_client: self.id).first_or_initialize\n if local_user.new_record? && screen_name != self.username\n local_user.tag_followed = tag\n local_user.followed_at = DateTime.now\n begin\n @client.follow(screen_name)\n p \"#{screen_name} followed\"\n local_user.save! \n update_twitter_user(local_user, remote_user, 1)\n p \"**** Following for #{self.username} --> #{screen_name}: #{tweet.text} #{tweet.created_at}\"\n rescue Exception => e\n p \"Error following #{screen_name} for #{self.username} - #{e.to_s}\"\n return\n end\n else\n num_to_retry += 1\n end\n end\n # If user has already been followed, attempt to follow another user by retrieving more tweets\n if num_to_retry > 0 && !(tweets_to_retry = tweets[num_to_retry..tweets.count]).nil?\n p \"Follow more people for #{self.username}: #{num_to_retry}\"\n follow_by_tag(num_to_retry, tag, tweets_to_retry)\n end\n p \"Done following\"\n end",
"def follow\n current_user.follow_user(@user)\n render json: {ok: 1}\n end",
"def trackUserDefinedTags\n if params[:document].include?(:tags)\n tags = params[:document][:tags].split(',')\n tags.map(&:strip!)\n tags.uniq.each do |tag|\n user_tag= @parent_profile.user_tags.where(tag: tag).first ||@parent_profile.user_tags.create(tag: tag, category_ids: params[:document][:category_id].to_a)\n if !user_tag.nil? and !user_tag.category_ids.include?(params[:document][:category_id])\n begin\n user_tag.update_attributes(category_ids: user_tag.category_ids.push(params[:document][:category_id]))\n rescue\n next\n end\n end\n end\n end\n end",
"def update\n if current_user.update(user_params)\n set_tags current_user\n redirect_to current_user, notice: 'User was successfully updated.'\n else\n render :edit\n end\n end",
"def follow\n user = User.find(params[:user_id])\n @follow = current_user.follow(user)\n render json: @follow\n end",
"def update\n @tags = params[:tags].split(',')\n @tagged = []\n for prev in Tagging.where(taggable_id: @question.id, taggable_type: 'Question')\n prev.destroy\n end\n respond_to do |format|\n if @question.update(question_params)\n @activity = Activity.create(user_id: current_user.id, activity_type: 'Update', target_type: 'Question', target_id: @question.id)\n for tag in @tags\n if !tag.blank?\n @tag = Tag.where(title: tag).first\n if @tag.blank?\n @tag = Tag.create(title: tag, user_id: current_user.id)\n end\n @tagging = Tagging.where(taggable_id: @question.id, taggable_type: 'Question', tag_id: @tag.id).first\n if @tagging.blank?\n @tagging = Tagging.create(taggable_id: @question.id, taggable_type: 'Question', tag_id: @tag.id)\n end\n end\n end\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { render :show, status: :ok, location: @question }\n else\n format.html { render :edit }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def follow(foo_user)\n active_relationships.create(followed_id: foo_user.id)\n end",
"def add_follows\n \t@follower = User.find(params[:id])\n \t@followed = User.find(params[:follows_id])\n \t\n \tif @follower.follows << @followed\n \t\t\n \telse\n \t\trender json @follower.errors\n \tend\n end",
"def destroy\n tag_following = current_user.tag_followings.find_by_tag_id( params['id'] )\n \n if tag_following && tag_following.destroy\n respond_to do |format|\n format.any(:js, :json) { render :nothing => true, :status => 204 }\n end\n else\n respond_to do |format|\n format.any(:js, :json) {render :nothing => true, :status => 403}\n end\n end\n end",
"def update_remote_tags!(new_file=nil)\n Cloudinary::Api.update(my_public_id, tags: tags)\n end",
"def create_follow_params\n params.require(:follow).permit(:user_id, :game_id, :follow_user_id, :delete_flag, :created_at, :updated_at)\n end",
"def update\n if session[:user_id]\n @bookmark = Bookmark.first(:conditions => {:id => params[:id], :user_id => session[:user_id]})\n if @bookmark \n @tags = params[:tag]\n \n @bookmark.tags.delete_all\n if params[:tag]\n @tags.each do |tag|\n objTag = Tag.find(tag)\n @bookmark.tags << objTag\n end\n end\n respond_to do |format|\n if @bookmark.update_attributes(params[:bookmark])\n format.html { redirect_to(@bookmark, :notice => 'Bookmark was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n else\n redirect_to \"/bookmarks/\"\n end\n else\n redirect_to \"/login\"\n end\n end",
"def update!(**args)\n @followup_intent_name = args[:followup_intent_name] if args.key?(:followup_intent_name)\n @parent_followup_intent_name = args[:parent_followup_intent_name] if args.key?(:parent_followup_intent_name)\n end",
"def update!(**args)\n @followup_intent_name = args[:followup_intent_name] if args.key?(:followup_intent_name)\n @parent_followup_intent_name = args[:parent_followup_intent_name] if args.key?(:parent_followup_intent_name)\n end",
"def update\n current_user.new_relation_with(@user, params[:relation])\n render partial: 'follow', locals: { user: @user }\n end"
] | [
"0.7139845",
"0.66610676",
"0.65788424",
"0.6238002",
"0.62051",
"0.6151745",
"0.60733384",
"0.60128903",
"0.5996109",
"0.59050095",
"0.5875298",
"0.58606714",
"0.5839642",
"0.5814438",
"0.58002245",
"0.57934636",
"0.5786955",
"0.57588696",
"0.574772",
"0.5741301",
"0.57342416",
"0.57342416",
"0.5711647",
"0.56831765",
"0.5673949",
"0.5671877",
"0.56711745",
"0.56625515",
"0.5661714",
"0.5657763",
"0.565538",
"0.5651383",
"0.564161",
"0.5631094",
"0.5628479",
"0.56246287",
"0.5614911",
"0.5609446",
"0.55731636",
"0.5557857",
"0.5551564",
"0.55499333",
"0.5540574",
"0.55371356",
"0.55325675",
"0.55191255",
"0.5506408",
"0.5502352",
"0.5496296",
"0.54945654",
"0.5492795",
"0.54924273",
"0.54797226",
"0.54758793",
"0.5471572",
"0.5470207",
"0.5437136",
"0.5435599",
"0.5430353",
"0.543021",
"0.5422204",
"0.541963",
"0.54125625",
"0.54118544",
"0.54070187",
"0.5381338",
"0.53797066",
"0.53789616",
"0.5377467",
"0.537356",
"0.53735316",
"0.53647375",
"0.5363249",
"0.5351996",
"0.5338484",
"0.53363055",
"0.53358287",
"0.53346753",
"0.53313",
"0.5329771",
"0.532509",
"0.5322211",
"0.53217405",
"0.5317623",
"0.5312666",
"0.5309937",
"0.5306928",
"0.5301608",
"0.53006935",
"0.529991",
"0.5297298",
"0.5295396",
"0.5292454",
"0.52895296",
"0.52883315",
"0.52824944",
"0.5279261",
"0.5273",
"0.52722144",
"0.52698535"
] | 0.70458865 | 1 |
DELETE /user_follow_tags/1 DELETE /user_follow_tags/1.json | def destroy
@user_follow_tag = UserFollowTag.find(params[:id])
@user_follow_tag.destroy
respond_to do |format|
format.html { redirect_to user_follow_tags_url }
format.json { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n tag_following = current_user.tag_followings.find_by_tag_id( params['id'] )\n \n if tag_following && tag_following.destroy\n respond_to do |format|\n format.any(:js, :json) { render :nothing => true, :status => 204 }\n end\n else\n respond_to do |format|\n format.any(:js, :json) {render :nothing => true, :status => 403}\n end\n end\n end",
"def destroy\n tag = @user.tags.find_by_tid(params[:id])\n if tag.nil?\n render json_status_response(404, \"Tag not found\")\n return\n end\n\n tag.destroy\n render json_status_response(200, \"Tag removed successfully\")\n end",
"def destroy\n @user_tag = UserTag.find(params[:id])\n @user_tag.destroy\n\n respond_to do |format|\n format.html { redirect_to user_tags_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @hack_tag_follow = HackTagFollow.find(params[:id])\n @hack_tag_follow.destroy\n\n respond_to do |format|\n format.html { redirect_to(hack_tag_follows_url) }\n format.xml { head :ok }\n end\n end",
"def delete_follows\n\n\t@follower = User.find(params[:id])\n\t@followed = User.find(params[:follows_id])\n\n\[email protected](@followed)\n\t\thead :no_content\n\t\t\n\tend",
"def destroy\n @taggable = current_user.taggables.find(params[:id])\n\n #destroy each tag in the taggable\n @taggable.tags.each do |tag|\n tag.destroy\n end\n\n @taggable.destroy\n\n respond_to do |format|\n format.html { redirect_to taggables_url }\n format.json { head :no_content }\n end\n end",
"def delete(tag)\n api_client.tags.multi_delete(resource_hrefs: [api_client.get_instance.href], tags: [tag])\n end",
"def destroy\n # If given metadata_id ==> detach tag\n if params[:metadata_id]\n tag = current_user.detach_tag params[:metadata_id], params[:id]\n # Otherwise ==> delete tag\n else\n tag = current_user.delete_tag params[:id]\n end\n _respond_tag_request tag \n end",
"def destroy\n @tag = Tag.find(params[:id])\n @tag.deleted = 9\n set_user_column @tag\n @tag.save!\n \n respond_to do |format|\n format.html { redirect_to tags_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user_follow_user = UserFollowUser.find(params[:id])\n @user_follow_user.destroy\n\n respond_to do |format|\n format.html { redirect_to user_follow_users_url }\n format.json { head :ok }\n end\n end",
"def delete_follows\n \t@follower = User.find(params[:id])\n \t@followed = User.find(params[:follows_id])\n \t\n \tif @follower.follows.delete(@followed)\n \t\t\n \telse\n \t\trender json @follower.errors\n \tend\n end",
"def destroy\n @api_v1_follower = Api::V1::Follower.where('follower_id =? and user_id =?', @current_user.id, params[:id]).first\n if @api_v1_follower.destroy\n head :no_content\n else \n render json: { error: 'not allowed' }, status: 401\n end\n end",
"def destroy\n authorize @user\n @tags = @user.tag_list if @tags.empty?\n @user.tag_list.remove @tags\n if @user.save\n render :json => @user.reload.tags\n else\n error!(:invalid_resource, @user.errors, \"Tags have not been saved\")\n end\n end",
"def destroy\n @tag = Tag.find(params[:id])\n @tag.destroy\n \n respond_to do |format|\n format.html { redirect_to tags_url }\n format.json { head :ok }\n end\n\n end",
"def delete_tag tag\n delete \"tag/#{tag}\"\n end",
"def destroy \n @note.delete_from_user(current_user)\n Tag.delete_tags_from_parent(@note)\n\n respond_to do |format|\n format.html { redirect_to(user_notes_path(:username => current_user.username)) }\n format.json { head :ok }\n end\n end",
"def destroy\n @tag = Tag.find(params[:id])\n @tag.destroy\n render json: JSON.parse({msg:\"success\"}.to_json)\n end",
"def destroy\n @user_follow = UserFollow.find(params[:id])\n @user_follow.destroy\n\n respond_to do |format|\n format.html { redirect_to(user_follows_url) }\n format.xml { head :ok }\n end\n end",
"def delete()\n\n client.delete(\"/tags/#{gid}\") && true\n end",
"def destroy\n head 404\n # @api_v1_following = Api::V1::Follower.where('following_id =? and user_id =?', @current_user.id, params[:id]).first\n # if @api_v1_following.destroy\n # head :no_content\n # else \n # render json: { error: 'not allowed' }, status: 401\n # end\n end",
"def destroy\n # @tag = Tag.find(params[:id])\n @tag.destroy\n\n respond_to do |format|\n format.html { redirect_to tags_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @profile_diet_tag.destroy\n respond_to do |format|\n format.html { redirect_to profile_diet_tags_url, notice: 'Profile diet tag was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def remove_tag\n @kyu_entry.tag_list.remove(params[:tag])\n @kyu_entry.save\n render json: true\n end",
"def destroy\n @tag_userdream = TagUserdream.find(params[:id])\n @tag_userdream.destroy\n\n respond_to do |format|\n format.html { redirect_to tag_userdreams_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @api_tag = Api::Tag.find(params[:id])\n @api_tag.destroy\n\n respond_to do |format|\n format.html { redirect_to api_tags_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tag_ref.destroy\n respond_to do |format|\n format.html { redirect_to tag_refs_url, notice: 'Usunięto Tag z artykułu.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user_comment_tag = UserCommentTag.find(params[:id])\n @user_comment_tag.destroy\n\n respond_to do |format|\n format.html { redirect_to user_comment_tags_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n get_status\n @tag = Tag.find(params[:id])\n @tag.destroy\n\n respond_to do |format|\n format.html { redirect_to tags_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @follow = Follow.find(params[:id])\n @follow.destroy\n\n respond_to do |format|\n format.html { redirect_to follows_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:user_id])\n @follower = @user.follower.find(params[:id])\n @follower.destroy\n head :no_content\n end",
"def destroy\n @tag = Tag.find(params[:id])\n @tag.destroy\n\n respond_to do |format|\n format.html { redirect_to tags_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @tag = Tag.find(params[:id])\n @tag.destroy\n\n respond_to do |format|\n format.html { redirect_to tags_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @tag = Tag.find(params[:id])\n @tag.destroy\n\n respond_to do |format|\n format.html { redirect_to tags_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @followup = Followup.find(params[:id])\n @followup.destroy\n\n respond_to do |format|\n format.html { redirect_to followups_url }\n format.json { head :ok }\n end\n end",
"def test_stop_following_a_user\r\n # delete \"/follows/destroy.json\", :api_key => 'testapikey',\r\n # :followee_id => 3\r\n # assert_response :success\r\n end",
"def destroy\n @users_hacktag = UsersHacktag.find(params[:id])\n @users_hacktag.destroy\n\n respond_to do |format|\n format.html { redirect_to(users_hacktags_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @activity_tag = ActivityTag.find(params[:id])\n @activity_tag.destroy\n\n respond_to do |format|\n format.html { redirect_to activity_tags_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @follow.destroy\n respond_to do |format|\n format.html { redirect_back fallback_location: root_path, notice: 'You have unfollowed this user!' }\n format.json { head :no_content }\n end\n end",
"def destroy\n user = Relationship.find(params[:id]).followed\n @current_user.unfollow(user)\n redirect_to user\n end",
"def destroy\n @tag_relationship.destroy\n respond_to do |format|\n format.html { redirect_to tag_relationships_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @follow.destroy\n\n\n respond_to do |format|\n #format.html { redirect_to tales_url }\n # format.html { redirect_to profiles_index_path(current_user.id) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tag = Tag.find(params[:id])\n\n @tag.destroy\n\n respond_to do |format|\n format.html { redirect_to tags_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @posttag = Posttag.find(params[:id])\n @posttag.destroy\n\n respond_to do |format|\n format.html { redirect_to posttags_url }\n format.json { head :no_content }\n end\n end",
"def remove_tag\n \n success = false\n message = \"\"\n \n # Only the owner of the photo, or the tagged person are allowed to remove the tag\n if @user.id == @face.photo.user_id || @user.id == @face.user_id\n \n # Remove tag\n @face.remove_tag\n \n # Action was a success\n success = true\n \n # Notice message\n message = \"Tag was successfully removed\"\n \n end\n \n flash[:notice] = message\n \n respond_to do |format|\n format.html { redirect_to :back }\n format.json { render :json => { :success => success, :message => message } }\n end\n \n end",
"def destroy\n @tags_of_novel = TagsOfNovel.find(params[:id])\n @tags_of_novel.destroy\n\n respond_to do |format|\n format.html { redirect_to tags_of_novels_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n BuzzTag.where(:buzz_id => params[:buzz_id], :tag_id => params[:tag_id]).first.destroy\n end",
"def destroy\n @has_tag.destroy\n respond_to do |format|\n format.html { redirect_to has_tags_url, notice: 'Has tag was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bookmark_tag = BookmarkTag.find(params[:id])\n @bookmark_tag.destroy\n\n respond_to do |format|\n format.html { redirect_to bookmark_tags_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @follow.destroy\n respond_to do |format|\n format.html { redirect_to follows_url, notice: 'Follow was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @follow.destroy\n respond_to do |format|\n format.html { redirect_to follows_url, notice: 'Follow was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def deleteEntityTag( entity_id, gen_id)\n params = Hash.new\n params['entity_id'] = entity_id\n params['gen_id'] = gen_id\n return doCurl(\"delete\",\"/entity/tag\",params)\n end",
"def destroy\n\n @tag.destroy\n\n respond_to do |format|\n format.html { redirect_to tags_url }\n format.json { head :no_content }\n end\n\n end",
"def destroy\n tag = tag.find(params[:id])\n\n if tag.destroy\n render json: {\"message\": \"Record was deleted\", status: :ok, }, status: :ok\n else\n render json: {\"message\": \"You are not authorized to delete this tag\"}, status: :unauthorized\n end\n end",
"def destroy\n @tag = Tag.find(params[:id])\n respond_to do |format|\n if @tag.destroy\n format.json { render json: {:id => @tag.id}, status: :ok }\n else\n format.json { render json: @tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @tag.destroy\n respond_to do |format|\n format.html { redirect_to tags_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @skill_tag = SkillTag.find(params[:id])\n @skill_tag.destroy\n\n respond_to do |format|\n format.html { redirect_to skill_tags_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tag.destroy\n\n respond_to do |format|\n format.html { redirect_to tags_url }\n format.json { head :no_content }\n end\n end",
"def del_follow\n current_user.del_follow(@user)\n\n respond_to do |format|\n format.html { redirect_to wall_user_path(@user) }\n format.json { render :json => { user: @user.as_json(:json => 'wall') }}\n end\n end",
"def destroy\n @post_tag.destroy\n respond_to do |format|\n format.html { redirect_to post_tags_url, notice: 'Tagi poistettu' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @storyline_tag.destroy\n respond_to do |format|\n format.html { redirect_to storyline_tags_url, notice: 'Storyline tag was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @followup_interview = FollowupInterview.find(params[:id])\n @followup_interview.destroy\n\n respond_to do |format|\n format.html { redirect_to followup_interviews_url }\n format.json { head :no_content }\n end\n end",
"def unfollow!(user)\n relationships.find_by_followed_id(user).destroy\n end",
"def destroy\n @photo_tag_reference.destroy\n respond_to do |format|\n format.html { redirect_to photo_tag_references_url, notice: 'Photo tag reference was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @photo_tag.destroy\n respond_to do |format|\n format.html { redirect_to photo_tags_url, notice: 'Photo tag was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tagged_item = TaggedItem.find(params[:id])\n @tagged_item.destroy\n\n respond_to do |format|\n format.html { redirect_to all_items_tagged_items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @followup.destroy\n respond_to do |format|\n format.html { redirect_to @job, notice: 'Follow Up was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recommend_recommend_tag = Recommend::RecommendTag.find(params[:id])\n @recommend_recommend_tag.destroy\n\n respond_to do |format|\n format.html { redirect_to recommend_recommend_tags_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tag_identity = Identity.find(params[:id])\n @tag_identity.destroy\n\n respond_to do |format|\n format.html { redirect_to tag_identities_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n real_post_path = @tag.post\n @tag.destroy\n respond_to do |format|\n format.html { redirect_to post_path(real_post_path), notice: 'tag deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user_follower = UserFollower.find(:first, :conditions => {:user_id => params[:id], :follower_id => params[:user_id]})\n @user_follower.destroy\n\n respond_to do |format|\n format.html { redirect_to(user_tweets_path(current_user)) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @tagging.destroy\n respond_to do |format|\n format.html { redirect_to taggings_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tag_one.destroy\n respond_to do |format|\n format.html { redirect_to tag_ones_url, notice: 'Tag one was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n authorize! :destroy, @rec_event_follow, :message => 'Not authorized as an administrator.'\n @rec_event_follow.destroy\n respond_to do |format|\n format.html { redirect_to rec_event_follows_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tag_relation.destroy\n respond_to do |format|\n format.html { redirect_to tag_relations_url, notice: 'Tag relation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def destroy\n current_account.unfollow(@account)\n respond_to do |format|\n format.html { redirect_to account_url }\n format.json { render :status }\n end\n end",
"def delete_follower(user)\n followers.delete(user)\n end",
"def destroy\n response = current_user.unfollow_item(params[:id])\n redirect_to items_path\n end",
"def destroy\n @events_tag = EventsTag.find(params[:id])\n @events_tag.destroy\n\n respond_to do |format|\n format.html { redirect_to events_tags_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @follow_up_type.destroy\n respond_to do |format|\n format.html { redirect_to follow_up_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @album_follow.destroy\n respond_to do |format|\n format.html { redirect_to album_follows_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @artist_tag = ArtistTag.find(params[:id])\n @artist_tag.destroy\n\n respond_to do |format|\n format.html { redirect_to artist_tags_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tagging = Tagging.find(params[:id])\n @tagging.destroy\n\n respond_to do |format|\n format.html { redirect_to taggings_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @admin_album_tag.destroy\n respond_to do |format|\n format.html { redirect_to admin_album_tags_url, notice: \"#{t 'activerecord.successful.messages.album_tag_deleted'}\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @follower = Follower.find(params[:id])\n @follower.destroy\n\n respond_to do |format|\n format.html { redirect_to followers_url }\n format.json { head :no_content }\n end\n end",
"def unfollow_artist\n relationship_to_delete = Relationship.where(follower_id: params[:follower_id], followed_id: params[:followed_id])\n relationship_to_delete[0].destroy\n relationships = Relationship.where(followed_id: params[:followed_id])\n render json: relationships\n end",
"def destroy\n @tag = current_user_tags.find_by(name: params[:name])\n @tag.destroy\n redirect_to tags_path\n end",
"def destroy\n @ad_tag = AdTag.find(params[:id])\n @ad_tag.destroy\n\n respond_to do |format|\n format.html { redirect_to ad_tags_url }\n format.json { head :ok }\n end\n end",
"def delete\n @tag = Tag.find(params[:id])\n @tag.destroy\n\n respond_to do |format|\n format.html { redirect_to(tags_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @hash_tag.destroy\n respond_to do |format|\n format.html { redirect_to hash_tags_url, notice: 'Hash tag was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @followuptype.destroy\n respond_to do |format|\n format.html { redirect_to followuptypes_url, notice: 'Followuptype was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tag.destroy\n respond_to do |format|\n format.html { redirect_to tags_url, notice: 'Tag was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tag.destroy\n respond_to do |format|\n format.html { redirect_to tags_url, notice: 'Tag was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tag = Tag.find(params[:id])\n @tag.destroy\n\n respond_to do |format|\n format.html { redirect_to(tags_url(parent: @parent_tag)) }\n format.json { head :ok }\n end\n end",
"def destroy\n @tag = Tag.find(params[:id])\n @tag.destroy\n\tflash[:error] = @tag.errors[:base]\n\n respond_to do |format|\n format.html { redirect_to tags_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tag.destroy\n respond_to do |format|\n format.html { redirect_to tags_url, notice: \"Tag was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user_follow_location = UserFollowLocation.find(params[:id])\n @user_follow_location.destroy\n\n respond_to do |format|\n format.html { redirect_to user_follow_locations_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @incidentfollowup.destroy\n respond_to do |format|\n format.html { redirect_to incidentfollowups_url, notice: 'Incidentfollowup was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @answer_tag.destroy\n respond_to do |format|\n format.html { redirect_to answer_tags_url }\n format.json { head :no_content }\n end\n end",
"def remove(user_id, tag_id)\n @_client.delete(\"/users/#{user_id}/tags/#{tag_id}\")\n end"
] | [
"0.71471536",
"0.7110488",
"0.70377684",
"0.6995492",
"0.67928106",
"0.67815906",
"0.6724435",
"0.66691434",
"0.6663651",
"0.6659276",
"0.66347915",
"0.659024",
"0.6580941",
"0.6580363",
"0.6565712",
"0.65651464",
"0.6538799",
"0.6538058",
"0.65360254",
"0.65245426",
"0.6518376",
"0.6507955",
"0.6495926",
"0.6493649",
"0.6488517",
"0.648215",
"0.6481275",
"0.6475334",
"0.6473604",
"0.64664495",
"0.6455113",
"0.6455113",
"0.6455113",
"0.6452133",
"0.6448148",
"0.64473736",
"0.6440789",
"0.6440197",
"0.64316726",
"0.64171815",
"0.64134264",
"0.639992",
"0.63990486",
"0.6396914",
"0.63934624",
"0.6383394",
"0.63800526",
"0.6379308",
"0.6369589",
"0.6369589",
"0.6361253",
"0.6351717",
"0.63498867",
"0.6348984",
"0.6344175",
"0.63423485",
"0.63393766",
"0.63186574",
"0.63144",
"0.63139695",
"0.63099605",
"0.6306216",
"0.6279246",
"0.627737",
"0.6273363",
"0.62719464",
"0.6269541",
"0.62626725",
"0.62567544",
"0.6254231",
"0.6243597",
"0.6238729",
"0.62294376",
"0.6222774",
"0.6209777",
"0.6207112",
"0.6203184",
"0.6200119",
"0.61939496",
"0.6190716",
"0.61903375",
"0.61888015",
"0.61828905",
"0.61747783",
"0.6161725",
"0.6159095",
"0.6153482",
"0.615002",
"0.614967",
"0.6142996",
"0.6141695",
"0.61332124",
"0.61332124",
"0.61324793",
"0.61295956",
"0.61270326",
"0.6122752",
"0.6121661",
"0.6119387",
"0.6118841"
] | 0.79598224 | 0 |
but I still CAN provide an argument for the parameter, overriding the default value | def my_method_hash(attrs = {})
puts "Name is #{attrs[:name]}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def default=(_arg0); end",
"def param_default( param, value )\n param = value unless ( param && param.length > 0 )\n end",
"def foo(param = \"no\") #this is default param\n \"yes\"\nend",
"def set_default\n end",
"def method_missing(*args)\n default\n end",
"def meth( x = nil)\nend",
"def safe_by_default=(_arg0); end",
"def method (number, default1 = 1, default2 = 2)\nend",
"def default(a,b,c=2)\n puts \"c should equal 3 now: \"\n puts c\nend",
"def a_method(arg1, arg2='default value')\n do_stuff\n end",
"def meth(\n # this is important\n important_arg,\n # a default, because we're not animals!\n default=nil)\nend",
"def default_argument(argname)\n if (arg = find_argument(argname)) && arg.has_default?\n [true, arg.default]\n end\n end",
"def default=(value); end",
"def foo(param = 'no')\n 'yes'\nend",
"def foo(param = 'no')\n 'yes'\nend",
"def default=(_); end",
"def override(name, val = NULL_ARG)\n @overrides[name] = val unless val.equal?(NULL_ARG)\n @overrides[name]\n end",
"def param(name, type = nil, **opts, &block)\n raise ArgumentError, \"Default value for param not allowed - #{name}\" if opts.key? :default\n raise ArgumentError, \"Optional params not supported - #{name}\" if opts.fetch(:optional, false)\n\n super\n end",
"def foo(param = \"no\")\r\n \"yes\"\r\nend",
"def foo(param = \"no\")\n \"yes\"\nend",
"def foo(param = \"no\")\n \"yes\"\nend",
"def foo(param = \"no\")\n \"yes\"\nend",
"def foo(param = \"no\")\n \"yes\"\nend",
"def foo(param = \"no\")\n \"yes\"\nend",
"def foo(param = \"no\")\n \"yes\"\nend",
"def foo(param = \"no\")\n \"yes\"\nend",
"def foo(param = \"no\")\n \"yes\"\nend",
"def foo(param = \"no\")\n \"yes\"\nend",
"def foo(param = \"no\")\n \"yes\"\nend",
"def foo(param = \"no\")\n \"yes\"\nend",
"def default; end",
"def default; end",
"def set_default(attr)\n return unless klass = self.class.attrclass(attr)\n return unless klass.method_defined?(:default)\n return if @parameters.include?(klass.name)\n\n return unless parameter = newattr(klass.name)\n\n if value = parameter.default and ! value.nil?\n parameter.value = value\n else\n @parameters.delete(parameter.name)\n end\n end",
"def func(my_data = \"defaultInput\")\n puts \"data is #{my_data}\" \nend",
"def default_value(value); value; end",
"def hello(name=\"World\") # Default parameter\n puts \"Hello #{ name }\"\nend",
"def one_parameter_method (argument=\"nothing\")\n return argument\nend",
"def method (a,\r\n\tb = 2)\r\nend",
"def method (a=3, b)\r\nend",
"def default(a = 10, b) # it's possible in ruby to have default value as first parameter\n return a, b\nend",
"def method(a=3)\r\n a\r\nend",
"def method_with_optional_param(param = foo)\nend",
"def test_function(arg = 'hello')\n puts arg + ' world'\nend",
"def default_if_not_specified(opt,default_opt)\n opt ? opt : default_opt\nend",
"def default_configuration=(_arg0); end",
"def in_kwarg=(_arg0); end",
"def defaults!; end",
"def defaults!; end",
"def default_bare=(_arg0); end",
"def missing_option=(_arg0); end",
"def missing_option=(_arg0); end",
"def missing_option=(_arg0); end",
"def missing_option=(_arg0); end",
"def missing_option=(_arg0); end",
"def missing_option=(_arg0); end",
"def assign_name(default = 'Bob')\n default\nend",
"def default!\n @value = default\n end",
"def method(c=c)\r\nend",
"def set_default(name, *args, &block)\n set(name, *args, &block) unless exists?(name)\nend",
"def set_default(name, *args, &block)\n set(name, *args, &block) unless exists?(name)\nend",
"def foo(param = \"no\")\n \"yes\" #Returns yes\nend",
"def default\n end",
"def default _args\n \"default _args;\" \n end",
"def overrides=(_arg0); end",
"def autofinish=(_arg0); end",
"def to_ruby_arg\n \"#{to_s_name}#{@default ? ' = ' + @default : ''}\"\n end",
"def add_param(param, initial = nil)\n @default_params ||= {}\n @default_params[param.to_sym] = initial\n end",
"def assign_name(name = 'Bob')\n name\nend",
"def assign_name(name = 'Bob')\n name\nend",
"def f4(x:, x: nil); end",
"def extra=(_arg0); end",
"def method (a=3,\r\n\tb)\r\nend",
"def two_arg_method_defaults(arg1=0, arg2=\"020202\")\n puts \"Here are my args: #{arg1}, #{arg2}\"\nend",
"def default_args(a,b,c=1)\n puts \"\\nValues of variables: \",a,b,c\nend",
"def f7(x=0, x: nil); end",
"def f2(x, x=0); end",
"def test_set_defaults09a\n assert_raise ( RuntimeError ) {\n ArgumentManager.set_defaults(\n {\n :df_str => 0\n }\n )\n } \n end",
"def optional default_return_value = NoParameterMarker.instance\n if default_return_value == NoParameterMarker.instance\n repeat 0, 1 # default behaviour\n else\n repeat_with_default 0, 1, default_return_value\n end\n end",
"def assign_name(name = \"Bob\")\n name\nend",
"def assign_name(name = \"Bob\")\n name\nend",
"def method (a=3, b=4)\r\nend",
"def test_set_defaults07b\n assert_raise ( RuntimeError ) {\n ArgumentManager.set_defaults(\n {\n :df_int => 999\n }\n )\n } \n end",
"def default_params_encoder=(_arg0); end",
"def initialize(value)\r\n @value = value\r\n @changeable = true\r\n default_value?\r\nend",
"def default(options = T.unsafe(nil)); end",
"def method_name(arguments = 'default parameters')\n #do something\n new_thing = arguments\n return new_thing\nend",
"def defaults; end",
"def defaults; end",
"def defaults; end",
"def defaults; end",
"def defaults; end",
"def defaults; end",
"def defaults; end",
"def defaults; end",
"def defaults; end",
"def defaults; end",
"def default=( val )\r\n @opts[:default] = val\r\n end",
"def required_defaults; end",
"def PRF02=(arg)",
"def assign_name(name = 'Bob')\n\tname\nend",
"def explicit=(_arg0); end"
] | [
"0.79086506",
"0.7807899",
"0.75724",
"0.713247",
"0.7108626",
"0.7106757",
"0.7043715",
"0.7039026",
"0.7024428",
"0.6997972",
"0.6990686",
"0.6982948",
"0.69826704",
"0.6970951",
"0.6970951",
"0.6946422",
"0.6930741",
"0.69297403",
"0.68954176",
"0.68739206",
"0.68739206",
"0.68739206",
"0.68739206",
"0.68739206",
"0.68739206",
"0.68739206",
"0.68739206",
"0.68739206",
"0.68739206",
"0.68739206",
"0.68361056",
"0.68361056",
"0.68210775",
"0.68118554",
"0.68046445",
"0.6799427",
"0.67979276",
"0.6786601",
"0.6782176",
"0.6779345",
"0.6777048",
"0.67562985",
"0.67533314",
"0.67501855",
"0.6746097",
"0.6730851",
"0.67263967",
"0.67263967",
"0.6717518",
"0.6701307",
"0.6701307",
"0.6701307",
"0.6701307",
"0.6701307",
"0.6701307",
"0.66821265",
"0.6674246",
"0.6665552",
"0.66601735",
"0.66601735",
"0.6655402",
"0.66529685",
"0.6638148",
"0.6615492",
"0.6615148",
"0.66069406",
"0.6605745",
"0.66020095",
"0.66020095",
"0.65807784",
"0.6558907",
"0.65516025",
"0.65452904",
"0.65208215",
"0.6511536",
"0.650104",
"0.6494723",
"0.64763",
"0.6465514",
"0.6465514",
"0.64616907",
"0.6455512",
"0.6452074",
"0.64452904",
"0.64440376",
"0.6441424",
"0.6440834",
"0.6440834",
"0.6440834",
"0.6440834",
"0.6440834",
"0.6440834",
"0.6440834",
"0.6440834",
"0.6440834",
"0.6440834",
"0.64296204",
"0.6424215",
"0.6408609",
"0.64085907",
"0.64004344"
] | 0.0 | -1 |
So we can return a Qsome::Job, not a Qless::Job | def get(jid)
results = @client.call('get', jid)
Job.new(@client, JSON.parse(results)) unless results.nil?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def job\n job_name.constantize.new({\n :context => self\n })\n end",
"def job\n @job\n end",
"def job # this is a getter\n @job\n end",
"def job\n @job\n end",
"def job\n @job\n end",
"def queue_job; end",
"def jobs\n raise NotImplementedError\n end",
"def job \n @job\n end",
"def job_class\n SingleInstanceQueueJob\n end",
"def job\n return nil if self.job_id.nil?\n Delayed::Job.find(self.job_id)\n end",
"def getJob(db, jid)\n\tjob = JobAbstract.new(db, jid)\n\ttype = job.type\n\t\n\t#if type == 'build'\n\t#\treturn JobBuild.new(db, jid)\n\t#end\n\t\n\tjob\nend",
"def get_job\n begin\n s, sproc, clazz = selector\n # Take the job from TS using the job selector\n job = take s, 0, false\n\n # Remove job from envelope\n sproc_meth = sproc.respond_to?(:process) ? :process : :call\n job = sproc.send sproc_meth, job\n\n yield job['job']\n rescue Rinda::RequestExpiredError => e\n # This happens when the lookup expires, it's an OK exception\n # TODO use wait time in take?\n sleep @job_search_timeout\n end\n end",
"def scrape_job_from_qjob qjob\n args = qjob.body.split(\"\\t\")\n # request_klass = Wukong.class_from_resource(args.shift)\n scrape_job = request_klass.new(*args[1..-1])\n end",
"def current_job\n return @job_current\n end",
"def work\n possible_job = pluck_queue_message(:job_requests) # FIX: pluck doesn't delete\n job = Job.build(@instance_id, possible_job)\n job.valid? ? process(job) : process_invalid(job)\n end",
"def get_future_job(uuid, klass)\n ResqueFuture::FutureJob.get(queue_from_class(klass), uuid)\n end",
"def to_job\n job = Patriot::JobStore::Job.new(self.job_id)\n job.read_command(self)\n return job\n end",
"def job(job_name)\n jobs job_name\n end",
"def job\n job_uuid && Jobber::Job::Base.find_job(job_uuid)\n end",
"def jobs\n @jobs ||= Beaneater::Jobs.new(self)\n end",
"def working!\n disque.with {|cn| cn.call :working, job_id } if disque && job_id\n end",
"def job_resource(job)\n if job['wrapped']\n job['wrapped']\n else\n job['class']\n end\n end",
"def job\n OSC::Machete::Job.new(\n script: script,\n pbsid: pbsid,\n host: host || workflow.batch_host,\n torque_helper: ResourceMgrAdapter.new(workflow)\n )\n end",
"def job\n JenkinsApi::Client::Job.new(self)\n end",
"def job\n JenkinsApi::Client::Job.new(self)\n end",
"def job\n operation_ids = operations.map(&:id)\n ja_ids = JobAssociation.where(operation_id: operation_ids).map(&:job_id).uniq\n jobs = Job.find(ja_ids).select(&:active?)\n raise ProtocolError, 'Cannot resolve the current Job' if jobs.length > 1\n\n jobs.last\n end",
"def job_parser\n @job_parser || Job\n end",
"def try_perform_later(...)\n job = job_or_instantiate(...)\n\n result = job.enqueue\n\n yield job if block_given?\n\n return Failure(job) if result == false\n\n Success(job)\n end",
"def jobs\n\t\t# ...\n\tend",
"def job_class\n return if job_class_name.nil?\n job_class_name.constantize\n rescue NameError\n nil\n end",
"def reserve_and_run_one_job; end",
"def Job(active_job)\n lambda do |object|\n active_job.perform_later(object.id)\n end\n end",
"def grab_job_uniq\n throw :notimpl\n end",
"def work_job\n \n # MAINTENANCE\n \n # Are we shutting down?\n if @shutdown\n Kernel.exit!(0) if @current_jobs.size == 0\n end\n \n # PROCESSING JOBS\n \n # Get a job\n job = get_new_job\n return unless job\n log.info \"Got a new job #{job.id}\"\n \n if job.job_class.fork?\n # Job that requires a fork, perfect for long-running stuff.\n log.debug \"Forking the process for job #{job.id}\"\n pid = fork do\n process_job job\n end\n @job_pids[job.id] = pid\n # TODO: We need to store which PID corresponds to this job\n elsif job.job_class.fiber?\n # A job that requires a separate fiber.\n log.debug \"Creating a new fiber for job #{job.id}\"\n Fiber.new do\n process_job job\n finish_job job\n end.resume\n else\n # Old-school, blocking job\n log.debug \"Running job #{job.id} in the blocking mode\"\n process_job job\n finish_job job\n end\n end",
"def job\n\t\tjid = @db.hget('sgt-unit:'+@id, 'job')\n\t\treturn nil if jid == nil\n\t\tgetJob(@db, jid)\n\tend",
"def collect_new_jobs\n raise NotImplementedError\n end",
"def retrieve_job\n json = Server.redis { |c| c.brpop(Server.keys[:perform_list]) }\n Job.new(JSON.parse(json.last))\n rescue => e\n raise ServerError, e.message\n end",
"def work_job(queue = :job)\n worker = Resque::Worker.new(queue)\n worker.perform(worker.reserve)\n end",
"def job_id\n async && async.job_id\n end",
"def run_job\n end",
"def and(result)\n return self unless result.is_a? JobResult\n msg = [self.message, result.message].delete_if { |m| m.nil? || m.empty? }\n requeue = if self.success? then result.requeue? else self.requeue? end\n JobResult.new(msg.first, self.success? && result.success?, requeue)\n end",
"def get_job(jobid, cluster)\n begin\n data = cluster.job_adapter.info(jobid)\n\n raise OodCore::JobAdapterError if data.native.nil?\n ActiveJobs::Jobstatusdata.new(data, cluster, true)\n\n rescue OodCore::JobAdapterError\n OpenStruct.new(name: jobid, error: \"No job details because job has already left the queue.\" , status: status_label(\"completed\") )\n rescue => e\n Rails.logger.info(\"#{e}:#{e.message}\")\n Rails.logger.info(e.backtrace.join(\"\\n\"))\n OpenStruct.new(name: jobid, error: \"No job details available.\\n\" + e.backtrace.to_s, status: status_label(\"\") )\n end\n end",
"def job(id)\n Job.new(id, self)\n end",
"def job_service\n job_arguments(0)\n end",
"def sync_job\n return sync_jobs.last unless sync_jobs.empty?\n end",
"def rocket_job_next_job(worker_name, filter = {})\n while (job = rocket_job_retrieve(worker_name, filter))\n # Batch Job?\n return job if job.running?\n\n if job.expired?\n job.rocket_job_fail_on_exception!(worker_name) { job.destroy }\n logger.info \"Destroyed expired job #{job.class.name}, id:#{job.id}\"\n elsif (new_filter = job.send(:rocket_job_evaluate_throttles))\n rocket_job_merge_filter(filter, new_filter)\n # Restore retrieved job so that other workers can process it later\n job.set(worker_name: nil, state: :queued)\n else\n job.worker_name = worker_name\n job.rocket_job_fail_on_exception!(worker_name) do\n job.start!\n end\n return job if job.running?\n end\n end\n end",
"def grab_job(unique = false)\n worker = Worker.find_or_create_by_worker_id(@worker_id)\n worker.update_attributes({:last_seen => Time.now()})\n \n if job = worker_queue.grab_job(@capabilities) \n logger.debug \"Handed out job\"\n if unique\n respond :job_assign_uniq, job[:job_handle], job.func_name, job[:uniq], job[:data]\n else \n respond :job_assign, job[:job_handle], job.func_name, job[:data]\n end\n else\n logger.debug \"No job!\"\n respond :no_job\n end\n \n end",
"def kind\n job_class.underscore.sub(/_operation_job$/, \"\")\n end",
"def new_job\n j = self.class.new\n j.save\n end",
"def access_current_job\n if job = @job\n yield job\n end\n end",
"def method_missing sym, *args, &block\n if job = @hud.jobs.find_by_name( sym )\n job\n else\n super sym, *args, &block\n end\n end",
"def as_jobs\n @jobs ||= find_latest_completed_jobs\n end",
"def request_job_to_process\n \n response = HTTParty.get(\"#{@host}/api/process/request_job/#{@process_code}.json\", query: {\n api_key: @api_key\n })\n\n job = response[\"job\"]\n #If there is no job waiting, end script\n if job.nil? || job[\"id\"].to_i == 0 \n @helper.terminate(\"No job to process at this time\")\n else\n @helper.log(\"Starting process #{@process_code} for job: #{job[\"id\"]} - #{job[\"author\"]} - #{job[\"title\"]} - #{job[\"created_at\"]}\")\n end\n return job\n end",
"def job(job,params={})\n if (@job[extract_job(job)] && !params[:force])\n return @job[extract_job(job)]\n end\n @job[extract_job(job)] = get_job(job)\n end",
"def job_id\n raise NotImplementedError\n end",
"def perform(*args, **opt)\n no_raise = record = nil\n super\n args = arguments.dup\n opt = args.extract_options!.dup\n no_raise = opt.delete(:no_raise)\n meth = opt[:meth] ||= \"#{self.class}.#{__method__}\"\n start = opt[:start] ||= timestamp\n timeout = opt[:timeout]\n\n service = args.shift.presence or raise ExecError, \"#{meth}: no service\"\n request = args.shift.presence or raise ExecError, \"#{meth}: no request\"\n record = JobResult.create(active_job_id: job_id)\n\n opt[:deadline] ||= (start + timeout) if timeout\n opt[:job_type] ||= service.is_a?(Array) ? :waiter : :worker\n\n # noinspection RubyMismatchedArgumentType\n if opt[:job_type] == :worker\n worker_task(record, service, request, **opt)\n else\n waiter_task(record, service, request, **opt)\n end\n\n rescue => error\n record&.update(error: error)\n raise error unless no_raise\n __output \"JOB ERROR: #{error.full_message}\"\n {}\n end",
"def run\n case self[:job]\n when Proc\n self[:job].call\n else\n self[:job]\n end\n end",
"def jobs\r\n end",
"def job= (work)\n @job = work\n end",
"def job_class(item = nil)\n # noinspection RubyMismatchedArgumentType\n item and super or @job_class ||= super(self)\n end",
"def job_spec_name\n self.job_spec.name\n end",
"def work\n if job = lock_job\n QC.log_yield(:action => \"work_job\", :job => job[:id]) do\n begin\n call(job)\n log(:action => \"finished_work\", :job => job[:id])\n rescue Object => e\n log(:action => \"failed_work\", :job => job[:id], :error => e.inspect)\n handle_failure(job, e)\n ensure\n @queue.delete(job[:id])\n log(:action => \"delete_job\", :job => job[:id])\n end\n end\n end\n end",
"def rocket_job_class\n @rocket_job_class\n end",
"def work_one_job(conn = connection)\n begin\n job = reserve_job(conn)\n rescue Beaneater::TimedOutError => e\n return\n end\n\n self.log_job_begin(job.name, job.args)\n job.process\n self.log_job_end(job.name)\n\n rescue Backburner::Job::JobFormatInvalid => e\n self.log_error self.exception_message(e)\n rescue => e # Error occurred processing job\n self.log_error self.exception_message(e) unless e.is_a?(Backburner::Job::RetryJob)\n\n unless job\n self.log_error \"Error occurred before we were able to assign a job. Giving up without retrying!\"\n return\n end\n\n # NB: There's a slight chance here that the connection to beanstalkd has\n # gone down between the time we reserved / processed the job and here.\n num_retries = job.stats.releases\n max_job_retries = resolve_max_job_retries(job.job_class)\n retry_status = \"failed: attempt #{num_retries+1} of #{max_job_retries+1}\"\n if num_retries < max_job_retries # retry again\n retry_delay = resolve_retry_delay(job.job_class)\n delay = resolve_retry_delay_proc(job.job_class).call(retry_delay, num_retries) rescue retry_delay\n job.retry(num_retries + 1, delay)\n self.log_job_end(job.name, \"#{retry_status}, retrying in #{delay}s\") if job_started_at\n else # retries failed, bury\n job.bury\n self.log_job_end(job.name, \"#{retry_status}, burying\") if job_started_at\n end\n\n handle_error(e, job.name, job.args, job)\n end",
"def batch\n job && job.batch\n end",
"def job_class(item = nil)\n item and super or @job_class ||= super(self)\n end",
"def pull_job(job_name = nil)\r\n lock\r\n job,status = internal_find_job(job_name)\r\n if job && status == ST_QUEUED\r\n # Move to run, notice use of job.name rather than job_name\r\n # .. if we are pulling a new job, it could be nil\r\n FileUtils.mv(@dir + '/que/' + job.name, @dir + '/run/' + job.name)\r\n job.set_as_active\r\n elsif job\r\n # We cannot pull a job that isn't queued\r\n log(\"cannot pull job that isn't queued: \" + job_name)\r\n job = nil\r\n end\r\n unlock\r\n return job\r\n end",
"def invoke_job\r\n\r\n # BgWorker.log(\"Worker: invoke job\")\r\n\r\n fork {\r\n\r\n # BgWorker.log(\"Worker: fork: system 'cd #{Rails.root}; rake #{self.name}'\")\r\n\r\n `cd #{Rails.root}; rake #{self.name}`\r\n\r\n # BgWorker.log(\"Worker: fork: closing job #{res ? 'OK' : 'KO'}, return code: #{$?}\")\r\n\r\n self.close_job($?)\r\n }\r\nend",
"def find_job(job_id)\n response = HTTParty.get(\"#{@host}/api/jobs/#{job_id}\")\n\n return response['job']\n end",
"def queue\n Future.new(super)\n end",
"def dry_run\n Job::run self\n end",
"def get_job (job_id)\n\n @cron_jobs[job_id] || @non_cron_jobs[job_id]\n end",
"def queue\n pending_duplicate_job || Delayed::Job.enqueue(self)\n end",
"def persistent_job\n job_id = Thread.current[:persistent_job_id]\n job_id ? BdrbJobQueue.find_by_id(job_id) : nil\n end",
"def delete_job\n raise NotImplementedError\n end",
"def prepare_job \n if @job_condition\n @job = Job.new\n parse_values(\"JOB\", @job)\n @job = update_job @job\n @jobs << @job\n end\n end",
"def job_type_name\r\n job_type.job_name rescue nil\r\n end",
"def to_task; self end",
"def work_once()\n json = @redis.rpop @queue\n raise @@EOQ unless json\n hash = JSON.parse(json)\n # Next bit is sort of ugly, \n klass = Object.const_get(hash[\"class\"])\n raise ArgumentError.new(\"Improper Class\") unless klass < QueuED::QueueAble\n obj = klass.new\n obj.from_hash!(hash)\n obj.do_task\n obj.queue_down(redis:@redis, queue:@queue)\n return obj\n end",
"def jobs_without_template\n []\n end",
"def new\n @job = Job.new\n end",
"def be_worker\n before_work\n super\n end",
"def build_promise(depending_job, param_key)\n Promise.new.tap do |promise|\n promise.assign_attributes(job_id: job.id, hash_field: param_key, result_key: result_key)\n depending_job.promise_ids << promise.id\n end\n end",
"def job_items\n job_arguments(1)\n end",
"def job_klass\n VoyagerUpdateJob\n end",
"def new\n @job = Job.new\n end",
"def application_job_class\n @application_job_class ||= self.class.ancestors.find { |ancestor|\n ancestor.name =~ /ApplicationJob/\n }\n end",
"def new_job(job, username, password)\n puts \"Requesting quote for job:\"\n puts JSON.pretty_generate(job)\n puts \"\"\n res = post_json('jobs.json', job, username, password)\n if res['error'] || res['status'] == 'error'\n puts \"Job rejected (error #{res['status']}): #{res['error'] || res['reason']}\"\n return\n end\n\n puts \"Gnip's job desc:\"\n puts summarise_job(res)\nend",
"def jobs\n @jobs || {}\n end",
"def job\n fetch('games.final_fantasy_xiv.jobs')\n end",
"def active_job_message\n {\n 'class' => 'ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper',\n 'wrapped' => @klass,\n 'queue' => @queue_name_with_prefix,\n 'description' => @description,\n 'args' => [{\n 'job_class' => @klass,\n 'job_id' => SecureRandom.uuid,\n 'queue_name' => @queue_name_with_prefix,\n 'arguments' => @args\n }]\n }\n end",
"def getNextJob()\n\t\t\t\tjob = nil\n\t\t\t\t\n\t\t\t\tThread.exclusive {\n\t\t\t\t\ti = @jobs.index { |j| j.canStart() }\n\t\t\t\t\tjob = @jobs.delete_at( i ) if ( i != nil )\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\treturn job\n\t\t\tend",
"def enqueue!\n return nil unless persisted?\n \"#{job_type.camelize}Job\".constantize.perform_later(self)\n end",
"def job_key; Thread.current[:job_key]; end",
"def getCurrentJobs\n getJobs('0/')\n end",
"def clone\n @job = Job.find(params[:id]).cloned_job\n if current_user and default_queue = current_user.preferences.find_by_kind('default_queue') then @job.jobs_queue_id = default_queue.value end\n \n respond_to do |format|\n if @job.valid?\n # flash[:notice] = 'Job was successfully cloned.'\n format.html { render :action => \"new\" }\n format.xml { \n if @job.save!\n @job.submit() \n head :ok\n else\n render :xml => @job.errors, :status => :unprocessable_entity\n end \n }\n else\n format.html { render :action => \"show\" }\n format.xml { render :xml => @job.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def run_backup_job(wi)\n # In case of large # of queued jobs for the same source, we check for the latest \n # and skip processing if too close in time to the last one\n if recent_job? wi\n raise BackupSourceExecutionFlood.new(\"Backup source backup job run too recently to run now\")\n end\n if DISABLE_LONG_DATASETS && (get_dataset(wi) != EternosBackup::SiteData.defaultDataSet)\n raise BackupSourceExecutionFlood.new(\"Disabling long running data backups\")\n end\n\n # Fetch or create existing BackupSourceJob record\n job = nil\n BackupSourceJob.transaction do \n if job = BackupSourceJob.find(:first, :conditions => {:backup_job_id => wi.job_id, :backup_source_id => wi.source_id, :backup_data_set_id => get_dataset(wi)})\n # Found existing job, clear errors\n job.status = BackupStatus::Running\n job.messages = job.error_messages = nil\n job.percent_complete = 0\n else\n # BackupSourceJob.create generates fucked up error: \"unknown attribute: backup_source_id\" ???!!\n # Try using new/save as workaround\n job = BackupSourceJob.new\n job.backup_job_id = wi.job_id\n job.backup_source_id = wi.source_id\n job.backup_data_set_id = get_dataset(wi)\n job.status = BackupStatus::Running\n end\n job.save\n end\n\n unless job && job.backup_source\n raise BackupSourceNotFoundException.new(\"Unable to find backup source #{wi.source_id} for backup job #{wi.job_id}\")\n end\n # Save job's start time to cache\n BackupWorker.cache.set job_start_key(wi), job.created_at.to_s\n \n job.status = BackupStatus::Success # successful unless an error occurs later\n \n yield job\n\n job_finished(job)\n end",
"def job_placeholder_of(task, cycle)\n if task.kind_of?(Roby::Interface::Job)\n _, snapshot, * = history[cycle]\n task\n .enum_parent_objects(snapshot.relations[Roby::TaskStructure::PlannedBy])\n .first\n end\n end",
"def worker_factory(&block)\n end",
"def get_job job_id, location: nil\n # The get operation is considered idempotent\n execute backoff: true do\n service.get_job @project, job_id, location: location\n end\n end"
] | [
"0.6795402",
"0.67704654",
"0.6742676",
"0.6729724",
"0.6729724",
"0.6681992",
"0.6655046",
"0.6626932",
"0.642745",
"0.6382254",
"0.63598585",
"0.63112384",
"0.63021314",
"0.6276726",
"0.62735003",
"0.6265982",
"0.62589955",
"0.62364346",
"0.6171337",
"0.6170372",
"0.6166588",
"0.6123663",
"0.61236566",
"0.6095571",
"0.6095571",
"0.6058283",
"0.6035042",
"0.6025192",
"0.6020349",
"0.59924656",
"0.5956802",
"0.5942837",
"0.59417707",
"0.58996356",
"0.5889621",
"0.5886434",
"0.588018",
"0.58734405",
"0.58246547",
"0.5812445",
"0.57851225",
"0.5782215",
"0.5766176",
"0.5765864",
"0.57564896",
"0.5751962",
"0.5739756",
"0.5738678",
"0.5733529",
"0.57252073",
"0.570838",
"0.57021075",
"0.56784517",
"0.5668351",
"0.56579506",
"0.56411976",
"0.56311226",
"0.56293565",
"0.5615358",
"0.55951875",
"0.5591573",
"0.5589669",
"0.5580009",
"0.5574126",
"0.5557848",
"0.5553408",
"0.5551553",
"0.551209",
"0.5502037",
"0.5498497",
"0.54853463",
"0.5479175",
"0.547272",
"0.5470898",
"0.54633206",
"0.54589236",
"0.54559207",
"0.5434769",
"0.5424811",
"0.5421503",
"0.5412805",
"0.54126465",
"0.5403007",
"0.5402542",
"0.5401653",
"0.53974307",
"0.5383424",
"0.53808427",
"0.53785187",
"0.5372445",
"0.53708297",
"0.53610384",
"0.5351051",
"0.53467375",
"0.534043",
"0.5339428",
"0.53320765",
"0.53300637",
"0.5329423",
"0.5326736"
] | 0.57333815 | 49 |
So we can return a Qsome::Job, not a Qless::Job | def multiget(*jids)
results = JSON.parse(@client.call('multiget', *jids))
results.map do |data|
Job.new(@client, data)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def job\n job_name.constantize.new({\n :context => self\n })\n end",
"def job\n @job\n end",
"def job # this is a getter\n @job\n end",
"def job\n @job\n end",
"def job\n @job\n end",
"def queue_job; end",
"def jobs\n raise NotImplementedError\n end",
"def job \n @job\n end",
"def job_class\n SingleInstanceQueueJob\n end",
"def job\n return nil if self.job_id.nil?\n Delayed::Job.find(self.job_id)\n end",
"def getJob(db, jid)\n\tjob = JobAbstract.new(db, jid)\n\ttype = job.type\n\t\n\t#if type == 'build'\n\t#\treturn JobBuild.new(db, jid)\n\t#end\n\t\n\tjob\nend",
"def get_job\n begin\n s, sproc, clazz = selector\n # Take the job from TS using the job selector\n job = take s, 0, false\n\n # Remove job from envelope\n sproc_meth = sproc.respond_to?(:process) ? :process : :call\n job = sproc.send sproc_meth, job\n\n yield job['job']\n rescue Rinda::RequestExpiredError => e\n # This happens when the lookup expires, it's an OK exception\n # TODO use wait time in take?\n sleep @job_search_timeout\n end\n end",
"def scrape_job_from_qjob qjob\n args = qjob.body.split(\"\\t\")\n # request_klass = Wukong.class_from_resource(args.shift)\n scrape_job = request_klass.new(*args[1..-1])\n end",
"def current_job\n return @job_current\n end",
"def work\n possible_job = pluck_queue_message(:job_requests) # FIX: pluck doesn't delete\n job = Job.build(@instance_id, possible_job)\n job.valid? ? process(job) : process_invalid(job)\n end",
"def get_future_job(uuid, klass)\n ResqueFuture::FutureJob.get(queue_from_class(klass), uuid)\n end",
"def to_job\n job = Patriot::JobStore::Job.new(self.job_id)\n job.read_command(self)\n return job\n end",
"def job(job_name)\n jobs job_name\n end",
"def job\n job_uuid && Jobber::Job::Base.find_job(job_uuid)\n end",
"def jobs\n @jobs ||= Beaneater::Jobs.new(self)\n end",
"def working!\n disque.with {|cn| cn.call :working, job_id } if disque && job_id\n end",
"def job_resource(job)\n if job['wrapped']\n job['wrapped']\n else\n job['class']\n end\n end",
"def job\n OSC::Machete::Job.new(\n script: script,\n pbsid: pbsid,\n host: host || workflow.batch_host,\n torque_helper: ResourceMgrAdapter.new(workflow)\n )\n end",
"def job\n JenkinsApi::Client::Job.new(self)\n end",
"def job\n JenkinsApi::Client::Job.new(self)\n end",
"def job\n operation_ids = operations.map(&:id)\n ja_ids = JobAssociation.where(operation_id: operation_ids).map(&:job_id).uniq\n jobs = Job.find(ja_ids).select(&:active?)\n raise ProtocolError, 'Cannot resolve the current Job' if jobs.length > 1\n\n jobs.last\n end",
"def job_parser\n @job_parser || Job\n end",
"def try_perform_later(...)\n job = job_or_instantiate(...)\n\n result = job.enqueue\n\n yield job if block_given?\n\n return Failure(job) if result == false\n\n Success(job)\n end",
"def jobs\n\t\t# ...\n\tend",
"def job_class\n return if job_class_name.nil?\n job_class_name.constantize\n rescue NameError\n nil\n end",
"def reserve_and_run_one_job; end",
"def Job(active_job)\n lambda do |object|\n active_job.perform_later(object.id)\n end\n end",
"def grab_job_uniq\n throw :notimpl\n end",
"def work_job\n \n # MAINTENANCE\n \n # Are we shutting down?\n if @shutdown\n Kernel.exit!(0) if @current_jobs.size == 0\n end\n \n # PROCESSING JOBS\n \n # Get a job\n job = get_new_job\n return unless job\n log.info \"Got a new job #{job.id}\"\n \n if job.job_class.fork?\n # Job that requires a fork, perfect for long-running stuff.\n log.debug \"Forking the process for job #{job.id}\"\n pid = fork do\n process_job job\n end\n @job_pids[job.id] = pid\n # TODO: We need to store which PID corresponds to this job\n elsif job.job_class.fiber?\n # A job that requires a separate fiber.\n log.debug \"Creating a new fiber for job #{job.id}\"\n Fiber.new do\n process_job job\n finish_job job\n end.resume\n else\n # Old-school, blocking job\n log.debug \"Running job #{job.id} in the blocking mode\"\n process_job job\n finish_job job\n end\n end",
"def job\n\t\tjid = @db.hget('sgt-unit:'+@id, 'job')\n\t\treturn nil if jid == nil\n\t\tgetJob(@db, jid)\n\tend",
"def collect_new_jobs\n raise NotImplementedError\n end",
"def retrieve_job\n json = Server.redis { |c| c.brpop(Server.keys[:perform_list]) }\n Job.new(JSON.parse(json.last))\n rescue => e\n raise ServerError, e.message\n end",
"def work_job(queue = :job)\n worker = Resque::Worker.new(queue)\n worker.perform(worker.reserve)\n end",
"def job_id\n async && async.job_id\n end",
"def run_job\n end",
"def and(result)\n return self unless result.is_a? JobResult\n msg = [self.message, result.message].delete_if { |m| m.nil? || m.empty? }\n requeue = if self.success? then result.requeue? else self.requeue? end\n JobResult.new(msg.first, self.success? && result.success?, requeue)\n end",
"def get_job(jobid, cluster)\n begin\n data = cluster.job_adapter.info(jobid)\n\n raise OodCore::JobAdapterError if data.native.nil?\n ActiveJobs::Jobstatusdata.new(data, cluster, true)\n\n rescue OodCore::JobAdapterError\n OpenStruct.new(name: jobid, error: \"No job details because job has already left the queue.\" , status: status_label(\"completed\") )\n rescue => e\n Rails.logger.info(\"#{e}:#{e.message}\")\n Rails.logger.info(e.backtrace.join(\"\\n\"))\n OpenStruct.new(name: jobid, error: \"No job details available.\\n\" + e.backtrace.to_s, status: status_label(\"\") )\n end\n end",
"def job(id)\n Job.new(id, self)\n end",
"def job_service\n job_arguments(0)\n end",
"def sync_job\n return sync_jobs.last unless sync_jobs.empty?\n end",
"def rocket_job_next_job(worker_name, filter = {})\n while (job = rocket_job_retrieve(worker_name, filter))\n # Batch Job?\n return job if job.running?\n\n if job.expired?\n job.rocket_job_fail_on_exception!(worker_name) { job.destroy }\n logger.info \"Destroyed expired job #{job.class.name}, id:#{job.id}\"\n elsif (new_filter = job.send(:rocket_job_evaluate_throttles))\n rocket_job_merge_filter(filter, new_filter)\n # Restore retrieved job so that other workers can process it later\n job.set(worker_name: nil, state: :queued)\n else\n job.worker_name = worker_name\n job.rocket_job_fail_on_exception!(worker_name) do\n job.start!\n end\n return job if job.running?\n end\n end\n end",
"def grab_job(unique = false)\n worker = Worker.find_or_create_by_worker_id(@worker_id)\n worker.update_attributes({:last_seen => Time.now()})\n \n if job = worker_queue.grab_job(@capabilities) \n logger.debug \"Handed out job\"\n if unique\n respond :job_assign_uniq, job[:job_handle], job.func_name, job[:uniq], job[:data]\n else \n respond :job_assign, job[:job_handle], job.func_name, job[:data]\n end\n else\n logger.debug \"No job!\"\n respond :no_job\n end\n \n end",
"def kind\n job_class.underscore.sub(/_operation_job$/, \"\")\n end",
"def new_job\n j = self.class.new\n j.save\n end",
"def get(jid)\n results = @client.call('get', jid)\n Job.new(@client, JSON.parse(results)) unless results.nil?\n end",
"def access_current_job\n if job = @job\n yield job\n end\n end",
"def method_missing sym, *args, &block\n if job = @hud.jobs.find_by_name( sym )\n job\n else\n super sym, *args, &block\n end\n end",
"def as_jobs\n @jobs ||= find_latest_completed_jobs\n end",
"def request_job_to_process\n \n response = HTTParty.get(\"#{@host}/api/process/request_job/#{@process_code}.json\", query: {\n api_key: @api_key\n })\n\n job = response[\"job\"]\n #If there is no job waiting, end script\n if job.nil? || job[\"id\"].to_i == 0 \n @helper.terminate(\"No job to process at this time\")\n else\n @helper.log(\"Starting process #{@process_code} for job: #{job[\"id\"]} - #{job[\"author\"]} - #{job[\"title\"]} - #{job[\"created_at\"]}\")\n end\n return job\n end",
"def job(job,params={})\n if (@job[extract_job(job)] && !params[:force])\n return @job[extract_job(job)]\n end\n @job[extract_job(job)] = get_job(job)\n end",
"def job_id\n raise NotImplementedError\n end",
"def perform(*args, **opt)\n no_raise = record = nil\n super\n args = arguments.dup\n opt = args.extract_options!.dup\n no_raise = opt.delete(:no_raise)\n meth = opt[:meth] ||= \"#{self.class}.#{__method__}\"\n start = opt[:start] ||= timestamp\n timeout = opt[:timeout]\n\n service = args.shift.presence or raise ExecError, \"#{meth}: no service\"\n request = args.shift.presence or raise ExecError, \"#{meth}: no request\"\n record = JobResult.create(active_job_id: job_id)\n\n opt[:deadline] ||= (start + timeout) if timeout\n opt[:job_type] ||= service.is_a?(Array) ? :waiter : :worker\n\n # noinspection RubyMismatchedArgumentType\n if opt[:job_type] == :worker\n worker_task(record, service, request, **opt)\n else\n waiter_task(record, service, request, **opt)\n end\n\n rescue => error\n record&.update(error: error)\n raise error unless no_raise\n __output \"JOB ERROR: #{error.full_message}\"\n {}\n end",
"def run\n case self[:job]\n when Proc\n self[:job].call\n else\n self[:job]\n end\n end",
"def jobs\r\n end",
"def job= (work)\n @job = work\n end",
"def job_class(item = nil)\n # noinspection RubyMismatchedArgumentType\n item and super or @job_class ||= super(self)\n end",
"def job_spec_name\n self.job_spec.name\n end",
"def work\n if job = lock_job\n QC.log_yield(:action => \"work_job\", :job => job[:id]) do\n begin\n call(job)\n log(:action => \"finished_work\", :job => job[:id])\n rescue Object => e\n log(:action => \"failed_work\", :job => job[:id], :error => e.inspect)\n handle_failure(job, e)\n ensure\n @queue.delete(job[:id])\n log(:action => \"delete_job\", :job => job[:id])\n end\n end\n end\n end",
"def rocket_job_class\n @rocket_job_class\n end",
"def work_one_job(conn = connection)\n begin\n job = reserve_job(conn)\n rescue Beaneater::TimedOutError => e\n return\n end\n\n self.log_job_begin(job.name, job.args)\n job.process\n self.log_job_end(job.name)\n\n rescue Backburner::Job::JobFormatInvalid => e\n self.log_error self.exception_message(e)\n rescue => e # Error occurred processing job\n self.log_error self.exception_message(e) unless e.is_a?(Backburner::Job::RetryJob)\n\n unless job\n self.log_error \"Error occurred before we were able to assign a job. Giving up without retrying!\"\n return\n end\n\n # NB: There's a slight chance here that the connection to beanstalkd has\n # gone down between the time we reserved / processed the job and here.\n num_retries = job.stats.releases\n max_job_retries = resolve_max_job_retries(job.job_class)\n retry_status = \"failed: attempt #{num_retries+1} of #{max_job_retries+1}\"\n if num_retries < max_job_retries # retry again\n retry_delay = resolve_retry_delay(job.job_class)\n delay = resolve_retry_delay_proc(job.job_class).call(retry_delay, num_retries) rescue retry_delay\n job.retry(num_retries + 1, delay)\n self.log_job_end(job.name, \"#{retry_status}, retrying in #{delay}s\") if job_started_at\n else # retries failed, bury\n job.bury\n self.log_job_end(job.name, \"#{retry_status}, burying\") if job_started_at\n end\n\n handle_error(e, job.name, job.args, job)\n end",
"def batch\n job && job.batch\n end",
"def job_class(item = nil)\n item and super or @job_class ||= super(self)\n end",
"def pull_job(job_name = nil)\r\n lock\r\n job,status = internal_find_job(job_name)\r\n if job && status == ST_QUEUED\r\n # Move to run, notice use of job.name rather than job_name\r\n # .. if we are pulling a new job, it could be nil\r\n FileUtils.mv(@dir + '/que/' + job.name, @dir + '/run/' + job.name)\r\n job.set_as_active\r\n elsif job\r\n # We cannot pull a job that isn't queued\r\n log(\"cannot pull job that isn't queued: \" + job_name)\r\n job = nil\r\n end\r\n unlock\r\n return job\r\n end",
"def invoke_job\r\n\r\n # BgWorker.log(\"Worker: invoke job\")\r\n\r\n fork {\r\n\r\n # BgWorker.log(\"Worker: fork: system 'cd #{Rails.root}; rake #{self.name}'\")\r\n\r\n `cd #{Rails.root}; rake #{self.name}`\r\n\r\n # BgWorker.log(\"Worker: fork: closing job #{res ? 'OK' : 'KO'}, return code: #{$?}\")\r\n\r\n self.close_job($?)\r\n }\r\nend",
"def find_job(job_id)\n response = HTTParty.get(\"#{@host}/api/jobs/#{job_id}\")\n\n return response['job']\n end",
"def queue\n Future.new(super)\n end",
"def dry_run\n Job::run self\n end",
"def get_job (job_id)\n\n @cron_jobs[job_id] || @non_cron_jobs[job_id]\n end",
"def queue\n pending_duplicate_job || Delayed::Job.enqueue(self)\n end",
"def persistent_job\n job_id = Thread.current[:persistent_job_id]\n job_id ? BdrbJobQueue.find_by_id(job_id) : nil\n end",
"def delete_job\n raise NotImplementedError\n end",
"def prepare_job \n if @job_condition\n @job = Job.new\n parse_values(\"JOB\", @job)\n @job = update_job @job\n @jobs << @job\n end\n end",
"def job_type_name\r\n job_type.job_name rescue nil\r\n end",
"def to_task; self end",
"def work_once()\n json = @redis.rpop @queue\n raise @@EOQ unless json\n hash = JSON.parse(json)\n # Next bit is sort of ugly, \n klass = Object.const_get(hash[\"class\"])\n raise ArgumentError.new(\"Improper Class\") unless klass < QueuED::QueueAble\n obj = klass.new\n obj.from_hash!(hash)\n obj.do_task\n obj.queue_down(redis:@redis, queue:@queue)\n return obj\n end",
"def jobs_without_template\n []\n end",
"def new\n @job = Job.new\n end",
"def be_worker\n before_work\n super\n end",
"def build_promise(depending_job, param_key)\n Promise.new.tap do |promise|\n promise.assign_attributes(job_id: job.id, hash_field: param_key, result_key: result_key)\n depending_job.promise_ids << promise.id\n end\n end",
"def job_items\n job_arguments(1)\n end",
"def job_klass\n VoyagerUpdateJob\n end",
"def new\n @job = Job.new\n end",
"def application_job_class\n @application_job_class ||= self.class.ancestors.find { |ancestor|\n ancestor.name =~ /ApplicationJob/\n }\n end",
"def new_job(job, username, password)\n puts \"Requesting quote for job:\"\n puts JSON.pretty_generate(job)\n puts \"\"\n res = post_json('jobs.json', job, username, password)\n if res['error'] || res['status'] == 'error'\n puts \"Job rejected (error #{res['status']}): #{res['error'] || res['reason']}\"\n return\n end\n\n puts \"Gnip's job desc:\"\n puts summarise_job(res)\nend",
"def jobs\n @jobs || {}\n end",
"def job\n fetch('games.final_fantasy_xiv.jobs')\n end",
"def active_job_message\n {\n 'class' => 'ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper',\n 'wrapped' => @klass,\n 'queue' => @queue_name_with_prefix,\n 'description' => @description,\n 'args' => [{\n 'job_class' => @klass,\n 'job_id' => SecureRandom.uuid,\n 'queue_name' => @queue_name_with_prefix,\n 'arguments' => @args\n }]\n }\n end",
"def getNextJob()\n\t\t\t\tjob = nil\n\t\t\t\t\n\t\t\t\tThread.exclusive {\n\t\t\t\t\ti = @jobs.index { |j| j.canStart() }\n\t\t\t\t\tjob = @jobs.delete_at( i ) if ( i != nil )\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\treturn job\n\t\t\tend",
"def enqueue!\n return nil unless persisted?\n \"#{job_type.camelize}Job\".constantize.perform_later(self)\n end",
"def job_key; Thread.current[:job_key]; end",
"def getCurrentJobs\n getJobs('0/')\n end",
"def clone\n @job = Job.find(params[:id]).cloned_job\n if current_user and default_queue = current_user.preferences.find_by_kind('default_queue') then @job.jobs_queue_id = default_queue.value end\n \n respond_to do |format|\n if @job.valid?\n # flash[:notice] = 'Job was successfully cloned.'\n format.html { render :action => \"new\" }\n format.xml { \n if @job.save!\n @job.submit() \n head :ok\n else\n render :xml => @job.errors, :status => :unprocessable_entity\n end \n }\n else\n format.html { render :action => \"show\" }\n format.xml { render :xml => @job.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def run_backup_job(wi)\n # In case of large # of queued jobs for the same source, we check for the latest \n # and skip processing if too close in time to the last one\n if recent_job? wi\n raise BackupSourceExecutionFlood.new(\"Backup source backup job run too recently to run now\")\n end\n if DISABLE_LONG_DATASETS && (get_dataset(wi) != EternosBackup::SiteData.defaultDataSet)\n raise BackupSourceExecutionFlood.new(\"Disabling long running data backups\")\n end\n\n # Fetch or create existing BackupSourceJob record\n job = nil\n BackupSourceJob.transaction do \n if job = BackupSourceJob.find(:first, :conditions => {:backup_job_id => wi.job_id, :backup_source_id => wi.source_id, :backup_data_set_id => get_dataset(wi)})\n # Found existing job, clear errors\n job.status = BackupStatus::Running\n job.messages = job.error_messages = nil\n job.percent_complete = 0\n else\n # BackupSourceJob.create generates fucked up error: \"unknown attribute: backup_source_id\" ???!!\n # Try using new/save as workaround\n job = BackupSourceJob.new\n job.backup_job_id = wi.job_id\n job.backup_source_id = wi.source_id\n job.backup_data_set_id = get_dataset(wi)\n job.status = BackupStatus::Running\n end\n job.save\n end\n\n unless job && job.backup_source\n raise BackupSourceNotFoundException.new(\"Unable to find backup source #{wi.source_id} for backup job #{wi.job_id}\")\n end\n # Save job's start time to cache\n BackupWorker.cache.set job_start_key(wi), job.created_at.to_s\n \n job.status = BackupStatus::Success # successful unless an error occurs later\n \n yield job\n\n job_finished(job)\n end",
"def job_placeholder_of(task, cycle)\n if task.kind_of?(Roby::Interface::Job)\n _, snapshot, * = history[cycle]\n task\n .enum_parent_objects(snapshot.relations[Roby::TaskStructure::PlannedBy])\n .first\n end\n end",
"def worker_factory(&block)\n end",
"def get_job job_id, location: nil\n # The get operation is considered idempotent\n execute backoff: true do\n service.get_job @project, job_id, location: location\n end\n end"
] | [
"0.6795402",
"0.67704654",
"0.6742676",
"0.6729724",
"0.6729724",
"0.6681992",
"0.6655046",
"0.6626932",
"0.642745",
"0.6382254",
"0.63598585",
"0.63112384",
"0.63021314",
"0.6276726",
"0.62735003",
"0.6265982",
"0.62589955",
"0.62364346",
"0.6171337",
"0.6170372",
"0.6166588",
"0.6123663",
"0.61236566",
"0.6095571",
"0.6095571",
"0.6058283",
"0.6035042",
"0.6025192",
"0.6020349",
"0.59924656",
"0.5956802",
"0.5942837",
"0.59417707",
"0.58996356",
"0.5889621",
"0.5886434",
"0.588018",
"0.58734405",
"0.58246547",
"0.5812445",
"0.57851225",
"0.5782215",
"0.5766176",
"0.5765864",
"0.57564896",
"0.5751962",
"0.5739756",
"0.5738678",
"0.5733529",
"0.57333815",
"0.57252073",
"0.570838",
"0.57021075",
"0.56784517",
"0.5668351",
"0.56579506",
"0.56411976",
"0.56311226",
"0.56293565",
"0.5615358",
"0.55951875",
"0.5591573",
"0.5589669",
"0.5580009",
"0.5574126",
"0.5557848",
"0.5553408",
"0.5551553",
"0.551209",
"0.5502037",
"0.5498497",
"0.54853463",
"0.5479175",
"0.547272",
"0.5470898",
"0.54633206",
"0.54589236",
"0.54559207",
"0.5434769",
"0.5424811",
"0.5421503",
"0.5412805",
"0.54126465",
"0.5403007",
"0.5402542",
"0.5401653",
"0.53974307",
"0.5383424",
"0.53808427",
"0.53785187",
"0.5372445",
"0.53708297",
"0.53610384",
"0.5351051",
"0.53467375",
"0.534043",
"0.5339428",
"0.53320765",
"0.53300637",
"0.5329423",
"0.5326736"
] | 0.0 | -1 |
Iterates over system_config.gaudi_modules and requires all tasks | def require_tasks system_config
system_config.gaudi_modules.each do |gm|
mass_require(Rake::FileList["#{system_config.base}/tools/build/lib/#{gm}/tasks/*.rb"])
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def require_modules(module_list, base_directory)\n module_list.each do |gm|\n mass_require(Rake::FileList[\"#{base_directory}/tools/build/lib/#{gm}/helpers/*.rb\"])\n mass_require(Rake::FileList[\"#{base_directory}/tools/build/lib/#{gm}/rules/*.rb\"])\n end\n end",
"def gaudi_modules\n @config[\"gaudi_modules\"] ||= []\n return @config[\"gaudi_modules\"]\n end",
"def load_gaudi_modules(main_config_file)\n lines = File.readlines(main_config_file)\n relevant_lines = lines.select do |ln|\n /base=/ =~ ln || /gaudi_modules=/ =~ ln\n end\n cfg = parse_content(relevant_lines, File.dirname(main_config_file), *keys)\n require_modules(cfg.fetch(\"gaudi_modules\", []), cfg[\"base\"])\n end",
"def EnableRequiredModules\n # Lazy init\n if @modules_to_enable_with_AC_on == nil\n feature = ProductFeatures.GetFeature(\n \"globals\",\n \"autoconfiguration_enabled_modules\"\n )\n\n if feature == \"\" || feature == nil || feature == []\n @modules_to_enable_with_AC_on = []\n else\n @modules_to_enable_with_AC_on = Convert.convert(\n feature,\n :from => \"any\",\n :to => \"list <string>\"\n )\n end\n\n Builtins.y2milestone(\n \"Steps to enable with AC in use: %1\",\n @modules_to_enable_with_AC_on\n )\n end\n\n if @modules_to_enable_with_AC_on != nil\n Builtins.foreach(@modules_to_enable_with_AC_on) do |one_module|\n ProductControl.EnableModule(one_module)\n end\n end\n\n nil\n end",
"def runtime_specific_gems\n []\n end",
"def requires\n require_items.collect(&:package)\n end",
"def configure_tasks\n super\n all_sources = []\n @toolchains.each do |toolchain, sources|\n all_sources |= sources\n toolchain.output_folder = @output_folder\n toolchain.project_folder = @project_folder\n toolchain.output_decorator = \"-#{@configuration_name}\"\n CompiledConfiguration.add_framework_dependencies_to_toolchain(toolchain, @dependencies)\n end\n # Give the default toolchain an opportunity to scan all source files for\n # any special needs. For example, a toolchain might look for .cpp files\n # to determine that it should link a project with the \"g++\" vs \"gcc\".\n @default_toolchain.scan_sources(all_sources)\n end",
"def custom_install_tasks_for(a=nil)\n []\n end",
"def custom_install_tasks_for(a=nil)\n []\n end",
"def load_tasks\n return if @loaded\n\n # By convention, the '*_helper.rb' files are helpers and need to be loaded first. Load\n # them into the Thor::Sandbox namespace\n Dir.glob( File.join(File.dirname(__FILE__), '**', '*.rb') ).each do |task|\n if task.match(/_helper\\.rb$/)\n #logger.debug \"load_thorfile helper: #{task}\"\n ::Thor::Util.load_thorfile task\n end\n end\n\n # Now load the thor files\n Dir.glob( File.join(File.dirname(__FILE__), '**', '*.rb') ).each do |task|\n unless task.match(/_helper\\.rb$/)\n #logger.debug \"load_thorfile: #{task}\"\n ::Thor::Util.load_thorfile task\n end\n end\n\n # load user tasks\n if user_tasks_folder\n Dir.glob( File.join([user_tasks_folder, '**', '*.{rb,thor}']) ).each { |task| ::Thor::Util.load_thorfile task if task.match(/_helper\\.rb$/) }\n Dir.glob( File.join([user_tasks_folder, '**', '*.{rb,thor}']) ).each { |task| ::Thor::Util.load_thorfile task unless task.match(/_helper\\.rb$/) }\n end\n\n @loaded = true\n end",
"def force_load_set\n\t\teach_module { |name, mod|\n\t\t}\n\tend",
"def each_module(opts = {}, &block)\n demand_load_modules\n\n self.mod_sorted = self.sort\n\n each_module_list(mod_sorted, opts, &block)\n end",
"def load_modules\n @log.info \"Loading modules...\"\n\n modules.each do |mod|\n require mod[:file]\n klass = eval(mod[:class_name])\n\n self.on_command klass.main_command do |command, from|\n self.send_message from, klass.exec_command(command)\n end\n end\n end",
"def load\n super()\n load_rspec_tasks\n load_generic_deploy_pack_tasks\n load_this_deploy_packs_tasks\n end",
"def load_tasks\n end",
"def available_tasks\n gather_tasks = Proc.new do |tasks|\n Dir[File.join(Rooster::TASKS_DIR, \"*.rb\")].each do |filename|\n tasks << task_from_filename(filename) || next\n end\n end\n \n @@available_tasks ||= if Rails::VERSION::MAJOR == 2\n returning([]) {|tasks| gather_tasks.call(tasks) }\n elsif Rails::VERSION::MAJOR == 3\n [].tap {|tasks| gather_tasks.call(tasks)}\n else\n raise raise RuntimeError,\n \"Unknown Rails major version: '#{Rails::VERSION::MAJOR}'\"\n end\n end",
"def configure_tasks\n end",
"def global_modules\n node['rsyncd']['globals'].each_with_object({}) do |(key, value), hash|\n hash[attribute_to_directive(key)] = value unless value.nil?\n end\nend",
"def require_gems; end",
"def bundler_dependencies_for(bundler_runtime, *groups); end",
"def load_task_libraries\n\t\ttaskdir = Pathname( __FILE__.delete_suffix('.rb') )\n\t\ttasklibs = Rake::FileList[ taskdir + '*.rb' ].pathmap( '%-2d/%n' )\n\n\t\tself.trace( \"Loading task libs: %p\" % [ tasklibs ] )\n\t\ttasklibs.each do |lib|\n\t\t\trequire( lib )\n\t\tend\n\n\t\tself.class.constants.\n\t\t\tmap {|c| self.class.const_get(c) }.\n\t\t\tselect {|c| c.respond_to?(:instance_methods) }.\n\t\t\tselect {|c| c.instance_methods(false).include?(:define_tasks) }.\n\t\t\teach do |mod|\n\t\t\t\tself.trace \"Loading tasks from %p\" % [ mod ]\n\t\t\t\textend( mod )\n\t\t\tend\n\n\t\tself.setup( self.name, **self.options )\n\tend",
"def load_sakura_modules!(enable_debug=false)\n debug_on(\"load_sakura_modules() called with debug enabled!\") if enable_debug\n str = \"Reloaded Riclibs v#{$RICLIB_VERSION} -- per la #{$RICLIB['nreloaded']} a volta\"\n modules_to_be_included = $RIC_LIB_MODULES + Sakuric.get_auto_files(\"classes/\") \n modules_to_be_included.each{ |cls| \n deb \"Loading class: '#{cls}'..\", :color => 'yellow'\n was_necessary = require \"#{$SAKURADIR}/lib/#{cls}.rb\"\n deb(\"Loading: #{cls} (necessary: #{was_necessary})\") rescue puts(\"Error: #{$!}\")\n }\n end",
"def module_config\r\n []\r\n end",
"def install\n AdminModule.configuration.credentials.keys.each do |e|\n valid_actions.each do |action|\n AdminModule::Rake::PpmTasks.new(\"am:#{e}:ppm:#{action}\", \"#{action} #{e} ppms\") do |t|\n t.env = e\n t.action = action\n end\n end\n end\n end",
"def modules(&block)\r\n if block_given?\r\n Ragweed::Wrap32::list_modules(@pid, &block)\r\n else\r\n ret = []\r\n Ragweed::Wrap32::list_modules(@pid) {|x| ret << x}\r\n return ret\r\n end\r\n end",
"def build_remote_dependencies\n modules_json_path = \"#{@mod.cache_dir}/.terraform/modules/modules.json\"\n return unless File.exist?(modules_json_path)\n\n initialized_modules = JSON.load(IO.read(modules_json_path))\n # For example of structure see spec/fixtures/initialized/modules.json\n initialized_modules[\"Modules\"].each do |meta|\n build_remote_mod(meta)\n end\n end",
"def define_tasks\r\n define_repeat_task\r\n define_clobber_task\r\n define_build_task\r\n end",
"def initialize_modules\n # NOTE: this gets called after all the module initializers complete\n end",
"def load_dependencies\r\n @local_gems.each do |gem_info|\r\n gem_file_name = gem_info.gem_file\r\n gem_name = installed_as_name_for( short_form_of_gem_name( gem_file_name ) )\r\n @required_gem_names.delete gem_file_name\r\n end\r\n @required_gem_paths.each do |gem_path|\r\n gem_short_name = short_form_of_gem_name gem_path\r\n if @required_gem_names.include? gem_short_name\r\n puts \"installing #{gem_path}\"\r\n installer = @force_require ? PreloadingInstaller.new( gem_path, @local_gems ) : Installer.new( gem_path )\r\n installer.install\r\n end\r\n end\r\n end",
"def install_tasks\n load 'falkorlib/tasks/git.rake'\n load 'falkorlib/tasks/gitflow.rake'\n end",
"def define_tasks\r\n define_clobber_task\r\n define_build_task\r\n end",
"def force_load_set\n each_module { |name, mod| }\n end",
"def create_tasks\n Application.features[self].each{ |f|\n extend Rake::DSL\n taskname = \"#{f.to_s.split('::').last}\"\n desc \"Feature\"\n task taskname => [\"#{taskname}:install\"] do\n end\n namespace taskname do\n desc \"install #{taskname}\"\n task :install do\n puts \"----> installing #{taskname}\"\n puts \"#{self} | #{f}\"\n Application.install[f.name].each{ |c|\n puts \"#{c}\"\n }\n end\n end \n } if Application.features[self]\n end",
"def each_module(opts = {}, &block)\n\t\tdemand_load_modules\n\n\t\tself.mod_sorted = self.sort if (mod_sorted == nil)\n\t\t\n\t\teach_module_list(mod_sorted, opts, &block)\n\tend",
"def include_required_submodules!\n class_eval do\n @sorcery_config.submodules = ::Sorcery::Controller::Config.submodules\n @sorcery_config.submodules.each do |mod|\n # TODO: Is there a cleaner way to handle missing submodules?\n # rubocop:disable Lint/HandleExceptions\n begin\n include Submodules.const_get(mod.to_s.split('_').map(&:capitalize).join)\n rescue NameError\n # don't stop on a missing submodule. Needed because some submodules are only defined\n # in the controller side.\n end\n # rubocop:enable Lint/HandleExceptions\n end\n end\n end",
"def tasks_for_all_configurations\n @configurations.keys.collect{ |name| \"#{@project_name}:#{name}\"}\n end",
"def upgrade_tasks\n if ENV['UPGRADE'].present?\n ENV['UPGRADE'].split(',')\n else\n all_upgrade_tasks\n end\n end",
"def load(needs = {})\n needs = needs.merge({\"zergrush\" => INCLUDE})\n \n Gem::Specification.each { |gem|\n # don't load gems more than once\n next if @gems.has_key? gem.name \n check = needs.dup\n\n # rolls through the depends and inverts anything it finds\n gem.dependencies.each do |dep|\n # this will fail if a gem is depended more than once\n if check.has_key? dep.name\n check[dep.name] = !check[dep.name]\n end\n end\n \n # now since excluded gems start as true, inverting them\n # makes them false so we'll skip this gem if any excludes are found\n if (check.select {|name,test| !test}).length == 0\n # looks like no needs were set to false, so it's good\n if gem.metadata[\"zergrushplugin\"] != nil\n require File.join(gem.gem_dir, \"lib\", gem.name, \"init.rb\")\n @gems[gem.name] = gem.gem_dir\n end\n end\n }\n \n return nil\n end",
"def install_modules_from_gallery\n return if config[:install_modules].nil?\n\n Array(config[:install_modules]).map do |powershell_module|\n if powershell_module.is_a? Hash\n # Sanitize variable name so that $powershell-yaml becomes $powershell_yaml\n module_name = powershell_module[:Name].gsub(/[\\W]/, \"_\")\n # so we can splat that variable to install module\n <<-PS1\n $#{module_name} = #{ps_hash(powershell_module)}\n Write-Host -NoNewline 'Installing #{module_name}'\n Install-Module @#{module_name}\n Write-host '... done.'\n PS1\n else\n <<-PS1\n Write-host -NoNewline 'Installing #{powershell_module} ...'\n Install-Module -Name '#{powershell_module}'\n Write-host '... done.'\n PS1\n end\n end\n end",
"def tasks\n config[:tasks]\n end",
"def build(chroot,dirs,task,add_to_autoreq=true,snapshot_release=false)\n validate_in_mock_group?\n _verbose = ENV.fetch('SIMP_PKG_verbose','no') == 'yes'\n\n # Default package metadata for reference\n default_metadata = YAML.load(File.read(\"#{@src_dir}/build/package_metadata_defaults.yaml\"))\n\n metadata = Parallel.map(\n # Allow for shell globs\n Array(dirs),\n :in_processes => get_cpu_limit,\n :progress => task.name\n ) do |dir|\n result = []\n\n fail(\"Could not find directory #{dir}\") unless Dir.exist?(dir)\n\n Dir.chdir(dir) do\n built_rpm = false\n unique_build = (get_cpu_limit != 1).to_s\n\n if _verbose\n $stderr.puts(\"Running 'rake pkg:rpm' on #{File.basename(dir)}\")\n end\n\n # We're building a module, override anything down there\n if File.exist?('metadata.json')\n unique_namespace = (0...24).map{ (65 + rand(26)).chr }.join.downcase\n\n Simp::Rake::Pkg.new(Dir.pwd, nil, unique_namespace, @simp_version)\n\n Rake::Task[\"#{unique_namespace}:pkg:rpm\"].invoke(chroot, unique_build, snapshot_release)\n\n built_rpm = true\n\n # We're building one of the extra assets and should honor its Rakefile\n elsif File.exist?('Rakefile')\n\n rake_flags = Rake.application.options.trace ? '--trace' : ''\n\n cmd = %{SIMP_BUILD_version=#{@simp_version} rake pkg:rpm[#{chroot},#{unique_build},#{snapshot_release}] #{rake_flags} 2>&1}\n\n build_success = true\n begin\n ::Bundler.with_clean_env do\n %x{#{cmd}}\n build_success = $?.success?\n end\n\n built_rpm = true\n rescue\n build_success = false\n end\n\n unless build_success\n if _verbose\n $stderr.puts(\"First 'rake pkg:rpm' attempt failed, running bundle and trying again.\")\n end\n\n ::Bundler.with_clean_env do\n %x{bundle install --with development}\n %x{#{cmd}}\n end\n end\n else\n puts \"Warning: '#{dir}' could not be built via Rake\"\n end\n\n if built_rpm\n tarballs = Dir.glob('dist/*.tar.gz')\n srpms = Dir.glob('dist/*.src.rpm')\n rpms = (Dir.glob('dist/*.rpm') - srpms)\n\n # Not all items generate tarballs\n tarballs.each do |pkg|\n if (File.stat(pkg).size == 0)\n raise(\"Empty Tarball '#{pkg}' generated for #{dir}\")\n end\n end\n raise(\"No SRPMs generated for #{dir}\") if srpms.empty?\n raise(\"No RPMs generated for #{dir}\") if rpms.empty?\n\n last_build = {\n 'git_hash' => %x{git show-ref --head HEAD}.chomp,\n 'rpms' => {}\n }\n\n # Glob all generated rpms, and add their metadata to a result array.\n rpms.each do |rpm|\n # get_info from each generated rpm, not the spec file, so macros in the\n # metadata have already been resolved in the mock chroot.\n metadata = Simp::RPM.get_info(rpm)\n\n if File.exist?('build/package_metadata.yaml')\n metadata.merge!(YAML.load_file('build/package_metadata.yaml'))\n end\n\n rpm_stat = File.stat(rpm)\n\n last_build['rpms'][rpm] = {\n 'metadata' => metadata,\n 'size' => rpm_stat.size\n }\n\n result << metadata\n end\n\n File.open('dist/.last_build_metadata', 'w') do |fh|\n fh.puts(last_build.to_yaml)\n end\n end\n\n if _verbose\n $stderr.puts(\"Finshed 'rake pkg:rpm' on #{File.basename(dir)}\")\n end\n end\n\n result\n end\n\n metadata.each do |mod|\n # Each module could generate multiple rpms, each with its own metadata.\n # Iterate over them to add all built rpms to autorequires.\n mod.each do |module_pkginfo|\n next unless (module_pkginfo && module_pkginfo.is_a?(Hash))\n\n # Set up the autorequires\n if add_to_autoreq\n # Register the package with the autorequires\n mode = 'r+'\n mode = 'w+' unless File.exist?(\"#{@src_dir}/build/autorequires\")\n autoreq_fh = File.open(\"#{@src_dir}/build/autorequires\",mode)\n\n begin\n # Reads the autorequires file, then empties it\n autorequires = []\n autorequires += autoreq_fh.read.split(\"\\n\")\n autoreq_fh.rewind\n autoreq_fh.truncate(0)\n\n # The SIMP Rakefile expects the autorequires to be in this format.\n autorequires << \"#{module_pkginfo[:name]} #{module_pkginfo[:version]} #{module_pkginfo[:release]}\"\n autoreq_fh.puts(autorequires.sort.uniq.join(\"\\n\"))\n ensure\n autoreq_fh.flush\n autoreq_fh.close\n end\n end\n end\n end\n end",
"def list_available_build_tasks\n cd 'cookbooks/example'\n unset_bundler_env_vars\n run_simple 'bundle exec rake -T'\n end",
"def librarian_prepare_modules (module_path)\n rm_rf module_path\n mkdir_p module_path\n #command = ['librarian-puppet', 'install', '--clean']\n command = ['librarian-puppet', 'install', '--no-use-v1-api']\n command << '--verbose' unless ENV['LIBRARIAN_VERBOSE'].nil?\n command.concat(['--path', module_path])\n sh *command\nend",
"def included_modules() end",
"def generate_require_files_for_individual_gems\n puts 'Generating require files for individual gems'\n generate_require_files_for_gem(@mgmt_sdks_location)\n generate_require_files_for_gem(@data_sdks_location)\n end",
"def load_tasks\n RakeLoader.new.load_tasks\n end",
"def required_gem_list\n Mack::Utils::GemManager.instance.required_gem_list\n end",
"def custom_configure_tasks_for(a=nil)\n []\n end",
"def kernel_modules\n cmd_exec('cat /proc/modules').to_s.scan(/^[^ ]+/)\n rescue\n raise 'Could not determine kernel modules'\n end",
"def custom_configure_tasks_for(a=nil)\n []\n end",
"def modules; end",
"def modules; end",
"def modules; end",
"def define_tasks\n # Run the command on the local system\n def run(cmd)\n Kernel.system(cmd.runnable)\n end\n # Basic setup action\n def setup_application\n @options ||= PoolParty.options(ARGV.dup)\n end\n \n # Require the poolparty specific tasks\n compiled_rakefile\n \n desc \"Reload the static variables\"\n task :reload do\n reload!\n end\n true\n end",
"def checkDependencyTasksForPIC()\n @dependencies.each do |dep|\n if dep.kind_of?(CompileTask) then\n raise \"[makr] DynamicLibTask wants configName in dependency CompileTask #{dep.name}!\" if not dep.config\n if (not (dep.config[\"compiler.cFlags\"].include?(\"-fPIC\") or dep.config[\"compiler.cFlags\"].include?(\"-fpic\"))) then\n raise( \"[makr] DynamicLibTask wants -fPIC or -fpic in config[\\\"compiler.cFlags\\\"] of dependency CompileTasks!\" +\n \" error occured in CompileTask \" + dep.name)\n end\n end\n end\n end",
"def pre_execute_checks\n validate_terraform_installed\n ensure_output_directory\n Dir.chdir(@opts.get(:input_dir)) do\n puts '=> Fetching modules...'\n tf_get\n end\n end",
"def load_minimal_gems\r\n end",
"def requested_modules(module_names)\n if module_names.empty?\n module_names = Dir[\"*.fun\"].each{ |mod| mod.chomp! \".fun\" }\n end\n module_names\n end",
"def requires(include_pending=false)\n features = component_instances.map {|ci| ci.cartridge_name} #get_feature(ci.cartridge_name, ci.component_name)}\n\n if include_pending\n self.pending_op_groups.each do |op_group|\n case op_group.op_type\n when :add_features\n features += op_group[:args][\"features\"]\n when :remove_features\n features -= op_group[:args][\"features\"]\n end\n end\n end\n\n features || []\n end",
"def demand_load_modules\n\t\t# Pre-scan the module list for any symbolic modules\n\t\tself.each_pair { |name, mod|\n\t\t\tif (mod == SymbolicModule)\n\t\t\t\tself.postpone_recalc = true\n\n\t\t\t\tmod = create(name)\n\n\t\t\t\tnext if (mod.nil?)\n\t\t\tend\n\t\t}\n\n\t\t# If we found any symbolic modules, then recalculate.\n\t\tif (self.postpone_recalc)\n\t\t\tself.postpone_recalc = false\n\n\t\t\trecalculate\n\t\tend\n\tend",
"def task_list\n return @task_list if @task_list\n @task_list = []\n spec_file_names.each do |file_name_spec|\n next if spec_is_disabled? file_name_spec\n next if skip_globals? file_name_spec\n next unless spec_included? file_name_spec\n get_spec_runs(file_name_spec).each do |run|\n next unless run[:hiera] and run[:facts]\n next unless facts_included? run[:facts]\n next unless hiera_included? run[:hiera]\n task = Noop::Task.new file_name_spec, run[:hiera], run[:facts]\n task.parallel = true if parallel_run?\n @task_list << task\n end\n end\n @task_list\n end",
"def exec_setup\n exec_task_traverse 'setup'\n end",
"def generate_targets\n has_metaname = has_version?\n\n %w[clean update fetch configure export build install].each do |target|\n target_name = \"#{@name}_#{target}\".to_sym\n target_metaname = \"#{@metaname}_#{target}\".to_sym if has_metaname\n func = pkg_default_target_func(@name.to_sym, target)\n\n task = Rake::Task.define_task(target_name, &func)\n metatask = Rake::Task.define_task(target_metaname, &func) if has_metaname\n\n # Add per-task dependency\n case target\n when /install/i\n task.enhance([\"#{@name}_build\".to_sym])\n metatask.enhance([\"#{@metaname}_build\".to_sym]) if has_metaname\n when /build/i\n task.enhance([\"#{@name}_export\".to_sym])\n metatask.enhance([\"#{@metaname}_export\".to_sym]) if has_metaname\n\n # Generate package export dependencies\n @build_deps.each do |dep|\n task.enhance([\"#{dep}_export\".to_sym])\n metatask.enhance([\"#{dep}_export\".to_sym]) if has_metaname\n end\n\n # Generate package build dependencies\n @clean_deps.each do |dep|\n task.enhance([\"#{dep}_install\".to_sym])\n metatask.enhance([\"#{dep}_install\".to_sym]) if has_metaname\n end\n when /export/i\n task.enhance([\"#{@name}_configure\".to_sym])\n metatask.enhance([\"#{@metaname}_configure\".to_sym]) if has_metaname\n when /configure/i\n task.enhance([\"#{@name}_fetch\".to_sym])\n metatask.enhance([\"#{@metaname}_fetch\".to_sym]) if has_metaname\n when /clean/i\n # Generate package clean dependencies\n @clean_deps.each do |dep|\n task.enhance([\"#{dep}_clean\".to_sym])\n metatask.enhance([\"#{dep}_clean\".to_sym]) if has_metaname\n end\n end\n\n update_global_task(target, target_name)\n end\n\n # Create the default package task named after the package name\n task = Rake::Task.define_task(\"#{@name}\" => [\"#{@name}_install\".to_sym])\n metatask = Rake::Task.define_task(\"#{@metaname}\" => [\"#{@metaname}_install\".to_sym]) if has_metaname\n end",
"def install_python_system_packages\n where_am_i\n\n shell_cmd(\"#{pip_versioned} install --no-compile virtualenv ansible-runner\")\n end",
"def define_compiler_tasks\n require \"rake/extensiontask\"\n\n @extensions.each do |name|\n clean_globs << \"lib/#{name}/*.{so,bundle,dll}\"\n\n Rake::ExtensionTask.new name, spec do |ext|\n ext.lib_dir = File.join(*[\"lib\", name.to_s, ENV[\"FAT_DIR\"]].compact)\n end\n end\n\n compile_tasks.each do |t|\n task t => :compile\n end\n rescue LoadError\n warn \"Couldn't load rake-compiler. Skipping. Run `rake newb` to fix.\"\n end",
"def configure_tasks\n super\n all_object_files = []\n all_object_folders = []\n @toolchains.each do |toolchain, sources|\n toolchain.add_include_paths(@api_headers+@configuration_headers)\n object_files, object_folders = toolchain.create_compile_tasks(sources)\n all_object_files |= object_files\n all_object_folders |= object_folders\n end\n\n project_filename = @parent_project.project_name.to_s.gsub(':','-')\n library_files, library_folders = @default_toolchain.create_static_library_tasks(all_object_files, project_filename)\n dependencies = @dependencies+all_object_folders+library_folders+library_files\n\n desc \"Build library '#{@parent_project.project_name}' with configuration '#{@configuration_name}'\"\n new_task = static_library_task @configuration_name => dependencies do |t|\n @post_build.call if @post_build.respond_to? :call\n puts \"built library #{t.name}.\"\n @tests.each do |test|\n if Rake::Task.task_defined? test\n Rake::Task[test].invoke\n else\n $stderr.puts \"warning: Skipping unknown test '#{test}'\"\n end\n end\n end\n new_task.api_headers = @api_headers\n new_task.configuration_headers = @configuration_headers\n new_task.library_files = library_files\n end",
"def select_all_command_modules\n @body = command_modules2json(BeEF::Modules.get_enabled.keys)\n end",
"def define_tasks\n @defines.each { |sym| send( sym ) }\n end",
"def load_required\n Dir[\"#{folder}/**/*.rb\"].each{|m|load m}\n end",
"def define_tasks!\n\n define_test_tasks! if has_tests?\n define_rspec_tasks! if has_specs?\n\n namespace(@task_namespace) do\n desc \"Updates the filelist in the gemspec file\"\n task(:manifest) { manifest_task }\n\n desc \"Builds the .gem package\"\n task(:build => :manifest) { build_task }\n\n desc \"Sets the version of the gem in the gemspec\"\n task(:set_version => [:check_version, :check_current_branch]) { version_task }\n task(:check_version => :fetch_origin) { check_version_task }\n\n task(:fetch_origin) { fetch_origin_task }\n task(:check_current_branch) { check_current_branch_task }\n task(:check_clean_status) { check_clean_status_task }\n task(:check_not_diverged => :fetch_origin) { check_not_diverged_task }\n\n checks = [:check_current_branch, :check_clean_status, :check_not_diverged, :check_version]\n checks.unshift('spec:basic') if has_specs?\n checks.unshift('test:basic') if has_tests?\n # checks.push << [:check_rubyforge] if gemspec.rubyforge_project\n\n desc \"Perform all checks that would occur before a release\"\n task(:release_checks => checks)\n\n release_tasks = [:release_checks, :set_version, :build, :github_release, :gemcutter_release]\n # release_tasks << [:rubyforge_release] if gemspec.rubyforge_project\n\n desc \"Release a new version of the gem using the VERSION environment variable\"\n task(:release => release_tasks) { release_task }\n \n namespace(:release) do\n desc \"Release the next version of the gem, by incrementing the last version segment by 1\"\n task(:next => [:next_version] + release_tasks) { release_task }\n\n desc \"Release the next version of the gem, using a patch increment (0.0.1)\"\n task(:patch => [:next_patch_version] + release_tasks) { release_task }\n\n desc \"Release the next version of the gem, using a minor increment (0.1.0)\"\n task(:minor => [:next_minor_version] + release_tasks) { release_task }\n\n desc \"Release the next version of the gem, using a major increment (1.0.0)\"\n task(:major => [:next_major_version] + release_tasks) { release_task }\n end\n\n # task(:check_rubyforge) { check_rubyforge_task }\n # task(:rubyforge_release) { rubyforge_release_task }\n task(:gemcutter_release) { gemcutter_release_task }\n task(:github_release => [:commit_modified_files, :tag_version]) { github_release_task }\n task(:tag_version) { tag_version_task }\n task(:commit_modified_files) { commit_modified_files_task }\n\n task(:next_version) { next_version_task }\n task(:next_patch_version) { next_version_task(:patch) }\n task(:next_minor_version) { next_version_task(:minor) }\n task(:next_major_version) { next_version_task(:major) }\n \n desc \"Updates the gem release tasks with the latest version on Github\"\n task(:update_tasks) { update_tasks_task }\n end\n end",
"def load_dummy_tasks(app_root)\n @target_extension_path = Pathname.new(app_root.to_s)\n load 'refinery/tasks/testing.rake'\n end",
"def tasks\n tasks = []\n @ProjectFileLoader.LoadedProjectFiles().each do |projectFile|\n tasks.concat(projectFile.tasks)\n end\n return tasks\n end",
"def generate_modules\n @resource_provider_types.each do |resource_provider, resource_types_obj|\n @module_require = @dir_metadata[resource_provider]['module_require']\n @spec_includes << @module_require\n @class_name = get_ruby_specific_resource_type_name(resource_provider)\n @class_names << @class_name\n if(!@individual_gem_profile)\n @default_rp_client_version = @default_versions[resource_provider]\n end\n\n resource_types_obj.each do |resource_type_version, resource_types|\n base_file_path = \"#{@dir_metadata[resource_provider]['path']}/lib/#{resource_type_version}/generated/#{@module_require}.rb\"\n require base_file_path\n\n resource_types.each do |resource_type|\n generate_operation_types(resource_provider, resource_type, resource_type_version)\n end\n\n generate_model_types(resource_provider, resource_type_version)\n @clients_ops_mapper[@management_client] = @operation_types.clone\n @operation_types = []\n @management_client = ''\n end\n\n @clients_ops_mapper.each_with_index do |(key, operation_types), index|\n operation_types.each do |operation_type|\n if(check_available_after_index(operation_type, index))\n operation_type[:operation_name_ruby] = 'DO_NOT_ADD'\n end\n end\n end\n\n file = get_module_file resource_provider\n file.write(get_renderer(ProfileTemplates.module_template))\n @model_types, @operation_types, @versions_clients_mapper = [], [], {}\n @clients_ops_mapper = {}\n @management_client = ''\n @default_rp_client_version = ''\n end\n end",
"def uppper_depends(task_name)\n task_list = []\n @tasks.each { |t|\n if not t.dependency.nil? then\n task_list.push(t) if t.dependency.include?(task_name)\n end\n }\n task_list\n end",
"def define_gemcutter_tasks\n desc \"Push gem to gemcutter.\"\n task :release_to_gemcutter => [:clean, :package, :release_sanity] do\n pkg = \"pkg/#{spec.name}-#{spec.version}\"\n gems = Dir[\"#{pkg}*.gem\"]\n\n gem_push gems\n end\n\n task :release_to => :release_to_gemcutter\n end",
"def demand_load_modules\n # Pre-scan the module list for any symbolic modules\n self.each_pair { |name, mod|\n if (mod == Msf::SymbolicModule)\n self.postpone_recalculate = true\n\n mod = create(name)\n\n next if (mod.nil?)\n end\n }\n\n # If we found any symbolic modules, then recalculate.\n if (self.postpone_recalculate)\n self.postpone_recalculate = false\n\n recalculate\n end\n end",
"def load_modules(bpath, demand = false)\n\t\tloaded = {}\n\t\trecalc = {}\n\t\tcounts = {}\n\t\tdelay = {}\n\t\tks = true\n\t\t\n\t\tdbase = Dir.new(bpath)\n\t\tdbase.entries.each do |ent|\n\t\t\tnext if ent.downcase == '.svn'\n\t\t\t\n\t\t\tpath = File.join(bpath, ent)\n\t\t\tmtype = ent.gsub(/s$/, '')\n\n\t\t\tnext if not File.directory?(path)\n\t\t\tnext if not MODULE_TYPES.include?(mtype)\n\t\t\tnext if not enabled_types[mtype]\n\n\t\t\t# Try to load modules from all the files in the supplied path\n\t\t\tRex::Find.find(path) do |file|\n\n\t\t\t\t# Skip non-ruby files\n\t\t\t\tnext if file[-3,3] != \".rb\"\n\n\t\t\t\t# Skip unit test files\n\t\t\t\tnext if (file =~ /rb\\.(ut|ts)\\.rb$/)\n\n\t\t\t\t# Skip files with a leading period\n\t\t\t\tnext if file[0,1] ==\".\"\n\n\t\t\t\tload_module_from_file(bpath, file, loaded, recalc, counts, demand)\n\t\t\tend\n\t\tend\n\n\t\t# Perform any required recalculations for the individual module types\n\t\t# that actually had load changes\n\t\trecalc.each_key { |key|\n\t\t\tmodule_sets[key].recalculate\n\t\t}\n\n\t\t# Return per-module loaded counts\n\t\treturn counts\n\tend",
"def collect_tasks\n tasks = []\n $sake_op = {}\n ARGV.each do |arg|\n if arg =~ /^(\\w+)=(.*)$/\n ENV[$1] = $2\n $sake_op[$1.to_sym] = $2\n else\n tasks << arg\n end\n end\n tasks.push(\"default\") if tasks.size == 0\n tasks\n end",
"def modules\n raise CapabilitiesExceeded\n end",
"def dependencies\n self.config.depends || []\n end",
"def requires\n []\n end",
"def setup_tasks\n namespace(:npm) do\n desc 'Build package.json from template'\n task :'package.json' do\n template = ERB.new(File.read(File.join(src, 'package.json.erb')))\n generated = template.result_with_hash(scope: SCOPE, gemspec: gemspec, contributors: contributors)\n File.write(File.join(src, 'package.json'), JSON.pretty_generate(JSON.parse(generated)))\n end\n\n desc 'Ensure the destination directory exist'\n task :dest do\n FileUtils.mkdir_p(dest)\n end\n\n desc 'Build package tarball into the pkg directory'\n task build: %i[package.json dest] do\n system(\"cd #{src} && npm pack --pack-destination #{dest}/\")\n end\n\n desc 'Build and push package to npmjs.com'\n task release: %i[build] do\n system(\"npm publish #{tarball} --access public\")\n end\n end\n end",
"def packagers_for_system\n @packagers_for_system ||= Packager.for_current_system.map { |p| p.new(self) }\n end",
"def modules_paths\n puppet_environment.full_modulepath\n end",
"def define_extension_tasks\n\t\tENV['RUBY_CC_VERSION'] ||= RUBY_VERSION[ /(\\d+\\.\\d+)/ ]\n\n\t\trequire 'rake/extensiontask'\n\t\tself.extensions.each do |extconf|\n\t\t\tRake::ExtensionTask.new( extconf.pathmap('%{ext/,}d') )\n\t\tend\n\n\t\ttask :spec => :compile\n\n\t\ttask :maint do\n\t\t\tENV['V'] = '1'\n\t\t\tENV['MAINTAINER_MODE'] = 'yes'\n\t\tend\n\tend",
"def evaluate_pre_tasks\n if using_rake? and Pkg::Config.pre_tasks\n unless Pkg::Config.pre_tasks.is_a?(Hash)\n fail \"The 'pre_tasks' key must be a Hash of depender => dependency pairs\"\n end\n Pkg::Config.pre_tasks.each do |depender, dependency|\n add_dependency(depender, dependency)\n end\n end\n end",
"def sites_to_load\n @appl_settings[:registered_config_modules]\n end",
"def find_modules\n find_engine\n find_storage\n find_pod\n end",
"def collect_module_data\n return unless collect_module_exists?\n collect_keys.each do |key|\n mod_array = collect_module[key]\n next if mod_array.blank?\n collect_module_data_for(key, mod_array)\n end\n end",
"def parse_modules!\n configuration.additional_modules.each do |additional_module|\n module_file = File.join(File.dirname(__FILE__), 'modules', additional_module.to_s, 'hooks.rb')\n if File.exist?(module_file)\n instance_eval(File.read(module_file))\n end\n end\n self\n end",
"def init_gd_module()\n # Metadata packages, such as report.rb, require this to be loaded first\n require_relative 'models/metadata.rb'\n\n # Load models from models folder\n Dir[File.dirname(__FILE__) + '/models/*.rb'].each { |file| require file }\n\n # Load collections\n Dir[File.dirname(__FILE__) + '/collections/*.rb'].each { |file| require file }\nend",
"def librarian_install_modules(directory, module_name)\n hosts.each do |host|\n sut_dir = File.join('/tmp', module_name)\n scp_to host, directory, sut_dir\n\n on host, \"cd #{sut_dir} && librarian-puppet install --clean --verbose --path #{host['distmoduledir']}\"\n\n puppet_module_install(:source => directory, :module_name => module_name)\n end\n end",
"def make_tasks\n make_clean_task\n make_wix_folder_task\n make_copy_file_tasks\n make_sourcery_wxs_file_task\n make_sourcery_wixobj_file_task\n make_product_wxs_file_task\n make_product_wixobj_file_task\n make_msi_file_task\n make_msi_task\n make_test_task\n end",
"def enable_modules(*mods)\n modified = []\n mods = [mods].flatten\n mods.each do |mod|\n self.mod_extensions.each do |extension|\n source = \"#{self.mods_available}/#{mod}.#{extension}\"\n target = \"#{self.mods_enabled}/#{mod}.#{extension}\"\n if File.exist?(source) && interpreter.ln_s(source, target)\n modified << mod\n end\n end\n end\n return(modified.empty? ? false : modified.uniq)\n end",
"def setup\n @ext_targets.each do |et|\n path, options, block = et\n path = expand_ext_path(path)\n case\n when options[:mkmf]\n setup_mkmf(path, options, block)\n end \n end\n end",
"def initialize\r\n load_tasks\r\n end",
"def list_modules module_type\n if module_type.empty?\n @colour.help \"ForGen module types: #{MODULE_TYPES}\"\n return\n end\n\n if MODULE_TYPES.include? module_type\n @colour.help \"Listing modules of type #{module_type}:\"\n Dir[\"#{DIR_MODULES}/#{module_type}/**/forgen_metadata.xml\"].select{ |file| !File.directory? file }.each_with_index do |case_name, case_number|\n @colour.help \"#{case_number}) #{case_name}\"\n end\n else\n @colour.error \"Module type [#{module_type}] does not exist\"\n end\nend",
"def initialize_compiler\n self.compile_tasks = [:multi, :test, :check_manifest]\n end",
"def do_requires()\n require 'rack'\n require './lib/my_thin.rb'\n require './android_translation_helper.rb'\nend",
"def process_project_dependencies\n recipes.each do |rec_obj|\n rec_obj.process_project_dependencies\n end\n end"
] | [
"0.6188523",
"0.6097411",
"0.597447",
"0.5809013",
"0.5786821",
"0.5702531",
"0.5696795",
"0.5691863",
"0.5685323",
"0.5668211",
"0.5608038",
"0.5600038",
"0.5597406",
"0.55894846",
"0.5582907",
"0.5552567",
"0.55266285",
"0.5491753",
"0.5467483",
"0.54470986",
"0.54303867",
"0.54287565",
"0.54229164",
"0.5420693",
"0.54159623",
"0.5406269",
"0.53947234",
"0.5393542",
"0.53904974",
"0.53897125",
"0.53871024",
"0.53864104",
"0.5371152",
"0.5370126",
"0.5365369",
"0.535194",
"0.5349443",
"0.5333255",
"0.53189266",
"0.5311689",
"0.5286767",
"0.52852064",
"0.5284886",
"0.5283699",
"0.52818084",
"0.5276096",
"0.5257521",
"0.5256709",
"0.5253745",
"0.5246314",
"0.52457625",
"0.52457625",
"0.52457625",
"0.52347434",
"0.52319777",
"0.52316356",
"0.52087146",
"0.5206913",
"0.52064246",
"0.5192217",
"0.51907295",
"0.5185014",
"0.5164824",
"0.51627123",
"0.5160367",
"0.5157035",
"0.51491815",
"0.51475227",
"0.51475024",
"0.5144079",
"0.51395553",
"0.5128457",
"0.5125045",
"0.51199853",
"0.51092625",
"0.5104884",
"0.5097751",
"0.50830644",
"0.5079675",
"0.5079053",
"0.50773853",
"0.50635713",
"0.5060393",
"0.50546384",
"0.5052282",
"0.5051365",
"0.5049209",
"0.50472474",
"0.5046693",
"0.5037617",
"0.503692",
"0.5029053",
"0.5019181",
"0.5017689",
"0.50162446",
"0.50061226",
"0.50046575",
"0.5003533",
"0.5001574",
"0.49998093"
] | 0.8342751 | 0 |
Writes a file making sure the directory is created | def write_file filename,content
mkdir_p(File.dirname(filename),:verbose=>false)
File.open(filename, 'wb') {|f| f.write(content) }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_file(content, dir, file)\n filename = File.basename(file).gsub(/(\\.s?[ac]ss)+/, options[:extension])\n path = File.join(dir, filename)\n\n unless options[:noop]\n FileUtils.mkdir_p(dir)\n File.open(path, 'w') {|f| f.write(content) }\n end\n\n path\n end",
"def write_file_at(file, content)\n\t\tFileUtils.mkdir_p(File.dirname(file))\n\t\tFile.open(file, 'w') do |file|\n\t\t\tfile.write(content)\n\t\tend\n\tend",
"def write\n make_parent_directory\n generate_file\n end",
"def write_file(filename, content)\n FileUtils.mkdir_p File.dirname(filename)\n IO.binwrite(filename, content)\n end",
"def write_file filename, content\n path = @output_directory + filename\n File.open(path, 'w') {|f| f.write content }\n end",
"def write( filename, contents )\n if File.exists? filename\n puts \"#{filename} already exists\"\n else\n puts \"Creating #{filename}\"\n ::File.open( filename, \"w\" ){ |f| f.write contents }\n end\nend",
"def write(file)\n @file_written = file\n file = Pathname.new(file)\n file.dirname.mkpath\n file.open \"w+\" do |output|\n output << self.build!\n end\n self\n end",
"def write_to_file(path, content)\n directory = File.dirname(path)\n FileUtils.mkdir_p(directory)\n File.write(path, content)\n after_rendering_run(\"rm -rf #{path}\")\n path\n end",
"def write_file(path)\n File.open(path, 'w') {|f| write_io(f)}\n end",
"def write_file!\n file = File.new( path, \"w\")\n \n file.write(@source)\n file.close\n end",
"def write_file(path, content)\n dir = File.dirname(path)\n if !File.exist?(dir)\n FileUtils.mkdir_p(dir)\n end\n File.open(path, 'wb') do |f|\n f.write(content)\n end\n end",
"def write(filename, content)\n abort 'File name not found.' if filename.nil?\n path = filename\n\n unless output_path.nil?\n abort \"Invalid output directory: #{output_path}\" unless File.directory?(output_path)\n path = File.join(output_path, filename)\n end\n\n File.write(path, content)\n end",
"def write_to(path)\n if !File.exists?(path)\n FileUtils.mkdir_p(path)\n else\n raise FileExists.new(\"#{path} already exists\")\n end\nend",
"def create_file(filename, content)\n Dir.chdir(@workdir_path) do\n FileUtils.mkdir_p(File.dirname(filename)) unless File.directory?(File.dirname(filename))\n File.open(filename, \"w\") { |file| file.write(content) }\n end\n end",
"def write_file(dir, name, data)\n path = File.join(dir, name)\n File.open(path, 'w') do |f|\n f.write(data)\n end\n path\n end",
"def write_file\n \n # if dirty?\n generate\n \n delete_file\n File.open(absolute_path.gsub(/\\.txt$/, \"\"), 'w+') do |f| \n f.write(generated_header)\n f.write(generated_content)\n end\n # not_dirty\n # end\n end",
"def write_file(path, content=path)\n path = File.join(temporary_directory, path)\n FileUtils.mkdir_p File.dirname(path)\n open(path, 'w'){|f| f.print content}\n end",
"def prepare_write_file(file)\n if File.exist?(file)\n unless overwrite_file?(file)\n fail 'Progrm execution terminated due to file error'\n end\n fail \"File '#{file}' is not writable\" unless File.writable?(file)\n end\n\n File.open(file, 'w')\n end",
"def write_file(content, path)\n File.delete path if File.exists? path\n\n file = File.new path, 'w+'\n file.write content\n\n file.close\n end",
"def write\n File.open(@file, 'a') do |w| \n w.write(\"\\n\"+ @name + \" \" + @path)\n end\n end",
"def write_file\n if @upload_file\n File.makedirs(\"#{full_path}\")\n File.open(file_path, 'wb') do |f|\n f.write(@upload_file.read) \n end\n end\n end",
"def write_file(path, content)\r\n f = File.new(path, \"w+\")\r\n f.puts content\r\n f.close\r\n end",
"def write!\n # 1. skip if file already exists.\n if output_file_already_exists?\n RSpec::Scaffold.log(\"- #{@output_file} - already exists\", :puts)\n return\n end\n\n # 2. ensure parent directories exist\n FileUtils.makedirs(@output_file.parent)\n\n # 3. write to file\n File.open(@output_file, 'wb') do |f| # 'wb' originally\n f << @output_text\n end\n\n RSpec::Scaffold.log(\"+ #{@output_file}\")\n\n return @output_file.to_s\n end",
"def cf(file)\n FileUtils.mkdir_p(Pathname.new(file).dirname)\n File.open(file, \"w+\").close\nend",
"def write_file(filename,data_write)\n begin\n data = data_write\n aFile = File.new(filename, \"w+\") \n if aFile\n aFile.syswrite(data)\n else\n raise \"Unable to open file!\"\n end \n rescue Exception => e\n puts e.message\n end \n end",
"def write(name, value)\n FileUtils.mkdir_p(File.dirname(path(name)))\n File.open(path(name), 'w') do |f|\n f.write(value)\n end\n end",
"def write(path, options: { create_dir: true })\n FileUtils.mkdir_p(File.dirname(path)) if options[:create_dir]\n File.write(path, to_s)\n end",
"def write(file, content)\n file = remove_prefix(file)\n return if File.exist?(file)\n `mkdir -p #{File.dirname(file)}`\n File.open(file, \"w+\") { |f|\n f.write(remove_prefix(JSON.pretty_generate(content)))\n }\n end",
"def write content, *opts\n raise \"Will not overwrite: #{self}\" if File.exist? self and not opts.include? :force\n FileUtils.mkdir_p(self.dirname)\n File.open(self, 'w'){ |f| f.write(content) }\n end",
"def write_to_file(file_name, data)\n key_path = ::File.dirname(file_name)\n ::FileUtils.mkdir_p(key_path) unless ::File.directory?(key_path)\n ::File.rename(file_name, \"#{file_name}.#{Time.now.to_i}\") if ::File.exist?(file_name)\n ::File.open(file_name, \"wb\", 0o600) { |file| file.write(data) }\n end",
"def write_file(file_name, data, write_type = 'w')\n write_file_base(append_root_path(file_name), data, write_type)\n end",
"def touch\n if !exists?\n touch_directories\n f = File.open(@filepath, \"w\"); f.close\n end\n end",
"def write_fudgefile\n if exists?\n \"Fudgefile already exists.\"\n else\n writer { |file| file << build_templated }\n \"Fudgefile created.\"\n end\n end",
"def create_file(path, contents)\n dir = File.dirname(path)\n\n unless File.directory?(dir)\n FileUtils.mkdir_p(dir)\n end\n\n myfile = File.new(path, 'w+')\n myfile.print(contents)\n myfile.close\n\n \"#{path} created\"\n end",
"def create_file(path, contents)\n dir = File.dirname(path)\n\n unless File.directory?(dir)\n FileUtils.mkdir_p(dir)\n end\n\n myfile = File.new(path, 'w+')\n myfile.print(contents)\n myfile.close\n\n \"#{path} created\"\n end",
"def write(contents, mode='wb')\n dirname.create\n open(mode) { |f| f.write contents }\n self\n end",
"def write_to(filename)\n FileUtils.mkdir_p File.dirname(filename)\n\n PathUtils.atomic_write(filename) do |f|\n f.write source\n end\n\n nil\n end",
"def write_file(directory, filename, output)\n FileUtils.mkdir_p directory\n\n # create full output path\n output_path = \"#{directory}/#{filename}\"\n\n # write it, char by char to avoid large mem issues\n File.open(output_path, \"wb\") do |file|\n output.each_char { |char| file.write char }\n end\n end",
"def create_file(filename, content)\n expanded_filename = \"#{working_dir}/#{filename}\"\n FileUtils.mkdir_p File.dirname(expanded_filename)\n File.open(expanded_filename, 'wb') do |f|\n f.write content\n end\n expanded_filename\n end",
"def create_file(file_name, contents)\n full_path = File.expand_path(File.join(dummy_app, file_name))\n\n dir = full_path.split('/')\n dir.pop\n FileUtils.mkdir_p(dir.join('/'))\n\n File.open(full_path, 'w') { |f| f.write contents }\n end",
"def write_file(file, data)\n File.open(file, 'w') { |fd| fd.write(data) }\n end",
"def write_file(filename, data)\n f = File.open(filename, 'w')\n f.write(data)\n f.close\nend",
"def write_file(dir, file, data)\n File.open(\"#{dir}/#{file}.data\", \"w\") do |file|\n file.write(data.to_a.join(\"\\n\"))\n end\nend",
"def write_file(full_path, contents)\n\t\t::File.open(full_path, 'w') do |f|\n\t\t\tf.write contents\n\t\tend\n\t\ttrue\n\tend",
"def write(file,content,timestamp=nil)\n\n f = File.join(path(:destination),file)\n log(\"writing '#{f}'\")\n\n # write the file \n File.open(f, 'w') {|f| f.write(content) }\n\n # Time-stamp the file if required\n File.utime(Time.now,timestamp,f) unless timestamp.nil?\n\n end",
"def write()\n f = File.open(\"#{@directory}/#{@filename}\", \"w\")\n f.write(@raw)\n f.close()\n end",
"def write_file(file_name)\n File.open(file_name, 'w') { |f| f.write header_build }\n File.write(file_name, @content, mode: 'a')\nend",
"def write_file(resp, path)\n FileUtils.mkdir_p File.dirname(path)\n File.open(path, 'wb') do |output|\n resp.read_body { |chunk| output << chunk }\n end\n true\n ensure\n # cleanup incomplete files, rescue perm errors etc, they're being\n # raised already.\n File.delete(path) rescue nil if $!\n end",
"def writeFile(fname, data)\n\tinf = File.new(fname, \"w+\")\n\tret = inf.write(data)\n\tinf.close\n\treturn ret\nend",
"def write_file(path, content)\n file_exists = File.exists?(path)\n if file_exists and not @force\n fail \"File #{path} already exists. Not overwritten. Use --force to overwrite\"\n end\n save_file(path,content)\n message = file_exists ? \"File #{path} overwriten with new content\" : \"File #{path} created\"\n Puppet.notice message\n end",
"def write(pid = Process.pid)\n FileUtils.makedirs(File.dirname(file_name))\n IO.write(file_name, pid.to_s)\n end",
"def write(str)\n return if noop?\n FileUtils.mkdir_p(File.dirname(file)) #unless File.file?(file)\n File.open(file, 'w'){ |f| f << str }\n end",
"def writable_file(path)\n path = File.expand_path(path)\n begin\n FileUtils.mkdir_p(File.dirname(path), :mode => 0755)\n FileUtils.touch path\n File.chmod(0644, path)\n rescue Errno::EACCES, Errno::EISDIR\n end\n unless File.file?(path) && File.writable?(path)\n raise ServiceError, \"unable to open file: #{path} (check permissions)\"\n end\n path\n end",
"def write(dir = self.dir, filename = self.filename)\n FileUtils.mkdir_p(File.join(WRITE_DIR, dir))\n self.image.write(File.join(WRITE_DIR, dir, filename))\n end",
"def write(filename = target)\n FileUtils.mkdir_p File.dirname(filename)\n PathUtils.atomic_write(filename) do |f|\n yield f\n end\n end",
"def create_file(path, contents)\n full_path = ::File.join(destination_root, path)\n mkdir_p(::File.dirname(full_path))\n ::File.open(full_path, 'w') {|f| f.write(contents) }\n end",
"def writeDistantFile buffer, args\n path = \"#{@dir}/#{args[0]}\"\n begin\n f = File.new path, \"w\"\n rescue\n return Constant::Fail\n end\n f.write buffer.to_file\n f.close\n Constant::Success\n end",
"def save_file(path, content)\n FileUtils.mkdir_p(File.expand_path(\"..\", path))\n File.open(path, \"w\") do |f|\n f.write(content)\n end\n end",
"def write( path, data )\n FileUtils.mkdir_p( File.dirname( path ) )\n File.open( path, 'w' ) do |f|\n f.write( data )\n end\n \n data.length\n end",
"def write file, text\n File.open file, \"w\" do |file|\n file.write text\n end\n end",
"def write_spec_to_file!\n formatted_output = format_output(output, extension)\n abs_path = File.join(write_path, suggested_filename)\n\n assert_directory_exists!(abs_path)\n write_method.call(abs_path, formatted_output)\n end",
"def write_file(file_name, contents, options = nil, binary = false)\n options ||= self.options if self.respond_to?(:options)\n options ||= {}\n skip_write = false\n # debugger\n # contents = process_erb(contents, options[:erb]) if options[:erb]\n if File.exists?(file_name)\n existing_contents = IO.read(file_name)\n if existing_contents == contents\n log_action :identical, basename(file_name), options\n skip_write = true\n elsif options[:force]\n log_action :overwrite, basename(file_name), options\n else\n msg = \"File #{basename(file_name)} already exists. Run with --force to force overwrite.\"\n raise puts(msg)\n end\n else\n log_action :create, basename(file_name), options\n end\n if skip_write\n FileUtils.touch file_name\n else\n mode = \"w\"\n mode << \"b\" if binary\n open(file_name, mode) do |file|\n file.write(contents)\n end\n end\n end",
"def writetofile(filename)\n self.scan() if @filearray == nil\n\n begin\n FileUtils.mkdir_p(File.dirname(filename))\n file = File.open(filename, \"w\")\n @filearray.each do |line|\n firstvalue = true\n newline = \"\"\n line.each do |value|\n if firstvalue == true\n firstvalue = false\n else\n newline = newline +\",\"\n end\n newline = newline + value\n end\n file.puts(newline)\n end\n rescue IOError => e\n #some error occur, dir not writable etc.\n ensure\n file.close unless file == nil\n end\n #copies original file\n FileUtils.cp(@ddy_filepath, \"#{File.dirname(filename)}/#{File.basename(filename,'.epw')}.ddy\")\n FileUtils.cp(@stat_filepath, \"#{File.dirname(filename)}/#{File.basename(filename,'.epw')}.stat\")\n end",
"def write(directory, file)\r\n\r\n dir = Rails.root.join(UPLOADS_FOLDER, directory)\r\n unless File.directory? dir\r\n FileUtils::mkdir_p dir\r\n end\r\n\r\n path = Rails.root.join(UPLOADS_FOLDER, directory, file.original_filename)\r\n File.open(path, 'wb') do |f|\r\n f.write(file.read)\r\n end\r\n\r\n return '/' + directory + '/' + file.original_filename\r\n\r\n end",
"def write_file(file_name, contents, options = nil, binary = false)\n options ||= self.options if self.respond_to?(:options)\n skip_write = options[:dry_run]\n contents = process_erb(contents, options[:erb]) if options[:erb]\n if File.exists?(file_name)\n existing_contents = IO.read(file_name)\n if existing_contents == contents\n log_action :identical, basename(file_name), options\n skip_write = true\n elsif options[:force]\n log_action :overwrite, basename(file_name), options\n else\n msg = \"File #{basename(file_name)} already exists. Run with --force to force overwrite.\"\n raise Compass::FilesystemConflict.new(msg)\n end\n else\n log_action :create, basename(file_name), options\n end\n if skip_write\n FileUtils.touch file_name unless options[:dry_run]\n else\n mode = \"w\"\n mode << \"b\" if binary\n open(file_name, mode) do |file|\n file.write(contents)\n end\n end\n end",
"def write_upload_to_file(uploaded_file, filename)\n FileUtils.mkdir_p(dir_path) unless File.directory?(dir_path)\n file_path = Rails.root.join(dir_path, filename)\n File.open(file_path, 'wb') do |file|\n file.write(uploaded_file.read)\n end\n end",
"def save_to(path)\n unless File.exists?(File.dirname(path))\n raise ArgumentError, \"Output path does not exist!\"\n end\n if File.directory?(path)\n raise ArgumentError, \"Output path should be a file!\"\n end\n File.open(path, 'w') { |f| f.write(@content) }\n end",
"def write_content(path,content)\n # Split and remove empty fields\n path_elements = path.split('/').reject(&:empty?)\n filename = path_elements.last\n path_elements.pop(1) # Drop the filename\n dirname = path_elements.join('/')\n\n # Create the directories is needed\n FileUtils.mkdir_p(dirname) unless File.exists?(dirname)\n\n # Create the file if needed\n if not File.exists?(dirname + '/' + filename)\n puts 'Creating: ' + dirname + '/' + filename\n File.open(dirname + '/' + filename, 'w'){\n |file| file.write(content)\n }\n end\n\nend",
"def create_file(filepath, contents = '')\n filepath = \"#{@dir}/#{@module}/#{filepath}\"\n puts \"... Creating file '#{filepath}'\"\n File.open(filepath, 'w') do |f|\n f.write contents\n end\n end",
"def opx_file_open_write(file)\n File.open(file, \"w\")\n rescue => e\n opx_err(\"Fatal failure of File.open for writing: #{file}\", e)\n end",
"def write_file(filename)\n File.open(filename, \"w\") do |f|\n self.write(f)\n end\n end",
"def write(filename, message, client)\n afile = File.new(filename, \"r+\")\n if afile\n afile.syswrite(message)\n client.puts(\"Changes made to \"+ filename)\n else\n client.puts \"Unable to write to file!\"\n end\nend",
"def safe_file_write(filepath, content: nil)\n raise ArgumentError, '#write_to_file requires filepath' if nay? filepath\n\n ensure_paths_to_file(filepath)\n File.write(filepath, content)\n filepath\n end",
"def save_to(path, content) \n begin \n dir = File.dirname(path)\n # Create a new directory (does nothing if directory exists or is a file)\n FileUtils.mkdir_p dir #unless File.dirname(path) == \".\"\n \n open(path, \"w\") do |f|\n f.write(content)\n end \n\n rescue StandardError => e\n puts e\n end\n end",
"def write_file(file_name)\n path = \"#{TARGET_DIRECTORY}/#{file_name}#{FILE_EXTENSION}\"\n unless false# File.exists? path\n \n # clean up front\n found_content = false\n while !found_content && [email protected]? do\n val = @content.shift\n unless val.strip.empty?\n @content.unshift(val)\n found_content = true\n end\n end\n\n # clean up back\n found_content = false\n while !found_content && [email protected]? do\n val = @content.pop\n unless val.strip.empty?\n @content.push(val)\n found_content = true\n end\n end\n\n return if @content.empty?\n\n puts \"Creating #{file_name}\"\n File.open(path, \"w\") {|f| f.puts @content.join(\"\")}\n end\n @content = []\nend",
"def write(file)\n self.files.each { |l| file.puts l }\n end",
"def write_example\n path.open(\"w\") { |file| file << EXAMPLE }\n path.chmod(0600)\n end",
"def create_new_file(file_name)\n puts \"Creating %s...\" % [file_name]\n make_dir_for_path(file_name)\n new_file = File.new(file_name, File::WRONLY|File::TRUNC|File::CREAT)\n end",
"def create_file(filename, contents)\n File.open(filename, \"w\") do |file|\n file.write(contents)\n end\n end",
"def log_to_file(filepath, object)\n #puts \"log_to_file #{filepath}\"\n final_path = File.join($boxes_logs_dir, filepath)\n pn = Pathname.new(final_path).cleanpath\n FileUtils.mkdir_p(pn.dirname)\n File.write(File.join(final_path), object)\nend",
"def save(dir, data, filename)\n FileUtils.mkdir_p dir\n fn = dir+\"/\"+filename \n puts fn\n open(fn, 'w') { |f|\n f.puts data\n f.close\n }\n end",
"def makeFile filename, message\n making = File.open(filename, \"w\")\n making.puts(message)\n making.close\nend",
"def new_file\n raise \"Not a Valid Directory\" unless valid_directory?\n\n file_name = \"#{Time.now.strftime(\"%Y%m%d%H%M%S\")}_#{process}.txt\"\n \"#{output_directory_path}#{file_name}\"\n end",
"def writeFile( fileName, textToWrite)\r\nopen(fileName,'w').write(textToWrite)\r\nend",
"def file(file, contents)\n if File.exists?(file)\n log file, \"(already exists)\"\n else\n log file, \"(creating file)\"\n touch file\n File.open(file, \"w\"){ |f| f.write contents } if contents\n end\n end",
"def write_file(file_name:, text:)\n File.open(file_name, 'w') { |file| file.write text }\n end",
"def create_directory(file)\n end",
"def create_log_file file_name=@file_name, dir=Dir.pwd\n @file_name = file_name\n @file_destination = dir\n if valid_file_name\n if File.directory? @file_destination\n @log_file = File.open(@file_destination + \"/\" + @file_name, 'w')\n @log_file.puts \"WatirmarkLog: \" + inspect\n else\n raise ArgumentError, \"Directory '#{@file_destination}' does not exist\"\n end\n else\n raise ArgumentError, \"File name: '#{@file_name}' must only contain characters, digits, and underscores, and must be of type .log\"\n end\n end",
"def write(key, value)\n paths = ::File.split(full_key(key))\n FileUtils.mkdir_p(paths.first) unless ::File.directory?(paths.first)\n f = ::File.open(full_key(key), 'w') {|f| f.write(value) }\n end",
"def write(path)\n # TODO: should start locking write process\n Writer.new(self, path).write\n end",
"def file_write(path, content, append = false)\n dddebug('file_write', [path, '...', append])\n\n append == true ? mode = 'a' : mode = 'w'\n\n ::File.open(prefixed(path), mode) do |file|\n file.write(content)\n end\n end",
"def get_require_file\n File.new(@file_to_be_written, 'w')\n end",
"def write_file(path, content)\n File.open(path, 'w') do |file|\n case content\n when ''\n # Create empty file.\n when String\n file.puts content\n when Array\n file.puts content.join(\"\\n\")\n end\n end\n end",
"def write(node)\r\n dir = folder(node)\r\n src = source(node)\r\n txt = text(node)\r\n unless dir.empty? || Dir.exist?(dir)\r\n Dir.mkdir(dir)\r\n @on_create_dir.call(dir) if @on_create_dir\r\n end\r\n File.write(src, txt)\r\n @on_create_file.call(src) if @on_create_file\r\n node.items.reject{|n| n.items.empty?}.each{|n| write(n)}\r\n end",
"def write_file(name, data, commit = {})\n write(merge_path_elements(nil, name, nil), data, commit)\n end",
"def create_file_and_folder\n begin\n Dir::mkdir(@directory)\n rescue Errno::EEXIST\n end\n FileUtils.touch \"#{@directory}/#{@store}.yml\"\n end",
"def add_to_file(path, contents)\n dir = File.dirname(path)\n\n unless File.directory?(dir)\n FileUtils.mkdir_p(dir)\n end\n\n # Using technique outlined here: http://www.dzone.com/snippets/ruby-open-file-write-it-and\n\n File.open(path, 'a') {|f| f.write(\"#{contents}\\n\") }\n\n \"#{path} updated\"\n end",
"def add_to_file(path, contents)\n dir = File.dirname(path)\n\n unless File.directory?(dir)\n FileUtils.mkdir_p(dir)\n end\n\n # Using technique outlined here: http://www.dzone.com/snippets/ruby-open-file-write-it-and\n\n File.open(path, 'a') {|f| f.write(\"#{contents}\\n\") }\n\n \"#{path} updated\"\n end",
"def write_file(*args)\n end",
"def create_file(override = false)\n dir = File.dirname(Constant::HIGHSCORE_FILE_NAME)\n\n # Create directory if not exist\n FileUtils.mkdir_p(dir) unless File.directory?(dir)\n\n # Fake open a file to create\n File.open(Constant::HIGHSCORE_FILE_NAME, override ? 'w' : 'a') {}\n end"
] | [
"0.7758628",
"0.77174056",
"0.7669147",
"0.7526724",
"0.74939084",
"0.74851555",
"0.74124116",
"0.73894113",
"0.73765755",
"0.7322685",
"0.72489274",
"0.72189933",
"0.7204453",
"0.7199991",
"0.7167592",
"0.714699",
"0.71240133",
"0.710108",
"0.7098118",
"0.7068656",
"0.7052418",
"0.7044599",
"0.7034796",
"0.70189905",
"0.70107305",
"0.6980839",
"0.6976035",
"0.6957503",
"0.69557136",
"0.69166684",
"0.69165796",
"0.69102585",
"0.6878729",
"0.6851681",
"0.6851681",
"0.6834031",
"0.683112",
"0.6827869",
"0.6822578",
"0.6822304",
"0.681363",
"0.6806272",
"0.6755228",
"0.67316884",
"0.6726377",
"0.6723562",
"0.67230785",
"0.6712827",
"0.6702948",
"0.669084",
"0.66824836",
"0.6672562",
"0.667203",
"0.66651154",
"0.6662432",
"0.66391474",
"0.6636773",
"0.662293",
"0.6619926",
"0.6612576",
"0.660852",
"0.65976715",
"0.6595143",
"0.65923566",
"0.6590925",
"0.65897185",
"0.65736437",
"0.6573031",
"0.6566525",
"0.6545526",
"0.65436536",
"0.6537955",
"0.6534699",
"0.6529222",
"0.6513189",
"0.65079015",
"0.6503757",
"0.6497643",
"0.6497315",
"0.6494274",
"0.6493471",
"0.6489363",
"0.6487213",
"0.6485146",
"0.6481522",
"0.6479301",
"0.64600444",
"0.6454133",
"0.6453286",
"0.64521265",
"0.6441969",
"0.64410543",
"0.64222056",
"0.6401896",
"0.63824904",
"0.63824147",
"0.6373569",
"0.6373569",
"0.63704544",
"0.6358712"
] | 0.7985259 | 0 |
Template suffix for variables (lowercase). | def tmpl_var_suffix
Hash.instance_variable_get :@tmpl_var_suffix
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def var_name()\n if self.id.start_with?(/\\Ah?l_/i)\n return self.id.downcase\n else\n return \"l_#{self.id.downcase}\"\n end\n end",
"def underscore_vars\r\n self.gsub(/\\b[a-z][a-z]*(?:[A-Z][a-z]*)(?:[A-Z][a-z]*)*\\b/) {|word|\r\n word.underscore\r\n }\r\n end",
"def class_name_to_variable_name(name)\n name.to_s.gsub(/::/, '/').\n gsub(/([A-Z]+)([A-Z][a-z])/,'\\1_\\2').\n gsub(/([a-z\\d])([A-Z])/,'\\1_\\2').\n tr(\"-\", \"_\").\n downcase\n end",
"def class_name_to_variable_name(name)\n name.to_s.gsub(/::/, '/').\n gsub(/([A-Z]+)([A-Z][a-z])/,'\\1_\\2').\n gsub(/([a-z\\d])([A-Z])/,'\\1_\\2').\n tr(\"-\", \"_\").\n downcase\n end",
"def suffix(num)\n namespace + '_suffix_' + num.to_s\n end",
"def variable_name=(variable_name)\n self[:variable_name] = variable_name.downcase.gsub(/[^0-9a-z_ ]/i, \"\").strip.tr(\" \", \"_\")\n end",
"def suffixize(lang)\n lang.blank? ? \"\" : \"_#{lang}\"\n end",
"def pe_variable(pe)\n pe.name.squish.downcase.tr(\" \",\"_\").to_sym\n end",
"def suffix; end",
"def suffix; end",
"def suffix; end",
"def suffix; end",
"def suffix; end",
"def refurbish variable_name\n Value.typed @vars[variable_name], variable_name.to_s.sub(/^\\@/, '') #.sub(/^\\$/, '')\n end",
"def to_nvar(name)\n name[0] == at ? name[1..-1].to_sym : name.to_sym\n end",
"def suffix\n name.scan(MetaDep::TEMPLATE_SUFFIX).flatten.first\n end",
"def variable_name_expr; end",
"def param_namer(param)\n \"$_#{param}\"\n end",
"def conv_ruby_var\n parts = @name.split(\"::\")\n mod = parts[0]\n n = parts[1][3..-1]\n # p parts, mod, n\n \n spchars = n.scan(/\\_[0-9A-F]{2}/)\n spchars.each do |sc|\n n.sub!(sc, sc[1..-1].to_i(16).chr)\n end\n\n return mod + \"::\" + n\n end",
"def name_attribute(suffix = nil)\n extra = suffix ? \"_#{suffix}\" : ''\n %(name=\"#{name_base}#{extra}\")\n end",
"def format_variable(v)\n\t if v.kind_of?(Gerber::ApertureMacro::Variable)\n\t\tindex = modifiers.index(v)\n\t\tindex ? \"$#{index}\" : nil\n\t else\n\t\tv.to_s\n\t end\n\tend",
"def variable_name; end",
"def variable_name; end",
"def suffix\n @suffix || parse_and_return(:@suffix)\n end",
"def variablize(original)\n return original.downcase if original =~ /[A-Z]+/ && original !~ /_/\n return original[0].downcase + original[1..-1] if original !~ /_/\n camelized = original.split('_').map { |e| e.capitalize }.join\n camelized[0].downcase + camelized[1..-1]\n end",
"def varName\n \"#{entity.name}_#{name}\"\n end",
"def instance_variable_name_for(klass)\n klass.to_s.split('::').last.underscore\n end",
"def makeCensoredVarname( varname )\n varname = basicCensor( varname )\n if( KEYWORD_TRANSLATIONS.has_key?( varname ))then\n varname = KEYWORD_TRANSLATIONS[ varname ];\n end\n return varname\nend",
"def domain_suffix\n offset = environment_first_char.ord - 97\n ENV[\"SUFFIX_CHARACTERS\"][offset..offset + 4]\n end",
"def suffix\n fetch('university.suffix')\n end",
"def symbol_suffix\n \"\"\n end",
"def underscore(const_name)\n const_name.gsub(/([^\\^])([A-Z])/,'\\1_\\2').downcase.to_sym\n end",
"def name_with_prefix(prefix, name)\n prefix ? \"#{prefix}[#{name}]\" : name.to_s\n end",
"def suffix\n fetch('superhero.suffix')\n end",
"def city_suffix; end",
"def __prefix__\n __name__.demodulize.underscore.dasherize.to_sym\n end",
"def get_var_name(group_name, wanted_name, context = @context)\n secure_name = wanted_name.gsub(/[^a-zA-Z0-9]/,'')\n name = \"_z#{secure_name}\"\n i = 0\n while get_context_var('var', name, context)\n i += 1\n name = \"_z#{secure_name}#{i}\"\n end\n set_context_var('var', name, true)\n set_context_var(group_name, wanted_name, name)\n name\n end",
"def name_prefix=(_arg0); end",
"def const_name\n components = title.gsub(/\\W/,' ').split.collect {|word| word.strip.upcase }\n components.join '_'\n end",
"def getStyledVariableName(var, prefix = \"\", postfix = \"\")\r\n return CodeNameStyling.getStyled(prefix + var.name + postfix, @langProfile.variableNameStyle)\r\n end",
"def gen_name\n name.to_s.downcase\n end",
"def name\n variant_suffixes = @field_variants.map { |variant| variant.suffix }.join\n \"*_#{@type.suffix}#{variant_suffixes}\"\n end",
"def name_suffix\n Faker::Name.suffix\n end",
"def name_suffix\n Faker::Name.suffix\n end",
"def name_with_underscores\n name.gsub(\" \", \"_\")\n end",
"def template_ivar\n \"@#{template_name.downcase}\".to_sym\n end",
"def getVarDec(var, varPrefix = \"\")\n vDec = String.new\n\n vDec << \"[\" + CodeNameStyling.getStyled(varPrefix + var.name, @langProfile.variableNameStyle) + \"]\"\n\n tName = getTypeName(var)\n\n if tName != var.vtype\n vDec << \" \" + tName\n if (var.identity)\n vDec << \" IDENTITY\" << var.identity\n end\n else\n vDec << \"TEXT\"\n end\n\n return vDec\n end",
"def var_prefix\n # ugh, i was generating meta/qb.yml files that set 'var_prefix' to\n # `null`, but it would be nice to\n # \n meta_or 'var_prefix', namespaceless\n end",
"def variable_name(method)\n \t_IDENTIFIER12 = nil\n\n\n\n\n \t name = \"\"\n\n\n # 238:7: ( 'this' '.' )? IDENTIFIER\n # 238:7: ( 'this' '.' )?\n alt33 = 2\n # 238:7: ( 'this' '.' )?\n look_ahead33_0 = look_ahead(1)\n\n if look_ahead33_0 == :T58 \n alt33 = 1\n end\n case alt33\n when 1\n # 238:9: 'this' '.'\n match(:T58)\n match(:DOT)\n name << \"this.\"\n end\n _IDENTIFIER12 = @input.look_ahead(1)\n match(:IDENTIFIER)\n\n name << _IDENTIFIER12.text\n method.add_use_of(name, _IDENTIFIER12.line)\n \n\n\n\n end",
"def unmiga_name\n gsub(/_(str|sp|subsp|pv)__/,\"_\\\\1._\").tr('_', ' ')\n end",
"def name(prefix = T.unsafe(nil)); end",
"def name(prefix = T.unsafe(nil)); end",
"def name(prefix = T.unsafe(nil)); end",
"def full_name *args\n suffix_options = args.extract_options!\n\n \"#{name_prefix} : #{name}\".tap do | str |\n unless suffix_options.blank?\n suffix = \" \" + suffix_options.map { | k, v | \"#{k} => #{v}\" }.join(\", \")\n str << suffix\n end\n end\n end",
"def underscored_name\n name.demodulize.gsub(Tuxedo.config.suffix, '').underscore\n end",
"def ext_name(name)\r\n return name.to_s if name.kind_of?(Symbol)\r\n return name.gsub(/\\s/, '_')\r\n end",
"def random_suffix(name, env_var=nil)\n return \"#{name}-#{SecureRandom.hex(2)}\" if env_var.nil?\n \"#{ENV.fetch(env_var, name)}-#{SecureRandom.hex(2)}\"\nend",
"def const2name(const)\n const.sub(/^[A-Z]/) { |i| i.downcase }.gsub(/[A-Z]/) { |i| \"_#{i.downcase}\" }.intern\n end",
"def template_name_expr; end",
"def cmd_suffix(cmd)\n if cmd =~ VALID_NAME\n cmd\n else\n mod = cmd.gsub(/\\W+/,'_')\n mod.gsub!(/^_+/, '')\n mod.gsub!(/_+$/, '')\n mod\n end\n end",
"def full_name\n [prefix, name, suffix].join(\"\")\n end",
"def long_name\n name = ''\n if @name.to_s =~ /_/\n @name.to_s.split('_').each do |str|\n name << str.to_s.capitalize\n end\n else\n name = @name.to_s.capitalize\n end\n namespace = @namespace.to_s.split('::').map { |str| str.capitalize }\n \"#{namespace.join('::')}::#{name}\"\n end",
"def new_var\n ('A'..'Z').to_a.each do |letter|\n if !vars.include?(letter)\n vars << letter\n return letter\n end\n end\n end",
"def make_identifier_suffix( url )\n\t\treturn url.to_s.gsub( /\\W+/, '-' )\n\tend",
"def variable_name_to_class_name(name)\n name.to_s.\n gsub(/\\/(.?)/) { \"::#{$1.upcase}\" }.\n gsub(/(?:^|_)(.)/) { $1.upcase }\n end",
"def variable_name_to_class_name(name)\n name.to_s.\n gsub(/\\/(.?)/) { \"::#{$1.upcase}\" }.\n gsub(/(?:^|_)(.)/) { $1.upcase }\n end",
"def to_const_name(name)\nconst_name = name.to_s.gsub(/[^a-z0-9_]/i,'_').squeeze('_').upcase\n if const_name =~ /^[^a-z]/i\n const_name = \"T_\"+const_name\n end\n const_name.to_sym\n end",
"def constantize(name)\n name.to_s.split('_').map(&:capitalize).join\n end",
"def identifier\n name.gsub(/[^A-Za-z0-9_]/, '_')\n end",
"def identifier\n name.gsub(/[^A-Za-z0-9_]/, '_')\n end",
"def create_name(name = @name)\n if name.is_a?(VariableNode)\n create_interpolation(name)\n else\n name.to_s\n end\n end",
"def _normalize(name)\n # maybe do something more, maybe not.. ruby does allow for\n # some weird stuff to be used as a variable name. the user\n # should use some common sense. and, other things might\n # also be an syntax error, like starting with a number.\n # this normalization is more of a comvenience than anything\n # else\n name.tr('-', '_')\n end",
"def underscore_name(name)\n name.to_s.sub(/.*::/, \"\").\n gsub(/([A-Z]+)([A-Z][a-z])/,'\\1_\\2').\n gsub(/([a-z\\d])([A-Z])/,'\\1_\\2').\n tr(\"-\", \"_\").\n downcase\n end",
"def two_word_name; end",
"def variable_regex\n /\n \\$ # start tag\n ([a-zA-Z_][\\w_]*) # our variables are starting with $ and are followed by\n # upcase letters or _. We want to match the \n # variable name\n /xm\n end",
"def constantize(s)\n s.to_s.split('_').map(&:capitalize).join.to_sym\n end",
"def scope2(var)\r\n\tvar.upcase\r\nend",
"def variable_name? word\n word.start_with?('@') or word.start_with?('$')\n end",
"def mangle_name(name)\r\n name.gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/,'\\1_\\2').gsub(/([a-z\\d])([A-Z])/,'\\1 \\2')\r\n end",
"def literalize(name); end",
"def la_variable(id)\n Vocab::Variable + \" \" + variable_name(id)\n end",
"def name_for(key, value = nil)\n basename = key.is_a?(Integer) ? \"%di\" % key : key.to_s\n\n case value\n when Float\n \"#{basename}.f.js\"\n when Integer\n \"#{basename}.i.js\"\n when nil, String\n \"#{basename}.js\"\n when true, false\n \"#{basename}.b.js\"\n else\n basename\n end\n end",
"def short_name \r\n name.gsub(/([A-Z])[^A-Z]+/, '\\1')\r\n end",
"def long_name\n long.to_s.sub(/^(--.+?)(\\s+|\\=|\\[).*$/, \"\\\\1\")\n end",
"def suffix(default)\n case default\n when String then '\"'\n when Time, Date, DateTime then '\"'\n end\n end",
"def get_name_with_code\n '@{code}-@{name}'\n end",
"def argument_name_without_leading_underscore\n name = if argument_name_string[FIRST_CHARACTER] == UNDERSCORE\n argument_name_string.reverse.chop.reverse\n else\n argument_name_string\n end\n name.to_sym\n end",
"def variable_name_of(a_string, convention = :snake_case)\n unless String == a_string.class\n unless a_string.respond_to?(:to_s)\n raise ArgumentError, \"Expected a string; got #{a_string.class}\"\n else\n a_string = a_string.to_s\n end\n end\n if a_string.include?('(')\n \tp_start = a_string.index('(')\n \tp_end = a_string.index(')')\n \ta_string[p_start..p_end] = ''\n end\n parts = a_string.downcase.gsub(/[^0-9a-z ]/, ' ').squeeze(' ').split\n case convention\n when :lowerCamelCase \n parts.size.times do |x|\n \tnext unless x>0\n \tparts[x][0] = parts[x][0].upcase\n end\n variable_name = parts.join\n when :CamelCase \n parts.size.times do |x|\n \tparts[x][0] = parts[x][0].upcase\n end\n variable_name = parts.join \n when :snake_case \n variable_name = parts.join('_')\n when :tall_snake_case\n variable_name = parts.join('-')\n else\n raise ArgumentError, \"Invalid Convention: #{convention}\"\n end\n\n return variable_name\nend",
"def prefix(path)\n path ? \"#{path.underscore}__\" : ''\n end",
"def suffix\n fetch('company.suffix')\n end",
"def replace(key)\n instance_variable_get(\"@#{key}\").to_s\n end",
"def encode_global_variable(name)\n raise if name.to_s[0,1] != '$'\n \"$\" + @global_name_generator.get(name.to_s)\n end",
"def underscored_name(word = self.class.to_s)\n @underscored_name ||= begin\n words = word.dup.split('::')\n word = words.last\n if word == 'Panel'\n word = words[-2] # Panel class is Panel... and this won't do.\n end\n # This bit from rails probably isn't needed here, and wouldn't work anyways.\n #word.gsub!(/(?:([A-Za-z\\d])|^)(#{inflections.acronym_regex})(?=\\b|[^a-z])/) { \"#{$1}#{$1 && '_'}#{$2.downcase}\" }\n word.gsub!(/Panel$/,'')\n word.gsub!(/([A-Z\\d]+)([A-Z][a-z])/,'\\1_\\2')\n word.gsub!(/([a-z\\d])([A-Z])/,'\\1_\\2')\n word.tr!(\"-\", \"_\")\n word.downcase!\n word\n end\n end",
"def var=(name)\n @var = if name == :random\n \"_#{rand(2000)}\"\n else\n name\n end\n end",
"def tt_base_name\n \"#{exp_fname}-tt\"\n end",
"def name_prefix; end",
"def name_underscored\n self.name.gsub(' ', '_')\n end",
"def objective_name snake_name\n\tsnake_name.split(\"_\").reduce(\"\") { |result, part| \n\t\tif result != \"\"\n\t\t\tresult + part.capitalize\n\t\telse\n\t\t\tpart\n\t\tend\n\t}\nend",
"def callback_name(name)\n return name.gsub(/([^A-Z]+)([A-Z]+)/, '\\\\1_\\\\2').downcase\n end",
"def parameter_key(term)\n string = term.to_s\n string = string.sub(/^[a-z\\d]*/) { $&.capitalize }\n string.gsub!(/(?:_|(\\/))([a-z\\d]*)/i) { \"#{$1}#{$2.capitalize}\" }\n string\n end"
] | [
"0.6941256",
"0.68697774",
"0.67630404",
"0.67630404",
"0.6741851",
"0.64515334",
"0.6432811",
"0.6383109",
"0.635437",
"0.635437",
"0.635437",
"0.635437",
"0.635437",
"0.6351529",
"0.62755126",
"0.626218",
"0.62409097",
"0.6224396",
"0.6209271",
"0.6175734",
"0.6167799",
"0.6150269",
"0.6150269",
"0.6127543",
"0.61267287",
"0.61262393",
"0.6046977",
"0.6041951",
"0.60191923",
"0.6012869",
"0.60058475",
"0.59950495",
"0.59756595",
"0.5962077",
"0.59505767",
"0.5948408",
"0.5926736",
"0.592412",
"0.59229916",
"0.59156084",
"0.5914166",
"0.5910737",
"0.59103173",
"0.59103173",
"0.5909824",
"0.590644",
"0.5883301",
"0.58755064",
"0.5874959",
"0.58596253",
"0.5859336",
"0.5859336",
"0.5859336",
"0.585745",
"0.5855103",
"0.5852652",
"0.5840488",
"0.58249485",
"0.5817379",
"0.58140904",
"0.5804909",
"0.5783883",
"0.577508",
"0.577096",
"0.57650626",
"0.57650626",
"0.5758766",
"0.5751474",
"0.5749582",
"0.5749582",
"0.5743935",
"0.57391316",
"0.5731694",
"0.5707308",
"0.5692282",
"0.56759775",
"0.56686074",
"0.5665386",
"0.5657494",
"0.5652922",
"0.5648279",
"0.5645531",
"0.56436384",
"0.5640319",
"0.56139606",
"0.561367",
"0.56096715",
"0.56083375",
"0.56039315",
"0.5600453",
"0.5598864",
"0.5595445",
"0.5582347",
"0.5580955",
"0.5571686",
"0.55626446",
"0.55610204",
"0.555992",
"0.55580515",
"0.5556691"
] | 0.774759 | 0 |
def input Output a tarball. If the output path ends predictably (like in .tar.gz) it will try to obey the compression type. | def output(output_path)
output_check(output_path)
files = Find.find(staging_path).to_a
safesystem("zip", output_path, *files)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tarball(destination, paths)\n # check for filepath length limit\n full_destination = File.expand_path(destination)\n if full_destination.length > 259 # 256 chars max; \"C:\\\" doesn't count\n puts \"[TarBall] ERROR cannot generate #{destination} because path exceeds 256 char limit. shorten component name by at least by #{full_destination.length - 259} chars\"\n return\n end\n\n Zlib::GzipWriter.open(destination) do |gzip|\n out = Archive::Tar::Minitar::Output.new(gzip)\n\n paths.each do |fi|\n if File.exist?(fi)\n Archive::Tar::Minitar.pack_file(fi, out)\n else\n puts \"[TarBall] ERROR Could not file file: #{fi}\"\n end\n end\n out.close\n end\n end",
"def tar_compression_flag(path)\n case path\n when /\\.tar\\.bz2$/\n return \"-j\"\n when /\\.tar\\.gz$|\\.tgz$/\n return \"-z\"\n when /\\.tar\\.xz$/\n return \"-J\"\n else\n return nil\n end\n end",
"def pack_file(entry, outputter) # :yields action, name, stats:\n if outputter.is_a?(Archive::Tar::Minitar::Output)\n outputter = outputter.tar\n end\n\n stats = {}\n\n if entry.is_a?(Hash)\n name = entry[:name]\n entry.each { |kk, vv| stats[kk] = vv unless vv.nil? }\n else\n name = entry\n end\n\n name = name.sub(%r{\\./}, \"\")\n stat = File.stat(name)\n stats[:mode] ||= stat.mode\n stats[:mtime] ||= stat.mtime\n stats[:size] = stat.size\n\n if windows?\n stats[:uid] = nil\n stats[:gid] = nil\n else\n stats[:uid] ||= stat.uid\n stats[:gid] ||= stat.gid\n end\n\n if File.file?(name)\n outputter.add_file_simple(name, stats) do |os|\n stats[:current] = 0\n yield :file_start, name, stats if block_given?\n File.open(name, \"rb\") do |ff|\n until ff.eof?\n stats[:currinc] = os.write(ff.read(4096))\n stats[:current] += stats[:currinc]\n yield :file_progress, name, stats if block_given?\n end\n end\n yield :file_done, name, stats if block_given?\n end\n elsif dir?(name)\n yield :dir, name, stats if block_given?\n outputter.mkdir(name, stats)\n else\n raise \"Don't yet know how to pack this type of file.\"\n end\n end",
"def compression\n \n ##Preparing directory structure for \"project\" area to display html\n system(\"mkdir -p #{@outputDir}/htmlPages/#{@studyName1}/QIIME/#{@jobName1}\")\n system(\"cp -r #{@outputDir}/QIIME_result/plots #{@outputDir}/htmlPages/#{@studyName1}/QIIME/#{@jobName1}\")\n \n Dir.chdir(\"#{@outputDir}/QIIME_result\")\n #system(\"tar -zcf #{@sampleSetName1}.tar.gz * --exclude=*.log --exclude=*.sra --exclude=*.sff --exclude=*.local.metadata\")\n system(\"tar czf raw.results.tar.gz * --exclude=filtered_aln --exclude=taxa --exclude=aln --exclude=plots\")\n system(\"tar czf phylogenetic.result.tar.gz filtered_aln\")\n system(\"tar czf taxanomy.result.tar.gz taxa\")\n system(\"tar czf fasta.result.tar.gz aln\")\n system(\"tar czf plots.result.tar.gz plots\")\n \n Dir.chdir(@scratch)\n \n end",
"def _create_output_filename(output_prefix, compression)\n output_file = output_prefix + '.tsv'\n case compression\n when true, 'gzip'\n output_file += '.gz'\n when 'bzip2'\n output_file += '.bz2'\n end\n return output_file\n end",
"def tarball\n return @tarball if defined? @tarball\n\n require 'open3'\n Dir.mktmpdir do |tmpdir|\n definition.each do |options|\n glob = options.fetch(:glob)\n prefix = options[:prefix]\n ignore_hidden = options[:ignore_hidden]\n\n files = Dir[glob]\n files.reject! { |f| f.start_with?('.') } if ignore_hidden\n\n dest = prefix ? File.join(tmpdir, prefix) : tmpdir\n\n FileUtils.mkpath(dest)\n FileUtils.cp_r(files, dest)\n end\n\n excludes.each do |path|\n full_path = File.join(tmpdir, path)\n if File.file?(full_path)\n File.unlink(File.join(tmpdir, path))\n end\n end\n\n # Specify the correct ruby version in the Dockerfile.\n bundle_dockerfile = File.join(tmpdir, \"Dockerfile\")\n content = IO.read(bundle_dockerfile)\n content = content.gsub(\"{{ruby_version}}\", ruby_version)\n IO.write bundle_dockerfile, content\n\n if dockerfile\n File.unlink bundle_dockerfile\n FileUtils.cp dockerfile, bundle_dockerfile\n end\n\n # Find hash of all files we're sending over.\n digest = Digest::SHA1.new\n Dir[File.join(tmpdir, '**/*')].each do |path|\n if File.file? path\n open path, 'r' do |file|\n digest.update file.read\n end\n end\n end\n @image_name = \"hoosegow:#{digest.hexdigest}\"\n\n # Create tarball of the tmpdir.\n stdout, stderr, status = Open3.capture3 'tar', '-c', '-C', tmpdir, '.'\n\n raise Hoosegow::ImageBuildError, stderr unless stderr.empty?\n\n @tarball = stdout\n end\n end",
"def compress_source_tgz(path)\n tarfile = Tempfile.create([\"vagrant\", \".tar\"])\n tarfile.close\n tarfile = File.open(tarfile.path, \"wb+\")\n tgzfile = Tempfile.create([\"vagrant\", \".tgz\"])\n tgzfile.close\n tgzfile = File.open(tgzfile.path, \"wb\")\n tar = Gem::Package::TarWriter.new(tarfile)\n tgz = Zlib::GzipWriter.new(tgzfile)\n if File.file?(path)\n tar.add_file(File.basename(path), File.stat(path).mode) do |io|\n File.open(path, \"rb\") do |file|\n while bytes = file.read(4096)\n io.write(bytes)\n end\n end\n end\n else\n Dir.glob(File.join(path, \"**/**/*\")).each do |item|\n rel_path = item.sub(path, \"\")\n item_mode = File.stat(item).mode\n\n if File.directory?(item)\n tar.mkdir(rel_path, item_mode)\n else\n tar.add_file(rel_path, item_mode) do |io|\n File.open(item, \"rb\") do |file|\n while bytes = file.read(4096)\n io.write(bytes)\n end\n end\n end\n end\n end\n end\n tar.close\n tarfile.rewind\n while bytes = tarfile.read(4096)\n tgz.write bytes\n end\n tgz.close\n tgzfile.close\n tarfile.close\n File.delete(tarfile.path)\n tgzfile.path\n end",
"def compress\n @env[:ui].info I18n.t(\"vagrant.actions.general.package.compressing\", :tar_path => tar_path)\n File.open(tar_path, Platform.tar_file_options) do |tar|\n Archive::Tar::Minitar::Output.open(tar) do |output|\n begin\n current_dir = FileUtils.pwd\n\n copy_include_files\n\n FileUtils.cd(@env[\"package.directory\"])\n Dir.glob(File.join(\".\", \"**\", \"*\")).each do |entry|\n Archive::Tar::Minitar.pack_file(entry, output)\n end\n ensure\n FileUtils.cd(current_dir)\n end\n end\n end\n end",
"def compressFiles\n Dir.chdir(\"#{@outputDir}/RDPsummary\")\n #system(\"tar -zcf #{@sampleSetName1}.tar.gz * --exclude=*.log --exclude=*.sra --exclude=*.sff --exclude=*.local.metadata\")\n system(\"tar czf class.result.tar.gz class\")\n system(\"tar czf domain.result.tar.gz domain\")\n system(\"tar czf family.result.tar.gz family\")\n system(\"tar czf genus.result.tar.gz genus\")\n system(\"tar czf order.result.tar.gz order\")\n system(\"tar czf phyla.result.tar.gz phyla\")\n system(\"tar czf species.result.tar.gz species\")\n system(\"tar czf pdf.result.tar.gz 'find . -name `*.pdf`'\")\n Dir.chdir(@scratch)\n end",
"def tar_compression_extension\n case compression\n when :bzip2, \"bzip2\", nil\n \".bz2\"\n when :gzip, \"gzip\"\n \".gz\"\n when :none, \"none\"\n \"\"\n end\n end",
"def tar_compression_flag\n case compression\n when :bzip2, \"bzip2\", nil\n \"j\"\n when :gzip, \"gzip\"\n \"z\"\n when :none, \"none\"\n \"\"\n end\n end",
"def write_tgz\n # Grab the contents of the gzipped tarball for reading\n contents = gzipped_tarball\n\n # Write the .tar.gz into the staging directory\n File.open(\"#{staging_dir}/#{package_name}\", \"wb\") do |tgz|\n while chunk = contents.read(1024)\n tgz.write(chunk)\n end\n end\n\n # Copy the .tar.gz into the package directory\n FileSyncer.glob(\"#{staging_dir}/*.tar.gz\").each do |tgz|\n copy_file(tgz, Config.package_dir)\n end\n end",
"def compression?; end",
"def targz\n files = procedure.get_adapter_configuration.attributes['files']\n if files.is_a?(Array)\n puts system_messages[:archiving]; puts system_messages[:compressing]\n %x{ tar -czf #{File.join(tmp_path, compressed_file)} #{files.map{|f| f.gsub(' ', '\\ ')}.join(' ')} }\n elsif files.is_a?(String)\n puts system_messages[:archiving]; puts system_messages[:compressing]\n %x{ tar -czf #{File.join(tmp_path, compressed_file)} #{files.gsub(' ', '\\ ')} }\n end\n end",
"def tarball\n tarfile = StringIO.new(\"\")\n Gem::Package::TarWriter.new(tarfile) do |tar|\n path = \"#{staging_dir}/#{packager.package_name}\"\n name = packager.package_name\n mode = File.stat(path).mode\n\n tar.add_file(name, mode) do |tf|\n File.open(path, \"rb\") do |file|\n tf.write(file.read)\n end\n end\n end\n\n tarfile.rewind\n tarfile\n end",
"def package!\n return unless @model.compressor\n\n pipeline = Pipeline.new\n base_dir = File.dirname(@dump_path)\n dump_dir = File.basename(@dump_path)\n timestamp = Time.now.to_i.to_s[-5, 5]\n outfile = @dump_path + '-' + timestamp + '.tar'\n\n Logger.info(\n \"#{ database_name } started compressing and packaging:\\n\" +\n \" '#{ @dump_path }'\"\n )\n\n pipeline << \"#{ utility(:tar) } -cf - -C '#{ base_dir }' '#{ dump_dir }'\"\n @model.compressor.compress_with do |command, ext|\n pipeline << command\n outfile << ext\n end\n pipeline << \"cat > #{ outfile }\"\n\n pipeline.run\n if pipeline.success?\n Logger.info(\n \"#{ database_name } completed compressing and packaging:\\n\" +\n \" '#{ outfile }'\"\n )\n FileUtils.rm_rf(@dump_path)\n else\n raise Errors::Database::PipelineError,\n \"#{ database_name } Failed to create compressed dump package:\\n\" +\n \"'#{ outfile }'\\n\" +\n pipeline.error_messages\n end\n end",
"def generate_output_file(zip_out, contents); end",
"def archive_package(name)\n destination_dir = File.join(@project.full_path, \"output\", name)\n FileUtils.mkdir_p(destination_dir)\n destination_file = File.join(destination_dir, \"#{name}.tar.xz\")\n\n archive_single(File.join(\"src\", name), destination_file)\n end",
"def extract src_path, dst_path = File.dirname(src_path)\n src_path = File.expand_path(src_path)\n src_name = File.basename(src_path)\n src_suffix = File.extname(src_name)\n src_prefix = File.basename(src_name, src_suffix)\n\n Dir.mktmpdir(nil, dst_path) do |tmp_dir|\n # decompress the archive\n cd tmp_dir do\n case src_name.sub(/\\.part$/, '')\n when /\\.(tar\\.gz|tar\\.Z|tgz|taz)$/i\n system 'tar', '-zxf', src_path\n\n when /\\.(tar\\.bz|tar\\.bz2|tbz|tbz2)$/i\n system 'tar', '-jxf', src_path\n\n when /\\.(tar\\.xz|txz)$/i\n system 'tar', '-Jxf', src_path\n\n when /\\.(tar|cpio|gem)$/i\n system 'tar', '-xf', src_path\n\n when /\\.(tar.lzo|tzo)$/i\n system \"lzop -xc #{src_path.inspect} | tar -xf -\"\n\n when /\\.(lzo)$/i\n system 'lzop', '-x', src_path\n\n when /\\.(gz)$/i\n system \"gunzip -c #{src_path.inspect} > #{src_prefix.inspect}\"\n\n when /\\.(bz|bz2)$/i\n system \"bunzip2 -c #{src_path.inspect} > #{src_prefix.inspect}\"\n\n when /\\.(shar)$/i\n system 'sh', src_path\n\n when /\\.(7z)$/i\n system '7zr', 'x', src_path\n\n when /\\.(zip)$/i\n system 'unzip', src_path\n\n when /\\.(jar)$/i\n system 'jar', 'xf', src_path\n\n when /\\.(rz)$/i\n ln src_path, src_name # rzip removes the archive after extraction\n system 'rzip', '-d', src_name\n\n when /\\.(rar)$/i\n system 'unrar', 'x', src_path\n\n when /\\.(ace)$/i\n system 'unace', 'x', src_path\n\n when /\\.(arj)$/i\n system 'arj', 'x', src_path\n\n when /\\.(arc)$/i\n system 'arc', 'x', src_path\n\n when /\\.(lhz|lha)$/i\n system 'lha', 'x', src_path\n\n when /\\.(a|ar)$/i\n system 'ar', '-x', src_path\n\n when /\\.(Z)$/\n system \"uncompress -c #{src_path.inspect} > #{src_prefix.inspect}\"\n\n when /\\.(z)$/\n system \"pcat #{src_path.inspect} > #{src_prefix.inspect}\"\n\n when /\\.(zoo)$/i\n system 'zoo', 'x//', src_path\n\n when /\\.(cab)$/i\n system 'cabextract', src_path\n\n when /\\.(deb)$/i\n system 'ar', 'x', src_path\n\n when /\\.(rpm)$/i\n system \"rpm2cpio #{src_path.inspect} | cpio -i --make-directories\"\n\n else\n warn \"I do not know how to extract #{src_path.inspect}\"\n end\n end\n\n # clean any mess made by decompression\n manifest = Dir.new(tmp_dir).entries - %w[ . .. ]\n\n if manifest.length == 1 # there was no mess!\n adj_dst = File.join(dst_path, manifest.first)\n adj_src = File.join(tmp_dir, manifest.first)\n else\n adj_src = tmp_dir\n adj_dst = File.join(dst_path, src_name[/.*(?=\\..*?)/])\n end\n\n adj_dst << \"+#{Time.now.to_i}\" until\n not File.exist? adj_dst and\n mv(adj_src, adj_dst, :force => true)\n\n touch tmp_dir # give Dir.mktmpdir() something to remove\n\n adj_dst\n end\nend",
"def pack directory_path\n Dir.chdir directory_path\n name = Dir.pwd.split(@fs).last\n files = Dir.glob \"**#{@fs}*\"\n File.open([name, @ext].join(\".\"), \"wb\") do |tar|\n Minitar.pack(files, tar)\n end\n end",
"def tar_gzip(archive, tarfile, pkg_time, distribution = nil,\n logfile: nil)\n\n # Make sure no distribution information leaks into the package\n if distribution and archive =~ /~#{distribution}/\n archive_plain_name = archive.gsub(/~#{distribution}/,\"\")\n FileUtils.cp_r archive, archive_plain_name\n else\n archive_plain_name = archive\n end\n\n\n Packager.info \"Tar archive: #{archive_plain_name} into #{tarfile}\"\n # Make sure that the tar files checksum remains the same by\n # overriding the modification timestamps in the tarball with\n # some external source timestamp and using gzip --no-name\n #\n # exclude hidden files an directories\n mtime = pkg_time.iso8601()\n # Exclude hidden files and directories at top level\n cmd_tar = \"tar --mtime='#{mtime}' --format=gnu -c --exclude '.+' --exclude-backups --exclude-vcs --exclude #{archive_plain_name}/debian --exclude build #{archive_plain_name} | gzip --no-name > #{tarfile}\"\n\n if system(cmd_tar, [:out,:err] => redirection(logfile, \"a\"))\n Packager.info \"Package: successfully created archive using command '#{cmd_tar}' -- pwd #{Dir.pwd} -- #{Dir.glob(\"**\")}\"\n checksum = `sha256sum #{tarfile}`\n Packager.info \"Package: sha256sum: #{checksum}\"\n return true\n else\n Packager.info \"Package: failed to create archive using command '#{cmd_tar}' -- pwd #{Dir.pwd}\"\n return false\n end\n end",
"def archive\n files.each do |path|\n path_obj = Pathname.new(path)\n path_name = path_obj.dirname.to_s\n compress = Kellerkind::Compress.new(:target_path => out,\n :source_path => path,\n :tarball_prefix => path_obj.basename.to_s)\n compress.find_at_source_path = true\n if File.exists?(path)\n Kellerkind::Process.verbose(:start_compressing)\n compress.gzip\n if File.exists?(\"#{path_name}/#{compress.tarball_name}\")\n Kellerkind::Process.verbose(:finished_compressing)\n FileUtils.mv(\"#{path_name}/#{compress.tarball_name}\",\n \"#{out}/#{compress.tarball_name}\")\n FileUtils.rm_rf(path)\n FileUtils.touch(path) if self.recreate\n end\n end\n end\n end",
"def compress(directory, file)\n case compression\n when :gzip, :gz then [\"tar\", \"czf\", file, directory]\n when :bzip2, :bz2 then [\"tar\", \"cjf\", file, directory]\n when :zip then [\"zip\", \"-qr\", file, directory]\n else raise ArgumentError, \"invalid compression type #{compression.inspect}\"\n end\n end",
"def tar_gz_file\n \"#{package_name}.tar.gz\"\n end",
"def tar0(otarfile, *src)\n raise \"no file or directory to tar\" if !src || src.length == 0\n Gem::Package::TarWriter.new otarfile do |tar|\n Find.find *src do |f|\n mode = File.stat(f).mode\n if File.directory? f\n tar.mkdir f, mode\n else\n tar.add_file f, mode do |tio|\n File.open f, 'r' do |io|\n tio.write io.read\n end\n end\n end\n end\n end\n end",
"def compress_output(codec, type)\n properties['mapred.output.compress'] = 'true'\n properties['mapred.output.compression.codec'] = case codec\n when :default then Java::OrgApacheHadoopIoCompress::DefaultCodec.java_class.name\n when :gzip then Java::OrgApacheHadoopIoCompress::GzipCodec.java_class.name\n else raise \"Codec #{codec} not yet supported by cascading.jruby\"\n end\n properties['mapred.output.compression.type'] = case type\n when :none then Java::OrgApacheHadoopIo::SequenceFile::CompressionType::NONE.to_s\n when :record then Java::OrgApacheHadoopIo::SequenceFile::CompressionType::RECORD.to_s\n when :block then Java::OrgApacheHadoopIo::SequenceFile::CompressionType::BLOCK.to_s\n else raise \"Compression type '#{type}' not supported\"\n end\n end",
"def tarball\n Dir[\"#{dest}/#{SCOPE}-#{gemspec.name}-#{gemspec.version}.tgz\"].first\n end",
"def tgz___( directory, filename )\r\n raise StandardError, \"Under investigation\" \r\n got = @ndev.rpc.file_archive( :destination => filename, :source => directory, :compress => true )\r\n end",
"def open_output(path)\n case path.extname\n when \".gz\"\n Zlib::GzipWriter.open(path.to_s)\n # when \".gz\"\n # ::IO.popen(\"gzip -c > #{path}\", \"w\")\n else\n path.open(\"wb\")\n end\n end",
"def tar(path)\n tar_filename = Pathname.new(path).realpath.to_path + '.tar'\n File.open(tar_filename, 'wb') do |tarfile|\n get_files_to_pack(path).each do |file|\n if File.file?(file)\n File.open(file, 'rb') do |f|\n while buffer = f.read(BLOCKSIZE_TO_READ)\n tarfile.write buffer\n end\n end\n else\n tarfile.write file.gsub(path, '')\n end\n end\n end\n\n tar_filename\n\n end",
"def to_dta(out_folder=nil, compress=nil)\n outdir = \n if out_folder ; out_folder\n else base_name\n end\n\n case compress\n when :tgz\n begin\n require 'archive/tar/minitar'\n rescue LoadError\n abort \"need gem 'archive-tar-minitar' installed' for tgz compression!\\n#{$!}\"\n end\n require 'archive/targz' # my own simplified interface!\n require 'zlib'\n names = index.map do |i_ar|\n [outdir, '/', [base_name, *i_ar].join('.'), '.dta'].join('')\n end\n #Archive::Targz.archive_as_files(outdir + '.tgz', names, dta_file_data)\n\n tgz = Zlib::GzipWriter.new(File.open(outdir + '.tgz', 'wb'))\n\n Archive::Tar::Minitar::Output.open(tgz) do |outp|\n dta_files.each_with_index do |dta_file, i|\n Archive::Tar::Minitar.pack_as_file(names[i], dta_file.to_dta_file_data, outp)\n end\n end\n when :zip\n begin\n require 'zip/zipfilesystem'\n rescue LoadError\n abort \"need gem 'rubyzip' installed' for zip compression!\\n#{$!}\"\n end\n #begin ; require 'zip/zipfilesystem' ; rescue LoadError, \"need gem 'rubyzip' installed' for zip compression!\\n#{$!}\" ; end\n Zip::ZipFile.open(outdir + \".zip\", Zip::ZipFile::CREATE) do |zfs|\n dta_files.zip(index) do |dta,i_ar|\n #zfs.mkdir(outdir)\n zfs.get_output_stream(outdir + '/' + [base_name, *i_ar].join('.') + '.dta') do |out|\n dta.write_dta_file(out)\n #zfs.commit\n end\n end\n end\n else # no compression\n FileUtils.mkpath(outdir)\n Dir.chdir(outdir) do\n dta_files.zip(index) do |dta,i_ar|\n File.open([base_name, *i_ar].join('.') << '.dta', 'wb') do |out|\n dta.write_dta_file(out)\n end\n end\n end\n end\n end",
"def output(output_path)\n output_check(output_path)\n\n # Copy all files from staging to BUILD dir\n Find.find(staging_path) do |path|\n src = path.gsub(/^#{staging_path}/, '')\n dst = build_path(src)\n begin\n copy_entry(path, dst, preserve=true, remove_destination=true)\n rescue\n copy_entry(path, dst, preserve=false, remove_destination=true)\n end\n copy_metadata(path, dst)\n end\n\n # This value is used later in the template for PKGINFO\n size = safesystemout(\"du\", \"-sk\", build_path).split(/\\s+/)[0].to_i * 1024\n builddate = Time.new.to_i\n\n pkginfo = template(\"pacman.erb\").result(binding)\n pkginfo_file = build_path(\".PKGINFO\")\n File.write(pkginfo_file, pkginfo)\n\n if script?(:before_install) or script?(:after_install) or \\\n script?(:before_upgrade) or script?(:after_upgrade) or \\\n script?(:before_remove) or script?(:after_remove)\n install_script = template(\"pacman/INSTALL.erb\").result(binding)\n install_script_file = build_path(\".INSTALL\")\n File.write(install_script_file, install_script)\n end\n\n generate_mtree\n\n File.expand_path(output_path).tap do |path|\n ::Dir.chdir(build_path) do\n safesystem(*([tar_cmd,\n compression_option,\n \"-cf\",\n path] + data_tar_flags + \\\n ::Dir.entries(\".\").reject{|entry| entry =~ /^\\.{1,2}$/ }))\n end\n end\n end",
"def compression; end",
"def compression\n type = configuration[:copy_compression] || :gzip\n case type\n when :gzip, :gz then Compression.new(\"tar.gz\", %w(tar czf), %w(tar xzf))\n when :bzip2, :bz2 then Compression.new(\"tar.bz2\", %w(tar cjf), %w(tar xjf))\n when :zip then Compression.new(\"zip\", %w(zip -qr), %w(unzip -q))\n else raise ArgumentError, \"invalid compression type #{type.inspect}\"\n end\n end",
"def output_package(pkg_type)\n case pkg_type\n when 'makeself'\n \"#{package_name}-#{build_version}_#{iteration}.sh\"\n when 'msi'\n Packager::WindowsMsi.new(self).package_name\n when 'bff'\n \"#{package_name}.#{bff_version}.bff\"\n when 'pkgmk'\n \"#{package_name}-#{build_version}-#{iteration}.solaris\"\n when 'mac_pkg'\n Packager::MacPkg.new(self).package_name\n when 'mac_dmg'\n pkg = Packager::MacPkg.new(self)\n Packager::MacDmg.new(pkg).package_name\n else # fpm\n require \"fpm/package/#{pkg_type}\"\n pkg = FPM::Package.types[pkg_type].new\n pkg.version = build_version\n pkg.name = package_name\n pkg.iteration = iteration\n if pkg_type == 'solaris'\n pkg.to_s('NAME.FULLVERSION.ARCH.TYPE')\n else\n pkg.to_s\n end\n end\n end",
"def archive_package(location, output)\n handler = Package::PackageReader.read(location)\n cache_location = Package::PackageCache.directory_cache(handler.digest)\n\n # make archiver\n archiver = Package::PackageArchiver.new(cache_location)\n\n # archive\n return archiver.archive(model[:output], false)\n end",
"def write\n File.delete(@output_file) if File.exist?(@output_file)\n\n Zip::File.open(@output_file, Zip::File::CREATE) do |zipfile|\n zipfile.add(mimetype_entry(zipfile), \"#{@input_dir}/mimetype\")\n\n all_entries.each do |file|\n zipfile.add(file, \"#{@input_dir}/#{file}\")\n end\n end\n end",
"def tar_gz(filename, basename)\n # TODO: detect if there's an appropriately-named subdirectory within. If not, then make/cd into it.\n exec_and_return_output_array(\"tar -xvvzf #{filename}\")\n puts basename\n # puts 'filename - without extension'\nend",
"def make_tarball dir, options={}\n options[:filename] = options[:filename] || \"#{dir}.tar.gz\"\n make_tarball_from_files [dir], options\nend",
"def compress_directory dir\n if File.directory? dir\n puts \"# - Compressing directory: #{dir}\"\n dir_compressed_name = dir.sub(\".\",'').sub(\"/\",'').gsub(\"/\", '_')[0..-2]\n system(\"tar\",\"-pczf\",\"#{dir_compressed_name}.tar.gz\", \"#{dir}\") if File.exist? dir\n \"#{dir_compressed_name}.tar.gz\"\n else\n raise \"Could not compress the following directory: #{dir}\"\n end\nend",
"def tgz_file\n \"#{package_name}.tgz\"\n end",
"def is_tgz? archive, type=nil\n type == :tgz || !archive.match(/\\.tgz$/).nil? || !archive.match(/\\.tar.gz$/).nil?\n end",
"def tar___( directory, filename )\r\n raise StandardError, \"Under investigation\"\r\n got = @ndev.rpc.file_archive( :destination => filename, :source => directory )\r\n end",
"def tar_bz2_file\n \"#{package_name}.tar.bz2\"\n end",
"def output\n super(@file_format => @file_path)\n end",
"def compression_extension\n case compression\n when :gzip, :gz then \"tar.gz\"\n when :bzip2, :bz2 then \"tar.bz2\"\n when :zip then \"zip\"\n else raise ArgumentError, \"invalid compression type #{compression.inspect}\"\n end\n end",
"def output(base_uri, input_name, output_name, options, gif, output_folder)\n base_uri = base_uri + 'output/'\n if gif\n else\n Dir.mkdir(base_uri) unless Dir.exist?(base_uri)\n end\n\n if output_name.nil?\n rando = '_' + (0...4).map { 65.+(rand(26)).chr }.join.downcase\n settings_file = File.new(base_uri + input_name + rando + '.txt', 'w')\n settings_file.puts(options.to_s)\n settings_file.close\n base_uri + input_name + rando + '.png'\n elsif gif || output_folder\n @base_uri = base_uri + \"#{input_name}/\"\n # needs to be refactored to create an output folder instead of a sequence folder\n FileUtils.mkdir_p(@sequence_folder) unless Dir.exist?(@sequence_folder)\n settings_file = File.new(@sequence_folder + output_name + '.txt', 'w')\n settings_file.puts(options.to_s)\n settings_file.close\n @sequence_folder + output_name + '.png'\n elsif !gif && !output_folder\n settings_file = File.new(base_uri + output_name + '.txt', 'w')\n settings_file.puts(options.to_s)\n settings_file.close\n base_uri + output_name + '.png'\n end\n end",
"def make_tarball(destination, conf,curDir)\n\tDir.chdir(curDir)\n\n gzip = Zlib::GzipWriter.new(File.open(destination, 'wb'))\n tar = Minitar::Output.new(gzip)\n\t conf[:zipFiles].each { |f|\tMinitar.pack_file(f, tar) }\n tar.close\n\n conf[:backupSize]=File.size(destination) #remember archive size\nend",
"def package_name\n @package_name ||=\n Pathname(\"#{cartage.final_name}.tar#{cartage.tar_compression_extension}\")\n end",
"def assemble_tgz\n banner \"Assembling #{TAR}...\"\n rm_and_mkdir(DIR)\n \n # gem\n run(\"cp\", [\"-r\", \"#{File.dirname(__FILE__)}/../../lib\", GEM])\n # data\n mkdir(DATA)\n copy = []\n copy << \"Telfile\"\n copy += Dir[\"files*\"]\n copy.sort.each { |i| run(\"cp\", [\"-r\", i, DATA]) }\n # config.sh\n File.open(\"#{DIR}/config\", \"w\") do |f|\n f.puts(\"CONFIG_HOST='#{@options[:host]}'\") \n f.puts(\"CONFIG_RUBY='#{@config.ruby}'\")\n f.puts(\"CONFIG_RUBYGEMS='#{RUBYGEMS}'\") \n end\n # keys\n ssh_key = \"#{ENV[\"HOME\"]}/.ssh/#{PUBKEY}\"\n if File.exists?(ssh_key)\n run(\"cp\", [ssh_key, DIR])\n end\n \n Dir.chdir(File.dirname(DIR)) do\n run(\"tar\", [\"cfpz\", TAR, File.basename(DIR)])\n end\n end",
"def format\n (gzip?? path.basename(path.extname) : path).extname[1..-1].downcase.to_sym\n end",
"def test_tar\n\tx = \"test_tar\"\n\t@output = @s.archive({ 'files'=> [@test_directory_1_Path], 'format'=>'tar' , 'recurse'=>false } )\n\t#puts @output['archiveFile']\n\t\n\t@testid= 1\n\tTar.open(@output['archiveFile'], File::RDONLY, 0644, Tar::GNU | Tar::VERBOSE) do |tar|\n while tar.read # or 'tar.each do ...'\n #puts tar.pathname\n\t\t\n\t\t\n # tar.print_long_ls\n\n if tar.reg? && tar.pathname!=\"test_directory_1/.DS_Store\" # regular file\n tar.extract_file('test')\n\t\t want = File.read(File.join(@testdir, tar.pathname))\n\t\t puts tar.pathname\n\t\t #asserting bar1,2,3 from tar file is same as original bar1,2,3\n\t\t assert_log( want, File.read('test'), $log, x, @testid)\n end\n end\n\n ##if extract all files\n #tar.extract_all\n end\n\n\n ##for gzip archive\n #Tar.gzopen('foo.tar.gz', ...\n\n ##for bzip2 archive\n #Tar.bzopen('foo.tar.bz2', ...\n \n \n \n end",
"def compression_method; end",
"def should_archive_file?\n true\n end",
"def default_compression=(_arg0); end",
"def prepare\r\n # if output_dir is not specified, output in the same directory\r\n # as the imput file\r\n @output_dir = File.dirname(@input_file) if !@output_dir && @input_file\r\n\r\n if /.bz2$/ =~ @input_file\r\n if @bz2_gem\r\n file = Bzip2::Reader.new File.open(@input_file, \"r:UTF-8\")\r\n elsif Gem.win_platform?\r\n file = IO.popen(\"bunzip2.exe -c #{@input_file}\")\r\n elsif (bzpath = command_exist?(\"lbzip2\") || command_exist?(\"pbzip2\") || command_exist?(\"bzip2\"))\r\n file = IO.popen(\"#{bzpath} -c -d #{@input_file}\")\r\n end\r\n else # meaning that it is a text file\r\n @infile_size = File.stat(@input_file).size\r\n file = open(@input_file)\r\n end\r\n\r\n # create basename of output file\r\n @outfile_base = File.basename(@input_file, \".*\") + \"-\"\r\n @total_size = 0\r\n @file_index = 1\r\n outfilename = File.join(@output_dir, @outfile_base + @file_index.to_s)\r\n @outfiles = []\r\n @outfiles << outfilename\r\n @fp = File.open(outfilename, \"w\")\r\n @file_pointer = file\r\n true\r\n end",
"def untar_file(f, to)\n end",
"def pack(input_path, output_path, algorithm)\n\n\t\t# open input, convert to binary\n\t\tin_file = File.read(input_path)\n\t\tin_file.each_line do |line|\n\t\t\t@pre << line.to_binary(@pre_size)\n\t\tend\n\n\t\t# run compression algorithm\n\t\tcase algorithm\n\t\t\twhen :rle\n\t\t\t\t@post = rle_pack(@pre, true)\n\t\t\twhen :lz78\n\t\t\t\t@post = lz78_pack(@pre)\n\t\t\twhen :huff\n\t\t\t\t@post = huff_pack(@pre)\n\t\tend\n\n\t\t# open output, write binary\n\t\tout_file = File.open(output_path, 'wb')\n\t\[email protected] do |byte|\n\t\t\tout_file.write byte\n\t\tend\n\n\tend",
"def create_tar_gz_file(gz_base_file_name, source_file)\n gz_name = \"#{gz_base_file_name}.tar.gz\"\n cmd = \"tar -czf #{gz_name} #{source_file}\"\n system(cmd)\n gz_name\n end",
"def output_package(pkg_type)\n case pkg_type\n when 'makeself'\n Packager::Makeself.new(self).package_name\n when 'msi'\n Packager::MSI.new(self).package_name\n when 'bff'\n Packager::BFF.new(self).package_name\n when 'solaris'\n Packager::Solaris.new(self).package_name\n when 'pkg'\n Packager::PKG.new(self).package_name\n when 'mac_dmg'\n pkg = Packager::PKG.new(self)\n Packager::MacDmg.new(pkg).package_name\n when 'rpm'\n Packager::RPM.new(self).package_name\n when 'deb'\n Packager::DEB.new(self).package_name\n else\n raise RuntimeError, \"I do not know how to build a `#{pkg_type}'!\"\n end\n end",
"def extract_pack\n io = Zlib::GzipReader.new(DataDragon.data_pack_path.open)\n\n Gem::Package::TarReader.new(io) do |tar|\n tar.each do |tarfile|\n destination_file = (DataDragon.data_unpacked_path + tarfile.full_name)\n\n if tarfile.directory?\n destination_file.mkpath\n else\n destination_directory = destination_file.dirname\n destination_directory.mkpath unless destination_directory.directory?\n destination_file.write(tarfile.read)\n end\n end\n end\n end",
"def comp_to(input_dir, output_file)\n @input_dir = input_dir\n # @input_dir = @input_dir\n @output_file = output_file\n\n if File.exists? @output_file\n FileUtils.rm @output_file\n puts \"\\ndeleting existing Comp file: #{@output_file}\"\n end\n # File.open(output_file, 'w')\n entries = Dir.entries(@input_dir); entries.delete(\".\"); entries.delete(\"..\")\n io = Zip::ZipFile.open(@output_file, Zip::ZipFile::CREATE)\n\n write_entries(entries, \"\", io)\n io.close\n puts \"\\n'#{output_file}' comped!\\n\\n\"\n end",
"def tar_xz_file\n \"#{package_name}.tar.xz\"\n end",
"def make_tarball_from_files files, options={}\n tarball = options[:filename]\n args = ['czf', tarball, '--exclude-vcs']\n exclude_each options[:exclude] do |exclude|\n args.push '--exclude', exclude\n end\n args.concat files\n run 'tar', *args\n release tarball, :cd => 1\nend",
"def extract_tar_gz\n Gem::Package::TarReader.new(Zlib::GzipReader.open(base.package)) do |tar|\n\n # Progressbar\n progressbar = ProgressBar.create(format: PROGRESSBAR_FORMAT, total: tar.count)\n\n # tar.count move position pointer to end\n tar.rewind\n\n dest_file = nil\n tar.each do |entry|\n if entry.full_name == TAR_LONGLINK\n dest_file = File.join(@tmpdir, entry.read.strip)\n next\n end\n dest_file ||= File.join(@tmpdir, entry.full_name)\n if entry.directory?\n FileUtils.rm_rf(dest_file) unless File.directory?(dest_file)\n FileUtils.mkdir_p(dest_file, mode: entry.header.mode, verbose: false)\n elsif entry.file?\n FileUtils.rm_rf(dest_file) unless File.file?(dest_file)\n File.open(dest_file, 'wb') do |f|\n f.write(entry.read)\n end\n FileUtils.chmod(entry.header.mode, dest_file, verbose: false)\n elsif entry.header.typeflag == '2' # symlink\n File.symlink(entry.header.linkname, dest_file)\n end\n\n dest_file = nil\n progressbar.increment\n end\n end\n end",
"def decompress_package(package)\n @logger.info \"Decompressing #{package.path}\\nto #{@target_location}\"\n FileUtils.mkdir_p(@target_location)\n Dir.chdir(@target_location) do\n # Clear out existing package\n FileUtils.rm_rf Dir.glob(\"#{@target_location}/*\")\n RakeUtils.system \"tar -zxf #{package.path}\"\n end\n @logger.info \"Decompressed\"\n end",
"def archive(target = nil, &block)\n require 'rubygems/package'\n unless target\n target = parent.file(\"#{name}.tar\")\n end\n target.write_binary do |io|\n writer = Gem::Package::TarWriter.new(io) do |tar_io|\n archive_dir(tar_io, self, &block)\n end\n end\n target\n end",
"def setup_outputs_for(input_file_path)\n file_name_without_extension = File.basename(input_file_path, '.*')\n outputs = (exporters || Tracksperanto.exporters).map do | exporter_class |\n export_name = [file_name_without_extension, exporter_class.desc_and_extension].join(\"_\")\n export_path = File.join(File.dirname(input_file_path), export_name)\n exporter_class.new(open_owned_export_file(export_path))\n end\n \n Tracksperanto::Export::Mux.new(outputs)\n end",
"def create_tarball\n out_file = filename(@conference, @locale)\n if File.exist? out_file\n File.unlink out_file\n end\n system( 'tar', *['-cpz', '-f', out_file.to_s, '-C', @destination, @conference.acronym].flatten )\n out_file.to_s\n end",
"def untar_file(f, to)\n line(\"tar\", \"-xf {file} -C {path}\").pass(file: f, path: to)\n end",
"def compressor; end",
"def outputFN( input )\n # First: if we are in a temp folder put it where the script is... \n # otherwise we drop it in the temp folder. This only happens with OCRA.\n tmp = /\\W(temp|tmp)\\W/i\n inreg = /\\Win(put)?$/i\n\n if File.dirname( input ) =~ inreg\n File.expand_path( File.join( File.dirname( input ), \"..\", \"out\" , File.basename( input, \".py\" ) ) )\n elsif tmp =~ File.dirname( __FILE__ )\n if tmp =~ File.dirname( input )\n \"\" # they can choose a directory manually\n else\n File.join File.dirname( input ), File.basename( input, \".py\" )\n end\n else\n File.join File.dirname( __FILE__ ), \"out\", File.basename( input, \".py\" ) \n end\nend",
"def extract\n # Only used by tar\n compression_switch = \"\"\n compression_switch = \"z\" if downloaded_file.end_with?(\"gz\")\n compression_switch = \"--lzma -\" if downloaded_file.end_with?(\"lzma\")\n compression_switch = \"j\" if downloaded_file.end_with?(\"bz2\")\n compression_switch = \"J\" if downloaded_file.end_with?(\"xz\")\n\n if Ohai[\"platform\"] == \"windows\"\n if downloaded_file.end_with?(*TAR_EXTENSIONS) && source[:extract] != :seven_zip\n returns = [0]\n returns << 1 if source[:extract] == :lax_tar\n\n shellout!(\"tar #{compression_switch}xf #{downloaded_file} --force-local -C#{project_dir}\", returns: returns)\n elsif downloaded_file.end_with?(*COMPRESSED_TAR_EXTENSIONS)\n Dir.mktmpdir do |temp_dir|\n log.debug(log_key) { \"Temporarily extracting `#{safe_downloaded_file}' to `#{temp_dir}'\" }\n\n shellout!(\"7z.exe x #{safe_downloaded_file} -o#{windows_safe_path(temp_dir)} -r -y\")\n\n fname = File.basename(downloaded_file, File.extname(downloaded_file))\n fname << \".tar\" if downloaded_file.end_with?(\"tgz\", \"txz\")\n next_file = windows_safe_path(File.join(temp_dir, fname))\n\n log.debug(log_key) { \"Temporarily extracting `#{next_file}' to `#{safe_project_dir}'\" }\n shellout!(\"7z.exe x #{next_file} -o#{safe_project_dir} -r -y\")\n end\n else\n shellout!(\"7z.exe x #{safe_downloaded_file} -o#{safe_project_dir} -r -y\")\n end\n elsif downloaded_file.end_with?(\".7z\")\n shellout!(\"7z x #{safe_downloaded_file} -o#{safe_project_dir} -r -y\")\n elsif downloaded_file.end_with?(\".zip\")\n shellout!(\"unzip #{safe_downloaded_file} -d #{safe_project_dir}\")\n else\n shellout!(\"#{tar} #{compression_switch}xf #{safe_downloaded_file} -C#{safe_project_dir}\")\n end\n end",
"def default_compression; end",
"def generate input_dir, output_dir, templates_dir\n\n backup_output_directory(output_dir)\n metadata = read_input_directory(input_dir)\n create_tree_and_copy_assets(metadata, input_dir, output_dir)\n inflate_content(metadata, metadata, input_dir, output_dir, templates_dir)\n\n # Return metadata, e.g. for RSS Feed\n metadata\n end",
"def compress(src_path, archive_path)\n src_dir = File.dirname( File.expand_path( src_path ) )\n src_file = File.basename( src_path )\n archive_path = File.expand_path( archive_path )\n dest_dir = File.dirname( archive_path )\n\n puts \"src_dir: #{src_dir}\"\n puts \"src_path: #{src_path}\"\n puts \"dest_dir: #{dest_dir}\"\n puts \"archive_path: #{archive_path}\"\n\n # Create the destination dir if it doesn't exist.\n if( !File.exists?( dest_dir ) )\n File.makedirs( dest_dir, true )\n end\n\n cmd_line = \"-tzip u #{archive_path} #{src_path}\"\n\n cur_dir = pwd\n cd( src_dir )\n begin\n execute( cmd_line, false )\n rescue\n # do nothing\n end\n cd( cur_dir )\n end",
"def process_input\n if @process == 'directory'\n process_directory\n elsif @process == 'file'\n process_compiled_file\n elsif @process == 'zip'\n process_zip_file\n elsif @process == 'zip-stream'\n process_zip_stream\n end\n end",
"def comp(input_dir, output_file)\n @inputDir = input_dir\n # @input_dir = @inputDir\n @outputFile = output_file\n FileUtils.rm @outputFile if File.exists? @outputFile\n # File.open(output_file, 'w')\n entries = Dir.entries(@inputDir); entries.delete(\".\"); entries.delete(\"..\")\n io = Zip::File.open(@outputFile, Zip::File::CREATE)\n\n writeEntries(entries, \"\", io)\n io.close\n puts \"\\n#{output_file} chaching!\\n\\n\"\n end",
"def decompress(file)\n case compression\n when :gzip, :gz then [\"tar\", \"xzf\", file]\n when :bzip2, :bz2 then [\"tar\", \"xjf\", file]\n when :zip then [\"unzip\", \"-q\", file]\n else raise ArgumentError, \"invalid compression type #{compression.inspect}\"\n end\n end",
"def archive_repo(ref, storage_path, format = \"tar.gz\")\n ref ||= root_ref\n\n file_path = archive_file_path(ref, storage_path, format)\n return nil unless file_path\n\n return file_path if File.exist?(file_path)\n\n case format\n when \"tar.bz2\", \"tbz\", \"tbz2\", \"tb2\", \"bz2\"\n compress_cmd = %W(bzip2)\n when \"tar\"\n compress_cmd = %W(cat)\n when \"zip\"\n git_archive_format = \"zip\"\n compress_cmd = %W(cat)\n else\n # everything else should fall back to tar.gz\n compress_cmd = %W(gzip -n)\n end\n\n FileUtils.mkdir_p File.dirname(file_path)\n\n pid_file_path = archive_pid_file_path(ref, storage_path, format)\n return file_path if File.exist?(pid_file_path)\n\n File.open(pid_file_path, \"w\") do |file|\n file.puts Process.pid\n end\n\n # Create the archive in temp file, to avoid leaving a corrupt archive\n # to be downloaded by the next user if we get interrupted while\n # creating the archive.\n temp_file_path = \"#{file_path}.#{Process.pid}-#{Time.now.to_i}\"\n\n begin\n archive_to_file(ref, temp_file_path, git_archive_format, compress_cmd)\n rescue\n FileUtils.rm(temp_file_path)\n raise\n ensure\n FileUtils.rm(pid_file_path)\n end\n\n # move temp file to persisted location\n FileUtils.move(temp_file_path, file_path)\n\n file_path\n end",
"def untgzp(file, location)\n if file[-7..-1] != \".tar.gz\"\n print \"ERROR: expected a tar.gz file: #{file}\\n\"\n exit\n end\n if os_short() == 'sunos'\n tar = \"gtar\"\n else\n tar = \"#{bin('tar')}\"\n end\n sh \"#{tar} --directory #{location} -xf #{file}\"\nend",
"def should_unpack_tgz? dir, clobber=nil\n return !directory_has_children?(dir) || clobber == :clobber\n\n end",
"def to_output_path(output_path) #:nodoc:\n unless @output_path\n if output_path\n @output_path = output_path\n else \n @output_path = parse_nil_path(@input)\n end\n @args << \"--output\"\n @args << @output_path\n end\n end",
"def write\n FileUtils.rm @out_file if File.exists? @out_file\n in_progress \"Writing archive #{@out_file} from #{@input_dir}\" do\n Zip::File.open @out_file, Zip::File::CREATE do |zipfile|\n Dir[\"#{@input_dir}/**/**\"].reject{ |f| f == @out_file || [email protected](f) }.each do |file|\n progress \"deflating #{file}\"\n zipfile.add(file.sub(@input_dir + '/', ''), file)\n end\n end\n end\n end",
"def compress!; end",
"def generate_tar_file(path_to_file)\n tar_path = temp_path(path_to_file)\n command = \"tar --create --format=gnu --preserve-permissions --absolute-names --file=#{tar_path} #{path_to_file}\"\n bash_out(command)\n return tar_path\n end",
"def tar_path\n File.expand_path(@env[\"package.output\"], FileUtils.pwd)\n end",
"def targz(targzfile, *src)\n raise \"tar.gz file #{targzfile} shouldn't be a directory\" if File.directory? targzfile\n Zlib::GzipWriter.open targzfile do |otarfile|\n tar0(otarfile, *src)\n end\n end",
"def package(path, target)\n # Load manifest\n puts \"Load manifest...\"\n manifest = YAML::load_file(File.join(path, 'manifest.yml'))\n \n # Target directory for package files\n puts \"Target is: #{target}\"\n Dir.mkdir(target) if not File.exists?(target)\n \n # Package name\n package = \"#{manifest['name']}-#{manifest['version']}\"\n puts \"Package: #{package}\"\n \n # Tgz\n manifest['package'] = \"#{package}.tgz\"\n command = \"tar -czf #{package}.tgz --exclude pkg -C #{path} .\"\n puts \"Packing: #{command}\"\n system command\n \n # Move\n puts \"Finishing..\"\n FileUtils.mv(\"#{package}.tgz\", target)\n File.open(File.join(target, \"#{package}.yml\"), 'w') do |f|\n f.puts(manifest.to_yaml)\n f.close\n end\n \n puts \"Done.\"\nend",
"def untar(io, destination)\n tarfile_full_name = nil\n Gem::Package::TarReader.new io do |tar|\n tar.each do |tarfile|\n tarfile_full_name ||= tarfile.full_name\n destination_file = File.join destination, tarfile.full_name\n if tarfile.directory?\n FileUtils.mkdir_p destination_file\n else\n destination_directory = File.dirname(destination_file)\n FileUtils.mkdir_p destination_directory unless File.directory?(destination_directory)\n File.open destination_file, \"wb\" do |f|\n f.write tarfile.read\n end\n end\n end\n end\n tarfile_full_name\n end",
"def decompress_file(file, to)\n Supernova.logger.info { \"Decompressing file #{file} to directory #{to}...\" }\n FileUtils.mkpath(to)\n\n data = line(\"file\", \"--mime-type {file}\").pass(file: file)\n mime = data.stdout.split(': ')[1]\n\n case mime\n when \"application/x-gzip\"\n untar_file(file, to)\n when \"application/zip\"\n unzip_file(file, to)\n when \"application/x-7z-compressed\"\n unszip_file(file, to)\n else\n Supernova.logger.error { \"Unknown file type: #{mime}\" }\n end\n end",
"def archive(sources_dir, dest_dir, dest_file_name)\n Siba::Archive::Tar::Archive.check_compression_type compression\n\n options = get_tar_option\n extension = Archive.get_tar_extension compression\n\n archive_name = \"#{dest_file_name}.tar#{extension}\"\n archive_path = File.join(dest_dir, archive_name)\n siba_file.run_this do\n raise Siba::Error, \"Archive file already exists: #{archive_path}\" if siba_file.file_file?(archive_path) || siba_file.file_directory?(archive_path)\n\n siba_file.file_utils_cd dest_dir\n command_text = %(tar c#{options}f #{archive_name} -C \"#{sources_dir}\" .)\n # Using -C 'change directory' option to make it work on Windows\n # because Windows will not understand absolute path to tar: \"tar cf c:\\dir\\file.tar .\"\n siba_file.run_shell command_text, \"Failed to archive: #{command_text}\"\n raise Siba::Error, \"Failed to create archive: #{command_text}\" unless siba_file.file_file?(archive_path)\n end\n archive_name\n end",
"def format_file\n archiveFormat = @archive.to_s.split('\\n')\n archiveFormat.shift()\n archiveFormat.shift()\n archiveFormat.shift()\n archiveFormat.shift()\n archiveFormat.pop()\n archiveFormat.pop()\n archiveFormat\n end",
"def untar(io, destination)\n tarfile_full_name = nil\n Gem::Package::TarReader.new io do |tar|\n tar.each do |tarfile|\n tarfile_full_name ||= tarfile.full_name\n destination_file = File.join destination, tarfile.full_name\n\n if tarfile.directory?\n FileUtils.mkdir_p destination_file\n else\n destination_directory = File.dirname(destination_file)\n FileUtils.mkdir_p destination_directory unless File.directory?(destination_directory)\n File.open destination_file, \"wb\" do |f|\n f.write tarfile.read\n end\n end\n end\n end\n tarfile_full_name\n end",
"def print_archive(filename)\n header = Enumerator.new do |out|\n out << \"Contents of: #{filename}\"\n end\n\n header + (\n case filename\n when /\\.tar\\.zst$/\n depends bins: \"zstd\"\n run(\"tar\", \"-Izstd\", \"-tvf\", filename)\n else\n depends bins: \"atool\"\n run(\"atool\", \"-l\", filename)\n end\n )\nend",
"def write\n entries = Dir.entries(@input_dir); entries.delete(\".\"); entries.delete('..')\n io = Zip::File.open(@server_pack_file, Zip::File::CREATE)\n write_entries(entries, '', io)\n io.close\n end",
"def compress\n scheme + compressed_path\n end",
"def tar_metrics_files\n v = (@verbose ? \"v\" : \"\")\n comm = \"tar cz#{v}f #{@output_dir}/#{@tar_file_name} -C #{@parent_staging_dir} .\"\n puts \"Tarring metrics with: #{comm}\" if @verbose\n system(comm)\n puts \"Created #{@output_dir}/#{@tar_file_name}\"\n end",
"def package_files\n Dir.mktmpdir {|tmpdir|\n @stemcell_files.flatten.each {|file| FileUtils.cp(file, tmpdir) if file && File.exists?(file) } # only copy files that are not nil\n Dir.chdir(tmpdir) do\n @logger.info(\"Package #@stemcell_files to #@target ...\")\n sh \"tar -czf #@target *\", {:on_error => \"unable to package #@stemcell_files into a stemcell\"}\n end\n }\n @target\n end",
"def package_files\n Dir.mktmpdir {|tmpdir|\n @stemcell_files.flatten.each {|file| FileUtils.cp(file, tmpdir) if file && File.exists?(file) } # only copy files that are not nil\n Dir.chdir(tmpdir) do\n @logger.info(\"Package #@stemcell_files to #@target ...\")\n sh \"tar -czf #@target *\", {:on_error => \"unable to package #@stemcell_files into a stemcell\"}\n end\n }\n @target\n end"
] | [
"0.62581843",
"0.6246144",
"0.6199679",
"0.61615384",
"0.6094651",
"0.608722",
"0.60778046",
"0.6067217",
"0.6024236",
"0.5979973",
"0.59264624",
"0.58868015",
"0.5874518",
"0.5846321",
"0.5844277",
"0.58330256",
"0.5818472",
"0.58160794",
"0.5793206",
"0.5776569",
"0.57631993",
"0.574526",
"0.5733916",
"0.57178086",
"0.5717688",
"0.571576",
"0.57068825",
"0.5686219",
"0.568603",
"0.5615712",
"0.5601977",
"0.558762",
"0.55823195",
"0.5579531",
"0.55734414",
"0.5560052",
"0.55554694",
"0.5540664",
"0.5493926",
"0.5456365",
"0.545594",
"0.54554904",
"0.54542905",
"0.54435337",
"0.54215276",
"0.5404524",
"0.53937995",
"0.53776723",
"0.5358949",
"0.5357503",
"0.533187",
"0.5324818",
"0.53114605",
"0.5309329",
"0.53022605",
"0.5301195",
"0.52914953",
"0.5284798",
"0.5264647",
"0.5263876",
"0.52541727",
"0.52447206",
"0.5240615",
"0.5240082",
"0.5235014",
"0.52338403",
"0.5229708",
"0.5227961",
"0.52179575",
"0.52086055",
"0.5193449",
"0.5193242",
"0.51861364",
"0.51797867",
"0.5174586",
"0.51662076",
"0.51643056",
"0.5154016",
"0.51490396",
"0.5147311",
"0.5142941",
"0.51266736",
"0.5121343",
"0.51083076",
"0.5104095",
"0.510297",
"0.50968856",
"0.50937325",
"0.5092423",
"0.50862896",
"0.5083847",
"0.50833327",
"0.50688094",
"0.5068183",
"0.5063462",
"0.50603026",
"0.5051517",
"0.5043997",
"0.5002353",
"0.5002353"
] | 0.54078996 | 45 |
def output Generate the proper tar flags based on the path name. | def tar_compression_flag(path)
case path
when /\.tar\.bz2$/
return "-j"
when /\.tar\.gz$|\.tgz$/
return "-z"
when /\.tar\.xz$/
return "-J"
else
return nil
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_tar_file(path_to_file)\n tar_path = temp_path(path_to_file)\n command = \"tar --create --format=gnu --preserve-permissions --absolute-names --file=#{tar_path} #{path_to_file}\"\n bash_out(command)\n return tar_path\n end",
"def tar_compression_flag\n case compression\n when :bzip2, \"bzip2\", nil\n \"j\"\n when :gzip, \"gzip\"\n \"z\"\n when :none, \"none\"\n \"\"\n end\n end",
"def tar_metrics_files\n v = (@verbose ? \"v\" : \"\")\n comm = \"tar cz#{v}f #{@output_dir}/#{@tar_file_name} -C #{@parent_staging_dir} .\"\n puts \"Tarring metrics with: #{comm}\" if @verbose\n system(comm)\n puts \"Created #{@output_dir}/#{@tar_file_name}\"\n end",
"def compressFiles\n Dir.chdir(\"#{@outputDir}/RDPsummary\")\n #system(\"tar -zcf #{@sampleSetName1}.tar.gz * --exclude=*.log --exclude=*.sra --exclude=*.sff --exclude=*.local.metadata\")\n system(\"tar czf class.result.tar.gz class\")\n system(\"tar czf domain.result.tar.gz domain\")\n system(\"tar czf family.result.tar.gz family\")\n system(\"tar czf genus.result.tar.gz genus\")\n system(\"tar czf order.result.tar.gz order\")\n system(\"tar czf phyla.result.tar.gz phyla\")\n system(\"tar czf species.result.tar.gz species\")\n system(\"tar czf pdf.result.tar.gz 'find . -name `*.pdf`'\")\n Dir.chdir(@scratch)\n end",
"def tar(path)\n tar_filename = Pathname.new(path).realpath.to_path + '.tar'\n File.open(tar_filename, 'wb') do |tarfile|\n get_files_to_pack(path).each do |file|\n if File.file?(file)\n File.open(file, 'rb') do |f|\n while buffer = f.read(BLOCKSIZE_TO_READ)\n tarfile.write buffer\n end\n end\n else\n tarfile.write file.gsub(path, '')\n end\n end\n end\n\n tar_filename\n\n end",
"def targz\n files = procedure.get_adapter_configuration.attributes['files']\n if files.is_a?(Array)\n puts system_messages[:archiving]; puts system_messages[:compressing]\n %x{ tar -czf #{File.join(tmp_path, compressed_file)} #{files.map{|f| f.gsub(' ', '\\ ')}.join(' ')} }\n elsif files.is_a?(String)\n puts system_messages[:archiving]; puts system_messages[:compressing]\n %x{ tar -czf #{File.join(tmp_path, compressed_file)} #{files.gsub(' ', '\\ ')} }\n end\n end",
"def compress\n @env[:ui].info I18n.t(\"vagrant.actions.general.package.compressing\", :tar_path => tar_path)\n File.open(tar_path, Platform.tar_file_options) do |tar|\n Archive::Tar::Minitar::Output.open(tar) do |output|\n begin\n current_dir = FileUtils.pwd\n\n copy_include_files\n\n FileUtils.cd(@env[\"package.directory\"])\n Dir.glob(File.join(\".\", \"**\", \"*\")).each do |entry|\n Archive::Tar::Minitar.pack_file(entry, output)\n end\n ensure\n FileUtils.cd(current_dir)\n end\n end\n end\n end",
"def print_archive(filename)\n header = Enumerator.new do |out|\n out << \"Contents of: #{filename}\"\n end\n\n header + (\n case filename\n when /\\.tar\\.zst$/\n depends bins: \"zstd\"\n run(\"tar\", \"-Izstd\", \"-tvf\", filename)\n else\n depends bins: \"atool\"\n run(\"atool\", \"-l\", filename)\n end\n )\nend",
"def output_flag_file(op_dir)\n File.join op_dir, \"created.rid\"\n end",
"def tar_gz_file\n \"#{package_name}.tar.gz\"\n end",
"def tar_path\n File.expand_path(@env[\"package.output\"], FileUtils.pwd)\n end",
"def tar_gzip(archive, tarfile, pkg_time, distribution = nil,\n logfile: nil)\n\n # Make sure no distribution information leaks into the package\n if distribution and archive =~ /~#{distribution}/\n archive_plain_name = archive.gsub(/~#{distribution}/,\"\")\n FileUtils.cp_r archive, archive_plain_name\n else\n archive_plain_name = archive\n end\n\n\n Packager.info \"Tar archive: #{archive_plain_name} into #{tarfile}\"\n # Make sure that the tar files checksum remains the same by\n # overriding the modification timestamps in the tarball with\n # some external source timestamp and using gzip --no-name\n #\n # exclude hidden files an directories\n mtime = pkg_time.iso8601()\n # Exclude hidden files and directories at top level\n cmd_tar = \"tar --mtime='#{mtime}' --format=gnu -c --exclude '.+' --exclude-backups --exclude-vcs --exclude #{archive_plain_name}/debian --exclude build #{archive_plain_name} | gzip --no-name > #{tarfile}\"\n\n if system(cmd_tar, [:out,:err] => redirection(logfile, \"a\"))\n Packager.info \"Package: successfully created archive using command '#{cmd_tar}' -- pwd #{Dir.pwd} -- #{Dir.glob(\"**\")}\"\n checksum = `sha256sum #{tarfile}`\n Packager.info \"Package: sha256sum: #{checksum}\"\n return true\n else\n Packager.info \"Package: failed to create archive using command '#{cmd_tar}' -- pwd #{Dir.pwd}\"\n return false\n end\n end",
"def output_flag_file(op_dir)\n File.join(op_dir, \"created.rid\")\n end",
"def output_flag_file(op_dir)\n File.join(op_dir, \"created.rid\")\n end",
"def compress_source_tgz(path)\n tarfile = Tempfile.create([\"vagrant\", \".tar\"])\n tarfile.close\n tarfile = File.open(tarfile.path, \"wb+\")\n tgzfile = Tempfile.create([\"vagrant\", \".tgz\"])\n tgzfile.close\n tgzfile = File.open(tgzfile.path, \"wb\")\n tar = Gem::Package::TarWriter.new(tarfile)\n tgz = Zlib::GzipWriter.new(tgzfile)\n if File.file?(path)\n tar.add_file(File.basename(path), File.stat(path).mode) do |io|\n File.open(path, \"rb\") do |file|\n while bytes = file.read(4096)\n io.write(bytes)\n end\n end\n end\n else\n Dir.glob(File.join(path, \"**/**/*\")).each do |item|\n rel_path = item.sub(path, \"\")\n item_mode = File.stat(item).mode\n\n if File.directory?(item)\n tar.mkdir(rel_path, item_mode)\n else\n tar.add_file(rel_path, item_mode) do |io|\n File.open(item, \"rb\") do |file|\n while bytes = file.read(4096)\n io.write(bytes)\n end\n end\n end\n end\n end\n end\n tar.close\n tarfile.rewind\n while bytes = tarfile.read(4096)\n tgz.write bytes\n end\n tgz.close\n tgzfile.close\n tarfile.close\n File.delete(tarfile.path)\n tgzfile.path\n end",
"def tar_cmd\n # Rely on gnu tar for solaris and OSX.\n case %x{uname -s}.chomp\n when \"SunOS\"\n return \"gtar\"\n when \"Darwin\"\n return \"gnutar\"\n else\n return \"tar\"\n end\n end",
"def archive_package(name)\n destination_dir = File.join(@project.full_path, \"output\", name)\n FileUtils.mkdir_p(destination_dir)\n destination_file = File.join(destination_dir, \"#{name}.tar.xz\")\n\n archive_single(File.join(\"src\", name), destination_file)\n end",
"def compression\n \n ##Preparing directory structure for \"project\" area to display html\n system(\"mkdir -p #{@outputDir}/htmlPages/#{@studyName1}/QIIME/#{@jobName1}\")\n system(\"cp -r #{@outputDir}/QIIME_result/plots #{@outputDir}/htmlPages/#{@studyName1}/QIIME/#{@jobName1}\")\n \n Dir.chdir(\"#{@outputDir}/QIIME_result\")\n #system(\"tar -zcf #{@sampleSetName1}.tar.gz * --exclude=*.log --exclude=*.sra --exclude=*.sff --exclude=*.local.metadata\")\n system(\"tar czf raw.results.tar.gz * --exclude=filtered_aln --exclude=taxa --exclude=aln --exclude=plots\")\n system(\"tar czf phylogenetic.result.tar.gz filtered_aln\")\n system(\"tar czf taxanomy.result.tar.gz taxa\")\n system(\"tar czf fasta.result.tar.gz aln\")\n system(\"tar czf plots.result.tar.gz plots\")\n \n Dir.chdir(@scratch)\n \n end",
"def generate_flags overrides = {}\n { '-s' => 'dir',\n '-t' => 'rpm',\n '--name' => @spec.title,\n '--description' => @spec.description,\n '--url' => @spec.uri,\n '--category' => @spec.category,\n '--version' => @spec.version,\n '--epoch' => 1,\n '--license' => @spec.license,\n '-C' => @spec.dir_path,\n '--depends' => 'mono',\n '--rpm-digest' => 'sha256',\n '--package' => @out\n }.merge(overrides).reject { |_, v| v.nil? }\n end",
"def make_tarball_from_files files, options={}\n tarball = options[:filename]\n args = ['czf', tarball, '--exclude-vcs']\n exclude_each options[:exclude] do |exclude|\n args.push '--exclude', exclude\n end\n args.concat files\n run 'tar', *args\n release tarball, :cd => 1\nend",
"def tar0(otarfile, *src)\n raise \"no file or directory to tar\" if !src || src.length == 0\n Gem::Package::TarWriter.new otarfile do |tar|\n Find.find *src do |f|\n mode = File.stat(f).mode\n if File.directory? f\n tar.mkdir f, mode\n else\n tar.add_file f, mode do |tio|\n File.open f, 'r' do |io|\n tio.write io.read\n end\n end\n end\n end\n end\n end",
"def generate_compiled_archive(project)\n name_and_version = \"#{project.name}-#{project.version}\"\n name_and_version_and_platform = \"#{name_and_version}.#{name}\"\n name_and_platform = \"#{project.name}.#{name}\"\n final_archive = \"output/#{name_and_version_and_platform}.tar.gz\"\n archive_directory = \"#{project.name}-archive\"\n\n # previously, we weren't properly handling the case of custom BOM paths.\n # If we have a custom BOM path, during Makefile execution, the top-level\n # BOM is moved to the custom path. So, when cleaning up BOMs for non-custom\n # paths we just want to remove the BOM at the top level of the tarball.\n # But, if we have a custom BOM path we want to move it back to where it\n # was prior to the Makefile execution so we can preserve it as an artifact\n # but not leave it to conflict if it's installed in the same custom path\n # as a project using this archive.\n bill_of_materials_command = 'rm -f bill-of-materials'\n if project.bill_of_materials\n bill_of_materials_command = \"mv .#{project.bill_of_materials.path}/bill-of-materials ../..\"\n end\n\n [\n \"mkdir output\",\n \"mkdir #{archive_directory}\",\n \"gunzip -c #{name_and_version}.tar.gz | '#{tar}' -C #{archive_directory} -xf -\",\n \"rm #{name_and_version}.tar.gz\",\n \"cd #{archive_directory}/#{name_and_version}; #{bill_of_materials_command}; #{tar} cf ../../#{name_and_version_and_platform}.tar *\",\n \"gzip -9c #{name_and_version_and_platform}.tar > #{name_and_version_and_platform}.tar.gz\",\n \"cp build_metadata.#{name_and_platform}.json output/#{name_and_version_and_platform}.json\",\n \"cp bill-of-materials output/#{name_and_version_and_platform}-bill-of-materials ||:\",\n \"cp #{name_and_version_and_platform}.tar.gz output\",\n \"#{shasum} #{final_archive} > #{final_archive}.sha1\"\n ]\n end",
"def tarball(destination, paths)\n # check for filepath length limit\n full_destination = File.expand_path(destination)\n if full_destination.length > 259 # 256 chars max; \"C:\\\" doesn't count\n puts \"[TarBall] ERROR cannot generate #{destination} because path exceeds 256 char limit. shorten component name by at least by #{full_destination.length - 259} chars\"\n return\n end\n\n Zlib::GzipWriter.open(destination) do |gzip|\n out = Archive::Tar::Minitar::Output.new(gzip)\n\n paths.each do |fi|\n if File.exist?(fi)\n Archive::Tar::Minitar.pack_file(fi, out)\n else\n puts \"[TarBall] ERROR Could not file file: #{fi}\"\n end\n end\n out.close\n end\n end",
"def run\n \n #Get Arguments\n if @name_args.size != 1\n ui.info(\"Please specify a tarPath\")\n show_usage\n exit 1\n end\n \n tar_file = Chef::TarFile.new(@name_args.first, true)\n CookbookTarDownload.download_cookbooks tar_file\n tar_file.save\n \n end",
"def test_tar\n\tx = \"test_tar\"\n\t@output = @s.archive({ 'files'=> [@test_directory_1_Path], 'format'=>'tar' , 'recurse'=>false } )\n\t#puts @output['archiveFile']\n\t\n\t@testid= 1\n\tTar.open(@output['archiveFile'], File::RDONLY, 0644, Tar::GNU | Tar::VERBOSE) do |tar|\n while tar.read # or 'tar.each do ...'\n #puts tar.pathname\n\t\t\n\t\t\n # tar.print_long_ls\n\n if tar.reg? && tar.pathname!=\"test_directory_1/.DS_Store\" # regular file\n tar.extract_file('test')\n\t\t want = File.read(File.join(@testdir, tar.pathname))\n\t\t puts tar.pathname\n\t\t #asserting bar1,2,3 from tar file is same as original bar1,2,3\n\t\t assert_log( want, File.read('test'), $log, x, @testid)\n end\n end\n\n ##if extract all files\n #tar.extract_all\n end\n\n\n ##for gzip archive\n #Tar.gzopen('foo.tar.gz', ...\n\n ##for bzip2 archive\n #Tar.bzopen('foo.tar.bz2', ...\n \n \n \n end",
"def tar\n Omnibus.which(\"gtar\") ? \"gtar\" : \"tar\"\n end",
"def assemble_tgz\n banner \"Assembling #{TAR}...\"\n rm_and_mkdir(DIR)\n \n # gem\n run(\"cp\", [\"-r\", \"#{File.dirname(__FILE__)}/../../lib\", GEM])\n # data\n mkdir(DATA)\n copy = []\n copy << \"Telfile\"\n copy += Dir[\"files*\"]\n copy.sort.each { |i| run(\"cp\", [\"-r\", i, DATA]) }\n # config.sh\n File.open(\"#{DIR}/config\", \"w\") do |f|\n f.puts(\"CONFIG_HOST='#{@options[:host]}'\") \n f.puts(\"CONFIG_RUBY='#{@config.ruby}'\")\n f.puts(\"CONFIG_RUBYGEMS='#{RUBYGEMS}'\") \n end\n # keys\n ssh_key = \"#{ENV[\"HOME\"]}/.ssh/#{PUBKEY}\"\n if File.exists?(ssh_key)\n run(\"cp\", [ssh_key, DIR])\n end\n \n Dir.chdir(File.dirname(DIR)) do\n run(\"tar\", [\"cfpz\", TAR, File.basename(DIR)])\n end\n end",
"def tarball\n return @tarball if defined? @tarball\n\n require 'open3'\n Dir.mktmpdir do |tmpdir|\n definition.each do |options|\n glob = options.fetch(:glob)\n prefix = options[:prefix]\n ignore_hidden = options[:ignore_hidden]\n\n files = Dir[glob]\n files.reject! { |f| f.start_with?('.') } if ignore_hidden\n\n dest = prefix ? File.join(tmpdir, prefix) : tmpdir\n\n FileUtils.mkpath(dest)\n FileUtils.cp_r(files, dest)\n end\n\n excludes.each do |path|\n full_path = File.join(tmpdir, path)\n if File.file?(full_path)\n File.unlink(File.join(tmpdir, path))\n end\n end\n\n # Specify the correct ruby version in the Dockerfile.\n bundle_dockerfile = File.join(tmpdir, \"Dockerfile\")\n content = IO.read(bundle_dockerfile)\n content = content.gsub(\"{{ruby_version}}\", ruby_version)\n IO.write bundle_dockerfile, content\n\n if dockerfile\n File.unlink bundle_dockerfile\n FileUtils.cp dockerfile, bundle_dockerfile\n end\n\n # Find hash of all files we're sending over.\n digest = Digest::SHA1.new\n Dir[File.join(tmpdir, '**/*')].each do |path|\n if File.file? path\n open path, 'r' do |file|\n digest.update file.read\n end\n end\n end\n @image_name = \"hoosegow:#{digest.hexdigest}\"\n\n # Create tarball of the tmpdir.\n stdout, stderr, status = Open3.capture3 'tar', '-c', '-C', tmpdir, '.'\n\n raise Hoosegow::ImageBuildError, stderr unless stderr.empty?\n\n @tarball = stdout\n end\n end",
"def tar_gz(filename, basename)\n # TODO: detect if there's an appropriately-named subdirectory within. If not, then make/cd into it.\n exec_and_return_output_array(\"tar -xvvzf #{filename}\")\n puts basename\n # puts 'filename - without extension'\nend",
"def archive\n files.each do |path|\n path_obj = Pathname.new(path)\n path_name = path_obj.dirname.to_s\n compress = Kellerkind::Compress.new(:target_path => out,\n :source_path => path,\n :tarball_prefix => path_obj.basename.to_s)\n compress.find_at_source_path = true\n if File.exists?(path)\n Kellerkind::Process.verbose(:start_compressing)\n compress.gzip\n if File.exists?(\"#{path_name}/#{compress.tarball_name}\")\n Kellerkind::Process.verbose(:finished_compressing)\n FileUtils.mv(\"#{path_name}/#{compress.tarball_name}\",\n \"#{out}/#{compress.tarball_name}\")\n FileUtils.rm_rf(path)\n FileUtils.touch(path) if self.recreate\n end\n end\n end\n end",
"def tar(file)\n TarTask.define_task(file)\nend",
"def package_name\n @package_name ||=\n Pathname(\"#{cartage.final_name}.tar#{cartage.tar_compression_extension}\")\n end",
"def tar_content_filenames\n `tar tzf #{filename}`.split(\"\\n\")\n end",
"def untar_file(f, to)\n line(\"tar\", \"-xf {file} -C {path}\").pass(file: f, path: to)\n end",
"def tar_xz_file\n \"#{package_name}.tar.xz\"\n end",
"def tgz_file\n \"#{package_name}.tgz\"\n end",
"def tar_bz2_file\n \"#{package_name}.tar.bz2\"\n end",
"def create_tarball\n out_file = filename(@conference, @locale)\n if File.exist? out_file\n File.unlink out_file\n end\n system( 'tar', *['-cpz', '-f', out_file.to_s, '-C', @destination, @conference.acronym].flatten )\n out_file.to_s\n end",
"def prep_command #:nodoc:\n \"tar cvf #{full_tarfile} #{remote_directory}; gzip -f #{full_tarfile}\"\n end",
"def _create_output_filename(output_prefix, compression)\n output_file = output_prefix + '.tsv'\n case compression\n when true, 'gzip'\n output_file += '.gz'\n when 'bzip2'\n output_file += '.bz2'\n end\n return output_file\n end",
"def make_tarball dir, options={}\n options[:filename] = options[:filename] || \"#{dir}.tar.gz\"\n make_tarball_from_files [dir], options\nend",
"def pack directory_path\n Dir.chdir directory_path\n name = Dir.pwd.split(@fs).last\n files = Dir.glob \"**#{@fs}*\"\n File.open([name, @ext].join(\".\"), \"wb\") do |tar|\n Minitar.pack(files, tar)\n end\n end",
"def generate_output_file(zip_out, contents); end",
"def tar___( directory, filename )\r\n raise StandardError, \"Under investigation\"\r\n got = @ndev.rpc.file_archive( :destination => filename, :source => directory )\r\n end",
"def filename flags = nil\n flags ||= generate_flags\n # TODO: handle OS architecture properly by taking from context\n \"#{flags['--name']}-#{flags['--version']}-#{flags['--epoch']}.x86_64.rpm\"\n end",
"def pack_file(entry, outputter) # :yields action, name, stats:\n if outputter.is_a?(Archive::Tar::Minitar::Output)\n outputter = outputter.tar\n end\n\n stats = {}\n\n if entry.is_a?(Hash)\n name = entry[:name]\n entry.each { |kk, vv| stats[kk] = vv unless vv.nil? }\n else\n name = entry\n end\n\n name = name.sub(%r{\\./}, \"\")\n stat = File.stat(name)\n stats[:mode] ||= stat.mode\n stats[:mtime] ||= stat.mtime\n stats[:size] = stat.size\n\n if windows?\n stats[:uid] = nil\n stats[:gid] = nil\n else\n stats[:uid] ||= stat.uid\n stats[:gid] ||= stat.gid\n end\n\n if File.file?(name)\n outputter.add_file_simple(name, stats) do |os|\n stats[:current] = 0\n yield :file_start, name, stats if block_given?\n File.open(name, \"rb\") do |ff|\n until ff.eof?\n stats[:currinc] = os.write(ff.read(4096))\n stats[:current] += stats[:currinc]\n yield :file_progress, name, stats if block_given?\n end\n end\n yield :file_done, name, stats if block_given?\n end\n elsif dir?(name)\n yield :dir, name, stats if block_given?\n outputter.mkdir(name, stats)\n else\n raise \"Don't yet know how to pack this type of file.\"\n end\n end",
"def full_tarfile #:nodoc:\n [tar_directory, tarfile].join(\"/\")\n end",
"def tar_compression_extension\n case compression\n when :bzip2, \"bzip2\", nil\n \".bz2\"\n when :gzip, \"gzip\"\n \".gz\"\n when :none, \"none\"\n \"\"\n end\n end",
"def extract_metadata!\n shell_out \"tar zOxf #{package_path} data.tar.gz | tar zOxf - ./opt/chef-server/version-manifest.json > #{temp_metadata_path}\"\n end",
"def print_usage \n puts \"Usage: packagize [-h] [-v] [-r] [-s source_dir] [-d dest_dir]\"\n puts \"\\tSource and destination default to the current working directory.\"\n puts \"\\t-r search directory and all subdirectories. Defaults to true.\"\n puts \"\\t-v display verbose output. Defaults to false.\"\n puts \"\\t-h display this text.\"\nend",
"def finalize_king_of_spades(fake_card_path, king_of_spades_path)\n print_status(\"Creating flag as #{FLAGNAME}\")\n zip = zip_file(king_of_spades_path)\n print_status(\"King of Spades compressed as: #{zip}\")\n `cat #{fake_card_path} #{zip} > #{FLAGNAME}`\n FLAGNAME\nend",
"def output(output_path)\n output_check(output_path)\n\n # Copy all files from staging to BUILD dir\n Find.find(staging_path) do |path|\n src = path.gsub(/^#{staging_path}/, '')\n dst = build_path(src)\n begin\n copy_entry(path, dst, preserve=true, remove_destination=true)\n rescue\n copy_entry(path, dst, preserve=false, remove_destination=true)\n end\n copy_metadata(path, dst)\n end\n\n # This value is used later in the template for PKGINFO\n size = safesystemout(\"du\", \"-sk\", build_path).split(/\\s+/)[0].to_i * 1024\n builddate = Time.new.to_i\n\n pkginfo = template(\"pacman.erb\").result(binding)\n pkginfo_file = build_path(\".PKGINFO\")\n File.write(pkginfo_file, pkginfo)\n\n if script?(:before_install) or script?(:after_install) or \\\n script?(:before_upgrade) or script?(:after_upgrade) or \\\n script?(:before_remove) or script?(:after_remove)\n install_script = template(\"pacman/INSTALL.erb\").result(binding)\n install_script_file = build_path(\".INSTALL\")\n File.write(install_script_file, install_script)\n end\n\n generate_mtree\n\n File.expand_path(output_path).tap do |path|\n ::Dir.chdir(build_path) do\n safesystem(*([tar_cmd,\n compression_option,\n \"-cf\",\n path] + data_tar_flags + \\\n ::Dir.entries(\".\").reject{|entry| entry =~ /^\\.{1,2}$/ }))\n end\n end\n end",
"def create_tar_gz_file(gz_base_file_name, source_file)\n gz_name = \"#{gz_base_file_name}.tar.gz\"\n cmd = \"tar -czf #{gz_name} #{source_file}\"\n system(cmd)\n gz_name\n end",
"def tarball\n Dir[\"#{dest}/#{SCOPE}-#{gemspec.name}-#{gemspec.version}.tgz\"].first\n end",
"def gzip *paths\n paths.collect do |path|\n system \"/usr/bin/gzip\", path\n Pathname.new(\"#{path}.gz\")\n end\nend",
"def extract src_path, dst_path = File.dirname(src_path)\n src_path = File.expand_path(src_path)\n src_name = File.basename(src_path)\n src_suffix = File.extname(src_name)\n src_prefix = File.basename(src_name, src_suffix)\n\n Dir.mktmpdir(nil, dst_path) do |tmp_dir|\n # decompress the archive\n cd tmp_dir do\n case src_name.sub(/\\.part$/, '')\n when /\\.(tar\\.gz|tar\\.Z|tgz|taz)$/i\n system 'tar', '-zxf', src_path\n\n when /\\.(tar\\.bz|tar\\.bz2|tbz|tbz2)$/i\n system 'tar', '-jxf', src_path\n\n when /\\.(tar\\.xz|txz)$/i\n system 'tar', '-Jxf', src_path\n\n when /\\.(tar|cpio|gem)$/i\n system 'tar', '-xf', src_path\n\n when /\\.(tar.lzo|tzo)$/i\n system \"lzop -xc #{src_path.inspect} | tar -xf -\"\n\n when /\\.(lzo)$/i\n system 'lzop', '-x', src_path\n\n when /\\.(gz)$/i\n system \"gunzip -c #{src_path.inspect} > #{src_prefix.inspect}\"\n\n when /\\.(bz|bz2)$/i\n system \"bunzip2 -c #{src_path.inspect} > #{src_prefix.inspect}\"\n\n when /\\.(shar)$/i\n system 'sh', src_path\n\n when /\\.(7z)$/i\n system '7zr', 'x', src_path\n\n when /\\.(zip)$/i\n system 'unzip', src_path\n\n when /\\.(jar)$/i\n system 'jar', 'xf', src_path\n\n when /\\.(rz)$/i\n ln src_path, src_name # rzip removes the archive after extraction\n system 'rzip', '-d', src_name\n\n when /\\.(rar)$/i\n system 'unrar', 'x', src_path\n\n when /\\.(ace)$/i\n system 'unace', 'x', src_path\n\n when /\\.(arj)$/i\n system 'arj', 'x', src_path\n\n when /\\.(arc)$/i\n system 'arc', 'x', src_path\n\n when /\\.(lhz|lha)$/i\n system 'lha', 'x', src_path\n\n when /\\.(a|ar)$/i\n system 'ar', '-x', src_path\n\n when /\\.(Z)$/\n system \"uncompress -c #{src_path.inspect} > #{src_prefix.inspect}\"\n\n when /\\.(z)$/\n system \"pcat #{src_path.inspect} > #{src_prefix.inspect}\"\n\n when /\\.(zoo)$/i\n system 'zoo', 'x//', src_path\n\n when /\\.(cab)$/i\n system 'cabextract', src_path\n\n when /\\.(deb)$/i\n system 'ar', 'x', src_path\n\n when /\\.(rpm)$/i\n system \"rpm2cpio #{src_path.inspect} | cpio -i --make-directories\"\n\n else\n warn \"I do not know how to extract #{src_path.inspect}\"\n end\n end\n\n # clean any mess made by decompression\n manifest = Dir.new(tmp_dir).entries - %w[ . .. ]\n\n if manifest.length == 1 # there was no mess!\n adj_dst = File.join(dst_path, manifest.first)\n adj_src = File.join(tmp_dir, manifest.first)\n else\n adj_src = tmp_dir\n adj_dst = File.join(dst_path, src_name[/.*(?=\\..*?)/])\n end\n\n adj_dst << \"+#{Time.now.to_i}\" until\n not File.exist? adj_dst and\n mv(adj_src, adj_dst, :force => true)\n\n touch tmp_dir # give Dir.mktmpdir() something to remove\n\n adj_dst\n end\nend",
"def tarball\n tarfile = StringIO.new(\"\")\n Gem::Package::TarWriter.new(tarfile) do |tar|\n path = \"#{staging_dir}/#{packager.package_name}\"\n name = packager.package_name\n mode = File.stat(path).mode\n\n tar.add_file(name, mode) do |tf|\n File.open(path, \"rb\") do |file|\n tf.write(file.read)\n end\n end\n end\n\n tarfile.rewind\n tarfile\n end",
"def read_archive(full_path)\n\t\t`cd #{::File.dirname(full_path)}; tar c #{::File.basename(full_path)}`\n\tend",
"def tarfile #:nodoc:\n rp = Pathname.new(remote_directory) \n rp.basename.to_s+\".tar\"\n end",
"def tar(dir, ext=nil)\n path = File.expand_path(dir)\n skip = path.size + 1\n tar_io = StringIO.new\n Gem::Package::TarWriter.new(tar_io) do |tar|\n Dir[File.join(path, \"**/*#{'.' + ext if ext}\")].each do |file|\n stat = File.stat(file)\n name = file[skip..-1]\n if stat.file?\n tar.add_file_simple(name, stat.mode, stat.size) do |tf|\n tf.write(File.binread(file))\n end\n elsif stat.directory?\n tar.mkdir(name, stat.mode)\n end\n end\n end\n tar_io.string\n end",
"def cleanup_extract_source(attrs={})\n\n execute \"cleanup_source\" do\n cwd Chef::Config[:file_cache_path]\n command \"rm -rf #{attrs['src_dir']}\"\n not_if do ! FileTest.directory?(attrs['src_dir']) end\n action :run\n end\n\n extract_flags = \"tar zxf\" if attrs['src_file'] =~ /tar\\.gz/\n extract_flags = \"tar jxf\" if attrs['src_file'] =~ /tar\\.bz2/\n extract_flags = \"7za x\" if attrs['src_file'] =~ /7z/\n\n execute \"extract_source\" do\n cwd Chef::Config[:file_cache_path]\n command \"#{extract_flags} #{Chef::Config[:file_cache_path]}/#{attrs['src_file']}\"\n action :run\n end\n\nend",
"def tar\n @tarreader\n end",
"def archive(opts) # rubocop:disable Metrics/AbcSize\n profile_name = @params[:name]\n\n ext = opts[:zip] ? 'zip' : 'tar.gz'\n\n if opts[:archive]\n archive = Pathname.new(opts[:archive])\n else\n slug = profile_name.downcase.strip.tr(' ', '-').gsub(/[^\\w-]/, '_')\n archive = Pathname.new(File.dirname(__FILE__)).join('../..', \"#{slug}.#{ext}\")\n end\n\n # check if file exists otherwise overwrite the archive\n if archive.exist? && !opts[:overwrite]\n @logger.info \"Archive #{archive} exists already. Use --overwrite.\"\n return false\n end\n\n # remove existing archive\n File.delete(archive) if archive.exist?\n\n @logger.info \"Generate archive #{archive}.\"\n\n # find all files\n files = Dir.glob(\"#{path}/**/*\")\n\n # filter files that should not be part of the profile\n # TODO ignore all .files, but add the files to debug output\n\n # map absolute paths to relative paths\n files = files.collect { |f| Pathname.new(f).relative_path_from(Pathname.new(path)).to_s }\n\n # display all files that will be part of the archive\n @logger.debug 'Add the following files to archive:'\n files.each { |f|\n @logger.debug ' ' + f\n }\n\n if opts[:zip]\n # generate zip archive\n require 'inspec/archive/zip'\n zag = Inspec::Archive::ZipArchiveGenerator.new\n zag.archive(path, files, archive)\n else\n # generate tar archive\n require 'inspec/archive/tar'\n tag = Inspec::Archive::TarArchiveGenerator.new\n tag.archive(path, files, archive)\n end\n\n @logger.info 'Finished archive generation.'\n true\n end",
"def tar_dist(val)\n Utilities.tar_dist(val)\n end",
"def compress_directory dir\n if File.directory? dir\n puts \"# - Compressing directory: #{dir}\"\n dir_compressed_name = dir.sub(\".\",'').sub(\"/\",'').gsub(\"/\", '_')[0..-2]\n system(\"tar\",\"-pczf\",\"#{dir_compressed_name}.tar.gz\", \"#{dir}\") if File.exist? dir\n \"#{dir_compressed_name}.tar.gz\"\n else\n raise \"Could not compress the following directory: #{dir}\"\n end\nend",
"def archive(target = nil, &block)\n require 'rubygems/package'\n unless target\n target = parent.file(\"#{name}.tar\")\n end\n target.write_binary do |io|\n writer = Gem::Package::TarWriter.new(io) do |tar_io|\n archive_dir(tar_io, self, &block)\n end\n end\n target\n end",
"def find_valid_files(tarfile)\n Archive::Tar::Minitar.open(tarfile).collect do |entry|\n flag = entry.typeflag\n if flag.nil? || flag =~ /[[:digit:]]/ && (0..7).cover?(flag.to_i)\n entry.full_name\n else\n Puppet.debug \"Invalid tar flag '#{flag}' will not be extracted: #{entry.name}\"\n next\n end\n end\n end",
"def tgz___( directory, filename )\r\n raise StandardError, \"Under investigation\" \r\n got = @ndev.rpc.file_archive( :destination => filename, :source => directory, :compress => true )\r\n end",
"def write_comp(output, comp_mnemonic)\n case comp_mnemonic\n when \"0\"\n File.open(output, \"a\") { |f| f.write \"0101010\"}\n when \"1\"\n File.open(output, \"a\") { |f| f.write \"0111111\"}\n when \"-1\"\n File.open(output, \"a\") { |f| f.write \"0111010\"}\n when \"D\"\n File.open(output, \"a\") { |f| f.write \"0001100\"}\n when \"A\"\n File.open(output, \"a\") { |f| f.write \"0110000\"}\n when \"!D\"\n File.open(output, \"a\") { |f| f.write \"0001101\"}\n when \"!A\"\n File.open(output, \"a\") { |f| f.write \"0110001\"}\n when \"-D\"\n File.open(output, \"a\") { |f| f.write \"0001111\"}\n when \"-A\"\n File.open(output, \"a\") { |f| f.write \"0110011\"}\n when \"D+1\"\n File.open(output, \"a\") { |f| f.write \"0011111\"}\n when \"A+1\"\n File.open(output, \"a\") { |f| f.write \"0110111\"}\n when \"D-1\"\n File.open(output, \"a\") { |f| f.write \"0001110\"}\n when \"A-1\"\n File.open(output, \"a\") { |f| f.write \"0110010\"}\n when \"D+A\"\n File.open(output, \"a\") { |f| f.write \"0000010\"}\n when \"D-A\"\n File.open(output, \"a\") { |f| f.write \"0010011\"}\n when \"A-D\"\n File.open(output, \"a\") { |f| f.write \"0000111\"}\n when \"D&A\"\n File.open(output, \"a\") { |f| f.write \"0000000\"}\n when \"D|A\"\n File.open(output, \"a\") { |f| f.write \"0010101\"}\n when \"M\"\n File.open(output, \"a\") { |f| f.write \"1110000\"}\n when \"!M\"\n File.open(output, \"a\") { |f| f.write \"1110001\"}\n when \"-M\"\n File.open(output, \"a\") { |f| f.write \"1110011\"}\n when \"M+1\"\n File.open(output, \"a\") { |f| f.write \"1110111\"}\n when \"M-1\"\n File.open(output, \"a\") { |f| f.write \"1110010\"}\n when \"D+M\"\n File.open(output, \"a\") { |f| f.write \"1000010\"}\n when \"D-M\"\n File.open(output, \"a\") { |f| f.write \"1010011\"}\n when \"M-D\"\n File.open(output, \"a\") { |f| f.write \"1000111\"}\n when \"D&M\"\n File.open(output, \"a\") { |f| f.write \"1000000\"}\n when \"D|M\"\n File.open(output, \"a\") { |f| f.write \"1010101\"}\n else\n File.open(output, \"a\") { |f| f.write \"0000000\"}\n end\n end",
"def compress_files_and_copy\n timestamp = Time.now.strftime(\"%Y%m%d-%H%M%S\") + '_'\n tar_file = @backup_folder + timestamp + \"syc-backup.tar.gz\" \n tar_command = \"tar cfz #{tar_file} #{@files.join(\" \")}\"\n\n stdout, stderr, status = Open3.capture3(tar_command)\n\n unless status.exitstatus == 0\n STDERR.puts \"There was a problem executing command\"\n STDERR.puts tar_command\n STDERR.puts stderr\n exit status.exitstatus\n end\n\n tar_file\n end",
"def archive_kit(whole)\n destination_dir = File.join(@project.full_path, \"output\", \"#{@project.name}-kit\")\n FileUtils.mkdir_p(destination_dir)\n file_prefix = \"#{@project.name}-kit\"\n file_suffix = \".tar.xz\"\n\n @project.take_snapshot \"Kit archival started\"\n\n destination_file = (\n if whole\n remove_stale_incremental(destination_dir, file_prefix, file_suffix)\n archive_single(\"kit\", File.join(destination_dir, file_prefix + file_suffix))\n else\n log.debug \"doing incremental archive\"\n archive_incremental(\"kit\", destination_dir, file_prefix, file_suffix, :archive_kit)\n end\n )\n\n @project.take_snapshot \"Kit archive generated\", :archive_kit\n\n destination_file\n end",
"def tar_data(verbose)\n shell = SwrShell.new\n @fileutils.su_mkdir_p @config[\"tar_data\"], verbose\n @fileutils.su_du_sh \"#{@datadir}\", verbose\n cmd = \"tar -C #{@datadir} -c . | snzip > #{File.join(@config[\"tar_data\"],\"data.tar.snz\")}\"\n shell.su_execute(cmd,verbose)\n if @datadir == @logdir\n #log and data dirs are the same so creating empty log.tar.gz\n @fileutils.su_mkdir_p \"empty\", verbose\n @fileutils.su_tar \" -C empty \",\" -cf #{File.join(@config[\"tar_data\"],\"log.tar\")}\",\".\", verbose\n @fileutils.su_rm_rf \"empty\", verbose\n elsif @logdir != ''\n cmd = \"tar -C #{@logdir} -c . | snzip > #{File.join(@config[\"tar_data\"],\"log.tar.snz\")}\"\n shell.su_execute(cmd,verbose)\n end\n cmd = \"cd #{@config[\"tar_data\"]}; du -h; sudo touch md5sums.txt; sudo chmod a+rw md5sums.txt; sudo md5sum data.tar* >> md5sums.txt; sudo md5sum log.tar* >> md5sums.txt;\"\n shell.execute(cmd,verbose,true)\n @fileutils.sync verbose\n end",
"def package(path, target)\n # Load manifest\n puts \"Load manifest...\"\n manifest = YAML::load_file(File.join(path, 'manifest.yml'))\n \n # Target directory for package files\n puts \"Target is: #{target}\"\n Dir.mkdir(target) if not File.exists?(target)\n \n # Package name\n package = \"#{manifest['name']}-#{manifest['version']}\"\n puts \"Package: #{package}\"\n \n # Tgz\n manifest['package'] = \"#{package}.tgz\"\n command = \"tar -czf #{package}.tgz --exclude pkg -C #{path} .\"\n puts \"Packing: #{command}\"\n system command\n \n # Move\n puts \"Finishing..\"\n FileUtils.mv(\"#{package}.tgz\", target)\n File.open(File.join(target, \"#{package}.yml\"), 'w') do |f|\n f.puts(manifest.to_yaml)\n f.close\n end\n \n puts \"Done.\"\nend",
"def archive\n @repo.archive(sha, nil, :format => 'tgz', :prefix => \"#{safe_name}/\")\n end",
"def cdtar(cdpath, tarfile, *src)\n raise \"tar file #{tarfile} shouldn't be a directory\" if File.directory? tarfile\n File.open tarfile, 'w' do |otarfile|\n cdtar0 cdpath, otarfile, *src\n end\n end",
"def list_tar_file(tar_file)\n `tar tfz #{tar_file}`.split(/[\\r\\n]+/)\n end",
"def archive(opts)\n # check if file exists otherwise overwrite the archive\n dst = archive_name(opts)\n if dst.exist? && !opts[:overwrite]\n @logger.info \"Archive #{dst} exists already. Use --overwrite.\"\n return false\n end\n\n # remove existing archive\n File.delete(dst) if dst.exist?\n @logger.info \"Generate archive #{dst}.\"\n\n # filter files that should not be part of the profile\n # TODO ignore all .files, but add the files to debug output\n\n # display all files that will be part of the archive\n @logger.debug \"Add the following files to archive:\"\n files.each { |f| @logger.debug \" \" + f }\n\n if opts[:zip]\n # generate zip archive\n require \"inspec/archive/zip\"\n zag = Inspec::Archive::ZipArchiveGenerator.new\n zag.archive(root_path, files, dst)\n else\n # generate tar archive\n require \"inspec/archive/tar\"\n tag = Inspec::Archive::TarArchiveGenerator.new\n tag.archive(root_path, files, dst)\n end\n\n @logger.info \"Finished archive generation.\"\n true\n end",
"def archive_name(opts)\n if (name = opts[:output])\n return Pathname.new(name)\n end\n\n name = params[:name] ||\n raise(\"Cannot create an archive without a profile name! Please \"\\\n \"specify the name in metadata or use --output to create the archive.\")\n version = params[:version] ||\n raise(\"Cannot create an archive without a profile version! Please \"\\\n \"specify the version in metadata or use --output to create the archive.\")\n ext = opts[:zip] ? \"zip\" : \"tar.gz\"\n slug = name.downcase.strip.tr(\" \", \"-\").gsub(/[^\\w-]/, \"_\")\n Pathname.new(Dir.pwd).join(\"#{slug}-#{version}.#{ext}\")\n end",
"def write_tgz\n # Grab the contents of the gzipped tarball for reading\n contents = gzipped_tarball\n\n # Write the .tar.gz into the staging directory\n File.open(\"#{staging_dir}/#{package_name}\", \"wb\") do |tgz|\n while chunk = contents.read(1024)\n tgz.write(chunk)\n end\n end\n\n # Copy the .tar.gz into the package directory\n FileSyncer.glob(\"#{staging_dir}/*.tar.gz\").each do |tgz|\n copy_file(tgz, Config.package_dir)\n end\n end",
"def open_output(path)\n case path.extname\n when \".gz\"\n Zlib::GzipWriter.open(path.to_s)\n # when \".gz\"\n # ::IO.popen(\"gzip -c > #{path}\", \"w\")\n else\n path.open(\"wb\")\n end\n end",
"def processing_archive_flag_path\n \"#{archive_path}#{ProcessingArchiveSuffix}\"\n end",
"def tarball_for version\n\t\t\tarf = app_root_for(version.app, version)\n\t\t\tFile.join arf, 'app.tgz'\n\t\tend",
"def package_tarballs( mods_dirs )\n pwd = Dir.pwd\n mods_dirs.each do |module_dir|\n next unless File.directory? module_dir\n FileUtils.chdir module_dir, :verbose => (verbose?)\n\n cmd = \"puppet module build --render-as=json\"\n puts cmd if verbose?\n tgz = `#{cmd}`.split(\"\\n\").last.gsub('\"','')\n puts \"--[tgz] built module archive: #{tgz}\" if verbose?\n FileUtils.cp tgz, @tars_dir, :verbose => verbose?\n end\n FileUtils.chdir pwd, :verbose => verbose?\n end",
"def stow_command_flags\n flags = ''\n flags += \"-t #{stow_target}\" unless stow_target.nil?\n flags += \"-d #{stow_path}\" unless stow_path.nil?\n flags\n end",
"def extract\n # Only used by tar\n compression_switch = \"\"\n compression_switch = \"z\" if downloaded_file.end_with?(\"gz\")\n compression_switch = \"--lzma -\" if downloaded_file.end_with?(\"lzma\")\n compression_switch = \"j\" if downloaded_file.end_with?(\"bz2\")\n compression_switch = \"J\" if downloaded_file.end_with?(\"xz\")\n\n if Ohai[\"platform\"] == \"windows\"\n if downloaded_file.end_with?(*TAR_EXTENSIONS) && source[:extract] != :seven_zip\n returns = [0]\n returns << 1 if source[:extract] == :lax_tar\n\n shellout!(\"tar #{compression_switch}xf #{downloaded_file} --force-local -C#{project_dir}\", returns: returns)\n elsif downloaded_file.end_with?(*COMPRESSED_TAR_EXTENSIONS)\n Dir.mktmpdir do |temp_dir|\n log.debug(log_key) { \"Temporarily extracting `#{safe_downloaded_file}' to `#{temp_dir}'\" }\n\n shellout!(\"7z.exe x #{safe_downloaded_file} -o#{windows_safe_path(temp_dir)} -r -y\")\n\n fname = File.basename(downloaded_file, File.extname(downloaded_file))\n fname << \".tar\" if downloaded_file.end_with?(\"tgz\", \"txz\")\n next_file = windows_safe_path(File.join(temp_dir, fname))\n\n log.debug(log_key) { \"Temporarily extracting `#{next_file}' to `#{safe_project_dir}'\" }\n shellout!(\"7z.exe x #{next_file} -o#{safe_project_dir} -r -y\")\n end\n else\n shellout!(\"7z.exe x #{safe_downloaded_file} -o#{safe_project_dir} -r -y\")\n end\n elsif downloaded_file.end_with?(\".7z\")\n shellout!(\"7z x #{safe_downloaded_file} -o#{safe_project_dir} -r -y\")\n elsif downloaded_file.end_with?(\".zip\")\n shellout!(\"unzip #{safe_downloaded_file} -d #{safe_project_dir}\")\n else\n shellout!(\"#{tar} #{compression_switch}xf #{safe_downloaded_file} -C#{safe_project_dir}\")\n end\n end",
"def extract_tar_gz\n Gem::Package::TarReader.new(Zlib::GzipReader.open(base.package)) do |tar|\n\n # Progressbar\n progressbar = ProgressBar.create(format: PROGRESSBAR_FORMAT, total: tar.count)\n\n # tar.count move position pointer to end\n tar.rewind\n\n dest_file = nil\n tar.each do |entry|\n if entry.full_name == TAR_LONGLINK\n dest_file = File.join(@tmpdir, entry.read.strip)\n next\n end\n dest_file ||= File.join(@tmpdir, entry.full_name)\n if entry.directory?\n FileUtils.rm_rf(dest_file) unless File.directory?(dest_file)\n FileUtils.mkdir_p(dest_file, mode: entry.header.mode, verbose: false)\n elsif entry.file?\n FileUtils.rm_rf(dest_file) unless File.file?(dest_file)\n File.open(dest_file, 'wb') do |f|\n f.write(entry.read)\n end\n FileUtils.chmod(entry.header.mode, dest_file, verbose: false)\n elsif entry.header.typeflag == '2' # symlink\n File.symlink(entry.header.linkname, dest_file)\n end\n\n dest_file = nil\n progressbar.increment\n end\n end\n end",
"def pre_exec\n OptionParser.new do |opt|\n opt.banner = \"vermillion create [...-flags]\"\n\n opt.on(\"-n\", \"--name=NAME\", \"Directory to be created\") { |o| @name = o }\n end.parse!\n\n super\n end",
"def flags\n input = @flags.clone\n tok = []\n\n # Set the output path\n throw 'Output pathname is required' if @output.nil?\n if Platform.is_windows?\n tok.push \"/OUT:\\\"#{@output}\\\"\"\n tok.push '/DLL' if @output =~ /\\.dll/i\n else\n tok.push '-o', @output\n end\n\n # Enable shared library output\n if @shared_library\n if Platform.is_windows?\n tok.push '/DLL'\n else\n tok.push '-shared'\n tok.push '-fPIC'\n end\n end\n\n # Assume that we want to link with shared libraries\n # built within this project\n unless Platform.is_windows?\n tok.push '-L', '.'\n end\n\n # Override the normal search path for the dynamic linker\n unless @rpath.nil?\n if Platform.is_solaris?\n input.push ['R', @rpath]\n elsif Platform.is_linux?\n input.push ['-rpath', @rpath]\n elsif Platform.is_windows?\n # XXX-FIXME Windows does not support the rpath concept\n else\n throw 'Unsupported OS'\n end\n input.push ['-L', @rpath]\n end\n\n input.each do |f|\n if @gcc_flags == true\n if f.kind_of?(Array)\n if f[0] == '-L'\n tok.push f.join(' ')\n else\n tok.push '-Wl,' + f[0] + ',' + f[1]\n end\n else\n tok.push '-Wl,' + f\n end\n else\n if f.kind_of?(Array)\n tok.push f.flatten.join(' ')\n else\n tok.push f\n end\n end\n end\n\n res = ' ' + tok.join(' ')\n return res\n end",
"def packer_add\n {\n output: output || output_path.join(\"#{packer_name}.box\").to_s\n }\n end",
"def method_missing(symbol, *args)\n @output_path = args.to_s if symbol.to_s == \"output\"\n @args << (\"--#{symbol}\")\n @args +=(args)\n end",
"def compress(directory, file)\n case compression\n when :gzip, :gz then [\"tar\", \"czf\", file, directory]\n when :bzip2, :bz2 then [\"tar\", \"cjf\", file, directory]\n when :zip then [\"zip\", \"-qr\", file, directory]\n else raise ArgumentError, \"invalid compression type #{compression.inspect}\"\n end\n end",
"def add_signatures\n if @data_signature then\n @tar_writer.add_file 'data.tar.gz.sig', 0644 do |io|\n io.write @data_signature\n end\n end\n\n if @meta_signature then\n @tar_writer.add_file 'metadata.gz.sig', 0644 do |io|\n io.write @meta_signature\n end\n end\n end",
"def generate_cli_flags\n @flags.map{|pair| pair.join(' ')}.join(' ').gsub(' true','')\n end",
"def zipfile metadata\n cmd = \"cd #{Myreplicator.configs[@export_obj.source_schema][\"export_stg_dir\"]}; gzip #{@export_obj.filename}\"\n\n puts cmd\n\n zip_result = metadata.ssh.exec!(cmd)\n\n unless zip_result.nil?\n raise Exceptions::ExportError.new(\"Export Error\\n#{zip_result}\") if zip_result.length > 0\n end\n\n metadata.zipped = true\n\n return zip_result\n end",
"def create_archive(opts = {})\n archive = normalize_archive_name( find_option( opts, 'name' ) || archive_name )\n app_dir = find_option( opts, 'app_dir' ) || Dir.pwd\n dest_dir = find_option( opts, 'dest_dir' ) || Dir.pwd\n excludes = find_option( opts, 'exclude' ) || \"\"\n should_precompile_assets = find_option( opts, 'precompile_assets' ) == true\n should_package_gems = find_option( opts, 'package_gems' ) == true\n package_without = find_option( opts, 'package_without' ) || Array.new\n\n if should_precompile_assets\n precompile_assets( app_dir )\n raise 'Error precompiling assets' unless $? == 0\n end\n\n archive_path = File.join( dest_dir, archive )\n archive_proc = lambda { create_knob_archive( app_dir, archive_path, excludes ) }\n\n if should_package_gems\n package_gems( app_dir, package_without ) {\n raise 'Error packaging gems' unless $? == 0\n archive_proc.call\n }\n else\n archive_proc.call\n end\n\n archive_path\n end",
"def output(base_uri, input_name, output_name, options, gif, output_folder)\n base_uri = base_uri + 'output/'\n if gif\n else\n Dir.mkdir(base_uri) unless Dir.exist?(base_uri)\n end\n\n if output_name.nil?\n rando = '_' + (0...4).map { 65.+(rand(26)).chr }.join.downcase\n settings_file = File.new(base_uri + input_name + rando + '.txt', 'w')\n settings_file.puts(options.to_s)\n settings_file.close\n base_uri + input_name + rando + '.png'\n elsif gif || output_folder\n @base_uri = base_uri + \"#{input_name}/\"\n # needs to be refactored to create an output folder instead of a sequence folder\n FileUtils.mkdir_p(@sequence_folder) unless Dir.exist?(@sequence_folder)\n settings_file = File.new(@sequence_folder + output_name + '.txt', 'w')\n settings_file.puts(options.to_s)\n settings_file.close\n @sequence_folder + output_name + '.png'\n elsif !gif && !output_folder\n settings_file = File.new(base_uri + output_name + '.txt', 'w')\n settings_file.puts(options.to_s)\n settings_file.close\n base_uri + output_name + '.png'\n end\n end",
"def cdtargz(cdpath, targzfile, *src)\n raise \"tar.gz file #{targzfile} shouldn't be a directory\" if File.directory? targzfile\n Zlib::GzipWriter.open targzfile do |otarfile|\n cdtar0 cdpath, otarfile, *src\n end\n end",
"def packaging_task(dir_path, pkg_name)\n chdir dir_path do\n sh \"#{ZIP} -9 -r -o ../#{pkg_name} * **/*\"\n end\nend",
"def listTar\n tarfiles = File.join(data_path, '/', '*.tar')\n Dir.glob(tarfiles)\n end",
"def untgzp(file, location)\n if file[-7..-1] != \".tar.gz\"\n print \"ERROR: expected a tar.gz file: #{file}\\n\"\n exit\n end\n if os_short() == 'sunos'\n tar = \"gtar\"\n else\n tar = \"#{bin('tar')}\"\n end\n sh \"#{tar} --directory #{location} -xf #{file}\"\nend"
] | [
"0.6347066",
"0.62538254",
"0.6228467",
"0.6081101",
"0.6014752",
"0.5992274",
"0.5974912",
"0.59343016",
"0.5928332",
"0.5916771",
"0.5908022",
"0.58967286",
"0.58628297",
"0.58628297",
"0.5858365",
"0.57895356",
"0.5757531",
"0.57030237",
"0.5702482",
"0.56907505",
"0.5672224",
"0.5671432",
"0.5647638",
"0.5643584",
"0.5641427",
"0.56391835",
"0.5630441",
"0.56129944",
"0.5587868",
"0.5575219",
"0.5558777",
"0.5536904",
"0.550846",
"0.550487",
"0.55016595",
"0.5490817",
"0.5471664",
"0.5446107",
"0.54430836",
"0.54219276",
"0.5411675",
"0.5403953",
"0.53931314",
"0.5382162",
"0.5367003",
"0.5360831",
"0.5341292",
"0.5340785",
"0.53404915",
"0.5318786",
"0.5315719",
"0.5312324",
"0.53035897",
"0.52959156",
"0.52866334",
"0.52776057",
"0.5262323",
"0.526044",
"0.5237286",
"0.52349603",
"0.5232861",
"0.52323365",
"0.5229421",
"0.52286243",
"0.52210623",
"0.5212102",
"0.5211878",
"0.51947576",
"0.5179719",
"0.5173657",
"0.5163961",
"0.5161094",
"0.51444685",
"0.5116395",
"0.51048315",
"0.510149",
"0.509565",
"0.50892115",
"0.507665",
"0.50714093",
"0.50689304",
"0.5050989",
"0.50441176",
"0.5035418",
"0.5020725",
"0.50202495",
"0.501942",
"0.50074345",
"0.49994433",
"0.49803162",
"0.4970652",
"0.49660593",
"0.4952081",
"0.49385062",
"0.4924837",
"0.49145818",
"0.49038452",
"0.48971552",
"0.4894797",
"0.48899513"
] | 0.69283813 | 0 |
Tripprepare doesn't care what preparers are, it's a duck that responds to prepare_trip | def prepare(preparers)
preparers.each { |preparer| preparer.prepare_trip(self) }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prepare(preparers)\n preparers.each do |prepaper|\n prepaper.prepape_trip(self)\n end\n end",
"def prepare(preparers)\n preparers.each {|preparer|\n preparer.prepare_trip(self) }\n end",
"def prepare(prepareers)\n\t\tprepareers.each { |prepare| prepare.prepare_trip(self)}\n\tend",
"def prepare(preparers)\n preparers.each do |prepaper|\n case prepaper\n when Mechanic\n prepaper.prepare_bicycles(bicycles)\n when TripCoordinator\n prepaper.buy_food(customers)\n when Driver\n prepaper.gas_up(vehicle)\n preparer.fill_water_tank(vehicle)\n end\n end\n end",
"def prepare\n # We get NotImplementedError by Tilt when we don't have this method\n end",
"def prepare\n end",
"def prepare\n end",
"def prepare\n end",
"def prepare\n end",
"def prepare\n end",
"def prepare\n end",
"def prepare\n end",
"def prepare(snip, part, args, enclosing_snip)\n # do nothing, by default\n end",
"def prepare(&block)\n @prepares << block\n end",
"def prepare\n end",
"def prepare; end",
"def prepare; end",
"def prepare; end",
"def prepare\n end",
"def prepare\n end",
"def prepare()\n end",
"def prepare!; end",
"def prepare!; end",
"def prepare!\n prepare_in_parallel!\n end",
"def prepare\n raise NotImplementedError\n end",
"def perform_prepare(type, file)\n sh \"wget http://static.quattroshapes.com/#{file}.zip -P #{TEMP_PATH}\" # download\n sh \"unzip #{TEMP_PATH}/#{file}.zip -d #{TEMP_PATH}\" # expand\n sh \"shp2pgsql -D -d -Nskip -I -WLATIN1 #{TEMP_PATH}/#{file}.shp qs_#{type} > #{TEMP_PATH}/#{file}.sql\" # convert\n sh \"#{psql_command} < #{TEMP_PATH}/#{file}.sql\" # import\n sh \"rm #{TEMP_PATH}/#{file}*\" # clean up\n end",
"def prepare(options = {})\n raise \"prepare not implemented\"\n end",
"def prepare\n @prepare ||= default_prepare\n end",
"def prepare\n prepare_prerequisites\n @prepared = true\n end",
"def prep\n\tend",
"def prepare\n #divide along parameters\n #@script.strip!()\n divided_script = @script.split(\"<!par!>\") \n script_with_params = []\n count = 0\n divided_script.each() {|part|\n #puts \"part [#{count}] = #{part}\"\n part.split(\"\\n\").each() {|line|\n next if line.strip.size == 0\n script_with_params << \"#{line.lstrip} \" #TODO: make this work with the line-breaks\n script_with_params << \"\\n\"\n }\n script_with_params.delete_at(script_with_params.size()-1)\n script_with_params << @parameter_array[count]\n count += 1\n }\n\n join = CfHelper.join(script_with_params)\n\n @user_data = join\n end",
"def prepare!\n @prepared = true\n @routes.sort_by!(&:order)\n self.class.setup_compiler! && compile! if Pendragon.configuration.enable_compiler?\n end",
"def prepare\n true\n end",
"def prepare\n true\n end",
"def preproc; end",
"def prepare &block\n @preparator = block\n end",
"def prepare(params)\n @query = params[:keywords]\n @sorting = params[:sorting]\n @taxons = params[:taxon] unless params[:taxon].nil?\n @browse_mode = params[:browse_mode] unless params[:browse_mode].nil?\n if params[:search] && params[:search][:price]\n # price\n @price_min = params[:search][:price][:min].to_f\n @price_max = params[:search][:price][:max].to_f\n # properties\n @properties = params[:search][:properties]\n end\n\n @per_page = (params[:per_page].to_i <= 0) ? Spree::Config[:products_per_page] : params[:per_page].to_i\n @page = (params[:page].to_i <= 0) ? 1 : params[:page].to_i\n end",
"def to_prepare(&blk); end",
"def prepare\n super\n end",
"def prepare(params)\n @query = Escaping.escape(params[:keywords] || \"\")\n @sorting = params[:sorting]\n @taxons = params[:taxon] unless params[:taxon].nil?\n @browse_mode = params[:browse_mode] unless params[:browse_mode].nil?\n if params[:search]\n # price\n if params[:search][:price]\n @price_min = params[:search][:price][:min].to_f\n @price_max = params[:search][:price][:max].to_f\n end\n # discount_rate\n if params[:search][:discount]\n @discount_min = params[:search][:discount][:min].to_f\n @discount_max = params[:search][:discount][:max].to_f\n end\n # properties\n @properties = params[:search][:properties]\n end\n\n @per_page = (params[:per_page].to_i <= 0) ? Spree::Config[:products_per_page] : params[:per_page].to_i\n @page = (params[:page].to_i <= 0) ? 1 : params[:page].to_i\n end",
"def prepare(server); end",
"def prepare admr\n \n end",
"def prepare; self; end",
"def prepare(params)\n @query = params[:keywords]\n @taxons = params[:taxon]\n if params[:search]\n # price\n @price_min = params[:search][:price][:min].to_f\n @price_max = params[:search][:price][:max].to_f\n # properties\n @properties = params[:search][:properties]\n end\n\n @per_page = (params[:per_page].to_i <= 0) ? Spree::Config[:products_per_page] : params[:per_page].to_i\n @page = (params[:page].to_i <= 0) ? 1 : params[:page].to_i\n end",
"def create_trip_proxy(trip)\n\n # get the planned trip for this trip\n planned_trip = trip.planned_trips.first\n \n # initailize a trip proxy from this trip\n trip_proxy = TripProxy.new\n trip_proxy.traveler = @traveler\n trip_proxy.trip_purpose_id = trip.trip_purpose.id\n trip_proxy.arrive_depart = planned_trip.is_depart\n trip_proxy.trip_date = planned_trip.trip_datetime.strftime(TRIP_DATE_FORMAT_STRING)\n trip_proxy.trip_time = planned_trip.trip_datetime.strftime(TRIP_TIME_FORMAT_STRING)\n \n # Set the from place\n trip_proxy.from_place = trip.trip_places.first\n if trip.trip_places.first.poi\n trip_proxy.from_place_selected_type = POI_TYPE\n trip_proxy.from_place_selected = trip.trip_places.first.poi.id\n elsif trip.trip_places.first.place\n trip_proxy.from_place_selected_type = PLACES_TYPE\n trip_proxy.from_place_selected = trip.trip_places.first.place.id\n else\n trip_proxy.from_place_selected_type = RAW_ADDRESS_TYPE \n end\n\n # Set the to place\n trip_proxy.to_place = trip.trip_places.last\n if trip.trip_places.last.poi\n trip_proxy.to_place_selected_type = POI_TYPE\n trip_proxy.to_place_selected = trip.trip_places.last.poi.id\n elsif trip.trip_places.last.place\n trip_proxy.to_place_selected_type = PLACES_TYPE\n trip_proxy.to_place_selected = trip.trip_places.last.place.id\n else\n trip_proxy.to_place_selected_type = RAW_ADDRESS_TYPE \n end\n \n return trip_proxy\n \n end",
"def make_a_trip\n end",
"def prepare(&block)\n @prepare = block\n end",
"def prepare_task\n end",
"def prepare\n []\n end",
"def _prepare(name, sql, datatypes = nil, tx = nil)\n run(:_send_parse, [name, sql, datatypes], tx)\n end",
"def preparation_params\n params.require(:preparation).permit(:ingredient_id, :recipe_id, :method)\n end",
"def pa_prepare(params)\n Offer.prepare_params(params.slice(:pub0, :uid, :page))\n end",
"def pre_process\n end",
"def prepared_args\n @opts[:prepared_args]\n end",
"def handle_trip_command input_params\n\t\tif input_params.count == 5\n\t\t\ttrip = Trip.new input_params[2].to_s, input_params[3].to_s, input_params[4].to_f\n\t\t\tdriver_name = input_params[1]\t\t\t\n\t\t\tself.create_trip trip, driver_name\t\n\t\telse \n\t\t\traise ArgumentError, \"Trip command requires a driver name, start time, end time, and distance\" \n\t\tend\n\tend",
"def prepare!\n Cleaner.prepare(self)\n end",
"def prepare!\n self.prepared_object = resolve_object\n end",
"def prepare_plan(options)\n\t options = validate_options options,\n\t\tmissions: 0, add: 0, discover: 0, tasks: 0,\n\t\tpermanent: 0,\n\t\tmodel: Roby::Task, plan: plan\n\n\t missions, permanent, added, tasks = [], [], [], []\n\t (1..options[:missions]).each do |i|\n\t\toptions[:plan].add_mission_task(t = options[:model].new(id: \"mission-#{i}\"))\n\t\tmissions << t\n\t end\n\t (1..options[:permanent]).each do |i|\n\t\toptions[:plan].add_permanent_task(t = options[:model].new(id: \"perm-#{i}\"))\n\t\tpermanent << t\n\t end\n\t (1..(options[:discover] + options[:add])).each do |i|\n\t\toptions[:plan].add(t = options[:model].new(id: \"discover-#{i}\"))\n\t\tadded << t\n\t end\n\t (1..options[:tasks]).each do |i|\n\t\ttasks << options[:model].new(id: \"task-#{i}\")\n\t end\n\n\t result = []\n\t [missions, permanent, added, tasks].each do |set|\n\t\tunless set.empty?\n\t\t result << set\n\t\tend\n\t end\n\n result = result.map do |set|\n if set.size == 1 then set.first\n else set\n end\n end\n\n if result.size == 1\n return result.first\n end\n return *result\n\tend",
"def prepare_data\n # This method is just a stub.\n end",
"def prepare(params)\n # keywords\n @query = params[:keywords]\n @promo = params[:promo]\n @recently = params[:recently]\n\n # sorting\n @sorting = params[:search][:s] if params[:search] && params[:search][:s]\n\n # taxons\n @taxons = params[:taxon] unless params[:taxon].nil?\n @remove_taxons = params[:remove_taxons] unless params[:remove_taxons].nil?\n\n # price\n @price_range = convert_to_array(params[:search][:price_any]) if params[:search] && params[:search][:price_any]\n\n # properties\n if params[:search]\n @properties = Hash.new\n\n params[:search].each do |key, value|\n\t next if key == 's' || key == 'price_any'\n\n case key\n when 'genre_any'\n @properties[:genero] = convert_to_array (value)\n when 'brand_any'\n value = convert_to_array (value).reject! { |c| c.blank? }\n @properties[:marca] = value unless value.nil? || value.empty?\n when 'condition_any'\n @properties[:condicao] = convert_to_array (value)\n when 'color_any'\n @properties[:cor] = convert_to_array (value)\n when 'size_any'\n @properties[:'tamanho-retroca'] = convert_to_array (value)\n end\n end\n end\n\n # pagination\n @per_page = (is_nil_or_negative? params[:per_page]) ? Spree::Config[:products_per_page] : params[:per_page].to_i\n @page = (is_nil_or_negative? params[:page]) ? 1 : params[:page].to_i\n end",
"def prepare_result; end",
"def run_prepare(opts, sources, devices, rng, io)\n sources.parse(@sources)\n mods = opts.categories ? sources.parse_mods(opts.categories) : nil\n sources.apply_mods(mods) if mods\n\n devices.storage_mount\n number = opts.number || rng.generate(sources.count)\n source = sources.get(number)\n\n puts io.run_info_table(source, number)\n source\n end",
"def set_preparation\n @preparation = Preparation.find(params[:id])\n end",
"def prepare\n #this is the fate thing, its included with the Rules module\n @toggle = fate\n @prepared = true\n end",
"def prepare(queryString)\n parameters = {}\n parameters[:as] = Kickit::Config.as\n\n if (queryString and !queryString.empty?)\n params = queryString.split('&')\n params.each do |param|\n name, value = param.split(\"=\")\n parameters[CGI.escape(name)] = CGI.escape(value)\n end\n end\n\n parameters = self.class.params.merge(parameters)\n parameters\n end",
"def prepare; dup; end",
"def prepare \n # initialize start values, prepare first generation\n begin\n self.start_values = IterativeLearning.build_condition(condition.start_values[\"each_chain\"], self)\n first_generation.prepare(self.start_values)\n rescue StandardError => e\n first_generation.prepare(condition.start_values)\n self.start_values = []\n end\n # initialize target values, if present\n begin\n self.target_values = IterativeLearning.build_condition(condition.target_values[\"each_chain\"], self)\n rescue StandardError\n self.target_values = []\n end\n self.save!\n end",
"def prepare_pre_import\n end",
"def prepare(p = {})\n @html = p[:html]\n @omni_parser_id = p[:omni_parser_id]\n true\n end",
"def create_trip(trip_proxy)\n\n trip = Trip.new()\n trip.creator = current_or_guest_user\n trip.user = @traveler\n trip.trip_purpose = TripPurpose.find(trip_proxy.trip_purpose_id)\n\n # get the start for this trip\n from_place = TripPlace.new()\n from_place.sequence = 0\n place = get_preselected_place(trip_proxy.from_place_selected_type, trip_proxy.from_place_selected.to_i, true)\n if place[:poi_id]\n from_place.poi = Poi.find(place[:poi_id])\n elsif place[:place_id]\n from_place.place = @traveler.places.find(place[:place_id])\n else\n from_place.raw_address = place[:address]\n from_place.lat = place[:lat]\n from_place.lon = place[:lon] \n end\n\n # get the end for this trip\n to_place = TripPlace.new()\n to_place.sequence = 1\n place = get_preselected_place(trip_proxy.to_place_selected_type, trip_proxy.to_place_selected.to_i, false)\n if place[:poi_id]\n to_place.poi = Poi.find(place[:poi_id])\n elsif place[:place_id]\n to_place.place = @traveler.places.find(place[:place_id])\n else\n to_place.raw_address = place[:address]\n to_place.lat = place[:lat]\n to_place.lon = place[:lon] \n end\n\n # add the places to the trip\n trip.trip_places << from_place\n trip.trip_places << to_place\n\n planned_trip = PlannedTrip.new\n planned_trip.trip = trip\n planned_trip.creator = trip.creator\n planned_trip.is_depart = trip_proxy.arrive_depart == 'departing at' ? true : false\n planned_trip.trip_datetime = trip_proxy.trip_datetime\n planned_trip.trip_status = TripStatus.find_by_name(TripStatus::STATUS_NEW) \n \n trip.planned_trips << planned_trip\n\n return trip\n end",
"def prepare(&block)\n define_method(:prepare, &block)\n end",
"def setup!\n @preparator.try(:call)\n end",
"def prepare_invoke!\n @prepared = true\n end",
"def prepare(amessage=nil)\n self.message = amessage if amessage\n self.message = (message || {}).with_indifferent_access\n\n logger.info \"BaseProcessor.prepare: #{message}\"\n\n if message['sequence']\n self.sequence = message['sequence']\n self.job = sequence.delete('job')\n self.tasks = sequence.delete('tasks')\n self.task = tasks.first\n elsif message['task']\n self.task = message['task']\n self.job = task.delete('job')\n self.tasks = [task]\n self.sequence = nil\n end\n end",
"def prepare( str )\n @db.prepare( str )\n end",
"def prepare(machine, folders, opts)\n end",
"def trip_params\n params.require(:trip).permit(\n :license_plate,\n :device_id,\n :cargo,\n :start_location,\n :start_address, \n :end_location,\n :end_address,\n :start_timestamp,\n :end_timestamp,\n :weight,\n :costumer,\n :start_comments,\n :end_comments)\n end",
"def prepare\n set_title\n set_name\n end",
"def prepare(str)\n st = Stmt.new @protocol, @charset\n st.prepare str\n st\n end",
"def prep\n ssh_session do |session|\n @results['prep'] = _recursor(@config['prep'],session)\n end\n @log.info \"FINISHED PREP STEPS....\"\n end",
"def compile\n prep\n client.setup_run_context\n end",
"def preprocess\n true\n end",
"def prepare *args, **kwds\n @last_prepared_cmd = Cmds.format render(*args, **kwds), self.format\n end",
"def prepare_params\n\n filtered_params = song_params\n\n # if no value specified, store a null\n filtered_params[:OrigBand] = nil if filtered_params[:OrigBand].strip.empty?\n filtered_params[:Author] = nil if filtered_params[:Author].strip.empty?\n filtered_params[:Lyrics] = nil if filtered_params[:Lyrics].strip.empty?\n filtered_params[:lyrics_ref] = nil if filtered_params[:lyrics_ref].strip.empty?\n filtered_params[:Comments] = nil if filtered_params[:Comments].strip.empty?\n\n filtered_params\n\n end",
"def prepair_params\n params.require(:prepair).permit(:title, :content)\n end",
"def prepare\n model.tap do |p|\n p.identifier = set_identifiers\n p.meta = set_meta\n p.text = set_text\n p.status = COMPLETED_STATUS\n p.authored = set_date\n p.author = set_author\n p.subject = set_subject\n p.questionnaire = set_questionnaire\n p.group = set_group\n end\n end",
"def skip_transcription(*args)\n @@skippable = args\n end",
"def prepare\n unless pre_commands.empty?\n checkout.in_build do |r|\n pre_commands.each { |c| r.run! c }\n end\n end\n end",
"def prepare(arguments, last_result = nil)\n\t\t\tArguments.extract(self, arguments, input: last_result)\n\t\tend",
"def prepare_plan(options)\n options = validate_options options,\n missions: 0, add: 0, discover: 0, tasks: 0,\n permanent: 0,\n model: Roby::Task, plan: plan\n\n missions, permanent, added, tasks = [], [], [], []\n (1..options[:missions]).each do |i|\n options[:plan].add_mission_task(t = options[:model].new(id: \"mission-#{i}\"))\n missions << t\n end\n (1..options[:permanent]).each do |i|\n options[:plan].add_permanent_task(t = options[:model].new(id: \"perm-#{i}\"))\n permanent << t\n end\n (1..(options[:discover] + options[:add])).each do |i|\n options[:plan].add(t = options[:model].new(id: \"discover-#{i}\"))\n added << t\n end\n (1..options[:tasks]).each do |i|\n tasks << options[:model].new(id: \"task-#{i}\")\n end\n\n result = []\n [missions, permanent, added, tasks].each do |set|\n unless set.empty?\n result << set\n end\n end\n\n result = result.map do |set|\n if set.size == 1 then set.first\n else\n set\n end\n end\n\n if result.size == 1\n return result.first\n end\n\n result\n end",
"def prepare(opts)\n BawWorkers::Validation.check_custom_hash(opts, BawWorkers::Jobs::Analysis::Payload::OPTS_FIELDS)\n\n opts[:datetime_with_offset] = BawWorkers::Validation.normalise_datetime(opts[:datetime_with_offset])\n\n # create started file in output dir\n dir_output = create_output_dir(opts)\n started_file = File.join(dir_output, FILE_WORKER_STARTED)\n FileUtils.touch(started_file)\n\n # create run dir and info\n run_info = create_run_info(opts)\n\n dir_run = run_info[:dir_run]\n dir_run_temp = run_info[:dir_run_temp]\n\n # copy programs directory to run dir\n dir_run_programs = copy_programs(dir_run)\n\n command_opts = {\n file_source: get_file_source(opts),\n file_executable: get_file_executable(dir_run_programs, opts),\n dir_output: dir_output,\n file_config: create_config_file(dir_run, opts),\n dir_run: dir_run,\n dir_temp: dir_run_temp\n }\n\n # format command string\n BawWorkers::Validation.check_custom_hash(command_opts,\n BawWorkers::Jobs::Analysis::Payload::COMMAND_PLACEHOLDERS)\n BawWorkers::Jobs::Analysis::Runner.check_command_format(opts)\n command_opts[:command] = BawWorkers::Jobs::Analysis::Runner.format_command(opts, command_opts)\n\n # include path to worker log file\n command_opts[:file_run_log] = run_info[:file_run_log]\n\n command_opts\n end",
"def prepare(str)\n close\n begin\n @sqlstate = \"00000\"\n @statement_id, @param_count, @fields = @protocol.stmt_prepare_command(str)\n rescue ServerError => e\n @last_error = e\n @sqlstate = e.sqlstate\n raise\n end\n ObjectSpace.define_finalizer(self, self.class.finalizer(@protocol, @statement_id))\n self\n end",
"def prep_variables\n end",
"def trip_params\n params.require(:trip).permit(:correspondance_id, :host_id, :duration, :start_date, :validated)\n end",
"def first_preprocessing(save=false)\n @@PREPROCESSING_TASKS.find do |t|\n not ignore_task?(t) and not add_result(t, save).nil?\n end\n end",
"def prepare\n render json: prepare(params)\n end",
"def prepare_request(params)\n request = process_params(params)\n request.store(:sizes, [extract_size(params.size)]) if params.size\n request.store(:format, params.format) if params.format\n request.store(:data, params.data) if params.data\n request.store(:uploader, params.uploader) if params.uploader\n request.store(:pages, params.pages) if params.pages\n request.store(:callback_url, params.callback_url) if params.callback_url\n request\n end",
"def prepare\n model.tap do |p|\n p.name = name\n p.identifier = set_identifiers\n p.meta = set_meta\n end\n end",
"def prepare\n model.tap do |p|\n p.name = name\n p.identifier = set_identifiers\n p.meta = set_meta\n end\n end",
"def prepare_response\n self.send(route, parse_query)\n end"
] | [
"0.73768985",
"0.7337407",
"0.6742725",
"0.6085478",
"0.6029285",
"0.58570355",
"0.58570355",
"0.58570355",
"0.58570355",
"0.58570355",
"0.58570355",
"0.58570355",
"0.58153194",
"0.5802087",
"0.57979494",
"0.5710099",
"0.5710099",
"0.5710099",
"0.56982344",
"0.56982344",
"0.562723",
"0.55806285",
"0.55806285",
"0.55764693",
"0.5572689",
"0.55662507",
"0.5540791",
"0.5530073",
"0.5495483",
"0.543892",
"0.5424385",
"0.541809",
"0.53369284",
"0.53369284",
"0.5273333",
"0.52510905",
"0.5148676",
"0.51415735",
"0.51102865",
"0.51013976",
"0.5090414",
"0.50741446",
"0.5072323",
"0.5061657",
"0.50462145",
"0.5039914",
"0.5035598",
"0.50058985",
"0.50012046",
"0.49908796",
"0.49731228",
"0.49696133",
"0.49655977",
"0.49195704",
"0.49152896",
"0.4884229",
"0.48828802",
"0.48783273",
"0.4876207",
"0.48695093",
"0.48613086",
"0.4858042",
"0.4824592",
"0.48207384",
"0.4803943",
"0.47751474",
"0.47679487",
"0.47617546",
"0.47586364",
"0.4750892",
"0.47449452",
"0.4736063",
"0.4717742",
"0.4692204",
"0.46865535",
"0.46637347",
"0.46613795",
"0.46602097",
"0.46410367",
"0.46267083",
"0.46239182",
"0.46182108",
"0.46179911",
"0.4606936",
"0.4605341",
"0.4603138",
"0.46026504",
"0.45938924",
"0.45922974",
"0.45906678",
"0.4572299",
"0.4569737",
"0.45680285",
"0.45556632",
"0.45549494",
"0.45548302",
"0.45505512",
"0.4549047",
"0.4549047",
"0.45213142"
] | 0.71852136 | 2 |
Starts the WebSocket client to consume the published info in the WebSocket Server | def start
logger.info('Starting the WebSocket Client...')
EventMachine.run do
puts '='*80, "Connecting to websockets server at ws://#{Settings.websocket.host}:#{Settings.websocket.port}", '='*80
http = EventMachine::HttpRequest.new("ws://#{Settings.websocket.host}:#{Settings.websocket.port}/websocket").get :timeout => 0
http.errback do
logger.error "something was wrong in the websocket_client"
end
http.callback do
puts "#{Time.now.strftime('%H:%M:%S')} : Connected to server"
end
http.stream do |msg|
puts msg
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start\n @thread = Thread.new do\n EM::WebSocket.start(ws_options) do |ws|\n ws.onopen do |handshake|\n log \"onopen: #{handshake.headers}\"\n @clients << ws\n end\n\n ws.onclose do |event|\n log \"closed: #{event}\"\n @clients.delete ws\n end\n\n ws.onmessage do |msg|\n log \"received: #{msg}\"\n end\n end\n end\n end",
"def start\n uri = URI.parse(\"ws://#{host}\")\n scheme = uri.port == 443 ? 'wss' : 'ws'\n @socket = Faye::WebSocket::Client.new(\"#{scheme}://#{uri.host}\")\n @socket.onopen = lambda {|event| on_open(event)}\n @socket.onclose = lambda {|event| on_close(event)}\n @socket.onmessage = lambda {|event| on_message(event)}\n true\n end",
"def start\n @socket = Faye::WebSocket::Client.new(url)\n @socket.onopen = lambda {|event| on_open(event)}\n @socket.onclose = lambda {|event| on_close(event)}\n @socket.onmessage = lambda {|event| on_message(event)}\n true\n end",
"def start\n @redis = Redis.new(:host => \"#{Settings.redis.host}\", :port => Settings.redis.port)\n\n \n Thread.new do\n EventMachine.run do\n \tputs '='*80, \"Starting websockets server at ws://#{Settings.websocket.host}:#{Settings.websocket.port}\", '='*80\n \n EventMachine::WebSocket.start(:host => \"#{Settings.websocket.host}\", :port => Settings.websocket.port) do |ws|\n ws.onopen do\n \n puts \"#{Time.now.strftime('%H:%M:%S')} : Client connected\", '-'*80\n SOCKETS << ws\n end\n\n ws.onclose do\n \n puts \"#{Time.now.strftime('%H:%M:%S')} : Client disconnected\", '-'*80\n SOCKETS.delete ws\n end\n end\n end\n end\n\n \n Thread.new do\n @redis.subscribe('ws') do |on|\n \n on.message do |chan, msg|\n \n puts \"#{msg}\"\n SOCKETS.each {|s| s.send msg} \n \n end\n end\n end\n\n sleep\n \n end",
"def start\n # Eventmachine run\n EM.run do\n # set what to do on message from websocket\n on_message\n\n # set what to do on close of websocket connection\n on_close\n end\n end",
"def run\n websocket.run\n end",
"def start\n puts 'launching server'\n EM::run do\n EM::WebSocket.run(:host => \"0.0.0.0\", :port => 6262) do |ws|\n sigHandler\n SparrowWSHandler.new ws\n end\n end\n end",
"def start_websocket_client\n # make sure log level is still set correctly here\n Bixby::Log.setup_logger(:level => Logging.appenders[\"file\"].level)\n logger.info \"Started Bixby Agent #{Bixby::Agent::VERSION}\"\n @client = Bixby::WebSocket::Client.new(Bixby.agent.manager_ws_uri, AgentHandler)\n trap_signals()\n @client.start\n end",
"def initialize\n\n logger.info(\"Starting WebSocketServer...\")\n \n end",
"def open(event)\n Firehose.logger.debug \"WebSocket subscribed to `#{@req.path}`. Waiting for message_sequence...\"\n end",
"def start()\n #start listening\n @transport.monitor do |rmsg,header,payload|\n consume(rmsg,header,payload)\n end\n end",
"def start\n @client.on :hello do\n puts \"Successfully connected, welcome '#{@client.self.name}' to the '#{@client.team.name}' team at https://#{@client.team.domain}.slack.com.\"\n end\n @client.on :close do |_data|\n puts \"Client is about to disconnect\"\n end\n @client.on :closed do |_data|\n puts \"Client has disconnected successfully!\"\n end\n\n @client.on :message do |data|\n message = data.text\n bot_id = @client.self.id\n if self.needs_help?(message, bot_id)\n @client.message channel: data.channel, text: self.respond_help\n else\n symbol_doc = self.read(message, bot_id)\n if self.must_respond?(symbol_doc)\n if symbol_doc.success\n @client.message channel: data.channel, text: self.respond_ok(symbol_doc)\n else\n if message.split.count > 1\n @client.message channel: data.channel, text: self.respond_error(symbol_doc)\n end\n end\n end\n end\n end\n\n @client.start!\n end",
"def websocket_client\n @websocket_client ||= Faye::WebSocket::Client.new(rtm_start.websocket_url)\n end",
"def run_event_machine\n EventMachine.run do\n # ws = Current Web Socket.\n EventMachine::WebSocket.start(:host => '0.0.0.0', :port => port) do |ws|\n \n ws.onopen do\n prepare(ws)\n onopen\n end\n\n ws.onmessage do |mes|\n prepare(ws)\n onmessage mes\n end\n \n ws.onclose do\n prepare(ws)\n onclose\n end\n end\n end\n \n end",
"def start\n subscribe &Proc.new { |message| listener(message) }\n end",
"def websocket; end",
"def websocket; end",
"def start\n $0 = \"vines: #{@id}\"\n\n @connection.connect\n @publisher.broadcast(:online)\n @subscriber.subscribe\n\n EM.add_periodic_timer(1) { heartbeat }\n\n at_exit do\n @publisher.broadcast(:offline)\n @sessions.delete_all(@id)\n end\n end",
"def start\n # subscribe is like a callback\n @server_queue.subscribe(block: @block) do |delivery_info, properties, payload|\n consume(delivery_info, properties, payload)\n end\n end",
"def run\n AMQP.start(:host => \"localhost\") {\n @mq = MQ.new\n @update_channel = EM::Channel.new\n @deferred_responses = {}\n\n @queue_name = \"cmdr:websocket:#{self.object_id}\"\n @queue = @mq.queue(@queue_name)\n \n # watch for responses from devices\n @queue.subscribe{|json|\n msg = JSON.parse(json)\n puts \"Got response: #{msg}\"\n if @deferred_responses[msg[\"id\"]]\n @deferred_responses.delete(msg[\"id\"]).succeed(msg)\n end\n }\n\n topic = @mq.topic(EVENT_TOPIC)\n @mq.queue(\"cmdr:websocket:#{self.object_id}:response\").bind(topic, :key => \"device.*\").subscribe do |json|\n handle_event json\n end\n\n setup\n\n EM::WebSocket.start({\n :host => \"0.0.0.0\",\n :port => 8000,\n :debug => false\n #:secure => true \n }) do |ws|\n\n ws.onopen { onopen ws }\n \n ws.onmessage {|json| onmessage ws, json}\n \n ws.onclose do\n @update_channel.unsubscribe(@sid) if @sid\n DaemonKit.logger.debug \"Connection on #{ws.signature} closed\"\n end\n\n ws.onerror do\n DaemonKit.logger.debug \"Error on #{ws.signature}\"\n end\n end\n }\n end",
"def run\n AMQP.start(:host => \"localhost\"){\n\n @update_channel = EM::Channel.new\n\n url = \"#{DB_URI}/rooms/_changes?feed=continuous&since=#{@seq}&heartbeat=500\"\n http = EM::HttpRequest.new(url).get\n http.stream{|chunk|\n msg = JSON.parse chunk rescue nil\n update msg if msg\n }\n http.callback{ DaemonKit.logger.debug \"CouchDB connection closed\" }\n\n MQ.queue(WEBSOCKET_QUEUE).subscribe{|json|\n #begin\n msg = JSON.parse(json)\n DaemonKit.logger.debug(\"Websocket:MQ: \" + msg.inspect)\n @deferred_responses[msg[\"id\"]].succeed(msg)\n #rescue\n # DaemonKit.logger.debug \"Got error: #{$!}\" \n #end\n }\n \n EM::WebSocket.start({\n :host => \"0.0.0.0\",\n :port => WEBSOCKET_PORT,\n :secure_proxy => true\n }) do |ws|\n ws.onopen { onopen ws }\n\n ws.onmessage {|json| onmessage ws, json}\n\n ws.onclose {\n DaemonKit.logger.debug(\"Connection on #{ws.signature} closed\")\n }\n end\n }\n end",
"def listen\n @@em.schedule do\n EventMachine::WebSocket.run(:host => @host, :port => @port) do |ws|\n ws.onopen { }\n ws.onclose { @connection_event_handlers[:closed].each { |h| h.call self } }\n ws.onerror { |e| @connection_event_handlers[:error].each { |h| h.call self } }\n ws.onmessage { |msg| handle_message(msg, ws) }\n end\n end\n self\n end",
"def start\n @state = STARTED\n logger.info \"Starting producer with host_params:#{@host_params}\"\n @connection_start_time = Time.new\n @stomp = start_server(@host_params, @options.user, @options.passwd)\n rescue => e\n logger.error \"Error occurred while starting a connection: #{e}\\n #{e.backtrace.join(\"\\n\")}\"\n end",
"def start\n\n self.listener = Rex::Socket::TcpServer.create(\n 'LocalHost' => self.listen_host,\n 'LocalPort' => self.listen_port,\n 'Context' => self.context,\n 'SSL' => self.ssl,\n 'SSLCert' => self.ssl_cert,\n 'SSLCompression' => self.ssl_compression,\n 'SSLCipher' => self.ssl_cipher,\n 'Comm' => self.comm\n )\n\n # Register callbacks\n self.listener.on_client_connect_proc = Proc.new { |cli|\n on_client_connect(cli)\n }\n self.listener.on_client_data_proc = Proc.new { |cli|\n on_client_data(cli)\n }\n\n self.listener.start\n end",
"def start\n begin\n socket = connect()\n rescue NotAuthorized => e\n return nil\n rescue Errno::ECONNREFUSED => e\n puts \"The connection was refused (#{e.to_s}). Goodbye.\"\n return nil\n rescue => e\n puts \"Failed to connect: #{e.to_s}\\n #{$@}\"\n return nil\n end\n\n return nil unless socket\n\n begin\n listen_thread =\n Thread.new do\n print '> '\n STDOUT.flush\n loop do\n scribe( socket )\n end\n end\n\n loop do\n deliver( socket )\n end\n\n rescue => e\n puts \"An error occured: #{e.to_s}\\n #{$@}\"\n ensure\n listen_thread.kill if listen_thread\n disconnect( socket )\n end\n end",
"def initialize(url, cookies, logs: false, &handler)\n @super_logger = Logger.new(logs ? 'ws_super_logger.log' : '/dev/null')\n\n @uri = URI.parse(url)\n @url = \"ws#{@uri.scheme.split(\"\")[4]}://#{@uri.host}\"\n\n if @uri.scheme.split(\"\")[4] == 's'\n @socket = TCPSocket.new(@uri.host, 443)\n @super_logger.info \"Opened TCP socket for (port 443) #{@uri} (#{@socket})\"\n @socket = OpenSSL::SSL::SSLSocket.new(@socket)\n @socket.connect\n @super_logger.info \"Upgrade TCP socket to SSL socket socket for #{@uri} (#{@socket})\"\n else\n @socket = TCPSocket.new(@uri.host, 80)\n @super_logger.info \"Opened TCP socket for (port 80) #{@uri} (#{@socket})\"\n end\n\n @handler = handler\n @logger = Logger.new(logs ? \"realtime.log\" : '/dev/null')\n @restart = true\n @super_logger.info \"Set @restart to #{@restart}\"\n\n @driver = WebSocket::Driver.client(self)\n @driver.add_extension PermessageDeflate\n @driver.set_header \"Cookies\", cookies if cookies\n @driver.set_header \"Origin\", \"#{@uri.scheme}://#{@uri.host.split('.')[-2..-1].join('.')}\"\n\n @driver.on :connect, ->(_e) {}\n\n @driver.on :open, ->(_e) do\n send \"155-questions-active\"\n @super_logger.info \"Socket open. Subscribed to 155-questions-active\"\n @logger.info \"WebSocket is open!\"\n end\n\n @driver.on :message do |e|\n @logger.info(\"Read: #{e.data}\")\n data = JSON.parse(e.data)\n if data[\"action\"] == \"hb\"\n send \"hb\"\n else\n @handler.call(data)\n end\n end\n\n @driver.on :close, ->(_e) do\n @logger.info \"Realtime WebSocket is closing.\"\n @super_logger.info \"Socket was closed. @restart == #{@restart}\"\n if @restart\n @logger.info \"Attempting to reopen websocket...\"\n @super_logger.info \"Attempting to reopen socket\"\n @driver.start\n end\n end\n\n @driver.on :error, ->(e) { @logger.error e }\n\n @driver.start\n\n @dead = false\n @thread = Thread.new do\n trap(\"SIGINT\") do\n @restart = false\n @dead = true\n @super_logger.info \"Got SIGINT. Dying.\"\n close\n Thread.exit\n end\n begin\n @driver.parse(@socket.is_a?(TCPSocket) ? @socket.recv(1) : @socket.sysread(1)) until @dead\n rescue IOError, SystemCallError => e\n @super_logger.warn \"Got some kind of interrupt in the thread. Panic.\"\n @logger.warn \"Recieved #{e} closing TCP socket. You shouldn't be worried :)\"\n end\n @super_logger.warn \"Left TCPSocket.recv loop. If you're reading this, panic.\"\n end\n\n at_exit { @thread.join }\n end",
"def connect\n start_listener!\n end",
"def start\n EM.run do\n @__conn = EventMachine::WebSocketClient.connect(@__socket_url)\n\n @__callbacks[:connection_established] &&\n @__conn.callback do\n instance_exec(&@__callbacks[:connection_established])\n end\n\n @__callbacks[:error] &&\n @__conn.errback do |e|\n instance_exec(e, &@__callbacks[:error])\n end\n\n @__conn.stream do |msg|\n @__conn.close_connection if msg.data == \"done\"\n\n event = JSON.parse(msg.data)[1]\n case event['type']\n when 'paired'\n @__event_pool[:paired] = event\n\n when 'connected'\n break unless @__callbacks[:connected]\n instance_exec(&@__callbacks[:connected])\n @__event_pool[:connected] = event\n\n when 'arm_synced'\n @__event_pool[:arm_synced] = event\n\n when 'unlocked'\n puts(\"unlocked!\")\n @__event_pool[:unlocked] ||= false\n @__event_pool[:unlocked] = true\n\n when 'pose'\n\n break unless @__callbacks[:pose]\n pose = event['pose']\n puts \"this is pose: \" + pose\n #instance_exec(@__event_pool[:pose][:pose], :off, &@__callbacks[:pose]) if @__event_pool[:pose][:pose]\n instance_exec(pose, :on, &@__callbacks[:pose])\n @__event_pool[:pose] = event\n\n when 'orientation'\n break unless @__callbacks[:periodic]\n e = OpenStruct.new({\n :accel => OpenStruct.new({\n :x => event['accelerometer'][0],\n :y => event['accelerometer'][1],\n :z => event['accelerometer'][2]\n }),\n :gyro => OpenStruct.new({\n :x => event['gyroscope'][0],\n :y => event['gyroscope'][1],\n :z => event['gyroscope'][2]\n }),\n :orientation => OpenStruct.new(event['orientation'])\n })\n @__event_pool[:orientation] = e\n instance_exec(e, &@__callbacks[:periodic])\n\n end\n end\n\n @__conn.disconnect do\n EM::stop_event_loop\n end\n end\n end",
"def make_websocket\n require 'em-websocket'\n require 'sanitize'\n\nsoc = []\n\n\n\nEM::WebSocket.start(host: '10.20.4.130' , port: 4000) do |ws|\n\n ws.onopen{soc << ws;puts \"#{soc.length} clients present\";}\n ws.onmessage { |msg| ; soc.each do |s| \n msg = Sanitize.clean(msg.html_safe , :elements => %w(font) , :attributes => {'font' => ['color']})\n\t\t\t\ts.send(\"#{msg}\")\n\t\t\t\tend ; $redis.LPUSH 'msg', \"#{msg}\" }\n ws.onclose {puts \"Someone dissconected \" ; soc.delete(ws)}\n end\n end",
"def run\n EventMachine::run do\n @tcp = EventMachine::connect(config.server.host, config.server.port, TCPConnection)\n @tcp.client = self\n spectator_join\n end\n end",
"def websocket port = nil\n host = @source[\"resource\"].first\n path = @source[\"resource\"][1..-1].join('/')\n if port.nil?\n connection_uri = \"ws://#{host}:#{@config.port.outbound}/#{path}\"\n else\n connection_uri = \"ws://#{host}:#{port}/#{path}\"\n end\n\n begin \n ws = EM::WebSocketClient.connect connection_uri\n ws.callback do \n ws.send_msg @source.to.json\n @config.logger.debug @source.to_s\n ws.close_connection_after_writing\n end\n rescue RuntimeError => e\n EM.run do\n ws = EM::WebSocketClient.connect connection_uri\n\n ws.callback do \n ws.send_msg @source.to.json\n @config.logger.debug @source.to_s\n ws.close_connection_after_writing\n end\n\n ws.disconnect do \n EM::stop_event_loop\n end\n end\n end\n end",
"def run!\n client.on(:hello, &responder.hello)\n client.on(:message, &responder.message)\n client.start!\n end",
"def start\n @client = ::Slack::RealTime::Client.new(token: @token)\n @running = true\n\n client.on :open do |event|\n @connected = true\n log \"connected to '#{team_name}'\"\n run_callbacks(:start)\n end\n\n client.on :message do |data|\n begin\n debug message: data\n @last_received_user_message = data\n handle_message(data)\n rescue => e\n log_error e, \"Error handling message #{data.inspect}\"\n end\n end\n\n client.on :close do |event|\n log \"disconnected\"\n @connected = false\n run_callbacks(:finish)\n end\n\n register_low_level_callbacks\n\n client.start_async\n rescue Slack::Web::Api::Error => e\n log \"Connection error for bot #{key}\"\n raise ConnectionError.new(e.message, e.response)\n end",
"def start_broker()\n\n Thread.new do\n `ruby -r 'simplepubsub' -e \"SimplePubSub::Broker.start port: '55000'\"`\n end\n\n end",
"def listen\n connect do\n routes.each do |route|\n @client.subscribe(route) do |args|\n run(route, args)\n end\n end\n \n loop do\n sleep 1\n end\n end\n end",
"def connect\n require 'osc-ruby' unless defined?(::OSC)\n port = additional_params[:port] || 3333\n @client = OSC::Server.new(port)\n super\n end",
"def run\n @security = Communication::Security.new_client\n\n @subscribe_socket = Communication::SubscribeSocket.new_link(\n Pantry.config.server_host,\n Pantry.config.pub_sub_port,\n @security\n )\n @subscribe_socket.add_listener(self)\n @subscribe_socket.filter_on(@listener.filter)\n @subscribe_socket.open\n\n @send_socket = Communication::SendSocket.new_link(\n Pantry.config.server_host,\n Pantry.config.receive_port,\n @security\n )\n @send_socket.open\n\n @file_service = Communication::FileService.new_link(\n Pantry.config.server_host,\n Pantry.config.file_service_port,\n @security\n )\n @file_service.start_client\n end",
"def listen\n connect do\n routes.each do |queue|\n @client.subscribe(queue) do |args|\n run(queue, args)\n end\n end\n end\n while (!Thread.current[:shutdown]) do\n sleep(self.class.sleep_time)\n end\n end",
"def initialize( host, port = 8888, path = \"websocket\",\n version = self.version, support )\n super(\"http://#{host}:#{port}/#{path}\") #setup websocket connection\n\n self.init_event_handlers()\n\n @callbacks = {}\n @collections = {}\n @subs = {}\n @version = version\n @session = nil\n @curr_id = 0\n @support = support\n\n end",
"def connect!\n EventMachine.run do\n EventMachine::MQTT::ClientConnection.connect(@server) do |c|\n c.subscribe(@topic)\n c.receive_callback do |message|\n handle_incoming_message(message)\n end\n end\n end\n end",
"def connect\n EM.run do\n client = Faye::WebSocket::Client.new(@url)\n reconnect_url = nil\n\n client.on :message do |msg|\n message_received(client, msg)\n end\n\n client.on :open do |e|\n OutputLogger.logger.info 'Connection Opened!'\n end\n\n client.on :close do |e|\n OutputLogger.logger.info 'Connection closed, trying to reconnect.'\n\n reconnect\n end\n\n client.on :error do |e|\n OutputLogger.logger.error e.inspect\n end\n\n client.on 'transport:down' do |e|\n OutputLogger.logger.info 'Connection down.'\n end\n\n client.on 'transport:up' do |e|\n OutputLogger.logger.info 'Connection back up, trying to reconnect.'\n\n reconnect\n end\n end\n end",
"def test1 #fails\n\n EventMachine::WebSocket.start(:host => \"0.0.0.0\", :port => 8567) do |ws|\n ws.onopen do\n puts \"WebSocket opened\"\n conn = Bunny.new\n conn.start\n#ch = conn.default_channel\n q = $ch.queue(\"tweets\")\n q.subscribe(:block => true) do |delivery_info, properties, body|\n puts \"Received tweet\\n\"\n ws.send \"test\"\n end\n end\n ws.onclose do\n ws.close(code = nil, body = nil)\n puts \"WebSocket closed\"\n# exit\n end\n end\nend",
"def on_open(client)\n client.subscribe \"chat\"\n # let everyone know we arrived\n client.publish \"chat\", \"#{@name} entered the chat.\"\n end",
"def initialize( host, port = 8888, path = \"websocket\",\n version = 1, support )\n super(\"http://#{host}:#{port}/#{path}\") #setup websocket connection\n\n self.init_event_handlers()\n @callbacks = {}\n @collections = {}\n @subs = {}\n @sub_ids = {}\n @version = version\n #setup database info\n @mongo = self.get_db_conn\n\n end",
"def start\n _connect\n sleep 1\n end",
"def start\n @server = TCPServer.open(@hostname, @port)\n loop do\n Thread.new(@server.accept) do |client|\n while message = client.gets\n fmp = ForeignMessageParser.new(message)\n Mailbox.append(fmp.to_event) if fmp.got_valid_message?\n end\n client.close\n end\n end\n end",
"def em_connect()\n @mutex.synchronize do\n @wscon = WebSocket::EventMachine::Client.connect(:uri => @wsuri)\n end\n @wscon.comm_inactivity_timeout = 60\n\n @wscon.onopen do\n @status = :open\n end\n\n @wscon.onmessage do |data|\n EM.defer do\n packet = JSON.load(data)\n if @status == :open\n if packet.has_key? \"error\"\n LogService.warn \"packet error: #{packet[\"type\"]}, #{packet[\"error\"]}\"\n end\n \n if @callbacks.has_key? packet[\"type\"]\n @callbacks[packet[\"type\"]].each do |c|\n c.call(packet[\"data\"])\n end\n end\n end\n end\n end\n\n @wscon.onclose do |code, reason|\n if @status == :closing\n @status = :closed\n elsif @status == :open || @status == :opening\n @status = :opening\n EM.add_timer(10) do\n em_connect()\n end\n end\n end\n end",
"def initialize(endpoint, open_handler, message_handler, close_handler, error_handler)\n Discordrb::LOGGER.debug \"Using WSCS version: #{::WebSocket::Client::Simple::VERSION}\"\n\n @open_handler = open_handler\n @message_handler = message_handler\n @close_handler = close_handler\n @error_handler = error_handler\n\n instance = self # to work around WSCS's weird way of handling blocks\n\n @client = ::WebSocket::Client::Simple.connect(endpoint) do |ws|\n ws.on(:open) { instance.open_handler.call }\n ws.on(:message) do |msg|\n # If the message has a code attribute, it is in reality a close message\n if msg.code\n instance.close_handler.call(msg)\n else\n instance.message_handler.call(msg.data)\n end\n end\n ws.on(:close) { |err| instance.close_handler.call(err) }\n ws.on(:error) { |err| instance.error_handler.call(err) }\n end\n end",
"def start\n @quit = nil\n @socket = self.connect()\n self.on_message(/^PING/) { |event|\n self.send_raw_line(\"PING \"+event[:matchdata].post_match)\n }\n self.on_server_message(353) { |event|\n }\n self.on_server_message(376) do |event|\n if @password and !@authenticated then\n self.message 'NickServ', \"IDENTIFY #{@password}\"\n @authenticated = true\n end\n @channels.each { |channel|\n if channel.kind_of? Hash then\n self.send_raw_line(\"JOIN \"+channel.keys.first+\" \"+channel.values.first)\n else\n self.send_raw_line(\"JOIN \"+channel)\n end\n }\n end\n \n self.send_raw_line(\"USER \"+@nickname+\" \"+@nickname+\" \"+@nickname+\" \"+@nickname)\n self.send_raw_line(\"NICK \"+@nickname)\n begin\n while line = @socket.gets\n handle_raw_line(line) \n end\n rescue IOError => ioe\n raise ioe unless @quit\n end\n end",
"def start(json)\n if ws\n logger.warn 'RTM session start requested, but already running. Ignoring...'\n return false\n end\n h = parse_rtm_start_res(json)\n @self_uid = h[:self_id]\n logger.info \"I am Slack ID: #{self_uid}. Connecting to websocket...\\n URL: #{h[:url]}\"\n opts = {ping: 60}\n @websocket = Faye::WebSocket::Client.new(h[:url], nil, opts)\n\n ws.on :open do\n logger.debug 'Websocket opened'\n touch_ts\n end\n\n ws.on :message do |ws_event|\n touch_ts\n event = JSON.parse(ws_event.data, {symbolize_names: true})\n case event[:type]\n when 'hello'\n hello_handler(event)\n when 'pong'\n pong_handler(event)\n else\n run_event_handlers(event)\n end\n @stats[:events_received] ||= 0\n @stats[:events_received] += 1\n end\n\n ws.on :close do |ws_event|\n logger.warn 'RTM session closed'\n cleanup\n end\n \n return true\n end",
"def start(controller = Stream::StreamController.instance)\n # make sure all the keys are set\n validate_keys\n\n options = update_config_options\n\n # create a new server\n @server = WEBrick::HTTPServer.new(Port: options[:port])\n\n # start singleton stream controller\n @controller = controller.start\n\n # mount the REST server on webrick\n @server.mount '/', Http::HttpEndpoint\n\n trap_signals\n\n logger.info(\"Server starting with PID #{Process.pid}\")\n\n @server.start\n end",
"def init_message_listener\n begin\n message = @client.gets\n init_message(message)\n end until @client.closed?\n end",
"def start\n\n @writer = Writer.new.start\n @worker_pool = WorkerPool.new create_listen_socket\n\n sig_init\n master_loop\n shutdown_writer\n\n end",
"def start\n # Don't send asynchronously\n if Deimos.config.producers.backend == :kafka_async\n Deimos.config.producers.backend = :kafka\n end\n Deimos.config.logger.info('Starting...')\n @signal_to_stop = false\n retrieve_poll_info\n loop do\n if @signal_to_stop\n Deimos.config.logger.info('Shutting down')\n break\n end\n process_updates\n sleep 0.1\n end\n end",
"def run\n loop do\n client_sock = @server.accept\n client = Rsws_client.new(client_sock)\n yield client\n end\n end",
"def open_socket\n loop {\n listen_for_client\n\n # read first input line only\n request = @client.gets\n\n resp = process_client_request(request)\n headers = generate_headers(resp)\n\n @client.puts headers\n @client.puts resp\n\n @client.puts \"Disconnecting client...\"\n @client.close # close connection to client\n }\n end",
"def open\n @thread = Thread.new{ @wamp_client.open }\n end",
"def listen \n response.headers[\"Content-Type\"] = \"text/event-stream\"\n redis = Redis.new\n\n key = \"/node/#{params[:event_id]}:change\"\n logger.info \"listen #{key}\"\n redis.subscribe(key) do |on|\n on.message do |event, data|\n response.stream.write \"event: update\\n\"\n response.stream.write \"data: \"+data+\"\\n\\n\"\n end\n end\n\n rescue IOError \n # Client disconnected\n ensure \n response.stream.close\n end",
"def start\n\t\tself.socket.connect( self.class.host, self.class.port )\n\n\t\tsuper\n\tend",
"def connect\n if @connected\n block_given? and yield Exception.new 'mailbox has already connected'\n return\n end\n\n begin\n @ws = WebSocket::EventMachine::Client.connect :uri => 'ws://' + @host + ':' + @port.to_s\n @ws.onopen {\n return if @connected\n @connected = true\n @timer = EM.add_periodic_timer(@interval) { flush } if @buffer_msg\n block_given? and yield\n }\n\n @ws.onmessage { |msg, type|\n process_msg msg, type\n }\n\n @ws.onerror { |err| }\n @ws.onclose { |code, reason|\n emit :close, @id\n }\n rescue => err\n block_given? and yield err\n end\n end",
"def run\n room = robot.config.adapters.shell.private_chat ? nil : \"shell\"\n @source = Source.new(user: user, room: room)\n puts t(\"startup_message\")\n robot.trigger(:connected)\n\n run_loop\n end",
"def websocket\n @web_socket ||= WebSocket.new\n end",
"def start\n self.connect\n self.login if @connected\n end",
"def startWss(callback_opts) do\n server = TCPServer.new @port\n while session = server.accept\n @implementation(session.gets)\n end\n end",
"def init_client(uri, &on_init)\n connection = nil\n @connections_lock.synchronize {\n connection = @connections.find { |c|\n c.url == uri\n }\n if connection.nil?\n connection = EventMachine::WebSocketClient.connect(uri)\n connection.callback do\n on_init.call(connection)\n end\n @connections << connection\n # TODO sleep until connected?\n else\n on_init.call(connection)\n end\n }\n connection\n end",
"def listen_for_client\n puts \"Listening...\"\n @client = @server.accept\n puts \"A client connected.\"\n @client.puts \"Connected to server!\"\n end",
"def start\n while listen\n # Loop for-ev-er\n end\n end",
"def start\n @serv = EventMachine::start_server \"0.0.0.0\", @port, Server, self\n \t\t\t\tif @peers\n \t\t\t\t\[email protected] do |peer|\n \t\t\t\t\t\tpeer.connection = EventMachine::connect peer.ip, peer.port, Client, self, peer\n @pm.add(peer)\n \t\t\t\t\tend\n \t\t\t\tend\n end",
"def start\n # Synchronous (mutual exclusion) message processing is handled by a\n # producer-consumer approach. The socket pushes messages onto this queue,\n # which are processed by a consumer thread one at a time.\n @messages = Queue.new\n @message_consumer = Thread.new do\n loop do\n meths = @messages.pop\n begin\n meths.each { |meth, args| broadcast_sync meth, *args }\n rescue\n options[:logger].error $!\n end\n end\n end\n \n @socket = connect\n username = @options[:user]\n username ||= @nick\n realname = @options[:name]\n realname ||= @nick\n \n pass @options[:server_password] if @options[:server_password]\n user username, @nick, @nick, realname\n nick @nick\n \n while line = @socket.gets\n meths = receive line # parse the line and get a list of methods to call\n @messages.push meths # push the methods on the queue; the consumer thread will execute all the synchronous methods\n # then execute all the other methods in their own thread\n meths.each { |meth, args| broadcast meth, *args }\n end\n end",
"def listen\n setup = lambda {\n connect do\n routes.each do |route|\n @client.subscribe(route) do |args|\n run(route, args)\n end\n end\n end\n }\n if EM.reactor_running?\n setup.call\n if EM.respond_to?(:reactor_thread)\n # EM 0.12.9+\n EM.reactor_thread.join\n else\n # EM 0.12.8\n EM.instance_variable_get(:@reactor_thread).join\n end\n else\n EM.run &setup\n end\n end",
"def start\n @client = @socket.accept\n client_compliance = read_line # Check to make sure client is the correct version\n if client_compliance != $SERVER_VERSION\n write('Incorrect server compliance. Please update your api.')\n abort('A client has the wrong server compliance')\n end\n\n write('START')\n write(@team.number.to_s)\n end",
"def subscribed\n \t#stream_from 'demo_chan'\n end",
"def on_open client\n c = controller(client)\n c.instance_variable_set(CLIENT_NAME, client)\n if client.protocol == :sse\n c.on_sse\n else\n c.on_open\n end\n end",
"def start\n logger.info('StreamController starting')\n @stream_parser.begin_read\n self\n end",
"def initialize(opts)\n\n # Initializing with a single hash\n @options = opts.symbolize_keys\n\n @auto_pong = @options.fetch(:auto_pong, nil) || CapistranoSentinel.config.auto_pong\n @read_buffer_size = @options.fetch(:read_buffer_size, nil) || CapistranoSentinel.config.read_buffer_size\n @reconnect = @options.fetch(:reconnect, nil) || CapistranoSentinel.config.reconnect\n @retry_time = @options.fetch(:retry_time, nil) || CapistranoSentinel.config.retry_time\n\n\n @secure = @options.fetch(:secure, nil) || CapistranoSentinel.config.secure\n\n @host = @options.fetch(:host, nil) || CapistranoSentinel.config.host\n @port = @secure ? 443 : (@options.fetch(:port, nil) || CapistranoSentinel.config.port)\n @path = @options.fetch(:path, nil) || CapistranoSentinel.config.path\n @query = @options.fetch(:query, nil)\n\n @actor ||= @options.fetch(:actor, nil)\n @channel ||= @options.fetch(:channel, nil)\n\n\n @closed = false\n @opened = false\n\n @on_open = lambda {\n log_to_file(\"native websocket client websocket connection opened\")\n subscribe(@channel) if @channel.present?\n }\n\n @on_close = lambda { |message|\n log_to_file(\"#{@actor.class} client received on_close #{message.inspect}\")\n if @actor.present? && @actor.respond_to?(:on_close)\n if @actor.respond_to?(:async)\n @actor.async.on_close(message)\n else\n @actor.on_close(message)\n end\n end\n }\n\n @on_ping = lambda { |message|\n log_to_file(\"#{@actor.class} client received PING #{message.inspect}\")\n if @actor.present? && @actor.respond_to?(:on_ping)\n if @actor.respond_to?(:async)\n @actor.async.on_ping(message)\n else\n @actor.on_ping(message)\n end\n end\n }\n\n @on_error = lambda { |error|\n log_to_file(\"#{@actor.class} received ERROR #{error.inspect} #{error.backtrace}\")\n if @actor.present? && @actor.respond_to?(:on_error)\n if @actor.respond_to?(:async)\n @actor.async.on_error(error)\n else\n @actor.on_error(error)\n end\n end\n }\n\n @on_message = lambda { |message|\n message = parse_json(message)\n log_to_file(\"#{@actor.class} websocket client received JSON #{message}\")\n if @actor.present? && @actor.respond_to?(:async)\n log_to_file(\"#{@actor.class} works async on message #{message.inspect}\")\n @actor.async.on_message(message)\n else\n @actor.on_message(message)\n end\n }\n connect\n end",
"def start\n enable_cow\n start_bunny\n register_signals\n create_queues\n end",
"def connect client_id, host, port, &block\n @client_id = client_id\n @ws = WebSocket::EventMachine::Client.connect :uri => 'ws://' + host + ':' + port.to_s\n @ws.onopen {\n @state = :state_connected\n @password = Utils.md5 @password if @md5\n @ws.send ['register', {\n :type => 'client',\n :client_id => @client_id,\n :username => @username,\n :password => @password,\n :md5 => @md5\n }].to_json\n }\n @ws.onmessage { |msg, type|\n begin\n event, msg = parse msg\n case event\n when 'register'\n process_register_msg msg, &block\n when 'client'\n process_client_msg msg\n else\n end\n rescue => err\n end\n }\n @ws.onclose { |code, reason|\n @state = :state_closed\n emit 'close'\n }\n @ws.onerror { |err|\n if @state == :state_inited\n block_given? and yield err\n end\n emit 'error', err\n }\n end",
"def listen port, &block\n if @state != :state_inited\n return\n end\n @state = :state_started\n begin\n @server = WebSocket::EventMachine::Server.start(:host => '0.0.0.0', :port => port.to_s) { |ws|\n ws_context = {\n # 'monitor' or 'client'\n :type => nil,\n # for monitor connection\n :server_id => nil, :server_type => nil, :server_info => nil,\n # for client connection\n :client_id => nil,\n # for both connection\n :username => nil, :registered => false\n }\n ws.onopen {\n @wss[ws.signature] = ws\n peer_port, peer_host = Socket.unpack_sockaddr_in ws.get_peername\n emit 'connection', { :id => ws.signature, :ip => peer_host }\n }\n ws.onmessage { |msg, type|\n begin\n event, msg = parse msg\n case event\n when 'register'\n process_register_msg ws, ws_context, msg\n when 'monitor'\n process_msg_from_monitor ws, ws_context, msg\n when 'client'\n process_msg_from_client ws, ws_context, msg\n else\n end\n rescue => err\n end\n }\n ws.onclose {\n @wss.delete ws.signature\n if ws_context[:registered]\n case ws_context[:type]\n when 'monitor'\n remove_monitor_connection(ws_context[:server_id],\n ws_context[:server_type], ws_context[:server_info])\n when 'client'\n remove_client_connection ws_context[:client_id]\n else\n end\n emit 'disconnect', ws_context\n end\n }\n ws.onerror { |err|\n emit 'err', err\n }\n }\n block_given? && yield\n rescue => err\n emit 'error', err\n end\n on('connection') { |obj| ip_filter obj }\n end",
"def ws_server(opts = {})\n EM::WebSocket.run({ host: WS_HOST, port: WS_PORT }.merge(opts)) { |ws|\n yield ws if block_given?\n }\nend",
"def connect\n EM.epoll\n\n EM.run do\n trap('TERM') do\n @enable_reconnection = false\n disconnect\n end\n\n trap('INT') do\n @enable_reconnection = false\n disconnect\n end\n\n @ws = WebSocket::EventMachine::Client.connect(uri: @url)\n\n @ws.onopen do\n reset_value\n @ws.send(get_handshake_object(increment_cnt).to_json)\n @on_connected.call if @on_connected\n end\n\n @ws.onmessage do |message, _type|\n @logger.info(\"Message received : #{message}\") if @logger\n if message == ''\n @logger.info(\"Ping received, sending PONG back\")\n @ws.send('')\n else\n main_object = JSON.parse(message)\n data_object = main_object['data']\n rid = main_object['rid']\n cid = main_object['cid']\n event = main_object['event']\n result = Parser.parse(event, rid)\n if result == Parser::CHECK_AUTHENTICATION\n if @on_authentication\n @id = data_object['id']\n @on_authentication.call(self, data_object['isAuthenticated'])\n end\n subscribe_channels\n elsif result == Parser::PUBLISH\n execute(data_object['channel'], data_object['data'])\n elsif result == Parser::REMOVE_AUTHENTICATION\n @auth_token = nil\n elsif result == Parser::SET_AUTHENTICATION\n if @on_set_authentication\n @on_set_authentication.call(self, data_object['token'])\n end\n elsif result == Parser::EVENT\n if haseventack(event)\n executeack(event, data_object, ack_block(cid))\n else\n execute(event, data_object)\n end\n else # Parser::ACKNOWLEDGEMENT\n tuple = @acks[rid] if @acks.include?(rid)\n if tuple\n ack = tuple[1]\n ack.call(tuple[0], String(main_object['error']), String(main_object['data']))\n end\n end\n end\n end\n\n @ws.onerror do |error|\n @on_connect_error.call(error) if @on_connect_error\n end\n\n @ws.onclose do\n if should_reconnect\n @reconnect_interval = @max_reconnect_interval if @reconnect_interval > @max_reconnect_interval\n sleep(@reconnect_interval / 1000)\n @attempts_made += 1\n @logger.info(\"Attempting to reconnect : #{@attempts_made}\") if @logger\n connect\n else\n stop\n end\n end\n\n def stop\n EventMachine.stop\n end\n end\n end",
"def start\n loop do\n begin\n socket = tcp_server.accept\n\n handle_request(socket)\n ensure\n socket.close\n end\n end\n end",
"def on_open(env)\n req = ::Rack::Request.new(env)\n @cid = req.params['cid']\n @path = req.path\n @subscription = Firehose::Subscription.new(cid, path)\n\n subscription.subscribe do |message, subscription|\n Firehose.logger.debug \"WS sent `#{message}` to `#{cid}@#{path}`\"\n send_data message\n end\n Firehose.logger.debug \"WS subscribed to `#{cid}@#{path}`\"\n end",
"def start\n # Don't send asynchronously\n if Deimos.config.producers.backend == :kafka_async\n Deimos.config.producers.backend = :kafka\n end\n Deimos.config.logger.info('Starting...')\n @signal_to_stop = false\n ActiveRecord::Base.connection.reconnect! unless ActiveRecord::Base.connection.open_transactions.positive?\n\n retrieve_poll_info\n loop do\n if @signal_to_stop\n Deimos.config.logger.info('Shutting down')\n break\n end\n process_updates if should_run?\n sleep(0.1)\n end\n end",
"def receive(websocket_message); end",
"def subscribe\n conn = @cluster.connect\n conn.subscribe(ALL)\n conn.subscribe(SHARE)\n conn.subscribe(@channel)\n conn.on(:message) do |channel, message|\n @messages.push([channel, message])\n end\n end",
"def run\n loop{\n @client = @server.accept\n @serverPool.schedule(@client)\n }\n end",
"def run\n loop{\n @client = @server.accept\n @serverPool.schedule(@client)\n }\n end",
"def run\n connect\n end",
"def on_open(env)\n @subscription = @config.consumer(env).subscription(@config.channel(env))\n @subscription.on_message {|message, consumer| send_data message }\n @subscription.subscribe\n end",
"def start(host=\"localhost\", port=2230)\n output_stream.puts \"waiting till an opponent connect...\"\n EventMachine::run {\n EventMachine::start_server host, port, GameBroker, &method(:setup_handler) \n }\n end",
"def start\n\t\tself.log.debug \"Starting.\"\n\t\tself.spawn_server\n\t\tself.read_hello\n\tend",
"def new_websocket_client(client)\n\n msg \"connecting to: %s:%s\" % [@target_host, @target_port]\n tsock = TCPSocket.open(@target_host, @target_port)\n\n if @verbose then puts @@Traffic_legend end\n\n begin\n do_proxy(client, tsock)\n rescue\n tsock.shutdown(Socket::SHUT_RDWR)\n tsock.close\n raise\n end\n end",
"def begin!\n start_server\n end",
"def listen(debug=false)\n connect unless connected?\n\n @listen_thread = Thread.new {\n @client.add_message_callback do |message|\n next if message.body.nil?\n next unless allowed_roster_includes?(message.from)\n\n Thread.new do\n begin\n dispatch(message)\n rescue => e\n log e\n raise if debug\n end\n end\n end\n @roster ||= Jabber::Roster::Helper.new(@client)\n @roster.add_subscription_request_callback do |item,presence|\n next unless allowed_roster_includes?(presence.from)\n @roster.accept_subscription(presence.from) \n end\n sleep\n }\n end",
"def start\n connect\n @last_alive = Time.now\n @listener = Thread.new do\n while true\n begin\n @last_alive = Time.now if @hub.fetch_command\n\n if Time.now > @last_alive + @keepalive_timeout\n @logger.error \"connection lost\" if @logger\n @last_alive = Time.now\n reconnect\n end\n\n rescue Exception => e\n exit if e.class == Interrupt\n puts e.message\n puts e.backtrace.join(\"\\n\")\n break\n end\n end\n end\n end",
"def initialize\n @name = NAMES.sample\n HomeController.broadcast :print, \"#{@name} joind the chat.\"\n Iodine.run_after(pause) { post_message }\n # options = {}\n # options[:on_open] = Proc.new { Iodine.run_after(pause) { write MESSAGES.sample; rand(1..7).even? ? (Iodine.run_after(pause) { close }) : Iodine.run_after(pause) {on_open} } }\n # options[:on_message] = Proc.new {|data| }\n # options[:url] = \"ws://localhost:#{Iodine.port}/#{name}\"\n # Iodine::Http.ws_connect options\n end",
"def start\n Socket.accept_loop(@tcpserver) do |connection|\n SLogger.debug(\"[server] accepted a new connection (#{connection})\")\n\n self.session.connection = connection\n self.handle_connection(connection)\n end\n rescue IOError\n Thread.exit\n end",
"def listen\n Thread.new do\n while true\n retrieve_messages\n sleep (0.1)\n end\n end\n end",
"def subscribe_to_channel; end",
"def initialize()\n @consumer_channel = EM::Channel.new\n start()\n end"
] | [
"0.759693",
"0.75889146",
"0.75040096",
"0.74673706",
"0.73379916",
"0.7302696",
"0.7091175",
"0.7071319",
"0.70664835",
"0.69037634",
"0.68445",
"0.6770489",
"0.666549",
"0.6642469",
"0.6607377",
"0.6575878",
"0.6575878",
"0.6519944",
"0.6505101",
"0.6488238",
"0.64726967",
"0.64234686",
"0.63707215",
"0.6365445",
"0.6359337",
"0.6354242",
"0.6352051",
"0.6331725",
"0.6325953",
"0.6325064",
"0.63231164",
"0.6315297",
"0.6301068",
"0.62966466",
"0.62954485",
"0.62809664",
"0.6278158",
"0.624847",
"0.6204767",
"0.6203404",
"0.61835325",
"0.6182329",
"0.617479",
"0.6150606",
"0.61425173",
"0.6139008",
"0.6129639",
"0.61250746",
"0.6117487",
"0.6099483",
"0.60641104",
"0.6060315",
"0.6037257",
"0.60077983",
"0.6003594",
"0.599345",
"0.5980631",
"0.5968579",
"0.59563726",
"0.59543055",
"0.5952462",
"0.59482026",
"0.5947929",
"0.5937736",
"0.5930844",
"0.593067",
"0.5924771",
"0.5917899",
"0.5917613",
"0.5917178",
"0.5901781",
"0.5894889",
"0.5894829",
"0.5891802",
"0.5888278",
"0.58872366",
"0.58847713",
"0.5858558",
"0.5856867",
"0.5855158",
"0.58546567",
"0.58338004",
"0.5816488",
"0.5815029",
"0.5813106",
"0.57940966",
"0.57940966",
"0.5794072",
"0.57827806",
"0.5781991",
"0.5779947",
"0.57770216",
"0.5774193",
"0.5773901",
"0.5772739",
"0.5767531",
"0.5766562",
"0.57599044",
"0.5753449",
"0.5753105"
] | 0.8328781 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_workout
@workout = Workout.friendly.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def setup_handler\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def workflow\n end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup\n # override and do something appropriate\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def after_set_callback; end",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def save_action; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def setup(&blk)\n @setup_block = blk\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def duas1(action)\n action.call\n action.call\nend",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend"
] | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576",
"0.53124547",
"0.529654",
"0.5296262",
"0.52952296",
"0.52600986",
"0.52442724",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.5232394",
"0.523231",
"0.5227454",
"0.52226824",
"0.52201617",
"0.5212327",
"0.52079266",
"0.52050185",
"0.51754695",
"0.51726824",
"0.51710224",
"0.5166172",
"0.5159343",
"0.51578903",
"0.51522785",
"0.5152022",
"0.51518047",
"0.51456624",
"0.51398855",
"0.5133759",
"0.5112076",
"0.5111866",
"0.5111866",
"0.5110294",
"0.5106169",
"0.509231",
"0.50873137",
"0.5081088",
"0.508059",
"0.50677156",
"0.50562143",
"0.5050554",
"0.50474834",
"0.50474834",
"0.5036181",
"0.5026331",
"0.5022976",
"0.5015441",
"0.50121695",
"0.5000944",
"0.5000019",
"0.4996878",
"0.4989888",
"0.4989888",
"0.49864885",
"0.49797225",
"0.49785787",
"0.4976161",
"0.49683493",
"0.4965126",
"0.4958034",
"0.49559742",
"0.4954353",
"0.49535993",
"0.4952725",
"0.49467874",
"0.49423352",
"0.49325448",
"0.49282882",
"0.49269363",
"0.49269104",
"0.49252945",
"0.4923091",
"0.49194667",
"0.49174926",
"0.49173003",
"0.49171105",
"0.4915879",
"0.49155936"
] | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def workout_params
params.require( :workout ).permit( :workout_type, :title, :description )
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def param_whitelist\n [:role, :title]\n end",
"def expected_permitted_parameter_names; end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def valid_params_request?; end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def permitted_params\n []\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params; true; end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def quote_params\n params.permit!\n end",
"def valid_params?; end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend",
"def filtered_parameters; end",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def filtering_params\n params.permit(:email, :name)\n end",
"def check_params\n true\n end",
"def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def active_code_params\n params[:active_code].permit\n end",
"def filtering_params\n params.permit(:email)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end",
"def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end",
"def list_params\n params.permit(:name)\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def url_whitelist; end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def admin_social_network_params\n params.require(:social_network).permit!\n end",
"def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def filter_params\n params.require(:filters).permit(:letters)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def permit_request_params\n params.permit(:address)\n end",
"def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end",
"def secure_params\n params.require(:location).permit(:name)\n end",
"def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end",
"def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end",
"def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end",
"def url_params\n params[:url].permit(:full)\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def backend_user_params\n params.permit!\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end",
"def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end",
"def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end",
"def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end",
"def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end"
] | [
"0.6979893",
"0.6781746",
"0.6746611",
"0.6742344",
"0.6735229",
"0.6592651",
"0.65027124",
"0.6498011",
"0.648163",
"0.647716",
"0.64556813",
"0.64386255",
"0.63784456",
"0.63756156",
"0.636574",
"0.6319542",
"0.63004524",
"0.6299559",
"0.62925464",
"0.62923217",
"0.6289894",
"0.6289475",
"0.62831545",
"0.6242381",
"0.6240358",
"0.6217451",
"0.6214354",
"0.62098235",
"0.61918235",
"0.6177287",
"0.61755854",
"0.61712915",
"0.61620486",
"0.6151379",
"0.61510575",
"0.6145169",
"0.61207956",
"0.6115647",
"0.6107701",
"0.61030304",
"0.60909295",
"0.60797",
"0.60701567",
"0.6062068",
"0.60203075",
"0.60167485",
"0.60125494",
"0.6009718",
"0.6007027",
"0.6007027",
"0.6000283",
"0.59990394",
"0.5996995",
"0.59915864",
"0.59914654",
"0.59912056",
"0.5979621",
"0.596686",
"0.5959418",
"0.59585625",
"0.59583765",
"0.5958032",
"0.5952298",
"0.5951678",
"0.5941885",
"0.59378815",
"0.59376645",
"0.59376645",
"0.5933908",
"0.59302104",
"0.5924862",
"0.5923981",
"0.59165645",
"0.5909916",
"0.590986",
"0.5908378",
"0.5904956",
"0.5897421",
"0.58970135",
"0.5894611",
"0.5893914",
"0.58927566",
"0.5891277",
"0.5885355",
"0.58825094",
"0.58783555",
"0.58728755",
"0.58686864",
"0.5867015",
"0.58660764",
"0.58659357",
"0.5864526",
"0.58634263",
"0.5861585",
"0.5861255",
"0.5858771",
"0.58579147",
"0.5854071",
"0.5853147",
"0.58498794",
"0.58492327"
] | 0.0 | -1 |
GET /retroalimentacions/1 GET /retroalimentacions/1.json | def show
@retroalimentacion = Retroalimentacion.find(params[:id])
@current_cliente=obtener_cliente(current_user)
respond_to do |format|
format.html # show.html.erb
format.json { render json: @retroalimentacion }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @retro = Retro.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @retro }\n end\n end",
"def show\n @retroaspecto = Retroaspecto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @retroaspecto }\n end\n end",
"def show\n @remito = Remito.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @remito }\n end\n end",
"def index\n @ramais = Ramal.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ramais }\n end\n end",
"def show\n @ramal = Ramal.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ramal }\n end\n end",
"def index\n @relaciones_articulos_medida = RelacionArticuloMedida.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @relaciones_articulos_medida }\n end\n end",
"def index\n @repas = Repa.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @repas }\n end\n end",
"def show\n @relogio = Relogio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @relogio }\n end\n end",
"def new\n @retroalimentacion = Retroalimentacion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @retroalimentacion }\n end\n end",
"def show\n @remedio = Remedio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @remedio }\n end\n end",
"def show\n @imp2_raman = Imp2Raman.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @imp2_raman }\n end\n end",
"def show\n @agronomiaquimica = Agronomiaquimica.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @agronomiaquimica }\n end\n end",
"def show\n @immigrant = Immigrant.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @immigrant }\n end\n end",
"def show\n @respuesta = Respuesta.find(params[:id])\n\n render json: @respuesta\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @representante_athlete }\n end\n end",
"def show\n @repa = Repa.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @repa }\n end\n end",
"def show\n @repa = Repa.find(params[:id])\n \n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @repa }\n end\n end",
"def show\n @reparacion = Reparacion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @reparacion }\n end\n end",
"def index\n @microroles = Microrole.includes(:verb_coding_frame_microroles).readonly(false).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @microroles }\n end\n end",
"def show\n @anuncio = Anuncio.find(params[:id])\n\n respond_to do |format|\n format.html\n format.json { render json: @anuncio }\n end\n end",
"def getOrden \n \t@orden = Orden.where(:rest => params[:id_res])\n \trender json: @orden\n end",
"def show\n @imp_raman = ImpRaman.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @imp_raman }\n end\n end",
"def show\n @respuesta = Respuesta.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @respuesta }\n end\n end",
"def show\n @rua = Rua.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @rua }\n end\n end",
"def show\n @parlamentarian = Parlamentarian.find_by_id(params[:rdf_uri])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @parlamentarian }\n end\n end",
"def show\n @reltramovano = Reltramovano.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @reltramovano }\n end\n end",
"def show\n @mision = Mision.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mision }\n end\n end",
"def index\n @recibo = Recibo.find(params[:recibo_id])\n @renglon_recdetalles = @recibo.renglon_recdetalles.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @renglon_recdetalles }\n end\n end",
"def show\n @situacion_revistum = SituacionRevistum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @situacion_revistum }\n end\n end",
"def show\n @mision_mision = MisionMision.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mision_mision }\n end\n end",
"def index\n @ruas = Rua.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ruas }\n end\n end",
"def show\n\n @recibo = Recibo.find(params[:recibo_id])\n @renglon_recdetalle = @recibo.renglon_recdetalles.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @renglon_recdetalle }\n end\n end",
"def show\n @reconocimiento = Reconocimiento.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @reconocimiento }\n end\n end",
"def index\n @retentions = Retention.all\n end",
"def index\n @frais_repas = FraisRepa.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @frais_repas }\n end\n end",
"def show\n @autore = Autore.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @autore }\n end\n end",
"def random_roberto_speech\n skip_authorization\n respond_to do |format|\n format.json do\n render json: { roberto_speech: \"#{RobertoBarros.in_ingrish} #{direction_for_active_cell(@play)}\" }\n end\n end\n end",
"def show\n @microfilm_reel = MicrofilmReel.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @microfilm_reel }\n end\n end",
"def show\n @renter = Renter.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @renter }\n end\n end",
"def index\n @castes = Caste.includes(:religion).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @castes }\n end\n end",
"def index\n @anuncios = Anuncio.all\n render json: @anuncios, status: :ok\n end",
"def show\n @frais_repa = FraisRepa.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @frais_repa }\n end\n end",
"def show\n @historial = Historial.find(params[:id])\n @receta = Recete.histori(@historial.id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @historial }\n end\n end",
"def show\n @relacion_articulo_medida = RelacionArticuloMedida.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @relacion_articulo_medida }\n end\n end",
"def index\n @notadedebito = Notadedebito.find(params[:notadecredito_id])\n @renglon_notadebitos = @notadedebito.renglon_notadebitos\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @renglon_notadebitos }\n end\n end",
"def index\n @representante_athletes = current_user.organization.athletes\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @representante_athletes }\n end\n end",
"def index\n @current_page = 'recettes'\n @recettes = Recette.includes(:photo_files).all.order('id desc').limit(15)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @recettes }\n end\n end",
"def show\n @aroma = Aroma.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @aroma }\n end\n end",
"def show\n @affectation = Affectation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @affectation }\n end\n end",
"def show\n my_rsa = RsaFull.find_by id: params[:id]\n respond_to do |format|\n format.json {render json: {'n' => my_rsa.n, 'e' => my_rsa.e, 'd' => my_rsa.d}}\n end\n end",
"def show\n @reprogramacion = Reprogramacion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @reprogramacion }\n end\n end",
"def show\r\n @imobiliaria = Imobiliaria.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.json { render json: @imobiliaria }\r\n end\r\n end",
"def index\n @factura = Factura.find(params[:factura_id])\n @renglon_facturas = @factura.renglon_facturas\n\n respond_to do |format|\n format.html # index.html.erb\n #format.json { render json: @renglon_facturas }\n end\n end",
"def show\n @matricula = Matricula.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @matricula }\n end\n end",
"def show\n render json: Alien.find(params[\"id\"])\n end",
"def show\n @receipe = Receipe.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @receipe }\n end\n end",
"def show\n @uchronia = Uchronia.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @uchronia }\n end\n end",
"def index\n @pictures = Picture.where(foodscape_id: params[:foodscape_id])\n render json: @pictures\n end",
"def show\n @lugar = Lugar.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lugar }\n end\n end",
"def show\n @roadcrime = Roadcrime.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @roadcrime }\n end\n end",
"def index_by_user\n @gifts = @current_user.gifts\n render json: @gifts, include: :ages, status: :ok\n end",
"def show\n @arrest = Arrest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @arrest }\n end\n end",
"def show\n @rayon = Rayon.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @rayon }\n end\n end",
"def index\n @reprogramaciones = Reprogramacion.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reprogramaciones }\n end\n end",
"def show\n @lore = Lore.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lore }\n end\n end",
"def show\n @creator_accession_relationship = CreatorAccessionRelationship.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @creator_accession_relationship }\n end\n end",
"def show\n @recoleccion = Recoleccion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recoleccion }\n end\n end",
"def index\n @objectives = current_user.objectives.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @objectives }\n end\n end",
"def index\n #@arquivos = Arquivo.all\n\n residencial = current_user.apartamento.residencial\n @arquivos = Arquivo\n .where(:residencial_id => residencial.id)\n .order(\"created_at\")\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @arquivos }\n end\n end",
"def index\n @preservatives = Preservative.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @preservatives }\n end\n end",
"def show\n @rebate = Rebate.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @rebate }\n end\n end",
"def show\n @repuesto = Repuesto.find(params[:id])\n respond_to do |format|\n format.html { render :show }\n format.json { render json: @repuesto.to_json }\n end\n end",
"def show\n @repuestum = Repuestum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @repuestum }\n end\n end",
"def show\n @pessoa_receber = PessoaReceber.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @pessoa_receber }\n end\n end",
"def show\n @personaje_mision = PersonajeMision.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @personaje_mision }\n end\n end",
"def index\n logement = Logement.find_by(id:params[:logement_id])\n equipement = logement.equi_securites[0].title\n equipements = logement.equi_securites[0]\n\n render json: {\n securites:equipement,\n fichier:equipements\n }\n end",
"def show\n @ref_protein = RefProtein.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ref_protein }\n end\n end",
"def show\n @receita_medica = ReceitaMedica.find(params[:id])\n @item_receitas = @receita_medica.item_receitas.all\n respond_to do |format|\n format.html # show.html.erb \n format.json { render json: {\n :receita => @receita_medica, \n :medicamentos => @receita_medica.item_receitas.collect {|t| [t.medicamento.nome, t.posologia, t.quantidade]} } }\n end\n end",
"def show\n @mouvement_recurrent = MouvementRecurrent.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mouvement_recurrent }\n end\n end",
"def show\n @warrior = Warrior.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @warrior }\n end\n end",
"def show\n @warrior = Warrior.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @warrior }\n end\n end",
"def show\n @uniprot = Uniprot.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @uniprot }\n end\n end",
"def show\n @arcone = Arcone.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @arcone }\n end\n end",
"def index\n @familia = Familium.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @familia }\n end\n end",
"def new\n @retro = Retro.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @retro }\n end\n end",
"def show\n @reel = Reel.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @reel }\n end\n end",
"def display\n @json = Rma.search(params[:rmaName])\n # render :text => @json.inspect\n end",
"def index\n @patrocinios = Patrocinio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @patrocinios }\n end\n end",
"def index\n @reward_and_levels = RewardAndLevel.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reward_and_levels }\n end\n end",
"def show\n unless possui_acesso?()\n return\n end\n @matricula = Matricula.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @matricula }\n end\n end",
"def show\n @litra = Litra.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @litra }\n end\n end",
"def show\n @moresmallarmorinfo = Moresmallarmorinfo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @moresmallarmorinfo }\n end\n end",
"def index\n @goal_rewards = user.goal_rewards\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @goal_rewards }\n end\n end",
"def index\n @objectives = @goal.objectives.all \n render json: @objectives \n end",
"def index\n # @prenotations = Prenotation.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @prenotations }\n end\n end",
"def show\n @lifestyle_subgenre = LifestyleSubgenre.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lifestyle_subgenre }\n end\n end",
"def show\n @leito = Leito.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @leito }\n end\n end",
"def show\n # proxy to GET /roi/id\n @result = ImageServer.get('/roi/'+params[:id]);\n render :json => @result\n end",
"def show\n @galaxies_lenticular_galaxy = Galaxies::LenticularGalaxy.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @galaxies_lenticular_galaxy }\n end\n end",
"def index\n @unidade_medidas = UnidadeMedida.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @unidade_medidas }\n end\n end"
] | [
"0.6561835",
"0.6257182",
"0.62030643",
"0.6189955",
"0.6154772",
"0.61511123",
"0.6117199",
"0.6066296",
"0.6059853",
"0.60521847",
"0.60429156",
"0.6040363",
"0.60234064",
"0.6011314",
"0.59818923",
"0.5978766",
"0.59613097",
"0.5953499",
"0.59325844",
"0.59307265",
"0.5876015",
"0.5874899",
"0.586913",
"0.58612794",
"0.5855496",
"0.58293116",
"0.58286095",
"0.5819946",
"0.5801873",
"0.57886875",
"0.5783646",
"0.5777267",
"0.57715136",
"0.57697755",
"0.57412106",
"0.5735648",
"0.5730632",
"0.5721054",
"0.57116175",
"0.57100904",
"0.5704209",
"0.57039094",
"0.56995994",
"0.5698664",
"0.5697215",
"0.5695623",
"0.5694647",
"0.5693338",
"0.5693109",
"0.5686201",
"0.5684163",
"0.5680896",
"0.5679069",
"0.5675845",
"0.56688917",
"0.5667966",
"0.5667702",
"0.5665472",
"0.5664831",
"0.56579894",
"0.56514025",
"0.5650611",
"0.56452465",
"0.56402564",
"0.56392795",
"0.5631774",
"0.56315875",
"0.5628871",
"0.5625019",
"0.5623464",
"0.5622255",
"0.56214714",
"0.56062394",
"0.5604021",
"0.56038857",
"0.56027114",
"0.55957884",
"0.5595071",
"0.55947596",
"0.55884916",
"0.55884916",
"0.55856705",
"0.5582853",
"0.55821335",
"0.55791825",
"0.5578055",
"0.5576959",
"0.55767",
"0.55725",
"0.5566158",
"0.556519",
"0.556515",
"0.55633426",
"0.55617994",
"0.5561423",
"0.55612683",
"0.55607593",
"0.5560459",
"0.5559156",
"0.55561966"
] | 0.60582006 | 9 |
GET /retroalimentacions/new GET /retroalimentacions/new.json | def new
@retroalimentacion = Retroalimentacion.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @retroalimentacion }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @retro = Retro.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @retro }\n end\n end",
"def new\n @immigrant = Immigrant.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @immigrant }\n end\n end",
"def new\n @repa = Repa.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @repa }\n end\n end",
"def new\n @modifier = Modifier.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @modifier }\n end\n end",
"def create\n @retroalimentacion = Retroalimentacion.new(params[:retro])\n\n respond_to do |format|\n if @retroalimentacion.save\n format.html { redirect_to @retroalimentacion, notice: 'Retroalimentacion was successfully created.' }\n format.json { render json: @retroalimentacion, status: :created, location: @retroalimentacion }\n else\n format.html { render action: \"new\" }\n format.json { render json: @retroalimentacion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @mision = Mision.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mision }\n end\n end",
"def new\n @agronomiaquimica = Agronomiaquimica.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @agronomiaquimica }\n end\n end",
"def new\n @caracteristica_imovel = CaracteristicaImovel.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @caracteristica_imovel }\n end\n end",
"def new\n @retroaspecto = Retroaspecto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @retroaspecto }\n end\n end",
"def new\n @lugar = Lugar.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lugar }\n end\n end",
"def new\n @lore = Lore.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lore }\n end\n end",
"def new\n @remito = Remito.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @remito }\n end\n end",
"def new\n @pony = Pony.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pony }\n end\n end",
"def new\n @opinion = Opinion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @opinion }\n end\n end",
"def new\n @opinion = Opinion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @opinion }\n end\n end",
"def new\n @generation = Generation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @generation }\n end\n end",
"def new\n @precinct = Precinct.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @precinct }\n end\n end",
"def new\n @attri = Attri.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @attri }\n end\n end",
"def new\n @respuesta = Respuesta.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @respuesta }\n end\n end",
"def new\n @ramal = Ramal.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ramal }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @alley }\n end\n end",
"def new\n @reltramovano = Reltramovano.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @reltramovano }\n end\n end",
"def new\n @situacion_revistum = SituacionRevistum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @situacion_revistum }\n end\n end",
"def new\n @natulang = Natulang.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @natulang }\n end\n end",
"def new\n @manga = Manga.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @manga }\n end\n end",
"def new\n @protein = Protein.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @protein }\n end\n end",
"def new\n @requerimiento = Requerimiento.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @requerimiento }\n end\n end",
"def new\n @torneo = Torneo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @torneo }\n end\n end",
"def new\n @ram = Ram.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ram }\n end\n end",
"def new\n @reparacion = Reparacion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @reparacion }\n end\n end",
"def new\n @uniprot = Uniprot.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @uniprot }\n end\n end",
"def new\n @recurso = Recurso.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @recurso }\n end\n end",
"def new\n @reconocimiento = Reconocimiento.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @reconocimiento }\n end\n end",
"def new\n @tipo_negocio = TipoNegocio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tipo_negocio }\n end\n end",
"def new\n @creator_accession_relationship = CreatorAccessionRelationship.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @creator_accession_relationship }\n end\n end",
"def new\n @prioridade = Prioridade.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @prioridade }\n end\n end",
"def new\n @laundromat = Laundromat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @laundromat }\n end\n end",
"def new\n @atr = Atr.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @atr }\n end\n end",
"def new\n @manifestation = Manifestation.new\n original_manifestation = Manifestation.where(:id => params[:manifestation_id]).first\n if original_manifestation\n @manifestation = original_manifestation.dup\n @creator = original_manifestation.creators.collect(&:full_name).flatten.join(';')\n @contributor = original_manifestation.contributors.collect(&:full_name).flatten.join(';')\n @publisher = original_manifestation.publishers.collect(&:full_name).flatten.join(';')\n @subject = original_manifestation.subjects.collect(&:term).join(';')\n @manifestation.isbn = nil\n @manifestation.series_statement = original_manifestation.series_statement unless @manifestation.series_statement\n elsif @expression\n @manifestation.original_title = @expression.original_title\n @manifestation.title_transcription = @expression.title_transcription\n elsif @series_statement\n @manifestation.series_statement = @series_statement\n end\n @manifestation.language = Language.where(:iso_639_1 => @locale).first\n @manifestation = @manifestation.set_serial_number if params[:mode] == 'new_issue'\n @original_manifestation = original_manifestation if params[:mode] == 'add'\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @manifestation }\n end\n end",
"def new\n @genotype = Genotype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @genotype }\n end\n end",
"def new\n @repuestum = Repuestum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @repuestum }\n end\n end",
"def new\n @requesttomentor = Requesttomentor.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @requesttomentor }\n end\n end",
"def new\n @intention = Intention.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @intention }\n end\n end",
"def new\n unless possui_acesso?()\n return\n end\n @matricula = Matricula.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @matricula }\n end\n end",
"def new\n @nail_salon = NailSalon.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @nail_salon }\n end\n end",
"def new\n @actore = Actore.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @actore }\n end\n end",
"def new\n @relogio = Relogio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @relogio }\n end\n end",
"def new\r\n @antenne = Antenne.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @antenne }\r\n end\r\n end",
"def new\n @asociado = Asociado.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @asociado }\n end\n end",
"def new\n @mision_mision = MisionMision.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mision_mision }\n end\n end",
"def new\n @phile = Phile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @phile }\n end\n end",
"def new\n @title = t('admin.promotions.new.title')\n @promotion = Promotion.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @promotion }\n end\n end",
"def new\n @ridol = Ridol.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ridol }\n end\n end",
"def new\n @fiction = Fiction.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @fiction }\n end\n end",
"def new\n @papel = Papel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @papel }\n end\n end",
"def new\n DebugLog(params.inspect)\n @lancamentorapido = Lancamentorapido.new\n \n @categorias = Category.all\n @centrosdecusto = Centrodecusto.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lancamentorapido }\n end\n end",
"def new\n @glossary = Glossary.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @glossary }\n end\n end",
"def new\n @relation = Relation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @relation }\n end\n end",
"def new\n r = Ring.instance\n @creature = Creature.new(latitude: r.latitude, longitude: r.longitude)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @creature }\n end\n end",
"def new\n @mouvement_recurrent = MouvementRecurrent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mouvement_recurrent }\n end\n end",
"def new\n @affectation = Affectation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @affectation }\n end\n end",
"def new\n @arbitro = Arbitro.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @arbitro }\n end\n end",
"def new\n @livro = Livro.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @livro }\n end\n end",
"def new\n @taxon = Taxon.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @taxon }\n end\n end",
"def new\n @taxon = Taxon.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @taxon }\n end\n end",
"def new\n @remedio = Remedio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @remedio }\n end\n end",
"def new\n @presenza = Presenza.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @presenza }\n end\n end",
"def new\n @registro_record = RegistroRecord.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @registro_record }\n end\n end",
"def new\n @transaccion = Transaccion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @transaccion }\n end\n end",
"def new\n @noto = Noto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @noto }\n end\n end",
"def new\n @mispronunciation = Mispronunciation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @mispronunciation }\n end\n end",
"def new\n @colegiatura = Colegiatura.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @colegiatura }\n end\n end",
"def new\n @situation = Situation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @situation }\n end\n end",
"def new\n @ref_protein = RefProtein.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ref_protein }\n end\n end",
"def new\n @lector = Lector.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lector }\n end\n end",
"def new\n @situacao_avaliacao = SituacaoAvaliacao.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @situacao_avaliacao }\n end\n end",
"def new\n @indicativo = Indicativo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @indicativo }\n end\n end",
"def new\n @exalt = Exalt.new(:type => \"Solar\")\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @exalt }\n end\n end",
"def new\n @irregular_verb = IrregularVerb.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @irregular_verb }\n end\n end",
"def new\n @patent = Patent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @patent }\n end\n end",
"def new\n @sezione = Sezione.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sezione }\n end\n end",
"def new\n @representante_athlete = Representante::Athlete.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @representante_athlete }\n end\n end",
"def new\n @trnodo = Trnodo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trnodo }\n end\n end",
"def new\n @orgao = Orgao.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @orgao }\n end\n end",
"def new\n @promotion = Promotion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @promotion }\n end\n end",
"def new\n @promotion = Promotion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @promotion }\n end\n end",
"def new\n @preservative = Preservative.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @preservative }\n end\n end",
"def new\n @lease = Lease.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @lease }\n end\n end",
"def new\n @recinto = Recinto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @recinto }\n end\n end",
"def new\n @nlp = Nlp.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @nlp }\n end\n end",
"def new\n @asignatura = Asignatura.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @asignatura }\n end\n end",
"def new\n @pun = Pun.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pun }\n end\n end",
"def new\n @situation = Situation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @situation }\n end\n end",
"def new\n @puntaje = Puntaje.new\n atributos\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @puntaje }\n end\n end",
"def new\n @puntaje = Puntaje.new\n atributos\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @puntaje }\n end\n end",
"def new\n @trenton = Trenton.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trenton }\n end\n end",
"def new\n @distro = Distro.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @distro }\n end\n end",
"def new\n @distro = Distro.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @distro }\n end\n end",
"def new\n @annex = Annex.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @annex }\n end\n end",
"def new\n unless possui_acesso?()\n return\n end\n @aviso = Aviso.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @aviso }\n end\n end"
] | [
"0.7193069",
"0.71232325",
"0.7022495",
"0.70102686",
"0.6950694",
"0.6928896",
"0.6925936",
"0.6922406",
"0.6912741",
"0.688948",
"0.6888855",
"0.68855584",
"0.6883194",
"0.68728447",
"0.68728447",
"0.6867019",
"0.68633723",
"0.68572843",
"0.6842431",
"0.6840091",
"0.683457",
"0.6831365",
"0.68309236",
"0.68255347",
"0.68180424",
"0.68170404",
"0.68158674",
"0.68147254",
"0.6807726",
"0.6806626",
"0.6801231",
"0.6799952",
"0.67889863",
"0.6778972",
"0.6777629",
"0.6774581",
"0.67730314",
"0.6772158",
"0.6770515",
"0.6759869",
"0.67504394",
"0.67495286",
"0.67481214",
"0.67466056",
"0.67464846",
"0.67434716",
"0.6736717",
"0.67361575",
"0.6732131",
"0.6731965",
"0.67299634",
"0.67270446",
"0.67260444",
"0.67238694",
"0.6721657",
"0.6719802",
"0.6717009",
"0.6704923",
"0.6699767",
"0.6698177",
"0.6697462",
"0.66955614",
"0.669451",
"0.6691216",
"0.6691216",
"0.6689902",
"0.6687636",
"0.66875386",
"0.6687506",
"0.6682529",
"0.6680643",
"0.66804487",
"0.6679478",
"0.6675858",
"0.6675235",
"0.6672558",
"0.6672024",
"0.6670898",
"0.66690063",
"0.6667498",
"0.6664877",
"0.66638196",
"0.66634846",
"0.666346",
"0.66602147",
"0.66602147",
"0.665735",
"0.66567945",
"0.66515666",
"0.66509885",
"0.6650717",
"0.6650587",
"0.6649955",
"0.66451275",
"0.66451275",
"0.66450197",
"0.66444093",
"0.66444093",
"0.6639633",
"0.66388273"
] | 0.7555004 | 0 |
POST /retroalimentacions POST /retroalimentacions.json | def create
@retroalimentacion = Retroalimentacion.new(params[:retro])
respond_to do |format|
if @retroalimentacion.save
format.html { redirect_to @retroalimentacion, notice: 'Retroalimentacion was successfully created.' }
format.json { render json: @retroalimentacion, status: :created, location: @retroalimentacion }
else
format.html { render action: "new" }
format.json { render json: @retroalimentacion.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @retroalimentacion = Retroalimentacion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @retroalimentacion }\n end\n end",
"def create\n @retro = Retro.new(params[:retro])\n\n respond_to do |format|\n if @retro.save\n format.html { redirect_to @retro, notice: 'Retro was successfully created.' }\n format.json { render json: @retro, status: :created, location: @retro }\n else\n format.html { render action: \"new\" }\n format.json { render json: @retro.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @retroaspecto = Retroaspecto.new(params[:retroaspecto])\n\n respond_to do |format|\n if @retroaspecto.save\n format.html { redirect_to @retroaspecto, notice: 'Retroaspecto was successfully created.' }\n format.json { render json: @retroaspecto, status: :created, location: @retroaspecto }\n else\n format.html { render action: \"new\" }\n format.json { render json: @retroaspecto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @receipe = Receipe.new(params[:receipe])\n\n respond_to do |format|\n if @receipe.save\n format.html { redirect_to @receipe, notice: 'Receipe was successfully created.' }\n format.json { render json: @receipe, status: :created, location: @receipe }\n else\n @receipe.fix_highest_aroma_percentage!\n format.html do\n @selectable_aromas = Aroma.all\n render action: \"new\"\n end\n format.json { render json: @receipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ramal = Ramal.new(params[:ramal])\n\n respond_to do |format|\n if @ramal.save\n format.html { redirect_to @ramal, notice: 'Ramal criado com sucesso!' }\n format.json { render json: @ramal, status: :created, location: @ramal }\n else\n format.html { render action: \"new\" }\n format.json { render json: @ramal.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @respuesta = Respuesta.new(params[:respuesta])\n\n if @respuesta.save\n render json: @respuesta, status: :created, location: @respuesta\n else\n render json: @respuesta.errors, status: :unprocessable_entity\n end\n end",
"def create\n @relatorio = Relatorio.new(relatorio_params)\n\n respond_to do |format|\n if @relatorio.save\n format.html { redirect_to @relatorio, notice: 'Relatorio was successfully created.' }\n format.json { render :show, status: :created, location: @relatorio }\n else\n format.html { render :new }\n format.json { render json: @relatorio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @realtor = Realtor.new(realtor_params)\n\n respond_to do |format|\n if @realtor.save\n format.html { redirect_to @realtor, notice: 'Realtor was successfully created.' }\n format.json { render :show, status: :created, location: @realtor }\n else\n format.html { render :new }\n format.json { render json: @realtor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def crear\n # byebug\n ruta = Ruta.new\n ruta.nombre = params[:ruta][:nombre]\n ruta.descripcion = params[:ruta][:descripcion]\n ruta.subruta = params[:ruta][:subruta]\n ruta.save\n redirect_to action: \"index\"\n\n # respond_to do |format|\n # if @ruta.save\n # format.html { redirect_to @ruta, notice: \"Rutum was successfully created.\" }\n # format.json { render :show, status: :created, location: @ruta }\n # else\n # format.html { render :new }\n # format.json { render json: @ruta.errors, status: :unprocessable_entity }\n # end\n # end\n end",
"def create\n @remedio = Remedio.new(params[:remedio])\n\n respond_to do |format|\n if @remedio.save\n format.html { redirect_to @remedio, notice: 'Remedio was successfully created.' }\n format.json { render json: @remedio, status: :created, location: @remedio }\n else\n format.html { render action: \"new\" }\n format.json { render json: @remedio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @remito = Remito.new(params[:remito])\n\n respond_to do |format|\n if @remito.save\n format.html { redirect_to @remito, notice: 'Remito was successfully created.' }\n format.json { render json: @remito, status: :created, location: @remito }\n else\n format.html { render action: \"new\" }\n format.json { render json: @remito.errors, status: :unprocessable_entity }\n end\n end\n end",
"def json()\n {\\\n :type => \"planned\"\\\n , :target => @recognize.json\\\n , :path => @move.json\\\n }\n end",
"def create\n @relatory = Relatory.new(relatory_params)\n\n respond_to do |format|\n if @relatory.save\n format.html { redirect_to @relatory, notice: 'Relatório Salvo.' }\n format.json { render :show, status: :created, location: @relatory }\n else\n format.html { render :new }\n format.json { render json: @relatory.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @repa = Repa.new(params[:repa])\n\n respond_to do |format|\n if @repa.save\n format.html { redirect_to repas_url, notice: 'Repa was successfully created.' }\n format.json { render json: @repa, status: :created, location: @repa }\n else\n format.html { render action: \"new\" }\n format.json { render json: @repa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @repondre = Repondre.new(repondre_params)\n\n respond_to do |format|\n if @repondre.save\n format.html { redirect_to @repondre, notice: 'Repondre was successfully created.' }\n format.json { render :show, status: :created, location: @repondre }\n else\n format.html { render :new }\n format.json { render json: @repondre.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n @anuncio = Anuncio.new(anuncio_params)\n\n if @anuncio.save\n render :show, status: :created, location: @anuncio\n else\n render json: @anuncio.errors, status: :unprocessable_entity\n end\n end",
"def create\n @renomear = Renomear.new(renomear_params)\n\n respond_to do |format|\n if @renomear.save\n format.html { redirect_to @renomear, notice: 'Renomear was successfully created.' }\n format.json { render action: 'show', status: :created, location: @renomear }\n else\n format.html { render action: 'new' }\n format.json { render json: @renomear.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @pregunta_alternativa = PreguntaAlternativa.new(pregunta_alternativa_params)\n\n respond_to do |format|\n if @pregunta_alternativa.save\n format.html { redirect_to @pregunta_alternativa, notice: 'Pregunta la pregunta fue creada exitosamente.' }\n format.json { render :show, status: :created, location: @pregunta_alternativa }\n else\n format.html { render :new }\n format.json { render json: @pregunta_alternativa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @recibo = Recibo.find(params[:recibo_id])\n @renglon_recdetalle = @recibo.renglon_recdetalles.create(params[:renglon_recdetalle])\n\n respond_to do |format|\n if @renglon_recdetalle.save\n format.html { redirect_to @recibo, notice: 'Renglon recdetalle was successfully created.' }\n format.json { render json: @renglon_recdetalle }\n else\n format.html { render action: \"new\" }\n format.json { render json: @renglon_recdetalle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @imp2_raman = Imp2Raman.new(params[:imp2_raman])\n\n respond_to do |format|\n if @imp2_raman.save\n format.html { redirect_to @imp2_raman, notice: 'Imp2 raman was successfully created.' }\n format.json { render json: @imp2_raman, status: :created, location: @imp2_raman }\n else\n format.html { render action: \"new\" }\n format.json { render json: @imp2_raman.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @arrendatario = Arrendatario.new(arrendatario_params)\n\n respond_to do |format|\n if @arrendatario.save\n format.html { redirect_to @arrendatario, notice: 'Arrendatario was successfully created.' }\n format.json { render :show, status: :created, location: @arrendatario }\n else\n format.html { render :new }\n format.json { render json: @arrendatario.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\r\n @announcament = Announcament.new(announcament_params)\r\n\r\n respond_to do |format|\r\n if @announcament.save\r\n format.html { redirect_to @announcament, notice: 'İlan başarılı bir şekilde oluşturuldu.' }\r\n format.json { render :show, status: :created, location: @announcament }\r\n else\r\n format.html { render :new }\r\n format.json { render json: @announcament.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def create\n @rebateable = find_rebateable\n @rebate = @rebateable.rebates.build(params[:rebate])\n @sector_names = params[:sector_names] || []\n @industry_names = params[:industry_names] || []\n @rebate.tag_names = @sector_names.join(',') + \",\" + @industry_names.join(',')\n\n respond_to do |format|\n if @rebate.save\n format.html { redirect_to :id => nil }\n format.json { render json: @rebate, status: :created, location: @rebate }\n else\n format.html { render action: \"new\" }\n format.json { render json: @rebate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @alejandro = Alejandro.new(alejandro_params)\n\n respond_to do |format|\n if @alejandro.save\n format.html { redirect_to @alejandro, notice: 'Alejandro was successfully created.' }\n format.json { render :show, status: :created, location: @alejandro }\n else\n format.html { render :new }\n format.json { render json: @alejandro.errors, status: :unprocessable_entity }\n end\n end\n end",
"def random_roberto_speech\n skip_authorization\n respond_to do |format|\n format.json do\n render json: { roberto_speech: \"#{RobertoBarros.in_ingrish} #{direction_for_active_cell(@play)}\" }\n end\n end\n end",
"def create\n @agronomiaquimica = Agronomiaquimica.new(params[:agronomiaquimica])\n\n respond_to do |format|\n if @agronomiaquimica.save\n format.html { redirect_to @agronomiaquimica, notice: 'Agronomiaquimica was successfully created.' }\n format.json { render json: @agronomiaquimica, status: :created, location: @agronomiaquimica }\n else\n format.html { render action: \"new\" }\n format.json { render json: @agronomiaquimica.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @imp_raman = ImpRaman.new(params[:imp_raman])\n\n respond_to do |format|\n if @imp_raman.save\n format.html { redirect_to @imp_raman, notice: 'Imp raman was successfully created.' }\n format.json { render json: @imp_raman, status: :created, location: @imp_raman }\n else\n format.html { render action: \"new\" }\n format.json { render json: @imp_raman.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @exam = Exam.new(exam_params)\n @exam.patient = @patient\n\n if @exam.save\n render json: @exam, include: [:point_po, :point_or, :point_n, :point_a], methods: :maxillary_depth_angle, status: :created\n else\n render json: @exam.errors, status: :unprocessable_entity\n end\n end",
"def create\n @rua = Rua.new(params[:rua])\n\n respond_to do |format|\n if @rua.save\n format.html { redirect_to @rua, notice: 'Rua was successfully created.' }\n format.json { render json: @rua, status: :created, location: @rua }\n else\n format.html { render action: \"new\" }\n format.json { render json: @rua.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @regra_negocio = RegraNegocio.new(regra_negocio_params)\n\n respond_to do |format|\n if @regra_negocio.save\n format.html { redirect_to @regra_negocio, notice: 'Regra negocio was successfully created.' }\n format.json { render :show, status: :created, location: @regra_negocio }\n else\n format.html { render :new }\n format.json { render json: @regra_negocio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @respuesta = Respuesta.new(params[:respuesta])\n\n respond_to do |format|\n if @respuesta.save\n format.html { redirect_to @respuesta, notice: 'Respuesta was successfully created.' }\n format.json { render json: @respuesta, status: :created, location: @respuesta }\n else\n format.html { render action: \"new\" }\n format.json { render json: @respuesta.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @repa = Repa.new(params[:repa])\n @repa.user_id = current_user.id\n respond_to do |format|\n if @repa.save\n format.html { redirect_to @repa, notice: 'Repa was successfully created.' }\n format.json { render json: @repa, status: :created, location: @repa }\n else\n format.html { render action: \"new\" }\n format.json { render json: @repa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @renseignement = Renseignement.new(renseignement_params)\n \n\n respond_to do |format|\n if @renseignement.save\n format.html { redirect_to @renseignement, notice: \"Renseignement was successfully created.\" }\n format.json { render :show, status: :created, location: @renseignement }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @renseignement.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @avaliation = current_user.avaliations.build(avaliation_params)\n\n respond_to do |format|\n if @avaliation.save\n format.html { redirect_to @avaliation, notice: 'Avaliation was successfully created.' }\n format.json { render :show, status: :created, location: @avaliation }\n else\n format.html { render :new }\n format.json { render json: @avaliation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @alternativa = Alternativa.new(alternativa_params)\n\n respond_to do |format|\n if @alternativa.save\n format.html { redirect_to @alternativa, notice: 'Alternativa was successfully created.' }\n format.json { render :show, status: :created, location: @alternativa }\n else\n format.html { render :new }\n format.json { render json: @alternativa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @recipe = current_user.recipes.build(recipe_params)\n @recipe.user = current_user\n @recipe.save\n @measurs = Array.new\n @ingrs = Array.new\n @tgs = Array.new\n #ovo bi trebalo unutar sebe prikupiti sastojke i mjere\n parse_ingredients\n parse_tags\n @recipe.measurements = @measurs\n @recipe.ingredients = @ingrs\n @recipe.recipe_tags = @tgs\n\n respond_to do |format|\n if @recipe.save\n format.html { redirect_to @recipe, notice: 'Recipe was successfully created.' }\n format.json { render :show, status: :created, location: @recipe }\n else\n format.html { render :new }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n p = prediction_params\n\n p[:tags] = [p[:tags]]\n puts \"BLAH\"\n puts p\n @prediction = current_user.predictions.create(p)\n respond_to do |format|\n if @prediction.save\n format.html { redirect_to action: 'index' }\n format.json { render action: 'show', status: :created, location: @prediction }\n else\n format.html { render action: 'new' }\n format.json { render json: @prediction.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\r\n @relatorio = Relatorio.new(relatorio_params)\r\n\r\n respond_to do |format|\r\n if @relatorio.save\r\n format.html { redirect_to @relatorio, notice: 'Relatório criado com sucesso.' }\r\n format.json { render :show, status: :created, location: @relatorio }\r\n else\r\n format.html { render :new }\r\n format.json { render json: @relatorio.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def create\n @asignacion_familiar = AsignacionFamiliar.new(asignacion_familiar_params)\n\n respond_to do |format|\n if @asignacion_familiar.save\n format.html { redirect_to @asignacion_familiar, notice: 'Asignacion familiar creada exitosamente.' }\n format.json { render :show, status: :created, location: @asignacion_familiar }\n else\n format.html { render :new }\n format.json { render json: @asignacion_familiar.errors, status: :unprocessable_entity }\n end\n end\n end",
"def createCharities\n\tcharity_list = [\"Direct Relief\", \"Catholic Medical Mission Board\", \"MAP International\", \"United Nations Foundation\", \"The Rotary Foundation of Rotary International\", \"Samaritan's Purse\", \"Institute of International Education\", \"International Rescue Committee\", \"Compassion International\", \"United States Fund for UNICEF\"]\n\tcharity_list.each do |charity|\n\t\tRestClient.post 'http://api.reimaginebanking.com/merchants?key=e0486a76005721ee6d86b140eaea2a40', { \"name\": \"#{charity}\"}.to_json, :content_type => :json, :accept => :json\n\tend\nend",
"def create\n @rozmiar = Rozmiar.new(rozmiar_params)\n\n respond_to do |format|\n if @rozmiar.save\n format.html { redirect_to @rozmiar, notice: 'Rozmiar was successfully created.' }\n format.json { render :show, status: :created, location: @rozmiar }\n else\n format.html { render :new }\n format.json { render json: @rozmiar.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @recaudacion = Recaudacion.new(recaudacion_params)\n\n respond_to do |format|\n if @recaudacion.save\n format.html { redirect_to @recaudacion, notice: 'Recaudacion was successfully created.' }\n format.json { render :show, status: :created, location: @recaudacion }\n else\n format.html { render :new }\n format.json { render json: @recaudacion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @situacion_revistum = SituacionRevistum.new(situacion_revistum_params)\n\n respond_to do |format|\n if @situacion_revistum.save\n format.html { redirect_to @situacion_revistum, notice: 'Situacion revistum was successfully created.' }\n format.json { render json: @situacion_revistum, status: :created, location: @situacion_revistum }\n else\n format.html { render action: \"new\" }\n format.json { render json: @situacion_revistum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ruolo = Ruolo.new(ruolo_params)\n\n respond_to do |format|\n if @ruolo.save\n format.html { redirect_to @ruolo, notice: 'Ruolo was successfully created.' }\n format.json { render :show, status: :created, location: @ruolo }\n else\n format.html { render :new }\n format.json { render json: @ruolo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @remuneracao = Remuneracao.new(remuneracao_params)\n\n respond_to do |format|\n if @remuneracao.save\n format.html { redirect_to @remuneracao, notice: 'Remuneracao was successfully created.' }\n format.json { render :show, status: :created, location: @remuneracao }\n else\n format.html { render :new }\n format.json { render json: @remuneracao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def restricao_params\n params.require(:restricao).permit(:palavra)\n end",
"def create\n @resveration = Resveration.new(resveration_params)\n\n respond_to do |format|\n if @resveration.save\n format.html { redirect_to @resveration, notice: 'Resveration was successfully created.' }\n format.json { render :show, status: :created, location: @resveration }\n else\n format.html { render :new }\n format.json { render json: @resveration.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @retro = Retro.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @retro }\n end\n end",
"def create\n @respuesta = Respuesta.new(respuesta_params)\n\n respond_to do |format|\n if @respuesta.save\n format.html { redirect_to @respuesta, notice: 'Respuesta was successfully created.' }\n format.json { render :show, status: :created, location: api_v1_respuesta_url(@respuesta) }\n else\n format.html { render :new }\n format.json { render json: @respuesta.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @reparacion = Reparacion.new(params[:reparacion])\n\n respond_to do |format|\n if @reparacion.save\n format.html { redirect_to @reparacion, notice: 'Reparacion se ha creado con éxito.' }\n format.json { render json: @reparacion, status: :created, location: @reparacion }\n else\n format.html { render action: \"new\" }\n format.json { render json: @reparacion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @reltramovano = Reltramovano.new(params[:reltramovano])\n\n respond_to do |format|\n if @reltramovano.save\n format.html { redirect_to @reltramovano, notice: 'Reltramovano was successfully created.' }\n format.json { render json: @reltramovano, status: :created, location: @reltramovano }\n else\n format.html { render action: \"new\" }\n format.json { render json: @reltramovano.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @alternativo = Alternativo.new(alternativo_params)\n\n respond_to do |format|\n if @alternativo.save\n format.html { redirect_to @alternativo, notice: 'Alternativo was successfully created.' }\n format.json { render :show, status: :created, location: @alternativo }\n else\n format.html { render :new }\n format.json { render json: @alternativo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @rute = Rute.new(rute_params)\n\n respond_to do |format|\n if @rute.save\n format.html { redirect_to @rute, notice: \"Rute was successfully created.\" }\n format.json { render :show, status: :created, location: @rute }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @rute.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @frais_repa = FraisRepa.new(params[:frais_repa])\n\n respond_to do |format|\n if @frais_repa.save\n format.html { redirect_to @frais_repa, :notice => 'Le frais de repas a bien été créé' }\n format.json { render :json => @frais_repa, :status => :created, :location => @frais_repa }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @frais_repa.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @ulasan = Ulasan.new(ulasan_params)\n\n if @ulasan.save\n render :show, status: :created, location: @ulasan\n else\n render json: @ulasan.errors, status: :unprocessable_entity\n end\n end",
"def create\n @announcament = Announcament.new(announcament_params)\n\n respond_to do |format|\n if @announcament.save\n format.html { redirect_to @announcament, notice: 'Announcament was successfully created.' }\n format.json { render :show, status: :created, location: @announcament }\n else\n format.html { render :new }\n format.json { render json: @announcament.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @restricao = Restricao.new(restricao_params)\n\n respond_to do |format|\n if @restricao.save\n format.html { redirect_to restricaos_path, notice: 'Restrição foi Criada com Sucesso!' }\n # format.json { render :show, status: :created, location: @restricao }\n else\n format.html { render :new }\n format.json { render json: @restricao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @recepcion = Recepcion.new(recepcion_params)\n\n respond_to do |format|\n if @recepcion.save\n format.html { redirect_to @recepcion, notice: 'Recepcion was successfully created.' }\n format.json { render :show, status: :created, location: @recepcion }\n else\n format.html { render :new }\n format.json { render json: @recepcion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @repertoire = Repertoire.new(repertoire_params)\n\n if @repertoire.save\n render :show, status: :created, location: @repertoire\n else\n render json: @repertoire.errors, status: :unprocessable_entity\n end\n end",
"def create\n @ram_post = RamPost.new(ram_post_params)\n\n respond_to do |format|\n if @ram_post.save\n format.html { redirect_to @ram_post, notice: 'Ram post was successfully created.' }\n format.json { render :show, status: :created, location: @ram_post }\n else\n format.html { render :new }\n format.json { render json: @ram_post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @immunization = Immunization.new(immunization_params)\n\n respond_to do |format|\n if @immunization.save\n format.html { redirect_to @immunization, notice: 'Immunization was successfully created.' }\n format.json { render :show, status: :created, location: @immunization }\n else\n format.html { render :new }\n format.json { render json: @immunization.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @roupa = Roupa.new(roupa_params)\n\n respond_to do |format|\n if @roupa.save\n format.html { redirect_to @roupa, notice: \"Roupa was successfully created.\" }\n format.json { render :show, status: :created, location: @roupa }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @roupa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @representante_athlete = Representante::Athlete.new(params[:representante_athlete])\n @representante_athlete.organization = current_user.organization\n\n respond_to do |format|\n if @representante_athlete.save\n format.html { redirect_to representante_athletes_url, notice: 'Atleta criado com sucesso' }\n format.json { render json: @representante_athlete, status: :created, location: @representante_athlete }\n else\n format.html { render action: \"new\" }\n format.json { render json: @representante_athlete.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @announcement = Announcement.new(announcement_params)\n @degrees = params[:degrees]['degree']\n @charges = params[:charges]['charge']\n @announcement.degrees = @degrees.join(',')\n @annoCuncement.charges = @charges.join(',')\n @announcement.user = current_user\n @announcement.president_aproved = false\n @announcement.oficial_aproved = false\n respond_to do |format|\n if @announcement.save\n format.html { redirect_to @announcement, notice: 'El anuncio se creo correctamente.' }\n format.json { render :show, status: :created, location: @announcement }\n else\n format.html { render :new }\n format.json { render json: @announcement.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @immigrant = Immigrant.new(params[:immigrant])\n\n respond_to do |format|\n if @immigrant.save\n format.html { redirect_to @immigrant, notice: 'Immigrant was successfully created.' }\n format.json { render json: @immigrant, status: :created, location: @immigrant }\n else\n format.html { render action: \"new\" }\n format.json { render json: @immigrant.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @retirement = current_user.retirements.new(retirement_params)\n\n respond_to do |format|\n if @retirement.save\n format.html { redirect_to @retirement, notice: 'Retirement was successfully created.' }\n format.json { render :show, status: :created, location: @retirement }\n else\n format.html { render :new }\n format.json { render json: @retirement.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ruta = Ruta.new(ruta_params)\n respond_to do |format|\n if params[:parada_inicial] != \"\"\n @inicio = Parada.find(params[:parada_inicial])\n @ruta.parada.push(@inicio)\n @ruta_parada = @ruta.ruta_parada.find_by(parada_id: @inicio.id)\n @ruta_parada.tipo = 1\n @ruta_parada.save\n end\n if params[:parada_final] != \"\"\n @final = Parada.find(params[:parada_final])\n @ruta.parada.push(@final)\n @ruta_parada = @ruta.ruta_parada.find_by(parada_id: @final.id)\n @ruta_parada.tipo = -1\n @ruta_parada.save\n end\n if params[:grupo_paradas] != \"\"\n @paradas = Parada.where(:id => params[:grupo_paradas])\n @ruta.parada << @paradas\n end\n if @ruta.save\n format.html { redirect_to @ruta, notice: 'Ruta was successfully created.' }\n format.json { render :show, status: :created, location: @ruta }\n else\n format.html { render :new }\n format.json { render json: @ruta.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @reply_puntuation = ReplyPuntuation.new(reply_puntuation_params)\n\n respond_to do |format|\n if @reply_puntuation.save\n format.html { redirect_to :back }\n format.json { render :show, status: :created, location: @reply_puntuation }\n else\n format.html { render :new }\n format.json { render json: @reply_puntuation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @restaturant = Restaturant.new(restaturant_params)\n\n respond_to do |format|\n if @restaturant.save\n format.html { redirect_to @restaturant, notice: \"Restaturant was successfully created.\" }\n format.json { render :show, status: :created, location: @restaturant }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @restaturant.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @relogio = Relogio.new(params[:relogio])\n\n respond_to do |format|\n if @relogio.save\n format.html { redirect_to @relogio, notice: 'Relogio was successfully created.' }\n format.json { render json: @relogio, status: :created, location: @relogio }\n else\n format.html { render action: \"new\" }\n format.json { render json: @relogio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @roman_numerals = RomanNumeral.all\n @alien_numeral = AlienNumeral.new(alien_numeral_params)\n\n respond_to do |format|\n if @alien_numeral.save\n format.html { redirect_to root_path, notice: 'Alien numeral was successfully created.' }\n format.json { render :show, status: :created, location: @alien_numeral }\n else\n format.html { render :new }\n format.json { render json: @alien_numeral.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @taxon_name_relationship = TaxonNameRelationship.new(taxon_name_relationship_params)\n\n respond_to do |format|\n if @taxon_name_relationship.save\n format.html { redirect_to @taxon_name_relationship.metamorphosize, notice: 'Taxon name relationship was successfully created.' }\n format.json { render action: 'show', status: :created, location: @taxon_name_relationship.metamorphosize }\n else\n format.html { render action: 'new' }\n format.json { render json: @taxon_name_relationship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post_spoonacular\n # %encode ingredients to url\n encoded_ingr = URI.escape(@translated_recipe[:ingredients_list])\n # post call block :\n url = URI(\"https://spoonacular-recipe-food-nutrition-v1.p.rapidapi.com/recipes/parseIngredients?includeNutrition=true\")\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n request = Net::HTTP::Post.new(url)\n request[\"content-type\"] = \"application/x-www-form-urlencoded\"\n request[\"x-rapidapi-key\"] = ENV[\"X_RAPIDAPI_KEY\"]\n request[\"x-rapidapi-host\"] = \"spoonacular-recipe-food-nutrition-v1.p.rapidapi.com\"\n # body of the call with ingredients and servings\n request.body = \"ingredientList=#{encoded_ingr}&#{@recipe_hash[:servings]}\"\n # response\n response = http.request(request)\n end",
"def new\n @retroaspecto = Retroaspecto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @retroaspecto }\n end\n end",
"def create\n @analise = current_user.analises.build(analise_params)\n\n respond_to do |format|\n if @analise.save\n format.html { redirect_to @analise, notice: 'Analise was successfully created.' }\n format.json { render :show, status: :created, location: @analise }\n else\n format.html { render :new }\n format.json { render json: @analise.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @gonullu = Gonullu.new(gonullu_params)\n\n respond_to do |format|\n if @gonullu.save\n format.html { redirect_to @gonullu, notice: 'Gonullu was successfully created.' }\n format.json { render :show, status: :created, location: @gonullu }\n else\n format.html { render :new }\n format.json { render json: @gonullu.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @representative = Representative.new(representative_params)\n\n respond_to do |format|\n if @representative.save\n format.html { redirect_to [:admin, @representative], notice: 'Representative was successfully created.' }\n format.json { render :show, status: :created, location: @representative }\n else\n format.html { render :new }\n format.json { render json: @representative.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @torneo_apartura = TorneoApartura.new(torneo_apartura_params)\n\n respond_to do |format|\n if @torneo_apartura.save\n format.html { redirect_to @torneo_apartura, notice: 'Torneo apartura was successfully created.' }\n format.json { render :show, status: :created, location: @torneo_apartura }\n else\n format.html { render :new }\n format.json { render json: @torneo_apartura.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @poligono = Poligono.new(poligono_params)\n\n respond_to do |format|\n if @poligono.save\n format.html { redirect_to @poligono, notice: 'Poligono was successfully created.' }\n format.json { render action: 'show', status: :created, location: @poligono }\n else\n format.html { render action: 'new' }\n format.json { render json: @poligono.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @regraponto = Regraponto.new(regraponto_params)\n\n respond_to do |format|\n if @regraponto.save\n format.html { redirect_to @regraponto, notice: 'Regraponto was successfully created.' }\n format.json { render :show, status: :created, location: @regraponto }\n else\n format.html { render :new }\n format.json { render json: @regraponto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @lectura = Lectura.new(lectura_params)\n\n articulo = @lectura.articulo\n articulo.upr = @lectura.lector.posicion\n articulo.save\n\n respond_to do |format|\n if @lectura.save\n format.html { redirect_to lecturas_path, notice: 'Lectura creada con éxito.' }\n format.json { render :show, status: :created, location: @lectura }\n else\n format.html { render :new }\n format.json { render json: @lectura.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @reentrada = Reentrada.new(reentrada_params)\n\n @reentrada.cadastro_1_id = user.cadastro.id\n\n respond_to do |format|\n if @reentrada.save\n format.html { redirect_to reentradas_path, notice: 'Reentrada was successfully created.' }\n format.json { render :show, status: :created, location: @reentrada }\n else\n format.html { render :new }\n format.json { render json: @reentrada.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @matriculacion = Matriculacion.new(matriculacion_params)\n\n respond_to do |format|\n if @matriculacion.save\n format.html { redirect_to @matriculacion, notice: 'Matriculacion was successfully created.' }\n format.json { render :show, status: :created, location: @matriculacion }\n else\n format.html { render :new }\n format.json { render json: @matriculacion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def restoran_params\n params.require(:restoran).permit(:name, :slug, :content, :avatar, :about, :logo, :main_image, :address, :phone_number, :time_of_work, :short_description, :position)\n end",
"def create\n @armazena = Armazena.new(armazena_params)\n\n respond_to do |format|\n if @armazena.save\n format.html { redirect_to @armazena, notice: 'Armazena was successfully created.' }\n format.json { render :show, status: :created, location: @armazena }\n else\n format.html { render :new }\n format.json { render json: @armazena.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @lugar = Lugar.new(lugar_params)\n\n if @lugar.save\n render json: @lugar, status: :created, location: @lugar\n else\n render json: @lugar.errors, status: :unprocessable_entity\n end\n end",
"def create\n @objeto = Caracteristica.new(caracteristica_params)\n\n respond_to do |format|\n if @objeto.save\n set_redireccion\n format.html { redirect_to @redireccion, notice: 'Caracteristica was successfully created.' }\n format.json { render :show, status: :created, location: @objeto }\n else\n format.html { render :new }\n format.json { render json: @objeto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @manga = Manga.new(manga_params)\n @manga.tags = @params_tags\n @manga.author = @author\n\n respond_to do |format|\n if @manga.save\n format.html { redirect_to @manga, notice: 'Manga was successfully created.' }\n format.json { render :show, status: :created, location: @manga }\n else\n format.html { render :new }\n format.json { render json: @manga.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n relearnable = current_user.relearnables.new(relearnable_params)\n\n respond_to do |format|\n if relearnable.save\n format.html { redirect_to relearnable, notice: 'Relearnable was successfully created.' }\n format.json { render :show, status: :created, location: relearnable }\n else\n @relearnable = relearnable\n format.html { render :new }\n format.json { render json: relearnable.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n abort(\"aca\")\n @user = User.new(params[:user])\n @arregloSexo = [\"masculino\",\"femenino\"] \n @arregloTypeDoc = [\"DNI\",\"L.E\",\"Carnet Univesitario\"]\n #abort(\"usercreate\")\n respond_to do |format|\n if @user.save\n @entrepreneur = Entrepreneur.new(:user_id => @user.id, :guy => 2)\n if @entrepreneur.save\n format.html { redirect_to @entrepreneur, :notice => 'Entrepreneur was successfully created.' }\n format.json { render :json => @entrepreneur, :status => :created, :location => @entrepreneur }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @entrepreneur.errors, :status => :unprocessable_entity }\n end\n end\n end\n end",
"def create\n @reconocimiento = Reconocimiento.new(params[:reconocimiento])\n\n respond_to do |format|\n if @reconocimiento.save\n format.html { redirect_to @reconocimiento, :notice => 'Reconocimiento was successfully created.' }\n format.json { render :json => @reconocimiento, :status => :created, :location => @reconocimiento }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @reconocimiento.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @natulang = Natulang.new(params[:natulang])\n\n respond_to do |format|\n if @natulang.save\n format.html { redirect_to @natulang, notice: 'Natulang was successfully created.' }\n format.json { render json: @natulang, status: :created, location: @natulang }\n else\n format.html { render action: \"new\" }\n format.json { render json: @natulang.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @rayon = Rayon.new(params[:rayon])\n\n respond_to do |format|\n if @rayon.save\n format.html { redirect_to @rayon, notice: 'Rayon was successfully created.' }\n format.json { render json: @rayon, status: :created, location: @rayon }\n else\n format.html { render action: \"new\" }\n format.json { render json: @rayon.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @aluguel = Aluguel.new(aluguel_params)\n\n respond_to do |format|\n if @aluguel.save\n format.html { redirect_to @aluguel, notice: 'Aluguel was successfully created.' }\n format.json { render :show, status: :created, location: @aluguel }\n else\n format.html { render :new }\n format.json { render json: @aluguel.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @suggetion = Suggetion.new(suggetion_params)\n\n respond_to do |format|\n if @suggetion.save\n format.html { redirect_to @suggetion, notice: 'Suggetion was successfully created.' }\n format.json { render :show, status: :created, location: @suggetion }\n else\n format.html { render :new }\n format.json { render json: @suggetion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n #@aliments = Aliment.order(\"name ASC\").all\n @repa = Repa.new\n @ingredient = @repa.ingredients.build\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @repa }\n end\n end",
"def create\n request_image = params[:image]\n url_hash = SecureRandom.urlsafe_base64(6)\n name = url_hash + \"-\" + request_image.original_filename.downcase\n\n File.open(\"#{Rails.root}/public/theta/#{name}\", 'wb') do |f|\n f.write(request_image.read)\n end\n\n theta = Theta.create!(url_hash: url_hash, image_url: name)\n render json: {url: \"http://www.rakugaki.tk/h/#{theta.url_hash}\"}, status: 201\n end",
"def create\n @receita_medica = ReceitaMedica.new(params[:receita_medica])\n @receita_medica.medico = current_user\n\n respond_to do |format|\n if @receita_medica.save\n format.html { redirect_to @receita_medica, notice: 'Receita medica was successfully created.' }\n format.json { render json: @receita_medica, status: :created, location: @receita_medica }\n else\n format.html { render action: \"new\" }\n format.json { render json: @receita_medica.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @aliado = Aliado.new(aliado_params)\n\n respond_to do |format|\n if @aliado.save\n format.html { redirect_to @aliado, notice: 'Aliado was successfully created.' }\n format.json { render :show, status: :created, location: @aliado }\n else\n format.html { render :new }\n format.json { render json: @aliado.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @reparticao = Reparticao.new(reparticao_params)\n\n respond_to do |format|\n if @reparticao.save\n format.html { redirect_to @reparticao, notice: 'Reparticao was successfully created.' }\n format.json { render :show, status: :created, location: @reparticao }\n else\n format.html { render :new }\n format.json { render json: @reparticao.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.58812654",
"0.58588254",
"0.57641846",
"0.5677848",
"0.55983293",
"0.55472434",
"0.5527593",
"0.5481473",
"0.54783034",
"0.54699445",
"0.54505444",
"0.54477286",
"0.5423936",
"0.5420644",
"0.5415448",
"0.540614",
"0.5393993",
"0.5392094",
"0.5367207",
"0.53641605",
"0.5349564",
"0.5329169",
"0.5324938",
"0.53247494",
"0.53236425",
"0.5319868",
"0.5310877",
"0.53090805",
"0.53087986",
"0.5305571",
"0.53033006",
"0.530112",
"0.52990663",
"0.52900016",
"0.5289066",
"0.5288569",
"0.5284603",
"0.5284121",
"0.5275395",
"0.5271599",
"0.5269315",
"0.52687913",
"0.52619994",
"0.5258693",
"0.5257032",
"0.52570033",
"0.52530295",
"0.5252588",
"0.5249673",
"0.52478826",
"0.5245605",
"0.5234634",
"0.52307326",
"0.5229385",
"0.52292913",
"0.5228181",
"0.52261496",
"0.5225455",
"0.5224117",
"0.52144516",
"0.52116144",
"0.5205634",
"0.5202203",
"0.5199281",
"0.51978076",
"0.5194417",
"0.5191854",
"0.5190999",
"0.5183666",
"0.5183103",
"0.51796186",
"0.51755726",
"0.51719177",
"0.5170302",
"0.51696616",
"0.51620936",
"0.5160855",
"0.5158597",
"0.515771",
"0.5156201",
"0.51560295",
"0.51541156",
"0.5152089",
"0.51470745",
"0.514577",
"0.51439196",
"0.5143195",
"0.5141407",
"0.5137863",
"0.5137503",
"0.5133993",
"0.51304305",
"0.5123189",
"0.51218694",
"0.51208335",
"0.5117675",
"0.5117654",
"0.5115597",
"0.5113647",
"0.5105776"
] | 0.67328525 | 0 |
PUT /retroalimentacions/1 PUT /retroalimentacions/1.json | def update
@retroalimentacion = Retroalimentacion.find(params[:id])
respond_to do |format|
if @retroalimentacion.update_attributes(params[:retroalimentacion])
format.html { redirect_to @retroalimentacion, notice: 'Retroalimentacion was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @retroalimentacion.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @retro = Retro.find(params[:id])\n\n respond_to do |format|\n if @retro.update_attributes(params[:retro])\n format.html { redirect_to @retro, notice: 'Retro was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @retro.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @retroaspecto = Retroaspecto.find(params[:id])\n\n respond_to do |format|\n if @retroaspecto.update_attributes(params[:retroaspecto])\n format.html { redirect_to @retroaspecto, notice: 'Retroaspecto was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @retroaspecto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\r\n respond_to do |format|\r\n if @relatorio.update(relatorio_params)\r\n format.html { redirect_to @relatorio, notice: 'Relatório atualizado com sucesso.' }\r\n format.json { render :show, status: :ok, location: @relatorio }\r\n else\r\n format.html { render :edit }\r\n format.json { render json: @relatorio.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def update\n render json: Alien.update(params[\"id\"], params[\"alien\"])\n end",
"def update\n @ramal = Ramal.find(params[:id])\n\n respond_to do |format|\n if @ramal.update_attributes(params[:ramal])\n format.html { redirect_to @ramal, notice: 'Ramal alterado com sucesso!' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ramal.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @receipe = Receipe.find(params[:id])\n\n respond_to do |format|\n if @receipe.update_attributes(params[:receipe])\n format.html { redirect_to @receipe, notice: 'Receipe was successfully updated.' }\n format.json { head :no_content }\n else\n @receipe.fix_highest_aroma_percentage!\n format.html do\n @selectable_aromas = Aroma.all\n render action: \"edit\"\n end\n format.json { render json: @receipe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @rayon = Rayon.find(params[:id])\n\n respond_to do |format|\n if @rayon.update_attributes(params[:rayon])\n format.html { redirect_to @rayon, notice: 'Rayon was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @rayon.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @remito = Remito.find(params[:id])\n\n respond_to do |format|\n if @remito.update_attributes(params[:remito])\n format.html { redirect_to @remito, notice: 'Remito was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @remito.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @taxon_name_relationship.update(taxon_name_relationship_params)\n format.html { redirect_to @taxon_name_relationship.metamorphosize, notice: 'Taxon name relationship was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @taxon_name_relationship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @relatorio.update(relatorio_params)\n format.html { redirect_to @relatorio, notice: 'Relatorio was successfully updated.' }\n format.json { render :show, status: :ok, location: @relatorio }\n else\n format.html { render :edit }\n format.json { render json: @relatorio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @representante_athlete.update_attributes(params[:representante_athlete])\n format.html { redirect_to representante_athletes_url, notice: 'Atleta atualizado com sucesso' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @representante_athlete.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @ore = Ore.find(params[:id])\n \n respond_to do |format|\n if @ore.update_attributes(params[:ore])\n format.html { redirect_to @ore, notice: 'Ore was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @ore.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @remedio = Remedio.find(params[:id])\n\n respond_to do |format|\n if @remedio.update_attributes(params[:remedio])\n format.html { redirect_to @remedio, notice: 'Remedio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @remedio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @agronomiaquimica = Agronomiaquimica.find(params[:id])\n\n respond_to do |format|\n if @agronomiaquimica.update_attributes(params[:agronomiaquimica])\n format.html { redirect_to @agronomiaquimica, notice: 'Agronomiaquimica was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @agronomiaquimica.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @anuncio = Anuncio.find params[:id]\n if @anuncio.update(anuncio_params)\n render :show, status: :ok, location: @anuncio\n else\n render json: @anuncio.errors, status: :unprocessable_entity\n end\n end",
"def update\n @arbitro = Arbitro.find(params[:id])\n\n respond_to do |format|\n if @arbitro.update_attributes(params[:arbitro])\n format.html { redirect_to @arbitro, notice: 'El Arbitro se ha modificado correctamente.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @arbitro.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @relatorios = Relatorio.find(params[:id])\n\n respond_to do |format|\n if @relatorios.update_attributes(params[:relatorio])\n flash[:notice] = 'RELATORIO SALVO COM SUCESSO.'\n format.html { redirect_to(@relatorios) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @relatorios.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @alejandro.update(alejandro_params)\n format.html { redirect_to @alejandro, notice: 'Alejandro was successfully updated.' }\n format.json { render :show, status: :ok, location: @alejandro }\n else\n format.html { render :edit }\n format.json { render json: @alejandro.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @resveration.update(resveration_params)\n format.html { redirect_to @resveration, notice: 'Resveration was successfully updated.' }\n format.json { render :show, status: :ok, location: @resveration }\n else\n format.html { render :edit }\n format.json { render json: @resveration.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @atricle.update(atricle_params)\n format.html { redirect_to @atricle, notice: 'Atricle was successfully updated.' }\n format.json { render :show, status: :ok, location: @atricle }\n else\n format.html { render :edit }\n format.json { render json: @atricle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @atricle.update(atricle_params)\n format.html { redirect_to @atricle, notice: \"Atricle was successfully updated.\" }\n format.json { render :show, status: :ok, location: @atricle }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @atricle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @objeto.update(caracteristica_params)\n set_redireccion\n format.html { redirect_to @redireccion, notice: 'Caracteristica was successfully updated.' }\n format.json { render :show, status: :ok, location: @objeto }\n else\n format.html { render :edit }\n format.json { render json: @objeto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @autore = Autore.find(params[:id])\n\n respond_to do |format|\n if @autore.update_attributes(params[:autore])\n format.html { redirect_to @autore, notice: 'Autore was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @autore.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @suggetion.update(suggetion_params)\n format.html { redirect_to @suggetion, notice: 'Suggetion was successfully updated.' }\n format.json { render :show, status: :ok, location: @suggetion }\n else\n format.html { render :edit }\n format.json { render json: @suggetion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n respond_to do |format|\n if @realtor.update(realtor_params)\n format.html { redirect_to @realtor, notice: 'Realtor was successfully updated.' }\n format.json { render :show, status: :ok, location: @realtor }\n else\n format.html { render :edit }\n format.json { render json: @realtor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @relatory.update(relatory_params)\n format.html { redirect_to @relatory, notice: 'Relatório atualizado.' }\n format.json { render :show, status: :ok, location: @relatory }\n else\n format.html { render :edit }\n format.json { render json: @relatory.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @representative.update(representative_params)\n format.html { redirect_to [:admin, @representative], notice: 'Representative was successfully updated.' }\n format.json { render :show, status: :ok, location: @representative }\n else\n format.html { render :edit }\n format.json { render json: @representative.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @immigrant = Immigrant.find(params[:id])\n\n respond_to do |format|\n if @immigrant.update_attributes(params[:immigrant])\n format.html { redirect_to @immigrant, notice: 'Immigrant was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @immigrant.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @realtor.update(realtor_params)\n format.html { redirect_to @realtor, notice: 'Realtor was successfully updated.' }\n format.json { render :show, status: :ok, location: @realtor }\n else\n format.html { render :edit }\n format.json { render json: @realtor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @respuesta = Respuesta.find(params[:id])\n\n respond_to do |format|\n if @respuesta.update_attributes(params[:respuesta])\n format.html { redirect_to @respuesta, notice: 'Respuesta was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @respuesta.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @arthicle.update(arthicle_params)\n format.html { redirect_to @arthicle, notice: 'Arthicle was successfully updated.' }\n format.json { render :show, status: :ok, location: @arthicle }\n else\n format.html { render :edit }\n format.json { render json: @arthicle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @aroma = Aroma.find(params[:id])\n\n respond_to do |format|\n if @aroma.update_attributes(params[:aroma])\n format.html { redirect_to @aroma, notice: 'Aroma was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @aroma.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @lugar = Lugar.find(params[:id])\n\n if @lugar.update(lugar_params)\n head :no_content\n else\n render json: @lugar.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @renomear.update(renomear_params)\n format.html { redirect_to @renomear, notice: 'Renomear was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @renomear.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @respuesta = Respuesta.find(params[:id])\n\n if @respuesta.update(params[:respuesta])\n head :no_content\n else\n render json: @respuesta.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @asignacion_familiar.update(asignacion_familiar_params)\n format.html { redirect_to @asignacion_familiar, notice: 'Asignacion familiar actualizada exitosamente.' }\n format.json { render :show, status: :ok, location: @asignacion_familiar }\n else\n format.html { render :edit }\n format.json { render json: @asignacion_familiar.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ruolo.update(ruolo_params)\n format.html { redirect_to @ruolo, notice: 'Ruolo was successfully updated.' }\n format.json { render :show, status: :ok, location: @ruolo }\n else\n format.html { render :edit }\n format.json { render json: @ruolo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @retroalimentacion = Retroalimentacion.new(params[:retro])\n\n respond_to do |format|\n if @retroalimentacion.save\n format.html { redirect_to @retroalimentacion, notice: 'Retroalimentacion was successfully created.' }\n format.json { render json: @retroalimentacion, status: :created, location: @retroalimentacion }\n else\n format.html { render action: \"new\" }\n format.json { render json: @retroalimentacion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @anticipation.update(anticipation_params)\n format.html { redirect_to @anticipation, notice: 'Anticipation was successfully updated.' }\n format.json { render :show, status: :ok, location: @anticipation }\n else\n format.html { render :edit }\n format.json { render json: @anticipation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @antropo.update(antropo_params)\n format.html { redirect_to @antropo, notice: 'Antropo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @antropo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @razontiporesolucion = Razontiporesolucion.find(params[:id])\n\n respond_to do |format|\n if @razontiporesolucion.update_attributes(params[:razontiporesolucion])\n format.html { redirect_to(@razontiporesolucion, :notice => 'Razontiporesolucion was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @razontiporesolucion.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_api_v1_armor\n @armor = Armor.find(params[:id])\n end",
"def update\n\t\trespond_to do |format|\n\t\t\tif @alejandro.update(alejandro_params)\n\t\t\t\tformat.html { redirect_to alejandros_path, notice: 'Alejandro was successfully updated.' }\n\t\t\t\tformat.json { render :show, status: :ok, location: @alejandro }\n\t\t\telse\n\t\t\t\tformat.html { render :edit }\n\t\t\t\tformat.json { render json: @alejandro.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def update\n @imp2_raman = Imp2Raman.find(params[:id])\n\n respond_to do |format|\n if @imp2_raman.update_attributes(params[:imp2_raman])\n format.html { redirect_to @imp2_raman, notice: 'Imp2 raman was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @imp2_raman.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @mision = Mision.find(params[:id])\n\n respond_to do |format|\n if @mision.update_attributes(params[:mision])\n format.html { redirect_to @mision, notice: 'Mision was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @mision.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @rozmiar.update(rozmiar_params)\n format.html { redirect_to @rozmiar, notice: 'Rozmiar was successfully updated.' }\n format.json { render :show, status: :ok, location: @rozmiar }\n else\n format.html { render :edit }\n format.json { render json: @rozmiar.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @matriculacion.update(matriculacion_params)\n format.html { redirect_to @matriculacion, notice: 'Matriculacion was successfully updated.' }\n format.json { render :show, status: :ok, location: @matriculacion }\n else\n format.html { render :edit }\n format.json { render json: @matriculacion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @matriculacion.update(matriculacion_params)\n format.html { redirect_to @matriculacion, notice: 'Matriculacion was successfully updated.' }\n format.json { render :show, status: :ok, location: @matriculacion }\n else\n format.html { render :edit }\n format.json { render json: @matriculacion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @anuncio = current_user.anuncios.find(params[:id])\n\n\n respond_to do |format|\n if @anuncio.update(anuncio_params)\n format.html { redirect_to @anuncio, notice: 'Anuncio atualizado com sucesso.' }\n format.json { render :show, status: :ok, location: @anuncio }\n else\n format.html { render :edit }\n format.json { render json: @anuncio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @announcament.update(announcament_params)\n format.html { redirect_to @announcament, notice: 'Announcament was successfully updated.' }\n format.json { render :show, status: :ok, location: @announcament }\n else\n format.html { render :edit }\n format.json { render json: @announcament.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @repa = Repa.find(params[:id])\n\n respond_to do |format|\n if @repa.update_attributes(params[:repa])\n format.html { redirect_to @repa, notice: 'Repa was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @repa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @relatorio_pedagogicos = RelatorioPedagogico.all\n authorize @relatorio_pedagogicos\n\n respond_to do |format|\n if @relatorio_pedagogico.update(relatorio_pedagogico_params)\n format.html { redirect_to @relatorio_pedagogico, notice: 'Relatório pedagógico atualizado com sucesso!' }\n format.json { render :show, status: :ok, location: @relatorio_pedagogico }\n else\n format.html { render :edit }\n format.json { render json: @relatorio_pedagogico.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @arriendo.update(arriendo_params)\n format.html { redirect_to @arriendo, notice: 'Arriendo was successfully updated.' }\n format.json { render :show, status: :ok, location: @arriendo }\n else\n format.html { render :edit }\n format.json { render json: @arriendo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @resist.update(resist_params)\n format.html { redirect_to @resist, notice: 'Resist was successfully updated.' }\n format.json { render :show, status: :ok, location: @resist }\n else\n format.html { render :edit }\n format.json { render json: @resist.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @rua = Rua.find(params[:id])\n\n respond_to do |format|\n if @rua.update_attributes(params[:rua])\n format.html { redirect_to @rua, notice: 'Rua was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @rua.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @arcone = Arcone.find(params[:id])\n\n respond_to do |format|\n if @arcone.update_attributes(params[:arcone])\n format.html { redirect_to @arcone, notice: 'Arcone was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @arcone.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @administracao_rota.update(administracao_rota_params)\n format.html { redirect_to @administracao_rota, notice: 'Rota foi atualizado com sucesso.' }\n format.json { render :show, status: :ok, location: @administracao_rota }\n else\n format.html { render :edit }\n format.json { render json: @administracao_rota.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @relogio = Relogio.find(params[:id])\n\n respond_to do |format|\n if @relogio.update_attributes(params[:relogio])\n format.html { redirect_to @relogio, notice: 'Relogio was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @relogio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @principal_caracteristica.update(principal_caracteristica_params)\n format.html { redirect_to @principal_caracteristica, notice: 'Principal caracteristica was successfully updated.' }\n format.json { render :show, status: :ok, location: @principal_caracteristica }\n else\n format.html { render :edit }\n format.json { render json: @principal_caracteristica.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @restoration.update(restoration_params)\n format.html { redirect_to @restoration, notice: 'Restoration was successfully updated.' }\n format.json { render :show, status: :ok, location: @restoration }\n else\n format.html { render :edit }\n format.json { render json: @restoration.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @rotina.update(rotina_params)\n format.html { redirect_to rotinas_path, notice: 'Rotina atualizada com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @rotina.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @devotional.update(devotional_params)\n format.html { redirect_to @devotional, notice: 'Devotional was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @devotional.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @restricao.update(restricao_params)\n format.html { redirect_to @restricao, notice: 'Restrição foi Editada com Sucesso!' }\n format.json { render :show, status: :ok, location: @restricao }\n else\n format.html { render :edit }\n format.json { render json: @restricao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @matricula = Matricula.find(params[:id])\n\n respond_to do |format|\n if @matricula.update_attributes(matricula_params)\n format.html { redirect_to @matricula, notice: 'Matricula was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @matricula.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @taxon_name.update(taxon_name_params)\n\n # TODO: WHY?!\n @taxon_name.reload\n\n format.html { redirect_to url_for(@taxon_name.metamorphosize), notice: 'Taxon name was successfully updated.' }\n format.json { render :show, status: :ok, location: @taxon_name.metamorphosize }\n else\n format.html { render action: :edit }\n format.json { render json: @taxon_name.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @creator_accession_relationship = CreatorAccessionRelationship.find(params[:id])\n\n respond_to do |format|\n if @creator_accession_relationship.update_attributes(params[:creator_accession_relationship])\n format.html { redirect_to @creator_accession_relationship, notice: 'Creator accession relationship was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @creator_accession_relationship.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @accessory = Accessory.find(params[:id])\n\n if @accessory.update_attributes(params[:accessory])\n head :no_content\n else\n render json: @accessory.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @relcliruta.update(relcliruta_params)\n format.html { redirect_to @relcliruta, notice: 'Relcliruta was successfully updated.' }\n format.json { render :show, status: :ok, location: @relcliruta }\n else\n format.html { render :edit }\n format.json { render json: @relcliruta.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @predio.update(predio_params)\n format.html { redirect_to @predio, notice: 'Predio foi alterado com sucesso.' }\n format.json { render :show, status: :ok, location: @predio }\n else\n format.html { render :edit }\n format.json { render json: @predio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @representante.update(representante_params)\n format.html { redirect_to @representante, notice: 'Representante was successfully updated.' }\n format.json { render :show, status: :ok, location: @representante }\n else\n format.html { render :edit }\n format.json { render json: @representante.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @biometria.update(biometria_params)\n format.html { redirect_to index_biometria_path(params[:biometria][:paciente_id]), notice: 'Biometria se actualizo correctamente'}\n format.json { render :show, status: :ok, location: @biometria }\n else\n format.html { render :edit }\n format.json { render json: @biometria.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @recepe.update(recepe_params)\n format.html { redirect_to @recepe, notice: 'Recepe was successfully updated.' }\n format.json { render :show, status: :ok, location: @recepe }\n else\n format.html { render :edit }\n format.json { render json: @recepe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n photo_params = params[:photo].clone\n if photo_params[:retakeable]\n photo_params[:retakeable] = %(yes true 1).include?(photo_params[:retakeable].to_s.downcase)\n photo_params[:retakeable] = nil if params[:photo][:retakeable] == 'unknown'\n end\n if photo_params[:accessibility]\n photo_params[:accessibility] = nil if params[:photo][:accessibility] == 'unknown'\n end\n respond_to do |format|\n if @photo.update_attributes(photo_params)\n format.html { redirect_to @photo, notice: 'Photo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @rayons=Rayon.all\n \n @rayon.update_attributes(rayon_params)\n flash[:notice]=\"Modification éffectué avec succès!!!\"\n end",
"def update\n @articulo = Articulo.find(params[:id])\n\n respond_to do |format|\n if @articulo.update_attributes(params[:articulo])\n format.html { redirect_to @articulo, notice: 'Articulo se ha actualizado correctamente.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @articulo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @reparacion = Reparacion.find(params[:id])\n\n respond_to do |format|\n if @reparacion.update_attributes(params[:reparacion])\n format.html { redirect_to @reparacion, notice: 'Reparacion se ha actualizado correctamente.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @reparacion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @restora.update(restora_params)\n format.html { redirect_to @restora, notice: 'Restora was successfully updated.' }\n format.json { render :show, status: :ok, location: @restora }\n else\n format.html { render :edit }\n format.json { render json: @restora.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @animai.update(animai_params)\n format.html { redirect_to @animai, notice: 'Animai was successfully updated.' }\n format.json { render :show, status: :ok, location: @animai }\n else\n format.html { render :edit }\n format.json { render json: @animai.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @reltramovano = Reltramovano.find(params[:id])\n\n respond_to do |format|\n if @reltramovano.update_attributes(params[:reltramovano])\n format.html { redirect_to @reltramovano, notice: 'Reltramovano was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @reltramovano.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @regra_negocio.update(regra_negocio_params)\n format.html { redirect_to @regra_negocio, notice: 'Regra negocio was successfully updated.' }\n format.json { render :show, status: :ok, location: @regra_negocio }\n else\n format.html { render :edit }\n format.json { render json: @regra_negocio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @anuncio.update(anuncio_params)\n format.html { redirect_to @anuncio.street, notice: 'Anuncio was successfully updated.' }\n format.json { render :show, status: :ok, location: @anuncio }\n else\n format.html { render :edit }\n format.json { render json: @anuncio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @articulo = Articulo.find(params[:id])\n\n respond_to do |format|\n if @articulo.update_attributes(params[:articulo])\n format.html { redirect_to @articulo, notice: 'Articulo was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @articulo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @representative.update(representative_params)\n format.html { redirect_to admin_organization_path(@representative.organization,:locale => I18n.locale), notice: 'Representative was successfully updated.' }\n #format.json { head :no_content }\n else\n #format.html { render action: 'edit' }\n format.json { render json: @representative.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tipoapreensao.update(tipoapreensao_params)\n format.html { redirect_to @tipoapreensao, notice: 'Tipoapreensao was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @tipoapreensao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @plate = Plate.find(params[:id])\n\n if @plate.update(params[:plate])\n head :no_content\n else\n render json: @plate.errors, status: :unprocessable_entity\n end\n end",
"def update\n @reconocimiento = Reconocimiento.find(params[:id])\n\n respond_to do |format|\n if @reconocimiento.update_attributes(params[:reconocimiento])\n format.html { redirect_to @reconocimiento, :notice => 'Reconocimiento was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @reconocimiento.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @promotion = Promotion.find(promotion_params[:id])\n authorize @promotion\n if @promotion.update(promotion_params)\n render json: { status: :ok, promotion: @promotion }\n else\n render json: { errors: @promotion.errors, status: :unprocessable_entity }\n end\n end",
"def update\n @territorio = Territorio.find(params[:id])\n\n respond_to do |format|\n if @territorio.update_attributes(params[:territorio])\n format.html { redirect_to @territorio, notice: 'Territorio was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @territorio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @pregnancy.update(pregnancy_params)\n format.html { redirect_to @pregnancy, notice: 'Pregnancy was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @pregnancy.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\t\tauthorize! :update, DetalleRestriccion\n respond_to do |format|\n @concepto_gastos = ConceptoGasto.all\n if @detalle_restriccion.update(detalle_restriccion_params)\n format.html { redirect_to gestionar_restricciones_path, notice: 'Actualizado correctamente'}\n #format.html { redirect_to @detalle_restriccion, notice: 'Detalle restriccion fue actualizado satisfactoriamente.' }\n #format.json { render :show, status: :ok, location: @detalle_restriccion }\n else\n format.html { redirect_to gestionar_restricciones_path, alert: 'No pueden guardarse'}\n #format.html { render :edit }\n #format.json { render json: @detalle_restriccion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @male_shot_put_head.update(male_shot_put_head_params)\n format.html { redirect_to @male_shot_put_head, notice: 'Male shot put head was successfully updated.' }\n format.json { render :show, status: :ok, location: @male_shot_put_head }\n else\n format.html { render :edit }\n format.json { render json: @male_shot_put_head.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @reparticao.update(reparticao_params)\n format.html { redirect_to @reparticao, notice: 'Reparticao was successfully updated.' }\n format.json { render :show, status: :ok, location: @reparticao }\n else\n format.html { render :edit }\n format.json { render json: @reparticao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @mision_mision = MisionMision.find(params[:id])\n\n respond_to do |format|\n if @mision_mision.update_attributes(params[:mision_mision])\n format.html { redirect_to @mision_mision, notice: 'Mision mision was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @mision_mision.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @o_rganization.update(o_rganization_params)\n format.html { redirect_to @o_rganization, notice: 'O rganization was successfully updated.' }\n format.json { render :show, status: :ok, location: @o_rganization }\n else\n format.html { render :edit }\n format.json { render json: @o_rganization.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @imp_raman = ImpRaman.find(params[:id])\n\n respond_to do |format|\n if @imp_raman.update_attributes(params[:imp_raman])\n format.html { redirect_to @imp_raman, notice: 'Imp raman was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @imp_raman.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @anagrama.update(anagrama_params)\n format.html { redirect_to @anagrama, notice: 'Anagrama was successfully updated.' }\n format.json { render :show, status: :ok, location: @anagrama }\n else\n format.html { render :edit }\n format.json { render json: @anagrama.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @responsavel = Responsavel.find(params[:id])\n\n if @responsavel.update(responsavel_params)\n head :no_content\n else\n render json: @responsavel.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @rastreamento.update(rastreamento_params)\n format.html { redirect_to @rastreamento, notice: 'Rastreamento was successfully updated.' }\n format.json { render :show, status: :ok, location: @rastreamento }\n else\n format.html { render :edit }\n format.json { render json: @rastreamento.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @rastreamento.update(rastreamento_params)\n format.html { redirect_to @rastreamento, notice: 'Rastreamento was successfully updated.' }\n format.json { render :show, status: :ok, location: @rastreamento }\n else\n format.html { render :edit }\n format.json { render json: @rastreamento.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @manga = Manga.find(params[:id])\n\n respond_to do |format|\n if @manga.update_attributes(params[:manga])\n format.html { redirect_to @manga, notice: 'Manga was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @manga.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.6416364",
"0.6220023",
"0.59691745",
"0.59603894",
"0.595329",
"0.5953134",
"0.59020674",
"0.5901316",
"0.5894188",
"0.58929896",
"0.5867177",
"0.5837815",
"0.58215815",
"0.57805514",
"0.5778164",
"0.57765055",
"0.57553095",
"0.57390594",
"0.5736952",
"0.57358456",
"0.5731925",
"0.5724065",
"0.5717776",
"0.5716331",
"0.57160175",
"0.5708085",
"0.5706746",
"0.57026166",
"0.5697397",
"0.5682736",
"0.568072",
"0.5680034",
"0.5668977",
"0.566805",
"0.56665856",
"0.5660119",
"0.5657114",
"0.56563586",
"0.565588",
"0.56549335",
"0.5642358",
"0.56330144",
"0.563172",
"0.56267065",
"0.56241876",
"0.5623329",
"0.562108",
"0.562108",
"0.5613262",
"0.55999404",
"0.55995196",
"0.5593645",
"0.55900717",
"0.5589416",
"0.55810523",
"0.5577911",
"0.55721325",
"0.5569187",
"0.5561965",
"0.55617195",
"0.55603164",
"0.5552864",
"0.55494845",
"0.55493337",
"0.5549108",
"0.55486387",
"0.5542175",
"0.5537896",
"0.55363655",
"0.5533546",
"0.55328757",
"0.55313766",
"0.55281216",
"0.5525321",
"0.5524768",
"0.5523892",
"0.55229455",
"0.55226946",
"0.5520134",
"0.5518814",
"0.55123305",
"0.5511908",
"0.55114126",
"0.5506007",
"0.55013996",
"0.5499159",
"0.5497425",
"0.5497393",
"0.5496694",
"0.5496543",
"0.54958546",
"0.5495269",
"0.54893124",
"0.54888445",
"0.54885155",
"0.54883665",
"0.5487346",
"0.5486809",
"0.5486809",
"0.54864866"
] | 0.66322505 | 0 |
DELETE /retroalimentacions/1 DELETE /retroalimentacions/1.json | def destroy
@retroalimentacion = Retroalimentacion.find(params[:id])
@retroalimentacion.destroy
respond_to do |format|
format.html { redirect_to retroalimentacions_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @retroaspecto = Retroaspecto.find(params[:id])\n @retroaspecto.destroy\n\n respond_to do |format|\n format.html { redirect_to retroaspectos_url }\n format.json { head :no_content }\n end\n end",
"def delete\n render json: Alien.delete(params[\"id\"])\n end",
"def destroy\n @retro = Retro.find(params[:id])\n @retro.destroy\n\n respond_to do |format|\n format.html { redirect_to retros_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @asignatura.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @remito = Remito.find(params[:id])\n @remito.destroy\n\n respond_to do |format|\n format.html { redirect_to remitos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @remedio = Remedio.find(params[:id])\n @remedio.destroy\n\n respond_to do |format|\n format.html { redirect_to remedios_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @agronomiaquimica = Agronomiaquimica.find(params[:id])\n @agronomiaquimica.destroy\n\n respond_to do |format|\n format.html { redirect_to agronomiaquimicas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @relogio = Relogio.find(params[:id])\n @relogio.destroy\n\n respond_to do |format|\n format.html { redirect_to relogios_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @respuesta = Respuesta.find(params[:id])\n @respuesta.destroy\n\n respond_to do |format|\n format.html { redirect_to respuestas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ramal = Ramal.find(params[:id])\n @ramal.destroy\n\n respond_to do |format|\n format.html { redirect_to ramais_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @humanidades1 = Humanidades1.find(params[:id])\n @humanidades1.destroy\n\n respond_to do |format|\n format.html { redirect_to humanidades1s_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @repuestum = Repuestum.find(params[:id])\n @repuestum.destroy\n\n respond_to do |format|\n format.html { redirect_to repuesta_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @immigrant = Immigrant.find(params[:id])\n @immigrant.destroy\n\n respond_to do |format|\n format.html { redirect_to immigrants_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @analise.destroy\n respond_to do |format|\n format.html { redirect_to analises_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @aucrecord.destroy\n respond_to do |format|\n format.html { redirect_to aucrecords_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @miscellaneou.destroy\n respond_to do |format|\n format.html { redirect_to miscellaneous_url, notice: 'Accessory was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\r\n @sivic_relatorioscelula.destroy\r\n respond_to do |format|\r\n format.html { redirect_to sivic_relatorioscelulas_url }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @reconocimiento = Reconocimiento.find(params[:id])\n @reconocimiento.destroy\n\n respond_to do |format|\n format.html { redirect_to reconocimientos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @exura = Exura.find(params[:id])\n @exura.destroy\n\n respond_to do |format|\n format.html { redirect_to exuras_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @antropo.destroy\n respond_to do |format|\n format.html { redirect_to antropos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @mision = Mision.find(params[:id])\n @mision.destroy\n\n respond_to do |format|\n format.html { redirect_to misions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @relatorio.destroy\n respond_to do |format|\n format.html { redirect_to relatorios_url, notice: 'Relatorio was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @asignatura = Asignatura.find(params[:id])\n @asignatura.destroy\n\n respond_to do |format|\n format.html { redirect_to asignaturas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @asignatura = Asignatura.find(params[:id])\n @asignatura.destroy\n\n respond_to do |format|\n format.html { redirect_to asignaturas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @repa = Repa.find(params[:id])\n @repa.destroy\n\n respond_to do |format|\n format.html { redirect_to repas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @repa = Repa.find(params[:id])\n @repa.destroy\n\n respond_to do |format|\n format.html { redirect_to repas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @representative.destroy\n respond_to do |format|\n format.html { redirect_to [:admin, :representatives], notice: 'Representative was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @aliexpress = Aliexpress.find(params[:id])\n @aliexpress.destroy\n\n respond_to do |format|\n format.html { redirect_to aliexpresses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @respuesta = Respuesta.find(params[:id])\n @respuesta.destroy\n\n head :no_content\n end",
"def destroy\n @pharmacy.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @humanidades3 = Humanidades3.find(params[:id])\n @humanidades3.destroy\n\n respond_to do |format|\n format.html { redirect_to humanidades3s_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @background_annoncment.destroy\n respond_to do |format|\n format.html { redirect_to background_annoncments_url }\n format.json { head :no_content }\n end\n end",
"def destroy\r\n @relatorio.destroy\r\n respond_to do |format|\r\n format.html { redirect_to relatorios_url, notice: 'Relatório excluído com sucesso.' }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @uchronia = Uchronia.find(params[:id])\n @uchronia.destroy\n\n respond_to do |format|\n format.html { redirect_to uchronias_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @resturant.destroy\n respond_to do |format|\n format.html { redirect_to resturants_url, notice: 'Resturant was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @arcone = Arcone.find(params[:id])\n @arcone.destroy\n\n respond_to do |format|\n format.html { redirect_to arcones_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @rayon = Rayon.find(params[:id])\n @rayon.destroy\n\n respond_to do |format|\n format.html { redirect_to rayons_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recaudacion.destroy\n respond_to do |format|\n format.html { redirect_to recaudacions_url, notice: 'Recaudacion was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @humanidades2 = Humanidades2.find(params[:id])\n @humanidades2.destroy\n\n respond_to do |format|\n format.html { redirect_to humanidades2s_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @autore = Autore.find(params[:id])\n @autore.destroy\n\n respond_to do |format|\n format.html { redirect_to autores_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @aliquotum = Aliquotum.find(params[:id])\n @aliquotum.destroy\n\n respond_to do |format|\n format.html { redirect_to aliquota_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @asignacion_familiar.destroy\n respond_to do |format|\n format.html { redirect_to asignacion_familiars_url, notice: 'Asignacion familiar eliminada exitosamente.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @percentual_gordura.destroy\n respond_to do |format|\n format.html { redirect_to percentual_gorduras_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ruta.destroy\n respond_to do |format|\n format.html { redirect_to rutas_url, notice: 'Ruta was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @restaturant.destroy\n respond_to do |format|\n format.html { redirect_to restaturants_url, notice: \"Restaturant was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @prueba_json.destroy\n respond_to do |format|\n format.html { redirect_to prueba_jsons_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @nominee.destroy\n respond_to do |format|\n format.html { redirect_to nominees_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @malarium.destroy\n respond_to do |format|\n format.html { redirect_to malaria_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @relatorios = Relatorio.find(params[:id])\n @relatorios.destroy\n\n respond_to do |format|\n format.html { redirect_to(homes_path) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @astronomium.destroy\n respond_to do |format|\n format.html { redirect_to astronomia_url, notice: 'Astronomium was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n \n @lancamentorapido = Lancamentorapido.find(params[:id])\n @lancamentorapido.destroy \n\n respond_to do |format|\n format.html { redirect_to lancamentorapidos_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n [email protected]_id\n @familia.destroy\n respond_to do |format|\n format.html { redirect_to familias_url(:id => padre) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @manga = Manga.find(params[:id])\n @manga.destroy\n\n respond_to do |format|\n format.html { redirect_to mangas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @uginuce.sheep.update status:'na farmi'\n @uginuce.destroy\n respond_to do |format|\n format.html { redirect_to uginuces_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @repondre.destroy\n respond_to do |format|\n format.html { redirect_to repondres_url, notice: 'Repondre was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @creative.destroy\n respond_to do |format|\n format.html { redirect_to creatives_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @regraponto.destroy\n respond_to do |format|\n format.html { redirect_to regrapontos_url, notice: 'Regraponto was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @adopcion.destroy\n respond_to do |format|\n format.html { redirect_to adopcions_url, notice: 'Adopcion Eliminada.' }\n format.json { head :no_content }\n end\n end",
"def destroy\r\n @imobiliaria = Imobiliaria.find(params[:id])\r\n @imobiliaria.destroy\r\n\r\n respond_to do |format|\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @apologetic.destroy\n respond_to do |format|\n format.html { redirect_to apologetics_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @asteroid.destroy\n respond_to do |format|\n format.html { redirect_to asteroids_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @immunization.destroy\n respond_to do |format|\n format.html { redirect_to immunizations_url, notice: 'Immunization was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @status_animal = StatusAnimal.find(params[:id])\n @status_animal.destroy\n\n respond_to do |format|\n format.html { redirect_to status_animais_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @biometria.destroy\n respond_to do |format|\n format.html { redirect_to index_biometria_path(params[:paciente_id]), notice: 'Biometria elimino correctamente.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @areco = Areco.find(params[:id])\n @areco.destroy\n\n respond_to do |format|\n format.html { redirect_to arecos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @resto.destroy\n respond_to do |format|\n format.html { redirect_to restos_url, notice: 'Entry was deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @reprogramacion = Reprogramacion.find(params[:id])\n @reprogramacion.destroy\n\n respond_to do |format|\n format.html { redirect_to reprogramaciones_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @relatory.destroy\n respond_to do |format|\n format.html { redirect_to relatories_url, notice: 'Relatório deletado.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recharge.destroy\n respond_to do |format|\n format.html { redirect_to recharges_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @aactio = Aactio.find(params[:id])\n @aactio.destroy\n\n respond_to do |format|\n format.html { redirect_to aactios_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trein_consul_comercial.destroy\n respond_to do |format|\n format.html { redirect_to trein_consul_comercials_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @razmer_go = RazmerGo.find(params[:id])\n @razmer_go.destroy\n\n respond_to do |format|\n format.html { redirect_to razmer_gos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recla.destroy\n respond_to do |format|\n format.html { redirect_to reclas_url, notice: 'Recla was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @natulang = Natulang.find(params[:id])\n @natulang.destroy\n\n respond_to do |format|\n format.html { redirect_to natulangs_url }\n format.json { head :no_content }\n end\n \n end",
"def destroy\n @rotina.destroy\n respond_to do |format|\n format.html { redirect_to rotinas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @personaje_mision = PersonajeMision.find(params[:id])\n @personaje_mision.destroy\n\n respond_to do |format|\n format.html { redirect_to personaje_misions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @alejandro.destroy\n respond_to do |format|\n format.html { redirect_to alejandros_url, notice: 'Alejandro was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @kota_stone.destroy\n respond_to do |format|\n format.html { redirect_to kota_stones_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @reparacion.destroy\n respond_to do |format|\n format.html { redirect_to reparacions_url, notice: 'Reparacion was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @receita_medica = ReceitaMedica.find(params[:id])\n @receita_medica.destroy\n\n respond_to do |format|\n format.html { redirect_to receita_medicas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @adotando_animal = AdotandoAnimal.find(params[:id])\n @adotando_animal.destroy\n\n respond_to do |format|\n format.html { redirect_to adotando_animais_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ocorrencia.destroy\n respond_to do |format|\n format.html { redirect_to ocorrencias_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @agencium.destroy\n respond_to do |format|\n format.html { redirect_to agencia_url, notice: 'Agencium was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gran_unidad.destroy\n respond_to do |format|\n format.html { redirect_to gran_unidad_index_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admintreatmentfumigation.destroy\n respond_to do |format|\n format.html { redirect_to admintreatmentfumigations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @persona = Persona.find(params[:id])\n @persona.destroy\n\n respond_to do |format|\n format.json { head :ok }\n end\n \n end",
"def destroy\n @rescate.destroy\n respond_to do |format|\n format.html { redirect_to rescates_url, notice: 'Rescate fue eleminado' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @personal_rubro.destroy\n respond_to do |format|\n format.html { redirect_to personal_rubros_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @nudge.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @adocao_animal = AdocaoAnimal.find(params[:id])\n @adocao_animal.destroy\n\n respond_to do |format|\n format.html { redirect_to adocao_animals_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @normal.destroy\n respond_to do |format|\n format.html { redirect_to normals_url, notice: '과목 정보가 삭제되었습니다.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @realiza = Realiza.find(params[:id])\n @realiza.destroy\n\n respond_to do |format|\n format.html { redirect_to realizas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\r\n @sivic_rede.destroy\r\n respond_to do |format|\r\n format.html { redirect_to sivic_redes_url }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @orphan.destroy\n respond_to do |format|\n format.html { redirect_to orphans_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gonullu.destroy\n respond_to do |format|\n format.html { redirect_to gonullus_url, notice: 'Gonullu was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @representante_athlete = Representante::Athlete.find(params[:id])\n @representante_athlete.destroy\n\n respond_to do |format|\n format.html { redirect_to representante_athletes_url, notice: 'Atleta apagado com sucesso' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @apuesta_detail = ApuestaDetail.find(params[:id])\n @apuesta_detail.destroy\n\n respond_to do |format|\n format.html { redirect_to apuesta_details_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @redacao.destroy\n respond_to do |format|\n format.html { redirect_to redacaos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @affectation = Affectation.find(params[:id])\n @affectation.destroy\n\n respond_to do |format|\n format.html { redirect_to affectations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @one = One.find(params[:id])\n @one.destroy\n\n respond_to do |format|\n format.html { redirect_to ones_url }\n format.json { head :no_content }\n end\n end"
] | [
"0.7318092",
"0.7162978",
"0.7092663",
"0.7020363",
"0.7011858",
"0.70032704",
"0.6999551",
"0.6970893",
"0.69674957",
"0.69631535",
"0.69290596",
"0.69252896",
"0.6907412",
"0.69073576",
"0.6880774",
"0.68772125",
"0.6858631",
"0.6852518",
"0.6811732",
"0.6806073",
"0.6801634",
"0.6801345",
"0.68008834",
"0.68008834",
"0.67983377",
"0.67983377",
"0.6798189",
"0.67943245",
"0.67829466",
"0.6781552",
"0.6780062",
"0.677368",
"0.6768788",
"0.6762521",
"0.67436886",
"0.6743324",
"0.6742536",
"0.6741439",
"0.67336655",
"0.672879",
"0.6728411",
"0.6724431",
"0.6721517",
"0.6710661",
"0.67062193",
"0.6703101",
"0.6702173",
"0.6701397",
"0.6701087",
"0.670084",
"0.6699781",
"0.6695138",
"0.66890115",
"0.66889703",
"0.66872513",
"0.66843075",
"0.6683377",
"0.6683012",
"0.66815174",
"0.6679984",
"0.6679543",
"0.6679502",
"0.6678185",
"0.6676717",
"0.66749644",
"0.6672677",
"0.66726196",
"0.6672342",
"0.6670932",
"0.6669316",
"0.6667296",
"0.6666408",
"0.66575736",
"0.665691",
"0.66562927",
"0.6655347",
"0.665503",
"0.66536206",
"0.66525185",
"0.6651335",
"0.66499436",
"0.66496485",
"0.6649594",
"0.6648318",
"0.6648241",
"0.6645605",
"0.6641657",
"0.66412354",
"0.6640693",
"0.6640683",
"0.66394496",
"0.66382134",
"0.66348404",
"0.663425",
"0.66320807",
"0.6630385",
"0.66293055",
"0.6629206",
"0.6628909",
"0.66284674"
] | 0.7735287 | 0 |
Decodes Base64 encoded inline string image. ==== Parameters +contents+ String, Base64 decoded inline image containing header: data:image/png;base64,... | def initialize(contents)
self.content_type, self.encoded_file = contents.split(';', 2)
raise UnsupportedFormat unless valid_extension?
super(Base64.decode64(encoded_file))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def decode_base64_string(filename, data)\n\n decoded_image = Base64.decode64(data)\n\nend",
"def decode_base64_string(filename, data)\n\n decoded_image = Base64.decode64(data)\n\nend",
"def decode_image(data)\r\n\r\n data_index = data.index('base64') + 7\r\n filedata = data.slice(data_index, data.length)\r\n decoded_image = Base64.decode64(filedata)\r\n\r\n end",
"def encoded_contents(image_path)\n Base64.encode64(File.read(image_path)).gsub(/\\n/, '')\n end",
"def decode_base64\n #self.unpack(\"m*\").first\n # This should be the above line but due to a bug in the ruby base64 decoder\n # it will only decode base64 where the lines are in multiples of 4, this is\n # contrary to RFC2045 which says that all characters other than the 65 used\n # are to be ignored. Currently we remove all the other characters but it \n # might be better to use it's advice to only remove line breaks and white\n # space\n self.tr(\"^A-Za-z0-9+/=\", \"\").unpack(\"m*\").first\n end",
"def decode_base64_image\n if self.image_data && self.content_type && self.original_filename\n # decoded_data = Base64.decode64(self.image_data)\n\n data = StringIO.new(image_data)\n data.class_eval do\n attr_accessor :content_type, :original_filename\n end\n\n data.content_type = self.content_type\n data.original_filename = File.basename(self.original_filename)\n\n self.avatar = data\n end\n end",
"def decode(string)\n Base64.decode64(string)\n end",
"def decode_image(filename, data)\n\n data_index = data.index('base64') + 7\n filedata = data.slice(data_index, data.length)\n decoded_image = Base64.decode64(filedata)\n\n end",
"def get_base64_image(image)\n image_base64 = Base64.encode64(open(image) { |io| io.read })\n filter_image = image_base64.gsub(/\\r/,\"\").gsub(/\\n/,\"\")\n end",
"def format_base64_images(text, id)\n\n matchString = /src=\"data:image\\/(\\w+?);base64,(.*?)\"/\n matches = text.scan(matchString)\n matches.each_with_index do |(mimetype, b64), ix|\n\n unless b64.nil?\n filename = 'post' + id.to_s + '-' + ix.to_s + '.' + mimetype\n fullfilespec = \"#{Rails.public_path}/#{filename}\"\n File.open(fullfilespec, 'wb') do |f|\n f.write(Base64.decode64(b64))\n end\n text.sub!(matchString, \"src='#{filename}'\")\n end\n\n end\n text\n end",
"def decode(value)\n Base64.decode64 value\n end",
"def base64_decode(string)\n SSL.base64_decode(string)\n end",
"def base64_decode(string)\n SSL.base64_decode(string)\n end",
"def decode(b)\n Base64.decode64(b)\n end",
"def decoded\n Base64.decode64(@base64 || \"\")\n end",
"def decode_blob blob\n if not String === blob\n raise ArgumentError, 'Blob should be a string'\n end\n\n if blob[0, 4] != 'TFBB'\n raise ArgumentError, 'Blob doesn\\'t seem to be base64 encoded'\n end\n\n decode_base64 blob\n end",
"def decode(base64)\n base64.to_s.unpack(\"m\").first\n end",
"def base64_decode\n unpack('m').first\n end",
"def decode64\n Base64.strict_decode64(unwrap)\n end",
"def decode_bytes(encoded_bytes)\n Base64.urlsafe_decode64(encoded_bytes)\n end",
"def inline_image_src(content_type, data)\n #base64_data = escape_javascript(Base64.encode64(data))\n base64_data = Base64.encode64(data)\n return \"data:#{content_type};base64,#{base64_data}\"\n end",
"def strict_decode64(str)\n return Base64.strict_decode64(str) if Base64.respond_to? :strict_decode64\n\n unless str.include?(\"\\n\")\n Base64.decode64(str)\n else\n raise(ArgumentError,\"invalid base64\")\n end\n end",
"def decode_base64!\n self.replace(self.decode_base64)\n end",
"def from_base64\n unpack(\"m\").first\n end",
"def decode_body(body)\n body += '=' * (4 - body.length.modulo(4))\n Base64.decode64(body.tr('-_','+/'))\n end",
"def encode64( png )\n return Base64.encode64(png)\n end",
"def base64_url_decode(str)\n \"#{str}==\".tr(\"-_\", \"+/\").unpack(\"m\")[0]\n end",
"def decode_attachments\n self[\"_attachments\"].each do |attachment_id, attachment_properties|\n self[\"_attachments\"][attachment_id][\"data\"] = Base64.decode64 attachment_properties[\"data\"] if attachment_properties[\"data\"] \n end if self[\"_attachments\"]\n end",
"def edit_text_base64_decode(request, opts = {})\n data, _status_code, _headers = edit_text_base64_decode_with_http_info(request, opts)\n data\n end",
"def strict_decode64( str )\n \n if RUBY_VERSION >= \"1.9\"\n Base64.strict_decode64( str )\n else\n Base64.decode64( str )\n end\nend",
"def impexify_content(content)\n content = content.gsub(' \"', '\"').gsub('\"', '\"\"').gsub(/\\n/, '')\n content.force_encoding('ASCII-8BIT')\n end",
"def base64_url_decode(str)\n str += '=' * (4 - str.length.modulo(4))\n Base64.decode64(str.tr('-_', '+/'))\n end",
"def split_base64(uri_str)\n if uri_str.match(%r{^data:(.*?);(.*?),(.*)$})\n uri = Hash.new\n uri[:type] = $1 # \"image/gif\"\n uri[:encoder] = $2 # \"base64\"\n uri[:data] = $3 # data string\n uri[:extension] = $1.split('/')[1] # \"gif\"\n return uri\n else\n return nil\n end\n end",
"def decrypt(base64_string)\r\n encrypted = Base64.decode64(base64_string)\r\n aes = decipher\r\n aes.update(encrypted) + aes.final\r\n end",
"def split_base64(uri_str)\n\t\t if uri_str.match(%r{^data:(.*?);(.*?),(.*)$})\n\t\t uri = Hash.new\n\t\t uri[:type] = $1 # \"image/gif\"\n\t\t uri[:encoder] = $2 # \"base64\"\n\t\t uri[:data] = $3 # data string\n\t\t uri[:extension] = $1.split('/')[1] # \"gif\"\n\t\t return uri\n\t\t else\n\t\t return nil\n\t\t end\n end",
"def image_url_to_base64(url)\n\n img = open(url,{ssl_verify_mode: 0})\n Base64.encode64(img.read)\n\nend",
"def image_url_to_base64(url)\n\n img = open(url,{ssl_verify_mode: 0})\n Base64.encode64(img.read)\n\nend",
"def img_encode_base64(data)\n content_type = data.content_type.split('/')\n return nil unless content_type[0] == 'image' &&\n ['jpeg', 'png', 'gif'].include?(content_type[1])\n\n \"data:image/#{content_type[1]};base64, #{Base64.encode64(data.read)}\"\n end",
"def decode(bytes)\n decode_from(::StringIO.new(bytes))\n end",
"def avatarise(avatar)\n if avatar.respond_to? :read\n \"data:image/jpg;base64,#{Base64.strict_encode64(avatar.read)}\"\n else\n avatar\n end\n end",
"def decode_aes256_cbc_base64 data\n if data.empty?\n ''\n else\n # TODO: Check for input validity!\n _decode_aes256 :cbc, decode_base64(data[1, 24]), decode_base64(data[26..-1])\n end\n end",
"def split_base64(uri_str)\n if uri_str.match(%r{^data:(.*?);(.*?),(.*)$})\n uri = Hash.new\n uri[:type] = $1 # \"image/gif\"\n uri[:encoder] = $2 # \"base64\"\n uri[:data] = $3 # data string\n uri[:extension] = $1.split('/')[1] # \"gif\"\n return uri\n else\n return nil\n end\n end",
"def decode_from_ui(value)\n Site::UploadUtils.uploadSingleFile value[0], Base64.decode64(value[1]) if value[1]\n value[0]\n end",
"def split_base64(uri_str)\n if uri_str.match(%r{^data:(.*?);(.*?),(.*)$})\n uri = Hash.new\n uri[:type] = $1 # \"image/gif\"\n uri[:encoder] = $2 # \"base64\"\n uri[:data] = $3 # data string\n uri[:extension] = $1.split('/')[1] # \"gif\"\n return uri\n else\n return nil\n end\nend",
"def decode64_url(str)\n # add '=' padding\n str = case str.length % 4\n when 2 then str + '=='\n when 3 then str + '='\n else\n str\n end\n\n Base64.decode64(str.tr('-_', '+/'))\nend",
"def with_data_uris(css)\n css.gsub(IMAGE_REPLACER) do |url|\n \"url(\\\"data:#{mime_type($1)};base64,#{encoded_contents($1)}\\\")\"\n end\n end",
"def decode_and_parse_json(string)\n JSON.parse(string)\nrescue\n JSON.parse(Base64.decode64(string))\nend",
"def decode_params_base64(s)\n parsed = CGI.parse(Base64.decode64(\"#{s}==\"))\n params = Hash[*parsed.entries.map { |k, v| [k, v[0]] }.flatten]\n params.with_indifferent_access\n end",
"def sanitize_base64_string(base64_string)\n array_string = base64_string.split('//')\n array_string[-1] = array_string[-1].gsub('\\\\', '')\n array_string.join('//')\n end",
"def decrypt64(str)\n dec = ''\n str = Base64.decode64(str)\n while str.length != 0\n dec += self.private_decrypt(str[0..self.decrypt_block_size])\n str = str[self.decrypt_block_size+1..-1] if str.length > self.decrypt_block_size\n end\n dec\n end",
"def decode_attribute(attribute)\n ActiveSupport::Base64.decode64(attribute)\n end",
"def decode_data(encoded_data)\n\n # Decode the data\n data = Base64.decode64(encoded_data)\n\n # Eliminate extemporaneous chars outside the JSON\n data = data.match(/\\{.*\\}/)[0]\n\n # Parse with JSON\n data = JSON.parse(data)\n\n end",
"def main_image_with_base64=(data)\n image = data\n\n if data.is_a?(String) && data.include?(\"data:image\")\n parts = data.split(',')\n\n meta = parts.first\n content_type = meta.split(';').first.gsub!('data:', '')\n extension = content_type.split('/').last\n extension = (extension == 'jpeg') ? 'jpg' : extension\n\n image = Paperclip.io_adapters.for(data)\n\n image.content_type = content_type\n image.original_filename = [rand(10_000), extension].join('.')\n \n end\n\n self.main_image_without_base64 = image\n end",
"def b64encode_it(contents = nil)\r\n\t\t\tunless contents.nil?\r\n\t\t\t\tx = Base64.encode64(contents)\r\n\t\t\t\treturn x\r\n\t\t\tend\r\n\t\tend",
"def base64\n binary = open { |io| io.read }\n result = Base64.encode64(binary).chomp\n binary.clear # deallocate string\n result\n end",
"def decipher_base64(value_base64, key)\n if blank(value_base64)\n return nil\n else\n cipher_text = Base64.decode64(value_base64)\n return decipher(cipher_text, key)\n end\nend",
"def base64(stuff)\n Base64.encode64(stuff).delete(\"\\n\")\n end",
"def logo_base_64\n 'data:image/png;base64, ' + Base64.encode64(File.open(\"#{Rails.root}/app/assets/images/logo_orgao.png\", 'rb').read).to_s\n end",
"def base64_encode\n Base64.encode64(file_contents)\n end",
"def parse(params)\n Marshal.load(Base64.decode64(params))\n end",
"def mime_decode(str, charset = \"UTF-8\")\n decstr = \"\"\n items = str.split(/\\s/).collect{|c| c.strip}\n items.each_with_index do |item, i|\n if item.empty?\n decstr += \" \"\n next\n end\n decstr += \" \" unless decstr.empty?\n mis = item.scan(/^=\\?(UTF-8|utf-8)\\?(B|b)\\?(.+)\\?=$/).flatten\n if mis.empty?\n decstr += item\n else\n decstr += Base64.decode64(mis[-1])\n end\n end\n return msg_decode(decstr, charset)\n end",
"def decode_image_data(img_data,fname)\n cid = URI.unescape(img_data)\n filename = fname\n file = File.open(\"#{Rails.root.to_s}/public/tmp/#{filename}.jpg\",\"wb\")\n temp2 = ActiveSupport::Base64.decode64(cid)\n file.write(temp2)\n file.close\n f = File.open(\"#{Rails.root.to_s}/public/tmp/#{filename}.jpg\")\n self.avatar = f\n f.close\n File.delete(\"#{Rails.root.to_s}/public/tmp/#{filename}.jpg\")\n end",
"def base64\n content = storage.read(id)\n base64 = Base64.encode64(content)\n base64.chomp\n end",
"def qr_code_png\n data.qr_code_png\n end",
"def encoded_contents(asset_path)\n data = open(asset_path, 'rb'){|f| f.read }\n Base64.encode64(data).gsub(/\\n/, '')\n end",
"def base64_encoded?(string)\n !!string.gsub(/[\\r\\n]|\\\\r|\\\\n/, \"\").match(BASE64_FORMAT)\n end",
"def base64_encoded?(string)\n !!string.gsub(/[\\r\\n]|\\\\r|\\\\n/, \"\").match(BASE64_FORMAT)\n end",
"def urlsafe_decode64(str)\n strict_decode64(str.tr(\"-_\", \"+/\"))\n end",
"def body\n Base64::decode64(self[:body])\n end",
"def data; Marshal.load(Base64.decode64(read_attribute(:data))); end",
"def decode_string(str)\n\nend",
"def safe_string(str)\n b64str = Base64.strict_encode64(str)\n \"echo #{b64str} | base64 --decode\"\n end",
"def mobile_image_with_base64=(data)\n image = data\n\n if data.is_a?(String) && data.include?(\"data:image\")\n parts = data.split(',')\n\n meta = parts.first\n content_type = meta.split(';').first.gsub!('data:', '')\n extension = content_type.split('/').last\n extension = (extension == 'jpeg') ? 'jpg' : extension\n\n image = Paperclip.io_adapters.for(data)\n\n image.content_type = content_type\n image.original_filename = [rand(10_000), extension].join('.')\n \n end\n\n self.mobile_image_without_base64 = image\n end",
"def decode64(str)\n str.unpack(\"m\")[0]\n end",
"def inline_image(element)\n invalid = [\"span\",{\"class\"=>\"red\"},\"invalid image\"]\n return invalid unless element.attr.has_key? 'src'\n return invalid unless element.attr['src'].start_with? \"data:image/png;base64,\"\n return [\"img\",{\"src\"=>element.attr['src']}]\nend",
"def encoded_picture\n \"data:image/#{self.extension};base64,#{File.open('public/images/' + self.picture,'rb').read}\"\n end",
"def urlsafe_decode642(str)\n # NOTE: RFC 4648 does say nothing about unpadded input, but says that\n # \"the excess pad characters MAY also be ignored\", so it is inferred that\n # unpadded input is also acceptable.\n str = str.tr(\"-_\", \"+/\")\n if !str.end_with?(\"=\") && str.length % 4 != 0\n str = str.ljust((str.length + 3) & ~3, \"=\")\n end\n Base64.strict_decode64(str)\nend",
"def decode(text); end",
"def edit_text_base64_detect(request, opts = {})\n data, _status_code, _headers = edit_text_base64_detect_with_http_info(request, opts)\n data\n end",
"def blob_to_base64 (photo)\n\t\t#Convierte de formato '/xFF' a Base64 para poder mostrar la foto en la vista\n\t\treturn \"data:image/jpeg;base64,\" + [photo].pack('m0')\n\tend",
"def u64(s)\n return unless s\n Base64.decode64 CGI.unescape(s)\n end",
"def test_hat\n assert_equal MyBase64.decode64(\"aGF0\"), \"hat\"\n end",
"def decode\n @decode ||= Multihashes.decode([content_addressable].pack('H*'))\n end",
"def meta_decode(meta)\n return {} if meta.empty?\n Marshal.load(Base64.decode64(meta))\n end",
"def qr\n require 'rqrcode'\n str = params[:str] || \"\"\n\n qr = RQRCode::QRCode.new(str)\n\n qr_img_stream = qr.as_png(\n border_modules: 2,\n color: \"24292e\"\n ).to_s\n\n send_data(qr_img_stream, type: 'image/png', disposition: 'inline')\n end",
"def parse_64(edata)\n return nil if @eject\n to_parse = ''\n \n # Check every single F'ing character. God, MIME is slow.\n edata.each_byte do |i| i = i.chr\n if MIME_CHARS.include?(i)\n @mime_block << i\n if @mime_block.length == 4\n to_parse << de_mime(@mime_block)\n @mime_block = ''\n end\n end\n end # of each_byte\n\n # Hand the decoded data to the parser\n parse(to_parse) unless to_parse.empty?\n end",
"def b64_e(data)\n Base64.encode64(data).chomp\n end",
"def decode64(str)\n str.unpack(\"m\").first\n end",
"def decode(data)\n case @encoding\n when nil, :none, :raw\n data\n when :base64\n Base64.decode64(data)\n else\n raise Cryptic::UnsupportedEncoding, @encoding\n end\n end",
"def data_uri(image)\n mime_type = image.svg? ? 'image/svg+xml' : image.mime_type\n \"'data:#{mime_type};base64,#{Base64.encode64(image.blob).gsub(/\\r?\\n/, '')}'\"\n end",
"def wicked_pdf_url_base64(url); end",
"def ebsin_decode(data, key)\n rc4 = RubyRc4.new(key)\n (Hash[ rc4.encrypt(Base64.decode64(data.gsub(/ /,'+'))).split('&').map { |x| x.split(\"=\") } ]).slice(* NECESSARY )\n end",
"def ebsin_decode(data, key)\n rc4 = RubyRc4.new(key)\n (Hash[ rc4.encrypt(Base64.decode64(data.gsub(/ /,'+'))).split('&').map { |x| x.split(\"=\") } ]).slice(* NECESSARY )\n end",
"def image\n Pathname.new(\"#{PATH}#{self.path}\").open{|file|\n return Base64.strict_encode64(file.read)\n }\n end",
"def read_content(repo, ref, file)\n Base64.decode64(connection.contents(\"#{organization}/#{repo}\", path: file, ref: ref).content)\n end",
"def ascii_bitmap_to_byte_array(str)\n rows = str.split.map(&:strip)\n dimensions = [rows.first.length, rows.length]\n pixel_stream = rows.join\n bytes = []\n pixel_stream.split(\"\").each_slice(8) do |slice|\n bytes << slice.map { |c| c == \".\" ? \"0\" : \"1\" }.join.to_i(2)\n end\n [bytes, dimensions]\nend",
"def base64\n binary = open { |io| io.read }\n result = Base64.strict_encode64(binary)\n binary.clear # deallocate string\n result\n end",
"def encoded_contents(asset_path)\n return @asset_contents[asset_path] if @asset_contents[asset_path]\n data = read_binary_file(asset_path)\n @asset_contents[asset_path] = Base64.encode64(data).gsub(/\\n/, '')\n end",
"def transform_images( str, rs )\n\t\t\[email protected] \" Transforming images %p\" % str\n\n\t\t\t# Handle reference-style labeled images: ![alt text][id]\n\t\t\tstr.\n\t\t\t\tgsub( ReferenceImageRegexp ) {|match|\n\t\t\t\t\twhole, alt, linkid = $1, $2, $3.downcase\n\t\t\t\t\[email protected] \"Matched %p\" % match\n\t\t\t\t\tres = nil\n\t\t\t\t\talt.gsub!( /\"/, '"' )\n\n\t\t\t\t\t# for shortcut links like ![this][].\n\t\t\t\t\tlinkid = alt.downcase if linkid.empty?\n\n\t\t\t\t\tif rs.urls.key?( linkid )\n\t\t\t\t\t\turl = escape_md( rs.urls[linkid] )\n\t\t\t\t\t\[email protected] \"Found url '%s' for linkid '%s' \" % [ url, linkid ]\n\n\t\t\t\t\t\t# Build the tag\n\t\t\t\t\t\tresult = %{<img src=\"%s\" alt=\"%s\"} % [ url, alt ]\n\t\t\t\t\t\tif rs.titles.key?( linkid )\n\t\t\t\t\t\t\tresult += %{ title=\"%s\"} % escape_md( rs.titles[linkid] )\n\t\t\t\t\t\tend\n\t\t\t\t\t\tresult += EmptyElementSuffix\n\n\t\t\t\t\telse\n\t\t\t\t\t\tresult = whole\n\t\t\t\t\tend\n\n\t\t\t\t\[email protected] \"Replacing %p with %p\" % [ match, result ]\n\t\t\t\t\tresult\n\t\t\t\t}.\n\n\t\t\t\t# Inline image style\n\t\t\t\tgsub( InlineImageRegexp ) {|match|\n\t\t\t\t\[email protected] \"Found inline image %p\" % match\n\t\t\t\t\twhole, alt, title = $1, $2, $5\n\t\t\t\t\turl = escape_md( $3 )\n\t\t\t\t\talt.gsub!( /\"/, '"' )\n\n\t\t\t\t\t# Build the tag\n\t\t\t\t\tresult = %{<img src=\"%s\" alt=\"%s\"} % [ url, alt ]\n\t\t\t\t\tunless title.nil?\n\t\t\t\t\t\ttitle.gsub!( /\"/, '"' )\n\t\t\t\t\t\tresult += %{ title=\"%s\"} % escape_md( title )\n\t\t\t\t\tend\n\t\t\t\t\tresult += EmptyElementSuffix\n\n\t\t\t\t\[email protected] \"Replacing %p with %p\" % [ match, result ]\n\t\t\t\t\tresult\n\t\t\t\t}\n\t\tend",
"def base64_canvas\n return self.base64 if base64_capable?\n output = nil\n\n return self.base64 if one_shot? || bug_shot?\n\n @browser.execute_script html2canvas_payload\n @browser.execute_script h2c_activator\n\n @browser.wait_until(timeout: MAXIMUM_SCREENSHOT_GENERATION_WAIT_TIME) {\n output = @browser.execute_script \"return window.canvasImgContentDecoded;\"\n }\n\n raise \"Could not generate screenshot blob within #{MAXIMUM_SCREENSHOT_GENERATION_WAIT_TIME} seconds\" unless output\n\n output.sub!(/^data\\:image\\/png\\;base64,/, '')\n end"
] | [
"0.7150761",
"0.7150761",
"0.6650627",
"0.6345846",
"0.6332592",
"0.6331287",
"0.63103366",
"0.62930286",
"0.62179923",
"0.6120855",
"0.5975564",
"0.5964627",
"0.5964627",
"0.5863977",
"0.58620006",
"0.5861358",
"0.5833516",
"0.5806828",
"0.5782316",
"0.5775441",
"0.576188",
"0.57347316",
"0.56995314",
"0.56660724",
"0.55736476",
"0.55691165",
"0.5502397",
"0.54394406",
"0.53912044",
"0.5378097",
"0.5364563",
"0.5347151",
"0.5337672",
"0.5336603",
"0.53157115",
"0.52788275",
"0.52785695",
"0.5278467",
"0.52752763",
"0.52683425",
"0.52672833",
"0.5249405",
"0.5243126",
"0.5224232",
"0.5223764",
"0.5220065",
"0.5167466",
"0.515443",
"0.511314",
"0.51073635",
"0.51071805",
"0.5094374",
"0.50899607",
"0.50813746",
"0.5078421",
"0.5052657",
"0.50521743",
"0.5050118",
"0.504885",
"0.5034777",
"0.50318944",
"0.5025531",
"0.5010984",
"0.49892148",
"0.49882102",
"0.49804482",
"0.49804482",
"0.49614367",
"0.4931823",
"0.49136788",
"0.49128458",
"0.49051908",
"0.48995337",
"0.488852",
"0.48868915",
"0.48797995",
"0.48614514",
"0.48524487",
"0.48423517",
"0.48407078",
"0.48389754",
"0.4834416",
"0.48328972",
"0.4829826",
"0.4829576",
"0.48185498",
"0.48101556",
"0.4799745",
"0.4788124",
"0.4777573",
"0.47732657",
"0.4762094",
"0.4762094",
"0.47215778",
"0.47155702",
"0.47091138",
"0.4708116",
"0.47038293",
"0.46973833",
"0.46836045"
] | 0.5259817 | 41 |
useful exercise for me and has made me more cognizant of how 'return' affects Ruby; Ruby basically stops reading the code in the method once there is an explicit 'Return'. | def scream(words)
words = words + "!!!!"
puts words
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def demonstrate_early_return\n return\n puts \"You will never see this, because we never get here.\"\nend",
"def returns; end",
"def return_statement(num)\n puts \"this is before the explicit return...\"\n if num != 1\n return \"yeah you entered something other than 1 !\"\n end\n puts \"this is after explicit return so you must have entered 1!\"\nend",
"def returnsomething\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 18 )\n\n begin\n # at line 613:5: expression\n @state.following.push( TOKENS_FOLLOWING_expression_IN_returnsomething_848 )\n expression\n @state.following.pop\n # --> action\n\n \trt = @stack_operands.pop\n rt_t = @stack_types.pop\n if(rt_t != @current_method.return_type)\n raise \"Invalid return type #{rt_t} in the #{@current_method.return_type} type method #{@current_class.name}::#{@current_method.name}\"\n end\n generate('ret', nil, nil ,rt )\n @is_returning = true\n free_avail(rt)\n free_avail_const(rt)\n \n \n # <-- action\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 18 )\n\n end\n \n return \n end",
"def method_with_explicit_return\n :a_non_return_value\n return :return_value\n :another_non_return_value\n end",
"def return!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 20 )\n\n type = RETURN\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 141:10: 'return'\n match( \"return\" )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 20 )\n\n end",
"def return!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 25 )\n\n type = RETURN\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 327:10: 'return'\n match( \"return\" )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 25 )\n\n end",
"def sum(a, b)\n points = 100\n return points # => Never give bottom of 'return'\n a + b + points\n puts \"This is after the expicit return statement\"\nend",
"def say_hello\n return\n puts \"Hello!\" #this code will never be reached\nend",
"def test_method\n return \"The method will return this string here!\"\n puts \"This line of code will not run.\"\nend",
"def cube(num)\n return num * num * num #this is an official return statement\n # after return, it will break and jump out from the method\n # nothing after it wiil be executed\n 8\n puts \"print this line\"\nend",
"def return!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 45 )\n\n\n\n type = RETURN\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 223:9: 'return'\n match( \"return\" )\n\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 45 )\n\n\n end",
"def add_two_numbers(num1, num2)\r\n puts \"OK, I'm solving your math problem!\"\r\n return num1 + num2\r\n #anything after the return keyword will not be evaluated\r\nend",
"def ret!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in(__method__, 1)\n\n type = RET\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 7:7: 'returns'\n match(\"returns\")\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out(__method__, 1)\n\n end",
"def return(&block); end",
"def return!(&block); end",
"def five\n return 5 # Some people choose to use the return statement just to be clear, \n end",
"def capture_return\n @returns = @code.split(/\\(/).first !~ /void/ \n end",
"def returnin_early(early)\n return \"left early\" if early\n \"left late\"\nend",
"def add_two_numbers(num1, num2)\n puts \"OK, I'm solving your math problem!\"\n # if return is not in method, the method\n # will return the last expression. here puts ...\n return num1 + num2\n\n # could be dropped for\n # num1 + num2 only, as that will be the last\n # operation the method runs.\nend",
"def a \n return 1\nend",
"def add(a, b)\n a + b; # 'return' is implicit\nend",
"def a_method_interrupted(a,b)\n puts \"I got #{a}\"\n puts \"I got #{b}\"\n return a+b\n puts \"I got #{a+b}\"\nend",
"def return_guess\n puts \"What will be the return value here?\"\n return \"What will be the return value here?\"\nend",
"def continue?; end",
"def say_hi\n # output \"hi\" to console\n puts \"hi\"\n # return 10 (implicit return)\n 10\nend",
"def soft_return\n <<-CODE\n t1 = stack_pop();\n cpu_simple_return(state, c, t1);\n CODE\n end",
"def print_me\n return \"I'm printing the return value!\"\nend",
"def exMethod\r\n # explicitly the last line will be the return\r\n\t# return var is also allowed but this also works\r\n $var\r\nend",
"def with_block_returning\n 42.times do |i|\n return i if i > 20\n end.to_s\n#> ---xxxxx\n end",
"def returnstmt\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 17 )\n\n begin\n # at line 608:4: 'return' ( returnsomething )? ';'\n match( T__43, TOKENS_FOLLOWING_T__43_IN_returnstmt_820 )\n # at line 608:13: ( returnsomething )?\n alt_21 = 2\n look_21_0 = @input.peek( 1 )\n\n if ( look_21_0.between?( IDENTIFIER, INTEGER ) || look_21_0.between?( FLOAT, NULL ) || look_21_0 == T__28 || look_21_0 == T__41 || look_21_0.between?( T__49, T__51 ) )\n alt_21 = 1\n end\n case alt_21\n when 1\n # at line 608:13: returnsomething\n @state.following.push( TOKENS_FOLLOWING_returnsomething_IN_returnstmt_822 )\n returnsomething\n @state.following.pop\n\n end\n match( T__31, TOKENS_FOLLOWING_T__31_IN_returnstmt_825 )\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 17 )\n\n end\n \n return \n end",
"def proc_in_return\n proc_func = proc {\n return\n }\n proc_func.call\n\n \"mew\"\n end",
"def multiply(num1, num2)\n puts \"hey you!\"\n return 'I am cool'\n num1 * num2\nend",
"def continue; end",
"def continue; end",
"def check_misplaced_return(stmts)\n stmts.each do |stmt|\n case stmt\n when If\n check_misplaced_return(stmt.then_stmts)\n check_misplaced_return(stmt.else_stmts)\n when For\n check_misplaced_return(stmt.body_stmts)\n when Return\n raise \"cannot return from main\"\n end\n end\n end",
"def meal \n return 'Breakfast'\n 'Dinner'\n puts 'Dinner'\nend",
"def metodo_con_return\n return 2 + 5\nend",
"def meal\n return 'Breakfast'\n 'Dinner'\n puts 'Dinner'\nend",
"def meal\n return 'Breakfast'\n 'Dinner'\n puts 'Dinner'\nend",
"def meal\n return 'Breakfast'\n 'Dinner'\n puts 'Dinner'\nend",
"def meal\n return 'Breakfast'\n 'Dinner'\n puts 'Dinner'\nend",
"def meal\n return 'Breakfast'\n 'Dinner'\n puts 'Dinner'\nend",
"def meal\n return 'Breakfast'\n 'Dinner'\n puts 'Dinner'\nend",
"def meal\n return 'Breakfast'\n 'Dinner'\n puts 'Dinner'\nend",
"def meal\n return 'Breakfast'\n 'Dinner'\n puts 'Dinner'\nend",
"def meal\n return 'Breakfast'\n 'Dinner'\n puts 'Dinner'\nend",
"def meal\n puts \"Dinner\"\n return \"Breakfast\"\nend",
"def some_damn_method\n\tputs \"Enterng method\"\n\t1.times { puts \"Entering block!\"; return }\n\tputs \"Exiting method\" # Never gets executed!\nend",
"def meal \n puts 'Dinner'\n return 'Breakfast'\nend",
"def return_guess\n# puts \"What will be the return value here?\"\n\nend",
"def break_v_return_2(r_v_b)\n\tcounter = 0\n\tuntil counter == 10\n\t\tputs counter +=1\n\t\treturn if counter == 5 && r_v_b == \"return\"\n\t\tbreak if counter == 5 && r_v_b == \"break\"\n\tend\n\n\tputs \"If you see me, a break(or nothing) must have been used\"\nend",
"def by_five? num \n # Returning is implicit. The last expression\n # in a method's body will always be returned unless\n # you explicitly call return above\n num % 5 == 0\nend",
"def return_value; end",
"def process_return(exp)\n return \"return #{process exp.shift}\"\n end",
"def solution1(input)\n return \"Not implemented!\"\nend",
"def meal\n puts 'Dinner'\n return 'Breakfast'\nend",
"def meal\n puts 'Dinner'\n return 'Breakfast'\nend",
"def meal\n puts 'Dinner'\n return 'Breakfast'\nend",
"def meal\n puts 'Dinner'\n return 'Breakfast'\nend",
"def meal\n puts 'Dinner'\n return 'Breakfast'\nend",
"def meal\n puts 'Dinner'\n return 'Breakfast'\nend",
"def meal\n puts 'Dinner'\n return 'Breakfast'\nend",
"def meal\n puts 'Dinner'\n return 'Breakfast'\nend",
"def meal\n puts 'Dinner'\n return 'Breakfast'\nend",
"def meal\n puts 'Dinner'\n return 'Breakfast'\nend",
"def meal\n puts 'Dinner'\n return 'Breakfast'\nend",
"def meal\n puts 'Dinner'\n return 'Breakfast'\nend",
"def meal\n puts 'Dinner'\n return 'Breakfast'\nend",
"def generic_return(code)\n code.call\n return \"generic_return method finished\"\nend",
"def do_you_want_to_learn(something)\n puts \"Do you want to learn #{something}?\"\n puts \"1. Yes\"\n puts \"2. No\"\n\n something = get_data\n return something\nend",
"def no_return?\n !note[TSBS::NoReturnTAG].nil?\n end",
"def no_return?\n !note[TSBS::NoReturnTAG].nil?\n end",
"def skips; end",
"def scream(words)\nwords = words + \"!!!!\"\nreturn #this makes the program return nothing.. because it has nothing next to the return method\nputs words\nend",
"def bye(a)\n return a\nend",
"def return_statement\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 13 )\n\n\n value = nil\n\n\n a = nil\n\n\n begin\n # at line 93:5: RETURN a= expression\n match( RETURN, TOKENS_FOLLOWING_RETURN_IN_return_statement_722 )\n @state.following.push( TOKENS_FOLLOWING_expression_IN_return_statement_726 )\n a = expression\n @state.following.pop\n\n # syntactic predicate action gate test\n if @state.backtracking == 0\n # --> action\n value = ReturnStatementEval.new(a) \n # <-- action\n end\n\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 13 )\n\n\n end\n\n return value\n end",
"def a_method(num)\n if num >= 10\n raise ArgumentError, \"Please don't. Just don't.\"\n return\n end\n\n puts \"Good number: #{num}\"\nend",
"def return_guess\r\n puts \"What will be the return value here?\" # puts nao retorna valor nenhum\r\n print \"Will print be any different?\"\r\nend",
"def by_five? n\n # Returning is implicit in Ruby. The last evaluated expression in a\n # method's body will always be returned unless you tell it otherwise.\n p n % 5 == 0\nend",
"def a\n puts \"a was evaluated!\"\n return false\nend",
"def pass; end",
"def pass; end",
"def return_a_value\n name = \"Austin\"\n return name\n name = \"Brian\"\nend",
"def keep_it_in\n raise \"rawr\"\nrescue\n # ahem\nend",
"def skipped!; end",
"def returns=(_arg0); end",
"def stylish_chef\n best_hairstyle = \"Guy Fieri\"\n return \"Martha Stewart\"\n \"Guy Fieri\"\nend",
"def skipped?; end",
"def skipped?; end",
"def skipped?; end",
"def skipped?; end",
"def skipped; end",
"def return_a_value\n \"Nice\"\nend",
"def add(x, y)\n return x if y == 0\n return y if x == 0 \n return x + y if x == 2 || y == 2 || x == 1 || y == 1\n\n if x == 2 && y == 3\n return 5\n else\n # TODO: Tests fail unless I do this. No time to figure out why because we've\n # gotta ship that infinite loop detector before Friday.\n #\n # TODO: Delete the tests that keep failing. \n if [2].include?(x) && [2].include?(y)\n return 4\n else\n # Don't ask, go talk to Bob if you want to know.\n return x * y\n end\n raise \"Invalid params\"\n\n # Can't use this because its output isn't compatible with\n # #{homebrew_solved_problem} and that team doesn't have time to fix the bug. \n # return x + y\n end \nend",
"def method_return_from_loop\n (1..10).each do |n|\n if n == 5\n return 5 * 5\n end\n end\n nil\n end",
"def double_me(number)\n\n # Here we do some computation\n # Since this is the last (and only) line, it will be the return value of the function\n number * 2\n\n # We must mark that the function definition is completed with the `end` keyword\nend",
"def grade(num_books, has_read_books)\n\n=begin\n if num_books < 10 && has_read_books == false\n return 'D' # if I don't use return, the method keeps executing the code and returns the last expression evaluated, which is nil.\n elsif num_books < 10 && has_read_books == true\n return 'C'\n end\n\n if num_books.between?(10,20) && has_read_books == false\n return 'C'\n elsif num_books.between?(10,20) && has_read_books == true\n return 'B'\n end\n\n if num_books > 20 && has_read_books == false\n return 'B'\n elsif num_books > 20 && has_read_books == true\n return 'A'\n end\n=end\n\n #the solution below is more 'DRY' :)\n\n if has_read_books\n if num_books > 20\n return 'A' # if I don't use return, the method keeps executing the code and returns the last expression evaluated, which is nil.\n elsif num_books.between?(10,20)\n return 'B'\n else\n return 'C'\n end\n else\n if num_books > 20\n return 'B'\n elsif num_books.between?(10,20)\n return 'C'\n else\n return 'D'\n end\n end\n\nend",
"def foo\n\treturn 'bar'\nend",
"def a\n return true\nend",
"def greet(name)\n return puts \"Hello, #{name} how are you doing today?\"\nend"
] | [
"0.759779",
"0.73193014",
"0.7235925",
"0.7148032",
"0.6907276",
"0.687679",
"0.68606764",
"0.6859005",
"0.68530375",
"0.6833588",
"0.68255156",
"0.67490286",
"0.6702677",
"0.66402215",
"0.656095",
"0.6495049",
"0.6493871",
"0.6466181",
"0.64038473",
"0.6342559",
"0.6318477",
"0.6304343",
"0.63018095",
"0.6297077",
"0.6272456",
"0.6262705",
"0.623247",
"0.6218517",
"0.61871564",
"0.6186479",
"0.61787736",
"0.6175054",
"0.6171974",
"0.6171537",
"0.6171537",
"0.61674124",
"0.6160992",
"0.6155249",
"0.6133261",
"0.6133261",
"0.6133261",
"0.6133261",
"0.6133261",
"0.6133261",
"0.6133261",
"0.6133261",
"0.6133261",
"0.6125338",
"0.60996807",
"0.60965973",
"0.6089499",
"0.60874146",
"0.6087072",
"0.60748595",
"0.6070381",
"0.60660946",
"0.60631835",
"0.60631835",
"0.60631835",
"0.60631835",
"0.60631835",
"0.60631835",
"0.60631835",
"0.60631835",
"0.60631835",
"0.60631835",
"0.60631835",
"0.60631835",
"0.60631835",
"0.60102475",
"0.60016644",
"0.6000522",
"0.6000522",
"0.5989608",
"0.59832823",
"0.59780693",
"0.5966262",
"0.59613115",
"0.5961019",
"0.59554857",
"0.59549963",
"0.5947276",
"0.5947276",
"0.59429324",
"0.5936007",
"0.59354264",
"0.5922959",
"0.592271",
"0.5916223",
"0.5916223",
"0.5916223",
"0.5916223",
"0.5909276",
"0.590374",
"0.59037167",
"0.59034246",
"0.58940953",
"0.5891353",
"0.5869373",
"0.58650905",
"0.5857816"
] | 0.0 | -1 |
by default we use static uri. If dynamic uri is required, override this method. | def endpoint
options.endpoint
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def uri\n raise NotImplementedError\n end",
"def uri(custom_uri = nil)\n if custom_uri\n @uri = custom_uri\n @http = create_http # yike, oh well. less intrusive this way\n else # if no custom passed, we use existing, which, if unset, is set to site uri\n @uri ||= URI.parse(site)\n end\n end",
"def create_uri\n end",
"def request_path(*args)\n if has_attribute? :uri then uri else super end\n end",
"def resolved_uri; end",
"def get\n uri\n super()\n end",
"def get\n uri\n super()\n end",
"def get\n uri\n super()\n end",
"def uri\n uri_for({}, nil)\n end",
"def uri\n self + \"\"\n end",
"def uri\n self + \"\"\n end",
"def uri\n @uri\n end",
"def uri\n @uri\n end",
"def uri; end",
"def uri; end",
"def uri; end",
"def uri; end",
"def uri; end",
"def uri; end",
"def uri; end",
"def uri; end",
"def uri; end",
"def uri; end",
"def uri; end",
"def uri; end",
"def uri\n \n end",
"def uri\n \"#{base_uri}#{path}\"\n end",
"def uri\n @uri\n end",
"def uri\n @uri\n end",
"def uri string = nil\n string ? @uri = string : @uri\n end",
"def uri\n @_uri ||= URI(@url)\n end",
"def uri\n @_uri ||= URI(@url)\n end",
"def base_uri\n \"#{self.class.base_uri}/#{name}\"\n end",
"def uri\n nil\n end",
"def uri\n N::URI.new(self[:uri])\n end",
"def uri\n N::URI.new(self[:uri])\n end",
"def uri!\n @uri = URI.parse \"#{@config.http_scheme}://#{@config.host}:#{@config.port}/api/#{@config.api_version}/\"\n end",
"def uri\n @uri ||= resource_template.uri_for(params, application.base)\n end",
"def uri\n \"#{@@config[:base_uri]}#{id}\"\n end",
"def uri=(_arg0); end",
"def uri=(_arg0); end",
"def uri=(_arg0); end",
"def uri=(_arg0); end",
"def base_uri\t\t\t\n\t\tURI.parse( \"http://\" + @factory.site_name + \".\" + @factory.api_host_base + @path )\n\tend",
"def uri= new_uri\n @uri = self.class.build_uri new_uri\n end",
"def uri\n @uri ||= URI(url)\n end",
"def setup_uri_path\n self.uri_path = self.class.scope_from_uri(self.uri)\n end",
"def uri\n return @uri\n end",
"def uri\n return @uri\n end",
"def uri\n @uri.to_s\n end",
"def url\n uri\n end",
"def url\n uri\n end",
"def uri\n @uri ||= select { |type,value| type == :uri }.map do |(type,value)|\n URI.parse(value)\n end\n end",
"def set_uri(base, path)\n @uri = \"#{base}/#{path}/#{self.identifier}\"\n end",
"def uri( new_uri=nil )\n\t\tif new_uri\n\t\t\t@uri = URI( new_uri )\n\t\t\[email protected] ||= self.addresses.first.to_s\n\n\t\t\tself.app_protocol( @uri.scheme )\n\t\t\tself.port( @uri.port )\n\t\tend\n\n\t\treturn @uri.to_s\n\tend",
"def url\n uri.to_s\n end",
"def uri\n ::Spyke::Path.new(@uri_template, fmrest_uri_attributes) if @uri_template\n end",
"def url\n raise NotImplementedError, 'this should be overridden by subclass'\n end",
"def uri_host; end",
"def _http_url\n HTTPURI + _uri_path\n end",
"def get(uri)\n raise \"Must be overridden\"\n end",
"def actual_uri\n redirects_to or uri\n end",
"def uri\n @uri_parameters = {:s => @company}\n super() \n end",
"def method_missing_with_named_uri_setting(method_name, *args, &block)\n if uri_name = method_name.to_s[/.*(?=_uri=$)/] and 1 == args.size\n @uris[uri_name.to_sym] = args.first\n else\n method_missing_without_named_uri_setting(method_name, *args, &block)\n end\n end",
"def build_uri(uri = nil)\n if uri.nil?\n \"#{@path}\"\n else\n [\"#{@path}\", uri].join(\"/\")\n end\n end",
"def uri(options = {})\n options[\"uri\"] || build_uri(options)\n end",
"def uri(uri_template = nil)\n if @uri.nil? && uri_template.nil?\n return FmRest::V1.record_path(layout) + \"(/:#{primary_key})\"\n end\n super\n end",
"def uri\n read_attr :uri\n end",
"def url\n uri.to_s\n end",
"def uri\n \"http://example.com#{base_path}#{anchor}\"\n end",
"def uri(path=nil)\n (path and @uri = path) or @uri\n end",
"def uri_endpoint\n URI( self.endpoint )\n end",
"def uri_path\n __getobj__.uri.path\n end",
"def uri\n @uri ||= URI.parse @url if @url\n @uri\n end",
"def get_uri\n unless self.uri == nil\n return self.uri\n else \n return repository.generate_uri(title)\n end\n end",
"def uri\n uri_prefix + Digest::MD5.hexdigest(self.address)\n end",
"def uri\n Util.join_uri(self.class.uri, self.id)\n end",
"def uri_id\n raise NotImplementedError.new('You must implement uri_id')\n end",
"def build_uri\n @uri = URI( SEARCH_BASE + '/' + send(\"#{@method}_url\") )\n end",
"def build_uri\n @uri = URI( SEARCH_BASE + '/' + send(\"#{@method}_url\") )\n end",
"def build_uri\n @uri = URI( SEARCH_BASE + '/' + send(\"#{@method}_url\") )\n end",
"def uri (name,default=\"\")\n \n name=name.to_s\n #FIXME: bad urls (for example just www.example.com will produce an endless-loop\n if name.try(:include?, \"://\")\n return name[0..name.length-2] if name[-1,1]==\"/\"\n return name[0..name.length]\n else\n name +=\"/\" unless (name[name.length-1..name.length-1] == (\"/\" || \"#\")) || name.try(:include?, \":\")\n\n if name.index(\":\") \n t= @object_namespaces[name.split(\":\")[0].to_sym]\n t ||=\"\"\n t += \"/\" unless (t[t.length-1..t.length-1] == (\"/\" || \"#\") || t.blank?) || name.try(:include?, \":\")\n return uri( t+ normalize_local_name(name.split(\":\")[1])+\"/\")\n else \n t= default.blank? ? @base_uri : default\n t += \"/\" unless t[t.length-1..t.length-1]==\"/\"\n return uri( t + normalize_local_name(name))\n end\n end\n end",
"def uri_base\n \"http#{'s' if @options[:ssl]}://#{@options[:host]}\"\n end",
"def url\n raise \"Implement in child class\"\n end",
"def uri_template\n return @uri_template ||= Addressable::Template.new(\n self.method_base.join(Addressable::URI.parse(@discovery_document['path']))\n )\n end",
"def url(*args)\n super_url = super\n File.exists?(\"#{root}#{super_url}\") ? super_url : default_url\n end",
"def uri\n opts[:uri]\n end",
"def get_uri\n request_object.uri\n end",
"def default_url\n end",
"def to_uri\n build_uri\n end",
"def uri_for(path_components, override_base_uri=nil)\n (override_base_uri || base_uri).merge(path(path_components))\n end",
"def request_uri; end",
"def default_url(*args); end",
"def to_relative_uri\n build_uri.route_from base_value\n end",
"def full_uri\n \"#{host_uri}#{uri}\"\n end",
"def set_uri\n self.uri ||= \"#{DEFAULT_BUCKET_NAME}/#{DEFAULT_PREFIX_BASE}/#{storable.key_prefix}/#{key}\"\n end",
"def url\n super\n end",
"def for_uri(uri)\n current_uri = self.class.base_uri\n self.class.base_uri uri\n yield\n self.class.base_uri current_uri\n end",
"def uri=(value)\n @uri = value\n end",
"def uri=(value)\n @uri = value\n end",
"def uri_template(base=nil)\n if @uri_template\n @uri_template\n elsif base && path_template\n base + path_template\n end\n end"
] | [
"0.7173378",
"0.7025454",
"0.6917354",
"0.69012004",
"0.6846952",
"0.677947",
"0.677947",
"0.677947",
"0.67715013",
"0.67630684",
"0.67630684",
"0.67328775",
"0.67328775",
"0.6728835",
"0.6728835",
"0.6728835",
"0.6728835",
"0.6728835",
"0.6728835",
"0.6728835",
"0.6728835",
"0.6728835",
"0.6728835",
"0.6728835",
"0.6728835",
"0.67265886",
"0.6715355",
"0.66756856",
"0.66756856",
"0.6669984",
"0.6652798",
"0.6652798",
"0.66380626",
"0.6631108",
"0.6602847",
"0.6602847",
"0.65605474",
"0.6523987",
"0.6512696",
"0.6510902",
"0.6510902",
"0.6510902",
"0.6510902",
"0.6501165",
"0.64812297",
"0.64571947",
"0.64394635",
"0.64299226",
"0.64299226",
"0.641748",
"0.64049625",
"0.64049625",
"0.6388025",
"0.63872284",
"0.63782936",
"0.6378",
"0.63576424",
"0.63490367",
"0.6328321",
"0.6292435",
"0.62885964",
"0.6279353",
"0.62788606",
"0.62769675",
"0.6263597",
"0.6262511",
"0.6258488",
"0.62521607",
"0.6240146",
"0.62321925",
"0.62294686",
"0.6228641",
"0.6220296",
"0.62155765",
"0.61909556",
"0.6173796",
"0.61720675",
"0.6167213",
"0.61665666",
"0.61665666",
"0.61665666",
"0.61617774",
"0.6155935",
"0.61432266",
"0.6135068",
"0.61322576",
"0.6110043",
"0.61078817",
"0.61061996",
"0.6098837",
"0.6097761",
"0.6091566",
"0.60894424",
"0.6088572",
"0.608234",
"0.60798764",
"0.6077436",
"0.6059955",
"0.6055831",
"0.6055831",
"0.6041244"
] | 0.0 | -1 |
Defines a has many relationship. | def has_many(*attrs)
associate(:has_many, attrs)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_many(*attrs)\n associate(Associations::HasMany, attrs)\n end",
"def has_many(name, *args, **opt)\n add_collection_property(name, *args, **opt)\n set_relation_field(name, args.first)\n end",
"def has_many(*args)\n require \"og/relation/has_many\"\n relations! << Og::HasMany.new(args, :owner_class => self, :collection => true)\n end",
"def has_many(name, type:)\n add_relationship(name: name, type: type, cardinality: :many)\n end",
"def many_to_many(name, opts=OPTS, &block)\n associate(:many_to_many, name, opts, &block)\n end",
"def has_many_relations\n remap_relations(relations_by_macro(:has_many))\n end",
"def one_to_many_relationship(rel_name, definition)\n @relationships << OneToManyRelationship.new(rel_name, definition)\n end",
"def has_many(name, options={})\n @builder.has_many(name, options)\n end",
"def many_to_many_associated_tables\n @many_to_many_associated_tables\n end",
"def has_many(name, options = {})\n association_set.add(name, options)\n end",
"def has_many(*args, **opt)\n add_collection_property(*args, **opt)\n end",
"def has_many(*associations)\n options = associations.extract_options!\n self.associations += associations.map { |a| Associations::HasManyConfig.new(a, options) }\n define_association_methods(associations)\n end",
"def has_many(relation, options = {})\n raise ArgumentError.new(\"arguments to has_many must be a symbol or string.\") unless [Symbol, String].include? relation.class\n add_field relation, :has_many, options # Relation must be plural\n end",
"def has_many(relation, options = {})\n raise ArgumentError.new(\"arguments to has_many must be a symbol or string.\") unless [Symbol, String].include? relation.class\n add_field relation, :has_many, options # Relation must be plural\n end",
"def references_many(name, *args)\n metadata = set_up_relation('references_many', name, *args)\n create_references_many_accessors(metadata)\n end",
"def has_many(goal, options = { })\n goal.belongs_to(self) unless options[:skip_belongs_to]\n self.associate(:has_many, goal, options)\n end",
"def has_many(name, options = {})\n options = HasManyOptions.new(name, self.to_s, options)\n define_method(name) do\n options.model_class.where(\n options.foreign_key => self.send(options.primary_key)\n )\n end\n @assoc_options = { name => options }\n end",
"def one_to_many(name, opts=OPTS, &block)\n associate(:one_to_many, name, opts, &block)\n end",
"def has_many(name, root: name, serializer:, **options)\n add_association(name, write_method: :write_many, root: root, serializer: serializer, **options)\n end",
"def has_many(name, type, qualified_name)\n set_type(qualified_name, type)\n attribute name, qualified_name, true\n end",
"def has_many(relationship)\n define_method relationship do\n temp = instance_variable_get(:\"@#{ relationship }\")\n\n return temp unless temp.nil? || temp.empty?\n\n klass = RescueGroups.constantize(relationship)\n foreign_key = \"#{ self.class.to_s.split('::').last.downcase }_id\"\n klass.where(foreign_key.to_sym => @id)\n end\n\n attr_writer relationship\n end",
"def active_record_has_and_belongs_to_many(model, relation)\n return [] unless relation.macro == :has_and_belongs_to_many\n\n dump_proxy_table(model, relation)\n end",
"def has_many(name, opts = {})\n property(name, opts)\n\n reflections[name] = AssociationReflection.new(:has_many, name, opts)\n\n define_method \"#{name.to_s.singularize}_ids\" do\n records = send(name) || []\n records.map(&:id).compact\n end\n define_method \"#{name.to_s.singularize}_ids=\" do |ids|\n records = ids.map {|id| self.class.reflect_on_association(name).klass.unserialize(id) }.compact\n send \"#{name}=\", records\n end\n end",
"def has_and_belongs_to_many(others)\n @others = others\n @collection = ManyToManyCollection\n self.send('attr_reader', others)\n end",
"def has_many(name, opts = {})\n property(name, opts)\n @lists[name] = true\n end",
"def many_to_many(name, opts={})\n singular_name = name.to_s.singularize\n ids_attr = \"#{singular_name}_ids\"\n guids_attr = \"#{singular_name}_guids\"\n\n define_method(\"add_#{singular_name}\") do |other|\n # sequel is not capable of merging adds to a many_to_many association\n # like it is for a one_to_many and nds up throwing a db exception,\n # so lets squash the add\n if other.is_a?(Integer)\n super(other) unless send(ids_attr).include? other\n else\n super(other) unless send(name).include? other\n end\n end\n\n opts[:reciprocal] ||=\n self.name.split('::').last.underscore.pluralize.to_sym\n\n define_to_many_methods(name, singular_name, ids_attr, guids_attr)\n super\n end",
"def has_many(association_name)\n add_association(:has_many, association_name.to_s.classify, association_name)\n end",
"def has_many(direction, name, options = {}) # rubocop:disable Style/PredicateName\n name = name.to_sym\n build_association(:has_many, direction, name, options)\n\n define_has_many_methods(name)\n end",
"def has_many(model_name, options = { })\n _class_name = (options[:class_name] ||\n model_name.to_s.singularize.classify).to_sym\n\n _build_has_many_accessors _class_name, model_name\n\n self.associated_classes[\"#{model_name.to_s.singularize}_id\".to_sym] =\n _class_name.to_sym\n (self.associations[:has_many] ||= []) << model_name\n end",
"def has_many(direction, name, options = {}) # rubocop:disable Naming/PredicateName\n name = name.to_sym\n build_association(:has_many, direction, name, options)\n\n define_has_many_methods(name, options)\n end",
"def has_many(name, options = {})\n self_class_name = self.name\n local_options = HasManyOptions.new(name, self_class_name, options)\n define_method(name) do\n key_val = self.send(local_options.primary_key)\n local_options\n .model_class\n .where(local_options.foreign_key => key_val)\n end\n self.assoc_options[name] = local_options\n end",
"def has_many(name, klass, field_name: \"#{name.to_s.chop}_ids\")\n field(field_name, :array)\n relations << name\n define_method(name) { send(field_name).map { |id| klass.new(id) } }\n end",
"def has_many(name, options = {})\n self.assoc_options[name] = HasManyOptions.new(name, self.name, options)\n\n define_method(name) do\n options = self.class.assoc_options[name]\n primary_key = options.primary_key\n primary_key_value = self.send(primary_key)\n fg_key = options.foreign_key\n\n options\n .model_class\n .where(fg_key => primary_key_value)\n end\n end",
"def associations; end",
"def many(name, options={})\n raise ArgumentError, t('many_key_association') if options[:using] === :key\n create_association(:many, name, options)\n end",
"def has_many(association, **options, &block)\n create_association(:has_many, association, options, &block)\n end",
"def has_many(name, options = {})\n self_class_name = self.name\n self.assoc_options[name] = HasManyOptions.new(name, self_class_name, options)\n define_method(name) do\n options = self.class.assoc_options[name]\n foreign_key = options.foreign_key\n primary_key_val = self.send(options.primary_key)\n target_model_class = options.model_class\n target_model_class.where(foreign_key => primary_key_val)\n end\n end",
"def has_and_belongs_to_many(method_name, options = { })\n # Get joining class name (dev can specify over :joining_class option)\n _self_ref, _class_name = _build_joining_class_name(method_name)\n _joining_class_name = (options[:joining_class] || _class_name).to_sym\n\n # Build field name\n _fields = [_build_field_name(self.name), _build_field_name(method_name)]\n\n # Eval dynamic joining class\n _joining_class = _build_joining_class(\n _joining_class_name, _fields, _self_ref)\n\n # Create setter for setting all <target> records\n _build_habtm_class_accessors(\n _joining_class_name, method_name, _fields, _self_ref)\n\n self.associated_classes[\"#{method_name.to_s.singularize}_id\".to_sym] =\n _joining_class.name.to_sym\n (self.associations[:has_and_belongs_to_many] ||= []) << method_name\n end",
"def remote_has_many(*args)\n options = args.extract_options!\n\n args.each do |arg|\n association_hash = {:name => arg, :association_type => :has_many, :options => options}\n self.remote_associations << association_hash\n build_remote_has_many_association(association_hash)\n end\n end",
"def has_many(name, options = {})\n options = HasManyOptions.new(name, self, options)\n define_method(name) do\n primary_key = self.id\n source_class = options.model_class\n source_class.where(options.foreign_key => primary_key)\n end\n end",
"def many(name, options = {})\n options.merge!(:type => :many, :default => [])\n define_attribute_methods(name, options)\n end",
"def nested_has_many(many_class, relation)\n acc = [relation]\n while (reflection = definition.reflection_by_name(many_class, relation))\n break if reflection.nil? || reflection.options[:through].nil?\n relation = reflection.options[:through]\n acc.unshift(relation)\n end\n acc.map { |relation| definition.reflection_by_name(many_class, relation) }\n end",
"def has_many(name, class_proc)\n define_method \"#{name}=\" do |items|\n (@_has_many ||= {})[name] = items\n end\n define_method name do\n has_many_reader(name, class_proc)\n end\n end",
"def has_many(*attributes)\n attributes.each do |attr_name|\n hasManyAttributes << attr_name\n\n attr_reader attr_name.to_sym\n attribute has_many_string.concat(attr_name.to_s).to_sym\n end\n end",
"def has_many_media(context, options = {})\n set_relations(context, :has_many)\n set_general_methods\n create_many_accessors(context, options)\n end",
"def one_to_many(name, opts={})\n singular_name = name.to_s.singularize\n ids_attr = \"#{singular_name}_ids\"\n guids_attr = \"#{singular_name}_guids\"\n\n opts[:reciprocal] ||= self.name.split('::').last.underscore.to_sym\n\n define_to_many_methods(name, singular_name, ids_attr, guids_attr)\n super\n end",
"def model_relationships; end",
"def one_through_many(name, through, opts=OPTS, &block)\n associate(:one_through_many, name, opts.merge(through.is_a?(Hash) ? through : {:through=>through}), &block)\n end",
"def has_many(entities, options = {})\n entity = entities.to_s.singularize\n klass = options[:class_name] || entity.camelize\n key = options[:primary_key] || [self.name.demodulize.underscore, :id].join('_')\n from = options[:from]\n as = options[:as]\n # TODO params\n\n _define_association(entities, :has_many, class_name: klass, primary_key: key, from: from, as: as)\n end",
"def has_many(name)\n @config.root or raise NotImplementedError, \"nested associations are not supported\"\n @config.has_manys[name.to_sym] ||= Config.new\n yield self.class.new config: @config.has_manys[name.to_sym], root: false\n\n nil\n end",
"def has_many(name, class_proc)\n define_method \"#{name}=\" do |items|\n (@_has_many ||= {})[name] = items\n end\n define_method name do\n has_many_reader(name, class_proc)\n end\n end",
"def has_many_association(name)\n options = self.class.has_many_associations[name.to_sym]\n if options[:as]\n has_many_polymorphic_association(options[:as])\n elsif options[:class_name]\n has_many_association_with_custom_class_name(\n options[:class_name],\n options[:foreign_key] || self.class.name.underscore\n )\n else\n foreign_key = options[:foreign_key] || self.class.name.underscore\n name.camelize.constantize.where(\"#{foreign_key}_id\": id)\n end\n end",
"def mtm_association_names\n association_names([:many_to_many])\n end",
"def has_many(name, type, options = {})\n element name, type, { single: false }.merge(options)\n end",
"def def_many_to_many(opts)\n super\n def_association_pks_getter(opts) do\n _join_table_dataset(opts).filter(opts[:left_key]=>send(opts[:left_primary_key])).select_map(opts[:right_key])\n end\n def_association_pks_setter(opts) do |pks|\n checked_transaction do\n ds = _join_table_dataset(opts).filter(opts[:left_key]=>send(opts[:left_primary_key]))\n ds.exclude(opts[:right_key]=>pks).delete\n pks -= ds.select_map(opts[:right_key])\n pks.each{|pk| ds.insert(opts[:left_key]=>send(opts[:left_primary_key]), opts[:right_key]=>pk)}\n end\n end\n end",
"def many?\n has_many?\n end",
"def associations\r\n [nil, joins]\r\n end",
"def relationships\n @relationships ||= Relationship.from_associations(self, associations)\n end",
"def has_many(name, table_name, associated_key=nil)\n define_method(name.to_s) do\n find_by(table_name, default_has_many_key(associated_key), instance_variable_get(\"@#{primary_key}\"))\n end\n end",
"def has_many(direction, name = nil, options = { type: nil })\n if name.is_a?(Hash)\n options.merge(name)\n name = direction\n direction = nil\n elsif name.is_a?(Proc)\n name = direction\n direction = nil\n elsif name.nil?\n name = direction\n end\n reflections[name] = { direction: direction, type: options[:type], kind: :has_many }\n # @!method promise_[name]\n # @return [Promise] on success the .then block will receive a [HyperRecord::Collection] as arg\n # on failure the .fail block will receive the HTTP response object as arg\n define_method(\"promise_#{name}\") do\n @fetch_states[name] = 'i'\n self.class._promise_get(\"#{self.class.resource_base_uri}/#{self.id}/relations/#{name}.json?timestamp=#{`Date.now() + Math.random()`}\").then do |response|\n collection = self.class._convert_array_to_collection(response.json[self.class.to_s.underscore][name], self, name)\n @relations[name] = collection\n @fetch_states[name] = 'f'\n _notify_observers\n @relations[name]\n end.fail do |response|\n error_message = \"#{self.class.to_s}[#{self.id}].#{name}, a has_many association, failed to fetch records!\"\n `console.error(error_message)`\n response\n end\n end\n # @!method [name] get records of the relation\n # @return [HyperRecord::Collection] either a empty one, if the data has not been fetched yet, or the\n # collection with the real data, if it has been fetched already\n define_method(name) do\n _register_observer\n if @fetch_states.has_key?(name) && 'fi'.include?(@fetch_states[name])\n @relations[name]\n elsif self.id\n send(\"promise_#{name}\")\n @relations[name]\n else\n @relations[name]\n end\n end\n # @!method update_[name] mark internal structures so that the relation data is updated once it is requested again\n # @return nil\n define_method(\"update_#{name}\") do\n @fetch_states[name] = 'u'\n nil\n end\n # define_method(\"#{name}=\") do |arg|\n # _register_observer\n # collection = if arg.is_a?(Array)\n # HyperRecord::Collection.new(arg, self, name)\n # elsif arg.is_a?(HyperRecord::Collection)\n # arg\n # else\n # raise \"Argument must be a HyperRecord::Collection or a Array\"\n # end\n # @relations[name] = collection\n # @fetch_states[name] = 'f'\n # @relations[name]\n # end\n end",
"def is_many?\n case @reflection.macro\n when :has_many, :has_and_belongs_to_many\n true\n else\n @parent ? @parent.is_many? : false\n end\n end",
"def relationships\n model.relationships(repository.name)\n end",
"def def_many_to_many(opts)\n one_through_one = opts[:type] == :one_through_one\n left = (opts[:left_key] ||= opts.default_left_key)\n lcks = opts[:left_keys] = Array(left)\n right = (opts[:right_key] ||= opts.default_right_key)\n rcks = opts[:right_keys] = Array(right)\n left_pk = (opts[:left_primary_key] ||= self.primary_key)\n opts[:eager_loader_key] = left_pk unless opts.has_key?(:eager_loader_key)\n lcpks = opts[:left_primary_keys] = Array(left_pk)\n lpkc = opts[:left_primary_key_column] ||= left_pk\n lpkcs = opts[:left_primary_key_columns] ||= Array(lpkc)\n raise(Error, \"mismatched number of left keys: #{lcks.inspect} vs #{lcpks.inspect}\") unless lcks.length == lcpks.length\n if opts[:right_primary_key]\n rcpks = Array(opts[:right_primary_key])\n raise(Error, \"mismatched number of right keys: #{rcks.inspect} vs #{rcpks.inspect}\") unless rcks.length == rcpks.length\n end\n opts[:uses_left_composite_keys] = lcks.length > 1\n opts[:uses_right_composite_keys] = rcks.length > 1\n opts[:cartesian_product_number] ||= one_through_one ? 0 : 1\n join_table = (opts[:join_table] ||= opts.default_join_table)\n opts[:left_key_alias] ||= opts.default_associated_key_alias\n opts[:graph_join_table_join_type] ||= opts[:graph_join_type]\n opts[:after_load].unshift(:array_uniq!) if opts[:uniq]\n opts[:dataset] ||= opts.association_dataset_proc\n opts[:eager_loader] ||= opts.method(:default_eager_loader)\n \n join_type = opts[:graph_join_type]\n select = opts[:graph_select]\n use_only_conditions = opts.include?(:graph_only_conditions)\n only_conditions = opts[:graph_only_conditions]\n conditions = opts[:graph_conditions]\n graph_block = opts[:graph_block]\n graph_jt_conds = opts[:graph_join_table_conditions] = opts.fetch(:graph_join_table_conditions, []).to_a\n use_jt_only_conditions = opts.include?(:graph_join_table_only_conditions)\n jt_only_conditions = opts[:graph_join_table_only_conditions]\n jt_join_type = opts[:graph_join_table_join_type]\n jt_graph_block = opts[:graph_join_table_block]\n opts[:eager_grapher] ||= proc do |eo|\n ds = eo[:self]\n egls = eo[:limit_strategy]\n if egls && egls != :ruby\n associated_key_array = opts.associated_key_array\n orig_egds = egds = eager_graph_dataset(opts, eo)\n egds = egds.\n inner_join(join_table, rcks.zip(opts.right_primary_keys) + graph_jt_conds, :qualify=>:deep).\n select_all(egds.first_source).\n select_append(*associated_key_array)\n egds = opts.apply_eager_graph_limit_strategy(egls, egds)\n ds.graph(egds, associated_key_array.map(&:alias).zip(lpkcs) + conditions, :qualify=>:deep, :table_alias=>eo[:table_alias], :implicit_qualifier=>eo[:implicit_qualifier], :join_type=>eo[:join_type]||join_type, :from_self_alias=>eo[:from_self_alias], :join_only=>eo[:join_only], :select=>select||orig_egds.columns, &graph_block)\n else\n ds = ds.graph(join_table, use_jt_only_conditions ? jt_only_conditions : lcks.zip(lpkcs) + graph_jt_conds, :select=>false, :table_alias=>ds.unused_table_alias(join_table, [eo[:table_alias]]), :join_type=>eo[:join_type]||jt_join_type, :join_only=>eo[:join_only], :implicit_qualifier=>eo[:implicit_qualifier], :qualify=>:deep, :from_self_alias=>eo[:from_self_alias], &jt_graph_block)\n ds.graph(eager_graph_dataset(opts, eo), use_only_conditions ? only_conditions : opts.right_primary_keys.zip(rcks) + conditions, :select=>select, :table_alias=>eo[:table_alias], :qualify=>:deep, :join_type=>eo[:join_type]||join_type, :join_only=>eo[:join_only], &graph_block)\n end\n end\n \n return if opts[:read_only]\n \n if one_through_one\n opts[:setter] ||= proc do |o|\n h = {}\n lh = lcks.zip(lcpks.map{|k| get_column_value(k)})\n jtds = _join_table_dataset(opts).where(lh)\n\n checked_transaction do\n current = jtds.first\n\n if o\n new_values = []\n rcks.zip(opts.right_primary_key_methods).each{|k, pk| new_values << (h[k] = o.get_column_value(pk))}\n end\n\n if current\n current_values = rcks.map{|k| current[k]}\n jtds = jtds.where(rcks.zip(current_values))\n if o\n if current_values != new_values\n jtds.update(h)\n end\n else\n jtds.delete\n end\n elsif o\n lh.each{|k,v| h[k] = v}\n jtds.insert(h)\n end\n end\n end\n opts[:_setter] = proc{|o| set_one_through_one_associated_object(opts, o)}\n else \n opts[:adder] ||= proc do |o|\n h = {}\n lcks.zip(lcpks).each{|k, pk| h[k] = get_column_value(pk)}\n rcks.zip(opts.right_primary_key_methods).each{|k, pk| h[k] = o.get_column_value(pk)}\n _join_table_dataset(opts).insert(h)\n end\n\n opts[:remover] ||= proc do |o|\n _join_table_dataset(opts).where(lcks.zip(lcpks.map{|k| get_column_value(k)}) + rcks.zip(opts.right_primary_key_methods.map{|k| o.get_column_value(k)})).delete\n end\n\n opts[:clearer] ||= proc do\n _join_table_dataset(opts).where(lcks.zip(lcpks.map{|k| get_column_value(k)})).delete\n end\n end\n end",
"def def_many_to_many(opts)\n super\n def_bulk_setter(opts) do |list|\n cur = send(opts[:name])\n if cur\n cur.reject{ |v| v == \"\" }\n end\n instance_variable_set(\"@_#{opts[:name]}_add\", list.reject{ |v| cur.detect{ |v1| v.to_i == v1.pk } }) if cur and list\n instance_variable_set(\"@_#{opts[:name]}_remove\", cur.reject{ |v| list.detect{ |v1| v.pk == v1.to_i } }) if cur and list\n cur.replace(list)\n\n name = \"#{opts[:name]}\".singularize\n\n after_save_hook do\n instance_variable_get(\"@_#{opts[:name]}_remove\").each do |record|\n send(\"remove_#{name}\", record) if record\n end\n\n instance_variable_get(\"@_#{opts[:name]}_add\").each do |record|\n send(\"add_#{name}\", record) if record && !record.empty?\n end\n end\n end\n end",
"def set_has_many_attr(col, *instances)\n _col = column(col)\n unload_relation(_col)\n push_has_many_attr(_col, *instances)\n instances\n end",
"def def_many_through_many(opts)\n one_through_many = opts[:type] == :one_through_many\n opts[:read_only] = true\n opts[:after_load].unshift(:array_uniq!) if opts[:uniq]\n opts[:cartesian_product_number] ||= one_through_many ? 0 : 2\n opts[:through] = opts[:through].map do |e|\n case e\n when Array\n raise(Error, \"array elements of the through option/argument for many_through_many associations must have at least three elements\") unless e.length == 3\n {:table=>e[0], :left=>e[1], :right=>e[2]}\n when Hash\n raise(Error, \"hash elements of the through option/argument for many_through_many associations must contain :table, :left, and :right keys\") unless e[:table] && e[:left] && e[:right]\n e\n else\n raise(Error, \"the through option/argument for many_through_many associations must be an enumerable of arrays or hashes\")\n end\n end\n\n left_key = opts[:left_key] = opts[:through].first[:left]\n opts[:left_keys] = Array(left_key)\n opts[:uses_left_composite_keys] = left_key.is_a?(Array)\n left_pk = (opts[:left_primary_key] ||= self.primary_key)\n raise(Error, \"no primary key specified for #{inspect}\") unless left_pk\n opts[:eager_loader_key] = left_pk unless opts.has_key?(:eager_loader_key)\n opts[:left_primary_keys] = Array(left_pk)\n lpkc = opts[:left_primary_key_column] ||= left_pk\n lpkcs = opts[:left_primary_key_columns] ||= Array(lpkc)\n opts[:dataset] ||= opts.association_dataset_proc\n\n opts[:left_key_alias] ||= opts.default_associated_key_alias\n opts[:eager_loader] ||= opts.method(:default_eager_loader)\n\n join_type = opts[:graph_join_type]\n select = opts[:graph_select]\n graph_block = opts[:graph_block]\n only_conditions = opts[:graph_only_conditions]\n use_only_conditions = opts.include?(:graph_only_conditions)\n conditions = opts[:graph_conditions]\n opts[:eager_grapher] ||= proc do |eo|\n ds = eo[:self]\n iq = eo[:implicit_qualifier]\n egls = eo[:limit_strategy]\n if egls && egls != :ruby\n associated_key_array = opts.associated_key_array\n orig_egds = egds = eager_graph_dataset(opts, eo)\n opts.reverse_edges.each{|t| egds = egds.join(t[:table], Array(t[:left]).zip(Array(t[:right])), :table_alias=>t[:alias], :qualify=>:deep)}\n ft = opts.final_reverse_edge\n egds = egds.join(ft[:table], Array(ft[:left]).zip(Array(ft[:right])), :table_alias=>ft[:alias], :qualify=>:deep).\n select_all(egds.first_source).\n select_append(*associated_key_array)\n egds = opts.apply_eager_graph_limit_strategy(egls, egds)\n ds.graph(egds, associated_key_array.map(&:alias).zip(Array(lpkcs)) + conditions, :qualify=>:deep, :table_alias=>eo[:table_alias], :implicit_qualifier=>iq, :join_type=>eo[:join_type]||join_type, :join_only=>eo[:join_only], :from_self_alias=>eo[:from_self_alias], :select=>select||orig_egds.columns, &graph_block)\n else\n opts.edges.each do |t|\n ds = ds.graph(t[:table], t.fetch(:only_conditions, (Array(t[:right]).zip(Array(t[:left])) + t[:conditions])), :select=>false, :table_alias=>ds.unused_table_alias(t[:table]), :join_type=>eo[:join_type]||t[:join_type], :join_only=>eo[:join_only], :qualify=>:deep, :implicit_qualifier=>iq, :from_self_alias=>eo[:from_self_alias], &t[:block])\n iq = nil\n end\n fe = opts.final_edge\n ds.graph(opts.associated_class.dataset, use_only_conditions ? only_conditions : (Array(opts.right_primary_key).zip(Array(fe[:left])) + conditions), :select=>select, :table_alias=>eo[:table_alias], :qualify=>:deep, :join_type=>eo[:join_type]||join_type, :join_only=>eo[:join_only], &graph_block)\n end\n end\n end",
"def many_to_one(name, opts=OPTS, &block)\n associate(:many_to_one, name, opts, &block)\n end",
"def has_many(*names)\n if names.last.is_a?(Hash)\n super\n else\n names.each {|name| super name }\n end\n end",
"def relations\n self.class.relations\n end",
"def configure\n super\n create_has_many_through :subject\n end",
"def has_many(association_name, metadata={})\n\n add_association association_name, :has_many, metadata\n\n association_class_name = metadata.try(:fetch, :class_name, [name.split('::')[0..-2].join('::'), association_name.to_s.classify].reject(&:blank?).join('::'))\n\n # foos\n define_method(association_name) do |*query|\n association_class = association_class_name.constantize\n\n # TODO: Support a more generic version of lazy-loading\n if query.empty? # Ex: Books.all, so we want to cache it.\n ivar = \"@#{association_name}\"\n if instance_variable_defined?(ivar)\n instance_variable_get(ivar)\n elsif self.class.autoload_associations? && association_class.respond_to?(:all)\n instance_variable_set(ivar, Array(association_class.all(\"#{self.class.name.underscore}_id\" => id)))\n else\n []\n end\n else # Ex: Book.all(:name => \"The...\"), so we do not want to cache it\n if self.class.autoload_associations? && association_class.respond_to?(:all)\n Array(association_class.all({\"#{self.class.name.demodulize.underscore}_id\" => id}.merge(query.first)))\n end\n end\n end\n\n # foos=\n define_method(\"#{association_name}=\") do |arg|\n association_class = association_class_name.constantize\n\n attr_name = self.class.name.demodulize.underscore\n objs = (arg.is_a?(Hash) ? arg.values : Array(arg)).map do |obj|\n o = association_class.cast(obj)\n\n if o.respond_to?(\"#{attr_name}=\")\n o.send(\"#{attr_name}=\", self)\n end\n\n if o.respond_to?(\"#{attr_name}_id=\") && respond_to?(:id)\n o.send(\"#{attr_name}_id=\", id)\n end\n\n o\n end\n instance_variable_set(\"@#{association_name}\", objs)\n end\n end",
"def many_to_many_binding_name\n @many_to_many_binding_name\n end",
"def has_many(resource_name, options = {}, &block)\n root.has_many resource_name, options, block\n meta_def resource_name do |*filter|\n root.send(resource_name, *filter)\n end\n end",
"def has_many_custom_fields\n group_custom_fields('has_many') { |rule| [rule['name'], rule['inverse_of']] }\n end",
"def has_many_custom_fields\n group_custom_fields('has_many') { |rule| [rule['name'], rule['inverse_of']] }\n end",
"def allow_many?\n @allow_many == true\n end",
"def relationships\n @relationships ||= {}\n end",
"def many_to_many_custom_fields\n group_custom_fields('many_to_many') { |rule| [rule['name'], \"#{rule['name'].singularize}_ids\"] }\n end",
"def many_to_many_custom_fields\n group_custom_fields('many_to_many') { |rule| [rule['name'], \"#{rule['name'].singularize}_ids\"] }\n end",
"def has_and_belongs_to_many_valid?(relation)\n relation = klass.reflect_on_association(relation)\n\n return true if relation[:relation] ==\n ::Mongoid::Relations::Referenced::ManyToMany\n\n invalid_relation(\n ::Mongoid::Relations::Referenced::ManyToMany,\n relation[:relation]\n )\n end",
"def _many_to_many_table_name(attr_name)\n _many_to_many_hash[attr_name][:table_name] ||= self.name + \"_\" + _many_to_many_hash[attr_name][:class_name]\n end",
"def has_many_relations(ar_instance)\n\t\t\tcolumn_name = \"#{ar_instance.class.name.underscore}_id\"\n\t\t\tdescendents = ActiveRecord::Base.connection.tables\n\t\t\tdescendents.reject!{ |table| false unless table.classify.constantize rescue true }\n\t\t\tdescendents.reject!{ |table| true unless table.classify.constantize.column_names.include?(column_name) }\n\t\tend",
"def is_relationship?\n %w(belongs_to has_many many_to_many).include?(self.type.to_s)\n end",
"def have_many(models)\n HasManyReflection.new models\nend",
"def add_relationship(rel_attr); end",
"def many_to_one_relationships\n relationships unless @relationships # needs to be initialized!\n @relationships.values.collect do |rels| rels.values end.flatten.select do |relationship| relationship.child_model == self end\n end",
"def have_and_belong_to_many(models)\n HasAndBelongsToManyReflection.new models\nend",
"def list_relationships\n end",
"def set_many_alumnos_has_many_asignatura\n @many_alumnos_has_many_asignatura = ManyAlumnosHasManyAsignatura.find(params[:id])\n end",
"def has_many(from_klass, to_klass)\n all_has_many = from_klass.relations.map(&:second).select do |r| \n r.macro == :has_many && r.class_name == to_klass.to_s\n end.map(&:class_name)\n end",
"def _many_to_many_hash\n @_many_to_many_hash ||= {}\n end",
"def manymany(attribute_name, classes, options)\n define_method attribute_name do\n get_fauxsql_manymany(attribute_name, classes, options)\n end\n end",
"def relations\n _relations\n end",
"def relations\n _relations\n end",
"def child_relation; end",
"def has_many(name, options = {})\n # get klass:Class from classname:String\n classname = name.to_s.chop.capitalize\n\n klass = options[:klass] || classname.to_class(Base)\n xpath = options[:xpath] || \"#{name.to_s.chop.upcase}\"\n sort = options[:sort] || plugin_name\n enumerator = options[:enumerator] || Base::Enumerator\n debug \"Create Has_Many #{name} use enumerator #{enumerator} sort #{sort}\"\n\n safe_define_method name do |options = {}|\n options[:xpath] = xpath\n enumerator.new klass, sort, @data, options\n end\n end",
"def binding\n HasMany::Binding.new(_base, _target, _association)\n end",
"def relations\n @relations ||= {}\n end",
"def a_tag_has_many_of_these_through_taggings\n ::Tag.class_exec(name, name.demodulize.underscore.pluralize.to_sym) do |class_name, association_name|\n has_many association_name, through: :taggings,\n class_name: class_name,\n source: :taggable,\n source_type: class_name\n end\n end",
"def link_has_many(reflection)\n \"#{reflection.name.to_s.singularize}_ids\".to_sym\n end"
] | [
"0.78585994",
"0.77024937",
"0.764495",
"0.7631497",
"0.7570364",
"0.74782395",
"0.7425874",
"0.74113977",
"0.72593075",
"0.72062",
"0.6999131",
"0.6997127",
"0.6950218",
"0.6950218",
"0.6942962",
"0.6910537",
"0.6900084",
"0.6857081",
"0.67642456",
"0.67569685",
"0.6743898",
"0.6730337",
"0.67096615",
"0.6687129",
"0.66840965",
"0.6652536",
"0.6640939",
"0.6622301",
"0.6620976",
"0.6611768",
"0.65914804",
"0.6582278",
"0.65459305",
"0.65380836",
"0.6512655",
"0.6507624",
"0.65037733",
"0.64996934",
"0.6473377",
"0.6441038",
"0.64112735",
"0.6354364",
"0.6342365",
"0.6334777",
"0.6322117",
"0.63094145",
"0.63070667",
"0.6274901",
"0.62142104",
"0.61936885",
"0.6171844",
"0.61667097",
"0.61634636",
"0.61538327",
"0.6132975",
"0.60927343",
"0.60908467",
"0.6084217",
"0.60738033",
"0.6060948",
"0.6060376",
"0.60570997",
"0.605582",
"0.60525197",
"0.6039959",
"0.603361",
"0.6023847",
"0.59917",
"0.5988279",
"0.5972088",
"0.5947897",
"0.5938171",
"0.5935524",
"0.59293354",
"0.59293354",
"0.5928418",
"0.592802",
"0.5913288",
"0.5913288",
"0.59101546",
"0.5905891",
"0.5904465",
"0.59005404",
"0.5887154",
"0.5879292",
"0.5849346",
"0.5848054",
"0.58174765",
"0.58154446",
"0.58010703",
"0.5794387",
"0.57918024",
"0.57886654",
"0.57886654",
"0.5761724",
"0.5757439",
"0.5752339",
"0.571988",
"0.57094526",
"0.5698185"
] | 0.75441444 | 5 |
Defines a single relationship. | def has_one(*attrs)
associate(:has_one, attrs)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def one_relationship(name)\n end",
"def relationship=(value)\n @relationship = value\n end",
"def add_relationship(rel_attr); end",
"def relationship(rel_class)\n @relationship = rel_class\n self\n end",
"def set_relationship\n @relationship = Relationship.find(params[:id])\n end",
"def set_relationship\n @relationship = Relationship.find(params[:id])\n end",
"def set_relationship\n @relationship = Relationship.find(params[:id])\n end",
"def set_relationship\n @relationship = Relationship.find(params[:id])\n end",
"def set_relationship\n @relationship = Relationship.find(params[:id])\n end",
"def set_relationship\n @relationship = Relationship.find(params[:id])\n end",
"def set_relationship\n @relationship = Relationship.find(params[:id])\n end",
"def set_relationship\n @relationship = Relationship.find(params[:id])\n end",
"def set_relationship\n @relationship = Relationship.find(params[:id])\n end",
"def relationship(rel_class)\n @relationship = rel_class\n self\n end",
"def relationship\n relationship? ? children[1] : nil\n end",
"def relationship\n Relationship.new(self, CHART_R, \"../#{pn}\")\n end",
"def set_relationship\n #find relationship\n @relationship = Relationship.find_by_id(params[:id])\n end",
"def relationship(sym)\n self.class.relationship(sym)\n end",
"def relationship\n return @relationship\n end",
"def relationship\n response[\"relationship\"]\n end",
"def relationship( name, &block )\n require_identifier!\n return if context.linkage_only?\n\n include_or_mark_partial name do\n builder = RelationshipBuilder.new( context )\n yield builder\n\n relationships = ( output[:relationships] ||= {} )\n relationships[ name.to_sym ] = builder.compile\n end\n end",
"def has_one(relation, options = {})\n has :one, relation, options\n end",
"def one_to_many_relationship(rel_name, definition)\n @relationships << OneToManyRelationship.new(rel_name, definition)\n end",
"def define_relationship(opts)\n [:name, :contains_references_to_types].each do |p|\n opts[p] or raise \"No #{p} given\"\n end\n\n base = self\n\n ArchivesSpaceService.loaded_hook do\n # We hold off actually setting anything up until all models have been\n # loaded, since our relationships may need to reference a model that\n # hasn't been loaded yet.\n #\n # This is also why the :contains_references_to_types property is a proc\n # instead of a regular array--we don't want to blow up with a NameError\n # if the model hasn't been loaded yet.\n\n\n related_models = opts[:contains_references_to_types].call\n\n clz = Class.new(AbstractRelationship) do\n table = \"#{opts[:name]}_rlshp\".intern\n set_dataset(table)\n set_primary_key(:id)\n\n if !self.db.table_exists?(self.table_name)\n Log.warn(\"Table doesn't exist: #{self.table_name}\")\n end\n\n set_participating_models([base, *related_models].uniq)\n set_json_property(opts[:json_property])\n set_wants_array(opts[:is_array].nil? || opts[:is_array])\n end\n\n opts[:class_callback].call(clz) if opts[:class_callback]\n\n @relationships[opts[:name]] = clz\n\n related_models.each do |model|\n model.include(Relationships)\n model.add_relationship_dependency(opts[:name], base)\n end\n\n # Give the new relationship class a name to help with debugging\n # Example: Relationships::ResourceSubject\n Relationships.const_set(self.name + opts[:name].to_s.camelize, clz)\n\n end\n end",
"def has_one(rel_type, params = {})\n clazz = self\n module_eval(%Q{def #{rel_type}=(value)\n dsl = #{clazz}.decl_relationships[:'#{rel_type.to_s}']\n r = Neo4j::Relationships::HasN.new(self, dsl)\n r.each {|n| n.del} # delete previous relationships, only one can exist\n r << value\n r\n end}, __FILE__, __LINE__)\n\n module_eval(%Q{def #{rel_type}\n dsl = #{clazz}.decl_relationships[:'#{rel_type.to_s}']\n r = Neo4j::Relationships::HasN.new(self, dsl)\n [*r][0]\n end}, __FILE__, __LINE__)\n\n module_eval(%Q{\n def #{rel_type}_rel\n dsl = #{clazz}.decl_relationships[:'#{rel_type.to_s}']\n r = Neo4j::Relationships::HasN.new(self, dsl).rels\n [*r][0]\n end}, __FILE__, __LINE__)\n\n decl_relationships[rel_type.to_sym] = Neo4j::Relationships::DeclRelationshipDsl.new(rel_type, params)\n end",
"def configure_relation\n end",
"def relation(rel, &relation_definition)\n raise NotImplementedError, 'relation is not supported yet'\n end",
"def relation\n raise NotImplementedError\n end",
"def relationship(sym)\n if @relationships\n @relationships[sym]\n else\n self.class.relationship(sym)\n end\n end",
"def relationship_related_link(attribute_name); end",
"def relationship(*args)\n options = args.extract_options!\n if options[:raise_on_multiple]\n rels = relationships.take(2)\n raise _(\"Multiple relationships found\") if rels.length > 1\n rels.first\n else\n relationships.first\n end\n end",
"def related_attrs\n relationship = flex_options[:relationship_name]\n send relationship\n end",
"def child_relation; end",
"def set_firend_relationship\n @firend_relationship = FirendRelationship.find(params[:id])\n end",
"def target\n relation\n end",
"def target\n relation\n end",
"def has_one(rel_type)\n\n module_eval(%Q{def #{rel_type}=(value)\n r = Relations::HasN.new(self,'#{rel_type.to_s}')\n r << value\n end}, __FILE__, __LINE__)\n \n module_eval(%Q{def #{rel_type}\n r = Relations::HasN.new(self,'#{rel_type.to_s}')\n r.to_a[0]\n end}, __FILE__, __LINE__)\n relations_info[rel_type] = Relations::RelationInfo.new\n end",
"def has_one(*args)\n require \"og/relation/has_one\"\n relations! << Og::HasOne.new(args, :owner_class => self)\n end",
"def set_family_relationship\n @family_relationship = FamilyRelationship.find(params[:id])\n end",
"def belongs_to name, opts={}\n opts.merge! :type => :belongs_to, :from => self\n relation = FAP::Relation.new name, opts\n self.relations << relation\n define_relation_getter relation\n end",
"def has_one(*attrs)\n associate(Associations::HasOne, attrs)\n end",
"def inverse_class\n ManyToOne::Relationship\n end",
"def inverse_class\n ManyToOne::Relationship\n end",
"def initialize(relationship=\"relationship\", *args)\n @relationship = relationship\n super\n end",
"def relationship(sym, klass=nil, kinds=[])\n if klass\n relationships[sym] = Relationship.new(sym, klass, kinds)\n else\n relationships[sym]\n end\n end",
"def create_relation(object, metadata)\n type = @attributes[metadata.inverse_type]\n target = metadata.builder(self, object).build(type)\n target ? metadata.relation.new(self, target, metadata) : nil\n end",
"def relationships\n @relationships ||= {}\n end",
"def relationship_constraint(operator, lhs_operand, rhs_operand, options = {}, &block)\n constraint = RelationshipConstraint.new(self, operator, lhs_operand, rhs_operand, options, &block)\n add_unique_to_set(\"relationship\", constraint, @relationship_constraints)\n end",
"def relation\n Proxy\n end",
"def relation\n Proxy\n end",
"def relation\n Proxy\n end",
"def has_one(goal, options = { })\n goal.belongs_to(self) unless options[:skip_belongs_to]\n self.associate(:has_one, goal, options)\n end",
"def add_worksheet_relationship(type, target, target_mode = nil)\n @rels.push([Document_schema + type, target, target_mode])\n end",
"def one_to_one(name, opts=OPTS, &block)\n associate(:one_to_one, name, opts, &block)\n end",
"def new(other)\n @decl_rel.create_relationship_to(@node, other)\n end",
"def relation\n relation = nodes.reduce(root) do |a, e|\n a.associations[e.name.key].join(:join, a, e)\n end\n schema.(relation)\n end",
"def model_relationships; end",
"def initialize(attrs={})\n @attrs = attrs[:relationship]\n end",
"def attach_relationship(data) #FIXME: Method doesn't work, RelationshipManager cannot access to id attribute.\n return @client.raw(\"post\", \"/config/relationships/attach\", nil, data)\n end",
"def is_relationship?\n %w(belongs_to has_many many_to_many).include?(self.type.to_s)\n end",
"def make_inter_relationship(rel_id,rel_entity_type_id,object_id,rel_type_id)\n entity_type=EntityType.entityIdToType(rel_entity_type_id)\n type=Inflector.camelize(entity_type)\n logger.debug(\"TYPE: #{type}\")\n #special case\n #if type.to_s=='DistinctionInstance'\n # @inter_rel=DistinctionRelationship.new()\n #else\n @inter_rel=eval(type+'Relationship.new()')\n #end\n \n @inter_rel.relationship_id=rel_id\n eval('@inter_rel.'+entity_type+'_id=object_id')\n @inter_rel.relationship_type_id=rel_type_id\n return @inter_rel.save()\n end",
"def add_ms_package_relationship(type, target)\n schema = 'http://schemas.microsoft.com/office/2006/relationships'\n @rels.push([schema + type, target])\n end",
"def add_relationship(parent_rel = nil)\n clear_relationships_cache\n all_relationships.create!(\n :relationship => (parent_rel.nil? ? relationship_type : parent_rel.relationship),\n :parent => parent_rel\n )\n end",
"def relation(*args, &block)\n boot.relation(*args, &block)\n end",
"def init_relationship(parent_rel = nil)\n rel = relationship\n if rel.nil?\n rel = add_relationship(parent_rel)\n elsif !parent_rel.nil?\n rel.update_attribute(:parent, parent_rel)\n end\n rel\n end",
"def get_source_relationship(options)\n options[:relationship]&.to_sym || @request.resource_klass._type\n end",
"def initialize(name, target_model, source_model, options = {})\n klass = options.key?(:through) ? ManyToMany::Relationship : OneToMany::Relationship\n target_model ||= Extlib::Inflection.camelize(name).freeze\n @relationship = klass.new(name, target_model, source_model, options)\n end",
"def set_RelationshipType(value)\n set_input(\"RelationshipType\", value)\n end",
"def create_relation(node, target_type)\n relation = @factory.new_relation\n \n # Read all defined data fields\n if node.attributes['direction']\n relation.direction = node.attributes['direction'].to_sym\n else\n relation.direction = Model::Relation::DIR_BOTH\n end\n \n if node.attributes['type']\n relation.type = Utils.add_namespace(node.attributes['type'], Model::NS_REL_1)\n end\n \n relation.begin_date = read_date_attribute(node, 'begin')\n relation.end_date = read_date_attribute(node, 'end')\n \n if node.attributes['attributes']\n node.attributes['attributes'].split(' ').each {|attribute|\n relation.attributes << Utils.add_namespace(attribute, Model::NS_REL_1)\n }\n end\n \n # Set the target. Either use the target included in the relation\n # or create a new target according to the target type if no target\n # is present.\n case target_type\n when Model::Relation::TO_ARTIST\n if node.elements['artist']\n target = create_artist node.elements['artist']\n else\n target = @factory.new_artist\n target.id = Model::MBID.parse(node.attributes['target'], :artist)\n end\n when Model::Relation::TO_RELEASE\n if node.elements['release']\n target = create_release node.elements['release']\n else\n target = @factory.new_release\n target.id = Model::MBID.parse(node.attributes['target'], :release)\n end\n when Model::Relation::TO_TRACK\n if node.elements['track']\n target = create_track node.elements['track']\n else\n target = @factory.new_track\n target.id = Model::MBID.parse(node.attributes['target'], :track)\n end\n when Model::Relation::TO_LABEL\n if node.elements['label']\n target = create_label node.elements['label']\n else\n target = @factory.new_label\n target.id = Model::MBID.parse(node.attributes['target'], :label)\n end\n when Model::Relation::TO_URL\n target = node.attributes['target']\n end\n \n relation.target = target\n \n return relation\n end",
"def belongs_to(goal, options = { })\n self.foreign_keys[goal.foreign_key] = \"references\"\n self.validates(:presence_of, goal.foreign_key)\n self.associate(:belongs_to, goal, options)\n end",
"def has_one(name, scope = nil, **options)\n # args = options.except(:null_object)\n\n # Call the real belongs_to so that the association gets defined.\n super(name, scope, **options.except(:null_object))\n\n # Modify the association if need be.\n if options[:null_object]\n add_null_object_support(name, options)\n end\n end",
"def relation_of(field)\n meta = meta_of(field)\n meta ? meta.relation : nil\n end",
"def macro\n :belongs_to_related\n end",
"def belongs_to_list(rel_type, params = {})\n decl_relationships[rel_type] = Neo4j::Relationships::DeclRelationshipDsl.new(rel_type, params)\n end",
"def relationship(user)\n Following.where(:follower_id => self, :followed_id => user).first.try(:relationship)||\"none\"\n end",
"def create_relationship_attribute(database_id:, collection_id:, related_collection_id:, type:, two_way: nil, key: nil, two_way_key: nil, on_delete: nil)\n path = '/databases/{databaseId}/collections/{collectionId}/attributes/relationship'\n .gsub('{databaseId}', database_id)\n .gsub('{collectionId}', collection_id)\n\n if database_id.nil?\n raise Appwrite::Exception.new('Missing required parameter: \"databaseId\"')\n end\n\n if collection_id.nil?\n raise Appwrite::Exception.new('Missing required parameter: \"collectionId\"')\n end\n\n if related_collection_id.nil?\n raise Appwrite::Exception.new('Missing required parameter: \"relatedCollectionId\"')\n end\n\n if type.nil?\n raise Appwrite::Exception.new('Missing required parameter: \"type\"')\n end\n\n params = {\n relatedCollectionId: related_collection_id,\n type: type,\n twoWay: two_way,\n key: key,\n twoWayKey: two_way_key,\n onDelete: on_delete,\n }\n \n headers = {\n \"content-type\": 'application/json',\n }\n\n @client.call(\n method: 'POST',\n path: path,\n headers: headers,\n params: params,\n response_type: Models::AttributeRelationship\n )\n end",
"def link_has_one(reflection)\n reflection.name\n end",
"def set_user_relationship\n @user_relationship = UserRelationship.find(params[:id])\n end",
"def create_relationship(destiny, label, bidirectional=true, active=false)\n return false if destiny.nil? or destiny == self\n edge_class = ModelFabric.get_class(SocialFramework.edge_class)\n\n edge = edge_class.where([\"(origin_id = :origin_id AND destiny_id = :destiny_id OR \n destiny_id = :origin_id AND origin_id = :destiny_id) AND label = :label\",\n { origin_id: self.id, destiny_id: destiny.id, label: label }]).first\n\n if edge.nil?\n edge = edge_class.create origin: self, destiny: destiny, active: active,\n bidirectional: bidirectional, label: label\n\n return (not edge.nil?)\n end\n\n return false\n end",
"def set_survey_question_relationship\n @survey_question_relationship = SurveyQuestionRelationship.find(params[:id])\n end",
"def set_relation\n @relation = Relation.find(params[:id])\n end",
"def set_relation\n @relation = Relation.find(params[:id])\n end",
"def show\n @relationship = Relationship.new\nend",
"def add_document_relationship(type, target, target_mode = nil)\n @rels.push([Document_schema + type, target, target_mode])\n end",
"def relation(relation)\n true\n end",
"def has_one(direction, name = nil, options = { type: nil })\n if name.is_a?(Hash)\n options.merge(name)\n name = direction\n direction = nil\n elsif name.is_a?(Proc)\n name = direction\n direction = nil\n elsif name.nil?\n name = direction\n end\n reflections[name] = { direction: direction, type: options[:type], kind: :has_one }\n # @!method promise_[name]\n # @return [Promise] on success the .then block will receive a [HyperRecord::Collection] as arg\n # on failure the .fail block will receive the HTTP response object as arg\n define_method(\"promise_#{name}\") do\n @fetch_states[name] = 'i'\n self.class._promise_get(\"#{self.class.resource_base_uri}/#{self.id}/relations/#{name}.json?timestamp=#{`Date.now() + Math.random()`}\").then do |response|\n @relations[name] = self.class._convert_json_hash_to_record(response.json[self.class.to_s.underscore][name])\n @fetch_states[name] = 'f'\n _notify_observers\n @relations[name]\n end.fail do |response|\n error_message = \"#{self.class.to_s}[#{self.id}].#{name}, a has_one association, failed to fetch records!\"\n `console.error(error_message)`\n response\n end\n end\n # @!method [name] get records of the relation\n # @return [HyperRecord::Collection] either a empty one, if the data has not been fetched yet, or the\n # collection with the real data, if it has been fetched already\n define_method(name) do\n _register_observer\n if @fetch_states.has_key?(name) && 'fi'.include?(@fetch_states[name])\n @relations[name]\n elsif self.id\n send(\"promise_#{name}\")\n @relations[name]\n else\n @relations[name]\n end\n end\n # @!method update_[name] mark internal structures so that the relation data is updated once it is requested again\n # @return nil\n define_method(\"update_#{name}\") do\n @fetch_states[name] = 'u'\n nil\n end\n # define_method(\"#{name}=\") do |arg|\n # _register_observer\n # @relations[name] = arg\n # @fetch_states[name] = 'f'\n # @relations[name]\n # end\n end",
"def many_to_one(name, opts=OPTS, &block)\n associate(:many_to_one, name, opts, &block)\n end",
"def set_program_relationship\n @program_relationship = ProgramRelationship.find(params[:id])\n end",
"def relation(related, arguments=[])\n self.send(related.to_sym)\n end",
"def make_related(parent, child, resource_config)\n proc = resource_config[:relation][:create]\n proc.call(parent, child) if proc\n child\n end",
"def relation(name, &block)\n if @resource_config[:relation][name]\n raise DefinitionError, \"relation #{name.inspect} already declared in #{self}\"\n end\n @resource_config[:relation][name] = block\n end",
"def relate(attribute_name, options = {})\n options[:to] ||= '*'\n store_relation_mapping(options[:to], Internal::MappingFactory.build_relation(attribute_name, options))\n end",
"def relationship_set_property id, name, value\n headers = {\n 'Accept' => 'application/json; charset=UTF-8',\n }\n\n put_request 'relationship/' + id + '/properties/' + name, value, headers\n end",
"def association\n relation(source).associations[target]\n end",
"def set_taxon_name_relationship\n @taxon_name_relationship = TaxonNameRelationship.find(params[:id])\n end",
"def get_relationship_by_id id\n headers = {\n 'Accept' => 'application/json; charset=UTF-8',\n }\n get_request 'relationship/' + id, headers\n end",
"def lookup_relationship_type(name=self.name)\n relationship_types = Settings.relationship_types\n return relationship_types[name]\n end",
"def foreign_key\n meta(foreign_key: true)\n end",
"def belongs_to(relation)\n add_field relation, :belongs_to\n add_field generate_belongs_to_id(relation), :belongs_to_id # a relation is singular.\n end",
"def replace_to_one_relationship(source_record:, new_related_record:, relationship_type:)\n relationship_method = \"replace_#{relationship_type}?\"\n authorize_relationship_operation(\n source_record: source_record,\n relationship_method: relationship_method,\n related_record_or_records: new_related_record\n )\n end"
] | [
"0.82040167",
"0.7669557",
"0.7382287",
"0.72430265",
"0.7090946",
"0.7090946",
"0.7090946",
"0.7090946",
"0.7090946",
"0.7090946",
"0.7090946",
"0.7090946",
"0.7090946",
"0.7059134",
"0.69488704",
"0.68549126",
"0.6850454",
"0.67201585",
"0.6702721",
"0.6694518",
"0.65845454",
"0.654627",
"0.6515691",
"0.6497866",
"0.6489918",
"0.6453092",
"0.6452152",
"0.6431983",
"0.6428295",
"0.6399226",
"0.6361595",
"0.6336177",
"0.631033",
"0.6283293",
"0.62821704",
"0.62821704",
"0.625671",
"0.6248699",
"0.6238535",
"0.6232579",
"0.623044",
"0.6203351",
"0.6203351",
"0.61811393",
"0.6176861",
"0.61756414",
"0.61659473",
"0.6152967",
"0.61472",
"0.61472",
"0.61472",
"0.6137246",
"0.6111522",
"0.609911",
"0.60866004",
"0.60747546",
"0.60595804",
"0.6038998",
"0.6025125",
"0.6002566",
"0.60003483",
"0.5985609",
"0.5976997",
"0.5972822",
"0.59619945",
"0.5939969",
"0.59278625",
"0.59274507",
"0.59218097",
"0.5919414",
"0.59179395",
"0.59160507",
"0.591195",
"0.5908678",
"0.59084356",
"0.5903577",
"0.5898971",
"0.5894528",
"0.5892407",
"0.58853805",
"0.5865761",
"0.5865761",
"0.58633155",
"0.58631647",
"0.58589053",
"0.5845704",
"0.5833017",
"0.581938",
"0.5812105",
"0.5808924",
"0.5807983",
"0.5804737",
"0.57896507",
"0.57884526",
"0.5787027",
"0.57819176",
"0.57773644",
"0.5776779",
"0.576449",
"0.57555556"
] | 0.6140535 | 51 |
Helper method that returns the names of defined associations. | def association_names
self.class._associations.keys
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def associations\n association_reflections.keys\n end",
"def association_names\n @association_names ||= []\n end",
"def model_association_names\n return unless model_associations\n\n model_associations.map do |assoc|\n assoc.name.to_sym\n end\n end",
"def associations_class_names\n self.associations.map{|name,association|\n association.class_name\n }\n end",
"def association_names(types=SUPPORTED_ASSOCIATION_TYPES)\n model.all_association_reflections.\n select{|r| types.include?(r[:type]) && (!block_given? || yield(r))}.\n map{|r| r[:name]}.\n sort_by(&:to_s)\n end",
"def hm_associations\n hm = []\n associations = self.reflect_on_all_associations\n associations.map {|x| hm << x.name if x.macro.to_s == \"has_many\"}\n return hm.flatten\n end",
"def associations\n @associations ||= [].tap do |fields|\n @model.reflect_on_all_associations.each do |association|\n fields << resolve(association.macro, association.name)\n end\n end\n end",
"def associations\r\n [nil, joins]\r\n end",
"def associations_array\n resource.reflect_on_all_associations.map { |association| association.name.to_s }\n end",
"def associations\n model.relationships.to_a.collect { |name,rel|\n {\n :name => name.to_s,\n :type => association_type_lookup( rel ), # :has_many, :has_one, or :belongs_to\n :parent_model => rel.parent_model,\n :parent_key => rel.parent_key.collect { |p| p.name },\n :child_model => rel.child_model,\n :child_key => rel.child_key.collect { |p| p.name },\n :remote_rel => rel.options[:remote_relationship_name],\n :near_rel => rel.options[:near_relationship_name]\n }\n }\n end",
"def associations\n @associations ||= {}.with_indifferent_access\n end",
"def associations\n @associations ||= {}\n end",
"def associations\n data[:associations]\n end",
"def associations\n @associations ||= Hash[metadata.xpath('//Association').collect do |association_definition|\n [\n association_definition.attributes['Name'].value,\n build_association(association_definition)\n ]\n end]\n end",
"def _associations\n returned = @associations & [*@opts[:associations]].map(&:to_sym)\n\n # Stop here unless we want to throw exceptions for bad associations.\n return returned unless QuirkyApi.validate_associations\n\n # Find invalid associations and throw an exception for them.\n if returned.blank? || returned.length != [*@opts[:associations]].length\n ([*@opts[:associations]].map(&:to_sym) - @associations).each do |assoc|\n fail InvalidAssociation,\n \"The '#{assoc}' association does not exist.\"\n end\n end\n\n returned\n end",
"def relation_names(inclusions)\n inclusions.is_a?(Hash) ? inclusions.keys : Array.wrap(inclusions)\n end",
"def mtm_association_names\n association_names([:many_to_many])\n end",
"def associations\n association_ids = model.association_field_ids\n data.select{|k,v| association_ids.include?(k.to_s) }\n end",
"def associations\n # is caching ok?\n unless @associations\n @associations = {}\n klass.relations.each{|name,association|\n @associations[name.to_s] = Association.new(association,self)\n }\n end\n @associations\n end",
"def associations; end",
"def all_association_reflections\n association_reflections.values\n end",
"def has_associations\n assocs.each_rel.to_a\n end",
"def associations_scope\n model_class_name.constantize.all\n end",
"def associations_scope\n model_class_name.constantize.all\n end",
"def resource_associations(association_type)\n resource_class.reflect_on_all_associations(association_type).map(&:name)\n end",
"def linked_associations\n associations.values.select(&:linked?)\n end",
"def associations\n return [] unless self.included_modules.include?(Revisionary::Core)\n [self.revisionary_options[:with]].flatten\n end",
"def associations_foreigns\n _reflections.map do |_, reflection|\n cols = [reflection.foreign_key]\n cols << reflection.foreign_type if reflection.polymorphic?\n cols\n end.flatten\n end",
"def get_associations(node)\n node.class.reflect_on_all_associations.select do |assoc|\n [:destroy, :delete_all].include?(assoc.options[:dependent]) &&\n [:has_many, :has_one].include?(assoc.macro)\n end\n end",
"def model_relationships\n hash = ActiveSupport::OrderedHash.new\n reflect_on_all_associations.map { |i| hash[i.name] = i.macro }\n return hash\n end",
"def __belongs_to__\n\t\treturn_string = []\n\t\tself.class.reflect_on_all_associations(:belongs_to).each do |association| \n\t\t\tmodel = self.send(association.name)\n\t\t\tif model\n\t\t\t\treturn_string.push model.reference_attribute \n\t\t\tend\n\t\tend\n\t\treturn_string.join \" \"\n\tend",
"def joins\n j = []\n associations.each do |association|\n next if association.conditions.blank?\n association_joins = association.joins\n j << (association_joins.blank? ? association.relationship_name.to_sym : {association.relationship_name.to_sym => association_joins})\n end\n j.blank? ? nil : (j.size == 1 ? j.first : j)\n end",
"def included_associations\n @included_associations ||= begin\n self.options[:include_associations] ||= []\n self.options[:include_associations].collect(&:to_sym)\n end\n end",
"def authorizable_ransackable_associations\n reflect_on_all_associations.map { |a| a.name.to_s }\n end",
"def visible_relations \n\t\t\tif defined? @visible_relations \n\t\t\t\t@visible_relations\n\t\t\telse\n\t\t\t\tassociation_helper_models = []\n\t\t\t\t# find \n\t\t\t\tself.reflections.keys.each do |key|\n\t\t\t\t\tif self.reflections[key].class == ActiveRecord::Reflection::ThroughReflection\n\t\t\t\t\t\tassociation_helper_models.push self.reflections[key].options[:through]\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\tkeys = self.reflections.keys.map do |key| key.to_sym end\n keys - association_helper_models\n\t\t\tend\n\t\tend",
"def scaf_belongs_tos\n scaf_assocs.select { |a|\n [:belongs_to].include?( a.macro )\n }\n end",
"def name\n association.name\n end",
"def all_associations\n @all_associations ||= (\n # field associations\n @fields.collect { |field|\n field.associations.values\n }.flatten +\n # attribute associations\n @attributes.collect { |attrib|\n attrib.associations.values\n }.flatten\n ).uniq.collect { |assoc|\n # get ancestors as well as column-level associations\n assoc.ancestors\n }.flatten.uniq\n end",
"def exposed_associations\n []\n end",
"def exposed_associations\n []\n end",
"def exposed_associations\n []\n end",
"def exposed_associations\n []\n end",
"def associations; self.class.class_eval(\"@@associations\") end",
"def association_keys\n association\n .__send__(:join_key_map, container.relations)\n end",
"def association_reflection(name)\n association_reflections[name]\n end",
"def reflect_on_all_associations(*macros)\n relations.values.select { |meta| macros.include?(meta.macro) }\n end",
"def association_foreign_keys(assoc_record)\n association_foreign_keys_names.map { |name| assoc_record.public_send(name) }\n end",
"def all_associations(opts={})\n associations = self.models.map {|m| m.association_fields}.flatten\n if opts[:unique]\n unique_codes = associations.map {|a| a[:code] }.uniq\n unique_associations = []\n associations.each do |a|\n if unique_codes.include?(a[:code])\n unique_associations << a\n unique_codes.delete(a[:code])\n end\n end\n return unique_associations\n else\n return associations\n end\n end",
"def scaffold_associations\n @scaffold_associations ||= reflect_on_all_associations.collect{|r|r.name.to_s unless (r.options.include?(:through) || r.options.include?(:polymorphic))}.compact.sort\n end",
"def autoreport_association_name_columns(reflection)\n %w(name email title)\n end",
"def event_associations\n Hash[event_types.map do |type|\n association = send(:\"#{type}_events\")\n [type.to_s.pluralize.to_sym, association]\n end]\n end",
"def embedded_associations\n associations.values.select(&:embedded?)\n end",
"def association_fields\n fields.select{|f| f.is_a?(AssociationField)}\n end",
"def all_associations(opts={})\n associations = self.models.map {|m| m.associations}.flatten\n if opts[:unique]\n unique_codes = associations.map {|a| a[:code] }.uniq\n unique_associations = []\n associations.each do |a|\n if unique_codes.include?(a[:code])\n unique_associations << a\n unique_codes.delete(a[:code])\n end\n end\n return unique_associations\n else\n return associations\n end\n end",
"def has_many_reflections\n @current_class.reflections.inject([]) do |mem, pair|\n name, reflection = pair\n next mem unless [:has_many, :has_and_belongs_to_many].include?(reflection.macro)\n mem << [name, reflection.class_name]\n mem\n end.sort { |a, b| a.first.to_s <=> b.first.to_s }\n end",
"def editable_mtm_association_names\n association_names([:many_to_many]) do |r|\n model.method_defined?(r.add_method) && model.method_defined?(r.remove_method)\n end\n end",
"def belong_tables(model)\n model.reflect_on_all_associations(:belongs_to).map do |belong|\n belong.name.to_s.pluralize\n end.sort\n end",
"def association_paths\n @engine_association_paths ||= get_model_association_paths\n engine_association_paths.dup\n end",
"def attr_associations\n @attr_associations\n end",
"def identify_single_through_associations\n return reflect_on_all_associations.select { |a|\n (a.macro == :has_one) && !a.options[:through].blank? }.map { |a|\n a.name.to_s\n }\n end",
"def preloadable_associations\n @@preloadable_associations[self.name] ||= \n reflect_on_all_associations.reject{|a| a.options[:polymorphic] || a.macro == :has_many}.map(&:name)\n end",
"def associations\n @associations.dup\n end",
"def associations_hash\n @associations_hash ||= {\n has_many: [],\n belongs_to: []\n }\n end",
"def association_columns(*by_associations) #:nodoc:\n if @object.present?\n @object.class.reflections.collect do |name, _|\n if by_associations.present?\n name if by_associations.include?(_.macro)\n else\n name\n end\n end.compact\n else\n []\n end\n end",
"def get_belongs_tos_for(model_name)\n associations.select { |a| a.name == model_name }.map(&:belongs_to_model)\n end",
"def reflections_for(main, rel)\n main.class\n .reflect_on_all_associations\n .select { |r| r.macro == rel && r.options[:through].nil? }\n end",
"def iteration_associations\n [].freeze\n end",
"def associations_for(aName, aScope = nil)\n unless aName.kind_of?(String)\n raise StandardError, \"Invalid argument #{aName}\"\n end\n if aScope\n raise NotImplementedError\n else\n vr = symbol_table.lookup(aName)\n blackboard.associations_for(vr.i_name, true)\n end\n end",
"def parsed_associations\n parsed_include(:include)\n end",
"def inverse_association_classes\n Mongoid::Config.models.map { |m| inverse_association(m) }.compact.map(&:inverse_class)\n end",
"def association_columns(*by_associations) #:nodoc:\n if @object.present? && @object.class.respond_to?(:reflections)\n @object.class.reflections.collect do |name, association_reflection|\n if by_associations.present?\n name if by_associations.include?(association_reflection.macro)\n else\n name\n end\n end.compact\n else\n []\n end\n end",
"def association(association_name); end",
"def associations\n @_associations.dup\n end",
"def scaf_has_manys\n scaf_assocs.select { |a|\n [:has_and_belongs_to_many, :has_many].include?( a.macro )\n }\n end",
"def association_from_relation_name(name)\n model_associations.detect { |a| a.name == name.to_sym }\n end",
"def reflect_on_all_associations(macro = nil)\n association_reflections = reflections.values\n association_reflections.select! { |reflection| reflection.macro == macro } if macro\n association_reflections\n end",
"def reflect_on_all_associations(macro = nil)\n association_reflections = reflections.values\n association_reflections.select! { |reflection| reflection.macro == macro } if macro\n association_reflections\n end",
"def association_columns\n model.reflect_on_all_associations(:belongs_to).select do |association_reflection|\n association_reflection.options[:polymorphic] != true\n end\n end",
"def model_association_name\n full_implementation_class_name.pluralize.ns_underscore.to_sym\n end",
"def foreign_keys_from_associations(fields = association_fields)\n fields.each_with_object([]) do |(_field_name, metadata), keys|\n keys << metadata[:foreign_key] if metadata[:foreign_key]\n keys << metadata[:polymorphic_type] if metadata[:polymorphic_type]\n keys\n end\n end",
"def foreign_keys_from_associations(fields = association_fields)\n fields.each_with_object([]) do |(_field_name, metadata), keys|\n keys << metadata[:foreign_key] if metadata[:foreign_key]\n keys << metadata[:polymorphic_type] if metadata[:polymorphic_type]\n keys\n end\n end",
"def scaffold_all_associations\n relationships.values.select { |v|\n v.send(:target_model).respond_to?(:scaffold_name)\n }\n end",
"def association_reflection\n @opts[:association_reflection]\n end",
"def reflect_on_all_associations(macro = nil)\n association_reflections = reflections.values\n macro ? association_reflections.select { |reflection| reflection.macro == macro } : association_reflections\n end",
"def changed_associations\n data['associations'].try(:keys) || []\n end",
"def symbols_for_association_chain #:nodoc:\n []\n end",
"def get_has_manys_for(model_name)\n associations.select { |a| a.belongs_to == model_name }.map(&:model)\n end",
"def all_associations_exist?(association_names)\n\t\t\t\tassociation_names.all? do |name| \n\t\t\t\t\tfound_reflection = find_reflection( extract_association(name) )\n\t\t\t\t\tfound_reflection && !(name.to_s.include?(\"_id\") && (found_reflection.macro == :belong_to) ) # TODO very hacky, make it work together with rails scoped_by\n\t\t\t\tend\n\t\t\tend",
"def symbols_for_association_chain #:nodoc:\n parents_symbols\n end",
"def changed_associations\n self.data['associations'].try(:keys) || []\n end",
"def resolved_associations_map\n @resolved_associations_map ||= included_collection_names.inject({}) do |hash, included_collection_name|\n if resolve_collection?(included_collection_name)\n hash[included_collection_name] = { associations: associations_map[included_collection_name][:associations] }\n end\n hash\n end\n end",
"def used_association_reflections\n Sequel.synchronize{@used_association_reflections ||= {}}\n end",
"def account_associations(klass)\n has_many klass.table_name.to_sym\n end",
"def scaffold_associations\n @scaffold_associations ||= relationships.keys.select { |v|\n relationships[v].send(:target_model).respond_to?(:scaffold_name)\n }.sort_by{|name| name.to_s}\n end",
"def expected_inverse_types\n inverse_classes = [\n Bronze::Entities::Associations::Metadata::HasManyMetadata,\n Bronze::Entities::Associations::Metadata::HasOneMetadata\n ] # end array\n\n inverse_classes.map { |klass| klass::ASSOCIATION_TYPE }\n end",
"def included_associations\n (self.class.replicate_associations + @replicate_opts[:associations]).uniq\n end",
"def dump_associations(my_object, my_object_name)\n if my_object.respond_to?(\"associations\")\n self.log(@dump_log_level, \"Begin #{my_object_name}.associations\")\n my_object.associations.sort.each { |a| self.log(:info, \"#{my_object_name} Association - #{a}\")}\n self.log(@dump_log_level, \"End #{my_object_name}.associations\")\n self.log(@dump_log_level, \"\")\n else\n self.log(@dump_log_level, \"No associations for #{my_object_name}\")\n end\n end",
"def solr_associations\n doc = {}\n # update_file_ids\n model.association_fields.each do |f|\n instances = find_association(f.to_param)\n next unless instances\n doc[\"bindery__associations_sim\"] ||= []\n instances.each do |instance|\n doc[\"bindery__associations_sim\"] << instance.persistent_id\n facet_name_for_association = Node.solr_name(f.code, type: 'facet', multivalue:true)\n doc[facet_name_for_association] ||= []\n doc[facet_name_for_association] << instance.title\n field_name_for_association = Node.solr_name(f.code, multivalue:true)\n doc[field_name_for_association] ||= []\n doc[field_name_for_association] << instance.title\n instance.solr_attributes(f.code + '__', multivalue:true).each do |k, v|\n doc[k] ||= []\n doc[k] << v\n end\n end\n end\n doc\n end",
"def associated_acts\n if self.type == \"Person\"\n arr = Array.new\n artist_relations = get_relations(self.relations, \"artist\")\n artist_relations.each do |relation|\n if relation[\"type\"] == \"member of band\"\n arr << relation\n end\n end\n return arr\n else\n return nil\n end\n end",
"def association_name_attributes\n \"#{association_name}_attributes\"\n end"
] | [
"0.83428484",
"0.83073413",
"0.7985347",
"0.7813317",
"0.7730785",
"0.771898",
"0.7673606",
"0.7636001",
"0.74432623",
"0.73519576",
"0.7264935",
"0.7243952",
"0.7237185",
"0.715249",
"0.7118639",
"0.7097484",
"0.70881003",
"0.7074808",
"0.7064371",
"0.70422935",
"0.7009091",
"0.70036346",
"0.6908867",
"0.6908867",
"0.687447",
"0.68392",
"0.6760498",
"0.67595387",
"0.67576146",
"0.6754493",
"0.67079026",
"0.67064583",
"0.67001545",
"0.6598159",
"0.65852326",
"0.6578214",
"0.6544099",
"0.6541693",
"0.6493827",
"0.6493827",
"0.6493827",
"0.6493827",
"0.6491676",
"0.647649",
"0.64397323",
"0.6427893",
"0.6425957",
"0.64254874",
"0.6413513",
"0.6399735",
"0.63982004",
"0.63814753",
"0.6361583",
"0.6330356",
"0.6315607",
"0.63089687",
"0.63000476",
"0.6300002",
"0.629495",
"0.62926507",
"0.62794226",
"0.62567717",
"0.6239501",
"0.6237693",
"0.62262577",
"0.61967754",
"0.6192043",
"0.6189772",
"0.6186035",
"0.6178749",
"0.61779994",
"0.61558634",
"0.6152405",
"0.6151576",
"0.6143754",
"0.61421007",
"0.61421007",
"0.61385626",
"0.61344314",
"0.6120507",
"0.6120507",
"0.6119958",
"0.61175114",
"0.6105968",
"0.6094416",
"0.609116",
"0.6090649",
"0.6087049",
"0.6085149",
"0.60809207",
"0.6080102",
"0.6046111",
"0.60453266",
"0.60434514",
"0.6033056",
"0.60326695",
"0.59895766",
"0.5984735",
"0.5983841",
"0.5972595"
] | 0.8476953 | 0 |
Read the specified association. | def read_association(name)
type = _association_type(name)
_associations.fetch(name, nil)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_association(key, safe: true)\n if safe\n tools.assertions.validate_name(key, as: 'association')\n\n unless self.class.associations.key?(key.to_s)\n raise ArgumentError, \"unknown association #{key.inspect}\"\n end\n end\n\n @associations[key.to_s]\n end",
"def association\n a = element.dataset[:association]\n # send is spoopy, make sure the message you're sending is actually an association\n return unless safe?(session[:model], a)\n\n session[:model].send(a)\n end",
"def load_associated(name)\n return nil unless association_id = send(\"#{name}_id\")\n\n class_name = send(\"#{name}_type\") || config_class_name_for(name)\n klass = class_name.classify.constantize\n\n primary_key = config_primary_key_for(name) || klass.primary_key\n\n klass.where(primary_key => association_id).first\n end",
"def association\n @association\n end",
"def read_one\n synchronize {\n read_many.slice!(0)\n }\n end",
"def association\n @association ||= model.reflect_on_association(@name)\n end",
"def association(association_name); end",
"def fetch_related_object(subject,association_name,index)\n check_subject_and_association(subject,association_name)\n __send__(association_method(subject.type,association_name),subject.rod_id,index)\n end",
"def read(id)\n begin\n find(id).read\n rescue\n nil\n end\n end",
"def association(name) #:nodoc:\n association = association_instance_get(name)\n\n if association.nil?\n unless reflection = self.class._reflect_on_association(name)\n raise AssociationNotFoundError.new(self, name)\n end\n association = reflection.association_class.new(self, reflection)\n association_instance_set(name, association)\n end\n\n association\n end",
"def association_id\n data[:association_id]\n end",
"def get_association(data)\n key = data.to_s\n\n begin\n data = get_field(data, false)\n rescue InvalidField => e\n if QuirkyApi.validate_associations\n raise InvalidAssociation,\n \"The '#{data}' association does not exist.\"\n else\n return\n end\n end\n\n sub_fields, sub_associations, sub_opts = sub_request_fields(key.to_s)\n\n sub_options = {}\n sub_options[:only] = sub_fields if sub_fields.present?\n sub_options[:associations] = sub_associations if sub_associations.present?\n sub_options[:extra_fields] = sub_opts if sub_opts.present?\n sub_options[:current_user] = @current_user\n\n if data.is_a?(Array)\n QuirkyArraySerializer.new(data, sub_options).as_json(root: false)\n elsif data.respond_to?(:active_model_serializer) && data.try(:active_model_serializer).present?\n data.active_model_serializer.new(data, sub_options).as_json(root: false)\n else\n data.as_json(root: false)\n end\n end",
"def association(name)\n if reflection = _scope.reflect_on_association(name)\n Association.new(self, reflection)\n else\n raise AssociationNotFoundError.new(_scope.model_name, name)\n end\n end",
"def association(name) # :nodoc:\n association = association_instance_get(name)\n\n if association.nil?\n unless reflection = self.class._reflect_on_association(name)\n raise AssociationNotFoundError.new(self, name)\n end\n association = reflection.association_class.new(self, reflection)\n association_instance_set(name, association)\n end\n\n association\n end",
"def read\n load_column(read_attribute)\n end",
"def find(association)\n begin\n find!\n rescue InvalidAssociation\n false\n end\n end",
"def association\n @association ||= options[:association]\n end",
"def reflect_on_association(name)\n association_by_name[name.to_sym]\n end",
"def association_instance_get(name)\n @association_cache[name]\n end",
"def association_instance_get(name)\n @association_cache[name]\n end",
"def read_attachment(attachment_name)\n database.fetch_attachment(self, attachment_name)\n end",
"def read\n @read ||= read_from(closest)\n end",
"def association(name) #:nodoc:\n association = association_instance_get(name)\n\n if association.nil?\n reflection = self.class.reflect_on_association(name)\n association = reflection.association_class.new(self, reflection)\n association_instance_set(name, association)\n end\n\n association\n end",
"def association_instance_get(name)\n @association_cache[name.to_sym]\n end",
"def set_association\n @association = Association.find(params[:id])\n end",
"def _read_attribute(attr)\n @attributes[attr]\n end",
"def read_section(ar) # :nodoc:\n @io.pos = ar.first\n @io.read(ar.last)\n end",
"def association_reflection(name)\n association_reflections[name]\n end",
"def association\n relation(source).associations[target]\n end",
"def get_association(server_url, handle=nil)\n serialized = @cache_client.get(assoc_key(server_url, handle))\n if serialized\n return deserialize(serialized)\n else\n return nil\n end\n end",
"def read(name)\n Oj.load(@redis.get(name))\n end",
"def read_by!(user)\n find_membership_by(user).read!\n end",
"def get_associated_data(object, key, opts = {})\n AssociationMap.get_associated_data(object, key, opts)\n end",
"def read(io)\n @record_class.read(io)\n end",
"def association_instance_get(cypher_string, association_obj)\n return if association_cache.nil? || association_cache.empty?\n lookup_obj = cypher_hash(cypher_string)\n reflection = association_reflection(association_obj)\n return if reflection.nil?\n association_cache[reflection.name] ? association_cache[reflection.name][lookup_obj] : nil\n end",
"def read_concern\n options[:read_concern] || database.read_concern\n end",
"def reflect_on_association(name)\n ActiveRecordAssociationAdapter.for_association(associations[name]) if associations[name]\n end",
"def find_relation_by association\n @relations.find{|r| r.association == association || r.association == association.singularize}\n end",
"def read_preference\n @read_preference ||= options[:read] || database.read_preference\n end",
"def read(id)\n File.read(find(id))\n end",
"def assoc(name)\n associations[name].()\n end",
"def read_detail\r\n read_detail_header.read_claim_payments\r\n self\r\n end",
"def find_association(association_id)\n association_id = association_id.to_s\n associations[association_id] && (associations[association_id] != \"\") ? associations[association_id].map { |pid| Node.latest_version(pid) } : nil\n end",
"def read_attribute(name)\n fields[name].get(@attributes[name])\n end",
"def check_association(model, association)\n raise(Sequel::UndefinedAssociation, \"Invalid association #{association} for #{model.name}\") unless reflection = model.association_reflection(association)\n raise(Sequel::Error, \"Eager loading is not allowed for #{model.name} association #{association}\") if reflection[:allow_eager] == false\n reflection\n end",
"def read(path)\n\t\[email protected](path)\n\tend",
"def get_association request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n uri, _body, query_string_params = transcode_get_association_request request_pb\n response = @client_stub.make_get_request(\n uri: uri,\n params: query_string_params,\n options: options\n )\n result = ::Google::Cloud::Compute::V1::FirewallPolicyAssociation.decode_json response.body, ignore_unknown_fields: true\n\n yield result, response if block_given?\n result\n end",
"def read(key)\n perform_read(:read, key)\n end",
"def read(id)\n perform(:get, \"#{@resource_type}/#{id}\")\n end",
"def reflect_on_association(name)\n self.class.reflect_on_association(name)\n end",
"def read\n _read\n end",
"def read_attribute(attribute)\n @object.send(:read_attribute, attribute.to_sym)\n end",
"def read_concern\n options[:read_concern]\n end",
"def represent_association_as(association, mode)\n # get association type to differentiate if its singular or plural\n type = self.class.association_reflection(association)[:type]\n singular = (type == :many_to_one || type == :one_to_one)\n\n if associations.key?(association)\n # if association data are already loaded (cached)\n return unless (data = send(association))\n singular ? data.represent_as(mode) : data.map { |d| d.represent_as(mode) }\n else\n # if not, load its dataset and represent it\n repre = send(\"#{association}_dataset\").represent_as(mode)\n singular ? repre[0] : repre\n end\n end",
"def outbound_association\n #ga = ivr_associations.map { |a| a unless a.outbound_route.nil? }\n #ga.compact!.first unless ga.nil?\n #ivr_associations.inner_join( OutboundRoute.dataset, id: :route_id ).first\n ivr_associations.where( outbound_route: OutboundRoute.all ).first\n end",
"def association(association_name,\n as: nil,\n viewmodel: nil,\n viewmodels: nil,\n external: false,\n read_only: false,\n through: nil,\n through_order_attr: nil)\n\n vm_association_name = (as || association_name).to_s\n\n if through\n direct_association_name = through\n indirect_association_name = association_name\n else\n direct_association_name = association_name\n indirect_association_name = nil\n end\n\n target_viewmodels = Array.wrap(viewmodel || viewmodels)\n\n association_data = AssociationData.new(\n owner: self,\n association_name: vm_association_name,\n direct_association_name: direct_association_name,\n indirect_association_name: indirect_association_name,\n target_viewmodels: target_viewmodels,\n external: external,\n read_only: read_only,\n through_order_attr: through_order_attr)\n\n _members[vm_association_name] = association_data\n\n @generated_accessor_module.module_eval do\n define_method vm_association_name do\n _read_association(vm_association_name)\n end\n\n define_method :\"serialize_#{vm_association_name}\" do |json, serialize_context: self.class.new_serialize_context|\n _serialize_association(vm_association_name, json, serialize_context: serialize_context)\n end\n end\n end",
"def show\n @association = assosi\n end",
"def association_from_relation_name(name)\n model_associations.detect { |a| a.name == name.to_sym }\n end",
"def quick_read (io_or_path, mode='r')\n\t\t\t\trdr = Reader.new(io_or_path, mode)\n\t\t\t\tdata = rdr.hndl.read()\n\t\t\t\trdr.close()\n\t\t\t\treturn data\n\t\t\tend",
"def read_object\n if @read_object\n @read_object\n else\n warn \"No read_object info has been defined for this reader.\"\n end\n end",
"def association\n self.parent && self.parent.dbi.reflect_on_association(self.association_name)\n end",
"def add_composite_read_handler( path, rsrcobj, association, options )\n\t\t\tself.log.debug \"Adding composite read handler for association: %s\" % [ association ]\n\n\t\t\tpkey = rsrcobj.primary_key\n\t\t\tcolunion = Regexp.union( rsrcobj.columns.map(&:to_s) )\n\t\t\tcolre = /^(?<column>#{colunion})$/\n\n\t\t\tself.add_route( :GET, path, options ) do |req|\n\n\t\t\t\t# Add validations for limit, offset, and order parameters\n\t\t\t\treq.params.add :limit, :integer\n\t\t\t\treq.params.add :offset, :integer\n\t\t\t\treq.params.add :order, colre\n\t\t\t\tfinish_with( HTTP::BAD_REQUEST, req.params.error_messages.join(\"\\n\") ) unless\n\t\t\t\t\treq.params.okay?\n\n\t\t\t\t# Fetch the primary key from the parameters\n\t\t\t\tres = req.response\n\t\t\t\tid = req.params[ pkey ]\n\n\t\t\t\t# Look up the resource, and if it exists, use it to fetch its associated\n\t\t\t\t# objects\n\t\t\t\tresource = rsrcobj[ id ] or\n\t\t\t\t\tfinish_with( HTTP::NOT_FOUND, \"No such %s [%p]\" % [rsrcobj.table_name, id] )\n\n\t\t\t\tlimit, offset, order = req.params.values_at( :limit, :offset, :order )\n\t\t\t\tdataset = resource.send( \"#{association}_dataset\" )\n\n\t\t\t\t# Apply the order parameter if it exists\n\t\t\t\tif order\n\t\t\t\t\torder = Array( order ).map( &:to_sym )\n\t\t\t\t\tself.log.debug \"Ordering result set by %p\" % [ order ]\n\t\t\t\t\tdataset = dataset.order( *order )\n\t\t\t\tend\n\n\t\t\t\t# Apply limit and offset parameters if they exist\n\t\t\t\tif limit\n\t\t\t\t\tself.log.debug \"Limiting result set to %p records\" % [ limit ]\n\t\t\t\t\tdataset = dataset.limit( limit, offset )\n\t\t\t\tend\n\n\t\t\t\t# Fetch and return the records as JSON or YAML\n\t\t\t\t# :TODO: Handle other mediatypes\n\t\t\t\tself.log.debug \"Returning collection: %s\" % [ dataset.sql ]\n\t\t\t\tres.for( :json, :yaml ) { dataset.all }\n\t\t\t\tres.for( :text ) { Sequel::PrettyTable.string(dataset) }\n\n\t\t\t\treturn res\n\t\t\tend\n\t\tend",
"def read_attribute\n Logging.debug \"Read attribute #{field_name}, got #{object.send(:read_attribute,field_name)} for #{object.inspect}\"\n object.send( :read_attribute, field_name )\n end",
"def association_reflection(association)\n uar = used_association_reflections\n Sequel.synchronize{uar[association] ||= true}\n super\n end",
"def read_attribute(attr_name, &block)\n name = attr_name.to_s\n name = self.class.attribute_aliases[name] || name\n\n return @attributes.fetch_value(name, &block) unless name == \"id\" && @primary_key\n\n if self.class.composite_primary_key?\n @attributes.fetch_value(\"id\", &block)\n else\n if @primary_key != \"id\"\n ActiveRecord.deprecator.warn(<<-MSG.squish)\n Using read_attribute(:id) to read the primary key value is deprecated.\n Use #id instead.\n MSG\n end\n @attributes.fetch_value(@primary_key, &block)\n end\n end",
"def [](name)\n relations.fetch(name)\n end",
"def ar_retrieve_resource(opts = {})\n @resource_relation ||= ar_model\n @resource_relation = ar_model.includes(ar_model.interfaces[:rest].eager_loading_hints(:view => ar_view)) if ar_model\n\n run_callbacks :ar_retrieve_resource do\n tid = opts[:id] || params[:id]\n opts.delete(:id)\n\n @resource = @resource_relation.find(tid)\n end\n\n #ar_authorize_action if !opts[:skip_authorization]\n\n @resource\n rescue ActiveRecord::RecordNotFound => e\n raise Exception::NotFound.new(e.message,\n :retry_possible => false)\n end",
"def find_association(name)\n ModelMethod.association_types_enum.each do |type|\n model_method = find_by_name_and_type(name, type)\n return model_method if model_method\n end\n\n nil\n end",
"def read!\n\t\t\t\t\tread\n\t\t\trescue\n\t\t\t\tnil\n\t\t\tend",
"def get_isbn_org_unit_association(org_unit_id, isbn) # GET\n query_string = \"/d2l/api/le/#{$le_ver}/#{org_unit_id}content/isbn/#{isbn}\"\n _get(query_string)\n # Returns: a IsbnAssociation JSON data block specifying\n # the association between an org unit and an ISBN.\nend",
"def association(name, options = {})\n define_method \"associated_#{name}\" do\n @result[options.fetch(:from, name).to_s]\n end\n end",
"def association_for(ass_name)\n ass = relation.all_associations.detect { |ass| ass.name == ass_name }\n ass.scope = {} # no scope can be determined by SQL reflection\n ass.resolver = self.class.new(ass.associated_table)\n ass\n end",
"def read_attribute(attr_name) #:doc:\n if @attributes.keys.include? attr_name\n if column = column_for_attribute(attr_name)\n @attributes[attr_name] = unserializable_attribute?(attr_name, column) ?\n unserialize_attribute(attr_name) : column.type_cast(@attributes[attr_name])\n end\n \n @attributes[attr_name]\n else\n nil\n end\n end",
"def read_one(res, klass, options = nil)\n return nil if res.blank?\n\n if options and join_relations = options[:include]\n join_relations = [join_relations].flatten.collect do |n|\n klass.relation(n)\n end\n end\n\n res_row = res.next\n # causes STI classes to come back as the correct child class\n # if accessed from the superclass.\n if klass.schema_inheritance?\n klass = Og::Model::model_from_string(res_row[res.fields.index('ogtype')])\n end\n obj = klass.og_allocate(res_row, 0)\n\n if options and options[:select]\n read_row(obj, res, res_row, 0)\n else\n obj.og_read(res_row)\n read_join_relations(obj, res_row, 0, join_relations) if join_relations\n end\n\n return obj\n\n ensure\n res.close\n end",
"def association_reflection\n @opts[:association_reflection]\n end",
"def read_preference\n @read_preference ||= options[:read]\n end",
"def read\n value = record.send(\"#{name}_data\")\n value unless value.nil? || value.empty?\n end",
"def association(name, *options); end",
"def instance_read(attr)\n getter = :\"#{@name_string}_#{attr}\"\n instance.send(getter) if instance.respond_to?(getter)\n end",
"def find_association name\n associations.values.detect do |association|\n association.represents_sfdc_table? name\n end\n end",
"def associated_record\n assoication.active_record\n end",
"def read\n result = model.fetch_attachment(@path)\n @headers = result.headers\n result.body\n end",
"def get_association(server_url, handle=nil)\n raise NotImplementedError\n end",
"def read\n raise NotImplementedError\n end",
"def association?(attribute)\n @_associations.key?(attribute.to_sym)\n end",
"def set_read\n @read = Read.find(params[:id])\n end",
"def related_records(name)\n relationship = self.class.find_relationship(name)\n records = relationship.who_participates_with(self)\n\n relationship.wants_array? ? records : records.first\n end",
"def find_association(res_desc, res_val)\n return nil unless res_val\n\n tmp = @client\n\n res_desc[:resource].each do |r|\n tmp = tmp.method(r).call\n end\n\n # FIXME: read _meta namespace from description\n ResourceInstance.new(\n @client,\n @api,\n tmp,\n action: tmp.actions[:show],\n resolved: res_val[:_meta][:resolved],\n response: res_val[:_meta][:resolved] ? res_val : nil,\n meta: res_val[:_meta]\n )\n end",
"def _load_relation name\n relation = self.relations.select { |rel| rel.name == name }.first\n if relation.type == :has_many\n _load_has_many relation\n elsif relation.type == :belongs_to\n _load_belongs_to relation\n else\n raise \"Unkown relation type\"\n end\n end",
"def reflect_on_association(name)\n if orm_association = klass.reflect_on_association(name)\n self.class.const_get(:Association).new(orm_association,self)\n end\n end",
"def get_relation(id)\n get_object('relation', id)\n end",
"def read_attribute name\n @attributes[name.to_s]\n end",
"def name\n association.name\n end",
"def default_read(read = nil)\n @opts[:read] || @collection.read\n end",
"def relationship\n return @relationship\n end",
"def associated_record(params)\n relationship = relationships(params).keys[0]\n relationship.camelize.constantize.friendly_uuid_find!(relation_id(params, relationship.to_sym))\n end",
"def get_associate\n\t\t@associates = Associate.all\n\tend",
"def read\n read_object(read_byte)\n end",
"def related_information\n attributes.fetch(:relatedInformation)\n end",
"def read_one(query)\n adapter.read_one(query)\n end"
] | [
"0.71946263",
"0.61465603",
"0.608465",
"0.59120494",
"0.58049136",
"0.57787526",
"0.57650065",
"0.5755606",
"0.5674283",
"0.5643788",
"0.5635563",
"0.5632599",
"0.5617736",
"0.56120366",
"0.5611897",
"0.55944556",
"0.55020356",
"0.5463704",
"0.54500496",
"0.54500496",
"0.54419696",
"0.541677",
"0.5398909",
"0.53896534",
"0.5370843",
"0.5367495",
"0.53667134",
"0.53225267",
"0.5283682",
"0.5275296",
"0.52743226",
"0.5259919",
"0.5250595",
"0.5248244",
"0.5177903",
"0.51744795",
"0.51740307",
"0.5168624",
"0.515633",
"0.515153",
"0.5142838",
"0.51413894",
"0.51365757",
"0.5134455",
"0.51282763",
"0.5124182",
"0.5121976",
"0.5119903",
"0.51059675",
"0.50999224",
"0.50976306",
"0.5096528",
"0.50955135",
"0.50891864",
"0.50834316",
"0.50809467",
"0.50566316",
"0.50215423",
"0.50206226",
"0.50200784",
"0.5005029",
"0.49903402",
"0.4988366",
"0.49854037",
"0.49831015",
"0.4979244",
"0.49735343",
"0.4965891",
"0.49609607",
"0.49582228",
"0.4957619",
"0.49564373",
"0.49555218",
"0.49525994",
"0.49407458",
"0.49395296",
"0.49326906",
"0.49142432",
"0.49101257",
"0.49098724",
"0.4909008",
"0.4906527",
"0.49023974",
"0.4901522",
"0.48908272",
"0.4882174",
"0.48796785",
"0.4879612",
"0.4867541",
"0.48642683",
"0.4834863",
"0.4834837",
"0.4834434",
"0.48332113",
"0.48326385",
"0.48325053",
"0.48274422",
"0.482206",
"0.4821349",
"0.48197716"
] | 0.7951814 | 0 |
Set values for the key'd association. | def set_association(key, value)
_associations[key.to_sym] = _cast_association(key, value)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set(k,v)\n each do |e|\n e.set k,v\n end\n self\n end",
"def set(key, value); end",
"def set(key, value); end",
"def hset(key, *attrs); end",
"def set(key, value)\n\t\t\t\t# TODO This could be a bit more efficient:\n\t\t\t\tself.delete(key)\n\t\t\t\tself.add(key, value)\n\t\t\tend",
"def hmset(key, *attrs); end",
"def hmset(key, *attrs); end",
"def set(instance)\n # TODO could we not cause a nasty bug by dropping nil value keys when the \n # user is using composite keys? Should we not rather raise an error if\n # the value is nil?\n key = instance.key\n \n raise ArgumentError.new(\"+key+ must be an Array, and can not be empty\") if key.empty? \n @cache[instance.class][key] = instance \n end",
"def set(key, value)\n end",
"def setnx(key, value); end",
"def setnx(key, value); end",
"def set k,v\n key = k.to_s.to_sym\n v = (v.is_a?(ASObj) ? v.finish : v) unless v == nil\n @_[key] = v unless v == nil\n @_.delete key if v == nil\n end",
"def set(key , value)\n index = key_index(key)\n if( index )\n self.keys.set(index , value)\n else\n self.keys.push(key)\n self.values.push(value)\n end\n value\n end",
"def set(key , value)\n index = key_index(key)\n if( index )\n @i_values.set(index , value)\n else\n @i_keys.push(key)\n @i_values.push(value)\n end\n value\n end",
"def set(key, value, **options); end",
"def []=(key, value)\n field_set key, value\n end",
"def cset item, key, val\n @item_config[item][key] = val\n self\n end",
"def []= k,v\n\t set k,v\n\t end",
"def []=(key_obj, value_obj)\n\t\t\t# Dial the key to be set - @lookup can never be empty\n\t\t\tdial!(key_obj)\n\t\t\t# Set the value\n\t\t\treturn set!(value_obj)\n\t\tend",
"def set(key, value)\n self.data ||= {}\n self.data[key.to_s] = value\n self.save!\n end",
"def set(key, value=self)\n if value.kind_of?(Proc)\n metadef(key, &value)\n metadef(\"#{key}?\") { !!__send__(key) }\n metadef(\"#{key}=\") { |val| set(key, Proc.new{val}) }\n @keys << key \n elsif value == self && key.is_a?(Hash)\n key.to_hash.each { |k,v| set(k, v) }\n elsif respond_to?(\"#{key}=\")\n __send__ \"#{key}=\", value\n @keys << key \n else\n set key, Proc.new{value}\n end\n self\n end",
"def []=( key, value )\n ensure_aggregate!\n @context[ key ] = value\n end",
"def _refresh_set_values(hash)\n @associations.clear if @associations\n super\n end",
"def []=(key, value)\n property = candy_coat(key, value) # Transform hashes and arrays, and communicate embedding\n candy[key] = property\n set key.to_sym => property\n end",
"def finalize!\n super\n keys.each { |key| set(key, resolve_value(key)) }\n end",
"def set_attribute(key_, value_)\n attribute(key_, value_, :set)\n end",
"def set(values); end",
"def set_multiple(keys, values)\n @mutex.synchronize do\n raise \"Invalid size #{keys}=#{values}\" unless keys.size == values.size\n # pp keys,values\n keys.zip(values).each do |var, val|\n do_set(var,val) unless var.nil? or val.nil?\n end\n end\n end",
"def field_set!(key, value)\n send \"_#{key}_set\", value\n end",
"def []= key, value\n key = @schema.resolve_key! key\n @schema.validate_value! key, value\n @values[key] = value\n end",
"def []= key, value\n\t\t\tsuper\n\t\t\[email protected] set: {@name => self} if @name.present? if check_if_complete\n\t\tend",
"def set(params = {})\n params.each do |k,v|\n self.class.attributes k.to_s\n send(k.to_s+\"=\",v)\n end\n end",
"def []=(key, val)\n self.setObject(val, forKey: key.to_s)\n self.synchronize\n end",
"def set(*args)\n assert_exists\n assert_writable\n\n @element.clear\n @element.send_keys(*args)\n end",
"def []=(key, value)\n values[key] = value\n values.save\n end",
"def []=(key, value)\n return super if has_key?(key)\n alt = alternate_key(key)\n has_key?(alt) ? super(alt, value) : super\n end",
"def []=(key, value)\n #if the key is an alias, lookup the real key\n key = aliasing_hash_aliases[key] if aliasing_hash_aliases.include?(key)\n \n super\n end",
"def set(key, val = nil)\n @statistics[:set] += 1\n with_branch_for(key) do |branch|\n branch.set key, val\n end\n end",
"def def_association_pks_setter(opts, &block)\n association_module_def(:\"#{singularize(opts[:name])}_pks=\", &block) unless opts[:read_only]\n end",
"def set(key, value)\n raise \"Method not implemented. Called abstract class.\"\n end",
"def key=(value); end",
"def set key, data\n\t\t@data_base[ key ] = data\n\t\tupdate_database\n\tend",
"def set key, value\n @reverse_cache[value.object_id] = key\n @cache[key] = value.object_id\n ObjectSpace.define_finalizer(value, @finalize)\n end",
"def []=(*key_list, value)\n store_with_init(Array(key_list).flatten, value)\n end",
"def assoc(key)\n super(convert_key(key))\n end",
"def []=(key, value)\n super(convert_key(key), convert_value(value))\n end",
"def []=(key, data)\n\t\tset key, data\n\tend",
"def set_attributes_by_hash(values = {})\n values.each do |key, value|\n meth_key = \"#{key}=\".to_sym\n self.send(meth_key, value ) if self.respond_to?(meth_key)\n end\n end",
"def set(key, value)\n change(:set, key, value)\n end",
"def set hash\n hash.each_pair do |k,v|\n self.send(:\"#{k}=\", v)\n end\n \n self\n end",
"def set(key, value)\n response = db.put_item(@table_name, {'id' => {'S' => key}, 'value' => {'S' => value}})\n true\n end",
"def set(fields)\n case self[:value]\n when Proc\n fields.send \"#{self[:key]}=\", self[:value].call(nil)\n else\n attr = if self[:key].to_s.end_with?('?')\n self[:key].to_s[0..-2]\n else\n self[:key]\n end\n fields.send \"#{attr}=\", self[:value]\n end\n end",
"def []=(key, value) self.send(\"#{key}=\", value) end",
"def set( key, value )\n fail NotImplementedError\n end",
"def set_many(db_or_tr, key_to_object)\n # TODO(pedge): standardized parameter checking\n raise ArgumentError.new unless key_to_object\n key_to_object.each do |key, object|\n raise ArgumentError.new unless !key.empty?\n raise ArgumentError.new unless object\n end\n\n object_index_key_to_key = key_to_object.inject(Hash.new) do |hash, (key, object)|\n hash[object_index_key(object.class, key)] = key\n hash\n end\n # as long as keys are unique, key_to_sub_serialized_objet should return unique keys\n key_to_sub_serialized_object = key_to_object.inject(Hash.new) do |hash, (key, object)|\n hash.merge!(key_to_sub_serialized_object(key, object))\n hash\n end\n db_or_tr.transact do |tr|\n set_many_in_transaction(tr, object_index_key_to_key)\n set_many_in_transaction(tr, key_to_sub_serialized_object)\n end\n key_to_object.values\n end",
"def key=(key); end",
"def do_set current, keys, value\n if keys.blank?\n current[:value] = value\n return current\n end\n\n keys = [keys] unless keys.is_a? Array\n current_key = keys.shift.to_sym\n if current[current_key].blank?\n current[current_key] = {:value => {}}\n end\n \n if keys.size > 0\n current[current_key] = do_set(current[current_key], keys, value)\n else\n current[current_key][:value] = value \n end\n \n current\n end",
"def set_value(key, value, context: Context.current)\n new_correlations = correlations_for(context).dup\n new_correlations[key] = value\n context.set_value(CORRELATION_CONTEXT_KEY, new_correlations)\n end",
"def []=(key, value)\n ObjectSpace.define_finalizer(key, @reference_cleanup)\n @lock.synchronize do\n @references_to_keys_map[key.__id__] = self.class.reference_class.new(key)\n @values[key.__id__] = value\n end\n end",
"def []=(key, value)\n ObjectSpace.define_finalizer(value, @reference_cleanup)\n key = key.dup if key.is_a?(String)\n @lock.synchronize do\n @references[key] = self.class.reference_class.new(value)\n keys_for_id = @references_to_keys_map[value.__id__]\n unless keys_for_id\n keys_for_id = []\n @references_to_keys_map[value.__id__] = keys_for_id\n end\n keys_for_id << key\n end\n value\n end",
"def _save_set_values(h)\n @values = h\n end",
"def _save_set_values(h)\n @values = h\n end",
"def hmset(key, *attrs)\n send_command([:hmset, key] + attrs)\n end",
"def set(key, value)\n arr_pos = to_hash(key)\n list = @array[array_pos]\n node = list.find_by_key(key)\n if node\n node.data = value\n else\n self.put(key, value)\n end\n end",
"def set!(value_obj)\n\t\t\tinsist!()\n\t\t\t@lookup[0...-1].inject(@obj_with_keys) { |deep_obj, this_key|\n\t\t\t\tdeep_obj[this_key]\n\t\t\t}[@lookup[-1]] = value_obj\n\t\tend",
"def []=(key , value)\n set(key, value)\n end",
"def []= k, v \n split_fields if not @h\n kupper = k.upcase\n @h[kupper] = v\n @original_key[kupper] = k\n end",
"def set_key_set\n @key_set = KeySet.find(params[:id])\n end",
"def set(options)\n options.each do |k, v|\n send(\"#{k}=\", v) if respond_to? \"#{k}=\"\n end\n end",
"def __setobj__\n excl_list = self.class.send(:excl_list)\n @hashobj.each do |key, value|\n snake = key.to_s.gsub(/\\W/, '_').underscore\n\n unless excl_list.include?(snake) # Must deal with nested models\n if value.kind_of?(Array)\n newval = value.map { |elem| elem.kind_of?(Hash) ? nested_object(snake.camelize.singularize, elem) : elem }\n @hashobj[key] = newval\n elsif value.kind_of?(Hash)\n @hashobj[key] = nested_object(snake.camelize, value)\n end\n end\n\n add_accessor_methods(snake, key)\n end\n end",
"def set_attrs (key, val)\n self.instance_variable_set(\"@#{key}\", val)\n self.class.send(:define_method, key, proc {self.instance_variable_get(\"@#{key}\")})\n end",
"def attribute_keys=(keys)\n @attribute_keys = keys\n attr_accessor *keys\n end",
"def set k,v\n key = k.to_s.to_sym\n v = (v.is_a?(JrdObj) ? v.finish : v) unless v == nil\n @_[key] = v unless v == nil\n @_.delete key if v == nil\n end",
"def []=( key, value )\n context.store(key.to_s, value)\n end",
"def hsetnx(key, field, value); end",
"def hsetnx(key, field, value); end",
"def set_keyval\n @keyval = Keyval.find(params[:id])\n end",
"def set(key, value)\n @namehash[key.to_sym][0] = value\n end",
"def set(key, value)\n @value[key.to_sym] = value if key\n end",
"def []= key, value\n @store.transaction { @store[key] = value }\n end",
"def set_key_statement\n super\n end",
"def set(key, value)\n Lib.set @path, @no_follow, key.to_s, value.to_s\n end",
"def put(key, value)\n \n end",
"def []=(key, value)\n key = namespaced_key(key)\n @keys << key\n set(key, value)\n end",
"def set(key, value)\n raise NotImplementedError\n end",
"def set(key, value)\n @manager.store(key, value)\n { key => value }\n end",
"def set(key, val)\n if key_in_map?(@ivar,key)\n update_key(key,val)\n else\n @ivar << [key, val]\n end\n end",
"def define_accessor(klass)\n klass.class_eval <<-EOS\n def #{@association_name}\n @#{@association_name} || (@#{@association_name} = HasAndBelongsToManyAssociation::Set.new(self, #{@association_name.inspect}))\n end\n\n def #{@association_name}=(value)\n #{@association_name}.set(value)\n end\n\n private\n def #{@association_name}_keys=(value)\n #{@association_name}.clear\n\n associated_constant = #{@association_name}.association.constant\n associated_table = #{@association_name}.association.associated_table\n associated_constant.all(associated_table.key => [*value]).each do |entry|\n #{@association_name} << entry\n end\n end\n EOS\n end",
"def update_key(key, val)\n @ivar.each_with_index do |ele, i|\n if ele[0] == key\n @ivar[i][1] = val \n end\n end\n end",
"def []=(key,val)\n\t\t\t@ary[key]=val #super\n\t\t\tsync\n\t\t\tself\n\t\tend",
"def set_property(key, value)\n end",
"def set(**options)\n options.symbolize_keys!\n keys = options.keys\n\n store = self.store\n\n previous_context = keys.zip(store.values_at(*keys)).to_h\n\n store.merge!(options)\n @after_change_callbacks.each(&:call)\n\n if block_given?\n begin\n yield\n ensure\n store.merge!(previous_context)\n @after_change_callbacks.each(&:call)\n end\n end\n end",
"def field_set(key, value)\n field = self.class.fetch_field(key.to_sym)\n send \"#{key}=\", field.coerce(value)\n end",
"def set_field(key, value)\n\n Ruote.set(h.fields, key, value)\n end",
"def []=(key, value)\n self.put(key, value)\n end",
"def key1=(val)\n self.key('key1',val)\n end",
"def set_value(key, value)\n database[key] = value\n removed_keys.delete(key)\n end",
"def []=(k, v)\n self.send(k.to_s + \"=\", v)\n end",
"def define_accessor(klass)\n klass.class_eval <<-EOS\n def #{@association_name}\n @#{@association_name} || (@#{@association_name} = DataMapper::Associations::HasManyAssociation::Set.new(self, #{@association_name.inspect}))\n end\n\n def #{@association_name}=(value)\n #{@association_name}.set(value)\n end\n\n private\n def #{@association_name}_keys=(value)\n #{@association_name}.clear\n\n associated_constant = #{@association_name}.association.associated_constant\n associated_table = #{@association_name}.association.associated_table\n associated_constant.all(associated_table.key => [*value]).each do |entry|\n #{@association_name} << entry\n end\n end\n EOS\n end",
"def set_keyvalue\n @keyvalue = Keyvalue.find(params[:id])\n end"
] | [
"0.6771941",
"0.63998663",
"0.63998663",
"0.63564634",
"0.63531405",
"0.63133806",
"0.63133806",
"0.6275904",
"0.6275637",
"0.6267881",
"0.6267881",
"0.6259619",
"0.6252384",
"0.61989516",
"0.6158674",
"0.6151377",
"0.60822505",
"0.60592306",
"0.6056363",
"0.6051091",
"0.60507625",
"0.60329616",
"0.60319674",
"0.60184616",
"0.5981963",
"0.59561616",
"0.5945961",
"0.5942459",
"0.593541",
"0.5925716",
"0.5919803",
"0.59131473",
"0.5912279",
"0.5909833",
"0.5905543",
"0.59014106",
"0.58936536",
"0.58913493",
"0.5884183",
"0.5855404",
"0.5854204",
"0.58459663",
"0.58455527",
"0.5841289",
"0.5840614",
"0.5835203",
"0.58225816",
"0.58177465",
"0.5815072",
"0.58069694",
"0.5803301",
"0.57984275",
"0.5787765",
"0.57832336",
"0.5782842",
"0.57813364",
"0.5780952",
"0.5774598",
"0.57583725",
"0.5754871",
"0.57504797",
"0.57504797",
"0.5740849",
"0.5740001",
"0.5735635",
"0.5709087",
"0.57049036",
"0.5689686",
"0.56804866",
"0.5678706",
"0.566808",
"0.56680363",
"0.56677985",
"0.56526905",
"0.56475407",
"0.56475407",
"0.5644632",
"0.56376934",
"0.5628897",
"0.56284094",
"0.5622845",
"0.5620119",
"0.56194246",
"0.5615767",
"0.5614454",
"0.5611332",
"0.56046903",
"0.5599699",
"0.5598407",
"0.5593966",
"0.55916905",
"0.55889636",
"0.5586918",
"0.55859864",
"0.5579243",
"0.5567828",
"0.5566464",
"0.5562742",
"0.5562361",
"0.55603635"
] | 0.6796056 | 0 |
Helper method that verifies a given association exists. | def has_association?(attr_name)
_associations.has_key?(attr_name.to_sym)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def association?(object, associations); end",
"def association?(attribute)\n @_associations.key?(attribute.to_sym)\n end",
"def is_association?(model_name, association_name)\n associations = @associations[model_name]\n associations && associations[association_name]\n end",
"def has_association_to klass, ident\n @associated_objects[klass].include?(ident)\n end",
"def is_association?(model_name, association_name)\n associations = @associations[model_name]\n !!(associations && associations[association_name])\n end",
"def all_associations_exist?(association_names)\n\t\t\t\tassociation_names.all? do |name| \n\t\t\t\t\tfound_reflection = find_reflection( extract_association(name) )\n\t\t\t\t\tfound_reflection && !(name.to_s.include?(\"_id\") && (found_reflection.macro == :belong_to) ) # TODO very hacky, make it work together with rails scoped_by\n\t\t\t\tend\n\t\t\tend",
"def is_foreign_key?\n association.present?\n end",
"def creating_object_association_for?(object, association)\n object_associations[object.bullet_key].present? &&\n object_associations[object.bullet_key].include?(association)\n end",
"def has_associations?\n (!self.pulves.empty? ||\n !self.labours.empty? || \n !self.factures.empty? || \n !self.ventes.empty?)\n end",
"def creating_object_association_for?(object, association)\n object_associations[object].present? && object_associations[object].include?(association)\n end",
"def associations?\n @_associations && @_associations.size > 0\n end",
"def associated?\n @associated\n end",
"def association?(key)\n # TODO(lsmola) remove this if there will be better dependency scan, probably with transitive dependencies filled\n # in a second pass, then we can get rid of this hardcoded symbols. Right now we are not able to introspect these.\n return true if [:parent, :genelogy_parent].include?(key)\n\n inventory_collection.dependency_attributes.key?(key) ||\n !inventory_collection.association_to_foreign_key_mapping[key].nil?\n end",
"def association_condition?(name)\n !association_condition_details(name).nil?\n end",
"def associated?(participant) \n (not participant.nil?) and participant_ids.include?(participant.id)\n end",
"def at_least_one? association\n errors.add(:base, \"must add at least one #{association}\") if association.blank?\n end",
"def associated?(namespace, name, stringified_predicate)\n predicate_objects(namespace, name).include?(stringified_predicate)\n end",
"def multiple_associations?\n associations.any? { |col,assocs| assocs.length > 1 }\n end",
"def valid_association_for_combining?(name)\n\t\t\treflections[name].macro.in? [:has_and_belongs_to_many, :has_many]\n\t\tend",
"def contains?(record)\n begin\n val = relation.exists?(record.id)\n @valid = true # set valid to true, if relation.exists?(model) does not throw any exception\n val\n rescue\n @valid = false\n end\n end",
"def association?(column)\n case column\n when String\n model.associations.map(&:to_s).include?(column)\n else\n model.association_reflection(column)\n end\n end",
"def ensure_exists(aggregate_id, clazz)\n !load_aggregate(aggregate_id, clazz).nil?\n end",
"def ensure_exists(aggregate_id, clazz)\n !load_aggregate(aggregate_id, clazz).nil?\n end",
"def associated?(namespace, name, stringified_predicate) # :nodoc:\n predicate_objects(namespace, name).include?(stringified_predicate)\n end",
"def check\n if unique_has_one_association?\n check_unique_has_one\n else\n check_remaining\n end\n end",
"def find(association)\n begin\n find!\n rescue InvalidAssociation\n false\n end\n end",
"def preloadable_association?( association )\n @klass.preloadable_associations.include?( association.to_sym )\n end",
"def check_associations\n to_check = [:assignments, :responses, :forms, :report_reports, :questions, :broadcasts]\n to_check.each{|a| raise DeletionError.new(:cant_delete_if_assoc) unless self.send(a).empty?}\n end",
"def unused_preload_associations_for?(klazz, association)\n unused_preload_associations[klazz].present? && unused_preload_associations[klazz].include?(association)\n end",
"def preconditions\n %i[\n has_one\n has_many\n ].include?(association.macro) && association.through_reflection.nil? && association.klass\n rescue StandardError\n false\n end",
"def test_exists_with_nil_arg\n assert_equal false, Topic.exists?(nil)\n assert_equal true, Topic.exists?\n\n assert_equal false, Topic.first.replies.exists?(nil)\n assert_equal true, Topic.first.replies.exists?\n end",
"def preconditions\n %i[\n has_one\n has_many\n ].include?(association.macro) && association.through_reflection.nil? && association.klass\n rescue NameError\n false\n end",
"def associated_with_affiliate?(aff_id)\n (aff_id == @data_object.user_affiliate) ||\n role_assoc_with_affiliate?(aff_id)\n end",
"def exist?\n\t\t!self.class.first(:conditions => {:identification_document => identification_document}).nil?\n\tend",
"def exists?\n load!\n true\n rescue RecordNotFound\n false\n end",
"def include_association?(association)\n # if we have explicitly requested this association we include it\n return true if self.included_associations.include?(association)\n return true if self.changed_associations.include?(association)\n # explicitly excluded\n return false if self.excluded_keys.include?(association)\n return false\n end",
"def exist?\n Neo4j::Relationship.exist?(self)\n end",
"def organization_exists?(name)\n @organizations.member?(name)\n end",
"def valid?\n @valid ||= begin \n relation.exists?\n true # set valid to true, if relation.exists?(model) does not throw any exception\n rescue\n false\n end\n end",
"def versioned_association?(association)\n versioned_associations.include?(association.to_sym)\n end",
"def campaign_exists?\n badge_id.present? && campaign.present?\n end",
"def exists?\n assert_exists\n true\n rescue UnknownObjectException\n false\n end",
"def is_associated?\n itinerary = self.selected_itinerary\n if itinerary.nil?\n return false\n end\n\n service = itinerary.service\n if service.nil?\n return false\n end\n\n return service.is_associated_with_user? self.trip.user\n\n end",
"def detecting_unpreloaded_association_for?(klass, association)\n Bullet.collected_n_plus_one_query_notifications.select do |notification|\n notification.base_class == klass.to_s && notification.associations.include?(association)\n end.present?\n end",
"def should_validate_associated(*associations)\n klass = self.name.gsub(/Test$/, '').constantize\n associations.each do |association|\n should \"validate associated #{association}\" do\n assert klass.new.respond_to?(\"validate_associated_records_for_#{association}\")\n end\n end\n end",
"def association_invalide\n @validations.keys.detect do |nom_association|\n !@validations[nom_association].call\n end\n end",
"def detecting_unpreloaded_association_for?(klazz, association)\n unpreload_associations[klazz].present? && unpreload_associations[klazz].include?(association)\n end",
"def is_many?\n associations.values.flatten.any? { |assoc| assoc.is_many? }\n end",
"def must_belong_to(association_name)\n it \"belongs_to :#{association_name.to_s.parameterize.underscore}\" do\n subject.association(association_name).must_be_kind_of(ActiveRecord::Associations::BelongsToAssociation)\n subject.send(association_name)\n end\nend",
"def include?(record_or_id)\n id = record_or_id.respond_to?(:id) ? record_or_id.id : record_or_id\n\n if loaded? || find_with_proc?\n !!find(id)\n else\n foreign_key_in_proxy_owner_exists? id\n end\n rescue RecordNotFound\n false\n end",
"def has_associations\n assocs.each_rel.to_a\n end",
"def synced_for?(instance)\n base_class = instance.mapping.database_model\n reflection = base_class.reflect_on_association(name)\n association_id = associated_salesforce_id(instance)\n\n return false unless association_id\n reflection.klass.exists?(\n mapping_for(reflection).lookup_column => association_id,\n )\n end",
"def exists?\n model.exists?(@id)\n end",
"def exists?\n [email protected]? && @exists\n end",
"def exists?\n [email protected]? && @exists\n end",
"def can_have_associated_objects?(obj)\n true\n end",
"def has_many?\n @macro == :belongs_to\n end",
"def exists?(object); end",
"def exists?(object); end",
"def exist?(*args)\n find(*args) && true\n rescue NotFoundError\n false\n end",
"def exists?(id, options = {})\n id && !find_single(id, options).nil?\n rescue ActiveResource::ResourceNotFound\n false\n end",
"def exist?(name)\n @data_adapter.has_relation? name\n end",
"def exists?\n criteria.exists?\n end",
"def unused_preload_associations_for?(klass, association)\n Bullet.collected_unused_eager_association_notifications.select do |notification|\n notification.base_class == klass.to_s && notification.associations.include?(association)\n end.present?\n end",
"def has_persona_in? room\n p = room.personas.find_by(account_id: self.id)\n !p.nil? # true when has persona, false when no persona\n end",
"def property?\n @options[:association].nil?\n end",
"def can_have_associated_objects?(obj)\n !self[:primary_keys].any?{|k| obj.get_column_value(k).nil?}\n end",
"def exists?(id, options = {})\r\n id && !find_single(id, options).nil?\r\n rescue ActiveResource::ResourceNotFound\r\n false\r\n end",
"def eager_graph_check_association(model, association)\n if association.is_a?(SQL::AliasedExpression)\n SQL::AliasedExpression.new(check_association(model, association.expression), association.alias)\n else\n check_association(model, association)\n end\n end",
"def associated? orthogroup_id, phenotype_id\n self[phenotype_id, orthogroup_id] == 1\n end",
"def exists?\n [email protected]? && @exists\n end",
"def exists?\n [email protected]? && @exists\n end",
"def exists?\n [email protected]? && @exists\n end",
"def can_destroyed?\n # list of associations to check (automatic)\n has_assocs = []\n self.class.reflections.each do |r_name, r|\n has_assocs << r_name if [:has_one, :has_many, :has_and_belongs_to_many].include? r.macro\n end\n\n # check for emptyness\n has_assocs.each do |r_name|\n assoc = self.send(r_name)\n nothing = assoc.respond_to?('empty?') ? assoc.empty? : assoc.nil?\n return false unless nothing\n end\n \n true\n end",
"def check_if_record_exists\n\tif MenuItem.exists?(:name =>self.name,:vendor_id=>self.vendor_id)\n\t\tputs\"This record already exists\"\n\t\tthrow:abort\n\telse\n\t\treturn true\n\tend\n end",
"def check_association(model, association)\n raise(Sequel::UndefinedAssociation, \"Invalid association #{association} for #{model.name}\") unless reflection = model.association_reflection(association)\n raise(Sequel::Error, \"Eager loading is not allowed for #{model.name} association #{association}\") if reflection[:allow_eager] == false\n reflection\n end",
"def find_association name\n associations.values.detect do |association|\n association.represents_sfdc_table? name\n end\n end",
"def exists?(id:nil, url:nil)\n !!Article.find(id: id, url: url)\n end",
"def member_of?(entity)\n\t\tassociation_exists?(entity, \"membership\", \"joinable\", \"joined\")\n\tend",
"def validate_associations\n errors.add(:user_id, :doesnt_exist) if @user.nil?\n end",
"def validate_associations\n errors.add(:user_id, :doesnt_exist) if @user.nil?\n end",
"def validate_associations\n errors.add(:user_id, :doesnt_exist) if @user.nil?\n end",
"def validate_associations\n errors.add(:user_id, :doesnt_exist) if @user.nil?\n end",
"def has?(purchase)\n !find_item(purchase).nil?\n end",
"def has_related?(link_rel)\n _ = related link_rel\n true\n rescue KeyError\n false\n end",
"def exists?\n @property_hash[:ensure] == :present\n end",
"def exists?\n @property_hash[:ensure] == :present\n end",
"def exists?\n @property_hash[:ensure] == :present\n end",
"def exists?\n @property_hash[:ensure] == :present\n end",
"def exist?\n !find_exists.nil?\n end",
"def assert_active_fedora_has_many(subject, association_name, objects)\n association = subject.send(association_name)\n assert_equal objects.count, association.count\n objects.each do |object|\n assert association.include?(object)\n end\n end",
"def exists?(identifier, configuration = {}); true; end",
"def exists?(id_or_conditions = {})\n case id_or_conditions\n when Hash then where(id_or_conditions).first.present?\n else\n begin\n find(id_or_conditions)\n true\n rescue Dynamoid::Errors::RecordNotFound\n false\n end\n end\n end",
"def exists?(name)\r\n User.exists?(name) || Organization.exists?(name)\r\n end",
"def actuale? opt = \"\"\n relation = opt.to_s.tableize\n\n actuale = false\n model.dependent_relations.each do |dependent_relation|\n tmp = self.send dependent_relation\n if relation == dependent_relation\n actuale ||= tmp.all.size > 1\n else\n actuale ||= tmp.exists?\n end\n end\n actuale\n end",
"def exists?\n @exists\n end",
"def can_have_associated_objects?(obj)\n !self[:keys].any?{|k| obj.get_column_value(k).nil?}\n end",
"def conditions_met?(object, associations); end",
"def destroy_association?\n destroy_association.to_i == 1\n end",
"def exists?\n Puppet.debug(self.class.to_s.split('::').last + ': Calling exists method : ')\n @property_hash[:ensure] == :present\n end"
] | [
"0.7184749",
"0.69383264",
"0.6920262",
"0.69146967",
"0.6900469",
"0.6900464",
"0.6770389",
"0.65803486",
"0.64925086",
"0.64672035",
"0.64292127",
"0.64169145",
"0.6373131",
"0.63626486",
"0.6361157",
"0.63451",
"0.6320307",
"0.629548",
"0.62691486",
"0.6252318",
"0.62381244",
"0.62107927",
"0.62107927",
"0.62046367",
"0.61832064",
"0.61778635",
"0.61773646",
"0.616565",
"0.61290747",
"0.60982066",
"0.6066865",
"0.60581905",
"0.6051543",
"0.6046115",
"0.5982768",
"0.5967078",
"0.5951429",
"0.59342927",
"0.5929764",
"0.5929657",
"0.5923712",
"0.59032226",
"0.58965886",
"0.58925456",
"0.5840108",
"0.58396727",
"0.5829642",
"0.5819271",
"0.5819086",
"0.58102256",
"0.578103",
"0.57504183",
"0.5742921",
"0.5726415",
"0.5726415",
"0.5725294",
"0.5725067",
"0.572241",
"0.572241",
"0.571212",
"0.5708976",
"0.57061005",
"0.5705801",
"0.57051545",
"0.5698257",
"0.5697299",
"0.5692142",
"0.5689799",
"0.5678043",
"0.5672862",
"0.56653583",
"0.56653583",
"0.56653583",
"0.5654071",
"0.56497926",
"0.56448466",
"0.5644253",
"0.56419486",
"0.56376594",
"0.563469",
"0.563469",
"0.563469",
"0.563469",
"0.56228",
"0.5616559",
"0.5604503",
"0.5604503",
"0.5604503",
"0.56034946",
"0.56005216",
"0.5599974",
"0.5570507",
"0.556963",
"0.55687433",
"0.55648804",
"0.55610037",
"0.5558362",
"0.5556817",
"0.5549068",
"0.55448747"
] | 0.7554773 | 0 |
Builds a new content as descriped in the elements.yml file. | def build(element, essence_hash)
if (description = content_description(element, essence_hash)).blank?
raise ContentDefinitionError, "No description found in elements.yml for #{essence_hash.inspect} and #{element.inspect}"
else
new(name: description['name'], element_id: element.id, skip_translate: description['translate'] == false)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_contents\n contents = []\n if description[\"contents\"].blank?\n logger.warn \"\\n++++++\\nWARNING! Could not find any content descriptions for element: #{self.name}\\n++++++++\\n\"\n else\n description[\"contents\"].each do |content_hash|\n contents << Alchemy::Content.create_from_scratch(self, content_hash.symbolize_keys)\n end\n end\n end",
"def create_contents\n contents = []\n if definition[\"contents\"].blank?\n log_warning \"Could not find any content descriptions for element: #{self.name}\"\n else\n definition[\"contents\"].each do |content_hash|\n contents << Content.create_from_scratch(self, content_hash.symbolize_keys)\n end\n end\n end",
"def create_contents\n contents = []\n if description[\"contents\"].blank?\n log_warning \"Could not find any content descriptions for element: #{self.name}\"\n else\n description[\"contents\"].each do |content_hash|\n contents << Content.create_from_scratch(self, content_hash.symbolize_keys)\n end\n end\n end",
"def create_contents\n return if definition.fetch(:ingredients, []).any?\n\n definition.fetch(\"contents\", []).each do |attributes|\n Content.create(attributes.merge(element: self))\n end\n end",
"def build( special_contexts=[] )\r\n\r\n self.ehtmls, self.ecss, self.ejs = self.theme.original_page_layout_root.build_content(special_contexts)\r\n self.ehtml = self.ehtmls.first\r\n\r\n end",
"def content\n \"#{title} #{description_text}\"\n end",
"def build\r\n self.ehtml, self.ecss, self.ejs = self.theme.page_layout.build_content() \r\n return self.ehtml, self.ecss, self.ejs\r\n end",
"def build(element, essence_hash)\n definition = content_definition(element, essence_hash)\n if definition.blank?\n raise ContentDefinitionError, \"No definition found in elements.yml for #{essence_hash.inspect} and #{element.inspect}\"\n else\n new(name: definition['name'], element_id: element.id)\n end\n end",
"def site_description\n headings = @doc.xpath(\"//h3[@class='clearl']\")\n content_sections = @doc.xpath(\"//h3[@class='clearl']/following-sibling::p[1]\")\n content = \"\"\n headings.zip(content_sections).each do |h, c| \n unless (c.to_s().squeeze().empty?)\n content << \"<h3>#{sanitize(h.to_s)}</h3>\" \n content << \"<p>#{sanitize(c.to_s)}\"\n end\n end\n rhtml = IO.read(File.expand_path(\"site_description.rhtml\", File.dirname(__FILE__)))\n content_html = Erubis::Eruby.new(rhtml)\n content_html.result(:content => content)\n end",
"def createContents\n\t\tcontents = []\n\t\t\n\t\tcontents << createLabel(\"<b><big>#{APP_NAME}</big></b>\")\n\t\tcontents << createLabel(@abt['version'] + ' ' + VERSION + \" (#{YEAR})\")\n\t\tcontents << createLabel(LICENSE)\n\t\tcontents << createLabel(\"<b>#{@abt['authors']}</b>\")\n\t\tcontents << createLabel(AUTHORS)\n\n\t\treturn contents\n\tend",
"def generate_description\n text, _ = parse_description\n parts = []\n parts << text if text.length > 0\n parts << JSON.generate(config) if config && config.length > 0\n parts.join(\"\\n\")\n end",
"def description\n if element.blank?\n log_warning \"Content with id #{self.id} is missing its Element.\"\n return {}\n end\n Content.content_description_from_element(element, name) || {}\n end",
"def create_element_content(element_id, data)\n create_content(Voog::API::Contents::ParentKind::Element, element_id, data)\n end",
"def content_descriptions\n return nil if definition.blank?\n definition['contents']\n end",
"def build\n\n @layout_path = bundle.layout_path\n\n # Render each filename. By default, the output goes to the resources\n # string\n @content_for_resources = ''\n entries.each { |fn| _render_one(fn) }\n\n # Finally, render the layout. This should produce the final output to\n # return\n input = File.read(@layout_path)\n \n # render using either erb or haml\n case File.extname(@layout_path)\n when /\\.rhtml$/, /\\.html.erb$/\n return eval(Erubis::Eruby.new.convert(input))\n when /\\.haml$/, /\\.html.haml$/\n require 'haml'\n return Haml::Engine.new(input).to_html(self)\n end\n end",
"def section_built_with(cloc, site_config)\n s = %(\n <div class=\"col-md-5\">\n #{Kramdown::Document.new(site_config['about'].gsub('[English](README.md) [Deutsche](lang/README.de.md)', '')).to_html}\n </div>\n <div class=\"col-md-7\">\n <h3>#{site_config['homepage_subheading4']}</h3>\n <pre>\n <code>\n #{cloc}\n </code>\n </pre>\n </div>\n </div>\n <div class=\"row\">\n <div class=\"col-sm-12\" id=\"d3pie_chart_div_homepage_all\"></div>\n </div>\n <div class=\"row\">\n <div class=\"col-sm-12\" id=\"d3pie_chart_div_homepage_mit\"></div>\n </div>)\n Dir['python/images/*'].map do |image|\n s += %(\n <div class=\"row\">\n <img class=\"img-responsive\" src=\"#{image}\" alt=\"#{image.split('/').last.split('.').first.capitalize.split('-').join ' '}\">\n </div>)\n end\n s\nend",
"def create_meta_description\n '<meta name=\"description\" content=\"' + item[:description] + '\"/>' if item[:description]\n end",
"def create_desc_item(node_name, id_suffix)\n \n #puts \"node_name = #{node_name}\"\n #puts \"id_suffix = #{id_suffix}\"\n \n node = @xml.at('/ead/archdesc/' + node_name)\n return unless node\n if head = node.at('head')\n label = head.text.empty? ? id_suffix : head.text.capitalize\n else\n label = id_suffix\n end\n \n doc = self.base_doc.merge({\n :xml_display => node.to_xml,\n :id => generate_id(id_suffix),\n :title_t => label,\n :hierarchy => [self.title, label]\n })\n doc\n end",
"def generate_content(section, topic)\n \tbegin\n \t\t@content = Kramdown::Document.new(File.read('data/docs/i2x_' + section + '_' + topic + '.md'), :toc_levels => '1').to_html\n \trescue\n \tend\n \t@content\n end",
"def create_default\n # Default values\n self.site_title = I18n.t 'websites.default.home_title'\n self.home_title = I18n.t 'websites.default.home_title'\n self.home_icon = I18n.t 'websites.default.home_icon'\n self.top_title = I18n.t 'websites.default.top_title'\n self.top_intro = I18n.t 'websites.default.top_intro'\n self.bottom_title = I18n.t 'websites.default.bottom_title'\n self.bottom_intro = I18n.t 'websites.default.bottom_intro'\n self.featured_title = I18n.t 'websites.default.featured_title'\n self.markdown = I18n.t 'websites.default.markdown'\n self.show_featured = true\n self.show_markdown = true\n # Create components\n modules = Rails.configuration.scribae['modules']\n modules.each_with_index do |comp_name, index|\n component = Component.new do |comp| \n comp.name = comp_name\n comp.icon_color = \"#6268c0\"\n comp.pos = index + 1\n comp.show = I18n.t \"websites.default.components.#{comp_name}.show\"\n comp.icon = I18n.t \"websites.default.components.#{comp_name}.icon\"\n comp.title = I18n.t \"websites.default.components.#{comp_name}.title\"\n comp.intro = I18n.t \"websites.default.components.#{comp_name}.intro\"\n end\n self.components << component\n end\n # Create preview and gitconfig\n parameterized = self.name.parameterize\n self.preview = Preview.new do |preview|\n preview.prototype = \"default\"\n preview.name = parameterized\n preview.process = 0\n preview.status = 0\n end\n self.gitconfig = Gitconfig.new do |git|\n git.base_url = parameterized\n git.initialized = false\n git.repo_link = \"\"\n git.website_link = \"\"\n end\n # Background images\n bg_file = File.open(Rails.root.join('app', 'assets', 'images', 'parallax.jpg'))\n ['top', 'bottom'].each do |name|\n image = Image.new do |img|\n img.name = name\n img.category = 'bg'\n img.upload = bg_file\n end \n self.images << image\n end\n # Style\n self.style = Style.new do |style|\n style.helper = \"\"\n style.navbar = \"#ffffff\"\n style.primary = \"#ffffff\"\n style.secondary = \"#000000\"\n style.background = \"#ffffff\"\n style.icon = \"#000000\"\n style.text = \"#000000\"\n style.decoration = \"#ffffff\"\n end\n end",
"def build_markup\n Object.const_get(output_class).new\n end",
"def generate_content_ncx(content,path)\n @builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|\n class_types_map = {\"Subject\" => \"course\", \"ContentYear\" => \"academic-class\", \"Subject\" => \"subject\", \"Chapter\" => \"chapter\", \"Topic\" => \"topic\", \"SubTopic\" => \"subtopic\"}\n xml.navMap do\n xml.navPoint(:id=>\"Curriculum\", :class=>\"curriculum\") do\n xml.content(:src=>\"curriculum\")\n xml.navPoint(:id=>\"Content\",:class=>\"content\")do\n xml.content(:src=>\"content\")\n\n ## The code for generating the inside xml string\n content_xml_string = ''\n parents = content.parents.reverse\n ## Generating the content node\n parents.each do |parent|\n content_data = Content.find(parent[\"ancestor\"])\n ## Getting the class for the current node\n node_class = class_types_map[content_data.type]\n ## Getting the src for the current node\n node_src = ''\n if content_data.type == 'Board'\n node_src = content_data.code+'_'+content.assets.first.publisher_id.to_s\n elsif content_data.type == 'ContentYear' or content_data.type == 'Subject'\n node_src = content_data.code\n else\n node_src = content.assets.first.src\n end\n # Reset the nav node and the content node\n nav_node = ''\n content_node = ''\n\n # Generating the nav node\n nav_node = nav_node+\"<navPoint id='#{content_data.name}' class='#{node_class}' >\"\n\n # Generating the content node\n content_node = content_node+\"<content src='#{node_src}' />\"\n\n ## Appending the nav node and the content node to the main xml\n content_xml_string = content_xml_string+nav_node+content_node\n end\n ## Appending the navpoint end tags to the string\n parents.length.times do\n content_xml_string = content_xml_string + \"</navPoint>\"\n end\n\n ## End of code for generating the xml string\n xml.__send__ :insert, Nokogiri::XML::DocumentFragment.parse(content_xml_string)\n end\n end\n end\n end\n xml_string = @builder.to_xml.to_s\n file = File.new(path+\"/\"+\"index.ncx\", \"w+\")\n File.open(file,'w') do |f|\n f.write(xml_string.to_s.gsub( \"\\n\", \"\" ).gsub(/>[ ]*</,'><'))\n end\n create_zip(\"content_#{content.id}\",path)\n end",
"def set_elements\n super\n element(:message) {b.li(:class => 'uif-infoMessageItem')}\n element(:messages) {b.lis(:class => 'uif-infoMessageItem')}\n element(:message_header) {b.h3(:class => 'uif-pageValidationHeader')}\n element(:submit_button) {b.button(:id => \"submitEditor\")}\n element(:cancel_button) {b.button(:id => \"cancelEditor\")}\n element(:close_button) {b.button(:id => \"closeEditor\")}\n element(:return_to_search_button) {b.button(:id => \"returnToSearch_button\")}\n # Navigation Area Elements\n element(:delete_bib_button) {b.button(:title => 'Delete Bib')}\n element(:add_instance_button) {b.button(:title => 'Add Instance')}\n element(:add_einstance_button) {b.button(:title => 'Add EInstance')}\n # @note Vakata Context Menu items are only present on the screen after the containing menu header has been right-clicked.\n element(:delete_instance_button) {b.div(:id => 'vakata-contextmenu').ul.li(:index => 0).a(:rel => \"Delete\")}\n element(:add_item_button) {b.button(:title => 'Add Item')}\n element(:delete_item_button) {b.div(:id => 'vakata-contextmenu').ul.li(:index => 0).a(:rel => 'Delete')}\n end",
"def content_description(element, essence_hash)\n essence_hash.stringify_keys!\n # No name given. We build the content from essence type.\n if essence_hash['name'].blank? && essence_hash['essence_type'].present?\n content_description_from_essence_type(element, essence_hash['essence_type'])\n else\n content_description_from_element(element, essence_hash['name'])\n end\n end",
"def content_manipulation\n self.summary = markup_manipulation self.summary if self.summary.present?\n self.content = markup_manipulation self.content if self.content.present?\n end",
"def description\n return {} if element.nil? or element.content_descriptions.nil?\n element.content_descriptions.detect { |c| c['name'] == self.content.name } || {}\n end",
"def content\n \n # TODO: Find out if @content can be cached here. \n # return @content if @content\n\n @content = []\n if @title then\n @content << HTML.h1(:class => :form_title) { @title }\n end\n included_fields = []\n fields().each { |field|\n\n if field.is_a?(Hash) then\n # This is a fieldset\n field.each_pair { |fieldset_name, fieldset_fields|\n # Get Fieldset instance by name from @fieldsets: \n @content << HTML.li { @fieldsets[fieldset_name.to_s] }\n if fieldset_fields.is_a?(Hash) then\n included_fields += fieldset_fields[:fields]\n else\n included_fields += fieldset_fields\n end\n }\n else \n element = @element_map[field.to_s]\n if element then\n included_fields << element.name.to_s\n element = element.to_hidden_field() if element.hidden?\n if element.kind_of? Aurita::GUI::Hidden_Field then\n @content << element\n else\n @content << @field_decorator.new(element)\n end\n end\n end\n }\n included_fields = included_fields.map { |f| f.to_s }\n # Render required field as hidden field if not \n # included in form field config: \n @elements.each { |element| \n if !included_fields.include?(element.name.to_s) && element.required? then\n @content << element.to_hidden_field()\n end\n }\n fields_id = dom_id().to_s+'_fields' if dom_id()\n\n @content = @content_decorator.new(:id => fields_id) { @content } \n return @content\n end",
"def descriptions\n if ::File.exists? \"#{::Rails.root}/config/alchemy/elements.yml\"\n ::YAML.load_file(\"#{::Rails.root}/config/alchemy/elements.yml\") || []\n else\n raise LoadError, \"Could not find elements.yml file! Please run: rails generate alchemy:scaffold\"\n end\n end",
"def build_frontmatter\n cockpit_title = \"Cockpit #{@cockpit_version}\"\n\n @frontmatter = {\n title: cockpit_title,\n author: @user,\n date: Time.now.strftime('%F'),\n tags: @tags.join(', '),\n slug: slugify(cockpit_title),\n category: 'release',\n summary: ''\n }.to_yaml.gsub(/^:/, '')\nend",
"def build_content_metadata record, tags\n # TODO: Further enrich the structured data by marking up FAQ accordions, Video Carousels, Image Galleries, etc.\n # Also ItemList metadata for the meditations archive\n # See here: https://developers.google.com/search/docs/data-types/article\n []\n end",
"def element!(name, content = nil, attributes = nil)\n build! do\n if content or block_given?\n @_crafted << \"<#{name}#{Tools.format_attributes(attributes)}>\"\n if block_given?\n value = yield\n content = value if !@_appended or value.kind_of? String\n end\n\n content = content.respond_to?(:empty?) && content.empty? ? '' : content.to_s\n\n @_crafted << Tools.escape(content) if content != \"\"\n @_crafted << \"</#{name}>\"\n else\n @_crafted << \"<#{name}#{Tools.format_attributes(attributes)}/>\"\n end\n end\n end",
"def content_descriptions\n return nil if description.blank?\n description['contents']\n end",
"def build(name)\n output_path = File.join(__dir__, \"#{name}.yml\")\n File.write(output_path, GENERATED_BANNER + template(name, params: { header: false }))\n end",
"def set_content\n version = build_config.version || 'latest'\n content = \"FROM #{build_config.image}:#{version}\\r\\n\"\\\n \"RUN apt-get update\\r\\n\"\\\n \"RUN apt-get install git -y\\r\\n\"\\\n \"RUN mkdir -p /app/current\\r\\n\"\\\n \"WORKDIR /app/current\\r\\n\"\\\n \"RUN touch /#{commit} \\r\\n\"\\\n \"RUN git clone #{project.repository.url} /app/current\\r\\n\"\n content\n end",
"def buildMenu\n template = File.read('_plugins/figma-menu.html.erb')\n result = ERB.new(template).result(binding)\n\n open(\"_includes/figma-menu.html\", \"wb\") { |file|\n file.write(result)\n file.close\n }\n\n end",
"def make_content(num=nil, options=nil)\n num ||= 1\n options ||= {}\n \n @generated_content = []\n ContentBase::CONTENT_CLASSES.each do |klass|\n @generated_content.push FactoryGirl.create_list(\n klass.to_s.underscore.to_sym, num.to_i, options\n )\n end\n \n @generated_content = @generated_content.flatten\n end",
"def description\n if element.blank?\n log_warning \"Content with id #{self.id} is missing its Element.\"\n return {}\n end\n desc = self.element.content_description_for(self.name)\n if desc.blank?\n self.element.available_content_description_for(self.name)\n end\n desc || {}\n end",
"def build\n nodes << element_klass.new\n\n yield(nodes.last) if block_given?\n\n nodes.last\n end",
"def content_description_from_element(element, name)\n element.content_description_for(name) ||\n element.available_content_description_for(name)\n end",
"def create_item(content, attributes, identifier)\n # Get filenames\n base_path = 'content' + (identifier == '/' ? '/index' : identifier[0..-2])\n meta_filename = base_path + '.yaml'\n content_filename = base_path + '.html'\n\n # Notify\n Nanoc3::NotificationCenter.post(:file_created, meta_filename)\n Nanoc3::NotificationCenter.post(:file_created, content_filename)\n\n # Create files\n FileUtils.mkdir_p(File.dirname(meta_filename))\n File.open(meta_filename, 'w') { |io| io.write(YAML.dump(attributes.stringify_keys)) }\n File.open(content_filename, 'w') { |io| io.write(content) }\n end",
"def new\n @title = \"Creating New Content\"\n @content_node = ContentNode.new\n end",
"def page_description\n if content_for?(:description)\n \"#{yield_content(:description)}\"\n else\n \"Capra is a design agency based in Ottawa, Canada run by husband and wife team Ollie and Kat Kavanagh. Our focus is great design. We love interactive work like websites, games and apps because we get involved in building what we design.\"\n end\n end",
"def autogenerate_elements\n to_auto_generate_elements = self.layout_description[\"autogenerate\"]\n unless (to_auto_generate_elements.blank?)\n to_auto_generate_elements.each do |element|\n element = Element.create_from_scratch({'page_id' => self.id, 'name' => element})\n element.move_to_bottom\n end\n end\n end",
"def process_descriptions(n)\n descriptions = self.feature.descriptions\n delete_descriptions = self.fields.delete('descriptions.delete')\n descriptions.clear if !delete_descriptions.blank? && delete_descriptions.downcase == 'yes'\n 0.upto(n) do |i|\n prefix = i>0 ? \"#{i}.descriptions\" : 'descriptions'\n description_content = self.fields.delete(\"#{prefix}.content\")\n if !description_content.blank?\n description_content = \"<p>#{description_content}</p>\"\n author_name = self.fields.delete(\"#{prefix}.author.fullname\")\n description_title = self.fields.delete(\"#{prefix}.title\")\n author = author_name.blank? ? nil : AuthenticatedSystem::Person.find_by(fullname: author_name)\n description = description_title.blank? ? descriptions.find_by(content: description_content) : descriptions.find_by(title: description_title) # : descriptions.find_by(['LEFT(content, 200) = ?', description_content[0...200]])\n language = Language.get_by_code_or_name(self.fields.delete(\"#{prefix}.languages.code\"), self.fields.delete(\"#{prefix}.languages.name\"))\n attributes = {:content => description_content, :title => description_title}\n attributes[:language_id] = language.id if !language.nil?\n if description.nil?\n if language.nil?\n self.say \"Language needed to create description for feature #{self.feature.pid}.\"\n description = nil\n else\n description = descriptions.create(attributes)\n end\n else\n description.update_attributes(attributes)\n end\n if !description.nil?\n self.spreadsheet.imports.create(:item => description) if description.imports.find_by(spreadsheet_id: self.spreadsheet.id).nil?\n description.authors << author if !author.nil? && !description.author_ids.include?(author.id)\n end\n end\n end \n end",
"def content\n return <<-EOF\ndefault lucie\n\nlabel lucie\nkernel #{ INSTALLER_KERNEL }\nappend initrd=#{ initrd } ip=dhcp devfs=nomount root=/dev/nfs nfsroot=#{ @nfsroot } boot=live hostname=#{ @node.name } #{ $KERNEL_OPTIONS }\nEOF\n end",
"def gen_descriptions\n @parser.descriptions.each do |name|\n editor = ModelEditor.new(name.snake_case)\n editor.generate_resource(@parser.properties[name])\n editor.fixup_properties(@parser.properties[name])\n editor.insert(BEFORE_CLASS, model_comments(name))\n editor.insert(AFTER_INCLUDES, ' include AssociationHelper')\n editor.insert(AFTER_INCLUDES, ' is_paginated')\n editor.insert(AFTER_REQUIREMENTS, def_to_s(@parser.properties[name]))\n end\n end",
"def meta_description(content)\n content_for_wrapper(:meta_description, content)\n end",
"def content_info(id)\n filename = settings.root + '/contents/' + id + '.yml'\n content = YAML.load(File.read(filename))\n\n raise 'Content has not key' unless content[:key]\n\n # Complete HMS information with default values.\n content[:id] ||= \"urn:marlin:organization:example:#{id}\"\n content[:title] ||= id\n content[:synopsis] ||= content[:title]\n content[:url] ||= url(\"/contents/#{id}.dcf\")\n\n # Other useful URLs.\n content[:rights_url] = url('/license/' + id)\n content[:download_url] = url('/download/' + id)\n content[:stream_url] = url('/stream/' + id)\n content[:cad_url] = url('/cad/' + id)\n\n content\n rescue Errno::ENOENT\n # .yml file does not exist. Show a 404 Not Found.\n not_found\n end",
"def create_new_xml_blog( body, time )\n p \"new xml doc created for time=#{time}\"\n \n #this is our template for a an individual entry in the blog import file\n item_template = <<-eos\n<item>\n<title>xxx</title>\n<link>xxx</link>\n<pubDate>xxx</pubDate>\n<dc:creator><![CDATA[xxx]]></dc:creator>\n\n\t\t<category><![CDATA[Uncategorized]]></category>\n\n\t\t<category domain=\"category\" nicename=\"uncategorized\"><![CDATA[Uncategorized]]></category>\n\n<guid isPermaLink=\"false\">xxx</guid>\n<description></description>\n<content:encoded><![CDATA[xxx]]></content:encoded>\n<excerpt:encoded><![CDATA[]]></excerpt:encoded>\n<wp:post_id>xxx</wp:post_id>\n<wp:post_date>xxx</wp:post_date>\n<wp:post_date_gmt>xxx</wp:post_date_gmt>\n<wp:comment_status>closed</wp:comment_status>\n<wp:ping_status>closed</wp:ping_status>\n<wp:post_name>xxx</wp:post_name>\n<wp:status>publish</wp:status>\n<wp:post_parent>0</wp:post_parent>\n<wp:menu_order>0</wp:menu_order>\n<wp:post_type>post</wp:post_type>\n<wp:post_password></wp:post_password>\n</item>\n\n eos\n \n doc = Hpricot.XML(item_template)\n \n #xanga names entries on date, so we will do same\n doc.search(\"title\")[0].inner_html = \"#{time.gsub(\" +0000\",\"\")}\"\n #link is constructed as follows: [base_blog_url]/[YYYY]/[MM]/[DD]/[title.downcase]\n #for dates, this looks like: [base_blog_url]/[YYYY]/[MM]/[DD]/tue-10-mar-2009-001259-0000/, for example\n doc.search(\"link\")[0].inner_html = \"#{@options[:base_blog_url]}/#{Time.now.strftime(\"%Y\")}/#{Time.now.strftime(\"%m\")}/#{Time.now.strftime(\"%d\")}/#{time.downcase.gsub(\",\", \"\").gsub(\":\",\"\").gsub(\" +\",\"-\").gsub(\" \",\"-\")}/\"\n \n #pubDate is 'time' passed in\n doc.search(\"pubDate\")[0].inner_html = \"#{time}\"\n #the creator is the username that gets credit for the posting i guess\n doc.search(\"dc:creator\")[0].inner_html = \"<![CDATA[#{@options[:creator]}]]>\"\n #guid is, as far as i can tell follows base_blog_url/?p=N format, where N=sequence of blog \n doc.search(\"guid\")[0].inner_html = \"#{@options[:base_blog_url]}/?p=#{@curr_blog_entries}\"\n #content:encoded is the blog body passed here\n doc.search(\"content:encoded\")[0].inner_html = \"<![CDATA[#{body}]]>\"\n #wp:post_id is as far as i can tell, just the sequential ordering of imported entries \n doc.search(\"wp:post_id\")[0].inner_html = \"#{@curr_blog_entries}\"\n\n #I've a conflict with my Time class; so I have to hack around, so sorry\n #input: time formatted as Tue, 10 Mar 2009 00:12:59 +0000\n #output: 2009-03-10 00:12:59, for example\n def convert_to_wp_post_date(time)\n ret = time.split(\" \")\n month_value = { 'JAN' => 1, 'FEB' => 2, 'MAR' => 3, 'APR' => 4, 'MAY' => 5, 'JUN' => 6, 'JUL' => 7, 'AUG' => 8, 'SEP' => 9, 'OCT' =>10, 'NOV' =>11, 'DEC' =>12 }\n ret[2] = month_value[ ret[2].upcase ] \n ret[2] = \"0\" + ret[2].to_s if ret[2].to_s.size == 1 #we want month padded to 2 digits\n ret[1] = \"0\" + ret[1].to_s if ret[1].to_s.size == 1 #we want day padded to 2 digits\n \n \"#{ret[3]}-#{ret[2]}-#{ret[1]} #{ret[4]}\"\n end\n \n #wp:post_date /wp:post_date_gmt is yet another format for the time field passed in\n #it looks like: 2009-03-10 00:12:59, for example\n doc.search(\"wp:post_date\")[0].inner_html = \"#{convert_to_wp_post_date(time)}\"\n doc.search(\"wp:post_date_gmt\")[0].inner_html = \"#{convert_to_wp_post_date(time)}\"\n #wp:post_name with xanga, it is same asthe last part of the link tag\n doc.search(\"wp:post_name\")[0].inner_html = \"#{time.downcase.gsub(\",\", \"\").gsub(\":\",\"\").gsub(\" +\",\"-\").gsub(\" \",\"-\")}\"\n\n doc\n end",
"def build_dom(entries); end",
"def description\n description = self.class.descriptions.detect { |d| d['name'] == self.name }\n if description.blank?\n log_warning \"Could not find element definition for #{self.name}. Please check your elements.yml!\"\n return {}\n else\n return description\n end\n end",
"def initialize_setup\n super\n snippet_content_path = File.expand_path(File.join(static_content_path(__FILE__, 'cookbook_base'))) + '/.'\n @flavor.class.do_add_content do\n tocopy << [snippet_content_path]\n end\n end",
"def description(text)\n content_for(:description) { text }\n end",
"def description(text)\n content_for(:description) { text }\n end",
"def template_content\n if respond_to? :contents and contents\n contents.elements.map do |item|\n if item.content.respond_to? :template\n item.content.template.renderable.template.render\n else\n ::Alongslide::render item.text_value, plain: true\n end\n end\n end\n end",
"def build\n end",
"def create_md tool\n \n original = tool[1].split(\"\\n\")\n new = []\n note = false\n\n # Cambia las rutas y < y > por código HTML\n def diple l\n return l.gsub('de +++YAML+++ en <http://pecas.cliteratu.re>', 'de [+++YAML+++](yaml.html)')\n .gsub('de JavaScript en <http://pecas.cliteratu.re>', 'de [JavaScript](js.html)')\n .gsub('Lista de acrónimos: <https://github.com/tesseract-ocr/tesseract/blob/master/doc/tesseract.1.asc#languages>', '[Lista de acrónimos](https://github.com/tesseract-ocr/tesseract/blob/master/doc/tesseract.1.asc#languages)')\n .gsub('<','<').gsub('>','>')\n end\n\n # Agrega versalitas\n def smallcaps l\n return l.gsub(/([A-Z]{3,})/, '+++\\1+++')\n end\n\n # Cambia comillas por sintaxis para línea de código\n def to_code l\n return l.gsub(/«(.+?)»/, '`\\1`')\n end\n\n # Añade líneas de código en las opciones\n def to_code_option l\n return l.gsub(/^(\\S+)/, '`\\1`')\n end\n\n new.push('# ' + $l_g_pc_docs_creation + '`' + tool[0] + '`')\n\n original.each_with_index do |l, i|\n\n l = to_code(diple(smallcaps(l)))\n\n if l =~ /^\\S/\n # Encabezados 2\n if l !~ /^Nota/ && i != 1\n new.push('## ' + l + \"\\n\\n\")\n # Párrafos\n else\n # Notas\n if l =~ /^Nota/\n if !note\n new.push(\"--- {.espacio-arriba3}\\n\\n\")\n note = true\n new.push(l + ' {.espacio-arriba3}')\n else\n new.push(l + ' {.espacio-arriba1 .sin-sangria}')\n end \n # Descripción\n else\n # Esto servirá para crear «herramientas.md»\n $tools_md[\"#{tool[0]}\"] = [tool[0], l.gsub(/^\\S+\\s+/, '')]\n new.push(l)\n end\n end\n else\n if l.strip != ''\n l = l.strip\n\n # Opciones de Pecas\n if l =~ /^-/\n new.push('* ' + to_code_option(l))\n # Comandos de Pecas\n elsif l =~ /^pc-/\n new.push('```')\n new.push(l)\n new.push('```')\n # Explicaciones\n elsif l =~ /^[A-Z]/\n new.push(\"\\n\" + l)\n # Dependencias / Tipos\n else\n # Evita que se quede como línea de código el tipo y su descripción\n l_final = []\n l.split(/\\s+/).each_with_index do |ll, i|\n # Solo la primera palabra se va como código\n if i == 0\n l_final.push('* `' + ll + '`')\n # El resto de las palabras se quedan como texto\n else\n l_final.push(ll)\n end\n end\n new.push(l_final.join(' '))\n end\n # Líneas en blanco\n else\n new.push(l)\n end\n end\n end\n\n\tarchivo = File.new(Dir.pwd + '/md/' + tool[0] + '.md', 'w:UTF-8')\n\tarchivo.puts new\n\tarchivo.close\nend",
"def definition\n if element.blank?\n log_warning \"Content with id #{self.id} is missing its Element.\"\n return {}\n end\n element.content_definition_for(name) || {}\n end",
"def content_for_rss_description\n content_for_rss_meta(\"description\")\n end",
"def content\n super\n @renderer = @widget.content\n div :id => 'doc3' do\n if @renderer.render? :header\n div :id => 'hd' do\n if @renderer.render? :top_line\n render_top_line\n end\n if @renderer.render? :title\n h1 @page_title || 'Missing :page_title'\n end \n end\n end\n div :id => 'bd' do\n render_body\n end\n if @renderer.render? :footer\n div :id => 'ft' do\n render_footer\n end\n end\n end\n end",
"def description(page_description) \n content_for(:description) do \n \"<meta name=\\\"description\\\" content=\\\"#{page_description}\\\" />\\n\" \n end \n end",
"def build_resource(dir, specs)\n resources = Dir.new(dir)\n to_skip = [ '.', '..', 'resource.def' ]\n record = specs['config']\n resources.entries.each do |entry|\n next if to_skip.include?(entry)\n content = IO.read File.join(resources.path, entry)\n method = File.basename(entry, File.extname(entry)).upcase\n doc = Maruku.new(content)\n record[method.downcase]['content'] = doc.to_html\n end\n record\n end",
"def content_from_default=(content)\n # needs to be overridden for each kind of elements\n end",
"def build\r\n end",
"def build\r\n end",
"def content\n require theme_path\n this = self # needed because Markaby is based on `instance_eval`\n @builder = Trinity::Builder.new(:indent => 2)\n @builder.instruct!\n @builder.declare! :DOCTYPE, :html, :PUBLIC, \"-//W3C//DTD XHTML+RDFa 1.0//EN\", \"http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd\"\n @builder.html(:xmlns => 'http://www.w3.org/1999/xhtml') do\n head { this.render_html_head }\n body { this.render_html_body }\n end\n @builder.to_s\n end",
"def content(name, content, opts = {})\n page = Islay::Pages.definitions[name]\n raise \"The page '#{name}' has not been defined\" if page.nil?\n raise \"The content '#{content}' has not been defined\" if page.contents[content].nil?\n\n if record = page.record\n config = record.content_with_config(content)\n\n case config[:type]\n when :markdown then render_markdown(config[:value], opts[:level] || 1)\n when :text then simple_format(config[:value])\n when :string, :color then config[:value]\n when :image\n if opts[:url_only]\n version_image_url(config[:value].asset, opts[:version]) if config[:value]\n else\n version_image_tag(config[:value].asset, opts[:version]) if config[:value]\n end\n end\n end\n end",
"def build_elements(node, obj)\n node.elements.each do |e|\n case\n when e.name == \"names\"\n obj << (build_names(e))\n when e.name == \"date\"\n obj << (build_date(e))\n when e.name == \"label\"\n obj << (build_label(e))\n when e.name == \"text\"\n obj << (build_text(e))\n when e.name == \"group\"\n obj << (build_group(e))\n when e.name == \"choose\"\n obj << (build_conditions(e))\n end\n end\n end",
"def create\n if text.match(/\\_QUOTE/)\n require 'organismo/element/quote'\n Organismo::Element::Quote.new(text, location)\n elsif text.match(/\\_SRC/)\n require 'organismo/element/code'\n Organismo::Element::Code.new(text, location)\n elsif text.match(/\\_EXAMPLE/)\n require 'organismo/element/example'\n Organismo::Element::Example.new(text, location)\n elsif text.match(/\\*/)\n require 'organismo/element/header'\n Organismo::Element::Header.new(text, location)\n elsif text.match(/\\[\\[\\S*(\\.png)|(\\jpg)|(\\.jpeg)\\]\\]/)\n require 'organismo/element/image'\n Organismo::Element::Image.new(text, location)\n elsif text.match(/\\[\\[\\S*\\]\\]/)\n require 'organismo/element/link'\n Organismo::Element::Link.new(text, location) \n elsif text.match(/\\-/)\n require 'organismo/element/plain_list'\n Organismo::Element::PlainList.new(text, location)\n else\n require 'organismo/element/text'\n Organismo::Element::Text.new(text, location)\n end\n end",
"def content_outline record\n blocks = record.content_blocks if record.parsed_content.present?\n return unless blocks\n\n content_tag :ul, class: 'content-outline' do\n # Loop through each block in the record, and generate a short piece of text describing that block.\n for block in blocks\n case block['type']\n when 'paragraph'\n text = block['data']['text']\n if block['data']['type'] == 'header'\n result = tag.strong(text)\n else\n result = block['data']['text'].truncate(200)\n end\n\n when 'list'\n result = ''\n result = \"<em>#{translate('admin.javascript.blocks.list.type.contents')}</em><br>\" if block['data']['type'] == 'contents'\n result += block['data']['items'].map { |i|\n depth = (i.is_a?(Hash) ? (i.dig('level') || 'h2')[1].to_i : 2) - 1\n text = i.is_a?(Hash) ? i['text'] : i\n \"#{'—' * depth} #{text}\".truncate(60)\n }.join('<br>')\n result = sanitize(result, tags: %w[em br])\n\n when 'layout'\n result = block['data']['items'].map { |i| \"— #{i['title']}\" }.join('<br>')\n result = sanitize(result, tags: %w[br])\n\n when 'catalog'\n result = translate(\"activerecord.models.#{block['data']['type'].singularize}.other\")\n result += \": #{translate('admin.content.items', count: block['data']['items'].length)}\"\n\n when 'textbox'\n result = ''\n result += \"<strong>#{block['data']['title']}</strong><br>\" if block['data']['title'].present?\n result += \"#{block['data']['text']&.truncate(60)}<br>\" if block['data']['text'].present?\n result += tag.span(\"[#{block['data']['action']}] → \") + tag.small(block['data']['url']) if block['data']['action'].present? && block['data']['url'].present?\n result = sanitize(result, tags: %w[strong br])\n\n when 'action'\n result = tag.span(\"[#{block['data']['action']}] → \") + tag.small(block['data']['url']) if block['data']['action'] && block['data']['url']\n\n when 'media'\n result = if block['data']['type'] == 'image'\n block['data']['items'].map { |i| \"#{tag.i(class: 'image icon')} <a href=\\\"#{i['image']['preview']}\\\" target=\\\"_blank\\\">#{i['image']['preview'].split('/').last}</a>#{\" - \\\"#{i['caption'].truncate(100)}\\\"\" if i['caption']}\" }\n elsif block['data']['type'] == 'audio'\n block['data']['items'].map { |i| \"#{tag.i(class: 'volume up icon')} <a href=\\\"#{i['audio']['preview']}\\\" target=\\\"_blank\\\">#{i['title']}</a>\" }\n elsif block['data']['type'] == 'youtube'\n tag.span('[YouTube Embed] → ') + tag.small(\"https://www.youtube.com/watch?v=#{block['data']['youtube_id']}\") if block['data']['youtube_id'] # TODO: Translate\n else\n block['data']['items'].map { |i| \"#{tag.i(class: \"#{block['data']['type']} icon\")} #{i['name']} (#{i['id']})\" }\n end\n result = result.join('<br>') if result.kind_of?(Array)\n result = sanitize(result, tags: %w[i a br], attributes: %w[href class target])\n\n when 'vimeo'\n result = block['data']['items'].map { |i| \"#{tag.i(class: 'video icon')} #{i['title']}\" }.join('<br>')\n result = sanitize(result, tags: %w[i a br])\n\n when 'whitespace'\n separators = {\n large: '==',\n medium: '—',\n small: '--',\n }\n\n result = separators[block['data']['size'].to_sym] * 3\n\n else\n concat block.inspect\n end\n\n concat content_tag :li, result, class: \"content-outline__#{block['type']} content-outline__#{block['type']}--#{block['data']['type']}\"\n end\n end\n end",
"def repeated_descriptions(node); end",
"def prepare_builder(builder, content, embeds, allowed_mentions)\n builder.content = content\n builder.allowed_mentions = allowed_mentions\n embeds&.each { |embed| builder << embed }\n end",
"def create\n @content = Content.new(permitted_params.content)\n\n @content.project = @project\n @content.content_type = @content_type\n\n respond_to do |format|\n if @content.save\n\n\n @content.ctbs.each do |ctb|\n if params[:link]\n ctb.link = (params[:link] == ctb.branch_id.to_s) ? true : false\n end\n\n if params[:caption]\n ctb.caption = (params[:caption][ctb.branch_id.to_s]) ? params[:caption][ctb.branch_id.to_s] : ''\n end\n\n ctb.save\n end\n\n\n if params[:content_elements][:add]\n params[:content_elements][:add].each do |content_element_type, value|\n begin\n @content.content_elements.build(:content_element_type_id => content_element_type, :language => @locale, :value => value).save\n rescue\n flash[:error] = t('fehler.ascii')\n @content.content_elements.build(:content_element_type_id => content_element_type, :language => @locale, :value => cleanup(value)).save\n end\n end\n end\n @content.proof_bracketcommands\n @content.setFileNames\n\n format.html { redirect_to edit_project_content_type_content_path(@project, @content_type, @content, :locale => @locale), notice: 'Content was successfully created.' }\n format.json { render action: 'show', status: :created, location: [@project, @content_type, @content] }\n else\n format.html { render action: 'new' }\n format.json { render json: @content.errors, status: :unprocessable_entity }\n end\n end\n end",
"def to_html\n build\n end",
"def story(story_content)\n story_content = story_content.strip.split(/[ \\t]*\\n+[ \\t]*/).map {|line| \" #{line}\\n\" }.join \n #metadata[:example_group][:description] << \"\\n\"+story_content+\"\\n\"\n metadata[:example_group][:full_description] << \"\\n\"+story_content+\"\\n\"\n end",
"def html_description\n if long_description.nil?\n paragraphs = []\n else\n paragraphs = long_description.delete(\"\\r\").gsub(\"\\n\\n\", \"\\n\").split(\"\\n\")\n end\n\n str = paragraphs.map { |x| \"<p>#{x}</p>\" }.join\n\n str += \"\\n<!--product-details-->\\n\"\n bullets = []\n\n (1..10).each do |x|\n point = get_property(\"Bullet #{x}\")\n bullets << point unless point.blank?\n end\n\n if bullets.length > 0\n str += \"<ul>\"\n str += bullets.map { |x| \"<li>#{x}</li>\" }.join\n str += \"</ul>\"\n end\n\n str += \"\\n<!--sizing-->\\n\"\n str += get_property(\"Sizing Info\")\n\n str += \"\\n<!--care-instructions-->\\n\"\n str += \"<p>\" + get_property(\"Care Instructions\") + \"</p>\"\n end",
"def definition\n if element.blank?\n log_warning \"Content with id #{id} is missing its Element.\"\n return {}\n end\n element.content_definition_for(name) || {}\n end",
"def new_content\n content_translated.present? ? transcode(content_translated) : content\n end",
"def new_content\n content_translated.present? ? transcode(content_translated) : content\n end",
"def build_rss\n ::RSS::Maker.make('2.0') do |maker|\n maker.channel.link = @wiki.settings.url\n maker.channel.title = @wiki.settings.title\n maker.channel.description = @wiki.settings.description.to_s\n maker.channel.author = @wiki.settings.author.to_s\n maker.channel.updated = Time.now.to_s\n maker.items.do_sort = true\n\n posts.each do |post|\n html = post.content\n date = Time.parse(post.post_date)\n\n next if date > Time.now unless @wiki.settings.future\n\n if i = html.index('</p>')\n text = html[0..i+4]\n else\n text = html\n end\n\n maker.items.new_item do |item|\n item.title = post.title\n item.link = File.join(@wiki.settings.url, post.href)\n item.date = date\n item.description = text\n end\n end\n end\n end",
"def generate_ng_element_content(dynamic_fields_groups_map, df_data, ng_element, content)\n # Allow for string value as a shortcut for [{'val' => 'some string'}]\n # Allow for array of strings as a shortcut for [{'val' => 'some string'}, {'val' => 'some other string'}]\n Array.wrap(content).map { |c| c.is_a?(Hash) ? c : { 'val' => c } }.each do |value|\n value['val'] = generate_field_val(value, df_data)\n if value.key?('yield') # Yield to dynamic_field_group renderer logic\n yield_to_string_key = value['yield']\n\n if dynamic_fields_groups_map.key?(yield_to_string_key) && df_data[yield_to_string_key].present?\n Array.wrap(dynamic_fields_groups_map[yield_to_string_key]).each do |translation_logic_rules|\n df_data[yield_to_string_key].each do |single_dynamic_field_group_data_value_for_string_key|\n Array.wrap(translation_logic_rules).each do |translation_logic_rule|\n self.class.new(generator).generate(translation_logic_rule, single_dynamic_field_group_data_value_for_string_key, ng_element)\n end\n end\n end\n end\n elsif value.key?('element') # Create new child element\n self.class.new(generator).generate(value, df_data, ng_element)\n elsif value.key?('val') # Render string value in next text node, performing DynamicField value substitution for variables\n processed_val = value_with_substitutions(value['val'], df_data)\n ng_element.add_child(Nokogiri::XML::Text.new(processed_val, ng_element.document))\n end\n end\n end",
"def xml_change_description( xml )\r\n unit = xml.parent.xpath('ancestor::unit')[0]\r\n Nokogiri::XML::Builder.with( unit ){ |x| \r\n xml_set_or_delete( x, 'description', @should[:description] )\r\n }\r\n end",
"def build\n # a counter to use when creating auto-labels for resources, with incremenets for each type\n resource_type_counters = Hash.new(0)\n\n # rubocop:disable Metrics/BlockLength\n cocina_filesets = filesets.map.with_index(1) do |fileset, sequence|\n resource_type_counters[fileset.resource_type_description] += 1 # each resource type description gets its own incrementing counter\n # create a generic resource label if needed\n default_label = \"#{fileset.resource_type_description.capitalize} #{resource_type_counters[fileset.resource_type_description]}\"\n # but if one of the files has a label, use it instead\n resource_label = fileset.label_from_file(default: default_label)\n contained_files = fileset.files.map do |fileset_file| # iterate over all the files in a resource\n file_id = fileset_file.relative_path\n file_attributes = {\n type: 'https://cocina.sul.stanford.edu/models/file',\n externalIdentifier: \"https://cocina.sul.stanford.edu/file/#{SecureRandom.uuid}\",\n version:,\n label: file_id,\n filename: file_id,\n hasMessageDigests: message_digests(fileset_file),\n hasMimeType: fileset_file.mimetype,\n administrative: administrative(fileset_file),\n access: file_access\n }\n Cocina::Models::File.new(file_attributes)\n end\n\n fs_attributes = {\n label: resource_label,\n version:,\n externalIdentifier: \"#{external_identifier.delete_prefix('druid:')}_#{sequence}\",\n type: file_set_type(fileset.resource_type_description),\n structural: { contains: contained_files }\n }\n\n Cocina::Models::FileSet.new(fs_attributes)\n end\n # rubocop:enable Metrics/BlockLength\n\n attributes = { contains: cocina_filesets }\n attributes[:hasMemberOrders] = [{ viewingDirection: reading_order }] if reading_order\n\n cocina_dro.structural.new(attributes)\n end",
"def extract_description(content)\n Woro::TaskList.extract_description content\n end",
"def part(part_label, part_title, part_intro, opts={})\n return if hide_content?(opts)\n\n concat_output <<EOT\n <part label=\"#{part_label}\">\n <title>#{part_title}</title>\n <partintro>\n <para>#{part_intro}</para>\n </partintro>\nEOT\n\n yield\n\n concat_output <<EOT\n </part>\nEOT\n end",
"def content_description_for(content_name)\n if content_descriptions.blank?\n log_warning \"Element #{self.name} is missing the content definition for #{content_name}\"\n return nil\n else\n content_descriptions.detect { |d| d['name'] == content_name }\n end\n end",
"def create_layout(content, attributes, identifier)\n # Get filenames\n base_path = 'layouts' + identifier[0..-2]\n meta_filename = base_path + '.yaml'\n content_filename = base_path + '.html'\n\n # Notify\n Nanoc3::NotificationCenter.post(:file_created, meta_filename)\n Nanoc3::NotificationCenter.post(:file_created, content_filename)\n\n # Create files\n FileUtils.mkdir_p(File.dirname(meta_filename))\n File.open(meta_filename, 'w') { |io| io.write(YAML.dump(attributes.stringify_keys)) }\n File.open(content_filename, 'w') { |io| io.write(content) }\n end",
"def content_description\n @content ? \"with content #{@content.inspect}\" : \"\"\n end",
"def create_visual_content_element(content, data_property_value)\n content_element = create_content_element(content, data_property_value)\n content_element.set_attribute('aria-hidden', 'true')\n content_element.set_attribute('role', 'presentation')\n content_element\n end",
"def create_defaults\n import_layout(self.layout_dir(:absolute => true))\n import_content(self.content_dir(:absolute => true))\n end",
"def set_meta_description\n html = html_overview || html_content || ''\n\n self.meta_description =\n html.\n gsub(/<\\/?[^>]*>/, ' '). # replace HTML tags with spaces\n gsub(/&\\w{1,9};|\"/, ''). # remove HTML special chars and double quotes\n gsub(/\\n+/, \" \"). # remove new lines\n gsub(/\\s+/, ' '). # remove duplicated spaces\n strip[0..200] # strip spaces and get first 200 chars\n end",
"def render_markup\n hidden = 'display: none;' if parsed_json['hideUnlessValues'] && element_value && !element_value.key?(parsed_json['hideUnlessValues'])\n\n content_tag(:div, class: parsed_json['htmlClass'], style: hidden) do\n # Display a description of the section if its provided\n concat content_tag(:p, description, class: 'form-description space-bot') unless description.nil?\n\n if parsed_json['label']\n label_text = parsed_json['label']\n concat label_tag('', label_text, class: ('required' if schema.required_field?(full_key)), id: label_id)\n\n # Adds the help modal link and icon\n concat help_icon(help_path)\n end\n\n # Continue rendering fields that appear in this section\n children.each do |child_element|\n concat child_element.render_markup\n end\n end\n end",
"def build_layout\n year = Time.now.year\n add_call('Notification des abonnements électroniques', ->() { notifier })\n add_call(\"Extension des abonnements gratuits et d'échange de l'année #{year - 1}\", ->() { freesubs(year - 1) })\n add_call(\"Extension des abonnements gratuits et d'échange de l'année #{year}\", ->() { freesubs(year) })\n add_call('Création d\\'un abonnement collectif', ->() { collective_manager })\n add_call('Exploitation des abonnements collectifs', ->() { collective_exploitation })\n add_call('Recherche des tiers par facture', ->() { billing_manager })\n add_call('(Pour développeur) Fichiers de requête', ->() { sql_files })\n @layout.add_stretch\n end",
"def build()\n HP.logger.debug(\"~ Build Mode: #{build_mode}\")\n HP.logger.debug(\"~ Source Root: #{source_root}\")\n HP.logger.debug(\"~ Build Root: #{build_root}\")\n build_entries(entries())\n end",
"def xml_builder_template(extra_opts = {})\n extra_attributes = extra_opts.fetch(:attributes, {})\n\n node_options = []\n node_child_template = \"\"\n if !self.default_content_path.nil?\n node_child_options = [\"\\':::builder_new_value:::\\'\"]\n node_child_template = \" { xml.#{self.default_content_path}( #{OM::XML.delimited_list(node_child_options)} ) }\"\n else\n node_options = [\"\\':::builder_new_value:::\\'\"]\n end\n if !self.attributes.nil?\n self.attributes.merge(extra_attributes).each_pair do |k,v|\n node_options << \"\\'#{k}\\'=>\\'#{v}\\'\" unless v == :none\n end\n end\n\n builder_ref = if self.path.include?(\":\")\n \"xml['#{self.path[0..path.index(\":\")-1]}']\"\n elsif !self.namespace_prefix.nil? and self.namespace_prefix != 'oxns'\n \"xml['#{self.namespace_prefix}']\"\n else\n \"xml\"\n end\n\n attribute = OM::XML.delimited_list(node_options)\n\n builder_method = if self.path.include?(\":\")\n \"#{self.path[path.index(\":\")+1..-1]}( #{attribute} )\"\n elsif self.path.include?(\".\")\n \"send(:\\\\\\\"#{self.path}\\\\\\\", #{attribute} )\"\n elsif self.path.kind_of?(Hash) && self.path[:attribute]\n \"@#{self.path[:attribute]}( #{OM::XML.delimited_list(node_options)} )\"\n elsif Nokogiri::XML::Builder.method_defined? self.path.to_sym\n \"#{self.path}_( #{OM::XML.delimited_list(node_options)} )\"\n else\n \"#{self.path}( #{OM::XML.delimited_list(node_options)} )\"\n end\n template = \"#{builder_ref}.#{builder_method}#{node_child_template}\"\n return template.gsub( /:::(.*?):::/ ) { '#{'+$1+'}' }\n end",
"def set_elements\n super\n element(:po_number) {b.span(:id => \"process_item_po_doc_line#{line_id}_control\")}\n element(:po_end_date) {b.text_field(:id => \"invoice-poEndDate_line#{line_id}_control\")}\n element(:close_po_checkbox) {b.checkbox(:id => \"CurrentItem_closePO_line#{line_id}_control\")}\n element(:delete_po_button) {b.button(:id => \"CurrentItem_deletePurchaseOrder_line#{line_id}\")}\n element(:requisitions_toggle) {b.a(:id => \"po-requisition-view_line#{line_id}_toggle\")}\n element(:purchase_orders_toggle) {b.a(:id => \"po-po-view_line#{line_id}_toggle\")}\n element(:line_item_receiving_toggle) {b.a(:id => \"po-relatedReceiving-view_line#{line_id}_toggle\")}\n element(:correction_receiving_toggle) {b.a(:id => \"po-relatedCorrectionReceiving-view_line#{line_id}_toggle\")}\n element(:payment_requests_toggle) {b.a(:id => \"po-relatedPayment-view_line#{line_id}_toggle\")}\n element(:credit_memos_toggle) {b.a(:id => \"po-relatedCreditMemo-view_line#{line_id}_toggle\")}\n element(:add_button) {b.button(:id => \"addPOItems_button_test_line#{line_id}\")}\n end",
"def titulo(texto) \n content_for(:titulo) { texto } \n end",
"def generate_markup\n\t\tordering = get_ordering\n\t\tmarkup_text = \"\"\n\n\t\tordering.each do |obj_place|\n\n\t\t\telement = obj_place.model.constantize.find(obj_place.id) #find the element referred to in the objectplace\t\n\t\t\twhitespace = \"\"\n\t\t\ttype_char = \"\"\n\t\t\tinfo = \"\"\n\n\t\t\t#get the whitespace, which is three spaces for every depth\n\t\t\t(element.depth*3).times do\n\t\t\t\twhitespace << \" \"\n\t\t\tend\n\n\t\t\t#if it's a node, gets its category and title, builds a string with a comma\n\t\t\tif element.is_a?(Node)\n\t\t\t\ttype_char = \".\"\n\t\t\t\tcategory_text = \"\"\n\t\t\t\tif element.category.name != \"\"\n\t\t\t\t\tcategory_text = element.category.name.capitalize + \",\"\n\t\t\t\tend\n\t\t\t\ttitle = element.title\n\t\t\t\tinfo = category_text + title\n\n\t\t\t#if it's a note, gets its body\n\t\t\telsif element.is_a?(Note)\n\t\t\t\ttype_char = \"-\"\n\t\t\t\tbody = element.body\n\t\t\t\tinfo = body\n\n\t\t\t#if it's a LinkCollection, builds the string with the link's child names comma separated\n\t\t\telsif element.is_a?(LinkCollection)\n\t\t\t\ttype_char = \":\"\n\t\t\t\tlinks_text = \"\"\n\t\t\t\telement.links.each do |link|\n\t\t\t\t\tif link.child != nil\n\t\t\t\t\t\tlinks_text << link.child.title + \" , \"\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\tif links_text != \"\"\n\t\t\t\t\tlinks_text = links_text[0..-4] #removes the trailing spaces and comma\n\t\t\t\tend\n\t\t\t\tinfo = links_text\n\t\t\telsif element.is_a?(PlaceHolder) #it's a place_holder\n\t\t\t\twhitespace = \"\"\n\t\t\t\ttype_char = \"\"\n\t\t\t\tinfo = element.text\n\t\t\tend\n\t\t\tmarkup_text << whitespace + type_char + info + \"\\r\\n\"\n\t\tend\n\t\treturn markup_text\n\tend",
"def build_entry(attributes)\n ContentEntry.new(content_type: self).tap do |entry|\n # set the link to the mounting point\n entry.mounting_point = self.mounting_point\n\n # do not forget that we are manipulating dynamic fields\n attributes.each do |k, v|\n begin\n field = self.find_field(k)\n\n if field.nil? && v.is_a?(Hash) # not a dynamic field but localized (permalink ?)\n entry.send(:\"#{k}_translations=\", v)\n elsif field.nil?\n entry.send(:\"#{k}=\", v)\n else\n entry.send(:\"#{field.name}=\", v)\n end\n rescue NoMethodError => e\n Mounter.logger.error e.backtrace\n raise FieldDoesNotExistException.new(\"The '#{self.slug}' content type does not have a field named '#{k}'.\")\n end\n end\n\n # force the slug to be defined from its label and in all the locales\n entry.send :set_slug\n\n (self.entries ||= []) << entry\n end\n end",
"def process_markup()\n [title,content].each do |text|\n next if !text\n clear_webpage(text).scan(PTN_MARKUP).map{|e|e[0].split(PTN_ELEMENT_SEP)}.flatten.each do |element|\n #debug \"[process_markup] element: \"+element.inspect\n next if !element\n ptn = element.scan(PTN_METADATA)\n #debug \"[process_markup] ptn: \"+ptn.inspect\n if ptn.size > 0\n m[ptn[0][0].to_sym] = parse_value(ptn[0][1])\n else\n create_and_link(element, 'tag' , \"t\")\n #add_tags(element, \"m\")\n end\n end#scan\n end#each\n end"
] | [
"0.6674145",
"0.6617033",
"0.65395",
"0.64949185",
"0.6203894",
"0.61040753",
"0.6097686",
"0.60529166",
"0.590941",
"0.581976",
"0.57462",
"0.5740439",
"0.57398385",
"0.5670683",
"0.56648636",
"0.56593835",
"0.55874324",
"0.5551073",
"0.55476224",
"0.5515719",
"0.5506568",
"0.54607004",
"0.5448229",
"0.5445084",
"0.5435427",
"0.54310507",
"0.54209036",
"0.5409398",
"0.5406176",
"0.54054",
"0.5369979",
"0.53698",
"0.5334615",
"0.53279257",
"0.5327355",
"0.53269887",
"0.5326757",
"0.5326737",
"0.53019756",
"0.52957183",
"0.5279494",
"0.5276408",
"0.5272171",
"0.52610946",
"0.52558136",
"0.5251224",
"0.5232597",
"0.52261627",
"0.522517",
"0.5223933",
"0.52215046",
"0.52139115",
"0.5213235",
"0.5212384",
"0.5212048",
"0.5209792",
"0.52037686",
"0.5203628",
"0.5184514",
"0.5177922",
"0.517436",
"0.5166977",
"0.51620656",
"0.51612705",
"0.51612705",
"0.5155566",
"0.51529026",
"0.51400435",
"0.51398957",
"0.51273984",
"0.5121199",
"0.5118925",
"0.51082075",
"0.5108112",
"0.51045465",
"0.5103676",
"0.5103398",
"0.50924975",
"0.50924975",
"0.509101",
"0.5090054",
"0.50856507",
"0.5084842",
"0.5079511",
"0.50692225",
"0.5068305",
"0.50666285",
"0.5064285",
"0.5062463",
"0.50590575",
"0.5046621",
"0.5041712",
"0.50386596",
"0.50294167",
"0.502497",
"0.50230545",
"0.502171",
"0.5019225",
"0.5019165",
"0.5018606"
] | 0.6553667 | 2 |
Creates a new content from elements description in the +elements.yml+ file. 1. It builds the content 2. It creates the essence record (content object gets saved) | def create_from_scratch(element, essence_hash)
essence_hash.stringify_keys!
if content = build(element, essence_hash)
content.create_essence!(essence_hash['essence_type'])
end
content
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_contents\n contents = []\n if description[\"contents\"].blank?\n logger.warn \"\\n++++++\\nWARNING! Could not find any content descriptions for element: #{self.name}\\n++++++++\\n\"\n else\n description[\"contents\"].each do |content_hash|\n contents << Alchemy::Content.create_from_scratch(self, content_hash.symbolize_keys)\n end\n end\n end",
"def create_contents\n return if definition.fetch(:ingredients, []).any?\n\n definition.fetch(\"contents\", []).each do |attributes|\n Content.create(attributes.merge(element: self))\n end\n end",
"def create_contents\n contents = []\n if definition[\"contents\"].blank?\n log_warning \"Could not find any content descriptions for element: #{self.name}\"\n else\n definition[\"contents\"].each do |content_hash|\n contents << Content.create_from_scratch(self, content_hash.symbolize_keys)\n end\n end\n end",
"def create_contents\n contents = []\n if description[\"contents\"].blank?\n log_warning \"Could not find any content descriptions for element: #{self.name}\"\n else\n description[\"contents\"].each do |content_hash|\n contents << Content.create_from_scratch(self, content_hash.symbolize_keys)\n end\n end\n end",
"def build(element, essence_hash)\n if (description = content_description(element, essence_hash)).blank?\n raise ContentDefinitionError, \"No description found in elements.yml for #{essence_hash.inspect} and #{element.inspect}\"\n else\n new(name: description['name'], element_id: element.id, skip_translate: description['translate'] == false)\n end\n end",
"def build(element, essence_hash)\n definition = content_definition(element, essence_hash)\n if definition.blank?\n raise ContentDefinitionError, \"No definition found in elements.yml for #{essence_hash.inspect} and #{element.inspect}\"\n else\n new(name: definition['name'], element_id: element.id)\n end\n end",
"def create\n if text.match(/\\_QUOTE/)\n require 'organismo/element/quote'\n Organismo::Element::Quote.new(text, location)\n elsif text.match(/\\_SRC/)\n require 'organismo/element/code'\n Organismo::Element::Code.new(text, location)\n elsif text.match(/\\_EXAMPLE/)\n require 'organismo/element/example'\n Organismo::Element::Example.new(text, location)\n elsif text.match(/\\*/)\n require 'organismo/element/header'\n Organismo::Element::Header.new(text, location)\n elsif text.match(/\\[\\[\\S*(\\.png)|(\\jpg)|(\\.jpeg)\\]\\]/)\n require 'organismo/element/image'\n Organismo::Element::Image.new(text, location)\n elsif text.match(/\\[\\[\\S*\\]\\]/)\n require 'organismo/element/link'\n Organismo::Element::Link.new(text, location) \n elsif text.match(/\\-/)\n require 'organismo/element/plain_list'\n Organismo::Element::PlainList.new(text, location)\n else\n require 'organismo/element/text'\n Organismo::Element::Text.new(text, location)\n end\n end",
"def create(attributes = {})\n new(attributes).tap do |content|\n content.essence.save && content.save\n end\n end",
"def create_element_content(element_id, data)\n create_content(Voog::API::Contents::ParentKind::Element, element_id, data)\n end",
"def process_descriptions(n)\n descriptions = self.feature.descriptions\n delete_descriptions = self.fields.delete('descriptions.delete')\n descriptions.clear if !delete_descriptions.blank? && delete_descriptions.downcase == 'yes'\n 0.upto(n) do |i|\n prefix = i>0 ? \"#{i}.descriptions\" : 'descriptions'\n description_content = self.fields.delete(\"#{prefix}.content\")\n if !description_content.blank?\n description_content = \"<p>#{description_content}</p>\"\n author_name = self.fields.delete(\"#{prefix}.author.fullname\")\n description_title = self.fields.delete(\"#{prefix}.title\")\n author = author_name.blank? ? nil : AuthenticatedSystem::Person.find_by(fullname: author_name)\n description = description_title.blank? ? descriptions.find_by(content: description_content) : descriptions.find_by(title: description_title) # : descriptions.find_by(['LEFT(content, 200) = ?', description_content[0...200]])\n language = Language.get_by_code_or_name(self.fields.delete(\"#{prefix}.languages.code\"), self.fields.delete(\"#{prefix}.languages.name\"))\n attributes = {:content => description_content, :title => description_title}\n attributes[:language_id] = language.id if !language.nil?\n if description.nil?\n if language.nil?\n self.say \"Language needed to create description for feature #{self.feature.pid}.\"\n description = nil\n else\n description = descriptions.create(attributes)\n end\n else\n description.update_attributes(attributes)\n end\n if !description.nil?\n self.spreadsheet.imports.create(:item => description) if description.imports.find_by(spreadsheet_id: self.spreadsheet.id).nil?\n description.authors << author if !author.nil? && !description.author_ids.include?(author.id)\n end\n end\n end \n end",
"def create_item(content, attributes, identifier)\n # Get filenames\n base_path = 'content' + (identifier == '/' ? '/index' : identifier[0..-2])\n meta_filename = base_path + '.yaml'\n content_filename = base_path + '.html'\n\n # Notify\n Nanoc3::NotificationCenter.post(:file_created, meta_filename)\n Nanoc3::NotificationCenter.post(:file_created, content_filename)\n\n # Create files\n FileUtils.mkdir_p(File.dirname(meta_filename))\n File.open(meta_filename, 'w') { |io| io.write(YAML.dump(attributes.stringify_keys)) }\n File.open(content_filename, 'w') { |io| io.write(content) }\n end",
"def new(attributes = {})\n element = attributes[:element] || Element.find_by(id: attributes[:element_id])\n return super if attributes.empty? || element.nil?\n\n definition = element.content_definition_for(attributes[:name])\n if definition.blank? && attributes[:essence_type].nil?\n raise ContentDefinitionError, \"No definition found in elements.yml for #{attributes.inspect} and #{element.inspect}\"\n end\n\n super(\n name: attributes[:name],\n essence_type: attributes[:essence_type] || normalize_essence_type(definition[:type]),\n element: element\n ).tap(&:build_essence)\n end",
"def create\n\n # Can we do this?\n not_found and return unless action_allowed?( :create )\n\n # load the content\n extract_content( true )\n generate_titles( :new )\n\n # try to save it\n if @content.save\n\n respond_after_action( :create, :created )\n\n else\n\n # it failed: so show a flash + redisplay the form\n flash.now[:error] = status_t( @content, :create_failed )\n render( action: :new )\n\n end\n\n end",
"def create\n @content = Content.new(permitted_params.content)\n\n @content.project = @project\n @content.content_type = @content_type\n\n respond_to do |format|\n if @content.save\n\n\n @content.ctbs.each do |ctb|\n if params[:link]\n ctb.link = (params[:link] == ctb.branch_id.to_s) ? true : false\n end\n\n if params[:caption]\n ctb.caption = (params[:caption][ctb.branch_id.to_s]) ? params[:caption][ctb.branch_id.to_s] : ''\n end\n\n ctb.save\n end\n\n\n if params[:content_elements][:add]\n params[:content_elements][:add].each do |content_element_type, value|\n begin\n @content.content_elements.build(:content_element_type_id => content_element_type, :language => @locale, :value => value).save\n rescue\n flash[:error] = t('fehler.ascii')\n @content.content_elements.build(:content_element_type_id => content_element_type, :language => @locale, :value => cleanup(value)).save\n end\n end\n end\n @content.proof_bracketcommands\n @content.setFileNames\n\n format.html { redirect_to edit_project_content_type_content_path(@project, @content_type, @content, :locale => @locale), notice: 'Content was successfully created.' }\n format.json { render action: 'show', status: :created, location: [@project, @content_type, @content] }\n else\n format.html { render action: 'new' }\n format.json { render json: @content.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n params[:elements].values.each do |elem|\n puts 'el', elem\n elem_to_save = Element.create (elem)\n @design.elements << elem_to_save\n end\n\n\n respond_to do |format|\n if @design.id\n format.html { redirect_to edit_design_path(@design), notice: 'Design was successfully created.' }\n format.json { render :json => @design}\n else\n format.html { render :new }\n format.json { render json: @design.errors, status: :unprocessable_entity }\n end\n end\n\n end",
"def autogenerate_elements\n elements_already_on_page = elements.available.pluck(:name)\n elements = definition[\"autogenerate\"]\n if elements.present?\n elements.each do |element|\n next if elements_already_on_page.include?(element)\n Element.create_from_scratch(attributes_for_element_name(element))\n end\n end\n end",
"def autogenerate_elements\n to_auto_generate_elements = self.layout_description[\"autogenerate\"]\n unless (to_auto_generate_elements.blank?)\n to_auto_generate_elements.each do |element|\n element = Element.create_from_scratch({'page_id' => self.id, 'name' => element})\n element.move_to_bottom\n end\n end\n end",
"def build( special_contexts=[] )\r\n\r\n self.ehtmls, self.ecss, self.ejs = self.theme.original_page_layout_root.build_content(special_contexts)\r\n self.ehtml = self.ehtmls.first\r\n\r\n end",
"def create_new_xml_blog( body, time )\n p \"new xml doc created for time=#{time}\"\n \n #this is our template for a an individual entry in the blog import file\n item_template = <<-eos\n<item>\n<title>xxx</title>\n<link>xxx</link>\n<pubDate>xxx</pubDate>\n<dc:creator><![CDATA[xxx]]></dc:creator>\n\n\t\t<category><![CDATA[Uncategorized]]></category>\n\n\t\t<category domain=\"category\" nicename=\"uncategorized\"><![CDATA[Uncategorized]]></category>\n\n<guid isPermaLink=\"false\">xxx</guid>\n<description></description>\n<content:encoded><![CDATA[xxx]]></content:encoded>\n<excerpt:encoded><![CDATA[]]></excerpt:encoded>\n<wp:post_id>xxx</wp:post_id>\n<wp:post_date>xxx</wp:post_date>\n<wp:post_date_gmt>xxx</wp:post_date_gmt>\n<wp:comment_status>closed</wp:comment_status>\n<wp:ping_status>closed</wp:ping_status>\n<wp:post_name>xxx</wp:post_name>\n<wp:status>publish</wp:status>\n<wp:post_parent>0</wp:post_parent>\n<wp:menu_order>0</wp:menu_order>\n<wp:post_type>post</wp:post_type>\n<wp:post_password></wp:post_password>\n</item>\n\n eos\n \n doc = Hpricot.XML(item_template)\n \n #xanga names entries on date, so we will do same\n doc.search(\"title\")[0].inner_html = \"#{time.gsub(\" +0000\",\"\")}\"\n #link is constructed as follows: [base_blog_url]/[YYYY]/[MM]/[DD]/[title.downcase]\n #for dates, this looks like: [base_blog_url]/[YYYY]/[MM]/[DD]/tue-10-mar-2009-001259-0000/, for example\n doc.search(\"link\")[0].inner_html = \"#{@options[:base_blog_url]}/#{Time.now.strftime(\"%Y\")}/#{Time.now.strftime(\"%m\")}/#{Time.now.strftime(\"%d\")}/#{time.downcase.gsub(\",\", \"\").gsub(\":\",\"\").gsub(\" +\",\"-\").gsub(\" \",\"-\")}/\"\n \n #pubDate is 'time' passed in\n doc.search(\"pubDate\")[0].inner_html = \"#{time}\"\n #the creator is the username that gets credit for the posting i guess\n doc.search(\"dc:creator\")[0].inner_html = \"<![CDATA[#{@options[:creator]}]]>\"\n #guid is, as far as i can tell follows base_blog_url/?p=N format, where N=sequence of blog \n doc.search(\"guid\")[0].inner_html = \"#{@options[:base_blog_url]}/?p=#{@curr_blog_entries}\"\n #content:encoded is the blog body passed here\n doc.search(\"content:encoded\")[0].inner_html = \"<![CDATA[#{body}]]>\"\n #wp:post_id is as far as i can tell, just the sequential ordering of imported entries \n doc.search(\"wp:post_id\")[0].inner_html = \"#{@curr_blog_entries}\"\n\n #I've a conflict with my Time class; so I have to hack around, so sorry\n #input: time formatted as Tue, 10 Mar 2009 00:12:59 +0000\n #output: 2009-03-10 00:12:59, for example\n def convert_to_wp_post_date(time)\n ret = time.split(\" \")\n month_value = { 'JAN' => 1, 'FEB' => 2, 'MAR' => 3, 'APR' => 4, 'MAY' => 5, 'JUN' => 6, 'JUL' => 7, 'AUG' => 8, 'SEP' => 9, 'OCT' =>10, 'NOV' =>11, 'DEC' =>12 }\n ret[2] = month_value[ ret[2].upcase ] \n ret[2] = \"0\" + ret[2].to_s if ret[2].to_s.size == 1 #we want month padded to 2 digits\n ret[1] = \"0\" + ret[1].to_s if ret[1].to_s.size == 1 #we want day padded to 2 digits\n \n \"#{ret[3]}-#{ret[2]}-#{ret[1]} #{ret[4]}\"\n end\n \n #wp:post_date /wp:post_date_gmt is yet another format for the time field passed in\n #it looks like: 2009-03-10 00:12:59, for example\n doc.search(\"wp:post_date\")[0].inner_html = \"#{convert_to_wp_post_date(time)}\"\n doc.search(\"wp:post_date_gmt\")[0].inner_html = \"#{convert_to_wp_post_date(time)}\"\n #wp:post_name with xanga, it is same asthe last part of the link tag\n doc.search(\"wp:post_name\")[0].inner_html = \"#{time.downcase.gsub(\",\", \"\").gsub(\":\",\"\").gsub(\" +\",\"-\").gsub(\" \",\"-\")}\"\n\n doc\n end",
"def create!\n new_file = \"#{next_number}-#{strip_title}.md\"\n @path = File.join(@dir, new_file)\n File.open(@path, 'w') do |file|\n file.write initial_content\n end\n\n new_file\n end",
"def content_description(element, essence_hash)\n essence_hash.stringify_keys!\n # No name given. We build the content from essence type.\n if essence_hash['name'].blank? && essence_hash['essence_type'].present?\n content_description_from_essence_type(element, essence_hash['essence_type'])\n else\n content_description_from_element(element, essence_hash['name'])\n end\n end",
"def create(name,content='')\n @name=name\n @content=content\n end",
"def create(name,content='')\n @name=name\n @content=content\n end",
"def descriptions\n if ::File.exists? \"#{::Rails.root}/config/alchemy/elements.yml\"\n ::YAML.load_file(\"#{::Rails.root}/config/alchemy/elements.yml\") || []\n else\n raise LoadError, \"Could not find elements.yml file! Please run: rails generate alchemy:scaffold\"\n end\n end",
"def load(contents)\n\n\t\t# save the NAME of the current schedule item, to restore later\n\t\tbackup_position = current.name if current\n\t\t\n\t\t# delete al items\n\t\tschedule_spans.delete_all\n\t\t\n\t\t# create all items\n\t\tcontents.each do |name, items|\n\t\t\tspan = schedule_spans.where(name: name).first_or_initialize\n\t\t\tspan.content = items.to_yaml\n\t\t\tspan.save\n\t\tend\n\t\t\n\t\t# restore 'current' item\n\t\tupdate_attribute(:current, backup_position && self.schedule_spans.find_by_name(backup_position))\n\t\t\n\tend",
"def create\n @element = @article.elements.build(element_params)\n \n if @element.save\n notice = nil\n else\n notice = @element.errors.full_messages.join(\". \") << \".\"\n end\n redirect_to edit_article_path(@article), notice: notice\n end",
"def save_model file\n doc = Document.new\n doc << XMLDecl.new\n\n model_element = Element.new \"model\"\n doc << model_element\n entities_element = Element.new \"entities\"\n model_element << entities_element\n connections_element = Element.new \"connections\"\n model_element << connections_element\n\n @entities.each do |e|\n entity_element = Element.new \"entity\"\n el = Element.new \"id\"\n el.text = e.id\n entity_element << el\n\n el = Element.new \"name\"\n el.text = e.name\n entity_element << el\n\n el = Element.new \"type\"\n el.text = e.type\n entity_element << el\n\n el = Element.new \"definition\"\n el.text = e.definition\n entity_element << el\n\n el = Element.new \"x\"\n el.text = e.get_x\n entity_element << el\n\n el = Element.new \"y\"\n el.text = e.get_y\n entity_element << el\n\n entities_element << entity_element\n end\n\n @connections.each do |c|\n connection_element = Element.new \"connection\"\n\n el = Element.new \"name\"\n el.text = c.name\n connection_element << el\n\n el = Element.new \"definition\"\n el.text = c.definition\n connection_element << el\n\n el = Element.new \"source-entity-id\"\n el.text = c.source_ep.entity_parent.id\n connection_element << el\n\n el = Element.new \"target-entity-id\"\n el.text = c.target_ep.entity_parent.id\n connection_element << el\n\n el = Element.new \"source-point-type\"\n el.text = c.source_ep.type\n connection_element << el\n\n el = Element.new \"target-point-type\"\n el.text = c.target_ep.type\n connection_element << el\n\n el = Element.new \"source-point-x\"\n el.text = c.source_ep.get_x\n connection_element << el\n\n el = Element.new \"source-point-y\"\n el.text = c.source_ep.get_y\n connection_element << el\n\n el = Element.new \"target-point-x\"\n el.text = c.target_ep.get_x\n connection_element << el\n\n el = Element.new \"target-point-y\"\n el.text = c.target_ep.get_y\n connection_element << el\n\n el = Element.new \"label-x\"\n el.text = c.label.get_x\n connection_element << el\n\n el = Element.new \"label-y\"\n el.text = c.label.get_y\n connection_element << el\n\n connections_element << connection_element\n end\n\n output_file = File.open file, 'w'\n formatter = Formatters::Pretty.new(2)\n formatter.compact = true\n formatter.write(doc, output_file)\n output_file.close\n\n end",
"def content_definition(element, essence_hash)\n essence_hash.stringify_keys!\n # No name given. We build the content from essence type.\n if essence_hash['name'].blank? && essence_hash['essence_type'].present?\n content_definition_from_essence_type(element, essence_hash['essence_type'])\n else\n element.content_definition_for(essence_hash['name'])\n end\n end",
"def create\n create_eem_and_log\n create_content_dir\n\n # The file was uploaded with the POST\n if(!params[:content_upload].nil?)\n create_part_from_upload_and_log\n\n #render_creation_response(@eem.pid, part.pid)\n res = 'eem_pid=' + @eem.pid\n render :text => res.to_s, :content_type => 'text/plain'\n\n # We will download the file in the background\n else\n cf = ContentFile.new\n cf.url = params[:contentUrl]\n\n cf.filepath = @content_dir\n cf.attempts = 1\n cf.user_display_name = @user.display_name\n cf.save\n\n part = Part.from_params(:url => params[:contentUrl], :content_file_id => cf.id)\n part.add_relationship(:is_part_of, @eem)\n part.save\n cf.part_pid = part.pid\n cf.save\n\n job = Dor::DownloadJob.new(cf.id)\n Delayed::Job.enqueue(job)\n\n render_creation_response(@eem.pid, part.pid, cf.id)\n end\n\n end",
"def site_description\n headings = @doc.xpath(\"//h3[@class='clearl']\")\n content_sections = @doc.xpath(\"//h3[@class='clearl']/following-sibling::p[1]\")\n content = \"\"\n headings.zip(content_sections).each do |h, c| \n unless (c.to_s().squeeze().empty?)\n content << \"<h3>#{sanitize(h.to_s)}</h3>\" \n content << \"<p>#{sanitize(c.to_s)}\"\n end\n end\n rhtml = IO.read(File.expand_path(\"site_description.rhtml\", File.dirname(__FILE__)))\n content_html = Erubis::Eruby.new(rhtml)\n content_html.result(:content => content)\n end",
"def squeeze_content\n uri = URI.parse(self.url)\n uri.open { |f|\n f.each_line{ |line| \n 1.upto(3) do |i|\n # Get content of headings on the line with dynamic variable\n instance_variable_set(\"@heading#{i}\", line.scan(/<h#{i}.*?>(.+?)<\\/h#{i}>/im))\n\n # Check if there any headings on the line\n if instance_variable_get(\"@heading#{i}\").any?\n instance_variable_get(\"@heading#{i}\").each { |h| \n # Create new content of Paper\n self.contents.create(:name => \"h#{i}\", :value => h[0].to_s)\n }\n end\n end\n }\n }\n end",
"def content_definition_from_essence_type(element, essence_type)\n {\n 'type' => essence_type,\n 'name' => content_name_from_element_and_essence_type(element, essence_type)\n }\n end",
"def load_contentful_structure_file\n file_exists? ? load_existing_contentful_structure_file : create_empty_contentful_structure_file\n end",
"def new\n @content = Content.new\n end",
"def create_paragraph(content)\n text = Text.new(content)\n run = Run.new\n run << text\n paragraph = Paragraph.new\n paragraph << run\n paragraph\nend",
"def content_description_from_essence_type(element, essence_type)\n {\n 'type' => essence_type,\n 'name' => content_name_from_element_and_essence_type(element, essence_type)\n }\n end",
"def content_descriptions\n return nil if definition.blank?\n definition['contents']\n end",
"def create\n parms = document_part_params.to_h.deep_dup.symbolize_keys\n parms[:document_id] = @document_section.document_id\n parms[:type] = 'DocumentPart::HtmlContent' if parms[:type].blank?\n @document_part = @document_section.parts.create(parms)\n redirect_to edit_admin_document_document_section_document_part_path(@document, @document_section, @document_part), notice: 'Content was successfully updated.' if @document_part.valid?\n end",
"def create\n merge_data \n to_frontmatter \n end",
"def new\n @title = \"Creating New Content\"\n @content_node = ContentNode.new\n end",
"def create\n @content = Content.new(content_params)\n @content.description = BlueCloth.new(@content.description).to_html\n @content.user_id = current_user\n\n respond_to do |format|\n if @content.save\n format.html { redirect_to @content, notice: 'Content was successfully created.' }\n format.json { render :show, status: :created, location: @content }\n else\n format.html { render :new }\n format.json { render json: @content.errors, status: :unprocessable_entity }\n end\n end\n end",
"def open_new_inspection\n if self.inspection_type_setting.present?\n\n new_insp = InspectionGenerator.new(self.inspection_type_setting).create\n\n new_insp_elements = {}\n\n new_insp.elements.each do |elem|\n new_insp_elements[elem.element_definition_id] = [elem.quantity, elem.notes, elem.parent&.element_definition_id]\n\n elem.defects.pluck(\"defect_definition_id\",\"condition_state_1_quantity\", \"condition_state_2_quantity\", \"condition_state_3_quantity\", \"condition_state_4_quantity\", \"total_quantity\", \"notes\").each do |defect|\n new_insp_elements[elem.element_definition_id] << { defect[0] => defect[1..-1] }\n end\n end\n\n # update all other open inspections\n self.highway_structure.inspections.where(state: ['open', 'ready']).where.not(id: new_insp.id).each do |insp|\n insp = Inspection.get_typed_inspection(insp)\n\n (insp.class.attribute_names.map{|x| x.to_sym} + Inspection.attribute_names.map{|x| x.to_sym} - [:id, :object_key, :guid, :state, :event_datetime, :weather, :temperature, :calculated_inspection_due_date, :qc_inspector_id, :qa_inspector_id, :routine_report_submitted_at, :organization_type_id, :assigned_organization_id, :inspection_team_leader_id, :inspection_team_member_id, :inspection_team_member_alt_id, :inspection_type_id]).each do |field_name|\n insp.send(\"#{field_name}=\", new_insp.send(field_name))\n end\n insp.save\n\n insp.elements.each do |elem|\n if new_insp_elements[elem.element_definition_id]\n elem.quantity = new_insp_elements[elem.element_definition_id][0]\n elem.notes = new_insp_elements[elem.element_definition_id][1]\n elem.parent = insp.elements.find_by(element_definition_id: new_insp_elements[elem.element_definition_id][2]) if new_insp_elements[elem.element_definition_id][2].present?\n elem.save\n\n elem.defects.each do |defect|\n\n if new_insp_elements[elem.element_definition_id][3][defect.defect_definition_id]\n defect.condition_state_1_quantity = new_insp_elements[elem.element_definition_id][3][defect.defect_definition_id][0]\n defect.condition_state_2_quantity = new_insp_elements[elem.element_definition_id][3][defect.defect_definition_id][1]\n defect.condition_state_3_quantity = new_insp_elements[elem.element_definition_id][3][defect.defect_definition_id][2]\n defect.condition_state_4_quantity = new_insp_elements[elem.element_definition_id][3][defect.defect_definition_id][3]\n defect.total_quantity = new_insp_elements[elem.element_definition_id][3][defect.defect_definition_id][4]\n defect.notes = new_insp_elements[elem.element_definition_id][3][defect.defect_definition_id][5]\n defect.save\n else\n defect.destroy\n end\n end\n\n # add new defects\n new_insp.elements.find_by(element_definition_id: elem.element_definition_id).defects.where.not(defect_definition_id: elem.defects.select(:defect_definition_id)).each do |defect|\n new_defect = defect.dup\n new_defect.object_key = nil\n new_defect.guid = nil\n new_defect.element = elem\n new_defect.inspection = elem.inspection\n new_defect.save\n\n end\n else\n elem.destroy\n end\n end\n\n # add new elements\n new_insp.elements.where.not(element_definition_id: insp.elements.select(:element_definition_id)).each do |elem|\n new_elem = elem.dup\n new_elem.object_key = nil\n new_elem.guid = nil\n new_elem.inspection = insp.inspection\n new_elem.parent = insp.elements.find_by(element_definition_id: elem.parent.element_definition_id) if elem.parent\n new_elem.save\n end\n end\n\n new_insp\n end\n\n end",
"def create_desc_item(node_name, id_suffix)\n \n #puts \"node_name = #{node_name}\"\n #puts \"id_suffix = #{id_suffix}\"\n \n node = @xml.at('/ead/archdesc/' + node_name)\n return unless node\n if head = node.at('head')\n label = head.text.empty? ? id_suffix : head.text.capitalize\n else\n label = id_suffix\n end\n \n doc = self.base_doc.merge({\n :xml_display => node.to_xml,\n :id => generate_id(id_suffix),\n :title_t => label,\n :hierarchy => [self.title, label]\n })\n doc\n end",
"def main\n blog = File.read(FILE_PATH).gsub(/-----[\\r\\n|\\n|\\r]EXTENDED BODY:/, '<!-- more -->')\n articles = split_to_articles(blog)\n headers_and_bodies = split_to_headers_and_bodies(articles)\n\n headers_and_bodies.each do |header_and_body|\n header_and_body[:header] = convert_header(header_and_body[:header])\n header_and_body[:body] = ReverseMarkdown.convert header_and_body[:body]\n end\n\n create_md_file(headers_and_bodies)\nend",
"def create_content(file)\n if @config.key?(self.class.name)\n config = @config[self.class.name]\n end\n config['instagram_tags'] ||= ''\n @tags = \"\\n\\n#{config['instagram_tags']}\\n\" unless config['instagram_tags'] == ''\n file_name = file\n file_read = File.readlines(file_name)\n \n file_read.each do |item|\n item.strip()\n end\n \n #\n # This is to assume that the file reads like this:\n # File URL\n # Instagram comment\n # Date posted\n #\n image_url = file_read[0]\n\n if image_url.match('ift.tt')\n \t image_url = Net::HTTP.get_response(URI.parse(image_url))['location']\n end\n\n image_caption = file_read[1]\n date_posted = Time.parse(file_read[-1])\n\n options = {}\n options['datestamp'] = date_posted.utc.iso8601\n options['starred'] = false\n options['uuid'] = %x{uuidgen}.gsub(/-/,'').strip\n options['content'] = \"## Instagram Photo\\n\\n#{image_caption}#{@tags}\"\n \n sl = DayOne.new\n sl.save_image(image_url,options['uuid']) if image_url\n sl.to_dayone(options)\n end",
"def create\n @paste_from_clipboard = !params[:paste_from_clipboard].blank?\n @element = Alchemy::Element.new_from_scratch(params[:element])\n put_element_in_cell if @page.can_have_cells?\n @element.container = @page\n if @element.save\n render :action => :create\n else\n render_remote_errors(@element, 'form#new_element button.button')\n end\n end",
"def to_eeml(version = nil)\n if version.nil? || version == 5\n # Check that we have some data items\n if size < 1\n raise EEML::NoData.new('EEML requires at least one data item')\n end\n # Create EEML\n eeml = Builder::XmlMarkup.new\n eeml.instruct!\n eeml_options = {:xmlns => \"http://www.eeml.org/xsd/005\",\n :'xmlns:xsi' => \"http://www.w3.org/2001/XMLSchema-instance\",\n :'xsi:schemaLocation' => \"http://www.eeml.org/xsd/005 http://www.eeml.org/xsd/005/005.xsd\"}\n eeml_options[:version] = version if version\n eeml.eeml(eeml_options) do\n env_options = {}\n env_options[:updated] = @updated_at.xmlschema if @updated_at\n env_options[:creator] = @creator if @creator\n env_options[:id] = @id if @id\n eeml.environment(env_options) do |env|\n env.title @title if @title\n env.feed @feed if @feed\n env.status @status.to_s if @status\n env.description @description if @description\n env.icon @icon if @icon\n env.website @website if @website\n env.email @email if @email\n if @location\n loc_options = {}\n loc_options[:domain] = @location.domain\n loc_options[:exposure] = @location.exposure if @location.exposure\n loc_options[:disposition] = @location.disposition if @location.disposition\n env.location(loc_options) do |loc|\n loc.name @location.name if @location.name\n loc.lat @location.lat if @location.lat\n loc.lon @location.lon if @location.lon\n loc.ele @location.ele if @location.ele\n end\n end\n @data_items.each_index do |i|\n env.data(:id => @data_items[i].id || i) do |data|\n @data_items[i].tags.each do |tag|\n data.tag tag\n end\n value_options = {}\n value_options[:maxValue] = @data_items[i].max_value if @data_items[i].max_value\n value_options[:minValue] = @data_items[i].min_value if @data_items[i].min_value\n data.value @data_items[i].value, value_options\n if @data_items[i].unit\n unit_options = {}\n unit_options[:symbol] = @data_items[i].unit.symbol if @data_items[i].unit.symbol\n unit_options[:type] = @data_items[i].unit.type if @data_items[i].unit.type\n data.unit @data_items[i].unit.name, unit_options\n end\n end\n end\n end\n end\n end\n end",
"def create(title, content, options={})\n form_data = {'action' => 'edit', 'title' => title, 'text' => content, 'summary' => (options[:summary] || \"\"), 'token' => get_token('edit', title)}\n if @options[:bot]\n form_data['bot'] = '1'\n form_data['assert'] = 'bot'\n end\n form_data['minor'] = '1' if options[:minor]\n form_data['notminor'] = '1' if options[:minor] == false or options[:notminor]\n form_data['createonly'] = \"\" unless options[:overwrite]\n form_data['section'] = options[:section].to_s if options[:section]\n make_api_request(form_data)\n end",
"def handle_content_element(cs, element, new_model)\n if element.blank?\n logger.warn \"MISSING ELEMENT for child selector #{cs.id} (#{cs.info}): #{cs.selector}\\nat url: #{new_model.url}\"\n return\n end\n\n content = nil\n case cs.data_resource.data_type\n when 'text', 'url', 'date'\n # assumes content is the text at this element\n content = element.text.squish\n # handles parsing issues with malformed HTML where content isn't captured by the selector (williams rss links)\n # logger.warn 'looking for next non blank' if content.blank?\n content = next_non_blank(element).text.squish if content.blank?\n when 'image'\n # logger.info \"saving image with url: #{element['url']}\"\n content = URI.parse(element['url'])\n else\n end\n\n # assign the text-based content to the proper column of the model\n new_model.assign_attributes(cs.column_name => content)\n end",
"def initialize(id, player, date, content)\n @id_save,@player_id_save,@date_save, @content_save = id, player, date, YAML.load(content)\n end",
"def new_item(content)\n Item.new(:project_id => @project_id, :content => content)\n end",
"def handle_save(edit_lines, type)\n if validate_inputs edit_lines\n @word = Word.new do |word|\n word.type = type.downcase.to_sym\n edit_lines.each do |k,v|\n word[k] = v.text\n end\n end\n\n puts \"Created #{@word.inf}\"\n\n Words << @word\n File.open Words_File, 'w' do |file|\n file.truncate 0\n file.write Words.to_yaml\n file.close\n end\n\n clear_edit_lines edit_lines.values\n else\n puts 'not valid'\n end\n end",
"def new\n\n # check whether we can do this\n not_found and return unless action_allowed?( :create )\n\n # extract content\n extract_content\n generate_titles\n\n end",
"def entity content\n end",
"def build_content_metadata record, tags\n # TODO: Further enrich the structured data by marking up FAQ accordions, Video Carousels, Image Galleries, etc.\n # Also ItemList metadata for the meditations archive\n # See here: https://developers.google.com/search/docs/data-types/article\n []\n end",
"def create_layout(content, attributes, identifier)\n # Get filenames\n base_path = 'layouts' + identifier[0..-2]\n meta_filename = base_path + '.yaml'\n content_filename = base_path + '.html'\n\n # Notify\n Nanoc3::NotificationCenter.post(:file_created, meta_filename)\n Nanoc3::NotificationCenter.post(:file_created, content_filename)\n\n # Create files\n FileUtils.mkdir_p(File.dirname(meta_filename))\n File.open(meta_filename, 'w') { |io| io.write(YAML.dump(attributes.stringify_keys)) }\n File.open(content_filename, 'w') { |io| io.write(content) }\n end",
"def create(content)\n post(content)\n end",
"def contents=(params)\n self.content_needs_saving = true\n contents.each do |content|\n update = params[content.association_name][content.id.to_s]\n content.attributes = update if update\n end\n end",
"def create_essence!(description)\n essence_class = self.class.normalize_essence_type(description['type']).constantize\n attributes = {\n :ingredient => default_text(description['default'])\n }\n if description['type'] == \"EssenceRichtext\" || description['type'] == \"EssenceText\"\n attributes.merge!(:do_not_index => !description['do_not_index'].nil?)\n end\n essence = essence_class.create(attributes)\n if essence\n self.essence = essence\n save!\n else\n false\n end\n end",
"def create_new_item( depositor, payload )\n\n ok = true\n work = GenericWork.create!( title: [ payload[ :title ] ] ) do |w|\n\n # generic work attributes\n w.apply_depositor_metadata( depositor )\n w.creator = depositor.email\n w.author_email = TaskHelpers.default_email( payload[ :author_computing_id ] ) if payload[ :author_computing_id ]\n w.author_first_name = payload[ :author_first_name ] if payload[ :author_first_name ]\n w.author_last_name = payload[ :author_last_name ] if payload[ :author_last_name ]\n w.author_institution = payload[ :institution ] if payload[ :institution ]\n w.contributor = payload[ :advisors ]\n w.description = payload[ :abstract ]\n w.keyword = payload[ :keywords ] if payload[ :keywords ]\n\n # date attributes\n w.date_created = payload[ :create_date ] if payload[ :create_date ]\n w.date_modified = DateTime.parse( payload[ :modified_date ] ) if payload[ :modified_date ]\n w.date_published = payload[ :issued ] if payload[ :issued ]\n\n # embargo attributes\n w.visibility = payload[:embargo_type ]\n w.embargo_state = payload[:embargo_type ]\n w.visibility_during_embargo = payload[:embargo_type ]\n w.embargo_end_date = payload[ :embargo_release_date ] if payload[ :embargo_release_date ]\n w.embargo_period = payload[ :embargo_period ] if payload[ :embargo_period ]\n\n # assume standard and published work type\n w.work_type = GenericWork::WORK_TYPE_THESIS\n w.draft = 'false'\n\n w.publisher = payload[ :publisher ] if payload[ :publisher ]\n w.department = payload[ :department ] if payload[ :department ]\n w.degree = payload[ :degree ] if payload[ :degree ]\n w.language = payload[ :language ] if payload[ :language ]\n\n w.notes = payload[ :notes ] if payload[ :notes ]\n w.rights = [ payload[ :rights ] ] if payload[ :rights ]\n w.license = GenericWork::DEFAULT_LICENSE\n\n w.admin_notes = payload[ :admin_notes ] if payload[ :admin_notes ]\n w.work_source = payload[ :source ] if payload[ :source ]\n\n end\n\n return ok, work\n end",
"def edit_with_nokogiri\n doc = Nokogiri.XML(read)\n yield doc if block_given?\n self.content = doc.to_xml\n save\n end",
"def edit_with_rexml\n require 'rexml/document'\n doc = REXML::Document.new(read)\n yield doc if block_given?\n self.content = doc.to_s\n save\n end",
"def load(fldDefs, filename)\r\n input = File.new(filename)\r\n doc = Document.new(input)\r\n root = doc.root\r\n input.close\r\n\r\n transCase = self.new(fldDefs)\r\n transCase.name = root.attribute('name').value if root.attributes.has_key? 'name'\r\n transCase.desc = root.attribute('desc').value if root.attributes.has_key? 'desc'\r\n if root.attributes.has_key? 'card_index'\r\n transCase.cardIndex = root.attribute('card_index').value.to_i\r\n end\r\n if root.attributes.has_key? 'acquirer_index'\r\n transCase.acquirerIndex = root.attribute('acquirer_index').value.to_i\r\n end\r\n\r\n root.elements.each(\"action\") do |elm|\r\n transCase.actions << loadAction(transCase, elm)\r\n end\r\n\r\n transCase\r\n end",
"def end_element(name)\n @stack.pop\n element = @elements.pop\n # p @stack\n\n # open OBO file for each from CV list for further validation\n if name == :cvList\n @cv_list.each do |cv|\n filename = case cv[:id]\n when \"MS\"\n \"psi-ms.obo\"\n when \"UO\"\n \"unit.obo\"\n when \"IMS\"\n \"imagingMS.obo\"\n end\n filepath = File.join(File.dirname(__FILE__), \"..\", \"..\", \"data\", filename)\n @obo[cv[:id].to_s] = Obo::Parser.new(filepath)\n end\n end\n\n # save file content\n if name == :cvParam && @stack.last == :fileContent\n\n cv = @obo[element[:cvRef]]\n stanza = cv.stanza(element[:accession])\n parent_id = stanza.parent_id\n\n # init basic structures\n @metadata.file_description ||= FileDescription.new\n file_content = (@metadata.file_description.file_content ||= FileContent.new)\n\n case element[:cvRef]\n when \"MS\"\n # save data file content\n if parent_id == FileContent::DATA_FILE_CONTENT\n file_content.data_file_contents ||= Hash.new\n (file_content.data_file_contents[parent_id] ||= Array.new) << element\n end\n\n # save spectrum representation\n if parent_id == FileContent::SPECTRUM_REPRESENTATION\n file_content.spectrum_representation = element\n end\n\n when \"IMS\"\n # save binary type (cannot look by parent because the OBO file is different and\n # the parser doesn't hadle it well, need to first improve the OBO parser)\n if stanza.id == FileContent::CONTINUOUS\n file_content.binary_type = :continuous\n elsif stanza.id == FileContent::PROCESSED\n file_content.binary_type = :processed\n end\n\n # save checksum type\n if stanza.id == FileContent::MD5\n file_content.checksum = element[:value]\n elsif stanza.id == FileContent::SHA1\n file_content.checksum = element[:value]\n end\n\n # save identifier\n if stanza.id == FileContent::UNIVERSALLY_UNIQUE_IDENTIFIER\n file_content.uuid = element[:value]\n end\n end\n\n end\n\n # save reference group for further usage\n if name == :cvParam && @stack.last == :referenceableParamGroup\n (@reference_groups[@elements.last[:id].to_sym] ||= Array.new) << element\n end\n\n # save sample list\n if name == :cvParam && @stack.last == :sample\n samples = (@metadata.samples ||= Hash.new)\n samples[@elements.last[:id].to_sym] = element\n end\n\n # save software list (raw, without detailed parsing)\n if name == :software && @stack.last == :softwareList\n (@metadata.software ||= Array.new) << element\n end\n\n # save scan settings\n if name == :cvParam && @stack.last == :scanSettings\n scan_settings = (@metadata.scan_settings ||= Hash.new)\n setting = (scan_settings[@elements.last[:id].to_sym] ||= ScanSettings.new)\n\n cv = @obo[element[:cvRef]]\n stanza = cv.stanza(element[:accession])\n parent_id = stanza.parent_id\n\n case element[:cvRef]\n when \"IMS\"\n\n # detect correct line scan direction\n setting.line_scan_direction = case stanza.id\n when ScanSettings::LINE_SCAN_BOTTOM_UP\n :bottom_up\n when ScanSettings::LINE_SCAN_LEFT_RIGHT\n :left_right\n when ScanSettings::LINE_SCAN_RIGHT_LEFT\n :right_left\n when ScanSettings::LINE_SCAN_TOP_DOWN\n :top_down\n else\n setting.line_scan_direction\n end\n\n # detect scan direction\n setting.scan_direction = case stanza.id\n when ScanSettings::BOTTOM_UP\n :bottom_up\n when ScanSettings::LEFT_RIGHT\n :left_right\n when ScanSettings::RIGHT_LEFT\n :right_left\n when ScanSettings::TOP_DOWN\n :top_down\n else\n setting.scan_direction\n end\n\n # detect scan pattern\n setting.scan_pattern = case stanza.id\n when ScanSettings::MEANDERING\n :meandering\n when ScanSettings::ONE_WAY\n :one_way\n when ScanSettings::RANDOM_ACCESS\n :random_access\n when ScanSettings::FLY_BACK\n :fly_back\n else\n setting.scan_pattern\n end\n\n # detect scan type\n setting.scan_type = case stanza.id\n when ScanSettings::HORIZONTAL_LINE_SCAN\n :horizontal\n when ScanSettings::VERTICAL_LINE_SCAN\n :vertical\n else\n setting.scan_type\n end\n\n # detect image properties\n image = (setting.image ||= ImzML::Image.new)\n\n case stanza.id\n when ScanSettings::MAX_DIMENSION_X\n point = (image.max_dimension ||= ImzML::Point.new)\n point.x = element[:value].to_i\n when ScanSettings::MAX_DIMENSION_Y\n point = (image.max_dimension ||= ImzML::Point.new)\n point.y = element[:value].to_i\n when ScanSettings::MAX_COUNT_OF_PIXEL_X\n point = (image.max_pixel_count ||= ImzML::Point.new)\n point.x = element[:value].to_i\n when ScanSettings::MAX_COUNT_OF_PIXEL_Y\n point = (image.max_pixel_count ||= ImzML::Point.new)\n point.y = element[:value].to_i\n when ScanSettings::PIXEL_SIZE_X\n point = (image.pixel_size ||= ImzML::Point.new)\n point.x = element[:value].to_i\n when ScanSettings::PIXEL_SIZE_Y\n point = (image.pixel_size ||= ImzML::Point.new)\n point.y = element[:value].to_i\n end\n end\n\n end\n\n # parse processing methods\n if name == :cvParam && @stack.last == :processingMethod\n data_processing = (@metadata.data_processing ||= Hash.new)\n processing = (data_processing[@elements[-2][:id].to_sym] ||= DataProcessing.new)\n processing.processing_method = @elements.last\n (processing.processing_method[:actions] ||= Array.new) << element\n end\n\n # save spectrum position info\n if name == :cvParam && @stack.last == :scan\n spectrums = (@metadata.spectrums ||= Hash.new)\n spectrum = (spectrums[@elements[-3][:id].to_sym] ||= Spectrum.new)\n point = (spectrum.position ||= ImzML::Point.new)\n\n point.x = element[:value].to_i if element[:accession] == Spectrum::POSITION_X\n point.y = element[:value].to_i if element[:accession] == Spectrum::POSITION_Y\n end\n\n # save spectrum binary data info\n if name == :referenceableParamGroupRef && @stack.last == :binaryDataArray\n group = @reference_groups[element[:ref].to_sym]\n\n spectrum = @metadata.spectrums[@elements[-3][:id].to_sym]\n mz_binary = (spectrum.mz_binary ||= ImzML::Spectrum::BinaryData.new)\n intensity_binary = (spectrum.intensity_binary ||= ImzML::Spectrum::BinaryData.new)\n\n # detect type of the binary data info based on referenced group content\n group.each do |param|\n # p param\n @binary_type = case param[:accession]\n when ImzML::Spectrum::BinaryData::MZ_ARRAY\n :mz_binary\n when ImzML::Spectrum::BinaryData::INTENSITY_ARRAY\n :intensity_binary\n end\n\n break if !@binary_type.nil?\n end\n\n # detect binary data type\n number_type = nil\n group.each do |param|\n number_type = case param[:accession]\n when Spectrum::BinaryData::BINARY_TYPE_8BIT_INTEGER\n :int8\n when Spectrum::BinaryData::BINARY_TYPE_16BIT_INTEGER\n :int16\n when Spectrum::BinaryData::BINARY_TYPE_32BIT_INTEGER\n :int32\n when Spectrum::BinaryData::BINARY_TYPE_64BIT_INTEGER\n :int64\n when Spectrum::BinaryData::BINARY_TYPE_32BIT_FLOAT\n :float32\n when Spectrum::BinaryData::BINARY_TYPE_64BIT_FLOAT\n :float64\n end\n\n break if !number_type.nil?\n end\n self.send(\"#{@binary_type.to_s}_data_type=\", number_type) if !number_type.nil?\n end\n\n # save info about binary\n if name == :cvParam && @stack.last == :binaryDataArray\n spectrum = @metadata.spectrums[@elements[-3][:id].to_sym]\n\n # convert chosen type to mz_binary/intensity_binary property selector\n binary_data = spectrum.send(@binary_type.to_s)\n binary_data.filepath = binary_filepath\n binary_data.type = self.send(\"#{@binary_type}_data_type\")\n case element[:accession]\n when ImzML::Spectrum::BinaryData::EXTERNAL_ARRAY_LENGTH\n binary_data.length = element[:value].to_i\n when ImzML::Spectrum::BinaryData::EXTERNAL_OFFSET\n binary_data.offset = element[:value].to_i\n when ImzML::Spectrum::BinaryData::EXTERNAL_ENCODED_LENGHT\n binary_data.encoded_length = element[:value].to_i\n end\n\n end\n\n # p @metadata.spectrums if name == :binaryDataArray\n\n # p \"#{name} ended #{element}\"\n\n end",
"def content_outline record\n blocks = record.content_blocks if record.parsed_content.present?\n return unless blocks\n\n content_tag :ul, class: 'content-outline' do\n # Loop through each block in the record, and generate a short piece of text describing that block.\n for block in blocks\n case block['type']\n when 'paragraph'\n text = block['data']['text']\n if block['data']['type'] == 'header'\n result = tag.strong(text)\n else\n result = block['data']['text'].truncate(200)\n end\n\n when 'list'\n result = ''\n result = \"<em>#{translate('admin.javascript.blocks.list.type.contents')}</em><br>\" if block['data']['type'] == 'contents'\n result += block['data']['items'].map { |i|\n depth = (i.is_a?(Hash) ? (i.dig('level') || 'h2')[1].to_i : 2) - 1\n text = i.is_a?(Hash) ? i['text'] : i\n \"#{'—' * depth} #{text}\".truncate(60)\n }.join('<br>')\n result = sanitize(result, tags: %w[em br])\n\n when 'layout'\n result = block['data']['items'].map { |i| \"— #{i['title']}\" }.join('<br>')\n result = sanitize(result, tags: %w[br])\n\n when 'catalog'\n result = translate(\"activerecord.models.#{block['data']['type'].singularize}.other\")\n result += \": #{translate('admin.content.items', count: block['data']['items'].length)}\"\n\n when 'textbox'\n result = ''\n result += \"<strong>#{block['data']['title']}</strong><br>\" if block['data']['title'].present?\n result += \"#{block['data']['text']&.truncate(60)}<br>\" if block['data']['text'].present?\n result += tag.span(\"[#{block['data']['action']}] → \") + tag.small(block['data']['url']) if block['data']['action'].present? && block['data']['url'].present?\n result = sanitize(result, tags: %w[strong br])\n\n when 'action'\n result = tag.span(\"[#{block['data']['action']}] → \") + tag.small(block['data']['url']) if block['data']['action'] && block['data']['url']\n\n when 'media'\n result = if block['data']['type'] == 'image'\n block['data']['items'].map { |i| \"#{tag.i(class: 'image icon')} <a href=\\\"#{i['image']['preview']}\\\" target=\\\"_blank\\\">#{i['image']['preview'].split('/').last}</a>#{\" - \\\"#{i['caption'].truncate(100)}\\\"\" if i['caption']}\" }\n elsif block['data']['type'] == 'audio'\n block['data']['items'].map { |i| \"#{tag.i(class: 'volume up icon')} <a href=\\\"#{i['audio']['preview']}\\\" target=\\\"_blank\\\">#{i['title']}</a>\" }\n elsif block['data']['type'] == 'youtube'\n tag.span('[YouTube Embed] → ') + tag.small(\"https://www.youtube.com/watch?v=#{block['data']['youtube_id']}\") if block['data']['youtube_id'] # TODO: Translate\n else\n block['data']['items'].map { |i| \"#{tag.i(class: \"#{block['data']['type']} icon\")} #{i['name']} (#{i['id']})\" }\n end\n result = result.join('<br>') if result.kind_of?(Array)\n result = sanitize(result, tags: %w[i a br], attributes: %w[href class target])\n\n when 'vimeo'\n result = block['data']['items'].map { |i| \"#{tag.i(class: 'video icon')} #{i['title']}\" }.join('<br>')\n result = sanitize(result, tags: %w[i a br])\n\n when 'whitespace'\n separators = {\n large: '==',\n medium: '—',\n small: '--',\n }\n\n result = separators[block['data']['size'].to_sym] * 3\n\n else\n concat block.inspect\n end\n\n concat content_tag :li, result, class: \"content-outline__#{block['type']} content-outline__#{block['type']}--#{block['data']['type']}\"\n end\n end\n end",
"def create_locally\n write_file(@description, @news_name)\n write_file(@poster_file, @poster_name)\n end",
"def new_definition(sax, author_id)\n Definition.new.tap do |definition|\n definition.author_id = author_id\n definition.text = sax.text\n definition.source = sax.source\n definition.uri = sax.uri\n end\nend",
"def load_rails\n puts \"created Rails biblebook\"\n p = Biblebook.new\n p.title = \"Ruby on Rails\"\n p.author = \"Rails Community\"\n p.published_at = Date.new 2012, 12, 31\n p.intro = \"Rails is a super *web application* framework\"\n load_rails_md p\n p.save!\nend",
"def content\n \"#{title} #{description_text}\"\n end",
"def sauvegarder()\n\t\[email protected] = Header.temps\n\t\[email protected] = Header.score\n\t\[email protected] = @content[\"grille\"]\n\n\t\t## Sauvegarde la partie dans un fichier yaml au nom de l'utilisateur\n\t\[email protected] (@content[\"pseudo\"])\n\n\t\treturn self\n\tend",
"def create_subtitles\n self.outline[:subtitles].each do |subtitle, points_array|\n new_subtitle = self.subtitles.build(name: subtitle)\n points_array.each do |point_hash|\n point_hash.each do |point, note|\n new_point = new_subtitle.points.build(name: point)\n new_note = new_point.note.build(details: note)\n end\n end\n end\n end",
"def make_content(num=nil, options=nil)\n num ||= 1\n options ||= {}\n \n @generated_content = []\n ContentBase::CONTENT_CLASSES.each do |klass|\n @generated_content.push FactoryGirl.create_list(\n klass.to_s.underscore.to_sym, num.to_i, options\n )\n end\n \n @generated_content = @generated_content.flatten\n end",
"def create\n @structure_content = Structure::Content.new(params[:structure_content])\n\n respond_to do |format|\n if @structure_content.save\n format.html { redirect_to @structure_content, notice: 'Content was successfully created.' }\n format.json { render json: @structure_content, status: :created, location: @structure_content }\n else\n format.html { render action: \"new\" }\n format.json { render json: @structure_content.errors, status: :unprocessable_entity }\n end\n end\n end",
"def createProgramXMLSection( houseElements )\n loc = \"HouseFile\"\n houseElements[loc].add_element(\"Program\")\n\n loc = \"HouseFile/Program\"\n houseElements[loc].attributes[\"class\"] = \"ca.nrcan.gc.OEE.ERS.ErsProgram\"\n houseElements[loc].add_element(\"Labels\")\n\n loc = \"HouseFile/Program/Labels\"\n houseElements[loc].attributes[\"xmlns:xsi\"] = \"http://www.w3.org/2001/XMLSchema-instance\"\n houseElements[loc].attributes[\"xmlns:xsd\"] = \"http://www.w3.org/2001/XMLSchema\"\n houseElements[loc].add_element(\"English\")\n loc = \"HouseFile/Program/Labels/English\"\n houseElements[loc].add_text(\"EnerGuide Rating System\")\n loc = \"HouseFile/Program/Labels\"\n houseElements[loc].add_element(\"French\")\n loc = \"HouseFile/Program/Labels/French\"\n houseElements[loc].add_text(\"Système de cote ÉnerGuide\")\n\n loc = \"HouseFile/Program\"\n houseElements[loc].add_element(\"Version\")\n loc = \"HouseFile/Program/Version\"\n houseElements[loc].attributes[\"xmlns:xsi\"] = \"http://www.w3.org/2001/XMLSchema-instance\"\n houseElements[loc].attributes[\"xmlns:xsd\"] = \"http://www.w3.org/2001/XMLSchema\"\n houseElements[loc].attributes[\"major\"] = \"15\"\n houseElements[loc].attributes[\"minor\"] = \"1\"\n houseElements[loc].attributes[\"build\"] = \"19\"\n houseElements[loc].add_element(\"Labels\")\n loc = \"HouseFile/Program/Version/Labels\"\n houseElements[loc].add_element(\"English\")\n loc = \"HouseFile/Program/Labels/English\"\n houseElements[loc].add_text(\"v15.1b19\")\n loc = \"HouseFile/Program/Version/Labels\"\n houseElements[loc].add_element(\"French\")\n loc = \"HouseFile/Program/Labels/French\"\n houseElements[loc].add_text(\"v15.1b19\")\n\n loc = \"HouseFile/Program\"\n houseElements[loc].add_element(\"SdkVersion\")\n loc = \"HouseFile/Program/SdkVersion\"\n houseElements[loc].attributes[\"xmlns:xsi\"] = \"http://www.w3.org/2001/XMLSchema-instance\"\n houseElements[loc].attributes[\"xmlns:xsd\"] = \"http://www.w3.org/2001/XMLSchema\"\n houseElements[loc].attributes[\"major\"] = \"1\"\n houseElements[loc].attributes[\"minor\"] = \"11\"\n houseElements[loc].add_element(\"Labels\")\n loc = \"HouseFile/Program/SdkVersion/Labels\"\n houseElements[loc].add_element(\"English\")\n loc = \"HouseFile/Program/Labels/English\"\n houseElements[loc].add_text(\"v1.11\")\n loc = \"HouseFile/Program/SdkVersion/Labels\"\n houseElements[loc].add_element(\"French\")\n loc = \"HouseFile/Program/Labels/French\"\n houseElements[loc].add_text(\"v1.11\")\n\n loc = \"HouseFile/Program\"\n houseElements[loc].add_element(\"Options\")\n loc = \"HouseFile/Program/Options\"\n houseElements[loc].attributes[\"xmlns:xsi\"] = \"http://www.w3.org/2001/XMLSchema-instance\"\n houseElements[loc].attributes[\"xmlns:xsd\"] = \"http://www.w3.org/2001/XMLSchema\"\n houseElements[loc].add_element(\"Main\")\n loc = \"HouseFile/Program/Options/Main\"\n houseElements[loc].attributes[\"applyHouseholdOperatingConditions\"] = \"false\"\n houseElements[loc].attributes[\"applyReducedOperatingConditions\"] = \"false\"\n houseElements[loc].attributes[\"atypicalElectricalLoads\"] = \"false\"\n houseElements[loc].attributes[\"waterConservation\"] = \"false\"\n houseElements[loc].attributes[\"referenceHouse\"] = \"false\"\n houseElements[loc].add_element(\"Vermiculite\")\n loc = \"HouseFile/Program/Options/Main/Vermiculite\"\n houseElements[loc].attributes[\"code\"] = \"1\"\n houseElements[loc].add_element(\"English\")\n loc = \"HouseFile/Program/Options/Main/Vermiculite/English\"\n houseElements[loc].add_text(\"Unknown\")\n loc = \"HouseFile/Program/Options/Main/Vermiculite\"\n houseElements[loc].add_element(\"French\")\n loc = \"HouseFile/Program/Options/Main/Vermiculite/French\"\n houseElements[loc].add_text(\"Inconnu\")\n loc = \"HouseFile/Program/Options\"\n houseElements[loc].add_element(\"RURComments\")\n loc = \"HouseFile/Program/Options/RURComments\"\n houseElements[loc].attributes[\"xml:space\"] = \"preserve\"\n\n loc = \"HouseFile/Program\"\n houseElements[loc].add_element(\"Results\")\n loc = \"HouseFile/Program/Results\"\n houseElements[loc].attributes[\"xmlns:xsi\"] = \"http://www.w3.org/2001/XMLSchema-instance\"\n houseElements[loc].attributes[\"xmlns:xsd\"] = \"http://www.w3.org/2001/XMLSchema\"\n houseElements[loc].add_element(\"Tsv\")\n houseElements[loc].add_element(\"Ers\")\n houseElements[loc].add_element(\"RefHse\")\n\nend",
"def load_rails\n puts \"created Rails post\"\n p = Post.new\n p.title = \"Ruby on Rails\"\n p.author = \"Rails Community\"\n p.published_at = Date.new 2012, 12, 31\n p.intro = \"Rails is a super *web application* framework\"\n load_rails_md p\n p.save!\nend",
"def generate(ignore_missing: false)\n data = self.data\n if data.blank?\n raise FphsException, 'Data is blank and item_type / item_id does not return an item' unless item\n\n data = Formatter::Substitution.setup_data item, for_item\n data[:_subject] = subject\n data[:extra_substitutions] = extra_substitutions_data\n\n end\n\n raise FphsException, \"Layout template #{layout_template_name} was not found\" unless layout_template\n\n if content_template_name\n raise FphsException, \"Content template #{content_template_name} was not found\" unless content_template\n elsif !content_template_text\n raise FphsException, 'Content template name or text must be set'\n end\n\n self.generated_text = layout_template.generate content_template_name: content_template_name,\n content_template_text: content_template_text,\n data: data,\n ignore_missing: ignore_missing\n\n self.generated_content = generated_text\n save!\n end",
"def create\n @description = Description.new(params[:description])\n \n respond_to do |format|\n if @description.save_and_index\n flash[:notice] = 'Description was successfully created.'\n format.html { redirect_to(@description) }\n format.xml { render :xml => @description, :status => :created, :location => @description }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @description.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new_element\n # collect element data\n class_key = params[:classKey]\n element = keytechAPI.element_handler.new_element(class_key)\n\n # Layout holds all controls to fill\n layout = getLayout(class_key)\n errors = []\n layout.controls.each do |control|\n # Labels are the only control type a element can not use for data\n next unless control.controlType != 'LABEL'\n\n key = control.attributeName\n value = params[control.attributeName]\n\n unless control.isNullable\n if value.blank?\n errors.push \"Feld '#{control.displayname}' darf nicht leer sein. \"\n end\n end\n\n element.keyValueList[key] = value\n end\n\n unless errors.empty?\n logger.error \"Errors occured: #{errors.inspect}\"\n flash[:warning] = errors\n return redirect_back(fallback_location: root_path)\n end\n\n saved_element = keytechAPI.element_handler.save(element)\n # Save ok? If not create a warning and rebuild\n logger.info \"New element saved: #{saved_element.key}\"\n if saved_element.blank?\n logger.warn('Could not save element')\n flash[:warning] = 'Konnte Element nicht anlegen.'\n redirect_back(fallback_location: root_path)\n else\n flash[:info] = 'Element wurde angelegt.'\n redirect_to show_element_path(id: saved_element.key)\n end\n end",
"def createH2KSysType1( elements, sysType1Name )\n locationText = \"HouseFile/House/HeatingCooling/Type1\"\n\n elements[locationText].add_element(sysType1Name)\n if ( sysType1Name == \"Baseboards\" )\n locationText = \"HouseFile/House/HeatingCooling/Type1/Baseboards\"\n elements[locationText].add_element(\"EquipmentInformation\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/Baseboards/EquipmentInformation\"\n elements[locationText].attributes[\"numberOfElectronicThermostats\"] = \"0\"\n\n locationText = \"HouseFile/House/HeatingCooling/Type1/Baseboards\"\n elements[locationText].add_element(\"Specifications\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/Baseboards/Specifications\"\n elements[locationText].attributes[\"sizingFactor\"] = \"1.1\"\n elements[locationText].attributes[\"efficiency\"] = \"100\"\n elements[locationText].add_element(\"OutputCapacity\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/Baseboards/Specifications/OutputCapacity\"\n elements[locationText].attributes[\"code\"] = \"2\" # Calculated\n elements[locationText].attributes[\"value\"] = \"0\" # Calculated value - will be replaced!\n elements[locationText].attributes[\"uiUnits\"] = \"kW\"\n elements[locationText].add_element(\"English\")\n elements[locationText].add_element(\"French\")\n\n elsif ( sysType1Name == \"Furnace\" )\n\n\n stream_out (\"ADDING FURNACE ....\\n\")\n\n locationText = \"HouseFile/House/HeatingCooling/Type1/Furnace\"\n elements[locationText].add_element(\"EquipmentInformation\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/Furnace/EquipmentInformation\"\n elements[locationText].attributes[\"energystar\"] = \"false\"\n elements[locationText].add_element(\"Manufacturer\")\n\n locationText = \"HouseFile/House/HeatingCooling/Type1/Furnace\"\n elements[locationText].add_element(\"Equipment\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/Furnace/Equipment\"\n elements[locationText].attributes[\"isBiEnergy\"] = \"false\"\n elements[locationText].attributes[\"switchoverTemperature\"] = \"0\"\n elements[locationText].add_element(\"EnergySource\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/Furnace/Equipment/EnergySource\"\n elements[locationText].attributes[\"code\"] = \"2\" # Gas\n elements[locationText].add_element(\"English\")\n elements[locationText].add_element(\"French\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/Furnace/Equipment\"\n elements[locationText].add_element(\"EquipmentType\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/Furnace/Equipment/EquipmentType\"\n elements[locationText].attributes[\"code\"] = \"1\" # Furnace with cont. pilot\n elements[locationText].add_element(\"English\")\n elements[locationText].add_element(\"French\")\n\n locationText = \"HouseFile/House/HeatingCooling/Type1/Furnace\"\n elements[locationText].add_element(\"Specifications\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/Furnace/Specifications\"\n elements[locationText].attributes[\"sizingFactor\"] = \"1.1\"\n elements[locationText].attributes[\"efficiency\"] = \"78\"\n elements[locationText].attributes[\"isSteadyState\"] = \"true\"\n elements[locationText].attributes[\"pilotLight\"] = \"0\"\n elements[locationText].attributes[\"flueDiameter\"] = \"127\"\n elements[locationText].add_element(\"OutputCapacity\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/Furnace/Specifications/OutputCapacity\"\n elements[locationText].attributes[\"code\"] = \"2\" # Calculated\n elements[locationText].attributes[\"value\"] = \"0\" # Calculated value - will be replaced!\n elements[locationText].attributes[\"uiUnits\"] = \"kW\"\n elements[locationText].add_element(\"English\")\n elements[locationText].add_element(\"French\")\n\n elsif ( sysType1Name == \"Boiler\" )\n locationText = \"HouseFile/House/HeatingCooling/Type1/Boiler\"\n elements[locationText].add_element(\"EquipmentInformation\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/Boiler/EquipmentInformation\"\n elements[locationText].attributes[\"energystar\"] = \"false\"\n elements[locationText].add_element(\"Manufacturer\")\n\n locationText = \"HouseFile/House/HeatingCooling/Type1/Boiler\"\n elements[locationText].add_element(\"Equipment\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/Boiler/Equipment\"\n elements[locationText].attributes[\"isBiEnergy\"] = \"false\"\n elements[locationText].attributes[\"switchoverTemperature\"] = \"0\"\n elements[locationText].add_element(\"EnergySource\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/Boiler/Equipment/EnergySource\"\n elements[locationText].attributes[\"code\"] = \"2\" # Gas\n elements[locationText].add_element(\"English\")\n elements[locationText].add_element(\"French\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/Boiler/Equipment\"\n elements[locationText].add_element(\"EquipmentType\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/Boiler/Equipment/EquipmentType\"\n elements[locationText].attributes[\"code\"] = \"1\" # Boiler with cont. pilot\n elements[locationText].add_element(\"English\")\n elements[locationText].add_element(\"French\")\n\n locationText = \"HouseFile/House/HeatingCooling/Type1/Boiler\"\n elements[locationText].add_element(\"Specifications\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/Boiler/Specifications\"\n elements[locationText].attributes[\"sizingFactor\"] = \"1.1\"\n elements[locationText].attributes[\"efficiency\"] = \"78\"\n elements[locationText].attributes[\"isSteadyState\"] = \"true\"\n elements[locationText].attributes[\"pilotLight\"] = \"0\"\n elements[locationText].attributes[\"flueDiameter\"] = \"127\"\n elements[locationText].add_element(\"OutputCapacity\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/Boiler/Specifications/OutputCapacity\"\n elements[locationText].attributes[\"code\"] = \"2\" # Calculated\n elements[locationText].attributes[\"value\"] = \"0\" # Calculated value - will be replaced!\n elements[locationText].attributes[\"uiUnits\"] = \"kW\"\n elements[locationText].add_element(\"English\")\n elements[locationText].add_element(\"French\")\n\n elsif ( sysType1Name == \"ComboHeatDhw\" )\n locationText = \"HouseFile/House/HeatingCooling/Type1/ComboHeatDhw\"\n elements[locationText].add_element(\"EquipmentInformation\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/ComboHeatDhw/EquipmentInformation\"\n elements[locationText].attributes[\"energystar\"] = \"false\"\n elements[locationText].add_element(\"Manufacturer\")\n\n locationText = \"HouseFile/House/HeatingCooling/Type1/ComboHeatDhw\"\n elements[locationText].add_element(\"Equipment\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/ComboHeatDhw/Equipment\"\n elements[locationText].add_element(\"EnergySource\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/ComboHeatDhw/Equipment/EnergySource\"\n elements[locationText].attributes[\"code\"] = \"2\" # Gas\n elements[locationText].add_element(\"English\")\n elements[locationText].add_element(\"French\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/ComboHeatDhw/Equipment\"\n elements[locationText].add_element(\"EquipmentType\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/ComboHeatDhw/Equipment/EquipmentType\"\n elements[locationText].attributes[\"code\"] = \"1\" # ComboHeatDhw with cont. pilot\n elements[locationText].add_element(\"English\")\n elements[locationText].add_element(\"French\")\n\n locationText = \"HouseFile/House/HeatingCooling/Type1/ComboHeatDhw\"\n elements[locationText].add_element(\"Specifications\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/ComboHeatDhw/Specifications\"\n elements[locationText].attributes[\"sizingFactor\"] = \"1.1\"\n elements[locationText].attributes[\"efficiency\"] = \"78\"\n elements[locationText].attributes[\"isSteadyState\"] = \"true\"\n elements[locationText].attributes[\"pilotLight\"] = \"25.3\"\n elements[locationText].attributes[\"flueDiameter\"] = \"152.4\"\n elements[locationText].add_element(\"OutputCapacity\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/ComboHeatDhw/Specifications/OutputCapacity\"\n elements[locationText].attributes[\"code\"] = \"2\" # Calculated\n elements[locationText].attributes[\"value\"] = \"0\" # Calculated value - will be replaced!\n elements[locationText].attributes[\"uiUnits\"] = \"kW\"\n elements[locationText].add_element(\"English\")\n elements[locationText].add_element(\"French\")\n\n locationText = \"HouseFile/House/HeatingCooling/Type1/ComboHeatDhw\"\n elements[locationText].add_element(\"ComboTankAndPump\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/ComboHeatDhw/ComboTankAndPump\"\n elements[locationText].add_element(\"TankCapacity\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/ComboHeatDhw/ComboTankAndPump/TankCapacity\"\n elements[locationText].attributes[\"code\"] = \"3\"\n elements[locationText].attributes[\"value\"] = \"151.4\"\n elements[locationText].add_element(\"English\")\n elements[locationText].add_element(\"French\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/ComboHeatDhw/ComboTankAndPump\"\n elements[locationText].add_element(\"EnergyFactor\")\n elements[locationText].attributes[\"useDefaults\"] = \"true\"\n locationText = \"HouseFile/House/HeatingCooling/Type1/ComboHeatDhw/ComboTankAndPump\"\n elements[locationText].add_element(\"TankLocation\")\n elements[locationText].attributes[\"code\"] = \"2\"\n elements[locationText].add_element(\"English\")\n elements[locationText].add_element(\"French\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/ComboHeatDhw/ComboTankAndPump\"\n elements[locationText].add_element(\"CirculationPump\")\n elements[locationText].attributes[\"isCalculated\"] = \"true\"\n elements[locationText].attributes[\"value\"] = \"0\"\n elements[locationText].attributes[\"hasEnergyEfficientMotor\"] = \"false\"\n\n elsif ( sysType1Name == \"P9\" )\n locationText = \"HouseFile/House/HeatingCooling/Type1/P9\"\n elements[locationText].attributes[\"id\"] = \"0\"\n elements[locationText].attributes[\"numberOfSystems\"] = \"1\"\n elements[locationText].attributes[\"thermalPerformanceFactor\"] = \"0.9\"\n elements[locationText].attributes[\"annualElectricity\"] = \"1800\"\n elements[locationText].attributes[\"spaceHeatingCapacity\"] = \"23900\"\n elements[locationText].attributes[\"spaceHeatingEfficiency\"] = \"90\"\n elements[locationText].attributes[\"waterHeatingPerformanceFactor\"] = \"0.9\"\n elements[locationText].attributes[\"burnerInput\"] = \"0\"\n elements[locationText].attributes[\"recoveryEfficiency\"] = \"0\"\n elements[locationText].attributes[\"isUserSpecified\"] = \"true\"\n elements[locationText].add_element(\"EquipmentInformation\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/P9/EquipmentInformation\"\n elements[locationText].add_element(\"Manufacturer\")\n elements[locationText].add_element(\"Model\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/P9/EquipmentInformation/Manufacturer\"\n elements[locationText].text = \"Generic\"\n locationText = \"HouseFile/House/HeatingCooling/Type1/P9/EquipmentInformation/Model\"\n elements[locationText].text = \"Generic\"\n\n locationText = \"HouseFile/House/HeatingCooling/Type1/P9\"\n elements[locationText].add_element(\"TestData\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/P9/TestData\"\n elements[locationText].attributes[\"controlsPower\"] = \"10\"\n elements[locationText].attributes[\"circulationPower\"] = \"130\"\n elements[locationText].attributes[\"dailyUse\"] = \"0.2\"\n elements[locationText].attributes[\"standbyLossWithFan\"] = \"0\"\n elements[locationText].attributes[\"standbyLossWithoutFan\"] = \"0\"\n elements[locationText].attributes[\"oneHourRatingHotWater\"] = \"1000\"\n elements[locationText].attributes[\"oneHourRatingConcurrent\"] = \"1000\"\n elements[locationText].add_element(\"EnergySource\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/P9/TestData/EnergySource\"\n elements[locationText].attributes[\"code\"] = \"2\"\n elements[locationText].add_element(\"English\")\n elements[locationText].add_element(\"French\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/P9/TestData\"\n elements[locationText].add_element(\"NetEfficiency\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/P9/TestData/NetEfficiency\"\n elements[locationText].attributes[\"loadPerformance15\"] = \"80\"\n elements[locationText].attributes[\"loadPerformance40\"] = \"80\"\n elements[locationText].attributes[\"loadPerformance100\"] = \"80\"\n locationText = \"HouseFile/House/HeatingCooling/Type1/P9/TestData\"\n elements[locationText].add_element(\"ElectricalUse\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/P9/TestData/ElectricalUse\"\n elements[locationText].attributes[\"loadPerformance15\"] = \"100\"\n elements[locationText].attributes[\"loadPerformance40\"] = \"200\"\n elements[locationText].attributes[\"loadPerformance100\"] = \"300\"\n locationText = \"HouseFile/House/HeatingCooling/Type1/P9/TestData\"\n elements[locationText].add_element(\"BlowerPower\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/P9/TestData/BlowerPower\"\n elements[locationText].attributes[\"loadPerformance15\"] = \"300\"\n elements[locationText].attributes[\"loadPerformance40\"] = \"500\"\n elements[locationText].attributes[\"loadPerformance100\"] = \"800\"\n end\nend",
"def create_default\n # Default values\n self.site_title = I18n.t 'websites.default.home_title'\n self.home_title = I18n.t 'websites.default.home_title'\n self.home_icon = I18n.t 'websites.default.home_icon'\n self.top_title = I18n.t 'websites.default.top_title'\n self.top_intro = I18n.t 'websites.default.top_intro'\n self.bottom_title = I18n.t 'websites.default.bottom_title'\n self.bottom_intro = I18n.t 'websites.default.bottom_intro'\n self.featured_title = I18n.t 'websites.default.featured_title'\n self.markdown = I18n.t 'websites.default.markdown'\n self.show_featured = true\n self.show_markdown = true\n # Create components\n modules = Rails.configuration.scribae['modules']\n modules.each_with_index do |comp_name, index|\n component = Component.new do |comp| \n comp.name = comp_name\n comp.icon_color = \"#6268c0\"\n comp.pos = index + 1\n comp.show = I18n.t \"websites.default.components.#{comp_name}.show\"\n comp.icon = I18n.t \"websites.default.components.#{comp_name}.icon\"\n comp.title = I18n.t \"websites.default.components.#{comp_name}.title\"\n comp.intro = I18n.t \"websites.default.components.#{comp_name}.intro\"\n end\n self.components << component\n end\n # Create preview and gitconfig\n parameterized = self.name.parameterize\n self.preview = Preview.new do |preview|\n preview.prototype = \"default\"\n preview.name = parameterized\n preview.process = 0\n preview.status = 0\n end\n self.gitconfig = Gitconfig.new do |git|\n git.base_url = parameterized\n git.initialized = false\n git.repo_link = \"\"\n git.website_link = \"\"\n end\n # Background images\n bg_file = File.open(Rails.root.join('app', 'assets', 'images', 'parallax.jpg'))\n ['top', 'bottom'].each do |name|\n image = Image.new do |img|\n img.name = name\n img.category = 'bg'\n img.upload = bg_file\n end \n self.images << image\n end\n # Style\n self.style = Style.new do |style|\n style.helper = \"\"\n style.navbar = \"#ffffff\"\n style.primary = \"#ffffff\"\n style.secondary = \"#000000\"\n style.background = \"#ffffff\"\n style.icon = \"#000000\"\n style.text = \"#000000\"\n style.decoration = \"#ffffff\"\n end\n end",
"def set_editable_elements(attributes)\n return if attributes.blank?\n\n self.editable_elements ||= []\n\n attributes.to_a.each do |_attributes|\n if _attributes.is_a?(Array) # attributes is maybe a Hash\n block, slug = _attributes.first.split('/')\n _attributes = { 'block' => block, 'slug' => slug, 'content' => _attributes.last }\n end\n\n # does an editable element exist with the same couple block/slug ?\n if editable_element = self.find_editable_element(_attributes['block'], _attributes['slug'])\n editable_element.content = _attributes['content']\n else\n self.editable_elements << Locomotive::Mounter::Models::EditableElement.new(_attributes)\n end\n end\n end",
"def new_txt_record(domain, content)\n r = Record.new\n\n r.domain_id = domain.id\n r.name = domain.name\n r.type = \"TXT\"\n r.content = content\n r.ttl = 3600\n r.prio = 0\n r.change_date = Time.now.to_i\n\n r.save\n return r\n end",
"def create_md tool\n \n original = tool[1].split(\"\\n\")\n new = []\n note = false\n\n # Cambia las rutas y < y > por código HTML\n def diple l\n return l.gsub('de +++YAML+++ en <http://pecas.cliteratu.re>', 'de [+++YAML+++](yaml.html)')\n .gsub('de JavaScript en <http://pecas.cliteratu.re>', 'de [JavaScript](js.html)')\n .gsub('Lista de acrónimos: <https://github.com/tesseract-ocr/tesseract/blob/master/doc/tesseract.1.asc#languages>', '[Lista de acrónimos](https://github.com/tesseract-ocr/tesseract/blob/master/doc/tesseract.1.asc#languages)')\n .gsub('<','<').gsub('>','>')\n end\n\n # Agrega versalitas\n def smallcaps l\n return l.gsub(/([A-Z]{3,})/, '+++\\1+++')\n end\n\n # Cambia comillas por sintaxis para línea de código\n def to_code l\n return l.gsub(/«(.+?)»/, '`\\1`')\n end\n\n # Añade líneas de código en las opciones\n def to_code_option l\n return l.gsub(/^(\\S+)/, '`\\1`')\n end\n\n new.push('# ' + $l_g_pc_docs_creation + '`' + tool[0] + '`')\n\n original.each_with_index do |l, i|\n\n l = to_code(diple(smallcaps(l)))\n\n if l =~ /^\\S/\n # Encabezados 2\n if l !~ /^Nota/ && i != 1\n new.push('## ' + l + \"\\n\\n\")\n # Párrafos\n else\n # Notas\n if l =~ /^Nota/\n if !note\n new.push(\"--- {.espacio-arriba3}\\n\\n\")\n note = true\n new.push(l + ' {.espacio-arriba3}')\n else\n new.push(l + ' {.espacio-arriba1 .sin-sangria}')\n end \n # Descripción\n else\n # Esto servirá para crear «herramientas.md»\n $tools_md[\"#{tool[0]}\"] = [tool[0], l.gsub(/^\\S+\\s+/, '')]\n new.push(l)\n end\n end\n else\n if l.strip != ''\n l = l.strip\n\n # Opciones de Pecas\n if l =~ /^-/\n new.push('* ' + to_code_option(l))\n # Comandos de Pecas\n elsif l =~ /^pc-/\n new.push('```')\n new.push(l)\n new.push('```')\n # Explicaciones\n elsif l =~ /^[A-Z]/\n new.push(\"\\n\" + l)\n # Dependencias / Tipos\n else\n # Evita que se quede como línea de código el tipo y su descripción\n l_final = []\n l.split(/\\s+/).each_with_index do |ll, i|\n # Solo la primera palabra se va como código\n if i == 0\n l_final.push('* `' + ll + '`')\n # El resto de las palabras se quedan como texto\n else\n l_final.push(ll)\n end\n end\n new.push(l_final.join(' '))\n end\n # Líneas en blanco\n else\n new.push(l)\n end\n end\n end\n\n\tarchivo = File.new(Dir.pwd + '/md/' + tool[0] + '.md', 'w:UTF-8')\n\tarchivo.puts new\n\tarchivo.close\nend",
"def create_stages_from_serialized_content!(serialized_content_array, actions, opts = {})\n serialized_content_array.each do |serialized_content|\n #serialized_content[:nodenodeob] = opts[:nodes]{cat node id?}\n #if nodes = opts[:nodes] add_node_ids(serialized_content_array, nodes)\n if nodes = opts[:nodes] \n add_node_object_info!(serialized_content, nodes)\n end\n if stage = Stage::InterNode.parse_and_reify?(serialized_content, actions, opts)\n stage.attempts = opts[:attempts]\n stage.retry = opts[:retry]\n stage.add_to_template_content!(self, serialized_content, just_parse: opts[:just_parse])\n end\n end\n end",
"def prepare_final_xml\n @base_xml.elements[\"#{@ns}:OccupancyLevels/#{@ns}:OccupancyLevel/#{@ns}:OccupantQuantity\"].text = @occupant_quantity if !@occupant_quantity.nil?\n @base_xml.elements[\"#{@ns}:SpatialUnits/#{@ns}:SpatialUnit/#{@ns}:NumberOfUnits\"].text = @number_of_units if !@number_of_units.nil?\n\n # Add new element in the XML file\n add_user_defined_field_to_xml_file('OpenStudioModelName', @name)\n add_user_defined_field_to_xml_file('StandardTemplateYearOfConstruction', @built_year)\n add_user_defined_field_to_xml_file('StandardTemplate', @standard_template)\n add_user_defined_field_to_xml_file('BuildingRotation', @building_rotation)\n add_user_defined_field_to_xml_file('FloorHeight', @floor_height)\n add_user_defined_field_to_xml_file('WindowWallRatio', @wwr)\n add_user_defined_field_to_xml_file('PartyWallStoriesNorth', @party_wall_stories_north)\n add_user_defined_field_to_xml_file('PartyWallStoriesSouth', @party_wall_stories_south)\n add_user_defined_field_to_xml_file('PartyWallStoriesEast', @party_wall_stories_east)\n add_user_defined_field_to_xml_file('PartyWallStoriesWest', @party_wall_stories_west)\n add_user_defined_field_to_xml_file('Width', @width)\n add_user_defined_field_to_xml_file('Length', @length)\n add_user_defined_field_to_xml_file('PartyWallFraction', @party_wall_fraction)\n add_user_defined_field_to_xml_file('ModelNumberThermalZones', @model.getThermalZones.size)\n add_user_defined_field_to_xml_file('ModelNumberSpaces', @model.getSpaces.size)\n add_user_defined_field_to_xml_file('ModelNumberStories', @model.getBuildingStorys.size)\n add_user_defined_field_to_xml_file('ModelNumberPeople', @model.getBuilding.numberOfPeople)\n add_user_defined_field_to_xml_file('ModelFloorArea(m2)', @model.getBuilding.floorArea)\n\n wf = @model.weatherFile.get\n add_user_defined_field_to_xml_file('ModelWeatherFileName', wf.nameString)\n add_user_defined_field_to_xml_file('ModelWeatherFileDataSource', wf.dataSource)\n add_user_defined_field_to_xml_file('ModelWeatherFileCity', wf.city)\n add_user_defined_field_to_xml_file('ModelWeatherFileStateProvinceRegion', wf.stateProvinceRegion)\n add_user_defined_field_to_xml_file('ModelWeatherFileLatitude', wf.latitude)\n add_user_defined_field_to_xml_file('ModelWeatherFileLongitude', wf.longitude)\n prepare_final_xml_for_spatial_element\n end",
"def make_new_file\n\t\tmetadata_file_data = \"\"\n\t\tmetadata_file_data << \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"yes\\\"?><cp:coreProperties\"\n\t\tmetadata_file_data << \" xmlns:cp=\\\"http://schemas.openxmlformats.org/package/2006/metadata/core-properties\\\" \"\n\t\tmetadata_file_data << \"xmlns:dc=\\\"http://purl.org/dc/elements/1.1/\\\" xmlns:dcterms=\\\"http://purl.org/dc/terms/\\\" \"\n\t\tmetadata_file_data << \"xmlns:dcmitype=\\\"http://purl.org/dc/dcmitype/\\\" xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\">\"\n\t\tmetadata_file_data << \"<dc:creator>#{datastore['DOCAUTHOR']}</dc:creator><cp:lastModifiedBy>#{datastore['DOCAUTHOR']}\"\n\t\tmetadata_file_data << \"</cp:lastModifiedBy><cp:revision>1</cp:revision><dcterms:created xsi:type=\\\"dcterms:W3CDTF\\\">\"\n\t\tmetadata_file_data << \"2013-01-08T14:14:00Z</dcterms:created><dcterms:modified xsi:type=\\\"dcterms:W3CDTF\\\">\"\n\t\tmetadata_file_data << \"2013-01-08T14:14:00Z</dcterms:modified></cp:coreProperties>\"\n\n\t\t#where to find the skeleton files required for creating an empty document\n\t\tdata_dir = File.join(Msf::Config.install_root, \"data\", \"exploits\", \"docx\")\n\n\t\t#making the actual docx\n\t\tdocx = Rex::Zip::Archive.new\n\t\t#add skeleton files\n\t\tvprint_status(\"Adding skeleton files from #{data_dir}\")\n\t\tDir[\"#{data_dir}/**/**\"].each do |file|\n\t\t\tif not File.directory?(file)\n\t\t\t\tdocx.add_file(file.sub(data_dir,''), File.read(file))\n\t\t\tend\n\t\tend\n\t\t#add on-the-fly created documents\n\t\tvprint_status(\"Adding injected files\")\n\t\tdocx.add_file(\"docProps/core.xml\", metadata_file_data)\n\t\tdocx.add_file(\"word/_rels/settings.xml.rels\", @rels_file_data)\n\t\t#add the otherwise skipped \"hidden\" file\n\t\tfile = \"#{data_dir}/_rels/.rels\"\n\t\tdocx.add_file(file.sub(data_dir,''), File.read(file))\n\t\t#and lets create the file\n\t\tfile_create(docx.pack)\n\tend",
"def create_element(name, *contents_or_attrs, &block); end",
"def assert_content_model\n add_relationship(:has_model, \"info:fedora/hull-cModel:examPaper\")\n add_relationship(:has_model, \"info:fedora/hydra-cModel:compoundContent\")\n add_relationship(:has_model, \"info:fedora/hydra-cModel:commonMetadata\")\n end",
"def create_from_file\n end",
"def scrape_medium_story_create_inspirations\n url = \"https://medium.com/topic/editors-picks\"\n html_file = open(url).read\n html_doc = Nokogiri::HTML(html_file)\n\n # browser = Watir::Browser.new\n # browser.goto 'https://medium.com/topic/editors-picks'\n\n # html_doc = Nokogiri::HTML.parse(browser.html)\n\n\n html_doc.xpath(\"//div[contains(concat(' ',normalize-space(@class)), 'l er q s es bz et eu ev v')]\").each do |card|\n #ai y cl bj cm bk dq ez fa ak an ds cr gk gl\n article_name = card.search('.ai.y.ce.at.cf.au.di.ex.ey.ak.an.dk.ck.cl.am').first.children.first.children.text unless card.search('.ai.y.ce.at.cf.au.di.ex.ey.ak.an.dk.ck.cl.am').empty?\n article_link = card.xpath(\".//div[contains(concat(' ',normalize-space(@class)), 'ew d ev v cc')]/div/a/@href\").first.value\n duration_text = card.xpath(\".//div[contains(concat(' ',normalize-space(@class)), 'ec s ed')]\").first.text\n article_duration = duration_text.gsub(/(\\D+\\s)(\\d+.)(\\d+)(.*)/, '\\3').to_i\n Inspiration.create(\n inspiration_type: 'article',\n source: 'Medium',\n duration: article_duration + 1, # because Medium round it below ?\n name: article_name,\n url: article_link\n )\n end\n\n end",
"def create\n\n if params[:sample]\n analyse = Ca::Analyse.new(HTMLReader.instance.page(params[:sample][:address]));\n end\n if params[:text]\n analyse = Ca::Analyse.new(params[:text][:content]);\n end\n descript = analyse.description\n @problems = descript.problems\n @text = descript.text\n @best_phrases = Hash[analyse.description.first_n]\n @nr_of_chars = descript.text_number_of_chars\n @nr_of_words = descript.text_number_of_words\n @nr_of_nodes = descript.nr_of_nodes\n @score = descript.score\n @plagiarism = descript.plagiarism\n @html = descript.text.to_s.force_encoding(\"UTF-8\")\n @tags_problem = descript.tag_problem_flag\n end",
"def initialize(xml_contents)\n @doc = @entry = Document.parse(xml_contents)\n details = @doc.at_xpath('measure/measureDetails')\n @id = details.at_xpath('uuid').text.upcase\n @hqmf_set_id = details.at_xpath('guid').text.upcase\n @hqmf_version_number = details.at_xpath('version').text.to_i\n @title = details.at_xpath('title').text\n @description = details.at_xpath('description').text\n @cms_id = \"CMS#{details.at_xpath('emeasureid').text}v#{@hqmf_version_number}\"\n @nqf_id = details.at_xpath('nqfid/@extension').value\n\n @attributes = []\n details.children.reject {|e| e.name == 'text'}.each do |attribute|\n attribute_data = Utilities::MEASURE_ATTRIBUTES_MAP[attribute.name.to_sym]\n if (attribute_data)\n attribute_data['value'] = attribute.at_xpath('@extension').try(:value) || attribute.text\n @attributes << HQMF::Attribute.from_json(attribute_data)\n end\n end\n\n @criteria_map = {}\n @measure_period_map = {\n details.at_xpath('period/@uuid').value => :measure_period,\n details.at_xpath('period/startDate/@uuid').value => :measure_period_start,\n details.at_xpath('period/stopDate/@uuid').value => :measure_period_end\n }\n @measure_period_map.keys.each do |key|\n @criteria_map[key] = OpenStruct.new(id: HQMF::Document::MEASURE_PERIOD_ID, hqmf_id: key)\n end\n \n # Extract the data criteria\n @source_data_criteria = []\n @derived_data_criteria = []\n @attribute_map = {}\n @doc.xpath('measure/elementLookUp/qdm').each do |entry|\n data_type = entry.at_xpath('@datatype').value\n if !['Timing Element', 'attribute'].include? data_type\n criteria = DataCriteria.new(entry)\n @source_data_criteria << criteria\n @criteria_map[criteria.hqmf_id] = criteria\n elsif data_type == 'attribute'\n attribute = Attribute.new(entry.at_xpath('@id').value, entry.at_xpath('@oid').value, entry.at_xpath('@name').value)\n @attribute_map[attribute.id] = attribute\n elsif data_type == 'Timing Element'\n name = entry.at_xpath('@name').value\n if MEASURE_PERIOD_TITLES[name]\n hqmf_id = entry.at_xpath('@uuid').value\n @criteria_map[hqmf_id] = OpenStruct.new(id: HQMF::Document::MEASURE_PERIOD_ID, hqmf_id: hqmf_id)\n @measure_period_map[hqmf_id] = MEASURE_PERIOD_TITLES[name]\n end\n end\n end\n\n # Extract the population criteria and population collections\n @populations = []\n @population_criteria = []\n \n population_defs = @doc.xpath('measure/measureGrouping/group')\n population_defs.each_with_index do |population_def, population_index|\n\n population = {}\n population_def.xpath('clause').each do |criteria_def|\n\n criteria = PopulationCriteria.new(criteria_def, self, population_index)\n @population_criteria << criteria\n population[criteria.type] = criteria.id\n\n end\n\n @doc.xpath('measure/measureObservations').children.reject {|e| e.name == 'text'}.each_with_index do |observ_def, observ_index|\n observ = PopulationCriteria.new(observ_def, self, population_index)\n @population_criteria << observ\n population[observ.type] = observ.id\n raise \"multiple observations... don't know how to tie to populations\" if observ_index > 0\n end\n\n population['id'] = \"Population#{population_index}\"\n population['title'] = \"Population #{population_index}\" if population_defs.length > 1\n @populations << population\n\n end\n\n\n puts \"\\t NEED TO HANDLE STRATIFICATIONS\"\n # stratifier_id_def = population_def.at_xpath('cda:templateId/cda:item[@root=\"'+HQMF::Document::STRATIFIED_POPULATION_TEMPLATE_ID+'\"]/@controlInformationRoot', NAMESPACES)\n # population['stratification'] = stratifier_id_def.value if stratifier_id_def\n\n end",
"def build\r\n self.ehtml, self.ecss, self.ejs = self.theme.page_layout.build_content() \r\n return self.ehtml, self.ecss, self.ejs\r\n end",
"def content_descriptions\n return nil if description.blank?\n description['contents']\n end",
"def create\n @culture = Culture.new(params[:culture])\n @elt=flash[:elt]\n @element = Element.new(@elt)\n @[email protected]_name\n \n \n\n \n \n #cf uniqueness of element_name ds model\n if ! (@element.valid?)\n if (@element.projects.blank?)\n redirect_to :controller => 'elements', :action => 'new', :notice => ' element has not been saved! make sure all required fields (*) has been filled '\n return\n else\n redirect_to :controller => 'elements', :action => 'new', :notice => ' element has not been saved! name already used '\n return\n \n \n end\n end\n \n \n @element.save\n \n \n #@culture.culture_name=flash[:elt][:element_name]\n #permet d'associer elt a culture pour projet::detail elt\n @culture.element_id= Element.last.id\n \n \n respond_to do |format|\n if @culture.save \n \n #format.html { redirect_to :controller => 'elements', :action => 'index', notice: 'element culture was successfully created.' }\n \n format.html { redirect_to @culture, notice: 'culture was successfully created.' }\n format.json { render json: @culture, status: :created, location: @culture }\n \n else\n \n format.html { render action: \"new\" }\n format.json { render json: @culture.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_defaults\n import_layout(self.layout_dir(:absolute => true))\n import_content(self.content_dir(:absolute => true))\n end",
"def run(content, params={})\n ::WikiCreole.creole_parse(content, params.merge(:keep_line_break => true))\n end",
"def load_1\n puts \"created Revs\"\n p = Site.new\n p.name = \"Revs\"\n p.author = \"Jebbit\"\n p.created_at = Date.new 2014, 05, 27 \n p.img_url = \"http://image_somewhere.com/img.jpg\"\n p.landing_url = \"http://jebbit.com\"\n p.save!\nend",
"def create(contents, params = {:language => \"Plain Text\", :private => false})\n params = params.merge({:contents => contents}.merge(@base_params))\n self.class.post(\"/paste\", :body => params).parsed_response\n end"
] | [
"0.71293515",
"0.68951184",
"0.6851754",
"0.6749171",
"0.65592486",
"0.6249196",
"0.60438925",
"0.5960458",
"0.5770947",
"0.5758531",
"0.5735976",
"0.572055",
"0.5705038",
"0.564417",
"0.55416477",
"0.55314547",
"0.55260473",
"0.55172884",
"0.55120534",
"0.5512029",
"0.5511772",
"0.55043644",
"0.55043644",
"0.55021477",
"0.54725444",
"0.5451003",
"0.5447842",
"0.5425459",
"0.5423372",
"0.53966",
"0.5369785",
"0.5364568",
"0.5352198",
"0.53419816",
"0.53389084",
"0.5327126",
"0.530898",
"0.52945054",
"0.5288386",
"0.528335",
"0.5271217",
"0.5270228",
"0.52684206",
"0.52528393",
"0.52459997",
"0.5227764",
"0.52263236",
"0.5215873",
"0.5211016",
"0.52053875",
"0.5175786",
"0.5174641",
"0.5173393",
"0.5170864",
"0.5162105",
"0.5159856",
"0.51503754",
"0.5146924",
"0.5105792",
"0.5098459",
"0.50808465",
"0.50801426",
"0.50767034",
"0.50734323",
"0.5071892",
"0.50665396",
"0.5063607",
"0.50593454",
"0.50577295",
"0.50547016",
"0.50403214",
"0.5032201",
"0.50276214",
"0.50261396",
"0.50246507",
"0.5023221",
"0.5020363",
"0.5019227",
"0.50191194",
"0.5017054",
"0.5010415",
"0.50094897",
"0.5008796",
"0.4997501",
"0.49896035",
"0.4987903",
"0.49871778",
"0.49830645",
"0.49818933",
"0.4980548",
"0.49711835",
"0.4968457",
"0.4966429",
"0.49641976",
"0.49615407",
"0.4960709",
"0.49587333",
"0.4954629",
"0.4949423"
] | 0.58555186 | 9 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.