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 /jobs/1 DELETE /jobs/1.xml
def destroy @job = Job.find(params[:id]) parent = @job.parent @job.destroy respond_to do |format| format.js {render :js => 'done'} format.html { redirect_to(parent.present? ? supplier_job_path(params[:supplier_id], parent.id) : supplier_jobs_path(params[:supplier_id])) } format.xml { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n node = @job.nodes.find(params[:id])\n @job.nodes.delete(node)\n\n respond_to do |format|\n format.html { redirect_to job_url(@job) }\n format.xml { head :ok }\n end\n end", "def delete(id)\n connection.delete do |req|\n req.url \"job/#{id}\"\n end\n end", "def destroy\n @job = @user.jobs.find(params[:id])\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to(jobs_url) }\n format.xml { head :ok }\n end\n end", "def destroy \n @job = Mugen::Job.delete(params[:id])\n \n respond_to do |format|\n format.html { redirect_to(mygengo_jobs_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to(jobs_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @job = Job.find(params[:id])\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to(jobs_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @job = Job.find(params[:id])\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to(jobs_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @job = Job.find(params[:id])\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to(jobs_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @job = Job.find(params[:id])\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to(jobs_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @job = Job.find(params[:id])\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to(jobs_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @job = Job.find(params[:id])\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to(jobs_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @job = Job.find(params[:id])\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to(jobs_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @job = Job.find(params[:id])\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to(jobs_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n if UbiquoJobs.manager.delete(params[:id])\n flash[:notice] = t(\"ubiquo.jobs.job_removed\")\n else\n flash[:error] = t(\"ubiquo.jobs.cant_remove\")\n end\n\n respond_to do |format|\n format.html { redirect_to(ubiquo.jobs_path) }\n format.xml { head :ok }\n end\n end", "def delete\n job_resource.delete\n end", "def destroy\n @job = Job.find(params[:id])\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to jobs_url }\n format.xml { head :ok }\n end\n end", "def delete_job(sid)\n\t\t\tresponse = connection.delete(\"search/jobs/#{sid}\")\n\t\t\treturn_error_or_body(response, response.body)\n\t\tend", "def destroy\n @job = Job.find(params[:id])\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to(jobs_url) }\n format.xml { head :ok }\n format.json { head :ok }\n end\n end", "def remove_jobs(job_ids)\n\n job_ids.each do |id|\n api_url = \"#{BASE_URL}/v4/projects/#{PROJECT_ID}/jobs/#{id}/erase\"\n\n begin\n response = RestClient::Request.new(\n :method => :post,\n :url => api_url,\n :verify_ssl => false,\n :headers => {\"PRIVATE-TOKEN\" => API_TOKEN}\n ).execute\n\n if response != nil && response.code == 204\n puts \"delete job #{id} => success\"\n else\n puts \"delete job #{id} => failed\"\n end\n\n rescue RestClient::ExceptionWithResponse => err\n puts \"delete job artifacts #{id} => error\"\n end\n\n end\n\nend", "def destroy\n @job_status = JobStatus.find(params[:id])\n @job_status.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_job_statuses_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n Job.destroy(params[:id])\n end", "def destroy\n @job_runner.destroy\n\n respond_to do |format|\n format.html { redirect_to(job_runners_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @job.destroy\n redirect_to root_url\n end", "def destroy\n @job = current_member.jobs.find(params[:id])\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to jobs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @job = Job.destroy(params[:id])\n redirect_to jobs_path\n end", "def destroy\n @job = Job.find(params[:id])\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to jobs_url }\n format.json { head :ok }\n end\n end", "def delete_job name\n\t\t\tputs \"==> Deleting job: '#{name}'\"\n\t\t\tRestClient.post(\"#{@jenkins_host}:#{@jenkins_port}/job/#{name}/doDelete\", {}){ |response, request, result, &block|\n\t\t\t\tif [301, 302, 307].include? response.code\n \t\t\t\t\tresponse.follow_redirection(request, result, &block)\n \t\t\t\telse\n \t\t\t\tresponse.return!(request, result, &block)\n \t\t\t\tend\n \t\t\t}\n \t\t\treturn true\n\t\tend", "def delete\n (status,error) = execio \"sudo -u #{self.job_owner} qdel #{self.jobid}\", nil\n if status.class == String and status.match(/^.*job.*#{self.jobid}.*/)\n self.state = \"d\"\n return 0\n else\n raise RuntimeError, \"Deletion of job #{self.jobid} failed!\"\n return nil\n end\n end", "def destroy\n @job = Job.find(params[:id])\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to jobs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @job = Job.find(params[:id])\n @job.destroy\n redirect_to jobs_path\n end", "def destroy\n @job = Job.find_by_job_number(params[:id])\n if admin?\n @job.destroy\n end\n respond_to do |format|\n format.html { redirect_to :back }\n format.xml { head :ok }\n end\n end", "def destroy\n #@job = Job.find(params[:id])\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to jobs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @job.destroy\n respond_to do |format|\n format.html { redirect_to jobs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @job.destroy\n respond_to do |format|\n format.html { redirect_to jobs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @job.destroy\n respond_to do |format|\n format.html { redirect_to jobs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @job.destroy\n respond_to do |format|\n format.html { redirect_to jobs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @job.destroy\n respond_to do |format|\n format.html { redirect_to jobs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @job_scope_addition = JobScopeAddition.find(params[:id])\n jid = @job_scope_addition.jobs_id\n jsa_id = params[:id]\n recs = AdditionTaskRecord.find_all_by_jobs_id(jsa_id)\n delete_records(recs)\n @job_scope_addition.destroy\n\n respond_to do |format|\n format.html { redirect_to(\"#{job_scope_additions_url}?jid=#{jid}\") }\n format.xml { head :ok }\n end\n end", "def destroy\n @job.destroy # all support documents automatically get destroyed\n flash[:success] = \"Job has been successfully deleted\"\n redirect_to active_jobs_path\n end", "def destroy\n respond_with Job.find(params[:id]).delete\n end", "def destroy\n @job_title = JobTitle.find(params[:id])\n @job_title.destroy\n\n respond_to do |format|\n format.html { redirect_to(job_titles_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @job = Job.find(params[:id])\n if @job.destroy\n response_message = {:message => \"Job deleted successfully.\", :job => @job}\n else\n response_message = {:message => \"Job deletion failed. Please try again!\"}\n end\n\n respond_to do |format|\n format.xml { render :xml => response_message }\n format.json { render :json => response_message }\n end\n end", "def destroy\n @job = @user.jobs.find(params[:id])\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to :dashboard, notice: 'Job was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @job = @user.jobs.find(params[:id])\n @job.destroy\n\n respond_to do |format|\n format.html { redirect_to :dashboard, notice: \"Job was successfully deleted.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @job.destroy\n redirect_to jobs_path, notice:'Job deleted.'\n end", "def destroy\n @task = current_user.tasks.find(params[:id])\n job = @task.job\n @task.destroy\n\n flash[:notice] = 'Task was deleted'\n\n respond_to do |format|\n format.html { redirect_to job_url(job) }\n format.xml { head :ok }\n end\n end", "def destroy\n @items_print_job = ItemsPrintJob.find(params[:id])\n @items_print_job.destroy\n\n respond_to do |format|\n format.html { redirect_to(items_print_jobs_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @dailyreport_job = DailyreportJob.find(params[:id])\n @dailyreport_job.destroy\n\n respond_to do |format|\n format.html { redirect_to(dailyreport_jobs_url) }\n format.xml { head :ok }\n end\n end", "def remove_artifacts(job_ids)\n\n job_ids.each do |id|\n api_url = \"#{BASE_URL}/v4/projects/#{PROJECT_ID}/jobs/#{id}/artifacts\"\n\n begin\n response = RestClient::Request.new(\n :method => :delete,\n :url => api_url,\n :verify_ssl => false,\n :headers => {\"PRIVATE-TOKEN\" => API_TOKEN}\n ).execute\n\n if response != nil && response.code == 204\n puts \"delete job artifacts #{id} => success\"\n else\n puts \"delete job artifacts #{id} => failed\"\n end\n\n rescue RestClient::ExceptionWithResponse => err\n puts \"delete job artifacts #{id} => error\"\n end\n end\n\nend", "def destroy\n @print_job_status = PrintJobStatus.find(params[:id])\n @print_job_status.destroy\n\n respond_to do |format|\n format.html { redirect_to(print_job_statuses_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @filter_job = FilterJob.find(params[:id])\n @filter_job.destroy\n\n respond_to do |format|\n format.html { redirect_to(filter_jobs_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @launched_job.destroy\n respond_to do |format|\n format.html { redirect_to launched_jobs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @saved_job = SavedJob.find(params[:id])\n @saved_job.destroy\n\n respond_to do |format|\n format.html { redirect_to saved_jobs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @job.destroy\n respond_to do |format|\n format.html { redirect_to jobs_url, notice: 'Job was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def purge\n \n @job = DialJob.find(params[:id])\n\[email protected]_results.each do |r|\n\t\tr.destroy\n\tend\n\[email protected]\n\t\n\tdir = nil\n\tjid = @job.id\n\tdfd = Dir.new(WarVOX::Config.data_path)\n\tdfd.entries.each do |ent|\n\t\tj,m = ent.split('-', 2)\n\t\tif (m and j == jid)\n\t\t\tdir = File.join(WarVOX::Config.data_path, ent)\n\t\tend\n\tend\n\t\n\tFileUtils.rm_rf(dir) if dir\n\n respond_to do |format|\n format.html { redirect_to :action => 'index' }\n format.xml { head :ok }\n end\n end", "def destroy\n ensure_authenticated!\n job = OAR::Job.find(params[:id])\n authorize!(job.user)\n\n url = uri_to(\n site_path(\n params[:site_id]\n )+\"/internal/oarapi/jobs/#{params[:id]}.json\",\n :out\n )\n http = EM::HttpRequest.new(url).delete(\n :timeout => 5,\n :head => {\n 'X-Remote-Ident' => @credentials[:cn],\n 'Accept' => media_type(:json)\n }\n )\n\n continue_if!(http, :is => [200,202,204,404])\n\n if http.response_header.status == 404\n raise NotFound, \"Cannot find job##{params[:id]} on the OAR server\"\n else\n response.headers['X-Oar-Info'] = (\n JSON.parse(http.response)['oardel_output'] || \"\"\n ).split(\"\\n\").join(\" \") rescue \"-\"\n\n location_uri = uri_to(\n resource_path(params[:id]),\n :in, :absolute\n )\n\n render :text => \"\",\n :head => :ok,\n :location => location_uri,\n :status => 202\n end\n end", "def destroy\n @job_item = @job.job_items.find(params[:id])\n @job_item.destroy\n\n respond_to do |format|\n format.html { redirect_to [@job] }\n format.json { head :ok }\n end\n end", "def destroy\n @job.destroy\n respond_to do |format|\n format.html { redirect_to mentor_jobs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @job.destroy\n respond_to do |format|\n format.html { redirect_to app_jobs_path, notice: 'Job was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n respond_to do |format|\n if result = @job.destroy_job === true \n flash[:notice] = 'Job was deleted.'\n format.html { redirect_to(jobs_url) }\n format.xml { head :ok }\n else\n flash[:notice] = result\n format.html { redirect_to(jobs_url) }\n format.xml { render :xml => result, :status => :unprocessable_entity }\n end\n end\n end", "def destroy\n @job_student = JobStudent.find(params[:id])\n @job_student.destroy\n\n respond_to do |format|\n format.html { redirect_to(job_students_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @sfjob = Sfjob.find(params[:id])\n @sfjob.destroy\n\n respond_to do |format|\n format.html { redirect_to sfjobs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @job = Job.find(params[:id])\n @job.hidden = true\n\t\[email protected]\n\n\t\tif @job.save\n\t\t flash[:notice] = 'Job successfully removed.'\n\t\tend\n\n respond_to do |format|\n format.html { redirect_to(jobs_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @myjob.destroy\n respond_to do |format|\n format.html { redirect_to myjobs_url, notice: 'Myjob was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @act_job.destroy\n respond_to do |format|\n format.html { redirect_to act_jobs_url, notice: 'Act job was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @training_active_job = Training::ActiveJob.find(params[:id])\n @training_active_job.destroy\n\n respond_to do |format|\n format.html { redirect_to training_active_jobs_url }\n format.json { head :ok }\n end\n end", "def destroy\n @job.destroy\n respond_to do |format|\n format.html { redirect_to jobs_url, notice: 'Job was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @job.destroy\n respond_to do |format|\n format.html { redirect_to jobs_url, notice: 'Job was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @job.destroy\n respond_to do |format|\n format.html { redirect_to jobs_url, notice: 'Job was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @job.destroy\n respond_to do |format|\n format.html { redirect_to jobs_url, notice: 'Job was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @job.destroy\n respond_to do |format|\n format.html { redirect_to jobs_url, notice: 'Job was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @job.destroy\n respond_to do |format|\n format.html { redirect_to jobs_url, notice: 'Job was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @job.destroy\n respond_to do |format|\n format.html { redirect_to jobs_url, notice: 'Job was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @job.destroy\n respond_to do |format|\n format.html { redirect_to jobs_url, notice: 'Job was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @job.destroy\n respond_to do |format|\n format.html { redirect_to jobs_url, notice: 'Job was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @job.destroy\n respond_to do |format|\n format.html { redirect_to jobs_url, notice: 'Job was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @job.destroy\n respond_to do |format|\n format.html { redirect_to jobs_url, notice: 'Job was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @job.destroy\n respond_to do |format|\n format.html { redirect_to jobs_url, notice: 'Job was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @job.destroy\n respond_to do |format|\n format.html { redirect_to jobs_url, notice: 'Job was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @saved_job.destroy\n respond_to do |format|\n format.html { redirect_to saved_jobs_url, notice: t('saved_jobs_controller.saved_jobs_delete_success') }\n format.json { head :no_content }\n end\n end", "def delete\n ensure_service!\n service.delete_job job_id, location: location\n true\n end", "def destroy\n @job_folio = JobFolio.find(params[:id])\n @job_folio.destroy\n\n respond_to do |format|\n format.html { redirect_to job_folios_url }\n format.json { head :ok }\n end\n end", "def destroy\n authorize!(@job)\n @job.destroy\n respond_to do |format|\n format.html { redirect_to jobs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @import_job.destroy\n respond_to do |format|\n format.html { redirect_to import_jobs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @job = current_user.posted_jobs.find(params[:id])\n @job.try(:destroy)\n render json: {}\n end", "def destroy\n @job = Job.find(params[:id])\n if current_user.is_an_admin? or @job.status != \"paid\"\n @job.destroy\n else\n flash[:error] = \"Paid jobs can only be modified by an administrator.\"\n end\n respond_to do |format|\n format.html { redirect_to(jobs_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @quartz = Quartz.find(params[:id])\n @quartz.destroy\n\n respond_to do |format|\n format.html { redirect_to(quartzs_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @job.destroy\n respond_to do |format|\n format.html { redirect_to jobs_url, success: 'Job was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @job.destroy\n flash[:success] = 'Job was successfully destroyed.' \n redirect_to jobs_url \n end", "def destroy\n @db_job.destroy\n respond_to do |format|\n format.html { redirect_to db_jobs_url, notice: 'Db job was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @job.destroy\n respond_to do |format|\n format.html { redirect_to jobs_url, notice: \"Job was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @job.destroy\n respond_to do |format|\n format.html { redirect_to @job, notice: 'Job was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def jobs_del\r\n job_profile_id = params[:job_profile_id]\r\n job_profile = JobProfile.find(job_profile_id, :select => \"id, account_id\")\r\n \r\n return jump_to(\"/errors/forbidden\") unless job_profile.account_id == session[:account_id]\r\n \r\n JobProfile.delete(job_profile_id)\r\n @job_profile_entry_id = \"job_profile_#{job_profile_id}\"\r\n end", "def destroy\n @job_application = JobApplication.find(params[:id])\n @job_application.destroy\n\n respond_to do |format|\n format.html { redirect_to(job_applications_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @job_application = JobApplication.find(params[:id])\n @job_application.destroy\n\n respond_to do |format|\n format.html { redirect_to(job_applications_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @job_progress.destroy\n respond_to do |format|\n format.html { redirect_to job_progresses_url, notice: 'Job progress was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @job_compact = JobCompact.find(params[:id])\n @job_compact.destroy\n\n respond_to do |format|\n format.html { redirect_to job_compacts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n job = Job.find(params[:id])\n job.destroy\n respond_with job do |format|\n format.html { redirect_to jobs_path }\n end\n end", "def destroy\n @job_assignment = @group.jobs.find(params[:id])\n @job_assignment.destroy\n\n respond_to do |format|\n format.html { redirect_to group_jobs_path(@group) }\n format.json { head :no_content }\n end\n end", "def destroy\n @job.destroy\n respond_to do |format|\n flash[:success] = \"Job successfully destroyed\"\n format.html { redirect_to root_path }\n format.json { head :no_content }\n end\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" ]
[ "0.7452005", "0.7419979", "0.7241207", "0.7198782", "0.7195508", "0.71373975", "0.71373975", "0.71373975", "0.71373975", "0.71373975", "0.71373975", "0.71373975", "0.71373975", "0.7121943", "0.707634", "0.70635164", "0.69475687", "0.69224626", "0.68076", "0.678244", "0.67754734", "0.6678432", "0.6678112", "0.6671498", "0.6671154", "0.6626906", "0.66191787", "0.6617399", "0.65881974", "0.6580739", "0.65704364", "0.6564409", "0.654713", "0.654713", "0.654713", "0.654713", "0.65466833", "0.6530977", "0.65238166", "0.65090317", "0.65073746", "0.649992", "0.6492774", "0.649188", "0.64862597", "0.64802533", "0.64779234", "0.6470744", "0.642212", "0.6410651", "0.64092785", "0.6408597", "0.6406917", "0.64039224", "0.64000297", "0.6393687", "0.63896716", "0.63893205", "0.6374795", "0.6362483", "0.63414353", "0.6337165", "0.6297526", "0.6294396", "0.6273179", "0.6265403", "0.62637395", "0.62637395", "0.62637395", "0.62637395", "0.62637395", "0.62637395", "0.62637395", "0.62637395", "0.62637395", "0.62637395", "0.62637395", "0.62637395", "0.62637395", "0.625869", "0.62420905", "0.62389356", "0.6235842", "0.62341815", "0.62271076", "0.6224081", "0.6222991", "0.62177604", "0.62009096", "0.6196906", "0.6196551", "0.61903375", "0.6185306", "0.6183074", "0.6183074", "0.6166792", "0.616592", "0.6157008", "0.6155638", "0.6154284", "0.6147719" ]
0.0
-1
now we've got sugarcube568_imageNamed and imageNamed_old to load the respective versions
def imageNamed(name) sugarcube568_imageNamed(name) || imageNamed_old(name) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def imageNamed(name)\n imageNamed568(name) || imageNamed_old(name)\n end", "def load_previous_version_images\n images = {}\n version = load_previous_version\n return images if ! version\n version.units.all.each do |unit|\n unit.images.all.each do |image|\n images[image.name.to_s] = image\n end\n end\n images\n end", "def software_image_list\n super\n end", "def software_image\n super\n end", "def remote_versions\n Setting.upyun.images.versions\n end", "def first_available_image\n image = %w[o s m l].each do |size|\n field = \"size_#{size}\"\n value = send(field)\n return \"#{id}-#{size}.#{img_type}\" if value.present?\n end\nend", "def image\n [:MANAGED_MAP, :UNMANAGED_MAP].each do |map|\n unless self.class.const_defined?(map)\n raise MapUndefined, \"Const #{map} is undefined; maps appear unbuilt\"\n end\n end\n\n map = @managed ? self.class::MANAGED_MAP : self.class::UNMANAGED_MAP\n distro = @distro.downcase.to_sym\n\n unless map[distro].nil?\n return map[distro][@version] unless map[distro][@version].nil?\n return map[distro][\"*\"] unless map[distro][\"*\"].nil?\n end\n\n nil\n end", "def image_formats\n format_from_name = self.class.name.downcase[/gif|jpeg|png|svg/]\n unless format_from_name\n fail \"#{self.class}: can't guess applicable format from worker name\"\n end\n\n [format_from_name.to_sym]\n end", "def reference_image(filename)\n\tpath = \"features/reference/#{iOSVersion}/#{device_str}/#{filename}\"\n\timg = Magick::Image::read(path).first\nend", "def resolve_image\n\t\t\tif self.image_file\n\t\t\t\tunless self.image_file.is_a? String\n\t\t\t\t\tset_image(image_file)\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tself.image_file = 'updates/default.png'\n\t\t\tend\n\t\tend", "def image_name_with_specified_version(version)\n @registry.nil? ? \"#{@name}:#{version}\" : \"#{@registry}/#{@name}:#{version}\"\n end", "def image_formats\n format_from_name = self.class.name.downcase[/gif|jpeg|png/]\n raise \"#{self.class}: can't guess applicable format from worker name\" unless format_from_name\n [format_from_name.to_sym]\n end", "def image_bundle\n @image_bundle ||=\n Hoosegow::ImageBundle.new.tap do |image|\n image.add(File.expand_path('../../*', __FILE__), :ignore_hidden => true)\n image.add(File.join(@inmate_dir, \"*\"), :prefix => 'inmate')\n image.ruby_version = @ruby_version\n end\n end", "def process_versions(options = {})\n pull_from_s3 if not File.exists? local_path \n versions.each do |k, v|\n version = version_by_label k\n next if (not options[:force]) && (not version.nil?)\n\n if v[2] == 'fixed'\n self.class.crop(local_path, local_path(k), v[0], v[1])\n else\n self.class.resize_to_fit(local_path, local_path(k), v[0], v[1])\n end\n\n unless version.nil?\n version.update_attributes(:label=>k, :state=>\"processed\")\n else\n imageversionable.image_versions << ImageVersion.new(:label=>k, :state=>\"processed\")\n end\n end\n \n end", "def image_name\n @image_name || image_bundle.image_name\n end", "def conforms_to_image\n return true if @uti == \"com.adobe.photoshop-image\"\n return true if @uti == \"com.adobe.illustrator.ai-image\"\n return true if @uti == \"com.compuserve.gif\"\n return true if @uti == \"com.microsoft.bmp\"\n return true if @uti == \"com.microsoft.ico\"\n return true if @uti == \"com.truevision.tga-image\"\n return true if @uti == \"com.sgi.sgi-image\"\n return true if @uti == \"com.ilm.openexr-image\"\n return true if @uti == \"com.kodak.flashpix.image\"\n return true if @uti == \"public.fax\"\n return true if @uti == \"public.jpeg\"\n return true if @uti == \"public.jpeg-2000\"\n return true if @uti == \"public.tiff\"\n return true if @uti == \"public.camera-raw-image\"\n return true if @uti == \"com.apple.pict\"\n return true if @uti == \"com.apple.macpaint-image\"\n return true if @uti == \"public.png\"\n return true if @uti == \"public.xbitmap-image\"\n return true if @uti == \"com.apple.quicktime-image\"\n return true if @uti == \"com.apple.icns\"\n return false\n end", "def imagemagick7?; end", "def convert_image(catalog_vapp_template, account_name)\n name = catalog_vapp_template['name']\n #much fudging ensues\n #arch = name.scan(/(36|24).bit/).first\n #k enuf o'that now!\n arch = \"n/a\" #Leaving out entirely as we don't get one from terremark (could parse but its a fudge)\n Image.new( {\n :id => catalog_vapp_template['href'].split('/').last,\n :name => catalog_vapp_template['name'],\n :architecture => arch,\n :owner_id => account_name,\n :description => catalog_vapp_template['name']\n })\n end", "def load_image(path)\n end", "def default_image\n if instance.platform.name =~ /^(.*)-([^-]*)$/\n \"#{$1}:#{$2}\"\n else\n instance.platform.name\n end\n end", "def mobile_badge_image\n badge_type.image_url + year.to_s + \"mobile.png\"\n end", "def image_for(file_name, dest = '')\n prefix = data_path.dup\n file_name = file_name.split('/').last unless file_name.empty?\n file_name = file_name.gsub(/.svg/i, '.png')\n case dest\n when 'mobile_inspire'\n \"#{prefix}/inspire/mobile/#{file_name}\"\n when 'desktop_inspire'\n \"#{prefix}/inspire/desktop/#{file_name}\"\n when 'thumbnails'\n \"#{prefix}/thumbnails/#{file_name}\"\n when 'show_image_desk'\n \"#{prefix}/show_images/desktop/#{file_name}\"\n when 'show_image_mob'\n \"#{prefix}/show_images/mobile/#{file_name}\"\n when 'show'\n \"#{prefix}/show_images/show/#{file_name}\"\n end\n end", "def named_image(name)\n card = named(name)\n return card['image_uris']['normal']\n end", "def imagga_images_info\n self.images.non_installation.collect do |image|\n image_options = { :image_url => image.filename.to_s }\n image_options.merge! pattern: image.pattern.name if image.pattern.present?\n image_options.merge! thumb_url: image.s3_path if image.s3_path.present?\n { :url => image.filename.to_s.gsub('https','http').gsub('-dev',''), :id => image.filename.path, :filepath => image.filename.path, :metadata => self.specifications_hash.merge(image_options) }\n end.flatten\n end", "def convert_image(image)\n Image.new(\n :id => image[\"id\"],\n :name => image[\"name\"],\n :owner_id => image[\"owner\"],\n :description => image[\"description\"],\n :architecture => \"i386\",\t# TODO: parse this from supportedInstanceType IDs w/ HW profile lookup\n :state => @@IMAGE_STATE_MAP[image[\"state\"]]\n )\n end", "def glider_image_swap\n image = PropertyImage.find(params[:image_id])\n render :partial => 'glider_image_swap',\n :layout => false,\n :locals => { :image => image }\n end", "def old_image\n images_url = ENV[\"IMAGES_URL\"]\n legacy_path = \"/file/#{params[:id]}/#{params[:file_name]}.#{params[:format]}\"\n new_thumbnail = ModelUtils.thumbnail_url(legacy_path, images_url)\n if new_thumbnail != nil\n Rails.logger.warn(\"Legacy path redirected: #{legacy_path} => #{new_thumbnail}\")\n redirect_to new_thumbnail, :status => :moved_permanently\n else\n Rails.logger.warn(\"Legacy path could not be redirected: #{legacy_path}\")\n render \"not_found\", status: 404, formats: [:html]\n end\n end", "def image_name\n path = \"sets/#{set}/#{dimension}_#{polarity}_#{verbal}\"\n # Rails.application.assets.find_asset(path).nil? ? 'placeholder' : path\n path\n end", "def low\n unless self.url.nil?\n httpsimagepath = self.url.insert(4, 's')\n # httpsimagepath.slice! self.filename\n filename = self.url.split('/').last\n if filename.last(4) == \".jpg\"\n filename_noext = filename.split('.').first\n else\n filename_noext = filename\n end\n version = self.url.split('/').last(2).first\n httpsimagepath.slice! filename\n if version.match('[v]\\d*').to_s == version\n httpsimagepath.slice! version + '/'\n httpsimagepath = httpsimagepath + 'q_auto:low/' + version + '/' + filename_noext\n else\n httpsimagepath = httpsimagepath + 'q_auto:low/' + filename_noext\n end\n return httpsimagepath\n end\n end", "def update_image image\n temp_path = @image_folder.detect{|image_string| image_string.downcase == \"#{@image_path}/#{image.image_file_name}\".downcase}\n filename = File.basename(temp_path)\n image.image_number = @img_count\n\n @img_count += 1\n if temp_path.blank?\n InputBatch::Log.status_log.error \">>>>>>>>Image #{filename} not found<<<<<<<<<\"\n puts \">>>>>>>>>>>>Image #{filename} not found\"\n InputBatch::Log.error_log.error \"Error on line #{@row_index} : Image #{filename} not found\"\n else\n InputBatch::Log.status_log.info \"Image #{filename} found\"\n image.page_count = %x[identify #{temp_path}].split(filename).length-1 rescue nil\n end\n\n rename_image image if facility.index_file_parser_type == \"WellsFargo_bank\"\n return image\n end", "def main_preview_img_header_variant\n if realty.preview_img.attached?\n view_context.image_tag realty.preview_img.variant(resize: '750X484^').processed, class: 'img-responsive project_img_top box-shadow img-rounded'\n end\n end", "def default_image\n end", "def version_path(image_path, version_name = nil)\n res = File.join(File.dirname(image_path), 'thumb', \"#{File.basename(image_path).parameterize}#{File.extname(image_path)}\")\n res = res.cama_add_postfix_file_name(\"_#{version_name}\") if version_name.present?\n res\n end", "def tineye_images_info\n self.images.non_installation.collect do |image|\n image_options = { :image_url => image.filename.to_s }\n image_options.merge! pattern: image.pattern.name if image.pattern.present?\n image_options.merge! thumb_url: image.s3_path if image.s3_path.present?\n { :url => image.filename.to_s, :filepath => image.filename.path, :metadatum => self.specifications_hash.merge(image_options) }\n end.flatten\n end", "def retina_image_path(name_at_1x)\n asset_path(name_at_1x.gsub(%r{\\.\\w+$}, '@2x\\0'))\n end", "def compare_image(actual_img_access_type, actual_img_access_name, excp_img_access_type, excp_img_access_name)\n if actual_img_access_type == 'url'\n actual_img_url = actual_img_access_name\n else\n actual_img_url = get_element_attribute(actual_img_access_type, actual_img_access_name, 'src')\n end\n\n if excp_img_access_type == 'url'\n expected_img_url = excp_img_access_name\n elsif excp_img_access_type == 'image_name'\n expected_img_url = './features/expected_images/' + excp_img_access_name\n else\n expected_img_url = get_element_attribute(excp_img_access_type, excp_img_access_name, 'src')\n end\n\n # replace 'https' with 'http' from actual image url\n if actual_img_url.include? 'https'\n actual_img_url['https'] = 'http'\n end\n\n # replace 'https' with 'http' from expected image url\n if expected_img_url.include? 'https'\n expected_img_url['https'] = 'http'\n end\n\n if expected_img_url.include? '.png'\n image_type = 'png'\n else\n image_type = 'jpg'\n end\n\n # Storing actual image locally\n open('./features/actual_images/actual_image.' + image_type, 'wb') do |file|\n file << open(actual_img_url).read\n end\n \n actual_img_url = './features/actual_images/actual_image.' + image_type\n\n # Storing Expected image locally\n if excp_img_access_type != 'image_name'\n open('./features/expected_images/expected_image.' + image_type, 'wb') do |file|\n file << open(expected_img_url).read\n end\n expected_img_url = './features/expected_images/expected_image.' + image_type\n end\n\n # Verify image extension and call respective compare function\n if image_type == 'png'\n return compare_png_images(expected_img_url, actual_img_url)\n end\n\n compare_jpeg_images(expected_img_url, actual_img_url)\nend", "def currentEdition\n img :src => $imgHostURL + \"/\" + $currentImg\n end", "def images; end", "def image_name(server)\r\n name = instance.platform.name\r\n return name unless server\r\n\r\n # 1:\r\n if server.downcase.start_with? \"https://cloud-images.ubuntu.com\"\r\n info \"Using cloud-image '#{name}'\"\r\n return name.downcase.sub(/^ubuntu-/, \"\")\r\n end\r\n # 2:\r\n if server.downcase.start_with? \"https://images.linuxcontainers.org\"\r\n name = name.downcase.split(\"-\")\r\n # 'core' parses out in this method as the 'version' so just use 'ubuntu-core' in the kitchen.yml\r\n if UBUNTU_RELEASES.key?(name[1]) && name[0] == \"ubuntu\"\r\n name[1] = UBUNTU_RELEASES[name[1]]\r\n name[0] = \"ubuntu-core\" if name[1] == \"16\" # Logic patch for the edge case. We'll do something different if this gets complicated\r\n end\r\n name = name.join(\"/\")\r\n info \"Using standard image #{name}\"\r\n end\r\n name\r\n end", "def update_image_attributes\n if imageable.present?\n self.width, self.height = `identify -format \"%wx%h\" #{url.file.path}`.split(/x/)\n end\n end", "def image_for(document)\n master_file_id = document[\"section_id_ssim\"].try :first\n\n video_count = document[\"avalon_resource_type_ssim\"].count{|m| m.start_with?('moving image'.titleize) } rescue 0\n audio_count = document[\"avalon_resource_type_ssim\"].count{|m| m.start_with?('sound recording'.titleize) } rescue 0\n\n if master_file_id\n if video_count > 0\n thumbnail_master_file_path(master_file_id)\n elsif audio_count > 0\n asset_path('audio_icon.png')\n else\n nil\n end\n else\n if video_count > 0 && audio_count > 0\n asset_path('hybrid_icon.png')\n elsif video_count > audio_count\n asset_path('video_icon.png')\n elsif audio_count > video_count\n asset_path('audio_icon.png')\n else\n nil\n end\n end\n end", "def rename_image_files(old_name)\n [ :original , :medium , :thumb ].each do |size|\n old_path = ImagesModule.image_path_for_basename(old_name, size, true)\n if old_path\n extension = File.extname(old_path)\n new_path = image_path(size, true, extension)\n FileUtils.mv(old_path, new_path) if old_path != new_path\n end\n end\n end", "def version_mismatch_detected\n end", "def image_class(class_name)\r\n @@super_image_class = class_name\r\n end", "def im_identify(source_name)\n \n # configure in local_config.rb\n identify = \"#{IMAGE_MAGICK_PATH}identify\"\n\n #raise \"Failed to find 'identify' binary on your system. Check your ImageMagick installation.\" unless `#{identify} --version`[\"ImageMagick\"]\n \n # Finally figured out how to make identify fast (-ping)\n # assume identify is in PATH for compatibility\n cmd = \"#{identify} -ping -format '%m:%w:%h' #{source_name}\"\n # logger.info(\"$PATH is: \" + `echo $PATH`)\n logger.info(\"Executing '#{cmd}'\")\n \n res = `#{cmd}`.strip.gsub(\"'\",'').split(\":\") # the gsub fixes a bug on PCs where additional characters were added\n {:type => res[0], :width => res[1], :height => res[2]}\n end", "def fetch name,params=nil\n\n fetch_original = !params || !params[:width] && !params[:height]\n use_not_found = (self.use_not_found ||\n params && !params[:not_found].nil?)\n nf_image = (params && params.has_key?(:not_found) ?\n params[:not_found] : self.not_found_image)\n\n if name.nil?\n return nil unless use_not_found\n name = nf_image\n end\n\n o = absolute(name) # Original\n\n # Fetch original image:\n\n if fetch_original\n if params && params[:absolute]\n return o if File.exists?(o)\n return absolute(nf_image) if use_not_found && !nf_image.nil?\n return nil\n else\n return resolve(name) if File.exists?(o)\n return resolve(nf_image) if use_not_found && !nf_image.nil?\n return nil\n end\n end\n \n # Fetch sized image:\n\n s = absolute(name,params)\n\n if File.exists?(o) # original exists\n\n if File.exists?(s)\n create_size(o,s,params) if params[:resize]==true\n return s if params[:absolute]\n return resolve(name,params)\n\n else # sized image doesn't exist\n if params[:resize]==false\n if use_not_found\n return nil if nf_image.nil?\n n = absolute(nf_image)\n ns = absolute(nf_image,params)\n create_size(n,ns,params.merge(:not_found => true))\n # This may return nil if 'a' doesn't exist.\n # Regardless, we return the location.\n return ns if params[:absolute]\n return resolve(nf_image,params)\n else\n return nil\n end\n end\n # Generate sized image:\n create_size(o,s,params.merge(:autogenerated => true))\n return s if params[:absolute]\n return resolve(name,params)\n end\n\n\n else # original doesn't exist\n if use_not_found\n return nil if nf_image.nil?\n n = absolute(nf_image)\n ns = absolute(nf_image,params)\n create_size(n,ns,params.merge(:not_found => true))\n # This may return nil if 'a' doesn't exist.\n # Regardless, we return the location.\n return ns if params[:absolute]\n return resolve(nf_image,params)\n else\n return nil\n end\n end\n\n\n\n end", "def prepare_image_apria\n images = []\n if @sitecode == \"00Q49\" # site code for DAP\n single_page_images = convert_multipage_to_singlepage\n single_page_images.each_with_index do |image_file, index|\n new_file_name = rename_image_for_dap(image_file, index)\n File.rename(image_file, new_file_name)\n @image_folder = Dir.glob(\"#{@location}/**/#{config['IMAGE']['image_folder']}*\", File::FNM_CASEFOLD)\n image = ImagesForJob.new :image => File.open(\"#{new_file_name}\",\"rb\")\n image.image_file_name = File.basename(new_file_name)\n image.is_splitted_image = true\n image = update_image image\n images << image\n end\n else\n image = ImagesForJob.new\n parse_values(\"IMAGE\", image)\n image_path = @image_folder.detect{|image_string| image_string.downcase == \"#{@image_path}/#{image.image_file_name}\".downcase}\n image.image = File.open(image_path, \"rb\")\n image_file_name = image.image_file_name.strip.split(\"\\\\\").last unless image.image_file_name.blank?\n path = Dir.glob(\"#{@location}/**/#{image_file_name}\").first\n count = %x[identify \"#{path}\"].split(image_file_name).length-1\n new_image_name = File.basename(\"#{path}\")\n if count>1\n dir_location = File.dirname(\"#{path}\")\n ext_name = File.extname(\"#{path}\")\n new_image_base_name = new_image_name.chomp(\"#{ext_name}\")\n if ((not ext_name.empty?) and (ext_name.casecmp(\".pdf\") == 0) ) then\n system \"pdftk '#{path}' burst output '#{dir_location}/#{new_image_base_name}_%d#{ext_name}'\"\n for image_count in 1..count\n image = ImagesForJob.new(:image_file_name=>\"#{new_image_base_name}_#{image_count}#{ext_name}\",:is_splitted_image=>true)\n image = update_image image\n images << image\n end\n else\n InputBatch.split_image(count,path, dir_location, new_image_base_name)\n single_images = Dir.glob(\"#{@location}/**/*\").select{|file| InputBatch.get_single_image(file, new_image_base_name)}.sort\n single_images.each_with_index do |single_image, index|\n new_image_name = \"#{dir_location}/#{new_image_base_name}_#{index}#{ext_name}\"\n File.rename(single_image, new_image_name)\n image = ImagesForJob.create(:image => File.open(new_image_name), :image_number => @img_count, :is_splitted_image=>true)\n @img_count += 1\n images << image\n end\n end\n else\n image = ImagesForJob.new(:image_file_name=>\"#{new_image_name}\")\n image = update_image image\n images << image\n end\n end\n return images\n end", "def distribution_pods\n\npod 'UIAlertView+Blocks'\npod 'SDWebImage', '~>3.7' # Cached images\n\nend", "def check_our_images!\n self.gsub!(/!image (\\w+\\/)?(\\d+)!/) do\n size, id = $1, $2\n size ||= 'thumb/'\n '\"!%s/%s%d.jpg!\":%s/image/show_image/%d' %\n [IMAGE_DOMAIN, size, id, HTTP_DOMAIN, id]\n end\n end", "def check_our_images!\n self.gsub!(/!image (\\w+\\/)?(\\d+)!/) do\n size, id = $1, $2\n size ||= 'thumb/'\n '\"!%s/%s%d.jpg!\":%s/image/show_image/%d' %\n [IMAGE_DOMAIN, size, id, HTTP_DOMAIN, id]\n end\n end", "def image_sequence_classnames\n { CinemaslidesCommon::TRANSITION_CHOICE_CUT => 'FadeOrCutTransitionsImageSequence',\n CinemaslidesCommon::TRANSITION_CHOICE_FADE => 'FadeOrCutTransitionsImageSequence', \n CinemaslidesCommon::TRANSITION_CHOICE_CROSSFADE => 'CrossfadeTransitionsImageSequence' }\nend", "def test06()\n begin\n imagefilepath = File.join($directory, \"images\", \"DSCN0751.JPG\")\n create_imageimporter_command = CommandModule.make_createimporter(\n imagefilepath)\n object_ref = Smig.perform_command(create_imageimporter_command).to_i\n importer_object = SmigIDHash.make_objectid(objectreference: object_ref)\n getproperties_command = CommandModule.make_get_objectproperties(\n importer_object,\n imageindex: 0,\n saveresultstype: :jsonstring)\n new_json = Smig.perform_command(getproperties_command)\n old_json = '{\"{TIFF}\":{\"ResolutionUnit\":2,\"Software\":\"E4500v1.1\",\"DateTime\":\"2004:01:16 15:17:17\",\"XResolution\":300,\"ImageDescription\":\" \",\"Orientation\":1,\"YResolution\":300,\"Model\":\"E4500\",\"Make\":\"NIKON\"},\"Depth\":8,\"{IPTC}\":{\"Caption\\/Abstract\":\" \"},\"PixelHeight\":681,\"{Exif}\":{\"DateTimeOriginal\":\"2004:01:16 15:17:17\",\"MeteringMode\":5,\"ComponentsConfiguration\":[1,2,3,0],\"MaxApertureValue\":2.8,\"DigitalZoomRatio\":0,\"Saturation\":0,\"FNumber\":3.6,\"CompressedBitsPerPixel\":3,\"FocalLength\":17.7,\"SceneType\":1,\"FileSource\":3,\"SceneCaptureType\":0,\"Sharpness\":0,\"ColorSpace\":1,\"GainControl\":0,\"SubjectDistRange\":0,\"Contrast\":0,\"PixelYDimension\":681,\"WhiteBalance\":0,\"LightSource\":0,\"FlashPixVersion\":[1,0],\"DateTimeDigitized\":\"2004:01:16 15:17:17\",\"ISOSpeedRatings\":[100],\"ExposureMode\":0,\"PixelXDimension\":908,\"ExifVersion\":[2,2],\"CustomRendered\":0,\"ExposureProgram\":2,\"Flash\":24,\"ExposureTime\":0.007336757153338224,\"FocalLenIn35mmFilm\":85,\"ExposureBiasValue\":0},\"{JFIF}\":{\"DensityUnit\":1,\"YDensity\":300,\"JFIFVersion\":[1,0,1],\"XDensity\":300},\"ProfileName\":\"sRGB IEC61966-2.1\",\"DPIWidth\":300,\"DPIHeight\":300,\"ColorModel\":\"RGB\",\"Orientation\":1,\"PixelWidth\":908}'\n unless new_json.eql?(old_json)\n puts \"Old JSON: #{old_json}\"\n puts \"New JSON: #{new_json}\"\n raise \"Image file metadata or our obtaining of it has changed.\"\n end\n\n rescue RuntimeError => e\n $errorcode = Smig.exitvalue\n unless $errorcode.zero?\n puts \"Exit string: #{Smig.exitstring}\"\n end\n puts e.message\n puts e.backtrace.to_s\n puts #{Smig.exitstring}\"\n# exit 240\n ensure\n Smig.close_object(importer_object)\n end\nend", "def set_cover_image(format)\n case format\n when \"Book\"\n return \"cornell/virtual-browse/book_cvr.png\"\n when \"Journal/Periodical\"\n return \"cornell/virtual-browse/journal_cvr.png\"\n when \"Manuscript/Archive\"\n return \"cornell/virtual-browse/manuscript_cvr.png\"\n when \"Map\"\n return \"cornell/virtual-browse/map_cvr.png\"\n when \"Musical Recording\"\n return \"cornell/virtual-browse/musical_recording_cvr.png\"\n when \"Musical Score\"\n return \"cornell/virtual-browse/musical_score_cvr.png\"\n when \"Non-musical Recording\"\n return \"cornell/virtual-browse/non_musical_cvr.png\"\n when \"Thesis\"\n return \"cornell/virtual-browse/thesis_cvr.png\"\n when \"Video\"\n return \"cornell/virtual-browse/video_cvr.png\"\n when \"Microform\"\n return \"cornell/virtual-browse/microform_cvr.png\"\n else\n return \"cornell/virtual-browse/generic_cvr.png\"\n end\n\n end", "def content_version(image_sourcefiles)\n \"content-#{sha256(image_sourcefiles)}\"\n end", "def image(legacy_size = NOT_GIVEN, legacy_is_gray = NOT_GIVEN, legacy_category = NOT_GIVEN, legacy_number = NOT_GIVEN, legacy_text = NOT_GIVEN, legacy_secure = NOT_GIVEN, size: '300x300', is_gray: false, category: nil, number: nil, text: nil, secure: true)\n warn_for_deprecated_arguments do |keywords|\n keywords << :size if legacy_size != NOT_GIVEN\n keywords << :is_gray if legacy_is_gray != NOT_GIVEN\n keywords << :category if legacy_category != NOT_GIVEN\n keywords << :number if legacy_number != NOT_GIVEN\n keywords << :text if legacy_text != NOT_GIVEN\n keywords << :secure if legacy_secure != NOT_GIVEN\n end\n\n raise ArgumentError, 'Size should be specified in format 300x300' unless size =~ /^[0-9]+x[0-9]+$/\n raise ArgumentError, \"Supported categories are #{SUPPORTED_CATEGORIES.join(', ')}\" unless category.nil? || SUPPORTED_CATEGORIES.include?(category)\n raise ArgumentError, 'Category required when number is passed' if !number.nil? && category.nil?\n raise ArgumentError, 'Number must be between 1 and 10' unless number.nil? || (1..10).cover?(number)\n raise ArgumentError, 'Category and number must be passed when text is passed' if !text.nil? && number.nil? && category.nil?\n\n url_parts = secure ? ['https:/'] : ['http:/']\n url_parts << ['lorempixel.com']\n url_parts << 'g' if is_gray\n url_parts += size.split('x')\n url_parts += [category, number, text].compact\n url_parts.join('/')\n end", "def default_url\r\n ActionController::Base.helpers.asset_path(\"fallback/\" + [version_name, \"default.png\"].compact.join('_'))\r\n #ActionController::Base.helpers.asset_path(\"fallback/\" + \"default.gif\")\r\n end", "def update_slider_images\n dir_name=\"app/assets/images/slider_images\"\n @slider_images=Dir.glob(dir_name+\"/*\").map do |f|\n File.basename f\n end.sort\n begin\n if slider_images_params[:slider_image_1]\n create_slider_image_file(\"slider_image_1\", slider_images_params[:slider_image_1], 1)\n end\n if slider_images_params &&slider_images_params[:slider_image_2]\n create_slider_image_file(\"slider_image_2\", slider_images_params[:slider_image_2], 2)\n end\n if slider_images_params &&slider_images_params[:slider_image_3]\n create_slider_image_file(\"slider_image_3\", slider_images_params[:slider_image_3], 3)\n end\n if slider_images_params &&slider_images_params[:slider_image_4]\n create_slider_image_file(\"slider_image_4\", slider_images_params[:slider_image_4], 4)\n end\n if slider_images_params && slider_images_params[:slider_image_5]\n create_slider_image_file(\"slider_image_5\", slider_images_params[:slider_image_5], 5)\n end\n redirect_to slider_images_path\n rescue\n redirect_to slider_images_path\n end\n end", "def image_elements(identifier)\n platform.images_for(identifier.clone)\n end", "def default_url\n \"photo/#{version_name}.jpg\"\n end", "def update_image_for_building_tag name\n unless service_config_hash[\"build\"].nil?\n service_config_hash[\"image\"]=name\n end\n \n self.image_name = service_config_hash[\"image\"]\n end", "def interface_image(filename)\n if interface_exist?(filename_with_language = filename + ($options&.language || 'en')) ||\n interface_exist?(filename_with_language = filename + 'en')\n filename = filename_with_language\n end\n load_image(@interface_cache, filename, Interface_Path, @interface_data, Image)\n end", "def image(hash={})\n\t\tif hash['id'] =~ /nsys|Hand|Arm|Leg|Eye|back|abdomen|chest|head|neck/o\n\t\t\tStatus.sf_update(hash['id'], hash['name'])\n\t\tend\n\tend", "def map_image_id(image)\n name, _ = image.name.split(/ \\d/, 2)\n other = image.name.gsub(Regexp.new(\"^#{name} ?\"), '')\n version, extra = other.split(/ +/, 2)\n [name, { version => { :id => image.id, :extra => extra } } ]\n end", "def show_image_version\n if @options[\"mode\"] == \"himage\"\n tpl = @himage_tpl\n elsif @options[\"mode\"] == \"vimage\"\n tpl = @vimage_tpl\n else \n raise \"invalid template name\" + @options[\"mode\"]\n end\n calc_weather_icon\n calc_wind_icon\n parse_radar unless @options[\"radar_location\"].empty?\n erb = ERB.new(File.read(tpl), 0, '>')\n @conky_output = erb.result(binding)\n puts @conky_output\n end", "def parse_sw_image_ids\n public_xml_doc.xpath('//resource[@type=\"page\" or @type=\"image\" or @type=\"thumb\"]').map do |node|\n node.xpath('./file[@mimetype=\"image/jp2\"]/@id').map do |x|\n \"#{@druid.gsub('druid:', '')}/\" + x\n end << node.xpath('./externalFile[@mimetype=\"image/jp2\"]').map do |y|\n \"#{y.attributes['objectId'].text.split(':').last}\" + '/' + \"#{y.attributes['fileId']}\"\n end\n end.flatten\n end", "def images\n Vultr::Resource::OS.new(@faraday)\n end", "def image( name )\n @images[name]\n end", "def default_url\n ActionController::Base.helpers.asset_path(\"images/\" + [version_name, \"missing.png\"].compact.join('/'))\n end", "def version\n Gem.loaded_specs['image_optim'].version.to_s\n rescue\n 'DEV'\n end", "def image(name)\n @parts.push(image: \"#{Bioturk::Application.config.image_server_interface}#{name}\")\n end", "def primary_image\n if images.length > 0\n images[0].url\n else\n \"https://vollrath.com/ClientCss/images/VollrathImages/No_Image_Available.jpg\"\n end\n end", "def full_version\n \"image_optim v#{version}\"\n end", "def fetch_image(host,old_file,new_file)\n\t`rm #{old_file}` \n\t`mv #{new_file} #{old_file}`\t\n\topen('assets/images/radar/new.png', 'wb') do |file|\n\t\tfile << open('host').read\n\tend\n\tnew_file\nend", "def not_found_image\n scryfall.card_code_number('5dn', 52)['image_uris']['large']\n end", "def photo_format; end", "def image\n if File.exists?(self.image_jpg_path)\n \"/assets/game_images/%s.jpg\" %[self.name.dehumanize]\n elsif File.exists?(self.image_png_path)\n \"/assets/game_images/%s.png\" %[self.name.dehumanize]\n else\n nil\n end\n end", "def preview_iphone_image\n dir = File.last_added_dir(Photostream_path) # this might be different between different OSX versions\n curfile = File.last_added(dir)\n if curfile == nil\n fail(\"No screenshots available\")\n else\n `qlmanage -p '#{curfile}'`\n end\nend", "def get_single_image(file,new_image_base_name)\r\n File.basename(file).split('.').first =~ /#{new_image_base_name}[a-z][a-z][a-z]/\r\n end", "def official_minimal\n @images.select do |img|\n img[\"official\"] == true &&\n img[\"status\"] == \"available\" &&\n img[\"virtual_size\"] != 0\n end.sort_by do |img|\n img[\"disk_size\"]\n end.first[\"id\"]\n rescue StandardError\n nil\n end", "def default_url\n # For Rails 3.1+ asset pipeline compatibility:\n ([version_name, \"default.png\"].compact.join('_'))\n \n #\"/images/fallback/\" + [version_name, \"default.png\"].compact.join('_')\n end", "def image_magick_version\n @@version ||= Gem::Version.create(`mogrify --version`.split(' ')[2].split('-').first)\n end", "def open_lid_image\n image_path(image_name: params[:open_lid_image])\n end", "def gallery_on_upgrade(plugin)\n end", "def image\n # 1. TODO Advertisement's image if there is an active Spot play event and has image\n # 2. else Song's image if there is an active song and has image\n return event.try(:image).try(:file) if event.try(:image) != nil\n # 3. TODO else programs's image if there is an active program with image\n # 4. TODO else Station's image if present\n # 5. TODO else App logo\n end", "def default_url\n ActionController::Base.helpers.asset_path(\"default/\" + [version_name, \"standard.jpg\"].compact.join('_'))\n end", "def build_section_for_loose_images\n image_files = find_image_files(resources_files.map(&:path))\n\n log \"Found #%s image files in project.\", image_files.count\n\n data = build_images_section_data(image_files, use_basename: [:key, :path])\n\n new_section('Images', data)\n end", "def official_minimal\n @images.select do |img|\n img[\"official\"] == true &&\n img[\"virtual_size\"] != 0\n end.sort_by do |img|\n img[\"disk_size\"]\n end.first[\"id\"]\n rescue StandardError\n nil\n end", "def default_version\n return @versions[:large] if @versions.key?(:large)\n return @versions[:medium] if @versions.key?(:medium)\n return @versions[:small] if @versions.key?(:small)\n end", "def image_sizes\n { :small => 'x110',\n :medium => 'x208',\n :large => 'x413',\n :big => 'x654',\n :storage => 'x867'\n }\n end", "def prepare_image\n images_for_job = []\n images = []\n @images_from_index = row.slice(config['IMAGE']['image_file_name'][0]..-1).compact\n @images_from_index = @images_from_index.collect{|file| file.include?('.') ? \\\n file: file + \".#{@image_ext}\"}\n # identifying check and envelop images\n @check_image, @envelop_image = call_parser_specific_method \"prepare_check_and_envelop_images\" if @version == 'BANK_OF_AMERICA' and facility.index_file_parser_type != \"Apria_bank\"\n envelop_image_to_loaded = (@envelop_image.upcase)[0...-4].split(\"_\") unless @envelop_image.blank?\n @image_folder = Dir.glob(\"#{@location}/**/#{config['IMAGE']['image_folder']}*\", File::FNM_CASEFOLD)\n @images_from_index.each do |file_name|\n unless @hash_envelop_images.has_key?(\"#{file_name}\")\n images_for_job << @image_folder.select{|file| File.basename(file).upcase == file_name.upcase}\n images_for_job << @image_folder.select{|file| file_name[0...-4] + \"B\" == File.basename(file)[0...-4].upcase}\n \n else\n unless @envelop_image.blank?\n images_for_job << @image_folder.select{|file| File.basename(file).upcase == @envelop_image.upcase ||\n File.basename(file)[0...-4].upcase == @envelop_image.upcase[0...-4] +'B'}\n if envelop_image_to_loaded.size == 2\n @image_folder = Dir.glob(\"#{@location}/**/#{config['IMAGE']['image_folder']}*\", File::FNM_CASEFOLD)\n images_for_job << @image_folder.select{|file| File.basename(file)[0...-4].upcase == envelop_image_to_loaded[0]+'B_'+ envelop_image_to_loaded[1]}\n end\n end\n end\n end\n images_for_job.flatten!\n # @initial_image_name = images_for_job[0]\n multi_page_facilities = ['CHRISTIAN HOSPITAL LABORATORY','GENOPTIX MEDICAL LABORATORY']\n images_for_job = convert_single_page_to_multipage(images_for_job) if multi_page_facilities.include? facility.name.strip.upcase\n f = nil\n images_for_job.each_with_index do |image_name,img_count|\n f = File.open(\"#{image_name}\",\"rb\")\n image = ImagesForJob.new(:image => f)\n parse_values(\"IMAGE\", image, File.basename(image_name))\n image_file_name = image.image_file_name.strip.split(\"\\\\\").last unless image.image_file_name.blank?\n # initial_image = images_for_job[0]\n @initial_image_name = image_file_name if img_count == 0\n path = Dir.glob(\"#{@location}/**/#{image_file_name}\").first\n count = %x[identify \"#{path}\"].split(image_file_name).length-1\n new_image_name = File.basename(\"#{path}\")\n if count>1\n dir_location = File.dirname(\"#{path}\")\n ext_name = File.extname(\"#{path}\")\n new_image_base_name = new_image_name.chomp(\"#{ext_name}\")\n if ((not ext_name.empty?) and (ext_name.casecmp(\".pdf\") == 0) ) then\n system \"pdftk '#{path}' burst output '#{dir_location}/#{new_image_base_name}_%d#{ext_name}'\"\n for image_count in 1..count\n image = ImagesForJob.new(:image_file_name=>\"#{new_image_base_name}_#{image_count}#{ext_name}\",:is_splitted_image=>true)\n image = update_image image\n image.save\n images << image\n end\n else\n InputBatch.split_image(count,path, dir_location, new_image_base_name)\n single_images = Dir.glob(\"#{@location}/**/*\").select{|file| InputBatch.get_single_image(file, new_image_base_name)}.sort\n single_images.each_with_index do |single_image, index|\n new_image_name = \"#{dir_location}/#{new_image_base_name}_#{index}#{ext_name}\"\n File.rename(single_image, new_image_name)\n image = ImagesForJob.create(:image => File.open(new_image_name), :image_number => @img_count,:is_splitted_image=>true)\n @img_count += 1\n images << image\n end\n end\n else\n # image = ImagesForJob.new(:image_file_name=>\"#{new_image_name}\")\n image = update_image image\n image.save\n images << image\n end\n f.close\n end\n return images\n end", "def get_image(image_name)\n image_service = client.vm_image_management\n image = image_service.list_virtual_machine_images.select { |x| x.name.casecmp(image_name.to_s) == 0 }.first\n Azure::Loggerx.error_with_exit 'The virtual machine image source is not valid.' unless image\n image\n end", "def image_types\n [\"image/jpeg\", \"image/png\", \"image/jpg\", \"image/gif\", \"image/tif\"]\n end", "def image_types\n [\"image/jpeg\", \"image/png\", \"image/jpg\", \"image/gif\", \"image/tif\"]\n end", "def images_for_mushroom_app # :nologin: :norobots:\n minimum_confidence = params[:minimum_confidence].blank? ? 1.5 : params[:minimum_confidence]\n minimum_quality = params[:minimum_quality].blank? ? 2.0 : params[:minimum_quality]\n target_width = params[:target_width].blank? ? 400 : params[:target_width]\n target_height = params[:target_height].blank? ? 600 : params[:target_height]\n minimum_width = params[:minimum_width].blank? ? target_width : params[:minimum_width]\n minimum_height = params[:minimum_height].blank? ? target_height : params[:minimum_height]\n confidence_reward = params[:confidence_reward].blank? ? 2.0 : params[:confidence_reward]\n quality_reward = params[:quality_reward].blank? ? 1.0 : params[:quality_reward]\n ratio_penalty = params[:ratio_penalty].blank? ? 0.5 : params[:ratio_penalty]\n\n # Last term in ORDER BY spec below penalizes images of the wrong aspect ratio.\n # If we wanted 600x400 it will penalize 400x400 images by 'ratio_penalty'.\n ratio_penalty = ratio_penalty.to_f / Math.log10(600.0/400)\n\n names = get_list_of_names(params[:names])\n names = names.map {|n| \"'\" + n.gsub(/'/, '\\\\\\'') + \"'\"}.join(',')\n\n data = Name.connection.select_rows(%(\n SELECT y.name, y.id, y.width, y.height\n FROM (\n SELECT x.text_name AS name, i.id AS id, i.width AS width, i.height AS height\n FROM (\n SELECT DISTINCT n1.text_name AS text_name, n2.id AS name_id\n FROM names n1\n JOIN names n2 ON IF(n1.synonym_id IS NULL, n2.id = n1.id, n2.synonym_id = n1.synonym_id)\n WHERE n1.rank = 'Species' AND n1.text_name IN (#{names})\n ) AS x, observations o, images i\n WHERE o.name_id = x.name_id\n AND i.id = o.thumb_image_id\n AND o.vote_cache >= #{minimum_confidence}\n AND i.vote_cache >= #{minimum_quality}\n AND i.width >= #{minimum_width} AND i.height >= #{minimum_height}\n ORDER BY\n o.vote_cache * #{confidence_reward} +\n i.vote_cache * #{quality_reward} -\n ABS(LOG(width/height) - #{Math.log10(target_width.to_f/target_height)}) * #{ratio_penalty} DESC\n ) AS y\n GROUP BY y.name\n ))\n\n if params[:test]\n render_test_image_report(data)\n else\n render_image_csv_file(data)\n end\n rescue => e\n render(:text => e.to_s, :layout => false, :status => 500)\n end", "def proxy_image\n multiresimage = Multiresimage.find(params[:id])\n img_length = params[:image_length]\n\n begin\n if multiresimage.DELIV_OPS.svg_image.svg_width[0].to_i <= params[:image_length].to_i\n img_length = multiresimage.DELIV_OPS.svg_image.svg_width[0].to_i-1\n end\n rescue Exception\n #this is a fix so that smaller images get shown. Currently, they break since larger versions do not exist.\n end\n\n default_image = File.open(\"app/assets/images/site/missing2.png\", 'rb') do |f|\n f.read\n end\n filename = \"missing2.png\"\n resp = ''\n\n if can?(:read, multiresimage)\n\n Net::HTTP.start(DIL_CONFIG['dil_fedora_base_ip'], DIL_CONFIG['dil_fedora_port']) { |http|\n resp = http.get(\"#{DIL_CONFIG['dil_fedora_url']}#{params[:id]}#{DIL_CONFIG['dil_fedora_disseminator']}#{img_length}\")\n #open(\"/usr/local/proxy_images/#{params[:id]}.jpg\" ,\"wb\") { |new_file|\n #new_file.write(resp.body)\n #send_file(new_file, :type => \"image/jpeg\", :disposition=>\"inline\")\n #send data uses server memory instead of storage.\n if(resp.body.include? \"error\")\n image = default_image\n else\n image = resp.body\n filename = \"#{params[:id]}.jpg\"\n end\n send_data(image, :disposition=>'inline', :type=>'image/jpeg', :filename=>filename)\n }\n #}\n else\n send_data(default_image, :disposition=>'inline', :type=>'image/jpeg', :filename=>filename)\n end\n end", "def get_image(image_name)\n image_res = find_match(@compute.images, image_name)\n image_to_use = (image_res != nil) ? image_res.id : nil\n if image_to_use.nil?\n Puppet.crit \"The image is not found on cloud account!, image_name => #{image_name}\"\n raise Puppet::Error, \"The image is not found on cloud account!, image_name => #{image_name}\"\n else\n Puppet.notice \"Image '#{image_name}' found : '#{image_to_use}'\"\n end\n return image_to_use\n end", "def big_image\n return image.gsub(/square/i, \"large\") if image =~ /facebook/ && image =~ /square/\n return image.gsub(/normal/i, \"original\") if image =~ /twitter/ && image =~ /normal/\n image\n end", "def imgTypes()\n return [\"gif\", \"jpg\", \"jpeg\", \"png\"]\n end", "def latest_ubuntu\n @images.select do |img|\n img[\"official\"] == true &&\n img[\"status\"] == \"available\" &&\n img[\"arch\"] == \"x86_64\" &&\n img[\"name\"] =~ /ubuntu/i\n end.sort do |a, b|\n # Reverse sort so \"22.10\" > \"22.04\"\n NameSorter.new(b[\"name\"]).version <=> NameSorter.new(a[\"name\"]).version\n end.first[\"id\"]\n rescue StandardError\n nil\n end", "def image_file_name= value\n super if value.present?\n end" ]
[ "0.68936616", "0.6532221", "0.6073566", "0.59153056", "0.5793694", "0.5790865", "0.57836723", "0.57596403", "0.5753062", "0.5632101", "0.56092405", "0.558377", "0.5563116", "0.55493844", "0.55419856", "0.55281574", "0.54937285", "0.5467317", "0.5459248", "0.54346603", "0.5424816", "0.54238015", "0.53780824", "0.53724694", "0.53470093", "0.53437", "0.5342967", "0.5329224", "0.5324328", "0.53166693", "0.53117764", "0.53038305", "0.52874863", "0.5280017", "0.5268417", "0.5222907", "0.51971227", "0.5193842", "0.5191494", "0.51858497", "0.5184236", "0.51833314", "0.5181611", "0.51769084", "0.5171067", "0.5167692", "0.5164625", "0.5164417", "0.51545745", "0.51545745", "0.51498204", "0.51455116", "0.5129877", "0.51211894", "0.5118241", "0.51096666", "0.5106124", "0.5105979", "0.51009184", "0.51003486", "0.5097279", "0.5096669", "0.5096132", "0.50898075", "0.50869626", "0.5086124", "0.50859404", "0.50816137", "0.50717133", "0.50689757", "0.5068154", "0.50551844", "0.50536793", "0.5048348", "0.50473523", "0.50331825", "0.50326926", "0.50310934", "0.50254875", "0.502272", "0.5021981", "0.50182843", "0.5013586", "0.50021356", "0.49982515", "0.49933115", "0.49878314", "0.49844322", "0.49830356", "0.49661553", "0.49607998", "0.4956398", "0.4956398", "0.49523592", "0.49464455", "0.49349567", "0.49325928", "0.4930253", "0.49301893", "0.49256298" ]
0.7264912
0
Insert all documents that have been previously saved into the document's `/inserts` folder in the asset store.
def insert_documents(insert_page_at, document_count, eventual_access=nil) eventual_access ||= self.access || PRIVATE self.update_attributes :access => PENDING self.processing_jobs.new( :action => 'document_insert_pages', :account_id => account_id, :title=>title, :options => { :id => id, :insert_page_at => insert_page_at, :pdfs_count => document_count, :access => eventual_access } ).queue end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pre_process_batch_insert(docs)\n docs.map do |doc|\n next unless doc\n append(doc)\n if persistable? && !_assigning?\n self.path = doc.atomic_path unless path\n if doc.valid?(:create)\n doc.run_before_callbacks(:save, :create)\n else\n self.inserts_valid = false\n end\n end\n doc.send(:as_attributes)\n end\n end", "def batch_insert(docs)\n execute_batch_push(docs)\n end", "def persist\n prepare do\n raise Errors::NoParent.new(document.class.name) unless parent\n if parent.new_record?\n parent.insert\n else\n collection.find(parent.atomic_selector).update(inserts)\n end\n end\n end", "def post_process_batch_insert(docs)\n docs.each do |doc|\n doc.new_record = false\n doc.run_after_callbacks(:create, :save)\n doc.post_persist\n end\n end", "def insert(documents, flags=nil)\n documents = [documents] unless documents.is_a?(Array)\n documents.each do |doc|\n promiscuous_create_operation(:document => doc).execute { super(doc, flags) }\n end\n end", "def persist_delayed(docs, inserts)\n return if docs.empty?\n\n collection.insert_many(inserts, session: _session)\n docs.each do |doc|\n doc.new_record = false\n doc.run_after_callbacks(:create, :save) unless _association.autosave?\n doc.post_persist\n end\n end", "def concat(documents)\n docs, inserts = [], []\n documents.each do |doc|\n next unless doc\n\n append(doc)\n save_or_delay(doc, docs, inserts) if persistable?\n end\n\n persist_delayed(docs, inserts)\n self\n end", "def execute_batch_set(docs)\n self.inserts_valid = true\n inserts = pre_process_batch_insert(docs)\n if insertable?\n collection.find(selector).update_one(\n positionally(selector, '$set' => { path => inserts }),\n session: _session\n )\n post_process_batch_insert(docs)\n end\n inserts\n end", "def push_documents(documents)\n documents.each {|d| push(d)}\n end", "def insert_many(documents, options = nil)\n native.insert_many(documents, options || {}).inserted_ids\n end", "def insert\n @companies = Company.all\n @placement_news = PlacementNews.all\n end", "def sync\n before_ids = Article.all.pluck(:id)\n after_ids = []\n\n file_paths.each do |file_path|\n article_data = extract_meta_data(file_path)\n article = Article.where(article_data).first_or_create\n\n article.body = extract_body(file_path)\n article.file_name = File.basename(file_path)\n\n front_matter = extract_front_matter(file_path)\n if front_matter.present?\n article.title = front_matter[:title]\n article.snippet = front_matter[:snippet]\n end\n\n article.save!\n\n after_ids << article.id\n end\n\n will_delete_ids = before_ids - after_ids\n Article.where(id: will_delete_ids).destroy_all\n end", "def insertDocs(coll)\n\n # start by dropping any existing data\n # result = @DB[coll].drop\n\n # Insert this many documents\n for i in 1..ARGV[0].to_i\n\n ing1 = Faker::Food.ingredient\n ing2 = Faker::Food.ingredient\n ing3 = Faker::Food.ingredient\n bread = @bread[rand(@bread.size)]\n range = @range[rand(@range.size)]\n # define the Ruby Hash object for the document\n doc =\n {\n :description => \"#{range} #{ing1}, #{ing2} and #{ing3} on #{bread}\",\n :fillings => [\n {\n :ingredient => ing1,\n :calories => rand(100),\n },\n {\n :ingredient => ing2,\n :calories => rand(100),\n },\n {\n :ingredient => ing3,\n :calories => rand(100),\n },\n ],\n :on => bread,\n :price => @price[rand(@price.size)],\n :rating => rand(10),\n :lastUpdate => Time.now\n }\n # Send to the console\n ap doc\n # Insert into the database\n result = @DB[coll].insert_one(doc)\n end\nend", "def bulk_save(docs)\n server.post(\"#{name}/_bulk_docs\", {:docs => docs})\n end", "def export_to_collection(matched_crime)\n doc_to_export = []\n matched_crime.each do |document|\n doc_to_export = document\n end\n result = export.insert_one(doc_to_export)\n puts \"Zapisano w kolekcji crime_export\"\nend", "def persist_delayed(objs, inserts)\n unless objs.empty?\n # collection.insert(inserts)\n inserts.each do |insert|\n insert.save\n end\n objs.each do |obj|\n # obj.save\n # obj.post_persist\n end\n end\n end", "def add_resources\n exhibit.solr_documents.each do |d|\n sitemap.add sitemap.exhibit_solr_document_path(exhibit, d), priority: 0.25, lastmod: document_last_modified(d)\n end\n end", "def insert(document)\n collection.insert document\n end", "def add_all_documents\n # Soit la liste des documents est déterminée par la configuration,\n # soit on prend les documents dans l'ordre du dossier (mauvais car c'est\n # très aléatoire)\n\n # +files+ est une liste de chemins d'accès absolus\n files = film.documents || Dir[\"#{film.folder_documents}/**/*.md\"]\n files.each do |src|\n if File.extname(src).start_with?('.htm')\n # <= C'est un fichier HTML qui est requis\n # => Soit c'est un document automatique et il faut le construire\n # pour l'actualiser.\n # Soit c'est un document personnalisé et on s'attend à le trouver\n # dans le dossier\n\n # Dans tous les cas, le nom du fichier de destination sera le même que\n # le nom du fichier source\n dst = src\n\n if AUTO_DOCUMENTS.key?(File.basename(src))\n # <= C'est un fichier automatique\n # => On l'actualise dans tous les cas\n\n suivi(\"Actualisation du fichier #{src}\")\n script_path = File.join(APP_FOLDER,'ajax','ajax','_scripts',\"build_#{File.basename(src,File.extname(src))}.rb\")\n load script_path\n\n elsif not(File.exists?(dst))\n # <= Le fichier n'existe pas\n # => On signale une erreur de document manquant\n log(\"Fichier #{src.inspect} recherché dans #{dst.inspect}\")\n suivi(\"ERREUR NON FATALE : fichier introuvable #{src}\")\n film.export_errors << \"Le fichier #{File.basename(src).inspect} devrait être ajouté aux livres, mais il est introuvable (dans #{src.inspect})\"\n next\n end\n\n else\n\n # <= Ce n'est pas un nom de fichier HTML\n # => On le formate en le kramdownant\n\n affixe = File.basename(src, File.extname(src))\n dst = File.join(film.folder_products,\"#{affixe}.html\")\n File.delete(dst) if File.exists?(dst)\n suivi(\"Construction du fichier #{dst} depuis markdown\")\n File.open(dst,'wb'){|f| f.write( kramdown(src) )}\n end\n\n suivi(\" + Ajout de : #{dst}\")\n @stream << File.read(dst)\n\n end\nend", "def insert_\n # new files to insert\n nfiles = @curr_schema.select_new_files\n count = nfiles.size\n Logger.<<(__FILE__,\"INFO\",\"Found #{nfiles.size} files to decode & insert for #{@curr_source.name}...\");\n return unless nfiles.size > 0\n\n SignalHandler.check\n ## Will decode them and insert their records, one by one (file)\n base_path = ::File.join(Conf::directories.store,@curr_source.name.to_s)\n ids_processed = []\n file_counter = 0\n iterate_over nfiles do |file|\n file_path = File.join(base_path,file[:folder],file[:file_name])\n begin\n file_ = CDR::File.new(file_path,search: true)\n rescue => e\n Logger.<<(__FILE__,\"WARNING\",\"File Error : #{e}\")\n raise e\n end\n records = @curr_source.decoder.decode file_\n if records.nil? \n Logger.<<(__FILE__,\"WARNING\",\"Found null output for file #{file}\")\n else\n @curr_schema.insert_records file[:file_id], records\n end\n @curr_schema.processed_files RubyUtil::arrayize(file[:file_id])\n backup_file file[:folder],file_\n str = log_file_summary file_,records\n Logger.<<(__FILE__,\"INFO\",\"(#{file_counter}/#{count}) #{str}\",inline: true)\n file_counter += 1\n end\n # so only one lookup for table cdr\n #mark_processed_decoded_files (ids_processed)\n Logger.<<(__FILE__,\"INFO\",\"Decoded & Inserted #{count} files ...\")\n Logger.<<(__FILE__,\"INFO\",\"Insert operation finished !\")\n end", "def find_or_create_documents!\n @find_or_create_documents ||= save!\n end", "def upload_images_and_documents\n if params[:project][:images]\n params[:project][:images].each do |project_image|\n @project.images.create(image: project_image, document: false)\n end\n end\n\n if params[:project][:legal_documents]\n params[:project][:legal_documents].each do |project_doc|\n @project.images.create(image: project_doc, document: true)\n end\n end\n end", "def execute_batch_push(docs)\n self.inserts_valid = true\n pushes = pre_process_batch_insert(docs)\n if insertable?\n collection.find(selector).update_one(\n positionally(selector, '$push' => { path => { '$each' => pushes } }),\n session: _session\n )\n post_process_batch_insert(docs)\n end\n pushes\n end", "def save_collection_places\n CollectionPlace.delete_all :conditions => [\"collection_id = ?\", self.id]\n inserts = (what.query[:places].values.map { |place_id| \"('#{self.id}','#{place_id}')\" }).join(\",\")\n CollectionPlace.connection.insert(\"insert into collection_places (collection_id, place_id) values #{inserts}\")\n end", "def insert_words(words)\n words.each do |word|\n insert(word)\n end\n end", "def insert_documents(obj, safe=nil, continue_on_error=false)\n to_do = [obj].flatten\n concern = @db.write_concern(safe)\n if continue_on_error\n out = []\n to_do.each do |doc|\n res = _insert_one(doc, concern)\n out << res if res\n end\n if to_do.size != out.size\n msg = \"Failed to insert document #{obj.inspect}, duplicate key, E11000\"\n raise(Mongo::OperationFailure, msg)\n end\n else\n begin\n @j_collection.insert( to_dbobject(to_do), concern )\n if @monitorable\n mon_do = to_do.map{ |doc| {'_id'=>doc['_id'], 'action'=>1} }\n @j_mon_collection.insert( to_dbobject(mon_do), concern )\n end\n rescue => ex\n if ex.message =~ /E11000/\n msg = \"Failed to insert document #{obj.inspect}, duplicate key, E11000\"\n raise(Mongo::OperationFailure, msg) if concern.w > 0\n else\n msg = \"Failed to insert document #{obj.inspect} db error: #{ex.message}\"\n raise Mongo::MongoDBError, msg\n end\n end\n end\n to_do\n end", "def migrate_document_structure\n set_previous_migrations\n\n GuidesGenerator::Parser::doc_hash.each do |version, data|\n text = get_version_index_text(data['files'], version)\n version_record = get_or_create_version(version, text)\n\n if data['files'] then migrate_documents(data['files'], nil, version_record) end\n if data['sections'] then migrate_sections(data['sections'], version_record) end\n end\n\n destroy_removed_migrations\n end", "def create\n PlaceVisit.collection.insert_many(params[:place_visits]) #save to batch to database mongoid awesome\n end", "def save\n generate_archive(generate_content_types, generate_rels, generate_document)\n end", "def copy_files(dest_dir)\n @package.documents.each do |file|\n ActiveRecord::Base.logger.debug \"copying file #{file.attach.path} in #{File.join(dest_dir, \"\")}\"\n FileUtils.cp(file.attach.path, File.join(dest_dir, \"\"))\n end\n end", "def put_docs(dir)\n try_operation do |log|\n success = true\n log << \"Loading documents in #{dir}\\n\"\n Dir.each_child(dir) do |f|\n log << \"\\t#{f}: \"\n filepath = File.join(dir, f)\n if f.end_with?(\".rb\") && File.exists?(filepath) && !File.directory?(filepath)\n # Read the file into a Ruby hash (incredibly unsafe, obviously) and convert to JSON\n hash = eval(IO.read(filepath))\n json = JSON.generate(hash)\n \n uri = URI::HTTP.build(\n host: DB_HOST,\n port: DB_PORT,\n path: DB_DBNAME\n )\n\n # Send the PUT request to create the corresponding document\n request = Net::HTTP::Post.new(uri)\n request['Content-Type'] = 'application/json'\n response = Net::HTTP.start(uri.hostname, uri.port, {}) do |http|\n http.request(request, json)\n end\n\n # Record the result.\n log << \"#{response.code} #{response.message}\\n\"\n if response.code.to_i < 200 || response.code.to_i > 299\n success = false\n end\n end\n end\n return success, log\n end\nend", "def insert\n @fieldname = params[:fieldname]\n @uploader_id = params[:uploader_id]\n @assets = Assetabler::Asset.find(params[:asset_ids])\n end", "def add_documents\n\t\tif @current_user.present?\n\t\t\t@property = Property.find(params[:property_id])\n\t\t\tif @property.present?\n\t\t\t\tif @property.documents.present?\n\t\t\t\t\[email protected]_all\n\t\t\t\tend\n\t\t\t\tparams[:files].each { |file|\n\t i = @property.documents.create(file: file)\n\t if i.save\n\t else\n\t \trender_json({\"status\" => \"Fail\", \"message\" => i.errors.full_messages.first}.to_json)\n\t \treturn\n\t end\n\t }\n\t render :file => 'api/v1/property/add_document'\n\t #render_json({\"status\" => \"Success\", \"message\" => \"Documents has been saved successfully.\"}.to_json)\n\t else\n\t \trender_json({\"status\" => \"Fail\", \"message\" => \"No property found.\"}.to_json)\n\t end\n\t\tend\n\tend", "def upload\n create_document\n \n render_upload\n end", "def save_docs(docs, o = {})\n return 0 if !docs || docs.size == 0\n saved_count = 0\n docs = filter_existing_docs(docs) if @src.itype != 'file' && !o[:force]\n return 0 if !docs || docs.size == 0\n docs_db = Item.find_by_dids(docs.map{|d|d[:did]}).map_hash{|d|[d[:did],d]}\n debug \"[save_docs] #{docs_db.size}/#{docs.size} docs found from db\"\n docs.each do |doc|\n #debug \"[save_docs] Processing #{doc[:did]}\"\n next if @src.o[:insert_only] && docs_db[doc[:did]]\n doc_db = docs_db[doc[:did]] || Item.new\n next if doc_db.modified_flag || !doc_db.changed_content?(doc)\n begin\n #type = (doc[:itype] =~ /query/)? 'Query' : 'Document'\n doc_db.update_attributes(doc.merge(:source_id=>@src.id))\n #debug \"[save_docs] filter : #{@src.filter.inspect}\"\n if @src.filter && @src.filter.size > 0 && doc_db.validate_by_condition(@src.filter)\n info \"[collect] Document #{doc_db.did} filtered out!\"\n doc_db.destroy\n else\n doc[:metadata][:tag_list].split(\",\").each{|e|doc_db.create_and_link(e, 'tag','t')} unless doc[:metadata][:tag_list].blank?\n doc_db.create_and_link(doc[:metadata][:query], 'query','q') if doc[:metadata][:query]\n #doc_db.add_tags(doc[:metadata][:tag_list], \"s\") unless doc[:metadata][:tag_list].blank?\n doc_db.process_all\n saved_count += 1\n doc_db.save\n end\n rescue Exception => e\n error \"[save_docs] \"+[e.inspect,e.backtrace].join(\"\\n\")\n end\n end\n #puts \"[save_docs] saved_count = #{saved_count}\"\n saved_count\n end", "def index\n @bulk_insert_lists = BulkInsertList.all\n new\n end", "def docs_to_write\n documents.select(&:write?)\n end", "def add_document(attributes)\n folder.documents.create(attributes)\n end", "def batch_save(root, resources, persps, exts)\n batch_save_actions(root, resources, persps, exts) do |action|\n action.perform\n end\n end", "def generate_and_persist_docs(module_branch, parsed_dsl)\n doc_generator = DocGenerator.new(module_branch, parsed_dsl).generate!(raise_error_on_missing_var: false)\n file_path__content_array = doc_generator.file_path__content_array\n return if file_path__content_array.empty?\n\n # add and commit these files\n final_doc_paths = doc_generator.file_paths\n commit_msg = \"Adding generated document files: #{final_doc_paths.join(', ')}\"\n RepoManager.add_files(module_branch, file_path__content_array, commit_msg: commit_msg)\n\n # finally we push these changes\n RepoManager.push_changes(module_branch)\n end", "def insert(options = {})\n prepare_insert(options) do\n if embedded?\n insert_as_embedded\n else\n insert_as_root\n end\n end\n end", "def update\n DOCUMENT_PATHS.each do |attr_name, path|\n if path.match(/\\*/)\n instance_variable_get(\"@#{attr_name}\").each do |simple_file_name, contents|\n replace_entry(\"word/#{simple_file_name}.xml\", contents.serialize(save_with: 0))\n end\n else\n xml_document = instance_variable_get(\"@#{attr_name}\")\n replace_entry path, xml_document.serialize(save_with: 0) if xml_document\n end\n end\n end", "def docImportHTML\n sourceDir = Pathname.new pathExports\n destDir = Pathname.new pathDocuments\n \n # Process and copy pages to dest dir.\n n = 0\n docPages().each do |page|\n n = n + 1\n \n sourceFile = sourceDir + pageOriginalFile(page) + \"index.html\"\n destPath = destDir + pageTargetFile(page)\n destFile = destPath + \"index.html\"\n \n puts \"Importing File #{n.to_s}: #{sourceFile} #{destFile}\"\n puts \" \"\n \n destPath.mkpath()\n html = File.open(sourceFile, \"rb\") { |f| f.read }\n html = htmlUpdateLinks(html)\n html = htmlStripTOC(html)\n html = htmlReplaceSyntaxHighlighterTags(html)\n html = htmlReplaceTabsWithSpaces(html)\n html = htmlPrettify(html)\n fileSaveContent(destFile, html)\n end\nend", "def index\n @insert_pubs = InsertPub.all\n end", "def insert_resource(doc)\n self.collection.insert(doc)\n end", "def bulk_import\n client = ElasticsearchClient.client\n\n find_in_batches.with_index do |entries, _i|\n client.bulk(\n index: es.index_name,\n type: '_doc',\n body: entries.map { |entry| { index: { _id: entry.id, data: entry.as_indexed_json } } },\n refresh: true, # NOTE: 定期的にrefreshしないとEsが重くなる\n )\n end\n end", "def create_entries\n existing_mappings = site.mappings.where(path: canonical_paths)\n\n records = canonical_paths.map do |canonical_path|\n entry = BulkAddBatchEntry.new(path: canonical_path)\n entry.mappings_batch = self\n entry.mapping = existing_mappings.detect { |mapping| mapping.path == canonical_path }\n entry\n end\n\n BulkAddBatchEntry.import(records, validate: false)\n end", "def persist\n prepare do\n unless updates.empty?\n collection.find(selector).update(updates)\n conflicts.each_pair do |key, value|\n collection.find(selector).update({ key => value })\n end\n end\n end\n end", "def batch_insert(operations, chunk_size=1000)\n raise \"Batch request must not exceed 1000 documents.\" unless chunk_size <= 1000\n operations.each_slice(chunk_size)\n .to_a\n .each{|op|\n resp = create_request().post(build_indexing_url(), :json => {:value => op})\n raise_on_http_error(resp)\n resp.to_s\n }\n end", "def import_page(page, parent_slug=nil)\n @db.save_doc({\n :title => page['title'],\n :version => ARGV[0],\n :language => 'en-us',\n :path => \"#{parent_slug}/#{page['url']}\",\n :text => get_content(\"#{parent_slug}/#{page['url']}\"),\n })\n puts \"saving #{page.inspect} to couchdb...\\n\"\nend", "def seed(&block)\n raise 'Must provide a block' unless block_given?\n\n @@urls.clear\n @@docs.clear\n\n # &block populates the @@urls and @@docs arrays.\n instance_eval(&block)\n\n begin\n @@db.client[:urls].insert_many(@@urls) unless @@urls.empty?\n @@db.client[:documents].insert_many(@@docs) unless @@docs.empty?\n\n @@urls.count + @@docs.count\n rescue StandardError => e\n err_msg = e.respond_to?(:result) ? e.result['writeErrors'] : e.message\n raise \"Write to DB failed - remember that both urls and docs won't \\\naccept duplicate urls. Exception details: #{err_msg}\"\n end\n end", "def save_or_delay(doc, docs, inserts)\n if doc.new_record? && doc.valid?(:create)\n doc.run_before_callbacks(:save, :create)\n docs.push(doc)\n inserts.push(doc.send(:as_attributes))\n else\n doc.save\n end\n end", "def update_all\n delete if blacklight_items.count > 0\n self.exports.collect { |pid| add_to_solr(pid) }\n commit\n end", "def insertDB()\n $allTracks.each do |track|\n\t\tif track.embeddable_by == \"all\" and not track.genre.nil? then\n\n\t\t isRap = false\n\t\t i = 0\n\n\t\t\twhile i < $rapGenres.count\n\t\t\t\tif track.genre.downcase.include? $rapGenres[i] or \n\t\t\t\t track.title.downcase.include? $rapGenres[i] or\n\t\t\t\t\t track.user.username.downcase.include? $rapGenres[i] then\n\t\t\t\t isRap = true\n\t\t\t\t break\n\t\t\t\telse\n\t\t i += 1\n\t\t\t\tend\n\t\t\tend\t\n\n\t\t if isRap then\n\t\t begin\n $db.execute(\"INSERT INTO tracks (id, created_at, title, permalink_url, uri, genre, comment_count, download_count, playback_count, favoritings_count, shared_to_count, raw) VALUES (?,?,?,?,?,?,?,?,?,?,?,?); COMMIT;\", track.id, ARGV[0], track.title, track.permalink_url, track.uri, track.genre, track.comment_count, track.download_count, track.playback_count, track.favoritings_count, track.shared_to_count, track.to_json)\n\t\t rescue\n\t\t puts \"Error while inserting track #{track.id} => #{track.to_json}\"\n\t\t end\n\t\t end\n\t\tend\n end\nend", "def insert\n @url_override = refinery.admin_images_path(request.query_parameters.merge(:insert => true))\n \n render :action => \"insert\"\n end", "def index\n @editor_atto_autosaves = EditorAttoAutosave.all\n end", "def insert_all(iter)\n iter.each {|v|\n insert v\n }\n nil\n end", "def add_document(folder_path)\n document_list = client.get_list(folder_path)\n document_list.add_file! file: File.join(Rails.root, 'public', 'uploads', 'documents') \n end", "def index_site(\n url, insert_externals: true, allow_paths: nil, disallow_paths: nil\n )\n crawl_opts = { allow_paths: allow_paths, disallow_paths: disallow_paths }\n total_pages_indexed = 0\n\n ext_urls = @crawler.crawl_site(url, crawl_opts) do |doc|\n result = true\n result = yield(doc) if block_given?\n\n if result && !doc.empty? && write_doc_to_db(doc)\n total_pages_indexed += 1\n Wgit.logger.info(\"Crawled and saved internal page: #{doc.url}\")\n end\n end\n\n @db.url?(url) ? @db.update(url) : @db.insert(url)\n\n if insert_externals && ext_urls\n num_inserted_urls = write_urls_to_db(ext_urls)\n Wgit.logger.info(\"Found and saved #{num_inserted_urls} external url(s)\")\n end\n\n Wgit.logger.info(\"Crawled and saved #{total_pages_indexed} docs for the \\\nsite: #{url}\")\n\n total_pages_indexed\n end", "def upload_text_assets(pages, access)\n asset_store.save_full_text(self, access)\n pages.each do |page|\n asset_store.save_page_text(self, page.page_number, page.text, access)\n end\n end", "def documents\n document_entries.map{ |f| FileObject[path, f] }\n end", "def import\n files\n @files.each {|file|\n Song.create_from_filename(file)\n }\n end", "def all\n @document = Document.all\n end", "def index\n @insert_conditions = InsertCondition.all\n end", "def add_to_index posts\n indexDir = java.io.File.new(@index_dir);\n writer = IndexWriter.new(indexDir, StandardAnalyzer.new, !File.exists?(indexDir.absolute_path))\n posts.each do |post|\n writer.updateDocument(Term.new(\"id\",post[:id]),create_lucene_document(post))\n @last_id = post[:id]\n @log.debug \"added post ##{post[:id]}\"\n end \n writer.optimize\n writer.close\n @log.info \"added #{posts.size} documents to index\"\n end", "def bulk_save( docs, opts = {} )\n parse = opts.delete :parse\n bulk = { :docs => docs }\n bulk[ \"all_or_nothing\" ] = true if opts.delete(:atomic) == true\n \n response = http_action :post, '_bulk_docs', opts.merge( :doc => bulk )\n\n docs.zip( response ) do |pair|\n doc, response = pair\n doc['_id'] = response['id']\n doc['_rev'] = response['rev']\n end\n \n parse ? response : response.to_json\n end", "def insert\n Thread.current[:\"[mongoid]:insert-consumer\"]\n end", "def insert\n Thread.current[:\"[mongoid]:insert-consumer\"]\n end", "def insert\n Thread.current[:\"[mongoid]:insert-consumer\"]\n end", "def sync\n puts \"Current pages: #{jekyll.join(', ')}\"\n puts \"New pages: #{dropbox.join(', ')}\"\n \n to_delete = jekyll - dropbox\n to_delete.map {|p| delete \"#{@dir}/#{p}\"}\n \n dropbox.map {|p| create \"#{@dir}/#{p}\"}\n end", "def flush_writes\n @queued_for_write.each do |style, file|\n raise FileExists, \"file \\\"#{path(style)}\\\" already exists in your Google Drive\" if exists?(path(style))\n\n name, mime_type = filename_from(style), \"#{ file.content_type }\"\n\n file_metadata = {\n name: name,\n description: 'paperclip file on google drive',\n mimeType: mime_type,\n parents: [find_public_folder]\n }\n\n google_api_client.create_file(\n file_metadata,\n fields: 'id',\n upload_source: file.binmode,\n content_type: file.content_type,\n )\n end\n after_flush_writes\n @queued_for_write = {}\n end", "def index_site(\n url, insert_externals: false, follow: :default,\n allow_paths: nil, disallow_paths: nil\n )\n crawl_opts = {\n follow: follow,\n allow_paths: allow_paths,\n disallow_paths: disallow_paths\n }\n total_pages_indexed = 0\n\n ext_urls = @crawler.crawl_site(url, **crawl_opts) do |doc|\n result = block_given? ? yield(doc) : true\n\n if result && !doc.empty?\n write_doc_to_db(doc)\n total_pages_indexed += 1\n end\n end\n\n @db.upsert(url)\n\n if insert_externals && ext_urls\n num_inserted_urls = write_urls_to_db(ext_urls)\n Wgit.logger.info(\"Found and saved #{num_inserted_urls} external url(s)\")\n end\n\n Wgit.logger.info(\"Crawled and indexed #{total_pages_indexed} documents \\\nfor the site: #{url}\")\n\n total_pages_indexed\n end", "def added(model, index)\n root_model.persistor.save_all\n end", "def save(bulk = false)\n raise ArgumentError, \"doc.database required for saving\" unless database\n result = database.save_doc self, bulk\n result['ok']\n end", "def prepare_insert(options = {})\n raise Errors::ReadonlyDocument.new(self.class) if readonly? && !Mongoid.legacy_readonly\n return self if performing_validations?(options) &&\n invalid?(options[:context] || :create)\n run_callbacks(:commit, with_children: true, skip_if: -> { in_transaction? }) do\n run_callbacks(:save, with_children: false) do\n run_callbacks(:create, with_children: false) do\n run_callbacks(:persist_parent, with_children: false) do\n _mongoid_run_child_callbacks(:save) do\n _mongoid_run_child_callbacks(:create) do\n result = yield(self)\n if !result.is_a?(Document) || result.errors.empty?\n post_process_insert\n post_process_persist(result, options)\n end\n end\n end\n end\n end\n end\n end\n self\n end", "def post_process_insert\n self.new_record = false\n flag_descendants_persisted\n true\n end", "def insert_without_hooks( index, *objects )\n\n @without_hooks = true\n\n insert( index, *objects )\n \n @without_hooks = false\n\n return objects\n\n end", "def append_document append_docs, import_format_modes, source_folder\n begin\n\n if append_docs.length != import_format_modes.length\n raise 'Please specify complete documents and import format modes.'\n end\n\n str_uri = $product_uri + '/words/' + @filename + '/appendDocument'\n signed_str_uri = Aspose::Cloud::Common::Utils.sign(str_uri)\n\n objs = []\n\n i = 0\n append_docs.each do |val|\n objs << {\"Href\" => source_folder.empty? ? val : source_folder + \"\\\\\" + val, \"ImportFormatMode\" => import_format_modes[i]}\n i = i+1\n end\n\n json_data = JSON.generate({'DocumentEntries' => objs})\n\n response_stream = RestClient.post(signed_str_uri, json_data, {:content_type => :json})\n\n valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)\n\n return valid_output unless valid_output.empty?\n folder = Aspose::Cloud::AsposeStorage::Folder.new\n\n output_stream = folder.get_file(source_folder.empty? ? @filename : (source_folder + '/' + @filename))\n output_path = $out_put_location + @filename\n Aspose::Cloud::Common::Utils.save_file(output_stream, output_path)\n ''\n rescue Exception => e\n print e\n end\n end", "def on_end_document()\n\n\t\tif ['PostgreSQL','MySQL'].include?(@source.connection.adapter_name) then\n\t\t\tresolve_ids_sql\n\t\t\t#resolve_ids_activerecord\n\t\telse\n\t\t\tresolve_ids_activerecord\n\t\tend\n\t\t\n\t\tputs UnresolvedId.count(:conditions => {:source_id => @source.id}).to_s + \" unresolved IDs\" if Debug > 3\n\n\t\t# add state_id to streets. this eases later lookup\n\t\t# We use a shortcut when we can, rails convention if we're not sure\n\t\tif ['PostgreSQL','MySQL'].include?(@source.connection.adapter_name) then\n\t\t\tadd_state_to_addresses_sql\n\t\telse\n\t\t\tadd_state_to_addresses_activerecord\n\t\tend\n\n\t\[email protected]_completed_at = Time.now\n\t\[email protected] = @contrib unless @contrib.nil?\n\t\[email protected]!\n\t\[email protected]\n\n\tend", "def temp\n # Find all files in the system\n allFiles = Devfile.find(:all)\n \n metadatatype = MetadataType.find_by_name(\"backup_recovery_path\")\n if metadatatype == nil\n render :text => \"Metadatatype was not found\", :status => 404\n return\n end\n \n # Go through each file and add metadata to it\n allFiles.each do |x|\n metadatavalue = '/home/user/MyDocs/DCIM/'+x.name\n Metadata.find_or_create_by_metadata_type_id_and_devfile_id(:metadata_type_id => metadatatype.id,\n :value => metadatavalue,\n :devfile_id => x.id) \n end\n \n render :text => \"Metadata added to all files in the system\", :status => 201\n return\n end", "def insert_as_root\n collection.insert_one(as_attributes, session: _session)\n end", "def store_files(uuids)\n Uploadcare::FileList.batch_store(uuids)\n end", "def create_all\n for i in 0..Pdf.get_pdf_file_count do\n pdf = Pdf.create_pdf(i.to_s, @client, @settings)\n pdf_file_name = Pdf.get_pdf_file_name(Pdf::PDFS.keys[i], @client)\n pdf.render_file(\"#{Rails.root}/app/assets/generated-pdfs/#{pdf_file_name}\")\n end\n generate_zip(@client)\n end", "def receive_document(doc)\n folder.documents << doc\n end", "def complete_upload_document\n @dom_id = \"##{params[:file][:dom_id]}\"\n\n @asset = Document.new(uploaded_asset_attributes.reverse_merge(uploaded_by: current_user))\n key = @asset.add_meta(params[:file])\n if @asset.save\n @asset.update_columns(media: key)\n end\n render template: \"/dash/chooser/complete_upload\"\n end", "def upload(options)\n raise NotReadyError, \"User hasn't been created yet\" unless created?\n Document.create options.merge(:owner => self)\n end", "def insert(table,doc)\n connection.insert(path(table),doc)\n end", "def cloud_search_batch_documents(&block)\n begin\n self.in_cloud_search_batch_documents = true\n yield\n # final flush for any left over documents\n self.cloud_search_document_batcher.flush\n ensure\n self.in_cloud_search_batch_documents = false\n end\n end", "def create_search_docs_and_upload(wd)\n started_at = Time.now\n \n #upload all files\n if wd.nil?\n wd = Dir.getwd\n end\n \n langs = Array.new\n if (Settings[:lang].nil?)\n @log.debug \"Environment :lang variable not set. Uploading directory: #{wd}/#{Settings[:CONTENT_DIR]}\"\n \n # Lang has not been set at the command-line, so do them all\n langs = []\n Pathname.glob(\"#{wd}/#{Settings[:CONTENT_DIR]}/*\").map { |i|\n langs << i.basename \n }\n else\n langs = Settings[:lang]\n end\n \n #we didn't find any languages. this might happen if the directory is empty or doesn't exist\n if (langs.empty?)\n langs = [Settings[:DEFAULT_LOCALE]]\n end\n \n #create the search docs for both lucene and cloudant\n create_search_doc_couchdb_lucene(langs)\n create_search_doc_cloudant(langs)\n construct_view()\n bulk_save()\n \n # Loop over the array of langs and upsert each directory\n langs.each {|i|\n begin\n locale_dir = \"#{wd}/#{Settings[:CONTENT_DIR]}/#{i}\"\n @log.debug \"Attempting to upload directory in: #{locale_dir}\"\n if File.directory? locale_dir\n #Upload this language and save it\n upload_directory(i, locale_dir)\n bulk_save()\n else\n @log.debug \"#{locale_dir} does not exist. Skipping.\"\n end\n rescue => e\n @log.error \"Couldn't upload #{locale_dir}.\"\n @log.error e.class\n @log.error e.message\n end\n }\n @log.info \"Upload duration: #{Time.now - started_at}\"\n end", "def create\n \n forbidden unless current_account_user.create_legal_document\n if params[:transloadit]\n documents = TransloaditDocumentsParser.parse params[:transloadit], @account.id\n if documents\n documents.each do |document|\n \n CatalogsDocuments.where(catalog_id: @catalog.id, document_id: document.id)\n .first_or_create(catalog_id: @catalog.id, document_id: document.id)\n \n DocumentExtractTextWorker.perform_async( document.id )\n end\n end\n end\n redirect_to catalog_account_catalog_documents_path(@account, @catalog)\n \n end", "def index_url(url, insert_externals: false)\n document = @crawler.crawl_url(url) do |doc|\n result = block_given? ? yield(doc) : true\n write_doc_to_db(doc) if result && !doc.empty?\n end\n\n @db.upsert(url)\n\n ext_urls = document&.external_links\n if insert_externals && ext_urls\n num_inserted_urls = write_urls_to_db(ext_urls)\n Wgit.logger.info(\"Found and saved #{num_inserted_urls} external url(s)\")\n end\n\n nil\n end", "def append_document append_docs, import_format_modes, source_folder\n begin\n \n if @filename == \"\"\n raise \"Base file not specified.\"\n end\n \n if append_docs.length != import_format_modes.length\n raise \"Please specify complete documents and import format modes.\"\n end\n \n str_uri = $productURI + \"/words/\" + @filename + \"/appendDocument\"\n signed_str_uri = Common::Utils.sign(str_uri)\n \n post_hash = Hash[\"DocumentEntries\",append_docs]; \n json_data = post_hash.to_json\n \n response_stream = RestClient.post(signed_str_uri,json_data,{:accept=>\"application/json\"})\n \n valid_output = Common::Utils.validate_output(response_stream)\n \n if valid_output == \"\" \n folder = SaasposeStorage::Folder.new\n if source_folder == \"\"\n output_stream = folder.getfile(@filename)\n else\n output_stream = folder.getfile( source_folder + \"/\" + @filename)\n end\n output_path = $OutPutLocation + @filename\n Common::Utils.saveFile(output_stream,output_path)\n return \"\"\n else\n return valid_output\n end\n \n \n rescue Exception=>e\n print e\n end\n end", "def insertDocument(collection, document)\n return collection.insert_one(document)\n end", "def to_inserts(args={})\n args[:table] ||= Pathname.new(@filename).basename.to_s.downcase.gsub(/\\W/, '_')\n args[:before] ||= @@defaults[:before]\n args[:after] ||= @@defaults[:after]\n insert_sql = args[:ignore] ? 'insert ignore' : 'insert'\n if args[:bulk]\n args[:before] += \"#{insert_sql} into #{args[:table]} values\"\n args[:values_glue] ||= \", \"\n args[:row_format] ||= \" (%s)\"\n args[:row_glue] ||= \",\\n\"\n else\n args[:before] ||= \"\"\n args[:values_glue] ||= \", \"\n args[:row_format] ||= \"#{insert_sql} into #{args[:table]} values(%s)\"\n args[:row_glue] ||= \";\\n\"\n end\n to_any args\n end", "def db_insert!( db_file )\n ####db = SQLite3::Database.new( db_file )\n ####db.transaction do |database|\n #### if not database.execute( db_fetch ).empty?\n #### raise(IndexError, \"Entry exists for #{filename}, #{@rmr_number}, #{@timestamp.to_s}... Skipping.\")\n #### end\n #### database.execute( db_insert )\n ####end\n ####db.close\n puts \"SQLite3\"\n end", "def create\n #@visit = params[:visits]\n Visit.collection.insert_many(params[:visits]) #save to batch to database mongoid awesome\n \n end", "def add_doc\n folder_id = params[:folder_id]\n\n temp_folder = Folder.new(folder_params)\n temp_folder.title = \"Temporary Folder\"\n\n if temp_folder.documents.empty?\n flash[:error] = \"At least one document is required.\"\n render :new_doc\n elsif temp_folder.save!\n # CompanyFolder.create!(company_id: params[:company_id], folder_id: folder_id)\n temp_folder.documents.each{|doc|\n doc.folder_id = folder_id\n doc.save!\n }\n temp_folder.delete\n\n flash[:info] = \"Document added to folder\"\n redirect_to company_folder_path(company_id: params[:company_id], id: folder_id)\n else\n flash[:error] = \"Document NOT added to folder\"\n redirect_to company_folder_new_doc_path(company_id: params[:company_id], id: params[:folder_id])\n end \n end", "def add_or_update_file(complete_path)\n document = Document.default_fields_for(complete_path)\n begin\n document.merge! PlainTextExtractor.extract_content_and_language_from(complete_path)\n raise \"empty document #{complete_path}\" if document[:content].strip.empty?\n logger.add_document document\n rescue => e\n logger.reject_document document, e\n end\n index << document\n end", "def upload_multiple_documents(note,params)\n if params[:document_home].present?\n document=params[:document_home][:document_attributes]\n Document.upload_multiple_docs_for_task_or_note(document,note,current_user.id,params)\n end\n end", "def archive!\n DocumentArchive.create!(:consumer_id => self.consumer_id, :suggested_standard_document_id => self.suggested_standard_document_id, :rejected_at => Time.now, :suggested_at => self.suggested_at, :source => self.source, :file_content_type => self.file_content_type, :cloud_service_full_path => self.cloud_service_full_path, :original_file_name => self.original_file_name)\n end" ]
[ "0.6468581", "0.64565676", "0.6141663", "0.6056899", "0.59336126", "0.5893217", "0.5812048", "0.5722167", "0.5637171", "0.5619128", "0.55665207", "0.55480045", "0.5512628", "0.5493801", "0.54933095", "0.5415548", "0.53882885", "0.5374697", "0.5373367", "0.53334683", "0.532624", "0.5312434", "0.53063804", "0.53008264", "0.5287844", "0.5225678", "0.5213386", "0.52119195", "0.51986873", "0.51693743", "0.5163203", "0.5134555", "0.5118053", "0.5117169", "0.50859153", "0.5082893", "0.5082308", "0.5073683", "0.5057913", "0.50307333", "0.5026032", "0.4999092", "0.49981046", "0.499197", "0.49778292", "0.4972934", "0.4967877", "0.4962808", "0.49582836", "0.49462357", "0.49424157", "0.49385044", "0.49139205", "0.4903956", "0.4891259", "0.48894268", "0.4889229", "0.4888891", "0.48722246", "0.48598808", "0.4858842", "0.48532787", "0.4850147", "0.4846758", "0.48448968", "0.4837458", "0.48372623", "0.48372623", "0.48372623", "0.48372054", "0.48349464", "0.48193932", "0.4818016", "0.48163235", "0.4813195", "0.48096037", "0.48067528", "0.4799303", "0.47928676", "0.47915944", "0.47905618", "0.47836077", "0.47827572", "0.47798193", "0.47773793", "0.4776112", "0.47715843", "0.47665378", "0.47604597", "0.4757783", "0.4751754", "0.47433972", "0.47382084", "0.47374955", "0.47317815", "0.47231513", "0.4719764", "0.4719313", "0.47114283", "0.4704368" ]
0.54784405
15
Ensure that titles are stripped of trailing whitespace.
def title=(title="Untitled Document") # Clean the stripped title self[:title] = CGI.unescape_html(self.strip title.strip) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strip_blanks\n self.title = self.title.strip\n end", "def strip_blanks\n self.title = self.title.strip\n end", "def strip_whitespace\n self.title = self.title.strip\n end", "def cleansed_title\n self.title.gsub(/[\\t\\r\\n\\f:@]/, '')\n end", "def remove_whitespace\n self.title = self.title.strip\n self.description = self.description.strip\n end", "def strip_blanks\n self.title = self.title.strip\n self.unit = self.unit.strip\n end", "def strip_trailing_whitespace\n %w( title abstract year ).each {|attribute|\n self.send(attribute).to_s.strip!\n }\n end", "def trim_title\n self.title.downcase.gsub(/[^0-9a-z ]/i, '')\n end", "def strip_empty_space\n self.title = title.strip if self.title\n self.preview = preview.strip if self.preview\n self.content = content.strip if self.content\n end", "def normalized_title\n t = self.title.presence || default_title\n t.gsub('.', '').strip\n end", "def cleanup_title(songTitle)\n\ttitle = songTitle.gsub(/(.)+<SEP>/, \"\") # strips everything but title\n\ttitle = title.gsub(/(([\\(\\[\\{\\\\\\/\\_\\-\\:\\\"\\`\\+\\=\\*]|(feat\\.)).*)/, \"\") # strips non-song title items\n\ttitle = title.gsub(/[\\?\\¿\\!\\¡\\.\\;\\&\\@\\%\\#\\|]/, \"\") # strips punctuation\n\tif title =~ (/[^\\x00-\\x7F]+/) # eliminates (most) non-english titles\n\t\treturn nil\n\tend\n\ttitle = title.downcase # converts title to lowercase\n\treturn title\nend", "def trimmed_title\n ttl = self.title || \"\"\n if st = self.url && Site.by_link(self.url)\n ttl = SiteServices.new(st).trim_title ttl\n end\n # Convert HTML entities\n @@coder.decode ttl\n end", "def strip_blanks\n self.title = self.title.strip\n self.code = self.code.strip\n self.complement_title = self.complement_title.strip\n end", "def strip_blanks\n self.title = self.title.strip\n self.code = self.code.strip\n end", "def removeDummyTitles(titleCount)\n\t\tif @oc[\"TitleString\"]==\"\"\n\t\t\tc=\"\"\n\t\t\t(1..titleCount).each do |i|\n\t\t\t\tc=c+\"@\" if i>1\n\t\t\t\tc=c+\"empty-notitle\"\n\t\t\tend\n\t\t\t@oc[\"TitleString\"]=c\n\t\tend\n\tend", "def alternate_clean_title(title)\n title.\n # Take the part of the title before Bill or Act\n split(/Bill|Act/, 2)[0].\n # Remove any brackets\n gsub(/\\([a-zA-Z.\\s\\d'\",-]*\\)/, '').\n # Strip any trailing whitespace\n rstrip\nend", "def sanitized_title\n @sanitized_title ||= title.downcase.gsub(/[\\s\\x00\\/\\\\:\\*\\?\\\"<>\\|]+/, '-')\n end", "def strip_whitespace\n self.title = title.strip\n\n # Don't mess with existing keys (since cannot change key text anyway)\n if new_record?\n self.key = key.strip\n end\n end", "def strip_whitespace\n self.tags = tags.gsub(/\\s+/, '')\n # self.tags = tags.strip\n self.title = title.strip\n self.description = description.strip\n # self.keywords = keywords.strip\n self.body = body.strip\n end", "def cleanup_title(line)\n\t#deletes everything but the song title\n\tline.gsub!(/.+>/, '')\n\t#deletes superfluous text\n\tline.gsub!(/(\\(|\\[|\\{|\\\\|\\/|\\_|\\-|\\:|\\\"|\\`|\\+|\\=|\\*|feat\\.).+$/,'')\n\t\t#deletes punctuation\n\t\tline.gsub!(/(\\?|\\¿|\\!|\\¡|\\.|\\;|\\&|\\@|\\%|\\#|\\|)*/,'')\n\t\t#determines if a word uses english characters or not\n\t\tif line =~ /^[\\w\\s']+$/\n\t\t\tline = line.downcase\n\t\t\t#if not english, sets line to nil\n\t\telse\n\t\t\tline = nil\n\t\tend\n\t\treturn line\n\tend", "def stripped_project_title\n Sanitize.clean(project_title) if project_title\n end", "def strip_naked\n return self if blank?\n self.downcase.strip.gsub(/([\\s]{2,})/, ' ')\n end", "def fix_title\r\n # Remove quotes if the user thought they needed them\r\n self.title = self.title.gsub(/^(?:'|\")(.*)(?:'|\")$/, '\\1')\r\n end", "def fix_title\n # Remove quotes if the user thought they needed them\n self.title = self.title.gsub(/^(?:'|\")(.*)(?:'|\")$/, '\\1')\n end", "def clean_title(title)\n title.\n # Take the part of the title before Bill, Act or -\n split(/Bill|Act|-/, 2)[0].\n # Remove any brackets\n gsub(/\\([a-zA-Z.\\d\\s'\",]*\\)/, '').\n # Strip any trailing whitespace\n rstrip\nend", "def normalized_title\n normalized(full_title)\n end", "def sanitised(title)\n title.delete(',') # ignore, commas\n .sub(/[?!']$/, '') # ignore ? and ! and ' at the end of the title!\n .gsub(\"' \", ' ') # ignore ' at the endin' of a word\n .sub('Feat. ', 'Feat ')\n end", "def flatten_title(title)\n return title.strip.downcase\nend", "def normalize_title(title)\n title.gsub(/_/, ' ')\n end", "def normalize_title(hsh)\n str = hsh['title'].strip\n\n numeral_regexes = [\n /^[0-9]+[.)](\\s+|(?=[\"'”’´‘“`'A-Z]))/i, # initial numbers + punctuation + space or a quote or a capital letter\n /^C{0,3}(L?X{0,3}|X[LC])(V?I{0,3}|I[VX])[.)](\\s+|(?=[\"'”’´‘“`'A-Z]))/i, # initial roman numerals\n /^[A-Z][.)](\\s+|(?=[\"'”’´‘“`'A-Z]))/i # initial single letter\n ]\n\n numeral_regexes.each do |regex|\n if str.gsub!(regex, '')\n break\n end\n end\n\n if (m = str.match /^([\"'”’´‘“`'])/)\n quote_char = m[1]\n pairable = pairable_quote_chars(quote_char)\n\n if str.scan(/[#{pairable}]/).length >= 2\n str.gsub!(/^#{quote_char}/, '')\n str.gsub!(/[#{pairable}][^#{pairable}]+$/, '')\n end\n end\n\n while (m = str.match /\\S+\\s+\\S+.*(\\n|\\.(?=\\s|\\()).*/)\n i = str.rindex m[1]\n str = str[0..i-1]\n end\n\n hsh['title'] = str\n normalize('title',hsh)\n end", "def remove_title_if_present\n @doc.css('title').each { |node| node.remove }\n end", "def title_brief\n return '' unless @marc_record && @marc_record['245']\n subfieldA = @marc_record['245']['a'] || ''\n title = subfieldA.strip\n # return the cleaned up title\n trim_punctuation(title)\n end", "def remove_whitespace\n self.description = self.description.strip\n end", "def check_title\n if self.title.blank? && st = (url && Site.by_link(self.url))\n self.title = (st.yield :Title, st.sampleURL)[:Title] || \"\"\n self.title = self.trimmed_title\n else\n self.title\n end\n end", "def cleanup_title(line)\n\n\t# title variable\n\ttitle = nil\n\n\t# splitting the line by \">\"\n\t# as the result should have 4 different strings\n\t# the tmp_4 war should contain title string\n\ttmp_1, tmp_2, tmp_3, tmp_4 = line.chomp.split(/>/)\n\n\t# ===============================================================\n\t# make the first letter of the string uppercase\n\tstr_up = tmp_4\n\tstr_up[0] = str_up[0].upcase\n\ttitle_tmp = str_up\n\t# ===============================================================\n\n\tif title_tmp.match(/^[\\A]/)\n\n\t\t# splitting up the title_tmp further\n\t\t# after splitting the first part of the title_tmp string should give back title\n\t\t# and the rest what left is the garbage string\n\t\ttitle_tmp_2, garbage = title_tmp.chomp.split(/[\\/\\()\\[\\]\\:\\_\\-\\+\\=\\*\\@\\![0-9]]/)\n\n\t\t# ===============================================================\n\t\t# Replace spaces within an empty char\n\t\tstr_no_sp = title_tmp_2.gsub(/\\s/,'')\n\t\tstr_no_sp = str_no_sp.gsub(/\\?/,'')\n\t\tstr_no_sp = str_no_sp.gsub(/\\!/,'')\n\t\tstr_no_sp = str_no_sp.gsub(/\\./,'')\n\t\tstr_no_sp = str_no_sp.gsub(/\\'/,'')\n\t\t\n\t\t# check if title matches the regular expression\n\t\treg_str = str_no_sp[/[a-zA-Z]+$/]\n\t\tis_equal = str_no_sp == reg_str # true or false\n\t\t# ================================================================\n\t\t\n\t\tif is_equal == true\n\t\t\tif title_tmp_2 != \"\"\n\t\t\t\t$counter_1 += 1\n\t\t\t\ttitle = title_tmp_2.downcase!.gsub(/\\s+$/,'')\n\t\t\t\ttitle = title.gsub(/\\.$/,'')\n\t\t\t\t#puts \"*********************\\n\"\n\t\t\t\t#puts \"[ENG][+]: #{title} ==> #{$counter_1}\"\n\t\t\t\t#puts \"*********************\\n\"\n\t\t\tend\t\n\t\telse\n\t\t\t$counter_2 += 1\n\t\t\t#puts \"*********************\\n\"\n\t\t\t#puts \"[NON-ENG][-]: #{title_tmp_2} ==> #{$counter_1}\"\n\t\t\t#puts \"*********************\\n\"\n\t\tend\n\tend\n\n\t# return cleaned up title string\n\treturn title;\n\nend", "def cleanTitle(str)\n str.nil? and return str\n r = Sanitize.clean(str).strip\n str.empty? and return str\n r = (r[0].match(/[^\\w]/)) ? r[1..-1].strip : r\n r.sub(/^(The|A|An) /i, '').capitalize\nend", "def cleanup_title(line)\n\ttitle = line.gsub(/.*>/, '') #strip everything in front of song title\n\ttitle.gsub!(/\\(.*|\\[.*|\\{.*|\\\\.*|\\/.*|\\_.*|\\-.*|\\:.*|\\\".*|\\`.*|\\+.*|\\=.*|\\*.*|feat\\..*/, \"\") #Remove rest of title following given characters\n\ttitle.gsub!(/(\\?|\\¿|\\!|\\¡|\\.|\\;|\\&|\\@|\\%|\\#|\\|)*/, '') #remove special characters\n\ttitle = title.downcase\n\ttitle.gsub!(/\\b(and|an|a|by|for|from|in|of|on|or|out|the|to|with)*\\b/, '') #remove stop words\n\ttitle.gsub!(/\\s\\s+/, ' ') #add whitespace between words\n\treturn title\nend", "def trim_whitespace; end", "def regulate_title\n self.title = self.title.strip\n self.title.downcase!\n end", "def trim_title(ttl)\n if ttl\n unless @site.ttlcut.blank?\n re = /#{@site.ttlcut}/\n if md = re.match(ttl)\n ttl = md[1] || ttl.sub(re, '')\n end\n end\n ttl.gsub(/\\s+/, ' ').strip\n end\n end", "def title_blank?\n self.title.blank?\n end", "def normalize_titles\n normalized_rt_title\n normalized_tz_title\n self\n end", "def clean_title(title)\n title.gsub(/[\\#=>\\d]|Papers We Love|PWL/, '').sub(/[-{1}]/, '').sub(/\\(part \\d?( of \\d?)?\\)/i, '').strip\nend", "def cleanup_title(single_line)\n\tif single_line =~ /[^>]*$/ #Starts at the end and finds the first > symbol and matches everything before it (the song title), credit goes to Jonah for reminding me that #{$&} exists\n title = \"#{$&}\"\n end\n\t#Thank you Isaac for telling me to use gsub instead of what I did above\n\ttitle.gsub!(/[\\(|\\[|\\{|\\\\|\\/|_|\\-|\\:|\\\"|\\`|\\+|\\{|\\*].*$/,\"\") #Replaces everything after the first instance of ( [ { \\ / _ - : \" ` + = *\n\ttitle.gsub!(/feat\\..*/) #removes everything after feat.\n\ttitle.gsub!(/[\\?|\\¿|\\!|\\¡|\\.|\\;|\\&|\\@|\\%|\\#|\\|]/,\"\") #removes all punctuation\n\tif title =~ /[^\\w\\s']/ #ignores songs that contain non-Eng\n\t\ttitle = nil\n\tend\n\tif title != nil\n\t\ttitle.downcase!\n\t\t#Stop words implementation\n\t\ttitle.gsub!(/is\\s|a\\s|ab\\s|and\\s|by\\s|for\\s|from\\s|in\\s|of\\s|on\\s|or\\s|out\\s|the\\s|to\\s|with\\s/,\"\")\n\t\treturn title\n\tend\nend", "def title?\n [email protected]_s.empty?\n end", "def evaporate\n self.gsub(/\\s/, '')\n end", "def cleanup_title(string)\n\ttitle = \"\"\n\t#looking for the third <SEP> by looking for the <SEP> pattern 3 times, each time setting the new title to everything to the right of the pattern.\n\t#this effectively extracts just the song title from the line\n\tsep_pattern = /<SEP>/\n\tif string =~ sep_pattern\n\t\ttitle = \"#{$'}\"\n\tend\n\tif title =~ sep_pattern\n\t\ttitle = \"#{$'}\"\n\tend\n\tif title =~ sep_pattern\n\t\ttitle = \"#{$'}\"\n\tend\n\n\t#cleanup said title part 2\n\t#pat1 are regular expressions identifying superflous text as stated in the instructions\n\tpart2 = /[(\\[\\{\\/:\"`+\\-_=*\\\\]|feat./\n\t#if the title contains any superfluous text, we just want whatever comes before said text using: (#{$`})\n\tif title =~ part2\n\t\ttitle = \"#{$`}\"\n\tend\n\n\t#eliminate characters part 3\n\t#finding and deleting the following punctuation: ? ¿ ! ¡ . ; & @ % # |\n\tpunctuation = /[?¿!¡.;&@%#|]/\n\tif title =~ punctuation\n\t\ttitle.gsub!(punctuation, \"\") #replace with empty string to remove\n\tend\n\n\t#set to lower case part 5\n\ttitle.downcase!\n\treturn title\nend", "def test_feed_title2_sanitize\n##\n# todo:\n## strip all tags from title2\n## limit to 255 chars\n## e.g. title2 such as this exist\n\n title2_in = %Q{This is a low-traffic announce-only list for people interested in hearing news about Polymer (<a href=\"http://polymer-project.org\">http://polymer-project.org</a>). The higher-traffic mailing list for all kinds of discussion is <a href=\"https://groups.google.com/group/polymer-dev\">https://groups.google.com/group/polymer-dev</a>}\n title2_out = %Q{This is a low-traffic announce-only list for people interested in hearing news about Polymer (http://polymer-project.org). The higher-traffic mailing list for all kinds of discussion is https://groups.google.com/group/polymer-dev}\n\n assert_equal title2_out, strip_tags( title2_in )\n assert_equal 229, strip_tags( title2_in )[0...255].length\n end", "def normalized_tz_title\n return self[:normalized_tz_title] if attribute_present?(:normalized_tz_title) or !attribute_present?(:tz_title)\n \n title_words = self.tz_title\n \n require 'cgi'\n title_words = CGI::unescapeHTML(title_words) # convert &quot; etc to regular characters\n title_words = ActionController::Base.helpers.strip_tags(title_words) # remove <b> tages etc\n\n # Lowercase, strip punctuation\n title_words = Movie::normalize_words(title_words)\n \n # Remove junk words. Do this after stripping html tags\n title_words = title_words.split(/\\s+/)\n title_words.delete_if { |word| Movie::JUNK_WORDS.include?(word) } \n title_words = title_words.join(' ')\n \n return self[:normalized_tz_title] = title_words\n end", "def strip_blanks!\n @content.reject! { |item| item[:type] == :blank }\n end", "def scrub_titles(text)\n \n # We don't want brackets in our JSON array, so we'll change them to parens\n text.gsub!(\"[\",\"(\")\n text.gsub!(\"]\",\")\")\n \n # And let's get rid of unicode characters, too...\n text = text.chars.normalize(:kd).gsub(/[^\\x00-\\x7F]/n,'').to_s\n \n # And just avoid double quotes for displaying titles.\n text.gsub!(\"\\\"\",\"\\'\")\n \n return text\n end", "def title_with_page_title_check\n return @page.title if @page && [email protected]?\n title_without_page_title_check\n end", "def normalize\n self.clean_extra_spaces.split.map{|w| w.size>2 ? w.capitalize : w.downcase}.join(' ')\n end", "def truncate\n title.chomp.slice(0...(width - 4))\n end", "def deny_reserved_titles\n if in_root_folder? && !PageHub.resource_title_available?(self.title)\n errors.add :pretty_title, \"That title is reserved for internal usage.\"\n return false\n end\n end", "def auto_trim?; end", "def title\n alternate_title.blank? ? course_titles(\" / \") : alternate_title\n end", "def title\n Sanitize.clean(name).strip\n end", "def title?\n !title.nil? && !title.empty?\n end", "def title?\n !title.nil? && !title.empty?\n end", "def cleanCategoryTitle string\n string.strip.upcase\n end", "def car_title(title_text,model_text)\n\ttitle = title_text.strip!\n\ttitle = title.gsub(model_text, \"\")\n\treturn title\nend", "def extract_full_title\n site_title = extract(:site) || \"\"\n title = extract_title\n separator = extract_separator\n reverse = extract(:reverse) == true\n\n TextNormalizer.normalize_title(site_title, title, separator, reverse)\n end", "def full_title(page_title)\n title = base_title\n\n Array(page_title).each do |var|\n title << (' | ' + var) unless var.empty? \n end\n\n title\n end", "def strip_side_space!\n replace self.gsub(/^\\s+/, \"\").gsub(/\\s+$/, $/)\n end", "def apply_updates_title(title)\n return if title.to_s.empty?\n\n wrap_length = MAX_LINE_LENGTH - WORD_WRAP_INDENT\n\n @control_string.sub!(\n /title\\s+(((\").*?(?<!\\\\)\")|((').*?(?<!\\\\)')|((%q{).*?(?<!\\\\)[}])|(nil))\\n/m,\n \"title %q{#{title}}\".word_wrap(wrap_length).indent(WORD_WRAP_INDENT)\n )\n end", "def sanitize_content\n self.title = helpers.sanitize(self.title)\n self.user_name = helpers.sanitize(self.user_name)\n end", "def capitalize_title\n self.title.capitalize! if title\n end", "def no_auto_trim!; end", "def post_title\n if !self.title.nil?\n phrases = [\"Won\\'t Believe\", \"Secret\", \"Top\", \"Guess\"]\n if !phrases.any? {|phrase| self.title.include?(phrase)}\n errors.add(:title, \"Not enough!\")\n end\n else\n errors.add(:title, \"Not enough!\")\n end\n end", "def cleanup_page_titles\n pages.each do |p|\n new_title = p.title.sub(/^page\\s*/i, '').strip\n p.title = new_title\n end\n\n pages.each do |p|\n if p.title.empty?\n if p.image_filename # we need to be able to make the assumption this exists\n p.title = file_name(p.image_filename)\n end\n end\n end\n\n seen = {}\n sequence = 1\n problems = []\n pages.each do |p|\n if p.title.empty?\n p.title = sequence.to_s\n end\n if seen[p.title]\n p.title += \" (#{sequence})\"\n problems.push p.title\n end\n seen[p.title] = true\n sequence += 1\n end\n\n if not problems.empty?\n warning \"Some page labels were not unique; the sequence number was appended: '\" + problems.join(\"', '\") + \"'.\"\n end\n end", "def auto_trim!; end", "def title_with_page_title_check\n return @content_node.title if @content_node && !@content_node.title.blank?\n title_without_page_title_check\n end", "def trim_whitespace=(_arg0); end", "def strip\n lambda do |rec, acc|\n acc.collect! do |v|\n # unicode whitespace class aware\n v.sub(/\\A[[:space:]]+/,'').sub(/[[:space:]]+\\Z/, '')\n end\n end\n end", "def bypass_title_validation?\n bypass_title_validation\n end", "def format_title_description\n if description.present? && title.present?\n self.description = description.strip.capitalize\n self.title = title.strip.capitalize\n end\n end", "def titleless_content\n parse if fresh?\n @content.sub(/h\\d\\..+/, '')\n end", "def format_title_description\n if description.present? && title.present?\n self.description = description.strip.capitalize\n self.title = title.strip.capitalize\n end\n end", "def format_title_description\n if description.present? && title.present?\n self.description = description.strip.capitalize\n self.title = title.strip.capitalize\n end\n end", "def truncate_attributes\n self.title = truncate(title, length: 1000)\n self.site_name = truncate(site_name, length: 200)\n self\n end", "def remove_whitespace\n self.time = self.time.strip\n self.description = self.description.strip\n self.venue = self.venue.strip.downcase\n self.location = self.location.strip.downcase\n end", "def slugged?\n !self.include?(\" \")\n end", "def delete_illegal_chars\n self.title.delete!(\"~\")\n end", "def accurate_title\n nil\n end", "def title\n description.truncate(30, :separator =>' ')\n end", "def meta_title\n\t\tread_attribute('title').gsub(/<\\/?[^>]*>/, \"\")\n\tend", "def validate_title(item)\n error(msg: 'Title may not be blank', item: __method__.to_s) if blank?(item)\n end", "def is_title_case\n if title.split.any?{|w|w[0].upcase != w[0]}\n errors.add(:title, \"Title must be in title case\")\n end\n end", "def cut_title\n self.title.sub(RUBY_FORMAT, '')\n# self.title.sub!(RHTML_FORMAT, '')\n# self.title.sub!(RJS_FORMAT, '')\n end", "def title\n @title ||= self.content.split(@@title_separator).first unless self.content.nil?\n end", "def remove_whitespace_from_list_items!\n @document.tree.search('li span').each { |span| span.inner_html.strip! }\n end", "def strip_attributes\n self.title = self.title.try :strip\n self.url = self.url.try :strip\n self.author = self.author.try :strip\n self.content = self.content.try :strip\n self.summary = self.summary.try :strip\n self.guid = self.guid.try :strip\n end", "def title_valid(title)\n if !title.empty?\n self.title = title\n return true\n else\n return false\n end\n end", "def sanitize_title(title, fallback_title = '', context = 'save' )\n raw_title = title\n\n title = remove_accents( title ) if 'save' == context\n\n # Filters a sanitized title string.\n #\n # @param string $title Sanitized title.\n # @param string $raw_title The title prior to sanitization.\n # @param string $context The context for which the title is being sanitized.\n title = apply_filters( 'sanitize_title', title, raw_title, context )\n\n title = fallback_title if ( '' == title || false == title )\n\n title\n end", "def title\n # strip some non-breaking space at the end\n @title ||= details.at(\"h1[itemprop='name']\").children.first.text.strip.gsub(' ', '') rescue nil\n end", "def doNotIgnoreMissingTitles()\n merge(doNotIgnoreMissingTitles: 'true')\n end", "def sanitize_children(children)\n children.reject{|node| node.name == \"text\" && node.content.strip.empty?}\n end", "def titled?\n title.present? && (title != DEFAULT_TITLE)\n end", "def check_title\n if title.to_s == '' && audio_file.present?\n str = File.basename(audio_file_url).gsub(/[_]/, ' ') \n self.title = str.gsub(/[.mp3]/, '')\n self.save\n end\n end", "def titleize(title)\n\n result = []\n\n excluded = ['a', 'and', 'of', 'over', 'the']\n arr = title.split\n\n arr.each_index {|i|\n if excluded.include?(arr[i]) && i != 0\n result << arr[i]\n else\n result << arr[i].capitalize\n end\n }\n\n result.join(\" \")\nend" ]
[ "0.7734926", "0.7734926", "0.7708592", "0.73002577", "0.7275279", "0.7145224", "0.7083284", "0.70476735", "0.6973481", "0.68507135", "0.67134714", "0.669988", "0.6695074", "0.6672396", "0.6553552", "0.65170956", "0.64457536", "0.6415425", "0.64105994", "0.6408349", "0.6393755", "0.63535607", "0.63455164", "0.6339523", "0.6329753", "0.6313712", "0.6288359", "0.62724257", "0.6227592", "0.62265855", "0.61935115", "0.6184513", "0.6173703", "0.61659896", "0.61572593", "0.61441994", "0.61259735", "0.6108577", "0.61081225", "0.60956967", "0.6073124", "0.6066984", "0.6055772", "0.60545194", "0.60409087", "0.6006807", "0.59342456", "0.5931548", "0.59287256", "0.5927853", "0.5882858", "0.5862814", "0.5847909", "0.584607", "0.58449936", "0.58378476", "0.5832429", "0.5820004", "0.58032644", "0.58032644", "0.5795478", "0.57773644", "0.5766144", "0.5753127", "0.5747551", "0.5734683", "0.573322", "0.57330835", "0.5729904", "0.5724547", "0.57130253", "0.57010233", "0.570098", "0.56997126", "0.56979936", "0.5683376", "0.5676956", "0.56765115", "0.5675485", "0.5675485", "0.5667082", "0.5663548", "0.5657139", "0.5653163", "0.563289", "0.5632816", "0.562366", "0.56203693", "0.5615943", "0.5615227", "0.5611978", "0.5611298", "0.5608711", "0.56006587", "0.559679", "0.55895925", "0.55883175", "0.55756783", "0.55746377", "0.5574443", "0.5573728" ]
0.0
-1
Save all text assets, including the `combined_page_text`, and the text of each page individually, to the asset store.
def upload_text_assets(pages, access) asset_store.save_full_text(self, access) pages.each do |page| asset_store.save_page_text(self, page.page_number, page.text, access) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save\n apply\n $scripts=[]\n for i in @pages\n next if i.nil?\n $scripts<<[i.stoppoints,i.name,Zlib::Deflate.deflate(i.script)]\n end\n GC.start\n end", "def save_page page\n return unless page.text?\n\n path = page_file page.full_name\n\n FileUtils.mkdir_p File.dirname(path) unless @dry_run\n\n cache[:pages] ||= []\n cache[:pages] << page.full_name\n\n return if @dry_run\n\n File.open path, 'wb' do |io|\n Marshal.dump page, io\n end\n end", "def save_pages\n path = SAVED_PAGES_DIR\n\n # prepare dir\n FileUtils.mkdir(path) unless File.directory?(path)\n\n # prepare filename\n url = @page.current_url\n url = url.sub(/#{Regexp.quote(Testing.base_url)}\\//, '') # remove base url\n url = url.gsub(/\\//, '_') # change / to _\n url = 'homepage' if url.empty? # that's homepage left\n filename = \"#{path}/#{url}.html\"\n\n # save page\n File.open(filename, 'w') { |f| f.write(@page.html) }\n puts \"Saved page to #{filename}\"\n end", "def get_text\n outarr = Array.new\n @data.each do |item|\n paths = item[\"path\"]\n item[\"text\"] = \"\"\n \n # OCR all files and save\n paths.each { |path| item[\"text\"] += ocr_file(\"../docs/\"+path)} if paths\n outarr.push(item)\n end\n @data = outarr\n end", "def write_page_assets(site_dir)\n end", "def combined_page_text\n self.pages.order('page_number asc').pluck(:text).join('')\n end", "def index\n @static_texts = StaticText.all\n end", "def save_locally(dir)\n FileUtils.mkdir_p(dir) unless File.exists? dir\n \n # remove HTML BASE tag if it exists\n @contents.xpath('//base').each { |t| t.remove }\n # remove head tag\n @contents.xpath('//head').each { |t| t.remove }\n # remove link tags\n @contents.xpath('//link').each { |t| t.remove }\n # remove script tags\n @contents.xpath('//script').each { |t| t.remove }\n # remove comments\n @contents.xpath('//comment()').each { |t| t.remove }\n # remove mediawiki meta tag\n @contents.xpath('//meta').each { |t| t.remove if t['name'] == \"generator\" }\n # remove sitesub h3 tag\n @contents.xpath('//h3').each { |t| t.remove if t['id'] == \"siteSub\" }\n\n # get lastmod/viewcount values\n @contents.xpath('//li').each do |t|\n if t['id'] == \"lastmod\"\n @lastmod = t.text.strip\n end\n if t['id'] == \"viewcount\"\n @viewcount = t.text.strip\n end\n end\n\n # remove unneeded divs\n @contents.xpath('//div').each do |t|\n t.remove if t['id'] == \"column-one\"\n t.remove if t['id'] == \"footer\"\n t.remove if t['id'] == \"catlinks\"\n t.remove if t['id'] == \"contentSub\"\n t.remove if t['id'] == \"jump-to-nav\"\n t.remove if t['class'] == \"printfooter\"\n t.remove if t['class'] == \"visualClear\"\n end\n\n if @main_page == true\n save_path = File.join(dir, \"index\")\n title = 'Dublin Core Metadata Initiative Media-Wiki Archive'\n else\n save_path = File.join(dir, File.basename(uri.to_s))\n title = File.basename(uri.to_s).gsub(\"_\", \" \")\n end\n save_path += '.html' if save_path !~ /\\.((html?)|(txt))$/\n File.open(save_path, 'w') { |f| f.write(\"<!DOCTYPE html>\\n<html>\\n<head>\\n<meta http-equiv=\\\"Content-Type\\\" content=\\\"text/html; charset=UTF-8\\\">\\n<meta http-equiv=\\\"Content-Language\\\" content=\\\"en-us\\\">\\n<title>#{title}</title>\\n</head>\\n<body>\\n<p><b>This is an archived MediaWiki page.</b><br />#{@lastmod}<br />#{@viewcount}</p>\\n#{@contents.xpath('//div[@id=\"bodyContent\"]').to_html}\\n</body>\\n</html>\") }\n # File.open(save_path, 'w') { |f| f.write(\"---\\nlayout: page\\ntitle: #{title}\\n---\\n\\n#{@contents.xpath('//div[@id=\"bodyContent\"]').to_html}\") }\n end", "def save_adword_urls(page)\n\t\tsave_adword_urls_right(page) \n\t\tsave_adword_urls_top(page)\n\tend", "def export\n @pages.each_with_index do |page, i|\n puts \"Export:\"\n=begin\n #page.load_original\n ScanEnhancer::profile(\"fill_invert\") {\n page.content.fill_invert\n }\n ScanEnhancer::profile(\"Deskew\") {\n page.deskew!\n }\n ScanEnhancer::profile(\"threshold\") {\n page.threshold!\n }\n=end\n ScanEnhancer::profile(\"export\") {\n page.export(\"page-%04d.tif\" % [@page_number_start + @page_number_step*i])\n #page.export_data(\"page-%04d.tif\" % [@page_number_start + @page_number_step*i])\n }\n page.free_data!\n puts \"\"\n end\n end", "def create_multiple_text_assets(client, customer_id, texts)\n operations = texts.map do |text|\n client.operation.mutate do |m|\n m.asset_operation = client.operation.create_resource.asset do |asset|\n asset.text_asset = client.resource.text_asset do |text_asset|\n text_asset.text = text\n end\n end\n end\n end\n\n # Send the operations in a single Mutate request.\n response = client.service.google_ads.mutate(\n customer_id: customer_id,\n mutate_operations: operations,\n )\n\n asset_resource_names = []\n response.mutate_operation_responses.each do |result|\n if result.asset_result\n asset_resource_names.append(result.asset_result.resource_name)\n end\n end\n print_response_details(response)\n asset_resource_names\nend", "def extract_pages_to_text\n reader.pages.each do |page|\n raw_extracted_pages << page.text.split(\"\\n\")\n end\n end", "def save_all_to_files\n\t\tsave_hash_to_file($searched, $progDir+'searched.txt')\n\t\tsave_hash_to_file($downloaded, $progDir+'downloaded.txt')\n\t\tsave_array_to_file($toSearch, $progDir+'toSearch.txt')\n\t\tsave_array_to_file($toDownload, $progDir+'toDownload.txt')\n\t\t@pgCount=$toSearch.size\n\trescue => e\n\t\t$error.save_error_to_file(__method__, e, $specialErrorTxt)\n\tend", "def create_text\n $game_text = {}\n text = {}\n key = \"\"\n SES::ExternalText::Languages.each do |l|\n $game_text.clear\n SES::ExternalText.each_file(\"Data/Text/#{l}\") do |f|\n File.open(f, \"r:BOM|UTF-8\") do |file|\n file.readlines.each_with_index do |v,i|\n next if v =~ /(^\\s*(#|\\/\\/).*|^\\s*$)/\n SES::ExternalText::Tags.each_pair do |k,p|\n if v =~ k\n p.call(*$~[1..-1])\n v.clear\n end\n end\n if SES::ExternalText.key && !v.empty?\n v = \"\\n#{v}\" unless $game_text[SES::ExternalText.key][1].empty?\n $game_text[SES::ExternalText.key][1] << v\n end\n end\n end\n end\n File.open(\"Data/#{l}.rvdata2\", \"w\") do |file|\n Marshal.dump($game_text, file)\n end\n end\n end", "def write_all\n if cached_write?\n then write_cached_assets else write_assets\n end\n end", "def write_file\n\n File.open(\"rebuild.html\", \"w\") do |file|\n @write_array.each do |tags_and_text|\n file.write tags_and_text\n end\n end\n\n end", "def save\n load_cache\n\n all_classes_and_modules.each do |klass|\n save_class klass\n\n klass.each_method do |method|\n save_method klass, method\n end\n\n klass.each_attribute do |attribute|\n save_method klass, attribute\n end\n end\n\n all_files.each do |file|\n save_page file\n end\n\n save_cache\n end", "def texts=(texts); end", "def texts=(texts); end", "def index\n @site_texts = SiteText.all\n end", "def index\n @text_contents = TextContent.all\n end", "def content_fulltext(page_xml, paper_title, page_title)\n page_path = Pathname.new(@source)\n basename = page_path.basename.to_s.gsub('.xml', '')\n full_text_path =\n File.join(page_path.parent, basename, paper_title, page_title)\n full_text_file = \"#{full_text_path}/fulltext.txt\"\n FileUtils.mkdir_p full_text_path\n page_text = page_xml.xpath('pagetext').map(&:content).first.to_s\n File.open(full_text_file, \"w\") { |f| f.write(page_text) }\n full_text_file.gsub Pathname.pwd.to_s + \"/\", \"\"\n end", "def texts_attributes=(texts_attributes)\n texts_attributes.each do |text_title, attributes|\n text(text_title).update_attributes(attributes)\n end\n end", "def save_content(title, content)\n File.open(\"pages/#{title}.txt\", \"w\") do |file|\n file.print(content)\n end\nend", "def index\n @texts = Text.order(:id).page(params[:page])\n end", "def save_text\n @lexemes << @lexeme\n end", "def save_information(keyword, page)\n\t\t\tkeyword.save_adword_urls(page)\n\t\t\tkeyword.save_nonadword_urls(page)\n \tend", "def save\n all_files.each{ |file| parse_and_save(file) }\n end", "def save_state file=nil\n App.out.write_text_files file\nend", "def index\n @texts = Text.all\n end", "def index\n @texts = Text.all\n end", "def write\n if root?\n index_file = File.join(page_dir, 'index.html')\n notice \"Writing top level index file at #{index_file}\"\n File.open(index_file, 'w') {|f| f.puts content}\n else\n # First create the index page\n index_file = File.join(page_dir, name + '.html')\n notice \"Writing index file for directory #{path} at #{index_file}\"\n File.open(index_file, 'w') {|f| f.puts content}\n\n # Create a directory to contain index pages for any child directories\n Dir.mkdir(File.join(page_dir, name))\n end\n dirs.sort.each{|dir| dir.write}\n\n # Determine if the page assets directory is necessary, to avoid clutter\n writing_page_assets = true\n begin\n # Detect whether the write_page_assets method is overridden\n # In case this explodes in 1.8.6 we'll always create the directory\n writing_page_assets = renderer.class.instance_method(:write_page_assets).owner != DirRenderer\n rescue\n end\n\n # The renderer knows what assets are linked to and what needs to be available\n # to display the page properly\n if writing_page_assets\n Dir.mkdir(page_assets_dir)\n renderer.write_page_assets(self)\n end\n end", "def write_pages\n pages = Dir[\"#{source_path}/*.html\"].each do |p_name|\n page = Page.new(source_path, File.basename(p_name))\n # TODO allow user to specify which layouts a page should use \n page.render(site_payload, layouts.select{|x| x.name == \"application.html\"})\n page.write(destination_path)\n end\n end", "def write\n self.theme_assets_by_priority.each do |asset|\n self.output_resource_op asset\n\n self.open_file(self.target_asset_path(asset), 'wb') do |file|\n content = asset.content\n\n if asset.stylesheet_or_javascript?\n self.replace_asset_urls(content)\n end\n\n file.write(content)\n end\n\n self.output_resource_op_status asset\n end\n end", "def write_page_text(text = @pagetext[@page], i = 0, newline_boundary = '',\n mode = :bestiary, text_width = :contents_width, l_x = 0)\n if @enemy && mode == :bestiary then draw_parameters\n else super(text, i, newline_boundary, mode, text_width, l_x) end\n end", "def save_content(title, content)\n\tFile.open(\"pages/#{title}.txt\" , \"w\") do |file|\n\t file.print(content)\n end \t\t\nend", "def save filename\n File.open(filename, 'w') { |file| @translated.each {|value| file.write(\"#{value}\") } } \n end", "def files_to_page\n insert_to_page('div', html)\n insert_to_page('script', js, false)\n insert_to_page('style', style, false)\n end", "def load_default_text_assets_regions\n returning OpenStruct.new do |text_asset|\n text_asset.index = Radiant::AdminUI::RegionSet.new do |index|\n index.top.concat %w{help_text}\n end\n text_asset.edit = Radiant::AdminUI::RegionSet.new do |edit|\n edit.main.concat %w{edit_header edit_form}\n edit.form.concat %w{edit_title edit_content edit_timestamp}\n edit.content_bottom.concat %w{edit_filter}\n edit.form_bottom.concat %w{edit_buttons}\n end\n text_asset.new = text_asset.edit\n end\n end", "def convert!\n merged_contents = []\n @files.each do |file|\n markup = Markup.new file, @remove_front_matter\n html = convert_image_urls markup.render, file.filename\n if @merge\n html = \"<div class=\\\"page-break\\\"></div>#{html}\" unless merged_contents.empty?\n merged_contents << html\n else\n output_pdf(html, file)\n end\n end\n\n unless merged_contents.empty?\n html = merged_contents.join\n output_pdf(html, nil)\n end\n end", "def saveTextOutput(iter, tosave, width, height, divisions)\n\tfileName = \"output\" + iter.to_s + \".txt\"\n\tif not File.exists?(fileName) \n\t\tsaveText = 'Generated area of size ' + width.to_s + ' x ' + height.to_s + ' with ' + divisions.to_s + \" divisions.\\n\"\n\t\tsaveFile = File.new(fileName, \"w\")\n\t\tfor y in 0..height \n\t\t\tfor x in 0..width \n\t\t\t\tsaveText = saveText + tosave[x][y]\n\t\t\tend \n\t\t\tsaveText = saveText + \"\\n\"\n\t\tend\n\t\tsaveFile.syswrite(saveText)\n\telse \n\t\tsaveTextOutput(iter + 1, tosave, width, height, divisions)\n\tend\nend", "def run\n\t\t\t\tif save_file\n\t\t\t\t\tdoc = Nokogiri::HTML(open(@file,\"r\"))\n\t\t\t\t\tparse_page(doc)\n\t\t\t\t\tflush_page\n\t\t\t save_words\n\t\t\t end\n\t\t\tend", "def sprint_process_text(doc)\n # there is at least one <pre> with MMS text if text has been included by\n # the user. (note) we'll have to verify that if they attach multiple texts \n # to the MMS then Sprint stacks it up in multiple <pre>'s. The only <pre> \n # tag in the document is for text from the user.\n doc.search(\"/html/body//pre\").each do |pre|\n type = 'text/plain'\n text = pre.inner_html.strip\n next if text.empty?\n type, text = transform_text(type, text)\n type, file = sprint_write_file(type, text.strip)\n add_file(type, file) unless type.nil? || file.nil?\n end\n end", "def to_text\n ocr_files.map do |resource|\n url = full_text_url(resource['id'])\n content = full_text_content(url)\n if xml_ocr_types.include?(resource['mimetype'])\n alto_xml_string_content(content)\n elsif html_ocr_types.include?(resource['mimetype'])\n hocr_string_content(content)\n else # plain text\n content.scrub.encode('UTF-8', invalid: :replace, undef: :replace, replace: '?').gsub(/\\s+/, ' ')\n end\n end\n end", "def save_nonadword_urls(page)\n\t\tnonadword_urls(page).each do |url|\n\t\t\tcreate_nonadword_url(url, \"center\")\n\t\tend\n\tend", "def load_default_text_asset_regions\n returning OpenStruct.new do |text_asset|\n text_asset.edit = Radiant::AdminUI::RegionSet.new do |edit|\n edit.main.concat %w{edit_header edit_form}\n edit.form.concat %w{edit_title edit_content edit_timestamp}\n edit.content_bottom.concat %w{edit_filter}\n edit.form_bottom.concat %w{edit_buttons}\n end\n end\n end", "def write_to_file file, *text\n text.flatten!\n\n File.open(File.expand_path(file), 'a+') do |file|\n full_text = (text * \"\\n\") + \"\\n\"\n\n unless file.read.include? full_text\n file.write full_text\n end\n end\n end", "def save_page(file_name = nil)\r\n file_name ||= Time.now.strftime(\"%Y%m%d%H%M%S\") + \".html\"\r\n puts \"about to save page: #{File.expand_path(file_name)}\" if $DEBUG\r\n File.open(file_name, \"w\").puts page_source\r\n end", "def save( directory )\n File.open( \"parsed_data/#{directory}.yaml\", 'w' ) do |f|\n f.write( @pages.to_yaml )\n end\n end", "def text_page_params\n params.require(:text_page).permit(:title, :contents, :load_from_google, :file_id, :google_account_id)\n end", "def index\n @text_files = TextFile.all\n end", "def write_page(page, path = '')\n self.output_resource_op page\n\n # Note: we assume the current locale is the default one\n page.translated_in.each do |locale|\n default_locale = locale.to_sym == self.mounting_point.default_locale.to_sym\n\n # we do not need the localized version of the filepath\n filepath = page.fullpath.dasherize\n\n Locomotive::Mounter.with_locale(locale) do\n # we assume the filepath is already localized\n self.write_page_to_fs(page, filepath, default_locale ? nil : locale)\n end\n end\n\n self.output_resource_op_status page\n\n # also write the nested pages\n (page.children || []).each do |child|\n self.write_page(child, page.depth == 0 ? '' : page.slug)\n end\n end", "def all_watermark_texts\n texts = []\n Sketchup.active_model.entities.each { |e|\n texts << e if e.is_a?(Sketchup::Text) && e.get_attribute('MSPhysics', 'Name') != nil\n }\n texts\n end", "def all_text\r\n @texts.inject(\"\") {|r, text| r += text + \"\\n\" }\r\n end", "def index\n @text_on_pdfs = TextOnPdf.all\n end", "def index\n @text_memories = TextMemory.all\n end", "def index\n @text_memories = TextMemory.all\n end", "def add_srt_data(text)\n language = Language.detect(text)\n text.gsub(/\\r\\n/, \"\\n\").split(/\\n\\n/).each do |block|\n index, times, text = block.split(/\\n/, 3)\n start_time, end_time = parse_srt_times(times)\n # TODO: Is this the best way to add records to an unsaved has_many?\n self.subtitles <<\n Subtitle.new(playable_media: self, language: language,\n start_time: start_time, end_time: end_time,\n text: text.chomp)\n end\n end", "def save(path)\n File.open(path, \"w\") { |outfile| outfile.print self.render }\n end", "def save_page(page, name)\n f = File.new(name,'w')\n f.puts page\n f.close\n end", "def index\n @contents = Content.site_text_items(@site.id)\n end", "def savePage(fileName = \"testPage.yml\")\n\t\t#File.open(\"file.rb\") if File::exists?( \"file.rb\" )\n\t\tfile = File.new(@@pageDirectory + fileName, \"w+\")\n\t\tserializedPage = YAML::dump(@currentHTMLPage)\n\t\tfile.puts(serializedPage)\n\t\tfile.close\n\t\t#puts(\"saved page: #{fileName}\")\n\tend", "def render_txt\n report = report_for_rendering\n filename = filename_timestamp(report.title)\n disable_client_cache\n send_data(report.to_text, :filename => \"#{filename}.txt\")\n end", "def sync(save=true)\n counts = {}\n ArticleText.find_by_sql(\"SELECT article_id, text FROM article_texts WHERE text LIKE '%#{name}%'\").each { |at|\n counts[at.article_id.to_i] = at.text.scan(/#{name}/).size\n }\n # replace existing Tags\n self.tags = []\n counts.each { |t, count|\n self.tags.build({:count => count, :article_id => t, :term_id=>id})\n }\n self.save if save\n self\n end", "def process_plain_text!( backfill = false, ocr = false )\n if backfill\n %x( mkdir #{folder} )\n unless $?.exitstatus == 0\n Rails.logger.error \"Failed at making directory.\"\n end\n n = PDF::Reader.new(file_path).page_count\n else\n n = PDF::Reader.new(file_path_opt).page_count\n end\n for i in 1..n\n if ocr\n # TODO: This will generate image versions so we need to clean them later\n %x( pdftoppm #{file_path_opt} -gray -r 300 -f #{i} -l #{i} -singlefile '#{folder}/#{i}_out' )\n unless $?.exitstatus == 0\n Rails.logger.error \"Failed at pdf to ppm. Command: pdftoppm #{file_path_opt} -gray -r 300 -f #{i} -l #{i} -singlefile '#{folder}/#{i}_out'\"\n return false\n end\n Rails.logger.info 'Out: ' + i.to_s + '_out.pgm'\n file_path_txt_stripped = file_path_txt.gsub('.txt','')\n %x( tesseract '#{folder}/#{i}_out.pgm' '#{folder}/#{i}_#{file_path_txt_stripped}' )\n unless $?.exitstatus == 0\n Rails.logger.error \"Failed at OCR. Command: tesseract '#{folder}/#{i}_out.pgm' '#{folder}/#{i}_#{file_path_txt_stripped}'\"\n return false\n end\n Rails.logger.info 'Out: ' + folder + '/' + i.to_s + '_' + file_path_txt\n # TODO: Clean pgm's here\n file_to_delete = folder + '/' + i.to_s + '_out.pgm'\n File.delete( file_to_delete )\n else\n %x( pdftotext -f #{i} -l #{i} #{file_path_opt} '#{folder}/#{i}_#{file_path_txt}' )\n unless $?.exitstatus == 0\n Rails.logger.error \"Failed at processing plain text. Command: pdftotext #{file_path} '#{folder}/#{file_path_txt}'\"\n return false\n end\n end\n end\n unless merge_txt_pages!(n)\n Rails.logger.error \"Merging txt files failed.\"\n return false\n end\n %x( cp #{folder}/#{file_path_txt} ../../document_txt_cache )\n unless $?.exitstatus == 0\n Rails.logger.error \"Failed at copying to cache. Command: cp #{folder}/#{file_path_txt} ../../document_txt_cache\"\n return false\n else\n Rails.logger.info 'Processed plain text file'\n return true\n end\n end", "def ingest_pages\n @table_of_contents.unique_pages.each_with_index do |entry, index|\n label = entry ? Utils.xml_escape(entry.title) : \"Page #{index + 1}\"\n @component_objects.push ingest_page(entry.image_filename, label, index + 1)\n end\n\n if @manifest.embargo\n @component_objects.each do |pid|\n @drupal_db.add_embargo pid, @manifest.embargo['rangeName'], @manifest.embargo['endDate']\n end\n end\n end", "def render_pages(static_path)\n puts \" Rendering pages\"\n Page.all.each do |p|\n if p.published? && (body = p.render)\n dir, filename = p.url, \"index.html\"\n dir, filename = p.parent.url, p.slug if p.slug =~ /\\.[^.]+$/i # File with extension (e.g. styles.css)\n FileUtils.mkdir_p(File.join(static_path, dir))\n File.open(File.join(static_path, dir, filename), 'w') { |io| io.print(body) }\n else\n puts \" ! Not rendering #{p.id} - #{p.status.name} - #{p.url}\"\n end\n end\nend", "def save_page\n page = xml_page()\n AR.save_all_videos(page)\nend", "def save_adword_urls_right(page) \n\t\tadword_urls_right(page).each do |url|\n\t\t\tcreate_adword_url(url, \"right\")\n\t\tend\n\tend", "def index\n @all_textual_content = @card.textual_content\n end", "def extract_text\n # check if we have a filter\n return if FILTERS[self.content_type].nil?\n\n # Create temporary working directory directory\n FileUtils.mkdir_p(File.join(RAILS_ROOT, 'tmp', 'documents'))\n\n # Find path to convert script\n convert_script = File.join(RAILS_ROOT, 'script', FILTERS[self.content_type])\n\n # Get paths to temp in/out file\n temp_file_in = self.create_temp_file.path\n temp_file_out = File.join(RAILS_ROOT, 'tmp', 'documents',\"#{self.id}.txt\")\n\n # Convert\n if system \"#{convert_script} #{temp_file_in} #{temp_file_out}\"\n self.content = File.read(temp_file_out)\n File.unlink(temp_file_out)\n else\n self.content = \"NO CONTENT\"\n end\n self.save\n end", "def save\n save_to_file(@output_file, @contents)\n end", "def write_page\n contents = [people,projects,events].inject({}) { |x,y| x.merge(y) }\n File.open('index.html','w') do |f|\n f.write(@template.render(contents))\n end\n end", "def print_to_output(text)\n if Object.const_defined?('Shamus')\n asset = Shamus.current.current_step.add_inline_asset('.txt', Shamus::Cucumber::InlineAssets::RENDER_AS_TEXT)\n File.open(asset, 'w') { |f| f.puts(\"#{text}\") }\n else\n puts \"#{text}\"\n end\n end", "def index\n @copy_texts = CopyText.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @copy_texts }\n end\n end", "def save\n File.open(@path, \"w\") do |file|\n Psych.dump({version: VERSION}, file)\n doc = {}\n @stats.each_pair do |article_path, article_stat|\n doc[article_path] = {\n stat: article_stat,\n related: @related[article_path] || [],\n }\n end\n Psych.dump(doc, file)\n end\n end", "def save_to(path)\n File.open(path, \"w\") do |file|\n I18n.with_locale(meta.locale) do\n file << render\n end\n end\n end", "def post_process(pages)\n end", "def writeToFile(type, text)\n\t\t# get collection\n\t\tthings = @@db.collection(\"saves\")\n\t\t\n\t\t# get form name\n\t\tfrm = @@form\n\t\t\n\t\t# check if form variable is set\n\t\tif(!frm)\n\t\t\tfrm = \"N/A\"\n\t\tend\n\t\t\n\t\t# insert into document\n\t\tthings.insert(type => text, \"form\" => frm)\n\tend", "def index_pages\n debug_msg \" generating pages search index\"\n\n pages = @files.select do |file|\n file.text?\n end\n\n pages.each do |page|\n debug_msg \" #{page.page_name}\"\n record = page.search_record\n @index[:searchIndex] << search_string(record.shift)\n @index[:longSearchIndex] << ''\n record.shift\n @index[:info] << record\n end\n end", "def build_book_all_in_one_old_code_remove\r\n\r\nbook_text = <<EOS\r\n---\r\nlayout: book\r\ntitle: Contents\r\npermalink: /book.html\r\n---\r\n\r\nEOS\r\n\r\nbook_text += render_toc( inline: true )\r\n\r\n\r\n### generate pages for countries\r\n# note: use same order as table of contents\r\n\r\ncountry_count=0\r\n\r\nContinent.all.each do |continent|\r\n continent.countries.order(:title).each do |country|\r\n\r\n beers_count = country.beers.count\r\n breweries_count = country.breweries.count\r\n next if beers_count == 0 && breweries_count == 0\r\n \r\n country_count += 1\r\n puts \"build country page #{country.key}...\"\r\n country_text = render_country( country )\r\n\r\n book_text += <<EOS\r\n\r\n---------------------------------------\r\n\r\nEOS\r\n\r\n book_text += country_text\r\n end\r\nend\r\n\r\n\r\nFile.open( '_pages/book.md', 'w+') do |file|\r\n file.write book_text\r\nend\r\n\r\nend", "def save_files\n @law_h = [:law, :link, :section]\n @case_h = [:case, :link, :date]\n\n # Parse into hashes\n @single_matches = @single_matches-@double_matches\n case_hash = @double_matches.map{|i| {@case_h[0] => i[0], @case_h[1] => i[1], @case_h[2] => i[2]}}\n law_hash = @single_matches.map{|i| {@law_h[0] => i[0], @law_h[1] => i[1], @law_h[2] => i[2]}}\n \n # Write files\n write_files(case_hash, law_hash)\n end", "def get_script_data(page) \n\tputs \"#{Time.now} - Page #{page} getting scrapped... \"\n\n\t# Begin crawling\t\n\tpage_src \t= \"./temp/#{page}.html\"\n\tscript_src \t= \"temp/script-#{page}.txt\"\n\n\thtml = Nokogiri::HTML(open(page_src))\n\thtml.css(\"script\").each do |script|\n\n\t\tif /window._sharedData/.match(script.content) \n\t\t\tputs \"#{Time.now} - Matched script\"\n\n\t\t\topen(script_src, 'w') do |file|\n\t\t\t\tfile << script\n\t\t\tend\n\t\tend\n\tend\n\tputs \"#{Time.now} - Page #{page_src} > script saved.\"\n\tparse_script(script_src)\nend", "def save_to_file\n File.open(@output, 'w+') do |file|\n file.puts HEADER if @additional_html\n file.puts @data_for_output.join(\"\\n\")\n file.puts FOOTER if @additional_html\n end\n end", "def import_text_content\n self.text_content = self.to_text\n self.save\n\n # Reindex to elasticsearch\n self.reindex\n end", "def save\n generate_archive(generate_content_types, generate_rels, generate_document)\n end", "def possible_texts\n @possible_texts ||= (pages[0, 5] + pages[(page_count / 4)...(page_count / 2)]).sample(5)\n end", "def save\n receipt = File.new(@save_path, 'w')\n receipt.write(render)\n receipt.close\n end", "def index\n @text_managers = TextManager.all\n end", "def addtext(url)\n img = MiniMagick::Image.open(IMAGE_FILE)\n rows = split_text_into_rows(text)\n addrow(img, rows[0], POSITION_1)\n addrow(img, rows[1], POSITION_2)\n addrow(img, rows[2], POSITION_3)\n addrow(img, rows[3], POSITION_4)\n addrow(img, rows[4], POSITION_5)\n addrow(img, rows[5], POSITION_6)\n save_to_file(img, url)\n end", "def store_content(world, scenario)\n # Make sure the content directory exists.\n basedir = File.join(Dir.pwd, 'content')\n FileUtils.mkdir_p(basedir)\n\n # Store content. Note that not all drivers may support this.\n filename = File.join(basedir, base_filename(scenario))\n filename += '.txt'\n\n File.open(filename, 'w') do |file|\n file.write(world.driver.page_source)\n end\n end", "def save_to_file\n File.open(\"results/#{seq_name}\"+\".txt\", 'w') { |file|\n \n n=1\n \n @actions.each do |a|\n file.puts a.description\n n +=1 \n end\n } \n \n end", "def text\n self.text = {\n \"processed\": processed,\n \"cleaned\": cleaned\n }\n end", "def create_and_link_text_asset(client, customer_id, text, field_type)\n operations = []\n temp_id = next_temp_id\n\n # Create the Text Asset.\n operations << client.operation.mutate do |m|\n m.asset_operation = client.operation.create_resource.asset do |a|\n a.resource_name = client.path.asset(customer_id, temp_id)\n a.text_asset = client.resource.text_asset do |text_asset|\n text_asset.text = text\n end\n end\n end\n\n # Create an AssetGroupAsset to link the Asset to the AssetGroup.\n operations << client.operation.mutate do |m|\n m.asset_group_asset_operation = client.operation.create_resource\n .asset_group_asset do |aga|\n aga.field_type = field_type\n aga.asset_group = client.path.asset_group(\n customer_id,\n ASSET_GROUP_TEMPORARY_ID)\n aga.asset = client.path.asset(customer_id, temp_id)\n end\n end\n\n operations\nend", "def set_search_text!\n self.text['a'] = extract_search_text :title, :meta_description\n self.text['b'] = extract_search_text :slug, :path\n self.text['c'] = extract_search_text *self.class.field_names(:textual)\n self.text['d'] = nil\n end", "def path_assets\n arr_classes = page_classes.split( ' ' )\n\n if arr_classes.length < 2\n\n arr_classes[ 0 ]\n\n else\n\n arr_section = arr_classes[ ( arr_classes.length - 1 ) ].split( '_' )\n asset_path = ''\n\n arr_section.each_with_index do |lista, i|\n if i == ( arr_section.length - 1 )\n asset_path = asset_path + lista\n else\n asset_path = asset_path + lista + '/'\n end\n end\n\n asset_path\n\n end\n end", "def save\n File.open(@test_name, \"w+\") do |file|\n file.write(render)\n end\n end", "def writes(text)\n output_file = File.open(ARGV[1], 'a')\n output_file.write(text)\n end", "def save!\n FileUtils.mkdir_p File.dirname(self.file)\n\n File.open(self.file, \"w+\") do |f|\n f << %(#{self.namespace}.translations || (#{self.namespace}.translations = {});\\n)\n self.translations.each do |locale, translations_for_locale|\n f << %(#{self.namespace}.translations[\"#{locale}\"] = #{translations_for_locale.to_json};\\n);\n end\n end\n end", "def generate_pages\n Dir.foreach(@site_path) do |file|\n if file =~ /(\\w+)\\.page/\n path = File.join(@site_path, file)\n\n File.open(File.join(@site_path, \"#{$1}.html\"), 'w') do |f|\n f << generate_page(parse_page(path))\n end\n\n @log.debug(\" generated a page from #{path}\")\n end\n end\n end" ]
[ "0.55962205", "0.55507225", "0.5429495", "0.5412409", "0.5299393", "0.5299038", "0.52539974", "0.5238184", "0.5228696", "0.52244806", "0.5206119", "0.5179005", "0.51789945", "0.5177082", "0.51638323", "0.5088538", "0.50697184", "0.50645953", "0.50645953", "0.5056267", "0.50397736", "0.503094", "0.49913475", "0.49773398", "0.49733767", "0.4964603", "0.49540216", "0.49144706", "0.49123707", "0.49119458", "0.49119458", "0.48972988", "0.48787662", "0.48675466", "0.4855018", "0.4843771", "0.48343804", "0.48180678", "0.4810518", "0.480402", "0.47869703", "0.47845858", "0.4765334", "0.47578713", "0.47503522", "0.4748392", "0.47481468", "0.47466043", "0.47461802", "0.47331995", "0.47251186", "0.47191536", "0.47039703", "0.46906397", "0.4677843", "0.4661257", "0.4661257", "0.46553326", "0.46534136", "0.4651866", "0.46478927", "0.4638467", "0.46221992", "0.4620493", "0.4610995", "0.46074566", "0.46050093", "0.46036094", "0.45979613", "0.45957664", "0.45930573", "0.4588788", "0.4588145", "0.45877925", "0.4583588", "0.45777482", "0.45714486", "0.4558567", "0.45580822", "0.45561773", "0.4556027", "0.45554322", "0.4541791", "0.4536762", "0.45239797", "0.4523941", "0.45177886", "0.45166522", "0.45143148", "0.4512449", "0.45070338", "0.44967443", "0.44954744", "0.44914323", "0.44846603", "0.44845414", "0.44773898", "0.44768307", "0.44666338", "0.4461957" ]
0.77455944
0
Update a document, with S3 permission fixing, cache expiry, and access control.
def secure_update(attrs, account) if !account.allowed_to_edit?(self) self.errors.add(:base, "You don't have permission to update the document." ) return false end access = attrs.delete :access access &&= access.to_i published_url = attrs.delete :published_url attrs[:remote_url] ||= published_url data = attrs.delete :data update_attributes attrs self.data = data if data set_access(access) if access && self.access != access true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_document(obj)\n visibility_changed = visibility_status(obj)\n obj.attributes = work_params\n obj.date_modified = Time.current.ctime\n obj.save\n VisibilityCopyJob.perform_later(obj) if visibility_changed\n InheritPermissionsJob.perform_later(obj) if work_params.fetch(:permissions_attributes, nil)\n end", "def update!(**args)\n @cloud_ai_document_option = args[:cloud_ai_document_option] if args.key?(:cloud_ai_document_option)\n @create_mask = args[:create_mask] if args.key?(:create_mask)\n @document = args[:document] if args.key?(:document)\n @policy = args[:policy] if args.key?(:policy)\n @request_metadata = args[:request_metadata] if args.key?(:request_metadata)\n end", "def update_document(document, params)\n # this will only work if there is only one datastream being updated.\n # once ActiveFedora::MetadataDatastream supports .update_datastream_attributes, use that method instead (will also be able to pass through params[\"asset\"] as-is without usin prep_updater_method_args!)\n # result = document.update_indexed_attributes(params[:params], params[:opts])\n result = document.update_datastream_attributes(params)\n end", "def update_document(document, params)\n # this will only work if there is only one datastream being updated.\n # once ActiveFedora::MetadataDatastream supports .update_datastream_attributes, use that method instead (will also be able to pass through params[\"asset\"] as-is without usin prep_updater_method_args!)\n # result = document.update_indexed_attributes(params[:params], params[:opts])\n result = document.update_datastream_attributes(params)\n end", "def update\n @s3_image = S3Image.find(params[:id])\n\n respond_to do |format|\n if @s3_image.update_attributes(params[:s3_image])\n format.html { redirect_to @s3_image, notice: 'S3 image was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @s3_image.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if signed_in?\n if current_user.admin?\n @document.user = current_user\n respond_to do |format|\n if @document.update(document_params)\n format.html { redirect_to @document, notice: I18n.t('documents.messages.update_success') }\n format.json { render :show, status: :ok, location: @document }\n else\n format.html { render :edit }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n else\n admin_user\n end\n else\n redirect_to signin_path\n end\n end", "def orchio_put(jdoc)\n response = client.send_request :put, inst_args(json: jdoc)\n if cache.enabled?\n simple_cache.save(\n Document.new(\n response.body.to_hash,\n Metadata.new(\n :collection => ocollection,\n :key => @id,\n :ref => response.header.etag\n )))\n end\n set_ref_value response\n orchio_status response, 201\n end", "def update!(**args)\n @document_acl_policy = args[:document_acl_policy] if args.key?(:document_acl_policy)\n @enable_document_text_extraction = args[:enable_document_text_extraction] if args.key?(:enable_document_text_extraction)\n @folder = args[:folder] if args.key?(:folder)\n end", "def update(projectId, document)\r\n\t\t\t\turl = getBaseURL+\"projects/\"+String(projectId)+\"/documents/\"+String(document.getId)+\"/\"\r\n\t\t\t\tfileBody = Hash.new \r\n\t\t\t\tfileBody[\"uploaddoc\"] = document.getUploaddoc\r\n\t\t\t\tresponse = ZohoHTTPClient.post(url, getQueryMap, document.toParamMAP, fileBody)\t\t\r\n\t\t\t\treturn $documentParser.getDocument(response)\r\n\t\t\tend", "def update_document(*args, request_record: nil)\n # defined in ActiverecordReindex::ReflectionReindex\n update_document_hook(request_record)\n\n original_update_document(*args)\n end", "def update\r\n params[:document][:version] = ENV[\"VERSION\"]\r\n params[:document][:username] = current_user.username\r\n @document = Document.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @document.update_attributes(document_params)\r\n format.html { redirect_to @document, notice: 'Document was successfully updated.' }\r\n format.json { head :no_content }\r\n else\r\n format.html { render action: \"edit\" }\r\n format.json { render json: @document.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def update!(**args)\n @cloud_ai_document_option = args[:cloud_ai_document_option] if args.key?(:cloud_ai_document_option)\n @document = args[:document] if args.key?(:document)\n @request_metadata = args[:request_metadata] if args.key?(:request_metadata)\n @update_options = args[:update_options] if args.key?(:update_options)\n end", "def update\n @bench_test_s3 = BenchTest::S3.find(params[:id])\n\n respond_to do |format|\n if @bench_test_s3.update_attributes(params[:bench_test_s3])\n format.html { redirect_to(@bench_test_s3, :notice => 'S3 was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @bench_test_s3.errors, :status => :unprocessable_entity }\n end\n end\n end", "def s3_updatefile(filename, filedata)\n s3_deletefile filename\n #AWS::S3::S3Object.store filename, filedata, QBUCKET.to_s, :access => :public_read\n AWS::S3::S3Object.store filename, filedata, IMAGES_BUCKET.to_s, :access => :public_read\n end", "def update\n @finance_document = FinanceDocument.find(params[:id])\n\n if @finance_document.update(finance_document_params)\n audit(@finance_document, current_user)\n head :no_content\n else\n render json: @finance_document.errors, status: :unprocessable_entity\n end\n end", "def bucket_policy_aws_principal_updated?(\r\n s3_client,\r\n bucket_name,\r\n new_aws_principal\r\n)\r\n bucket_policy = s3_client.get_bucket_policy(bucket: bucket_name).policy.read\r\n policy_json = JSON.parse(bucket_policy)\r\n\r\n policy_json['Statement'][0]['Principal']['AWS'] = new_aws_principal\r\n\r\n s3_client.put_bucket_policy(\r\n bucket: bucket_name,\r\n policy: policy_json.to_json\r\n )\r\n return true\r\nrescue StandardError => e\r\n puts \"Error updating bucket policy: #{e.message}\"\r\n return false\r\nend", "def update!(**args)\n @bucket_id = args[:bucket_id] if args.key?(:bucket_id)\n @obj_id = args[:obj_id] if args.key?(:obj_id)\n end", "def update\n add_breadcrumb @document.name, library_category_library_document_path(@category, @document)\n add_breadcrumb \"Modify\"\n\n respond_to do |format|\n if @document.update(document_params)\n notify_user(:notice, 'Document was successfully updated.')\n format.html { redirect_to library_category_library_document_path(@category, @document) }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def put( doc, opts = {} )\n response = http_action :put, doc, opts.merge( :doc => doc )\n doc['_id'], doc['_rev'] = response['id'], response['rev'] if doc.kind_of? Hash\n response\n end", "def update\n @document = Document.find(params[:id])\n\n respond_to do |format|\n if @document.update_attributes(params[:document].merge({:updated_by => current_user}))\n format.html { redirect_to edit_admin_document_path(@document), notice: '<strong>Success!</strong> The document was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_doc(doc)\n id = doc[\"_id\"] if doc[\"_id\"]\n\n @conn.query({url_path: \"#{database}/#{id}\", opts: doc, method: :put})\n end", "def update\n respond_to do |format|\n if @s3image.update(s3image_params)\n format.html { redirect_to @s3image, notice: 'S3image was successfully updated.' }\n format.json { render :show, status: :ok, location: @s3image }\n else\n format.html { render :edit }\n format.json { render json: @s3image.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @bucket = args[:bucket] if args.key?(:bucket)\n @generation = args[:generation] if args.key?(:generation)\n @object = args[:object] if args.key?(:object)\n end", "def update_document(database_id:, collection_id:, document_id:, data: nil, permissions: nil)\n path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'\n .gsub('{databaseId}', database_id)\n .gsub('{collectionId}', collection_id)\n .gsub('{documentId}', document_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 document_id.nil?\n raise Appwrite::Exception.new('Missing required parameter: \"documentId\"')\n end\n\n params = {\n data: data,\n permissions: permissions,\n }\n \n headers = {\n \"content-type\": 'application/json',\n }\n\n @client.call(\n method: 'PATCH',\n path: path,\n headers: headers,\n params: params,\n response_type: Models::Document\n )\n end", "def update!(**args)\n @bucket = args[:bucket] if args.key?(:bucket)\n @generation_number = args[:generation_number] if args.key?(:generation_number)\n @object = args[:object] if args.key?(:object)\n end", "def update!(**args)\n @document = args[:document] if args.key?(:document)\n end", "def update!(**args)\n @document = args[:document] if args.key?(:document)\n end", "def update!(**args)\n @document = args[:document] if args.key?(:document)\n @gcs_path = args[:gcs_path] if args.key?(:gcs_path)\n @line_number = args[:line_number] if args.key?(:line_number)\n @operation = args[:operation] if args.key?(:operation)\n @user_event = args[:user_event] if args.key?(:user_event)\n end", "def update_file_on_s3(file, objects)\n file_path = s3_file_path(file)\n conn = RedmineS3::Connection.conn\n object = objects[file_path]\n\n # get the file modified time, which will stay nil if the file doesn't exist yet\n # we could check if the file exists, but this saves a head request\n s3_mtime = object.last_modified rescue nil \n\n # put it on s3 if the file has been updated or it doesn't exist on s3 yet\n if s3_mtime.nil? || s3_mtime < File.mtime(file)\n fileObj = File.open(file, 'r')\n RedmineS3::Connection.put(file_path, fileObj.read)\n fileObj.close\n\n puts \"Put file \" + File.basename(file)\n else\n puts File.basename(file) + ' is up-to-date on S3'\n end\n end", "def update!(**args)\n @document = args[:document] if args.key?(:document)\n @id = args[:id] if args.key?(:id)\n @metadata = args[:metadata] if args.key?(:metadata)\n end", "def update\n authorize @document\n\n respond_to do |format|\n if @document.update(document_params)\n flash_label = \"Document was successfully updated.\"\n flash.now[:notice] = flash_label\n\n format.html { redirect_to @document, notice: flash_label }\n format.json { render :show, status: :ok, location: @document }\n format.js\n else\n format.html { render :edit }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n format.js\n end\n end\n end", "def update(entry_id, document_entry)\n\t\t\tkparams = {}\n\t\t\t# Document entry id to update\n\t\t\tclient.add_param(kparams, 'entryId', entry_id);\n\t\t\t# Document entry metadata to update\n\t\t\tclient.add_param(kparams, 'documentEntry', document_entry);\n\t\t\tclient.queue_service_action_call('document', 'update', kparams);\n\t\t\tif (client.is_multirequest)\n\t\t\t\treturn nil;\n\t\t\tend\n\t\t\treturn client.do_queue();\n\t\tend", "def update!(**args)\n @bucket_name = args[:bucket_name] if args.key?(:bucket_name)\n @generation = args[:generation] if args.key?(:generation)\n @object_name = args[:object_name] if args.key?(:object_name)\n end", "def update!(**args)\n @cookie = args[:cookie] if args.key?(:cookie)\n @current_client_url = args[:current_client_url] if args.key?(:current_client_url)\n @document = args[:document] if args.key?(:document)\n @id = args[:id] if args.key?(:id)\n @image = args[:image] if args.key?(:image)\n end", "def update_with_document(doc_data)\n begin\n self.transaction do \n document = doc_data.slice(\n :name, :phase_id, :bookmark, :privilege,\n :description, :author, :source,:doc_source_id,\n :employee_user_id, :created_by_user_id)\n document.merge!({\n :document_home_id => self.id,\n :doc_type_id => doc_data[:category_id]})\n doc= self.latest_doc\n if doc.update_attributes(document) && self.save\n true\n else\n doc.errors.each do |error|\n self.errors.add(error[0], error[1])\n end\n false\n end\n end\n rescue\n false\n end\n end", "def update_document index, id, document\n uri = URI(\"http://#{@host}:#{@port_s}/#{index}/_doc/#{id}/_update\")\n req = Net::HTTP::Post.new(uri)\n req.body = { \"doc\": document }.to_json\n run(uri, req)\n end", "def update_document_using_put_with_http_info(document, document_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DocumentApi.update_document_using_put ...'\n end\n # verify the required parameter 'document' is set\n if @api_client.config.client_side_validation && document.nil?\n fail ArgumentError, \"Missing the required parameter 'document' when calling DocumentApi.update_document_using_put\"\n end\n # verify the required parameter 'document_id' is set\n if @api_client.config.client_side_validation && document_id.nil?\n fail ArgumentError, \"Missing the required parameter 'document_id' when calling DocumentApi.update_document_using_put\"\n end\n # resource path\n local_var_path = '/nucleus/v1/document/{document_id}'.sub('{' + 'document_id' + '}', document_id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['*/*'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(document)\n auth_names = ['oauth2']\n data, status_code, headers = @api_client.call_api(:PUT, 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 => 'Document')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DocumentApi#update_document_using_put\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def update\n respond_to do |format|\n if @document.update(document_params)\n @document.create_activity :update, owner: current_user\n format.html { redirect_to @document, notice: 'Document was successfully updated.' }\n format.json { render :show, status: :ok, location: @document }\n else\n format.html { render :edit }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @document.update_attributes(document_params)\n redirect_to catalog_account_catalog_document_path(@account, @catalog, @document)\n end", "def file_public_write\n if $item_public_write.variable() == 1\n $s3.client.put_object_acl(acl: ' public-read-write',\n bucket: $bucket,\n key: $bucket_item)\n else\n $s3.client.put_object_acl(acl: 'private',\n bucket: $bucket,\n key: $bucket_item)\n end\n end", "def update_document!(model, id)\n document = model.update(id, params)\n unless document.valid?\n error 400, convert(body_for(:invalid_document, document))\n end\n document\n end", "def update(selector, document, opts={})\n send_write(:update, selector, document, !document.keys.first.to_s.start_with?(\"$\"), opts)\n end", "def update\n\t\traise RuntimeError, \"Not authorized\" unless current_user && current_user.root? == true\n\n\t\tparams = doc_params\n\t\tparams[:body].gsub!(/\\r\\n/, \"\\n\")\n\t\t@doc = Doc.find(params[:id])\n\n\t\trespond_to do |format|\n\t\t\tif @doc.update(params)\n\t\t\t\tformat.html { redirect_to @doc, notice: t('controllers.shared.successfully_updated', :model => t('activerecord.models.doc')) }\n\t\t\t\tformat.json { head :no_content }\n\t\t\telse\n\t\t\t\tformat.html { render action: \"edit\" }\n\t\t\t\tformat.json { render json: @doc.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def update_policy(arn, doc)\n MU::Cloud::AWS::Role.update_policy(arn, doc, credentials: @credentials)\n end", "def update\n authorize @document\n disable_primary if document_params[:primary]\n respond_to do |format|\n if @document.update(document_params)\n format.html { redirect_to @document.instruction, notice: 'Document was successfully updated.' }\n format.json { render :show, status: :ok, location: @document }\n else\n format.html { render :edit }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if (@document = Document.find(params[:id])).update_attributes(params[:document])\n flash['notice'] = 'Document was successfully updated.'\n end\n respond_with @document, \n :location => site_document_url(@document.site.slug , @document.id.to_s)\n end", "def update\n save_doc\n end", "def update\n\tdata = unpack_document(params[:document][:datafile]) \n\tdoc_params = {:title => document_params[\"title\"], :date => get_date(document_params,\"date\")}\n\tif !data.nil? then\n\t\tdoc_params[:content] = data[:content]\n\t\tdoc_params[:styles] = data[:styles]\n\tend\n respond_to do |format|\n if @document.update(doc_params)\n format.html { redirect_to @document, notice: \"Document updated successfully\"}\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def put\n if(resource.collection?)\n Forbidden\n elsif(!resource.parent_exists? || !resource.parent_collection?)\n Conflict\n else\n resource.lock_check if resource.supports_locking?\n status = resource.put(request, response)\n response['Location'] = \"#{scheme}://#{host}:#{port}#{url_format(resource)}\" if status == Created\n response.body = response['Location']\n status\n end\n end", "def update\n document = Document.find(params[:id])\n document.update!(update_params)\n render json: {}\n end", "def update!(**args)\n @canonical_docid = args[:canonical_docid] if args.key?(:canonical_docid)\n @docid = args[:docid] if args.key?(:docid)\n @image_index = args[:image_index] if args.key?(:image_index)\n @query_index = args[:query_index] if args.key?(:query_index)\n end", "def update!(**args)\n @document_id = args[:document_id] if args.key?(:document_id)\n end", "def update(doc, uri=nil, content_type=nil)\n return _put_doc(doc, uri, content_type)\n end", "def update\n Rails.logger.info \"Before update\"\n respond_to do |format|\n if @document.update(document_params)\n format.html { redirect_to @document, notice: 'Document was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n Rails.logger.info \"After update\"\n end", "def update!(document, attributes)\n method = klass.ancestors.include?(ActAsGroup::Resource) && klass.group_update_method ||\n ActAsGroup.configuration.update_resource.to_sym\n\n document.send(method, attributes)\n end", "def update_document_using_put(document, document_id, opts = {})\n data, _status_code, _headers = update_document_using_put_with_http_info(document, document_id, opts)\n data\n end", "def run_me\r\n bucket_name = 'doc-example-bucket'\r\n object_key = 'my-file.txt'\r\n object_content = 'This is the content of my-file.txt.'\r\n access_level_before = 'private'\r\n access_level_after = 'public-read'\r\n region = 'us-west-2'\r\n s3_client = Aws::S3::Client.new(region: region)\r\n\r\n # Set the initial access level of the bucket to 'private'\r\n # for public access.\r\n if bucket_acl_set?(s3_client, bucket_name, access_level_before)\r\n puts \"1. Initial bucket ACL set to '#{access_level_before}' \" \\\r\n \"for public access.\\n\\n\"\r\n else\r\n puts \"1. Initial bucket ACL not set to '#{access_level_before}' \" \\\r\n 'for public access. Stopping program.'\r\n exit 1\r\n end\r\n\r\n # What happens when you try to access the bucket? (It should be denied.)\r\n puts \"2. After initial bucket ACL set to '#{access_level_before}' \" \\\r\n \"for public access, trying to access the bucket:\\n\\n\"\r\n object_content_by_bucket_unsigned_request(bucket_name, region)\r\n\r\n # Upload an object to the bucket.\r\n if object_uploaded?(s3_client, bucket_name, object_key, object_content)\r\n puts \"3. Object uploaded to bucket.\\n\\n\"\r\n else\r\n puts '3. Object not uploaded to bucket. Stopping program. ' \\\r\n \"Note that the bucket ACL is still set to '#{access_level_before}' \" \\\r\n 'for public access.'\r\n exit 1\r\n end\r\n\r\n # What happens when you try to access the object now?\r\n # (It should still be denied.)\r\n puts \"4. After object uploaded, trying to access the object:\\n\\n\"\r\n object_content_by_object_unsigned_request(bucket_name, object_key, region)\r\n\r\n # Now set the initial access level of the object to 'public-read'\r\n # for public access.\r\n if object_acl_set?(s3_client, bucket_name, object_key, access_level_after)\r\n puts \"5. Object ACL set to '#{access_level_after}' for public access.\\n\\n\"\r\n else\r\n puts \"5. Object ACL not set to '#{access_level_after}' for public \" \\\r\n 'access. Stopping program. ' \\\r\n \"Note that the bucket ACL is still set to '#{access_level_before}' \" \\\r\n 'for public access.'\r\n exit 1\r\n end\r\n\r\n # What happens when you try to access the object now? (It should now work.)\r\n puts \"6. After object ACL set to '#{access_level_after}' for public \" \\\r\n \"access, trying to access the object:\\n\\n\"\r\n object_content_by_object_unsigned_request(bucket_name, object_key, region)\r\n\r\n # Now set the access level for the object to 'private' for public access.\r\n if object_acl_set?(s3_client, bucket_name, object_key, access_level_before)\r\n puts \"7. Object ACL now set to '#{access_level_before}' \" \\\r\n \"for public access.\\n\\n\"\r\n else\r\n puts \"7. Object ACL not set to '#{access_level_before}' \" \\\r\n 'for public access. Stopping program. ' \\\r\n \"Note that the bucket ACL is still set to '#{access_level_before}'.\"\r\n exit 1\r\n end\r\n\r\n # What happens when you try to access the object now?\r\n # (It should now be denied.)\r\n puts \"8. After object ACL set to '#{access_level_before}' \" \\\r\n \"for public access, trying to access the object:\\n\\n\"\r\n object_content_by_object_unsigned_request(bucket_name, object_key, region)\r\n\r\n puts '9. Program ends. Note that the bucket ACL is still set to ' \\\r\n \"'#{access_level_before}' for public access.\"\r\nend", "def update\n respond_to do |format|\n if @document.update(document_params)\n format.html { redirect_to @document, notice: 'Document was successfully updated.' }\n format.json { render :show, status: :ok, location: @document }\n else\n format.html { render :edit }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @document.update(document_params)\n Log.create! description: \"#{current_user.email} updated #{@document.name} at #{@document.updated_at.strftime '%d-%m-%Y %H:%M:%S'}\", role_id: current_user.roles.ids.first\n format.html { redirect_to admin_document_path(@document), notice: 'Document was successfully updated.' }\n format.json { render :show, status: :ok, location: @document }\n else\n format.html { render :edit }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @problem.reported_by == current_user\n respond_to do |format|\n if @problem.update(problem_params)\n format.html { redirect_to @problem, notice: 'Problem was successfully updated.' }\n format.json { render :show, status: :ok, location: @problem }\n else\n format.html {\n initialize_locations(@problem)\n @s3_direct_post = S3_BUCKET.presigned_post(key: \"uploads/#{SecureRandom.uuid}/${filename}\", success_action_status: 201, acl: :public_read)\n render :edit\n }\n format.json { render json: @problem.errors, status: :unprocessable_entity }\n end\n end\n else\n redirect_to problem_path(@problem)\n end\n end", "def update\n @document = Document.find(params[:id])\n\n respond_to do |format|\n if @document.update_attributes(params[:document])\n format.html { redirect_to root_url , notice: 'Document was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_document( doc_id:, filename:, content: nil, author: nil, actions:nil, callback_url:nil )\n params = {}\n params[:actions] = actions if actions\n params[:author] = author if author\n params[:callback_url] = callback_url if callback_url\n params[:backtrace] = @backtrace if @backtrace\n\n base_filename = File.basename(filename)\n response = nil\n if content\n with_tempfile(content) do |io|\n params[:file] = io\n response = send_request :post, \"document/#{@app}/#{doc_id}/#{base_filename}\", params, :json\n end\n else\n response = send_request :post, \"document/#{@app}/#{doc_id}/#{base_filename}\", params, :json\n end\n response\n end", "def update!(**args)\n @asr_model = args[:asr_model] if args.key?(:asr_model)\n @doc_key = args[:doc_key] if args.key?(:doc_key)\n @lang = args[:lang] if args.key?(:lang)\n @mustang_doc_id = args[:mustang_doc_id] if args.key?(:mustang_doc_id)\n @url = args[:url] if args.key?(:url)\n @s3_mode = args[:s3_mode] if args.key?(:s3_mode)\n @s3_model_info_label = args[:s3_model_info_label] if args.key?(:s3_model_info_label)\n @transcript = args[:transcript] if args.key?(:transcript)\n end", "def update\n @document = Document.find(params[:id])\n\n respond_to do |format|\n if @document.update_attributes(params[:document])\n format.html { redirect_to @document, :notice => 'Document was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @document.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @document = Document.find(params[:id])\n\n respond_to do |format|\n if @document.update_attributes(params[:document])\n format.html { redirect_to @document, notice: 'Document was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def s3_upload_policy_document(s3_bucket)\r\n\r\n if s3_bucket == \"ted_kennedy_image\" || s3_bucket == \"production_images_1\" #for forms uploading images\r\n\r\n logger.info \"in image bucket, bucketis= \"+s3_bucket.to_s\r\n\r\n\t\t\tBase64.encode64(\r\n\t\t\t\t\t\t {\r\n\t\t\t\t\t\t\texpiration: 30.minutes.from_now.utc.strftime('%Y-%m-%dT%H:%M:%S.000Z'),\r\n\t\t\t\t\t\t\tconditions: [\r\n\t\t\t\t\t\t\t\t\t{ bucket: s3_bucket },\r\n\t\t\t\t\t\t\t\t\t{ acl: 'public-read' },\r\n\t\t\t\t\t\t\t\t\t[\"starts-with\", \"$key\", \"\"],\r\n\t\t\t\t\t\t\t\t\t[\"starts-with\", \"$Content-Type\", \"image\"],\r\n\t\t\t\t\t\t\t\t\t[\"content-length-range\", 0, 1048576],\r\n\t\t\t\t\t\t\t\t\t[\"starts-with\", \"$x-amz-meta-my-file-name\", \"\"],\r\n\t\t\t\t\t\t\t\t\t{ success_action_status: '201' }\r\n\t\t\t\t\t\t\t]\r\n\t\t\t\t\t}.to_json\r\n\t\t\t).gsub(/\\n|\\r/, '')\r\n\r\n\t\telse #for forms loading attachments\r\n\t\t\tBase64.encode64(\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t\texpiration: 30.minutes.from_now.utc.strftime('%Y-%m-%dT%H:%M:%S.000Z'),\r\n\t\t\t\t\t\t\tconditions: [\r\n\t\t\t\t\t\t\t\t\t{ bucket: s3_bucket },\r\n\t\t\t\t\t\t\t\t\t{ acl: 'public-read' },\r\n\t\t\t\t\t\t\t\t\t[\"starts-with\", \"$key\", \"\"],\r\n\t\t\t\t\t\t\t\t\t[\"starts-with\", \"$Content-Disposition\", \"\"],\r\n\t\t\t\t\t\t\t\t\t[\"content-length-range\", 0, 104857600],\r\n\t\t\t\t\t\t\t\t\t[\"starts-with\", \"$x-amz-meta-my-file-name\", \"\"],\r\n [\"starts-with\", \"$Content-Type\", \"\"],\r\n\t\t\t\t\t\t\t\t\t{ success_action_status: '201' }\r\n\t\t\t\t\t\t\t]\r\n\t\t\t\t\t}.to_json\r\n\t\t\t).gsub(/\\n|\\r/, '')\r\n\r\n\t end\r\n\r\n\tend", "def update\n @document = Document.find(params[:id])\n\n respond_to do |format|\n if @document.update_attributes(params[:document])\n format.html { redirect_to edit_admin_document_path(@document), notice: 'Document was successfully updated.' }\n format.js { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n \t@document = Document.find(params[:id])\n if @document.update_attributes(document_params)\n render json: {status: 'SUCCESS', message:'Document updated', data:@document}, status: :ok\n else\n\t\trender json: {status: 'ERROR', message:'Document not updated', data:@document.errors}, status: :unprocessable_entity\n end\n end", "def update\n @modified_document = ModifiedDocument.find(params[:id])\n \n if @modified_document.update(modified_document_params)\n render json: @modified_document, status: :ok \n else\n render json: @modified_document.errors, status: :unprocessable_entity\n end\n end", "def update\n @document = Document.find(params[:id])\n\n respond_to do |format|\n if @document.update_attributes(params[:document])\n format.html { redirect_to :action => \"index\", notice: 'Document was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @document = Document.find(params[:id])\n\n respond_to do |format|\n if @document.update_attributes(params[:document])\n format.html { redirect_to @document, notice: 'Document was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @document = Document.find(params[:id])\n\n respond_to do |format|\n if @document.update_attributes(params[:document])\n format.html { redirect_to @document, notice: 'Document was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @document = Document.find(params[:id])\n\n respond_to do |format|\n if @document.update_attributes(params[:document])\n format.html { redirect_to @document, notice: 'Document was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @document = Document.find(params[:id])\n\n respond_to do |format|\n if @document.update_attributes(params[:document])\n format.html { redirect_to documents_path, notice: 'Document was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :edit }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @document = current_user.documents.find(params[:id])\n respond_to do |format|\n if @document.update(document_params)\n format.html { redirect_to @document, notice: 'Document was successfully updated.' }\n format.json { render :show, status: :ok, location: @document }\n else\n format.html { render :edit }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @doc = Doc.find(params[:id])\n \n respond_to do |format|\n if @doc.update_attributes(params[:doc])\n save_object_relationship\n format.html { redirect_to(@doc, :notice => 'Doc was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @doc.errors, :status => :unprocessable_entity }\n end\n end\n end", "def s3_upload_policy_document\n\t return @policy if @policy\n\t ret = {\"expiration\" => 5.minutes.from_now.utc.xmlschema,\n\t \"conditions\" => [ \n\t {\"bucket\" => YOUR_BUCKET_NAME}, \n\t [\"starts-with\", \"$key\", @document.s3_key],\n\t {\"acl\" => \"private\"},\n\t {\"success_action_status\" => \"200\"},\n\t [\"content-length-range\", 0, 1048576]\n\t ]\n\t }\n\t @policy = Base64.encode64(ret.to_json).gsub(/\\n/,'')\n\t end", "def web_dav_put(*args, &block)\n args = web_dav_args args\n map_method :put, args, &block\n end", "def update!(**args)\n @docid = args[:docid] if args.key?(:docid)\n @item_metadata = args[:item_metadata] if args.key?(:item_metadata)\n end", "def update_document(fields, safe = false)\n collection.update({\"_id\" => self.id}, fields, :safe => safe)\n reload\n end", "def update\n @document = load_document_from_params\n # generates sanatized params from params hash to update the doc with\n sanitize_update_params\n @response = update_document(@document,@sanitized_params)\n @document.save\n flash[:notice] = \"Your changes have been saved.\"\n if params.has_key? :add_another_author\n redirect_to({:controller => \"catalog\", :action => \"edit\", :id => params[:id], :wf_step => :contributor, :add_contributor => true}) \n else\n redirect_to( {:controller => \"catalog\", :action => \"edit\", :id => params[:id]}.merge(params_for_next_step_in_wokflow) )\n end\n end", "def update\n @event = @account.events.find(params[:id])\n file = params[:event][:photo_url]\n public_url = nil\n if file != nil\n s3 = Aws::S3::Resource.new(region: 'us-east-1')\n bucket = 'fifo-cloud'\n # Get just the file name\n name = file.original_filename\n # Create the object to upload\n obj = s3.bucket(bucket).object(name)\n # Create the option\n options = {\n acl: \"public-read\",\n metadata: {\n collection: \"events\",\n title: params[:event][:title],\n source: @event.id.to_s\n }\n }\n obj.upload_file(file.tempfile, options)\n public_url = s3.bucket(bucket).object(name).public_url\n end\n respond_to do |format|\n if @event.update_attributes!(event_params(public_url))\n\n if public_url != nil\n @upload = Upload.new(\n url: public_url,\n name: name,\n event_id: @event.id,\n collection: 'events',\n account_id: @account.id\n ).save!\n end\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 update\n if @doc.update_from_params(params[:course_document])\n render json: @doc, status: :ok\n else\n render json: doc.errors, status: :unprocessable_entity\n end\n end", "def bucket_public_write\n if $bucket_public_write.variable() == 1\n $s3.client.put_bucket_acl(acl: 'public-read-write',bucket: $bucket)\n else\n $s3.client.put_bucket_acl(acl: 'private',bucket: $bucket)\n end\n end", "def put(params)\n bucket = params[:bucket]\n object = params[:object]\n value = params[:value]\n content_type = params[:content_type]\n cb = params[:cb]\n date = generate_date\n sign_string = generate_signed_string('PUT', 'private', bucket, object, content_type)\n signature = generate_signature(sign_string)\n auth = generate_auth(signature)\n headers = generate_put_headers(date, auth, 'private', content_type, value.size)\n path = \"/\" << object\n\n @req_options = {:method => :put, :head => headers, :path => path, :body => value}\n @cb = cb if cb\n @bucket = bucket\n try_request\n self\n end", "def update\n document = Document.find(params[:id])\n if document.update(params_document)\n render json: document, status: 200\n else\n render json: document.errors, status: 422\n end\n\n end", "def update\r\n\r\n respond_to do |format|\r\n if @document.update(document_params)\r\n format.html { redirect_to root_url, notice: 'Document was successfully updated.' }\r\n format.json { render :show, status: :ok, location: @document }\r\n else\r\n format.html { render :edit }\r\n format.json { render json: @document.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def update!(**args)\n @acl_info = args[:acl_info] if args.key?(:acl_info)\n @document_type = args[:document_type] if args.key?(:document_type)\n @file_extension = args[:file_extension] if args.key?(:file_extension)\n @last_content_modified_timestamp = args[:last_content_modified_timestamp] if args.key?(:last_content_modified_timestamp)\n @num_subscribers = args[:num_subscribers] if args.key?(:num_subscribers)\n @num_viewers = args[:num_viewers] if args.key?(:num_viewers)\n @result_info = args[:result_info] if args.key?(:result_info)\n @type_info = args[:type_info] if args.key?(:type_info)\n end", "def update\n respond_to do |format|\n if @document.update(document_params)\n format.html { redirect_to @document, notice: 'Document was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @document.update(document_params)\n format.html { redirect_to @document, notice: 'Document was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @document.update(document_params)\n format.html { redirect_to @document, notice: 'Document was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @document = Document.find(params[:id])\n\n respond_to do |format|\n if @document.update_attributes(params[:document])\n format.html { redirect_to(@document, :notice => 'Document was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @document.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @document.update(document_params)\n format.html { redirect_to back_index_case_url, notice: 'Document was successfully updated.' }\n else\n format.html { render :edit }\n end\n end\n end", "def update\n\n @documentable = @document.documentable\n\n respond_to do |format|\n if @document.update(document_params)\n notify_user(:notice, 'Document was successfully updated.')\n format.html { redirect_to get_resource_url(@documentable) }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_file(bucket_id:, file_id:, permissions: nil)\n path = '/storage/buckets/{bucketId}/files/{fileId}'\n .gsub('{bucketId}', bucket_id)\n .gsub('{fileId}', file_id)\n\n if bucket_id.nil?\n raise Appwrite::Exception.new('Missing required parameter: \"bucketId\"')\n end\n\n if file_id.nil?\n raise Appwrite::Exception.new('Missing required parameter: \"fileId\"')\n end\n\n params = {\n permissions: permissions,\n }\n \n headers = {\n \"content-type\": 'application/json',\n }\n\n @client.call(\n method: 'PUT',\n path: path,\n headers: headers,\n params: params,\n response_type: Models::File\n )\n end", "def update_doc(doc)\n assert_type(doc, Wgit::Document)\n selection = { 'url.url' => doc.url }\n doc_hash = Wgit::Model.document(doc).merge(Wgit::Model.common_update_data)\n update = { '$set' => doc_hash }\n mutate(true, :documents, selection, update)\n end", "def update\n @document = Document.find(params[:id])\n\n respond_to do |format|\n if @document.update_attributes(params[:document])\n format.html { redirect_to @document, :flash => { :success => 'Document was successfully updated.' } }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n @compliance = Compliance.find(params[:id])\n\n # Vendor Session\n if vendor_session?\n if !params[:compliance][:documents_attributes].nil? then\n if @compliance.documents.nil? || @compliance.documents.empty?\n bucket_name = \"Vendors/\" + Vendor.find(session[:id]).code + \"/\" + params[:compliance][:sku] + \"/\" + (Time.now.to_i).to_s\n else\n bucket_name = \"Vendors/\" + Vendor.find(session[:id]).code + \"/\" + params[:compliance][:sku] + \"/\" + @compliance.documents.first.url.rpartition(\"/\")[0].rpartition(\"/\")[2]\n end\n\n params[:compliance][:documents_attributes].each { |key, value|\n if value.has_key?(\"file\") then\n begin\n\n # key, binary_object, bucket_name --> can be replaced by store_object(bucket, key, object)\n aws_connection_instance = AmazonS3Asset.new\n aws_connection_instance.store_object(bucket_name, value[\"file\"].original_filename, value[\"file\"])\n\n value[\"url\"] = \"http://s3.amazonaws.com/\" + bucket_name + \"/\" + value[\"file\"].original_filename\n value.delete(\"file\")\n rescue\n params[:compliance][:documents_attributes] = {} unless params[:compliance][:documents_attributes].nil?\n @compliance = Compliance.find(params[:id])\n flash.now[:alert] = \"An Error occurred during the update of Compliance Set, Please resubmit with lesser upload files.\"\n render \"edit\"\n return\n end\n end\n }\n end\n\n @compliance.last_activity_at = Time.now\n\n respond_to do |format|\n if @compliance.update_attributes(params[:compliance])\n format.html {\n redirect_to vendor_asin_compliance_home_path(:sku => @compliance.sku, :vendor_id => @compliance.vendor_id)\n }\n\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @compliance.errors, :status => :unprocessable_entity }\n end\n end\n else\n # User Session\n\n if !params[:compliance][:comments_internal].nil? and [email protected]_internal.eql?(params[:compliance][:comments_internal]) then\n @compliance.comments_internal = params[:compliance][:comments_internal]\n end\n\n if !params[:compliance][:comments_external].nil? and [email protected]_external.eql?(params[:compliance][:comments_external]) then\n @compliance.comments_external = params[:compliance][:comments_external]\n end\n\n # User approves Compliance Set\n if !params[:compliance][:status].nil? and params[:compliance][:status].eql?(\"approved\") and !\"approved\".eql?(@compliance.status)\n @compliance.status = \"approved\"\n # Approve all Purchase Order Asins associated with the Compliance Set\n Asin.by_compliance(@compliance).each do |asin|\n asin.compliance_approved\n end\n end\n\n # User Rejects Compliance Set\n if !params[:compliance][:status].nil? and params[:compliance][:status].eql?(\"rejected\") and !\"rejected\".eql?(@compliance.status)\n @compliance.status = \"rejected\"\n # Clear any associations that Purchase Order Asins have with this Compliance Set\n Asin.by_compliance(@compliance).each do |asin|\n asin.compliance_rejected\n end\n end\n\n # User Moves Compliance Set back to Vendor\n if !params[:compliance][:status].nil? and params[:compliance][:status].eql?(\"vendor_input\") and !\"vendor_input\".eql?(@compliance.status)\n @compliance.status = \"vendor_input\"\n # Passing the Compliance Set back to the Vendor should not have any impact\n end\n\n @compliance.last_activity_at = Time.now\n\n respond_to do |format|\n if @compliance.save\n format.html {\n redirect_to user_home_path\n }\n format.xml { head :ok }\n else\n # TODO Fix this\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @compliance.errors, :status => :unprocessable_entity }\n end\n end\n\n end\n\n end", "def update\n find_params = document_review_owner_params.slice(:user_id, :project_id)\n review_owner = DocumentReviewOwner.find_or_initialize_by(find_params)\n authorize! :update, review_owner\n review_owner.assign_attributes(document_review_owner_params)\n if review_owner.save\n render json: review_owner\n else\n render json: review_owner.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @document.update(document_params)\n format.html { redirect_to @document, notice: 'Document was successfully updated.' }\n format.json { render :show, status: :ok, location: @document }\n else\n format.html { render :edit }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.68818676", "0.64250505", "0.6407086", "0.6407086", "0.6277202", "0.6263566", "0.6238744", "0.6227901", "0.6196237", "0.61919606", "0.6175464", "0.6168635", "0.6142867", "0.6135202", "0.61308074", "0.6104177", "0.61019415", "0.60974413", "0.60667354", "0.6065294", "0.60536516", "0.6051953", "0.6039392", "0.6035559", "0.60336155", "0.6030947", "0.6030947", "0.60197234", "0.60158646", "0.5995863", "0.5990201", "0.5977571", "0.59693885", "0.5964422", "0.59500605", "0.5946684", "0.5923212", "0.5908924", "0.5907574", "0.5907497", "0.5884882", "0.5878643", "0.58778024", "0.5876268", "0.5875508", "0.58748174", "0.58734655", "0.58553827", "0.58548874", "0.58525425", "0.5850407", "0.5845095", "0.5838733", "0.5837338", "0.58246344", "0.58216727", "0.58169395", "0.5812706", "0.580914", "0.58062434", "0.58014", "0.5796993", "0.5796139", "0.57925874", "0.5777826", "0.57765377", "0.5775061", "0.57719886", "0.5763766", "0.5757912", "0.5756586", "0.5756586", "0.5756586", "0.575484", "0.5749146", "0.5744817", "0.5743051", "0.57414436", "0.57413703", "0.57385194", "0.5738277", "0.57371026", "0.57273126", "0.57262796", "0.57257074", "0.5723479", "0.57206166", "0.57117915", "0.5705304", "0.5705304", "0.5705304", "0.5704927", "0.5702907", "0.5702679", "0.56998855", "0.5698901", "0.56969696", "0.5694223", "0.56942225", "0.56934816" ]
0.665254
1
For polymorphism on access control with Note and Section:
def document_id id end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private_notes\n \n end", "def private_notes\n end", "def section; end", "def audit section\n\t\t\tsection\n\t\tend", "def can_edit?(doc_type)\n self.can_access?(doc_type)\n end", "def access_info\n super\n end", "def sections\n account.accessible_sections if account\n end", "def accessibility; end", "def access_control\n \n end", "def allow_to\n # owner of story can do anything? editing?\n super :owner, :all => true\n # approved users can create new stories\n super :user, :only => [:show, :index, :search, :new, :create]\n # everybody can list and watch\n super :all, :only => [:show, :index, :search]\n end", "def setup_view_edit_permissions(lot)\n allowableActions = []\n # This is in display order (bottom up)\n # The names after blah_ are the section names used in\n # the HTML/AngularJS code, so keep that in mind if you\n # find yourself editing those.\n #\n # View (unhide) ability\n allowableActions << \"view_charges\"\n allowableActions << \"view_pick-up\"\n allowableActions << \"view_info\"\n allowableActions << \"view_seller\"\n allowableActions << \"view_wait-to-clear-pickup\"\n allowableActions << \"view_wait-for-driver-dispatch\"\n allowableActions << \"view_wait-for-trip-confirmation\"\n allowableActions << \"view_wait-for-inventory\"\n allowableActions << \"view_wait-for-title\"\n allowableActions << \"view_ready-for-auction-section\"\n allowableActions << \"view_wait-for-sale-confirmation\"\n allowableActions << \"view_wait-for-buyer-charge\"\n allowableActions << \"view_ready-for-seller-billing-section\"\n allowableActions << \"view_wait-for-settlement-confirmation\"\n allowableActions << \"view_service-orders\"\n \n # Edit ability\n if !lot.closed? || (lot.closed? && can?(:edit_closed_lots, lot))\n allowableActions << \"edit_charges\" if can? :edit_charges_section, lot\n allowableActions << \"edit_pick-up\" if can? :edit_location_section, lot\n allowableActions << \"edit_info\" if can? :edit_lot_info_section, lot\n allowableActions << \"edit_seller\" if can? :edit_seller_info_section, lot\n allowableActions << \"edit_wait-to-clear-pickup\" if can? :edit_hold_info_section, lot\n allowableActions << \"edit_wait-for-driver-dispatch\" if can? :edit_tow_provider_section, lot\n allowableActions << \"edit_wait-for-trip-confirmation\" if can? :edit_charges_reconciliation_section, lot\n allowableActions << \"edit_wait-for-inventory\" if can? :edit_inventory_section, lot\n allowableActions << \"edit_wait-for-title\" if can? :edit_ownership_transfer_section, lot\n allowableActions << \"edit_ready-for-auction-section\" if can? :edit_auction_section, lot\n allowableActions << \"edit_wait-for-sale-confirmation\" if can? :edit_sale_confirmation_section, lot\n allowableActions << \"edit_wait-for-buyer-charge\" if can? :edit_member_billing_section, lot\n allowableActions << \"edit_ready-for-seller-billing-section\" if can? :edit_seller_billing_section, lot\n allowableActions << \"edit_wait-for-settlement-confirmation\" if can? :edit_settlement_confirmation_section, lot\n allowableActions << \"edit_service-orders\" if can? :edit_service_order_section, lot\n end\n \n gon.allowableActions = allowableActions\n end", "def set_study_accession\n self.study_accession = self.study.accession\n end", "def access_level\n if self.administrator?\n return 3\n elsif self.editor?\n return 2\n elsif self.commenter?\n return 1\n end\n end", "def privacy\n end", "def privacy\n end", "def show\n authorize Section\n end", "def can_read_content?(user)\n released_for_student?(user) || can_edit?(user)\n end", "def has_access_to(cp)\n if can_review(cp) || can_edit(cp) || is_admin\n true\n end\n\n end", "def permits_read_acccess_for(user)\n end", "def enforce_show_permissions(opts={})\n permissions = current_ability.permissions_doc(params[:id])\n if permissions.under_embargo? && !can?(:edit, permissions)\n raise Hydra::AccessDenied.new(\"This item is under embargo. You do not have sufficient access privileges to read this document.\", :edit, params[:id])\n end\n unless can? :read, permissions \n raise Hydra::AccessDenied.new(\"You do not have sufficient access privileges to read this document, which has been marked private.\", :read, params[:id])\n end\n end", "def section_properties; end", "def set_access_level(access_level)\n if access_level >= 1\n self.commenter = true\n else\n self.commenter = false\n end\n if access_level >= 2\n self.editor = true\n else\n self.editor = false\n end\n if access_level >= 3\n self.administrator = true\n else\n self.administrator = false\n end\n end", "def can_read?(user)\n (self.user == user) || course.can_edit?(user)\n end", "def show\n @note = Note.find(params[:id])\n restrict_access(\"notes\") if @note.firm_id != @firm.id \n end", "def section?\n type == \"Section\"\n end", "def show\n #authorize @part\n end", "def read_permissions\n can :read, String do |pid|\n Rails.logger.debug(\"[READPERM] Checking from STRING\")\n test_read(pid)\n end\n\n can :read, [DRI::Batch] do |obj|\n Rails.logger.debug(\"[READPERM] Checking from Object\")\n test_read(obj.id)\n end\n\n\n can :read, SolrDocument do |obj|\n Rails.logger.debug(\"[READPERM] Checking from SolrDoc\")\n cache.put(obj.id, obj)\n test_read(obj.id)\n end\n end", "def section_id\n 'generic'\n end", "def sections(*args); end", "def access_level\n if self.reviewer?\n return 5\n elsif self.administrator?\n return 3\n elsif self.editor?\n return 2\n elsif self.commenter?\n return 1\n end\n end", "def access_level\n if self.reviewer?\n return 5\n elsif self.administrator?\n return 3\n elsif self.editor?\n return 2\n elsif self.commenter?\n return 1\n end\n end", "def permissions_policy(&block); end", "def edit_permissions\n can [:edit, :update], String do |pid|\n Rails.logger.debug(\"[EDITPERM] Checking from STRING\")\n test_edit(pid)\n end\n\n can [:edit, :update, :destroy], DRI::Batch do |obj|\n Rails.logger.debug(\"[EDITPERM] Checking from Batch\")\n test_edit(obj.id)\n end\n\n can [:edit, :update, :destroy], DRI::GenericFile do |obj|\n Rails.logger.debug(\"[EDITPERM] Checking from GenericFile\")\n test_edit(obj.id)\n end\n\n can :edit, SolrDocument do |obj|\n Rails.logger.debug(\"[EDITPERM] Checking from SOLRDOC\")\n cache.put(obj.id, obj)\n test_edit(obj.id)\n end\n end", "def AccessRights=(arg0)", "def can_edit?(user)\n\n end", "def protected\n\tend", "def sub_sections(kind)\n {'actions' => [nil, ActionList, @actions],\n 'realtime' => ['optional', MatchList, real_time, @opts, @file],\n 'periodic' => ['optional', MatchList, periodic, @opts, @file]\n }[kind]\n end", "def enforce_show_permissions(_opts = {})\n permissions = current_ability.permissions_doc(solr_id)\n if (permissions['read_access_group_ssim'].present? && permissions['read_access_group_ssim'].include?('registered')) || can?(:discover, permissions)\n permissions\n else\n raise Blacklight::AccessControls::AccessDenied.new('You do not have sufficient access privileges to view this document, which has been marked private.', :discover, params[:id])\n end\n end", "def inherit_restricted_status\n self.restricted = parent.restricted?\n end", "def edit_subject_areas?\n edit_settings? || owner?\n end", "def child_acl\n acl = super\n acl << {\n 'privilege' => '{DAV:}read',\n 'principal' => @calendar_info['principaluri'],\n 'protected' => true\n }\n\n unless @calendar_info['{http://sabredav.org/ns}read-only']\n acl << {\n 'privilege' => '{DAV:}write',\n 'principal' => @calendar_info['principaluri'],\n 'protected' => true\n }\n end\n\n acl\n end", "def super_sector; end", "def can_edit?(user)\n course.can_edit? user\n end", "def initialize()\n super\n @odata_type = \"#microsoft.graph.onenoteSection\"\n end", "def permissions = {}", "def can_see_comment?(comment); comment.user.admin?; end", "def enforce_edit_permissions(opts={})\n logger.debug(\"Enforcing edit permissions\")\n load_permissions_from_solr\n if !can? :edit, params[:id]\n session[:viewing_context] = \"browse\"\n raise Hydra::AccessDenied.new(\"You do not have sufficient privileges to edit this document. You have been redirected to the read-only view.\", :edit, params[:id])\n else\n session[:viewing_context] = \"edit\"\n end\n end", "def show\n @private_note = PrivateNote.find(params[:id])\n authorize @private_note\n end", "def specialty; end", "def set_access_info(opts)\n opts = check_params(opts,[:access_info])\n super(opts)\n end", "def customize\n # @questionnaire = Questionnaire.find(params[:id], :include => [:permissions])\n @questionnaire = Questionnaire.find(params[:id])\n end", "def show\n authorize @adoc_name\n end", "def privileges(user, parent_priv = nil)\n\t\tif user.admin?\n\t\t\treturn PRIVILEGE_EDIT\n\t\tend\n\t\tif self.creator_id.nil? && user.privilege >= User::PRIVILEGE_STAFF\n\t\t return PRIVILEGE_EDIT\n\t\tend \n\t\tif self.creator_id == user.id\n\t\t\treturn PRIVILEGE_EDIT\n\t\tend\n\t\t\n\t\tparent_priv ||= self.notable.privileges(user)\n\t\t\n\t\treturn PRIVILEGE_EDIT if parent_priv[:edit_note]\n\t\treturn PRIVILEGE_VIEW if parent_priv[:view_note]\n\t\treturn PRIVILEGE_NONE\n\tend", "def edited_with_inheritance_by?(user)\n return true if editors.include?(user)\n return true if teachable&.lecture&.editors&.include?(user)\n return true if teachable&.lecture&.teacher == user\n return true if teachable&.course&.editors&.include?(user)\n false\n end", "def educational_attainment; end", "def authorization; end", "def notes; end", "def notes; end", "def notes; end", "def show_collection_section(collection, section)\n if [\"intro\", \"faq\", \"rules\"].include?(section) # just a check that we're not using a bogus section string\n !collection.collection_profile.send(section).blank? || collection.parent && !collection.parent.collection_profile.send(section).blank?\n end\n end", "def show_section_appraisal_moderated?\n subject.lead?(record) ||\n (\n record.assessor_assignments.moderated.submitted? &&\n (\n subject.primary?(record) ||\n (assessor? && record.from_previous_years?)\n )\n )\n end", "def custom_permissions\n if admin?\n can [:confirm_delete], ActiveFedora::Base\n can [:allow_downloads, :prevent_downloads], AdminSet\n\n can :manage, Spotlight::HomePage\n can :manage, Spotlight::Exhibit\n end\n\n can :read, Spotlight::HomePage\n can :read, Spotlight::Exhibit\n\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n end", "def traits; end", "def action_allowed?\n case params[:action]\n when 'edit'\n @questionnaire = Questionnaire.find(params[:id])\n current_user_has_admin_privileges? ||\n (current_user_is_a?('Instructor') && current_user_id?(@questionnaire.try(:instructor_id))) ||\n (current_user_is_a?('Teaching Assistant') && session[:user].instructor_id == @questionnaire.try(:instructor_id))\n else\n current_user_has_student_privileges?\n end\n end", "def menu_section_id(parms = {})\n parms[:typ] == 'ae' ? :automate : :svc\n end", "def section(ident)\n @sections[ident]\n end", "def show_collection_preface(collection)\n show_collection_section(collection, \"intro\") || show_collection_section(collection, \"faq\") || show_collection_section(collection, \"rules\")\n end", "def levels_can_see\r\n if public? || !Relationshiptype.followers_and_founders_types.include?(relationshiptype_id)\r\n Relationshiptype.followers_and_founders_types\r\n elsif relationshiptype_id == Relationshiptype.nobody\r\n Relationshiptype.founders\r\n else Relationshiptype.circle_and_closer(relationshiptype_id)\r\n end\r\n end", "def discover_groups\n super << Hydra::AccessControls::AccessRight::PERMISSION_TEXT_VALUE_AUTHENTICATED\n end", "def thesis_admin\n processor\n\n can :manage, :all\n cannot 'destroy', :copyright\n cannot 'destroy', :degree\n cannot 'destroy', :department\n cannot 'destroy', :hold_source\n cannot 'destroy', :license\n cannot 'destroy', :thesis\n end", "def common_abilities_for_admins(user)\n can :access, Admin\n can :manage, :all if user.is_admin?\n\n conf_ids_for_organizer = Conference.with_role(:organizer, user).pluck(:id)\n conf_ids_for_cfp = Conference.with_role(:cfp, user).pluck(:id)\n conf_ids_for_info_desk = Conference.with_role(:info_desk, user).pluck(:id)\n\n if conf_ids_for_organizer\n # To access splashpage of their conference if it is not public\n can :show, Conference, id: conf_ids_for_organizer\n # To access conference/proposals/registrations\n can :manage, Registration, conference_id: conf_ids_for_organizer\n # To access conference/proposals\n can :manage, Event, program: { conference_id: conf_ids_for_organizer }\n # To access comment link in menu bar\n can :index, Comment, commentable_type: 'Event',\n commentable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_organizer).pluck(:id)).pluck(:id)\n end\n\n if conf_ids_for_cfp\n # To access comment link in menu bar\n can :index, Comment, commentable_type: 'Event',\n commentable_id: Event.where(program_id: Program.where(conference_id: conf_ids_for_cfp).pluck(:id)).pluck(:id)\n # To access conference/proposals\n can :manage, Event, program: { conference_id: conf_ids_for_cfp }\n end\n\n if conf_ids_for_info_desk\n # To access conference/proposals/registrations\n can :manage, Registration, conference_id: conf_ids_for_info_desk\n end\n end", "def can_edit_own?(attribute)\n return false if person.is_a?(Participant) && %w[firstname lastname high_school_id on_track_to_graduate].include?(attribute.to_s)\n return true if person.is_a?(Student) && %w[high_school_id].include?(attribute.to_s)\n true # Override this method in child classes\n end", "def section_by_id(section_id); end", "def basic\n # Any user can create a new Thesis.\n can :create, Thesis\n can :start, Thesis\n can :confirm, Thesis\n\n # Only the Thesis author can view their Thesis.\n can :read, Thesis, users: { id: @user.id }\n can :update, Thesis, users: { id: @user.id }\n end", "def list_sections\n \n end", "def set_editability\n @editable = user_signed_in? && (current_user.member.role.name.eql? \"University Admin\") &&\n current_user.member.institution.id == @course.department.institution.id\n end", "def primary_terms\n [:title, :description, :source, :rights_note]\n end", "def can_edit?(user)\n Article.can_edit?(user)\n end", "def must_have_edit_permission!(name)\n must_be_creator!(name)\n must_be_only_editor!(name)\n must_own_all_descriptions!(name)\n must_own_all_observations!(name)\n must_own_all_namings!(name)\n end", "def access_type\n @access_type\n end", "def can_edit_study?(user)\n if self.study.queued_for_deletion?\n return false\n else\n return self.study.can_edit?(user)\n end\n end", "def publication_admin(role)\n can :read, Publication, :id => role.publication_id\n can :update, Publication, :id => role.publication_id\n can :manage, Issue, :publication_id => role.publication_id\n can :update, AdminUser, :id => @user.id\n\n end", "def can_edit_patient?\n has_role?(:enroller) || has_role?(:public_health) || has_role?(:public_health_enroller)\n end", "def can_edit? record\n return true if current_user.admin? # admins can edit anything\n case record.class.to_s\n when 'User'\n record.id == current_user.id # regular users can't edit other users\n when 'Warning', 'Interaction', 'Treatment', 'Bulletin', 'ThreadedDiscussionPost', 'Price', 'Comment', 'Guideline'\n record.created_by == current_user.id # these posts can only be edited by their creators\n else true # everyone can edit anything else\n end\n end", "def permitted?\n Article.can_edit?(@user)\n end", "def cat_perms\n ident = :categories\n text = 'Forum permissions'\n desc = 'All permissions that have to do with the forums'\n id_based = false\n options = [:true, :false, :flow]\n def_option = :flow\n\n forum_global = write_permission_group(ident, text, desc, options, def_option)\n\n text = 'See this category'\n desc = 'Gives the user the ability to view this category'\n g = write_permission(text, desc, :see, options, def_option)\n g.add_to_group(forum_global)\n\n text = 'Mass Moderate'\n desc = 'Gives the user the ability to perform mass moderation actions in this category'\n g = write_permission(text, desc, :mass_moderate, options, def_option)\n g.add_to_group(forum_global)\n\n text = 'Create discussions this category'\n desc = 'Gives the user the ability to creat discussions in this category'\n g = write_permission(text, desc, :create, options, def_option)\n g.add_to_group(forum_global)\n\n states = [:normal, :archived, :locked, :stickied]\n\n # Actions\n ident = :actions\n parent_text = '{0} discussions in this category'\n parent_desc = 'Gives the user the ability to {0} to discussions in this category'\n options = [:all, :own, :false, :flow]\n def_option = :flow\n\n actions = write_permission_group(ident, 'Actions', 'Actions corresponding to the root discussion object', options, def_option)\n\n [:sticky, :tag, :lock, :archive].each do |action|\n text = translate_text(parent_text, action.to_s.gsub('_', ' ').capitalize)\n desc = translate_text(parent_desc, action.to_s.gsub('_', ' ').capitalize)\n g = write_permission(text, desc, action, options, def_option)\n g.add_to_group(actions)\n end\n\n actions.add_to_group(forum_global)\n\n # Edit\n ident = 'Discussion States - Edit'\n edit_parent_text = 'Edit {0} discussions in this category'\n edit_parent_desc = 'Gives the user the ability to edit {0} discussions in this category'\n edit = write_permission_group(:edit, ident, 'Permissions for each discussion state in regards to editing', options, def_option)\n # View\n ident = 'Discussion States - View'\n view_parent_text = '{0} {1} discussions in this category'\n view_parent_desc = 'Gives the user the ability to {0} {1} discussions in this category'\n view = write_permission_group(:view, ident, 'Permissions for each discussion state in regards to viewing', options, def_option)\n\n states.each do |action|\n edit_text = translate_text(edit_parent_text, 'Edit', action)\n edit_desc = translate_text(edit_parent_desc, 'Edit', action)\n view_text = translate_text(view_parent_text, 'View', action)\n view_desc = translate_text(view_parent_desc, 'View', action)\n g = write_permission(edit_text, edit_desc, action, options, def_option)\n g1 = write_permission(view_text, view_desc, action, options, def_option)\n g.add_to_group(edit)\n g1.add_to_group(view)\n end\n\n edit.add_to_group(forum_global)\n view.add_to_group(forum_global)\n\n # Reply To\n ident = 'Discussion States - Reply'\n parent_text = 'Reply to {0} discussions in this category'\n parent_desc = 'Gives the user the ability to reply to {0} discussions in this category'\n reply_to = write_permission_group(:reply_to, ident, 'Permissions dealing with replying to different discussion states', options, def_option)\n\n states.each do |action|\n text = translate_text(parent_text, action)\n desc = translate_text(parent_desc, action)\n g = write_permission(text, desc, action, options, def_option)\n g.add_to_group(reply_to)\n end\n\n reply_to.add_to_group(forum_global)\n\n # Replies\n ident = 'Replies'\n parent_text = '{0} {1} replies in this category'\n parent_desc = 'Gives the user the ability to {0} {1} replies in this category'\n replies = write_permission_group(:replies, ident, 'Permissions dealing with replies', options, def_option)\n\n # Edit\n edit = write_permission_group(:edit, 'Replies - Edit', 'Permissions dealing with editing replies', options, def_option)\n\n [:normal, :archived].each do |action|\n text = translate_text(parent_text, 'Edit', action)\n desc = translate_text(parent_desc, 'Edit', action)\n g = write_permission(text, desc, action, options, def_option)\n g.add_to_group(edit)\n end\n\n edit.add_to_group(replies)\n\n actions = write_permission_group(:actions, 'Replies - Actions', 'Permissions dealing with performing actions on replies', options, def_option)\n\n # Archive\n text = translate_text(parent_text, 'Archive', '')\n desc = translate_text(parent_text, 'Archive', '')\n g = write_permission(text, desc, :archive, options, def_option)\n g.add_to_group(actions)\n\n # Sanction\n text = translate_text(parent_text, 'Sanction', '')\n desc = translate_text(parent_text, 'Sanction', '')\n g = write_permission(text, desc, :sanction, options, def_option)\n g.add_to_group(actions)\n\n # Override Time\n text = 'Override post cooldown time'\n desc = 'Gives the user the ability to override the post cooldown time in this category'\n g = write_permission(text, desc, :override_time, [:true, :false, :flow], def_option)\n g.add_to_group(actions)\n\n actions.add_to_group(replies)\n\n # View\n view = write_permission_group(:view, 'Replies - View', 'Permissions dealing with viewing replies', options, def_option)\n\n # Archived\n text = 'View archived replies'\n desc = 'Gives the user the ability to view archived topics in this category'\n g = write_permission(text, desc, :archived, options, def_option)\n g.add_to_group(view)\n\n # Revisions\n text = \"View a post's revisions\"\n desc = 'Gives the user the ability to view revisions from posts in this category'\n g = write_permission(text, desc, :revisions, options, def_option)\n g.add_to_group(view)\n\n view.add_to_group(replies)\n\n replies.add_to_group(forum_global)\n\n global_options = {\n text: 'Forums',\n desc: 'All permissions that have to do with the forums',\n options: options,\n def_option: def_option\n }\n\n PermissionsGenerator.new('Forums', true, global_options, forum_global, [])\nend", "def _section_fields\n {\n 'article' => ['r:Title', 'o:Author', 'o:DOI'],\n 'journal' => ['r:Title', 'o:ISSN', 'r:Volume', 'o:Issue', 'r:Year', 'r:Pages'],\n 'host' => ['o:Title', 'o:ISSN or ISBN', 'o:Volume', 'o:Issue', 'r:Year', 'o:Pages'],\n 'auto-cancel' => ['o:Automatic cancellation'],\n 'notes' => ['o:Notes'],\n 'conference' => ['r:Title', 'o:Location', 'r:Year', 'o:ISSN or ISBN', 'r:Pages'],\n 'book' => ['r:Title', 'o:Author', 'o:Edition', 'o:DOI', 'o:ISBN', 'r:Year', 'o:Publisher'],\n 'thesis' => ['r:Title', 'r:Author', 'o:Affiliation', 'o:Publisher', 'o:Type', 'r:Year', 'o:Pages'],\n 'report' => ['r:Title', 'o:Author', 'o:Publisher', 'o:DOI', 'o:Report Number'],\n 'standard' => ['r:Title', 'o:Subtitle', 'o:Publisher', 'o:DOI', 'o:Standard Number', 'o:ISBN', 'r:Year', 'o:Pages'],\n 'patent' => ['r:Title', 'o:Inventor', 'o:Patent Number', 'r:Year', 'o:Country'],\n 'other' => ['r:Title', 'o:Author', 'o:Publisher', 'o:DOI']\n }\nend", "def role; end", "def role; end", "def custom_permissions_read(_notebook, _user, _use_admin=false)\n true\n end", "def section_for_script(script)\n sections_as_student.find {|section| section.script_id == script.id} ||\n sections.find {|section| section.script_id == script.id}\n end", "def superclass() end", "def sub_sector; end", "def can_edit?(user)\n self == user\n end", "def can_edit?(user)\n self == user\n end", "def can_edit?(user)\n self == user\n end", "def permitted_for!(_course_user)\n raise NotImplementedError, 'Subclasses must implement a permitted_for! method.'\n end", "def show\n authorize Reading\n end", "def initialize(user)\n #anyone can read anything, it's an encyclopedia, right?\n can :read, :all\n\n #if user isn't signed in, there are no more permissions for them\n return if user.nil?\n\n if user.dictator?\n can :manage, :all # they can do anything they want\n can :access, :rails_admin # grant access to rails_admin\n can :dashboard # ditto\n else\n #if they're not a dictator, they're a \"contributor\" and they can only\n #modify the following db objects\n can [:create, :update], [Page, Prerequisite, ConceptBundle, Question, Answer]\n end\n \n end", "def method_missing(method, *args, &body)\n\n if in_set?([\"<<\",\"clear\",\"delete\"],method.to_s)\n\n # DEPRICATED CODE:\n if !call_if_exists(@parent, \"gr_#{@target.proxy_reflection.name.to_s}_w?\")\n guard_rails_error(\"Not authorized to use #{method.to_s} on read-only object\")\n end\n # END OF DEPRICATED CODE\n\n failed = false\n \n # If the parent, the proxy, the Rails proxy, or the array itself\n # fail to allow edits, then the edit methods will be prohibited\n\n if @parent.respond_to?(\"gr_can_edit?\")\n if [email protected]_can_edit?\n failed = true\n end\n end\n if @target.respond_to?(\"gr_can_edit?\")\n if [email protected]_can_edit?\n failed = true\n end\n end\n if self.respond_to?(\"gr_can_edit?\")\n if !self.gr_can_edit?\n failed = true\n end\n end\n if @target.respond_to?(\"proxy_reflection\")\n if [email protected]_can_edit?\n failed = true\n end\n end\n\n # << counts as an append method, so it can be performed, even without\n # write access, as long as one of the objects in quesiton actively \n # allows append access (note that not specifying append access at all)\n # does not count the same as directly saying append access is allowed,\n # as it would with any other type of access control policy\n\n if failed and method.to_s==\"<<\" \n if @parent.respond_to?(\"gr_can_append?\")\n if @parent.gr_can_append?\n failed = false\n end\n end\n if @target.respond_to?(\"gr_can_append?\")\n if @target.gr_can_append?\n failed = false\n end\n end\n if self.respond_to?(\"gr_can_append?\")\n if self.gr_can_append?\n failed = false\n end\n end\n if @target.respond_to?(\"proxy_reflection\")\n if @target.target.gr_can_append?\n failed = false\n end\n end\n # If the method in question is << and there is no\n # append access, the violation policy for append access\n # will be run.\n\n # TODO: check to make sure that this line cannot be \n # reached if << was called but no append access annotation\n # was defined\n return eval_violation(:append_access) if failed\n end\n \n # If the method is blocked for write access reasons, call\n # the appropriate violation method\n eval_violation(:write_access) if failed\n end\n\n # DEPRICATED CODE: Allows specific methods to be singled out as allowed\n # or not based on gr_ methods in the object that \"owns\" this reflection.\n # This feature is currently unused, but might be useful\n special_function = \"gr_#{@target.proxy_reflection.name.to_s}_#{method.to_s}\"\n if @parent.respond_to?(special_function)\n if [email protected](special_function)\n guard_rails_error(\"Not authorized to use #{method.to_s} on this object\")\n end\n end\n # END OF DEPRICATED CODE\n\n # If 'find' is used on the plural association, make sure that none of its\n # parameters contain unsafe SQL (aka call the appropriate 'transform' method\n # on that string).\n if method.to_s == \"find\"\n args = clean_args(args)\n end\n\n # As with all objects potentially pulled from the database, policies need\n # to be set up immediatly\n target.each do |obj|\n obj.populate_policies\n end\n \n # If no errors have been raised up to this point, pass the method on to the\n # target, along with any arguments or block that may have been provided\n if block_given?\n @target.target.send(method,*args,&body)\n else\n @target.send(method,*args,&body)\n end\n end", "def can_edit?(user)\n user == self.user\n end" ]
[ "0.5881289", "0.58406115", "0.5782376", "0.5707754", "0.5632676", "0.5603648", "0.546491", "0.54600567", "0.54448444", "0.53993917", "0.5398793", "0.5328593", "0.5307072", "0.52543974", "0.52543974", "0.5235695", "0.5230199", "0.52281296", "0.52259094", "0.52257186", "0.5211888", "0.5171504", "0.5158445", "0.515473", "0.50932735", "0.5090847", "0.5081221", "0.5078393", "0.50705796", "0.5061571", "0.5061571", "0.50529313", "0.5043336", "0.5041203", "0.503627", "0.5021262", "0.5016977", "0.5012441", "0.5009706", "0.50031227", "0.49775553", "0.49658933", "0.4964188", "0.49590087", "0.49520478", "0.49518308", "0.49402055", "0.49382657", "0.49305713", "0.4929936", "0.4927727", "0.4922314", "0.4920603", "0.49095255", "0.4909303", "0.49085543", "0.49022916", "0.49022916", "0.49022916", "0.4899452", "0.48975456", "0.4892171", "0.48835805", "0.48812366", "0.48733404", "0.48647222", "0.48635712", "0.48510173", "0.48493436", "0.48460838", "0.48413", "0.48374772", "0.4835713", "0.48349306", "0.48249242", "0.48234388", "0.4821923", "0.48189703", "0.48184422", "0.48136067", "0.4812604", "0.48107696", "0.48027918", "0.47988698", "0.47988653", "0.47964108", "0.4790431", "0.4790259", "0.4790259", "0.47891736", "0.4786999", "0.47868776", "0.4780221", "0.47799647", "0.47799647", "0.47799647", "0.47785413", "0.4775418", "0.47705483", "0.47697222", "0.47695008" ]
0.0
-1
Produce the full text of the document by combining the text of each of the pages. Used at initial import.
def combined_page_text self.pages.order('page_number asc').pluck(:text).join('') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def extract_pages_to_text\n reader.pages.each do |page|\n raw_extracted_pages << page.text.split(\"\\n\")\n end\n end", "def content_fulltext(page_xml, paper_title, page_title)\n page_path = Pathname.new(@source)\n basename = page_path.basename.to_s.gsub('.xml', '')\n full_text_path =\n File.join(page_path.parent, basename, paper_title, page_title)\n full_text_file = \"#{full_text_path}/fulltext.txt\"\n FileUtils.mkdir_p full_text_path\n page_text = page_xml.xpath('pagetext').map(&:content).first.to_s\n File.open(full_text_file, \"w\") { |f| f.write(page_text) }\n full_text_file.gsub Pathname.pwd.to_s + \"/\", \"\"\n end", "def docImportHTML\n sourceDir = Pathname.new pathExports\n destDir = Pathname.new pathDocuments\n \n # Process and copy pages to dest dir.\n n = 0\n docPages().each do |page|\n n = n + 1\n \n sourceFile = sourceDir + pageOriginalFile(page) + \"index.html\"\n destPath = destDir + pageTargetFile(page)\n destFile = destPath + \"index.html\"\n \n puts \"Importing File #{n.to_s}: #{sourceFile} #{destFile}\"\n puts \" \"\n \n destPath.mkpath()\n html = File.open(sourceFile, \"rb\") { |f| f.read }\n html = htmlUpdateLinks(html)\n html = htmlStripTOC(html)\n html = htmlReplaceSyntaxHighlighterTags(html)\n html = htmlReplaceTabsWithSpaces(html)\n html = htmlPrettify(html)\n fileSaveContent(destFile, html)\n end\nend", "def get_text_for_indexing_full\n return get_body_for_quoting + \"\\n\\n\" + get_attachment_text_full\n end", "def all_page_part_content\n parts.map(&:body).join \" \"\n end", "def render_refworks_texts(documents)\n val = ''\n documents.each do |doc|\n if doc.exports_as? :refworks_marc_txt\n val += doc.export_as(:refworks_marc_txt) + \"\\n\"\n elsif doc.exports_as? :refworks_archives\n val += doc.export_as(:refworks_archives) + \"\\n\"\n elsif doc.doc.exports_as? :refworks_dcs\n val += doc.export_as(:refworks_dcs) + \"\\n\"\n end\n end\n val\n end", "def all_text\r\n @texts.inject(\"\") {|r, text| r += text + \"\\n\" }\r\n end", "def add_page_to_doc\n @page_content.each { |line| @doc_content += line}\n @pages_in_doc += 1\n if !@doc_start_page\n @doc_start_page = current_page()\n end\n return @doc_content\n end", "def to_s; \"Doc-#{target}\\n#{text}\" end", "def all_page_part_content\n\t content = \"\"\n\t \n\t self.parts.each do |part|\n\t content << \" #{part.body}\"\n\t end\n\t \n\t content\n\tend", "def get_text\n outarr = Array.new\n @data.each do |item|\n paths = item[\"path\"]\n item[\"text\"] = \"\"\n \n # OCR all files and save\n paths.each { |path| item[\"text\"] += ocr_file(\"../docs/\"+path)} if paths\n outarr.push(item)\n end\n @data = outarr\n end", "def text\n @text ||= @reader.pages.map! do |page|\n page.text\n end.flatten.map! do |line|\n line.split /\\n+/\n end.flatten\n end", "def convert!\n merged_contents = []\n @files.each do |file|\n markup = Markup.new file, @remove_front_matter\n html = convert_image_urls markup.render, file.filename\n if @merge\n html = \"<div class=\\\"page-break\\\"></div>#{html}\" unless merged_contents.empty?\n merged_contents << html\n else\n output_pdf(html, file)\n end\n end\n\n unless merged_contents.empty?\n html = merged_contents.join\n output_pdf(html, nil)\n end\n end", "def output_words\n if @number <= self.class.total_included_words\n convert_paragraphs_to_words(self.class.included_paragraphs_joined)\n else\n repeat = (@number / self.class.total_included_words.to_f).ceil\n convert_paragraphs_to_words((PARAGRAPHS * repeat).join(\"\\n\\n\"))\n end\n end", "def fulltext_to_solr\n @solr_document[\"text\"] ||= []\n json = get_json\n \n unless json.nil?\n i = 1\n Array.wrap(json[\"pages\"]).each do |p|\n \n xml = get_alto(i.to_s)\n unless xml.nil?\n alto = Stanford::AltoParser.new\n parser = Nokogiri::XML::SAX::Parser.new(alto)\n parser.parse(xml)\n @solr_document[\"text\"] << alto.text.strip\n i += 1\n end\n end\n end\n end", "def sprint_process_text(doc)\n # there is at least one <pre> with MMS text if text has been included by\n # the user. (note) we'll have to verify that if they attach multiple texts \n # to the MMS then Sprint stacks it up in multiple <pre>'s. The only <pre> \n # tag in the document is for text from the user.\n doc.search(\"/html/body//pre\").each do |pre|\n type = 'text/plain'\n text = pre.inner_html.strip\n next if text.empty?\n type, text = transform_text(type, text)\n type, file = sprint_write_file(type, text.strip)\n add_file(type, file) unless type.nil? || file.nil?\n end\n end", "def extract_text(site, page)\n page.render({}, site.site_payload)\n doc = Nokogiri::HTML(page.output)\n paragraphs = doc.search('p').map {|e| e.text}\n page_text = paragraphs.join(\" \").gsub(\"\\r\",\" \").gsub(\"\\n\",\" \")\n end", "def build_book_all_in_one_old_code_remove\r\n\r\nbook_text = <<EOS\r\n---\r\nlayout: book\r\ntitle: Contents\r\npermalink: /book.html\r\n---\r\n\r\nEOS\r\n\r\nbook_text += render_toc( inline: true )\r\n\r\n\r\n### generate pages for countries\r\n# note: use same order as table of contents\r\n\r\ncountry_count=0\r\n\r\nContinent.all.each do |continent|\r\n continent.countries.order(:title).each do |country|\r\n\r\n beers_count = country.beers.count\r\n breweries_count = country.breweries.count\r\n next if beers_count == 0 && breweries_count == 0\r\n \r\n country_count += 1\r\n puts \"build country page #{country.key}...\"\r\n country_text = render_country( country )\r\n\r\n book_text += <<EOS\r\n\r\n---------------------------------------\r\n\r\nEOS\r\n\r\n book_text += country_text\r\n end\r\nend\r\n\r\n\r\nFile.open( '_pages/book.md', 'w+') do |file|\r\n file.write book_text\r\nend\r\n\r\nend", "def render_archives_texts(documents)\n\n val = ''\n documents.each do |doc|\n archives = {\n \"RT\" => \"Archives or Manuscripts\",\n \"A1\" => doc['author_display'].present? ? doc['author_display'][0].to_s : doc['author_display'].to_s,\n \"JF\"=> doc['found_in_labels_ss'].to_s,\n \"VO\"=> doc['container_display'].present? ? doc['container_display'][0].to_s : doc['container_display'].to_s, #Volume container\n \"T1\"=> doc['title_display'].present? ? doc['title_display'][0].to_s : doc['title_display'].to_s,\n \"UL\"=> \"https://archives.yale.edu/#{doc['archive_space_uri_s'].to_s}\",\n \"RD\"=> Date.today\n }\n archives.each {|key|\n j_value = key[1].kind_of?(Array)? key[1][0].to_s : key[1].to_s\n val << \"#{key[0].to_s} #{j_value}\\n\" }\n val << \"\\n\"\n end\n val\n end", "def possible_texts\n @possible_texts ||= (pages[0, 5] + pages[(page_count / 4)...(page_count / 2)]).sample(5)\n end", "def combined_content\n output = @other_content_top ? \"#{@other_content_top.join(\"\\n\")}\\n\" : ''\n was_color = Color.coloring?\n Color.coloring = false\n @content.dedup!(match_section: true)\n output += @content.to_s\n output += @other_content_bottom.join(\"\\n\") unless @other_content_bottom.nil?\n # Just strip all ANSI colors from the content before writing to doing file\n Color.coloring = was_color\n\n output.uncolor\n end", "def upload_text_assets(pages, access)\n asset_store.save_full_text(self, access)\n pages.each do |page|\n asset_store.save_page_text(self, page.page_number, page.text, access)\n end\n end", "def build_docs\n object_map.each do |index, objects|\n objects.each do |object|\n template_context = {\n #:meta => Site\n index => object\n }\n content = converter.render(template_map[index], template_context)\n filename = converter.filename_for(object)\n write_output_file(filename, content)\n end\n end\n end", "def prepare_text\n feed_url = FeedUrl.where(:language_id => language_id).order(\"RANDOM()\").limit(1).first.try(:url)\n if feed_url && (feed = FeedNormalizer::FeedNormalizer.parse(feed_url))\n feed_text = feed.entries[0..3].map(&:content)\n self.text = ''\n feed_text.each do |ft|\n self.text += content_tag(:p, sanitize(HTMLEntities.new.decode(ft), :tags => \"\", :attributes => \"\"))\n end\n end\n end", "def to_s\n doc_sep = Mhtml::DOUBLE_LINE_BREAK + BOUNDARY_PREFIX + @boundary + \n Mhtml::LINE_BREAK\n super + doc_sep + @sub_docs.join(doc_sep)\n end", "def to_docbook( *rules )\n @stack = Array.new\n @ids = Array.new\n @references = Array.new\n @automatic_content_ids = Array.new\n\n rules = DEFAULT_RULES if rules.empty?\n # make our working copy\n text = self.dup\n \n @urlrefs = {}\n @shelf = []\n @rules = rules.collect do |rule|\n case rule\n when :docbook\n DOCBOOK_RULES\n else\n rule\n end\n end.flatten\n \n # standard clean up\n incoming_entities text \n clean_white_space text \n\n # start processor\n @pre_list = []\n pre_process_docbook text\n\n no_docbook text\n docbook_rip_offtags text\n docbook_hard_break text\n\n refs text\n docbook_blocks text\n inline text\n \n smooth_offtags text\n retrieve text\n \n post_process_docbook text\n clean_html text if filter_html\n text.strip!\n \n text << \"\\n\"\n @stack.each_with_index {|sect,index| text << \"</sect#{@stack.size-index}>\\n\"}\n text << \"</chapter>\" if @chapter\n \n if (@references - @ids).size > 0\n text << %{<chapter label=\"86\" id=\"chapter-86\"><title>To Come</title>}\n (@references - @ids).each {|name| text << %!<sect1 id=\"#{name}\"><title>#{name.split('-').map {|t| t.capitalize}.join(' ')}</title><remark>TK</remark></sect1>\\n!}\n text << \"</chapter>\"\n end\n \n text\n\n end", "def text_content\n body = doc.css(\"body\")\n text_table = body.css(\".grf-indent > div:nth-child(1)\")[0]\n if text_table.present?\n remove_metadata(text_table)\n remove_creator(text_table)\n text_table.inner_html\n end\n end", "def generate_primary_xml( doc )\n \n # generate a list of paths to xml files for each page\n pages = []\n (1..doc.total_pages).each do | num |\n pg = File.basename( doc.get_document_page_xml_file( doc.document_id, num, :alto ) )\n pages << pg\n end\n\n\n # Create the XML document this binds all of theses pages together with a title\n xml_doc = Nokogiri::XML::Builder.new do |xml|\n xml.doc.create_internal_subset( 'book', nil, 'book.dtd' )\n xml.book {\n xml.bookInfo {\n xml.documentId \"#{doc.document_id}\"\n }\n xml.citation {\n xml.titleGroup {\n xml.fullTitle \"#{doc.title}\"\n }\n }\n xml.text_ {\n pages.each do |pg|\n xml.page( :fileRef => pg )\n end\n }\n }\n end\n\n # Dump the file to TW filesystem\n xml_file = doc.get_primary_xml_file()\n File.open( xml_file, \"w\" ) { |f| f.write( xml_doc.doc.to_xml ) }\n puts \"Wrote pimary XML file #{xml_file}\"\nend", "def parse_text\r\n @text_nodes.map(&:content).join('')\r\n end", "def parse_text\r\n @text_nodes.map(&:content).join('')\r\n end", "def process_full_text(text)\n frag = Nokogiri::HTML::DocumentFragment.parse text.to_html\n clean_text = Nokogiri::HTML::DocumentFragment.parse \"\"\n\n frag.traverse do |node|\n # skip empty <br> elements\n next if node.nil? || node.name == \"br\"\n\n # Construct a new <p> with extracted text\n if node.text?\n new_p = Nokogiri::XML::Node.new(\"p\", clean_text)\n new_p.content = node.text.strip\n clean_text << new_p\n end\n end\n clean_text.to_html\n end", "def map_words_on_page\n fetcher = FetchUrl.new\n page_content = fetcher.fetch(self[:url]).body\n\n processor = PageProcessor.new\n processor.process_page page_content\n end", "def index\n @text_on_pdfs = TextOnPdf.all\n end", "def html_markup_asciidoc(text); end", "def finish_preparations\n munge\n @document.attributes['alternative_language_counter'] = @counter + 1\n @listing_text = @listing.convert\n @colist_text = @colist&.convert\n end", "def tex_cleanup\n puts ' cleanup obsolete stuff in LaTeX'\n document.content.gsub! /\\\\textbackslash\\{}printbibliography/, '\\printbibliography'\n document.content.gsub! /\\\\textbackslash\\{}cite\\\\\\{(.*?)\\\\}/, '\\cite{\\1}'\n\n puts ' increase heading levels'\n # for the annual report the level of headings of the project reports need to be increased\n # a) headings within a project need to be named paragraphs\n document.content.gsub! /\\\\subsection{(.*)}\\\\label/, '\\subsubsection{\\1}~\\\\\\label'\n # b) project titles need to be two levels down\n document.content.gsub! /\\\\section{(.*)}\\\\label/, '\\subsection{\\1}\\label' # TODO: do we need that here?\n\n # to fix multiple occurrences of labels in the aggregated report, we prepend each label with\n # the project's slug\n document.content.gsub! /\\\\label{([\\w-]*)}/, \"\\\\label{#{document.data['slug']}-\\\\1}\"\n\n # wrap the project's report in it's own _biblatex_ reference section\n document.content.prepend(\"\\\\begin{refsection}[projects/#{document.data['slug']}]\\n\\n\")\n document.content += \"\\n\\\\end{refsection}\\n\"\n\n # add the project's title\n document.content.prepend(\"\\\\subsection{#{document.data['title']}}\\\\label{#{document.data['title'].downcase.gsub(/\\s/, '-')}}\\n\\n\")\n end", "def texts=(texts); end", "def texts=(texts); end", "def get_text_only(doc)\n text = StringIO.new\n if doc.kind_of?(Hpricot::Text)\n text.printf(\"%s\\n\", doc.to_s.strip) unless doc.to_s.strip.empty?\n else\n if doc.respond_to?(:children)\n doc.children.each do |child|\n text.printf(\" %s\", get_text_only(child))\n end\n end\n end\n text.string.strip\n end", "def call\n total = dataset.document_count\n ret = {}\n\n enum = RLetters::Datasets::DocumentEnumerator.new(dataset: dataset)\n enum.each_with_index do |doc, i|\n progress&.call((i.to_f / total.to_f * 100).to_i)\n\n lister = Documents::WordList.new\n words = lister.words_for(doc.uid)\n\n tagged = Tagger.add_tags(words.join(' '))\n next if tagged.nil?\n\n nouns = Tagger.get_nouns(tagged)\n next if nouns.nil?\n\n ret.merge!(nouns) { |_, v1, v2| v1 + v2 }\n end\n\n progress&.call(100)\n ret.sort_by { |(_, v)| -v }\n end", "def completed_text_extraction\n end", "def render_inproceedings(p)\n r = \"\"\n r += p.authors.map {|a| a.abbreviated_name}.joined_by_comma_and_and + \". \"\n r += p.title.detex.titlecase + \". \"\n r += \"In \"\n\n if p.editors.size > 0 then\n r += p.editors.map {|e| e.abbreviated_name}.joined_by_comma_and_and + \", editors, \"\n end\n\n r += text_for_field(\"Booktitle\", p, :postfix => \"\").detex\n\n # TODO simplify this complex nested if structures that result from the conversion\n # from BibDesks abbrv template\n if field(p,\"Volume\") then # <$fields.Volume?>\n r += text_for_field(\"Volume\", p, :prefix => \", volume \", :postfix => \"\") # <$fields.Volume/>\n if field(p,\"Series\") then # <$fields.Series?>\n r += text_for_field(\"Series\", p, :prefix => \" of \", :postfix => \"\") # <$fields.Series/>\n end # </$fields.Series?>\n else #<?$fields.Volume?>\n if field(p,\"Number\") then # <$fields.Number?>\n r += text_for_field(\"Number\", p, :prefix => \" , number \", :postfix => \"\") #<$fields.Number/>\n if field(p,\"Series\") then # <$fields.Series?>\n r += text_for_field(\"Series\", p, :prefix => \" in \", :postfix => \"\") # <$fields.Series/>\n end #</$fields.Series?>\n else #<?$fields.Number?>\n r += text_for_field(\"Series\", p, :prefix => \", \", :postfix => \"\") # <$fields.Series.stringByPrependingCommaAndSpaceIfNotEmpty/>\n end # </$fields.Number?>\n end # </$fields.Volume?>\n\n if field(p,\"Pages\") then\n r += text_for_field(\"Pages\", p, :prefix => \", pages \", :postfix => \". \").detex\n else\n r += \". \"\n end\n\n if field(p,\"Address\") then # <$fields.Address?>\n r += text_for_field(\"Address\", p, :prefix => \" , \", :postfix => \" \") # , <$fields.Address/>\n r += month_for_field(\"Month\", p, :prefix => \" , \", :postfix => \" \") # , <$fields.Month.stringByAppendingSpaceIfNotEmpty/>\n r += text_for_field(\"Year\", p, :postfix => \". \").detex # <$fields.Year/>. \n r += text_for_field(\"Organization\", p, :postfix => \", \").detex # <$fields.Organization/> , \n r += text_for_field(\"Publisher\", p, :postfix => \" \").detex # <$fields.Publisher/>\n else # <?$fields.Address?>\n r += text_for_field(\"Organization\", p, :prefix => \", \", :postfix => \", \").detex # <$fields.Organization/> ,\n r += text_for_field(\"Publisher\", p, :postfix => \", \").detex # <$fields.Publisher/> , \n r += month_for_field(\"Month\", p, :postfix => \" \") # <$fields.Month.stringByAppendingSpaceIfNotEmpty/>\n r += text_for_field(\"Year\", p).detex # <$fields.Year/>. \n end # </$fields.Address?>\n\n r += text_for_field(\"Note\", p, :prefix => \", \").detex # <$fields.Note.stringByPrependingFullStopAndSpace/>.\n r += \".\"\n return r\nend", "def get_text_for_indexing_clipped\n return get_body_for_quoting + \"\\n\\n\" + get_attachment_text_clipped\n end", "def text\n map(&:text).join\n end", "def to_text\n ocr_files.map do |resource|\n url = full_text_url(resource['id'])\n content = full_text_content(url)\n if xml_ocr_types.include?(resource['mimetype'])\n alto_xml_string_content(content)\n elsif html_ocr_types.include?(resource['mimetype'])\n hocr_string_content(content)\n else # plain text\n content.scrub.encode('UTF-8', invalid: :replace, undef: :replace, replace: '?').gsub(/\\s+/, ' ')\n end\n end\n end", "def render_dcs_ris_texts(documents) # also can be used as refwork export\n val = ''\n documents.each do |doc|\n dcs = {\n \"TY\" => doc['metadata_source_ss']&.include?('Voyager') ? \"Book\" : \"Archives or Manuscripts\",\n \"AU\" => doc['author_display'].present? ? doc['author_display'][0].to_s : doc['author_display'].to_s,\n \"PB\"=> doc['full_publisher_display']&.first,\n \"CY\" => doc['creation_place_facet']&.to_s,\n \"PY\" => doc['dcs_date_ss']&.first,\n \"VL\"=> doc['container_display'].present? ? doc['container_display'][0].to_s : doc['container_display'].to_s, #Volume container\n \"T1\"=> doc['title_display'].present? ? doc['title_display'][0].to_s : doc['title_display'].to_s,\n \"UR\"=> doc[:dcs_uri_ss],\n \"Y2\"=> Date.today\n }\n dcs.each {|key|\n j_value = key[1].kind_of?(Array)? key[1][0].to_s : key[1].to_s\n val << \"#{key[0].to_s} - #{j_value}\\n\" }\n val << \"ER -\\n\"\n val << \"\\n\"\n end\n val\n end", "def to_s\n\t\t# String to return\n\t\tstr = String.new\n\n\t\t# For each line in the current page\n\t\t# Concat it to the String to return\n\t\t@pages[ @ptr ].each do |line|\n\t\t\tstr += line\n\t\tend\n\t\n\t\t# Return result\n\t\tstr\n\n\tend", "def extract_text(elements)\n elements.map { |text| base_class.new(text).export }.join\n end", "def text(*val)\n if val.empty?\n return @list\n end\n $log.debug \" TEXTPAD inside text() with #{val.class} \"\n case val\n when Array\n # either its an array of strings\n # or its an array, and val[0] is an array of strings, and val[1] is a hash / symbol TODO\n case val[0]\n when String\n # This is the usual simple case of an array of strings\n @list = val\n $log.debug \" creating TEXTDOC 0 with String\"\n when TextDocument\n # this is repeating it seems FIXME\n $log.debug \" creating TEXTDOC 04 with TextDocu #{val[0].content_type} \"\n\n @document = val[0]\n @document.source ||= self\n @document.parse_required # added 2014-09-03 - 17:54\n @list = @document.text\n when Array\n # This is the complex case which i would like to phase out.\n # Earlier this was what was used where the second arg was an optional hash\n @list = val[0]\n if val[1].is_a? Symbol\n content_type = val[1]\n hsh = { :text => @list, :content_type => content_type }\n $log.debug \" creating TEXTDOC 1 with #{content_type} \"\n @document = TextDocument.new hsh\n @document.source = self\n elsif val[1].is_a? Hash\n # this is hack for those cases where ct is there, but the caller may not\n # pass it in config\n if val[1].key? :content_type and val[1][:content_type].nil?\n ;\n else\n # content type comes nil from viewer/help which sets it later using block yield\n content_type = val[1][:content_type]\n stylesheet = val[1][:stylesheet]\n @title = val[1][:title] if val[1].key? :title\n $log.debug \" creating TEXTDOC 2 with ct=#{content_type}, #{val[1]} \"\n @document = TextDocument.new val[1]\n @document.text = @list\n @document.source = self\n end\n else\n #raise \"val_1 Unable to do anything with #{val[1].class} \"\n $log.debug \" val_1 Unable to do anything with #{val[1].class} in textpad text()\"\n end\n else\n raise \"val_0 Unable to do anything with #{val[0].class} \"\n end\n when Hash\n $log.debug \" creating TEXTDOC 3 with #{val[:content_type]} \"\n @document = TextDocument.new val\n @document.source ||= self\n @list = @document.text\n when TextDocument\n $log.debug \" creating TEXTDOC 4 with TextDocu #{val.content_type} \"\n\n @document = val\n @document.source ||= self\n @document.parse_required # added 2014-09-03 - 17:54\n @list = @document.text\n end\n @_populate_needed = true\n @repaint_all = true\n @repaint_required = true\n init_vars\n # i don't want the whole thing going into the event 2014-06-04\n fire_property_change :text, \"dummmy\", \"text has changed\"\n self\n end", "def import_markup_text( file_content )\n count = 0\n if file_content.scan(PTN_LINE)[0] =~ /tattertools/\n file_content = convert_tatter_xml( file_content )\n return file_content\n end\n count += create_pages( :content => file_content )\n count\n end", "def text\n ignores = [\n :text, :to_solr, :contribs, :img_src, :media_srcs,\n :captions_src, :transcript_src, :rights_code,\n :access_level, :access_types, :title, :ci_ids, :display_ids,\n :instantiations, :outside_url,\n :reference_urls, :exhibits, :special_collection, :access_level_description,\n :img_height, :img_width, :player_aspect_ratio,\n :player_specs, :transcript_status, :transcript_content,\n :playlist_group, :playlist_order, :playlist_map,\n :playlist_next_id, :playlist_prev_id, :supplemental_content, :contributing_organization_names,\n :contributing_organizations_facet, :contributing_organization_names_display, :producing_organizations,\n :producing_organizations_facet, :build_display_title\n ]\n\n @text ||= (PBCore.instance_methods(false) - ignores)\n .reject { |method| method =~ /\\?$/ } # skip booleans\n .map { |method| send(method) } # method -> value\n .select { |x| x } # skip nils\n .flatten # flattens list accessors\n .map { |x| x.respond_to?(:to_a) ? x.to_a : x } # get elements of compounds\n .flatten.uniq.sort\n end", "def texts; end", "def render_dcs_texts(documents)\n val = ''\n documents.each do |doc|\n dcs = {\n \"RT\" => \"Digital Collections\",\n \"SR\" => \"Online\",\n \"A1\" => doc['author_display'],\n \"CN\" => doc['dcs_call_number_ss']&.first,\n \"PB\" => doc['full_publisher_display']&.first,\n \"YR\" => doc['dcs_date_ss']&.first,\n \"PP\" => doc['creation_place_facet']&.to_s,\n \"VO\" => doc['container_display'].present? ? doc['container_display'][0].to_s : doc['container_display'].to_s, #Volume container\n \"T1\" => doc['title_display'].present? ? doc['title_display'][0].to_s : doc['title_display'].to_s,\n \"AB\" => doc['abstract_hl']&.to_s,\n \"UL\" => doc[:dcs_uri_ss],\n \"RD\" => Date.today\n }\n dcs.each {|key|\n j_value = key[1].kind_of?(Array)? key[1][0].to_s : key[1].to_s\n val << \"#{key[0].to_s} #{j_value}\\n\" }\n val << \"\\n\"\n end\n val\n end", "def text\n document.text\n end", "def index_pages\n debug_msg \" generating pages search index\"\n\n pages = @files.select do |file|\n file.text?\n end\n\n pages.each do |page|\n debug_msg \" #{page.page_name}\"\n record = page.search_record\n @index[:searchIndex] << search_string(record.shift)\n @index[:longSearchIndex] << ''\n record.shift\n @index[:info] << record\n end\n end", "def combineLines(theLines)\n\n\ttheText = \"\";\n\t\n\ttheLines.each do |theLine|\n\t\ttheText += theLine[:text] + theLine[:comment] + \"\\n\";\n\tend\n\n\treturn theText;\n\nend", "def index\n @texts = Text.order(:id).page(params[:page])\n end", "def sub_text(tag)\n @doc.css(tag).each do |el|\n el.content = yield el.content\n end\nend", "def children_to_docx; end", "def text\n @parts.join\n end", "def collect_document(input, output)\r\n inputs=input.map{|xx| xx.esc.to_osPath }.join(\" \") # qoute cond combine the inputs\r\n\r\n #now combine the input files\r\n @log.info(\"combining the input files\")\r\n cmd=\"pandoc -s -S -o #{output} --ascii #{inputs}\" # note that inputs is already quoted\r\n system(cmd)\r\n if $?.success? then\r\n PandocBeautifier.new().beautify(output)\r\n end\r\n end", "def add_paragraphs\n lines = seperate_lines\n max_index = lines.size - 1\n (1..(max_index)).each do |index|\n previous_line = lines[index -1]\n current_line = lines[index]\n next_line = lines[index + 1]\n if current_line[0] != (\"#\" || \"\\n\" || \"</p>\")\n if previous_line[0] == \"\\n\"\n lines.insert(index, \"<p>\\n\")\n elsif next_line[0] == \"\\n\"\n lines.insert(index + 1, \"\\n</p>\")\n elsif next_line == nil\n lines << \"\\n</p>\"\n else\n lines\n end\n end\n end\n @doc = lines.join\n end", "def render_archives_ris_texts(documents)\n val = ''\n documents.each do |doc|\n archives = {\n \"TY\" => \"Archives or Manuscripts\",\n \"AU\" => doc['author_display'].present? ? doc['author_display'][0].to_s : doc['author_display'].to_s,\n \"PB\"=> doc['found_in_labels_ss'].to_s,\n \"VL\"=> doc['container_display'].present? ? doc['container_display'][0].to_s : doc['container_display'].to_s, #Volume container\n \"T1\"=> doc['title_display'].present? ? doc['title_display'][0].to_s : doc['title_display'].to_s,\n \"UR\"=> \"https://archives.yale.edu/#{doc['archive_space_uri_s'].to_s}\",\n \"Y2\"=> Date.today\n }\n archives.each {|key|\n j_value = key[1].kind_of?(Array)? key[1][0].to_s : key[1].to_s\n val << \"#{key[0].to_s} - #{j_value}\\n\" }\n val << \"\\n\"\n end\n val\n end", "def build\n html = []\n scripts.each do |script|\n code = File.read(script)\n html << %[<div class=\"file\" id=\"#{script}\"><pre>]\n html << highlight(code)\n html << %[</pre></div>]\n end\n text = html.join(\"\\n\")\n text = interlink(text)\n text = garnish(text)\n text\n end", "def children_to_docx\n ''\n end", "def collect_pages\n #find page terminator\n start_line = 0\n current_line = 0\n @lines.each_with_index do |line, i|\n current_line = i\n if end_of_page?(line, i)\n @pages << Page.new(start_line, i) # every page in raw document\n start_line = i + 1 \n end \n end #end of line.each\n \n if current_line > start_line\n page = Page.new(start_line, current_line)\n @pages << page\n end\n #puts \" collect_pages found #{@pages.length} pages\"\n @pages \n end", "def next_page\n @page_content = []\n pagefile = File.open(@pagefilename, \"r\")\n while (l = pagefile.gets)\n @page_content << l\n end\n \n @nextpagenum += 1\n @pagefilename = @pagefile_prefix + @nextpagenum.to_s + \".txt\"\n \n return @page_content \n end", "def text hard_break = ''\n @parts.map do |part|\n if RDoc::Markup::HardBreak === part then\n hard_break\n else\n part\n end\n end.join\n end", "def content\n PlainTextExtractor.extract_content_from(complete_path)\n end", "def documents\n # This function and its helpers are side-effecty for speed\n @documents ||= raw[:hits][:hits].map do |hit|\n doc = extract_source(hit)\n copy_underscores(hit, doc)\n copy_highlight(hit, doc)\n doc\n end\n end", "def compile\n table = TOC.new(self).table\n if table == []\n return content || ''\n else\n text = content + \"\\n\\n\" || ''\n table.each do |item |\n section = DocumentRepository.find(item.id)\n if section != nil\n text << section.compile << \"\\n\\n\"\n end\n end\n return text\n end\n end", "def html_markup_org(text); end", "def iiif_fulltext\n\niiif_identifier = params[:iiif_identifier]\n\npage_metadata = \"http://10.7.130.237:8983/solr/rspace/pages?fl=transcript,title,description,pageorder,subject-topical,id,rspace-id&q=iiif:#{iiif_identifier}&wt=json\"\npage = open(page_metadata).read\npage = JSON.parse(page)\n\ntitle = page[\"response\"][\"docs\"][0][\"title\"]\nunless page[\"response\"][\"docs\"][0][\"transcript\"].nil? \n\ttranscript = \"<p>Transcript:</p><p>\" + page[\"response\"][\"docs\"][0][\"transcript\"] + \"</p>\"\nend\nunless page[\"response\"][\"docs\"][0][\"description\"].nil? \n\tdescription = \"<p>Description:</p><p>\" + page[\"response\"][\"docs\"][0][\"description\"] + \"</p>\" \nend\nunless page[\"response\"][\"docs\"][0][\"date\"].nil? \n\tdate = \"<p>Date:</p><p>\" + page[\"response\"][\"docs\"][0][\"date\"] + \"</p>\" \nend\nunless page[\"response\"][\"docs\"][0][\"subject-topical\"].nil? \n\tsubjecttopic = \"<p>Subject (Topical):</p><p>\" + page[\"response\"][\"docs\"][0][\"subject-topical\"].join(\"<br />\").html_safe + \"</p>\" \nend\nunless page[\"response\"][\"docs\"][0][\"subject-geographic\"].nil? \n\tsubjectgeo = \"<p>Subject (Geographic):</p><p>\" + page[\"response\"][\"docs\"][0][\"subject-geographic\"].join(\"<br />\").html_safe + \"</p>\" \nend\nunless page[\"response\"][\"docs\"][0][\"rspace-id\"].nil? \n rspaceid = \"<p>Admin ID:</p><p>\" + page[\"response\"][\"docs\"][0][\"rspace-id\"] + \"</p>\" \nend\nunless page[\"response\"][\"docs\"][0][\"pid\"].nil? \n pid = \"<p>PID:</p><p>\" + page[\"response\"][\"docs\"][0][\"id\"] + \"</p>\" \nend\nrender html: \"<p>Title:</p><p>#{title}</p>#{date}#{description}#{transcript}#{subjecttopic}#{subjectgeo}#{rspaceid}\".html_safe\n\n#render \"page\"\nend", "def text page\n @client.text page\n end", "def new_doc\n @doc_content = \"\"\n @doc_start_page = nil\n @pages_in_doc = 0\n end", "def included_paragraphs_joined\n PARAGRAPHS.join(\"\\n\\n\")\n end", "def text\n # .dup is required because the String is frozen.\n mark(@doc.text.first.dup)\n end", "def extractFullText( text, text_format=TEXT_FORMAT_ALTO )\n keywords = String.new\n if( text_format == TEXT_FORMAT_ALTO )\n keywords = extractFullTextFromAlto( text )\n end\n #keywords.join( \" \" )\n end", "def build_html\n # the first one should not use a locale, for the default:\n generate_all_html_pages\n\n # now translate, if necessary:\n if translation.should_translate?\n translation.prepare\n translation.available_locales.each do |locale|\n translation.current_locale = locale\n generate_all_html_pages\n end\n end\n end", "def init_textuals\n set_content_type\n return if image?\n\n if source_from != 'google_drive'\n\n yomu = Yomu.new (Rails.env.production? ? document.url : document.path)\n\n if !yomu.nil?\n text = yomu.text\n text_utf8 = text.force_encoding(\"UTF-8\")\n self.update_columns(file_content_text: text_utf8)\n yomu = nil\n end\n end\n\n # Prioritize markdown.\n if self.file_content_md\n markdown_to_html_and_text\n elsif self.file_content_html\n clean_html if self.source_from == 'google_drive'\n html_to_markdown\n html_to_plain\n elsif self.file_content_text\n text_to_md\n text_to_html\n elsif self.image?\n # do nothing\n else\n errors.add(\"There is no textual content for work id: #{self.id}\")\n end\n make_diffs\n self.delay(:queue => 'preview_maker', priority: 20).create_preview_png\n end", "def collapse_document(doc); end", "def extract_text\n # check if we have a filter\n return if FILTERS[self.content_type].nil?\n\n # Create temporary working directory directory\n FileUtils.mkdir_p(File.join(RAILS_ROOT, 'tmp', 'documents'))\n\n # Find path to convert script\n convert_script = File.join(RAILS_ROOT, 'script', FILTERS[self.content_type])\n\n # Get paths to temp in/out file\n temp_file_in = self.create_temp_file.path\n temp_file_out = File.join(RAILS_ROOT, 'tmp', 'documents',\"#{self.id}.txt\")\n\n # Convert\n if system \"#{convert_script} #{temp_file_in} #{temp_file_out}\"\n self.content = File.read(temp_file_out)\n File.unlink(temp_file_out)\n else\n self.content = \"NO CONTENT\"\n end\n self.save\n end", "def index\n @text_contents = TextContent.all\n end", "def inner_text\n map { |x| x.inner_text }.join\n end", "def get_complete_text\n text = @header.dup\n text.concat(\".\\n\\n\")\n text.concat(@body)\n end", "def full_text\n return self.text[:full_text]\n end", "def render_manual(p)\n r = \"\"\n if p.authors.size > 0 then\n r += p.authors.map {|a| a.abbreviated_name}.joined_by_comma_and_and + \". \"\n end\n\n r += p.title.detex.titlecase + \". \"\n r += text_for_field(\"Organization\", p, :postfix => \", \").detex\n r += text_for_field(\"Address\", p, :postfix => \", \").detex\n\n if field(p,\"Edition\") then\n r += text_for_field(\"Edition\", p).titlecase.detex + \" edition, \"\n end\n\n r += month_for_field(\"Month\", p, :postfix => \" \").detex\n r += text_for_field(\"Year\", p, :postfix => \". \").detex\n r += text_for_field(\"Note\", p, :postfix => \". \").detex\n return r\nend", "def multiple_news_to_html news\n news.inject(\"\") do |items, item|\n items + news_to_html(item)\n end\nend", "def do_clip(pagename, titletxt, onlytext = false)\n pagepath = (\"#{Wiki_path}/data/pages/#{clean_pagename(pagename)}.txt\").gsub(\":\",\"/\")\n\n curpage = cururl.split(\"/\").last\n sel = has_selection\n\n # format properly if citation\n unless onlytext\n if curpage.index(\"ref:\")\n curpage = \"[@#{curpage.split(':').last.downcase}]\"\n elsif cururl.index(\"localhost/wiki\")\n curpage = \"[[:#{capitalize_word(curpage.gsub(\"_\", \" \"))}]]\"\n else\n title = (titletxt ? titletxt : curtitle)\n curpage =\"[[#{cururl}|#{title}]]\"\n end\n else\n curpage = ''\n end\n\n insert = (sel ? \"#{sel} \" : \" * \" ) # any text, or just a link (bullet list)\n insert.gsubs!( {:all_with=> \"\\n\\n\"}, \"\\n\", \"\\n\\n\\n\" )\n\n if File.exists?(pagepath)\n prevcont = File.read(pagepath)\n\n haslinks = prevcont.match(/\\-\\-\\-(\\n \\*[^\\n]+?)+?\\Z/m) # a \"---\"\" followed by only lines starting with \" * \"\n\n # bullet lists need an extra blank line after them before the \"----\"\n if sel\n divider = (haslinks ? \"\\n\\n----\\n\" : \"\\n----\\n\")\n else\n divider = (haslinks ? \"\\n\" : \"\\n----\\n\")\n end\n\n growltext = \"Selected text added to #{pagename}\"\n else\n prevcont = \"h1. #{capitalize_word(pagename)}\\n\\n\"\n growltext = \"Selected text added to newly created #{pagename}\"\n end\n filetext = [prevcont, divider, insert, curpage].join\n dwpage(pagename, filetext)\n\n growl(\"Text added\", growltext)\nend", "def merge(fulltext_reader)\n fulltext_reader.dump_data do |data|\n @io.write data \n end\n end", "def xpath_get_all_text(doc)\n doc.text\n end", "def render_article(p)\n r = \"\"\n r += p.authors.map {|a| a.abbreviated_name}.joined_by_comma_and_and + \". \"\n r += p.title.detex.titlecase + \". \"\n\n r += text_for_field(\"Journal\", p, :postfix => \", \").detex\n r += text_for_field(\"Volume\", p)\n r += text_for_field(\"Number\", p, :prefix => \"(\", :postfix => \")\").detex\n\n # TODO simplify this complex nested if structures that result from the conversion\n # from BibDesks abbrv template\n if field(p,\"Pages\") then # <$fields.Pages?>\n if field(p,\"Volume\") then # <$fields.Volume?>\n r += \":\"\n else # <?$fields.Volume?>\n if field(p,\"Number\") then #<$fields.Number?>\n r+= \":\"\n else # <?$fields.Number?>\n r += \"page \"\n end # </$fields.Number?>\n end # </$fields.Volume?>\n\n r += text_for_field(\"Pages\", p, :postfix => \", \").detex # <$fields.Pages/>,\n else # <?$fields.Pages?>\n if field(p,\"Volume\") then #<$fields.Volume?>\n r += \", \"\n else # <?$fields.Volume?>\n if field(p,\"Number\") then #<$fields.Number?>\n r += \", \"\n end #</$fields.Number?>\n end\n end #</$fields.Pages?>\n\n r += month_for_field(\"Month\", p, :postfix => \" \").detex\n r += text_for_field(\"Year\", p, :postfix => \". \").detex\n r += text_for_field(\"Note\", p, :postfix => \". \")\n return r\nend", "def page_print(text)\n return text unless highline.page_at\n\n lines = text.lines.to_a\n while lines.size > highline.page_at\n highline.puts lines.slice!(0...highline.page_at).join\n highline.puts\n # Return last line if user wants to abort paging\n return \"...\\n#{lines.last}\" unless continue_paging?\n end\n lines.join\n end", "def get_docx_contents_as_string(docx, collapse: false)\n Tempfile.create(\"court_report.zip\", \"tmp\") do |file|\n file << docx.force_encoding(\"UTF-8\")\n\n xml_document = Zip::File.open(file.path) do |docx_extracted|\n docx_extracted.find_entry(\"word/document.xml\").get_input_stream.read.force_encoding(\"UTF-8\")\n end\n separate_with = collapse ? \"\" : \"\\n\"\n xml_document.gsub(/<[^>]*>+/, \"\\n\").gsub(/\\n+/, separate_with)\n end\n end", "def document(file_name)\n origin = File.open(\"#{file_name}\",'r')\n docs = File.open(\"docs/doc-#{file_name.split('/')[-1]}.html\",'w')\n comment = true\n script = Script.new(file_name)\n \n # Need to refactor this into some form of a rules engine. It's getting a bit hairy\n str = origin.each_line.inject(\"\") do |str, line|\n # Skip if it's a shebang\n if line =~ /^ *#!/\n str << \"\"\n \n # Blank Comment line, insert newline\n elsif line =~ /^ *# *$/\n comment = true\n str << \"\\n\"\n \n # Evaluate as text if it's a comment with spaces prior\n elsif line =~ /^ *#/\n str << \"\\n\" unless comment \n comment = true\n \n # Find the meta-information in the comments and harvest it\n if line.include? '**Author**'\n script.author = line.gsub(/^.*: /,'').chomp\n elsif line.include? '**Description**'\n script.description = line.gsub(/^.*: /,'').chomp\n elsif line.include? '**Usage**'\n script.usage = line.gsub(/^.*: /,'').chomp\n elsif line.include? '**Type**'\n script.type = line.gsub(/^.*: /,'').chomp\n end\n \n str << \"#{line.gsub(/^ *# /,'')}\"\n \n # Find the Gems used\n elsif line =~ /^ *require /\n gemname = line.gsub(/^ *require /,'').delete(\"'\").delete('\"').gsub('/','-').chomp\n # Don't add it unless it's not there or it's an absolute path\n unless ($gems.include? gemname) or (gemname =~ /^[A-Za-z]\\:/)\n $gems << gemname\n end\n \n str << \"\\n\" if comment \n comment = false\n str << \" #{line}\"\n # Evaluate as a code block if it's code\n else\n str << \"\\n\" if comment \n comment = false\n str << \" #{line}\"\n end\n end\n \n # Add the current script to the collection for indexing\n $scripts << script\n \n # The following outputs a complete documentation for each and every single script that's in the directory. Very useful if you remember to type them out properly, otherwise you get to spend a few hours fixing it. Do it right the first time, trust me.\n \n # Headers and style information\n docs.puts \"<html>\"\n docs.puts \"<link rel='stylesheet' type='text/css' href='style.css' />\"\n docs.puts \"<body>\"\n \n docs.puts \"<a href='index.html'>( &#60;&#60; Back to Index )</a>\"\n \n # Insert the string into the docs\n docs.puts GitHub::Markdown.render(str)\n \n docs.puts \"<a href='index.html'>( &#60;&#60; Back to Index )</a>\"\n docs.puts \"</body></html>\"\nend", "def render_archives_endnote_texts(documents)\n val = ''\n documents.each do |doc|\n archives_endnote = {\n \"%0\" => \"Archives or Manuscripts\",\n \"%A\" => doc['author_display'].present? ? doc['author_display'][0].to_s : doc['author_display'].to_s,\n \"%I\"=> doc['found_in_labels_ss'].to_s,\n \"%V\"=> doc['container_display'].present? ? doc['container_display'][0].to_s : doc['container_display'].to_s, #Volume container\n \"%T\"=> doc['title_display'].present? ? doc['title_display'][0].to_s : doc['title_display'].to_s,\n \"%U\"=> \"https://archives.yale.edu/#{doc['archive_space_uri_s'].to_s}\",\n \"%O\"=> Date.today\n }\n archives_endnote.each {|key|\n j_value = key[1].kind_of?(Array)? key[1][0].to_s : key[1].to_s\n val << \"#{key[0].to_s} #{j_value}\\n\" }\n val << \"\\n\"\n end\n val\n end", "def create_text\n songs.inject(\"\") do |list, song|\n list << \"#{song.filename}, #{song.title}\\n\"\n end\n end", "def ingest_pages\n @table_of_contents.unique_pages.each_with_index do |entry, index|\n label = entry ? Utils.xml_escape(entry.title) : \"Page #{index + 1}\"\n @component_objects.push ingest_page(entry.image_filename, label, index + 1)\n end\n\n if @manifest.embargo\n @component_objects.each do |pid|\n @drupal_db.add_embargo pid, @manifest.embargo['rangeName'], @manifest.embargo['endDate']\n end\n end\n end", "def merge_texts!(hash, element)\n unless element.has_text?\n hash\n else\n # must use value to prevent double-escaping\n texts = +\"\"\n element.texts.each { |t| texts << t.value }\n merge!(hash, CONTENT_KEY, texts)\n end\n end", "def post_process(doc)\n doc.gsub(\"\\n\",'')\n end" ]
[ "0.6827037", "0.661266", "0.63545054", "0.6271447", "0.6250127", "0.62302476", "0.62280506", "0.620762", "0.61110324", "0.6095425", "0.6049715", "0.6027878", "0.59439987", "0.5918354", "0.58808285", "0.58788574", "0.5835971", "0.57839525", "0.57797146", "0.5739447", "0.5725464", "0.57211405", "0.5708594", "0.5692173", "0.5691243", "0.5667508", "0.56513953", "0.5624599", "0.5595558", "0.5595558", "0.5556702", "0.5552656", "0.55388516", "0.55287457", "0.55264735", "0.55085766", "0.550463", "0.550463", "0.5500144", "0.5499434", "0.54959905", "0.5483233", "0.54790574", "0.5471111", "0.5469247", "0.54557437", "0.5444132", "0.5433918", "0.5425785", "0.54199386", "0.54181", "0.5416607", "0.53976345", "0.53906286", "0.5379232", "0.5370965", "0.5368989", "0.536647", "0.53612316", "0.5355846", "0.53543234", "0.53520393", "0.5348721", "0.5346069", "0.53395647", "0.53352654", "0.5333724", "0.532803", "0.5322325", "0.531136", "0.5293014", "0.52902496", "0.52851146", "0.5272323", "0.5271061", "0.5257996", "0.5254762", "0.52538055", "0.52514654", "0.52501553", "0.5235213", "0.52318406", "0.52303237", "0.5224434", "0.521703", "0.5214059", "0.5212919", "0.52046525", "0.52033526", "0.51976544", "0.5197202", "0.51961017", "0.5188211", "0.51861775", "0.51851124", "0.5183638", "0.51771456", "0.51745206", "0.5173335", "0.51695406" ]
0.73425186
0
Determine the number of annotations on each page of this document.
def per_page_annotation_counts self.annotations.group('page_number').count end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_annotations_count page_number\n begin\n \n if @filename == ''\n raise 'filename not specified'\n end\n \n if page_number == ''\n raise 'page number not specified'\n end\n \n str_uri = $product_uri + '/pdf/' + @filename + '/pages/' + page_number.to_s + '/annotations'\n str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri) \n response_stream = RestClient.get(str_signed_uri, {:accept=>'application/json'})\n \n stream_hash = JSON.parse(response_stream)\n \n return stream_hash['Annotations']['List'].length\n \n \n rescue Exception=>e\n print e\n end\n end", "def count\n @document.page_count\n end", "def page_count\n load_page(1) if @num_records.nil? # load pagination metadata\n @num_pages\n end", "def num_pages\n groups = self.groups.includes(:descriptions)\n groups.map {|g| g.descriptions.length > 0 ? 1 : 0}.sum\n end", "def num_pages\n n, rest = @num_entries.divmod(@entries_per_page)\n if rest > 0 then n + 1 else n end\n end", "def number_of_pages\n document.at(\"[@itemprop='numberOfPages']\").innerHTML.scan(/\\d+/).first.to_i rescue nil\n end", "def get_all_annotation page_number\n begin\n \n if @filename == ''\n raise 'filename not specified'\n end\n \n if page_number == ''\n raise 'page number not specified'\n end\n \n total_annotations = self.get_annotations_count(page_number)\n \n all_annotations = Array.new\n \n index = 1\n while index <= total_annotations\n \n all_annotations.push(self.get_annotation(page_number, index))\n \n index+=1\n end\n \n return all_annotations\n \n \n rescue Exception=>e\n print e\n end\n end", "def total_annotations_count(source_type)\n count = 0\n \n count += self.count_annotations_by(source_type)\n \n # TODO: get counts for resources, methods, parameters and representations.\n \n return count\n end", "def number_of_pages\n return @number_of_pages\n end", "def score\n\n if self.annotations_count\n return self.annotations_count\n else\n return 0\n end\n\n end", "def score\n\n if self.annotations_count\n return self.annotations_count\n else\n return 0\n end\n\n end", "def page_count\n @page_counter\n end", "def page_count; pages.count; end", "def total_annotations_count(source_type)\n 0\n end", "def number_of_pages job\n count = 0\n pages = job.client_images_to_jobs.length\n if (@facility.image_type == 1) && (pages < 2)\n job.images_for_jobs.each do |image|\n path = Dir.glob(\"#{@location}/Parser/Images/#{image.filename}\").first\n count += %x[identify \"#{path}\"].split(image.filename).length-1 #command for retrieve number of pages in a tiff file (multi/single)\n end\n pages = count\n end\n pages\n end", "def page_count\n @total_pages\n end", "def page_count(doc)\n doc.at_css('.pagination') && doc.at_css('.pagination')\n .css('b')\n .map(&:text)\n .map(&:to_i)\n .max\n end", "def num_pages\n (@total_entries.to_i / per_page.to_f).ceil\n end", "def number_of_pages job\n count = 0\n pages = job.client_images_to_jobs.length\n if (@facility.image_type == 1) && (pages < 2)\n job.images_for_jobs.each do |image|\n path = Dir.glob(\"#{@location}/**/#{image.filename}\").first\n count += %x[identify \"#{path}\"].split(image.filename).length-1 #command for retrieve number of pages in a tiff file (multi/single)\n end\n pages = count\n end\n pages\n end", "def number_of_pages job\n count = 0\n pages = job.client_images_to_jobs.length\n if (@facility.image_type == 1) && (pages < 2)\n job.images_for_jobs.each do |image|\n path = Dir.glob(\"#{@location}/**/#{image.filename}\").first\n count += %x[identify #{path}].split(image.filename).length-1 #command for retrieve number of pages in a tiff file (multi/single)\n end\n pages = count\n end\n pages\n end", "def number_of_pages job\n count = 0\n pages = job.client_images_to_jobs.length\n if (@facility.image_type == 1) && (pages < 2)\n job.images_for_jobs.each do |image|\n path = Dir.glob(\"#{@location}/**/#{image.filename}\").first\n count += %x[identify #{path}].split(image.filename).length-1 rescue nil #command for retrieve number of pages in a tiff file (multi/single)\n end\n pages = count\n end\n pages\n end", "def number_of_pages job\n count = 0\n pages = job.client_images_to_jobs.length\n if (@facility.image_type == 1) && (pages < 2)\n job.images_for_jobs.each do |image|\n path = Dir.glob(\"#{@location}/**/#{image.filename}\").first\n count += %x[identify #{path}].split(image.filename).length-1 rescue nil #command for retrieve number of pages in a tiff file (multi/single)\n end\n pages = count\n end\n pages\n end", "def number_of_pages job\r\n count = 0\r\n pages = job.client_images_to_jobs.length\r\n if (@facility.image_type == 1) && (pages < 2)\r\n job.images_for_jobs.each do |image|\r\n path = Dir.glob(\"#{@location}/**/#{image.filename}\").first\r\n count += %x[identify \"#{path}\"].split(image.filename).length-1 #command for retrieve number of pages in a tiff file (multi/single)\r\n end\r\n pages = count\r\n end\r\n pages\r\n end", "def cluster_annotation_count\n self.cluster_groups.map {|c| c.cell_annotations.size}.reduce(0, :+)\n end", "def page_count\n @pages.count\n end", "def count\n load_page(1) if @num_records.nil? # load pagination metadata\n @num_records\n end", "def num_pages\n (except(:offset, :limit).count.to_f / limit_value).ceil\n end", "def number_pages\n pagenum = 1\n @sequence.each do |entry|\n entry.pagenum = pagenum\n next if (is_page? entry and entry.valid_repeat)\n pagenum += 1 if is_page?(entry)\n end\n end", "def number_of_pages job\n count = 0\n pages = job.client_images_to_jobs.length\n if (@facility.image_type == 1) && (pages < 2)\n job.images_for_jobs.each do |image|\n image_path = @image_folder.detect{|image_string| image_string.downcase == \"#{@image_path}/#{image.image_file_name}\".downcase}\n count += %x[identify #{image_path}].split(image.image_file_name).length-1 rescue nil #command for retrieve number of pages in a tiff file (multi/single)\n end\n pages = count\n end\n pages\n end", "def num_pages\n if order_bw_pages && order_color_pages\n return 2 + order_bw_pages + order_color_pages\n end\n end", "def show_total_pages\n pages = show_total_hits / show_results_per_page\n return pages + 1\n end", "def page_count\n @page_count ||= get_page_count\n end", "def page_count\n if collection.length < page_size\n 1\n else\n (collection.length / page_size) + 1\n end\n end", "def num_pages\n (total_count.to_f / per_page).ceil\n end", "def get_num_annotations_by_question_id(question_id)\n annos = get_annotations_by_question_id(question_id)\n return annos.count\n end", "def page_count\n bib_page_count\n end", "def count; info['doc_count']; end", "def page_count\n @page_count ||= ( @total_results / @query.page_size.to_f ).ceil\n end", "def page_count\n file_groups\n @highest_page_count\n end", "def pages(board)\n get(board, 1)[:pages].size\n end", "def getNumberOfPages(doc)\n numberOfPages = 1\n\n doc.search(\"Document > View > ScrollView > VBoxView > View > MatrixView > VBoxView:nth(0) > HBoxView > TextView > SetFontStyle > b\").each do |e|\n # Parse the last number in the string, e.g. the 99 in \"Page 3 of 99\"\n numberOfPages = e.inner_html[/[0-9]+$/].to_i\n end\n\n return numberOfPages\nend", "def total_pages\n pages.size\n end", "def getPageCount()\n return @helper.getPageCount()\n end", "def getPageCount()\n return @helper.getPageCount()\n end", "def getPageCount()\n return @helper.getPageCount()\n end", "def getPageCount()\n return @helper.getPageCount()\n end", "def pages_count\n @pages_count ||= (items_count / @per_page.to_f).ceil\n end", "def page_count\n @page_count\n end", "def page_count\n 1\n end", "def extract_total_pages\n pag = setup.fetch_page.css('.Ver12C')[70].text\n pag.scan(/\\d+/)[2].to_i\n end", "def actual_page_count\n warn \"WARNING: actual_page_count is not yet implemented properly.\"\n warn \" Please send patches.\"\n @pages.count\n end", "def page_count(input)\n info = info(input)\n return nil if info.nil?\n info['Pages'].to_i\n end", "def page_count\n (unpaged_count.to_f / @entries_per_page).ceil\n end", "def total_pages; end", "def page_nums(req, count)\n first = page(req) - SPREAD\n last = bound_first(first) + (SPREAD * 2)\n first = bound_last(last, count) - (SPREAD * 2) if bound_last(last, count) == last_page(count)\n bound_first(first)..bound_last(last, count)\n end", "def calculate_pages\n pdftk_cmd = \"#{CONFIG[:pdftk]} #{@source} dump_data | grep NumberOfPages | grep -o -e \\\"\\\\([0-9]*\\\\)$\\\"\"\n @pages = %x[#{pdftk_cmd}].to_i\n end", "def count\n @documents.count\n end", "def get_num_pages\n record_count = @model_class.count\n if record_count % @items_per_page == 0\n (record_count / @items_per_page)\n else\n (record_count / @items_per_page) + 1\n end\n end", "def page_count\n @page_count = notices_count/30 + 1\n @page_count = max_pages if @page_count > max_pages\n @page_count\n end", "def num_pages\n \n # Retrieve postings that match the given conditions\n postings = getPostings(params)\n \n # Escapes the case when @postings is nil\n num_pages = postings.blank? ? 0 : postings.num_pages\n \n respond_to do |format|\n format.json { render json: num_pages }\n end\n \n end", "def page_count\n page_size.zero? ? 1 : (count.to_f / page_size).ceil\n end", "def number_of_pages=(value)\n @number_of_pages = value\n end", "def count_documents\n size = 0\n @data.each_value do |documents|\n size += documents.size\n end\n\n size\n end", "def get_total_image_page_count\r\n total_page_count = 0\r\n images_for_jobs.each do |images_for_job|\r\n total_page_count += images_for_job.page_count.to_i\r\n end\r\n total_page_count\r\n end", "def count\n @count ||= documents.size\n end", "def count_images_of_one_page(page)\n perform_search_for_single_page('//img', [], page)\n end", "def page_count(arg)\n @pages = arg\n end", "def total_pages\n self.search.results.total_pages\n end", "def nonadword_count_total(page)\n\t\tnonadword_urls(page).length\n\tend", "def num_records\n num_urls + num_docs\n end", "def num_records\n num_urls + num_docs\n end", "def page_count\n # Integer arithmetic is simpler and faster.\n @page_count ||= item_count > 0 ? (item_count - 1) / items_per_page + 1 : 1\n end", "def page_number\n\t\t\t\treturn 0 if @total_results == 0\n\t\t\t\t@offset + 1\n\t\t\tend", "def total_pages\n\t\t\t\treturn 0 if @total_results == 0\n\t\t\t\t(@total_results.to_f / BATCH_SIZE).ceil\n\t\t\tend", "def total_pages\n collection.total_pages\n end", "def total\n @doclist['numFound']\n end", "def page_length\n return 0 if self.elements[:results].nil?\n self.elements[:results].length\n end", "def page_count\n @collection.max + 1\n end", "def pages_per_sheet\n return @pages_per_sheet\n end", "def number_of_reviews_pages (reviews_count)\n\tif reviews_count <= 10\n\t\tpages_count = 1\n\telse \n\t\tnumber_of_review_last_page = reviews_count % 10\n\t\tpages_count = (reviews_count-number_of_review_last_page)/10\n\t\tif number_of_review_last_page > 0\n\t\t\tpages_count = pages_count +1\n\t\telse\n\t\t\tpages_count = pages_count +0\n\t\tend\n\tend\nend", "def get_total_pages\n list = @parsed_response[\"#{@collection}List\"]\n @total_pages = (list['total_results'].to_f/list['page_size'].to_f).ceil\n end", "def count\n if paginated?\n to_hash['results'].nil? ? 0 : to_hash['results'].size\n else\n to_hash['count']\n end\n end", "def total_pages\n @total_pages ||= (@data.rows.length / per_page.to_f).ceil\n end", "def hit_count()\n #This is a stub, used for indexing\n end", "def adword_count_total(page)\n\t\tadword_count_top(page) + adword_count_right(page)\n\tend", "def number_of_json_pages(state) #this will return an integer representing number of pages, use this to refactor\n state_locations(state)[\"numberOfPages\"]\n end", "def num_pages\n (total_count.to_f / limit_value).ceil\n end", "def num_pages\n (total_count.to_f / limit_value).ceil\n end", "def num_pages\n (count.to_f / options[:limit]).ceil\n end", "def summarize_annotations\n\t\tresult = {is_expressed: 0, is_not_expressed: 0, not_sure_expressed: 0, is_bad_pattern: 0, total_anns: self.annotations.count}\n\t\tself.annotations.each do |ann|\n\t\t\tcase ann.annotation\n\t\t\twhen 0\n\t\t\t\tresult[:is_not_expressed] += 1\n\t\t\twhen 1\n\t\t\t\tresult[:is_expressed] += 1\n\t\t\twhen 2\n\t\t\t\tresult[:not_sure_expressed] += 1\n\t\t\tend\n\n\t\t\tif(!ann.is_bad_pattern.nil? && ann.is_bad_pattern)\n\t\t\t\tresult[:is_bad_pattern] += 1\n\t\t\tend\n\t\tend\n\t\tresult\n\tend", "def count_annotations_by(source_type_in)\n if source_type_in.nil? || source_type_in.casecmp('all').zero?\n annotations.count\n else\n annotations.where(source_type: source_type_in).count\n end\n end", "def total_pages\n nil\n end", "def total_pages\n nil\n end", "def total_pages\n f = total_results.to_f / RESULTS_PER_PAGE\n f.ceil\n end", "def page_count=(num)\n @page_count = num\n end", "def num_paragraphs\n @paragraphs.length\n end", "def num_docs\n @client[DOCUMENTS_COLLECTION].count\n end", "def nbpages\n attachments.order(position: 'asc').first.nbpages\n rescue StandardError => exc\n logger.error(\"Message for the log file #{exc.message}\")\n 0\n end", "def num_pages\n 26\n end", "def page_size\n @raw_page['records'].size\n end" ]
[ "0.78737545", "0.6964414", "0.6594237", "0.6590082", "0.65886855", "0.6553357", "0.6550715", "0.6539981", "0.6535128", "0.65301055", "0.65301055", "0.6505616", "0.6499778", "0.64700586", "0.64520293", "0.64335287", "0.6422388", "0.64068544", "0.64063936", "0.6401035", "0.6397296", "0.6397296", "0.63949215", "0.63678956", "0.632991", "0.63165164", "0.6313771", "0.6309939", "0.62937665", "0.6289435", "0.6268371", "0.6252773", "0.62408423", "0.6188841", "0.6177757", "0.6174203", "0.6170208", "0.61596406", "0.61493933", "0.6135601", "0.61332375", "0.6128682", "0.6127656", "0.6127656", "0.6127656", "0.6127656", "0.6102647", "0.61006355", "0.60857", "0.6054275", "0.60493314", "0.60457706", "0.6039803", "0.6038988", "0.60135007", "0.60115623", "0.60076725", "0.600374", "0.6001216", "0.5995043", "0.5992027", "0.59672195", "0.59426683", "0.5939223", "0.5936368", "0.5917113", "0.5915888", "0.58973205", "0.5896258", "0.5890794", "0.5890794", "0.5880294", "0.58710676", "0.58692116", "0.5867704", "0.586685", "0.58599454", "0.58505917", "0.5850353", "0.5841726", "0.58352", "0.5833083", "0.5822838", "0.582257", "0.58165205", "0.5807754", "0.58050406", "0.58050406", "0.57979786", "0.5791225", "0.5789871", "0.5781024", "0.5781024", "0.57792884", "0.5775638", "0.5761787", "0.5756755", "0.57527864", "0.5745163", "0.5736717" ]
0.8656055
0
Return an array of all of the document entity values for a given type, for Solr indexing purposes.
def entity_values(kind) self.entities.kind(kind.to_s).pluck('value') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_entities(type)\n @entities[type.name]\n end", "def index\n @type_of_values = TypeOfValue.all\n end", "def datatypes\n value.document.fetch(\"#{value.key}_type\", [])\n end", "def fields_for_type(type)\n return @field_mapping[type] || Set.new\n end", "def list(type)\n get(resource_path_for_entity_type(type) + \"?rows=all\")\n end", "def get_entity_types\n Occi::Log.debug(\"Getting entity types ...\")\n @model.kinds.collect { |kind| kind.term }\n end", "def all\n all_by_type.values.flatten\n end", "def index\n @entity_types = EntityType.all\n end", "def entity_types\n @entity_types ||= metadata.xpath('//EntityType').collect {|entity| entity.attributes['Name'].value}\n end", "def get_entity_types\n get_types(Occi::Core::Entity.kind)\n end", "def ids(type)\n Document.where(:typ => type).select(:ide).collect { |d| d[:ide] }.uniq.sort\n end", "def index\n @documenttypes = Documenttype.all\n end", "def solr_range_queries_to_a(solr_field)\n @response[:stats][:stats_fields][solr_field][:data] || []\n end", "def get_entity_list(entity_type, ns=Model::NS_MMD_1)\n # Search for the first occuring node of type entity which is a child node\n # of the metadata element.\n entity_list = @document.elements[\n \"//[local-name()='metadata' and namespace-uri()='%s']/[local-name()='%s-list' and namespace-uri()='%s'][1]\" %\n [Model::NS_MMD_1, entity_type, ns]]\n \n unless entity_list.nil? or entity_list.is_a? REXML::Text\n collection = Model::ScoredCollection.new(entity_list.attributes['count'],\n entity_list.attributes['offset'])\n # Select the method to use for reading the list.\n read_list_method = method('read_' + entity_list.name.gsub('-', '_'))\n \n # Read the entity list and store the entities in the collection.\n read_list_method.call(entity_list, collection, true) if read_list_method\n \n return collection\n else\n return Model::ScoredCollection.new\n end\n end", "def all; @docs.values end", "def get_all_sobjects(type)\n case type\n when 'Account'\n records = @client.materialize(type).query(\"Agents__c != ''\")\n when 'ccrmbasic__Email__c'\n records = @client.materialize(type).query(\"ccrmbasic__Contact__c != ''\")\n else\n records = @client.materialize(type).all\n end\n sobjects = records.dup.to_a\n while records.next_page?\n sobjects += records.next_page\n records = records.next_page\n end\n sobjects\n end", "def results\n @solr_data[:docs]\n end", "def types\n FIELD_TYPES\n end", "def values value_type = :formatted_value\n return @values unless @values.nil?\n\n @values = []\n while @rowset.next do\n @values << 1.upto(self.columns.size).map do |i|\n @rowset.getString i\n end\n end\n\n @values\n end", "def results\n @solr_data[:docs]\n end", "def entities_of_type(type)\n @entities.select { |entity| entity['type'] == type }.map { |entity| Entity.new entity }\n end", "def values\n enumerations.dig(type, :values)\n end", "def types\n get_metadata unless @types\n return @types\n end", "def get_entity_type_identifiers\n get_entity_types_related_to Occi::Core::Entity.kind.type_identifier\n end", "def values\n @values ||= self == Enum ? nil : begin\n connection.enum_values(type_name).freeze\n end\n end", "def entity_types\n @entity_types ||= parent_tokenizer.class.all_entity_types\n end", "def service_types_generated \n types = [ ServiceTypeValue[:fulltext], ServiceTypeValue[:holding], ServiceTypeValue[:table_of_contents], ServiceTypeValue[:relevant_link] ]\n \n return types\n end", "def index\n @q = ContactType.page(params[:page]).search(params[:q])\n @contact_types = @q.result(distinct: true)\n end", "def index\n @range_types = RangeType.all\n end", "def types\n @data.keys & TYPES\n end", "def index_as\n if @index_as\n Array(@index_as)\n else\n self.proxied_term.index_as\n end\n end", "def all_by_name_and_type(name, type)\n where(name: name, array_type: type).order_by(&:array_index).to_a\n end", "def custom_entity_types\n @_custom_entity_types ||= {}\n end", "def custom_entity_types\n @_custom_entity_types ||= {}\n end", "def potential_values\n @original_document[value_field]\n end", "def index\n @type_searches = TypeSearch.all\n end", "def search_facet_fields\n self.content_columns.select {|c| [:boolean,:decimal,:float,:integer,:string,:text].include?(c.type) }.map {|c| c.name }\n end", "def get_tlv_values(type)\n\t\tget_tlvs(type).collect { |a| a.value }\n\tend", "def get_tlv_values(type)\n\t\tget_tlvs(type).collect { |a| a.value }\n\tend", "def values\n @store.all_values\n end", "def values_array\n @_field_path.map{ |field_| @_values[field_.name] }\n end", "def index\n @types = Type.all\n end", "def show\n @entity_types = EntityType.where(collection_id: @document.collection_id)\n @document.adjust_offset(true)\n end", "def field_types\r\n return @field_types\r\n end", "def values\n return @values\n end", "def entity_types\n @entity_types ||= schemas.map do |namespace, schema|\n schema.entity_types.map do |entity_type|\n \"#{namespace}.#{entity_type}\"\n end\n end.flatten\n end", "def entity_types\n @entity_types ||= schemas.map do |namespace, schema|\n schema.entity_types.map do |entity_type|\n \"#{namespace}.#{entity_type}\"\n end\n end.flatten\n end", "def values\n return @values\n end", "def values\n return @values\n end", "def term_values(*term_pointer)\n # TODO if we can add primary_solr_name onto OmDatastream, we may be able to do away with get_values_from_solr.\n if @internal_solr_doc\n #lazy load values from solr on demand\n get_values_from_solr(*term_pointer)\n else\n om_term_values(*term_pointer)\n end\n end", "def get_entity_type_identifiers\n get_kind_type_identifiers_related_to Occi::Core::Entity.kind.type_identifier\n end", "def values\n fields.map { |f| f.value }\n end", "def index\n @document_types = DocumentType.all\n @document_types = @document_types.where(description: params[:description]) if params[:description]\n end", "def types\n @types ||= []\n end", "def get_workspace_entities_by_type(workspace_namespace, workspace_name, entity_type)\n path = self.api_root + \"/api/workspaces/#{uri_encode(workspace_namespace)}/#{uri_encode(workspace_name)}/entities/#{entity_type}\"\n process_firecloud_request(:get, path)\n end", "def show\n @entity_types = EntityType.where(project_id: @document.project_id)\n @document.adjust_offset(true)\n end", "def as_indexed_json\n indexed_values\n end", "def types\n respond_to?(:articleType) ? articleType : []\n end", "def all_rows_for(type, request)\n all_dataset_for(type, request).all\n end", "def elements\n return @types.dup\n end", "def ingested_ids\n ingested_ids_by_type.flatten\n end", "def ingested_ids\n ingested_ids_by_type.flatten\n end", "def index\n @types = ItemType.all\n end", "def service_types_generated\n [\n ServiceTypeValue['fulltext'],\n ServiceTypeValue['holding'],\n ServiceTypeValue['highlighted_link'],\n ServiceTypeValue['disambiguation'],\n ServiceTypeValue['site_message']\n ]\n end", "def values\n []\n end", "def types\n list = Array.new\n\n if @db != nil\n is_ok = false\n\n begin\n stm = @db.prepare( 'SELECT qType FROM qryResults GROUP BY qType ORDER BY qType')\n rs = stm.execute\n\n rs.each do |row|\n list.push row['qType']\n end\n\n stm.close\n is_ok = true\n rescue ::SQLite3::Exception => e\n Maadi::post_message(:Warn, \"Repository (#{@type}:#{@instance_name}) encountered an SELECT Types error (#{e.message}).\")\n end\n end\n\n return list\n end", "def values\n @values.values\n end", "def solr_doc_data\n doc = {}\n\n\n # To support indexing of records of different classes, create a unique id by concatenating\n # class name (downcased and underscored) and record id (see solr_id below)...\n doc[:id] = solr_id\n\n\n # ... then record class name and record id as record_type, record_id\n doc[:record_type] = self.class.to_s.underscore\n doc[:record_id] = self.id\n\n\n # This will add all attributes that correspond to database columns (make sure these are all in the schema, or modify)\n attrs = self.class.column_names.map { |n| n.to_sym }\n attrs.each do |a|\n if a != :id\n doc[a] = self[a]\n end\n end\n\n\n ######################################################\n # Here you can add other elements to the doc as needed\n #\n # If you are indexing records from multiple models, it's a good idea to use a case statement here\n # to specify which fields to index for which model, e.g.:\n #\n # case self\n # when Foo\n # doc['foo_attribute'] = self.foo_attribute\n # when Boo\n # doc['boo_attribute'] = self.boo_attribute\n # end\n #\n ######################################################\n\n\n # remove nil/empty values\n doc.delete_if { |k,v| nil_or_empty?(v) }\n\n\n doc\n end", "def index\n @point_types = PointType.all\n end", "def values\n @values.values\n end", "def get_entity_types_related_to(type_identifier)\n Occi::Log.debug(\"Getting entity type identifiers related to #{type_identifier}\")\n collection = @model.get type_identifier\n collection.kinds.collect { |kind| kind.type_identifier }\n end", "def values\n @values ||= []\n end", "def values\n @values.values\n end", "def word_values\n return @words.values\n end", "def index\n @type_of_articles = TypeOfArticle.all\n end", "def values\n @values ||= []\n end", "def entities\n @entities\n end", "def index_as\n Array(@index_as)\n end", "def find_all_fedora_type(params, ftype)\n # ftype should be :collection or :apo (or other symbol if we added more since this was updated)\n date_range_q = get_date_solr_query(params)\n solrparams = {\n :q => \"#{Type_Field}:\\\"#{Fedora_Types[ftype]}\\\" #{date_range_q}\",\n :wt => :json,\n :fl => @@field_return_list\n }\n get_rows(solrparams, params)\n response = run_solr_query(solrparams)\n determine_proper_response(params, response)\n end", "def index\n @date_types = DateType.all\n end", "def index\n @entity_types = EntityType.paginate(:page => params[:page], :per_page => per_page).order(sort_column + ' ' + sort_direction)\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @entity_types }\n end\n end", "def [] field\n f = self.get(field)\n return nil if (f == nil)\n return f.values.to_a\n end", "def value_types; end", "def index\n @article_types = ArticleType.all\n end", "def index\n @q = @enterprise.document_types.ransack(params[:q])\n @pagy, @document_types = pagy( @q.result )\n end", "def index\n @params_config_type_docs = ParamsConfigTypeDoc.all\n end", "def get_dictionary_index types, line, indexes=nil\n indexes ||= []\n if types.is_a? Symbol\n types = [types]\n end\n kanji_id = @kanji_lookup[get_element(:kanji, line)]\n out=[]\n types.each do |type|\n dictionary_index_value = get_element(type, line)\n unless dictionary_index_value.nil?\n dictionary_id = @dictionary_lookup[type]\n values = [kanji_id, dictionary_id, dictionary_index_value]\n #puts \"values:#{values}\"\n indexes << values\n else \n #puts \"#{type} not found on this line\"\n end\n end\n return indexes\n end", "def values\n @values\n end", "def get_records(type)\n if @action == 'initial_run'\n @logger.info \"Getting all records from SalesForce for #{type}\"\n records = get_all_sobjects(type)\n else\n @logger.info \"Getting records for yesterday from SalesForce for #{type}\"\n records = @client.materialize(type)\n \n datetime = DateTime.now\n datetime = datetime -= 1\n records.query(\"lastmodifieddate >= #{datetime}\")\n end\n end", "def index\n @types = [ContactType.student]\n \n respond_to do |format|\n format.html\n format.json {\n render json: Contact.full_text_search(params[:q])\n }\n end\n end", "def values\n @data.values\n end", "def constant_indexes\n {\n service_types_index: ServiceSerializer.service_types_index\n }\n end", "def related_distinction_types_for_solr\n\t types = Array.new\n\t \n\t if is_opportunity?\n distinctions_offered.each do |d|\n if !d.distinction_types.blank?\n\t\t types = types + d.distinction_types.map{|dt| dt.distinction_type_id}\n else\n \t# if there is no type assigned to distinction - 'Other' subfacet\n \ttypes.push('other')\n end\n end\n\t\t\n\t\t # if there is no related distinction - 'Other' subfacet\n\t types.push('other') if distinctions_offered.blank?\n \n\t end\n\t \n\t return types.uniq.join(', ')\n end", "def values(start_time, ndatapoints)\n requires :id, :granularity\n data = service.get_instrumentation_value(self.uris.find {|uri| uri['name'] == 'value_raw'}['uri'], start_time, ndatapoints, self.granularity).body\n data.map do |datum|\n Fog::Joyent::Analytics::Value.new(datum)\n end\n end", "def allowed_types\n [ Entities::SearchString, \n Entities::Organization, \n Entities::Domain, \n Entities::Host,\n Entities::Person, \n Entities::Username, \n Entities::Account]\nend", "def index\n @data_set_types = DataSetType.all\n end", "def service_types_index\n index = {}\n ServiceType.all.each do |service_type|\n index[service_type.id] = service_type\n end\n index\n end", "def instances(type)\n @instances[type]\n end", "def index\n @type_identifications = TypeIdentification.all\n end", "def flat(entity_type,search_term)\n\n endpoint = \"#{@base_uri}?request=flat&level=admin&field=#{entity_type}&value=#{search_term}&auth=#{@api_key}\"\n result = JSON.parse(RestClient.get(endpoint))\n\n result\n end" ]
[ "0.6474695", "0.6416341", "0.63455075", "0.62797475", "0.6140852", "0.61085665", "0.593722", "0.5888546", "0.58861524", "0.5794548", "0.57635224", "0.5757715", "0.5748562", "0.5716814", "0.5648104", "0.564423", "0.5637249", "0.5605242", "0.5586327", "0.5575393", "0.5568374", "0.55530304", "0.5542064", "0.5534918", "0.55162084", "0.54999566", "0.5491364", "0.54638505", "0.5463224", "0.5458335", "0.5452744", "0.54485565", "0.5427767", "0.5427767", "0.5413751", "0.54125243", "0.53638715", "0.53563374", "0.53563374", "0.5352197", "0.5349681", "0.53492004", "0.5321845", "0.53203434", "0.5319239", "0.5318655", "0.5318655", "0.53186476", "0.53186476", "0.5313309", "0.53094816", "0.52915156", "0.5290896", "0.5274173", "0.52705795", "0.5254752", "0.5242231", "0.52420026", "0.52414984", "0.52354646", "0.5235371", "0.5235371", "0.522169", "0.52143764", "0.5212267", "0.5210019", "0.520848", "0.5208133", "0.51980805", "0.5194679", "0.518786", "0.5174734", "0.5169058", "0.51646924", "0.51643026", "0.5155149", "0.5154353", "0.5152193", "0.5147423", "0.51472235", "0.5146946", "0.51345557", "0.51259315", "0.5125863", "0.5124408", "0.5116495", "0.51162076", "0.51152605", "0.5114074", "0.5110008", "0.51085603", "0.5098945", "0.5095732", "0.50933355", "0.50915915", "0.5088782", "0.50805366", "0.50780964", "0.50764674", "0.5071159" ]
0.63140684
3
Reset the cached counter of public notes on the document.
def reset_public_note_count count = annotations.unrestricted.count if count != self.public_note_count update_attributes :public_note_count => count end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reset_counter; end", "def set_note(n)\n @note = 0\n end", "def reset\n @count = 0\n end", "def clear; @docs[] = {} end", "def reset!\n LinerNotes.logger.debug \"--- RESETTING ---\"\n @track_credits = nil\n @album_credits = nil\n @individual_credits = nil\n @artwork = nil\n @extra_artwork = nil\n @lyrics = nil\n @displayed_lyrics = nil\n Links.reset!\n ArtistLink.reset!\n end", "def reset_counter\n @run_count = 0\n end", "def initialize()\n @doc_count = 0\n @docs = []\n end", "def reset\n @number = nil\n end", "def reset_unread_notification_count\n post('notifications/markAsRead')\n end", "def reset!\n @cache = nil\n end", "def reset\r\n @cache.reset\r\n end", "def reset\n @results = @hits = @verified_hits = @total = @solr_response = @doc_ids = nil\n end", "def reset\n @results = @hits = @verified_hits = @total = @solr_response = @doc_ids = nil\n end", "def update_comment_cache_counters\n update_attributes!(\n comment_count: comments.length,\n participants_count: watchers_count || ([self]+comments).map { |obj| obj[:author_linked_account_id] || obj[:author_name] }.uniq.length,\n )\n update_thumbs_up_count\n end", "def reset(value=0)\n @counter = value.to_i\n end", "def reset\n @debug_indent = 0\n @uri_to_term_or_curie = {}\n @uri_to_prefix = {}\n @references = Hash.new{|h,k| h[k] = 0}\n @prefixes = {}\n @serialized = {}\n @subjects = {}\n @ordered_subjects = []\n @titles = {}\n @doc_title = \"\"\n end", "def reset_followers_count!\n self.class.update_counters id, followers_count: -followers_count\n self[:followers_count] -= followers_count\n end", "def counter_cache; end", "def reset\n self.repetitions = 0\n self.interval = 0\n self.due = Date.today\n self.studied_at = Date.today\n save\n end", "def reset_counters!\n reload!\n self.class.counter_columns.each do |cc|\n counter = self.send(cc.name)\n counter.reset! unless counter.nil?\n end\n save\n end", "def reset()\n #This is a stub, used for indexing\n end", "def reset()\n #This is a stub, used for indexing\n end", "def invalidate\n @cache_version ||= 0\n @cache_version += 1\n end", "def reset!\n config[:since_id] = 1\n config[:since_id_reply] = 1\n end", "def after_update(doc)\n\t\t# expire_cache_for(doc)\n\tend", "def clear_document_cache(document) \n expire_fragment :recent_posts\n expire_fragment :menu\n\n cache_paths = []\n cache_paths << File.join(RAILS_ROOT, 'public', 'cache', document.path)\n\n cache_paths.each do | cache_path |\n Rails.logger.debug 'Deleting CACHE: ' + cache_path\n FileUtils.rm_rf cache_path if File.exists? cache_path\n end\n end", "def reset\n @value = nil\n @count = 0\n end", "def default_counter\n self.counter = 0 if self.counter.nil?\n end", "def reset!( opts = {} )\n http_action :delete, nil rescue nil\n http_action :put, nil, opts.merge( :doc => '' )\n create_shared_design\n end", "def initialize; @docs = {} end", "def set_counter\n session[:counter] = 0 if !session[:counter].present?\n end", "def clear!\n @documents = {}\n @attributes = {}\n @lookup_map = nil\n @all_loaded = false\n @all = []\n end", "def reset_since_id_counters\n reset!\n reset_since_id\n reset_since_id_reply\n reset_since_id_home_timeline\n reset_since_id_dm\n end", "def reset_unread_chats_count\n Rails.cache.delete(unread_chats_count_cache_key)\n end", "def recalculate_my_comments_counter!\n dcount = my_draft_comments.count\n pcount = my_published_comments.count\n update_attributes!({\n my_draft_comments_count: dcount,\n my_published_comments_count: pcount,\n my_comments_count: dcount + pcount\n })\n end", "def update_cache\n if self.yes?\n Song.increment_counter(:yes_count, song.id)\n else\n Song.increment_counter(:no_count, song.id)\n end\n end", "def reset\n @entry_cache.clear\n end", "def clear_cache\n @copyright_status = nil\n end", "def clear_docs\n result = @client[DOCUMENTS_COLLECTION].delete_many({})\n result.n\n ensure\n @last_result = result\n end", "def counter_cache=(_arg0); end", "def reset_counter!\n return if counter == 0\n sql(:execute, %(\n INSERT INTO knifeswitch_counters (name,counter)\n VALUES (?, 0)\n ON DUPLICATE KEY UPDATE counter=0\n ), namespace)\n end", "def reset_hit_count\n \"0\"\n end", "def todo_reset\n @generated_todo = false\n @downloaded_a_page = false\n end", "def reset\n @id = nil\n @members = []\n @topic = nil\n end", "def reset_checks\n @counter = 0\n end", "def sweep_count_cache\n @visits_count_cache = false\n @views_count_cache = false\n end", "def remove_all_documents\n @documents.clear\n\n # setup frequencies\n @frequencies = DocVector.new(@frequencies.length, 0)\n\n # setup occurences\n @occurences = DocVector.new(@occurences.length, 0)\n end", "def reset_flag_count\n Flag.create(memory_id: self.id, user_id: user.id, message: \"Flagcount Reset by administrator #{user.username}\")\n self.flagcount = 0\n self.save\n end", "def unpublish\n self.published = false\n end", "def reset_password_reset_page_access_counter\n send(\n :\"#{sorcery_config.reset_password_page_access_count_attr_name}=\", 0\n )\n sorcery_adapter.save\n end", "def cache_clear\n @moneta.clear\n end", "def auto_update_doc_status\n unless Post.count(:conditions => [\"posts.document_id = ? and posts.status=?\",\n \"#{self.document.id}\", \"Published\"] )==0\n self.document.status = \"Published\"\n else\n self.document.status = \"\"\n end\n self.document.save \n end", "def after_update(note)\n expire_cache_for(note)\n end", "def after_create(doc)\n\t\tActionController::Base.new.expire_fragment(\"count_docs\")\n\t\tActionController::Base.new.expire_fragment(\"count_#{doc.sourcedb}\")\n\t\tdoc.projects.each do |p|\n\t\t\tActionController::Base.new.expire_fragment(\"count_docs_#{p.name}\")\n\t\t\tActionController::Base.new.expire_fragment(\"count_#{doc.sourcedb}_#{p.name}\")\n\t\tend\n\tend", "def reset_dump_count(namespace)\n @coll.update({ SolrConfigConst::SOLR_URL_KEY => @solr_loc,\n SolrConfigConst::NS_KEY => namespace\n },\n { \"$set\" => { SolrConfigConst::DOCS_DUMPED_KEY => 0 }})\n end", "def rewind\n @seen.clear\n super\n end", "def reset\n # TODO\n end", "def after_destroy(doc)\n\t\tActionController::Base.new.expire_fragment('count_docs')\n\t\tActionController::Base.new.expire_fragment(\"count_#{doc.sourcedb}\")\n\t\tdoc.projects.each do |p|\n\t\t\tActionController::Base.new.expire_fragment(\"count_docs_#{p.name}\")\n\t\t\tActionController::Base.new.expire_fragment(\"count_#{doc.sourcedb}_#{p.name}\")\n\t\tend\n\tend", "def reset()\n @contadores = { :Piedra => 0, :Papel => 0, :Tijeras => 0,\n :Lagarto => 0, :Spock => 0}\n end", "def invalidate_first_page\n $redis.del('feed:first_page')\n end", "def reset!\n self.result = nil\n @rows = nil\n @docs = nil\n end", "def refresh_comment_count\n count = 0\n comments.each do |comment|\n # Recalculate for sub-comments and sum.\n count += comment.refresh_comment_count + 1\n end\n self[:comment_count] = count\n self.skip_timestamp_update = true\n\n # Save and return\n self.save\n self[:comment_count]\n end", "def after_update(sticky_note)\n expire_cache_for(sticky_note)\n end", "def unpublish!\n self.is_published = false\n save\n end", "def reset_unread_conversations_counter\n unread_count = conversations.unread.count\n if self.unread_conversations_count != unread_count\n self.class.where(:id => id).update_all(:unread_conversations_count => unread_count)\n end\n end", "def reset\n deleted.all.update marked_deleted: false\n end", "def set_counters\r\n @score_count = 0\r\n @score_total = 0\r\nend", "def set_note_order\n self.note_order = noteable.notes.maximum(:note_order) + 1\n end", "def rebuild_document_collection()\n end", "def clear_extended_doc_fresh_cache\n ::CouchRest::ExtendedDocument.subclasses.each{|klass| klass.req_design_doc_refresh if klass.respond_to?(:req_design_doc_refresh)}\n end", "def reset_password_reset_page_access_counter\n send(:\"#{sorcery_config.reset_password_page_access_count_attribute_name}=\", 0)\n sorcery_adapter.save\n end", "def clear_cache\n @results = nil\n @result_ids = nil\n @num_results = nil\n @letters = nil\n end", "def reset!\n @cached_descriptions = nil\n @nodes = nil\n @cloud_nodes = nil\n end", "def reset_hit_count=(is_reset)\n self.hit_count = 0 if is_reset == \"1\"\n end", "def heal_associated_docs\n bad_keys = []\n @document.doc_refs do |key, value|\n if DocumentRepository.find key == nil\n bad_keys << key\n end\n end\n bad_keys.each do |key|\n @document.doc_refs.delete(key)\n end\n DocumentRepository.update @document\n end", "def invalidate_sorted_cache\n\t\tmod_sorted = nil\n\t\tmod_ranked = nil\n\tend", "def reset\n\t\tself.rs \t= 0\n\t\tself.ps \t= 0\n\t\tself.ss \t= 0\n\t\tself.gen\t= Random.new(SEED)\n\tend", "def clean_document_cache\n @document_cache_keys.each_key do |cache_key|\n document = get_document(cache_key)\n \n document.each do |index_field,index_values|\n if index_values.size > 0\n document[index_field] = index_values.uniq\n end\n\n # If we have multiple value entries in what should be a single valued \n # field, not the best solution, but just arbitrarily pick the first entry.\n if !@config[\"schema\"][\"fields\"][index_field.to_s][\"multi_valued\"] and index_values.size > 1\n new_array = []\n new_array.push(index_values[0])\n document[index_field] = new_array\n end\n end\n \n set_document( cache_key, document )\n end\n end", "def reset_discounts\n @discounts = []\n end", "def update_replies_count\n Answer.update_counters(answer_id, replies_count: 1)\n end", "def set_counter(pages)\n @counter = 0\n @pages = pages.to_i\n end", "def reset_evernote_recipes(account)\n account.update_count = 0\n EvernoteRecipe.where(\"evernote_account_id = \" + account.id.to_s).destroy_all\n end", "def clear_cache_like! *keys\n clear_cache_like *keys\n ipcm_trigger :clear_cache_like, *keys\n end", "def unpublish!\r\n unpublish\r\n save!\r\n end", "def update_cache\n\t\tself.species_count = self.species.count(:conditions => ['species.change_id IS NULL'])\n\t\tself.save!\n\tend", "def reset\n # The read and write caches are Arrays. We use the _bits_ least\n # significant bits of the PEROBS::ObjectBase ID to select the index in\n # the read or write cache Arrays.\n @reads = ::Array.new(2 ** @bits)\n @writes = ::Array.new(2 ** @bits)\n @transaction_stack = ::Array.new\n @transaction_thread = nil\n @transaction_objects = ::Hash.new\n end", "def assign_control_doc_number\n\t\tself.control_doc_number = Time.now.strftime(\"%Y\") + \"/\" + Time.now.to_i.to_s\n\t\tself.control_doc_number\n\tend", "def reset\n @entries = []\n @owner = nil\n @curr_bucket = nil\n @curr_text = ''\n end", "def _update_counts_after_destroy\n _wrap_in_counter_culture_active do\n self.class.after_commit_counter_cache.each do |hash|\n # decrement counter cache\n change_counter_cache(hash.merge(:increment => false))\n end\n end\n end", "def reset\n @lists = {}\n @references = {}\n @serialized = {}\n @graphs = {}\n @subjects = {}\n end", "def increment_doer_no_reply_count!\n increment_doer_no_reply_count\n save\n end", "def clear!\n\t\t\t\t@marked = false\n\t\t\tend", "def revoke!\n self.revoked = Time.now.to_i\n AccessToken.collection.update({ :_id=>token }, { :$set=>{ :revoked=>revoked } })\n Client.collection.update({ :_id=>client_id }, { :$inc=>{ :tokens_revoked=>1 } })\n end", "def revoke!\n self.revoked = Time.now.to_i\n AccessToken.collection.update({ :_id=>token }, { :$set=>{ :revoked=>revoked } })\n Client.collection.update({ :_id=>client_id }, { :$inc=>{ :tokens_revoked=>1 } })\n end", "def update_views_count\n views = session[:counter]\n if views.nil?\n views = 1\n else\n views += 1\n end\n session[:counter] = views\n views\n end", "def unpublish!\n self.published = false\n self.previously_published = false\n save(:validate => false)\n end", "def reset\n @nums\n end", "def reset\n hash.clear\n expire_cache!\n self\n end", "def reset!\n self.words_for_last = []\n self.corpus_dfs = {}\n self.block_list = []\n self.single_block = []\n end", "def reindex!\n self.__elasticsearch__.update_document if self.published?\n end" ]
[ "0.624501", "0.61837107", "0.6080125", "0.60098344", "0.5901831", "0.5845609", "0.58312446", "0.57278055", "0.5719366", "0.5709244", "0.56585896", "0.562301", "0.562301", "0.5560256", "0.554109", "0.55210483", "0.5510694", "0.55036366", "0.54875326", "0.54749024", "0.5469772", "0.5469772", "0.54419637", "0.5439107", "0.5428548", "0.54212755", "0.5419174", "0.5416084", "0.5399328", "0.5396625", "0.5395097", "0.538741", "0.53778756", "0.53741974", "0.5331672", "0.53243625", "0.5324168", "0.53239805", "0.53181136", "0.53139424", "0.5312597", "0.5308857", "0.5302292", "0.529601", "0.52915525", "0.5287204", "0.52533734", "0.5245766", "0.52105254", "0.52105033", "0.5210094", "0.5201889", "0.5199332", "0.51916283", "0.5183977", "0.5180896", "0.5177699", "0.51743567", "0.5156404", "0.5152635", "0.51518553", "0.51475626", "0.5134448", "0.5131994", "0.5126668", "0.51231134", "0.51216763", "0.5119121", "0.51180077", "0.5112257", "0.5111328", "0.51079816", "0.51062334", "0.50999415", "0.5098517", "0.5097102", "0.5096406", "0.5095666", "0.5095611", "0.5086759", "0.5085368", "0.5083934", "0.50835365", "0.5081137", "0.5079366", "0.5075478", "0.5072868", "0.50710124", "0.5070508", "0.50652516", "0.5064702", "0.50637025", "0.5063143", "0.5063143", "0.5057689", "0.5054187", "0.50390047", "0.5038115", "0.5037708", "0.5035688" ]
0.750443
0
Return a hash of all the document's entities (for an API response). The hash is ordered by entity kind, after the sidebar, with individual entities sorted by relevance.
def ordered_entity_hash hash = ActiveSupport::OrderedHash.new DC::VALID_KINDS.each {|kind| hash[kind] = [] } entities.each do |e| hash[e.kind].push :value => e.value, :relevance => e.relevance end hash.each do |key, list| hash[key] = list.sort_by {|e| -e[:relevance] } end hash end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def entities\n @entities ||= begin\n acc = {}\n @api.routes.filter_map(&:entity).each do |entity|\n collect_entities(acc, entity)\n end\n acc.keys.sort_by(&:name)\n end\n end", "def entities\n return bad_request unless params[:id] and request.format.json? || request.format.js?\n return not_found unless current_document\n @response = {'entities' => current_document.ordered_entity_hash}\n render_cross_origin_json\n end", "def entities\n _entities\n end", "def entities\n _entities\n end", "def entities\n ordering.map(&:entity).compact\n end", "def articles_related_to(entities)\n if(entities.is_a? Entity)\n articles = articles_for(entities)\n else\n articles = []\n entities.each do |entity|\n articles = articles | articles_for(entity) # set union to remove duplication\n articles.sort! { |x, y| x.published_at <=> y.published_at }.reverse!\n end\n end\n articles.uniq! { |article| article.headline } if articles.present?\n articles\n end", "def index\n @entities = Entity::Repo.roots\n end", "def entities\n @entities ||= []\n end", "def index\n @entities = Entity.all.page(params[:page])\n end", "def entities\n @entities\n end", "def entities_list\n raise 'Not implemented'\n end", "def index\n @entities = Entity.all\n end", "def index\n @entities = Entity.all\n end", "def ordered_entities\n ids = self.entity_ids\n self.entities.sort { |a, b| ids.index(a.id) <=> ids.index(b.id) }\n end", "def entities; end", "def index\n @entity_types = EntityType.paginate(:page => params[:page], :per_page => per_page).order(sort_column + ' ' + sort_direction)\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @entity_types }\n end\n end", "def entities viewerid=nil\n tagging_query(viewerid).to_a.map(&:entity)\n end", "def show\n @entity_types = EntityType.where(collection_id: @document.collection_id)\n @document.adjust_offset(true)\n end", "def ids; @docs.keys end", "def find_entities\n []\n end", "def retrieve_all_entities\n response = self.execute(\"RetrieveAllEntities\", {\n EntityFilters: \"Entity\",\n RetrieveAsIfPublished: true\n },\n Metadata::RetrieveAllEntitiesResponse)\n end", "def digest\n @articles = Article.where(include_in_digest: true)\n end", "def get_all_fences\n @coll.find.to_a\n end", "def load_entities\n {}\n end", "def entities\n @entities ||= questions.map{|question|question.meta_attribute_entity}.uniq\n end", "def index\n breadcrumb_for_collections(@collection)\n semantic_breadcrumb @collection.name, @collection\n semantic_breadcrumb \"Entity Types\"\n @entity_types = @collection.entity_types\n end", "def get_entity_types\n get_types(Occi::Core::Entity.kind)\n end", "def index\n @entity_types = EntityType.order('id').page(params[:page])\n \n respond_to do |format|\n format.html # index.html.erb\n end\n end", "def index\n # @entries = Entry.all\n @search.sorts = ['term desc', 'created_at desc'] if @search.sorts.empty?\n @search_term = params[:q]\n @entries = @search\n .result(distinct: true)\n .includes(:definitions)\n .page(params[:page])\n .per(params[:per_page])\n\n\n 1\n end", "def to_a\n list = parsed_body['Data']['Entities']['Entity']\n if Hash === list\n list = [list]\n end\n list.map do |data|\n Result.new('Entity', renderer.result(data), self).finalize!\n end\n end", "def entities\n begin\n @first_name = @current_sf_user.first_name\n @last_name = @current_sf_user.last_name\n\n @entity_results = Array.new\n\n limit = QUERY_RESULT_LIMIT || 100\n\n @safe_user_entity_subscriptions = @current_sf_user.entity_subscriptions.find(:all, :limit => limit.to_s)\n chatter_feed_finder = Salesforce::ChatterFeed.new\n\n # This will be an array of entities (Users, Accounts, Asssets, etc) that this user has subscribed.\n @safe_user_entity_subscriptions.each do |an_entity|\n oid = an_entity.parent_id.to_s\n otype = determine_sf_object_type(oid)\n\n begin\n sf_object = salesforce_object_find_by_id(oid)\n entity_row =RForce::MethodHash.new\n entity_row['name'] = sf_object.name\n entity_row['id'] = sf_object.id #should be the same as <an_entity.parent_id.to_s>\n entity_row['type'] = otype\n #entity_row['feeds'] = chatter_feed_finder.get_all_chatter_feeds_with_attachments(entity_row['id'], entity_row['type'], @binding, session.session_id, limit, true)\n\n if current_user[:chatter_load_attachment] == true\n entity_row['feeds'] = chatter_feed_finder.get_all_chatter_feeds_with_attachments(entity_row['id'], entity_row['type'], @binding, session.session_id, limit, true)\n else\n entity_row['feeds'] = chatter_feed_finder.get_all_chatter_feeds_without_attachments(entity_row['id'], entity_row['type'], @binding, session.session_id, limit)\n end\n\n @entity_results << entity_row\n rescue ActiveRecord::RecordNotFound => exception\n logger.info(\"***Record not found: \" + exception.class.name + exception.message + \"<hr/>\" + exception.backtrace.to_s)\n flash[:notice] = \"#{otype} with ID: #{oid} cannot be found. <br/>\"\n return\n end\n end\n\n rescue NoMethodError => nme\n #matching for -> undefined method `entity_subscriptions' for\n #User does not have chatter installed.\n if nme.message.match(/undefined\\s+method\\s+\\Sentity_subscriptions\\S/mi)\n flash[:notice] = \"You do not have Salesforce Chatter application installed.\"\n redirect_to base_url\n else\n return nme\n end \n rescue Exception => exception\n logger.info(\"***Other Exception: \" + exception.class.name + exception.message.to_s + \"<hr/>\" + exception.backtrace.to_s)\n flash[:notice] = exception.class.name + exception.message.to_s + \"<hr/>\" + exception.backtrace\n return\n end\n end", "def documents\n # This function and its helpers are side-effecty for speed\n @documents ||= raw[:hits][:hits].map do |hit|\n doc = extract_source(hit)\n copy_underscores(hit, doc)\n copy_highlight(hit, doc)\n doc\n end\n end", "def all; @docs.values end", "def index\n @entities = Entity.find(:all, :limit=>100)\n EntitiesHelper.setModelGraph(\"public/UMLmodel.png\")\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @entities }\n end\n end", "def entities_used\n entities_arr = Array.new\n @entities.each do |entity|\n entities_arr << entity.id unless entities_arr.include?(entity.id)\n end\n return entities_arr\n end", "def show\n @entity_types = EntityType.where(project_id: @document.project_id)\n @document.adjust_offset(true)\n end", "def index\n\t\tlang = params[:lang] || I18n.locale\n paginate = params[:paginate] || 0\n\t\tcollection = entity.with_relationships.lang(lang).paginate(paginate).order(date: :desc)\n\t\tcollection = filters( params, collection)\n\n\t\trender json: collection.to_json( :except => [:keywords, :updated_at],\n\t\t\t:include => [\n\t\t\t\t{ :translations => {:only => [:id, :slug]} },\n\t\t\t\t{ :categories => {:only => [:id, :name]} },\n\t\t\t\t{ :gallery => {:only => :img_name} },\n\t\t\t\t:lawyers,\n\t\t\t\t:translation\n\t\t\t]);\n\tend", "def index\n # Uses will_paginate gem\n @words = Word\n .includes(\n definitions: [\n { related_definitions: :word },\n :places,\n :alt_spellings,\n :source_materials,\n :source_dates\n ]\n )\n .order(sort_order)\n .paginate(page: params[:page], per_page: 50)\n .load\n end", "def index\n # @results = []\n # @document.bioc_doc.all_relations.each do |a|\n # e = EntityUtil.get_relation_entity(a)\n # a.locations.each do |l|\n # @results << {did: @document.did, offset: l.offset, text: a.text, length: l.length, infons: a.infons }\n # end\n # end\n @project = @document.project\n @version = params[:version] || @document.version\n @version = @version.to_i if @version.present?\n @is_manager = @project.manager?(current_user)\n\n if @is_manager\n @relations = @document.relations.where('`version`=?', @version)\n else\n @relations = @assign.relations\n end\n @relations = @relations.order(\"offset\")\n end", "def as_indexed_json(options={})\n self.as_json(\n methods: [:creation_epoch],\n include: {\n page: {only: [:url, :title, :site_name, :description, :content, :image_url]},\n }\n )\n end", "def entity_search\n @entity_search = Array.new\n entity_search = {}\n @entity = UserEntity.where(:entity_name => /.*#{params[:entity][:char]}*./).all\n @entity.each do |entity|\n @user_entity = User.where(:id => entity.user_id)\n @user_entity.each do |users|\n es = entity_search.merge(:user_entity_id => entity.id ,:user_id => users.id, :profile_picture => users.profile_picture_url, :first_name => users.first_name,:address => entity.address, :comment => entity.comment, :entity_image => entity.entity_image, :entity_name => entity.entity_name, :rating_count => entity.rating_count, :sub_category => entity.sub_category, :lat => entity.lat , :longitude => entity.longitude, :user_category_id => entity.user_category_id)\n @entity_search << es\n end\n end\n respond_to do |format|\n if @entity.present?\n format.json {render :json => @entity_search}\n else\n end\n end\nend", "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 get_nearby_documents(id)\n @original_document = get_solr_response_for_doc_id(id).last # returns an array with a response object and the document.\n return [] unless document_has_required_fields?\n shelfkey = get_value_from_combined_key(combined_key, shelfkey_field)\n reverse_shelfkey = get_value_from_combined_key(combined_key, reverse_shelfkey_field)\n if normalized_page == 0\n previous_documents = get_next_documents_from_field_value(reverse_shelfkey, reverse_shelfkey_field)\n next_documents = get_next_documents_from_field_value(shelfkey, shelfkey_field)\n documents = [previous_documents, @original_document, next_documents].flatten\n elsif @opts[:page].to_i < 0\n documents = get_next_documents_from_field_value(reverse_shelfkey, reverse_shelfkey_field)\n elsif @opts[:page].to_i > 0\n documents = get_next_documents_from_field_value(shelfkey, shelfkey_field)\n end\n documents\n end", "def entities\n @entities ||= Entity.from_models(self, @models)\n end", "def ordered_docs\n @ordered_docs ||= ActiveFedora::SolrService.query(\"member_of_collection_ids_ssim:#{id}\", rows: 10_000).map { |x| SolrDocument.new(x) }\n end", "def index\n # @results = []\n # @document.bioc_doc.all_annotations.each do |a|\n # e = EntityUtil.get_annotation_entity(a)\n # a.locations.each do |l|\n # @results << {did: @document.did, offset: l.offset, text: a.text, length: l.length, infons: a.infons }\n # end\n # end\n @project = @document.project\n @version = params[:version] || @document.version\n @version = @version.to_i if @version.present?\n @is_manager = @project.manager?(current_user)\n\n if @is_manager || @project.collaborate_round\n @annotations = @document.annotations.where('`version`=?', @version)\n else\n @annotations = @assign.annotations\n end\n @annotations = @annotations.order(\"offset\")\n end", "def get_all\n get_docs\n get_text\n return JSON.pretty_generate(@data)\n end", "def to_hash\n result = { }\n\n # id\n result['_id'] = @_id if @_id\n\n # timestamp\n result['at'] = @at\n\n # kind\n result['kind'] = kind.to_s\n\n # entities\n @entities.each do |entity_name, entity|\n result[entity_name.to_s] = entity.model_id\n end\n\n # meta\n result['meta'] = @meta.stringify_keys unless @meta.blank?\n\n result\n end", "def all_articles\n all_articles = comment_articles + articles + mention_articles\n # debugger\n all_articles.uniq.sort_by {|article| article.updated_at}.reverse\n end", "def index\n render json: Term.roots\n .includes(:user)\n .map(&:serialize_list),\n status: :ok\n end", "def document_hashes(search_args = {})\n return @document_hashes if defined?(@document_hashes)\n @document_hashes = LazySearch.new(@client, @search_definition, search_args)\n end", "def as_indexed_json(*)\n attributes\n .symbolize_keys\n .slice(:id, :title, :body)\n end", "def index\n @entries = Entry.ordered\n end", "def all_article_titles_with_authors\n @all = {}\n search_techcrunch[\"articles\"].each do |hash|\n author = hash[\"author\"]\n title = hash[\"title\"]\n @all[title] = author\n end\n return @all\n end", "def entities\n @entities ||= Entities.from_grpc @grpc\n end", "def get_entity_types\n Occi::Log.debug(\"Getting entity types ...\")\n @model.kinds.collect { |kind| kind.term }\n end", "def related_content(options = {})\n api_url = \"/collections/#{self.collection.attributes[:token]}/pages/#{@attributes[:identifier]}/related\"\n response = @muddyit.send_request(api_url, :get, options, nil)\n results = []\n response.each { |result|\n # The return format needs sorting out here .......\n results.push :page => @attributes[:collection].pages.find(result['identifier']), :count => result['count']\n }\n return results\n end", "def get_entities(type)\n @entities[type.name]\n end", "def all\n @hits\n end", "def list\n @documentations = Documentation.not_article.order('created_at DESC')\n end", "def documents\n authorizations.map(&:document)\n end", "def index\n fact = to_json(Fact.last)\n tip = to_json(Tip.last)\n quote = to_json(Quote.last)\n expert_opinion = to_json(ExpertOpinion.last)\n faq = to_json(Faq.last)\n article = to_json(Article.last)\n testimony = to_json(Testimony.last)\n documentary = to_json(Documentary.last)\n \n json_response({ \n fact: fact,\n tip: tip, \n quote: quote,\n expert_opinion: expert_opinion,\n faq: faq,\n article: article,\n testimony: testimony,\n documentary: documentary\n })\n end", "def call\n total = dataset.document_count\n ret = {}\n\n enum = RLetters::Datasets::DocumentEnumerator.new(dataset: dataset)\n enum.each_with_index do |doc, i|\n progress&.call((i.to_f / total.to_f * 100).to_i)\n\n lister = Documents::WordList.new\n words = lister.words_for(doc.uid)\n\n tagged = Tagger.add_tags(words.join(' '))\n next if tagged.nil?\n\n nouns = Tagger.get_nouns(tagged)\n next if nouns.nil?\n\n ret.merge!(nouns) { |_, v1, v2| v1 + v2 }\n end\n\n progress&.call(100)\n ret.sort_by { |(_, v)| -v }\n end", "def index\n conditions = { :client_id => @client.id }\n if params[\"tags\"]\n conditions.merge!({:tags => params[\"tags\"]})\n end\n\n @collections = Collection.where(conditions).order('updated_at DESC')\n @collections.reject! { |item| ! item.read?(@user, @client) }\n\n entries = Array.new\n if @collections\n @collections.each do |item|\n entries << item.info_hash(@user, @client)\n end\n end\n render_json :entry => entries and return\n end", "def to_hash\n return self.document.to_hash\n end", "def calculate_inverse_document_frequency\n results = {}\n \n terms.each do |term|\n count = 0.0\n \n @data.each do |document|\n count += 1 if document.include?(term)\n end\n \n results[term] = Math.log10(total_documents / count)\n end\n \n results\n end", "def search_all_terms\n render json: Article.with_all_terms(params[:query]).map(&:title)\n end", "def create_entities\n results = []\n if @attributes.has_key?(:entities)\n @attributes[:entities].each do |result|\n results.push Muddyit::Collections::Collection::Entities::Entity.new(@muddyit, result.merge!(:collection => @attributes[:collection]))\n end\n @attributes[:entities] = results\n end\n end", "def to_indexed_json\n to_json( include: { comments: { only: [:content, :name] }, author: { only: [:name]} } )\n end", "def list\n collection = empty_collection\n all(params[:entity]).each do |bt|\n bt_coll = backend_proxy_for(bt).list\n collection.entities.merge bt_coll.entities\n end\n\n return if collection.only_categories?\n collection.valid!\n\n respond_with collection\n end", "def parse_entities(ents)\n ents.to_s\n ents.map(&:last).select{|e| e[\"type\"] == \"portal\"}\n #.map{|e|\n\n # {\n # \"title\" => e[\"title\"],\n # \"lat\" => e[\"latE6\"],\n # \"lng\" => e[\"lngE6\"],\n # \"resCount\" => e[\"resCount\"],\n # \"health\" => e[\"resCount\"],\n # \"team\" => e[\"team\"]\n # }\n #}\nend", "def get_entity_type_identifiers\n get_kind_type_identifiers_related_to Occi::Core::Entity.kind.type_identifier\n end", "def get_entity_list(entity_type, ns=Model::NS_MMD_1)\n # Search for the first occuring node of type entity which is a child node\n # of the metadata element.\n entity_list = @document.elements[\n \"//[local-name()='metadata' and namespace-uri()='%s']/[local-name()='%s-list' and namespace-uri()='%s'][1]\" %\n [Model::NS_MMD_1, entity_type, ns]]\n \n unless entity_list.nil? or entity_list.is_a? REXML::Text\n collection = Model::ScoredCollection.new(entity_list.attributes['count'],\n entity_list.attributes['offset'])\n # Select the method to use for reading the list.\n read_list_method = method('read_' + entity_list.name.gsub('-', '_'))\n \n # Read the entity list and store the entities in the collection.\n read_list_method.call(entity_list, collection, true) if read_list_method\n \n return collection\n else\n return Model::ScoredCollection.new\n end\n end", "def all\n @documents = Document.order(\"id DESC\").all\n end", "def hash\n [author, created, icon, id, integration_id, is_favorite, is_read_only, is_shared, modified, popularity, tags, title, type, url].hash\n end", "def to_h\n {\n id: @id,\n word: @word,\n author: @author,\n permalink: @permalink,\n definition: @definition,\n example: @example,\n upvotes: @upvotes,\n downvotes: @downvotes\n }\n end", "def index\n page = params[:page]\n per_page = (params[:per_page] || 10).to_i\n if page\n entities = _all_instances_query.page(page).per(per_page)\n render json: entities, entity: _get_class,\n meta: { total_pages: entities.total_pages, total_count: entities.total_count }\n else\n entities = _all_instances_query\n respond_with entities, entity: '_get_class'\n end\n end", "def index\n @tags = Tag.used.clone #This is a Hash with keys(tags) ordered from most used to least\n respond_with @taglist\n end", "def index\n @ideas = Idea.current_ideas_for(current_user).entries\n respond_with(@ideas) do |format|\n format.json { render json: @ideas }\n end\n end", "def bookmarks\n full = options[:full]\n docs = options[:doc] && documents.map { |doc| [doc.id, doc] }.to_h\n item_list.map { |item|\n next unless item.is_a?(Bookmark)\n entry = {\n document_id: item.document_id,\n document_type: item.document_type.to_s,\n lens: item.lens,\n updated_at: item.updated_at,\n created_at: item.created_at,\n }\n full && entry.merge!(\n title: item.user_type, # TODO: not persisted; should it be?\n id: item.id,\n user_id: item.user_id,\n user_type: item.user_type,\n )\n docs && entry.merge!(doc: docs[item.document_id])\n entry\n }.compact.as_json\n end", "def object_hash_get_all(collection)\n logger.debug \"Retrieving object documents from collection(#{collection})\"\n @database.object_doc_get_all(collection)\n end", "def object_hash_get_all(collection)\n logger.debug \"Retrieving object documents from collection(#{collection})\"\n @database.object_doc_get_all(collection)\n end", "def index\n if !@db\n render json: [], status: 200\n else\n docs = @db.all_docs(params={\"include_docs\":\"true\"})[\"rows\"]\n names = docs.map { |d| d[\"doc\"][\"name\"] }\n render json: JSON.dump(names), status: 200\n end\n end", "def index\n @documentations = Documentation.all.order(\"created_at desc\")\n end", "def index\n\t\t\t\tbookmarks = Bookmark.where(\"user_id == ?\", doorkeeper_token.resource_owner_id)\n\t\t\t\tformatted_bookmarks = []\n\t\t\t\tbookmarks.each do |bookmark|\n\t\t\t\t formatted_tags = []\n\t\t\t\t bookmark.tags.each do |tag|\n\t\t\t\t formatted_tags << tag.tagname\n\t\t\t\t end\t\t\t \n\t\t\t\t formatted_bookmarks << {:id => bookmark.id, :url => bookmark.url.url, :title => bookmark.title, :description => bookmark.description, :tags => formatted_tags}\n\t\t\t\tend\n\t\t\t\trespond_with formatted_bookmarks\n\t\t\tend", "def index\n @entity_types = EntityType.all\n end", "def hash\n return unless doc_value?\n result['doc']['hash']\n end", "def search_by_string entity_name,headers\n begin\n\n page_num = 1\n response = http_get_body(\"https://dehashed.com/search?query=#{entity_name}&page=#{page_num}\",nil, headers)\n json = JSON.parse(response)\n\n\n #check if entries different to null\n if json[\"entries\"]\n\n json[\"entries\"].each do |e|\n #check if Email different to null and create entity\n if e[\"email\"]\n _create_entity(\"EmailAddress\", {\"name\" => e[\"email\"]})\n end\n #check if username different to null and create entity\n if e[\"username\"]\n _create_entity(\"Person\", {\"name\" => e[\"username\"]})\n end\n #check if name different to null and create entity\n if e[\"name\"]\n _create_entity(\"Person\", {\"name\" => e[\"name\"]})\n end\n #check if phone number different to null and create entity\n if e[\"phone\"]\n _create_entity(\"PhoneNumber\", {\"name\" => e[\"phone\"]})\n end\n #check if address different to null and create entity\n #if e[\"address\"]\n # _create_entity(\"PhysicalLocation\", {\"name\" => e[\"address\"]})\n #end\n\n _create_issue({\n name: \"leak found related to: #{_get_entity_name} Source: #{e[\"obtained_from\"]}\",\n type: \"Data leak\",\n severity: 2,\n status: \"confirmed\",\n description:\"Email:#{e[\"email\"]}\\n username: #{e[\"username\"]}\\n password: *******#{e[\"password\"][-4...-1]}\\n\n # Hashed Password:#{e[\"hashed_password\"]}\\n IP Address: #{e[\"ip_address\"]}\\n phone:#{e[\"phone\"]} Source #{e[\"obtained_from\"]}\",\n details: e\n })\n end\n\n while json[\"entries\"] do\n page_num += 1\n\n response = http_get_body(\"https://dehashed.com/search?query=#{entity_name}&page=#{page_num}\",nil, headers)\n json = JSON.parse(response)\n\n #check if entries different to null\n if json[\"entries\"]\n\n json[\"entries\"].each do |e|\n #check if Email different to null and create entity\n if e[\"email\"]\n _create_entity(\"EmailAddress\", {\"name\" => e[\"email\"]})\n end\n #check if username different to null and create entity\n if e[\"username\"]\n _create_entity(\"Person\", {\"name\" => e[\"username\"]})\n end\n #check if name different to null and create entity\n if e[\"name\"]\n _create_entity(\"Person\", {\"name\" => e[\"name\"]})\n end\n #check if phone number different to null and create entity\n if e[\"phone\"]\n _create_entity(\"PhoneNumber\", {\"name\" => e[\"phone\"]})\n end\n #check if address different to null and create entity\n #if e[\"address\"]\n # _create_entity(\"PhysicalLocation\", {\"name\" => e[\"address\"]})\n #end\n\n _create_issue({\n name: \"leak found related to: #{_get_entity_name} Source: #{e[\"obtained_from\"]}\",\n type: \"Data leak\",\n severity: 2,\n status: \"confirmed\",\n description:\"Email:#{e[\"email\"]}\\n username: #{e[\"username\"]}\\n password: *******#{e[\"password\"][-4...-1]}\\n\n # Hashed Password:#{e[\"hashed_password\"]}\\n IP Address: #{e[\"ip_address\"]}\\n phone:#{e[\"phone\"]} Source #{e[\"obtained_from\"]}\",\n details: e\n })\n end\n end\n\n end\n end\n #exciption\n rescue JSON::ParserError => e\n _log_error \"Unable to parse JSON: #{e}\"\n end\n\n end", "def collected_entities entity_type, viewer=nil\n entity_type = entity_type.to_s\n if viewer == self\n assoc = entity_type.to_s\n scope = self.method(assoc).call\n scope = scope.where.not(owner_id: id) if entity_type == \"List\"\n scope\n else\n arr = collection_pointers.where(entity_type: entity_type, private: false).map(&:entity)\n arr = arr.keep_if { |l| l.owner != self } if entity_type == \"List\"\n arr\n end\n end", "def eds_documents(data)\n docs = data&.dig('response', 'docs')\n docs = Array.wrap(docs).compact\n factory = blacklight_config.document_factory\n model_opt = { lens: blacklight_config.lens_key }\n docs.map { |doc| factory.build(doc, data, model_opt) }\n end", "def index\n if admin?\n @entity_data = EntityDatum.all\n else\n @entity_data = EntityDatum.find current_entity.property_document_id\n end # end if admin?\n#logger.info \"#{File.basename(__FILE__)}.index:#{@entity_data.inspect}\"\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @entity_data }\n end\n end", "def index\n @hash_tags = HashTag.all\n end", "def all\n response = request(:get_all)\n handles = response.values.flatten.collect { |handle| Entity::Handle.build(handle) }\n\n if handles.size == 1\n # Fetch data for single entity\n find(handles.first)\n elsif handles.size > 1\n # Fetch all data for all the entities\n entity_data = get_data_array(handles)\n\n # Build Entity objects and add them to the proxy\n entity_data.each do |data|\n entity = build(data)\n entity.persisted = true\n end\n end\n\n self\n end", "def entities(*values)\n values.inject(self) { |res, val| res._entities(val) }\n end", "def get_entities_for_context( parent_context = nil )\n if parent_context.instance_of?( V3::ContextDAO )# Context specified? Return its entity list:\n parent_context.entity_list.values\n else # Let's do a \"manual\" search among the entities:\n # [Steve, 20150805] This check allows, so far, to have \"root entities\" laying around,\n # waiting to be fetched. 'Still don't know if it's a really useful feature at all...\n @entity_list.values.map do |entity|\n entity if entity.parent_context == parent_context\n end.compact\n end\n end", "def hits(options = {})\n if options[:verify]\n verified_hits\n elsif solr_docs\n solr_docs.map { |d| OoorHit.new(d, highlights_for(d), self) }\n else\n []\n end\n end", "def all_article_titles_with_content\n @all = {}\n search_techcrunch[\"articles\"].each do |hash|\n title = hash[\"title\"]\n content = hash[\"content\"]\n @all[title] = content\n end\n @all\n end", "def sort_docs_by_key!; end", "def metadata\n if with_compound\n result_with_id.merge('page' => compounds_to_h)\n else\n result_with_id.merge('page' => page)\n end\n end", "def index\n @finance_documents = FinanceDocument.all.order(\"updated_at DESC\").order(\"created_at DESC\")\n\n render json: @finance_documents\n end" ]
[ "0.6685144", "0.6448963", "0.5882639", "0.5882639", "0.5837262", "0.5734265", "0.5731404", "0.5664527", "0.5650625", "0.56401956", "0.56066865", "0.5595238", "0.5595238", "0.55951166", "0.5537426", "0.54904765", "0.5458033", "0.54162407", "0.54103583", "0.5402562", "0.53850853", "0.53667164", "0.5349253", "0.53408915", "0.5272838", "0.5263054", "0.5258989", "0.5256691", "0.52528954", "0.5249579", "0.5224563", "0.52244276", "0.5179425", "0.51789135", "0.51747245", "0.51554024", "0.5122323", "0.51176804", "0.51008534", "0.50784063", "0.50614727", "0.50539213", "0.50417715", "0.50305533", "0.5019331", "0.5009253", "0.5008085", "0.49971905", "0.4997153", "0.49938506", "0.49900442", "0.49894932", "0.49849233", "0.4984346", "0.49810153", "0.4977201", "0.49652654", "0.4956908", "0.49561745", "0.49500147", "0.4943062", "0.49363738", "0.4931952", "0.49178776", "0.4916317", "0.4900528", "0.48911676", "0.48883265", "0.48868495", "0.48799568", "0.4878229", "0.48781592", "0.48778623", "0.4876893", "0.487418", "0.4856632", "0.48546705", "0.48539284", "0.4846791", "0.484655", "0.4846224", "0.4846224", "0.48457938", "0.48374277", "0.4836475", "0.48350036", "0.48345277", "0.4833417", "0.48321435", "0.4831034", "0.48252282", "0.48224735", "0.4819689", "0.4817923", "0.4817321", "0.48130256", "0.48092845", "0.48045027", "0.48026958", "0.48014104" ]
0.67121935
0
updates the document's character count by detecting the largest end_offset off our pages.
def reset_char_count! update_attributes :char_count => 1+self.pages.maximum(:end_offset).to_i end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def char_length(offset, end_offset)\n effective_line = @locator.line_for_offset(end_offset) - @locator.line_for_offset(offset)\n locator.char_length(offset, end_offset) + (effective_line * @leading_line_offset)\n end", "def char_length(offset, end_offset)\n end", "def char_length(offset, end_offset)\n raise \"Should not be called\"\n end", "def update_counter(text)\n number_of_newlines = text.count(\"\\n\")\n\n if number_of_newlines > 0\n @line += text.count(\"\\n\")\n @column = text.length - text.rindex(\"\\n\")\n else\n @column += text.length\n end\n end", "def add_page_to_doc\n @page_content.each { |line| @doc_content += line}\n @pages_in_doc += 1\n if !@doc_start_page\n @doc_start_page = current_page()\n end\n return @doc_content\n end", "def end_document\n # postprocess @text to remove trailing spaces on lines\n @text = @text.split(\"\\n\").map(&:strip).join(\"\\n\")\n # remove trailing whitespace at end of buffer\n @text.strip!\n end", "def page_count_from_end(current_page, total_pages)\n (total_pages.to_i - current_page.to_i) + 1\n end", "def actual_page_count\n warn \"WARNING: actual_page_count is not yet implemented properly.\"\n warn \" Please send patches.\"\n @pages.count\n end", "def update_tweets_size\n total = content.length\n tweets = nil\n new_tweets = total / MAX_CHARS + ((total % MAX_CHARS).positive? ? 1 : 0)\n while new_tweets != tweets\n tweets = new_tweets # Tweets count\n pager_size = tweets.to_s.length * 2 + 2 # ' 45/45' --> 6\n real_total = pager_size * tweets + total\n new_tweets = real_total / MAX_CHARS + ((real_total % MAX_CHARS).positive? ? 1 : 0)\n end\n\n @tweet_count = tweets\n @pager_size = tweet_count.to_s.length * 2 + 2 # ' 45/45' --> 6\n end", "def page_count(doc)\n doc.at_css('.pagination') && doc.at_css('.pagination')\n .css('b')\n .map(&:text)\n .map(&:to_i)\n .max\n end", "def getNumberOfPages(doc)\n numberOfPages = 1\n\n doc.search(\"Document > View > ScrollView > VBoxView > View > MatrixView > VBoxView:nth(0) > HBoxView > TextView > SetFontStyle > b\").each do |e|\n # Parse the last number in the string, e.g. the 99 in \"Page 3 of 99\"\n numberOfPages = e.inner_html[/[0-9]+$/].to_i\n end\n\n return numberOfPages\nend", "def update_final_page_count(project)\n unless project.layout.nil?\n pgtr = project.project_grid_table_row\n pgtr.page_count = project.layout.final_page_count\n end\n end", "def refresh\n return data.length if data.length > 0\n if next_page\n @doc = get next_page\n elsif last_page?\n return 0\n else\n @doc = get(collection, params={:count => per_page, :start => start}.update(@opts['extra_args']))\n end\n return data.length\n end", "def end_document; end", "def end_document; end", "def char_length(offset, end_offset)\n if multibyte?\n @string.byteslice(offset, end_offset - offset).length\n else\n end_offset - offset\n end\n end", "def cursor_move_to_end\n @cursor_position = @text.scan(/./m).size\n self.reset_cursor_blinking\n end", "def determine_end_offset_relative_to_source(end_offset, last_line_length)\n end_offset - last_line_length - 1\n end", "def move_to_end\n @cursor = @text.length # put cursor outside of text\n end", "def move_to_end\n @cursor = @text.length # put cursor outside of text\n end", "def document_counter(idx)\n idx + 1\n end", "def end_pos; end", "def end_pos; end", "def update\n\t\t\tself.set(@start, @editor.buffer.index)\n\t\t\thighlight if @highlight\n\t\tend", "def find_page_end\n \n end", "def max_page(doc)\n last_page_link = doc.css(\"span.pagelinks a\").last['href']\n Integer(last_page_link[/p=(\\d+)&/,1])\nend", "def max_page(doc)\n last_page_link = doc.css(\"span.pagelinks a\").last['href']\n Integer(last_page_link[/p=(\\d+)&/,1])\nend", "def for_docs\n commits.each do |commit|\n @count += 1 if doc_commit?(commit.message)\n end\n self\n end", "def num_pages\n 26\n end", "def count\n @document.page_count\n end", "def word_end_pos(from: @cursor)\n end_pos = @text.index(separator, from) || text_size\n end_pos -= 1 unless @text.empty?\n end_pos\n end", "def update\n super\n #==========================================================================\n # Here we check for action from the directional keys - scrolling between\n # pages and up/down within a page, if applicable. It also updates the\n # page number display at the bottom of the window.\n #==========================================================================\n process_cursor_move\n @scrolldata.each_value { |v| v.update } if @scrolldata\n end", "def on_end_document\n end", "def char_length(offset, end_offset)\n string.byteslice(offset, end_offset - offset).length\n end", "def page_count\n @collection.max + 1\n end", "def input_end_offset\n _response_word.fetch(\"endingPos\", nil)\n end", "def num_pages\n n, rest = @num_entries.divmod(@entries_per_page)\n if rest > 0 then n + 1 else n end\n end", "def calc_index_width\n @last_index_width = (@index_width || [0])\n @index_width = [0]\n text = \"\"\n for i in 0..@strlen\n text += (@lpstr[i] || '')\n if @last_str[i] == @lpstr[i]\n @index_width[i+1] = @last_index_width[i+1]\n else\n @index_width[i+1] = self.contents.text_size(text).width\n end\n end \n end", "def adword_count_right(page)\n\t\tadword_urls_right(page).length\n\tend", "def new_doc\n @doc_content = \"\"\n @doc_start_page = nil\n @pages_in_doc = 0\n end", "def doc_size(categories)\n [*categories].inject(0){|sum, category|\n sum += @doc_counter[category] || 0\n }\n end", "def calculate_pages\n pdftk_cmd = \"#{CONFIG[:pdftk]} #{@source} dump_data | grep NumberOfPages | grep -o -e \\\"\\\\([0-9]*\\\\)$\\\"\"\n @pages = %x[#{pdftk_cmd}].to_i\n end", "def on_end_document\n STDOUT << \"on_end_document\\n\"\n STDOUT.flush\n end", "def page_length=(n)\n write(BrotherEscp::Sequence.page_length(n))\n end", "def update_loc_count(src_code)\n if src_code\n self.loc_count = src_code.each_line.reject{|l| l.blank?}.count\n end\n end", "def end_pos=(_); end", "def page_count\n bib_page_count\n end", "def offset_range\n return nil unless original_text\n start_pos.offset...(start_pos.offset + original_text.bytesize)\n end", "def cursor_end\n blen = @buffer.rstrip.length\n if blen < @width\n set_col_offset blen\n else\n @pcol = blen-@width\n #set_form_col @width-1\n set_col_offset blen\n end\n @curpos = blen # this is position in array where editing or motion is to happen regardless of what you see\n # regardless of pcol (panning)\n end", "def max_pages() 1 end", "def page_count\n @page_count = notices_count/30 + 1\n @page_count = max_pages if @page_count > max_pages\n @page_count\n end", "def count\n @count ||= documents.size\n end", "def num_pages \n if source_record['300'] && (source_record['300']['a'] =~ /(\\d{1,6}) ?pp?(?:[\\. ]|\\Z)(?!.*\\d+ pp?(?:[\\. ]|\\Z))/)\n return $1\n end\n\n return nil\n end", "def last_page\n (max_matches.to_f / per_page).ceil\n end", "def num_corpus_documents\n @corpus_size ||= begin\n solr_query = {}\n solr_query[:q] = '*:*'\n solr_query[:qt] = 'precise'\n solr_query[:rows] = 1\n solr_query[:start] = 0\n \n solr_response = Solr::Connection.find solr_query\n \n if solr_response[\"response\"] &&\n solr_response[\"response\"][\"numFound\"]\n solr_response[\"response\"][\"numFound\"]\n else\n # FIXME: Should we raise an error here?\n 1\n end\n end\n end", "def total_pages; end", "def max_length=(new_max_length)\n @max_length = new_max_length\n chars = @text.scan(/./m)\n @text = chars[0, @max_length].join if chars.size > @max_length\n self.cursor_move_to_end if @cursor_position > chars.size\n end", "def seek_contiguous_max(needle, step_lines = 10)\n\n file = @file\n max = nil\n\n # move to head of line\n seek_line_head\n\n loop do\n\n # file#pos before #forward_lines\n pos_old = file.pos\n\n lines = forward_lines(step_lines)\n lines_pos = lines.rindex(needle)\n\n # for debug\n # p [\n # lines: lines,\n # lines_pos: lines_pos,\n # file_pos: file.pos\n # ].to_s\n # sleep 0.05\n\n # if did not match needle\n # - returner is last set value to 'max'\n break if lines_pos.nil?\n\n lines_end_pos = str_byte_index(lines, /(\\r\\n|\\r|\\n)+?/, lines_pos)\n\n if lines_end_pos.nil?\n max = file.size if file.eof?\n break\n end\n\n max = pos_old + lines_end_pos\n\n # for debug\n # p [\n # lines: lines,\n # lines_bytesize: lines.bytesize,\n # lines_pos: lines_pos,\n # lines_end_pos: lines_end_pos,\n # file_pos: file.pos\n # ].to_s\n # sleep 0.05\n\n break if file.eof?\n break if lines_end_pos < lines.size - 1\n end\n\n file.seek(max) unless max.nil?\n max\n end", "def num_pages\n (except(:offset, :limit).count.to_f / limit_value).ceil\n end", "def collect_pages\n #find page terminator\n start_line = 0\n current_line = 0\n @lines.each_with_index do |line, i|\n current_line = i\n if end_of_page?(line, i)\n @pages << Page.new(start_line, i) # every page in raw document\n start_line = i + 1 \n end \n end #end of line.each\n \n if current_line > start_line\n page = Page.new(start_line, current_line)\n @pages << page\n end\n #puts \" collect_pages found #{@pages.length} pages\"\n @pages \n end", "def last_page_index\n num_pages() - 1\n end", "def page_size\n @raw_page['records'].size\n end", "def page_count\n file_groups\n @highest_page_count\n end", "def word_count_engine(document)\n document = document.gsub(/[^ 0-9A-Za-z]/, '').downcase.split(' ')\n\n store = {}\n max = 0\n\n document.each do |element|\n if store[element]\n store[element] += 1\n max = [store[element], max].max\n else\n store[element] = 1\n max = 1 if max == 0\n end\n end\n\n buckets = Array.new(max) { [] }\n\n store.each do |key, value|\n buckets[max - value].push([key, value.to_s])\n end\n\n buckets.flatten(1)\nend", "def goto_line pos\n pos = pos.to_i\n pages = ((pos * 1.00)/$pagesize).ceil\n pages -= 1\n $sta = pages * $pagesize + 1\n $cursor = pos\nend", "def last_page_num(cards)\n (cards.count / 8.to_f).ceil\n end", "def calculate_word_count\n 0x0C\n end", "def cursor_pageup\n @mode = (@mode + TABLE.size - 1) % TABLE.size\n refresh\n end", "def size\n reader.doccount\n end", "def end=(new_end)\n @end = new_end ? new_end.to_i : nil\n end", "def standard_document_size\n object.standard_document ? object.standard_document.size : nil\n end", "def cursor_end\n blen = @buffer.rstrip.length\n if blen < @width\n set_form_col blen\n else\n # there is a problem here FIXME. \n @pcol = blen-@width\n #set_form_col @width-1\n set_form_col blen\n end\n @curpos = blen # this is position in array where editing or motion is to happen regardless of what you see\n # regardless of pcol (panning)\n # $log.debug \" crusor END cp:#{@curpos} pcol:#{@pcol} b.l:#{@buffer.length} d_l:#{@width} fc:#{@form.col}\"\n #set_form_col @buffer.length\n end", "def deleteTextBackspaceTooBig cursor, nbToDelete\n nb = nbToDelete - cursor.column\n line = cursor.line - 1\n while nb > 0 && line >= 0\n nb -= @fileContent[line].size + 1\n line -= 1\n end\n if nb <= 0\n return nbToDelete\n else \n return nbToDelete - nb\n end\n end", "def goto_line pos\n pages = ((pos * 1.00) / @pagesize).ceil\n pages -= 1\n @sta = pages * @pagesize + 1\n @cursor = pos\nend", "def goto_end\n @cursor = @view.size - 1\n @sta = @view.size - @pagesize\n @old_cursor = nil\n redraw_required\nend", "def finalize_pos word, pos\n final_pos = word_pos_cache.get_or_set(word) do\n doublecheck = wordpos_lookup(word)\n if ['noun', 'verb'].none? &doublecheck.m(:include?)\n finalize_engtagger_pos(pos)\n else\n finalize_wordpos_pos(pos)\n end\n end\n save_proc(final_pos, word)\n { word: word, pos: [final_pos] }\n end", "def max_numbered_pages\n 1_000\n end", "def last_page_number\n number_of_pages\n end", "def update_cursor_pos\n @cursor_timer = 0\n pos = @text.virtual_position\n if pos == 0\n @cursor.x = 1\n else\n @cursor.x = @sprite.bitmap.text_size(value[0...pos]).width\n end\n end", "def length\n doc.search('td#runtime').text.to_i\n end", "def make\n count = Docsplit.extract_length(file_path.to_s)\n\n instance[pages_count_column] = count\n instance.run_callbacks(:save) { false }\n\n File.open(file.path)\n end", "def cursor_eol\n # pcol is based on max length not current line's length\n @pcol = @content_cols - @cols - 1\n _arr = _getarray\n @curpos = _arr[@current_index].size\n @repaint_required = true\n end", "def nonadword_count_total(page)\n\t\tnonadword_urls(page).length\n\tend", "def count(chr = nil, start = nil, stop = nil)\n num = 0\n self.each(chr, start, stop) { |entry| num += 1 }\n return num\n end", "def extract_end_page( existing_payload, solr_doc, fedora_doc )\n\n # for books and articles\n start_page = IngestHelpers.fedora_first_field_extract( fedora_doc, 'mods relatedItem part extent end' )\n return start_page if start_page.present?\n return nil\n end", "def page_count\n (unpaged_count.to_f / @entries_per_page).ceil\n end", "def update_position(position, scanner, search_phrase_1, search_phrase_2)\n matched = scanner.matched\n\n if matched.casecmp(search_phrase_1) == 0 || matched.casecmp(search_phrase_2) == 0\n position.store(scanner.matched.downcase, position[:word_count])\n end\n\n position[:word_count] += matched.split(' ').size\n end", "def page_count; pages.count; end", "def update_occurences(doc_vector)\n # Setup the occurences array\n @occurences = DocVector.new(doc_vector.length, 0) if @occurences.length == 0\n\n @occurences.add_up(doc_vector)\n end", "def finish\n if @write_options then\n write_options\n exit\n end\n\n @op_dir ||= 'doc'\n\n @rdoc_include << \".\" if @rdoc_include.empty?\n root = @root.to_s\n @rdoc_include << root unless @rdoc_include.include?(root)\n\n @exclude = self.exclude\n\n finish_page_dir\n\n check_files\n\n # If no template was specified, use the default template for the output\n # formatter\n\n unless @template then\n @template = @generator_name\n @template_dir = template_dir_for @template\n end\n\n if @locale_name\n @locale = RDoc::I18n::Locale[@locale_name]\n @locale.load(@locale_dir)\n else\n @locale = nil\n end\n\n self\n end", "def update_content\n\t\tday = Day.from_identifier(post_params[:day])\n\t\tdocument = Document.for_user(@user.id, day.year, day.month, day.day).first\n\t\traise \"Unknown document\" unless document\n\t\tdocument.content = post_params[:content]\n\t\tdocument.words = count_words(post_params[:content])\n\t\tdocument.save!\n\t\trender_ok\n\tend", "def word_count\n @@word_count\n end", "def process_cursor_move\n #==========================================================================\n # First we set oldpage to the current page number, so that we can check\n # if the page ended up changing. Then we check if the player has pressed\n # left - if they have and we are not on the first page, we go back a\n # page. After that we check if they have pressed right, and go forward if\n # we are not on the last page. Then we move on to scrolling up and down\n # within a page - if they hit up and are not at the top of the page, it\n # will scroll up, and if they hit down and are not at the bottom of the\n # page it will scroll down. After we are done checking for input, we\n # redraw the page if the page has changed.\n #==========================================================================\n if @changed\n @changed = false\n return\n end\n oldpage = @page\n if Input.trigger?(:LEFT) && 1 < @page\n @page -= 1\n elsif Input.trigger?(:RIGHT) && @page < max_pages\n @page += 1\n elsif ((Input.press?(:UP)) if Input.repeat?(:UP)) && self.oy > 0\n self.oy -= [scroll_speed, [0, (height+oy+contents_height-24)].min.abs].max\n draw_scroll\n elsif ((Input.press?(:DOWN)) if Input.repeat?(:DOWN))\n self.oy += [scroll_speed, [0, contents_height + 24 - height - oy].max].min\n draw_scroll\n end\n if oldpage != @page\n refresh and @changed = true\n end\n return true\n end", "def count(chr = nil, start = nil, stop = nil) \n num = 0\n self.each(chr, start, stop) { |entry| num += 1 }\n num\n end", "def last_page?; ! @doc.has_key? 'next' end", "def test_document_max_length\n\n new_document = Document.new( #:data => 'a' * (Document::MAX_FILE_SIZE - 1),\n :data => 'a' * 100,\n :unpacked => 0,\n :name => 'dummy.doc',\n :content_type => 'text/html',\n :created_by => @cathy.id)\n\n documents = Document.find(:all)\n design_review_documents = DesignReviewDocument.find(:all)\n\n new_document.attach(@mx234a_placement,\n document_types(:stackup),\n @cathy)\n\n updated_documents = Document.find(:all)\n updated_design_review_documents = DesignReviewDocument.find(:all)\n\n new_document_list = updated_documents - documents\n new_design_review_document_list = updated_design_review_documents - design_review_documents\n\n assert_equal(1, new_document_list.size)\n assert_equal(1, new_design_review_document_list.size)\n\n new_doc = new_document_list[0]\n new_design_review_document = new_design_review_document_list[0]\n\n assert_equal(new_document.id, new_doc.id)\n assert_equal(new_document.id, new_design_review_document.document_id)\n\n \n end", "def num_docs\n @client[:documents].count\n end", "def num_docs\n @client[DOCUMENTS_COLLECTION].count\n end", "def total_pages\n -1\n end", "def range_end\n @character_range[1]\n end" ]
[ "0.57933974", "0.56286603", "0.55321014", "0.54675525", "0.54235876", "0.5374911", "0.5298904", "0.52900696", "0.5244548", "0.52311796", "0.52136344", "0.51916903", "0.51326364", "0.5110331", "0.5110331", "0.5102242", "0.5098795", "0.5072326", "0.50568926", "0.50568926", "0.5047531", "0.50467616", "0.50467616", "0.50445783", "0.504064", "0.5031703", "0.5031703", "0.50302863", "0.50217557", "0.5005318", "0.49752998", "0.49722335", "0.4970414", "0.49524269", "0.49281335", "0.491267", "0.49007463", "0.4852173", "0.4834397", "0.48037696", "0.47658655", "0.47635812", "0.47462627", "0.4739483", "0.47351566", "0.47252658", "0.4722004", "0.4714633", "0.4712099", "0.4706661", "0.47004303", "0.46801355", "0.46738502", "0.46642923", "0.46592855", "0.4645564", "0.46353945", "0.4631203", "0.4630623", "0.46248668", "0.4614978", "0.46093476", "0.45963264", "0.4596012", "0.4593434", "0.4593347", "0.45846608", "0.45839107", "0.45820686", "0.4578722", "0.455991", "0.45528594", "0.45493355", "0.45488042", "0.4533192", "0.4531238", "0.45307967", "0.4530743", "0.45274514", "0.45197946", "0.45160887", "0.45095307", "0.45086288", "0.45081574", "0.45064327", "0.45041567", "0.45001602", "0.44984686", "0.44977385", "0.44965586", "0.449229", "0.44922197", "0.44887686", "0.4483474", "0.4483219", "0.44822323", "0.44802114", "0.44787", "0.44752803", "0.44744137" ]
0.7333622
0
Does this document have a title?
def titled? title.present? && (title != DEFAULT_TITLE) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hasTitle\n if @title then\n true\n else\n false\n end\n end", "def inferred_title?(document); end", "def has_title?\n @title != nil\n end", "def title?\n @assigned_paragraph_type == :title\n end", "def inferred_title?(document)\n return false unless document.is_a?(Jekyll::Document)\n\n meta = read_yaml(File.dirname(document.path), File.basename(document.path))\n !meta.key?(\"title\")\n end", "def page_title?\n @_page_title.present?\n end", "def title?\n !name? && tagline\n end", "def title?\n !title.nil? && !title.empty?\n end", "def title?\n !title.nil? && !title.empty?\n end", "def should_extract_title(doc)\n return true\n end", "def title?\n return false unless title\n return @display_title if defined?(@display_title)\n\n @display_title = (@text !~ %r!title=false!i)\n end", "def title_exist?(filename)\n test_file_existence(filename, Titles_Path, @title_data)\n end", "def title?\n [email protected]_s.empty?\n end", "def page_title_set?\n defined?(@_page_title)\n end", "def title_blank?\n self.title.blank?\n end", "def is_title\n false\n end", "def title_check\n \n\n if self.title\n \n if !self.title.include? \"Believe\" || \"Won't\" || \"Secret\"\n true\n else\n false\n end\n else\n false\n end\n end", "def allows_document?\n self.allows_title? && ![TITLE, COVER].include?(self.kind)\n end", "def window_title?\n window_title_set? and @_window_titles.any?\n end", "def empty_title?\n tag = xpath(\"//title\")\n return true if tag.nil? or tag.empty?\n return true if tag.children.empty?\n false\n end", "def title_is(title = nil)\n title_is_empty if title.nil? || title.empty?\n @title = title\n end", "def has_title?(library, title)\n\nend", "def title_with_page_title_check\n return @page.title if @page && [email protected]?\n title_without_page_title_check\n end", "def window_title_set?\n defined?(@_window_titles)\n end", "def title\n [email protected]?\n end", "def title_with_page_title_check\n return @content_node.title if @content_node && !@content_node.title.blank?\n title_without_page_title_check\n end", "def title_valid(title)\n if !title.empty?\n self.title = title\n return true\n else\n return false\n end\n end", "def check_title\n if self.title.blank? && st = (url && Site.by_link(self.url))\n self.title = (st.yield :Title, st.sampleURL)[:Title] || \"\"\n self.title = self.trimmed_title\n else\n self.title\n end\n end", "def exists?\n Window.exists?(@title, @text)\n end", "def existing_title\n valid = true\n existing_title = DATABASE.execute(\"SELECT * FROM anime_series WHERE title = '#{title}';\")\n \n if !existing_title.empty?\n valid = false\n end\n return valid\n end", "def valid?\n return false if @title.nil?\n true\n end", "def title_create?(title)\n if create?\n not titles_create_exception.include? title\n else\n titles_create_exception.include? title\n end\n end", "def can_i_read?(title)\n page_info_contains_key(title, 'readable', 'readable')\n end", "def product_title_exists?(input_title)\n\t\ttitle_exists = self.class.find_by_title(input_title) ? true : false\t\t\n\tend", "def title\n @doc.title || DEFAULT_TITLE\n end", "def valid?\n return false if @title.nil? || @title == \"\"\n\n true\n end", "def showTitle?(string)\n return string.start_with?(\"_\") ? false : true\n end", "def studium_generale?\n extended_title.nil?\n end", "def flash_missing_title?\n return if params[:article][:title].present?\n flash_error(:article_title_required.t)\n true\n end", "def part_of_title\n self.is_part_of && self.is_part_of.title ? self.is_part_of.title : nil\n end", "def allows_title?\n case kind\n when COVER, IMAGE1, AUDIO, VIDEO1, TITLE, TEXT then true\n else false\n end\n end", "def expected_title expected_title\n define_method 'has_expected_title?' do\n has_expected_title = expected_title.kind_of?(Regexp) ? expected_title =~ @browser.title : expected_title == @browser.title\n raise \"Expected title '#{expected_title}' instead of '#{@browser.title}'\" unless has_expected_title\n end\n end", "def is_title?(title)\n results = @client.find_game(title)\n title_names = results.collect{|game| game.name}\n title_names.uniq!\n title_names_downcase = title_names.map {|game| game.downcase}\n title_names_downcase.include? title.downcase\n end", "def check_title\n @page_title = \"FauxTwitter\"\n end", "def page_new?(title)\n page_info_contains_key(title, 'new')\n end", "def update_title?\r\n # If returning to title screen\r\n if $game_temp.to_title\r\n # Switch to title screen\r\n $scene = Scene_Title.new\r\n return true\r\n end\r\n return false\r\n end", "def deny_reserved_titles\n if in_root_folder? && !PageHub.resource_title_available?(self.title)\n errors.add :pretty_title, \"That title is reserved for internal usage.\"\n return false\n end\n end", "def loaded?(*how)\n pageTitle_element.present?\n end", "def title_enabled?(title)\n return true unless titles_filter.any?\n titles_filter.include? title\n end", "def title?; end", "def part_title\n self.has_part && self.has_part.title ? self.has_part.title : nil\n end", "def title(doc)\n node = doc.at('/html/head/title') and node.text\n end", "def verify_title(test_data)\n verify_values_match(test_data[UseOfCollections::TITLE.name], element_value(title_input))\n end", "def verify_title(test_data)\n verify_values_match(test_data[CoreUseOfCollectionsData::TITLE.name], element_value(title_input))\n end", "def browsing_titles?\n model_table_name == 'name_titles'\n end", "def expected_title(expected_title)\n define_method(\"has_expected_title?\") do\n has_expected_title = expected_title.kind_of?(Regexp) ? expected_title =~ title : expected_title == title\n raise \"Expected title '#{expected_title}' instead of '#{title}'\" unless has_expected_title\n has_expected_title\n end\n end", "def contained?\n has_field?(:container, :journal) ||\n has_field?(:booktitle) && get(:booktitle) != get(:title)\n end", "def bypass_title_validation?\n bypass_title_validation\n end", "def page_title title= nil\n\t\tif title\n\t\t\tcontent_for(:page_title) { \"#{title} - 2da.re\" }\n\t\t\treturn title\n\t\telse\n\t\t\tcontent_for?(:page_title) ? content_for(:page_title) : \"Ready 2da.re?\"\n\t\tend\n\tend", "def mutate_h1? doc\n h1s = doc.css('h1') || []\n if h1s.size == 0\n false\n else\n stuff = doc.css('body>*')\n if stuff.size == 1\n false\n else\n true\n end\n end\n end", "def has_movie(title)\n page.has_css?(@movie_list_css, text: title)\n end", "def display_name\n title.present? && title || _('Untitled')\n end", "def mutate_h1?(doc)\n h1s = doc.css('h1') || []\n if h1s.empty?\n false\n else\n stuff = doc.css('body>*')\n if stuff.size == 1\n false\n else\n true\n end\n end\n end", "def validate_title\n errors.add(:title, :must_be_null_in_this_slide) if !self.allows_title? && !self.title.nil?\n end", "def title_first_post\n return current_user.poems.count == 1\n end", "def update_to_title?\r\n # If returning to title screen\r\n if $game_temp.to_title\r\n # Change to title screen\r\n $scene = Scene_Title.new\r\n return true\r\n end\r\n return false\r\n end", "def display_header?\n [email protected]_title?\n end", "def verify_page?(key, exit = true)\n base_title = wait_for_title(exit)\n puts \"Verify Title - Desired Prefix: #{site.get_title(key)} => Full Title: #{page_title}\" if exit\n if site.get_title(key) != base_title\n fail(\"Page title does not match expected result. EXPECTED: #{site.get_title(key)} FOUND: #{page_title}\") if exit\n return false\n end\n return true\n end", "def assert_title(title)\n assert_seen title, :within => \"head title\"\n end", "def title\n @rdig_document.title\n end", "def published_with_new_title?(change_set)\n change_set.resource.decorate.public_readable_state? && change_set.changed?(:title)\n end", "def title\n @title ||= parsed_document.css('title').inner_text rescue nil\n end", "def original_title\n document[\"originalTitle\"] rescue nil\n end", "def is_title_case\n if title.split.any?{|w|w[0].upcase != w[0]}\n errors.add(:title, \"Title must be in title case\")\n end\n end", "def valid?\n title_or_description.to_s != ''\n end", "def title\n evaluate(\"document.title\")\n end", "def title\n t = nil\n # default to long title\n long_titles = self.courses.map(&:long_title)\n return t if (t = long_titles.find(&:present?)).present?\n\n # then try specific title. then short title\n return self.specific_title if self.specific_title.present?\n\n short_titles = self.courses.map(&:short_title)\n return t if (t = short_titles.find(&:present?)).present?\n\n return '(Title Unavailable)'\n end", "def document_show_html_title document=nil\n document ||= @document\n\n presenter(document).html_title\n end", "def title_unique?\n song = Song.find_by(title: self.title)\n if song && song.release_year == self.release_year\n errors.add(:title, \"Artist cannot release same song in one year.\")\n end\n end", "def title\n @title ||= Utilities.longest_common_substring_in_array(titles.values) \n @title = titles[:og_title] unless title_ok?\n @title = titles[:html_title] unless title_ok?\n @title = titles[:from_doc] unless title_ok?\n\n @title\n end", "def title\n document.search(\".bookTitle\").innerHTML.strip rescue nil\n end", "def title\n if @title == nil\n \"Movie not found!\"\n else\n @title\n end\n end", "def title\n return super if block_given?\n\n @title || if show?\n content_tag('span', presenter.heading, itemprop: \"name\")\n else\n @view_context.link_to_document @document, counter: @counter, itemprop: 'name'\n end\n end", "def no_title!\n @no_title = true\n end", "def remove_title_if_present\n @doc.css('title').each { |node| node.remove }\n end", "def title\n return @title if @title\n return @filename if @filename\n return @type if @type\n return \"Unknown file name\"\n end", "def post_title\n if !self.title.nil?\n phrases = [\"Won\\'t Believe\", \"Secret\", \"Top\", \"Guess\"]\n if !phrases.any? {|phrase| self.title.include?(phrase)}\n errors.add(:title, \"Not enough!\")\n end\n else\n errors.add(:title, \"Not enough!\")\n end\n end", "def custom_slug_or_title\n title.presence\n end", "def title\n @data.title ||= parsed_document.css('title').inner_html.gsub(/\\t|\\n|\\r/, '') rescue nil\n end", "def title\n @title ||= self.content.split(@@title_separator).first unless self.content.nil?\n end", "def title_only_by_default?(view)\n return false if %i[show enabled].include?(view)\n\n title_only = default_blacklight_config.view.send(:[], view)&.title_only_by_default\n title_only.nil? ? false : title_only\n end", "def exists?(title, text = \"\")\n @functions[__method__] ||= AU3_Function.new(\"WinExists\", 'SS', 'L')\n @functions[__method__].call(title.wide, text.wide) == 1\n end", "def title(force_refresh = false)\n if @title && !force_refresh\n @title\n else\n @title = document[\"title\"] rescue nil\n end\n end", "def title\n return nil\n end", "def document_show_html_title\n @document[Blacklight.config[:show][:html_title]]\n end", "def matches_query?\n self.title == query[:text]\n end", "def resource_present?(type, title)\n !!catalog.resource(type, title)\n end", "def isSeriesTitle(title)\n $titleCount[title] == 1 and return false\n ft = transliterate(title).downcase.gsub(/^[\\[\\(]|[\\)\\]]$/, '').gsub(/\\s\\s+/, ' ').gsub('’', '\\'').strip()\n return $seriesTitlesPat.match(ft)\nend", "def accurate_title\n nil\n end", "def has_content?\n ( not self.title.nil? and not self.title.length == 0 ) or \n (not self.description.nil? and not self.description.length == 0 ) or \n (not self.teaser.nil? and not self.teaser.length == 0 )\n end" ]
[ "0.8606401", "0.8454915", "0.8200039", "0.8041204", "0.8004934", "0.79137343", "0.78353626", "0.7740822", "0.7740822", "0.7700232", "0.76467276", "0.75731164", "0.7557868", "0.75455636", "0.74813765", "0.74781764", "0.7375217", "0.7311967", "0.72917736", "0.72851545", "0.72036564", "0.7124486", "0.70793104", "0.7060561", "0.7047885", "0.70399845", "0.70316255", "0.6976684", "0.69631314", "0.6946809", "0.69351274", "0.69162166", "0.68846637", "0.6861311", "0.6837478", "0.68322355", "0.6811603", "0.68038946", "0.6788", "0.6787509", "0.6787339", "0.67327094", "0.6704671", "0.6674592", "0.664209", "0.66259634", "0.6623683", "0.66209996", "0.66061556", "0.6600715", "0.6561727", "0.6556115", "0.6551712", "0.6549513", "0.653296", "0.6529152", "0.6482031", "0.64668757", "0.6446585", "0.64214087", "0.6411309", "0.64047986", "0.64029753", "0.64009047", "0.6395978", "0.638918", "0.63809055", "0.6366456", "0.63319916", "0.63182557", "0.63031733", "0.62994474", "0.62947214", "0.62916285", "0.62798995", "0.62774354", "0.627576", "0.6268209", "0.6264761", "0.6250076", "0.6246853", "0.6237542", "0.6226545", "0.6222834", "0.62129813", "0.61893404", "0.6180249", "0.6168198", "0.6166451", "0.61647415", "0.6160343", "0.6159952", "0.61541337", "0.6145988", "0.6128987", "0.61280334", "0.6122951", "0.61222863", "0.6121403", "0.611" ]
0.7805069
7
When the access level changes, all subresource and asset permissions need to be updated.
def set_access(access_level) changes = {:access => PENDING} changes[:publish_at] = nil if PUBLIC_LEVELS.include? access_level update_attributes changes background_update_asset_access access_level end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "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 do_acl_changes\n if access_controls.requires_changes?\n converge_by(access_controls.describe_changes) do\n access_controls.set_all\n end\n end\n end", "def do_acl_changes\n if access_controls.requires_changes?\n converge_by(access_controls.describe_changes) do\n access_controls.set_all\n end\n end\n end", "def set_access_levels\n user_access_controls.each(&:disable!) if persisted? && disabled\n end", "def update_permissions\n self.view_permission.update_attribute(:name, name + \" view\")\n self.signup_permission.update_attribute(:name, name + \" signup\")\n self.admin_permission.update_attribute(:name, name + \" admin\")\n end", "def update\n success = false;\n error = \"Resource not available.\"\n permissions = nil\n\n if params.key?(:id) and params.key?(:permissions)\n permissions = ProjectPermission.find_by(id: params[:id])\n if permissions\n if permissions.user and permissions.user == @current_user\n error = \"User permissions may not be modified.\"\n else\n project = permissions.project\n if project and user_can_access_project(project.id, [:can_author])\n\n p = params.require(:permissions).permit(\n :can_author, :can_view, :can_annotate).to_h\n\n p['can_view'] = p['can_view'] == 'true' if p.key? 'can_view'\n p['can_annotate'] = p['can_annotate'] == 'true' if p.key? 'can_annotate'\n p['can_author'] = p['can_author'] == 'true' if p.key? 'can_author'\n\n ## Authors get full permissions.\n if p['can_author']\n p['can_view'] = true\n p['can_annotate'] = true\n p['can_author'] = true\n ## Annotators get at least viewing and annotation permissions.\n elsif p['can_annotate']\n p['can_view'] = true\n end\n\n\n ## Make sure that can_view is not being taken away from a user with\n ## authoring or annotation permissions.\n if( !p['can_view'] and (\n get_with_default(p, 'can_author', permissions.can_author.to_s) == 'true' or \n get_with_default(p, 'can_annotate', permissions.can_annotate.to_s) == 'true'))\n # Rails.logger.debug \"Hello -- ILLEGAL STATE REACHED!\"\n error = \"Illegal state of permissions: you cannot revoke \"+\n \"viewing permissions from an author or annotator.\"\n else\n success = permissions.update(p)\n error = \"Error updating permissions.\" unless success\n end\n\n \n # success = false;\n # error = \"#{params.to_json} #{p.to_json}\"\n end\n end\n end\n end\n\n if success\n render json: permissions, serializer: ProjectPermissionSerializer,\n root: \"permissions\"\n else\n render_error error\n end\n end", "def set_permissions_to(perm_level)\r\n unless self.relationshiptype_id == perm_level\r\n if self.new?\r\n self.relationshiptype_id = perm_level\r\n self.save! #for validation on create to happen\r\n else\r\n update_attribute(:relationshiptype_id, perm_level)\r\n end\r\n end\r\n \r\n if self.is_a?(Album)\r\n self.album_contents.each {|item| item.set_permissions_to(perm_level) }\r\n end\r\n end", "def update_subject_permissions\n @subject = Subject.find(params[:subject_id])\n user_login = params[:user][:login] unless params[:user].nil?\n @us = User.find_by_login(user_login) \n @ac = params[:level]\n @subject.allow!( @us, @ac.to_sym ) unless @us.nil?\n @subject.inherit_permissions! if params[:inherits]\n end", "def set_access_level(access_level)\n if access_level >= 1\n self.commenter = true\n else\n self.commenter = false\n end\n if access_level >= 2\n self.editor = true\n else\n self.editor = false\n end\n if access_level >= 3\n self.administrator = true\n else\n self.administrator = false\n end\n end", "def access_level=(lvl)\n debug \"Setting new access_level in Uv::Storage::File#access_level=#{lvl}\"\n\n #@access_level = lvl\n lvl = uv_access_level(lvl)\n\n debug \"New access_level is '#{lvl}'\"\n\n begin\n if self.mapping.present?\n debug \"File already exists on Uv::Storage, trying to update the record\"\n\n self.mapping.file_path = self.connection.update(mapping.nodes, mapping.file_path, { 'access_level' => lvl } )\n self.mapping.access_level = lvl\n self.mapping.save\n end\n rescue => e\n fatal \"Failed to update remote file and save mapping.\"\n fatal \"Error was: #{e}\"\n\n return false\n end\n\n # update the options (if the file will be saved afterwards)\n self.options['access_level'] = lvl\n\n return true\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 set_access\n @access = @current_event.accesses.find(params[:id])\n authorize @access\n end", "def resource_access=(value)\n @resource_access = value\n end", "def resource_access=(value)\n @resource_access = value\n end", "def update_permissions_if_vcs_changed\n return unless saved_change_to_vcs_submit?\n Repository.get_class.update_permissions\n end", "def access_level=(new_level)\n super new_level.to_s\n end", "def access_level=(new_level)\n super new_level.to_s\n end", "def update!(**args)\n @access = args[:access] if args.key?(:access)\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", "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", "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", "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", "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_permissions_on_storage\n if @options[:perms]\n response = system(\"chmod -R o+w #{File.join(@path, 'storage')}\")\n if response\n say_success \"Updated permissions on storage/ directory.\"\n else\n say_failed \"Could not update permissions on storage/ directory.\"\n end\n end\n end", "def manage_readonly_access\n if self.config_type == 'Read-Only Access Control'\n if ApplicationController.read_only_firecloud_client.present?\n if self.value_changed?\n AdminConfiguration.set_readonly_service_account_permissions(self.convert_value_by_type)\n end\n else\n errors.add(:config_type, '- You have not enabled the read-only service account yet. You must enable this account first before continuing. Please see https://github.com/broadinstitute/single_cell_portal_core#running-the-container#read-only-service-account for more information.')\n end\n end\n end", "def child_acl\n acl = super\n acl << {\n 'privilege' => '{DAV:}read',\n 'principal' => @calendar_info['principaluri'],\n 'protected' => true\n }\n\n unless @calendar_info['{http://sabredav.org/ns}read-only']\n acl << {\n 'privilege' => '{DAV:}write',\n 'principal' => @calendar_info['principaluri'],\n 'protected' => true\n }\n end\n\n acl\n end", "def permissions\n Sufia::GenericFile::Permissions.parse_permissions(params)\n @generic_file.update_attributes(params[:generic_file].reject { |k,v| %w{ Filedata Filename revision}.include? k})\n @generic_file.save\n Resque.enqueue(ContentUpdateEventJob, @generic_file.pid, current_user.user_key)\n redirect_to sufia.edit_generic_file_path, :notice => render_to_string(:partial=>'generic_files/asset_updated_flash', :locals => { :generic_file => @generic_file })\n end", "def update_level_\n end", "def update\n @role = Role.find(params[:id])\n authorize @role\n\n if @role.update(access: role_params[:access])\n deliver_if(recipients: @role.user, key: 'users.added_as_coowner') do |_r|\n UserMailer.permissions_change_notification(@role, current_user).deliver_now\n end\n render json: {\n code: 1,\n msg: format(_('Successfully changed the permissions for %{email}. They have been\n notified via email.'), email: @role.user.email)\n }\n else\n render json: { code: 0, msg: flash[:alert] }\n end\n end", "def update!(**args)\n @permissions = args[:permissions] unless args[:permissions].nil?\n end", "def update!(**args)\n @granted = args[:granted] if args.key?(:granted)\n @permission = args[:permission] if args.key?(:permission)\n @resource = args[:resource] if args.key?(:resource)\n @resource_attributes = args[:resource_attributes] if args.key?(:resource_attributes)\n end", "def update!(**args)\n @permissions = args[:permissions] unless args[:permissions].nil?\n end", "def update_permissions\r\n if request.post? and @logged_in_user.is_admin?\r\n # update the create, read, update, delete right for this folder:\r\n update_group_permissions(folder_id, params[:create_check_box], 'create', params[:update_recursively][:checked] == 'yes' ? true : false)\r\n update_group_permissions(folder_id, params[:read_check_box], 'read', params[:update_recursively][:checked] == 'yes' ? true : false)\r\n update_group_permissions(folder_id, params[:update_check_box], 'update', params[:update_recursively][:checked] == 'yes' ? true : false)\r\n update_group_permissions(folder_id, params[:delete_check_box], 'delete', params[:update_recursively][:checked] == 'yes' ? true : false)\r\n end\r\n\r\n # Return to the folder\r\n redirect_to :action => 'list', :id => folder_id\r\n end", "def update_permissions\n self.admin_permission.update_attribute(:name, name + \" dept admin\")\n end", "def update_user\n current_user.update_last_access if current_user && signed_in?\n end", "def uv_access_level(access_level = nil)\n access_level = self.access_level if access_level.blank?\n\n case access_level.to_s\n when 'public-read', 'public'\n Uv::Storage::File::ACL_PUBLIC\n when 'authenticated-read', 'protected'\n Uv::Storage::File::ACL_PROTECTED\n when 'private'\n Uv::Storage::File::ACL_PRIVATE\n else\n Uv::Storage::File::ACL_PUBLIC\n end\n end", "def update!(**args)\n @permission = args[:permission] if args.key?(:permission)\n end", "def update!(**args)\n @permission = args[:permission] if args.key?(:permission)\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 authorize_updating\n unless current.user.can_update? folder_id\n flash[:folder_error] = 'You don\\'t have update permissions for this folder.'\n redirect_to folder_path(folder_id)\n end\n end", "def smart?; self.permission_level = 2; end", "def update\n options = { fallback_location: study_path(@study) }\n notice = 'Permission updated successfully'\n options[:alert] = 'You cannot modify permissions for the only study owner.' if @study.single_owner?(@permission.user)\n unless :alert.in?(options)\n @permission.update(permission_params) ?\n options[:notice] = notice :\n options[:alert] = 'There was an error updating the permissions.'\n end\n redirect_back options\n end", "def set_permission\r\n\r\n render :nothing => true\r\n return if params[:access_id].blank? || params[:set].blank?\r\n @access = Access.find(params[:access_id])\r\n return if @access.nil?\r\n @set = params[:set] == 'true'\r\n if params[:user_id]\r\n @user = User.find(params[:user_id])\r\n h = {:user_id => @user.id, :access_id => @access.id}\r\n if params[:prop]\r\n @ua = UserAccess.first(:conditions => h) || UserAccess.create(h)\r\n @ua.read = @set if params[:prop] == 'read'\r\n @ua.write = @set if params[:prop] == 'write'\r\n @ua.save\r\n else # aktion\r\n if @set\r\n UserAccess.create(h) unless UserAccess.exists?(h)\r\n else\r\n UserAccess.delete_all(h) if UserAccess.exists?(h)\r\n end\r\n end\r\n end\r\n if params[:profile_id]\r\n @profile = Profile.find(params[:profile_id])\r\n h = {:profile_id => @profile.id, :access_id => @access.id}\r\n if params[:prop]\r\n @pa = ProfileAccess.first(:conditions => h) || ProfileAccess.create(h)\r\n @pa.read = @set if params[:prop] == 'read'\r\n @pa.write = @set if params[:prop] == 'write'\r\n @pa.save\r\n else # aktion\r\n if @set\r\n ProfileAccess.create(h) unless ProfileAccess.exists?(h)\r\n else\r\n ProfileAccess.delete_all(h) if ProfileAccess.exists?(h)\r\n end\r\n end\r\n end\r\n end", "def update\n authorize! :update, @operation_level\n respond_to do |format|\n if @operation_level.update(operation_level_params)\n format.html { redirect_to @operation_level, notice: 'Operation level was successfully updated.' }\n format.json { render :show, status: :ok, location: @operation_level }\n else\n format.html { render :edit }\n format.json { render json: @operation_level.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n \n if request.get?\n @role = Role.find(params[:id].to_i)\n else\n @role = Role.find(params[:id].to_i)\n\n # set parent role\n if not params[:role][:parent].to_s.empty?\n @role.parent = Role.find(params[:role][:parent])\n else\n @role.parent = nil\n end\n\n # get an array of static permissions and set the permission associations\n params[:role][:static_permissions] = [] if params[:role][:static_permissions].nil?\n permissions = params[:role][:static_permissions].collect { |i| StaticPermission.find(i) }\n @role.static_permissions = permissions\n\n if @role.update_attributes(params[:role])\n flash[:success] = 'Role has been updated successfully.'\n redirect_to :action => 'show', :id => @role\n else\n render :action => 'update'\n end\n end\n \n rescue RecursionInTree\n @role.errors.add :parent, \"must not be a descendant of itself\"\n render :action => 'update'\n rescue ActiveRecord::RecordNotFound\n flash[:error] = 'You sent an invalid request.'\n redirect_to :action => 'list'\n end" ]
[ "0.6638481", "0.6476497", "0.6476497", "0.6448233", "0.62101257", "0.61848336", "0.6075828", "0.6074644", "0.600127", "0.59954625", "0.59309286", "0.59273237", "0.58997303", "0.58997303", "0.58597916", "0.5847865", "0.5847865", "0.57794476", "0.5778734", "0.5778734", "0.5778734", "0.5778734", "0.5778734", "0.5778734", "0.5778734", "0.5778734", "0.5778734", "0.5778734", "0.5778734", "0.5778734", "0.5778734", "0.5778734", "0.5778734", "0.5778734", "0.5778734", "0.5778734", "0.5778734", "0.5778734", "0.5778734", "0.5778734", "0.5778734", "0.5778734", "0.5778734", "0.5778734", "0.5778734", "0.5778734", "0.5778734", "0.5778734", "0.5778734", "0.5778734", "0.5778734", "0.5778734", "0.5778734", "0.5778734", "0.5778734", "0.5778734", "0.5778734", "0.5778734", "0.5778734", "0.5778734", "0.5778734", "0.5778734", "0.5778734", "0.5778734", "0.5778734", "0.5778734", "0.5778734", "0.5778734", "0.5778734", "0.5778734", "0.5778734", "0.57777816", "0.577772", "0.5777289", "0.57746345", "0.57746345", "0.577127", "0.57102364", "0.57089734", "0.5691148", "0.5687945", "0.5687444", "0.56774807", "0.567604", "0.5675783", "0.5652325", "0.56446475", "0.5644012", "0.56360734", "0.5630689", "0.5630689", "0.562875", "0.562875", "0.562875", "0.5619911", "0.56153405", "0.5611776", "0.56051105", "0.55980194", "0.559263" ]
0.6898231
0
If we need to change the ownership of the document, we have to propagate the change to all associated models.
def set_owner(account) unless org = account.organization errors.add(:account, "must have an organization") and return false end update_attributes(:account_id => account.id, :organization_id => org.id) sql = "account_id = #{account.id}, organization_id = #{org.id}" self.pages.update_all( sql ) self.entities.update_all( sql ) self.entity_dates.update_all( sql ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def restore_ownership; end", "def restore_ownership; end", "def after_save \n return unless @owner\n\n unless owner_role.nil?\n owner_role.users.each do |user|\n accepts_no_role!( :owner, user ) # unassign previous owners\n end\n end\n \n accepts_role!( :owner, @owner ) # assign new owner\n\n # clean up\n self.reload\n @owner = nil\n end", "def update_owner(user)\n self.notify = true if self.owner != user\n self.owner = user unless user.nil?\n self.save\n end", "def owner=(newuser) #:nodoc:\n saved? ? raise(NotImplementedError, \"Cannot change a document's owner once the document has been saved\") : super\n end", "def restore_ownership=(_arg0); end", "def restore_ownership=(_arg0); end", "def change_owner!(user_changing, user_to_be_changed)\n if(!user_changing.persisted? || super_admin != user_changing)\n raise SecurityError.new \"No Permissions\"\n end \n exist_user?(user_to_be_changed)\n if(super_admin != user_changing)\n ActiveRecord::Base.transaction do\n remove_user!(user_changing, user_to_be_changed)\n participants.create(user_id: user_changing.id, member_type: Course.roles[\"admin\"])\n update(super_admin: user_to_be_changed)\n end\n end\n\nend", "def transfer_ownership\n transaction do\n Collaborator.create resourceable: resourceable, user: resourceable.owner\n resourceable.update(owner: user)\n destroy\n end\n end", "def propagate_acl()\n\n #Propagate to subfolders\n self.children.each do |subfolder|\n if subfolder.acl.inherits\n acl = self.acl.deep_clone()\n acl.inherits = true\n acl.save\n\n subfolder.acl = acl\n subfolder.save\n\n subfolder.propagate_acl()\n end\n end\n\n #Propagate to documents\n self.references.each do |reference|\n if reference.acl.inherits\n acl = self.acl.deep_clone()\n acl.inherits = true\n acl.save\n reference.acl = acl\n reference.save\n end\n end\n\n\n end", "def update\n find_params = document_review_owner_params.slice(:user_id, :project_id)\n review_owner = DocumentReviewOwner.find_or_initialize_by(find_params)\n authorize! :update, review_owner\n review_owner.assign_attributes(document_review_owner_params)\n if review_owner.save\n render json: review_owner\n else\n render json: review_owner.errors, status: :unprocessable_entity\n end\n end", "def update_document(obj)\n visibility_changed = visibility_status(obj)\n obj.attributes = work_params\n obj.date_modified = Time.current.ctime\n obj.save\n VisibilityCopyJob.perform_later(obj) if visibility_changed\n InheritPermissionsJob.perform_later(obj) if work_params.fetch(:permissions_attributes, nil)\n end", "def change_ownership(creation, pseud)\n creation.pseuds.delete(self)\n creation.pseuds << pseud rescue nil\n if creation.is_a?(Work)\n creation.chapters.each {|chapter| self.change_ownership(chapter, pseud)}\n for series in creation.series\n if series.works.count > 1 && (series.works - [creation]).collect(&:pseuds).flatten.include?(self)\n series.pseuds << pseud rescue nil\n else\n self.change_ownership(series, pseud)\n end\n end\n comment_ids = creation.find_all_comments.collect(&:id).join(\",\")\n Comment.update_all(\"pseud_id = #{pseud.id}\", \"pseud_id = '#{self.id}' AND id IN (#{comment_ids})\") unless comment_ids.blank?\n end\n end", "def autoset_owner\n bypass_auth do\n if accessor\n self.owner_id ||= accessor.id\n end\n end\n\n true # this is very important!\n end", "def update_owner(organization, owner_id)\n if owner_id\n new_owner = User.find(owner_id)\n\n unless new_owner.owns\n new_owner.organization = organization\n new_owner.save\n end\n end\n end", "def ensure_author_orcid\n return if @resource.owner_author # the owner is already represented by an author with their orcid\n\n user = @resource.user\n\n this_author = @resource.authors.where(author_first_name: user.first_name, author_last_name: user.last_name).first\n\n if this_author.present?\n this_author.update(author_orcid: user.orcid)\n return\n end\n\n StashEngine::Author.create(\n author_first_name: user.first_name,\n author_last_name: user.last_name,\n author_orcid: user.orcid,\n author_email: user.email,\n resource_id: @resource.id\n )\n end", "def principals\n modify\n end", "def ensure_ownership\n raise StandardError, I18n.t('user.unauthorised', email: current_user.email) if @post.user != current_user\n end", "def update\n valid = true\n to_add = []\n to_remove = []\n unless params[:author] == nil\n params[:author].each_key do |author_id|\n author_assoc = params[:author][author_id]\n unless author_assoc.blank?\n to_remove << PublicationAuthor.find_by_id(author_id)\n p = Person.find(author_assoc).user\n if @publication.asset.creators.include?(p)\n @publication.errors.add_to_base(\"Multiple authors cannot be associated with the same MethodBox person.\")\n valid = false\n else\n to_add << p\n end\n end\n end\n end\n \n #Check for duplicate authors\n if valid && (to_add.uniq.size != to_add.size)\n @publication.errors.add_to_base(\"Multiple authors cannot be associated with the same MethodBox person.\")\n valid = false\n end\n\n respond_to do |format|\n if valid && @publication.update_attributes(params[:publication]) \n to_add.each {|a| @publication.asset.creators << a}\n to_remove.each {|a| a.destroy}\n \n #Create policy if not present (should be)\n if @publication.asset.policy.nil?\n @publication.asset.policy = Policy.create(:name => \"publication_policy\", :sharing_scope => 3, :access_type => 1, :use_custom_sharing => true)\n @publication.asset.save\n end\n \n #Update policy so current authors have manage permissions\n @publication.asset.creators.each do |author|\n @publication.asset.policy.permissions.clear\n # @publication.asset.policy.permissions << Permission.create(:contributor => author.person, :policy => @publication.asset.policy, :access_type => 4)\n permis = Permission.create(:contributor => author.person, :policy => @publication.asset.policy, :access_type => 4)\n permis.save\n end \n # @publication.asset.policy.save\n #Add contributor\n @publication.asset.policy.permissions << Permission.create(:contributor => @publication.contributor.person, :policy => @publication.asset.policy, :access_type => 4)\n permis = Permission.create(:contributor => @publication.contributor.person, :policy => @publication.asset.policy, :access_type => 4)\n permis.save\n # @publication.asset.save\n flash[:notice] = 'Publication was successfully updated.'\n format.html { redirect_to(@publication) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @publication.errors, :status => :unprocessable_entity }\n end\n end\n end", "def updates_after_create\n parent_policy = Policy.where('parent_id IS NULL').first\n agency_policy = parent_policy.dup\n agency_policy.organization = self\n agency_policy.parent_id = parent_policy.id\n agency_policy.description = \"#{self.short_name} Transit Policy\"\n agency_policy.object_key = nil\n agency_policy.save!\n\n User.where(organization_id: Grantor.first.id).each{|user| user.viewable_organizations = user.user_organization_filter.try(:get_organizations)}\n end", "def change_topics_owner\n self.topics.each do |topic|\n topic.user = User.where(:is_admin => true).first\n topic.save!\n end\n end", "def deep_set_user(new_user, logging=false)\n original_user = self.user\n set_user = lambda { |thing|\n unless thing.user == new_user\n old_login = thing.user ? thing.user.login : \"<nil>\"\n Rails.logger.info \"changing ownership of #{thing.name} from #{old_login} to #{new_user.login}\" if logging\n thing.user = new_user\n thing.save\n end\n # TODO: See page.rb about returning page_elements intead of embeddables\n # in the children method. Probably a better approach.\n if thing.class == Page\n thing.page_elements.each do |pe|\n if pe.user != new_user\n pe.user = new_user\n pe.save\n end\n end\n end\n if thing.respond_to? 'teacher_notes'\n thing.teacher_notes.each do |note|\n unless note.user == new_user\n old_login = note.user ? note.user.login : \"<nil>\"\n Rails.logger.info \"changing ownership of #{note} from #{old_login} to #{new_user.login}\" if logging\n note.user = new_user\n note.save\n end\n end\n end\n if thing.respond_to? 'author_notes'\n thing.author_notes.each do |note|\n unless note.user == new_user\n Rails.logger.info \"changing ownership of #{note} from #{note.user} to #{new_user}\" if logging\n note.user = new_user\n note.save\n end\n end\n end\n\n }\n \n set_user.call(self) \n self.each &set_user\n \n \n if original_user\n unless original_user == new_user\n original_user.removed_investigation\n end\n end\n end", "def set_owner_member\n self.organizations << self.owner\n end", "def reset_owner #:doc:\n self.owner_class.reset_owner\n end", "def owner=(new_owner)\n if @owner != new_owner\n @dacl.reassign!(@owner, new_owner)\n @owner = new_owner\n end\n end", "def may_share_document?(document=nil)\n\t\t\tdocument && ( \n\t\t\t\tself.is_administrator? ||\n\t\t\t\t( document.owner && self == document.owner ) \n\t\t\t)\n\t\tend", "def promote_new_owner\n membership = self.network_memberships.find(\n :first, \n :conditions => [\"organization_id <> ?\", self.owner.id], \n :order => 'created_at')\n self.owner = membership.organization\n self.save\n end", "def copy_to_cooperative\n space = Space.accessible_by(@context).find(unsafe_params[:id])\n object = item_from_uid(unsafe_params[:object_id])\n\n if space.contributor_permission(@context) && space.member_in_cooperative?(@context.user_id)\n if object && space.shared_space\n ActiveRecord::Base.transaction do\n copy_service.copy(object, space.shared_space.uid).each do |new_object|\n SpaceEventService.call(\n space.shared_space.id,\n @context.user_id,\n nil,\n new_object,\n \"copy_to_cooperative\",\n )\n end\n end\n\n flash[:success] = \"#{object.class} successfully copied\"\n end\n else\n flash[:warning] = \"You have no permission to copy object(s) to cooperative.\"\n end\n\n redirect_back(fallback_location: space_path(space))\n end", "def update_refs\n return true if self.user_id or changes.has_key? :user_id\n fields = self.attributes.select {|k,v| changes.has_key? k}\n self.references.update_all(fields) unless self.user_id\n end", "def set_owner_and_roles\n if Member.where(company_id: self.company_id).count == 1\n self.add_role :director\n self.add_role :manager\n self.add_role :tradesman\n self.company.update(owner_id:self.id)\n end\n end", "def update_validation \n #ap 'document # update_validation'\n set_ok\n p = parent\n parent.update_validation if p\n end", "def autosets_owner_on_create\n has_owner # this will do nothing if the user has already set up has_owner :something\n # the hook runs before validation so we can validate_associated\n before_validation_on_create :autoset_owner\n end", "def test_multiple_updates_on_same_object\n # we start with dhh as owner and alexander as user/creator\n @presentation.name = \"new name\"\n @presentation.owner = @alexander\n @presentation.save\n \n assert_equal \"new name\", @presentation.name\n assert_equal @alexander, @presentation.owner\n assert_equal @alexander, @presentation.user\n \n assert [email protected]_owner_of?(@presentation)\n assert @alexander.is_owner_of?(@presentation)\n \n # ---- owner is now alexander, user/creator also alexander\n \n @presentation.name = \"new name 2\"\n @presentation.save\n \n assert_equal \"new name 2\", @presentation.name\n assert_equal @alexander, @presentation.owner\n assert_equal @alexander, @presentation.user\n \n assert [email protected]_owner_of?(@presentation)\n assert @alexander.is_owner_of?(@presentation)\n \n assert [email protected]_creator_of?(@presentation)\n assert @alexander.is_creator_of?(@presentation)\n \n # --- no change. owner: alexander, user/creator: alexander.\n \n @presentation.name = \"new name 3\"\n @presentation.user = @dhh\n @presentation.save\n \n assert_equal \"new name 3\", @presentation.name\n assert_equal @alexander, @presentation.owner\n assert_equal @dhh, @presentation.user\n \n assert [email protected]_owner_of?(@presentation)\n assert @alexander.is_owner_of?(@presentation)\n \n assert [email protected]_creator_of?(@presentation)\n assert @dhh.is_creator_of?(@presentation)\n \n # --- owner is still alexander, but user/creator is now dhh.\n \n @presentation.name = \"new name 4\"\n @presentation.owner = @dhh\n @presentation.save\n \n assert_equal \"new name 4\", @presentation.name\n assert_equal @dhh, @presentation.owner\n assert_equal @dhh, @presentation.user\n \n assert [email protected]_owner_of?(@presentation)\n assert @dhh.is_owner_of?(@presentation)\n \n assert [email protected]_creator_of?(@presentation)\n assert @dhh.is_creator_of?(@presentation)\n \n # --- owner is now also dhh, user/creator is still dhh.\n \n @presentation.name = \"new name 5\"\n @presentation.owner = @alexander\n @presentation.save\n # @presentation.reload\n \n assert_equal \"new name 5\", @presentation.name\n assert_equal @alexander, @presentation.owner\n assert_equal @dhh, @presentation.user\n \n assert [email protected]_owner_of?(@presentation)\n assert @alexander.is_owner_of?(@presentation)\n \n assert [email protected]_creator_of?(@presentation)\n assert @dhh.is_creator_of?(@presentation)\n \n \n end", "def update_owner(owner_id, owner_name)\n\t\tif not ActiveRecord::Base.connection.table_exists? 'model_owners'\n\t\t\treturn\n\t\tend\n\t\towner = ModelOwner.where(:inki_model_name => self.class.table_name, :model_id => self.id).first\n\t\tif owner and owner.model_owner_id == owner_id \n\t\t\treturn\n\t\telsif owner # owner exists, but the owner just changed\n\t\t\towner.model_owner_name = owner_name\n\t\t\towner.model_owner_id = owner_id\n\t\t\towner.save\n\t\telse # owner does not exist, create it\n\t\t\tModelOwner.create(:inki_model_name => self.class.table_name, :model_id => self.id, :model_owner_name => owner_name, :model_owner_id => owner_id)\n\t\tend\n\tend", "def promote\n @group_user = @parent.find(params[:id]) #get the record\n\n if !current_user or (!current_user.is_admin and [email protected]?(current_user))\n redirect_to @group, :notice => \"You cannot update users in that group.\"\n return\n end\n\n respond_to do |format|\n # We'll set is_owner to true. Remember update_attribute bypasses validations!\n if @group_user.update_attribute(:is_owner, true)\n format.html { redirect_to(@group, :notice => 'Group user was successfully promoted!') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @group_user.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n redirect_to :owners #no permit\n end", "def owner=(user)\n de = document_editor_owner\n if de\n return user if de == user\n de.set_owner(false)\n end\n\n de = document_editors.find_by(user_id: user.id)\n if de.nil?\n self.editors << user\n de = document_editors.find_by(user_id: user.id)\n end\n de.set_owner(true)\n end", "def after_update\n super\n touch_associations\n end", "def check_update_permission\n return if owner? || @article.is_public_editable\n redirect_to articles_url\n end", "def merge\n document.update_attributes :access => access\n email_on_complete\n super\n end", "def owner=(value)\n self.person = value if a_person\n end", "def set_owner_attributes(record)\n if @owner.persisted?\n construct_owner_attributes.each { |key, value| record[key] = value }\n end\n end", "def transfer\n if @cookbook_collaborator.nil?\n not_found!\n else\n authorize!(@cookbook_collaborator)\n @cookbook_collaborator.transfer_ownership\n\n redirect_to cookbook_path(@cookbook), notice: 'Owner changed'\n end\n end", "def can_modify\n\t\tself.changed_attributes.each do |attr|\n\n\t\t\tif attr.to_s == \"reports\"\n\t\t\t\tself.reports.each do |r|\n\t\t\t\t\tunless r.changed_attributes.blank?\n\t\t\t\t\t\tif r.owner_ids.include? self.created_by_user_id\n\t\t\t\t\t\telsif r.owner_ids.include? self.created_by_user.organization.id.to_s\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tself.errors.add(:reports,\"You cannot edit #{attr.name.to_s}\")\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\n\t\t\telsif attr.to_s == \"recipients\"\n\t\t\t\trecipients_changed\n\t\t\telsif attr.to_s == \"payments\"\n\t\t\t\told_payment_not_deleted\n\t\t\telse\n\t\t\t\t## only in case of \n\t\t\t\tif self.owner_ids.include? self.created_by_user.id.to_s\n\t\t\t\telsif self.owner_ids.include? self.created_by_user.organization.id.to_s\n\t\t\t\telse\n\t\t\t\t\tself.errors.add(:owner_ids,\"You cannot edit the field: #{attr.to_s}\")\n\t\t\t\tend\n\t\t\tend\n\n\t\tend\n\tend", "def update_from_relation(field_name, related = Ladder::Config.settings[:with_relations])\n objects = send(field_name).to_a\n\n if related || embedded_relations[field_name]\n # Force autosave of related documents to ensure correct serialization\n methods.select { |i| i[/autosave_documents/] }.each { |m| send m }\n\n # update inverse relation properties\n relation = relations[field_name]\n objects.each { |object| object.resource.set_value(relation.inverse, rdf_subject) } if relation.inverse\n objects.map(&:update_resource)\n else\n # remove inverse relation properties\n objects.each { |object| resource.delete [object.rdf_subject] }\n objects.map(&:rdf_subject)\n end\n end", "def prepare_to_change_association(object)\n name = association_name(object)\n send(\"#{name}_will_change!\")\n end", "def set_document\n @document = Document.find(params[:id])\n @project = @document.project\n exit_if_not_member and return false\n end", "def owner=(_)\n end", "def destroy\n retired_org = Organisation.find_or_create_by(name: 'Retrait') do |org|\n org.abbreviation = 'Retrait'\n end\n\n if Author.where(person_id: self.id).count > 0\n self.organisation = retired_org\n self.save\n else\n super\n end\n end", "def apply_save_data_to_curation_concern(attributes)\n if attributes.fetch('on_behalf_of', nil).present?\n current_depositor = curation_concern.depositor\n new_depositor = ::User.find_by_user_key(attributes.fetch('on_behalf_of'))\n curation_concern.apply_depositor_metadata(new_depositor)\n curation_concern.edit_users = update_edit_users_for_curation_concern(current_depositor, new_depositor)\n end\n super\n end", "def assign_approver\n if approver == \"1\"\n document.approver = user\n document.save!\n end\n end", "def publish\n # Make sure it is not already published\n if published_at\n raise Exception.new(\"Cannot publish User Agreement that is already published\");\n end\n published_datetime = Time.now # It's being published now\n transaction do\n versioned_document = VersionedDocument.get_versioned_document\n previous_agreement = versioned_document.published_version\n \n puts \"published_datetime = #{published_datetime.inspect}\"\n \n # Any existing published version will be superceded\n if previous_agreement\n previous_agreement.superceded_at = published_datetime\n previous_agreement.save\n puts \"Saved previous_agreement\"\n end\n self.published_at = published_datetime\n puts \"Saving self = #{self.inspect}\"\n save\n # Record this user agreement as being the published version\n versioned_document.published_version = self\n # This user agreement is no longer the new version (which it presumably was)\n versioned_document.new_version = nil\n puts \"Saving versioned_document = #{versioned_document.inspect}\"\n versioned_document.save\n puts \"All saved.\"\n end\n end", "def cascade_preservation\n self.reload\n if self.can_perform_cascading?\n self.cascading_elements.each do |pib|\n pib.preservation_profile = self.preservation_profile\n pib.save\n end\n end\n end", "def transfer\n authorize!(@collaborator)\n\n @collaborator.transfer_ownership\n\n redirect_to(\n @collaborator.resourceable,\n notice: t('collaborator.owner_changed',\n resource: @collaborator.resourceable.name,\n user: @collaborator.user.username)\n )\n end", "def transfer\n authorize!(@collaborator)\n\n @collaborator.transfer_ownership\n\n redirect_to(\n @collaborator.resourceable,\n notice: t(\"collaborator.owner_changed\",\n resource: @collaborator.resourceable.name,\n user: @collaborator.user.username)\n )\n end", "def set_owner #:doc:\n self.owner_class.owner= get_current_owner\n end", "def check_ownership\n redirect_to books_path, alert: I18n.t(\"books.not_owner\") if current_user.id != @book.user_id\n # equivaut a:\n # if current_user.id != @book.user_id\n # flash[:alert]= \"Vous n'etes pas le proprietaire de ce livre\"\n # redirect_to books_path\n # end\n end", "def update_users_and_parent\n # Update editors' and authors' contributions.\n authors.each do |user|\n SiteData.update_contribution(:del, authors_join_table, user.id)\n end\n editors.each do |user|\n SiteData.update_contribution(:del, editors_join_table, user.id)\n end\n\n return unless parent.description_id == id\n\n # Make sure parent doesn't point to a nonexisting object.\n parent.description_id = nil\n parent.save_without_our_callbacks\n end", "def link(contact)\n contact.accounts << self\n contact.owner = self if contact.owner.nil?\n contact.save\n end", "def heal_associated_docs\n bad_keys = []\n @document.doc_refs do |key, value|\n if DocumentRepository.find key == nil\n bad_keys << key\n end\n end\n bad_keys.each do |key|\n @document.doc_refs.delete(key)\n end\n DocumentRepository.update @document\n end", "def freeze\n @touched_associations.freeze\n\n super\n end", "def set_publication_owner(name, owner)\n typed_exec(\"ALTER PUBLICATION #{connection.quote_ident(name)} OWNER TO #{connection.quote_ident(owner)}\")\n end", "def ownerDocument\n nil\n end", "def set_author\n author_reference.reference = \"Patient/#{user.icn}\"\n end", "def validate_impossible_changes\n errors.add(:user_id, :cant_be_changed) if @document && @document.user_id != self.user_id\n end", "def set_owner\n @owner = Owner.find_by_owner_user_id(current_owner_user.id)\n end", "def require_ownership\n model = content_type_from_controller(self.class)\n redirect_if_not_owned model.find(params[:id]), send(redirect_path)\n rescue\n redirect_to '/500'\n end", "def change_owner\n @seminar = Seminar.find(params[:id])\n @teacher = Teacher.find(params[:new_owner])\n \n @seminar.update(:owner => @teacher)\n SeminarTeacher.find_or_create_by(:user => @teacher, :seminar => @seminar).update(:can_edit => true)\n \n flash[:success] = \"Class Owner Updated\"\n redirect_to @seminar\n end", "def test_save_case_3\n set_up_new_records\n @author.blog_posts << @post1\n @author.save\n # Set the blog.owner to owner2 & check that relation is set correctly\n author = TestWriter.get(@author[:id])\n author.blog_posts.each { |rec| p rec}\n author.blog_posts.delete( @post1 )\n assert_equal false, (author.blog_posts.include? @post1)\n author.save\n author = TestWriter.get(author[:id])\n post1 = TestBlogPost.get(@post1[:id])\n assert_equal false, (author.blog_posts.include? @post1)\n assert_equal nil, post1.test_writer\n end", "def author_not_changed\n return unless author_changed? && persisted?\n errors.add(:author, 'Change of author not allowed!')\n end", "def corresponding_author=(user)\n contribution = self.corresponding_author_contribution || Contribution.new(:role_id => 1)\n contribution.user_id = user.id\n contribution.save(false)\n self.corresponding_author \n end", "def transfer_ownership_impl!(player)\n old_owner = Player.minimal(owner_id)\n self.owner = player\n save!\n\n as_json = self.as_json(:mode => :minimal)\n new_owner = player.as_json(:mode => :minimal)\n\n member_ids.each do |member_id|\n Notification.create_for_alliance_owner_changed(\n member_id, as_json, old_owner, new_owner\n )\n end\n\n ControlManager.instance.alliance_owner_changed(self, player)\n\n true\n end", "def setOwner _obj, _args\n \"_obj setOwner _args;\" \n end", "def disassociate\n _parent = parent_document\n _type = self.type.sub('associated:', '')\n _parent.doc_refs.delete(_type)\n self.parent_id = 0\n self.parent_ref = nil\n self.root_document_id = 0\n self.root_ref = nil\n DocumentRepository.update(_parent)\n DocumentRepository.update(self)\n end", "def assign_current_document!; end", "def update!(*)\n assert_source_saved 'The source must be saved before mass-updating the collection'\n super\n end", "def update!(*)\n assert_source_saved 'The source must be saved before mass-updating the collection'\n super\n end", "def owner=(v) self['Owner'] = v end", "def set_owner(id)\n self.owner_id = id\n end", "def assign_to(new_owner)\n if new_owner != \"congress\"\n @assigned_to = new_owner\n end\n end", "def update?\n owner?\n end", "def cascade!(document)\n return unless persistable?\n\n case _association.dependent\n when :delete_all\n document.delete\n when :destroy\n document.destroy\n else\n document.save\n end\n end", "def set_owner\n @goal.owner = current_user\n end", "def update(*)\n assert_source_saved 'The source must be saved before mass-updating the collection'\n super\n end", "def update(*)\n assert_source_saved 'The source must be saved before mass-updating the collection'\n super\n end", "def preserve\n # No one should be preserving an object that has errors\n return false if self.errors.present?\n\n Hyacinth::Config.lock_adapter.with_lock(\"#{self.uid}-preserve\") do |_lock_object|\n ensure_doi!\n break if self.errors.present?\n\n preservation_result, errors = Hyacinth::Config.preservation_persistence.preserve(self)\n\n unless preservation_result\n self.errors.add(:preservation, \"Failed to preserve #{self.uid} due to the following errors: #{errors.join(', ')}\")\n break\n end\n\n update_preservation_timestamps(DateTime.current)\n self.save\n end\n\n self.errors.blank?\n end", "def set_document\n @document = Document.cached_find(params[:legal_document_id])\n end", "def correct_user_for_docs\n @document = current_user.documents.find_by(params[:friendly])\n redirect_to documents_path, notice: \"Not authorised to edit this document\" if @document.nil?\n end", "def before_update_save(record)\n record.comments.each do |comment|\n comment.user = current_user\n end\n end", "def set_legal_document\n @legal_document = LegalDocument.find(params[:id])\n end", "def init_user_orcid\n return unless author_orcid\n return unless (user = resource&.user)\n return if user&.orcid\n\n user.orcid = author_orcid\n user.save\n end", "def validate_owner\n unless @article.owner == current_user\n redirect_to root_path, notice: 'You do not have edit access to the article!'\n end\n end", "def remove_from_parent\n @change_set = ChangeSet.for(resource)\n parent_resource = find_resource(parent_resource_params[:id])\n authorize! :update, parent_resource\n\n parent_change_set = ChangeSet.for(parent_resource)\n current_member_ids = parent_resource.member_ids\n parent_change_set.member_ids = current_member_ids - [resource.id]\n\n obj = nil\n change_set_persister.buffer_into_index do |persist|\n obj = persist.save(change_set: parent_change_set)\n end\n after_update_success(obj, @change_set)\n rescue Valkyrie::Persistence::ObjectNotFoundError => e\n after_update_error e\n end", "def update\n @doc = Doc.find(params[:id])\n \n respond_to do |format|\n if @doc.update_attributes(params[:doc])\n save_object_relationship\n format.html { redirect_to(@doc, :notice => 'Doc was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @doc.errors, :status => :unprocessable_entity }\n end\n end\n end", "def authorize_owner_and_planner\n\n can :manage, AttachedDocument do |doc|\n curr_organization == doc.plan.organization\n end\n end", "def duplicate!(recipient=nil, options={})\n Document.transaction do\n # Clone the document.\n newattrs = attributes.dup.merge({\n :access => PENDING,\n :created_at => Time.now,\n :updated_at => Time.now\n })\n newattrs.delete('id')\n newattrs[:account_id] = recipient.id if recipient\n newattrs[:organization_id] = recipient.organization.id if recipient and not newattrs[:organization_id]\n copy = Document.create!(newattrs.merge({:hit_count => 0, :detected_remote_url => nil}))\n newattrs = {:document_id => copy.id}\n\n # Clone the docdata.\n if docdata and options['include_docdata']\n Docdata.create! document_id: copy_id, data: docdata.data.dup\n end\n\n # Clone the associations.\n associations = [entities, entity_dates, pages]\n associations.push sections if options['include_sections']\n # Copy all notes that are visible by either the document owner or the recipient\n account_context = options['as_owner'] ? self.account : recipient\n associations.push annotations.accessible(account_context) if options['include_annotations']\n # Copy the new document into all of the same projects as the old document\n associations.push project_memberships if options['include_project']\n associations.each do |association|\n association.each do |model|\n model_attrs = model.attributes.dup.merge newattrs\n model_attrs.delete('id')\n model.class.create! model_attrs\n end\n end\n\n # Clone the assets.\n DC::Store::AssetStore.new.copy_assets(self, copy, self.access)\n\n # Reindex, set access.\n copy.index\n copy.set_access access\n\n copy\n end\n end", "def __owner__= owner\n @__owner = owner\n end", "def save\n self.approved = true\n super\n end", "def update\n\t\t\n\t\t# check if the current use is this person\n\t\t\t\t\n\t\t\n\tend", "def modifiable\n @ole.Modifiable\n end" ]
[ "0.6337711", "0.6337711", "0.6123703", "0.60103095", "0.58914506", "0.58688754", "0.5866902", "0.58403426", "0.5801534", "0.57156944", "0.56937575", "0.5689962", "0.56714606", "0.56451887", "0.5631376", "0.5605006", "0.5595832", "0.5570872", "0.5565383", "0.55379623", "0.55364037", "0.5526543", "0.5479651", "0.5473213", "0.5471943", "0.5466692", "0.5442124", "0.5422716", "0.54159296", "0.5408862", "0.54058635", "0.54031163", "0.5400336", "0.5396108", "0.5390122", "0.5389687", "0.53798133", "0.53764004", "0.5359968", "0.53474605", "0.53414196", "0.5340125", "0.5322533", "0.53158176", "0.5313682", "0.52875006", "0.52852416", "0.52768236", "0.5276712", "0.5266621", "0.5261602", "0.52557915", "0.52501076", "0.5247987", "0.5247744", "0.5226633", "0.5225877", "0.52221197", "0.52117056", "0.52049094", "0.52004725", "0.51989263", "0.51877797", "0.5184392", "0.5183862", "0.51651514", "0.51640546", "0.5160957", "0.51479524", "0.51445615", "0.51408046", "0.5140144", "0.5124012", "0.51231813", "0.51208365", "0.5119573", "0.5119573", "0.51166487", "0.5107539", "0.51030475", "0.51022726", "0.5097841", "0.5097661", "0.509411", "0.509411", "0.50936556", "0.5090436", "0.5085108", "0.5082976", "0.50793004", "0.5066639", "0.50649315", "0.50594324", "0.5059057", "0.50570476", "0.5051848", "0.5037742", "0.50349504", "0.503273", "0.5031892" ]
0.51721907
65
Documents don't themselves have an aspect ratio, as individual pages can have differing aspect ratios. We should considering calculating and storing an ideal aspect ratio that will be wrong for the least number of pages. Until then, we just return the first page's aspect ratio.
def safe_aspect_ratio pages.first.safe_aspect_ratio end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def aspect_ratio\n return 'none' unless fixed_ratio?\n dims = fullsize_settings[:dimensions]\n dims[0].to_f / dims[1]\n end", "def aspect_ratio\n if self.width && self.height\n return self.width/self.height.to_f\n else\n return 1.324 # Derived from the default values, above\n end\n end", "def aspectratio\n if not @ratio then\n # Only calc the ratio the first time. Memoization!\n @ratio = Rational(@width, @height) # Ruby reduces fractions for us! How handy.\n end\n\n if @ratio == Rational(16, 10) # 16x10 is a special case, since we don't want it reduced down to 8x5\n return \"16x10\"\n else\n return \"#{@ratio.numerator}x#{@ratio.denominator}\" # Return the aspect ratio in WxH format\n end\n end", "def aspect_ratio\n if self.native_width && self.native_height\n return self.native_width/self.native_height.to_f\n else\n return 1.324 # Derived from the default values, above\n end\n end", "def aspect_ratio; (@x/@y).abs; end", "def aspect_ratio(avail_width=nil, avail_height=nil)\n case self.aspect_ratio_method\n when ASPECT_RATIO_DEFAULT_METHOD\n return ASPECT_RATIO_DEFAULT_WIDTH / ASPECT_RATIO_DEFAULT_HEIGHT.to_f\n when ASPECT_RATIO_MANUAL_METHOD\n return self.native_width/self.native_height.to_f\n when ASPECT_RATIO_MAX_METHOD\n width = avail_width || ASPECT_RATIO_DEFAULT_WIDTH\n height = avail_height || ASPECT_RATIO_DEFAULT_HEIGHT\n return width / height.to_f\n end\n end", "def aspect_ratio\n height.to_f / width.to_f\n end", "def aspect_ratio\n (@x/@y).abs\n end", "def aspect_ratio(style_name=nil)\n style_name ||= reflection.default_style\n if style_name.equal?(:original)\n original_width = from_examination(:@original_width)\n original_height = from_examination(:@original_height)\n original_width.to_f / original_height\n else\n w, h = *dimensions(style_name)\n w.to_f / h\n end\n end", "def aspect_ratio(size)\n size[:width].to_f / size[:height]\n end", "def pixel_aspect_ratio\n pixel_width / pixel_height\n end", "def aspect\n width.to_f / height.to_f if !(width.blank? && height.blank?)\n end", "def all_ratings_calculated_ratio\n\t\tif number_of_ratings > 0\n\t\t\tratio = mean_calculated_ratio\n\t\telse\n\t\t\tratio = chapter.mean_calculated_ratio\n\t\tend\n\t\treturn ratio\n\tend", "def aspect\n width.to_f / height\n end", "def aspect\n width / height\n end", "def infer_width_or_height_from_ratio\n if @min_size[:height].zero?\n @min_size[:height] = (@min_size[:width] / @ratio).to_i if @ratio\n else\n @min_size[:width] = (@min_size[:height] * @ratio).to_i if @ratio\n end\n end", "def get_doc_scale w, h\n page_w, page_h = @current_page.size\n\n scale_x = w / page_w \n scale_y = h / page_h\n\n if scale_x > scale_y\n scale_y\n else\n scale_x\n end\n end", "def set_aspect_ratio\n @columns = 25\n @rows = 25\n base_image_columns = @base_image[\"%w\"].to_i\n base_image_rows = @base_image[\"%h\"].to_i\n\n if base_image_columns > base_image_rows\n @columns *= (base_image_columns / base_image_rows.to_f)\n @columns = @columns.round\n else\n @rows *= (base_image_rows / base_image_columns.to_f)\n @rows = @rows.round\n end\n end", "def set_ratio\n @ratio = $program.width.to_f / $program.height\n end", "def aspect_ratio_padding_bottom\n return false unless @aspect_ratio_container\n\n thumb = asset&.file(\"thumb_#{thumb_size}\")\n\n return nil unless thumb && thumb.width && thumb.height\n\n height_over_width = thumb.height.to_f / thumb.width.to_f\n\n \"#{(height_over_width * 100.0).truncate(1)}%\"\n end", "def calculate_aspect_ratio(info, options)\n if options[:preserve_aspect_ratio]\n composited_size = SmartImage::RatioCalculator.new(\n :source_width => info.width,\n :source_height => info.height,\n :dest_width => Integer(options[:width]), \n :dest_height => Integer(options[:height])\n ).size\n\n return composited_size.width, composited_size.height\n else\n return options[:width], options[:height]\n end\n end", "def ratio_from_size_or_params\n if @min_size.has_value?(0) && @options[:fixed_ratio]\n @options[:fixed_ratio].to_f\n elsif !@min_size[:width].zero? && !@min_size[:height].zero?\n @min_size[:width].to_f / @min_size[:height].to_f\n else\n false\n end\n end", "def aspect_ratio_method\n inherit_aspect_ratio_method && library_interactive ? library_interactive.aspect_ratio_method : custom_aspect_ratio_method\n end", "def has_wider_aspect_ratio?(size1, size2)\n aspect_ratio(size1) > aspect_ratio(size2)\n end", "def resize_ratio_for asset\n base_geo = asset.geometry(:base_to_crop)\n original_geo = asset.geometry\n # Returning the biggest size as the ratio will be more exact.\n field = base_geo.width > base_geo.height ? :width : :height\n #Ratio to original / base\n original_geo.send(field).to_f / base_geo.send(field).to_f\n end", "def ratio\n # This call is interesting because it involves converting the\n # cog to a floar instead of both the chainring and the cog.\n # This avoids any uncessary conversions to get the job done!\n chainring / cog.to_f\n end", "def scale_to_fit_container( aspect, container_width, container_height )\n width, height = aspect.split( Optparser::ASPECT_CHOICE_CUSTOM_PREFIX ).last.split( 'x' ).collect{|x| x.to_f}\n factor = container_height / container_width > height / width ? container_width / width : container_height / height\n @logger.debug( \"Scaling factor to fit custom aspect ratio #{ width } x #{ height } in #{ @options.size } container: #{ factor }\" )\n width_scaled = width * factor\n height_scaled = height * factor\n return width_scaled.floor, height_scaled.floor\n end", "def apply_preserve_aspect_ratio(change_orientation=false)\n return unless preserve_aspect_ratio?\n\n side = @transcoder_options[:preserve_aspect_ratio]\n size = @raw_options.send(side)\n side = invert_side(side) if change_orientation \n\n if @transcoder_options[:enlarge] == false\n original_size = @movie.send(side)\n size = original_size if original_size < size\n end\n\n case side\n when :width\n new_height = size / @movie.calculated_aspect_ratio\n new_height = evenize(new_height)\n @raw_options[:resolution] = \"#{size}x#{new_height}\"\n when :height\n new_width = size * @movie.calculated_aspect_ratio\n new_width = evenize(new_width)\n @raw_options[:resolution] = \"#{new_width}x#{size}\"\n end\n\n invert_resolution if change_orientation \n end", "def read_ratio(cursor)\n num = @bindata_reader_32.read(@data[cursor..cursor+3])\n denom = @bindata_reader_32.read(@data[cursor+4..cursor+7])\n invalid_data(\"@#{cursor} - Invalid rational #{num}/#{denom}\") if ((denom == 0) and (num != 0))\n return (num == 0) ? 0 : num.to_f / denom.to_f\n end", "def fit_to_scale(rough_ratio)\n nearest_scale_ratio = 0 # FIXME: why not 1.0?\n\n if rough_ratio > 0\n rough_tonic = 2 ** (Math.log(rough_ratio) / Math.log(2)).floor\n\n ratios_and_deltas = scale_ratios.map do |scale_ratio|\n\n # bring scale_ratio into rough_ratio's 8ve\n scale_ratio *= 2 while scale_ratio < rough_tonic\n scale_ratio /= 2 while scale_ratio > (rough_tonic * 2)\n\n delta = (rough_ratio - scale_ratio).abs\n {:scale_ratio => scale_ratio, :delta => delta}\n end\n\n # FIXME!!!!!!!!!!!! HUGE FUCKING BUG; MAKES NO SENSE!\n # says delta is nil, when it's obviously not!!\n # \n ratios_and_deltas.each do |rd|\n if rd[:delta].nil?\n error \"NULL DELTA! #{rd.inspect}\" \n return 0\n end\n end\n\n nearest_scale_ratio = ratios_and_deltas.sort{|x, y| x[:delta] <=> y[:delta]}.first[:scale_ratio]\n end\n\n return nearest_scale_ratio\n end", "def page_size\n if width > 0 && height > 0\n [width, height]\n else\n size\n end\n end", "def maintain_aspect_ratio?\n source_node[:maintainAspectRatio]==\"true\"\n end", "def maintain_aspect_ratio?\n source_node[:maintainAspectRatio]==\"true\"\n end", "def find_page_image_format(pdf_file)\n output = `pdfimages -list #{pdf_file}`\n # The result from pdfimages should look like this:\n #\n # page num type width height color comp bpc enc interp object ID x-ppi y-ppi size ratio\n # --------------------------------------------------------------------------------------------\n # 1 0 image 2480 3507 gray 1 8 jpeg no 6 0 300 300 325K 3.8%\n # 2 1 image 2480 3507 gray 1 8 jpeg no 11 0 300 300 141K 1.7%\n # 3 2 image 2480 3507 gray 1 8 jpeg no 16 0 300 300 706K 8.3%\n #\n # So the image encoding should be in column [9] (where the page number is in column [0]).\n #\n # Run through the pages and ensure that they are all the same type.\n image_type = nil\n output.each_line() {\n |line|\n next if line =~ /^----/ || line =~ /^page/\n data = line.split(/\\s+/)\n image_type ||= data[9]\n image_type = \"inconsistent\" if image_type != data[9]\n }\n return image_type\nend", "def ratio(value_a1, value_a2, value_b2)\n (value_a1 * value_b2 / value_a2).to_i rescue 0\n end", "def page_size\n page_size = @reader.crop_box(1)\n if @reader.page_rotation(1) % 180 == 0\n [page_size.width, page_size.height]\n else\n [page_size.height, page_size.width]\n end\n end", "def votes_ratio(voting_field = \"votes\")\n eval(voting_field).try(:[], 'ratio') || 0\n end", "def scale_aspect_to_minimum_size(aSize)\n if aSize.width/aSize.height > self.size.width/self.size.height\n s = CGSize.new(aSize.width, (aSize.width/size.width * size.height).to_i)\n else\n s = CGSize.new((aSize.height/size.height * size.width).to_i, aSize.height)\n end\n\n scale_to_size(s)\n end", "def size_ratio(geom)\n geom_size = SizableLocation.new(geom).size\n if geom_size.positive?\n size.to_f / geom_size\n else\n 0.0\n end\n end", "def aspect(aspect)\n (aspects.select { |content_type_aspect| content_type_aspect.aspect == aspect }).first\n end", "def scaled_photos\n # How big is the area where we're showing phtoos\n row_width = grid_width\n\n scaled_photos = []\n\n # resolve the photos promise (if a promise)\n aspect_ratios = []\n photos = model.reject do |photo|\n if photo.height\n aspect_ratios << ((photo.width / photo.height) * 100).round\n false # keep\n else\n true # reject\n end\n end\n\n scaled_widths = summed_widths(photos)\n # Sum the width for the photos\n number_of_rows = (scaled_widths / row_width).round\n number_of_rows = [(number_of_rows / 2).round, 1].max\n\n partitions = `partition(aspect_ratios, number_of_rows)`\n\n index = 0\n\n partitions.map do |row|\n summed_ratios = row.sum\n row.each do |ratio|\n photo = photos[index]\n\n # the percent of the rows width this photo should take up\n percent_width = ratio / summed_ratios\n width = percent_width * row_width\n height = width / (ratio / 100.0)\n\n index += 1\n scaled_photos << ScaledPhoto.new(width.floor, height.floor, photo)\n end\n end\n\n scaled_photos\n end", "def correct_ratio\n all = stats.where(\"answer_id >= 0\").size.to_f\n all > 0 ? correct_count.to_f/all : 0\n end", "def title_photo\n return title_photos.where(\"photo_width / photo_height < 3\").first\n end", "def scale_aspect_to_maximum_size(aSize)\n if aSize.width/aSize.height > self.size.width/self.size.height\n s = CGSize.new((aSize.height/size.height * size.width).to_i, aSize.height)\n else\n s = CGSize.new(aSize.width, (aSize.width/size.width * size.height).to_i)\n end\n\n scale_to_size(s)\n end", "def serving_ratio(serving_amt = self.serving_size)\n ratio = 1.0\n #have to transform to float to maintain decimal precision\n if self.serving_size && serving_amt && self.serving_size > 0 && serving_amt > 0\n ratio = serving_amt/self.serving_size.to_f\n end\n ratio\n end", "def width\n self.resolution.first unless self.resolution.nil? || many?\n end", "def calculate_aspect_ratio\n multi_polygons = get_multi_polygons(@feature_json)\n rad_per_deg = 0.017453293\n\n multi_polygons.each do |multi_polygon|\n if multi_polygon.size > 1\n runner.registerWarning('Ignoring holes in polygon')\n end\n multi_polygon.each do |polygon|\n n = polygon.size\n length = 0\n north = 0\n east = 0\n south = 0\n west = 0\n aspect_ratio = 0\n\n for i in (0..n - 2) do i\n vertex_1 = nil\n vertex_2 = nil\n if i == n - 2\n vertex_1 = polygon[n - 2]\n vertex_2 = polygon[0]\n else\n vertex_1 = polygon[i]\n vertex_2 = polygon[i + 1]\n end\n x_1 = vertex_1[0]\n y_1 = vertex_1[1]\n x_2 = vertex_2[0]\n y_2 = vertex_2[1]\n\n dist = (x_2 - x_1)**2 + (y_2 - y_1)**2\n\n length = Math.sqrt(dist)\n\n # delta latitude\n dlat = x_2 - x_1\n # delta longitude\n dlon = y_2 - y_1\n\n # convert radian to degree\n sin_angle = Math.asin(dlon / length) * (1 / rad_per_deg)\n sin_angle = sin_angle.round(4)\n\n cos_angle = Math.acos(dlat / length) * (1 / rad_per_deg)\n cos_angle = cos_angle.round(4)\n\n if cos_angle >= 45 && cos_angle <= 135 && sin_angle >= 45 && sin_angle <= 90\n north += length\n elsif cos_angle >= 0 && cos_angle < 45 && sin_angle > -45 && sin_angle < 45\n east += length\n elsif cos_angle >= 45 && cos_angle <= 135 && sin_angle >= -90 && sin_angle <= -45\n south += length\n elsif cos_angle > 135 && cos_angle <= 180 && sin_angle > -45 && sin_angle < 45\n west += length\n end\n\n if east + west != 0\n aspect_ratio = (north + south) / (east + west)\n else\n aspect_ratio = 1\n end\n\n end\n\n aspect_ratio = aspect_ratio.round(4)\n return aspect_ratio\n end\n end\n end", "def size_ratio(geom)\n if geom && geom.geometry_type == RGeo::Feature::Polygon && geom.area > 0\n return size.to_f / geom.area\n else\n return 0.0\n end\n end", "def index\n index_params = params.permit(:page).reverse_merge({\n :page => 1 # pagination index starts at 1, not 0\n })\n\n @images = Image.order(created_at: :desc)\n .page(index_params[:page])\n .per(10)\n @images.each do |image|\n maybe_update_aspect_ratio image\n end\n end", "def get_portions(name, slide_index, shape_index, paragraph_index, password = nil, folder = nil, storage = nil, sub_shape = nil)\n data, _status_code, _headers = get_portions_with_http_info(name, slide_index, shape_index, paragraph_index, password, folder, storage, sub_shape)\n data\n end", "def fit_to_page?\n # is there some better way to express this?\n (!fit_to_width.nil? || !fit_to_height.nil?)\n end", "def fixed_ratio?\n fullsize_settings[:dimensions].all?(&:present?)\n end", "def extract_first_page_images\n #######\n # Docsplit.extract_images(document.file.file, :size => %w{200x 700x 1000x}, :format => :jpg, :pages => %w{1}, output: output_path)\n Docsplit.extract_images(file.path, :size => %w{200x 700x 1000x}, :format => :jpg, :pages => %w{1}, output: \"public/#{self.docsplit_dir}\" )\n \n # def store_path(for_file=filename)\n # # File.join([store_dir, full_filename(for_file)].compact)\n # \"#{self.model.class.to_s.underscore}\" + \"/\" + \"#{mounted_as}\" + \"/\" + \"#{self.model.user.uuid.to_s}\" + \"/\" + \"#{self.model.slug}\" + \"/\" + \"#{(version_name || :original).to_s}\" + \"_\" + \"#{self.file.basename}\" + \".jpg\"\n # end\n # if Rails.env.production?\n # document.store!(new_file=\"#{output_path}/200x/#{document.model.file_name.chomp(document.model.document.file.extension)[0..-2]}_1.jpg}\")\n # document.store!(new_file=\"#{output_path}/700x/#{document.model.file_name.chomp(document.model.document.file.extension)[0..-2]}_1.jpg}\")\n # document.store!(new_file=\"#{output_path}/1000x/#{document.model.file_name.chomp(document.model.document.file.extension)[0..-2]}_1.jpg}\")\n # end\n # Docsplit.extract_images(document.file.file, :size => %w{200x 700x 1000x}, :format => :jpg, :pages => %w{1}, output: \"/tmp/uploads/docsplit/#{model.class.to_s.underscore}/#{model.slug}\")\n\n\n # ::Docsplit.extract_images(self.pdf, :size => %w{200x 700x 1000x}, :format => :jpg, :pages => %w{1}, output: output_path)\n # if Rails.env.production?\n # # Rename file folders. \n # FileUtils.mv local_output_path + \"160x\", s3_output_path + \"160x\"\n # FileUtils.mv local_output_path + \"700x\", s3_output_path + \"700x\"\n # FileUtils.mv local_output_path + \"1000x\", s3_output_path + \"1000x\"\n # end\n \n true\n # self\n end", "def ratio_res_to_listings\n (count_listings != 0) ? calculate_ratio : 0\n end", "def aspect_ratio=(aspect_ratio)\n validator = EnumAttributeValidator.new('String', [\"16:9\", \"9:16\", \"1:1\", \"4:5\", \"4:3\"])\n unless validator.valid?(aspect_ratio)\n fail ArgumentError, \"invalid value for \\\"aspect_ratio\\\", must be one of #{validator.allowable_values}.\"\n end\n @aspect_ratio = aspect_ratio\n end", "def y(value)\n return value if letter?\n\n width_ratio = value / PAGE_SIZES[:letter].height\n width_ratio * @page_size.height\n end", "def best_viewport()\n \n percentage = 0\n \n read() do |img|\n\n found = faces()\n \n index = if found.any? then\n \n # find the top y\n box = found.max_by {|x, y, width, height| y}\n y, height = box.values_at 1, 3\n y - (height / 2)\n \n else\n \n y_maxcontrast(img)\n \n end\n \n percentage = (100 / (img.rows / index.to_f)).round\n \n end \n \n return percentage\n \n end", "def get_adjusted_height (width, height)\n return width == 0 ? 0 : (height.to_f * FACEBOOK_MAX_WIDTH.to_f / width.to_f).to_i\n end", "def get_aspect_ratios(query_obj=nil)\n uri = URI.parse(@uri + \"/AspectRatios\")\n results = get(uri,query_obj)\n end", "def calc_resource_ratios(revision={})\n ratio = {}\n # make ratio table\n @model.tuple_space_lock.synchronize do\n @model.tuple_spaces.each do |tuple_space|\n rev = revision.has_key?(tuple_space) ? revision[tuple_space] : 0\n current = timeout(1){tuple_space.current_task_worker_size} + rev\n resource = tuple_space.task_worker_resource\n # minimum resource is 1\n resource = 1 unless resource > 0\n ratio[tuple_space] = current / resource.to_f\n end\n end\n return ratio\n end", "def show\n maybe_update_aspect_ratio @image\n end", "def get_video_display_resolution(document,datastream_name, dsid)\n\n #default values\n height=\"288\"\n width=\"512\"\n\n metadata = document.datastreams[datastream_name]\n\n if metadata.kind_of?(ActiveFedora::NokogiriDatastream) \n xpath_to_file=\"//xmlns:resource[@dsID='#{dsid}']/xmlns:file/xmlns:videoData/\"\n video_height=metadata.find_by_xpath(xpath_to_file+\"@height\").to_s\n video_width=metadata.find_by_xpath(xpath_to_file+\"@width\").to_s\n\n if !video_height.empty? and !video_width.empty? \n #scale display to fit within limits\n aspect_ratio=video_height.to_f/video_width.to_f\n if (aspect_ratio - 0.5625).abs < 0.0001\n #leave as default\n elsif (aspect_ratio - 0.75).abs < 0.0001\n #4:3\n width=\"384\"\n else\n #scale to max width\n height=(512*aspect_ratio).ceil.to_s\n end\n end\n end\n return {:height=>height, :width=>width}\n end", "def aperture\n f = image_exif[\"FNumber\"]\n return nil if f.blank?\n (Rational(*(f.split('/').map( &:to_i )))).to_f\n end", "def extract_dimensions\n return unless image?\n tempfile = attachment.queued_for_write[:original]\n unless tempfile.nil?\n geometry = Paperclip::Geometry.from_file(tempfile)\n self.width, self.height = [geometry.width.to_i, geometry.height.to_i]\n self.aspect_ratio = width.to_f/height\n end\n end", "def extract_dimensions\n return unless image?\n tempfile = attachment.queued_for_write[:original]\n unless tempfile.nil?\n geometry = Paperclip::Geometry.from_file(tempfile)\n self.width, self.height = [geometry.width.to_i, geometry.height.to_i]\n self.aspect_ratio = width.to_f/height\n end\n end", "def wp_constrain_dimensions(current_width, current_height, max_width = 0, max_height = 0)\n return [current_width, current_height] if max_width == 0 && max_height == 0\n\n width_ratio = height_ratio = 1.0\n did_width = did_height = false\n\n if max_width > 0 && current_width > 0 && current_width > max_width\n width_ratio = max_width / current_width\n did_width = true\n end\n\n if max_height > 0 && current_height > 0 && current_height > max_height\n height_ratio = max_height / current_height\n did_height = true\n end\n\n # Calculate the larger/smaller ratios\n smaller_ratio = [width_ratio, height_ratio].min\n larger_ratio = [width_ratio, height_ratio].max\n\n if (current_width * larger_ratio).round > max_width || (current_height * larger_ratio).round > max_height\n # The larger ratio is too big. It would result in an overflow.\n ratio = smaller_ratio\n else\n # The larger ratio fits, and is likely to be a more \"snug\" fit.\n ratio = larger_ratio\n end\n\n # Very small dimensions may result in 0, 1 should be the minimum.\n w = [1, (current_width * ratio).round].max\n h = [1, (current_height * ratio).round].max\n\n # Sometimes, due to rounding, we'll end up with a result like this: 465x700 in a 177x177 box is 117x176... a pixel short\n # We also have issues with recursive calls resulting in an ever-changing result. Constraining to the result of a constraint should yield the original result.\n # Thus we look for dimensions that are one pixel shy of the max value and bump them up\n\n # Note: did_width means it is possible $smaller_ratio == $width_ratio.\n if did_width && w == max_width - 1\n w = max_width # Round it up\n end\n\n # Note: did_height means it is possible $smaller_ratio == $height_ratio.\n if did_height && h == max_height - 1\n h = max_height # Round it up\n end\n\n # Filters dimensions to constrain down-sampled images to.\n apply_filters('wp_constrain_dimensions', [w, h], current_width, current_height, max_width, max_height)\n end", "def percent_doc\n return @percent_doc if @percent_doc\n\n @fully_documented = (@num_items - @doc_items) == 0\n\n @percent_doc = @doc_items.to_f / @num_items * 100 if @num_items.nonzero?\n @percent_doc ||= 0\n\n @percent_doc\n end", "def pm_ratio_value\n return 1 if end_date.nil?\n num_days = (end_date - start_date).to_i + 1\n num_days == 3 ? 0 : num_days\n end", "def final_decision_weight_ratio\n r = read_attribute(:final_decision_weight_ratio)\n (r.nil? || r.zero?) ? 0.5 : r\n end", "def resource_version_by_ratio\n ratio_values = ::Settings.resource_version_by_settings&.ratio_default_values\n ratio = ratio_values.send(@entity_type.name) unless ratio_values.nil?\n ratio = 100 if ratio.nil? || !(0..100).cover?(ratio.to_i)\n\n if ratio == 0 || @ref_id >= (@entity_type.stats[:total].value * (ratio / 100.0))\n resource_version_timestamp\n else\n resource_version_default_value\n end\n end", "def parse_page( pl_ratio = 36.0/18.0 )\n \n # initializations\n lines = 0\n page = []\n eof = false\n \n # looping through buffer until page is full\n while (lines_per_page - lines) > 0 && !eof\n buffer_line = self.buffer.shift \n if buffer_line.nil? # EOF reached, stop while loop \n eof = true\n else # add content to page until full \n word_count = buffer_line.split.size\n number_lines = (word_count/words_per_line).round\n number_lines = number_lines - 1 + pl_ratio # account for paragraph padding\n \n if (lines + number_lines) <= lines_per_page\n # add the whole buffer_line to the page\n lines += number_lines\n page << buffer_line\n else\n # add only part of the buffer_line to the page\n # unshift the rest back into the buffer \n remainder = lines_per_page - lines - 1 # addition line is for rounding and pl_ration adjustment\n remainder = (remainder * words_per_line).to_i\n from_beginning = word_count - remainder \n if from_beginning > 0\n keeper = buffer_line.match(/^([\\w|'|\"]*\\W?){#{from_beginning}}/).to_s # first X number of words\n page << keeper\n remainder = buffer_line.sub( keeper, '' )\n self.buffer.unshift( remainder ) # add remainder to the buffer \n end \n lines = lines_per_page # satisfy conditions for end of page\n end \n end \n end \n page \n end", "def get_size\n img_sizes = flickr.photos.getSizes(photo_id: @info['id']).to_a\n img = img_sizes.last\n\n # Loop down through images until appropriate sized one is found\n (img_sizes.length-2).downto(0) do |i|\n if img_sizes[i]['height'].to_i < 1000 || img_sizes[i]['width'].to_i < 1600\n img = img_sizes[i+1]\n break\n end\n end\n\n @source = img['source']\n @page = img['url']\n @height = img['height']\n @width = img['width']\n end", "def reformat_split_ratio(split_ratio)\n numerator, denominator = *(split_ratio.split(\":\").map(&:strip))\n numerator.to_f / denominator.to_f\n end", "def square_images\n @template[:message][:attachment][:payload][:image_aspect_ratio] = 'square'\n self\n end", "def format_ratio(n)\n \"%2.2f\\%\" % (n * 100).to_s\n end", "def yes_no_ratio\n yes = self.options[:yes].to_i + REDIS_VOTES.get('YES:' + self.id).to_i\n no = self.options[:no].to_i + REDIS_VOTES.get('NO:' + self.id).to_i\n\n total = yes + no\n total = total == 0 ? 1 : total\n\n ratio = {\n yes: ((yes / total) * 100).round(0),\n no: ((no / total) * 100).round(0)\n }\n end", "def get_perimeter_multiplier(area, aspect_ratio, perimeter_original)\n perimeter_new = 2 * (Math.sqrt(area * aspect_ratio) + Math.sqrt(area / aspect_ratio))\n perimeter_ratio = perimeter_original / perimeter_new\n return perimeter_ratio\n end", "def last_page\n (max_matches.to_f / per_page).ceil\n end", "def make_ratio(array1, array2)\n if array1.empty? || array2.empty?\n result = 0\n else\n result = array1.compact.inject(0){|sum, item| sum + item}.to_f/array2.compact.inject(0){|sum, item| sum + item}.to_f\n end\n result\n end", "def thumb_width\n width * thumb_height / height\n end", "def reduce_to(size, max_size, ratio = 1, allow_enlarge = false, min_max = false)\n ret = size.dup\n\n if min_max\n if max_size[:width] < max_size[:height] != size[:width] < size[:height]\n max_size[:width], max_size[:height] = max_size[:height], max_size[:width]\n end\n end\n\n if allow_enlarge\n if ret[:width] < max_size[:width]\n scale = max_size[:width].to_f / ret[:width].to_f\n ret[:width] = ret[:width] * scale\n ret[:height] = ret[:height] * scale\n end\n\n if max_size[:height] && (ret[:height] < ratio * max_size[:height])\n scale = max_size[:height].to_f / ret[:height].to_f\n ret[:width] = ret[:width] * scale\n ret[:height] = ret[:height] * scale\n end\n end\n\n if ret[:width] > ratio * max_size[:width]\n scale = max_size[:width].to_f / ret[:width].to_f\n ret[:width] = ret[:width] * scale\n ret[:height] = ret[:height] * scale\n end\n\n if max_size[:height] && (ret[:height] > ratio * max_size[:height])\n scale = max_size[:height].to_f / ret[:height].to_f\n ret[:width] = ret[:width] * scale\n ret[:height] = ret[:height] * scale\n end\n\n ret[:width] = ret[:width].round\n ret[:height] = ret[:height].round\n ret\n end", "def reduce_to(size, max_size, ratio = 1, allow_enlarge = false, min_max = false)\n ret = size.dup\n\n if min_max\n if max_size[:width] < max_size[:height] != size[:width] < size[:height]\n max_size[:width], max_size[:height] = max_size[:height], max_size[:width]\n end\n end\n\n if allow_enlarge\n if ret[:width] < max_size[:width]\n scale = max_size[:width].to_f / ret[:width].to_f\n ret[:width] = ret[:width] * scale\n ret[:height] = ret[:height] * scale\n end\n\n if max_size[:height] && (ret[:height] < ratio * max_size[:height])\n scale = max_size[:height].to_f / ret[:height].to_f\n ret[:width] = ret[:width] * scale\n ret[:height] = ret[:height] * scale\n end\n end\n\n if ret[:width] > ratio * max_size[:width]\n scale = max_size[:width].to_f / ret[:width].to_f\n ret[:width] = ret[:width] * scale\n ret[:height] = ret[:height] * scale\n end\n\n if max_size[:height] && (ret[:height] > ratio * max_size[:height])\n scale = max_size[:height].to_f / ret[:height].to_f\n ret[:width] = ret[:width] * scale\n ret[:height] = ret[:height] * scale\n end\n\n ret[:width] = ret[:width].round\n ret[:height] = ret[:height].round\n ret\n end", "def per_page\n page_size = ENV['BETTERY_PER_PAGE']\n\n page_size.to_i if page_size\n end", "def horizontal_images\n hrz = 'horizontal'\n @template[:message][:attachment][:payload][:image_aspect_ratio] = hrz\n self\n end", "def get_portions_with_http_info(name, slide_index, shape_index, paragraph_index, password = nil, folder = nil, storage = nil, sub_shape = nil)\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: SlidesApi.get_portions ...'\n end\n\n # verify the required parameter 'name' is set\n if @api_client.config.client_side_validation && name.nil?\n fail ArgumentError, \"Missing the required parameter 'name' when calling SlidesApi.get_portions\"\n end\n # verify the required parameter 'slide_index' is set\n if @api_client.config.client_side_validation && slide_index.nil?\n fail ArgumentError, \"Missing the required parameter 'slide_index' when calling SlidesApi.get_portions\"\n end\n # verify the required parameter 'shape_index' is set\n if @api_client.config.client_side_validation && shape_index.nil?\n fail ArgumentError, \"Missing the required parameter 'shape_index' when calling SlidesApi.get_portions\"\n end\n # verify the required parameter 'paragraph_index' is set\n if @api_client.config.client_side_validation && paragraph_index.nil?\n fail ArgumentError, \"Missing the required parameter 'paragraph_index' when calling SlidesApi.get_portions\"\n end\n # resource path\n local_var_path = '/slides/{name}/slides/{slideIndex}/shapes/{shapeIndex}/paragraphs/{paragraphIndex}/portions'\n local_var_path = @api_client.replace_path_parameter(local_var_path, 'name', name)\n local_var_path = @api_client.replace_path_parameter(local_var_path, 'slideIndex', slide_index)\n local_var_path = @api_client.replace_path_parameter(local_var_path, 'shapeIndex', shape_index)\n local_var_path = @api_client.replace_path_parameter(local_var_path, 'paragraphIndex', paragraph_index)\n\n # query parameters\n query_params = {}\n query_params[:'folder'] = @api_client.prepare_for_query(folder) unless folder.nil?\n query_params[:'storage'] = @api_client.prepare_for_query(storage) unless storage.nil?\n query_params[:'subShape'] = @api_client.prepare_for_query(sub_shape) unless sub_shape.nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n header_params[:'password'] = password unless password.nil?\n\n # http body (model)\n post_body = nil\n\n # form parameters\n post_files = []\n\n auth_names = ['JWT']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :body => post_body,\n :files => post_files,\n :auth_names => auth_names,\n :return_type => 'Portions')\n return data, status_code, headers\n end", "def quality_percentage\n require 'hpricot'\n doc = Hpricot(File.read(\"#{Continuous4r::WORK_DIR}/flog/index.html\"))\n doc.search('//h3') do |h3|\n if h3.inner_text.match(/^Project average score/)\n score = h3.inner_text.split(/Project average score : /)[1].to_f\n if score > 100.0\n percent = 0\n elsif score < 11.0\n percent = 100\n else\n percent = ((100.0 - score) * 100.0) / 89.0\n end\n return percent\n end\n end\n end", "def scale_aspect_to_fill_size(aSize)\n if aSize.width/aSize.height > size.width/size.height\n croppedImg = image_by_cropping_to_center_size(CGSize.new(size.width, (size.width/aSize.width * aSize.height).to_i))\n else\n croppedImg = image_by_cropping_to_center_size(CGSize.new((size.height/aSize.height * aSize.width).to_i, size.height))\n end\n\n croppedImg.scale_to_size(aSize)\n end", "def get_PE_ratio\n @PE_ratio = Stock.where(:stock_ticker => self.stock_ticker).first.PE_ratio / 100\n end", "def mediaBicipital\n\t\tmedia = 0.0\n\t\[email protected] do |i|\n\t\t media += @bicipital[i]\n\t\tend\n\t\tmedia /= @bicipital.length.to_f\n\t\tmedia.round(2)\n\tend", "def wp_image_matches_ratio(source_width, source_height, target_width, target_height)\n # To test for varying crops, we constrain the dimensions of the larger image\n # to the dimensions of the smaller image and see if they match.\n if source_width > target_width\n constrained_size = wp_constrain_dimensions(source_width, source_height, target_width)\n expected_size = [target_width, target_height]\n else\n constrained_size = wp_constrain_dimensions(target_width, target_height, source_width)\n expected_size = [source_width, source_height]\n end\n\n # If the image dimensions are within 1px of the expected size, we consider it a match.\n (constrained_size[0] - expected_size[0]).abs <= 1 && (constrained_size[1] - expected_size[1]).abs <= 1\n end", "def get_pdf(x)\n if x >= @lower && x <= @upper\n @pdf_denominator\n else \n 0.0\n end\t \n end", "def calculate_ratio\n count_reservations / count_listings\n end", "def get_number_of_pages(numrec)\n return ((numrec + 50) / 50 * 50) / 50\nend", "def height\n self.resolution.last unless self.resolution.nil? || many?\n end", "def calculate_new_size(width, height)\n ratio = width.to_f / height.to_f\n target = Gnawrnip.max_frame_size\n\n return [width, height] if target > [width, height].max\n\n if ratio < 1\n new_width = target * ratio\n new_height = target\n else\n new_width = target\n new_height = target / ratio\n end\n\n [new_width, new_height]\n end", "def golden_ratio(precision)\n x = fib(99)/fib(98).to_f\n x.round(precision)\n end", "def rate_per_day_overall_of_videos\n ( video_count / account_age_in_days.to_f ).round(1)\n end", "def pdf\n base = Estimate.get_base\n estimate = base.fetch_by_id(id)\n return base.pdf(estimate)\n end", "def images_conversion_progress\n return (\"%.2f\" % (number_of_completed_images * 1.0 / self.number_of_images_entry)).to_f if self.is_pdf_convertible? \n return 1\n end", "def fit_to_pages(width = 0, height = 0)\n @fit_page = 1\n @fit_width = width\n @fit_height = height\n end" ]
[ "0.73481125", "0.72288257", "0.7040896", "0.69896793", "0.668754", "0.66756976", "0.662657", "0.65336084", "0.6385839", "0.6345753", "0.62481636", "0.62335086", "0.6145229", "0.6095233", "0.6034445", "0.5984581", "0.5973498", "0.5916359", "0.5895308", "0.5820019", "0.5762467", "0.5759321", "0.5658779", "0.5553714", "0.54981834", "0.5494896", "0.5471334", "0.54234856", "0.5408662", "0.53797", "0.5313355", "0.5273996", "0.5273996", "0.5270924", "0.5270716", "0.52548814", "0.5210829", "0.5207761", "0.52061427", "0.5196701", "0.5191071", "0.5119401", "0.51085985", "0.51084995", "0.5097317", "0.5083576", "0.50647366", "0.50540775", "0.50491035", "0.50083405", "0.50034136", "0.4984624", "0.49807507", "0.4972385", "0.49714306", "0.49535507", "0.49306133", "0.4927005", "0.4888802", "0.48883367", "0.48798135", "0.48618826", "0.48554763", "0.48401067", "0.48401067", "0.48153222", "0.48070952", "0.47855687", "0.4782902", "0.4780845", "0.47690302", "0.47625026", "0.47569078", "0.4754149", "0.4750048", "0.47415572", "0.473192", "0.47310144", "0.471734", "0.47120148", "0.46987998", "0.46987998", "0.46927884", "0.46804565", "0.46802023", "0.4679709", "0.46679384", "0.46672577", "0.466571", "0.46616408", "0.4651615", "0.46515355", "0.46458358", "0.4641641", "0.46134132", "0.46102336", "0.46068186", "0.459332", "0.4576961", "0.45744812" ]
0.8242837
0
Externally used image path, not to be confused with `page_image_path()`
def page_image_template "#{slug}-p{page}-{size}.gif" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def image_path\n \"#{PATH}/#{image_filename}\"\n end", "def page_image_path(page_number, size)\n File.join(pages_path, \"#{slug}-p#{page_number}-#{size}.gif\")\n end", "def giant_path\n \"g_#{image_path}\"\n end", "def image_path(image)\r\n image.rel_path\r\n end", "def image(page_image = '')\n default_image = asset_url \"/images/main/main.jpg\"\n if page_image.empty?\n default_image\n else\n asset_url \"#{page_image}\"\n end\n end", "def image_for(page)\n if page.main_image.exists?\n image_tag page.main_image.url\n else\n image_tag page.root.main_image.url\n end\n end", "def image_path(source)\n compute_public_path(source, 'images', 'png')\n end", "def image_url(page, image_src)\r\n image_uri = URI.parse(image_src)\r\n if image_uri.absolute?\r\n image_uri\r\n elsif image_uri.relative?\r\n root = URI::Generic.build :scheme => page.url.scheme, :host => page.url.host \r\n URI.join root.to_s, image_uri.to_s\r\n else\r\n raise BasiliskImageError, \"Could not parse image src.\"\r\n end\r\n rescue\r\n raise BasiliskImageError, \"Could not parse image src.\"\r\n end", "def image_path filename\n File.expand_path \"../resources/#{filename}\", __dir__\nend", "def site_image_path(src)\n rewrite_asset_path(src.expand_url(\"#{account_site_assets}/images/\"))\n end", "def image_path(icon)\n File.expand_path(File.dirname(__FILE__) + \"/../../images/#{icon}.png\")\n end", "def images_path\n @imags_path ||= File.expand_path 'images/', assets_path\n end", "def image_path(source)\n compute_public_path(source, 'images')\n end", "def image_location\n src || ''\n end", "def image_url\n # It's just stored in public/data/slug.jpg or whatever the relevant file\n # extension is\n image = Dir[\"public/data/#{slug}.*\"].first.split(\"/\").last\n # That's accessed publicly over the website as /data/slug.jpg or whatever\n \"/data/#{image}\"\n end", "def img_path() \"#{$dir}/sprites.gif\"; end", "def image\n @path\n end", "def IMG_PATH\n SongBugs::IMG_PATH\n end", "def image_jpg_path\n \"%s/app/assets/images/game_images/%s.jpg\" %[Rails.root, self.name.dehumanize]\n end", "def image_path(path, options={})\n asset_path(path, :type => :image)\n end", "def image_path\r\n if self.image.nil? then\r\n return item.image_path\r\n else\r\n return \"/images/items/\" + self.image\r\n end\r\n end", "def images_path\n \tmain_app.send(Auth::OmniAuth::Path.create_or_index_path(Auth.configuration.image_class))\n end", "def image(name)\n File.expand_path(\"tex/#{name}\", File.dirname(__FILE__))\nend", "def image_png_path\n \"%s/app/assets/images/game_images/%s.png\" %[Rails.root, self.name.dehumanize]\n end", "def site_image_url(src)\n rewrite_asset_path(src.expand_url(\"#{account_site_assets_url}/images/\"))\n end", "def image_path\n \"/image_store/#{id}.#{extension}\"\n end", "def image_path(src)\n src.gsub!(/\\s/, '')\n src =~ %r{^\\s*(/|http)} ? src : uri_root_path('images', src)\n end", "def image_png\r\ndirectory = File.expand_path File.dirname(__FILE__)\r\nspecific_filename = directory + \"/\" + \"Media/shop.png\"\r\nend", "def img_path(img)\n\t # Easy peasy for normal files\n\t o = File.expand_path(img, $img_path)\n\t return o if __FILE__ !~ /\\.jar!\\//\n\t # Juggling around packages:\n\t idir = File.expand_path(\"img\", EnveCollection.home)\n\t Dir.mkdir(idir) unless Dir.exist? idir\n\t h = File.expand_path(img, idir)\n\t FileUtils.copy(o, h) unless File.exist? h\n\t h\n end", "def logo_path(ngo)\n if ngo.image.attached?\n Rails.application.routes.url_helpers.rails_blob_path(ngo.image, only_path: true)\n else\n ActionController::Base.helpers.image_path('image_not_found.png')\n end\n end", "def default_image_path\n \"default_interest_images/#{name.gsub(/\\s/,'').gsub(/\\W/,'_').downcase}\"\n end", "def image_path(src)\n asset_path(:images, src)\n end", "def path\n \"#{parent_image.basepath}-#{width}-#{height}-#{x1}-#{x2}-#{y1}-#{y2}#{parent_image.extname}\"\n end", "def image_path\n \"#{File.dirname(__FILE__).gsub('spec/strategies', 'public')}#{@upload.avatar.url(:big)}\"\n end", "def theme_public_images_path(source = '')\n File.join(theme_path, 'public', 'images', source)\n end", "def asset_image_path(image_name)\n File.expand_path(\"../../assets/images/#{image_name}\", __FILE__)\n end", "def image\n if File.exist?(\"public/images/profile_images/#{self.username}.jpg\")\n img_path = \"/images/profile_images/#{self.username}.jpg\"\n else\n img_path = \"/images/default.jpg\"\n end\n return img_path\n end", "def docGetImagePath(url, dirPath)\n imageFileName = Pathname(url).basename.to_s\n return dirPath + \"images/\" + imageFileName\nend", "def image_url\n is_processed ?\n FileSystem.url(image_path) : \n orig_image_url\n end", "def image_url\n is_processed ?\n FileSystem.url(image_path) : \n orig_image_url\n end", "def get_image_url(page_doc)\n\timage_url = page_doc.css('body center:nth-child(1) a img')\n\n\tif image_url.nil? or image_url.length == 0\n\t\treturn nil\n\tend\n\n\treturn @base_url + image_url[0][\"src\"]\nend", "def image_url\n return unless image.attached?\n\n url_for(image)\n end", "def default_url\n ActionController::Base.helpers.asset_path(\"integral/defaults/post_image.jpg\")\n end", "def page_asset_image_tag(image_file_name)\n %{<img src=\"#{page_assets_link_base}#{image_file_name}\" />}\n end", "def image\n MAIN_CDN + \"headshots/current/168x168/#{@id}.jpg\"\n end", "def image_url\n return \"\" if @path.nil? || @path.empty?\n \"#{images_scheme}://#{images_host}/\" << if m = /^(pv4|pfk|p7s|p6o|p3w|p7s|p)\\/(.*)$/.match(@path)\n \"p/\" << m[2]\n else\n @path\n end\n end", "def image_read_path\n @image_read_path\n end", "def image_url(path)\n @@image_url_cache ||= {}\n @@image_url_cache[path] ||= client.get_temporary_link(normalize_path(path)).link\n end", "def casein_config_logo\n \t'/images/logo_ss.jpg'\n end", "def image_path\n uri_path = URI(profile_image_url).path\n extension = File.extname(uri_path)\n \"#{@base_path}/#{screen_name}#{extension}\"\n end", "def image_path(source, options = T.unsafe(nil)); end", "def image_path\n thumbnail_url\n end", "def imagen_path\n\t\t\"../perfumes/#{id}.#{imagen}\"\n\t\t# \"../perfumes/#{imagen}\"\n\tend", "def square_path\n \"s_#{image_path}\"\n end", "def image_path(source)\n path_to_asset(source)\n end", "def image_jpg\r\n directory = File.expand_path File.dirname(__FILE__)\r\n specific_filename = directory + \"/\" + \"Media/1.jpg\"\r\nend", "def absolute_images_path\n File.join(absolute_import_dir, \"images\")\n end", "def partial\n \"/otus/page/public_images\"\n end", "def processing_image_path(image_name)\n \"/assets/\" + Rails.application.assets.find_asset(image_name).digest_path\n end", "def picture_path\n File.expand_path(File.join(PICTURE_DIR, code2filename(code)))\n end", "def relative_images_path\n File.join(relative_import_dir, \"images\")\n end", "def image_pdf\r\n directory = File.expand_path File.dirname(__FILE__)\r\n specific_filename = directory + \"/\" + \"Media/file1.pdf\"\r\nend", "def unit_path\n \"u_\" + image_path\n end", "def avatar_path\n if ENV[\"FALLBACK_ICONS_DEBUG\"]\n return ActionController::Base.helpers.asset_path(self.class.image_files(:robot).sample)\n end\n\n if avatar.attached?\n # ▼Activestorrage service_url missing default_url_options[:host] · Issue #32866 · rails/rails\n # https://github.com/rails/rails/issues/32866\n Rails.application.routes.url_helpers.rails_blob_path(avatar, only_path: true)\n else\n list = self.class.image_files(race_info.key)\n file = list[(id || self.class.count.next).modulo(list.size)]\n ActionController::Base.helpers.asset_path(file) # asset_url にしてもURLにならないのはなぜ?\n end\n end", "def path\n \"#{RAILS_ROOT}/photos/#{self.visit.user_id}/#{self.visit_id}\"\n \n# \"#{RAILS_ROOT}/public/images/#{self.class.to_s.underscore.pluralize}\"\n end", "def file_path\n base_image ? base_image.base_filename : nil\n end", "def production_opening\n @images_path = \"/../../assets/images\"\n end", "def graph_image_path\n File.join('/', graph_relative_path)\n end", "def get_template_image_url(file_type)\n path = get_server_url(true) + \"/assets/\"\n case file_type\n when 'word' # for word type\n full_path = path + 'file_docx.svg'\n when 'cell' # .xlsx for cell type\n full_path = path + 'file_xlsx.svg'\n when 'slide' # .pptx for slide type\n full_path = path + 'file_pptx.svg'\n else\n full_path = path + 'file_docx.svg' # the default value is .docx\n end\n\n full_path\n end", "def generate_image_location(id, page_number)\n generate_build_location \"#{@config.image_directory_name}/#{id}-#{page_number}\"\n end", "def path_to_image(source)\n path = super(source)\n if @generate_urls_with_host\n protocol = request.protocol()\n path = protocol + request.host_with_port() + path\n end\n return path\n end", "def image\n 'gh.png'\n end", "def image\n if !self.extend_url.blank?\n self.qrcode\n elsif self.page_content.try(:content) =~ /<img\\s+.*src\\s*=\\s*\"(.*\\.(?:jpg|png|gif))\"/i\n $1\n else\n \"/assets/avatar.jpg\"\n end\n end", "def relative_url_fragment_to_jpg\n return \"/#{IMAGEDB_FOLDER}/#{self.id}.jpg\"\n end", "def image_save_path\n @image_save_path\n end", "def get_path\n if self.presentation.user.role==\"guest\"\n \"#{Rails.root}/public/guestdata/\"+self.presentation.user_id.to_s+\"/\"+self.presentation.id.to_s+\"/images/:filename\"\n else\n \"#{Rails.root}/public/userdata/\"+self.presentation.user.name.downcase.gsub(\" \", \"_\")+\"/\"+self.presentation.name.downcase.gsub(\" \", \"_\")+\"/images/:filename\"\n #\"#{Rails.root}/public/userdata/\"+self.presentation.user.name.downcase.gsub(\" \", \"_\")+\"/\"+self.presentation.name.downcase.gsub(\" \", \"_\")+\"/images/:attachment/:id_:style.:extension\"\n end\n end", "def image_path\n \"#{@parent_path}output/#{@input_name}/#{@input_name}.png\"\n end", "def public_path(image_path, css_path)\n image_path, css_path = Pathname.new(image_path), Pathname.new(css_path)\n (image_path.absolute? ? Pathname.new(\"public#{image_path}\") : css_path.dirname + image_path).cleanpath\n end", "def image_path\n photo = album_cover ? album_cover.photo : photos.first\n if photo\n return \"/album/#{id}/photo/#{photo.id}\"\n else\n return nil\n end\n end", "def image_name\n path = \"sets/#{set}/#{dimension}_#{polarity}_#{verbal}\"\n # Rails.application.assets.find_asset(path).nil? ? 'placeholder' : path\n path\n end", "def ubiquo_image_path(name)\n \"/images/ubiquo/#{name}\"\n end", "def logo_path\n root_path\n end", "def logo_path\n root_path\n end", "def logo_path\n root_path\n end", "def get_image_url\n image_url = Storage.get_file_url(ENV['AWS_S3_DIR_PAGES'], self.issue_id, self.filename )\n return image_url\n end", "def access_dir\n \"/assets/#{model.imageable_type.downcase.pluralize}/\"\n end", "def marker_img_path_for_grade grade\n image_path(\"#{marker_img_for_grade(grade)}\")\n end", "def image\n if File.exists?(self.image_jpg_path)\n \"/assets/game_images/%s.jpg\" %[self.name.dehumanize]\n elsif File.exists?(self.image_png_path)\n \"/assets/game_images/%s.png\" %[self.name.dehumanize]\n else\n nil\n end\n end", "def beer_logo_path\n self.logo_path.url(:medium)\n end", "def setup_program_image\n image_path(image_name: params[:setup_program_image])\n end", "def imgurl\n picref.imgurl if picref\n end", "def default_url\n ActionController::Base.helpers.asset_path('mails/bigimage.jpg', type: :image).to_s\n end", "def find_inspire_image\n path = Dir[image_for('', 'mobile_inspire') + '*']\n path.first.split('/').last\n end", "def default_url\n ActionController::Base.helpers.image_path('user.png')\n end", "def image_path(size)\n (self.images.image) ? self.images.image.file.url(size) : ( (self.venue.images.image) ? self.venue.images.image.file.url(size) : \"/images/noimage_#{(size == :large) ? 300 : ((size == :medium) ? 210 : 125)}.gif\" )\n end", "def giant_url\n is_processed ?\n FileSystem.url(giant_path) : \n orig_image_url\n end", "def read_path\n @read_path ||= self.class.image_read_path.dup\n end", "def load_image(path)\n end", "def page_url\n return @page_url.dup unless @page_url.nil?\n generate_file_name()\n #duplicate so outside sources do not edit this property\n @page_url.dup\n end", "def relative_path\n return self.avatar.match(/http[^|]*/)[0].to_s\n end" ]
[ "0.7650894", "0.7416475", "0.7297698", "0.72710353", "0.7265467", "0.7253573", "0.7217244", "0.71998996", "0.7185095", "0.7183806", "0.7165193", "0.7113745", "0.7054708", "0.70529044", "0.70217425", "0.699451", "0.6991893", "0.6980747", "0.69629896", "0.6854156", "0.68498015", "0.6817418", "0.6816656", "0.68113106", "0.67998433", "0.6796577", "0.67881775", "0.6786083", "0.6774307", "0.6769638", "0.67595553", "0.675823", "0.6749532", "0.6744921", "0.6736681", "0.6736084", "0.6731255", "0.67194414", "0.67087555", "0.67087555", "0.6690029", "0.6686186", "0.6672608", "0.6661532", "0.6658308", "0.6645863", "0.6645521", "0.6622367", "0.6619538", "0.6618379", "0.661824", "0.66176623", "0.6596732", "0.6590991", "0.6582822", "0.6578316", "0.6570624", "0.6561787", "0.6550597", "0.6541972", "0.65374887", "0.6533669", "0.6530918", "0.650459", "0.65027994", "0.6491275", "0.64887136", "0.64817995", "0.6469347", "0.6465503", "0.6460721", "0.64546484", "0.64423126", "0.64312994", "0.6418347", "0.6416747", "0.6415495", "0.6413525", "0.6375141", "0.6369177", "0.6349252", "0.6345442", "0.6345442", "0.6345442", "0.63408303", "0.6339126", "0.6328457", "0.6324829", "0.63199496", "0.6319647", "0.6317329", "0.63134444", "0.63109446", "0.63092786", "0.6296345", "0.6286426", "0.6285921", "0.6282788", "0.62733036", "0.62719715" ]
0.68138754
23
Internally used image path, not to be confused with page_image_template()
def page_image_path(page_number, size) File.join(pages_path, "#{slug}-p#{page_number}-#{size}.gif") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def page_image_template\n \"#{slug}-p{page}-{size}.gif\"\n end", "def image_path\n \"#{PATH}/#{image_filename}\"\n end", "def giant_path\n \"g_#{image_path}\"\n end", "def image_for(page)\n if page.main_image.exists?\n image_tag page.main_image.url\n else\n image_tag page.root.main_image.url\n end\n end", "def image_path filename\n File.expand_path \"../resources/#{filename}\", __dir__\nend", "def image(name)\n File.expand_path(\"tex/#{name}\", File.dirname(__FILE__))\nend", "def img_path() \"#{$dir}/sprites.gif\"; end", "def path\n \"#{parent_image.basepath}-#{width}-#{height}-#{x1}-#{x2}-#{y1}-#{y2}#{parent_image.extname}\"\n end", "def image_path\n \"/image_store/#{id}.#{extension}\"\n end", "def image_jpg_path\n \"%s/app/assets/images/game_images/%s.jpg\" %[Rails.root, self.name.dehumanize]\n end", "def image\n @path\n end", "def get_template_image_url(file_type)\n path = get_server_url(true) + \"/assets/\"\n case file_type\n when 'word' # for word type\n full_path = path + 'file_docx.svg'\n when 'cell' # .xlsx for cell type\n full_path = path + 'file_xlsx.svg'\n when 'slide' # .pptx for slide type\n full_path = path + 'file_pptx.svg'\n else\n full_path = path + 'file_docx.svg' # the default value is .docx\n end\n\n full_path\n end", "def image_png\r\ndirectory = File.expand_path File.dirname(__FILE__)\r\nspecific_filename = directory + \"/\" + \"Media/shop.png\"\r\nend", "def image_path\r\n if self.image.nil? then\r\n return item.image_path\r\n else\r\n return \"/images/items/\" + self.image\r\n end\r\n end", "def image_path(image)\r\n image.rel_path\r\n end", "def image_path(source)\n compute_public_path(source, 'images', 'png')\n end", "def image(page_image = '')\n default_image = asset_url \"/images/main/main.jpg\"\n if page_image.empty?\n default_image\n else\n asset_url \"#{page_image}\"\n end\n end", "def image_png_path\n \"%s/app/assets/images/game_images/%s.png\" %[Rails.root, self.name.dehumanize]\n end", "def thumbnail\n \"template_\" + self.template.stylesheets + \".png\"\n end", "def image_url(page, image_src)\r\n image_uri = URI.parse(image_src)\r\n if image_uri.absolute?\r\n image_uri\r\n elsif image_uri.relative?\r\n root = URI::Generic.build :scheme => page.url.scheme, :host => page.url.host \r\n URI.join root.to_s, image_uri.to_s\r\n else\r\n raise BasiliskImageError, \"Could not parse image src.\"\r\n end\r\n rescue\r\n raise BasiliskImageError, \"Could not parse image src.\"\r\n end", "def square_path\n \"s_#{image_path}\"\n end", "def default_image_path\n \"default_interest_images/#{name.gsub(/\\s/,'').gsub(/\\W/,'_').downcase}\"\n end", "def thumbnail_path\n \"t_#{image_path}\"\n end", "def images_path\n @imags_path ||= File.expand_path 'images/', assets_path\n end", "def image_path(path, options={})\n asset_path(path, :type => :image)\n end", "def image_path(source, options = T.unsafe(nil)); end", "def image_path\n thumbnail_url\n end", "def image_path(source)\n compute_public_path(source, 'images')\n end", "def image_url\n # It's just stored in public/data/slug.jpg or whatever the relevant file\n # extension is\n image = Dir[\"public/data/#{slug}.*\"].first.split(\"/\").last\n # That's accessed publicly over the website as /data/slug.jpg or whatever\n \"/data/#{image}\"\n end", "def image_location\n src || ''\n end", "def unit_path\n \"u_\" + image_path\n end", "def site_image_path(src)\n rewrite_asset_path(src.expand_url(\"#{account_site_assets}/images/\"))\n end", "def images_path\n \tmain_app.send(Auth::OmniAuth::Path.create_or_index_path(Auth.configuration.image_class))\n end", "def thumbnail_path\n \"t_\" + image_path\n end", "def page_asset_image_tag(image_file_name)\n %{<img src=\"#{page_assets_link_base}#{image_file_name}\" />}\n end", "def image_jpg\r\n directory = File.expand_path File.dirname(__FILE__)\r\n specific_filename = directory + \"/\" + \"Media/1.jpg\"\r\nend", "def image_path(icon)\n File.expand_path(File.dirname(__FILE__) + \"/../../images/#{icon}.png\")\n end", "def image_name\n @presenter.is_homepage? ? 'thumb' : 'thumb_inner'\n end", "def image_pdf\r\n directory = File.expand_path File.dirname(__FILE__)\r\n specific_filename = directory + \"/\" + \"Media/file1.pdf\"\r\nend", "def partial\n \"/otus/page/public_images\"\n end", "def image\n if File.exist?(\"public/images/profile_images/#{self.username}.jpg\")\n img_path = \"/images/profile_images/#{self.username}.jpg\"\n else\n img_path = \"/images/default.jpg\"\n end\n return img_path\n end", "def image_path(src)\n src.gsub!(/\\s/, '')\n src =~ %r{^\\s*(/|http)} ? src : uri_root_path('images', src)\n end", "def image_name\n path = \"sets/#{set}/#{dimension}_#{polarity}_#{verbal}\"\n # Rails.application.assets.find_asset(path).nil? ? 'placeholder' : path\n path\n end", "def image_path(src)\n asset_path(:images, src)\n end", "def image\n if File.exists?(self.image_jpg_path)\n \"/assets/game_images/%s.jpg\" %[self.name.dehumanize]\n elsif File.exists?(self.image_png_path)\n \"/assets/game_images/%s.png\" %[self.name.dehumanize]\n else\n nil\n end\n end", "def casein_config_logo\n \t'/images/logo_ss.jpg'\n end", "def image_path\n \"#{@parent_path}output/#{@input_name}/#{@input_name}.png\"\n end", "def image\n 'gh.png'\n end", "def generate_image_location(id, page_number)\n generate_build_location \"#{@config.image_directory_name}/#{id}-#{page_number}\"\n end", "def default_image\n end", "def docGetImagePath(url, dirPath)\n imageFileName = Pathname(url).basename.to_s\n return dirPath + \"images/\" + imageFileName\nend", "def IMG_PATH\n SongBugs::IMG_PATH\n end", "def path_to_image(source)\n path = super(source)\n if @generate_urls_with_host\n protocol = request.protocol()\n path = protocol + request.host_with_port() + path\n end\n return path\n end", "def path\n \"#{RAILS_ROOT}/photos/#{self.visit.user_id}/#{self.visit_id}\"\n \n# \"#{RAILS_ROOT}/public/images/#{self.class.to_s.underscore.pluralize}\"\n end", "def img_path(img)\n\t # Easy peasy for normal files\n\t o = File.expand_path(img, $img_path)\n\t return o if __FILE__ !~ /\\.jar!\\//\n\t # Juggling around packages:\n\t idir = File.expand_path(\"img\", EnveCollection.home)\n\t Dir.mkdir(idir) unless Dir.exist? idir\n\t h = File.expand_path(img, idir)\n\t FileUtils.copy(o, h) unless File.exist? h\n\t h\n end", "def theme_public_images_path(source = '')\n File.join(theme_path, 'public', 'images', source)\n end", "def image_path\n \"#{File.dirname(__FILE__).gsub('spec/strategies', 'public')}#{@upload.avatar.url(:big)}\"\n end", "def image\n MAIN_CDN + \"headshots/current/168x168/#{@id}.jpg\"\n end", "def image_for(file_name, dest = '')\n prefix = data_path.dup\n file_name = file_name.split('/').last unless file_name.empty?\n file_name = file_name.gsub(/.svg/i, '.png')\n case dest\n when 'mobile_inspire'\n \"#{prefix}/inspire/mobile/#{file_name}\"\n when 'desktop_inspire'\n \"#{prefix}/inspire/desktop/#{file_name}\"\n when 'thumbnails'\n \"#{prefix}/thumbnails/#{file_name}\"\n when 'show_image_desk'\n \"#{prefix}/show_images/desktop/#{file_name}\"\n when 'show_image_mob'\n \"#{prefix}/show_images/mobile/#{file_name}\"\n when 'show'\n \"#{prefix}/show_images/show/#{file_name}\"\n end\n end", "def setup_plate_layout_image\n image_path(image_name: params[:setup_plate_layout_image])\n end", "def default_url\n ActionController::Base.helpers.asset_path(\"integral/defaults/post_image.jpg\")\n end", "def image path, attrs = {}\n Tagz.tag :img, { :src => path }.merge(attrs)\n end", "def file_path\n base_image ? base_image.base_filename : nil\n end", "def get_path\n if self.presentation.user.role==\"guest\"\n \"#{Rails.root}/public/guestdata/\"+self.presentation.user_id.to_s+\"/\"+self.presentation.id.to_s+\"/images/:filename\"\n else\n \"#{Rails.root}/public/userdata/\"+self.presentation.user.name.downcase.gsub(\" \", \"_\")+\"/\"+self.presentation.name.downcase.gsub(\" \", \"_\")+\"/images/:filename\"\n #\"#{Rails.root}/public/userdata/\"+self.presentation.user.name.downcase.gsub(\" \", \"_\")+\"/\"+self.presentation.name.downcase.gsub(\" \", \"_\")+\"/images/:attachment/:id_:style.:extension\"\n end\n end", "def image_url\n return \"\" if @path.nil? || @path.empty?\n \"#{images_scheme}://#{images_host}/\" << if m = /^(pv4|pfk|p7s|p6o|p3w|p7s|p)\\/(.*)$/.match(@path)\n \"p/\" << m[2]\n else\n @path\n end\n end", "def image_path(source)\n path_to_asset(source)\n end", "def relative_url_fragment_to_jpg\n return \"/#{IMAGEDB_FOLDER}/#{self.id}.jpg\"\n end", "def image(key, image_path, options = {})\n # Idea from here http://itext.ugent.be/library/question.php?id=31 \n # Thanks Bruno for letting me know about it.\n img = Image.get_instance(image_path)\n coords = @form.get_field_positions(key.to_s)\n rect = coords[0].position\n img.set_absolute_position(rect.left, rect.bottom)\n img.scale_to_fit(rect)\n image_content = @stamp.get_over_content(options.fetch(:page, 1))\n image_content.add_image(img)\n end", "def image\n @image ||= ImageDrop.new(:page => page, :context => @context)\n @image if @image.path\n end", "def get_thumbnail\n puts \"id:\", id\n if File.exists?(\"app/assets/images/project_#{id}/page_index.png\")\n \"/assets/project_#{id}/page_index.png\"\n else\n \"/assets/default.jpg\"\n end\n end", "def image_path(size)\n (self.images.image) ? self.images.image.file.url(size) : ( (self.venue.images.image) ? self.venue.images.image.file.url(size) : \"/images/noimage_#{(size == :large) ? 300 : ((size == :medium) ? 210 : 125)}.gif\" )\n end", "def image\n if attachment?\n attachment.url(:large)\n elsif filename?\n \"/images/slides/#{filename}\"\n else\n \"/images/slides/default.jpg\"\n end\n end", "def logo_path(ngo)\n if ngo.image.attached?\n Rails.application.routes.url_helpers.rails_blob_path(ngo.image, only_path: true)\n else\n ActionController::Base.helpers.image_path('image_not_found.png')\n end\n end", "def type_img\n \"/assets/file-types/#{self.asset_type}.png\"\n end", "def imagen_path\n\t\t\"../perfumes/#{id}.#{imagen}\"\n\t\t# \"../perfumes/#{imagen}\"\n\tend", "def image(path,options={})\n set RGhost::Image.for(path,options)\n end", "def icone_plmtype(plmtype)\n\t\tret = \"/images/#{plmtype}.png\"\n\t\tunless File.exist?(\"#{config.root}/public#{ret}\")\n\t\t\tret = \"\"\n\t\tend\n\t\tret\n\tend", "def photo_path\n\"/photo_store/#{id}.#{extension}\"\nend", "def image_path(source, options = {})\n asset_path source, { :dir => 'images' }.merge(options)\n end", "def asset_image_path(image_name)\n File.expand_path(\"../../assets/images/#{image_name}\", __FILE__)\n end", "def site_image_url(src)\n rewrite_asset_path(src.expand_url(\"#{account_site_assets_url}/images/\"))\n end", "def get_email_image(image_path)\n # Return the path as a string\n return image_path\nend", "def image_url\n is_processed ?\n FileSystem.url(image_path) : \n orig_image_url\n end", "def image_url\n is_processed ?\n FileSystem.url(image_path) : \n orig_image_url\n end", "def image_fs_path(issue, basename)\n debugger\n dir_path = Rails.root.join('public', \"photos/#{@issue.date.strftime('%m-%d-%y')}\")\n if not File.exists?(dir_path)\n FileUtils.mkdir_p(dir_path)\n end\n \"#{dir_path}/#{basename}\"\nend", "def image\n \"icon.png\"\n end", "def load_image(path)\n end", "def img_file\n return \"map_\" + symbol.to_s + \"_full\"\n end", "def image\n if attachment?\n attachment.url(:large)\n elsif filename?\n \"/images/menu/#{filename}\"\n else\n nil\n end\n end", "def default_url\n ActionController::Base.helpers.asset_path(\"placeholders/\" + [\"default\", version_name].compact.join('_')) + \".png\"\n return \"/images/placeholders/\" + [\"default\", version_name].compact.join('_') + \".png\"\n end", "def image; end", "def absolute_images_path\n File.join(absolute_import_dir, \"images\")\n end", "def template_image=(filepath)\n @template_image = read_image(filepath)\n end", "def tier_image_path(tier, options={})\n defaults = {:name => :thumb}\n options = defaults.merge(options).symbolize_keys\n version = options.delete(:name)\n source = options.delete(:source)\n return source if source\n\n if tier.image.file?\n source = tier.image.url(version)\n end\n source = case version.to_s\n when /thumb/ then image_path 'icons/tiers/default_thumb.png'\n when /profile/ then image_path 'icons/tiers/default_profile.png'\n when /invoice/ then image_path 'icons/tiers/default_invoice.png'\n end unless source\n source\n end", "def ubiquo_image_path(name)\n \"/images/ubiquo/#{name}\"\n end", "def relative_images_path\n File.join(relative_import_dir, \"images\")\n end", "def resource_images(context={})\n ['/mail/img/Mail.png']\n end", "def images\n @images ||= {\n :news => HomePageImage.path_for_slot(:news),\n :wellness => HomePageImage.path_for_slot(:wellness),\n :research => HomePageImage.path_for_slot(:research),\n :testimonials => HomePageImage.path_for_slot(:testimonials),\n :conditions => HomePageImage.path_for_slot(:conditions),\n :events => HomePageImage.path_for_slot(:events)\n }\n end", "def default_url\n ActionController::Base.helpers.image_path('user.png')\n end", "def marker_img_path_for_grade grade\n image_path(\"#{marker_img_for_grade(grade)}\")\n end" ]
[ "0.7723291", "0.75510156", "0.740188", "0.73719907", "0.72654647", "0.7210056", "0.7180687", "0.71671045", "0.71297526", "0.71255475", "0.71107906", "0.71013737", "0.708507", "0.70850617", "0.7084603", "0.7056477", "0.70080036", "0.6991442", "0.698584", "0.6970849", "0.6969843", "0.6947293", "0.69121206", "0.6901007", "0.68996763", "0.6880167", "0.6869943", "0.68668914", "0.6850094", "0.6837425", "0.682276", "0.6822371", "0.6811601", "0.67919475", "0.67525303", "0.6749975", "0.6744938", "0.6729163", "0.6681742", "0.6679551", "0.6657289", "0.66509753", "0.66454643", "0.6644576", "0.6641576", "0.664116", "0.6637133", "0.66301626", "0.66282284", "0.66257983", "0.66234887", "0.66209656", "0.66050655", "0.6599067", "0.6581502", "0.6579267", "0.6563582", "0.65572876", "0.6555022", "0.653712", "0.6533209", "0.6501335", "0.65000385", "0.6499076", "0.64919823", "0.6484916", "0.6476931", "0.64713156", "0.64710027", "0.64692956", "0.64676934", "0.646423", "0.6447207", "0.64213336", "0.6421164", "0.64196", "0.64188766", "0.64154047", "0.6395817", "0.6389341", "0.63856155", "0.63744473", "0.63737017", "0.63737017", "0.6372534", "0.6359314", "0.63558155", "0.6346716", "0.6344993", "0.6343161", "0.6339967", "0.6338483", "0.63310885", "0.632135", "0.6319636", "0.63005555", "0.6298996", "0.6297117", "0.6285906", "0.6284931" ]
0.74867046
2
Temporarily used for tabula processing intended to be extracted into a tabula namespace in future.
def page_csv_path(page_number) File.join(pages_path, "#{slug}-p#{page_number}.csv") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_table; end", "def post_processing_tables(nodes)\n tables = nodes\n .css('table:not(.o-ld-columns-table)')\n .add_class('c-ld-table')\n tables.wrap('<div class=\"c-ld-table__wrap\"></div>') unless @options[:material]\n end", "def reconstitute_step(step_text, table)\n @keep_hold_of_raw_table = table\n step_text+\":\"\nend", "def table=(_arg0); end", "def after_processing_hook; end", "def parse\n lines = @text.split(\"\\n\")\n head = lines.shift\n head = head.gsub(/[[:punct:]]/, '')\n #head = head.gsub(/[[:space:]]|\\t/, '')\n head_match = Tables::Header_regex.match(head.strip)\n if head_match then\n @die = head_match[2].to_i\n @header = head_match[3].strip\n end\n lines.each { |l|\n l = l.gsub(/[[:punct:]]/, '')\n ti = Tables::Line_regex.match(l.strip)\n if ti then\n @outcomes << TableItem.new(ti.to_s)\n end\n }\n end", "def parse_and_set_tables\n tables = @nokogiri_document.xpath(\".//table\")\n @tables_count = tables.count\n unless @tables_count > 12\n tables.each_with_index do | table , index |\n if index.odd?\n key = define_key_based_on_index(index)\n noko = Nokogiri::HTML(table.to_s)\n noko.xpath(\"/html/body/table\").each do | table |\n @tables[key] = table\n end\n noko = nil\n end\n end\n end\n end", "def parse\n input_data.each do |filename, data|\n rowdata_template = OpenStruct.new\n @preprocess_block.call(filename, rowdata_template) if @preprocess_block\n\n arrived_at_table_data = false\n\n data.split(\"\\r\\n\").each do |line|\n next if line.strip.empty? # Skip blank and whitespace lines\n\n if !arrived_at_table_data\n next if line =~ /\\ACreated by SunData/ # Skip created by line\n if date_match = line.match(/\\A(\\d\\d\\d\\d-\\d\\d-\\d\\d)\\t\\tLocal time is (GMT.\\d+ Hrs)/)\n rowdata_template.date = date_match[1]\n rowdata_template.timezone = date_match[2]\n end\n\n if sunscan_match = line.match(/\\ASunScan probe (v.*)/)\n rowdata_template.sunscan_version = sunscan_match[1]\n end\n\n if matches = line.scan(/\\s*([^\\t:]+)\\s*:\\s*([^\\t:]+)/)\n matches.flatten.map(&:strip).each_slice(2) do |key, value|\n next if value.nil? || value.empty?\n rowdata_template[key.downcase.gsub(\" \", \"_\")] = value\n end\n end\n\n # Once we hit the table hearder we can start processing tabular data.\n # The header is two lines long because of the formatting.\n next if line =~ /\\ATime\\tPlot\\t/\n arrived_at_table_data = true and next if line =~ /\\s+mitted\\s+ent/\n\n\n else\n rowdata = rowdata_template.dup\n table_line = line.split(\"\\t\")\n rowdata.time = table_line[0]\n rowdata.plot = table_line[1]\n rowdata.sample = table_line[2]\n rowdata.transmitted = table_line[3]\n rowdata.spread = table_line[4]\n rowdata.incident = table_line[5]\n rowdata.beam = table_line[6]\n rowdata.zenith_angle = table_line[7]\n rowdata.lai = table_line[8]\n rowdata.notes = table_line[9]\n # Only record output data once the full line data has been captured.\n output_data << rowdata\n end\n end\n end\n end", "def parse_local_table(sheet, table, tableindex)\n local_table = sheet.create_or_open_table_at(tableindex)\n local_table.name = table.xpath(\"@table:name\").to_s\n\n table.xpath(\"table:table-row\").each do |row|\n local_table << parse_local_row(row)\n end\n\n local_table.trim!\n end", "def extract_tables(main)\n sections = main.split(\"[End of table] \\n\")\n tables = []\n sections.each do |section|\n flag = false\n table = \"\"\n section.lines do |line|\n flag = true if line =~ /^Table /\n table << line if flag\n end\n tables << table unless table.empty?\n end\n tables\n end", "def block_docbook_table( text ) \n text.gsub!( TABLE_RE ) do |matches|\n\n caption, id, tatts, fullrow = $~[1..4]\n tatts = docbook_pba( tatts, caption ? 'table' : 'informaltable' )\n tatts = shelve( tatts ) if tatts\n rows = []\n\n found_first = false\n cols = 0\n raw_rows = fullrow.split( /\\|$/m ).delete_if {|row|row.empty?}\n raw_rows.each do |row|\n\n ratts, row = docbook_pba( $1, 'row' ), $2 if row =~ /^(#{A}#{C}\\. )(.*)/m\n row << \" \"\n \n cells = []\n head = 'tbody'\n cols = row.split( '|' ).size-1\n row.split( '|' ).each_with_index do |cell, i|\n next if i == 0\n ctyp = 'entry'\n head = 'thead' if cell =~ /^_/\n\n catts = ''\n catts, cell = docbook_pba( $1, 'entry' ), $2 if cell =~ /^(_?#{S}#{A}#{C}\\. ?)(.*)/\n\n catts = shelve( catts ) if catts\n cells << \"<#{ ctyp }#{ catts }>#{ cell.strip.empty? ? \"&nbsp;\" : row.split( '|' ).size-1 != i ? cell : cell[0...cell.length-1] }</#{ ctyp }>\" \n end\n ratts = shelve( ratts ) if ratts\n if head == 'tbody'\n if !found_first\n found_first = true\n rows << \"<#{ head }>\"\n end\n else\n rows << \"<#{ head }>\"\n end\n rows << \"<row#{ ratts }>\\n#{ cells.join( \"\\n\" ) }\\n</row>\"\n rows << \"</#{ head }>\" if head != 'tbody' || raw_rows.last == row\n end\n title = \"<title>#{ caption }</title>\\n\" if caption\n \n if id\n @ids << \"id#{id}\"\n id = \" id=\\\"#{ \"id#{id}\" }\\\"\"\n end\n \n %{<#{ caption ? nil : 'informal' }table#{ id }#{ tatts }>\\n#{title}<tgroup cols=\"#{cols}\">\\n#{ rows.join( \"\\n\" ) }\\n</tgroup>\\n</#{ caption ? nil : 'informal' }table>\\n\\n}\n end\n end", "def parse_web(table_cells)\nend", "def parse\n @table = []\n rows = @doc.split(/\\r?\\n/)\n rows.each do |row|\n row_array = row.split(\"|\")\n row_array.each(&:strip!)\n @table.push(row_array)\n end\n @table.delete_at(1) if @header # strip header separator\n @table\n end", "def resolve_tabfile\n File.readlines(tabfile_path).map do |line|\n line.chomp!\n unless line.empty?\n name, size, owner = line.split(\"\\t\")\n _create(name, size, owner) unless _exists?(name)\n end\n end\n end", "def trd; end", "def parse_font_table(src, current_pos)\n group = 1\n\n font = nil\n in_extra = nil\n\n while (true)\n case(src[current_pos])\n when '{' then\n font = RubyRTF::Font.new if group == 1\n in_extra = nil\n\n group += 1\n\n when '}' then\n group -= 1\n\n if group <= 1\n break if font.nil?\n font.cleanup_names\n @doc.font_table[font.number] = font\n end\n\n in_extra = nil\n\n break if group == 0\n\n when '\\\\' then\n ctrl, val, current_pos = parse_control(src, current_pos + 1)\n\n font = RubyRTF::Font.new if font.nil?\n\n case(ctrl)\n when :f then font.number = val\n when :fprq then font.pitch = val\n when :fcharset then font.character_set = val\n when *[:flomajor, :fhimajor, :fdbmajor, :fbimajor,\n :flominor, :fhiminor, :fdbminor, :fbiminor] then\n font.theme = ctrl.to_s[1..-1].to_sym\n\n when *[:falt, :fname, :panose] then in_extra = ctrl\n else\n cmd = ctrl.to_s[1..-1].to_sym\n if RubyRTF::Font::FAMILIES.include?(cmd)\n font.family_command = cmd\n end\n end\n\n # need to next as parse_control will leave current_pos at the\n # next character already so current_pos += 1 below would move us too far\n next\n when *[\"\\r\", \"\\n\"] then ;\n else\n case(in_extra)\n when :falt then font.alternate_name << src[current_pos]\n when :panose then font.panose << src[current_pos]\n when :fname then font.non_tagged_name << src[current_pos]\n when nil then font.name << src[current_pos]\n end\n end\n current_pos += 1\n end\n\n current_pos\n end", "def completed_text_extraction\n end", "def tabla_pasos(contador,array_anterior)\n aux=0\n tabla = Terminal::Table.new do |a|\n a.title= \"ELEMENTOS A ORDENAR: #{array_anterior}\"\n a.headings = [{value:'DATO', alignment: :center},{value:'ESTRUCTURA', alignment: :center}]\n for i in 0..contador-1\n a.add_row([\n aux+=1,\n @pasoL[i]\n ])\nend\n end\n return tabla\n end", "def prepare_table(element)\n name=element.attributes[\"name\"]\n oid=SNMPPass.oid2num(element.attributes[\"oid\"])\n\n # Read index and columns\n indexes=element.elements[\"row/linkage\"].elements.collect(\"index\") {|index| index.attributes[\"name\"]}\n columns=element.elements[\"row\"].elements.collect(\"column\") do\n |column|\n column_name=column.attributes[\"name\"]\n column_oid=column.attributes[\"oid\"]\n column_id=SNMPPass.oid2num(column_oid).last\n\n $DEBUG.puts \"TABLE: #{name} NAME: #{column_name} ID #{column_id}, OID: #{column_oid}\"\n\n #column_desc=column.elements[\"description\"].text.gsub(/^[[:blank:]\\n]*/,\"\").gsub(/[[:blank:]\\n]*$/,\"\")\n type=prepare_type(column.elements[\"syntax\"], column_name)\n [column_name,column_id,type]\n end\n\n @indexes[name]=indexes\n @columns[name]=columns\n\n table=DynamicTree.new(oid){|op, *roid| dynamic_tree_callback(name, op, *roid) }\n add_node(table)\n end", "def pre_process\n end", "def parse_table(object_entry)\n if object_entry.custom_map and @type_items[object_entry.custom_map.type] == \"com.apple.notes.ICTable\"\n object_entry.custom_map.map_entry.each do |map_entry|\n case @key_items[map_entry.key]\n when \"crTableColumnDirection\"\n #puts \"Column Direction: #{object_entrys[map_entry.value.object_index]}\"\n when \"crRows\"\n parse_rows(@table_objects[map_entry.value.object_index])\n when \"crColumns\"\n parse_columns(@table_objects[map_entry.value.object_index])\n when \"cellColumns\"\n parse_cell_columns(@table_objects[map_entry.value.object_index])\n end\n\n # If we know how many rows and columns we have, we can initialize the table\n initialize_table if (@total_columns > 0 and @total_rows > 0 and @reconstructed_table.length < 1)\n end\n\n # We need to reverse the table if it is right to left\n if @table_direction == RIGHT_TO_LEFT_DIRECTION\n @reconstructed_table.each do |row|\n row.reverse!\n end\n end\n end\n end", "def tt; end", "def extract_as_table treatments_heading_row, sample_col, treatments_first_col,treatments_last_col,sheet\n table = []\n sheet_name = sheet.attributes[\"name\"]\n cells = sheet.find(\"//ss:sheet[@name='#{sheet_name}']/ss:rows/ss:row/ss:cell[@row >= '#{(treatments_heading_row).to_s}' and (@column = '#{sample_col.to_s}' or (@column>='#{treatments_first_col.to_s}' and @column<='#{treatments_last_col.to_s}'))]\")\n\n cells.each do |cell|\n row = cell.attributes['row'].to_i\n col = cell.attributes['column'].to_i\n\n #normalise row and column, to leave a table only containing the required content\n row = row - treatments_heading_row\n if col == sample_col\n col = 0\n else\n col = col - treatments_first_col + 1\n end\n\n table[row]||=[]\n table[row][col]=cell.content\n\n end\n\n\n #tidy up the table, removing rows once a completely empty row is encountered, and padding rows up to the maximum width, and replacing\n #nils with empty strings\n lasti=table.size\n maxwidth=0\n table.each_with_index do |row,i|\n maxwidth = row.size unless row.nil? || row.size<maxwidth\n if row.nil? || row.empty? || row.select{|v| !v.blank?}.empty?\n lasti=i\n break\n end\n end\n table = table[0...lasti]\n table.each do |row|\n if row.size<maxwidth\n row.fill(\"\",row.size,maxwidth-row.size)\n end\n row.map!{|v| v.nil? ? \"\" : v}\n end\n\n table\n end", "def tableify node\n if node.xpath('title').length > 0\n colgroup = Nokogiri::XML::Node.new( 'colgroup', $document )\n node = wrap_up node.name, node, { name: 'table', role: node.name, class: node.name }, Nokogiri::XML::NodeSet.new( $document, [ colgroup, node.children ].flatten )\n else\n colgroup = Nokogiri::XML::Node.new( 'colgroup', $document )\n node = wrap_up node.name, node, { name: 'informaltable', role: node.name, class: node.name }, Nokogiri::XML::NodeSet.new( $document, [ colgroup, node.children ].flatten )\n end\n\n # Convert title to caption (see\n # http://www.sagehill.net/docbookxsl/Tables.html ) and re-order things\n newchildren = []\n node.children.each { |child| child.name == 'title' and convert 'title', child, 'caption' }\n node.children.each { |child| child.name == 'caption' and newchildren << child }\n node.children.each { |child| child.name == 'colgroup' and newchildren << child }\n node.children.each { |child| child.name != 'caption' and child.name != 'colgroup' and newchildren << child }\n node.children = Nokogiri::XML::NodeSet.new( $document, newchildren )\n\n return node\nend", "def post_process; end", "def import_unifying_themes(table)\n relevent_columns = ((table/:tr)[2]/:td).each do |td| \n themeName = ((td/:p)[0]).inner_text.strip \n theme = RiGse::UnifyingTheme.find_by_name(themeName)\n if (theme)\n (td/:li).each do |li|\n big_idea = RiGse::BigIdea.new\n big_idea.description = (clean_text(li.inner_text)).gsub(/^\\./,\"\")\n big_idea.unifying_theme = theme \n big_idea.save\n end\n else\n logger.warn \"could not find theme for : #{themeName}\"\n end\n end \n end", "def read_tabs\n end", "def reduce_tab(_production, _range, _tokens, _children)\n Regex::Character.new('\\t')\n end", "def preprocess(&block); end", "def process_rows!\n # Correct incorrect rows in the table\n table.each do |row|\n row_metric = row[\"metric\"] # perf optimization\n # TODO inject Saikuro reference\n if row_metric == :saikuro\n fix_row_file_path!(row)\n end\n tool_tables[row_metric] << row\n file_tables[row[\"file_path\"]] << row\n class_tables[row[\"class_name\"]] << row\n method_tables[row[\"method_name\"]] << row\n end\n end", "def tablefeaturetype(io)\n lt, id_list, crw_header, crw_totals, id_field_next, cb_fs_data, rup_build, _ = io.read(28).unpack('VVVVVVvv')\n\n result = {\n lt: lt, # lt (4 bytes): A SourceType that specifies the type of data source for the table.\n lt_d: sourcetype(lt),\n idList: id_list, # idList (4 bytes): An unsigned integer that specifies an identifier for the table. MUST be unique within the sheet. SHOULD<183> be unique within the workbook.\n crwHeader: crw_header == 1, # crwHeader (4 bytes): A Boolean (section 2.5.14) that specifies whether the table has a header row.\n crwTotals: crw_totals == 1, # crwTotals (4 bytes): A Boolean that specifies whether there is a total row.\n idFieldNext: id_field_next, # idFieldNext (4 bytes): An unsigned integer that specifies the next unique identifier to use when assigning unique identifiers to the fieldData.idField field of the table.\n cbFSData: cb_fs_data, # cbFSData (4 bytes): An unsigned integer that specifies the size, in bytes, of the fixed portion of this structure. The fixed portion starts at the lt field and ends at the rgbHashParam field. MUST be equal to 64.\n rupBuild: rup_build, # rupBuild (2 bytes): An unsigned integer that specifies the build number of the application that wrote the structure.\n # unused1 (2 bytes): Undefined, and MUST be ignored.\n }\n\n attrs = Unxls::BitOps.new(io.read(4).unpack('V').first)\n result.merge!({\n # A - unused2 (1 bit): Undefined, and MUST be ignored.\n fAutoFilter: attrs.set_at?(1), # B - fAutoFilter (1 bit): A bit that specifies whether the table has an AutoFilter. MUST be 1 when fPersistAutoFilter is 1.\n fPersistAutoFilter: attrs.set_at?(2), # C - fPersistAutoFilter (1 bit): A bit that specifies whether the AutoFilter is preserved for this table after data refresh operations.<184>\n fShowInsertRow: attrs.set_at?(3), # D - fShowInsertRow (1 bit): A bit that specifies whether the insert row is visible. MUST be 1 if fInsertRowInsCells is 1.\n fInsertRowInsCells: attrs.set_at?(4), # E - fInsertRowInsCells (1 bit): A bit that specifies whether rows below the table are shifted down because of the insert row being visible.\n fLoadPldwIdDeleted: attrs.set_at?(5), # F - fLoadPldwIdDeleted (1 bit): A bit that specifies whether the idDeleted field is present. MUST be zero if the lt field is not set to 0x00000001.\n fShownTotalRow: attrs.set_at?(6), # G - fShownTotalRow (1 bit): A bit that specifies whether the total row was ever visible.\n # H - reserved1 (1 bit): MUST be zero and MUST be ignored.\n fNeedsCommit: attrs.set_at?(8), # I - fNeedsCommit (1 bit): A bit that specifies whether table modifications were not synchronized with the data source. MUST be zero if the lt field is not set to 0x00000001.\n fSingleCell: attrs.set_at?(9), # J - fSingleCell (1 bit): A bit that specifies whether the table is limited to a single cell. The table cannot have header rows, total rows, or multiple columns. If fSingleCell equals 1, the lt field MUST be set to 0x00000002.\n # K - reserved2 (1 bit): MUST be zero and MUST be ignored.\n fApplyAutoFilter: attrs.set_at?(11), # L - fApplyAutoFilter (1 bit): A bit that specifies whether the AutoFilter is currently applied. MUST be 1 if the AutoFilter is currently applied<185>.\n fForceInsertToBeVis: attrs.set_at?(12), # M - fForceInsertToBeVis (1 bit): A bit that specifies whether the insert row is forced to be visible because the table has no data.\n fCompressedXml: attrs.set_at?(13), # N - fCompressedXml (1 bit): A bit that specifies whether the cached data for this table in the List Data stream is compressed. MUST be zero if the lt field is not set to 0x00000001.\n fLoadCSPName: attrs.set_at?(14), # O - fLoadCSPName (1 bit): A bit that specifies whether the cSPName field is present. MUST be zero if the lt field is not set to 0x00000001.\n fLoadPldwIdChanged: attrs.set_at?(15), # P - fLoadPldwIdChanged (1 bit): A bit that specifies whether idChanged field is present. MUST be zero if the lt field is not set to 0x00000001.\n verXL: attrs.value_at(16..19), # verXL (4 bits): An unsigned integer that specifies the application version under which the table was created. MUST be either 0xB or 0xC<186>.\n fLoadEntryId: attrs.set_at?(20), # Q - fLoadEntryId (1 bit): A bit that specifies whether the entryId field is present.\n fLoadPllstclInvalid: attrs.set_at?(21), # R - fLoadPllstclInvalid (1 bit): A bit that specifies whether the cellInvalid field is present. MUST be zero if the lt field is not set to 0x00000001.\n fGoodRupBld: attrs.set_at?(22), # S - fGoodRupBld (1 bit): A bit that specifies whether the rupBuild field is valid.\n # T - unused3 (1 bit): Undefined, and MUST be ignored.\n fPublished: attrs.set_at?(24), # U - fPublished (1 bit): A bit that specifies whether the table is published. This bit is ignored if the fPublishedBookItems field of the BookExt_Conditional12 structure is zero.\n # reserved3 (7 bits): Undefined, and MUST be ignored.\n })\n\n _, _, _, lem, _ = io.read(32).unpack('V3VC*')\n result.merge!({\n lPosStmCache: :not_implemented, # lPosStmCache (4 bytes): An unsigned integer that specifies the position of the cached data within the List Data stream. Undefined and MUST be ignored if the lt field is not set to 0x00000001.\n cbStmCache: :not_implemented, # cbStmCache (4 bytes): An unsigned integer that specifies the size, in bytes, of the cached data within the List Data stream. Undefined and MUST be ignored if the lt field is not set to 0x00000001.\n cchStmCache: :not_implemented, # cchStmCache (4 bytes): An unsigned integer that specifies the count of characters of the cached data within the List Data stream when the cached data is uncompressed. Undefined and MUST be ignored if the lt field is not set to 0x00000001.\n LEMMode: lemmode(lem), # lem (4 bytes): A LEMMode enumeration that specifies the table edit mode. If lt is set to 0x00000000, 0x00000002 or 0x00000003, this field MUST be set to 0x00000000.\n rgbHashParam: :not_implemented, # rgbHashParam (16 bytes): An array of bytes that specifies round-trip information. SHOULD<187> be ignored and MUST be preserved if the lt field is set to 0x00000001. Undefined and MUST be ignored if the lt field is not set to 0x00000001.\n })\n\n result[:rgbName] = xlunicodestring(io) # rgbName (variable): An XLUnicodeString that specifies the name of the table. MUST be unique per workbook, and case-sensitive in all locales.\n result[:cFieldData] = io.read(2).unpack('v').first # cFieldData (2 bytes): An unsigned integer that specifies the number of columns in the table. MUST be greater than or equal to 0x0001 and less than or equal to 0x0100.\n\n if result[:fLoadCSPName]\n result[:cSPName] = xlunicodestring(io) # cSPName (variable): An XLUnicodeString that specifies the name of the cryptographic service provider used to specify rgbHashParam. This field is present only if fLoadCSPName is set to 1.\n end\n\n if result[:fLoadEntryId]\n result[:entryId] = xlunicodestring(io) # entryId (variable): An XLUnicodeString that specifies a unique identifier for the table. The string equals the value of the idList field, represented in decimal format, without any leading zeros. It is used when lt equals 0x00000002 and ignored otherwise. This field is present only if fLoadEntryId is set to 1.\n end\n\n result[:fieldData] = result[:cFieldData].times.map { feat11fielddataitem(io, result) } # fieldData (variable): An array of Feat11FieldDataItem that contains the specification of the columns of the table. The number of items in this array is specified by the cFieldData field.\n\n if result[:fLoadPldwIdDeleted]\n result[:idDeleted] = :not_implemented # idDeleted (variable): A Feat11RgSharepointIdDel structure that specifies the identifiers of deleted rows. This information is used when synchronizing with the Web based data provider’s data source. This field is only present if the fLoadPldwIdDeleted field is set to 1.\n end\n\n if result[:fLoadPldwIdChanged]\n result[:idChanged] = :not_implemented # idChanged (variable): A Feat11RgSharepointIdChange structure that specifies the identifiers of the edited rows. This information is used when synchronizing with the Web based data provider’s data source. This field is only present if the fLoadPldwIdChanged field is set to 1.\n end\n\n if result[:fLoadPllstclInvalid]\n result[:cellInvalid] = :not_implemented # cellInvalid (variable): A Feat11RgInvalidCells structure that specifies the location of cells within the table that contain values that are invalid based on validation rules on the Web based data provider. This field is only present if the fLoadPllstclInvalid field is set to 1.\n end\n\n result\n end", "def block_textile_table( text ) \n text.gsub!( TABLE_RE ) do |matches|\n\n caption, id, tatts, fullrow = $~[1..4]\n tatts = pba( tatts, 'table' )\n tatts = shelve( tatts ) if tatts\n rows = []\n\n fullrow.\n split( /\\|$/m ).\n delete_if {|row|row.empty?}.\n each do |row|\n\n ratts, row = pba( $1, 'tr' ), $2 if row =~ /^(#{A}#{C}\\. )(.*)/m\n row << \" \"\n \n cells = []\n row.split( '|' ).each_with_index do |cell, i|\n next if i == 0\n \n ctyp = 'd'\n ctyp = 'h' if cell =~ /^_/\n\n catts = ''\n catts, cell = pba( $1, 'td' ), $2 if cell =~ /^(_?#{S}#{A}#{C}\\. ?)(.*)/\n\n catts = shelve( catts ) if catts\n cells << \"\\t\\t\\t<t#{ ctyp }#{ catts }>#{ cell.strip.empty? ? \"&nbsp;\" : row.split( '|' ).size-1 != i ? cell : cell[0...cell.length-1] }</t#{ ctyp }>\"\n end\n ratts = shelve( ratts ) if ratts\n rows << \"\\t\\t<tr#{ ratts }>\\n#{ cells.join( \"\\n\" ) }\\n\\t\\t</tr>\"\n end\n caption = \"\\t<p class=\\\"caption\\\">#{caption}</p>\\n\" if caption\n \"#{caption}\\t<table#{ tatts }>\\n#{ rows.join( \"\\n\" ) }\\n\\t</table>\\n\\n\"\n end\n end", "def namespace; end", "def namespace; end", "def namespace; end", "def namespace; end", "def namespace; end", "def namespace; end", "def namespace; end", "def namespace; end", "def create_table_def\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 5 )\n return_value = CreateTableDefReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n root_0 = nil\n column20 = nil\n pk_definition21 = nil\n\n\n begin\n # at line 31:3: ( column | pk_definition )\n alt_5 = 2\n look_5_0 = @input.peek( 1 )\n\n if ( look_5_0 == ID )\n alt_5 = 1\n elsif ( look_5_0 == PRIMARY_KEY )\n alt_5 = 2\n else\n raise NoViableAlternative( \"\", 5, 0 )\n end\n case alt_5\n when 1\n root_0 = @adaptor.create_flat_list\n\n\n # at line 31:5: column\n @state.following.push( TOKENS_FOLLOWING_column_IN_create_table_def_180 )\n column20 = column\n @state.following.pop\n @adaptor.add_child( root_0, column20.tree )\n\n when 2\n root_0 = @adaptor.create_flat_list\n\n\n # at line 32:5: pk_definition\n @state.following.push( TOKENS_FOLLOWING_pk_definition_IN_create_table_def_186 )\n pk_definition21 = pk_definition\n @state.following.pop\n @adaptor.add_child( root_0, pk_definition21.tree )\n\n end# - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look( -1 )\n\n\n return_value.tree = @adaptor.rule_post_processing( root_0 )\n @adaptor.set_token_boundaries( return_value.tree, return_value.start, return_value.stop )\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n return_value.tree = @adaptor.create_error_node( @input, return_value.start, @input.look(-1), re )\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 5 )\n\n end\n \n return return_value\n end", "def test_html_tables\n e = Extractor::HTMLTableExtractor.new(:headerlines => 1)\n e.run(fixture(\"infoplease.html\").read)\n assert_match(/Per Capita Personal Income by State .* Infoplease.com/, e.title)\n assert_equal(52, e.data.size)\n assert_equal(11, e.data[0].size)\n assert_equal(\"State\", e.headers[0])\n assert_equal(\"1990\", e.headers[2])\n assert_equal(2, e.properties.size)\n\n # should skip blank rows\n e = Extractor::HTMLTableExtractor.new(:headerlines => 1)\n e.run(testdata(\"worldpop.html\"))\n assert_equal(101, e.data.size)\n\n ce = Extractor::CustomExtractor.new(testdata(\"html_table_with_header.rb\"))\n ce.run(testdata(\"cia_oil.html\"))\n assert_equal(209, ce.data.size) # rows\n assert_equal(4, ce.data[0].size) # columns\n assert_equal(\"Oil - production (bbl/day)\", ce.headers[2])\n end", "def initialize(opts={})\n @uri = opts[:uri] || files[opts[:index]]\n dir = opts[:dir] || File.expand_path('../../data/pdf', File.dirname(__FILE__))\n @path = File.expand_path(uri.split('/').last, dir)\n range = opts[:range] || 3..5\n caption, @rows = TabulaWrapper.new(path, range).extract\n @title = caption[title_re]\n @description = caption[description_re]\n @date = parse_date(title)\n # The coding changed with the 2014-02-13 data.\n @header = date < Date.new(2014,2,13) ? headers[0] : headers[1]\n\n refine_rows\n end", "def css=(_arg0); end", "def transformations; end", "def parse_table\n advance\n table = Element.new(:table)\n table = parse_attributes(table)\n table = parse_caption(table)\n while match?(:table_row, :table_header, :table_data)\n table = parse_row(table)\n end\n if match? :table_end\n advance\n else\n warning 'Could not find end of table, missing \"|}\"'\n end\n table\n end", "def prepare_data \n table=Array.new\n flag=true\n flag2=false\n count=0 \n @reader.pages.each_with_index do |page,i| \n break if i >= @page \n #(?!([a-zA-Z\\-0-9]+))\n #text = page.text.gsub(/\\n\\s{1}+[0-9]{1}+,[0-9]\\s{1}+/,' ')\n rows=page.text.split(/\\n/) \n rows.each_with_index do|row,ind|\n temp=row.split(/\\s{2}+/)\n \n if temp.length == 1 && temp[0].include?('-')\n flag2=true\n rows[ind+1].insert(0, temp[0]) if !rows[ind+1].nil?\n flag2=false;\n end\n if temp.length >9\n temp.delete_at(1) \n end \n if temp.length ==9\n table << temp unless (temp.empty? || row.include?(\"Portfolio Name\"))\n \n end\n if flag && row.include?(\"Portfolio Name\")\n non_standardized_header row\n flag=false\n end\n end\t \n end \n return table\n end", "def parse_table\n return false unless after_block_boundary?\n\n saved_pos = @src.save_pos\n orig_pos = @src.pos\n table = new_block_el(:table, nil, nil, alignment: [], location: @src.current_line_number)\n leading_pipe = (@src.check(TABLE_LINE) =~ /^\\s*\\|/)\n @src.scan(TABLE_SEP_LINE)\n\n rows = []\n has_footer = false\n columns = 0\n\n add_container = lambda do |type, force|\n if !has_footer || type != :tbody || force\n cont = Element.new(type)\n cont.children, rows = rows, []\n table.children << cont\n end\n end\n\n until @src.eos?\n break unless @src.check(TABLE_LINE)\n if @src.scan(TABLE_SEP_LINE)\n if rows.empty?\n # nothing to do, ignoring multiple consecutive separator lines\n elsif table.options[:alignment].empty? && !has_footer\n add_container.call(:thead, false)\n table.options[:alignment] = @src[1].scan(TABLE_HSEP_ALIGN).map do |left, right|\n (left.empty? && right.empty? && :default) || (right.empty? && :left) ||\n (left.empty? && :right) || :center\n end\n else # treat as normal separator line\n add_container.call(:tbody, false)\n end\n elsif @src.scan(TABLE_FSEP_LINE)\n add_container.call(:tbody, true) unless rows.empty?\n has_footer = true\n elsif @src.scan(TABLE_ROW_LINE)\n trow = Element.new(:tr)\n\n # parse possible code spans on the line and correctly split the line into cells\n env = save_env\n cells = []\n @src[1].split(/(<code.*?>.*?<\\/code>)/).each_with_index do |str, i|\n if i.odd?\n (cells.empty? ? cells : cells.last) << str\n else\n reset_env(src: Kramdown::Utils::StringScanner.new(str, @src.current_line_number))\n root = Element.new(:root)\n parse_spans(root, nil, [:codespan])\n\n root.children.each do |c|\n if c.type == :raw_text\n f, *l = c.value.split(/(?<!\\\\)\\|/, -1).map {|t| t.gsub(/\\\\\\|/, '|') }\n (cells.empty? ? cells : cells.last) << f\n cells.concat(l)\n else\n delim = (c.value.scan(/`+/).max || '') + '`'\n tmp = +\"#{delim}#{' ' if delim.size > 1}#{c.value}#{' ' if delim.size > 1}#{delim}\"\n (cells.empty? ? cells : cells.last) << tmp\n end\n end\n end\n end\n restore_env(env)\n\n cells.shift if leading_pipe && cells.first.strip.empty?\n cells.pop if cells.last.strip.empty?\n cells.each do |cell_text|\n tcell = Element.new(:td)\n tcell.children << Element.new(:raw_text, cell_text.strip)\n trow.children << tcell\n end\n columns = [columns, cells.length].max\n rows << trow\n else\n break\n end\n end\n\n unless before_block_boundary?\n @src.revert_pos(saved_pos)\n return false\n end\n\n # Parse all lines of the table with the code span parser\n env = save_env\n l_src = ::Kramdown::Utils::StringScanner.new(extract_string(orig_pos...(@src.pos - 1), @src),\n @src.current_line_number)\n reset_env(src: l_src)\n root = Element.new(:root)\n parse_spans(root, nil, [:codespan, :span_html])\n restore_env(env)\n\n # Check if each line has at least one unescaped pipe that is not inside a code span/code\n # HTML element\n # Note: It doesn't matter that we parse *all* span HTML elements because the row splitting\n # algorithm above only takes <code> elements into account!\n pipe_on_line = false\n while (c = root.children.shift)\n next unless (lines = c.value)\n lines = lines.split(\"\\n\")\n if c.type == :codespan\n if lines.size > 2 || (lines.size == 2 && !pipe_on_line)\n break\n elsif lines.size == 2 && pipe_on_line\n pipe_on_line = false\n end\n else\n break if lines.size > 1 && !pipe_on_line && lines.first !~ /^#{TABLE_PIPE_CHECK}/o\n pipe_on_line = (lines.size > 1 ? false : pipe_on_line) || (lines.last =~ /^#{TABLE_PIPE_CHECK}/o)\n end\n end\n @src.revert_pos(saved_pos) and return false unless pipe_on_line\n\n add_container.call(has_footer ? :tfoot : :tbody, false) unless rows.empty?\n\n if table.children.none? {|el| el.type == :tbody }\n warning(\"Found table without body on line #{table.options[:location]} - ignoring it\")\n @src.revert_pos(saved_pos)\n return false\n end\n\n # adjust all table rows to have equal number of columns, same for alignment defs\n table.children.each do |kind|\n kind.children.each do |row|\n (columns - row.children.length).times do\n row.children << Element.new(:td)\n end\n end\n end\n if table.options[:alignment].length > columns\n table.options[:alignment] = table.options[:alignment][0...columns]\n else\n table.options[:alignment] += [:default] * (columns - table.options[:alignment].length)\n end\n\n @tree.children << table\n\n true\n end", "def block_textile_table( text ) \n text.gsub!( TABLE_RE ) do |matches|\n\n tatts, fullrow = $~[1..2]\n tatts = pba( tatts, 'table' )\n tatts = shelve( tatts ) if tatts\n rows = []\n\n fullrow.each_line do |row|\n ratts, row = pba( $1, 'tr' ), $2 if row =~ /^(#{A}#{C}\\. )(.*)/m\n cells = []\n row.split( /(\\|)(?![^\\[\\|]*\\]\\])/ )[1..-2].each do |cell|\n next if cell == '|'\n ctyp = 'd'\n ctyp = 'h' if cell =~ /^_/\n\n catts = ''\n catts, cell = pba( $1, 'td' ), $2 if cell =~ /^(_?#{S}#{A}#{C}\\. ?)(.*)/\n\n catts = shelve( catts ) if catts\n cells << \"\\t\\t\\t<t#{ ctyp }#{ catts }>#{ cell }</t#{ ctyp }>\" \n end\n ratts = shelve( ratts ) if ratts\n rows << \"\\t\\t<tr#{ ratts }>\\n#{ cells.join( \"\\n\" ) }\\n\\t\\t</tr>\"\n end\n \"\\t<table#{ tatts }>\\n#{ rows.join( \"\\n\" ) }\\n\\t</table>\\n\\n\"\n end\n end", "def _table; @table end", "def getTableFromLocalHtml fileName\n f = File.open(fileName)\n doc = Nokogiri::HTML(f, nil, 'utf-8')\n f.close\n tableTr = doc.xpath('//*[@id=\"page-form\"]/div[2]/div[2]/table//tr')\n return tableTr\nend", "def opx_instantiate_tabulator()\n file = TABULATOR_DATA_FILE\n tc = opx_file_process(file, \"Tabulator Count\", \"tabulator_count\", true)\n tab = opx_new_tabulator_tc(tc)\n opx_err(\"Fatal failure during Tabulator validation: #{file}\") if\n (tab.validation_errors.length > 0 || tab.validation_warnings.length > 0)\n tab\n rescue => e\n opx_err(\"Fatal failure during Tabulator instantiation\", e)\n end", "def parse()\n #This is a stub, used for indexing\n end", "def after_parse; end", "def after_parse; end", "def tabulate content, options\n data = []\n content.each {|line| data << line.join(\"\\t\"); }\n puts \"Rows: #{data.size}\" if $opt_verbose\n require 'tempfile'\n tmpfile = Tempfile.new('SQL.XXXXXX')\n filename = tmpfile.path\n #filename = Shellwords.escape(filename)\n #puts \"Writing to #{filename}\"\n tmpfile.write(data.join(\"\\n\"))\n tmpfile.close # need to flush, otherwise write is buffered\n if options[:formatting]\n system(\"term-table.rb < #{filename} | sponge #{filename}\")\n end\n return filename\nend", "def processor; end", "def table_elements\n lambda do |env|\n name, node = env[:node_name], env[:node]\n if (TABLE_SECTIONS.include?(name) || TABLE_ITEMS.include?(name)) && !node.ancestors.any? { |n| n.name == TABLE }\n node.replace(node.children)\n end\n end\n end", "def parslet; end", "def parslet; end", "def parslet; end", "def parslet; end", "def parse_table\n @parse_table ||= parse_table_for_rule(start)\n end", "def tables\n @tables ||= {}.tap do |tables|\n parsed_data['tables'].map do |table|\n parsed_table_rows = parse_choices(table['rows'])\n tables[table['id']] = Table.new(table['name'], table['parameters'], parsed_table_rows)\n end\n end\n end", "def handle_tab_width(body)\n if /\\t/ =~ body\n tab_width = @options.tab_width\n body.split(/\\n/).map do |line|\n 1 while line.gsub!(/\\t+/) do\n ' ' * (tab_width * $&.length - $`.length % tab_width)\n end && $~\n line\n end.join \"\\n\"\n else\n body\n end\n end", "def preproc; end", "def parse_dispatch_tables(fn)\n\n ctr = 0\n name = nil\n tables = {}\n\n File.read(fn).each_line{|l| \n\n ctr += 1\n l.strip!\n\n next if (iscomment(l) || isblank(l))\n\n # table header\n if (l =~ /^\\[(.*) (.*)\\]$/)\n name=$1\n\n tables[name] = Hash.new\n tables[name]['table'] = []\n tables[name]['field'] = $2\n next\n end\n\n if (name == nil)\n raise \"error: no table name #{fn}: line #{ctr}\"\n end\n\n tables[name]['table'] << l.split\n }\n\n verify_dispatch_tables(tables);\n\n return tables\nend", "def private; end", "def extract_tables(tables)\n puts \"Extracting #{tables.count} tables...\"\n tables.each do |table|\n extract_table(table)\n end\n end", "def after_processing\n end", "def after_source_extraction(extracted_source)\n end", "def data_tables\n @data_tables ||= @profile_page.search('table#yfncsumtab').to_s.gsub(\"\\n\",'')\n end", "def formalize_tab(tab)\n parse_tabs(tab)[0].to_s\nend", "def opx_new_tabulator_tc(tc)\n opx_warn(Tabulator.new(false, false, false, tc))\n rescue => e\n opx_err(\"Fatal failure of Tabulator.new for Tabulator Count\", e)\n end", "def tld; end", "def tld; end", "def before_multiline_arg(multiline_arg)\n return if skip_current_step?\n @current_table = []\n @current_step[:table] = @current_table unless multiline_arg.class == Cucumber::Ast::DocString\n end", "def table_content\n # This makes a call to gift_rows and gets back an array of data that will \n # populate the columns and rows of a table I then included some styling to \n # include a header and make its text bold. I made the row background colors \n # alternate between grey and white Then I set the table column widths\n table gift_rows do\n row(0).font_style = :bold\n self.header = true\n self.row_colors = ['DDDDDD', 'FFFFFF']\n self.column_widths = [180, 180, 180]\n end\n end", "def requirement_table_cleanup1(x, y)\n x.delete(\"colspan\")\n x.delete(\"scope\")\n y.delete(\"colspan\")\n y.delete(\"scope\")\n x.name = \"td\"\n p = x.at(ns(\"./p[@class = 'RecommendationTitle']\")) and\n p.delete(\"class\")\n x.parent << y.dup\n y.parent.remove\n end", "def expand_tabs text\n expanded = []\n\n text.each_line do |line|\n nil while line.gsub!(/(?:\\G|\\r)((?:.{8})*?)([^\\t\\r\\n]{0,7})\\t/) do\n r = \"#{$1}#{$2}#{' ' * (8 - $2.size)}\"\n r = RDoc::Encoding.change_encoding r, text.encoding\n r\n end\n\n expanded << line\n end\n\n expanded.join\n end", "def fix_for_toc_entry(elements); end", "def table; end", "def table; end", "def table; end", "def table; end", "def parse_v1(doc, of, version, debug)\n#------------------------------------------------------------------------------\n# parse yesterday's table data\n# it looks that if I use '//td', then all rows in all tables in the list are returned\n# table id's : 'usa_table_countries_today' and 'usa_table_countries_yesterday'\n#------------------------------------------------------------------------------\n time_stamp = parse_time_stamp(doc,debug,of).prev_day();\n tables = doc.xpath(\"//div[@class='container']/div/div/div/div/div/table\");\n printf(\"ntables: %i\\n\",tables.length)\n\n for table in tables\n \n if (debug > 0) then\n of.printf(\"------------- //table ID: %s\\n\",table['id'])\n of.puts(table)\n end\n \n if (table['id'] == 'usa_table_countries_yesterday') then\n print_header(of)\n rows = table.xpath('tbody/tr')\n for row in rows\n cells = row.xpath('td')\n r = parse_cells(cells,time_stamp,version);\n print_record_to_file(r,of); # print record to a file\n end\n end\n end\n\n return ;\n end", "def table_of_contents\n lineWidth = 50\n table_name = \"Table of Contents\"\n colume1_label = \"Chapter\"\n colume2_label = \"\"\n colume3_label = \"page\"\n spacer = \"\"\n puts table_name.center(lineWidth)\n puts spacer\n puts (colume1_label + \" 1:\").ljust(lineWidth/4) + \"Numbers\".ljust(lineWidth/4) + (colume3_label+\" 1\").rjust(lineWidth/2)\n puts (colume1_label + \" 2:\").ljust(lineWidth/4) + \"Letters\".ljust(lineWidth/4) + (colume3_label+\" 72\").rjust(lineWidth/2)\n puts (colume1_label + \" 3:\").ljust(lineWidth/4) + \"Variables\".ljust(lineWidth/4) + (colume3_label+\" 118\").rjust(lineWidth/2)\n\nend", "def build_pdf_header_rpt2(pdf)\n pdf.font \"Helvetica\" , :size => 8\n $lcCli = @company.name \n $lcdir1 = @[email protected][email protected][email protected]\n\n $lcFecha1= Date.today.strftime(\"%d/%m/%Y\").to_s\n $lcHora = Time.now.to_s\n\n max_rows = [client_data_headers_rpt.length, invoice_headers_rpt.length, 0].max\n rows = []\n (1..max_rows).each do |row|\n rows_index = row - 1\n rows[rows_index] = []\n rows[rows_index] += (client_data_headers_rpt.length >= row ? client_data_headers_rpt[rows_index] : ['',''])\n rows[rows_index] += (invoice_headers_rpt.length >= row ? invoice_headers_rpt[rows_index] : ['',''])\n end\n\n if rows.present?\n\n pdf.table(rows, {\n :position => :center,\n :cell_style => {:border_width => 0},\n :width => pdf.bounds.width\n }) do\n columns([0, 2]).font_style = :bold\n\n end\n\n pdf.move_down 10\n\n end\n\n\n \n pdf \n end", "def regularise_styles(content_raw)\n doc = REXML::Document.new(content_raw)\n\n # Get the default column types from all the sheets (tables) in\n # the workbook\n num_tables = doc.root.elements.to_a('//office:body/*/table:table').length\n (1 .. num_tables).to_a.each do |tnum|\n col_types = []\n cols = doc.root.elements.to_a(\"//table:table[#{tnum}]/table:table-column\")\n cols.each do |col|\n (0 ... (col.attributes['table:number-columns-repeated'] ||\n 1).to_i).to_a.each do\n col_types << col.attributes['table:default-cell-style-name']\n end\n end # each column\n\n # Get the number of rows for each table\n num_rows = doc.root.elements.to_a(\"//table:table[#{tnum}]/table:table-row\").length\n\n # Go through each row and process its cells\n (1 .. num_rows).to_a.each do |rnum|\n # The cells are both <table:table-cell> and\n # <table:covered-table-cell>\n cells = doc.root.elements.to_a(<<-END\n//table:table[#{tnum}]/table:table-row[#{rnum}]/(table:table-cell | table:covered-table-cell)\nEND\n )\n # Keep track of the column number, for formatting purposes\n # (c.f. col_types)\n col_num = 0\n cells.each do |cell|\n # Only need to explicitly format the <table:table-cell>s\n if cell.name == 'table-cell'\n cell.attributes['table:style-name'] ||= col_types[col_num]\n end\n # Advance the column number, based on the columns spanned\n # by the cell\n col_num += (cell.attributes['table:number-columns-repeated'] ||\n 1).to_i\n end\n\n end # each row\n end # each table\n\n return doc.to_s\n end", "def process(css, opts = T.unsafe(nil)); end", "def process(css, opts = T.unsafe(nil)); end", "def paquete\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 2 )\n\n\n return_value = PaqueteReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n\n root_0 = nil\n\n __K_PACKAGE4__ = nil\n __EOL6__ = nil\n qualified_name5 = nil\n\n\n tree_for_K_PACKAGE4 = nil\n tree_for_EOL6 = nil\n\n begin\n root_0 = @adaptor.create_flat_list\n\n\n # at line 14:4: K_PACKAGE qualified_name EOL\n __K_PACKAGE4__ = match( K_PACKAGE, TOKENS_FOLLOWING_K_PACKAGE_IN_paquete_57 )\n if @state.backtracking == 0\n tree_for_K_PACKAGE4 = @adaptor.create_with_payload( __K_PACKAGE4__ )\n @adaptor.add_child( root_0, tree_for_K_PACKAGE4 )\n\n end\n\n @state.following.push( TOKENS_FOLLOWING_qualified_name_IN_paquete_59 )\n qualified_name5 = qualified_name\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, qualified_name5.tree )\n end\n\n __EOL6__ = match( EOL, TOKENS_FOLLOWING_EOL_IN_paquete_61 )\n if @state.backtracking == 0\n tree_for_EOL6 = @adaptor.create_with_payload( __EOL6__ )\n @adaptor.add_child( root_0, tree_for_EOL6 )\n\n end\n\n\n # - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look( -1 )\n\n\n if @state.backtracking == 0\n return_value.tree = @adaptor.rule_post_processing( root_0 )\n @adaptor.set_token_boundaries( return_value.tree, return_value.start, return_value.stop )\n\n end\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n return_value.tree = @adaptor.create_error_node( @input, return_value.start, @input.look(-1), re )\n\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 2 )\n\n\n end\n\n return return_value\n end", "def pre_export\n end", "def post_process(doc)\n doc\n end", "def terpene; end", "def mostrar_una_venta(venta)\n if venta[:tope] == nil\n puts 'No hay ventas en el sistemas'\n else\n print 'Ingrese el cogido de la venta: '\n codigo = gets.chomp\n nodo_venta = buscar_una_venta_en_cola(venta,codigo)\n if nodo_venta == 'La venta no existe en el sistema'\n puts nodo_venta\n else\n tabla = Terminal::Table.new do |t|\n t.title = 'BUSCAR UNA VENTA'\n t.headings=['codigo','subtotal','descuento','total de venta','libros vendidos']\n t.add_row([\n nodo_venta[:codigo],\n nodo_venta[:subtotal],\n nodo_venta[:descuento],\n nodo_venta[:total_venta],\n nodo_venta[:size]\n ])\nend\n tabla2 = Terminal::Table.new do |a|\n a.title = 'Lista de libros vendidos'\n a.headings = ['Autor', 'Nombre', 'Precio','ISBN']\n\n aux = nodo_venta[:tope]\n loop do\n a.add_row([\n aux[:autor],\n aux[:nombre],\n aux[:precio],\n aux[:ISBN]\n ])\n if aux[:siguiente] == nil\n break\n end\n aux = aux[:siguiente]\n end\n end\n puts tabla\n puts tabla2\n end\nend#fin primer if\ngets\nend", "def latex_cabecalho(yaml)\n puts yaml\n string = header(yaml[\"template\"])\n string << packages_basic()\n string << changes(yaml[\"versao\"], Time.now)\n string << titulo(yaml[\"titulo\"])\n string << autor(yaml[\"autor\"])\n string << instituicao(yaml[\"instituicao\"])\n string << tipotrabalho(yaml[\"tipotrabalho\"])\n string << orientador(yaml[\"orientador\"])\n string << coorientador(yaml[\"coorientador\"])\n string << data_atual()\n string << metadatas(yaml[\"palavraschave\"]) \nend", "def get_schematron_processor\n\n return @schematron_processor if @schematron_processor\n @schematron_processor = Nokogiri::XSLT(File.open(@stylesheet))\n end", "def initialize(source)\n @transformer_factory = TransformerFactory.newInstance()\n @source = source\n @style_sheet = @transformer_factory.newTemplates(@source) \n end", "def tabular_input\n @tabular_input ||= IOStreams::Tabular.new(\n columns: tabular_input_header,\n allowed_columns: tabular_input_white_list,\n required_columns: tabular_input_required,\n skip_unknown: tabular_input_skip_unknown,\n format: tabular_input_format\n )\n end", "def generate_tabular_report(filename, ostream)\n file = File.read(filename)\n data_hash = JSON.parse(file)\n rpt_data = transform(data_hash)\n rpt_data.keys.each do |name|\n ostream.puts\n ostream.puts name\n tbl = create_resources_table(rpt_data[name]['resources'])\n tbl.each do |r|\n ostream.puts r.join(\"\\t\")\n end\n end\nend" ]
[ "0.5954213", "0.54071563", "0.52411115", "0.5240897", "0.5155906", "0.51430553", "0.510546", "0.50890815", "0.50829566", "0.5076232", "0.50529045", "0.50250256", "0.50164926", "0.50161356", "0.501386", "0.49771923", "0.4949652", "0.49276152", "0.4917898", "0.49131048", "0.49072728", "0.49023196", "0.48743016", "0.48713326", "0.48638496", "0.4862528", "0.48423305", "0.4822342", "0.48015645", "0.47904634", "0.47856253", "0.47813505", "0.4779037", "0.4779037", "0.4779037", "0.4779037", "0.4779037", "0.4779037", "0.4779037", "0.4779037", "0.4767473", "0.47596854", "0.47573474", "0.47564387", "0.47514468", "0.47494087", "0.47470716", "0.47050035", "0.469839", "0.46980876", "0.46914327", "0.4684195", "0.46829358", "0.4682884", "0.4682884", "0.46783447", "0.46752554", "0.4669865", "0.46603802", "0.46603802", "0.46603802", "0.46603802", "0.46599272", "0.46565238", "0.46496925", "0.46494478", "0.46402147", "0.4636699", "0.46279266", "0.46144575", "0.46111542", "0.460762", "0.4599648", "0.45967728", "0.45955402", "0.45955402", "0.45935085", "0.45922306", "0.45907596", "0.45804536", "0.45766804", "0.4575197", "0.4575197", "0.4575197", "0.4575197", "0.45698", "0.4566701", "0.45650533", "0.45649233", "0.456373", "0.456373", "0.45596147", "0.45471212", "0.45462176", "0.4536743", "0.45303234", "0.45258224", "0.45252097", "0.45223004", "0.45213264", "0.45202088" ]
0.0
-1
Keep a local ProcessingJob record of this active CloudCrowd Job. Use record_job
def record_job(job_json) job = JSON.parse(job_json) processing_jobs.create!( :account_id => account_id, :cloud_crowd_id => job['id'], :title => title, :remote_job => job ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def queue\n # If a Document is associated with this ProcessingJob, determine\n # whether the Document is available to be worked on, and if it's not\n # use ActiveRecord's error system to indicate it's unavailability.\n #if document and document.has_running_jobs?\n # errors.add(:document, \"This document is already being processed\") and (return false)\n #\n # # in future we'll actually lock the document\n # # Lock the document & contact CloudCrowd to start the job\n # #document.update :status => UNAVAILABLE\n #end\n \n begin\n # Note the job id once CloudCrowd has recorded the job.\n @response = RestClient.post(ProcessingJob.endpoint, {:job => CloudCrowdSerializer.new(self).to_json})\n @remote_job = JSON.parse @response.body\n self.cloud_crowd_id = @remote_job['id']\n\n # We've collected all the info we need, so\n save # it and retain the lock on the document.\n rescue Errno::ECONNREFUSED, RestClient::Exception => error\n LifecycleMailer.exception_notification(error).deliver_now\n # In the event of an error while communicating with CloudCrowd, unlock the document.\n self.update_attributes :complete => true\n #document.update :status => AVAILABLE\n raise error\n end\n end", "def set_job\n @job = Job.find(params[:id])\n if @job.processing? && S3Store.read(S3Store::OUTPUT_BUCKET, \"#{@job.model_path}.out\")\n @job.solution_path = \"#{@job.model_path}.out\"\n @job.finished!\n @job.save\n end\n @job\n end", "def processing!\n self.sub_state = :processing\n save!\n end", "def enqueue\n # We need to save before passing to perform_later b/c perform_later will need our ID.\n # For this reason, the job_id col can't have a null constraint.\n save! unless persisted?\n job = job_class.constantize.perform_later(self, **job_params)\n update!(job_id: job.job_id, provider_job_id: job.provider_job_id)\n end", "def batch_job\n @job = Job.new\n session[:batch_job] = true\n end", "def process\n save_as(:processed)\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 process\n # self.update_attributes(state: 'processing')\n interactor = \"::#{self.handler.class.name}::#{self.action_name.camelcase}\".constantize\n context = interactor.call({\n product_instance: self.product_instance,\n handler: self.handler,\n job: self,\n })\n if context.failure?\n self.error_messages ||= []\n self.error_messages << context.errors if context.errors.present?\n self.save\n end\n context\n end", "def process_job job\n begin\n log.info \"Performing job #{job.id}\"\n jo = job.job_object\n jo.log = log\n jo.perform\n log.info \"Job #{job.id} completed\"\n job.complete\n Model::Worker.increment(id, {:'stats.done' => 1})\n rescue Exception => e\n log.error \"Job #{job.id} failed\"\n log.error e\n job.fail e\n Model::Worker.increment(id, {:'stats.failed' => 1})\n p e\n end\n end", "def prepare_job\n user = Access::Validate.user(creator)\n\n Rails.logger.info 'AnalysisJob::prepare_job: Begin.'\n\n # TODO: This may need to be an async operation itself depending on how fast it runs\n\n # counters\n options = {\n count: 0,\n duration_seconds_sum: 0,\n data_length_bytes_sum: 0,\n queued_count: 0,\n failed_count: 0,\n results: [],\n analysis_job: self\n }\n\n self.started_at = Time.zone.now\n save!\n\n # query associated saved_search to get audio_recordings\n query = saved_search.audio_recordings_extract(user)\n\n options = query\n .find_in_batches(batch_size: AnalysisJob.batch_size)\n .reduce(options, &method(:prepare_analysis_job_item))\n\n # don't update progress - resque jobs may already be processing or completed\n # the resque jobs can do the updating\n\n self.overall_count = options[:count]\n self.overall_duration_seconds = options[:duration_seconds_sum]\n self.overall_data_length_bytes = options[:data_length_bytes_sum]\n save!\n\n Rails.logger.info \"AnalysisJob::prepare_job: Complete. Queued: #{options[:queued_count]}\"\n end", "def enqueue(job)\n @jobs ||= {}\n @jobs[job.key] = {}\n\n self.save\n end", "def retain!\n if changed?\n store_job!\n self.retained = true\n end\n end", "def perform\n self.status = STATUS_DONE\n self.save\n job.update_status\n end", "def do_job(job)\n job['run_at'] = Time.now\n job['status'] = 'in progress'\n job['attempt'] += 1\n storage.save(job) do |job|\n begin\n args = job['args'].merge(JR.config[:merge_job_itself_to_args] ? {:job_itself => job.dup} : {})\n job.succeed(args)\n job['args'] = args\n job_completed(job)\n rescue CancelJob\n cancel_job(job)\n rescue Exception => e\n rescue_job(e, job)\n end\n end\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 save\n self.class.store(job_id, data, expire_at)\n self\n end", "def job \n @job\n end", "def load_job_submit\n location = Location.find_by_location_barcode(self.pdt_screen_def.get_input_control_value(\"location\"))\n self.set_temp_record(:location, location)\n if !location\n result_screen = PDTTransaction.build_msg_screen_definition(\"location does not exist\",nil,nil,nil)\n return result_screen\n end\n\n if !location.current_job_reference_id\n result_screen = PDTTransaction.build_msg_screen_definition(\"job not created , create new job\",nil,nil,nil)\n return result_screen\n end\n job = Job.find_by_id(location.current_job_reference_id)\n \n if !job\n result_screen = PDTTransaction.build_msg_screen_definition(\"job not created , create new job\",nil,nil,nil)\n return result_screen\n end\n\n if job.job_type_code.upcase != \"RECOOLING\"\n result_screen = PDTTransaction.build_msg_screen_definition(\"this is not a recooling job\",nil,nil,nil)\n return result_screen\n end\n\n if job.current_job_status.upcase != \"JOB_CREATED\"\n result_screen = PDTTransaction.build_msg_screen_definition(\"job[\" + job.job_number + \"] status must be 'created'\",nil,nil,nil)\n return result_screen\n end\n\n pallet_probes = PalletProbe.find_all_by_job_id(job.id)\n if (pallet_probes.length() == 0)\n error = [\"NO PROBES ALLOCATED\"]\n result_screen = PDTTransaction.build_msg_screen_definition(nil, nil, nil, error)\n return result_screen\n end\n\n ActiveRecord::Base.transaction do\n job.update_attribute(:current_job_status, \"JOB_LOADED\")\n\n self.set_transaction_complete_flag\n end\n\n self.set_transaction_complete_flag\n result_screen = PDTTransaction.build_msg_screen_definition(\"job loaded succesfully\",nil,nil,nil)\n return result_screen\n end", "def job\n @job\n end", "def job\n @job\n end", "def create_job_record(job_id)\n if @dbh[:progress_bars].filter(:id => job_id).first\n @dbh[:progress_bars].filter(:id => job_id).\n update(:progress_text => 'queued...', \n :progress_percent => 0,\n :job_start => Time.now,\n :last_updated => Time.now,\n :job_finish => nil)\n else\n @dbh[:progress_bars].\n insert(:id => job_id, \n :progress_text => 'queued...', \n :job_start => Time.now, \n :last_updated => Time.now)\n end\n end", "def process_new\n # each time a job is run then then a note is made that the owning user\n # has run a job. This is so we can get a count of jobs even if the user\n # deletes them\n user = User.find_by_email(self.email)\n if user.runs[\"#{self.type}\"].blank?\n user.runs[\"#{self.type}\"] = 1\n else\n user.runs[\"#{self.type}\"] += 1\n end\n user.save\n\n # get the input file, if it has not already been loaded\n begin\n if self.infile.nil? and !self.inputurl.nil?\n self.get_infile unless (self.type == 'durden' or self.type == 'identkey')\n end\n rescue\n self.jobfail(\"Could not get input file\",\"could not get input file\")\n return\n end\n\n # before processing the job, write a brief summary to the log of this job. It\n # should be csv: type,user,id,date\n logfile = \"#{Vibrant::Application.config.dropbox}/oboe_log_#{Rails.env}.txt\"\n begin\n open(logfile, 'a') do |f|\n f.puts \"#{self.type},#{self.email},#{self.id},#{self.created_at}\"\n end\n rescue\n Rails.logger.error(\"Could not write to logfile!\")\n end\n \n # having got the file, we can now commence the processing\n begin\n self.send(\"process_new_#{self.type}\")\n rescue\n self.update_attributes(:status =>'not yet available')\n end\n end", "def before job=nil\n processing!\n end", "def prepare_job\n if @job_condition\n @job = Job.new\n @job_index = @job_index\n parse_values(\"JOB\", @job)\n @job.guid_number= parse(\"guid_number\")\n @job = update_job @job\n @jobs << @job\n end\n end", "def resume_job!(job, data)\n job.save! do\n Burstflow::Worker.perform_later(workflow.id, job.id, data)\n end\n end", "def job\n @job\n end", "def call\n return nil unless request.job?\n return nil unless layer_finder.queue\n return nil unless layer_finder.job\n\n context.slow_job_policy.stored!(request)\n\n # record the change in memory usage\n mem_delta = ScoutApm::Instruments::Process::ProcessMemory.new(context).rss_to_mb(request.capture_mem_delta!)\n\n timing_metrics, allocation_metrics = create_metrics\n\n unless ScoutApm::Instruments::Allocations::ENABLED\n allocation_metrics = {}\n end\n\n SlowJobRecord.new(\n context,\n queue_layer.name,\n job_layer.name,\n root_layer.stop_time,\n job_layer.total_call_time,\n job_layer.total_exclusive_time,\n request.context,\n timing_metrics,\n allocation_metrics,\n mem_delta,\n job_layer.total_allocations,\n score,\n limited?,\n span_trace\n )\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 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 process\n save_as(:processing)\n perform_checks\n initiate_delivery\n capture_payment\n save_as(:processed)\n end", "def processed!\n Resque::Stat << \"processed\"\n Resque::Stat << \"processed:#{self}\"\n Resque::Stat << \"processed_#{job.queue}\"\n end", "def processed!\n Resque::Stat << \"processed\"\n Resque::Stat << \"processed:#{self}\"\n Resque::Stat << \"processed_#{job['queue']}\"\n end", "def work\n if job = lock_job\n QC.log_yield(:at => \"work\", :job => job[:id]) do\n process(job)\n end\n end\n end", "def to_job\n super.tap do |job|\n if commit_log.status == PhraseStatus::PUSHED\n job.set_delay(random_delay)\n job.set_queue('finalize')\n end\n end\n end", "def enqueue(job_id)\n create_job_record(job_id)\n BEANSTALK_QUEUE.yput(:job_id => job_id)\n @last_queried[job_id] = Time.now\n end", "def enqueue!\n return nil unless persisted?\n \"#{job_type.camelize}Job\".constantize.perform_later(self)\n end", "def job # this is a getter\n @job\n end", "def later(pathname)\n if klass = job_class\n logger.measure_info \"Enqueued: #{name}, Job class: #{job_class_name}\" do\n job = klass.new(properties)\n upload_file(job, pathname)\n job.save!\n job\n end\n else\n raise(ArgumentError, \"Cannot instantiate a class for: #{job_class_name.inspect}\")\n end\n end", "def processing\n result = RegisterCheckerApi.job_status(job_name, job_correlation_id)\n return if result == 'RUNNING'\n\n if result == 'SUCCESS'\n session[:job] = nil\n flash[:success] = I18n.t('database_updated')\n redirect_to authenticated_root_path\n else\n redirect_to authenticated_root_path, alert: 'Uploaded file is not valid'\n end\n end", "def processing\n jobs_index(Job.processing)\n end", "def current_job\n return @job_current\n end", "def save\n # if job is invalid return false\n return false unless valid?\n\n # update next_enqueue_timestamp\n @next_enqueue_timestamp = calculate_next_enqueue_time(Time.now.utc).to_i\n\n Sidekiq.redis do |conn|\n # add to set of all jobs\n conn.sadd(self.class.jobs_key, redis_key)\n\n # add informations for this job!\n conn.hmset(redis_key, *hash_to_redis(to_hash))\n end\n\n logger.info { \"CRON JOB: add job with name: #{@name}\" }\n end", "def success job=nil\n # ...could have gone error-free because errors were reported only in the record\n # NB: This is a pretty crude report. For more specific info, the model should throw the error\n # with a proper report, which will then get recorded in errors[:base]\n if relaunch?\n raise Exception, self.errors.full_messages # Make sure DJ gets the memo\n end\n self.status = (errors.present? ? :bad : :good) if processing? # ...thus allowing others to set the status\n self.dj = nil if good?\n if persisted?\n if changed? # && !bad? # By this point, any error state should be part of the record\n msgs = errors.messages.clone\n save\n msgs.each { |type, errs| errs.each { |err| errors.add type, err } }\n else\n update_attribute :dj_id, dj&.id\n end\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 new_job\n j = self.class.new\n j.save\n end", "def job=(job)\n @job = job\n end", "def job= (work)\n @job = work\n end", "def create\n attrs = to_hash_without_nils\n .except(:job)\n .merge({ job_id: job.id })\n copy self.class.create(attrs)\n true\n end", "def prepare_job_and_associations\r\n temp_job = @temp_job\r\n payer_group = '--'\r\n @original_job = Job.includes(:images_for_jobs).find(temp_job.job_id)\r\n @micr_record, payer_group = get_micr_and_payer_group if @original_job.micr_applicable?\r\n\r\n job = prepare_job\r\n job.payer_group = payer_group\r\n job.is_correspondence = @original_job.is_correspondence\r\n\r\n check_information = prepare_check\r\n job.check_informations << check_information\r\n check_information.micr_line_information = @micr_record if @micr_record\r\n\r\n Batch.where(:id => @original_job.batch_id).update_all(:associated_entity_updated_at => Time.now)\r\n job\r\n end", "def create\n job = Job.new\n job.job_name = params[:job_name]\n job.description = params[:description]\n job.quote = params[:quote].to_f\n job.running_total = 0\n \n if job.save\n jobConnect = JobToUser.new\n jobConnect.job_id = job.id\n jobConnect.user_id = current_user.id\n jobConnect.save\n redirect_to(\"/services/show\", :notice => 'Job was successfully created.')\n else\n redirect_to(\"/services/show\", :notice => 'Job Failed to Save. Try Again Later.')\n end\n end", "def queue_job; end", "def create\n @recording = Recording.new(recording_params)\n @recording.update_attribute(:is_recorded, false)\n\n respond_to do |format|\n if @recording.save\n format.html { redirect_to @recording, notice: 'Recording was successfully created.' }\n format.json { render :show, status: :created, location: @recording }\n job_id = RecordingWorker.perform_at(@recording.start_datetime, @recording.id)\n @recording.update_attribute(:job_id, job_id)\n else\n format.html { render :new }\n format.json { render json: @recording.errors, status: :unprocessable_entity }\n end\n end\n end", "def write(record)\n @worker.enqueue record\n end", "def submit_job\n unless inputfile_identifier.nil?\n set_version if version.nil?\n submit_script = generate_submit_script(input_deck: inputfile_identifier)\n\n if !submit_script.nil?\n Dir.chdir(jobdir) {\n cmd = \"qsub #{prefix}.sh\"\n self.pid = `#{cmd}`\n }\n end\n end\n\n # If successful, set the status to \"Submitted\" and save to database.\n unless pid.nil? || pid.empty?\n self.pid = pid.strip\n self.submitted_at = Time.new.ctime\n set_status! :b\n else\n self.pid = nil\n self.submitted_at = '---'\n set_status! :f\n end\n end", "def submit_job\n unless inputfile_identifier.nil?\n set_version if version.nil?\n submit_script = generate_submit_script(input_deck: inputfile_identifier)\n\n if !submit_script.nil?\n Dir.chdir(jobdir) {\n cmd = \"qsub #{prefix}.sh\"\n self.pid = `#{cmd}`\n }\n end\n end\n\n # If successful, set the status to \"Submitted\" and save to database.\n unless pid.nil? || pid.empty?\n self.pid = pid.strip\n self.submitted_at = Time.new.ctime\n set_status! :b\n else\n self.pid = nil\n self.submitted_at = '---'\n set_status! :f\n end\n end", "def batch\n job && job.batch\n end", "def job=(job)\n @job = job\n end", "def save_records\n @job_condition = job_condition\n find_type\n prepare_batch\n\n if @batch\n @image_count = 1 if @job_condition\n @batch.inbound_file_information = @inbound_file_information if @inbound_file_information\n\n images = prepare_image\n images.each{|image| @batch.images_for_jobs << image}\n\n prepare_job\n @batch.jobs << @job if @job_condition\n images.each{|image| @job.images_for_jobs << image}\n\n if @job_condition\n check = prepare_cheque\n @job.check_number = '0' if check.check_amount == 0.0\n @job.check_informations << check\n @job.initial_image_name = @initial_image_name\n micr = prepare_micr\n if micr\n payer = micr.payer\n check.payer_id = micr.payer_id if micr.payer_id\n if !facility.payer_ids_to_exclude.blank?\n @job.job_status = JobStatus::EXCLUDED if payer && payer.excluded?(facility)\n elsif !facility.payer_ids_to_include.blank?\n @job.job_status = JobStatus::EXCLUDED if !facility.included_payers.include?(payer)\n end\n micr.check_informations << check\n end\n end\n \n if @batch.save\n if @job.save\n images.each do |image|\n if image.save\n InputBatch.log.debug \"Image #{image.filename} id #{image.id} batch id #{image.batch.id} job id #{image.jobs.first.id} successfully loaded\"\n puts \"Image #{image.filename} successfully loaded\"\n end\n end\n\n total_number_of_images = number_of_pages(@job)\n check_number = check.check_number if !check.blank?\n estimated_eob = @job.estimated_no_of_eobs(total_number_of_images, micr, check_number)\n @job.update_attributes(:estimated_eob => estimated_eob, :pages_to => total_number_of_images)\n\n if @job_condition and check.save\n InputBatch.log.debug \"Check id #{check.id}, check_number #{check.check_number}, Job id #{check.job.id}, batch id #{check.job.batch.id} successfully loaded\"\n if micr and micr.save\n InputBatch.log.debug \"Check #{check.id} associated to micr #{check.micr_line_information.id}\"\n @job.save_payer_group(micr)\n end\n end\n end\n end\n end\n end", "def queue\n pending_duplicate_job || Delayed::Job.enqueue(self)\n end", "def set_running_job\n @running_job = RunningJob.find(params[:id])\n end", "def save_job_record_and_get_job_id(start_time, command_and_option, fqdn)\n return 0 if $debug\n\n job_id = @connector.con[:jobs].insert(start_time: start_time, command_and_option: command_and_option, base_fqdn: fqdn)\n @connector.disconnect\n job_id\n end", "def process(_block = nil)\n EXEL::Job.run(@context[:job], @context)\n end", "def save_records\n @new_batch_flag = 0\n (@parser == 'wellsfargo' && type == \"CORRESP\") ? prepare_wellfargo_corresp_batch : prepare_batch\n if @bat\n if @inbound_file_information\n @bat.inbound_file_information = @inbound_file_information\n @bat.arrival_time = arr_time = @inbound_file_information.arrival_time\n set_batch_time @bat, arr_time\n end\n @job_condition = job_condition\n if @job_condition\n @img_count = 1\n do_bank_logics if type == 'PAYMENT' #Applying bank specific logic\n end\n images = call_parser_specific_method \"prepare_image\"\n images.each{|image| @bat.images_for_jobs << image}\n\n prepare_job\n @bat.jobs << @job if @job_condition\n images.each{|image| @job.images_for_jobs << image}\n @job.initial_image_name = @initial_image_name\n if @job_condition\n check = prepare_cheque\n if type == 'PAYMENT'\n micr = prepare_micr\n if micr\n payer = micr.payer\n check.payer_id = micr.payer_id if micr.payer_id\n if !facility.payer_ids_to_exclude.blank?\n @job.job_status = JobStatus::EXCLUDED if payer && payer.excluded?(facility)\n elsif !facility.payer_ids_to_include.blank?\n @job.job_status = JobStatus::EXCLUDED if !facility.included_payers.include?(payer)\n end\n micr.check_informations << check\n end\n end\n @job.check_informations << check\n end\n end\n\n if @bat.save\n @bat.update_attributes(:status => BatchStatus::NEW)\n if @job.save\n images.each do |image|\n# if image.save\n if image.image_file_name.upcase == @check_image.to_s.upcase\n save_image_types(\"CHK\",image)\n elsif ((image.image_file_name.upcase == @envelop_image.to_s.upcase) and (@job.job_status != JobStatus::EXCLUDED))\n save_image_types(\"ENV\",image)\n elsif ((@job.job_status == JobStatus::EXCLUDED) and (image.image_file_name.upcase != @check_image.to_s.upcase))\n save_image_types(\"OTH\",image)\n end\n total_number_of_images = number_of_pages(@job)\n check_number = check.check_number if !check.blank?\n estimated_eob = @job.estimated_no_of_eobs(total_number_of_images, micr, check_number)\n @job.update_attributes(:estimated_eob => estimated_eob, :pages_to => total_number_of_images)\n \n InputBatch::Log.status_log.info \"Image #{image.image_file_name}\n id #{image.id} batch id #{image.batch.id} job id #{image.jobs.first.id}\n successfully loaded\"\n puts \"Image #{image.image_file_name} successfully loaded\" if !image.size.blank?\n# else\n# raise \"Error on line #{@row_index} : Cannot load image #{image.image_file_name}\"\n# end\n end\n if @job_condition and check.save\n InputBatch::Log.status_log.info \"Check id #{check.id}, check_number\n #{check.check_number}, Job id #{check.job.id}, batch id #{check.job.batch.id}\n successfully loaded\"\n if micr and micr.save\n InputBatch::Log.status_log.info \"Check #{check.id} associated to micr\n #{check.micr_line_information.id}\"\n @job.save_payer_group(micr)\n end\n\n end\n else\n raise \"Error on line #{@row_index} : Cannot save job for batch #{@bat.batchid}\"\n end\n else\n raise \"Error on line #{@row_index} : Cannot save batch\"\n end\n \"#{@bat.date.strftime(\"%Y%m%d\")}_#{@bat.batchid}_SUPPLEMENTAL_OUTPUT\" rescue nil\n end", "def create\n @pending_job = PendingJob.new(pending_job_params)\n current_stage = 'E'\n @pending_job.time_queued = Time.now\n @pending_job.current_stage = current_stage\n @pending_job.current_stage_started = Time.now\n\n respond_to do |format|\n if @pending_job.save\n EFinishJob.perform_in(1.minutes, @pending_job.id, @pending_job.course, @pending_job.assignment, @pending_job.username)\n format.html { redirect_to @pending_job, notice: 'Pending job was successfully created.' }\n format.json { render :show, status: :created, location: @pending_job }\n else\n format.html { render :new }\n format.json { render json: @pending_job.errors, status: :unprocessable_entity }\n end\n end\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 to_job\n job = Patriot::JobStore::Job.new(self.job_id)\n job.read_command(self)\n return job\n end", "def process_job(instance, attachment_name)\n instance.send(attachment_name).job_is_processing = true\n yield\n instance.send(attachment_name).job_is_processing = false\n end", "def ignored(job)\n @last_job_id = job.job_id\n end", "def create\n @job = Job.new(job_params.merge({\n owner_id: current_user_id,\n owner_name: current_user_name,\n user_id: current_user_db_record.id,\n remote: job_params[:remote]\n }))\n\n respond_to do |format|\n if @job.save\n format.html { redirect_to @job, notice: 'Job was successfully created.' }\n format.json { render :show, status: :created, location: @job }\n else\n format.html { render :new }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end", "def call(job)\n @processed_job_ids << job.job_id\n block.call(job)\n end", "def save_processed_data\n attachment.update(processed_data: json_parser.final_hash)\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(active_job)\n lambda do |object|\n active_job.perform_later(object.id)\n end\n end", "def submit_job\n input_deck = generate_input_deck\n # results_script = generate_results_script\n\n if !input_deck.nil? #&& !results_script.nil?\n submit_script = generate_submit_script(input_deck: input_deck)\n # submit_script = generate_submit_script(input_deck: input_deck,\n # results_script: results_script)\n\n if !submit_script.nil?\n Dir.chdir(jobdir) {\n cmd = \"qsub #{prefix}.sh\"\n self.pid = `#{cmd}`\n }\n end\n end\n\n # If successful, set the status to \"Submitted\" and save to database.\n unless pid.nil? || pid.empty?\n self.pid = pid.strip\n # self.submitted_at = Time.new.ctime\n set_status! :b\n else\n self.pid = nil\n # self.submitted_at = '---'\n set_status! :f\n end\n end", "def update_job job\n job.check_number = '0' if job.check_number.blank?\n job.pages_from = 1\n job.payer = Payer.find_by_payer(\"No Payer\")\n return job\n end", "def update_job job\n job.check_number = '0' if job.check_number.blank?\n job.pages_from = 1\n job.payer = Payer.find_by_payer(\"No Payer\")\n return job\n end", "def << job_data\n add_job(job_data)\n end", "def record_event_job\n WebhookJob::RecordEvent.perform_now({\n client_id: @user_kyc_detail.client_id,\n event_source: GlobalConstant::Event.web_source,\n event_name: GlobalConstant::Event.kyc_reopen_name,\n event_data: {\n user_kyc_detail: @user_kyc_detail.get_hash,\n admin: @user_kyc_detail.get_last_acted_admin_hash\n },\n event_timestamp: Time.now.to_i\n })\n\n end", "def job\n return nil if self.job_id.nil?\n Delayed::Job.find(self.job_id)\n end", "def create_upload_process_job(upload, priority = 0)\n if upload\n job = UploadProcessorJob.new(upload.object_key)\n fire_background_job(job, priority)\n end\n end", "def enqueue_job\n BgJob.enqueue(\n WebhookJob::RecordEvent,\n {\n client_id: @user_kyc_detail.client_id,\n event_source: GlobalConstant::Event.web_source,\n event_name: GlobalConstant::Event.update_ethereum_address_name,\n event_data: {\n user_kyc_detail: @user_kyc_detail.get_hash,\n admin: @admin.get_hash\n },\n event_timestamp: Time.now.to_i\n }\n )\n\n end", "def reprocess!\n self.file = self.storage.retrieve(self.path)\n process\n end", "def final_update_record(record,jobacct)\n # do nothing\n end", "def sync_job!\n return if @job.terminal?\n\n if @job.from_submission?\n Job.sync_challenge_job!(@job.id)\n else\n Job.sync_job!(@context, @job.id)\n end\n end", "def record(&blk)\n start_recording\n blk.call\n ensure\n stop_recording\n end", "def recordOn()\n @record = true ;\n end", "def process_in_background(column, worker=::CarrierWave::Workers::ProcessAsset)\n super\n (@@_carrierwave_process_in_background ||= {})[:\"#{column}\"] = worker\n end", "def job\n JenkinsApi::Client::Job.new(self)\n end", "def job\n JenkinsApi::Client::Job.new(self)\n end", "def finish_job!(job)\n job.finish!\n job.save! do\n analyze_workflow_state(job)\n end\n end", "def set_launched_job\n @launched_job = LaunchedJob.find(params[:id])\n end", "def update(job)\n mass_assign(job)\n self\n end", "def job_class\n SingleInstanceQueueJob\n end", "def new\n @job = Job.new\n end", "def create\n @job = Job.new(params[:job])\n\n respond_to do |format|\n if @job.save\n # after @job.save, initially the job is in a \"pending\" state.\n @job.initialize_job_parameters \n @job.nextstep! # pending - > launch_pending\n logger.debug( 'initiating background cluster launch...' ) \n # job state is now \"launching_instances\"... \n Delayed::Job.enqueue ClusterLaunchJob.new(@job) \n flash[:notice] = 'Job was successfully submitted.' \n\n format.html { redirect_to(jobs_url) }\n format.xml { render :xml => @job, :status => :created, :location => @job }\n format.json { render :json => @job, :status => :created, :location => @job } \n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @job.errors, :status => :unprocessable_entity }\n format.json { render :json => @job.errors, :status => :unprocessable_entity }\n end\n end\n end", "def finish!\n database = Concierge::OptionalDatabaseAccess.new(SyncProcessRepository)\n\n sync_record.stats[:properties_processed] = processed\n sync_record.stats[:available_records] = counters.available\n sync_record.stats[:unavailable_records] = counters.unavailable\n\n sync_record.finished_at = Time.now\n\n database.create(sync_record)\n true\n end", "def perform(record)\n run(record, false)\n end", "def processed!\n self.update_attribute :processed, true\n end", "def after_perform_increment_jobs_processed(*)\n @registry.hincrby key, 'jobs_processed', 1\n end", "def perform_now\n raise(::Mongoid::Errors::Validations, self) unless valid?\n\n worker = RocketJob::Worker.new(inline: true)\n start if may_start?\n # Re-Raise exceptions\n rocket_job_work(worker, true) if running?\n result\n end" ]
[ "0.6781324", "0.6015498", "0.59980714", "0.59472966", "0.5873365", "0.5867775", "0.5859998", "0.584067", "0.57934386", "0.57781696", "0.5767818", "0.57500464", "0.57348454", "0.57296985", "0.57122576", "0.5711334", "0.5699153", "0.56836224", "0.56673217", "0.56673217", "0.56560665", "0.56554693", "0.5634189", "0.5599811", "0.5586324", "0.5582496", "0.55778456", "0.5571782", "0.5566999", "0.5522939", "0.5515833", "0.5511122", "0.55067", "0.54952276", "0.5494595", "0.5478893", "0.54721665", "0.5467006", "0.5461197", "0.5455622", "0.54227126", "0.5416739", "0.53900653", "0.5384642", "0.5375631", "0.5365315", "0.5326558", "0.5304812", "0.52925533", "0.5286996", "0.5265391", "0.5265325", "0.52585477", "0.5256646", "0.5256646", "0.5255721", "0.52435523", "0.5223806", "0.52223045", "0.52186286", "0.52168024", "0.5214698", "0.52088475", "0.51961493", "0.5194026", "0.5191067", "0.5188231", "0.51693696", "0.5166742", "0.51609886", "0.51559746", "0.51514506", "0.51382935", "0.51300895", "0.51295364", "0.51295364", "0.5127792", "0.51271856", "0.51222426", "0.5094329", "0.5090232", "0.50860786", "0.508233", "0.50815487", "0.5081504", "0.5078778", "0.5069064", "0.50647724", "0.50647724", "0.50582474", "0.5055129", "0.5045615", "0.5044782", "0.5044606", "0.5035485", "0.50350857", "0.5033949", "0.5033343", "0.50315857", "0.50308245" ]
0.6681429
1
Create an identical clone of this document, in all ways (except for the ID). toggles to include various aspects of documents: include_docdata => true/false include_sections => true/false include_annotations => true/false & conditioned on if the recipient should be treated as owner include_project => true/false: copy the documents into the same projects the original doc is in.
def duplicate!(recipient=nil, options={}) Document.transaction do # Clone the document. newattrs = attributes.dup.merge({ :access => PENDING, :created_at => Time.now, :updated_at => Time.now }) newattrs.delete('id') newattrs[:account_id] = recipient.id if recipient newattrs[:organization_id] = recipient.organization.id if recipient and not newattrs[:organization_id] copy = Document.create!(newattrs.merge({:hit_count => 0, :detected_remote_url => nil})) newattrs = {:document_id => copy.id} # Clone the docdata. if docdata and options['include_docdata'] Docdata.create! document_id: copy_id, data: docdata.data.dup end # Clone the associations. associations = [entities, entity_dates, pages] associations.push sections if options['include_sections'] # Copy all notes that are visible by either the document owner or the recipient account_context = options['as_owner'] ? self.account : recipient associations.push annotations.accessible(account_context) if options['include_annotations'] # Copy the new document into all of the same projects as the old document associations.push project_memberships if options['include_project'] associations.each do |association| association.each do |model| model_attrs = model.attributes.dup.merge newattrs model_attrs.delete('id') model.class.create! model_attrs end end # Clone the assets. DC::Store::AssetStore.new.copy_assets(self, copy, self.access) # Reindex, set access. copy.index copy.set_access access copy end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clone_for_template(document)\n dup_field = self.dup\n dup_field.document = document\n dup_field\n end", "def replicate\n\n self.class.new(document, ref, source: source.dup)\n end", "def build\n if expand_document\n combine_layout\n combine_activity_metadata\n document.update! build_params\n else\n document.document_parts.delete_all\n document.update! document_params.merge(toc: template.toc, material_ids: template.toc.collect_material_ids)\n end\n end", "def new_document()\n # Work out fields to ignore - these will be auto populated by Solr\n copy_fields = []\n @config[\"schema\"][\"copy_fields\"].each do |copy_field|\n copy_fields.push( copy_field[\"dest\"] )\n end\n \n doc = {}\n @config[\"schema\"][\"fields\"].each do |key,detail|\n unless copy_fields.include?(key)\n doc[ key.to_sym ] = []\n end\n end\n return doc\n end", "def clone\n copy(false)\n end", "def soft_copy\n copy = View.from_doc(@doc.soft_copy)\n copy.scoped_as = scoped_as\n copy\n end", "def copy\n obj = self.dup\n obj.attributes = {\n :name => \"Copy of #{name}\",\n :active => false,\n :created_at => nil,\n :updated_at => nil\n }\n obj\n end", "def clone\n @clone = true\n end", "def deep_clone!\n opts = {}\n opts[:except] = [\n :current_offering_admin_phase_id, \n :complete, \n :financial_aid_approval_request_sent_at,\n :application_for_offerings_count,\n :enable_award_acceptance,\n :accepted_offering_status_id,\n :declined_offering_status_id\n ]\n opts[:include] = [\n {:pages => {:questions => [:options, :validations]}}, \n {:statuses => :emails},\n {:admin_phases => {:tasks => :extra_fields}},\n :restrictions,\n :mentor_questions,\n :mentor_types,\n :review_criterions,\n :application_review_decision_types,\n :application_interview_decision_types,\n :application_final_decision_types,\n :application_moderator_decision_types,\n :dashboard_items,\n :application_types,\n :application_categories,\n :offering_committee_member_restrictions,\n :sessions,\n :offering_award_types,\n :other_award_types,\n :location_sections\n ]\n self.clone(opts)\n end", "def clone\n self.class.new(@attributes.except(:_id).except(:versions).dup)\n end", "def copy\n project_to_clone = Project.find(params[:id])\n @project = project_to_clone.clone\n\n # FIXME add copying of project team members\n\n # date/time transformations\n convert_db_datetime_to_display\n end", "def create_document\n # rubocop:disable Lint/AmbiguousOperatorPrecedence\n if template.metadata['subject'].presence &&\n template.metadata['subject'].casecmp('ela').zero? || template.prereq?\n @document = Document.actives.find_or_initialize_by(file_id: downloader.file_id)\n else\n @document = foundational? ? find_core_document : find_fs_document\n id_field = foundational? ? :foundational_file_id : :file_id\n\n @expand_document ||= @document.present?\n\n @document[id_field] = downloader.file_id if @document.present?\n @document ||= Document.actives.find_or_initialize_by(id_field => downloader.file_id)\n end\n # rubocop:enable Lint/AmbiguousOperatorPrecedence\n end", "def clone_me(target_sv)\n target_sv.pages.create(\n self.attributes.except(\n \"created_at\",\n \"updated_at\",\n \"id\",\n \"survey_version_id\",\n \"survey_version\",\n \"clone_of_id\"\n ).merge(\"clone_of_id\" => self.id)\n )\n end", "def deep_copy(**options)\n copy = self.dup\n copy.question_id = options.fetch(:question_id, nil)\n return copy\n end", "def create\n authorize! :create, Document.new, @project\n main = @project.document_mains.create\n rev = main.revisions.create\n document = rev.versions.new(document_params(true))\n if document.save\n send_emails_helper(document)\n render json: document.attributes_for_edit\n else\n rev.destroy\n main.destroy\n render json: document.errors, status: :unprocessable_entity\n end\n end", "def replicate(organizations=nil)\n organizations ||= Organization.active\n organizations.each do |organization|\n if organization.site == site\n document = Document.new(\n attributes.slice(*(Document.attribute_names - [\"id\"]))\n )\n document.organization_id = organization.id\n document.is_default = true\n\n default_document_elements.each do |element|\n document.document_elements << DocumentElement.new(\n element.attributes.slice(*(DocumentElement.attribute_names - [\"id\"]))\n )\n end\n document.save!\n end\n end\n end", "def duplicate_document(source)\r\n dest = {}\r\n source.attribute_names.each do |attribute_name|\r\n next if attribute_name == '_id' # don't duplicate _id\r\n# if duplicate, string must be added. Useful for unique attributes\r\n add_duplicate = params['dup_fields'].to_s.match(attribute_name + ',')\r\n dest[attribute_name] = source[attribute_name]\r\n dest[attribute_name] << ' dup' if add_duplicate\r\n end\r\n# embedded documents\r\n source.embedded_relations.keys.each do |embedded_name|\r\n next if source[embedded_name].nil? # it happens\r\n dest[embedded_name] = []\r\n source[embedded_name].each do |embedded|\r\n dest[embedded_name] << duplicate_embedded(embedded)\r\n end\r\n end\r\n dest\r\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 clone() 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 create\n set_unique_id if respond_to?(:set_unique_id) # hack\n save_doc\n end", "def duplicate_document(source)\r\n params['dup_fields'] += ',' if params['dup_fields'] # for easier field matching\r\n dest = {}\r\n source.attribute_names.each do |attribute_name|\r\n next if attribute_name == '_id' # don't duplicate _id\r\n\r\n # if duplicate, string dup is added. For unique fields\r\n add_duplicate = params['dup_fields'].to_s.match(attribute_name + ',')\r\n dest[attribute_name] = source[attribute_name]\r\n dest[attribute_name] << ' dup' if add_duplicate\r\n end\r\n # embedded documents\r\n source.embedded_relations.keys.each do |embedded_name|\r\n next if source[embedded_name].nil? # it happens\r\n\r\n dest[embedded_name] = []\r\n source[embedded_name].each do |embedded|\r\n dest[embedded_name] << duplicate_embedded(embedded)\r\n end\r\n end\r\n dest['created_at'] = Time.now if dest['created_at']\r\n dest['updated_at'] = Time.now if dest['updated_at']\r\n dest\r\nend", "def createonly()\n merge(createonly: 'true')\n end", "def create_document(file, file_type, object, comment, file_name=nil)\n if object.invoice_no.include?('/')\n file_obj=object.invoice_no.gsub('/','')\n else\n file_obj=object.invoice_no\n end\n filename = (file_name ? \"#{file_name}.#{file_type}\" : nil ) || \"InvoiceNo_#{file_obj}_#{Time.zone.now.to_i}_New.#{file_type}\"\n\n newfile=File.open(\"#{filename}\", \"w\") {|f| f.write(file) }\n\n root_file=File.open(\"#{RAILS_ROOT}/#{filename}\",'r')\n document={:name => \"Test\" ,:data=> root_file}\n document_home = {:document_attributes => document}\n document_home.merge!(:access_rights => 2, :created_by_user_id=>object.created_by_user_id,:company_id=>object.company_id,\n :mapable_id=>comment.id,:mapable_type=>'Comment', :owner_user_id=>object.owner_user_id)\n newdocument_home = comment.document_homes.new(document_home)\n newdocument = newdocument_home.documents.build(document.merge(:company_id=>object.company_id, :created_by_user_id=>object.created_by_user_id))\n newdocument_home.save\n if newdocument_home.save\n root_file.close\n File.delete(\"#{RAILS_ROOT}/#{filename}\")\n end\n end", "def clone\n super\n end", "def create\n\t\tbegin\n\t\t\traise ArgumentError, \"project id has to be specified.\" unless params[:project_id].present?\n\n\t\t\t@project = Project.editable(current_user).find_by_name(params[:project_id])\n\t\t\traise \"The project does not exist, or you are not authorized to make a change to the project.\\n\" unless @project.present?\n\n\t\t\tdoc_hash = if doc_params.present? && params[:commit].present?\n\t\t\t\tdoc_params\n\t\t\telse\n\t\t\t\ttext = if params[:text]\n\t\t\t\t\tparams[:text]\n\t\t\t\telsif request.content_type =~ /text/\n\t\t\t\t\trequest.body.read\n\t\t\t\tend\n\n\t\t\t\traise \"Could not find text.\" unless text.present?\n\n\t\t\t\t_doc = {\n\t\t\t\t\tsource: params[:source],\n\t\t\t\t\tsourcedb: params[:sourcedb] || '',\n\t\t\t\t\tsourceid: params[:sourceid],\n\t\t\t\t\tbody: text\n\t\t\t\t}\n\n\t\t\t\t_doc[:divisions] = params[:divisions] if params[:divisions].present?\n\t\t\t\t_doc[:typesettings] = params[:typesettings] if params[:typesettings].present?\n\t\t\t\t_doc\n\t\t\tend\n\n\t\t\tdoc_hash = Doc.hdoc_normalize!(doc_hash, current_user, current_user.root?)\n\t\t\tdocs_saved, messages = Doc.store_hdocs([doc_hash])\n\t\t\traise IOError, \"Could not create the document: #{messages.join(\"\\n\")}\" if messages.present?\n\n\t\t\t@doc = docs_saved.first\n\t\t\[email protected] << @project\n\t\t\texpire_fragment(\"sourcedb_counts_#{@project.name}\")\n\t\t\texpire_fragment(\"count_docs_#{@project.name}\")\n\t\t\texpire_fragment(\"count_#{@doc.sourcedb}_#{@project.name}\")\n\n\t\t\trespond_to do |format|\n\t\t\t\tformat.html { redirect_to show_project_sourcedb_sourceid_docs_path(@project.name, doc_hash[:sourcedb], doc_hash[:sourceid]), notice: t('controllers.shared.successfully_created', :model => t('activerecord.models.doc')) }\n\t\t\t\tformat.json { render json: @doc.to_hash, status: :created, location: @doc }\n\t\t\tend\n\t\trescue => e\n\t\t\trespond_to do |format|\n\t\t\t\tformat.html { redirect_to new_project_doc_path(@project.name), notice: e.message }\n\t\t\t\tformat.json { render json: {message: e.message}, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def clone_associations\n new_form = OregonDigital::Metadata::IngestFormContainer.new(\n :asset_map => @asset_map,\n :template_map => @template_map,\n :asset_class => @asset_class,\n :cloneable => true\n )\n for assoc in @form.associations.select {|assoc| assoc.clone == true}\n new_form.form.add_association(assoc) if assoc.clone\n end\n\n new_form.add_blank_groups\n\n return new_form\n end", "def clone\n @clone ||= super\n end", "def client_new_doc\n data = params\n cid = current_company.id\n @return_path = data[:return_path]\n @return_path = request.headers['HTTP_REFERER'] if @return_path.blank?\n @matter = Matter.scoped_by_company_id(cid).find(params[:id])\n @document_home = DocumentHome.new\n @document = @document_home.documents.build\n @mapable_id = data[:id]\n @mapable_type = 'Matter'\n @task= MatterTask.scoped_by_company_id(cid).find(data[:task_id] ) if data[:task_id]\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @document_home }\n end\n end", "def changes_from_clone\n changes_from_document(clone_source, true)\n end", "def clone\n dup\n end", "def attribs_not_to_replicate(replication)\n # start with the initial, constant set\n dont_copy = ATTRIBS_NOT_TO_COPY\n\n # add the ones that are specified explicitly in the replicable options\n dont_copy += replicable_opts(:dont_copy)\n\n # don't copy foreign key field of belongs_to associations\n replicable_opts(:child_assocs).each do |assoc|\n refl = self.class.reflect_on_association(assoc)\n dont_copy << refl.foreign_key if refl.macro == :belongs_to\n end\n\n # don't copy foreign key field of parent's has_* association, if applicable\n if replicable_opts(:parent_assoc)\n dont_copy << replicable_opts(:parent_assoc).to_s + '_id'\n end\n\n # copy user-modifiable attributes IF:\n # 1. dest obj is being created OR\n # 2. dest obj attrib value has NOT deviated from std\n # therefore, if either of the above conditions is met, we should NOT add the attrib to the dont_copy list\n # in all other cases, we should add it to the dont_copy list\n replicable_opts(:user_modifiable).each do |attrib|\n\n # if we are creating, immediately we know that nothing gets added to dont_copy\n # otherwise, we need to check if value has deviated in dest obj\n unless replication.creating?\n\n # if the src attrib is or was a hash, it gets special treatment\n if send(attrib).is_a?(Hash) || send(\"#{attrib}_was\").is_a?(Hash)\n\n # get refs, ensuring no nils\n src_hash = send(attrib) || {}\n src_hash_was = send(\"#{attrib}_was\") || {}\n dest_hash = replication.dest_obj.send(attrib) || {}\n\n # loop over each key in src\n src_hash_was.each_key do |k|\n # don't copy this particular key if deviated\n dont_copy << \"#{attrib}.#{k}\" if src_hash_was[k] != dest_hash[k]\n end\n else\n # figure out if the attribute has deviated\n deviated = send(\"#{attrib}_was\") != replication.dest_obj.send(attrib)\n\n # don't copy if value has deviated\n dont_copy << attrib if deviated\n end\n end\n end\n\n dont_copy\n end", "def clone\n self.copy\n end", "def clone\n self.copy\n end", "def clone\n end", "def clone\n end", "def clone\n end", "def clone\n end", "def add_project_doc(project, document)\n document.project_id = project.id\n end", "def generate_copy!(org)\n raise _('generate_copy! requires an organisation target') unless org.is_a?(Org) # Assume customizing_org is persisted\n template = deep_copy(\n attributes: {\n version: 0,\n published: false,\n family_id: new_family_id,\n org: org,\n is_default: false,\n title: _('Copy of %{template}') % { template: self.title }\n }, modifiable: true, save: true)\n return template\n end", "def dup\n DocumentMapper::Base.new(self)\n end", "def deep_copy(attributes: {}, **options)\n copy = self.dup\n if attributes.respond_to?(:each_pair)\n attributes.each_pair{ |attribute, value| copy.send(\"#{attribute}=\".to_sym, value) if copy.respond_to?(\"#{attribute}=\".to_sym) }\n end\n copy.save! if options.fetch(:save, false)\n options[:template_id] = copy.id\n self.phases.each{ |phase| copy.phases << phase.deep_copy(options) }\n return copy\n end", "def build_complex_attributes(document)\n document.identifier = identifier\n document.description = description\n document.access_rights = geo_concern.solr_document.visibility\n end", "def to_project\n\t\tp = Rubyfocus::Project.new(nil)\n\t\tinstance_variables.each do |ivar|\n\t\t\tnext if ivar == :\"@document\"\n\t\t\tsetter = ivar.to_s.gsub(/^@/,\"\") + \"=\"\n\t\t\tp.send(setter, self.instance_variable_get(ivar))\tif p.respond_to?(setter)\n\t\tend\n\t\tp\n\tend", "def clone; end", "def clone; end", "def clone; end", "def set_document\n @document = Document.find(params[:id])\n @project = @document.project\n exit_if_not_member and return false\n end", "def copy\n projectid = params[:project_id]\n subprojectid = params[:subproject_id]\n versiontocopy = params[:versiontocopy]\n subsubproject_to_copy = Subsubproject.find(versiontocopy)\n new_subsubproject = Subsubproject.find(versiontocopy).dup\n new_subsubproject.name = new_subsubproject.name + ' (neu)'\n new_subsubproject.master = false\n new_subsubproject.save!\n\n # copy/duplicate offertpositions\n subsubproject_to_copy.offertpositions.each do |offertposition|\n new_offertposition = offertposition.dup\n new_offertposition.subsubproject_id = new_subsubproject.id\n new_offertposition.save!\n end\n\n # copy/duplicate grobengineerings\n grobengineerings_to_copy = Grobengineering.where(:subsubproject_id => versiontocopy).order(:id)\n grobengineerings_to_copy.each do |grobengineering|\n new_record = grobengineering.dup\n new_record.subsubproject_id = new_subsubproject.id\n offertposition = Offertposition.where(:subsubproject_id => new_subsubproject.id, :name => grobengineering.offertposition.name).first\n if !offertposition.nil?\n new_record.offertposition_id = offertposition.id\n end\n new_record.save!\n end\n\n redirect_to project_subproject_path(projectid, subprojectid),\n :notice => 'Version erfolgreich kopiert'\n\n end", "def collapse_document(doc); end", "def clone\n newobj = Marshal.load(Marshal.dump(self))\n props = newobj.instance_variable_get(:@props)\n props[:id] = Engine.instance.db.getid\n put_object(newobj)\n newobj\n rescue\n log.error \"Clone failed\"\n nil\n end", "def clone\n a = dup\n a.verbatim_label = [verbatim_label, \"[CLONED FROM #{id}\", \"at #{Time.now}]\"].compact.join(' ')\n\n roles.each do |r|\n a.collector_roles.build(person: r.person, position: r.position)\n end\n\n if georeferences.load.any?\n not_georeference_attributes = %w{created_at updated_at project_id updated_by_id created_by_id collecting_event_id id position}\n georeferences.each do |g|\n c = g.dup.attributes.select{|c| !not_georeference_attributes.include?(c) }\n a.georeferences.build(c)\n end\n end\n\n a.save\n a\n end", "def copy\n new_cfn_model = CfnModel.new\n @conditions.each do |k,v|\n new_cfn_model.conditions[k] = v\n end\n @globals.each do |k,v|\n new_cfn_model.globals[k] = v\n end\n @parameters.each do |k,v|\n new_cfn_model.parameters[k] = v\n end\n @resources.each do |k, v|\n new_cfn_model.resources[k] = v\n end\n @mappings.each do |k, v|\n new_cfn_model.mappings[k] = v\n end\n new_cfn_model.raw_model = @raw_model.dup unless @raw_model.nil?\n new_cfn_model\n end", "def create_copy\n #add page at end of survey\n new_page_num = self.survey_version.pages.size + 1\n page_attribs = self.attributes.merge(:page_number => new_page_num)\n page_attribs.delete(\"id\")\n page_attribs.delete(\"next_page_id\")\n new_page = Page.create!(page_attribs)\n\n #Copy current page assetables\n self.survey_elements.each do |se|\n se.copy_to_page(new_page)\n end\n\n new_page\n end", "def create\n @document = @instruction.documents.build(document_params)\n authorize @document\n disable_primary if @document.primary\n respond_to do |format|\n if @document.save\n format.html { redirect_to @instruction, notice: t('documents.create.success') }\n format.json { render :show, status: :created, location: @document }\n else\n format.html { render :new }\n format.json { render json: @document.errors, status: :unprocessable_entity }\n end\n end\n end", "def soft_copy\n StringDoc.from_structure(@structure, node: @node ? Utils::Dup.deep(@node) : nil)\n end", "def dup\n new_object = super\n new_object.send :initialize_attributes, @attributes\n new_object\n end", "def shallow_clone\n cloned = self.clone\n cloned.remove_relations\n return cloned\n end", "def clone\n raise NotImplementedError\n end", "def duplicate merge_options = {}\n # start to clone\n duplicated_obj = self.clone :except => [:zip_file], :include => [:template_partials, :mail_template_files]\n duplicated_obj.zip_file = File.open(self.zip_file.path) if self.zip_file.path # it will make a copy version of zipfile\n duplicated_obj.attributes = merge_options if merge_options.is_a? Hash # merge custom options\n # without saving can't not create files. so save it first.\n duplicated_obj.save\n\n ### below code is used to clone mail_template_files and replace the new url for cloned template body.\n # pair the mail_template_files and insert into substitution_array.\n substitution_pair_array = []\n self.mail_template_files.each_with_index do |origin_file, index|\n substitution_pair_array << [origin_file, duplicated_obj.mail_template_files[index]]\n end\n\n # replace image or file url with new url.\n original_body = self.body\n\n substitution_pair_array.each do |origin_file, new_file|\n original_body = MailEngine::HtmlDocumentAssetsReplacer.replace_resource_in_html(\n original_body,\n origin_file.file.url,\n new_file.file.url,\n :url\n )\n end\n\n # write back the new body with cloned resource urls.\n duplicated_obj.update_attributes :body => original_body\n duplicated_obj\n end", "def build(document)\n build_simple_attributes(document)\n build_complex_attributes(document)\n end", "def duplicate\n super do |cloned_resource|\n cloned_resource.title = \"Copy #{@resource.title[0...Integral.title_length_maximum - 5]}\"\n cloned_resource.view_count = 0\n cloned_resource.build_active_block_list(content: @resource.active_block_list.content, listable: cloned_resource)\n cloned_resource.tag_list = @resource.tag_list_on(@resource.tag_context)\n cloned_resource.slug = @resource.slug\n cloned_resource.status = :draft\n cloned_resource.published_at = nil\n end\n end", "def deep_copy(src)\n field = Field.find(src)\n name = field.name\n if (name !~ /\\(copy\\)\\s*$/)\n name += \" (copy)\"\n end\n self.name = field.parent_id ? field.name : name\n self.group_id = field.group_id\n self.parent_id = field.parent_id\n self.is_required = field.is_required\n self.is_multi = field.is_multi\n self.type = field.type\n self.par_hi_lim = field.par_hi_lim\n self.par_lo_lim = field.par_lo_lim\n self.display_as = field.display_as\n self.save\n field.limits.each do |l|\n newL = l.clone :except => :field_id\n newL.field_id = self.id\n newL.save\n end\n field.children.each do |k|\n newK = Field.new\n newK.deep_copy(k.id)\n newK.parent_id = self.id\n newK.save\n end\n return self.id\n end", "def initialize(copy=false)\n @copy = (copy == true)\n end", "def duplicate\n p = self.dup\n p.name = 'COPY OF ' + name\n p.deleted_at = nil\n p.created_at = p.updated_at = nil\n p.taxons = taxons\n\n p.product_properties = product_properties.map { |q| r = q.dup; r.created_at = r.updated_at = nil; r }\n\n image_dup = lambda { |i| j = i.dup; j.attachment = i.attachment.clone; j }\n\n variant = master.dup\n variant.sku = 'COPY OF ' + master.sku\n variant.deleted_at = nil\n variant.images = master.images.map { |i| image_dup.call i }\n p.master = variant\n\n # don't dup the actual variants, just the characterising types\n p.option_types = option_types if has_variants?\n\n # allow site to do some customization\n p.send(:duplicate_extra, self) if p.respond_to?(:duplicate_extra)\n p.save!\n p\n end", "def clone\n self\n end", "def clone\n super\n end", "def clone_without_user\n a = self.clone\n a.user = nil\n a\n end", "def clone\n Marshal.load(Marshal.dump(self))\n end", "def clone\n Marshal.load(Marshal.dump(self))\n end", "def clone\n Marshal.load(Marshal.dump(self))\n end", "def clone\n Marshal.load(Marshal.dump(self))\n end", "def clone\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 +(document)\n original, target = [to_raw, document.to_raw].map{ |raw| raw.except(*%w(uuid version previous_version)) }\n\n Document.new(@store, original.merge(target).merge(:uuid => Util.random_uuid), true)\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 dup\n copy(false)\n end", "def create_new\n create_doc_keys(true)\n initialize_document(@docs[:num_comments], 0)\n\n\t\t@comment_id = increase_atomic_count(@docs[:num_comments])\n\n\t\tcreate_doc_keys(true)\n\n create_default_docs\n end", "def from_document doc\n d = {}.tap do |d|\n d[:id] = doc[:_id]\n d[:time] = doc[:_t]\n d[:body] = doc[:_d]\n end.compact\n receive! d\n self\n end", "def copy\n new_attributes = self.attributes\n new_attributes.delete(:id)\n file = WSFile.create(new_attributes)\n owner = self.permissions(level: 'owner').user.first\n Permission.create(user: owner, file: file, level: \"owner\")\n self.assets.each do |asset|\n file.assets.push asset\n end\n self.children.each do |child|\n file.children.push child.copy\n end\n file.save\n file.data = self.data\n file\n end", "def make_copy\n\t\t\tMarshal.load(Marshal.dump(self))\n\t\tend", "def duplicate\n @copy = self.deep_clone :no_duplicates => true, :never_clone => [:uuid, :updated_at,:created_at]\n @copy.static_page = self.static_page.duplicate\n self.sub_pages.each do |page| \n copy_of_page = page.duplicate\n @copy.sub_pages << copy_of_page\n copy_of_page.save\n end\n @copy.save\n @copy\n end", "def clone\n o = dup\n o.freeze if frozen?\n o\n end", "def deep_copy\n field_copy = self.dup\n field_copy.save!\n field_copy\n end", "def clone_requirements_from(original_project)\n original_project.requirements.each do |req|\n r2 = req.dup\n r2.attributes = { project_id: id }\n r2.save\n end\n end", "def _clone\n self.class.new(self)\n end", "def clone_body; end", "def dup\n return super unless post_id\n clone = super\n clone.post_id = nil\n clone\n end", "def clone(*) end", "def clone(*) end", "def clone_with_associations\n raise \"Method not implemented, please define \\\"clone_with_associations\\\" in #{model_name.to_s}\"\n end", "def generate_document_structure; build_document_hash end", "def clone\n q = super\n q.attrs = self.attrs.clone\n return q\n end", "def create\n if params[:project_id]\n cloned_from = Project.find(params[:project_id])\n @project = cloned_from.clone(params, @cur_user.id)\n else\n @cloned_project = nil\n @project = Project.new project_params\n @project.user_id = @cur_user.id\n end\n\n respond_to do |format|\n if @project.save\n format.html do\n redirect_to @project, notice: 'Project was successfully created.'\n end\n format.json do\n render json: @project.to_hash(false),\n status: :created, location: @project\n end\n else\n flash[:error] = @project.errors.full_messages\n format.html { redirect_to projects_path }\n format.json do\n render json: @project.errors, status: :unprocessable_entity\n end\n end\n end\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 copy\n\t\t\treturn self.dup\n\t\tend", "def duplicate\n enhance_settings\n\n p = self.dup\n p.category = 'COPY OF ' + category\n p.created_at = p.updated_at = nil\n p.url = url\n p.attachment = attachment\n\n # allow site to do some customization\n p.send( :duplicate_extra, self ) if p.respond_to?( :duplicate_extra )\n p.save!\n \n p\n end", "def copy(options = {})\n copy_object(options)\n end", "def clone\n return Marshal.load(Marshal.dump(self))\n end", "def generate_document options={}\n\n # which vendor or which account?\n party = options[\"party_type\"].constantize.find_by_id(options[\"party\"])\n\n # generate pending document_entity (the row in the document table)\n document = Document.create( document_type: options[\"doc_type\"],\n recipient: party.name,\n total: \"0\",\n event_id: self.id,\n status: DocumentStatus::requested,\n name: DocumentStatus::requested,\n creator_id: options[\"current_user\"])\n options[\"document_id\"] = document.id\n\n #if we're invoicing, lock invoicable line items\n if options[\"doc_type\"] == DocumentType::Event::invoice\n lock_new_invoice_line_items party, document\n end\n # queue the pdf creation and persistence\n Sidekiq::Client.enqueue( EventDocument, options )\n end" ]
[ "0.6470156", "0.6108942", "0.6086397", "0.6070406", "0.57580686", "0.5739125", "0.571301", "0.5681215", "0.56742346", "0.5669589", "0.5634285", "0.5602384", "0.55871075", "0.55836535", "0.55686194", "0.5552745", "0.54687065", "0.5444203", "0.5413753", "0.5395581", "0.5391251", "0.5372622", "0.53419644", "0.5318238", "0.5316244", "0.531603", "0.5299399", "0.5295239", "0.52932364", "0.5293174", "0.5282595", "0.52790254", "0.52765095", "0.52765095", "0.52747196", "0.5263026", "0.5263026", "0.5263026", "0.5256452", "0.52163047", "0.52136165", "0.52129716", "0.52120227", "0.5197806", "0.51967853", "0.51967853", "0.51967853", "0.51918304", "0.5182737", "0.51756674", "0.5174641", "0.51735896", "0.5165289", "0.5162297", "0.51494056", "0.514699", "0.5146571", "0.51445836", "0.5140304", "0.51398563", "0.51366645", "0.5135506", "0.51331115", "0.51324505", "0.51243126", "0.5110041", "0.5109395", "0.50996566", "0.50951695", "0.50951695", "0.50951695", "0.50951695", "0.50951695", "0.50945693", "0.50899714", "0.5082955", "0.50769037", "0.5072985", "0.50721496", "0.5063263", "0.5046547", "0.50428325", "0.5037362", "0.5035972", "0.50352967", "0.5032358", "0.5018814", "0.50021726", "0.5000657", "0.5000657", "0.4994744", "0.499124", "0.49889988", "0.4982432", "0.49793684", "0.49778852", "0.49663326", "0.4964434", "0.49637184", "0.49608868" ]
0.7389626
0
TODO: Make the to_json an extended form of the canonical.
def as_json(opts={}) json = { :id => id, :organization_id => organization_id, :account_id => account_id, :created_at => created_at.to_date.strftime(DISPLAY_DATE_FORMAT), :access => access, :page_count => page_count, :annotation_count => annotation_count || 0, :public_note_count => public_note_count, :title => title, :slug => slug, :source => source, :description => description, :organization_name => organization_name, :organization_slug => organization_slug, :organization_documents_url => organization_documents_url, :account_name => account_name, :account_slug => account_slug, :account_documents_url => account_documents_url, :related_article => related_article, :pdf_url => pdf_url, :thumbnail_url => thumbnail_url( { :cache_busting => opts[:cache_busting] } ), :full_text_url => full_text_url, :page_image_url => page_image_url_template( { :cache_busting => opts[:cache_busting] } ), :page_text_url => page_text_url_template( { :cache_busting => opts[:cache_busting] } ), :canonical_url => canonical_url(:html), :document_viewer_url => document_viewer_url, :document_viewer_js => canonical_url(:js), :reviewer_count => reviewer_count, :remote_url => remote_url, :detected_remote_url => detected_remote_url, :publish_at => publish_at.as_json, :hits => hits, :mentions => mentions, :total_mentions => total_mentions, :project_ids => project_ids, :char_count => char_count, :data => data, :language => language, :file_hash => file_hash } if opts[:annotations] json[:annotations_url] = annotations_url if commentable?(opts[:account]) json[:annotations] = self.annotations_with_authors(opts[:account]) end json end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_json(options={})\n canonical(options).to_json\n end", "def to_json_string\n MARC::JSONLWriter.encode(self)\n end", "def to_json\n to_raw.to_json\n end", "def to_json(*)\n\t\t\t# to_json needs to not care about arguments with the C extension\n\t\t\t# version of the JSON gem.\n\t\t\t# See json-1.5.1/ext/json/ext/generator/generator.c:902\n\t\t\tto_hash.to_json\n\t\tend", "def to_json_raw_object()\n #This is a stub, used for indexing\n end", "def to_json\r\n to_hash.to_json\r\n end", "def to_json\n to_parsed.to_json\n end", "def to_nice_json\n JSON.pretty_generate to_hash\n end", "def to_nice_json\n JSON.pretty_generate to_hash\n end", "def to_json\n Oj.dump(to_hash)\n end", "def to_json_raw(*args)\n #This is a stub, used for indexing\n end", "def to_json\n return self.to_hash.to_json\n end", "def to_json\n return to_hash.to_json\n end", "def to_json\n\n end", "def to_json\n self.to_hash.to_json\n end", "def to_json\n self.to_hash.to_json\n end", "def to_json\n to_hash.to_json\n end", "def to_json\n to_hash.to_json\n end", "def to_json\n to_hash.to_json\n end", "def to_json\n to_hash.to_json\n end", "def to_json\n to_hash.to_json\n end", "def to_json\n to_hash.to_json\n end", "def to_json\n to_hash.to_json\n end", "def to_json\n to_hash.to_json\n end", "def to_json\n to_hash.to_json\n end", "def to_json\n to_hash.to_json\n end", "def to_json\n to_hash.to_json\n end", "def to_json\n to_hash.to_json\n end", "def to_json\n to_hash.to_json\n end", "def to_json\n to_json_object.to_json\n end", "def to_json\n to_hash.to_json\n end", "def to_json\n\t\tto_h.to_json\n\tend", "def to_json\n\t\tto_h.to_json\n\tend", "def to_json\n self.to_hash.to_json\n end", "def to_json\n JSON.generate to_hash\n end", "def to_json\n to_h.to_json\n end", "def to_json\n to_h.to_json\n end", "def to_json(what)\n what.to_hash.to_json\n end", "def to_json\n Yajl::Encoder.encode(to_hash, :pretty => true)\n end", "def tojson\n\t\tend", "def to_json\n return Json.dump(to_hash)\n end", "def to_json\n to_s.to_json\n end", "def to_json\n JSON.pretty_generate(to_hash)\n end", "def to_json!\n self.to_hash.to_json\n end", "def to_json(*)\n #This is a stub, used for indexing\n end", "def to_json\n attributes = self.values\n attributes[:date_published] = self.date_published_iso8601\n return attributes.to_json\n end", "def to_json\n attrs.to_json\nend", "def as_json(*args)\n super.merge({\n \"id\" => self.obj_key,\n \"obj_key\" => self.obj_key,\n \"link_path\" => self.public_path,\n \"to_title\" => self.to_title,\n \"edit_path\" => self.admin_edit_path\n }).merge(self.json.stringify_keys!)\n end", "def to_json\n raise StandardError, \"Not implemented!\"\n end", "def to_json\n self.to_h.to_json\n end", "def to_json\n #JSON.fast_generate(to_hash)\n JSON.pretty_generate(to_hash)\n end", "def to_json\n #JSON.fast_generate(to_hash)\n JSON.pretty_generate(to_hash)\n end", "def to_json\n MultiJson.encode(to_hash)\n end", "def to_json(*)\n to_hash.to_json\n end", "def to_json\n JSON.generate(to_h)\n end", "def to_json\n to_a.to_json\n end", "def to_json(*a)\n {\n :id => self.id,\n :followed_place_id => self.followed_place_id,\n :longitude => self.longitude,\n :latitude => self.latitude,\n :name => self.name,\n :postcode => self.postcode,\n :city => self.city,\n :address => self.address,\n :country => self.country,\n :icon => self.icon,\n :distance => self.distance,\n :publications => self.publications,\n :distance_boundary => 0,#self.distance_boundary,\n :can_publish => true #self.can_publish\n }.to_json(*a)\n end", "def to_json\n Yajl::Encoder.encode(@raw_data)\n end", "def to_json *args \n self.to_hash.to_json\n end", "def to_json *args \n self.to_hash.to_json\n end", "def to_json(*args); end", "def to_json\n JSON.generate(__to_json_map__)\n end", "def to_json\n JSON.generate(__to_json_map__)\n end", "def to_json\n JSON.generate(__to_json_map__)\n end", "def to_json\n JSON.generate(__to_json_map__)\n end", "def as_json\n to_s.as_json\n end", "def to_json\n JSON(as_json)\n end", "def to_json(*arg)\n @meta.to_json(*arg)\n end", "def to_json\n hash = to_h\n\n hash.each do |k, v|\n hash[k] = self.class.convert(v, k, :to_json)\n end\n\n Oj.dump(hash, omit_nil: true)\n end", "def to_json\n @json ||= get_json\n end", "def as_json(*)\n {\n JSON.create_id => self.class.name,\n 'a' => [ first, last, exclude_end? ]\n }\n end", "def json_serialize\n end", "def to_json\n object.to_json\n end", "def in_json\n {\n bio: {\n originatingSourceSystem: SOURCE_SYSTEM,\n permissionType: @permission_type,\n permissionValue: @permission_value,\n sourceDate: @source_date,\n sourceSystemUser: @source_system_user,\n permissionId: @id,\n vet360Id: @vet360_id,\n effectiveStartDate: @effective_start_date,\n effectiveEndDate: @effective_end_date\n }\n }.to_json\n end", "def to_json_sub\n to_json_struct.to_json\n end", "def serialize\n self.to_hash.to_json\n end", "def to_json\n JSON.pretty_generate(to_h)\n end", "def to_json arg\n as_json.to_json\n end", "def instance_to_json\n { \n id: self.id,\n title: self.title,\n content: self.content,\n likes: self.likes,\n author: {\n id: self.author.id,\n name: self.author.name\n }\n }\n end", "def to_json\n {\n first_name: first_name,\n last_name: last_name,\n email: email,\n phone: phone,\n address: address,\n birthday: birthday,\n circle: circle,\n created_at: created_at,\n slug: slug\n }\n end", "def to_marc_json\n to_marc.to_hash.to_json\n end", "def extended_json(resource)\n return resource.as_json.to_hash unless resource.respond_to?(:links)\n return resource.as_json.to_hash unless resource.links.kind_of?(Occi::Core::Links)\n\n links = resource.links\n ext_json = resource.as_json\n ext_json.links = links.as_json\n ext_json.to_hash\n end", "def to_json\n hash = self.key_map()\n hash.to_json\n end", "def to_json\n hash = self.key_map()\n hash.to_json\n end", "def to_json\r\n hash = self.key_map()\r\n hash.to_json\r\n end", "def as_json(_opts={})\n raise NotImplementedError\n end", "def pretty_json\n JSON.pretty_generate({\n \"id\" => @id,\n \"aliases\" => @aliases,\n \"origins\" => @origins.map(&:to_local),\n \"default-cache-behavior\" => @default_cache_behavior.to_local,\n \"cache-behaviors\" => @cache_behaviors.map(&:to_local),\n \"comment\" => @comment,\n \"enabled\" => @enabled,\n })\n end", "def to_json\n MultiJson.dump(raw)\n end", "def to_json\n MultiJson.dump(raw)\n end", "def to_json(*attrs); super self.class.params; end", "def to_json(*attrs); super self.class.params; end", "def to_json(*attrs); super self.class.params; end", "def to_json\n\t\tresult = {}\n\t\tself.filters.collect { |c| result[c[0].to_sym] = c[1] }\n\t\treturn result.to_json\n\tend", "def to_json\n { :document => document, :signature => signature }.to_json\n end", "def encode(value)\n Oj.dump value.as_json(options.dup)\n end", "def to_json\n {\n :json_class => self.class.name,\n :display_name => self.display_name,\n :name => self.name,\n :uuid => self.uuid\n }.to_json\n end", "def to_json\n # convert the result to JSON\n MultiJson.dump(to_hash)\n end", "def ser_short\n {\n author: @author,\n title: @title,\n summary: @summary,\n created: @created\n }.to_json\n end", "def to_json\n @json.to_json\n end", "def to_json(**options)\n Granola.json.(attributes, options)\n end", "def in_json\n {\n bio: {\n emailAddressText: @email_address,\n emailId: @id,\n originatingSourceSystem: SOURCE_SYSTEM,\n sourceSystemUser: @source_system_user,\n sourceDate: @source_date,\n vet360Id: @vet360_id,\n effectiveStartDate: @effective_start_date,\n effectiveEndDate: @effective_end_date\n }\n }.to_json\n end" ]
[ "0.75769156", "0.6889507", "0.6834035", "0.6825121", "0.67475337", "0.66842425", "0.66818535", "0.6641304", "0.6641304", "0.663225", "0.6610654", "0.65974265", "0.65822506", "0.65784353", "0.65712535", "0.65712535", "0.6565441", "0.6565441", "0.6548345", "0.6548345", "0.6548345", "0.6548345", "0.6548345", "0.6548345", "0.6548345", "0.6548345", "0.6548345", "0.6548345", "0.6548345", "0.6538411", "0.65311056", "0.65262306", "0.65262306", "0.6511982", "0.64998484", "0.64882964", "0.64882964", "0.64794666", "0.6446247", "0.6439808", "0.6429788", "0.6416829", "0.64069605", "0.6405491", "0.64031106", "0.6386114", "0.63790494", "0.6371492", "0.6366735", "0.6361388", "0.63527817", "0.63527817", "0.6351589", "0.6341636", "0.6332173", "0.63313025", "0.6330218", "0.6324568", "0.6319428", "0.6319428", "0.6297245", "0.62737024", "0.62737024", "0.62737024", "0.62737024", "0.626384", "0.6263612", "0.6251818", "0.6236571", "0.6235529", "0.62314385", "0.62307274", "0.62103987", "0.61964256", "0.6194458", "0.6194059", "0.6191677", "0.6182941", "0.61593693", "0.6153763", "0.61532795", "0.61444736", "0.6140052", "0.6140052", "0.6139637", "0.61226255", "0.6121572", "0.61115426", "0.61115426", "0.61059064", "0.61059064", "0.61059064", "0.6102864", "0.61024255", "0.6099918", "0.6097999", "0.60933053", "0.6092716", "0.60889834", "0.60878456", "0.6069199" ]
0.0
-1
The filtered attributes we're allowed to display in the admin UI.
def admin_attributes { :id => id, :account_name => account_name, :organization_name => organization_name, :page_count => page_count, :thumbnail_url => thumbnail_url, :pdf_url => pdf_url(direct: true), :public => public?, :title => public? ? title : nil, :source => public? ? source : nil, :created_at => created_at.to_datetime.strftime(DISPLAY_DATETIME_FORMAT), :remote_url => remote_url, :detected_remote_url => detected_remote_url } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def valid_filter_attributes\n resource_class.attribute_names\n end", "def attributes\n @allowed_attributes\n end", "def _filtered_attributes\n return accessible_attributes.to_a if accessible_attributes.present?\n\n return self.new.attributes.keys - protected_attributes.to_a\n end", "def showable_attributes\n return attributes if permitted_to?(WriteAllPrivilege)\n attributes.reject do |k,v|\n !allowed?(:read, k, true)\n end\n end", "def extra_attributes_to_filter\n # default value if not set\n return ['password'] unless @options[:filter_attributes]\n # parse option value\n if @options[:filter_attributes].kind_of? Array\n attrs = @options[:filter_attributes]\n elsif @options[:filter_attributes].kind_of? String\n attrs = @options[:filter_attributes].split(',').collect { |col| col.strip }\n else\n $LOG.error(\"Can't figure out attribute list from #{@options[:filter_attributes].inspect}. This must be an Array of column names or a comma-separated list.\")\n attrs = []\n end\n attrs\n end", "def attributes\n attrs = sort_members(@context.attributes).find_all{|a| @options.show_all || a.visibility == :public || a.visibility == :protected}\n attrs.collect{|a| {:name=>a.name, :visibility=>a.visibility, :rw=>a.rw, :description=>markup(a.comment, true)}}\n end", "def restricted_attributes\n if model.respond_to?(:restricted_alchemy_resource_attributes)\n model.restricted_alchemy_resource_attributes\n else\n []\n end\n end", "def allowed_sort_attributes\n @scope.attribute_names\n end", "def filtered_attributes\n # Run the read permission check\n allow_and_deny_fields(:read).then do |allow, deny|\n\n result = nil\n\n if allow && allow != true && allow.size > 0\n # always keep id\n allow << :id\n\n # Only keep fields in the allow list\n result = @attributes.select { |key| allow.include?(key) }\n elsif deny == true\n # Only keep id\n # TODO: Should this be a full reject?\n result = @attributes.reject { |key| key != :id }\n elsif deny && deny.size > 0\n # Reject any in the deny list\n result = @attributes.reject { |key| deny.include?(key) }\n else\n result = @attributes\n end\n\n # Deeply filter any nested models\n result.then do |res|\n keys = []\n values = []\n res.each do |key, value|\n if value.is_a?(Model)\n value = value.filtered_attributes\n end\n keys << key\n values << value\n end\n\n Promise.when(*values).then do |values|\n keys.zip(values).to_h\n end\n end\n end\n end", "def only\n attributes.fetch(:only)\n end", "def allowed_attributes\n self.new.attributes.keys.reject do |col|\n protected_attributes.include?(col)\n end\n end", "def public_attributes\n self.attribute_names.select{|a| !Profile::PRIVATE_FIELDS.include?(a)}\n end", "def inspect\n inspection_filter = PARAMETER_FILTER.new(filter_attributes)\n original_attributes = attributes\n filtered_attributes = inspection_filter.filter(original_attributes)\n\n attribute_descriptions = filtered_attributes.sort.map { |key, value|\n inspect_value = case\n when original_attributes[key].nil? then nil.inspect\n when value == FILTERED then FILTERED\n else value.inspect\n end\n\n \"#{key}: #{inspect_value}\"\n }.join(\", \")\n\n separator = \" \" unless attribute_descriptions.empty?\n \"#<#{self.class.name}#{separator}#{attribute_descriptions}>\"\n end", "def scaffold_filter_attributes(action, attributes)\n allowed_attributes = scaffold_attributes(action).collect{|x| x.to_s}\n attributes.reject{|k,v| !allowed_attributes.include?(k.to_s.split('(')[0])}\n end", "def filter_by attributes\n\n all.select { |item| matches? item, attributes }\n\n end", "def simple_fields\n fields.select(&:filterable?)\n end", "def filter_text\n attributes.fetch(:filterText)\n end", "def safe_attributes\n self.source.custom_fields_safe_attributes + %w(_slug seo_title meta_keywords meta_description _destroy)\n end", "def attributes\n @attributes ||= descriptors_fields.select{|field| field.scope == ATTRIBUTE_FIELDS }\n end", "def visibility_attributes\n raw_attributes.slice(:visibility, :visibility_during_lease, :visibility_after_lease, :lease_expiration_date, :embargo_release_date, :visibility_during_embargo, :visibility_after_embargo)\n end", "def showable_columns\n showable_attributes.keys\n end", "def attributes\n @attributes ||= get_field_by_type(ATTRIBUTE_FIELDS)\n end", "def permitted_attributes\n klass.properties.keys.map(&:to_sym) + %i[id edit_users edit_groups read_groups visibility work_members_attributes]\n end", "def model_filters(model)\n model.attribute_names + model.reflection_names\n end", "def attributes_for_remote\n ignored = self.class.ignored_attributes\n\n entity.attributes.reject do |a, _|\n ignored.include?(a) || a.end_with?('_count', '_id', '_cache')\n end\n end", "def attributes\n @attributes\n end", "def attributes\n @attributes\n end", "def attributes\n @attributes\n end", "def attributes\n ATTRIBUTE_NAMES\n end", "def attributes\n ATTRIBUTES\n end", "def attributes\n permissions.select { |k, v| v.present? }.as_json\n end", "def filter_fields\n\t \n\t \tremove_attribute(:version)\n\t \tremove_attribute(:op_success)\n\t \tattributes\n\n\t \t\n\t end", "def filter_fields\n\t \n\t \tremove_attribute(:version)\n\t \tremove_attribute(:op_success)\n\t \tattributes\n\n\t \t\n\t end", "def html_attributes(attribute_filter= :enabled)\n if @html_attributes.nil?\n ha_ids = self.section_piece_param.html_attribute_ids.split(',').collect{|i|i.to_i}\n @html_attributes= HtmlAttribute.find_by_ids(ha_ids)\n end\n\n case attribute_filter\n when :enabled\n return_html_attributes = @html_attributes.select{|ha| !disabled_html_attribute_ids.include?(ha.id)}\n when :disabled\n return_html_attributes = @html_attributes.select{|ha| disabled_html_attribute_ids.include?(ha.id)}\n else\n return_html_attributes = @html_attributes\n end\n\n end", "def attributes\n @_attributes\n end", "def attributes\n @_attributes\n end", "def lookups\n (instance_type::INTERNAL_ATTRIBUTES + @mapping.salesforce_fields).uniq.join(\", \")\n end", "def allowed_filterables\n %i[created_at updated_at name].freeze\n end", "def attributes\n @attributes\n end", "def readable_attributes \n return attributes if permitted_to?(ReadAllPrivilege)\n attributes.reject do |k,v|\n !allowed?(:read, k)\n end\n end", "def search_attributes\n\t\t['dn', self.attr_firstname, self.attr_lastname, self.attr_mail, self.attr_member]\n\tend", "def filters\n self.class.filters\n end", "def attributes\n @attrs.keys\n end", "def inspect_attributes\n %i[uuid name type slug status email]\n end", "def attributes\n @attrs\n end", "def get_filterset_fields\n return self.class.filterset_fields&.map(&:to_s) || self.get_fields\n end", "def visibility_attributes(attributes)\n attributes.slice(:visibility, :visibility_during_lease,\n :visibility_after_lease, :lease_expiration_date,\n :embargo_release_date, :visibility_during_embargo,\n :visibility_after_embargo)\n end", "def attribute_values\n attributes.values\n end", "def visibility_attributes( attributes )\n attributes.slice( :visibility,\n :visibility_during_lease,\n :visibility_after_lease,\n :lease_expiration_date,\n :embargo_release_date,\n :visibility_during_embargo,\n :visibility_after_embargo )\n end", "def audited_attributes\n self.attributes.keys.select { |k| !self.non_audited_columns.include?(k) }\n end", "def show_fields\n self.class.fields.values.select { |field| field.show }\n end", "def attributes\n @attributes\n end", "def display_attributes\n self.class.display_attribute_names.map do |name|\n [name.to_s, self.send(name)]\n end.to_h\n end", "def filters\n [\n [\"Id\", \"id\"],\n [\"Added By\", \"created_by\"], \n [\"Updated By\", \"updated_by\"]\n ]\n end", "def attributes\n query[ model_name ]\n end", "def attr_columns\n @attr_columns\n end", "def available_filters\n unless @available_filters\n initialize_available_filters\n @available_filters.each do |field, options|\n options[:name] ||= l(options[:label] || \"field_#{field}\".gsub(/_id$/, ''))\n end\n end\n @available_filters\n end", "def attributes\n restricted = defined?(self.class::NON_ATTRIBUTE_PARAMS) ? self.class::NON_ATTRIBUTE_PARAMS : []\n (self.class::PARAM_DEFAULTS.keys - restricted).index_with { |attr| send(attr) }.with_indifferent_access\n end", "def has_attributes?\n a = @context.attributes.find{|a| @options.show_all || a.visibility == :public || a.visibility == :protected}\n a ? true : false\n end", "def attr_strings\n @attr_strings\n end", "def attributes\n data[:attributes]\n end", "def filter\n @filter\n end", "def to_params\n self.filter_attributes %w(_slug _position _visible seo_title meta_keywords meta_description)\n end", "def visible_attr \n _storable_attributes\n end", "def filter_attributes(attributes, to_filter)\n return nil if attributes.nil? || to_filter.nil?\n\n attributes.select { |key, _| to_filter.include? key.to_sym }\n end", "def filter_data\n @data.map do |currency|\n currency.select { |attribute,_|\n selected_attributes.include? attribute.to_s\n }\n end\n end", "def attributes\n @enabled\n end", "def filter\n\t\treturn @filter\n\tend", "def filters\n mentos(:get_all_filters)\n end", "def records_filtered\n records\n @config[:records_filtered]\n end", "def attributes\n instance_values.with_indifferent_access.slice(*USER_ATTRIBUTES)\n end", "def typus_filters\n\n fields_with_type = ActiveSupport::OrderedHash.new\n\n if self.respond_to?('admin_filters')\n fields = self.admin_filters\n else\n return [] unless Typus::Configuration.config[self.name]['filters']\n fields = Typus::Configuration.config[self.name]['filters'].split(', ').collect { |i| i.to_sym }\n end\n\n fields.each do |field|\n attribute_type = self.model_fields[field.to_sym]\n if self.reflect_on_association(field.to_sym)\n attribute_type = self.reflect_on_association(field.to_sym).macro\n end\n fields_with_type[field.to_s] = attribute_type\n end\n\n return fields_with_type\n\n end", "def get_attributes\n\t\t\t@@attributes\n\t\tend", "def attributes\n model_attributes(@@setters_list)\n end", "def attributes\n model_attributes(@@setters_list)\n end", "def attributes\n model_attributes(@@setters_list)\n end", "def attributes\n model_attributes(@@setters_list)\n end", "def attributes\n model_attributes(@@setters_list)\n end", "def attributes\n model_attributes(@@setters_list)\n end", "def searchable_attribute_names\n if model.respond_to?(:searchable_alchemy_resource_attributes)\n model.searchable_alchemy_resource_attributes\n else\n attributes.select { |a| searchable_attribute?(a) }\n .concat(searchable_relation_attributes(attributes))\n .collect { |h| h[:name] }\n end\n end", "def audited_attributes\n attributes.except(*non_audited_columns.map(&:to_s))\n end", "def readable_columns\n readable_attributes.keys\n end", "def attributes\n []\n end", "def attributes\n @json_attributes.reject{|k,v| !schema.fields.include?(k)}\n end", "def permitted_params\n res = attribute_names.map(&:to_sym) - %i[disabled user_id created_at updated_at tracker_id tracker_history_id\n admin_id]\n refine_permitted_params res\n end", "def attributes\n @attributes ||= []\n end", "def attributes\n self.class::ATTRIBUTES\n end", "def attributes\n self.class.fields.inject({}) do |attribute_hash, field|\n attribute_hash[field] = send(field)\n attribute_hash\n end\n end", "def attributes\n @attributes ||= []\n @attributes\n end", "def eav_attributes_list # :nodoc:\n (\n self.instance_eav_attributes + self.class_eav_attributes.keys\n ).collect { |attribute| attribute.to_s }.uniq\n end", "def attributes\n attrs = filter_partials(self.class._attributes.dup)\n filter(attrs).each_with_object({}) do |attr, hash|\n hash[camelize_value(attr)] = send(attr)\n end\n end", "def entries\n @filter\n end", "def attributes\n @list.map(&:attributes)\n end", "def filter?(attributes)\n return attributes.keys.all?{|key| filter_keyvalue?(key, attributes[key])}\n end", "def filter?(attributes)\n return attributes.keys.all?{|key| filter_keyvalue?(key, attributes[key])}\n end", "def attributes\n @attributes ||= []\n raise TypeError, \"attributes contain bad elements #{@attributes}\" unless @attributes.all?{ |attribute| attribute.is_a? String }\n @attributes.sort!\n @attributes.uniq!\n @attributes\n end", "def display_attributes\n super.reject { |k, v| imported_attributes.fetch(k, nil) == v }\n end", "def display_attributes\n super.reject { |k, v| imported_attributes.fetch(k, nil) == v }\n end", "def attribute_names\n @attributes.keys\n end", "def attribute_names\n @attributes.keys\n end", "def attribute_names\n @attributes.keys\n end" ]
[ "0.7758516", "0.74291545", "0.730456", "0.72977936", "0.7288793", "0.7039144", "0.6999964", "0.6968357", "0.69572985", "0.68503386", "0.68135995", "0.66777176", "0.6675979", "0.66697246", "0.6630031", "0.6595662", "0.658562", "0.6517738", "0.65152496", "0.65148485", "0.64906967", "0.64863634", "0.64701265", "0.64357585", "0.6418293", "0.63775486", "0.63775486", "0.63775486", "0.63757855", "0.63739127", "0.6366599", "0.63581103", "0.63581103", "0.63201237", "0.63031274", "0.62948406", "0.62897635", "0.6279059", "0.62691784", "0.62649626", "0.62644655", "0.62131965", "0.6212604", "0.62097865", "0.6208685", "0.6192402", "0.61908257", "0.6175201", "0.6159854", "0.6157648", "0.6157106", "0.61568683", "0.61531836", "0.6152299", "0.61506665", "0.6139381", "0.613259", "0.6125293", "0.6115771", "0.6115703", "0.6114422", "0.6106669", "0.61060965", "0.6101794", "0.609836", "0.6096074", "0.60864675", "0.60864335", "0.6078228", "0.6070686", "0.60689765", "0.6067212", "0.6052849", "0.60527146", "0.60527146", "0.60527146", "0.60527146", "0.60527146", "0.60527146", "0.60499746", "0.6049667", "0.60470915", "0.60470504", "0.6046287", "0.60381657", "0.60307366", "0.6025689", "0.6018861", "0.60180414", "0.6012703", "0.6012366", "0.60057545", "0.600111", "0.59979874", "0.59979874", "0.59976435", "0.599043", "0.599043", "0.5982271", "0.5982271", "0.5982271" ]
0.0
-1
Updates file_size and file_hash Will default to reading the data from the asset_store or can be passed arbitrary data such as from a file on disk
def update_file_metadata(data) update_attributes!( :file_size => data.bytesize, :file_hash => Digest::SHA1.hexdigest( data ) ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_file_info\n if self.path\n size = File.exists?(self.path) ? File.size(self.path) : nil\n end\n if size\n (value, units) = bits_to_human_readable(size)\n self.size = value unless value.nil? or value.empty?\n self.size_units = units unless units.nil? or units.empty?\n self.save if self.descMetadata.changed?\n end\n end", "def update!(**args)\n @data = args[:data] if args.key?(:data)\n @file_name = args[:file_name] if args.key?(:file_name)\n @size = args[:size] if args.key?(:size)\n end", "def update_file_size\n size = File.size(self.file_path)\n if !self.image_size? or self.image_size != size\n self.update_attributes({:image_size => size})\n end\n end", "def update_asset_attributes\n if !self.external_service? and self.present? and self.changed?\n self.content_type = self.filename.file.content_type\n self.file_size = self.filename.file.size\n self.width, self.height = `identify -format \"%wx%h\" #{self.filename.file.path}`.split(/x/) unless self.document? or self.width? or self.height?\n self.ratio = self.width.to_f / self.height.to_f if self.width.present? and self.height.present?\n end\n end", "def update!(**args)\n @content_size = args[:content_size] if args.key?(:content_size)\n @download_url = args[:download_url] if args.key?(:download_url)\n @file_format = args[:file_format] if args.key?(:file_format)\n @file_format_class = args[:file_format_class] if args.key?(:file_format_class)\n @parsed_content_size = args[:parsed_content_size] if args.key?(:parsed_content_size)\n end", "def update_asset_attributes\n if !self.external_service? and self.present? and self.changed?\n self.content_type = self.filename.file.content_type\n self.file_size = self.filename.file.size\n self.width, self.height = `identify -format \"%wx%h\" #{self.filename.file.path}`.split(/x/) unless self.document? or self.width? or self.height?\n self.ratio = self.width.to_f / self.height.to_f if self.width.present? and self.height.present?\n end\n end", "def update!(**args)\n @file_size = args[:file_size] unless args[:file_size].nil?\n @references_version = args[:references_version] unless args[:references_version].nil?\n end", "def update!(**args)\n @file_path = args[:file_path] if args.key?(:file_path)\n @gcs_timestamps = args[:gcs_timestamps] if args.key?(:gcs_timestamps)\n @size_bytes = args[:size_bytes] if args.key?(:size_bytes)\n end", "def update!(**args)\n @file_path = args[:file_path] if args.key?(:file_path)\n @gcs_timestamps = args[:gcs_timestamps] if args.key?(:gcs_timestamps)\n @size_bytes = args[:size_bytes] if args.key?(:size_bytes)\n end", "def update!(**args)\n @blob_id = args[:blob_id] if args.key?(:blob_id)\n @content_type = args[:content_type] if args.key?(:content_type)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @key = args[:key] if args.key?(:key)\n @name = args[:name] if args.key?(:name)\n @size = args[:size] if args.key?(:size)\n end", "def update!(**args)\n @filename = args[:filename] if args.key?(:filename)\n @size = args[:size] if args.key?(:size)\n @upload_status = args[:upload_status] if args.key?(:upload_status)\n end", "def update!(**args)\n @original_file_size_lower_bound_bytes = args[:original_file_size_lower_bound_bytes] if args.key?(:original_file_size_lower_bound_bytes)\n @truncation_state = args[:truncation_state] if args.key?(:truncation_state)\n end", "def file_hash=(value)\n @file_hash = value\n end", "def update\n @global_asset = GlobalAsset.find(params[:id])\n \n upload_hash = FileUploadUtil.uploadFile(params[:data_file], \"global_asset\", ['rar','pdf','word','zip','txt','sql'], @global_asset.data_file_url)\n if upload_hash[:status] == 'error'\n respond_to do |format|\n flash[:notice] = upload_hash[:msg]\n format.html { render action: \"new\" }\n format.json { render json: @global_asset.errors, status: :unprocessable_entity }\n end\n return\n end\n if !params[:data_file].nil?\n @global_asset.data_file_url = upload_hash[:file_name]\n @global_asset.data_content_type = upload_hash[:content_type]\n @global_asset.data_file_size = upload_hash[:file_size]\n @global_asset.width = upload_hash[:width]\n @global_asset.height = upload_hash[:height]\n @global_asset.user_id = @current_user.uid\n @global_asset.user_name = @current_user.name\n end\n \n respond_to do |format|\n if @global_asset.update_attributes(global_asset_params)\n format.html { redirect_to admin_global_asset_path(@global_asset), notice: 'Global asset was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @global_asset.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @expiration_timestamp_micros = args[:expiration_timestamp_micros] if args.key?(:expiration_timestamp_micros)\n @height = args[:height] if args.key?(:height)\n @mime_type = args[:mime_type] if args.key?(:mime_type)\n @size = args[:size] if args.key?(:size)\n @type = args[:type] if args.key?(:type)\n @width = args[:width] if args.key?(:width)\n end", "def update!(**args)\n @storage_size_byte = args[:storage_size_byte] if args.key?(:storage_size_byte)\n end", "def update_file(file_data)\n sha = file_data['sha256']\n file_dir = create_cache_dir(file_data['sha256'])\n file_path = File.join(file_dir, File.basename(file_data['filename']))\n if check_file(file_path, sha)\n @logger.debug(\"Using prexisting file: #{file_path}\")\n return file_path\n end\n\n @logger.debug(\"Queueing download for: #{file_path}\")\n serial_execute { download_file(file_path, sha, file_data['uri']) }\n end", "def set_file_size\n write_attribute(:file_size, File.size(file_name)) if (file_size.blank? and !file_name.blank?)\n end", "def update!(**args)\n @checksums_location = args[:checksums_location] if args.key?(:checksums_location)\n @chunk_size_bytes = args[:chunk_size_bytes] if args.key?(:chunk_size_bytes)\n @object_location = args[:object_location] if args.key?(:object_location)\n @object_size_bytes = args[:object_size_bytes] if args.key?(:object_size_bytes)\n @object_version = args[:object_version] if args.key?(:object_version)\n end", "def set_asset_metadata\n headers = fog_connection.head_object(CarrierWave::Uploader::Base.fog_directory, upload_data[:path]).headers\n\n self.name = upload_data[:filename]\n self.size = headers['Content-Length']\n self.etag = headers['Etag']\n self.content_type = headers['Content-Type']\n end", "def perform_update_storage_size_from_s3\n total_size = 0\n if self.final_file_key\n total_size += fetch_object_size(self.final_file_key)\n else\n total_size += fetch_object_size(self.original_file_key)\n end\n self.update_column(:storage_size, total_size)\n recalculate_storage_size\n end", "def update_filepath(_package_id:, _filepath:, _sha1:, _size:); end", "def update!(**args)\n @blob_generation = args[:blob_generation] if args.key?(:blob_generation)\n @blob_id = args[:blob_id] if args.key?(:blob_id)\n @download_read_handle = args[:download_read_handle] if args.key?(:download_read_handle)\n @read_token = args[:read_token] if args.key?(:read_token)\n @upload_metadata_container = args[:upload_metadata_container] if args.key?(:upload_metadata_container)\n end", "def update!(**args)\n @data = args[:data] if args.key?(:data)\n @height = args[:height] if args.key?(:height)\n @mime_type = args[:mime_type] if args.key?(:mime_type)\n @width = args[:width] if args.key?(:width)\n end", "def update\n respond_to do |format|\n\n if @file_upload.update(file_upload_params)\n format.html { redirect_to user_file_upload_path, notice: 'File was successfully updated.' }\n format.json { render :show, status: :ok, location: @file_upload }\n @md5 = Digest::MD5.file(@file_upload.attachment.path).hexdigest \n @file_upload[:hash_val]=@md5\n @file_upload.save\n else\n format.html { render :edit }\n format.json { render json: @file_upload.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @blob_ref = args[:blob_ref] if args.key?(:blob_ref)\n @blobstore2_info = args[:blobstore2_info] if args.key?(:blobstore2_info)\n @cosmo_binary_reference = args[:cosmo_binary_reference] if args.key?(:cosmo_binary_reference)\n @crc32c_hash = args[:crc32c_hash] if args.key?(:crc32c_hash)\n @inline = args[:inline] if args.key?(:inline)\n @length = args[:length] if args.key?(:length)\n @md5_hash = args[:md5_hash] if args.key?(:md5_hash)\n @object_id_prop = args[:object_id_prop] if args.key?(:object_id_prop)\n @path = args[:path] if args.key?(:path)\n @reference_type = args[:reference_type] if args.key?(:reference_type)\n @sha1_hash = args[:sha1_hash] if args.key?(:sha1_hash)\n end", "def update!(**args)\n @byte_size = args[:byte_size] if args.key?(:byte_size)\n @encoding_quality = args[:encoding_quality] if args.key?(:encoding_quality)\n @encoding_type = args[:encoding_type] if args.key?(:encoding_type)\n @height = args[:height] if args.key?(:height)\n @image_blob_id = args[:image_blob_id] if args.key?(:image_blob_id)\n @image_bytes = args[:image_bytes] if args.key?(:image_bytes)\n @image_string = args[:image_string] if args.key?(:image_string)\n @width = args[:width] if args.key?(:width)\n end", "def update\n @sys_image = resource_find(params[:id])\n uploaded_io = params[:file]\n if (params[:sys_image_id] != -1)\n @sys_image.sys_image_id = params[:sys_image_id]\n end\n\n unless uploaded_io.nil?\n _size = File.size(uploaded_io) \n params[:sys_image].merge!({:size => _size}) \n end\n\n if @sys_image.update_attributes(params[:sys_image])\n unless uploaded_io.nil?\n write_resource(@sys_image, uploaded_io.read, \"ndz\")\n end \n\n #flash[\"success\"] = 'Sys image was successfully updated.'\n flash[\"success\"] = t(\"amazing.sys_image.updated\")\n redirect_to(@sys_image) \n else\n render :action => \"edit\"\n end\n end", "def update!(**args)\n @blob_id = args[:blob_id] if args.key?(:blob_id)\n @options = args[:options] if args.key?(:options)\n @ref_id = args[:ref_id] if args.key?(:ref_id)\n @shard_bin = args[:shard_bin] if args.key?(:shard_bin)\n @size = args[:size] if args.key?(:size)\n @source_v2_blob_id = args[:source_v2_blob_id] if args.key?(:source_v2_blob_id)\n @v2_read_blob_token = args[:v2_read_blob_token] if args.key?(:v2_read_blob_token)\n end", "def file_size\n @file_size ||= 0\n end", "def update_meta_info!\n return unless has_been_read?\n\n ensure_meta_info_dir_exists!\n meta_info_file_pathname.write(\"#{@inode}:#{@read_bytes}\")\n end", "def set_size\n self.size = attachment.size if attachment.size\n end", "def update_upload_attributes\n if document.present? && document_changed?\n self.content_type = document.file.content_type\n self.file_size = document.file.size\n self.file_name = File.basename(document.url)\n end\n end", "def update!(**args)\n @file_contents = args[:file_contents] if args.key?(:file_contents)\n end", "def update\n version_event = false\n\n if params.has_key?(:revision) and params[:revision] != @generic_file.content.latest_version.versionID\n revision = @generic_file.content.get_version(params[:revision])\n @generic_file.add_file_datastream(revision.content, :dsid => 'content')\n version_event = true\n begin\n Resque.enqueue(ContentRestoredVersionEventJob, @generic_file.pid, current_user.user_key, params[:revision])\n rescue Redis::CannotConnectError\n logger.error \"Redis is down!\"\n end\n end\n\n if params.has_key?(:filedata)\n return unless virus_check(params[:filedata]) == 0\n add_posted_blob_to_asset(@generic_file, params[:filedata])\n version_event = true\n begin\n Resque.enqueue(ContentNewVersionEventJob, @generic_file.pid, current_user.user_key)\n rescue Redis::CannotConnectError\n logger.error \"Redis is down!\"\n end\n end\n @generic_file.update_attributes(params[:generic_file].reject { |k,v| %w{ Filedata Filename revision part_of date_modified date_uploaded format }.include? k})\n @generic_file.set_visibility(params)\n @generic_file.date_modified = Time.now.ctime\n @generic_file.save\n # do not trigger an update event if a version event has already been triggered\n begin\n Resque.enqueue(ContentUpdateEventJob, @generic_file.pid, current_user.user_key) unless version_event\n rescue Redis::CannotConnectError\n logger.error \"Redis is down!\"\n end\n record_version_committer(@generic_file, current_user)\n redirect_to sufia.edit_generic_file_path(:tab => params[:redirect_tab]), :notice => render_to_string(:partial=>'generic_files/asset_updated_flash', :locals => { :generic_file => @generic_file })\n\n end", "def setFileSize(fileSize)\r\n\t\t\t\t\t@fileSize = fileSize\r\n\t\t\t\tend", "def update!(**args)\n @attachment_id = args[:attachment_id] unless args[:attachment_id].nil?\n @data = args[:data] unless args[:data].nil?\n @size = args[:size] unless args[:size].nil?\n end", "def update!(**args)\n @object_size_bytes = args[:object_size_bytes] if args.key?(:object_size_bytes)\n @object_version = args[:object_version] if args.key?(:object_version)\n end", "def update!(**args)\n @filename = args[:filename] if args.key?(:filename)\n @height = args[:height] if args.key?(:height)\n @ms_offset = args[:ms_offset] if args.key?(:ms_offset)\n @width = args[:width] if args.key?(:width)\n end", "def recalculate_filesize\n @filesize = @collection.reduce(0) {|sum,asset| sum + asset.size}\n end", "def update!(**args)\n @compression = args[:compression] if args.key?(:compression)\n @content = args[:content] if args.key?(:content)\n @uncompressed_size = args[:uncompressed_size] if args.key?(:uncompressed_size)\n end", "def edit_data(&block)\n lock do\n @cached_data = load_data_from_file\n block.call(self)\n File.safe_write(path, JSON.pretty_generate(@cached_data))\n @cached_data\n end\n end", "def update_file(params)\n self.processed = false\n self.attributes = params\n set_upload_attributes\n save!\n Avatar.delay.finalize_and_cleanup(id)\n end", "def update!(**args)\n @algorithm = args[:algorithm] if args.key?(:algorithm)\n @bigstore_object_ref = args[:bigstore_object_ref] if args.key?(:bigstore_object_ref)\n @blob_ref = args[:blob_ref] if args.key?(:blob_ref)\n @blobstore2_info = args[:blobstore2_info] if args.key?(:blobstore2_info)\n @composite_media = args[:composite_media] if args.key?(:composite_media)\n @content_type = args[:content_type] if args.key?(:content_type)\n @content_type_info = args[:content_type_info] if args.key?(:content_type_info)\n @cosmo_binary_reference = args[:cosmo_binary_reference] if args.key?(:cosmo_binary_reference)\n @crc32c_hash = args[:crc32c_hash] if args.key?(:crc32c_hash)\n @diff_checksums_response = args[:diff_checksums_response] if args.key?(:diff_checksums_response)\n @diff_download_response = args[:diff_download_response] if args.key?(:diff_download_response)\n @diff_upload_request = args[:diff_upload_request] if args.key?(:diff_upload_request)\n @diff_upload_response = args[:diff_upload_response] if args.key?(:diff_upload_response)\n @diff_version_response = args[:diff_version_response] if args.key?(:diff_version_response)\n @download_parameters = args[:download_parameters] if args.key?(:download_parameters)\n @filename = args[:filename] if args.key?(:filename)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @hash_verified = args[:hash_verified] if args.key?(:hash_verified)\n @inline = args[:inline] if args.key?(:inline)\n @is_potential_retry = args[:is_potential_retry] if args.key?(:is_potential_retry)\n @length = args[:length] if args.key?(:length)\n @md5_hash = args[:md5_hash] if args.key?(:md5_hash)\n @media_id = args[:media_id] if args.key?(:media_id)\n @object_id_prop = args[:object_id_prop] if args.key?(:object_id_prop)\n @path = args[:path] if args.key?(:path)\n @reference_type = args[:reference_type] if args.key?(:reference_type)\n @sha1_hash = args[:sha1_hash] if args.key?(:sha1_hash)\n @sha256_hash = args[:sha256_hash] if args.key?(:sha256_hash)\n @timestamp = args[:timestamp] if args.key?(:timestamp)\n @token = args[:token] if args.key?(:token)\n end", "def uploaded_file(object, &block)\n if (hash = object).is_a?(Hash) && !hash.key?(\"storage\")\n hash.inject({}) do |result, (name, data)|\n result.update(name.to_sym => uploaded_file(data, &block))\n end\n else\n super\n end\n end", "def update!(**args)\n @image_bytes = args[:image_bytes] if args.key?(:image_bytes)\n end", "def update!(**args)\n @file_id = args[:file_id] if args.key?(:file_id)\n @file_name = args[:file_name] if args.key?(:file_name)\n @mime_type = args[:mime_type] if args.key?(:mime_type)\n end", "def update!(**args)\n @blob_path = args[:blob_path] if args.key?(:blob_path)\n @content_name = args[:content_name] if args.key?(:content_name)\n @content_size = args[:content_size] if args.key?(:content_size)\n @content_type = args[:content_type] if args.key?(:content_type)\n @dlp_scan_outcome = args[:dlp_scan_outcome] if args.key?(:dlp_scan_outcome)\n @dlp_scan_summary = args[:dlp_scan_summary] if args.key?(:dlp_scan_summary)\n @group_id = args[:group_id] if args.key?(:group_id)\n @original_dimension = args[:original_dimension] if args.key?(:original_dimension)\n @quote_reply_message_id = args[:quote_reply_message_id] if args.key?(:quote_reply_message_id)\n @sha256 = args[:sha256] if args.key?(:sha256)\n @upload_ip = args[:upload_ip] if args.key?(:upload_ip)\n @upload_timestamp_usec = args[:upload_timestamp_usec] if args.key?(:upload_timestamp_usec)\n @video_id = args[:video_id] if args.key?(:video_id)\n @video_thumbnail_blob_id = args[:video_thumbnail_blob_id] if args.key?(:video_thumbnail_blob_id)\n @virus_scan_result = args[:virus_scan_result] if args.key?(:virus_scan_result)\n end", "def checksum(file_path, hash_class, _bit_size)\n # Size of each chunk\n chunk_size = 2048\n # Hash that is the checksum function\n # when a bitsize was specified\n if _bit_size\n hash = hash_class.new(_bit_size)\n else\n hash = hash_class.new\n end\n # File handler\n file_object = File.open(file_path, 'r')\n # loop to update the hash\n while true\n content = file_object.read chunk_size\n # Break the loop if we don't get any byte\n unless content\n return hash.hexdigest\n end\n # Update the hash\n hash.update content\n end\nend", "def file_size\n 1000 # temporarily disable file size calculation\n # TODO: fix this in production env (perhaps zencoder is not replacing target file?)\n # self.file.size\n end", "def update_storage_size_from_s3\n FetchS3ObjectLengthJob.perform_later(self.class.to_s, self.id)\n end", "def init_image_from_stream(file)\n @file = nil\n self.upload_temp_file = nil\n if file.respond_to?(:content_length)\n self.upload_length = file.content_length.chomp\n end\n self.upload_length = file.size if file.respond_to?(:size)\n add_extra_attributes_from_file(file)\n end", "def update(params = {})\n file = params.delete(:file)\n if file\n self.filename = sanitize_filename(file.original_filename)\n self.content_type = file.content_type\n self.file_contents = file.read\n end\n super\n end", "def add_some_extra_params\n @params['size'] = @file.size\n @params['md5sum'] = @file.md5sum\n end", "def update!(**args)\n @data_items = args[:data_items] if args.key?(:data_items)\n @data_size = args[:data_size] if args.key?(:data_size)\n @filesets = args[:filesets] if args.key?(:filesets)\n @tables = args[:tables] if args.key?(:tables)\n end", "def perform_update_storage_size_from_s3\n raise \"IMPLEMENT THIS METHODS ON INCLUDING CLASS\"\n end", "def hash_file path, hash_store\r\n\thexdigest = HASH_DIGEST.hexdigest(open(path, 'rb') { |io| io.read })\r\n\thash_store[hexdigest] << path\r\nend", "def s3_updatefile(filename, filedata)\n s3_deletefile filename\n #AWS::S3::S3Object.store filename, filedata, QBUCKET.to_s, :access => :public_read\n AWS::S3::S3Object.store filename, filedata, IMAGES_BUCKET.to_s, :access => :public_read\n end", "def file_size\n self.file_file_size\n end", "def file=(file_data)\n return nil if file_data.nil? || file_data.size == 0 \n self.assign_type file_data.content_type\n self.location = file_data.original_filename if respond_to?(:location)\n if file_data.is_a?(StringIO)\n file_data.rewind\n self.temp_data = file_data.read\n else\n self.temp_path = file_data.path\n end\n @save_attachment = true\n end", "def uploaded_data=(data)\n return if data.nil? #&& data.size > 0\n #set new values\n self.filename = data.original_filename.strip.gsub(/[^\\w\\d\\.\\-]+/, '_')\n self.disk_filename = Attachment.disk_filename(filename)\n #check for small files indicated by beeing a StringIO\n @uploaded_file = data\n end", "def resize(data_size)\n @fileobj.seek(@offset + 4)\n @fileobj.write([data_size].pack('I>'))\n unless @parent_chunk.nil?\n size_diff = @data_size - data_size\n @parent_chunk.resize(@parent_chunk.data_size - size_diff)\n end\n @data_size = data_size\n @size = data_size + HEADER_SIZE\n end", "def file=(data)\n self.file.assign(data)\n # uploaded photos need metadata immediately in order to\n # \"Sync obs. w/ photo metadata\"\n if data.is_a?(ActionDispatch::Http::UploadedFile)\n extract_metadata(data.path)\n end\n end", "def update!(**args)\n @content = args[:content] if args.key?(:content)\n @height = args[:height] if args.key?(:height)\n @mime_type = args[:mime_type] if args.key?(:mime_type)\n @width = args[:width] if args.key?(:width)\n end", "def analyze_file!(full_file_path)\n pn = Pathname.new(full_file_path)\n self.file_size = pn.size\n self.file_updated_at = pn.mtime\n\n if is_a?(NfsStore::Manage::ArchivedFile)\n if file_size < MaxSizeForArchiveFileHash || file_hash.nil?\n self.file_hash = self.class.hash_for_file(full_file_path)\n else\n Rails.logger.warn 'Skipping file hash for large ArchivedFile'\n end\n end\n\n self.content_type = NfsStore::Utils::MimeType.full_mime_type(full_file_path) || UnknownMimeTypeText\n end", "def data_size\n File.size(file_path)\n end", "def data_size\n File.size(file_path)\n end", "def update_for_file(data_json_file_path)\n # Update file_level_identifier so that correct execution context is used.\n @file_level_identifier = data_json_file_path\n if File.exist?(data_json_file_path)\n # Assign settings from data.json file\n file_level_settings = load_settings(data_json_file_path)\n @settings_hierarchy['file'][@file_level_identifier] = { 'settings' => file_level_settings }\n else\n # Assign settings to empty hash.\n @settings_hierarchy['file'][@file_level_identifier] = { 'settings' => {} }\n end\n # Re-compute effective settings\n @effective_settings = compute_effective_settings\n true\n end", "def update!(**args)\n @avro_file_format = args[:avro_file_format] if args.key?(:avro_file_format)\n @file_rotation_interval = args[:file_rotation_interval] if args.key?(:file_rotation_interval)\n @file_rotation_mb = args[:file_rotation_mb] if args.key?(:file_rotation_mb)\n @json_file_format = args[:json_file_format] if args.key?(:json_file_format)\n @path = args[:path] if args.key?(:path)\n end", "def update!(**args)\n @mime_type = args[:mime_type] if args.key?(:mime_type)\n @raw_bytes = args[:raw_bytes] if args.key?(:raw_bytes)\n @uri = args[:uri] if args.key?(:uri)\n end", "def data=(value)\n # Set metadata on object\n attribute_set(:filename, value[:filename])\n attribute_set(:content_type, value[:content_type])\n attribute_set(:size, value[:size])\n\n # Store contents of file (may be a String or a StringIO)\n attribute_set(:data, if value[:tempfile].respond_to?(:rewind)\n value[:tempfile].rewind\n value[:tempfile].read\n else\n value[:tempfile]\n end)\n end", "def update!(**args)\n @compression_type = args[:compression_type] if args.key?(:compression_type)\n @raw_hashes = args[:raw_hashes] if args.key?(:raw_hashes)\n @raw_indices = args[:raw_indices] if args.key?(:raw_indices)\n @rice_hashes = args[:rice_hashes] if args.key?(:rice_hashes)\n @rice_indices = args[:rice_indices] if args.key?(:rice_indices)\n end", "def update!(**args)\n @estimated_copied_bytes = args[:estimated_copied_bytes] if args.key?(:estimated_copied_bytes)\n @estimated_size_bytes = args[:estimated_size_bytes] if args.key?(:estimated_size_bytes)\n @state = args[:state] if args.key?(:state)\n end", "def update!(**args)\n @estimated_copied_bytes = args[:estimated_copied_bytes] if args.key?(:estimated_copied_bytes)\n @estimated_size_bytes = args[:estimated_size_bytes] if args.key?(:estimated_size_bytes)\n @state = args[:state] if args.key?(:state)\n end", "def update!(**args)\n @prefix_size = args[:prefix_size] if args.key?(:prefix_size)\n @raw_hashes = args[:raw_hashes] if args.key?(:raw_hashes)\n end", "def set_update_values(link_hash)\n\thash = CreateHash.read_hash_file(link_hash[\"asset\"])\n\tnew_hash = {}\n\tnew_hash.store(\"Asset Number\", hash[\"fields\"][\"Asset Number\"])\n\tnew_hash.store(\"Purchase Date\", hash[\"fields\"][\"Purchase Date\"])\n\tnew_hash.store(\"Purchase Cost\", hash[\"fields\"][\"Purchase Cost\"])\n\tnew_hash.store(\"Supplier\", hash[\"fields\"][\"Supplier\"])\n\tnew_hash.store(\"Order Number\", hash[\"fields\"][\"Order Number\"])\n\treturn new_hash\nend", "def file_hash\n return @file_hash\n end", "def set_file_from_raw_data\n self.status = 'archived'\n self.file = ActionDispatch::Http::UploadedFile.new(filename: filename, tempfile: tempfile_for_filedata)\n end", "def update_asset_settings!\n AssetSettings[:development].files[@file_id] = @sfiles.map(&:local_url)\n return unless AssetMapper.compile?\n\n AssetSettings[:production].files[@file_id] = @cloud_files.map(&:production_url)\n AssetSettings[:production].files[@file_id] << @tfile.production_url if @tfile.production_url\n\n AssetSettings[:local_assets].files[@file_id] = @cloud_files.map(&:local_url)\n AssetSettings[:local_assets][@file_id] << @tfile.local_url if @tfile.local_url\n end", "def update!(**args)\n @content = args[:content] if args.key?(:content)\n @file = args[:file] if args.key?(:file)\n @path = args[:path] if args.key?(:path)\n @permissions = args[:permissions] if args.key?(:permissions)\n @state = args[:state] if args.key?(:state)\n end", "def update(uploaded_file)\n _set(uploaded_file)\n end", "def size\n @size ||= File.size(file)\n end", "def update_upload_filesize_sum\n update_column(:upload_filesize_sum, own_maps.sum(:upload_file_size)) \n end", "def add_file_datastream(file, opts={})\n super\n if file.respond_to?(:size)\n size = bits_to_human_readable(file.size)\n elsif file.kind_of?(File)\n size = bits_to_human_readable(File.size(file))\n else\n size = \"\"\n end\n datastreams[\"descMetadata\"].extent = size\n end", "def update_tag_file\n make_cache_dir\n begin\n tag_array = read_tag_file(@tag_file)\n yield(tag_array)\n write_tag_file(tag_array)\n end\n end", "def update!(**args)\n @container = args[:container] if args.key?(:container)\n @elementary_streams = args[:elementary_streams] if args.key?(:elementary_streams)\n @encryption_id = args[:encryption_id] if args.key?(:encryption_id)\n @file_name = args[:file_name] if args.key?(:file_name)\n @key = args[:key] if args.key?(:key)\n @segment_settings = args[:segment_settings] if args.key?(:segment_settings)\n end", "def update!(**args)\n @deprecated_entropy_color = args[:deprecated_entropy_color] if args.key?(:deprecated_entropy_color)\n @filename = args[:filename] if args.key?(:filename)\n @flags = args[:flags] if args.key?(:flags)\n @height = args[:height] if args.key?(:height)\n @width = args[:width] if args.key?(:width)\n end", "def update!(**args)\n @create_time = args[:create_time] if args.key?(:create_time)\n @hashes = args[:hashes] if args.key?(:hashes)\n @name = args[:name] if args.key?(:name)\n @owner = args[:owner] if args.key?(:owner)\n @size_bytes = args[:size_bytes] if args.key?(:size_bytes)\n @update_time = args[:update_time] if args.key?(:update_time)\n end", "def update!(**args)\n @image_height = args[:image_height] if args.key?(:image_height)\n @image_id = args[:image_id] if args.key?(:image_id)\n @image_url = args[:image_url] if args.key?(:image_url)\n @image_width = args[:image_width] if args.key?(:image_width)\n @is_animated = args[:is_animated] if args.key?(:is_animated)\n @is_default = args[:is_default] if args.key?(:is_default)\n @metadata = args[:metadata] if args.key?(:metadata)\n end", "def update!(**args)\n @asset = args[:asset] if args.key?(:asset)\n @compression_format = args[:compression_format] if args.key?(:compression_format)\n @data_format = args[:data_format] if args.key?(:data_format)\n @project_id = args[:project_id] if args.key?(:project_id)\n end", "def file_size\n number_to_human_size(super)\n end", "def update!(**args)\n @file_id = args[:file_id] if args.key?(:file_id)\n @justification = args[:justification] if args.key?(:justification)\n @last_modified_time = args[:last_modified_time] if args.key?(:last_modified_time)\n @mime_type = args[:mime_type] if args.key?(:mime_type)\n @title = args[:title] if args.key?(:title)\n @url = args[:url] if args.key?(:url)\n end", "def hash\n raise NotImplementedError.new(\"hash() must be implemented by subclasses of AbstractVersionedFile.\")\n end", "def set_stocked_file\n @stocked_file = StockedFile.find_by(id: params[:id]) || StockedFile.find_by(hash_key: params[:hash_key])\n end", "def update!(**args)\n @byte_size = args[:byte_size] if args.key?(:byte_size)\n @docid = args[:docid] if args.key?(:docid)\n @duration = args[:duration] if args.key?(:duration)\n @expiration_timestamp_micros = args[:expiration_timestamp_micros] if args.key?(:expiration_timestamp_micros)\n @fprint = args[:fprint] if args.key?(:fprint)\n @height = args[:height] if args.key?(:height)\n @mime_type = args[:mime_type] if args.key?(:mime_type)\n @state = args[:state] if args.key?(:state)\n @timestamp = args[:timestamp] if args.key?(:timestamp)\n @type = args[:type] if args.key?(:type)\n @video_segment_end_us = args[:video_segment_end_us] if args.key?(:video_segment_end_us)\n @video_segment_start_us = args[:video_segment_start_us] if args.key?(:video_segment_start_us)\n @width = args[:width] if args.key?(:width)\n end", "def file_data=(file_data)\n @file_path = nil\n self.raw_data = nil\n @file_data = file_data\n # Ensure that the IO-like object can return CRC32 and data size\n # information so that it's possible to verify extraction later if desired.\n unless @file_data.respond_to?(:data_descriptor) then\n @file_data = Zip::Codec::Store.new.decompressor(@file_data)\n end\n @file_data\n end", "def update_file_size(file_id, file_size)\n $db.execute(\"UPDATE files SET file_size = ? WHERE file_id = ?\", file_size, file_id)\nend", "def update!(**args)\n @content_validation_stats = args[:content_validation_stats] if args.key?(:content_validation_stats)\n @data_bytes_count = args[:data_bytes_count] if args.key?(:data_bytes_count)\n end", "def set_file\n if have_file?\n begin\n set_file_for_remote_storage\n rescue Errno::ENOENT\n set_file_for_local_storage\n rescue NoMethodError\n raise \"Original resource has no File\"\n end\n else\n raise \"Original resource has no File\"\n end\n end", "def file_size\n stream.size\n end" ]
[ "0.6791512", "0.66723084", "0.6563773", "0.64980394", "0.64271307", "0.6394023", "0.6344489", "0.62978506", "0.62961334", "0.62264585", "0.6208466", "0.61774457", "0.6166524", "0.60745484", "0.6072598", "0.6070162", "0.60647684", "0.6060879", "0.60525876", "0.60396755", "0.60209495", "0.59838206", "0.5977583", "0.5956166", "0.5954875", "0.5926682", "0.59046507", "0.59043205", "0.58778226", "0.5863945", "0.58303964", "0.5826023", "0.57728356", "0.57725024", "0.5764427", "0.5729258", "0.5727528", "0.57271314", "0.571743", "0.571508", "0.57114625", "0.5708211", "0.56874603", "0.56809497", "0.5677672", "0.5670963", "0.56609607", "0.5659298", "0.56464165", "0.5646273", "0.5643923", "0.56400585", "0.5629392", "0.56144464", "0.5608921", "0.5608211", "0.5603163", "0.5567117", "0.55607706", "0.55589205", "0.5556895", "0.5546221", "0.5537068", "0.5507943", "0.55032814", "0.548337", "0.548337", "0.5469246", "0.5467991", "0.5463127", "0.54555196", "0.54407233", "0.5437498", "0.5437498", "0.54337126", "0.5426209", "0.54213905", "0.5400679", "0.53940934", "0.5382998", "0.5379419", "0.53788334", "0.53666896", "0.5364933", "0.53572917", "0.5351428", "0.53507626", "0.534997", "0.5345949", "0.5336877", "0.5335152", "0.5330373", "0.532196", "0.53202075", "0.531765", "0.5316873", "0.531149", "0.53104585", "0.53011847", "0.52977353" ]
0.73113394
0
Used for unit tests
def sleep(n) Kernel.sleep(n) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def spec; end", "def spec; 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 specie; end", "def specie; end", "def specie; end", "def specie; end", "def implementation; end", "def implementation; 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 setup\n \n end", "def setup\n \n end", "def setup\n \n end", "def before_setup; end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def testing\n # ...\n end", "def private_method\n end", "def refutal()\n end", "def weber; end", "def internal; end", "def setup\r\n end", "def __dummy_test__\n end", "def setup\n\t\tend", "def setup\n\t\tend", "def setup; end", "def init; end", "def init; end", "def init; end", "def init; end", "def before_run; end", "def setup\n\n end", "def setup\n\n end", "def init\n\n end", "def probers; 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 strategy; end", "def self_test; end", "def self_test; end", "def initialize\n\n end", "def initialize\n\n end", "def schubert; end", "def driver; end", "def initialize\r\n\r\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 setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def setup\n end", "def initialize()\r\n\r\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end" ]
[ "0.7921957", "0.7030221", "0.7030221", "0.68979514", "0.68979514", "0.68979514", "0.68979514", "0.68979514", "0.68979514", "0.68979514", "0.68979514", "0.68979514", "0.68979514", "0.68979514", "0.68979514", "0.68979514", "0.68979514", "0.68979514", "0.68979514", "0.68979514", "0.68979514", "0.68979514", "0.68220943", "0.68220943", "0.68220943", "0.68220943", "0.66059524", "0.66059524", "0.6550377", "0.6550377", "0.6550377", "0.6531246", "0.6531246", "0.6531246", "0.6531246", "0.6531246", "0.6531246", "0.6531246", "0.6474587", "0.6443914", "0.6443914", "0.6443914", "0.6443914", "0.6443914", "0.6443914", "0.64279974", "0.63932216", "0.6350192", "0.6329395", "0.63163716", "0.63119185", "0.6311533", "0.62983656", "0.62983656", "0.628515", "0.62748075", "0.62748075", "0.62748075", "0.62748075", "0.6266105", "0.62649035", "0.62649035", "0.62629265", "0.6258202", "0.6239714", "0.6239714", "0.6239714", "0.6239714", "0.6239714", "0.6239714", "0.6239714", "0.6239714", "0.6239714", "0.62236834", "0.6222066", "0.6222066", "0.62193394", "0.62193394", "0.62116224", "0.6194519", "0.61806834", "0.61622393", "0.61622393", "0.6156575", "0.6156575", "0.6156575", "0.6156575", "0.6156575", "0.6156575", "0.6156575", "0.6156575", "0.6156575", "0.6156575", "0.6156575", "0.6156575", "0.6124586", "0.60969824", "0.60969824", "0.60969824", "0.60969824", "0.60969824" ]
0.0
-1
wraps Savon client methods for convenience
def get_lead_by_idnum(idnum) @client.get_lead_by_idnum(idnum) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new_client\n Savon.client(\n wsdl: @wsdl,\n endpoint: @endpoint,\n convert_request_keys_to: :none,\n soap_version: 1,\n pretty_print_xml: true,\n filters: [:password],\n logger: @soap_logger,\n log_level: @soap_log_level,\n log: @soap_log\n )\n end", "def client\n Savon::Client.new do |savon|\n savon.ssl_verify_mode :none\n savon.wsdl base_url\n savon.namespaces namespaces\n savon.env_namespace 'SOAP-ENV'\n savon.raise_errors false\n #savon.namespace_identifier #none\n savon.convert_request_keys_to :lower_camelcase\n savon.strip_namespaces true\n savon.pretty_print_xml true\n savon.log log_env\n savon.open_timeout 10 #seconds\n savon.read_timeout 45 #seconds\n end\n end", "def initialize\n @client = Savon.client(wsdl: Twinfield::WSDLS[:session])\n end", "def client \n @client ||= Savon::Client.new do\n wsdl.document = self.endpoint\n end\n end", "def client\n Savon.client options\n end", "def soap_client\n return @client if @client and @access_token and @access_token['expires_at'] and\n Time.now < @access_token['expires_at']\n\n @client = Savon.client(\n wsdl: WSDL_URI,\n namespace: NAMESPACE_URI,\n namespace_identifier: :v2,\n namespaces: {\n 'xmlns:arr' => 'http://schemas.microsoft.com/2003/10/Serialization/Arrays'\n },\n headers: {'Authorization' => \"Bearer #{get_access_token['access_token']}\"},\n )\n end", "def client\n @client ||= Savon.client(wsdl) do |wsdl|\n wsdl.endpoint = endpoint\n end.tap do |client|\n client.config.soap_header = soap_headers\n client.http.auth.ssl.verify_mode = :none\n end\n end", "def soap_client\n return @client if @client && @access_token && @access_token['expires_at'] &&\n (Time.now < @access_token['expires_at'])\n\n @client = Savon.client(\n wsdl: WSDL_URI,\n namespace: NAMESPACE_URI,\n namespace_identifier: :v2,\n namespaces: {\n 'xmlns:arr' => 'http://schemas.microsoft.com/2003/10/Serialization/Arrays'\n },\n headers: { 'Authorization' => \"Bearer #{get_access_token['access_token']}\" }\n )\n end", "def initialize\n # Note: Deliberately disabling the verbose Savon logging\n @savon = ::Savon.client(endpoint: ENDPOINT, namespace: NAMESPACE,\n soap_version: 1, wsdl: WSDL, log: false)\n end", "def client\n @client ||= Savon.client(client_options)\n return @client unless block_given?\n yield @client\n end", "def savon_client(params)\n savon_params = {\n :wsdl => params[:wsdl] || 'http://www.voxbone.com/VoxAPI/services/VoxAPI?WSDL',\n :namespace => 'http://www.voxbone.com/VoxAPI',\n :log => false\n }\n\n if params[:log_level]\n savon_params[:log] = true\n savon_params[:log_level] = params[:log_level]\n end\n\n Savon.client(savon_params)\n end", "def method_missing(method, *args, &block)\n if @client.respond_to?(method)\n define_singleton_method(method) do |*args, &block|\n @client.send(method, *args, &block)\n end\n return send(method, *args, &block)\n end\n super\n end", "def method_missing(meth, *args, &blk)\n if client.respond_to?(meth)\n client.send(meth, *args, &blk)\n else\n super\n end\n end", "def method_missing(meth, *args)\n if client.respond_to?(meth)\n client.send(meth, *args)\n else\n super(meth, *args)\n end\n end", "def client\n @client ||= Savon::Client.new do\n wsdl.endpoint = Kraut.endpoint\n wsdl.namespace = \"urn:SecurityServer\"\n end\n end", "def savon\n @savon ||= Savon.client(wsdl: WSDL_URL)\n end", "def savon\n @savon ||= Savon.client(wsdl: WSDL_URL)\n end", "def initialize(api, endpoint, namespace, version)\n if self.class() == AdsCommon::SavonService\n raise NoMethodError, 'Tried to instantiate an abstract class'\n end\n @api, @version, @namespace = api, version, namespace\n @headerhandler = []\n @client = create_savon_client(endpoint, namespace)\n end", "def create_savon_client(endpoint, namespace)\n client = Savon::Client.new do |wsdl, httpi|\n wsdl.endpoint = endpoint\n wsdl.namespace = namespace\n AdsCommon::Http.configure_httpi(@api.config, httpi)\n end\n return client\n end", "def method_missing(meth, *args, &block)\n super unless client.respond_to?(meth)\n\n define_singleton_method meth do |*meth_args, &meth_block|\n client.send(meth, *meth_args, &meth_block)\n end\n\n send(meth, *args, &block)\n end", "def method_missing(method_name, *args, &block)\n return super unless client.respond_to?(method_name)\n client.send(method_name, *args, &block)\n end", "def method_missing(method_name, *args, &block)\n return super unless client.respond_to?(method_name)\n client.send(method_name, *args, &block)\n end", "def method_missing(method_name, *args, &block)\n return super unless client.respond_to?(method_name)\n client.send(method_name, *args, &block)\n end", "def client_access\n super\n end", "def client\n # @client ||= MyService::Client.new(SinaToken.consumer.key, SinaToken.consumer.secret, token, secret)\n end", "def soap_client\n # authentication\n credentials = { 'cor:UserName' => username, 'cor:UserPassword' => password }\n # required SOAP header\n soap_header = { 'cor:OGHeader' => { 'cor:Authentication' => { 'cor:UserCredentials' => credentials } } }\n # logging options\n log_options = { log_level: :debug, log: true, pretty_print_xml: true }\n # class name of caller object\n klass_name = self.class.name.split('::').last\n # WSDL endpoint is derived from ClassName\n options = { wsdl: \"#{url}/#{klass_name}.asmx?WSDL\", namespaces: namespaces, soap_header: soap_header }\n # SOAP client\n Savon.client(options.merge(log_options))\n end", "def initialize(client)\n super(client, 'core')\n end", "def client; end", "def client; end", "def client\n @client ||= begin\n client_config = {\n wsdl: config.wsdl,\n namespace: config.soap_namespace,\n log_level: config.log_level,\n element_form_default: :qualified,\n namespaces: NAMESPACES\n }\n\n client_config[:proxy] = config.http_proxy if config.http_proxy.present?\n\n Savon::Client.new client_config\n end\n end", "def method_missing(method_name, *arguments, &block)\n client.send(method_name, *arguments, &block)\n end", "def service_request(service); end", "def initialize(client)\n @client = client\n end", "def client\n @client ||= Savon::Client.new do\n wsdl.document = File.expand_path(File.join(File.dirname(__FILE__), \"economic.wsdl\"))\n end\n end", "def create_client\n\nend", "def wrapper; end", "def initialize(username, password, api_key) \n @username = username\n @password = password\n @api_key = api_key\n @client = Savon.client(wsdl: BULLHORN_WSDL, log_level: :debug, pretty_print_xml: true)\n #@client = Savon.client(wsdl: BULLHORN_WSDL, log_level: :warn, pretty_print_xml: true)\n end", "def request(api_method, response_klass, my_params={})\n savon_client = setup_savon_client\n\n params = my_params.merge(login: VoipApi.account.login, secret: VoipApi.account.secret)\n\n # Invoke the call to the API\n begin\n puts YAML::dump(savon_client)\n # request = savon_client.build_request(api_method, message: params)\n # puts YAML::dump(request.body)\n # puts YAML::dump(request.headers)\n savon_response = savon_client.call(api_method, message: params)\n rescue Savon::Error => error\n Logger.log \"Savon Error Encountered: #{error.http.code} #{error.message}\"\n end\n\n if savon_response.success? && !savon_response.soap_fault? && !savon_response.http_error?\n # Have this get converted to the appropriate kind of savon_response\n if response_klass\n response_klass.new(savon_response)\n end\n end\n end", "def internal_client(client)\n @internal_client ||= client.with(\n auto_encryption_options: nil,\n min_pool_size: 0,\n monitoring: client.send(:monitoring),\n )\n end", "def initialize(client)\n self.client=client\n\n\tend", "def encryption_client; end", "def initialize\n # Note: Suds logging is disabled\n @soap_client = Suds.client(endpoint: ENDPOINT, namespace: NAMESPACE,\n soap_version: 1, wsdl: WSDL, log: false)\n end", "def init_client; end", "def initialize(client)\n\t self.client=client\n end", "def security_server_client\n end", "def client\n @client ||= ::Twilio::REST::Client.new(@account_sid, @auth_token)\n end", "def configure_savon(homepage_url,domain,username,password,self_signed_cert)\n puts \"Configuring Savon\" if @enable_debug_logging\n if !@enable_debug_logging\n Savon.configure do |config|\n config.log = false\n config.log_level = :error\n HTTPI.log = false\n end\n end\n\n # Create the client\n site = homepage_url + \"_vti_bin/Lists.asmx?wsdl\"\n username = domain + \"\\\\\" + username\n client = Savon::Client.new do |wsdl,http,wsse|\n http.auth.basic username, password\n wsdl.document = site\n end\n\n # A self-signed certificate will not verify, so this ssl verify is turned\n # off so that openssl doesn't throw on excpetion when testing with a\n # self-signed certificate\n client.http.auth.ssl.verify_mode = :none if @info_values['self-signed_cert'].downcase == \"true\"\n\n return client\n end", "def client\n end", "def call\n define_methods_into(@client)\n define_classes\n end", "def method_missing(name, *args, &block) # rubocop:disable Style/MethodMissingSuper, Style/MissingRespondToMissing\n client.public_send(name, *args, &block)\n end", "def initialize(guid = nil, options = {})\n self.errors = []\n self.guid = guid\n self.proxy = options[:proxy]\n\n # savon client options\n self.client_options = { wsdl: SOAP_API_WSDL_URL }\n client_options[:proxy] = proxy if proxy\n end", "def service_endpoint; end", "def service_endpoint; end", "def unsupported_client\n\n end", "def initialize(**options)\n @api_client = PayPoint::Blue::API.new(**options)\n super\n end", "def request(*)\n raise 'HttpApiBuilder::BaseClient#request must be implemented, see documentation'\n end", "def auth_client\n raise NOT_IMPLEMENTED_ERROR\n end", "def initialize\n # URL and TIMEOUT_SECONDS are defined in\n # config/initializers/movies_service_client_config.rb\n @client = ActionWebService::Client::XmlRpc.new(\n MoviesApi, \n ENDPOINT_URL, \n {:handler_name => 'movies_service', :timeout => TIMEOUT_SECONDS}\n )\n end", "def initialize(client)\n @client = client\n end", "def initialize(client)\n @client = client\n end", "def initialize(client)\n @client = client\n end", "def initialize(client)\n @client = client\n end", "def initialize(client)\n @client = client\n end", "def initialize(client)\n @client = client\n end", "def initialize(client)\n @client = client\n end", "def initialize(client)\n @client = client\n end", "def initialize(client)\n @client = client\n end", "def initialize(client)\n @client = client\n end", "def initialize(client)\n @client = client\n end", "def initialize(client)\n @client = client\n end", "def initialize(client)\n @client = client\n end", "def initialize(client)\n @client = client\n end", "def initialize(client)\n @client = client\n end", "def initialize(client)\n @client = client\n end", "def initialize(client)\n @client = client\n end", "def initialize(client)\n @client = client\n end", "def initialize(client)\n @client = client\n end", "def initialize(client)\n @client = client\n end", "def initialize(client)\n @client = client\n end", "def initialize(client)\n @client = client\n end", "def initialize(client)\n @client = client\n end", "def initialize(client)\n @client = client\n end", "def initialize(client)\n @client = client\n end", "def initialize(client)\n @client = client\n end", "def initialize(client)\n @client = client\n end", "def initialize(client)\n @client = client\n end", "def initialize(client)\n @client = client\n end", "def initialize(client)\n @client = client\n end", "def initialize(client)\n @client = client\n end", "def initialize(client)\n @client = client\n end", "def initialize(client)\n @client = client\n end", "def initialize(client)\n @client = client\n end", "def initialize(client)\n @client = client\n end", "def initialize(client)\n @client = client\n end", "def initialize(client)\n @client = client\n end", "def initialize(client)\n @client = client\n end", "def initialize(client)\n @client = client\n end", "def initialize(client)\n @client = client\n end", "def initialize(client)\n @client = client\n end", "def initialize(client)\n @client = client\n end", "def initialize(client)\n @client = client\n end" ]
[ "0.6878374", "0.6774605", "0.66199154", "0.65472716", "0.6526434", "0.64873487", "0.643791", "0.6412938", "0.6331157", "0.63168603", "0.6292211", "0.628581", "0.6259567", "0.6238324", "0.6203991", "0.61314803", "0.61314803", "0.6021638", "0.60110563", "0.6002162", "0.59782755", "0.59782755", "0.59782755", "0.59766513", "0.59672385", "0.5915919", "0.59004116", "0.5869638", "0.5869638", "0.58620507", "0.5837849", "0.5782415", "0.57497907", "0.5684239", "0.5682618", "0.56797606", "0.56742865", "0.5653081", "0.5607801", "0.5593821", "0.5588211", "0.5579374", "0.55681634", "0.5542975", "0.55393595", "0.5538686", "0.5537854", "0.55235755", "0.5514551", "0.5514521", "0.5512486", "0.5510616", "0.5510616", "0.5507052", "0.54907244", "0.5442812", "0.5413869", "0.53938603", "0.53852826", "0.53852826", "0.53852826", "0.53852826", "0.53852826", "0.53852826", "0.53852826", "0.53852826", "0.53852826", "0.53852826", "0.53852826", "0.53852826", "0.53852826", "0.53852826", "0.53852826", "0.53852826", "0.53852826", "0.53852826", "0.53852826", "0.53852826", "0.53852826", "0.53852826", "0.53852826", "0.53852826", "0.53852826", "0.53852826", "0.53852826", "0.53852826", "0.53852826", "0.53852826", "0.53852826", "0.53852826", "0.53852826", "0.53852826", "0.53852826", "0.53852826", "0.53852826", "0.53852826", "0.53852826", "0.53852826", "0.53852826", "0.53852826", "0.53852826" ]
0.0
-1
returns true if the two cuboids intersect each other. False otherwise.
def intersects?(other) raise "NOT A CUBOID" unless other.is_a? Cuboid self_range = range_finder other_range = other.range_finder self_range.each do |k,_| return false unless overlap?(self_range[k], other_range[k]) end true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def intersects?(other_cuboid)\n\t\toverlaps_along_x_with?(other_cuboid) && overlaps_along_y_with?(other_cuboid) && overlaps_along_z_with?(other_cuboid)\n\tend", "def intersects?(cuboid)\n return true if self == cuboid\n !left_face_is_right_of_other_right_face(cuboid) &&\n !right_face_is_left_of_other_left_face(cuboid) &&\n !top_face_is_below_other_bottom_face(cuboid) &&\n !bottom_face_is_above_other_top_face(cuboid) &&\n !front_face_is_behind_other_back_face(cuboid) &&\n !back_face_is_front_other_front_face(cuboid)\n end", "def intersects?(cuboid)\n cuboid.vertices.each do |vertex|\n if self.contains?(vertex) || self.touches?(vertex)\n return true\n end\n end\n return false\n end", "def intersects?(other)\n return false if separate? other\n return false if contained? other\n return false if coincident? other\n true\n end", "def intersects?(other)\n self_index = dimensions(self.vertices)\n other_index = dimensions(other.vertices)\n\n intersection = {}\n intersection[:x] = self_index[:x] & other_index[:x]\n intersection[:y] = self_index[:y] & other_index[:y]\n intersection[:z] = self_index[:z] & other_index[:z]\n\n intersection.value?([]) ? false : true\n end", "def intersects?(other)\n if !(self.x2 < other.x1) &&\n !(other.x2 < self.x1) &&\n !(self.y2 < other.y1) &&\n !(other.y2 < self.y1) &&\n !(self.z2 < other.z1) &&\n !(other.z2 < self.z1)\n return true\n else\n return false\n end\n end", "def intersects?(other)\n other.vertices.each do |vertex|\n return true if interior?(vertex)\n end\n false\n end", "def intersects?(other)\n return false if self.xMax < other.xMin\n return false if self.xMin > other.xMax\n return false if self.yMax < other.yMin\n return false if self.yMin > other.yMax\n return false if self.zMax < other.zMin\n return false if self.zMin > other.zMax\n true\n end", "def intersects?(other)\n !!intersection_with(other)\n end", "def intersects?(other)\n if origin <= other.origin\n vertices.each { |vertex| return true if vertex > other.origin }\n else\n other.vertices.each { |vertex| return true if vertex > origin }\n end\n false\n end", "def intersects?(other)\n return false if self.equal?(other)\n !(above?(other) || below?(other) || right_of?(other) || left_of?(other) || behind?(other) || in_front_of?(other))\n end", "def colliding?(block)\n x2 > block.x1 &&\n x1 < block.x2 &&\n y2 > block.y1 &&\n y1 < block.y2 &&\n z2 > block.z1 &&\n z1 < block.z2\n end", "def collision_detected?\n ($boxes - Array(self)).any? do |other_box|\n # .include method with other_square\n other_box.include?(@square)\n end\nend", "def intersects?(other)\n# (@x <= other.x_outer && other.x <= @x_outer) || (@y <= other.y_outer && other.y <= @y_outer) ||\n# (@z <= other.z_outer && other.z <= @z_outer)\n\n\n (other.x < (@x + @l)) && ((other.x + other.l) > @x) &&\n (other.y < (@y + @w)) && ((other.y + other.w) > @y) &&\n (other.z < (@z + @h)) && ((other.z + other.h) > @z)\n\n end", "def intersects?(other)\n horizontal_intersection = self.horizontal_intersection?(other)\n vertical_intersection = self.vertical_intersection?(other)\n within_z_index_range = self.within_z_index_range?(other)\n\n return within_z_index_range && vertical_intersection && horizontal_intersection\n\n end", "def intersects?(other)\n (@x <= other.x_max && other.x <= @x_max) &\n (@y <= other.y_max && other.y <= @y_max) &\n (@z <= other.x_max && other.z <= @z_max)\n end", "def coincident?(other)\n center.distance(other.center) == 0 and @r == other.r\n end", "def crossing?(other); end", "def crossing?(other); end", "def crossing?(other); end", "def are_colliding?(obj1, obj2)\n obj1.center_x == obj2.center_x && obj1.center_y == obj2.center_y\n end", "def included_in?(other_rect)\n self == self.intersects(other_rect)\n end", "def ==(cube) # :nodoc:\n @vbits == cube.bits\n end", "def collision_between obj1, obj2\n\t\t\tif obj1.y + obj1.height < obj2.y ; return false ; end\n\t\t\tif obj1.y > obj2.y + obj2.height ; return false ; end\n\t\t\tif obj1.x + obj1.width < obj2.x ; return false ; end\n\t\t\tif obj1.x > obj2.x + obj2.width ; return false ; end\n\t\t\treturn true\n\t\tend", "def intersects?(r2)\n if @p2.x <= r2.p1.x or r2.p2.x <= @p1.x \n return false\n elsif @p2.y >= r2.p1.y or r2.p2.y >= @p1.y\n end\n return true\n end", "def intersect? rect\n rect.is_a?(Rectangle) && !(@x + @width < rect.x || rect.x + rect.width < @x || @y + @height < rect.y || rect.y + rect.height < @y)\n end", "def collide?(other)\r\n max_left = [left, other.left].max\r\n max_top = [top, other.top].max\r\n min_right = [right,other.right].min\r\n min_bottom = [bottom,other.bottom].min\r\n return max_left <= min_right && max_top <= min_bottom\r\n end", "def overlap?(object1, object2)\n\t#upper left corner\n\tlx1 = object1.x\n\tly1 = object1.y\n\n\tlx2 = object2.x\n\tly2 = object2.y\n\t\n\t#lower right corner\n\trx1 = object1.x + object1.class::WIDTH\n\try1 = object1.y + object1.class::HEIGHT\n\n\trx2 = object2.x + object2.class::WIDTH\n\try2 = object2.y + object2.class::HEIGHT\n\n\tif rx1 - lx2 < 5 or\n\t\t\trx2 - lx1 < 5 then\n\t\treturn false\n\tend\n\n\tif ry1 - ly2 < 5 or\n\t\t\try2 - ly1 < 5 then\n\t\treturn false\n\tend\n\n\treturn true\nend", "def ==(c) \n (@x == c.x) && (@y == c.y)\n end", "def crossing?(other)\n return false unless overlaps?(other)\n (@begin_pos <=> other.begin_pos) * (@end_pos <=> other.end_pos) == 1\n end", "def eql?(other_grid)\n return @id == other_grid.id\n #return @id == other_grid.id\n #result = false\n #if other_grid.x == @x && other_grid.y == @y \n # result = true\n # for y in 0...other_grid.y do\n # for x in 0...other_grid.x do\n # unless other_grid.block(x, y) == self.block(x, y)\n#\t result = false\n#\t break\n#\t end\n#\tend\n# end\n# end\n# result\n end", "def collides?(object2); radius_collision?(object2); end", "def ==(other_grid)\n return @id == other_grid.id\n #result = false\n #if other_grid.x == @x && other_grid.y == @y \n # result = true\n # for y in 0...other_grid.y do\n # for x in 0...other_grid.x do\n # unless other_grid.block(x, y) == self.block(x, y)\n # \t result = false\n # break\n # \t end\n # \tend\n # end\n # end\n # result\n end", "def collide(block)\n return (block.x == @x && block.y == @y)\n end", "def ==(other_envelope)\r\n if other_envelope.class != self.class\r\n false\r\n else\r\n upper_corner == other_envelope.upper_corner and lower_corner == other_envelope.lower_corner\r\n end\r\n end", "def disjoint?(*args)\n not intersects?(*args)\n end", "def contained?(other)\n center.distance(other.center) < (@r - other.r).abs\n end", "def disjoint?(other); end", "def disjoint?(other); end", "def disjoint?(other); end", "def intersects?(tile)\n return false if tile.id == @id\n # pp rotated_side\n rotated_sides.any? { |side| tile.sides.any? { |their_side| their_side[:side] == side[:side] } }\n end", "def collision?(other)\n Gosu::distance(@x, @y, other.x, other.y) < @radius * @size + other.radius * other.size\n end", "def intersect?(obj)\n obj.x + obj.w > @x && obj.x < @x + @w &&\n (@inverted ? obj.y < get_y(obj) && obj.y + obj.h > @y : obj.y > get_y(obj) && obj.y < @y + @h)\n end", "def intersect?(other_set)\n requires_set(other_set, __method__)\n intersection(other_set).any?\n end", "def disjoint?(other)\n horizontally_disjoint?(other) || vertically_disjoint?(other)\n end", "def collides?(other)\n !(\n @pos.x + width <= other.pos.x ||\n @pos.x >= other.pos.x + other.width ||\n @pos.y + height <= other.pos.y ||\n @pos.y >= other.pos.y + other.height\n )\n end", "def intersects? other\n\t\t\t\tother.any?{|path| include?(path)}\n\t\t\tend", "def intersects?(other)\n @origin.keys.each do |axis|\n return false unless min_lte_max(axis, other) && max_gte_min(axis, other)\n end\n true\n end", "def contains?(other)\n other.corners.all? { |corner| includes_point?(corner) }\n end", "def fully_includes?(other)\n overlaps?(other) && other == intersection(other)\n end", "def parallel?(other)\n cross(other).magnitude == 0\n end", "def ==(other)\n if other.is_a?(Moon::Rect)\n x == other.x && y == other.y && w == other.w && h == other.h\n else\n false\n end\n end", "def ==(other)\n if other.is_a?(Moon::Rect)\n x == other.x && y == other.y && w == other.w && h == other.h\n else\n false\n end\n end", "def intersect?(triangle, lines)\n line1 = [triangle[0], triangle[2]]\n line2 = [triangle[1], triangle[2]]\n \n lines.any? do |line|\n \n int1 = Geom.intersect_line_line line, line1\n int2 = Geom.intersect_line_line line, line2\n \n intersected = false\n \n if(!int1.nil?)\n puts \"#{line1.inspect} intersect #{line.inspect} at #{int1.inspect}\"\n intersected = true if(in_box(line1, int1) && in_box(line, int1))\n end\n \n if (!int2.nil?)\n puts \"#{line2.inspect} intersect #{line.inspect} at #{int2.inspect}\"\n intersected = true if(in_box(line2, int2) && in_box(line, int2))\n end\n \n intersected\n end\n end", "def eql?(other)\n @left == other.left && @middle == other.middle && @right == other.right\n end", "def intersects_plane?(inst1,t1,plane_group,t2)\n #we will perform a test intersection to see if any new edges were created.\n if @helper_group==nil\n @helper_group=Sketchup.active_model.active_entities.add_group #this group will contain the edges from the test intersection\n @helper_group.entities.add_cpoint([0,0,0]) #adding a construction point to ensure that this group contains something to avoid automatic deletion by SketchUp\n end\n ents1=get_entities(inst1)\n ents2=@helper_group.entities\n new_edges=ents1.intersect_with(false,t1,ents2,@helper_group.transformation,false,[plane_group])\n\n if new_edges.length>0 #if new edges were created by the intersection\n return true\n else\n return false\n end\n end", "def checkCollision?(other)\n refresh()\n other.refresh()\n \n xMin = @center_left[X]\n xMax = @center_right[X]\n yMin = @center_bottom[Y]\n yMax = @center_top[Y]\n\n xMax > other.center_left[X] && xMin < other.center_right[X] && \n yMin > other.center_top[Y] && yMax < other.center_bottom[Y]\n end", "def test_obb_vs_obb(rect_a, rect_b)\n @coll_depth = Numeric::POSITIVE_INFINITY\n 2.times do |i|\n axis_a = rect_a.axes[i]\n depth_a = test_intervals(rect_a.projection(axis_a), rect_b.projection(axis_a))\n return false if depth_a == 0\n\n axis_b = rect_b.axes[i]\n depth_b = test_intervals(rect_a.projection(axis_b), rect_b.projection(axis_b))\n return false if depth_b == 0\n\n abs_a = depth_a.abs\n abs_b = depth_b.abs\n\n if abs_a < @coll_depth.abs or abs_b < @coll_depth.abs\n altb = abs_a < abs_b\n @coll_normal = altb ? axis_a : axis_b\n @coll_depth = altb ? depth_a : depth_b\n end\n end\n\n @cpa = rect_a\n @cpb = rect_b\n true\n end", "def collide?(object)\n return false if object == self\n\n hitbox_a = case @direction\n when :down\n hitbox(0, rad_y)\n when :up\n hitbox(0, -rad_y)\n when :right\n hitbox(rad_x, 0)\n when :left\n hitbox(-rad_x, 0)\n end\n hitbox_b = object.hitbox\n\n # Return true if the hitboxes overlap\n (hitbox_a[0] & hitbox_b[0]).any? &&\n (hitbox_a[1] & hitbox_b[1]).any?\n end", "def overlap(first_rect, second_rect)\n a1 = first_rect[0]\n a2 = first_rect[1]\n b1 = second_rect[0]\n b2 = second_rect[1]\n\n if b1[0] < a2[0] && b1[1] < a2[1]\n return true\n else \n return false\n end\n\nend", "def ==(other)\n other.kind_of?(Vector3D) &&\n other.x == x && other.y == y && other.z == z\n end", "def c2?(g,u)\n ok = false\n g.adjacent_vertices(u).each do |v| \n if (@l[v] == nil or @l[v] == 'inf')\n\tg.adjacent_vertices(v).each do |z|\n\t if @l[z] == @i.to_s\n\t ok = true\n\t break\n\t end # if\n\t ok = false\n\tend # do\n\tif ok == false\n\t return false\n\tend # if\n end # if\n end # do\n return true\n end", "def ==(other)\n return false unless other.is_a?(Client)\n cluster == other.cluster && options == other.options\n end", "def ==(other)\n return false unless other.is_a?(Client)\n cluster == other.cluster && options == other.options\n end", "def collide_rect?(other_rect)\n !intersects(other_rect).empty?\n end", "def testLigneContient(a,a2)\n\t\t0.upto(a.size-1) do |x|\n\t\t\tif a[x].couleur != a2[x].couleur && a2[x].couleur != Tuile.getCouleurVide \n\t\t\t\treturn false\n\t\t\tend\n\t\tend\n\t\treturn true\n\n\tend", "def overlapping?(left, right)\n (tuples(left) & tuples(right)).any?\n end", "def same_pos?(pos1, pos2)\n pos1 = pos1.pos if pos1.respond_to?(:pos)\n pos2 = pos2.pos if pos2.respond_to?(:pos)\n pos1.x == pos2.x and pos1.y == pos2.y and pos1.z == pos2.z\n end", "def same_pos?(pos1, pos2)\n pos1 = pos1.pos if pos1.respond_to?(:pos)\n pos2 = pos2.pos if pos2.respond_to?(:pos)\n pos1.x == pos2.x and pos1.y == pos2.y and pos1.z == pos2.z\n end", "def same?(other)\n (from_end == other.from_end and\n to_end == other.to_end and\n overlap == other.overlap)\n end", "def same?(other)\n (from_end == other.from_end and\n to_end == other.to_end and\n overlap == other.overlap)\n end", "def ==(other)\n return false unless other.is_a? Normal3\n @x == other.x && @y == other.y && @z == other.z\n end", "def intersect?(r)\n @x < r.x + r.w && @x + @w > r.x && @y < r.y + r.h && @y + @h > r.y\n end", "def contained?(other); end", "def contained?(other); end", "def contained?(other); end", "def iscrossing(pt1,pt2, theface)\r\n line = [pt1, pt2]\r\n theface.loops.each { |loop|\r\n edges = loop.edges\r\n edges.each { |e| #check each edge to see if it intersects line inside the edge\r\n l2 = [e.vertices[0].position, e.vertices[1].position] # make a line\r\n point = Geom.intersect_line_line(line, e.vertices) # find intersection\r\n if (point != nil)\r\n online1 = isonline(point, line[0], line[1]) # is the point on the line\r\n online2 = isonline(point, e.vertices[0].position, e.vertices[1].position) # is the point on the edge\r\n #ent.add_cpoint(point) if (online1 and online2)\r\n #puts \"online1 #{online1} #{online2}\"\r\n return true if (online1 and online2)\r\n # if (online1 and online2) then we can return true here, no need to process more\r\n end\r\n } # edges.each\r\n } # loops.each\r\n return false\r\n end", "def collide\n # For each block of the shape, check if it collides with\n # another block in the game.\n get_blocks.each do |block|\n collision = block.collide_with_other_blocks;\n if (collision)\n return true\n end\n end\n\n # Check if the shape collide with main windows\n bounds = get_bounds\n \n if ( bounds[3] > @game.height )\n return true\n end\n \n if ( bounds[2] > @game.width )\n return true\n end\n \n if ( bounds[0] < 0 )\n return true\n end \n return false\n end", "def vt_intersects?(*args)\n vt_range.intersects?(*args)\n end", "def isCollidedWith(obj)\n if(self == obj)\n return false ;\t\t\t\n end\n\n r = @pos.distanceTo(obj.pos) ;\t\n l = @size + obj.size ;\t\t\n\n return (r < l) ;\t\t\n end", "def deuce?\n @player1.points == 3 && @player2.points == 3\n end", "def overlaps?(other); end", "def overlaps?(other); end", "def overlaps?(other); end", "def ==(comp)\n comp.x === x && comp.y === y\n end", "def coprime?(num_1, num_2)\n arr1 = factors(num_1)\n arr2 = factors(num_2)\n final = arr1 & arr2 # & is the intersection of two arrays.\n if final.length != 0\n return false\n else\n return true\n end\nend", "def similar_to?(other)\n self.composition == other.composition\n end", "def pieces_equal?(piece1, piece2)\n return true if piece1.empty? && piece2.empty?\n return false if piece1.empty? || piece2.empty?\n\n if piece1.class.superclass == BasicPiece && piece2.class.superclass == BasicPiece\n if piece1.class == piece2.class &&\n piece1.color == piece2.color &&\n piece1.position == piece2.position\n return true\n end\n end\n\n false\nend", "def intersects?(another_geometry)\n raise Error::UnsupportedOperation, \"Method Geometry#intersects? not defined.\"\n end", "def test_intersect1\n # Testing pathological cases: Intersect one cube against another offset.\n model = Sketchup.active_model\n entities = model.entities\n pts = []\n pts[0] = [0, 0, 0]\n pts[1] = [100, 0, 0]\n pts[2] = [100, 100, 0]\n pts[3] = [0, 100, 0]\n\n #Test instance.intersect\n definition = model.definitions.add(\"component\")\n # Add the face to the entities in the group\n face = definition.entities.add_face pts\n status = face.pushpull -100, true\n\n origin = Geom::Point3d.new 0, 0, 0\n transform = Geom::Transformation.new origin\n point = Geom::Point3d.new 0, 25, 0\n t = Geom::Transformation.new point\n\n golden = entities.add_group\n\n pts1 = []\n pts1[0] = [0, 0, 0]\n pts1[1] = [100, 0, 0]\n pts1[2] = [100, 75, 0]\n pts1[3] = [0, 75, 0]\n\n # Add the face to the entities in the group\n face = golden.entities.add_face pts1\n\n status = face.pushpull -100, true\n\n golden.transform! t\n instance1 = entities.add_instance definition, transform\n instance2 = instance1.copy\n instance2.move! t\n\n intersection = instance1.intersect(instance2)\n assert(golden.equals?(intersection), 'instance.intersect failed')\n end", "def ==(other)\n result = (other.x == x && other.y == y && other.z == z)\n # puts \"(#{other.x} == #{x} && #{other.y} == #{y} && #{other.z} == #{z}) = #{result.inspect}\"\n result\n end", "def collision? args\n #The minimum area enclosed by the center of the ball and the 2 corners of the block\n #If the area ever drops below this value, we know there is a collision\n min_area = ((@block_size * 3) * args.state.ball.radius) / 2\n\n #https://www.mathopenref.com/coordtrianglearea.html\n ax = @x1\n ay = @y1\n bx = @x2\n by = @y2\n cx = args.state.ball.center.x\n cy = args.state.ball.center.y\n\n current_area = (ax*(by-cy)+bx*(cy-ay)+cx*(ay-by))/2\n\n collision = false\n if @rotation >= 0\n if (current_area < min_area &&\n current_area > 0 &&\n args.state.ball.center.y > @y1 &&\n args.state.ball.center.x < @x2)\n\n collision = true\n end\n else\n if (current_area < min_area &&\n current_area > 0 &&\n args.state.ball.center.y > @y2 &&\n args.state.ball.center.x > @x1)\n\n collision = true\n end\n end\n\n return collision\n end", "def eql?(other)\n return false unless other.captures_hash == captures_hash\n return false unless other.squares_hash == squares_hash\n return false unless other.turn == turn\n return false unless other.state == state\n\n true\n end", "def eql?(other)\n (@x == other.x) && (@y == other.y)\n end", "def ==(other)\n other.x == @x && other.y == @y\n end", "def include?(other_square)\n # top left\n @square.contains?(other_square.x1, other_square.y1) || \n # top right\n @square.contains?(other_square.x1, other_square.y2) || \n # bottom right\n @square.contains?(other_square.x1, other_square.y3) || \n # bottom left\n @square.contains?(other_square.x1, other_square.y4) \nend", "def overlap(first_rectangle, second_rectangle)\n\tfirst_rectangle_x1 = first_rectangle[0][0]\n\tfirst_rectanlge_y1 = first_rectangle[0][1]\n\tfirst_rectangle_x2 = first_rectangle[1][0]\n\tfirst_rectanlge_y2 = first_rectangle[1][1]\n\n\tsecond_rectangle_x1 = second_rectangle[0][0]\n\tsecond_rectanlge_y1 = second_rectangle[0][1]\n\tsecond_rectangle_x2 = second_rectangle[1][0]\n\tsecond_rectanlge_y2 = second_rectangle[1][1]\n\n\tif first_rectangle_x1 < second_rectangle_x2 && first_rectangle_x2 > second_rectangle_x1 && first_rectanlge_y1 < second_rectanlge_y2 && first_rectanlge_y2 > second_rectanlge_y1\n\t\treturn true\n\telse\n\t\treturn false\n\tend\nend", "def scene_collision?\n return false unless solid?\n scene = Gamework::App.current_scene\n return false if scene.nil?\n\n scene.solid_objects.any? {|object| collide?(object)}\n end", "def overlaps?(other)\n !disjoint?(other)\n end", "def overlaps?(other)\n !disjoint?(other)\n end" ]
[ "0.78990805", "0.76804894", "0.7523567", "0.70820683", "0.70796764", "0.6934062", "0.6906339", "0.68007666", "0.6741866", "0.6598876", "0.6483527", "0.6462282", "0.64231575", "0.6355845", "0.6319558", "0.6306597", "0.6286855", "0.6268682", "0.6268682", "0.6268682", "0.6259042", "0.6226046", "0.62001604", "0.6183575", "0.6138047", "0.6080084", "0.60753834", "0.6063483", "0.6031614", "0.5984925", "0.5982849", "0.5982005", "0.5956904", "0.5948311", "0.5938184", "0.59270656", "0.591846", "0.5917463", "0.5917463", "0.5917463", "0.59113294", "0.58884573", "0.58802646", "0.58703655", "0.5862585", "0.5852675", "0.584438", "0.5834448", "0.5817375", "0.5794663", "0.57885706", "0.5757734", "0.5757734", "0.575593", "0.574239", "0.5738172", "0.5733039", "0.57183707", "0.5702398", "0.5699178", "0.5698288", "0.5676972", "0.5657628", "0.565646", "0.5655507", "0.56525326", "0.56496", "0.56383556", "0.56383556", "0.561625", "0.561625", "0.56115437", "0.56071544", "0.5606568", "0.5606568", "0.5606568", "0.5601089", "0.5599473", "0.5594699", "0.5583596", "0.5570795", "0.55702764", "0.55702764", "0.55702764", "0.55697274", "0.55664885", "0.55613977", "0.55610186", "0.55539584", "0.55527854", "0.55482304", "0.55338717", "0.5530061", "0.55273795", "0.5520432", "0.55116117", "0.54886556", "0.5477329", "0.5477139", "0.5477139" ]
0.725815
3
rotates along given axis
def rotate!(axis) raise "INVALID AXIS" unless ["x", "y", "z"].include?(axis.to_s) case axis when "x" @origin[2] -= height @origin[2] = 0 if z < 0 @dimensions[1], @dimensions[2] = depth, height when "y" @origin[2] -= width @origin[2] = 0 if z < 0 @dimensions[0], @dimensions[2] = depth, width when "z" @origin[1] -= width @origin[1] = 0 if y < 0 @dimensions[0], @dimensions[1] = height, width end true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rotate!(axis)\n center = [origin[X]+width/2, origin[Y]+height/2, origin[Z]+length/2]\n case axis\n when :x\n self.height, self.length = self.length, self.height\n when :y\n self.width, self.length = self.length, self.width\n when :z\n self.width, self.height = self.height, self.width\n end\n self.origin = [center[X]-width/2, center[Y]-height/2, center[Z]-length/2]\n end", "def rotate!(axis = :x)\n case axis\n when :x\n self.move_to!(@origin_x, @origin_y, @origin_z + @height)\n @width, @height = @height, @width\n when :y\n self.move_to!(@origin_x + @height, @origin_y, @origin_z)\n @length, @height = @height, @length\n when :z\n self.move_to!(@origin_x + @width, @origin_y, @origin_z)\n @width, @length = @length, @width\n end\n end", "def rotate(angle, axis)\n axis = axis.normalize if axis.length != 1.0\n cos0 = Math.cos(angle)\n cos1 = 1 - cos0\n sin0 = Math.sin(angle)\n xval = ((cos0 + (axis.x * axis.x) * cos1) * @x) + (((axis.x * axis.y * cos1) - (axis.z * sin0)) * @y) + (((axis.x * axis.z * cos1) + (axis.y * sin0)) * @z)\n yval = (((axis.x * axis.y * cos1) + (axis.z * sin0)) * @x) + ((cos0 + (axis.y * axis.y) * cos1) * @y) + (((axis.y * axis.z * cos1) - (axis.x * sin0)) * @z)\n zval = (((axis.x * axis.z * cos1) - (axis.y * sin0)) * @x) + (((axis.y * axis.z * cos1) + (axis.x * sin0)) * @y) + ((cos0 + (axis.z * axis.z) * cos1) * @z)\n AVector.new(xval, yval, zval)\n end", "def rotate_by(angle, axis)\n\t\t# rotate only if cuboid is rotatable\n\t\t# determine the new dimensions for the cuboid from the old position and the given angle and axis of rotation\n\t\t# To achieve this, hold the index corresponding to the given 'axis' fixed and swap the other two idices. This is because there will be no change in dimensions in the axis of rotation. The other two indices are swapped beacuse they are perpendicular to each other and the angle of rotation is 90 degrees per rotation. The direction of rotation will be determined by the sign of the angle, where I take positive angles to be clockwise and negative angles to be counter-clockwise\n\t\tnum_of_rotations = angle.abs / 90 # determine how many roations to make\n\n\t\twhile num_of_rotations > 0 \n\t\t\tpivot = angle <= 0 ? (-1) : 1 # determine the sign from the angle. The pivot will either roatate towards the origin (0,0,0) or away from it\n\t\t\tif axis == 0\n\t\t\t\t@curr_origin = [curr_origin[0], curr_origin[1], curr_origin[2] + dimensions[2] * pivot]\n\t\t\t\t@dimensions = [dimensions[0], dimensions[2], dimensions[1]]\n\t\t\telsif axis == 1\n\t\t\t\t@curr_origin = [curr_origin[0] + dimensions[0] * pivot, curr_origin[1], curr_origin[2]]\n\t\t\t\t@dimensions = [dimensions[2], dimensions[1], dimensions[0]]\t\n\t\t\telse \n\t\t\t\t@curr_origin = [curr_origin[0], curr_origin[1] + dimensions[1] * pivot, curr_origin[2]]\n\t\t\t\t@dimensions = [dimensions[0], dimensions[1], dimensions[2]]\n\t\t\tend\n\n\t\t\tnum_of_rotations -= 1 # ignore angles smaller than 90 and round down thsoe greater than 90 to the nearest multiple of 90.\n\t\tend\n\n\t\t[@curr_origin, @dimensions] # return the curr_origin and dimensions to confirm rotation was successful\n\tend", "def axis_rotation( axis, angle ) \n\t\t\traise TypeError, \"no implicit conversion of %s to ODE::Vector\" unless\n\t\t\t\taxis.is_a?( ODE::Vector )\n\t\t\tangle = Float(angle)\n\n\t\t\tif len = axis.abs\n\t\t\t\ta = axis/len * sin( angle / 2.0 );\n\t\t\t\tself.class.new( a, cos(angle/2.0) )\n\t\t\telse\n\t\t\t\tself.class.identity\n\t\t\tend\n\t\tend", "def rotate(angle, axis_x = width / 2.0, axis_y = height / 2.0)\n clone.rotate!(angle, axis_x, axis_y)\n end", "def rotate direction, origin = Vector[0,0,0], angle\n @pos.rotate!(direction.to_v,origin.to_v,angle)\n end", "def rot90(k=1,axes=[0,1])\n case k % 4\n when 0\n view\n when 1\n swapaxes(*axes).reverse(axes[0])\n when 2\n reverse(*axes)\n when 3\n swapaxes(*axes).reverse(axes[1])\n end\n end", "def rotate!(angle, axis_x = width / 2.0, axis_y = height / 2.0)\n ptr = self.class.create_image_ptr(width, height, alpha_blending?)\n ::GD2::GD2FFI.send(:gdImageCopyRotated, ptr, image_ptr, axis_x.to_f, axis_y.to_f, 0, 0, width.to_i, height.to_i, angle.to_degrees.round.to_i)\n init_with_image(ptr)\n end", "def rotate_x(t)\n sin_t = sin(t)\n cos_t = cos(t)\n @matrix *= Matrix.rows(\n [[1, 0, 0],\n [0, cos_t, -sin_t],\n [0, sin_t, cos_t]])\n self\n end", "def Vector3dRotateXY(arg0, arg1)\n ret = _invoke(1610744170, [arg0, arg1], [VT_BYREF | VT_DISPATCH, VT_R8])\n @lastargs = WIN32OLE::ARGV\n ret\n end", "def update_origin_by_axis(in_axis)\n temp_ik = IKres.new( in_axis.a0, in_axis.a1 , in_axis.a2 , in_axis.a3 , in_axis.a4 , in_axis.a5 )\n result_ik = MotionPlan.ik_step([@current_ik.a0, @current_ik.a1, @current_ik.a2, @current_ik.a3, @current_ik.a4, @current_ik.a5],\n [temp_ik.res_plane.origin.x, temp_ik.res_plane.origin.y, temp_ik.res_plane.origin.z],\n [temp_ik.res_plane.x_axis.x, temp_ik.res_plane.x_axis.y, temp_ik.res_plane.x_axis.z],\n [temp_ik.res_plane.y_axis.x, temp_ik.res_plane.y_axis.y, temp_ik.res_plane.y_axis.z]\n )\n # update(result_ik) if result_ik[:success]\n update_front(result_ik, in_axis) if result_ik[:success]\n end", "def rotate!(angle, *args)\n x, y, z = if args.length == 1 then [args[0].x, args[0].y, args[0].z]\n elsif args.length == 3 then [args[0], args[1], args[2]]\n elsif args.length == 4 then raise \"Four dimensional vector rotation is not yet implemented\"\n else raise \"Expected either a Vector3d or x, y and z arguments\"\n end\n\n\n # Calculate the sine and cosine of the angle once\n costheta = cos(angle)\n sintheta = sin(angle)\n\n # Find the new x position of the rotated vector\n rx = (costheta + (1 - costheta) * x * x) * self.x +\n ((1 - costheta) * x * y - z * sintheta) * self.y +\n\t ((1 - costheta) * x * z + y * sintheta) * self.z\n\n\t# Find the new y position for the new rotated point\n ry = ((1 - costheta) * x * y + z * sintheta) * self.x +\n\t (costheta + (1 - costheta) * y * y) * self.y +\n\t ((1 - costheta) * y * z - x * sintheta) * self.z\n\n\t# Find the new z position for the new rotated point\n\trz = ((1 - costheta) * x * z - y * sintheta) * self.x +\n\t ((1 - costheta) * y * z + x * sintheta) * self.y +\n\t (costheta + (1 - costheta) * z * z) * self.z\n\n self.x, self.y, self.z = rx, ry, rz\n self\n end", "def change_direction(axis)\n if axis == :x\n @velocity_x *= -1\n elsif axis == :y\n @velocity_y *= -1\n end \n end", "def rotate( vector )\n\t\t\t(self.inverse * self.class.new(vector) * self ).vec \n\t\tend", "def rotate!( *args )\n super( *args )\n reset_positions_inside\n end", "def rotate_origo(angle_x = 0, angle_y = 0, angle_z = 0)\n\t\[email protected] do |a|\n\t\t\ta.each do |b|\n\t\t\t\tx = b[0]; y = b[1]; z = b[2]\n\n\t\t\t\tx, y, z = rotate_point(x, y, z, 0, 0, 0, angle_x, angle_y, angle_z)\n\n\t\t\t\tb[0] = x; b[1] = y; b[2] = z\n\t\t\tend\n\t\tend\n\tend", "def rotate_matrix(arr)\n\nend", "def rotate!(radians)\n sin = Math.sin radians\n cos = Math.cos radians\n prev_x = @x\n @x = cos * @x - sin * @y\n @y = sin * prev_x + cos * @y\n end", "def rotate(axis = :x, walls = [])\n\n # check to see if there are already impedements\n walls.each do |wall|\n return false if self.intersects?(wall)\n end\n\n case axis\n when :x\n if !walls.empty?\n dist = Math.sqrt((@h/2) ** 2 + (@w/2) ** 2)\n temp = Cuboid.new(@origin, @l, dist, dist)\n\n walls.each do |wall|\n return false if temp.intersects?(wall)\n end\n end\n\n rotate_x\n\n when :y\n if !walls.empty?\n dist = Math.sqrt((@l/2) ** 2 + (@w/2) ** 2)\n temp = Cuboid.new(@origin, dist, @h, dist)\n\n walls.each do |wall|\n return false if temp.intersects?(wall)\n end\n end\n\n rotate_y\n\n when :z\n if !walls.empty?\n dist = Math.sqrt((@h/2) ** 2 + (@l/2) ** 2)\n temp = Cuboid.new(@origin, dist, dist, @w)\n\n walls.each do |wall|\n return false if temp.intersects?(wall)\n end\n end\n\n rotate_z\n else\n raise ArgumentError, \"Please use a symbol to identify the axis: :x, :y, or :z\"\n end\n\n self.vertices\n end", "def rotate(angle, around_x=0, around_y=0, &rendering_code); end", "def Matrix3dRotationFromPoint3dOriginXY(arg0, arg1, arg2)\n ret = _invoke(1610743912, [arg0, arg1, arg2], [VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH])\n @lastargs = WIN32OLE::ARGV\n ret\n end", "def rotate(arr)\n\nend", "def rot90\n rot :d90\n end", "def Point3dRotateXY(arg0, arg1)\n ret = _invoke(1610743864, [arg0, arg1], [VT_BYREF | VT_DISPATCH, VT_R8])\n @lastargs = WIN32OLE::ARGV\n ret\n end", "def rotate_matrix(array)\n\n\nend", "def rot #@\n a = pop\n b = pop\n c = pop\n push a\n push c\n push b\n end", "def my_rotate(arr)\n print arr.rotate\n end", "def rotate(angle, *args)\n begin\n case args.length\n when 0\n @transforms << [:rotate, [Float(angle)]]\n when 2\n cx = Float(args[0])\n cy = Float(args[1])\n @transforms << [:translate, [cx, cy]]\n @transforms << [:rotate, [angle]]\n @transforms << [:translate, [-cx, -cy]]\n else\n raise ArgumentError, \"wrong number of arguments (#{args.length} for 1 or 3)\"\n end\n rescue ArgumentError\n raise ArgumentError, \"arguments must be convertable to float (got #{[angle, *args].map(&:class).join(', ')})\"\n end\n yield(self) if block_given?\n self\n end", "def rotate(by = 1)\n return if @current_position.nil?\n index = DIRECTIONS.index(@current_position.dir)\n index = (index + by) % DIRECTIONS.length\n @current_position.dir = DIRECTIONS[index]\n end", "def array_rotation(arr, num)\n\tarr.rotate(num)\nend", "def rotate\n @angle += Math::PI / 16\n @angle = @angle % (Math::PI * 2)\n end", "def rotate(forward, upward)\n FMOD.type?(forward, Vector) unless forward.nil?\n FMOD.type?(upward, Vector) unless upward.nil?\n FMOD.invoke(:Geometry_SetRotation, self, forward, upward)\n end", "def transform(vec)\n return getRotationMatrix() * vec\n end", "def rotate!\n @grid = @grid.transpose.map{|c| c.reverse}\n end", "def rotate_array(aArray, off_x, off_y, rel_angle, change_in_place=false)\r\n # - - - - - - - - - - - - - - - - - - - - -\r\nend", "def Matrix3dFromAxisAndRotationAngle(arg0, arg1)\n ret = _invoke(1610743898, [arg0, arg1], [VT_I4, VT_R8])\n @lastargs = WIN32OLE::ARGV\n ret\n end", "def Transform3dIsTranslateRotateScaleRotate(arg0, arg1, arg2, arg3, arg4)\n ret = _invoke(1610744070, [arg0, arg1, arg2, arg3, arg4], [VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH])\n @lastargs = WIN32OLE::ARGV\n ret\n end", "def rotate_without_changing(arr)\n\nend", "def rotate!( angle_rad )\n self.angle += angle_rad\n self\n end", "def rot180\n rot :d180\n end", "def turn(view, time, axis, speed)\n # We want it to take 20 seconds for a full revolution\n return if( time >= 20.0)\n angle = Math::PI * time / 10.0\n angle *= speed\n\n # Create a transformation to rotate about axis through the eye position\n camera = view.camera\n eye = camera.eye\n target = camera.target\n up = camera.up\n t = Geom::Transformation.rotation(eye, axis, angle)\n target.transform! t\n up.transform! t\n camera.set eye, target, up\nend", "def mirror_angle_horizontally!\n @angle = (-@angle) % 360\n end", "def zrotation\n end", "def rotate_around_origin(angle)\n sin_of_angle = Math.sin(angle)\n cos_of_angle = Math.cos(angle)\n\n Point.new(\n x * cos_of_angle - y * sin_of_angle,\n x * sin_of_angle + y * cos_of_angle\n )\n end", "def rotate_x\n x = @x.content\n z = Array.new @z.length, 0\n\n @z.length.times { |i| z[i] = x[(i - 1) % @z.length] }\n\n @z.content = z\n end", "def rotation\n {\n axis: @r[0],\n angle: @r[1],\n matrix: @r[2]\n }\n end", "def rotate(x,y,theta)\n [x*-1*Math.cos(theta) + y*Math.sin(theta), x*-1*Math.sin(theta) + y*-1*Math.cos(theta)]\n end", "def rotate! pitch=0, yaw=0, roll=0\n\t\ta = pitch.respond_to?(:x) ? pitch.to_a : [pitch,yaw,roll]\n\t\t# create 3 quats for pitch, yaw, roll\n\t\t# and multiply those together to form a rotation quat\n\t\t# then apply it to the current quat to update it\n#\t\tsy, sp, sr = a.map { |x| Math.sin(x*@@pi360) }\n#\t\tcy, cp, cr = a.map { |x| Math.cos(x*@@pi360) }\n\t\tsp, sy, sr = a.map { |x| Math.sin(x*@@pi360) }\n\t\tcp, cy, cr = a.map { |x| Math.cos(x*@@pi360) }\n\t\tresult = normalize * Quat.new(\n\t\t\tcr*sp*cy + sr*cp*sy,\n\t\t\tcr*cp*sy - sr*sp*cy,\n\t\t\tsr*cp*cy - cr*sp*sy,\n\t\t\tcr*cp*cy + sr*sp*sy\n\t\t).normalize\n\t\t@x,@y,@z,@w = result.to_a\n\t\tself\n\tend", "def Matrix3dRotationFromRowZ(arg0)\n ret = _invoke(1610744146, [arg0], [VT_BYREF | VT_DISPATCH])\n @lastargs = WIN32OLE::ARGV\n ret\n end", "def test_rotate_90_degrees\n angle = 90\n new_transform = @subject.rotate(angle)\n\n assert_equal Vector2D.new(0, 0), new_transform.position\n assert_equal Vector2D.new(-2, 0), new_transform.target\n end", "def rotate(radians)\n sin = Math.sin radians\n cos = Math.cos radians\n Vector.new cos * @x - sin * @y, sin * @x + cos * @y\n end", "def rotateRight()\n twoTypeRotate()\n end", "def rotate_matrix(len, mtx)\n (0..(len / 2)).each do |layer|\n first = layer\n last = len - 1 - layer\n (first..last - 1).each do |i|\n top = mtx[first][i]\n mtx[first][i] = mtx[last - i][first] # TOP <-- LEFT\n mtx[last - i][first] = mtx[last][last - i] # LEFT <-- BOTTOM\n mtx[last][last - i] = mtx[i][last] # BOTTOM <-- RIGHT\n mtx[i][last] = top\n end\n end\n mtx\nend", "def rotate(vector, spaces)\n if spaces < vector.length && spaces > 0\n vector[0..(spaces-1)] = vector[0..(spaces-1)].reverse!\n vector[spaces..(vector.length-1)] = vector[spaces..(vector.length-1)].reverse!\n vector.reverse!\n else\n nil\n end\nend", "def rotate(angle_x = 0, angle_y = 0, angle_z = 0)\n\t\tc = 0; cx = 0; cy = 0; cz = 0\n\t\t# get middle point\n\t\[email protected] do |a|\n\t\t\ta.each do |b|\n\t\t\t\tcx += b[0]\n\t\t\t\tcy += b[1]\n\t\t\t\tcz += b[2]\n\t\t\t\tc +=1\n\t\t\tend\n\t\tend\n\t\tcx /= c; cy /= c; cz /= c\n\t\t# rotate points\n\t\[email protected] do |a|\n\t\t\ta.each do |b|\n\t\t\t\tx = b[0]; y = b[1]; z = b[2]\n\n\t\t\t\tx, y, z = rotate_point(x, y, z, cx, cy, cz, angle_x, angle_y, angle_z)\n\n\t\t\t\tb[0] = x; b[1] = y; b[2] = z\n\t\t\tend\n\t\tend\n\tend", "def rotate_x\n @w, @h = @h, @w\n end", "def turn_right\n @angle += ROTATION_SPEED\n end", "def test_rotate_360_degrees\n angle = 360\n new_transform = @subject.rotate(angle)\n\n assert_equal Vector2D.new(0, 0), new_transform.position\n assert_equal Vector2D.new(0, 2), new_transform.target\n end", "def rotate_around!(degrees, origin=Point.empty)\n result = rotate_around(degrees, origin)\n @x = result.x\n @y = result.y\n return result\n end", "def Matrix3dIsRotateScaleRotate(arg0, arg1, arg2, arg3)\n ret = _invoke(1610744069, [arg0, arg1, arg2, arg3], [VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH])\n @lastargs = WIN32OLE::ARGV\n ret\n end", "def rotate( rad )\n ca = Math.cos( rad )\n sa = Math.sin( rad )\n Vector[ ca*x - sa*y, sa*x + ca*y ]\n end", "def my_rotate(rotation = 1)\n # debugger\n answer = []\n each_with_index { |x, i| answer[i] = x }\n if rotation > 0\n rotation.times { answer.push(answer.shift) }\n elsif rotation == 0\n answer\n else\n rotation.abs.times { answer.unshift(answer.pop) }\n end\n answer\n end", "def rotate_image(arr)\n last_index = arr.size - 1\n\n # i will essentially act as our layer\n i = 0\n while i < (arr.size / 2)\n \n # column index, j, which should always start at the same index as the layer\n # to avoid moving outer-layer elements\n j = i\n\n # this makes sure j never iterates over the last element in the layer, because\n # it will have already been rotated from the first rotation in that layer\n # NOTE: this mistake can best be shown in a 5x5 or larger, if we forgot this\n layer_offset = last_index - i\n\n while j < (layer_offset) # last_index = arr[i].size - 1 because the array is square\n # debugger\n\n # store the value in the top row\n stored = arr[i][j]\n\n # rotate left to top\n arr[i][j] = arr[last_index - j][i]\n\n # rotate bottom to left\n arr[last_index - j][i] = arr[layer_offset][last_index - j]\n\n # rotate right to bottom\n arr[layer_offset][last_index - j] = arr[j][layer_offset]\n\n # rotate top to right by replacing right with stored\n arr[j][layer_offset] = stored\n\n j += 1\n end\n \n i += 1\n end\n\n # The submission code shouldn't include this, this is just to visualize the result\n p \"#{arr.size}x#{arr.size} Rotated Matrix\"\n arr.each do |row|\n p row\n end\nend", "def rotate matrix, direction\n direction == 'clockwise' ? matrix.reverse.transpose : matrix.transpose.reverse\nend", "def rotate\n g = Grid.new\n self.each do |point,v|\n g[Point.new(point.y,point.x)] = v\n end\n (0..g.height - 1).each do |y|\n ( 0..g.width/2.ceil - 1 ).each do |x|\n tmp = g[Point.new(x,y)]\n g[Point.new(x,y)] = g[Point.new(g.width - x - 1, y )]\n g[Point.new(g.width - x - 1,y)] = tmp\n end\n end\n g\n end", "def rotate_around!(degrees, origin=Point.empty)\n result = self.to_point.rotate_around(degrees, origin)\n self.x = result.x\n self.y = result.y\n return result\n end", "def rotate\n push shift\n end", "def rotate_matrix(arr)\n flipped_array = [] # initialize empty array\n transposed_arr = my_transpose(arr) # flip the rows with columns inside using a transpose method\n transposed_arr.each { |row| flipped_array << row.reverse } # once we reverse the new rows, it goes from 45 to 90 degrees rotation\n flipped_array\nend", "def test_rotate_negative_90_degrees\n angle = -90\n new_transform = @subject.rotate(angle)\n\n assert_equal Vector2D.new(0, 0), new_transform.position\n assert_equal Vector2D.new(2, 0), new_transform.target\n end", "def transform\n if rotate\n \"rotate(#{rotate},#{x},#{y})\"\n else\n nil\n end\n end", "def test_rotate_270_degrees\n angle = 270\n new_transform = @subject.rotate(angle)\n\n assert_equal Vector2D.new(0, 0), new_transform.position\n assert_equal Vector2D.new(2, 0), new_transform.target\n end", "def translate_origin(axis, offset)\n case axis\n when \"x\"\n axis = 0\n when \"y\"\n axis = 1\n when \"z\"\n axis = 2\n else\n # Raise error\n end\n\n result_ik = MotionPlan.nudge(axis, offset, [@current_ik.a0, @current_ik.a1, @current_ik.a2, @current_ik.a3, @current_ik.a4, @current_ik.a5])\n update(result_ik) if result_ik[:success]\n end", "def rotate_array(array,k,type=\"right\")\n puts \"Input array is\"\n p array\n reverse_array(array, 0, array.size-1)\n if type == \"right\"\n reverse_array(array,0,k-1)\n reverse_array(array,k,array.size-1)\n else\n reverse_array(array,0,k)\n reverse_array(array,k+1,array.size-1)\n end\n puts \"#{type} rotated array is\"\n p array\nend", "def rotate(command)\n turn = directions[@rover_facing]\n @rover_facing = command == 'L' ? turn.first : turn.last\n end", "def rotate(*args)\n with_command %(-rotate \"#{Geometry.new(*args)}\")\n end", "def rotate_x(\n theta # float\n) # mat3\n deg = degrees(theta).floor % 360\n if $rotation_memo[\"x#{deg}\"]\n return $rotation_memo[\"x#{deg}\"]\n end\n c = Math.cos(theta) # float\n s = Math.sin(theta) # float\n matrix = Mat3.new(\n Vec3.new(1, 0, 0),\n Vec3.new(0, c, -s),\n Vec3.new(0, s, c)\n );\n $rotation_memo[\"x#{deg}\"] = matrix\n matrix\nend", "def rotate(mesh, params = {})\n\traise StandardError, \":mesh is nil or not a TriMesh\" if (mesh.nil? or !(mesh.kind_of? TriMesh))\n\traise StandardError, \":degree is nil or not a Number\" if (params[:degree].nil? or !(params[:degree].is_a? Numeric))\n\traise StandardError, \"Define :axis with :x, :y, :z or as a Line\" if (params[:axis].nil?) or (not (params[:axis].kind_of? Symbol) and not (params[:axis].kind_of? Line))\n\traise StandardError, \":vector is not a Vector3\" if not (params[:vector].kind_of? Vector3 ) and not params[:vector].nil?\n\traise StandardError, \"Define :axis with :x, :y, :z\" if (params[:axis].kind_of? Symbol) and ((params[:axis] != :x) and (params[:axis] != :y) and (params[:axis] != :z))\n\traise StandardError, \"No vector is allowed if Line is defined\" if not (params[:vector].nil?) and (params[:axis].kind_of? Line)\n\n\t#assign Variables\n\tdegree = params[:degree] * Math::PI / 180\n\taxis = params[:axis]\n\t(vec = params[:vector].nil? ? (mesh.center) : params[:vector]) if axis.kind_of? Symbol\n\n\t#Do Rotation\n\t# Math.cos( degree * Math::PI/180 )\n\tif axis.kind_of? Symbol\n\t\tmesh = translate mesh, :vector => (vec * -1)\n\t\tnew_vecs = Array.new\n\t\tif axis == :x \n\t\t\tmesh.vertices.each do | vector |\n\t\t\t\ty = vector.y * Math.cos(degree) - vector.z * Math.sin(degree)\n\t\t\t\tz = vector.y * Math.sin(degree) + vector.z * Math.cos(degree)\n\t\t\t\tnew_vecs << (Vector3.new vector.x, y, z)\n\t\t\tend\n\t\telsif axis == :y \n\t\t\tmesh.vertices.each do | vector |\n\t\t\t\tx = vector.z * Math.sin(degree) + vector.x * Math.cos(degree)\n\t\t\t\tz = vector.z * Math.cos(degree) - vector.x * Math.sin(degree)\n\t\t\t\tnew_vecs << (Vector3.new x, vector.y, z)\n\t\t\tend\n\t\telsif axis == :z \n\t\t\tmesh.vertices.each do | vector |\n\t\t\t\tx = vector.x * Math.cos(degree) - vector.y * Math.sin(degree)\n\t\t\t\ty = vector.x * Math.sin(degree) + vector.y * Math.cos(degree)\n\t\t\t\tnew_vecs << (Vector3.new x, y, vector.z)\n\t\t\tend\n\t\tend\n\t\tmesh = TriMesh.new new_vecs, mesh.tri_indices\n\t\tmesh = translate mesh, :vector => vec\n\telsif axis.kind_of? Line\n\t\tvec = axis.base_point\n\t\tdir = axis.direction - vec\n\t\tx_rot = Vector3.new(0, dir.y, dir.z).angle(dir) / Math::PI / 180\n\t\ty_rot = Vector3.new(dir.x, 0, dir.z).angle(dir) / Math::PI / 180\n\t\tmesh = translate mesh, :vector => (vec * -1)\n\t\tmesh = rotate mesh, :axis => :x, :degree => -x_rot\n\t\tmesh = rotate mesh, :axis => :y, :degree => -y_rot\n\t\tmesh = rotate mesh, :axis => :z, :degree => degree\n\t\tmesh = rotate mesh, :axis => :y, :degree => y_rot\n\t\tmesh = rotate mesh, :axis => :x, :degree => x_rot\n\t\tmesh = translate mesh, :vector => vec\n\tend\n\tmesh\nend", "def test_rotate_180_degrees\n angle = 180\n new_transform = @subject.rotate(angle)\n\n assert_equal Vector2D.new(0, 0), new_transform.position\n assert_equal Vector2D.new(0, -2), new_transform.target\n end", "def apply_rotation\n if @rotation_block != nil\n ([email protected](@rotation_cycle)).each do |i|\n @blocks.each do |block|\n old_x = block.x\n old_y = block.y\n block.x = @rotation_block.x + (@rotation_block.y - old_y)\n block.y = @rotation_block.y - (@rotation_block.x - old_x)\n end\n end\n end\n end", "def rotate_x(r, phi)\n s, c = Math.sin(phi), Math.cos(phi)\n a_10 = c * r[1][0] + s * r[2][0]\n a_11 = c * r[1][1] + s * r[2][1]\n a_12 = c * r[1][2] + s * r[2][2]\n a_20 = - s * r[1][0] + c * r[2][0]\n a_21 = - s * r[1][1] + c * r[2][1]\n a_22 = - s * r[1][2] + c * r[2][2]\n return [\n r[0],\n [a_10, a_11, a_12],\n [a_20, a_21, a_22]\n ]\n rescue => e\n raise\n end", "def rotate_array(arr)\narr.drop(1) + arr[0...1]\nend", "def Matrix3dRotationFromColumnZ(arg0)\n ret = _invoke(1610744147, [arg0], [VT_BYREF | VT_DISPATCH])\n @lastargs = WIN32OLE::ARGV\n ret\n end", "def multiply!(axis=origin,real=1)\r\n if axis.kind_of? Quaternion\r\n multiply!(axis.axis,axis.real)\r\n elsif axis.point3_like?\r\n r = (@real*real)[email protected](axis)\r\n p3 = axis.scale r\r\n qp3 = @axis.scale real\r\n cross = @axis.cross axis\r\n a = p3.add!(qp3).add!(cross)\r\n set(a,r)\r\n else\r\n raise_no_conversion axis\r\n end\r\n self\r\n end", "def my_rotate(arr, offset=1)\n rotations = offset % arr.length\n arr.drop(rotations) + arr.take(rotations)\nend", "def Matrix3dIsXYRotation(arg0, arg1)\n ret = _invoke(1610744054, [arg0, arg1], [VT_BYREF | VT_DISPATCH, VT_BYREF | VT_R8])\n @lastargs = WIN32OLE::ARGV\n ret\n end", "def setAngleAxis(angle, axis)\n if axis == Vector[0,0,0]\n raise(ArgumentError, \"Axis must not be the zero vector\")\n end\n if axis.size() != 3\n raise(ArgumentError, \"Axis must be a 3-dimensional vector\")\n end\n axis = axis.normalize()\n @beta0 = Math.cos(angle / 2.0)\n beta1 = axis[0] * Math.sin(angle / 2.0)\n beta2 = axis[1] * Math.sin(angle / 2.0)\n beta3 = axis[2] * Math.sin(angle / 2.0)\n @beta_s = Vector[beta1, beta2, beta3]\n end", "def my_rotate!(array, amt)\n\nend", "def rotate_y(\n theta # float\n) # mat3\n deg = degrees(theta).floor % 360\n if $rotation_memo[\"y#{deg}\"]\n return $rotation_memo[\"y#{deg}\"]\n end\n c = Math.cos(theta) # float\n s = Math.sin(theta) # float\n matrix = Mat3.new(\n Vec3.new(c, 0, s),\n Vec3.new(0, 1, 0),\n Vec3.new(-s, 0, c)\n );\n $rotation_memo[\"y#{deg}\"] = matrix\n matrix\nend", "def my_rotate(pos=1)\n pos.times do\n self.push(self.shift)\n end\n return self\n end", "def rotate! n = 1\n n %= size\n return self if n.zero?\n new_index = (@current_index - n) % size\n center_indices_at new_index\n @array.rotate! n\n end", "def my_rotate(arr, offset=1)\n # your code goes here\n shift = offset % arr.length\n arr.drop(shift) + arr.take(shift)\nend", "def rotate_deg!( angle_deg )\n self.angle_deg += angle_deg\n self\n end", "def rotate_array(ar)\n ar[1..-1] << ar[0]\nend", "def rotate_array(arr)\n [*arr[1..-1], *arr[0, 1]]\nend", "def rotate(input)\n input[1..-1] << input[0]\nend", "def my_rotate(arr, offset=1)\n # your code goes here\n drop(offset) + take(offset)\n\nend", "def rotateAndFlip(image)\n return image.transpose.flip\nend", "def rotate_right!\n @picture.rotate_right!\n end", "def rotate!(bone, channel, theta)\n set_channel(bone, channel, channel_data_for(bone).get_channel(channel) + theta)\n end" ]
[ "0.76205575", "0.7495789", "0.73058647", "0.6895596", "0.6892747", "0.6885244", "0.6478798", "0.639373", "0.6134381", "0.6083075", "0.60657007", "0.60223764", "0.60081553", "0.59958315", "0.59859276", "0.59215266", "0.59166354", "0.59003484", "0.5887707", "0.58770895", "0.5851187", "0.5822846", "0.579113", "0.57894427", "0.577648", "0.5703575", "0.56974983", "0.56900764", "0.56526077", "0.5649284", "0.56359166", "0.5631025", "0.5629701", "0.56286407", "0.5625483", "0.56167483", "0.56164306", "0.56084967", "0.5572187", "0.5565244", "0.5563642", "0.55537224", "0.55526626", "0.55514", "0.5549405", "0.55450493", "0.5527432", "0.54958814", "0.54878294", "0.54737705", "0.5466506", "0.54658556", "0.5445615", "0.54428655", "0.5431141", "0.54254276", "0.54113007", "0.54076624", "0.5397603", "0.53961414", "0.5393812", "0.53849924", "0.5370529", "0.53695065", "0.53654367", "0.5360521", "0.53569484", "0.5356869", "0.53555155", "0.5332036", "0.5328429", "0.53244364", "0.5317142", "0.53139985", "0.5307228", "0.53004175", "0.5295862", "0.52856207", "0.52824575", "0.52678156", "0.5267052", "0.5263724", "0.5255796", "0.5253268", "0.5228782", "0.52227634", "0.52159667", "0.5214364", "0.52126837", "0.521054", "0.51784", "0.51743406", "0.5174275", "0.5163906", "0.5163427", "0.5149468", "0.5147985", "0.5146414", "0.5145316", "0.5141676" ]
0.7164591
3
check to see if the x, y and z range of 2 cuboids overlap
def overlap?(self_range, other_range) return true if self_range == other_range overlap_helper(self_range, other_range) || overlap_helper(other_range, self_range) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def intersects?(other_cuboid)\n\t\toverlaps_along_x_with?(other_cuboid) && overlaps_along_y_with?(other_cuboid) && overlaps_along_z_with?(other_cuboid)\n\tend", "def colliding?(block)\n x2 > block.x1 &&\n x1 < block.x2 &&\n y2 > block.y1 &&\n y1 < block.y2 &&\n z2 > block.z1 &&\n z1 < block.z2\n end", "def intersects?(other)\n (@x <= other.x_max && other.x <= @x_max) &\n (@y <= other.y_max && other.y <= @y_max) &\n (@z <= other.x_max && other.z <= @z_max)\n end", "def intersects?(other)\n return false if self.xMax < other.xMin\n return false if self.xMin > other.xMax\n return false if self.yMax < other.yMin\n return false if self.yMin > other.yMax\n return false if self.zMax < other.zMin\n return false if self.zMin > other.zMax\n true\n end", "def intersects?(other)\n# (@x <= other.x_outer && other.x <= @x_outer) || (@y <= other.y_outer && other.y <= @y_outer) ||\n# (@z <= other.z_outer && other.z <= @z_outer)\n\n\n (other.x < (@x + @l)) && ((other.x + other.l) > @x) &&\n (other.y < (@y + @w)) && ((other.y + other.w) > @y) &&\n (other.z < (@z + @h)) && ((other.z + other.h) > @z)\n\n end", "def overlap(first_rect, second_rect)\n a1 = first_rect[0]\n a2 = first_rect[1]\n b1 = second_rect[0]\n b2 = second_rect[1]\n\n if b1[0] < a2[0] && b1[1] < a2[1]\n return true\n else \n return false\n end\n\nend", "def overlap?(object1, object2)\n\t#upper left corner\n\tlx1 = object1.x\n\tly1 = object1.y\n\n\tlx2 = object2.x\n\tly2 = object2.y\n\t\n\t#lower right corner\n\trx1 = object1.x + object1.class::WIDTH\n\try1 = object1.y + object1.class::HEIGHT\n\n\trx2 = object2.x + object2.class::WIDTH\n\try2 = object2.y + object2.class::HEIGHT\n\n\tif rx1 - lx2 < 5 or\n\t\t\trx2 - lx1 < 5 then\n\t\treturn false\n\tend\n\n\tif ry1 - ly2 < 5 or\n\t\t\try2 - ly1 < 5 then\n\t\treturn false\n\tend\n\n\treturn true\nend", "def intersects?(other)\n raise \"NOT A CUBOID\" unless other.is_a? Cuboid \n self_range = range_finder\n other_range = other.range_finder\n\n self_range.each do |k,_|\n return false unless overlap?(self_range[k], other_range[k])\n end \n\n true \n end", "def intersects?(other)\n if !(self.x2 < other.x1) &&\n !(other.x2 < self.x1) &&\n !(self.y2 < other.y1) &&\n !(other.y2 < self.y1) &&\n !(self.z2 < other.z1) &&\n !(other.z2 < self.z1)\n return true\n else\n return false\n end\n end", "def collide?(other)\r\n max_left = [left, other.left].max\r\n max_top = [top, other.top].max\r\n min_right = [right,other.right].min\r\n min_bottom = [bottom,other.bottom].min\r\n return max_left <= min_right && max_top <= min_bottom\r\n end", "def check_hit(box) # Checa se a hitbox tem overlap com outra hitbox\n heightimp = false\n @zlist.each do |heightLevel| # Checa impacto de altura, se não tem impacto de altura, um objeto no maximo passa por cima do outro sem colidir\n box.zlist.each do |hitheight|\n if (heightLevel == hitheight) # Qualquer nivel de altura ser igual a qualquer nivel de altura da outra hitbox é o bastante pra ter impacto de altura\n heightimp = true\n end\n end\n end\n if (((@x > box.x + box.width or box.x > @x + @width) or (@y > box.y + box.length or box.y > @y + @length)) or (heightimp == false)) # Se não tem overlap bidimensional ou não há impacto de altura, não tem colisão\n return false\n else\n return true\n end\n end", "def intersects?(cuboid)\n cuboid.vertices.each do |vertex|\n if self.contains?(vertex) || self.touches?(vertex)\n return true\n end\n end\n return false\n end", "def intersects?(cuboid)\n return true if self == cuboid\n !left_face_is_right_of_other_right_face(cuboid) &&\n !right_face_is_left_of_other_left_face(cuboid) &&\n !top_face_is_below_other_bottom_face(cuboid) &&\n !bottom_face_is_above_other_top_face(cuboid) &&\n !front_face_is_behind_other_back_face(cuboid) &&\n !back_face_is_front_other_front_face(cuboid)\n end", "def are_colliding?(obj1, obj2)\n obj1.center_x == obj2.center_x && obj1.center_y == obj2.center_y\n end", "def overlap(first_rectangle, second_rectangle)\n\tfirst_rectangle_x1 = first_rectangle[0][0]\n\tfirst_rectanlge_y1 = first_rectangle[0][1]\n\tfirst_rectangle_x2 = first_rectangle[1][0]\n\tfirst_rectanlge_y2 = first_rectangle[1][1]\n\n\tsecond_rectangle_x1 = second_rectangle[0][0]\n\tsecond_rectanlge_y1 = second_rectangle[0][1]\n\tsecond_rectangle_x2 = second_rectangle[1][0]\n\tsecond_rectanlge_y2 = second_rectangle[1][1]\n\n\tif first_rectangle_x1 < second_rectangle_x2 && first_rectangle_x2 > second_rectangle_x1 && first_rectanlge_y1 < second_rectanlge_y2 && first_rectanlge_y2 > second_rectanlge_y1\n\t\treturn true\n\telse\n\t\treturn false\n\tend\nend", "def is_block_at?(x, y, z)\n not (x < 0 || y < 0 || z < 0 || x >= size_x || y >= size_y || z >= size_z)\n end", "def crossing?(other)\n return false unless overlaps?(other)\n (@begin_pos <=> other.begin_pos) * (@end_pos <=> other.end_pos) == 1\n end", "def collision_between obj1, obj2\n\t\t\tif obj1.y + obj1.height < obj2.y ; return false ; end\n\t\t\tif obj1.y > obj2.y + obj2.height ; return false ; end\n\t\t\tif obj1.x + obj1.width < obj2.x ; return false ; end\n\t\t\tif obj1.x > obj2.x + obj2.width ; return false ; end\n\t\t\treturn true\n\t\tend", "def include?(other_square)\n # top left\n @square.contains?(other_square.x1, other_square.y1) || \n # top right\n @square.contains?(other_square.x1, other_square.y2) || \n # bottom right\n @square.contains?(other_square.x1, other_square.y3) || \n # bottom left\n @square.contains?(other_square.x1, other_square.y4) \nend", "def oor?(x, y=0, z=0)\n return true if x < 0 || y < 0 || z < 0\n return true if xsize <= x\n return true if ysize <= y if ysize > 0\n return true if zsize <= z if zsize > 0\n return false\n end", "def overlap?(rect)\n return false unless rect.is_a? Rectangle\n\n return (@x1 <= rect.x2 && \n @x2 >= rect.x1 && \n @y1 <= rect.y2 && \n @y2 >= rect.y1)\n end", "def overlap?(window)\n\t\t((window.left <= self.right) && (self.left <= window.right)) &&\n\t\t((window.top <= self.bottom) && (self.top <= window.bottom))\n\tend", "def out_of_bounds?\n (0..@grid_size[0]).cover?(@coordinates[0]) &&\n (0..@grid_size[1]).cover?(@coordinates[1])\nend", "def intersects?(other)\n horizontal_intersection = self.horizontal_intersection?(other)\n vertical_intersection = self.vertical_intersection?(other)\n within_z_index_range = self.within_z_index_range?(other)\n\n return within_z_index_range && vertical_intersection && horizontal_intersection\n\n end", "def overlap_ok?\n # if overlap: true\n end", "def intersects?(other)\n self_index = dimensions(self.vertices)\n other_index = dimensions(other.vertices)\n\n intersection = {}\n intersection[:x] = self_index[:x] & other_index[:x]\n intersection[:y] = self_index[:y] & other_index[:y]\n intersection[:z] = self_index[:z] & other_index[:z]\n\n intersection.value?([]) ? false : true\n end", "def intersects?(r2)\n if @p2.x <= r2.p1.x or r2.p2.x <= @p1.x \n return false\n elsif @p2.y >= r2.p1.y or r2.p2.y >= @p1.y\n end\n return true\n end", "def out_of_bounds?\n (0..@grid_size[0]).cover?(@coordinates[0]) &&\n (0..@grid_size[1]).cover?(@coordinates[1])\n end", "def collides?(other)\n !(\n @pos.x + width <= other.pos.x ||\n @pos.x >= other.pos.x + other.width ||\n @pos.y + height <= other.pos.y ||\n @pos.y >= other.pos.y + other.height\n )\n end", "def collision_detected?\n ($boxes - Array(self)).any? do |other_box|\n # .include method with other_square\n other_box.include?(@square)\n end\nend", "def test_obb_vs_obb(rect_a, rect_b)\n @coll_depth = Numeric::POSITIVE_INFINITY\n 2.times do |i|\n axis_a = rect_a.axes[i]\n depth_a = test_intervals(rect_a.projection(axis_a), rect_b.projection(axis_a))\n return false if depth_a == 0\n\n axis_b = rect_b.axes[i]\n depth_b = test_intervals(rect_a.projection(axis_b), rect_b.projection(axis_b))\n return false if depth_b == 0\n\n abs_a = depth_a.abs\n abs_b = depth_b.abs\n\n if abs_a < @coll_depth.abs or abs_b < @coll_depth.abs\n altb = abs_a < abs_b\n @coll_normal = altb ? axis_a : axis_b\n @coll_depth = altb ? depth_a : depth_b\n end\n end\n\n @cpa = rect_a\n @cpb = rect_b\n true\n end", "def in_bounds?(x, y)\n return false if x.to_i < 0\n return false if y.to_i < 0\n\n x.to_i < cols && y.to_i < rows\n end", "def Range3dIsContainedInRange3d(arg0, arg1)\n ret = _invoke(1610744090, [arg0, arg1], [VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH])\n @lastargs = WIN32OLE::ARGV\n ret\n end", "def collides?(object2); radius_collision?(object2); end", "def collide_point?(x,y)\n nself = normalize()\n x.between?(nself.left,nself.right) && y.between?(nself.top,nself.bottom)\n end", "def falls_within?(x, y)\n x >= 0 && x < x_dimension && y >= 0 && y < y_dimension\n end", "def within?(x, y)\n (x >= 0) && (x < height) && (y >= 0) && (y < height)\n end", "def overlap? range\n !(self & range).nil?\n end", "def collide(block)\n return (block.x == @x && block.y == @y)\n end", "def over_bound?(x, y)\n if (x != @x || y != @y) && $game_map.valid?(x, y)\n max_w = $game_map.max_width ; max_h = $game_map.max_height\n screen_x = $game_map.adjust_x(x) * 32 + 16\n screen_y = $game_map.adjust_y(y) * 32 + 32\n sx = (screen_x / 32).to_i; sy = (screen_y / 32).to_i\n if sx.between?(0 - out_offset, max_w + out_offset) && \n sy.between?(0 - out_offset, max_h + out_offset)\n \n return false\n end # sx, sy\n end # xy != @xy && map_valid\n return true\n end", "def inside_rect?(point1, point2)\n lats = [point1.lat, point2.lat].sort\n lons = [point1.lon, point2.lon].sort\n la = self.lat\n lo = self.lon\n\n (la >= lats[0] && la <= lats[1] && lo >= lons[0] && lo <= lons[1])\n end", "def overlaps?(other); end", "def overlaps?(other); end", "def overlaps?(other); end", "def intersect? rect\n rect.is_a?(Rectangle) && !(@x + @width < rect.x || rect.x + rect.width < @x || @y + @height < rect.y || rect.y + rect.height < @y)\n end", "def intersect?(obj)\n obj.x + obj.w > @x && obj.x < @x + @w &&\n (@inverted ? obj.y < get_y(obj) && obj.y + obj.h > @y : obj.y > get_y(obj) && obj.y < @y + @h)\n end", "def inside?(x, y)\n x >= 0 && x < @width && y >= 0 && y < @height\n end", "def in_bounds?(side_a, side_b, side_c, perim, max_leg, max_hypot, max_perim)\n perim <= max_perim && side_a <= max_leg && side_b <= max_leg && side_c <= max_hypot\nend", "def test_overlaping\n x = IntegerRange.new(1, 5)\n y = IntegerRange.new(3, 10)\n\n assert_equal(x.mergeable?(y), true)\n assert_equal(y.mergeable?(x), true)\n end", "def collide_rect?(rect)\n return true if collide_point?(rect.topleft)\n return true if collide_point?(rect.topright)\n return true if collide_point?(rect.bottomleft)\n collide_point?(rect.bottomright)\n end", "def overlapInterval (array1, array2)\n\t@answer = false\n\t@a = array1[0] <= array2[0]\n\t@b = array1[1] > array2[0]\n\t@c = array1[0] > array2[0]\n\t@d = array1[0] < array2[1]\n\tif ((@a&&@b)||(@c&&@d))\n\t\t@answer = true\n\tend\n\t@answer\n\t\nend", "def is_obstructed?(x1, y1, x2, y2, bad)\n bad.include?(\"#{x1} #{y1} #{x2} #{y2}\") || bad.include?(\"#{x2} #{y2} #{x1} #{y1}\")\nend", "def intersects?(other)\n if origin <= other.origin\n vertices.each { |vertex| return true if vertex > other.origin }\n else\n other.vertices.each { |vertex| return true if vertex > origin }\n end\n false\n end", "def checkCollision?(other)\n refresh()\n other.refresh()\n \n xMin = @center_left[X]\n xMax = @center_right[X]\n yMin = @center_bottom[Y]\n yMax = @center_top[Y]\n\n xMax > other.center_left[X] && xMin < other.center_right[X] && \n yMin > other.center_top[Y] && yMax < other.center_bottom[Y]\n end", "def intersect?(r)\n @x < r.x + r.w && @x + @w > r.x && @y < r.y + r.h && @y + @h > r.y\n end", "def test_ships_overlap?\n board = Board.new\n cruiser = Ship.new('Cruiser', 3)\n board.place(cruiser, [\"A1\", \"A2\", \"A3\"])\n submarine = Ship.new(\"Submarine\", 2)\n assert_equal true, board.ship_overlap?(submarine, [\"A1\", \"B1\"])\n\n assert_equal false, board.valid_placement?(submarine, [\"A1\", \"B1\"])\n assert_equal true, board.valid_placement?(submarine, [\"C1\", \"C2\"])\n end", "def contains?(*args)\n x, y = *Vector2.extract(args.singularize)\n x.between?(self.x, self.x2 - 1) && y.between?(self.y, self.y2 - 1)\n end", "def included_in?(other_rect)\n self == self.intersects(other_rect)\n end", "def can_place? x, y\n x >= 0 and x < @max_x and y >= 0 and y < @max_y and !object_at?(x, y)\n end", "def rec_intersection(rect1, rect2)\n x1 = [rect1[0][0],rect2[0][0]].max\n y1 = [rect1[0][1],rect2[0][1]].max\n y2 = [rect2[1][1],rect1[1][1]].min\n x2 = [rect2[1][0],rect1[1][0]].min\n if rect2[0][0] > rect1[1][0] || rect2[0][1] > rect1[1][1]\n return nil\n else\n return [[x1,y1],[x2,y2]]\n end\nend", "def overlaps?(other)\n cover?(other.begin) || other.cover?(first)\n end", "def contains(x1,y1,x2,y2)\n @x1<=x1 && @y1<=y1 && x2<=@x2 && y2<=@y2\n end", "def in_bounds?(x, y)\n x >= 0 && x < @grid_width && y >= 0 && y < @grid_height\n end", "def collide_with_characters?(x, y)\n return false if allow_overlap?\n rme_collide_with_characters?(x, y)\n end", "def intersects?(other)\n @origin.keys.each do |axis|\n return false unless min_lte_max(axis, other) && max_gte_min(axis, other)\n end\n true\n end", "def overlap()\n\n # find max and min x coordinates in each rectangle\n max_rectangle_x = []\n min_rectangle_x = []\n (1..2).each do |i|\n max_rectangle_x[i] = 0\n min_rectangle_x[i] = 1000\n (1..4).each do |j|\n print \"Enter x_coordinate of corner #{j} of recatangle #{i}: \"\n x_coordinate = gets.chomp.to_i\n if max_rectangle_x[i] < x_coordinate\n max_rectangle_x[i] = x_coordinate\n end\n if min_rectangle_x[i] > x_coordinate\n min_rectangle_x[i] = x_coordinate \n end\n end\n end \n\n# find max and min y coordinates in each rectangle\n max_rectangle_y = []\n min_rectangle_y = []\n (1..2).each do |i|\n max_rectangle_y[i] = 0\n min_rectangle_y[i] = 1000\n (1..4).each do |j|\n print \"Enter y_coordinate of corner #{j} of recatangle #{i}: \"\n y_coordinate = gets.chomp.to_i\n if max_rectangle_y[i] < y_coordinate\n max_rectangle_y[i] = y_coordinate\n end\n if min_rectangle_y[i] > y_coordinate\n min_rectangle_y[i] = y_coordinate\n end\n end\n end \n\n# Do max/min tests for overlap [see top of program]\n\n puts \"max_rectangle_x[1] = #{max_rectangle_x[1]}\"\n puts \"min_rectangle_x[1] = #{min_rectangle_x[1]}\"\n puts \"max_rectangle_x[2] = #{max_rectangle_x[2]}\"\n puts \"min_rectangle_x[2] = #{min_rectangle_x[2]}\"\n puts \"max_rectangle_y[1] = #{max_rectangle_y[1]}\"\n puts \"min_rectangle_y[1] = #{min_rectangle_y[1]}\"\n puts \"max_rectangle_y[2] = #{max_rectangle_y[2]}\"\n puts \"min_rectangle_y[2] = #{min_rectangle_y[2]}\"\n\n if max_rectangle_x[1] < min_rectangle_x[2] || \\\n max_rectangle_x[2] < min_rectangle_x[1] || \\\n max_rectangle_y[1] < min_rectangle_y[2] || \\\n max_rectangle_y[2] < min_rectangle_y[1]\n puts \"Rectangles do not overlap\"\n else\n puts \"Rectangles overlap\" \n end\nend", "def vt_intersects?(*args)\n vt_range.intersects?(*args)\n end", "def overlapping?(left, right)\n (tuples(left) & tuples(right)).any?\n end", "def valid_coords(i, j)\n (0...height) === i && (0...width) === j\n end", "def in? a, b, c\r\n a[0]>=b[0] && a[1]>=b[1] && a[0]<=c[0] && a[1]<=c[1]\r\n end", "def intersects?(*args)\n other = coerce_range(*args)\n raise ArgumentError, \"#{self.begin.class} expected, received #{other.begin.class}\" unless other.begin.kind_of?(self.begin.class)\n\n if other.instant?\n self.begin <= other.begin and other.end < self.end\n else\n other.begin < self.end and self.begin < other.end\n end\n end", "def clash_check(a, b)\n\tclashes = []\n a.each do |a_start, a_finish|\n range_a = a_start..a_finish\n\n # check against each of b's slots\n b.each do |b_start, b_finish|\n range_b = b_start..b_finish\n \n # detect overlap of ranges\n # if Rails: range_a.overlaps?(range_b)\n if range_a.cover?(range_b.first) || range_b.cover?(range_a.first) \n\t\t\t\tclashes << [range_a, range_b]\n end\n end\n end\n clashes.empty?\nend", "def rec_intersection(rect1, rect2)\n\tx_min = [rect1[0][0],rect2[0][0]].max \n\tx_max = [rect1[1][0],rect2[1][0]].min \n\ty_min = [rect1[0][1],rect2[0][1]].max \n\ty_max = [rect1[1][1],rect2[1][1]].min \n\n\t(x_max < x_min) || (y_max < y_min) ? nil : [[x_min, y_min], [x_max, y_max]]\nend", "def out_of_bounds?(x, y)\n x < 0 || y < 0 || x > @width - 1 || y > @height - 1\n end", "def contains?(x, y)\n x > bounds.x && x < bounds.x+bounds.width && y > bounds.y && y < bounds.y+bounds.height\n end", "def boundaries(x, y)\n return false if x > 7 || x < 0 || y > 7 || y < 0\n return true\n\n end", "def valid_board_coordinates?(x, y)\n x >= 0 && y >= 0 && x < 3 && y < 3\n end", "def interior?(coords)\n x, y, z = coords\n x >= @origin_x && x <= @max_x &&\n y >= @origin_y && y <= @max_y &&\n z >= @origin_z && z <= @max_z\n end", "def is_obstructed?(piece1_loc, destination)\r\n# converts the location arrays into easier-to-read x and y terms\r\n x1 = piece1_loc[0]\r\n y1 = piece1_loc[1]\r\n x2 = destination[0]\r\n y2 = destination[1]\r\n if piece2_loc != nil\r\n x3 = piece2_loc[0]\r\n y3 = piece2_loc[1]\r\n end\r\n # Determines whether the line between piece 1 and the destination is horizontal or vertical. \r\n # If neither, then it calculates the slope of line between piece 1 and destination. \r\n # If a second piece is given, then it also calculates the slope between piece 1 and piece 2.\r\n if y1 == y2\r\n horizontal = true\r\n elsif x1 == x2\r\n vertical = true\r\n else\r\n slope_dest = (y2-y1).to_f/(x2-x1).to_f\r\n end\r\n\r\n\tif horizontal && x1 < x2\r\n\t\t(x1+1..x2-1).each do |x|\r\n\t\t\treturn true if is_occupied?(x, y1)\r\n\t\tend\r\n\telsif horizontal && x1 > x2\r\n\t\t(x2+1..x1-1).each do |x|\r\n\t\t\treturn true if is_occupied?(x, y1)\r\n\t\tend\r\n\telsif vertical && y1 < y2\r\n\t\t(y1+1..y2-1).each do |y|\r\n\t\t\treturn true if is_occupied?(x1, y)\r\n\t\tend\r\n\telsif vertical && y1 > y2\r\n\t\t(y2+1..y1-1).each do |y|\r\n\t\t\treturn true if is_occupied?(x1, y)\r\n\t\tend\r\n\telsif horizontal || vertical\r\n\t\treturn false\r\n\telsif slope_dest.abs == 1.0 && x1 < x2\r\n\t\t(x1+1..x2-1).each do |x|\r\n\t\t\tdelta_y = x-x1\r\n\t\t\ty = y2 > y1 ? y1 + delta_y : y1 - delta_y\r\n\t\t\treturn true if is_occupied?(x, y)\r\n\t\tend\r\n\telsif slope_dest.abs == 1.0 && x1 > x2\r\n\t\t(x2+1, x1-1).each do |x|\r\n\t\t\tdelta_y = x1-x\r\n\t\t\ty = y2 > y1 ? y1 + delta_y : y1 - delta_y\r\n\t\t\treturn true if is_occupied?(x, y)\r\n\t\tend\r\n\telsif (slope_dest.abs != 1.0)\r\n\t\tfail 'path is not a straight line'\r\n\telse return false\r\n\tend\r\n\t\r\nend", "def in_range?\n return self.range.include?([@x, @y])\n end", "def can_be_placed?(x, y)\n return false unless (0..(rows - 1)).include?(x)\n return false unless (0..(columns - 1)).include?(y)\n\n true\n end", "def intersects?(other)\n return false if self.equal?(other)\n !(above?(other) || below?(other) || right_of?(other) || left_of?(other) || behind?(other) || in_front_of?(other))\n end", "def out_of_bounds?(x,y)\n x < 0 || y < 0 || x > @size - 1 || y > @size - 1\n end", "def intersects?(other)\n other.vertices.each do |vertex|\n return true if interior?(vertex)\n end\n false\n end", "def overlapping?(coordinates)\n cell_used = false\n coordinates.each do |coordinate|\n if !cell_used\n cell_used = !@cells[coordinate].empty?\n end\n end\n cell_used\n end", "def two_squares?(x,y)\n return on_home_row? && (x_diff(x) == 0) && (y_diff(y) == 2)\n end", "def love_rectangle(rect_1, rect_2)\n ranges_1 = make_range(rect_1)\n ranges_2 = make_range(rect_2)\n\n match_x = matching_range(ranges_1[:x], ranges_2[:x])\n match_y = matching_range(ranges_1[:y], ranges_2[:y])\n\n if [match_x.empty?, match_y.empty?].any?\n \"No match!\"\n else\n make_output(match_x, match_y)\n end\nend", "def pos?(x, y)\n (width.include?(x) && height.include?(y)) ||\n occupied_spaces.include?([x, y])\n end", "def overlaps? point\n inside_top_left?(point) && inside_bottom_right?(point)\n end", "def overlaps?(other)\n (self.check_in - other.check_out) * (other.check_in - self.check_out) >= 0\n end", "def crossing?(other); end", "def crossing?(other); end", "def crossing?(other); end", "def intersects?(subnet)\n includes? subnet.first or includes? subnet.last\n end", "def collide_with_vehicles?(x, y)\r\n $game_map.boat.pos_nt?(x, y) || $game_map.ship.pos_nt?(x, y)\r\n end", "def collide_with_vehicles?(x, y)\r\r\n $game_map.boat.pos_rect_nt?(x, y, collision_rect) || $game_map.ship.pos_rect_nt?(x, y, collision_rect)\r\r\n end", "def intersects?(other)\n return false if separate? other\n return false if contained? other\n return false if coincident? other\n true\n end", "def rectangle_inclusion_lambda(x1, y1, x2, y2)\n # take top left point and bottom right one\n x1, x2 = x2, x1 if x1 > x2\n y1, y2 = y2, y1 if y1 > y2\n\n ->(x, y) { (x1..x2).cover?(x) && (y1..y2).cover?(y) }\n end", "def within_drawn? x1, y1, x2, y2\n ((x2 - @origin.x) < x1 && x1 < (x2 - origin.x + size.x) && (y2 - @origin.y) < y1 && y1 < (y2 - origin.y + size.y))\nend", "def calc_box_collision\n return unless state.world_lookup.keys.length > 0 # return unless hash has atleast 1 key\n collision_floor\n collision_left\n collision_right\n collision_ceiling\n end", "def has?(x, y)\n [x, y].count{|c| @map_cells_range.include? c} == 2\n end" ]
[ "0.7726147", "0.7491228", "0.7271436", "0.71529996", "0.71063", "0.70563054", "0.6983636", "0.695283", "0.6880446", "0.67826754", "0.6779791", "0.6734316", "0.6718926", "0.6690226", "0.66063446", "0.65880823", "0.65805286", "0.65580344", "0.65351194", "0.6493899", "0.6480472", "0.6477024", "0.6465974", "0.645502", "0.64434624", "0.64432615", "0.6432578", "0.64293253", "0.6406024", "0.6399888", "0.6375211", "0.63653356", "0.6361488", "0.6358933", "0.6353648", "0.63401705", "0.6338091", "0.6329214", "0.6328227", "0.6325367", "0.63151", "0.63131577", "0.63131577", "0.63131577", "0.63096404", "0.6291101", "0.6290779", "0.62637997", "0.62521577", "0.62441826", "0.6216507", "0.62138236", "0.6201656", "0.62004083", "0.6179375", "0.6178943", "0.61755645", "0.6166122", "0.61573714", "0.6142452", "0.6132325", "0.6131653", "0.61244917", "0.6104936", "0.60987836", "0.6088096", "0.60858023", "0.6083237", "0.60669935", "0.60635936", "0.60625017", "0.605451", "0.605271", "0.60435104", "0.6036086", "0.6034674", "0.6031753", "0.6028983", "0.6027604", "0.60249335", "0.60175014", "0.6007067", "0.6003948", "0.6002072", "0.59920657", "0.5990715", "0.5986963", "0.5978541", "0.5975705", "0.59735", "0.5970376", "0.5970376", "0.5970376", "0.5966468", "0.59616786", "0.5957531", "0.595579", "0.59538877", "0.5950675", "0.59490824", "0.5947374" ]
0.0
-1
Create a topic ==== Parameters name Name of topic to create ==== See Also
def create_topic(name) request({ 'Action' => 'CreateTopic', 'Name' => name, :parser => Fog::Parsers::AWS::SNS::CreateTopic.new }) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create name\n response = client.create_topic(:name => name)\n Topic.new(response.topic_arn, :config => config)\n end", "def create_topic(sns, topic_name)\n req_hash = generate_request('CreateTopic', 'Name' => topic_name)\n arn = request_info(req_hash, SnsCreateTopicParser.new(:logger => @logger))\n Sns::Topic.new(sns, arn)\n rescue\n on_exception\n end", "def create\n if args.length != 2\n error \"Kafka name and topic required\"\n end\n name, urls = attachment(args)\n create_topic(urls, args.last)\n display(\"Creating topic #{args.last}..\")\n display\n get_topics(urls, name)\n end", "def topic(name)\n Kazoo::Topic.new(self, name)\n end", "def create_topic(name, partitions: nil, replication_factor: nil, config: nil)\n raise ArgumentError, \"partitions must be a positive integer\" if Integer(partitions) <= 0\n raise ArgumentError, \"replication_factor must be a positive integer\" if Integer(replication_factor) <= 0\n\n Kazoo::Topic.create(self, name, partitions: Integer(partitions), replication_factor: Integer(replication_factor), config: config)\n end", "def create_topic!\n fora.post_new_topic\n end", "def create_topic(topic_name,question_bank_id,tenant_id)\n topic = Topic.find_by_name_and_question_bank_id(topic_name,question_bank_id)\n if topic.nil? or topic.blank?\n topic = Topic.new\n topic.name = topic_name\n topic.question_bank_id = question_bank_id\n topic.tenant_id = tenant_id\n topic.save\n end\n return topic\n end", "def topic(name)\n pubsub.topic(name) || create_topic(name)\n end", "def topic(topic_name, &proc)\n t = create_topic(topic_name)\n proc.call(t) if proc\n t\n end", "def topic( name )\n Qup::Adapter::Kestrel::Topic.new( @addr, name )\n end", "def CreateTopic params = {}\n \n APICall(path: 'topics.json',method: 'POST',payload: params.to_json)\n \n end", "def topic(name, keyword_args={})\n Topic.instance(name, self, keyword_args)\n end", "def topic(name)\n name = name.to_s\n\n @topics[name] ||= begin\n @topic_names = nil\n self.class::Topic.new(name)\n end\n end", "def create_topic(message, url=nil)\n url ||= message.url\n \n topic = Topic.first(:url => url)\n \n if topic.nil?\n topic = Topic.new(:source => name, :url => url)\n set_topic_name(topic)\n \n Grapevine.log.debug \"#{topic.errors.full_messages.join(',')}\" unless topic.valid?\n topic.save\n Grapevine.log.debug \"TOPIC: #{topic.name}\"\n end\n \n return topic\n end", "def create(topic, options = {})\n body = options.has_key?(:body) ? options[:body] : {}\n body[:topic] = topic\n\n response = @client.post \"/api/topics\", body, options\n\n return response\n end", "def create\n @topic = Topic.new\n @topic.topic_name = params[:topic][:topic_name].titleize\n respond_to do |format|\n if @topic.save\n format.html { redirect_to @topic, notice: 'Topic was successfully created.' }\n format.json { render json: @topic, status: :created, location: @topic }\n else\n format.html { render action: \"new\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_topic topic_name,\n labels: nil,\n kms_key_name: nil,\n persistence_regions: nil,\n schema_name: nil,\n message_encoding: nil,\n retention: nil,\n options: {}\n if persistence_regions\n message_storage_policy = Google::Cloud::PubSub::V1::MessageStoragePolicy.new(\n allowed_persistence_regions: Array(persistence_regions)\n )\n end\n\n if schema_name || message_encoding\n unless schema_name && message_encoding\n raise ArgumentError, \"Schema settings must include both schema_name and message_encoding.\"\n end\n schema_settings = Google::Cloud::PubSub::V1::SchemaSettings.new(\n schema: schema_path(schema_name),\n encoding: message_encoding.to_s.upcase\n )\n end\n\n publisher.create_topic \\\n name: topic_path(topic_name, options),\n labels: labels,\n kms_key_name: kms_key_name,\n message_storage_policy: message_storage_policy,\n schema_settings: schema_settings,\n message_retention_duration: Convert.number_to_duration(retention)\n end", "def create_topic\n raise NotImplementedError.new\n end", "def new_topic(forum, subject, message)\n @topic.new_topic(forum, subject, message)\n end", "def create(attrs)\n self << topic = Topic.new(attrs)\n topic\n end", "def topic_create(topic)\n @topic = topic\n @board = topic.board\n @user = topic.author\n @mail = @user.email\n @link = board_topic_url(@board, @topic)\n @greeting = \"Hi\"\n\n @subject = \"您已成功在Board: #{@board.name}內新增了一篇Topic~\"\n\n mail to: @mail, subject: @subject\n end", "def topic( name, &block )\n destination( name, :topic, @topics, &block )\n end", "def create_channel!(name)\n resp = sns.create_topic(name: name)\n Channel.new(nil, resp.topic_arn)\n end", "def create\n c_id = params[:course_id]\n Topic.create(:course_id => c_id, :name => params[:topic][:name])\n redirect_to course_topics_path(:id => c_id)\n end", "def create_topic(topic, opts = {})\n raise \"Topic can't be nil or empty\" if topic.nil? || topic.to_s.empty?\n opts = opts.dup\n opts[:communicator] = self\n topic = topic.to_s\n if topic.start_with? 'amqp:'\n # absolute address\n unless topic.start_with? @address_prefix\n raise \"Cannot subscribe to a topic from different domain (#{topic}) - #{@address_prefix}\"\n end\n opts[:address] = topic\n topic = topic.split(@address_prefix).last\n else\n opts[:address] = @address_prefix + topic\n end\n OmfCommon::Comm::AMQP::Topic.create(topic, opts)\n end", "def addTopic(topic_name,article)\r\n topic = Topic.where(:topic_name => topic_name).first;\r\n #Add Topic to the Topic table if new\r\n if(topic.nil?)\r\n topic = Topic.new(topic_params)\r\n topic.save\r\n article.topic = topic\r\n else\r\n article.topic = topic\r\n end\r\n article.save\r\n end", "def create\n\n\t\t@topic = Topic.new(set_topic_attributes)\n\n\t\tif(@topic.save)\n\t\t\tflash[:success] = \"Tópico criado com sucesso\"\n\t\t\treturn redirect_to @topic\n\t\telse\n\t\t\t#nothing to do\n\t\tend\n\n\tend", "def create\n requires! :title\n requires! :body\n requires! :node_id\n\n raise AccessDenied.new(\"The current user does not have permission to create Topic.\") unless can?(:create, Topic)\n\n @topic = current_user.topics.new(title: params[:title], body: params[:body])\n @topic.node_id = params[:node_id]\n @topic.save!\n\n render \"show\"\n end", "def topic(_name)\n raise 'not implemented'\n end", "def create\n topic_breadcrums({\"display_text\": \"Create Topic\"})\n @topic = Topic.new(topic_params)\n\n respond_to do |format|\n if @topic.save\n format.html { redirect_to topics_url, notice: 'Topic was successfully created.' }\n format.json { render :show, status: :created, location: @topic }\n else\n format.html { render :new }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_topic\n t = Topic.create(title: new_topic) if new_topic.present?\n t.update_column(:user_id, self.user_id)\n t.save\n self.topic = t\n end", "def create\n @topic = current_user.topics.build(params[:topic])\n\n respond_to do |format|\n if @topic.save\n flash[:notice] = 'Topic was successfully created.'\n format.html { redirect_to(@topic) }\n format.xml { render :xml => @topic, :status => :created, :location => @topic }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @topic.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create_topic\r\n @debate.create_topic(params[:topic])\r\n redirect_to :action => \"index\"\r\n end", "def create\n parameters = topic_params\n parameters[:user_id] = current_user.id\n @topic = Topic.new(parameters)\n\n respond_to do |format|\n if @topic.save\n format.html { redirect_to @topic, notice: 'Topic was successfully created.' }\n format.json { render :show, status: :created, location: @topic }\n else\n format.html { render :new }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @topic = current_user.topics.build(params[:topic])\n\n respond_to do |format|\n if @topic.save\n format.html { redirect_to @topic, notice: 'Topic was successfully created.' }\n format.json { render json: @topic, status: :created, location: @topic }\n else\n format.html { render action: \"new\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_topic\n @debate.create_topic(params[:topic])\n redirect_to :action => \"index\"\n end", "def create\n @topic = Topic.new(params[:topic])\n\n respond_to do |format|\n if @topic.save\n flash[:notice] = 'Topic was successfully created.'\n format.html { redirect_to(@topic) }\n format.xml { render :xml => @topic, :status => :created, :location => @topic }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @topic.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @admin_topic = Topic.new(params[:topic])\n \n respond_to do |format|\n if @admin_topic.save\n format.html { redirect_to :action => 'index', :notice => 'Topic was successfully created.' }\n format.json { render :json => @admin_topic, :status => :created, :location => @admin_topic }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @admin_topic.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @topic = Topic.new(params[:topic])\n\n respond_to do |format|\n if @topic.save\n flash[:success] = 'Topic was successfully created.'\n format.html { redirect_to(@topic) }\n format.xml { render :xml => @topic, :status => :created, :location => @topic }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @topic.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @topic = Topic.new(params[:topic])\n\n respond_to do |format|\n if @topic.save\n format.html { redirect_to(@topic, :notice => 'Topic was successfully created.') }\n format.xml { render :xml => @topic, :status => :created, :location => @topic }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @topic.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @topic = Topic.new(params[:topic])\n\n respond_to do |format|\n if @topic.save\n format.html { redirect_to(@topic, :notice => 'Topic was successfully created.') }\n format.xml { render :xml => @topic, :status => :created, :location => @topic }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @topic.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @topic = Topic.new(params[:topic])\n\n respond_to do |format|\n if @topic.save\n format.html { redirect_to @topic, notice: 'Topic was successfully created.' }\n format.json { render json: @topic, status: :created, location: @topic }\n else\n format.html { render action: \"new\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @topic = Topic.new(params[:topic])\n\n respond_to do |format|\n if @topic.save\n format.html { redirect_to @topic, notice: 'Topic was successfully created.' }\n format.json { render json: @topic, status: :created, location: @topic }\n else\n format.html { render action: \"new\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def topic(arn)\n Topic.new(self,arn)\n end", "def create_topic payload\n\t\t\t\t\tFreshdesk::Api::Client.convert_to_hash( @connection.post TOPICS, payload )\n\t\t\t\tend", "def create\n @topic = Topic.new(topic_params)\n\n respond_to do |format|\n if @topic.save\n format.html { redirect_to @topic, notice: 'Topic was successfully created.' }\n format.json { render :show, status: :created, location: @topic }\n else\n format.html { render :new }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_forum_topic(options={})\n\t\t\tForumTopic.create({\n\t\t\ttitle: \"Forum topic title sample\",\n\t\t\tbody: \"Forum topic body sample\"\n\t\t\t}.merge(options))\n\t\tend", "def create\n @topic = Topic.new(topic_params)\n\n respond_to do |format|\n if @topic.save\n format.html { redirect_to topics_path, notice: 'Topic was successfully created.' }\n format.json { render :show, status: :created, location: @topic }\n else\n format.html { render :new }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @api_v1_topic = Api::V1::Topic.new(api_v1_topic_params)\n\n respond_to do |format|\n if @api_v1_topic.save\n format.html { redirect_to @api_v1_topic, notice: 'Topic was successfully created.' }\n format.json { render :show, status: :created, location: @api_v1_topic }\n else\n format.html { render :new }\n format.json { render json: @api_v1_topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @topic = current_user.topics.build(topic_params)\n\n respond_to do |format|\n if @topic.save\n format.html { redirect_to @topic, notice: 'Topic was successfully created.' }\n format.json { render :show, status: :created, location: @topic }\n else\n format.html { render :new }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @topic = Topic.new(params[:topic])\n\n respond_to do |format|\n if @topic.save\n format.html { redirect_to [:admin, @topic], notice: 'Topic was successfully created.' }\n format.json { render json: @topic, status: :created, location: @topic }\n else\n format.html { render action: \"new\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_pubsub_topic topic_id\n pubsub = Google::Cloud::Pubsub.new project: @project_id\n topic = pubsub.create_topic topic_id\n policy = topic.policy do |p|\n p.add \"roles/pubsub.publisher\",\n \"serviceAccount:[email protected]\"\n end\n @topics << topic\n topic\n end", "def create_subtopic(subtopic_name,topic_id,question_bank_id,tenant_id)\n subtopic = Subtopic.find_by_name_and_topic_id_and_question_bank_id(subtopic_name,topic_id,question_bank_id)\n if subtopic.nil? or subtopic.blank?\n subtopic = Subtopic.new\n subtopic.name = subtopic_name\n subtopic.topic_id = topic_id\n subtopic.question_bank_id = question_bank_id\n subtopic.tenant_id = tenant_id\n subtopic.save\n end\n return subtopic\n end", "def create\n \n client = Mastodon::REST::Client.new(base_url: ENV[\"MASTODON_URL\"], bearer_token: ENV[\"ACCESS_TOKEN\"])\n \n @topic = Topic.new(topic_params)\n @topic.user_id = current_user.id\n\n respond_to do |format|\n if @topic.save\n response = client.create_status(\"新しいトピック:#{@topic.title} が作成されました!\")\n format.html { redirect_to @topic, notice: 'Topic was successfully created.' }\n format.json { render :show, status: :created, location: @topic }\n else\n format.html { render :new }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @topic = Topic.new(params[:topic])\n @topic.author = current_user\n\n respond_to do |format|\n if @topic.save\n flash[:notice] = \"Topic was successfully created.\"\n format.html { redirect_to(@topic) }\n format.xml { render :xml => @topic, :status => :created, :location => @topic }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @topic.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @text_topic = TextTopic.new(params[:text_topic])\n\n respond_to do |format|\n if @text_topic.save\n format.html { redirect_to(@text_topic, :notice => 'Text topic was successfully created.') }\n format.xml { render :xml => @text_topic, :status => :created, :location => @text_topic }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @text_topic.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @topic = Topic.create(topic_params)\n current_user.topics.push(@topic)\n \n respond_with @topic\n end", "def create\n @topic = @category.topics.new(topic_params)\n authorize @topic\n\n if @topic.save\n render 'api/v1/topics/show', status: :created\n else\n render json: @topic.errors, status: :unprocessable_entity\n end\n end", "def topic(c, t)\n @socket << \"TOPIC #{c} :#{t}\"\n end", "def new\n @topic = Topic.new\n end", "def new_topic(forum, subject, message)\n self.validate_topic_input(forum, subject, message)\n self.auth.login_with_raises\n uri = self.get_new_topic_uri(forum, subject, message)\n page = self.get_new_topic_page(uri)\n form = self.get_new_topic_form(page)\n self.set_subject_and_message(form, subject, message)\n page = self.post_new_topic(form)\n page = self.validate_new_topic_result(page)\n topic = self.get_topic_from_result(page)\n\n self.config.add_subject(forum, topic, subject)\n\n { :forum => forum,\n :topic => topic,\n :subject => subject,\n :message => message,\n :result => true }\n end", "def create\n @topic = current_user.communities.find(params[:community_id]).topics.new(create_params)\n Topic.checkParams(params, current_user) && @topic.save\n respond_with(@topic)\n end", "def create\n @topic = Topic.new(params[:topic])\n @topic.user_id = current_user.id\n\n respond_to do |format|\n if @topic.save\n format.html { redirect_to @topic, notice: 'Topic was successfully created.' }\n format.json { render json: @topic, status: :created, location: @topic }\n else\n format.html { render action: \"new\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n respond_to do |format|\n if @forum.topics.create!(params[:topic])\n format.html { redirect_to forum_path(@forum), notice: 'Topic was successfully created.' }\n format.json { render json: @topic, status: :created, location: @topic }\n else\n format.html { render action: \"new\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n #@topic = Topic.new(topic_params)\n @topic = current_user.topics.build(topic_params)\n\n respond_to do |format|\n if @topic.save\n format.html { redirect_to @topic, notice: 'Topic was successfully created.' }\n format.json { render action: 'show', status: :created, location: @topic }\n else\n format.html { render action: 'new' }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @topic = @forum.topics.new(params[:topic])\n @topic.user = current_user\n p = @topic.posts.first\n p.user = current_user\n p.topic = @topic\n p.save!\n \n respond_to do |format|\n if @topic.save\n format.html { render :action => \"show\", :notice => \"Topic successfully created\" }\n else\n format.html { render :action => \"new\" }\n end\n end\n end", "def admin_new\n\t\t@topic = Topic.new\n\t\t#@topic.name = params[:new_topic] #Topic textbox for new topic\n\t\[email protected]\n\tend", "def create\n @forum_topic = Forum::Topic.new(forum_topic_params)\n\n respond_to do |format|\n if @forum_topic.save\n format.html { redirect_to @forum_topic, notice: 'Topic was successfully created.' }\n format.json { render action: 'show', status: :created, location: @forum_topic }\n else\n format.html { render action: 'new' }\n format.json { render json: @forum_topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n\n\t\t@topic = Topic.new(nil)\n\n\t\treturn @topic\n\n\tend", "def create\n @topic = Topic.new(topic_params)\n @topic.user_id = current_user.id\n respond_to do |format|\n if @topic.save\n format.html { redirect_to @topic, notice: 'Topic was successfully created.' }\n format.json { render action: 'show', status: :created, location: @topic }\n else\n format.html { render action: 'new' }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_subscription topic, subscription_name, options = {}\n updated_option = construct_create_subscription_options topic, subscription_name, options\n subscriber.create_subscription(**updated_option)\n end", "def create\n klass = params[:project_topic] ? ProjectTopic : Topic\n topic_params = params[:project_topic] || params[:topic]\n title = params[:project_topic] ? 'Project Topic' : 'Topic'\n @topic = klass.new(topic_params)\n @topic.creator = current_user\n @topic.presenter = current_user\n respond_to do |format|\n if @topic.save\n format.html { redirect_to redirect_path , notice: \"#{title} was successfully created.\" }\n format.json { render json: @topic, status: :created, location: @topic }\n else\n format.html { render 'form' }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @topic = Topic.new(params[:topic])\n\t\t@post = Post.new(params[:posts])\n\t\[email protected] = current_user\n\t\[email protected] = @forum\n\t\[email protected] = current_user\n\t\[email protected] = @topic\n\t\t\n respond_to do |format|\n if @topic.save\n\t\t\t\[email protected]\n flash[:notice] = 'Topic was successfully created.'\n format.html { redirect_to([@forum, @topic]) }\n else\n format.html { render :action => \"new\" }\n end\n end\n end", "def log_create\n TopicCreate.create!(:topic_id => self.id)\n end", "def create\n @topic = current_user.topics.build()\n @topic.title = params[:title]\n @topic.user_id = current_user.id\n @topic.user_email = current_user.email\n\n respond_to do |format|\n if @topic.save!\n format.html { redirect_to topics_url, :notice => 'topic was successfully created.' }\n format.json { render :json => @topic, :status => :created, :location => @topic }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @topic.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n topic = Topic.find(sub_topic_params[:topic_id])\n @sub_topic = topic.sub_topics.build(sub_topic_params)\n\n respond_to do |format|\n if @sub_topic.save\n format.html { redirect_to @sub_topic, notice: 'Sub topic was successfully created.' }\n format.json { render :show, status: :created, location: @sub_topic }\n else\n format.html { render :new }\n format.json { render json: @sub_topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @topic = Topic.new(published_at: Time.now)\n end", "def new_topic(t)\n topics = [ ]\n t.split(',').each { |_t|\n topic = Topic.find_or_create_by_topic(_t.downcase)\n topics << topic\n }\n return topics\n end", "def create\n @category = Category.find_by(id: params[:category_id])\n @topic = @category.topics.new(topic_params)\n\n if @topic.save\n flash[:success] = \"temat został utworzony\"\n redirect_to category_topic_path(@category, @topic)\n else\n flash[:error] = \"coś poszło nie tak\"\n end\n end", "def create\n @data_topic = DataTopic.new(params[:data_topic])\n\n respond_to do |format|\n if @data_topic.save\n format.html { redirect_to @data_topic, notice: 'Data topic was successfully created.' }\n format.json { render json: @data_topic, status: :created, location: @data_topic }\n else\n format.html { render action: \"new\" }\n format.json { render json: @data_topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @topic_form_url = forum_category_forum_topics_path(@category, @forum)\n respond_to do |format|\n if @topic.save\n format.html { redirect_to @topic, notice: 'Topic was successfully created.' }\n format.json { render action: 'show', status: :created, location: @topic }\n else\n format.html { render action: 'new' }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_topic(description)\n topic = Topic.new\n topic.title = description\n topic.user = self\n topic.save\n end", "def create\n @topic = Topic.new(params[:topic])\n @topic.user_id = current_user.id\n @topic.updater_id = current_user.id\n message = @topic.messages.first\n message.user_id = current_user.id\n message.forum_id = params[:topic][:forum_id]\n\n respond_to do |format|\n if @topic.save\n format.html { redirect_to topic_url(@topic), notice: 'Topic was successfully created.' }\n format.json { render json: @topic, status: :created, location: @topic }\n else\n format.html { render action: \"new\" }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @question_topic = QuestionTopic.new(params[:question_topic])\n\n respond_to do |format|\n if @question_topic.save\n format.html { redirect_to(@question_topic, :notice => 'Question topic was successfully created.') }\n format.xml { render :xml => @question_topic, :status => :created, :location => @question_topic }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @question_topic.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @article_topic = ArticleTopic.new(article_topic_params)\n\n respond_to do |format|\n if @article_topic.save\n format.html { redirect_to @article_topic, notice: 'Article topic was successfully created.' }\n format.json { render :show, status: :created, location: @article_topic }\n else\n format.html { render :new }\n format.json { render json: @article_topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def topic=(name, &block)\n topic = Topic.new(name, self)\n @topics << Proxy.new(topic, &block).target.tap(&:build)\n @topics.last\n end", "def create\n # Making sure only signed in users can access\n # if user_signed_in?\n topic = Topic.create(topic_params)\n if topic.valid?\n render json: topic\n else\n render json: topic.errors, status: :unprocessable_entity\n end\n # else\n # render status: 403, plain: 'Please Sign In to Access'\n # end\n end", "def create\n @user_topic = UserTopic.new(user_topic_params)\n\n respond_to do |format|\n if @user_topic.save\n format.html { redirect_to @user_topic, notice: 'User topic was successfully created.' }\n format.json { render :show, status: :created, location: @user_topic }\n else\n format.html { render :new }\n format.json { render json: @user_topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def []=(name, topic)\n @by_name[name] = topic\n end", "def create\n @topic = current_user.topics.build(topic_params)\n @topic.user_id = current_user.id\n @topic.forum_id = @forum.id\n \n if @topic.save\n redirect_to forum_topic_path(@forum, @topic)\n else\n render 'new'\n end\n end", "def create\n @topic = Topic.new(topic_params)\n @topic.user = current_user\n if @topic.save\n redirect_to @topic, notice: 'Topic was successfully created.'\n else\n render :new \n end\n end", "def create\n @topic = Topic.new(topic_params)\n @topic.active = true\n\n respond_to do |format|\n if @topic.save!\n format.html { redirect_to @topic, notice: 'Topic was successfully created.' }\n format.json { render :show, status: :created, location: @topic }\n else\n format.html { render :new }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @topic = Topic.friendly.find(params[:topic_id])\n @post = @topic.posts.new(post_params)\n @post.user_id = current_user.id\n @post.topic_id = @topic.id\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to topic_posts_path(@topic), 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 topic_params\n params.require(:topic).permit(:name)\n end", "def topic_params\n params.require(:topic).permit(:name)\n end", "def topic()\n Sensit::Api::Topic.new @http_client\n end", "def create\n @topickey = Topickey.new(params[:topickey])\n\n respond_to do |format|\n if @topickey.save\n format.html { redirect_to @topickey, notice: 'Topickey was successfully created.' }\n format.json { render json: @topickey, status: :created, location: @topickey }\n else\n format.html { render action: \"new\" }\n format.json { render json: @topickey.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n topic = Topic.new(topic_params)\n if topic.save\n response_data = {\n status: 'success',\n txt: ['質問を投稿しました!'],\n }\n else\n response_data = {\n status: 'error',\n txt: topic.errors.full_messages,\n }\n end\n render json: response_data\n end", "def create\n # MUST REFACTOR!\n if params[:primary_category] && !params[:primary_category][:id].blank?\n parent_topic = Topic.find(params[:primary_category][:id])\n end\n if params[:super_category] && !params[:super_category][:id].blank?\n super_cat = Topic.find(params[:super_category][:id])\n parent_topic ||= super_cat\n end\n @topic = Topic.new params[:topic]\n if (super_cat.nil?)\n @topic = Topic.create(:name => params[:topic][:name])\n @topic.update_attribute(:root_id, @topic.id)\n success = true\n else\n @topic = Topic.create(:name => params[:topic][:name], :root_id => super_cat.id)\n success = true\n end\n respond_to do |format|\n if success\n # disabling moving to new super cats right now\n # @topic.update_attribute(:root_id, super_cat.id) unless super_cat.nil?\n unless parent_topic.nil?\n @topic.move_to_child_of parent_topic \n end \n flash[:notice] = \"Topic #{@topic.name} was successfully created.\"\n format.html { redirect_to([:admin, @topic]) }\n format.xml { render :xml => @topic, :status => :created, :location => [:admin, @topic] }\n else\n flash[:notice] = \"There was a problem creating this topic.\"\n format.html { render :action => \"new\" }\n format.xml { render :xml => @topic.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n topic = Topic.find(params[:topic_id])\n @post = topic.posts.build(post_params)\n @post.user = current_user\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to [topic, @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" ]
[ "0.91790056", "0.82937074", "0.8227159", "0.80858", "0.79557437", "0.78835845", "0.7814814", "0.7768391", "0.7694547", "0.7612487", "0.7532647", "0.7486461", "0.7410618", "0.7378798", "0.734722", "0.7326911", "0.7292466", "0.7277718", "0.7275666", "0.7245585", "0.72146744", "0.7191634", "0.71061355", "0.7050037", "0.70399666", "0.7009903", "0.7001438", "0.6992745", "0.6976847", "0.6970441", "0.69441396", "0.69279695", "0.6921773", "0.69149476", "0.6883182", "0.6871548", "0.6848669", "0.684577", "0.6838533", "0.6828894", "0.6828894", "0.6819599", "0.6819599", "0.6819501", "0.67930806", "0.6790422", "0.678424", "0.6779341", "0.6766912", "0.6761498", "0.67563915", "0.67389494", "0.6699161", "0.6697466", "0.6694532", "0.66919726", "0.66186345", "0.66182584", "0.65885305", "0.65717864", "0.65619755", "0.65536106", "0.65291166", "0.652166", "0.65215504", "0.64954275", "0.6480384", "0.6459709", "0.64500606", "0.64419776", "0.6440119", "0.6423861", "0.6415345", "0.63947254", "0.63936615", "0.6385192", "0.6376052", "0.63666695", "0.6339167", "0.63379604", "0.63373315", "0.6320992", "0.6318313", "0.6315608", "0.6311883", "0.6310303", "0.6306187", "0.63049513", "0.62965417", "0.6292296", "0.6267327", "0.62495506", "0.6248854", "0.6229767", "0.6229767", "0.6220877", "0.62101996", "0.6209756", "0.6208276", "0.6177463" ]
0.88835526
1
support setting an RGeo object or a WKT string
def serialize(value) return if value.nil? geo_value = cast_value(value) # TODO: - only valid types should be allowed # e.g. linestring is not valid for point column # raise "maybe should raise" unless RGeo::Feature::Geometry.check_type(geo_value) RGeo::WKRep::WKBGenerator.new(hex_format: true, type_format: :ewkb, emit_ewkb_srid: true) .generate(geo_value) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def wkt=(value)\n begin\n a = ::Gis::FACTORY.parse_wkt(value)\n b = a.geometry_type.type_name.tableize.singularize.to_sym\n\n self.geographic_item = GeographicItem.new(b => a)\n @wkt_error = nil\n rescue RGeo::Error::RGeoError => e\n self.geographic_item = nil\n @wkt_error = e.message\n end\n end", "def georss_w3cgeo_representation(options)#:nodoc: \r\n self[0].georss_w3cgeo_representation(options)\r\n end", "def georss_w3cgeo_representation(options)\r\n w3cgeo_ns = options[:w3cgeo_ns] || \"geo\"\r\n \r\n \"<#{w3cgeo_ns}:lat>#{self[0][0].y}</#{w3cgeo_ns}:lat>\\n<#{w3cgeo_ns}:long>#{self[0][0].x}</#{w3cgeo_ns}:long>\\n\"\r\n end", "def georss_w3cgeo_representation(options = {}) #:nodoc:\r\n w3cgeo_ns = options[:w3cgeo_ns] || \"geo\"\r\n point = self.center\r\n \"<#{w3cgeo_ns}:lat>#{point.y}</#{w3cgeo_ns}:lat>\\n<#{w3cgeo_ns}:long>#{point.x}</#{w3cgeo_ns}:long>\\n\"\r\n end", "def set_GeoContext(value)\n set_input(\"GeoContext\", value)\n end", "def set_GeoContext(value)\n set_input(\"GeoContext\", value)\n end", "def geo(coordinates=nil)\n @options[:geo] = coordinates if coordinates.kind_of?(Array)\n end", "def set_geo\n @geo = Geo.find(params[:id])\n end", "def set_geo_datum\n @geo_datum = GeoDatum.find(params[:id])\n end", "def as_georss(options = {})\r\n dialect= options[:dialect] || :simple\r\n case(dialect)\r\n when :simple\r\n geom_attr = \"\"\r\n geom_attr += \" featuretypetag=\\\"#{options[:featuretypetag]}\\\"\" if options[:featuretypetag]\r\n geom_attr += \" relationshiptag=\\\"#{options[:relationshiptag]}\\\"\" if options[:relationshiptag]\r\n geom_attr += \" floor=\\\"#{options[:floor]}\\\"\" if options[:floor]\r\n geom_attr += \" radius=\\\"#{options[:radius]}\\\"\" if options[:radius]\r\n geom_attr += \" elev=\\\"#{options[:elev]}\\\"\" if options[:elev]\r\n \r\n georss_simple_representation(options.merge(:geom_attr => geom_attr))\r\n when :w3cgeo\r\n georss_w3cgeo_representation(options)\r\n when :gml\r\n georss_gml_representation(options)\r\n end\r\n end", "def test_save_and_load_point_from_wkt\n create_model\n obj_ = SpatialModel.new\n obj_.latlon = 'POINT(1 2)'\n obj_.save!\n id_ = obj_.id\n obj2_ = SpatialModel.find(id_)\n assert_equal(@factory.point(1, 2), obj2_.latlon)\n assert_equal(3785, obj2_.latlon.srid)\n end", "def geo_object\n begin\n if r = geo_object_type # rubocop:disable Lint/AssignmentInCondition\n send(r)\n else\n false\n end\n rescue RGeo::Error::InvalidGeometry\n return nil # TODO: we need to render proper error for this!\n end\n end", "def set_location(lon, lat)\n\t\tfactory = Driver.rgeo_factory_for_column(:location)\n\t\t# update(location: factory.point(lon,lat))\n\t\tself.location = factory.point(lon,lat)\n\tend", "def as_georss(options = {})\r\n dialect= options[:dialect] || :simple\r\n case(dialect)\r\n when :simple\r\n geom_attr = \"\"\r\n geom_attr += \" featuretypetag=\\\"#{options[:featuretypetag]}\\\"\" if options[:featuretypetag]\r\n geom_attr += \" relationshiptag=\\\"#{options[:relationshiptag]}\\\"\" if options[:relationshiptag]\r\n geom_attr += \" floor=\\\"#{options[:floor]}\\\"\" if options[:floor]\r\n geom_attr += \" radius=\\\"#{options[:radius]}\\\"\" if options[:radius]\r\n geom_attr += \" elev=\\\"#{options[:elev]}\\\"\" if options[:elev]\r\n georss_simple_representation(options.merge(:geom_attr => geom_attr))\r\n when :w3cgeo\r\n georss_w3cgeo_representation(options)\r\n when :gml\r\n georss_gml_representation(options)\r\n end\r\n end", "def setLonLat\n # keep in mind that this format is longitude, latitude, not the other way\n self.lonlat = \"POINT(#{longitude} #{latitude})\"\n end", "def geo; end", "def __spatial_column_name=(geom); end", "def to_wgs84!(options={})\n with_validity_check { to_wgs84(options) }\n end", "def georss_simple_representation(options)#:nodoc: \r\n self[0].georss_simple_representation(options)\r\n end", "def mongoize\n\t{:type => 'Point', :coordinates => [@longitude, @latitude]}\nend", "def quote(value, column = nil)\n if value.kind_of?(GeoRuby::SimpleFeatures::Geometry)\n value.as_sdo_geometry\n else\n original_quote(value,column)\n end\n end", "def correct_geo_coords\n coords = params.seek :geo, :geojson, :geometry, :coordinates\n if coords\n array = GeosHelper.geo_coords_to_array(coords)\n params[:geo][:geojson][:geometry][:coordinates] = array\n end\n end", "def georss_simple_representation(options)\r\n georss_ns = options[:georss_ns] || \"georss\"\r\n geom_attr = options[:geom_attr]\r\n \"<#{georss_ns}:polygon#{geom_attr}>\" + self[0].georss_poslist + \"</#{georss_ns}:polygon>\\n\"\r\n end", "def set_geometry\n @geometry = Geometry.find(params[:id])\n end", "def parse_wkt(string)\n value, srid = string.split(\",\")\n @srid = srid if srid.present?\n # factory = factory_settings.get_column_factory(table_name, column, constraints)\n factory = @factory_generator || RGeo::ActiveRecord::RGeoFactorySettings.new\n wkt_parser(factory, value).parse(value)\n rescue RGeo::Error::ParseError\n nil\n end", "def type_cast_with_gis(*args)\n value, column, _ = args\n if value.nil?\n column.spatial? ? value : type_cast_without_gis(*args)\n elsif value.kind_of?(GeoRuby::SimpleFeatures::Geometry)\n #geometry_to_string(value)\n value.as_hex_ewkb\n else\n type_cast_without_gis(*args)\n end\n end", "def set_Geocode(value)\n set_input(\"Geocode\", value)\n end", "def to_georss(*args)\n xml = Geos::Helper.xml_options(*args)[0]\n xml.georss(:where) do\n xml.gml(:Point) do\n xml.gml(:pos, \"#{self.lat} #{self.lng}\")\n end\n end\n end", "def geographic_oregon(subject, data)\n geographic(subject, data, RDF::Vocab::DC[:spatial], {:adminCode1 => \"OR\", :countryBias => \"US\"})\n end", "def update!(**args)\n @lat_lng = args[:lat_lng] if args.key?(:lat_lng)\n @location_type = args[:location_type] if args.key?(:location_type)\n @postal_address = args[:postal_address] if args.key?(:postal_address)\n @radius_meters = args[:radius_meters] if args.key?(:radius_meters)\n end", "def update!(**args)\n @lat_lng = args[:lat_lng] if args.key?(:lat_lng)\n @location_type = args[:location_type] if args.key?(:location_type)\n @postal_address = args[:postal_address] if args.key?(:postal_address)\n @radius_meters = args[:radius_meters] if args.key?(:radius_meters)\n end", "def parse_geom(lat, lon)\n @lat, @lon = lat.to_f, lon.to_f\n\n if defined? GeoRuby\n @geom = GeoRuby::SimpleFeatures::Point.from_x_y(@lon, @lat)\n else\n { lat: @lat, lon: @lon }\n end\n end", "def set_location(photo_id, lat, lon, accuracy = nil)\n request_options = {:photo_id => photo_id, :lat => lat, :lon => lon}\n request_options[:accuracy] = accuracy if !accuracy.nil?\n @flickr.send_request('flickr.photos.geo.setLocation', request_options, :post)\n true\n end", "def update!(**args)\n @geo_target_constant = args[:geo_target_constant] if args.key?(:geo_target_constant)\n end", "def to_geo_json_string\n GeographicItem.connection.select_one(\n \"SELECT ST_AsGeoJSON(#{geo_object_type}::geometry) a \" \\\n \"FROM geographic_items WHERE id=#{id};\")['a']\n end", "def geometry_simplified_type(sql_type)\n case sql_type\n when /geography\\(point/i then :point\n when /geography\\(linestring/i then :line_string\n when /geography\\(polygon/i then :polygon\n when /geography\\(multipoint/i then :multi_point\n when /geography\\(multilinestring/i then :multi_line_string\n when /geography\\(multipolygon/i then :multi_polygon\n when /geography\\(geometrycollection/i then :geometry_collection\n when /geography/i then :geometry\n else\n super\n end\n end", "def to_geo\n self.translate(KA, GEO)\n end", "def write(geom, options = nil)\n unless options.nil?\n old_options = {\n include_srid: include_srid\n }\n\n set_options(options)\n end\n\n size_t = FFI::MemoryPointer.new(:size_t)\n FFIGeos.GEOSWKBWriter_write_r(Geos.current_handle_pointer, ptr, geom.ptr, size_t).get_bytes(0, size_t.read_int)\n ensure\n set_options(old_options) unless old_options.nil?\n end", "def update!(**args)\n @geometry = args[:geometry] if args.key?(:geometry)\n @properties = args[:properties] if args.key?(:properties)\n @type = args[:type] if args.key?(:type)\n end", "def cast(value)\n if value.respond_to?(:to_wkt)\n value\n elsif value\n MySQLPoint::Coordinate.from_wkt(value)\n end\n end", "def test_point_to_json\n create_model\n obj = SpatialModel.new\n assert_match(/\"latlon\":null/, obj.to_json)\n obj.latlon = @factory.point(1.0, 2.0)\n assert_match(/\"latlon\":\"POINT\\s\\(1\\.0\\s2\\.0\\)\"/, obj.to_json)\n end", "def set_data_model\n @data_model = Georeference::GoogleMap\n end", "def set_lonlat\n return unless persisted? && latitude.present? && longitude.present?\n\n sql = <<~SQL\nUPDATE stores\nSET lonlat = ST_SetSRID(ST_MakePoint(longitude, latitude), 4326)\nWHERE id = #{id}\n SQL\n ActiveRecord::Base.connection.execute sql\n end", "def set_geolocation\n @location = Geolocation.find(params[:id]) \n end", "def to_wgs84(options={})\n if is_gridref?\n Osgb::Gridref.new(self, options).to_latlng(:wgs84)\n else\n self.coordinates(:wgs84, options)\n end\n end", "def set_geographic_item\n @geographic_item = GeographicItem.find(params[:id])\n end", "def geojson\n obj = factory.parse_wkt(geometry_as_wkt)\n RGeo::GeoJSON.encode(obj).to_json\n rescue\n Geoblacklight.logger.warn \"Geometry is not valid: #{geom}\"\n default_extent\n end", "def update!(**args)\n @geo_coordinates = args[:geo_coordinates] if args.key?(:geo_coordinates)\n @label = args[:label] if args.key?(:label)\n @location = args[:location] if args.key?(:location)\n end", "def parse_geom(lat, lon)\n @lat, @lon = lat.to_f, lon.to_f\n\n if defined?(\"GeoRuby\")\n @geom = GeoRuby::SimpleFeatures::Point.from_x_y(@lon, @lat)\n else\n { :lat => @lat, :lon => @lon }\n end\n end", "def customize_geojson(geojson, options={})\n geojson\n end", "def quote(value, column = nil)\n if value.kind_of?(GeoRuby::SimpleFeatures::Geometry)\n \"GeomFromWKB(0x#{value.as_hex_wkb},#{value.srid})\"\n else\n original_quote(value,column)\n end\n end", "def as_ewkt(allow_srid=true,allow_z=true,allow_m=true)\r\n if allow_srid\r\n ewkt=\"SRID=#{@srid};\"\r\n else\r\n ewkt=\"\"\r\n end\r\n ewkt << text_geometry_type \r\n ewkt << \"M\" if @with_m and allow_m and (!@with_z or !allow_z) #to distinguish the M from the Z when there is actually no Z... \r\n ewkt << \"(\" << text_representation(allow_z,allow_m) << \")\" \r\n end", "def update!(**args)\n @latlng = args[:latlng] if args.key?(:latlng)\n @radius_km = args[:radius_km] if args.key?(:radius_km)\n end", "def update!(**args)\n @latlng = args[:latlng] if args.key?(:latlng)\n @radius_km = args[:radius_km] if args.key?(:radius_km)\n end", "def update!(**args)\n @latlng = args[:latlng] if args.key?(:latlng)\n @radius_km = args[:radius_km] if args.key?(:radius_km)\n end", "def test_utm_names\n srs = Gdal::Osr::SpatialReference.new()\n srs.set_from_user_input('+proj=utm +zone=11 +south +datum=WGS84')\n \n srs.morph_to_esri()\n assert_equal('GCS_WGS_1984', srs.get_attr_value('GEOGCS'))\n assert_equal('WGS_1984_UTM_Zone_11S', srs.get_attr_value('PROJCS'))\n end", "def update!(**args)\n @lat_lng = args[:lat_lng] if args.key?(:lat_lng)\n @location_type = args[:location_type] if args.key?(:location_type)\n @postal_address = args[:postal_address] if args.key?(:postal_address)\n @radius_miles = args[:radius_miles] if args.key?(:radius_miles)\n end", "def translate_geometry_type(key, value)\n return unless key == 'layer_geom_type_s' && geometry_types.include?(value)\n\n metadata[key] = geometry_types[value]\n end", "def to_wgs84\n ll = to_latlng(@easting, @northing, @type)\n lat_lng = LatLng.new(latitude: ll[:latitude], longitude: ll[:longitude], type: @type)\n lat_lng.to_WGS84\n end", "def text_geometry_type #:nodoc:\r\n \"POINT\"\r\n end", "def set_location\n location = flickr.places.findByLatLon(lat: lat, lon: lon)\n location.size >= 1 ? @location = location.first['name'] : @location = \"Unidentifiable location\"\n end", "def parse(geojson, opts={})\n return nil if geojson.nil? || geojson.try(:empty?)\n geojson_hash = geojson.is_a?(Hash) ? geojson : JSON.parse(geojson)\n decoded_geojson = RGeo::GeoJSON.decode(geojson_hash)\n decoded_geojson = decoded_geojson.first if decoded_geojson.is_a? Enumerable\n opts.fetch(:to, :geometry) == :wkt ? decoded_geojson.try(:geometry).try(:as_text) : decoded_geojson.try(:geometry)\n end", "def __spatial_column_name_wkt; end", "def update!(**args)\n @defines_geometry_for = args[:defines_geometry_for] if args.key?(:defines_geometry_for)\n @geometry_composition = args[:geometry_composition] if args.key?(:geometry_composition)\n end", "def update!(**args)\n @has_geolocation = args[:has_geolocation] if args.key?(:has_geolocation)\n end", "def set_gratitude\n @gratitude = Gratitude.find(params[:id])\n end", "def place=(set_place)\n\t#derive BSON::ObjectId from what is passed in for all 3 cases\n\tif set_place.is_a?(Place)\n\t\t@place=BSON::ObjectId.from_string(set_place.id)\n\telsif set_place.is_a?(String)\n\t\t@place=BSON::ObjectId.from_string(set_place)\n\telse #should already be BSON::ObjectId\n\t\t@place=set_place\n\tend\nend", "def set_lonlat\n return unless persisted? && latitude.present? && longitude.present?\n\n sql = <<~SQL\n UPDATE stores\n SET lonlat = ST_SetSRID(ST_MakePoint(longitude, latitude), 4326)\n WHERE id = #{id}\n SQL\n ActiveRecord::Base.connection.execute sql\n end", "def update!(**args)\n @geometry_id = args[:geometry_id] if args.key?(:geometry_id)\n end", "def use_hidden_geometry=(setting)\n end", "def vector_geom_type\n return 'Mixed' if file_sets.nil? || file_sets.empty?\n geom_field = Solrizer.solr_name('geometry_type')\n file_sets.first.solr_document.fetch(geom_field, ['Mixed']).first\n end", "def rgeo_factory\n return RGeo::Geos.factory(srid: 4326)\n end", "def update!(**args)\n @negative_geo_target_type = args[:negative_geo_target_type] if args.key?(:negative_geo_target_type)\n @positive_geo_target_type = args[:positive_geo_target_type] if args.key?(:positive_geo_target_type)\n end", "def update!(**args)\n @lat = args[:lat] if args.key?(:lat)\n @lon = args[:lon] if args.key?(:lon)\n @radius = args[:radius] if args.key?(:radius)\n end", "def geoObject()\n return @shape ;\n end", "def update\n geos = params[:post_geos].split(\"\\n\").map{|line| line.blank? ? nil : line.strip}.compact\n current_user.settings.post_geos = geos\n\n respond_to do |format|\n format.html { redirect_to client_post_geos_path, notice: 'Post geos was successfully updated.' }\n format.json { head :no_content }\n end\n end", "def append_geom( geom, **other_attrs )\n if geom.is_a?(GeoRuby::SimpleFeatures::Geometry)\n geom = RGeo::WKRep::WKBParser.new.parse(geom.as_wkb) rescue nil\n end\n new_geom = geom\n self.place_geometry.reload\n if place_geometry && !place_geometry.geom.nil?\n union = place_geometry.geom.union(new_geom)\n new_geom = if union.geometry_type == ::RGeo::Feature::MultiPolygon\n union\n else\n f = place_geometry.geom.factory\n f.multi_polygon([union])\n end\n end\n self.save_geom( new_geom, **other_attrs )\n end", "def create_point(lng, lat)\n Rails.logger.debug \"RgeoGeometryAdapter Creating point geometry from lng = #{lng}, lat = #{lat}\"\n @geometry_factory.point(lng, lat)\n end", "def set_GeocodeFlags(value)\n set_input(\"GeocodeFlags\", value)\n end", "def set_GeocodeFlags(value)\n set_input(\"GeocodeFlags\", value)\n end", "def setprojectiontype(*)\n super\n end", "def process_geo\n\t if !params[:geo].nil? && params[:geo].split(\",\").length == 2\n\t\t@lat = params[:geo].split(\",\")[0].to_f\n\t\t@lng = params[:geo].split(\",\")[1].to_f\n\t end\n\t if params[:radius].nil?\n\t\t@radius = 1.0\n\t else\n\t\t@radius = params[:radius].to_f\n\t end\n\tend", "def set_computer_geometry\n @computer_geometry = ComputerGeometry.find(params[:id])\n end", "def geography(name, options = {})\n column(name, :geography, options)\n end", "def write(geom, options = nil)\n unless options.nil?\n old_options = {\n trim: trim,\n old_3d: old_3d,\n rounding_precision: rounding_precision,\n output_dimensions: output_dimensions\n }\n\n set_options(options)\n end\n\n FFIGeos.GEOSWKTWriter_write_r(Geos.current_handle_pointer, ptr, geom.ptr)\n ensure\n set_options(old_options) unless options.nil?\n end", "def set_latlng!\n if ! self.physical_address1.blank? && ! self.physical_address_city.blank? && ! self.physical_address_state.blank? && ! self.physical_address_zip.blank? \n phys_addr = Geokit::Geocoders::YahooGeocoder.geocode self.physical_address1 + \",\" + \n self.physical_address_city + \",\" + self.physical_address_state + \" \" + self.physical_address_zip\n if phys_addr && ! phys_addr.lat.blank? && ! phys_addr.lng.blank? \n latlng = AddrLatlng.new(:agent_id => self.id, :lat => phys_addr.lat, :lng => phys_addr.lng)\n self.addr_latlng = latlng\n self.save\n end\n else\n if ! self.addr_latlng.blank?\n self.addr_latlng.destroy\n end\n end\n end", "def to_georss(*args)\n xml = Geos::Helper.xml_options(*args)[0]\n\n xml.georss(:where) do\n xml.gml(:LineString) do\n xml.gml(:posList) do\n xml << self.to_a.collect do |p|\n \"#{p[1]} #{p[0]}\"\n end.join(' ')\n end\n end\n end\n end", "def set_lat_lng\n return if do_not_connect_to_api\n return if latitude.present? && longitude.present?\n address_txt = URI.encode([street_number, route, city,\n state.to_s + ' ' + zipcode.to_s, country].compact.join(', '))\n\n data = JSON.parse(open(\"http://maps.googleapis.com/maps/api/geocode/json?address=#{address_txt}&sensor=true\").read)\n return unless data['results'].count > 0\n result = data['results'].find { |r| r['geometry'].present? && r['geometry']['location'].present? }\n return unless result\n self.lonlat = \"POINT(#{result['geometry']['location']['lng']} #{result['geometry']['location']['lat']})\"\n end", "def geo_factory\n @geo_factory\n end", "def geo_factory\n @geo_factory\n end", "def notes_geojson\n\t \t{ 'type' => 'FeatureCollection', \n\t \t 'features' => aw.notes_geo \n\t \t}\n\t \tend", "def test_unnamed_to_unknown\n srs = Gdal::Osr::SpatialReference.new()\n srs.set_from_user_input('+proj=mill +datum=WGS84')\n \n srs.morph_to_esri()\n assert_equal('Miller_Cylindrical', srs.get_attr_value('PROJCS'))\n end", "def setWindStr _obj, _args\n \"_obj setWindStr _args;\" \n end", "def set_location\n @location = \"Minneapolis, MN\"\n end", "def update!(**args)\n @lat_deg = args[:lat_deg] if args.key?(:lat_deg)\n @long_deg = args[:long_deg] if args.key?(:long_deg)\n end", "def geometry_simplified_type(field_type)\n case field_type\n when /linestring/i then :linestring\n when /multipoint/i then :multipoint\n when /multilinestring/i then :multilinestring\n when /multipolygon/i then :multipolygon\n when /geometrycollection/i then :geometry\n when /point/i then :point\n when /polygon/i then :polygon\n when /geometry/i then :geometry\n when /geography/i then :geography\n end\n end", "def text_geometry_type #:nodoc:\n 'POINT'\n end", "def partial() \"single/geometryfield\" ; end", "def update_geo_location(record)\n result = Kase.connection.update(\"UPDATE #{table_name} \" + \n \"SET #{table_name}.lng = #{record.lng ? sanitize_sql(record.lng) : 'NULL'}, \" +\n \"#{table_name}.lat = #{record.lat ? sanitize_sql(record.lat) : 'NULL'} \" +\n \"WHERE #{table_name}.id = #{sanitize_sql(record.id)}\")\n result\n end", "def __spatial_column_name_wkb; end", "def update!(**args)\n @feature_id = args[:feature_id] if args.key?(:feature_id)\n @lat_lng = args[:lat_lng] if args.key?(:lat_lng)\n @location_name = args[:location_name] if args.key?(:location_name)\n @mid = args[:mid] if args.key?(:mid)\n @timezone = args[:timezone] if args.key?(:timezone)\n end" ]
[ "0.7202398", "0.6309818", "0.6215792", "0.6098635", "0.6024202", "0.6024202", "0.6006036", "0.59561497", "0.59482825", "0.5900866", "0.5875878", "0.58646154", "0.5804384", "0.5798024", "0.5790414", "0.5756337", "0.56999433", "0.56589955", "0.5646789", "0.5641992", "0.56418467", "0.55582225", "0.55567664", "0.55564994", "0.5552446", "0.55021346", "0.54963887", "0.54948646", "0.549484", "0.5452762", "0.5451549", "0.5449281", "0.5447211", "0.5438733", "0.5391242", "0.538351", "0.5379354", "0.5373788", "0.5372773", "0.5368177", "0.53661674", "0.5364857", "0.5343719", "0.5336343", "0.53293365", "0.53152746", "0.53126425", "0.530628", "0.529244", "0.52918506", "0.52809244", "0.52718574", "0.524966", "0.5249104", "0.5249104", "0.5248838", "0.5241744", "0.52338475", "0.52234244", "0.5221737", "0.52167696", "0.52164245", "0.52065116", "0.52062064", "0.5205709", "0.51995957", "0.51963055", "0.5195114", "0.5193959", "0.5188494", "0.5183163", "0.51819867", "0.5181058", "0.5172281", "0.5165731", "0.51576585", "0.5155496", "0.51518327", "0.51457727", "0.51457727", "0.5137713", "0.51361716", "0.5132797", "0.51317704", "0.5126754", "0.51245683", "0.5124427", "0.5122365", "0.511813", "0.511813", "0.51093346", "0.510277", "0.51001245", "0.5098226", "0.50945807", "0.50878114", "0.50801295", "0.5076361", "0.5067255", "0.5065127", "0.5063746" ]
0.0
-1
convert WKT string into RGeo object
def parse_wkt(string) wkt_parser(string).parse(string) rescue RGeo::Error::ParseError nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_wkt(string)\n value, srid = string.split(\",\")\n @srid = srid if srid.present?\n # factory = factory_settings.get_column_factory(table_name, column, constraints)\n factory = @factory_generator || RGeo::ActiveRecord::RGeoFactorySettings.new\n wkt_parser(factory, value).parse(value)\n rescue RGeo::Error::ParseError\n nil\n end", "def parse(geojson, opts={})\n return nil if geojson.nil? || geojson.try(:empty?)\n geojson_hash = geojson.is_a?(Hash) ? geojson : JSON.parse(geojson)\n decoded_geojson = RGeo::GeoJSON.decode(geojson_hash)\n decoded_geojson = decoded_geojson.first if decoded_geojson.is_a? Enumerable\n opts.fetch(:to, :geometry) == :wkt ? decoded_geojson.try(:geometry).try(:as_text) : decoded_geojson.try(:geometry)\n end", "def from_wkt(wkt_shape)\n a = RGeo::WKRep::WKTParser.new(Gis::FACTORY, support_wkt12: true)\n b = a.parse(wkt_shape)\n spatial_query(b.geometry_type.to_s, wkt_shape)\n end", "def georss_w3cgeo_representation(options)#:nodoc: \r\n self[0].georss_w3cgeo_representation(options)\r\n end", "def georss_w3cgeo_representation(options)\r\n w3cgeo_ns = options[:w3cgeo_ns] || \"geo\"\r\n \r\n \"<#{w3cgeo_ns}:lat>#{self[0][0].y}</#{w3cgeo_ns}:lat>\\n<#{w3cgeo_ns}:long>#{self[0][0].x}</#{w3cgeo_ns}:long>\\n\"\r\n end", "def geojson\n obj = factory.parse_wkt(geometry_as_wkt)\n RGeo::GeoJSON.encode(obj).to_json\n rescue\n Geoblacklight.logger.warn \"Geometry is not valid: #{geom}\"\n default_extent\n end", "def wkt=(value)\n begin\n a = ::Gis::FACTORY.parse_wkt(value)\n b = a.geometry_type.type_name.tableize.singularize.to_sym\n\n self.geographic_item = GeographicItem.new(b => a)\n @wkt_error = nil\n rescue RGeo::Error::RGeoError => e\n self.geographic_item = nil\n @wkt_error = e.message\n end\n end", "def georss_w3cgeo_representation(options = {}) #:nodoc:\r\n w3cgeo_ns = options[:w3cgeo_ns] || \"geo\"\r\n point = self.center\r\n \"<#{w3cgeo_ns}:lat>#{point.y}</#{w3cgeo_ns}:lat>\\n<#{w3cgeo_ns}:long>#{point.x}</#{w3cgeo_ns}:long>\\n\"\r\n end", "def parse(ewkt)\r\n @factory.reset\r\n @tokenizer_structure = TokenizerStructure.new(ewkt)\r\n @with_z=false\r\n @with_m=false\r\n @is_3dm = false\r\n parse_geometry(true)\r\n @srid=nil\r\n end", "def to_wgs84\n ll = to_latlng(@easting, @northing, @type)\n lat_lng = LatLng.new(latitude: ll[:latitude], longitude: ll[:longitude], type: @type)\n lat_lng.to_WGS84\n end", "def to_geo\n self.translate(KA, GEO)\n end", "def test_save_and_load_point_from_wkt\n create_model\n obj_ = SpatialModel.new\n obj_.latlon = 'POINT(1 2)'\n obj_.save!\n id_ = obj_.id\n obj2_ = SpatialModel.find(id_)\n assert_equal(@factory.point(1, 2), obj2_.latlon)\n assert_equal(3785, obj2_.latlon.srid)\n end", "def geometry_as_wkt\n return geom unless geom.match?(/ENVELOPE/)\n\n envelope_to_polygon\n end", "def parse_geom(lat, lon)\n @lat, @lon = lat.to_f, lon.to_f\n\n if defined? GeoRuby\n @geom = GeoRuby::SimpleFeatures::Point.from_x_y(@lon, @lat)\n else\n { lat: @lat, lon: @lon }\n end\n end", "def as_georss(options = {})\r\n dialect= options[:dialect] || :simple\r\n case(dialect)\r\n when :simple\r\n geom_attr = \"\"\r\n geom_attr += \" featuretypetag=\\\"#{options[:featuretypetag]}\\\"\" if options[:featuretypetag]\r\n geom_attr += \" relationshiptag=\\\"#{options[:relationshiptag]}\\\"\" if options[:relationshiptag]\r\n geom_attr += \" floor=\\\"#{options[:floor]}\\\"\" if options[:floor]\r\n geom_attr += \" radius=\\\"#{options[:radius]}\\\"\" if options[:radius]\r\n geom_attr += \" elev=\\\"#{options[:elev]}\\\"\" if options[:elev]\r\n \r\n georss_simple_representation(options.merge(:geom_attr => geom_attr))\r\n when :w3cgeo\r\n georss_w3cgeo_representation(options)\r\n when :gml\r\n georss_gml_representation(options)\r\n end\r\n end", "def load_geojson(geojson_file)\n\t\t\t\tgeo_json = File.read(geojson_file)\n\t\t\t\t@features = RGeo::GeoJSON.decode(geo_json, json_parser: :json)\n\t\t\t\t@geometry=factory.parse_wkt(features.first.geometry.to_s)\n\t\t\tend", "def to_geojson_s\n s = nil\n if shapefile && shapefile.file && shapefile.file.file\n File.open(shapefile.file.file, \"r\") do |file|\n s = file.read\n end\n end\n s\n end", "def parse_geom(lat, lon)\n @lat, @lon = lat.to_f, lon.to_f\n\n if defined?(\"GeoRuby\")\n @geom = GeoRuby::SimpleFeatures::Point.from_x_y(@lon, @lat)\n else\n { :lat => @lat, :lon => @lon }\n end\n end", "def to_WGS84\n\n\t if @type == :ie\n\t @a = 6377340.189\n\t @b = 6356034.447\n else\n @a = 6377563.396\n @b = 6356256.909\n end\n\n @eSquared = ((@a * @a) - (@b * @b)) / (@a * @a)\n\n @phi = deg_to_rad(@latitude)\n @lambda = deg_to_rad(@longitude)\n @v = @a / (Math.sqrt(1 - @eSquared * sin_pow_2(@phi)))\n @H = 0\n @x = (@v + @H) * Math.cos(@phi) * Math.cos(@lambda)\n @y = (@v + @H) * Math.cos(@phi) * Math.sin(@lambda)\n @z = ((1 - @eSquared) * @v + @H) * Math.sin(@phi)\n\n @tx = 446.448\n @ty = -124.157\n @tz = 542.060\n\n @s = -0.0000204894\n @rx = deg_to_rad( 0.00004172222)\n @ry = deg_to_rad( 0.00006861111)\n @rz = deg_to_rad( 0.00023391666)\n\n @xB = @tx + (@x * (1 + @s)) + (-@rx * @y) + (@ry * @z)\n @yB = @ty + (@rz * @x) + (@y * (1 + @s)) + (-@rx * @z)\n @zB = @tz + (-@ry * @x) + (@rx * @y) + (@z * (1 + @s))\n\n @a = 6378137.000\n @b = 6356752.3141\n @eSquared = ((@a * @a) - (@b * @b)) / (@a * @a)\n\n @lambdaB = rad_to_deg(Math.atan(@yB / @xB))\n @p = Math.sqrt((@xB * @xB) + (@yB * @yB))\n @phiN = Math.atan(@zB / (@p * (1 - @eSquared)))\n\n (1..10).each do |i|\n @v = @a / (Math.sqrt(1 - @eSquared * sin_pow_2(@phiN)))\n @phiN1 = Math.atan((@zB + (@eSquared * @v * Math.sin(@phiN))) / @p)\n @phiN = @phiN1\n end\n\n @phiB = rad_to_deg(@phiN)\n\n { :latitude => @phiB, :longitude => @lambdaB }\n\n end", "def to_geo_json_string\n GeographicItem.connection.select_one(\n \"SELECT ST_AsGeoJSON(#{geo_object_type}::geometry) a \" \\\n \"FROM geographic_items WHERE id=#{id};\")['a']\n end", "def as_georss(options = {})\r\n dialect= options[:dialect] || :simple\r\n case(dialect)\r\n when :simple\r\n geom_attr = \"\"\r\n geom_attr += \" featuretypetag=\\\"#{options[:featuretypetag]}\\\"\" if options[:featuretypetag]\r\n geom_attr += \" relationshiptag=\\\"#{options[:relationshiptag]}\\\"\" if options[:relationshiptag]\r\n geom_attr += \" floor=\\\"#{options[:floor]}\\\"\" if options[:floor]\r\n geom_attr += \" radius=\\\"#{options[:radius]}\\\"\" if options[:radius]\r\n geom_attr += \" elev=\\\"#{options[:elev]}\\\"\" if options[:elev]\r\n georss_simple_representation(options.merge(:geom_attr => geom_attr))\r\n when :w3cgeo\r\n georss_w3cgeo_representation(options)\r\n when :gml\r\n georss_gml_representation(options)\r\n end\r\n end", "def to_georss(*args)\n xml = Geos::Helper.xml_options(*args)[0]\n xml.georss(:where) do\n xml.gml(:Point) do\n xml.gml(:pos, \"#{self.lat} #{self.lng}\")\n end\n end\n end", "def wgs_coordinates\n return @data[\"WGS_COORDINATES\"] if @data[\"WGS_COORDINATES\"]\n query = Geocoder::Query.new(\n coordinates, {\n coord_in: 'utmk',\n coord_out: 'wgs84'\n })\n lookup = Geocoder::Lookup::Olleh.new\n wgs = lookup.search(query).first.converted_coord\n @data[\"WGS_COORDINATES\"] = wgs\n wgs\n end", "def to_wgs84!(options={})\n with_validity_check { to_wgs84(options) }\n end", "def test_gk_to_wgs84\n from = Proj4::Point.new(@rw, @hw, @zw)\n to = @proj_gk.transform(@proj_wgs84, from)\n assert_not_equal from.object_id, to.object_id\n assert_in_delta @lon, to.x * Proj4::RAD_TO_DEG, PRECISION\n assert_in_delta @lat, to.y * Proj4::RAD_TO_DEG, PRECISION\n assert_in_delta 0, to.z, PRECISION\n end", "def rgeo_factory\n return RGeo::Geos.factory(srid: 4326)\n end", "def parse_wkb(value)\n first_ring_offset = (2 * UINT32_BYTESIZE) + 1\n ring_count = to_uint32(value[first_ring_offset, UINT32_BYTESIZE])\n offset = (3 * UINT32_BYTESIZE) + 1\n\n rings = ring_count.times.map do\n start = offset + UINT32_BYTESIZE\n point_count = to_uint32(value[offset...start])\n offset = (2 * DOUBLE_BYTESIZE * point_count) + start\n\n points = value[start...offset].unpack(\"#{DOUBLE_PACKFLAG}*\")\n points.each_slice(2).with_object([]) do |(lon, lat), memo|\n memo << Spatial::Point.new(lat, lon)\n end\n end\n\n Spatial::Polygon.new(rings)\n end", "def to_georss(*args)\n xml = Geos::Helper.xml_options(*args)[0]\n\n xml.georss(:where) do\n xml.gml(:LineString) do\n xml.gml(:posList) do\n xml << self.to_a.collect do |p|\n \"#{p[1]} #{p[0]}\"\n end.join(' ')\n end\n end\n end\n end", "def text_representation(allow_z=true,allow_m=true) #:nodoc:\r\n @geometries.collect{|geometry| geometry.as_ewkt(false,allow_z,allow_m)}.join(\",\")\r\n end", "def to_wgs84(options={})\n if is_gridref?\n Osgb::Gridref.new(self, options).to_latlng(:wgs84)\n else\n self.coordinates(:wgs84, options)\n end\n end", "def to_wgs84(error_if_incompatible = false)\r\n parameter_count = 7\r\n out_values = FFI::MemoryPointer.new(:double, parameter_count)\r\n Api.proj_coordoperation_get_towgs84_values(self.context, self, out_values, parameter_count, error_if_incompatible ? 1 : 0)\r\n out_values.read_array_of_double(parameter_count)\r\n end", "def get_geo_transform\n @gdalfile.get_geo_transform\n end", "def parse_string string\n self.coords = string.split(separator).map(&:to_f)\n end", "def de_format_locations(string)\n # lat => '45.5192172',\n # long => '-122.6755683',\n # radius => 0.1,\n # look for locations\n loc.each do |k|\n sp = k.split('point_radius:')\n end\n string\n end", "def parse(ewkb)\r\n @factory.reset\r\n @unpack_structure=UnpackStructure::new(ewkb)\r\n @with_z = false\r\n @with_m = false\r\n parse_geometry\r\n @unpack_structure.done\r\n @srid=nil\r\n end", "def get_location(str)\n u=URI.encode(\"http://maps.google.com/maps/api/geocode/xml?sensor=false&address=#{str}\")\n loc=(Hpricot.XML(open(u)))/'//location'\n h={} \n h['lat']=(loc/:lat).inner_text\n h['lng']=(loc/:lng).inner_text\n h\n end", "def process_geo\n\t if !params[:geo].nil? && params[:geo].split(\",\").length == 2\n\t\t@lat = params[:geo].split(\",\")[0].to_f\n\t\t@lng = params[:geo].split(\",\")[1].to_f\n\t end\n\t if params[:radius].nil?\n\t\t@radius = 1.0\n\t else\n\t\t@radius = params[:radius].to_f\n\t end\n\tend", "def test_wgs84_to_gk\n point = @proj_wgs84.transform(@proj_gk, Proj4::Point.new(@lon * Proj4::DEG_TO_RAD, @lat * Proj4::DEG_TO_RAD, 0))\n assert_equal @rw, point.x.round\n assert_equal @hw, point.y.round\n assert_in_delta @zw, point.z, PRECISION\n end", "def georss_simple_representation(options)\r\n georss_ns = options[:georss_ns] || \"georss\"\r\n geom_attr = options[:geom_attr]\r\n \"<#{georss_ns}:polygon#{geom_attr}>\" + self[0].georss_poslist + \"</#{georss_ns}:polygon>\\n\"\r\n end", "def test_ogr_transform()\n return if not @have_proj4\n\n utm_srs = Gdal::Osr::SpatialReference.new()\n utm_srs.set_utm(11)\n utm_srs.set_well_known_geog_cs('WGS84')\n\n ll_srs = Gdal::Osr::SpatialReference.new()\n ll_srs.set_well_known_geog_cs('WGS84')\n\n ct = Gdal::Osr::CoordinateTransformation.new(ll_srs, utm_srs)\n\n pnt = Gdal::Ogr.create_geometry_from_wkt('POINT(-117.5 32.0)', ll_srs)\n result = pnt.transform(ct)\n\n out_srs = pnt.get_spatial_reference().export_to_pretty_wkt()\n\n assert_equal(out_srs[0..5], 'PROJCS',\n 'output srs corrupt, ref counting issue?')\n end", "def wkt_from_cg_point_list(point)\n point.split(\" \").reverse.join(\" \")\n end", "def wkt_from_cg_point_list(point)\n point.split(\" \").reverse.join(\" \")\n end", "def georss_simple_representation(options)#:nodoc: \r\n self[0].georss_simple_representation(options)\r\n end", "def cast(value)\n if value.respond_to?(:to_wkt)\n value\n elsif value\n MySQLPoint::Coordinate.from_wkt(value)\n end\n end", "def from_geos_to_quad_tree(geom, zoom)\n geom = case geom\n when Geos::Geometry\n geom\n when /^[A-Fa-f0-9]+$/\n Geos::WkbReader.new.read_hex(geom)\n when /^[PLMCG]/\n Geos::WktReader.new.read(geom)\n when String\n Geos::WkbReader.new.read(geom)\n end\n\n coord_seq = geom.centroid.coord_seq\n from_lng_lat_to_quad_tree(coord_seq.get_x(0), coord_seq.get_y(0), zoom)\n end", "def convert_to_geojson\n\t\tgeojson = RGeo::GeoJSON.encode(@features_collection).to_json\n\t\tsave_geojson_to_file(geojson)\n\t\tgeojson\n\tend", "def test_point_to_json\n create_model\n obj = SpatialModel.new\n assert_match(/\"latlon\":null/, obj.to_json)\n obj.latlon = @factory.point(1.0, 2.0)\n assert_match(/\"latlon\":\"POINT\\s\\(1\\.0\\s2\\.0\\)\"/, obj.to_json)\n end", "def geo_object\n begin\n if r = geo_object_type # rubocop:disable Lint/AssignmentInCondition\n send(r)\n else\n false\n end\n rescue RGeo::Error::InvalidGeometry\n return nil # TODO: we need to render proper error for this!\n end\n end", "def parse_point_list(geometry_type)\r\n @factory.begin_geometry(geometry_type,@srid)\r\n \r\n token = ''\r\n while token != ')'\r\n @factory.begin_geometry(Point,@srid)\r\n token = parse_coords\r\n if token.nil?\r\n raise EWKTFormatError.new(\"EWKT string not correctly terminated\")\r\n end\r\n @factory.end_geometry(@with_z,@with_m)\r\n end\r\n \r\n @factory.end_geometry(@with_z,@with_m)\r\n end", "def geometry_type_ogrinfo(shp_filename)\n IO.popen(\"#{Settings.gdal_path}ogrinfo -ro -so -al '#{shp_filename}'\") do |file|\n file.readlines.each do |line|\n next unless line =~ /^Geometry:\\s+(.*)\\s*$/\n\n logger.debug \"generate-mods: parsing ogrinfo geometry output: #{line}\"\n return Regexp.last_match(1).gsub('3D', '').gsub('Multi', '').strip\n end\n end\n end", "def marshal_load(s)\n# Unpack coords from unmarshaled string\n@coords = s.unpack(\"w*\") # and use them to initialize the object\nend", "def test_utm_names\n srs = Gdal::Osr::SpatialReference.new()\n srs.set_from_user_input('+proj=utm +zone=11 +south +datum=WGS84')\n \n srs.morph_to_esri()\n assert_equal('GCS_WGS_1984', srs.get_attr_value('GEOGCS'))\n assert_equal('WGS_1984_UTM_Zone_11S', srs.get_attr_value('PROJCS'))\n end", "def doc2layer_geom_type(doc)\n sdtstype = doc.xpath('//metadata/spdoinfo/ptvctinf/sdtsterm/sdtstype').text\n return 'Polygon' if sdtstype.match /G-polygon/i\n return 'Point' if sdtstype.match /Point/i\n return 'Line' if sdtstype.match /String/i\n\n direct = doc.xpath('//metadata/spdoinfo/direct').text\n return 'Raster' if direct.match /Raster/i\n return 'Point' if direct.match /Point/i\n return 'Polygon' if direct.match /Vector/i\n\n indspref = doc.xpath('//metadata/spdoinfo/indspref').text\n return 'Table' if indspref.match /Table/i\n\n # undetermined\n return 'UNDETERMINED'\n end", "def extract_coordinates(parsed)\n parsed['results'].first['geometry']['location']\nend", "def valid_geometry?(solr_geom)\n return false unless solr_geom.present?\n\n # :solr_geom => \"ENVELOPE(#{w}, #{e}, #{n}, #{s})\",\n # Solr docs say: \"minX, maxX, maxY, minY order\"\n # maximum boundary: (minX=-180.0,maxX=180.0,minY=-90.0,maxY=90.0)\n match = solr_geom.match(/ENVELOPE\\(([\\d\\.\\-]+)[\\ \\,]*([\\d\\.\\-]+)[\\ \\,]*([\\d\\.\\-]+)[\\ \\,]*([\\d\\.\\-]+)\\)/)\n\n # Not parsable ENVELOPE() syntax?\n return false unless match.present?\n\n minX, maxX, maxY, minY = match.captures\n return false if minX.to_f < -180 ||\n maxX.to_f > 180 ||\n maxY.to_f > 90 ||\n minY.to_f < -90\n\n return true\nend", "def latitude\n self.wkb_geometry.coordinates[1]\n end", "def build_geom(feature)\n if make_valid?\n geom = ActiveRecord::Base.connection.select_value(\"SELECT ST_CollectionExtract(ST_MakeValid(ST_Force_2D(ST_GeomFromKML('#{feature}'))),3)\")\n else\n geom = ActiveRecord::Base.connection.select_value(\"SELECT ST_Force_2D(ST_GeomFromKML('#{feature}'))\")\n end\n end", "def correct_geo_coords\n coords = params.seek :geo, :geojson, :geometry, :coordinates\n if coords\n array = GeosHelper.geo_coords_to_array(coords)\n params[:geo][:geojson][:geometry][:coordinates] = array\n end\n end", "def as_ewkt(allow_srid=true,allow_z=true,allow_m=true)\r\n if allow_srid\r\n ewkt=\"SRID=#{@srid};\"\r\n else\r\n ewkt=\"\"\r\n end\r\n ewkt << text_geometry_type \r\n ewkt << \"M\" if @with_m and allow_m and (!@with_z or !allow_z) #to distinguish the M from the Z when there is actually no Z... \r\n ewkt << \"(\" << text_representation(allow_z,allow_m) << \")\" \r\n end", "def test_geojson_file_as_param\n file_name = \"#{File.dirname(__FILE__)}/geojson_files/line_string_data.json\"\n file = File.new(file_name, 'r')\n gpx_file = GPX::GeoJSON.convert_to_gpx(geojson_file: file)\n assert_equal(1, gpx_file.tracks.size)\n end", "def parse(kml)\n @factory.reset\n @with_z = false\n @parser = REXML::Parsers::PullParser.new(kml)\n while @parser.has_next?\n e = @parser.pull\n if e.start_element?\n if(type = ELEMENT_MAP[e[0]])\n @factory.begin_geometry(type)\n else\n @buffer = \"\" if(e[0] == \"coordinates\") # clear the buffer\n accumulate_start(e)\n end\n elsif e.end_element?\n if(ELEMENT_MAP[e[0]])\n @factory.end_geometry(@with_z)\n @buffer = \"\" # clear the buffer\n else\n accumulate_end(e)\n if(e[0] == \"coordinates\")\n parse_coordinates(@buffer)\n @buffer = \"\" # clear the buffer\n end\n end\n elsif e.text? \n accumulate_text(e)\n elsif e.cdata?\n accumulate_cdata(e)\n end\n end\n @factory.geometry.dup\n end", "def preprocess(name, response)\n # remove commas (they are annoying in numbers) and spaces\n if response.is_a?(String) && (ToHTML::rm_prefix(name) != \"geometry\")\n return response.strip.downcase.gsub(/,/, \"\").gsub(/\\s+/, \" \").gsub(/^\\+/, \"\")\n end\n \n return response.to_s\n end", "def test_unnamed_to_unknown\n srs = Gdal::Osr::SpatialReference.new()\n srs.set_from_user_input('+proj=mill +datum=WGS84')\n \n srs.morph_to_esri()\n assert_equal('Miller_Cylindrical', srs.get_attr_value('PROJCS'))\n end", "def intersecting_radius_of_wkt_sql(wkt, distance)\n \"ST_DWithin((#{GeographicItem::GEOGRAPHY_SQL}), ST_Transform( ST_GeomFromText('#{wkt}', \" \\\n \"4326), 4326), #{distance})\"\n end", "def deserialize(value)\n if value.respond_to?(:to_wkt)\n value\n elsif value\n MySQLPoint::Coordinate.from_wkb(value[4..-1])\n end\n end", "def geographic_oregon(subject, data)\n geographic(subject, data, RDF::Vocab::DC[:spatial], {:adminCode1 => \"OR\", :countryBias => \"US\"})\n end", "def convert_location(address)\n loc_query = Addressable::URI.new(\n :scheme => \"http\",\n :host => \"maps.googleapis.com\",\n :path => \"/maps/api/geocode/json\",\n :query_values => {:address => \"#{address}\",\n :sensor => \"false\"}\n )\n\n geolocation_json = RestClient.get(loc_query.to_s)\n location = JSON.parse(geolocation_json)\n\n latitude = location[\"results\"][0][\"geometry\"][\"location\"][\"lat\"]\n longitude = location[\"results\"][0][\"geometry\"][\"location\"][\"lng\"]\n\n [latitude, longitude]\n end", "def parse(row)\n gid, name, @ascii, @alternates, lat, lon, feat, kind,\n @nation, _cc2, @region, @code, _adm3, _adm4, @pop, @ele,\n @gtop, @tz, @up = row.split(/\\t/)\n\n @name = name #name.encode(Encoding::ISO_8859_1)\n @gid = @geoname_id = gid.to_i\n @kind = human_code(kind)\n\n @abbr = @alternates.split(',').find { |n| n =~ /^[A-Z]{2,3}$/ }\n\n parse_geom(lat, lon)\n # puts \"#{@kind} - #{@code} - #{@region}\"\n end", "def text_geometry_type #:nodoc:\r\n \"POINT\"\r\n end", "def geocode(s)\n @geocoder.run(s)\n end", "def create_projected_point(lng, lat)\n Rails.logger.debug \"RgeoGeometryAdapter Creating point geometry from lng = #{lng}, lat = #{lat}\"\n @geometry_factory.project(create_point(lng, lat))\n end", "def test_point_to_waypoint\n pt = [-118, 34]\n waypoint = GPX::GeoJSON.send(:point_to_waypoint, pt, nil)\n assert_equal(34, waypoint.lat)\n assert_equal(-118, waypoint.lon)\n end", "def resize_to_geometry_string(geometry_string)\n manipulate! do |img|\n new_img = img.change_geometry(geometry_string) do |new_width, new_height|\n img.resize(new_width, new_height)\n end\n destroy_image(img)\n new_img = yield(new_img) if block_given?\n new_img\n end\n end", "def mongoize\n\t{:type => 'Point', :coordinates => [@longitude, @latitude]}\nend", "def to_lat\n self.translate(\"#{GEO}#{KA}\", \"#{LAT}#{LAT}\")\n end", "def test_point_to_trackpoint\n pt = [-118, 34]\n waypoint = GPX::GeoJSON.send(:point_to_track_point, pt, nil)\n assert_equal(34, waypoint.lat)\n assert_equal(-118, waypoint.lon)\n end", "def parse_lat_long(raw)\n m = raw.match(/(\\d+)\\s+(\\d+\\.?\\d*)\\s*([NS])\\s+(\\d+)\\s+(\\d+\\.?\\d*)\\s*([WE])/i)\n if m.nil? || m.size != 5\n return nil\n else\n # Parse out degrees and minutes\n latitude = m[1].to_f + (m[2].to_f / 60.0)\n longitude = m[4].to_f + (m[5].to_f / 60.0)\n\n # Figure out negative vs positive\n latitude *= (m[3] =~ /N/i ? 1 : -1)\n longitude += (m[6] =~ /E/i ? 1 : -1)\n\n return [latitude, longitude]\n end\n end", "def bbox_from_string(string, factory)\n return unless string\n minlon, minlat, maxlon, maxlat = string.split(',').collect { |i| i.to_f }\n bbox = RGeo::Cartesian::BoundingBox.new(factory)\n bbox.add(factory.point(minlon, minlat)).add(factory.point(maxlon, maxlat))\n end", "def georss_gml_representation(options)#:nodoc: \r\n self[0].georss_gml_representation(options)\r\n end", "def text_geometry_type #:nodoc:\n 'POINT'\n end", "def notes_geojson\n\t \t{ 'type' => 'FeatureCollection', \n\t \t 'features' => aw.notes_geo \n\t \t}\n\t \tend", "def geocode!(instance)\n result = coordinates(instance).first\n if result\n {\n lat: result.latitude,\n lon: result.longitude,\n region: result.state_code,\n locality: result.city,\n postalcode: result.postal_code,\n address: result.address\n }\n else\n {}\n end\n end", "def geo; end", "def create_point(lng, lat)\n Rails.logger.debug \"RgeoGeometryAdapter Creating point geometry from lng = #{lng}, lat = #{lat}\"\n @geometry_factory.point(lng, lat)\n end", "def create_features_from_file\n pg_lyr = @pg_ds.get_layer(0)\n dst_feat = Gdal::Ogr::Feature.new( feature_def = pg_lyr.get_layer_defn() )\n \n\t\twkt_list = [ '10', '2', '1', '3d_1', '4', '5', '6' ]\n wkt = nil\n \n wkt_list.each do |item|\n file_name = File.join('..', '..','ogr','data','wkb_wkt',item + '.wkt')\n\t\t\tFile.open(file_name, 'rb') do |file|\n\t\t\t wkt = file.read\n\t\t\tend\n\t\t\n\t\t\tgeom = Gdal::Ogr.create_geometry_from_wkt( wkt )\n \n\t\t\t## Write geometry as a new Postgis feature.\n\t\t\tdst_feat.set_geometry_directly( geom )\n\t\t\tdst_feat.set_field( 'PRFEDEA', item )\n\t\t\tpg_lyr.create_feature( dst_feat )\n\t\tend\n\tend", "def simple_poly tolerance=0.001, precision = 4, bbox = false \n self.class.find_simple_geojson self.id, tolerance, precision, bbox\n end", "def simple_poly tolerance=0.001, precision = 4, bbox = false \n self.class.find_simple_geojson self.id, tolerance, precision, bbox\n end", "def type_cast_with_gis(*args)\n value, column, _ = args\n if value.nil?\n column.spatial? ? value : type_cast_without_gis(*args)\n elsif value.kind_of?(GeoRuby::SimpleFeatures::Geometry)\n #geometry_to_string(value)\n value.as_hex_ewkb\n else\n type_cast_without_gis(*args)\n end\n end", "def test_translate_nad_shift()\n srs = Gdal::Osr::SpatialReference.new()\n srs.set_gs(-117.0, 100000.0, 100000)\n srs.set_geog_cs('Test GCS', 'Test Datum', 'WGS84',\n Gdal::Osr::SRS_WGS84_SEMIMAJOR,\n Gdal::Osr::SRS_WGS84_INVFLATTENING)\n\n srs.set_towgs84(1, 2, 3)\n\n assert_equal(srs.get_towgs84(), [1,2,3,0,0,0,0])\n proj4 = srs.export_to_proj4()\n\n srs2 = Gdal::Osr::SpatialReference.new()\n srs2.import_from_proj4(proj4)\n\n assert_equal(srs2.get_towgs84(), [1,2,3,0,0,0,0])\n end", "def geometry_simplified_type(sql_type)\n case sql_type\n when /geography\\(point/i then :point\n when /geography\\(linestring/i then :line_string\n when /geography\\(polygon/i then :polygon\n when /geography\\(multipoint/i then :multi_point\n when /geography\\(multilinestring/i then :multi_line_string\n when /geography\\(multipolygon/i then :multi_polygon\n when /geography\\(geometrycollection/i then :geometry_collection\n when /geography/i then :geometry\n else\n super\n end\n end", "def test_lat_lon_xml_format\n tracepoint = build(:tracepoint, :latitude => 0.00004 * GeoRecord::SCALE, :longitude => 0.00008 * GeoRecord::SCALE)\n\n assert_match /lat=\"0.0000400\"/, tracepoint.to_xml_node.to_s\n assert_match /lon=\"0.0000800\"/, tracepoint.to_xml_node.to_s\n end", "def parse(str_)\n str_ = str_.downcase\n @cur_factory = @exact_factory\n if @cur_factory\n @cur_factory_support_z = @cur_factory.property(:has_z_coordinate) ? true : false\n @cur_factory_support_m = @cur_factory.property(:has_m_coordinate) ? true : false\n end\n @cur_expect_z = nil\n @cur_expect_m = nil\n @cur_srid = @default_srid\n if @support_ewkt && str_ =~ /^srid=(\\d+);/i\n str_ = $'\n @cur_srid = $1.to_i\n end\n begin\n _start_scanner(str_)\n obj_ = _parse_type_tag(false)\n if @cur_token && !@ignore_extra_tokens\n raise Error::ParseError, \"Extra tokens beginning with #{@cur_token.inspect}.\"\n end\n ensure\n _clean_scanner\n end\n obj_\n end", "def parse(tz_string); end", "def geo_json_facet\n return nil if geo_json.nil?\n if a = RGeo::GeoJSON.decode(geo_json)\n return spatial_query(a.geometry_type.to_s, a.to_s)\n else\n return nil\n end\n end", "def relate(geom)\n check_geometry(geom)\n FFIGeos.GEOSRelate_r(Geos.current_handle_pointer, ptr, geom.ptr)\n end", "def to_WGS\n [@lat - @d_lat, @lon - @d_lon]\n end", "def extract_geolocation\n img_lat = get_exif('GPSLatitude')[0][1].split(', ') rescue nil\n img_lng = get_exif('GPSLongitude')[0][1].split(', ') rescue nil\n lat_ref = get_exif('GPSLatitudeRef')[0][1] rescue nil\n lng_ref = get_exif('GPSLongitudeRef')[0][1] rescue nil\n return unless img_lat && img_lng && lat_ref && lng_ref \n latitude = to_frac(img_lat[0]) + (to_frac(img_lat[1])/60) + (to_frac(img_lat[2])/3600)\n longitude = to_frac(img_lng[0]) + (to_frac(img_lng[1])/60) + (to_frac(img_lng[2])/3600) \n latitude = latitude * -1 if lat_ref == 'S' # (N is +, S is -)\n longitude = longitude * -1 if lng_ref == 'W' # (W is -, E is +) \n self.latitude = latitude\n self.longitude = longitude\n end", "def from_tnetstring(str)\n from_ruby(::TNetstring.parse(str)[0])\n end", "def test_gk_to_wgs84_forward\r\n transform = Proj::Transformation.new(@crs_gk, @crs_wgs84)\r\n from = Proj::Coordinate.new(x: 5428192.0, y: 3458305.0, z: -5.1790915237)\r\n to = transform.forward(from)\r\n\r\n assert_in_delta(48.98963932450735, to.x, PRECISION)\r\n assert_in_delta(8.429263044355544, to.y, PRECISION)\r\n assert_in_delta(-5.1790915237, to.z, PRECISION)\r\n assert_in_delta(0, to.t, PRECISION)\r\n end", "def parse_multi_point\r\n if @tokenizer_structure.get_next_token !='('\r\n raise EWKTFormatError.new('Invalid MultiPoint')\r\n end\r\n \r\n token = @tokenizer_structure.check_next_token\r\n if token == '('\r\n #specification\r\n @factory.begin_geometry(MultiPoint,@srid)\r\n \r\n token = ''\r\n while token != ')'\r\n parse_point\r\n token = @tokenizer_structure.get_next_token\r\n if token.nil?\r\n raise EWKTFormatError.new(\"EWKT string not correctly terminated\")\r\n end\r\n end\r\n \r\n @factory.end_geometry(@with_z,@with_m)\r\n else\r\n #postgis\r\n parse_point_list(MultiPoint)\r\n end\r\n end" ]
[ "0.71993065", "0.6746403", "0.64745647", "0.6186708", "0.6157979", "0.6085415", "0.60383284", "0.597152", "0.59067166", "0.5870072", "0.58491415", "0.5817878", "0.57695055", "0.56940246", "0.5660838", "0.5649549", "0.5619508", "0.55949056", "0.55864155", "0.55830747", "0.5580722", "0.5549287", "0.5543105", "0.5514618", "0.5501872", "0.5390363", "0.5386805", "0.5371616", "0.5355064", "0.5350945", "0.53375506", "0.5325984", "0.52597517", "0.52555704", "0.52214646", "0.52067256", "0.5166745", "0.5166456", "0.5151662", "0.51485187", "0.5143313", "0.5143313", "0.51306087", "0.5102835", "0.5096388", "0.50869226", "0.5079684", "0.5078572", "0.50626737", "0.50566053", "0.50524795", "0.5047009", "0.50454324", "0.5036977", "0.5016315", "0.50135905", "0.49744534", "0.49707174", "0.4945105", "0.49419224", "0.49341008", "0.49154234", "0.49058658", "0.4903131", "0.48987815", "0.48776165", "0.48750445", "0.48609063", "0.4860779", "0.48559904", "0.48425493", "0.48403898", "0.4832845", "0.48283887", "0.48238805", "0.48146564", "0.48023158", "0.4800274", "0.47944528", "0.47901225", "0.4788413", "0.47841007", "0.47736067", "0.4769924", "0.47674602", "0.47539598", "0.47539598", "0.47535822", "0.4746929", "0.47439757", "0.47435957", "0.47433838", "0.47419444", "0.47334978", "0.4719557", "0.4717437", "0.47071236", "0.4704932", "0.46913528", "0.46789235" ]
0.6931328
1
The +name+ split and joined into a string seperated by "/"'s
def path name.split("::").join("/").downcase end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def split_name\n\t\t@full_name.split('')\n\tend", "def parts\n name.split(\" \")\n end", "def split_name(name)\n file_name = File.basename(name)\n mres = /^([^\\/\\.]+)\\.(.+)$/i.match(file_name)\n mres.nil? ? [file_name, ''] : [mres[1], mres[2]]\n end", "def name_join\n @code_name = @split_name.join('')\n p @code_name\nend", "def name\n name_parts.compact.join(' ')\n end", "def full_name\n full_path.collect(&:name).join(\" > \")\n end", "def handle\n @name.to_str.strip.downcase.split(/[_ ]+/).join(\"_\")\n end", "def updateName(name)\n name_array = name.split(\"\\\\\")\n return name_array[0]\nend", "def join_name(name)\r\n\tnew_alias = name.join('')\r\n\tif new_alias.include?('!')\r\n\t\tnew_alias.gsub!('!', ' ')\r\n\tend\r\n\tnew_alias_ary = new_alias.split(' ')\r\nend", "def join_name(name)\r\n\tnew_alias = name.join('')\r\n\tif new_alias.include?('!')\r\n\t\tnew_alias.gsub!('!', ' ')\r\n\tend\r\n\tnew_alias_ary = new_alias.split(' ')\r\nend", "def dir_name string\n string.split('/')[0..-2].join('/')\nend", "def _SplitAndJoinParts(path, pop) \n pathParts = path.split(\"/\")[0..-(pop+1)]\n \n result = JoinPaths(pathParts)\n \n # we face an absolute linux part\n if(path.start_with?(\"/\"))\n result = \"/\" + result\n end\n \n return result\n end", "def split_path; end", "def full_name\n [@owner, @name].join('/')\n end", "def name\n path.gsub(/\\./,'_').gsub(%r{/}, '.').gsub(%r{(^\\.|\\.$)},'')\n end", "def format_name(str)\n parts = str.split(\" \")\n print parts\nend", "def parts\n prefix, parts = split_names(@path)\n prefix.empty? ? parts : [prefix] + parts\n end", "def split\n p @rev_name\n @split_name = @rev_name.split('')\n p @split_name\nend", "def customize_path(first, last)\n #return (first.gsub(/[.!@%&\"]/,'').squeeze(\" \").tr(\" \",'+')+ '_'+last.gsub(/[.!@%&\"]/,' ').squeeze(\" \").tr(\" \",'+')).split('+').map(&:capitalize)*'+'\n return (first.gsub(/[.!@%&\"]/,'').squeeze(\" \").tr(\" \",'+').split('+').map(&:capitalize)*'+' + '_'+last.gsub(/[.!@%&\"]/,' ').squeeze(\" \").tr(\" \",'+').split('+').map(&:capitalize)*'+')\n end", "def normalize_name(name, prefixes) #:nodoc:\n\t prefixes = prefixes.presence\n\t parts = name.to_s.split('/')\n\t parts.shift if parts.first.empty?\n\t name = parts.pop\n\n\t # return here if name is just like \"show\"\n\t return name, prefixes || [\"\"] if parts.empty?\n\n\t # otherwise, change prefixes\n\t parts = parts.join('/')\n\t prefixes = prefixes ? prefixes.map { |p| \"#{p}/#{parts}\" } : [parts]\n\n\t # for input \"my/show\", [\"users\", \"application\"]\n\t # it would become\n\t # \"show\", [\"users/my\", \"application/my\"]\n\t return name, prefixes\n\t end", "def split() File.split(path).map {|f| Path::Name.new(f) } end", "def split_path\n to_s.split_path\n end", "def splitname(path)\n [dirname(path), filename(path), extname(path)]\n end", "def rearrange(name)\n match = /(\\w+), (\\w+)( \\w+)?/.match(name) # (1)\n\n last_name = match[1]\n first_name = match[2]\n if match[3]\n separator = \"#{match[3][0,2]}. \" # (2)\n else\n separator = ' ' # (3)\n end\n \n \"#{first_name}#{separator}#{last_name}\" # (4)\nend", "def parse_localname(path)\n # localname appears after the second slash\n remainder, slash, localname = path.rpartition('/')\n return [path, ''] unless remainder.index('/')\n return [remainder, localname]\n end", "def name_to_dir(name)\n s = \"\"\n name.each_char do |c|\n if (c =~ /[-A-Za-z0-9_|\\[\\]]/) != nil\n s += c\n else\n c2 = TAG_NAME_MAP[c]\n if not c2\n msg = \"Bad character '#{c}' in tag '#{name}'\"\n puts(\"*** #{msg}\")\n raise Exception.new(msg)\n end\n s += \"#{c2}\"\n end\n end\n s\n end", "def name_slicer(names_switched)\n\tstringed_switched_name = names_switched.join(' ')\n\tstringed_switched_name.split(\"\")\nend", "def split(name)\n extension = nil\n dirname, basename = File.dirname(name), File.basename(name)\n if basename =~ /^(.*)\\.(#{extensions.keys.map {|e| Regexp.escape(e)}.join('|')})$/\n basename = $1\n extension = $2\n end\n [dirname, basename, extension]\n end", "def split_names(path)\n names = []\n while r = chop_basename(path)\n path, basename = r\n names.unshift basename\n end\n return path, names\n end", "def namify(paths)\n first = paths[0]\n rest = paths[1..-1].reduce([]) { |a, e| a << \"[#{e}]\" }.join('')\n \"#{first}#{rest}\"\n end", "def file_names(b_name)\n array = b_name.chars\n array.map! do |letter|\n letter = '_' if letter == ' '\n letter\n end\n array.join\nend", "def normal_name(text)\n\t\t\tar = text.split(', ')\n\t\t\tlastname = ar[0]\n\t\t\tfirstpart = ar[1]\n\t\t\tfirstname = firstpart.gsub(/[[:upper:]]\\./, '').strip\n\t\t\tfirstname + ' ' + lastname\n\t\tend", "def split_names(path)\n names = []\n while r = chop_basename(path)\n path, basename = r\n names.unshift basename\n end\n return path, names\n end", "def normalize_name(name, prefix)\n handlers = Template::Handlers.extensions.join('|')\n name = name.to_s.gsub(/\\.(?:#{handlers})$/, '')\n\n parts = name.split('/')\n return parts.pop, [prefix, *parts].compact.join(\"/\")\n end", "def join(*args)\n Path::Name.new(*args)\n #args.unshift self\n #result = args.pop\n #result = Path::Name.new(result) unless Path::Name === result\n #return result if result.absolute?\n #args.reverse_each {|arg|\n # arg = Path::Name.new(arg) unless Path::Name === arg\n # result = arg + result\n # return result if result.absolute?\n #}\n #result\n end", "def formatNameFromString( name )\n name.split(\",\")\n end", "def formatNameFromString( name )\n name.split(\",\")\n end", "def parse_name(name)\n words = name.path_to_name.strip.split(/\\s+/)\n first = words.shift\n { first: first, last: words.join('-') }\n end", "def extract_full_names(s)\n\ts = \" \".concat(s).concat(\" \")\n\t#puts \"###############################################\"\n\t#puts s\n\tlist = s.scan(/\\s'?\"?\\w+,?\\s\\w+[,']?\\.?\\s?\\w*\\s?&?\\s?\\w*\"?'?\\s/)\n\t#puts \"=>\", list\n\tlist.map! do |name| \n\t\ttmp = name.sub(/^\\s*/, \"\").sub(/\\s*$/, \"\").sub(/<.+>/, \"\").sub(/,$/, \"\").delete(\"\\\"\\'\\.\")\n\t\tif tmp.include?(\",\") and !tmp.include?(\"&\")then\n\t\t\tl = tmp.split(\",\")\n\t\t\tl[1].sub!(/^\\s*/, \"\")\n\t\t\t#assert(l.length == 2, \"fails at #{tmp} out of #{s}\")\n\t\t\tif (l.length != 2) then\n\t\t\t\ttmp = \"\"\n\t\t\telse\n\t\t\t\ttmp = l[1].concat(\" \").concat(l[0])\n\t\t\tend\n\t\tend\n\t\ttmp\n\tend\n\tlist\nend", "def split_names(path)\n names = []\n while r = chop_basename(path)\n path, basename = r\n names.unshift basename\n end\n return path, names\n end", "def attach_to_name(name)\n if preferred_form == Prefix\n s= [prefix,name].compact.join(\" \")\n else\n s = [name,suffix].compact.join(\" \")\n end\n s.strip\n end", "def split_name_for_automatic_splitting\n temp = name\n if temp\n if temp.match /\\A[A-Z]{3}[a-z]/\n temp = temp[2..-1]\n end\n (temp && temp.split(/([A-Z]?[a-z]+)/).map(&:downcase) || []).reject do |part|\n part.size < 3\n end\n else\n []\n end\n end", "def full_name(delim = ', ')\n n = name\n n += \"#{delim}#{borough}\" if !borough.nil?\n n\n end", "def create_url\n #we trim away all periods and break apart the name by spaces to use to acquire the url of the poet in the Poetry Foundation website\n name_no_periods = @name.tr(\".\", \"\")\n name_no_periods = name_no_periods.split(\" \")\n\n #we use name_no_periods to generate the url for the poet (example url: \"https://www.poetryfoundation.org/poets/ben-jonson\")\n url = \"https://www.poetryfoundation.org/poets/\"\n name_no_periods.each { |part| url = \"#{url}#{part}-\"}\n\n #this leaves an extra hyphen at the end, but we can just cut that off in the return.\n url = url.chop\n end", "def createlabelname(name)\t\t\n\n\t\tsplitname=name.split(\"/\")\n\t\tfor i in 1..splitname.length do\n# If the name is within brackets, then actual name of the person is unknown\n\t\t\tif(splitname[i-1] =~ /^\\(.+\\)/) \n\t\t\t\tsplitname[i-1] = \"(....)\\\\n\" \n\t\t\tend\n\t\tend\t\n\t\t\t\n\t\tname=splitname.join(\"\")\n\n# Initialize long name\n\t\tsplitname=name.split(\" \")\n\t\tfor i in 1..splitname.length do\n# If there are more than 2 names, and this is not 1st name or last name, and it is not already initialized, and this is not 2nd name while the first name is a title such as \"Ompu\"\n\t\t\tif(splitname.length>2 && i != 1 && i != splitname.length && !(i==2 && (splitname[0].strip==\"Ompu\" || splitname[0].strip==\"O.\" || splitname[0].strip==\"Amani\"|| splitname[0].strip==\"A.\" || splitname[0].strip==\"Aman\" || splitname[0].strip==\"Datu\" || splitname[0].strip==\"Nai\" || splitname[0].strip==\"Apa\" || splitname[0].strip==\"Pu\" || splitname[0].strip==\"Na\" || splitname[0].strip==\"Boru\" || splitname[0].strip==\"Apa\" || splitname[0].strip==\"Raja\")) )\n\t\t\t\t\tsplitname[i-1] = splitname[i-1][0,1].capitalize + \".\"\n\t\t\tend\t\n\t\tend\n\n# Put each name in new line to shorthen it\n#\t\tname.gsub!(\" \",\"\\n\")\n\n\t\tfor i in 1..splitname.length do\n# If this name is not an initial (ended by \".\"), or if it is an initial but before a non-initial\n\t\t\tif(splitname[i-1] && splitname[i])\n\t\t\t\tif(splitname[i-1][-1,1] != \".\" || (splitname[i-1][-1,1] == \".\" && splitname[i][-1,1] != \".\"))\n#\t\t\t\t\tif $orientation==\"horizontal\" then splitname[i-1]=splitname[i-1] + \" \"\n#\t\t\t\t\telse splitname[i-1]=splitname[i-1] + \"\\\\n\" end\n\t\t\t\t\tsplitname[i-1]=splitname[i-1] + \"\\\\n\"\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\tname=splitname.join(\"\")\n\n\t\tlabel= name\t\n\t\treturn label\n\tend", "def to_s\r\n clean!\r\n \r\n map do |name|\r\n name.include?(delimiter) ? \"\\\"#{name}\\\"\" : name\r\n end.join(delimiter.ends_with?(\" \") ? delimiter : \"#{delimiter} \")\r\n end", "def cleanpath\n names = []\n split('/').each do |name|\n case name\n when '..'\n names.pop\n when '.'\n when ''\n else\n names.push name\n end\n end\n names.join('/')\n end", "def pretty_name\n name = @first_name.concat(@last_name).split /(?=[A-Z])/\n name = name[0] + \" \" + name[1]\n return name\n # return first_name + \" \" + last_name\n end", "def resolve_name(inner_text, run_options)\n if inner_text.end_with?('|')\n inner_text.chop.chomp('/').split(%r{[:/]}, 2).last\n else\n inner_text\n end\n end", "def list names\n names = names.map { |name| name[:name] }\n last_name = names.pop\n return last_name.to_s if names.empty?\n \"#{names.join(', ')} & #{last_name}\"\nend", "def path_and_name(path)\n match = path.match(/(.+)\\/(.+$)/)\n [match[1], match[2].split('.').max_by(&:length).underscore.humanize.titlecase]\n end", "def list names\n names = names.map { |name| name[:name] }\n p names\n case\n when names.count == 0\n \"\"\n when names.count == 1\n names[0]\n when names.count == 2\n names[0] + \" & \" + names[1]\n when names.count > 2\n last = names.pop\n names.join(\", \") + \" & \" + last\n end\nend", "def path_name\n str = name.dup\n str << '/' if is_dir\n str = parent.path_name + str if parent\n str\n end", "def name\n @name ||= path.split('/').last\n end", "def subdir_and_filename_for(entry)\n Pathname.new(entry).split\n end", "def normalized_path_name(path, bases)\n normalised_path = normalise_path(path, bases[:directory])\n\n # https://tools.ietf.org/html/rfc3986#section-3\n # paths for resource groups (e.g. directories) should always have a trailing slash\n #2.3.1 :006 > File.join(\"/a/\",\"/b\", \"/\") => \"/a/b/\"\n #2.3.1 :007 > File.join(\"/a/\",\"/b/\", \"/\") => \"/a/b/\"\n #2.3.1 :008 > File.join(\"/a\", \"b\", \"/\") => \"/a/b/\"\n normalized_url_path = File.join(bases[:url_base_path], normalised_path, '/')\n\n # we use the normalized_url_path so that the name fragment always has a value that makes sense\n normalised_name = normalised_name(normalized_url_path)\n\n { path: normalized_url_path, name: normalised_name }\n end", "def format_gallery_name name_string\n return name_string.gsub(\" \", '') if name_string\n end", "def names\n self.name.split(' ')\n end", "def split_name(name)\n classified_name = name.to_s.classify\n name_parts = classified_name.split(\"::\")\n namespace_name = name_parts[0...-1].join(\"::\")\n return [nil, classified_name] if namespace_name.empty?\n\n [namespace_name, name_parts.last]\n end", "def append_name(*args,join:'')\n\t\t\t\tPathname.new(self.to_s+args.join(join))\n\t\t\tend", "def split_nsh_path(path)\n result = [\"\",path]\n result[0] = path.split(\"/\")[2] if path.start_with?(\"//\")\n result[1] = \"/#{path.split(\"/\")[3..-1].join(\"/\")}\" if path.start_with?(\"//\") \n result\n end", "def process_property_name\n return [create_name] unless @name.is_a?(Array)\n @name.inject([]) do |name, part|\n name << create_name(part)\n end\n end", "def path_name\n return unless @basename\n\n parts = @basename.split('.')\n parts.pop if parts.length > 1 && parts.last =~ /^\\w+$/\n parts.pop if parts.last =~ /^\\d+$/\n parts.join('.')\n end", "def determine_name_parts(name)\n @first_name = name[0..name.index(\" \")].strip.downcase\n @last_name = name[name.index(\" \")..name.length].strip.downcase\n end", "def get_namespace_and_name(input_remote_name, delimiter)\n if (input_remote_name||'').include?(delimiter)\n input_remote_name.split(delimiter)\n # support ns/name as well as ns:name\n elsif (input_remote_name||'').include?('/')\n input_remote_name.split('/')\n else\n [nil, input_remote_name]\n end\n end", "def name\n $0.split(\"/\").last\n end", "def extract_file_name(diff_file_name)\n file_name = diff_file_name.to_s.split(\"/\")\n # Remove the first part of \"--- a\"\n file_name.shift\n # Re-join the remaining parts\n file_name = file_name.join('/')\n return file_name\n end", "def path(*elements) #Create a path from the elements\n#-------------------------------------------------------------------------------\n path=elements.join('/').strip #Remove leading and trailing whitespace\n while path.gsub!('//','/'); end #Remove duplicate slashes\n return path\nend", "def format_name(name)\n name.split(' ').join('_')\n end", "def format_name(name)\n name.split(' ').join('_')\n end", "def name\n file.partition(base).last.gsub(/[_\\/]/, \" \").strip\n end", "def namesplit(fullname)\n ary = fullname.split(\"::\")\n n = ary.pop || \"\"\n ns = ary.join(\"::\")\n return ns, n\n end", "def normalised_name(path)\n path == '/' ? '/' : File.basename(path)\n end", "def name\n result = []\n result << self.first_name\n result << self.last_name\n if result.compact.empty?\n self.user.login if self.user\n else\n result.compact.map {|m| m.to_s.strip}.reject {|i| i.blank?}.join(' ')\n end\n end", "def get_name_initials(names)\n output = []\n names.each do |name|\n first, last = name.split(\" \")\n output << [first[0], last[0]].join\n end\n output\nend", "def guard_name(p)\n [p.first_name, p.last_name, p.relation].join(' ')\n end", "def name_to_dir(name)\n name.gsub(/[^-A-Za-z0-9_|\\[\\]]/, \"_\")\n end", "def rel_split(fallback: true)\n\t\t\t\tif (i=components.index(\".\"))\n\t\t\t\t\tdirname=Pathname.new(components[0..i-1].join(\"/\"))\n\t\t\t\t\tbasename=Pathname.new(components[i+1..-1].join(\"/\"))\n\t\t\t\telsif fallback\n\t\t\t\t dirname=self.dirname\n\t\t\t\t basename=self.basename\n\t\t\t\tend\n\t\t\t\treturn dirname,basename\n\t\t\tend", "def split_filename(path)\n pathname = Pathname.new(path.value)\n list(quoted_string(pathname.dirname.to_s),\n quoted_string(pathname.basename(pathname.extname).to_s),\n quoted_string(pathname.extname.to_s),\n :space)\n end", "def spyname(real_name)\n spy_array = []\n split_name = real_name.reverse.split('')\n split_name.join.chars\n split_name.map! do|name|\n name.tr!(\"aeiouAEIUO\",\"eiouaEIOUA\")\n name.tr!(\"bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ\",\"cdfghjklmnpqrstvwxyzbCDFGHJKLMNPQRSTVWXYZB\")\n spy_array << name.to_str\nend\n p spy_array.join\nend", "def names\n nameparts = name.split(' ')\n firstinitial = nameparts.second ? \"#{firstname[0, 1]}.\" : ''\n secondname = nameparts.third ? nameparts.second : ''\n secondinitial = nameparts.third ? \"#{secondname[0, 1]}.\" : ''\n middlenames = nameparts.length > 2 ? nameparts.from(1).to(nameparts.from(1).length - 2) : []\n middleinitials = ''\n middlenames.each_with_index do |name, index|\n middleinitials << ' ' if index.positive?\n middleinitials << \"#{name.to_s[0, 1]}.\"\n end\n lastname = nameparts.last\n names = []\n names << full_name # Joseph Aloysius Hansom\n names << \"#{title} #{name}\" if titled? # Sir Joseph Aloysius Hansom\n names += aka # Boz, Charlie Cheese, and Crackers\n names << \"#{title} #{firstinitial} #{middleinitials} #{lastname}\" if titled? && nameparts.length > 2\n names << \"#{title} #{firstinitial} #{lastname}\" if titled? && nameparts.length > 1\n names << name if name != full_name # Joseph Aloysius Hansom\n if name.include? ',' # George Inn, Barcombe\n names << name.split(/,/).first\n return names\n end\n names << \"#{title} #{name.split(/ of /).first}\" if name.include?(' of ') && titled? # King Charles II [of England]\n names << name.split(/ of /).first if name.include?(' of ') # [King] Charles II [of England]\n names << \"#{firstname} #{middleinitials} #{lastname}\" if nameparts.length > 2 # Joseph A[loysius]. R[obert]. Hansom\n names << \"#{firstinitial} #{middleinitials} #{lastname}\" if nameparts.length > 2 # J. A. R. Hansom\n names << \"#{firstname} #{nameparts.second} #{lastname}\" if nameparts.length > 2 # Joseph Aaron Hansom\n names << \"#{firstname} #{secondinitial} #{lastname}\" if nameparts.length > 2 # Joseph A. Hansom\n names << \"#{firstinitial} #{secondname} #{lastname}\" if nameparts.length > 2 # J. Aaron Hansom\n names << \"#{title} #{firstname} #{lastname}\" if nameparts.length > 2 && titled? # Sir Joseph Hansom\n names << \"#{firstname} #{lastname}\" if nameparts.length > 2 # Joseph Hansom\n names << \"#{firstinitial} #{lastname}\" if nameparts.length > 1 # J. Hansom\n names << \"#{title} #{lastname}\" if titled? # Lord Carlisle\n names << \"#{title} #{firstname}\" if titled? # Sir William\n names << firstname if nameparts.length > 1 # Charles\n names << lastname if nameparts.length > 1 # Kitchener\n names.uniq\n end", "def smart_slash(input)\n if !(input =~ /\\.\\w+$/)\n input = File.join(input, '/')\n end\n input\n end", "def join(path)\n path_str = path.to_s\n super(path_str[0..0] == '/' ? path_str[1..-1] : path_str).p\n end", "def split_name\n first, *rest = name.split(/\\b/)\n initials, after_initials = first.split(/(?=[A-Z][a-z])/, 2)\n [\n name,\n initials,\n after_initials,\n first,\n *rest,\n *name.split(/([A-Z]?[a-z]+)/)\n ].compact.map(&:downcase).uniq.map(&:freeze)\n end", "def split_filename(fn)\n fn.split(/[\\/\\\\]/)\n end", "def create_multi_name\n base_name = String.new(Faker::Games::ElderScrolls.creature)\n if base_name.split.size == 1\n adjective = Spicy::Proton.adjective.capitalize\n new_name = base_name.split.unshift(adjective)\n new_name.join(' ')\n else\n return base_name\n end\n end", "def full_name\n \"#{username}/#{name}\"\n end", "def full_name\n [prefix, name, suffix].join(\"\")\n end", "def name = (name)", "def full_name\n self.name ? \"#{self.name.split(' ')[0..-2].join(' ')}, #{self.name.split(' ')[-1]}\" : ''\n end", "def split_wiki_path(path)\n if path == \"/\"\n [ @default_coll_name, @default_wiki_name, \"/\" ]\n else\n path = path[1..-1] if path[0] == '/'\n path = path[0..-2] if path[-1] == '/'\n path = path.gsub(%r{//+}, '/')\n\n cn, wn, pn = path.split('/', 3)\n if wn.nil?\n [ cn, @default_wiki_name, \"/\" ]\n elsif pn.nil?\n [ cn, wn, \"/\" ]\n else\n [ cn, wn, pn ]\n end\n end\n end", "def pretty_name\n name.gsub(/\\.([^.]+)$/, '')\n end", "def path\n [name]\n end", "def name\n @name.gsub(\"\\n\",' ')\n end", "def path(name)\n root.join(name)\n end", "def clean_name\n return name.split(':').pop\n end", "def split\n @original_route.split('/')[1..-1]\n end", "def full_name\n name = @name.gsub(/[[:alpha:]]+/, &:capitalize)\n\n if @height.include? '/'\n numbers = digits_scan(@height).map(&:to_i)\n \"#{name} #{numbers[0]}'#{numbers[1]}/#{numbers[2]}\"\n else\n \"#{name} #{@height}'\"\n end\n end", "def separate (string, joiner = \"-\")\n string.split(//).join(joiner)\nend", "def full_name\n\t\t\tnames = [self.name]\n\t\t\tp = self.parent\n\t\t\twhile !p.nil? do\n\t\t\t\tnames << p.name\n\t\t\t\tp = p.parent\n\t\t\tend\n\t\t\tnames.reverse.join(\" / \")\n\t\tend" ]
[ "0.6712902", "0.6598084", "0.6593246", "0.64444995", "0.6421173", "0.636001", "0.63291526", "0.6315965", "0.6314213", "0.6314213", "0.6212336", "0.61808264", "0.61607", "0.6140464", "0.61230034", "0.60938805", "0.60892445", "0.60728806", "0.6072206", "0.6042162", "0.59701186", "0.5953467", "0.5946135", "0.593081", "0.5927292", "0.59198785", "0.5911015", "0.5905261", "0.5883575", "0.5864323", "0.5848215", "0.5826448", "0.5820313", "0.5814186", "0.5806842", "0.58041847", "0.58041847", "0.5766092", "0.5748636", "0.5746977", "0.5745175", "0.5731777", "0.57304686", "0.5728748", "0.57177436", "0.57058805", "0.56978464", "0.56881654", "0.5679585", "0.56783843", "0.56750256", "0.5671493", "0.56712615", "0.56709534", "0.567047", "0.5664491", "0.5660906", "0.5659447", "0.5649241", "0.5639975", "0.56374884", "0.56112206", "0.55957484", "0.55867964", "0.55830395", "0.5578624", "0.557474", "0.5571634", "0.55702126", "0.55702126", "0.5539261", "0.5530181", "0.5529827", "0.55283755", "0.55280846", "0.5525952", "0.55201894", "0.5516443", "0.5515385", "0.5505559", "0.5502907", "0.5489389", "0.5487877", "0.5475583", "0.54754424", "0.54695207", "0.5463525", "0.54587024", "0.5455955", "0.54531276", "0.5452918", "0.5449256", "0.54449564", "0.54438233", "0.54425424", "0.54405344", "0.54316735", "0.5419666", "0.54183125", "0.5415589" ]
0.5805264
35
The +path+ plus the current action.html.erb
def full_path path + "/#{@action}.html.erb" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_current_path; end", "def path\n\t\trequest.original_fullpath\n\tend", "def path\n @global_page.path\n end", "def view_path\n @@view_path\n end", "def show\n render @current_template\n end", "def to_render\n \"#{controller}/#{action}\"\n end", "def current_action\n params[:action]\n end", "def friendly_current_page\n begin\n params[\"controller\"] + \"-\" + params[\"action\"]\n rescue\n \"example-app\"\n end\n end", "def current_action\n @action\n end", "def current_action\n self.controller.action_name.to_sym\n end", "def path ; @request.path_info ; end", "def url\n @current_controller.url_for :controller => @controller_name, :action => @action_name\n end", "def cp(path)\n \"current_page\" if request.fullpath.index(path)\n end", "def path\n request.path\n end", "def append_view_path(path); end", "def append_view_path(path); end", "def controller_path; end", "def controller_path; end", "def request_path; end", "def path\n location.path\n end", "def view(page, *)\n rails_render(action: page.tr(\"-\", \"_\"), layout: true) ||\n rails_render(html: super.html_safe, layout: true)\n end", "def current_path\n url_for(params)\n end", "def render_previous\n hsh = Rails.application.routes.recognize_path(request.referer)\n render template: \"#{hsh[:controller]}/#{hsh[:action]}\"\n end", "def current_path(path)\n \"green\" if current_page?(path)\n end", "def rendered_action_name\n\t\t@rendered_action || params[:action]\n\tend", "def page_requested\n\t\trequest.env['REQUEST_PATH'].split(\"/\")[-1]\n\tend", "def current_path\n @current_path ||= @deploy_to + '/current'\n end", "def browse_path\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"\" ] if browse_everything_controller2_debug_verbose\n rv = params[:path] || ''\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"browse_path rv=#{rv}\",\n \"\" ] if browse_everything_controller2_debug_verbose\n rv\n end", "def target_view_path\n super\n end", "def auto_path\n cur_page.auto_path\n end", "def view_path\n @view_path ||= root + \"/views\"\n end", "def controller_view_path\n ivar_cache do\n Mack::Paths.views(self.controller.controller_name)\n end\n end", "def path\n\t\t@path\n\tend", "def path\n return get_path self\n end", "def path_to_back\n\t\t\t\tback_path = request.referer\n\t\t\t\treturn back_path if back_path && back_path != request.url\n\n\t\t\t\treturn path_to :index if self.class.actions.include?(:index)\n\n\t\t\t\t'/'\n\t\t\tend", "def path_to_back\n\t\t\t\tback_path = request.referer\n\t\t\t\treturn back_path if back_path && back_path != request.url\n\t\t\t\treturn path_to :index if self.class.actions.include?(:index)\n\t\t\t\t'/'\n\t\t\tend", "def current_url; end", "def prepend_view_path(path); end", "def prepend_view_path(path); end", "def render\n @case = Case.find(self.case_id)\n @page_path = Page.find(self.page_id).path\n end", "def path(options={}, &block)\n cur_page.path(options, &block)\n end", "def path\n raise NotImplementedError, \"implement me to support page.visit, e.g. '/relatve_URI_of_this_page'\"\n end", "def set_current_path(path)\n @current_path = path\nend", "def set_current_action\n @visitor.current_action = @_action_name\nend", "def path(request)\n request.path\n end", "def target_path\n @target_path ||= \"app/views/activity_notification\"\n end", "def current_path\n current_url = page.current_url\n url_match = URL_REGEX.match(current_url)\n return url_match[4] if url_match\n\n # Special case: prepend a slash to the path to force a valid URL for things like\n # \"about:srcdoc\" iframe srcdoc pages.\n current_url = \"/#{current_url}\" if current_url[0] != '/'\n\n current_url\n end", "def current\n ActiveSupport::StringInquirer.new(@params[:view].is_a?(Array) ?\n @params[:view].join(\"\") :\n @params[:view].to_s)\n end", "def view_path\n File.join path, 'views'\n end", "def path\n return @path\n end", "def path\n return @path\n end", "def path\n return @path\n end", "def path\n return @path\n end", "def current_path\n URI.parse(current_url).path\nend", "def path opts = {}\n context.url_for(opts)\n end", "def path\n @path\n end", "def path\n @path\n end", "def path\n @path\n end", "def path\n @path\n end", "def path\n `window.location.pathname`\n end", "def path\n @path\n end", "def path\n @path\n end", "def path\n @path\n end", "def path\n @path\n end", "def current_path\n current_folder.path\n end", "def erb_path\n end", "def path\n @location.path\n end", "def select_render action=nil\n # defaults to current action, though another may be specified, even a full path\n \"#{action || @action}_\"+\n case\n when injector?\n \"injector\"\n when dialog?\n \"modal\"\n else\n \"page\"\n end\n end", "def path\n end", "def path\n self.collection_tag.template_tag.page_generator.build_path( self.model)\n end", "def path\n current_localization.path\n end", "def show\n render(page_path)\n end", "def path\n @path\n end", "def path\n @path\n end", "def path; @path_stack end", "def current_template\n get_current_wizard_step.to_s\n end", "def last_action\n Rails.application.routes.recognize_path(request.referrer)[:action]\n end", "def controller_path\n self.class.controller_path\n end", "def render_page_path\n if Settings.website.base_url.present?\n render :partial => \"admin/general/page_path\", :locals => { :page_path => [email protected] }\n else\n render :partial => \"admin/general/page_path\", :locals => { :page_path => @page.path }\n end\n end", "def inspect\n \"#<#{self.class.name}:##{self.path_name}>\"\n end", "def main_path\n params._controller.or('main') + \"/\" + params._action.or('index')\n end", "def main_path\n params._controller.or('main') + \"/\" + params._action.or('index')\n end", "def main_path\n params._controller.or('main') + \"/\" + params._action.or('index')\n end", "def location\n render :action=>\"location\"\n end", "def path path = nil\n @path = normalize_path(path) if path && configurable?\n @setup[:path] ||= @path ||\n (@controller.ctrl.slice.view.path if @controller) ||\n 'view/'\n end", "def request_path\n @path = controller_path + '#' + action_name\n def @path.is(*str)\n str.map{|s| self.include?(s)}.include?(true)\n end\n end", "def path\n end", "def path\n end", "def path\n end", "def to_path\n @path\n end", "def get_action_link\n if controller_path == 'admin/articles'\n case action_name\n when 'index' then t('buttons/all_articles').html_safe\n when 'new' then t('buttons/new_article').html_safe\n when 'edit' then t('buttons/edit_article').html_safe\n when 'show' then t('buttons/preview').html_safe\n end\n elsif controller_path == 'admin/authors'\n case action_name\n when 'index' then t('buttons/all_authors').html_safe\n when 'new' then t('buttons/new_author').html_safe\n when 'edit' then t('buttons/edit_author').html_safe\n when 'show' then t('buttons/author').html_safe\n end\n end\n end", "def set_current_path\n case params.values_at(:controller, :action).join('/')\n when 'search/image' then return\n when %r{^devise/} then return\n when %r{^user/} then return\n end\n if request.path == root_path\n session.delete('app.current_path')\n else\n prms = url_parameters.except(:id)\n path = make_path(request.path, **prms)\n comp = compress_value(path)\n session['app.current_path'] = (path.size <= comp.size) ? path : comp\n end\n session['app.time'] = DateTime.now\n end", "def current_path?(path)\n request.path == path\n end", "def show\n @parent_path = set_parent_path\n end", "def template\n\t\tSlim::Template.new(File.join(App.root, 'app', 'views', \"#{self.name}\", \"#{self.action}.slim\"))\n\tend", "def index_path\n \"#{path}/index.html\"\n end", "def current_url\n page.current_url\n end", "def current_url\n page.current_url\n end", "def cp(path)\n \"current\" if current_page?(path)\n end", "def get_path\n request_object.path\n end" ]
[ "0.68426466", "0.6774888", "0.6670076", "0.6610921", "0.654586", "0.6506843", "0.6495319", "0.64738184", "0.64653623", "0.6461044", "0.6453939", "0.6449542", "0.6425803", "0.6423476", "0.6411562", "0.6411562", "0.6357818", "0.6357818", "0.6351074", "0.63361335", "0.63083845", "0.6299419", "0.6282849", "0.6243379", "0.61992294", "0.6196309", "0.61884034", "0.616582", "0.6140828", "0.6132313", "0.6103692", "0.60799843", "0.60585004", "0.60553133", "0.6037005", "0.60368353", "0.600443", "0.59993976", "0.59993976", "0.59933305", "0.5990178", "0.59892035", "0.5988841", "0.5977793", "0.59775335", "0.5973804", "0.59632796", "0.59619766", "0.594282", "0.59337354", "0.59322256", "0.59322256", "0.59322256", "0.59214234", "0.59180707", "0.59166193", "0.59166193", "0.59166193", "0.59166193", "0.5915325", "0.5915001", "0.5915001", "0.5915001", "0.5915001", "0.59133375", "0.5904076", "0.59027475", "0.5901808", "0.5893597", "0.5891823", "0.5885402", "0.58784485", "0.58639926", "0.58639926", "0.5858948", "0.58575416", "0.58420855", "0.5841499", "0.5837877", "0.58316565", "0.5827097", "0.5827097", "0.5827097", "0.5819725", "0.58188367", "0.581322", "0.5812228", "0.5812228", "0.5812228", "0.58064264", "0.58061665", "0.58054847", "0.5803261", "0.580293", "0.5795691", "0.5790142", "0.5784672", "0.5784672", "0.57833284", "0.57821685" ]
0.80868953
0
The Controllers class name without the word `controller` in it.
def name self.class.to_s.gsub(/controller$/i, "") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def controller_full_name\n controller.class.name.sub('Controller','').gsub('::','_').underscore\n end", "def controller_name(name)\n @controller_class_name = \"#{name}_controller\".camelize\n end", "def controller_name\n @controller_name ||= controller.class.to_s.sub('Controller', '').underscore\nend", "def controller_name\n \"#{self.class.app_namespace}::#{@controller_name}\"\n end", "def full_implementation_controller_name\n \"#{model_class_name.pluralize}Controller\"\n end", "def controller_name\n self.class.controller_name\n end", "def controller_name\n self.name.underscore.pluralize\n end", "def controller_name\n [namespace.module_name, resource_name.plural.camelize + \"Controller\"].compact.join(\"::\")\n end", "def controller_name\n self.class.name.downcase.pluralize\n end", "def controller_name\n path = segments[2..-2].join('/')\n path < 'a' ? path : camelize(path)+\"Controller\"\n end", "def model_name\n self.class.name[/(.*)Controller/,1].singularize.underscore\n end", "def klass_from_controller(c = controller_name)\n c.singularize.camelize.constantize\n end", "def controller_name(node)\n if option_with_hash(node)\n option_node = node.arguments.all[1]\n name =\n if hash_key_exist?(option_node, 'controller')\n option_node.hash_value('controller').to_s\n else\n node.arguments.all.first.to_s.gsub('::', '').tableize\n end\n else\n name = node.arguments.all.first.to_s.gsub('::', '').tableize\n end\n namespaced_class_name(name)\n end", "def namespaced_class_name(name)\n class_name = \"#{name.split('/').map(&:camelize).join('::')}Controller\"\n if @namespaces.empty?\n class_name\n else\n @namespaces.map { |namespace| \"#{namespace.camelize}::\" }.join('') + class_name\n end\n end", "def controller_name\n self.class.to_s\n end", "def object_name\n self.class.name.underscore.split('/').last.sub(/_controller$/, '').singularize\n end", "def controller_filename\n File.join(File.expand_path(RAILS_ROOT), 'app', 'controllers', \"#{@controller.class.to_s.underscore}.rb\").\n sub('/controllers/controllers/', '/controllers/')\n end", "def controller\n @controller ||= controller_name.constantize\n end", "def controller_name\n self.request.route_obj.instance_variable_get('@controller')\n end", "def model_name\n params[:controller].sub(\"Controller\", \"\").underscore.split('/').last.singularize\n end", "def classes_for_main\n controller.controller_name + '-' + controller.action_name\n end", "def template_namespace\n @controller.class.to_s.sub('Controller','').underscore.pluralize\n end", "def class_for_controller_name\n controller_model\n end", "def controller_html_class\n \"#{h controller_path}-controller\"\n end", "def getKlass #:doc:\n @Klass = self.controller_name.classify.constantize\n @Klass\n end", "def controller_name(name)\n tests \"#{name}_controller\".camelize.constantize\n end", "def controller(name)\n controllers.select { |a| a.name == name }.first\n end", "def controller_name\n @controller_name ||=\n if @resource_options.key?(:controller_name)\n tools.string.underscore(@resource_options.fetch(:controller_name)).\n sub(/_controller\\z/, '')\n else\n plural_resource_name\n end # if-else\n end", "def get_formatted_controller_name\n params[:controller]\n end", "def pretty_controller_name(name = \"\")\n name.split('_').map(&:capitalize).join(' ').singularize\n end", "def associated_class_string\n controller_name.classify\n end", "def sanitize_api_class( controller )\n controller.name.split(\"::\").last\n end", "def objects_name\n if class_parent_name != 'Object'\n \"#{class_parent_name.underscore}__#{controller_name}\".to_sym\n else\n controller_name.to_sym\n end\n end", "def controller_to_name(v = nil)\n v ||= request_parameters\n v = v[:controller] || v['controller'] if v.is_a?(Hash)\n if v.is_a?(String) || v.is_a?(Symbol)\n v.to_s.strip.underscore.delete_suffix('_controller')\n else\n # noinspection RailsParamDefResolve\n v.try(:controller_name)\n end\n end", "def controller_name; end", "def controller_name; end", "def thing\n controller_name.classify.constantize\n end", "def controller_class\n @controller_class ||= @controller&.class || self.class.class_for(@key)\n end", "def controller_css_class\n controller_name\n end", "def class_name\n self.class.name.split(\"::\").last.downcase\n end", "def to_s\n File.join(\n \"app\",\n \"controllers\",\n *model.controller_prefixes.map(&:as_snake_case),\n file_name\n ).to_s\n end", "def model_name\n params[:controller].split('/').last.singularize\n end", "def controller_path\n @controller_path ||= name.delete_suffix(\"Controller\").underscore unless anonymous?\n end", "def namespace\n # 2012.3.13 didn't work on Rails 3.0.7, cancan 1.6.7; looks promising, but needs some figuring out.\n #cns = @controller.class.to_s.split('::')\n #cns.size == 2 ? cns.shift.downcase : \"\"\n \n # I am sure there is a slicker way to capture the controller namespace\n # 2012.3.13 But it works!\n controller_name_segments = params[:controller].split('/')\n controller_name_segments.pop\n controller_namespace = controller_name_segments.join('/').camelize\n end", "def namespace\n # controller_name_segments = params[:controller].split('/')\n # controller_name_segments.pop\n # controller_name_segments.join('/').camelize\n params[:controller].split('/').first\n end", "def model_controller(model)\n model.class.name.underscore.pluralize\n end", "def type\n controller_name.singularize\n end", "def class_name\n self.class.name.split(\"::\").last\n end", "def model_controller(model)\n model.class.name.downcase.pluralize\n end", "def model\n\t\tObject.const_get(controller_name.classify)\n\tend", "def namespace\n namespace = SkinnyControllers.controller_namespace || ''\n \"#{namespace}::\" if namespace\n end", "def default_controller_name\n @object.class == ApplicationController ? \"Home\" : @object.controller_name.titlecase\n end", "def class_name\n self.class.to_s.split('::').last\n end", "def derived_name\n return controller_name if respond_to?(:controller_name)\n return model_name.plural if respond_to?(:model_name)\n name ? name.underscore.pluralize : nil\n end", "def scout_sinatra_controller_name(request)\n name = 'unknown'\n verb = request.request_method if request && request.respond_to?(:request_method) \n Array(self.class.routes[verb]).each do |pattern, keys, conditions, block|\n if pattern = process_route(pattern, keys, conditions) { pattern.source }\n name = pattern\n end\n end\n name.gsub!(%r{^[/^]*(.*?)[/\\$\\?]*$}, '\\1')\n if verb\n name = [verb,name].join(' ')\n end\n name\n end", "def model\n controller_name.classify.constantize\n end", "def resource_name\n name.to_s.chomp('Controller').demodulize.singularize\n end", "def csharp_api_fqn( controller )\n [ sanitize_api_namespace(controller), sanitize_api_class(controller) ].compact.join(\".\")\n end", "def get_controller\n @controller_name = params[:controller]\n end", "def model_type\n self.class.name[/(.*)Controller/,1].singularize.constantize\n end", "def model_type\n self.class.name[/(.*)Controller/,1].singularize.constantize\n end", "def api_controller_name\n self.class.api_controller_name || model_name.pluralize\n end", "def model_klass\n controller_name.classify.constantize\n end", "def controllers\n base_controller_class.constantize.descendants\n end", "def controllers_path\n (RUBYCOCOA_ROOT + 'app/controllers').to_s\n end", "def controller_model\n @controller_model ||= begin\n controller_name.singularize.camelize.constantize\n rescue\n nil\n end\n end", "def controller_scope_name\n @controller_scope_name ||= 'admin.' + self.class.name.sub(/Controller$/, '').underscore.tr('/', '_')\n end", "def model\n self.controller_name.classify.constantize\n end", "def full_object_name\n if class_parent_name != 'Object'\n \"#{class_parent_name.underscore}__#{controller_name.singularize}\"\n else\n controller_name.singularize\n end\n end", "def class_name\n name = @klass.name\n name.name\n end", "def klass_name\n \"#{params[:klass_name].classify}\"\n end", "def plural_model_name\n params[:controller].split('/').last\n end", "def current_class_name\n @klass.to_s\n end", "def object_name\n controller_name.singularize\n end", "def base_controller_class\n proc_or_string = (@base_controller_class ||= \"::ApplicationController\")\n proc_or_string.respond_to?(:call) ? proc_or_string.call : proc_or_string\n end", "def primary_controller_names\n ActionController::Routing::Routes.routes.collect {|r| r.defaults[:controller] }.uniq.compact.\n reject { |c| c=~%r~/~}.\n select { |c| c=~%r~s$~ } - %w(sessions javascripts)\n end", "def classname\n @classname ||= self.class.name.split(\"::\")[1..-1].join(\"::\")\n end", "def full_class_name\n @class_names.join(\"::\")\n end", "def safe_class_name()\n self.class.name.downcase.gsub(/[^\\d\\w]/, '_')\n end", "def model_name\n @model_class ? @model_class.name.demodulize.underscore : self.controller_name.singularize\n end", "def resources_name\n controller_name\n end", "def page_name\n return params[:controller].singularize\n end", "def resource_name\n @@resource_name ||= self.class.to_s.split('::').last.gsub('Controller', '').singularize.underscore\n end", "def get_resource_name\n \tself.controller_name.singularize\n end", "def title\n return params[:controller].camelize\n end", "def model\n begin\n return controller_name.classify.constantize\n rescue\n return ('SlashAdmin::' + controller_name.classify).constantize\n end\n end", "def class_name\n fetch('heroes_of_the_storm.class_names')\n end", "def controller_class; end", "def controller_class; end", "def class_name object\n return object.class.to_s.split(/(?=[A-Z])/).join(' ')\n end", "def screen_name\n controller_name = t(\"controllers.#{params[:controller]}\").upcase\n action_name = t(\"actions.controllers.#{params[:action]}\").upcase\n \"#{controller_name} / #{action_name}\"\n end", "def underscorized_classname\n self.class.name.split(\"::\").last.\n gsub( /([A-Z]+)([A-Z][a-z])/, '\\1_\\2' ).\n gsub( /([a-z\\d])([A-Z])/, '\\1_\\2' ).downcase\n end", "def class_name\n Jaspion::Kilza::Class.normalize(@original_name)\n end", "def resource_name\n controller_name.demodulize.singularize\n end", "def resource_name\n controller_name.demodulize.singularize\n end", "def resource_name\n controller_name.demodulize.singularize\n end", "def class_name\n self.to_s.demodulize.underscore\n end", "def action_controller_title\n return \"#{action_name.camelize} #{controller_name.singularize.camelize}\"\n end", "def class_name\n self.fullname[/\\A(.*)([\\.\\#])([^\\.\\#]+)\\z/, 1]\n end", "def name\n klass.name.split('::').last\n end" ]
[ "0.8138946", "0.81307435", "0.8116277", "0.79861736", "0.7981022", "0.79437536", "0.79402995", "0.78532916", "0.78292066", "0.77975655", "0.77604365", "0.77519697", "0.77496713", "0.77435577", "0.7738385", "0.76681775", "0.7547195", "0.7489283", "0.74226636", "0.7379831", "0.73575", "0.73502016", "0.73501205", "0.72956675", "0.72935", "0.7292864", "0.7267328", "0.72649837", "0.7235969", "0.71802586", "0.716089", "0.7157446", "0.7155758", "0.7154748", "0.7143193", "0.7143193", "0.7141529", "0.7137986", "0.7129505", "0.7096864", "0.70808905", "0.70547074", "0.70470893", "0.7043104", "0.70342135", "0.7000477", "0.69974905", "0.69749427", "0.69736254", "0.696963", "0.6913235", "0.6908339", "0.69070524", "0.68962795", "0.6879187", "0.68656474", "0.68428564", "0.6839981", "0.68346477", "0.6827229", "0.6827229", "0.6819245", "0.68183345", "0.6803509", "0.6798507", "0.67705643", "0.6743204", "0.6735931", "0.6722966", "0.67073965", "0.6693864", "0.6683339", "0.6670251", "0.6668935", "0.6668369", "0.6667014", "0.6662152", "0.6641509", "0.66412055", "0.66293675", "0.6612479", "0.66038233", "0.65919405", "0.6554949", "0.65434873", "0.6542736", "0.65409833", "0.65292436", "0.65292436", "0.65246737", "0.6521454", "0.6516297", "0.650981", "0.649544", "0.649544", "0.649544", "0.6488462", "0.6483116", "0.6469559", "0.6457314" ]
0.838742
0
Setting up the GET request
def get_response_body uri = URI.parse(@url) #parse the url being passed in with 'URI.parse' response = Net::HTTP.get_response(uri) # 'GET' the response of the uri with 'Net::HTTP.get_resonse' and pass in the uri variable response.body #return the 'body' from the 'response' variable end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def GET; end", "def get; end", "def _get\n http_method(:get)\n end", "def get\n start { |connection| connection.request http :Get }\n end", "def get\n\t\t\tself.make_request!({uri: self.to_uri, method: :get})\n\t\tend", "def get endpoint\n do_request :get, endpoint\n end", "def http_method\n :get\n end", "def http( *args )\n p http_get( *args )\n end", "def get(*args)\n prepare_request(:get, args)\n @@client.add(:get, @path, *args)\n end", "def get\n RestClient.get(url, @header) do |rso, req, res|\n setup(rso, req, res)\n end\n end", "def get(options = {}, all = true)\n uri = URI.parse(request_path(options, all))\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n puts \"Request URL (GET) is #{uri.request_uri}\" \n\n response = http.request(Net::HTTP::Get.new(uri.request_uri))\n response.body\n end", "def do_get\n Net::HTTP.get(URI.parse(api_url))\n end", "def get\n end", "def get!\n request! :get\n end", "def get\n url = prefix + \"get\"\n return response(url)\n end", "def get\n url = prefix + \"get\"\n return response(url)\n end", "def get\n end", "def get(url); end", "def perform_get_request\n # Validate preventing request error\n\n # setup params, like API Key if needed\n\n # Perform the request\n get_request\n end", "def get_request\n# Use our @http_object object's request method to call the\n# Net::HTTP::Get class and return the resulting response object\n @http_object.request(Net::HTTP::Get.new(@url.request_uri))\n end", "def get(path, params = {})\n\t\trequest(path, :get, params)\n\tend", "def request_method\n {:filter => :post,\n :sample => :get,\n :firehose => :get,\n :retweet => :get\n }.fetch(@path, :get)\n end", "def get\n request_object.get_query\n end", "def get\n Iterable.request(conf, base_path).get\n end", "def get\n Iterable.request(conf, base_path).get\n end", "def get_request\n # Use our @http_object object's request method to call the\n # Net::HTTP::Get class and return the resulting response object\n @http_object.request(Net::HTTP::Get.new(@url.request_uri))\n end", "def get\n url = prefix + \"get\"\n return response(url)\n end", "def get\n url = prefix + \"get\"\n return response(url)\n end", "def get(params)\n request.method = :get\n execute(params)\n end", "def get path = \"\", payload = {}\n make_request(path, \"get\", payload)\n end", "def get_request(path, params={}, options={})\n request(:get, path, params, options)\n end", "def make_request url, parameters={}, method=:get, settings={}\n raise 'not implemented'\n end", "def get query = nil\n\t\tif (query = make_query query)\n\t\t\[email protected] = @uri.query ? @uri.query+\"&\"+query : query\n\t\tend\n\t\tfull_path = @uri.path + (@uri.query ? \"?#{@uri.query}\" : \"\")\n\t\t\t\n\t\treq = Net::HTTP::Get.new(full_path)\n\t\t# puts Net::HTTP::Proxy(@proxy_host, @proxy_port, @proxy_user, @proxy_pwd).get(@uri)\n\t\tdo_http req\n\tend", "def get\n execute_request('GET') do |uri, headers|\n HTTP.http_client.get(\n uri,\n follow_redirect: true,\n header: headers\n )\n end\n end", "def to_get_request\n 'get_%ss' % api_name\n end", "def get(params = {})\n request! do\n api[url.path + to_query(params)].get(API_HEADERS)\n end\n end", "def request; end", "def request; end", "def request; end", "def request; end", "def request; end", "def request; end", "def request; end", "def request; end", "def request; end", "def request; end", "def request; end", "def get!\n self.https.request self.http_request # Net::HTTPResponse object\n end", "def get\n check_response( @httpcli.get(@endpoint) )\n end", "def request\n http_segments = @segments.clone\n @params.each do |key,value|\n http_segments[key] = value\n end\n \n # avoid using URI.encode\n query = ''\n http_segments.each do |key, value|\n query += \"&#{key}=#{value}\"\n end\n query = query[1..-1]\n \n uri = URI::HTTP.build(\n :host => HOST,\n :path => @action_path,\n :query => query\n ).to_s\n result = JSON.parse(HTTParty.get(uri).parsed_response)\n Baidumap::Response.new(result,self)\n end", "def get()\n return @http.request(@req)\n end", "def get(params = {})\n http_helper.send_get_request(\"#{@url_prefix}\", params)\n end", "def get(url='/', vars={})\n send_request url, vars, 'GET'\n end", "def get(path, data = {})\n # Allow format override\n format = data.delete(:format) || @format\n # Add parameters to URL query string\n get_params = {\n :method => \"get\", \n :verbose => DEBUG\n }\n get_params[:params] = data unless data.empty?\n # Create GET request\n get = Typhoeus::Request.new(\"#{protocol}#{@server}#{path}\", get_params)\n # Send request\n do_request(get, format, :cache => true)\n end", "def request_search(options, format = :xml)\r\n\t\t\turi = URI \"#{API_URL}edsapi/rest/Search?#{options}\"\r\n\t\t\t@log << uri.to_s << \" -- \"\r\n\t\t\t#return uri.request_uri\r\n\t\t\treq = Net::HTTP::Get.new(uri.request_uri)\r\n\r\n\t\t\treq['x-authenticationToken'] = @auth_token\r\n\t\t\treq['x-sessionToken'] = @session_token\r\n\t\t\treq['Accept'] = 'application/json' #if format == :json\r\n\r\n\t\t\tNet::HTTP.start(uri.hostname, uri.port, :read_timeout => 10) { |http|\r\n \t\t\tbegin\r\n\t\t\t return http.request(req).body\r\n\t\t\trescue Timeout::Error, Net::ReadTimeout, Errno::EINVAL, Errno::ECONNRESET, EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError => e\r\n\t\t\t raise \"No response from server\"\r\n\t\t\tend\r\n\t\t\t}\r\n end", "def get url\n RestClient::Request.execute(:method => :get, :url => url, :headers => lbaas_headers, :timeout => @timeout, :open_timeout => @open_timeout)\n end", "def get\n end", "def get(path)\n request 'GET', path\n end", "def _request(url, type, key)\n url = URI(url)\n type ||= :GET\n req_path = \"#{url.path}?#{url.query}\"\n\n if type == :GET\n req = Net::HTTP::Get.new(req_path)\n elsif type == :POST\n req = Net::HTTP::Post.new(req_path)\n end\n\n req.add_field('X-Vermillion-Key', key)\n req.add_field('Accept', 'application/json')\n req.add_field('Cache-Control', 'no-cache')\n req.add_field('From', @config.get(:user))\n req.add_field('User-Agent', 'Vermillion Client 1.0')\n\n res = Net::HTTP.new(url.host, url.port).start do |http|\n http.request(req)\n end\n\n res\n end", "def do_GET(request, _response)\n log_request(request)\n end", "def get(path, params = {})\n Chirpy.request params.merge({:path => path, :method => 'get'}.merge(authentication))\n end", "def get(request)\n do_request(request) { |client| client.http_get }\n end", "def get(url, args = {})\r\n make_request(:get, url, args)\r\n end", "def get\n url = prefix + \"get\" + id_param\n return response(url)\n end", "def make_get_request url, headers = []\n make_request url, headers: headers\n end", "def content_get\n\t\t\t# compress GET requests to try and stay under that 8KB request limit\n\t\t\tdeflated_request = Zlib::Deflate.deflate(@request, 9)[2..-5]\n\t\t\t# strict_encode64() isn't available? sub out the newlines\n\t\t\t@request_params[\"SAMLRequest\"] = Base64.encode64(deflated_request).gsub(/\\n/, \"\")\n\t\t\t\n\t\t\tLogging.debug \"SAMLRequest=#{@request_params[\"SAMLRequest\"]}\"\n\t\t\turi = Addressable::URI.parse(@URL)\n\t\t\turi.query_values = @request_params\n\t\t\turl = uri.to_s\n\t\t\t#url = @URL + \"?SAMLRequest=\" + @request_params[\"SAMLRequest\"]\n\t\t\tLogging.debug \"Sending to URL #{url}\"\n\t\t\treturn url\n\t\tend", "def get(path, params = {}, request_options = {})\n request(:get, path, params)\n end", "def get(path, params={})\n params[:apikey] = self.api_key\n RestClient::Request.execute(\n :method => :get,\n :url => \"#{self.uri}#{path}\",\n :headers => {\n :params => params\n },\n :verify_ssl=> @ssl_verify )\n end", "def get(path, params={})\n request(:get, path, params)\n end", "def get(path, params={})\n RestClient.get request_base+path, {params: params}\n end", "def get options\n rest_request({ method: :get }.merge(options))\n end", "def get options\n rest_request({ method: :get }.merge(options))\n end", "def request(*args); end", "def get(path, params, connection = CONNECTION)\n request = Net::HTTP::Get.new(to_url(path, params))\n process_request(request, connection)\nend", "def get(path, params={})\n request(:get, path, params)\n end", "def get(path, params={})\n request(:get, path, params)\n end", "def get(path, params={})\n request(:get, path, params)\n end", "def get(path, params={})\n request(:get, path, params)\n end", "def get(path, params={})\n request(:get, path, params)\n end", "def get(path, params={})\n request(:get, path, params)\n end", "def get(path, params={})\n request(:get, path, params)\n end", "def get(path, params={})\n request(:get, path, params)\n end", "def get(path, params={})\n request(:get, path, params)\n end", "def get(path, params={})\n request(:get, path, params)\n end", "def api_get\n handler.get({email: email}, path)\n end", "def get(uri, params = {}, env = {}, &block)\n super(uri, params, env, &block).tap do |response|\n record_request_response_pair!('get')\n end\n end", "def get(path, **args); end", "def http_get(endpoint)\n uri= URI.parse \"#{@main_url}#{endpoint}\"\n http = Net::HTTP.new(uri.host, uri.port)\n request = Net::HTTP::Get.new(uri.request_uri)\n request.basic_auth(@username, @api_key)\n response = http.request(request)\n response.body\nend", "def query\n start do |connection|\n request = HTTP::Get.new \"#{ @uri.path }?#{ @uri.query }\"\n @headers.each { |header, value| request[header] = value }\n connection.request request\n end\n end", "def get(user_auth=false)\n http = new_http()\n request = Net::HTTP::Get.new(@uri.request_uri)\n initialize_header(request, @header)\n authenticate_user(request) if user_auth == true\n request.body = @payload if @payload\n log_request(request)\n response = http.request(request)\n log_response(response)\nend", "def get(path, query={})\n request.get(path, query_options(query))\n end", "def api_get(action, data)\n api_request(action, data, 'GET')\n end", "def api_get(action, data)\n api_request(action, data, 'GET')\n end", "def get url\n url = URI url\n request = HTTP::Get.new url.path\n\n dispatch request, to: url\n end", "def request(params)\n\n # Add auth header\n headers = params[:headers] || {}\n headers['x-vcloud-authorization'] = @auth_key if !@auth_key.nil? || !@auth_key.equal?('')\n\n # set connection options\n options = {:url => params[:url],\n :body => params[:body] || '',\n :expects => params[:expects] || 200,\n :headers => headers || {},\n :method => params[:method] || 'GET'\n }\n\n # connect\n res = RestClient::Request.execute options\n\n raise res if (res.code!=params[:expects] && res.code!=200)\n\n res\n\n\n end", "def content_get\n # compress GET requests to try and stay under that 8KB request limit\n deflated_request = Zlib::Deflate.deflate(@request, 9)[2..-5]\n # strict_encode64() isn't available? sub out the newlines\n @request_params[\"SAMLRequest\"] = Base64.encode64(deflated_request).gsub(/\\n/, \"\")\n \n Logging.debug \"SAMLRequest=#{@request_params[\"SAMLRequest\"]}\"\n uri = Addressable::URI.parse(@URL)\n if uri.query_values == nil\n uri.query_values = @request_params\n else\n # solution to stevenwilkin's parameter merge\n uri.query_values = @request_params.merge(uri.query_values)\n end\n url = uri.to_s\n #Logging.debug \"Sending to URL #{url}\"\n return url\n end", "def get\n @get ||= Verb.new do |verb|\n verb.entity :air, :lodging, :car, :rail, :transport, \\\n :cruise, :restaurant, :activity, :note, :map, :directions, \\\n :points_program \\\n do |entity, id|\n do_request('get', entity, {:id=>id}, nil)\n end\n\n verb.entity :profile do |*args|\n entity = args[0]\n do_request('get', entity, nil, nil)\n end\n\n verb.entity :trip do |*args|\n entity, id, filter = args\n if filter.nil?\n filter = {}\n end\n filter[:id] = id\n do_request('get', entity, filter, nil)\n end\n end\n end", "def get(url, params={})\n @agent.get(url,params)\n end", "def request\n raise 'need to be implemented'\n end", "def get(path, params = {})\n request(:get, path, params)\n end", "def get(path, params = {})\n request(:get, path, params)\n end" ]
[ "0.7655196", "0.7311063", "0.72740865", "0.72560245", "0.72164136", "0.71721923", "0.71032083", "0.69700783", "0.6962748", "0.69190234", "0.6865394", "0.68603307", "0.6852004", "0.68427813", "0.6840409", "0.6840409", "0.6837059", "0.682648", "0.6811289", "0.6787137", "0.6739443", "0.6737178", "0.6709398", "0.6705855", "0.6705855", "0.6683266", "0.6665616", "0.6665616", "0.6663256", "0.666076", "0.6650878", "0.6650572", "0.66348386", "0.66304225", "0.66124713", "0.6590628", "0.6575105", "0.6575105", "0.6575105", "0.6575105", "0.6575105", "0.6575105", "0.6575105", "0.6575105", "0.6575105", "0.6575105", "0.6575105", "0.654948", "0.65429825", "0.65061677", "0.6497362", "0.6495985", "0.6489141", "0.64788276", "0.64692074", "0.6464434", "0.64534515", "0.6450366", "0.64470017", "0.6446237", "0.6443726", "0.643266", "0.6422117", "0.64170176", "0.6405339", "0.64050156", "0.64040035", "0.6398606", "0.6389176", "0.63879734", "0.6385084", "0.6385084", "0.6381508", "0.6379107", "0.6377282", "0.6377282", "0.6377282", "0.6377282", "0.6377282", "0.6377282", "0.6377282", "0.6377282", "0.6377282", "0.6377282", "0.63752514", "0.6374785", "0.6369022", "0.63649774", "0.6360074", "0.6358611", "0.63559216", "0.63486445", "0.63486445", "0.6348537", "0.63484204", "0.63455147", "0.63440776", "0.6340916", "0.6338606", "0.6331356", "0.6331356" ]
0.0
-1
Call this method if you want the player to learn
def play_to_learn(tateti, opponent) best_play = nil value = nil tateti.empty_cells.each do |possible_play| current_possible = Tateti.new(tateti.copy_board) current_possible.play(possible_play[0], possible_play[1], signature) current_possible_value = get_leaf_value(current_possible, opponent) if value.nil? || current_possible_value > value best_play = possible_play value = current_possible_value end end update_weights(best_play, @eta) update_matrix tateti.play(best_play[0], best_play[1], signature) return tateti end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def action_a\n $game_system.se_play($data_system.decision_se)\n scene = GamePlay::Skill_Learn.new(@pokemon, @ui.learnable_skills[@index].id)\n scene.main\n if scene.learnt\n @return_data = true\n @running = false\n else\n Graphics.transition\n end\n end", "def learn_more\n end", "def affichage_player\n\n\n end", "def love\n \n end", "def learning_mode\n super\n end", "def learning_mode\n super\n end", "def play\n @hungry = true\n end", "def play\n @hungry = true\n end", "def play\n @hungry = true\n end", "def player; end", "def player; end", "def player; end", "def player; end", "def player; end", "def player; end", "def player; end", "def train\n super\n puts \"#{@role} #{@last_name} supports the team during the training\"\n end", "def learn(m, thing, info)\n acknowledgements = ['good to know','got it','roger','understood','OK']\n acknowledgement = acknowledgements[rand(acknowledgements.size)]\n m.reply \"#{acknowledgement}, #{m.user.nick}.\"\n thing.downcase!\n if @@learning_db.has_key? thing\n @@learning_db[thing] = @@learning_db[thing] + \" or #{info}\"\n else\n @@learning_db[thing] = info\n end\n end", "def initialize(player)\n @en_passant = false\n super(player)\n end", "def witcher; end", "def learn utterance\n MyLogger.debug \"Player ##{id} learning #{utterance}\"\n # 1. Incorporation\n rule = grammar.learn utterance.meaning, utterance.word\n # 2. Merging\n grammar.merge rule if rule\n # 3. Cleaning\n grammar.clean!\n end", "def play_to_learn(board, opponent)\n return play(board)\n end", "def learn_it\n interviews = \"https://www.youtube.com/playlist?list=PLUJNJAesbJGVGDiZJ8WvcEC3e1O5cDb5r\"\n puts \"If you want to learn from the IT pros, check out this playlist #{interviews}\"\n superprof_it = \"http://bit.ly/superprof-info\"\n puts \"If you want private lessons, checkout my profile here: #{superprof_it}\"\n podia\nend", "def learn(message)\n @eyes.process_message(message)\n end", "def elearning\n @title = \"e-Learning\"\n end", "def no_learn\n 8\n end", "def play\n puts \"#{name} got zoomies playing fetch!\"\n @hungry = true\n end", "def start\n setPlayers\n question\nend", "def speech\n \n @profile = ProfileId.all\n @hello = 'HELLO'\n # @score = @identified['identifiedProfile']['score']\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\n #calls to all the methods that produce game!\n end", "def learn_human_languages\n puts \"Do you want to learn English?\"\n puts \"1. Yes\"\n puts \"2. No\"\n\n english = get_data\n\n if english == \"1\"\n learn_english\n else\n babel = \"https://www.youtube.com/playlist?list=PLfKvL-VUSKAnkBk88BAb3oq1MlGVnhwcY\"\n puts \"If you want to learn other languages, check this out for FREE: #{babel}\"\n starter_kit\n podia\n end\nend", "def play\n \n end", "def learn_english\n puts \"Go learn English!\"\n dyse = \"https://doyouspeakenglish.fr/\"\n puts \"If you're French, go there for FREE: #{dyse}\"\n english_kit = \"http://bit.ly/kit-anglais\"\n puts \"And for only 1€ you can get a complete starter kit here: #{english_kit}\"\n grammar = \"https://learnenglish.britishcouncil.org/skills\"\n puts \"Otherwise go there: #{grammar}\"\n superprof_english = \"http://bit.ly/superprof-anglais\"\n puts \"If you want private lessons, checkout my profile here: #{superprof_english}\"\n podia\nend", "def adventuring() skill(:adventuring) end", "def spe_training\n\tend", "def play\n @hungry = true\n #p \"play method called\" #print notification to console\n end", "def learn\n\n language = do_you_want_to_learn(\"human languages\")\n\n if language == \"1\"\n learn_human_languages\n end\n\n math = do_you_want_to_learn(\"math\")\n\n math = get_data\n\n if math == \"1\"\n learn_math\n end\n\n it = do_you_want_to_learn(\"it\")\n\n it = get_data\n\n if it == \"1\"\n learn_it\n end\nend", "def learning_new\n puts \"I am Learning #{TECH_ONE}\"\n end", "def next_player!\n end", "def tutorial\n puts\n rules\n deck = Visualized.new\n examples deck.base_deck\n bad_examples deck.base_deck\nend", "def introduction\r\n\r\n end", "def show_players\r\n puts \"Tu as #{human_player.life_points}\"\r\n puts \"il reste #{@enemies.length} bots, courage!!\"\r\n end", "def play\n end", "def learning_help(m)\n m.reply \"Learning module\"\n m.reply \"===========\"\n m.reply \"Description: Teach the bot about things, and have it repeat that info back later.\"\n m.reply \"Usage: [botname] [thing] is [information] (to store additional [information] under the keyword [thing].)\"\n m.reply \"[botname] [thing] (to get whatever the bot knows about [thing].)\"\n end", "def speech; end", "def give_bonus player\n player.add_1_life\n end", "def play; end", "def play\n end", "def play\n end", "def play\n end", "def play\n end", "def difficulty_intro\n print \"\\nWhat difficulty would you like to play? (e)asy, (m)edium, or (h)ard? \"\n end", "def begin\r\n system(\"clear\")\r\n a = Artii::Base.new(:font => 'slant')\r\n puts\r\n puts\r\n puts a.asciify(' Welcome!')\r\n puts\r\n puts a.asciify(' Trent or not!')\r\n puts\r\n puts \" By\\n\\n\"\r\n puts \" James, Carmen, Nathan, and Olivia\\n\\n\\n\\n\"\r\n puts \" Hello , what is your name?\"\r\n\r\n # accepts input and makes a new player class object with their name\r\n # and a default score of 0.\r\n @user = Player.new(gets.chomp, 0)\r\n @user.randomise\r\n end", "def player_base\n @wealth = 0\n @fame = 0\n @current_exp = 0\n @exp_needed = 100\n @available_attribute_points = 30\n @total_proficiency_points = 1\n @available_proficiency_points = 1\n end", "def learn(result)\n return false unless @must_learn\n\n play = Play.get_or_create(@board, @played, @color)\n play.legal = result\n play.save\n @board.reload\n\n unless result\n @most_alike_board = Board.get_this_or_most_alike(@conf)\n @factor = Board.similarity_factor(@conf, @most_alike_board.configuration)\n end\n end", "def play \n end", "def check_new_skills\n last_skills = skills\n self.class.learnings.each do |learning|\n learn_skill(learning.skill_id) if can_learn_skill?(learning)\n end\n display_learn_skills(skills - last_skills)\n end", "def set_player\n\n end", "def speak\n puts \"I'm a person\"\n end", "def play\n# \tThere are 3 players in Knuckleheads: \n\t\tputs \"There are #{to_s} players in #{@title}\"\n# \tI'm Moe with a health of 100 and a score of 103.\n# \tI'm Larry with a health of 60 and a score of 65.\n# \tI'm Curly with a health of 125 and a score of 130.\n\t\[email protected] do |spieler|\n\t\t\tputs \"I'm #{spieler} with a health of #{@health} and a score of #{score}\"\n\t\t\tend\n# \tMoe got blammed!\n# \tMoe got w00ted!\n# \tMoe got w00ted!\n# \tI'm Moe with a health of 120 and a score of 123.\n# \tLarry got blammed!\n# \tLarry got w00ted!\n# \tLarry got w00ted!\n# \tI'm Larry with a health of 80 and a score of 85.\n# \tCurly got blammed!\n# \tCurly got w00ted!\n# \tCurly got w00ted!\n# \tI'm Curly with a health of 145 and a score of 150.\n\t\tend", "def start\n puts \"We have new challengers! Welcome #{@player_1.name} and #{@player_2.name}!\"\n turn\n end", "def game_setup\n end", "def examine \n\t\tputs \"Your Description: #{@player.desc}\" \n\t\tputs \"Health Status: #{@player.health}\" \n\tend", "def setup\n super\n @background = Image['Bg level1.png']\n viewport.lag = 0\n viewport.game_area = [0, 0, 3000, 1000]\n @gilbert = Gilbert.create(x: 50, y: 900, limited: viewport.game_area.width)\n @level = File.join(ROOT, 'levels', self.filename + '.yml')\n load_game_objects(file: @level)\n\n @plataformas = Plataforma2.all\n @music = Song.new('media/Songs/Music Level1.mp3')\n @loser_song = Song.new('media/Songs/gameover.ogg')\n\n @moneda = Moneda.all.first\n\n @meta_on = false\n\n @marco_name = Image['MarcoName.png']\n @marco_score = Image['MarcoPoint.png']\n\n @score = 0\n @msj_name = Chingu::Text.new(@player_name, x: 85, y: 25, size: 30, color: Gosu::Color::WHITE)\n @msj_score = Chingu::Text.new(@score.to_s, x: $window.width - 130, y: 30, size: 35)\n @mensaje = Chingu::Text.new('Has encontrado todas las monedas', x: 320, y: 20, size: 25, color: Gosu::Color::GREEN)\n @mensaje2 = Chingu::Text.new('Encuentra la Meta', x: @msj_name.x, y: 45, size: 30, color: Gosu::Color::YELLOW)\n\n @music.play(true) if @sonido\n end", "def play\n\tend", "def use_skill_nontarget\n Sound.play_use_skill\n @actor.mp -= @actor.calc_mp_cost(@skill)\n @status_window.window_update(@actor)\n @skill_window.window_update(@actor)\n @target_window.window_update($game_party.members)\n if $game_party.all_dead?\n $scene = Scene_Gameover.new\n elsif @skill.common_event_id > 0\n $game_temp.common_event_id = @skill.common_event_id\n $scene = Scene_Map.new\n end\n end", "def use_skill_nontarget\n Sound.play_use_skill\n @actor.mp -= @actor.calc_mp_cost(@skill)\n @status_window.window_update(@actor)\n @skill_window.window_update(@actor)\n @target_window.window_update($game_party.members)\n if $game_party.all_dead?\n $scene = Scene_Gameover.new\n elsif @skill.common_event_id > 0\n $game_temp.common_event_id = @skill.common_event_id\n $scene = Scene_Map.new\n end\n end", "def before_players_ready\r\n end", "def learn\n begin\n pattern = params[:chat][:pattern].strip\n template = params[:chat][:template]\n teach_bot(pattern,template)\n response = {error: false,message: \"Bot is trained.\"}\n render json: response,status: :ok\n rescue Exception => e\n response = {error: true,message: e.message}\n render json: response,status: :unprocessable_entity \n end\n end", "def tutorial\n end", "def score_hand\n\n end", "def play\r\n @secret_word = get_random_word\r\n @secret_word_letters = @secret_word.chars.to_a\r\n print_instructions\r\n play_loop\r\n end", "def spouse; end", "def start \n\t @output.puts \"Welcome to Noughts and Crosses!\"\n\t @output.puts \"Created by:#{created_by}\"\n\t @output.puts \"StudentID: #{student_id}\"\n\t @output.puts \"Starting game...\"\n\t @output.puts \"Player 1: 0 and Player 2: 1\"\n\n\t\n\tend", "def won?\n end", "def won?\n end", "def learn(board)\r\n @board = board\r\n end", "def play_sports\n end", "def update_lifes\n\n if !compare_answer\n @current_responder.lose_life\n end\n\n puts \"#{@player1.print_life} vs #{@player2.print_life}\"\n\n end", "def train_first(player1, player2, runs)\n separation\n tateti = Tateti.new\n p1 = 0\n p2 = 0\n ties = 0\n runs.times do\n loop do\n tateti = player1.play_to_learn(tateti, player2)\n break p1 += 1 if !tateti.winner.nil?\n break ties += 1 if tateti.tie?\n tateti = player2.play(tateti)\n break p2 += 1 if !tateti.winner.nil?\n break ties += 1 if tateti.tie?\n end\n tateti.empty_board\n end\n print_stats(player1, player2, runs, p1, p2, ties)\nend", "def stand!\n\t\t@standing = true\n\tend", "def light_the_way\n HisMastersVoice.instance.tell_me(self)\n end", "def intro \n @player1 = Player.new(\"Josiane\")\n puts \"à ma droite Josiane\"\n @player2 = Player.new(\"José\")\n puts \"à ma gauche José\"\nend", "def help_players\n puts \"Greed is a dice game played among 2 or more players, using 5\"\n puts \"six-sided dice.\"\n pressToContinue\n end", "def start_game\n question = Question.new\n player_answer = question.ask_question(current_player)\n answer_check = question.check_answer(player_answer)\n \n \n if !answer_check\n current_player.lose_life\n change_current_player\n puts \"Seriously?! You lost a life!!\"\n else\n puts \"Absolutely Correct!\"\n end\n\n puts \"#{player_1.name} has #{player_1.lives} lives\"\n puts \"#{player_2.name} has #{player_2.lives} lives\"\n\n self.lives_checker\n end", "def learn_math\n puts \"If you need some basic maths lessons.\"\n prglump = \"https://www.youtube.com/channel/UCLxVJHhqaLMuyTcbUsoCrFg/videos?view=0&sort=p&flow=grid\"\n puts \"Perhaps you can learn something on this YouTube channel #{prglump}\"\n superprof_math = \"https://bit.ly/2wlBbF9\"\n puts \"If you want more advance math private lessons, checkout my profile here: #{superprof_math}\"\n podia\nend", "def check_learnings(show=TH::Learn_Condition_Formulas::Show_Messages)\n last_skills = skills\n self.class.learnings.each do |learning|\n learn_skill(learning.skill_id) if can_learn?(learning)\n forget_skill(learning.skill_id) if can_forget?(learning)\n end\n learned_skills = skills - last_skills\n forget_skills = last_skills - skills\n display_learning_messages(learned_skills, forget_skills) if show\n end", "def play\n take_turn until @master.game_over?\n @master.show_board\n @robot.speak\n end", "def after_players_ready\r\n end", "def speak\n\t\traise 'You must implement this in a subclass'\n\tend", "def ask_question\n question = Question.new\n puts \"\\nPlayer 1: #{question.text}\"\n end", "def won?\n # Fill this in\n end", "def playHand\n\t\ttotal_score = 0\n\t\ti = 0\n\t\tputs @hand.to_str\n\t\tputs @hand.isEmpty?\n\t\twhile not @hand.isEmpty? do\n\t\t\tputs 'Current Hand: %s' % [@hand.to_str]\n\t\t\tword = self.pickBestWord\n\t\t\treturn if word == \".\"\n\t\t\tpoints = getWordScore(word)\n\t\t\ttotal_score += points\n\t\t\tputs '%s earned %d points. Total: %d points' % [word, points, total_score]\n\t\t\[email protected](word)\n\t\t\ti += 1\n\t\tend\n\tend", "def change_player\n\n end", "def pbPlayTrainerIntroME(trainer_type)\r\n trainer_type_data = GameData::TrainerType.get(trainer_type)\r\n return if nil_or_empty?(trainer_type_data.intro_ME)\r\n bgm = pbStringToAudioFile(trainer_type_data.intro_ME)\r\n pbMEPlay(bgm)\r\nend", "def train_players\n self.players.each(&:train)\n end", "def display_learning_messages(learned_skills, forget_skills)\n learned_skills.each do |skill|\n $game_message.add(sprintf(TH::Learn_Condition_Formulas::Learn_Message, self.name, skill.name))\n end\n forget_skills.each do |skill|\n $game_message.add(sprintf(TH::Learn_Condition_Formulas::Forget_Message, self.name, skill.name))\n end\n end", "def speak meaning\n MyLogger.debug \"Player ##{id} speaking #{meaning}\"\n word = lookup(meaning, should_invent?)\n Utterance.new(meaning, word) unless word.nil?\n end", "def setup\n @potential_plays = [\"rock\", \"paper\", \"scissors\"]\n @win_counter = Hash[\"P1\",0, \"P2\",0]\n end", "def played\n won + drawn + lost + noresult\n end" ]
[ "0.68083525", "0.6510004", "0.64347064", "0.6417011", "0.63358337", "0.63358337", "0.62427026", "0.62427026", "0.62427026", "0.6215584", "0.6215584", "0.6215584", "0.6215584", "0.6215584", "0.6215584", "0.6215584", "0.6182033", "0.6150178", "0.61481744", "0.61362034", "0.6134157", "0.6102562", "0.6090035", "0.60860896", "0.6042573", "0.602549", "0.601782", "0.6005136", "0.5990935", "0.59664494", "0.595739", "0.5956505", "0.59472126", "0.59321237", "0.59225863", "0.59215564", "0.59183556", "0.5893493", "0.58913654", "0.58779436", "0.5874862", "0.5874729", "0.5869473", "0.58557", "0.5840259", "0.5840063", "0.5834531", "0.58266264", "0.58222437", "0.58222437", "0.58222437", "0.58222437", "0.58175826", "0.5791809", "0.57868695", "0.5785146", "0.5784782", "0.5783142", "0.5776397", "0.5773647", "0.57523113", "0.5749444", "0.57493794", "0.57276624", "0.5726381", "0.57129747", "0.5712169", "0.5712169", "0.57078314", "0.56951946", "0.5690839", "0.56896067", "0.5687334", "0.5684926", "0.5683339", "0.5679836", "0.5679836", "0.5678693", "0.56757015", "0.56745213", "0.56742877", "0.56689066", "0.56673205", "0.56602657", "0.56598365", "0.56596637", "0.56520057", "0.5638983", "0.5627968", "0.5606234", "0.55985516", "0.559469", "0.5591928", "0.55866134", "0.5585817", "0.558185", "0.5577848", "0.55673426", "0.55658084", "0.55639696", "0.55594856" ]
0.0
-1
Method used to calculate one possible final board and its value only letting players use play method
def get_leaf_value(tateti, opponent) # Assume its turn of the opponent loop do tateti = opponent.play(tateti) break if !tateti.winner.nil? break if tateti.tie? tateti = play(tateti) break if !tateti.winner.nil? break if tateti.tie? end return game_function(tateti) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def win_block_1_2(player)\n\n\t\tif player == 1\n\t\t\tproduct = 1\n\t\telse\n\t\t\tproduct = 4\n\t\tend\n\n\t\tif self.board[0] == \"0\" && (self.board[1].to_i * self.board[2].to_i == product || self.board[3].to_i * self.board[6].to_i == product || self.board[4].to_i * self.board[8].to_i == product )\n\t\t\treturn 0\n\t\telsif self.board[1] == \"0\" && (self.board[4].to_i * self.board[7].to_i == product || self.board[0].to_i * self.board[2].to_i == product)\n\t\t\treturn 1\n\t\telsif self.board[2] == \"0\" && (self.board[1].to_i * self.board[0].to_i == product || self.board[5].to_i * self.board[8].to_i == product || self.board[4].to_i * self.board[6].to_i == product)\n\t\t\treturn 2\n\t\telsif self.board[3] == \"0\" && (self.board[4].to_i * self.board[5].to_i == product || self.board[0].to_i * self.board[6].to_i == product)\n\t\t\treturn 3\n\t\telsif self.board[4] == \"0\" && (self.board[0].to_i * self.board[8].to_i == product || self.board[2].to_i * self.board[6].to_i == product || self.board[1].to_i * self.board[7].to_i == product || self.board[3].to_i * self.board[5].to_i == product)\n\t\t\treturn 4\n\t\telsif self.board[5] == \"0\" && (self.board[4].to_i * self.board[3].to_i == product || self.board[2].to_i * self.board[8].to_i == product)\n\t\t\treturn 5\n\t\telsif self.board[6] == \"0\" && (self.board[3].to_i * self.board[0].to_i == product || self.board[4].to_i * self.board[2].to_i == product || self.board[7].to_i * self.board[8].to_i == product)\n\t\t\treturn 6\n\t\telsif self.board[7] == \"0\" && (self.board[4].to_i * self.board[1].to_i == product || self.board[6].to_i * self.board[8].to_i == product)\n\t\t\treturn 7\n\t\telsif self.board[8] == \"0\" && (self.board[4].to_i * self.board[0].to_i == product || self.board[5].to_i * self.board[2].to_i == product || self.board[7].to_i * self.board[6].to_i == product)\n\t\t\treturn 8\n\t\telse\n\t\t\treturn -1\n\t\tend\n\tend", "def until_the_end(numbers, boards)\n winning = []\n numbers.product(boards) do |n, board|\n if !winning.include?(board) && score = board.play(n)\n if winning.length < boards.length-1\n winning << board\n else\n return score\n end\n end\n end\nend", "def evaluate(board, player = 'o', opponent = 'x')\r\n # Checking rows for victory\r\n 3.times do |row|\r\n if are_equal?(board[row][0], board[row][1], board[row][2], player, opponent)\r\n return player?(board[row][0], player, opponent)\r\n end\r\n end\r\n # Checking cols for victory\r\n 3.times do |col|\r\n if are_equal?(board[0][col], board[1][col], board[2][col], player, opponent)\r\n return player?(board[0][col], player, opponent)\r\n end\r\n end\r\n # Checking frist diagonal for victory\r\n return player?(board[0][0], player, opponent) if are_equal?(board[0][0], board[1][1], board[2][2], player, opponent)\r\n # Checking second diagonal for victory\r\n return player?(board[0][2], player, opponent) if are_equal?(board[0][2], board[1][1], board[2][0], player, opponent)\r\n # If none of them have won\r\n 0\r\n end", "def solve\n cell_index, cell = @game_board.first\n until cell.nil?\n cell_value = cell.increment\n unless cell_value == false\n if @game_board.value_allowed?(cell_index, cell_value)\n cell.increment!\n cell_index, cell = @game_board.next(cell_index)\n else\n cell.increment!\n end\n else\n cell.empty!\n cell_index, cell = @game_board.prev(cell_index)\n end\n end\n\n @game_board\n end", "def calculateQValueForLastAction(playerState) # => board is new board after OP placed a move\n\t\t\t# if !self.currentStateKey || !self.currentActionKey\n\n\t\t\tif !self.newStateKey\n\t\t\t\t# binding.pry\n\t\t\t\tputs 'new state is nil'\n\t\t\t\treturn \n\t\t\tend\n\n\n\t\t\t# opponent must updated the board here\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t# binding.pry\n\n\n\t\t\t# puts \"player state: #{playerState}\"\n\t\t\t# unless self.matrix[self.newStateKey]\n\t\t\t# \tputs \"#{self.token} self.matrix[self.newStateKey] is nil: #{self.newStateKey}\"\n\t\t\t# \t# return \n\t\t\t# end\n\n\t\t\tunless self.matrix[self.newStateKey] # first play does not have matrix and when game is over, there is no available move\n\t\t\t\t_initializeState(self.newStateKey) \n\t\t\tend\n\n\t\t\tself.nextBestMove = nil\n\t\t\tnewActionQValue = 0\n\n\t\t\tif playerState == PLAYER_STATE[:WIN] || playerState == PLAYER_STATE[:LOSE] || playerState == PLAYER_STATE[:DRAW] # => self play win or (OP play win) = self lose\n\t\t\t\t\n\t\t\t\t # => already win, don't need the max Q of next actions\n\t\t\t\tcase playerState\n\t\t\t\twhen PLAYER_STATE[:WIN]\n\t\t\t\t\tnewActionQValue = REWARDS[:WIN]\n\t\t\t\twhen PLAYER_STATE[:LOSE]\n\t\t\t\t\tnewActionQValue = REWARDS[:LOSE]\n\t\t\t\twhen PLAYER_STATE[:DRAW]\n\t\t\t\t\tnewActionQValue = REWARDS[:DRAW]\n\t\t\t\telse\n\t\t\t\tend\n\n\t\t\telsif self.matrix[self.newStateKey] # => alive after OP played a move, and generate self.nextBestMove to guide next move and newActionQValue\n\n\t\t\t\t### get next max Q\n\t\t\t\tactions = nil\n\n\t\t\t\tself.nextBestMove = self.findBestMove(self.newStateKey) # => the best move may be not the best if OP has two win position\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t# => OP played last position on board\n\t\t\t\t# found newStateKey, but there are no actions\n\t\t\t\tif !self.nextBestMove\n\n\t\t\t\t\tactions = self.matrix[self.newStateKey] # [[:key, 1], [:key2, 2]] \n\t\t\t\t\t#puts \"actions: #{actions}\" if self.game.mode == \"Play\"\n\t\t\t\t\tunless actions.empty? # => must has actions here, may be {}\n\t\t\t\t\t\tactions = actions.sort_by {|k, v| v}\n\n\t\t\t\t\t\tactionWithMaxQ = actions.last[0] # => 'x|y'\n\t\t\t\t\t\tactionWithMinQ = actions.first[0]\n\n\t\t\t\t\t\tif self.matrix[self.newStateKey][actionWithMinQ] == self.matrix[self.newStateKey][actionWithMaxQ] # new state\n\n\t\t\t\t\t\t\tactionWithMaxQ = actions[rand(actions.length - 1)][0] # => no win move, then use the best Q action for next move if there is no win move\n\t\t\t\t\t\t\tself.nextBestMove = actionWithMaxQ\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tself.nextBestMove = actionWithMaxQ\n\t\t\t\t\t\tend\n\n\t\t\t\t\tend\t# => actions\n\t\t\t\t\t\n\t\t\t\t\t#puts \"#{self.tag} Generate a move for next turn: #{self.nextBestMove} on state #{self.newStateKey}\" #if self.game.mode == \"Play\"\n\t\t\t\telse\n\t\t\t\t\t#puts \"#{self.tag} Found a best move for next turn: #{self.nextBestMove} !!!!!!!!!!!\" #if self.game.mode == \"Play\"\n\t\t\t\tend # => !self.nextBestMove\n\n\t\t\t\t \n\n\n\n\t\t\t\t####### check win move ######\n\t\t\t\t# actionWithMaxQ = nil\n\t\t\t\t# puts \"actions for win move: #{actions}\" if self.game.mode == \"Play\"\n\t\t\t\t# if actions\n\t\t\t\t# \tactions = actions.sort_by {|k, v| v}\n\n\t\t\t\t# \tactionWithMaxQ = actions.last[0] # => 'x|y'\n\t\t\t\t# \tactionWithMinQ = actions.first[0]\n\n\t\t\t\t# \tif self.matrix[currentStateKey][actionWithMinQ] == self.matrix[currentStateKey][actionWithMaxQ] # new state\n\n\t\t\t\t# \t\tactionWithMaxQ = actions[rand(actions.length - 1)][0] # => no win move, then use the best Q action for next move if there is no win move\n\t\t\t\t\t\t\n\t\t\t\t# \t\tself.nextMove = actionWithMaxQ\n\t\t\t\t# \tend\n\t\t\t\t\t# self.nextBestMove = nil\n\t\t\t\t\t# puts \"==========================================\"\n\t\t\t\t\t# puts \"#{actions}\"\n\t\t\t\t\t# actions.each do |action|\n\t\t\t\t\t# \txy = action[0].split(DELIMITER)\n\t\t\t\t\t# \tif self.game.board.winMove?(x:xy[0], y:xy[1], token:self.token)\n\t\t\t\t\t# \t\tunless self.nextBestMove \n\t\t\t\t\t# \t\t\tself.nextBestMove = action[0] \t\t\t\t# => found win move\n\t\t\t\t\t# \t\t\tactionWithMaxQ = self.nextBestMove\n\t\t\t\t\t# \t\tend\n\t\t\t\t\t\t\t\n\t\t\t\t\t# \t\tputs \"player: #{self.token}, next best move: #{actionWithMaxQ}\"\n\t\t\t\t\t# \tend\n\t\t\t\t\t# end\n\n\n\n\n\t\t\t\t\t# actionWithMaxQ = actions.last[0] unless actionWithMaxQ # => 'x|y' # => no win move, then use the best Q action for next move\n\t\t\t\t# end\n\n\t\t\t\tnewActionQValue = self.matrix[self.newStateKey][self.nextBestMove] || 0 if newActionQValue == 0\n\t\t\telse # => draw\n\t\t\t\tnewActionQValue = 0\n\t\t\tend\n\t\t\t # actions.last[1]\n\n\n\n\t\t\t# reward = _analyzeNewState(self.newStateKey, actionWithMaxQ)\n\n\t\t\treward = REWARDS[playerState.to_sym] # get the reward of last move after OP played\n\n\t\t\t# lastActionQValue = 0\n\t\t\t# lastStateKey = nil\n\t\t\t# lastActionKey = nil\n\t\t\t# if !self.lastStateKey || !self.lastActionKey\n\t\t\t# \t# binding.pry\n\t\t\t# \tlastStateKey = @currentStateKey\n\t\t\t# \tlastActionKey = @currentActionKey\n\t\t\t# \tlastActionQValue = 0\n\t\t\t# else\n\t\t\t# \t# binding.pry\n\t\t\t# \tlastStateKey = @lastStateKey\n\t\t\t# \tlastActionKey = @lastActionKey\n\t\t\t# \tlastActionQValue = self.matrix[lastStateKey][lastActionKey]\n\t\t\t# end\n\n\n\t\t\t\n\t\t\t\n\n\n\t\t\t# if !lastActionQValue\n\t\t\t# \tputs 'lastActionQValue is nil'\n\t\t\t# \treturn \n\t\t\t# end\n\n\t\t\t# # binding.pry\n\n\t\t\t# if !self.matrix[@currentStateKey]\n\n\t\t\t# end\n\n\n\n\n\n\n\n\n\t\t\t# currentActionQValue = self.matrix[self.currentStateKey]\n\n\t\t\t# [self.currentActionKey] || 1\n\n\n\n\n\n\n\n\t\t\t\n\t\t\t# q = (1 - CONFIG[:discount]) * self.currentActionQValue + CONFIG[:alpha] * (reward + CONFIG[:discount] * newActionQValue)# - self.currentActionQValue)\n\n\t\t\tif self.lastActionQValue && reward && newActionQValue && self.matrix[self.lastStateKey] && self.lastActionKey\n\t\t\t\tq = nil\n\t\t\t\tq = self.lastActionQValue + CONFIG[:alpha] * (reward + CONFIG[:discount] * newActionQValue - self.lastActionQValue)\n\n\t\t\t\tself.matrix[self.lastStateKey][self.lastActionKey] = q.round(5)\n\n\t\t\t\t# $matrix = self.matrix\n\t\t\t\t#puts \"player: #{self.token} state: #{playerState}, reward: #{reward}, Q: #{q.round(5)}\"# if self.game.mode == \"Play\"\n\t\t\t\t# puts \"newStateKey: #{newStateKey}, newAction: #{actionWithMaxQ}, nextMoveQValue: #{newActionQValue}\"\n\t\t\t\t#puts \"lastPlayedStateKey: #{self.lastStateKey}, lastPlayedAction: #{self.lastActionKey}, lastActionQValue: #{lastActionQValue}, updatedQValue: #{self.matrix[self.lastStateKey][self.lastActionKey]}\"# if self.game.mode == \"Play\"\n\t\t\t\t# puts \"depends on new state: #{self.newStateKey}, new action: #{actionWithMaxQ}, newActionMaxQValue: #{newActionQValue}\" if self.game.mode == \"Play\"\n\t\t\t\t# puts \"last state: #{self.lastStateKey}, move: #{self.lastActionKey}, old Q: #{self.lastActionQValue}, updated to #{self.matrix[self.lastStateKey][self.lastActionKey]}\"\n\t\t\t\t# puts \"==========================================================================================\"\n\n\t\t\t\t\n\t\t\telse\n\t\t\t\tputs \"No any state after OP moved!!!!!!!!!\" if self.game.mode == \"Play\"\n\t\t\tend\n\n\t\t\tself.lastStateKey = nil\n\t\t\tself.lastActionKey = nil\n\t\t\tself.lastActionQValue = nil\n\t\t\tputs \"===================END====================\" if self.game.mode == \"Play\"\n\t\tend", "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 game_over(player)\n #combinaisons gagnantes\n vic_combi = [[0,1,2], [3,4,5], [6,7,8], [0,3,6], [1,4,7], [2,5,8], [0,4,8], [2,4,6]]\n #verifie si les cases occupées le sont par le meme joueur\n vic_combi.each do |victorious_case|\n if @board.board[victorious_case[0]].case_value + @board.board[victorious_case[1]].case_value+ @board.board[victorious_case[2]].case_value == player.symbol * 3\n return player\n end\n end\n return false\n end", "def play_as_master_first\r\n @pending_points = 0\r\n w_cards = []\r\n curr_points_me = @team_mates.inject(0){ |result, name_pl| result + @points_segno[name_pl] }\r\n @cards_on_hand.each do |card_lbl|\r\n card_s = card_lbl.to_s # something like '_Ab'\r\n segno = card_s[2,1] # character with index 2 and string len 1\r\n is_card_lbl_briscola = card_s[2] == @briscola.to_s[2] \r\n curr_w = 0\r\n curr_w += 70 if is_card_lbl_briscola\r\n # check if it is an asso or 3\r\n curr_w += 220 if card_s[1] == \"A\"[0]\r\n curr_w += 200 if card_s[1] == \"3\"[0] \r\n if card_s =~ /[24567]/\r\n # liscio value\r\n lisc_val = (card_s[1] - '0'[0]).to_i\r\n curr_w += 50 + lisc_val\r\n end\r\n curr_w += 60 if card_s[1] == \"F\"[0]\r\n # check horse and king cards\r\n if card_s[1] == \"C\"[0]\r\n if is_mariazz_possible?(segno)\r\n curr_w += 90 + 70\r\n else\r\n curr_w += 30\r\n end\r\n end \r\n if card_s[1] == \"R\"[0]\r\n if is_mariazz_possible?(segno)\r\n curr_w += 100 + 70\r\n else\r\n curr_w += 20\r\n end\r\n end\r\n # penalty for cards wich are not stroz free\r\n curr_w += 10 * @strozzi_on_suite[segno].size\r\n if (curr_points_me + @deck_info.get_card_info(card_lbl)[:points]) > @target_points\r\n curr_w -= (@deck_info.get_card_info(card_lbl)[:points] + 100)\r\n curr_w -= 200 if is_card_lbl_briscola\r\n curr_w -= 1000 if is_card_lbl_briscola and card_s[1] == \"A\"[0]\r\n end\r\n \r\n w_cards << [card_lbl, curr_w ] \r\n end\r\n # find a minimum\r\n #p w_cards\r\n min_list = w_cards.min{|a,b| a[1]<=>b[1]}\r\n @log.debug(\"Play as first: best card#{min_list[0]}, (w_cards = #{w_cards.inspect})\")\r\n return min_list[0]\r\n end", "def current_player(board)\nturn_count(board).even? ? \"X\":\"O\"\nend", "def current_player(board)\n current_pla = turn_count(board)\n if current_pla %2==0\n return \"X\"\n else\n return \"O\"\n end\n \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 play!(column, opponent_board)\n # Is the column full?\n # Let's grab both boards, bitwise or them and transpose so we can\n # easily sum the column.\n full_board = opponent_board.bitboard | self.bitboard\n full_board = self.class.to_a(full_board)\n full_board = full_board.transpose\n\n count = full_board[column].inject { |sum, val| sum + val }\n return false if count == ROWS\n\n # Okay, not full, drop it into the uppermost empty space\n # Again, use the full board, grab the row (which would be the col)\n # and get the index of the leftmost zero of the reversed row.\n row = full_board[column].reverse.index(0)\n\n new_bitboard = self.class.binary_string(self.bitboard)\n new_bitboard[(column * COLS) + row] = \"1\"\n self.update_attributes! bitboard: new_bitboard.to_i(2), turn: false\n opponent_board.update_attribute :turn, true\n\n Pusher['moves'].trigger('drop', {\n row: (ROWS - row - 1),\n col: column,\n user_id: self.user_id,\n turn: opponent_board.user_id\n })\n\n return [ROWS - row - 1, column]\n end", "def play\n 2.times {deal}\n blind_score\n if player_hand.collect{|x| x.value}.inject(:+) == 21\n bjwin\n elsif computer_hand.collect{|x| x.value}.inject(:+) == 21\n bjlose\n else\n action\n end\n end", "def computers_round\n @played = false\n\n if @turn == 1\n random_tile #which will choose a corner automatically\n end\n\n [@curr_player_index,((@curr_player_index + 1) % 2)].each do |i|\n if @played == false\n check_2in3(@avail_tiles, @players[i].moves) #first checks if computer can already win, then check if need to prevent player from winning\n choose_tile(@any_winning[0]) if @any_winning.length > 0\n end\n end\n\n if @played == false #runs if no one can immediately win in this round\n if @final_move == nil\n final_move(@avail_tiles, @players[@curr_player_index].moves, nil)\n end\n\n if @final_move != nil #final move is now determined; note, this is not 'else' of the prior 'if'\n choose_tile(@final_move)\n else #if final move not determined, run strategy\n if @turn == 3 #the strategy would not be useful except in turn 1\n winning_strategy\n choose_tile(@checkmate_move) if @checkmate_move != nil\n end\n end\n end\n\n if @played == false #is still no move taken\n #in the event that Player goes first, and chooses a corner\n if @turn == 2 and @avail_corners.length == 3\n choose_tile(\"5\") #choose the centre\n #in the event that Computer goes first, and Player chooses centre\n elsif @turn == 3 and @taken_tiles.include? \"5\"\n player_chooses_centre_in_turn2\n elsif @turn == 4\n if @avail_corners.length == 3 #in the event that Player goes first but avoids choosing corners\n choose_tile(\"5\") #choose the centre\n elsif @avail_corners.length == 2\n if @players[@curr_player_index].moves.include? \"5\" #i.e. Player took 2 diagonal corners; Computer took centre\n #choose a tile that is not a corner\n non_corners = [\"2\",\"4\",\"6\",\"8\"]\n random_non_corner = non_corners[rand(4)]\n choose_tile(random_non_corner)\n else #i.e. Player intially takes centre, Computer then takes corner, Player then takes diagonal corner\n random_tile #chooses a remaining corner\n end\n else\n if @avail_corners.length == 2 and !@taken_tiles.include? \"5\" #i.e. Player initial takes non-corner, Computer takes a corner, Player then takes a corner\n choose_tile(\"5\") #choose the centre\n end\n end\n else\n random_tile\n end\n end\n end", "def winner(board)\nif winning_combination = won?(board)\nboard[winning_combination[0]]\nend\nend", "def current_player(board)\nturn_count(board).even? ? \"X\" : \"O\"\nend", "def winner(board)\n if combination = won?(board)\n board[combination.first]\n end\nend", "def player_moves(board)\n\t\tnew_hash_o = {} # Holds the winning combination positions the other player is occupying\n\t\tnew_hash_c = {} # Holds the winning combination positions the current player is occupying\n\t\tfinal_hash_o = {} # Holds the other player winning combination that need to be blocked on the next move\n\t\tfinal_hash_c = {} # Holds the move to be made for the current player winning combination\n\t\tWIN_COMBINATIONS.each do |k,v| # Check which of the other player's and current player's positions are part of a winning combination\n\t\t new_hash_o[k] = []\n\t\t new_hash_c[k] = []\n\t\t @other_player_positions.each do |t| # Check which of the other player's positions are part of a winning combination\n\t\t\t if v.include?(t)\n\t\t\t \tnew_hash_o[k] << t # If the position is part of a winning combination include it in the new hash\n\t\t \tend\n\t\t end\n\t\t @current_player_positions.each do |t| # Check which of the current player's positions are part of a winning combination\n\t\t\t if v.include?(t)\n\t\t\t \tnew_hash_c[k] << t # If the position is part of a winning combination include it in the new hash\n\t\t \tend\n\t\t end\n\t\tend\n\t\t@other_player_positions = [] # Clear the other player position results ready for the next turn\n\t\t@current_player_positions = [] # Clear the current player position results ready for the next turn\n\t\tnew_hash_o.each do |k,v| # Check whether the other player has one move to go on a winning combination\n\t\t\t# If there are two positions of a winning combination held by the other player include the combination in the final hash\n\t\t\tif new_hash_o[k].size > 1\n\t\t\t\tfinal_hash_o[k] = new_hash_o[k] # Final hash holds the vulnerable positions that need to be filled\n\t\t\tend\n\t\tend\n\t\tnew_hash_c.each do |k,v| # Check whether the current player has one move to go on a winning combination\n\t\t\t# If there are two positions of a winning combination held by the current player include the combination in the final hash\n\t\t\tif new_hash_c[k].size > 1\n\t\t\t\tfinal_hash_c[k] = new_hash_c[k] # Final hash holds the winning positions that need to be filled\n\t\t\tend\n\t\tend\n\t\t# Find the final position to move to block the other player's winning combination\n\t\t # Find the final position for current player to move to win\n\t\tWIN_COMBINATIONS.each do |k,v|\n\t\t\tif final_hash_o.include?(k)\n\t\t\t\t@move_o << WIN_COMBINATIONS[k] - final_hash_o[k]\n\t\t\t\tif !board.valid_move?(@move_o[0][0]) # Check whether the final position is a valid move\n\t\t\t\t\t@move_o.shift # If not a valid position remove the final move\n\t\t\t\tend\n\t\t\tend\n\t\t\tif final_hash_c.include?(k)\n\t\t\t\t@move_c << WIN_COMBINATIONS[k] - final_hash_c[k]\n\t\t\t\tif !board.valid_move?(@move_c[0][0]) # Check whether the final position is a valid move\n\t\t\t\t\t@move_c.shift # If not a valid position remove the final move from the array\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\tif !@move_o.empty? # Don't test and pass an empty array\n\t\t\t\t@move_o = @move_o.sample # Only one move can be made\n\t\t\t\t@move_o # Final move to block the other player's winning combination\n\t\tend\n\t\tif !@move_c.empty? # Don't test and pass an empty array\n\t\t\t\t@move_c = @move_c.sample # Only one move can be made\n\t\t\t\t@move_c # Final move to block the other player's winning combination\n\t\tend\n\tend", "def current_player(board)\n turn_count(board)\n if turn_count(board).even?\n \"X\"\n else \n \"O\"\n end\nend", "def solve!\n\n until solved?\n\n\n @cell_array.each do |cell_object|\n cell_object.refresh_possible_values(@cell_array)\n if cell_object.value == 0 && cell_object.possible_values.length == 1\n cell_object.value = cell_object.possible_values[0]\n end\n end\n\n end\n\n board\n\n end", "def play(board)\n until over?(board)\n turn(board)\n #value=current_player(board)\n end\n if winner(board)==\"X\"\n puts \"Congratulations X!\"\n elsif winner(board)==\"O\"\n puts \"Congratulations O!\"\n else\n puts \"Cats Game!\"\n end\nend", "def next_scores\n if @last_piece_moved != @computers_piece\n max_scores # computers move\n else\n min_scores # players move\n end\n end", "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 computer_input(board)\n row_col = computer_choose_random(board)\n row_col = [1, 1] if field_empty?([1, 1], board)\n unless computer_choose_defensive(board).none?\n row_col = computer_choose_defensive(board)\n end\n unless computer_choose_aggressive(board).none?\n row_col = computer_choose_aggressive(board)\n end\n row_col\nend", "def take_turn\n valid_cells(@opponent_board).sample\n end", "def current_player(board)\n if turn_count(board).even?\n return \"X\"\n else\n return \"O\"\n end\nend", "def current_player(board)\n if turn_count(board).even?\n return \"X\"\n else\n return \"O\"\n end\nend", "def check_for_optimal_move(mark_value)\n @board.all_valid_moves.each do |valid_move|\n @board.mark_square(valid_move[0],valid_move[1],mark_value)\n marked_square=[valid_move[0],valid_move[1]]\n if @board.winner?\n return mark_value\n elsif @board.tie?\n return 0\n else\n check_for_optimal_move(mark_value = -mark_value)\n end\n end\nend", "def current_player(board)\n count = turn_count(board)\n if count.even?\n return \"X\"\n else\n return \"O\"\n end\nend", "def current_player(board)\n return turn_count(board).odd? ? \"O\" : \"X\"\n\nend", "def current_player(board)\n var = turn_count(board)\n if var.even?\n return \"X\"\n elsif var.odd?\n return \"O\"\n end \n var\nend", "def reduce_possibilities!\n @status = :impossible unless valid?\n @possibilities.each_with_index do |row, i|\n break if @status == :impossible\n row.each_with_index do |cell, j|\n break if @status == :impossible\n next if cell.length == 1\n\n neighbors = find_row_neighbors(i, j) + find_col_neighbors(i, j) + find_square_neighbors(i, j)\n @possibilities[i][j] -= neighbors\n if @possibilities[i][j].length == 0\n @status = :impossible\n elsif @possibilities[i][j].length == 1\n @board[i][j] = @possibilities[i][j][0]\n end\n end\n end\n end", "def current_player(board) # Current_player method takes in an argument of the game board\n turn_count(board).even? ? board = \"X\" : board = \"O\"\nend", "def current_player\n self.board.turn_count.even?? self.player_1 : self.player_2\n end", "def current_player(board)\n if turn_count(board).even?\n \"X\"\n elsif turn_count(board).odd?\n \"O\"\n end\nend", "def current_player(board)\n turn_count(board).even? ? \"X\" : \"O\"\nend", "def current_player(board)\n turn_count(board).even? ? \"X\" : \"O\"\nend", "def current_player(board)\n turn_count(board).even? ? \"X\" : \"O\"\nend", "def current_player(board)\n turn_count(board).even? ? \"X\" : \"O\"\nend", "def current_player(board)\n turn_count(board).even? ? \"X\" : \"O\"\nend", "def current_player(board)\n turn_count(board).even? ? \"X\" : \"O\"\nend", "def current_player(board)\n turn_count(board).even? ? \"X\" : \"O\"\nend", "def current_player(board)\n turn_count(board).even? ? \"X\" : \"O\"\nend", "def current_player(board)\n turn_count(board).even? ? \"X\" : \"O\"\nend", "def current_player(board)\n turn_count(board).even? ? \"X\" : \"O\"\nend", "def current_player(board)\n count = turn_count(board)\n count.even? ? \"X\" : \"O\"\nend", "def current_player(board)\n\n # if_this_is_a_true_value ? then_the_result_is_this : else_it_is_this\n turn_count(board) % 2 == 0 ? \"X\" : \"O\"\n\nend", "def current_player(board)\n if turn_count(board).even?\n \"X\"\n else\n \"O\"\n end\nend", "def current_player(board)\n if turn_count(board).even?\n \"X\"\n else\n \"O\"\n end\nend", "def winner(board)\n if winning_combination = won?(board)\n board[winning_combination[0]]\n end\nend", "def winner(board)\n if winning_combo = won?(board)\n # winning_comobo = won?(board) # Erica\n # if winning_combo.present? # Erica\n board[winning_combo.first] \n end\nend", "def perform\n @turn += 1\n if @turn%2 != 0\n slot = players[0].play(@board)\n else\n slot = players[1].play(@board)\n end\n @board.update_board(slot, @turn.even? ? 2 : 1)\n end", "def winner\n if winning_combo = won?\n @board[winning_combo.first]\n end\n end", "def computer_input!(board)\n defend = ai_defence_move(board)\n attack = ai_offensive_move(board)\n if board_full?(board)\n false\n elsif someone_win?(board)\n false\n else\n loop do\n if attack\n board[attack] = COMPUTER_MARKER\n break\n elsif defend\n board[defend] = COMPUTER_MARKER\n break\n else\n computer_input = rand(0..8)\n if board[computer_input] == INITIAL_MARKER\n board[computer_input] = COMPUTER_MARKER\n break\n end\n end\n end\n end\nend", "def winner(board)\n if winning_combo = won?(board)\n board[winning_combo.first]\n end\n\n # x_arr = board.each_index.select{|i| board[i] == 'X'}\n # o_arr = board.each_index.select{|i| board[i] == 'O'}\n # if won?(board) == nil\n # nil\n # elsif (won?(board)-x_arr).empty?\n # p \"X\"\n # elsif (won?(board)-o_arr).empty?\n # p \"O\"\n # end\nend", "def win_checker\n @board.flatten.max == 16_384\n end", "def board_value(s, rw)\n value = 0\n for i in 1..8\n for j in 1..8\n if s[[i, j]] == rw + 1\n # regular pieces worh 1 point\n value = value + 1\n elsif s[[i, j]] == rw + 2\n value = value - 1\n elsif s[[i, j]] == rw + 3\n # kings worth 2 points\n value = value + 2\n elsif s[[i, j]] == rw + 4\n value = value - 2\n end\n end\n end\n value \nend", "def winner\n if combo = won?\n winner = board.position(combo.first + 1)\n end\n winner\n end", "def successor_function(board, player)\n states = []\n actions = []\n 6.times do |row|\n 6.times do |col|\n if board[row][col] == 0\n #copy the board and set the indeces to the player's glyph\n copiedBoard = copy_board(board)\n copiedBoard[row][col] = player\n states.push(copiedBoard)\n actions.push([row, col])\n end\n end\n end\n return actions, states\n end", "def guessing_method\n smallest_num_of_possibilities = 9\n\n loop_board do |cell|\n smallest_num_of_possibilities = cell.possibilities.length if cell.possibilities.length < smallest_num_of_possibilities && cell.content.is_a?(Array)\n end\n\n loop_board do |cell|\n if cell.possibilities.length == smallest_num_of_possibilities\n cell.possibilities.each do |guess_value|\n\n guessing_board_copy = Marshal.load(Marshal.dump(self))\n guessing_board_copy.full_board[cell.tri_square_index][cell.square_index][cell.tri_cell_index][cell.cell_index].content = guess_value\n guessing_board_copy.full_board[cell.tri_square_index][cell.square_index][cell.tri_cell_index][cell.cell_index].possibilities = []\n\n if guessing_board_copy.solve!\n self.full_board = guessing_board_copy.full_board\n return guessing_board_copy\n end\n end\n return false\n end\n end\n end", "def move(board)\n if !board.taken?(\"5\")\n board = \"5\"\n elsif board.turn_count == 1\n board = \"1\"\n elsif board.turn_count == 2\n board = [\"3\", \"7\", \"9\"].detect do |position|\n !board.taken?(position)\n end\n elsif board.turn_count > 2 && board.turn_count < 6\n win_combo_array = []\n Game::WIN_COMBINATIONS.select do |win_combo|\n if ((board.position((win_combo[0] + 1).to_s) == opponent_token) && (board.position((win_combo[1] + 1).to_s) == opponent_token)) ||\n ((board.position((win_combo[1] + 1).to_s) == opponent_token) && (board.position((win_combo[2] + 1).to_s) == opponent_token)) ||\n ((board.position((win_combo[2] + 1).to_s) == opponent_token) && (board.position((win_combo[0] + 1).to_s) == opponent_token)) == true\n win_combo_array << win_combo\n end\n end\n number_at_index = win_combo_array[0].select do |number|\n position_number = (number + 1).to_s\n if board.position(position_number) != opponent_token\n position_number\n end\n end\n board = (number_at_index[0] + 1).to_s\n else\n win_combo_array = []\n Game::WIN_COMBINATIONS.select do |win_combo|\n if ((board.position((win_combo[0] + 1).to_s) == token) && (board.position((win_combo[1] + 1).to_s) == token)) ||\n ((board.position((win_combo[1] + 1).to_s) == token) && (board.position((win_combo[2] + 1).to_s) == token)) ||\n ((board.position((win_combo[2] + 1).to_s) == token) && (board.position((win_combo[0] + 1).to_s) == token)) == true\n win_combo_array << win_combo\n end\n end\n number_at_index = win_combo_array[0].select do |number|\n position_number = (number + 1).to_s\n if board.position(position_number) != opponent_token\n position_number\n end\n end\n board_n = (number_at_index[0] + 1).to_s\n board = final_moves(board, board_n)\n end\n end", "def player1_score\n player_hand.inject(0){|sum,n| sum + n.value }\n end", "def current_player(board)\n turns = turn_count(board)\n if turns.odd?\n return \"O\"\n else\n return \"X\"\n end\nend", "def current_player(board)\n turn_count(board)%2 == 0 ? \"X\" : \"O\"\nend", "def current_player(board)\n player = turn_count(board).even? ? \"X\" : \"O\"\nend", "def current_player(board)\n#takes #turn_count and checks if even, then(?) gives value of X, else(:) it is O\n turn_count(board) % 2 == 0 ? \"X\" : \"O\"\nend", "def current_player #player 1 goes first because 0 is even. so first turn is player 1, second is player 2, 3rd is player 1\n @board.turn_count.even? ? @player_1 : @player_2\n end", "def hard_computer(multiplayer, spaces, playerMoves, o_playerMoves, threeInRow)\n num = rand(9)\n\n if smart_comp(playerMoves, o_playerMoves, spaces, threeInRow) != nil\n num = smart_comp(playerMoves, o_playerMoves, spaces, threeInRow)\n else\n num = easy_computer(multiplayer, spaces)\n end\n num\nend", "def current_player(board)\n return turn_count(board)%2==0 ? \"X\" : \"O\"\nend", "def win_game(board)\n final_board = \" #{board[0]} | #{board[1]} | #{board[2]}\\n-----------\\n #{board[3]} | #{board[4]} | #{board[5]}\\n-----------\\n #{board[6]} | #{board[7]} | #{board[8]}\"\n if board[0] == board[1] && board[1] == board[2]\n puts final_board\n puts \"CONGRATULATIONS #{board[0]} WINS\"\n exit\n elsif board[3] == board[4] && board[4] == board[5]\n puts final_board\n puts \"CONGRATULATIONS #{board[3]} WINS\"\n exit\n elsif board[6] == board[7] && board[7] == board[8]\n puts final_board\n puts \"CONGRATULATIONS #{board[6]} WINS\"\n exit \n elsif board[0] == board[3] && board[3] == board[6]\n puts final_board\n puts \"CONGRATULATIONS #{board[0]} WINS\"\n exit \n elsif board[1] == board[4] && board[4] == board[7]\n puts final_board\n puts \"CONGRATULATIONS #{board[1]} WINS\"\n exit \n elsif board[2] == board[5] && board[5] == board[8]\n puts final_board\n puts \"CONGRATULATIONS #{board[2]} WINS\"\n exit\n elsif board[0] == board[4] && board[4] == board[8]\n puts final_board\n puts \"CONGRATULATIONS #{board[0]} WINS\"\n exit\n elsif board[0] == board[4] && board[4] == board[8]\n puts final_board\n puts \"CONGRATULATIONS #{board[0]} WINS\"\n exit\n elsif board[2] == board[4] && board[4] == board[6]\n puts final_board\n puts \"CONGRATULATIONS #{board[2]} WINS\"\n exit \n end\nend", "def completion(board,width,height,count,finished_game_counter,current_score)\n \n #define individual counters for each colour\n counter_red = 0\n counter_green = 0\n counter_blue = 0\n counter_yellow = 0\n counter_magenta = 0\n counter_cyan = 0\n \n #iterate through array and add 1 to the counter of the colour\n board.each do |row|\n row.each do |column| \n if column == :red\n counter_red += 1\n elsif column == :green\n counter_green += 1\n elsif column == :blue\n counter_blue += 1\n elsif column == :yellow\n counter_yellow += 1\n elsif column == :magenta\n counter_magenta += 1\n elsif column == :cyan\n counter_cyan += 1\n end \n end\n end\n \n #calculates the percentage of the game completed depending on which colour is in the top left element\n if board[0][0] == :red\n percentage = (counter_red*100)/(width*height)\n elsif board[0][0] == :green\n percentage = (counter_green*100)/(width*height)\n elsif board[0][0] == :blue\n percentage = (counter_blue*100)/(width*height)\n elsif board[0][0] == :yellow\n percentage = (counter_yellow*100)/(width*height)\n elsif board[0][0] == :magenta\n percentage = (counter_magenta*100)/(width*height)\n elsif board[0][0] == :cyan\n percentage = (counter_cyan*100)/(width*height)\n end\n puts \"#{percentage}%\"\n \n #the if statement below lets the program know if the user has finished a game yet or not\n if percentage == 100\n finished_game_counter += 1\n if finished_game_counter == 1\n current_score = count\n high_score(current_score,finished_game_counter)\n \n #if the user has finished more than 1 game, then the program will compare its previous score with \n #its current score.\n elsif finished_game_counter > 1\n if count < current_score\n current_score = count\n high_score(current_score,finished_game_counter)\n end\n end\n congratulation(percentage,count,current_score,finished_game_counter,width,height)\n end\nend", "def board_full?\n @board.flatten.all?\n @turn == 9 \n end", "def current_player(board)\n if turn_count(board) % 2 == 0\n return \"X\" #even turn count == X\n end \n return \"O\" #odd turn count == O \nend", "def game_over \n # all the grid's cells are full and different numbers \n end", "def try_turn\n raise \"Turn has already been finalized on original board\" if @finalized\n new_board = @original_board.dup\n apply_turn(new_board)\n new_board\n end", "def evaluate_result\n winning_patterns_index.each do |pattern|\n self.winner = current_player if pattern.all? { |index| available_moves[index] == current_player.symbol }\n end\n end", "def defend_against_opponent(board)\n\t\tcell_found = nil\n\t\tWIN_COMBINATIONS.each do |combo|\n\t\t\thash = Hash.new\n\t\t\thash[combo[0]] = board.cells[combo[0]]\n\t\t\thash[combo[1]] = board.cells[combo[1]]\n\t\t\thash[combo[2]] = board.cells[combo[2]]\n\t\t\tif(hash.values.count(\"X\") == 2 && hash.values.include?(\" \"))\n\t\t\t\tcell_found = hash.key(\" \")+1\n\t\t\tend\n\t\tend\n\t\tcell_found\n\tend", "def current_player(board)\n if turn_count(board).even?\n current_player = \"X\"\n else\n current_player = \"O\"\n end\nend", "def block(board)\n\t\tPOSSIBLE_WINS.each do |win|\n\t\t\tmarks = board.each_index.select { |i| board[i] == opponent_symbol(@symbol).to_s }\n\t\t\tmatches = win & marks\n\t\t\tif matches.size == 2\n\t\t\t\tmissing = win - matches\n\t\t\t\tmissing = missing[0]\n\t\t\t\treturn missing unless board[missing] != \" \"\n\t\t\tend\n\t\tend\n\t\treturn false\n\tend", "def offensive_row_for_ai(board)\n offensive_play = {}\n WINNING_COMBINATIONS.each { |offense| offensive_play[offense] = 0 }\n WINNING_COMBINATIONS.each do |offense|\n offense.each do |is_x|\n offensive_play[offense] += 1 if board[is_x] == COMPUTER_MARKER\n if board[is_x] == PLAYER_MARKER\n offensive_play[offense] = 0\n break\n end\n end\n end\n offensive_play\nend", "def won?(board)\nwin_combination = WIN_COMBINATIONS\n\n win_index_1 = win_combination[0]\n win_index_2 = win_combination[1]\n win_index_3 = win_combination[2]\n win_index_4 = win_combination[3]\n win_index_5 = win_combination[4]\n win_index_6 = win_combination[5]\n win_index_7 = win_combination[6]\n win_index_8 = win_combination[7]\n\n position_1 = board[0] # load the value of the board at win_index_1\n position_2 = board[1] # load the value of the board at win_index_2\n position_3 = board[2] # load the value of the board at win_index_3\n position_4 = board[3] # load the value of the board at win_index_4\n position_5 = board[4] # load the value of the board at win_index_5\n position_6 = board[5] # load the value of the board at win_index_6\n position_7 = board[6] # load the value of the board at win_index_7\n position_8 = board[7] # load the value of the board at win_index_8\n position_9 = board[8] # load the value of the board at win_index_9\n\n if position_1 == \"X\" && position_2 == \"X\" && position_3 == \"X\"\n return win_combination[0] # return the win_combination indexes that won.\n elsif position_4 == \"X\" && position_5 == \"X\" && position_6 == \"X\"\n return win_combination[1] # return the win_combination indexes that won.\n elsif position_7 == \"X\" && position_8 == \"X\" && position_9 == \"X\"\n return win_combination[2] # return the win_combination indexes that won.\n elsif position_1 == \"X\" && position_4 == \"X\" && position_7 == \"X\"\n return win_combination[3] # return the win_combination indexes that won.\n elsif position_2 == \"X\" && position_5 == \"X\" && position_8 == \"X\"\n return win_combination[4] # return the win_combination indexes that won.\n elsif position_3 == \"X\" && position_6 == \"X\" && position_9 == \"X\"\n return win_combination[5] # return the win_combination indexes that won.\n elsif position_7 == \"X\" && position_5 == \"X\" && position_3 == \"X\"\n return win_combination[6] # return the win_combination indexes that won.\n elsif position_1 == \"X\" && position_5 == \"X\" && position_9 == \"X\"\n return win_combination[7] # return the win_combination indexes that won.\n \n elsif position_1 == \"O\" && position_2 == \"O\" && position_3 == \"O\"\n return win_combination[0] # return the win_combination indexes that won.\n elsif position_4 == \"O\" && position_5 == \"O\" && position_6 == \"O\"\n return win_combination[1] # return the win_combination indexes that won.\n elsif position_7 == \"O\" && position_8 == \"O\" && position_9 == \"O\"\n return win_combination[2] # return the win_combination indexes that won.\n elsif position_1 == \"O\" && position_4 == \"O\" && position_7 == \"O\"\n return win_combination[3] # return the win_combination indexes that won.\n elsif position_2 == \"O\" && position_5 == \"O\" && position_8 == \"O\"\n return win_combination[4] # return the win_combination indexes that won.\n elsif position_3 == \"O\" && position_6 == \"O\" && position_9 == \"O\"\n return win_combination[5] # return the win_combination indexes that won.\n elsif position_7 == \"O\" && position_5 == \"O\" && position_3 == \"O\"\n return win_combination[6] # return the win_combination indexes that won.\n elsif position_1 == \"O\" && position_5 == \"O\" && position_9 == \"O\"\n return win_combination[7] # return the win_combination indexes that won.\n else\n false\n end\nend", "def current_player(board)\n next_turn = turn_count(board)\n if next_turn % 2 == 0 \n return 'X'\n else \n return 'O'\n end\nend", "def current_player(board)\n if turn_count(board).odd?\n \"O\"\n else\n \"X\"\n end\nend", "def current_player(board)\n turn_count(board).odd? ? \"O\" : \"X\"\nend", "def current_player(board)\n turn_count(board).odd? ? \"O\" : \"X\"\nend", "def evaluate(game)\n\t\t\tsum_of_tiles = game.board.inject(0) { |sum, tile| sum + tile.val} \n\t\t\tempty_tiles_factor = (game.board.select{|t| t.empty?}.count * 15) \n\t\t\tmax_tile = game.board.max_by { |tile| tile.val}.val\n\t\t\thighest_tile_factor = max_tile * max_tile \n\t\t\tsum_of_tiles + empty_tiles_factor + highest_tile_factor\n\t\tend", "def possible_moves \n row = @current_row\n column = @current_column\n values = Hash.new \n if (row + 1) <= @matrix.length \n values[@matrix[row + 1][column]] = [(row + 1),column]\n end \n if (row - 1) >= 0\n values[@matrix[row - 1][column]] = [(row - 1),column]\n end \n if (column + 1) <= @matrix[0].length \n values[@matrix[row][column + 1]] = [row,(column + 1)]\n end\n if (column - 1) >= 0 \n values[@matrix[row][column - 1]] = [row,(column - 1)]\n end \n highest_value_square(values)\nend", "def won?(board)\n WIN_COMBINATIONS.each do |triple|\n if(winning?(board, triple))\n return triple\n end\n end\n return false\nend", "def won?(board)\n WIN_COMBINATIONS.each do |triple|\n if(winning?(board, triple))\n return triple\n end\n end\n return false\nend", "def check_full_board\n if @board.include? \"\"\n puts \"back to player switch\"\n else\n check_for_winner\n end\n end", "def current_player\n @board.turn_count.even? ? @player_1 : @player_2\n\n end", "def move(board)\n\t\tmove = 0 # Variable to hold the Computer player's selected move\n\t\tposition = 0\n\t\tplace = 0\n\t\tedge = 0\n\t\tcorner = 0\n\t\tcomputer_move = [] # Array to hold the moves available to the current Computer player\n\t\tvalid_moves = [\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\"] # Defines allowed moves in a Tic Tac Toe game\n\t\t# Bring in some artificial intelligence\n\t\tposition = ai_block_win(board)\n\t\tplace = ai_best_moves(board)\n\t\tedge = ai_strategy_edges(board)\n\t\tcorner = ai_strategy_corners(board)\n\t\t# End artificial intelligence\n\t\tvalid_moves.each_with_index do |a,i| # Checks which of its valid moves are available to the Computer player\n\t\t\tif board.valid_move?(a)\n\t\t\t\tcomputer_move << ((i + 1).to_s) # If the move is valid add it to the available moves array\n\t\t\tend\n\t\tend\n\t\tif position != nil && !position.empty? && board.valid_move?(position[0][0]) # If move is valid and not nil or empty move takes position\n\t\t\tmove = position[0]\n\t\telsif edge != nil # If move returned by edge exists\n\t\t\tmove = edge\n\t\telsif corner != nil # If move returned by corner exists\n\t\t\tmove = corner\n\t\telsif place != nil # If move returned by place exists\n\t\t\tmove = place\n\t\telse\n\t\t\tmove = computer_move.sample # Take a random move from the available moves array if no other moves valid\n\t\tend\n\t\tmove # Return the move to be made to #game\n\tend", "def evaluate_game(game_board)\n game_finished = false\n for i in 0..5\n \n if game_finished == true\n break\n end\n \n #Vertical and Horizontal evaluation to see if 4 are connected\n for j in 0..3\n if (game_board[i+1][j] == game_board[i+1][j+1]) && (game_board[i+1][j]==game_board[i+1][j+2]) && (game_board[i+1][j]==game_board[i+1][j+3])&&(game_board[i+1][j]==\"X\"||game_board[i+1][j]==\"O\") #rows\n puts \"User \" + game_board[i+1][j].to_s + \" wins\"\n game_finished = true\n break\n end\n end\n \n end\n \n for i in 0..6\n for j in 0..2 #columns\n if (game_board[j+1][i] == game_board[j+2][i]) && (game_board[j+1][i] == game_board[j+3][i])&&(game_board[j+1][i] == game_board[j+4][i])&&((game_board[j+1][i] == \"X\")||(game_board[j+1][i] == \"O\")) #columns\n puts \"User \" + game_board[j+1][i].to_s + \" wins\"\n game_finished = true\n break\n end\n end\n end\n \n #Evaluate if Diagonals have 4 connected\n for i in 1..6 #rows\n \n if game_finished == true\n break\n end\n \n for j in 0..6 #columns\n \n \n if (j<=3) #if it has 4 spaces to the right\n if (i>=4)#if it has 4 spaces up\n if(game_board[i][j]==game_board[i-1][j+1])&&(game_board[i][j]==game_board[i-2][j+2])&&(game_board[i][j]==game_board[i-3][j+3])&&((game_board[i][j] == \"X\")||(game_board[i][j] == \"O\"))\n puts \"User \" + game_board[i][j].to_s + \" wins\"\n game_finished = true\n break\n end\n end\n if (i<=3)#if it has 4 spaces down\n #Evalaution\n if(game_board[i][j]==game_board[i+1][j+1])&&(game_board[i][j]==game_board[i+2][j+2])&&(game_board[i][j]==game_board[i+3][j+3])&&((game_board[i][j] == \"X\")||(game_board[i][j] == \"O\"))\n puts \"User \" + game_board[i][j].to_s + \" wins\"\n game_finished = true\n break\n end\n end\n \n end\n \n \n if (j>3) #if it has 4 spaces to the left\n if (i>=4)#if it has 4 spaces up\n if(game_board[i][j]==game_board[i-1][j-1])&&(game_board[i][j]==game_board[i-2][j-2])&&(game_board[i][j]==game_board[i-3][j-3])&&((game_board[i][j] == \"X\")||(game_board[i][j] == \"O\"))\n puts \"User \" + game_board[i][j].to_s + \" wins\"\n game_finished = true\n break\n end\n end\n \n if (i<4) #if it has 4 spaces down\n #puts(\"Llega a segundo if<4\")\n if(game_board[i][j]==game_board[i+1][j-1])&&(game_board[i][j]==game_board[i+2][j-2])&&(game_board[i][j]==game_board[i+3][j-3])&&((game_board[i][j] == \"X\")||(game_board[i][j] == \"O\"))\n puts \"User \" + game_board[i][j].to_s + \" wins\"\n game_finished = true\n break\n end\n end\n \n end\n \n end\n end\n \n return game_finished\n \nend", "def current_player(board)\n \n num_turns = turn_count(board)\n \n if num_turns % 2 == 0\n return \"X\"\n else\n return \"O\"\n end\n\nend", "def evaluate(game)\n\t\t\tsum_of_tiles = game.board.inject(0) { |sum, tile| sum + tile.val} \n\t\t\tempty_tiles_factor = (game.board.select{|t| t.empty?}.count * 15) \n\t\t\tmax_tile = game.board.max_by { |tile| tile.val}.val\n\t\t\thighest_tile_factor = max_tile * max_tile * max_tile * max_tile\n\t\t\tsum_of_tiles + empty_tiles_factor + highest_tile_factor\n\t\tend", "def board(computers_cards_value, players_cards_value, players_cards, computers_cards, players_cards_two, players_cards_two_value)\n system 'clear'\n linewidth = 100\n #add the cards\n puts (('BlackJack').ljust(linewidth / 3)) + (('Computers Cards').center(linewidth / 3)) + (('Computers Cards Value = '+computers_cards_value.to_s+'').rjust(linewidth / 3))\n print ('').center(linewidth / 3)\n cards_print(computers_cards)\n print \"Hidden Card\"\n puts ''\n puts ''\n puts ''\n if players_cards_two_value >0\n puts (('').ljust(linewidth / 3)) + (('Players Double Down Cards').center(linewidth / 3)) + (('Players Cards Value = '+players_cards_two_value.to_s+'').rjust(linewidth / 3)) \n print ('').center(linewidth / 3)\n cards_print(players_cards_two)\n end\n print ('').center(linewidth / 3)\n cards_print(players_cards)\n puts '' \n puts (('').ljust(linewidth / 3)) + (('Players Cards').center(linewidth / 3)) + (('Players Cards Value = '+players_cards_value.to_s+'').rjust(linewidth / 3)) \n end", "def compute_state # {{{\n\n player_moves = []\n ki_moves = []\n\n player_moves = self.get_moves_as_hash true\n ki_moves = self.get_moves_as_hash false\n\n return WON if has_winning_combination player_moves\n return LOST if has_winning_combination ki_moves\n\n return DRAWN if player_moves.count + ki_moves.count == 3*3\n\n RUNNING\n end", "def current_player(board)\n return (turn_count(board).even? ? \"X\" : \"O\")\nend", "def get_moves(piece, board)\n valid_col = case piece.name\n when ?A then 3\n when ?B then 5\n when ?C then 7\n when ?D then 9\n else 11\n end\n moves = []\n\n # If in hallway\n if piece.row == 1\n cols = valid_col < piece.col ? (valid_col...piece.col).to_a : (piece.col+1..valid_col).to_a\n if cols.count{|c| board[[1, c]] == ?.} == cols.length\n if board[[2, valid_col]] == ?.\n if board[[3, valid_col]] == ?.\n moves << [[3, valid_col], (cols.count + 2) * piece.cost]\n elsif board[[3, valid_col]] == piece.name\n moves << [[2, valid_col], (cols.count + 1) * piece.cost]\n end\n end\n end\n # If not in its column (can never stand in hallway anf column at same time)\n elsif (piece.col == valid_col && piece.row == 2 && board[[piece.row + 1, piece.col]] != piece.name) || (piece.col != valid_col && piece.row == 2)\n 2.times do |t|\n dir = t == 0 ? -1 : 1\n curr = piece.col\n steps = 1\n while board[[1, curr]] == ?.\n moves << [[1, curr], steps * piece.cost] if ![3, 5, 7, 9].include?(curr)\n steps += 1\n curr += dir\n end\n end\n elsif piece.row == 3 && piece.col != valid_col && board[[2, piece.col]] == ?.\n 2.times do |t|\n dir = t == 0 ? -1 : 1\n curr = piece.col\n steps = 2\n while board[[1, curr]] == ?.\n moves << [[1, curr], steps * piece.cost] if ![3, 5, 7, 9].include?(curr)\n steps += 1\n curr += dir\n end\n end\n end\n moves\nend", "def getPlayTotal()\n\ttotal = 0\n\ti = 0\n\twhile i < $playerCards.length\n\t\tx = $playerCards.at(i)\n\t\tif x == 1\n\t\t\t$playerSoft = true\n\t\tend\t\n\t\ttotal = total + x\n\t\ti += 1\n\tend\n\treturn total\nend", "def determine_players_best_total(current_player)\n # @player1_hand = ['ace of spades', '5 of spades', '4 of spades', 'ace of diamonds']\n # @player1_hand = ['3 of spades', 'ace of hearts', '4 of spades', 'ace of clubs']\n # @player1_hand = ['ace of clubs', '2 of clubs', 'ace of hearts', '4 of hearts']\n sum_of_players_hand = 0\n number_of_aces_in_hand = 0\n if current_player == 1 then\n @player1_hand.each {|x| #begin loop adding players hand\n card_value = @deckhash.fetch(x)\n if card_value == 1 then #adjust aces to a value of 11\n card_value = 11\n number_of_aces_in_hand = number_of_aces_in_hand + 1\n end #end of ace adjustment\n sum_of_players_hand = sum_of_players_hand + card_value\n } #end of loop adding players hand\n\n if sum_of_players_hand > 21 then #must set one or more aces back to one\n loop do\n if number_of_aces_in_hand == 0 then break end\n\n sum_of_players_hand = sum_of_players_hand - 10\n\n if sum_of_players_hand < 22 then break end\n number_of_aces_in_hand = number_of_aces_in_hand - 1\n end #end of loop do\n end #end of sum_of_players_hand > 21\n end #end if current player = 1\n\n if current_player == 2 then\n @player2_hand.each {|x| #begin loop adding players hand\n card_value = @deckhash.fetch(x)\n if card_value == 1 then #adjust aces to a value of 11\n card_value = 11\n number_of_aces_in_hand = number_of_aces_in_hand + 1\n end #end of ace adjustment\n sum_of_players_hand = sum_of_players_hand + card_value\n } #end of loop adding players hand\n if sum_of_players_hand > 21 then #must set one or more aces back to one\n loop do\n if number_of_aces_in_hand == 0 then break end\n sum_of_players_hand = sum_of_players_hand - 10\n $stdout.write(\"sum of players hand #{sum_of_players_hand} :\")\n if sum_of_players_hand < 22 then break end\n number_of_aces_in_hand = number_of_aces_in_hand - 1\n end #end of loop do\n end #end of sum_of_players_hand > 21\n end #end if current player = 2\n\n if current_player == 3 then\n @player3_hand.each {|x| #begin loop adding players hand\n card_value = @deckhash.fetch(x)\n if card_value == 1 then #adjust aces to a value of 11\n card_value = 11\n number_of_aces_in_hand = number_of_aces_in_hand + 1\n end #end of ace adjustment\n sum_of_players_hand = sum_of_players_hand + card_value\n } #end of loop adding players hand\n if sum_of_players_hand > 21 then #must set one or more aces back to one\n loop do\n if number_of_aces_in_hand == 0 then break end\n sum_of_players_hand = sum_of_players_hand - 10\n# $stdout.write(\"sum of players hand #{sum_of_players_hand} :\")\n if sum_of_players_hand < 22 then break end\n number_of_aces_in_hand = number_of_aces_in_hand - 1\n end #end of loop do\n end #end of sum_of_players_hand > 21\n end #end if current player = 3\n\n if current_player == 4 then\n @player4_hand.each {|x| #begin loop adding players hand\n card_value = @deckhash.fetch(x)\n if card_value == 1 then #adjust aces to a value of 11\n card_value = 11\n number_of_aces_in_hand = number_of_aces_in_hand + 1\n end #end of ace adjustment\n sum_of_players_hand = sum_of_players_hand + card_value\n } #end of loop adding players hand\n if sum_of_players_hand > 21 then #must set one or more aces back to one\n loop do\n if number_of_aces_in_hand == 0 then break end\n sum_of_players_hand = sum_of_players_hand - 10\n# $stdout.write(\"sum of players hand #{sum_of_players_hand} :\")\n if sum_of_players_hand < 22 then break end\n number_of_aces_in_hand = number_of_aces_in_hand - 1\n end #end of loop do\n end #end of sum_of_players_hand > 21\n end #end if current player = 4\n # ### This method returns sum of player's best hand\n return sum_of_players_hand\n end" ]
[ "0.71388805", "0.6633895", "0.65473354", "0.64825106", "0.6421695", "0.64081186", "0.63770586", "0.6359299", "0.63577694", "0.6350082", "0.6343247", "0.62910604", "0.6290867", "0.62817544", "0.6257944", "0.62224907", "0.6220637", "0.6218962", "0.62176746", "0.62169486", "0.6213324", "0.6206368", "0.61838084", "0.61723715", "0.6171329", "0.6170996", "0.6170996", "0.616167", "0.6156422", "0.61553097", "0.61527264", "0.61499685", "0.61469597", "0.61417174", "0.6136437", "0.6134275", "0.6134275", "0.6134275", "0.6134275", "0.6134275", "0.6134275", "0.6134275", "0.6134275", "0.6134275", "0.6134275", "0.6123206", "0.61189884", "0.6108642", "0.6108642", "0.61056745", "0.6105649", "0.6101829", "0.610033", "0.60991645", "0.60937446", "0.60918707", "0.60914433", "0.6091411", "0.6090877", "0.60902077", "0.6084344", "0.60842186", "0.6082946", "0.60820955", "0.60809726", "0.60790855", "0.607719", "0.60736865", "0.6069954", "0.6066857", "0.6062197", "0.60619867", "0.6060078", "0.6060003", "0.605643", "0.60501754", "0.6049764", "0.6048266", "0.6035024", "0.6029421", "0.60290456", "0.6027568", "0.60250455", "0.6021422", "0.6021422", "0.6021279", "0.6018625", "0.601559", "0.601559", "0.60143477", "0.60140014", "0.60118574", "0.6011445", "0.60097414", "0.6008913", "0.6008544", "0.6004081", "0.6001523", "0.5996939", "0.5994901", "0.5990729" ]
0.0
-1
Plays according to what the player have learned
def play(tateti) best_value = nil best_play = nil tateti.empty_cells.each do |possible_play| row = possible_play[0] col = possible_play[1] current_value = @play_matrix[row][col] if best_value.nil? || current_value > best_value best_value = current_value best_play = possible_play end end tateti.play(best_play[0], best_play[1], signature) return tateti end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def play\n @played = knows_legals? ? random_play : most_likely_play\n end", "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 play\n display_welcome_message\n loop do \n human.choose #.choose is an instance method on the Player class, since human is an object of the Player class\n computer.choose\n display_winner\n break unless play_again? #could put play again loop here, but easier to not have double loop here\n end \n display_goodbye_message\n end", "def play\n display_welcome_message\n loop do\n human.choose\n computer.choose\n display_moves\n display_winner\n keep_score\n break unless play_again?\n end\n display_goodbye_message\n end", "def play\n state = 0\n\n\n while true\n if state == 0\n puts \"C'est à #{@player0.name} de jouer (jeton #{@player0.token})\"\n puts \"Quelle case veux tu cocher #{@player0.name} ?\"\n print \"> \"\n n = gets.chomp.upcase\n\n until not_played?(n) && case_authorization?(n)\n print \"> \"\n n = gets.chomp.upcase\n end\n @played_cases << n\n @view.play(\"player0\",n)\n\n if @view.iswin?(@player0.token)\n puts \"#{@player0.name} a gagné.\"\n puts \"FÉLICITATIONS #{@player0.name}! \"\n puts \" \"\n @player0.score += 1\n break\n elsif isfull?\n puts \"Match nul ! \"\n puts \" \"\n break\n else\n state = 1 - state\n end\n else\n puts \"C'est à #{@player1.name} de jouer (jeton #{@player1.token})\"\n puts \"Quelle case veux tu cocher #{@player1.name} ?\"\n print \"> \"\n n = gets.chomp.upcase\n\n until not_played?(n) && case_authorization?(n)\n print \"> \"\n n = gets.chomp.upcase\n end\n\n @played_cases << n\n @view.play(\"player1\",n)\n\n if @view.iswin?(@player1.token)\n puts \"#{@player1.name} a gagné.\"\n puts \"FÉLICITATIONS #{@player1.name}! \"\n puts \" \"\n @player1.score += 1\n break\n elsif isfull?\n puts \"Match nul ! \"\n puts \" \"\n break\n else\n state = 1 - state\n end\n end\n end\n end", "def play\n game_introductions\n\n loop do\n set_markers_and_first_mover\n\n loop do\n clear_screen_and_display_board\n loop_of_player_moves\n display_result\n break if someone_won_match?\n display_play_again_message\n reset\n end\n\n clear\n display_champion\n break unless rematch?\n reset_game_data\n end\n\n display_goodbye_message\n end", "def play\n take_turn until @master.game_over?\n @master.show_board\n @robot.speak\n end", "def play\n while(true)\n answer1 = @human.choose\n answer2 = @computer.choose\n puts self.win?(answer1,answer2)\n self.continue?\n end\n end", "def play; end", "def play\n \n end", "def play \n end", "def play\n #calls to all the methods that produce game!\n end", "def play\n @@plays += 1\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 \n begin\n \n @computer_choice = get_computer_choice()\n @player_choice = get_player_choice()\n \n result = logic(@computer_choice, @player_choice)\n\n get_choices()\n \n case result\n\n when \"tie\"\n @rounds -= 1\n @ties += 1\n puts \"[~] it's a tie !\"\n \n when \"player win\"\n @rounds -= 1\n @player_wins += 1\n puts \"[$] Player win this round (#{@player_wins}/3)!\"\n\n when \"computer win\"\n @rounds -= 1\n @computer_wins += 1\n puts \"[$] Computer win this round (#{@computer_wins}/3)!\"\n\n end\n\n rescue Interrupt\n\n puts \"\\n\\n[!] Keyboard interrupt, Exting.\"; exit()\n \n \n end\n \n\n end", "def play\n# \tThere are 3 players in Knuckleheads: \n\t\tputs \"There are #{to_s} players in #{@title}\"\n# \tI'm Moe with a health of 100 and a score of 103.\n# \tI'm Larry with a health of 60 and a score of 65.\n# \tI'm Curly with a health of 125 and a score of 130.\n\t\[email protected] do |spieler|\n\t\t\tputs \"I'm #{spieler} with a health of #{@health} and a score of #{score}\"\n\t\t\tend\n# \tMoe got blammed!\n# \tMoe got w00ted!\n# \tMoe got w00ted!\n# \tI'm Moe with a health of 120 and a score of 123.\n# \tLarry got blammed!\n# \tLarry got w00ted!\n# \tLarry got w00ted!\n# \tI'm Larry with a health of 80 and a score of 85.\n# \tCurly got blammed!\n# \tCurly got w00ted!\n# \tCurly got w00ted!\n# \tI'm Curly with a health of 145 and a score of 150.\n\t\tend", "def play\n\tend", "def play_hand\n\n p1 = self.player1\n p2 = self.player2\n p1.play\n p2.play\n winner = winner?(p1,p2)\n if winner\n handle_winner(p1,p2)\n else \n self.war\n end\n\n end", "def keep_playing\n until @player_1_score == @player_victory or @player_2_score == @player_victory \n set_weapon_p1(choose_weapons)\n set_weapon_p2(choose_weapons)\n display_winner_one_game(determine_winner_one_game)\n accumulate_series_score(determine_winner_one_game)\n display_scoreboard\n end\n end", "def play\n\t\t\twhile !win && @turns < TURNS\n\t\t\t\tturn\n\t\t\tend\n\t\t\t# counter increments at start of turn, so must be less than max turns\n\t\t\tif win\n\t\t\t\tplay_again\n\t\t\telse\n\t\t\t\tputs \"\\n Sorry, you ran out of turns. The word was #{@secret_word}\"\n\t\t\t\tplay_again\n\t\t\tend\n\t\tend", "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 play\n @play_array = [\"rock\", \"paper\", \"scissors\"]\n @play_array.sample\n end", "def played\n won + drawn + lost + noresult\n end", "def play\n\t\tgame_loop\n\tend", "def play\n\t\twelcome\n\t\task_name\n\t\task_name2 \n\t\task_input\n\t\tturns\n\tend", "def play\n\n until over?\n turn\n end\n\n if self.won?\n puts \"Congratulations #{self.winner}!\"\n elsif self.draw?\n puts \"Cat's Game!\"\n end\n\n end", "def play \n game_loop\n if @player1.score >= @num_of_games\n puts \"#{@player1.name} is the WINNER!\"\n elsif @player2.score >= @num_of_games\n puts \"#{@player2.name} is the WINNER!\"\n end\n end", "def play\n until @board.winner?(@player_1.token) || @board.winner?(@player_2.token)\n @board.print\n self.play_turn\n p \"--------------------\"\n end\n\n self.switch_players!\n @board.print\n p @current_player.token + \" has won!\"\n end", "def play\n until @board.winner?(@player_1.token) || @board.winner?(@player_2.token)\n @board.print\n self.play_turn\n p \"--------------------\"\n end\n\n self.switch_players!\n @board.print\n p @current_player.token + \" has won!\"\n end", "def play\n\t\tloop do\n\t\t\tgetBets\n\t\t\tdealInitialCards\n\t\t\tmakeMoves\n\t\t\tif not @playing\n\t\t\t\tbreak\n\t\t\tend\n\t\t\tdealerScore = @players[DEALER_INDEX].value\n\t\t\tcollectBets(dealerScore)\n\t\tend\n\t\[email protected] \"Thank you for playing.\"\n\tend", "def play\n @players.each do |p|\n @events.handle(:player_play, p) do\n p.hands.each {|hand| play_hand(p, hand) }\n\n p.hands.reject! {|hand| hand.invalid }\n end\n end\n\n # Dealer plays his hand last.\n @events.handle(:dealer_play, @dealer) do\n dealer_play_hand\n end\n end", "def play!\n print_welcome()\n\n until @win || @lose\n print_current_status()\n letter_or_word = ask_player_letter_or_word()\n\n case letter_or_word\n when \"L\"\n letter_guess()\n when \"W\"\n word_guess()\n else\n puts \"There is an error in the program\"\n end\n\n if @lose == true\n print_lose\n elsif @win == true\n print_win\n end\n end\n end", "def play\n bang = player.from_hand(Card.bang_card)\n if bang\n left_player = player.players.first\n if left_player && left_player.distance_to <= 1\n player.play_card(bang, left_player)\n end\n end\n end", "def play\n reset\n loop do\n break if @guesses == 0 || @win == true\n status_message\n enter_number\n evaluation_message\n end\n lose_message if @guesses == 0 && @win == false\n end", "def play_round\n take_turn\n puts \"Current word: #{@fragment}\"\n if losses(current_player) == true\n record(current_player)\n score_board\n end\n next_player!\n end", "def play\n display_welcome_message\n loop do\n number_of_games = 0\n loop do\n computer.choose(@human)\n human.choose\n display_moves\n increment_game_count\n puts\n display_winner\n display_score\n update_win_history\n number_of_games += 1\n puts\n break if first_to_score?(10)\n end\n display_final_outcome\n reset_game\n break unless play_again?\n end\n display_goodbye_message\n end", "def play_the_game\n self.deal\n while player1.count && player2.count\n self.play_hand\n end\n\n p player1.packet\n p player2.packet\n\n end", "def play\n 2.times {deal}\n blind_score\n if player_hand.collect{|x| x.value}.inject(:+) == 21\n bjwin\n elsif computer_hand.collect{|x| x.value}.inject(:+) == 21\n bjlose\n else\n action\n end\n end", "def play\n #self.set_players # Only uncomment one of these two lines.\n self.set_computer_players # Uncomment this line to have two computer players\n until @board.winner?\n self.turn\n self.change_current_player\n end\n winner = (@current_player == @player1) ? @player2 : @player1\n puts \" #{winner.color.to_s.upcase} is the winner!!!!\"\n puts \"Thanks for playing.\"\n end", "def play\n turn until over?\n if won?\n puts \"Congratulations #{winner}!\"\n else\n puts \"Cats Game!\"\n end\n end", "def next_player!\n end", "def play\r\n while !over?\r\n turn\r\n end\r\n if won?\r\n puts \"Congratulations #{winner}!\"\r\n elsif draw?\r\n puts \"Cats Game!\"\r\n end\r\n end", "def play\n case [@player1,@player2].join(';')\n when 'rock;paper' then puts 'Gracz 2 wygrał'\n when 'rock;scissors' then puts 'Gracz 1 wygrał'\n when 'scissors;rock' then puts 'Gracz 2 wygrał'\n when 'scissors;paper' then puts 'Gracz 1 wygrał'\n when 'paper;scissors' then puts 'Gracz 2 wygrał'\n when 'paper;rock' then puts 'Gracz 1 wygrał'\n when 'paper;paper' then puts 'Remis'\n when 'rock;rock' then puts 'Remis'\n when 'scissors;scissors' then puts 'Remis'\n else\n puts 'Błędne informacje'\n end\n end", "def play\n\n\t\tif ran_out_of_options?\n \t\t\tputs \"SORRY, YOU ARE HOPELESSLY INDECISIVE\".red.blink\n \t\t\texit\n \tend\n\n\t\t@winner = select_winner\n\n\t until self.set_of_ten_dup.length == 1 do\n\t \t@challenger = select_challenger\n\t \n\t system \"clear\"\n\n\t\tCLI.intro_image\n\t\tdisplay_choices\n\t\tinput = input_prompt\n\t \n\t\tmatch_arr = add_businesses\n\n\t\tadd_to_winner_loser_tables(match_arr[0],match_arr[1]) if input == '1' || input == '1!'\n\t\tadd_to_winner_loser_tables(match_arr[1],match_arr[0]) if input == '2' || input == '2!'\n\t\tremove_from_match_options(input)\n\t\t@winner = @challenger if input == '2' || input == '2!'\n\t\tself.url = @winner[:url]\n\t\tbreak if input == '1!' || input == '2!'\n\t end\n\t puts \"We recommend you go to \" + \"#{@winner[:name]}\".green + \"!\" \n end", "def play\n synchronize do\n @starved = false\n @source.play\n end\n end", "def play_until_victory \n\tuntil victory == true \n\t\t first_player_plays\n\t\t second_player_plays\n\tend\n end", "def play\n until self.over? do\n turn\n end\n\n if self.won?\n puts \"Congratulations #{self.winner}!\"\n elsif self.draw?\n puts \"Cat's Game!\"\n end\n end", "def start\n \t\tself.board.display_instruction\n \t\tcurrent_player = select_first_player\n \t\t(self.board.size).times do \n \t\t\tplay(current_player)\n \t\t\tcurrent_player = next_of current_player \n end\n display_winner(nil, true)\n \tend", "def play\n @last_card_played = @my_hand.pick_random\n set_last_card_played @last_card_played\n end", "def play\n #turns = 0\n until over?\n turn\n end\nend", "def play\n\t\n\t\tuntil over?\n\t\tturn\n\t\tend\n\t\t\n\t\tif won? \n\t\t\twinner\n\t\telsif draw? \n\t\t\tputs \"The game was a Draw!\"\n\t\telse \n\t\t\tputs \"Unexpected Error Occured\" \n\t\tend\n\tend", "def play\n @hungry = true\n #p \"play method called\" #print notification to console\n end", "def play\n board_setup\n gameplay_setup\n end", "def play\n until over? do\n turn;\n end\n\n if won?\n puts \"Congratulations #{winner}!\";\n replay\n elsif draw?\n puts \"Cat's Game!\";\n replay\n end\n end", "def play\n until over?\n turn\n end\n\n if won?\n puts \"Congratulations #{winner}!\"\n elsif draw?\n puts \"Cat's Game!\"\n end\n end", "def play\n\n until self.over?\n self.turn\n end\n\n if self.won?\n self.board.display\n puts \"Congratulations #{self.winner}!\"\n elsif self.draw?\n self.board.display\n puts \"Cat's Game!\"\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 play\n wake\n puts \"You play fetch with #{@name}.\"\n time_passed\n end", "def play\n outcome = ''\n [1, 2].each {|ix| _select_players(ix)}\n c_player, o_player = _init_players\n o_player.set_other!(c_player) if o_player.is_IA_S?\n c_player.set_other!(o_player) if c_player.is_IA_S?\n #\n move_already_played = []\n #\n loop do\n STDOUT.print(\"#{@board.to_s}\\n#==> #{c_player.name}/#{c_player.type}'s TURN:\\n\")\n loop do\n m, sym = _get_move_from(c_player, move_already_played) # current player do his move\n v = @board.set_cell(m, sym.to_s)\n if m == -1 || v == sym # if sym not valid symbol, set_cell(m, sym != sym\n move_already_played << m.to_i\n break\n end\n STDERR.print \"! cell[#{m}] already set, try something else - v was: #{v.inspect} // #{v.class}\\n\"\n end\n move_already_played.sort!\n outcome = @board.game_over?\n break if outcome == :draw || outcome == :winner\n c_player, o_player = _switch_players(c_player, o_player)\n end\n _conclusion(outcome, c_player)\n end", "def play\n # Game play asks for players input on a turn of the game\n # Game play checks if the game is over after every turn\n # Game play plays the first turn of the game\n # Game play plays the first few turns of the game\n # Game play checks if the game is won after every turn\n # Game play checks if the game is a draw after every turn\n while !over?\n turn\n end\n # Game play stops playing if someone has won\n # Game play congratulates the winner X\n # Game play congratulates the winner O\n if won?\n puts \"Congratulations #{winner}!\"\n # Game play stops playing in a draw\n # Game play prints \"Cat's Game!\" on a draw\n elsif draw?\n puts \"Cat's Game!\"\n end\n end", "def play\n loop do\n prep_game\n loop do\n current_player_moves\n break if board.someone_won? || board.full?\n board.clear_screen_and_display_board(players) if human_turn?\n end\n display_result\n break unless play_again?\n reset\n end\n display_goodbye_message\n end", "def play\n until over?\n turn\n end\n if winner\n puts \"Congratulations #{winner}!\"\n else\n puts \"Cats Game!\"\n end\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 @ole.Play()\n end", "def play()\n @ole.Play()\n end", "def run\n player1 = Player.new(\"You\")\n player2 = Player.new(\"Computer\")\n rps = RockPaperScissors.new\n\t\tbegin\n\t\t\tputs \"---------Play Rock Paper Scissors!----------------\"\n\n\t\t\tplayer1.choose_by_input\n\t\t\tplayer2.choose_by_rand\n\n\t\t\tputs \"#{player1.name} picked #{player1.gesture}, and #{player2.name} picked #{player2.gesture}\"\n\n\t\t\trps.arbitrate(player1, player2)\n\n\t\t\tputs \"Do you want to play again? (Y/N)\"\n\t\t\tplay=gets.chomp.downcase\n\t\t\tplay = ( play =='y') ? TRUE: FALSE\n\n\t\tend while play==TRUE\n\tend", "def play_to_learn(board, opponent)\n return play(board)\n end", "def play\n\t @players.each { |player| player.score = 0 }\n\t \n\t loop do\n\t @board.clear\n\t\t@cur_player = @players[0]\n\t\t@rounds += 1\n\t\t\n\t\tprint \"\\n******************* Tic-Tac-Toe ********************\"\n\t puts \"\\n#{@players[0].name} will play with #{@players[0].mark}; #{@players[1].name} will play with #{@players[1].mark}\\n\\n\"\n\t\[email protected]_board \n\t \n\t\tloop do\n position = prompt_movement\n\t @board.set_mark(position, @cur_player.mark)\n\t\t @board.print_board \n\t\t \n\t\t result = \n\t\t if @board.is_winner?(@cur_player.mark)\n\t\t @cur_player.score += 1\n\t\t puts \"\\n#{@cur_player.name} wins!!\"\n\t\t\t true\n\t\t elsif @board.is_full?\n\t\t puts \"\\nThe game ended in a tie!\"\n\t\t\t true\n\t\t\tend\n\t\t \n\t\t break if result\n\t\t swap_players\n\t\tend\n\t\t\n\t\tbreak if prompt_quit\n\t end\n\t \n\t print_final_score\n\tend", "def war\n \n until winner?(self.player1,self.player2)\n 4.times do \n player1.play\n player2.play\n end\n end\n\n handle_winner(self.player1,self.player2)\n\n end", "def play\n until @board.winner?(:X) || @board.winner?(:O)\n p \"#{@current_player.mark}'s turn\"\n @board.print\n self.play_turn\n end\n\n @board.print\n self.switch_players!\n p \"#{@current_player.mark} has won!\"\n end", "def play\n until over?\n turn\n end\n\n if won?\n puts \"Congratulations #{winner}!\"\n\n else draw?\n puts \"Cat's Game!\"\n\n end\n end", "def play\n\t\tshow\n\t\twhile true\n\t\t\trow, col = input\n\t\t\tupdate row, col\n\t\t\tshow\n\n\t\t\tif is_a_winner?\n\t\t\t\tputs \"Player #{@player} won!\"\n\t\t\t\tbreak\n\t\t\telsif is_a_tie?\n\t\t\t\tputs \"Game is tied!\"\n\t\t\t\tbreak\n\t\t\tend\n\n\t\t\tswitch_players\n\t\tend\n\tend", "def play\n SHELL.confirm(\"Let's play some blackjack!\")\n loop do\n collect_bets\n give_initial_cards\n # ask if player would like to split here\n @players.each { |player| action_cycle(player, :player) }\n action_cycle(@dealer, :dealer)\n decide_scores\n break if done_playing?\n reset\n end\n end", "def play_cycle\n play\n earn_achievements\n end_game\n end", "def play\n # playing the first hand\n players.each { |player| ask_for_user_input(player, \"play_first_hand\") }\n self.to_s\n puts \" the winner of the first hand #{first_hand_winner.nickname}\"\n\n #playing the second hand\n ask_for_user_input(first_hand_winner, \"play_second_hand\")\n ask_for_user_input(other_player(first_hand_winner), \"play_second_hand\")\n\n self.to_s\n puts \" the winner of the second hand #{second_hand_winner.nickname}\"\n return if player_won_first_two_hands?\n\n #playing the third hand\n ask_for_user_input(second_hand_winner, \"play_third_hand\")\n ask_for_user_input(other_player(second_hand_winner), \"play_third_hand\")\n\n self.to_s\n end", "def play\n while !over?\n turn\n end\n if won?\n puts \"Congratulations #{winner}!\"\n else\n puts \"Cat's Game!\"\n end\n end", "def play\n while !over?\n turn\n end\n\n if won?\n puts \"Congratulations #{winner}!\"\n elsif draw?\n puts \"Cat's Game!\"\n end\n end", "def play\n \"We're rockiinnggg\"\n end", "def arriba\n case @selection\n when 2\n mesaje_select(@play_message)\n @selection = 1\n @select_song.play\n when 3\n mesaje_select(@difficulty_message)\n @selection = 2\n @select_song.play\n when 4\n mesaje_select(@music_message)\n @selection = 3\n @select_song.play\n when 5\n mesaje_select(@about_message)\n @selection = 4\n @select_song.play\n end\n sleep(0.15)\n end", "def play\n while !over?\n \t turn\n end\n if won?\n \t puts \"Congratulations \"+ winner() +\"!\"\n else\n \t puts \"Cat's Game!\"\n end\n end", "def play\n\t\t@current_turn = 0\n\t\t@current_player = @hunter\n\t\tplayers.each{|p| p.write(game_parameters)}\n\t\tuntil is_game_over?\n\t\t\tpre_turn_wall_count = @walls.size\n\t\t\treport_state_to_spectators\n\t\t\t@current_player.take_turn\n\t\t\t# Only print the board every 10 turns or if a wall was added or removed\n\t\t\tprint_minified_board() if @current_turn%10 == 0 || @walls.size != pre_turn_wall_count\n\t\t\tadvance_turn!\n\t\t\tprint \"#{@current_turn} \"\n\t\tend\n\t\tresult = report_winner\n\t\tcleanup_players!\n\t\tcleanup_spectators!\n\t\tresult\t# Returns this so the EvasionServer can save results\n\tend", "def play(opponent)\n opponent.choose\n end", "def play(players)\n while !win?\n players.each do |player|\n self.end_if_tie\n self.draw\n puts \"#{player.name} turn with #{player.sign}\"\n self.write(player)\n if win?\n puts \"#{player.name} wins!\"\n exit\n end\n end\n end\n end", "def play_for_trick \n if @player1.deal == true && @player2.deal == false && [email protected]?\n #start with the hand on each player\n response_hand = @player2.hand\n leading_card_hand = @player1.hand\n #find card of player who leads\n leading_card = @player1.lead_card\n @player1.remove_card_from_hand(leading_card)\n puts @player1.name + \" chooses the \" + leading_card.card_to_string\n #find card of player who responds\n response_card = @player2.respond(leading_card)\n @player2.remove_card_from_hand(response_card)\n puts @player1.name + \" plays the \" + leading_card.card_to_string + \" and \" +\n @player2.name + \" plays the \" + response_card.card_to_string\n \n #find winning card and then find out who that card belongs too\n winning_card = determine_winner(leading_card, response_card)\n if winning_card == leading_card \n @player1.deal = true\n @player2.deal = false\n @player1.score += 1\n else\n @player2.deal = true\n @player1.deal = false\n @player2.score += 1\n end\n #display players scores\n puts @player1.name + \"'s score is \" + @player1.score.to_s\n puts @player2.name + \"'s score is \" + @player2.score.to_s\n end\n\n if @player1.deal == false && @player2.deal == true && [email protected]?\n #start with the hand on each player\n response_hand = @player2.hand\n leading_card_hand = @player1.hand\n #find card of player who leads\n leading_card = @player2.lead_card\n @player2.remove_card_from_hand(leading_card)\n puts @player2.name + \" chooses the \" + leading_card.card_to_string\n #find card of player who responds\n response_card = @player1.respond(leading_card)\n @player1.remove_card_from_hand(response_card)\n puts @player2.name + \" plays the \" + leading_card.card_to_string + \" and \" +\n @player1.name + \" plays the \" + response_card.card_to_string\n\n #find winning card and then find out who that card belongs too\n winning_card = determine_winner(leading_card, response_card)\n\n if winning_card == leading_card \n @player2.deal = true\n @player1.deal = false\n @player2.score += 1\n else\n @player1.deal = true\n @player2.deal = false\n @player1.score += 1\n end\n #display players scores\n puts @player1.name + \"'s score is \" + @player1.score.to_s\n puts @player2.name + \"'s score is \" + @player2.score.to_s\n end\n end", "def play()\n \twinner = false\n \twhile not winner\n\t # player 1 moves\n\t @board.show()\n\t location = @player1.play()\n\t @board.changeLocation(location, @player1.marker)\n\n\t # did he win?\n\t winner = @board.checkWinner(@player1.marker)\n\t break if winner\n\n\t # player 2 plays\n\t @board.show()\n\t location = @player2.play()\n\t @board.changeLocation(location, @player2.marker)\n\n\t # did he win?\n\t winner = @board.checkWinner(@player2.marker)\n\n\tend\n @board.show()\n puts \"Player #{winner} won the game!\"\n end", "def play\n puts \"#{name} got zoomies playing fetch!\"\n @hungry = true\n end", "def play\n while !over?\n turn\n end\n if won?\n puts \"Congratulations #{winner}!\"\n else draw?\n puts \"Cat's Game!\"\n end\n end", "def play\n while over? == false\n turn\n end\n if won?\n puts \"Congratulations #{winner}!\"\n elsif draw?\n puts \"Cat's Game!\"\n end\n end", "def play\n start = Time.now\n until @board.won?\n @player ? round_player : round_ai\n @attempts += 1\n sleep(2)\n system(\"cls\")\n @board.render\n end\n finish = Time.now\n time_to_finish = finish - start\n declare_win(time_to_finish)\n end", "def play\n while !over?\n turn\n end\n won? ? (puts \"Congratulations #{@winner}!\") : (puts \"Cat's Game!\")\n\n end", "def play(cmd)\n play_game(cmd)\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 while !over?\n turn\n end\n if won?\n puts \"Congratulations #{ winner }!\"\n elsif draw?\n puts \"Cat's Game!\"\n else\n puts \"Game over\"\n end\n end", "def play\n puts 'Playing'\n end", "def next_turn\n @play == 0 ? @play +=1 : @play -=1 #change la valeur de play, donc change de joueur\n tu_vas_jouer_oui?(player[play])\n end" ]
[ "0.7563246", "0.74452245", "0.7326587", "0.7291661", "0.7221097", "0.7176399", "0.7174837", "0.71102804", "0.7089614", "0.70865387", "0.7061119", "0.7058428", "0.7045526", "0.7006848", "0.6998227", "0.6998227", "0.6998227", "0.6998227", "0.69852924", "0.6964193", "0.69231814", "0.69181776", "0.69021803", "0.68971735", "0.6891035", "0.68789023", "0.68713033", "0.68692386", "0.6865273", "0.6846359", "0.68457323", "0.6826923", "0.6826923", "0.6824598", "0.68186575", "0.68098295", "0.68002915", "0.6798934", "0.67937326", "0.6759366", "0.67558074", "0.6745371", "0.67394227", "0.67300564", "0.6726075", "0.67217803", "0.6720404", "0.6715616", "0.6713965", "0.6706336", "0.6702538", "0.6701842", "0.66878474", "0.66854835", "0.66824675", "0.6670952", "0.6661855", "0.66530395", "0.6643765", "0.6642709", "0.6641316", "0.6638773", "0.66331977", "0.6630473", "0.662961", "0.662826", "0.6627895", "0.6627895", "0.6627895", "0.6624126", "0.6624126", "0.6620914", "0.66188645", "0.6605878", "0.65962553", "0.65929604", "0.6589155", "0.6586578", "0.6582785", "0.6574971", "0.6572911", "0.6572546", "0.65677446", "0.6560333", "0.6550957", "0.6549828", "0.6542794", "0.65423024", "0.6541388", "0.65407324", "0.65392345", "0.6534237", "0.6526624", "0.6525757", "0.65205944", "0.65200955", "0.6513293", "0.6509626", "0.65018785", "0.64991695", "0.649816" ]
0.0
-1
before_action :set_space_type, only: [:show, :edit, :update, :destroy] GET /space_types GET /space_types.json
def index @space_types = @space_types.order(:name) respond_to do |format| format.js format.html end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_space_type\n @space_type = SpaceType.find(params[:id])\n end", "def set_space_type\n @space_type = SpaceType.find(params[:id])\n end", "def set_space_type\n @space_type = SpaceType.find(params[:id])\n end", "def create\n @space_type = SpaceType.new(space_type_params)\n authorize! :create, @space_type\n\n respond_to do |format|\n if @space_type.save\n format.html { redirect_to @space_type, notice: t('.create_ok') }\n format.json { render action: 'show', status: :created, location: @space_type }\n else\n format.html { render action: 'new' }\n format.json { render json: @space_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def space_type_params\n params.require(:space_type).permit(:name)\n end", "def update\n respond_to do |format|\n old_name = @space_type.name\n if @space_type.update(space_type_params)\n @space_type.spaces.each { |s| s.touch }\n format.html { redirect_to @space_type, notice: t('.update_ok') }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @space_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @space_type.destroy\n respond_to do |format|\n format.html { redirect_to space_types_url, status: 303 }\n format.json { head :no_content }\n end\n end", "def update_space_type_params\n params.require(:space_type).permit(:id, :name)\n end", "def add_space_type(template, clim, building_type, spc_type)\n #OpenStudio::logFree(OpenStudio::Info, 'openstudio.standards.Model', \"Adding space type: #{template}-#{clim}-#{building_type}-#{spc_type}\")\n\n # Get the space type data\n data = self.find_object(self.standards['space_types'], {'template'=>template, 'building_type'=>building_type, 'space_type'=>spc_type})\n if !data\n OpenStudio::logFree(OpenStudio::Warn, 'openstudio.standards.Model', \"Cannot find data for space type: #{template}-#{clim}-#{building_type}-#{spc_type}, will not be created.\")\n return false #TODO change to return empty optional schedule:ruleset?\n end\n \n name = make_name(template, clim, building_type, spc_type)\n\n # Create a new space type and name it\n space_type = OpenStudio::Model::SpaceType.new(self)\n space_type.setName(name)\n\n # Set the standards building type and space type for this new space type\n space_type.setStandardsBuildingType(building_type)\n space_type.setStandardsSpaceType(spc_type)\n\n # Set the rendering color of the space type\n rgb = data['rgb']\n rgb = rgb.split('_')\n r = rgb[0].to_i\n g = rgb[1].to_i\n b = rgb[2].to_i\n rendering_color = OpenStudio::Model::RenderingColor.new(self)\n rendering_color.setRenderingRedValue(r)\n rendering_color.setRenderingGreenValue(g)\n rendering_color.setRenderingBlueValue(b)\n space_type.setRenderingColor(rendering_color)\n\n # Create the schedule set for the space type\n default_sch_set = OpenStudio::Model::DefaultScheduleSet.new(self)\n default_sch_set.setName(\"#{name} Schedule Set\")\n space_type.setDefaultScheduleSet(default_sch_set)\n\n # Lighting\n make_lighting = false\n lighting_per_area = data['lighting_per_area']\n lighting_per_person = data['lighting_per_person']\n unless lighting_per_area == 0 || lighting_per_area.nil? then make_lighting = true end\n unless lighting_per_person == 0 || lighting_per_person.nil? then make_lighting = true end\n\n if make_lighting == true\n\n # Create the lighting definition\n lights_def = OpenStudio::Model::LightsDefinition.new(self)\n lights_def.setName(\"#{name} Lights Definition\")\n lights_frac_to_return_air = data['lighting_fraction_to_return_air']\n lights_frac_radiant = data['lighting_fraction_radiant']\n lights_frac_visible = data['lighting_fraction_visible']\n unless lighting_per_area == 0 || lighting_per_area.nil?\n lights_def.setWattsperSpaceFloorArea(OpenStudio.convert(lighting_per_area, 'W/ft^2', 'W/m^2').get)\n lights_def.setReturnAirFraction(lights_frac_to_return_air)\n lights_def.setFractionRadiant(lights_frac_radiant)\n lights_def.setFractionVisible(lights_frac_visible)\n end\n unless lighting_per_person == 0 || lighting_per_person.nil?\n lights_def.setWattsperPerson(OpenStudio.convert(lighting_per_person, 'W/person', 'W/person').get)\n lights_def.setReturnAirFraction(lights_frac_to_return_air)\n lights_def.setFractionRadiant(lights_frac_radiant)\n lights_def.setFractionVisible(lights_frac_visible)\n end\n\n # Create the lighting instance and hook it up to the space type\n lights = OpenStudio::Model::Lights.new(lights_def)\n lights.setName(\"#{name} Lights\")\n lights.setSpaceType(space_type)\n\n # Additional Lighting\n additional_lighting_per_area = data['additional_lighting_per_area']\n if additional_lighting_per_area != nil\n # Create the lighting definition\n additional_lights_def = OpenStudio::Model::LightsDefinition.new(self)\n additional_lights_def.setName(\"#{name} Additional Lights Definition\")\n additional_lights_def.setWattsperSpaceFloorArea(OpenStudio.convert(additional_lighting_per_area, 'W/ft^2', 'W/m^2').get)\n additional_lights_def.setReturnAirFraction(lights_frac_to_return_air)\n additional_lights_def.setFractionRadiant(lights_frac_radiant)\n additional_lights_def.setFractionVisible(lights_frac_visible)\n\n # Create the lighting instance and hook it up to the space type\n additional_lights = OpenStudio::Model::Lights.new(additional_lights_def)\n additional_lights.setName(\"#{name} Additional Lights\")\n additional_lights.setSpaceType(space_type)\n end\n\n # Get the lighting schedule and set it as the default\n lighting_sch = data['lighting_schedule']\n unless lighting_sch.nil?\n default_sch_set.setLightingSchedule(add_schedule(lighting_sch))\n end\n end\n\n # Ventilation\n\n make_ventilation = false\n ventilation_per_area = data['ventilation_per_area']\n ventilation_per_person = data['ventilation_per_person']\n ventilation_ach = data['ventilation_air_changes']\n unless ventilation_per_area == 0 || ventilation_per_area.nil? then make_ventilation = true end\n unless ventilation_per_person == 0 || ventilation_per_person.nil? then make_ventilation = true end\n unless ventilation_ach == 0 || ventilation_ach.nil? then make_ventilation = true end\n\n\n if make_ventilation == true\n\n # Create the ventilation object and hook it up to the space type\n ventilation = OpenStudio::Model::DesignSpecificationOutdoorAir.new(self)\n ventilation.setName(\"#{name} Ventilation\")\n puts \"#{name}\"\n space_type.setDesignSpecificationOutdoorAir(ventilation)\n ventilation.setOutdoorAirMethod('Sum')\n unless ventilation_per_area.nil? || ventilation_per_area.to_f == 0\n ventilation.setOutdoorAirFlowperFloorArea(OpenStudio.convert(ventilation_per_area, 'ft^3/min*ft^2', 'm^3/s*m^2').get)\n end\n unless ventilation_per_person.nil? || ventilation_per_person.to_f == 0\n ventilation.setOutdoorAirFlowperPerson(OpenStudio.convert(ventilation_per_person, 'ft^3/min*person', 'm^3/s*person').get)\n end\n unless ventilation_ach.nil? || ventilation_ach.to_f == 0\n ventilation.setOutdoorAirFlowAirChangesperHour(ventilation_ach)\n end\n end\n\n # Occupancy\n\n make_people = false\n occupancy_per_area = data['occupancy_per_area']\n unless occupancy_per_area == 0 || occupancy_per_area.nil? then make_people = true end\n\n if make_people == true\n # create the people definition\n people_def = OpenStudio::Model::PeopleDefinition.new(self)\n people_def.setName(\"#{name} People Definition\")\n unless occupancy_per_area == 0 || occupancy_per_area.nil?\n people_def.setPeopleperSpaceFloorArea(OpenStudio.convert(occupancy_per_area / 1000.0, 'people/ft^2', 'people/m^2').get)\n end\n\n # create the people instance and hook it up to the space type\n people = OpenStudio::Model::People.new(people_def)\n people.setName(\"#{name} People\")\n people.setSpaceType(space_type)\n\n # get the occupancy and occupant activity schedules from the library and set as the default\n occupancy_sch = data['occupancy_schedule']\n unless occupancy_sch.nil?\n default_sch_set.setNumberofPeopleSchedule(add_schedule(occupancy_sch))\n end\n occupancy_activity_sch = data['occupancy_activity_schedule']\n unless occupancy_activity_sch.nil?\n default_sch_set.setPeopleActivityLevelSchedule(add_schedule(occupancy_activity_sch))\n end\n\n end\n\n # Infiltration\n\n make_infiltration = false\n infiltration_per_area_ext = data['infiltration_per_exterior_area']\n infiltration_per_area_ext_wall = data['infiltration_per_exterior_wall_area']\n infiltration_ach = data['infiltration_air_changes']\n unless (infiltration_per_area_ext == 0 || infiltration_per_area_ext.nil?) && (infiltration_per_area_ext_wall == 0 || infiltration_per_area_ext_wall.nil?) && (infiltration_ach == 0 || infiltration_ach.nil?) \n then make_infiltration = true\n end\n\n if make_infiltration == true\n\n # Create the infiltration object and hook it up to the space type\n infiltration = OpenStudio::Model::SpaceInfiltrationDesignFlowRate.new(self)\n infiltration.setName(\"#{name} Infiltration\")\n infiltration.setSpaceType(space_type)\n unless infiltration_per_area_ext == 0 || infiltration_per_area_ext.nil?\n infiltration.setFlowperExteriorSurfaceArea(OpenStudio.convert(infiltration_per_area_ext, 'ft^3/min*ft^2', 'm^3/s*m^2').get)\n end\n unless infiltration_per_area_ext_wall == 0 || infiltration_per_area_ext_wall.nil?\n infiltration.setFlowperExteriorWallArea(OpenStudio.convert(infiltration_per_area_ext_wall, 'ft^3/min*ft^2', 'm^3/s*m^2').get)\n end\n unless infiltration_ach == 0 || infiltration_ach.nil?\n infiltration.setAirChangesperHour(infiltration_ach)\n end\n\n # Get the infiltration schedule from the library and set as the default\n infiltration_sch = data['infiltration_schedule']\n unless infiltration_sch.nil?\n default_sch_set.setInfiltrationSchedule(add_schedule(infiltration_sch))\n end\n\n end\n\n # Electric equipment\n\n make_electric_equipment = false\n elec_equip_per_area = data['electric_equipment_per_area']\n elec_equip_frac_latent = data['electric_equipment_fraction_latent']\n elec_equip_frac_radiant = data['electric_equipment_fraction_radiant']\n elec_equip_frac_lost = data['electric_equipment_fraction_lost']\n unless elec_equip_per_area == 0 || elec_equip_per_area.nil? then make_electric_equipment = true end\n\n if make_electric_equipment == true\n\n # Create the electric equipment definition\n elec_equip_def = OpenStudio::Model::ElectricEquipmentDefinition.new(self)\n elec_equip_def.setName(\"#{name} Electric Equipment Definition\")\n unless elec_equip_per_area == 0 || elec_equip_per_area.nil?\n elec_equip_def.setWattsperSpaceFloorArea(OpenStudio.convert(elec_equip_per_area, 'W/ft^2', 'W/m^2').get)\n elec_equip_def.setFractionLatent(elec_equip_frac_latent)\n elec_equip_def.setFractionRadiant(elec_equip_frac_radiant)\n elec_equip_def.setFractionLost(elec_equip_frac_lost)\n end\n\n # Create the electric equipment instance and hook it up to the space type\n elec_equip = OpenStudio::Model::ElectricEquipment.new(elec_equip_def)\n elec_equip.setName(\"#{name} Electric Equipment\")\n elec_equip.setSpaceType(space_type)\n\n # Get the electric equipment schedule from the library and set as the default\n elec_equip_sch = data['electric_equipment_schedule']\n unless elec_equip_sch.nil?\n default_sch_set.setElectricEquipmentSchedule(add_schedule(elec_equip_sch))\n end\n\n end\n\n # Gas equipment\n\n make_gas_equipment = false\n gas_equip_per_area = data['gas_equipment_per_area']\n gas_equip_frac_latent = data['gas_equipment_fraction_latent']\n gas_equip_frac_radiant = data['gas_equipment_fraction_radiant']\n gas_equip_frac_lost = data['gas_equipment_fraction_lost']\n\n unless gas_equip_per_area == 0 || gas_equip_per_area.nil? then make_gas_equipment = true end\n\n if make_gas_equipment == true\n\n # Create the gas equipment definition\n gas_equip_def = OpenStudio::Model::GasEquipmentDefinition.new(self)\n gas_equip_def.setName(\"#{name} Gas Equipment Definition\")\n gas_equip_def.setFractionLatent(gas_equip_frac_latent)\n gas_equip_def.setFractionRadiant(gas_equip_frac_radiant)\n gas_equip_def.setFractionLost(gas_equip_frac_lost)\n unless gas_equip_per_area == 0 || gas_equip_per_area.nil?\n gas_equip_def.setWattsperSpaceFloorArea(OpenStudio.convert(gas_equip_per_area, 'Btu/hr*ft^2', 'W/m^2').get)\n end\n\n # Create the gas equipment instance and hook it up to the space type\n gas_equip = OpenStudio::Model::GasEquipment.new(gas_equip_def)\n gas_equip.setName(\"#{name} Gas Equipment\")\n gas_equip.setSpaceType(space_type)\n\n # Get the gas equipment schedule from the library and set as the default\n gas_equip_sch = data['gas_equipment_schedule']\n unless gas_equip_sch.nil?\n default_sch_set.setGasEquipmentSchedule(add_schedule(gas_equip_sch))\n end\n\n end\n\n thermostat = OpenStudio::Model::ThermostatSetpointDualSetpoint.new(self)\n thermostat.setName(\"#{name} Thermostat\")\n\n heating_setpoint_sch = data['heating_setpoint_schedule']\n unless heating_setpoint_sch.nil?\n thermostat.setHeatingSetpointTemperatureSchedule(add_schedule(heating_setpoint_sch))\n end\n\n cooling_setpoint_sch = data['cooling_setpoint_schedule']\n unless cooling_setpoint_sch.nil?\n thermostat.setCoolingSetpointTemperatureSchedule(add_schedule(cooling_setpoint_sch))\n end\n\n # componentize the space type\n space_type_component = space_type.createComponent\n\n # #TODO make this return BCL component space types?\n #\n # #setup the file names and save paths that will be used\n # file_name = \"nrel_ref_bldg_space_type\"\n # component_dir = \"#{Dir.pwd}/#{component_name}\"\n # osm_file_path = OpenStudio::Path.new(\"#{component_dir}/files/#{file_name}.osm\")\n # osc_file_path = OpenStudio::Path.new(\"#{component_dir}/files/#{file_name}.osc\")\n #\n # #OpenStudio::logFree(OpenStudio::Info, 'openstudio.standards.Model', \"component_dir = #{component_dir}\")\n #\n # OpenStudio::logFree(OpenStudio::Info, 'openstudio.standards.Model', \"creating directories\")\n # FileUtils.rm_rf(component_dir) if File.exists?(component_dir) and File.directory?(component_dir)\n # FileUtils.mkdir_p(component_dir)\n # FileUtils.mkdir_p(\"#{component_dir}/files/\")\n #\n # #save the space type as a .osm\n # #OpenStudio::logFree(OpenStudio::Info, 'openstudio.standards.Model', \"saving osm to #{osm_file_path}\")\n # model.toIdfFile().save(osm_file_path,true)\n #\n # #save the componentized space type as a .osc\n # #OpenStudio::logFree(OpenStudio::Info, 'openstudio.standards.Model', \"saving osc to #{osc_file_path}\")\n # space_type_component.toIdfFile().save(osc_file_path,true)\n #\n # #make the BCL component\n # OpenStudio::logFree(OpenStudio::Info, 'openstudio.standards.Model', \"creating BCL component\")\n # component = BCL::Component.new(component_dir)\n # OpenStudio::logFree(OpenStudio::Info, 'openstudio.standards.Model', \"created uid = #{component.uuid}\")\n #\n # #add component information\n # component.name = component_name\n # component.description = \"This space type represent spaces in typical commercial buildings in the United States. The information to create these space types was taken from the DOE Commercial Reference Building Models, which can be found at http://www1.eere.energy.gov/buildings/commercial_initiative/reference_buildings.html. These space types include plug loads, gas equipment loads (cooking, etc), occupancy, infiltration, and ventilation rates, as well as schedules. These space types should be viewed as starting points, and should be reviewed before being used to make decisions.\"\n # component.source_manufacturer = \"DOE\"\n # component.source_url = \"http://www1.eere.energy.gov/buildings/commercial_initiative/reference_buildings.html\"\n # component.add_provenance(\"dgoldwas\", Time.now.gmtime.strftime('%Y-%m-%dT%H:%M:%SZ'), \"\")\n # component.add_tag(\"Space Types\") # todo: what is the taxonomy string for space type? is there one?\n #\n # #add arguments as attributes\n # component.add_attribute(\"NREL_reference_building_vintage\", template, \"\")\n # component.add_attribute(\"Climate_zone\", clim, \"\")\n # component.add_attribute(\"NREL_reference_building_primary_space_type\", building_type, \"\")\n # component.add_attribute(\"NREL_reference_building_secondary_space_type\", spc_type, \"\")\n #\n # #openstudio type attribute\n # component.add_attribute(\"OpenStudio Type\", space_type.iddObjectType.valueDescription, \"\")\n #\n # #add other attributes\n # component.add_attribute(\"Lighting Standard\", data[\"lighting_standard\"], \"\")\n # component.add_attribute(\"Lighting Primary Space Type\", data[\"lighting_pri_spc_type\"], \"\")\n # component.add_attribute(\"Lighting Secondary Space Type\", data[\"lighting_sec_spc_type\"], \"\")\n #\n # component.add_attribute(\"Ventilation Standard\", data[\"ventilation_standard\"], \"\")\n # component.add_attribute(\"Ventilation Primary Space Type\", data[\"ventilation_pri_spc_type\"], \"\")\n # component.add_attribute(\"Ventilation Secondary Space Type\", data[\"ventilation_sec_spc_type\"], \"\")\n #\n # component.add_attribute(\"Occupancy Standard\", \"NREL reference buildings\", \"\")\n # component.add_attribute(\"Occupancy Primary Space Type\", building_type, \"\")\n # component.add_attribute(\"Occupancy Secondary Space Type\", spc_type, \"\")\n #\n # component.add_attribute(\"Infiltration, Gas Equipment, Electric Equipment, and Schedules Standard\", \"NREL reference buildings\", \"\")\n # component.add_attribute(\"Infiltration, Gas Equipment, Electric Equipment, and Schedules Primary Space Type\", building_type, \"\")\n # component.add_attribute(\"Infiltration, Gas Equipment, Electric Equipment, and Schedules Secondary Space Type\", spc_type, \"\")\n #\n # #add the osm and osc files to the component\n # component.add_file(\"OpenStudio\", \"0.9.3\", osm_file_path.to_s, \"#{file_name}.osm\", \"osm\")\n # component.add_file(\"OpenStudio\", \"0.9.3\", osc_file_path.to_s, \"#{file_name}.osc\", \"osc\")\n #\n # #OpenStudio::logFree(OpenStudio::Info, 'openstudio.standards.Model', \"saving component to #{component_dir}\")\n # component.save_component_xml(component_dir)\n #\n # =e\n # return the space type and the componentized space type\n \n return space_type\n \n end", "def set_space\n @space = Space.find(params[:id])\n end", "def set_space\n @space = Space.find(params[:id])\n end", "def set_space\n @space = Space.find(params[:id])\n end", "def space_type_params\n params.require(:space_type).permit(\n :name, :short_name, :spaces_count, :notes,\n equipment_items_attributes: [:id, :qty, :notes, :equipment_model_id, :_destroy] )\n end", "def set_space\n @space = Space.find(params[:id])\n end", "def set_space\n @space = Space.find(params[:id])\n end", "def set_space\n @space = Space.find(params[:id])\n end", "def set_space\n @space = Space.find(params[:id])\n end", "def set_space\n @space = Space.find(params[:id])\n end", "def set_space\n @space = Space.find(params[:id])\n end", "def set_space_cat\n @space_cat = SpaceCat.find(params[:id])\n end", "def show\n @space = Space.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @space }\n end\n end", "def space_params\n params.require(:space).permit(:name, :spaceType, :multiplier, :area)\n end", "def show\n @space_cat = SpaceCat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @space_cat }\n end\n end", "def set_space\n @space = Space.friendly.find(params[:id])\n redirect_to root_path unless @space.present?\n end", "def set_spacecraft\n @spacecraft = Spacecraft.find(params[:id])\n end", "def space_params\n params.require(:space).permit(:name, :description, :url, :is_public, :user_id)\n end", "def show\n @myspace = Myspace.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @myspace }\n end\n end", "def set_space\n @space = @location.spaces.find_by_permalink(params[:space_id])\n raise ActiveRecord::RecordNotFound unless @space\n end", "def set_space\n @space = current_user.spaces.friendly.find(params[:id])\n end", "def index\n authorize CarrierType\n @carrier_types = CarrierType.order(:position)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @carrier_types }\n end\n end", "def show\n render json: @trait_type\n end", "def set_type\n @type = Type.find(params[:id])\n\n end", "def show\n render json: @space_station\n end", "def set_type\n @type = IngredientType.find(params[:id])\n end", "def set_actiontype\n @actiontype = Actiontype.find(params[:id])\n end", "def set_mapspace\n @mapspace = Mapspace.find(params[:id])\n end", "def set_type\n @type = Type.find(params[:id])\n end", "def create\n @space = Space.new(space_params)\n\n respond_to do |format|\n if @space.save\n format.html { redirect_to @space, notice: 'Space was successfully created.' }\n format.json { render action: 'show', status: :created, location: @space }\n else\n format.html { render action: 'new' }\n format.json { render json: @space.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @dash_type = DashType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dash_type }\n end\n end", "def index\n @spaces = Space.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @spaces }\n end\n end", "def set_type\n @type = Type.find(params[:id])\n end", "def set_type\n @type = Type.find(params[:id])\n end", "def set_type\n @type = Type.find(params[:id])\n end", "def set_segment_type\n @segment_type = SegmentType.find(params[:id])\n end", "def create\n @space = Space.new(space_params)\n\n respond_to do |format|\n if @space.save\n format.html { redirect_to root_path, notice: \"Space was successfully created.\" }\n format.json { render :show, status: :created, location: @space }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @space.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @space = Space.new(space_params)\n @space.user = current_user\n if @space.save\n render json: @space\n else\n render json: @space.errors, status: :unprocessable_entity\n end\n end", "def create\n @space_form = Space::Form.new(space: current_team.spaces.new,\n user: current_user,\n attributes: space_params)\n\n authorize @space_form.space, :create?\n\n respond_to do |format|\n if @space_form.save\n format.html do\n redirect_to case\n when @space_form.space.access_control.private? then space_members_path(@space_form.space)\n else space_pages_path(@space_form.space)\n end\n end\n format.json { render :show, status: :created, location: @space_form.space }\n else\n format.html { render :new }\n format.json { render json: @space_form.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @space = Space.find(params[:id]) \n end", "def show\n @os_type = OsType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @os_type }\n end\n end", "def set_center_type\n @center_type = CenterType.find(params[:id])\n end", "def create\n @space = Space.new(space_params)\n @space.user = current_user\n\n if !space_params.has_key? :is_private\n @space.is_private = @space.user.prefers_private?\n if @space.organization\n @space.is_private = @space.is_private || @space.organization.prefers_private?\n end\n end\n\n if @space.save\n render json: SpaceRepresenter.new(@space).to_json(user_options: {current_user_can_edit: true})\n else\n render json: @space.errors, status: :unprocessable_entity\n end\n end", "def create\n @space = Space.new(params[:space])\n\n respond_to do |format|\n if @space.save\n format.html { redirect_to @space, notice: 'Space was successfully created.' }\n format.json { render json: @space, status: :created, location: @space }\n else\n format.html { render action: \"new\" }\n format.json { render json: @space.errors, status: :unprocessable_entity }\n end\n end\n end", "def space_params\n params.require(:space).permit(:name, :category, :address, :city, :state, :hours, :phone, :email, :website, :description)\n end", "def index\n render json: Space.all\n end", "def show\n @gl_type = GlType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @gl_type }\n end\n end", "def set_space(space_id = params[:id])\n @space = Space.find(space_id)\n end", "def space_cat_params\n params.require(:space_cat).permit(:name)\n end", "def show\n @segment_type = SegmentType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @segment_type }\n end\n end", "def set_type\n @type = controller_name.classify\n end", "def set_type\n @type = controller_name.classify\n end", "def assign_space_type_stubs(building_type, space_type_map)\n\n space_type_map.each do |space_type_name, space_names|\n # Create a new space type\n stub_space_type = OpenStudio::Model::SpaceType.new(self)\n stub_space_type.setStandardsBuildingType(building_type)\n stub_space_type.setStandardsSpaceType(space_type_name)\n \n space_names.each do |space_name|\n space = self.getSpaceByName(space_name)\n next if space.empty?\n space = space.get\n space.setSpaceType(stub_space_type)\n\n #OpenStudio::logFree(OpenStudio::Info, 'openstudio.model.Model', \"Setting #{space.name} to #{building_type}.#{space_type_name}\")\n end\n end\n\n return true\n end", "def space_params\n params.require(:space).permit(:name, :image, :detail, :facility_id, :image_cache, :remove_image)\n end", "def set_space_scene\n @space_scene = SpaceScene.find(params[:id])\n end", "def set_space_amenity\n @space_amenity = SpaceAmenity.find(params[:id])\n end", "def set_cloth_type\n @cloth_type = ClothType.find(params[:id])\n end", "def change_type\n\t\t\trender json: User.update_type_by_id(params[:id], params[:type], params[:is])\n\t\tend", "def update\n respond_to do |format|\n if @space.update(space_params)\n format.html { redirect_to @space, notice: \"Space was successfully updated.\" }\n format.json { render :show, status: :ok, location: @space }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @space.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @safe_space = SafeSpace.new(safe_space_params)\n\n respond_to do |format|\n if @safe_space.save\n format.html { redirect_to @safe_space, notice: 'Safe space was successfully created.' }\n format.json { render :show, status: :created, location: @safe_space }\n else\n format.html { render :new }\n format.json { render json: @safe_space.errors, status: :unprocessable_entity }\n end\n end\n end", "def space_params\n params.require(:space).permit(:title, :space_setting_id, :num_of_people_id, :content, :address, :token,\n :atmosphere_id, :city_id, :price_hour, :price_day, :price_month, :price_year,\n :detailed_ids => [], :user_group_ids => [], :rent_env_ids => [], photos_attributes: [:data] )\n end", "def update\n respond_to do |format|\n if @space.update(space_params)\n format.html { redirect_to @space, notice: 'Space was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @space.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_unit_action_type\n @unit_action_type = UnitActionType.find(params[:id])\n end", "def destroy\n @dash_type = DashType.find(params[:id])\n @dash_type.destroy\n\n respond_to do |format|\n format.html { redirect_to dash_types_url }\n format.json { head :no_content }\n end\n end", "def create\n @space_cat = SpaceCat.new(space_cat_params)\n\n respond_to do |format|\n if @space_cat.save\n format.html { redirect_to @space_cat, notice: 'Space cat was successfully created.' }\n format.json { render action: 'show', status: :created, location: @space_cat }\n else\n format.html { render action: 'new' }\n format.json { render json: @space_cat.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @center_types = CenterType.all\n end", "def index\n authorize! :show, PointsEntryType\n load_active_points_entry_types\n\n respond_to do |format|\n format.html\n format.json { render json: @points_entry_types }\n end\n end", "def index\n authorize_action_for OrderType, at: current_store\n @order_types = current_store.order_types\n end", "def space_params\n params.require(:space).permit(:name, :cover, :access_control).to_h\n end", "def update\n if @space.update(space_params)\n render json: @space, status: :ok\n else\n render json: @space.errors, status: :unprocessable_entity\n end\n end", "def set_storage_type\n @storage_type = StorageType.find(params[:id])\n end", "def show\n @mapspace = Mapspace.find(params[:id])\n render :template => \"mapspaces/show\"\n end", "def show\n render partial: @space\n end", "def set_test_type\n @test_type = TestType.find(params[:id])\n authorize @test_type\n end", "def show\n authorize @space, :show?\n end", "def new\n @space = Space.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @space }\n end\n end", "def create\n @space = Space.new(space_params)\n\n respond_to do |format|\n if @space.save\n format.html { redirect_to spaces_path, notice: 'Friend was successfully created.' }\n format.json { render action: 'show', status: :created, location: @space }\n else\n format.html { render action: 'new' }\n format.json { render json: @space.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_safe_space\n @safe_space = SafeSpace.find(params[:id])\n end", "def show\n if params[:term]\n @types = Type.all(:conditions => ['typeName LIKE ?', \"%#{params[:term]}%\"])\n else\n @type = Type.find(params[:id])\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @types }\n end\n end", "def index\n if params['user_id']\n @user = User.find(params['user_id'])\n @spaces = @user.spaces.visible_by(current_user)\n else\n @spaces = Space.visible_by(current_user).first(10)\n end\n #render json: @spaces.as_json(only: [:id, :name, :description, :updated_at, :user_id])\n render json: SpacesRepresenter.new(@spaces).to_json\n end", "def show\n @action_type = ActionType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.haml\n format.json { render json: @action_type }\n end\n end", "def create\n @space_cat = SpaceCat.new(params[:space_cat])\n\n respond_to do |format|\n if @space_cat.save\n format.html { redirect_to @space_cat, notice: 'Space cat was successfully created.' }\n format.json { render json: @space_cat, status: :created, location: @space_cat }\n else\n format.html { render action: \"new\" }\n format.json { render json: @space_cat.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @type = Type.find(params[:type])\n @type.destroy\n\n respond_to do |format|\n format.html { redirect_to company_types_url }\n format.json { head :no_content }\n end\n end", "def create\n @myspace = Myspace.new(params[:myspace])\n\n respond_to do |format|\n if @myspace.save\n format.html { redirect_to @myspace, notice: 'Myspace was successfully created.' }\n format.json { render json: @myspace, status: :created, location: @myspace }\n else\n format.html { render action: \"new\" }\n format.json { render json: @myspace.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @page_type = PageType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @page_type }\n end\n end", "def set_item_type\n @item_type = ItemType.find(params[:id])\n end", "def show\n @space_user = SpaceUser.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @space_user }\n end\n end", "def set_type\n raise Error::NotFoundError unless (@type = Type.find(params[:id]))\n end", "def action_instances_tem\n type = params[:type]\n case type\n when \"edit_name\"\n respond_to do |format|\n @user = User.find(params[:data])\n if @user.update_attributes(full_name: params[:value])\n format.json { render json: @user }\n else\n format.json { render json: @user.errors.messages, status: :unprocessable_entity }\n end\n end\n\n when \"change_password\"\n respond_to do |format|\n @user = User.find(params[:data])\n if @user.valid_password?(params[:old_pass])\n if @user.update_attributes(password: params[:new_pass], password_confirmation: params[:new_pass])\n format.json { render json: @user }\n else\n format.json { render json: @user.errors.messages, status: :unprocessable_entity }\n end\n else\n format.json { render text: \"Current Password is incorrect\" }\n end\n end\n\n when \"long_create\"\n respond_to do |format|\n @current_title = CurrentTitle.find(params[:data])\n if @current_title.update_attributes(long_term: params[:value])\n format.json { render json: @current_title }\n else\n format.json { render json: @current_title.errors.messages, status: :unprocessable_entity }\n end\n end\n\n when \"long_edit\"\n respond_to do |format|\n @current_title = CurrentTitle.find(params[:data])\n if @current_title.update_attributes(long_term: params[:value])\n format.json { render json: @current_title }\n else\n format.json { render json: @current_title.errors.messages, status: :unprocessable_entity }\n end\n end\n\n when \"short_create\"\n respond_to do |format|\n @current_title = CurrentTitle.find(params[:data])\n if @current_title.update_attributes(short_term: params[:value])\n format.json { render json: @current_title }\n else\n format.json { render json: @current_title.errors.messages, status: :unprocessable_entity }\n end\n end\n \n when \"short_edit\"\n respond_to do |format|\n @current_title = CurrentTitle.find(params[:data])\n if @current_title.update_attributes(short_term: params[:value])\n format.json { render json: @current_title }\n else\n format.json { render json: @current_title.errors.messages, status: :unprocessable_entity }\n end\n end\n\n when \"delete_long\"\n respond_to do |format|\n @current_title = CurrentTitle.find(params[:data])\n @comments = Comment.where(current_title_id: params[:data], comment_type: \"long_term\")\n if @current_title.update_attributes(long_term: nil) && @comments.destroy_all\n format.json { render json: @current_title }\n else\n format.json { render json: @current_title.errors.messages, status: :unprocessable_entity }\n end\n end\n\n when \"delete_short\"\n respond_to do |format|\n @current_title = CurrentTitle.find(params[:data])\n @comments = Comment.where(current_title_id: params[:data], comment_type: \"short_term\")\n if @current_title.update_attributes(short_term: nil) && @comments.destroy_all\n format.json { render json: @current_title }\n else\n format.json { render json: @current_title.errors.messages, status: :unprocessable_entity }\n end\n end\n\n when \"create_comment\"\n p params[:comment], \"=================================\"\n comment_type = params[:comment_type] || nil\n sub_type = params[:sub_type] || nil\n obj_id = params[:obj_id] || nil\n\n respond_to do |format|\n @comment = Comment.new(comment: params[:comment], comment_type: sub_type, :\"#{comment_type}\" => obj_id, user_id: params[:data] )\n \n if @comment.save\n unless sub_type.eql?(\"\")\n owner_notification = Notification.create(user_id: params[:user_owner_id], obj_user_id: params[:data], notification_type: \"comment\", obj_id: obj_id, obj_type: \"#{comment_type}_#{sub_type}_owner\", is_seen: false) unless params[:user_owner_id].eql?(params[:data])\n if comment_type == \"evidence_id\"\n user_array = Evidence.find(obj_id).comments.map(&:user_id).uniq\n if user_array.length > 0\n user_array.delete(params[:user_owner_id].to_i)\n user_array.delete(params[:data].to_i)\n user_array.each do |user_id|\n notification = Notification.create(user_id: user_id, obj_user_id: params[:data], notification_type: \"comment\", obj_id: obj_id, obj_type: \"#{comment_type}_#{sub_type}\", is_seen: false)\n end\n end\n\n elsif comment_type == \"current_title_id\"\n user_array = CurrentTitle.find(obj_id).comments.map(&:user_id).uniq\n if user_array.length > 0\n user_array.delete(params[:user_owner_id].to_i)\n user_array.delete(params[:data].to_i)\n user_array.each do |user_id|\n notification = Notification.create(user_id: user_id, obj_user_id: params[:data], notification_type: \"comment\", obj_id: obj_id, obj_type: \"#{comment_type}_#{sub_type}\", is_seen: false)\n end\n end \n \n end \n else\n\n owner_notification = Notification.create(user_id: params[:user_owner_id], obj_user_id: params[:data], notification_type: \"comment\", obj_id: obj_id, obj_type: \"#{comment_type}_owner\", is_seen: false) unless params[:user_owner_id].eql?(params[:data])\n user_array = ShortTermObjective.find(obj_id).comments.map(&:user_id).uniq\n if user_array.length > 0\n user_array.delete(params[:user_owner_id].to_i)\n user_array.delete(params[:data].to_i)\n user_array.each do |user_id|\n notification = Notification.create(user_id: user_id, obj_user_id: params[:data], notification_type: \"comment\", obj_id: obj_id, obj_type: comment_type, is_seen: false)\n end\n end \n end\n \n format.json { render json: @comment }\n else\n format.json { render json: @comment.errors.messages, status: :unprocessable_entity }\n end\n end\n\n when \"edit_comment\"\n respond_to do |format|\n @comment = Comment.find(params[:data])\n if @comment.update_attributes(comment: params[:value])\n format.json { render json: @comment }\n else\n format.json { render json: @comment.errors.messages, status: :unprocessable_entity }\n end\n end\n\n when \"delete_comment\"\n respond_to do |format|\n @comment = Comment.find(params[:data])\n if @comment.destroy\n format.json { render json: @comment }\n else\n format.json { render json: @comment.errors.messages, status: :unprocessable_entity }\n end\n end\n\n when \"update_status\"\n respond_to do |format|\n @slot_assess = SlotAssess.find(params[:data])\n if @slot_assess.update_attributes(status: params[:status])\n format.json { render json: @slot_assess }\n else\n format.json { render json: @slot_assess.errors.messages, status: :unprocessable_entity }\n end\n end\n\n when \"create_short_term_objective\"\n @current_title = CurrentTitle.find(params[:data])\n\n @short_term_objective = ShortTermObjective.new(short_term: params[:short_term_objective], action_plan: params[:action_plan], target_date: params[:target_date], current_title_id: @current_title.id)\n respond_to do |format|\n if @short_term_objective.save\n format.json { render json: @short_term_objective }\n else\n format.json { render json: @short_term_objective.errors.messages, status: :unprocessable_entity }\n end\n end\n\n when \"edit_short_term_objective\"\n @short_term_objective = ShortTermObjective.find(params[:data])\n\n respond_to do |format|\n if @short_term_objective.update_attributes(short_term: params[:short_term_objective], action_plan: params[:action_plan], target_date: params[:target_date])\n format.json { render json: @short_term_objective }\n else\n format.json { render json: @short_term_objective.errors.messages, status: :unprocessable_entity }\n end\n end\n\n when \"delete_short_term_objective\"\n respond_to do |format|\n @short_term_objective = ShortTermObjective.find(params[:data])\n @comments = Comment.where(short_term_objective_id: params[:data])\n if @short_term_objective.destroy && @comments.destroy_all\n format.json { render json: @short_term_objective }\n else\n format.json { render json: @short_term_objective.errors.messages, status: :unprocessable_entity }\n end\n end\n \n when \"create_evidence\"\n slot_assess_ids = params[:values]\n evidence = params[:text]\n\n respond_to do |format|\n slot_assess_ids.each do |s|\n @evidence = Evidence.new(content: evidence, status: \"New\", slot_assess_id: s)\n unless @evidence.save\n format.json { render json: @evidence.errors.messages, status: :unprocessable_entity } \n end\n end\n format.json { render json: slot_assess_ids }\n end\n \n when \"edit_evidence\"\n @evidence = Evidence.find(params[:data])\n respond_to do |format|\n if @evidence.update_attributes(content: params[:value])\n format.json { render json: @evidence }\n else\n format.json { render json: @evidence.errors.messages, status: :unprocessable_entity }\n end\n end\n\n when \"delete_evidence\"\n respond_to do |format|\n @evidence = Evidence.find(params[:data])\n @comments = Comment.where(evidence_id: params[:data])\n if @evidence.destroy && @comments.destroy_all\n format.json { render json: @evidence }\n else\n format.json { render json: @evidence.errors.messages, status: :unprocessable_entity }\n end\n end\n\n when \"create_obj_evidence\"\n evidence = params[:text]\n obj_assess_id = params[:value]\n obj_type = params[:obj_type]\n\n respond_to do |format|\n\n @evidence = Evidence.new(content: evidence, status: \"New\", :\"#{obj_type}\" => obj_assess_id)\n if @evidence.save\n format.json { render json: @evidence }\n else\n format.json { render json: @evidence.errors.messages, status: :unprocessable_entity } \n end\n end\n\n when \"add_self_value\"\n respond_to do |format|\n @slot_assess = SlotAssess.find(params[:data])\n if @slot_assess.update_attributes(self_value: params[:self_value])\n format.json { render json: @slot_assess }\n else\n format.json { render json: @slot_assess.errors.messages, status: :unprocessable_entity }\n end\n end\n\n when \"add_self_score\"\n respond_to do |format|\n @other_subject_assess = OtherSubjectAssess.find(params[:data])\n if @other_subject_assess.update_attributes(self_score: params[:self_score])\n format.json { render json: @other_subject_assess }\n else\n format.json { render json: @other_subject_assess.errors.messages, status: :unprocessable_entity }\n end\n end\n\n when \"approve_slot_detail\"\n respond_to do |format|\n @slot_assess = SlotAssess.find(params[:data])\n approved_user = User.find(params[:approved_user_id])\n is_bod = params[:role]\n\n unless is_bod.eql?(\"\") #is bod\n p \"Bod\"\n if @slot_assess.update_attributes(value: params[:value], status: \"Passed\", approved_user_id: approved_user.id, is_notified: false)\n User.find(@slot_assess.user.id).update_attributes(new_approved: true)\n @notification2 = Notification.create(user_id: @slot_assess.user.id, obj_user_id: approved_user.id, notification_type: \"approve\", obj_id: @slot_assess.id, obj_type: \"slot\", is_seen: false)\n format.json { render json: @slot_assess }\n else\n format.json { render json: @slot_assess.errors.messages, status: :unprocessable_entity }\n end\n else\n p \"Manager\"\n if @slot_assess.update_attributes(value: params[:value], approved_user_id: approved_user.id, is_notified: true)\n \n # for teamleader notification\n if approved_user.is_team_leader\n # Notify to user\n notification1 = Notification.create(user_id: @slot_assess.user.id, obj_user_id: approved_user.id, notification_type: \"approve\", obj_id: @slot_assess.id, obj_type: \"slot\", is_seen: false)\n\n # Notify to manager -> submit\n manager = User.find(Department.find( @slot_assess.user.main_department_id).manager_id)\n notification2 = Notification.create(user_id: manager.id, obj_user_id: @slot_assess.user.id, notification_type: \"submit\", obj_id: @slot_assess.id, obj_type: \"slot\", is_seen: false)\n end\n\n # for manager notification\n if approved_user.is_manager\n # Notify to user\n @notification = Notification.create(user_id: @slot_assess.user.id, obj_user_id: approved_user.id, notification_type: \"approve\", obj_id: @slot_assess.id, obj_type: \"slot\", is_seen: false)\n \n # Notify to bod -> submit\n bod_users = User.where(is_bod: true).each do |bod_user|\n notification = Notification.create(user_id: bod_user.id, obj_user_id: @slot_assess.user.id, notification_type: \"submit\", obj_id: @slot_assess.id, obj_type: \"slot\", is_seen: false)\n end\n end\n\n # for bod notification\n \n \n format.json { render json: @slot_assess }\n else\n format.json { render json: @slot_assess.errors.messages, status: :unprocessable_entity }\n end\n end\n end\n\n when \"approve_other_subject_detail\"\n respond_to do |format|\n @other_subject_assess = OtherSubjectAssess.find(params[:data])\n approved_user = User.find(params[:approved_user_id])\n is_bod = params[:role]\n\n unless is_bod.eql?(\"\") #is bod\n p \"Bod\"\n if @other_subject_assess.update_attributes(status: \"Passed\", approved_user_id: approved_user.id, score: params[:score], is_notified: false)\n @notification2 = Notification.create(user_id: @other_subject_assess.user.id, obj_user_id: approved_user.id, notification_type: \"approve\", obj_id: @other_subject_assess.id, obj_type: \"other_subject\", is_seen: false)\n format.json { render json: @other_subject_assess }\n else\n format.json { render json: @other_subject_assess.errors.messages, status: :unprocessable_entity }\n end\n else\n p \"Manager\"\n if @other_subject_assess.update_attributes(approved_user_id: approved_user.id, score: params[:score], is_notified: true)\n \n # for teamleader notification\n if approved_user.is_team_leader\n # Notify to user\n notification1 = Notification.create(user_id: @other_subject_assess.user.id, obj_user_id: approved_user.id, obj_type: \"other_subject\", notification_type: \"approve\", obj_id: @other_subject_assess.id, is_seen: false)\n\n # Notify to manager -> submit\n manager = User.find(Department.find( @other_subject_assess.user.main_department_id).manager_id)\n notification2 = Notification.create(user_id: manager.id, obj_user_id: @other_subject_assess.user.id, notification_type: \"submit\", obj_id: @other_subject_assess.id, obj_type: \"other_subject\", is_seen: false)\n end\n\n # for manager notification\n if approved_user.is_manager\n # Notify to user\n @notification = Notification.create(user_id: @other_subject_assess.user.id, obj_user_id: approved_user.id, notification_type: \"approve\", obj_id: @other_subject_assess.id, obj_type: \"other_subject\", is_seen: false)\n \n # Notify to bod -> submit\n bod_users = User.where(is_bod: true).each do |bod_user|\n notification = Notification.create(user_id: bod_user.id, obj_user_id: @other_subject_assess.user.id, notification_type: \"submit\", obj_id: @other_subject_assess.id, obj_type: \"other_subject\", is_seen: false)\n end\n end\n\n # for bod notification\n \n \n format.json { render json: @other_subject_assess }\n else\n format.json { render json: @other_subject_assess.errors.messages, status: :unprocessable_entity }\n end\n end \n end\n\n when \"reject_slot_in_timeline\"\n respond_to do |format|\n @slot_assess = SlotAssess.find(params[:data])\n approved_user = User.find(params[:approved_user_id])\n is_bod = params[:role]\n\n unless is_bod.eql?(\"\") #is bod\n p \"Bod\"\n if @slot_assess.update_attributes(status: \"Not Passed\", approved_user_id: params[:approved_user_id], is_notified: false)\n notification1 = Notification.create(user_id: @slot_assess.user.id, obj_user_id: approved_user.id, notification_type: \"reject\", obj_id: @slot_assess.id, obj_type: \"slot\", is_seen: false)\n notification2 = Notification.create(user_id: Department.find(@slot_assess.user.main_department_id).manager_id, obj_user_id: approved_user.id, notification_type: \"return\", obj_id: @slot_assess.id, obj_type: \"slot\", is_seen: false)\n notification3 = Notification.create(user_id: @slot_assess.user.team_leader_id, obj_user_id: approved_user.id, notification_type: \"return\", obj_id: @slot_assess.id, obj_type: \"slot\", is_seen: false)\n format.json { render json: @slot_assess }\n else\n format.json { render json: @slot_assess.errors.messages, status: :unprocessable_entity }\n end\n else\n p \"Manager\"\n if @slot_assess.update_attributes(approved_user_id: params[:approved_user_id], is_notified: false)\n # for team leader & user notification\n if approved_user.is_manager\n notification1 = Notification.create(user_id: @slot_assess.user.id, obj_user_id: approved_user.id, notification_type: \"reject\", obj_id: @slot_assess.id, obj_type: \"slot\", is_seen: false)\n notification3 = Notification.create(user_id: @slot_assess.user.team_leader_id, obj_user_id: approved_user.id, notification_type: \"return\", obj_id: @slot_assess.id, obj_type: \"slot\", is_seen: false)\n end\n\n # for user notification\n if approved_user.is_team_leader\n notification1 = Notification.create(user_id: @slot_assess.user.id, obj_user_id: approved_user.id, notification_type: \"reject\", obj_id: @slot_assess.id, obj_type: \"slot\", is_seen: false)\n end\n \n format.json { render json: @slot_assess }\n else\n format.json { render json: @slot_assess.errors.messages, status: :unprocessable_entity }\n end\n end\n end\n \n when \"reject_slot_detail\"\n respond_to do |format|\n @slot_assess = SlotAssess.find(params[:data])\n value = params[:value] || 1\n approved_user = User.find(params[:approved_user_id])\n is_bod = params[:role]\n\n unless is_bod.eql?(\"\") #is bod\n p \"Bod\"\n if @slot_assess.update_attributes(value: value, status: \"Not Passed\", approved_user_id: params[:approved_user_id], is_notified: false)\n notification1 = Notification.create(user_id: @slot_assess.user.id, obj_user_id: approved_user.id, notification_type: \"reject\", obj_id: @slot_assess.id, obj_type: \"slot\", is_seen: false)\n notification2 = Notification.create(user_id: Department.find(@slot_assess.user.main_department_id).manager_id, obj_user_id: approved_user.id, notification_type: \"return\", obj_id: @slot_assess.id, obj_type: \"slot\", is_seen: false)\n notification3 = Notification.create(user_id: @slot_assess.user.team_leader_id, obj_user_id: approved_user.id, notification_type: \"return\", obj_id: @slot_assess.id, obj_type: \"slot\", is_seen: false)\n format.json { render json: @slot_assess }\n else\n format.json { render json: @slot_assess.errors.messages, status: :unprocessable_entity }\n end\n else\n p \"Manager\"\n if @slot_assess.update_attributes(value: value, approved_user_id: params[:approved_user_id], is_notified: false)\n # for team leader & user notification\n if approved_user.is_manager\n notification1 = Notification.create(user_id: @slot_assess.user.id, obj_user_id: approved_user.id, notification_type: \"reject\", obj_id: @slot_assess.id, obj_type: \"slot\", is_seen: false)\n notification3 = Notification.create(user_id: @slot_assess.user.team_leader_id, obj_user_id: approved_user.id, notification_type: \"return\", obj_id: @slot_assess.id, obj_type: \"slot\", is_seen: false)\n end\n\n # for user notification\n if approved_user.is_team_leader\n notification1 = Notification.create(user_id: @slot_assess.user.id, obj_user_id: approved_user.id, notification_type: \"reject\", obj_id: @slot_assess.id, obj_type: \"slot\", is_seen: false)\n end\n \n format.json { render json: @slot_assess }\n else\n format.json { render json: @slot_assess.errors.messages, status: :unprocessable_entity }\n end\n end\n end\n\n when \"reject_other_subject_detail\"\n respond_to do |format|\n @other_subject_assess = OtherSubjectAssess.find(params[:data])\n approved_user = User.find(params[:approved_user_id])\n is_bod = params[:role]\n\n unless is_bod.eql?(\"\") #is bod\n p \"Bod\"\n if @other_subject_assess.update_attributes(status: \"Not Passed\", approved_user_id: params[:approved_user_id], is_notified: false)\n notification1 = Notification.create(user_id: @other_subject_assess.user.id, obj_user_id: approved_user.id, notification_type: \"reject\", obj_id: @other_subject_assess.id, obj_type: \"other_subject\", is_seen: false)\n notification2 = Notification.create(user_id: Department.find(@other_subject_assess.user.main_department_id).manager_id, obj_user_id: approved_user.id, notification_type: \"return\", obj_id: @other_subject_assess.id, obj_type: \"other_subject\", is_seen: false)\n notification3 = Notification.create(user_id: @other_subject_assess.user.team_leader_id, obj_user_id: approved_user.id, notification_type: \"return\", obj_id: @other_subject_assess.id, obj_type: \"other_subject\", is_seen: false)\n format.json { render json: @other_subject_assess }\n else\n format.json { render json: @other_subject_assess.errors.messages, status: :unprocessable_entity }\n end\n else\n p \"Manager\"\n if @other_subject_assess.update_attributes(approved_user_id: params[:approved_user_id], is_notified: false)\n # for team leader & user notification\n if approved_user.is_manager\n notification1 = Notification.create(user_id: @other_subject_assess.user.id, obj_user_id: approved_user.id, notification_type: \"reject\", obj_id: @other_subject_assess.id, obj_type: \"other_subject\", is_seen: false)\n notification3 = Notification.create(user_id: @other_subject_assess.user.team_leader_id, obj_user_id: approved_user.id, notification_type: \"return\", obj_id: @other_subject_assess.id, obj_type: \"other_subject\", is_seen: false)\n end\n\n # for user notification\n if approved_user.is_team_leader\n notification1 = Notification.create(user_id: @other_subject_assess.user.id, obj_user_id: approved_user.id, notification_type: \"reject\", obj_id: @other_subject_assess.id, obj_type: \"other_subject\", is_seen: false)\n end\n \n format.json { render json: @other_subject_assess }\n else\n format.json { render json: @other_subject_assess.errors.messages, status: :unprocessable_entity }\n end\n end \n end\n\n when \"withdraw_slot_detail\"\n respond_to do |format|\n @slot_assess = SlotAssess.find(params[:data])\n @user = User.find(@slot_assess.user.id)\n\n \n if @user.team_leader_id\n\n @notification = Notification.where(user_id: @user.team_leader_id, obj_user_id: @user.id, obj_id: @slot_assess.id, obj_type: \"slot\", notification_type: \"submit\").order(\"created_at desc\").first\n if @notification\n if @notification.destroy\n @slot_assess.update_attributes(is_notified: false)\n format.json { render json: @slot_assess }\n else\n format.json { render json: @slot_assess.errors.messages, status: :unprocessable_entity }\n end\n else\n format.text { render text: \"Can't withdraw slot assess without having been notified yet.\"}\n end\n else\n format.text { render text: \"This user's team leader is not availble. Please contact your Administrator to resolve.\"}\n end\n\n end\n\n when \"withdraw_other_subject_detail\"\n respond_to do |format|\n @other_subject_assesses = OtherSubjectAssess.find(params[:data])\n @user = User.find(@other_subject_assesses.user.id)\n\n \n if @user.team_leader_id\n @notification = Notification.where(user_id: @user.team_leader_id, obj_user_id: @user.id, obj_id: @other_subject_assesses.id, obj_type: \"other_subject\", notification_type: \"submit\").order(\"created_at desc\").first\n if @notification\n if @notification.destroy\n @other_subject_assesses.update_attributes(is_notified: false)\n format.json { render json: @other_subject_assesses }\n else\n format.json { render json: @other_subject_assesses.errors.messages, status: :unprocessable_entity }\n end\n else\n format.text { render text: \"Can't withdraw other subject assess without having been notified yet.\"}\n end\n else\n format.text { render text: \"This user's team leader is not availble. Please contact your Administrator to resolve.\"}\n end\n\n end\n\n when \"notify_for_detail\"\n respond_to do |format|\n @slot_assess = SlotAssess.find(params[:data])\n if @slot_assess.self_value\n @user = User.find(@slot_assess.user.id)\n\n if @user.team_leader_id\n @notification = Notification.new(user_id: @user.team_leader_id, obj_user_id: @user.id, notification_type: \"submit\", obj_id: @slot_assess.id, obj_type: \"slot\", is_seen: false)\n if @notification.save\n @slot_assess.update_attributes(is_notified: true)\n format.json { render json: @slot_assess }\n else\n format.json { render json: @slot_assess.errors.messages, status: :unprocessable_entity }\n end\n else\n format.text { render text: \"This user's team leader is not availble. Please contact your Administrator to resolve.\"}\n end\n else\n format.text { render text: \"Please add your self assessment before notify to your manager\"}\n end\n\n end\n\n when \"notify_for_other_subject_detail\"\n respond_to do |format|\n @other_subject_assess = OtherSubjectAssess.find(params[:data])\n if @other_subject_assess.self_score\n @user = User.find(@other_subject_assess.user.id)\n\n if @user.team_leader_id\n @notification = Notification.new(user_id: @user.team_leader_id, obj_user_id: @user.id, notification_type: \"submit\", obj_id: @other_subject_assess.id, obj_type: \"other_subject\", is_seen: false)\n if @notification.save\n @other_subject_assess.update_attributes(is_notified: true)\n format.json { render json: @other_subject_assess }\n else\n format.json { render json: @other_subject_assess.errors.messages, status: :unprocessable_entity }\n end\n else\n format.text { render text: \"This user's team leader is not availble. Please contact your Administrator to resolve.\"}\n end\n else\n format.text { render text: \"Please add your assessment result before notify to your manager\"}\n end\n\n end\n\n when \"update_notification_is_seen\"\n notification_type = []\n notification_type.push(params[:notification_type])\n if params[:notification_type] == \"approve\"\n notification_type.push(\"submit\")\n end\n\n if params[:notification_type] == \"reject\"\n notification_type.push(\"return\")\n end\n\n @user = User.find(params[:data])\n rs = false\n respond_to do |format|\n if @user.notifications.where(notification_type: notification_type).length > 0\n @user.notifications.where(notification_type: notification_type).each do |notification|\n if notification.update_attributes(is_seen: true)\n rs = true\n else\n rs = false\n end\n\n unless rs\n format.json { render json: @user.errors.messages, status: :unprocessable_entity }\n end\n end\n\n if rs\n format.json { render json: @user }\n end\n else\n format.json { render json: @user }\n end\n\n end\n\n\n end\n\n end", "def create\n @type = Type.new(params[:type])\n the_name = @type.name\n\n if the_name.empty?\n redirect_to types_path, notice: 'Type a little, pick something from the list, hit the button!'\n else\n old_name = Type.where({name: @type.name}).first\n\n if old_name\n redirect_to old_name\n else\n\n the_name.slice! 'New: \"'\n the_name.chop!\n the_name.capitalize!\n @type.name = the_name\n @type.owner = current_user\n @type.active = false\n\n \n respond_to do |format|\n if @type.save\n #format.html { redirect_to edit_type_path(@type), notice: \"Congrats! Your the first to reveiw a #{@type.name}, what is it?\" }\n format.html { redirect_to check_type_path(@type), notice: \"Looking for #{@type.name}?\" }\n format.json { render json: @type, status: :created, location: @type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @type.errors, status: :unprocessable_entity }\n end\n end\n end\n end\n end", "def show\n @type = Type.find(params[:id])\n end", "def set_resourcetype\n @resourcetype = Resourcetype.find(params[:id])\n end" ]
[ "0.76273173", "0.7608862", "0.7608862", "0.68890697", "0.67971057", "0.67481714", "0.6651089", "0.6613869", "0.6268525", "0.61668247", "0.6166034", "0.6166034", "0.6136154", "0.60745776", "0.6074244", "0.6074244", "0.6074244", "0.6074244", "0.6074244", "0.6056657", "0.59500253", "0.59227246", "0.5907492", "0.5844681", "0.57758945", "0.57732433", "0.5766952", "0.57013375", "0.5694119", "0.5677488", "0.5674591", "0.5664176", "0.5663783", "0.5660222", "0.5654301", "0.56466645", "0.5640937", "0.5636211", "0.5620971", "0.56154114", "0.56013805", "0.56013805", "0.56013805", "0.5599031", "0.55912274", "0.5589502", "0.5580818", "0.5575457", "0.55723655", "0.55639046", "0.55594426", "0.5552181", "0.5535413", "0.5535347", "0.5533641", "0.55195796", "0.55157965", "0.55156547", "0.5508697", "0.5508697", "0.5508392", "0.55046284", "0.5503922", "0.54973674", "0.5496813", "0.5489402", "0.54588956", "0.5443917", "0.54402685", "0.5437892", "0.54332095", "0.54317737", "0.54294777", "0.5420545", "0.5405008", "0.5404699", "0.54023325", "0.5401607", "0.5397536", "0.53912926", "0.5389644", "0.53844184", "0.5382783", "0.53764164", "0.5345748", "0.5343449", "0.5343433", "0.5341168", "0.53396094", "0.5339038", "0.53364736", "0.533518", "0.53337353", "0.53276175", "0.5326187", "0.5320814", "0.53155464", "0.5312696", "0.53121364", "0.5311574" ]
0.662102
7
GET /space_types/1 GET /space_types/1.json
def show respond_to do |format| format.js format.html end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @space_types = @space_types.order(:name)\n respond_to do |format|\n format.js\n format.html\n end\n end", "def set_space_type\n @space_type = SpaceType.find(params[:id])\n end", "def show\n if params[:term]\n @types = Type.all(:conditions => ['typeName LIKE ?', \"%#{params[:term]}%\"])\n else\n @type = Type.find(params[:id])\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @types }\n end\n end", "def set_space_type\n @space_type = SpaceType.find(params[:id])\n end", "def set_space_type\n @space_type = SpaceType.find(params[:id])\n end", "def destroy\n @space_type.destroy\n respond_to do |format|\n format.html { redirect_to space_types_url, status: 303 }\n format.json { head :no_content }\n end\n end", "def index\n @spaces = Space.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @spaces }\n end\n end", "def show\n @space = Space.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @space }\n end\n end", "def create\n @space_type = SpaceType.new(space_type_params)\n authorize! :create, @space_type\n\n respond_to do |format|\n if @space_type.save\n format.html { redirect_to @space_type, notice: t('.create_ok') }\n format.json { render action: 'show', status: :created, location: @space_type }\n else\n format.html { render action: 'new' }\n format.json { render json: @space_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @types = Type.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @types.lookup(params[:q]) }\n end\n end", "def space_type_params\n params.require(:space_type).permit(:name)\n end", "def index\n render json: Space.all\n end", "def show\n @myspace = Myspace.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @myspace }\n end\n end", "def show\n @space_cat = SpaceCat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @space_cat }\n end\n end", "def show\n @gl_type = GlType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @gl_type }\n end\n end", "def show\n @segment_type = SegmentType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @segment_type }\n end\n end", "def get_resource_types\n Occi::Log.debug(\"Getting resource types ...\")\n collection = @model.get Occi::Core::Resource.kind\n collection.kinds.collect { |kind| kind.term }\n end", "def show\n @os_type = OsType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @os_type }\n end\n end", "def index\n render json: usage(params[:type])\n end", "def index\n if params['user_id']\n @user = User.find(params['user_id'])\n @spaces = @user.spaces.visible_by(current_user)\n else\n @spaces = Space.visible_by(current_user).first(10)\n end\n #render json: @spaces.as_json(only: [:id, :name, :description, :updated_at, :user_id])\n render json: SpacesRepresenter.new(@spaces).to_json\n end", "def index\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @resource_types }\n end\n end", "def index\n @types = Type.all\n end", "def show\n @all_type=Api::V1::AdminType.all\n render json: @all_type\n end", "def type\n @json['type']\n end", "def type\n response[\"type\"]\n end", "def type\n response[\"type\"]\n end", "def index\n @costtypes = Costtype.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @costtypes }\n end\n end", "def index\n @identifier_types = IdentifierType.order(:position).page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @identifier_types }\n end\n end", "def show\n @dash_type = DashType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dash_type }\n end\n end", "def index\n authorize @thing, :get_types?\n @thing_types = @thing.thing_types\n end", "def index\n authorize CarrierType\n @carrier_types = CarrierType.order(:position)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @carrier_types }\n end\n end", "def type\r\n\t\t\t`#{BITS::BITSADMIN} /gettype {#{@id}}`\r\n\t\tend", "def index\n @crate_types = CrateType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @crate_types }\n end\n end", "def index\n @trait_types = TraitType.all\n\n render json: @trait_types\n end", "def update_space_type_params\n params.require(:space_type).permit(:id, :name)\n end", "def type\n @gapi[\"type\"]\n end", "def add_space_type(template, clim, building_type, spc_type)\n #OpenStudio::logFree(OpenStudio::Info, 'openstudio.standards.Model', \"Adding space type: #{template}-#{clim}-#{building_type}-#{spc_type}\")\n\n # Get the space type data\n data = self.find_object(self.standards['space_types'], {'template'=>template, 'building_type'=>building_type, 'space_type'=>spc_type})\n if !data\n OpenStudio::logFree(OpenStudio::Warn, 'openstudio.standards.Model', \"Cannot find data for space type: #{template}-#{clim}-#{building_type}-#{spc_type}, will not be created.\")\n return false #TODO change to return empty optional schedule:ruleset?\n end\n \n name = make_name(template, clim, building_type, spc_type)\n\n # Create a new space type and name it\n space_type = OpenStudio::Model::SpaceType.new(self)\n space_type.setName(name)\n\n # Set the standards building type and space type for this new space type\n space_type.setStandardsBuildingType(building_type)\n space_type.setStandardsSpaceType(spc_type)\n\n # Set the rendering color of the space type\n rgb = data['rgb']\n rgb = rgb.split('_')\n r = rgb[0].to_i\n g = rgb[1].to_i\n b = rgb[2].to_i\n rendering_color = OpenStudio::Model::RenderingColor.new(self)\n rendering_color.setRenderingRedValue(r)\n rendering_color.setRenderingGreenValue(g)\n rendering_color.setRenderingBlueValue(b)\n space_type.setRenderingColor(rendering_color)\n\n # Create the schedule set for the space type\n default_sch_set = OpenStudio::Model::DefaultScheduleSet.new(self)\n default_sch_set.setName(\"#{name} Schedule Set\")\n space_type.setDefaultScheduleSet(default_sch_set)\n\n # Lighting\n make_lighting = false\n lighting_per_area = data['lighting_per_area']\n lighting_per_person = data['lighting_per_person']\n unless lighting_per_area == 0 || lighting_per_area.nil? then make_lighting = true end\n unless lighting_per_person == 0 || lighting_per_person.nil? then make_lighting = true end\n\n if make_lighting == true\n\n # Create the lighting definition\n lights_def = OpenStudio::Model::LightsDefinition.new(self)\n lights_def.setName(\"#{name} Lights Definition\")\n lights_frac_to_return_air = data['lighting_fraction_to_return_air']\n lights_frac_radiant = data['lighting_fraction_radiant']\n lights_frac_visible = data['lighting_fraction_visible']\n unless lighting_per_area == 0 || lighting_per_area.nil?\n lights_def.setWattsperSpaceFloorArea(OpenStudio.convert(lighting_per_area, 'W/ft^2', 'W/m^2').get)\n lights_def.setReturnAirFraction(lights_frac_to_return_air)\n lights_def.setFractionRadiant(lights_frac_radiant)\n lights_def.setFractionVisible(lights_frac_visible)\n end\n unless lighting_per_person == 0 || lighting_per_person.nil?\n lights_def.setWattsperPerson(OpenStudio.convert(lighting_per_person, 'W/person', 'W/person').get)\n lights_def.setReturnAirFraction(lights_frac_to_return_air)\n lights_def.setFractionRadiant(lights_frac_radiant)\n lights_def.setFractionVisible(lights_frac_visible)\n end\n\n # Create the lighting instance and hook it up to the space type\n lights = OpenStudio::Model::Lights.new(lights_def)\n lights.setName(\"#{name} Lights\")\n lights.setSpaceType(space_type)\n\n # Additional Lighting\n additional_lighting_per_area = data['additional_lighting_per_area']\n if additional_lighting_per_area != nil\n # Create the lighting definition\n additional_lights_def = OpenStudio::Model::LightsDefinition.new(self)\n additional_lights_def.setName(\"#{name} Additional Lights Definition\")\n additional_lights_def.setWattsperSpaceFloorArea(OpenStudio.convert(additional_lighting_per_area, 'W/ft^2', 'W/m^2').get)\n additional_lights_def.setReturnAirFraction(lights_frac_to_return_air)\n additional_lights_def.setFractionRadiant(lights_frac_radiant)\n additional_lights_def.setFractionVisible(lights_frac_visible)\n\n # Create the lighting instance and hook it up to the space type\n additional_lights = OpenStudio::Model::Lights.new(additional_lights_def)\n additional_lights.setName(\"#{name} Additional Lights\")\n additional_lights.setSpaceType(space_type)\n end\n\n # Get the lighting schedule and set it as the default\n lighting_sch = data['lighting_schedule']\n unless lighting_sch.nil?\n default_sch_set.setLightingSchedule(add_schedule(lighting_sch))\n end\n end\n\n # Ventilation\n\n make_ventilation = false\n ventilation_per_area = data['ventilation_per_area']\n ventilation_per_person = data['ventilation_per_person']\n ventilation_ach = data['ventilation_air_changes']\n unless ventilation_per_area == 0 || ventilation_per_area.nil? then make_ventilation = true end\n unless ventilation_per_person == 0 || ventilation_per_person.nil? then make_ventilation = true end\n unless ventilation_ach == 0 || ventilation_ach.nil? then make_ventilation = true end\n\n\n if make_ventilation == true\n\n # Create the ventilation object and hook it up to the space type\n ventilation = OpenStudio::Model::DesignSpecificationOutdoorAir.new(self)\n ventilation.setName(\"#{name} Ventilation\")\n puts \"#{name}\"\n space_type.setDesignSpecificationOutdoorAir(ventilation)\n ventilation.setOutdoorAirMethod('Sum')\n unless ventilation_per_area.nil? || ventilation_per_area.to_f == 0\n ventilation.setOutdoorAirFlowperFloorArea(OpenStudio.convert(ventilation_per_area, 'ft^3/min*ft^2', 'm^3/s*m^2').get)\n end\n unless ventilation_per_person.nil? || ventilation_per_person.to_f == 0\n ventilation.setOutdoorAirFlowperPerson(OpenStudio.convert(ventilation_per_person, 'ft^3/min*person', 'm^3/s*person').get)\n end\n unless ventilation_ach.nil? || ventilation_ach.to_f == 0\n ventilation.setOutdoorAirFlowAirChangesperHour(ventilation_ach)\n end\n end\n\n # Occupancy\n\n make_people = false\n occupancy_per_area = data['occupancy_per_area']\n unless occupancy_per_area == 0 || occupancy_per_area.nil? then make_people = true end\n\n if make_people == true\n # create the people definition\n people_def = OpenStudio::Model::PeopleDefinition.new(self)\n people_def.setName(\"#{name} People Definition\")\n unless occupancy_per_area == 0 || occupancy_per_area.nil?\n people_def.setPeopleperSpaceFloorArea(OpenStudio.convert(occupancy_per_area / 1000.0, 'people/ft^2', 'people/m^2').get)\n end\n\n # create the people instance and hook it up to the space type\n people = OpenStudio::Model::People.new(people_def)\n people.setName(\"#{name} People\")\n people.setSpaceType(space_type)\n\n # get the occupancy and occupant activity schedules from the library and set as the default\n occupancy_sch = data['occupancy_schedule']\n unless occupancy_sch.nil?\n default_sch_set.setNumberofPeopleSchedule(add_schedule(occupancy_sch))\n end\n occupancy_activity_sch = data['occupancy_activity_schedule']\n unless occupancy_activity_sch.nil?\n default_sch_set.setPeopleActivityLevelSchedule(add_schedule(occupancy_activity_sch))\n end\n\n end\n\n # Infiltration\n\n make_infiltration = false\n infiltration_per_area_ext = data['infiltration_per_exterior_area']\n infiltration_per_area_ext_wall = data['infiltration_per_exterior_wall_area']\n infiltration_ach = data['infiltration_air_changes']\n unless (infiltration_per_area_ext == 0 || infiltration_per_area_ext.nil?) && (infiltration_per_area_ext_wall == 0 || infiltration_per_area_ext_wall.nil?) && (infiltration_ach == 0 || infiltration_ach.nil?) \n then make_infiltration = true\n end\n\n if make_infiltration == true\n\n # Create the infiltration object and hook it up to the space type\n infiltration = OpenStudio::Model::SpaceInfiltrationDesignFlowRate.new(self)\n infiltration.setName(\"#{name} Infiltration\")\n infiltration.setSpaceType(space_type)\n unless infiltration_per_area_ext == 0 || infiltration_per_area_ext.nil?\n infiltration.setFlowperExteriorSurfaceArea(OpenStudio.convert(infiltration_per_area_ext, 'ft^3/min*ft^2', 'm^3/s*m^2').get)\n end\n unless infiltration_per_area_ext_wall == 0 || infiltration_per_area_ext_wall.nil?\n infiltration.setFlowperExteriorWallArea(OpenStudio.convert(infiltration_per_area_ext_wall, 'ft^3/min*ft^2', 'm^3/s*m^2').get)\n end\n unless infiltration_ach == 0 || infiltration_ach.nil?\n infiltration.setAirChangesperHour(infiltration_ach)\n end\n\n # Get the infiltration schedule from the library and set as the default\n infiltration_sch = data['infiltration_schedule']\n unless infiltration_sch.nil?\n default_sch_set.setInfiltrationSchedule(add_schedule(infiltration_sch))\n end\n\n end\n\n # Electric equipment\n\n make_electric_equipment = false\n elec_equip_per_area = data['electric_equipment_per_area']\n elec_equip_frac_latent = data['electric_equipment_fraction_latent']\n elec_equip_frac_radiant = data['electric_equipment_fraction_radiant']\n elec_equip_frac_lost = data['electric_equipment_fraction_lost']\n unless elec_equip_per_area == 0 || elec_equip_per_area.nil? then make_electric_equipment = true end\n\n if make_electric_equipment == true\n\n # Create the electric equipment definition\n elec_equip_def = OpenStudio::Model::ElectricEquipmentDefinition.new(self)\n elec_equip_def.setName(\"#{name} Electric Equipment Definition\")\n unless elec_equip_per_area == 0 || elec_equip_per_area.nil?\n elec_equip_def.setWattsperSpaceFloorArea(OpenStudio.convert(elec_equip_per_area, 'W/ft^2', 'W/m^2').get)\n elec_equip_def.setFractionLatent(elec_equip_frac_latent)\n elec_equip_def.setFractionRadiant(elec_equip_frac_radiant)\n elec_equip_def.setFractionLost(elec_equip_frac_lost)\n end\n\n # Create the electric equipment instance and hook it up to the space type\n elec_equip = OpenStudio::Model::ElectricEquipment.new(elec_equip_def)\n elec_equip.setName(\"#{name} Electric Equipment\")\n elec_equip.setSpaceType(space_type)\n\n # Get the electric equipment schedule from the library and set as the default\n elec_equip_sch = data['electric_equipment_schedule']\n unless elec_equip_sch.nil?\n default_sch_set.setElectricEquipmentSchedule(add_schedule(elec_equip_sch))\n end\n\n end\n\n # Gas equipment\n\n make_gas_equipment = false\n gas_equip_per_area = data['gas_equipment_per_area']\n gas_equip_frac_latent = data['gas_equipment_fraction_latent']\n gas_equip_frac_radiant = data['gas_equipment_fraction_radiant']\n gas_equip_frac_lost = data['gas_equipment_fraction_lost']\n\n unless gas_equip_per_area == 0 || gas_equip_per_area.nil? then make_gas_equipment = true end\n\n if make_gas_equipment == true\n\n # Create the gas equipment definition\n gas_equip_def = OpenStudio::Model::GasEquipmentDefinition.new(self)\n gas_equip_def.setName(\"#{name} Gas Equipment Definition\")\n gas_equip_def.setFractionLatent(gas_equip_frac_latent)\n gas_equip_def.setFractionRadiant(gas_equip_frac_radiant)\n gas_equip_def.setFractionLost(gas_equip_frac_lost)\n unless gas_equip_per_area == 0 || gas_equip_per_area.nil?\n gas_equip_def.setWattsperSpaceFloorArea(OpenStudio.convert(gas_equip_per_area, 'Btu/hr*ft^2', 'W/m^2').get)\n end\n\n # Create the gas equipment instance and hook it up to the space type\n gas_equip = OpenStudio::Model::GasEquipment.new(gas_equip_def)\n gas_equip.setName(\"#{name} Gas Equipment\")\n gas_equip.setSpaceType(space_type)\n\n # Get the gas equipment schedule from the library and set as the default\n gas_equip_sch = data['gas_equipment_schedule']\n unless gas_equip_sch.nil?\n default_sch_set.setGasEquipmentSchedule(add_schedule(gas_equip_sch))\n end\n\n end\n\n thermostat = OpenStudio::Model::ThermostatSetpointDualSetpoint.new(self)\n thermostat.setName(\"#{name} Thermostat\")\n\n heating_setpoint_sch = data['heating_setpoint_schedule']\n unless heating_setpoint_sch.nil?\n thermostat.setHeatingSetpointTemperatureSchedule(add_schedule(heating_setpoint_sch))\n end\n\n cooling_setpoint_sch = data['cooling_setpoint_schedule']\n unless cooling_setpoint_sch.nil?\n thermostat.setCoolingSetpointTemperatureSchedule(add_schedule(cooling_setpoint_sch))\n end\n\n # componentize the space type\n space_type_component = space_type.createComponent\n\n # #TODO make this return BCL component space types?\n #\n # #setup the file names and save paths that will be used\n # file_name = \"nrel_ref_bldg_space_type\"\n # component_dir = \"#{Dir.pwd}/#{component_name}\"\n # osm_file_path = OpenStudio::Path.new(\"#{component_dir}/files/#{file_name}.osm\")\n # osc_file_path = OpenStudio::Path.new(\"#{component_dir}/files/#{file_name}.osc\")\n #\n # #OpenStudio::logFree(OpenStudio::Info, 'openstudio.standards.Model', \"component_dir = #{component_dir}\")\n #\n # OpenStudio::logFree(OpenStudio::Info, 'openstudio.standards.Model', \"creating directories\")\n # FileUtils.rm_rf(component_dir) if File.exists?(component_dir) and File.directory?(component_dir)\n # FileUtils.mkdir_p(component_dir)\n # FileUtils.mkdir_p(\"#{component_dir}/files/\")\n #\n # #save the space type as a .osm\n # #OpenStudio::logFree(OpenStudio::Info, 'openstudio.standards.Model', \"saving osm to #{osm_file_path}\")\n # model.toIdfFile().save(osm_file_path,true)\n #\n # #save the componentized space type as a .osc\n # #OpenStudio::logFree(OpenStudio::Info, 'openstudio.standards.Model', \"saving osc to #{osc_file_path}\")\n # space_type_component.toIdfFile().save(osc_file_path,true)\n #\n # #make the BCL component\n # OpenStudio::logFree(OpenStudio::Info, 'openstudio.standards.Model', \"creating BCL component\")\n # component = BCL::Component.new(component_dir)\n # OpenStudio::logFree(OpenStudio::Info, 'openstudio.standards.Model', \"created uid = #{component.uuid}\")\n #\n # #add component information\n # component.name = component_name\n # component.description = \"This space type represent spaces in typical commercial buildings in the United States. The information to create these space types was taken from the DOE Commercial Reference Building Models, which can be found at http://www1.eere.energy.gov/buildings/commercial_initiative/reference_buildings.html. These space types include plug loads, gas equipment loads (cooking, etc), occupancy, infiltration, and ventilation rates, as well as schedules. These space types should be viewed as starting points, and should be reviewed before being used to make decisions.\"\n # component.source_manufacturer = \"DOE\"\n # component.source_url = \"http://www1.eere.energy.gov/buildings/commercial_initiative/reference_buildings.html\"\n # component.add_provenance(\"dgoldwas\", Time.now.gmtime.strftime('%Y-%m-%dT%H:%M:%SZ'), \"\")\n # component.add_tag(\"Space Types\") # todo: what is the taxonomy string for space type? is there one?\n #\n # #add arguments as attributes\n # component.add_attribute(\"NREL_reference_building_vintage\", template, \"\")\n # component.add_attribute(\"Climate_zone\", clim, \"\")\n # component.add_attribute(\"NREL_reference_building_primary_space_type\", building_type, \"\")\n # component.add_attribute(\"NREL_reference_building_secondary_space_type\", spc_type, \"\")\n #\n # #openstudio type attribute\n # component.add_attribute(\"OpenStudio Type\", space_type.iddObjectType.valueDescription, \"\")\n #\n # #add other attributes\n # component.add_attribute(\"Lighting Standard\", data[\"lighting_standard\"], \"\")\n # component.add_attribute(\"Lighting Primary Space Type\", data[\"lighting_pri_spc_type\"], \"\")\n # component.add_attribute(\"Lighting Secondary Space Type\", data[\"lighting_sec_spc_type\"], \"\")\n #\n # component.add_attribute(\"Ventilation Standard\", data[\"ventilation_standard\"], \"\")\n # component.add_attribute(\"Ventilation Primary Space Type\", data[\"ventilation_pri_spc_type\"], \"\")\n # component.add_attribute(\"Ventilation Secondary Space Type\", data[\"ventilation_sec_spc_type\"], \"\")\n #\n # component.add_attribute(\"Occupancy Standard\", \"NREL reference buildings\", \"\")\n # component.add_attribute(\"Occupancy Primary Space Type\", building_type, \"\")\n # component.add_attribute(\"Occupancy Secondary Space Type\", spc_type, \"\")\n #\n # component.add_attribute(\"Infiltration, Gas Equipment, Electric Equipment, and Schedules Standard\", \"NREL reference buildings\", \"\")\n # component.add_attribute(\"Infiltration, Gas Equipment, Electric Equipment, and Schedules Primary Space Type\", building_type, \"\")\n # component.add_attribute(\"Infiltration, Gas Equipment, Electric Equipment, and Schedules Secondary Space Type\", spc_type, \"\")\n #\n # #add the osm and osc files to the component\n # component.add_file(\"OpenStudio\", \"0.9.3\", osm_file_path.to_s, \"#{file_name}.osm\", \"osm\")\n # component.add_file(\"OpenStudio\", \"0.9.3\", osc_file_path.to_s, \"#{file_name}.osc\", \"osc\")\n #\n # #OpenStudio::logFree(OpenStudio::Info, 'openstudio.standards.Model', \"saving component to #{component_dir}\")\n # component.save_component_xml(component_dir)\n #\n # =e\n # return the space type and the componentized space type\n \n return space_type\n \n end", "def new\n @space = Space.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @space }\n end\n end", "def index\n @weapon_types = WeaponType.all\n\n render json: @weapon_types\n end", "def show\n @site_type = SiteType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @site_type }\n end\n end", "def index\n @taxonomies = Taxonomy.find_all_by_taxonomy_type(params[:taxonomy_type].presence || 'category')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @taxonomies }\n end\n end", "def get_lesson_types\n get \"lessonTypes.json\"\n end", "def show\n @type = Type.find(params[:id])\n end", "def index\n @types = ItemType.all\n end", "def show\n @cg_table_type = CgTableType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cg_table_type }\n end\n end", "def show\n @boxtype = Boxtype.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @boxtype }\n end\n end", "def get_storage_types\n JSON.parse(RestClient.get(\"https://#{region.sub(/-\\d$/, '')}.power-iaas.cloud.ibm.com/broker/v1/storage-types\", headers))[region]\n end", "def show\n render json: @trait_type\n end", "def update\n respond_to do |format|\n old_name = @space_type.name\n if @space_type.update(space_type_params)\n @space_type.spaces.each { |s| s.touch }\n format.html { redirect_to @space_type, notice: t('.update_ok') }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @space_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @crate_type = CrateType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @crate_type }\n end\n end", "def show\n @types_of_apprenticeship = TypesOfApprenticeship.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @types_of_apprenticeship }\n end\n end", "def index\n @discipline_types = DisciplineType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @discipline_types }\n end\n end", "def index\n @grouptypes = Grouptype.all\n end", "def index\n @hardware_types = HardwareType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @hardware_types }\n end\n end", "def show\n @type = Type.find(params[:id])\n @things = @type.things\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @type }\n end\n end", "def show\n @ctype = Ctype.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ctype }\n end\n end", "def show\n @page_type = PageType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @page_type }\n end\n end", "def show\n @collection_type = CollectionType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @collection_type }\n end\n end", "def show\n respond_to do |format|\n format.html\n format.json { render json: @typegroup }\n end\n end", "def new\n @myspace = Myspace.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @myspace }\n end\n end", "def getPageInfoByIDType(id, type)\n request('getPageInfoByIDType', {'id' => id, 'type' => type})\nend", "def index\n @entry_types = EntryType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @entry_types }\n end\n end", "def index\n @session_types = SessionType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @session_types }\n end\n end", "def show\n @structure_type = StructureType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @structure_type }\n end\n end", "def get_space(opts = {})\n data, _status_code, _headers = get_space_with_http_info(opts)\n return data\n end", "def index\n @cloth_types = ClothType.all\n end", "def index\n @typegroups = Typegroup.all\n respond_to do |format|\n format.html\n format.json { render json: @typegroups }\n end\n end", "def get_universe_types_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: UniverseApi.get_universe_types ...\"\n end\n if opts[:'datasource'] && !['tranquility', 'singularity'].include?(opts[:'datasource'])\n fail ArgumentError, 'invalid value for \"datasource\", must be one of tranquility, singularity'\n end\n if !opts[:'page'].nil? && opts[:'page'] < 1\n fail ArgumentError, 'invalid value for \"opts[:\"page\"]\" when calling UniverseApi.get_universe_types, must be greater than or equal to 1.'\n end\n\n # resource path\n local_var_path = \"/universe/types/\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'datasource'] = opts[:'datasource'] if !opts[:'datasource'].nil?\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'user_agent'] = opts[:'user_agent'] if !opts[:'user_agent'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n header_params[:'X-User-Agent'] = opts[:'x_user_agent'] if !opts[:'x_user_agent'].nil?\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = []\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 => 'Array<Integer>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: UniverseApi#get_universe_types\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n @language_types = LanguageType.all\n\n render json: @language_types\n end", "def find_space_in_system(slug, params={}, headers=default_headers)\n @logger.info(\"Retrieving Space \\\"#{slug}\\\"\")\n get(\"#{@api_url}/spaces/#{slug}\", params, headers)\n end", "def get_scene_type(scene_type_id)\n get \"commandcenter/scenetypes/#{scene_type_id}\"\n end", "def show\n @instance_type = InstanceType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @instance_type }\n end\n end", "def get_zones_per_space_type(space_type)\n list_of_zones = []\n model_space_type = @model.getSpaceTypeByName(space_type.name.get).get\n model_space_type.spaces.each do |space|\n list_of_zones << space.thermalZone.get\n end\n return list_of_zones\n end", "def types\n @title = 'Resource Type Listing A-Z'\n @objects_by_letter = objects_by_letter(:puppet_type)\n erb(:objects)\nend", "def types\n if @@types.nil? || (@@last_type_check + (4 * 60 * 60)) < Time.now\n @@last_type_check = Time.now\n @@types = _make_request(:types)['results']\n end\n @@types\n end", "def index\n @run_types = RunType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @run_types }\n end\n end", "def show\n @contract_type = ContractType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @contract_type }\n end\n end", "def index\n @os_types = OsType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @os_types, except: [:desc, :created_at, :updated_at] } \n end\n end", "def get_semester_outype\n path = \"/d2l/api/lp/#{$lp_ver}/outypes/semester\"\n _get(path)\n # returns OrgUnitType JSON data block\nend", "def type\n @activities = Activity.tagged_with_on(:types,params[:type_name]).page params[:page]\n respond_with @activities\n end", "def index\n @techaxis_types = TechaxisType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @techaxis_types }\n end\n end", "def show\n @spaceship = Spaceship.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @spaceship }\n end\n end", "def show\n @service_type = ServiceType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @service_type }\n end\n end", "def show\n @contractor_type = ContractorType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @contractor_type }\n end\n end", "def show\n @stock_type = StockType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @stock_type }\n end\n end", "def index\n @equipament_types = EquipamentType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @equipament_types }\n end\n end", "def index\n @space = Space.find(params[:space_id])\n @leases = Lease.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @leases }\n end\n end", "def court_types\n render json: GamePass.court_types_options\n end", "def show\n @resource_fields = Field.where(\"resource_type_id = ?\", params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @resource_type }\n end\n end", "def index\n @segment_types = SegmentType.all\n end", "def show\n render json: @weapon_type\n end", "def show\n @space_user = SpaceUser.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @space_user }\n end\n end", "def index\n @comm_types = CommType.all\n end", "def index\n @ctypes = Ctype.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ctypes }\n end\n end", "def index\n @material_types = MaterialType.all\n\n render json: @material_types\n end", "def lookup(type)\n @resource_types[type] || []\n end", "def show\n @api_v1_user_types = Api::V1::UserType.all\n end", "def index\n @sample_types = SampleType.all.sort_by(&:name)\n @first = if @sample_types.any?\n @sample_types[0].name\n else\n 'no sample types'\n end\n\n respond_to do |format|\n format.html { render layout: 'aq2' }\n format.json do\n render json: @sample_types\n .sort { |a, b| a.name <=> b.name }\n .to_json(methods: :field_types)\n end\n end\n end", "def show\n @session_type = SessionType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @session_type }\n end\n end", "def show\n @entry_type = EntryType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @entry_type }\n end\n end", "def show\n @fieldtype = Fieldtype.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @fieldtype }\n end\n end" ]
[ "0.66851836", "0.64573693", "0.64471376", "0.6391785", "0.6391785", "0.6383449", "0.62726235", "0.61619806", "0.6093615", "0.6086681", "0.6030398", "0.601878", "0.59964496", "0.5983734", "0.5979993", "0.5892507", "0.58694977", "0.5853532", "0.5845269", "0.5833435", "0.58294415", "0.5807572", "0.57327914", "0.5728818", "0.57158846", "0.57158846", "0.5714563", "0.57101023", "0.570487", "0.5698117", "0.56928444", "0.56889176", "0.56880426", "0.5682228", "0.56743044", "0.56651056", "0.5645779", "0.56453204", "0.5644226", "0.56357145", "0.5632032", "0.56310564", "0.5629413", "0.5622195", "0.5611838", "0.560059", "0.55991364", "0.55968136", "0.55962706", "0.55823034", "0.5579188", "0.5560875", "0.5558604", "0.5546124", "0.55455416", "0.55411166", "0.5540161", "0.5535503", "0.5534812", "0.55341005", "0.55280113", "0.5521963", "0.5519428", "0.55153036", "0.5513167", "0.5511327", "0.55093473", "0.55034953", "0.5503008", "0.5497731", "0.5497453", "0.54962945", "0.54959285", "0.54905397", "0.54845065", "0.54775524", "0.5475172", "0.545941", "0.5458192", "0.5452577", "0.5450981", "0.5446785", "0.54454815", "0.54393363", "0.5438801", "0.5435896", "0.5435271", "0.5432918", "0.54191166", "0.5418041", "0.5414571", "0.541401", "0.54139626", "0.54135823", "0.54069054", "0.5405781", "0.5401182", "0.539908", "0.53962225", "0.53951067", "0.5393405" ]
0.0
-1
POST /space_types POST /space_types.json
def create @space_type = SpaceType.new(space_type_params) authorize! :create, @space_type respond_to do |format| if @space_type.save format.html { redirect_to @space_type, notice: t('.create_ok') } format.json { render action: 'show', status: :created, location: @space_type } else format.html { render action: 'new' } format.json { render json: @space_type.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def space_type_params\n params.require(:space_type).permit(:name)\n end", "def update_space_type_params\n params.require(:space_type).permit(:id, :name)\n end", "def add_space_type(template, clim, building_type, spc_type)\n #OpenStudio::logFree(OpenStudio::Info, 'openstudio.standards.Model', \"Adding space type: #{template}-#{clim}-#{building_type}-#{spc_type}\")\n\n # Get the space type data\n data = self.find_object(self.standards['space_types'], {'template'=>template, 'building_type'=>building_type, 'space_type'=>spc_type})\n if !data\n OpenStudio::logFree(OpenStudio::Warn, 'openstudio.standards.Model', \"Cannot find data for space type: #{template}-#{clim}-#{building_type}-#{spc_type}, will not be created.\")\n return false #TODO change to return empty optional schedule:ruleset?\n end\n \n name = make_name(template, clim, building_type, spc_type)\n\n # Create a new space type and name it\n space_type = OpenStudio::Model::SpaceType.new(self)\n space_type.setName(name)\n\n # Set the standards building type and space type for this new space type\n space_type.setStandardsBuildingType(building_type)\n space_type.setStandardsSpaceType(spc_type)\n\n # Set the rendering color of the space type\n rgb = data['rgb']\n rgb = rgb.split('_')\n r = rgb[0].to_i\n g = rgb[1].to_i\n b = rgb[2].to_i\n rendering_color = OpenStudio::Model::RenderingColor.new(self)\n rendering_color.setRenderingRedValue(r)\n rendering_color.setRenderingGreenValue(g)\n rendering_color.setRenderingBlueValue(b)\n space_type.setRenderingColor(rendering_color)\n\n # Create the schedule set for the space type\n default_sch_set = OpenStudio::Model::DefaultScheduleSet.new(self)\n default_sch_set.setName(\"#{name} Schedule Set\")\n space_type.setDefaultScheduleSet(default_sch_set)\n\n # Lighting\n make_lighting = false\n lighting_per_area = data['lighting_per_area']\n lighting_per_person = data['lighting_per_person']\n unless lighting_per_area == 0 || lighting_per_area.nil? then make_lighting = true end\n unless lighting_per_person == 0 || lighting_per_person.nil? then make_lighting = true end\n\n if make_lighting == true\n\n # Create the lighting definition\n lights_def = OpenStudio::Model::LightsDefinition.new(self)\n lights_def.setName(\"#{name} Lights Definition\")\n lights_frac_to_return_air = data['lighting_fraction_to_return_air']\n lights_frac_radiant = data['lighting_fraction_radiant']\n lights_frac_visible = data['lighting_fraction_visible']\n unless lighting_per_area == 0 || lighting_per_area.nil?\n lights_def.setWattsperSpaceFloorArea(OpenStudio.convert(lighting_per_area, 'W/ft^2', 'W/m^2').get)\n lights_def.setReturnAirFraction(lights_frac_to_return_air)\n lights_def.setFractionRadiant(lights_frac_radiant)\n lights_def.setFractionVisible(lights_frac_visible)\n end\n unless lighting_per_person == 0 || lighting_per_person.nil?\n lights_def.setWattsperPerson(OpenStudio.convert(lighting_per_person, 'W/person', 'W/person').get)\n lights_def.setReturnAirFraction(lights_frac_to_return_air)\n lights_def.setFractionRadiant(lights_frac_radiant)\n lights_def.setFractionVisible(lights_frac_visible)\n end\n\n # Create the lighting instance and hook it up to the space type\n lights = OpenStudio::Model::Lights.new(lights_def)\n lights.setName(\"#{name} Lights\")\n lights.setSpaceType(space_type)\n\n # Additional Lighting\n additional_lighting_per_area = data['additional_lighting_per_area']\n if additional_lighting_per_area != nil\n # Create the lighting definition\n additional_lights_def = OpenStudio::Model::LightsDefinition.new(self)\n additional_lights_def.setName(\"#{name} Additional Lights Definition\")\n additional_lights_def.setWattsperSpaceFloorArea(OpenStudio.convert(additional_lighting_per_area, 'W/ft^2', 'W/m^2').get)\n additional_lights_def.setReturnAirFraction(lights_frac_to_return_air)\n additional_lights_def.setFractionRadiant(lights_frac_radiant)\n additional_lights_def.setFractionVisible(lights_frac_visible)\n\n # Create the lighting instance and hook it up to the space type\n additional_lights = OpenStudio::Model::Lights.new(additional_lights_def)\n additional_lights.setName(\"#{name} Additional Lights\")\n additional_lights.setSpaceType(space_type)\n end\n\n # Get the lighting schedule and set it as the default\n lighting_sch = data['lighting_schedule']\n unless lighting_sch.nil?\n default_sch_set.setLightingSchedule(add_schedule(lighting_sch))\n end\n end\n\n # Ventilation\n\n make_ventilation = false\n ventilation_per_area = data['ventilation_per_area']\n ventilation_per_person = data['ventilation_per_person']\n ventilation_ach = data['ventilation_air_changes']\n unless ventilation_per_area == 0 || ventilation_per_area.nil? then make_ventilation = true end\n unless ventilation_per_person == 0 || ventilation_per_person.nil? then make_ventilation = true end\n unless ventilation_ach == 0 || ventilation_ach.nil? then make_ventilation = true end\n\n\n if make_ventilation == true\n\n # Create the ventilation object and hook it up to the space type\n ventilation = OpenStudio::Model::DesignSpecificationOutdoorAir.new(self)\n ventilation.setName(\"#{name} Ventilation\")\n puts \"#{name}\"\n space_type.setDesignSpecificationOutdoorAir(ventilation)\n ventilation.setOutdoorAirMethod('Sum')\n unless ventilation_per_area.nil? || ventilation_per_area.to_f == 0\n ventilation.setOutdoorAirFlowperFloorArea(OpenStudio.convert(ventilation_per_area, 'ft^3/min*ft^2', 'm^3/s*m^2').get)\n end\n unless ventilation_per_person.nil? || ventilation_per_person.to_f == 0\n ventilation.setOutdoorAirFlowperPerson(OpenStudio.convert(ventilation_per_person, 'ft^3/min*person', 'm^3/s*person').get)\n end\n unless ventilation_ach.nil? || ventilation_ach.to_f == 0\n ventilation.setOutdoorAirFlowAirChangesperHour(ventilation_ach)\n end\n end\n\n # Occupancy\n\n make_people = false\n occupancy_per_area = data['occupancy_per_area']\n unless occupancy_per_area == 0 || occupancy_per_area.nil? then make_people = true end\n\n if make_people == true\n # create the people definition\n people_def = OpenStudio::Model::PeopleDefinition.new(self)\n people_def.setName(\"#{name} People Definition\")\n unless occupancy_per_area == 0 || occupancy_per_area.nil?\n people_def.setPeopleperSpaceFloorArea(OpenStudio.convert(occupancy_per_area / 1000.0, 'people/ft^2', 'people/m^2').get)\n end\n\n # create the people instance and hook it up to the space type\n people = OpenStudio::Model::People.new(people_def)\n people.setName(\"#{name} People\")\n people.setSpaceType(space_type)\n\n # get the occupancy and occupant activity schedules from the library and set as the default\n occupancy_sch = data['occupancy_schedule']\n unless occupancy_sch.nil?\n default_sch_set.setNumberofPeopleSchedule(add_schedule(occupancy_sch))\n end\n occupancy_activity_sch = data['occupancy_activity_schedule']\n unless occupancy_activity_sch.nil?\n default_sch_set.setPeopleActivityLevelSchedule(add_schedule(occupancy_activity_sch))\n end\n\n end\n\n # Infiltration\n\n make_infiltration = false\n infiltration_per_area_ext = data['infiltration_per_exterior_area']\n infiltration_per_area_ext_wall = data['infiltration_per_exterior_wall_area']\n infiltration_ach = data['infiltration_air_changes']\n unless (infiltration_per_area_ext == 0 || infiltration_per_area_ext.nil?) && (infiltration_per_area_ext_wall == 0 || infiltration_per_area_ext_wall.nil?) && (infiltration_ach == 0 || infiltration_ach.nil?) \n then make_infiltration = true\n end\n\n if make_infiltration == true\n\n # Create the infiltration object and hook it up to the space type\n infiltration = OpenStudio::Model::SpaceInfiltrationDesignFlowRate.new(self)\n infiltration.setName(\"#{name} Infiltration\")\n infiltration.setSpaceType(space_type)\n unless infiltration_per_area_ext == 0 || infiltration_per_area_ext.nil?\n infiltration.setFlowperExteriorSurfaceArea(OpenStudio.convert(infiltration_per_area_ext, 'ft^3/min*ft^2', 'm^3/s*m^2').get)\n end\n unless infiltration_per_area_ext_wall == 0 || infiltration_per_area_ext_wall.nil?\n infiltration.setFlowperExteriorWallArea(OpenStudio.convert(infiltration_per_area_ext_wall, 'ft^3/min*ft^2', 'm^3/s*m^2').get)\n end\n unless infiltration_ach == 0 || infiltration_ach.nil?\n infiltration.setAirChangesperHour(infiltration_ach)\n end\n\n # Get the infiltration schedule from the library and set as the default\n infiltration_sch = data['infiltration_schedule']\n unless infiltration_sch.nil?\n default_sch_set.setInfiltrationSchedule(add_schedule(infiltration_sch))\n end\n\n end\n\n # Electric equipment\n\n make_electric_equipment = false\n elec_equip_per_area = data['electric_equipment_per_area']\n elec_equip_frac_latent = data['electric_equipment_fraction_latent']\n elec_equip_frac_radiant = data['electric_equipment_fraction_radiant']\n elec_equip_frac_lost = data['electric_equipment_fraction_lost']\n unless elec_equip_per_area == 0 || elec_equip_per_area.nil? then make_electric_equipment = true end\n\n if make_electric_equipment == true\n\n # Create the electric equipment definition\n elec_equip_def = OpenStudio::Model::ElectricEquipmentDefinition.new(self)\n elec_equip_def.setName(\"#{name} Electric Equipment Definition\")\n unless elec_equip_per_area == 0 || elec_equip_per_area.nil?\n elec_equip_def.setWattsperSpaceFloorArea(OpenStudio.convert(elec_equip_per_area, 'W/ft^2', 'W/m^2').get)\n elec_equip_def.setFractionLatent(elec_equip_frac_latent)\n elec_equip_def.setFractionRadiant(elec_equip_frac_radiant)\n elec_equip_def.setFractionLost(elec_equip_frac_lost)\n end\n\n # Create the electric equipment instance and hook it up to the space type\n elec_equip = OpenStudio::Model::ElectricEquipment.new(elec_equip_def)\n elec_equip.setName(\"#{name} Electric Equipment\")\n elec_equip.setSpaceType(space_type)\n\n # Get the electric equipment schedule from the library and set as the default\n elec_equip_sch = data['electric_equipment_schedule']\n unless elec_equip_sch.nil?\n default_sch_set.setElectricEquipmentSchedule(add_schedule(elec_equip_sch))\n end\n\n end\n\n # Gas equipment\n\n make_gas_equipment = false\n gas_equip_per_area = data['gas_equipment_per_area']\n gas_equip_frac_latent = data['gas_equipment_fraction_latent']\n gas_equip_frac_radiant = data['gas_equipment_fraction_radiant']\n gas_equip_frac_lost = data['gas_equipment_fraction_lost']\n\n unless gas_equip_per_area == 0 || gas_equip_per_area.nil? then make_gas_equipment = true end\n\n if make_gas_equipment == true\n\n # Create the gas equipment definition\n gas_equip_def = OpenStudio::Model::GasEquipmentDefinition.new(self)\n gas_equip_def.setName(\"#{name} Gas Equipment Definition\")\n gas_equip_def.setFractionLatent(gas_equip_frac_latent)\n gas_equip_def.setFractionRadiant(gas_equip_frac_radiant)\n gas_equip_def.setFractionLost(gas_equip_frac_lost)\n unless gas_equip_per_area == 0 || gas_equip_per_area.nil?\n gas_equip_def.setWattsperSpaceFloorArea(OpenStudio.convert(gas_equip_per_area, 'Btu/hr*ft^2', 'W/m^2').get)\n end\n\n # Create the gas equipment instance and hook it up to the space type\n gas_equip = OpenStudio::Model::GasEquipment.new(gas_equip_def)\n gas_equip.setName(\"#{name} Gas Equipment\")\n gas_equip.setSpaceType(space_type)\n\n # Get the gas equipment schedule from the library and set as the default\n gas_equip_sch = data['gas_equipment_schedule']\n unless gas_equip_sch.nil?\n default_sch_set.setGasEquipmentSchedule(add_schedule(gas_equip_sch))\n end\n\n end\n\n thermostat = OpenStudio::Model::ThermostatSetpointDualSetpoint.new(self)\n thermostat.setName(\"#{name} Thermostat\")\n\n heating_setpoint_sch = data['heating_setpoint_schedule']\n unless heating_setpoint_sch.nil?\n thermostat.setHeatingSetpointTemperatureSchedule(add_schedule(heating_setpoint_sch))\n end\n\n cooling_setpoint_sch = data['cooling_setpoint_schedule']\n unless cooling_setpoint_sch.nil?\n thermostat.setCoolingSetpointTemperatureSchedule(add_schedule(cooling_setpoint_sch))\n end\n\n # componentize the space type\n space_type_component = space_type.createComponent\n\n # #TODO make this return BCL component space types?\n #\n # #setup the file names and save paths that will be used\n # file_name = \"nrel_ref_bldg_space_type\"\n # component_dir = \"#{Dir.pwd}/#{component_name}\"\n # osm_file_path = OpenStudio::Path.new(\"#{component_dir}/files/#{file_name}.osm\")\n # osc_file_path = OpenStudio::Path.new(\"#{component_dir}/files/#{file_name}.osc\")\n #\n # #OpenStudio::logFree(OpenStudio::Info, 'openstudio.standards.Model', \"component_dir = #{component_dir}\")\n #\n # OpenStudio::logFree(OpenStudio::Info, 'openstudio.standards.Model', \"creating directories\")\n # FileUtils.rm_rf(component_dir) if File.exists?(component_dir) and File.directory?(component_dir)\n # FileUtils.mkdir_p(component_dir)\n # FileUtils.mkdir_p(\"#{component_dir}/files/\")\n #\n # #save the space type as a .osm\n # #OpenStudio::logFree(OpenStudio::Info, 'openstudio.standards.Model', \"saving osm to #{osm_file_path}\")\n # model.toIdfFile().save(osm_file_path,true)\n #\n # #save the componentized space type as a .osc\n # #OpenStudio::logFree(OpenStudio::Info, 'openstudio.standards.Model', \"saving osc to #{osc_file_path}\")\n # space_type_component.toIdfFile().save(osc_file_path,true)\n #\n # #make the BCL component\n # OpenStudio::logFree(OpenStudio::Info, 'openstudio.standards.Model', \"creating BCL component\")\n # component = BCL::Component.new(component_dir)\n # OpenStudio::logFree(OpenStudio::Info, 'openstudio.standards.Model', \"created uid = #{component.uuid}\")\n #\n # #add component information\n # component.name = component_name\n # component.description = \"This space type represent spaces in typical commercial buildings in the United States. The information to create these space types was taken from the DOE Commercial Reference Building Models, which can be found at http://www1.eere.energy.gov/buildings/commercial_initiative/reference_buildings.html. These space types include plug loads, gas equipment loads (cooking, etc), occupancy, infiltration, and ventilation rates, as well as schedules. These space types should be viewed as starting points, and should be reviewed before being used to make decisions.\"\n # component.source_manufacturer = \"DOE\"\n # component.source_url = \"http://www1.eere.energy.gov/buildings/commercial_initiative/reference_buildings.html\"\n # component.add_provenance(\"dgoldwas\", Time.now.gmtime.strftime('%Y-%m-%dT%H:%M:%SZ'), \"\")\n # component.add_tag(\"Space Types\") # todo: what is the taxonomy string for space type? is there one?\n #\n # #add arguments as attributes\n # component.add_attribute(\"NREL_reference_building_vintage\", template, \"\")\n # component.add_attribute(\"Climate_zone\", clim, \"\")\n # component.add_attribute(\"NREL_reference_building_primary_space_type\", building_type, \"\")\n # component.add_attribute(\"NREL_reference_building_secondary_space_type\", spc_type, \"\")\n #\n # #openstudio type attribute\n # component.add_attribute(\"OpenStudio Type\", space_type.iddObjectType.valueDescription, \"\")\n #\n # #add other attributes\n # component.add_attribute(\"Lighting Standard\", data[\"lighting_standard\"], \"\")\n # component.add_attribute(\"Lighting Primary Space Type\", data[\"lighting_pri_spc_type\"], \"\")\n # component.add_attribute(\"Lighting Secondary Space Type\", data[\"lighting_sec_spc_type\"], \"\")\n #\n # component.add_attribute(\"Ventilation Standard\", data[\"ventilation_standard\"], \"\")\n # component.add_attribute(\"Ventilation Primary Space Type\", data[\"ventilation_pri_spc_type\"], \"\")\n # component.add_attribute(\"Ventilation Secondary Space Type\", data[\"ventilation_sec_spc_type\"], \"\")\n #\n # component.add_attribute(\"Occupancy Standard\", \"NREL reference buildings\", \"\")\n # component.add_attribute(\"Occupancy Primary Space Type\", building_type, \"\")\n # component.add_attribute(\"Occupancy Secondary Space Type\", spc_type, \"\")\n #\n # component.add_attribute(\"Infiltration, Gas Equipment, Electric Equipment, and Schedules Standard\", \"NREL reference buildings\", \"\")\n # component.add_attribute(\"Infiltration, Gas Equipment, Electric Equipment, and Schedules Primary Space Type\", building_type, \"\")\n # component.add_attribute(\"Infiltration, Gas Equipment, Electric Equipment, and Schedules Secondary Space Type\", spc_type, \"\")\n #\n # #add the osm and osc files to the component\n # component.add_file(\"OpenStudio\", \"0.9.3\", osm_file_path.to_s, \"#{file_name}.osm\", \"osm\")\n # component.add_file(\"OpenStudio\", \"0.9.3\", osc_file_path.to_s, \"#{file_name}.osc\", \"osc\")\n #\n # #OpenStudio::logFree(OpenStudio::Info, 'openstudio.standards.Model', \"saving component to #{component_dir}\")\n # component.save_component_xml(component_dir)\n #\n # =e\n # return the space type and the componentized space type\n \n return space_type\n \n end", "def space_type_params\n params.require(:space_type).permit(\n :name, :short_name, :spaces_count, :notes,\n equipment_items_attributes: [:id, :qty, :notes, :equipment_model_id, :_destroy] )\n end", "def assign_space_type_stubs(building_type, space_type_map)\n\n space_type_map.each do |space_type_name, space_names|\n # Create a new space type\n stub_space_type = OpenStudio::Model::SpaceType.new(self)\n stub_space_type.setStandardsBuildingType(building_type)\n stub_space_type.setStandardsSpaceType(space_type_name)\n \n space_names.each do |space_name|\n space = self.getSpaceByName(space_name)\n next if space.empty?\n space = space.get\n space.setSpaceType(stub_space_type)\n\n #OpenStudio::logFree(OpenStudio::Info, 'openstudio.model.Model', \"Setting #{space.name} to #{building_type}.#{space_type_name}\")\n end\n end\n\n return true\n end", "def create_bldg_space_types(model)\n @building_sections.each do |bldg_subsec|\n bldg_subsec.create_space_types(model, @total_floor_area, num_stories, @standard_template, @open_studio_standard)\n end\n end", "def create_types\n @types.each do |type|\n create_type(type) unless Type.where(name: type['name']).first\n end\n end", "def create_types\n\t\t[]\n\tend", "def create_types\n\t\t[]\n\tend", "def set_space_type\n @space_type = SpaceType.find(params[:id])\n end", "def set_space_type\n @space_type = SpaceType.find(params[:id])\n end", "def create_types\n\t[]\nend", "def create_types\n\t[]\nend", "def set_space_type\n @space_type = SpaceType.find(params[:id])\n end", "def create_types\n\t[Domain]\nend", "def destroy\n @space_type.destroy\n respond_to do |format|\n format.html { redirect_to space_types_url, status: 303 }\n format.json { head :no_content }\n end\n end", "def create\n @type = Type.new(type_params)\n\n unless @type.save\n render json: @type.errors, status: :unprocessable_entity\n end\n \n end", "def create\n section_type_ids = params[:site_type].delete(\"section_type_ids\")\n @site_type = SiteType.new(params[:site_type])\n @site_type.section_type_ids = section_type_ids\n\n respond_to do |format|\n if @site_type.save\n format.html { redirect_to @site_type, notice: 'Site type was successfully created.' }\n format.json { render json: @site_type, status: :created, location: @site_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @site_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def type_params\n params.from_jsonapi.require(:type).permit(:name)\n end", "def index\n @space_types = @space_types.order(:name)\n respond_to do |format|\n format.js\n format.html\n end\n end", "def create\n field_type_ids = params[:entry_type].delete(\"field_type_ids\")\n @entry_type = EntryType.new(params[:entry_type])\n @entry_type.field_type_ids = field_type_ids\n @entry_type.form_code = build_form_code(@entry_type.field_types)\n @entry_type.model_code = build_model_code(@entry_type.name, @entry_type.field_types)\n @entry_type.model = build_model_from_code(@entry_type)\n\n respond_to do |format|\n if @entry_type.save\n format.html { redirect_to @entry_type, notice: 'Entry type was successfully created.' }\n format.json { render json: @entry_type, status: :created, location: @entry_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @entry_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def types\n commit('types', nil)\n end", "def space_params\n params.require(:space).permit(:name, :spaceType, :multiplier, :area)\n end", "def create\n @space = Space.new(params[:space])\n\n respond_to do |format|\n if @space.save\n format.html { redirect_to @space, notice: 'Space was successfully created.' }\n format.json { render json: @space, status: :created, location: @space }\n else\n format.html { render action: \"new\" }\n format.json { render json: @space.errors, status: :unprocessable_entity }\n end\n end\n end", "def type_params\n params.require(:type).permit( :name)\n end", "def create\n @space = Space.new(space_params)\n\n respond_to do |format|\n if @space.save\n format.html { redirect_to root_path, notice: \"Space was successfully created.\" }\n format.json { render :show, status: :created, location: @space }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @space.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @space = Space.new(space_params)\n @space.user = current_user\n if @space.save\n render json: @space\n else\n render json: @space.errors, status: :unprocessable_entity\n end\n end", "def create\n @space = Space.new(space_params)\n\n respond_to do |format|\n if @space.save\n format.html { redirect_to @space, notice: 'Space was successfully created.' }\n format.json { render action: 'show', status: :created, location: @space }\n else\n format.html { render action: 'new' }\n format.json { render json: @space.errors, status: :unprocessable_entity }\n end\n end\n end", "def node_type_params\n params.require(:node_type).permit(:name, :destroyable)\n end", "def create\n @os_type = OsType.new(params[:os_type])\n\n respond_to do |format|\n if @os_type.save\n format.html { redirect_to @os_type, notice: 'Os type was successfully created.' }\n format.json { render json: @os_type, status: :created, location: @os_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @os_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_dummy_type\n params[:data] ||= {}\n params[:data][:type] = resource_klass._type.to_s\n end", "def create\n @gl_type = GlType.new(gl_type_params)\n\n respond_to do |format|\n if @gl_type.save\n format.html { redirect_to gl_types_path, notice: 'Gl type was successfully created.' }\n format.json { render json: @gl_type, status: :created, location: @gl_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @gl_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_types\n\t\t[Device]\n\tend", "def create_types\n\t\t[Device]\n\tend", "def create\n @segment_type = SegmentType.new(params[:segment_type])\n\n respond_to do |format|\n if @segment_type.save\n format.html { redirect_to @segment_type, notice: 'Segment type was successfully created.' }\n format.json { render json: @segment_type, status: :created, location: @segment_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @segment_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def space_params\n params.require(:space).permit(:calendar_frequency, \n :listing_weekly_price_native, \n :title, :summary,\n :bedrooms, :beds, :bathrooms, :bed_style, :home_style, :room_style, :person_capacity, \n :directions, \n :country_code, :street_address, :apt_ste_bld, :city, :state, :postal_code)\n end", "def type_params\n params.require(:type).permit(:name)\n end", "def update\n respond_to do |format|\n old_name = @space_type.name\n if @space_type.update(space_type_params)\n @space_type.spaces.each { |s| s.touch }\n format.html { redirect_to @space_type, notice: t('.update_ok') }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @space_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @collection = current_user.collections.find(params[:collection_id])\n @entity_type = @collection.entity_types.new(params[:entity_type])\n\n respond_to do |format|\n if @entity_type.save\n format.html { redirect_to collection_entity_types_path(@collection), notice: 'Type was successfully created.' }\n format.json { render json: @entity_type, status: :created, location: @entity_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @entity_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @range_type = RangeType.new(range_type_params)\n\n respond_to do |format|\n if @range_type.save\n format.html { redirect_to @range_type, notice: 'Range type was successfully created.' }\n format.json { render :show, status: :created, location: @range_type }\n else\n format.html { render :new }\n format.json { render json: @range_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def shipment_type_params\n params.require(:shipment_type).permit(:shipment_type_id, :type_name)\n end", "def create\n\n @object_type = ObjectType.new(params[:object_type].except(:rows, :columns))\n\n if params[:object_type][:handler] == 'collection'\n @object_type.rows = params[:object_type][:rows]\n @object_type.columns = params[:object_type][:columns]\n end\n\n respond_to do |format|\n if @object_type.save\n format.html { redirect_to object_types_url, notice: \"Object type #{@object_type.name} was successfully created.\" }\n format.json { render json: @object_type, status: :created, location: @object_type }\n else\n format.html { render action: 'new', layout: 'aq2-plain' }\n format.json { render json: @object_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @q_type = QType.new(q_type_params)\n\n respond_to do |format|\n if @q_type.save\n format.html { redirect_to @q_type, notice: 'Q type was successfully created.' }\n format.json { render :show, status: :created, location: @q_type }\n else\n format.html { render :new }\n format.json { render json: @q_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def os_type_params\n params.require(:os_type).permit(:name, :description, :egc_server_type_id)\n end", "def create\n @segment_type = SegmentType.new(segment_type_params)\n\n respond_to do |format|\n if @segment_type.save\n format.html { redirect_to @segment_type, notice: 'Segment type was successfully created.' }\n format.json { render :show, status: :created, location: @segment_type }\n else\n format.html { render :new }\n format.json { render json: @segment_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def evals_types\n call_path = \"evals/types\"\n data = build_post_data(\"\")\n perform_post(build_url(call_path), data)\n end", "def build_space_type_hash\n space_type_hash = {}\n if @space_types\n space_type_list = []\n @space_types.each do |space_name, space_type|\n space_type_list << space_type[:space_type]\n end\n space_type_hash[xget_id] = space_type_list\n end\n @building_sections.each do |bldg_subsec|\n space_type_list = []\n bldg_subsec.space_types_floor_area.each do |space_type, hash|\n space_type_list << space_type\n end\n space_type_hash[bldg_subsec.xget_id] = space_type_list\n end\n return space_type_hash\n end", "def create\n @space_cat = SpaceCat.new(params[:space_cat])\n\n respond_to do |format|\n if @space_cat.save\n format.html { redirect_to @space_cat, notice: 'Space cat was successfully created.' }\n format.json { render json: @space_cat, status: :created, location: @space_cat }\n else\n format.html { render action: \"new\" }\n format.json { render json: @space_cat.errors, status: :unprocessable_entity }\n end\n end\n end", "def type_params\n params.require(:type).permit(:common_name, :botanical_name, :info_panel, :count)\n end", "def process_post_typenames_and_namespaces()\n type_names_node_set = @request_body_xml.xpath('//csw:DescribeRecord//csw:TypeName',\n 'csw' => 'http://www.opengis.net/cat/csw/2.0.2')\n if (type_names_node_set != nil && type_names_node_set.size > 0)\n @type_names = []\n @namespaces = {}\n namespace_definitions = @request_body_xml.root.namespaces\n type_names_node_set.each do |type_name|\n # must work around to present indetical hashes for model validation for both GET and POST\n node_namespace_prefix_orig = type_name.text.split(':')[0]\n if (node_namespace_prefix_orig == type_name.text)\n # no namespace\n node_namespace_prefix = 'xmlns'\n node_namespace_prefix_orig = 'default'\n else\n node_namespace_prefix = \"xmlns:#{node_namespace_prefix_orig}\"\n end\n node_namespace_href = namespace_definitions[node_namespace_prefix]\n if !node_namespace_href.nil?\n @namespaces[node_namespace_prefix_orig.to_sym] = node_namespace_href\n end\n @type_names << type_name.text\n end\n else\n @type_names = []\n end\n if (@namespaces.nil? || @namespaces.empty?)\n @namespaces = {:gmi => 'http://www.isotc211.org/2005/gmi'}\n end\n end", "def create\n @os_type = OsType.new(os_type_params)\n\n respond_to do |format|\n if @os_type.save\n format.html { redirect_to @os_type, notice: 'Os type was successfully created.' }\n format.json { render :show, status: :created, location: @os_type }\n else\n format.html { render :new }\n format.json { render json: @os_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @newspace = current_user.created_spaces.new(space_params)\n\n respond_to do |format|\n if @newspace.save && update_subscription(@newspace)\n\n current_user.spaces << @newspace # Creates the join record to add the admin to this space\n\n format.html { redirect_to space_members_path(@newspace), notice: 'Space was successfully created.' }\n format.json { render :show, status: :created, location: @newspace }\n else\n format.html { render :new }\n format.json { render json: @mewspace.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @page_type = PageType.new(params[:page_type])\n\n respond_to do |format|\n if @page_type.save\n format.html { redirect_to @page_type, notice: 'Page type was successfully created.' }\n format.json { render json: @page_type, status: :created, location: @page_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @page_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @myspace = Myspace.new(params[:myspace])\n\n respond_to do |format|\n if @myspace.save\n format.html { redirect_to @myspace, notice: 'Myspace was successfully created.' }\n format.json { render json: @myspace, status: :created, location: @myspace }\n else\n format.html { render action: \"new\" }\n format.json { render json: @myspace.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @method_type = MethodType.new(method_type_params)\n\n respond_to do |format|\n if @method_type.save\n format.html { redirect_to @method_type, notice: \"Method type was successfully created.\" }\n format.json { render :show, status: :created, location: @method_type }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @method_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @trait_type = TraitType.new(trait_type_params)\n\n if @trait_type.save\n render json: @trait_type, status: :created, location: @trait_type\n else\n render json: @trait_type.errors, status: :unprocessable_entity\n end\n end", "def create\n @right_type = RightType.new(right_type_params)\n\n respond_to do |format|\n if @right_type.save\n format.html { redirect_to @right_type, notice: 'Right type was successfully created.' }\n format.json { render :show, status: :created, location: @right_type }\n else\n format.html { render :new }\n format.json { render json: @right_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @space_cat = SpaceCat.new(space_cat_params)\n\n respond_to do |format|\n if @space_cat.save\n format.html { redirect_to @space_cat, notice: 'Space cat was successfully created.' }\n format.json { render action: 'show', status: :created, location: @space_cat }\n else\n format.html { render action: 'new' }\n format.json { render json: @space_cat.errors, status: :unprocessable_entity }\n end\n end\n end", "def space_cat_params\n params.require(:space_cat).permit(:name)\n end", "def create\n @type = Type.new(type_params)\n @sub_types = params[:subtype_attributes]\n if @type.save\n @sub_types.each do |subtype|\n @subtype = @type.subtype.new\n @subtype.name = subtype[\"name\"]\n @subtype.code = subtype[\"code\"]\n @subtype.save\n end\n flash[:notice] = 'Type was successfully created.'\n redirect_to types_path\n else\n flash[:error] = @type.errors.full_messages\n render \"new\"\n end\n end", "def type_name_params\n params.require(:type_name).permit(:type_id, :name)\n end", "def create\n @tag_type = TagType.new(tag_type_params)\n respond_to do |format|\n if @tag_type.save\n format.html { redirect_to @tag_type, notice: 'Tag type was successfully created.' }\n format.json { render :show, status: :created, location: @tag_type }\n else\n format.html { render :new }\n format.json { render json: @tag_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @resource_type = ResourceType.new(params[:resource_type])\n respond_to do |format|\n if @resource_type.save\n if params[:fields]\n params[:fields].each do |param|\n @field = Field.new(\n :name => param[:name], \n :field_type_id => param[:field_type_id],\n :resource_type_id => @resource_type.id, \n :resource_type_reference_id => param[:resource_type_reference_id]\n )\n param[:validator_ids].each do |index|\n @field.field_validations.build(validator_id: index)\n end\n @field.save\n end\n end\n format.html { redirect_to @resource_type, notice: 'Resource type was successfully created.' }\n format.json { render json: @resource_type, status: :created, location: @resource_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @resource_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def grouptype_params\n params.require(:grouptype).permit(:name)\n end", "def segment_type_params\n params.require(:segment_type).permit(:name)\n end", "def create\n @comm_type = CommType.new(comm_type_params)\n\n respond_to do |format|\n if @comm_type.save\n format.html { redirect_to @comm_type, notice: 'Comm type was successfully created.' }\n format.json { render action: 'show', status: :created, location: @comm_type }\n else\n format.html { render action: 'new' }\n format.json { render json: @comm_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @space = Space.new(space_params)\n\n respond_to do |format|\n if @space.save\n format.html { redirect_to spaces_path, notice: 'Friend was successfully created.' }\n format.json { render action: 'show', status: :created, location: @space }\n else\n format.html { render action: 'new' }\n format.json { render json: @space.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @dash_type = DashType.new(params[:dash_type])\n\n respond_to do |format|\n if @dash_type.save\n format.html { redirect_to @dash_type, notice: 'Dash type was successfully created.' }\n format.json { render json: @dash_type, status: :created, location: @dash_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @dash_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n authorize :resquest_type, :create?\n @resquest_type = ResquestType.new(resquest_type_params)\n\n respond_to do |format|\n if @resquest_type.save\n format.html { redirect_to @resquest_type, notice: 'Resquest type was successfully created.' }\n format.json { render :show, status: :created, location: @resquest_type }\n else\n format.html { render :new }\n format.json { render json: @resquest_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @phones_type = PhonesType.new(phones_type_params)\n\n respond_to do |format|\n if @phones_type.save\n format.html { redirect_to @phones_type, notice: 'Phones type was successfully created.' }\n format.json { render :show, status: :created, location: @phones_type }\n else\n format.html { render :new }\n format.json { render json: @phones_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @space_form = Space::Form.new(space: current_team.spaces.new,\n user: current_user,\n attributes: space_params)\n\n authorize @space_form.space, :create?\n\n respond_to do |format|\n if @space_form.save\n format.html do\n redirect_to case\n when @space_form.space.access_control.private? then space_members_path(@space_form.space)\n else space_pages_path(@space_form.space)\n end\n end\n format.json { render :show, status: :created, location: @space_form.space }\n else\n format.html { render :new }\n format.json { render json: @space_form.errors, status: :unprocessable_entity }\n end\n end\n end", "def type_params\n params.require(:type).permit(:name, :index)\n end", "def create\n @statement_type = StatementType.new(statement_type_params)\n\n respond_to do |format|\n if @statement_type.save\n format.html { redirect_to @statement_type, notice: 'Statement type was successfully created.' }\n format.json { render :show, status: :created, location: @statement_type }\n else\n format.html { render :new }\n format.json { render json: @statement_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @office_space = OfficeSpace.new(office_space_params)\n\n respond_to do |format|\n if @office_space.save\n format.html { redirect_to @office_space, notice: 'Office space was successfully created.' }\n format.json { render :show, status: :created, location: @office_space }\n else\n format.html { render :new }\n format.json { render json: @office_space.errors, status: :unprocessable_entity }\n end\n end\n end", "def types(types); end", "def create\n group = Group.find(params[:group_id])\n unless @current_user.id == group.user_id\n return render json: { message: \"You are not permitted to perform this operation.\" }, status: :forbidden\n end\n @space = Space.new(space_params)\n if @space.save\n render json: @space, status: :created\n else\n render json: @space.errors, status: :unprocessable_entity\n end\n end", "def create\n @identifier_type = IdentifierType.new(params[:identifier_type])\n\n respond_to do |format|\n if @identifier_type.save\n format.html { redirect_to @identifier_type, :notice => t('controller.successfully_created', :model => t('activerecord.models.identifier_type')) }\n format.json { render :json => @identifier_type, :status => :created, :location => @identifier_type }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @identifier_type.errors, :status => :unprocessable_entity }\n end\n end\n end", "def departuretype_params\n params.require(:departuretype).permit(:departureTypes)\n end", "def create\n @safe_space = SafeSpace.new(safe_space_params)\n\n respond_to do |format|\n if @safe_space.save\n format.html { redirect_to @safe_space, notice: 'Safe space was successfully created.' }\n format.json { render :show, status: :created, location: @safe_space }\n else\n format.html { render :new }\n format.json { render json: @safe_space.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @observation_type = ObservationType.new(params[:observation_type])\n\n respond_to do |format|\n if @observation_type.save\n format.html { redirect_to @observation_type, notice: 'Observation type was successfully created.' }\n format.json { render json: @observation_type, status: :created, location: @observation_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @observation_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @instance_type = InstanceType.new(params[:instance_type])\n\n respond_to do |format|\n if @instance_type.save\n format.html { redirect_to @instance_type, notice: 'Instance type was successfully created.' }\n format.json { render json: @instance_type, status: :created, location: @instance_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @instance_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @novelty_type = NoveltyType.new(novelty_type_params)\n\n respond_to do |format|\n if @novelty_type.save\n format.html { redirect_to @novelty_type, notice: 'Novelty type was successfully created.' }\n format.json { render :show, status: :created, location: @novelty_type }\n else\n format.html { render :new }\n format.json { render json: @novelty_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @storage_type = StorageType.new(storage_type_params)\n\n respond_to do |format|\n if @storage_type.save\n format.html { redirect_to @storage_type, notice: 'Storage type was successfully created.' }\n format.json { render :show, status: :created, location: @storage_type }\n else\n format.html { render :new }\n format.json { render json: @storage_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @nametype = Nametype.new(nametype_params)\n\n respond_to do |format|\n if @nametype.save\n format.html { redirect_to @nametype, notice: 'Nametype was successfully created.' }\n format.json { render :show, status: :created, location: @nametype }\n else\n format.html { render :new }\n format.json { render json: @nametype.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @valid_type = ValidType.new(valid_type_params)\n @valid_type.typed = true\n\n respond_to do |format|\n if @valid_type.save\n format.html { redirect_to valid_types_path, notice: 'Entity Type was successfully created.' }\n format.json { render :show, status: :created, location: @valid_type }\n else\n format.html { render :new }\n format.js { render :new }\n format.json { render json: @valid_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def resource_type_params\n params.require(:resource_type).permit(:name)\n end", "def create\n @itemtype = Itemtype.new(itemtype_params)\n\n respond_to do |format|\n if @itemtype.save\n format.html { redirect_to @itemtype, notice: 'Itemtype was successfully created.' }\n format.json { render :show, status: :created, location: @itemtype }\n else\n format.html { render :new }\n format.json { render json: @itemtype.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @entity_type = EntityType.new(entity_type_params)\n @entity_type.collection_id = @collection.id\n respond_to do |format|\n if @entity_type.save\n format.html { redirect_to collection_entity_types_path(@collection), notice: 'The entity type was successfully created.' }\n format.json { render :show, status: :created, location: @entity_type }\n else\n format.html { render :new }\n format.json { render json: @entity_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @fieldtype = Fieldtype.new(params[:fieldtype])\n\n respond_to do |format|\n if @fieldtype.save\n format.html { redirect_to @fieldtype, notice: 'Fieldtype was successfully created.' }\n format.json { render json: @fieldtype, status: :created, location: @fieldtype }\n else\n format.html { render action: \"new\" }\n format.json { render json: @fieldtype.errors, status: :unprocessable_entity }\n end\n end\n end", "def range_type_params\n params.require(:range_type).permit(:name, :description)\n end", "def valid_type_params\n params.require(:valid_type).permit(:entity_type, :name, :code, :regional_name_value)\n end", "def relation_type_params\n params.require(:relation_type).permit(:name, :color, :num_nodes, :project_id, :entity_type => [])\n end", "def create\n @production_type = ProductionType.new(production_type_params)\n\n respond_to do |format|\n if @production_type.save\n format.html { redirect_to @production_type, notice: 'Production type was successfully created.' }\n format.json { render :show, status: :created, location: @production_type }\n else\n format.html { render :new }\n format.json { render json: @production_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @session_type = SessionType.new(params[:session_type])\n\n respond_to do |format|\n if @session_type.save\n format.html { redirect_to @session_type, notice: 'Session type was successfully created.' }\n format.json { render json: @session_type, status: :created, location: @session_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @session_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def space_params\n params.require(:space).permit(:name, :category, :address, :city, :state, :hours, :phone, :email, :website, :description)\n end", "def create\n @weapon_type = WeaponType.new(weapon_type_params)\n\n if @weapon_type.save\n render json: @weapon_type, status: :created, location: @weapon_type\n else\n render json: @weapon_type.errors, status: :unprocessable_entity\n end\n end", "def create_types_effectivenesses\n @types.each do |type|\n I18n.locale = :en\n type_record = Type.find_by(name: type['name_en'])\n create_type_effectivenesses(type, type_record) if type_record\n end\n end", "def pet_types\r\n BnetApi::make_request('/wow/data/pet/types')\r\n end", "def device_type_params\n params.require(:device_type).permit(:code,\n :name,\n :internal_api_server_type,\n :internal_web_server_type,\n :desktop_type,\n :web_server_type,\n :mobile_type)\n end", "def create\n @types_of_apprenticeship = TypesOfApprenticeship.new(params[:types_of_apprenticeship])\n\n respond_to do |format|\n if @types_of_apprenticeship.save\n format.html { redirect_to @types_of_apprenticeship, notice: 'Types of apprenticeship was successfully created.' }\n format.json { render json: @types_of_apprenticeship, status: :created, location: @types_of_apprenticeship }\n else\n format.html { render action: \"new\" }\n format.json { render json: @types_of_apprenticeship.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.69664407", "0.65157187", "0.65092963", "0.63412845", "0.6136117", "0.6122288", "0.6054214", "0.60184675", "0.60184675", "0.59732586", "0.59732586", "0.5948731", "0.5948731", "0.5903168", "0.57803077", "0.57726896", "0.5736006", "0.5731621", "0.5684437", "0.56249815", "0.56244224", "0.5611018", "0.5599227", "0.5534249", "0.5505799", "0.5502497", "0.549128", "0.5486804", "0.54529786", "0.544543", "0.544243", "0.5431043", "0.54289144", "0.54289144", "0.5424653", "0.5420796", "0.54151523", "0.5404732", "0.53808117", "0.5377894", "0.53530234", "0.5341481", "0.533696", "0.5334847", "0.5325844", "0.5324681", "0.5322764", "0.53223634", "0.53151876", "0.53149754", "0.5304311", "0.5292765", "0.5288958", "0.5287518", "0.5282546", "0.5269039", "0.5261735", "0.5260721", "0.5256804", "0.5232941", "0.5214999", "0.5201418", "0.5192368", "0.51922125", "0.51861167", "0.5185213", "0.5178887", "0.51778454", "0.5177247", "0.517042", "0.51690364", "0.5165193", "0.5159902", "0.515934", "0.5154", "0.5150383", "0.5150159", "0.51489097", "0.5141249", "0.5141009", "0.51400554", "0.51390225", "0.5122136", "0.5119659", "0.51151717", "0.5111573", "0.5106194", "0.51054764", "0.51050067", "0.5099578", "0.5096885", "0.5094801", "0.50947237", "0.5093076", "0.5091924", "0.50902504", "0.50893974", "0.5088467", "0.5087873", "0.50877094" ]
0.67583036
1
PATCH/PUT /space_types/1 PATCH/PUT /space_types/1.json
def update respond_to do |format| old_name = @space_type.name if @space_type.update(space_type_params) @space_type.spaces.each { |s| s.touch } format.html { redirect_to @space_type, notice: t('.update_ok') } format.json { head :no_content } else format.html { render action: 'edit' } format.json { render json: @space_type.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_space_type_params\n params.require(:space_type).permit(:id, :name)\n end", "def update\n if @space.update(space_params)\n render json: @space, status: :ok\n else\n render json: @space.errors, status: :unprocessable_entity\n end\n end", "def set_space_type\n @space_type = SpaceType.find(params[:id])\n end", "def update\n respond_to do |format|\n if @space.update(space_params)\n format.html { redirect_to @space, notice: 'Space was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @space.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_space_type\n @space_type = SpaceType.find(params[:id])\n end", "def set_space_type\n @space_type = SpaceType.find(params[:id])\n end", "def update\n respond_to do |format|\n if @box_request_abuse_type.update(box_request_abuse_type_params)\n format.html { redirect_to @box_request_abuse_type, notice: 'Box request abuse type was successfully updated.' }\n format.json { render :show, status: :ok, location: @box_request_abuse_type }\n else\n format.html { render :edit }\n format.json { render json: @box_request_abuse_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @os_type.update(os_type_params)\n format.html { redirect_to @os_type, notice: 'Os type was successfully updated.' }\n format.json { render :show, status: :ok, location: @os_type }\n else\n format.html { render :edit }\n format.json { render json: @os_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @os_type = OsType.find(params[:id])\n\n respond_to do |format|\n if @os_type.update_attributes(params[:os_type])\n format.html { redirect_to @os_type, notice: 'Os type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @os_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @type.update(type_params)\n end", "def update\n @gl_type = GlType.find(params[:id])\n\n respond_to do |format|\n if @gl_type.update_attributes(gl_type_params)\n format.html { redirect_to gl_types_path, notice: 'Gl type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @gl_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @space = Space.find(params[:id])\n \n respond_to do |format|\n if @space.update_attributes(params[:space])\n format.html { redirect_to @space, notice: 'Space was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @space.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @space.update(space_params)\n format.html { redirect_to @space, notice: \"Space was successfully updated.\" }\n format.json { render :show, status: :ok, location: @space }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @space.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @cloth_type.update(cloth_type_params)\n format.html { redirect_to @cloth_type, notice: \"Cloth type was successfully updated.\" }\n format.json { render :show, status: :ok, location: @cloth_type }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @cloth_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @space_cat.update(space_cat_params)\n format.html { redirect_to @space_cat, notice: 'Space cat was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @space_cat.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n authorize :resquest_type, :update?\n respond_to do |format|\n if @resquest_type.update(resquest_type_params)\n format.html { redirect_to @resquest_type, notice: 'Resquest type was successfully updated.' }\n format.json { render :show, status: :ok, location: @resquest_type }\n else\n format.html { render :edit }\n format.json { render json: @resquest_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @comm_type.update(comm_type_params)\n format.html { redirect_to @comm_type, notice: 'Comm type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @comm_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def space_type_params\n params.require(:space_type).permit(:name)\n end", "def update\n respond_to do |format|\n if @model_type.update(model_type_params)\n format.html { redirect_to @model_type, notice: 'Model type was successfully updated.' }\n format.json { render :show, status: :ok, location: @model_type }\n else\n format.html { render :edit }\n format.json { render json: @model_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @segment_type = SegmentType.find(params[:id])\n\n respond_to do |format|\n if @segment_type.update_attributes(params[:segment_type])\n format.html { redirect_to @segment_type, notice: 'Segment type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @segment_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n standard_update(OrganizationType, params[:id], organization_type_params)\n end", "def update\n @entry_type = EntryType.find(params[:id])\n\n respond_to do |format|\n field_type_ids = params[:entry_type].delete(\"field_type_ids\")\n @entry_type.field_type_ids = field_type_ids if field_type_ids\n params[:entry_type].delete(\"form_code\")\n if @entry_type.update_attributes(params[:entry_type])\n format.html { redirect_to @entry_type, notice: 'Entry type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @entry_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @office_space.update(office_space_params)\n format.html { redirect_to @office_space, notice: 'Office space was successfully updated.' }\n format.json { render :show, status: :ok, location: @office_space }\n else\n format.html { render :edit }\n format.json { render json: @office_space.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @boxtype = Boxtype.find(params[:id])\n\n respond_to do |format|\n if @boxtype.update_attributes(params[:boxtype])\n format.html { redirect_to @boxtype, notice: 'Boxtype was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @boxtype.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @storage_type.update(storage_type_params)\n format.html { redirect_to @storage_type, notice: 'Storage type was successfully updated.' }\n format.json { render :show, status: :ok, location: @storage_type }\n else\n format.html { render :edit }\n format.json { render json: @storage_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @contract_type.update(contract_type_params)\n format.html { redirect_to @contract_type, notice: 'Contract type was successfully updated.' }\n format.json { render :show, status: :ok, location: @contract_type }\n else\n format.html { render :edit }\n format.json { render json: @contract_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @site_type = SiteType.find(params[:id])\n\n respond_to do |format|\n section_type_ids = params[:site_type].delete(\"section_type_ids\")\n if @site_type.update_attributes(params[:site_type]) && @site_type.section_type_ids = section_type_ids\n format.html { redirect_to @site_type, notice: 'Site type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @site_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @novelty_type.update(novelty_type_params)\n format.html { redirect_to @novelty_type, notice: 'Novelty type was successfully updated.' }\n format.json { render :show, status: :ok, location: @novelty_type }\n else\n format.html { render :edit }\n format.json { render json: @novelty_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @segment_type.update(segment_type_params)\n format.html { redirect_to @segment_type, notice: 'Segment type was successfully updated.' }\n format.json { render :show, status: :ok, location: @segment_type }\n else\n format.html { render :edit }\n format.json { render json: @segment_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @crate_type = CrateType.find(params[:id])\n\n respond_to do |format|\n if @crate_type.update_attributes(params[:crate_type])\n format.html { redirect_to @crate_type, :notice => 'Crate type was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @crate_type.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @method_type.update(method_type_params)\n format.html { redirect_to @method_type, notice: \"Method type was successfully updated.\" }\n format.json { render :show, status: :ok, location: @method_type }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @method_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @breadcrumb = 'update'\n @contracting_request_document_type = ContractingRequestDocumentType.find(params[:id])\n @contracting_request_document_type.updated_by = current_user.id if !current_user.nil?\n\n respond_to do |format|\n if @contracting_request_document_type.update_attributes(params[:contracting_request_document_type])\n format.html { redirect_to @contracting_request_document_type,\n notice: (crud_notice('updated', @contracting_request_document_type) + \"#{undo_link(@contracting_request_document_type)}\").html_safe }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contracting_request_document_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @phones_type.update(phones_type_params)\n format.html { redirect_to @phones_type, notice: 'Phones type was successfully updated.' }\n format.json { render :show, status: :ok, location: @phones_type }\n else\n format.html { render :edit }\n format.json { render json: @phones_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n logger.info(params)\n @space = Space.find(params[:id])\n respond_to do |format|\n if @space.update(space_params)\n flash[:info] = \"空间更新成功!\"\n format.html { redirect_to @space }\n format.json { render :show, status: :ok, location: @space }\n else\n format.html { render :edit }\n format.json { render json: @space.errors, status: :unprocessable_entity }\n end\n end\n\n end", "def change_type\n\t\t\trender json: User.update_type_by_id(params[:id], params[:type], params[:is])\n\t\tend", "def space_type_params\n params.require(:space_type).permit(\n :name, :short_name, :spaces_count, :notes,\n equipment_items_attributes: [:id, :qty, :notes, :equipment_model_id, :_destroy] )\n end", "def update\n respond_to do |format|\n if @type.update(type_params)\n format.html { redirect_to director_types_path, notice: 'Type was successfully updated.' }\n format.json { render :show, status: :ok, location: @director_type }\n else\n format.html { render :edit }\n format.json { render json: @type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @range_type.update(range_type_params)\n format.html { redirect_to @range_type, notice: 'Range type was successfully updated.' }\n format.json { render :show, status: :ok, location: @range_type }\n else\n format.html { render :edit }\n format.json { render json: @range_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @spec_type.update(spec_type_params)\n format.html { redirect_to @spec_type, notice: 'Spec type was successfully updated.' }\n format.json { render :show, status: :ok, location: @spec_type }\n else\n format.html { render :edit }\n format.json { render json: @spec_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @trait_type = TraitType.find(params[:id])\n\n if @trait_type.update(trait_type_params)\n head :no_content\n else\n render json: @trait_type.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @clothing_type.update(clothing_type_params)\n format.html { redirect_to @clothing_type, notice: 'Clothing type was successfully updated.' }\n format.json { render :show, status: :ok, location: @clothing_type }\n else\n format.html { render :edit }\n format.json { render json: @clothing_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @contract_type = ContractType.find(params[:id])\n\n respond_to do |format|\n if @contract_type.update_attributes(params[:contract_type])\n format.html { redirect_to @contract_type, notice: 'Contract type was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contract_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @commission_type.update(commission_type_params)\n format.html { redirect_to @commission_type, notice: 'Commission type was successfully updated.' }\n format.json { render :show, status: :ok, location: @commission_type }\n else\n format.html { render :edit }\n format.json { render json: @commission_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @stock_type = StockType.find(params[:id])\n\n respond_to do |format|\n if @stock_type.update_attributes(params[:stock_type])\n format.html { redirect_to @stock_type, notice: 'Stock type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @stock_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @dash_type = DashType.find(params[:id])\n\n respond_to do |format|\n if @dash_type.update_attributes(params[:dash_type])\n format.html { redirect_to @dash_type, notice: 'Dash type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @dash_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @api_v1_admin_type.update(api_v1_admin_type_params)\n format.html { redirect_to @api_v1_admin_type, notice: 'Admin type was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_admin_type }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_admin_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @myspace = Myspace.find(params[:id])\n\n respond_to do |format|\n if @myspace.update_attributes(params[:myspace])\n format.html { redirect_to @myspace, notice: 'Myspace was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @myspace.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @q_type.update(q_type_params)\n format.html { redirect_to @q_type, notice: 'Q type was successfully updated.' }\n format.json { render :show, status: :ok, location: @q_type }\n else\n format.html { render :edit }\n format.json { render json: @q_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @space_type.destroy\n respond_to do |format|\n format.html { redirect_to space_types_url, status: 303 }\n format.json { head :no_content }\n end\n end", "def update\n respond_to do |format|\n if @yarn_type.update(yarn_type_params)\n format.html { redirect_to @yarn_type, notice: 'Yarn type was successfully updated.' }\n format.json { render :show, status: :ok, location: @yarn_type }\n else\n format.html { render :edit }\n format.json { render json: @yarn_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @lift_type.update(lift_type_params)\n format.html {redirect_to lift_types_path, notice: 'Lift type was successfully updated.'}\n format.json {render :show, status: :ok, location: @lift_type}\n else\n format.html {render :edit}\n format.json {render json: @lift_type.errors, status: :unprocessable_entity}\n end\n end\n end", "def update\n respond_to do |format|\n if @instance_type.update(instance_type_params)\n format.html { redirect_to @instance_type, notice: 'Instance type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @instance_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def type= new_type\n @gapi.update! type: verify_type(new_type)\n end", "def update\n @space_cat = SpaceCat.find(params[:id])\n\n respond_to do |format|\n if @space_cat.update_attributes(params[:space_cat])\n format.html { redirect_to @space_cat, notice: 'Space cat was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @space_cat.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @collection_type = CollectionType.find(params[:id])\n\n respond_to do |format|\n if @collection_type.update_attributes(params[:collection_type])\n format.html { redirect_to @collection_type, notice: 'Collection type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @collection_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @catalog_contract_type.update(catalog_contract_type_params)\n format.html { redirect_to @catalog_contract_type, notice: 'Contract type was successfully updated.' }\n format.json { render :show, status: :ok, location: @catalog_contract_type }\n else\n format.html { render :edit }\n format.json { render json: @catalog_contract_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @thing_type.update(thing_type_params)\n format.html { redirect_to @thing_type, notice: 'Thing type was successfully updated.' }\n format.json { render :show, status: :ok, location: @thing_type }\n else\n format.html { render :edit }\n format.json { render json: @thing_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @gearbox_type = GearboxType.find(params[:id])\n\n respond_to do |format|\n if @gearbox_type.update_attributes(params[:gearbox_type])\n format.html { redirect_to(@gearbox_type, :notice => 'Gearbox type was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @gearbox_type.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @realty_type = RealtyType.find(params[:id])\n\n respond_to do |format|\n if @realty_type.update_attributes(params[:realty_type])\n format.html { redirect_to @realty_type, notice: 'Realty type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @realty_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @shipment_type.update(shipment_type_params)\n format.html { redirect_to @shipment_type, notice: 'Shipment type was successfully updated.' }\n format.json { render :show, status: :ok, location: @shipment_type }\n else\n format.html { render :edit }\n format.json { render json: @shipment_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n @object_type = ObjectType.find(params[:id])\n\n if params[:object_type][:prefix] != @object_type.prefix\n entries = Item.joins(:locator).where(\"items.object_type_id = #{@object_type.id} AND locators.item_id = items.id\").count\n if entries != 0\n flash[:error] = \"Cannot change location wizard to #{params[:object_type][:prefix]} because there\n are items associated with this object type using the current wizard whose locations\n might get messed up. To change the wizard, (a) write down all the item numbers; (b)\n delete all the items; (c) change the location wizard; (d) undelete all the items by\n changing their locations to a location that works with the new location wizard.\"\n render action: 'edit'\n return\n end\n end\n\n ok = @object_type.update_attributes(params[:object_type].except(:rows, :columns))\n\n if params[:object_type][:handler] == 'collection'\n @object_type.rows = params[:object_type][:rows]\n @object_type.columns = params[:object_type][:columns]\n @object_type.save\n end\n\n respond_to do |format|\n if ok\n format.html { redirect_to object_types_path, notice: \"Object type '#{@object_type.name}' was successfully updated.\" }\n format.json { head :no_content }\n else\n format.html { redirect_to edit_object_type_path, notice: \"Object type could not be updated. #{@object_type.errors.full_messages.join(', ')}.\" }\n format.json { render json: @object_type.errors, status: :unprocessable_entity }\n end\n end\n\n end", "def update\n @opportunity_type = OpportunityType.find(params[:id])\n\n respond_to do |format|\n if @opportunity_type.update_attributes(params[:opportunity_type])\n format.html { redirect_to @opportunity_type, notice: 'Opportunity type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @opportunity_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_space_in_system(slug, body, headers=default_headers)\n @logger.info(\"Updating Space \\\"#{slug}\\\"\")\n put(\"#{@api_url}/spaces/#{slug}\", body, headers)\n end", "def update\n respond_to do |format|\n if @identifier_type.update(identifier_type_params)\n format.html { redirect_to @identifier_type, notice: 'Identifier type was successfully updated.' }\n format.json { render :show, status: :ok, location: @identifier_type }\n else\n format.html { render :edit }\n format.json { render json: @identifier_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @doc_type.update(doc_type_params)\n format.html { redirect_to @doc_type, notice: t('message.template.scaffold.update', model: t('activerecord.models.doc_type')) }\n format.json { render :show, status: :ok, location: @doc_type }\n else\n format.html { render :edit }\n format.json { render json: @doc_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @defect_type.update(defect_type_params)\n format.html { redirect_to @defect_type, notice: 'Defect type was successfully updated.' }\n format.json { render :show, status: :ok, location: @defect_type }\n else\n format.html { render :edit }\n format.json { render json: @defect_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @modeltype.update(modeltype_params)\n format.html { redirect_to @modeltype, notice: 'Modeltype was successfully updated.' }\n format.json { render :show, status: :ok, location: @modeltype }\n else\n format.html { render :edit }\n format.json { render json: @modeltype.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @document_type = DocumentType.find(params[:id])\n\n respond_to do |format|\n if @document_type.update_attributes(params[:document_type])\n format.html { redirect_to @document_type, notice: 'Document type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @document_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @grouptype.update(grouptype_params)\n format.html { redirect_to @grouptype, notice: 'Grouptype was successfully updated.' }\n format.json { render :show, status: :ok, location: @grouptype }\n else\n format.html { render :edit }\n format.json { render json: @grouptype.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @space.update(space_params) && update_subscription(@space)\n format.html { redirect_to edit_space_url(@space), notice: 'Space was successfully updated.' }\n format.json { render :show, status: :ok, location: @space }\n else\n format.html { render :edit }\n format.json { render json: @space.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @affected_type.update(affected_type_params)\n format.html { redirect_to @affected_type, notice: 'Affected type was successfully updated.' }\n format.json { render :show, status: :ok, location: @affected_type }\n else\n format.html { render :edit }\n format.json { render json: @affected_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n instance = get_instance\n set_meta instance\n if instance.update(type_params)\n # Redirect to index\n format.html { redirect_to redirect_address(@type), notice: \"#{type_label} was successfully updated.\" }\n else\n flash[:alert] = \"#{type_label} has not been saved.\"\n format.html { render sti_template(@type, :edit) }\n end\n end\n end", "def update\n respond_to do |format|\n if @trait_type.update(trait_type_params)\n format.html { redirect_to @trait_type, notice: 'Trait type was successfully updated.' }\n format.json { render :show, status: :ok, location: @trait_type }\n else\n format.html { render :edit }\n format.json { render json: @trait_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @valid_type.update(valid_type_params)\n format.html { redirect_to valid_types_path, notice: 'Entity Type was successfully updated.' }\n format.json { render :show, status: :ok, location: @valid_type }\n else\n format.html { render :edit }\n format.js { render :edit }\n format.json { render json: @valid_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @question_type = QuestionType.find(params[:id])\n\n respond_to do |format|\n if @question_type.update_attributes(params[:question_type])\n format.html { redirect_to @question_type, notice: 'Question type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @divition_type.update(divition_type_params)\n format.html { redirect_to divition_types_path, notice: 'Divition type was successfully updated.' }\n format.json { render :show, status: :ok, location: @divition_type }\n else\n format.html { render :edit }\n format.json { render json: @divition_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @production_type.update(production_type_params)\n format.html { redirect_to @production_type, notice: 'Production type was successfully updated.' }\n format.json { render :show, status: :ok, location: @production_type }\n else\n format.html { render :edit }\n format.json { render json: @production_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @entity_type.update(entity_type_params)\n format.html { redirect_to @entity_type, notice: 'Entity type was successfully updated.' }\n format.json { render :show, status: :ok, location: @entity_type }\n else\n format.html { render :edit }\n format.json { render json: @entity_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @value_type = ValueType.find(params[:id])\n\n respond_to do |format|\n if @value_type.update_attributes(params[:value_type])\n format.html { redirect_to @value_type, notice: 'Value type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @value_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @use_type.update(use_type_params)\n format.html { redirect_to @use_type, notice: 'Use type was successfully updated.' }\n format.json { render :show, status: :ok, location: @use_type }\n else\n format.html { render :edit }\n format.json { render json: @use_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @typeio.update(typeio_params)\n format.html { redirect_to @bulletin_board, notice: 'Typeio was successfully updated.' }\n format.json { render :show, status: :ok, location: @typeio }\n else\n format.html { render :edit }\n format.json { render json: @typeio.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @resource_type.update_attributes(params[:resource_type])\n if params[:fields]\n params[:fields].each do |param|\n if param[:id]\n @field = Field.find(param[:id])\n @field.update_attributes(\n :name => param[:name], \n :field_type_id => param[:field_type_id],\n :resource_type_id => params[:id],\n :resource_type_reference_id => param[:resource_type_reference_id]\n )\n else\n @field = Field.create(\n :name => param[:name],\n :field_type_id => param[:field_type_id],\n :resource_type_id => params[:id],\n :resource_type_reference_id => param[:resource_type_reference_id]\n )\n end\n if @field.field_validations.any?\n @field.field_validations.each { |v| v.destroy }\n end\n if param[:validator_ids]\n param[:validator_ids].each do |index|\n next if index == \"multiselect-all\"\n @field.field_validations.build(validator_id: index.to_i)\n end\n end \n @field.save\n end\n end \n format.html { redirect_to @resource_type, notice: 'Resource type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @resource_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @collection = @entity_type.collection\n respond_to do |format|\n if @entity_type.update(entity_type_params)\n format.html { redirect_to collection_entity_types_path(@collection), notice: 'The entity type was successfully updated.' }\n format.json { render :show, status: :ok, location: @entity_type }\n else\n format.html { render :edit }\n format.json { render json: @entity_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @nametype.update(nametype_params)\n format.html { redirect_to @nametype, notice: 'Nametype was successfully updated.' }\n format.json { render :show, status: :ok, location: @nametype }\n else\n format.html { render :edit }\n format.json { render json: @nametype.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @acquired_type.update(acquired_type_params)\n format.html { redirect_to @acquired_type, notice: 'Acquired type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @acquired_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_question_type\n form_params = params.require(:form).permit(:question_id, :question_type)\n\n render json: Question.update_question_type(form_params)\n end", "def update\n @structure_type = StructureType.find(params[:id])\n\n respond_to do |format|\n if @structure_type.update_attributes(params[:structure_type])\n format.html { redirect_to @structure_type, notice: 'Structure type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @structure_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @instance_type = InstanceType.find(params[:id])\n\n respond_to do |format|\n if @instance_type.update_attributes(params[:instance_type])\n format.html { redirect_to @instance_type, notice: 'Instance type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @instance_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @foundation_type.update(foundation_type_params)\n format.html { redirect_to @foundation_type, notice: 'Foundation type was successfully updated.' }\n format.json { render :show, status: :ok, location: @foundation_type }\n else\n format.html { render :edit }\n format.json { render json: @foundation_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @space_form = Space::Form.new(space: @space,\n user: current_user,\n attributes: space_params)\n\n authorize @space, :update?\n\n respond_to do |format|\n if @space_form.save\n format.html { redirect_to space_pages_path(@space_form.space), notice: 'Space was successfully updated.' }\n format.json { render :show, status: :ok, location: @space_form.space }\n else\n format.html { render :edit }\n format.json { render json: @space_form.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @item_type.update(item_type_params)\n format.html { redirect_to @item_type, notice: 'ItemType was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @item_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @itemtype.update(itemtype_params)\n format.html { redirect_to @itemtype, notice: 'Itemtype was successfully updated.' }\n format.json { render :show, status: :ok, location: @itemtype }\n else\n format.html { render :edit }\n format.json { render json: @itemtype.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_saved_object(params, type, id, space_id = \"\")\n endpoint = if space_id.present?\n \"s/#{space_id}/api/saved_objects/#{type}/#{id}\"\n else\n \"api/saved_objects/#{type}/#{id}\"\n end\n\n request(\n http_method: :put,\n endpoint: endpoint,\n params: params.to_json\n )\n end", "def update\n @service_type = ServiceType.find(params[:id])\n\n respond_to do |format|\n if @service_type.update_attributes(params[:service_type])\n format.html { redirect_to @service_type, notice: 'Service type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @service_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @devicetype.update(devicetype_params)\n format.html { redirect_to @devicetype, notice: 'Devicetype was successfully updated.' }\n format.json { render :show, status: :ok, location: @devicetype }\n else\n format.html { render :edit }\n format.json { render json: @devicetype.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @incident_type.update(incident_type_params)\n format.html { redirect_to admin_incident_types_path, notice: 'Incident type was successfully updated.' }\n format.json { render :show, status: :ok, location: @incident_type }\n else\n format.html { render :edit }\n format.json { render json: @incident_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @series_type = SeriesType.find(params[:id])\n\n respond_to do |format|\n if @series_type.update_attributes(params[:series_type])\n format.html { redirect_to @series_type, notice: 'Series type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @series_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @power_rack_type.update(power_rack_type_params)\n format.html { redirect_to @power_rack_type, notice: \"Power rack type was successfully updated.\" }\n format.json { render :show, status: :ok, location: @power_rack_type }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @power_rack_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @contractor_type = ContractorType.find(params[:id])\n\n respond_to do |format|\n if @contractor_type.update_attributes(params[:contractor_type])\n format.html { redirect_to @contractor_type, notice: 'Contractor type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contractor_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\r\n @equipe_type = EquipeType.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @equipe_type.update_attributes(params[:equipe_type])\r\n format.html { redirect_to equipe_types_url, notice: I18n.t(:general_update_success) }\r\n format.json { head :no_content }\r\n else\r\n format.html { render action: \"edit\" }\r\n format.json { render json: @equipe_type.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end" ]
[ "0.7292051", "0.6436006", "0.63852006", "0.6380993", "0.63784087", "0.63784087", "0.63504165", "0.63433325", "0.6327819", "0.6315074", "0.62682146", "0.6256635", "0.6246546", "0.6173676", "0.6141779", "0.61315477", "0.6125417", "0.6122588", "0.6122341", "0.6107857", "0.6089353", "0.60869676", "0.6064395", "0.6063564", "0.6056969", "0.60401624", "0.6032266", "0.60311395", "0.6030118", "0.6023906", "0.60041946", "0.5993202", "0.59891474", "0.5988394", "0.5978321", "0.59704345", "0.5963679", "0.59627587", "0.5958173", "0.5954458", "0.595356", "0.59491843", "0.594205", "0.5934261", "0.593257", "0.5929203", "0.5926842", "0.5920464", "0.59201574", "0.59131205", "0.59104717", "0.59030163", "0.59010094", "0.58992493", "0.58949244", "0.5894147", "0.5886357", "0.58700544", "0.5868754", "0.5867652", "0.5859043", "0.5852793", "0.58522254", "0.5851892", "0.5849638", "0.5845946", "0.58420134", "0.58351487", "0.58337176", "0.58260465", "0.58211124", "0.5821067", "0.58173466", "0.58161306", "0.5808844", "0.58079076", "0.5803612", "0.5798953", "0.579604", "0.5793607", "0.57898617", "0.5789701", "0.57859313", "0.5779426", "0.5775797", "0.57735324", "0.5765752", "0.5764648", "0.57643354", "0.57557076", "0.5755552", "0.5754378", "0.5752599", "0.57525784", "0.5740018", "0.5735073", "0.5730783", "0.5730596", "0.5730149", "0.57270664" ]
0.786411
0
DELETE /space_types/1 DELETE /space_types/1.json
def destroy @space_type.destroy respond_to do |format| format.html { redirect_to space_types_url, status: 303 } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @dash_type = DashType.find(params[:id])\n @dash_type.destroy\n\n respond_to do |format|\n format.html { redirect_to dash_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @space.destroy\n respond_to do |format|\n format.html { redirect_to spaces_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @gl_type = GlType.find(params[:id])\n @gl_type.destroy\n\n respond_to do |format|\n format.html { redirect_to gl_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @segment_type = SegmentType.find(params[:id])\n @segment_type.destroy\n\n respond_to do |format|\n format.html { redirect_to segment_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @type = Type.find(params[:id])\n @type.destroy\n\n respond_to do |format|\n format.html { redirect_to types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @os_type = OsType.find(params[:id])\n @os_type.destroy\n\n respond_to do |format|\n format.html { redirect_to os_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @os_type.destroy\n respond_to do |format|\n format.html { redirect_to os_types_url, notice: 'Os type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @space = Space.find(params[:id])\n\n @space.destroy\n\n respond_to do |format|\n format.html { redirect_to spaces_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @type = Type.find(params[:type])\n @type.destroy\n\n respond_to do |format|\n format.html { redirect_to company_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @storage_type.destroy\n respond_to do |format|\n format.html { redirect_to storage_types_url, notice: 'Storage type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @myspace = Myspace.find(params[:id])\n @myspace.destroy\n\n respond_to do |format|\n format.html { redirect_to myspaces_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @api_v1_admin_type.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_admin_types_url, notice: 'Admin type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @segment_type.destroy\n respond_to do |format|\n format.html { redirect_to segment_types_url, notice: 'Segment type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @dishtype.destroy\n respond_to do |format|\n format.html { redirect_to dishtypes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @space.destroy\n respond_to do |format|\n format.html { redirect_to spaces_url, notice: \"Space was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @space.destroy\n respond_to do |format|\n format.html { redirect_to spaces_url, notice: 'Space was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @space.destroy\n respond_to do |format|\n format.html { redirect_to spaces_url, notice: 'Space was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @fieldtype = Fieldtype.find(params[:id])\n @fieldtype.destroy\n\n respond_to do |format|\n format.html { redirect_to fieldtypes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @crossbowtype.destroy\n respond_to do |format|\n format.html { redirect_to crossbowtypes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @cg_table_type = CgTableType.find(params[:id])\n @cg_table_type.destroy\n\n respond_to do |format|\n format.html { redirect_to cg_table_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @commission_type.destroy\n respond_to do |format|\n format.html { redirect_to commission_types_url, notice: 'Commission type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @gig_type.destroy\n respond_to do |format|\n format.html { redirect_to gig_types_url, notice: 'Gig type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @cloth_type.destroy\n respond_to do |format|\n format.html { redirect_to cloth_types_url, notice: \"Cloth type was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @space = @basic.spaces.find(params[:id])\n @space.destroy\n respond_to do |format|\n format.html { redirect_to edit_basic_path(@basic), notice: 'Space was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @item_type.destroy\n respond_to do |format|\n format.html { redirect_to item_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @crate_type = CrateType.find(params[:id])\n @crate_type.destroy\n\n respond_to do |format|\n format.html { redirect_to crate_types_url }\n format.json { head :ok }\n end\n end", "def destroy\n @arc_type.destroy\n respond_to do |format|\n format.html { redirect_to arc_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @box_request_abuse_type.destroy\n respond_to do |format|\n format.html { redirect_to box_request_abuse_types_url, notice: 'Box request abuse type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @type.put_to_trash\n respond_to do |format|\n format.html { redirect_to director_types_path, notice: 'Type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @identifier_type.destroy\n\n respond_to do |format|\n format.html { redirect_to identifier_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @contract_type = ContractType.find(params[:id])\n @contract_type.destroy\n\n respond_to do |format|\n format.html { redirect_to contract_types_url }\n format.json { head :ok }\n end\n end", "def destroy\n @space.destroy\n head :no_content\n end", "def destroy\n @space.destroy\n head :no_content\n end", "def destroy\n @boxtype = Boxtype.find(params[:id])\n @boxtype.destroy\n\n respond_to do |format|\n format.html { redirect_to boxtypes_url }\n format.json { head :ok }\n end\n end", "def destroy\n @grouptype.destroy\n respond_to do |format|\n format.html { redirect_to grouptypes_url, notice: 'Grouptype was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @tax_type = TaxType.find(params[:id])\n @tax_type.destroy\n\n respond_to do |format|\n format.html { redirect_to tax_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @nav_type.destroy\n respond_to do |format|\n format.html { redirect_to nav_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @statement_type.destroy\n respond_to do |format|\n format.html { redirect_to statement_types_url, notice: 'Statement type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @space_cat.destroy\n respond_to do |format|\n format.html { redirect_to space_cats_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @all_field_type = AllFieldType.find(params[:id])\n @all_field_type.destroy\n\n respond_to do |format|\n format.html { redirect_to all_field_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @bs_type.destroy\n respond_to do |format|\n format.html { redirect_to bs_types_url, notice: 'Bs type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @cdist_type = CdistType.find(params[:id])\n @cdist_type.destroy\n\n respond_to do |format|\n format.html { redirect_to cdist_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @space_cat = SpaceCat.find(params[:id])\n @space_cat.destroy\n\n respond_to do |format|\n format.html { redirect_to space_cats_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @shipment_type.destroy\n respond_to do |format|\n format.html { redirect_to shipment_types_url, notice: 'Shipment type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @novelty_type.destroy\n respond_to do |format|\n format.html { redirect_to novelty_types_url, notice: 'Novelty type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @itemtype.destroy\n respond_to do |format|\n format.html { redirect_to itemtypes_url, notice: 'Itemtype was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @model_type.destroy\n respond_to do |format|\n format.html { redirect_to model_types_url, notice: 'Model type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @q_type.destroy\n respond_to do |format|\n format.html { redirect_to q_types_url, notice: 'Q type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @phones_type.destroy\n respond_to do |format|\n format.html { redirect_to phones_types_url, notice: 'Phones type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @production_type.destroy\n respond_to do |format|\n format.html { redirect_to production_types_url, notice: 'Production type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @ctype = Ctype.find(params[:id])\n @ctype.destroy\n\n respond_to do |format|\n format.html { redirect_to ctypes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @drum_type.destroy\n respond_to do |format|\n format.html { redirect_to drum_types_url, notice: 'Drum type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @affected_type.destroy\n respond_to do |format|\n format.html { redirect_to affected_types_url, notice: 'Affected type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @structure_type = StructureType.find(params[:id])\n @structure_type.destroy\n\n respond_to do |format|\n format.html { redirect_to structure_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @garbage_type.destroy\n respond_to do |format|\n format.html { redirect_to garbage_types_url, notice: 'Garbage type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @yarn_type.destroy\n respond_to do |format|\n format.html { redirect_to yarn_types_url, notice: 'Yarn type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @instance_type.destroy\n respond_to do |format|\n format.html { redirect_to instance_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @oma_relation_type = OmaRelationType.find(params[:id])\n @oma_relation_type.destroy\n\n respond_to do |format|\n format.html { redirect_to oma_relation_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @identifier_type.destroy\n respond_to do |format|\n format.html { redirect_to identifier_types_url, notice: 'Identifier type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @acct_type.destroy\n respond_to do |format|\n format.html { redirect_to acct_types_url, notice: 'Acct type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @collection_type = CollectionType.find(params[:id])\n @collection_type.destroy\n\n respond_to do |format|\n format.html { redirect_to collection_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n authorize :resquest_type, :destroy?\n @resquest_type.destroy\n respond_to do |format|\n format.html { redirect_to resquest_types_url, notice: 'Resquest type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @client_type = ClientType.find(params[:id])\n @client_type.destroy\n\n respond_to do |format|\n format.html { redirect_to client_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @accessory_type.destroy\n respond_to do |format|\n format.html { redirect_to accessory_types_url, notice: 'Accessory type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @ramp_type.destroy\n respond_to do |format|\n format.html { redirect_to ramp_types_url, notice: 'Ramp type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @foundation_type.destroy\n respond_to do |format|\n format.html { redirect_to foundation_types_url, notice: 'Foundation type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @devicetype.destroy\n respond_to do |format|\n format.html { redirect_to devicetypes_url, notice: 'Devicetype was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @page_type = PageType.find(params[:id])\n @page_type.destroy\n\n respond_to do |format|\n format.html { redirect_to page_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @coverage_type.destroy\n respond_to do |format|\n format.html { redirect_to coverage_types_url, notice: 'Coverage type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @mall_type = MallType.find(params[:id])\n @mall_type.destroy\n\n respond_to do |format|\n format.html { redirect_to mall_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @stock_type = StockType.find(params[:id])\n @stock_type.destroy\n\n respond_to do |format|\n format.html { redirect_to stock_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @os_type = OsType.find(params[:id])\n @os_type.destroy\n\n respond_to do |format|\n format.html { redirect_to(os_types_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @shape_type = ShapeType.find(params[:id])\n @shape_type.destroy\n\n\t\tmsg = I18n.t('app.msgs.success_deleted', :obj => I18n.t('app.common.shape_type'))\n\t\tsend_status_update(I18n.t('app.msgs.cache_cleared', :action => msg))\n respond_to do |format|\n format.html { redirect_to admin_shape_types_url }\n format.json { head :ok }\n end\n end", "def destroy\n @appliance_type = ApplianceType.find(params[:id])\n @appliance_type.destroy\n\n respond_to do |format|\n format.html { redirect_to appliance_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @sa_action_type.destroy\n respond_to do |format|\n format.html { redirect_to sa_action_types_url, notice: 'Sa action type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @typeconge.destroy\n respond_to do |format|\n format.html { redirect_to typeconges_url, notice: 'Typeconge was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @catalog_contract_type.destroy\n respond_to do |format|\n format.html { redirect_to catalog_contract_types_url, notice: 'Contract type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @espace.destroy\n respond_to do |format|\n format.html { redirect_to espaces_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @contract_type.destroy\n respond_to do |format|\n format.html { redirect_to contract_types_url, notice: 'Contract type a bien été supprimé.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @admission_type = AdmissionType.find(params[:id])\n @admission_type.destroy\n\n respond_to do |format|\n format.html { redirect_to admission_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @modeltype.destroy\n respond_to do |format|\n format.html { redirect_to modeltypes_url, notice: 'Modeltype was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @spaceship = Spaceship.find(params[:id])\n @spaceship.destroy\n\n respond_to do |format|\n format.html { redirect_to spaceships_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @modtype.destroy\n respond_to do |format|\n format.html { redirect_to modtypes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @service_type = ServiceType.find(params[:id])\n @service_type.destroy\n\n respond_to do |format|\n format.html { redirect_to service_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @costtype = Costtype.find(params[:id])\n @costtype.destroy\n\n respond_to do |format|\n format.html { redirect_to costtypes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @girltype = Girltype.find(params[:id])\n @girltype.destroy\n\n respond_to do |format|\n format.html { redirect_to girltypes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @divition_type.destroy\n respond_to do |format|\n format.html { redirect_to divition_types_url, notice: 'Divition type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @route_type.destroy\n respond_to do |format|\n format.html { redirect_to route_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @site_type = SiteType.find(params[:id])\n @site_type.destroy\n\n respond_to do |format|\n format.html { redirect_to site_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @document_type = DocumentType.find(params[:id])\n @document_type.destroy\n\n respond_to do |format|\n format.html { redirect_to document_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @flat_type.destroy\n respond_to do |format|\n format.html { redirect_to flat_types_url, notice: 'Flat type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @maintenance_type.destroy\n respond_to do |format|\n format.html { redirect_to maintenance_types_url, notice: 'Maintenance type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @servicetype = Servicetype.find(params[:id])\n @servicetype.destroy\n\n respond_to do |format|\n format.html { redirect_to servicetypes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @servicetype = Servicetype.find(params[:id])\n @servicetype.destroy\n\n respond_to do |format|\n format.html { redirect_to servicetypes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @sale_type.destroy\n respond_to do |format|\n format.html { redirect_to sale_types_url, notice: \"Sale type was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @mtype = Mtype.find(params[:id])\n @mtype.destroy\n\n respond_to do |format|\n format.html { redirect_to mtypes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @actiontype.destroy\n respond_to do |format|\n format.html { redirect_to actiontypes_url, notice: 'Actiontype was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @contractor_type = ContractorType.find(params[:id])\n @contractor_type.destroy\n\n respond_to do |format|\n format.html { redirect_to contractor_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @spacecraft.destroy\n respond_to do |format|\n format.html { redirect_to spacecrafts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @ad_type = AdType.find(params[:id])\n @ad_type.destroy\n\n respond_to do |format|\n format.html { redirect_to ad_types_url }\n format.json { head :no_content }\n end\n end" ]
[ "0.7057087", "0.7019595", "0.70014274", "0.69960076", "0.6978413", "0.69512826", "0.69446206", "0.69306666", "0.6877801", "0.6839855", "0.68057626", "0.67871445", "0.6780286", "0.6777816", "0.6757962", "0.6752708", "0.6752708", "0.67316777", "0.6726969", "0.6723898", "0.6720128", "0.6705731", "0.6703466", "0.66973424", "0.66827685", "0.667665", "0.66743344", "0.66672885", "0.6657364", "0.66478974", "0.66458106", "0.6644964", "0.6644964", "0.6643736", "0.6640789", "0.66403574", "0.6638677", "0.6635831", "0.6631016", "0.66266954", "0.6624247", "0.6611025", "0.6608959", "0.6602761", "0.6597289", "0.65955925", "0.65927255", "0.65924037", "0.65890163", "0.65889525", "0.6587348", "0.6584858", "0.65779126", "0.65776926", "0.6577203", "0.65772027", "0.6566855", "0.6561366", "0.6553803", "0.6551141", "0.6549774", "0.6549049", "0.65476763", "0.6539234", "0.6539207", "0.65382403", "0.6537439", "0.6533454", "0.6531325", "0.6530312", "0.65257275", "0.6523214", "0.6521879", "0.6519598", "0.6516871", "0.6516223", "0.65134966", "0.6511653", "0.6511617", "0.65079075", "0.6506789", "0.6500778", "0.64976114", "0.6497357", "0.64960563", "0.64932823", "0.6492585", "0.6488369", "0.64882344", "0.64870757", "0.6486599", "0.6484805", "0.64838725", "0.64838725", "0.6482788", "0.6480484", "0.64774764", "0.6472806", "0.6470545", "0.6469108" ]
0.7996014
0
Use callbacks to share common setup or constraints between actions.
def set_space_type @space_type = SpaceType.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 space_type_params params.require(:space_type).permit( :name, :short_name, :spaces_count, :notes, equipment_items_attributes: [:id, :qty, :notes, :equipment_model_id, :_destroy] ) 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
Add a file (IO instance) or filename (responding to to_str) to this group.
def add(file_or_filename) if file_or_filename.respond_to?(:to_io) add_file file_or_filename.to_io elsif file_or_filename.respond_to?(:to_str) add_filename file_or_filename end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_file file\n if not File.file? file\n raise ArgumentError\n else\n @files.push file\n puts \"#{File.basename file} added to package #{@name}\" if @verbose\n end\n end", "def add_file(str)\n\t\[email protected](str)\n\tend", "def add_file (file)\n @files[file.path] = file\n end", "def add_file (file)\n @files[file.path] = file\n end", "def add_file(file)\n @files << file\n end", "def add_file file, opts={}\n opts[:mime_type] ||= Ddr::Utils.mime_type_for(file)\n opts[:original_name] ||= Ddr::Utils.file_name_for(file)\n\n # @file_to_add is set for callbacks to access the data\n self.file_to_add = file\n\n run_callbacks(:add_file) do\n super\n end\n\n # clear the instance data\n self.file_to_add = nil\n end", "def addFile(file)\r\n @files << file\r\n end", "def add(filename)\n not_implemented('add')\n end", "def add_file(file)\n @files[file.name] = file\n file.parent = self\n end", "def add_file src, target, exclude = nil\n @files << FileItem.new(src, target, exclude)\n self\n end", "def add_file(*args)\n context = args.pop\n file_path_hash_or_string, content, commit_msg = args\n file_path_hash = file_path_hash_form(file_path_hash_or_string)\n get_adapter_repo(context).add_file(file_path_hash, content, commit_msg)\n end", "def add_file(file)\n raise FileError, 'Piece length must be greater than 0' if @data['info']['piece length'] <= 0\n\n if @data['info'].key?('name') && @data['info'].key?('length')\n @data['info']['files'] = []\n @data['info']['files'] << {\n 'path' => [@data['info']['name']],\n 'length' => @data['info']['length']\n }\n @data['info'].delete('name')\n @data['info'].delete('length')\n end\n\n if @data['info'].key?('files')\n @data['info']['files'] << {\n 'path' => file.split('/'),\n 'length' => ::File.size(file)\n }\n @data['info']['pieces'] += hash_file(file, @data['info']['piece length'])\n return\n end\n\n @data['info']['name'] = ::File.basename(file)\n @data['info']['length'] = ::File.size(file)\n @data['info']['pieces'] = hash_file(file, @data['info']['piece length'])\n end", "def addFile path, username, groupname, rights = 0640\n userRights = getUserRights rights\n groupRights = getGroupRights rights\n othersRights = getOthersRights rights\n file = Modeles::File.new(:path => username + '/' +\n groupname + '/' +\n path,\n :userRights => userRights,\n :groupRights => groupRights,\n :othersRights => othersRights)\n user = Modeles::User.find_by_name username\n return nil if user.nil?\n group = Modeles::Group.find_by_name groupname\n return nil if group.nil?\n file.user = user\n file.group = group\n ret = file.save\n if ret\n FileInfos.new file\n end\n end", "def +(fname)\n FileObject[path, fname]\n end", "def add_file(file)\n setup_file_tailer file\n self\n end", "def file(*args)\r\n args.each do |arg|\r\n add_formatted arg\r\n end\r\n self\r\n end", "def add_content(io_or_filename)\n if io_or_filename.class == String\n File.open(io_or_filename, mode='r') do |f|\n add_content_io f\n end\n else\n add_content_io io_or_filename\n end\n self\n end", "def add_file(values)\n convert_to_multipart unless self.multipart? || self.body.decoded.blank?\n add_multipart_mixed_header\n if values.is_a?(String)\n basename = File.basename(values)\n filedata = File.open(values, 'rb') { |f| f.read }\n else\n basename = values[:filename]\n filedata = values\n unless filedata[:content]\n filedata = values.merge(:content=>File.open(values[:filename], 'rb') { |f| f.read })\n end\n end\n self.attachments[basename] = filedata\n end", "def add_file path\n if File.exist? path\n @files << path\n else\n raise Errno::ENOENT, \"File '#{path}' doesn't exist\"\n end\n end", "def add_file(file_name, data, flags)\n data = filter \"decode\", file_name, data\n path = working_join file_name\n \n File.unlink path rescue nil\n \n if flags.include? 'l' # if it's a link\n @file_opener.symlink path, data\n else\n @file_opener.open(path, 'w') {|f| f.write data }\n File.set_flag path, false, true if flags.include? 'x'\n end\n end", "def project_file_add(project_id, file)\n put(\"/projects/#{project_id}/files\", nil, file)\n end", "def add_file entry, content = nil\n path = repo_path.join entry\n dir, filename = path.split unless entry.end_with? \"/\"\n\n FileUtils.mkdir_p dir.to_s == '.' ? repo_path : dir\n FileUtils.touch path if filename\n File.write path, content if filename && content\n end", "def add_file(file, release_id, package_id, processor=nil)\n page = '/frs/admin/editrelease.php'\n\n userfile = open file, 'rb'\n\n type_id = userfile.path[%r|\\.[^\\./]+$|]\n type_id = FILETYPES[type_id]\n processor_id = PROCESSORS[processor.downcase]\n\n form = {\n \"step2\" => '1',\n \"group_id\" => group_id,\n \"package_id\" => package_id,\n \"release_id\" => release_id,\n \"userfile\" => userfile,\n \"type_id\" => type_id,\n \"processor_id\" => processor_id,\n \"submit\" => \"Add This File\"\n }\n\n boundary = Array::new(8){ \"%2.2d\" % rand(42) }.join('__')\n boundary = \"multipart/form-data; boundary=___#{ boundary }___\"\n\n http_post(page, form, 'content-type' => boundary)\n end", "def add_file(file_params)\n # append a new file to our the current identity's list of bruse_files\n\n file = BruseFile.new(file_params)\n\n if bruse_files << file\n # return file\n file\n else\n # could not append file!\n file.destroy\n nil\n end\n end", "def add_file(file, dsid, file_name) \n return add_external_file(file, dsid, file_name) if dsid == 'content'\n super\n end", "def add_file(file, dsid, file_name) \n return add_external_file(file, file_name) if dsid == 'content'\n super\n end", "def append_file(fn, str)\n File.open(fn, 'a') do |f|\n f.puts str\n end\n end", "def add_file(path)\n File.readlines(path).each { |s| self << s.strip }\n nil\n end", "def addFile(src, dest=nil)\n orig = dest\n dest = File.join(@defaultPath, File.basename(src)) if !dest\n @files[src] = dest\n end", "def add_file(file_path, description = nil, convert_to = nil, pingback_url = nil, comment = nil)\n Dropio::Resource.client.add_file(self, file_path, description, convert_to, pingback_url, comment)\n end", "def add_file(file, line = T.unsafe(nil), has_comments = T.unsafe(nil)); end", "def add_file(file)\n if file.class == ActionDispatch::Http::UploadedFile\n file_object = file.tempfile\n file_name = file.original_filename\n mime_type = file.content_type\n elsif file.class == File\n file_object = file\n file_name = Pathname.new(file.path).basename.to_s\n mime_type = mime_type_from_ext(file_name)\n else\n return false\n end\n\n self.add_file_datastream(file_object, label: file_name, mimeType: mime_type, dsid: 'content')\n set_file_timestamps(file_object)\n self.checksum = generate_checksum(file_object)\n self.original_filename = file_name\n self.mime_type = mime_type\n self.size = file.size.to_s\n self.file_uuid = UUID.new.generate\n true\n end", "def add_file(name)\n @files[name] = nil unless @files.has_key?(name)\n end", "def add(file); @actions << Action::AddAction.new(file); end", "def optional_file(val)\n path = val\n io = val if String === val\n if Hash === val\n raise 'argument to optional_file should be length 1' if val.size != 1\n path = val.first[0]\n io = val.first[1]\n end\n @book.add_optional_file(path, io)\n end", "def addFile(name)\n @filesQueue.push(name)\n end", "def append_to_file(file, str)\n File.open(file, 'a+') { |f| f << str }\n end", "def append(filename)\n return @filemgr.append(filename, @contents)\n end", "def add_file(repo_obj,path,content,msg=nil)\n Response.wrap_helper_actions() do\n ret = Hash.new\n repo_obj.add_file(path,content)\n ret[\"message\"] = msg if msg\n ret\n end\n end", "def add_file(file)\n @files_so_far += 1\n @display.print_file @files_so_far, file\n end", "def add_file(name, content)\n full_path = File.join(path, name)\n file = MirrorFile.new(full_path)\n\n file.write(content)\n\n file\n end", "def add( file, number )\n\t\t@files[ number ] = file\n\tend", "def add_file(fname, fdata=nil, xtra=nil, comment=nil)\n super(randomize(fname), randomize(fdata), xtra, comment)\n end", "def add_file_tag(tag_level, tag_value, tag_type, priority=0)\n @file_tags<< {:level => tag_level, :name => tag_value, :type=> tag_type}\n @file_tag_tuple_priority=priority\n end", "def add_file(path_to_file, options)\n puts \"INSIDE add_file METHOD\"\n puts \"OPTIONS: #{options.inspect}\"\n name = options[:name] || File.basename(path_to_file)\n if options[:type]\n redis_collection = new name, options[:type]\n else\n redis_collection = new name\n end\n \n IO.foreach path_to_file do |line|\n redis_collection << line\n end\n redis_collection\n end", "def addfile(contents, path, client = nil, clientip = nil)\n contents = Base64.decode64(contents) if client\n bucket = Puppet::FileBucket::File.new(contents)\n Puppet::FileBucket::File.indirection.save(bucket)\n end", "def add_file(file_path)\n @ole.AddFile(file_path)\n end", "def add_file(file_path)\n @ole.AddFile(file_path)\n end", "def add_file( location, permission = 660 )\n\n files_nodes = @sopm.xpath('/otrs_package/Filelist/File')\n\n update = true\n files_nodes.each { |files_node|\n\n next if files_node['Location'] != location\n next if files_node['Permission'] != permission\n\n update = false\n\n break\n }\n\n return if !update\n\n # append Filelist/File\n new_file_entry = Nokogiri::XML::Node.new 'File', sopm\n new_file_entry['Permission'] = permission\n new_file_entry['Location'] = location\n\n files_nodes.last.next = \"\\n \" + new_file_entry.to_xml\n\n store\n end", "def add_file(filename)\n dir = File.dirname(filename).gsub(\"#{@dest}\",\".\")\n fn = File.basename(filename)\n folder = @folders[dir] || @folders[dir]=[]\n folder << fn\n end", "def add_file(filename)\n dir = File.dirname(filename).gsub(\"#{@dest}\",\".\")\n fn = File.basename(filename)\n folder = @folders[dir] || @folders[dir]=[]\n folder << fn\n end", "def new_file(path, sub_group_path = nil, set_name = true)\n file = project.new(PBXFileReference)\n file.path = path.to_s\n file.update_last_known_file_type\n\n target = find_subpath(sub_group_path, true)\n target.children << file\n\n same_path_of_group = target.path == file.pathname.dirname.to_s\n same_path_project = file.pathname.dirname.to_s == '.' && target.path.nil?\n unless same_path_of_group || same_path_project\n file.name = file.pathname.basename.to_s\n end\n file\n end", "def add_file(path, *args)\n puts \"#{@indent}#{basename(path)}#{id(path)}\"\n end", "def add_to_file entry, content\n path = repo_path.join entry\n File.write path, content, :mode => \"a\"\n end", "def add_file name, file, mime, content\n @params << \n \"Content-Disposition: form-data; name=\\\"#{name}\\\"; filename=\\\"#{file}\\\"\\n\" +\n \"Content-Transfer-Encoding: binary\\n\" +\n \"Content-Type: #{mime}\\n\" + \n \"\\n\" + \n \"#{content}\"\n end", "def add_file(tar_writer, file, root_path)\n stat = File.stat(file)\n name = Pathname.new(file).relative_path_from(root_path).to_s\n tar_writer.add_file_simple(name, stat.mode, stat.size) do |io|\n File.open(file, 'rb') { |f| IO.copy_stream(f, io) }\n end\n rescue Errno::ENOENT\n nil\n end", "def add file\n file.download unless file.downloaded?\n @files << file\n end", "def add_file( location, permission = 644 )\n parse\n\n update = true\n @structure['files'].each { |file|\n\n next if file['location'] != location\n next if file['permission'] != permission\n\n update = false\n\n break\n }\n return if !update\n\n @structure['files'].push({\n 'location' => location,\n 'permission' => permission,\n })\n\n store\n end", "def add_file_datastream(file, opts={})\n label = opts.has_key?(:label) ? opts[:label] : \"\"\n attrs = {:dsLabel => label, :controlGroup => 'M', :blob => file, :prefix=>opts[:prefix]}\n if opts.has_key?(:mime_type)\n attrs.merge!({:mimeType=>opts[:mime_type]})\n elsif opts.has_key?(:mimeType)\n attrs.merge!({:mimeType=>opts[:mimeType]})\n elsif opts.has_key?(:content_type)\n attrs.merge!({:mimeType=>opts[:content_type]})\n end\n attrs[:checksumType] = opts[:checksumType] if opts[:checksumType]\n attrs[:versionable] = opts[:versionable] unless opts[:versionable].nil?\n ds = create_datastream(self.class.datastream_class_for_name(opts[:dsid]), opts[:dsid], attrs)\n add_datastream(ds).tap do |dsid|\n self.class.build_datastream_accessor(dsid) unless respond_to? dsid\n end\n end", "def add_file(file)\n logger.info(\" ########### add file\")\n if (file.nil?)\n logger.error(\"file is nil\")\n self.original_filename = nil\n self.has_attached_file = false\n return false\n elsif (!check_file?(file))\n logger.error(\"error uploading file\")\n self.original_filename = nil\n self.has_attached_file = false\n\n return false\n else\n self.add_file_datastream(file, :label => file.original_filename, :mimeType => file.content_type, :dsid => 'content', :controlGroup => 'M')\n self.original_filename = file.original_filename\n self.mime_type = file.content_type\n self.has_attached_file = true\n end\n return true\n end", "def attaches_file(id_or_name_or_label, path)\n field = find_field(id_or_name_or_label, FileField)\n field.set(path)\n end", "def add_file(file)\n @zip.put_next_entry(file.path)\n @zip.write(file.read)\n end", "def append_file(filename,data)\n begin\n File.open(filename, \"a+\") do |f|\n f<< data\n end\n rescue Exception => e\n puts e.message \n end\n end", "def append_ext(str)\r\n unless String === str\r\n raise ArgumentError, \"argument musi byc typu String\"\r\n else\r\n str << \".txt\"\r\n end\r\nend", "def add_file_with_data(file_path, data)\n # 600 is the default permission the file will have. Readable/writable by owner only.\n @tar.add_file_simple(file_path, 0o600, data.bytesize) do |io|\n io.write(data)\n end\n @total_size_processed += data.bytesize\n end", "def append_file(fname, content)\n begin\n aFile = File.new(fname,\"a\")\n aFile.puts content\n aFile.close\n rescue Exception=>e\n # logger.error e\n p e.inspect\n end\nend", "def add(path); end", "def file\n add FileCursor.new\n end", "def add_extra_files(*files); end", "def create_file(title, description, parent_id, mime_type, file_name)\n \tinsert_file(title, description, parent_id, 'application/vnd.google-apps.file', file_name)\n\tend", "def add_file(urls, options = {})\n return if(urls.blank?)\n urls = [ urls ] unless(urls.is_a?(Array))\n files = urls.collect { |url| { :url => get_absolute_file_url(url), :options => options } }\n @current.attributes[:files] = files if(files.size > 0)\n end", "def add_file(attrs)\n return if search(\"//ovf:References/ovf:File[@ovf:href='#{attrs[:href]}']\").count == 1\n file = Nokogiri::XML::Node.new 'File', self\n file['ovf:href'] = attrs[:href] if attrs[:href]\n if attrs[:id]\n file['ovf:id'] = attrs[:id]\n else\n n = filecount + 1\n file['ovf:id'] = \"file#{n}\"\n end\n at('//ovf:References').add_child file\n end", "def file_append(f, t)\n File.open(f, \"a\") { |f| f.write t }\n end", "def addFile(filePath, hash)\n #N Without this the path won't be broken up into elements so that we can start by processing the first element\n pathElements = getPathElements(filePath)\n #N Without this check, we would attempt to process an invalid path consisting of an empty string or no path elements (since the path should always contain at least one element consisting of the file name)\n if pathElements.length == 0\n #N Without this, the case of zero path elements will not be treated as an error\n raise \"Invalid file path: #{filePath.inspect}\"\n end\n #N Without this check, the cases of having the immediate file name (to be added as a file in this directory) and having a file within a sub-directory will not be distinguished\n if pathElements.length == 1\n #N Without this, the single path element will not be treated as being the immediate file name\n fileName = pathElements[0]\n #N Without this, we won't have our object representing the file name and a hash of its contents\n fileContent = FileContent.new(fileName, hash, @pathElements)\n #N Without this, the file&content object won't be added to the list of files contained in this directory\n files << fileContent\n #N Without this, we won't be able to look up the file&content object by name.\n fileByName[fileName] = fileContent\n else\n #N Without this, we won't have the first part of the file path required to identify the immediate sub-directory that it is found in.\n pathStart = pathElements[0]\n #N Without this, we won't have the rest of the path which needs to be passed to the content tree in the immediate sub-directory\n restOfPath = pathElements[1..-1]\n #N Without this, the file & hash won't be added into the sub-directory's content tree\n getContentTreeForSubDir(pathStart).addFile(restOfPath, hash)\n end\n end", "def add_attachment(summary, file, **kwargs)\n @client.add_attachment(summary, file, id, **kwargs).first\n end", "def zip_add_file(zip, filename, content)\n print_status(\"Adding '#{filename}' (#{content.length} bytes)\");\n zip.add_file(filename, content, nil, nil, nil)\n end", "def store= store\n super\n\n @file = @store.add_file @file.full_name if @file\n end", "def store= store\n super\n\n @file = @store.add_file @file.full_name if @file\n end", "def store= store\n super\n\n @file = @store.add_file @file.full_name if @file\n end", "def store= store\n super\n\n @file = @store.add_file @file.full_name if @file\n end", "def record(filename)\n contents = File.read(filename) rescue nil\n files[filename] = contents unless files.has_key? filename\n end", "def add_file_attachment(new_attachments)\n attachments = @task.attachments\n attachments += new_attachments\n @task.attachments = attachments\n end", "def add_file(file, skip_fits)\n if file.class == ActionDispatch::Http::UploadedFile\n file_object = file.tempfile\n file_name = file.original_filename\n mime_type = file.content_type\n elsif file.class == File\n file_object = file\n file_name = Pathname.new(file.path).basename.to_s\n mime_type = mime_type_from_ext(file_name)\n else\n return false\n end\n\n self.add_file_datastream(file_object, label: file_name, mimeType: mime_type, dsid: 'content')\n set_file_timestamps(file_object)\n self.checksum = generate_checksum(file_object)\n self.original_filename = file_name\n self.mime_type = mime_type\n self.size = file.size\n self.file_uuid = UUID.new.generate\n unless skip_fits\n self.add_fits_metadata_datastream(file)\n end\n true\n end", "def file=(a)\n @file = a\n @real_fname = a\n end", "def add_attachment(summary, file, *ids, **kwargs)\n params = {}\n params[:ids] = ids\n params[:summary] = summary\n params[:content_type] = kwargs.fetch(:content_type, 'application/octet-stream')\n params[:file_name] = kwargs.fetch(:file_name, File.basename(file))\n params[:is_patch] = kwargs[:patch?] if kwargs[:patch?]\n params[:is_private] = kwargs[:private?] if kwargs[:private?]\n params[:comment] = kwargs[:comment] if kwargs[:comment]\n params[:data] = XMLRPC::Base64.new(file.read)\n ret = @client.call('Bug.add_attachment', params)\n handle_faults(ret)\n ret['ids']\n end", "def add_file( file_path )\n\n path_to_dot_git = File.join( @git_folder_path, \".git\" )\n git_add_cmd = \"git --git-dir=#{path_to_dot_git} --work-tree=#{@git_folder_path} add #{file_path}\"\n log.info(x) { \"[git] single file add command => #{git_add_cmd}\" }\n %x[#{git_add_cmd}];\n log.info(x) { \"[git] has added #{file_path} into the git repository.\" }\n\n end", "def add_file absolute_name, relative_name: absolute_name, parser: nil\n unless top_level = @files_hash[relative_name] then\n top_level = RDoc::TopLevel.new absolute_name, relative_name\n top_level.parser = parser if parser\n top_level.store = self\n @files_hash[relative_name] = top_level\n @text_files_hash[relative_name] = top_level if top_level.text?\n end\n\n top_level\n end", "def add_file(rev, full_path, content, _mime_type = 'text/plain')\n if file_exists?(rev, full_path)\n raise Repository::FileExistsConflict, full_path\n end\n # file does not exist, so add it\n creation_time = Time.current\n file = Repository::RevisionFile.new(rev.revision_identifier, {\n name: File.basename(full_path),\n path: File.dirname(full_path),\n last_modified_revision: rev.revision_identifier,\n changed: true,\n user_id: rev.user_id,\n last_modified_date: creation_time,\n submitted_date: creation_time\n })\n rev.__add_file(file, content)\n rev\n end", "def push_file(source, original_filename, id = nil)\n data = self.read_from(source)\n self.grid.put(data, filename: original_filename, _id: id)\n end", "def add_file(file)\n uploader_to_add = PostImageUploader.new\n uploader_to_add.cache!(file)\n @uploaders.delete_if { |x| x.filename == file.original_filename }\n @uploaders << uploader_to_add\n end", "def basic_file_object(path)\n bf = BasicFile.new\n file = File.open(path)\n raise 'file cannot be nil!' if file.nil?\n bf.add_file(file, true)\n bf.save\n bf\n end", "def add_content_to_file(file_path, content)\n names = file_path.split('/')\n file_name = names.pop\n directory = self.mkdir(names.join('/'))\n directory.add_content_to_file(file_name, content)\n end", "def addFile(url, local_name)\r\n\t\t\t`bitsadmin /rawreturn /addfile {#{@id}} #{url} #{local_name}`\r\n\t\tend", "def append(filename, text)\n File.open(filename,\"a\") {|f| f << text + \"\\n\"}\n end", "def append(filename, text)\n File.open(filename,\"a\") {|f| f << text + \"\\n\"}\n end", "def <<( str )\n path = Pathname( str )\n\n case\n when !path.exist?\n raise Errno::ENOENT, path.to_path\n when !path.directory?\n raise Errno::ENOTDIR, path.to_path\n else\n super path.expand_path\n end\n end", "def attach( file_or_files, filename = file_or_files.is_a?(File) ? File.basename(file_or_files.path) : nil,\n type = nil, headers = nil)\n @mailer.attach(file_or_files, filename, type, headers)\n end", "def file_set(file_expression, label=:default, &block)\n @file_sets << [file_expression, label, block]\n end", "def file=(value)\n @file = value\n end", "def file=(value)\n @file = value\n end" ]
[ "0.6983619", "0.6971453", "0.68681395", "0.68613744", "0.68383956", "0.67734784", "0.6758105", "0.67193085", "0.6655178", "0.6460086", "0.64396197", "0.6312505", "0.6234488", "0.6214845", "0.61766", "0.61743474", "0.61599505", "0.61571217", "0.6109019", "0.6107618", "0.59985334", "0.59956044", "0.59698063", "0.5962663", "0.5948102", "0.5919999", "0.59111947", "0.58851075", "0.5870706", "0.5870075", "0.5865109", "0.5841763", "0.58264726", "0.5818277", "0.581817", "0.5793481", "0.5771216", "0.57678366", "0.57622904", "0.5760197", "0.5745099", "0.57391435", "0.57090247", "0.5685635", "0.56705284", "0.56449515", "0.5634776", "0.5634776", "0.5619942", "0.5618113", "0.5618113", "0.5615231", "0.56050295", "0.55884033", "0.55742615", "0.55643773", "0.55545986", "0.5551976", "0.5543251", "0.5525941", "0.55164", "0.5505594", "0.55005735", "0.54978806", "0.5495428", "0.5487273", "0.54488885", "0.5443864", "0.54284436", "0.54201514", "0.54043835", "0.53992796", "0.5396776", "0.53858477", "0.5377661", "0.5377141", "0.536965", "0.536965", "0.536965", "0.536965", "0.536721", "0.53519833", "0.53451866", "0.5345065", "0.5343784", "0.53385633", "0.53367364", "0.53250325", "0.5312974", "0.53014535", "0.5289499", "0.5287453", "0.52870566", "0.5281054", "0.5281054", "0.52718407", "0.52619094", "0.5245419", "0.52375674", "0.52375674" ]
0.7960889
0
Add the IO instance +file+ to this group.
def add_file(file) setup_file_tailer file self end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_file(file)\n @files << file\n end", "def add_file (file)\n @files[file.path] = file\n end", "def add_file(file)\n @files[file.name] = file\n file.parent = self\n end", "def addFile(file)\r\n @files << file\r\n end", "def add_file (file)\n @files[file.path] = file\n end", "def add_file file\n if not File.file? file\n raise ArgumentError\n else\n @files.push file\n puts \"#{File.basename file} added to package #{@name}\" if @verbose\n end\n end", "def add_file file, opts={}\n opts[:mime_type] ||= Ddr::Utils.mime_type_for(file)\n opts[:original_name] ||= Ddr::Utils.file_name_for(file)\n\n # @file_to_add is set for callbacks to access the data\n self.file_to_add = file\n\n run_callbacks(:add_file) do\n super\n end\n\n # clear the instance data\n self.file_to_add = nil\n end", "def add(filename)\n not_implemented('add')\n end", "def add_file(file)\n @files_so_far += 1\n @display.print_file @files_so_far, file\n end", "def add(file_or_filename)\n if file_or_filename.respond_to?(:to_io)\n add_file file_or_filename.to_io\n elsif file_or_filename.respond_to?(:to_str)\n add_filename file_or_filename\n end\n end", "def add(file); @actions << Action::AddAction.new(file); end", "def file=(file)\n @prerequisites << file\n @queue << \"file #{file}\"\n @file = file\n end", "def project_file_add(project_id, file)\n put(\"/projects/#{project_id}/files\", nil, file)\n end", "def add_file(file)\n @zip.put_next_entry(file.path)\n @zip.write(file.read)\n end", "def add_file(file)\n raise FileError, 'Piece length must be greater than 0' if @data['info']['piece length'] <= 0\n\n if @data['info'].key?('name') && @data['info'].key?('length')\n @data['info']['files'] = []\n @data['info']['files'] << {\n 'path' => [@data['info']['name']],\n 'length' => @data['info']['length']\n }\n @data['info'].delete('name')\n @data['info'].delete('length')\n end\n\n if @data['info'].key?('files')\n @data['info']['files'] << {\n 'path' => file.split('/'),\n 'length' => ::File.size(file)\n }\n @data['info']['pieces'] += hash_file(file, @data['info']['piece length'])\n return\n end\n\n @data['info']['name'] = ::File.basename(file)\n @data['info']['length'] = ::File.size(file)\n @data['info']['pieces'] = hash_file(file, @data['info']['piece length'])\n end", "def add_file(file)\n index = @repo.index\n index.add path: file, oid: (Rugged::Blob.from_workdir @repo, file), mode: 0100644\n index.write\n\n @affected_files << file\n end", "def add( file, number )\n\t\t@files[ number ] = file\n\tend", "def file\n add FileCursor.new\n end", "def add file\n file.download unless file.downloaded?\n @files << file\n end", "def add_file(file)\n if file.class == ActionDispatch::Http::UploadedFile\n file_object = file.tempfile\n file_name = file.original_filename\n mime_type = file.content_type\n elsif file.class == File\n file_object = file\n file_name = Pathname.new(file.path).basename.to_s\n mime_type = mime_type_from_ext(file_name)\n else\n return false\n end\n\n self.add_file_datastream(file_object, label: file_name, mimeType: mime_type, dsid: 'content')\n set_file_timestamps(file_object)\n self.checksum = generate_checksum(file_object)\n self.original_filename = file_name\n self.mime_type = mime_type\n self.size = file.size.to_s\n self.file_uuid = UUID.new.generate\n true\n end", "def append(file)\n return file.each { |f| self << f } if file.class == Array\n return if @files.include?(file)\n\n if !@dependency_resolver.nil?\n path = File.expand_path(file)\n resolve_dependencies(path)\n elsif [email protected]?(file)\n @files << file\n end\n end", "def add(file)\n @file = file\n FileUtils.cp_r(file.path,folder_path)\n unless system(\"cd #{repo_path};git add .\")\n raise GitCloud::GitException.new(\"Add\")\n end\n end", "def add_file(file_path)\n @ole.AddFile(file_path)\n end", "def add_file(file_path)\n @ole.AddFile(file_path)\n end", "def add_file path\n if File.exist? path\n @files << path\n else\n raise Errno::ENOENT, \"File '#{path}' doesn't exist\"\n end\n end", "def add_file(file_params)\n # append a new file to our the current identity's list of bruse_files\n\n file = BruseFile.new(file_params)\n\n if bruse_files << file\n # return file\n file\n else\n # could not append file!\n file.destroy\n nil\n end\n end", "def add_file(file)\n uploader_to_add = PostImageUploader.new\n uploader_to_add.cache!(file)\n @uploaders.delete_if { |x| x.filename == file.original_filename }\n @uploaders << uploader_to_add\n end", "def add_file src, target, exclude = nil\n @files << FileItem.new(src, target, exclude)\n self\n end", "def add_file(path)\n File.readlines(path).each { |s| self << s.strip }\n nil\n end", "def add_file(str)\n\t\[email protected](str)\n\tend", "def add_keyfile(file)\n ProcessWatcher.watch(\"ssh-add\", [file], nil, -1, 10)\n end", "def +(fname)\n FileObject[path, fname]\n end", "def add_file(file, line = T.unsafe(nil), has_comments = T.unsafe(nil)); end", "def store(file, dependencies = nil)\n @mutex.synchronize do\n @data[file.to_s] = File.new(file, dependencies: dependencies)\n end\n end", "def add_file(file)\n logger.info(\" ########### add file\")\n if (file.nil?)\n logger.error(\"file is nil\")\n self.original_filename = nil\n self.has_attached_file = false\n return false\n elsif (!check_file?(file))\n logger.error(\"error uploading file\")\n self.original_filename = nil\n self.has_attached_file = false\n\n return false\n else\n self.add_file_datastream(file, :label => file.original_filename, :mimeType => file.content_type, :dsid => 'content', :controlGroup => 'M')\n self.original_filename = file.original_filename\n self.mime_type = file.content_type\n self.has_attached_file = true\n end\n return true\n end", "def add_file(file) \n puts \"Reading file #{file}\" if ( $VERBOSE )\n words = Words.parse_file(file)\n if ( $VERBOSE )\n puts \"Read in #{words.length} words.\"\n puts \"Inserting words from file #{file}\"\n STDOUT.flush()\n end\n @mc.add_elems(words)\n end", "def file=(file)\n self.fileRef = file.uuid\n end", "def set(file)\n self.file = file\n end", "def add_idl_file(idl_file, name = nil)\n # IDLFiles listed by component recipes are not managed\n # so we do not register the recipe with the IDLFile,\n # unless it is the component idl file self.\n # this is done later in recipe #verify\n @idl_files[name || idl_file.full_path] = idl_file\n end", "def add_file(file, dsid, file_name) \n return add_external_file(file, dsid, file_name) if dsid == 'content'\n super\n end", "def file=(value)\n @file = value\n end", "def file=(value)\n @file = value\n end", "def add_file(name, content)\n full_path = File.join(path, name)\n file = MirrorFile.new(full_path)\n\n file.write(content)\n\n file\n end", "def addFile(name)\n @filesQueue.push(name)\n end", "def add_file_datastream(file, opts={})\n label = opts.has_key?(:label) ? opts[:label] : \"\"\n attrs = {:dsLabel => label, :controlGroup => 'M', :blob => file, :prefix=>opts[:prefix]}\n if opts.has_key?(:mime_type)\n attrs.merge!({:mimeType=>opts[:mime_type]})\n elsif opts.has_key?(:mimeType)\n attrs.merge!({:mimeType=>opts[:mimeType]})\n elsif opts.has_key?(:content_type)\n attrs.merge!({:mimeType=>opts[:content_type]})\n end\n attrs[:checksumType] = opts[:checksumType] if opts[:checksumType]\n attrs[:versionable] = opts[:versionable] unless opts[:versionable].nil?\n ds = create_datastream(self.class.datastream_class_for_name(opts[:dsid]), opts[:dsid], attrs)\n add_datastream(ds).tap do |dsid|\n self.class.build_datastream_accessor(dsid) unless respond_to? dsid\n end\n end", "def add_file(file, dsid, file_name) \n return add_external_file(file, file_name) if dsid == 'content'\n super\n end", "def append_to_file(file, str)\n File.open(file, 'a+') { |f| f << str }\n end", "def file(*args)\r\n args.each do |arg|\r\n add_formatted arg\r\n end\r\n self\r\n end", "def append_to_file(file, eol: $/)\n file.to_pathname.append_lines(self, eol: eol)\n self\n end", "def write(file)\n self.files.each { |l| file.puts l }\n end", "def add( key_file )\n @key_files.push( key_file ).uniq!\n self\n end", "def attach(file)\n existing_file = self.file\n\n file.owner = self\n file.display_filename = existing_file.display_filename if existing_file\n if file.save and existing_file then\n existing_file.owner_type = nil\n existing_file.owner_id = nil\n existing_file.save\n end\n end", "def add_file!(paginated_file)\n container = @website_file.parent\n container.append_child(paginated_file)\n stash_paginated_file(paginated_file)\n end", "def add_file(file_path, description = nil, convert_to = nil, pingback_url = nil, comment = nil)\n Dropio::Resource.client.add_file(self, file_path, description, convert_to, pingback_url, comment)\n end", "def add_file( location, permission = 660 )\n\n files_nodes = @sopm.xpath('/otrs_package/Filelist/File')\n\n update = true\n files_nodes.each { |files_node|\n\n next if files_node['Location'] != location\n next if files_node['Permission'] != permission\n\n update = false\n\n break\n }\n\n return if !update\n\n # append Filelist/File\n new_file_entry = Nokogiri::XML::Node.new 'File', sopm\n new_file_entry['Permission'] = permission\n new_file_entry['Location'] = location\n\n files_nodes.last.next = \"\\n \" + new_file_entry.to_xml\n\n store\n end", "def add_section(name, file)\n raise \"A section with name #{name} already exists\" if include?(name)\n result = Section.new(name, file)\n @files[file] ||= []\n @files[file] << result\n result\n end", "def add(file)\n # add file to object db\n return false if !File.exists?(file)\n return false if !File.file?(file)\n \n sha = get_raw_repo.put_raw_object(File.read(file), 'blob')\n \n # add it to the index\n @git_index.add(file, sha)\n end", "def add_file( file_path )\n\n path_to_dot_git = File.join( @git_folder_path, \".git\" )\n git_add_cmd = \"git --git-dir=#{path_to_dot_git} --work-tree=#{@git_folder_path} add #{file_path}\"\n log.info(x) { \"[git] single file add command => #{git_add_cmd}\" }\n %x[#{git_add_cmd}];\n log.info(x) { \"[git] has added #{file_path} into the git repository.\" }\n\n end", "def add_file(name)\n @files[name] = nil unless @files.has_key?(name)\n end", "def add_file(path_to_file, options)\n puts \"INSIDE add_file METHOD\"\n puts \"OPTIONS: #{options.inspect}\"\n name = options[:name] || File.basename(path_to_file)\n if options[:type]\n redis_collection = new name, options[:type]\n else\n redis_collection = new name\n end\n \n IO.foreach path_to_file do |line|\n redis_collection << line\n end\n redis_collection\n end", "def file_append(f, t)\n File.open(f, \"a\") { |f| f.write t }\n end", "def add_file(*args)\n context = args.pop\n file_path_hash_or_string, content, commit_msg = args\n file_path_hash = file_path_hash_form(file_path_hash_or_string)\n get_adapter_repo(context).add_file(file_path_hash, content, commit_msg)\n end", "def add_line_to_file(file, line)\n File.open(file, \"a\") {|f| f.puts(\"#{line}\")}\n end", "def add_file(file, release_id, package_id, processor=nil)\n page = '/frs/admin/editrelease.php'\n\n userfile = open file, 'rb'\n\n type_id = userfile.path[%r|\\.[^\\./]+$|]\n type_id = FILETYPES[type_id]\n processor_id = PROCESSORS[processor.downcase]\n\n form = {\n \"step2\" => '1',\n \"group_id\" => group_id,\n \"package_id\" => package_id,\n \"release_id\" => release_id,\n \"userfile\" => userfile,\n \"type_id\" => type_id,\n \"processor_id\" => processor_id,\n \"submit\" => \"Add This File\"\n }\n\n boundary = Array::new(8){ \"%2.2d\" % rand(42) }.join('__')\n boundary = \"multipart/form-data; boundary=___#{ boundary }___\"\n\n http_post(page, form, 'content-type' => boundary)\n end", "def file\n @file ||= Operations::FileFactory.new(self)\n end", "def <<( file_path )\n if file_path.is_a?( Array )\n file = file_path.shift\n path = file_path\n else\n file = file_path\n path = []\n end\n File.open( file ) do |file_io|\n while( piece = file_io.read( @contents['info']['piece length'] - ( @carry_over ? @carry_over.length : 0 ) ) ) do\n if @carry_over\n piece = @carry_over + piece\n @carry_over = nil\n end\n if piece.length < @contents['info']['piece length']\n @carry_over = piece\n else\n @contents['info']['pieces'] << Digest::SHA1.digest( piece )\n end\n end\n @contents['info']['files'] << {\n 'path' => [ path, File.basename( file ) ].flatten,\n 'length' => file_io.pos\n }\n end\n self\n end", "def add_file( location, permission = 644 )\n parse\n\n update = true\n @structure['files'].each { |file|\n\n next if file['location'] != location\n next if file['permission'] != permission\n\n update = false\n\n break\n }\n return if !update\n\n @structure['files'].push({\n 'location' => location,\n 'permission' => permission,\n })\n\n store\n end", "def file(file_id)\n self.class.new @repo, @path, :file_id => file_id, :file_log => file_log\n end", "def add(file_asset)\n\t\t\tkparams = {}\n\t\t\tclient.add_param(kparams, 'fileAsset', file_asset);\n\t\t\tclient.queue_service_action_call('fileasset', 'add', kparams);\n\t\t\tif (client.is_multirequest)\n\t\t\t\treturn nil;\n\t\t\tend\n\t\t\treturn client.do_queue();\n\t\tend", "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 push(asset)\n @group.add_asset(asset)\n self\n end", "def add_file(file, skip_fits)\n if file.class == ActionDispatch::Http::UploadedFile\n file_object = file.tempfile\n file_name = file.original_filename\n mime_type = file.content_type\n elsif file.class == File\n file_object = file\n file_name = Pathname.new(file.path).basename.to_s\n mime_type = mime_type_from_ext(file_name)\n else\n return false\n end\n\n self.add_file_datastream(file_object, label: file_name, mimeType: mime_type, dsid: 'content')\n set_file_timestamps(file_object)\n self.checksum = generate_checksum(file_object)\n self.original_filename = file_name\n self.mime_type = mime_type\n self.size = file.size\n self.file_uuid = UUID.new.generate\n unless skip_fits\n self.add_fits_metadata_datastream(file)\n end\n true\n end", "def addfile(contents, path, client = nil, clientip = nil)\n contents = Base64.decode64(contents) if client\n bucket = Puppet::FileBucket::File.new(contents)\n Puppet::FileBucket::File.indirection.save(bucket)\n end", "def add_file_to_distributed_cache(file)\n add_to_distributed_cache(file, \"mapred.cache.files\")\n end", "def addFile path, username, groupname, rights = 0640\n userRights = getUserRights rights\n groupRights = getGroupRights rights\n othersRights = getOthersRights rights\n file = Modeles::File.new(:path => username + '/' +\n groupname + '/' +\n path,\n :userRights => userRights,\n :groupRights => groupRights,\n :othersRights => othersRights)\n user = Modeles::User.find_by_name username\n return nil if user.nil?\n group = Modeles::Group.find_by_name groupname\n return nil if group.nil?\n file.user = user\n file.group = group\n ret = file.save\n if ret\n FileInfos.new file\n end\n end", "def append(filename)\n return @filemgr.append(filename, @contents)\n end", "def create_node(file)\n attributes = {\n id: SecureRandom.uuid\n }.merge(\n file.try(:node_attributes) || {}\n )\n node = FileMetadata.for(file: file).new(attributes)\n original_filename = file.original_filename\n file = storage_adapter.upload(file: file, resource: node, original_filename: original_filename)\n node.file_identifiers = node.file_identifiers + [file.id]\n node\n rescue StandardError => error\n Valkyrie.logger.error \"#{self.class}: Failed to append the new file #{original_filename} for #{node.id}: #{error}\"\n nil\n end", "def add_file(path, *args)\n puts \"#{@indent}#{basename(path)}#{id(path)}\"\n end", "def add_to_file entry, content\n path = repo_path.join entry\n File.write path, content, :mode => \"a\"\n end", "def add_from_file(filepath, *args)\n unless File.readable?(filepath)\n raise Veil::FileNotReadable.new(\"Cannot read #{filepath}\")\n end\n add(*args, value: File.read(filepath),\n frozen: true)\n end", "def add_content(io_or_filename)\n if io_or_filename.class == String\n File.open(io_or_filename, mode='r') do |f|\n add_content_io f\n end\n else\n add_content_io io_or_filename\n end\n self\n end", "def build_file\n IoDecorator.new(file_stream, original_filename, file_content_type.to_s, use)\n end", "def add_file(attrs)\n return if search(\"//ovf:References/ovf:File[@ovf:href='#{attrs[:href]}']\").count == 1\n file = Nokogiri::XML::Node.new 'File', self\n file['ovf:href'] = attrs[:href] if attrs[:href]\n if attrs[:id]\n file['ovf:id'] = attrs[:id]\n else\n n = filecount + 1\n file['ovf:id'] = \"file#{n}\"\n end\n at('//ovf:References').add_child file\n end", "def add_attachment(summary, file, **kwargs)\n @client.add_attachment(summary, file, id, **kwargs).first\n end", "def file=(file)\n self.name = filename(file)\n self.attachment = Attachment.find_or_initialize_by(file: file)\n end", "def add_file(tar_writer, file, root_path)\n stat = File.stat(file)\n name = Pathname.new(file).relative_path_from(root_path).to_s\n tar_writer.add_file_simple(name, stat.mode, stat.size) do |io|\n File.open(file, 'rb') { |f| IO.copy_stream(f, io) }\n end\n rescue Errno::ENOENT\n nil\n end", "def add_file_with_data(file_path, data)\n # 600 is the default permission the file will have. Readable/writable by owner only.\n @tar.add_file_simple(file_path, 0o600, data.bytesize) do |io|\n io.write(data)\n end\n @total_size_processed += data.bytesize\n end", "def file_add(file)\n\t\tputs \"Add entries to the local host repository from file: #{file}\"\n\t\traise \"File non-exist. Please check your file path and name again: #{file}\" unless File.exist?(file)\n\t\thosts=file_2_list(file)\n\t\tchanges=bulk_add(hosts)\n\t\treturn changes\n\trescue => ee\n\t\tputs \"Exception on method #{__method__}: #{ee}\"\n\tend", "def add_file(file, role_name, parent_role)\n content = release.fetch_role(parent_role, root)\n parent = Gem::TUF::Role.from_hash(content)\n\n targets = Gem::TUF::Role::Targets.new(release.fetch_role(role_name, parent))\n targets.add_file(file)\n\n bucket.create(file.path, file.body)\n targets_signed = parent.sign_role(role_name, targets.to_hash, online_key)\n\n add_signed_delegated_role(role_name, parent_role, targets_signed)\n end", "def append_file(fn, str)\n File.open(fn, 'a') do |f|\n f.puts str\n end\n end", "def <<(asset)\n\t\t\tadd(asset)\n\t\tend", "def store= store\n super\n\n @file = @store.add_file @file.full_name if @file\n end", "def store= store\n super\n\n @file = @store.add_file @file.full_name if @file\n end", "def store= store\n super\n\n @file = @store.add_file @file.full_name if @file\n end", "def store= store\n super\n\n @file = @store.add_file @file.full_name if @file\n end", "def add_rpm_ghost_file(file)\n @ghost_files.add file\n end", "def add(key_file); end", "def create_node(file)\n attributes = {\n id: SecureRandom.uuid\n }.merge(\n file.try(:node_attributes) || {}\n )\n node = FileMetadata.for(file: file).new(attributes)\n original_filename = file.original_filename\n upload_options = file.try(:upload_options) || {}\n stored_file = storage_adapter.upload(file: file, resource: node, original_filename: original_filename, **upload_options)\n file.try(:close)\n node.file_identifiers = node.file_identifiers + [stored_file.id]\n node\n rescue StandardError => error\n message = \"#{self.class}: Failed to append the new file #{original_filename} for #{node.id} to resource #{parent.id}: #{error}\"\n # For FileSet parents we're likely attaching a derivative, so let the\n # error raise so sidekiq restarts.\n raise FileUploadFailed, message if file_set?(parent)\n # Prevent raising the error for resource file attachments - otherwise if\n # this keeps retrying (e.g this gets called 6 times by file_nodes and fails on the 5th) we'll end up with a bunch of orphan files on disk\n # - they've been uploaded to the storage adapter but not associated to a\n # FileSet.\n Valkyrie.logger.error message\n Honeybadger.notify message\n nil\n end", "def write\n File.open(@file, 'a') do |w| \n w.write(\"\\n\"+ @name + \" \" + @path)\n end\n end", "def file(path)\n new_file = SourceFile.new(path)\n add_file(new_file)\n new_file\n end" ]
[ "0.76329976", "0.7561803", "0.7550584", "0.7486133", "0.7466988", "0.69956297", "0.68230516", "0.6543025", "0.651876", "0.64229244", "0.64128184", "0.6314754", "0.6299916", "0.6263896", "0.62555766", "0.6254994", "0.6210089", "0.62063205", "0.61620283", "0.61512566", "0.61213386", "0.61030537", "0.60995007", "0.60995007", "0.5998436", "0.5992918", "0.597235", "0.5947994", "0.58842325", "0.5879915", "0.58745", "0.58678186", "0.58330786", "0.5830139", "0.5825481", "0.58135796", "0.57906467", "0.575849", "0.5749409", "0.57472765", "0.5727261", "0.5727261", "0.56964797", "0.56943893", "0.5693091", "0.5689188", "0.5679884", "0.56606746", "0.56585586", "0.56560904", "0.5645257", "0.56439716", "0.5635883", "0.5630049", "0.5629415", "0.56030756", "0.5591565", "0.5585032", "0.557497", "0.5560271", "0.55458266", "0.5545031", "0.55415326", "0.5525828", "0.55244505", "0.5523975", "0.55191237", "0.5518554", "0.5517955", "0.5486951", "0.54765344", "0.5472258", "0.5458629", "0.5455143", "0.54491097", "0.5448758", "0.544385", "0.5382494", "0.5372931", "0.53633016", "0.5357024", "0.5344644", "0.53416044", "0.533416", "0.5332594", "0.5331381", "0.53307164", "0.5324272", "0.5292435", "0.52913946", "0.52829295", "0.5269544", "0.5269544", "0.5269544", "0.5269544", "0.52677745", "0.5244804", "0.5242171", "0.52337146", "0.5226833" ]
0.70765704
5
Add a file created by opening +filename+ to this group after stepping +n+ lines backwards from the end of it.
def add_filename(filename, n = 0) file = Logfile.open(filename.to_str, :backward => n) file.backward n setup_file_tailer file self end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add(filename)\n raise StandardError, \"That filename is invalid, its too long\" if filename.length > 255\n # Get the next record number\n p n = getNextRecordNumber\n \n filename = File.expand_path(filename)\n filename.gsub!(/^([a-z])/){$1.upcase}\n \n utf8 = filename\n # Are there any UTF8 characters to deal with?\n if not filename =~ /^[\\x21-\\x7E]+$/i\n # Use File::SEPARATOR\n filename = filename[0,3]+(filename[3..-1].split(\"\\\\\").collect { |chunk| ((chunk =~ /^[\\x21-\\x7E]+$/i) ? chunk : chunk.gsub(/([^a-z0-9_])/i,\"\")[0..5].upcase+\"~1\"+File.extname(chunk))}.join(\"\\\\\"))\n end\n \n test = open(\"temp.txt\",\"w\")\n # Go to the end of the file, where the next record needs to be written\n @fh.sysseek(0, IO::SEEK_END)\n @fh.write filename.ljust(280,\"\\000\")\n @fh.write [n].pack(\"V\")\n @fh.write [filename.match(/^([A-Z]):/i)[1].upcase[0] - 65].pack(\"V\")\n @fh.write [((Time.now.to_f+11644473600)*(10**7)).to_i].pack(\"Q\")\n @fh.write [(open(utf8).read.length / Sys::Filesystem.stat(filename[0,3]).block_size).ceil].pack(\"V\")\n @fh.write Iconv.new(\"UTF-16LE\",\"UTF-8\").iconv(utf8).ljust(520,\"\\000\")\n @fh.write \"\\x0D\\x0A\"\n \"D#{filename[0..0].downcase}#{n+1}\"+File.extname(utf8)\n end", "def forward(n = 0)\n seek(0, File::SEEK_SET)\n while n > 0 and not eof?\n readline\n n -= 1\n end\n self\n end", "def append(filename)\n return @filemgr.append(filename, @contents)\n end", "def add_file(file)\n @files_so_far += 1\n @display.print_file @files_so_far, file\n end", "def add_file(file)\n setup_file_tailer file\n self\n end", "def add_line_to_file(filename, new_value, line_number = nil)\n File.open(filename, 'r+') do |file|\n lines = file.each_line.to_a\n if line_number\n lines[line_number] = new_value + \"\\n\"\n else\n lines.push(new_value + \"\\n\")\n end\n file.rewind\n file.write(lines.join)\n file.close\n end\n end", "def forward(n = 0)\n preset_attributes unless defined? @lines\n rewind\n while n > 0 and not eof?\n readline(@line_separator)\n n -= 1\n end\n self\n end", "def tail(filename)\n if filename\n if block_given?\n File.open(filename) do |file|\n file.seek(0, IO::SEEK_END)\n\n yield file\n end\n\n else\n file = File.open(filename)\n file.seek(0, IO::SEEK_END)\n file\n end\n\n elsif block_given?\n yield\n end\n end", "def insert_after_line(file, insert, regex = /^## Next/)\n tempfile = File.open(\"#{file}.tmp\", \"w\")\n f = File.new(file)\n f.each do |line|\n tempfile << line\n next unless line =~ regex\n\n tempfile << \"\\n\"\n tempfile << insert\n tempfile << \"\\n\"\n end\n f.close\n tempfile.close\n\n FileUtils.mv(\"#{file}.tmp\", file)\nend", "def splitByFile\n outfile = nil\n stream = open(@filename)\n until (stream.eof?)\n line = stream.readline\n\n # we need to create a new file\n if (line =~ /--- .*/) == 0\n if (outfile) \n outfile.close_write\n end\n #find filename\n tokens = line.split(\" \")\n tokens = tokens[1].split(\":\")\n tokens = tokens[0].split(\"/\")\n filename = tokens[-1]\n filename << \".patch\"\n if File.exists?(filename)\n puts \"File #{filename} already exists. Renaming patch.\"\n appendix = 0\n while File.exists?(\"#{filename}.#{appendix}\")\n appendix += 1\n end\n filename << \".#{appendix}\"\n end\n outfile = open(filename, \"w\")\n outfile.write(line)\n else\n if outfile\n outfile.write(line)\n end\n end\n end\n end", "def add_lines_to_file file_name\n\n\t# Change the mode of the file in order to add a new line to the existing file\n\tfile = File.open(file_name, 'a')\n\n\t# Ask the user the amount of lines to be added\n\tputs \"How many lines would you like to add now?\"\n\tnumber_of_lines = gets.chomp\n\n\t# According to the amount of lines, ask for each line\n\tnumber_of_lines.to_i.times do |lines|\n\t\tprint \"#{lines + 1}: \"\n\t\tfile.write(gets)\n\tend\n\n\t# Close the file\n\tfile.close\nend", "def insert n, *args\n new_frames = self.slice(0, n)\n args.each do |f|\n new_frames.push f\n end\n new_frames.concat self.slice(n..-1)\n\n self.clear\n self.concat new_frames\n self\n end", "def add_file!(paginated_file)\n container = @website_file.parent\n container.append_child(paginated_file)\n stash_paginated_file(paginated_file)\n end", "def new_chunk(index)\n chunk_num = (index / CHUNK_LINE_SIZE).to_i\n write_file = File.new(\"data/chunk#{chunk_num}\", \"w\")\n\n return write_file\nend", "def back_to(line_number)\n while @lines.size > line_number\n @lines.pop\n end\n refresh\n end", "def append_line_to_file(filename, line)\n FileUtils.touch(filename)\n File.open(filename, 'a') do |f|\n f.puts line\n end\nend", "def append(filename, text)\n File.open(filename,\"a\") {|f| f << text + \"\\n\"}\n end", "def append(filename, text)\n File.open(filename,\"a\") {|f| f << text + \"\\n\"}\n end", "def pipe_in_file(file_name)\n file_name = expand_path(file_name)\n\n File.open(file_name, \"r\").each_line do |line|\n last_command_started.write(line)\n end\n end", "def pipe_in_file(file_name)\n file_name = expand_path(file_name)\n\n File.open(file_name, 'r').each_line do |line|\n last_command_started.write(line)\n end\n end", "def nextf\n $index += 1\n if($index >= $files.length)\n $index = $files.length - 1\n end\n paint\nend", "def nextf\n $index += 1\n if($index >= $files.length)\n $index = $files.length - 1\n end\n paint\nend", "def append_to_file(file, eol: $/)\n file.to_pathname.append_lines(self, eol: eol)\n self\n end", "def move_to_next_line()\r\n while @seek_ptr < @len && @fileBuf.at(@seek_ptr) != \"\\n\"\r\n @seek_ptr = @seek_ptr + 1\r\n end\r\n end", "def line_chunk(file_name, prefix, chunksize = 1_073_741_824)\n outfilenum = 1\n File.open(file_name,\"r\") do |f|\n until f.eof?\n File.open(\"#{out_pref}_#{outfilenum}.txt\",\"w\") do |outfile|\n line = \"\"\n while outfile.size <= (chunksize-line.length) && !f.eof?\n line = f.readline\n outfile << line\n end\n end\n outfilenum += 1\n end\n end\nend", "def get_next_line(file, index)\n index.value += 1\n return get_current_line(file, index)\nend", "def next_lines(lines, number)\n lines.slice!(0, number)\n end", "def insert_text_at_line_number(source, target_file, line_number)\n if line_number > 0\n line_number -= 1\n file = IO.readlines(target_file)\n file.insert((line_number), check_source_type(source))\n File.open(target_file, \"w\") do |x|\n x.puts file\n end\n else\n raise ArgumentError, \"Line number must be 1 or higher.\".red\n end\n end", "def backward(n = 0, bufsize = nil)\n preset_attributes unless defined? @lines\n if n <= 0\n seek(0, File::SEEK_END)\n return self\n end\n bufsize ||= default_bufsize || stat.blksize || 8192\n size = stat.size\n begin\n if bufsize < size\n seek(0, File::SEEK_END)\n while n > 0 and tell > 0 do\n seek(-bufsize, File::SEEK_CUR)\n buffer = read(bufsize)\n n -= buffer.count(@line_separator)\n seek(-bufsize, File::SEEK_CUR)\n end\n else\n rewind\n buffer = read(size)\n n -= buffer.count(@line_separator)\n rewind\n end\n rescue Errno::EINVAL\n size = tell\n retry\n end\n pos = -1\n while n < 0 # forward if we are too far back\n pos = buffer.index(@line_separator, pos + 1)\n n += 1\n end\n seek(pos + 1, File::SEEK_CUR)\n self\n end", "def chunk(file_name, prefix, chunksize = 1_073_741_824)\n File.open(file_name\"r\") do |f|\n until f.eof?\n File.open(\"#{prefix}_#{\"%05d\"%(f.pos/chunksize)}.txt\",\"w\") do |fc|\n fc << f.read(chunksize)\n end\n end\n end\nend", "def run\n begin\n yield @first_line if block_given?\n while (size = File::Stat.new(@filename).size) >= @next_start\n size = @file.stat.size\n reset_buffer_size\n begin\n line = \"\"\n @file.seek(@next_start, File::SEEK_SET)\n @file.read(@buf_size, @buffer)\n buffer_start = @next_start\n found_new_line = false\n 0.upto(@buffer.size - 1) do |index|\n line << @buffer[index]\n if @buffer[index].chr == \"\\n\"\n yield(line) if block_given?\n line = \"\"\n found_new_line = true\n @next_start = buffer_start + index + 1\n end\n end\n unless found_new_line || @buffer.empty?\n raise BufferError\n end\n rescue BufferError\n increment_buffer_size\n retry\n end\n\t sleep 0.01\n end\n rescue Errno::ENOENT\n # Wait until the file is recreated\n while !File.exists?(@filename)\n sleep 0.05\n end\n end\n end", "def reset(filename)\n @history = []\n @history_idx = -1\n\n unless filename.nil? or !File.exists? filename\n @history = File.readlines(filename).map { |l| l.rstrip }.reverse\n end\n\n @backend = File.open filename, \"a+\" unless filename.nil?\n end", "def file_end(file, output)\n end", "def add( file, number )\n\t\t@files[ number ] = file\n\tend", "def _increment_file_line()\n\t\t@reading_line += 1\n\tend", "def backward(n = 0, bufsiz = nil)\n if n <= 0\n seek(0, File::SEEK_END)\n return self\n end\n bufsiz ||= stat.blksize || 8192\n size = stat.size\n begin\n if bufsiz < size\n seek(0, File::SEEK_END)\n while n > 0 and tell > 0 do\n start = tell\n seek(-bufsiz, File::SEEK_CUR)\n buffer = read(bufsiz)\n n -= buffer.count(\"\\n\")\n seek(-bufsiz, File::SEEK_CUR)\n end\n else\n seek(0, File::SEEK_SET)\n buffer = read(size)\n n -= buffer.count(\"\\n\")\n seek(0, File::SEEK_SET)\n end\n rescue Errno::EINVAL\n size = tell\n retry\n end\n pos = -1\n while n < 0 # forward if we are too far back\n pos = buffer.index(\"\\n\", pos + 1)\n n += 1\n end\n seek(pos + 1, File::SEEK_CUR)\n self\n end", "def add_file(filename)\n dir = File.dirname(filename).gsub(\"#{@dest}\",\".\")\n fn = File.basename(filename)\n folder = @folders[dir] || @folders[dir]=[]\n folder << fn\n end", "def add_file(filename)\n dir = File.dirname(filename).gsub(\"#{@dest}\",\".\")\n fn = File.basename(filename)\n folder = @folders[dir] || @folders[dir]=[]\n folder << fn\n end", "def n_lines(filename); end", "def next_file\n @current_file_index += 1\n\n if @current_file_index >= @files.length\n @current_file = @files.first\n @current_file_index = 0\n else\n @current_file = @files[@current_file_index]\n end\n\n @data = load_file(@current_file)\n end", "def add_file(file)\n @files[file.name] = file\n file.parent = self\n end", "def add(filename)\n not_implemented('add')\n end", "def unix_tail_command_brute(filename, lines)\n lines_total, output = 0, \"\"\n\n file = File.open(filename,'r')\n file.each_line do |l|\n lines_total += 1\n end\n file.close\n\n start_line = lines_total - lines\n\n line_number = 0\n file = File.open(filename,'r')\n file.each_line do |l|\n\n if line_number >= start_line\n output << \"#{l}\"\n end\n line_number += 1\n end\n file.close\n\n output\nend", "def incremented_file_num(file)\n ext = File.extname(file)\n name_no_ext = File.basename(file, \".*\")\n number = get_dup_number(name_no_ext)\n file_no_paren = name_no_ext.split(/[(]\\d+[)]\\z/)[0]\n\n new_file_path = incremented_path(file_no_paren, number, ext)\n\n while File.exist?(new_file_path)\n number += 1\n new_file_path = incremented_path(file_no_paren, number, ext)\n end\n\n file_no_paren + \"(\" + number.to_s + \")\"\nend", "def next_file_number\r\n most_recent_file_number + 1\r\n end", "def go\n\nlines = 3 # cut it at line 3\n\nbasename = 'file_to_split.txt'\nextname = \"part\"\n\npart = 1\nline = 0\n\nfline = 0\nfor i in ifp = open(basename)\n fline = fline + 1\nend\nifp.close\n\nparts = fline / lines + 1\n\nfor i in ifp = open(basename)\n if line == 0\n ofp = open(sprintf(\"%s.%s%02d\", basename, extname, part), \"w\")\n printf(ofp, \"%s part%02d/%02d\\n\", basename, part, parts)\n ofp.write(\"BEGIN--cut here--cut here\\n\")\n end\n ofp.write(i)\n line = line + 1\n if line >= lines and !ifp.eof?\n ofp.write(\"END--cut here--cut here\\n\")\n ofp.close\n part = part + 1\n line = 0\n end\nend\nofp.write(\"END--cut here--cut here\\n\")\nofp.close\n\nifp.close\n\nend", "def merge_last(i)\n return unless i > 1\n range = -i..-1\n @line[range] = @line[range].join\n @line_no -= (i-1)\n @history -= (i-1)\n end", "def add_after(filename, matching_text, data=nil, &block)\n gsub_file filename, /(\\s*#{Regexp.escape(matching_text)})/mi do |match|\n \"#{match}\\n#{data || block.call}\"\n end\n end", "def append_to_end_of_file(source, target_file, remove_last_line=false)\n t_file = IO.readlines(target_file)\n t_file.pop if remove_last_line == true\n new_file = []\n new_file << t_file << check_source_type(source)\n File.open(target_file, \"w\") do |x|\n x.puts new_file\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 output(file_name, mode=\"a\")\n Thread.new do\n IO.raw_file(file_name, mode) do |writer|\n until self.closed && self.empty?\n sleep 0.01 if self.empty? # pass execution if empty\n self.pop{ |mem| writer[mem, @bytes] } until self.empty?\n end\n end\n end\n end", "def file_prepend(file, str)\n # For adding the last photo processed to beginning of file.\n # https://stackoverflow.com/questions/8623231/prepend-a-single-line-to-file-with-ruby Copied\n new_contents = \"\"\n str = str + \"\\n\" # not in original, but needed to put this return in somewhere\n File.open(file, 'r') do |fd|\n contents = fd.read\n new_contents = str << contents\n end\n # Overwrite file but now with prepended string on it\n File.open(file, 'w') do |fd| \n fd.write(new_contents)\n end\nend", "def append_to_block_in_file(filename, new_line, start_string, end_string)\n original_block =\n File.read(filename)[/#{start_string}(.*?)\\n(\\s*)#{end_string}$/m]\n return false if original_block.nil? || original_block.empty?\n\n modified_block = append_line_before_tag(original_block, new_line, end_string)\n gsub_file filename, original_block, modified_block\n return true\nend", "def rewind_to(n)\n @data.rewind\n while @data.lineno != n\n @data.readline\n end\n end", "def skip(n = 1)\n @pointer += n\n self\n end", "def >> file_name, i = index\n if ((File.writable? file_name or not File.exists? file_name) and not\n File.directory? (file = File.new(file_name, 'w')))\n buff = @form[i].update_text\n i = 1\n size = buff.length\n buff.each do |line|\n line = line.chop\n line += \"\\n\" unless i == size\n i += 1\n file.write line\n end\n end\n file.close if file\n end", "def append_file(filename,data)\n begin\n File.open(filename, \"a+\") do |f|\n f<< data\n end\n rescue Exception => e\n puts e.message \n end\n end", "def incremented_path(file, number, ext)\n incremented_file = file + \"(\" + number.to_s + \")\"\n File.join(data_path, File.basename(incremented_file + ext))\nend", "def append_xy_file(filename, x, y)\n File.open(filename, 'a') do |xy_file|\n xy_file.puts \"#{x} #{y}\" \n end\n true\n end", "def update_file\n output = (@blocks[:before] + @blocks[:attributes] + @blocks[:after]).join(\"\\n\").strip + \"\\n\"\n File.open(@filename,'w') { |f| f.write(output) } if output != @file\n end", "def append_idea idea\n open(\"#{FileName}.txt\", 'a') do |file|\n file.puts idea\n end\n\n File.read(\"#{FileName}.txt\")\nend", "def insert_after\r\n @lines.insert(@line_num, TextLineBuffer.new(\"\"))\r\n @line_num = @line_num + 1\r\n end", "def write_tail(f, pos)\n f.seek(0)\n f.write([pos].pack('N'))\n pos\n end", "def test_file_must_contain_append()\n\t\tCfruby::FileEdit.file_must_contain(@multilinefilename, \"new line\", :position => Cfruby::FileEdit::APPEND)\n\t\tFile.open(@multilinefilename, File::RDONLY) { |fp|\n\t\t\tlines = fp.readlines()\n\t\t\tassert_equal(\"new line\\n\", lines[-1])\n\t\t}\n\tend", "def file(filename, indent)\n line_num = 0\n File.readlines(filename).each do |line|\n line_num += 1\n line.prepend(' ' * indent) unless line.empty? || line_num == 1\n end.join.chomp\n end", "def back_up(n = 1)\n raise ArgumentError if @index < n\n @index -= n\n end", "def advance n\n @index += n\n self\n end", "def advance(count_lsn_no, group)\n new_lsn_no = @lsn_no + count_lsn_no\n reposition(new_lsn_no, group)\n end", "def add_file(file, line = T.unsafe(nil), has_comments = T.unsafe(nil)); end", "def append_xy_file(filename, x, y)\n File.open(filename, 'a') do |xy_file|\n xy_file.puts \"#{x} #{y}\"\n end\n true\n end", "def send_next_frame sequence_number\n # pull from file into buffer\n frames_delivered = @delivered / @options[:frame_size]\n \n # Get number of bytes delivered (floors @delivery)\n bytes_sent = frames_delivered * @options[:frame_size]\n\n # Assume previous frames were sent\n bytes_sent += (sequence_number - ((@window % 2) * @options[:window_size])) * @options[:frame_size]\n\n if bytes_sent >= @filesize\n return\n end\n\n to_read = [@options[:frame_size], @filesize - bytes_sent].min\n @buffer[sequence_number] = @file.read(to_read)\n end", "def fback (fname)\n fcont = File.read(fname)\n File.new(fcont)\n end", "def append_to_file(path, *args, &block)\n options = args.last.is_a?(Hash) ? args.pop : {}\n options.merge!(before: /\\z/)\n insert_into_file(path, *(args << options), &block)\n end", "def get_line(filename, lineno)\n File.open(filename) do |f|\n f.gets until f.lineno == lineno - 1\n f.gets\n end\n end", "def append_file(fn, str)\n File.open(fn, 'a') do |f|\n f.puts str\n end\n end", "def add_to_git_ignore(filename)\n File.open(File.join(dotfiles_path, '.gitignore'), \"a+\") do |file|\n contents = file.read\n unless contents =~ %r{^#{filename}$}\n info(\"Adding #{filename} to #{File.join(dotfiles_path, '.gitignore')}\")\n file.write(filename + \"\\n\")\n end\n end\n end", "def backward_lines(size = 10)\n\n file = @file\n reg = Regexp.new('\\r\\n|\\r|\\n')\n result = \"\"\n\n while file.pos > 0\n\n char = backward_char\n\n if char.nil?\n file.rewind\n break\n end\n\n # backward pos as bytesize of char\n file.seek(-(char.bytesize), IO::SEEK_CUR)\n\n break if char.match(reg) && result.scan(reg).size > size\n\n result.insert(0, char)\n end\n\n result\n end", "def put_to_new_next_line(txt)\n l = current_line_range()\n insert_txt_at(txt, l.end + 1)\n set_pos(l.end + 1)\n end", "def repeat_last(opt)\n opt ||= {}\n opt[:section] ||= 'all'\n opt[:section] = guess_section(opt[:section])\n opt[:note] ||= []\n opt[:tag] ||= []\n opt[:tag_bool] ||= :and\n\n last = last_entry(opt)\n if last.nil?\n logger.warn('Skipped:', 'No previous entry found')\n return\n end\n\n repeat_item(last, opt)\n write(@doing_file)\n end", "def next()\n\n @filehandler.pos = @list_of_positions[@current_iteration]\n\n if @list_of_positions.length > @current_iteration\n @current_iteration += 1\n end\n\n make_entry()\n\n end", "def tail(path, n)\n file = File.open(path, \"r\")\n buffer_s = 512\n line_count = 0\n file.seek(0, IO::SEEK_END)\n\n offset = file.pos # we start at the end\n\n while line_count <= n && offset > 0\n to_read = if (offset - buffer_s) < 0\n offset\n else\n buffer_s\n end\n\n file.seek(offset-to_read)\n data = file.read(to_read)\n\n data.reverse.each_char do |c|\n if line_count > n\n offset += 1\n break\n end\n offset -= 1\n if c == \"\\n\"\n line_count += 1\n end\n end\n end\n\n file.seek(offset)\n data = file.read\nend", "def add_after_or_append(filename, matching_text, text_to_add, before_text, after_text)\n content = File.read(filename)\n if content.include?(matching_text)\n add_after(filename, matching_text, text_to_add)\n else\n append_file(filename, [before_text, text_to_add, after_text].join(\"\\n\"))\n end\n end", "def add_file(file)\n index = @repo.index\n index.add path: file, oid: (Rugged::Blob.from_workdir @repo, file), mode: 0100644\n index.write\n\n @affected_files << file\n end", "def addFile(name)\n @filesQueue.push(name)\n end", "def show fileName\n f = File.open(fileName, \"r+\")\n inLines = f.readlines\n f.close\n puts \"\\n***********************************************\"\n inLines.each_with_index {|val, index|\n puts \"#{val}\"\n if index > 10\n exit\n end\n }\n\n exit\nend", "def add_file(file)\n @zip.put_next_entry(file.path)\n @zip.write(file.read)\n end", "def add_line_to_file(file, line)\n File.open(file, \"a\") {|f| f.puts(\"#{line}\")}\n end", "def read_line_number(filename, number)\n return nil if number < 1\n line = File.readlines(filename)[number-1]\n line ? line.chomp : nil\n end", "def after(line_num, lines=1)\n return self unless line_num\n\n select do |l, ln|\n ln > line_num && ln <= line_num + lines\n end\n end", "def read_file_and_close(filename)\n counter = 1\n file = File.new(filename, \"r\") #\"readfile.rb\"\n while (line = file.gets)\n puts \"#{counter}: #{line}\"\n counter = counter + 1\n end\n file.close\n end", "def add_line_to_file file_path,line\n return \"echo #{line} >> #{file_path}\"\n end", "def file_history_push(file)\n file_history = $file_history.to_h\n file_history.each_pair do |index, file_name|\n if file_name == \"\"\n file_name = file\n $file_history[\"#{index}\"] = \"#{file_name}\"\n break\n end\n end\n end", "def ensure_trailing_newline(file_text)\n count_trailing_newlines(file_text) > 0 ? file_text : (file_text + \"\\n\")\n end", "def pass_file_to_block(filename)\n File.open(filename, \"r\") do |infile|\n while (line = infile.gets)\n puts \"#{counter}: #{line}\"\n counter = counter + 1\n end\n end\n end", "def update_recent(file_name)\n # Read in the list of recently opened files\n recent_files = []\n File.open(RECENT_LOC, 'r') do |recent|\n recent_files = recent.read.split(\"\\n\")\n end\n\n # If file is already in recent_files, move it to the beginning\n # Otherwise, just add it to the beginning\n abs_path = File.expand_path(file_name)\n recent_files.delete(abs_path) if recent_files.include?(abs_path)\n recent_files.prepend(abs_path)\n\n # Write updated list of recent files back into file\n File.open(RECENT_LOC, 'w') do |recent|\n recent.puts recent_files.join(\"\\n\")\n end\n\n puts recent_files\nend", "def test_file_append()\n\t\t# test the empty file\n\t\tCfruby::FileEdit.file_append(@emptyfilename, \"new line\")\n\t\tlines = File.open(@emptyfilename, File::RDONLY).readlines()\n\t\tassert_equal(1, lines.length)\n\t\tassert_equal(\"new line\", lines[-1])\n\t\t\n\t\t# test the multiline file\n\t\tCfruby::FileEdit.file_append(@multilinefilename, \"new line\")\n\t\tlines = File.open(@multilinefilename, File::RDONLY).readlines()\n\t\tassert_equal(@multilinefilecontents.split(\"\\n\").length+1, lines.length)\n\t\tassert_equal(\"new line\", lines[-1])\t\t\n\tend", "def new_line!(number)\n if @preprocessor.line_first\n @packet.send_packet\n @packet.add_line(number.to_i)\n else\n @packet.add_line(number.to_i)\n @packet.send_packet\n end\nend", "def file_finished(file, offenses); end", "def next_number\n counter.call(files.last_number).to_s\n end", "def prepend_file_to_file(file_name_1, data1, file_name_2)\n File.open(append_root_path(file_name_1), 'w') do |f1|\n f1.puts data1\n File.foreach(append_root_path(file_name_2)) do |f2|\n f1.puts f2\n end\n end\n end" ]
[ "0.56700957", "0.55981344", "0.5490302", "0.5464723", "0.53666383", "0.53162956", "0.52750343", "0.52734905", "0.524358", "0.5184762", "0.5158358", "0.5153315", "0.5141805", "0.50886977", "0.50778514", "0.50717044", "0.5047773", "0.5047773", "0.5037931", "0.5035951", "0.5021667", "0.5021667", "0.50113434", "0.5010444", "0.50055087", "0.49649537", "0.49603468", "0.49151352", "0.48979592", "0.4883899", "0.48795936", "0.48657298", "0.48466203", "0.4837431", "0.48192105", "0.47943762", "0.47903255", "0.47903255", "0.47890797", "0.47842124", "0.47840127", "0.47793937", "0.47660363", "0.47630516", "0.47562143", "0.47434625", "0.47348323", "0.47201434", "0.47183388", "0.46773654", "0.46772075", "0.4669631", "0.4665779", "0.4658644", "0.4633202", "0.46287555", "0.46249408", "0.46239018", "0.46204495", "0.4617698", "0.4612353", "0.45982105", "0.45951897", "0.45950174", "0.45900428", "0.45860797", "0.45830336", "0.45794803", "0.45773476", "0.4574008", "0.45634174", "0.45610234", "0.45551828", "0.45502695", "0.45428073", "0.4542089", "0.4527486", "0.45263603", "0.4520627", "0.4516879", "0.45158997", "0.45137703", "0.45130908", "0.4512079", "0.4506206", "0.4500477", "0.44920915", "0.44919068", "0.44910926", "0.4484956", "0.44759035", "0.44641533", "0.4461068", "0.44539058", "0.44468594", "0.4446134", "0.443668", "0.44321877", "0.4423802", "0.44210202" ]
0.7640431
0
Iterate over all files contained in this group yielding to +block+ for each of them.
def each_file(&block) each_tailer { |t| t.file }.map(&block) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def each(&block)\n @files.each(&block)\n end", "def each(&block)\n\t\t\t\tfiles = []\n\n\t\t\t\[email protected] do |filename|\n\t\t\t\t\tf = open_file(filename)\n\t\t\t\t\tf.each do |line|\n\t\t\t\t\t\tline.gsub!(\"\\n\",\"\")\n\n\t\t\t\t\t\t# Ignore these lines since they does not contain a\n\t\t\t\t\t\t# filename.\n\t\t\t\t\t\tnext if /^#/.match(line)\n\n\t\t\t\t\t\t# Skip empty lines as well.\n\t\t\t\t\t\tnext if /^\\s*$/.match(line)\n\n\t\t\t\t\t\tline = File.join(@prefix, line) unless @prefix.nil?\n\t\t\t\t\t\tfiles << line\n\t\t\t\t\tend\n\t\t\t\t\tclose_file(f)\n\t\t\t\tend\n\n\t\t\t\tfiles.each(&block)\n\t\t\tend", "def each\n files.each do |file|\n yield file\n end\n end", "def each_file(&block)\n @files.keys.each do |file|\n yield(file)\n end\n end", "def each_file\n files.each { |filename| yield filename }\n end", "def each(&block)\n File.open(filepath, 'rb') do |io|\n while part = io.read(block_size)\n yield part\n end\n end\n end", "def each(&block)\n files.each(&block)\n\n directories.each do |subdirectory|\n block.call(subdirectory)\n\n subdirectory.each(&block)\n end\n end", "def each\n changeset.each { |file| yield file }\n end", "def each(&block)\n if block_given?\n @fog_wrapper.each do |key|\n yield file(key)\n end\n else\n to_enum(:each)\n end\n end", "def foreach\n find_files.each do |file|\n yield(@build_result_dir, file)\n end\n end", "def each(&b)\n all_files.each( &b)\n self\n end", "def each(&b)\n all_files.each( &b)\n self\n end", "def each\n files.each do |f|\n content = File.read(path(f))\n content = compress(content) if @app.compress_bundles\n # Include a new line to prevent weirdness at file boundaries\n yield(\"#{content}\\n\")\n end\n end", "def each_file\n return to_enum(__method__) unless block_given?\n\n paths.each do |root|\n stat_tree(root).each do |filename, stat|\n if stat.file?\n yield filename\n end\n end\n end\n\n nil\n end", "def each_file\n self.files.each_pair do |path, data|\n if not data.empty?\n yield path, StateModule::File::new(path, data)\n end\n end\n end", "def each(&block)\n SemanticLogger.named_tagged(dirmon_entry: id.to_s) do\n # Case insensitive filename matching\n Pathname.glob(pattern, File::FNM_CASEFOLD).each do |pathname|\n next if pathname.directory?\n pathname = begin\n pathname.realpath\n rescue Errno::ENOENT\n logger.warn(\"Unable to expand the realpath for #{pathname.inspect}. Skipping file.\")\n next\n end\n\n file_name = pathname.to_s\n\n # Skip archive directories\n next if file_name.include?(self.class.default_archive_directory)\n\n # Security check?\n if (whitelist_paths.size > 0) && whitelist_paths.none? { |whitepath| file_name.to_s.start_with?(whitepath) }\n logger.error \"Skipping file: #{file_name} since it is not in any of the whitelisted paths: #{whitelist_paths.join(', ')}\"\n next\n end\n\n # File must be writable so it can be removed after processing\n unless pathname.writable?\n logger.error \"Skipping file: #{file_name} since it is not writable by the current user. Must be able to delete/move the file after queueing the job\"\n next\n end\n block.call(pathname)\n end\n end\n end", "def update_files(&block)\n \n get_template_entries.each do |entry|\n \n next if entry.directory?\n \n entry.get_input_stream do |is|\n \n data = is.sysread\n \n if CONTENT_FILES.include?(entry.name)\n process_entry(data, &block)\n end\n \n @output_stream.put_next_entry(entry.name)\n @output_stream.write data\n \n end\n end\n end", "def each\n file_rec = next_candidate\n until file_rec.nil?\n yield file_rec\n\n file_rec = next_candidate\n end\n end", "def each\n File.open(to_path, 'rb') do |file|\n while chunk = file.read(16384)\n yield chunk\n end\n end\n end", "def each\n Dir[ path_pattern ].each { |path| yield open(path) }\n end", "def each_file_in_tree\n self.directories_in_tree.find_each do |directory|\n next if directory.nil?\n directory.cfs_files.find_each do |cfs_file|\n next if cfs_file.nil?\n\n yield cfs_file if block_given?\n end\n end\n end", "def each\n @sources.each { |directory, path| yield directory, path }\n end", "def each(&block)\n\t\tclient.fs.sftp.dir.foreach(self.path, &block)\n\tend", "def each\n pos = 0\n while(pos < @original_duration) do\n chunk = nil\n begin\n chunk = Chunk.new(@original_file, @original_duration, pos, (@chunk_duration + @overlap), @rate)\n yield chunk\n pos = pos + [chunk.duration, @chunk_duration].min\n ensure\n chunk.close_file if chunk\n end\n end\n end", "def each(&block)\n\t\t\t\treturn to_enum unless block_given?\n\t\t\t\t\n\t\t\t\t::Dir.glob(full_pattern, ::File::FNM_DOTMATCH) do |path|\n\t\t\t\t\t# Ignore `.` and `..` entries.\n\t\t\t\t\tnext if path =~ /\\/..?$/\n\t\t\t\t\t\n\t\t\t\t\tyield Path.new(path, @root)\n\t\t\t\tend\n\t\t\tend", "def each_file\n @sftp.dir.foreach(@path.to_s) do |entry|\n filename = entry.name\n yield filename unless directory? filename\n end\n end", "def each_file(directory)\n directory_contents(directory).each do |path|\n yield path\n end\n end", "def each_io\n each_file do |filename|\n io = get filename\n yield filename, io\n end\n end", "def each_io\n each_file do |filename|\n io = get filename\n yield filename, io\n end\n end", "def foreach(&block)\n ::Dir.foreach(path, &block)\n end", "def tar_each(&block)\n # In case of extreme weirdness where this happens twice.\n close_file!\n open_file!\n @tar_reader.each(&block)\n ensure\n close_file!\n end", "def foreach(zip_file_name, &block); end", "def each_section(&block)\n @files.each do |file, list|\n list.each do |entry|\n yield(entry) if entry.is_a?(Section)\n end\n end\n end", "def each(&block)\n @tarreader.each { |entry| yield entry }\n ensure\n @tarreader.rewind\n end", "def each\n\t\t\n\t\t# Save States that this affects, and set them to defaults\n\t\tstates = [@lineno, @filelineno, @filename]\n\t\t@lineno = 0;\n\t\t\n\t\t# Read every line walking through the files\n\t\[email protected] do |filename|\n\t\t\t\n\t\t\t# Setup States Per File\n\t\t\t@filename = filename\n\t\t\t@filelineno = 0\n\t\t\tstream = STDIN\n\t\t\tstream = File.open(filename) unless filename == '-'\n\t\t\t\n\t\t\t# Read Lines\n\t\t\twhile line = stream.gets\n\t\t\t\t@lineno += 1\n\t\t\t\t@filelineno += 1\n\t\t\t\tyield line\n\t\t\tend\n\t\t\t\n\t\tend\n\t\t\n\t\t# Restore the original states\n\t\t@lineno, @filelineno, @filename = states\n\t\t\n\tend", "def files\n return enum_for(:files) unless block_given?\n\n yield @filename\n end", "def each(&block)\n group.each_value(&block)\n end", "def each_file(markup)\n @files.each do |dest,file|\n if (formatted_like?(dest,markup) || !formatted?(dest))\n yield dest, file\n end\n end\n end", "def each(&block)\n return @parts.each(&block)\n end", "def each_block(rewind = true, with_prologue = true)\n\t self.rewind if rewind\n\t while !eof?\n\t\tio = self.rio\n\t\tif @next_block_pos == 0 && with_prologue\n\t\t read_prologue\n\t\telse\n\t\t io.seek(@next_block_pos)\n\t\tend\n\n\t\t@data = nil\n\t\t@data_header.updated = false\n\n if !read_block_header\n next_io\n next\n end\n\n\t\tyield(@block_info)\n\t end\n\trescue EOFError\n\tend", "def each(options = {}, &block)\n raise \"MotionAL::Assets.each does not support :group option. Use MotionAL::Asset.find_all to get other group assets.\" if options[:group]\n\n options[:group] = @group\n\n MotionAL::Asset.find_all(options) do |asset, error|\n block.call(asset, error)\n end\n end", "def each_attachment\n attachment_urls.each { |url| yield ActiveSP::File.new(self, url, true) }\n end", "def each\r\n\t\t\[email protected] do |item|\r\n\t\t\t\tyield item\r\n\t\t\tend\r\n\t\tend", "def each *args, &block\n file.each(*args, &block)\n\n if moved?\n @moved = false\n @file_io = nil\n self.each(*args, &block)\n end\n end", "def each\n return enum_for unless block_given?\n\n while (chunk = read)\n yield chunk\n end\n end", "def each_directory(&block)\n @directories.each(&block)\n end", "def each_file_with_index\n index = 0\n\n each_file do |file|\n yield file, index\n index += 1\n end\n end", "def each_file\n return unless block_given?\n\n loc_path = LokaliseRails.locales_path\n Dir[\"#{loc_path}/**/*\"].sort.each do |f|\n full_path = Pathname.new f\n\n next unless file_matches_criteria? full_path\n\n relative_path = full_path.relative_path_from Pathname.new(loc_path)\n\n yield full_path, relative_path\n end\n end", "def process\n outs = []\n @infiles.each do |f|\n if f.instance_of? Hash\n dat = f[:block].(f[:file])\n if dat.instance_of? String\n out << dat + \"\\n\\n\"\n else\n fail TypeError, \"#{dat.class} returned, String expected\"\n end\n elsif f.instance_of? String\n outs << File.read(f)\n elsif f.instance_of? Array\n outs << f.map { |fn| File.read(fn) }\n else\n fail TypeError, \"Infile #{f.inspect} is not a hash nor a string nor an array!\"\n end\n end\n out = outs.join(\"\\n\\n\")\n if @block\n out = @block.(out)\n end\n if @outfile\n File.delete(@outfile) if File.exist? @outfile\n File.open(@outfile, 'w') do |f|\n f.write(out)\n end\n end\n out\n end", "def each\n\t\t\t\t\twhile chunk = self.read\n\t\t\t\t\t\tyield chunk\n\t\t\t\t\tend\n\t\t\t\tensure\n\t\t\t\t\tself.close($!)\n\t\t\t\tend", "def each(&block)\n @buffer.each(&block)\n end", "def foreach(zip_file_name, &block)\n ::Zip::File.open(zip_file_name) do |zip_file|\n zip_file.each(&block)\n end\n end", "def each_object (&block)\n\n each_object_path do |path|\n block.call(load_object(path))\n end\n end", "def each &block\n @parts.each(&block)\n end", "def each &block\n if block_given?\n Tempfile.open('temp', binmode: true) do |newmovi|\n @avi.process_movi do |indices, movi|\n newindices = indices.select do |m|\n movi.pos = m[:offset] + 8 # 8 for id and size\n frame = Frame.new(movi.read(m[:size]), m[:id], m[:flag])\n block.call frame\n unless frame.data.nil?\n m[:offset] = newmovi.pos\n m[:size] = frame.data.size\n m[:flag] = frame.flag\n m[:id] = frame.id\n newmovi.print m[:id]\n newmovi.print [frame.data.size].pack('V')\n newmovi.print frame.data\n newmovi.print \"\\0\" if frame.data.size % 2 == 1\n true\n else\n false\n end\n end\n [newindices, newmovi]\n end\n end\n else\n self.enum_for :each\n end\n end", "def each(&block)\n @grouped_collection.each { |gc| block.call(gc) }\n end", "def process_blocks(blocks); end", "def each(&block)\n fake_stream = Zipline::FakeStream.new(&block)\n Zipline::OutputStream.open(fake_stream) do |zip|\n @package.parts.each do |name, part|\n begin\n if part.respond_to?(:stream) && part.respond_to?(:size)\n zip.put_next_entry name, part.size\n part.stream zip\n else\n data = @package.marshal_part(name)\n zip.put_next_entry name, data.size\n zip << data\n end\n rescue => e\n raise e unless @ignore_part_exceptions\n end\n end\n end\n end", "def each_chunk( &block )\n\t\t\tself.validate\n\n\t\t\titer = Enumerator.new do |yielder|\n\t\t\t\tself.bytes.each_slice( self.chunksize ) do |bytes|\n\t\t\t\t\tyielder.yield( bytes.pack('C*') )\n\t\t\t\tend\n\t\t\tend\n\n\t\t\treturn iter unless block\n\t\t\treturn iter.each( &block )\n\t\tend", "def each(&block)\n end", "def each_entry(&block) # :yield: p\n Dir.foreach(path) {|f| yield Path::Name.new(f) }\n end", "def match(glob, &block)\n yield @filename\n end", "def each_data_file(path)\n return enum_for(:each_data_file,path) unless block_given?\n\n each_data_path(path) do |full_path|\n yield(full_path) if File.file?(full_path)\n end\n end", "def each(partition=nil, &block)\n if partition.nil?\n index.each do |id, info|\n yield find(id)\n end\n else\n S3Object.stream(File.join(basedir, p), bucket_name) do |f|\n until f.eof?\n yield Marshal.load(f)\n end\n end\n end\n end", "def each(&block)\n File.open(@filename).each do |line|\n yield(line.chomp)\n end\n end", "def each(&block)\n yield self\n children.each {|c| c.each(&block)}\n end", "def each(&block)\n @all.each_batch { |batch| batch.each { |s| yield s } }\n end", "def each(&block)\n packages.each_value(&block)\n end", "def each(&block)\n if block_given?\n Parallel.each(each_path, in_threads: threads) do |path|\n load_script_from_path path, &block\n end\n else\n self.enum_for :each\n end\n end", "def each_file(&bl)\n unpack do |dir|\n Pathname(dir).find do |path|\n next if path.to_s == dir.to_s\n pathstr = path.to_s.gsub(\"#{dir}/\", '')\n bl.call pathstr unless pathstr.blank?\n end\n end\n end", "def each_item(&block)\n root_group = get(@root['mainGroup'].to_s, Xcode::PBXGroup)\n root_group.each_item(&block)\n end", "def get_each\n\t\t@in_files.each do |in_file|\n\t\t\tlines = []\n\t\t\tFile.foreach(in_file) {|line| lines << line.chomp}\n\t\t\talbum_items = yield lines\n\t\t\tif !album_items.empty?\n\t\t\t\t@out_items += album_items\n\t\t\t\t@log_lines << to_log(album_items) \n\t\t\tend\n\t\tend\n\tend", "def iterate_over files\n files.each do |file|\n yield file\n SignalHandler.check { \n @db.close\n Logger.<<(__FILE__,\"WARNING\",\"Signal SIGINT received: stopping decoding files ...\")\n }\n end\n end", "def each\n loop do\n yield read\n end\n end", "def each(&block)\n\n all.each { |wi| block.call(wi) }\n end", "def each_file(&bl)\n unpack do |dir|\n Pathname.new(dir).find do |path|\n next if path.to_s == dir.to_s\n pathstr = path.to_s.gsub(\"#{dir}/\", '')\n bl.call pathstr unless pathstr.blank?\n end\n end\n end", "def files(rootDir)\n Dir.foreach(rootDir) do |dir|\n if dir != \".\" && dir != \"..\"\n puts \"Processing \" + dir\n Dir.foreach(rootDir + \"/\" + dir) do |file|\n if file != \".\" && file != \"..\"\n open(rootDir + \"/\" + dir + \"/\" + file) do |f|\n yield(f)\n end\n end\n end\n end\n end\nend", "def each\n while (part = readpartial)\n yield part\n end\n end", "def block\n (@blocks ||= Array.new) << Block.new\n @in_block = @blocks.last\n yield\n @in_block = nil\n end", "def find_files(block)\n files = []\n block.scan(URL_PATTERN).each do |attribute, path|\n if !URI.parse(path).absolute?\n resource = create_resource_file(attribute, path)\n files << resource if resource\n end\n end\n files\n end", "def each(&block)\n synchronized do\n return if @files.empty?\n\n file_deleteable = []\n # creates this array just once\n watched_files = @files.values\n\n # look at the closed to see if its changed\n watched_files.select {|wf| wf.closed? }.each do |watched_file|\n path = watched_file.path\n begin\n stat = watched_file.restat\n if watched_file.size_changed? || watched_file.inode_changed?(inode(path,stat))\n # if the closed file changed, move it to the watched state\n # not to active state because we want to use MAX_OPEN_FILES throttling.\n watched_file.watch\n end\n rescue Errno::ENOENT\n # file has gone away or we can't read it anymore.\n file_deleteable << path\n @logger.debug? && @logger.debug(\"each: closed: stat failed: #{path}: (#{$!}), deleting from @files\")\n rescue => e\n @logger.debug? && @logger.debug(\"each: closed: stat failed: #{path}: (#{e.inspect})\")\n end\n end\n\n # look at the ignored to see if its changed\n watched_files.select {|wf| wf.ignored? }.each do |watched_file|\n path = watched_file.path\n begin\n stat = watched_file.restat\n if watched_file.size_changed? || watched_file.inode_changed?(inode(path,stat))\n # if the ignored file changed, move it to the watched state\n # not to active state because we want to use MAX_OPEN_FILES throttling.\n # this file has not been yielded to the block yet\n # but we must have the tail to start from the end, so when the file\n # was first ignored we updated the bytes_read to the stat.size at that time.\n # by adding this to the sincedb so that the subsequent modify\n # event can detect the change\n watched_file.watch\n yield(:unignore, watched_file)\n end\n rescue Errno::ENOENT\n # file has gone away or we can't read it anymore.\n file_deleteable << path\n @logger.debug? && @logger.debug(\"each: ignored: stat failed: #{path}: (#{$!}), deleting from @files\")\n rescue => e\n @logger.debug? && @logger.debug(\"each: ignored: stat failed: #{path}: (#{e.inspect})\")\n end\n end\n\n # Send any creates.\n if (to_take = @max_active - watched_files.count{|wf| wf.active?}) > 0\n watched_files.select {|wf| wf.watched? }.take(to_take).each do |watched_file|\n watched_file.activate\n # don't do create again\n next if watched_file.state_history_any?(:closed, :ignored)\n # if the file can't be opened during the yield\n # its state is set back to watched\n if watched_file.initial?\n yield(:create_initial, watched_file)\n else\n yield(:create, watched_file)\n end\n end\n else\n now = Time.now.to_i\n if (now - @lastwarn_max_files) > MAX_FILES_WARN_INTERVAL\n waiting = @files.size - @max_active\n specific = if @close_older.nil?\n \", try setting close_older. There are #{waiting} unopened files\"\n else\n \", files yet to open: #{waiting}\"\n end\n @logger.warn(@max_warn_msg + specific)\n @lastwarn_max_files = now\n end\n end\n\n # wf.active means the actual files were opened\n # and have been read once - unless they were empty at the time\n watched_files.select {|wf| wf.active? }.each do |watched_file|\n path = watched_file.path\n begin\n stat = watched_file.restat\n rescue Errno::ENOENT\n # file has gone away or we can't read it anymore.\n file_deleteable << path\n @logger.debug? && @logger.debug(\"each: active: stat failed: #{path}: (#{$!}), deleting from @files\")\n watched_file.unwatch\n yield(:delete, watched_file)\n next\n rescue => e\n @logger.debug? && @logger.debug(\"each: active: stat failed: #{path}: (#{e.inspect})\")\n next\n end\n\n if watched_file.file_closable?\n @logger.debug? && @logger.debug(\"each: active: file expired: #{path}\")\n yield(:timeout, watched_file)\n watched_file.close\n next\n end\n\n _inode = inode(path,stat)\n read_thus_far = watched_file.bytes_read\n # we don't update the size here, its updated when we actually read\n if watched_file.inode_changed?(_inode)\n @logger.debug? && @logger.debug(\"each: new inode: #{path}: old inode was #{watched_file.inode.inspect}, new is #{_inode.inspect}\")\n watched_file.update_inode(_inode)\n yield(:delete, watched_file)\n yield(:create, watched_file)\n elsif stat.size < read_thus_far\n @logger.debug? && @logger.debug(\"each: file rolled: #{path}: new size is #{stat.size}, old size #{read_thus_far}\")\n yield(:delete, watched_file)\n yield(:create, watched_file)\n elsif stat.size > read_thus_far\n @logger.debug? && @logger.debug(\"each: file grew: #{path}: old size #{read_thus_far}, new size #{stat.size}\")\n yield(:modify, watched_file)\n end\n end\n\n file_deleteable.each {|f| @files.delete(f)}\n end\n end", "def each(&block)\n @batch_queue.each(&block)\n end", "def each (&block)\n\n @items.each { |i| block.call(i) }\n end", "def eachGroup(&block)\n debug(\"Running 'eachGroup' in GroupNodeSet\")\n @nodeSets.each { |g|\n block.call(g)\n }\n end", "def each_schema_file(&block)\n Dir[File.expand_path(\"../fixtures/*.yaml\", __FILE__)].each(&block)\n end", "def each(&block)\n internal_collection.each(&block)\n end", "def grouped(files); end", "def each_image(&block)\n images.each(&block)\n end", "def each\n medias.each{ |media| yield media }\n end", "def each(&blk)\n @buffer.each(&blk)\n end", "def extract_blocks(dir)\n @dir = File.expand_path(dir)\n if File.directory? @dir\n Find.find(*Dir[\"#{self.dir}/**/*.rb\"]) do |filename|\n if File.file? filename\n sexp = @rp.process(File.read(filename), filename)\n self.process(sexp)\n end\n end\n elsif File.file? @dir\n sexp = @rp.process(File.read(@dir), @dir)\n self.process(sexp)\n end\n @sexp_blocks\n end", "def each(&block)\n all.each(&block)\n end", "def each(&block)\n records.each(&block)\n end", "def each\n\t\treturn self if (!@fp)\n\t\tyield Marshal.load(@fp) while ([email protected])\n\t\treturn self \n\tend", "def yields\n parsed {\n @yields\n }\n end", "def each(&block)\n documents.each(&block)\n end", "def batch\n yield if block_given?\n end", "def _each(&block)\n _next.each(&block) if _next\n end", "def each_partition(&block)\n Bucket.objects(bucket_name, :prefix => basedir) do |o|\n f = File.basename(o.key)\n next if f == 'index'\n yield f\n end\n end", "def each_package(&block)\n packages_by_name.each_value(&block)\n end" ]
[ "0.80323106", "0.7818534", "0.78127897", "0.7635867", "0.7465636", "0.7359753", "0.72199017", "0.7203133", "0.700522", "0.6931638", "0.68576515", "0.68576515", "0.68499184", "0.68456817", "0.6802476", "0.67830515", "0.6758182", "0.6707364", "0.66735905", "0.66613203", "0.6647773", "0.6633661", "0.66107553", "0.654761", "0.65446395", "0.649032", "0.64871335", "0.64652836", "0.64652836", "0.6444381", "0.6428138", "0.6412465", "0.639916", "0.63716376", "0.63457215", "0.6314621", "0.63063604", "0.6301539", "0.62673986", "0.62441933", "0.6243772", "0.6230444", "0.6217975", "0.6210108", "0.6187147", "0.61822057", "0.61813265", "0.6156579", "0.61339873", "0.6104479", "0.60990715", "0.6077274", "0.6076078", "0.6055576", "0.6054278", "0.603603", "0.60244614", "0.60195214", "0.6016606", "0.5999855", "0.5990041", "0.59878546", "0.5984495", "0.59786963", "0.5970992", "0.59698814", "0.596707", "0.5965753", "0.59463185", "0.59431386", "0.594133", "0.59316677", "0.592564", "0.5922335", "0.5920186", "0.59162426", "0.58929026", "0.58884263", "0.58873713", "0.58838755", "0.5883395", "0.5879533", "0.5876711", "0.5871431", "0.5858114", "0.5854937", "0.58542895", "0.58510095", "0.58500886", "0.58325875", "0.5828955", "0.5827449", "0.582154", "0.5817369", "0.5816549", "0.581529", "0.58091825", "0.5804796", "0.5798845", "0.5797648" ]
0.76924634
3
Iterate over all tailers in this group yielding to +block+ for each of them.
def each_tailer(&block) @tailers.list.map(&block) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def each(&block)\n yield self\n children.each {|c| c.each(&block)}\n end", "def tail\n wait_for_activity do |tailer|\n tailer.pending_lines.each do |line|\n line.extend LineExtension\n line.instance_variable_set :@tailer, tailer\n yield line\n end\n end\n end", "def each(&block)\n decorators.each(&block)\n end", "def each_file(&block)\n each_tailer { |t| t.file }.map(&block)\n end", "def each(&block)\n\t\t\t\[email protected](&block)\n\t\t\tend", "def each(&block) \n current = @head\n \n while current\n block.call(current.value)\n current = current.successor\n end\n end", "def each(&block)\n (@first .. @last).each(&block)\n end", "def each_child(&_block)\n @children.each { |child| yield child }\n end", "def each(&block)\n @patterns.each(&block)\n end", "def each\n @source.each do |elem|\n yield DropDelegation.wrap_element(elem)\n end\n end", "def each(&block)\n return @parts.each(&block)\n end", "def each_spawner(&block)\r\n @spawners.each(&block)\r\n end", "def each\n @children.each { |child| yield child }\n end", "def each\n @body.each do |block|\n yield @resource.send(@encoder, @resource.send(@charsetter, block.to_s))\n end\n end", "def each(&block)\n @ledger.each(&block)\n end", "def each\n yield self\n children.each {|c| c.each {|n| yield n}}\n end", "def each &block\n @legs.each &block\n end", "def each(&block)\n block.call(self)\n @child_array.each do |node|\n node.each(&block)\n end\n end", "def iterate_children(ts, block, new_model)\n ts.children.each do |cs|\n # assumes there is only one element - could iterate instead but what case would that be?\n element = block.css(cs.selector).first\n\n handle_element(cs, element, new_model)\n end # end top selector children iteration\n end", "def each(&block)\n axis_iterator(:child).each(&block)\n end", "def blocks() end", "def each\n @flux.each do |ligne|\n yield(ligne)\n end\n end", "def _each(&block)\n _next.each(&block) if _next\n end", "def each\n\t\treturn nil unless block_given?\n\n\t\tcurrent = self.head\n\t\twhile current\n\t\t\tyield current\n\t\t\tcurrent = current.next\n\t\tend\n\tend", "def each\n self.traverse_down { |node| yield(node) }\n end", "def each_channel(&block); end", "def each\n @children.each {|child| yield child}\n end", "def each\n current_node = @head\n (0..@size - 1).each do |_i|\n yield current_node.data\n current_node = current_node.next\n end\n end", "def each(&block)\n i = @elements.length - 1\n while i >= 0\n yield @elements[i]\n i -= 1\n end\n end", "def each_child\n @children.each { |child| yield child }\n end", "def each\n @node_set.each do |c|\n yield NodeProxy.new(c, parent)\n end\n end", "def each(&block)\n return to_enum unless block_given?\n \n unless empty?\n yield(head)\n tail.each(&block)\n end\n \n self\n end", "def batch\n yield if block_given?\n end", "def each(&block)\n\n all.each { |wi| block.call(wi) }\n end", "def each_block(&block)\n return enum_for(:each_block) unless block_given?\n\n each_log do |log|\n log.each_block(&block)\n end\n end", "def each(&block)\n dots.each(&block)\n end", "def each(&block)\n group.each_value(&block)\n end", "def blocks; end", "def blocks; end", "def blocks; end", "def process_blocks(blocks); end", "def each(&blk)\n @body_callback = blk\n schedule_dequeue\n end", "def each &block\n @parts.each(&block)\n end", "def each\n @node_set.each do |c|\n yield NodeProxy.new(c, parent)\n end\n end", "def each(&block)\n return enum_for(:each) unless block_given?\n visit { |node| yield node }\n self\n end", "def each\n return nil unless block_given?\n\n current = self.head\n while current\n yield current\n current = current.next\n end\n end", "def each_receiver(&blk) # :yield: anAID\n receivers.each(&blk)\n end", "def each_block\n 0.upto(3) do |x|\n 0.upto(3) do |y|\n # TODO: Move the bitwise and into #rotation.\n # Not sure now there's a rotate method for each direction.\n c = Tetrominos[@shape][@rotation & 3][y][x]\n yield x, y, c if c == 1\n end\n end\n end", "def each(node, &block); end", "def each(node, &block)\n visit(node, &block)\n end", "def each_child\n @children.each { |child| yield child }\n end", "def pipelined\n yield\n end", "def each(&block)\n end", "def block\n (@blocks ||= Array.new) << Block.new\n @in_block = @blocks.last\n yield\n @in_block = nil\n end", "def each_target(&block)\n\t\ttargets.each do |target|\n\t\t\tblock.call(target)\n\t\tend\n\tend", "def each_target(&block)\n\t\ttargets.each do |target|\n\t\t\tblock.call(target)\n\t\tend\n\tend", "def each(&block)\n begin\n while true\n block.call(@fiber.resume)\n end\n rescue StopIteration\n end\n end", "def each_patch\n @patches.each do |p|\n yield p\n end\n end", "def feed_each(data, &block)\n end", "def each\n yield self[0]\n yield self[1]\n end", "def each(&block)\n all.each(&block)\n end", "def each\n @links.each { |_, actor| yield(actor) }\n end", "def each(&block)\n @tarreader.each { |entry| yield entry }\n ensure\n @tarreader.rewind\n end", "def each_edge(&block)\r\n each_dependency_provider do |provider, edges|\r\n edges.each do |edge|\r\n block.call(provider, edge)\r\n end\r\n end\r\n end", "def each_node(&block)\n nodes.each_node &block\n end", "def each_node(&block)\n nodes.each_node &block\n end", "def each_node(&block)\n c = children # save children before yield\n yield(self)\n c.each do |n|\n n.each_node(&block)\n end\n end", "def yields\n parsed {\n @yields\n }\n end", "def each_registered_block(type, &block); end", "def each(&block)\n @all.each_batch { |batch| batch.each { |s| yield s } }\n end", "def each(&block)\n @stack.lazy.map(&:middleware).each(&block)\n end", "def each_mid(&block)\n \n end", "def each_block\n unless block_given?\n return enum_for(:each_block)\n end\n\n each_log do |log|\n log.each_block do |block_index, block|\n yield block_index, block\n end\n end\n end", "def process_self_and_descendants\n yield self\n descendants.each { |item| yield(item) }\n end", "def each(&block)\n @buffer.each(&block)\n end", "def each &blk\n @body_callback = blk\n end", "def each(&block)\n root.each(&block)\n end", "def each\n @routes.each do |rt|\n yield rt\n end\n self\n end", "def each\n\t parts = body_parts.map { |p| \n\t\tp.multipart? ? p.body_parts : p }\n\t parts.flatten.compact.each { |p| yield(p) }\n\tend", "def each(&block)\n tree.each(&block)\n end", "def br(block)\n return if @finished\n @builder.br(block.is_a?(Generator) ? block.start_block : block.to_ptr)\n self.finish\n end", "def each(&block)\n entries.each(&block)\n self\n end", "def each_node(&block)\n\t\t\tnodes.each(&block)\n\t\tend", "def each_receiver(&blk) # :yields: anAID\n receivers.each(&blk)\n end", "def each( &block )\n @trees.merge( @networks ).each( &block )\n end", "def each\n all.each do |el|\n yield el\n end\n end", "def generators(&blk); end", "def generators(&blk); end", "def each\n enclosed_yield = Proc.new { |*args| yield *args }\n\n @proc.call Yielder.new(&enclosed_yield)\n end", "def each(&block)\n Placeholder.each(node_data, &block)\n end", "def each(&block)\n each_page { |page| page.each(&block) }\n end", "def each\n all.each do |el|\n yield el\n end\n end", "def each(&block); end", "def each(&block); end", "def each(&block); end", "def each(&block); end", "def each(&block); end", "def each(&block); end", "def each(&block)\n\t\[email protected](1).each(&block)\n\t\treturn self\n\tend", "def each(&block)\n node = first\n\n while node\n if block\n block.yield(node)\n end\n\n if node.next\n node = node.next\n else\n break\n end\n end\n\n return node\n end" ]
[ "0.64705664", "0.6391662", "0.63500714", "0.6252506", "0.6173574", "0.6153464", "0.60445", "0.5946809", "0.5942449", "0.5941352", "0.59347117", "0.5928642", "0.59150916", "0.5906767", "0.5898796", "0.58932215", "0.5881881", "0.5853531", "0.5840768", "0.58348775", "0.5825165", "0.58132076", "0.5801961", "0.5783529", "0.57822824", "0.576774", "0.57585806", "0.5752724", "0.57489866", "0.5740183", "0.5729776", "0.572202", "0.57212174", "0.5718545", "0.57142705", "0.57133955", "0.57122946", "0.56983966", "0.56983966", "0.56983966", "0.568912", "0.5673834", "0.5673756", "0.5671588", "0.5670544", "0.56652856", "0.5665009", "0.5658279", "0.565807", "0.56556404", "0.56443584", "0.5639741", "0.56294256", "0.5627188", "0.5608261", "0.5608261", "0.5607127", "0.56060636", "0.5601812", "0.5600606", "0.55961114", "0.5584638", "0.5583436", "0.55812275", "0.5581035", "0.5581035", "0.55799556", "0.557465", "0.5565616", "0.5562544", "0.5559775", "0.5557447", "0.55550325", "0.5545993", "0.5540168", "0.5540032", "0.5529948", "0.55295324", "0.55259657", "0.5520735", "0.5520429", "0.55139047", "0.5512753", "0.5512421", "0.551237", "0.55047953", "0.5504692", "0.5504692", "0.5500021", "0.5490345", "0.54878014", "0.5485642", "0.54855484", "0.54855484", "0.54855484", "0.54855484", "0.54855484", "0.54855484", "0.54813945", "0.5478481" ]
0.8152976
0
Stop all tailers in this group at once.
def stop each_tailer { |t| t.stop } each_tailer { |t| t.join } self end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stop_all!\n @devices.each(&:stop!)\n end", "def stop\r\n logger.info{\"stop_dispatchers #{@group}\"}\r\n return unless @group\r\n @group.list.each {|d| d[:dying] = true}\r\n @group.list.each {|d| d.join }\r\n @dispatch_targets = \"\"\r\n end", "def stop_all\n @resources.each { |name,object| stop name unless object.done? } unless @all_stopped\n end", "def stop_all_streams; end", "def stop_all\n @targets.each do |target_ip, _|\n deactivate target_ip\n end\n end", "def stop\n @timers.each do |timer|\n timer.cancel\n end\n @timers.clear\n end", "def stop\n @bars.each(&:stop)\n end", "def stop()\n @tasks.each_value { |task| task.stop() }\n end", "def stop\n puts \"Stoping any instance with group ID: #{@os_aws.group_uuid}\"\n\n stop_instances_by_group_id(@os_aws.group_uuid)\n end", "def stop!\n stopper.call\n end", "def stop\n consumers.values.each(&:unsubscribe)\n end", "def stop()\n @flows.each_value { |f| f.stop() }\n end", "def stop\n @loop = nil\n end", "def stop_workers\n for worker in workers\n for child in worker.childs\n child.die!\n end\n end\n workers.clear\n end", "def stop\n @enabled = false\n end", "def stop\n Internals::ThreadPool.stop\n @listeners ||= []\n\n # TODO: should use a mutex for this\n @listeners.each do |listener|\n # call stop to halt the main loop\n listener.stop\n end\n @listeners = nil\n end", "def stop\n @run = false\n end", "def stop\n @manager.shutdown\n @nodes.each(&:stop)\n end", "def stop_subscribers\n subscribers.each { |subscriber| subscriber << :terminate! }\n\n nil\n end", "def stop\n managers.each { |manager| manager << :terminate! } if managers\n @managers = nil\n\n nil\n end", "def stop\n @running = false\n @threads.each do |thread|\n thread.kill(5)\n thread.join\n end\n @threads = []\n end", "def detach\n @loop.watchers.each {|watcher| watcher.detach }\n end", "def stop\n control :kill\n self\n end", "def stop\n @stopping = true\n wakeup\n end", "def stop_threads\n @worker_threads.each do |name, t|\n puts \"Stopping thread: #{name}\"\n t.exit\n end\n end", "def stop\n @consumers.each(&:stop)\n end", "def stop\n @running = false\n end", "def stop\n @running = false\n end", "def stop\n @stop_loop.call\n end", "def stop_on(signal)\n Signal.trap(signal) {\n @multi_node.stop\n }\n self\n end", "def stop\n super\n @temp.stop\n end", "def stop\n put :stop\n end", "def stop\n @running = false\n end", "def stop\n @running = false\n end", "def stop\n @running = false\n end", "def stop\n @pipeline.stop\n end", "def stop!\n @stop_ractor.send(:stop) and loop { break unless wait }\n end", "def stop\n self.polling_timers.each do |polling_timer|\n polling_timer.shutdown\n end\n self.polling_timers = []\n end", "def stop\n @thread.kill\n self.send(:post_stop) if self.respond_to?(:post_stop, true)\n end", "def stop\n daemon_workers.each do |pid, worker_threads|\n worker_threads.each(&:kill)\n worker_threads.clear\n end\n exit\n end", "def stop\n @stopping=true\n self << lambda{ self.terminate }\n # Pass a terminate function as final\n # function on queue. Will unblock thread\n # if not doing anything.\n end", "def stop\n @arpeggiators.each { |arpeggiator| arpeggiator.sequencer.event.do_stop }\n @clock.stop\n true\n end", "def stop_all\n @servers.each do |s|\n terminate_server(s) if s.state == 'operational' || s.state == 'stranded'\n end\n @servers.each { |s| s.wait_for_state(\"stopped\") }\n # unset dns in our local cached copy..\n @servers.each { |s| s.params['dns-name'] = nil }\n end", "def stop\n @listening = false\n @thread.join if @thread\n end", "def stop(&blk)\n if blk\n Smith.stop(true, &blk)\n else\n Smith.stop(true)\n end\n end", "def stop!\n @stop_mutex.synchronize { @stop = true }\n end", "def stop\n unless Thread.current == @thread\n @thread.kill\n end\n end", "def stop\n @stop = true\n end", "def stop_throttling\n @timer.cancel\n @timer = nil\n end", "def stop\n yield\n end", "def stop!\n @stop = true\n end", "def stop!\n @stop = true\n end", "def stop\n if (self.relay_thread)\n self.relay_thread.kill\n self.relay_thread = nil\n end\n\n self.relay_mutex.synchronize {\n self.relays.delete_if { |k, v|\n v.shutdown\n v.close\n true\n }\n }\n\n # make sure we kill off active sockets when we shut down\n while self.rfds.length > 0\n close_relay_conn(self.rfds.shift) rescue nil\n end\n\n # we can safely clear the channels array because all of the\n # reverse relays were closed down\n self.rev_chans.clear\n self.relays.clear\n end", "def stop_chronicles(**options)\n Injector.new(self, options).run\n end", "def stop!\n @thread.kill && @thread.stop?\n end", "def stop\n @runner.stop\n end", "def shutdown\n @threads.each { |thread| thread.kill if thread.respond_to?(:kill) }\n @threads.map! { nil }\n end", "def stop\n\n @threadPool.each do |t|\n\n t.terminate\n\n end\n\n @threadPool = []\n\n @running = false\n\n @jobs.each do |j|\n j.signalCancel \n end\n\n @jobs = []\n @timeoutList = []\n @preJobs = {}\n @messageIndex = {}\n\n end", "def stop!\n # Lock usage:\n # 1. @stop.mutex\n\n @stop.set(true)\n end", "def stop!\n return unless self.started_at.present? and self.stopped_at.nil?\n\n # Each attendee needs to be stopped as well.\n self.attendees.each(&:stop!)\n\n self.update_attribute(:stopped_at, Time.now)\n end", "def stop\n @shutdown = true\n end", "def stop\n if @thread\n @thread.kill\n @thread = nil\n end\n end", "def stop_watching\n @thread.kill\n end", "def stop\n @pipe_eventable.force_detach if @pipe_eventable\n @pipe_eventable = nil\n true\n end", "def stop\n @actions << :stop\n end", "def stop\n end", "def stop\n end", "def stop\n end", "def kill_threads\n threads.each{|thread| thread.terminate}\n self.threads = []\n end", "def stop\n @running = false\n end", "def stop( timeout = 5 )\n return self unless running?\n @stop = true\n\n @cleanup.call\n ObjectSpace.undefine_finalizer(self)\n\n # the cleanup call sends SIGTERM to all the child processes\n # however, some might still be hanging around, so we are going to wait\n # for a timeout interval and then send a SIGKILL to any remaining child\n # processes\n nap_time = 0.05 * timeout # sleep for 5% of the timeout interval\n timeout = Time.now + timeout\n\n until @cids.empty?\n sleep nap_time\n unless Time.now < timeout\n @cids.kill 'KILL', :all\n @cids.clear\n @group.list.each {|t| t.kill}\n break\n end\n end\n\n self\n end", "def stop_all_movements\n @move_obj.clear_move_info\n @shadow_point.clear_move_info\n end_smooth_slide\n @shadow_point.end_smooth_slide\n end", "def stop\n with_mutex do\n if running?\n @update.push(nil, :head => true)\n @ticker.join\n end \n self\n end\n end", "def stop\n get_scheduler.unschedule(@thread_id) if @thread_id\n flush_buckets()\n end", "def stopKill\n self.stop_d\n return\n end", "def stop(commands, runner)\n end", "def stop!\n @stopped = true\n end", "def stop\n @mutex.synchronize{ @do_stop = true }\n end", "def stop\n check_alive! if options(:strict)\n self << Stop.new\n @strategy.stop\n raise @exception if @exception\n end", "def stop_all_streams\n log(:debug) { log_fmt(\"Stop all streams\") }\n connection.streams.remove_all(identifier)\n end", "def disable!\n tracers.each(&:disable!)\n end", "def stop!\n @thread.kill if @running\n @running = false\n end", "def stopsig(*) end", "def turn_off_all\n return if running?\n @competition.turn_off_all\n end", "def stop\n stop_control_loop\n end", "def stop()\n @running = false # to avoid error message from termination\n # the \"minus\" terminates all processes with the group ID @pid\n # this ensures the child and all of its grandchildren are terminated\n # PROBLEM: the children are not terminated when the parent exits\n Process.kill(\"-TERM\", @pid)\n Timer.cancel(@name)\n @@inst[self.class].delete(@name)\n end", "def shutdown\n @@servers.values.each do |server|\n server.disconnect\n server.scheduler.remove_all\n end\n end", "def stop\n @stopped = true\n end", "def stop\n @stopped = true\n end", "def stop\n @stopped = true\n end", "def stop\n return unless services.any? { |s| s.process }\n puts \"Stopping the services...\"\n services.map {|s| Thread.new { s.stop } }.map(&:join)\n end", "def stop!\n @connections.each do |connection|\n puts \" -> stopping '#{connection.connection_id}'\"\n connection.disconnect\n end\n\n SweetieBot.log 'Stopped.'\n end", "def stop_supervised\n Karafka::App.stop!\n\n # See https://github.com/dry-rb/dry-configurable/issues/93\n timeout = Thread.new { Karafka::App.config.shutdown_timeout }.join.value\n\n # We check from time to time (for the timeout period) if all the threads finished\n # their work and if so, we can just return and normal shutdown process will take place\n (timeout * SUPERVISION_CHECK_FACTOR).to_i.times do\n if consumer_threads.count(&:alive?).zero?\n Thread.new { Karafka.monitor.instrument('app.stopped') }.join\n return\n end\n\n sleep SUPERVISION_SLEEP\n end\n\n raise Errors::ForcefulShutdownError\n rescue Errors::ForcefulShutdownError => e\n Thread.new { Karafka.monitor.instrument('app.stopping.error', error: e) }.join\n # We're done waiting, lets kill them!\n consumer_threads.each(&:terminate)\n\n # exit! is not within the instrumentation as it would not trigger due to exit\n Kernel.exit! FORCEFUL_EXIT_CODE\n end", "def stop\n Agent.stop\n end", "def stop_loop_animation\n loop_animation(nil)\n end", "def stop\n @stopping = true\n thread.join\n end", "def stop\n\n super\n\n stop_observing\n end", "def stop_watchdog!\n @watch_thread.exit if @watch_thread\n end", "def stop\n\n @stopped = true\n end", "def stop\n if @running\n @running = false\n @connections.each { |conn| conn.stop(@stop_bytes) }\n end\n end" ]
[ "0.6860611", "0.6478915", "0.63873327", "0.6318151", "0.627823", "0.62006503", "0.61925113", "0.60933924", "0.6019008", "0.6013114", "0.5999452", "0.5985321", "0.59636724", "0.594251", "0.59315616", "0.5917357", "0.59011674", "0.59001845", "0.5892454", "0.5883986", "0.58704364", "0.58648527", "0.58379567", "0.5820282", "0.58181155", "0.5816845", "0.5805305", "0.5805305", "0.57931525", "0.5759769", "0.5749061", "0.5730539", "0.57301694", "0.57301694", "0.57301694", "0.5728862", "0.5728777", "0.5724247", "0.5713665", "0.5711309", "0.5687073", "0.567402", "0.5666323", "0.5655504", "0.56542635", "0.5651341", "0.5626847", "0.5619055", "0.56183904", "0.56134564", "0.5607141", "0.5607141", "0.5606369", "0.5606177", "0.5603073", "0.559532", "0.5592992", "0.5583177", "0.55782443", "0.5574687", "0.55731624", "0.5560608", "0.55602616", "0.55504465", "0.55472046", "0.55458105", "0.55458105", "0.55458105", "0.55447", "0.5543614", "0.5542588", "0.55391186", "0.5529116", "0.552808", "0.55191505", "0.55167514", "0.551569", "0.55126107", "0.5511055", "0.5507719", "0.5504382", "0.55009025", "0.5500761", "0.54974264", "0.549481", "0.5481313", "0.54794455", "0.5476022", "0.54706913", "0.54706913", "0.54661417", "0.5463298", "0.54628104", "0.546085", "0.5455666", "0.5454531", "0.5454347", "0.54539824", "0.5453209", "0.54508716" ]
0.75995207
0
Tail all the lines of all the files in the Tail::Group instance, that is yield to each of them. Every line is extended with the LineExtension module, that adds some methods to the line string. To get the path of the file this line was received from call line.file.path.
def tail wait_for_activity do |tailer| tailer.pending_lines.each do |line| line.extend LineExtension line.instance_variable_set :@tailer, tailer yield line end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def each_file(&block)\n each_tailer { |t| t.file }.map(&block)\n end", "def tail_file\n file_watch = FileWatch::Tail.new\n file_watch.tail( \"#{@path}*\" )\n file_watch.subscribe do |_, line|\n process_line( line )\n end\n end", "def each_line(*args, &block)\n IO.foreach(@path, *args, &block)\n end", "def foreachline(*args, &block)\n warn \"Path::Name#foreachline is obsoleted. Use Path::Name#each_line.\"\n each_line(*args, &block)\n end", "def tail_last\n log_name = last_log\n File.open log_name do |f|\n f.extend File::Tail\n f.interval = 2\n f.backward(2)\n f.return_if_eof = true\n loop do\n f.tail { |line| color_print line }\n break unless last_log == log_name\n end\n end\nend", "def each\n @theLines.each { |s| yield s }\n end", "def tail(n = nil, &block) # :yields: line\n @n = n\n result = []\n array_result = false\n unless block\n block = lambda { |line| result << line }\n array_result = true\n end\n preset_attributes unless defined? @lines\n loop do\n begin\n restat\n read_line(&block)\n redo\n rescue ReopenException => e\n until eof? || @n == 0\n block.call readline(@line_separator)\n @n -= 1 if @n\n end\n reopen_file(e.mode)\n @after_reopen.call self if defined? @after_reopen\n rescue ReturnException\n return array_result ? result : nil\n end\n end\n end", "def each_tailer(&block)\n @tailers.list.map(&block)\n end", "def tail(n = nil, &block) # :yields: line\n @n = n\n result = []\n array_result = false\n unless block\n block = lambda { |line| result << line }\n array_result = true\n end\n preset_attributes unless @lines\n loop do\n begin\n restat\n read_line(&block)\n redo\n rescue ReopenException => e\n until eof? || @n == 0\n block.call readline\n @n -= 1 if @n\n end\n reopen_file(e.mode)\n @after_reopen.call self if @after_reopen\n rescue ReturnException\n return array_result ? result : nil\n end\n end\n end", "def each(&block)\n\t\t\t\tfiles = []\n\n\t\t\t\[email protected] do |filename|\n\t\t\t\t\tf = open_file(filename)\n\t\t\t\t\tf.each do |line|\n\t\t\t\t\t\tline.gsub!(\"\\n\",\"\")\n\n\t\t\t\t\t\t# Ignore these lines since they does not contain a\n\t\t\t\t\t\t# filename.\n\t\t\t\t\t\tnext if /^#/.match(line)\n\n\t\t\t\t\t\t# Skip empty lines as well.\n\t\t\t\t\t\tnext if /^\\s*$/.match(line)\n\n\t\t\t\t\t\tline = File.join(@prefix, line) unless @prefix.nil?\n\t\t\t\t\t\tfiles << line\n\t\t\t\t\tend\n\t\t\t\t\tclose_file(f)\n\t\t\t\tend\n\n\t\t\t\tfiles.each(&block)\n\t\t\tend", "def get_text_lines(remotefile, &block) # :yield: line\n lines = []\n retrlines(\"RETR \" + remotefile) do |line|\n if block\n yield(line)\n else\n lines << line\n end\n end\n lines\n end", "def each(options = {})\n options = { delimiter: \"\\t\", progress_bar: true }.merge(options)\n \n # Create the progress bar\n if options[:progress_bar]\n `wc -l #{@io.path}` =~ /\\d+/\n pbar = ProgressBar.new(\"Parsing #{Pathname.new(@io.path).basename}\", $~[0].to_i, STDOUT)\n end\n \n @io.each do |raw_line|\n pbar.inc if options[:progress_bar]\n \n # Handle possible issues with line return encodings\n cr_lines = raw_line.strip.split(\"\\r\")\n cr_lines.each do |line|\n # Skip lines that are comments.\n # TODO: This eventually may want to be handled differently since some comments are actually pragmas\n begin\n next if line =~ /^(#|\\s+$)/\n rescue\n # Try to handle for bad character conversion\n line = Iconv.new('UTF-8//IGNORE', 'UTF-8').iconv(line)\n next if line =~ /^(#|\\s+$)/\n end\n \n yield line.split(options[:delimiter]).map(&:strip)\n end\n end\n end", "def tail(filename)\n if filename\n if block_given?\n File.open(filename) do |file|\n file.seek(0, IO::SEEK_END)\n\n yield file\n end\n\n else\n file = File.open(filename)\n file.seek(0, IO::SEEK_END)\n file\n end\n\n elsif block_given?\n yield\n end\n end", "def each_line\n return enum_for(:each) unless block_given?\n offset, last_line_index = @from, lines.count - 1\n lines.each_with_index do |line, line_index|\n yield(line, page_for(index: offset), line_index == last_line_index)\n offset += line.length\n end\n end", "def extract_modified_lines(file_path, options); end", "def extract_modified_lines(file_path, options); end", "def each\n # Prefixes of all diff lines, indicating their types\n # For example: `\" - + -+ ---+++ --+ -++\"`\n line_prefixes = lines.each_with_object(+\"\") { |line, s| s << (line[0] || ' ') }.gsub(/[^ +-]/, ' ')\n\n line_prefixes.scan(LINE_PAIRS_PATTERN) do\n # For `\"---+++\"`, `begin_index == 0`, `end_index == 6`\n begin_index, end_index = Regexp.last_match.offset(:del_ins)\n\n # For `\"---+++\"`, `changed_line_count == 3`\n changed_line_count = (end_index - begin_index) / 2\n\n halfway_index = begin_index + changed_line_count\n (begin_index...halfway_index).each do |i|\n # For `\"---+++\"`, index 1 maps to 1 + 3 = 4\n yield [i, i + changed_line_count]\n end\n end\n end", "def process_grouped_examples(lines, pattern, lineno = 1)\n chunks = lines.slice_before(pattern)\n chunks = chunks.map { |chunk| v = [chunk, lineno]; lineno += chunk.size; v }\n chunks.map do |chunk, chunk_lineno|\n trimmed_chunk = chunk.trim_blank\n [trimmed_chunk, chunk_lineno + chunk.index(trimmed_chunk.first)]\n end\n chunks.each { |chunk, chunk_lineno| process_example(chunk, chunk_lineno) }\n self\n end", "def each\n files.each do |file|\n yield file\n end\n end", "def each\n\t\t\n\t\t# Save States that this affects, and set them to defaults\n\t\tstates = [@lineno, @filelineno, @filename]\n\t\t@lineno = 0;\n\t\t\n\t\t# Read every line walking through the files\n\t\[email protected] do |filename|\n\t\t\t\n\t\t\t# Setup States Per File\n\t\t\t@filename = filename\n\t\t\t@filelineno = 0\n\t\t\tstream = STDIN\n\t\t\tstream = File.open(filename) unless filename == '-'\n\t\t\t\n\t\t\t# Read Lines\n\t\t\twhile line = stream.gets\n\t\t\t\t@lineno += 1\n\t\t\t\t@filelineno += 1\n\t\t\t\tyield line\n\t\t\tend\n\t\t\t\n\t\tend\n\t\t\n\t\t# Restore the original states\n\t\t@lineno, @filelineno, @filename = states\n\t\t\n\tend", "def lines_for(file_name, name = T.unsafe(nil)); end", "def each_file\n files.each { |filename| yield filename }\n end", "def each(&block)\n SemanticLogger.named_tagged(dirmon_entry: id.to_s) do\n # Case insensitive filename matching\n Pathname.glob(pattern, File::FNM_CASEFOLD).each do |pathname|\n next if pathname.directory?\n pathname = begin\n pathname.realpath\n rescue Errno::ENOENT\n logger.warn(\"Unable to expand the realpath for #{pathname.inspect}. Skipping file.\")\n next\n end\n\n file_name = pathname.to_s\n\n # Skip archive directories\n next if file_name.include?(self.class.default_archive_directory)\n\n # Security check?\n if (whitelist_paths.size > 0) && whitelist_paths.none? { |whitepath| file_name.to_s.start_with?(whitepath) }\n logger.error \"Skipping file: #{file_name} since it is not in any of the whitelisted paths: #{whitelist_paths.join(', ')}\"\n next\n end\n\n # File must be writable so it can be removed after processing\n unless pathname.writable?\n logger.error \"Skipping file: #{file_name} since it is not writable by the current user. Must be able to delete/move the file after queueing the job\"\n next\n end\n block.call(pathname)\n end\n end\n end", "def get_lines(filename); end", "def each\n res = Hash.new {|h, k| h[k] = ''}\n @file.each do |line|\n if line.chomp.empty?\n yield(res)\n res = Hash.new {|h, k| h[k] = ''}\n else\n if m = @line_regexp.match(line)\n res[m[1].downcase] = m[2]\n else \n res[\"body\"] += line.gsub(/\\A\\./, '').gsub(/\\A /, '')\n end\n end\n end\n ensure\n @file.close\n end", "def readlines(&block)\n loop do\n if @lines.size < 3 && [email protected]?\n @lines << @f.readline\n elsif @lines.size == 0 && @f.eof?\n break\n else\n yield @lines.shift\n end\n end\n end", "def each_file\n @sftp.dir.foreach(@path.to_s) do |entry|\n filename = entry.name\n yield filename unless directory? filename\n end\n end", "def each_entry(&block) # :yield: p\n Dir.foreach(path) {|f| yield Path::Name.new(f) }\n end", "def group_lines\n @lines.rewind\n\n in_list = false\n wanted_type = wanted_level = nil\n\n block = LineCollection.new\n group = nil\n\n while line = @lines.next\n if line.level == wanted_level and line.type == wanted_type\n group.add_text(line.text)\n else\n group = block.fragment_for(line)\n block.add(group)\n\n if line.type == :LIST\n wanted_type = :PARAGRAPH\n else\n wanted_type = line.type\n end\n\n wanted_level = line.type == :HEADING ? line.param : line.level\n end\n end\n\n block.normalize\n block\n end", "def do_it_lines\n open(file_name).each {|x| p x; }\n end", "def lines\n return self.sale.file_content.lines[self.begins_at_line..self.ends_at_line]\n end", "def each(&block)\n File.open(@filename).each do |line|\n yield(line.chomp)\n end\n end", "def each_filename; end", "def updated_lines\n io = @diff.each_line\n path = nil\n\n found = []\n\n while true\n line = io.next\n if line =~ FILE_PATTERN\n path = $1\n end\n\n if hunk_header?(line)\n line_numbers = line_numbers_for_destination(line)\n found << [ path, line_numbers ]\n end\n end\n rescue StopIteration\n return found\n end", "def trace_file_lines(path)\n begin\n File.open(path, 'r') { |file| file.read.lines }\n rescue Errno::ENOENT\n p \"Não foi possível o arquivo (nome inválido)\"\n exit\n end\n end", "def each\n changeset.each { |file| yield file }\n end", "def each_file\n return to_enum(__method__) unless block_given?\n\n paths.each do |root|\n stat_tree(root).each do |filename, stat|\n if stat.file?\n yield filename\n end\n end\n end\n\n nil\n end", "def run\n begin\n yield @first_line if block_given?\n while (size = File::Stat.new(@filename).size) >= @next_start\n size = @file.stat.size\n reset_buffer_size\n begin\n line = \"\"\n @file.seek(@next_start, File::SEEK_SET)\n @file.read(@buf_size, @buffer)\n buffer_start = @next_start\n found_new_line = false\n 0.upto(@buffer.size - 1) do |index|\n line << @buffer[index]\n if @buffer[index].chr == \"\\n\"\n yield(line) if block_given?\n line = \"\"\n found_new_line = true\n @next_start = buffer_start + index + 1\n end\n end\n unless found_new_line || @buffer.empty?\n raise BufferError\n end\n rescue BufferError\n increment_buffer_size\n retry\n end\n\t sleep 0.01\n end\n rescue Errno::ENOENT\n # Wait until the file is recreated\n while !File.exists?(@filename)\n sleep 0.05\n end\n end\n end", "def each(eol=$/)\n while line = self.gets(eol)\n yield line\n end\n end", "def unix_tail_command_brute(filename, lines)\n lines_total, output = 0, \"\"\n\n file = File.open(filename,'r')\n file.each_line do |l|\n lines_total += 1\n end\n file.close\n\n start_line = lines_total - lines\n\n line_number = 0\n file = File.open(filename,'r')\n file.each_line do |l|\n\n if line_number >= start_line\n output << \"#{l}\"\n end\n line_number += 1\n end\n file.close\n\n output\nend", "def each_line_with_index\n c = 0\n each_line do |l|\n yield l, c\n c += 1\n end\n end", "def lazy_commands_enum\n if block_given?\n File.open(@filename) do |file|\n yield file.each_line.lazy, file\n end\n else\n ensure_file_is_open\n\n @file.each_line.lazy\n end\n end", "def each_line\n while line = self.gets do\n yield line\n end\n end", "def log\n count = default_log_lines(params)\n lines = get_file_lines(log: true, tail: count)\n respond_with(lines)\n end", "def on_tail(*opts, &block)\n define_tail(*opts, &block)\n self\n end", "def each_io\n each_file do |filename|\n io = get filename\n yield filename, io\n end\n end", "def each_io\n each_file do |filename|\n io = get filename\n yield filename, io\n end\n end", "def for_contents(path)\r\n if(path.end_with? 'zip')\r\n for_zipped_contents(path) { |line| yield(line) }\r\n else\r\n File.open(path, \"r\") do |file|\r\n file.each_line do |line|\r\n yield(line)\r\n end\r\n end\r\n end\r\n end", "def line(name = nil, attr = {}, &block)\n linemap = FFMap.new parent: self, looping: attr[:looping]\n @fields << linemap\n linemap.fields << [:begin, name]\n block.call(linemap)\n linemap.fields << [:end, name]\n end", "def each_file(&bl)\n unpack do |dir|\n Pathname(dir).find do |path|\n next if path.to_s == dir.to_s\n pathstr = path.to_s.gsub(\"#{dir}/\", '')\n bl.call pathstr unless pathstr.blank?\n end\n end\n end", "def each(&block)\n @files.each(&block)\n end", "def each_log_line\n File.readlines('/var/log/syslog').each do |line|\n line.chomp!\n \n timestamp, rest = Time.parse(line), line[16..-1]\n yield [timestamp, rest]\n end\n end", "def extract_files(lines)\n lines.drop_while { |line| !line.match?(FILE_MARKER) }\n .slice_before(FILE_MARKER).map do |slice|\n # The first element of the slice is a file marker. Therefore it's\n # removed from the slice and parsed separately.\n file_marker = slice.shift.match(FILE_MARKER)\n File.new(name: file_marker[:filename],\n data: slice.join)\n end\n end", "def each_entry(&block)\n return enum_for(:each_entry) unless block_given?\n\n # XXX We have to re-open the archive on every call because libarchive is designed for streaming and doesn't\n # support iterating across the archive multiple times.\n archive = ::Archive::Reader.open_filename(file.path)\n while (entry = archive.next_header(clone_entry: true))\n yield Entry.new(archive, entry)\n end\n\n self\n ensure\n archive&.close\n end", "def each_file(&bl)\n unpack do |dir|\n Pathname.new(dir).find do |path|\n next if path.to_s == dir.to_s\n pathstr = path.to_s.gsub(\"#{dir}/\", '')\n bl.call pathstr unless pathstr.blank?\n end\n end\n end", "def reader_thread_proc\n begin\n File::Tail::Logfile.tail(@path, :backward => 10) do |line|\n begin\n parse_logline(line)\n rescue Exception => e\n puts \"Malformed log line [#{line}]: #{e}\"\n end\n end\n rescue Exception => e \n puts \"LogReader is dead: #{e}\"\n end\n end", "def each\n files.each do |f|\n content = File.read(path(f))\n content = compress(content) if @app.compress_bundles\n # Include a new line to prevent weirdness at file boundaries\n yield(\"#{content}\\n\")\n end\n end", "def each\n Dir[ path_pattern ].each { |path| yield open(path) }\n end", "def each\n pos = 0\n while(pos < @original_duration) do\n chunk = nil\n begin\n chunk = Chunk.new(@original_file, @original_duration, pos, (@chunk_duration + @overlap), @rate)\n yield chunk\n pos = pos + [chunk.duration, @chunk_duration].min\n ensure\n chunk.close_file if chunk\n end\n end\n end", "def extract_lines\n reg = Regexp.new('^\\[' + @date + ':\\d\\d:\\d\\d:\\d\\d\\].*\\n', Regexp::MULTILINE)\n if File.exists?(@@gzlogfile)\n require 'zlib'\n gzfile = open(@@gzlogfile)\n @gz = Zlib::GzipReader.new(gzfile)\n @gz.read.match(reg).to_s.split(\"\\n\")\n end\n @file.read.match(reg).to_s.split(\"\\n\")\n end", "def each_line(sep=$/, &block)\n unless block_given?\n return IoEnumerator.new(self, :each_line, sep) # for 1.8.7\n end\n if sep._equal?(nil)\n block.call( self.__contents )\n else\n sep = Maglev::Type.coerce_to(sep, String, :to_str)\n if sep.__size._equal?(0)\n while true\n para = self.__next_paragraph\n if para._equal?(nil)\n return self\n end\n block.call(para)\n end\n else\n while true\n line = self.__next_line( sep)\n if line._equal?(nil)\n return self\n end\n block.call( line )\n end\n end\n end\n self\n end", "def entry_lines(file)\n entries = []\n ::Zip::ZipFile.foreach(file) do |zentry|\n entries << zentry\n end\n entries\n end", "def egrep(filelist, pattern, egrepoptions={})\n lines = []\n filelist.each do |fn|\n open(fn) do |inf|\n count = 0\n\n inf.each do |line|\n count += 1\n if pattern.match(line)\n if block_given?\n yield fn, count, line\n else\n #puts \"#{fn}:#{count}:#{line}\"\n lines << \"#{fn}#{@todo_delim}#{count}#{@todo_delim}#{line}\"\n end\n end\n end\n\n end\n end\n unless block_given?\n ret = lines.empty? nil:lines\n return ret\n end\n end", "def tail\n self.class.allocate.replace(\n sub %r`#{File::SEPARATOR}*$`, File::SEPARATOR\n )\n end", "def each_entry( &block ) # :yield: p\n Dir.foreach( expand_tilde ) { |f| yield self.class.new( f ) }\n end", "def log_tail(options = {}, &block)\n raise \"no log host specified for #{self}\" unless log_host\n raise \"no log file patterns specified for #{self}\" unless log_file_patterns\n\n unless options.has_key? :discard_stderr\n options[:discard_stderr] = !$DEBUG\n end\n\n tail_command = TailCommand.new log_file_patterns, options\n\n command = \"ssh -oClearAllForwardings=yes '#{host}' \" +\n \"'sudo sh -c \\\"#{tail_command}\\\"'\" +\n (options[:discard_stderr] ? ' 2>/dev/null' : '')\n\n IO.popen(command) do |pipe|\n if block_given?\n yield pipe\n else\n begin\n while line = pipe.readline\n puts line\n end\n rescue EOFError\n # ignore\n end\n end\n end\n end", "def children\n c = file_log.children(file_node)\n c.map do |x|\n VersionedFile.new(@repo, @path, :file_id => x, :file_log => file_log)\n end \n end", "def each_line_with_offset\n return to_enum(:each_line_with_offset) unless block_given?\n\n offset = 0\n\n each_line do |line|\n yield line, offset\n offset = tell\n end\n end", "def loop_over_asset_lines(file_name)\n line_count = 0\n puts \"Loading #{file_name}\"\n batch_size = 25000\n File.open(file_name) do |file|\n file.each_slice(batch_size) do |lines|\n line_count += lines.length\n Parallel.each(lines, in_processes: 8) do |line|\n asset_json = FastJsonparser.parse(line, symbolize_keys: false)\n AssetRouter.new(asset_json, @import_id, @db)\n line_count += 1\n end\n end\n end\n\n puts \"\\n\\nDone loading #{file_name}. (#{line_count} lines)\"\n end", "def each(&block)\n @tarreader.each { |entry| yield entry }\n ensure\n @tarreader.rewind\n end", "def each_filename\n next_descend = path\n while next_descend != PathExpression.EMPTY\n dir, next_descend = PathExpression.descend(path)\n yield dir\n end\n end", "def buffer_lines\n buffer_line_cycle.map { |i| self[i] }.join(\"\\n\")\n end", "def each_file(&block)\n @files.keys.each do |file|\n yield(file)\n end\n end", "def lines\n @lines ||= build_lines\n end", "def tail(log, classes, methods, verbose, separator='|')\n result = String.new\n puts \"Tailing in #{log} I/O for line matching #{classes} classe(s) and #{methods} method(s) with separator '#{separator}'\" if verbose && !classes.nil? && !methods.nil?\n puts \"Tailing in #{log} I/O for line #{methods} method(s) with separator '#{separator}'\" if verbose && classes.nil? && !methods.nil?\n puts \"Tailing in #{log} I/O for line matching #{classes} classe(s) with separator '#{separator}'\" if verbose && !classes.nil? && methods.nil?\n puts \"Tailing in #{log} I/O for all lines\" if verbose && classes.nil? && methods.nil?\n classes =classes.split(',') unless classes.nil?\n methods =methods.split(',') unless methods.nil?\n classes.map!{|c| c.downcase} unless classes.nil?\n methods.map!{|m| m.downcase} unless methods.nil?\n @line_number = 0\n @line_match = 0\n # interrupted = false\n trap(\"INT\") do\n puts \"#{@line_match} lines matched on the #{@line_number} lines in the log\" if verbose \n break\n end\n begin\n File::Tail::Logfile.tail(log) do |line|\n @line_number += 1\n if match(line,classes,methods, separator)\n puts line \n @line_match += 1\n end\n # if interrupted\n # break\n # end\n end\n rescue\n nil\n end\n end", "def next_lines(lines, number)\n lines.slice!(0, number)\n end", "def listFileHashLines(baseDir)\n #N Without this, the base directory might be missing the final '/', which might cause a one-off error when 'subtracting' the base directory name from the absolute paths to get relative paths\n baseDir = normalisedDir(baseDir)\n #N Without this, we wouldn't know what command to run remotely to loop over the output of the file-files command and run the hash command on each line of output\n remoteFileHashLinesCommand = findFilesCommand(baseDir) + [\"|\", \"xargs\", \"-r\"] + @hashCommand.command\n #N Without this we wouldn't actually run the command just defined\n ssh(remoteFileHashLinesCommand.join(\" \")) do |line| \n #N Without this the line of output wouldn't be echoed to the user\n puts \" #{line}\"\n #N Without this the line of output (with a file name and a hash value) wouldn't be available to the caller of this method\n yield line \n end\n end", "def nextline\n # handle last file\n\n if @curr.nil?\n @curr=File.open @files.next rescue nil\n end\n\n return if @curr.nil? # Still Nil?\n\n # handle EOF\n if (line = @curr.gets).nil?\n @curr=nil\n :eof\n else\n line.chomp\n end\n end", "def tail(options = {}, &block)\n q = []\n event_id_highwater = nil\n counter = 0\n number = options[:number] || 0\n for_each_event name do |event|\n q.unshift event if counter < number\n counter = counter + 1\n end\n\n while q.size > 0\n event = q.shift\n yield event\n event_id_highwater = event.event_id\n end\n\n running = true\n if options[:follow]\n while running\n stack_status = describe_stacks(stack_name: name).stacks.first.stack_status\n running = running && (/.+_(COMPLETE|FAILED)$/.match(stack_status) == nil)\n\n yielding = true\n for_each_event name do |event|\n if event_id_highwater == event.event_id\n yielding = false\n end\n\n if yielding\n q.unshift event\n end\n end\n\n while q.size > 0\n event = q.shift\n yield event\n event_id_highwater = event.event_id\n end\n\n sleep 1 if running unless options[:no_sleep]\n end\n end\n end", "def each(separator = $/)\n return enum_for(:each, separator) unless block_given?\n\n line = ''\n newline_pos = nil\n\n # Either trying to parse the remainder or reading some more data\n while newline_pos || !(buffer = read(@options[:line_buffer_size])).empty?\n prev_newline_pos = newline_pos || 0\n newline_pos = buffer.index(separator, prev_newline_pos)\n\n if newline_pos\n line << buffer[prev_newline_pos..newline_pos]\n newline_pos += 1\n yield line\n line = ''\n else\n line << buffer[prev_newline_pos..-1]\n end\n end\n\n # Flush the remainder if body doesn't end with separator\n yield line unless line.empty?\n\n return self\n end", "def process_lines(input_file)\n for line in input_file\n process_line(line)\n end\n end_of_file\n end", "def stream_response_lines(response, &block)\n last_line = \"\"\n\n response.read_body do |chunk|\n chunk_lines = (last_line + chunk).lines\n # This could end with half a line, so save it for next time. If\n # chunk_lines is empty, pop returns nil, so this also ensures last_line\n # is always a string.\n last_line = chunk_lines.pop || \"\"\n chunk_lines.each(&block)\n end\n\n yield last_line unless last_line.empty?\n end", "def each_data_file(path)\n return enum_for(:each_data_file,path) unless block_given?\n\n each_data_path(path) do |full_path|\n yield(full_path) if File.file?(full_path)\n end\n end", "def each_file\n self.files.each_pair do |path, data|\n if not data.empty?\n yield path, StateModule::File::new(path, data)\n end\n end\n end", "def each_path_slice(n)\n temp = []\n File.foreach path do |line|\n line.strip!\n temp << line unless line.blank?\n\n if temp.length >= n\n yield temp\n temp.clear\n end\n end\n\n yield temp unless temp.empty?\n end", "def foreach(*args, &block)\n warn \"Path::Name#foreach is obsoleted. Use each_line or each_entry.\"\n if FileTest.directory? path\n # For polymorphism between Dir.foreach and IO.foreach,\n # Path::Name#foreach doesn't yield Path::Name object.\n Dir.foreach(path, *args, &block)\n else\n IO.foreach(path, *args, &block)\n end\n end", "def egrep(pattern)\n each do |fn|\n open(fn) do |inf|\n count = 0\n\n inf.each do |line|\n count += 1\n if pattern.match(line)\n if block_given?\n yield fn, count, line\n else\n puts \"#{fn}:#{count}:#{line}\"\n end\n end\n end\n \n end\n end\n end", "def parse_files\r\n ln_count = 0\r\n\r\n settings.file_order.each do |f|\r\n out = make_file(\"tmp.press\")\r\n\r\n ln_count += parse_lines(f, out)\r\n\r\n out.close\r\n tmp_files << out\r\n end\r\n\r\n ln_count\r\n end", "def lines(sep=$/) # added for 1.8.7\n return IoEnumerator.new(self, :each_line, sep)\n end", "def get_each\n\t\t@in_files.each do |in_file|\n\t\t\tlines = []\n\t\t\tFile.foreach(in_file) {|line| lines << line.chomp}\n\t\t\talbum_items = yield lines\n\t\t\tif !album_items.empty?\n\t\t\t\t@out_items += album_items\n\t\t\t\t@log_lines << to_log(album_items) \n\t\t\tend\n\t\tend\n\tend", "def each\n file_rec = next_candidate\n until file_rec.nil?\n yield file_rec\n\n file_rec = next_candidate\n end\n end", "def doing_by_line_length\n consumer = Fiber.new do |producer, queue|\n #f = open(\"./lib/fiber_output.txt\", \"a\") do |f|\n #f = open(\"./lib/files_to_textual/fibering_files_output.txt\", \"a\") do |f|\n #f = open(\"./lib/databasers/fibered_files_output.txt\", \"a\") do |f|\n #f = open(\"./lib/databasers/fibered_files_output.txt\", \"a\") do |f| \n f = open(\"./lib/databasers/fibering_files_output.txt\", \"a\") do |f| \n loop do\n queue = producer.transfer(consumer, queue)\n #puts queue\n #puts \"queue : \" + \"#{queue}\"\n #puts queue\n #puts queue.to_s\n #puts queue.to_s.chomp\n #puts queue.to_s.strip\n #puts queue.to_s.strip.downcase\n #puts queue.to_s.strip.downcase.to_textual\n var << queue.to_s.chomp.to_textual\n puts f << var\n #puts f << queue << var\n queue.clear\n end\n raise StopIteration\n end\n end\n producer = Fiber.new do |consumer, queue|\n a = File.read(file_name) do |a|\n b = a.to_textual\n loop do\n while value = b.shift\n queue << value\n end\n consumer.transfer queue\n queue.clear\n end\n raise StopIteration\n end\n end\n consumer.transfer(producer, [])\n after_break\n end", "def each_file(directory)\n directory_contents(directory).each do |path|\n yield path\n end\n end", "def each_line(&block)\n # expect that str.index accepts an Integer for 1st argument as a byte data\n offset = 0\n while(pos = self.index(0x0a, offset))\n block.call(self[offset, pos + 1 - offset])\n offset = pos + 1\n end\n block.call(self[offset, self.size - offset]) if self.size > offset\n self\n end", "def each(&b)\n all_files.each( &b)\n self\n end", "def each(&b)\n all_files.each( &b)\n self\n end", "def last_lines\n @last_lines ||= begin\n list = []\n @text.lines.to_a.reverse.each do |line|\n list << line\n break if line =~ /^\\S/\n end\n list.reverse\n end\n end", "def lines(source); end", "def each\n CSV.foreach(@file, :encoding => 'iso-8859-1:utf-8') do |row|\n # File has a footer - truncate at the last valid line\n break if row.empty?\n \n yield row\n end\n end", "def line\n @files.first ? @files.first[1] : nil\n end" ]
[ "0.6510908", "0.6249164", "0.564926", "0.54589766", "0.54008055", "0.534556", "0.53061855", "0.52799016", "0.5279679", "0.5264458", "0.5158363", "0.51000345", "0.5092031", "0.50782996", "0.50687075", "0.50687075", "0.4975333", "0.49530557", "0.4947006", "0.49245948", "0.48945594", "0.4888956", "0.48791122", "0.48505136", "0.48497415", "0.4819625", "0.48132354", "0.48076746", "0.4807037", "0.479508", "0.47938976", "0.4793855", "0.47929758", "0.4789436", "0.47260097", "0.46850395", "0.46770117", "0.46747765", "0.4659083", "0.46569195", "0.4633304", "0.4618897", "0.4618024", "0.4615556", "0.46096063", "0.46082497", "0.46082497", "0.4601436", "0.45955792", "0.45925638", "0.4581867", "0.45654666", "0.45617464", "0.45571515", "0.45520607", "0.45496267", "0.4539533", "0.45383453", "0.45351744", "0.45296282", "0.45271197", "0.45261857", "0.45257494", "0.45196512", "0.4517153", "0.45134082", "0.45074773", "0.4506185", "0.45041242", "0.44975683", "0.44969907", "0.44875148", "0.44830558", "0.4481015", "0.4480531", "0.44673413", "0.4466775", "0.4463919", "0.44625154", "0.44615644", "0.4457233", "0.4448221", "0.44438466", "0.44428015", "0.44409552", "0.44392973", "0.44338447", "0.44319507", "0.44237065", "0.44205788", "0.44129792", "0.4410319", "0.4394825", "0.43941146", "0.43936527", "0.43936527", "0.43934473", "0.4391078", "0.43907782", "0.4385091" ]
0.7038521
0
Notes that the given variable name is provided either by the CloudFormation environment or by another template.
def defined(name) @undefined_variables -= [name] @defined_variables |= [name] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def refurbish variable_name\n Value.typed @vars[variable_name], variable_name.to_s.sub(/^\\@/, '') #.sub(/^\\$/, '')\n end", "def variable_name=(variable_name)\n self[:variable_name] = variable_name.downcase.gsub(/[^0-9a-z_ ]/i, \"\").strip.tr(\" \", \"_\")\n end", "def lookupvar(name)\n puppet_scope.lookupvar name\n end", "def variable_get(name)\n assert_type name, :String, :name\n environment.caller.var(name.value)\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 template_ivar\n \"@#{template_name.downcase}\".to_sym\n end", "def variable_name; end", "def variable_name; end", "def get named\n raise VariableError, \"Used variable '#{named}' without setting it to something first\" unless @vars.key? named\n refurbish(named)\n end", "def lookup_variable (varname)\n\n env, var = lookup_environment(varname)\n env[var]\n end", "def get_variable(name)\n @variables[name]\n end", "def variable\n @variable ||= \"@#{@name}\"\n end", "def var!(var_name, **opts)\n value = var(var_name, **opts)\n value.nil? ? error(\"Undefined variable #{✏ var_name}.\") : value\n end", "def hasVar?( name )\n\t\t\t\tArgTest::type( \"name\", name, String )\n\t\t\t\tname.strip!()\n\t\t\t\tArgTest::stringLength( \"name\", name, 1 )\n\t\t\t\treturn @vars.has_key?( name )\n\t\t\tend", "def variable_by_name(name)\n @var_set[name]\n end", "def variable_name_expr; end", "def variable_exists(name)\n assert_type name, :String, :name\n bool(environment.caller.var(name.value))\n end", "def var_name_ok?(varname)\n svar=varname.to_s\n if @@reserved_words.include?(svar)\n raise ArgumentError, \"Name \\\"#{svar}\\\" is a reserved word in Ruby.\"\n elsif @@reserved_vars.include?(svar)\n raise ArgumentError, \"Cannot override the #{svar} variable.\"\n elsif /\\A[a-zA-Z][a-zA-Z0-9_]*\\z/.match(svar)\n return svar\n else\n raise ArgumentError, \"Invalid variable name \\\"#{var}\\\": it must be a letter followed by any number of letters, numbers and underscores.\"\n end\n end", "def [](variable_name)\n variables.find { |c| c.name == variable_name }\n end", "def varName\n \"#{entity.name}_#{name}\"\n end", "def descriptor\n ConfigvarsRails.variable_descriptor name\n end", "def _get_var(name)\n\t\treturn @replace_vars[name]\n\tend", "def getVar( name )\n\t\t\t\tArgTest::type( \"name\", name, String )\n\t\t\t\tname.strip!()\n\t\t\t\tArgTest::stringLength( \"name\", name, 1 )\n\t\t\t\treturn @vars[ name ]\n\t\t\tend", "def is_namevar?\n @is_namevar\n end", "def name(name = nil)\n @name_template = name if name\n @name_template\n end", "def variable_value(key)\n 'value'\n end", "def template_variables\n variables = {\n 'name' => new_resource.name,\n 'user' => new_resource.user,\n 'group' => new_resource.group,\n 'pid' => new_resource.pid_path,\n 'pid_dir' => new_resource.pid_dir,\n 'log_dir' => new_resource.log_dir,\n 'conf_dir' => new_resource.conf_dir,\n 'spool_dir' => new_resource.spool_dir,\n 'configs' => new_resource.configs\n }\n variables.merge!(new_resource.variables)\n variables\n end", "def variable(name)\n Tk.execute_only(:tkwait, :variable, name)\n end", "def update_value_of_variable(var_name, new_value)\n self.instance_variable_set(\"@#{var_name}\".to_sym, new_value)\n end", "def lookup_variable(key)\n\n fexp.lookup_variable(key)\n end", "def fetch_variable(var_name, required: false)\n raise \"#{var_name} is a required variable\" if ENV[var_name].nil? && required\n\n return false if ENV[var_name] && ENV[var_name].downcase == 'false'\n ENV[var_name]\nend", "def is_condensed?(variable_name)\n @condensed_variables.include?(variable_name.to_sym)\n end", "def get_variable( var_name)\n\t\tvar = Vim::evaluate(\n\t\t\t\"exists(\\\"#{var_name}\\\") ? #{var_name} : \\\"__NIL__\\\"\"\n\t\t)\n\n\t\tvar == '__NIL__' ? nil : var\n\tend", "def initialize variable_name, layout\n @variable = variable_name\n @layout = layout\n end", "def set_variable (varname, value)\n\n env, var = lookup_environment(varname)\n env[var] = value\n end", "def var=(name)\n @var = if name == :random\n \"_#{rand(2000)}\"\n else\n name\n end\n end", "def setVar( name, value )\n\t\t\t\tArgTest::type( \"name\", name, String )\n\t\t\t\tname.strip!()\n\t\t\t\tArgTest::stringLength( \"name\", name, 1 )\n\t\t\t\tArgTest::type( \"value\", value, Object, true )\n\t\t\t\t@vars[ name ] = value\n\t\t\tend", "def lookup_variable_stack (varname)\n\n get_environment.lookup_variable_stack(varname)\n end", "def set_variable(name, value)\n @variables[name] = value\n end", "def variable_index( name )\n has = names.index_of(name)\n return nil unless has\n raise \"internal error #{name}:#{has}\" if has < 0\n has\n end", "def render_variable(context)\n if @file.match(VARIABLE_SYNTAX)\n partial = context.registers[:site]\n .liquid_renderer\n .file(\"(variable)\")\n .parse(@file)\n partial.render!(context)\n end\n end", "def find_variable_by_name(name)\n v = @variables.find { |v| v[:argument][:name] == name }\n\n v\n end", "def var(name)\n res = send_cmd(\"print #{name}\").join(\"\").chomp\n if /undefined variable:/ =~ res\n kernel_raise GnuplotError,res.strip\n end\n res\n end", "def print var_name\n v = @var_table[var_name]\n if v.class == Array\n @upstream.info \"Array: #{v.length}: #{@var_table[var_name].inspect}\"\n elsif v.class == Fixnum\n @upstream.info \"Integer: #{v}\"\n elsif v.nil?\n @upstream.info \"nil\"\n end\n end", "def delete_variable (varname)\n\n env, var = lookup_environment(varname)\n env.delete(var)\n end", "def variable(name)\n var = nc.var(name) # NetCDFVar\n get(var)\n end", "def add_template_parameter(name, value)\n\t\t\t@templateVariables = appendParameter(@templateVariables, name, value)\n\t\tend", "def defvar(name, dwords=1)\n unless var?(name)\n @bss << \"#{name}: resd #{dwords}\\n\"\n @vars[name] = name\n else\n STDERR.puts \"[warning] attempted to redefine #{name}\"\n end\n end", "def myname=(myname)\n @context[:myname] = myname\n end", "def add_var(name, var)\n @var[name] = var\n end", "def variable_checker(variable)\n $user_variables[variable.upcase.ord - 65]\n end", "def setup(key, var)\n @vars[key] = var\n end", "def name(variable=default)\n\t\t ### The last line in here get's returned by default\n\t\tend", "def env_var(field)\n \"DCOS_#{field.to_s.upcase}\"\n end", "def var(name, value)\n @locals[name] = value\n end", "def check_var(varname,var=nil)\n var.nil? and fail \"Requires #{varname} be set!\"\n var\nend", "def say_name\n @name = name\n end", "def inject_var(name, value, b)\n Thread.current[:__pry_local__] = value\n b.eval(\"#{name} = Thread.current[:__pry_local__]\")\nensure\n Thread.current[:__pry_local__] = nil\nend", "def show_variable(name)\n query('SHOW VARIABLES WHERE `variable_name` = ?', name).first.value rescue nil\n end", "def variable_name(resource)\n name = controller.instance_variables.index { |var| controller.instance_variable_get(var) === resources.first }\n name = controller.instance_variables[name].to_s.gsub(/@/, '') if name\n name.to_s\n end", "def template_name=(_arg0); end", "def template_name=(_arg0); end", "def look_up_variable(name, expr)\n distance = @locals[expr]\n if distance.nil?\n @globals[name]\n else\n @environment.get_at distance, name.lexeme\n end\n end", "def var name\n Symbolic.check_name name\n var = VarExpr.new(name)\n meta_def name do\n var\n end\n var\n end", "def set_variable(name, value)\n current = @variables[name]\n if current.respond_to? :set_variable\n current.set_variable(name, value)\n else\n @variables[name] = value.to_str rescue value.to_s rescue value\n end\n end", "def template(_template_name)\n \"This is a dummy template! <%= dummy %> \\n \"\\\n 'Here is a global value <%= dummy_global %>'\n end", "def instance_variable_name(name)\n \"@#{name.to_s}\".to_sym\n end", "def find_name(name)\n\t\tif @vartab[name]\n\t\t\treturn @vartab[name]\n\t\telse\n\t\t\treturn @parent.find_name(name) if @parent\n\t\tend\n\t\traise \"Variable '%s' not defined...\" % name\n\tend", "def variable(name, value)\n raise \"Invalid variable name '#{name}'.\" unless valid_id(name)\n @file.write(\"#{name} = #{value}\\n\")\n end", "def instance_variable_name\n if options.key?(:instance_variable_name)\n options[:instance_variable_name]\n elsif name\n :\"@#{name}\"\n end\n end", "def instance_variable_ged name\n var = get_instance_variable name.to_s[1 .. -1].to_sym\n #puts \"getting #{name} #{var}\"\n var\n end", "def [](variable_name)\n instance_variable_get(\"@#{variable_name}\")\n end", "def variable_params\n params.require(:variable).permit(:name, :description, :value)\n end", "def addVariable(var_info)\n if @scope_location.nil?\n if @global.has_key?(var_info[:id])\n abort(\"\\nERROR: Variable '#{var_info[:id]}' already defined in global\\n\")\n else\n @global[var_info[:id]] = var_info\n end\n else\n in_arguments = false\n if (! @procedures[@scope_location][:args].nil?)\n @procedures[@scope_location][:args].each { |arg|\n if arg[:id] == var_info[:id]\n in_arguments = true\n break\n end\n }\n end\n if in_arguments\n abort(\"\\nERROR: Local variable '#{var_info[:id]}' already defined in the arguments of '#{@scope_location}'\\n\")\n elsif @procedures[@scope_location][:local_vars].has_key?(var_info[:id])\n abort(\"\\nERROR: Variable '#{var_info[:id]}' already defined in '#{@scope_location}'\\n\")\n else\n @procedures[@scope_location][:local_vars][var_info[:id]] = var_info\n end\n end\n end", "def name\n # scope: which vars can this method 'see'?\n @name\n end", "def make_variable(argument_name, variable_display_name, distribution, options = {})\n options = { variable_type: 'variable' }.merge(options)\n distribution[:mode] = distribution[:mean] if distribution.key? :mean\n\n raise \"Set the static value in the options 'options[:static_value]', not the distribution\" if distribution[:static_value]\n\n a = @arguments.find_all { |a| a[:name] == argument_name }\n raise \"could not find argument_name of #{argument_name} in measure #{name}. Valid argument names are #{argument_names}.\" if a.empty?\n raise \"more than one argument with the same name of #{argument_name} in measure #{name}\" if a.size > 1\n\n if distribution_valid?(distribution)\n # grab the argument hash\n a = a.first\n\n # add more information to the argument\n v = {}\n v[:argument] = a\n v[:display_name] = variable_display_name\n v[:display_name_short] = options[:variable_display_name_short] ? options[:variable_display_name_short] : variable_display_name\n v[:variable_type] = options[:variable_type]\n\n v[:type] = distribution[:type]\n v[:units] = distribution[:units] ? distribution[:units] : nil\n v[:minimum] = distribution[:minimum]\n v[:maximum] = distribution[:maximum]\n v[:relation_to_output] = distribution[:relation_to_output] ? distribution[:relation_to_output] : nil\n v[:mode] = distribution[:mode]\n v[:static_value] = options[:static_value] if options[:static_value]\n # TODO: Static value should be named default value or just value\n\n # Always look for these attributes even if the distribution does not need them\n v[:weights] = distribution[:weights] if distribution[:weights]\n v[:values] = distribution[:values] if distribution[:values]\n v[:standard_deviation] = distribution[:standard_deviation] if distribution[:standard_deviation]\n v[:step_size] = distribution[:step_size] ? distribution[:step_size] : nil\n\n # assign uuid and version id to the variable\n v[:uuid] = SecureRandom.uuid\n v[:version_uuid] = SecureRandom.uuid\n @variables << v\n end\n\n true\n end", "def say_name\n \"My name is #{@name}\"\n end", "def tmpl_var_suffix\r\n Hash.instance_variable_get :@tmpl_var_suffix\r\n end", "def set_resource_name(resource, name)\n fog_compute.tags.create :key => \"Name\", :value => name, :resource_id => resource.id\n end", "def parameter?(var_name)\n @@user_supplied_parameters.has_key?(var_name)\n end", "def referenced(name)\n @undefined_variables |= [name] unless @defined_variables.include?(name)\n end", "def variable(name, default_value = nil, &block)\n Waw::FullState::Variable.new(name, default_value, &block)\n rescue => ex\n raise ex\n end", "def set_variable(config, variable_name)\n value = ENV[variable_name]\n\n if value.to_s != ''\n config.vm.provision 'shell' do |s|\n s.inline = \"echo export #{variable_name}=\\\"\\'\\\"\\'#{value.to_s}\\'\\\"\\'\\\" | tee -a /home/vagrant/.bashrc\"\n end\n end\nend", "def named name\r\n check_string_or_proc name, 'name'\r\n @name = name\r\n end", "def delete_variable!(variable_name)\n touched = false\n\n if default_import == variable_name\n @default_import = nil\n touched = true\n end\n\n if named_imports?\n deleted = @named_imports.delete(variable_name)\n touched = true if deleted\n end\n\n clear_import_string_cache if touched\n end", "def variable(name)\n puts \"Hello, #{name}\"\n sleep(1)\n puts \"Let's begin with variables!\"\n sleep(1.5)\n puts \"A variable is a way of storing data for later use\"\n sleep(1.5)\n puts \"A variable begins with a descriptive name, followed by equals '=' and then what you want to assign the variable as\"\n sleep(2)\n puts \"For example: \"\n sleep(1)\n puts \"days_in_a_year = 365\".colorize(:blue)\n sleep(1)\n puts \"hours_in_a_day = 24\".colorize(:blue)\n sleep(1)\n puts \"your_name = '#{name}'\".colorize(:blue)\n sleep(1)\n puts \"my_name = 'Axel'\".colorize(:blue)\n sleep(2)\n puts \"This allows us to use whats in the variable, without having to remember what's in it.\"\n sleep(1.5)\n puts \"Say we wanted to figure out how many hours are in a week\"\n sleep(2)\n puts \"We can simple do: 7 x hours_in_a_day = 168\"\n sleep(1.5)\n puts \"Another reason variables are so helpful is because they are easy to change!\"\n sleep(3)\n puts \"Let's say that the hours in a day change\"\n sleep(2)\n puts \"I'll let you decide what they change to\"\n sleep(1.5)\n puts \"What do they change to??\"\n sleep(1)\n prompt = TTY::Prompt.new\n hours_in_a_day = prompt.ask(\"How many hours in a day now?\".colorize(:green), convert: :int, default: ENV[\"User\"], )\n puts \"Awesome, so hours_in_a_day = #{hours_in_a_day}\"\n sleep(2)\n puts \"So to find out how many hours in a week we do 7 x hours_in_a_day = #{7 * hours_in_a_day}\"\n sleep(3)\n puts \"Notice how the variables my_name and your_name had quotation marks around them\"\n sleep(2)\n puts \"my_name = 'Axel' \".colorize(:blue)\n puts \"your_name = '#{name}'\".colorize(:blue)\n sleep(3)\n puts \"but hours_in_a_day didn't\"\n puts \"hours_in_a_day = #{hours_in_a_day}\".colorize(:blue)\n sleep(3)\n puts \"This is because they are different 'data types'. \"\n sleep(1)\n end", "def variable_name? word\n word.start_with?('@') or word.start_with?('$')\n end", "def set_variable\n var_name=EvalBlock.lasgn(expression)\n self.variable=var_name.present? ? Variable.find_or_create_by(game: game, name: var_name) : nil\n end", "def env_name(key); end", "def say_my_name(my_name)\n\t# the my_name variable now\n\t# corresponds to the argument\n\t# defined in the function\n\t# sometimes called 'parameter'\n\tputs my_name\nend", "def variable=(flag)\n @wants_variable = flag\n @variable_id = nil unless flag\n end", "def get_variable(variableName)\r\n cmd = \"GET VARIABLE \" + variableName\r\n send(cmd)\r\n res = get_result()\r\n if res == '0' then\r\n res = nil\r\n end\r\n res\r\n\tend", "def put_var_scope\n\tinvisible_var = 4\n\tputs \"The argument variable is: #{invisible_var}\"\nend", "def name\n \"#{email_templatable_type} template: #{self[:name]}\"\n end", "def vehicleVarName _args\n \"vehicleVarName _args;\" \n end", "def foo\n # puts name # you can get the outside variable name\n puts \"foo\"\n end", "def template_name_expr; end", "def var(key:, value:)\n add option: \"-var='#{key}=#{value}'\"\n end", "def bind_var_name(o)\n if in_local_var_context\n @bound_var_names[o] = make_next_var\n else\n o\n end\n end", "def [](key, name = nil)\n if name\n h = @var_map[key]\n h && h[name]\n else\n @var_map[key]\n end\n end", "def [](var_name)\n cache.fetch(cache_key(var_name), cache_options) do\n if (var = target(var_name)).present?\n var.value\n else\n defaults[var_name.to_sym]\n end\n end\n end" ]
[ "0.6594396", "0.62164074", "0.61589015", "0.60820913", "0.6062689", "0.60330683", "0.6022929", "0.6022929", "0.5981369", "0.59636843", "0.5941758", "0.58705735", "0.58321524", "0.5787757", "0.5784766", "0.5781882", "0.57719296", "0.575948", "0.5735199", "0.56896687", "0.5655458", "0.564945", "0.5644262", "0.5643249", "0.5594202", "0.5574494", "0.5556477", "0.5535489", "0.55178875", "0.55019563", "0.5499954", "0.5471945", "0.54357755", "0.54337263", "0.5425621", "0.5415103", "0.540894", "0.53991413", "0.5371702", "0.5370707", "0.53495115", "0.53335017", "0.5331954", "0.5313015", "0.53054434", "0.5295279", "0.5275317", "0.5268728", "0.5261658", "0.5261563", "0.52539754", "0.52503157", "0.524819", "0.52423763", "0.52421564", "0.5236715", "0.5234609", "0.52285177", "0.5219534", "0.52153045", "0.5201206", "0.5201206", "0.51969206", "0.5187295", "0.5183528", "0.5162763", "0.51559114", "0.51208997", "0.5120435", "0.51156193", "0.5114309", "0.5104313", "0.5100936", "0.50982106", "0.50926995", "0.5086565", "0.5086558", "0.5085767", "0.508338", "0.5071209", "0.5065881", "0.5065567", "0.5064255", "0.50641954", "0.5064106", "0.50635076", "0.5063139", "0.50581086", "0.5054944", "0.5054574", "0.5048659", "0.50483704", "0.50402", "0.5035448", "0.5034251", "0.5034024", "0.5024126", "0.5018189", "0.50166774", "0.50136214", "0.50090855" ]
0.0
-1
Notes that the given variable name is used as an input into a template.
def referenced(name) @undefined_variables |= [name] unless @defined_variables.include?(name) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def refurbish variable_name\n Value.typed @vars[variable_name], variable_name.to_s.sub(/^\\@/, '') #.sub(/^\\$/, '')\n end", "def template_ivar\n \"@#{template_name.downcase}\".to_sym\n end", "def variable_name=(variable_name)\n self[:variable_name] = variable_name.downcase.gsub(/[^0-9a-z_ ]/i, \"\").strip.tr(\" \", \"_\")\n end", "def variable_name; end", "def variable_name; end", "def template(name); end", "def name(name = nil)\n @name_template = name if name\n @name_template\n end", "def get_variable(name)\n @variables[name]\n end", "def template(_template_name)\n \"This is a dummy template! <%= dummy %> \\n \"\\\n 'Here is a global value <%= dummy_global %>'\n end", "def variable_name_expr; end", "def render_variable(context)\n if @file.match(VARIABLE_SYNTAX)\n partial = context.registers[:site]\n .liquid_renderer\n .file(\"(variable)\")\n .parse(@file)\n partial.render!(context)\n end\n end", "def use_template(name)\n call \"_#{name}\"\n end", "def initialize variable_name, layout\n @variable = variable_name\n @layout = layout\n end", "def template_name=(_arg0); end", "def template_name=(_arg0); end", "def variable\n @variable ||= \"@#{@name}\"\n end", "def get named\n raise VariableError, \"Used variable '#{named}' without setting it to something first\" unless @vars.key? named\n refurbish(named)\n end", "def variable_by_name(name)\n @var_set[name]\n end", "def _get_var(name)\n\t\treturn @replace_vars[name]\n\tend", "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 render_variable(context)\n Liquid::Template.parse(@file).render(context) if @file =~ VARIABLE_SYNTAX\n end", "def template_name_expr; 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 varName\n \"#{entity.name}_#{name}\"\n end", "def variable_get(name)\n assert_type name, :String, :name\n environment.caller.var(name.value)\n end", "def add_template_parameter(name, value)\n\t\t\t@templateVariables = appendParameter(@templateVariables, name, value)\n\t\tend", "def [](variable_name)\n variables.find { |c| c.name == variable_name }\n end", "def getVar( name )\n\t\t\t\tArgTest::type( \"name\", name, String )\n\t\t\t\tname.strip!()\n\t\t\t\tArgTest::stringLength( \"name\", name, 1 )\n\t\t\t\treturn @vars[ name ]\n\t\t\tend", "def update_value_of_variable(var_name, new_value)\n self.instance_variable_set(\"@#{var_name}\".to_sym, new_value)\n end", "def var!(var_name, **opts)\n value = var(var_name, **opts)\n value.nil? ? error(\"Undefined variable #{✏ var_name}.\") : value\n end", "def render_variable(context); end", "def print var_name\n v = @var_table[var_name]\n if v.class == Array\n @upstream.info \"Array: #{v.length}: #{@var_table[var_name].inspect}\"\n elsif v.class == Fixnum\n @upstream.info \"Integer: #{v}\"\n elsif v.nil?\n @upstream.info \"nil\"\n end\n end", "def var name\n Symbolic.check_name name\n var = VarExpr.new(name)\n meta_def name do\n var\n end\n var\n end", "def interpolation(name)\r\n \r\n puts \"Hi, my name is #{name}.\"\r\n \r\n (name) = \"Josh\"\r\n \r\n \r\n end", "def say_name\n \"My name is #{@name}\"\n end", "def var=(name)\n @var = if name == :random\n \"_#{rand(2000)}\"\n else\n name\n end\n end", "def lookup_variable(key)\n\n fexp.lookup_variable(key)\n end", "def tmpl_var_suffix\r\n Hash.instance_variable_get :@tmpl_var_suffix\r\n end", "def get_typed_variable_name(variable_name, input_value, input_type = nil)\n unless input_type\n input_type = case input_value\n when String\n :string\n when Fixnum\n :int\n else\n nil\n end\n end\n if input_type\n \"#{@variable_prefix_types[input_type.to_sym]}#{variable_name}\"\n else\n \"#{variable_name}\"\n end\n end", "def render_name_template(template, node)\n # {p#name} is replaced with the value of the name property. {i#name} is\n # replaced with the ids of input nodes with edges named name. We\n # probably need to do these replacements in one pass...\n string = template\n string = string.gsub(%r{\\{p#(\\w+)(/s)?\\}}) { |_| node.props[Regexp.last_match(1)] }\n string = string.gsub(%r{\\{i#(\\w+)(/s)?\\}}) { |_| node.inputs.select { |e| e.props[:name] == Regexp.last_match(1) }.map { |e| e.from.id }.join(', ') }\n string = string.gsub(/\\{x#field\\}/) { |_| \"#{node.props.dig('field', :field_class).split('.').last}.#{node.props.dig('field', :name)}\" }\n string = string.gsub(/\\{x#state\\}/) { |_| \"#{node.props.dig('code', :declaring_class)}##{node.props.dig('code', :method_name)} #{node.props['sourceFile']}:#{node.props['sourceLine']}\" }\n string = string.gsub(/\\{x#simpleStamp\\}/) do |_|\n stamp = node.props.dig('checkedStamp')\n if stamp =~ /a!?# L(.*);/\n Regexp.last_match(1)\n else\n stamp\n end\n end\n string\n end", "def variable_value(key)\n 'value'\n end", "def variable(name, value)\n raise \"Invalid variable name '#{name}'.\" unless valid_id(name)\n @file.write(\"#{name} = #{value}\\n\")\n end", "def variable(name)\n puts \"Hello, #{name}\"\n sleep(1)\n puts \"Let's begin with variables!\"\n sleep(1.5)\n puts \"A variable is a way of storing data for later use\"\n sleep(1.5)\n puts \"A variable begins with a descriptive name, followed by equals '=' and then what you want to assign the variable as\"\n sleep(2)\n puts \"For example: \"\n sleep(1)\n puts \"days_in_a_year = 365\".colorize(:blue)\n sleep(1)\n puts \"hours_in_a_day = 24\".colorize(:blue)\n sleep(1)\n puts \"your_name = '#{name}'\".colorize(:blue)\n sleep(1)\n puts \"my_name = 'Axel'\".colorize(:blue)\n sleep(2)\n puts \"This allows us to use whats in the variable, without having to remember what's in it.\"\n sleep(1.5)\n puts \"Say we wanted to figure out how many hours are in a week\"\n sleep(2)\n puts \"We can simple do: 7 x hours_in_a_day = 168\"\n sleep(1.5)\n puts \"Another reason variables are so helpful is because they are easy to change!\"\n sleep(3)\n puts \"Let's say that the hours in a day change\"\n sleep(2)\n puts \"I'll let you decide what they change to\"\n sleep(1.5)\n puts \"What do they change to??\"\n sleep(1)\n prompt = TTY::Prompt.new\n hours_in_a_day = prompt.ask(\"How many hours in a day now?\".colorize(:green), convert: :int, default: ENV[\"User\"], )\n puts \"Awesome, so hours_in_a_day = #{hours_in_a_day}\"\n sleep(2)\n puts \"So to find out how many hours in a week we do 7 x hours_in_a_day = #{7 * hours_in_a_day}\"\n sleep(3)\n puts \"Notice how the variables my_name and your_name had quotation marks around them\"\n sleep(2)\n puts \"my_name = 'Axel' \".colorize(:blue)\n puts \"your_name = '#{name}'\".colorize(:blue)\n sleep(3)\n puts \"but hours_in_a_day didn't\"\n puts \"hours_in_a_day = #{hours_in_a_day}\".colorize(:blue)\n sleep(3)\n puts \"This is because they are different 'data types'. \"\n sleep(1)\n end", "def yay(name)\n # Interpolate string - performs .to_s on variable name and adds it in\n # the appropriate place in the string\n puts \"#{name} is great!\" \n end", "def info_fname\n \"_#{name}_info.html.erb\"\n end", "def add_var(name, var)\n @var[name] = var\n end", "def [](variable_name)\n instance_variable_get(\"@#{variable_name}\")\n end", "def say_my_name(my_name)\n\t# the my_name variable now\n\t# corresponds to the argument\n\t# defined in the function\n\t# sometimes called 'parameter'\n\tputs my_name\nend", "def expand_template_name(template, state)\n eval '\"' + template + '\"'\n end", "def var(name)\n res = send_cmd(\"print #{name}\").join(\"\").chomp\n if /undefined variable:/ =~ res\n kernel_raise GnuplotError,res.strip\n end\n res\n end", "def lookup_variable (varname)\n\n env, var = lookup_environment(varname)\n env[var]\n end", "def say_name\n @name = name\n end", "def process_dvar(exp)\n dvar = exp.shift\n dvar_name = @model.encode_local_variable(dvar)\n raise \"dynamic variable not available\" unless @current_iter_dvars.include?(dvar_name)\n\n resultify(\"#{dvar_name}\")\n end", "def is_namevar?\n @is_namevar\n end", "def variable!(string)\n string.replace(variable(string))\n end", "def variable_index( name )\n has = names.index_of(name)\n return nil unless has\n raise \"internal error #{name}:#{has}\" if has < 0\n has\n end", "def instance_variable_name(name)\n \"@#{name.to_s}\".to_sym\n end", "def each_var(key, name = nil)\n if name\n var = self[key, name] or\n raise MissingVariableError, \"No such var, #{key}.#{name}\"\n yield var\n else\n h = @var_map[key] or\n raise MissingKeyError, \"No such key, #{key}\"\n h.each do |name, var|\n yield var\n end\n end\n end", "def name(variable=default)\n\t\t ### The last line in here get's returned by default\n\t\tend", "def la_variable(id)\n Vocab::Variable + \" \" + variable_name(id)\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 lookupvar(name)\n puppet_scope.lookupvar name\n end", "def name\n \"#{email_templatable_type} template: #{self[:name]}\"\n end", "def set_variable(name, value)\n current = @variables[name]\n if current.respond_to? :set_variable\n current.set_variable(name, value)\n else\n @variables[name] = value.to_str rescue value.to_s rescue value\n end\n end", "def template(template_name)\n @attributes.store(template_name)\n end", "def var(name, value)\n @locals[name] = value\n end", "def edit\n locals :report_variable => current_report_variable\n end", "def variable(name)\n Tk.execute_only(:tkwait, :variable, name)\n end", "def template_replace template, myhash\n #tmpltext=File::read(template);\n\n t = template.dup\n t.gsub!( /##(.*?)##/ ) {\n #raise \"Key '#{$1}' found in template but the value has not been set\" unless ( myhash.has_key?( $1 ) )\n myhash[ $1 ].to_s\n }\n t\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 set_variable(name, value)\n @variables[name] = value\n end", "def template_name; end", "def template_name; end", "def instance_variable_ged name\n var = get_instance_variable name.to_s[1 .. -1].to_sym\n #puts \"getting #{name} #{var}\"\n var\n end", "def v(identifier)\n @variable_names = {} unless @variable_names\n unless @variable_names[identifier]\n @@variable_name_counter += 1\n @variable_names[identifier] = \"v_#{@@variable_name_counter}\"\n end\n @variable_names[identifier]\n end", "def remove_variable(name)\n if @handle.ptr == nil\n raise \"this is disposed\"\n end\n Native.RunEditor_remove_variable(@handle.ptr, name)\n end", "def define_variable(name)\n emit_section :data\n emit \"#{name}: .long 0x0\\n\"\n emit_section :text\nend", "def define_variable(name)\n emit_section :data\n emit \"#{name}: .long 0x0\\n\"\n emit_section :text\nend", "def var_name_ok?(varname)\n svar=varname.to_s\n if @@reserved_words.include?(svar)\n raise ArgumentError, \"Name \\\"#{svar}\\\" is a reserved word in Ruby.\"\n elsif @@reserved_vars.include?(svar)\n raise ArgumentError, \"Cannot override the #{svar} variable.\"\n elsif /\\A[a-zA-Z][a-zA-Z0-9_]*\\z/.match(svar)\n return svar\n else\n raise ArgumentError, \"Invalid variable name \\\"#{var}\\\": it must be a letter followed by any number of letters, numbers and underscores.\"\n end\n end", "def find_variable_by_name(name)\n v = @variables.find { |v| v[:argument][:name] == name }\n\n v\n end", "def defvar(name, dwords=1)\n unless var?(name)\n @bss << \"#{name}: resd #{dwords}\\n\"\n @vars[name] = name\n else\n STDERR.puts \"[warning] attempted to redefine #{name}\"\n end\n end", "def named name\r\n check_string_or_proc name, 'name'\r\n @name = name\r\n end", "def store_title variable_name\r\n command 'storeTitle', variable_name\r\n end", "def template(name, options=nil, &block)\n opts[:named_templates][name.to_s] = [options, define_roda_method(\"named_templates_#{name}\", 0, &block)].freeze\n nil\n end", "def replaceVariables\n\t\t@template = @template.gsub! \"###namespace###\", @namespace\n\t\t@template = @template.gsub! \"###model-name###\", @modelName\n\t\t@template = @template.gsub! \"###baseApi###\", (@baseApi.nil? ? \"\" : \" : #{@baseApi}\")\n\tend", "def interpolate(string, vars)\n string.gsub(/{{ (\\w+) }}/) { vars[$1] }\nend", "def [](var_name)\n run(:true)[var_name]\n end", "def on_mustache_partial(name)\n [:dynamic, \"#{options[:partial]}(#{name.to_sym.inspect})\"]\n end", "def buffer_variable(number, name)\n echo func('getbufvar', number, name)\n end", "def setVar( name, value )\n\t\t\t\tArgTest::type( \"name\", name, String )\n\t\t\t\tname.strip!()\n\t\t\t\tArgTest::stringLength( \"name\", name, 1 )\n\t\t\t\tArgTest::type( \"value\", value, Object, true )\n\t\t\t\t@vars[ name ] = value\n\t\t\tend", "def gen_put_variable(code_array, name)\n if name.kind_of?(JSValue)\n assert(name.type == :identifier)\n name = name.value\n end\n\n res = resolve_variable(name)\n if res\n type, link, idx = res\n if link == 0\n code_array.push(type == :formal ? :INSN_PUTFORMAL : :INSN_PUTLVAR)\n code_array.push(idx)\n else\n code_array.push(type == :formal ? :INSN_PUTFORMALEX : :INSN_PUTLVAREX)\n code_array.push(link)\n code_array.push(idx)\n end\n else\n # global variable\n code_array.push(:INSN_GETGLOBAL)\n code_array.push(:INSN_CONST)\n code_array.push(JSValue.new_string(name))\n code_array.push(:INSN_PUTPROP)\n end\n end", "def variable(name)\n var = nc.var(name) # NetCDFVar\n get(var)\n end", "def get(variable_name)\n @state.get(variable_name)\n end", "def replaceVariables\n\t\t@template = @template.gsub! \"###namespace###\", @namespace\n\t\t@template = @template.gsub! \"###model-name###\", @modelName\n\t\t@template = @template.gsub! \"###properties###\", @properties\n\tend", "def replace(key)\n instance_variable_get(\"@#{key}\").to_s\n end", "def delete_variable!(variable_name)\n touched = false\n\n if default_import == variable_name\n @default_import = nil\n touched = true\n end\n\n if named_imports?\n deleted = @named_imports.delete(variable_name)\n touched = true if deleted\n end\n\n clear_import_string_cache if touched\n end", "def instance_variable_name\n if options.key?(:instance_variable_name)\n options[:instance_variable_name]\n elsif name\n :\"@#{name}\"\n end\n end", "def pe_variable(pe)\n pe.name.squish.downcase.tr(\" \",\"_\").to_sym\n end", "def render(template_name, template_vars = {})\n template_file = File.join(File.dirname(__FILE__), 'fixtures', 'requests', \"#{template_name}.xml\")\n raise TrufinaException.new(\"Unable to find fixture file: #{template_file}\") unless File.exists?(template_file)\n \n template_binding_object = OpenStruct.new(template_vars)\n\n template = ERB.new(File.read(template_file))\n template.result(template_binding_object.get_binding)\nend", "def parse_and_resolve_variable(input)\n @stack[-1].get_variable(parse_variable(input))\n end", "def rename_local_variable\n # Start on either 'asdf', and do viw<leader>rrlv\n asdf = 10\n p asdf\n # TODO: make this work without 'v'\nend" ]
[ "0.722488", "0.670614", "0.6467525", "0.63224137", "0.63224137", "0.6288513", "0.62228125", "0.6221403", "0.6155122", "0.61331856", "0.61200035", "0.610101", "0.60931987", "0.60640407", "0.60640407", "0.60421026", "0.60152", "0.6014361", "0.5948788", "0.59264916", "0.59200835", "0.5898854", "0.58980864", "0.5854968", "0.58520657", "0.58180416", "0.58089435", "0.5786611", "0.57853836", "0.576446", "0.5727453", "0.5713276", "0.57029694", "0.56703013", "0.5652315", "0.5644298", "0.5639749", "0.563567", "0.5622825", "0.56224865", "0.5602472", "0.5594228", "0.5590064", "0.55872566", "0.5569755", "0.55575913", "0.5556197", "0.5553942", "0.5549767", "0.55291146", "0.55097204", "0.5508682", "0.54912156", "0.5487786", "0.5487198", "0.5480802", "0.5471139", "0.5466576", "0.5465926", "0.5453317", "0.54505014", "0.54426587", "0.54377574", "0.5434905", "0.5429879", "0.5428094", "0.5424949", "0.54234576", "0.54032737", "0.53796977", "0.5375109", "0.5364048", "0.5364048", "0.53584844", "0.53563", "0.53306705", "0.53215015", "0.53215015", "0.53186035", "0.53053933", "0.53000164", "0.52961487", "0.5293151", "0.52903867", "0.5288664", "0.5285317", "0.52807206", "0.5272772", "0.5272163", "0.52688426", "0.52585244", "0.52584124", "0.5251441", "0.52417463", "0.5237615", "0.52373874", "0.5234955", "0.52313673", "0.5230704", "0.52193224", "0.521745" ]
0.0
-1
before_validation :ensure_file_is_accessible pass in columns to plot
def initialize(attributes={}) super # @attributes={} #attributes.each { |key, val| (@attributes[key] = val) if respond_to?("#{key}=") } # # @attributes.each do |name, value| # send("#{name}=", value) # end run_callbacks :initialize do @r_values = [] @pr_values = [] @dmax = 0.0 @pr_max = -Float::MAX @pr_min = Float::MAX @cols =[0,1] @filename = @file_blob.filename end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attr_domain(record,row)\n #SUBPLOT\n #a meno che il numero di subplot sia incluso tra 1 e 12\n unless (1..12).include?(record.subplot)\n #salvo l'errore\n save_error(record,\"Wrong subplot\",row)\n #segnalo che c'è stato un errore sulla riga\n session[:row_error] = true\n #e segnalo l'errore sul file\n session[:file_error] = true\n end\n #IN_OUT\n #a meno che esterno valga 1 o 2\n unless (1..2).include?(record.in_out)\n #salvo l'errore\n save_error(record,\"Wrong in_out\",row)\n #segnalo che c'è stato un errore sulla riga\n session[:row_error] = true\n #e segnalo l'errore sul file\n session[:file_error] = true\n end\n #PRIEST\n #a meno che priest valga 1 o 2\n #unless (1..2).include?(record.priest)\n est_identifier = Season.find_by_nome(\"Estate\").identifier\n pri_identifier = Season.find_by_nome(\"Primavera\").identifier\n unless record.priest == est_identifier || record.priest == pri_identifier\n #salvo l'errore\n save_error(record,\"Wrong Pri/Est\",row)\n #segnalo che c'è stato un errore sulla riga\n session[:row_error] = true\n #e segnalo l'errore sul file\n session[:file_error] = true\n end\n end", "def view_data_file\n permitted = params.permit(:file_id, :data_set_id)\n blob = get_blob(@data_set, permitted[:file_id])\n @data_to_plot = ScatterData.new(:cols => [0,1])\n\n begin\n\n blob.open do |tempfile|\n\n @data_to_plot.file = tempfile\n @data_to_plot.filename = blob.filename\n\n if blob.filename.extension == \"sec\"\n @data_to_plot.is_subtracted = false\n @data_to_plot.read_sec_file\n @ymin = @data_to_plot.y_min # signif(@data_to_plot.y_min,3)\n @ymax = signif(@data_to_plot.y_max + (@data_to_plot.y_max*0.01).abs,3)\n else\n @data_to_plot.is_subtracted = @data_set.reciprocal_space_files.find_by(:id => permitted[:file_id]).sas_type\n @data_to_plot.read_contents\n @ymin_log = signif(@data_to_plot.y_min_log,3)\n @ymax_log = signif(@data_to_plot.y_max_log + (@data_to_plot.y_max_log*0.05).abs,3)\n\n puts \"min max log #{@ymin_log} #{@ymax_log} #{@data_to_plot.xy_max}\"\n\n @ymin = signif(@data_to_plot.y_min,3)\n @ymax = signif(@data_to_plot.y_max + (@data_to_plot.y_max*0.05).abs,3)\n\n if @data_to_plot.is_subtracted && @data_to_plot.xy_min > 0\n @data_to_plot.xy_min = 0\n end\n end\n end\n\n rescue StandardError => e\n puts \"RESCUING #{e}\"\n @data_set.errors.add(:base, e)\n end\n\n # ActiveStorage::Blob.service.send(:path_for, @data_set.files.find_by(:id => params[:file_id]))\n respond_to do |format|\n if @data_set.errors.any?\n format.html { redirect_to :add_datafile, :id => permitted[:data_set_id]}\n else\n # format.html { render :view_data_file }\n format.js\n end\n end\n\n end", "def validate_file\n if (original_filename.nil?)\n self.errors.add(I18n.t('dias.views.paper.labels.pdffil'), I18n.t('dias.models.paper.validate.file'))\n elsif (mime_type != \"application/pdf\")\n self.errors.add(I18n.t('dias.views.paper.labels.pdffil'), I18n.t('dias.models.paper.validate.pdffile'))\n end\n end", "def plot_visible_only=(v) Axlsx.validate_boolean(v); @plot_visible_only = v; end", "def update(uploaded_file)\n super\n record.save_changes(validate: false)\n end", "def plot_params\n params.require(:plot).permit(:plot,:first_name, :middle_name, :last_name, :rank, :birth_date, \n :death_date, :birth_location, :death_location, :cemetery_id, :created_by_id, :approved, \n :unit, :description, :spouse, :mother, :father, :find_a_grave, :scv_id, :fold_3_url, :rank, \n :enlistment_date,:service_end_date,:release_from_service,:ancestry_com_url,:disposition)\n end", "def show_uploaded_schema\n initalize_breadcrumb(\"Uploaded File(s)\", uploadedfile_datauploaders_path)\n @table_name = params[:table_name]\n @uploaded_schema = DataUploader.get_uploaded_schema(@table_name)\n if @uploaded_schema.size > 0 then\n table_column_information = get_user_table_column_info(@table_name)\n @disabled_column = []\n table_column_information.each do |column_info| \n if column_info[:is_disable] == true then\n @disabled_column.append(column_info[:column_name])\n end\n\n if column_info[:money_format] != '' then\n @uploaded_schema.each do |schema|\n if schema[:Field] == column_info[:column_name] then\n schema[:money_symbol] = column_info[:money_format]\n break\n end \n end\n elsif column_info[:percentage_format] == true then\n @uploaded_schema.each do |schema|\n if schema[:Field] == column_info[:column_name] then\n schema[:is_percentage] = column_info[:percentage_format]\n break\n end\n end\n end\n end\n\n check_record_uploaded = UserFileMapping.where(:table_name => @table_name).first\n @is_record_uploaded = false\n if check_record_uploaded then\n @is_record_uploaded = check_record_uploaded.is_record_uploaded\n end\n puts @uploaded_schema\n initalize_breadcrumb(\"Uploaded File Schema\", showuploadedschema_datauploaders_path({:table_name => @table_name}))\n else\n redirect_to uploadedfile_datauploaders_path, :flash => { :error => \"Table schema not exists\" }\n end\n end", "def validate\n validate_params\n validate_coordinates\n validate_colour\n validate_dimension\n end", "def upload_file_columns_for_record\n @table_columns = {columns: []}\n table_name = params[:table_name] \n uploaded_schema = DataUploader.get_uploaded_schema(table_name)\n if uploaded_schema.size > 0\n disabled_column = get_user_table_column_info(table_name)\n uploaded_schema.each do |schema|\n if !((disabled_column.collect{|val| (val[:is_disable] == true ? val[:column_name] : '') }).include?schema[:Field]) then \n @table_columns[:columns].append({title: schema[:Field], data: schema[:Field]})\n end\n end \n respond_to do |format| \n format.html \n format.js \n format.json { render :json => @table_columns}\n end\n else\n redirect_to uploadedfile_datauploaders_path, :flash => { :error => \"Table schema does not exists\" }\n end\n end", "def validate\n validate_params\n validate_colour\n validate_coordinates\n validate_dimension\n end", "def valid_attributes\n { :import_date => '2011-10-01', :input_file=>Rack::Test::UploadedFile.new('test/fixtures/csv/2XU.txt', 'text/csv') }\n end", "def after_render_field(record, column); end", "def file_name_plot_to_plot(record,row)\n #rintraccio il file\n file = ImportFile.find(session[:file_id])\n #numero del plot\n plot_number = /\\d+\\D+(\\d+)[.]\\S*/\n #confronto\n file.file_name =~ plot_number\n #estrapolo il numero del plot\n file_plot = $1\n file_plot = file_plot.to_i\n #se il plot indicato nel nome del file non è uguale a quello contenuto all'interno\n unless file_plot == record.cod_plot\n #salvo l'errore\n save_error(record,\"File name - Plot\",row)\n #segnalo che c'è stato un errore sulla riga\n session[:row_error] = true\n #e segnalo l'errore sul file\n session[:file_error] = true\n end\n end", "def file_field; end", "def upload_params\n params.require(:upload).permit(:input_file, columns_attributes: [:id, :meaning])\n end", "def should_validate?(_filename)\n raise NotImplementedError\n end", "def external_reference_check(record,row)\n #riferimenti al plot\n plot = Plot.find(:first, :conditions => [\"numero_plot = ? AND deleted = false\", record.cod_plot])\n #se il plot non esiste\n if plot.blank?\n save_error(record,\"Riferimento al Plot\",row)\n #segnalo che c'è stato un errore sulla riga\n session[:row_error] = true\n #e segnalo l'errore sul file\n session[:file_error] = true\n end\n end", "def validate_columns\n columns.each do |name|\n if !column_available?(name)\n errors.add column_label_for(name), :inclusion\n end\n end if columns.present?\n end", "def validate\n super\n rescue Sudoku::Constraint::ConstraintError => e\n raise ConstraintError, e.message + \" in a column\"\n end", "def validate_file_is_included\n if workflow_file.nil? && @file_data.nil?\n errors.add :workflow_file,\n \" missing, please select a file and try again\"\n end\n end", "def before_csv_render\n before_render\n end", "def _before_validation\n end", "def perform_file_validation(_filename, _filehandle)\n raise NotImplementedError\n end", "def column_params\n params.require(:column).permit(:name, :title, :position)\n end", "def initialize(params = {})\r\n @uploaded_file = params[:roster]\r\n @column_hash = params[:columns] || {}\r\n @has_headers = params[:has_headers]\r\n @course_role_id = params[:course_role_id]\r\n @course_offering = CourseOffering.find_by_id(params[:id])\r\n\r\n @users_created = []\r\n @users_enrolled = []\r\n\r\n @preview_rows = []\r\n @column_array = []\r\n\r\n process_csv if @uploaded_file\r\n end", "def column_params\n params.require(:column).permit(:label, :value, :id, :created_at, :updated_at)\n end", "def check_fields\n columns= resource.model.column_names - AutoRest::AR_MAGIC_COLUMNS\n\n default_columns= columns.select { |attr| attr !~ /.*_count$/ }.map do |elem|\n [elem.intern, elem.titleize]\n end\n\n # For storing columns, I use an array and not a hash --i.e.: (:column => 'Title') -- \n # to ensure the order of the columns. I convert the params from linear array to \n # grouped array to alivianate user's data entry:\n # [[:col0, \"name0\"], [:col1, \"name1\"]] becomes [:col0, \"name0\", :col1, \"name1\"]\n \n # *TODO* This should be cleaned a little, because right now is a bit difficult\n # to remember the way the attributes for each view work.\n\n [:for_index, :for_new, :for_edit, :for_show].each do |key|\n arr= fields.send(key)\n exc= exclude_fields.send(key)\n\n if !arr # User has not supplied columns.\n arr= default_columns\n else\n # enum_for creates an enum from array, therefore protecting the original array contents.\n # each slice returns an array of specified elements: [1,2,3,4] => 1..4 => [[1,2],[3,4]]\n arr= arr.enum_for(:each_slice, 2).to_a\n end\n \n # Remove excluded fields.\n arr= arr.reject { |e| exc.map{|elem|elem.to_s}.include?(e[0].to_s) } if exc\n fields.send(\"#{key}=\", arr)\n end\n end", "def validate_slug_columns\n raise ArgumentError, \"Source column '#{self.slug_source}' does not exist!\" if !self.respond_to?(self.slug_source)\n raise ArgumentError, \"Slug column '#{self.slug_column}' does not exist!\" if !self.respond_to?(\"#{self.slug_column}=\")\n end", "def scatter_plot\n validate(\n x_axis: [:optional, :security_default],\n y_axis: [:optional, :security_default],\n x_axis_type: [:optional, :security_default],\n y_axis_type: [:optional, :security_default],\n x_axis_notation: [:optional, :security_default],\n y_axis_notation: [:optional, :security_default],\n container_id: [:optional, :security_default]\n )\n if params[:x_axis].blank? or params[:y_axis].blank?\n render inline: \"\"\n else\n @chart = ScatterPlotChart.new(\n @experiment,\n params[:x_axis].to_s,\n params[:y_axis].to_s,\n params[:type_of_x],\n params[:type_of_y],\n x_axis_type: params[:x_axis_type].to_s,\n y_axis_type: params[:y_axis_type].to_s,\n x_axis_notation: params[:x_axis_notation].to_s,\n y_axis_notation: params[:y_axis_notation].to_s\n )\n Rails.logger.debug(\"ScatterPlotChart --- x axis: #{@chart.x_axis}, y axis: #{@chart.y_axis}\")\n @chart.prepare_chart_data\n @uuid = SecureRandom.uuid\n @container_id = params[:container_id] || \"bivariate_chart_#{@uuid}\"\n end\n end", "def external_file_attributes; end", "def set_the_field_values\n fn = self.file_name\n unless self.file_ext && !self.file_ext.blank?\n self.file_ext = fn.split('.').last\n end\n ex = self.file_ext\n nm = self.name\n \n pic_name = fn.split('.')\n pic_name.delete(pic_name.last)\n \n pn = pic_name.join('_').to_s.to_go\n \n the_name = ( nm.blank? || nm.start_with?('dcfile_') ) ? pn.titleize : nm.to_s\n the_fname = !nm.blank? ? nm.to_s.to_go : pn\n \n self.name = the_name\n self.original_name = fn\n # => self.file_name = \"#{the_fname}.#{ex}\"\n self.file_name = \"#{ generate_dc_name }.#{ex}\"\n self.image = IMAGE_EXTS.include?( ex.to_s.downcase ) ? true : false\n self.save\n end", "def column_params\n params.require(:column).permit(:name)\n end", "def validate_attributes\n if male_index_changed? && !for_male?\n self.remove_male_icon! if self.male_icon\n self.remove_male_camera_background! if self.male_camera_background\n end\n if female_index_changed? && !for_female?\n self.remove_female_icon! if self.female_icon\n self.remove_female_camera_background! if self.female_camera_background\n end\n self.male_icon_background_color = '#' + male_icon_background_color if male_icon_background_color.present? && !male_icon_background_color.starts_with?('#')\n self.female_icon_background_color = '#' + female_icon_background_color if female_icon_background_color.present? && !female_icon_background_color.starts_with?('#')\n end", "def file_field(method, **kwargs)\n without_field_error_wrapper do\n with_blueprint_file_input method, kwargs do |options|\n super(method, options)\n end\n end\n end", "def before_validation\n\t\tself.class.columns.each do |c|\n\t\t\tif self[c.name] and [:string, :text].include?(c.class)\n\t\t\t\tself[c.name] = RailsSanitize.full_sanitizer.sanitize(self[c.name]) \n\t\t\tend\n\t\tend\t\t\n\tend", "def set_convention\n @convention = Convention.find(params[:id])\n\t @convention.plots.reject!{|x| x == \"\"}\n end", "def valid_attributes\n {\n :name => \"my dashboard\",\n :data => 'new data',\n :scale => false,\n :is_public => false\n }\n end", "def validate_file_input\n if params[:input_data].present?\n check_format(params[:input_data])\n else\n\t\t\traise_error NO_FILE_PROVIDED\n\t\tend\n end", "def validate\n return unless no_file_selected? || invalid_extname? || filesize_too_big?\n\n raise CsvUploadFailureException, error\n end", "def pre_validation\n\n end", "def importer_parameters_format\n errors.add(:importer_parameters, \"title_columns can't be blank\") unless title_columns\n errors.add(:importer_parameters, \"geo_columns can't be blank\") unless geo_columns\n\n unless valid_article_usage?\n errors.add(:importer_parameters, 'cannot use article without parse_article')\n end\n end", "def validate\n super \n end", "def attr_csv(*attributes)\n define_attribute_methods rescue nil\n super\n attributes.reject { | attr | attr.is_a?(Hash) }.each { | attr | alias_method \"#{attr}_before_type_cast\", attr }\n\n # Register before_validate to update the csv fields\n before_validation :update_csved_attributes\n end", "def column_params\n params.require(:column).permit(:name, :ident)\n end", "def update(uploaded_file)\n super\n record.save(raise_on_failure: true)\n end", "def fdn_legend_params\n params.require(:fdn_legend).permit! if params[:fdn_legend]\n # params.require(:fdn_legend).permit(:org_id, :type_code, :title, :content, :file_resources_attributes => [:filename, :ffx,:display_name,:],:file_attributes => [:filename, :ffx,:display_name])\n end", "def plot_params\n params.require(:plot).permit(:title, :content)\n end", "def after_columns_created\n end", "def pre_validation\n\n\n end", "def verify\n\n\t\t# Uploaded data is located in the POST :file param\n\t\t@file_data = params[:file]\n\n\t\t# Check that we are able to read the data\n \t\tif @file_data.respond_to?(:read)\n\n \t\t\t# Create an array to store CSV rows\n \t\t\trows = Array.new\n \t\t\t\n \t\t\t# Parse apart our CSV file and read the rows into our array\n \t\t\tCSV.parse(@file_data.read) do |csv_obj|\n \t\t\t\trows.push(csv_obj)\n \t\t\tend\n\n \t\t\t# We assume that attributes are in the header of the CSV\n \t\t\t# TODO: Ask user whether these are actually the attributes\n \t\t\tparsed_attributes = rows[0]\n\n \t\t\t# Remove the row so we don't accidentally process it\n \t\t\trows.delete_at(0)\n\n \t\t\t# Create a new Hash object of attributes\n \t\t\t@attributes = Hash.new\n \t\t\tparsed_attributes.each do |attribute|\n \t\t\t\tattribute_underscore = attribute.split.join('')\n \t\t\t\t@attributes[attribute_underscore] = \"String\"\n \t\t\tend\n\n\t\t\t# Now create a representation of the model we want\n\t\t\t@dataset = Dataset.new\n\t\t\[email protected] = params[:name]\n\t\t\[email protected] = @attributes.to_json\n\t\t\[email protected]_url = SecureRandom.hex(10)\n\t\t\t# If base_url collides, find a new random hex values\n\t\t\twhile Dataset.where(:base_url => @dataset.base_url).exists? do\n\t\t\t\[email protected]_url = SecureRandom.hex(10)\n\t\t\tend\n\n \t\t\t# Generate all the hashes\n \t\t\t@hashes = Array.new\n \t\t\trows.each do |row|\n\n \t\t\t\t# Parse into hashes\n \t\t\t\th = Hash.new\n \t\t\t\[email protected]_with_index do |(attribute, type), index|\n \t\t\t\t\th[attribute] = row[index]\n \t\t\t\tend\n\n \t\t\t\t# Put it into our dataset\n \t\t\t\[email protected](h)\n \t\t\t\t\n \t\t\tend\n\n \t\t\t# Create a JSON object from the hash\n \t\t\t@sample = @hashes[0].to_json\n\n \t\t\t# From the sample, figure out the proper types\n \t\t\tattributes_copy = @attributes.clone\n \t\t\[email protected] do |attribute, type|\n \t\t\t\tif is_numeric?(@hashes[0][attribute])\n \t\t\t\t\tattributes_copy.delete(attribute)\n \t\t\t\t\tattributes_copy[attribute] = 'Numeric'\n \t\t\t\tend\n \t\t\tend\n \t\t\t@attributes = attributes_copy\n\n \t\t\t# We temporarily keep things in the cache to pass to the upload method\n \t\t\tRails.cache.write(\"dataset\", @dataset)\n \t\t\tRails.cache.write(\"attributes\", @attributes)\n \t\t\tRails.cache.write(\"hashes\", @hashes)\n\n \t\t\t# Return the dataset object\n \t\t\trender json: @attributes\n\n \t\tend\n\n\tend", "def validateRequiredFiles()\n @sampleSheet = @baseCallsDir + \"/SampleSheet.csv\" \n\n if !File.exist?(@sampleSheet)\n raise \"Missing SampleSheet.csv in directory: \" + @baseCallsDir\n end\n end", "def validateRequiredFiles()\n @sampleSheet = @baseCallsDir + \"/SampleSheet.csv\" \n\n if !File.exist?(@sampleSheet)\n raise \"Missing SampleSheet.csv in directory: \" + @baseCallsDir\n end\n end", "def plot_params\n params.require(:plot).permit(:farmer_id, :areaRai, :treeCount, :breed, :project, :certificate, :certificateDate, :harvestPeriod, :harvestQuantity, :price, :plotManagement, :fertilizeManagement, :waterManagement, :illnessManagement, :harvestManagement, :sellingChannel, :logistic, :addressNo, :addressMoo, :addressTambon, :addressAmphoe, :addressProvince, :addressZipcode, :lat, :long, :picture, :polygon)\n end", "def after_save\n df = DataFile.find_by_id(self.orig_data_file_id)\n unless df.blank?\n df.annotations.each do |a|\n a.annotatable = self\n #need to call update without callbacks, otherwise a new version is created\n a.send(:update_without_callbacks)\n\n #versions for annotations are no longer enabled in SEEK - but this code is left here incase they are re-enabled in the future.\n a.versions.each do |av|\n av.annotatable =self\n av.save\n end\n end\n end\n super\n end", "def validate_avatar\n if self.avatar.queued_for_write[:original]\n # self.errors.add(:change_pass)\n dimensions = Paperclip::Geometry.from_file(self.avatar.queued_for_write[:original])\n self.errors.add(:avatar, \"should at least 320px\") if dimensions.width > 320\n end\n end", "def initialize(filepath, current_user, relation)\n\n # Open the new file & get the attributes row from it\n @relation = relation\n @import_file = Roo::Spreadsheet.open(filepath, extension: :xlsx)\n @excel_attributes_raw = @import_file.sheet(0).row(1)\n @excel_attributes = @excel_attributes_raw.map{ |el| el.downcase.gsub(\" \", \"_\") }\n\n # validate attributes row\n @invalid_rows = false\n @valid_attributes_from_db = getAllValidAttributes\n @mandatory_attributes_from_db = getAllMandatoryAttributes(current_user)\n \n # get valid and invalid attributes based on name\n getValidAndInvalidAttributes\n\n # valid attributes found and all mandatory attributes are there\n if checkAttributeRequirements\n # get valid listings from excel\n getValidListingsFromExcel\n\n # handle title and shipment to countries\n handleTitle\n handleCountries\n handleUSPs\n\n # check if there exists a value for mandatory attributes\n checkListingAttributeRequirements\n\n # handle listings which have to be updated\n listingsToUpdate current_user\n end\n end", "def before_validation_callback\n end", "def validation; end", "def validation; end", "def create\n @upload = Upload.create(upload_params)\n @upload.update(rows_in_input_file: @upload.calculate_all_rows)\n @upload.update(columns_attributes: @upload.headers_from_input_file.map { |h| { name: h } })\n if @upload.save && @upload.valid?\n redirect_to pick_columns_upload_url(@upload), notice: 'Please select street name and number columns for geocoding'\n else\n render :new\n end\n end", "def plot_params\n params.require(:plot).permit( :name, :desc )\n end", "def column_transform_params\n params.require(:column_transform).permit(:internal, :external)\n end", "def columns_ignored *args\n if args.size > 0 && configurable?\n raise 'please call %s only inside #model block' % __method__ if model_defined?\n @columns_ignored = args\n end\n end", "def validate_csv_format\n\tfile = params[:file]\n\theaders = CSV.open(file.path, 'r') { |csv| csv.first }\n\tunless (EXPECTED_HEADER - headers).empty?\n\t\tremoved_columns = EXPECTED_HEADER - headers\n\t\tadded_columns = headers - EXPECTED_HEADER\n\t\tresponse = {msg: \"You have added or removed columns\"}\n\t\t# response = {msg: \"You have removed some columns\"}\n\t\tresponse[:added_column] = added_columns unless added_columns.nil?\n\t\t# response[:removed_columns] = removed_columns unless removed_columns.nil?\n\t\tresponse[:removed_columns] = removed_columns\n\t\trender json: response.to_json, status: \"422\"\n\tend\nend", "def mount_uploader(column, uploader, options={}, &block)\n options[:mount_on] ||= \"#{column}_filename\"\n key options[:mount_on]\n\n super\n\n alias_method :read_uploader, :read_attribute\n alias_method :write_uploader, :write_attribute\n\n include CarrierWave::Validations::ActiveModel\n\n validates_integrity_of column if uploader_option(column.to_sym, :validate_integrity)\n validates_processing_of column if uploader_option(column.to_sym, :validate_processing)\n\n after_save \"store_#{column}!\".to_sym\n before_save \"write_#{column}_identifier\".to_sym\n after_destroy \"remove_#{column}!\".to_sym\n end", "def on_data_changed\n # Default column settings taken from\n defaults_hash = config[:owner].class.meta_columns.inject({}){ |r, c| r.merge!(c[:name] => c[:default_value]) }\n stripped_columns = data_class.all_columns.map do |c|\n # reject all keys that are 1) same as defaults\n c.reject{ |k,v| defaults_hash[k.to_sym].to_s == v.to_s }\n end\n store_data(stripped_columns)\n end", "def whitelist\n @columns = []\n end", "def validate params\n validate_params(params)\n validate_dimension\n end", "def base_validate_parameters\n check_for_valid_filepath if (@repository.parameters[:file])\n validate_parameters\n nil\n end", "def validate_data!(filename)\n unless self.data.is_a?(Hash)\n raise Errors::InvalidYAMLFrontMatterError,\n \"Invalid YAML front matter in #{filename}\"\n end\n end", "def upload_data_file\n\n @data_set = DataSet.find_by(:id => params[:id])\n permitted = params.require(:data_set).permit(reciprocal_space_file: [:sas_type, :file])\n\n if permitted.permitted?\n @rcp = @data_set.reciprocal_space_files.create(permitted[:reciprocal_space_file])\n #@rcp = ReciprocalSpaceFile.new(data_set_id: @data_set.id, file: permitted[:reciprocal_space_file][:file], sas_type: permitted[:reciprocal_space_file][:sas_type])\n\n unless @rcp.errors.any?\n # grab JSON string from file if present\n @rcp.json = SasCif.new(:file => @rcp.file).get_json\n #@data_set.reciprocal_space_files << @rcp\n end\n end\n #\n # must validate file before saving\n # file has to be either dat file (3 columns) or formatted *.sec or zip file of data\n #\n puts @data_set.errors.inspect\n\n respond_to do |format|\n if @data_set.save\n @rcp = @data_set.reciprocal_space_files.last\n #format.html { redirect_to edit_data_set_path, :id => add_datafile_path(:id => @data_set.id) }\n format.js\n else\n puts @data_set.errors.inspect\n format.html { render 'add_or_edit_data_set', notice: \"Error in Uploaded File\" }\n format.js { render 'errors'}\n end\n end\n\n end", "def validate_partition_fields(partition_fields, attribute_names)\n partition_fields.select do |partition_field|\n unless attribute_names.insert(-1, 'convergdb_batch_id').include?(partition_field)\n raise \"partition field #{partition_field} undefined in relation #{@name}\"\n end\n end\n nil\n end", "def internal_file_attributes; end", "def report_missing_required_value\n super(filename: filename, xpath: xpath)\n end", "def _before_validation\n serialize_deserialized_values\n super\n end", "def validate_dimension\n fail ValidationError.new('accepted range is between 1 and 250') unless [@x_axis, @y_axis].all? {|num| num > 0 && num <= 250 }\n end", "def initialize(g, f, ed)\n @grid = g\n @extra_dim = ed\n @field_name = f\n raise \"Field #{field_name} is not found in grid #{grid.grid_name} of file #{grid.file.file_name}\" unless\n grid.field_list.include?(field_name)\n ds = grid.field_dim_size(field_name)\n raise \"Extra dimensions passed to constructor of field #{field_name} must match size of extra dimensions\" unless(ds.size ==@extra_dim.size)\n (0...(@extra_dim.size)).each do |i|\n raise \"Extra dimension out of range for field #{field_name}\" unless\n (@extra_dim[i] >= 0 && @extra_dim[i] < ds[i])\n end\n end", "def attachment=(params)\n super params\n import_attachment if persisted? && attachment.try(:valid?)\n end", "def validate_file(file)\n end", "def plot_point_params\n params.require(:plot_point).permit(:name, :book_id, :body)\n end", "def visualization_params\n params.require(:visualization).permit(:enabled, :name, :slug, :markup_type, :markup, :component, :data_point_name)\n end", "def geometry_columns!; end", "def chart_params\n params.require(:chart).permit(:patient_id, :doctor_id, :pages, :chart, :filename)\n end", "def validate_on_save(fields)\n end", "def data_import_params\n params.require(:data_import).permit(:employee_file, :qualification_file, :training_file, :created_by_id)\n end", "def required_csv_fields\n [:email, :name]\n end", "def beanplot\n end", "def visualization_params\n params.require(:visualization).permit(:name, :chart_type, :x_choice, :y_choice, :dataset_id)\n end", "def grid_modified!\n end", "def validate\n super\n end", "def validate_column_mappings(line)\n unmapped = []\n line.each_key do |key|\n next if column_names.include? key\n unmapped << key\n end\n raise NdrImport::UnmappedDataError, unmapped if unmapped.any?\n end", "def validate_input(data)\r\n @field_names[1..-1].each do |f|\r\n next if data[f].nil?\r\n\r\n raise 'Invalid data %s for column %s' % [data[f], f] unless \\\r\n KBTable.valid_data_type?(@field_types[@field_names.index(f)],\r\n data[f])\r\n end\r\n end", "def validation\n self.country ||= province.country\n unless !@x || !@y || @x == \"\" || @y == \"\"\n self.geom = Point.from_x_y(@x.to_f, @y.to_f)\n end\n end", "def excel_params\n params.require(:excel).permit(:name, :avatar)\n end", "def importDataSource(file, *sync_column)\n\n\nend", "def adt_params\n params.require(:adt).permit([\n :name,\n :x_colname,\n :y_colname,\n :sheetname,\n :y_legend,\n :color_y\n ])\n \n end", "def column_image_params\n params.require(:column_image).permit(:titolo, :descrizione, :collegamento, :column_id, :immagine)\n end", "def apply_validations_for_float\n flex_column_class.validates field_name, :numericality => true, :allow_nil => true\n end", "def identity_file_is_blank\n \t errors.add :base, l(:\"file.error.validation_indentity_file_blank\") if self.identity_file.blank?\n end", "def validate\n @has_validated = true\n\n unless File.exist?(@commits_path)\n @errors.push(\"#{File.basename(@commits_path)}: does not exist\")\n end\n\n unless File.exist?(@data_path)\n @errors.push(\"#{File.basename(@data_path)}: does not exist\")\n end\n\n # Stop as further validations need to read the files.\n return if @errors.any?\n\n begin\n data_file.peek\n rescue StopIteration\n @errors.push(\"#{File.basename(@data_path)}: has no data to import\")\n return\n end\n\n DataValidator.call(self).each do |error|\n @errors.push(\"#{File.basename(@data_path)}: #{error}\")\n end\n\n CommitsValidator.call(self).each do |error|\n @errors.push(\"#{File.basename(@commits_path)}: #{error}\")\n end\n\n nil\n end" ]
[ "0.5602226", "0.5497967", "0.5492223", "0.53162205", "0.52915907", "0.5283613", "0.52708554", "0.5261385", "0.5251319", "0.5243778", "0.5167704", "0.51356894", "0.51299155", "0.5113238", "0.5108351", "0.5106229", "0.50818", "0.5064727", "0.5034494", "0.50328237", "0.5017601", "0.50141126", "0.5009542", "0.49667478", "0.49548846", "0.49539113", "0.49485818", "0.4943499", "0.4942975", "0.49367166", "0.49237245", "0.49228543", "0.49193314", "0.49090385", "0.48970062", "0.48864678", "0.4874948", "0.48706818", "0.48605466", "0.48548657", "0.48505342", "0.48495257", "0.48334536", "0.48326266", "0.48310137", "0.48308647", "0.48307368", "0.48306292", "0.48285204", "0.48259056", "0.48154613", "0.48154613", "0.48064882", "0.48019412", "0.4797445", "0.47966754", "0.47809035", "0.47709003", "0.47709003", "0.47668773", "0.47658888", "0.47633988", "0.47576854", "0.47563934", "0.47560206", "0.47502148", "0.47457713", "0.47443715", "0.47392535", "0.4738285", "0.47350332", "0.47212368", "0.47163445", "0.47158062", "0.47151467", "0.4713811", "0.47105905", "0.47057533", "0.47054073", "0.47014603", "0.46900564", "0.46751064", "0.46563786", "0.46552393", "0.46491048", "0.46459308", "0.46456066", "0.4642223", "0.46400568", "0.46396932", "0.46390003", "0.46388066", "0.4637627", "0.46375367", "0.46356487", "0.46350512", "0.46306682", "0.46300957", "0.46290275", "0.4625174" ]
0.474144
68
file should already be validated during upload, no need to double check
def read_contents #puts "pofr file #{@file_blob.filename}" file_lines=[] @file_blob.open do |file| File.open(file){|x| file_lines = x.readlines} puts file_lines[0] puts file_lines.last end if @file_blob.filename.extension == "out" # GNOM getDataLinesFromGnom(file_lines) elsif @file_blob.filename.extension == "dat" # scatter puts "reading file @file #{@file_blob.filename}" getDataLinesFromScatter(file_lines) end @dmax = @r_values.last @pr_values.each do |y| @pr_max = (y[1] > @pr_max) ? y[1] : @pr_max @pr_min = (y[1] < @pr_min) ? y[1] : @pr_min end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_file(file)\n end", "def check_file\n super\n end", "def validate_file(filename)\n return true\nend", "def valid_file\n\n filename = self.file.original_filename\n content_type = self.file.content_type\n\n #The upload should be nonempty.\n if filename == nil\n errors.add_to_base(\"Please enter an image filename\")\n return false\n end\n\n #The upload should have file suffix\n unless filename =~ /\\.(jpg)|(jpeg)|(png)|(gif)$/i\n errors.add_to_base(\"Please use image file with a filename suffix\")\n return false\n end\n\n #The file should be an image file.\n unless content_type =~ /^image/\n errors.add(:content_type, \"is not a recognized format\")\n return false\n end\n return true\n end", "def valid_file\n\n filename = self.file.original_filename\n content_type = self.file.content_type\n\n #The upload should be nonempty.\n if filename == nil\n errors.add(:base, \"Please enter an image filename\")\n return false\n end\n\n #The upload should have file suffix.\n unless filename =~ /\\.(jpg)|(jpeg)|(png)|(gif)$/i\n errors.add(:base, \"Please use image file with a filename suffix\")\n return false\n end\n\n #The file should be an image file.\n unless content_type =~ /^image/\n errors.add(:content_type, \"is not a recognized format\")\n return false\n end\n return true\n end", "def should_validate?(_filename)\n raise NotImplementedError\n end", "def perform_file_validation(_filename, _filehandle)\n raise NotImplementedError\n end", "def validate\n return unless no_file_selected? || invalid_extname? || filesize_too_big?\n\n raise CsvUploadFailureException, error\n end", "def validate_upload\n validate_image_length\n validate_image_type\n validate_image_md5sum\n validate_image_name\n end", "def validate_files\n expected_user_id = user.id\n uploaded_files.each do |file|\n if file.user_id != expected_user_id\n Rails.logger.error \"User #{user.user_key} attempted to ingest uploaded_file #{file.id}, but it belongs to a different user\"\n return false\n end\n end\n true\n end", "def validate_file\n if (original_filename.nil?)\n self.errors.add(I18n.t('dias.views.paper.labels.pdffil'), I18n.t('dias.models.paper.validate.file'))\n elsif (mime_type != \"application/pdf\")\n self.errors.add(I18n.t('dias.views.paper.labels.pdffil'), I18n.t('dias.models.paper.validate.pdffile'))\n end\n end", "def attached_file_valid?\n return false if file.nil?\n file_attacher.validate\n file_attacher.errors.each { |e|\n errors.add(:file, :invalid, message: e)\n }.empty?\n end", "def validate_file_input\n if params[:input_data].present?\n check_format(params[:input_data])\n else\n\t\t\traise_error NO_FILE_PROVIDED\n\t\tend\n end", "def ensure_upload_is_file\n return if params.require(:file).respond_to?(:tempfile)\n\n render(\n json: {\n errors: ['\"file\" was not a valid multipart/form-data file'],\n error_keys: [:not_multipart_form_data]\n },\n status: 422\n )\n end", "def ensure_upload_is_file\n return if params.require(:file).respond_to?(:tempfile)\n\n render(\n json: {\n errors: ['\"file\" was not a valid multipart/form-data file'],\n error_keys: [:not_multipart_form_data]\n },\n status: 422\n )\n end", "def validate_file(file_path)\n if file_path.respond_to? :read\n src = file_path.read\n else\n src = read_local_file(file_path)\n end \n # we force the :post mode otherwise it fails for\n # big files\n return validate_text(src, :post)\n end", "def validate_local_files\n expected_user_id = user.id\n uploaded_files.each do |file|\n if file.user_id != expected_user_id\n Rails.logger.error \"User #{user.user_key} attempted to ingest uploaded_file #{file.id}, but it belongs to a different user\"\n return false\n end\n end\n true\n end", "def attachment_with_upload_method\n if method == \"upload\" && !attachment?\n errors.add(:base, \"Please make sure to upload your prescription.\")\n end\n end", "def validate_files(files, env)\n expected_user_id = env.user.id\n files.each do |file|\n if file.user_id != expected_user_id\n Hyrax.logger.error \"User #{env.user.user_key} attempted to ingest uploaded_file #{file.id}, but it belongs to a different user\"\n return false\n end\n end\n true\n end", "def validate\n @files.each {|fn| check_file fn}\n end", "def accepts_file_upload?\n true\n end", "def accepts_file_upload?\n true\n end", "def accepts_file_upload?\n true\n end", "def accepts_file_upload?\n true\n end", "def accepts_file_upload?\n true\n end", "def accepts_file_upload?\n true\n end", "def validate_file_is_included\n if workflow_file.nil? && @file_data.nil?\n errors.add :workflow_file,\n \" missing, please select a file and try again\"\n end\n end", "def validate\n if filename.nil?\n errors.add_to_base(\"You must choose a file to upload\")\n else\n # Images should only be GIF, JPEG, or PNG\n enum = attachment_options[:content_type]\n unless enum.nil? || enum.include?(send(:content_type))\n errors.add_to_base(\"You can only upload images (GIF, JPEG, or PNG)\")\n end\n # Images should be less than UPLOAD_LIMIT MB.\n enum = attachment_options[:size]\n unless enum.nil? || enum.include?(send(:size))\n msg = \"Images should be smaller than #{UPLOAD_LIMIT} MB\"\n errors.add_to_base(msg)\n end\n end\n end", "def valid_file?\n if @image.size.zero?\n errors.add_to_base(\"Please enter an image filename\")\n return false\n end\n unless @image.content_type =~ /^image/\n errors.add(:image, \"is not a recognized format\")\n return false\n end\n if @image.size > 1.megabyte\n errors.add(:image, \"can't be bigger than 1 megabyte\")\n return false\n end\n return true\n end", "def validate\n @errors = []\n methods.grep(/^validate_/).each { |m| method(m).call }\n @errors.each { |e| e.file = @file }\n valid?\n end", "def check_file_size\n valid?\n errors[:image_file_size].blank?\n end", "def validate_file_path\n base_path = ::File.realpath(self.class.temp_dir)\n @path = ::File.realpath(params.permit(:file)[:file], base_path)\n unless @path.start_with?(base_path)\n raise ViewComponent::SystemTestControllerNefariousPathError\n end\n end", "def validate\n if self.filename.nil?\n errors.add_to_base(\"You must choose an image to upload\")\n else\n [:size, :content_type].each do |attr_name|\n enum = attachment_options[attr_name]\n\n unless enum.nil? || enum.include?(send(attr_name))\n errors.add_to_base(\"Images should be smaller than #{MAX_SIZE_IN_MB} MB in size\") if attr_name == :size\n errors.add_to_base(\"Your image must be either a JPG, PNG or GIF\") if attr_name == :content_type\n end\n end\n end\n end", "def validate_avatar\n if self.avatar.queued_for_write[:original]\n # self.errors.add(:change_pass)\n dimensions = Paperclip::Geometry.from_file(self.avatar.queued_for_write[:original])\n self.errors.add(:avatar, \"should at least 320px\") if dimensions.width > 320\n end\n end", "def validate_upload?\n upload? || review? || published? || unpublished_changes?\n end", "def valid?\n return false if @file_id.nil?\n true\n end", "def validate_file_size(file)\n if file.content_type != 'application/pdf' && file.size > max_file_size_non_pdf\n raise CarrierWave::IntegrityError, I18n.t(:'errors.messages.max_size_error',\n max_size: '50MB')\n end\n end", "def validates_as_attachment\n validates_presence_of :size, :content_type, :filename\n validate :attachment_attributes_valid?\n end", "def check( _upload )\n @original = _upload\n path = File.join( @uploadDir, @original )\n res = UploadUtils.filename( path )\n @uploadPath = res['path']\n @ext = res['ext']\n @filename = res['filename']\n end", "def validate_image_type\n if save_to_temp_file\n # Override whatever user gave us with result of \"file --mime\".\n self.upload_type =\n MimeMagic.by_magic(File.open(upload_temp_file)).try(&:type)\n if upload_type&.start_with?(\"image\")\n result = true\n else\n file = upload_original_name.to_s\n file = \"?\" if file.blank?\n errors.add(:image,\n :validate_image_wrong_type.t(type: upload_type, file: file))\n result = false\n end\n end\n self.content_type = upload_type\n result\n end", "def validate_input_files\n file_validation = FileValidation.new(input_files)\n raise_error(file_validation.errors) unless file_validation.files_exist? \n raise_error(file_validation.errors) unless file_validation.files_are_ascii?\n true\n end", "def check_file_presence_on_update(params)\n if params[:financial_document][:file] == '{}' && params[:financial_document][:remove_file] == '1'\n errors.add(:file, I18n.t('errors.messages.blank'))\n return false\n else\n return true\n end\n end", "def validate_create_file\n folder_id = params[:folder_id].presence\n @folder =\n begin\n folder_id && Folder.find(folder_id)\n rescue ActiveRecord::RecordNotFound\n raise_api_error \"The folder doesn't exist.\"\n end\n\n if @folder && [email protected]_by?(@context)\n raise_api_error \"You don't have permissions to add files to the folder.\"\n end\n\n raise_api_error \"You're not allowed to create a file in an HTTPS folder.\" if @folder&.https?\n\n file_name = params[:name].presence\n if file_name.blank? || !file_name.is_a?(String)\n raise_api_error \"File name needs to be a non-empty String\"\n end\n\n description = params[:description].presence\n if description && !description.is_a?(String)\n raise_api_error \"File description needs to be a String\"\n end\n\n @scope = if ActiveModel::Type::Boolean.new.cast(params[:public_scope])\n Scopes::SCOPE_PUBLIC\n else\n params[:scope].presence || Scopes::SCOPE_PRIVATE\n end\n\n unless [Scopes::SCOPE_PUBLIC, Scopes::SCOPE_PRIVATE].include?(@scope) ||\n Space.valid_scope?(@scope)\n raise_api_error \"Scope is invalid\"\n end\n\n if Space.valid_scope?(@scope) && !Space.from_scope(@scope).editable_by?(current_user)\n raise_api_error \"You don't have permissions to add files to the space.\"\n end\n\n return if @folder.nil? || @folder.scope == @scope\n\n raise_api_error \"The folder doesn't belong to a scope #{@scope}.\"\n end", "def validate_file_status(filename)\n raise IconGenerator::Error unless File.exists? filename\n end", "def file_chk( path )\n if File.exist?( path ) == false\n raise JackRDF_Critical, \"#{path} is not a valid file\"\n end\n end", "def verify_file_type\n if file_name\n allowed_types = %w(jpeg jpg png gif)\n\n unless allowed_types.include? file_name.split('.')[1]\n errors.add(:file_name, 'File is not an image.')\n end\n end\n end", "def save\n valid_file? and successful_conversion?\n end", "def require_file_current_uploads\n the_type = @resource.upload_type\n return if %i[files unknown].include?(the_type)\n\n render json: { error:\n 'You may not submit a file by direct upload in the same version when you have submitted files by URL' }.to_json, status: 409\n end", "def check_file_size\n if document && document.file && document.file.size.to_f > self.class::UPLOAD_LIMIT\n errors.add(:document, \"You cannot upload a document greater than #{Filesize.from(self.class::UPLOAD_LIMIT.to_s+ \" b\").pretty}\")\n end\n end", "def on_validating_entry(state, event, *event_args)\n super\n\n __debug_sim('The uploaded file is received in the Shrine cache.')\n\n # Verify validity of the uploaded file. # TODO: simulation - remove\n if simulating\n # From UploadController#upload:\n # stat, hdrs, body = FileUploader.upload_response(:cache, request.env)\n __debug_sim('CODE') do\n args = ':cache, request.env'\n \"FileUploader.upload_response(#{args})\"\n end\n __debug_sim(\"[invalid_file: #{submission.invalid_file}]\")\n submission.file_valid = !submission.invalid_file\n if submission.file_valid\n self.succeeded << submission.id\n else\n self.failures << 'invalid file'\n end\n end\n\n # Verify validity of the uploaded file.\n unless simulating\n wf_upload_file(*event_args)\n end\n\n valid = ready?\n\n # TODO: simulation - remove\n if valid\n __debug_sim('The remediated file was determined to be VALID.')\n __debug_sim('The form is populated with extracted metadata.')\n __debug_sim('USER continues to fill form until submit is enabled.')\n __debug_sim('USER must `cancel!` or `submit!` to advance...')\n else\n __debug_sim('The remediated file was determined to be INVALID.')\n __debug_sim('System generates a form error message to be displayed.')\n end\n\n # If the file is valid then the submission remains in this state until\n # the user completes and submits the form, or cancels the submission.\n reject! unless valid # NOTE: => :creating\n\n self\n end", "def validate_file(file)\n if file.respond_to? :read\n src = file.read\n else\n src = read_local_file(file)\n end \n\n return validate_text(src)\n end", "def file?\n self.file.file?\n end", "def verify_image(path)\n end", "def validate_job_seeker_photo\r\n if not self.photo_file_name .blank?\r\n if not self.photo_content_type.match(/image|png|jpg|jpeg|gif/)\r\n errors.add(\"Photo\",\"Only image file allowed\")\r\n end\r\n end\r\n end", "def base_validate_parameters\n check_for_valid_filepath if (@repository.parameters[:file])\n validate_parameters\n nil\n end", "def file_valid?(file)\n mime = MIME::Types.type_for(file).first\n !mime.nil? && ACCEPTED_MIMES.include?(mime.content_type)\n end", "def validate_file_is_t2flow\n if !@file_data.nil? && !get_details_from_model\n errors.add :workflow_file,\n \" \\\"\" + @file_data.original_filename +\n \"\\\" is not a valid taverna workflow file (t2flow)\"\n end\n end", "def process_upload\n return if @upload_processed\n @file.file.process!\n @upload_processed = true\n end", "def validate_file(filename)\n unless File.file?(file_path(filename))\n session[:error] = \"#{filename.split(\"/\").last} does not exist.\"\n redirect \"/\"\n end\nend", "def update(uploaded_file)\n super\n record.save_changes(validate: false)\n end", "def check\n super\n uncommitted = Perforce.uncommitted_files\n fail \"Uncommitted files violate the First Principle Of Release!\\n#{uncommitted.join(\"\\n\")}\" unless uncommitted.empty?\n end", "def file_correct?(file_path)\n raise 'ERROR: Is your file path correct ?' unless File.exist?(file_path)\n end", "def validate_subscribers_file\n if @subscribers_file.blank? || (@subscribers_file.content_type != \"application/vnd.ms-excel\" && @subscribers_file.content_type != \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\")\n @error_message << \"Veuillez choisir un fichier Excel contenant une liste de numéros.<br />\"\n @error = true\n end\n end", "def valid_file\n @file.present? && @file.content_type == 'text/csv'\n end", "def clean_up_paperclip_errors\n errors.delete(:file) if errors[:file] == errors[:file_file_size]\n end", "def can_upload?\n false\n end", "def validate_and_build_special_images(fileParams,file)\n # if Asset2.is_valid_file?(file)\n @special_image = @special.special_images.build(fileParams)\n # end\n end", "def validate_filename(_item)\n nil\n end", "def check_new\n if File.exist?(@new_file_path)\n #TODO: error properly\n abort\n end\n end", "def validate_subscribers_file\n if @subscribers_file.blank? || (@subscribers_file.content_type != \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\")\n @error_message << \"Veuillez choisir un fichier Excel 2007 contenant une liste de numéros.<br />\"\n @error = true\n end\n end", "def validate_file(file_path)\n if file_path.respond_to? :read\n src = file_path.read\n else\n src = read_local_file(file_path)\n end\n return validate_text(src)\n end", "def validate_import_file(data)\n\t\tbegin\n\t\t\timport_filetype_detect(data)\n\t\trescue DBImportError\n\t\t\treturn false\n\t\tend\n\t\treturn true\n\tend", "def validate!\n logger.debug \"Starting validation for #{description}\"\n raise NotFound.new path unless File.exists? path\n logger.info \"Successfully validated #{description}\"\n self\n end", "def add_file(file)\n logger.info(\" ########### add file\")\n if (file.nil?)\n logger.error(\"file is nil\")\n self.original_filename = nil\n self.has_attached_file = false\n return false\n elsif (!check_file?(file))\n logger.error(\"error uploading file\")\n self.original_filename = nil\n self.has_attached_file = false\n\n return false\n else\n self.add_file_datastream(file, :label => file.original_filename, :mimeType => file.content_type, :dsid => 'content', :controlGroup => 'M')\n self.original_filename = file.original_filename\n self.mime_type = file.content_type\n self.has_attached_file = true\n end\n return true\n end", "def create\n if @file.present?\n @id = SecureRandom.urlsafe_base64\n FileUtils.mv @file.tempfile, temp_path\n true\n else\n errors.add(:file, 'is required')\n false\n end\n end", "def validate_file_id\n file = ProjectFile.find_by(id: project_file_id)\n if file.nil? \n errors.add(:project_file_id, \"must be a valid file\")\n end\n end", "def file?\n [email protected]?\n end", "def update(uploaded_file)\n super\n record.save(raise_on_failure: true)\n end", "def image_file_changed?\n raise 'please override image_file_changed?'\n end", "def kyc_images_validation\n return unless document_uploaded?\n %w[selfie_picture govt_id_picture id_picture].each do |file|\n file = send(file)\n return errors[:base] << I18n.t('wrong_img_format') unless ( file.content_type =~ /^image\\/(jpeg|pjpeg|gif|png|bmp)$/ ) || ( file.content_type.in?([\"application/pdf\"]) )\n end\n end", "def validate_image_name\n name = upload_original_name.to_s\n name = name.sub(/^[a-zA-Z]:/, \"\")\n name = name.sub(%r{^.*[/\\\\]}, \"\")\n # name = '(uploaded at %s)' % Time.now.web_time if name.empty?\n name = name.truncate(120)\n return unless name.present? && User.current &&\n User.current.keep_filenames != \"toss\"\n\n self.original_name = name\n end", "def file?\n original_filename.present?\n end", "def validate\n unless attachment.errors.empty?\n # uncomment this to get rid of the less-than-useful interrim messages\n # errors.clear \n errors.add :attachment, \"Paperclip returned errors for file '#{attachment_file_name}' - check ImageMagick installation or image source file.\"\n false\n end\n end", "def update_from_filename filename\n self.original_filename = filename\n self.valid?\n end", "def validate\n @has_validated = true\n\n unless File.exist?(@commits_path)\n @errors.push(\"#{File.basename(@commits_path)}: does not exist\")\n end\n\n unless File.exist?(@data_path)\n @errors.push(\"#{File.basename(@data_path)}: does not exist\")\n end\n\n # Stop as further validations need to read the files.\n return if @errors.any?\n\n begin\n data_file.peek\n rescue StopIteration\n @errors.push(\"#{File.basename(@data_path)}: has no data to import\")\n return\n end\n\n DataValidator.call(self).each do |error|\n @errors.push(\"#{File.basename(@data_path)}: #{error}\")\n end\n\n CommitsValidator.call(self).each do |error|\n @errors.push(\"#{File.basename(@commits_path)}: #{error}\")\n end\n\n nil\n end", "def check_file\n unless params[:file].blank?\n if params[:file].content_type.eql?(\"text/csv\")\n else\n flash[:alert] = \"file format Invalid, expected: text/csv Got #{params[:file].content_type}\"\n redirect_back(fallback_location: tv_series_index_path)\n end\n else\n flash[:alert] = 'Please provide a file to be uploaded !'\n redirect_back(fallback_location: tv_series_index_path)\n end\n end", "def avatar_must_be_in_correct_format\n return unless avatar.present?\n\n # FileMagic.mime { |fm| fm.file(avatar.path) }\n valid_format = [\"image/png\", \"image/jpg\", \"image/jpeg\"].include?(avatar.content_type) && [\"image/png\", \"image/jpg\", \"image/jpeg\"].include?(MimeMagic.by_magic(avatar)&.type)\n errors.add(:avatar, :content_type_invalid) unless valid_format\n\n valid_size = avatar.size <= 2.megabytes\n errors.add(:avatar, :file_size_out_of_range, filesize: avatar.size) unless valid_size\n end", "def picture_validation\n if picture.attached?\n if picture.blob.byte_size > 2000000\n picture.purge\n errors[:base] << 'Maksymalny rozmiar logo klanu to 2MB'\n elsif !picture.blob.content_type.starts_with?('image/')\n picture.purge\n errors[:base] << 'Zły format'\n end\n else\n errors[:base] << 'Logo klanu jest obowiązkowe.'\n end\n end", "def validate_subscribers_email_file\n if @subscribers_file.blank? || (@subscribers_file.content_type != \"application/vnd.ms-excel\" && @subscribers_file.content_type != \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\")\n @error_message << \"Veuillez choisir un fichier Excel contenant une liste d'emails.<br />\"\n @error = true\n end\n end", "def validate(file)\n Kernel::load file\n ENDPOINT.each_key do |k|\n auth = ENDPOINT[k][:oneauth]\n name = auth.split(\":\",2).first\n if name != ENV[\"USER\"]\n $Logger.error \"User attempting to upload invalid config.rb with user name of #{name} instead of #{ENV[\"USER\"]} for this service\"\n return false\n end\n end\n\n return true\n end", "def filecheck\n file.nil? ? false : File.exist?(file)\n end", "def validFile? filename\n if !filename.kind_of? String\n return false\n elsif File.exists? filename\n return File.readable? filename\n else\n return false\n end\nend", "def validate_file_input file, type\n @logger.debug \"Validating input file for #{type} file #{file}\"\n error = false\n unless file.is_a?(String) and !file.nil?\n error = \"The #{type} filename (#{file}) is not valid.\"\n else\n unless File.exists?(file)\n error = \"The #{type} file (#{file}) was not found.\"\n end\n end\n if error\n @logger.error \"Could not validate input file: #{error}\"\n raise \"InvalidInput\"\n end\nend", "def valid?\n File.exist?(fullpath)\n end", "def upload_filtered_file\n if ALLOWED_FILE_TYPES.include? File.extname(file_params[:file])\n upload_file\n else\n render json: \"Only #{ALLOWED_FILE_TYPES.join(', ')} extension file is allowed to upload\", status: 422\n end\n end", "def local_file?(file)\n file.is_a?(Tempfile) ||\n file.is_a?(ActionDispatch::Http::UploadedFile) ||\n file.is_a?(Rack::Test::UploadedFile)\n end", "def validate_companies_file\n if @companies_file.blank? || (@companies_file.content_type != \"application/vnd.ms-excel\" && @companies_file.content_type != \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\")\n flash.now[:error] = \"Veuillez choisir un fichier Excel contenant une liste d'entreprises.\"\n @error = true\n end\n end", "def check_file\n raise InvalidFileError, 'File must be present in CSV format!' unless valid_file\n\n raise InvalidCSVError, 'Your CSV file type is not supported!' unless readable_file\n end", "def resumable_upload? file #:nodoc:\n ::File.size?(file).to_i > Storage.resumable_threshold\n end", "def add_file(file)\n if file.class == ActionDispatch::Http::UploadedFile\n file_object = file.tempfile\n file_name = file.original_filename\n mime_type = file.content_type\n elsif file.class == File\n file_object = file\n file_name = Pathname.new(file.path).basename.to_s\n mime_type = mime_type_from_ext(file_name)\n else\n return false\n end\n\n self.add_file_datastream(file_object, label: file_name, mimeType: mime_type, dsid: 'content')\n set_file_timestamps(file_object)\n self.checksum = generate_checksum(file_object)\n self.original_filename = file_name\n self.mime_type = mime_type\n self.size = file.size.to_s\n self.file_uuid = UUID.new.generate\n true\n end", "def can_upload?\n klass.model_class && mime_types && mime_types.keys.include?(file_mime_type)\n end" ]
[ "0.791152", "0.72847843", "0.72402275", "0.72293377", "0.72215986", "0.7182079", "0.7114536", "0.7093546", "0.7028747", "0.6977053", "0.6956772", "0.69545656", "0.6900014", "0.6834158", "0.6834158", "0.6811859", "0.68005717", "0.6799437", "0.6764987", "0.6761738", "0.6738392", "0.6738392", "0.6738392", "0.6738392", "0.6738392", "0.6738392", "0.6733954", "0.66749984", "0.6662376", "0.6661368", "0.6609326", "0.66017926", "0.6566215", "0.65631443", "0.6556355", "0.65549755", "0.65211487", "0.65018743", "0.6494795", "0.64908046", "0.64740413", "0.6467954", "0.64148295", "0.64147896", "0.6413616", "0.63856214", "0.636343", "0.6352967", "0.6344799", "0.63389117", "0.6338547", "0.63299227", "0.6312827", "0.6308494", "0.63044137", "0.6270198", "0.6254956", "0.6248558", "0.62418973", "0.6240632", "0.62357527", "0.6232092", "0.6225837", "0.6224615", "0.62206733", "0.6204121", "0.6200689", "0.61962324", "0.6194249", "0.61909974", "0.6190217", "0.6188894", "0.6179939", "0.6178637", "0.6178602", "0.6178281", "0.6173188", "0.61706823", "0.61661375", "0.6165279", "0.61611784", "0.6158546", "0.6147822", "0.6138995", "0.61372626", "0.6130206", "0.61210054", "0.6095881", "0.6086013", "0.6081928", "0.6080831", "0.6071955", "0.60673225", "0.60663694", "0.6061407", "0.60485584", "0.6047445", "0.60431075", "0.6043076", "0.60401237", "0.6039968" ]
0.0
-1
Boolean method that determines if there is a dicount applicable to the line item. Returns true if the line_item can be discounted. Returns false otherwise.
def has_discount? !discount.nil? && (!discount.product_list? || discount.product_ids.include?(line_item.product_id)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def discount_amount\n has_discount? ? (line_item.total_in_cents * discount.percentage/100.0).to_i : 0\n end", "def is_discounted\n price.to_i < 10\n end", "def apply_discount\n\n #Check if discount is applicable. Purchases is a hash with the stock item as\n # a key. disc_items is the list of items that have to be bought together\n # if the discount is to be applicable. For each of these the code checks to\n # see if the item is in the carts purcheses hash. If after this process\n # apply is still true then the relevant discount has to applied to each of the \n # purchases in the current discount list. \n apply = true\n \n @cart_disc_list.each { |d| d.disc_items.each {|v| \n \n\t apply = (apply && @purchases.has_key?(v)) \n }\n \n if (apply == true)\n # apply discount\n\n\t d.disc_items.each { |w| \n @purchases[w].discount = d.percentage_discount\n @purchases[w].adjusted_price -= \n (@purchases[w].price * @purchases[w].discount / 100 ) \n \t\t\t }\n\t end\n apply = true\n }\n end", "def is_discounted?\n discounted = false\n discounted = true if price.to_i < 10\n discounted\n end", "def is_discounted?\n price < 10\n end", "def is_discounted?\n price < 10\n end", "def discountable_item_total\n tot = 0\n self.line_items.each do |li|\n tot += li.total if li.product.taxons.any? {|t| t.name == \"Discountable\"}\n end\n self.item_total = tot\n end", "def test_discount_on_item_not_valid_for_discount\n # Add 3 green tea to line items\n line_items = [ @green_tea_in_cart_1, @green_tea_in_cart_2, @green_tea_in_cart_3]\n @bulk_discount.apply(line_items)\n\n # Test if the discount is applied\n assert_equal @green_tea_in_cart_1.price, @green_tea.price, \"Discount not applied\"\n assert_equal @green_tea_in_cart_2.price, @green_tea.price, \"Discount not applied\"\n assert_equal @green_tea_in_cart_3.price, @green_tea.price, \"Discount not applied\"\n end", "def is_discounted?\n price < 1000 # actually doing self.price\n end", "def discount_for_category(line_items)\n item_counter = max_items || 1000\n product_or_group = apply_to_type == 'product' ? apply_to_product.name : apply_to_group\n line_items\n .select { |l| l.send(apply_to_type).to_s == product_or_group }\n .sort_by { |l| -l.unit_price }\n .take(max_items.nil? ? 1000 : max_items)\n .reduce(0) do |sum, line_item|\n total_quantity = max_items.nil? ? line_item.quantity : [item_counter, line_item.quantity].min\n if item_counter < 1\n # If we've gone over our limit for max_items, don't add anymore to the discount\n sum\n else\n item_counter -= total_quantity\n total_amount = amount * total_quantity\n if discount_type == 'fixed'\n sum + (total_amount > line_item.total_price ? line_item.total_price : total_amount)\n elsif discount_type == 'percentage'\n sum + (line_item.unit_price * total_quantity * amount * 0.01).round(2)\n end\n end\n end\n end", "def priced?()\n priced = true\n if (self.order_in_lines.length == 0)\n return false\n end\n self.order_in_lines.each do |line|\n if (not line.price or line.price == 0)\n priced = false\n end\n end\n return priced\n end", "def is_discounted?\n price.to_f <= 2\n end", "def calc_critical_count_item(user)\n item = user.item_db_symbol\n return true if UNCONDITIONAL_CRITICAL_ITEMS.include?(item)\n return true if item == :stick && user.db_symbol == :\"farfetch’d\"\n return true if item == :lucky_punch && user.db_symbol == :chansey\n return false\n end", "def lastIsUndercutPrice(item_id)\n if item_id != nil then\n sold_status = ListingStatus.cached_listing_status_from_description(\"Sold\")\n expired_status = ListingStatus.cached_listing_status_from_description('Expired')\n sold_not_undercut = SalesListing.cached_sold_not_undercut_count(item_id, current_user.id, sold_status[:id])\n expired_not_undercut = SalesListing.cached_expired_not_undercut_count(item_id, current_user.id, expired_status[:id])\n sold_and_undercut = SalesListing.cached_sold_and_undercut_count(item_id, current_user.id, sold_status[:id])\n expired_and_undercut = SalesListing.cached_expired_and_undercut_count(item_id, current_user.id, expired_status[:id])\n\n if sold_not_undercut > 0 then\n is_undercut_price = false\n else if expired_not_undercut > 0 then\n is_undercut_price = false\n else if sold_and_undercut > 0 then\n is_undercut_price = true\n else if expired_and_undercut > 0 then\n is_undercut_price = true\n else\n is_undercut_price = false\n end\n end\n end\n end\n end\n end", "def lastIsUndercutPrice(item_id)\n if item_id != nil then\n sold_status = ListingStatus.cached_listing_status_from_description(\"Sold\")\n expired_status = ListingStatus.cached_listing_status_from_description('Expired')\n sold_not_undercut = SalesListing.cached_sold_not_undercut_count(item_id, current_user[:id], sold_status[:id])\n expired_not_undercut = SalesListing.cached_expired_not_undercut_count(item_id, current_user[:id], expired_status[:id])\n sold_and_undercut = SalesListing.cached_sold_and_undercut_count(item_id, current_user[:id], sold_status[:id])\n expired_and_undercut = SalesListing.cached_expired_and_undercut_count(item_id, current_user[:id], expired_status[:id])\n\n if sold_not_undercut > 0 then\n is_undercut_price = false\n else if expired_not_undercut > 0 then\n is_undercut_price = false\n else if sold_and_undercut > 0 then\n is_undercut_price = true\n else if expired_and_undercut > 0 then\n is_undercut_price = true\n else\n is_undercut_price = false\n end\n end\n end\n end\n end\n end", "def checkout_allowed?\n line_items.count > 0\n end", "def discount_on_line_item_total\n total_discount = 0\n\n line_item_promotions.each do |promotion|\n total_discount += discount_for_line_item_promotion(promotion)\n end\n\n total_discount\n end", "def discount_running?\n !discount_period.nil? && discount_period > 0\n end", "def digital?\n line_items.all? { |item| item.digital? }\n end", "def check_line_items_quantities?\n self.line_items.each do |line_item|\n line_item_addresses_quantity = line_item.line_item_addresses.pluck(:quantity).sum\n if line_item.quantity == line_item_addresses_quantity\n line_item.line_item_addresses.each do |line_item_address|\n if line_item_address.quantity < 1\n unless self.user.quadvision_user.quadvision_delivery_addresses.pluck(:id).include?(line_item_address.address.id)\n return false\n end\n end\n end\n else\n return false\n end\n end\n return true\n end", "def test_discount_on_less_quantity_of_item\n # Add 2 strawberries to line items\n line_items = [ @strawberry_in_cart_1, @strawberry_in_cart_2]\n @bulk_discount.apply(line_items)\n\n # Test if the discount is applied\n assert_equal @strawberry_in_cart_1.price, @strawberry.price, \"Discount not applied\"\n assert_equal @strawberry_in_cart_2.price, @strawberry.price, \"Discount not applied\"\n end", "def discounted?\n price < 10\n end", "def discounted_total\n line_item.total_in_cents - discount_amount\n end", "def run(cart)\n\n return if @discount == 0;\n\n cart.line_items.each do |line_item|\n @discount.apply(line_item)\n end\n end", "def run(cart)\n\n return if @discount == 0;\n\n cart.line_items.each do |line_item|\n @discount.apply(line_item)\n end\n end", "def discounted?\n if price.to_f < 1000\n # return true\n # else\n # return false\n # end\n end\n end", "def total_discounts\n ipod = @items.index { |x| x.product.name == 'iPod' && x.quantity >= 2 }\n imac = @items.index { |x| x.product.name == 'iMac' }\n if ipod && imac\n # discount applies\n iphone = @items.index { |x| x.product.name == 'iPhone 4' }\n total_discount = @items[iphone].quantity * (@items[iphone].product.price - @items[iphone].product.discounted) if iphone \n end\n total_discount ||= 0\n end", "def apply_to!(sale, line_item = nil)\n coupon = self\n \n return \"coupon_usage_limit_exceeded\" if coupon.used_up?\n return \"no_sale_found_for_user\" if sale.nil?\n \n if coupon.applies_to?(:sale)\n sale.coupons << coupon\n elsif coupon.applies_to?(:product)\n li = sale.line_items.find_by_product_sku(coupon.product.sku)\n return \"no_eligible_line_items\" if li.nil?\n li.coupons << coupon\n \n li.calculate_and_attach_discount_items\n end\n \n \"true\"\n end", "def discount5\n\t\tif @number_items>=5\n\t\t\treturn true\n\t\telse\n\t\t\treturn false\n\t\tend\n\tend", "def skip_measurements?\n !line_items.any? { |l| l.product.category == :suit || l.product.category == :shirt }\n end", "def valid_discount_amount?\n\t\tif current_price.between?(max_discount_amount, min_discount_amount) \n\t\t\treturn true\t\t\t\n\t\telse\n\t\t\treturn false\t\t\n\t\tend \n\tend", "def apply(line_item)\n # Calculate the total discount for this line item\n line_discount = @amount * line_item.quantity\n\n # Calculated the discounted line price\n new_line_price = line_item.line_price - line_discount\n\n # Apply the new line price to this line item with a given message\n # describing the discount, which may be displayed in cart pages and\n # confirmation emails to describe the applied discount.\n line_item.change_line_price(new_line_price, message: @message)\n\n # Print a debugging line to the console\n puts \"Discounted line item with variant #{line_item.variant.id} by #{line_discount}.\"\n end", "def enable?(item)\n CookingManager.quantity(item) > 0\n end", "def has_line_item?\n true\n end", "def has_discounts?\n rpg_shop.permit_sales\n end", "def applyDiscount\n # get all rules with an item code\n rules = @rules.select { |obj| obj.getCode != \"total\" } \n rules.each do |rule|\n # find the minimum threshold for the rule to apply\n size = @items.select { |item| item.getCode == rule.getCode }.size \n # if threshold is not exceeded\n unless rule.getThreshold > size \n @items.each do |item| \n # if item code matches the rule code\n if(item.getCode == rule.getCode) \n # reset the price to the initial price to revert modifications\n item.refreshPrice \n # compute discount price based on rule\n item.setPrice(rule.getPercent ? item.getPrice * (1-rule.getValue) : item.getPrice - rule.getValue) \n end\n end\n end\n end\n end", "def test_discount_on_bulk_quantity_of_item\n # Add 3 strawberries to line items\n line_items = [ @strawberry_in_cart_1, @strawberry_in_cart_2, @strawberry_in_cart_3]\n @bulk_discount.apply(line_items)\n\n # Test if the discount is applied\n assert_equal @strawberry_in_cart_1.price, @strawberry.price - @bulk_discount.bulk_discount, \"Discount applied\"\n assert_equal @strawberry_in_cart_2.price, @strawberry.price - @bulk_discount.bulk_discount, \"Discount applied\"\n assert_equal @strawberry_in_cart_3.price, @strawberry.price - @bulk_discount.bulk_discount, \"Discount applied\"\n end", "def check_line_item_in_inventory(line_item)\n # feature flipper\n if Features.inactive?(:refulfill)\n return true\n end\n found = false\n\n if rii = find_match_and_decrement_available(line_item)\n if line_item.order.shipping_address.country.name == 'United States' && rii.vendor == 'bergen'\n line_item.return_inventory_item = rii\n line_item.refulfill_status = 'new'\n found = true\n line_item.save\n elsif line_item.order.shipping_address.country.name == 'Australia' && rii.vendor == 'next'\n line_item.return_inventory_item = rii\n line_item.refulfill_status = 'new'\n found = true\n line_item.save\n end\n end\n found\n end", "def apply_discount\n #binding.pry\n self.total *= (1-(self.discount/100.0))\n discount_s = \"After the discount, the total comes to $#{self.total.to_i}.\"\n no_discount_s = \"There is no discount to apply.\"\n discount > 0 ? discount_s : no_discount_s\n end", "def did_anyone_buy_this_thing?\n if line_items.empty?\n return true \n else\n errors.add(:base, 'Line Items Present')\n return false\n\n end\n end", "def valid_coupon?(coupon, cart)\n cart.has_key?(coupon[:item]) && cart[coupon[:item]].fetch(:count) >= coupon[:num]\nend", "def enable?(item)\n return (item.price > 0)\n end", "def discounted_item_total\n ( self.item_total - self.discountable_item_total )\n end", "def is_discounted? #? means will return t/f \n price < 200\nend", "def not_refer_to_cart_item\n if cart_items.empty?\n return true\n else\n errors.add(:base, I18n.t('models.product.validations.lines'))\n return false\n end\n end", "def total_discounted_price\n # convert to array so it doesn't try to do sum on database directly\n line_items.to_a.sum(&:total_discounted_price)\n end", "def fulfillable?\n line_items.all?(&:fulfillable?)\n end", "def ensure_not_referenced_by_any_line_item\n if line_items.empty?\n return true\n else\n errors.add(:base, 'este produto não pode ser deletado porque pertence à itens em carrinhos de compras')\n return false\n end\n end", "def calculate_coupon_credit\n return 0 if order.line_items.not_on_sale.empty?\n \n ###\n # Send only line items that have not been put on sale to the calculator\n ###\n amount = source.calculator.compute(order).abs\n amount = order.item_total if amount > order.item_total\n -1 * amount\n end", "def adjustment_line_is?\r\n adjustment_amounts = [coinsurance_amount, copay_amount, deductible_amount,\r\n denied_amount, discount_amount, noncovered_amount, primary_payment_amount,\r\n prepaid_amount, patient_responsibility_amount, contractual_amount,\r\n miscellaneous_one_adjustment_amount, miscellaneous_two_adjustment_amount,\r\n miscellaneous_balance]\r\n\r\n total_adjustment_amount = adjustment_amounts.inject(0) {|sum, value| sum + value.to_f }\r\n balance_amount = service_procedure_charge_amount.to_f - (service_paid_amount.to_f + total_adjustment_amount)\r\n\r\n non_zero_adjustment_amounts = adjustment_amounts.keep_if {|v| !v.to_f.zero?}\r\n is_there_atleast_one_adjustment_amount = non_zero_adjustment_amounts.length > 0\r\n\r\n balance_amount.to_f.round(2).zero? && service_procedure_charge_amount.blank? && service_allowable.blank? &&\r\n is_there_atleast_one_adjustment_amount\r\n end", "def usable_item_conditions_met?(item)\r\n movable? && occasion_ok?(item)\r\n end", "def some_digital?\n line_items.map { |item| return true if item.digital? }\n false\n end", "def group?\n !self.DiscountGrpCustNo.zero?\n end", "def has_line_items?\n line_items.any?\n end", "def refunded_with_active_certificates?\n refunded_at.present? && daily_deal_certificates.active.try(:size) == quantity\n end", "def conv_discount\n ((self.respond_to?(:discount) && discount) || 0).to_r\n end", "def add_discount(product, condition, price_formula_true, price_formula_false = 'product_price * _amount')\n product_list[product].add_discount(condition, price_formula_true, price_formula_false)\n end", "def validate_line_item\n if @line_item = @quote.line_items.find(params[:id])\n return true\n else\n flash.now[:alert] = 'Order item is not in your cart.'\n respond_to do |format|\n format.html { render 'show' }\n format.json { render json: { result: 'false', errors: flash[:alert] }, status: 401 }\n end\n return false\n end\n end", "def is_enough\r\n \tProduct.find(@cart_item.product_id).count - @cart_item.count >= 0\r\n end", "def enable?(item)\n item && item.price > 0\n end", "def has_line_item?(id)\n\t\tself.order_line_items.each do |item|\n\t\t\treturn true if item.product_id == id\n\t\tend\n\t\treturn false\n\tend", "def revisit_necessary?(input_item)\n occ_days = @result_history.occurrence_days(input_item)\n occ_days.positive? && occ_days < @config[:revisit_new_item_days_boundary]\n end", "def applicable?\n mandatory || amount != 0\n end", "def apply_discount\n # if @discount != 20\n discount_percent = ((100.0 - @discount.to_f) / 100.0)\n @total *= discount_percent\n return \"After the discount, the total comes to $#{@total.to_i}.\"\n # else\n # return \"There is no discount to apply.\"\n # end\n end", "def value_for_line_item(line_item)\n return 0 unless line_item_eligible?(line_item)\n line_item.total\n end", "def discount(item)\n path = File.expand_path('../../../public/discounts.yml', __FILE__)\n @discounts ||= YAML.load_file(path)\n if @discounts[item]\n order.map { |e| @discounts[item][e[0]] }.compact.max || 0\n else\n 0\n end\n end", "def total_discount(items)\n 0\n end", "def discount_amount\n all_discounts = line_items.collect { |li| li.discounts }.flatten\n mapping = all_discounts.map(&:price_extend)\n # when we create the discount items, we need to set calculate their price_extend value\n mapping.sum\n end", "def item_need_review\n return @item_need_review\n end", "def only_downloadable\n downloadable_count = 0\n @order.line_items.each do |item|\n if((!item.product.downloadables.empty?) || (!item.variant.downloadables.empty?))\n downloadable_count += 1\n end\n end\n @order.line_items.size == downloadable_count\n end", "def calculate_item_amount_with_discount(item, user)\n\n item_bill_amount = calculate_item_amount(item.quantity, item.price)\n return item_bill_amount if item.is_grocery? \n\n\n return item_bill_amount - (item_bill_amount * get_discount_percentage(user))/100\n end", "def validate\n !discount_code.nil? && discount.nil? ? raise(InvalidDiscountCode, \"There is no discount with that code\") : true\n end", "def disabilities_not_service_connected?\n disabilities.pluck('ratedDisabilityId').all? do |rated_id|\n rated_id.present? && (all_rated_disabilities\n .find { |rated| rated_id == rated.rated_disability_id }\n &.decision_code == 'NOTSVCCON')\n end\n end", "def price_to_be_announced?\n unless self.product_supplies.empty? || self.product_supplies.first.supply_details.empty?\n unpriced_item_type = self.product_supplies.first.supply_details.first.unpriced_item_type\n end\n unpriced_item_type ? unpriced_item_type.human==\"PriceToBeAnnounced\" : false\n end", "def apply_discount\n if self.discount == 0\n return \"There is no discount to apply.\"\n else self.total *= (1 - (self.discount.to_f / 100))\n return \"After the discount, the total comes to $#{self.total.to_i}.\"\n end\n end", "def apply_discount\n @total *= (1 - (discount * 0.01))\n if discount == 0\n return \"There is no discount to apply.\"\n else\n return \"After the discount, the total comes to $#{@total.to_i}.\"\n end\n end", "def discounted_total\n line_items = line_items_total\n fees = [item_fees_in_cents].sum\n credits = [customer_credits_total, promo_code_total].sum\n discounts = [membership_discount_total, quantity_discount_total].sum\n\n total = line_items + fees - credits - discounts\n [total, 0].max\n end", "def contain_item?(id)\n return item_quantity(id) > 0\n end", "def item_usable?\r\n user.usable?(item) && item_effects_valid?\r\n end", "def calculate_item_liability(item_attributes)\n calculate_item_gross(item_attributes)\n end", "def validate_discount_number\n disc = self.discount.to_f\n if disc < 0\n self.errors.add(:discount, I18n.t(\"activerecord.errors.messages.greater_than_or_equal_to\", :count => 0))\n elsif disc > 100\n self.errors.add(:discount, I18n.t(\"activerecord.errors.messages.less_than_or_equal_to\", :count => 100))\n end\n end", "def add_accessories?\n complete? && product.accessories.count > child_order_details.count\n end", "def enable?(item)\n return false if item.nil?\n return false if $game_party.gold < item.dismantle_gold_fee \n return item.dismantlable?\n end", "def run(cart)\n # Each line_item has a quantity, which usually makes the total...\n # ...quantity of items higher than the length of cart.line_items\n total_item_count = 0\n applicable_line_items = cart.line_items.select do |line_item|\n is_shirt = line_item.variant.product.tags.include? 'shirts'\n is_bundle = line_item.variant.product.tags.include? 'bundle'\n if is_shirt and is_bundle\n total_item_count += line_item.quantity\n line_item\n end\n end\n\n # The remaining amount of items that can be discounted in each category\n items_in_bundles_of_3 = (total_item_count / 3).floor * 3\n items_in_bundles_of_2 = ((total_item_count % 3) / 2).floor * 2\n \n # Change the price of applicable items\n applicable_line_items.each do |line_item|\n unexamined_item_count = line_item.quantity\n if items_in_bundles_of_3 >= unexamined_item_count\n discount = unexamined_item_count * @discount_per_item_in_bundle_of_three\n line_item.change_line_price(line_item.line_price - discount, message: \"\")\n items_in_bundles_of_3 -= unexamined_item_count\n next\n end\n if items_in_bundles_of_3 > 0 and items_in_bundles_of_3 < unexamined_item_count\n discount = items_in_bundles_of_3 * @discount_per_item_in_bundle_of_three\n line_item.change_line_price(line_item.line_price - discount, message: \"\")\n unexamined_item_count -= items_in_bundles_of_3\n items_in_bundles_of_3 = 0\n end\n if items_in_bundles_of_2 >= unexamined_item_count\n discount = unexamined_item_count * @discount_per_item_in_bundle_of_two\n line_item.change_line_price(line_item.line_price - discount, message: \"\")\n items_in_bundles_of_2 -= unexamined_item_count\n end\n end\n end", "def apply_discount\n if discount != 0\n self.total = (total * ((100.0 - discount.to_f)/100)).to_i\n \"After the discount, the total comes to $#{self.total}.\"\n else\n \"There is no discount to apply.\"\n end\n end", "def item_usable?\n user.usable?(item) && item_effects_valid?\n end", "def has_enough_money(item)\r\n if(self.credits>= item.get_price)\r\n return true\r\n else\r\n puts('get money')\r\n return false\r\n end\r\n end", "def apply_discount\n if discount !=0\n self.total = total- (total*(discount/100.to_f)).to_i\n \"After the discount, the total comes to $#{self.total}.\"\n else\n \"There is no discount to apply.\"\n end\n end", "def apply_free_shippling_rule\n if (@subtotal > 100.00 || @customer[:state] == 'IL') # If subtotal greater than 100 or state is IL\n if !(@line_items.detect { |item| item.sku == '123' }) # If a particular item is not present\n @shipping_charge = 0\n end\n end\n end", "def compute_amount(line_item)\n raise \"Adjustable does not match line item\" unless line_item == inventory_unit.line_item\n -(line_item.total.to_d / line_item.inventory_units.not_canceled.reject(&:original_return_item ).size)\n end", "def can_buy?(item)\r\n item.buyable_by?(self)\r\n end", "def discounted_conference_items\n @discounted_items ||= ConferenceItem.discounted_items(discount_key).not_registered(line_items)\n end", "def apply_discount\n self.total -= (self.discount * 0.01) * self.total\n return self.total > 0 ? \"After the discount, the total comes to $#{self.total.to_i}.\" : \"There is no discount to apply.\"\n end", "def check_amount\n if (mode == 'percentage' and percentage == 0) or (mode == 'fixed' and money.zero?)\n errors.add(:amount, 'a discount cannot be zero')\n end\n end", "def calculate_discount_amount(product, product_promotion)\n if product_promotion && product_promotion.discount.to_f > 0.0\n calculate_promotion_discount(product, product_promotion)\n elsif product.sale_price && product.sale_price.to_f > 0.0\n\n if product.street_price.to_f > product.sale_price.to_f\n product.street_price.to_f - product.sale_price.to_f\n elsif !!!(product.street_price.to_f > 0.0) && product.msrp.to_f > product.sale_price.to_f\n product.msrp.to_f - product.sale_price.to_f\n else\n 0.0\n end\n\n else\n 0.0\n end\n end", "def item_effect_effective_correction(effective, item)\r\n return effective |= item.hit < 100\r\n end", "def partition(cart, line_items)\n # Sort the items by price from high to low\n sorted_items = line_items.sort_by{|line_item| line_item.variant.price}.reverse\n # Create an array of items to return\n discounted_items = []\n # Keep counters of items seen and discounted, to avoid having to recalculate on each iteration\n total_items_seen = 0\n discounted_items_seen = 0\n\n # Loop over all the items and find those to be discounted\n sorted_items.each do |line_item|\n total_items_seen += line_item.quantity\n # After incrementing total_items_seen, see if any items must be discounted\n count = discounted_items_to_find(total_items_seen, discounted_items_seen)\n # If there are none, skip to the next item\n next if count <= 0\n\n if count >= line_item.quantity\n # If the full item quantity must be discounted, add it to the items to return\n # and increment the count of discounted items\n discounted_items.push(line_item)\n discounted_items_seen += line_item.quantity\n else\n # If only part of the item must be discounted, split the item\n discounted_item = line_item.split(take: count)\n # Insert the newly-created item in the cart, right after the original item\n position = cart.line_items.find_index(line_item)\n cart.line_items.insert(position + 1, discounted_item)\n # Add it to the list of items to return\n discounted_items.push(discounted_item)\n discounted_items_seen += discounted_item.quantity\n end\n end\n\n # Return the items to be discounted\n discounted_items\n end", "def can_buy?(item)\n item.buyable_by?(self)\n end", "def available\n\t\tavailable = 0\n\t\tDonationLine.unexpired.where(product_id: id).where(inventory_id: nil).map { |line| available += line.quantity}\n\t\tavailable\n\tend", "def ensure_not_referenced_by_any_line_item\nif line_items.count.zero?\nreturn true\nelse\nerrors[:base] << \"Line Items present\"\nreturn false\nend\nend" ]
[ "0.63958365", "0.6342182", "0.6298566", "0.62357354", "0.61703545", "0.61703545", "0.61700547", "0.6165784", "0.6146745", "0.6098343", "0.6045398", "0.6024317", "0.6019758", "0.59431356", "0.59374064", "0.59182966", "0.5910624", "0.58971137", "0.58790725", "0.58580625", "0.58321995", "0.58191764", "0.57790095", "0.57780707", "0.57780707", "0.5761082", "0.57417774", "0.57248145", "0.5724619", "0.5717439", "0.57132876", "0.5649521", "0.5638977", "0.55748385", "0.5507469", "0.5468663", "0.5467194", "0.5445527", "0.5420256", "0.5416414", "0.53995997", "0.53752184", "0.53474414", "0.53458273", "0.5345497", "0.53427327", "0.53410506", "0.53304213", "0.5330291", "0.53148973", "0.5293457", "0.52888733", "0.5285602", "0.5278341", "0.5260184", "0.52547354", "0.5252586", "0.5248919", "0.52473986", "0.52413696", "0.5233886", "0.5211054", "0.5209072", "0.51946175", "0.5187939", "0.5172483", "0.5171433", "0.5168056", "0.51678056", "0.5157948", "0.5152797", "0.5132283", "0.51273686", "0.51253337", "0.51241195", "0.51084816", "0.51055425", "0.5099511", "0.5096506", "0.5093714", "0.5093307", "0.5088382", "0.5087724", "0.5084826", "0.50830525", "0.5079285", "0.507718", "0.50763327", "0.50736254", "0.5069385", "0.5067854", "0.5063436", "0.5060615", "0.50595844", "0.5053553", "0.5051968", "0.50503004", "0.50483894", "0.5046481", "0.50444126" ]
0.7031669
0
Returns that amount that is discounted from the line item. Returns 0 if there is no applicable discount.
def discount_amount has_discount? ? (line_item.total_in_cents * discount.percentage/100.0).to_i : 0 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def discounted_total\n line_item.total_in_cents - discount_amount\n end", "def get_discounted_amount\n\t\tif self.discount.nil?\n\t\t\t0\n\t\telse\n\t\t\tself.amount * self.discount\n\t\tend\n\n end", "def discount_amount\n all_discounts = line_items.collect { |li| li.discounts }.flatten\n mapping = all_discounts.map(&:price_extend)\n # when we create the discount items, we need to set calculate their price_extend value\n mapping.sum\n end", "def discounted_item_total\n ( self.item_total - self.discountable_item_total )\n end", "def discount_on_line_item_total\n total_discount = 0\n\n line_item_promotions.each do |promotion|\n total_discount += discount_for_line_item_promotion(promotion)\n end\n\n total_discount\n end", "def discounted_total\n line_items = line_items_total\n fees = [item_fees_in_cents].sum\n credits = [customer_credits_total, promo_code_total].sum\n discounts = [membership_discount_total, quantity_discount_total].sum\n\n total = line_items + fees - credits - discounts\n [total, 0].max\n end", "def discountable_item_total\n tot = 0\n self.line_items.each do |li|\n tot += li.total if li.product.taxons.any? {|t| t.name == \"Discountable\"}\n end\n self.item_total = tot\n end", "def total_discounted_price\n # convert to array so it doesn't try to do sum on database directly\n line_items.to_a.sum(&:total_discounted_price)\n end", "def discount_value\n return 0 unless order.fixed_pricing?\n\n if free_gift? && pricing_sku.present?\n pricing_sku.find_price(quantity: 1).regular.to_f\n else\n price_adjustment.amount.abs.to_f\n end\n end", "def discount_coefficient(item)\n 1 - discount(item) / 100.0\n end", "def total_discount(items)\n 0\n end", "def apply_discount\n self.total -= (self.discount * 0.01) * self.total\n return self.total > 0 ? \"After the discount, the total comes to $#{self.total.to_i}.\" : \"There is no discount to apply.\"\n end", "def apply_discount\n if self.discount == 0\n return \"There is no discount to apply.\"\n else self.total *= (1 - (self.discount.to_f / 100))\n return \"After the discount, the total comes to $#{self.total.to_i}.\"\n end\n end", "def discount_amount\n return 0.0 if @code.blank?\n\n if applicable?\n options = all_coupons[@code.to_s]\n if options[2] == :fixed\n options[1]\n elsif options[2] == :percent\n (@order_or_cart.total_product_amount * options[1]) / 100.0\n end\n else\n 0.0\n end\n end", "def apply_discount\n @total *= (1 - (discount * 0.01))\n if discount == 0\n return \"There is no discount to apply.\"\n else\n return \"After the discount, the total comes to $#{@total.to_i}.\"\n end\n end", "def calculate_discount_for(total)\n if self.discount_percentage.present? && self.discount_percentage != 0.0\n (total / 100) * self.discount_percentage.round(2)\n else\n 0\n end\n end", "def value_for_line_item(line_item)\n return 0 unless line_item_eligible?(line_item)\n line_item.total\n end", "def discount\n return 0 unless product.price and product.price != 0\n (100 - (price/product.price)*100).round(0)\n end", "def calculate_item_amount_with_discount(item, user)\n\n item_bill_amount = calculate_item_amount(item.quantity, item.price)\n return item_bill_amount if item.is_grocery? \n\n\n return item_bill_amount - (item_bill_amount * get_discount_percentage(user))/100\n end", "def pre_tax_amount_from_line_item line_item\n amount = (line_item.discounted_amount - line_item.included_tax_total) / line_item.quantity\n\n Spree::Money.new(\n BigDecimal.new(amount.to_s).round(2, BigDecimal::ROUND_HALF_DOWN),\n currency: line_item.currency\n ).cents\n end", "def apply_discount\n # conditional to check if there's a discount\n if discount > 0\n @total -= @total * (discount / 100.0).to_f\n #gets rid of trailing zeros \n total = @total.to_s.sub(/\\.?0+$/, '')\n return \"After the discount, the total comes to $#{total}.\"\n else\n return \"There is no discount to apply.\"\n end\n end", "def compute_amount(line_item)\n raise \"Adjustable does not match line item\" unless line_item == inventory_unit.line_item\n -(line_item.total.to_d / line_item.inventory_units.not_canceled.reject(&:original_return_item ).size)\n end", "def min_discount_amount\n\t\tamount = self.original_price - self.original_price * 0.05\n\t\treturn amount\n\tend", "def apply_discount\n if @discount == 0\n \"There is no discount to apply.\"\n else\n @discounted_price = (self.total * @discount * 0.01)\n @total -= @discounted_price\n \"After the discount, the total comes to $#{@total.to_i}.\"\n end\n end", "def apply_discount\n if discount != 0\n self.total = (total * ((100.0 - discount.to_f)/100)).to_i\n \"After the discount, the total comes to $#{self.total}.\"\n else\n \"There is no discount to apply.\"\n end\n end", "def discount(item)\n path = File.expand_path('../../../public/discounts.yml', __FILE__)\n @discounts ||= YAML.load_file(path)\n if @discounts[item]\n order.map { |e| @discounts[item][e[0]] }.compact.max || 0\n else\n 0\n end\n end", "def discount_for_category(line_items)\n item_counter = max_items || 1000\n product_or_group = apply_to_type == 'product' ? apply_to_product.name : apply_to_group\n line_items\n .select { |l| l.send(apply_to_type).to_s == product_or_group }\n .sort_by { |l| -l.unit_price }\n .take(max_items.nil? ? 1000 : max_items)\n .reduce(0) do |sum, line_item|\n total_quantity = max_items.nil? ? line_item.quantity : [item_counter, line_item.quantity].min\n if item_counter < 1\n # If we've gone over our limit for max_items, don't add anymore to the discount\n sum\n else\n item_counter -= total_quantity\n total_amount = amount * total_quantity\n if discount_type == 'fixed'\n sum + (total_amount > line_item.total_price ? line_item.total_price : total_amount)\n elsif discount_type == 'percentage'\n sum + (line_item.unit_price * total_quantity * amount * 0.01).round(2)\n end\n end\n end\n end", "def get_discounted_value bill\n # this function needs to be called only once to initialize rules\n return 0 if bill.nil?\n bill_amount = bill.amount\n if discount = validate_discount(bill)\n if discount.operation.eql? \"x\"\n bill_amount = bill_amount * (1 - discount.value * 0.01)\n elsif discount.operation.eql? \"/\"\n bill_amount = bill_amount - (bill_amount/discount.value).floor\n elsif discount.operation.eql? \"-\"\n bill_amount = bill_amount - discount.value\n end\n end\n return bill_amount < 0 ? 0 : bill_amount\n end", "def apply_discount\n if self.discount > 0\n self.total = @total - @total * @discount / 100\n return \"After the discount, the total comes to $#{@total}.\"\n else\n return \"There is no discount to apply.\"\n end\n end", "def discount\n @price - @price * @discount/100\n end", "def apply_discount\n if discount !=0\n self.total = total- (total*(discount/100.to_f)).to_i\n \"After the discount, the total comes to $#{self.total}.\"\n else\n \"There is no discount to apply.\"\n end\n end", "def apply_discount\n #binding.pry\n self.total *= (1-(self.discount/100.0))\n discount_s = \"After the discount, the total comes to $#{self.total.to_i}.\"\n no_discount_s = \"There is no discount to apply.\"\n discount > 0 ? discount_s : no_discount_s\n end", "def conv_discount\n ((self.respond_to?(:discount) && discount) || 0).to_r\n end", "def apply_discount\n if @discount != 0\n @discount = @discount.to_f / 100 # discount is 20%, so must convert to float before dividing by 100 to get percent\n self.total = (@total * (1 - @discount)).to_i # convert back to integer so result is $800 not $800.0\n \"After the discount, the total comes to $#{self.total}.\"\n # puts @total\n # puts @discount.to_f / 100\n # puts 1 - (@discount.to_f / 100)\n else\n \"There is no discount to apply.\"\n end\n end", "def discount_amount(bill)\n return sum_price_non_groceries(bill.get_items) * @discount\n end", "def apply_discount\n # if @discount != 20\n discount_percent = ((100.0 - @discount.to_f) / 100.0)\n @total *= discount_percent\n return \"After the discount, the total comes to $#{@total.to_i}.\"\n # else\n # return \"There is no discount to apply.\"\n # end\n end", "def get_discount\n if @discount\n @discount.amountOff ? '$'+ @discount.amountOff.to_s : @discount.percentOff.to_s + '%'\n else\n 'N/A'\n end\n end", "def amount(include_discount = true)\r\n include_discount && @discount && @discount.apply_to_recurring? ? self[:amount] - @discount.calculate(self[:amount]) : self[:amount]\r\n end", "def discount_value\n return '20' if taxons.find_by(id: 126) # Taxon 20% Descuento\n return '25' if taxons.find_by(id: 128) # Taxon 25% Descuento\n return '30' if taxons.find_by(id: 127) # Taxon 30% Descuento\n return '33' if taxons.find_by(id: 134) # Taxon 33% Descuento\n end", "def price\n (original_price * (1 - discount_rate)).to_i\n end", "def apply_discount\n if discount > 0 \n @total = @total * 0.8\n \"After the discount, the total comes to $#{@total.to_i}.\"\n else\n \"There is no discount to apply.\"\n end\n end", "def calculate_coupon_credit\n return 0 if order.line_items.empty?\n amount = adjustment_source.calculator.compute(order.line_items).abs\n amount = order.item_total if amount > order.item_total\n -1 * amount\n end", "def pre_discount_total\n sum(:pre_discount_total)\n end", "def collection_discount(total)\n (discount * total) / 100\n end", "def apply_discount\n # checks if there is any discount\n if discount == 0\n \"There is no discount to apply.\"\n else\n #applies discount\n @total = @total * (1-@discount/100.0)\n # converts back to integer\n @total = @total.to_i\n \"After the discount, the total comes to $#{@total}.\"\n end\n end", "def total_discounts\n ipod = @items.index { |x| x.product.name == 'iPod' && x.quantity >= 2 }\n imac = @items.index { |x| x.product.name == 'iMac' }\n if ipod && imac\n # discount applies\n iphone = @items.index { |x| x.product.name == 'iPhone 4' }\n total_discount = @items[iphone].quantity * (@items[iphone].product.price - @items[iphone].product.discounted) if iphone \n end\n total_discount ||= 0\n end", "def percentage_discount\n ((1 - (sale_price / original_price)) * 100).round.to_i\n end", "def final_amount\n amount_paid - discount_value - discount_percent\n end", "def final_price\n (self.price*(1 - self.discount.to_f / 100)).to_i\n end", "def calculate_coupon_credit\n return 0 if order.line_items.not_on_sale.empty?\n \n ###\n # Send only line items that have not been put on sale to the calculator\n ###\n amount = source.calculator.compute(order).abs\n amount = order.item_total if amount > order.item_total\n -1 * amount\n end", "def apply(line_item)\n # Calculate the total discount for this line item\n line_discount = @amount * line_item.quantity\n\n # Calculated the discounted line price\n new_line_price = line_item.line_price - line_discount\n\n # Apply the new line price to this line item with a given message\n # describing the discount, which may be displayed in cart pages and\n # confirmation emails to describe the applied discount.\n line_item.change_line_price(new_line_price, message: @message)\n\n # Print a debugging line to the console\n puts \"Discounted line item with variant #{line_item.variant.id} by #{line_discount}.\"\n end", "def discount(level=0)\n #raise 'DEADBEEF'\n if self.cart_discounts.count == 0 or level == 0 or level.nil?\n return self.price\n else\n if self.cart_discounts.find_by_level_id(level).nil?\n return self.cart_discounts.find(:all, :conditions => [\"level_id < ?\", level]).sort_by(&:level_id).reverse.first.amount\n else\n return self.cart_discounts.find_by_level_id(level).amount\n end\n end\n end", "def final_price\n price * (100 - discount) / 100\n end", "def apply_discount\n if @discount\n discount = @total * @discount / 100 \n @total = @total - discount\n return \"After the discount, the total comes to $#{@total}.\"\n else # cash register wasn't initiailzied w/ discount\n return \"There is no discount to apply.\"\n end\n end", "def coupon_discount\n if coupon.unit == :value\n coupon.discount\n elsif coupon.unit == :percent\n original_price * (coupon.discount / 100)\n else\n 0\n end\n end", "def discount_total_base\n total * (conv_discount / 100)\n end", "def compute_amount(line_item)\n adjustment_amount = calculator.compute(PartialLineItem.new(line_item))\n if !adjustment_amount.is_a?(BigDecimal)\n Spree::Deprecation.warn \"#{calculator.class.name}#compute returned #{adjustment_amount.inspect}, it should return a BigDecimal\"\n end\n adjustment_amount ||= BigDecimal.new(0)\n adjustment_amount = adjustment_amount.abs\n\n order = line_item.order\n line_items = actionable_line_items(order)\n\n actioned_line_items = order.line_item_adjustments.reload.\n select { |a| a.source == self && a.amount < 0 }.\n map(&:adjustable)\n other_line_items = actioned_line_items - [line_item]\n\n applicable_quantity = total_applicable_quantity(line_items)\n used_quantity = total_used_quantity(other_line_items)\n usable_quantity = [\n applicable_quantity - used_quantity,\n line_item.quantity\n ].min\n\n persist_quantity(usable_quantity, line_item)\n\n amount = adjustment_amount * usable_quantity\n [line_item.amount, amount].min * -1\n end", "def apply_discount\n\t\t@total -= @discount\n\t\tputs \"Total price expected: £ #{@total.round(3)}\"\n\tend", "def max_discount_amount\n\t\tamount = self.original_price - self.original_price * 0.3\n\t\treturn amount\n\tend", "def get_average_discount(toy)\n\treturn get_retail_price(toy) - get_average_price(toy)\nend", "def apply_discount_on_total(total_amount)\n return total_amount if total_amount < 100\n\n discount_amount = (total_amount.to_i / 100) * EACH_HUNDRED_DOLLAR\n total_amount - discount_amount\n end", "def total_amount\n line_items.reduce(Money.zero) { |a, e| a + e.total_amount_inc_tax }\n end", "def total_revenue_after_discounts\n total_revenue.first.to_f - total_discount.to_f\n end", "def run(cart)\n\n return if @discount == 0;\n\n cart.line_items.each do |line_item|\n @discount.apply(line_item)\n end\n end", "def run(cart)\n\n return if @discount == 0;\n\n cart.line_items.each do |line_item|\n @discount.apply(line_item)\n end\n end", "def vat_amount_from_line_item line_item\n amount = line_item.included_tax_total / line_item.quantity\n\n Spree::Money.new(\n BigDecimal.new(amount.to_s).round(2, BigDecimal::ROUND_HALF_UP),\n currency: line_item.currency\n ).cents\n end", "def calculate_net_amount\n @items.each do |item|\n item.price_after_discount = @discount_processor.calculate_item_amount_with_discount(item, @user)\n end\n\n #total items bill amount\n items_total = @items.map(&:price_after_discount).reduce(:+)\n\n #applying discount on total amount.\n @discount_processor.apply_discount_on_total(items_total)\n end", "def item_total\n @promotion_attributed_line_items.map(&:amount).sum\n end", "def discount(subtotal: nil)\n discount = promo.discount\n\n case\n when discount == \"free shipping\"\n order.shipping\n # make sure there is no typo to give customer more than 30% off\n when 0.3 < discount.to_f && discount.to_f < 1\n nil\n when discount.to_f < 0.3\n (subtotal || order.subtotal) * discount.to_f\n when discount.to_f > 1\n discount.to_f\n end\n end", "def refund_amount_for(item_return)\n item_return.line_item.price\n end", "def computeTotal\n # get rule for total\n rule = @rules.find{ |obj| obj.getCode == \"total\" } \n # sum item prices\n total = @items.inject(0){|sum, x| sum + x.getPrice} \n # if rule exists and condition is met, apply discount\n if rule && total > rule.getThreshold \n total = rule.getPercent ? total * (1-rule.getValue) : total - rule.getValue\n end\n return total\n end", "def calculate_discount_amount(product, product_promotion)\n if product_promotion && product_promotion.discount.to_f > 0.0\n calculate_promotion_discount(product, product_promotion)\n elsif product.sale_price && product.sale_price.to_f > 0.0\n\n if product.street_price.to_f > product.sale_price.to_f\n product.street_price.to_f - product.sale_price.to_f\n elsif !!!(product.street_price.to_f > 0.0) && product.msrp.to_f > product.sale_price.to_f\n product.msrp.to_f - product.sale_price.to_f\n else\n 0.0\n end\n\n else\n 0.0\n end\n end", "def discounted_items_to_find(total_items_seen, discounted_items_seen)\n Integer(total_items_seen / (@paid_item_count + @discounted_item_count) * @discounted_item_count) - discounted_items_seen\n end", "def discounted_items_to_find(total_items_seen, discounted_items_seen)\n Integer(total_items_seen / (@paid_item_count + @discounted_item_count) * @discounted_item_count) - discounted_items_seen\n end", "def discounted_items_to_find(total_items_seen, discounted_items_seen)\n Integer(total_items_seen / (@paid_item_count + @discounted_item_count) * @discounted_item_count) - discounted_items_seen\n end", "def balance_owed\n discounted_price - amount_paid\n end", "def applyDiscount\n # get all rules with an item code\n rules = @rules.select { |obj| obj.getCode != \"total\" } \n rules.each do |rule|\n # find the minimum threshold for the rule to apply\n size = @items.select { |item| item.getCode == rule.getCode }.size \n # if threshold is not exceeded\n unless rule.getThreshold > size \n @items.each do |item| \n # if item code matches the rule code\n if(item.getCode == rule.getCode) \n # reset the price to the initial price to revert modifications\n item.refreshPrice \n # compute discount price based on rule\n item.setPrice(rule.getPercent ? item.getPrice * (1-rule.getValue) : item.getPrice - rule.getValue) \n end\n end\n end\n end\n end", "def line_total\n (@quantity * @price + line_item_sales_tax_total).round(2)\n end", "def apply_discount\n\n #Check if discount is applicable. Purchases is a hash with the stock item as\n # a key. disc_items is the list of items that have to be bought together\n # if the discount is to be applicable. For each of these the code checks to\n # see if the item is in the carts purcheses hash. If after this process\n # apply is still true then the relevant discount has to applied to each of the \n # purchases in the current discount list. \n apply = true\n \n @cart_disc_list.each { |d| d.disc_items.each {|v| \n \n\t apply = (apply && @purchases.has_key?(v)) \n }\n \n if (apply == true)\n # apply discount\n\n\t d.disc_items.each { |w| \n @purchases[w].discount = d.percentage_discount\n @purchases[w].adjusted_price -= \n (@purchases[w].price * @purchases[w].discount / 100 ) \n \t\t\t }\n\t end\n apply = true\n }\n end", "def discounted_price_for_customs\n hash[\"DiscountedPriceForCustoms\"]\n end", "def calculate_promotion_discount(product, product_promotion)\n case product_promotion.discount_type\n when '$'\n product_promotion.discount.to_f\n when '%'\n if product.street_price.to_f > 0.0\n product.street_price.to_f * (product_promotion.discount / 100)\n elsif product.msrp.to_f > 0.0\n product.msrp.to_f * (product_promotion.discount / 100)\n else\n 0.0\n end\n else\n 0.0\n end\n end", "def line_items_pre_tax_price\n @pre_tax ||= LineItem.total_price(unpaid_line_items)\n end", "def current_amount\n items.reduce(0) do |sum, item|\n sum + item.current_amount * item.price\n end\n end", "def membership_discount_total\n membership_fixed_total + membership_percent_total\n end", "def calculate_discount(price:, discount:, discount_type:)\n if discount_type == 'a'\n ((price.to_f - discount.to_f) * 100).round\n elsif discount_type == 'p'\n ((price.to_f / 100 * (100 - discount.to_f)) * 100).round\n else\n raise \"Unknown price discount type: #{discount_type}\"\n end\n end", "def unadjusted_total\n total = Money.new( 0, 'USD' )\n \n for line_item in line_items\n total += ( line_item.price * line_item.quantity )\n end\n \n total\n end", "def calculate_discount(inLX,inLXZero)\n Float(inLX) / Float(inLXZero)\n end", "def discount(discount_percent)\n # debugger\n discount = discount_percent / 100.00\n @price = @price - (@price * discount)\n end", "def total\r\n\t\tthe_cost = product[:wholesale_base_price] + option_value[:wholesale_extra_cost]\r\n\t\tthe_discount = product[:discount]\r\n\t\tabs_discount = product[:discount_is_abs]\r\n\r\n\t\tmultiplier = draft.priced ? 1.0 : 1.1\r\n\r\n\t\tProduct.discount_price(the_cost, the_discount, abs_discount) * quantity * multiplier\r\n\tend", "def price_after_discount(price, discount)\n return price - discount * (price / 100)\nend", "def payment_price_discount\n\t\t\t\t\treturn nil\n\t\t\t\tend", "def ticket_discount(user, paid: false)\n ticket_purchases.by_user(user).where(paid: paid).sum{ |tp| (tp.discount_value || 0) + (tp.discount_percent || 0) }\n end", "def total_price\r\n total = 0\r\n\r\n #Adds the prices of the orders up\r\n order_items.each do |order_item|\r\n total += order_item.item.price*order_item.quantity\r\n end\r\n\r\n #Applies any discounts\r\n if(campaign)\r\n discount = campaign.campaign_type.percentage_reduced\r\n if discount != 100\r\n total -= (total * discount / 100)\r\n elsif discount == 100\r\n i = []\r\n order_items.each do |order_item|\r\n i.push(order_item.item.price)\r\n end\r\n total -= i.min\r\n end\r\n end\r\n return total\r\n end", "def get_discount_percent( product )\n relation = self.product.relations.where( related_to: product ).first\n\n relation.try( :discount_percent) || 100\n end", "def apply_discount\nif @discount != nil \n @total -= (@total*@discount/100)\n \"After the discount, the total comes to $#{@total}.\"\nelse\n \"There is no discount to apply.\"\nend\nend", "def compute_total(total)\n if discount.eq?('percent')\n percent_value = amount.to_f / 100\n total = total - (total * percent_value)\n else\n total = total - amount\n (total < 0) ? 0 : total \n end \n end", "def amount_after_tax\n if waitlist_deduct_amount.present?\n amount_after_discounted + amount_of_tax - waitlist_deduct_amount\n else\n amount_after_discounted + amount_of_tax\n end\n end", "def cost\n (@items_cost - @promotion_adjustment).round(2)\n end", "def price_after_discount(price, discount)\n p = price - (price * discount / 100)\nend", "def discount_amount\n $tracer.trace(format_method(__method__))\n tt = ToolTag.new(@tag.find(\"td\")[2], format_method(__method__))\n return tt.inner_text\n end" ]
[ "0.8330925", "0.7665453", "0.76641643", "0.76087475", "0.7547135", "0.73917145", "0.73597383", "0.733183", "0.73027223", "0.7204924", "0.7191906", "0.7164064", "0.7102184", "0.7101042", "0.7099847", "0.7091651", "0.70402247", "0.70356846", "0.7035187", "0.70177925", "0.6939695", "0.6916783", "0.68836486", "0.6876017", "0.6850712", "0.6824803", "0.68210906", "0.6803302", "0.6800111", "0.67973685", "0.6783896", "0.6765578", "0.6747101", "0.6744122", "0.6743091", "0.6711446", "0.67090625", "0.66995823", "0.66925085", "0.66826296", "0.6663345", "0.6648571", "0.6647674", "0.6635847", "0.6631694", "0.6621969", "0.66107655", "0.66041774", "0.65999794", "0.6577702", "0.6550345", "0.65321094", "0.6515037", "0.65127784", "0.65086687", "0.64918894", "0.6482178", "0.6477837", "0.6470981", "0.6433228", "0.6410003", "0.6407775", "0.640605", "0.6399046", "0.6399046", "0.63835543", "0.63796896", "0.63668126", "0.63364285", "0.63116574", "0.63067424", "0.6278965", "0.62749285", "0.62749285", "0.62749285", "0.62638944", "0.62501234", "0.6249523", "0.62409794", "0.6209019", "0.6199237", "0.61774576", "0.61696106", "0.6166573", "0.6159163", "0.61541927", "0.61530787", "0.6144018", "0.61327904", "0.61315465", "0.6117692", "0.6117675", "0.6105022", "0.61002433", "0.6099734", "0.60818535", "0.60723615", "0.60699713", "0.6049421", "0.6039286" ]
0.8395994
0
Returns that total amount that will be charged for the line item taking into account any applicable discount.
def discounted_total line_item.total_in_cents - discount_amount end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def discount_on_line_item_total\n total_discount = 0\n\n line_item_promotions.each do |promotion|\n total_discount += discount_for_line_item_promotion(promotion)\n end\n\n total_discount\n end", "def discounted_total\n line_items = line_items_total\n fees = [item_fees_in_cents].sum\n credits = [customer_credits_total, promo_code_total].sum\n discounts = [membership_discount_total, quantity_discount_total].sum\n\n total = line_items + fees - credits - discounts\n [total, 0].max\n end", "def discountable_item_total\n tot = 0\n self.line_items.each do |li|\n tot += li.total if li.product.taxons.any? {|t| t.name == \"Discountable\"}\n end\n self.item_total = tot\n end", "def total_discounted_price\n # convert to array so it doesn't try to do sum on database directly\n line_items.to_a.sum(&:total_discounted_price)\n end", "def discounted_item_total\n ( self.item_total - self.discountable_item_total )\n end", "def discount_amount\n all_discounts = line_items.collect { |li| li.discounts }.flatten\n mapping = all_discounts.map(&:price_extend)\n # when we create the discount items, we need to set calculate their price_extend value\n mapping.sum\n end", "def total_amount\n line_items.reduce(Money.zero) { |a, e| a + e.total_amount_inc_tax }\n end", "def line_total\n (@quantity * @price + line_item_sales_tax_total).round(2)\n end", "def item_total\n @promotion_attributed_line_items.map(&:amount).sum\n end", "def discount_amount\n has_discount? ? (line_item.total_in_cents * discount.percentage/100.0).to_i : 0\n end", "def pre_tax_amount_from_line_item line_item\n amount = (line_item.discounted_amount - line_item.included_tax_total) / line_item.quantity\n\n Spree::Money.new(\n BigDecimal.new(amount.to_s).round(2, BigDecimal::ROUND_HALF_DOWN),\n currency: line_item.currency\n ).cents\n end", "def compute_amount(line_item)\n raise \"Adjustable does not match line item\" unless line_item == inventory_unit.line_item\n -(line_item.total.to_d / line_item.inventory_units.not_canceled.reject(&:original_return_item ).size)\n end", "def total\n sum = self.line_items.inject(BigDecimal('0.0')) { |sum, li| sum + li.price } +\n self.price_modifiers.inject(BigDecimal('0.0')) { |sum, pm| sum + pm.amount }\n return ApplicationHelper.round_currency(sum)\n end", "def total_amount\n sum = ::Money.new(1, self.currency)\n @line_items.each {|li| sum += li.total_amount}\n sum -= ::Money.new(1, self.currency)\n sum\n end", "def value_for_line_item(line_item)\n return 0 unless line_item_eligible?(line_item)\n line_item.total\n end", "def unadjusted_total\n total = Money.new( 0, 'USD' )\n \n for line_item in line_items\n total += ( line_item.price * line_item.quantity )\n end\n \n total\n end", "def get_total_price\n self.line_items.sum { |item| item.get_subtotal }\n end", "def total_discount(items)\n 0\n end", "def total\r\n\t\tthe_cost = product[:wholesale_base_price] + option_value[:wholesale_extra_cost]\r\n\t\tthe_discount = product[:discount]\r\n\t\tabs_discount = product[:discount_is_abs]\r\n\r\n\t\tmultiplier = draft.priced ? 1.0 : 1.1\r\n\r\n\t\tProduct.discount_price(the_cost, the_discount, abs_discount) * quantity * multiplier\r\n\tend", "def computeTotal\n # get rule for total\n rule = @rules.find{ |obj| obj.getCode == \"total\" } \n # sum item prices\n total = @items.inject(0){|sum, x| sum + x.getPrice} \n # if rule exists and condition is met, apply discount\n if rule && total > rule.getThreshold \n total = rule.getPercent ? total * (1-rule.getValue) : total - rule.getValue\n end\n return total\n end", "def vat_amount_from_line_item line_item\n amount = line_item.included_tax_total / line_item.quantity\n\n Spree::Money.new(\n BigDecimal.new(amount.to_s).round(2, BigDecimal::ROUND_HALF_UP),\n currency: line_item.currency\n ).cents\n end", "def calculate_item_amount_with_discount(item, user)\n\n item_bill_amount = calculate_item_amount(item.quantity, item.price)\n return item_bill_amount if item.is_grocery? \n\n\n return item_bill_amount - (item_bill_amount * get_discount_percentage(user))/100\n end", "def total_cost\n line_items.to_a.sum {|item| item.total_cost}\n end", "def total\n total_price = 0.0\n cart.line_items.each do |line_item|\n if !line_item.unit_price.blank?\n total_price += line_item.unit_price.to_f\n if line_item.line_item_options\n line_item.line_item_options.each do |line_item_option|\n total_price += line_item_option.price.to_f\n end\n end\n elsif line_item.menu_section_item\n total_price += line_item.menu_section_item.price.to_f\n if line_item.menu_item_options\n line_item.menu_item_options.each do |menu_item_option|\n total_price += menu_item_option.price.to_f\n end\n end\n else\n total_price += 0\n end\n end\n tax = total_price.to_f * 0.0825\n total_price = total_price + tax\n if tip\n total_price = total_price.to_f + tip.to_f\n end\n return total_price\n end", "def total\n total = 0\n line_items.each do |line_item|\n total += line_item.item.price * line_item.quantity\n end\n total\n end", "def compute_amount(line_item)\n adjustment_amount = calculator.compute(PartialLineItem.new(line_item))\n if !adjustment_amount.is_a?(BigDecimal)\n Spree::Deprecation.warn \"#{calculator.class.name}#compute returned #{adjustment_amount.inspect}, it should return a BigDecimal\"\n end\n adjustment_amount ||= BigDecimal.new(0)\n adjustment_amount = adjustment_amount.abs\n\n order = line_item.order\n line_items = actionable_line_items(order)\n\n actioned_line_items = order.line_item_adjustments.reload.\n select { |a| a.source == self && a.amount < 0 }.\n map(&:adjustable)\n other_line_items = actioned_line_items - [line_item]\n\n applicable_quantity = total_applicable_quantity(line_items)\n used_quantity = total_used_quantity(other_line_items)\n usable_quantity = [\n applicable_quantity - used_quantity,\n line_item.quantity\n ].min\n\n persist_quantity(usable_quantity, line_item)\n\n amount = adjustment_amount * usable_quantity\n [line_item.amount, amount].min * -1\n end", "def total_cost_items\n line_items.sum(&:total_cost_line_item)\n end", "def calculate_coupon_credit\n return 0 if order.line_items.empty?\n amount = adjustment_source.calculator.compute(order.line_items).abs\n amount = order.item_total if amount > order.item_total\n -1 * amount\n end", "def total_price\r\n total = 0\r\n\r\n #Adds the prices of the orders up\r\n order_items.each do |order_item|\r\n total += order_item.item.price*order_item.quantity\r\n end\r\n\r\n #Applies any discounts\r\n if(campaign)\r\n discount = campaign.campaign_type.percentage_reduced\r\n if discount != 100\r\n total -= (total * discount / 100)\r\n elsif discount == 100\r\n i = []\r\n order_items.each do |order_item|\r\n i.push(order_item.item.price)\r\n end\r\n total -= i.min\r\n end\r\n end\r\n return total\r\n end", "def total_price\n line_items.to_a.sum { |item| item.total_price}\n end", "def subtotal\n line_items.reduce(BigDecimal(\"0\")) { |result, item| result += item.amount }\n end", "def current_subtotal\n debt_claim_items.reject(&:marked_for_destruction?).sum(&:current_debt)\n end", "def total\n @total = items.inject(0.0) { |sum, order_line_item| sum + order_line_item.subtotal }\n end", "def total_price\n total = total_price_without_installments\n if promotions.any?\n adjustment = adjustments.eligible.map(&:amount).sum\n\n (total += adjustment).to_f\n end\n if line_items.any? { |li| li.request_installments == true }\n total = total / 5\n end\n total\n end", "def total\n cart_value = 0\n self.line_items.each do |line_item|\n cart_value += line_item.value\n end\n cart_value\n end", "def total_price\n line_items.to_a.sum { |item| item.total_price }\n end", "def total_price\n line_items.to_a.sum { |item| item.total_price }\n end", "def total_price\n line_items.to_a.sum { |item| item.total_price }\n end", "def total_price\n line_items.to_a.sum { |item| item.total_price }\n end", "def total_tax\n line_items.reduce(Money.zero) { |a, e| a + e.total_tax }\n end", "def total_unit_price\r\n\t\ttotal = self.unit_price\r\n\r\n\t\ttotal = Product.discount_price(total, discount, discount_is_abs)\r\n\r\n\t\tliovs = self.line_item_option_values\r\n\t\tliovs.each do |cur_liov|\r\n\t\t\ttotal += cur_liov.extra_cost\r\n\t\tend\r\n\r\n\t\ttotal\r\n#\t\tmultiplier = order.priced ? 1.0 : 1.1\r\n\r\n#\t\ttotal * multiplier\r\n\tend", "def total_price\n\t\tline_items.to_a.sum { |item| item.total_price }\n\tend", "def total_price\n line_items.to_a.sum {|item| item.total_price}\n end", "def amount\n estimate_total = self.estimate_line_items.sum(:amount)\n if self.tax_inclusive? \n tax_total = 0 \n else\n tax_total = 0 \n tax_line_items.each do |line_item|\n tax_account = line_item.account\n next if (tax_account.accountable_type=='DutiesAndTaxesAccounts' && tax_account.accountable.calculation_method==4 && tax_account.accountable.split_tax == 0) \n tax_total += line_item.amount\n end\n end\n ship_charge = self.shipping_line_items.sum(:amount)\n estimate_total + tax_total + ship_charge\n end", "def additional_shipping_total\n self.line_items.inject(0) { |total,line_item| total + line_item.variation.product.additional_shipping_cost }\n end", "def total_price\n\t\tline_items.to_a.sum{|item| item.total_price}\n\tend", "def cost\n (@items_cost - @promotion_adjustment).round(2)\n end", "def tax_total\n self.tax_amount = line_items.inject(0.to_money) {|sum,l| sum + l.tax_amount }\n self.tax_rate # calculates average rate, leave for compatibility reasons\n self.tax_amount\n end", "def total_price\n line_items.map { |line_item| line_item.item.price * line_item.quantity }.sum\n end", "def final_amount\n amount_paid - discount_value - discount_percent\n end", "def tax_total\n self.tax_amount = line_items.inject(0.to_money) {|sum,l| sum + l.tax_amount }\n self.tax_amount\n end", "def tax_total\n self.tax_amount = line_items.inject(Money.new(0, self.currency || Money.default_currency)) {|sum,l| sum + l.tax_amount }\n self.tax_rate # calculates average rate, leave for compatibility reasons\n self.tax_amount\n end", "def total\n total_invoice_items_price(invoice_items)\n end", "def calculate_coupon_credit\n return 0 if order.line_items.not_on_sale.empty?\n \n ###\n # Send only line items that have not been put on sale to the calculator\n ###\n amount = source.calculator.compute(order).abs\n amount = order.item_total if amount > order.item_total\n -1 * amount\n end", "def pre_discount_total\n sum(:pre_discount_total)\n end", "def total_price\n self.line_items.each.sum {|li| li.total_price}\n end", "def item_total\n line_items.map(&:total).reduce(:+)\n end", "def sub_total_price\n line_items.inject(0) {|sum, item| sum += item.price * item.qty }\n end", "def get_total\n counts = convert_to_hash(@item_list)\n uniq_items = @item_list.uniq\n\n final = (@total - @sale.apply(uniq_items, counts)).round(2) # Used round for precision\n puts get_invoice + final.to_s\n final\n end", "def total_price\n puts \"O PRECO TOTAL DE ORDER FOI CHAMADO\"\n self.line_items.to_a.sum{ |item| item.total_price}\n end", "def line_item_sales_tax_total\n\n ((pre_tax_total * 20).ceil.to_f / 20.0).round(2)\n end", "def line_items_pre_tax_price\n @pre_tax ||= LineItem.total_price(unpaid_line_items)\n end", "def total_amount_due_to_retailer\n shipping = self.retailer.reimburse_shipping_cost ? self.ship_total : 0.0\n product_cost = (self.line_items.collect {|line_item| line_item.product_cost_for_retailer }).sum\n self.tax_total + shipping + product_cost\n end", "def get_discounted_amount\n\t\tif self.discount.nil?\n\t\t\t0\n\t\telse\n\t\t\tself.amount * self.discount\n\t\tend\n\n end", "def tax_total\n self.tax_amount = line_items.inject(::Money.new(0, self.currency || ::Money.default_currency.iso_code)) {|sum,line| sum + line.tax_amount}\n self.tax_amount\n end", "def calculate_product_total(items_bought)\n result = items_bought * @price\n if @discount\n result -= @discount.apply(self, items_bought)\n end\n result \n end", "def calculate\n @item_list.each { |item|\n tax_rate = (item.exempt? ? 0.00 : Constants::NON_IMPORT_TAX_RATE) + (item.imported? ? Constants::IMPORT_TAX_RATE : 0.00)\n total_before_tax = item.qty * item.price\n tax = (total_before_tax * tax_rate).round_to_05\n\n @receipt_tax += tax\n @receipt_total += item.total = total_before_tax + tax\n }\n\n # do final rounding - needed due to Float quirks\n @receipt_tax = @receipt_tax.round(2)\n @receipt_total = @receipt_total.round(2)\n return self\n end", "def total\n self.line_items_total + self.shipping_cost\n end", "def total\n\t\tprices = line_items.map {|li| li.price}\n\t\tprices.reduce(0) {|it0, it1| it0+it1}\n\tend", "def total_before_tax\n self.delivery_price + self.items_sub_total\n end", "def total\n Money.new(self.expense_entries.sum('unit_cost_pence * qty'))\n end", "def total\n @items_total = []\n self.line_items.each do |item|\n @item = Item.find_by_id(item.item_id)\n @items_total << @item.price.to_f\n end\n cart_total = @items_total.inject(0){|sum, x| sum + x }\n @cart_total = cart_total.round(2)\n @cart_total\n end", "def discount_total_base\n total * (conv_discount / 100)\n end", "def apply(line_item)\n # Calculate the total discount for this line item\n line_discount = @amount * line_item.quantity\n\n # Calculated the discounted line price\n new_line_price = line_item.line_price - line_discount\n\n # Apply the new line price to this line item with a given message\n # describing the discount, which may be displayed in cart pages and\n # confirmation emails to describe the applied discount.\n line_item.change_line_price(new_line_price, message: @message)\n\n # Print a debugging line to the console\n puts \"Discounted line item with variant #{line_item.variant.id} by #{line_discount}.\"\n end", "def calculate_net_amount\n @items.each do |item|\n item.price_after_discount = @discount_processor.calculate_item_amount_with_discount(item, @user)\n end\n\n #total items bill amount\n items_total = @items.map(&:price_after_discount).reduce(:+)\n\n #applying discount on total amount.\n @discount_processor.apply_discount_on_total(items_total)\n end", "def total_cost\n return (date_range.end_date - date_range.start_date) * (200 * (1 - discount))\n end", "def sub_total\n sum = 0\n line_items.each do |line_item|\n sum += line_item.total_price\n end\n sum\n end", "def total_before_tax\n total = 0\n @cart_items.each do |item|\n total += item.price\n end\n return total\n end", "def discount_for_category(line_items)\n item_counter = max_items || 1000\n product_or_group = apply_to_type == 'product' ? apply_to_product.name : apply_to_group\n line_items\n .select { |l| l.send(apply_to_type).to_s == product_or_group }\n .sort_by { |l| -l.unit_price }\n .take(max_items.nil? ? 1000 : max_items)\n .reduce(0) do |sum, line_item|\n total_quantity = max_items.nil? ? line_item.quantity : [item_counter, line_item.quantity].min\n if item_counter < 1\n # If we've gone over our limit for max_items, don't add anymore to the discount\n sum\n else\n item_counter -= total_quantity\n total_amount = amount * total_quantity\n if discount_type == 'fixed'\n sum + (total_amount > line_item.total_price ? line_item.total_price : total_amount)\n elsif discount_type == 'percentage'\n sum + (line_item.unit_price * total_quantity * amount * 0.01).round(2)\n end\n end\n end\n end", "def fulfillment_fee\n\t line_items.inject(0.0) {|charge, line_item| charge = charge + (line_item.fulfillment_fee)}\n end", "def sub_total\n return ApplicationHelper.round_currency(self.line_items.inject(BigDecimal('0.0')) { |sum, li| sum + li.price })\n end", "def total_before_tax\n order.delivery_price + items_sub_total\n end", "def final_price\n price * (100 - discount) / 100\n end", "def flow_line_item_price line_item, total=false\n result = unless flow_order\n Flow.format_default_price(line_item.price * (total ? line_item.quantity : 1))\n else\n id = line_item.variant.id.to_s\n\n lines = flow_order.lines || []\n item = lines.select{ |el| el['item_number'] == id }.first\n\n return Flow.price_not_found unless item\n\n total ? item['total']['label'] : item['price']['label']\n end\n\n # add line item promo\n # promo_total, adjustment_total\n result += ' (%s)' % Flow.format_default_price(line_item.promo_total) if line_item.promo_total > 0\n\n result\n end", "def calculate_invoice_total\n res = [ ]\n self.line_items.each do |item|\n res.push(item.qty * item.price)\n end\n # Return the sum of the items\n self.total = res.inject(:+) \n end", "def grand_total\n order_lines.inject(Money.new(0)) { |grand_total, line| grand_total + line.total_price }\n end", "def amount(include_discount = true)\r\n include_discount && @discount && @discount.apply_to_recurring? ? self[:amount] - @discount.calculate(self[:amount]) : self[:amount]\r\n end", "def current_amount\n items.reduce(0) do |sum, item|\n sum + item.current_amount * item.price\n end\n end", "def total_amount\n self.tickets.inject(0) do |amount, ticket|\n amount += ticket.price_minus_discount\n end\n end", "def calculated_total\n variant_ids = self.standing_line_items.pluck(:variant_id)\n avvs = self.account.account_viewable_variants.where(variant_id: variant_ids).to_a\n\n self.standing_line_items.includes(:variant).inject(0.to_d) do |sum, i|\n avv = avvs.select{|avv| avv.variant_id == i.variant_id}.first\n if avv\n sum + (avv.price * i.quantity)\n else\n sum + (i.variant.price * i.quantity)\n end\n end\n end", "def total_amount_before_modifier\n sale_amount + discount_amount + tax_amount + shipping_amount\n end", "def item_total\n tot = 0\n self.line_items.each do |li|\n tot += li.total\n end\n self.item_total = tot\n end", "def total_full_price\n # convert to array so it doesn't try to do sum on database directly\n line_items.to_a.sum(&:total_full_price)\n end", "def balance_owed\n discounted_price - amount_paid\n end", "def refund_amount_for(item_return)\n item_return.line_item.price\n end", "def total_with_tax\n total = 0\n @cart_items.each do |item|\n total += item.total_price\n end\n return total\n end", "def total_cost\n order_items.map { |order_item| order_item.subtotal }.sum.round(2)\n end", "def total_price\n # convert to array so it doesn't try to do sum on database directly\n @total = 0\n line_items.each do |item|\n @total = item.price\n end\n line_items.to_a.sum {|item| (item.quantity * item.price) }\n end", "def line_items_total\n\t\ttotal = 0\n\t\tfor item in self.order_line_items\n\t\t\ttotal += item.total\n\t\tend\n\t\treturn total\n\tend", "def total\n regular_total = sub_total\n if used_promo\n regular_total -= discount_from_promo\n end\n regular_total >= 0 ? (\"%.2f\" % regular_total).to_f : 0.0 \n end" ]
[ "0.8150358", "0.79515874", "0.79193884", "0.7789169", "0.76566005", "0.76113844", "0.7552692", "0.7522501", "0.7505379", "0.7482933", "0.74801713", "0.7440243", "0.73556066", "0.7262891", "0.7222655", "0.71931213", "0.7141181", "0.7126781", "0.71064097", "0.70661384", "0.70492244", "0.7043839", "0.70078695", "0.69854265", "0.69738597", "0.69715863", "0.69666934", "0.6963726", "0.6957913", "0.69571316", "0.6950748", "0.6935849", "0.69214606", "0.69185233", "0.6915488", "0.69153994", "0.69153994", "0.69153994", "0.69153994", "0.69128996", "0.69096357", "0.6898144", "0.68724304", "0.68663067", "0.686386", "0.68579084", "0.68514", "0.6844797", "0.68365633", "0.68328327", "0.6830495", "0.68227303", "0.6821039", "0.68086517", "0.6808379", "0.6807148", "0.68065053", "0.6783707", "0.67814434", "0.6777679", "0.67761785", "0.67753166", "0.67723835", "0.6767471", "0.6751632", "0.6750826", "0.6744586", "0.67433065", "0.6742436", "0.67406803", "0.6738275", "0.67119455", "0.6708618", "0.6697046", "0.6684111", "0.66770357", "0.6676878", "0.6658881", "0.664807", "0.6647165", "0.66464466", "0.66287243", "0.6626126", "0.6606726", "0.65982246", "0.6594779", "0.6581024", "0.65787005", "0.65776944", "0.6573345", "0.65726", "0.65659577", "0.6560774", "0.6559431", "0.65584517", "0.6557146", "0.6556638", "0.6542669", "0.65401155", "0.651811" ]
0.85232097
0
Part 1: How big is the subgraph containing '0' Essentially generated by a breadth first search
def subgraph_with(vertex) vertices = Set.new edges = Set.new pending = [vertex] until pending.empty? this_node = pending.shift conn_edges, conn_nodes = neighbors(this_node) conn_nodes.each do |node| pending << node unless vertices.include?(node) end vertices << this_node edges << conn_edges end PipeGraph.new(edges, vertices) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_order_bfs\n queue = []\n @num_courses.times { |v| queue.push(v) if @in_degrees[v].zero? } # 入度为0的全都放入\n\n visited = []\n until queue.empty?\n node_key = queue.shift\n\n visited.unshift(node_key) # 注意顺序\n\n @nodes[node_key]&.each do |neighbor|\n @in_degrees[neighbor] -= 1\n queue.push(neighbor) if @in_degrees[neighbor].zero?\n end\n end\n\n visited.size == @num_courses ? visited : []\n end", "def size\n @graphs.inject(0) {|memo, g| memo += g.size}\n end", "def calc\n # If the searches have not started\n if breadth_first_search.visited.empty?\n # Calculate the two searches\n calc_breadth_first\n calc_dijkstra\n end\n end", "def bfs(g,s)\r\n q = []\r\n dists = Hash.new(Float::INFINITY)\r\n curr = s\r\n dists[curr] = 0\r\n \r\n #q += g[curr].each_index.select {|v| v != s && !dists.include?(v) && g[curr][v] == 1 }.map {|v| [curr,v] }\r\n g[curr].each.with_index {|e,v| q.push [curr,v] if v != s && e == 1 && !dists.include?(v)}\r\n while q.size > 0\r\n \tprev,curr = q.shift\r\n dists[curr] = [6 + dists[prev],dists[curr]].min\r\n #q += g[curr].each_index.select {|v| v != s && !dists.include?(v) && g[curr][v] == 1 }.map {|v| [curr,v] }\r\n g[curr].each.with_index {|e,v| q.push [curr,v] if v != s && e == 1 && !dists.include?(v)}\r\n #prev,curr = q.shift\r\n end\r\n \r\n return dists\r\nend", "def size\n\t\[email protected]\n\tend", "def DFSb(v, vf) #wyszukiwanie mostow w grafie\n $d[v] = $cv\n low = $cv\n $cv = $cv + 1\n 0.upto($n-1) do |i|\n if $a[v][i] > 0 and i != vf\n if $d[i] == 0\n temp = DFSb(i, v)\n low = temp if temp < low\n else\n low = $d[i] if $d[i] < low\n end\n end\n end\n if vf > -1 and low == $d[v]\n $a[vf][v] = 2\n $a[v][vf] = 2\n end\n return low\nend", "def full_tree_node_count(min_capacity)\n full_tree_leaf_count(min_capacity) * 2 - 1\n end", "def breadth_first(value)\n\tend", "def breadth_first_search(root)\n visited = {}\n distance = {}\n predecessor = {}\n\n visited[root] = true\n distance[root] = 0\n predecessor[root] = nil\n\n queue = [ root ]\n\n while from = queue.shift\n\tnext unless @graph[from]\n\t@graph[from].each_key do |to|\n\t unless visited[to]\n\t visited[to] = true\n\t distance[to] = distance[from] + 1\n\t predecessor[to] = from\n\t queue.push(to)\n\t end\n\tend\n end\n return distance, predecessor\n end", "def height\n return 0 if is_empty\n\n queue = [@root]\n height = 0\n\n while true\n node_count = queue.length\n\n return height if node_count == 0\n\n height += 1\n\n while node_count > 0\n node = queue.shift()\n\n queue << node.left unless node.left.nil?\n queue << node.right unless node.right.nil?\n\n node_count -= 1\n end\n end\n end", "def size_without_recursion\n count = 0\n return 0 unless @root\n q = QueueWithLinkedList.new\n q.enqueue(@root)\n while !q.isEmpty?\n node = q.dequeue\n count += 1\n q.enqueue(node.left) if node.left\n q.enqueue(node.right) if node.right\n end\n count\n end", "def leaf_count\n @leaf_count\n end", "def river_sizes(matrix)\n sizes = []\n visited = Array.new(matrix.length, Array.new(matrix[0].length, false))\n\n (0..matrix.length - 1).each do |i|\n (0..matrix[i].length - 1).each do |j|\n next if visited[i][j]\n traverse_node(i, j, matrix, visited, sizes) \n end\n end\n\n sizes\nend", "def calculate_g(neighbor)\n total_g = 0\n branching_dup = dup_hash(@branching_paths)\n loop do\n parent = branching_dup[neighbor]\n if diagonal_move?(parent, neighbor)\n total_g += 14\n else\n total_g += 10\n end\n break if neighbor == @maze.find_start\n neighbor = parent\n end\n total_g\n end", "def number_of_edges\n @adj.values.map(&:length).inject(:+)\n end", "def size\n counter = 0\n each { |node| counter += 1 }\n return counter\n end", "def count(g, u, v)\n g.vertices.each do |v|\n v.data = 0\n v.parent = nil\n end\n\n dfs_count(g, u, v)\n v.data\nend", "def breadth_first_search(root)\n visited = {}\n distance = {}\n predecessor = {}\n\n visited[root] = true\n distance[root] = 0\n predecessor[root] = nil\n\n queue = [ root ]\n\n while from = queue.shift\n next unless @graph[from]\n @graph[from].each_key do |to|\n unless visited[to]\n visited[to] = true\n distance[to] = distance[from] + 1\n predecessor[to] = from\n queue.push(to)\n end\n end\n end\n return distance, predecessor\n end", "def challenge4\n\t@size = length(@rootNode)\n\tputs \"Challenge #4 solution: \"\n\tputs \"Number of nodes in tree: \" + @size.to_s\n\tputs \"-----------------------------------\"\nend", "def load_factor\n total_nodes = 0.0\n index = -1\n @items.each do |item|\n index = index + 1\n if item != nil\n total_nodes = total_nodes + item.count\n end\n end\n factor = total_nodes / size\n if factor > 0.7\n resize\n end\n return factor\n end", "def segment_count\n children.map(&:segment_count).inject(:+).to_i + 2\n end", "def children_size\n leaf? ? 0 : children.map(&:size).reduce(:+)\n end", "def use_breadth_first(item, graph, logic_function = ->(x){graph[x].empty?} , returned = \"steps\" )\r\n search_queue = []\r\n steps = {}\r\n search_queue = search_queue.concat(graph[item])\r\n searched = []\r\n #Setting up initial steps \r\n if !search_queue.empty?\r\n search_queue.each do |term|\r\n steps[term] = 1\r\n end\r\n end\r\n #Here goes the graph algorithm\r\n while !search_queue.empty?\r\n person = search_queue.shift()\r\n if !( searched.include?(person) )\r\n\r\n if logic_function.call(person)\r\n if returned == \"steps\"\r\n return steps[person]\r\n end\r\n if returned == \"found\"\r\n return true\r\n end\r\n else\r\n if !(graph[person].nil?) \r\n graph[person].each do |related|\r\n steps[related] = steps[person] + 1 #Setting up the steps of parents of the current element in the queue\r\n end\r\n search_queue = search_queue.concat(graph[person])\r\n end\r\n end\r\n\r\n end\r\n end\r\n return false\r\nend", "def in_degree\n @in_edges.length\n end", "def depth_min; depths.min end", "def number_of_half_nodes_in_binary_tree(root)\n return 0 if !root\n count = 0\n queue = Queue.new()\n queue.enqueue(root)\n while(!queue.is_empty?)\n node = queue.dequeue\n\n count += 1 if (node.left_child && !node.right_child) || (!node.left_child && node.right_child)\n\n queue.enqueue(node.left_child) if node.left_child\n queue.enqueue(node.right_child) if node.right_child\n end\n count\nend", "def depth_first_search\n visited = {}\n timestamp = {}\n tree_edges = {}\n back_edges = {}\n cross_edges = {}\n forward_edges = {}\n count = 0\n\n # begin workaround removing depencency to order of Hash#each\n if @index.empty? then\n preference_of_nodes = nil\n else\n preference_of_nodes = {}.merge(@index)\n i = preference_of_nodes.values.max\n @graph.each_key do |node0|\n preference_of_nodes[node0] ||= (i += 1)\n end\n end\n # end workaround removing depencency to order of Hash#each\n\n dfs_visit = Proc.new { |from|\n visited[from] = true\n timestamp[from] = [count += 1]\n ary = @graph[from].keys\n # begin workaround removing depencency to order of Hash#each\n if preference_of_nodes then\n ary = ary.sort_by { |node0| preference_of_nodes[node0] }\n end\n # end workaround removing depencency to order of Hash#each\n ary.each do |to|\n if visited[to]\n if timestamp[to].size > 1\n if timestamp[from].first < timestamp[to].first\n \t# forward edge (black)\n \tp \"#{from} -> #{to} : forward edge\" if $DEBUG\n \tforward_edges[from] = to\n else\n \t# cross edge (black)\n \tp \"#{from} -> #{to} : cross edge\" if $DEBUG\n \tcross_edges[from] = to\n end\n else\n # back edge (gray)\n p \"#{from} -> #{to} : back edge\" if $DEBUG\n back_edges[from] = to\n end\n else\n # tree edge (white)\n p \"#{from} -> #{to} : tree edge\" if $DEBUG\n tree_edges[to] = from\n dfs_visit.call(to)\n end\n end\n timestamp[from].push(count += 1)\n }\n\n ary = @graph.keys\n # begin workaround removing depencency to order of Hash#each\n if preference_of_nodes then\n ary = ary.sort_by { |node0| preference_of_nodes[node0] }\n end\n # end workaround removing depencency to order of Hash#each\n ary.each do |node|\n unless visited[node]\n dfs_visit.call(node)\n end\n end\n return timestamp, tree_edges, back_edges, cross_edges, forward_edges\n end", "def bfs(v)\n curr = v\n queue = []\n distances = Hash.new(0)\n queue.push(curr)\n distances[curr] = 0\n while !queue.empty?\n curr = queue.shift\n dst = distances[curr] + 1\n if @hypernyms.include?(curr)\n queue += @hypernyms[curr]\n end\n queue.each do |v|\n \n distances[v] = dst if !distances.include?(v)\n end\n end\n distances\n end", "def recalculate(inode)\n full_count = 0\n inode.list_of_children.each do |node|\n#p node\n komvos = self.get(node)\n#p komvos\n if komvos.normalize==0\n puts \"node #{node} is not leaf\"\n # if not leaf\n #recalc(holon.searchFor(node).listOfChildren)\n self.recalculate(komvos)\n else \n # exw kanei: node.normalize kai einai leaf\n puts \"node #{node} is leaf\"\n \n end\n # uplogizw to sum of coun and re-normalize\n full_count = full_count + komvos.weight\n end\n inode.weight = full_count\n end", "def hard(input)\n graph = Graph.from(input)\n components = []\n vertices = Set.new(graph.vertices)\n until vertices.empty?\n start = vertices.first\n component = graph_walk(graph, start)\n components << component\n vertices = vertices.difference(component)\n end\n components.length\nend", "def solution(x, a)\n leaves = {}\n path = 0\n for i in (0..a.count - 1)\n leaf = a[i]\n if leaf <= x\n unless leaves[leaf]\n path += 1 \n return i if path == x\n end\n leaves[leaf] = true\n end\n end\n return -1\nend", "def cliquishness(node)\n neighbors = @graph[node].keys\n sg = subgraph(neighbors)\n if sg.graph.size != 0\n edges = sg.edges\n nodes = neighbors.size\n complete = (nodes * (nodes - 1))\n return edges.quo(complete)\n else\n return 0.0\n end\n end", "def edges\n edges = 0\n @graph.each_value do |v|\n edges += v.size\n end\n edges\n end", "def solve\n graph = Graph.create(words, WordNode)\n graph.connect_nodes(:one_char_diff)\n\n end_node = graph.nodes_hash[end_word]\n start_node = graph.nodes_hash[start_word]\n start_node.cost = 0\n\n heap = Containers::Heap.new { |a, b| (a.cost <=> b.cost) == -1 }\n graph.nodes_hash.each do |k, v|\n heap.push v\n end\n\n puts heap.size\n # puts \"is empty?#{heap.empty?}\"\n until heap.empty? do\n current_node = heap.pop\n puts current_node.value, current_node.cost\n # puts current_node == end_node\n # puts current_node.value, end_node.value\n return graph.path(end_node) if current_node == end_node\n\n current_node.connected_nodes.each do |node|\n\n # puts node.visited\n unless node.visited\n cost = current_node.cost + 1\n if cost < node.cost\n node.cost = cost\n node.parent = current_node\n # puts \"changed parent\"\n # puts node.parent\n end\n end\n end\n\n current_node.visited = true\n end\n end", "def depth_iter(root=@root)\n return 0 if root.nil? # height of an empty tree is 0\n \n s = []\n h = 1\n s.push [root, h]\n loop do\n break if s.empty?\n node, _h = s.pop\n # nothing to do with node.val\n h = _h if h < _h # interested by the max\n s.push [node.rnode, _h+1] if node.rnode\n s.push [node.lnode, _h+1] if node.lnode\n end\n h\n end", "def size\n return 0 if empty?\n count_node(head, 1)\nend", "def with_rows_and_height\n root = self\n queue = [root]\n visited = []\n\n until queue.empty?\n current = queue.shift\n adjacency_list = current.children\n\n self.height += 1\n adjacency_list.each do |node|\n root.rows << (node.nil? ? \"x\" : node.value)\n next if node.nil?\n visited << node.value\n\n if node.distance == Float::INFINITY\n node.distance = current.distance + 1\n node.parent = current\n queue.push(node)\n end\n end\n end\n\n self\n end", "def solve_bfs(initial, final)\n\tunvisited = [initial]\n\tvisited = Set.new unvisited\n\n\twhile not unvisited.empty?\n\t\tc = unvisited[0]\n\t\tunvisited.delete_at 0\n\n\t\treturn c.n_moves if c.eql? final\n\t\tneighbours = c.moves.select { |x| not visited.include? x }\n\t\tunvisited.concat(neighbours)\n\t\tvisited.merge neighbours\n\tend\n\tNO_SOLUTION\nend", "def calculate_num_children\n for x in @lattice do\n for c in @lattice.lower_covers[x] do\n if @irreducibles.contain?(c) then\n @num_children[x] += 1\n end\n end\n end\n end", "def load_factor\n total_size = 0\n @items.each do |list|\n unless list == nil\n node = list.head\n while node != nil\n total_size += 1\n node = node.next\n end\n end\n end\n total_size.to_f / @items.count\n end", "def orbit_count\n return 0 unless @root\n sum_of_depths = 0\n nodes_to_traverse = [{ node: @root, depth: 0 }]\n until nodes_to_traverse.empty?\n node_pair = nodes_to_traverse.shift\n node = node_pair[:node]\n depth = node_pair[:depth]\n sum_of_depths += depth\n node.children.each { |child| nodes_to_traverse << { node: child, depth: depth + 1 } }\n end\n sum_of_depths\n end", "def maxCircle(queries)\n @parent = {}\n @size = {}\n @node_id = {}\n @id_node = {}\n id = 1\n res = []\n @max_size = 0\n queries.each do |edge|\n a, b = edge\n\n id = new_node a, id unless @parent[a]\n id = new_node b, id unless @parent[b]\n\n size = union_find(a, b) || 0\n @max_size = [@max_size,size].max\n res << @max_size\n # res << max_val(@size)\n # p res.size\n # p sizes(res)\n end\n res\nend", "def printBreadthFirst()\n # println(\"printBreadthFirst\");\n #\n # // queues for pushing and saving all elements in \"breadth first search\" style\n # ArrayList items = new ArrayList();\n # ArrayList depths = new ArrayList();\n # ArrayList indicesParent = new ArrayList();\n #\n # // add first elements and startingpoint\n # items.add(this);\n # depths.add(0);\n # indicesParent.add(-1);\n #\n # // tmp vars for running in while loop\n # int index = 0;\n # int itemCount = 1;\n #\n # while (itemCount > index) {\n # FileSystemItem item = (FileSystemItem) items.get(index);\n # int depth = (Integer) depths.get(index);\n # int indexToParent = (Integer) indicesParent.get(index);\n #\n # // print four spaces for each level of depth + debug println\n # for (int i = 0; i < depth; i++) print(\" \");\n # println(index+\" \"+indexToParent+\"<-->\"+index+\" (\"+depth+\") \"+item.file.getName());\n #\n # // is current node a directory?\n # // yes -> push all children to the end of the items\n # if (item.file.isDirectory()) {\n # for (int i = 0; i < item.childCount; i++) {\n # items.add(item.children[i]);\n # depths.add(depth+1);\n # indicesParent.add(index);\n # }\n # itemCount += item.childCount;\n # }\n # index++;\n # }\n # println(index+\" files\");\n end", "def depth_max; depths.max end", "def height_edges(root)\n return -1 if root == nil\n\n left = height_edges(root.left)\n right = height_edges(root.right)\n\n if left > right\n h = 1 + left\n else\n h = 1 + right\n end\n\n return h\n\nend", "def strongly_connected_components\n\t\t@explored_nodes = Array.new(size, false)\n\t\t@finishing_time_arr = Array.new(size)\n\t\t@scc = Array.new\n\t\t@dfs_queue = Array.new\n\t\t@finishing_time_queue = Array.new\n\t\t@finishing_time = 0\n\t\tcalculate_finishing_time\n\t\t@leaders = scc_call_order\n\t\tcalculate_scc\n\t\tputs \"#{@scc.map(&:count).sort.reverse.take(5)}\"\n\tend", "def size\n return @tree.size\n end", "def analyze\n max_chain = 0\n min_chain = @count\n num_chains = 0\n @table.each do |node|\n chain_length = 0\n num_chains += 1 if node\n while node\n node = node.next\n chain_length += 1\n end\n max_chain = chain_length if max_chain < chain_length\n min_chain = chain_length if chain_length < min_chain\n end\n return \"Load factor: #{1.0*@count/@table.size}\\n\" +\n \"Table density: #{1.0*num_chains/@table.size}\\n\" +\n \"Mimumum chain: #{min_chain}\\n\" +\n \"Maximum chain: #{max_chain}\"\n end", "def part_1\n nodes = Set.new([SHINY_GOLD])\n growing = true\n size = nodes.size\n\n while growing\n @bag_rules.each do |key, bags|\n nodes.add(key) if bags.keys.to_set.intersect?(nodes)\n end\n growing = size != nodes.size\n size = nodes.size\n end\n\n nodes.size - 1\n end", "def bc_count\n \[email protected] + @initial.size + @final.size + @cyclic.size\n end", "def height\n height_recursive(@root)\n end", "def overruns\n if self.left >= 0\n return 0\n else\n return self.left * -1\n end\n end", "def breadth_first(a=[])\n unless a.length == 0\n s = []\n a.each do |z|\n if z.key?('v')\n print \"#{z['v']} \"\n s.push(z['l'])\n s.push(z['r'])\n end\n end\n breadth_first(s)\n end\n \nend", "def size(node)\n if node.nil?\n return 0\n elsif node.left_child.nil? && node.right_child.nil?\n return 1\n else\n left_size = size(node.left_child)\n right_size = size(node.right_child)\n return left_size + 1 + right_size\n end\nend", "def total_n_queens_proto(n)\n base=[]\n n.times do\n base.push Array.new(n, 0)\n end\n result=[]\n result[0]=0\n dfs(base, n, -1, 0, result)\n #[result.size, result]\n result[0]\nend", "def bnodes\n @graphs.inject([]) {|memo, g| memo += g.bnodes}\n end", "def bfs\n\n\n end", "def analyze\n max_chain = 0\n min_chain = @count\n num_chains = 0\n @table.each do |node|\n chain_length = 0\n num_chains += 1 if node\n while node\n node = node.next\n chain_length += 1\n end\n max_chain = chain_length if max_chain < chain_length\n min_chain = chain_length if chain_length < min_chain\n end\n \"Load factor: #{1.0*@count/@table.size}\\n\" +\n \"Table density: #{1.0*num_chains/@table.size}\\n\" +\n \"Mimumum chain: #{min_chain}\\n\" +\n \"Maximum chain: #{max_chain}\"\n end", "def size\n @nodes.length\n end", "def size\n @nodes.length\n end", "def numPaths(start_from, vertices,edge_weights)\n graph = RGL::DirectedAdjacencyGraph.new\n graph.add_vertices vertices\n edge_weights.each { |(bag1, bag2), w| graph.add_edge(bag1, bag2) }\n\n num_paths = 0\n vertices.map do |vert|\n unless vert.eql?(start_from)\n num_paths+=1 if graph.path?(start_from,vert)\n end\n end\n num_paths\nend", "def load_factor\n node_count = 0.0\n \n @items.each do |item|\n if item != nil\n current_node = item.head\n while current_node != nil\n node_count += 1\n current_node = current_node.next\n end\n end\n end\n @max_load_factor = (node_count / @items.size)\n if @max_load_factor > 0.70\n self.resize\n self.load_factor\n else\n @max_load_factor\n end\n end", "def size\n @nodes.size\n end", "def solve_biro_recursion\n\t\ttime do\n\t\t\tans = self.biro_recursion(@size, @size)\n\t\t\tputs \"The number of routes through a #{@size}x#{@size} grid is #{ans}.\"\n\t\tend\n\tend", "def size\n count = 0\n visit_nodes do\n count += 1\n end\n count\n end", "def small_world\n freq = Hash.new(0)\n @graph.each_value do |v|\n freq[v.size] += 1\n end\n return freq\n end", "def size\n @root and @root.size or 0\n end", "def half_nodes_count(root)\n if root.nil?\n puts 'Empty tree'\n return\n end\n half_nodes_count = 0\n queue = QueueWithLinkedList.new\n queue.enqueue(root)\n while !queue.isEmpty?\n node = queue.dequeue\n half_nodes_count += 1 if ((node.left && !node.right) || (!node.left && node.right))\n queue.enqueue(node.left) if node.left\n queue.enqueue(node.right) if node.right\n end\n half_nodes_count\n end", "def small_world\n freq = Hash.new(0)\n @graph.each_value do |v|\n\tfreq[v.size] += 1\n end\n return freq\n end", "def size(tree)\n if isEmpty?(tree)\n 0\n else\n 1 + size(tree.left) + size(tree.right)\n end\nend", "def min_depth\n return 0 if @poss.empty?\n @poss[0].length\n end", "def binary_serach_all_zero_row(top, bottom)\n mid_index = top + (bottom - top) / 2\n all_zeros = true\n\n if bottom < top\n bottom = top\n end\n\n if top > bottom\n top = bottom\n end\n\n if top == bottom\n mid_index = top\n end\n\n if @not_all_zero_row_index[mid_index]\n all_zeros = false\n else\n unless @all_zero_row_index[mid_index]\n lower, upper = get_optimized_col_bounds\n (lower..upper).each do |i|\n cell = @matrix[mid_index][i]\n\n if cell != 0\n all_zeros = false\n @not_all_zero_col_index[i] = true\n @not_all_zero_row_index[mid_index] = true\n @number_of_cell_visited += 1\n break\n end\n\n @number_of_cell_visited += 1\n end\n\n @all_zero_row_index[mid_index] = true\n end\n end\n\n if all_zeros\n return mid_index\n elsif top == bottom\n return nil\n else\n new_top = mid_index + 1\n new_bottom = bottom\n result = binary_serach_all_zero_row(new_top, new_bottom)\n return result if result\n\n new_top = top\n new_bottom = mid_index - 1\n return binary_serach_all_zero_row(new_top, new_bottom)\n end\n end", "def num_edges()\n edgeNum = 0\n @source.values.each do |x|\n edgeNum += x.size()\n end\n return edgeNum/2\n end", "def contig_generation(kmers_a)\n graph = debruijn_graph_from_kmers(kmers_a)\n # puts graph.keys.length\n # puts graph.values.flatten.length\n # puts graph\n return maximal_non_branching_paths(graph)\n end", "def vertex_count\n @graph.length\n end", "def a_star_search(tiles_order)\n tree = []\n leaves = []\n solution = [1, 2, 3, 4, 5, 6, 7, 8, 9]\n\n leaf = build_leaf(tiles_order, {tiles_order: nil, branch: []})\n\n i = 0\n while i < 6000 && leaf[:tiles_order] != solution\n i += 1\n tree << leaf[:tiles_order]\n new_buds = neighbor_boards(leaf[:tiles_order])\n new_buds.each do |bud|\n leaves << build_leaf(bud, leaf) unless tree.include? bud\n end\n leaf = pop_cheapest_leaf(leaves)\n\n p \"iterations = #{i}\"\n p \"depth = #{leaf[:branch].length}\"\n p \"manhattan distance = #{leaf[:m_distance]}\"\n p \"tiles_order = #{leaf[:tiles_order]}\"\n\n return leaf[:branch] if leaf[:tiles_order] == solution\n end\n end", "def size_all\n\t\tfname=\"Node:#{__method__}\"\n\t\tret=0\n\t\tlevel=0\n\t\tbegin\n\t\t\tret=self.size_all_(ret, level)\n\t\trescue Exception=>e\n\t\t\tLOG.error(fname){\"EXCEPTION during nodes size calculation: #{e} \"}\n\t\tret=-1\n\t\tend\n\t\tret\n\tend", "def calculate_path_size\n t0 = Time.now\n path_sizes = {0 => 0.0, 1 => 0.0, 2 => 0.0, 4 => 0.0, 10 => 0.0, Float::INFINITY => 0.0}\n\n # Retrieves all routes provenient from the same trip\n sibling_routes = AlternateRoute.where(:trip_id => @route.trip_id)#.where(\"state != 'discarded'\")\n\n # Get segment-based mileage for all sibling routes\n sibling_routes_mileage = calculate_routes_mileage(sibling_routes)\n\n # Remove the main route from sibling routes group\n sibling_routes = (sibling_routes.map{|r| r.id} - [@route.id])\n\n # Generate frequencies of each route segment over alternate routes\n frequencies = {}\n appearances = Segment.where(:osm_way_id => @segment_ids).group_by {|s| s.osm_way_id}\n appearances.each do |k, v|\n frequencies[k] = v.map{|e| e.alternate_route_id}.uniq - [nil]\n end\n\n @route.segments.each do |segment|\n segment_length = segment.length\n\n impedance = segment_length/sibling_routes_mileage[@route.id]\n\n # Get all sibling routes where the current segment is used\n ocurrences = frequencies[segment.osm_way_id] & sibling_routes\n #ocurrences = AlternateRoute.joins(:segments).where(:id => sibling_routes).where(\"segments.osm_way_id = ?\", segment.osm_way_id).references(:segments).pluck(:id).uniq\n\n path_sizes.keys.each do |gamma|\n sums = {0 => 1.0, 1 => 1.0, 2 => 1.0, 4 => 1.0, 10 => 1.0, Float::INFINITY => 1.0}\n\n ocurrences.each do |route|\n if gamma == Float::INFINITY\n # if (sibling_routes_mileage[@route.id]/sibling_routes_mileage[route]) > 1.0\n if (sibling_routes_mileage.values.min/sibling_routes_mileage[route]) > 1.0\n sums[gamma] = 0.0\n end\n else\n # sums[gamma] += (sibling_routes_mileage[@route.id]/sibling_routes_mileage[route])**gamma\n # sums[gamma] += (sibling_routes_mileage.values.min/sibling_routes_mileage[route])**gamma\n sums[gamma] += (sibling_routes_mileage.values.min/sibling_routes_mileage[route])**gamma**@route.systems_suggested\n end\n end\n\n if gamma == Float::INFINITY\n path_sizes[gamma] += (impedance * sums[gamma])\n else\n path_sizes[gamma] += (impedance * (1.0/sums[gamma]))\n end\n end\n end\n puts \"[#{@route.id}] Completed in #{(Time.now - t0)* 1000.0} ms\"\n puts \"[#{@route.id}] Path Size: #{path_sizes}\"\n path_sizes\n end", "def find_breadth_traversal_tree(in_order,post_order,level, h)\n # level => 0F 0T 1F 1T etc\n if in_order.size == nil || in_order.size == 0\n puts \"finish\"\n elsif in_order.size == 1\n # finish\n yield(level, in_order[0])\n puts \"#{level} \\t #{in_order[0]}\"\n else \n # this is not finished yet\n max_index_in_post = 0\n max_index_in_in = 0\n in_order.each_with_index do |in_ele,in_index|\n post_index = post_order.index(in_ele)\n\n if post_index > max_index_in_post\n max_index_in_post = post_index\n max_index_in_in = in_index\n end\n\n end\n current_root = in_order[max_index_in_in]\n yield(level, current_root)\n puts \"#{level} \\t #{current_root}\"\n\n level[0] = (Integer(level[0])+1).to_s\n next_level_f = level+\"F\"\n next_level_t = level+\"T\"\n front_of_in = in_order[0...max_index_in_in]\n tail_of_in = in_order[(max_index_in_in+1)...in_order.size]\n \n #\n find_breadth_traversal_tree(front_of_in,post_order,next_level_f, h) {|level,ele| h[level] = ele}\n find_breadth_traversal_tree(tail_of_in,post_order,next_level_t, h) {|level,ele| h[level] = ele}\n\n #\n end # end of else\n\n\nend", "def minCut(graph, size)\n cross = 0\n contraction graph, size\n #the size of the graph has decreased by 1\n #stop recursing when there is only two vertices left\n if size - 1 > 2\n # puts \"graph #{graph}\"\n cross = minCut graph, size - 1\n end\n if size == 3\n for i in graph[0][1..-1]\n if graph[1].include? i\n cross += 1\n end\n end\n end\n cross\nend", "def test_06\n @dg = DiGraph.new([5,9],[0,3],[3,8],[8,9],[9,0])\n @paths = Hash.new\n @paths[5] = [9]\n @paths[0] = [3]\n @paths[3] = [8]\n @paths[8] = [9]\n @paths[9] = [0]\n @nodes = @paths.keys\n received_dg = @dg.strongly_connected_component_including_node(0);\n filled_dg = DiGraph.new(*fill(0));\n if (not filled_dg.equal?(received_dg))\n puts \"test_06 failed...\"\n puts \"DiGraph => #{@dg.to_s}\"\n puts \"node => 0\"\n puts \"expected => #{filled_dg.to_s}\"\n puts \"received => #{received_dg.to_s}\"\n end\n assert_equal(true,filled_dg.equal?(received_dg))\n end", "def count_paths(grid_size)\n factorial(2*grid_size) / (factorial(grid_size) * factorial(grid_size))\nend", "def visitor(i,j,n,m,grid,visited)\n if (i<0 || i>n-1 || j<0 || j>m-1 || grid[i][j]==0 || visited[i][j])\n return 0\n else visited[i][j] = true\n score = 1\n score += visitor(i-1,j-1,n,m,grid,visited)\n score += visitor(i-1,j,n,m,grid,visited)\n score += visitor(i-1,j+1,n,m,grid,visited)\n score += visitor(i,j-1,n,m,grid,visited)\n score += visitor(i,j+1,n,m,grid,visited)\n score += visitor(i+1,j-1,n,m,grid,visited)\n score += visitor(i+1,j,n,m,grid,visited)\n score += visitor(i+1,j+1,n,m,grid,visited)\n return score\n end\nend", "def nodes\n @graph.keys.length\n end", "def edges\n i = 0\n @hypernyms.each do |key, values|\n i += values.length\n end\n i\n end", "def bfs\n\n end", "def findShortest(graph_nodes, graph_from, graph_to, ids, val)\n return -1 if ids.count(val)<=1 # no two nodes with color val\n dmin = graph_nodes\n num_edges = graph_from.length\n neighbors = {}\n 0.upto(num_edges-1) do |i|\n if neighbors[graph_from[i]]\n neighbors[graph_from[i]] << graph_to[i]\n else\n neighbors[graph_from[i]] = [graph_to[i]]\n end\n if neighbors[graph_to[i]]\n neighbors[graph_to[i]] << graph_from[i]\n else\n neighbors[graph_to[i]] = [graph_from[i]]\n end\n end\n p neighbors\n ids.each_with_index do |v,i|\n if v == val\n # zero-base index to one-base index \n source_node = i+1\n # look for others using bfs (stop looking if distance > dmin)\n queue = []\n visited = []\n backtrace = {}\n queue << source_node\n while !(queue.empty?)\n current_node = queue.shift\n visited << current_node\n if (current_node!=source_node) && (ids[current_node-1]==val)\n puts \"we are here!\"\n # how did I get here? backtrace\n hops = 0\n trace_node = current_node\n while (trace_node!=source_node)\n trace_node = backtrace[trace_node]\n hops +=1\n end\n if hops < dmin\n dmin = hops\n end\n break\n end\n neighbors[current_node].each do |xnode|\n if !(visited.include?(xnode))\n queue << xnode\n backtrace[xnode] = current_node\n end\n end\n end\n p visited\n end\n end\n if dmin == graph_nodes\n return -1\n else\n return dmin\n end\nend", "def bfs\n # raise NotImplementedError\n end", "def depth_of_index(link)\n self.avoid_zero_division(1, self.avoid_zero_division(self.depth_of_page_in_url(link), @dpus.values.max))\n end", "def calc_tree_height(\n cycle:\n)\n height = 1\n return height if cycle.zero?\n (1..cycle).each do |num|\n height = num.odd? ? height * 2 : height + 1\n end\n height\nend", "def findMaximum(weights)\n\t\n\tputs \"Weights\" if DEBUG_OUTPUT\n\tprintMatrix(weights) if DEBUG_OUTPUT\n\t# l(x) == l[x]\n\t\t\n\teq = EqualityGraph.new(weights)\n\teq.generateLabelFunctions()\n\t\n\t#Generate equality graph\n\t\n\teq.generateEqualityGraph()\n\t\n\t#Pick an abitrary matching in the equality subgraph\n\t\n\teq_match = MatchGraph.new(eq.x_vertices, eq.y_vertices)\n\t\n\teq.initialMatch(eq_match)\t\n\t\n\tputs \"Equality Match\\n#{eq_match.to_s}\" if DEBUG_OUTPUT\n\t\n\t#puts \"Is Equality Match perfect? #{eq_match.isPerfectMatch}\" if DEBUG_OUTPUT\n\t\t\t\n\tuntil(eq_match.isPerfectMatch)\n\t\t#Pick a free vertex in X\n\t\tfreeX = eq_match.get_free_x_vertex\n\t\t\n\t\teq_match.alt_tree_x_nodes.push(freeX)\n\t\t\t\n\t\tputs \"\\nMAJOR STEP Picked a free X: #{freeX}\" if DEBUG_OUTPUT\n\t\t\n\t\ts_vertices = [ freeX ]\n\t\tt_vertices = Array.new\n\t\t\n\t\t#Though sets s and t should be enough, will keep track of the alternating paths \n\t\t#originating at freeX\n\t\t\n\t\t\n\t\ts_neighbors = eq.get_neighbors_of_x_vertices(s_vertices).to_set\n\t\t\n\t\ts_neighbors_not_in_t = s_neighbors.to_a\n\t\t\n\t\tuntil(false)\n\t\t\tputs \"S = #{s_vertices.to_a} N(S) = #{s_neighbors.to_a} T= #{t_vertices.to_a}\" if DEBUG_OUTPUT\n\t\t\t\t\n\t\t\tif s_neighbors.size == t_vertices.size\n\t\t\t\tputs \"\\nSTEP No more s_neighbors to process, growing eq\" if DEBUG_OUTPUT\n\t\t\t\told_size = s_neighbors.size\n\t\t\t\t\n\t\t\t\teq.growEqualityGraph(s_vertices, t_vertices, s_neighbors, s_neighbors_not_in_t)\n\t\t\t\t\n\t\t\t\traise \"s neighbors did not increase\" if s_neighbors.size <= old_size\t\t\t\t\t\t\n\t\t\telse\n\t\t\t\tputs \"\\nSTEP Picking a new Y not yet in T from S neighbors\" if DEBUG_OUTPUT\n\t\t\t\t#pick y\n\t\t\t\ty = s_neighbors_not_in_t.pop #(s_neighbors - t_vertices).find { true } \n\t\t\t\tif eq_match.is_y_vertex_free(y)\n\t\t\t\t\t#Reset S and T\n\t\t\t\t\traise \"T and S are out of wack\" if s_vertices.size != t_vertices.size + 1\t\t\t\t\t\n\t\t\t\t\teq_match = growMatch(y, eq_match, eq, freeX)\n\t\t\t\t\tputs \"Grew match Equality Graph was #{eq}\" if DEBUG_OUTPUT\n\t\t\t\t\tbreak\n\t\t\t\telse\n\t\t\t\t\tputs \"y[#{y}] is matched\" if DEBUG_OUTPUT\n\t\t\t\t\tnew_s_node = growTree(s_vertices, t_vertices, y, eq, eq_match)\n\t\t\t\t\t\n\t\t\t\t\tnew_s_neighbors = eq.get_neighbors_of_x_vertices( [new_s_node] )# - t_vertices\n\t\t\t\t\ts_neighbors.merge( new_s_neighbors )\n\t\t\t\t\t#new_s_neighbors could intesect with t\n\t\t\t\t\ts_neighbors_not_in_t = (s_neighbors - t_vertices).to_a\n\t\t\t\tend\n\t\t\tend \n\t\tend\n\tend\n\t\n\tputs \"Sum is #{eq_match.sumEdgeWeights(weights)}\" if DEBUG_OUTPUT\n\t\n\treturn eq_match.sumEdgeWeights(weights)\nend", "def height\n return 0 if @root.nil?\n current = @root\n height_recursive(current)\n end", "def test_05\n @dg = DiGraph.new([0,7],[1,9],[1,4],[7,4],[7,0],[7,9],[3,7],[9,4],[9,7],[9,9],[4,1],[4,4],[4,7])\n @paths = Hash.new\n @paths[0] = [7]\n @paths[1] = [9,4]\n @paths[7] = [4,0,9]\n @paths[3] = [7]\n @paths[9] = [4,7,9]\n @paths[4] = [1,4,7]\n @nodes = @paths.keys\n received_dg = @dg.strongly_connected_component_including_node(0);\n filled_dg = DiGraph.new(*fill(0));\n if (not filled_dg.equal?(received_dg))\n puts \"test_05 failed...\"\n puts \"DiGraph => #{@dg.to_s}\"\n puts \"node => 0\"\n puts \"expected => #{filled_dg.to_s}\"\n puts \"received => #{received_dg.to_s}\"\n end\n assert_equal(true,filled_dg.equal?(received_dg))\n end", "def fully_connected?(root_node, count)\n visited = [root_node]\n to_visit = [root_node]\n \n while !to_visit.empty?\n current_node = to_visit.shift\n\n current_node.children.each do |node|\n if !visited.include?(node)\n visited << node\n to_visit << node # get children next cycle\n end\n end\n end\n\n puts visited.count == count\nend", "def depth; end", "def nodeCount\n count = 1\n\n if @children.size\n @children.each do |key, val|\n count += val.nodeCount\n end\n end\n\n count\n end", "def size\n size = 1\n size += @left.size unless @left.nil?\n size += @right.size unless @right.nil?\n size\n end", "def count(builder)\n m = Either.success(builder.machine)\n\n while m.defined?\n if m.flatmap(&:segment).map{|s| s.node.id == :ST }.fetch(false)\n return m.flatmap{|n| n.distance(builder.machine) }.fetch(0) + 2\n else\n m = m.flatmap(&:parent)\n end\n end\n end", "def size_of_children(arr)\n children_count = arr[0]\n metadata_count = arr[1]\n\n if children_count == 0\n # the value is simply the sum of child nodes\n value = arr[2..(metadata_count+1)].sum\n $metadata_total += value\n return {size: (2 + metadata_count), value: value}\n elsif children_count >= 1\n total_children_size = 0\n\n child_nodes_values = [ nil ] # we need a dummy item at index 0\n\n children_count.times do |index|\n kiddo_report = size_of_children(arr[2+total_children_size..-1])\n total_children_size += kiddo_report[:size]\n child_nodes_values << kiddo_report[:value]\n end\n\n metadata_nodes = arr[(2 + total_children_size)..(1 + total_children_size + metadata_count)]\n $metadata_total += metadata_nodes.sum\n\n # Value is more complicated when the node has child nodes. Value is the sum\n # of the values of child nodes referred to, but we have to be careful since\n # arrays are 0-indexed and references to child nodes are 1-indexed. If the\n # child node doesn't actually exist, the value is 0.\n total_value = 0\n metadata_nodes.each do |node|\n total_value += child_nodes_values.fetch(node, 0)\n end\n\n return {size: (2 + total_children_size + metadata_count), value: total_value}\n end\nend", "def find_height_nodes(root) # O(n)\n return 0 if root == nil\n left_height = 1 + find_height_nodes(root.left)\n right_height = 1 + find_height_nodes(root.right)\n\n return (left_height > right_height)? left_height : right_height\nend", "def most_specific_subdivision; end" ]
[ "0.62283415", "0.61713403", "0.6133745", "0.60346776", "0.6001972", "0.5975894", "0.5969828", "0.5968527", "0.5917075", "0.5913511", "0.5912248", "0.58996624", "0.5886517", "0.58621854", "0.5861451", "0.5852817", "0.5849068", "0.5843676", "0.5842256", "0.5835864", "0.5831141", "0.58259976", "0.5824158", "0.5820061", "0.58151865", "0.58101964", "0.58069175", "0.5776646", "0.57679105", "0.5762106", "0.5759042", "0.5756305", "0.5754713", "0.5752616", "0.57417107", "0.574112", "0.5736551", "0.57363546", "0.5735711", "0.57346827", "0.571577", "0.5715042", "0.5712946", "0.57113004", "0.5710599", "0.57071996", "0.5691257", "0.56906277", "0.56871164", "0.56832993", "0.567775", "0.5675806", "0.56725883", "0.5663693", "0.56634855", "0.56602466", "0.56594974", "0.5644875", "0.5643974", "0.5643974", "0.5638675", "0.5632889", "0.5631485", "0.5630395", "0.5627388", "0.56268185", "0.56245196", "0.5607961", "0.5604476", "0.56008226", "0.5599973", "0.5597454", "0.55779624", "0.5574291", "0.55708456", "0.5561025", "0.55598354", "0.5553838", "0.5549662", "0.55476433", "0.55364907", "0.5535576", "0.55325234", "0.5529731", "0.55286515", "0.55212146", "0.5520382", "0.551781", "0.55164766", "0.55148125", "0.5505659", "0.54985595", "0.54973054", "0.5492361", "0.54907566", "0.548641", "0.5484593", "0.5479718", "0.547668", "0.5472361", "0.5467669" ]
0.0
-1
Part 2: How many subgraphs are there?
def subgraphs subs = [] nodes_to_hit = @vertices.dup until nodes_to_hit.empty? subgraph = subgraph_with(nodes_to_hit.to_a.first) subs << subgraph nodes_to_hit -= subgraph.vertices end subs end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def size\n @graphs.inject(0) {|memo, g| memo += g.size}\n end", "def number_of_edges\n @adj.values.map(&:length).inject(:+)\n end", "def edges\n edges = 0\n @graph.each_value do |v|\n edges += v.size\n end\n edges\n end", "def size\n\t\[email protected]\n\tend", "def vertex_count\n @graph.length\n end", "def calculate_num_children\n for x in @lattice do\n for c in @lattice.lower_covers[x] do\n if @irreducibles.contain?(c) then\n @num_children[x] += 1\n end\n end\n end\n end", "def num_nests\n my_nests.length\n end", "def connected?\n subgraphs = 0\n @bugs.each_connected_component {|c| subgraphs += 1 }\n subgraphs == 1\n end", "def edges\n i = 0\n @hypernyms.each do |key, values|\n i += values.length\n end\n i\n end", "def num_edges()\n edgeNum = 0\n @source.values.each do |x|\n edgeNum += x.size()\n end\n return edgeNum/2\n end", "def nodes\n @graph.keys.length\n end", "def hard(input)\n graph = Graph.from(input)\n components = []\n vertices = Set.new(graph.vertices)\n until vertices.empty?\n start = vertices.first\n component = graph_walk(graph, start)\n components << component\n vertices = vertices.difference(component)\n end\n components.length\nend", "def number_of_edges\n @pathway.relations.size\n end", "def edge_count\n @adjacency_list.flatten.count / 2\n end", "def size\n count = 0\n visit_nodes do\n count += 1\n end\n count\n end", "def subgraph\n paths.subgraph\n end", "def test_create_graph\n val = create_graph(1234, 5)\n locations_count = val[0].count\n prospectors_count = val[1].count\n assert_equal 7, locations_count\n assert_equal 5, prospectors_count\n end", "def segment_count\n children.map(&:segment_count).inject(:+).to_i + 2\n end", "def nr_of_regions\n ConnectedComponents.new(in_use_graph).count\n end", "def analyze\n max_chain = 0\n min_chain = @count\n num_chains = 0\n @table.each do |node|\n chain_length = 0\n num_chains += 1 if node\n while node\n node = node.next\n chain_length += 1\n end\n max_chain = chain_length if max_chain < chain_length\n min_chain = chain_length if chain_length < min_chain\n end\n \"Load factor: #{1.0*@count/@table.size}\\n\" +\n \"Table density: #{1.0*num_chains/@table.size}\\n\" +\n \"Mimumum chain: #{min_chain}\\n\" +\n \"Maximum chain: #{max_chain}\"\n end", "def numPaths(start_from, vertices,edge_weights)\n graph = RGL::DirectedAdjacencyGraph.new\n graph.add_vertices vertices\n edge_weights.each { |(bag1, bag2), w| graph.add_edge(bag1, bag2) }\n\n num_paths = 0\n vertices.map do |vert|\n unless vert.eql?(start_from)\n num_paths+=1 if graph.path?(start_from,vert)\n end\n end\n num_paths\nend", "def graphs(n)\n {\n 'cpu' =>\n \"groupByNode(collectd.#{name(n)}.cpu.*.cpu.*.value, 5, 'sumSeries')\",\n\n 'memory' =>\n \"groupByNode(collectd.#{name(n)}.memory.memory.*.value,4,'sumSeries')\",\n\n 'interface_if_octets_rx' =>\n \"groupByNode(collectd.#{name(n)}.interface.if_octets.*.rx,4,'sumSeries')\",\n\n 'interface_if_octets_tx' =>\n \"groupByNode(collectd.#{name(n)}.interface.if_octets.*.tx,4,'sumSeries')\",\n\n 'qmail_filecount_files' =>\n \"groupByNode(collectd.#{name(n)}.filecount.*.files.value,3,'sumSeries')\",\n\n 'qmail_filecount_files_stacked' =>\n \"groupByNode(collectd.*.filecount.*.files.value,1,'sumSeries')\",\n\n 'qmail_filecount_files_derivative' =>\n \"groupByNode(collectd.#{name(n)}.filecount.*.files.value,3,'derivative')\",\n\n 'qmail_filecount_files_derivative_stacked' =>\n \"groupByNode(collectd.*.filecount.*.files.value,1,'derivative')\",\n\n 'qmail_filecount_files_integral' =>\n \"groupByNode(collectd.#{name(n)}.filecount.*.files.value,3,'integral')\",\n\n 'qmail_filecount_files_integral_stacked' =>\n \"groupByNode(collectd.*.filecount.*.files.value,1,'integral')\",\n\n 'qmail_filecount_size' =>\n \"groupByNode(collectd.#{name(n)}.filecount.*.bytes.value,3,'sumSeries')\",\n\n 'qmail_filecount_size_stacked' =>\n \"groupByNode(collectd.*.filecount.*.bytes.value,1,'sumSeries')\",\n }\n end", "def total_count\n object.nodes.size\n end", "def analyze\n max_chain = 0\n min_chain = @count\n num_chains = 0\n @table.each do |node|\n chain_length = 0\n num_chains += 1 if node\n while node\n node = node.next\n chain_length += 1\n end\n max_chain = chain_length if max_chain < chain_length\n min_chain = chain_length if chain_length < min_chain\n end\n return \"Load factor: #{1.0*@count/@table.size}\\n\" +\n \"Table density: #{1.0*num_chains/@table.size}\\n\" +\n \"Mimumum chain: #{min_chain}\\n\" +\n \"Maximum chain: #{max_chain}\"\n end", "def sibling_count(*args)\n sibling_rels(*args).size\n end", "def size\n @nodes.length\n end", "def size\n @nodes.length\n end", "def num_edges\n\t\treturn @Edges.length\n\tend", "def count_all\n # map all nodes into enumerable\n # then add them all together (reduce :+)\n self.map { |node| node.count }.reduce(:+)\n end", "def size\n @nodes.size\n end", "def size\n counter = 0\n each { |node| counter += 1 }\n return counter\n end", "def num_vertices()\n return vertex_list().length()\n end", "def nodeCount\n count = 1\n\n if @children.size\n @children.each do |key, val|\n count += val.nodeCount\n end\n end\n\n count\n end", "def count(g, u, v)\n g.vertices.each do |v|\n v.data = 0\n v.parent = nil\n end\n\n dfs_count(g, u, v)\n v.data\nend", "def size\n all_nodes.length\n end", "def number_of_connected(graph)\n visited = Hash.new(false)\n res = 0\n graph.vertices.keys.each do |v|\n unless visited[v]\n dfu(graph, v, visited)\n res += 1\n end\n end\n res\n end", "def small_world\n freq = Hash.new(0)\n @graph.each_value do |v|\n freq[v.size] += 1\n end\n return freq\n end", "def subarray_count(subarray)\n\t\t\t\t\teach_cons(subarray.length).count(subarray)\n\t\t\t end", "def n_paths(graph, from)\n counter = { from => 1 }\n graph.topsort.each do |v|\n next if v == from\n in_edges = graph.edges.select { |e| e.target == v && graph.adjacent(v, :direction => :in).include?(e.source) }\n counter[v] = in_edges.map { |e| counter[e.source] }.inject(:+)\n end\n counter\nend", "def objects\n @graphs.inject([]) {|memo, g| memo += g.objects}\n end", "def size\n count = 1\n node = @node\n\n while node.next\n count += 1\n node = node.next\n end\n\n count\n end", "def find_subgraph(n)\n # variables: stack of nodes to check, list of nodes in a subgraph \n list_of_nodes = []\n nodes_to_check = [n.id]\n \n until nodes_to_check.empty?\n node = nodes_to_check.pop\n nbrs = self.find_neighbors(node)\n nodes_to_check.add_unique!(nbrs - list_of_nodes)\n list_of_nodes.push(node)\n end \n \n list_of_nodes \n end", "def in_degree\n @in_edges.length\n end", "def subgraph(list = nil)\n if list\n\[email protected]\n\tlist.each do |node|\n\t @label[node] = true\n\tend\n end\n sub_graph = Pathway.new([], @undirected)\n @graph.each do |from, hash|\n\tnext unless @label[from]\n\thash.each do |to, relation|\n\t next unless @label[to]\n\t sub_graph.append(Relation.new(from, to, relation))\n\tend\n end\n return sub_graph\n end", "def total_bags_inside\n children.size + children.map(&:total_bags_inside).sum\n end", "def small_world\n freq = Hash.new(0)\n @graph.each_value do |v|\n\tfreq[v.size] += 1\n end\n return freq\n end", "def size(is_weighted=false)\n if is_weighted\n graph_size = 0\n @adj.each do |_, hash_val|\n hash_val.each { |_, v| graph_size += v[:weight] if v.key?(:weight) }\n end\n return graph_size\n end\n number_of_edges\n end", "def number_of_children\n @children.size\n end", "def current_num_nodes() ; info[:current_num_nodes] ; end", "def strongly_connected_components\n\t\t@explored_nodes = Array.new(size, false)\n\t\t@finishing_time_arr = Array.new(size)\n\t\t@scc = Array.new\n\t\t@dfs_queue = Array.new\n\t\t@finishing_time_queue = Array.new\n\t\t@finishing_time = 0\n\t\tcalculate_finishing_time\n\t\t@leaders = scc_call_order\n\t\tcalculate_scc\n\t\tputs \"#{@scc.map(&:count).sort.reverse.take(5)}\"\n\tend", "def list_subs\n @sub = SubDriver.where(driver: self)\n @sub_list =[]\n @sub_count = 0\n @sub.each do |i|\n @sub_count += CommentSubJoin.where(sub_driver: i).count\n end\n\n @sub.each do |i|\n @each_sub = []\n @each_sub << i.name\n @each_sub_count =CommentSubJoin.where(sub_driver: i).count\n @each_sub << @each_sub_count.to_f / @sub_count.to_f\n @sub_list << @each_sub\n end\n @sub_sorted = @sub_list.sort_by {|_key, value| value}.reverse.first(5)\n # puts @sub_count\n return @sub_sorted, @sub_count\n end", "def num_children\n count = 0\n self.children.each do |child|\n count = count + child.num_children\n end\n\n return self.children.size + count\n end", "def total\n object.nodes.size\n end", "def subtree_count(*args)\n subtree_rels(*args).size\n end", "def fulltree_count(*args)\n fulltree_rels(*args).size\n end", "def nodes\n @grpc.node_count\n end", "def count\n count = 0\n\n each do |node|\n count += 1\n end\n\n return count\n end", "def count_children\n count = children.count\n if count\n children.each { |child| count += child.count_children }\n end\n count\n end", "def count_children(color:)\n if color == \"no other\"\n 0\n else\n children_counts = BAG_MAP_2[color].map { |content_arry| content_arry.first }\n children = children_counts.inject(0) { |sum,x| sum + x }\n\n ary = BAG_MAP_2[color]\n\n ary.each do |arry_content|\n num = arry_content.first\n col = arry_content.last\n\n children += num * count_children(color: col)\n end\n\n children\n end\nend", "def node_count\n raise NotImplementedError\n end", "def bnodes\n @graphs.inject([]) {|memo, g| memo += g.bnodes}\n end", "def count\n number_of_trees + number_of_networks\n end", "def children_size\n size = locations.size\n locations.each{|location|\n locations = location.locations\n if locations.present?\n size += location.children_size\n end\n }\n return size\n end", "def child_count(*args)\n child_rels(*args).size\n end", "def max_cycle_length\n scc_kosaraju.map{|scc| scc.size}.max\n end", "def detect_cycle_in_graph(edges)\nend", "def nested_notes_count\n count = notes.any? ? notes.count : 0\n subcategories.each do |category|\n next unless category.notes.any?\n\n count += category.notes.count\n end\n count\n end", "def number_of_nodes(node_name)\n nodes(node_name).count\nend", "def count_edge\n count = 0\n @f_net.each_with_index do |followees, follower|\n count += followees_of(follower).count\n end\n count\n end", "def size\n count = 1\n current = @head\n while current.next?\n current = current.next_node\n count += 1\n end\n count\n end", "def node_size\n @results.size\n end", "def number_of_living_descendants\n count_descendants_matching { |d| d.alive? }\nend", "def test_edges_on_examples\n assert_equal(6,@small_dfa.edges.size)\n assert_equal(7,@small_nfa.edges.size)\n end", "def test_edge_count_on_examples\n assert_equal(6, @small_dfa.edge_count)\n assert_equal(7, @small_nfa.edge_count)\n end", "def size_of_children(arr)\n children_count = arr[0]\n metadata_count = arr[1]\n\n if children_count == 0\n # the value is simply the sum of child nodes\n value = arr[2..(metadata_count+1)].sum\n $metadata_total += value\n return {size: (2 + metadata_count), value: value}\n elsif children_count >= 1\n total_children_size = 0\n\n child_nodes_values = [ nil ] # we need a dummy item at index 0\n\n children_count.times do |index|\n kiddo_report = size_of_children(arr[2+total_children_size..-1])\n total_children_size += kiddo_report[:size]\n child_nodes_values << kiddo_report[:value]\n end\n\n metadata_nodes = arr[(2 + total_children_size)..(1 + total_children_size + metadata_count)]\n $metadata_total += metadata_nodes.sum\n\n # Value is more complicated when the node has child nodes. Value is the sum\n # of the values of child nodes referred to, but we have to be careful since\n # arrays are 0-indexed and references to child nodes are 1-indexed. If the\n # child node doesn't actually exist, the value is 0.\n total_value = 0\n metadata_nodes.each do |node|\n total_value += child_nodes_values.fetch(node, 0)\n end\n\n return {size: (2 + total_children_size + metadata_count), value: total_value}\n end\nend", "def orbit_count\n return 0 unless @root\n sum_of_depths = 0\n nodes_to_traverse = [{ node: @root, depth: 0 }]\n until nodes_to_traverse.empty?\n node_pair = nodes_to_traverse.shift\n node = node_pair[:node]\n depth = node_pair[:depth]\n sum_of_depths += depth\n node.children.each { |child| nodes_to_traverse << { node: child, depth: depth + 1 } }\n end\n sum_of_depths\n end", "def topologies(n, cache = {})\n cache[n] =\n n == 0 ? 1 : (0..n-1).inject(0){ |sum, i| \\\n sum + topologies(i, cache) * topologies(n-i-1, cache) } unless cache.has_key? n\n cache[n]\nend", "def counts\n @rules.inject(Hash.new(0)) do |counts, (lhs, rhs)|\n counts[lhs] += 2 if lhs == @start\n rhs.each { |node| counts[node.value] += 1 if nonterm? node.value }\n counts\n end\n end", "def part_1\n nodes = Set.new([SHINY_GOLD])\n growing = true\n size = nodes.size\n\n while growing\n @bag_rules.each do |key, bags|\n nodes.add(key) if bags.keys.to_set.intersect?(nodes)\n end\n growing = size != nodes.size\n size = nodes.size\n end\n\n nodes.size - 1\n end", "def ll_size()\n return @num_nodes\n end", "def deep_count(arr)\n count = 0\n arr.each do |el|\n if el.class != Array\n count += 1\n else\n count += 1 + deep_count(el)\n end\n end\n count\nend", "def size\n return 0 if empty?\n count_node(head, 1)\nend", "def nitems() end", "def node_count\n @nodes.length - 1\n end", "def open_subgraph(package, parent, level)\n name = sanitize package\n name = \"cluster_#{name}\" if $group_packages\n label = parent && (package =~ /^#{parent}\\.(.+)$/) && $1 || package\n puts_indent level, \"subgraph #{name} {\"\n puts_indent (level + 1), \"label = \\\"#{label}\\\";\"\nend", "def num_children\n @children.size\n end", "def parent_count(*args)\n parent_rels(*args).size\n end", "def children_size\n leaf? ? 0 : children.map(&:size).reduce(:+)\n end", "def numVertices\n @vertices.size\n end", "def numVertices\n @vertices.size\n end", "def ancestors_count(*args)\n ancestor_rels(*args).size\n end", "def countNumIntran(res)\n\t\tiCount = 0\n\n\t\tif res == nil || res.length == 0\n\t\t\treturn iCount\n\t\tend\n\n\t\tres.each do |constituent|\n\t\t\t# verify Intransitive Verb Phrase\n\t\t\tif(constituent.pos == @vp)\n\t\t\t\t# (or no immediate children at all)\n\t\t\t\tif(constituent.children == nil || !constituent.has_children?)\n\t\t\t\t\tiCount = iCount + 1\n\t\t\t\telse\n\t\t\t\t\t# whose immediate (top-level) constituents include no NPs\n\t\t\t\t\t# containsNps = false\n\t\t\t\t\t# constituent.children.each do |child|\n\t\t\t\t\t# \tif(child.pos == @np)\n\t\t\t\t\t# \t\tcontainsNps = true\n\t\t\t\t\t# \t\tbreak\n\t\t\t\t\t# \tend\n\t\t\t\t\t# end\n\n\t\t\t\t\t# # no top-level constituents found\n\t\t\t\t\t# if(!containsNps)\n\t\t\t\t\t# \tiCount = iCount + 1\n\t\t\t\t\t# end\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tiCount = iCount + countNumIntran(constituent.children)\n\t\tend\n\t\treturn iCount\n\tend", "def total_n_queens_proto(n)\n base=[]\n n.times do\n base.push Array.new(n, 0)\n end\n result=[]\n result[0]=0\n dfs(base, n, -1, 0, result)\n #[result.size, result]\n result[0]\nend", "def size\n count = 0\n node = @front\n\n while node\n count += 1\n node = node.next_node\n end\n\n count\n end", "def returnTriples()\n return @graph.dump(:ntriples)\n end", "def num_islands(grid)\n return 0 if grid.empty?\n\n count = 0\n\n grid.each_with_index do |row, i|\n row.each_with_index do |_col, j|\n if grid[i][j] == '1'\n dfs(i, j, grid)\n count += 1\n end\n end\n end\n count\nend", "def count_paths(grid_size)\n factorial(2*grid_size) / (factorial(grid_size) * factorial(grid_size))\nend", "def number_of_groups\n empty? ? 0 : boundaries.size\n end", "def num_chains(lattice, diagram)\n chain_count = 0\n for x in lattice do\n if lattice.upper_covers[x].count == 1 then\n parent_x = lattice.upper_covers[x].first\n for child_x in lattice.lower_covers[x] do\n if lattice.upper_covers[child_x].count == 1 then\n parent_point = diagram.points[parent_x]\n x_point = diagram.points[x]\n child_point = diagram.points[child_x]\n dv = x_point - parent_point\n du = child_point - x_point\n if dv.x == du.x && dv.y == du.y then\n chain_count += 1\n end\n end\n end\n end\n end\n return chain_count\nend", "def size\n return 0 if @head.nil?\n number_of_nodes = 0\n current_node = @head\n while !node.nil? do\n number_of_nodes += 1\n current_node = node.next\n end\n number_of_nodes\n end" ]
[ "0.70592535", "0.6713531", "0.66128975", "0.6481643", "0.64406306", "0.6377136", "0.63748354", "0.63649714", "0.6357266", "0.6291252", "0.62727916", "0.6216807", "0.62087005", "0.6164723", "0.6065929", "0.6047042", "0.6042155", "0.6019763", "0.5987444", "0.597597", "0.5944948", "0.5944533", "0.5938808", "0.59294164", "0.59290206", "0.59247684", "0.59247684", "0.59242254", "0.5895515", "0.5865544", "0.5847338", "0.581873", "0.58032316", "0.5802873", "0.57939726", "0.5793537", "0.5785905", "0.5753692", "0.5743399", "0.57420635", "0.57371294", "0.57274157", "0.5723449", "0.5710506", "0.57080925", "0.5697293", "0.5695805", "0.56864804", "0.56801254", "0.56613326", "0.56592745", "0.5643201", "0.5638152", "0.5637036", "0.563102", "0.5629454", "0.5620975", "0.56007355", "0.55883276", "0.5581362", "0.5578302", "0.5576055", "0.55732733", "0.5567465", "0.55558944", "0.555567", "0.5550031", "0.554101", "0.55399853", "0.5530857", "0.5529995", "0.5526175", "0.5522527", "0.5509272", "0.55060804", "0.5504695", "0.5501345", "0.54978293", "0.5489203", "0.547916", "0.547193", "0.5469003", "0.54661983", "0.5466174", "0.5459327", "0.54539466", "0.5446398", "0.5445097", "0.544211", "0.544211", "0.5441585", "0.54332393", "0.5432484", "0.54287916", "0.54252696", "0.54235125", "0.5419303", "0.5402095", "0.5401656", "0.5389952" ]
0.68094414
1
GET /type_spends GET /type_spends.json
def index @type_spends = TypeSpend.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def type\n @activities = Activity.tagged_with_on(:types,params[:type_name]).page params[:page]\n respond_with @activities\n end", "def subscriptions\n update_subscriptions(params[:types]) if params[:types]\n @types = build_notification_types\n render :json => @types\n end", "def index\n @types = Type.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @types.lookup(params[:q]) }\n end\n end", "def appointment_types(params = {})\n scope 'default'\n get('schedule/appointmenttypes/', params)\n end", "def index\n @special_needs_types = SpecialNeedsType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @special_needs_types }\n end\n end", "def show\n if params[:term]\n @types = Type.all(:conditions => ['typeName LIKE ?', \"%#{params[:term]}%\"])\n else\n @type = Type.find(params[:id])\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @types }\n end\n end", "def add_type(type)\n end", "def index\n render json: usage(params[:type])\n end", "def search_for_type(type)\n q = type\n # search for tweets containing type or #type\n # save them to DB if request is valid (ie not an exception)\n end", "def add_type(type)\n\n # nothing to be done\n end", "def add_type(type)\n\n # nothing to be done\n end", "def index\n @type_partners = TypePartner.all\n end", "def get_available_types_from_usage(usage) #TODO: Research use\n return @client.raw(\"get\", \"/helpers/available-types/#{usage}\")\n end", "def index\n types = @user.tried_beer_ratings.last.beer_types.map do |type|\n {name: type.name, description: type.beg_description}\n end\n render json: types\n end", "def list_types\n user = current_user\n if !params[:distance].nil? and params[:distance].to_i > 0\n distance = params[:distance].to_i\n else\n distance = 30\n end\n if !params[:latitude].blank? \n latitude = params[:latitude].to_f\n else\n latitude = user.latitude\n end\n if !params[:longitude].blank? \n longitude = params[:longitude].to_f\n else\n longitude = user.longitude\n end\n\n if !params[:latitude].blank? and !params[:longitude].blank? \n user.latitude = latitude\n user.longitude = longitude\n user.save\n end\n\n result = Venue.collect_network_types(current_user, latitude, longitude, distance)\n \n render json: success(result)\n end", "def get_available_types_from_usage(usage)\n # TODO: Research use\n @client.raw('get', \"/helpers/available-types/#{usage}\")\n end", "def show\n @event_types = EventType.find(params[:id])\n respond_with @event_type\n end", "def index\n @heart_rate_types = HeartRateType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @heart_rate_types }\n end\n end", "def pet_types\r\n BnetApi::make_request('/wow/data/pet/types')\r\n end", "def index\n @event_types = EventType.all\n respond_with @event_types\n end", "def types\n types = Question.distinct.pluck(:type)\n render json: types.to_a\n end", "def index\n @sends = Send.all\n end", "def request_type(*args)\n type\n end", "def show\n @type = Type.find(params[:id])\n @things = @type.things\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @type }\n end\n end", "def ride_types(args = {})\n make_request(\n http_method: :get,\n endpoint: path_for(:ride_types),\n access_token: args.delete(:access_token),\n options: { query: args }\n )\n end", "def search\n authorize! :show, PointsEntryType\n search_points_entry_types\n\n respond_to do |format|\n #format.html # actually, no.\n format.json {\n render json: @points_entry_types.select([:id, :name, :default_points])\n }\n end\n end", "def index\n @talk_types = TalkType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @talk_types }\n end\n end", "def types\n @client.make_request :get, reports_path\n end", "def populate_endpoints_by_type(type, options = {})\n endpoint_class = Endpoint.get_class(type)\n num_endpoints = number_of_endpoints(type)\n (0..num_endpoints).each do |i|\n endpoint = endpoint_class.new(i, self)\n should_include_message = endpoint.online? || options[:include_offline]\n @endpoints[type] << endpoint if should_include_message\n end\n @endpoints[type].size\n end", "def rec_new\n @beer_types_to_try = BeerType.limit(6).map{|type| [type.id, type.name]}\n render json: @beer_types_to_try\n end", "def index\n @entry_types = EntryType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @entry_types }\n end\n end", "def index\n authorize! :show, PointsEntryType\n load_active_points_entry_types\n\n respond_to do |format|\n format.html\n format.json { render json: @points_entry_types }\n end\n end", "def index\n @gl_types = GlType.where(:gl_report => \"B\").order(\"gl_side DESC\") + GlType.where(:gl_report => \"T\").order(\"gl_side DESC\")\n @gl_typs = Array.new\n # @gl_types = @gl_types + @gl_types2\n respond_to do |format|\n format.html # index.html.erb\n\n format.json {\n @gl_types = @gl_types.select{|gl_type|\n gl_typ = Hash.new\n gl_type.attributes.each do |key, value|\n gl_typ[key] = value\n end\n gl_typ[:links] = CommonActions.object_crud_paths(nil, edit_gl_type_path(gl_type), gl_type_path(gl_type))\n @gl_typs.push(gl_typ)\n }\n render json: {:aaData => @gl_typs}\n }\n end\n end", "def index\n @typegroups = Typegroup.all\n respond_to do |format|\n format.html\n format.json { render json: @typegroups }\n end\n end", "def index\n @specification_types = SpecificationType.all.order(\"display_order\")\n\n render json: @specification_types, each_serializer: Web::V1::SpecificationTypeSerializer\n end", "def types_of_service(params, options = {})\n path = \"#{base_uri(params)}/patient_documents\"\n path << current_if_specified_in(params)\n path << '/type_of_service_extension'\n request(path, options).to_hash\n end", "def getassociated(type)\n self.forward_items_dataset.filter(\"content LIKE '%type\\\":\\\"#{type}%'\")\n end", "def index\n @student_types = StudentType.all\n\n render json: @student_types\n end", "def index\n @types = Type.all\n end", "def add\n\n item = params[:item]\n type = params[:type]\n\n added = nil\n\n if type=='song'\n\n if Favorite.exist_song(item, user_signed_in?, current_user)\n added = Song.quit_favorite(item, user_signed_in?, current_user)\n else\n added = Song.add_favorite(item, user_signed_in?, current_user)\n end\n \n end\n\n if type=='movie'\n\n year = item['year']\n name = item['name']\n\n if Favorite.exist_movie(year, name, user_signed_in?, current_user)\n added = Movie.quit_favorite(item, user_signed_in?, current_user)\n else\n added = Movie.add_favorite(item, user_signed_in?, current_user)\n end\n\n end\n\n response = {\n :added => added,\n }\n \n render :json =>response\n \n end", "def listing(type, **params)\n params[:t] = params.delete(:time) if params.key?(:time)\n @client.model(:get, \"/user/#{get_attribute(:name)}/#{type}.json\", params)\n end", "def listing(type, **params)\n params[:t] = params.delete(:time) if params.key?(:time)\n @client.model(:get, \"/user/#{get_attribute(:name)}/#{type}.json\", params)\n end", "def get_lesson_types\n get \"lessonTypes.json\"\n end", "def set_type_spend\n @type_spend = TypeSpend.find(params[:id]) rescue not_found\n end", "def index\n @act_types = ActType.order(:name).page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @act_types }\n end\n end", "def index\n @typebourses = Typebourse.all\n end", "def index\n ends = End.find_each\n render json: ends\n end", "def index \n respond_to do |format|\n format.html # index.html.erb\n format.json { \n asset_types = AssetType.all\n render json: asset_types \n }\n end\n end", "def index\n @costtypes = Costtype.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @costtypes }\n end\n end", "def show\n respond_to do |format|\n format.html\n format.json { render json: @typegroup }\n end\n end", "def get_response_of_type(type)\n type = type.split('_').map(&:capitalize).join\n\n loop do\n response = get_message\n return response if response.class.name.demodulize == type\n end\n end", "def index\n @bs_types = BsType.all\n end", "def type\n validate_request!(ClaimsApi::V2::ParamsValidation::IntentToFile)\n\n type = get_bgs_type(params)\n response = local_bgs_service.find_intent_to_file_by_ptcpnt_id_itf_type_cd(\n target_veteran.participant_id,\n type\n )\n message = \"No active '#{params[:type].downcase}' intent to file found.\"\n raise ::Common::Exceptions::ResourceNotFound.new(detail: message) if response.blank?\n\n response = [response] unless response.is_a?(Array)\n intent_to_files = response.compact.collect do |element|\n bgs_itf_to_lighthouse_itf(bgs_itf: element)\n end\n\n active_itf = intent_to_files.detect do |itf|\n itf[:status].casecmp?('active') && itf[:expiration_date].to_datetime > Time.zone.now\n end\n\n raise ::Common::Exceptions::ResourceNotFound.new(detail: message) if active_itf.blank?\n\n render json: ClaimsApi::V2::Blueprints::IntentToFileBlueprint.render(active_itf, root: :data)\n end", "def index\n @follow_up_types = FollowUpType.all\n end", "def index\n if params[:contribution_type] == \"show\"\n @contributions = Contribution.where.not(url: '').order(created_at: :desc)\n elsif params[:contribution_type] == \"ask\"\n @contributions = Contribution.where.not(text: '').order(created_at: :desc)\n elsif params[:contribution_type] == nil || params[:contribution_type] == ''\n @contributions = Contribution.all.order(created_at: :desc)\n else\n render :json => {:status => \"400\", :error => \"Bad Request\"}, status: :bad_request\n end\n end", "def set_end_products\n case params[:type]\n when \"full\"\n BGSService.end_product_data = BGSService.existing_full_grants\n when \"partial\"\n BGSService.end_product_data = BGSService.existing_partial_grants\n when \"none\"\n BGSService.end_product_data = BGSService.no_grants\n when \"all\"\n BGSService.end_product_data = BGSService.all_grants\n end\n\n redirect_to \"/test/users\"\n end", "def get_outype(outype_id)\n path = \"/d2l/api/lp/#{$lp_ver}/outypes/#{outype_id}\"\n _get(path)\nend", "def index\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @resource_types }\n end\n end", "def index\n @accounting_items = Accounting::Item\n .where(user_id: @current_user.id)\n .includes(:type)\n .joins(:type)\n\n respond_to do |format|\n format.json { render json: @accounting_items, include: :type }\n end\n end", "def slots_based_on_type(staff:, type:, date:)\n case type\n when HearingDay::REQUEST_TYPES[:central]\n 11\n when HearingDay::REQUEST_TYPES[:video]\n staff.stc4\n when HearingDay::REQUEST_TYPES[:travel]\n (date.monday? || date.friday?) ? staff.stc2 : staff.stc3\n end\n end", "def show\n @special_needs_type = SpecialNeedsType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @special_needs_type }\n end\n end", "def index\n @discipline_types = DisciplineType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @discipline_types }\n end\n end", "def choose_new_type\n @types = Poll.all_types_for_select\n end", "def show\n @types_of_apprenticeship = TypesOfApprenticeship.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @types_of_apprenticeship }\n end\n end", "def index\n @use_types = UseType.all\n end", "def type_params\n params.from_jsonapi.require(:type).permit(:name)\n end", "def add_type(type)\n\n # does nothing, types are differentiated by the 'typ' column\n end", "def type_objects\n pre = Prereq.new(:need_type => params[:type])\n pre.id = params[:id].to_i\n respond_to do |format|\n format.js {render :partial => 'prereqs/prereq_items_by_type', :locals => {:prereq => pre}}\n end\n end", "def fetch_facebook_friends_or_subscribers_or_subscribedto (type)\n identity = self.identities.find_by_provider_id(ApplicationController.fb_app[:id])\n\t\tif type == \"friends\"\n\t\t\tgraph_url_string = getURL( ApplicationController.fb_app[:graph][:query_root_url] + ApplicationController.fb_app[:graph][:query_friends_suffix], {:access_token =>identity.authentication.token} )\n\t\telsif type == \"subscribers\"\n\t\t\tgraph_url_string = getURL( ApplicationController.fb_app[:graph][:query_root_url] + ApplicationController.fb_app[:graph][:query_subscribers_suffix], {:access_token =>identity.authentication.token} )\n\t\telsif type == \"subscribedto\"\n\t\t\tgraph_url_string = getURL( ApplicationController.fb_app[:graph][:query_root_url] + ApplicationController.fb_app[:graph][:query_subscribedto_suffix], {:access_token =>identity.authentication.token} )\n\t\telse\n\t\t\tgraph_url_string = nil;\n\t\t\talert_log(\"Invalid type: Cannot fetch facebook connections of type: \"+type)\t\t\t\n\t\t\tnot_found\n\t\tend\n\t\treturn fetch_facebook_list_data(graph_url_string)\n\tend", "def index\n @types = ItemType.all\n end", "def show\n @service_type = ServiceType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @service_type }\n end\n end", "def index\n @bike_types = BikeType.all.order(\"updated_at DESC\").order(\"created_at DESC\")\n\n render json: @bike_types #each_serializer: Web::V1::BikeTypeSerializer\n end", "def list(type)\n get(resource_path_for_entity_type(type) + \"?rows=all\")\n end", "def lookup(type)\n @resource_types[type] || []\n end", "def index\n @types = [ContactType.student]\n \n respond_to do |format|\n format.html\n format.json {\n render json: Contact.full_text_search(params[:q])\n }\n end\n end", "def url_for_list(type); end", "def added(type = nil)\n keys = (@after.keys - @before.keys).collect(&:to_s)\n filter(keys, type)\n end", "def court_types\n render json: GamePass.court_types_options\n end", "def index\n @edge_types = EdgeType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @edge_types }\n end\n end", "def drinks(type)\n drinkRecords.all(:type => type)\n end", "def index\n @bet_types = Bet::Type.all\n end", "def index\n @novelty_types = NoveltyType.all\n end", "def add_type(type)\n\n # does nothing, types are differentiated by the 'typ' column\n end", "def index\n @event_types = EventType.sorted\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @event_types }\n end\n end", "def type\n @json['type']\n end", "def index\n @crate_types = CrateType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @crate_types }\n end\n end", "def show\n @stakeholder_type = StakeholderType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @stakeholder_type }\n end\n end", "def types\n aux = WorkOrderType.by_name\n render json: serialized_work_order_types(aux)\n end", "def apply_types\n return unless _types\n\n _types.each do |rdf_type|\n unless resource.type.include? RDF::Vocabulary.find_term(rdf_type)\n resource << RDF::Statement.new(rdf_subject, RDF.type, RDF::Vocabulary.find_term(rdf_type))\n end\n end\n end", "def service_type_name\n \"REST\"\n end", "def get_product_count_types\n types = CountType.where(product_id: params[:product_id]).order(\"name ASC\").map { |type| [type.id, type.name] }\n render :json => types.to_json.to_s.to_json\n end", "def show\n render json: @end_service, status: :ok\n end", "def new\n @sighting = Sighting.new\n\t@types = Type.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sighting }\n end\n end", "def index\n @title = \"Типы страхования\"\n @insurance_types = InsuranceType.all\n\n respond_to do |format|\n if InsuranceType.all.length < 2\n format.html # index.html.erb\n format.json { render json: @insurance_types }\n else\n flash.now[:block] = \"Ограничение на количество типов!\"\n format.html { render action: \"index\" }\n format.json { render json: @user_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @food_type_id = @foodTypes.first\n\n if params['type']\n @foods = Food.includes(:type).includes(:nutritional_information).where( type_id: params['type']['type_id']).paginate(page: params[:page])\n else\n @foods = Food.includes(:type).includes(:nutritional_information).where( type_id: @food_type_id).paginate(page: params[:page])\n end\n\n respond_with @foods\n end", "def index\n @followuptypes = Followuptype.all\n end", "def index\n @followuptypes = Followuptype.all\n end", "def endpoint_types\n %w()\n end", "def show\n @partner_type = PartnerType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @partner_type }\n end\n end", "def show\n render json: @specification_type, serializer: Web::V1::SpecificationTypeSerializer\n end" ]
[ "0.5639627", "0.5563108", "0.5484765", "0.5408027", "0.53468215", "0.52912515", "0.52535987", "0.52492", "0.5208997", "0.5160403", "0.5160403", "0.5154902", "0.514129", "0.5138585", "0.510025", "0.50882685", "0.5086667", "0.5084799", "0.5071767", "0.50553745", "0.50340605", "0.50114554", "0.49973017", "0.49731854", "0.49643737", "0.49520397", "0.49476376", "0.49473524", "0.49430642", "0.493889", "0.49386868", "0.4923857", "0.4905559", "0.4895442", "0.48941758", "0.4888942", "0.48869422", "0.48784858", "0.4873049", "0.48617542", "0.48475814", "0.48475814", "0.48471275", "0.4842038", "0.48360363", "0.4834453", "0.48239994", "0.48156992", "0.48156175", "0.4811871", "0.48100263", "0.48074487", "0.4806279", "0.48045564", "0.48035112", "0.4800426", "0.48003596", "0.47985643", "0.47983402", "0.47940752", "0.47931653", "0.47865033", "0.47844017", "0.47816774", "0.4780683", "0.4777507", "0.47750488", "0.4775015", "0.47722057", "0.47676113", "0.47670007", "0.4766159", "0.47618997", "0.47569695", "0.4754563", "0.47527552", "0.4752434", "0.47509226", "0.47461733", "0.47460645", "0.4744964", "0.474334", "0.47391057", "0.47381532", "0.47381", "0.4734315", "0.47295532", "0.47241777", "0.47170383", "0.47156385", "0.47127783", "0.47097397", "0.47087094", "0.4707032", "0.47002143", "0.46974024", "0.46974024", "0.4690083", "0.4685353", "0.46819028" ]
0.64120215
0
GET /type_spends/1 GET /type_spends/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @type_spends = TypeSpend.all\n end", "def index\n @types = Type.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @types.lookup(params[:q]) }\n end\n end", "def index\n @heart_rate_types = HeartRateType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @heart_rate_types }\n end\n end", "def index\n @special_needs_types = SpecialNeedsType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @special_needs_types }\n end\n end", "def subscriptions\n update_subscriptions(params[:types]) if params[:types]\n @types = build_notification_types\n render :json => @types\n end", "def index\n @sends = Send.all\n end", "def index\n ends = End.find_each\n render json: ends\n end", "def index\n @talk_types = TalkType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @talk_types }\n end\n end", "def show\n @service_type = ServiceType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @service_type }\n end\n end", "def index\n @costtypes = Costtype.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @costtypes }\n end\n end", "def show\n @event_types = EventType.find(params[:id])\n respond_with @event_type\n end", "def show\n @types_of_apprenticeship = TypesOfApprenticeship.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @types_of_apprenticeship }\n end\n end", "def index\n @discipline_types = DisciplineType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @discipline_types }\n end\n end", "def appointment_types(params = {})\n scope 'default'\n get('schedule/appointmenttypes/', params)\n end", "def show\n if params[:term]\n @types = Type.all(:conditions => ['typeName LIKE ?', \"%#{params[:term]}%\"])\n else\n @type = Type.find(params[:id])\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @types }\n end\n end", "def type\n @activities = Activity.tagged_with_on(:types,params[:type_name]).page params[:page]\n respond_with @activities\n end", "def index\n render json: usage(params[:type])\n end", "def show\n @segment_type = SegmentType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @segment_type }\n end\n end", "def show\n @series_type = SeriesType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @series_type }\n end\n end", "def index\n @entry_types = EntryType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @entry_types }\n end\n end", "def index\n @typegroups = Typegroup.all\n respond_to do |format|\n format.html\n format.json { render json: @typegroups }\n end\n end", "def show\n @type = Type.find(params[:id])\n @things = @type.things\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @type }\n end\n end", "def index\n @student_types = StudentType.all\n\n render json: @student_types\n end", "def index\n @edge_types = EdgeType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @edge_types }\n end\n end", "def show\n @heart_rate_type = HeartRateType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @heart_rate_type }\n end\n end", "def show\n respond_to do |format|\n format.html\n format.json { render json: @typegroup }\n end\n end", "def index\n @crate_types = CrateType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @crate_types }\n end\n end", "def index\n @type_partners = TypePartner.all\n end", "def show\n @stakeholder_type = StakeholderType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @stakeholder_type }\n end\n end", "def index\n @specification_types = SpecificationType.all.order(\"display_order\")\n\n render json: @specification_types, each_serializer: Web::V1::SpecificationTypeSerializer\n end", "def index\n types = @user.tried_beer_ratings.last.beer_types.map do |type|\n {name: type.name, description: type.beg_description}\n end\n render json: types\n end", "def index\n @event_types = EventType.all\n respond_with @event_types\n end", "def show\n render json: @end_service, status: :ok\n end", "def show\n @site_type = SiteType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @site_type }\n end\n end", "def show\n @partner_type = PartnerType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @partner_type }\n end\n end", "def show\n @servicetype = Servicetype.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @servicetype }\n end\n end", "def show\n @special_needs_type = SpecialNeedsType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @special_needs_type }\n end\n end", "def index\n @pubtypes = Pubtype.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pubtypes }\n end\n end", "def index\n respond_to do |format|\n format.html\n format.json {\n\n render :json => TimeOff.joins('LEFT OUTER JOIN request_types ON time_offs.request_type_id = request_types.id')\n .joins('INNER JOIN users ON time_offs.user_id = users.id')\n .select(\n 'time_offs.id,\n time_offs.request_start_date,\n time_offs.request_end_date,\n time_offs.status,\n time_offs.comments,\n users.name as users_name,\n request_types.name as request_type_name') }\n end\n end", "def show\n @servicetype = Servicetype.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @servicetype }\n end\n end", "def show\n @talk_type = TalkType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @talk_type }\n end\n end", "def set_type_spend\n @type_spend = TypeSpend.find(params[:id]) rescue not_found\n end", "def show\n render json: @specification_type, serializer: Web::V1::SpecificationTypeSerializer\n end", "def index\n @session_types = SessionType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @session_types }\n end\n end", "def index\n @subsedes = Subsede.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @subsedes }\n end\n end", "def show\n spread_type = @tenant.tenant_details.pluck(:spread_type).uniq.join(\",\") unless @tenant.tenant_details.nil?\n\n @spread = JSON.parse RestClient.get(\"#{$pim_core_service}/pimcore/api/FoodRecepie/SpreadName?id=\"+spread_type)\n\n \n end", "def index\n @publication_types = PublicationType.find(:all, :conditions => {:client_id => session[:client_id]})\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @publication_types }\n end\n end", "def index \n respond_to do |format|\n format.html # index.html.erb\n format.json { \n asset_types = AssetType.all\n render json: asset_types \n }\n end\n end", "def index\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @resource_types }\n end\n end", "def index\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @service_demand_breakdowns }\n end\n end", "def new\n @sighting = Sighting.new\n\t@types = Type.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sighting }\n end\n end", "def show\n @talktype = Talktype.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @talktype }\n end\n end", "def index\n @bike_types = BikeType.all.order(\"updated_at DESC\").order(\"created_at DESC\")\n\n render json: @bike_types #each_serializer: Web::V1::BikeTypeSerializer\n end", "def index\n @sample_types = SampleType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sample_types }\n end\n end", "def types\n @client.make_request :get, reports_path\n end", "def show\n @budgeting_type = BudgetingType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @budgeting_type }\n end\n end", "def show\n @close_type = CloseType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @close_type }\n end\n end", "def show\n @event_type = EventType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event_type }\n end\n end", "def index\n @publinktypes = Publinktype.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @publinktypes }\n end\n end", "def index\n @gl_types = GlType.where(:gl_report => \"B\").order(\"gl_side DESC\") + GlType.where(:gl_report => \"T\").order(\"gl_side DESC\")\n @gl_typs = Array.new\n # @gl_types = @gl_types + @gl_types2\n respond_to do |format|\n format.html # index.html.erb\n\n format.json {\n @gl_types = @gl_types.select{|gl_type|\n gl_typ = Hash.new\n gl_type.attributes.each do |key, value|\n gl_typ[key] = value\n end\n gl_typ[:links] = CommonActions.object_crud_paths(nil, edit_gl_type_path(gl_type), gl_type_path(gl_type))\n @gl_typs.push(gl_typ)\n }\n render json: {:aaData => @gl_typs}\n }\n end\n end", "def show\n @dash_type = DashType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dash_type }\n end\n end", "def index\n @timerecord_types = TimerecordType.paginate(:page => params[:page], :per_page => per_page).order('id')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @timerecord_types }\n end\n end", "def index\n @ftypes = Ftype.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ftypes }\n end\n end", "def index\n @seance_types = SeanceType.all\n @seance_type = SeanceType.new\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @seance_types }\n end\n end", "def index\n @shape_types = ShapeType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @shape_types }\n end\n end", "def index\n @supplysites = Supplysite.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @supplysites }\n end\n end", "def index\n @event_types = EventType.sorted\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @event_types }\n end\n end", "def types\n types = Question.distinct.pluck(:type)\n render json: types.to_a\n end", "def search\n authorize! :show, PointsEntryType\n search_points_entry_types\n\n respond_to do |format|\n #format.html # actually, no.\n format.json {\n render json: @points_entry_types.select([:id, :name, :default_points])\n }\n end\n end", "def index\n @product_types = ProductType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @product_types }\n end\n end", "def index\n authorize! :show, PointsEntryType\n load_active_points_entry_types\n\n respond_to do |format|\n format.html\n format.json { render json: @points_entry_types }\n end\n end", "def show\n @travel_type = TravelType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @travel_type }\n end\n end", "def index\n @product_types = ProductType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @product_types }\n end\n end", "def show\n @lending = Lending.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @lending }\n end\n end", "def index\n @types = Type.all\n end", "def index\n @company_types = CompanyType.all\n\n render json: @company_types\n end", "def index\n @bs_types = BsType.all\n end", "def show\n @business_type = BusinessType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @business_type }\n end\n end", "def show\n @breadcrumb = 'read'\n @timerecord_type = TimerecordType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @timerecord_type }\n end\n end", "def show\n @entry_type = EntryType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @entry_type }\n end\n end", "def show\n @tasktype = Tasktype.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tasktype }\n end\n end", "def index\n @task_types = TaskType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @task_types }\n end\n end", "def index\n @act_types = ActType.order(:name).page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @act_types }\n end\n end", "def rec_new\n @beer_types_to_try = BeerType.limit(6).map{|type| [type.id, type.name]}\n render json: @beer_types_to_try\n end", "def index\n @sample_types = SampleType.all.sort_by(&:name)\n @first = if @sample_types.any?\n @sample_types[0].name\n else\n 'no sample types'\n end\n\n respond_to do |format|\n format.html { render layout: 'aq2' }\n format.json do\n render json: @sample_types\n .sort { |a, b| a.name <=> b.name }\n .to_json(methods: :field_types)\n end\n end\n end", "def index\n @techaxis_types = TechaxisType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @techaxis_types }\n end\n end", "def index\n @observation_types = ObservationType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @observation_types }\n end\n end", "def get_response_of_type(type)\n type = type.split('_').map(&:capitalize).join\n\n loop do\n response = get_message\n return response if response.class.name.demodulize == type\n end\n end", "def index\n @service_times = ServiceTime.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @service_times }\n end\n end", "def create\n @type_spend = TypeSpend.new(type_spend_params)\n\n respond_to do |format|\n if @type_spend.save\n format.html { redirect_to @type_spend, notice: 'Type spend was successfully created.' }\n format.json { render :show, status: :created, location: @type_spend }\n else\n format.html { render :new }\n format.json { render json: @type_spend.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @follow_up_types = FollowUpType.all\n end", "def show\n @client_type = ClientType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client_type }\n end\n end", "def index\n @snps = Snp.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @snps }\n end\n end", "def show\n @agency_type = AgencyType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @agency_type }\n end\n end", "def get_outype(outype_id)\n path = \"/d2l/api/lp/#{$lp_ver}/outypes/#{outype_id}\"\n _get(path)\nend", "def index\n @title = \"Типы страхования\"\n @insurance_types = InsuranceType.all\n\n respond_to do |format|\n if InsuranceType.all.length < 2\n format.html # index.html.erb\n format.json { render json: @insurance_types }\n else\n flash.now[:block] = \"Ограничение на количество типов!\"\n format.html { render action: \"index\" }\n format.json { render json: @user_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @typebourses = Typebourse.all\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 show\n @bus_seat_type = BusSeatType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bus_seat_type }\n end\n end", "def index\n @novelty_types = NoveltyType.all\n end", "def index\n @play_segments = PlaySegment.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @play_segments }\n end\n end" ]
[ "0.68092483", "0.5606812", "0.55895877", "0.556787", "0.55632246", "0.5535312", "0.5508944", "0.5415928", "0.5393468", "0.5372552", "0.53638375", "0.5358073", "0.53431433", "0.53099465", "0.5308323", "0.5305816", "0.53039306", "0.53034866", "0.529288", "0.52862304", "0.5260903", "0.5255023", "0.52543086", "0.5253587", "0.5231803", "0.5227098", "0.5203143", "0.5192586", "0.51865876", "0.5180138", "0.51768357", "0.5175498", "0.51661295", "0.5166042", "0.5163476", "0.51556873", "0.5152391", "0.5149589", "0.51489127", "0.5143519", "0.51406056", "0.5128259", "0.5127314", "0.5119065", "0.5117293", "0.5114146", "0.510669", "0.5098993", "0.50965565", "0.5095511", "0.5086541", "0.50857496", "0.50856715", "0.5077808", "0.5075079", "0.506528", "0.5063355", "0.5062487", "0.5056183", "0.50514877", "0.5045741", "0.50420976", "0.50322735", "0.5019732", "0.501676", "0.5009715", "0.5008341", "0.50048566", "0.5004649", "0.50043905", "0.5003178", "0.49989992", "0.4997943", "0.49946705", "0.49862564", "0.49728018", "0.4968228", "0.49661896", "0.49626315", "0.49583137", "0.49577793", "0.49575728", "0.49498326", "0.49472976", "0.4944413", "0.4940409", "0.4940173", "0.49387518", "0.49355578", "0.4933194", "0.49296904", "0.49232337", "0.49127954", "0.49076435", "0.49070984", "0.490568", "0.4902859", "0.4901635", "0.48999712", "0.48999113", "0.48998663" ]
0.0
-1
POST /type_spends POST /type_spends.json
def create @type_spend = TypeSpend.new(type_spend_params) respond_to do |format| if @type_spend.save format.html { redirect_to @type_spend, notice: 'Type spend was successfully created.' } format.json { render :show, status: :created, location: @type_spend } else format.html { render :new } format.json { render json: @type_spend.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @type_spends = TypeSpend.all\n end", "def create\n @slot_type_options =\n @newsletter.slot_types.try(:map) { |type| [type.name, type.id] }\n .append(['+ Add another type', 'new'])\n\n @slot = @newsletter.slots.build(slot_params)\n\n respond_to do |format|\n if @slot.save\n format.html { redirect_to pretty_newsletter_slots_path(@newsletter), notice: 'Slot was successfully created.' }\n format.json { render :show, status: :created, location: @slot }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @slot.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_type(type)\n end", "def add(type, body)\n if expired?(@begin_time)\n @auth = get_auth(@api_key)\n end\n if type == \"MozyPro\"\n body['name'] ||= 'New group'\n body =<<HERE\n {\n \"name\": \"#{body['name']}\",\n \"partner_id\": #{body['partner_id']}\n \"enable_stash\": \"Yes\"\n }\nHERE\n else\n body['name'] ||= 'New group'\n body = <<HERE\n {\n \"default_quotas\": [{\n \"type\": \"GrandFathered\",\n \"quota\": -1\n },\n {\n \"type\": \"Desktop\",\n \"quota\": -1\n },\n {\n \"type\": \"Server\",\n \"quota\": -1\n }],\n \"name\": \"#{body['name']}\",\n \"partner_id\": #{body['partner_id']}\n }\nHERE\n end\n\n Log.debug body\n\n user_group = RestClient.post \"#{@base_url}#{@add_url}\", body, header\n Log.debug('add 1 user_group')\n user_group_id = JSON.parse(user_group.body)['items'][0]['data']['id']\n end", "def sell_payment_types_create (email, params={})\r\n url = api_url \"/sell/payment_types​/new\"\r\n load = MultiJson.dump email: email\r\n req = request_params(params)\r\n\r\n feed_or_retry do\r\n RestClient.post url, load, req \r\n end \r\n end", "def add_type(type)\n\n # nothing to be done\n end", "def add_type(type)\n\n # nothing to be done\n end", "def create_break_type(body:)\n new_api_call_builder\n .request(new_request_builder(HttpMethodEnum::POST,\n '/v2/labor/break-types',\n 'default')\n .header_param(new_parameter('application/json', key: 'Content-Type'))\n .body_param(new_parameter(body))\n .header_param(new_parameter('application/json', key: 'accept'))\n .body_serializer(proc do |param| param.to_json unless param.nil? end)\n .auth(Single.new('global')))\n .response(new_response_handler\n .deserializer(APIHelper.method(:json_deserialize))\n .is_api_response(true)\n .convertor(ApiResponse.method(:create)))\n .execute\n end", "def add_dummy_type\n params[:data] ||= {}\n params[:data][:type] = resource_klass._type.to_s\n end", "def create\n @type = Type.new(type_params)\n @sub_types = params[:subtype_attributes]\n if @type.save\n @sub_types.each do |subtype|\n @subtype = @type.subtype.new\n @subtype.name = subtype[\"name\"]\n @subtype.code = subtype[\"code\"]\n @subtype.save\n end\n flash[:notice] = 'Type was successfully created.'\n redirect_to types_path\n else\n flash[:error] = @type.errors.full_messages\n render \"new\"\n end\n end", "def create\n section_type_ids = params[:site_type].delete(\"section_type_ids\")\n @site_type = SiteType.new(params[:site_type])\n @site_type.section_type_ids = section_type_ids\n\n respond_to do |format|\n if @site_type.save\n format.html { redirect_to @site_type, notice: 'Site type was successfully created.' }\n format.json { render json: @site_type, status: :created, location: @site_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @site_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_end_products\n case params[:type]\n when \"full\"\n BGSService.end_product_data = BGSService.existing_full_grants\n when \"partial\"\n BGSService.end_product_data = BGSService.existing_partial_grants\n when \"none\"\n BGSService.end_product_data = BGSService.no_grants\n when \"all\"\n BGSService.end_product_data = BGSService.all_grants\n end\n\n redirect_to \"/test/users\"\n end", "def subscriptions\n update_subscriptions(params[:types]) if params[:types]\n @types = build_notification_types\n render :json => @types\n end", "def create\n @outgoing_type = OutgoingType.new(params[:outgoing_type])\n\n respond_to do |format|\n if @outgoing_type.save\n format.html { redirect_to(outgoing_types_path, :notice => 'Outgoing type was successfully created.') }\n format.xml { render :xml => @outgoing_type, :status => :created, :location => @outgoing_type }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @outgoing_type.errors, :status => :unprocessable_entity }\n end\n end\n end", "def type_params\n params.from_jsonapi.require(:type).permit(:name)\n end", "def create\n @type_partner = TypePartner.new(type_partner_params)\n\n respond_to do |format|\n if @type_partner.save\n format.html { redirect_to @type_partner, notice: 'Type partner was successfully created.' }\n format.json { render :show, status: :created, location: @type_partner }\n else\n format.html { render :new }\n format.json { render json: @type_partner.errors, status: :unprocessable_entity }\n end\n end\n end", "def send_type_params\n params.require(:send_type).permit(:info)\n end", "def create\n @wedding = Wedding.new(params[:wedding])\n if (!params[:wedding][:service_type_ids])\n params[:wedding][:service_type_ids] = params[:wedding][:service_type_ids].split(';')\n end\n params[:wedding][:service_type_ids] ||= []\n ServiceType.all.each do |service_type|\n @wedding.service_types_weddings << ServiceTypesWedding.create(:service_type_id => service_type.id, \n :wedding_id => @wedding.id,\n :activated => params[:wedding][:service_type_ids].include?(service_type.id.to_s))\n end\n\n respond_to do |format|\n if @wedding.save\n format.html { redirect_to @wedding, notice: 'Wedding was successfully created.' }\n format.json { render json: @wedding, status: :created, location: @wedding }\n else\n format.html { render action: \"new\" }\n format.json { render json: @wedding.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @bs_type = BsType.new(bs_type_params)\n\n respond_to do |format|\n if @bs_type.save\n format.html { redirect_to @bs_type, notice: 'Bs type was successfully created.' }\n format.json { render :show, status: :created, location: @bs_type }\n else\n format.html { render :new }\n format.json { render json: @bs_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @stop = params[:type].constantize.new(stop_params)\n\n respond_to do |format|\n if @stop.save\n format.html { redirect_to edit_order_path @stop.order, notice: \"Stop was successfully created.\" }\n format.json { render :show, status: :created, location: @stop }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @stop.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @type = Type.new(type_params)\n\n unless @type.save\n render json: @type.errors, status: :unprocessable_entity\n end\n \n end", "def subscriber_add(statuspage_id, method, address, silent = '1', granular = '')\n data = {}\n data['statuspage_id'] = statuspage_id\n data['method'] = method\n data['address'] = address\n data['silent'] = silent\n data['granular'] = granular\n\n request :method => :post,\n :url => @url + 'subscriber/add',\n :payload => data\n end", "def create\n @partner_type = PartnerType.new(params[:partner_type])\n\n respond_to do |format|\n if @partner_type.save\n format.html { redirect_to @partner_type, notice: 'Partner type was successfully created.' }\n format.json { render json: @partner_type, status: :created, location: @partner_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @partner_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @spit_type = SpitType.new(params[:spit_type])\n\n respond_to do |format|\n if @spit_type.save\n format.html { redirect_to(@spit_type, :notice => 'Spit type was successfully created.') }\n format.xml { render :xml => @spit_type, :status => :created, :location => @spit_type }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @spit_type.errors, :status => :unprocessable_entity }\n end\n end\n end", "def add_type(type)\n\n # does nothing, types are differentiated by the 'typ' column\n end", "def create\n @use_type = UseType.new(use_type_params)\n\n respond_to do |format|\n if @use_type.save\n format.html { redirect_to @use_type, notice: 'Use type was successfully created.' }\n format.json { render :show, status: :created, location: @use_type }\n else\n format.html { render :new }\n format.json { render json: @use_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @item_type = ItemType.new(item_type_params)\n\n respond_to do |format|\n if @item_type.save\n format.html { redirect_to @item_type, notice: 'ItemType was successfully created.' }\n format.json { render action: 'show', status: :created, location: @suplier }\n else\n format.html { render action: 'new' }\n format.json { render json: @item_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def rec_new\n @beer_types_to_try = BeerType.limit(6).map{|type| [type.id, type.name]}\n render json: @beer_types_to_try\n end", "def evals_types\n call_path = \"evals/types\"\n data = build_post_data(\"\")\n perform_post(build_url(call_path), data)\n end", "def type_spend_params\n params.require(:type_spend).permit(:name, :description, :code, :user_id)\n end", "def create\n @valid_type = ValidType.new(valid_type_params)\n @valid_type.typed = true\n\n respond_to do |format|\n if @valid_type.save\n format.html { redirect_to valid_types_path, notice: 'Entity Type was successfully created.' }\n format.json { render :show, status: :created, location: @valid_type }\n else\n format.html { render :new }\n format.js { render :new }\n format.json { render json: @valid_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @series_type = SeriesType.new(params[:series_type])\n\n respond_to do |format|\n if @series_type.save\n format.html { redirect_to @series_type, notice: 'Series type was successfully created.' }\n format.json { render json: @series_type, status: :created, location: @series_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @series_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @bet_type = Bet::Type.new(bet_type_params)\n\n respond_to do |format|\n if @bet_type.save\n format.html { redirect_to @bet_type, notice: 'Type was successfully created.' }\n format.json { render :show, status: :created, location: @bet_type }\n else\n format.html { render :new }\n format.json { render json: @bet_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_types\n\t[]\nend", "def create_types\n\t[]\nend", "def create\n field_type_ids = params[:entry_type].delete(\"field_type_ids\")\n @entry_type = EntryType.new(params[:entry_type])\n @entry_type.field_type_ids = field_type_ids\n @entry_type.form_code = build_form_code(@entry_type.field_types)\n @entry_type.model_code = build_model_code(@entry_type.name, @entry_type.field_types)\n @entry_type.model = build_model_from_code(@entry_type)\n\n respond_to do |format|\n if @entry_type.save\n format.html { redirect_to @entry_type, notice: 'Entry type was successfully created.' }\n format.json { render json: @entry_type, status: :created, location: @entry_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @entry_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @segment_type = SegmentType.new(params[:segment_type])\n\n respond_to do |format|\n if @segment_type.save\n format.html { redirect_to @segment_type, notice: 'Segment type was successfully created.' }\n format.json { render json: @segment_type, status: :created, location: @segment_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @segment_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def type_params\n params.require(:type).permit( :name)\n end", "def add_type(type)\n\n # does nothing, types are differentiated by the 'typ' column\n end", "def add\n\n item = params[:item]\n type = params[:type]\n\n added = nil\n\n if type=='song'\n\n if Favorite.exist_song(item, user_signed_in?, current_user)\n added = Song.quit_favorite(item, user_signed_in?, current_user)\n else\n added = Song.add_favorite(item, user_signed_in?, current_user)\n end\n \n end\n\n if type=='movie'\n\n year = item['year']\n name = item['name']\n\n if Favorite.exist_movie(year, name, user_signed_in?, current_user)\n added = Movie.quit_favorite(item, user_signed_in?, current_user)\n else\n added = Movie.add_favorite(item, user_signed_in?, current_user)\n end\n\n end\n\n response = {\n :added => added,\n }\n \n render :json =>response\n \n end", "def create\n @sponsor_type = @event.sponsor_types.build(params[:sponsor_type])\n\n respond_to do |format|\n if @sponsor_type.save\n format.html { redirect_to([@event, @sponsor_type], :notice => 'Sponsor type was successfully created.') }\n format.xml { render :xml => @sponsor_type, :status => :created, :location => @sponsor_type }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @sponsor_type.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @fender_type = FenderType.new(fender_type_params)\n\n respond_to do |format|\n if @fender_type.save\n format.html { redirect_to fender_types_path, notice: 'Fender type was successfully created.' }\n format.json { render :show, status: :created, location: @fender_type }\n else\n format.html { render :new }\n format.json { render json: @fender_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @event_type = EventType.new(params[:event_type])\n\n respond_to do |format|\n if @event_type.save\n\t\t\t\tmsg = I18n.t('app.msgs.success_created', :obj => I18n.t('app.common.event_type'))\n\t\t\t\tsend_status_update(I18n.t('app.msgs.cache_cleared', :action => msg))\n format.html { redirect_to admin_event_type_path(@event_type), notice: msg }\n format.json { render json: @event_type, status: :created, location: @event_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @event_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def use_type_params\n params.require(:use_type).permit(:name)\n end", "def shipment_type_params\n params.require(:shipment_type).permit(:shipment_type_id, :type_name)\n end", "def create\n @shipment_type = ShipmentType.new(shipment_type_params)\n\n respond_to do |format|\n if @shipment_type.save\n format.html { redirect_to @shipment_type, notice: 'Shipment type was successfully created.' }\n format.json { render :show, status: :created, location: @shipment_type }\n else\n format.html { render :new }\n format.json { render json: @shipment_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @collection = current_user.collections.find(params[:collection_id])\n @entity_type = @collection.entity_types.new(params[:entity_type])\n\n respond_to do |format|\n if @entity_type.save\n format.html { redirect_to collection_entity_types_path(@collection), notice: 'Type was successfully created.' }\n format.json { render json: @entity_type, status: :created, location: @entity_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @entity_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @typegroup = Typegroup.new(typegroup_params)\n\n respond_to do |format|\n if @typegroup.save\n format.html { redirect_to @typegroup, notice: 'Typegroup was successfully created.' }\n format.json { render action: 'show', status: :created, location: @typegroup }\n else\n format.html { render action: 'new' }\n format.json { render json: @typegroup.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @segment_type = SegmentType.new(segment_type_params)\n\n respond_to do |format|\n if @segment_type.save\n format.html { redirect_to @segment_type, notice: 'Segment type was successfully created.' }\n format.json { render :show, status: :created, location: @segment_type }\n else\n format.html { render :new }\n format.json { render json: @segment_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_types\n\t\t[]\n\tend", "def create_types\n\t\t[]\n\tend", "def addtype_params\n params.require(:addtype).permit(:Addtypecode, :Name, :Orgainize_id, :Description,:fbillstatus,:Creator,:CreateDate,:Approver,:ApproverDate)\n end", "def type_params\n params.require(:type).permit(:name)\n end", "def create\n @spending = Spending.new(spending_params)\n respond_to do |format|\n if @spending.save \n format.html { redirect_to new_spending_url, notice: 'Spending was successfully created.' }\n format.json { render action: 'show', status: :created, location: @spending }\n else\n format.html { render action: 'new' }\n format.json { render json: @spending.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @subscription_type = SubscriptionType.new(subscription_type_params)\n\n respond_to do |format|\n if @subscription_type.save\n format.html { redirect_to @subscription_type, notice: 'Subscription types was successfully created.' }\n format.json { render :show, status: :created, location: @subscription_type }\n else\n format.html { render :new }\n format.json { render json: @subscription_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @novelty_type = NoveltyType.new(novelty_type_params)\n\n respond_to do |format|\n if @novelty_type.save\n format.html { redirect_to @novelty_type, notice: 'Novelty type was successfully created.' }\n format.json { render :show, status: :created, location: @novelty_type }\n else\n format.html { render :new }\n format.json { render json: @novelty_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_event\n id = params[:id].to_i\n from = Time.parse(params[:from])\n to = from + 1.day\n to = Time.parse(params[:to]) if params[:to]\n \n obj = nil\n if params[:type] == \"event\"\n obj = current_itinerary.add_event(id, from, to) \n elsif params[:type] == \"attraction\"\n obj = current_itinerary.add_attraction(id, from, to)\n elsif params[:type] == \"meal\"\n obj = current_itinerary.add_meal(id, from, to)\n elsif params[:type] == \"transportation\"\n obj = current_itinerary.add_transportation(id, from, to)\n end\n\n render :json => {\n :status => 0,\n :obj => obj\n }\n end", "def create\n @service_type = ServiceType.new(params[:service_type])\n\n respond_to do |format|\n if @service_type.save\n format.html { redirect_to @service_type, notice: 'Service type was successfully created.' }\n format.json { render json: @service_type, status: :created, location: @service_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @service_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def add(type, description, options={})\n type = type.downcase\n if type == 'todo' then @items.push TodoItem.new(description, options) #uses ToDoItem class in todo.rb\n elsif type == 'event' then @items.push EventItem.new(description, options) #uses EventItem class in event.rb\n elsif type == 'link' then @items.push LinkItem.new(description, options) #usesLinkItem class in event.rb\n else raise UdaciListErrors::InvalidItemType,\n \"'#{type}' is not a valid data type\" #raise error if type is not one of the 3 required\n end\n end", "def create\n @types_of_apprenticeship = TypesOfApprenticeship.new(params[:types_of_apprenticeship])\n\n respond_to do |format|\n if @types_of_apprenticeship.save\n format.html { redirect_to @types_of_apprenticeship, notice: 'Types of apprenticeship was successfully created.' }\n format.json { render json: @types_of_apprenticeship, status: :created, location: @types_of_apprenticeship }\n else\n format.html { render action: \"new\" }\n format.json { render json: @types_of_apprenticeship.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @type_sound = TypeSound.new(type_sound_params)\n\n respond_to do |format|\n if @type_sound.save\n format.html { redirect_to type_sounds_url, notice: 'tipo de sonido a sido creado.' }\n format.json { render :show, status: :created, location: @type_sound }\n else\n format.html { render :new }\n format.json { render json: @type_sound.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_to_services(name, type, description)\n data = {\n 'OS-KSADM:service' => {\n 'name' => name,\n 'type' => type,\n 'description' => description\n }\n }\n return post_request(address(\"/OS-KSADM/services\"), data, token())\n end", "def create\n @receipt_item_type = current_account.receipt_item_types.create(receipt_item_type_params)\n if @receipt_item_type\n respond_with @receipt_item_type do |format|\n format.json { render :json => current_account.receipt_item_types.include_names.find(@receipt_item_type.id) }\n end\n else\n respond_with @receipt_item_type\n end\n end", "def type_params\n params.require(:type).permit(:common_name, :botanical_name, :info_panel, :count)\n end", "def create\n @entity_type = EntityType.new(entity_type_params)\n @entity_type.collection_id = @collection.id\n respond_to do |format|\n if @entity_type.save\n format.html { redirect_to collection_entity_types_path(@collection), notice: 'The entity type was successfully created.' }\n format.json { render :show, status: :created, location: @entity_type }\n else\n format.html { render :new }\n format.json { render json: @entity_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def type_partner_params\n params.require(:type_partner).permit(:type, :description)\n end", "def create\n @sale_type = SaleType.new(sale_type_params)\n\n respond_to do |format|\n if @sale_type.save\n format.html { redirect_to @sale_type, notice: \"Sale type was successfully created.\" }\n format.json { render :show, status: :created, location: @sale_type }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @sale_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def accept_list_end list\n @list_type.pop\n end", "def create\n @stock = Stock.new(stock_params)\n\n respond_to do |format|\n if @stock.save\n temp_params = stock_params\n temp_params[\"type\"] = stock_params[\"type\"] == \"NSE\" ? \"BSE\" : \"NSE\"\n Stock.create(temp_params)\n format.html { redirect_to @stock, notice: 'Stock was successfully created.' }\n format.json { render :show, status: :created, location: @stock }\n else\n format.html { render :new }\n format.json { render json: @stock.errors, status: :unprocessable_entity }\n end\n end\n end", "def follow_up_type_params\n params.require(:follow_up_type).permit(:name)\n end", "def create\n @subject_type = SubjectType.new(subject_type_params)\n\n respond_to do |format|\n if @subject_type.save\n format.html { redirect_to @subject_type, notice: 'Subject type was successfully created.' }\n format.json { render :show, status: :created, location: @subject_type }\n else\n format.html { render :new }\n format.json { render json: @subject_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def fender_type_params\n params.require(:fender_type).permit(:name, :model_part, :status)\n end", "def set_addtype\n @addtype = Addtype.find(params[:id])\n end", "def create\n @special_needs_type = SpecialNeedsType.new(params[:special_needs_type])\n\n respond_to do |format|\n if @special_needs_type.save\n format.html { redirect_to @special_needs_type, :notice => 'Tipo de necessidade especial criada com sucesso.' }\n format.json { render :json => @special_needs_type, :status => :created, :location => @special_needs_type }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @special_needs_type.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_type_spend\n @type_spend = TypeSpend.find(params[:id]) rescue not_found\n end", "def create\n @stakeholder_type = StakeholderType.new(params[:stakeholder_type])\n\n respond_to do |format|\n if @stakeholder_type.save\n format.html { redirect_to @stakeholder_type, notice: 'Stakeholder type was successfully created.' }\n format.json { render json: @stakeholder_type, status: :created, location: @stakeholder_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @stakeholder_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_additional(name, type, klass)\n self.payload += self.add_record(name, type, klass).encode\n self.additional_rr += 1\n end", "def create\n @ending = Ending.new(ending_params)\n\n respond_to do |format|\n if @ending.save\n format.html { redirect_to @ending, notice: 'Ending was successfully created.' }\n format.json { render :show, status: :created, location: @ending }\n else\n format.html { render :new }\n format.json { render json: @ending.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @heart_rate_type = HeartRateType.new(params[:heart_rate_type])\n\n respond_to do |format|\n if @heart_rate_type.save\n format.html { redirect_to @heart_rate_type, notice: 'Heart rate type was successfully created.' }\n format.json { render json: @heart_rate_type, status: :created, location: @heart_rate_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @heart_rate_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @expense_sub_type = ExpenseSubType.new(expense_sub_type_params)\n\n respond_to do |format|\n if @expense_sub_type.save\n format.html { redirect_to @expense_sub_type, notice: 'Expense sub type was successfully created.' }\n format.json { render :show, status: :created, location: @expense_sub_type }\n else\n format.html { render :new }\n format.json { render json: @expense_sub_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @itemtype = Itemtype.new(itemtype_params)\n\n respond_to do |format|\n if @itemtype.save\n format.html { redirect_to @itemtype, notice: 'Itemtype was successfully created.' }\n format.json { render :show, status: :created, location: @itemtype }\n else\n format.html { render :new }\n format.json { render json: @itemtype.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n userID = session[:user_id]\n editionID = params[:edition_id]\n price = params[:price]\n\n uri = URI(\"http://107.170.7.58:4567/api/create/sell\")\n parameters = {\"ext\" => \"json\", \"user_id\" => userID, \"edition_id\" => editionID, \"price\" => price, \"start_date\" => Time.now, \"end_date\" => 90.days.from_now}\n response = Net::HTTP.post_form(uri, parameters)\n list = JSON.parse(response.body)\n\n @response = list[0][\"kind\"]\n end", "def create\n @addresstype = Addresstype.new(params[:addresstype])\n\n respond_to do |format|\n if @addresstype.save\n format.html { redirect_to @addresstype, notice: 'Addresstype was successfully created.' }\n format.json { render json: @addresstype, status: :created, location: @addresstype }\n else\n format.html { render action: \"new\" }\n format.json { render json: @addresstype.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @typebourse = Typebourse.new(typebourse_params)\n\n respond_to do |format|\n if @typebourse.save\n format.html { redirect_to @typebourse, notice: 'Typebourse was successfully created.' }\n format.json { render :show, status: :created, location: @typebourse }\n else\n format.html { render :new }\n format.json { render json: @typebourse.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_answer(name, type, klass)\n self.payload += self.add_record(name, type, klass).encode\n self.answer_rr += 1\n end", "def create\n @talk_type = TalkType.new(params[:talk_type])\n\n respond_to do |format|\n if @talk_type.save\n flash[:notice] = 'Talk type was successfully created.'\n format.html { redirect_to :action => :index }\n format.json { render json: @talk_type, status: :created, location: @talk_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @talk_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @eventtype = Eventtype.new(eventtype_params)\n\n respond_to do |format|\n if @eventtype.save\n format.html { redirect_to @eventtype, notice: 'Eventtype was successfully created.' }\n format.json { render action: 'show', status: :created, location: @eventtype }\n else\n format.html { render action: 'new' }\n format.json { render json: @eventtype.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @q_type = QType.new(q_type_params)\n\n respond_to do |format|\n if @q_type.save\n format.html { redirect_to @q_type, notice: 'Q type was successfully created.' }\n format.json { render :show, status: :created, location: @q_type }\n else\n format.html { render :new }\n format.json { render json: @q_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @type = Type.new(params[:type])\n the_name = @type.name\n\n if the_name.empty?\n redirect_to types_path, notice: 'Type a little, pick something from the list, hit the button!'\n else\n old_name = Type.where({name: @type.name}).first\n\n if old_name\n redirect_to old_name\n else\n\n the_name.slice! 'New: \"'\n the_name.chop!\n the_name.capitalize!\n @type.name = the_name\n @type.owner = current_user\n @type.active = false\n\n \n respond_to do |format|\n if @type.save\n #format.html { redirect_to edit_type_path(@type), notice: \"Congrats! Your the first to reveiw a #{@type.name}, what is it?\" }\n format.html { redirect_to check_type_path(@type), notice: \"Looking for #{@type.name}?\" }\n format.json { render json: @type, status: :created, location: @type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @type.errors, status: :unprocessable_entity }\n end\n end\n end\n end\n end", "def create\n @type_of_cleaning_and_washing = TypeOfCleaningAndWashing.new(params[:type_of_cleaning_and_washing])\n\n respond_to do |format|\n if @type_of_cleaning_and_washing.save\n format.html { redirect_to type_of_cleaning_and_washings_path, notice: 'Type of cleaning and washing was successfully created.' }\n format.json { render json: @type_of_cleaning_and_washing, status: :created, location: @type_of_cleaning_and_washing }\n else\n format.html { render action: \"new\" }\n format.json { render json: @type_of_cleaning_and_washing.errors, status: :unprocessable_entity }\n end\n end\n end", "def sell_payment_types_update (payment_type_id, email, params={})\r\n url = api_url \"/sell/payment_types​/#{payment_type_id}\"\r\n load = MultiJson.dump email: email\r\n req = request_params(params)\r\n\r\n feed_or_retry do\r\n RestClient.put url, load, req \r\n end \r\n end", "def add(key, type, options={})\n @client.add(key, type, options)\n end", "def create\n @method_type = MethodType.new(method_type_params)\n\n respond_to do |format|\n if @method_type.save\n format.html { redirect_to @method_type, notice: \"Method type was successfully created.\" }\n format.json { render :show, status: :created, location: @method_type }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @method_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @close_type = CloseType.new(params[:close_type])\n\n respond_to do |format|\n if @close_type.save\n format.html { redirect_to @close_type, notice: 'Close type was successfully created.' }\n format.json { render json: @close_type, status: :created, location: @close_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @close_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @consumer_type = ConsumerType.new(consumer_type_params)\n\n respond_to do |format|\n if @consumer_type.save\n format.html { redirect_to @consumer_type, notice: 'Consumer type was successfully created.' }\n format.json { render :show, status: :created, location: @consumer_type }\n else\n format.html { render :new }\n format.json { render json: @consumer_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @followuptype = Followuptype.new(followuptype_params)\n\n respond_to do |format|\n if @followuptype.save\n format.html { redirect_to @followuptype, notice: 'Followuptype was successfully created.' }\n format.json { render :show, status: :created, location: @followuptype }\n else\n format.html { render :new }\n format.json { render json: @followuptype.errors, status: :unprocessable_entity }\n end\n end\n end", "def arrivaltype_params\n params.require(:arrivaltype).permit(:arrivalTypes)\n end", "def create\n @email_type = EmailType.new(email_type_params)\n\n respond_to do |format|\n if @email_type.save\n format.html { redirect_to @email_type, notice: 'Email type was successfully created.' }\n format.json { render action: 'show', status: :created, location: @email_type }\n else\n format.html { render action: 'new' }\n format.json { render json: @email_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @subject_type = SubjectType.new(subject_type_params)\n\n respond_to do |format|\n if @subject_type.save\n format.html { redirect_to @subject_type, notice: t('controller.successfully_created', model: t('activerecord.models.subject_type')) }\n format.json { render json: @subject_type, status: :created, location: @subject_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @subject_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @follow_up_type = FollowUpType.new(follow_up_type_params)\n\n respond_to do |format|\n if @follow_up_type.save\n format.html { redirect_to @follow_up_type, notice: 'Follow up type was successfully created.' }\n format.json { render action: 'show', status: :created, location: @follow_up_type }\n else\n format.html { render action: 'new' }\n format.json { render json: @follow_up_type.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.5583205", "0.5558214", "0.5554737", "0.5477166", "0.5410528", "0.53973454", "0.53973454", "0.5330582", "0.5275746", "0.5266227", "0.52426887", "0.521633", "0.52086836", "0.5157111", "0.5155337", "0.51474756", "0.5117887", "0.51015735", "0.5082392", "0.5061917", "0.50576", "0.5034633", "0.50294924", "0.502364", "0.50051504", "0.50018907", "0.49980274", "0.49904293", "0.49877685", "0.4986087", "0.49803868", "0.49745932", "0.49550527", "0.49540278", "0.49540278", "0.4944607", "0.4938629", "0.49263984", "0.4910009", "0.48988307", "0.48961502", "0.48953053", "0.48848206", "0.4882524", "0.4877076", "0.48752668", "0.48713464", "0.48683724", "0.48657048", "0.48560143", "0.48560143", "0.4855397", "0.48518175", "0.4851089", "0.4844453", "0.4844045", "0.48439565", "0.48418623", "0.4839953", "0.48377097", "0.48371813", "0.4835841", "0.4832128", "0.48319975", "0.4828868", "0.48277482", "0.48256806", "0.48210946", "0.48186153", "0.48168463", "0.48145822", "0.4797769", "0.479574", "0.47934815", "0.47906533", "0.47904864", "0.47901583", "0.47876543", "0.47845545", "0.47816354", "0.47809368", "0.47712672", "0.4770207", "0.4767324", "0.4765631", "0.47609556", "0.4755252", "0.47504172", "0.4737166", "0.47333017", "0.47313216", "0.4718669", "0.47151667", "0.47151193", "0.4714117", "0.47119924", "0.4711293", "0.47110423", "0.47104064", "0.47099298" ]
0.54942954
3
PATCH/PUT /type_spends/1 PATCH/PUT /type_spends/1.json
def update respond_to do |format| if @type_spend.update(type_spend_params) format.html { redirect_to @type_spend, notice: 'Type spend was successfully updated.' } format.json { render :show, status: :ok, location: @type_spend } else format.html { render :edit } format.json { render json: @type_spend.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @type.update(type_params)\n end", "def update\n respond_to do |format|\n if @spending.update(spending_params)\n format.html { redirect_to @spending, notice: 'Spending was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @spending.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @site_type = SiteType.find(params[:id])\n\n respond_to do |format|\n section_type_ids = params[:site_type].delete(\"section_type_ids\")\n if @site_type.update_attributes(params[:site_type]) && @site_type.section_type_ids = section_type_ids\n format.html { redirect_to @site_type, notice: 'Site type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @site_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @call_type.update(call_type_params)\n format.html { redirect_to @call_type, notice: 'Call type was successfully updated.' }\n format.json { render :show, status: :ok, location: @call_type }\n else\n format.html { render :edit }\n format.json { render json: @call_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @special_needs_type = SpecialNeedsType.find(params[:id])\n\n respond_to do |format|\n if @special_needs_type.update_attributes(params[:special_needs_type])\n format.html { redirect_to @special_needs_type, :notice => 'Tipo de necessidade especial atualizada com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @special_needs_type.errors, :status => :unprocessable_entity }\n end\n end\n end", "def patch(type, info)\n path, info = type_info(type, :path), force_case(info)\n ida = type == :client ? 'client_id' : 'id'\n raise ArgumentError, \"info must include #{ida}\" unless id = info[ida]\n hdrs = headers\n if info && info['meta'] && (etag = info['meta']['version'])\n hdrs.merge!('if-match' => etag)\n end\n reply = json_parse_reply(@key_style,\n *json_patch(@target, \"#{path}/#{Addressable::URI.encode(id)}\", info, hdrs))\n\n # hide client endpoints that are not quite scim compatible\n type == :client && !reply ? get(type, info['client_id']): reply\n end", "def update\n respond_to do |format|\n if @bs_type.update(bs_type_params)\n format.html { redirect_to @bs_type, notice: 'Bs type was successfully updated.' }\n format.json { render :show, status: :ok, location: @bs_type }\n else\n format.html { render :edit }\n format.json { render json: @bs_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n instance = get_instance\n set_meta instance\n if instance.update(type_params)\n # Redirect to index\n format.html { redirect_to redirect_address(@type), notice: \"#{type_label} was successfully updated.\" }\n else\n flash[:alert] = \"#{type_label} has not been saved.\"\n format.html { render sti_template(@type, :edit) }\n end\n end\n end", "def update\n @entry_type = EntryType.find(params[:id])\n\n respond_to do |format|\n field_type_ids = params[:entry_type].delete(\"field_type_ids\")\n @entry_type.field_type_ids = field_type_ids if field_type_ids\n params[:entry_type].delete(\"form_code\")\n if @entry_type.update_attributes(params[:entry_type])\n format.html { redirect_to @entry_type, notice: 'Entry type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @entry_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @spec_type.update(spec_type_params)\n format.html { redirect_to @spec_type, notice: 'Spec type was successfully updated.' }\n format.json { render :show, status: :ok, location: @spec_type }\n else\n format.html { render :edit }\n format.json { render json: @spec_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @follow_up_type.update(follow_up_type_params)\n format.html { redirect_to @follow_up_type, notice: 'Follow up type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @follow_up_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @service_type = ServiceType.find(params[:id])\n\n respond_to do |format|\n if @service_type.update_attributes(params[:service_type])\n format.html { redirect_to @service_type, notice: 'Service type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @service_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @spit_type = SpitType.find(params[:id])\n\n respond_to do |format|\n if @spit_type.update_attributes(params[:spit_type])\n format.html { redirect_to(@spit_type, :notice => 'Spit type was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @spit_type.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @method_type.update(method_type_params)\n format.html { redirect_to @method_type, notice: \"Method type was successfully updated.\" }\n format.json { render :show, status: :ok, location: @method_type }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @method_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @use_type.update(use_type_params)\n format.html { redirect_to @use_type, notice: 'Use type was successfully updated.' }\n format.json { render :show, status: :ok, location: @use_type }\n else\n format.html { render :edit }\n format.json { render json: @use_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @followuptype = Followuptype.find(params[:id])\n respond_to do |format|\n if @followuptype.update(followuptype_params)\n format.html { redirect_to followuptypes_path }\n format.json\n format.js\n else\n format.js\n format.html { render :edit }\n format.json \n end\n end\n end", "def update\n @partner_type = PartnerType.find(params[:id])\n\n respond_to do |format|\n if @partner_type.update_attributes(params[:partner_type])\n format.html { redirect_to @partner_type, notice: 'Partner type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @partner_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @series_type = SeriesType.find(params[:id])\n\n respond_to do |format|\n if @series_type.update_attributes(params[:series_type])\n format.html { redirect_to @series_type, notice: 'Series type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @series_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @addtype.update(addtype_params)\n format.html { redirect_to @addtype, notice: '变动方式修改成功!' }\n format.json { render :show, status: :ok, location: @addtype }\n else\n format.html { render :edit }\n format.json { render json: @addtype.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @student_type = StudentType.find(params[:id])\n\n if @student_type.update(student_type_params)\n head :no_content\n else\n render json: @student_type.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @type_partner.update(type_partner_params)\n format.html { redirect_to @type_partner, notice: 'Type partner was successfully updated.' }\n format.json { render :show, status: :ok, location: @type_partner }\n else\n format.html { render :edit }\n format.json { render json: @type_partner.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_break_type(id:,\n body:)\n new_api_call_builder\n .request(new_request_builder(HttpMethodEnum::PUT,\n '/v2/labor/break-types/{id}',\n 'default')\n .template_param(new_parameter(id, key: 'id')\n .should_encode(true))\n .header_param(new_parameter('application/json', key: 'Content-Type'))\n .body_param(new_parameter(body))\n .header_param(new_parameter('application/json', key: 'accept'))\n .body_serializer(proc do |param| param.to_json unless param.nil? end)\n .auth(Single.new('global')))\n .response(new_response_handler\n .deserializer(APIHelper.method(:json_deserialize))\n .is_api_response(true)\n .convertor(ApiResponse.method(:create)))\n .execute\n end", "def update\n @segment_type = SegmentType.find(params[:id])\n\n respond_to do |format|\n if @segment_type.update_attributes(params[:segment_type])\n format.html { redirect_to @segment_type, notice: 'Segment type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @segment_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @segment_type.update(segment_type_params)\n format.html { redirect_to @segment_type, notice: 'Segment type was successfully updated.' }\n format.json { render :show, status: :ok, location: @segment_type }\n else\n format.html { render :edit }\n format.json { render json: @segment_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @servicetype = Servicetype.find(params[:id])\n\n respond_to do |format|\n if @servicetype.update_attributes(params[:servicetype])\n format.html { redirect_to @servicetype, :notice => 'Servicetype was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @servicetype.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @novelty_type.update(novelty_type_params)\n format.html { redirect_to @novelty_type, notice: 'Novelty type was successfully updated.' }\n format.json { render :show, status: :ok, location: @novelty_type }\n else\n format.html { render :edit }\n format.json { render json: @novelty_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @claim_type.update(claim_type_params)\n format.html { redirect_to @claim_type, notice: 'Claim type was successfully updated.' }\n format.json { render :show, status: :ok, location: @claim_type }\n else\n format.html { render :edit }\n format.json { render json: @claim_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @email_type.update(email_type_params)\n format.html { redirect_to @email_type, notice: 'Email type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @email_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @servicetype = Servicetype.find(params[:id])\n\n respond_to do |format|\n if @servicetype.update_attributes(params[:servicetype])\n format.html { redirect_to @servicetype, notice: 'Servicetype was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @servicetype.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @shipment_type.update(shipment_type_params)\n format.html { redirect_to @shipment_type, notice: 'Shipment type was successfully updated.' }\n format.json { render :show, status: :ok, location: @shipment_type }\n else\n format.html { render :edit }\n format.json { render json: @shipment_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n prms = @boat_type.is_modification? ? modification_params : boat_type_params\n respond_to do |format|\n if @boat_type.update(prms)\n format.html { redirect_to edit_boat_type_path(@boat_type), notice: 'Тип лодки успешно обновлён' }\n format.json { render json: @boat_type.hash_view('control'), status: :ok}\n else\n format.html { render :edit }\n format.json { render json: @boat_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @addresstype = Addresstype.find(params[:id])\n\n respond_to do |format|\n if @addresstype.update_attributes(params[:addresstype])\n format.html { redirect_to @addresstype, notice: 'Addresstype was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @addresstype.errors, status: :unprocessable_entity }\n end\n end\n end", "def sell_payment_types_update (payment_type_id, email, params={})\r\n url = api_url \"/sell/payment_types​/#{payment_type_id}\"\r\n load = MultiJson.dump email: email\r\n req = request_params(params)\r\n\r\n feed_or_retry do\r\n RestClient.put url, load, req \r\n end \r\n end", "def update\n respond_to do |format|\n if @contact_type.update(contact_type_params)\n format.html { redirect_to @contact_type, notice: 'Contact type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @contact_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @stakeholder_type = StakeholderType.find(params[:id])\n\n respond_to do |format|\n if @stakeholder_type.update_attributes(params[:stakeholder_type])\n format.html { redirect_to @stakeholder_type, notice: 'Stakeholder type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @stakeholder_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @phones_type.update(phones_type_params)\n format.html { redirect_to @phones_type, notice: 'Phones type was successfully updated.' }\n format.json { render :show, status: :ok, location: @phones_type }\n else\n format.html { render :edit }\n format.json { render json: @phones_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @model_type.update(model_type_params)\n format.html { redirect_to @model_type, notice: 'Model type was successfully updated.' }\n format.json { render :show, status: :ok, location: @model_type }\n else\n format.html { render :edit }\n format.json { render json: @model_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @service_type_master.update(service_type_master_params)\n format.html { redirect_to @service_type_master, notice: 'Service type master was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @service_type_master.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @outgoing_type = OutgoingType.find(params[:id])\n\n respond_to do |format|\n if @outgoing_type.update_attributes(params[:outgoing_type])\n format.html { redirect_to(outgoing_types_path, :notice => 'Outgoing type was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @outgoing_type.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @opportunity_type = OpportunityType.find(params[:id])\n\n respond_to do |format|\n if @opportunity_type.update_attributes(params[:opportunity_type])\n format.html { redirect_to @opportunity_type, notice: 'Opportunity type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @opportunity_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @followuptype.update(followuptype_params)\n format.html { redirect_to @followuptype, notice: 'Followuptype was successfully updated.' }\n format.json { render :show, status: :ok, location: @followuptype }\n else\n format.html { render :edit }\n format.json { render json: @followuptype.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @attendence_type.update(attendence_type_params)\n format.html { redirect_to @attendence_type, notice: 'Attendence type was successfully updated.' }\n format.json { render :show, status: :ok, location: @attendence_type }\n else\n format.html { render :edit }\n format.json { render json: @attendence_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_question_type\n form_params = params.require(:form).permit(:question_id, :question_type)\n\n render json: Question.update_question_type(form_params)\n end", "def update \t\n record = AssetType.find(params[:id])\n record.update_attributes(params[:record])\n \n respond_to do |format|\n format.html\n format.json {\n render json: {}\n }\n end\n end", "def update\n @types_of_apprenticeship = TypesOfApprenticeship.find(params[:id])\n\n respond_to do |format|\n if @types_of_apprenticeship.update_attributes(params[:types_of_apprenticeship])\n format.html { redirect_to @types_of_apprenticeship, notice: 'Types of apprenticeship was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @types_of_apprenticeship.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @task_type.update(task_type_params)\n format.html { redirect_to task_types_path, notice: 'Task type was successfully updated.' }\n format.json { render :show, status: :ok, location: @task_type }\n else\n format.html { render :edit }\n format.json { render json: @task_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @sale_type.update(sale_type_params)\n format.html { redirect_to @sale_type, notice: \"Sale type was successfully updated.\" }\n format.json { render :show, status: :ok, location: @sale_type }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @sale_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @act_type = ActType.find(params[:id])\n\n respond_to do |format|\n if @act_type.update_attributes(params[:act_type])\n format.html { redirect_to @act_type, notice: 'Данные типа документа успешно обновлены.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @act_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @typebourse.update(typebourse_params)\n format.html { redirect_to @typebourse, notice: 'Typebourse was successfully updated.' }\n format.json { render :show, status: :ok, location: @typebourse }\n else\n format.html { render :edit }\n format.json { render json: @typebourse.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @optype.update(optype_params)\n format.html { redirect_to @optype, notice: 'Optype was successfully updated.' }\n format.json { render :show, status: :ok, location: @optype }\n else\n format.html { render :edit }\n format.json { render json: @optype.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @expense_sub_type.update(expense_sub_type_params)\n format.html { redirect_to @expense_sub_type, notice: 'Expense sub type was successfully updated.' }\n format.json { render :show, status: :ok, location: @expense_sub_type }\n else\n format.html { render :edit }\n format.json { render json: @expense_sub_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @subject_type.update(subject_type_params)\n format.html { redirect_to @subject_type, notice: 'Subject type was successfully updated.' }\n format.json { render :show, status: :ok, location: @subject_type }\n else\n format.html { render :edit }\n format.json { render json: @subject_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @typegroup.update(typegroup_params)\n format.html { redirect_to @typegroup, notice: 'Typegroup was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @typegroup.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @client_type = ClientType.find(params[:id])\n\n respond_to do |format|\n if @client_type.update_attributes(params[:client_type])\n format.html { redirect_to @client_type, notice: 'Client type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @client_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n authorize :resquest_type, :update?\n respond_to do |format|\n if @resquest_type.update(resquest_type_params)\n format.html { redirect_to @resquest_type, notice: 'Resquest type was successfully updated.' }\n format.json { render :show, status: :ok, location: @resquest_type }\n else\n format.html { render :edit }\n format.json { render json: @resquest_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @workflow_type.update(workflow_type_params)\n format.html { redirect_to @workflow_type, notice: 'Workflow type was successfully updated.' }\n format.json { render :show, status: :ok, location: @workflow_type }\n else\n format.html { render :edit }\n format.json { render json: @workflow_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @fender_type.update(fender_type_params)\n format.html { redirect_to fender_types_path, notice: 'Fender type was successfully updated.' }\n format.json { render :show, status: :ok, location: @fender_type }\n else\n format.html { render :edit }\n format.json { render json: @fender_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @data_set_type.update(data_set_type_params)\n format.html { redirect_to @data_set_type, notice: 'Data set type was successfully updated.' }\n format.json { render :show, status: :ok, location: @data_set_type }\n else\n format.html { render :edit }\n format.json { render json: @data_set_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def _update(type, current_name, metadata={})\n type = type.to_s.camelize\n request :update do |soap|\n soap.body = {\n :metadata => {\n :current_name => current_name,\n :metadata => prepare(metadata),\n :attributes! => { :metadata => { 'xsi:type' => \"ins0:#{type}\" } }\n }\n }\n end\n end", "def update\n @count = @procedure_type.requirements.count\n respond_to do |format|\n if @procedure_type.update(procedure_type_params)\n format.html { redirect_to procedure_types_path, notice: 'Tipo de tramite actualizado exitosamente' }\n format.json { render :show, status: :ok, location: @procedure_type }\n else\n format.html { render :edit }\n format.json { render json: @procedure_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @route_type.update(route_type_params)\n format.html { redirect_to @route_type, notice: 'Route type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @route_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @realty_type = RealtyType.find(params[:id])\n\n respond_to do |format|\n if @realty_type.update_attributes(params[:realty_type])\n format.html { redirect_to @realty_type, notice: 'Realty type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @realty_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @specification_type = SpecificationType.find(params[:id])\n\n if @specification_type.update(specification_type_params)\n audit(@specification_type, current_user)\n render json: @specification_type, status: :created, serializer: Web::V1::SpecificationTypeSerializer\n else\n render json: @specification_type.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @expense.update_attributes(params[get_type])\n update_paps\n format.html { redirect_to @expense, notice: 'Udalosť bola úspešne zmenená.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @expense.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @service_type = args[:service_type] if args.key?(:service_type)\n end", "def update\n @close_type = CloseType.find(params[:id])\n\n respond_to do |format|\n if @close_type.update_attributes(params[:close_type])\n format.html { redirect_to @close_type, notice: 'Close type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @close_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @entity_type.update(entity_type_params)\n format.html { redirect_to @entity_type, notice: 'Entity type was successfully updated.' }\n format.json { render :show, status: :ok, location: @entity_type }\n else\n format.html { render :edit }\n format.json { render json: @entity_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @event_type = EventType.find(params[:id])\n\n respond_to do |format|\n if @event_type.update_attributes(params[:event_type])\n\t\t\t\tmsg = I18n.t('app.msgs.success_updated', :obj => I18n.t('app.common.event_type'))\n\t\t\t\tsend_status_update(I18n.t('app.msgs.cache_cleared', :action => msg))\n format.html { redirect_to admin_event_type_path(@event_type), notice: msg }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @scheduler_type.update(scheduler_type_params)\n format.html { redirect_to @scheduler_type, notice: 'Scheduler type was successfully updated.' }\n format.json { render :show, status: :ok, location: @scheduler_type }\n else\n format.html { render :edit }\n format.json { render json: @scheduler_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @os_type = OsType.find(params[:id])\n\n respond_to do |format|\n if @os_type.update_attributes(params[:os_type])\n format.html { redirect_to @os_type, notice: 'Os type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @os_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @cloth_type.update(cloth_type_params)\n format.html { redirect_to @cloth_type, notice: \"Cloth type was successfully updated.\" }\n format.json { render :show, status: :ok, location: @cloth_type }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @cloth_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n raw = params[:sample_type]\n st = SampleType.find(raw[:id])\n\n st.name = raw[:name]\n st.description = raw[:description]\n st.save\n st.save_field_types raw[:field_types]\n\n render json: { sample_type: st }\n\n end", "def update\r\n @meeting_type = MeetingType.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @meeting_type.update_attributes(params[:meeting_type])\r\n format.html { redirect_to @meeting_type, only_path: true, notice: 'Meeting type was successfully updated.' }\r\n format.json { head :no_content }\r\n else\r\n format.html { render action: \"edit\" }\r\n format.json { render json: @meeting_type.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def update\n respond_to do |format|\n if @type_bond.update(type_bond_params)\n format.html { redirect_to @type_bond, notice: 'Type bond was successfully updated.' }\n format.json { render :show, status: :ok, location: @type_bond }\n else\n format.html { render :edit }\n format.json { render json: @type_bond.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @heart_rate_type = HeartRateType.find(params[:id])\n\n respond_to do |format|\n if @heart_rate_type.update_attributes(params[:heart_rate_type])\n format.html { redirect_to @heart_rate_type, notice: 'Heart rate type was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @heart_rate_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @competence_type.update(competence_type_params)\n format.json { render :show, status: :ok, object: @competence_type }\n else\n format.json { render json: @competence_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @company_type = CompanyType.find(params[:id])\n\n if @company_type.update(company_type_params)\n head :no_content\n else\n render json: @company_type.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @box_request_abuse_type.update(box_request_abuse_type_params)\n format.html { redirect_to @box_request_abuse_type, notice: 'Box request abuse type was successfully updated.' }\n format.json { render :show, status: :ok, location: @box_request_abuse_type }\n else\n format.html { render :edit }\n format.json { render json: @box_request_abuse_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @modeltype.update(modeltype_params)\n format.html { redirect_to @modeltype, notice: 'Modeltype was successfully updated.' }\n format.json { render :show, status: :ok, location: @modeltype }\n else\n format.html { render :edit }\n format.json { render json: @modeltype.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @dash_type = DashType.find(params[:id])\n\n respond_to do |format|\n if @dash_type.update_attributes(params[:dash_type])\n format.html { redirect_to @dash_type, notice: 'Dash type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @dash_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def change_type\n\t\t\trender json: User.update_type_by_id(params[:id], params[:type], params[:is])\n\t\tend", "def update\n @sponsor_type = SponsorType.find(params[:id])\n\n respond_to do |format|\n if @sponsor_type.update_attributes(params[:sponsor_type])\n format.html { redirect_to([@event, @sponsor_type], :notice => 'Sponsor type was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @sponsor_type.errors, :status => :unprocessable_entity }\n end\n end\n end", "def put(type, info)\n path, info = type_info(type, :path), force_case(info)\n ida = type == :client ? 'client_id' : 'id'\n raise ArgumentError, \"info must include #{ida}\" unless id = info[ida]\n hdrs = headers\n if info && info['meta'] && (etag = info['meta']['version'])\n hdrs.merge!('if-match' => etag)\n end\n reply = json_parse_reply(@key_style,\n *json_put(@target, \"#{path}/#{Addressable::URI.encode(id)}\", info, hdrs))\n\n # hide client endpoints that are not quite scim compatible\n type == :client && !reply ? get(type, info['client_id']): reply\n end", "def update\n respond_to do |format|\n if @brew_type.update(brew_type_params)\n format.html { redirect_to @brew_type, notice: 'Brew type was successfully updated.' }\n format.json { render :show, status: :ok, location: @brew_type }\n else\n format.html { render :edit }\n format.json { render json: @brew_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @instance_type.update(instance_type_params)\n format.html { redirect_to @instance_type, notice: 'Instance type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @instance_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @flat_type.update(flat_type_params)\n format.html { redirect_to @flat_type, notice: 'Flat type was successfully updated.' }\n format.json { render :show, status: :ok, location: @flat_type }\n else\n format.html { render :edit }\n format.json { render json: @flat_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @eventtype.update(eventtype_params)\n format.html { redirect_to @eventtype, notice: 'Eventtype was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @eventtype.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @adjustment_type.update(adjustment_type_params)\n format.html { redirect_to @adjustment_type, notice: 'Adjustment type was successfully updated.' }\n format.json { render :show, status: :ok, location: @adjustment_type }\n else\n format.html { render :edit }\n format.json { render json: @adjustment_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @affected_type.update(affected_type_params)\n format.html { redirect_to @affected_type, notice: 'Affected type was successfully updated.' }\n format.json { render :show, status: :ok, location: @affected_type }\n else\n format.html { render :edit }\n format.json { render json: @affected_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @jewelry_type = JewelryType.find(params[:id])\n\n respond_to do |format|\n if @jewelry_type.update_attributes(params[:jewelry_type])\n format.html { redirect_to @jewelry_type, notice: 'Jewelry type was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @jewelry_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @collection = @entity_type.collection\n respond_to do |format|\n if @entity_type.update(entity_type_params)\n format.html { redirect_to collection_entity_types_path(@collection), notice: 'The entity type was successfully updated.' }\n format.json { render :show, status: :ok, location: @entity_type }\n else\n format.html { render :edit }\n format.json { render json: @entity_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n @phone_types = PhoneType.all\n @phone_type = PhoneType.find(params[:id])\n\n @phone_type.update_attributes(phone_type_params)\n\n=begin\n respond_to do |format|\n if @phone_type.update(phone_type_params)\n format.html { redirect_to @phone_type, notice: 'Phone type was successfully updated.' }\n format.json { render :show, status: :ok, location: @phone_type }\n else\n format.html { render :edit }\n format.json { render json: @phone_type.errors, status: :unprocessable_entity }\n end\n end\n=end\n end", "def update\n respond_to do |format|\n if get_instance.update(type_params)\n # Redirect to index\n format.json { render sti_template(@type, :show), status: :ok, location: get_instance } # TODO: test\n else\n format.json { render json: get_instance.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @survey_data_type.update(survey_data_type_params)\n format.html { redirect_to @survey_data_type, notice: 'Survey data type was successfully updated.' }\n format.json { render :show, status: :ok, location: @survey_data_type }\n else\n format.html { render :edit }\n format.json { render json: @survey_data_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @crate_type = CrateType.find(params[:id])\n\n respond_to do |format|\n if @crate_type.update_attributes(params[:crate_type])\n format.html { redirect_to @crate_type, :notice => 'Crate type was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @crate_type.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @recipe_type.update(recipe_type_params)\n format.html { redirect_to @recipe_type, notice: \"Recipe type was successfully updated.\" }\n format.json { render :show, status: :ok, location: @recipe_type }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @recipe_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @intervention_type.update(intervention_type_params)\n format.html { redirect_to intervention_types_path, notice: 'O tipo de intervenção foi actualizado.' }\n format.json { render :show, status: :ok, location: @intervention_type }\n else\n format.html { render :edit }\n format.json { render json: @intervention_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @type_activity.update(type_activity_params)\n format.html { redirect_to @type_activity, notice: 'Type activity was successfully updated.' }\n format.json { render :show, status: :ok, location: @type_activity }\n else\n format.html { render :edit }\n format.json { render json: @type_activity.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @ride_type.update(ride_type_params)\n format.html { redirect_to @ride_type, notice: 'Ride type was successfully updated.' }\n format.json { render :show, status: :ok, location: @ride_type }\n else\n format.html { render :edit }\n format.json { render json: @ride_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @consumer_type.update(consumer_type_params)\n format.html { redirect_to @consumer_type, notice: 'Consumer type was successfully updated.' }\n format.json { render :show, status: :ok, location: @consumer_type }\n else\n format.html { render :edit }\n format.json { render json: @consumer_type.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.615752", "0.6034026", "0.59777164", "0.5964778", "0.59570384", "0.59546965", "0.59451306", "0.59365535", "0.593154", "0.5917625", "0.59059685", "0.59027517", "0.58969545", "0.5894304", "0.5889677", "0.58754635", "0.5874857", "0.58543897", "0.5847064", "0.5846698", "0.584038", "0.5835769", "0.5827818", "0.5824328", "0.58181256", "0.58110374", "0.5802161", "0.5801176", "0.579935", "0.57983094", "0.5798295", "0.57919776", "0.57774425", "0.57553154", "0.5752132", "0.5751825", "0.5747551", "0.57424396", "0.5734445", "0.57223755", "0.57171357", "0.5709127", "0.5705917", "0.5704064", "0.570229", "0.56929684", "0.5691208", "0.56909704", "0.56900764", "0.5683716", "0.5681119", "0.5679235", "0.56781757", "0.56702983", "0.56693023", "0.5668826", "0.56683254", "0.56606805", "0.5657955", "0.56567633", "0.5652732", "0.5644053", "0.56381446", "0.56354207", "0.5633233", "0.5629763", "0.5627205", "0.5626949", "0.5623572", "0.56235313", "0.56222135", "0.5621567", "0.56206995", "0.5615852", "0.56105244", "0.5602945", "0.5599972", "0.5598998", "0.5597842", "0.55974996", "0.5595007", "0.5594561", "0.5593928", "0.55933636", "0.5590384", "0.5586879", "0.558488", "0.5583602", "0.5580397", "0.55798984", "0.55760294", "0.5574809", "0.55744", "0.5569568", "0.55683184", "0.5564341", "0.55621904", "0.55589545", "0.55579185", "0.55563545" ]
0.59709686
3
DELETE /type_spends/1 DELETE /type_spends/1.json
def destroy @type_spend.destroy respond_to do |format| format.html { redirect_to type_spends_url, notice: 'Type spend was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @addresstype = Addresstype.find(params[:id])\n @addresstype.destroy\n\n respond_to do |format|\n format.html { redirect_to addresstypes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @segment_type = SegmentType.find(params[:id])\n @segment_type.destroy\n\n respond_to do |format|\n format.html { redirect_to segment_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @dash_type = DashType.find(params[:id])\n @dash_type.destroy\n\n respond_to do |format|\n format.html { redirect_to dash_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @bs_type.destroy\n respond_to do |format|\n format.html { redirect_to bs_types_url, notice: 'Bs type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @addtype.destroy\n respond_to do |format|\n format.html { redirect_to addtypes_url, notice: '变动方式删除成功!.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @type = Type.find(params[:type])\n @type.destroy\n\n respond_to do |format|\n format.html { redirect_to company_types_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 @type = Type.find(params[:id])\n @type.destroy\n\n respond_to do |format|\n format.html { redirect_to types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @dishtype.destroy\n respond_to do |format|\n format.html { redirect_to dishtypes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @heart_rate_type = HeartRateType.find(params[:id])\n @heart_rate_type.destroy\n\n respond_to do |format|\n format.html { redirect_to heart_rate_types_url }\n format.json { head :ok }\n end\n end", "def destroy\n @servicetype = Servicetype.find(params[:id])\n @servicetype.destroy\n\n respond_to do |format|\n format.html { redirect_to servicetypes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @servicetype = Servicetype.find(params[:id])\n @servicetype.destroy\n\n respond_to do |format|\n format.html { redirect_to servicetypes_url }\n format.json { head :no_content }\n end\n end", "def delete\n if params[:social_event_type_id]\n socialEventType = SocialEventType.where(id: params[:social_event_type_id]).first\n if socialEventType.delete \n render json: { message: \"deleted successfully.\" } , status: 200\n else \n render json: socialEventType.errors , status: 422\n end\n else\n render json: { message: \"send social event type id.\" } , status: 422 \n end \n end", "def _delete(type, *args)\n type = type.to_s.camelize\n metadata = args.map { |full_name| {:full_name => full_name} }\n request :delete do |soap|\n soap.body = {\n :metadata => metadata\n }.merge(attributes!(type))\n end\n end", "def destroy\n @spending.destroy\n respond_to do |format|\n format.html { redirect_to spendings_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @count_type.destroy\n respond_to do |format|\n format.html { redirect_to count_types_url, notice: 'Count type was successfully destroyed.' }\n #format.json { head :no_content }\n end\n end", "def destroy\n @downtime_type.destroy\n respond_to do |format|\n format.html { redirect_to downtime_types_url, notice: '成功删除.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @service_type = ServiceType.find(params[:id])\n @service_type.destroy\n\n respond_to do |format|\n format.html { redirect_to service_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @segment_type.destroy\n respond_to do |format|\n format.html { redirect_to segment_types_url, notice: 'Segment type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @novelty_type.destroy\n respond_to do |format|\n format.html { redirect_to novelty_types_url, notice: 'Novelty type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @dish_type.destroy\n respond_to do |format|\n format.html { redirect_to dish_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @email_type.destroy\n respond_to do |format|\n format.html { redirect_to email_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @special_needs_type = SpecialNeedsType.find(params[:id])\n @special_needs_type.destroy\n\n respond_to do |format|\n format.html { redirect_to special_needs_types_url, :notice => 'Tipo de necessidade especial excluída com sucesso.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @travel_type = TravelType.find(params[:id])\n @travel_type.destroy\n\n respond_to do |format|\n format.html { redirect_to travel_types_url }\n format.json { head :ok }\n end\n end", "def destroy\n @spit_type = SpitType.find(params[:id])\n @spit_type.destroy\n\n respond_to do |format|\n format.html { redirect_to(spit_types_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @expense_sub_type.destroy\n respond_to do |format|\n format.html { redirect_to expense_sub_types_url, notice: 'Expense sub type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @talk_type = TalkType.find(params[:id])\n @talk_type.destroy\n\n respond_to do |format|\n format.html { redirect_to talk_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @talktype = Talktype.find(params[:id])\n @talktype.destroy\n\n respond_to do |format|\n format.html { redirect_to talktypes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @client_type = ClientType.find(params[:id])\n @client_type.destroy\n\n respond_to do |format|\n format.html { redirect_to client_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @testtype.destroy\n respond_to do |format|\n format.html { redirect_to testtypes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @flat_type.destroy\n respond_to do |format|\n format.html { redirect_to flat_types_url, notice: 'Flat type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def remove\n ids = params[\"#{model.name.underscore}_ids\"]\n if ids.is_a?(Array) && ids.length > 0\n model.where(id: params[\"#{model.name.underscore}_ids\"]).destroy_all\n flash[:info] = \"Successfully deleted #{ids.length} #{type_label}\"\n end\n redirect_to sti_path(@type)\n end", "def destroy\n @typegroup.destroy\n respond_to do |format|\n format.html { redirect_to typegroups_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @attendence_type.destroy\n respond_to do |format|\n format.html { redirect_to attendence_types_url, notice: 'Attendence type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @stakeholder_type = StakeholderType.find(params[:id])\n @stakeholder_type.destroy\n\n respond_to do |format|\n format.html { redirect_to stakeholder_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @agency_type = AgencyType.find(params[:id])\n @agency_type.destroy\n\n respond_to do |format|\n format.html { redirect_to agency_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @series_type = SeriesType.find(params[:id])\n @series_type.destroy\n\n respond_to do |format|\n format.html { redirect_to series_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @spore_type_count.destroy\n respond_to do |format|\n format.html { redirect_to spore_type_counts_url, notice: 'Spore type count 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 @edge_type = EdgeType.find(params[:id])\n @edge_type.destroy\n\n respond_to do |format|\n format.html { redirect_to edge_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @use_type.destroy\n respond_to do |format|\n format.html { redirect_to use_types_url, notice: 'Use type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @tasktype = Tasktype.find(params[:id])\n @tasktype.destroy\n\n respond_to do |format|\n format.html { redirect_to tasktypes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @data_set_type.destroy\n respond_to do |format|\n format.html { redirect_to data_set_types_url, notice: 'Data set type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @act_type = ActType.find(params[:id])\n @act_type.destroy\n\n respond_to do |format|\n format.html { redirect_to act_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @shape_type = ShapeType.find(params[:id])\n @shape_type.destroy\n\n\t\tmsg = I18n.t('app.msgs.success_deleted', :obj => I18n.t('app.common.shape_type'))\n\t\tsend_status_update(I18n.t('app.msgs.cache_cleared', :action => msg))\n respond_to do |format|\n format.html { redirect_to admin_shape_types_url }\n format.json { head :ok }\n end\n end", "def destroy\n @activity_type = ActivityType.find(params[:id])\n @activity_type.destroy\n\n respond_to do |format|\n format.html { redirect_to activity_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @heat_type = HeatType.find(params[:id])\n @heat_type.destroy\n\n respond_to do |format|\n format.html { redirect_to heat_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @type_bond.destroy\n respond_to do |format|\n format.html { redirect_to type_bonds_url, notice: 'Type bond was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @girltype = Girltype.find(params[:id])\n @girltype.destroy\n\n respond_to do |format|\n format.html { redirect_to girltypes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @share_type.destroy\n respond_to do |format|\n format.html { redirect_to share_types_url, notice: t('share_type.destroyed') }\n format.json { head :no_content }\n end\n end", "def destroy\n @agenda_type = AgendaType.find(params[:id])\n @agenda_type.destroy\n\n respond_to do |format|\n format.html { redirect_to agenda_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @discipline_type = DisciplineType.find(params[:id])\n @discipline_type.destroy\n\n respond_to do |format|\n format.html { redirect_to discipline_types_url, :notice => 'Tipo de disciplina excluído com sucesso.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @partner_type = PartnerType.find(params[:id])\n @partner_type.destroy\n\n respond_to do |format|\n format.html { redirect_to partner_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @ride_type.destroy\n respond_to do |format|\n format.html { redirect_to ride_types_url, notice: 'Ride type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @sale_type.destroy\n respond_to do |format|\n format.html { redirect_to sale_types_url, notice: \"Sale type was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @item_type.destroy\n respond_to do |format|\n format.html { redirect_to item_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @claim_type.destroy\n respond_to do |format|\n format.html { redirect_to claim_types_url, notice: 'Claim type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @types_of_apprenticeship = TypesOfApprenticeship.find(params[:id])\n @types_of_apprenticeship.destroy\n\n respond_to do |format|\n format.html { redirect_to types_of_apprenticeships_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @expense_type.destroy\n respond_to do |format|\n format.html { redirect_to expense_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @subject_type.destroy\n respond_to do |format|\n format.html { redirect_to subject_types_url, notice: 'Subject type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @bus_seat_type = BusSeatType.find(params[:id])\n @bus_seat_type.destroy\n\n respond_to do |format|\n format.html { redirect_to bus_seat_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @brew_type.destroy\n respond_to do |format|\n format.html { redirect_to brew_types_url, notice: 'Brew type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_from_entzumena\n headline = Headline.where({:source_item_type => params[:source_item_type], :source_item_id => params[:source_item_id]}).first\n if headline.destroy\n render :json => true, :status => 200\n else\n render :json => false, :status => :error\n end\n end", "def destroy\n @affected_type.destroy\n respond_to do |format|\n format.html { redirect_to affected_types_url, notice: 'Affected type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @client_type.destroy\n respond_to do |format|\n format.html { redirect_to client_types_url, notice: 'Tipo de Cliente deletado.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @techaxis_type = TechaxisType.find(params[:id])\n @techaxis_type.destroy\n\n respond_to do |format|\n format.html { redirect_to techaxis_types_url, :notice => t('controllermessage.delete') }\n format.json { head :no_content }\n end\n end", "def destroy\n @call_type.destroy\n respond_to do |format|\n format.html { redirect_to call_types_url, notice: 'Call type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @drum_type.destroy\n respond_to do |format|\n format.html { redirect_to drum_types_url, notice: 'Drum type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete\n sellID = params[:sell_id]\n\n uri = URI(\"http://107.170.7.58:4567/api/delete/sell\")\n parameters = {\"ext\" => \"json\", \"id\" => sellID}\n response = Net::HTTP.post_form(uri, parameters)\n list = JSON.parse(response.body)\n\n @response = list[0][\"kind\"]\n end", "def destroy\n @shipment_type.destroy\n respond_to do |format|\n format.html { redirect_to shipment_types_url, notice: 'Shipment type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @incident_type = IncidentType.find(params[:id])\n @incident_type.destroy\n\n respond_to do |format|\n format.html { redirect_to incident_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @fish_type = FishType.find(params[:id])\n @fish_type.destroy\n\n respond_to do |format|\n format.html { redirect_to fish_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @task_type.destroy\n respond_to do |format|\n format.html { redirect_to admin_task_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @businesstype.destroy\n respond_to do |format|\n format.html { redirect_to businesstypes_url, notice: 'Businesstype was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @business_type = BusinessType.find(params[:id])\n @business_type.destroy\n\n respond_to do |format|\n format.html { redirect_to business_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @site_type = SiteType.find(params[:id])\n @site_type.destroy\n\n respond_to do |format|\n format.html { redirect_to site_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @typebourse.destroy\n respond_to do |format|\n format.html { redirect_to typebourses_url, notice: 'Typebourse was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @close_type = CloseType.find(params[:id])\n @close_type.destroy\n\n respond_to do |format|\n format.html { redirect_to close_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @type_debit.destroy\n respond_to do |format|\n format.html { redirect_to type_debits_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @premise_type = PremiseType.find(params[:id])\n @premise_type.destroy\n\n respond_to do |format|\n format.html { redirect_to premise_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @sitetype = Sitetype.find(params[:id])\n @sitetype.destroy\n\n respond_to do |format|\n format.html { redirect_to(sitetypes_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @hr_config_discipline_type.destroy\n respond_to do |format|\n format.html { redirect_to hr_config_discipline_types_url, notice: 'Discipline type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @subject_type.destroy\n\n respond_to do |format|\n format.html { redirect_to subject_types_url, notice: t('controller.successfully_deleted', model: t('activerecord.models.subject_type')) }\n format.json { head :no_content }\n end\n end", "def destroy\n @bet_type.destroy\n respond_to do |format|\n format.html { redirect_to bet_types_url, notice: 'Type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @realty_type = RealtyType.find(params[:id])\n @realty_type.destroy\n\n respond_to do |format|\n format.html { redirect_to realty_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @costtype = Costtype.find(params[:id])\n @costtype.destroy\n\n respond_to do |format|\n format.html { redirect_to costtypes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @seance_type = SeanceType.find(params[:id])\n @seance_type.destroy\n\n respond_to do |format|\n format.html { redirect_to(seance_types_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @income_type.destroy\n respond_to do |format|\n format.html { redirect_to income_types_url, notice: 'Income type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @checklist_type.destroy\n respond_to do |format|\n format.html { redirect_to checklist_types_url, notice: 'Checked item type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def remove(index, type, id)\n resp = delete do |req|\n req.url \"#{index}/#{type}/#{id}\"\n end\n resp.body\n end", "def destroy\n @sub1_line_item.destroy\n respond_to do |format|\n format.html { redirect_to sub1_line_items_url, notice: 'Sub1 line item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @awon_record_type.destroy\n respond_to do |format|\n format.html { redirect_to awon_record_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @ss_type = SsType.find(params[:id])\n @ss_type.destroy\n\n respond_to do |format|\n format.html { redirect_to(ss_types_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @task_type.destroy\n respond_to do |format|\n format.html { redirect_to task_types_url, notice: 'Task type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @flow_type.destroy\n respond_to do |format|\n format.html { redirect_to flow_types_url, notice: 'Flow type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @entry_type = EntryType.find(params[:id])\n @entry_type.destroy\n\n respond_to do |format|\n format.html { redirect_to entry_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @cdist_type = CdistType.find(params[:id])\n @cdist_type.destroy\n\n respond_to do |format|\n format.html { redirect_to cdist_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @sample_type = SampleType.find(params[:id])\n @sample_type.destroy\n\n respond_to do |format|\n format.html { redirect_to sample_types_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @method_type.destroy\n respond_to do |format|\n format.html { redirect_to method_types_url, notice: \"Method type was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @typeconge.destroy\n respond_to do |format|\n format.html { redirect_to typeconges_url, notice: 'Typeconge was successfully destroyed.' }\n format.json { head :no_content }\n end\n end" ]
[ "0.6533858", "0.6475706", "0.64441544", "0.64405197", "0.6419661", "0.64052206", "0.6403103", "0.638258", "0.6358583", "0.63218886", "0.6317211", "0.6317211", "0.63141406", "0.6300886", "0.63004285", "0.6297554", "0.6288666", "0.6276399", "0.62738574", "0.62507355", "0.62478745", "0.62475616", "0.62368137", "0.62328327", "0.62325126", "0.6231549", "0.62305254", "0.62294585", "0.62290394", "0.6227361", "0.6214882", "0.6212767", "0.6211554", "0.62096834", "0.620412", "0.6201405", "0.6189278", "0.61864847", "0.6184597", "0.6182167", "0.6181935", "0.6180399", "0.6156304", "0.61554545", "0.61543274", "0.6147773", "0.61466366", "0.6145392", "0.6145026", "0.6142093", "0.6137757", "0.6135624", "0.6133277", "0.6127645", "0.61252075", "0.61242914", "0.61224717", "0.6121058", "0.6119788", "0.61191887", "0.6117199", "0.6116946", "0.61149675", "0.6114272", "0.6113814", "0.6107383", "0.6105122", "0.6104658", "0.6104459", "0.61029035", "0.60972464", "0.6095393", "0.609527", "0.60933083", "0.6089152", "0.6089143", "0.6089043", "0.60832506", "0.60806274", "0.6077611", "0.606722", "0.60659057", "0.6065528", "0.6057429", "0.60565174", "0.6055152", "0.60526687", "0.60473716", "0.6046347", "0.60446435", "0.604318", "0.6039004", "0.60385764", "0.6038133", "0.602927", "0.60292625", "0.60289454", "0.60275", "0.6027168", "0.60269326" ]
0.6822667
0
Use callbacks to share common setup or constraints between actions.
def set_type_spend @type_spend = TypeSpend.find(params[:id]) rescue not_found 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 setup_handler\n end", "def before_actions(*logic)\n self.before_actions = logic\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 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 default_action; end", "def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n 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.6163927", "0.6046165", "0.59465253", "0.59167755", "0.58904207", "0.58346355", "0.577713", "0.5703502", "0.5703502", "0.56531286", "0.56215113", "0.54224145", "0.5410795", "0.5410795", "0.5410795", "0.53924775", "0.5379919", "0.53580743", "0.53401667", "0.53397506", "0.5332605", "0.5312215", "0.5296594", "0.52965283", "0.52957606", "0.5259903", "0.52443177", "0.523896", "0.523896", "0.523896", "0.523896", "0.523896", "0.52329034", "0.52322394", "0.5227445", "0.5222394", "0.5220348", "0.5212759", "0.5207747", "0.5205933", "0.5176468", "0.5173833", "0.5171983", "0.51663405", "0.5159596", "0.5158247", "0.51526845", "0.5152398", "0.5151361", "0.5145775", "0.5140135", "0.51338995", "0.51127726", "0.5112607", "0.5112607", "0.5110613", "0.51067513", "0.5092337", "0.508788", "0.5081578", "0.5080434", "0.50679874", "0.50567716", "0.5051213", "0.5048352", "0.5048352", "0.5035347", "0.5026666", "0.5023127", "0.5016081", "0.50129867", "0.5000684", "0.4999752", "0.49979812", "0.499026", "0.499026", "0.49866846", "0.49800366", "0.49795717", "0.49771172", "0.4968475", "0.4965813", "0.4958072", "0.49561292", "0.4954901", "0.49536785", "0.4953058", "0.49468648", "0.49424478", "0.4932989", "0.49291888", "0.49273813", "0.49271655", "0.4925948", "0.49236968", "0.49203572", "0.49181753", "0.49173692", "0.4916862", "0.49161318", "0.49155986" ]
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def type_spend_params params.require(:type_spend).permit(:name, :description, :code, :user_id) 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
Try the channel first, then roles, then the server
def names_from_context search = [team_name_from_channel_name] + team_names_from_roles (search + [bot.config.dig(server.id, 'default_team')]).compact end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def serversForCapRoles(roles)\n find_servers(:roles => roles).collect { |x| x.host }\nend", "def find_channel(id: nil, name: nil, server_id: nil, server_name: nil)\n server = find_server(id: server_id, name: server_name)\n if server\n find_channel_in_server(id: id, name: name, server: server)\n else\n $bot.servers.each{ |_, s|\n channel = find_channel_in_server(id: id, name: name, server: s)\n return channel if !channel.nil?\n }\n nil\n end\nrescue\n nil\nend", "def loop( &block )\n block ||= proc do \n channels = @channel_map.reject {|k,v| v.type == '[email protected]' }\n not channels.empty?\n end\n process while block.call\n end", "def evaluate_client(umsg,sock)\n case umsg[0]\n when \"channel_list\"\n sock.write(\"Channels: #{@channels.join(\",\")}\\n\") \n when \"add_channel:\"\n channel = umsg[1]\n if @channels.include? channel\n @user[:channels] = @user[:channels] | [channel]\n @@connection.subscribe(channel,@user[:nickname])\n sock.write(\"Channel #{channel} added\\n\")\n else\n sock.write(\"Channel #{channel} doesnt exist\\n\")\n end\n when \"my_channels\"\n sock.write(\"#{list_to_print(\"MY CHANNELS\",@user[:channels])}\\n\")\n when \"rm_channel:\"\n channel = umsg[1]\n if @user[:channels].include? channel\n @user[:channels].delete(channel)\n @@connection.unsubscribe(channel,@user[:nickname])\n sock.write(\"Channel #{channel} removed\\n\")\n else\n sock.write(\"Channel #{channel} is not present in your list\\n\")\n end\n when \"set_mode:\"\n if @@mode.include? umsg[1]\n @user[:mode] = umsg[1]\n sock.write(\"Now your mode is: #{umsg[1]}\\n\")\n else\n sock.write(\"Invalid mode: #{umsg[1]}\\n\")\n end\n when \"get_ads:\"\n channel = umsg[1]\n if @user[:mode] == \"pull\" and @user[:channels].include? channel\n send_pull_msg(sock,channel)\n else\n sock.write(\"You have to change your mode to pull\\n\")\n end\n when \"help\"\n\tsock.write(\"#{list_to_print(\"VALID COMMANDS\",[\"my_channels -> to see your channels(subscriptions)\", \"add_channel: <channel_name>\",\"rm_channel: <channel_name>\", \"channel_list\",\"set_mode: pull | push\", \"get_ads: <channel_name >\"])}\\n\")\n end\n end", "def roles(host)\n if $PROPERTIES.has_key?(host)\n #get the role assigned for the host\n roles=$PROPERTIES[host][:roles]\n #add the default roles to the host role array\n roles=roles + $PROPERTIES[\"default\"][:roles]\n else \n #assign default role for unassigned hosts\n roles=$PROPERTIES[\"default\"][:roles]\n end\n roles\nend", "def roles(host)\n roles = [ \"network\" ]\n case host\n when /^node/\n roles << \"compute\"\n when /^login/\n roles << \"login\"\n when /^master/\n roles << \"master\"\n when /^nfs/\n roles << \"nfsserver\"\n end\n roles\nend", "def ping(rname)\n server = TEST ? $bot.servers.values.first : $bot.servers[SERVER_ID]\n if server.nil?\n log(\"Server not found\")\n return \"\"\n end\n\n role = server.roles.select{ |r| r.name == rname }.first\n if role != nil\n if role.mentionable\n return role.mention\n else\n log(\"Role #{rname} in server #{server.name} not mentionable\")\n return \"\"\n end\n else\n log(\"Role #{rname} not found in server #{server.name}\")\n return \"\"\n end\nrescue => e\n lex(e, \"Failed to ping role #{rname}\")\n \"\"\nend", "def get_server_roles(server_id)\n roles = JSON.parse(Discordrb::API::Server.roles(@bot.token, server_id))\n result = {}\n roles.each do |role|\n result[role[\"name\"]] = role[\"id\"]\n end\n return result\nend", "def run servers\n\t\tservers.each do |server|\n\n\t\t\t@clientCount += 1\n\n\t\t\tclient = Kesh::Mumble::MumbleClient.new( server[:host], server[:port], server[:nick], @options )\n\t\t\t@connections[ client ] = server\n\n\t\t\tclient.register_handler :ServerSync, method( :on_connected )\n\t\t\tclient.register_handler :UserState, method( :on_user_state )\n\t\t\tclient.register_handler :UserRemove, method( :on_user_remove )\n\t\t\t# client.register_handler :UDPTunnel, method( :on_audio )\n\n\t\t\tclient.register_text_handler '!help', method( :cmd_help )\n\t\t\tclient.register_text_handler '!find', method( :cmd_find )\n\t\t\tclient.register_text_handler '!goto', method( :cmd_goto )\n\t\t\tclient.register_text_handler '!test', method( :cmd_test )\n\t\t\tclient.register_text_handler '!info', method( :cmd_info )\n\t\t\tclient.register_text_handler '!admin', method( :cmd_admin )\n\t\t\tclient.register_text_handler '!mute', method( :cmd_mute )\n\t\t\tclient.register_text_handler '!result', method( :cmd_result )\n\t\t\tclient.register_text_handler '!list', method( :cmd_list )\n\n\t\t\tclient.register_exception_handler method( :on_exception )\n\n\t\t\tload_roles_ini client\n\n\t\t\tcreate_new_match( client )\n\n\t\t\tclient.connect\n\n\t\t\tcreate_comment( client )\n\n\t\tend\n\n\t\t# Main loop\n\t\tuntil @shutdown do\n\n\t\t\tif ( Time.now - @lastCleanUp ) > 60 * 60\n\t\t\t\tremove_old_matches\n\t\t\t\t@lastCleanUp = Time.now\n\t\t\tend\n\n\n\t\t\tif ( Time.now - @lastTrack ) > 60 * 5\n\t\t\t\ttrack_matches\n\t\t\t\t@lastTrack = Time.now\n\t\t\tend\n\n\t\t\treturn true unless all_connected? # TODO: This is a very ugly way to reset all connections\n\n\t\t\tsleep 0.2\n\n\t\tend\n\n\t\treturn @restart\n\n\tend", "def reconnect!(roles)\n @cluster.reset!\n @cluster.connect!(self.servers(roles))\n end", "def eval_first_msg(umsg,sock)\n user_info = umsg.split(\" \")\n if umsg =~ /user_info:/\n @user_info.push({:nickname => user_info[1],:role => \"client\", :channels => [], :mode => \"pull\", :time => Time.now})\n sock.write(\"Welcome #{user_info[1]}\\n\")\n @@connection.insert_user user_info[1]\n @user_info.last[:channels] = @@connection.fill_channels_user(user_info[1])\n elsif (umsg =~ /source_info:/) \n @user_info.push({:nickname => user_info[1],:role => \"editor\",:status => \"logging\"}) \n sock.write(\"password:\\n\")\n elsif (umsg =~ /admin_info:/ )\n @user_info.push({:nickname => user_info[1],:role => \"admin\", :status => \"logging\"}) \n sock.write(\"password:\\n\")\n end \n end", "def evaluate_admin(umsg,sock)\n case umsg[0]\n when \"pwd:\"\n evaluate_pwd(umsg,sock) \n when \"add_channel:\"\n channel = umsg[1]\n unless @channels.include? channel\n @@connection.insert_channel channel\n @channels.push(channel) \n sock.write(\"Channel added\\n\")\n else\n sock.write(\"The channels already exits\\n\")\n end\n when \"rm_channel:\"\n channel = umsg[1]\n if @channels.include? channel\n @@connection.delete_channel channel\n @channels.delete(channel)\n sock.write(\"Channel was removed\\n\")\n else\n sock.write(\"Channel doesn't exist\\n\")\n end\n when \"channel_list\"\n sock.write(\"#{list_to_print(\"CHANNELS\",@channels)}\\n\")\n when \"help\"\n sock.write(\"#{list_to_print(\"VALID COMMANDS\",[\"add_channel: <channel_name>\",\"rm_channel: <channel_name>\"])}\\n\")\n end\n end", "def cwhoami(m)\n if userroles(m.channel,m.user).empty?\n m.reply \"You're #{m.user.nick},\" + (!m.user.authname.nil? ? \" authenticated as #{User(m.user).authname},\" : \" unauthenticated,\") + \" with no roles.\"\n else\n m.reply \"You're #{m.user.nick},\" + (!m.user.authname.nil? ? \" authenticated as #{User(m.user).authname},\" : \" unauthenticated,\") + \" with the following roles #{userroles(m.channel,m.user)}.\", true\n end\n end", "def reset_roles(server_roles, member_roles, guild_info)\n roles = member_roles.dup\n # If guild is set, remove guild role\n unless guild_info.nil?\n role_id = server_roles[guild_info[\"name\"]]\n roles = roles - [role_id] unless role_id.nil?\n end\n\n # Remove server roles\n @worlds.each_value do |world|\n role_id = server_roles[world]\n roles = roles - [role_id] unless role_id.nil?\n end\n unless OFF_WORLD_ROLE.nil?\n role_id = server_roles[OFF_WORLD_ROLE]\n roles = roles - [role_id] unless role_id.nil?\n end\n \n return roles\nend", "def agent(channel); end", "def prepare_client(client, channel, type); end", "def init_irc\n sock = TCPSocket.open($server, $port)\n irc = IRC.new(sock)\n irc.as($nick).join($channel).connect()\n # We wait until the end of the complete initialization(channel joined and people listed).\n irc.wait_for(Rpl::NamesList)\n irc\nend", "def auth_sequence( port, data, auth_server )\n threads = []\n while session = auth_server.accept\n threads << Thread.new do\n # debug_msg \"\\nReady to accept new connections. Listening on port: #{port}. #{Time.now}\"\n # session = auth_server.accept\n debug_msg \"--- #{session.peeraddr[2]} connected. #{Time.now}\"\n user = get_username( session, data )\n next if user == false\n debug_msg \"--- Received \\\"#{user}\\\" for username. #{Time.now}\"\n salt = send_salt( session, user )\n debug_msg \"--- Sent salt to the client. #{Time.now}\"\n passwd_salty = get_salty_passwd( session )\n debug_msg \"--- Received salty password from the client. #{Time.now}\"\n authenticate?( session, salt, passwd_salty, user, data )\n end\n end\n threads.each { |t| t.join }\n end", "def select_cmux_support_role_types(roles)\n roles.select { |_, r| ROLE_PORT.keys.map.include?(r[:roleType]) }\n end", "def assign_role(role)\n if role == 'cm'\n @player = 'codemaker'\n @computer = 'codebreaker'\n announce_role\n elsif role == 'cb'\n @player = 'codebreaker'\n @computer = 'codemaker'\n announce_role\n else\n puts \"Invalid Selection. Either choose 'cb' or 'cm'.\"\n choose_role\n end\n end", "def find_server!\n @client.clients.each do |client|\n client.force_status! do |status|\n if status == :primary && [:primary, :primary_preferred, :secondary_preferred].include?(@client.read_pref)\n @pending_server = false\n server_found!\n elsif status == :secondary && [:secondary, :primary_preferred, :secondary_preferred].include?(@client.read_pref)\n @pending_server = false\n server_found!\n end\n end\n end\n end", "def run\n while true\n begin\n res = select( @descriptors, nil, nil)\n if res != nil \n for sock in res[0]\n if sock == @serverSocket \n accept_new_connection\n elsif sock.eof? \n sock.close\n @user_info.delete(@user_info[@descriptors.index(sock)-1])\n @descriptors.delete(sock)\n else\n msg = sock.gets()\n puts msg\n user_info = @user_info[@descriptors.index(sock)-1]\n if (msg =~ /user_info:|source_info:|admin_info:/) and user_info.nil? \n eval_first_msg(msg,sock) \n elsif (msg =~ /user_info:|source_info:|admin_info:/) and !(user_info.nil?)\n sock.write(\"You are registered #{user_info[:nickname]}, do not try to deceive me\\n\")\n else\n response_request(msg,sock)\n end\n end\n end\n end\n rescue => e\n puts \"Somenthing wrong happened #{e}\"\n end\n end\n end", "def find_channel(channel_name, server_name = nil, type: nil)\n results = []\n\n if /<#(?<id>\\d+)>?/ =~ channel_name\n # Check for channel mentions separately\n return [channel(id)]\n end\n\n @servers.each_value do |server|\n server.channels.each do |channel|\n results << channel if channel.name == channel_name && (server_name || server.name) == server.name && (!type || (channel.type == type))\n end\n end\n\n results\n end", "def check_for_role\n self.role = ROLES[:user] if self.role.nil?\n end", "def role(role, server)\n @roles[role] ||= []\n @roles[role] << server\n end", "def prepare_simple_client(client, channel, type); end", "def channel_status_strategy(m, level)\n if config.has_key? :authentication_channel\n channel = Channel config[:authentication_channel]\n elsif bot.config.authentication.channel\n channel = Channel bot.config.authentication.channel\n else\n channel = m.channel\n end\n\n if level.nil?\n raise StandardError, \"You haven't configured an authentication level.\"\n end\n\n bot.loggers.debug level.inspect\n\n user_modes = channel.users[m.user]\n modes = { q: 'founder', a: 'admin', o: 'operator',\n h: 'half-operator', v: 'voice' }\n\n modes.keys.take(modes.keys.find_index(level) + 1).each do |mode|\n return true if user_modes.include? mode.to_s\n end\n\n m.user.notice \"This command requires at least #{modes[level]} status \" +\n \"on #{channel}.\"\n \n return false\n rescue => e\n m.user.notice 'Something went wrong.'\n raise\n end", "def set_possible_roles\n\tif User.has_role Role.ADMINISTRATOR,session[:roles]\n\t @roles=Role.all\n\t return\n\tend\n\n\t@logged_in_user_role_id = UserRoleMap.getRoleidByUserid(session[:session_user])\n\t#@roles = Role.where(:id => RoleReportTo.select(\"user_role_id\").where(:manager_role_id => @logged_in_user_role_id))\n\t@roles = Role.getRolesByRoleid(RoleReportTo.getUserRoleidByManagerRoleid(@logged_in_user_role_id))\n\thas_volunteer=false\n\[email protected] do |role|\n\t if role.role == Role.VOLUNTEER\n\t\thas_volunteer=true\n\t\tbreak\n\t end\n\tend\n\tunless has_volunteer\n\t @volunteer_role=Role.where(role:Role.VOLUNTEER)\n\t @volunteer_role.each do |role|\n\t\[email protected] role\n\t end\n\tend\n end", "def send_roles\n s_roles = Hash.new\n @world.roles.keys.each do |role|\n s_roles[role] = @world.role_lookup(role)\n end\n s_roles\n end", "def channel(channel_command, *command_args)\n channel_hash = Hash.new\n command_args = command_args.join(\" \")\n case channel_command\n when \"authcap\"\n raise ArgumentError, \"Authcap requires a channel number and privilege\" if command_args.empty?\n channel_output = run_command(this_method_name, \"#{channel_command} #{command_args.join(' ')}\")\n return channel_hash = split_output(channel_output, ':')\n when \"getaccess\"\n raise ArgumentError, \"Authcap requires a channel number and uid\" if command_args.empty?\n user_hash = user(\"list\", command_args[0])\n raise ArgumentError, \"Invalid user specified\" unless user_hash.has_key?(\"uid#{command_args[1]}\".to_sym)\n channel_output = run_command(this_method_name, \"#{channel_command} #{command_args.join(' ')}\")\n channel_hash = split_output(channel_output, ':')\n when \"setaccess\"\n raise ArgumentError, \"Authcap requires a channel number, uid, and privilege level\" if command_args.empty?\n user_hash = user(\"list\", command_args[0])\n raise ArgumentError, \"Invalid user specified\" unless user_hash.has_key?(\"uid#{command_args[1]}\".to_sym)\n command_args[2] = \"privilege=#{command_args[2]}\"\n run_command(this_method_name, \"#{channel_command} #{command_args.join(' ')}\")\n when \"info\"\n raise ArgumentError, \"Info requires a channel number\" if command_args.empty?\n channel_output = run_command(this_method_name, \"#{channel_command} #{command_args}\")\n channel_output = channel_output.grep(/:/).each { |line| line.strip! }.delete_if { |line| line =~ /:$/ }\n return channel_hash = split_output(channel_output, ':')\n when \"getciphers\"\n raise ArgumentError, \"Info requires a protocol and channel number\" if command_args.empty?\n channel_output = run_command(this_method_name, \"#{channel_command} #{command_args.join(' ')}\").grep(/^[0-9]/)\n channel_output.each { |c| channel_hash[\"id#{c.split[0]}\".to_sym] = c.split[1..-1] }\n return channel_hash\n else\n raise ArgumentError, \"Invalid Channel Command\"\n end\n end", "def initialize_cache_handlers\n on_guild_create do |guild|\n @guild_cache.cache(guild.id, guild)\n guild.channels.each do |channel|\n channel.instance_variable_set(:@guild_id, guild.id)\n @channel_cache.cache(channel.id, channel)\n @guild_channel_cache.fetch(guild.id) { [] } << channel.id\n end\n\n guild.roles.each do |role|\n @role_cache.cache(role.id, role)\n @guild_role_cache.fetch(guild.id) { [] } << role.id\n end\n\n guild.members.each do |member|\n @member_cache.cache([guild.id, member.user.id], member)\n @user_cache.cache(member.user.id, member.user)\n end\n end\n\n on_channel_create do |channel|\n @channel_cache.cache(channel.id, channel)\n if (guild_id = channel.guild_id)\n @guild_channel_cache.fetch(guild_id) { [] } << channel.id\n end\n end\n\n on_channel_update do |channel|\n @channel_cache.cache(channel.id, channel)\n end\n\n on_channel_delete do |channel|\n channel_cache.remove(channel.id)\n if (guild_id = channel.guild_id)\n @guild_channel_cache.resolve(guild_id).delete(channel.id)\n end\n end\n\n on_guild_update do |guild|\n @guild_cache.cache(guild.id, guild)\n end\n\n on_guild_delete do |guild|\n @guild_cache.delete(guild.id)\n end\n\n on_guild_member_add do |member|\n @user_cache.cache(member.user.id, member.user)\n @member_cache.cache([member.guild_id, member.user.id], member)\n end\n\n on_guild_member_update do |payload|\n @user_cache.cache(payload.user.id, payload.user)\n if (existing = @member_cache.resolve([payload.guild_id, payload.user.id]))\n existing.instance_variable_set(:@roles, payload.roles)\n existing.instance_variable_set(:@nick, payload.nick)\n @member_cache.cache([existing.guild_id, existing.user.id], existing)\n else\n member = get_guild_member(payload.guild_id, payload.user.id)\n @member_cache.cache([member.guild_id, member.user.id], member)\n end\n end\n\n on_guild_member_remove do |payload|\n @user_cache.cache(payload.user.id, payload.user)\n @member_cache.remove([payload.guild_id, member.user.id])\n end\n\n on_guild_members_chunk do |payload|\n payload.members.each do |member|\n @member_cache.cache([member.guild_id, member.user.id], member)\n end\n end\n\n on_guild_role_create do |payload|\n @role_cache.cache(payload.role.id, payload.role)\n @guild_role_cache.fetch(payload.guild_id) { [] } << payload.role.id\n end\n\n on_guild_role_update do |payload|\n @role_cache.cache(payload.role.id, payload.role)\n end\n\n on_guild_role_delete do |payload|\n @role_cache.remove(payload.role_id)\n @guild_role_cache.resolve(payload.guild_id).delete(payload.role_id)\n end\n\n on_presence_update do |payload|\n @user_cache.cache(payload.user.id, payload.user) if payload.user\n\n @member_cache.cache([payload.guild_id, payload.user.id], payload) if payload.roles && payload.user && payload.guild_id\n end\n end", "def set_channel_info(client)\n @@channel_list = nil\n s = Rufus::Scheduler.new(:max_work_threads => 200)\n #Wait 5s so that the client is setup before trying to run.\n s.in '5s' do\n @@channel_list = client.web_client.channels_list.channels\n end\n s = Rufus::Scheduler.new(:max_work_threads => 200)\n s.every '15m' do\n @@channel_list = client.web_client.channels_list.channels || @@channel_list\n end\n end", "def check_role!\n add_role :user if roles.blank?\n if has_role?(:admin)\n add_role :editor unless has_role?(:editor)\n add_role :user unless has_role?(:user)\n end\n end", "def servers_for_role?(roles) #:nodoc:\n roles=Array(roles)\n roles.any? { |r| @roles.keys.include? (r) }\n end", "def master\n tries = 0\n begin\n redis.master!\n rescue Errno::ECONNREFUSED, Errno::EAGAIN\n puts \"master role setting for #{name} failed: #{$!}\"\n sleep 1\n retry if (tries+=1) > 5\n raise \"could not setup master #{name} #{$!}\"\n end\n end", "def join(server, already); end", "def init(args)\n if @server.service_type == :client # let server offer and ask for client\n # several sorts of options here - server offer, ask client or both\n @wopts.each do |key,val|\n case key\n when ECHO, SGA, BINARY, ZMP, EOREC\n ask_him(key,val)\n else\n offer_us(key,val)\n end\n end\n else\n # several sorts of options here - server offer, ask client or both\n @wopts.each do |key,val|\n case key\n when ECHO, SGA, BINARY, ZMP, EOREC\n offer_us(key,val)\n else\n ask_him(key,val)\n end\n end\n end\n true\n end", "def initialize(server, newnick, opts)\n raise ArgumentError, \"Please specify at least one channel\" unless opts[:channel] or opts[:channels]\n \n @nick = newnick\n @server = server\n @port = opts[:port]\n @port ||= 6667\n @local_ip = opts[:local_ip]\n @options = opts\n @listeners = Set.new\n @listeners << self\n @logger = @options[:logger]\n @nick_generator = Proc.new do |oldnick|\n if options[:ghost_without_password] then\n message \"GHOST #{oldnick}\", 'NickServ'\n nil\n elsif options[:dont_ghost] or options[:password].nil? then\n \"#{oldnick}_\"\n else\n message \"GHOST #{oldnick} #{options[:password]}\", 'NickServ'\n nil\n end\n end\n @server_type = Daemon[opts[:server_type]]\n @server_type ||= Daemon.default\n @throttle_rate = opts[:throttle_rate]\n @throttle_rate ||= 1\n @throttle_threshold = opts[:throttle_threshold]\n @throttle_threshold ||= 5\n \n @when_long = (opts[:when_long] || :send).to_sym\n @max_message_length = opts[:max_message_length].to_i\n @max_message_length = 500 if @max_message_length < 1\n \n @nick_regex = (opts[:nick_regex] ? opts[:nick_regex].to_re : NICK_REGEX)\n \n @channels = Set.new\n @channels.merge opts[:channels] if opts[:channels]\n @channels << opts[:channel] if opts[:channel]\n @channels.map! do |chan|\n if chan.kind_of? Hash then\n { normalized_channel_name(chan.keys.only) => chan.values.only }\n else\n normalized_channel_name chan\n end\n end\n # Make a hash of channels to their passwords\n @channel_passwords = @channels.select { |ch| ch.kind_of? Hash }.mash { |pair| pair }\n # Strip the passwords from @channels, making it an array of channel names only\n @channels.map! { |chan| chan.kind_of?(Hash) ? chan.keys.only : chan }\n @channel_members = Hash.new\n @updating_channel_members = Hash.new # stores the NAMES list as its being built\n \n if @throttle = opts[:throttle] then\n @messages_queue = Queue.new\n @messages_thread = Thread.new do\n throttled = false\n loop do\n args = @messages_queue.pop\n throttled = true if not throttled and @messages_queue.length >= @throttle_threshold\n throttled = false if throttled and @messages_queue.empty?\n sleep @throttle_rate if throttled\n privmsg *args\n end\n end\n end\n \n @chan_mutex = Mutex.new\n @join_mutex = Mutex.new\n @socket_mutex = Mutex.new\n end", "def subscribe_to_default_channels\n #User.find_by_username(\"brevidy\").channels.where(:recommended => true).each { |c| c.subscribe!(self) } unless Rails.env.test?\n end", "def serverHandling()\n \n loop {\n #puts \"ServerHandling thread: #{Thread.current}\"\n thread = Thread.start($serv.accept) do |client|\n \n message = client.gets.chomp\n\n \n\n arr = message.split(' ')\n server_cmd = arr[0]\n args = arr[1..-1]\n# if server_cmd != \"UPDATE\" then puts \"THIS IS THE MESSAGE: #{message}\" end\n\n case server_cmd\n when \"EDGEB2\"; edgeb_network(args)\n when \"EDGEU2\"; edgeu_network(args)\n when \"UPDATE\"; updateTable(args)\n when \"TOSOURCE\"; source_console(args)\n when \"PING\"; ping_network(args)\n when \"FORWARD\"; forward_packet(args)\n when \"SEND\"; packet_forward(args)\n when \"SEND2\"; file_forward(args)\n when \"SUCCESS\"; transfer_success(args)\n when \"CIRCUITB2\"; circuitb_network(args)\n else STDERR.puts \"ERROR: INVALID COMMAND \\\"#{server_cmd}\\\"\"\n end\n client.close\n end\n \n }\n\nend", "def roles(*select_roles, &block)\n if block_given?\n return yield(roles(*select_roles))\n end\n\n roles_set = Set.new select_roles.flatten.compact.map{|r| r.to_sym}\n if roles_set.empty? || roles_set.include?(:all)\n self\n else\n @cache[roles_set] ||= select { |server| server.matches_roles?(roles_set) }\n end\n end", "def roles(*select_roles, &block)\n if block_given?\n return yield(roles(*select_roles))\n end\n\n roles_set = Set.new select_roles.flatten.compact.map{|r| r.to_sym}\n if roles_set.empty? || roles_set.include?(:all)\n self\n else\n @cache[roles_set] ||= select { |server| server.matches_roles?(roles_set) }\n end\n end", "def _network_init\n # A note on special_rooms. Special rooms are \"rooms\" that may or may not\n # be tied to an actual chatroom, and even if they are, it may be inappropriate\n # to log their contents. Whiteboard rooms, for instance, are connected to\n # an actual chatroom, but logging the rooms' contents would be absurd.\n # Private message \"rooms\" aren't actual chatrooms, but logging is probably a\n # good idea. The special room hash persists across network restarts but is\n # not saved to disk. Any value evaluating to true means \"log\".\n special_rooms = @var.delete :special_rooms\n\n # Flush out all blacklisted state\n @var[:blacklist_env].each { |rm| @var.delete rm unless rm == :blacklist_env }\n @var[:special_rooms] = special_rooms\n\n # Add the key hashes\n @var[:user_keys].each do |name, key|\n keyhash = MD5::digest(key)[0,8]\n @connection.comm.rsa_keys[name] = key\n @connection.comm.names[keyhash] = name\n end\n\n # Keys and access\n @var[:granted] = [ @var[:our_name] ]\n @var[:granted_by] = [ @var[:our_name] ]\n @var[:revoked] ||= []\n\n # Chat rooms and presense\n @var[:room] = 'chat' # current room\n @var[:membership] = {} # maps room-name to known room members' keyhashes\n @var[:presence] = {} # maps peer keyhash to presence + salutation\n @var[:membership][EMPTY_ROOM] = [ @connection.comm.our_keyhash ]\n @var[:presence][@connection.comm.our_keyhash] = [ 'offline', '' ]\nend", "def client?\n roles.count == 1 && has_role?('client')\n end", "def server_login\n loaded_session=false\n begin\n if !env[\"session_file\"].nil? && !env[\"session_file\"].empty?\n path=File.expand_path(env[\"session_file\"])\n# puts \"Attempting to load previous session keys from #{env[\"session_file\"]}\" if env[\"echo\"]\n yaml=YAML::load(File.open(path))\n if yaml[\"auth\"]\n yaml[\"auth\"].each {|k,v|\n if v.nil? #cleanup for old auth file\n k=\"global\"\n v=k\n end\n ServerCredentials.instance[k][\"auth\"]=v\n }\n end\n credentials=ServerCredentials.instance[env[\"default_server\"]]\n if credentials[\"auth\"]\n puts \"Attempting to use previous key\" if env[\"echo\"]\n loaded_session=ZabbixServer.instance.use_auth(credentials)\n puts \"#{env[\"server\"]} connected\" if env[\"echo\"]\n puts \"API Version: #{ZabbixServer.instance.version}\" if env[\"echo\"]\n end\n end\n rescue Errno::ECONNREFUSED, Errno::ENOENT, ZbxAPI_ExceptionLoginPermission\n puts \"Failed to load previous session key\" if env[\"echo\"]\n# return\n end\n\n\n credentials=ServerCredentials.instance[env[\"default_server\"]] if credentials.nil?\n\n if !loaded_session && !credentials[\"server\"].nil? &&\n !credentials[\"username\"].nil? && !credentials[\"password\"].nil?\n puts \"Found valid login credentials, attempting login\" if env[\"echo\"]\n begin\n\n #\n ZabbixServer.instance.login(credentials)\n\n rescue ZbxAPI_ExceptionBadAuth => e\n puts e.message\n rescue ZbxAPI_ExceptionLoginPermission\n puts \"Error Invalid login or no API permissions.\"\n rescue ZbxAPI_ExceptionBadServerUrl\n puts \"Error connecting to server\" #TODO Fix message to show hostname\n end\n end\n\n end", "def roles\n\t\t\t\tProxy.new connection, 'role-strategy/strategy'\n\t\t\tend", "def auth_agent_channel(session, channel, packet); end", "def server?\n @role == :server\n end", "def load_roles\n top.roles.clear\n\n # define empty roles for all known ones so tasks don't fail if a role\n # doesn't exist due to a filter\n all_roles = rubber_instances.all_roles\n all_roles += rubber_cfg.environment.known_roles\n all_roles.uniq!\n all_roles.each {|name| top.roles[name.to_sym] = []}\n\n # define capistrano host => role mapping for all instances\n rubber_instances.filtered.each do |ic|\n ic.roles.each do |role|\n opts = Rubber::Util::symbolize_keys(role.options).merge(:platform => ic.platform, :provider => ic.provider)\n msg = \"Auto role: #{role.name.to_sym} => #{ic.full_name}\"\n msg << \", #{opts.inspect}\" if opts.inspect.size > 0\n logger.info msg\n top.role role.name.to_sym, ic.full_name, opts\n end\n end\n end", "def each_online_admin\n each_controlchannel {|channel|\n channel.users.each {|user, modes|\n yield(user) if is_admin?(user)\n }\n }\n end", "def check_for_role\n\t\tself.role = ROLES[:user] if !self.role.present?\n\tend", "def handle(message)\n if message[\"content\"].include? \"!players\"\n @@hlds_servers.each do |s|\n ip, port, is_hltv, pwd = s[0], s[1], s[2], s[3]\n content = get_status(ip, port, is_hltv, pwd)\n say(get_token(message[\"flow\"]), content)\n end\n elsif message[\"content\"].match(/!rcon(\\d+)/)\n if @@hlds_admins.include?(message[\"user\"])\n server, command = message[\"content\"].match(/^!rcon(\\d.)(.*)$/i).captures\n ip, port, is_hltv, pwd = @@hlds_servers[server.to_i-1][0], @@hlds_servers[server.to_i-1][1], @@hlds_servers[server.to_i-1][2], @@hlds_servers[server.to_i-1][3]\n content = rcon_exec(ip, port, is_hltv, pwd, command)\n say(get_token(message[\"flow\"]), content)\n elsif message[\"user\"] == \"0\"\n # bot himself\n else\n say(get_token(message[\"flow\"]), \"Sorry, you're not a CS Admin.\")\n end\n end\n end", "def main\n action = configuration[:action]\n\n mc = rpcclient('lusers', :options => options)\n\n case action\n when \"who\"\n mc.who() do |r|\n begin\n lusers = []\n r[:body][:data][:msg].each do |l|\n lusers << l['user']\n end\n if configuration.has_key?('filter') and not configuration['filter'].empty?\n filter = configuration['filter'].split(' ')\n filter.collect!{|x| x.strip}\n lusers = lusers - filter\n end\n unless lusers.empty?\n printf(\"%-40s: %s\\n\", r[:senderid], lusers.join(','))\n end\n rescue RPCError => e\n puts \"The RPC agent returned an error: #{e}\"\n end\n end\n when \"wall\"\n # XXX: sanitize .. ? probably 8)\n mc.wall(:msg => ARGV.to_s) do |r|\n printf(\"%-40s: OK\\n\", r[:senderid]) if r[:body][:data][:msg] == 0\n end\n when \"has_user\"\n mc.has_user(:user => ARGV.to_s ) do |r|\n # XXX: argv can be a string of several users, i.e. \"john jane\"\n #printf(\"%-40s: %s\\n\", r[:senderid], r[:body][:data][:out]) if r[:body][:data][:msg] == 0\n # this will give an entry for each user, i.e.:\n # host.name : john\n # host.name : jane\n # other.host.name : john\n #\n # ...which is easy to parse. Could do\n # host.name : john\n # : jane\n #\n # which would be easier to 'parse' for human eyes, visually separating hosts/data better\n r[:body][:data][:out].split(' ').each do |u|\n printf(\"%-40s: %s\\n\", r[:senderid], u)\n end\n end\n when \"has_group\"\n mc.has_group(:group => ARGV.to_s ) do |r|\n #printf(\"%-40s: %s\\n\", r[:senderid], r[:body][:data][:out]) if r[:body][:data][:msg] == 0\n r[:body][:data][:out].split(' ').each do |u|\n printf(\"%-40s: %s\\n\", r[:senderid], u)\n end\n end\n end\n\n printrpcstats\n end", "def channel_join(m, channel)\r\n if_admin(m) { @bot.join(channel) }\r\n end", "def cmute(m, nick)\n nick = User(nick)\n if is_chanadmin?(m.channel, m.user) && is_botpowerful?(m.channel)\n User('ChanServ').send(\"quiet #{m.channel} #{nick}\")\n elsif !is_chanadmin?(m.channel, m.user)\n m.reply NOTADMIN, true\n elsif !is_botpowerful?(m.channel)\n m.reply NOTOPBOT, true\n end\n end", "def first_user_hook\n if User.with_role(:admin).count == 0\n self.grant :admin\n else # set editor as default role\n self.grant :editor if self.roles.empty?\n end\n end", "def remote_state\n return @remote_state if @remote_state.present?\n\n remote_user = get_json(\"/v1/users/#{user.email}\")\n remote_roles = get_json(\"/v1/users/#{user.email}/roles\")\n @remote_state = remote_user.merge(remote_roles)\n rescue SocketError\n raise ServiceUnavailable.new(\"Gloo isn't accepting connections on #{base_url}\")\n end", "def check_default_role\n roles << :user if roles.empty?\n end", "def login_related(msg)\n if Login === msg\n if @connection.server.authenticator.allowed?(\n msg.user_name, msg.password)\n @connection.user_name = msg.user_name\n @connection.send_msg(LoginOK.new)\n @connection.room.add_connection @connection\n else\n @connection.send_msg(LoginWrong.new)\n end\n return true\n elsif not @connection.authorized?\n @connection.send_msg Kick.new(\n \"Unauthorized connections aren't allowed to send '#{msg.class}'!\")\n @connection.force_close\n return true\n end\n false\n end", "def should_run?( options )\n if roles = Array( options[:roles] )\n return false unless roles.any?{ |r| r == :all || host.has_role?( r ) }\n end\n\n true\n end", "def connect\n tries ||= 5\n if @connection.nil? or @connection.disconnected?\n @connection = Net::IMAP.new(@server, port: @port, ssl: @ssl)\n if @starttls\n @connection.starttls\n end\n @connection.login(@username, @password)\n end\n @connection.select(@folder)\n rescue Net::IMAP::ByeResponseError, Net::IMAP::NoResponseError => e\n retry unless (tries -= 1).zero?\n end", "def claim_thread_runner\n while running?\n User.select(:id, :email, :connected_at, :archived).find_each do |user|\n if server_rhash.hash(user.id) == server_tag && !user.archived && user.connected_at\n schedule_work(:connect_user, :hash => user.id, :user_id => user.id)\n else\n schedule_work(:disconnect_user, :hash => user.id, :user_id => user.id)\n end\n\n # Try not to peg the processor.\n sleep 0.01\n end\n light_sleep 10\n end\n rescue Exception => e\n Log.exception(e)\n raise e\n ensure\n Log.info(\"Stopping claim thread.\")\n end", "def installRoles\n roledir = @ansible_path+\"/roles\"\n\n canon_links = {}\n\n repodirs = []\n\n # Make sure we search the global ansible_dir, if any is set\n if $MU_CFG and $MU_CFG['ansible_dir'] and !$MU_CFG['ansible_dir'].empty?\n if !Dir.exist?($MU_CFG['ansible_dir'])\n MU.log \"Config lists an Ansible directory at #{$MU_CFG['ansible_dir']}, but I see no such directory\", MU::WARN\n else\n repodirs << $MU_CFG['ansible_dir']\n end\n end\n\n # Hook up any Ansible roles listed in our platform repos\n if $MU_CFG and $MU_CFG['repos']\n $MU_CFG['repos'].each { |repo|\n repo.match(/\\/([^\\/]+?)(\\.git)?$/)\n shortname = Regexp.last_match(1)\n repodirs << MU.dataDir + \"/\" + shortname\n }\n end\n\n repodirs.each { |repodir|\n [\"roles\", \"ansible/roles\"].each { |subdir|\n next if !Dir.exist?(repodir+\"/\"+subdir)\n Dir.foreach(repodir+\"/\"+subdir) { |role|\n next if [\".\", \"..\"].include?(role)\n realpath = repodir+\"/\"+subdir+\"/\"+role\n link = roledir+\"/\"+role\n \n if isAnsibleRole?(realpath)\n if !File.exist?(link)\n File.symlink(realpath, link)\n canon_links[role] = realpath\n elsif File.symlink?(link)\n cur_target = File.readlink(link)\n if cur_target == realpath\n canon_links[role] = realpath\n elsif !canon_links[role]\n File.unlink(link)\n File.symlink(realpath, link)\n canon_links[role] = realpath\n end\n end\n end\n }\n }\n }\n\n # Now layer on everything bundled in the main Mu repo\n Dir.foreach(MU.myRoot+\"/ansible/roles\") { |role|\n next if [\".\", \"..\"].include?(role)\n next if File.exist?(roledir+\"/\"+role)\n File.symlink(MU.myRoot+\"/ansible/roles/\"+role, roledir+\"/\"+role)\n }\n\n coldir = \"#{Etc.getpwuid(Process.uid).dir}/.ansible/collections/ansible_collections\"\n [\"ansible.windows\", \"community.general.gem\"].each { |coll|\n %x{#{@ansible_execs}/ansible-galaxy collection list -p \"#{coldir}\"}\n if $? != 0\n system(%Q{#{@ansible_execs}/ansible-galaxy}, \"collection\", \"install\", coll, \"-p\", coldir)\n end\n } \n\n if @server.config['run_list']\n @server.config['run_list'].each { |role|\n found = false\n if !File.exist?(roledir+\"/\"+role)\n if role.match(/[^\\.]\\.[^\\.]/) and @server.config['groomer_autofetch']\n system(%Q{#{@ansible_execs}/ansible-galaxy}, \"--roles-path\", roledir, \"install\", role)\n found = true\n# XXX check return value\n else\n canon_links.keys.each { |longrole|\n if longrole.match(/\\.#{Regexp.quote(role)}$/)\n File.symlink(roledir+\"/\"+longrole, roledir+\"/\"+role)\n found = true\n break\n end\n }\n end\n else\n found = true\n end\n if !found\n raise MuError, \"Unable to locate Ansible role #{role}\"\n end\n }\n end\n\n end", "def check_for_role\n\t\tself.role = ROLES[:user] if self.role.nil?\n\tend", "def get_role_ids()\n server = Rails.cache.read('discord_bot/servers')&.find { |s| s['id'] == self.discord_server.id }\n\n return [] if server.nil?\n\n roles_config = server['exp_roles_config']\n\n return [] if roles_config.nil?\n\n thresholds = roles_config.sort_by { |r| r[0] }\n acquired_roles = []\n\n while thresholds.count > 0 && self.exp > thresholds.first[0] do\n acquired_roles.push(thresholds.shift)\n end\n\n return acquired_roles\n end", "def start( port = 24842 )\n server = TCPServer.new( port )\n\n while @session = server.accept\n username = converse()\n salt = generate_salt\n auth_string = converse( salt )\n if authenticate?( username, salt, auth_string )\n result = \"AUTHORIZED\"\n else\n result = \"NOT AUTHORIZED\"\n end\n @session.puts( result )\n @session.close\n end\n \n # returning last result\n return result\n\n end", "def start_new_roles_on_nodes(nodes_needed, instance_type, secret)\n if !valid_secret?(secret)\n return BAD_SECRET_MSG\n end\n\n if nodes_needed.class != Array\n Djinn.log_error(\"Was expecting nodes_needed to be an Array, not \" +\n \"a #{nodes_needed.class}\")\n return BAD_INPUT_MSG\n end\n\n Djinn.log_info(\"Received a request to acquire nodes with roles \" +\n \"#{nodes_needed.join(', ')}, with instance type #{instance_type} for \" +\n \"new nodes\")\n\n vms_to_use = []\n ZKInterface.lock_and_run {\n num_of_vms_needed = nodes_needed.length\n\n @nodes.each_with_index { |node, index|\n if node.is_open?\n Djinn.log_info(\"Will use node #{node} to run new roles\")\n node.jobs = nodes_needed[vms_to_use.length]\n vms_to_use << node\n\n if vms_to_use.length == nodes_needed.length\n Djinn.log_info(\"Only using open nodes to run new roles\")\n break\n end\n end\n }\n\n vms_to_spawn = nodes_needed.length - vms_to_use.length\n \n if vms_to_spawn > 0 and !is_cloud?\n Djinn.log_error(\"Still need #{vms_to_spawn} more nodes, but we \" +\n \"aren't in a cloud environment, so we can't acquire more nodes - \" +\n \"failing the caller's request.\")\n return NOT_ENOUGH_OPEN_NODES\n end\n\n if vms_to_spawn > 0\n Djinn.log_info(\"Need to spawn up #{vms_to_spawn} VMs\")\n # Make sure the user has said it is ok to add more VMs before doing so.\n allowed_vms = Integer(@creds['max_images']) - @nodes.length\n if allowed_vms < vms_to_spawn\n Djinn.log_info(\"Can't spawn up #{vms_to_spawn} VMs, because that \" +\n \"would put us over the user-specified limit of #{@creds['max']} \" +\n \"VMs. Instead, spawning up #{allowed_vms}.\")\n vms_to_spawn = allowed_vms\n if vms_to_spawn.zero?\n Djinn.log_error(\"Reached the maximum number of VMs that we \" +\n \"can use in this cloud deployment, so not spawning more nodes.\")\n return \"Reached maximum number of VMs we can use.\"\n end\n end\n\n disks = Array.new(size=vms_to_spawn, obj=nil) # no persistent disks\n\n # start up vms_to_spawn vms as open\n imc = InfrastructureManagerClient.new(@@secret)\n begin\n new_nodes_info = imc.spawn_vms(vms_to_spawn, @creds, \"open\", disks)\n rescue AppScaleException => exception\n Djinn.log_error(\"Couldn't spawn #{vms_to_spawn} VMs with roles \" +\n \"open because: #{exception.message}\")\n return exception.message\n end\n\n\n # initialize them and wait for them to start up\n Djinn.log_debug(\"info about new nodes is \" +\n \"[#{new_nodes_info.join(', ')}]\")\n add_nodes(new_nodes_info)\n\n # add information about the VMs we spawned to our list, which may\n # already have info about the open nodes we want to use\n new_nodes = Djinn.convert_location_array_to_class(new_nodes_info,\n @creds['keyname'])\n vms_to_use << new_nodes\n vms_to_use.flatten!\n end\n }\n\n wait_for_nodes_to_finish_loading(vms_to_use)\n \n nodes_needed.each_index { |i|\n Djinn.log_info(\"Adding roles #{nodes_needed[i].join(', ')} \" +\n \"to virtual machine #{vms_to_use[i]}\")\n ZKInterface.add_roles_to_node(nodes_needed[i], vms_to_use[i],\n @creds['keyname'])\n }\n\n wait_for_nodes_to_finish_loading(vms_to_use)\n\n return \"OK\"\n end", "def get_role_info()\n make_call(NO_TIMEOUT, ABORT_ON_FAIL) { \n @conn.get_role_info(@secret) \n }\n end", "def ensure_channel(data, server = nil)\n if @channels.include?(data['id'].to_i)\n @channels[data['id'].to_i]\n else\n @channels[data['id'].to_i] = Channel.new(data, self, server)\n end\n end", "def channels \n debug [query[\"channels\"], \" are registered channels\"]\n @channels ||= query[\"channels\"].collect(&:strip).reject(&:empty?) \n @channels[0] ||= nil # Every user should have at last one channel\n @channels\n end", "def check_role\n redirect_to(root_url) unless check_role?(\"News Editor\") or check_role?(\"Site Admin\")\n end", "def check_role\n redirect_to(root_url) unless check_role?(\"News Editor\") or check_role?(\"Site Admin\")\n end", "def response_request(msg,sock)\n begin \n @user = @user_info[@descriptors.index(sock)-1]\n msg = msg.strip\n umsg = msg.split(\" \")\n cmd = umsg[0]\n puts \"Comando ingresado: \" + cmd\n case @user[:role]\n when \"client\"\n if @@cmd_client.include? cmd\n evaluate_client(umsg,sock)\n else\n raise Exception.new(\"#{@@cmd_client}\")\n end\n when \"editor\"\n if @@cmd_editor.include? cmd\n evaluate_editor(umsg,sock) \n else\n raise Exception.new(\"#{@@cmd_editor}\")\n end\n when \"admin\"\n if @@cmd_admin.include? cmd\n evaluate_admin(umsg,sock)\n else\n raise Exception.new(\"#{@@cmd_admin}\")\n end\n end\n rescue Exception => e\n sock.write(\"Invalid command: #{umsg[0]}\\nValid Commands:#{e}\\n\")\n end\n end", "def loop_until_server_online\n\t\tcs_conn=self.cloud_server_init\n\n\t\terror_message=\"Failed to build server.\"\n\n\t\ttimeout=self.server_online_timeout-(Time.now-self.updated_at).to_i\n\t\ttimeout = 120 if timeout < 120\n\n\t\tbegin\n\t\t\tTimeout::timeout(timeout) do\n\n\t\t\t\t# poll the server until progress is 100%\n\t\t\t\tcs=cs_conn.find_server(\"#{self.cloud_server_id_number}\")\n\t\t\t\tuntil cs.progress == 100 and cs.status == \"ACTIVE\" do\n\t\t\t\t\tcs=cs_conn.find_server(\"#{self.cloud_server_id_number}\")\n\t\t\t\t\tsleep 1\n\t\t\t\tend\n\n\t\t\t\terror_message=\"Failed to ssh to the node.\"\t\n\n\t\t\t\tif ! system(%{\n\n\t\t\t\t\t\tCOUNT=0\n\t\t\t\t\t\twhile ! ssh -o \"StrictHostKeyChecking no\" -T -i #{self.server_group.ssh_key_basepath} root@#{cs.addresses[:public][0]} /bin/true > /dev/null 2>&1; do\n\t\t\t\t\t\t\tif (($COUNT > 23)); then\n\t\t\t\t\t\t\t\texit 1\n\t\t\t\t\t\t\tfi\n\t\t\t\t\t\t\t((COUNT++))\n\t\t\t\t\t\t\tsleep 15\n\t\t\t\t\t\tdone\n\t\t\t\t\t\texit 0\n\n\t\t\t\t}) then\n\t\t\t\t\tfail_and_raise error_message\n\t\t\t\tend\n\n\t\t\tend\n\t\trescue Exception => e\n\t\t\tfail_and_raise error_message\n\t\tend\n\n\tend", "def prompt_user_roles(account_id, user_id, selected_roles=[], options={})\n passed_role_names = []\n if !selected_roles.empty?\n if selected_roles.is_a?(String)\n passed_role_names = selected_roles.split(',').uniq.compact.collect {|r| r.strip}\n else\n passed_role_names = selected_roles\n end\n end\n\n available_roles = @account_users_interface.available_roles(account_id, user_id)['roles']\n\n if available_roles.empty?\n print_red_alert \"No available roles found.\"\n exit 1\n end\n role_options = available_roles.collect {|role|\n {'name' => role['authority'], 'value' => role['id']}\n }\n\n roles = []\n\n if !passed_role_names.empty?\n invalid_role_names = []\n passed_role_names.each do |role_name|\n found_role = available_roles.find {|ar| ar['authority'] == role_name || ar['id'] == role_name.to_i}\n if found_role\n roles << found_role\n else\n invalid_role_names << role_name\n end\n end\n if !invalid_role_names.empty?\n print_red_alert \"Invalid Roles: #{invalid_role_names.join(', ')}\"\n exit 1\n end\n else\n no_prompt = (options[:no_prompt] || (options[:options] && options[:options][:no_prompt]))\n v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'roles', 'fieldLabel' => 'Role', 'type' => 'select', 'selectOptions' => role_options, 'required' => true}], options[:options])\n role_id = v_prompt['roles']\n roles << available_roles.find {|r| r['id'].to_i == role_id.to_i }\n add_another_role = !no_prompt\n while add_another_role do\n v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'roles', 'fieldLabel' => 'Another Role', 'type' => 'select', 'selectOptions' => role_options, 'required' => false}], options[:options])\n if v_prompt['roles'].to_s.empty?\n add_another_role = false\n else\n role_id = v_prompt['roles']\n roles << available_roles.find {|r| r['id'].to_i == role_id.to_i }\n end\n end\n \n end\n\n roles = roles.compact\n return roles\n\n end", "def run\n parse_quiz_questions\n\n # First thing to do is to connect to the server\n connect\n\n # Here we keep the connection open, as long as it's not getting closed by the server (that would result in\n # @socket.eof? returning true).\n until @socket.eof? do\n\n # We read the next incoming message from the socket connection.\n message = @socket.gets\n\n # We ouput the message on the terminal, so we can see what our bot's input is.\n puts message\n\n # If the message we are getting is a \"PING\" message...\n if message.start_with?(\"PING\")\n # ...then we need to react to that PING, so as to not get disconnected accidentally.\n handle_ping_message(message)\n\n # If the message is a private message sent inside our channel...\n elsif message.include?(\"PRIVMSG #{@channel}\")\n # ...then we react in some way to that message.\n handle_channel_message(message)\n\n # If we haven't joined our channel yet and the message includes \"MODE\" and the bot's name...\n elsif !@joined && message.include?(\"MODE #{@name}\")\n # ...then the server is ready for us to join the channel.\n irc_send_join(@channel)\n # We set @joined to true, so we don't try to join the channel twice accidentally.\n @joined = true\n end\n end\nend", "def find_channel\n debug 'Looking for channel...'\n _response = self.signed_request'/api/v1/channels.list.joined', 'GET'\n _channels = _response['channels']\n\n _channels.each { |ch|\n if ch['name'] == $config.get_channel\n @channel_id = ch['_id']\n break\n end\n }\n\n if @channel_id\n debug \"Channel found! Channel ID is #{@channel_id}\"\n else\n puts \"Channel not found. Check if channel ##{$config.get_channel} exists and bot user is added to the channel.\"\n exit 1\n end\n end", "def when_channel_confirmed(channel)\n debug { \"requesting sftp subsystem\" }\n @state = :subsystem\n channel.subsystem(\"sftp\", &method(:when_subsystem_started))\n end", "def channel!\n return true unless query?\n\n raise 'This command may only be used in channels.'\n end", "def initialize_roles(user)\n case user.class.to_s\n when \"AdminUser\"\n admin_user_with_role(user)\n when \"HakaUser\"\n haka_user(user)\n when \"GuestUser\"\n guest_user(user)\n else\n raise \"Current user class could not be determined. This is a bug.\"\n end\n end", "def select_server(server_list)\n while true\n puts \"Would you like to connect to any server directly?\"\n if check_in_tmux\n puts \"Please select server\"\n puts \"Select multible server by enter server number comma seperated.\"\n print \"Server numer(s) (Enter to exit): \"\n else\n puts \"Please select a server\"\n puts \"(you could connect to multible server if you run awsssh in tmux)\"\n print \"Server numer (Enter to exit): \"\n end\n server_selection = STDIN.gets.chomp.split(\",\").map{|n| n.strip.to_i if n.strip.to_i != 0}\n server_to_connect = server_selection.reject{ |a| a.nil? || a > server_list.length+1}\n if server_to_connect.length > 1 && check_in_tmux\n session = \"awsssh-connect\"\n `tmux -2 new-session -d -s #{session}`\n server_to_connect.each_with_index do |server, index|\n puts \"connect to #{server_list[server]}\"\n `tmux send -t #{session} \"ssh #{server_list[server]}\" ENTER`\n # `tmux send -t #{session} \"ls -la\" ENTER`\n `tmux split-window -t #{session}:.1`\n `tmux select-layout -t #{session} tiled`\n end\n `tmux send -t #{session} \"exit\" ENTER`\n `tmux set-window-option -t #{session} synchronize-panes on`\n `tmux select-window -t #{session}:1`\n `tmux switch -t #{session}`\n elsif server_to_connect.length == 1\n puts \"connect one to #{server_list[server_to_connect.first]}\"\n connect_server server_list[server_to_connect.first]\n else\n puts \"No Server sellected\"\n puts\n break\n end\n exit 0\n end\n end", "def login\n puts \"logging in\"\n tries ||= 3\n @@sftp = Net::SFTP.start('moftp.mo.gov', Rails.application.credentials[:missouri_username], password: Rails.application.credentials[:missouri_password], number_of_password_prompts: 0 )\n puts \"logon successful!\"\n rescue Net::SSH::AuthenticationFailed \n tries -= 1\n if tries > 0 \n puts \"Trying again: #{tries}\"\n retry\n else\n puts \"Logon failed. Try again later.\"\n UserMailer.login_error.deliver_now!\n @@sftp = nil\n return\n end\n end", "def ensure_all_roles_are_running\n roles_to_add = []\n ZKInterface.lock_and_run {\n ip_info = ZKInterface.get_ip_info()\n ip_info['ips'].each { |ip|\n if !ZKInterface.is_node_done_loading?(ip)\n next\n end\n\n if ZKInterface.is_node_live?(ip)\n next\n else\n failed_job_data = ZKInterface.get_job_data_for_ip(ip)\n failed_node = DjinnJobData.new(failed_job_data, @creds['keyname'])\n roles_to_add << failed_node.jobs\n\n remove_app_hosting_data_for_node(ip)\n remove_node_from_local_and_zookeeper(ip)\n Djinn.log_info(\"Will recover [#{failed_node.jobs.join(', ')}] \" +\n \" roles that were being run by the failed node at #{ip}\")\n end\n }\n\n if !roles_to_add.empty?\n start_new_roles_on_nodes(roles_to_add, @creds['instance_type'],\n @@secret)\n end\n }\n\n return roles_to_add\n end", "def setup_role\n #get_statuses(@role)\n #set_default_status(@role)\n end", "def read_server_role(srcn)\n\n filter1 = Net::LDAP::Filter.eq( \"objectclass\", \"serverRole\" )\n filter2 = Net::LDAP::Filter.eq( \"cn\", srcn )\n filter = Net::LDAP::Filter.join(filter1, filter2)\n attrs = [ ]\n\n $conn.search(:base => $basedomainsr,\n :filter => filter) do |entry|\n serverrole = entry\n\n return serverrole\n end\nend", "def ha_config_check\n prop = Proposal.where(barclamp: \"cinder\").first\n\n unless prop.nil?\n backends = prop[\"attributes\"][\"cinder\"][\"volumes\"].select do |volume|\n backend_driver = volume[\"backend_driver\"]\n [\"local\", \"raw\"].include? backend_driver\n end\n return { cinder_wrong_backend: true } unless backends.empty?\n end\n\n # Check if roles important for non-disruptive upgrade are deployed in the cluster\n clustered_roles = [\n \"database-server\",\n \"rabbitmq-server\",\n \"keystone-server\",\n \"glance-server\",\n \"cinder-controller\",\n \"neutron-server\",\n \"neutron-network\",\n \"nova-controller\"\n ]\n barclamps = [\n \"database\",\n \"rabbitmq\",\n \"keystone\",\n \"glance\",\n \"cinder\",\n \"neutron\",\n \"nova\"\n ]\n roles_not_ha = []\n roles_clusters = {}\n clusters_roles = {}\n clusters_roles.default = []\n barclamps.each do |barclamp|\n proposal = Proposal.where(barclamp: barclamp).first\n next if proposal.nil?\n proposal[\"deployment\"][barclamp][\"elements\"].each do |role, elements|\n next unless clustered_roles.include? role\n elements.each do |element|\n if ServiceObject.is_cluster?(element)\n # currently roles can't be assigned to more than one cluster\n roles_clusters[role] = element\n clusters_roles[element] |= [role]\n else\n roles_not_ha |= [role]\n end\n end\n end\n end\n return { roles_not_ha: roles_not_ha } if roles_not_ha.any?\n\n # Make sure nova compute role is not mixed with a controller roles\n conflicting_roles = [\n \"cinder-controller\",\n \"cinder-volume\",\n \"glance-server\",\n \"keystone-server\",\n \"neutron-server\",\n \"neutron-network\",\n \"nova-controller\",\n \"swift-proxy\",\n \"swift-ring-compute\",\n \"ceilometer-server\",\n \"heat-server\",\n \"horizon-server\",\n \"manila-server\",\n \"trove-server\"\n ]\n ret = {}\n NodeObject.find(\"roles:nova-compute-kvm\").each do |node|\n conflict = node.roles & conflicting_roles\n unless conflict.empty?\n ret[:role_conflicts] ||= {}\n ret[:role_conflicts][node.name] = conflict\n end\n end\n\n # example inputs:\n # roles_clusters = {\n # \"neutron-server\": \"cluster:cluster1\",\n # \"neutron-network\": \"cluster:cluster1\",\n # \"database-server\": \"cluster:cluster2\",\n # \"rabbitmq-server\": \"cluster:cluster3\"\n # }\n # clusters_roles = {\n # \"cluster:cluster1\": [\"neutron-server\", \"neutron-network\"],\n # \"cluster:cluster2\": [\"database-server\"],\n # \"cluster:cluster3\": [\"rabbitmq-server\"]\n # }\n deployment_supported =\n case clusters_roles.length\n when 0\n # no clusters, no point complaining as this will be detected by other prechecks\n true\n\n when 1\n # everything on one cluster = no problem\n true\n\n when 2\n # neutron-network in separate cluster\n true if clusters_roles[roles_clusters[\"neutron-network\"]].length == 1 ||\n # neutron-network + neutron-server in separate cluster\n (clusters_roles[roles_clusters[\"neutron-network\"]].length == 2 &&\n roles_clusters[\"neutron-network\"] == roles_clusters[\"neutron-server\"]) ||\n # database-server + rabbitmq-server in separate cluster\n (clusters_roles[roles_clusters[\"database-server\"]].length == 2 &&\n roles_clusters[\"database-server\"] == roles_clusters[\"rabbitmq-server\"])\n\n when 3\n # neutron-network and database-server + rabbitmq-server in separate clusters\n # rest of *-server roles is implicitly on the third cluster\n true if clusters_roles[roles_clusters[\"neutron-network\"]].length == 1 &&\n clusters_roles[roles_clusters[\"database-server\"]].length == 2 &&\n roles_clusters[\"database-server\"] == roles_clusters[\"rabbitmq-server\"]\n end\n ret[:unsupported_cluster_setup] = true unless deployment_supported\n\n ret\n end", "def agent(channel)\n return if @agent_forwarded\n\n @agent_forwarded = true\n\n channel.send_channel_request(\"[email protected]\") do |achannel, success|\n if success\n debug { \"authentication agent forwarding is active\" }\n else\n achannel.send_channel_request(\"auth-agent-req\") do |a2channel, success2|\n if success2\n debug { \"authentication agent forwarding is active\" }\n else\n error { \"could not establish forwarding of authentication agent\" }\n end\n end\n end\n end\n end", "def set_roles\n roles << Role.user unless has_role?(\"user\")\n as_seller! if @registration_as_seller.to_i == 1\n end", "def runJabber\n \n i = 0\n while i < 3 do \n begin\n @jbclient = Jabber::Client.new Jabber::JID.new(@@conf[\"jabber_account\"])\n @jbclient.connect(@@xmpp_host, @@xmpp_port)\n @jbclient.auth(@@conf[\"password\"])\n @jbclient.send(Jabber::Presence.new.set_type(:available))\n puts \"Connected to jabber server\" if @jbclient.is_connected?\n \n roster = Jabber::Roster::Helper.new(@jbclient)\n \n roster.add_subscription_request_callback { |item,presence|\n if presence.from == @@visualRESTmain\n roster.accept_subscription(presence.from)\n end\n }\n i = 3\n rescue => exception\n puts \"xmpp \" + exception\n sleep(1)\n i += 1\n end\n end\n \n @jbclient.add_message_callback { |msg|\n if msg != nil and msg.type == :chat and msg.body and msg.from == @@visualRESTmain\n puts \"<#{msg.from}> #{msg.body.strip}\"\n \n cmd, arg = msg.body.split(/ /, 2)\n \n if cmd and @@test_messages\n puts \"CMD: \" + cmd\n end\n if arg and @@test_messages\n puts \"ARG: \" + arg\n end\n command(msg.from, cmd, arg)\n end\n }\nend", "def client?\n role == 'client'\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 post_init\n send_message :PASS, @settings[:server_password] if @settings[:server_password]\n send_message :USER, @settings[:ident], \"0\", \"0\", @settings[:realname]\n send_message :NICK, @settings[:nick]\n end", "def propagate_roles_needed(task_name) \n \n #All recipes besides server have the same name in their body; thus task_name usually is\n #Recipe.name. However, if you are executing a task that appears\n #as 'server_display' in the dropdown menu, it is actually named 'server' in the \n #recipes and in the database.\n if(task_name!=\"server_display\")\n recipe_to_run=Recipe.find_by_name(task_name) \n else \n recipe_to_run = Recipe.find_by_name(\"server\")\n if !recipe_to_run.role_needed then\n #Check if the recipe chosen to run on this deployment is a predefined recipe\n #that does not require a parameter, i.e. a specific ip_address list.\n #check to see that current_stage has all roles needed for the recipes it has,\n #otherwise propagate them.\n recipe_types = recipe_to_run.server_types #aggregating the server_types for all recipes in this stage\n recipe_types.each{|t| \n if !current_stage.roles.map{|r|r.name}.include?(t.name)then\n \n #propagate a role for every host that fits type t:\n t.hosts.each do |h|\n if(t.name==\"db\")\n @role = current_stage.roles.build({\"no_release\"=>\"0\", \"name\"=>t.name, \"primary\"=>\"1\", \"ssh_port\"=>\"\", \"no_symlink\"=>\"0\", \"host_id\"=>h.id})\n else\n @role = current_stage.roles.build({\"no_release\"=>\"0\", \"name\"=>t.name, \"primary\"=>\"0\", \"ssh_port\"=>\"\", \"no_symlink\"=>\"0\", \"host_id\"=>h.id})\n end\n if([email protected])\n RAILS_DEFAULT_LOGGER.error(\"could not save the given role #{t.name} on host #{h.name}\");\n end\n end\n \n end\n \n }\n end \n end\n end", "def web_servers; machines_by_role('web'); end", "def retry_read(original_error, session, server_selector, failed_server: nil, &block)\n begin\n server = select_server(cluster, server_selector, session, failed_server)\n rescue Error, Error::AuthError => e\n original_error.add_note(\"later retry failed: #{e.class}: #{e}\")\n raise original_error\n end\n \n log_retry(original_error, message: 'Read retry')\n \n begin\n yield server, true\n rescue *retryable_exceptions => e\n e.add_notes('modern retry', 'attempt 2')\n raise e\n rescue Error::OperationFailure, Error::PoolError => e\n e.add_note('modern retry')\n unless e.write_retryable?\n original_error.add_note(\"later retry failed: #{e.class}: #{e}\")\n raise original_error\n end\n e.add_note(\"attempt 2\")\n raise e\n rescue Error, Error::AuthError => e\n e.add_note('modern retry')\n original_error.add_note(\"later retry failed: #{e.class}: #{e}\")\n raise original_error\n end\n end", "def clistadmins(m, channel)\n channel = m.channel if channel.nil?\n if is_supadmin?(m.user) || is_admin?(m.user) || is_chanadmin?(channel, m.user)\n m.reply \"The current admins are #{$adminhash[channel]}.\", true\n else\n m.reply NOTADMIN, true\n end\n end", "def parse_messages(msg)\n case @mode\n when :initialize\n # ignore everything until negotiation done\n when :name\n publish(\"[clearline]\") if vtsupport?\n @login_name = msg.proper_name\n if options['guest_accounts'] && @login_name =~ /Guest/i\n self.name = \"Guest#{id}\"\n @character = new_char\n put_object(self)\n world.all_accounts << id\n # make the account non-swappable so we dont lose connection\n Engine.instance.db.makenoswap(id)\n @conn.set(:color, color)\n welcome\n @mode = :playing\n elsif @login_name.empty?\n sendmsg(append_echo(\"login> \"))\n @mode = :name\n else\n acctid = world.all_accounts.find {|a|\n @login_name == get_object(a).name\n }\n @account = get_object(acctid)\n sendmsg(append_echo(\"password> \"))\n @conn.set(:hide, true)\n @mode = :password\n end\n when :password\n @login_passwd = msg\n @conn.set(:hide, false)\n if @account.nil? # new account\n sendmsg(append_echo(\"Create new user?\\n'Y/y' to create, Hit enter to retry login> \"))\n @mode = :newacct\n else\n if @login_passwd.is_passwd?(@account.passwd) # good login\n # deregister all observers here and on connection\n unsubscribe_all\n @conn.unsubscribe_all\n # reregister all observers to @account\n @conn.subscribe(@account.id)\n # make the account non-swappable so we dont lose connection\n Engine.instance.db.makenoswap(@account.id)\n @conn.set(:color, @account.color)\n switch_acct(@account)\n # Check if this account already logged in\n reconnect = false\n if @account.subscriber_count > 0\n @account.publish(:reconnecting)\n @account.unsubscribe_all\n reconnect = true\n end\n @account.subscribe(@conn)\n if options['account_system']\n @account.sendmsg(append_echo(login_menu))\n @account.mode = :menu\n else\n @character = get_object(@account.characters.first)\n # make the character non-swappable so we dont lose references\n Engine.instance.db.makenoswap(@character.id)\n world.connected_characters << @character.id\n @character.account = @account\n @account.character = @character\n welcome(reconnect)\n @account.mode = :playing\n end\n else # bad login\n @checked -= 1\n sendmsg(append_echo(\"Sorry wrong password.\"))\n if @checked < 1\n disconnect\n else\n @mode = :name\n sendmsg(append_echo(\"login> \"))\n end\n end\n end\n when :newacct\n if msg =~ /^y/i\n self.name = @login_name\n self.passwd = @login_passwd.encrypt\n put_object(self)\n # make the account non-swappable so we dont lose connection\n Engine.instance.db.makenoswap(id)\n world.all_accounts << id\n @conn.set(:color, color)\n if options['account_system']\n sendmsg(append_echo(login_menu))\n @mode = :menu\n else\n @character = new_char\n welcome\n @mode = :playing\n end\n else\n @mode = :name\n sendmsg(append_echo(\"login> \"))\n end\n when :menu, :menucr, :menupl\n parse_menu(msg)\n when :playing\n @character.parse(msg)\n else\n log.error \"Account#parse_messages unknown :mode - #{@mode.inspect}\"\n end\n end", "def collaborators\n collab_roles = accepted_roles.for_name(\"collaborator\")\n User.find_by_sql(\"SELECT * FROM users INNER JOIN roles_users ON roles_users.user_id = users.id WHERE roles_users.role_id IN (12)\")\n end", "def authorised\n if self.roles.size > 0\n true\n end\n end", "def cwhois(m, nick)\n nick = User(nick)\n if is_supadmin?(m.user) || is_admin?(m.user) || is_chanadmin?(m.channel, m.user) || is_mod?(m.user)\n if userroles(m.channel,nick).empty?\n m.reply \"That's #{nick},\" + (!User(nick).authname.nil? ? \" authenticated as #{User(nick).authname},\" : \" unauthenticated,\") + \" with no roles.\"\n else\n m.reply \"That's #{nick}, \" + (!User(nick).authname.nil? ? \" authenticated as #{User(nick).authname},\" : \" unauthenticated,\") + \" with the following roles #{userroles(m.channel,nick)}.\", true\n end\n else\n m.reply NOTADMIN, true\n end\n end", "def find_channel(name)\n if name.include? '/'\n sid, cid = name.split('/')\n\n server = discord.servers[sid.to_i]\n server ||= (discord.servers.find { |_i, s| s.name.downcase.tr(' ', '~') == sid.downcase } || [])[1]\n return unless server\n\n chan = server.channels.find { |c| [c.id.to_s, c.name].include? cid }\n return unless chan\n\n DiscordChannelShim.new chan\n else\n chans = channel_list.select { |c| c.name == name }\n if chans.count == 1\n chans.first\n elsif chans.count > 1\n chans\n end\n end\n end" ]
[ "0.5720341", "0.56589437", "0.56453264", "0.56047165", "0.55786675", "0.5382283", "0.53383464", "0.52945673", "0.52794886", "0.5250711", "0.5222046", "0.52152044", "0.5201001", "0.5186215", "0.5174222", "0.5159841", "0.514997", "0.5128987", "0.5118287", "0.5100035", "0.5073613", "0.507339", "0.50688475", "0.50571626", "0.5055286", "0.5049658", "0.50430995", "0.5039046", "0.5036568", "0.5021885", "0.50154525", "0.5004783", "0.4979872", "0.49557212", "0.49516696", "0.4943874", "0.49325806", "0.4930507", "0.4910683", "0.49098632", "0.48926976", "0.48926976", "0.48911178", "0.48767415", "0.48759863", "0.48645568", "0.48615792", "0.48595005", "0.4851542", "0.48501515", "0.48410842", "0.48410428", "0.48408112", "0.4837393", "0.48343426", "0.48124743", "0.48096538", "0.48039827", "0.48027095", "0.47910458", "0.4791012", "0.47846693", "0.47792333", "0.47769648", "0.4767857", "0.47654885", "0.4762441", "0.47450888", "0.4741302", "0.47360188", "0.47263962", "0.47263962", "0.47210604", "0.47180507", "0.47116253", "0.47100288", "0.47076377", "0.47054377", "0.46995315", "0.4698782", "0.46983194", "0.46978015", "0.46825188", "0.4673303", "0.4672489", "0.46670908", "0.46514678", "0.46509424", "0.4640229", "0.46372128", "0.46353602", "0.46344784", "0.46340418", "0.4631608", "0.46248963", "0.46222284", "0.46200848", "0.46152613", "0.46107826", "0.46062666", "0.45983112" ]
0.0
-1
Compiles and caches marc, even if cached marc exists.
def compile_marc @marc = Sierra::Data::Helpers::SierraMARC.compile_marc(self) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def caching_compile(action, template)\n if Global.compile && action.template\n Cache.compiled[action.relaxed_hash] ||= compile(action, template)\n else\n compile(action, template)\n end\n end", "def compile\n @version, @uri = Ruby.find_ruby(@configuration)\n\n download_start_time = Time.now\n if @uri.include? '://'\n print \"-----> Downloading #{@version} ruby from #{@uri} ... \"\n else\n filename = File.basename(@uri)\n print \"-----> Retrieving #{@version} ruby (#{filename}) ... \"\n end\n LibertyBuildpack::Util::Cache::ApplicationCache.new.get(@uri) do |file| # TODO: Use global cache\n puts \"(#{(Time.now - download_start_time).duration})\"\n expand file\n end\n end", "def recompile\n unmemoize(:compile)\n compile\n end", "def compile(css, include_paths, settings)\n\tcss\nend", "def compile\n Milkrun.say \"Cleaning and assembling a new #{task} build\"\n `./gradlew clean assemble#{task}`\n @assembled = true\n Milkrun.say \"Package built to #{path}\"\n path\n end", "def compile\n File.chmod(0o755, start_script(root))\n augment_classpath_content\n end", "def recompile\n @compiled = nil\n compile\n end", "def compile_exec()\n compile\n exec\n end", "def compile_asset_from_cache(asset_path, &block)\n # TODO(philc): We should not check the file's md5 more than once when we're running in production mode.\n contents = File.read(asset_path)\n md5 = Digest::MD5.hexdigest(contents)\n cached_asset = $compiled_cache[asset_path]\n if md5 != cached_asset[:md5]\n cached_asset[:contents] = block_given? ? block.yield(asset_path) : File.read(contents)\n cached_asset[:md5] = md5\n end\n cached_asset[:contents]\n end", "def quick_marc\n @marc = Sierra::Data::Helpers::SierraMARC.compile_marc(\n self,\n ldr: @leader_field || Sierra::Data::LeaderField.\n by_record_id(record_id: id),\n cfs: @control_fields || Sierra::Data::ControlField.\n by_record_id(record_id: id),\n vfs: @varfields || Sierra::Data::Varfield.\n by_record_id(record_id: id)\n )\n end", "def compile\n Dir.chdir(build_path) do\n do_compile\n end\n end", "def set_compiled_method_cache; end", "def compile\n end", "def run_mxmlc\n if @target_id.nil?\n @target_id = @fcsh.mxmlc(get_compile_command)\n else\n @fcsh.compile(@target_id)\n end\n end", "def compile\n Timer.new(:title => \"YMDP\").time do\n clean_tmp_dir do\n process_domains\n end\n end\n end", "def set_produce_compilation_cache(enabled:)\n {\n method: \"Page.setProduceCompilationCache\",\n params: { enabled: enabled }.compact\n }\n end", "def wrap_compile(action, template = nil)\n template ||= reaction_or_file(action).to_s\n caching_compile(action, template)\n end", "def precompiled_assets(clear_cache = T.unsafe(nil)); end", "def precompiled_assets(clear_cache = T.unsafe(nil)); end", "def compile!\n new_version = generate_version\n new_abs_path = abs_path(new_version)\n return @compiled_path = current_file_path if @compile_files.empty?\n\n FileUtils.mkdir_p @min_dir unless File.exist?(@min_dir)\n js? ? compile_js!(new_abs_path) : compile_css!(new_abs_path)\n\n if not_changed?(new_abs_path, current_abs_path)\n puts \"file not changed, use current file (#{current_file_path})\"\n FileUtils.rm_rf new_abs_path\n @compiled_path = current_file_path\n else\n puts \"new file version (#{file_path(new_version)}) created\"\n @compiled_path = file_path(new_version)\n end\n end", "def compile\n JavaBuildpack::Util.download(@version, @uri, 'Auto Reconfiguration', jar_name(@version), @lib_directory)\n end", "def marc\n @marc ||= (\n Blacklight::Marc::Document.new fetch(self.class.marc_source_field), self.class.marc_format_type\n ) if key?(self.class.marc_source_field)\n end", "def cache\n store = Moneta.new :File, dir: 'moneta'\n Cachy.cache_store = store\n Cachy\n end", "def exec\r\n if valid?\r\n _result = configure\r\n _result &&= compile\r\n _result &&= install\r\n end\r\n end", "def add_compilation_cache(url:, data:)\n {\n method: \"Page.addCompilationCache\",\n params: { url: url, data: data }.compact\n }\n end", "def compile\n download_start_time = Time.now\n print \"-----> Downloading Spring Boot CLI #{@version} from #{@uri} \"\n\n JavaBuildpack::Util::ApplicationCache.new.get(@uri) do |file| # TODO: Use global cache #50175265\n puts \"(#{(Time.now - download_start_time).duration})\"\n expand(file, @configuration)\n end\n link_classpath_jars\n end", "def compile force:nil, production:nil\n @production = production || false\n method_name = 'compile_%s' % @source.to_s.split('.').last.downcase\n\n if respond_to?(method_name, true)\n (!force && cached) || ( process_erb; send(method_name))\n else\n @source.read\n end\n end", "def compile(target_path:)\n target_path = Pathname.new(target_path)\n mkdir_p target_path\n root = Pathname.new(\"/\")\n cache_resources = @site.cache_resources\n @stdout.puts \"Compiling #{@site.root_path.expand_path}\"\n begin\n @site.cache_resources = true\n @site.resources.each do |resource|\n derooted = Pathname.new(resource.request_path).relative_path_from(root)\n path = target_path.join(derooted)\n mkdir_p path.dirname\n @stdout.puts \" #{path}\"\n File.open(path.expand_path, \"w\"){ |f| f.write render(resource) }\n end\n @stdout.puts \"Successful compilation to #{target_path.expand_path}\"\n ensure\n @site.cache_resources = cache_resources\n end\n end", "def cache!\n self.clear_cache!\n self.public = true\n self.official = true\n save!\n css_to_cache = \"\"\n last_role = \"\"\n file_count = 1\n skin_dir = Skin.skins_dir + skin_dirname\n FileUtils.mkdir_p skin_dir\n (get_all_parents + [self]).each do |next_skin|\n if next_skin.get_sheet_role != last_role\n # save to file\n if css_to_cache.present?\n cache_filename = skin_dir + \"#{file_count}_#{last_role}.css\"\n file_count+=1\n File.open(cache_filename, 'w') {|f| f.write(css_to_cache)}\n css_to_cache = \"\"\n end\n last_role = next_skin.get_sheet_role\n end\n css_to_cache += next_skin.get_css\n end\n # TODO this repetition is all wrong but my brain is fried\n if css_to_cache.present?\n cache_filename = skin_dir + \"#{file_count}_#{last_role}.css\"\n File.open(cache_filename, 'w') {|f| f.write(css_to_cache)}\n css_to_cache = \"\"\n end\n self.cached = true\n save!\n end", "def compile!\n @directives.freeze unless @directives.frozen?\n\n @result ||= compile.freeze\n end", "def cached_computation(input)\n file = cache_file(input)\n return YAML.load_file(file) if File.exists?(file) and not @force_recompute\n result = @computation.call(input)\n File.open(file, \"w\") { |file| file.write(result.to_yaml) }\n return result\n end", "def safe_compile!(compiler)\n begin\n compiler.compile!\n rescue\n recompile_assets!(compiler)\n end\n end", "def compile(filename)\n check_cookie\n Native::magic_compile(@cookie, filename);\n end", "def minify_css(content)\n @css_cache[content] ||= begin\n root = SassC::Engine.new(content, @options[:sass_options])\n root.render.rstrip\n end\n end", "def compile_template(st_file, ct_path, ct_file_mtime, owner, sym)\n no_refresh = true\n\n # Lock template source to avoid race condition\n st_file.flock(File::LOCK_EX)\n\n # Compile, if template still needs compiling on lock release\n if !File.file?(ct_path) || File.mtime(ct_path) == ct_file_mtime\n no_refresh = false\n ct_dir = File.dirname(ct_path)\n FileUtils.mkdir_p(ct_dir) unless File.directory?(ct_dir)\n File.open(tmp_ct_path = ct_path + '~', 'w:UTF-8') do |ct_file|\n TemplateCompiler.compile_template(\n ct_file, st_file.read, owner, sym, true, @context.timers\n )\n end\n FileUtils.mv(tmp_ct_path, ct_path)\n end\n\n # Release lock\n st_file.flock(File::LOCK_UN)\n\n no_refresh\n end", "def compile(rule, rs, is_reset=false)\n evaluated = evaluate(rule,rs,is_reset)\n return Compiled.new(\n rule,\n evaluated,\n codes(evaluated)\n ).freeze\n end", "def compile(mod); end", "def fetch_cargo_toml\n rest_for_github_repo do |rest|\n log_info \"Fetching Cargo.toml from github.com/#{github_repo}\"\n Mash.new(\n TOML.parse(\n Base64.decode64(\n JSON.parse(rest[\"repos/#{github_repo}/contents/Cargo.toml\"].get.body)[\"content\"]\n ).force_encoding('UTF-8')\n )\n )\n end\n rescue RestClient::ResourceNotFound => e\n # TODO: use key cargo_toml_url and set it to false for projects\n # without Cargo.toml\n log_error \"Cargo.toml was not found for #{id_with_cat}\"\n return Mash.new\n end", "def cached_call(compiler)\n cache_check(compiler) << call_cached_method(compiler)\n end", "def cached_call(compiler)\n cache_check(compiler) << call_cached_method(compiler)\n end", "def compile\n self.class.compile(id)\n end", "def compile!\n puts \"Compiling website..\"\n puts %x[rm -rf output]\n puts %x[nanoc compile]\nend", "def compile!\n puts \"Compiling website..\"\n puts %x[rm -rf output]\n puts %x[nanoc compile]\nend", "def compile!\n puts \"Compiling website..\"\n puts %x[rm -rf output]\n puts %x[nanoc compile]\nend", "def compile\n puts \"Compilando archivos fuentes:\"\n @objs.each do |obj|\n command = \"#{@cc} -fpic -c -o #{obj} #{obj[0..-2] + \"c\"} #{@cflags}\"\n puts \"\\t\"+ command\n exit (0) if not((system(command)))\n end\n \n puts \"Convirtiendo a bibliotecas dinamicas\"\n system(\"mkdir lib\")\n @shared.each do |obj|\n library = obj.split('/').last\n compiled_libraries = `ls #{@lib_dir}`.split(\" \")\n \n libs = compiled_libraries.inject(\"\") {\n |string,lib|\n string += \"-l#{lib[3...-3]} \"\n }\n \n if (@so == \"linux\")\n command = \"#{@cc} -shared -o lib/lib#{library} #{obj[0..-3] + \"o\"}\" +\n \" -L#{@lib_dir} #{libs}\"\n elsif (@so == \"mac\")\n command = \"#{@cc} -shared -o lib/lib#{library} #{obj[0..-3] + \"o\"}\" +\n \" -L#{@lib_dir} #{libs}\" \n end\n puts \"\\t\" + command\n puts \"No compilo de forma correcta\" if not((system(command)))\n end\nend", "def cached?\n Dir.exist?(cached_repo_path)\n end", "def run(*args)\n if compile? && !@compiled\n rc = compile\n @compiled = true if rc == 0\n if(rc != 0)\n raise CompileException.new(rc, @compile_out, @compile_err)\n end\n end\n\n execute(args)\n end", "def create_cache_for(klassname, path)\n klass = class_cache[klassname]\n return nil unless klass\n\n method_files = klass[\"sources\"]\n cache = OpenStructHash.new\n\n method_files.each do |f|\n system_file = f.index(@sys_dir) == 0\n Dir[File.join(File.dirname(f), \"*\")].each do |yaml|\n next unless yaml =~ /yaml$/\n next if yaml =~ /cdesc-[^\\/]+yaml$/\n\n method = read_yaml yaml\n\n if system_file then\n method[\"source_path\"] = \"Ruby #{RDoc::RI::Paths::VERSION}\"\n else\n gem = Gem.path.any? do |path|\n pattern = File.join Regexp.escape(path), 'doc', '(.*?)', ''\n\n f =~ /^#{pattern}/\n end\n\n method[\"source_path\"] = if gem then\n \"gem #{$1}\"\n else\n f\n end\n end\n\n name = method[\"full_name\"]\n cache[name] = method\n end\n end\n\n write_cache cache, path\n end", "def compiled_path=(path); end", "def compiled?\n [email protected]?\n end", "def post_compile(css, settings)\n\tcss\nend", "def cached?; end", "def compile_c\n puts \"Compilando archivos fuentes:\"\n objs = @objs + [@main]\n objs.each do |obj|\n command = \"#{@cc} #{@debug} -c -o #{obj} #{obj[0..-2] + \"c\"} #{@cflags}\"\n puts \"\\t\"+ command\n exit (0) if not((system(command)))\n end\n command = \"#{@cc} #{@debug} -o #{@main[0..-3]} #{objs.join(\" \")}\" +\n \" #{@cflags}\"\n puts \"\\t\"+ command\n puts \"No compilo de forma correcta\" if not(system(command))\nend", "def compile\n if @app_dir.nil?\n raise 'app directory must be provided'\n elsif @version.nil? || @uri.nil?\n raise \"Version #{@version} or uri #{@uri} is not available, detect needs to be invoked\"\n end\n\n # create a dynatrace home dir in the droplet\n dt_home = File.join(@app_dir, DT_HOME_DIR)\n FileUtils.mkdir_p(dt_home)\n\n @logger.debug(\"Dynatrace home directory: #{dt_home}\")\n\n download_and_install_agent(dt_home)\n end", "def make_compile_rule(src)\n sha = Digest::SHA1.hexdigest(src)\n fn = File.basename(src, '.c')\n dest = \"build/#{sha}_#{fn}.o\"\n SOURCE_LOOKUP[src] = dest\n\n CompileTask.define_task(dest => [src]) do |t|\n sh \"#{TOOLCHAIN}gcc #{t.cflags.join(' ')} -c #{t.prerequisites.first} -o #{t.name}\"\n end\nend", "def cache_fleximage( content, path )\n return unless perform_caching && APP_CONFIG['perform_fleximage_caching']\n benchmark \"Cached page: #{page_cache_file(path)}\" do\n FileUtils.makedirs(File.dirname(page_cache_path(path)))\n File.open(page_cache_path(path), \"wb+\") { |f| f.write(content) }\n end\n end", "def make_cache\n if !@thread_safe \n @@c = {}\n elsif defined?(ThreadSafe)\n @@c = ThreadSafe::Hash.new\n else\n raise 'ThreadSafe is required to use the Memory cache.'\n end \n end", "def _inter source\n c = compile source\n cifrom c\nend", "def compile!\n return if compiled?\n @regexps = @routes.map.with_index do |route, index|\n route.index = index\n /(?<_#{index}>#{route.matcher.to_regexp})/\n end\n @regexps = recursive_compile(@regexps)\n @compiled = true\n end", "def load_cache\n begin\n file = File.join(\"inline\", File.basename(so_name))\n if require file then\n dir = Inline.directory\n warn \"WAR\\NING: #{dir} exists but is not being used\" if test ?d, dir and $VERBOSE\n return true\n end\n rescue LoadError\n end\n return false\n end", "def compiled_statement\n @compiler_mutex.synchronize do\n condition_keys, if_statements = Set.new, \"\"\n\n routes.each_with_index do |route, i|\n route.freeze\n route.conditions.keys.each { |key| condition_keys << key }\n if_statements << route.compiled_statement(i == 0)\n end\n\n statement = \"def match(request)\\n\"\n statement << condition_keys.inject(\"\") do |cached, key|\n cached << \" cached_#{key} = request.#{key}.to_s\\n\"\n end\n statement << if_statements\n statement << \" else\\n\"\n statement << \" [nil, {}]\\n\"\n statement << \" end\\n\"\n statement << \"end\"\n end\n end", "def compiled_statement\n @compiler_mutex.synchronize do\n condition_keys, if_statements = Set.new, \"\"\n \n routes.each_with_index do |route, i|\n route.freeze\n route.conditions.keys.each { |key| condition_keys << key }\n if_statements << route.compiled_statement(i == 0)\n end\n \n statement = \"def match(request)\\n\"\n statement << condition_keys.inject(\"\") do |cached, key|\n cached << \" cached_#{key} = request.#{key}.to_s\\n\"\n end\n statement << if_statements\n statement << \" else\\n\"\n statement << \" [nil, {}]\\n\"\n statement << \" end\\n\"\n statement << \"end\"\n end\n end", "def compiler?(verify = false, writeable_directory = false)\n if (session.methods.include? :cache) && session.cache.exists?(\"compiler?\")\n return session.cache.read(\"compiler?\")\n end\n writeable_directory = '/var/tmp/' unless writeable_directory == true\n compilers = ['gcc', 'cc', 'tcc', 'pcc']\n compilers.each do |tool|\n next unless installed?(tool)\n if verify == true\n\n tmp_file = writeable_directory.to_s + ::Rex::Text.rand_text_alpha(12)\n tmp_file_c = tmp_file + '.c'\n match_string = ::Rex::Text.rand_text_alpha(32)\n test_c = \"#include <stdio.h>\\nint main(void){printf(\\\"#{match_string} %c\\\",0x0a);return 0;}\"\n test_c.each_line do |line|\n cmd_exec(\"echo '#{line}'>>#{tmp_file_c}\")\n end\n compile = \"#{tool} #{tmp_file_c} -o #{tmp_file}\"\n cmd_exec(compile)\n out = cmd_exec(tmp_file)\n rm tmp_file\n rm tmp_file_c\n if out.match(match_string)\n session.cache.add(\"compiler?\", tool) if session.methods.include? :cache\n return tool\n end\n else\n session.cache.add(\"compiler?\", tool) if session.methods.include? :cache\n return tool\n end\n end\n session.cache.add(\"compiler?\", false) if session.methods.include? :cache\n false\n end", "def compile_assets\n boot_rails\n run_compiler\n \n !failed?\n end", "def compile_assets\n boot_rails\n run_compiler\n \n !failed?\n end", "def compileif\n\n end", "def arc_files(target_name)\n source_files(target_name) do |file|\n has_compiler_flag(file, '-fobjc-arc')\n end\n end", "def fetch_local(new_dest, fetch_if_missing = true)\n if !File.exists? @repo.cache_path\n if fetch_if_missing\n fetch\n else\n raise \"Source cache #{@repo.cache_path} not readable.\"\n end\n end\n FileUtils.cp_r @repo.cache_path, new_dest\n end", "def sync_to_cache_for_archiving\n result = sync_to_cache(false)\n self.erase_cache_symlinks rescue nil\n result\n end", "def compile(str)\n @compiled[str]\n end", "def compiledo\n\n end", "def build_app_caches(app_name, instance_name)\n Dir.chdir RailsPwnerer::Config[app_name, instance_name][:app_path] do\n if File.exist?('Gemfile')\n Kernel.system 'bundle exec rake assets:precompile RAILS_ENV=production'\n else\n Kernel.system 'rake assets:precompile RAILS_ENV=production'\n end\n end\n end", "def copy_over_cache_files\n FileUtils.cp_r \"#{@cache}/.\", @path\n end", "def compile(name)\n Rule::Compile.build(file(name))\n end", "def asset_modified(path)\n @task.say 'Recompiling assets'\n @builder.compile_assets\n end", "def Cape(&block)\n Cape.module_eval do\n @outer_self = block.binding.eval('self', __FILE__, __LINE__)\n begin\n if 0 < block.arity\n block.call self\n else\n module_eval(&block)\n end\n ensure\n rake.expire_cache!\n end\n end\n Cape\nend", "def compile!\n raise NotImplementedError\n end", "def download_or_update_local_cache\n # we have nothing to download if the source is a local directory\n return if source_is_local?\n # we need git for this purpose\n raise RequiredLibraryMissingError, \"git\" if `which git`.empty?\n\n # create the cache, and download or update as required\n FileUtils.mkdir_p @cache\n Dir.chdir(@cache) do\n if has_cache?\n show_info \"Repository exists in local cache..\"\n show_info \"Updating local cache..\"\n `git pull -q`\n else\n show_info \"Downloading repository to local cache..\"\n `git clone -q #{@source} .`\n end\n end\n end", "def compile(src = @source)\n @compiled_source || (@compiled_source = super(src))\n end", "def initialize(directory, &block)\n @force_recompute = false\n @computation = block\n @directory = find_directory(Dir.pwd, directory)\n if @directory\n class <<self; alias [] :cached_computation; end\n else\n class <<self; alias [] :uncached_computation; end\n $stderr.puts(\"#{$0}: Could not find cache directory: #{directory}.\")\n end\n end", "def getContentCache(theContent)\n\n\ttheChecksum = Digest::SHA256.hexdigest(theContent).insert(2, '/');\n\ttheCache = \"#{PATH_FORMAT_CACHE}/#{theChecksum}\";\n\t\n\treturn theCache;\n\nend", "def compile\n compile_libraries\n compile_ohai_plugins\n compile_compliance\n compile_attributes\n compile_lwrps\n compile_resource_definitions\n compile_recipes\n end", "def warm_cache(target_files); end", "def compile\n if @app_dir.nil?\n raise 'app directory must be provided'\n elsif @version.nil? || @uri.nil?\n raise \"Version #{@version} or uri #{@uri} is not available, detect needs to be invoked\"\n end\n\n # create a dynatrace home dir in the droplet\n dynatrace_home = File.join(@app_dir, DYNATRACE_HOME_DIR)\n FileUtils.mkdir_p(dynatrace_home)\n @logger.debug(\"Dynatrace OneAgent home directory: #{dynatrace_home}\")\n\n download_and_install_agent(dynatrace_home)\n\n # export dynatrace specific environment variables\n export_dynatrace_app_environment_variables\n export_dynatrace_connection_environment_variables\n end", "def compile_file(path)\n path = \"#{path}.rb\" unless path =~ /\\.rb\\Z/\n res = RubyVM::InstructionSequence.compile_file(path)\n data = Marshal.dump(res.to_a)\n rbc_path = path + \"c\"\n File.open(rbc_path, \"w+\") {|f| f.write data }\n rescue NotImplementedError\n # Ruby bug with terminated objects\n false\n end", "def recompile?\n true\n end", "def recompile?\n true\n end", "def assets_to_compile \n return @assets_to_compile if @assets_to_compile \n files = Dir.glob(prefix + \"**/*\").select {|f| File.file?(f)}\n files.collect! { |f| f.gsub(/^#{prefix}\\//, \"\") }\n end", "def compile_assets\n self.class.boot_rails\n return false unless self.class.rails_booted\n begin\n clean\n precompile\n true\n rescue => e\n puts \"An error occurred compiling assets: #{e}\"\n false\n ensure\n ::Rails.application.assets.instance_eval { expire_index! }\n end\n end", "def create_cache_file(controller=:_all,action=:_all)\n files = paths_for(controller,action).uniq\n path_name = cache_path_name(controller,action)\n \n # if we already have the file, we can just skip this step\n if File.exists?(path_name)\n puts \"Skipped creating/updating #{controller}::#{action} (Nothing changed)\" if RAILS_ENV == \"development\"\n return path_name\n end\n \n cache_content = \"\"\n # otherwise, we create the file\n files.each do |f|\n if File.exists?(f)\n cache_content += File.new(f).read\n else\n # TODO: add some debug info for when an included file doesn't exist\n end\n end\n # write out the content\n File.open(path_name,\"w\") do |f|\n f.write(cache_content)\n end\n \n # if we have a minifier, use it\n @minifier.minify!(path_name) if @minifier\n \n puts \"\\nCreated #{path_name} \"\n puts \"with \\n\\t #{files.join(\"\\n\\t\")}\\n\" if RAILS_ENV == \"development\"\n path_name\n end", "def compile\n system \"rm -rf #{new_relic_home}\"\n system \"mkdir -p #{new_relic_home}\"\n system \"mkdir -p #{File.join new_relic_home, 'logs'}\"\n\n JavaBuildpack::Util.download(@version, @uri, 'New Relic Agent', jar_name(@version), new_relic_home)\n copy_resources new_relic_home\n end", "def compile\n detect if @auto_reconfiguration_uri.nil?\n LibertyBuildpack::Util.download(@auto_reconfiguration_version, @auto_reconfiguration_uri, 'Auto Reconfiguration', jar_name(@auto_reconfiguration_version), @lib_directory)\n FrameworkUtils.link_libs(SpringAutoReconfiguration.spring_apps(@app_dir), @lib_directory)\n SpringAutoReconfiguration.spring_apps(@app_dir).each { |app| modify_web_xml(app) }\n end", "def compile!\n return if compiled?\n @routes.each_with_index do |route, index|\n route.index = index\n route.regexp = /(?<_#{index}>#{route.matcher.to_regexp})/\n end\n @compiled = true\n end", "def compile\n download_jonas\n download_deployme\n remove_jcl_over_slf\n puts 'Compile completed, release cmd to be run:'\n puts release\n end", "def css\n @css ||= assemble_css\n end", "def compile\n # setup configurations\n configurations\n\n # Download and untar apache2\n apache2 = download_untar @configuration[\"download_url\"]\n\n # download and untar zlib\n zlib = download_untar @configuration[\"zlib_download_url\"]\n\n @logger.debug\"ZlIB Dir Content: #{Dir[File.join(zlib,\"*\")]}\"\n # configure and compile zlib\n zlib_configure_file = File.join(zlib,\"configure\")\n zlib_install_dir = File.join(@application.cache_dir,\"zlib\")\n\n shell_script = File.join(@application.buildpack_dir,\"resources/shell/compile_zlib.sh\");\n fail \"Shell Script failed\" unless 0 == system(\"./#{shell_script}\")\n # @logger.debug(\"#{zlib_configure_file} --prefix=#{zlib_install_dir}\")\n # result = system(\"#{zlib_configure_file} --prefix=#{zlib_install_dir}\")\n #\n # puts result\n # @logger.debug(\"Configure ZLIB result: #{result[0..-100]}\")\n #\n # # Make zlib\n # @logger.debug(\"make -C #{zlib}\")\n # result = `make -C #{zlib}`\n # puts result\n # @logger.debug(\"Make ZLIB result: #{result[0..-100]}\")\n # @logger.debug(\"make install -C #{zlib}\")\n # result = `make install -C #{zlib}`\n # @logger.debug(\"Make Install Result: #{result[0..-100]}\")\n\n @logger.debug \"Zlib Install Location: #{Dir[File.join(zlib_install_dir,'*')]}\"\n\n end", "def compile_file(file, compiled)\n if CodeLoader.save_compiled?\n Compiler.compile file, compiled\n else\n Compiler.compile_file file\n end\n end", "def cached?\n @rules = cached_rules if cached_rules? && caching_on?\n end", "def cache_file\n File.join(Rscons.application.build_dir, \".rsconscache\")\n end", "def compile\n raise NotImplementedError\n end" ]
[ "0.5613974", "0.5589122", "0.5463801", "0.5337648", "0.5285645", "0.5278577", "0.5270932", "0.52607185", "0.52275854", "0.5197679", "0.51414925", "0.5132814", "0.51307714", "0.5064622", "0.5005117", "0.4975766", "0.497216", "0.49615714", "0.49615714", "0.49342835", "0.4930692", "0.4916335", "0.48960495", "0.4890491", "0.48865515", "0.4870194", "0.48569137", "0.48468187", "0.48419562", "0.48415455", "0.4811472", "0.48008013", "0.47955003", "0.47935763", "0.47905302", "0.47842523", "0.47745085", "0.47392428", "0.4732411", "0.4732411", "0.4726384", "0.46984655", "0.46984655", "0.46984655", "0.46982467", "0.4694617", "0.4694185", "0.46910748", "0.46714067", "0.46688524", "0.4657968", "0.46571556", "0.4656505", "0.46502998", "0.46410796", "0.46399346", "0.46364206", "0.46156108", "0.46127993", "0.46053538", "0.46052578", "0.4602684", "0.45956707", "0.45919913", "0.45919913", "0.45897695", "0.45875815", "0.45820287", "0.45808998", "0.45754957", "0.45748731", "0.4571191", "0.4569776", "0.45686886", "0.45631567", "0.45522076", "0.4537743", "0.45366514", "0.45262206", "0.45067942", "0.44992986", "0.44989228", "0.44978404", "0.4497437", "0.44963786", "0.4493378", "0.4493378", "0.44913566", "0.44873488", "0.44865873", "0.44839096", "0.44788036", "0.4474427", "0.4469717", "0.44656137", "0.44648015", "0.44440708", "0.4437187", "0.4434857", "0.44274628" ]
0.603821
0
Compiles and caches marc, abnormally. This uses prepared statements which may be quicker than marc / compile_marc's use of associations for leader/control/varfields. However this method does not cache the leader/control/varfield values, it retrieves, so is likely slower if you also will need to retrieve those associations/fields for other reasons.
def quick_marc @marc = Sierra::Data::Helpers::SierraMARC.compile_marc( self, ldr: @leader_field || Sierra::Data::LeaderField. by_record_id(record_id: id), cfs: @control_fields || Sierra::Data::ControlField. by_record_id(record_id: id), vfs: @varfields || Sierra::Data::Varfield. by_record_id(record_id: id) ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def compile_marc\n @marc = Sierra::Data::Helpers::SierraMARC.compile_marc(self)\n end", "def _compile!\n code = @collection.attributes.map do |_,(klass,mapped)|\n %{\n def deserialize_#{ mapped }(value)\n Lotus::Utils::Kernel.#{klass}(value)\n end\n }\n end.join(\"\\n\")\n\n instance_eval %{\n def to_record(entity)\n if entity.id\n Hash[*[#{ @collection.attributes.map{|name,(_,mapped)| \":#{mapped},entity.#{name}\"}.join(',') }]]\n else\n Hash[*[#{ @collection.attributes.reject{|name,_| name == @collection.identity }.map{|name,(_,mapped)| \":#{mapped},entity.#{name}\"}.join(',') }]]\n end\n end\n\n def from_record(record)\n #{ @collection.entity }.new(\n Hash[*[#{ @collection.attributes.map{|name,(klass,mapped)| \":#{name},Lotus::Utils::Kernel.#{klass}(record[:#{mapped}])\"}.join(',') }]]\n )\n end\n\n #{ code }\n }\n end", "def marc\n @marc ||= (\n Blacklight::Marc::Document.new fetch(self.class.marc_source_field), self.class.marc_format_type\n ) if key?(self.class.marc_source_field)\n end", "def to_mrc(opts={})\n defaults = {\n :record => MARC::Record.new\n }\n opts = defaults.merge(opts)\n set_opts_attribs(opts)\n @record.leader = @leader\n @record.leader = @leader\n @record.append(MARC::ControlField.new('008',@control_008)) # TODO Make this iterative for all control fields.\n @marc_lines.each do |line|\n @record.append(MARC::DataField.new(\n line.tag,\n line.ind_1,\n line.ind_2,\n *(line.subfield_codes.each_with_index.collect {|sfc,i| [sfc.gsub('|',''),line.values[i]]})\n ))\n end\n\n @record\n end", "def compiled_statement\n @compiler_mutex.synchronize do\n condition_keys, if_statements = Set.new, \"\"\n\n routes.each_with_index do |route, i|\n route.freeze\n route.conditions.keys.each { |key| condition_keys << key }\n if_statements << route.compiled_statement(i == 0)\n end\n\n statement = \"def match(request)\\n\"\n statement << condition_keys.inject(\"\") do |cached, key|\n cached << \" cached_#{key} = request.#{key}.to_s\\n\"\n end\n statement << if_statements\n statement << \" else\\n\"\n statement << \" [nil, {}]\\n\"\n statement << \" end\\n\"\n statement << \"end\"\n end\n end", "def compiled_statement\n @compiler_mutex.synchronize do\n condition_keys, if_statements = Set.new, \"\"\n \n routes.each_with_index do |route, i|\n route.freeze\n route.conditions.keys.each { |key| condition_keys << key }\n if_statements << route.compiled_statement(i == 0)\n end\n \n statement = \"def match(request)\\n\"\n statement << condition_keys.inject(\"\") do |cached, key|\n cached << \" cached_#{key} = request.#{key}.to_s\\n\"\n end\n statement << if_statements\n statement << \" else\\n\"\n statement << \" [nil, {}]\\n\"\n statement << \" end\\n\"\n statement << \"end\"\n end\n end", "def compile_exec()\n compile\n exec\n end", "def load\n # logger.debug(\"CMB: load for #{self.to_param}\")\n # Pull the fields we need from the cached record into an options_hash\n queue = @cached.queue\n options_hash = {\n :queue_name => queue.queue_name,\n :h_or_s => queue.h_or_s,\n :center => queue.center.center,\n :ppg => @cached.ppg\n }\n # logger.debug(\"CMB: options_hash = #{options_hash.inspect}\")\n\n # :group_request is a special case\n group_request = Combined::Call.retain_fields.map { |field| field.to_sym }\n # logger.debug(\"CMB: group_request = #{group_request.inspect}\")\n options_hash[:group_request] = [ group_request ]\n\n # Create retain object\n call = Retain::Call.new(retain_user_connection_parameters, options_hash)\n\n # Touch to force a fetch from Retain\n begin\n call.send(group_request[0])\n rescue Retain::SdiReaderError => e\n if e.sr == 65 && e.ex == 11\n # This may cause another exception but I don't think it\n # will. If it does, the to_param can be manually coded.\n raise CallNotFound.new(to_param)\n else\n raise e\n end\n end\n\n # Make or find Cached PMR\n @cached.pmr = Pmr.find_existing_pmr(call).unwrap_to_cached\n\n # Make or find customer\n cust_options = {\n :country => call.country,\n :customer_number => call.customer_number\n }\n @cached.pmr.customer = Cached::Customer.find_or_new(cust_options)\n\n # logger.debug(\"CMB: TMP customer_time_zone_adj = #{call.customer_time_zone_adj}\")\n # logger.debug(\"CMB: TMP time_zone_code = #{call.time_zone_code}\")\n\n # Update call record\n #\n # This comment applies to most of the combined models.\n # We gather the options that go into the database record from\n # the call and assign them to the database record. We then ask\n # if anything has changed. If something has changed, when we\n # mark last_fetched with the current time. We then fix the\n # dirty flag as false, force the updated_at to be now, and then\n # do a save.\n # The net result will be that the updated_at timestamp will be\n # the time that we last checked retain. The last_fetched will\n # be the time when Retain last changed.\n #\n options = self.class.cached_class.options_from_retain(call)\n @cached.attributes = options\n if @cached.changed?\n @cached.last_fetched = Time.now\n end\n @cached.dirty = false\n @cached.updated_at = Time.now\n\n @cached.owner_css,\n @cached.owner_message,\n @cached.owner_editable = compute_owner_private\n\n @cached.resolver_css,\n @cached.resolver_message,\n @cached.resolver_editable = compute_resolver_private\n\n @cached.next_queue_css,\n @cached.next_queue_message,\n @cached.next_queue_editable = compute_next_queue_private\n @cached.save\n end", "def recompile\n unmemoize(:compile)\n compile\n end", "def compile\n @re = build_re(@__opts__)\n\n # Define dynamic patterns\n tlds = @__tlds__.dup\n\n onCompile\n\n tlds.push(TLDS_2CH_SRC_RE) if (!@__tlds_replaced__)\n tlds.push(@re[:src_xn])\n\n @re[:src_tlds] = tlds.join('|')\n @re[:email_fuzzy] = Regexp.new(@re[:tpl_email_fuzzy].gsub('%TLDS%', @re[:src_tlds]), true)\n @re[:link_fuzzy] = Regexp.new(@re[:tpl_link_fuzzy].gsub('%TLDS%', @re[:src_tlds]), true)\n @re[:link_no_ip_fuzzy] = Regexp.new(@re[:tpl_link_no_ip_fuzzy].gsub('%TLDS%', @re[:src_tlds]), true)\n @re[:host_fuzzy_test] = Regexp.new(@re[:tpl_host_fuzzy_test].gsub('%TLDS%', @re[:src_tlds]), true)\n\n #\n # Compile each schema\n #\n\n aliases = []\n\n @__compiled__ = {} # Reset compiled data\n\n schemaError = lambda do |name, val|\n raise Error, ('(LinkifyIt) Invalid schema \"' + name + '\": ' + val)\n end\n\n @__schemas__.each do |name, val|\n\n # skip disabled methods\n next if (val == nil)\n\n compiled = { validate: nil, link: nil }\n\n @__compiled__[name] = compiled\n\n if (val.is_a? Hash)\n if (val[:validate].is_a? Regexp)\n compiled[:validate] = createValidator(val[:validate])\n elsif (val[:validate].is_a? Proc)\n compiled[:validate] = val[:validate]\n else\n schemaError(name, val)\n end\n\n if (val[:normalize].is_a? Proc)\n compiled[:normalize] = val[:normalize]\n elsif (!val[:normalize])\n compiled[:normalize] = createNormalizer()\n else\n schemaError(name, val)\n end\n next\n end\n\n if (val.is_a? String)\n aliases.push(name)\n next\n end\n\n schemaError(name, val)\n end\n\n #\n # Compile postponed aliases\n #\n\n aliases.each do |an_alias|\n if (!@__compiled__[@__schemas__[an_alias]])\n # Silently fail on missed schemas to avoid errons on disable.\n # schemaError(an_alias, self.__schemas__[an_alias]);\n else\n @__compiled__[an_alias][:validate] = @__compiled__[@__schemas__[an_alias]][:validate]\n @__compiled__[an_alias][:normalize] = @__compiled__[@__schemas__[an_alias]][:normalize]\n end\n end\n\n #\n # Fake record for guessed links\n #\n @__compiled__[''] = { validate: nil, normalize: createNormalizer }\n\n #\n # Build schema condition, and filter disabled & fake schemas\n #\n slist = @__compiled__.select {|name, val| name.length > 0 && !val.nil? }.keys.map {|str| escapeRE(str)}.join('|')\n\n # (?!_) cause 1.5x slowdown\n @re[:schema_test] = Regexp.new('(^|(?!_)(?:[><\\uff5c]|' + @re[:src_XPCc] + '))(' + slist + ')', 'i')\n @re[:schema_search] = Regexp.new('(^|(?!_)(?:[><\\uff5c]|' + @re[:src_XPCc] + '))(' + slist + ')', 'i')\n @re[:schema_at_start] = Regexp.new('^' + @re[:schema_search].source, 'i')\n\n @re[:pretest] = Regexp.new(\n '(' + @re[:schema_test].source + ')|(' + @re[:host_fuzzy_test].source + ')|@',\n 'i'\n )\n\n #\n # Cleanup\n #\n\n resetScanCache\n end", "def compile_query\n #puts \"DATASET COMPILE self #{self}\"\n #puts \"DATASET COMPILE queries #{queries}\"\n \n # Old way: works but doesn't handle fmp compound queries.\n #query.each_with_object([{},{}]){|x,o| o[0].merge!(x[0] || {}); o[1].merge!(x[1] || {})}\n \n # New way: handles compound queries. Reqires ginjo-rfm 3.0.11.\n return unless queries # This should help introspecting dataset that results from record deletion. TODO: test this.\n queries.inject {|new_query,scope| apply_scope(new_query, scope)} ##puts \"SCOPE INJECTION scope:#{scope} new_query:#{new_query}\"; \n end", "def compile!\n self.normalized_facets = { all: {} }.with_indifferent_access\n\n #aggregate all compiled facets into the all collection\n normalized_facets[:all][:fields] = facets.inject({}) do |result, (facet_alias, facet)|\n result.deep_merge! dealias_facet!(facet, facet_alias)[:fields]\n end\n\n #filter all compiled facets into a corresponding attributes collection\n normalized_facets.each do |facet_alias, normalized_facet|\n normalized_facet[:attributes] = normalized_facet[:fields].reject { |facet, nested_facets|\n is_association?(facet)\n }\n end\n\n self.compiled = true\n self\n end", "def compile\n '(%s = %s; %s %s []; %s; %s.join)' % [\n RESULT_VARIABLE_BACKDOOR,\n @result_variable.inspect,\n\n @result_variable,\n @continue_result ? '||=' : '=',\n\n @source_lines.map do |source_line|\n compiled_line = []\n combine_prev = false\n\n source_line.each do |stmt|\n is_code = stmt.type == :code\n is_expr = stmt.type == :expr\n\n if is_code\n compiled_line << stmt.value\n combine_prev = false\n\n else\n code =\n if is_expr\n \" << (#{stmt.value.strip})\"\n else\n \" << #{stmt.value.inspect}\"\n end\n\n if combine_prev\n compiled_line.last << code\n else\n compiled_line << @result_variable.to_s + code\n end\n\n combine_prev = true\n end\n end\n\n compiled_line.join('; ')\n\n end.join(\"\\n\"),\n\n @result_variable,\n ]\n end", "def caching_compile(action, template)\n if Global.compile && action.template\n Cache.compiled[action.relaxed_hash] ||= compile(action, template)\n else\n compile(action, template)\n end\n end", "def compile!\n @directives.freeze unless @directives.frozen?\n\n @result ||= compile.freeze\n end", "def recompile\n @compiled = nil\n compile\n end", "def compile\n self.class.compile(id)\n end", "def compile(rule, rs, is_reset=false)\n evaluated = evaluate(rule,rs,is_reset)\n return Compiled.new(\n rule,\n evaluated,\n codes(evaluated)\n ).freeze\n end", "def build_record\n record = MARC::Record.new\n data_field = nil\n control_field = nil\n subfield = nil\n text = \"\"\n attrs = nil\n if Module.constants.index(\"Nokogiri\") && @parser.is_a?(Nokogiri::XML::Reader)\n datafield = nil\n cursor = nil\n open_elements = []\n @parser.each do |node|\n if node.value? && cursor\n if cursor.is_a?(Symbol) && (cursor == :leader)\n record.leader = node.value\n else\n cursor.value = node.value\n end\n cursor = nil\n end\n next unless node.namespace_uri == @ns\n if open_elements.index(node.local_name.downcase)\n open_elements.delete(node.local_name.downcase)\n next\n else\n open_elements << node.local_name.downcase\n end\n case node.local_name.downcase\n when \"leader\"\n cursor = :leader\n when \"controlfield\"\n record << datafield if datafield\n datafield = nil\n control_field = MARC::ControlField.new(node.attribute(\"tag\"))\n record << control_field\n cursor = control_field\n when \"datafield\"\n record << datafield if datafield\n datafield = nil\n data_field = MARC::DataField.new(node.attribute(\"tag\"), node.attribute(IND1), node.attribute(IND2))\n datafield = data_field\n when \"subfield\"\n raise \"No datafield to add to\" unless datafield\n subfield = MARC::Subfield.new(node.attribute(CODE))\n datafield.append(subfield)\n cursor = subfield\n when \"record\"\n record << datafield if datafield\n return record\n end\n end\n\n else\n while @parser.has_next?\n event = @parser.pull\n\n if event.text?\n text += REXML::Text.unnormalize(event[0])\n next\n end\n\n if event.start_element?\n text = \"\"\n attrs = event[1]\n case strip_ns(event[0])\n when \"controlfield\"\n text = \"\"\n control_field = MARC::ControlField.new(attrs[TAG])\n when \"datafield\"\n text = \"\"\n data_field = MARC::DataField.new(attrs[TAG], attrs[IND1],\n attrs[IND2])\n when \"subfield\"\n text = \"\"\n subfield = MARC::Subfield.new(attrs[CODE])\n end\n end\n\n if event.end_element?\n case strip_ns(event[0])\n when \"leader\"\n record.leader = text\n when \"record\"\n return record\n when \"controlfield\"\n control_field.value = text\n record.append(control_field)\n when \"datafield\"\n record.append(data_field)\n when \"subfield\"\n subfield.value = text\n data_field.append(subfield)\n end\n end\n end\n end\n end", "def association_prepared_statement(opts, assoc_bv)\n return unless model.cache_associations\n ps = opts.send(:cached_fetch, :prepared_statement) do\n unless opts[:instance_specific]\n ds, bv = _associated_dataset(opts, {}).unbind\n\n f = ds.opts[:from]\n if f && f.length == 1\n s = ds.opts[:select]\n if ds.opts[:join]\n if opts.eager_loading_use_associated_key? && s && s.length == 1 && s.first.is_a?(SQL::ColumnAll)\n table = s.first.table\n ds = ds.select(*opts.associated_class.columns.map{|c| Sequel.identifier(c).qualify(table)})\n end\n elsif !s || s.empty?\n ds = ds.select(*opts.associated_class.columns.map{|c| Sequel.identifier(c)})\n end\n end \n \n if bv.length != assoc_bv.length\n h = {}\n bv.each do |k,v|\n h[k] = v unless assoc_bv.has_key?(k)\n end\n ds = ds.bind(h)\n end\n ds.clone(:log_sql=>true).prepare(opts.returns_array? ? :select : :first, :\"smpsap_#{NEXT.call}\")\n end\n end\n\n if ps && @server && _associated_objects_use_same_server?\n ps = ps.server(@server)\n end\n\n ps\n end", "def commence\n @vm, = API.compile( @db.handle, @sql )\n\n @current_row = API.step( @vm )\n\n @columns = @current_row[ :columns ]\n @types = @current_row[ :types ]\n\n check_eof( @current_row )\n end", "def compile_to_c\n statements.collect { |s| s.compile_to_c }.join(\"\\n\")\n end", "def constructed_records(database_record, lookups, attributes)\n associated = cache.find(target_class(database_record), lookups)\n\n # If the association record already exists, we don't need to build out\n # associations any further.\n if associated\n database_record.association(name).send(construction_method, associated)\n return []\n end\n\n associated = database_record.association(name).build(lookups)\n cache << associated\n\n associated.assign_attributes(attributes)\n\n nested = yield associated if block_given?\n\n [associated, *nested]\n end", "def compile\n @lock.synchronize do\n @compiled_targets = {}\n \n ordered = @targets.sort do |a,b|\n # The states with the longest lifetimes must be excluded from\n # all the younger checks. Nil = +inf.\n if b[1].nil?\n 1\n elsif a[1].nil?\n -1\n else\n b[1] <=> a[1]\n end\n end\n \n excluded = ordered.inject(nil) do |exclude, pair|\n # Build up a set of all queries which should last *longer* than us.\n query, age = pair\n if exclude\n if age\n @compiled_targets[\"(#{query}) and not (#{exclude})\"] = age\n end\n \"(#{query}) or (#{exclude})\"\n else\n if age\n @compiled_targets[query] = age\n end\n query\n end\n end\n\n # Add default\n if @default\n q = if excluded\n \"not (#{excluded})\"\n else\n \"true\"\n end\n @compiled_targets[q] = @default\n end\n end\n end", "def compile!\n return if compiled?\n @regexps = @routes.map.with_index do |route, index|\n route.index = index\n /(?<_#{index}>#{route.matcher.to_regexp})/\n end\n @regexps = recursive_compile(@regexps)\n @compiled = true\n end", "def compiled_content(params = {})\n rep_for_params!(params).compiled_content(params)\n end", "def compile\n end", "def precompiled(local_keys); end", "def marc_record\n @marc_record ||= Folio::MarcRecordMapper.build(stripped_marc_json, holdings, instance)\n end", "def marc_source\n @_marc_source ||= fetch(_marc_source_field)\n end", "def prepare\n opts = {}.update(self.class.options).update(options).update(file: eval_file)\n metadata[:mime_type] = opts.delete(:mime_type)\n if opts.include?(:outvar)\n opts[:buffer] = opts.delete(:outvar)\n opts[:save_buffer] = true\n end\n @src = self.class.compile(data, opts)\n end", "def set_object_fields\n \n # source id\n ##marc_source_id = marc.get_marc_source_id\n ##self.id = marc_source_id if marc_source_id\n # FIXME how do we generate ids?\n #self.marc.set_id self.id\n \n # parent source\n parent = marc.get_parent\n # If the 773 link is removed, clear the source_id\n # But before save it so we can update the parent\n # source.\n @old_parent = source_id if !parent\n self.source_id = parent ? parent.id : nil\n \n # record type\n self.record_type = 2 if marc.is_holding?\n \n # std_title\n self.std_title, self.std_title_d = marc.get_std_title\n \n # composer\n self.composer, self.composer_d = marc.get_composer\n \n # siglum and ms_no\n # in A/1 we do not have 852 in the bibliographic data\n # instead we store in ms_no the Book RISM ID (old rism id)\n if RISM::BASE == \"a1\" and record_type == 0\n self.book_id = marc.get_book_rism_id\n else\n self.lib_siglum, self.shelf_mark = marc.get_siglum_and_shelf_mark\n end\n \n # ms_title for bibliographic records\n self.title, self.title_d = marc.get_source_title if self.record_type != 2\n \n # physical_condition and urls for holding records\n self.ms_condition, self.urls, self.image_urls = marc.get_ms_condition_and_urls if self.record_type == 2\n \n # miscallaneous\n self.language, self.date_from, self.date_to = marc.get_miscellaneous_values\n\n self.marc_source = self.marc.to_marc\n end", "def compile\n prep\n client.setup_run_context\n end", "def precompile!\n # force the loading of the merge_vars, to and custom_html_data\n to\n merge_vars\n custom_html_data\n # free memory by setting the wrapped object to nil\n self.wrapped_object = nil\n self\n end", "def generate_active_record(mdm_model, config)\n #do the code to create new classes based on model metadata\n #and load them up in the Ruby VM\n #below NOTE! Need table created first for AR\n #AR provides a #column_names method that returns an array of column names\n useconnection = nil\n mdm_model.mdm_objects.each do |mdm_object|\n klass = Class.new ActiveRecord::Base do\n #establish_connection(config)\n #AR to set the physical tablename\n before_save :diff_row\n self.table_name = mdm_object.name\n \n #below does composite keys!\n \n if mdm_object.mdm_primary_keys.size > 0\n pkeys = mdm_object.mdm_primary_keys.collect{|x| x.mdm_column.name.to_sym }\n self.primary_keys = pkeys\n @@pklist = pkeys\n puts \"-\" * 80\n puts mdm_object.name, pkeys.size\n end\n #note this is FK implementation\n # has_many :statuses, :class_name => 'MembershipStatus', :foreign_key => [:user_id, :group_id]\n\n def name\n \n end\n \n def diff_row\n #here we send changes out over to the queue\n #we need PK followed by row\n puts self.changes\n pkvals = {}\n changevals = {}\n self.class.primary_keys.each do |k|\n pkvals[k] = self.read_attribute(k)\n end\n changevals['colvals'] = self.changes\n changevals['pkeys'] = pkvals\n redis = Redis.new\n redis.publish(\"mdm:freemdm\", changevals.to_json)\n end\n end\n \n \n #NOTE will need some adjustments to fit legacy tables to AR\n Object.const_set mdm_object.name.capitalize, klass\n puts config.symbolize_keys\n klass.establish_connection(config.symbolize_keys) \n useconnection = klass.connection if !useconnection\n # eval(\"class #{klass.name}; attr_accessible *columns;end\")\n #\n generate_column_meta(klass)\n\n klass.connection.jdbc_connection.close\n end\n \n end", "def process_compiled_file\n doc = Nokogiri::XML(File.open(@source))\n records = doc.xpath('//*[local-name()=\"mods\"]')\n records.each do |record|\n # record\n druid = record.parent['objectId']\n doc_node = Nokogiri::XML(record.to_s)\n mods_file = MODSFile.new(doc_node, @template_xml, @namespace)\n process_mods_file(mods_file, druid)\n end\n write_output if @analysis_only == false\n report_data_loss\n end", "def compile(*args)\n\t filtered_args, vm = prepare_call(args)\n\t CompiledCall.new(self, filtered_args, vm)\n\tend", "def set_compiled_method_cache; end", "def compiledo\n\n end", "def compile(code, force=false)\r\n raise DBGeni::NotImplemented\r\n end", "def compile\n if routes.any?\n eval(compiled_statement, binding, \"Generated Code for Merb::Router#match(#{__FILE__}:#{__LINE__})\", 1)\n else\n reset!\n end\n end", "def to_marc\n @_ruby_marc_obj ||= load_marc\n end", "def decode_pseudo_marc(pseudo_marc)\n raise ParserError, \"Cannot decode empty string.\" if pseudo_marc == \"\"\n \n pseudo_marc = pseudo_marc.split(\"\\n\") \n raw_fields = []\n \n if pseudo_marc[0][0..5] == \"LEADER\"\n record = create_record_for_type(pseudo_marc[0][7..-1])\n else\n raise ParserError, \"Cannot decode record without a leader.\"\n end\n \n pseudo_marc[1..pseudo_marc.length].each do |field|\n data = @entities.decode(field[7..-1])\n if field[0..2] != ' '\n data = MARC::ControlField.control_tag?(field[0..2]) ? data : \"a#{data}\"\n raw_fields << { \n :tag => field[0..2], \n :indicator1 => field[4,1], \n :indicator2 => field[5,1], \n :value => data.strip, \n :raw => field.strip\n }\n else \n raw_fields.last[:value] += \" #{data}\"\n raw_fields.last[:raw] += field.strip\n end\n end\n \n raw_fields.each do |field|\n tag = field[:tag]\n field_data = field[:value]\n if MARC::ControlField.control_tag?(tag)\n record.append(MARC::ControlField.new(tag, field_data)) \n else\n datafield = MARC::DataField.new(tag)\n datafield.indicator1 = field[:indicator1]\n datafield.indicator2 = field[:indicator2]\n \n field_data.split('|').each{|sub| \n subfield = MARC::Subfield.new(sub[0,1], sub[1..-1])\n datafield.append(subfield)\n }\n record.append(datafield)\n end\n end\n \n return record\n end", "def update_cako\n\t\tsql = \"update from CacheTako\"\n\t\treturn sql\n\tend", "def construct_sql\n if @reflection.options[:finder_sql]\n @finder_sql = interpolate_sql(@reflection.options[:finder_sql])\n else\n @finder_sql = conditions\n end\n \n if @reflection.options[:counter_sql]\n @counter_sql = interpolate_sql(@reflection.options[:counter_sql])\n elsif @reflection.options[:finder_sql]\n # replace the SELECT clause with COUNT(*), preserving any hints within /* ... */\n @reflection.options[:counter_sql] = @reflection.options[:finder_sql].sub(/SELECT (\\/\\*.*?\\*\\/ )?(.*)\\bFROM\\b/im) { \"SELECT #{$1}COUNT(*) FROM\" }\n @counter_sql = interpolate_sql(@reflection.options[:counter_sql])\n else\n @counter_sql = @finder_sql\n end\n end", "def compile!\n return if compiled?\n @routes.each_with_index do |route, index|\n route.index = index\n route.regexp = /(?<_#{index}>#{route.matcher.to_regexp})/\n end\n @compiled = true\n end", "def load\n # This could be generallized but for now lets just do this\n return if @cached.queue_name.nil?\n\n # logger.debug(\"CMB: load for #{self.to_param}\")\n time_now = Time.now\n\n # Pull the fields we need from the cached record into an options_hash\n options_hash = {\n :queue_name => @cached.queue_name,\n :h_or_s => @cached.h_or_s,\n :center => @cached.center.center\n }\n\n # :requested_elements is a special case\n requested_elements = Combined::Call.retain_fields.map { |field| field.to_sym }\n requested_elements << :ppg\n requested_elements << :p_s_b\n # logger.debug(\"CMB: requested_elements = #{requested_elements.inspect}\")\n options_hash[:requested_elements] = requested_elements\n\n # Create a Retain::Queue from the options cache.\n retain_queue = Retain::Queue.new(retain_user_connection_parameters, options_hash)\n retain_calls = retain_queue.calls\n\n # We know that the queue is valid or the calls method above\n # would have raised an expcetion. We are going to attach calls\n # to this queue and that does not work with a new record so we\n # go ahead and save it to the database.\n @cached.save if @cached.new_record?\n\n # retain_calls are the calls from retain while db_calls are the\n # calls that the database knows about.\n db_calls = @cached.calls\n\n # If retain says we have no calls, we delete the calls in the\n # database and go home.\n if retain_calls.length == 0\n # logger.debug(\"CMB: Queue is empty\")\n\n # If DB already says there are no calls, then there are no\n # calls to delete and, also, we do not need to touch\n # last_fetched.\n unless db_calls.length == 0\n @cached.calls.clear\n @cached.last_fetched = time_now\n end\n\n # We know that the queue is not dirty, set the updated_at\n # time, and save what has changed.\n @cached.dirty = false\n @cached.updated_at = time_now\n @cached.save\n return\n end\n\n # A new approach: Mark all the db calls as not used. Then walk\n # the retain call list. If the ppg and call_search_result both\n # equal, then we assume its the same call (I can't see how it\n # could not be) and mark it as used. Afterwards, we walk the db\n # call list and delete the unused calls.\n db_calls_hash = { }\n db_calls.each { |db_call|\n db_calls_hash[db_call.ppg] = db_call\n db_call.used = false\n }\n\n no_new = true\n slot = 0\n group_request = nil\n\n retain_calls.each do |retain_call|\n slot += 1\n db_call = db_calls_hash[retain_call.ppg]\n\n # Trust old call as the same\n if db_call && db_call.call_search_result == retain_call.call_search_result\n db_call.used = true\n db_call.slot = slot\n next\n end\n\n # first time through set these up\n if no_new\n no_new = false # at least one new call\n group_request = Combined::Call.retain_fields.map { |field| field.to_sym }\n group_request.freeze\n end\n\n # Make call fetch the fields we need\n retain_call.group_requests = group_request\n retain_call.send(group_request[0])\n\n # create or find the call\n call_options = Cached::Call.options_from_retain(retain_call)\n\n # If we have a call with the same ppg, we reuse it else we\n # find or create a new one. I don't see how the find could\n # not return a new record in the case that db_call was\n # originally null.\n db_call = @cached.calls.find_or_new(call_options) unless db_call\n\n # if an old record, update it with new info (If it is a new\n # record, this work will already been done.)\n unless db_call.new_record?\n db_call.attributes = call_options\n end\n\n db_call.used = true\n db_call.last_fetched = time_now if db_call.changed?\n db_call.slot = slot\n db_call.dirty = false\n\n # Make or find Cached PMR\n db_pmr = Pmr.find_existing_pmr(retain_call).unwrap_to_cached\n\n # I believe now that customer is not required for pmrs, we can \n # delete this code... To Be Done\n #\n # This code is duplicated three times presently. The problem\n # is that we do not want the center or other fields from the\n # call to enter in to the search or values for the customer.\n # So, we do a specific search for the customer by country and\n # customer number.\n #\n # Well, actually that is only half the problem. The bigger\n # problem with the PMR and customer is that we do not want to\n # fetch them from Retain until we need something from them.\n # That is why we construct the database objects in multiple\n # places.\n cust_options = {\n :country => retain_call.country,\n :customer_number => retain_call.customer_number\n }\n db_customer = Cached::Customer.find_or_new(cust_options)\n db_customer.save\n db_pmr.customer = db_customer\n db_pmr.save\n db_call.pmr = db_pmr\n\n # We just do the save which will cause updated_at to be\n # modified. It also causes the PMR and customer to be saved\n # if they are new.\n db_call.updated_at = time_now\n db_call.save\n end\n\n # delete any unused db_calls\n no_deletes = true\n db_calls.each do |db_call|\n unless db_call.used\n db_call.destroy\n no_deletes = false\n end\n end\n\n # mark as last_fetched if anything changed including adding or\n # deleting db calls.\n unless no_deletes && no_new && [email protected]?\n @cached.last_fetched = time_now\n end\n\n # Force the reload of the calls if we added or deleted db calls\n unless no_deletes && no_new\n @cached.calls(true)\n end\n @cached.dirty = false\n @cached.updated_at = time_now\n @cached.save\n end", "def compile\n if routes.any?\n eval(compiled_statement, binding, \"Generated Code for Router\", 1)\n else\n reset!\n end\n end", "def compilers\n find_related_frbr_objects( :is_compiled_by, :which_roles?) \n end", "def run_mxmlc\n if @target_id.nil?\n @target_id = @fcsh.mxmlc(get_compile_command)\n else\n @fcsh.compile(@target_id)\n end\n end", "def compile(mod); end", "def compile\n compile_libraries\n compile_ohai_plugins\n compile_compliance\n compile_attributes\n compile_lwrps\n compile_resource_definitions\n compile_recipes\n end", "def populate_from_cc(new_credit_card)\n #clear derived fields\n self.display_number=nil\n self.expiration_date=nil\n\n REMOTE_FIELDS.each do |f|\n #double rescue so it will read from hashes or records\n value=new_credit_card.send(f) rescue new_credit_card[f] rescue nil\n self.send(\"#{f}=\",value)\n end\n #NOTE: if first and last name are populated, will populate name attribute too\n #@name=nil if first_name? && last_name?\n end", "def each\n # Need to close the connection, teh result_set, AND the result_set.getStatement when\n # we're done.\n connection = open_connection!\n\n # We're going to need to ask for item/copy info while in the\n # middle of streaming our results. JDBC is happier and more performant\n # if we use a seperate connection for this.\n extra_connection = open_connection! if include_some_holdings?\n\n # We're going to make our marc records in batches, and only yield\n # them to caller in batches, so we can fetch copy/item info in batches\n # for efficiency.\n batch_size = settings[\"horizon.batch_size\"].to_i\n record_batch = []\n\n exclude_tags = (settings[\"horizon.exclude_tags\"] || \"\").split(\",\")\n\n\n rs = self.fetch_result_set!(connection)\n\n current_bib_id = nil\n record = nil\n record_count = 0\n\n error_handler = org.marc4j.ErrorHandler.new\n\n while(rs.next)\n bib_id = rs.getInt(\"bib#\");\n\n if bib_id != current_bib_id\n record_count += 1\n\n if settings[\"debug_ascii_progress\"] && (record_count % settings[\"solrj_writer.batch_size\"] == 0)\n $stderr.write \",\"\n end\n\n # new record! Put old one on batch queue.\n record_batch << record if record\n\n # prepare and yield batch?\n if (record_count % batch_size == 0)\n enhance_batch!(extra_connection, record_batch)\n record_batch.each do |r|\n # set current_bib_id for error logging\n current_bib_id = r['001'].value\n yield r\n end\n record_batch.clear\n end\n\n # And start new record we've encountered.\n error_handler = org.marc4j.ErrorHandler.new\n current_bib_id = bib_id\n record = MARC::Record.new\n record.append MARC::ControlField.new(\"001\", bib_id.to_s)\n end\n\n tagord = rs.getInt(\"tagord\");\n tag = rs.getString(\"tag\")\n\n # just silently skip it, some weird row in the horizon db, it happens.\n # plus any of our exclude_tags.\n next if tag.nil? || tag == \"\" || exclude_tags.include?(tag)\n\n indicators = rs.getString(\"indicators\")\n\n # a packed byte array could be in various columns, in order of preference...\n # the xref stuff is joined in from the auth table\n # Have to get it as bytes and then convert it to String to avoid JDBC messing\n # up the encoding marc8 grr\n authtext = rs.getBytes(\"xref_longtext\") || rs.getBytes(\"xref_text\")\n text = rs.getBytes(\"longtext\") || rs.getBytes(\"text\")\n\n\n if tag == \"000\"\n # Horizon puts a \\x1E marc field terminator on the end of hte\n # leader in the db too, but that's not really part of it.\n record.leader = String.from_java_bytes(text).chomp(\"\\x1E\")\n\n fix_leader!(record.leader)\n elsif tag != \"001\"\n # we add an 001 ourselves with bib id in another part of code.\n field = build_marc_field!(error_handler, tag, indicators, text, authtext)\n record.append field unless field.nil?\n end\n end\n\n # last one\n record_batch << record if record\n\n # yield last batch\n enhance_batch!(extra_connection, record_batch)\n\n record_batch.each do |r|\n yield r\n end\n record_batch.clear\n\n rescue Exception => e\n logger.fatal \"HorizonReader, unexpected exception at bib id:#{current_bib_id}: #{e}\" \n raise e\n ensure\n logger.info(\"HorizonReader: Closing all JDBC objects...\")\n\n # have to cancel the statement to keep us from waiting on entire\n # result set when exception is raised in the middle of stream.\n statement = rs && rs.getStatement\n if statement\n statement.cancel\n statement.close\n end\n\n rs.close if rs\n\n # shouldn't actually need to close the resultset and statement if we cancel, I think.\n connection.close if connection\n\n extra_connection.close if extra_connection\n\n logger.info(\"HorizonReader: Closed JDBC objects\")\n end", "def insert_cako\n\t\tsql = \"insert into CacheTako values (?, ?, ?)\"\n\t\treturn sql\n\tend", "def do_compile code, do_eval=true\n\t\t\[email protected]_logger.trace TRACE_ENGINE,\"Compiling #{code.fn} action #{code.action}\"\n\t\t\tbegin\n\t\t\t\t# Translate Cfruby style code into plain Ruby\n\t\t\t\ttranslator = Cfp_Translate.new(@cf,@parser)\n\t\t\t\t# Translate conditional blocks\n\t\t\t\tlines = translator.conditionals(code)\n\t\t\t\t# Line by line translation, depending on function - i.e. control, files, tidy etc.\n\t\t\t\ttranslated_lines = []\n\t\t\t\t# code.each do | line,num |\n\t\t\t\tlines.each do | line |\n\t\t\t\t\ttranslated_lines.push translator.do_translate(code.action,line)\n\t\t\t\tend\n\t\t\t\t# Encapsulate teh code into a class object\n\t\t\t\tbuf = code.encapsulate(translated_lines).join(\"\\n\")\n\t\t\t\[email protected]_logger.trace TRACE_ALL,buf\n\t\t\t\teval buf if do_eval\n\t\t\trescue SyntaxError, RuntimeError\n\t\t\t\tmsg = 'ERROR cfscript ',code.fn,\" line #{code.linenum} - #{$!}\\n\"\n\t\t\t\tcode.dump\n\t\t\t\[email protected]_logger.error LOG_CRIT,msg,'cfruby'\n\t\t\t\traise\n\t\t\tend\n\t\t\tbuf\n\t\tend", "def compile\n queue = all_members\n while queue.count > 0\n found_strands = queue.shift.cluster_maps.map do |obj|\n obj.strand(false)\n end\n found_strands.reject! { |s| @strands.include?(s) }\n @strands += found_strands\n queue += found_strands.map(&:members).flatten\n end\n evaluate\n end", "def initialize_copy(c)\n @db = c.db\n @opts = Hash[c.opts]\n if cols = c.cache_get(:_columns)\n @cache = {:_columns=>cols}\n else\n @cache = {}\n end\n end", "def compile force:nil, production:nil\n @production = production || false\n method_name = 'compile_%s' % @source.to_s.split('.').last.downcase\n\n if respond_to?(method_name, true)\n (!force && cached) || ( process_erb; send(method_name))\n else\n @source.read\n end\n end", "def memoize_table_column(*raw_columns, editable: true)\n RedisMemo::MemoizeQuery.__send__(:using_active_record!, self)\n return if RedisMemo::DefaultOptions.disable_all\n return if RedisMemo::DefaultOptions.model_disabled_for_caching?(self)\n\n columns = raw_columns.map(&:to_sym).sort\n\n RedisMemo::MemoizeQuery.memoized_columns(self, editable_only: true) << columns if editable\n RedisMemo::MemoizeQuery.memoized_columns(self, editable_only: false) << columns\n\n RedisMemo::MemoizeQuery::ModelCallback.install(self)\n RedisMemo::MemoizeQuery::Invalidation.install(self)\n\n unless RedisMemo::DefaultOptions.disable_cached_select\n RedisMemo::MemoizeQuery::CachedSelect.install(ActiveRecord::Base.connection)\n end\n\n # The code below might fail due to missing DB/table errors\n columns.each do |column|\n next if columns_hash.include?(column.to_s)\n\n raise RedisMemo::ArgumentError.new(\"'#{name}' does not contain column '#{column}'\")\n end\n\n unless RedisMemo::DefaultOptions.model_disabled_for_caching?(self)\n RedisMemo::MemoizeQuery::CachedSelect.enabled_models[table_name] = self\n end\n rescue ActiveRecord::NoDatabaseError, ActiveRecord::StatementInvalid\n # no-opts: models with memoize_table_column decleared might be loaded in\n # rake tasks that are used to create databases\n end", "def redisize_sql_metas key, attres\n model_name = key[1]\n primary_key = key[2]\n\n # binding.pry\n attres.map do |attrs|\n metakey = [\"meta\", model_name, primary_key, attrs[primary_key]]\n\n parse_instance_attrs(model_name, attrs, key)\n assign_reverse_key(metakey, key)\n end\n\n parse_sql_key(key)\n end", "def precompiled(locals); end", "def to_mom( compiler )\n @receiver = SelfExpression.new(compiler.receiver_type) if @receiver.is_a?(SelfExpression)\n if(@receiver.ct_type)\n simple_call(compiler)\n else\n cached_call(compiler)\n end\n end", "def compile_to_c\n \"if (\" + @condition.compile_to_c + \") {\\n\" +\n indent_c(@then_part.compile_to_c) +\n \"\\n} else {\\n\" +\n indent_c(@else_part.compile_to_c) +\n \"\\n}\"\n end", "def compile_varfields(record_id, tags)\n varfields = get_varfields(record_id, tags)\n return nil if !varfields\n compiled = varfields.map { |x| x['extracted_content']}\n compiled.flatten!\n compiled.delete(\"\")\n return compiled\n end", "def initialize\n\n # request configuration information\n conf = Configvalue.where(:name => :atodate).first\n @atoDate = conf.dvalue\n @atoYear = 0\n conf = Configvalue.where(:name => :controlrevision).first\n @controlRev = conf.ivalue\n \n # set initial values\n @id = 1 # 1 is used just for convenience\n @cagtested = 1 # 1 is used just for test\n @cagopen = 1 # 1 is used just for test\n @cagpartial = 1 # 1 is used just for test\n @cagdue = 1 # 1 is used just for test\n @caglate = 1 # 1 is used just for test\n @cagnotscheduled = 1 # 1 is used just for test\n @cagauto = 1 # 1 is used just for test\n @cagtotal = 1 # 1 is used just for test\n @cagcyclemonth = 1 # 1 is used just for test\n @cagcycleduration = 12 #\n @mabtested = 1 # 1 is used just for test\n @mabopen = 1 # 1 is used just for test\n @mabpartial = 1 # 1 is used just for test\n @mabdue = 1 # 1 is used just for test\n @mablate = 1 # 1 is used just for test\n @mabnotscheduled = 1 # 1 is used just for test\n @mabauto = 1 # 1 is used just for test\n @mabtotal = 1 # 1 is used just for test\n @mabcyclemonth = 1 # 1 is used just for test\n @mabcycleduration = 48 #\n \n # get sql connection\n sql = ActiveRecord::Base.connection();\n \n # Process DB specific code\n if ActiveRecord::Base::connection.is_a?(ActiveRecord::ConnectionAdapters::SQLServerAdapter)\n \n # get setup values\n tempDate = sql.select_value(\"SELECT DATEDIFF(day, '#{@atoDate.year}-#{@atoDate.month}-#{@atoDate.day}', GETDATE())\")\n tempYear = tempDate.to_i / 365\n @atoYear = tempYear.to_i + 1\n @mabcyclemonth = (tempDate.to_i / 30.415).to_i\n @cagcyclemonth = (@mabcyclemonth.to_i % 12) + 1\n enclaveYear = sql.select_value(\"SELECT MAX(enclaveYear) FROM enclavequarters\")\n enclaveQuarter = sql.select_value(\"SELECT MAX(enclaveQuarter) FROM enclavequarters WHERE enclaveYear=#{enclaveYear}\")\n eqList = \"0\"\n eqSet = Enclavequarter.where(\"enclaveYear=#{enclaveYear} AND enclaveQuarter=#{enclaveQuarter}\")\n enclaveCount= eqSet.length\n eqSet.each do |eq|\n eqList += \", #{eq.id}\"\n end\n #Rails.logger.error \"\\n\" + \"metric.initialize - Got Here 1 - tempDate: #{tempDate}, tempYear: #{tempYear}, atoYear: #{@atoYear}, mabcyclemonth: #{@mabcyclemonth}, cagcyclemonth: #{@cagcyclemonth}, enclaveYear: #{enclaveYear}, enclaveQuarter: #{enclaveQuarter}, enclaveCount: #{enclaveCount}, eqList: #{eqList}\\n\"\n \n # create base sql statements for lookup\n cagSQLFragment = \" FROM enclavecontrols ec, cybercontrols cc WHERE ec.cybercontrol_id=cc.id AND cc.criticalControl=1 AND ec.enclavequarter_id IN (#{eqList}) AND ec.RMF=0 AND cc.Revision=#{@controlRev} \"\n cagSQLFragment += \"AND ec.created_at > DATEADD(year, #{(@atoYear - 1)}, '#{@atoDate.year}-#{@atoDate.month}-#{@atoDate.day}') \"\n mabSQLFragment = \" FROM enclavecontrols ec, cybercontrols cc WHERE ec.cybercontrol_id=cc.id AND cc.criticalControl=0 AND ec.enclavequarter_id IN (#{eqList}) AND ec.RMF=0 AND cc.Revision=#{@controlRev} \"\n if @atoYear == 4 then\n mabSQLFragment += \"AND ec.created_at > DATEADD(year, #{(@atoYear - 1)}, '#{@atoDate.year}-#{@atoDate.month}-#{@atoDate.day}') \"\n end\n \n # get list of controls that have a scheduled date\n cagccwithsheduledlist = \"0\"\n cagccwithsheduled = sql.select_values(\"SELECT cc.id \" + cagSQLFragment + \" AND ec.plannedTestDate IS NOT NULL\")\n cagccwithsheduled.each do |id|\n cagccwithsheduledlist += \", #{id}\"\n end\n mabccwithsheduledlist = \"0\"\n mabccwithsheduled = sql.select_values(\"SELECT cc.id \" + mabSQLFragment + \" AND ec.plannedTestDate IS NOT NULL\")\n mabccwithsheduled.each do |id|\n mabccwithsheduledlist += \", #{id}\"\n end\n\n \n # finalize sql statements and get initial metrics\n @cagtested = sql.select_value(\"SELECT count(*) \" + cagSQLFragment + \" AND ec.actualTestDate IS NOT NULL\")\n @mabtested = sql.select_value(\"SELECT count(*) \" + mabSQLFragment + \" AND ec.actualTestDate IS NOT NULL\")\n @cagopen = sql.select_value(\"SELECT count(*) \" + cagSQLFragment + \" AND ec.SSPImplementationStatus != 'Implemented' AND ec.SSPImplementationStatus != 'Not Applicable'\")\n @mabopen = sql.select_value(\"SELECT count(*) \" + mabSQLFragment + \" AND ec.SSPImplementationStatus != 'Implemented' AND ec.SSPImplementationStatus != 'Not Applicable'\")\n @cagpartial = sql.select_value(\"SELECT count(*) \" + cagSQLFragment + \" AND ec.SSPImplementationStatus = 'Partially Implemented'\")\n @mabpartial = sql.select_value(\"SELECT count(*) \" + mabSQLFragment + \" AND ec.SSPImplementationStatus = 'Partially Implemented'\")\n @cagdue = sql.select_value(\"SELECT count(*) \" + cagSQLFragment + \" AND ec.actualTestDate IS NULL AND ec.plannedTestDate < DATEADD(day, 30, GETDATE()) AND ec.plannedTestDate >= GETDATE()\")\n @mabdue = sql.select_value(\"SELECT count(*) \" + mabSQLFragment + \" AND ec.actualTestDate IS NULL AND ec.plannedTestDate < DATEADD(day, 60, GETDATE()) AND ec.plannedTestDate >= GETDATE()\")\n @caglate = sql.select_value(\"SELECT count(*) \" + cagSQLFragment + \" AND ec.actualTestDate IS NULL AND ec.plannedTestDate < GETDATE()\")\n @mablate = sql.select_value(\"SELECT count(*) \" + mabSQLFragment + \" AND ec.actualTestDate IS NULL AND ec.plannedTestDate < GETDATE()\")\n #@cagnotscheduled = sql.select_value(\"SELECT count(*) \" + cagSQLFragment + \" AND ec.plannedTestDate IS NULL\")\n #@mabnotscheduled = sql.select_value(\"SELECT count(*) \" + mabSQLFragment + \" AND ec.plannedTestDate IS NULL\")\n #@cagscheduled = sql.select_value(\"SELECT count(*) \" + cagSQLFragment + \" AND ec.plannedTestDate IS NOT NULL\")\n #@mabscheduled = sql.select_value(\"SELECT count(*) \" + mabSQLFragment + \" AND ec.plannedTestDate IS NOT NULL\")\n @cagscheduled = sql.select_value(\"SELECT count(*) FROM cybercontrols WHERE id in (#{cagccwithsheduledlist})\")\n @mabscheduled = sql.select_value(\"SELECT count(*) FROM cybercontrols WHERE id in (#{mabccwithsheduledlist})\")\n @cagauto = sql.select_value(\"SELECT count(*) \" + cagSQLFragment + \" AND ec.testMethod = 'Automatic'\")\n @mabauto = sql.select_value(\"SELECT count(*) \" + mabSQLFragment + \" AND ec.testMethod = 'Automatic'\")\n @cagtotal = sql.select_value(\"SELECT count(*) \" + cagSQLFragment)\n @mabtotal = sql.select_value(\"SELECT count(*) \" + mabSQLFragment)\n \n else\n\n # get setup values\n tempDate, dummy = sql.execute(\"SELECT DATEDIFF(SYSDATE(), '#{@atoDate.year}-#{@atoDate.month}-#{@atoDate.day}'), 0\").fetch_row\n tempYear = tempDate.to_i / 365\n @atoYear = tempYear.to_i + 1\n @mabcyclemonth = (tempDate.to_i / 30.415).to_i\n @cagcyclemonth = @mabcyclemonth.to_i % 12\n enclaveYear, dummy = sql.execute(\"SELECT MAX(enclaveYear) FROM enclavequarters\").fetch_row\n enclaveQuarter, dummy = sql.execute(\"SELECT MAX(enclaveQuarter) FROM enclavequarters WHERE enclaveYear=#{enclaveYear}\").fetch_row\n eqList = \"0\"\n eqSet = Enclavequarter.where(\"enclaveYear=#{enclaveYear} AND enclaveQuarter=#{enclaveQuarter}\")\n enclaveCount= eqSet.length\n eqSet.each do |eq|\n eqList += \", #{eq.id}\"\n end\n \n # create base sql statements for lookup\n cagSQLFragment = \" FROM enclavecontrols ec, cybercontrols cc WHERE ec.cybercontrol_id=cc.id AND cc.criticalControl=1 AND ec.enclavequarter_id IN (#{eqList}) AND ec.RMF=0 AND cc.Revision=#{@controlRev} \"\n cagSQLFragment += \"AND ec.created_at > ADDDATE('#{@atoDate.year}-#{@atoDate.month}-#{@atoDate.day}', INTERVAL #{(@atoYear - 1)} YEAR) \"\n mabSQLFragment = \" FROM enclavecontrols ec, cybercontrols cc WHERE ec.cybercontrol_id=cc.id AND cc.criticalControl=0 AND ec.enclavequarter_id IN (#{eqList}) AND ec.RMF=0 AND cc.Revision=#{@controlRev} \"\n if @atoYear == 4 then\n mabSQLFragment += \"AND ec.created_at > ADDDATE('#{@atoDate.year}-#{@atoDate.month}-#{@atoDate.day}', INTERVAL #{(@atoYear - 1)} YEAR) \"\n end\n \n # get list of controls that have a scheduled date\n cagccwithsheduledlist = \"0\"\n cagccwithsheduled = sql.select_values(\"SELECT cc.id \" + cagSQLFragment + \" AND ec.plannedTestDate IS NOT NULL\")\n cagccwithsheduled.each do |id|\n cagccwithsheduledlist += \", #{id}\"\n end\n mabccwithsheduledlist = \"0\"\n mabccwithsheduled = sql.select_values(\"SELECT cc.id \" + mabSQLFragment + \" AND ec.plannedTestDate IS NOT NULL\")\n mabccwithsheduled.each do |id|\n mabccwithsheduledlist += \", #{id}\"\n end\n\n \n # finalize sql statements and get initial metrics\n @cagtested, dummy = sql.execute(\"SELECT count(*), 0 \" + cagSQLFragment + \" AND ec.actualTestDate IS NOT NULL\").fetch_row\n @mabtested, dummy = sql.execute(\"SELECT count(*), 0 \" + mabSQLFragment + \" AND ec.actualTestDate IS NOT NULL\").fetch_row\n @cagopen, dummy = sql.execute(\"SELECT count(*), 0 \" + cagSQLFragment + \" AND ec.SSPImplementationStatus != 'Implemented' AND ec.SSPImplementationStatus != 'Not Applicable'\").fetch_row\n @mabopen, dummy = sql.execute(\"SELECT count(*), 0 \" + mabSQLFragment + \" AND ec.SSPImplementationStatus != 'Implemented' AND ec.SSPImplementationStatus != 'Not Applicable'\").fetch_row\n @cagpartial, dummy = sql.execute(\"SELECT count(*), 0 \" + cagSQLFragment + \" AND ec.SSPImplementationStatus = 'Partially Implemented'\").fetch_row\n @mabpartial, dummy = sql.execute(\"SELECT count(*), 0 \" + mabSQLFragment + \" AND ec.SSPImplementationStatus = 'Partially Implemented'\").fetch_row\n @cagdue, dummy = sql.execute(\"SELECT count(*), 0 \" + cagSQLFragment + \" AND ec.actualTestDate IS NULL AND ec.plannedTestDate < ADDDATE(SYSDATE(), 30) AND ec.plannedTestDate >= SYSDATE()\").fetch_row\n @mabdue, dummy = sql.execute(\"SELECT count(*), 0 \" + mabSQLFragment + \" AND ec.actualTestDate IS NULL AND ec.plannedTestDate < ADDDATE(SYSDATE(), 60) AND ec.plannedTestDate >= SYSDATE()\").fetch_row\n @caglate , dummy = sql.execute(\"SELECT count(*), 0 \" + cagSQLFragment + \" AND ec.actualTestDate IS NULL AND ec.plannedTestDate < SYSDATE()\").fetch_row\n @mablate , dummy = sql.execute(\"SELECT count(*), 0 \" + mabSQLFragment + \" AND ec.actualTestDate IS NULL AND ec.plannedTestDate < SYSDATE()\").fetch_row\n #@cagnotscheduled, dummy = sql.execute(\"SELECT count(*), 0 \" + cagSQLFragment + \" AND ec.plannedTestDate IS NULL\").fetch_row\n #@mabnotscheduled, dummy = sql.execute(\"SELECT count(*), 0 \" + mabSQLFragment + \" AND ec.plannedTestDate IS NULL\").fetch_row\n #@cagscheduled, dummy = sql.execute(\"SELECT count(*), 0 \" + cagSQLFragment + \" AND ec.plannedTestDate IS NOT NULL\").fetch_row\n #@mabscheduled, dummy = sql.execute(\"SELECT count(*), 0 \" + mabSQLFragment + \" AND ec.plannedTestDate IS NOT NULL\").fetch_row\n @cagscheduled = sql.select_value(\"SELECT count(*) FROM cybercontrols WHERE id in (#{cagccwithsheduledlist})\")\n @mabscheduled = sql.select_value(\"SELECT count(*) FROM cybercontrols WHERE id in (#{mabccwithsheduledlist})\")\n @cagauto, dummy = sql.execute(\"SELECT count(*), 0 \" + cagSQLFragment + \" AND ec.testMethod = 'Automatic'\").fetch_row\n @mabauto, dummy = sql.execute(\"SELECT count(*), 0 \" + mabSQLFragment + \" AND ec.testMethod = 'Automatic'\").fetch_row\n @cagtotal, dummy = sql.execute(\"SELECT count(*), 0 \" + cagSQLFragment).fetch_row\n @mabtotal, dummy = sql.execute(\"SELECT count(*), 0 \" + mabSQLFragment).fetch_row\n \n end\n \n # finalize metrics\n @cagtested = @cagtested.to_i / enclaveCount\n @mabtested = @mabtested.to_i / enclaveCount\n @cagauto = @cagauto.to_i / enclaveCount\n @mabauto = @mabauto.to_i / enclaveCount\n @cagtotal = @cagtotal.to_i / enclaveCount\n @mabtotal = @mabtotal.to_i / enclaveCount\n @cagopen = @cagopen.to_i / enclaveCount\n @mabopen = @mabopen.to_i / enclaveCount\n @cagpartial = @cagpartial.to_i / enclaveCount\n @mabpartial = @mabpartial.to_i / enclaveCount\n #@cagdue = @cagdue.to_i / enclaveCount\n @cagdue = @cagdue.to_i\n #@mabdue = @mabdue.to_i / enclaveCount\n @mabdue = @mabdue.to_i\n #@caglate = @caglate.to_i / enclaveCount\n @caglate = @caglate.to_i\n #@mablate = @mablate.to_i / enclaveCount\n @mablate = @mablate.to_i\n #@cagnotscheduled = @cagnotscheduled.to_i / enclaveCount\n #@mabnotscheduled = @mabnotscheduled.to_i / enclaveCount\n @cagnotscheduled = @cagtotal - @cagauto - @cagscheduled.to_i\n @mabnotscheduled = @mabtotal - @mabauto - @mabscheduled.to_i\n\n end", "def controlaccess_elements(marc)\n elements = []\n # corpname\n elements.concat controlaccess_elements_for_tags(marc, ['610','611','710','711','697'], 'corpname')\n # persname\n elements.concat controlaccess_elements_for_tags(marc, ['600','700'], 'persname')\n # geogname\n elements.concat controlaccess_elements_for_tags(marc, ['651'], 'geogname')\n # subject\n elements.concat controlaccess_elements_for_tags(marc, ['650'], 'subject')\n # genreform\n elements.concat controlaccess_elements_for_tags(marc, ['655'], 'genreform')\n # occupation\n elements.concat controlaccess_elements_for_tags(marc, ['656'], 'occupation',['2'])\n # function\n functions = marc.fields('657').map do |field|\n { name: 'function', value: field.subfields.map(&:value).join(' '), attrs: { encodinganalog: '657' } }\n end.to_a\n elements.concat functions\n # title\n titles = marc.fields('630').map do |field|\n { name: 'title', value: field.subfields.map(&:value).join(' '), attrs: { encodinganalog: '630' } }\n end.to_a\n elements.concat titles\n titles = marc.fields('730').map do |field|\n { name: 'title', value: field.subfields.map(&:value).join(' '), attrs: { encodinganalog: '730' } }\n end.to_a\n elements.concat titles\n controlaccess = {\n name: 'controlaccess',\n children: elements\n }\n [controlaccess]\n end", "def caches(*attrs)\n fields = []\n\n if attrs.include? :all\n fields.concat [*self._attributes.keys].map(&:to_sym) +\n [*self._optional_fields].map(&:to_sym) +\n [*self._associations].map(&:to_sym)\n\n attrs.delete(:all)\n end\n\n if attrs.include? :associations\n fields.concat self._associations\n attrs.delete(:associations)\n end\n\n if attrs.include? :optional_fields\n fields.concat self._optional_fields\n attrs.delete(:optional_fields)\n end\n\n if attrs.include? :fields\n fields.concat self._attributes\n attrs.delete(:fields)\n end\n\n self._cacheable_fields = fields.concat(attrs)\n end", "def execute_CMC\n\t\[email protected]_bit_at(CARRY_FLAG, @flags[CARRY_FLAG] ^ 1)\n\tend", "def compile\n Timer.new(:title => \"YMDP\").time do\n clean_tmp_dir do\n process_domains\n end\n end\n end", "def set(recs, data)\r\n # If updates are not in the form of a Proc, convert updates, which\r\n # could be an array, a hash, or a Struct into a common format (i.e.\r\n # hash).\r\n update_rec = convert_input_data(data) unless data.is_a?(Proc)\r\n\r\n updated_recs = []\r\n\r\n # For each one of the recs that matched the update query, apply the\r\n # updates to it and write it back to the database table.\r\n recs.each do |rec|\r\n temp_rec = rec.dup\r\n\r\n if data.is_a?(Proc)\r\n begin\r\n data.call(temp_rec)\r\n rescue NoMethodError\r\n raise 'Invalid field name in code block: %s' % $!\r\n end\r\n else\r\n @field_names.each { |fn| temp_rec[fn] = update_rec.fetch(fn,\r\n temp_rec.send(fn)) }\r\n end\r\n\r\n # Is the user trying to change something they shouldn't?\r\n raise 'Cannot update recno field!' unless \\\r\n rec.recno == temp_rec.recno\r\n raise 'Cannot update internal fpos field!' unless \\\r\n rec.fpos == temp_rec.fpos\r\n raise 'Cannot update internal line_length field!' unless \\\r\n rec.line_length == temp_rec.line_length\r\n\r\n # Are the data types of the updates correct?\r\n validate_input(temp_rec)\r\n\r\n check_required_fields(temp_rec)\r\n\r\n check_against_input_for_specials(temp_rec)\r\n\r\n # Apply updates to the record and add it to an array holding\r\n # updated records. We need the fpos and line_length because\r\n # the engine will use them to determine where to write the\r\n # update and whether the updated record will fit in the old\r\n # record's spot.\r\n updated_recs << { :rec => @field_names.zip(@field_types\r\n ).collect { |fn, ft| convert_to_encoded_string(ft,\r\n temp_rec.send(fn)) }, :fpos => rec.fpos,\r\n :line_length => rec.line_length }\r\n \r\n\r\n # Update any associated blob/memo fields.\r\n temp_rec.each { |r| r.write_to_file if r.is_a?(KBMemo) } if \\\r\n @field_types.include?(:Memo)\r\n temp_rec.each { |r| r.write_to_file if r.is_a?(KBBlob) } if \\\r\n @field_types.include?(:Blob)\r\n end\r\n\r\n # Take all of the update records and write them back out to the\r\n # table's file.\r\n @db.engine.update_records(self, updated_recs)\r\n\r\n # Return the number of records updated.\r\n return recs.size\r\n end", "def compile\n begin\n edges = []\n @members.each do |member|\n edges += member.strand_maps\n end\n edges.reject! { |e| @members.map(&:typed_id).include?(e.typed_id) }\n @members += edges\n end while edges.count > 0\n end", "def compile_all(mustCompile)\r\n return if !mustCompile\r\n FileLineData.clear\r\n echoln _INTL(\"*** Starting full compile ***\")\r\n echoln \"\"\r\n yield(_INTL(\"Compiling town map data\"))\r\n compile_town_map # No dependencies\r\n yield(_INTL(\"Compiling map connection data\"))\r\n compile_connections # No dependencies\r\n yield(_INTL(\"Compiling phone data\"))\r\n compile_phone # No dependencies\r\n yield(_INTL(\"Compiling type data\"))\r\n compile_types # No dependencies\r\n yield(_INTL(\"Compiling ability data\"))\r\n compile_abilities # No dependencies\r\n yield(_INTL(\"Compiling move data\"))\r\n compile_moves # Depends on Type\r\n yield(_INTL(\"Compiling item data\"))\r\n compile_items # Depends on Move\r\n yield(_INTL(\"Compiling berry plant data\"))\r\n compile_berry_plants # Depends on Item\r\n yield(_INTL(\"Compiling Pokémon data\"))\r\n compile_pokemon # Depends on Move, Item, Type, Ability\r\n yield(_INTL(\"Compiling Pokémon forms data\"))\r\n compile_pokemon_forms # Depends on Species, Move, Item, Type, Ability\r\n yield(_INTL(\"Compiling machine data\"))\r\n compile_move_compatibilities # Depends on Species, Move\r\n yield(_INTL(\"Compiling shadow moveset data\"))\r\n compile_shadow_movesets # Depends on Species, Move\r\n yield(_INTL(\"Compiling Regional Dexes\"))\r\n compile_regional_dexes # Depends on Species\r\n yield(_INTL(\"Compiling ribbon data\"))\r\n compile_ribbons # No dependencies\r\n yield(_INTL(\"Compiling encounter data\"))\r\n compile_encounters # Depends on Species\r\n yield(_INTL(\"Compiling Trainer type data\"))\r\n compile_trainer_types # No dependencies\r\n yield(_INTL(\"Compiling Trainer data\"))\r\n compile_trainers # Depends on Species, Item, Move\r\n yield(_INTL(\"Compiling battle Trainer data\"))\r\n compile_trainer_lists # Depends on TrainerType\r\n yield(_INTL(\"Compiling metadata\"))\r\n compile_metadata # Depends on TrainerType\r\n yield(_INTL(\"Compiling animations\"))\r\n compile_animations\r\n yield(_INTL(\"Converting events\"))\r\n compile_trainer_events(mustCompile)\r\n yield(_INTL(\"Saving messages\"))\r\n pbSetTextMessages\r\n MessageTypes.saveMessages\r\n MessageTypes.loadMessageFile(\"Data/messages.dat\") if safeExists?(\"Data/messages.dat\")\r\n System.reload_cache\r\n echoln \"\"\r\n echoln _INTL(\"*** Finished full compile ***\")\r\n echoln \"\"\r\n pbSetWindowText(nil)\r\n end", "def compile(str)\n @compiled[str]\n end", "def marc_record_from_marc21\n return if marc_source.blank?\n MARC::Record.new_from_marc marc_source\n end", "def assemble\n # var a, b, c;\n \"var \" + @locals.join(\", \") + \";\\n\" +\n @code.join\n end", "def load cxr\n where(cxx: cxr, hub: nil).delete_all\n #cxr_origins = OagSchedule.hub(hub).where(dest_apt: hub).pluck(:origin_apt, :airline_code, :mkt_cxrs ).uniq\n #cxr_dests = OagSchedule.hub(hub).where(origin_apt: hub).pluck(:dest_apt,:airline_code).uniq\n\n #origins = OagSchedule.cxr(cxr).distinct()\n direct_flight_records = []\n\n #origins = OagSchedule.cxr(cxr).pluck(:origin_apt, :airline_code, :mkt_cxrs).uniq\n\n schedules = OagSchedule.cxr(cxr).select(:origin_apt, :dest_apt, :airline_code, :mkt_cxrs).distinct\n cxr_schedules = schedules.group_by{|flt| [flt.origin_apt, flt.dest_apt] }.map{ |apt_pair,sched_a|\n [apt_pair, (sched_a.map{|sched| sched.airline_code } +\n sched_a.map{|sched| sched.mkt_carriers}.flatten(1)).uniq]}\n cxr_schedules.sort!\n cxr_schedules.each do |combo|\n direct_flight_records << new(cxx: cxr, origin: combo[0][0], dest: combo[0][1], carriers: combo[1])\n end\n ##origins = OagSchedule.for_cxr(cxr).pluck(:origin_apt).uniq\n #origins.each do |o_apt|\n # dest_apts = OagSchedule.cxr(cxr).where(origin_apt: o_apt).pluck(:dest_apt, :airline_code).uniq\n # dest_apts.each do |dest_apt|\n # direct_flight_records << new(cxx: cxr, origin: o_apt, dest: dest_apt)\n # end\n #end\n DirectFlight.import direct_flight_records\n end", "def transform\n remove_custom_chronology_value\n move_custom_provenance_value\n move_collection_names\n copy_holdings\n\n # Removing some Alma-specific nodes we don't want to expose.\n @record.xpath('./datafield[@tag=\"INT\"]').remove\n @record.xpath('./datafield[@tag=\"INST\"]').remove\n\n new_marcxml\n rescue StandardError => e\n raise MarcTransformationError, \"MARC transformation error: #{e.message}\"\n end", "def compile\n Dir.chdir(build_path) do\n do_compile\n end\n end", "def compile_plan()\n return Plan::ParserPlan.build( self )\n end", "def compile_line(line)\n return if line.strip.empty?\n \n if !check_for_directive(line)\n @computer.memory.storage[@compile_counter].from_code(line)\n @compile_counter += 1\n end\n end", "def compile\n table = TOC.new(self).table\n if table == []\n return content || ''\n else\n text = content + \"\\n\\n\" || ''\n table.each do |item |\n section = DocumentRepository.find(item.id)\n if section != nil\n text << section.compile << \"\\n\\n\"\n end\n end\n return text\n end\n end", "def compile(filename)\n check_cookie\n Native::magic_compile(@cookie, filename);\n end", "def calculate_cbm\n @cbm = @bab + @str_modifier + @unarmed_prof\n @cbm_def = 10 + @bab + @str_modifier + @dex_modifier + @unarmed_prof\n end", "def sql\n <<-SQL\n -- Search learning paths\n SELECT DISTINCT\n c.id,\n c.name,\n c.course_code,\n c.settings,\n cc.content,\n 'learning_path' AS content_type,\n c.id AS learning_path_id,\n 0 AS learning_objective_id\n FROM courses c\n LEFT OUTER JOIN fearless_taggings ts\n ON ts.taggable_id = c.id AND ts.taggable_type = 'LearningPath'\n LEFT OUTER JOIN fearless_tags t\n ON t.id = ts.tag_id\n LEFT OUTER JOIN fearless_custom_contents cc\n ON cc.contentable_id = c.id AND cc.contentable_type = 'LearningPath'\n WHERE 0=0\n #{construct_account_clause}\n #{construct_course_worklow_clause}\n #{construct_name_sql}\n #{construct_all_tags_search('t', 'name')}\n UNION ALL\n -- Search learning objectives\n SELECT DISTINCT\n cm.id,\n cm.name,\n c.course_code,\n c.settings,\n cc.content,\n 'learning_objective' AS content_type,\n cm.context_id::bigint AS learning_path_id,\n cm.id::bigint AS learning_objective_id\n FROM context_modules cm\n INNER JOIN courses c\n ON c.id = cm.context_id\n AND cm.context_type = 'Course'\n LEFT OUTER JOIN fearless_taggings ts\n ON ts.taggable_id = cm.id AND ts.taggable_type = 'LearningObjective'\n LEFT OUTER JOIN fearless_tags t\n ON t.id = ts.tag_id\n LEFT OUTER JOIN fearless_custom_contents cc\n ON cc.contentable_id = cm.id AND cc.contentable_type = 'LearningObjective'\n WHERE 0=0\n #{construct_account_clause}\n #{construct_generic_workflow_clause('cm')}\n #{construct_name_sql('cm')}\n #{construct_all_tags_search('t', 'name')}\n UNION ALL\n -- Search learning learning_event\n SELECT DISTINCT\n ct.id,\n ct.title AS name,\n c.course_code,\n c.settings,\n cc.content,\n 'learning_event' AS content_type,\n ct.context_id::bigint AS learning_path_id,\n ct.context_module_id::bigint AS learning_objective_id\n FROM content_tags ct\n INNER JOIN courses c\n ON c.id = ct.context_id\n AND ct.context_type = 'Course'\n LEFT OUTER JOIN fearless_taggings ts\n ON ts.taggable_id = ct.id AND ts.taggable_type = 'LearningEvent'\n LEFT OUTER JOIN fearless_tags t\n ON t.id = ts.tag_id\n LEFT OUTER JOIN fearless_custom_contents cc\n ON cc.contentable_id = ct.id AND cc.contentable_type = 'LearningEvent'\n WHERE 0=0\n #{construct_account_clause}\n #{construct_generic_workflow_clause('ct')}\n #{construct_name_sql('ct', 'title')}\n #{construct_all_tags_search('t', 'name')}\n SQL\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 do_execute code\n\t\t\tclassname = code.classname\n\t\t\tmethod = code.methodname\n\t\t\treturn if method == 'initialize'\n\t\t\t# @cf.cfp_logger.trace TRACE_ENGINE,\"Executing #{classname}.#{method}\"\n\t\t\t# Make sure global and class level variables exist\n\t\t\tsourcepath = File.dirname(code.fn)\n\t\t\thomepath = ENV['HOME']\n\t\t\tuser = ENV['USER'] # @@FIXME\n\t\t\tbegin\n\t\t\t\tiname = '@'+instancename(classname)\n\t\t\t\tif !@executeclasslist[classname]\n\t\t\t\t\t# ---- Create new class and add into runtime space\n\t\t\t\t\tscode = \"#{iname} = Cfp_Compile::#{classname}.new @cf,sourcepath,homepath,user\"\n\t\t\t\t\[email protected]_logger.trace TRACE_ENGINE,'Executing: '+scode\n\t\t\t\t\teval scode\n\t\t\t\t\t@executeclasslist[classname] = Cfp_ExecuteClass.new(classname)\n\t\t\t\tend\n\t\t\t\tif !@executeclasslist[classname].skip\n\t\t\t\t\tscode = \"#{iname}.#{method}\"\n\t\t\t\t\[email protected]_logger.trace TRACE_ENGINE,'Executing: '+scode\n\t\t\t\t\teval scode\n\t\t\t\tend\n\t\t\trescue CfrubyRuntime::PackageNotInstalledError, CfrubyRuntime::ExitScript\n\t\t\t\t@executeclasslist[classname].skip = true\n\t\t\trescue\n\t\t\t\tmsg = 'ERROR cfscript ',code.fn,\" line #{code.linenum} - #{$!}\\n\"\n\t\t\t\tcode.dump\n\t\t\t\[email protected]_logger.error LOG_CRIT,msg,'cfruby'\n\t\t\t\traise\n\t\t\tend\n\t\tend", "def build_statement(constructor, field, options = T.unsafe(nil)); end", "def compile\n return [] if empty?\n\n # Build \"bracketed\" statements.\n bsta = @statements.map do |s|\n auto_brackets, scalar_s = s.is_a?(Array) ? [true, s[0]] : [false, s]\n\n # Logic:\n # brackets | auto | result\n # ----------|-------|-------\n # true | * | true\n # false | * | false\n # :auto | true | true\n # :auto | false | false\n\n brackets = if @statements.size < 2\n # If there are no neighboring statements, there WILL BE NO brackets in any case.\n false\n elsif @brackets == true or @brackets == false\n @brackets\n elsif @brackets == :auto\n auto_brackets\n else\n raise \"Unknown @brackets value #{@brackets.inspect}, SE\"\n end\n\n if brackets\n [\"(\", scalar_s, \")\"].join\n else\n scalar_s\n end\n end\n\n [bsta.join(glue)] + @args\n end", "def compile(css, include_paths, settings)\n\tcss\nend", "def compile(template_name, compiled_content)\n self.kramdown_source.compile(template_name, compiled_content)\n end", "def run(*args)\n if compile? && !@compiled\n rc = compile\n @compiled = true if rc == 0\n if(rc != 0)\n raise CompileException.new(rc, @compile_out, @compile_err)\n end\n end\n\n execute(args)\n end", "def compile dir = nil\n if dir.nil?\n dir = @game_dir\n end\n\n valid_dir_entries(dir).each do |d|\n fullPath = File.join(dir, d)\n\n if File.directory?(fullPath)\n compile File.join(dir, d)\n elsif File.file?(fullPath)\n bits = fullPath[@game_dir.length+1..fullPath.length-1].split(File::SEPARATOR)\n if bits.include?('archetypes')\n compile_archetype(fullPath)\n elsif bits.include?('qualities')\n compile_mixin(fullPath)\n elsif bits.include?('verbs')\n compile_verb(fullPath)\n elsif bits.include?('adverbs')\n compile_adverb(fullPath)\n elsif bits[0] == 'domains' && bits.length == 3\n @pending << [ :compile_domain_data, [ fullPath, bits ]]\n end\n end\n end\n end", "def compile_code(*jsstmts)\n code *jsstmts\n compile\n end", "def compile\n @instance ||= new\n end", "def save_flex_attributes\n @save_flex_attr ||= []\n attribute_class = self.flex_options[:class_name].constantize\n base_foreign_key = self.flex_options[:base_foreign_key] # e.g. location_id\n value_field = self.flex_options[:value_field]\n name_field = self.flex_options[:name_field]\n foreign_key = self.flex_options[:foreign_key]\n \n # first, delete everything, unless we're not making changes:\n if self.flex_options[:purge] || !@save_flex_attr.empty?\n attribute_class.delete_all(deletion_query(foreign_key))\n related_attrs.reload\n self.flex_options.delete(:purge)\n end\n \n #now, rebuild things:\n @save_flex_attr.each do |pair|\n attr_name, value = pair\n parameters = {\n foreign_key => self.id,\n value_field => value,\n name_field => attr_name\n }\n parameters[self.flex_options[:version_column]] = self.send(flex_options[:version_column]) if self.flex_options[:versioned]\n \n build_related_attr_field( parameters )\n end\n @save_flex_attr = []\n end", "def compose\n case type\n when :integrated\n formated_query\n when :separated\n \"select #{target_column_names} from #{config[:object]} #{where_clause}\"\n end\n end", "def build(klazz_name)\n klazz_underscore = klazz_name.underscore\n klazzes = @repositories.map { |r| r.class_descriptors.filter(:rb_klazz => klazz_name).first }.compact\n raise StandardError if klazzes.empty?\n klazz = klazzes[-1] # keep the last one\n table = klazz.table\n if table.nil?\n raise ArgumentError # Fix this\n end\n string = %{\n$LOAD_PATH << Dir.pwd unless $LOAD_PATH.include? Dir.pwd\nrequire 'connection'\n\n}\n\n string = add_mapping_constants(klazz, klazz_name, string)\n string += string_methods(klazz_name)\n\n string << %{\n#{table}__#{klazz_name} = DB[:#{table}]\n#{table}__#{klazz_name}.identifier_input_method = :#{klazz_underscore}_db_in\n#{table}__#{klazz_name}.identifier_output_method = :#{klazz_underscore}_db_out\n}\n\n string << \"class #{klazz_name} < Sequel::Model\\n\"\n\n string << \" set_dataset #{table}__#{klazz_name}\\n\\n\"\n string = add_primary_keys(klazz, string)\n string = add_references(klazz, string)\n string = add_collections(klazz, string)\n string = add_ojb_entry(klazz, string)\n\n string << \"end\\n\"\n\n string << <<DEFN\nclass #{klazz_name}\n Definition = \"#{string}\"\n\n def self.definition\n OJBequel::Utils.less Definition\n end\nend\nDEFN\n\n #string << add_definition(klazz_name, string)\n string\n end", "def prepare\n namespace = @config[:namespace] || 'merb-cache'\n host = @config[:host] || '127.0.0.1:11211'\n @memcache = MemCache.new(host, {:namespace => namespace})\n @tracking_key = \"_#{namespace}_keys\" unless @config[:no_tracking]\n raise NotReady unless @memcache.active?\n true\n rescue NameError\n raise NotDefined\n end", "def run\n _escaped_sql = escaped_sql\n @query_logger << _escaped_sql if @query_logger\n result = @conn.exec_query _escaped_sql\n row_class = OccamsRecord::Results.klass(result.columns, result.column_types, @eager_loaders.names, model: @eager_loaders.model, modules: @use)\n rows = result.rows.map { |row| row_class.new row }\n @eager_loaders.run!(rows, query_logger: @query_logger)\n rows\n end" ]
[ "0.5925297", "0.5203729", "0.5078971", "0.5057087", "0.4984734", "0.4932112", "0.48944306", "0.48818266", "0.48788586", "0.48468804", "0.48451093", "0.4817521", "0.4804821", "0.47933313", "0.47621754", "0.4723399", "0.4713499", "0.47050372", "0.4695349", "0.46773624", "0.46743086", "0.46716723", "0.46680102", "0.46556017", "0.46250144", "0.4599403", "0.45901057", "0.4584468", "0.45543867", "0.44905436", "0.44667125", "0.44342512", "0.44271633", "0.44243214", "0.43929523", "0.4390791", "0.43891987", "0.43815705", "0.43770903", "0.4367573", "0.43519956", "0.43512717", "0.43505958", "0.43498784", "0.43401018", "0.43399605", "0.43124786", "0.43105295", "0.43103886", "0.42994907", "0.42849293", "0.42803928", "0.42200944", "0.42117164", "0.41887924", "0.41830665", "0.41729736", "0.41698077", "0.4147078", "0.4139864", "0.41243127", "0.4122742", "0.41140506", "0.4113779", "0.41046178", "0.41003835", "0.40945485", "0.40926507", "0.4078019", "0.4059374", "0.40556926", "0.40525", "0.40474", "0.40451452", "0.40388492", "0.4032564", "0.4028757", "0.40270412", "0.4018498", "0.40056342", "0.40031737", "0.4001962", "0.4001372", "0.39961138", "0.39906308", "0.39877245", "0.39859608", "0.3984422", "0.39811575", "0.39794144", "0.3977314", "0.39729705", "0.39678347", "0.39638665", "0.39518058", "0.3941694", "0.3940099", "0.39395523", "0.39348176", "0.39343038" ]
0.61666507
0
Never trust parameters from the scary internet, only allow the white list through.
def unit_params params.require(:unit).permit(:name, :unit, :create_user, :edit_user, :comment) 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 /clients GET /clients.json
def index @clients = Client.page(params[:page] || 1).per(10) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @clients = current_user.clients\n render json: @clients\n end", "def index\n @clients = Client.all\n render json: @clients\n end", "def index\n @clients = Client.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clients }\n end\n end", "def index\n @clients = Client.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clients }\n end\n\n end", "def get_clients\n @clients\n end", "def get_clients\n @clients\n end", "def index\n sanitized_params = parse_params(client_where_params)\n clients = Client.find_all(sanitized_params)\n render json: clients\n end", "def list_clients(json_payload={})\n conn = @client.get do |req|\n req.url \"/api/v2/client/list?\"\n req.headers[\"Authorization\"] = @token\n req.params = json_payload\n end\n conn.body\n end", "def index\n render json: Client.all\n end", "def index\n @clients = Client.all\n @uuid = params[:uuid]\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clients }\n end\n end", "def index\n clients = request do\n api.request(\n :expects => 200,\n :headers => headers,\n :method => :get,\n :path => \"/oauth/clients\"\n ).body\n end\n styled_header(\"OAuth Clients\")\n styled_array(clients.map { |client|\n [client[\"name\"], client[\"id\"], client[\"redirect_uri\"]]\n })\n end", "def show\n render json: @client\n end", "def clients\n @clients = Vendor.find(params[:id]).clients\n end", "def show\n @client = Client.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client }\n end\n end", "def show\n @client = Client.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client }\n end\n end", "def show\n @client = Client.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client }\n end\n end", "def show\n @client = Client.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client }\n end\n end", "def show\n @client = Client.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client }\n end\n end", "def show\n @client = Client.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client }\n end\n end", "def show\n @client = Client.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client }\n end\n end", "def show\n client = Client.retrieve_by_id(params[:id])\n\n render json: client, serializer: SingleClientSerializer\n end", "def index\n @clients = Client.all\n end", "def index\n @clients = Client.all\n end", "def index\n @clients = Client.all\n end", "def index\n @clients = Client.all\n end", "def index\n @clients = Client.all\n end", "def index\n @clients = Client.all\n end", "def index\n @clients = Client.all\n end", "def index\n @clients = Client.all\n end", "def index\n @clients = Client.where(params.except(:action, :controller, :format)).to_a # TODO: remove .to_a when Rails to_json bug fixed\n respond_with(@clients)\n end", "def clients\n response = User_GetClients()\n return [] if response.empty?\n unless response[\"Code\"].to_i != 0\n response[\"Client\"].collect{|c| Client.new(c[\"ClientID\"].to_i, c[\"Name\"])}\n else\n raise response[\"Code\"] + \" - \" + response[\"Message\"]\n end\n end", "def show\n @client = clients.find(params[:id])\n end", "def show\r\n @client = Client.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @client }\r\n end\r\n end", "def index\n @clients = Client.all\n end", "def details\n response = CreateSend.get \"/clients/#{client_id}.json\", {}\n Hashie::Mash.new(response)\n end", "def recent\n if current_user.is_admin?\n @clients = Client.all\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @clients }\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 @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 add_breadcrumb(I18n.t('model.list', model: Client.model_name.human))\n\n @clients = Client.all()\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clients }\n end\n end", "def index\n get_clientes\n end", "def index \n @clients = ApiClient.all\n end", "def show\n @clients = get_clients\n @client = Client.find(params[:id])\n\n respond_to do |format|\n #format.html # show.html.erb\n format.json { render json: @client }\n format.js\n end\n end", "def index_clients\n @client = Client.all\n end", "def clients_index\n @clients = User.clients\n end", "def index\n puts params\n puts params[:filter]\n \n @clients = get_clients \n @client = Client.new\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clients }\n end\n end", "def show\n @client = Client.find(params[:id])\n @contracts = Contract.where(:client_id => @client.id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @client }\n end\n end", "def show\n\t\t@client = Client.find(params[:id])\n\t\tif @client.status != 0\n\t\t\trender :json => @client, status: 200\n\t\telse\n\t\t\trender :json => @client.status, status: 400\n\t\tend\n\tend", "def show\n @clientsOffers = ClientsOffers.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clientsOffers }\n end\n end", "def index\r\n user = authenticate\r\n if user\r\n clients = Client.where('clientof = ?', user.id)\r\n render json: {clients: clients, message: 'Success', status: :ok}\r\n else\r\n render json: {message: 'Invalid token', status: :unauthorized}\r\n end\r\n end", "def index\n @clients = Client.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @client }\n end\n end", "def index\n \n @qa_clients = QaClient.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @qa_clients }\n end\n end", "def index\n @clients = current_user.is_admin ? Client.all : current_user.clients\n end", "def index\n @clients = current_user.account.clients.search(params[:search]).order(sort_column + \" \" + sort_direction).paginate(:per_page => 10, :page => params[:page])\n\n @account = current_user.account\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clients }\n end\n end", "def get_clients_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: AuthClientsApi.get_clients ...\"\n end\n # resource path\n local_var_path = \"/auth/clients\"\n\n # query parameters\n query_params = {}\n query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'order'] = opts[:'order'] if !opts[:'order'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2_client_credentials_grant', 'oauth2_password_grant']\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 => 'PageResourceClientResource')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: AuthClientsApi#get_clients\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def show\n @client = Client.find(params[:id])\n if @client.nil?\n @clients = Client.all\n flash.now[:alert] = \"Les détails du client n'ont pas été trouvés\"\n render \"index\"\n end\n respond_to do |format|\n format.html #show.html.erb\n format.xml { render :xml => @client }\n end\n end", "def index\n @page_count, @clients = Locomotive::Client.paginated(:page => (params[:page] || 1).to_i)\n display @clients\n end", "def client_list\n @clients.each do |item|\n puts \"List of clients:\"\n puts \"----------------------------------------------\"\n puts item.name\n end\n end", "def index\n @clients = Client.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @clients }\n end\n end", "def client(client, options = {})\n get(\"clients/#{client}\", options).pop\n end", "def show\n @client = Client.find(params[:id])\n respond_with(@client)\n end", "def show\n @client = Client.find(params[:id])\n respond_with(@client)\n end", "def all_clients\n resp = get CLIENT_API_PATH\n result = process_response(resp)\n return [] if result.empty? # In case response is {}\n result.each.map { |c| Resources::Client.new(c) }\n end", "def serialized_clients(_data)\n ActiveModel::ArraySerializer.new(_data, each_serializer: Api::V1::ClientsSerializer, root: 'clients')\n end", "def get_clients\n Client.get(:all).map{|c| c.to_ws}\n end", "def index\n @client_infos = ClientInfo.all\n end", "def show\n @client = Client.find(params[:id])\n authorize! :read, @client\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @client }\n end\n end", "def clients\r\n ClientsController.instance\r\n end", "def show\n @client = Client.find(params[:id])\n @uuid = params[:uuid]\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client }\n end\n end", "def show\n id = shift_argument || raise(Heroku::Command::CommandFailed, \"Usage: clients:show [ID]\")\n\n client = request do\n api.request(\n :expects => 200,\n :headers => headers,\n :method => :get,\n :path => \"/oauth/clients/#{CGI.escape(id)}\"\n ).body\n end\n\n if options[:shell]\n puts \"HEROKU_OAUTH_ID=#{client[\"id\"]}\"\n puts \"HEROKU_OAUTH_SECRET=#{client[\"secret\"]}\"\n else\n styled_header(%{Client \"#{client[\"name\"]}\".})\n styled_hash(client)\n end\n end", "def index\n @clients = Client.all.paginate(page: params[:page], per_page: 4)\n end", "def show\n\n @client = Client.find(params[:id])\n end", "def show\n @client = Client.find(params[:id])\n end", "def show\n @client = Client.find(params[:id])\n end", "def show\n @client = Client.find(params[:id])\n end", "def show\n @client = Client.find(params[:id])\n end", "def show\n @client = Client.find(params[:id])\n end", "def clients\n Harvest::Resources::Client\n end", "def show\n client= Client.find_by_id params[:id]\n if client != nil\n render(json: client, status: 200) \n else\n head 404\n end \n end", "def clients\n clis = []\n url = prefix + \"listc\"\n users = response(url)\n if users.class == Array #success\n users.each do |u|\n clis << User.new(u[\"id\"], @authid, @subdomain, u)\n end\n return clis\n else #failed\n return users\n end\n end", "def show\n @client = Client.find(params[:id])\n\n end", "def show\n @client = Client.find_by(id: params[:id])\n end", "def index\n @clientes = Cliente.all\n end", "def index\n @clientes = Cliente.all\n end", "def index\n @clientes = Cliente.all\n end", "def index\n @clientes = Cliente.all\n end", "def clients\n clients = []\n each { |rec| clients << rec[:client] }\n clients.uniq\n end", "def index\n @applicationclients = Applicationclient.all\n end", "def clients!\n @clients = search_clients clients_doc!\n end", "def index\n if @clients.count > 0\n @client = params[:client_id].blank? ? @clients[0] :\n Client.find_by_id(params[:client_id])\n @client = @clients[0] unless @client\n else\n @clients = Array.new\n end\n end", "def index\n @clients = Client.search(params[:search]).order(sort_column + \" \" + sort_direction).page(params[:page]).per(10)\n respond_with(@clients)\n end", "def clients\n Client.find_all_by_uuids( @members.map { |m| m['client_uuid'] } ) #rescue []\n end", "def get_client_by_id client_id\n @clients[client_id]\n end", "def show\n @api_client = ApiClient.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @api_client }\n end\n end", "def show\n @cliente = Cliente.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cliente }\n end\n end", "def show\n @cliente = Cliente.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cliente }\n end\n end", "def show\n @cliente = Cliente.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cliente }\n end\n end", "def index\n add_breadcrumb(I18n.t('model.list', model: Client.model_name.human))\n\n @clients = current_space.clients\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clients_grid }\n end\n end", "def clients\n @clients ||= search_clients clients_doc\n end", "def clients\n @clients ||= Harvest::API::Clients.new(credentials)\n end", "def index\n @apps = @client.apps\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @apps }\n end\n end" ]
[ "0.8153739", "0.80063516", "0.7787718", "0.7723655", "0.7567505", "0.7567505", "0.7552252", "0.74898314", "0.74426955", "0.7392605", "0.73510695", "0.7308904", "0.7292815", "0.7288331", "0.7288331", "0.7288331", "0.7288331", "0.7288331", "0.7288331", "0.7288331", "0.72777784", "0.7262758", "0.7262758", "0.7262758", "0.7262758", "0.7262758", "0.7262758", "0.7262758", "0.7262758", "0.7259375", "0.7255732", "0.7249349", "0.7229643", "0.7219946", "0.72115874", "0.71583647", "0.71478164", "0.7129887", "0.7117261", "0.70936006", "0.70791084", "0.70255953", "0.6929662", "0.6925695", "0.6914162", "0.68931085", "0.68685716", "0.6852543", "0.68520474", "0.68042296", "0.67752814", "0.6770067", "0.6742152", "0.67400545", "0.67364126", "0.6733337", "0.6732957", "0.6728584", "0.67280895", "0.67277414", "0.67277414", "0.6705845", "0.67055035", "0.67024124", "0.66981196", "0.6692535", "0.66914594", "0.66538125", "0.66442525", "0.66424763", "0.6635733", "0.66097313", "0.6608064", "0.6608064", "0.6608064", "0.6608064", "0.6605627", "0.65717447", "0.65539455", "0.65528524", "0.6544092", "0.65374035", "0.65374035", "0.65374035", "0.65374035", "0.6531604", "0.6529103", "0.6527591", "0.65138793", "0.65084696", "0.64964205", "0.6489253", "0.64873284", "0.6466735", "0.6466735", "0.6466735", "0.6466009", "0.64622515", "0.6455276", "0.64468354" ]
0.6951358
42
GET /clients/1 GET /clients/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @clients = current_user.clients\n render json: @clients\n end", "def show\n client = Client.retrieve_by_id(params[:id])\n\n render json: client, serializer: SingleClientSerializer\n end", "def index\n @clients = Client.all\n render json: @clients\n end", "def index\n @clients = Client.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clients }\n end\n end", "def index\n @clients = Client.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clients }\n end\n\n end", "def index\n @clients = Client.all\n @uuid = params[:uuid]\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clients }\n end\n end", "def show\n @client = Client.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client }\n end\n end", "def show\n @client = Client.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client }\n end\n end", "def show\n @client = Client.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client }\n end\n end", "def show\n @client = Client.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client }\n end\n end", "def show\n @client = Client.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client }\n end\n end", "def show\n @client = Client.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client }\n end\n end", "def show\n @client = Client.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client }\n end\n end", "def show\n @client = clients.find(params[:id])\n end", "def show\r\n @client = Client.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @client }\r\n end\r\n end", "def index\n sanitized_params = parse_params(client_where_params)\n clients = Client.find_all(sanitized_params)\n render json: clients\n end", "def index\n render json: Client.all\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 show\n render json: @client\n end", "def show\n\t\t@client = Client.find(params[:id])\n\t\tif @client.status != 0\n\t\t\trender :json => @client, status: 200\n\t\telse\n\t\t\trender :json => @client.status, status: 400\n\t\tend\n\tend", "def details\n response = CreateSend.get \"/clients/#{client_id}.json\", {}\n Hashie::Mash.new(response)\n end", "def get_clients\n @clients\n end", "def get_clients\n @clients\n end", "def show\n @client = Client.find(params[:id])\n @uuid = params[:uuid]\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client }\n end\n end", "def index\n @clients = Client.all\n end", "def index\n @clients = Client.all\n end", "def index\n @clients = Client.all\n end", "def index\n @clients = Client.all\n end", "def index\n @clients = Client.all\n end", "def index\n @clients = Client.all\n end", "def index\n @clients = Client.all\n end", "def index\n @clients = Client.all\n end", "def show\n @clients = get_clients\n @client = Client.find(params[:id])\n\n respond_to do |format|\n #format.html # show.html.erb\n format.json { render json: @client }\n format.js\n end\n end", "def index\n @clients = Client.all\n end", "def clients\n @clients = Vendor.find(params[:id]).clients\n end", "def show\n\n @client = Client.find(params[:id])\n end", "def show\n @client = Client.find(params[:id])\n @contracts = Contract.where(:client_id => @client.id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @client }\n end\n end", "def show\n @client = Client.find(params[:id])\n end", "def show\n @client = Client.find(params[:id])\n end", "def show\n @client = Client.find(params[:id])\n end", "def show\n @client = Client.find(params[:id])\n end", "def show\n @client = Client.find(params[:id])\n end", "def recent\n if current_user.is_admin?\n @clients = Client.all\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @clients }\n end\n end", "def show\n @client = Client.find_by(id: params[:id])\n end", "def index\n add_breadcrumb(I18n.t('model.list', model: Client.model_name.human))\n\n @clients = Client.all()\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clients }\n end\n end", "def show\n @client = Client.find(params[:id])\n\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 show\n client= Client.find_by_id params[:id]\n if client != nil\n render(json: client, status: 200) \n else\n head 404\n end \n end", "def show\n @client = Client.find(params[:id])\n respond_with(@client)\n end", "def show\n @client = Client.find(params[:id])\n respond_with(@client)\n end", "def index\n @clients = Client.where(params.except(:action, :controller, :format)).to_a # TODO: remove .to_a when Rails to_json bug fixed\n respond_with(@clients)\n end", "def client(client, options = {})\n get(\"clients/#{client}\", options).pop\n end", "def show\n @clientsOffers = ClientsOffers.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clientsOffers }\n end\n end", "def index\n if @clients.count > 0\n @client = params[:client_id].blank? ? @clients[0] :\n Client.find_by_id(params[:client_id])\n @client = @clients[0] unless @client\n else\n @clients = Array.new\n end\n end", "def list_clients(json_payload={})\n conn = @client.get do |req|\n req.url \"/api/v2/client/list?\"\n req.headers[\"Authorization\"] = @token\n req.params = json_payload\n end\n conn.body\n end", "def index\n get_clientes\n end", "def index \n @clients = ApiClient.all\n end", "def show\n @client = Client.find params[:id]\n end", "def index_clients\n @client = Client.all\n end", "def get_client_by_id client_id\n @clients[client_id]\n end", "def index\n @clients = Client.page(params[:page] || 1).per(10)\n end", "def show\n @client = Client.find(params[:id])\n authorize! :read, @client\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @client }\n end\n end", "def index\n puts params\n puts params[:filter]\n \n @clients = get_clients \n @client = Client.new\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clients }\n end\n end", "def show\n @client = Client.find(params[:id])\n if @client.nil?\n @clients = Client.all\n flash.now[:alert] = \"Les détails du client n'ont pas été trouvés\"\n render \"index\"\n end\n respond_to do |format|\n format.html #show.html.erb\n format.xml { render :xml => @client }\n end\n end", "def show\n id = shift_argument || raise(Heroku::Command::CommandFailed, \"Usage: clients:show [ID]\")\n\n client = request do\n api.request(\n :expects => 200,\n :headers => headers,\n :method => :get,\n :path => \"/oauth/clients/#{CGI.escape(id)}\"\n ).body\n end\n\n if options[:shell]\n puts \"HEROKU_OAUTH_ID=#{client[\"id\"]}\"\n puts \"HEROKU_OAUTH_SECRET=#{client[\"secret\"]}\"\n else\n styled_header(%{Client \"#{client[\"name\"]}\".})\n styled_hash(client)\n end\n end", "def index\n clients = request do\n api.request(\n :expects => 200,\n :headers => headers,\n :method => :get,\n :path => \"/oauth/clients\"\n ).body\n end\n styled_header(\"OAuth Clients\")\n styled_array(clients.map { |client|\n [client[\"name\"], client[\"id\"], client[\"redirect_uri\"]]\n })\n end", "def show\n @client = Client.find params[:client_id]\n end", "def index\n @clients = Client.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @client }\n end\n end", "def clients\n response = User_GetClients()\n return [] if response.empty?\n unless response[\"Code\"].to_i != 0\n response[\"Client\"].collect{|c| Client.new(c[\"ClientID\"].to_i, c[\"Name\"])}\n else\n raise response[\"Code\"] + \" - \" + response[\"Message\"]\n end\n end", "def show\n @client_number = ClientNumber.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client_number }\n end\n end", "def show\n @api_client = ApiClient.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @api_client }\n end\n end", "def show\n # @client = Client.find(params[:client_id])\n end", "def index\n @client_infos = ClientInfo.all\n end", "def show\n @client_need = ClientNeed.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client_need }\n end\n end", "def clients_index\n @clients = User.clients\n end", "def client_detail\n service_response = UserManagement::GetClientDetail.new(params).perform\n render_api_response(service_response)\n end", "def show\n @cliente = Cliente.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cliente }\n end\n end", "def show\n @cliente = Cliente.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cliente }\n end\n end", "def show\n @cliente = Cliente.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cliente }\n end\n end", "def index\n @clients = Client.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @clients }\n end\n end", "def new\n @client = Client.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @client }\n end\n end", "def new\n @client = Client.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @client }\n end\n end", "def new\n @client = Client.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @client }\n end\n end", "def new\n @client = Client.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @client }\n end\n end", "def index\n \n @qa_clients = QaClient.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @qa_clients }\n end\n end", "def client_by_name(client_name, options={})\n params = {\n :klass => Invoicexpress::Models::Client,\n :client_name => client_name\n }\n\n get(\"clients/find-by-name.xml\", params.merge(options))\n end", "def show\n @my_studio_client = MyStudio::Client.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @my_studio_client }\n end\n end", "def show\n @client = Client.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @client }\n end\n end", "def client_list\n @clients.each do |item|\n puts \"List of clients:\"\n puts \"----------------------------------------------\"\n puts item.name\n end\n end", "def clients\r\n ClientsController.instance\r\n end", "def index\n @page_count, @clients = Locomotive::Client.paginated(:page => (params[:page] || 1).to_i)\n display @clients\n end", "def show\n @blocking_client = BlockingClient.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @blocking_client }\n end\n end", "def index\n @clients = current_user.account.clients.search(params[:search]).order(sort_column + \" \" + sort_direction).paginate(:per_page => 10, :page => params[:page])\n\n @account = current_user.account\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clients }\n end\n end", "def index\n @clients = Client.all.paginate(page: params[:page], per_page: 4)\n end", "def show\n @client = Client.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @client }\n end\n end", "def show\n @client = Client.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @client }\n end\n end", "def show\n @client = Client.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @client }\n end\n end", "def show\n @cliente = Cliente.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cliente }\n end\n end", "def show\n @client_type = ClientType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client_type }\n end\n end", "def show_client_name\n @clients = Client.order(:name)\n end", "def show\n @player_client = PlayerClient.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @player_client }\n end\n end" ]
[ "0.77151686", "0.7692742", "0.76121694", "0.76004916", "0.75575113", "0.755476", "0.752935", "0.752935", "0.752935", "0.752935", "0.752935", "0.752935", "0.752935", "0.7514162", "0.74707705", "0.7333753", "0.7307614", "0.7303017", "0.72995025", "0.7250661", "0.7203704", "0.7171568", "0.7171568", "0.71102506", "0.70843935", "0.70843935", "0.70843935", "0.70843935", "0.70843935", "0.70843935", "0.70843935", "0.70843935", "0.704313", "0.7040381", "0.70358586", "0.70218045", "0.7009596", "0.7008099", "0.70063454", "0.70063454", "0.70063454", "0.70063454", "0.6995464", "0.6968148", "0.69642144", "0.69568175", "0.6953349", "0.69522655", "0.69481176", "0.69481176", "0.6938673", "0.69104326", "0.6905667", "0.6902351", "0.6896804", "0.6891922", "0.68601125", "0.68504554", "0.6836542", "0.6831088", "0.6830472", "0.6822119", "0.6809127", "0.67781234", "0.67500174", "0.67341346", "0.6729087", "0.67201155", "0.67046773", "0.66985166", "0.6681257", "0.66732234", "0.66197157", "0.66104084", "0.6608874", "0.6608714", "0.66008717", "0.66008717", "0.66008717", "0.65942836", "0.6591368", "0.6591368", "0.6591368", "0.6591368", "0.65854293", "0.6557645", "0.6555167", "0.6529309", "0.6522679", "0.65144825", "0.65083075", "0.65045846", "0.6501457", "0.6490616", "0.6487846", "0.6487846", "0.64872134", "0.6479357", "0.646814", "0.64457077", "0.64439553" ]
0.0
-1
POST /clients POST /clients.json
def create @client = Client.new(client_params) respond_to do |format| begin ActiveRecord::Base.transaction do @client.save! @address = Address.new(address_params) @address.client_id = @client.id @address.save! end format.html { redirect_to @client, notice: 'Client was successfully created.' } format.json { render :show, status: :created, location: @client } rescue format.html { render :new } format.json { render json: @client.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @client = Client.new(client_params)\n\n respond_to do |format|\n if @client.save\n format.html { redirect_to clients_url, notice: 'El cliente se creó correctamente' }\n format.json { render :index, status: :created, location: @client }\n else\n format.html { render :new }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @client = current_user.clients.build(client_params)\n\n respond_to do |format|\n if @client.save\n format.html { redirect_to @client, notice: 'Client was successfully created.' }\n format.json { render :show, status: :created, location: @client }\n else\n format.html { render :new }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @client = Client.new(params[:client])\n\n respond_to do |format|\n if @client.save\n format.html { redirect_to clients_path, notice: 'Client was successfully created.' }\n format.json { render json: @client, status: :created, location: @client }\n else\n format.html { render action: \"new\" }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @client = current_user.clients.build(client_params)\n \n respond_to do |format|\n if @client.save\n format.html { redirect_to @client, notice: 'Client was successfully created.' }\n format.json { render :show, status: :created, location: @client }\n else\n format.html { render :new }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @client = Client.new(client_params)\n\n respond_to do |format|\n if @client.save\n format.html { redirect_to clients_path, notice: 'Client was successfully created.' }\n format.json { render :show, status: :created, location: @client }\n else\n format.html { render :new }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @client = Client.new(params[:client])\n\n respond_to do |format|\n if @client.save\n format.html { redirect_to @client, notice: 'Client was successfully created.' }\n format.json { render json: @client, status: :created, location: @client }\n else\n format.html { render action: \"new\" }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @client = Client.new(params[:client])\n\n respond_to do |format|\n if @client.save\n format.html { redirect_to @client, notice: 'Client was successfully created.' }\n format.json { render json: @client, status: :created, location: @client }\n else\n format.html { render action: \"new\" }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @client = Client.new(params[:client])\n\n respond_to do |format|\n if @client.save\n format.html { redirect_to @client, notice: 'Client was successfully created.' }\n format.json { render json: @client, status: :created, location: @client }\n else\n format.html { render action: \"new\" }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @client = Client.new(client_params)\n\n respond_to do |format|\n if @client.save\n format.html { redirect_to @client, notice: 'client was successfully created.' }\n format.json { render :show, status: :created, location: @client }\n else\n format.html { render :new }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @client = Client.new(client_params)\n\n respond_to do |format|\n if @client.save\n format.html { redirect_to @client, notice: 'Client was successfully created.' }\n format.json { render :show, status: :created, location: @client }\n else\n format.html { render :new }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @client = Client.new(client_params)\n\n respond_to do |format|\n if @client.save\n format.html { redirect_to @client, notice: 'Client was successfully created.' }\n format.json { render :show, status: :created, location: @client }\n else\n format.html { render :new }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @client = Client.new(client_params)\n\n respond_to do |format|\n if @client.save\n format.html { redirect_to @client, notice: 'Client was successfully created.' }\n format.json { render :show, status: :created, location: @client }\n else\n format.html { render :new }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @client = Client.new(client_params)\n respond_to do |format|\n if @client.save\n format.html { redirect_to @client, notice: 'Client was successfully created.' }\n format.json { render :show, status: :created, location: @client }\n else\n format.html { render :new }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n #newParams = client_params.as_json\n flash[:notice] = \"Cliente creado\"\n @client = current_freelance.clients.create(client_params)\n\n #@client = current_freelance.clients\n #@client.name = params[:name]\n #@client.surname = params[:surname]\n #@client.username = params[:username]\n #@client.password = params[:password]\n\n respond_to do |format|\n if @client.save\n format.html { redirect_to clients_path, notice: 'Client was successfully created.' }\n #format.json { render :show, status: :created, location: @client }\n else\n format.html { render :new }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @client = Client.new(client_params)\n\n respond_to do |format|\n if @client.save\n format.html { redirect_to @client, notice: \"Client was successfully created.\" }\n format.json { render :show, status: :created, location: @client }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @client = Client.create(client_params)\n # byebug\n if @client.valid?\n render json: { client: ClientSerializer.new(@client) }, status: :created\n else\n render json: { error: 'failed to create account' }, status: :not_acceptable\n end \n end", "def create\n @client = Client.new(params[:client])\n\n respond_to do |format|\n if @client.save \n format.html { redirect_to @client, :notice => 'Klijent je uspjesno kreiran.' }\n format.json { render :json => @client, :status => :created, :location => @client }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @client.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @client = Client.new(client_params)\n\n respond_to do |format|\n if @client.save\n format.html { redirect_to @client, notice: 'Cliente cadastrado com sucesso!' }\n format.json { render :show, status: :created, location: @client }\n else\n format.html { render :new }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @client = Client.create(client_params)\n @clients = Client.all\n flash[:notice]=\"client créé avec succès!!!\"\n end", "def create\n @client = current_user.clients.new(client_params)\n\n respond_to do |format|\n if @client.save\n format.html { redirect_to @client, notice: 'Event was successfully created.' }\n format.json { render :show, status: :created, location: @client }\n else\n format.html { render :new }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @client = current_user.clients.build(client_params)\n\n if @client.save\n render :create, status: :created\n CareeerMailer.trial_end(current_user.email, @client).deliver_later\n CareeerMailer.welcome(current_user.email, @client).deliver_later\n else\n render json: @client.errors, status: :unprocessable_entity\n end\n end", "def create\n @client = Client.new(params[:client])\n flash[:notice] = 'Client was successfully created.' if @client.save\n respond_with(@client)\n end", "def create\n @client = Client.new(client_params)\n\n respond_to do |format|\n if @client.save\n format.html { redirect_to @client, notice: 'Cliente criado com sucesso.' }\n format.json { render :show, status: :created, location: @client }\n else\n format.html { render :new }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_client(options = {})\n post(:clients, clients: [options]).pop\n end", "def create\n @client = Client.new(client_params)\n @client.user_id = current_user.id\n respond_to do |format|\n if @client.save\n format.html { redirect_to @client, notice: 'Client record was successfully created.' }\n format.json { render :show, status: :created, location: @client }\n else\n format.html { render :new }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @client = current_user.clients.new(client_params)\n\n @client.save\n redirect_to @client\n end", "def create\n\n @client = Client.new(client_params)\n\n #se não aguardar carregar os dados\n if @client.state == '...'\n sweetalert_warning('Você precisa informar o CEP e aguardar os dados do endereço serem preenchidos.', 'Aviso!', useRejections: false)\n redirect_to new_client_path and return\n end\n\n respond_to do |format|\n if @client.save\n format.html { redirect_to @client, notice: 'Cliente criado com sucesso.' }\n format.json { render :show, status: :created, location: @client }\n sweetalert_success('Cliente cadastrado com sucesso.', 'Sucesso!', useRejections: false)\n else\n format.html { render :new }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @client = Client.new(params[:client])\n \n respond_to do |format|\n if @client.save\n format.html { redirect_to(@client, :notice => \"Client was successfully created. #{undo_link}\") }\n end\n respond_with(@client)\n end\n end", "def create\n @client = Client.new(client_params)\n authorize @client\n respond_to do |format|\n if @client.save\n format.html { redirect_back_or_default clients_url, t('Record has been saved') }\n format.json { render :show, status: :created, location: @client }\n format.js { render :show, status: :created, location: @client }\n else\n format.html { render :new }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n format.js { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @client = Client.new(params[:client])\n @client.campaign_id = session[:campaign_id]\n @groups = Group.all.map {|g| [g.name, g.id]}\n\n respond_to do |format|\n if @client.save\n format.html { redirect_to @client, :notice => 'Client was successfully created.' }\n format.json { render :json => @client, :status => :created, :location => @client }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @client.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n\n client = Cliente.new\n\n client.nombre = params[:nombre]\n client.cedula = params[:cedula]\n client.pagina = params[:pagina]\n\n client.dirrecion = params[:dirrecion]\n client.telefono = params[:telefono]\n \n client.sector = params[:sector]\n \n\n if client.save\n \n\n render(json: client,status: 201 ,location: client)\n else\n\n render(json: client.errors,status: 422 )\n\n end\n end", "def create\n client= Client.new\n client.cedula= params[:cedula]\n client.sector= params[:sector]\n client.nombre= params[:nombre]\n client.telefono= params[:telefono]\n client.pagina= params[:pagina]\n client.direccion= params[:direccion]\n if client.save\n render(json: client, status: 201 , location: client)\n else \n render(json: client.errors, status: 422)\n end\n end", "def create\n @clientsOffers = ClientsOffers.new(params[:clientsOffers])\n\n respond_to do |format|\n if @clientsOffers.save\n format.html { redirect_to @clientsOffers, notice: 'ClientsOffers was succesfully created.' }\n format.json { render json: @clientsOffers, status: :created, location: @clientsOffers }\n else\n format.html { render action: \"new\" }\n format.json { render json: @clientsOffers.errors, status: :unprocesable_entity }\n end\n end\n end", "def create(client)\n @client = Locomotive::Client.new(client)\n\n if @client.save\n redirect resource(@client), :message => {:notice => \"Client was successfully created\"}\n else\n render :new\n end\n end", "def create\r\n params[:client][:version] = ENV[\"VERSION\"]\r\n params[:client][:domain] = current_user.domain\r\n params[:client][:username] = current_user.username\r\n @client = Client.new(client_params)\r\n\r\n respond_to do |format|\r\n if @client.save\r\n format.html { redirect_to @client, notice: 'Client was successfully created.' }\r\n format.json { render json: @client, status: :created, location: @client }\r\n format.js {}\r\n else\r\n format.html { render action: \"new\" }\r\n format.json { render json: @client.errors, status: :unprocessable_entity }\r\n format.js {}\r\n end\r\n end\r\n end", "def create\n @clients = get_clients\n @client = Client.new(params[:client])\n\n respond_to do |format|\n if @client.save\n @clients = get_clients\n newVisitOnCreate(@client)\n #format.html { redirect_to @client, notice: 'Client was successfully created.' }\n format.json { render json: @client, status: :created, location: @client }\n format.js\n else\n #format.html { render action: \"index\" }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n format.js\n end\n end\n end", "def create\n @client = Client.new(params[:client])\n\n respond_to do |format|\n if @client.save\n format.html { redirect_to @client, notice: 'Client was successfully created.' }\n format.json { render json: @client, status: :created, location: @client }\n format.js\n else\n format.html { render action: \"new\" }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n format.js\n end\n end\n end", "def create\n @client = Client.new(client_params)\n authorize! :create, @client\n\n respond_to do |format|\n if not @client.caseworker.can_add_clients?\n @client.errors[:base] << \"You are past your limit. Please come back later.\"\n format.html { render :action => \"new\" }\n format.json { render :json => @client.errors, :status => :unprocessable_entity }\n elsif @client.save\n format.html { redirect_to @client, :notice => 'Client was successfully created.' }\n format.json { render :json => @client, :status => :created, :location => @client }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @client.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @client = Client.new(client_params)\n respond_to do |format|\n # if @client.valid? \n if @client.save\n format.html { redirect_to @client, notice: 'Client was successfully created.' }\n format.json { render :show, status: :created, location: @client }\n else\n format.html { render :new }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n # else\n # format.html { render :new }\n # format.json { render json: @client.errors, status: :unprocessable_entity }\n # end\n end\n end", "def create\n @client = Client.new(params[:client])\n\n respond_to do |format|\n if @client.save\n format.html { redirect_to(@client, :notice => 'Client was successfully created.') }\n format.xml { render :xml => @client, :status => :created, :location => @client }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @client.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n #create the object of client and assign the attributes in the request\n @client = Client.new(params[:client])\n \n #save the client\n if @client.save\n #if saved, return and redirect to client show page with success message\n return redirect_to client_path(@client), notice: \"client created successfuly\"\n else\n #if not saved, render the form with error messages\n return render action: :new\n end\n end", "def create\n @client = Client.new(params[:client])\n\n respond_to do |format|\n if @client.save\n\t\tClientMailer.registration_confirmation(@client).deliver\n\t\tCountry.create!({'clientkey'=>@client.id, 'country'=>@client.country})\n format.html { redirect_to @client, notice: 'Client was successfully created.' }\n format.json { render json: @client, status: :created, location: @client }\n else\n format.html { render action: \"new\" }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_client(name, facebook_id, twitter_handle)\n puts name, facebook_id, twitter_handle\n # Point the HTTP POST method at the clients endpoint of Klipfolio's API.\n response = self.class.post(\"https://app.klipfolio.com/api/1.0/clients\", basic_auth: @auth, headers: { \"Content-Type\" => \"application/json\" },\n body: {\n \"name\": name,\n \"description\": \"\",\n \"seats\": 5,\n \"status\": \"active\"\n }.to_json)\n puts response.body\n puts \"Client was successfully created.\" if response.success?\n\n # Extract the new client's ID from the HTTP response so that it can be passed to the update_features & update_resources methods.\n client_id = response[\"meta\"][\"location\"]\n client_id.slice!(\"/clients/\")\n p client_id\n\n update_resources(client_id)\n update_features(client_id)\n update_company_properties(client_id, facebook_id, twitter_handle)\n create_group(client_id)\n share_dashboard(client_id)\n end", "def create\n @client = clients.new(params[:client])\n\n if @client.save\n flash[:notice] = 'Customer was successfully created.'\n redirect_to(user_company_clients_url(current_company))\n else\n render :action => \"new\"\n end\n end", "def create\n @client = Client.new(client_params)\n\n respond_to do |format|\n if @client.save\n password = params[:password] || random_password\n @client.user.update(password: password)\n\n ClientMailer.after_sign_up(@client, password).deliver_now\n format.html { redirect_to clients_path, notice: \"Client: #{@client.email} was sucessfully created.\" }\n # format.json { render :show, status: :created, location: @client }\n else\n format.html { render :new }\n # format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @client = Client.new(client_params)\n respond_to do |format|\n if @client.save\n format.html { redirect_to(@client, :notice => 'Client was successfully created.') }\n format.xml { render :xml => @client, :status => :created, :location => @client }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @client.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n\t\t@client = User.create(clients_params)\n\t\tif @client.save\n flash[:success] = \"Record saved successfully.\"\n\t\t\tredirect_to clients_params\n else\n @error = @client.errors.full_messages\n redirect_to clients_params\n\t\tend\n\tend", "def index\n @clients = current_user.clients\n render json: @clients\n end", "def create\n @id = client_params[:id].to_i\n @message = ''\n\n if @id.nil? || @id == 0\n @client = Client.new(client_params)\n else\n @client = Client.find_by_id(@id)\n end\n\n if @client.valid?\n if @client.id == 0 || @client.id.nil? \n @client.save()\n else\n @client.update(client_params)\n end\n else\n @message = @client.errors.messages\n end\n\n render json:{client: @client, message: @message}\n end", "def create\n @client = Client.new(client_params)\n\n respond_to do |format|\n if @client.save\n format.html { redirect_to(@client, :notice => 'Le client a bien été créé.') }\n format.xml { render :xml => @client, :status => :created, :location => @client }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @client.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create_client\n if current_admin.present?\n @client = Client.new(params[:client])\n respond_to do |format|\n if @client.save\n flash[:notice] = \"Client has been successfully added!\"\n format.html { redirect_to root_url }\n format.json { render json: @client, status: :created, location: @client }\n else\n format.html { render action: \"new\" }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n else\n redirect_to new_admin_session_path and return\n end \n end", "def create\n @client = Client.new(params[:client])\n\n respond_to do |format|\n if @client.save\n flash[:notice] = 'Client was successfully created.'\n format.html { redirect_to(@client) }\n format.xml { render :xml => @client, :status => :created, :location => @client }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @client.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @client = Client.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @client }\n end\n end", "def new\n @client = Client.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @client }\n end\n end", "def new\n @client = Client.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @client }\n end\n end", "def new\n @client = Client.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @client }\n end\n end", "def create\n @client = Client.new(client_params)\n\n if @client.save\n redirect_to @client, notice: 'Client was successfully created.'\n else\n render :new\n end\n end", "def client_create(global_options, options)\n result = Excon.post(\n \"#{global_options[:fenton_server_url]}/clients.json\",\n body: client_json(options),\n headers: { 'Content-Type' => 'application/json' }\n )\n\n [result.status, JSON.parse(result.body)]\n end", "def create\n @client = Client.new(params[:client])\n \n respond_to do |format|\n if @client.save\n flash[:notice] = 'Client was successfully created.'\n format.html { redirect_to client_url(@role) }\n format.xml { head :created, :location => client_url(@role) }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @client.errors.to_xml }\n end\n end\n end", "def create\n @client = Client.new(params[:client])\n\t\[email protected] = false\n if @client.save\n redirect_to signup_clients_path, notice: 'Client was successfully created!'\n else\n render action: \"new\"\n end\n end", "def create\n authorize! :create, Client\n build_client\n save_client or render :new\n end", "def create\n @client = Client.new(client_params)\n\n respond_to do |format|\n if @client.save\n\n format.js\n\n format.html { redirect_to root_path, notice: 'Vous avez bien été ajouté à notre newsletter' }\n\n format.json { render :show, status: :created, location: @client }\n\n else\n\n format.html { render :new }\n\n format.json { render json: @client.errors, status: :unprocessable_entity }\n\n end\n end\n end", "def serialized_clients(_data)\n ActiveModel::ArraySerializer.new(_data, each_serializer: Api::V1::ClientsSerializer, root: 'clients')\n end", "def create\n @client = Client.new(params[:client])\n @uuid = params[:uuid]\n respond_to do |format|\n if @client.save\n format.html { redirect_to :controller => 'ads', :action => 'admin_dash', :id => 1, :uuid => @uuid, notice: 'Client was successfully created.' }\n format.json { render json: @client, status: :created, location: @client }\n else\n format.html { render action: \"new\" }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @clientes_servico = ClientesServico.new(clientes_servico_params)\n\n respond_to do |format|\n if @clientes_servico.save\n format.html { redirect_to @clientes_servico, notice: 'Clientes servico was successfully created.' }\n format.json { render action: 'show', status: :created, location: @clientes_servico }\n else\n format.html { render action: 'new' }\n format.json { render json: @clientes_servico.errors, status: :unprocessable_entity }\n end\n end\n end", "def client_params\n params.require(:client).permit(:name, :recruiter_id, :user_ids => [])\n end", "def create\n @members_client = MembersClient.new(members_client_params)\n\n respond_to do |format|\n if @members_client.save\n format.html { redirect_to @members_client, notice: 'Members client was successfully created.' }\n format.json { render :show, status: :created, location: @members_client }\n else\n format.html { render :new }\n format.json { render json: @members_client.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @client = Client.new(client_params)\n\n respond_to do |format|\n if @client.save\n format.html { redirect_to admin_client_path(@client, search: params[:search], page: params[:page]),\n notice: 'Клиент успешно создан.' }\n format.json { render :show, status: :created, location: @client }\n else\n format.html { render :new }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @client = Client.new(params[:client])\n\n if @client.password == nil then @client.password = temp_password && @client.password_confirmation = temp_password end\n password = @client.password\n\n respond_to do |format|\n if @client.save\n ClientMailer.new_client(@client, password).deliver\n format.html { redirect_to project_url(:id => @client.project_id, :page => 'options'), notice: 'Client was successfully created.' }\n format.json { render json: @client, status: :created, location: @client }\n else\n format.html { render action: \"new\" }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @invoice_client = InvoiceClient.new(invoice_client_params)\n\n respond_to do |format|\n if @invoice_client.save\n format.html { redirect_to @invoice_client, notice: 'Invoice client was successfully created.' }\n format.json { render :show, status: :created, location: @invoice_client }\n else\n format.html { render :new }\n format.json { render json: @invoice_client.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\n @client = Client.new(client_params)\n @client.business_owner_id = helpers.current_business_owner.id\n\n if @client.save\n flash[:notice] = \"#{@client.name} was added as a new client.\"\n redirect_to clients_path\n else\n render :new\n end\n end", "def create\n @client = Client.new(client_params)\n \n if @client.valid?\n code = Random.new\n @client.code = code.rand(1000)\n old_password = @client.password\n @client.password = SecureRandom.hex(6)\n status = ApiClient.save(@client)\n\n if status\n @user = User.create(\n name: @client.name,\n email: @client.email,\n password: old_password,\n password_salt: @client.password,\n client_id: @client.code\n )\n end\n end\n\n respond_to do |format|\n if status\n format.html { redirect_to client_path(@client.code), notice: 'Client was successfully created.' }\n format.json { render action: 'show', status: :created, location: @client }\n else\n format.html { render action: 'new', notice: 'Could not create a client.' }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @clients = Client.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clients }\n end\n end", "def create\n @cliente = Cliente.new(params[:cliente])\n\n respond_to do |format|\n if @cliente.save\n format.html { redirect_to @cliente, notice: 'Cliente was successfully created.' }\n format.json { render json: @cliente, status: :created, location: @cliente }\n else\n format.html { render action: \"new\" }\n format.json { render json: @cliente.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @cliente = Cliente.new(params[:cliente])\n\n respond_to do |format|\n if @cliente.save\n format.html { redirect_to @cliente, notice: 'Cliente was successfully created.' }\n format.json { render json: @cliente, status: :created, location: @cliente }\n else\n format.html { render action: \"new\" }\n format.json { render json: @cliente.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @clients = Client.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clients }\n end\n\n end", "def client_params\n params.require(:client).permit(\n :name,\n )\n end", "def index\n @clients = Client.all\n render json: @clients\n end", "def create\n @client = current_client\n @session = @client.session\n debug { \"SessionsController#create - #{@session.inspect}\"}\n raise \"ResourceOwner from token != session.owner\" if doorkeeper_token.resource_owner_id != @session.owner.id\n\n @client.update_attributes!(client_params)\n render json: @client, status: :created, serializer: Sso::ClientSerializer\n end", "def client_params\n params.require(:client).permit(:nombre, :direccion, :telefono, :email)\n end", "def create\n @cliente = Cliente.new(params[:cliente])\n \n respond_to do |format|\n if @cliente.save\n format.html { redirect_to edit_cliente_path(@cliente), notice: 'Cliente was successfully created.' }\n format.json { render json: @cliente , status: :created, location: @cliente }\n else\n format.html { render action: \"new\" }\n format.json { render json: @cliente.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @cliente = Cliente.new(params[:cliente])\n\n respond_to do |format|\n if @cliente.save\n format.html { redirect_to @cliente, notice: 'Cliente criado com sucesso.' }\n format.json { render json: @cliente, status: :created, location: @cliente }\n else\n format.html { render action: \"new\" }\n format.json { render json: @cliente.errors, status: :unprocessable_entity }\n end\n end\n end", "def client_params\n params.require(:client).permit!\n end", "def client_params\n params.require(:client).permit!\n end", "def create_client(client, options={})\n if !client || !client.is_a?(Invoicexpress::Models::Client)\n raise ArgumentError, \"Need a Invoicexpress::Models::Client instance\"\n end\n\n if !client.name\n raise ArgumentError, \"Client's name is required\"\n end\n\n params = { :body => client, :klass => Invoicexpress::Models::Client }\n post(\"clients.xml\", params.merge(options))\n end", "def create\n\n @client = Client.new(client_params)\n if @client.save\n respond_to do |format|\n format.html { redirect_to(clients_path, :notice => 'Le client « ' + @client.Prenom + ' ' + @client.Nom + ' » a été crée') }\n end\n else\n render :new\n end\n end", "def index\n @clients = Client.all\n @uuid = params[:uuid]\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @clients }\n end\n end", "def update\n @client.update(client_params)\n render json: @client\n end", "def create_client\n\nend", "def create\n @client = Client.new(client_params)\n if @client.save\n redirect_to client_path(@client)\n else\n render ‘new’\n end\n end", "def create\n @cliente = Cliente.new(cliente_params)\n\n respond_to do |format|\n if @cliente.save\n format.html { redirect_to @cliente, notice: 'El cliente se creó exitosamente.' }\n format.json { render :show, status: :created, location: @cliente }\n else\n format.html { render :new }\n format.json { render json: @cliente.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @cliente = Cliente.new(cliente_params)\n\n respond_to do |format|\n if @cliente.save\n format.html { redirect_to @cliente, notice: 'Cliente criado com sucesso.' }\n format.json { render :show, status: :created, location: @cliente }\n else\n format.html { render :new }\n format.json { render json: @cliente.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_client\n\n\t\t@clients = Client.new(client_params)\n\t\tif @clients.save\n\t\t\tredirect_to '/details'\n\t\telse\n\t\t\trender 'index'\n\t\tend\n\tend", "def create\n @client_user = ClientUser.new(client_user_params)\n\n respond_to do |format|\n if @client_user.save\n format.html { redirect_to @client_user, notice: 'Client user was successfully created.' }\n format.json { render :show, status: :created, location: @client_user }\n else\n format.html { render :new }\n format.json { render json: @client_user.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @player_client = PlayerClient.new(params[:player_client])\n\n respond_to do |format|\n if @player_client.save\n format.html { redirect_to @player_client, notice: 'Player client was successfully created.' }\n format.json { render json: @player_client, status: :created, location: @player_client }\n else\n format.html { render action: \"new\" }\n format.json { render json: @player_client.errors, status: :unprocessable_entity }\n end\n end\n end", "def client_params\n params.require(:client).permit(:name, :password, :password_confirmation)\n end", "def create\n @client = Client.new(params[:client])\n respond_to do |format|\n if @client.save\n @user = @client.complete_user\n flash[:notice] = 'Client was successfully created.'\n set_login_cookie(@user.get_psv)\n format.html { redirect_to(settings_path()) }\n format.xml { render :xml => @client, :status => :created, :location => @client }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @client.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @client = Client.new\n @account = current_user.account\n @user = current_user\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @client }\n end\n end", "def create\n @qa_client = QaClient.new(params[:qa_client])\n\n respond_to do |format|\n if @qa_client.save\n format.html { redirect_to @qa_client, notice: 'Qa client was successfully created.' }\n format.json { render json: @qa_client, status: :created, location: @qa_client }\n else\n format.html { render action: \"new\" }\n format.json { render json: @qa_client.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_client\n name = get_answer_to(\"What is the client\\'s name?\")\n age = get_answer_to(\"What is the client\\'s age?\")\n new_client = Clients.new(name, age)\n @clients << new_client\n end" ]
[ "0.72085994", "0.71753484", "0.7120956", "0.7116921", "0.710099", "0.6981326", "0.6981326", "0.6981326", "0.6979284", "0.6971666", "0.6971666", "0.6971666", "0.6970004", "0.69603", "0.6956069", "0.69386387", "0.69206727", "0.691133", "0.689539", "0.6878896", "0.6864519", "0.68514645", "0.6848104", "0.68280786", "0.68258786", "0.67249995", "0.6631503", "0.6616964", "0.6615913", "0.6600805", "0.65753627", "0.6568949", "0.65436697", "0.65353733", "0.65334564", "0.6531048", "0.6502263", "0.6499667", "0.64883107", "0.64827263", "0.6479907", "0.647583", "0.6469023", "0.64618635", "0.64546674", "0.6445776", "0.64390033", "0.6424845", "0.6421493", "0.6417318", "0.64138657", "0.63861483", "0.6379262", "0.6379262", "0.6379262", "0.6379262", "0.6357731", "0.63550496", "0.63400084", "0.632291", "0.63123393", "0.62888896", "0.6285559", "0.62848794", "0.6259729", "0.62461823", "0.6243193", "0.6238357", "0.6233286", "0.6227824", "0.62261456", "0.6218333", "0.62095124", "0.61974883", "0.61974883", "0.6196421", "0.6193734", "0.61913884", "0.61777097", "0.61735517", "0.6149281", "0.6141443", "0.6135297", "0.6135297", "0.61311144", "0.6123147", "0.61173683", "0.6108032", "0.6104324", "0.6098371", "0.6091657", "0.6085008", "0.60848856", "0.60817873", "0.6080912", "0.606868", "0.60654974", "0.60625815", "0.60587716", "0.6055919" ]
0.6187541
78
PATCH/PUT /clients/1 PATCH/PUT /clients/1.json
def update respond_to do |format| begin ActiveRecord::Base.transaction do @client.update!(client_params) @client.address.update!(address_params) end format.html { redirect_to @client, notice: 'Client was successfully updated.' } format.json { render :show, status: :ok, location: @client } rescue format.html { render :edit } format.json { render json: @client.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @client.update(client_params)\n render json: @client\n end", "def patch(type, info)\n path, info = type_info(type, :path), force_case(info)\n ida = type == :client ? 'client_id' : 'id'\n raise ArgumentError, \"info must include #{ida}\" unless id = info[ida]\n hdrs = headers\n if info && info['meta'] && (etag = info['meta']['version'])\n hdrs.merge!('if-match' => etag)\n end\n reply = json_parse_reply(@key_style,\n *json_patch(@target, \"#{path}/#{Addressable::URI.encode(id)}\", info, hdrs))\n\n # hide client endpoints that are not quite scim compatible\n type == :client && !reply ? get(type, info['client_id']): reply\n end", "def update\n @client = Client.find(params[:id])\n\n respond_to do |format|\n if @client.update_attributes(params[:client])\n format.html { redirect_to clients_path, notice: 'Client was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @client = Client.find(params[:id])\n\n respond_to do |format|\n if @client.update_attributes(params[:client])\n format.html { redirect_to clients_path, notice: 'Client was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @client = Client.find(params[:id])\n\n respond_to do |format|\n if @client.update_attributes(params[:client])\n format.html { redirect_to @client, notice: 'Client was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @client = Client.find(params[:id])\n\n respond_to do |format|\n if @client.update_attributes(params[:client])\n format.html { redirect_to @client, notice: 'Client was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_client\n\t\t@client = Client.find(params[:id])\n\n\t \trespond_to do |format|\n\t\t if @client.update_attributes(client_update_params)\n\t\t format.html { redirect_to(@client, :notice => 'Entry was successfully updated.') }\n\t\t format.json { respond_with_bip(@client) }\n\t\t else\n\t\t format.html { render :action => \"edit\" }\n\t\t format.json { respond_with_bip(@client) }\n\t\t end\n\n \t end\n\tend", "def update\n @client = Client.find(params[:id])\n\n respond_to do |format|\n if @client.update_attributes(params[:client])\n format.html { redirect_to @client, notice: 'Client was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n params[:client][:contact_ids] ||= []\n @client = Client.find(params[:id])\n\n respond_to do |format|\n if @client.update_attributes(params[:client])\n format.html { redirect_to @client, notice: 'Client was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @client = Client.find(params[:id])\n\n respond_to do |format|\n if @client.update_attributes(params[:client])\n format.html { redirect_to @client, :notice => 'El cliente se ha actualizado correctamente.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @client.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @clients = get_clients\n @client = Client.find(params[:id])\n\n respond_to do |format|\n if @client.update_attributes(params[:client])\n @clients = get_clients\n #format.html { redirect_to @client, notice: 'Client was successfully updated.' }\n format.json { head :no_content }\n format.js\n else\n #format.html { render action: \"index\" }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n format.js\n end\n end\n end", "def update_client\n\t\tif(request.method == \"OPTIONS\")\n\t\t\trespond({status: 0})\n\t\telsif request.method == \"POST\"\n\t\t\trespond(update_user_client(params))\n\t\tend\n\tend", "def update\r\n params[:client][:version] = ENV[\"VERSION\"]\r\n params[:client][:username] = current_user.username\r\n @client = Client.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @client.update_attributes(client_params)\r\n format.html { redirect_to @client, notice: 'Client was successfully updated.' }\r\n format.json { head :no_content }\r\n else\r\n format.html { render action: \"edit\" }\r\n format.json { render json: @client.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def update\n @client = Client.find(params[:id])\n\n respond_to do |format|\n if @client.update_attributes(params[:client])\n format.html { redirect_to @client, :notice => 'Klijent je uspjesno izmjenjen.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @client.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @client = Client.find(params[:id])\n authorize! :update, @client\n\n respond_to do |format|\n if @client.update_attributes(client_params)\n format.html { redirect_to @client, :notice => 'Client was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @client.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n succeess_redirect_path = URI(request.referer).path.gsub 'edit', ''\n if @client.update(client_params)\n format.html { redirect_to succeess_redirect_path, notice: 'Client was successfully updated.' }\n format.json { render :show, status: :ok, location: @client }\n else\n format.html { redirect_to URI(request.referer).path }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n\n if @client.update(client_params)\n format.html { redirect_to clients_path, notice: 'Client was successfully updated.' }\n format.json { render :show, status: :ok, location: @client }\n else\n format.html { render :edit }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n authorize! :update, Client\n load_client\n build_client\n save_client or render :edit\n end", "def update\n @client = Client.find(params[:id])\n\n respond_to do |format|\n if @client.update_attributes(params[:client])\n format.html { redirect_to user_url(@client.id), notice: 'Client was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { redirect_to edit_user_url(@client.id)}\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n authorize @client\n respond_to do |format|\n if @client.update(client_params)\n format.html { redirect_back_or_default clients_url, t('Record has been saved') }\n format.json { render :show, status: :ok, location: @client }\n else\n format.html { render :edit }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @client.update(client_params)\n format.html { redirect_to clients_url, notice: 'La información del cliente se actualizó correctamente.' }\n format.json { render :index, status: :ok, location: @client }\n else\n format.html { render :edit }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @client.update(client_params)\n format.html { redirect_to @client, notice: 'Client record was successfully updated.' }\n format.json { render :show, status: :ok, location: @client }\n else\n format.html { render :edit }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n \n respond_to do |format|\n if @client.update(client_params)\n format.html { redirect_to @client, notice: 'Client was successfully updated.' }\n format.json { render :show, status: :ok, location: @client }\n else\n format.html { render :edit }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @client.update(client_params)\n format.html { redirect_to @client, notice: 'Client was successfully updated.' }\n format.json { render :show, status: :ok, location: @client }\n else\n format.html { render :edit }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @client.update(client_params)\n format.html { redirect_to @client, notice: 'Client was successfully updated.' }\n format.json { render :show, status: :ok, location: @client }\n else\n format.html { render :edit }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @client.update(client_params)\n format.html { redirect_to @client, notice: 'Client was successfully updated.' }\n format.json { render :show, status: :ok, location: @client }\n else\n format.html { render :edit }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @client.update(client_params)\n format.html { redirect_to @client, notice: 'Client was successfully updated.' }\n format.json { render :show, status: :ok, location: @client }\n else\n format.html { render :edit }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @client.update(client_params)\n format.html { redirect_to @client, notice: 'Client was successfully updated.' }\n format.json { render :show, status: :ok, location: @client }\n else\n format.html { render :edit }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @client.update(client_params)\n format.html { redirect_to @client, notice: \"Client was successfully updated.\" }\n format.json { render :show, status: :ok, location: @client }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @client.update(client_params)\n format.html { redirect_to @client, notice: 'client was successfully updated.' }\n format.json { render :show, status: :ok, location: @client }\n else\n format.html { render :edit }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @client.update(client_params)\n format.html { redirect_to @client, notice: 'client was successfully updated.' }\n format.json { render :show, status: :ok, location: @client }\n else\n format.html { render :edit }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @client.update(client_params)\n head(:ok)\n else\n render json: @client.errors.full_messages, status: :unprocessable_entity\n end\n end", "def update\n @client = Client.find(params[:id])\n\n respond_to do |format|\n if @client.update_attributes(params[:client])\n format.html { redirect_to(client_url, :notice => 'Client was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @client.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @client.update(client_params)\n\n format.html { redirect_to @client, notice: 'Client was successfully updated.' }\n\n format.json { render :show, status: :ok, location: @client }\n\n else\n\n format.html { render :edit }\n\n format.json { render json: @client.errors, status: :unprocessable_entity }\n\n end\n end\n end", "def update\n @client = current_user.clients.find(params[:id])\n\n respond_to do |format|\n if @client.update_attributes(client_params)\n format.html { redirect_to @client, notice: 'Event was successfully updated.' }\n format.json { render :show, status: :ok, location: @client }\n else\n format.html { render :edit }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n id = shift_argument || raise(Heroku::Command::CommandFailed, \"Usage: clients:update [ID] [options]\")\n\n if options.empty?\n raise(Heroku::Command::CommandFailed, \"Missing options\")\n end\n\n validate!(options[:url]) if options[:url]\n shell = options.delete(:shell)\n options[:redirect_uri] = options.delete(:url)\n\n client = request do\n api.request(\n :body => encode_json(options),\n :expects => 200,\n :headers => headers,\n :method => :patch,\n :path => \"/oauth/clients/#{CGI.escape(id)}\"\n ).body\n end\n\n if shell\n puts \"HEROKU_OAUTH_ID=#{client[\"id\"]}\"\n puts \"HEROKU_OAUTH_SECRET=#{client[\"secret\"]}\"\n else\n styled_header(%{Updated client \"#{client[\"name\"]}\".})\n styled_hash(client)\n end\n end", "def update\n client=Client.find_by_id params[:id]\n if client!= nil\n client.cedula=params[:cedula] ? params[:cedula]: client.cedula\n client.sector=params[:sector] ? params[:sector]: client.sector\n client.nombre=params[:nombre] ? params[:nombre]: client.nombre\n client.telefono=params[:telefono] ? params[:telefono]: client.telefono\n client.pagina=params[:pagina] ? params[:pagina]: client.pagina\n client.direccion=params[:direccion] ? params[:direccion]: client.direccion\n if client.save\n render(json: client, status: 201)\n end \n else\n render(json: client.errors, status: 404)\n end \n end", "def update\n @client = Client.find(params[:id])\n\n respond_to do |format|\n if @client.update_attributes(params[:client])\n format.html { redirect_to(@client, :notice => 'Client was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @client.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n\tif signed_in?\n\t\tif params[:client][:encrypted_password_confirmation].blank?\n\t\t\tparams[:client].delete(\"encrypted_password\")\n\t\t\tparams[:client].delete(\"encrypted_password_confirmation\")\n\t\tend\n\t\t@current_client = current_user.username\n\t\tif current_user.username == 'admin'\n\t\t\t@client = Client.find(params[:id])\n\t\telse\n\t\t\tredirect_to home_path\n\t\tend\n\telse\n\t\tredirect_to signin_path\n\tend\n respond_to do |format|\n if @client.update_attributes(params[:client])\n format.html { redirect_to clients_path}\n else\n format.html { render action: \"edit\" }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @client = args[:client] if args.key?(:client)\n @list_update_requests = args[:list_update_requests] if args.key?(:list_update_requests)\n end", "def update\n @api_client = ApiClient.find(params[:id])\n\n respond_to do |format|\n if @api_client.update_attributes(params[:api_client])\n format.html { redirect_to @api_client, notice: 'Api client was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @api_client.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @client = Client.find(params[:id])\n respond_to do |format|\n if @client.update_attributes(params[:client])\n \n flash[:notice] = 'Client was successfully updated.'\n format.html { redirect_to(@client) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @client.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @client = Client.find(params[:id])\n respond_to do |format|\n if @client.update_attributes(client_params)\n format.html { redirect_to(@client, :notice => 'Client was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @client.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @clientsOffers = ClientsOffers.find(params[:id])\n\n respond_to do |format|\n if @clientsOffers.update_attributes(params[:clientsOffers])\n format.html { redirect_to @clientsOffers, notice: 'ClientsOffers was succesfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @clientsOffers.errors, status: :unprocesable_entity }\n end\n end\n end", "def update\n @client = Client.find(params[:id])\n \n respond_to do |format|\n if @client.update_attributes(params[:client])\n flash[:notice] = 'Client was successfully updated.'\n format.html { redirect_to client_url(@role) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @client.errors.to_xml }\n end\n end\n end", "def update\n respond_to do |format|\n if @client.update(client_params)\n format.html { redirect_to @client, notice: 'Client a été mise à jour.' }\n format.json { render :show, status: :ok, location: @client }\n else\n format.html { render :edit }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @client.update(client_params)\n format.html { redirect_to @client, notice: 'Cliente atualizado com sucesso!' }\n format.json { render :show, status: :ok, location: @client }\n else\n format.html { render :edit }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @client = Client.find(params[:id])\n flash[:notice] = 'Client was successfully updated.' if @client.update_attributes(params[:client])\n respond_with(@client)\n end", "def update\n @client = Client.find(params[:id])\n\n respond_to do |format|\n if @client.update_attributes(client_params)\n format.html { redirect_to(@client, :notice => 'Les informations du client ont été mises à jour.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @client.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @client.update(client_params)\n format.html { redirect_to @client, notice: 'Cliente atualizado com sucesso.' }\n format.json { render :show, status: :ok, location: @client }\n else\n format.html { render :edit }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n # NOTE: API V1 dropped support for updating client keys via update (aka PUT),\n # but this code never supported key updating in the first place. Since\n # it was never implemented, we will simply ignore that functionality\n # as it is being deprecated.\n # Delete this comment after V0 support is dropped.\n payload = { name: name }\n payload[:validator] = validator unless validator.nil?\n\n # DEPRECATION\n # This field is ignored in API V1, but left for backwards-compat,\n # can remove after API V0 is no longer supported.\n payload[:admin] = admin unless admin.nil?\n\n begin\n new_client = chef_rest_v1.put(\"clients/#{name}\", payload)\n rescue Net::HTTPClientException => e\n # rescue API V0 if 406 and the server supports V0\n supported_versions = server_client_api_version_intersection(e, SUPPORTED_API_VERSIONS)\n raise e unless supported_versions && supported_versions.include?(0)\n\n new_client = chef_rest_v0.put(\"clients/#{name}\", payload)\n end\n\n Chef::ApiClientV1.from_hash(new_client)\n end", "def update_resources(client_id)\n response = self.class.put(\"https://app.klipfolio.com/api/1.0/clients/#{client_id}/resources\", basic_auth: @auth, headers: { \"Content-Type\" => \"application/json\" },\n body: {\n \"resources\": [{\"name\":\"dashboard.tabs.total\", \"value\":1}]\n }.to_json)\n puts response.body\n puts \"Client's resources were updated.\" if response.success?\n end", "def update\n @client = clients.find(params[:id])\n\n if @client.update_attributes(params[:client])\n flash[:notice] = 'Client was successfully updated.'\n redirect_to(user_company_clients_url(current_company))\n else\n render :action => \"edit\"\n end\n end", "def update\n @client = Client.find(params[:id])\n\n respond_to do |format|\n if @client.update_attributes(params[:client])\n format.html { redirect_to(@client, :notice => \"Client was successfully updated. #{undo_link}\") }\n else\n format.html { render :action => \"edit\" }\n end\n end\n end", "def update\n @client = Client.find(params[:id])\n flash[:success] = \"Cliente editado exitosamente\" if @client.update_attributes(params[:client])\n respond_with(@client)\n end", "def update\n @client = Client.find(params[:id])\t\t\n if @client.update_attributes(params[:client])\n redirect_to @client, notice: 'Client was successfully updated!'\n else\n render action: \"edit\"\n end\n end", "def update\n respond_to do |format|\n if @client_info.update(client_info_params)\n\n format.html { redirect_to @client_info, notice: 'Client info was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @client_info.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n client_id = params[:contact].delete(:client_id)\n @contact = Contact.find(params[:id])\n @contact.client = Client.find(client_id.to_i)\n\n respond_to do |format|\n if @contact.update_attributes(params[:contact])\n format.html { redirect_to @contact, notice: 'Contact was successfully updated.' }\n format.js\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.js { render action: \"edit\" }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch!\n request! :patch\n end", "def update\n if @client.update(client_params)\n redirect_to clients_path\n else\n render :edit\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 @client = Client.find(params[:id])\n @client.campaign_id = session[:campaign_id]\n @groups = Group.all.map {|g| [g.name, g.id]}\n\n respond_to do |format|\n if @client.update_attributes(params[:client])\n format.html { redirect_to @client, :notice => 'Client was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @client.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @client = Client.find(params[:id])\n\n respond_to do |format|\n \tif params[:client][:logo].blank?\n \t\tparams[:client][:logo] = @client.logo\n \telse\n \t\tnew_file_name = upload_file(params[:client][:logo], \"/public/files/logo_files/\")\n\t \tFileUtils.rm Dir[\"#{Rails.root}/public/files/logo_files/\"[email protected]_s]\n\t \tparams[:client][:logo] = new_file_name\n \tend\n\t \tparams[:client][:updated_by] = current_user.id\n @client.attributes = params[:client]\n if @client.save\n format.html { redirect_to clients_path, notice: 'Client was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @client = Client.find(params[:id])\n @client.name = @client.name.upcase\n if session[:user].nil? \n redirect_to :controller => \"login\", :action => \"new\"\n else\n @client.updated_by = session[:user]\n end\n\n respond_to do |format|\n if @client.update_attributes(params[:client])\n format.html { redirect_to clients_path(:clientid => @client.id), notice: 'Client was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @client = Client.find params[:id]\n respond_to do |format|\n if @client.update_attributes(client_params)\n format.html { redirect_to client_path(@client), notice: 'Cliente fue Actualizado correctamente.' }\n else\n format.html { render :edit }\n end\n end\n end", "def update\n @qa_client = QaClient.find(params[:id])\n\n respond_to do |format|\n if @qa_client.update_attributes(params[:qa_client])\n format.html { redirect_to @qa_client, notice: 'Qa client was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @qa_client.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @blocking_client = BlockingClient.find(params[:id])\n\n respond_to do |format|\n if @blocking_client.update_attributes(params[:blocking_client])\n format.html { redirect_to @blocking_client, notice: 'Blocking client was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @blocking_client.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @my_studio_client = MyStudio::Client.find(params[:id])\n\n respond_to do |format|\n if @my_studio_client.update_attributes(params[:my_studio_client])\n format.html { redirect_to @my_studio_client, notice: 'Client was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @my_studio_client.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit_client\n\t\t@client = Client.find(params[:id])\n\tend", "def update_client\n if current_admin.present?\n @client = Client.friendly.find(params[:id])\n respond_to do |format|\n if params[:client][:permalink].present?\n @client.update_attributes(:slug => params[:client][:permalink])\n end\n if @client.update_attributes(params[:client])\n format.html { redirect_to edit_admin_path(@client), notice: 'Client was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n else\n redirect_to new_admin_session_path and return\n end \n end", "def update\n @contact = Contact.find(params[:id])\n if params[:contact][:clientId] == \"\"\n params[:contact][:clientId] = nil\n end \n\n respond_to do |format|\n if @contact.update_attributes(params[:contact])\n format.html { redirect_to @contact, notice: 'Contato atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contact.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @client = Client.find(params[:id])\n @uuid = params[:uuid]\n respond_to do |format|\n if @client.update_attributes(params[:client])\n format.html { redirect_to :controller => 'ads', :action => 'admin_dash', :id => 1, :uuid => @uuid, notice: 'Client was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @client.update(client_params)\n redirect_to client_path(@client)\n else\n render :edit\n end\n end", "def update\n respond_to do |format|\n if @clients.update(clients_setting_params)\n format.html { redirect_to edit_clients_setting_path(@clients), notice: 'Setting was successfully updated.' }\n format.json { render :show, status: :ok, location: @clients }\n else\n format.html { render :edit }\n format.json { render json: @clients.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n #se não aguardar carregar os dados\n if client_params[:state] == '...'\n sweetalert_warning('Você precisa informar o CEP e aguardar os dados do endereço serem preenchidos.', 'Aviso!', useRejections: false)\n redirect_to edit_client_path(@client) and return\n end\n\n respond_to do |format|\n\n if @client.update(client_params)\n format.html { redirect_to @client, notice: 'Cliente atualizado com sucesso.' }\n format.json { render :show, status: :ok, location: @client }\n sweetalert_success('Cliente atualizado com sucesso.', 'Sucesso!', useRejections: false)\n else\n format.html { render :edit }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @otg_client.update(otg_client_params)\n format.html { redirect_to @otg_client, notice: 'Otg client was successfully updated.' }\n format.json { render :show, status: :ok, location: @otg_client }\n else\n format.html { render :edit }\n format.json { render json: @otg_client.errors, status: :unprocessable_entity }\n end\n end\n end", "def update(id, client)\n @client = Locomotive::Client.get(id)\n raise NotFound unless @client\n if @client.update_attributes(client)\n redirect resource(@client), :message => {:notice => \"Client was successfully updated\"}\n else\n display @client, :edit\n end\n end", "def update_client(client)\n raise ArgumentError, 'Cannot update without id' if client.id.nil?\n resp = put \"#{CLIENT_API_PATH}/#{client.id}\", params: client.as_json\n process_response(resp)\n true\n rescue Errors::UnprocessableEntity\n false\n end", "def update\n @client.update_attributes(client_params)\n @clients = Client.all\n flash[:notice]=\"Client Modifier avec succès!!!\"\n end", "def update\n @client_need = ClientNeed.find(params[:id])\n\n respond_to do |format|\n if @client_need.update_attributes(params[:client_need])\n format.html { redirect_to @client_need, notice: 'Client need was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @client_need.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 @live_client.update(live_client_params)\n format.html { redirect_to @live_client, notice: 'Live client was successfully updated.' }\n format.json { render :show, status: :ok, location: @live_client }\n else\n format.html { render :edit }\n format.json { render json: @live_client.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @client.update(client_params)\n redirect_to show_clients_path(@client), notice: 'Client was successfully updated.'\n else\n render :edit\n end\n end", "def update\n @oauth_client = OauthClient.find(params[:id])\n\n respond_to do |format|\n if @oauth_client.update(oauth_client_params)\n format.html { redirect_to oauth_clients_path, notice: 'OAuth client was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @oauth_client.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @potential_client.update(potential_client_params)\n format.html { redirect_to @potential_client, notice: 'Potential client was successfully updated.' }\n format.json { render :show, status: :ok, location: @potential_client }\n else\n format.html { render :edit }\n format.json { render json: @potential_client.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\t @client = User.find(params[:id])\n\t\tif @client.update(clients_params)\n flash[:success] = \"Record updated successfully\"\n\t\t\tredirect_to clients_path\n\t\telse\n flash[:error] = \"Record not updated\"\n\t\t\tredirect_to new_client_path\n\t end\n end", "def update\n @cliente = Cliente.find(params[:id])\n\n respond_to do |format|\n if @cliente.update_attributes(params[:cliente])\n format.html { redirect_to @cliente, notice: 'Cliente was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cliente.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @cliente = Cliente.find(params[:id])\n\n respond_to do |format|\n if @cliente.update_attributes(params[:cliente])\n format.html { redirect_to @cliente, notice: 'Cliente was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cliente.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @cliente = Cliente.find(params[:id])\n\n respond_to do |format|\n if @cliente.update_attributes(params[:cliente])\n format.html { redirect_to @cliente, notice: 'Cliente was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cliente.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user = User.find(params[:id])\n @client = Client.find(params[:id])\n if @client.update(client_params)\n # Save the item successfully\n redirect_to @client\n else\n render :action => \"edit\"\n end\n\n\n end", "def update\n \n\n @client.redirect_urls << client_params[:add_redirect_url] if client_params[:add_redirect_url]\n \n @client.app_ids << BSON::ObjectId.new.to_s if client_params[:add_app_id]\n \n \n @client.versioned_update({\"redirect_urls\" => 1, \"app_ids\" => 1})\n\n if @client.op_success?\n render \"show\"\n else\n render \"edit\"\n end\n \n end", "def update\n @cliente = Cliente.find(params[:id])\n\n respond_to do |format|\n if @cliente.update_attributes(params[:cliente])\n format.html { redirect_to edit_cliente_path(@cliente), notice: 'Cliente was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cliente.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @kont_klient.update(kont_klient_params)\n format.html { redirect_to @kont_klient, notice: 'Kont klient was successfully updated.' }\n format.json { render :show, status: :ok, location: @kont_klient }\n else\n format.html { render :edit }\n format.json { render json: @kont_klient.errors, status: :unprocessable_entity }\n end\n end\n end", "def update(url, data)\n RestClient.put url, data, :content_type => :json\nend", "def update\n respond_to do |format|\n if @invoice_client.update(invoice_client_params)\n format.html { redirect_to @invoice_client, notice: 'Invoice client was successfully updated.' }\n format.json { render :show, status: :ok, location: @invoice_client }\n else\n format.html { render :edit }\n format.json { render json: @invoice_client.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @members_client.update(members_client_params)\n format.html { redirect_to @members_client, notice: 'Members client was successfully updated.' }\n format.json { render :show, status: :ok, location: @members_client }\n else\n format.html { render :edit }\n format.json { render json: @members_client.errors, status: :unprocessable_entity }\n end\n end\n end", "def put(type, info)\n path, info = type_info(type, :path), force_case(info)\n ida = type == :client ? 'client_id' : 'id'\n raise ArgumentError, \"info must include #{ida}\" unless id = info[ida]\n hdrs = headers\n if info && info['meta'] && (etag = info['meta']['version'])\n hdrs.merge!('if-match' => etag)\n end\n reply = json_parse_reply(@key_style,\n *json_put(@target, \"#{path}/#{Addressable::URI.encode(id)}\", info, hdrs))\n\n # hide client endpoints that are not quite scim compatible\n type == :client && !reply ? get(type, info['client_id']): reply\n end", "def update\n respond_to do |format|\n if @group_client.update(group_client_params)\n format.html { redirect_to @group_client, flash: { success: \"Group client was successfully updated.\" } }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @group_client.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @client.valid?\n old_password = @client.password\n @client.password = SecureRandom.hex(6)\n status = ApiClient.update(@client)\n\n user = User.find_by(client_id: @client.code)\n\n if user\n user.name = @client.name\n user.email = @client.email\n user.password = old_password\n user.password_salt = @client.password\n user.client_id = @client.code\n user.save\n end\n end\n\n respond_to do |format|\n if @client.valid?\n format.html { redirect_to @client, notice: 'Client was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @client.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @paperclip_client = PaperclipClient.find(params[:id])\n @client = @paperclip_client\n\n respond_to do |format|\n if @paperclip_client.update_attributes(params[:paperclip_client])\n format.html { redirect_to(@paperclip_client, :notice => 'Paperclip client was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render 'clients/edit' }\n format.xml { render :xml => @paperclip_client.errors, :status => :unprocessable_entity }\n end\n end\n end" ]
[ "0.7246776", "0.7098947", "0.7001019", "0.7001019", "0.6907153", "0.6907153", "0.6898349", "0.68953735", "0.68737906", "0.68383723", "0.6836901", "0.6832358", "0.68251896", "0.68093616", "0.6761033", "0.67596495", "0.6749836", "0.6744567", "0.6742964", "0.6738345", "0.6662724", "0.6658593", "0.6656517", "0.663776", "0.663776", "0.663776", "0.663776", "0.663776", "0.6626655", "0.66230094", "0.66230094", "0.66127205", "0.66124266", "0.6592544", "0.6591728", "0.6571905", "0.6568473", "0.6558184", "0.6556564", "0.6551927", "0.65294915", "0.65179825", "0.6515788", "0.6502897", "0.6473843", "0.6446003", "0.6421461", "0.6409732", "0.6406041", "0.640233", "0.6366552", "0.63497573", "0.6337082", "0.63074195", "0.6272843", "0.62723297", "0.6270256", "0.6268116", "0.6264833", "0.6254527", "0.6252514", "0.6248435", "0.6247299", "0.6224292", "0.6223213", "0.621889", "0.6215606", "0.62134844", "0.62066174", "0.61981916", "0.6166009", "0.6160013", "0.6154378", "0.6148328", "0.6138611", "0.6137676", "0.61360943", "0.61347663", "0.6125761", "0.61200345", "0.611495", "0.6103802", "0.60907006", "0.60776746", "0.6072726", "0.60696524", "0.60639095", "0.6055205", "0.6055205", "0.6054419", "0.60506576", "0.60399896", "0.6039832", "0.60386735", "0.60369116", "0.6029953", "0.6027162", "0.60236543", "0.60227644", "0.60153466" ]
0.6326184
53
DELETE /clients/1 DELETE /clients/1.json
def destroy respond_to do |format| begin ActiveRecord::Base.transaction do OrderDetail.joins(:order).where(orders: { client_id: @client.id }).destroy_all Order.where(client_id: @client.id).destroy_all @client.destroy end format.html { redirect_to clients_url, notice: 'Client was successfully destroyed.' } format.json { head :no_content } rescue format.html { redirect_to clients_url, notice: 'Error. :p' } format.json { head :no_content } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :ok }\n end\n end", "def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :ok }\n end\n end", "def destroy\n @client.destroy\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @client = Client.find(params[:id])\n @client.destroy\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :no_content }\n end\n end", "def destroy\r\n @client = Client.find(params[:id])\r\n @client.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to clients_url }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @client = Client.find(params[:id])\n authorize! :update, @client\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :ok }\n end\n end", "def destroy\n chef_rest_v1.delete(\"clients/#{@name}\")\n end", "def destroy\n @client = Client.find(params[:id])\n @client.destroy\n \n respond_to do |format|\n format.html { redirect_to clients_url }\n format.xml { head :ok }\n end\n end", "def destroy\n @client.destroy\n respond_to do |format|\n format.html { redirect_to clients_url, notice: 'Client record was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @client.destroy\n respond_to do |format|\n format.html { redirect_to clients_url, notice: 'Client a été supprimer.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @client.destroy\n respond_to do |format|\n format.html { redirect_to clients_url, notice: 'Client was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @client.destroy\n respond_to do |format|\n format.html { redirect_to clients_url, notice: 'Client was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @client.destroy\n respond_to do |format|\n format.html { redirect_to clients_url, notice: 'Client was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @client.destroy\n respond_to do |format|\n format.html { redirect_to clients_url, notice: 'Client was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @client.destroy\n respond_to do |format|\n format.html { redirect_to clients_url, notice: 'Client was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @client.destroy\n respond_to do |format|\n format.html { redirect_to clients_url, notice: 'Client was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @client.destroy\n respond_to do |format|\n format.html { redirect_to clients_url, notice: 'Client was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @client.destroy\n respond_to do |format|\n format.html { redirect_to clients_url, notice: \"Client was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @client.destroy\n respond_to do |format|\n format.html { redirect_to clients_url, notice: 'El Cliente fue Eliminado Exitosamente.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @client.destroy\n respond_to do |format|\n format.html { redirect_to clients_url, notice: 'Данные по клиенту удалены.' }\n format.json { head :no_content }\n end\n end", "def destroy\n authorize @client\n @client.destroy\n respond_to do |format|\n format.html { redirect_back_or_default clients_url, t('Record has been deleted') }\n format.json { head :no_content }\n end\n end", "def destroy\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_url, notice: 'Client was successfully destroyed.' }\n\n format.json { head :no_content }\n end\n end", "def destroy\n client=Client.find_by_id(params[:id])\n if client != nil\n if client.destroy\n head 204\n end\n else\n head 404\n end\n end", "def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to(clients_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to(clients_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to(clients_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @client.destroy\n respond_to do |format|\n format.html { redirect_to clients_url, notice: 'Cliente apagado com sucesso.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to(clients_url) }\n end\n end", "def destroy\n @client.destroy\n respond_to do |format|\n format.html { redirect_to clients_url, notice: 'Cliente excluído com sucesso!' }\n format.json { head :no_content }\n end\n end", "def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to(clients_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @client = Client.find(params[:id])\n \n if @client.deleted_at.blank?\n @client.destroy\n else\n @client.revive\n end\n \n respond_to do |format|\n format.html { redirect_to :back }\n format.json { head :ok }\n end\n end", "def destroy\n @client = Client.find(params[:id])\n @client.destroy\n respond_with(@client)\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @api_client = ApiClient.find(params[:id])\n @api_client.destroy\n\n respond_to do |format|\n format.html { redirect_to api_clients_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @client = Client.find(params[:id])\n @client.destroy\n @uuid = params[:uuid]\n respond_to do |format|\n format.html { redirect_to :controller => 'ads', :action => 'admin_dash', :id => 1, :uuid => @uuid }\n format.json { head :no_content }\n end\n end", "def destroy\n @client = Client.find(params[:id])\n @client.destroy\n redirect_to clients_url\n end", "def destroy\n @secubat_client = SecubatClient.find(params[:id])\n @secubat_client.destroy\n\n respond_to do |format|\n format.html { redirect_to secubat_clients_url }\n format.json { head :ok }\n end\n end", "def destroy\n @otg_client.destroy\n respond_to do |format|\n format.html { redirect_to otg_clients_url, notice: 'Otg client was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n clients_delete(@entity)\n @entity.destroy\n respond_to do |format|\n format.html { redirect_to clients_path }\n format.json { render json: {success: true} }\n end\n end", "def destroy\n @client_info.destroy\n respond_to do |format|\n format.html { redirect_to client_infos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @client_info.destroy\n respond_to do |format|\n format.html { redirect_to client_infos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @qa_client = QaClient.find(params[:id])\n @qa_client.destroy\n\n respond_to do |format|\n format.html { redirect_to qa_clients_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @my_studio_client = MyStudio::Client.find(params[:id])\n @my_studio_client.destroy\n\n respond_to do |format|\n format.html { redirect_to my_studio_clients_url }\n format.json { head :ok }\n end\n end", "def destroy\n @user = current_user\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_path(@user) }\n format.xml { head :ok }\n end\n end", "def destroy\n @client = Client.find(params[:id])\n @client.destroy\n @clients = get_clients\n @client = Client.new\n\n respond_to do |format|\n #format.html { redirect_to clients_url }\n format.json { head :no_content }\n format.js\n end\n end", "def destroy\n @client = clients.find(params[:id])\n @client.destroy\n redirect_to(user_company_clients_url(current_company))\n end", "def delete(client_id)\n id = client_id.to_s\n Client.collection.filter(:id => id).delete\n AuthRequest.collection.filter(:client_id => id).delete\n AccessGrant.collection.filter(:client_id => id).delete\n AccessToken.collection.filter(:client_id => id).delete\n end", "def destroy\n id = shift_argument || raise(Heroku::Command::CommandFailed, \"Usage: clients:destroy [ID]\")\n client = request do\n api.request(\n :expects => 200,\n :headers => headers,\n :method => :delete,\n :path => \"/oauth/clients/#{CGI.escape(id)}\"\n ).body\n end\n puts \"Deregistered client '#{client[\"name\"]}'.\"\n end", "def destroy\n\n\tif signed_in?\n\t\tif current_user.username == 'admin'\n\t\t\t@client = Client.find(params[:id])\n\t\t\[email protected]\n\t\telse\n\t\t\tredirect_to home_path\n\t\tend\n\telse\n\t\tredirect_to signin_path\n\tend\n respond_to do |format|\n format.html { redirect_to clients_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @client = Client.find params[:id]\n @client.destroy\n respond_to do |format|\n format.html { redirect_to clients_url, notice: 'Cliente fue Eliminado correctamente.' }\n end\n end", "def destroy\n @client.destroy\n redirect_to index_clients_path, notice: 'Client was successfully destroyed.'\n end", "def destroy\n @client.delete( name )\n end", "def delete\n client.delete(url)\n @deleted = true\nend", "def destroy\n @client.destroy\n redirect_to clients_url, notice: 'Client was successfully destroyed.'\n end", "def destroy\n [email protected]\n end", "def destroy\n @client.destroy\n respond_to do |format|\n format.html { redirect_to clients_url, notice: 'Cliente foi excluido.' }\n format.json { head :no_content }\n sweetalert_success('Cliente excluido com sucesso.', 'Sucesso!', useRejections: false)\n end\n end", "def delete(username)\n perform_request({:action => \"client-delete\", :username => username})\n end", "def destroy\n @client.delete(@name)\n end", "def destroy\n @live_client.destroy\n respond_to do |format|\n format.html { redirect_to live_clients_url, notice: 'Live client was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy(id)\n @client = Locomotive::Client.get(id)\n raise NotFound unless @client\n if @client.destroy\n redirect resource(:clients)\n else\n raise InternalServerError\n end\n end", "def destroy\n @clientsOffers = ClientsOffers.find(params[:id])\n @clientsOffers.destroy\n\n respond_to do |format|\n format.html { redirect_to clientsOffers_url }\n format.json { head :no_content }\n end\n end", "def delete_client\n\t\t@client = Client.find(params[:id])\n\n\t\tif @client.destroy\n\t\t\tredirect_to \"/details\"\n\t\telse\n\t\t\treder :action => \"delete_client\"\n\t\tend\n\tend", "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 :ok }\n end\n end", "def destroy\n @client = Client.find(params[:id])\n @client.campaign_id = session[:campaign_id]\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_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\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 @members_client.destroy\n respond_to do |format|\n format.html { redirect_to members_clients_url, notice: 'Members client was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @authorized_client.destroy\n respond_to do |format|\n format.html {redirect_to authorized_clients_url, notice: 'Authorized client was successfully destroyed.'}\n format.json {head :no_content}\n end\n end", "def destroy\n begin\n @client = Client.find(params[:id])\n @client.destroy\n rescue Exception => e\n flash[:notice]= \"There is no any client regarding this ID.\"\n end\n redirect_to clients_path\n end", "def destroy\n authorize! :destroy, Client\n load_client\n destroy_client\n\n redirect_to clients_url\n end", "def destroy\n @blocking_client = BlockingClient.find(params[:id])\n @blocking_client.destroy\n\n respond_to do |format|\n format.html { redirect_to blocking_clients_url }\n format.json { head :no_content }\n end\n end", "def delete(path)\n RestClient.delete request_base+path\n end", "def destroy\n @client.destroy\n respond_to do |format|\n format.html { redirect_to admin_clients_url(search: params[:search], page: params[:page]),\n notice: 'Клиент удален.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @invoice_client.destroy\n respond_to do |format|\n format.html { redirect_to invoice_clients_url, notice: 'Invoice client was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @group_client.destroy\n respond_to do |format|\n format.html { redirect_to group_clients_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @evclient = Evclient.find(params[:id])\n @evclient.destroy\n\n respond_to do |format|\n format.html { redirect_to evclients_url }\n format.json { head :ok }\n end\n end", "def destroy\n @client = Client.find(params[:id])\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to(search_results_url, :notice => \"Client was successfully destroyed. #{undo_link}\") }\n end\n end", "def destroy\n @clientz.destroy\n respond_to do |format|\n format.html { redirect_to clientzs_url, notice: 'Clientz was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @clientes_servico.destroy\n respond_to do |format|\n format.html { redirect_to clientes_servicos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @oauth_client = OauthClient.find(params[:id])\n @oauth_client.destroy\n\n respond_to do |format|\n format.html { redirect_to oauth_clients_url }\n format.json { head :no_content }\n format.xml { head :no_content }\n end\n end", "def destroy\n @player_client = PlayerClient.find(params[:id])\n @player_client.destroy\n\n respond_to do |format|\n format.html { redirect_to player_clients_url }\n format.json { head :ok }\n end\n end", "def destroy\n @client.destroy\n #redirect_to clients_url, notice: 'Client was successfully destroyed.'\n respond_with(status: 200)\n end", "def destroy\n @client_need = ClientNeed.find(params[:id])\n @client_need.destroy\n\n respond_to do |format|\n format.html { redirect_to client_needs_url }\n format.json { head :no_content }\n end\n end", "def delete\n url = prefix + \"delete\"\n return response(url)\n end", "def delete\n url = prefix + \"delete\"\n return response(url)\n end", "def destroy\n @client_transaction = ClientTransaction.find(params[:id])\n @client_transaction.destroy\n\n respond_to do |format|\n format.html { redirect_to client_transactions_url }\n format.json { head :ok }\n end\n end", "def delete(*args)\n prepare_request(:delete, args)\n @@client.add(:delete, @path, *args)\n end", "def destroy\n @client = Client.find(params[:id])\n Client.transaction do\n FileUtils.rm Dir[\"#{Rails.root}/public/files/logo_files/\"[email protected]_s]\n @client.destroy\n\n respond_to do |format|\n format.html { redirect_to clients_url, notice: 'Client was successfully deleted.' }\n format.json { head :no_content }\n end\n end\n end", "def destroy\n @potential_client.destroy\n respond_to do |format|\n format.html { redirect_to potential_clients_url, notice: 'Potential client was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @invoice = Invoice.find(params[:invoice_id])\n @client = @invoice.clients.find(params[:id])\n @client.destroy\n redirect_to invoice_path(@invoice)\n end", "def destroy\n @client_type = ClientType.find(params[:id])\n @client_type.destroy\n\n respond_to do |format|\n format.html { redirect_to client_types_url }\n format.json { head :no_content }\n end\n end" ]
[ "0.7799133", "0.7799133", "0.77840954", "0.7773193", "0.7773193", "0.7773193", "0.7773193", "0.7773193", "0.7773193", "0.7773193", "0.7773193", "0.7773193", "0.77693796", "0.7714836", "0.7636574", "0.76239145", "0.75873226", "0.75829566", "0.75397116", "0.75370675", "0.75370675", "0.75370675", "0.75370675", "0.75370675", "0.75370675", "0.75370675", "0.75340575", "0.75272644", "0.75252855", "0.75238895", "0.7522936", "0.75201535", "0.75145394", "0.7514412", "0.7514412", "0.74944866", "0.7491275", "0.7479932", "0.74794835", "0.747936", "0.74498194", "0.74491817", "0.7391081", "0.7375605", "0.7364077", "0.7327643", "0.73224396", "0.72956", "0.7285409", "0.72851473", "0.72829443", "0.7266207", "0.7265022", "0.72463274", "0.72105354", "0.71828586", "0.71656084", "0.7149041", "0.71426386", "0.71295375", "0.71136683", "0.7111024", "0.70977694", "0.70917463", "0.70891607", "0.7084439", "0.70822245", "0.7080042", "0.70782703", "0.70740044", "0.70711744", "0.7062625", "0.7045157", "0.70289207", "0.70289207", "0.70289207", "0.70176363", "0.70030874", "0.6997158", "0.69877917", "0.6981966", "0.6972628", "0.6963233", "0.6941935", "0.6938942", "0.693774", "0.6933007", "0.6927011", "0.6918082", "0.6916923", "0.69118625", "0.69090945", "0.69089085", "0.69042593", "0.69042593", "0.6871871", "0.6855773", "0.68540096", "0.6834792", "0.6830209", "0.6822335" ]
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_client @client = Client.preload(:address).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 client_params params.require(:client).permit(:name, :password, :password_confirmation) 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 filtering_params\n params.permit(:email)\n end", "def active_code_params\n params[:active_code].permit\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 url_whitelist; 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 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 permit_request_params\n params.permit(:address)\n end", "def sensitive_params=(params)\n @sensitive_params = params\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 unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\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 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.6978086", "0.6780264", "0.6742658", "0.6738813", "0.67338693", "0.65908474", "0.6501793", "0.6495506", "0.64796513", "0.64755446", "0.6454826", "0.6437561", "0.6377127", "0.63722163", "0.6364058", "0.63178706", "0.62979764", "0.62968165", "0.62913024", "0.6289789", "0.6289145", "0.62875307", "0.6280997", "0.62420976", "0.62388235", "0.6216686", "0.62122375", "0.6208949", "0.619173", "0.6176307", "0.6173907", "0.6170346", "0.616111", "0.6150513", "0.6150023", "0.61446756", "0.6120429", "0.6112975", "0.6104845", "0.6102966", "0.6087884", "0.6079323", "0.60699135", "0.60602236", "0.60191786", "0.60170597", "0.60100305", "0.6009527", "0.60052776", "0.60052776", "0.600042", "0.5999317", "0.59933805", "0.5991528", "0.5991221", "0.5990094", "0.5979497", "0.5966058", "0.5958738", "0.59579456", "0.5957759", "0.5956938", "0.5951788", "0.59511644", "0.59423065", "0.59373474", "0.59361076", "0.59361076", "0.59331447", "0.5928005", "0.5924882", "0.5924011", "0.59169155", "0.5908037", "0.5907541", "0.59061426", "0.59056246", "0.5897408", "0.58960444", "0.58951247", "0.5893136", "0.5892312", "0.5890385", "0.58853275", "0.58801144", "0.58784765", "0.5872648", "0.58682626", "0.5867028", "0.58661693", "0.586578", "0.58643955", "0.5863193", "0.58609086", "0.5859997", "0.5858935", "0.5858632", "0.5853379", "0.5852741", "0.584806", "0.5847703" ]
0.0
-1
PATCH/PUT /products/1 PATCH/PUT /products/1.json
def update @venue = Venue.find(params[:id]) state_id = params[:venue][:state] town_id = params[:venue][:town] postal_code_id = params[:venue][:postal_code] p state_id, town_id, postal_code_id location_relation = LocationRelation.where(:state_id => state_id, :postal_code_id => postal_code_id, :town_id => town_id).first respond_to do |format| if @venue.update( :name => params[:venue][:name], :address => params[:venue][:address], :location_relation_id => location_relation.id, :room_name => params[:venue][:room_name], :room_cost => params[:venue][:room_cost], :room_setup => params[:venue][:room_setup], :capacity => params[:venue][:capacity], :screen => params[:venue][:screen], :whiteboard_available => params[:venue][:whiteboard_available], :catering => params[:venue][:catering], :lunch_available => params[:venue][:lunch], :notes => params[:venue][:notes], :contact => params[:venue][:contact], :number => params[:venue][:number] ) format.html { redirect_to venues_path, notice: 'RTO was successfully updated.' } format.json { head :no_content } else format.html { render action: 'edit' } format.json { render json: @venue.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 @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 = 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.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 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 patch!\n request! :patch\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 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", "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.7269931", "0.6935652", "0.68690825", "0.6846676", "0.68126076", "0.67678404", "0.6749974", "0.6741848", "0.67151767", "0.6700884", "0.6686023", "0.66597176", "0.6654553", "0.66536564", "0.664067", "0.664067", "0.66382414", "0.6631012", "0.6631012", "0.6627257", "0.6620688", "0.6603794", "0.6603763", "0.6603763", "0.6603763", "0.6603763", "0.6603763", "0.6603763", "0.6603763", "0.6603763", "0.6603763", "0.6603763", "0.6603763", "0.6603763", "0.6603763", "0.6603763", "0.6603763", "0.6603763", "0.6603763", "0.6602732", "0.65937763", "0.6593595", "0.6587338", "0.65602255", "0.6557081", "0.6557081", "0.6557081", "0.6557081", "0.6557081", "0.65562665", "0.6540051", "0.65274733", "0.6498262", "0.6490972", "0.6485979", "0.6477706", "0.6475468", "0.6473973", "0.6454957", "0.6453377", "0.6441549", "0.643574", "0.64351535", "0.642971", "0.64243215", "0.6420181", "0.6415268", "0.64094204", "0.64077", "0.6406827", "0.6405912", "0.6403632", "0.6403632", "0.6403632", "0.6403632", "0.6403632", "0.6403632", "0.6403632", "0.6403632", "0.6403632", "0.6403632", "0.6403632", "0.6403632", "0.6403632", "0.6403632", "0.6403632", "0.6403632", "0.6403632", "0.6403632", "0.6403632", "0.6403632", "0.6403632", "0.6403632", "0.6403632", "0.6403632", "0.6403632", "0.6403632", "0.6403632", "0.6403632", "0.6403632", "0.6403632" ]
0.0
-1
Check for authorized user
def correct_user @user ||= (@character ? @character.user : @clutch.user) redirect_to user_path(current_user), alert: "That does not belong to you!" unless is_current_user?(@user) || is_admin? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def authorized?(user)\n true\n end", "def authorized?\n # TODO(samstern): Check for expired token.\n !(session[:user_id].nil?)\n end", "def authorized?(user_id)\n logged_in_user_id == user_id\n end", "def authorized\n\t\tif current_user\n\t\t\treturn true\n\t\telse\n\t\t\treturn false\n\t\tend\n\tend", "def authorized?\n [email protected]['REMOTE_USER']\n end", "def authorized?\n !!request.env['REMOTE_USER']\n end", "def authorized?(user)\n current_user == user\nend", "def authorized?(tmp_user)\n user == tmp_user\n end", "def authorized?(user, request, params)\n true\n end", "def authorized?\n true\n end", "def authorized?\n logged_in?\n end", "def authorized?\n if Vermonster::Client.connection.get(\"me\").status == 200\n true\n else\n false\n end\n end", "def user_authorized?(user)\n user == current_user || is_admin?\n end", "def authorized?\n logged_in?\n end", "def authorized?\n logged_in?\n end", "def authorized?\n @authorized ||= User.get(@env).present?\n end", "def authorized?\n @authorized ||= current_user.present? # TODO: Check for authorization\n end", "def authorized?\n true\n end", "def authorized?\n\n if session[:current_user] != nil\n true\n else\n redirect '/not_authorized'\n end\n\n end", "def check_auth\n @slot.user == (current_user ) or raise AccessDenied\n end", "def authorized?\n logged_in?\n end", "def authorized?\n logged_in?\n end", "def check_user\n if user_signed_in?\n else\n redirect_to root_path, :alert => \"Unauthorised Access\"\n end\n \n end", "def check_user\n if user_signed_in?\n else\n redirect_to root_path, :alert => \"Unauthorised Access\"\n end\n \n end", "def authorized?\n !auth.nil?\n end", "def authorized?\n @current_user ||= User.first(:conditions => {:name => session[:cas_user]})\n !@current_user.nil?\n end", "def require_auth(user)\n return head(:forbidden) unless current_user == user.account\n end", "def authorized?(**args)\n true\n end", "def authorized?(user, action)\n\t\ttrue\n\tend", "def authorized?\n logged_in?\n end", "def authorized?\n logged_in? && current_user.login == \"ej0c\"\n end", "def authorize?(user)\n true\n end", "def authorize_user\n if @user.id != current_user.id\n redirect_to \"/\", notice: 'You are not allowed the given operation' and return\n end\n end", "def authorized?\n current_user.logged_in?\n end", "def authorization_check\n # if there isn't a current session, redirect to login\n if session[:current_user] == nil\n redirect \"users/login\"\n else\n return true\n end\n end", "def authorize?(_user)\n true\n end", "def authorize?(_user)\n true\n end", "def authorized_for_user?(user)\n is_authorized_for?(user, user.circle)\n end", "def authorized?\nlogged_in?\nend", "def authorized?\n\t\t\t@authenticated\n\t\tend", "def ck_user\n ctrl = request.path_parameters['controller'].to_sym\n action = request.path_parameters['action'].to_sym\n flash[:warnings] = []\n\n\n # Are we handling an already authenticated system user?\n if session[:sysuser_id]\n @sysuser = Sysuser.find_by_id(session[:sysuser_id])\n return true if @sysuser\n end\n\n # Is the user requesting a public action?\n raise AuthenticationRequired unless is_public_action?(ctrl, action)\n\n # Ok, this is a public area - go ahead\n return true\n end", "def authorized_user\n @event = Event.friendly.find(params[:id])\n if @event.creator_id != current_user.id\n if current_user.email == '[email protected]' || current_user.email == '[email protected]'\n return true\n end\n redirect_to root_path, alert: \"Oops! You don't have permission to do that\"\n end\n end", "def check_authorization\n unless @user and @user.role.name == 'admin'\n flash[:notice] = \"Not authorized!\"\n redirect_to root_path\n end\n end", "def user_authorize\n if session[:user_id]\n return true\n else\n redirect_to new_session_path\n return false\n end\n end", "def authorization_check\n raise Errors::UnauthorizedError.new unless current_user.present?\n end", "def authorize?(user)\n true\n #user.login == \"administrador\"\n end", "def check_user\n if current_user.nil?\n render status: :forbidden, json: false\n return\n end\n end", "def check_authorization\n if current_user && current_user.admin_role.present?\n return true\n end\n render nothing: true, status: :unauthorized\n false\n end", "def authorized?\n if $credentials != nil\n @Userz = User.first(:username => $credentials[0])\n if @Userz\n if @Userz.edit == true\n return true\n else\n return false\n end\n else\n return false\n end\n end\n end", "def authorize\n \t\t#teste http://localhost:3000/products/2/who_bought.atom\n \t\t#ou curl --silent --user dave:secret http://localhost:3000/products/2/who_bought.atom \n \t\treturn if User.count.zero?\n\n \t\tif request.format == Mime[:html]\n \t\t\tuser = User.find_by(id: session[:user_id])\n \t\telse\n \t\t\tuser = authenticate_or_request_with_http_basic do |u,p|\n \t\t\t\tUser.find_by_name(u).try(:authenticate, p)\n \t\t\tend\n \t\tend\n\n \t\tredirect_to login_url, notice: \"Please log in\" unless user\n \t\t\n \tend", "def user_check\n if user_signed_in?\n render status: :ok, json: current_user\n else\n render status: :forbidden, nothing: true\n end\n end", "def check_is_login_required\n authorized_denied unless logged_in?\n end", "def checkUser\n if validUser\n return true\n else\n flash[:alert] = \"Unauthorized Access!!\"\n redirect_to profile_path(current_user)\n end\n end", "def check_user\n if user_signed_in? && (current_user.has_role?(:admin) || current_user.id == @listing.user_id )\n else \n flash[:alert] = \"You are not authorized to do that!\"\n redirect_to root_path\n end\n end", "def authorize_user\n puts \"AUTHORIZE USER\"\n puts \"params[:id] \" + params[:id].to_s\n # render json: { status: 401, message: 'Unauthorized' } unless get_current_user.id == params[:id].to_i\n render json: { status: 401, message: 'Unauthorized' } unless get_current_user\n end", "def check_user_authorization\n return unless params[:username].present? && params[:password].present?\n\n admin_user = AdminUser.where(username: params[:username]).first\n return unless admin_user\n\n @authorized_user = admin_user.authenticate(params[:password])\n end", "def ensure_user\n current_user? || deny_access('You must be logged in to perform this action.')\n end", "def login_required\n username, passwd = get_auth_data\n logged_in? && authorized? ? true : access_denied\n end", "def authorization_check\n # if there isn't a current session, redirect to login\n if session[:current_user] == nil\n redirect \"/login\"\n else\n return true\n end\n end", "def check_authorization\n # sanity check\n raise \"No current user in check_authorization filter??\" unless current_user\n\n if(params[:id].to_i != current_user.id)\n flash[:error] = \"You're not authorized for that URL\"\n redirect_to root_path\n end\n end", "def authorize(user=\"no\")\n if user.nil?\n not_authorized(\"User not found.\")\n false\n elsif user == 'no'\n require_login\n !!current_user\n else\n if user_authorized?(user)\n true\n else\n not_authorized\n false\n end\n end\n end", "def check_user\n @user = authenticate(@campaign.user_id, request.path, nil)\n end", "def authorize \n user = User.find_by_id(session[:user_id]) \n unless user\n redirect_to login_url, :notice => \"Please log in\"\n end\n end", "def authorized?\n current_user.login == \"Admin\"\n end", "def user_is_authorized( user, txn, *args )\n\t\t\tself.log.notice \"No implementation of user_is_authorized for %s\" %\n\t\t\t\t[ self.class.signature.name ]\n\t\t\treturn false\n\t\tend", "def authorize\n unless User.find_by(id: session[:user_id])\n redirect_to login_url, notice: \"Please log in\"\n end\n end", "def logged_in?\n authorized?\n end", "def authorize\n (render :json => { :error => \"Authentication error\" }, :status => :unauthorized and return) unless User.current.present?\n authorized ? true : deny_access\n end", "def authorization_check\n if session[:current_user] == nil\n redirect '/not_authorized'\n else\n return true\n end\nend", "def authorization_check\n # sessions take user info from db and hold it\n # during their session so not continually going to db\n # and so we know a current session exists for them\n if session[:current_user] == nil\n redirect '/not_authorized'\n else\n return true\n end\nend", "def authorize_user\n puts \"AUTHORIZE USER\"\n puts \"user id: #{get_current_user.id}\"\n puts \"params: #{params[:id]}\"\n render json: { status: 401, message: 'Unauthorized' } unless get_current_user.id == params[:id].to_i\n end", "def is_authorized?\n @authorized\n end", "def is_authorized?\n @authorized\n end", "def authorize_user\n render json: {message: \"Unauthorized\"}, status: 401 unless get_current_user.id == params[:user_id].to_i\n end", "def authorized?\n return if session[:access_token]\n end", "def authorize\n redirect_to('/login') unless @current_user\n end", "def authorize\n\t\tredirect_to '/login' unless current_user\n\tend", "def check_user\n if (!user_signed_in?)\n redirect_to root_path, notice: 'You must log in to do that'\n end\n # if (!current_user.superadmin_role)\n # redirect_to root_path, notice: 'You do not have permissions to do that'\n # end\n end", "def check_current_user_owns\n head :not_found unless @user == current_user\n end", "def authorize_user!\n if !current_user.present?\n render json: {error: 'No user error'}\n end\n end", "def authorized?\n render nothing: true, status: :forbidden if !current_account\n end", "def authorized?\n\n current_user && current_user.is_admin?\n end", "def authorized_user!\n unless user_logged_in?\n redirect_to root_path\n end\n end", "def authorize_user!\n user = Circle.find(params[:id]).user\n if current_user != user\n flash[:notices] = \"Unathorized action\"\n redirect_to user_url(user.id)\n end\n end", "def authorize_user_by_id\n\t\trender_unauthorized_msg unless current_user && current_user.id == params[:id].to_i\n\tend", "def authorize\n unless User.find_by_id(session[:user_id])\n redirect_to :log_in, :notice => \"Please log in\"\n end\n end", "def authorize\n @user = User.find_by_id_and_multitrack_token(params[:user_id], params[:token])\n head(@user ? :ok : :forbidden)\n end", "def check_user_access\n check_access_and_redirect(@request)\n end", "def check_user\n if (user_signed_in? && !current_user.has_role?(:admin))\n flash[:alert] = \"You are not authorized to access that page\"\n redirect_to root_path\n end\n end", "def authorize\n unless User.find_by_id(session[:user_id])\n redirect_to login_url, :notice => \"Please log in\"\n end\n end", "def authorize_user\n unless current_user\n store_location\n flash[:notice] = t('app.security.unauthorized_access', :default => \"You need to be logged in to access this page!\")\n redirect_to new_session_url\n return false\n else\n return not_found unless authorized?\n end\n end", "def authorized_user\n @user = Post.find(params[:id]).user\n redirect_to(root_url) unless logged_in? && (current_user?(@user) || current_user.admin?)\n end", "def authorized?\n #if current_user is nil, return false\n #otherwise, check for authorization\n if current_user\n authorized = false\n\n #if user is admin, return true\n if session[:admin] == true\n authorized = true\n else\n #puts authorized user ids in an array and check against\n #the current_user id\n authorized_users = Array.new\n\n authorized_users.push(@project.user_id)\n @project.collaborators.each do |col|\n authorized_users.push(col.user_id)\n end\n\n authorized_users.each do |user|\n # binding.pry\n if current_user.id == user\n authorized = true\n end\n end\n #authorized user not found\n if !authorized\n false\n end\n end\n\n #return result\n authorized\n else\n #current_user is nil, return false\n false\n end\n end", "def authorize?(user)\n user && user.admin?\n end", "def check_login\n head :forbidden unless self.current_user\n end", "def authorize\n \t\t\tunless User.find_by(id: session[:user_id])\n \t\t\t\tredirect_to login_url, notice: \"Please Log-in\"\n \t\t\tend\n \t\tend", "def authorize\n if !session[:user_id]\n redirect_to root_path\n end\n if session[:user_id]\n if User.find_by(id: session[:user_id]).access != \"admin\"\n redirect_to root_path\n end\n end\n end", "def authorized?(username, password, request)\n current_user = User.where(username: username).first\n current_user.try(:authenticate, password).present? && modify?(current_user, request)\n end", "def check_authorization!\n #check_current_user!\n #authorized = current_user.present? && valid_organisation_date?\n\n # TODO check due_date\n if !current_user\n flash[:alert] = \"Por favor ingrese.\"\n redirect_to new_session_url(subdomain: 'app') and return\n elsif !current_user.present?# || current_organisation.dued_with_extension? || !authorized_user?\n redir = request.referer.present? ? :back : home_path\n\n if request.xhr?\n render text: '<div class=\"alert alert-warning flash\"><h4 class=\"n\">Usted no tiene los privilegios para ver esta página</h4><div>'\n else\n flash[:alert] = \"Usted ha sido redireccionado por que no tiene suficientes privilegios.\"\n redirect_to redir and return\n end\n end\n end", "def check_user\n unless @user == current_user\n flash[:alert] = \"You don't have permission to access this page.\"\n redirect_to root_path\n end\n end", "def authorize\n redirect_to '/login' unless current_user\n end" ]
[ "0.8252605", "0.8167617", "0.8067663", "0.7996582", "0.7945356", "0.792822", "0.79031134", "0.7898001", "0.78932744", "0.7837472", "0.78125626", "0.77961665", "0.7788877", "0.7739458", "0.7739458", "0.7705936", "0.7705874", "0.77023256", "0.7685791", "0.76849866", "0.7677199", "0.7677199", "0.76712173", "0.76712173", "0.76608324", "0.7653784", "0.7646677", "0.7604019", "0.76000357", "0.7576181", "0.757491", "0.75560296", "0.75295466", "0.75167817", "0.74984336", "0.7497637", "0.7497637", "0.7494322", "0.7489962", "0.7471131", "0.74626076", "0.7457603", "0.74526334", "0.74501413", "0.74496967", "0.74467814", "0.74453264", "0.7443245", "0.744013", "0.74316734", "0.7428657", "0.7421109", "0.74056333", "0.73999244", "0.7397853", "0.7396411", "0.7390975", "0.7386573", "0.7385046", "0.7382379", "0.7374295", "0.73630655", "0.735965", "0.73582226", "0.7356417", "0.7350957", "0.7346744", "0.733729", "0.7334281", "0.7331675", "0.7326324", "0.73243093", "0.73243093", "0.7323681", "0.73193485", "0.7317877", "0.7310301", "0.7301704", "0.7286393", "0.72841364", "0.72815734", "0.72811526", "0.72792053", "0.7278993", "0.72767055", "0.7269948", "0.726603", "0.7266009", "0.7265029", "0.72585714", "0.72572744", "0.72493184", "0.7245353", "0.7243421", "0.72321516", "0.7222985", "0.7222077", "0.72186947", "0.7214722", "0.7212801", "0.7211927" ]
0.0
-1
Checks to see if the actual_spaces after an lbracket equals the value
def measure(actual_spaces, lineno, column) if actual_spaces != @config msg = "Line has #{actual_spaces} space(s) after a [, " msg << "but should have #{@config}." @problems << Problem.new(problem_type, lineno, column + 1, msg, @options[:level]) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def balance_space?\n inside_empty_brackets?\n end", "def inside_blank_pair?\n closing_pair(prev_char(:skip_space => true)) == next_char(:skip_space => true)\n end", "def position_taken?(fir, sec)\n if (fir[sec] == \" \") || (fir[sec] == \"\") || (fir[sec] == nil)\n return false\n else\n return true\n end\nend", "def spaces?\n @cells.map{|cell| cell[4] }.include?(0)\n end", "def taken?(input)\n position(input) == \" \" ? false : true\n end", "def cat_game?\n \[email protected]_value?(\" \") ? false : true\n end", "def check_validity square_availability\r\n if square_availability == \" \"\r\n true\r\n else\r\n puts \"That space is taken. Get your own!\"\r\n end\r\nend", "def check_space?(input_loc)\n valid=false\n begin\n x_val = input_loc[0]\n y_val = input_loc[1]\n if @tic.board[x_val][y_val] == \"*\"\n valid=true\n end\n rescue\n end\n \n return valid\n end", "def check_validity square_availability\n if square_availability == \" \"\n true\n else\n puts \"That space is taken. Get your own!\"\n end\nend", "def taken?(input)\n if position(input) != \" \"\n return true\n end\n return false\n end", "def taken?(input)\n position(input) != \" \"\n end", "def check_for_open_board\n active_spaces.values.include?(\" \")\n end", "def position_taken?(board, space)\n\tif (board[space] == \"\") || (board[space] == \" \") || (board[space] == nil)\n\t\treturn false\n\telse\n\t\treturn true\n\tend\nend", "def check_choice(choice)\n @spaces[choice] == \" \" ? true : false \n end", "def should_space(left, right)\n true\n end", "def position_taken?(board, position)\n board[position] != \" \" && board[position] != \"\" \nend", "def space?(n, m)\n @map[n][m] == SPACE\n end", "def position_taken?(board, position)\n board[position] != \" \"\nend", "def position_taken?(board, position)\n if board[(position.to_i - 1)] == \" \"\n false\n else\n true\n end\nend", "def position_taken?(board, location)\n board[location] != \" \" && board[location] != \"\"\nend", "def position_taken?(board, location)\n board[location] != \" \" && board[location] != \"\"\nend", "def position_taken?(board, location)\n board[location] != \" \" && board[location] != \"\"\nend", "def position_taken?(board, location)\n board[location] != \" \" && board[location] != \"\"\nend", "def position_taken?(board, location)\n board[location] != \" \" && board[location] != \"\"\nend", "def position_taken?(board, location)\n board[location] != \" \" && board[location] != \"\"\nend", "def position_taken?(board, location)\n board[location] != \" \" && board[location] != \"\"\nend", "def position_taken?(board, location)\n board[location] != \" \" && board[location] != \"\"\nend", "def position_taken?(board, location)\n board[location] != \" \" && board[location] != \"\"\nend", "def position_taken?(board, location)\n board[location] != \" \" && board[location] != \"\"\nend", "def space()\n # pocitanie riadkov\n self.line.push position if /\\n/ === data[position]\n /\\s/ === data[position]\n\n end", "def position_taken?(board, position)\n board[position] != \" \" && board[position] != \"\"\nend", "def check_validity square_availability\n if square_availability == \" \"\n true\n else\n puts \"Place déja occupé, réessayer!\"\n end\nend", "def position_taken?(cord)\n cord == \" \" || cord == \"\" || cord == nil\nend", "def position_taken?(position)\n !(@board[position.to_i] == \" \") \n end", "def taken?(location)\n position(location) != \" \"\n end", "def empty_space?(index)\t\t#CHECKS IF GIVEN INDEX IS AN EMPTY SPACE\n\t\t@board[index] == \" . \"\n\tend", "def valid_move?(row, position)\n # need to shortcirtuit for position\n cells[row] && cells[row][position] == \" \"\n end", "def position_taken?(board, location)\n return board[location] != \" \" && board[location] != \"\"\nend", "def position_taken?(board, location)\n !(board[location] == \" \" || board[location] == \"\" || board[location] == nil) #board[location] is not eq. to \" \" or \"\" or nil\nend", "def position_taken?(a,i)\n if a[i]==\" \" || a[i]==\"\" || a[i]==nil\n false\n else\n true\n end\nend", "def position_taken? (board, numeric_position)\n board[numeric_position - 1] == \" \"\nend", "def position_taken?(a,i)\r\n if a[i]==\" \" || a[i]==\"\" || a[i]==nil\r\n false\r\n else\r\n true\r\n end\r\nend", "def position_taken?(a,b)\n if (a[b] == \" \") || (a[b] == \"\") || (a[b] == nil)\n return false\n else\n return true\n end\nend", "def is_box_full(column, line)\n if @array[column][line] != \" \"\n return true\n else\n return false\n end\n end", "def space_available?(space)\n \t@spaces[to_space_sym(space)] == \" \" ? true : false\n end", "def position_taken?(board,index)\n if board[index] != \" \"\n true\n end\nend", "def position_taken?(board, position)\n board[position] == \" \" || board[position] == nil ? false : true\nend", "def position_taken?(position)\n @board[position] != \" \"\n end", "def position_taken?(board, location)\n board[location] != \" \" && board[location] != \"\"\n end", "def position_taken?(location)\n @board[location] != \" \" && @board[location] != \"\"\n end", "def myspace?; myspace.to_s != \"\" end", "def check_missing_space(tokens, ix, grammar_path)\n end", "def taken?(input)\n !(position(input) == \" \" || position(input) == \"\")\n end", "def board_has_empty_spaces?(positions)\n if positions.has_value?(\" \")\n # Board still has empty cells\n true\n else\n false\n end\nend", "def taken?(input)\n !(position(input) == \" \" || position(input) == \"\")\n end", "def position_taken?(board, index)\n !(board[index] == \" \")\nend", "def is_spacer_error?(); @type == GRT_SPACER_ERROR; end", "def position_taken?(board, location)\n !(board[location].nil? || board[location] == \" \")\nend", "def position_taken?(board, location)\n !(board[location].nil? || board[location] == \" \")\nend", "def position_taken?(board, location)\n !(board[location].nil? || board[location] == \" \")\nend", "def position_taken?(board, location)\n !(board[location].nil? || board[location] == \" \")\nend", "def position_taken?(board, location)\n !(board[location].nil? || board[location] == \" \")\nend", "def position_taken?(board, location)\n !(board[location].nil? || board[location] == \" \")\nend", "def position_taken?(board,position)\n \n !((board[position] == \" \") || (board[position] == \"\") || (board[position] == nil))\n \nend", "def position_taken?(board, position)\n !((board[position] == \" \") || (board[position] == \"\") || (board[position] == nil))\nend", "def position_taken?(board, position)\n board[position] != \" \" && board[position] != \"\" && board[position] != nil\nend", "def position_taken?(board, position)\n board[position] != \" \" && board[position] != \"\" && board[position] != nil\nend", "def position_taken?(pos)\r\n #true if space is empty and false if filled\r\n if @board[pos] == \" \"\r\n return false\r\n else\r\n return true\r\n end\r\n end", "def taken?(input)\n position(input) != \"\" && position(input) != \" \"\n end", "def position_taken?(board, index)\n board[index] != \" \"\nend", "def position_taken?(board, index)\n board[index] != \" \"\nend", "def position_taken?(board,position)\n position = position.to_i - 1\n board[position]!= \" \" && board[position]!= \"\" && board[position]!= nil\nend", "def taken?(box)\n box.mark != \" \" ? true : false\n end", "def taken?(a)\n index = a.to_i - 1\n !(@cells[index].nil? || @cells[index] == \" \")\n end", "def position_taken?(position)\n @board[position] != \" \"\n end", "def _spaces\n _save = self.pos # repetition\n _count = 0\n while true\n\n begin # choice\n _tmp = apply(:_space)\n break if _tmp\n _tmp = apply(:_comment)\n end while false # end choice\n\n break unless _tmp\n _count += 1\n end\n _tmp = _count >= 1\n unless _tmp\n self.pos = _save\n end # end repetition\n set_failed_rule :_spaces unless _tmp\n return _tmp\n end", "def position_taken?(board, index)\n board[index] != \" \" && board[index] !=\"\"\nend", "def position_taken?(location)\n @board[location] != \" \" && @board[location] != \"\"\n end", "def position_taken?(location)\n @board[location] != \" \" && @board[location] != \"\"\n end", "def position_taken?(board, position)\n !(board[position] == \" \" || board[position] == \"\" || board[position] == nil)\nend", "def misplaced_space?\n space && (space_id != space.space_id)\n end", "def position_taken?(board,position)\n position= position.to_i\n position = position - 1\n board[position]!= \" \" && board[position]!= \"\" && board[position]!= nil\nend", "def position_taken?(board, index)\n board[index] != \" \" && board[index] != \"\"\nend", "def position_taken? (board, position)\n if (board[position] == \" \" || board[position] == \"\" || board[position] == nil)\n false\n else\n true\n end \nend", "def position_taken? (board, index)\n board[index] != \" \"\nend", "def position_taken?(board, location)\n if board[location] == \" \" || board[location] == \"\" || board[location] == nil\n false\n else true\n end\nend", "def position_taken?(index)\n (@board[index] == \" \") || (@board[index] == \"\") || (@board[index] == nil) ? false : true\nend", "def position_taken?(board, index)\n check = board[index]\n if check == \" \" || check == \"\" || check == nil\n false\n else\n true\n end\nend", "def position_taken?(board, index) \n\tboard[index] != \" \"\nend", "def position_taken?(location)\n !(board[location] == \" \" || board[location].nil?)\nend", "def position_taken?(board, position)\n if board[position] == \" \"\n false\n elsif board[position] == nil || board[position] == \"\"\n false\n else\n true\n end\nend", "def is_space(input)\n input[0] == \" \"\nend", "def position_taken?(board, index)\n (board[index] == \" \" || board[index] == \"\" || board[index] == nil) ?\n false : true\n end", "def position_taken?(board, position)\n !(board[position] == nil? || board[position] == \" \")\nend", "def inside_empty_brackets?\n bracket?(prev_char) && bracket?(next_char) && inside_blank_pair?\n end", "def position_taken? (board, index)\n board[index]==\" \" || board[index]==\"\" || board[index]==nil ? false : true\nend", "def stalemate?\n\n\t\t@symbol_counter = 0\n\n\t\t(0..8).each do |i|\n\t\t\tif @field[i].value != \" \"\n\t\t\t\t@symbol_counter += 1\n\t\t\tend\n\t\tend\n\n\t\tif @symbol_counter == 9\n\t\t\treturn true\n\t\telse\n\t\t\treturn false\n\t\tend\n\n\tend", "def position_taken?(board, index)\n board[index] == \" \" || board[index] == \"\" || board[index] == nil ? false : true\nend", "def full?\r\n @board.each do |space|\r\n if space == \" \"\r\n return false\r\n end\r\n end\r\n true\r\n end", "def position_taken?(board,index)\n board[index] == \" \" || board[index] == \"\" || board[index] == nil ? false:true\nend", "def position_taken? (index)\n @board[index] != \" \" ? true : false\n end" ]
[ "0.6832021", "0.651518", "0.6242812", "0.62184983", "0.6162069", "0.6143169", "0.6126169", "0.6107561", "0.61052454", "0.61001885", "0.60994846", "0.6076188", "0.60572034", "0.60383356", "0.5999305", "0.5988711", "0.59877175", "0.59841573", "0.59668326", "0.595133", "0.595133", "0.595133", "0.595133", "0.595133", "0.595133", "0.595133", "0.595133", "0.595133", "0.595133", "0.59446746", "0.5943552", "0.5934371", "0.5919354", "0.5916195", "0.5909996", "0.59010565", "0.59004086", "0.58989626", "0.5897342", "0.58939815", "0.5889312", "0.5881889", "0.5870994", "0.58700097", "0.5869628", "0.586428", "0.58595484", "0.5835807", "0.5829562", "0.580988", "0.58081955", "0.5806268", "0.58025616", "0.58024853", "0.5797406", "0.5792036", "0.5789999", "0.57860756", "0.57860756", "0.57860756", "0.57860756", "0.57860756", "0.57860756", "0.57853687", "0.57819045", "0.5777801", "0.5777801", "0.57768416", "0.5776137", "0.57751244", "0.57751244", "0.5764179", "0.57629", "0.5759432", "0.5756264", "0.57481277", "0.5742896", "0.5742627", "0.5742627", "0.57416666", "0.57409245", "0.5740544", "0.57392776", "0.5730243", "0.5728985", "0.5726705", "0.5692293", "0.5691155", "0.56864274", "0.56863195", "0.5672528", "0.56668234", "0.56660986", "0.56660444", "0.5658481", "0.5657005", "0.5653561", "0.5652553", "0.56470424", "0.56457675", "0.5644096" ]
0.0
-1
Counts the number of spaces after the lbracket.
def count_spaces(lexed_line, column) event_index = lexed_line.event_index(column) if event_index.nil? log 'No lbracket in this line. Moving on...' @do_measurement = false return end next_event = lexed_line.at(event_index + 1) log "Next event: #{next_event}" if next_event.nil? log 'lbracket must be at the end of the line.' @do_measurement = false return 0 end [:on_nl, :on_ignored_nl].each do |event| if next_event[1] == event log "lbracket is followed by a '#{event}'. Moving on." @do_measurement = false return 0 end end if next_event[1] == :on_rbracket log 'lbracket is followed by a rbracket. Moving on.' @do_measurement = false return 0 end second_next_event = lexed_line.at(event_index + 2) log "Event + 2: #{second_next_event}" [:on_comment, :on_lbrace].each do |event| if second_next_event[1] == event log "Event + 2 is a #{event}. Moving on." @do_measurement = false return next_event.last.size end end next_event[1] != :on_sp ? 0 : next_event.last.size end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def count_spaces(lexed_line, column)\n event_index = lexed_line.event_index(column)\n\n if event_index.nil?\n log 'No lbrace in this line. Moving on...'\n @do_measurement = false\n return\n end\n\n next_event = lexed_line.at(event_index + 1)\n\n if next_event.nil?\n log 'lbrace must be at the end of the line. Moving on.'\n @do_measurement = false\n return 0\n end\n\n if next_event[1] == :on_nl || next_event[1] == :on_ignored_nl\n log \"lbrace is followed by a '#{next_event[1]}'. Moving on.\"\n @do_measurement = false\n return 0\n end\n\n if next_event[1] == :on_rbrace\n log 'lbrace is followed by an rbrace. Moving on.'\n @do_measurement = false\n return 0\n end\n\n second_next_event = lexed_line.at(event_index + 2)\n if second_next_event[1] == :on_comment\n log 'Event + 2 is a comment.'\n @do_measurement = false\n return next_event.last.size\n end\n\n next_event[1] != :on_sp ? 0 : next_event.last.size\n end", "def count_spaces (foo)\n foo.count(\" \")\n end", "def count_indent(line)\n line.match(/(\\s+)/)[1].length\nend", "def level_of_indent\n self.scan(/^ *(?=\\S)/).map { |space| space.length }.min || 0\n end", "def level_of_indent\n self.scan(/^ *(?=\\S)/).map { |space| space.length }.min || 0\n end", "def level\n (@line[/^#+/] || '').size\n end", "def indent_width(txt)\n txt.match(/\\A\\s*/).to_s.length\n end", "def line_level line\n line.match(/^[ \\t]*/)[0].gsub(\"\\t\", \" \").split('').length\n end", "def increase_spaces()\n @spaces += 1\n end", "def length_term\n self.gsub(/\\e\\[[^m]*m/, '').length\n end", "def count_spaces string\n string.count(\" \")\nend", "def list_indent_level\n @list_indent_stack.length\n end", "def list_indent_level\n @list_indent_stack.length\n end", "def counting_spaces\n i = 0\n while i < 9 do\n result = @array.at(i)\n result.each do |num|\n if num == 0\n @@count = @@count + 1\n end\n end\n i = i + 1\n end\n end", "def count_spaces(str)\n count = 0\n str.split(\"\").each do |char|\n if char == \"\\s\"\n count += 1\n end\n end\n count\n end", "def indentize!(count, char = ' ')\n tap do |s|\n s.gsub!(/([^\\n]*)(\\n|$)/) do\n s1 = Regexp.last_match(1)\n s2 = Regexp.last_match(2)\n not_empty = s1 != '' || s2 != ''\n \"#{char * count}#{s1}#{s2}\" if not_empty\n end\n end\n end", "def count_spaces(str)\n count = 0\n space = \" \"\n str.each_char do |char|\n if char == space\n count += 1\n end\n end\n count\n end", "def count_spaces(str)\n str.count(\" \")\nend", "def whitespace_token\n return if !(match = @chunk.match(WHITESPACE)) || (@chunk[0] == \"\\n\")\n prev = @tokens[-1]\n prev.send(match ? :spaced= : :new_line=, true) if prev\n match ? match[0].size : 0\n end", "def width\n theWidth = 0\n @theLines.each { |l| theWidth = l.length if l.length > theWidth }\n theWidth\n end", "def count_space(array)\n return 0 if array.empty?\n char = array.shift\n is_space(char) + count_space(array)\nend", "def indentation_level\n spaces = (@source.size - @stripped_source.size)\n spaces == 0 ? 0 : spaces / 2\n end", "def number_of_rows(matrix)\n counter = 1\n matrix.each_char { |symb|\n counter += 1 if symb == \"\\n\"\n }\n counter\nend", "def count_spaces string\n count = 0\n space = \" \"\n string.each_char do |char|\n if char == space\n count += 1\n end\n end\n count\nend", "def count_spaces(str)\n count = 0\n space = \" \"\n str.each_char do |char|\n if char == space\n count += 1\n end\n end\n count\nend", "def word_spacing_for_this_line\n if @align == :justify &&\n @line_wrap.space_count > 0 &&\n !@line_wrap.paragraph_finished?\n (@width - @line_wrap.width) / @line_wrap.space_count\n else\n 0\n end\n end", "def count_spaces(string)\n count = 0\n space = \" \"\n string.each_char do |char|\n if char == space\n count+=1\n end\n end\n count\nend", "def calculate_word_count\n 0x0C\n end", "def turn_count(board)\n counter = 0 \n board.each do |space|\n if space != \" \" \n then counter += 1 \n end\n end\n return counter\nend", "def space\n self.last.to_i - self.first.to_i + 1\n end", "def word_spacing_for_this_line\n if @align == :justify && (@force_justify || (@line_wrap.space_count > 0 && !@line_wrap.paragraph_finished?))\n (available_width - @line_wrap.width) / @line_wrap.space_count\n else\n 0\n end\n end", "def process_current_level\n @previous_level = @current_level * 1\n leading_whitespace = self.class.get_leading_whitespace_from_text @text\n if leading_whitespace == \"\"\n @current_level = 0\n \n # If there is leading whitespace but indent_token is still empty string\n elsif @indent_token == \"\"\n @indent_token = leading_whitespace\n @current_level = 1\n \n # Else, set current_level to number of repetitions of index_token in leading_whitespace\n else\n i = 0\n while leading_whitespace.index(@indent_token) == 0 do\n leading_whitespace = leading_whitespace[@indent_token.length..-1]\n i += 1\n end\n @current_level = i\n end\n \n self\n end", "def calculate_word_count\n 0x0A\n end", "def get_indent_level(line)\n\t\tres = 0\n\t\twhile line[res] == \"\\t\"\n\t\t\tres += 1\n\t\tend\n\t\treturn res\n\tend", "def count_spaces(string)\n count = 0\n string.chars { |char| if char === \" \" then count += 1 end}\n return count\nend", "def turn_count\n count = 0\n @cells.each do |element|\n count += 1 if element != \" \"\n end\n count\n end", "def turn_count(board)\n 9 - board.count(\" \")\nend", "def li_number\n self.lineitems.size\n end", "def vspace\n\t\t\[email protected][range].lines.count\n\t\tend", "def turn_count(board)\n counter = 0\n board.each do |x| if x !=\" \"\n counter +=1\n end \n end\n counter\n end", "def line\n\t return -1 if @inputStack.empty? # only if initialize() arg is bogus\n\n\t input = @inputStack[0] # not @inputStack.last\n\t str = input.string[0 .. input.pos]\n\t return str.count(\"\\n\") + 1\n\tend", "def remaining\n 80 - current_line.size\n end", "def length\n (lines.map do |line|\n Strings::Align.display_width(line)\n end << 0).max\n end", "def determine_line_number(scanner)\n scanner.string[0, scanner.pos].count(\"\\n\")\n end", "def line_length(line)\n line.chomp.gsub(/\\e\\[[\\d;]*m/, '').length\n end", "def turn_count\n counter = 0\n cells.each do |index|\n if index != \" \"\n counter += 1\n end\n end\n counter\n end", "def line_count\n\t\tlines.size\n\tend", "def line_count\n\t\tlines.size\n\tend", "def turn_count\n counter = 0\n @cells.each do |cell|\n if cell != \" \"\n counter += 1\n end\n end\n counter\n end", "def word_count(text, len)\r\n words, strays = text.length.divmod(len)\r\n words += 1 if strays > 0\r\n pad = \"X\" * (len - strays)\r\n return [words, pad]\r\n end", "def _spaces\n _save = self.pos # repetition\n _count = 0\n while true\n\n begin # choice\n _tmp = apply(:_space)\n break if _tmp\n _tmp = apply(:_comment)\n end while false # end choice\n\n break unless _tmp\n _count += 1\n end\n _tmp = _count >= 1\n unless _tmp\n self.pos = _save\n end # end repetition\n set_failed_rule :_spaces unless _tmp\n return _tmp\n end", "def line_length(line)\n line.chomp.gsub(/\\e\\[[\\d;]*m/, '').length\n end", "def length\n count = 0\n each { count += 1 }\n count\n end", "def turn_count\n @cells.select{|position| position != \" \"}.count\n end", "def word_counter(string)\n\n if string.empty? #== 0, suggested by Rubocop\n i_num_words = 0\n else\n new_string = string\n new_string = new_string.delete \" \"\n i_num_words = string.length - new_string.length + 1\n end\n return i_num_words\nend", "def printing_width(str)\n str.gsub(/\\x1b\\[[\\d;]+[A-z]/, '').size\n end", "def printing_width(str)\n str.gsub(/\\x1b\\[[\\d;]+[A-z]/, '').size\n end", "def horizontal_blank_space(msg_line=\"\")\n screen_width - msg_line.length\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 inc_l\n end", "def turn_count\n self.cells.reject{|cell| cell.include?(\" \")}.count\n end", "def rl_delete_horizontal_space(count, ignore)\r\n start = @rl_point\r\n\r\n while (@rl_point!=0 && whitespace(@rl_line_buffer[@rl_point - 1]))\r\n @rl_point-=1\r\n end\r\n start = @rl_point\r\n while (@rl_point < @rl_end && whitespace(@rl_line_buffer[@rl_point]))\r\n @rl_point+=1\r\n end\r\n if (start != @rl_point)\r\n rl_delete_text(start, @rl_point)\r\n @rl_point = start\r\n end\r\n if (@rl_point < 0)\r\n @rl_point = 0\r\n end\r\n 0\r\n end", "def count\n Jhead.call(\"-c\", @match, @pattern).split(\"\\n\").size\n end", "def spaces; end", "def spaces; end", "def update_counter(text)\n number_of_newlines = text.count(\"\\n\")\n\n if number_of_newlines > 0\n @line += text.count(\"\\n\")\n @column = text.length - text.rindex(\"\\n\")\n else\n @column += text.length\n end\n end", "def turn_count(board)\n counter = 0\n board.each do |token|\n if token != \" \"\n counter += 1\n end\n end\n counter\nend", "def whitespace_token\n return nil unless md=WHITESPACE.match(@chunk)\n input = md.to_a[0]\n input.length\n end", "def number_indents\n 0\n end", "def run_line_length_cop; 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 line_depth(line)\n whitespace = line.scan(/^([\\s]+)/).flatten.first\n if whitespace\n whitespace.length\n else\n 0\n end\n end", "def length\n length = 0; each {length += 1}; length\n end", "def num_chars_left\n @character_limit - length\n end", "def indents\n lines.map do |line|\n line.chars.take_while { |char| char == \" \" }.size / INDENT_WIDTH\n end\n end", "def turn_count\n #@cells.select {|cell| cell == \"X\" || cell == \"O\"}.size\n counter = 0\n @cells.each do |cell|\n if cell != \" \" && cell != \"\"\n counter += 1\n end\n end\n counter\n end", "def count(line)\n\t\tpos = 0\n\t\twhile (pos < line.length)\n\t\t\t# if marker, decompress and count length\n\t\t\t# else add 1 to length, for normal character\n\t\t\tif line[pos] == \"(\"\n\t\t\t\t# substring containing only the marker\n\t\t\t\tmarker = line[pos, line[pos, line.length - pos].index(\")\") + 1]\n\t\t\t\tlen = marker[/(?<=\\()\\d+/].to_i\n\t\t\t\trepeat = marker[/\\d+\\)$/].to_i\n\t\t\t\t@length += repeat * len\n\n\t\t\t\t# move pos onto next piece of data\n\t\t\t\tpos += marker.length + len\n\t\t\telse\n\t\t\t\t@length += 1\n\t\t\t\tpos += 1\n\t\t\tend\n\t\tend\n\tend", "def printer_error(s)\n \"#{s.count('n-z')}/#{s.length}\"\nend", "def current_length; end", "def num_notes\n matches = @token.match(/^Lig(\\d+)/)\n throw :unrecognized, 'no_match' if matches.nil?\n return matches[1].to_i\n end", "def length()\n return to_s.gsub(\" \", \"\").gsub(\"-\", \"\").length\n end", "def word_count\n puts \"\\\\n words chars\"\n puts \"---------------------\"\n puts self.public_send('|',\"wc\")\n self\n end", "def turn_count\n @board.count{|i| i != \" \"}\n end", "def turn_count\n @board.count{|position| position != \" \"}\n end", "def ansi_length(str)\n str.gsub(/\\e\\[(2J|\\d*(;\\d+)*(m|f|H))/, '').length\nend", "def parse_spc\n @spc = @row[/(^[ \\t]+)/,1].to_s #sometime result is nil\n @ron = @row.strip.size\n end", "def chars_left; end", "def length; count end", "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 whitespace_token\n if md=WHITESPACE.match(@chunk)\n input = md.to_a[0]\n input.length\n else\n did_not_match\n end\n end", "def width\n chars.inject(0) { |length, char| length + (char.bytesize == 1 ? 1 : 2) }\n end", "def spacing; 0; end", "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 word_counter(string)\n new_string = string.split\n return new_string.length\nend", "def count_rows(s)\n return nil if s.nil?\n\n col = 1\n row = 1\n\n s.each_char do |c|\n if c == \"\\n\" or col > TA_COLS then\n col = 1\n row += 1\n next\n end\n\n col += 1\n end\n\n row\n end", "def run_length(list)\n return 0 if list.empty?\n return 0 if list.first != \"=\"\n return 1 + run_length(list.rest)\n end", "def length\n @tokens.length\n end", "def length\n @line.length\n end", "def indent2(str, count)\n if str\n char = ' '\n #(char * count) + gsub(/(\\n+)/) { $1 + (char * count) }\n str.gsub(/(\\n+)/) { $1 + (char * count) }\n end\n end", "def word_counter\n \"This is a string\".split.size\nend" ]
[ "0.70418525", "0.658439", "0.6513675", "0.6488543", "0.6488543", "0.6295566", "0.62891656", "0.6245838", "0.6185864", "0.6178162", "0.6155", "0.61413807", "0.61413807", "0.6133925", "0.61050975", "0.5995918", "0.5947635", "0.59331095", "0.5918501", "0.58683413", "0.5821014", "0.57946724", "0.5774198", "0.57589656", "0.5733327", "0.5731637", "0.5707241", "0.56941056", "0.5693072", "0.56878924", "0.5683158", "0.5667707", "0.5667144", "0.5641816", "0.56372976", "0.56312186", "0.56222713", "0.5619309", "0.56112707", "0.56061894", "0.5588872", "0.55816764", "0.55662906", "0.55656505", "0.5563918", "0.55617374", "0.55435336", "0.55435336", "0.55312574", "0.5527961", "0.5527047", "0.5522346", "0.5505074", "0.5495175", "0.5479026", "0.5475558", "0.5475558", "0.54737735", "0.54653406", "0.5464396", "0.5454341", "0.5446769", "0.5446436", "0.54408723", "0.54408723", "0.5439808", "0.54352295", "0.5434227", "0.54337007", "0.542858", "0.5418991", "0.54148346", "0.54110694", "0.54101735", "0.5406086", "0.54052246", "0.54033154", "0.53983766", "0.5397153", "0.5391335", "0.53911567", "0.53859735", "0.5368972", "0.53672093", "0.5357536", "0.5356221", "0.5354991", "0.53542763", "0.5352129", "0.53328454", "0.5332294", "0.53285074", "0.53209233", "0.5313401", "0.5305624", "0.5296492", "0.52859557", "0.52807206", "0.5277602", "0.52757543" ]
0.70826674
0
the attricbutes of the tool when first creating it
def initialize(tool_name, time_used) @tool_name = tool_name #make the given tool name into a instance variable to use in other area @time = time_used #make the given time used into a instance variable to use in other area @tool_health = 100 @current_time = 0 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tool_attrs=(tool_attributes={})\n tool_attributes.each_pair do |k,v|\n tool.send(\"#{k}=\", v)\n end\n end", "def tool_attributes(overrides = {})\n {\n name: \"Pros and Cons\",\n description: \"Weighing up pros and cons can speed up the decision-making process,\n improve your understanding of the situation and help you avoid decision-making\n paralysis.\",\n price: 10.00\n }.merge(overrides)\nend", "def tools\n @tools ||= TOOLS\n end", "def tool_config\n IMS::LTI::ToolConfig.create_from_xml(self.xml)\n end", "def creation #wizard will be able to create objects, his proficiency is based on the skill level he has in this type of magic\r\n \r\n end", "def tool=(name)\n @tool = name.to_sym\n end", "def devtools_identifier=(_arg0); end", "def devtools_identifier; end", "def manifest() @opts.manifest; end", "def setup_info\n {}\n end", "def tool\n name.split('_')[0]\n end", "def create\n @tool = current_user.tools.build(tool_params)\n @user = current_user\n\n if @tool.save\n redirect_to(\n tools_user_path(@tool.owner),\n notice: t(\"tool.created\", name: @tool.name)\n )\n else\n render :new\n end\n end", "def new\n @tool = current_user.tools.new\n @user = current_user\n end", "def maker\n @@maker \n end", "def setup_followertool_usage\n @range_view = 2\n @range_view = 6 if fo_tool.tool_data(\"Tool Target = \", false) == \"true\" ||\n fo_tool.tool_data(\"Tool Special = \", false) == \"autotarget\"\n \n if fo_tool.is_a?(RPG::Skill) || fo_tool.is_a?(RPG::Item)\n if fo_tool.scope.between?(1, 6)\n setup_target \n else ; @targeted_character = $game_player\n @range_view = 6\n end\n # prepare tool for invoke follower\n elsif fo_tool.is_a?(RPG::Weapon) || fo_tool.is_a?(RPG::Armor)\n invoke = fo_tool.tool_data(\"Tool Invoke Skill = \")\n if invoke > 0\n if $data_skills[invoke].scope.between?(1, 6)\n setup_target\n else ; @targeted_character = $game_player\n @range_view = 6\n end\n else\n # no invoke skill just set up an enemy target\n setup_target\n end\n end\n end", "def initialize_generate\n super\n declare_cookbook_gems\n declare_rake_tasks\n declare_guard_sets\n end", "def do_setup; \"\" end", "def create\n @tool = Tool.new(tool_params)\n if @tool.save\n render json: @tool, status: :created\n end\n end", "def effectiveCommander _args\n \"effectiveCommander _args;\" \n end", "def show\n @other_tools = @tool.others_from_this_owner\n @collaborators = @tool.collaborators\n end", "def create\n @breadcrumb = 'create'\n @tool = Tool.new(params[:tool])\n @tool.created_by = current_user.id if !current_user.nil?\n\n respond_to do |format|\n if @tool.save\n format.html { redirect_to @tool, notice: crud_notice('created', @tool) }\n format.json { render json: @tool, status: :created, location: @tool }\n else\n @companies = companies_dropdown\n @offices = offices_dropdown\n @products = products_dropdown\n format.html { render action: \"new\" }\n format.json { render json: @tool.errors, status: :unprocessable_entity }\n end\n end\n end", "def inspect\n \"#<#{self.class.name}:#{object_id} @tool=%s @profile=%s>\" % [tool.inspect, profile.inspect]\n end", "def attributes=(_arg0); end", "def initialize\n @am = RDoc::Markup::AttributeManager.new\n @output = nil\n end", "def show\n @tools = @tool_type.tools\n end", "def linetool\n Sketchup.active_model.select_tool LineTool.new\nend", "def set_tool\n @tool = Tool.find(params[current_user.id])\n end", "def arguments\n self.class.dry_initializer.attributes(self)\n end", "def activate\n #Radiant::Config[\"tools\"] ||= \"i18n_date i18n_archive_title reverse_breadcrumbs asset_helpers\"\n\n RadiantTools.init(Radiant::Config[\"tools\"] || :all)\n end", "def initialize_and_add_tool(p_args)\n\n # Check arguments\n return unless p_args.is_a?(Hash) && p_args.has_keys?(:container, :config)\n\n # Update the configuration on the tool's UI\n widget_hash = p_args[:container]\n tool_config = p_args[:config]\n widget_hash[:ui].extension.set_configuration(tool_config)\n\n # Add the tool to the collection and the form\n tool_count = @tools.length\n @tools << { :widget => widget_hash, :config => tool_config }\n @form.gridLayout.addWidget(widget_hash[:form], tool_count, 0, 1, 1)\n end", "def tool_profile\n IMS::LTI::Models::ToolProfile.new(\n lti_version: 'LTI-2p0',\n product_instance: product_instance,\n resource_handler: resource_handlers,\n base_url_choice: [base_url_choice],\n service_offered: service_offered\n )\n end", "def manifest(m)\r\n load_paths = load_paths('lazydoc', 'configurable', 'tap')\r\n bin_path = File.join(load_paths.last.chomp('lib'), 'bin/tapexe')\r\n \r\n m.template name, 'tap.erb', {\r\n :load_paths => load_paths,\r\n :bin_path => bin_path\r\n }\r\n \r\n m.on(:generate) do \r\n log :chmod, \"0755 #{name}\"\r\n FileUtils.chmod(0755, name)\r\n end\r\n \r\n m.template profile, 'profile.erb', {\r\n :generator => self.class,\r\n :filename => profile\r\n }\r\n end", "def pre_execute\n\n @node['atts'] = []\n end", "def build_tool(rules: [])\n {\n \"driver\": {\n \"name\" => @scan_report.scanner_name,\n \"version\" => @scan_report.version,\n \"informationUri\" => @uri,\n \"rules\" => rules,\n \"properties\" => {\n \"salusEnforced\": @required || false\n }\n }\n }\n end", "def command_builder; end", "def initialize(info={})\n super(update_info(info,\n 'Name' => 'SCRNSAVE T1180 (User-land Persistence)',\n 'Description' => %q{\n To achieve persistence the attacker can modify 'SCRNSAVE.EXE' value in the registry and change its data to point to any malicious file, next the attacker has to enable the screensaver on the endpoint and change screensaver timeout by modifying the registry data for 'ScreenSaveActive' and 'ScreenSaveTimeOut'. Once this is completed, anytime the user leaves their desktop unattended for the specified amount of time, the screensaver function automatically kicks in and executes the attackers malicious PE/Appl.\n },\n 'License' => UNKNOWN_LICENSE,\n 'Author' =>\n [\n 'Module Author: r00t-3xp10it',\n 'Special Thanks: shanty damayanti',\n ],\n \n 'Version' => '$Revision: 1.4',\n 'DisclosureDate' => '11 02 2019',\n 'Platform' => 'windows',\n 'Arch' => 'x86_x64',\n 'Privileged' => 'false', # Thats no need for privilege escalation.\n 'Targets' =>\n [\n # Affected systems are.\n [ 'Windows 2008', 'Windows xp', 'windows vista', 'windows 7', 'windows 9', 'Windows 10' ]\n ],\n 'DefaultTarget' => '6', # Default its to run againts windows 10\n 'References' =>\n [\n [ 'URL', 'https://attack.mitre.org/techniques/T1180/' ],\n [ 'URL', 'https://github.com/r00t-3xp10it/msf-auxiliarys' ],\n [ 'URL', 'https://ired.team/offensive-security/t1180-screensaver-hijack' ],\n [ 'URL', 'https://www.howtogeek.com/225305/how-to-find-and-set-screen-savers-on-windows-10/' ]\n\n\n ],\n\t\t\t'DefaultOptions' =>\n\t\t\t\t{\n 'LOOT_FOLDER' => '/root/.msf4/loot', # Default logs storage directory\n 'APPL_PATH' => '%windir%\\\\System32\\\\calc.exe', # Default PE/appl (payload) to run (test)\n\t\t\t\t},\n 'SessionTypes' => [ 'meterpreter' ]\n \n ))\n \n register_options(\n [\n OptString.new('SESSION', [ true, 'The session number to run this module on', 1]),\n OptString.new('TIME_OUT', [ true, 'Set inactivity timeout before screensaver runs', 10]),\n OptString.new('APPL_PATH', [ true, 'Set absoluct path of malicious PE/Appl to run'])\n ], self.class)\n\n register_advanced_options(\n [\n OptBool.new('LOG_OFF', [ false, 'Logoff current user to force registry refresh?', false]),\n OptString.new('LOOT_FOLDER', [ true, 'Set the absoluct path where to store revert.rc (local)'])\n ], self.class)\n\n end", "def toolbox(type)\n end", "def toolbox(type)\n end", "def toolbox(type)\n end", "def generate_options\n cli_class.all_commands[\"generate\"].options\n end", "def use_predefined_tool\n update_follower_movement\n return if @targeted_character.nil?\n if obj_size?(@targeted_character, @range_view) && @follower_attacktimer == 0\n turn_toward_character(@targeted_character) \n use_weapon(fo_tool.id) if actor.primary_use == 1 \n use_armor(fo_tool.id) if actor.primary_use == 2\n use_item(fo_tool.id) if actor.primary_use == 3 || actor.primary_use == 4 ||\n actor.primary_use == 5 || actor.primary_use == 6\n \n use_skill(fo_tool.id) if actor.primary_use==7 || actor.primary_use==8 ||\n actor.primary_use == 9 || actor.primary_use == 10\n \n if fo_tool.tool_data(\"User Graphic = \", false).nil?\n @targeted_character = nil\n turn_toward_player\n end\n @follower_attacktimer = 60\n end\n delete_targetf if self.actor.dead?\n end", "def initialize\n @attribute_manager = RDoc::Markup::AttributeManager.new\n @output = nil\n end", "def create\n @tool = Tool.new(tool_params)\n user = User.find(params[:user_id])\n @tool.user_id = current_user.id\n respond_to do |format|\n if @tool.save\n format.html { redirect_to user_tools_path, notice: 'Tool was successfully added.' }\n format.json { render :show, status: :created, location: @tool }\n else\n format.html { render :new }\n format.json { render json: @tool.errors, status: :unprocessable_entity }\n end\n end\n end", "def initialize(opts={})\n self.verbosity = opts[:verbosity]\n self.can_install = opts[:install]\n\tself.manifest = \"init.pp\"\n self.node_manager = NodeManager.new(self)\n end", "def crew _args\n \"crew _args;\" \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 command_name; end", "def setup\r\n end", "def set_tool\n @tool = Tool.find(params[:id])\n end", "def set_tool\n @tool = Tool.find(params[:id])\n end", "def tidy_exe\n @tidy_exe\n end", "def get_tool_data(words, create)\n create ? (@tool_data[words] ||= ToolData.new(words)) : @tool_data[words]\n end", "def arguments(model)\n args = OpenStudio::Measure::OSArgumentVector.new\n \n # Add a check box for specifying verbose info statements\n\tverbose_info_statements = OpenStudio::Ruleset::OSArgument::makeBoolArgument(\"verbose_info_statements\", false)\n\tverbose_info_statements.setDisplayName(\"Check to allow measure to generate verbose runner.registerInfo statements.\")\n\tverbose_info_statements.setDefaultValue(false)\n\targs << verbose_info_statements\n\n # 1) make an argument for <conditioned> thermal zone(s) to apply EMS t-stat schedule changes to \n tz_handles = OpenStudio::StringVector.new\n tz_display_names = OpenStudio::StringVector.new\n\n # put thermal zone names into a hash\n tz_hash = {}\n model.getThermalZones.each do |tz|\n tz_hash[tz.name.to_s] = tz\n end\n\n # looping through a sorted hash of zones\n tz_hash.sort.map do |tz_name, tz|\n if tz.thermostatSetpointDualSetpoint.is_initialized\n tstat = tz.thermostatSetpointDualSetpoint.get\n if tstat.heatingSetpointTemperatureSchedule.is_initialized || tstat.coolingSetpointTemperatureSchedule.is_initialized\n tz_handles << tz.handle.to_s\n tz_display_names << tz_name\n end\n end\n end\n\n # add building to string vector with zones\n building = model.getBuilding\n tz_handles << building.handle.to_s\n \n tz_display_names << '*All Conditioned Thermal Zones*' \n \n zones = OpenStudio::Measure::OSArgument.makeChoiceArgument('zones', tz_handles, tz_display_names, true)\n zones.setDisplayName('Choose Conditioned Thermal Zone(s) to apply EMS Program T-stat changes to.')\n zones.setDefaultValue('*All Conditioned Thermal Zones*') # if no zone is chosen this will run on all zones\n args << zones\n \n # 2) make a choice argument for setting EMS InternalVariableAvailabilityDictionaryReporting value\n int_var_avail_dict_rep_chs = OpenStudio::StringVector.new\n int_var_avail_dict_rep_chs << 'None'\n int_var_avail_dict_rep_chs << 'NotByUniqueKeyNames'\n int_var_avail_dict_rep_chs << 'Verbose'\n \n internal_variable_availability_dictionary_reporting = OpenStudio::Measure::OSArgument.makeChoiceArgument('internal_variable_availability_dictionary_reporting', int_var_avail_dict_rep_chs, true)\n internal_variable_availability_dictionary_reporting.setDisplayName('Level of output reporting related to the EMS internal variables that are available.')\n internal_variable_availability_dictionary_reporting.setDefaultValue('None')\n args << internal_variable_availability_dictionary_reporting\n \n # 3) make a choice argument for setting EMSRuntimeLanguageDebugOutputLevel value\n ems_runtime_language_debug_level_chs = OpenStudio::StringVector.new\n ems_runtime_language_debug_level_chs << 'None'\n ems_runtime_language_debug_level_chs << 'ErrorsOnly'\n ems_runtime_language_debug_level_chs << 'Verbose'\n \n ems_runtime_language_debug_output_level = OpenStudio::Measure::OSArgument.makeChoiceArgument('ems_runtime_language_debug_output_level', ems_runtime_language_debug_level_chs, true)\n ems_runtime_language_debug_output_level.setDisplayName('Level of output reporting related to the execution of EnergyPlus Runtime Language, written to .edd file.')\n ems_runtime_language_debug_output_level.setDefaultValue('None')\n args << ems_runtime_language_debug_output_level\n \n # 4) make a choice argument for setting EMS ActuatorAvailabilityDictionaryReportingvalue\n actuator_avail_dict_rep_chs = OpenStudio::StringVector.new\n actuator_avail_dict_rep_chs << 'None'\n actuator_avail_dict_rep_chs << 'NotByUniqueKeyNames'\n actuator_avail_dict_rep_chs << 'Verbose'\n \n actuator_availability_dictionary_reporting = OpenStudio::Measure::OSArgument.makeChoiceArgument('actuator_availability_dictionary_reporting', actuator_avail_dict_rep_chs, true)\n actuator_availability_dictionary_reporting.setDisplayName('Level of output reporting related to the EMS actuators that are available.')\n actuator_availability_dictionary_reporting.setDefaultValue('None')\n args << actuator_availability_dictionary_reporting\n \n return args\n end", "def initialize\n @option = Tools::Option.new\n end", "def attr_info; end", "def create\n @tool = Tool.new(tool_params)\n\n respond_to do |format|\n if @tool.save\n format.html { redirect_to @tool, notice: 'Tool was successfully created.' }\n format.json { render :show, status: :created, location: @tool }\n else\n format.html { render :new }\n format.json { render json: @tool.errors, status: :unprocessable_entity }\n end\n end\n end", "def setup\n ''\n end", "def tool_params\n params.require(:tool).permit(:name, :description, :image, :serial, :barcode, :date_purchased, :capability, :reservable, :max_reservation_time, :category_ids=>[])\n end", "def commander _args\n \"commander _args;\" \n end", "def tool\n return @tool if @tool\n\n tools.each do |k, v|\n next unless command? v\n return @tool = k\n end\n @tool\n end", "def work_tool(tool)### set and get\r\n @tool = tool\r\n puts \"#{@name} works using a #{@tool} #{return_phtest_writer}\"\r\n end", "def tool_params\n params.require(:tool).permit(:name, :serial, :model, :location, :location_id, :category_id, :purchased, :cost, :value, :put_in_service, :loaner, :in_service, :retired, :condition, :annual_service, :note, :tab)\n end", "def initialize(info = {})\n ret = super(info)\n\n register_advanced_options(\n [\n Msf::OptBool.new('PrependSetresuid',\n [\n false,\n \"Prepend a stub that executes the setresuid(0, 0, 0) system call\",\n false\n ]\n ),\n Msf::OptBool.new('PrependSetreuid',\n [\n false,\n \"Prepend a stub that executes the setreuid(0, 0) system call\",\n false\n ]\n ),\n Msf::OptBool.new('PrependSetuid',\n [\n false,\n \"Prepend a stub that executes the setuid(0) system call\",\n false\n ]\n ),\n Msf::OptBool.new('PrependSetresgid',\n [\n false,\n \"Prepend a stub that executes the setresgid(0, 0, 0) system call\",\n false\n ]\n ),\n Msf::OptBool.new('PrependSetregid',\n [\n false,\n \"Prepend a stub that executes the setregid(0, 0) system call\",\n false\n ]\n ),\n Msf::OptBool.new('PrependSetgid',\n [\n false,\n \"Prepend a stub that executes the setgid(0) system call\",\n false\n ]\n ),\n Msf::OptBool.new('AppendExit',\n [\n false,\n \"Append a stub that executes the exit(0) system call\",\n false\n ]\n ),\n ], Msf::Payload::Bsd)\n\n ret\n end", "def manifest\n anno = IIIF::Presentation::Annotation.new('on' => path)\n anno.resource = create_resource\n canvas.images << anno\n canvas.other_content = [annotations]\n manifest = IIIF::Presentation::Manifest.new(\n '@id' => path,\n 'label' => \"Histonets - Collection Template #{id}\"\n )\n sequence.canvases << canvas\n manifest.sequences << sequence\n manifest\n end", "def promotion_tools\n @title = \"Promotion Tools\"\n end", "def initialize_generate\n super\n add_accessors\n declare_guardfile\n declare_chefignore_patterns\n end", "def arguments(model)\n args = OpenStudio::Measure::OSArgumentVector.new\n \n # Add a check box for specifying verbose info statements\n\tverbose_info_statements = OpenStudio::Ruleset::OSArgument::makeBoolArgument(\"verbose_info_statements\", false)\n\tverbose_info_statements.setDisplayName(\"Check to allow measure to generate verbose runner.registerInfo statements.\")\n\tverbose_info_statements.setDefaultValue(false)\n\targs << verbose_info_statements\n \n # Choice List Argument for Qualifying DX Cooling Coil Object (should be a member of a PTHP zone equipment object) \n dx_single_speed_clg_coils_handles = OpenStudio::StringVector.new\n dx_single_speed_clg_coils_display_names = OpenStudio::StringVector.new\n model.getZoneHVACPackagedTerminalHeatPumps.each do |zoneHVACPackagedTerminalHeatPump|\n dx_cooling_coil = zoneHVACPackagedTerminalHeatPump.coolingCoil.to_CoilCoolingDXSingleSpeed.get \n dx_single_speed_clg_coils_handles << dx_cooling_coil.handle.to_s\n dx_single_speed_clg_coils_display_names << dx_cooling_coil.name.to_s\n end # end loop through coil_cooling_DX_single_speed objects \n \n building = model.getBuilding\n dx_single_speed_clg_coils_handles << building.handle.to_s\n dx_single_speed_clg_coils_display_names << '*All Single Speed DX Cooling Coils*' \n \n # Make an argument for CoilCoolingDXSingleSpeeds objects\n coil_cooling_DX_single_speed_objects = OpenStudio::Ruleset::OSArgument::makeChoiceArgument(\"coil_cooling_DX_single_speed_objects\", dx_single_speed_clg_coils_handles, dx_single_speed_clg_coils_display_names,true)\n coil_cooling_DX_single_speed_objects.setDisplayName(\"Choose a Single Speed DX Cooling Coil belonging to a PTHP object to apply CoolCapFT curve to.\")\n coil_cooling_DX_single_speed_objects.setDefaultValue('*All Single Speed DX Cooling Coils*') \n args << coil_cooling_DX_single_speed_objects\n \n #make an argument for the OA DB temp below which the capacity of the DX cooling coil changes\n oa_db_curve_threshold_temp = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"oa_db_curve_threshold_temp\",true)\n oa_db_curve_threshold_temp.setDisplayName(\"The Outdoor Dry Bulb Temp (Deg F) below which the 'CoolCapFT' curve will be enabled.\")\n oa_db_curve_threshold_temp.setDefaultValue(87.8)\n args << oa_db_curve_threshold_temp\n\n # Double Precision Argument for C2A Replacement HPACCoolCapFT biquadratic curve attribute\n c2_a = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"c2_a\",true)\n c2_a.setDisplayName(\"The value of a in curve 'a + b (Twb;i) + c (Twb;i) + d (Tc;i) + e (Tc;i) + f (Twb;i) (Tc;i)'.\")\n c2_a.setDefaultValue(0.942567793) \n args << c2_a\n\n # Double Precision Argument for C2B Replacement HPACCoolCapFT biquadratic curve attribute\n c2_b = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"c2_b\",true)\n c2_b.setDisplayName(\"The value of b in curve 'a + b (Twb;i) + c (Twb;i) + d (Tc;i) + e (Tc;i) + f (Twb;i) (Tc;i)'.\")\n c2_b.setDefaultValue(-0.009543347) \n args << c2_b\n \n # Double Precision Argument for C2C Replacement HPACCoolCapFT biquadratic curve attribute\n c2_c = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"c2_c\",true)\n c2_c.setDisplayName(\"The value of c in curve 'a + b (Twb;i) + c (Twb;i) + d (Tc;i) + e (Tc;i) + f (Twb;i) (Tc;i)'.\")\n c2_c.setDefaultValue(0.000683770)\n args << c2_c\n\n # Double Precision Argument for C2D Replacement HPACCoolCapFT biquadratic curve attribute\n c2_d = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"c2_d\",true)\n c2_d.setDisplayName(\"The value of d in curve 'a + b (Twb;i) + c (Twb;i) + d (Tc;i) + e (Tc;i) + f (Twb;i) (Tc;i)'.\")\n c2_d.setDefaultValue(-0.011042676)\n args << c2_d\n\n # Double Precision Argument for C2E Replacement HPACCoolCapFT biquadratic curve attribute\n c2_e = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"c2_e\",true)\n c2_e.setDisplayName(\"The value of e in curve 'a + b (Twb;i) + c (Twb;i) + d (Tc;i) + e (Tc;i) + f (Twb;i) (Tc;i)'.\")\n c2_e.setDefaultValue(0.000005249)\n args << c2_e\n\n # Double Precision Argument for C2F Replacement HPACCoolCapFT biquadratic curve attribute\n c2_f = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"c2_f\",true)\n c2_f.setDisplayName(\"The value of f in curve 'a + b (Twb;i) + c (Twb;i) + d (Tc;i) + e (Tc;i) + f (Twb;i) (Tc;i)'.\")\n c2_f.setDefaultValue(-0.000009720)\n args << c2_f\n\n # make a choice argument for setting EMS InternalVariableAvailabilityDictionaryReporting value\n int_var_avail_dict_rep_chs = OpenStudio::StringVector.new\n int_var_avail_dict_rep_chs << 'None'\n int_var_avail_dict_rep_chs << 'NotByUniqueKeyNames'\n int_var_avail_dict_rep_chs << 'Verbose'\n \n internal_variable_availability_dictionary_reporting = OpenStudio::Measure::OSArgument.makeChoiceArgument('internal_variable_availability_dictionary_reporting', int_var_avail_dict_rep_chs, true)\n internal_variable_availability_dictionary_reporting.setDisplayName('Level of output reporting related to the EMS internal variables that are available.')\n internal_variable_availability_dictionary_reporting.setDefaultValue('None')\n args << internal_variable_availability_dictionary_reporting\n \n # make a choice argument for setting EMSRuntimeLanguageDebugOutputLevel value\n ems_runtime_language_debug_level_chs = OpenStudio::StringVector.new\n ems_runtime_language_debug_level_chs << 'None'\n ems_runtime_language_debug_level_chs << 'ErrorsOnly'\n ems_runtime_language_debug_level_chs << 'Verbose'\n \n ems_runtime_language_debug_output_level = OpenStudio::Measure::OSArgument.makeChoiceArgument('ems_runtime_language_debug_output_level', ems_runtime_language_debug_level_chs, true)\n ems_runtime_language_debug_output_level.setDisplayName('Level of output reporting related to the execution of EnergyPlus Runtime Language, written to .edd file.')\n ems_runtime_language_debug_output_level.setDefaultValue('None')\n args << ems_runtime_language_debug_output_level\n \n # make a choice argument for setting EMS ActuatorAvailabilityDictionaryReportingvalue\n actuator_avail_dict_rep_chs = OpenStudio::StringVector.new\n actuator_avail_dict_rep_chs << 'None'\n actuator_avail_dict_rep_chs << 'NotByUniqueKeyNames'\n actuator_avail_dict_rep_chs << 'Verbose'\n \n actuator_availability_dictionary_reporting = OpenStudio::Measure::OSArgument.makeChoiceArgument('actuator_availability_dictionary_reporting', actuator_avail_dict_rep_chs, true)\n actuator_availability_dictionary_reporting.setDisplayName('Level of output reporting related to the EMS actuators that are available.')\n actuator_availability_dictionary_reporting.setDefaultValue('None')\n args << actuator_availability_dictionary_reporting\n \n return args\n \n end", "def setup\n\t\tend", "def setup\n\t\tend", "def external_file_attributes=(_arg0); end", "def arguments(model)\n args = OpenStudio::Measure::OSArgumentVector.new\n \n # Add a check box for specifying verbose info statements\n\tverbose_info_statements = OpenStudio::Ruleset::OSArgument::makeBoolArgument(\"verbose_info_statements\", false)\n\tverbose_info_statements.setDisplayName(\"Check to allow measure to generate verbose runner.registerInfo statements.\")\n\tverbose_info_statements.setDefaultValue(false)\n\targs << verbose_info_statements\n\n # Make arrays of qualified plant loops names and handles\n condenser_plantloop_handles = OpenStudio::StringVector.new\n condenser_plantloop_display_names = OpenStudio::StringVector.new\n model.getPlantLoops.each do |plant_loop|\n show_loop = false\n if plant_loop.sizingPlant.loopType == \"Condenser\"\n show_loop = true\n end \n if show_loop == true\n condenser_plantloop_handles << plant_loop.handle.to_s\n condenser_plantloop_display_names << plant_loop.name.to_s\n end\n end # end loop through plant loops \n \n building = model.getBuilding\n condenser_plantloop_handles << building.handle.to_s\n condenser_plantloop_display_names << '*All Condenser Plant Loops*' \n \n # Make an argument for condensor plant loop\n condensor_plant_loop_objects = OpenStudio::Ruleset::OSArgument::makeChoiceArgument(\"condensor_plant_loop_objects\", condenser_plantloop_handles, condenser_plantloop_display_names,true)\n condensor_plant_loop_objects.setDisplayName(\"Choose a Condenser Plant Loop to apply plant control overrides to.\")\n condensor_plant_loop_objects.setDefaultValue('*All Condenser Plant Loops*') \n args << condensor_plant_loop_objects\n \n #make an argument for the OA DB temp below which to disable the condenser plant loop operation \n oa_db_override_temp = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"oa_db_override_temp\",true)\n oa_db_override_temp.setDisplayName(\"The Outdoor Dry Bulb Temp (Deg F) below which the condenser plant loop will not be allowed to operate.\")\n oa_db_override_temp.setDefaultValue(42.8)\n args << oa_db_override_temp\n \n # make a choice argument for setting EMS InternalVariableAvailabilityDictionaryReporting value\n int_var_avail_dict_rep_chs = OpenStudio::StringVector.new\n int_var_avail_dict_rep_chs << 'None'\n int_var_avail_dict_rep_chs << 'NotByUniqueKeyNames'\n int_var_avail_dict_rep_chs << 'Verbose'\n \n internal_variable_availability_dictionary_reporting = OpenStudio::Measure::OSArgument.makeChoiceArgument('internal_variable_availability_dictionary_reporting', int_var_avail_dict_rep_chs, true)\n internal_variable_availability_dictionary_reporting.setDisplayName('Level of output reporting related to the EMS internal variables that are available.')\n internal_variable_availability_dictionary_reporting.setDefaultValue('None')\n args << internal_variable_availability_dictionary_reporting\n \n # make a choice argument for setting EMSRuntimeLanguageDebugOutputLevel value\n ems_runtime_language_debug_level_chs = OpenStudio::StringVector.new\n ems_runtime_language_debug_level_chs << 'None'\n ems_runtime_language_debug_level_chs << 'ErrorsOnly'\n ems_runtime_language_debug_level_chs << 'Verbose'\n \n ems_runtime_language_debug_output_level = OpenStudio::Measure::OSArgument.makeChoiceArgument('ems_runtime_language_debug_output_level', ems_runtime_language_debug_level_chs, true)\n ems_runtime_language_debug_output_level.setDisplayName('Level of output reporting related to the execution of EnergyPlus Runtime Language, written to .edd file.')\n ems_runtime_language_debug_output_level.setDefaultValue('None')\n args << ems_runtime_language_debug_output_level\n \n # make a choice argument for setting EMS ActuatorAvailabilityDictionaryReportingvalue\n actuator_avail_dict_rep_chs = OpenStudio::StringVector.new\n actuator_avail_dict_rep_chs << 'None'\n actuator_avail_dict_rep_chs << 'NotByUniqueKeyNames'\n actuator_avail_dict_rep_chs << 'Verbose'\n \n actuator_availability_dictionary_reporting = OpenStudio::Measure::OSArgument.makeChoiceArgument('actuator_availability_dictionary_reporting', actuator_avail_dict_rep_chs, true)\n actuator_availability_dictionary_reporting.setDisplayName('Level of output reporting related to the EMS actuators that are available.')\n actuator_availability_dictionary_reporting.setDefaultValue('None')\n args << actuator_availability_dictionary_reporting\n \n return args\n \n end", "def tools_setup(config)\n config[:tools].each_key do |name|\n tool = config[:tools][name]\n\n # populate name if not given\n tool[:name] = name.to_s if (tool[:name].nil?)\n\n # handle inline ruby string substitution in executable\n if (tool[:executable] =~ RUBY_STRING_REPLACEMENT_PATTERN)\n tool[:executable].replace(@system_wrapper.module_eval(tool[:executable]))\n end\n\n # populate stderr redirect option\n tool[:stderr_redirect] = StdErrRedirect::NONE if (tool[:stderr_redirect].nil?)\n\n # populate background execution option\n tool[:background_exec] = BackgroundExec::NONE if (tool[:background_exec].nil?)\n\n # populate optional option to control verification of executable in search paths\n tool[:optional] = false if (tool[:optional].nil?)\n end\n end", "def arguments(model)\n args = OpenStudio::Ruleset::OSArgumentVector.new\n \n # Make an argument to apply/not apply this measure\n chs = OpenStudio::StringVector.new\n chs << \"TRUE\"\n chs << \"FALSE\"\n apply_measure = OpenStudio::Ruleset::OSArgument::makeChoiceArgument('apply_measure', chs, true)\n apply_measure.setDisplayName(\"Apply Measure?\")\n apply_measure.setDefaultValue(\"TRUE\")\n args << apply_measure\n \n #Argument 1 Type of Chilled Beam System, required, choice, default Active\n beam_options = [\"Active\", \"Passive\"]\n cooled_beam_type = OpenStudio::Ruleset::OSArgument::makeChoiceArgument(\"cooled_beam_type\", beam_options,true)\n cooled_beam_type.setDisplayName('Select the Type of Chilled Beam to be added and indicate the Thermal Zones that Chilled Beams will be added to. NOTE: Users should confirm subsequent chilled beam model parameters. Defaulted coefficient values may not be representative of actual chilled beam performance')\n cooled_beam_type.setDefaultValue(\"Active\")\n args << cooled_beam_type\n \n #Argument 3 Chilled Water Loop selection or creation \n existing_plant_loops = model.getPlantLoops\n existing_chilled_loops = existing_plant_loops.select{ |pl| pl.sizingPlant.loopType() == \"Cooling\"}\n existing_plant_names = existing_chilled_loops.select{ |pl| not pl.name.empty?}.collect{ |pl| pl.name.get }\n existing_plant_names << \"Create New\"\n existing_plant_loop_name = OpenStudio::Ruleset::OSArgument::makeChoiceArgument(\"existing_plant_loop_name\", existing_plant_names, true)\n existing_plant_loop_name.setDisplayName('Chilled Water loop serving chilled beams. If \"Create New\" is selected a loop containing an air cooled chiller (COP=3.5) generating chilled water at 57 Deg F will be created. A constant speed pump (with user defined pressure rise) will be created.')\n existing_plant_loop_name.setDefaultValue (\"Create New\")\n args << existing_plant_loop_name\n \n #argument 4, new loop rated pump head type double, required, double, default 60 feet\n new_loop_rated_pump_head = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('new_loop_pump_head', true)\n new_loop_rated_pump_head.setDisplayName('The pump head (in feet of water) that will be assigned to the primary chilled water loop circulation pump. This argument will only be used if a new chilled water plant loop is created.')\n new_loop_rated_pump_head.setDefaultValue (60)\n args<< new_loop_rated_pump_head\n #must check interpretation of the 60 default value for pump head. meant to be 60 feet.\n \n #argument 5. air_loop_name, required, double, default Create New\n air_loops_list = model.getAirLoopHVACs.collect { |l| l.name.get }\n air_loops_list << \"Create New\"\n air_loop_name = OpenStudio::Ruleset::OSArgument::makeChoiceArgument('air_loop_name', air_loops_list, true)\n air_loop_name.setDisplayName('Air loop to serve selected zones by chilled beam units. This should be an air loop configured as a DOAS. If \"Create New\" is selected, an air loop containing a Dual Wheel DOAS system with a chilled water coil served by the user selected chiller plant loop will be created. The DOAS will be configured to deliver a constant temperature of 65 Deg F to connected zones.')\n air_loop_name.setDefaultValue (\"Create New\")\n args << air_loop_name\n \n #argument 5.5 (mislabeled in spec) new airloop fan pressure rise, required, double, default none\n new_airloop_fan_pressure_rise = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('new_airloop_fan_pressure_rise',true)\n new_airloop_fan_pressure_rise.setDisplayName('The pressure rise (inches of water) that will be assigned to the constant speed fans of a new air loop. This pressure rise, which includes the pressure across an energy wheel, will be split evenly between the new supply and exhaust fans.')\n new_airloop_fan_pressure_rise.setDefaultValue(\"5.00\")\n args << new_airloop_fan_pressure_rise\n \n #argument 6 supply air vol flow rate, double, default to -1\n supply_air_vol_flow_rate = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('supply_air_vol_flow_rate',true)\n supply_air_vol_flow_rate.setDisplayName('The combined air flow rate (cfm) of the supply air serving all chilled beams in a zone. Enter -1 to autosize (based on the zone ventilation requirement). If a value is entered, and multiple thermal zones are selected, this value will be hard coded to all selected zones.')\n supply_air_vol_flow_rate.setDefaultValue(\"-1\")\n args << supply_air_vol_flow_rate\n \n #argument 7 max tot chw vol flow rate, required, double, default -1\n max_tot_chw_vol_flow_rate = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('max_tot_chw_vol_flow_rate',true)\n max_tot_chw_vol_flow_rate.setDisplayName('Combined maximum chilled water flow rate (gpm) of all chilled beam units serving a zone. Enter -1 to autosize based on the zone design load. If a value is entered, and multiple thermal zones are selected, this value will be hard coded to all selected zones.')\n max_tot_chw_vol_flow_rate.setDefaultValue(\"-1\")\n args << max_tot_chw_vol_flow_rate\n \n #arg 8 number of beams, required, double, default -1\n number_of_beams = OpenStudio::Ruleset::OSArgument::makeIntegerArgument('number_of_beams',true)\n number_of_beams.setDisplayName('The number of individual chilled beam units serving each zone. Enter -1 to autosize based on a value of 1.11 GPM per chilled beam unit.')\n number_of_beams.setDefaultValue(\"-1\")\n args << number_of_beams\n \n #arg9 beam_length, required, double, defailt -1\n beam_length = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('beam_length',true)\n beam_length.setDisplayName('The length (ft) of an individual beam. Enter -1 to autosize based upon the # of beam units and the zone design sensible cooling load.')\n beam_length.setDefaultValue(\"-1\")\n args << beam_length\n \n #arg10 design_inlet_water_temperature, requried, double, default 59\n design_inlet_water_temperature = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('design_inlet_water_temperature',true)\n design_inlet_water_temperature.setDisplayName('The design inlet water temperature (Deg F) of a beam unit.')\n design_inlet_water_temperature.setDefaultValue(\"59\")\n args << design_inlet_water_temperature\n \n #arg11 design_outlet_water_temperature, required, double, default 62.6\n design_outlet_water_temperature = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('design_outlet_water_temperature',true)\n design_outlet_water_temperature.setDisplayName('The design outlet water temperature )Deg F) of the beam units.')\n design_outlet_water_temperature.setDefaultValue(\"62.6\")\n args << design_outlet_water_temperature\n \n #arg12 coil_surface_area_per_coil_length, required, double, default 17.78\n coil_surface_area_per_coil_length = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('coil_surface_area_per_coil_length',true)\n coil_surface_area_per_coil_length.setDisplayName('Surface area on the air side of the beam per unit beam length (ft^2/ft). This parameter is a unique value representing specific chilled beam products. See E+ Engineering Reference for equation details')\n coil_surface_area_per_coil_length.setDefaultValue(\"17.78\")\n args << coil_surface_area_per_coil_length\n \n #arg13 coefficient_alpha required, double, default 15.3\n coefficient_alpha = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('coefficient_alpha',true)\n coefficient_alpha.setDisplayName('Model parameter alpha (unitless). This parameter is a unique value representing specific chilled beam products. See E+ Engineering Reference for equation details')\n coefficient_alpha.setDefaultValue(\"15.3\")\n args << coefficient_alpha\n \n #arg14 coefficient_n1, required, double, default 0\n coefficient_n1 = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('coefficient_n1',true)\n coefficient_n1.setDisplayName('Model parameter n1 (unitless). This parameter is a unique value representing specific chilled beam products. See E+ Engineering Reference for equation details')\n coefficient_n1.setDefaultValue(\"0\")\n args << coefficient_n1\n \n #arg15 coefficient_n2,required, double, default .84)\n coefficient_n2 = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('coefficient_n2',true)\n coefficient_n2.setDisplayName('Model parameter n2 (unitless). This parameter is a unique value representing specific chilled beam products. See E+ Engineering Reference for equation details')\n coefficient_n2.setDefaultValue(\"0.84\")\n args << coefficient_n2\n\n #arg16 coefficient_n3,required, double, default .84)\n coefficient_n3 = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('coefficient_n3',true)\n coefficient_n3.setDisplayName('Model parameter n3 (unitless). This parameter is a unique value representing specific chilled beam products. See E+ Engineering Reference for equation details')\n coefficient_n3.setDefaultValue(\".12\")\n args << coefficient_n3\n \n #arg17 coefficient_a0,required, double, default .5610)\n coefficient_a0 = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('coefficient_a0',true)\n coefficient_a0.setDisplayName('Model parameter a0 (unitless). This parameter is a unique value representing specific chilled beam products. See E+ Engineering Reference for equation details')\n coefficient_a0.setDefaultValue(\".5610\")\n args << coefficient_a0\n \n #arg18 coefficient_k1,required, double, default .00571)\n coefficient_k1 = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('coefficient_k1',true)\n coefficient_k1.setDisplayName('Model parameter k1 (unitless). This parameter is a unique value representing specific chilled beam products. See E+ Engineering Reference for equation details')\n coefficient_k1.setDefaultValue(\".005710\")\n args << coefficient_k1\n \n #arg19 coefficient_n,required, double, default .40)\n coefficient_n = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('coefficient_n',true)\n coefficient_n.setDisplayName('Model parameter n (unitless). This parameter is a unique value representing specific chilled beam products. See E+ Engineering Reference for equation details')\n coefficient_n.setDefaultValue(\".400\")\n args << coefficient_n\n \n #arg20 coefficient_kin,required, double, default 2.0)\n coefficient_kin = OpenStudio::Ruleset::OSArgument::makeDoubleArgument('coefficient_kin',true)\n coefficient_kin.setDisplayName('Model parameter kin (unitless). This parameter is a unique value representing specific chilled beam products. See E+ Engineering Reference for equation details')\n coefficient_kin.setDefaultValue(\"2.0\")\n args << coefficient_kin\n \n #argument 21 leaving_pipe_inside_dia, required, choice, default \"1/2 type K\"\n pipe_inside_dia_options = [\"1/2 Type K\", \"1/2 Type L\", \"3/4 Type K\", \"3/4 Type L\"]\n leaving_pipe_inside_dia = OpenStudio::Ruleset::OSArgument::makeChoiceArgument(\"leaving_pipe_inside_dia\", pipe_inside_dia_options,true)\n leaving_pipe_inside_dia.setDisplayName('Diameter (inches) of the chilled beam unit water inlet and outlet pipe connections.')\n leaving_pipe_inside_dia.setDefaultValue(\"1/2 Type K\")\n args << leaving_pipe_inside_dia\n #note: [1/2 TypeK = .527 ] [1/2 Type L = .545] [3/4 type k = .745] [3/4 type l=.785]\n \n return args\n end", "def create_command_help\n puts \"The Ruby Farm - a simple command line animals app\"\n puts\n puts \"Command Usage:\"\n puts \" [create | c] <name=> <type=> creates a animal with name\"\n puts \"\"\n puts \"Examples:\"\n puts \" bin/run [create | c] name=my_animal_name\"\n puts \" bin/run [create | c] name=my_animal_name type=pig\"\n end", "def cmd; end", "def createEphem(targetName)\n\n cmd = \"#{$cmdPre}ataephem \" + targetName;\n doCmd(cmd);\n cmd = \"#{$cmdPre}atawrapephem \" + targetName + \".ephem\";\n doCmd(cmd);\n\n return targetName + \".ephem\"\n\nend", "def tool_action_text(tool_action)\n tool_action\n end", "def tool_params\n params.require(:tool).permit(\n :name,\n :slug,\n :type,\n :description,\n :source_url,\n :instructions,\n :up_for_adoption\n )\n end", "def generate\n super\n end", "def setup\n add_standard_properties\n #\n create_banner\n create_standard_options\n create_advanced_options\n create_mode_options\n create_application_options\n create_feature_options\n create_tail_options\n #\n parse_options\n load_config_configuration\n create_result_directory\n load_results_archive\n end", "def arguments(model)\n args = OpenStudio::Ruleset::OSArgumentVector.new\n \n #make a choice argument for model objects\n water_fixture_def_display_names = OpenStudio::StringVector.new\n water_fixture_def_handles = OpenStudio::StringVector.new\n \n #putting model object and names into hash\n model.getWaterUseEquipmentDefinitions.each do |water_fixture_def|\n water_fixture_def_display_names << water_fixture_def.name.to_s\n water_fixture_def_handles << water_fixture_def.handle.to_s\n end\n \n #make a choice argument for the light fixture to replace\n water_fixture_def = OpenStudio::Ruleset::OSArgument::makeChoiceArgument(\"water_fixture_def\", water_fixture_def_handles, water_fixture_def_display_names)\n water_fixture_def.setDisplayName(\"Choose a Water Fixture Type to Install Aerators On.\")\n args << water_fixture_def\n\n #make an argument for the number of lamps\n pct_flow_reduction = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"pct_flow_reduction\",true)\n pct_flow_reduction.setDisplayName(\"Percent Flow Reduction (%)\")\n pct_flow_reduction.setDefaultValue(50.0)\n args << pct_flow_reduction\n \n #make an argument for material and installation cost per fixture\n material_and_installation_cost_per_fixture = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"material_and_installation_cost_per_fixture\",true)\n material_and_installation_cost_per_fixture.setDisplayName(\"Cost to Install Aerators per Fixture ($).\")\n material_and_installation_cost_per_fixture.setDefaultValue(0.0)\n args << material_and_installation_cost_per_fixture\n \n return args\n end", "def build_conversion\n {\n \"tool\": {\n \"driver\": {\n \"name\": \"Salus\",\n \"informationUri\": DEFAULT_URI\n }\n }\n }\n end", "def create(url, tooling_name, tooling_url, toolchain)\n CCProcess.start(\"sdk-manage --target --install '#{@name}' '#{url}'\" +\n (tooling_name.to_s.empty? ? \"\" : \" --tooling '#{tooling_name}'\") +\n (tooling_url.to_s.empty? ? \"\" : \" --tooling-url '#{tooling_url}'\") +\n (toolchain.to_s.empty? ? \"\" : \" --toolchain '#{toolchain}'\"),\n (_ :adding_target) + \" #{@name}\", 60*60, 1)\n end", "def set_tool\n @tool = Tool.find(params[:id])\n end", "def initialize \n self.help = false\n end", "def make; end", "def create_tool\n if @work_order_tool.present?\n render json: :conflict, status: :conflict\n else\n @work_order_tool = WorkOrderTool.new\n @work_order_tool.assign_attributes(@json['data'])\n if !@json['data']['created_by']\n @work_order_tool.created_by = current_user.id if !current_user.nil?\n end\n if @work_order_tool.save\n render json: serialized_work_order_tool(@work_order_tool), status: :created\n else\n render json: format_errors(@work_order_tool), status: :unprocessable_entity\n end\n end\n end", "def command_start=(_arg0); end", "def command_start=(_arg0); end", "def command_start=(_arg0); end", "def arguments(model)\n args = OpenStudio::Ruleset::OSArgumentVector.new\n\n #make a choice argument for model objects\n lighting_def_handles = OpenStudio::StringVector.new\n lighting_def_display_names = OpenStudio::StringVector.new\n\n #putting model object and names into hash\n lighting_def_hash = {}\n \n building = model.getBuilding\n lighting_def_display_names << \"*All Lights*\"\n lighting_def_handles << building.handle.to_s\n\n model.getLightsDefinitions.each do |lighting_def|\n lighting_def_display_names << lighting_def.name.to_s\n lighting_def_handles << lighting_def.handle.to_s\n end\n \n model.getLuminaireDefinitions.each do |lighting_def|\n lighting_def_display_names << lighting_def.name.to_s\n lighting_def_handles << lighting_def.handle.to_s\n end\n \n #make a choice argument for space type\n light_def = OpenStudio::Ruleset::OSArgument::makeChoiceArgument(\"light_def\", lighting_def_handles, lighting_def_display_names)\n light_def.setDisplayName(\"Apply the Measure to a Specific Lighting Definition or to All Lights in the model.\")\n light_def.setDefaultValue(\"*All Lights*\") \n args << light_def\n\n #make an argument for reduction percentage\n lighting_power_reduction_percent = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"lighting_power_reduction_percent\",true)\n lighting_power_reduction_percent.setDisplayName(\"Lighting Power Reduction (%).\")\n lighting_power_reduction_percent.setDefaultValue(30.0)\n args << lighting_power_reduction_percent\n\n #make an argument for material and installation cost\n material_and_installation_cost = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"material_and_installation_cost\",true)\n material_and_installation_cost.setDisplayName(\"Building Level Increase in Material and Installation Cost.\")\n material_and_installation_cost.setDefaultValue(0.0)\n args << material_and_installation_cost\n\n #make an argument for expected life\n expected_life = OpenStudio::Ruleset::OSArgument::makeIntegerArgument(\"expected_life\",true)\n expected_life.setDisplayName(\"Expected Life (whole years).\")\n expected_life.setDefaultValue(100)\n args << expected_life\n\n #make an argument for O & M cost\n om_cost = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"om_cost\",true)\n om_cost.setDisplayName(\"Building Level Increase in O & M Costs.\")\n om_cost.setDefaultValue(0.0)\n args << om_cost\n\n #make an argument for O & M frequency\n om_frequency = OpenStudio::Ruleset::OSArgument::makeIntegerArgument(\"om_frequency\",true)\n om_frequency.setDisplayName(\"O & M Frequency (whole years).\")\n om_frequency.setDefaultValue(1)\n args << om_frequency\n\n return args\n end", "def create_container_and_configuration(p_args)\n\n # Create container\n tool_container = GuiUtils.create_child_form({\n\t\t\t\t:class => Ui_ToolDescriptionWidget,\n :flags => 0,\n\t\t\t\t:base_widget => CustomFontWidget.new(@tools_form),\n\t\t\t})\n\n # Create configuration\n tool_config = ToolConfiguration.new(p_args)\n\n # Return results\n { :container => tool_container, :config => tool_config }\n end", "def command_start; end", "def command_start; end", "def command_start; end", "def arguments(model)\n args = OpenStudio::Measure::OSArgumentVector.new\n\n # make an argument for add_constructions\n add_constructions = OpenStudio::Measure::OSArgument.makeBoolArgument('add_constructions', true)\n add_constructions.setDisplayName('Add Constructions to Model')\n add_constructions.setDescription('The Construction Set will be applied to the entire building')\n add_constructions.setDefaultValue(true)\n args << add_constructions\n\n # make an argument for wall and roof construction template\n construction_set_chs = OpenStudio::StringVector.new\n construction_set_chs << '90.1-2019'\n construction_set_chs << 'Good'\n construction_set_chs << 'Better'\n construction_set_chs << 'ZE AEDG Multifamily Recommendations'\n wall_roof_construction_template = OpenStudio::Measure::OSArgument.makeChoiceArgument('wall_roof_construction_template', construction_set_chs, true)\n wall_roof_construction_template.setDisplayName('Construction template for adding wall and roof constructions')\n wall_roof_construction_template.setDescription('The constructions will be applied to the entire building')\n wall_roof_construction_template.setDefaultValue('ZE AEDG Multifamily Recommendations')\n args << wall_roof_construction_template\n\n # make an argument for window construction template\n construction_set_chs = OpenStudio::StringVector.new\n construction_set_chs << '90.1-2019'\n construction_set_chs << 'Good'\n construction_set_chs << 'Better'\n construction_set_chs << 'ZE AEDG Multifamily Recommendations'\n window_construction_template = OpenStudio::Measure::OSArgument.makeChoiceArgument('window_construction_template', construction_set_chs, true)\n window_construction_template.setDisplayName('Construction template for adding window constructions')\n window_construction_template.setDescription('The constructions will be applied to the entire building')\n window_construction_template.setDefaultValue('ZE AEDG Multifamily Recommendations')\n args << window_construction_template\n\n # make an argument for add_space_type_loads\n add_space_type_loads = OpenStudio::Measure::OSArgument.makeBoolArgument('add_space_type_loads', true)\n add_space_type_loads.setDisplayName('Add Space Type Loads to Model')\n add_space_type_loads.setDescription('Populate existing space types in model with internal loads.')\n add_space_type_loads.setDefaultValue(true)\n args << add_space_type_loads\n\n # make an argument for add_elevators\n add_elevators = OpenStudio::Measure::OSArgument.makeBoolArgument('add_elevators', true)\n add_elevators.setDisplayName('Add Elevators to Model')\n add_elevators.setDescription('Elevators will be add directly to space in model vs. being applied to a space type.')\n add_elevators.setDefaultValue(false)\n args << add_elevators\n\n # make an argument for elev_spaces\n # todo - make sure this is setup to handle no elevators and also that it handles bad names well.\n elev_spaces = OpenStudio::Measure::OSArgument.makeStringArgument('elev_spaces', true)\n elev_spaces.setDisplayName('Elevator Spaces')\n elev_spaces.setDescription('Comma separated names of spaces for elevator. Each space listed will have associated elevator loads.')\n elev_spaces.setDefaultValue(\"Elevator_1_4,Elevator_2_4\")\n args << elev_spaces\n\n # elevator type\n elevator_type_chs = OpenStudio::StringVector.new\n elevator_type_chs << 'Traction'\n elevator_type_chs << 'Hydraulic'\n # todo - could include auto that looks at number of stories\n elevator_type = OpenStudio::Measure::OSArgument.makeChoiceArgument('elevator_type', elevator_type_chs, true)\n elevator_type.setDisplayName('Elevator Type')\n elevator_type.setDescription('This will impact loads, schedules, and fraction of heat lost.')\n elevator_type.setDefaultValue('Traction')\n args << elevator_type\n\n # make an argument for add_internal_mass\n add_internal_mass = OpenStudio::Measure::OSArgument.makeBoolArgument('add_internal_mass', true)\n add_internal_mass.setDisplayName('Add Internal Mass to Model')\n add_internal_mass.setDescription('Adds internal mass to each space.')\n add_internal_mass.setDefaultValue(true)\n args << add_internal_mass\n\n # make an argument for add_exterior_lights\n add_exterior_lights = OpenStudio::Measure::OSArgument.makeBoolArgument('add_exterior_lights', true)\n add_exterior_lights.setDisplayName('Add Exterior Lights to Model')\n add_exterior_lights.setDescription('Multiple exterior lights objects will be added for different classes of lighting such as parking and facade.')\n add_exterior_lights.setDefaultValue(true)\n args << add_exterior_lights\n\n # make an argument for onsite_parking_fraction\n onsite_parking_fraction = OpenStudio::Measure::OSArgument.makeDoubleArgument('onsite_parking_fraction', true)\n onsite_parking_fraction.setDisplayName('Onsite Parking Fraction')\n onsite_parking_fraction.setDescription('If set to 0 no exterior lighting for parking will be added')\n onsite_parking_fraction.setDefaultValue(0.0)\n args << onsite_parking_fraction\n\n # make an argument for add_thermostat\n add_thermostat = OpenStudio::Measure::OSArgument.makeBoolArgument('add_thermostat', true)\n add_thermostat.setDisplayName('Add Thermostats')\n add_thermostat.setDescription('Add Thermostat to model based on Space Type Standards information of spaces assigned to thermal zones.')\n add_thermostat.setDefaultValue(true)\n args << add_thermostat\n\n # make an argument for add_swh\n add_swh = OpenStudio::Measure::OSArgument.makeBoolArgument('add_swh', true)\n add_swh.setDisplayName('Add Service Water Heating to Model')\n add_swh.setDescription('This will add both the supply and demand side of service water heating.')\n add_swh.setDefaultValue(true)\n args << add_swh\n\n swh_chs = OpenStudio::StringVector.new\n swh_chs << 'HeatPump'\n swh_type = OpenStudio::Measure::OSArgument.makeChoiceArgument('swh_type', swh_chs, true)\n swh_type.setDisplayName('Service Water Heating Source')\n swh_type.setDescription('The primary source of heating used by SWH systems in the model.')\n swh_type.setDefaultValue('HeatPump')\n args << swh_type\n\n # make an argument for add_hvac\n add_hvac = OpenStudio::Measure::OSArgument.makeBoolArgument('add_hvac', true)\n add_hvac.setDisplayName('Add HVAC System to Model')\n add_hvac.setDefaultValue(true)\n args << add_hvac\n\n # Make argument for system type\n hvac_chs = OpenStudio::StringVector.new\n hvac_chs << 'Minisplit Heat Pumps with DOAS'\n hvac_chs << 'Minisplit Heat Pumps with ERVs'\n hvac_chs << 'PTHPs with DOAS'\n hvac_chs << 'PTHPs with ERVs'\n hvac_chs << 'Four-pipe Fan Coils with central air-source heat pump with DOAS'\n hvac_chs << 'Four-pipe Fan Coils with central air-source heat pump with ERVs'\n hvac_chs << 'Water Source Heat Pumps with Boiler and Fluid-cooler with DOAS'\n hvac_chs << 'Water Source Heat Pumps with Boiler and Fluid-cooler with ERVs'\n hvac_chs << 'Water Source Heat Pumps with Ground Source Heat Pump with DOAS'\n hvac_chs << 'Water Source Heat Pumps with Ground Source Heat Pump with ERVs'\n hvac_system_type = OpenStudio::Measure::OSArgument.makeChoiceArgument('hvac_system_type', hvac_chs, true)\n hvac_system_type.setDisplayName('HVAC System Type')\n hvac_system_type.setDefaultValue('Four-pipe Fan Coils with central air-source heat pump with DOAS')\n args << hvac_system_type\n\n # make an argument for remove_objects\n # remove_objects = OpenStudio::Measure::OSArgument.makeBoolArgument('remove_objects', true)\n # remove_objects.setDisplayName('Clean Model of non-geometry objects')\n # remove_objects.setDescription('Only removes objects of type that are selected to be added.')\n # remove_objects.setDefaultValue(true)\n # args << remove_objects\n\n return args\n end", "def create\n @tool = Tool.new(params[:tool])\n\n respond_to do |format|\n if @tool.save\n format.html { redirect_to @tool, notice: 'Tool was successfully created.' }\n format.json { render json: @tool, status: :created, location: @tool }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tool.errors, status: :unprocessable_entity }\n end\n end\n end", "def tool_names\n tools.map{|e| e.const_name }\n end", "def arguments(model)\n args = OpenStudio::Measure::OSArgumentVector.new\n \n # Add a check box for specifying verbose info statements\n\tverbose_info_statements = OpenStudio::Ruleset::OSArgument::makeBoolArgument(\"verbose_info_statements\", false)\n\tverbose_info_statements.setDisplayName(\"Check to allow measure to generate verbose runner.registerInfo statements.\")\n\tverbose_info_statements.setDefaultValue(false)\n\targs << verbose_info_statements\n \n # Note: There does not seem to be a way to retrieve the linkage between \n # existing ZoneHVACIdealLoadsAirSystemideal objects and their \n # attached Thermal Zones (via the API). Therefore this measure will \n # ask the user which existing conditioned thermal zones to \n # convert to be served by (autosized) ZoneHVACIdealLoadsAirSystems from a choice list. \n # initially, the choice list will only be populated by Thermal zones which are \n # (1) conditioned and (2) served only by ZoneHVAC Equipment objetcs, which this \n # measure will delete. \n \n # 1) make an argument for <conditioned> thermal zone(s) served only by ZoneHVAC equipment \n # to apply ZoneHVACIdealLoadsAirSystem assignments to \n tz_handles = OpenStudio::StringVector.new\n tz_display_names = OpenStudio::StringVector.new\n\n # put all thermal zone names into a hash\n tz_hash = {}\n model.getThermalZones.each do |tz|\n tz_hash[tz.name.to_s] = tz\n end\n\n # looping through a sorted hash of zones to place 'qualified' thermal zones within\n # must be conditioned and not attached to an airloop\n tz_hash.sort.map do |tz_name, tz|\n if tz.thermostatSetpointDualSetpoint.is_initialized\n tstat = tz.thermostatSetpointDualSetpoint.get\n if tstat.heatingSetpointTemperatureSchedule.is_initialized || tstat.coolingSetpointTemperatureSchedule.is_initialized\n if tz.airLoopHVAC.empty?\n tz_handles << tz.handle.to_s\n tz_display_names << tz_name\n end\n end\n end\n end\n\n # add building to string vector with zones\n building = model.getBuilding\n tz_handles << building.handle.to_s\n tz_display_names << '*All Cond. Zones not served by Air Loops*' \n \n zones = OpenStudio::Measure::OSArgument.makeChoiceArgument('zones', tz_handles, tz_display_names, true)\n zones.setDisplayName('Choose Conditioned Thermal Zone(s) to apply Ideal HVAC system changes to.')\n zones.setDefaultValue('*All Cond. Zones not served by Air Loops*') # if no zone is chosen this will run on all zones\n args << zones\n \n # Make a double precision argument for the Supply Mass Flow rate for Heating \n heating_mdot_per_ft2 = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"heating_mdot_per_ft2\",true)\n heating_mdot_per_ft2.setDisplayName(\"Htg Supply Airflow\")\n heating_mdot_per_ft2.setDescription(\"Airflow of Zone Ideal HVAC system when in heating mode in cfm/ft^2.\")\n heating_mdot_per_ft2.setDefaultValue(1.0)\n heating_mdot_per_ft2.setMinValue(0.0)\n heating_mdot_per_ft2.setMaxValue(3.0)\n args << heating_mdot_per_ft2\n \n # Make a double precision argument for the Supply Mass Flow rate for Cooling\n cooling_mdot_per_ft2 = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"cooling_mdot_per_ft2\",true)\n cooling_mdot_per_ft2.setDisplayName(\"Clg Supply Airflow\")\n cooling_mdot_per_ft2.setDescription(\"Airflow of Zone Ideal HVAC system when in cooling mode in cfm/ft^2.\")\n cooling_mdot_per_ft2.setDefaultValue(1.2)\n cooling_mdot_per_ft2.setMinValue(0.0)\n cooling_mdot_per_ft2.setMaxValue(3.0)\n args << cooling_mdot_per_ft2\n\n # Make a double precision argument for the Supply Air Dry Bulb Temperature for Heating \n heating_LAT = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"heating_LAT\",true)\n heating_LAT.setDisplayName(\"Htg LAT\")\n heating_LAT.setDescription(\"Supply Air Temp of Zone Ideal HVAC system when in heating mode, Deg F.\")\n heating_LAT.setDefaultValue(105)\n heating_LAT.setMinValue(90)\n heating_LAT.setMaxValue(120)\n args << heating_LAT\n\n # Make a double precision argument for the Supply Air Dry Bulb Temperature for Cooling\n cooling_LAT = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"cooling_LAT\",true)\n cooling_LAT.setDisplayName(\"Clg LAT\")\n cooling_LAT.setDescription(\"Supply Air Temp of Zone Ideal HVAC system when in cooling mode, Deg F.\")\n cooling_LAT.setDefaultValue(55)\n cooling_LAT.setMinValue(42)\n cooling_LAT.setMaxValue(65)\n args << cooling_LAT\n \n # Make a double precision argument for the Supply Air Humidity Ratio for Heating \n heating_HumRat = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"heating_HumRat\",true)\n heating_HumRat.setDisplayName(\"Htg HumRat\")\n heating_HumRat.setDescription(\"Supply Air Humidity Ratio of Zone Ideal HVAC system when in heating mode, (lb H2O/lb dry air).\")\n heating_HumRat.setDefaultValue(0.015)\n heating_HumRat.setMinValue(0.006)\n heating_HumRat.setMaxValue(0.017)\n args << heating_HumRat\n \n # Make a double precision argument for the Supply Air Humidity Ratio for Cooling\n cooling_HumRat = OpenStudio::Ruleset::OSArgument::makeDoubleArgument(\"cooling_HumRat\",true)\n cooling_HumRat.setDisplayName(\"Clg HumRat\")\n cooling_HumRat.setDescription(\"Supply Air Humidity Ratio of Zone Ideal HVAC system when in cooling mode, (lb H2O/lb dry air).\")\n cooling_HumRat.setDefaultValue(0.009)\n cooling_HumRat.setMinValue(0.006)\n cooling_HumRat.setMaxValue(0.017)\n args << cooling_HumRat\n\n # make a choice argument for setting EMS InternalVariableAvailabilityDictionaryReporting value\n int_var_avail_dict_rep_chs = OpenStudio::StringVector.new\n int_var_avail_dict_rep_chs << 'None'\n int_var_avail_dict_rep_chs << 'NotByUniqueKeyNames'\n int_var_avail_dict_rep_chs << 'Verbose'\n \n internal_variable_availability_dictionary_reporting = OpenStudio::Measure::OSArgument.makeChoiceArgument('internal_variable_availability_dictionary_reporting', int_var_avail_dict_rep_chs, true)\n internal_variable_availability_dictionary_reporting.setDisplayName('Level of output reporting related to the EMS internal variables that are available.')\n internal_variable_availability_dictionary_reporting.setDefaultValue('None')\n args << internal_variable_availability_dictionary_reporting\n \n # make a choice argument for setting EMSRuntimeLanguageDebugOutputLevel value\n ems_runtime_language_debug_level_chs = OpenStudio::StringVector.new\n ems_runtime_language_debug_level_chs << 'None'\n ems_runtime_language_debug_level_chs << 'ErrorsOnly'\n ems_runtime_language_debug_level_chs << 'Verbose'\n \n ems_runtime_language_debug_output_level = OpenStudio::Measure::OSArgument.makeChoiceArgument('ems_runtime_language_debug_output_level', ems_runtime_language_debug_level_chs, true)\n ems_runtime_language_debug_output_level.setDisplayName('Level of output reporting related to the execution of EnergyPlus Runtime Language, written to .edd file.')\n ems_runtime_language_debug_output_level.setDefaultValue('None')\n args << ems_runtime_language_debug_output_level\n \n # make a choice argument for setting EMS ActuatorAvailabilityDictionaryReportingvalue\n actuator_avail_dict_rep_chs = OpenStudio::StringVector.new\n actuator_avail_dict_rep_chs << 'None'\n actuator_avail_dict_rep_chs << 'NotByUniqueKeyNames'\n actuator_avail_dict_rep_chs << 'Verbose'\n \n actuator_availability_dictionary_reporting = OpenStudio::Measure::OSArgument.makeChoiceArgument('actuator_availability_dictionary_reporting', actuator_avail_dict_rep_chs, true)\n actuator_availability_dictionary_reporting.setDisplayName('Level of output reporting related to the EMS actuators that are available.')\n actuator_availability_dictionary_reporting.setDefaultValue('None')\n args << actuator_availability_dictionary_reporting\n \n return args\n end", "def create\n @user = current_user\n @tool = Tool.new(params[:tool])\n @job = Jobsite.find(@tool.jobsite_id)\n @tool.user_id = @user.id\n @user.tools << @tool\n @job.tools << @tool\n\n respond_to do |format|\n if @tool.save\n format.html { redirect_to @tool, notice: 'Tool was successfully created.' }\n format.json { render json: @tool, status: :created, location: @tool }\n else\n format.html { render action: \"new\" }\n format.json { render json: @tool.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.6415285", "0.64112633", "0.5985611", "0.5779437", "0.5768114", "0.57666206", "0.57365674", "0.5706035", "0.570463", "0.57045114", "0.5644419", "0.5628853", "0.5617216", "0.55888355", "0.55859834", "0.55729324", "0.5508657", "0.5502608", "0.5494366", "0.5489616", "0.5489081", "0.54865783", "0.5458073", "0.54515547", "0.5441706", "0.5424804", "0.5421428", "0.54153496", "0.5408495", "0.53889334", "0.5385132", "0.53805906", "0.53699106", "0.5369647", "0.5355696", "0.53520244", "0.5338017", "0.5338017", "0.5338017", "0.5325691", "0.53071254", "0.5306628", "0.5287387", "0.5278984", "0.5271412", "0.52711725", "0.52704024", "0.52616066", "0.5260157", "0.5260157", "0.52541006", "0.5252278", "0.5248784", "0.5234623", "0.52237827", "0.522342", "0.5213378", "0.52009416", "0.51981187", "0.5189508", "0.5184005", "0.51835847", "0.5183436", "0.51804894", "0.51787335", "0.5175947", "0.5166827", "0.516584", "0.516584", "0.5165101", "0.51575947", "0.5150942", "0.51494765", "0.51438403", "0.51428825", "0.5142567", "0.51404434", "0.5131448", "0.5129558", "0.512849", "0.5127339", "0.5125672", "0.51231235", "0.5122228", "0.5119922", "0.51170415", "0.5097331", "0.5091167", "0.5091167", "0.5091167", "0.5090491", "0.5089929", "0.5087262", "0.5087262", "0.5087262", "0.50849646", "0.5083989", "0.50812316", "0.50781333", "0.5078047" ]
0.5848172
3
the damage done and what happen to the tool and item
def damage(item_damaged) #allow the item class to be use through the parameter until @current_time == @time || item_damaged.item_health == 0 || @tool_health == 0 item_damaged.item_health -= 5 @tool_health -= 10 @current_time += 1 end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def perform_damage_effect\n end", "def perform_damage_effect\n end", "def item_effect_no_recovery(item)\r\n # If HP recovery rate and recovery amount are 0\r\n if item.recover_hp_rate == 0 and item.recover_hp == 0\r\n # Set damage to empty string\r\n self.damage = ''\r\n # If SP recovery rate / recovery amount are 0, and parameter increase\r\n # value is ineffective.\r\n if item.recover_sp_rate == 0 and item.recover_sp == 0 and\r\n (item.parameter_type == 0 or item.parameter_points == 0)\r\n # If state is unchanged\r\n unless @state_changed\r\n # Set damage to \"Miss\"\r\n self.damage = 'Miss'\r\n end\r\n end\r\n end\r\n end", "def process_tool_action(item)\n PearlKernel.load_item(item)\n return if !battler.tool_ready?(item)\n \n unless PearlKernel.has_data?\n if item.is_a?(RPG::Weapon) || item.is_a?(RPG::Armor)\n msgbox('Tool data missing') if $DEBUG\n return\n end\n if item.scope.between?(1, 6)\n msgbox('Tool data missing') if $DEBUG\n return\n elsif item.scope == 0\n return\n \n elsif !battler.usable?(item)\n RPG::SE.new(\"Cursor1\", 80).play if self.is_a?(Game_Player)\n return \n end\n end\n \n if PearlKernel.has_data? and not usable_test_passed?(item)\n RPG::SE.new(\"Cursor1\", 80).play if self.is_a?(Game_Player)\n return\n end\n \n @user_casting = [PearlKernel.tool_castime,item] if PearlKernel.has_data?\n if @user_casting[0] > 0\n @animation_id = 0\n @animation_id = PearlKernel.tool_castanimation\n else\n load_abs_tool(item)\n end\n end", "def item_effect_miss\r\n self.damage = 'Miss'\r\n end", "def item_effect(item)\n # Clear critical flag\n self.critical = false\n # If item scope is for ally with 1 or more HP, and your own HP = 0,\n # or item scope is for ally with 0 HP, and your own HP = 1 or more\n if ((item.scope == 3 or item.scope == 4) and self.hp == 0) or\n ((item.scope == 5 or item.scope == 6) and self.hp >= 1)\n # End Method\n return false\n end\n # Clear effective flag\n effective = false\n # Set effective flag if common ID is effective\n effective |= item.common_event_id > 0\n # Determine hit\n hit_result = (rand(100) < item.hit)\n # Set effective flag is skill is uncertain\n effective |= item.hit < 100\n # If hit occurs\n if hit_result == true\n # Calculate amount of recovery\n recover_hp = maxhp * item.recover_hp_rate / 100 + item.recover_hp\n recover_sp = maxsp * item.recover_sp_rate / 100 + item.recover_sp\n if recover_hp < 0\n recover_hp += self.pdef * item.pdef_f / 20\n recover_hp += self.mdef * item.mdef_f / 20\n recover_hp = [recover_hp, 0].min\n end\n # Element correction\n recover_hp *= elements_correct(item.element_set)\n recover_hp /= 100\n recover_sp *= elements_correct(item.element_set)\n recover_sp /= 100\n # Dispersion\n if item.variance > 0 and recover_hp.abs > 0\n amp = [recover_hp.abs * item.variance / 100, 1].max\n recover_hp += rand(amp+1) + rand(amp+1) - amp\n end\n if item.variance > 0 and recover_sp.abs > 0\n amp = [recover_sp.abs * item.variance / 100, 1].max\n recover_sp += rand(amp+1) + rand(amp+1) - amp\n end\n # If recovery code is negative\n if recover_hp < 0\n # Guard correction\n if self.guarding?\n recover_hp /= 2\n end\n end\n # Set damage value and reverse HP recovery amount\n self.damage = -recover_hp\n # HP and SP recovery\n last_hp = self.hp\n last_sp = self.sp\n self.hp += recover_hp\n self.sp += recover_sp\n effective |= self.hp != last_hp\n effective |= self.sp != last_sp\n # State change\n @state_changed = false\n effective |= states_plus(item.plus_state_set)\n effective |= states_minus(item.minus_state_set)\n # If parameter value increase is effective\n if item.parameter_type > 0 and item.parameter_points != 0\n # Branch by parameter\n case item.parameter_type\n when 1 # Max HP\n @maxhp_plus += item.parameter_points\n when 2 # Max SP\n @maxsp_plus += item.parameter_points\n when 3 # Strength\n @str_plus += item.parameter_points\n when 4 # Dexterity\n @dex_plus += item.parameter_points\n when 5 # Agility\n @agi_plus += item.parameter_points\n when 6 # Intelligence\n @int_plus += item.parameter_points\n end\n # Set to effective flag\n effective = true\n end\n # If HP recovery rate and recovery amount are 0\n if item.recover_hp_rate == 0 and item.recover_hp == 0\n # Set damage to empty string\n self.damage = \"\"\n # If SP recovery rate / recovery amount are 0, and parameter increase\n # value is ineffective.\n if item.recover_sp_rate == 0 and item.recover_sp == 0 and\n (item.parameter_type == 0 or item.parameter_points == 0)\n # If state is unchanged\n unless @state_changed\n # Set damage to \"Miss\"\n self.damage = \"Miss\"\n end\n end\n end\n # If miss occurs\n else\n # Set damage to \"Miss\"\n self.damage = \"Miss\"\n end\n # If not in battle\n unless $game_temp.in_battle\n # Set damage to nil\n self.damage = nil\n end\n # End Method\n return effective\n end", "def item_effect_damagefix\r\n self.damage = nil unless $game_temp.in_battle\r\n end", "def item_effect_recovery(item)\r\n recover_hp = maxhp * item.recover_hp_rate / 100 + item.recover_hp\r\n recover_sp = maxsp * item.recover_sp_rate / 100 + item.recover_sp\r\n if recover_hp < 0\r\n recover_hp += self.pdef * item.pdef_f / 20\r\n recover_hp += self.mdef * item.mdef_f / 20\r\n recover_hp = [recover_hp, 0].min\r\n end\r\n return recover_hp, recover_sp\r\n end", "def take_damage amt, name, sym, message\n @hp -= amt\n @last_hit_by = name\n @kill_type = sym\n hear_line message\n # check if you died?\n end", "def does_damage\n puts \"You encounter the dreadful #{@name}!\"\n puts \"The #{@name} takes away #{@damage} health points.\"\n return @damage\n end", "def make_item_action_result\n # Get item\n @item = $data_items[@active_battler.current_action.item_id]\n # If unable to use due to items running out\n unless $game_party.item_can_use?(@item.id)\n # Shift to step 1\n @phase4_step = 1\n return\n end\n # If consumable\n if @item.consumable\n # Decrease used item by 1\n $game_party.lose_item(@item.id, 1)\n end\n # Display item name on help window\n @help_window.set_text(@item.name, 1)\n # Set animation ID\n @animation1_id = @item.animation1_id\n @animation2_id = @item.animation2_id\n # Set common event ID\n @common_event_id = @item.common_event_id\n # Decide on target\n index = @active_battler.current_action.target_index\n target = $game_party.smooth_target_actor(index)\n # Set targeted battlers\n set_target_battlers(@item.scope)\n # Apply item effect\n for target in @target_battlers\n target.item_effect(@item)\n end\n end", "def make_item_action_result\r\n # Get item\r\n @item = $data_items[@active_battler.current_action.item_id]\r\n # If unable to use due to items running out\r\n unless $game_party.item_can_use?(@item.id)\r\n # Shift to step 1\r\n @phase4_step = 1\r\n return\r\n end\r\n # If consumable\r\n if @item.consumable\r\n # Decrease used item by 1\r\n $game_party.lose_item(@item.id, 1)\r\n end\r\n # Display item name on help window\r\n @help_window.set_text(@item.name, 1)\r\n # Set animation ID\r\n @animation1_id = @item.animation1_id\r\n @animation2_id = @item.animation2_id\r\n # Set common event ID\r\n @common_event_id = @item.common_event_id\r\n # Decide on target\r\n index = @active_battler.current_action.target_index\r\n target = $game_party.smooth_target_actor(index)\r\n # Set targeted battlers\r\n set_target_battlers(@item.scope)\r\n # Apply item effect\r\n for target in @target_battlers\r\n target.item_effect(@item)\r\n end\r\n end", "def item_effect_damage(recover_hp, recover_sp, effective)\r\n # Set Damage\r\n self.damage = -recover_hp\r\n # HP and SP recovery\r\n last_hp = self.hp\r\n last_sp = self.sp\r\n self.hp += recover_hp\r\n self.sp += recover_sp\r\n effective |= self.hp != last_hp\r\n effective |= self.sp != last_sp\r\n # Return Effectiveness\r\n return effective\r\n end", "def testSpecificDamage\n #=============================================================\n #TESTS SPECIFICDAMAGE\n # 1. TO_S\n # 2. METODO ADJUST\n #=============================================================\n \n index = 1\n object = \"SPECIFICDAMAGE\"\n section = \"METODO TO_S\"\n \n titleTest(index,object,section)\n puts \"#{@damageSpecific[2].to_s}\"\n \n #=============================================================\n \n index += 1\n section = \"METODO ADJUST\"\n \n titleTest(index,object,section)\n collectionWeapons = [Weapon.newCopy(@weapon[0]),Weapon.newCopy(@weapon[1]),Weapon.newCopy(@weapon[2]), Weapon.newCopy(@weapon[2])]\n collectionShields = [ShieldBooster.newCopy(@shieldBooster[0]),ShieldBooster.newCopy(@shieldBooster[1]),ShieldBooster.newCopy(@shieldBooster[1]),\n ShieldBooster.newCopy(@shieldBooster[2])]\n \n puts \"AJUSTANDO AL DAMAGE ANTERIOR...\"\n puts \"\\n--> COLECCION DE WEAPONS: #{collectionWeapons.to_s if collectionWeapons.empty?}\"\n collectionWeapons.each{ |weapons|\n puts \"#{weapons.to_s}\"\n }\n puts \"--> COLECCION DE SHIELDS: #{collectionShields.to_s if collectionShields.empty?}\"\n collectionShields.each{ |shields|\n puts \"#{shields.to_s}\"\n }\n \n damageAdjust = @damageSpecific[2].adjust(collectionWeapons,collectionShields)\n \n puts \"\\n--> OBJETO DAMAGE AJUSTADO: \\n#{damageAdjust.to_s}\"\n puts \"\\n--> TIENE EFECTO?: #{!damageAdjust.hasNoEffect}\"\n \n end", "def make_item_action_result\n \n # sorry i didnt work on this...\n # couse i dont have a sprite that uses items....\n # so i just added the standby sprite here...\n # when i get more time for this i'll try what i can do for this one... ^-^\n # its the same as the ones above...\n if @active_battler.is_a?(Game_Actor)\n @spriteset.actor_sprites[@active_battler.index].pose(1)\n else\n @spriteset.enemy_sprites[@active_battler.index].enemy_pose(1)\n end\n \n @item = $data_items[@active_battler.current_action.item_id]\n unless $game_party.item_can_use?(@item.id)\n @phase4_step = 1\n return\n end\n if @item.consumable\n $game_party.lose_item(@item.id, 1)\n end\n @help_window.set_text(@item.name, 1)\n @animation1_id = @item.animation1_id\n @animation2_id = @item.animation2_id\n @common_event_id = @item.common_event_id\n index = @active_battler.current_action.target_index\n target = $game_party.smooth_target_actor(index)\n set_target_battlers(@item.scope)\n for target in @target_battlers\n target.item_effect(@item)\n end\n end", "def attack_effect_damage\r\n self.hp -= self.damage\r\n end", "def slip_damage_effect\r\n # Set damage\r\n slip_damage_effect_base_damage\r\n # Dispersion\r\n slip_damage_effect_dispersion\r\n # Subtract damage from HP\r\n slip_damage_effect_damage\r\n # End Method\r\n return true\r\n end", "def setup_damage\n return if item_in_use.nil?\n item = copy(item_in_use) \n # Copy item. In case if you want to modify anything\n \n # ----- Evaluate skill ------- #\n if @acts[1].is_a?(String) # Change formula? No prob ~\n item.damage.formula = @acts[1]\n elsif @acts[1].is_a?(Integer) # Skill link? No prob ~\n item = $data_skills[@acts[1]]\n elsif @acts[1].is_a?(Float) # Rescale damage? No prob ~\n item.damage.formula = \"(#{item.damage.formula}) * #{@acts[1]}\"\n end\n \n # ------- Check target scope ------- #\n if area_flag && target_array\n # Damage to all targets ~\n target_array.uniq.each do |target|\n get_scene.tsbs_invoke_item(target, item, self)\n # Check animation guard\n if !item.ignore_anim_guard? && item.parallel_anim?\n target.anim_guard = target.anim_guard_id\n target.anim_guard_mirror = target.flip\n end\n end\n elsif target\n # Damage to single target\n get_scene.tsbs_invoke_item(target, item, self)\n # Check animation guard\n if !item.ignore_anim_guard? && item.parallel_anim?\n target.anim_guard = target.anim_guard_id\n target.anim_guard_mirror = target.flip\n end\n end\n end", "def attack_effect_miss\r\n self.damage = 'Miss'\r\n self.critical = false\r\n end", "def skill_effect_damage\r\n # Substract damage from HP\r\n last_hp = self.hp\r\n self.hp -= self.damage\r\n return self.hp != last_hp\r\n end", "def effects_message(entity, recover)\n \"#{entity.name} uses #{name} and recovers #{recover}\"\\\n \" HP!\\n\\nHP: #{entity.hp}/#{entity.max_hp}\\n\\n\"\n end", "def weaponDamage \n damage = self.weapon.damage\n if( self.weapon.type == :versatile && @shield.value == 0 )\n damage += 2\n end\n damage\n end", "def item_apply(user, item)\n super\n if item.damage.element_id < 0\n user.atk_elements.each do |e|\n $game_party.add_bestiary_data(@enemy_id, :ele, e)\n end\n else\n $game_party.add_bestiary_data(@enemy_id, :ele, item.damage.element_id)\n end\n end", "def setup_damage\n return unless PONY::ERRNO::check_sequence(current_act)\n target = current_action_targets\n item = @acts[1].is_a?(Numeric) ? $data_skills[@acts[1]] : @acts[1]\n temp_action = Game_Action.new(self, target, item)\n temp_aciton.reassign_item(temp_action.get_symbol_item)\n return if item.nil? || item.is_a?(Symbol)\n BattleManager.invoke_action(temp_action)\n end", "def attacks(victim)\n #AFFICHE LE JOUEUR ATTAQUANT SA VICTIME\n puts \"le joueur #{self.names} attaque le joueur #{victim.names}\"\n\n #DAMAGE_COMPUTED PREND LA VALEUR DU NOMBRE OBTENU ALEATOIREMENT\n damage_computed = compute_damage\n\n #AFFICHE LE NOMBRE DE DOMMAGES INFLIGES\n puts \"il lui inflige #{damage_computed} points de dommages\"\n\n #VICTIM RECOIS LES DOMMAGES\n victim.gets_damage(damage_computed)\n end", "def make_result_info\n gold = 0\n treasures = $game_troop.make_drop_items\n for en_dead in tactics_dead\n if en_dead.actor? or en_dead.hidden?\n # Add amount of gold obtained\n gold += en_dead.gold\n end\n end\n show_gold_gain(gold)\n show_item_gain(treasures)\n end", "def skill_effect_damagefix\r\n self.damage = nil unless $game_temp.in_battle\r\n end", "def damaged\n @hp = @hp - 1\n end", "def double_check\n if any_damage?\n @used = true\n @missed = false\n @evaded = false\n end\n end", "def testNumericDamage\n #=============================================================\n #TESTS SPACECITY\n # 1. TO_S\n # 2. METODO ADJUST\n #=============================================================\n \n index = 1\n object = \"NUMERICDAMAGE\"\n section = \"METODO TO_S\"\n \n titleTest(index,object,section)\n puts \"#{@damageNumeric[2].to_s}\"\n \n #=============================================================\n \n index += 1\n section = \"METODO ADJUST\"\n \n titleTest(index,object,section)\n \n collectionWeapons = [Weapon.newCopy(@weapon[0]),Weapon.newCopy(@weapon[1]),Weapon.newCopy(@weapon[2]), Weapon.newCopy(@weapon[2])]\n collectionShields = [ShieldBooster.newCopy(@shieldBooster[0]),ShieldBooster.newCopy(@shieldBooster[1]),ShieldBooster.newCopy(@shieldBooster[1]),\n ShieldBooster.newCopy(@shieldBooster[2])]\n \n puts \"AJUSTANDO AL DAMAGE ANTERIOR...\"\n puts \"\\n--> COLECCION DE WEAPONS: #{collectionWeapons.to_s if collectionWeapons.empty?}\"\n collectionWeapons.each{ |weapons|\n puts \"#{weapons.to_s}\"\n }\n puts \"--> COLECCION DE SHIELDS: #{collectionShields.to_s if collectionShields.empty?}\"\n collectionShields.each{ |shields|\n puts \"#{shields.to_s}\"\n }\n \n damageAdjust = @damageNumeric[2].adjust(collectionWeapons,collectionShields)\n \n puts \"\\n--> OBJETO DAMAGE AJUSTADO: \\n#{damageAdjust.to_s}\"\n puts \"\\n--> TIENE EFECTO?: #{!damageAdjust.hasNoEffect}\"\n \n end", "def skill_effect_miss\r\n self.damage = 'Miss'\r\n end", "def check_equip_effects(equip)\n end", "def taking_damage_action\n if @warrior.feel(:backward).empty? && @health < 10\n @warrior.walk!(:backward)\n elsif @warrior.feel.empty?\n @warrior.walk!\n elsif @warrior.feel.enemy?\n @warrior.attack!\n end\n end", "def deal_damage(damage, type, source = nil, armour_pierce = 0)\n\t\t\tdamage_taken = deal_damage? damage, type, source, armour_pierce\n\t\t\tEntity::Status.tick @entity, StatusTick::DAMAGE_TAKEN, damage, type, source\n\t\t\[email protected] = @entity.hp - damage_taken\n\t\t\treturn damage_taken\n\t\tend", "def make_basic_action_result\n # Gather the current Ammo Cost\n gather_ammo_cost = Ammo::Range_weapons_id[@active_battler.weapon_id]\n # Gather the Current Ammo\n gather_ammo = Ammo::Range_ammo_id[@active_battler.weapon_id]\n # Check if the Active Battler is attacking and if they are using a ranged weapon\n if @active_battler.current_action.basic == 0 and Ammo::Range_weapons_id.has_key?(@active_battler.weapon_id)\n # Check the Ammo Count\n if $game_party.item_number(gather_ammo) >= gather_ammo_cost\n # Sufficient Ammo, remove item\n $game_party.lose_item(gather_ammo,gather_ammo_cost)\n syn_scene_battle_range\n else\n # Insufficient Ammo\n @help_window.set_text(\"#{@active_battler.name} cannot attack due to insufficient Ammo\", 1)\n end\n # Call Default Code\n else\n syn_scene_battle_range\n end\n end", "def confirm_attack\n @active_battler.current_action.set_attack\n process_action\n @windows[Win_Status].clear_dmg_preview\n if (@active_battler != nil)\n @active_battler.perf_action = true\n end\n @windows[Menu_Actor].setup(@active_battler)\n actor_menu_open\n clear_tr_sprites\n end", "def takeDamage (dmg)\n\t\t@currentHealth -= dmg\n\tend", "def slip_damage_effect_damage\r\n self.hp -= self.damage\r\n end", "def take_damage(damage)\n self.health -= damage\n # or @health -= damage\n shout(\"Ouch! #{name} took #{damage} and has #{self.health} left\")\n die if self.health <= 0\n end", "def gets_damage(damage) \n @life_points -= damage\n\n if @life_points <= 0 \n puts \"Déso #{@name} t'es mort !\"\n end\n end", "def damage_result_helper(attacker, defender, damage)\n if defender.health.HP <= 0\n Battle.award_exp_from_kill(attacker, defender)\n self.report_kill(Battle.get_name(attacker), Battle.get_name(defender), damage)\n if defender.class == BattlePc && defender.pc.kingdom_id\n self.regicide = defender.pc.kingdom_id if defender.pc.kingdom.player_character_id == defender.pc.id\n end\n self.fighter_killed(defender) unless defender.class == PlayerCharacter\n else\n self.report_hit(Battle.get_name(attacker), Battle.get_name(defender), damage)\n end\n end", "def hp_decriment(opponent)\n\t\thp_will_change!\n\t\tputs \"damage taken!\"\n\t\t# self.hp -= 1 \n\t\tself.hp -= (1 + opponent.attack/self.defense)\n\t\tif self.hp <=0 \n\t\t\tputs \"Fatality!\"\n\t\t\tself.lives_decriment()\n\t\tend\n\t\tself.save!\n\tend", "def invest_in_the_system\r\n @profit_from_crash += msg.value\r\n end", "def invest_in_the_system\r\n @profit_from_crash += msg.value\r\n end", "def broken(tool_condition) #allow the tool class to be use through the parameter\n if @item_health == 0 && tool_condition.tool_health == 0 #when both health reach 0 at the same time\n puts \"Both #{@item_name} and #{tool_condition.tool_name} break at the same time!\"\n elsif @item_health <= 0 #when the item's health is 0 or below 0 before the tool's health\n puts \"The #{@item_name} breaks first!\"\n elsif tool_condition.tool_health <= 0 #when the tool's health reaches 0 or below 0 before the item's health\n puts \"Your #{tool_condition.tool_name} breaks first!\"\n else\n puts \"Nothing breaks. \\nYour #{tool_condition.tool_name}'s health is now #{tool_condition.tool_health}. \\nThe #{@item_name}'s health is now #{@item_health}.\"\n end\n end", "def get_damage_string\n \"1d3\"\n end", "def load_abs_tool(item)\n return if @knockdown_data[0] > 0\n PearlKernel.load_item(item)\n \n return if self.is_a?(Game_Follower) and @targeted_character.nil?\n \n if !@targeting[0] and self.battler.is_a?(Game_Actor)\n if item.is_a?(RPG::Skill) || item.is_a?(RPG::Item)\n # apply target to skills items \n if PearlKernel.tool_target == \"true\" || item.scope == 7 ||\n item.scope == 9\n load_target_selection(item)\n return\n end\n else\n # apply target parsing the invoked skill to weapons and armors\n invoke = PearlKernel.tool_invoke\n if invoke != nil && invoke > 0 && invoke != 1 && invoke != 2\n invokeskill = $data_skills[invoke]\n if PearlKernel.tool_target == \"true\" || invokeskill.scope == 7 ||\n invokeskill.scope == 9\n load_target_selection(item)\n return\n end\n # apply target to normal weapon and armor without invoking\n else\n if PearlKernel.tool_target == \"true\"\n load_target_selection(item)\n return\n end\n end\n end\n end\n if item.is_a?(RPG::Skill) || item.is_a?(RPG::Item)\n battler.use_item(item) \n else\n if PearlKernel.tool_invoke != 0\n battler.use_item($data_skills[PearlKernel.tool_invoke])\n end\n end\n \n # if the tool has data continue\n if PearlKernel.has_data?\n consume_ammo_item(item) if battler.is_a?(Game_Actor) and\n PearlKernel.tool_itemcost != 0\n @anime_speed = PearlKernel.user_animespeed\n battler.apply_cooldown(item, PearlKernel.tool_cooldown)\n end\n create_projectile_object(item)\n create_anime_sprite_object(item)\n end", "def dmg( d_type, dmg, ap, srpe_att, char_att )\n d = dmg\n\n # surprise attacks do more damage\n if srpe_att\n d = d * 1.5\n end\n\n # when you see it coming, there is a chance that you get to evade part of the damage\n if !srpe_att && (rand(100) + 1 < @c_evade)\n d = d / 1.25; # consider redesigning this feature, the original value was way to strong, temp reducing the divider\n end\n\n # modify damage based on your resistances to the different types\n case d_type\n when :standard\n d -= @c_class == 'Knight' ? 10 : 0 # Warriors get a special resistance to standard damage\n when :magic\n d -= @c_class == 'Wizard' ? 10 : 1 # Magi get a special resistance to magic damage\n when :earth\n d -= 1\n when :fire\n d -= 1\n when :water\n d -= 1\n when :wind\n d -= 1\n when :shadow\n d -= @c_class == 'Shinobi' ? 10 : 1 # Rogue get a special resistance to shadow damage\n when :ice\n d -= 1\n when :lightning\n d -= 1\n when :dark\n d -= 1\n when :light\n d -= 1\n when :psionic\n d -= 1\n else\n d -= 0\n end\n\n # modify damage based on armor worn\n if @armor == 'Leather'\n unless srpe_att # characters don't get to use armor values when surprise attacked\n d -= (2 - ap)\n end\n elsif @armor == 'Chain mail'\n unless srpe_att # characters don't get to use armor values when surprise attacked\n d -= (6 - ap)\n end\n elsif @armor == 'Full Plate'\n unless srpe_att # characters don't get to use armor values when surprise attacked\n d -= (12 - ap)\n end\n end\n\n # make sure we don't give them hp when they block it\n if d < 0\n d = 0;\n end\n\n # apply the damage\n @c_hp = @c_hp - d\n\n # display results\n if d == 0\n puts 'You suffered no damage from the attack, way to go!'\n elsif @c_hp <= 0\n @c_lvl -= 1\n puts \"You #{ @c_name } have perished. You respawn back at town square but have suffered loss in level. You are now level #{ @c_lvl }\"\n else\n puts \"You have suffered #{ d } wounds and now have #{ @c_hp } health left\"\n end\n\n # NOTE: this is becoming to painful, removing until we figure out\n # how to handle all the different combos for the counter attack\n # if @c_hp > 0 && !srpe_att && (rand(100) + 1 < @c_counter)\n # if @c_class == 'Knight' && @weapon == 'Short Sword'\n # char_att.dmg(:physical, rand(10) + 2, 0, false)\n # end\n # if @c_class == 'Knight' && @weapon == 'Longsword'\n # char_att.dmg(:physical, rand(20) + 2, 0, false)\n # end\n # if @c_class == 'Knight' && @weapon == 'Battle Axe'\n # char_att.dmg(:physical, rand(11) + 10, 0, false)\n # end\n # if @c_class == 'Wizard' && @weapon == 'Fireball'\n # char_att.dmg(:fire, rand(10) + 6, 0, false)\n # end\n # if @c_class == 'Wizard' && @weapon == 'Ice Spikes'\n # char_att.dmg(:ice, rand(10) + 6, 0, false)\n # end\n # if @c_class == 'Wizard' && @weapon == 'Crushing Grasp'\n # char_att.dmg(:magic, rand(10) + 6, 0, false)\n # end\n # if @c_class == 'Shinobi' && @weapon == 'Tanto'\n # char_att.dmg(:magic, rand(6) + 6, 6, false)\n # end\n # if @c_class == 'Shinobi' && @weapon == 'Ninjato'\n # char_att.dmg(:magic, rand(12) + 6, 3, false)\n # end\n # end\n end", "def action\n if taking_damage?\n taking_damage_action\n elsif @warrior.feel.stairs? #&& ground_covered?\n @warrior.walk!\n elsif @warrior.feel.empty? && @warrior.health < MAX_HEALTH\n @warrior.rest!\n elsif @warrior.feel.enemy?\n @warrior.attack!\n elsif @warrior.feel.captive?\n @warrior.rescue!\n elsif @warrior.feel.empty?\n @warrior.walk!\n elsif @warrior.feel.wall?\n @warrior.pivot!(:backward)\n end\n end", "def gets_damage(damages)\n @life_points -= damages\n if life_points > 0\n puts \"#{name} a perdu #{damages}, il lui reste #{life_points} points de vie\"\n else\n puts \"#{name} a perdu #{damages}, #{name} a été tué\"\n end\n end", "def do_action\n if self.affects == \"world\" then\n player_tile = self.character.tile\n\n # an aoe effect is represented as a list of objects,\n # each one representing the effect on one tile\n ITEM_PROPERTIES[self.item_type][\"aoe\"].each do |aoe|\n dx = aoe[\"xCoordPlus\"]\n dy = aoe[\"yCoordPlus\"]\n tile_becomes = aoe[\"tileBecomes\"]\n Tile.tile_at(player_tile.x + dx, player_tile.y + dy).become tile_becomes\n end\n\n elsif self.affects == \"player\" then\n\n dx = self.moves_player_x\n dy = self.moves_player_y\n\n # Move me to the place this item takes me\n if (dx != 0 or dy != 0) then\n target_tile = Tile.tile_at(self.character.tile.x + dx,\n self.character.tile.y + dy)\n if target_tile\n self.character.tile = target_tile\n end\n end\n\n self.character.heal(self.health_effect)\n self.character.charge(self.battery_effect)\n end\n\n if self.consumable then\n self.character.item = nil\n self.destroy\n end\n\n end", "def ty_execute_action_attack\n # Check to see if the current attacker is the actor and is using a weapon that needs ammo\n if @active_battler.is_a?(Game_Actor) && TysAmmoRequirements::Weapons_ammo_cost[@active_battler.weapon_id]\n # Both checks clear, so perform Ammo adjustments\n # First we collect some end-user options, like ammo cost and ammo ID.\n gather_ammo_cost = TysAmmoRequirements::Weapons_ammo_cost[@active_battler.weapon_id]\n # This handles multiple ammunition for the same weapon. First we check if the setting is an array\n if TysAmmoRequirements::Weapons_ammo_id[@active_battler.weapon_id].is_a?(Array)\n # Check passed, so now we store the array items\n array_items = TysAmmoRequirements::Weapons_ammo_id[@active_battler.weapon_id]\n # Now we check each ID in array_items and compare to see if we have enough ammo\n for index in array_items\n # Check to see if the actor has enough ammo\n if $game_party.item_number($data_items[index]) >= gather_ammo_cost\n # Check cleared, gather item ID and terminate check loop\n gather_ammo_item = $data_items[index]\n break\n end\n end\n else\n gather_ammo_item = $data_items[TysAmmoRequirements::Weapons_ammo_id[@active_battler.weapon_id]]\n end\n # Next we check to make sure the attacking actor has enough ammo\n if $game_party.item_number(gather_ammo_item) >= gather_ammo_cost\n # The check cleared, so perform ammo adjustments\n # Consume Ammunition\n $game_party.lose_item(gather_ammo_item, gather_ammo_cost)\n # Display text\n text = sprintf(Vocab::ConsumeAmmo, @active_battler.name, gather_ammo_cost, gather_ammo_item.name)\n @message_window.add_instant_text(text)\n else\n # Failed check, go into defense mode\n if TysAmmoRequirements::Unequip_weapon_NoAmmo\n @active_battler.change_equip_by_id(0,0)\n else\n text = sprintf(Vocab::NoAmmo, @active_battler.name, gather_ammo_item.name)\n @message_window.add_instant_text(text)\n @active_battler.action.kind = 1\n execute_action_guard\n end\n end\n # Perform a check to see if Active_Battler is a enemy and has ammo\n elsif @active_battler.is_a?(Game_Enemy) && $data_enemies[@active_battler.enemy_id].note.include?(TysAmmoRequirements::Enemy_ammo_activate_string)\n # Now we have to isolate the interger in the 'Note' string of the enemies\n # and then store the interger in a new local value for future use.\n enemy_ammo_cost = $data_enemies[@active_battler.enemy_id].note.downcase.match('ammocost:(\\d*)')[1].to_i\n enemy_use_physical = true if $data_enemies[@active_battler.enemy_id].note.include?('usephysical')\n enemy_use_physical = false if $data_enemies[@active_battler.enemy_id].note.include?('usephysical') == false\n enemy_ammo_name = TysAmmoRequirements::Enemy_ammo_name[@active_battler.enemy_id]\n # Check to see if the enemy has enough ammo to attack\n if @enemy_ammo[@enemy_attack] >= enemy_ammo_cost\n # Check cleared, remove enemy ammo.\n text = sprintf(Vocab::EnemyUsedAmmo, @active_battler.name, enemy_ammo_name)\n @message_window.add_instant_text(text)\n @enemy_ammo[@enemy_attack] -= enemy_ammo_cost\n else\n # Check failed, put enemy in guard mode \n if enemy_use_physical == false\n text = sprintf(Vocab::EnemyNoAmmo, @active_battler.name, enemy_ammo_name)\n @message_window.add_instant_text(text)\n @active_battler.action.kind = 1\n execute_action_guard\n end\n end\n end\n end", "def item_effect(item)\r\n # Item Effect Setup\r\n item_effect_setup\r\n # Return False If Out of Scope\r\n return false if item_effect_scope(item)\r\n # Setup Effective\r\n effective = item_effect_effective_setup(item)\r\n # First hit detection\r\n hit_result = item_effect_hit_result(item)\r\n # Set effective flag if skill is uncertain\r\n effective = item_effect_effective_correction(effective, item)\r\n # If hit occurs\r\n if hit_result\r\n # Calculate amount of recovery\r\n recover_hp, recover_sp = item_effect_recovery(item)\r\n # Element correction\r\n recover_hp, recover_sp = item_effect_element_correction(recover_hp, \r\n recover_sp, item)\r\n # If recovery code is negative\r\n if recover_hp < 0\r\n # Guard correction\r\n recover_hp = item_effect_guard_correction(recover_hp)\r\n end\r\n # Dispersion\r\n recover_hp, recover_sp = item_effect_dispersion(recover_hp, \r\n recover_sp, item)\r\n # Damage & Recovery\r\n effective = item_effect_damage(recover_hp, recover_sp, effective)\r\n # State change\r\n @state_changed = false\r\n effective |= states_plus(item.plus_state_set)\r\n effective |= states_minus(item.minus_state_set)\r\n # If parameter value increase is effective\r\n if item.parameter_type > 0 and item.parameter_points != 0\r\n # Item Effect Parameter Points\r\n item_effect_parameter_points(item)\r\n # Set to effective flag\r\n effective = true\r\n end\r\n # Item effect no recovery\r\n item_effect_no_recovery(item)\r\n # If miss occurs\r\n else\r\n # Item effect miss\r\n item_effect_miss\r\n end\r\n # Item effect damage fix\r\n item_effect_damagefix\r\n # End Method\r\n return effective\r\n end", "def attack_effect(attacker)\n # Clear critical flag\n self.critical = false\n # First hit detection\n hit_result = (rand(100) < attacker.hit)\n # If hit occurs\n if hit_result == true\n # Calculate basic damage\n atk = [attacker.atk - self.pdef / 2, 0].max\n self.damage = atk * (20 + attacker.str) / 20\n # Element correction\n self.damage *= elements_correct(attacker.element_set)\n self.damage /= 100\n # If damage value is strictly positive\n if self.damage > 0\n # Critical correction\n if rand(100) < 4 * attacker.dex / self.agi\n self.damage *= 2\n self.critical = true\n end\n # Guard correction\n if self.guarding?\n self.damage /= 2\n end\n end\n # Dispersion\n if self.damage.abs > 0\n amp = [self.damage.abs * 15 / 100, 1].max\n self.damage += rand(amp+1) + rand(amp+1) - amp\n end\n # Second hit detection\n eva = 8 * self.agi / attacker.dex + self.eva\n hit = self.damage < 0 ? 100 : 100 - eva\n hit = self.cant_evade? ? 100 : hit\n hit_result = (rand(100) < hit)\n end\n # If hit occurs\n if hit_result == true\n # State Removed by Shock\n remove_states_shock\n # Substract damage from HP\n self.hp -= self.damage\n # State change\n @state_changed = false\n states_plus(attacker.plus_state_set)\n states_minus(attacker.minus_state_set)\n # When missing\n else\n # Set damage to \"Miss\"\n self.damage = \"Miss\"\n # Clear critical flag\n self.critical = false\n end\n # End Method\n return true\n end", "def takeDamage (damage)\n\t\t@health = @health - damage\n\tend", "def item_effect_guard_correction(recover_hp)\r\n return self.guarding? ? recover_hp /= 2 : recover_hp\r\n end", "def deal_damage!(damage)\n\t\t\[email protected] = @entity.hp - damage\n\t\t\treturn damage\n\t\tend", "def get_other_loss_confirmation()\n return \"#{@player.get_other_name()} loses with #{@player.get_other_weapon()}!\"\n end", "def make_skill_action_result\n # Gather the current Ammo Cost\n gather_ammo_cost = Ammo::Skill_ammo[@active_battler.current_action.skill_id]\n # Gather Ammo\n gather_ammo = Ammo::Range_ammo_id[@active_battler.weapon_id]\n # Check if the Actor is using a defiend skill\n if Ammo::Skill_ammo.has_key?(@active_battler.current_action.skill_id)\n # Check if Ammo is present\n if $game_party.item_number(gather_ammo) >= gather_ammo_cost\n # Sufficient Ammo, remove item\n $game_party.lose_item(gather_ammo,gather_ammo_cost)\n # Call Default Code\n syn_scene_battle_skill\n else\n # Set Window; Do Nothing\n @help_window.set_text(\"#{@active_battler.name} cannot attack due to insufficient Ammo\", 1)\n end\n # Otherwise SKip the check and call default code\n else\n syn_scene_battle_skill\n end\n end", "def execute_damage(user)\n fulfill_conditional if hp - @result.hp_damage <= 0\n mrts_conditional_drops_execute_damage(user) \n end", "def drop_item1\n return enemy.drop_item1\n end", "def compute_damage\n super * @weapon_level\n end", "def after_redeem() end", "def gets_damage(damage)\n @life_points = @life_points - damage\n\n # If the user has 0 life point it show a message that he loose\n if @life_points <= 0\n puts \"\\n\"\n puts \"----- La partie est finie #{self.name} a perdu ! -----\"\n end\n end", "def hook_report_actions\n @flavor.class.after_add_resources do\n actions = actions_taken\n @recipe.send(:ruby_block, 'report_actions_taken') do\n # :nocov:\n block do\n $stdout.puts \"\\n\\nactions taken:\"\n actions.each { |a| $stdout.puts \" #{a}\" }\n end\n # :nocov:\n end\n end\n end", "def use_item(item_name)\n item = self.items.find_by(name: item_name)\n if item.item_type == \"Healing Potion\"\n if self.hp += 10 < self.base_hp\n puts \"You drank the entire bottle. You feel energized! (+10 HP)\"\n puts \"You HP is now #{self.hp}\"\n #removes Item from inventory \n Item.destroy(item)\n else\n #if HP goes ove the base_health, it automatically caps at base_hp aka your max hp\n self.hp = self.base_hp\n puts \"You drank the entire bottle. You are at full health!\"\n puts \"Your HP is now #{self.base_hp}\"\n Item.destroy(item)\n end \n elsif item.item_type == \"Weapon\"\n #weapons will boost the characters attack points by a random number?\n if self.current_weapon == nil \n random_attack_boost = [2,3,5].sample\n self.attack_power += random_attk_boost\n puts \"You've equipped #{item.name}. (+#{random_attk_boost})\"\n else \n equipped_weapon = self.items.find_by(current_weapon)\n Item.destroy(equppied_weapon)\n self.attack_power = self.base_attk\n random_attack_boost = [5,6,10].sample\n self.attack_power += random_attack_boost\n puts \"You have replaced your weapon with #{item.name}. (+#{random_attk_boost})\"\n end \n else \n puts \"You can't use/equip this!\"\n end \n end", "def gets_damage(damage)\n @life_points = @life_points - damage\n if @life_points > 0 \n then puts \"#{@name} est encore dans le game, il a encore #{@life_points} points de vie !\"\n else puts \"sorry but #{@name} tu es muerto, tu as #{@life_points} points de vie!\"\n end\n\n end", "def health_damage damage, check\n if check\n @health -= damage\n end\n end", "def attack_effect_base_damage(attacker)\r\n atk = [attacker.atk - self.pdef / 2, 0].max\r\n self.damage = atk * (20 + attacker.str) / 20\r\n end", "def drop_item2\n return enemy.drop_item2\n end", "def damage(ap)\n @health_points -= ap\n end", "def damage\n @damage ||= [(@power * (rand + 0.5)).to_i - @defender.toughness, 0].max\n end", "def show_item_gold?(targets) #don't show item/gold gained during battle\n end", "def game_water_action\n if tool_canuse?(WweaponId) and not @showing_water\n if actor.mp >= FlameMpCost\n @gamewater.direction = @direction\n @gamewater.moveto(@x, @y)\n @gamewater.char_steps = 2\n @gamewater.action_time = WaterDuration\n @showing_water = true\n RPG::SE.new(WaterSoundSe,80).play\n #actor.mp -= FlameMpCost\n @tool_anime = WaterDuration\n else\n Sound.play_buzzer\n end\n end\n end", "def mod_damage_taken(team, v, set = false)\n gen_mod_data(team, v, :damage_taken, set)\n end", "def get_loss_confirmation()\n return \"#{@player.get_name()} loses with #{@player.get_weapon()}!\"\n end", "def take_damage(damage)\n damage_taken = 0\n dodge_roll = rand((self.agility + ((self.dodgeFlag && 1 || 0) * DODGE_ACTIVATE_VALUE)) .. DODGE_RANGE_UPPER)\n if !dodge_roll.between?(DODGE_RANGE_LOWER, DODGE_RANGE_UPPER)\n damage_taken = damage - (damage * (self.defense / 100.0)).to_i\n self.health -= damage_taken\n self.dodgeFlag = false;\n self.save\n end\n damage_taken\n end", "def attacks(other_player) \n puts \"Le joueur #{@name} attaque le joueur #{other_player.name}.\"\n other_player_damage = compute_damage\n\n puts \"Il lui inflige #{other_player_damage} points de dommages.\"\n other_player.gets_damage(other_player_damage)\n end", "def attacks(player)\n puts \"#{@name} attaque #{player.name}\"\n damage = compute_damage\n puts \" il lui inflige #{damage} points dommages\"\n player.gets_damage(damage)\n end", "def report\r\n\t\tputs \"You have picked up the #{@name} of #{@type}!\"\r\n\t\tputs \" \"\r\n\t\tsleep 1\r\n\t\tputs \"Item Number #@@item_number\"\r\n\t\tputs \"Level : #@level\"\r\n\t\tputs \"Strength = #@strength\"\r\n\t\tputs \"Agility = #@agility\"\r\n\t\tputs \"Health = #@health\"\r\n\t\tputs \"Mana = #@mana\"\r\n\t\tputs\" \"\r\n\t\treturn\r\n\tend", "def attacks(player)\r\n puts \"#{@name} attaque le joueur #{player.name}\"\r\n player.gets_damage(compute_damage)\r\n end", "def gets_damage(damage)\n\n # On soustrait aux points de vie\n @life_points = @life_points - damage\n \n\n # le joueur est mort s'il n'a plus de vie\n if @life_points <= 0\n puts \"#{@name} is down and dead.I'm soooo very sorry!\"\n puts\"*********************************************************************************************\"\n puts\"*********************************GAME***OVER*********************************************************\"\n puts\"*********************************************************************************************\"\n \n #sinon on l'informe qu'il ne va pas mal!\n else \n puts \"#{@name} still has #{@life_points} points left\"\n puts \"#{@name} is still all right\"\n end\n end", "def skill_effect_guard_correction\r\n self.damage /= 2 if self.guarding?\r\n end", "def take_damage(damage)\n History.create!(object: self, action: :take_damage, params: { integrity: integrity, damage: damage })\n if integrity > damage\n decrement!(:integrity, damage)\n else\n History.create!(object: self, action: :system_destroy, notify: true)\n update!(killed: true)\n end\n end", "def gain_drop_items\n drops = []\n rate = Grade.rate(:drop)\n $game_troop.make_drop_items(rate).each do |item|\n $game_party.gain_item(item, 1)\n drops.push(item)\n end\n SceneManager.scene.drop_items(drops)\n end", "def reason; end", "def reason; end", "def dealer_action\n # Dealer stands on soft 17's.\n while @dealer.hand.count < 17\n @dealer.take(@shoe.hit)\n end\n\n # The first card is drawn silently. This fixes the count.\n @shoe.adjust_count(@dealer.hand.cards[0])\n end", "def item_effect_setup\r\n self.critical = false\r\n end", "def gets_damage(damage)\n \t@life_points = @life_points - damage\n \t#puts \"#{name} subit #{damage} points de dommage\"\n \tif life_points <= 0 \n \t\tputs \"Le joueur #{@name} a été tué !\"\n \tend\n end", "def attacks(player)\n \tputs \"Le joueur #{@name} attaque le joueur #{player.name}\"\n \tdamage = compute_damage\n \tputs \"Il lui inflige #{damage} points de dommage\"\n \tplayer.gets_damage(damage)\n end", "def melee_weapon; end", "def virus_effects\n print \"#{@state} will lose #{predicted_deaths} people in this outbreak \n and the outbreak will spread across the state in #{speed_of_spread} months. \\n\\n\"\n end", "def mod_damage_dealt(team, v, set = false)\n gen_mod_data(team, v, :damage_dealt, set)\n end", "def attack_effect_guard_correction\r\n self.damage /= 2 if self.guarding?\r\n end", "def hit damage\n out = ''\n p_up = rand charisma\n if p_up % 9 == 7\n @life += p_up / 4\n out << \"[#{self.name} magick powers up #{p_up}!]\\n\"\n end\n @life -= damage\n out << \"[#{self.name} has died.]\\n\" if @life <= 0\n out\n end", "def item_effect_dispersion(recover_hp, recover_sp, item)\r\n if item.variance > 0 and recover_hp.abs > 0\r\n amp = [recover_hp.abs * item.variance / 100, 1].max\r\n recover_hp += rand(amp+1) + rand(amp+1) - amp\r\n end\r\n if item.variance > 0 and recover_sp.abs > 0\r\n amp = [recover_sp.abs * item.variance / 100, 1].max\r\n recover_sp += rand(amp+1) + rand(amp+1) - amp\r\n end\r\n return recover_hp, recover_sp\r\n end", "def attack_effect_dispersion\r\n if self.damage.abs > 0\r\n amp = [self.damage.abs * 15 / 100, 1].max\r\n self.damage += rand(amp+1) + rand(amp+1) - amp\r\n end\r\n end", "def determine_damage\n if Random.rand(100) < critical_rate\n [fighter_attack * 2, FightEvent.attack_types['critical']]\n else\n [fighter_attack, FightEvent.attack_types['normal']]\n end\n end", "def shield_bonus\n 0\n end" ]
[ "0.658866", "0.658866", "0.64421237", "0.6419076", "0.63061005", "0.62276524", "0.62129027", "0.6201596", "0.6129299", "0.61285526", "0.6115125", "0.60675794", "0.60284436", "0.59782135", "0.59689283", "0.59382385", "0.5932258", "0.5922257", "0.58690464", "0.5833041", "0.58297104", "0.58257", "0.57851374", "0.5774399", "0.57705635", "0.5767163", "0.57471013", "0.5745403", "0.5736627", "0.5732445", "0.5727201", "0.56795424", "0.5659327", "0.56539595", "0.5642295", "0.56350565", "0.5633875", "0.5627791", "0.5626142", "0.5614106", "0.5609646", "0.5607343", "0.560704", "0.560704", "0.5599338", "0.55991834", "0.55988336", "0.559709", "0.5551134", "0.5551028", "0.55431867", "0.55377084", "0.5528419", "0.55274343", "0.55249804", "0.5522821", "0.55141616", "0.55073553", "0.55044645", "0.55043983", "0.54983515", "0.5498118", "0.549473", "0.54872674", "0.54854196", "0.5460813", "0.5458379", "0.5454834", "0.5443659", "0.544349", "0.5433335", "0.5433272", "0.542091", "0.54208916", "0.54141176", "0.54086345", "0.5386774", "0.5385813", "0.5384202", "0.5378235", "0.5374618", "0.53733647", "0.53704166", "0.53683484", "0.5366504", "0.5361699", "0.5361699", "0.5358936", "0.5357057", "0.5339862", "0.53342843", "0.5332736", "0.5322182", "0.531596", "0.53115904", "0.53100425", "0.5305997", "0.5302821", "0.5301382", "0.53011507" ]
0.6205301
7
when the item is first created, the inputs that the user put is save as instance variables
def initialize(item_name, item_health) @item_name = item_name @item_health = item_health end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def insert_required_params_into_new_item_object\n @new_item.plane_id = plane.id\n @new_item.dep_airport_code = departure_airport.code\n @new_item.arr_airport_code = arrival_airport.code\n @new_item.inflight_duration_in_seconds = calculate_inflight_duration\n end", "def new\n \t@item=Item.new({:ItemName =>'def'})\n end", "def new\n @item = Item.new \n @item.create_date = current_user.new_item_date\n @tags_to_display = \"\"\n end", "def add\n # 1. Ask the user for the meal name and store in var\n name = @meal_view.ask_name\n # 2. Ask the user for the meal price and store in var\n price = @meal_view.ask_price\n # 3. Create a new meal instance with those values\n meal = Meal.new(name: name, price: price)\n # 4. Add to repository using #create\n @meal_repo.create(meal)\n end", "def new\n @item = Item.new\n end", "def new\n @item = Item.new\n end", "def new\n @item = Item.new\n end", "def create\n @item = Item.new(item_params)\n @item.save\n redirect_to @item\n end", "def new\n @first_input = FirstInput.new\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 post_initialize_fields\n end", "def new\n @item = Item.new\n end", "def create\n @item = Item.new(params[:item])\n\n if @item.save\n redirect_to :back\n end\n end", "def create\n @purchase_requisition = PurchaseRequisition.new(params[:purchase_requisition])\n #if check_validation\n if @purchase_requisition.save\n #@purchase_requisition.add_item(params[:item])\n redirect_to(edit_purchase_requisition_path(@purchase_requisition), :notice => 'Purchase Requisition was successfully created.')\n else\n render :action => \"new\" \n end\n #else\n # initial_data\n # flash[:error] = \"Please fill in the item information\"\n # render :action => \"new\"\n #end\n \n end", "def create\n @pick_item = PickItem.new(pick_item_params)\n\n respond_to do |format|\n if @pick_item.save\n format.html { redirect_to @pick_item, notice: '新建成功' }\n format.json { render :show, status: :created, location: @pick_item }\n else\n format.html { render :new }\n format.json { render json: @pick_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\n @item = Item.new(item_params)\n #まだView設定がまだのため仮の登録データ、あとでViewからのデータをitem_paramsで定義します。\n atai = 1\n watasi = \"hoge\"\n\n @item.status = atai\n @item.upper_category = watasi\n @item.middle_category = watasi\n @item.lower_category = watasi\n @item.seller = watasi\n @item.size_type = watasi\n \n \n @item.save\n redirect_to root_path\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 add\n # 1. Ask the user for the customer name and store in var\n name = @customer_view.ask_name\n # 2. Ask the user for the customer price and store in var\n address = @customer_view.ask_address\n # 3. Create a new customer instance with those values\n customer = Customer.new(name: name, address: address)\n # 4. Add to repository using #create\n @customer_repo.create(customer)\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 handle_inputs\n collect_inputs(form_model: :post)\n\n if state.post.has_errors?\n set_state post: state.post\n else\n state.post.create.then do |post|\n if post.has_errors?\n set_state post: post\n else\n $HISTORY.pushState(nil, \"/posts/#{post.id}\")\n end\n end\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 input(inputItem)\n @input = inputItem\n end", "def create\n if params[:item].present?\n # TODO - see impact\n @item = Item.new(params[:item])\n @item.user_id = current_user.id if current_user.present?\n\n # TODO Commented shipping information because of REQUIREMENT CHANGE (https://www.pivotaltracker.com/story/show/62299176)\n \n # @item.bring_it_to_you = params[:item][:bring_it_to_you] if params[:item][:bring_it_to_you].present?\n # @item.come_and_get_it = params[:item][:come_and_get_it] if params[:item][:come_and_get_it].present?\n # @item.lets_meet_up = params[:item][:lets_meet_up] if params[:item][:lets_meet_up].present?\n # @item.come_to_you = params[:item][:come_to_you] if params[:item][:come_to_you].present?\n # @item.come_to_me = params[:item][:come_to_me] if params[:item][:come_to_me].present?\n # @item.done_remotely = params[:item][:done_remotely] if params[:item][:done_remotely].present?\n # @item.ship_it = params[:item][:ship_it] if params[:item][:ship_it].present?\n # @item.lets_meet_service = params[:item][:lets_meet_service] if params[:item][:lets_meet_service]\n\n if @item.user.nil? and params[:user_id] and params[:user_id] != ''\n @item.user_id = params[:user_id]\n end\n if not @item.user_id.present? and session[:guest_user_id].to_i > 0\n @item.user_id = session[:guest_user_id].to_i\n end\n # if params[:multi_trade] and params[:multi_trade] == \"on\"\n # @item.is_single_tradeya = false\n # end\n if params[:item][:tod_id].blank?\n @item.exp_date = Item.get_expiry_date_for_tod\n @item.status = \"LIVE\"\n else\n @item.tod = false\n @item.status = \"ACTIVE\"\n end\n respond_to do |format|\n if ((params[:captcha] and params[:item][:tod_id]) or params[:item][:tod_id].nil?) and not @item.user_id.blank?\n if @item.desc == \"Add more details about your good or service here...\" then @item.desc = \"\" end\n if @item.save\n\n # sbx tracking pixel fire\n if current_user.tracking_infos.where(affiliate:'sbx').present?\n Resque.enqueue(FireTrackingPixelJob, current_user.id, 'post')\n end\n\n chk = false\n # Case 1 - Old Offer - edit\n\n # Case 2 - New Tradeya/Offer but item selected from dropdown\n if params[:item][:selected_item_id].to_i > 0 or params[:item][:have].to_i > 0\n create_new = true\n # Create new record for item photos\n end\n # Case 3 - New Tradeya/Offer\n if params[:item_photos].present?\n photos = JSON.parse(params[:item_photos])\n if photos and photos.count > 0\n photos.each_with_index do |photo,index|\n existing_ph = ItemPhoto.find(photo[\"id\"])\n if create_new and existing_ph.item_id.present?\n ph = ItemPhoto.new\n ph.photo = existing_ph.photo\n ph.width = existing_ph.width; ph.height = existing_ph.height;\n ph.crop_x = existing_ph.crop_x; ph.crop_y = existing_ph.crop_y;\n ph.crop_w = existing_ph.crop_w; ph.crop_h = existing_ph.crop_h;\n else\n ph = existing_ph\n end\n if ph.present?\n ph.item_id = @item.id\n if index == 0\n ph.main_photo = true\n end\n ph.save\n chk = true\n end\n end\n end\n end\n if params[:item_videos].present?\n videos = JSON.parse(params[:item_videos])\n if videos and videos.count > 0\n videos.each do |video|\n existing_vi = ItemVideo.find(video[\"id\"])\n if create_new and existing_vi.item_id.present?\n vi = ItemVideo.new\n vi.video = existing_vi.vi\n else\n vi = existing_vi\n end\n if vi.present?\n vi.item_id = @item.id\n vi.save\n chk = true\n end\n end\n end\n end\n # TODO - read below and make it like below\n\n # if params[:file_type] == \"photo\"\n # if params[:item][:item_photo] and params[:item][:item_photo][:id] and params[:item][:item_photo][:id].to_i > 0\n # ip = ItemPhoto.find(params[:item][:item_photo][:id])\n # ip.item_id = @item.id\n # ip.save\n # chk = true\n # elsif params[:item][:item_photo]\n # if params[:item][:item_photo][:photo]\n # o = ItemPhoto.new(params[:item][:item_photo])\n # o.item_id = @item.id\n # o.save\n # chk = true\n # end\n # end\n # elsif params[:file_type] == \"video\"\n # if params[:item][:item_video] and params[:item][:item_video][:id] and params[:item][:item_video][:id].to_i > 0\n # o = ItemVideo.find(params[:item][:item_video][:id])\n # o.item_id = @item.id\n # o.save\n # chk = true\n # elsif params[:item][:item_video]\n # if params[:item][:item_video][:video]\n # o = ItemVideo.new(params[:item][:item_video])\n # o.item_id = @item.id\n # o.save\n # chk = true\n # end\n # end\n # end\n\n if not chk and params[:item][:selected_item_id].to_i > 0\n itm = Item.find(params[:item][:selected_item_id])\n if itm.item_videos and itm.item_videos.count > 0\n o = ItemVideo.new\n if File.exist?(itm.item_videos[0].video.path)\n o.video = File.open(itm.item_videos[0].video.path)\n else\n o.video_from_url(itm.item_videos[0].video.url)\n end\n o.item_id = @item.id\n o.save\n elsif itm.item_photos and itm.item_photos.count > 0\n o = ItemPhoto.new\n if File.exist?(itm.item_photos[0].photo.path)\n o.photo = File.open(itm.item_photos[0].photo.path)\n else\n o.photo_from_url(itm.item_photos[0].photo.url)\n end\n o.item_id = @item.id\n o.save\n end\n end\n\n # if params[:item_wants] and params[:item_wants].present?\n # os = JSON.parse(params[:item_wants])\n # os.each do |iwa|\n # o = ItemWant.new\n # o.title = iwa[0]\n # o.category_id = iwa[1]\n # o.desc = iwa[2]\n # o.item = @item\n # o.user = current_user\n # o.save\n # end\n # end\n if params[:item][:have].present?\n Have.create(:item_id => params[:item][:have].to_i,:user_id => current_user.id )\n end\n\n flash[:notice] = \"item created\"\n # Send mail when item created\n if (InfoAndSetting.sm_on_trd_live and @item.user.notify_tradeya_begins)\n if (@item.user.items.count == 1)\n ItemMailer.item_added_first(@item.id,@item.user.id).deliver\n elsif (@item.user.items.count < 6)\n ItemMailer.item_added(@item.id,@item.user.id).deliver\n end\n # Activity Feed\n @item.create_activity key: @item.id, owner: @item.user, recipient: @item.user\n end\n\n\n if params[:item][:tod_id] # check if the request is coming from an offer or just item\n trade = Trade.new(:item_id => params[:item][:tod_id].to_i, :offer_id => @item.id, :status => 'ACTIVE')\n trade.save!\n if params[:item][:tod] and params[:item][:tod] == \"1\"\n offer_as_tod = Item.new\n offer_as_tod.title = @item.title\n offer_as_tod.desc = @item.desc\n offer_as_tod.tod = true\n offer_as_tod.exp_date = Item.get_expiry_date_for_tod\n offer_as_tod.category_id = @item.category_id\n offer_as_tod.user_id = @item.user_id\n offer_as_tod.status = 'INCOMPLETE'\n offer_as_tod.is_single_tradeya = @item.is_single_tradeya\n if offer_as_tod.save\n session[:offer_as_tod] = offer_as_tod.id\n chk = false\n if params[:file_type] == \"photo\"\n if params[:item][:item_photo]\n if params[:item][:item_photo] and params[:item][:item_photo][:id] and params[:item][:item_photo][:id].to_i > 0\n ip = ItemPhoto.find(params[:item][:item_photo][:id])\n o = ItemPhoto.new\n if File.exist?(ip.photo.path)\n o.photo = File.open(ip.photo.path)\n else\n o.photo_from_url(ip.photo.url)\n end\n o.item_id = offer_as_tod.id\n o.save\n chk = true\n elsif params[:item][:item_photo]\n if params[:item][:item_photo][:photo]\n o = ItemPhoto.new(params[:item][:item_photo])\n o.item_id = offer_as_tod.id\n o.save\n chk = true\n end\n end\n end\n elsif params[:file_type] == \"video\"\n if params[:item][:item_video] and params[:item][:item_video][:id] and params[:item][:item_video][:id].to_i > 0\n iv = ItemVideo.find(params[:item][:item_video][:id])\n o = ItemVideo.new\n if File.exist?(iv.video.path)\n o.video = File.open(iv.video.path)\n else\n o.video_from_url(iv.video.url)\n end\n o.item_id = offer_as_tod.id\n o.save\n chk = true\n elsif params[:item][:item_video]\n if params[:item][:item_video][:video]\n o = ItemVideo.new(params[:item][:item_video])\n o.item_id = offer_as_tod.id\n o.save\n chk = true\n end\n end\n end\n\n if not chk and params[:archive_id].present?\n o = ItemVideo.new\n o.video_from_url(@url)\n o.item_id = offer_as_tod.id\n o.save\n chk = true\n end\n\n if not chk and params[:item][:selected_item_id].to_i > 0\n itm = Item.find(params[:item][:selected_item_id])\n if itm.item_videos and itm.item_videos.count > 0\n o = ItemVideo.new\n if File.exist?(itm.item_videos[0].video.path)\n o.video = File.open(itm.item_videos[0].video.path)\n else\n o.video_from_url(itm.item_videos[0].video.url)\n end\n o.item_id = offer_as_tod.id\n o.save\n else\n o = ItemPhoto.new\n if File.exist?(itm.item_photos[0].photo.path)\n o.photo = File.open(itm.item_photos[0].photo.path)\n else\n o.photo_from_url(itm.item_photos[0].photo.url)\n end\n o.item_id = offer_as_tod.id\n o.save\n end\n end\n if session[:guest_user_id].to_i > 0\n session[:guest_offer_as_tod] = true\n end\n end\n else\n session[:guest_user_id] = nil\n session[:is_guest_user] = nil\n end\n\n # Alert.add_2_alert_q(ALERT_TYPE_TRADEYA, NEW_OFFER_ON_TRADEYA, trade.item.user.id, nil, trade.id)\n\n # if InfoAndSetting.sm_on_o_made then EventNotificationMailer.offer_is_made(trade).deliver end\n if InfoAndSetting.sm_on_o_made and trade.item.user.notify_received_offer then EventNotification.add_2_notification_q(NOTIFICATION_TYPE_USER_SETTING, NOTIFICATION_OFFER_MADE, trade.item.user.id, {:trade_id => trade.id}) end\n # if InfoAndSetting.sm_on_trd_live and params[:item][:tod] == '1' then EventNotificationMailer.tradeya_is_live(@item).deliver end\n # if InfoAndSetting.sm_on_trd_live and @item.user.notify_tradeya_begins?(MAIL) and params[:item][:tod] == '1' then EventNotification.add_2_notification_q(NOTIFICATION_TYPE_USER_SETTING, NOTIFICATION_TRADEYA_IS_LIVE, @item.user.id, {:item_id => @item.id}) end\n #if InfoAndSetting.sm_on_trd_live and @item.user.notify_tradeya_begins and params[:item][:tod] == '1' then EventNotification.add_2_notification_q(NOTIFICATION_TYPE_USER_SETTING, NOTIFICATION_TRADEYA_IS_LIVE, @item.user.id, {:item_id => @item.id}) end\n\n # if offer is submitted from new offer flow, id and title of offer is needed\n if params[:new_offer_flow].present? and params[:item][:is_tod].present? and (params[:item][:is_tod] == 'false') and current_user\n session[:new_offer_title] = @item.title\n session[:new_offer_id] = @item.id\n else\n session[:item_saved_offer] = true\n end\n finished(\"make_offer_form\")\n # if current_user and !current_user.showed_onboarding\n # format.html { redirect_to profile_url }\n # else\n format.html { redirect_to item_path(Item.find(params[:item][:tod_id])) }\n # end\n else\n session[:guest_user_id] = nil\n session[:is_guest_user] = nil\n # Alert.add_2_alert_q(ALERT_TYPE_TRADEYA, TRADEYA_LIVE, @item.user.id, @item.id)\n\n # if InfoAndSetting.sm_on_trd_live then EventNotificationMailer.tradeya_is_live(@item).deliver end\n # if InfoAndSetting.sm_on_trd_live and @item.user.notify_tradeya_begins?(MAIL) then EventNotification.add_2_notification_q(NOTIFICATION_TYPE_USER_SETTING, NOTIFICATION_TRADEYA_IS_LIVE, @item.user.id, {:item_id => @item.id}) end\n #if InfoAndSetting.sm_on_trd_live and @item.user.notify_tradeya_begins then EventNotification.add_2_notification_q(NOTIFICATION_TYPE_USER_SETTING, NOTIFICATION_TRADEYA_IS_LIVE, @item.user.id, {:item_id => @item.id}) end\n\n # if not session[:ipad_mini_contest].nil? and session[:ipad_mini_contest] = 5\n # format.html{ redirect_to contest_url}\n # else\n\n if params[:item][:offer_for]\n if params[:item][:offer_for].include? \"?\"\n format.html { redirect_to my_offers_item_path(Item.find(params[:item][:offer_for]))+ \"&item_saved=\" + @item.id.to_s}\n else\n format.html { redirect_to my_offers_item_path(Item.find(params[:item][:offer_for]))+ \"?item_saved=\" + @item.id.to_s}\n end\n elsif params[:item][:referer_page]\n session[:have_saved] = params[:item][:referer_page]\n if params[:item][:referer_page].include? \"?\"\n format.html {redirect_to params[:item][:referer_page]+ \"&item_saved=\" + @item.id.to_s}\n else\n format.html {redirect_to params[:item][:referer_page]+ \"?item_saved=\" + @item.id.to_s}\n end\n elsif params[:item][:have_add_page]\n if params[:item][:have_add_page].include? \"?\"\n format.html {redirect_to params[:item][:have_add_page]+ \"&item_saved=\" + @item.id.to_s}\n else\n format.html {redirect_to params[:item][:have_add_page]+ \"?item_saved=\" + @item.id.to_s}\n end\n elsif params[:item][:referer_browse_page]\n if params[:item][:referer_browse_page].include? \"?\"\n format.html {redirect_to params[:item][:referer_browse_page]+ \"&item_saved=\" + @item.id.to_s}\n else\n format.html {redirect_to params[:item][:referer_browse_page]+ \"?item_saved=\" + @item.id.to_s}\n end\n else\n # session[:item_saved] = {:title => @item.title, :url => item_path(@item)}\n format.html { redirect_to new_item_path + \"?item_saved=\" + @item.id.to_s }\n end\n # format.html { redirect_to @item.item_url }\n # end\n end\n else\n format.html { redirect_to new_item_path }\n end\n else\n if params[:item][:tod_id]\n format.html { redirect_to item_path(Item.find(params[:item][:tod_id])) }\n else\n format.html { redirect_to new_item_path }\n end\n end\n end\n else\n respond_to do |format|\n format.html { redirect_to new_item_path }\n end\n end\n end", "def set_form_instance_variables\n\t\t@list=List.new\n\t\t@task=@current_list.tasks.new\n\tend", "def create\n i = Item.new\n i.title = params[\"title\"]\n i.description = params[\"desc\"]\n i.save\n redirect_to recommendations_url\n end", "def create\n @item = Item.new(item_params)\n if @item.save\n flash[:success] = \"項目已新增!\"\n redirect_to root_url\n else\n flash[:danger] = \"新增失敗!\"\n @submit_text = \"新增\"\n render 'new'\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 super\n end", "def create\n super\n end", "def create\n super\n end", "def create\n super\n end", "def create\n super\n end", "def create\n super\n end", "def create\n super\n end", "def create\n super\n end", "def create\n super\n end", "def set_first_input\n @first_input = FirstInput.find(params[:id])\n end", "def create\n\t \t@item = Item.new(item_params)\n\t \tif @item.save\n\t \t\tredirect_to items_path\n\t \telse\n\t \t\trender action: \"new\"\n\t \tend\n\t 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 @admin_item = Admin::Item.new(params[:admin_item])\n @admin_item.agency_id = @current_agency.id\n fields = params[:item][:field]\n\n respond_to do |format|\n if @admin_item.save\n \n fields.each do |key, value|\n Admin::FieldValue.create(:item_id => @admin_item.id, :field_id => key, :value => value)\n end\n \n format.html { redirect_to edit_admin_item_path(@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 set_input\n @input = Input.find(params[:id])\n end", "def set_input\n @input = Input.find(params[:id])\n end", "def set_input\n @input = Input.find(params[:id])\n end", "def set_input\n @input = Input.find(params[:id])\n end", "def createItem(title, description, date)\n new_item = List.new\n new_item.title = title\n new_item.description = description\n new_item.save\n new_item.date = date\n end", "def generate_sales_entry_add_product_form\n @item= Item.find_by_id params[:selected_item_id]\n @sales_order = SalesOrder.find_by_id params[:sales_order_id]\n @new_object = SalesEntry.new \n end", "def set_item\n if flash[:model]\n @item = Item.find(flash[:model][\"id\"])\n @item.assign_attributes(flash[:model])\n flash[:model_errors].each do |k,v|\n @item.errors.add(k,v[0])\n end\n @item.date_lended = I18n.localize @item.date_lended if @item.date_lended\n @item.initial_return_date = I18n.localize @item.initial_return_date if @item.initial_return_date \n flash.clear\n @item\n else\n @item = Item.find(params[:id])\n @item.date_lended = I18n.localize @item.date_lended if @item.date_lended\n @item.initial_return_date = I18n.localize @item.initial_return_date if @item.initial_return_date \n end\n\n \n end", "def set_user_input\n @user_input = UserInput.find(params[:id])\n end", "def create\r\n @item = Item.new(params[:item])\r\n if @item.save\r\n redirect_to @item, notice: 'Item was successfully created.'\r\n else\r\n render action: \"new\"\r\n end\r\n end", "def set_new_item\n @new_item = NewItem.find(params[:id])\n end", "def new\r\n @item = Item.new\r\n @item.user_id = 0\r\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 new\n\t\t@item = Product.new\n\tend", "def initialize(input_options)\n super()\n @junk_food = input_options[:junk_food]\n @calories = input_options[:calories]\n @price = input_options[:price]\n @status = input_options[:status]\n end", "def create\n @item = Item.new(item_params) #or params[:items]\n\n respond_to do |format|\n if @item.save #if object is saved successfully, eg validations pass\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.js\n format.xml\n else \n #if object is not saved successfully, redirect to new action\n format.html { render action: 'new' } #all filled fields will be prepopulated\n format.js\n format.xml\n \n end\n end\n end", "def initialize(title:, ready_in_minutes:, servings:, source_url:) #key,value method so arguments dont have to be place in specific orders \n self.title = title #set it to self. to be able to make custom changes if i wanted to in the futre ex:upcase, downcase\n self.ready_in_minutes = ready_in_minutes\n self.servings = servings\n self.source_url = source_url\n \n self.save\n \n end", "def create\n @orden_item = OrdenItem.new(orden_item_params)\n @orden_item.orden_id = @orden_item.id_orden\n @orden_item.item_id = @orden_item.id_item\n @orden_item.item_name = @orden_item.item.item_name\n @orden_item.item_image = @orden_item.item.item_image\n @orden_item.item_type = @orden_item.item.item_type\n\n respond_to do |format|\n if @orden_item.save\n format.html { redirect_to @orden_item, notice: 'Orden item was successfully created.' }\n format.json { render :show, status: :created, location: @orden_item }\n else\n format.html { render :new }\n format.json { render json: @orden_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def initialize(input_options)\n @uid = input_options[:uid]\n @description = input_options[:description]\n @category = input_options[:category]\n @price = input_options[:price]\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 init_on_create(*)\n self._classname = self.class.to_s\n write_default_attributes\n write_changed_attributes\n clear_changes\n end", "def before_create()\n end", "def create_todo_item(title, description)\n new_item = Todoitem.new\n new_item.title = title\n new_item.description = description\n new_item.save\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 process_instance(item)\n @instance = Yarpler::Models::Instance.new\n @instance.variable = item[0].to_s\n end", "def initialize\n save\n end", "def create\n\n \t\t@item = current_user.items.build(item_params)\n \t\tif @item.save\n \t\t\tflash[:success] = \"Item created!\"\n \t\t\tredirect_to items_path\n \t\telse\n \t\t\t@feed_items = []\n \t\t\trender 'static_pages/home'\n \t\tend\n \tend", "def save_values\n self.first_name = @first_name_field.text.strip.chomp\n self.last_name = @last_name_field.text.strip.chomp\n self.age = @age.text.strip.chomp\n self.email = @email.text.strip.chomp\n self.github = @github.text.strip.chomp\n self.twitter = @twitter.text.strip.chomp\n self.fun_fact = @fun_fact.text.strip.chomp\n puts self.first_name\n puts self.last_name\n puts self.age\n\n # TODO: 2. Finish the implementation to set the other fields.\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 @choice_item = ChoiceItem.new(choice_item_params)\n\n respond_to do |format|\n if @choice_item.save\n format.html { redirect_to @choice_item, notice: 'Choice item was successfully created.' }\n format.json { render :show, status: :created, location: @choice_item }\n else\n format.html { render :new }\n format.json { render json: @choice_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create \n @item = Item.new(params.require(:item).permit(:name))\n @item.list = current_user.list\n if @item.save\n flash[:notice] = \"You're item was added to the list!\"\n redirect_to @item.list\n else\n flash[:error] = \"You and your Item suck - try again\"\n render @item.list\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 pre_initialize_fields\n end", "def create\n \t\n \t@item=Item.new(item_params)\n \t\n \tif @item.save\n \t\tredirect_to(:action=>'display')\n \telse\n \t\trender('new')\n \tend\t\n \n end", "def save_values\n self.first_name = @first_name_field.text.strip.chomp\n self.last_name = @last_name_field.text.strip.chomp\n self.email = @email_field.text.strip.chomp\n self.github = @github_field.text.strip.chomp\n self.twitter = @twitter_field.text.strip.chomp\n self.fun_fact = @fun_fact_field.text.strip.chomp\n\n # TODO: 2. Finish the implementation to set the other fields. DONE\n end", "def create\n @item = Item.new(item_params)\n\n respond_to do |format|\n if @item.save\n category_field_values = []\n params[:item_field].each do |key, value|\n category_field_values << { item_id: @item.id, category_field_id: key, value: value }\n end\n CategoryFieldValue.create(category_field_values)\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 \n @item = Item.new(item_params)\n user = User.find_by(id: session[:user_id])\n @item.user_id = user.id\n # category = Category.find_by name: params[:category]\n # @item.category_id = category.id\n\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 puts(@item.errors.messages)\n format.html { render action: 'new' }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def add\n data = {\n id: SecureRandom.uuid\n }\n\n create data do |item|\n refresh do\n @sidebar.input.value = ''\n render!\n self.state = item[:id]\n end\n end\n end", "def initialize(input_options) #input_options is a hash\n @name = input_options[:name]\n @color = input_options[:color]\n @price = input_options[:price]\n @inventory = input_options[:inventory]\n end", "def create\n upload_item params[params[:item_type]], session['username'], params[:alternative_name], params[:tag_name], params[:item_type], params[:details]\n end", "def initialize(input_holder_name, input_amount, input_type)\n @holder_name = input_holder_name\n @amount = input_amount\n @type = input_type\nend", "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 save_input(input_item)\n if !@@temp_input_list.has_key?(\"#{input_item['.module']}\")\n @@temp_input_list[\"#{input_item['.module']}\"] = { \"#{input_item['.parameter']}\" => input_item['.value'] }\n else\n @@temp_input_list[\"#{input_item['.module']}\"][\"#{input_item['.parameter']}\"] = input_item['.value']\n end\nend", "def create\n @input = Input.new(params[:input].merge!(:user => current_user))\n respond_to do |format|\n if @input.save\n format.html { redirect_to @input, notice: 'Input was successfully created.' }\n format.json { render json: @input, status: :created, location: @input }\n else\n format.html { render action: \"new\" }\n format.json { render json: @input.errors, status: :unprocessable_entity }\n end\n end\n end", "def generate_new_item_object\n @new_item = Flight.new\n insert_required_params_into_new_item_object\n insert_default_params_into_new_item_object\n insert_optional_params_into_new_item_object(self)\n return @new_item\n end", "def input_for_create( ctx, ** )\n { title: ctx[:title] }\n end", "def create\n @defaultitem = Defaultitem.create defaultitem_params\n redirect_to admins_path\n end", "def createToDo title, description\n item = Todo.new\n item.title = title\n item.description = description\n item.save\nend", "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 insert_default_params_into_new_item_object\n payload_value_obj = PayloadValueFlc.new_by_flight_creator_object(self)\n @new_item.boarding_duration_in_seconds = plane.aircrafttype.boarding_duration_default\n @new_item.taxi_duration_in_seconds = departure_airport.taxi_duration_default\n @new_item.flight_miles = route_length_in_miles_not_rounded.to_int\n @new_item.pax_count = plane.avg_pax_count\n @new_item.payload_value_flc = payload_value_obj.payload_value_flc\n @new_item.code = generate_flight_code\n end", "def create\n @question_item = QuestionItem.new(question_item_params)\n\n respond_to do |format|\n if @question_item.save\n format.html { redirect_to @question_item, notice: 'Question item was successfully created.' }\n format.json { render :show, status: :created, location: @question_item }\n else\n format.html { render :new }\n format.json { render json: @question_item.errors, status: :unprocessable_entity }\n end\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 create\n @item = Item.new(params[:item])\n if params[\"itinerary_id\"] != \"\"\n @item.itineraries << Itinerary.find(params[\"itinerary_id\"])\n if ( @item.location != nil ) && ( @item.img_url == nil )\n @item.geocode_function\n else\n @item.save\n end\n redirect_to \"/itineraries/#{params[:itinerary_id]}\"\n else\n @item.save\n redirect_to items_path\n end\n\n end", "def new_basic_predetails\n\t\t@petsitter = Petsitter.new #object that form will bind to \n\t\t\n\t\t# we could have put what is below directly in the view but the controller's job is supposed to be to ask data from the model and set it up for the views - the view should be completely decoupled from the model( the view should never know of the model's existence )\n\t\t@all_residential_areas_in_nairobi = ResidentialArea.all\n\tend", "def create\n @item_type = ItemType.new(item_type_params)\n\n respond_to do |format|\n if @item_type.save\n format.html { redirect_to @item_type, notice: 'ItemType was successfully created.' }\n format.json { render action: 'show', status: :created, location: @suplier }\n else\n format.html { render action: 'new' }\n format.json { render json: @item_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @item = Item.new(item_params)\n @user = User.find_by_id(session[:user_id]) if session[:user_id]\n\n @item.rating = 0\n @item.rating_count = 0\n @item.current_amount = item_params[:max_amount]\n @item.user = @user #This is the owner of the item\n respond_to do |format|\n if @item.save\n format.html { redirect_to user_supplier_path_url(@user)}\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 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 = 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 initialize(input_options)\n\t\t\t@first_name = input_options[:first_name]\n\t\t\t@last_name = input_options[:last_name] \n\t\t\t@salary = input_options[:salary]\n\t\t\t@active = input_options[:active] \n\t\tend", "def save\r\n @@items.push self\r\n end", "def add_to\n begin\n study = Study.find(params[:study_id])\n unless study.user_id != session[:user_id] || study.active == true\n i = Item.new\n i.study_id = params[:study_id]\n i.name = params[:item_name]\n i.description = params[:item_description]\n unless i.save\n flash[:error] = \"Please enter a valid item name and description.\"\n end\n end\n rescue\n\n ensure\n redirect_to(edit_study_path(params[:study_id]))\n end\n end", "def initialize( quantity)\n #@item_name = item_name\n @quantity = quantity\n\n end", "def create\n @questionairre_item = QuestionairreItem.new(params[:questionairre_item])\n respond_to do |format|\n if @questionairre_item.save\n ## To step 2\n #format.html {\n # render :partial => \"step2\",\n # :layout => false,\n # :locals => { :questionairre_item => @questionairre_item}\n #}\n format.html { redirect_to @questionairre_item, notice: 'Questionairre item was successfully created.' }\n format.json { render json: @questionairre_item, status: :created, location: @questionairre_item }\n else\n @types = QuestionairreItem::TYPES\n format.html { render :action => \"new\" }\n format.json { render json: @questionairre_item.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.6439379", "0.6347448", "0.63215697", "0.62827027", "0.62627256", "0.62627256", "0.62627256", "0.6214163", "0.61589295", "0.61163557", "0.60723484", "0.6037059", "0.6034132", "0.60244673", "0.6020945", "0.6018476", "0.5970915", "0.5970213", "0.5961268", "0.59607476", "0.59592986", "0.59440565", "0.593294", "0.5927763", "0.59199214", "0.59176576", "0.5914559", "0.5914559", "0.5914559", "0.5914559", "0.5914559", "0.5914559", "0.5914559", "0.5914559", "0.5914559", "0.59098995", "0.59058166", "0.59037274", "0.5889159", "0.5878568", "0.5878568", "0.5878568", "0.5878568", "0.58781487", "0.586959", "0.5863825", "0.58579814", "0.5849474", "0.5847701", "0.58449256", "0.584492", "0.58414954", "0.58381915", "0.5830981", "0.5830624", "0.5815161", "0.58140177", "0.5811822", "0.58063006", "0.58018076", "0.5791948", "0.57853884", "0.5784482", "0.5774388", "0.5767849", "0.5767429", "0.5766474", "0.5766084", "0.57625455", "0.5758596", "0.57559407", "0.57524383", "0.575179", "0.5735084", "0.5732261", "0.5729832", "0.57280844", "0.5726332", "0.5722231", "0.5721646", "0.57207924", "0.571739", "0.57165545", "0.5709353", "0.5704689", "0.56956977", "0.56951404", "0.56945467", "0.5692808", "0.5692475", "0.5692362", "0.5691019", "0.5689478", "0.56874365", "0.5685094", "0.56770426", "0.5672623", "0.56719714", "0.56686616", "0.5667852", "0.56668967" ]
0.0
-1
checks whether the tool breaks, the item breaks, both breaks, or nothing breaks
def broken(tool_condition) #allow the tool class to be use through the parameter if @item_health == 0 && tool_condition.tool_health == 0 #when both health reach 0 at the same time puts "Both #{@item_name} and #{tool_condition.tool_name} break at the same time!" elsif @item_health <= 0 #when the item's health is 0 or below 0 before the tool's health puts "The #{@item_name} breaks first!" elsif tool_condition.tool_health <= 0 #when the tool's health reaches 0 or below 0 before the item's health puts "Your #{tool_condition.tool_name} breaks first!" else puts "Nothing breaks. \nYour #{tool_condition.tool_name}'s health is now #{tool_condition.tool_health}. \nThe #{@item_name}'s health is now #{@item_health}." end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def break?\n @break\n end", "def valid_item\n @windows[Win_Help].move_to(2)\n #@windows[Win_Help].show\n @active_battler.current_action.clear\n @active_battler.current_action.set_item(@item.id)\n if @item.for_dead_friend? and !$game_system.actors_bodies? \n if $game_map.passable?(@cursor.x, @cursor.y, 0) and\n (occupied_by?(@cursor.x, @cursor.y) == nil)\n open_revive_window\n end\n else\n @active_battler.current_action.set_item(@item.id)\n @targets = get_targets\n if @targets.empty?\n Sound.play_buzzer\n else\n Sound.play_decision\n @cursor.active = false \n @windows[Win_Confirm].ask(Command_Confirm::Item) \n @windows[Win_Status].dmg_preview(3, @active_battler, @item, @targets)\n @windows[Win_Help].move_to(2)\n #@windows[Win_Help].show\n end\n end\n end", "def broken?\n self.broken_parts.size > 0\n end", "def on_block_break(evt)\n target_block = evt.block\n player = evt.player\n tool = player.inventory.item_in_main_hand\n return if player.sneaking?\n return unless pickaxe?(tool.type) || spade?(tool.type)\n return unless has_job?(player)\n return unless range_breakable?(target_block)\n\n n = case tool.type\n when Material::IRON_PICKAXE then 1\n when Material::DIAMOND_PICKAXE then 1\n else 1\n end\n\n around_blocks = cubic_around_blocks(target_block, n)\n blocks = around_blocks.reject { |block|\n block.y < player.location.y\n }.select { |block|\n breakable_together?(target_block, block)\n }\n\n blocks.each do |block|\n later(0) do\n block.break_naturally(tool)\n end\n end\n\n end", "def ensure_not_referenced_by_any_line_item\n\tif line_items.count.zero?\nreturn true\nelse\nerrors[:base] << \"Line Items present\"\nreturn false\nend\nend", "def ensure_not_referenced_by_any_line_item\n if line_items.count.zero?\n return true\n else\n errors[:base] << \"Line Items present\" #这是什么意思\n return false\n end\n end", "def ensure_not_referenced_by_any_line_item \n if line_items.count.zero?\n return true\n else\n errors[:base] << \"Line Items present!\"\n return false\n end\n end", "def ensure_not_referenced_by_any_line_item\n \t\tif line_items.empty?\n \t\t\treturn true\n \t\telse\n \t\t\terrors.add(:base, 'Existe linha de item')\n\t\t \treturn false\n \t\tend\n \tend", "def ensure_not_referenced_by_any_line_item\nif line_items.count.zero?\nreturn true\nelse\nerrors[:base] << \"Line Items present\"\nreturn false\nend\nend", "def ensure_not_referenced_by_any_line_item\n\n if line_items.count.zero?\n return true\n else\n errors[:base] << \"Line Items present\"\n return false\n\nend\nend", "def ensure_not_referenced_by_any_line_item\n\nif line_items.count.zero?\nreturn true\nelse\nerrors[:base] << \"Line Items present\"\nreturn false\nend\nend", "def should_collect_broken_bikes?(container)\n !self.full? && container.broken_bikes.count >= 1 \n end", "def ensure_not_referenced_by_any_line_item\n\tif line_items.count.zero?\nreturn true\nelse\nerrors.add(:base, 'Line Items present' )\nreturn false\n end\nend", "def broken?\n @broken == :broken \n\tend", "def ensure_not_referenced_by_any_line_item\n\tif line_items.empty?\n \t return true\n \telse\n \t errors.add(:base, 'Line Items present' )\n \treturn false\n \tend\n end", "def ensure_not_referenced_by_any_line_item\n if line_items.empty?\n return true\n else\n errors.add(:base, 'este produto não pode ser deletado porque pertence à itens em carrinhos de compras')\n return false\n end\n end", "def ensure_not_referenced_by_any_line_item\nunless line_items.empty?\nerrors.add(:base, 'Line Items present')\nthrow :abort\nend\nend", "def ensure_not_referenced_by_any_line_item\nunless line_items.empty?\nerrors.add(:base, 'Line Items present')\nthrow :abort\nend\nend", "def ensure_not_referenced_by_any_line_item\nunless line_items.empty?\nerrors.add(:base, 'Line Items present')\nthrow :abort\nend\nend", "def break\n @break = true\n end", "def validate_line_items\n \n end", "def ensure_not_referenced_by_any_line_item\n unless line_items.empty?\n errors.add(:base, 'Line Items present')\n throw :abort\n end\n end", "def break!\n if @broke\n puts \"Cup is already broken! calm yourself!\"\n else\n @broke = true\n puts \"Splat!!!\"\n end\n end", "def ensure_not_referenced_by_any_line_item\r\n\t\tunless line_items.empty?\r\n\t\t\terrors.add(:base, 'Line Items Present')\r\n\t\t throw :abort\r\n\t\tend\r\n\t\r\n\tend", "def ensure_not_referenced_by_any_line_item\n if line_items.empty?\n return true\n else\n errors.add(:base, 'Line Items present')\n return false\n end\n end", "def ensure_not_referenced_by_any_line_item\n if line_items.empty?\n return true\n else\n errors.add(:base, 'Line Items present')\n return false\n end\n end", "def ensure_not_referenced_by_any_line_item\n if line_items.empty?\n return true\n else\n errors.add(:base, 'Line Items present')\n return false\n end\n end", "def ensure_not_referenced_by_any_line_item\n if line_items.count.zero?\n return true\n else\n errors[:base] << \"Line Items present\"\n return false\n end\n end", "def ensure_not_referenced_by_any_item_line\n if item_lines.empty?\n return true\n else\n errors.add(:base, 'Line Items present')\n return false\n end\nend", "def ensure_not_referenced_by_any_line_item\n if line_items.empty?\n return true\n else\n errors.add(:base, 'Existuju polozky')\n return false\n end\n end", "def ensure_not_referenced_by_any_line_item\n \t if line_items.empty?\n \t \treturn true\n \t else\n \t \terrors.add(:base, 'Line items present')\n \t \treturn false\n \t end\n \tend", "def ensure_not_referenced_by_any_line_item \n \tif line_items.empty?\n return true \n else\n errors.add(:base, 'Line Items present')\n return false \n end\n end", "def check_bag(lost_item)\n @items.each do |type,list|\n contains_lost_item = list.any? {|item,empty| item == lost_item}\n return \"No worries, you already packed #{lost_item}.\" if contains_lost_item\n end\n return \"Your bag is missing #{lost_item}!\"\n end", "def ensure_not_referenced_by_any_line_item \n if line_items.empty? \n return true \n else \n errors.add(:base, 'Line Items present') \n return false \n end \n end", "def show_item_gold?(targets) #don't show item/gold gained during battle\n end", "def ensure_not_referenced_by_any_line_item # hook method (a method that Rails calls automatically at a given point in an object’s life)\n if line_items.empty?\n return true\n else\n errors.add(:base, 'Line Items present')\n return false\n end\n end", "def ensure_not_referenced_by_any_line_item\n \tif line_items.empty?\n \t\treturn true\n \telse\n \t\terrors.add(:base, 'Line Items present')\n \t\treturn false\n \tend \t\t\n end", "def add_break\n\t\tcheck_if_myself\n\t\t@break = Break.new\n\tend", "def ensure_not_referenced_by_any_line_item \n\t\tif line_items.empty?\n\t\t\treturn true \n\t\telse\n\t\t\terrors.add(:base, 'Line Items present')\n\t\treturn false\n\t\tend\n\tend", "def available_works?\n if prev.valid_tracking?\n prev.done > done\n else\n product_line_quantity > done\n end\n end", "def ensure_not_referenced_by_any_line_item\nif line_items.empty?\nreturn true\nelse\nerrors.add(:base, 'Line Items present')\nreturn false\nend\nend", "def ensure_not_referenced_by_any_line_item\nif line_items.empty?\nreturn true\nelse\nerrors.add(:base, 'Line Items present')\nreturn false\nend\nend", "def ensure_not_referenced_by_any_line_item\nif line_items.empty?\nreturn true\nelse\nerrors.add(:base, 'Line Items present')\nreturn false\nend\nend", "def ensure_not_referenced_by_any_line_item\nif line_items.empty?\nreturn true\nelse\nerrors.add(:base, 'Line Items present')\nreturn false\nend\nend", "def ensure_not_referenced_by_any_line_item\n if line_items.empty?\n return true\n else\n errors.add(:base, 'Istnieja powiazania z Line Items')\n return false;\n end\n end", "def did_anyone_buy_this_thing?\n if line_items.empty?\n return true \n else\n errors.add(:base, 'Line Items Present')\n return false\n\n end\n end", "def ensure_not_referenced_by_any_line_item\n if line_items.empty?\n\t return true\n else\n errors.add(:base, 'Line Items present')\n return false\n end\n end", "def ensure_not_referenced_by_any_line_item\n\tif line_items.count.zero?\n\treturn true\n\telse\n\terrors[:base] << \"Line Items present\"\n\treturn false\n\tend\nend", "def ill_item?(instance)\n instance['source'] == 'FOLIO' &&\n instance['discoverySuppress'] == true &&\n instance['staffSuppress'] == false\n end", "def ensure_not_referenced_by_any_line_item\n if line_items.count.zero?\n return true\n else\n errors[:base] << \"Line Items present\"\n return false\n end \n end", "def ensure_not_referenced_by_any_line_item\n if line_items.empty?\n return true\n else\n errors.add(:base, 'Line Items present')\n return false\n end\n end", "def ensure_not_referenced_by_any_line_item\n if line_items.empty?\n return true\n else\n errors.add(:base, 'Line Items present')\n return false\n end\n end", "def usable_item_conditions_met?(item)\r\n movable? && occasion_ok?(item)\r\n end", "def precheck_clearancing_error\n potential_item = Item.find_by(id: @item_id)\n\n if !@item_id.is_a?(Integer) || @item_id == 0\n @errors << \"Item id #{@item_id} is not valid\"\n\n elsif potential_item && potential_item.status == 'clearanced'\n # NOTE: The catch at the end is there just to satisfy a spec condition. Not super happy about that.\n @errors << \"Item id #{@item_id} already clearanced into Batch #{potential_item.clearance_batch.id if potential_item.clearance_batch}\"\n\n elsif !potential_item\n @errors << \"Item id #{@item_id} could not be found\"\n\n elsif Item.sellable.where(id: @item_id).none?\n @errors << \"Item id #{@item_id} could not be clearanced\"\n\n else\n false\n\n end\n\n end", "def validate_items\n not(empty_item_list? or has_invalid_items? ||\n has_different_point_values?) ? true : false\n end", "def has_line_item?\n true\n end", "def ensure_not_referenced_by_any_line_item\n\t\tunless line_items.empty?\n\t\t\terrors.add(:base, 'Line Items Presents')\n\t\t\tthrow :abort\n\t\tend\n\tend", "def ensure_not_referenced_by_any_line_item\n if line_items.empty?\n return true\n else\n errors.add(:base, 'Line Items present')\n return false\n end\n end", "def ensure_not_referenced_by_any_line_item\n\t if line_items.count.zero?\n\t\t return true\n\t else\n\t\t errors[:base] << \"Line Items present\"\n\t\t return false\n\t end\n\tend", "def ensure_not_referenced_by_any_line_item\n if line_items.empty?\n return true\n else\n errors.add(:base, 'Line Items present')\n return false\n end\n end", "def ensure_not_referenced_by_any_line_item\n\tif line_items.empty?\n\treturn true\n\telse\n\terrors.add(:base, 'Line Items present')\n\treturn false\n\tend\n\tend", "def ensure_not_referenced_by_any_line_item\n\t\tunless line_items.empty?\n\t\t\terrors.add(:base, 'Line Items present')\n\t\t\tthrow :abort\n\t\tend\n\tend", "def ensure_not_referenced_by_any_line_item\n\t\tif line_items.emty?\n\t\t\treturn true\n\t\tesle\n\t\t\terrors.add(:base, 'Line Items present')\n\t\t\treturn false\n\t\tend\n\tend", "def ensure_not_referenced_by_any_line_item\n\tif line_items.empty?\n\treturn true\n\telse\n\terrors.add(:base, 'Line Items present')\n\treturn false\n\tend\nend", "def process_tool_action(item)\n PearlKernel.load_item(item)\n return if !battler.tool_ready?(item)\n \n unless PearlKernel.has_data?\n if item.is_a?(RPG::Weapon) || item.is_a?(RPG::Armor)\n msgbox('Tool data missing') if $DEBUG\n return\n end\n if item.scope.between?(1, 6)\n msgbox('Tool data missing') if $DEBUG\n return\n elsif item.scope == 0\n return\n \n elsif !battler.usable?(item)\n RPG::SE.new(\"Cursor1\", 80).play if self.is_a?(Game_Player)\n return \n end\n end\n \n if PearlKernel.has_data? and not usable_test_passed?(item)\n RPG::SE.new(\"Cursor1\", 80).play if self.is_a?(Game_Player)\n return\n end\n \n @user_casting = [PearlKernel.tool_castime,item] if PearlKernel.has_data?\n if @user_casting[0] > 0\n @animation_id = 0\n @animation_id = PearlKernel.tool_castanimation\n else\n load_abs_tool(item)\n end\n end", "def broken?\n\t\t@broken\n\tend", "def ensure_not_referenced_by_any_line_item \n if line_items.empty?\n return true \n else\n errors.add(:base, 'Line Items present')\n return false \n end\n end", "def main_break?\r\n return $scene != self # Abort loop if sceen is changed\r\n end", "def ensure_not_referenced_by_any_line_item\n if line_item1s.count.zero?\n return true\n else\n errors[:base] << \"Line Items present\"\n return false\n end\n end", "def ensure_not_referenced_by_any_line_item\n\t\tif line_items.count.zero?\n\t\t\treturn true\n\t\telse\n\t\t\terrors[:base] << \"Line Items Prsent\"\n\t\t\treturn false\n\t\tend\n\tend", "def blocked?\n\t\twin_lines.all? { |line|\n\t\t\tline.any? { |line_piece| line_piece == \"x\" } &&\n\t\t\tline.any? { |line_piece| line_piece == \"o\" }\n\t\t}\n\tend", "def ensure_not_referenced_by_any_line_item \n if line_items.empty?\n return true \n else\n errors.add(:base, 'Line Items present')\n return false \n end\n end", "def update_item\n # continue input if item should be used\n return false if !self.check_item_condition?\n # if item not usable or item use process not executed and no selection\n if $game_player.battler.item == 0 ||\n !$game_player.use_item($data_items[$game_player.battler.item]) &&\n $game_temp.select_data == nil\n # play buzzer, can't use\n $game_system.se_play($data_system.buzzer_se)\n end\n # stop input update\n return true\n end", "def ensure_not_referenced_by_any_line_item\n if line_items.empty?\n return true\n else\n errors.add(:base, 'Line Items present')\n return false\n end\n end", "def ensure_not_referenced_by_any_line_item\n \tif line_items.empty?\n \t\treturn true\n \telse\n \t\terrors.add(:base, 'Line Items Present')\n \t\treturn false\n \tend\n end", "def ensure_not_referenced_by_any_line_item\n\t\tif line_items.empty?\n\t\t\treturn true\n\t\telse\n\t\t\terrors.add(:base, 'Product sedang di referensikan oleh Line Item')\n\t\t\treturn false\n\t\tend\n\tend", "def ensure_not_referenced_by_any_line_item\n if line_items.count.zero?\n return true\n else\n errors[:base] << \"Line Items present\"\n return false\n end\n end", "def judge_win_loss\n return if update_processes or @spriteset.effect?\n #-------------------------------------------------------------\n # Check Victory Conditions\n check_victory_conditions\n\n #-------------------------------------------------------------\n # Check Failure conditions\n check_failure_conditions\n \n #If all Actors dead\n if (friends_of(Battler_Actor).select {|mem| !mem.death_state?}).empty?\n add_fail_com\n end\n update_event_queue\n end", "def ensure_not_referenced_by_any_line_item\n if line_items.empty?\n return true\n else\n errors.add(:base, 'Variant used in Line Items')\n return false\n end\n end", "def ensure_not_referenced_by_any_line_item\n if line_items.empty?\n return true\n else\n errors.add(:base, 'Line Items present')\n return false\n end\n end", "def ensure_not_referenced_by_any_line_item\n if basket_items.empty?\n return true\n else\n errors.add(:base, 'Basket Items present')\n return false\n end\n end", "def check_tool_belgio(file_tool_belpex)\n s = Roo::Excel.new(file_tool_belpex.to_s)\n\n if s.sheet(\"Buy summary\").cell(\"G\",2) != \"OK\"\n @errore << \"Nel file #{file_tool_belpex.to_s} nel foglio \\\"Buy summary\\\" il check verbale non è OK\"\n end\n if s.sheet(\"Sell summary\").cell(\"G\",2) != \"OK\"\n @errore << \"Nel file #{file_tool_belpex.to_s} nel foglio \\\"Sell summary\\\" il check verbale non è OK\"\n end\n if s.sheet(\"Buy summary\").cell(\"B\",1) != $data\n @errore << \"Data presente nel file #{file_tool_belpex.to_s} non corrisponde con la data selezionata\"\n end\n end", "def not_referenced_by_any_line_item\n unless line_items.empty?\n errors.add(:base, \"Line items present\")\n throw :abort\n end\n end", "def ensure_not_referenced_by_any_line_item\n if line_items.empty?\n return true\n else\n errors.add(:base, 'Line Items present')\n return false\n end\n end", "def ensure_not_referenced_by_any_line_item\n return if line_items.empty?\n\n errors.add(:base, \"Line Items present\")\n throw :abort\n end", "def ensure_not_referenced_by_any_line_item\n\t\tif line_items.empty?\n\t\t\treturn true\n\t\telse\n\t\t\terrors.add(:base, 'Line items present')\n\t\t\treturn false\n\t\tend\n\tend", "def ensure_not_referenced_by_any_line_work\n if line_works.empty?\n return true\n else\n errors.add(:base, 'Line Works present')\n return false\n end\n end", "def ensure_not_referenced_by_any_line_item\n unless line_items.empty?\n errors.add(:base, \"Line Items present\")\n throw :abort\n end\n end", "def ensure_not_referenced_by_any_line_item\n\t\tif line_items.empty?\n\t\t\treturn true\n\t\telse\n\t\t\terrors.add(:base,'Line Items present') #We associate errors with the base object\n\t\t\treturn false\n\t\tend\n\tend", "def ensure_not_referenced_by_any_line_item \n if line_items.empty?\n return true \n else\n errors.add(:base, 'Line Items present')\n return false \n end\n end", "def checkWin(bombs, remaining, auxAux, buttons)\n\t\tif remaining > 0\n\t\t\tfor i in 0...auxAux.length\n\t\t\t\tif auxAux[i]==\" \"\n\t\t\t\t\treturn -1\n\t\t\t\tend\n\t\t\tend\n\t\telse \n\t\t\tfor i in 0...buttons.length\n\t\t\t\tif buttons[i].getValue==\"B\"\n\t\t\t\t\tif buttons[i].getMarked!=\"M\"\n\t\t\t\t\t\treturn -1\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\tendTime = Time.now\n\t\tstartTime = @timePlayed\n\t\t@timePlayed = (endTime-startTime).round\n\t\tmenuWin(bombs)\n\tend", "def ensure_not_referenced_by_any_line_item\n\t\tif line_items.empty?\n\t\t return true\n\t \telse\n\t \t errors.add(:base, 'Line Items present')\n\t return false\n\t end\n end", "def ensure_not_referenced_by_any_line_item\n\t\tif line_items.count.zero?\n\t\t\treturn true\n\t\telse\n\t\t\terrors[:base] << \"Line Items present\"\n\t\t\treturn false\n\t\tend\n\tend", "def valid_item?\n # PCP Items can only be created by Commenting Group\n return 1 if pcp_step.in_presenting_group?\n\n # scenario without comments; note that I can safely assume that there are at\n # least two steps ... because it is not allowed to add PCP Items to the first\n # PCP Step (0), hence the current step is at least PCP Step (1).\n ps = pcp_subject.current_steps\n if pcp_comments.count == 0 then\n if pcp_step == ps[ 0 ] # newly created?\n return ( pub_assmt.nil? && new_assmt == assessment ) ? 0 : 2\n elsif pcp_step == ps[ 1 ] # new item released\n return ( pub_assmt == new_assmt && new_assmt == assessment ) ? 0 : 3\n else\n # inconsistent: there should be comments in the previous step\n return 4\n end\n end\n # we have comments here ( pcp_comments.count > 0 )\n \n # if PCP Item was newly created for step, last public comment -\n # if existing - determines current assessment, else assessment\n if pcp_step == ps[ 0 ]\n return 5 unless pub_assmt.nil?\n na = assessment\n pcp_comments.each do | c |\n return 6 unless c.pcp_step == pcp_step\n na = c.assessment if c.is_public\n end\n return ( new_assmt == na ) ? 0 : 7\n end\n\n # PCP Item was created for earlier step, determine current assessment\n # from current comments: default is last, most recent comment, look\n # for any public comments which then override new_assmt\n pc = pcp_comments.for_step( ps[ 0 ])\n if pc.count == 0 \n # no comments for current step (yet - or if closed)\n return 8 unless ( pub_assmt == new_assmt )\n elsif ps[ 0 ].in_commenting_group?\n na = pc.last.assessment\n pc.each do | c |\n na = c.assessment if c.is_public\n end\n return 9 unless ( new_assmt == na )\n else\n # no assessment changes allowed by presenting group\n pc.each do | c |\n return 10 if assessment_changed?( c.assessment )\n end\n end\n\n # now check if pub_assmt is correctly computed from previous step:\n # determine last released assessment, if any\n\n if ps[ 1 ].in_presenting_group?\n # there should be no changes at all\n pc = pcp_comments.for_step( ps[ 1 ])\n pc.each do | c |\n return 11 unless ( pub_assmt == c.assessment )\n # note: new_assmt could be different now due to new comments\n # in current step ...\n end\n else # in_commenting_group?\n pc = pcp_comments.is_public.for_step( ps[ 1 ])\n if pc.count > 0\n return 12 unless ( pub_assmt == pc.last.assessment )\n else # no public comments, assessment comes from item\n return 13 unless ( pub_assmt == new_assmt && new_assmt == assessment )\n end\n end\n\n return 0\n end", "def ensure_not_referenced_by_any_line_item\n\t\t\tif line_items.empty?\n\t\t\t\treturn true \n\t\t\telse\n\t\t\t\terrors.add(:base, 'Line Items present')\n\t\t\t\treturn false \n\t\t\tend\n\t\tend", "def ensure_not_referenced_by_any_line_item\n unless line_items.empty?\n errors.add(:base, 'Line Items present')\n throw :abort\n end\n end", "def ensure_not_referenced_by_any_line_item\n unless line_items.empty?\n errors.add(:base, 'Line Items present')\n throw :abort\n end\n end", "def ensure_not_referenced_by_any_line_item\n unless line_items.empty?\n errors.add(:base, 'Line Items present')\n throw :abort\n end\n end", "def ensure_not_referenced_by_any_line_item\n unless line_items.empty?\n errors.add(:base, 'Line Items Present')\n throw :abort\n end\n end", "def end_workup?(l)\n\t\tstart_treatment?(l)\n\tend" ]
[ "0.5960296", "0.58975303", "0.5763711", "0.55955744", "0.55845857", "0.55553985", "0.55226916", "0.5513445", "0.5507034", "0.5492271", "0.5450597", "0.5446428", "0.5409863", "0.540484", "0.5399324", "0.5399088", "0.5394322", "0.5394322", "0.5394322", "0.5393399", "0.53917164", "0.53912675", "0.53834504", "0.53581905", "0.53556556", "0.53556556", "0.53556556", "0.5334393", "0.53326756", "0.5330738", "0.5330428", "0.5323426", "0.53207403", "0.5320533", "0.53199935", "0.531819", "0.53162795", "0.5313215", "0.53058356", "0.52959067", "0.5293403", "0.5293403", "0.5293403", "0.5293403", "0.5272354", "0.5252781", "0.5251067", "0.5248653", "0.52462804", "0.52454585", "0.5242679", "0.52386975", "0.52333236", "0.5232512", "0.52217287", "0.5219373", "0.5217706", "0.52141935", "0.5212305", "0.52080494", "0.52059925", "0.52048177", "0.5199884", "0.51899827", "0.51897365", "0.51887983", "0.5187638", "0.51871854", "0.5182847", "0.51827884", "0.51775575", "0.5175511", "0.51745594", "0.51731586", "0.51616573", "0.5155272", "0.51526487", "0.5151708", "0.51457644", "0.5145098", "0.5139051", "0.51365256", "0.5132439", "0.5125876", "0.51246315", "0.51197594", "0.5118208", "0.5104848", "0.5104711", "0.5104391", "0.51004374", "0.51000917", "0.50947833", "0.5092241", "0.5090523", "0.5088905", "0.5088905", "0.5088905", "0.5088443", "0.50876045" ]
0.6877373
0
Get city names from the hash
def get_city_names(hash) hash.keys end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_city_names(hash)\n\thash.each { |k, v| puts k}\nend", "def get_city_names(somehash)\n somehash.keys\n end", "def get_city_name(myhash)\n myhash.keys\nend", "def get_city_names(hash)\n hash.each{ |k, v| puts k}\nend", "def get_city_names(hashbook)\n hashbook.keys\nend", "def get_city_names(somehash)\n cities = somehash.keys\nend", "def get_city_names(somehash)\n\tputs somehash.keys\nend", "def get_city_names(city_zip_hash)\n# Write code here\n return city_zip_hash.keys\nend", "def get_city_names(somehash)\n somehash.keys\nend", "def get_city_names(somehash)\n somehash.keys\nend", "def get_city_name(city_name)\n city_name.keys\nend", "def get_city_names(some_hash)\n some_hash.keys \nend", "def city_names(hash)\n hash.each{ |k,v| puts k}\nend", "def get_city_names(somehash)\n# Write code here\nsomehash.keys\nend", "def get_city_names(input)\n input.each_key\nend", "def get_city_names(somehash)\n puts \"Cities:\"\n somehash.each do |key, value|\n puts \"- #{key}\"\n end\nend", "def get_city_names(somehash)\n somehash.keys\n# Write code here\nend", "def get_city_names(somehash)\n somehash.keys.each { |city| puts city.to_s }\nend", "def get_city_names(dial_book)\n\t\treturn dial_book.keys\n\t\tend", "def get_city_names (somehash)\n somehash.each { |k ,v| puts k }\n end", "def get_city_names(somehash)\n # return an array of the keys of the hash parameter\n return somehash.keys\nend", "def get_city_names(dial_book) \n dial_book.keys\nend", "def get_city_names(somehash)\n somehash.each { |k, _v| puts k }\nend", "def get_city_names(somehash)\n somehash.each { |k, v| puts k }\nend", "def get_city_names(somehash)\n list=\"\"\n somehash.each do |key, value|\n list.concat(key)\n list.concat(\" \")\n end\n puts \"#{list}\"\nend", "def get_city_names(somehash)\n=begin\n somehash.each do |each_dial|\n puts each_dial[0]\n end\n=end\n somehash.keys\nend", "def get_city_names(somehash)\nsomehash.each { |k, _| puts k.capitalize }\nend", "def get_city_names(somehash)\n puts \"What city do you want the area code for?\"\n somehash.each { |k, v| puts k.capitalize } # somehash.keys could be used\n code = gets.chomp\n get_area_code(somehash, code.downcase)\nend", "def get_city_names(cityName)\n dial_book.each do |dbkey, dbval|\n if dial_book[dbkey] == dial_book[cityName]\n get_area_code(dial_book, )\n end\n end\nend", "def city_names(available_cities)\n puts \"Available Cities Are\"\n available_cities.each {|k,v| puts \"City: #{k}\"}\nend", "def city_info(cities)\n cities.each do |key, value|\n puts \"#{key} has #{value.length} main cities: #{value[0..-2].join(\", \")} and #{value[-1]}\"\n # puts \"#{key} has #{value.length} main cities: #{value.join(\", \")}\"\n end\nend", "def city_names\n cities.pluck(:name).join(\", \")\n end", "def cities\n CS.get :us, :ca\n end", "def list_cities(cities)\n puts cities.keys\nend", "def display_city_names(somehash)\n somehash.each { |k, v| puts k }\nend", "def get_cities(dial_book)\n dial_book.each { |k, _v| puts k }\nend", "def display_city(hash)\n hash.each { |k, v| puts k}\nend", "def employeeLocationsByCity()\n locations = Hash.new\n \n employeesList = (RawData.new(\"employee_details\").getMnoData())['content']['employees']\n \n employeesList.each do | employee |\n # extract the city/country information from the 'address' field\n address = employee['address']\n location = employee['address'].gsub(/\\ \\d+/, \"\")\n location = location.split(/\\s*[,;]\\s*/x).from(-2).join(', ')\n \n # Add to locations records\n occurrence = locations.fetch(location, nil)\n \n if !occurrence\n locations[location] = Array.new\n end \n \n locations[location].push(address)\n \n #puts locations\n end\n\n return locations\n end", "def get_cities\n cities = {}\n doc = nil\n retry_if_exception do\n doc = Nokogiri::HTML( easy_curl(@host_url) )\n end\n return [] if not doc\n a_cities = doc.css(\"ul[class='s-dropdown afh-dd-city'] li a\")\n a_cities.each do |city|\n city_name = city.text\n city_code = city['href'].scan(/\\w+(?=\\/changecity)/).pop\n next if not city_code\n cities[city_code] = city_name\n end\n cities\nend", "def print_city_names(dial_book)\n puts 'City names:'\n dial_book.each_key { |city_name| puts city_name }\nend", "def get_city_names(url)\n doc = Nokogiri::HTML(URI.open(url))\n href = doc.css('.col-lg-offset-1')\n text = href.text.split\n return text[0]\n end", "def find_state_for_city(user_city)\n found = false\n $states.each do |statekey, stateinfo|\n if stateinfo[1].map{|x| x.downcase}.include?(user_city.downcase)\n found = statekey\n end\n end\n if found \n puts \"Ah #{user_city} is in #{found}\"\n else\n puts \"we didnt find your city, try again sucka!\"\n end\nend", "def cities_helper\n [\n ['基隆市', '基隆市'],\n ['台北市', '台北市'],\n ['新北市', '新北市'],\n ['桃園縣', '桃園縣'],\n ['新竹市', '新竹市'],\n ['新竹縣', '新竹縣'],\n ['苗栗縣', '苗栗縣'],\n ['台中市', '台中市'],\n ['彰化縣', '彰化縣'],\n ['南投縣', '南投縣'],\n ['雲林縣', '雲林縣'],\n ['嘉義市', '嘉義市'],\n ['嘉義縣', '嘉義縣'],\n ['台南市', '台南市'],\n ['高雄市', '高雄市'],\n ['屏東縣', '屏東縣'],\n ['台東縣', '台東縣'],\n ['花蓮縣', '花蓮縣'],\n ['宜蘭縣', '宜蘭縣'],\n ['澎湖縣', '澎湖縣'],\n ['金門縣', '金門縣'],\n ['連江縣', '連江縣']\n ]\n end", "def all_city()\n $dial_book.each {|k,v| puts k}\nend", "def carwash_city_name\n\t\t\tobject.city.name\n\t\tend", "def cities\n gallaries.map{|place| place.city}\n\n end", "def get_city\n @single_city_data[\"name\"]\n end", "def city_list\n self.cities.collect do |city|\n city.name\n end.join(\", \")\n end", "def display_city(city)\n city.each { |k,v| puts k }\nend", "def stay_city\n # cities = Country.all.map{|country|country.cities}\n # cities.map{|city|city.name}\n end", "def valid_cities(city_hash,traveller)\n non_international_cities = {}\n\n if travel_internationally?() == false\n traveller_country = traveller.start.split(\", \")\n city_hash.each do |city,price|\n array_city = city.split(\", \")\n\n if traveller_country[1] == array_city[1]\n percent_off = price * 0.5\n price -= percent_off\n non_international_cities[city] = price\n end\n end\n city_hash = non_international_cities\n end\n return city_hash\nend", "def assign_quick_city_name(hash,name)\n corrected_name = name.strip.titleize\n if[\n \"Houston\",\n \"Katy\",\n \"Spring\",\n \"Austin\",\n \"Sugar Land\",\n \"Blanco\",\n \"Portland\",\n \"Brenham\",\n \"Conroe\",\n \"Meadows Place\",\n \"League City\",\n \"Pearland\",\n \"College Station\",\n \"Sugarland\",\n \"Bee Cave\",\n \"Round Rock\",\n \"Beecave\",\n \"San Marcos\",\n \"San Antonio\"].include? corrected_name\n hash[:city] = corrected_name\n else\n return false\n end\n true\n end", "def get_townhall_city(html)\n city =[]\n html.search(\"p/a\").each do |element|\n city << element.text.downcase.tr(\" \", \"-\")\n end\n return city\n end", "def team_names\n game_hash.collect do |location, team_data|\n team_data[:team_name]\n end\nend", "def metadata_cities(structure)\n place = []\n courses = structure.courses\n\n place << 'A domicile' if courses.where(type: 'Course::Private').any?\n if (public_courses = courses.where.not(type: 'Course::Private')).any?\n place += public_courses.flat_map(&:places).flat_map(&:city).uniq.map(&:name).sort\n end\n\n place.first(3).to_sentence\n end", "def afficeur\n @city_link.map do |element|\n villes = get_city_names(element)\n email = get_townhall_email(element)\n @result = []\n @result << {villes => email}\n end\n end", "def get_characters\n character_hash = look_up('http://www.swapi.co/api/people/')\n character_hash[\"results\"].collect do |element|\n element[\"name\"]\n end\nend", "def list_of_continents\n\n hash_continents = {}\n @query.get_graph.each_key do |city|\n continent = get_city_info(city, \"continent\")\n if not hash_continents.has_key?(continent)\n hash_continents[continent] = []\n end\n hash_continents[continent] << get_city_info(city,\"name\")\n end\n\n return hash_continents\n\n end", "def locations_hash\n [ \n {:city=>'Jos', :city_id => 2, :description=>'Evangel', :id=>1},\n {:city=>'Jos', :city_id => 2, :description=>'JETS', :id=>3},\n {:city=>'Jos', :city_id => 2, :description=>'ECWA', :id=>2},\n {:city=>'Miango', :city_id => 4, :description=>'MRH', :id=>4},\n {:city=>'Miango', :city_id => 2, :description=>'KA', :id=>5},\n {:city=>'Miango', :city_id => 2, :description=>'Miango Dental Clinic', :id=>6},\n {:city=>'Kano', :city_id => 3, :description=>'Tofa Bible School', :id=>7},\n {:city=>'Kano', :city_id => 3, :description=>'Kano Eye Hospital', :id=>8},\n {:city=>'Abuja', :city_id => 5, :description=>'Abuja Guest House', :id=>9}\n ]\n end", "def city_name_search(city)\r\n\t\tcity_name = city\r\n\t\tunless city_name.nil?\r\n\t\t\tcity_name = \"San%20Jose\"\r\n\t\tend\r\n\t\t#replace white spaces.\r\n\t\tcity_name.gsub(\" \", \"%20\")\r\n\t\tapi_key = \"vr7UJMGlyK75TAnqbjZzLff4RzhNHEG2\" #Thao's key. Move this later to env section.\r\n\t\trsc_url = \"https://api.sandbox.amadeus.com/v1.2/points-of-interest/\"\r\n\t\trsc_url_api = \"yapq-search-text?apikey=#{api_key}\"\r\n\t\trsc_url_city = \"&city_name=#{city_name}\"\r\n\t\t#/v1.2/points-of-interest/yapq-search-text?apikey=vr7UJMGlyK75TAnqbjZzLff4RzhNHEG2&city_name=Boston\r\n\t\tget_url = \"#{rsc_url}#{rsc_url_api}#{rsc_url_city}\"\r\n\t\tresponse = Faraday.get get_url\r\n\tend", "def show_cities(phonebook)\n phonebook.each {|k,v| puts k}\nend", "def get_countries\n countries=[]\n @locations.each do |loc|\n countries << loc.country.capitalize if loc.country\n end\n countries.uniq\n end", "def city\n fetch('dune.cities')\n end", "def find_city_and_state(zip)\r\n \r\n puts 'finding ' + zip.to_s\r\n \r\n # stores result\r\n result = nil\r\n \r\n # need to pad zeros in front of the zip \r\n padded_zip = sprintf '%05d', (zip)\r\n \r\n # load the user agent.\r\n a = Mechanize.new { |agent|\r\n agent.user_agent = @user_agent\r\n }\r\n \r\n # convert url to the zip\r\n actual_url = self.replace_zip_in_url(padded_zip)\r\n \r\n # go to page and fetch the string.\r\n a.get(actual_url) do |p|\r\n \r\n # check if the sorry zip code does not exist. node exist.\r\n error_nodes = p.search('//div[@class=\"noresults-container\"]').length\r\n \r\n # need to check if the zip is valid.\r\n if error_nodes == 0\r\n # you basically want the first result.\r\n # so break after you grab it.\r\n p.search('//div[@id=\"result-cities\"]/p[@class=\"std-address\"]').each do |addr|\r\n city_state_str = self.city_state_as_hash(padded_zip, addr.text)\r\n #puts city_state_str.inspect\r\n result = city_state_str\r\n break\r\n end\r\n else\r\n puts 'not a valid zip'\r\n end\r\n end\r\n \r\n # return results.\r\n # either a nil or a hash containig zip, city, state\r\n result\r\n end", "def getAllCities\r\n result = []\r\n @vertex.each_value do |city|\r\n result << city.name\r\n end\r\n return result\r\n end", "def area_code(hash, city_name)\n area_code = hash[city_name]\n display_info(city_name, area_code)\nend", "def city\n fetch('world_cup.cities')\n end", "def find_state_for_city(cityName)\n @cities.each do |x, y|\n \ty.each do |z|\n\t\t\tif z == cityName\n\t\t\t\tputs \"That #{cityName} is part of a state called #{x}\"\n\t \tend\n\t end\n\tend\nend", "def give_me_capital_cities(countries_hash)\n capitals=Array.new #note: could have done captials = []\n \n countries_hash.each {|key, value|\n capitals << countries_hash[key][:capital]\n }\n\n return capitals\n\nend", "def all_unique_city_values\n sparql = \"\n SELECT DISTINCT ?city\n WHERE \n {\n GRAPH <http://data.artsapi.com/graph/organisations> {\n ?org <http://data.artsapi.com/def/arts/locationCity> ?city .\n }\n }\"\n\n results = User.current_user.within { Tripod::SparqlClient::Query.select(sparql) }\n\n results.map { |r| r[\"city\"][\"value\"] }\n end", "def slug_candidates\n [\n [:title],\n [:title, :address],\n [:title, :address, self.city.name]\n ]\n end", "def get_city_hash(init_city, edge)\n i = edge.index(init_city)\n if i == 1\n return edge[0]\n elsif i == 0\n return edge[1]\n end\n end", "def city_state_name\n [city, state_abbr_name].join(', ')\n end", "def city_state_name\n [city, state_abbr_name].join(', ')\n end", "def show_cities(dial_book) \n dial_book.each{|k, v| puts k.capitalize }\nend", "def perform\n urls = get_townhall_urls(\"https://annuaire-des-mairies.com/val-d-oise.html\")\n puts array = get_townhall_email_city_name(urls)\n #puts getHash(name_array, mail_array)\n end", "def cities \n galleries.map{|g| g.city}.uniq\n end", "def city\r\n\t\t\t@city ||= json[\"cit\"].to_s.capitalize\r\n\t\tend", "def districts_helper(city)\n districts =\n {\n \"基隆市\" => [\n ['仁愛區'],\n ['信義區'],\n ['中正區'],\n ['中山區'],\n ['安樂區'],\n ['暖暖區'],\n ['七堵區']\n ],\n \"台北市\" => [\n ['中正區'],\n ['大同區'],\n ['中山區'],\n ['松山區'],\n ['大安區'],\n ['萬華區'],\n ['信義區'],\n ['士林區'],\n ['北投區'],\n ['內湖區'],\n ['南港區'],\n ['文山區'],\n ]\n }\n districts[\"#{city}\"]\n end", "def city_prefix; end", "def cities(hash)\nhash.each {|k, v| puts k }\nputs \"what city would you like to lookup?\"\nloop do \n city_name = gets.chomp\n if hash[city_name] == nil\n puts \"invalid city name, please try again\"\n else\n area_code(hash, city_name)\n break \n end\nend\nend", "def slug_candidates\n [\n :name,\n [:name, :city],\n [:name, :street_address, :city],\n ]\n end", "def cities\n galleries.map {|g| g.city}\n end", "def name_and_email_val_doise\n\tresult = []\n\tlist_url = urls_of_val_doise_townhalls # city pages urls\n\tlist_url.each { |town_url| name, mail = emails_from_webpage(town_url); result.push({:name => name.to_s, :email => mail}) } # name & email from each city\n\tputs result; # un tableau avec le nom et le mail des mairies\nend", "def cities\n galleries.map do |gallery|\n gallery.city\n end\n #undefined method `city' for \"New York\":String\n end", "def area_code_search(city)\n if $dictionary.has_key?(city) == false\n puts \"You have entered an invalid city.\"\n else\n area_code = $dictionary.values_at(city)\n puts \"The area code for #{city} is #{area_code.join}!\"\n end\n end", "def full_descriptor\n city_country_tz = \"<img src='/images/flags/#{self.country.country_code.downcase}.png' /> #{self.utf8_name}\" # we will search on the ascii name but display the UTF8 one\n \n # if city has a region mapped in the db, print it out\n city_country_tz += \", #{self.region.name}\" if (self.region)\n \n # If the city has a country mapped in the db, print it out\n city_country_tz += \", #{self.country.name}\" if (self.country)\n \n # If the city has a time zone mapped in the db, print it out\n city_country_tz += \" (#{self.time_zone.name})\" if (self.time_zone) \n \n # this is a bad hack to make sure the seperator value is include\n # need to figure out how auto-complete can append this once a selection is selected\n #city_country_tz += \"; \"\n \n # Return the array\n city_country_tz\n end", "def cities\n galleries.map do |c|\n c.city\n end\n end", "def get_area_code(hashbook, city)\n hashbook[city]\nend", "def display_city_names(dial_book)\n puts \"Available options:\"\n dial_book.each{|k, v| puts k}\nend", "def city_state_name\n [city.to_s.titleize, state_abbr_name].compact.join(', ')\n end", "def city_state_name\n [city.to_s.titleize, state_abbr_name].compact.join(', ')\n end", "def team_names\n names = []\n game_hash.each do |location, data|\n names << data[:team_name]\n end\n names\nend", "def team_names\n game_hash.collect do |location, attributes|\n attributes[:team_name]\n end\nend", "def slug_candidates\n [\n :name,\n [:name, :city],\n [:name, :address, :city],\n ]\n end", "def city_name\n @city = City.find(city_id)\n @city[:name]\n end", "def house_names(list)\n houses = list.map do |c|\n c[:house]\n end\n return houses.uniq\nend", "def team_names\n names = []\n game_hash.each do |location, team_hash|\n names << team_hash.fetch_values(:team_name)\n end\n \n names.flatten # flatten is necessary because fetch was putting two arrays inside names\n\nend", "def team_names \n # team_array = []\n # game_hash.each do |location, team_data|\n # team_array << team_data[:team_name]\n # end\n # team_array\n game_hash.collect do |location, team_data|\n team_data[:team_name]\n end\nend", "def print_city_list\n\n # simply call the print_vertices function of the graph API\n @query.get_graph.each_key { |city| puts \"#{get_city_info(city,\"name\")}\"}\n\n end" ]
[ "0.8179079", "0.7861688", "0.7727905", "0.76723766", "0.7663262", "0.7639538", "0.75658274", "0.7516943", "0.7432483", "0.7432483", "0.74241716", "0.7383513", "0.73674905", "0.73635846", "0.7300421", "0.72706527", "0.723864", "0.7204035", "0.7172686", "0.71348774", "0.7053699", "0.703148", "0.7015225", "0.6960569", "0.69410354", "0.68917876", "0.68016607", "0.67275566", "0.6482891", "0.6458237", "0.6448241", "0.6394779", "0.6391914", "0.63856864", "0.63591146", "0.63339776", "0.6319588", "0.61898094", "0.61060745", "0.60528445", "0.60267985", "0.6021048", "0.59886783", "0.5973624", "0.5973218", "0.5937874", "0.5927115", "0.59256536", "0.5902426", "0.58981824", "0.589798", "0.58751833", "0.58731765", "0.5851802", "0.584686", "0.5822894", "0.58098215", "0.5795276", "0.5791642", "0.57874393", "0.5783171", "0.57794344", "0.5775424", "0.57689273", "0.5763914", "0.5745412", "0.57442504", "0.57381403", "0.5730508", "0.5716424", "0.57134426", "0.5705916", "0.5689736", "0.5689736", "0.5683862", "0.5662067", "0.56589144", "0.56564856", "0.56547326", "0.56504846", "0.56456286", "0.5644259", "0.56380403", "0.56351495", "0.5633606", "0.5631631", "0.56311834", "0.5629988", "0.5620918", "0.56092364", "0.5602706", "0.5602706", "0.56003916", "0.557961", "0.557707", "0.556393", "0.5556502", "0.55509746", "0.55471", "0.5534712" ]
0.82532233
0
Get area code based on given hash and key
def get_area_code(hash, key) hash[key] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_area_code(hash, k)\n\thash[key]\nend", "def get_area_code(somehash, key)\n somehash[key]\n end", "def get_area_code(hash, key)\n hash[key]\nend", "def get_area_code(somehash, key)\n# Write code here\nsomehash[key]\nend", "def get_area_code(some_hash, key)\n some_hash[key]\nend", "def get_area_code(somehash, key)\n somehash[key]\nend", "def get_area_code(somehash, key)\n somehash[key]\nend", "def get_area_code(somehash, key)\n#\nend", "def get_area_codes (somehash, key)\n somehash [key]\n end", "def get_area_code(somehash, key)\n\tputs \"The area code for #{key} is #{somehash[key]}\"\nend", "def get_area_code(somehash, key)\n somehash[key]\n# Write code here\nend", "def get_area_code(somehash, key)\n somehash[\"#{key}\"]\nend", "def get_area_code(somehash, key)\n puts somehash[key]\n\nend", "def get_area_code(somehash, key)\n=begin\n somehash.each do |each_dial|\n if each_dial[0] == key\n each_dial[1]\n end\n end\n=end\n somehash[key]\nend", "def get_area_code(somehash, key)\nputs \"The area code for #{key} is #{somehash[key].to_i}\"\nend", "def get_area_code(dial_book, key)\n\t\treturn dial_book[key]\n\t\tend", "def get_area_code(input, key)\n input[key]\nend", "def get_area_code(somehash, key)\n if somehash.key?(key)\n return \"The are code for #{key} is #{somehash[key]}\"\n end \n \"We don't have any information on #{key}\"\nend", "def get_area_code(phone_book, key)\n phone_book[key]\nend", "def area_code(hash, city_name)\n area_code = hash[city_name]\n display_info(city_name, area_code)\nend", "def get_area_code(hashbook, city)\n hashbook[city]\nend", "def get_area_code(city_zip_hash, key)\n# Write code here\n if city_zip_hash[key]\n print \"The zip code is: \"\n puts city_zip_hash[key]\n zip = city_zip_hash[key]\n return zip\n else\n puts \"cannot find the city name, sorry\"\n end\nend", "def get_area_code(somehash, key)\n # Check that the hash has a mapping to the specified key\n if somehash.include? key\n # Return the string we want to show the user of the city to area code map\n return \"The area code for #{key} is #{somehash[key]}\"\n else\n # Return the below statement if the hash does not contain the key\n return \"That city does not exist.\"\n end\nend", "def get_area_code(somehash, key)\n if somehash.include?(key) \n puts \"The area code for #{key.capitalize} is #{somehash[key]}\"\n else \n puts \"You entered an invalid city name\"\n end\nend", "def get_area_code(dial_book, areacode)\n dial_book[areacode]\nend", "def get_area_code(somehash, key)\n if somehash[key] == nil\n puts \"City not found :(\"\n else\n puts \"The area code is #{somehash[key]}\" \n end\nend", "def get_area_code(somehash, key)\n if somehash[key]\n puts \"#area code: #{somehash[key]}\"\n return\n end\n\n puts 'City not found! Please try again.'\n false\nend", "def get_area_code(dial_book, city_name)\n # @type [String]\n area_code = ''\n\n # @type [String]\n normalized_city_name = normalize_city_name(city_name)\n\n dial_book.each_key do |city_name_dial|\n if normalize_city_name(city_name_dial) == normalized_city_name\n area_code = dial_book[city_name_dial]\n break\n end\n end\n\n area_code\nend", "def check_area_code(somehash, city)\n area_code = somehash[city]\n if area_code \n return \"The area code for #{city} is #{area_code}\"\n end\n \"Error: Bad city\"\nend", "def getArea(book, lookup)\n if book.key?(lookup)\n areacode = book[lookup]\n puts \"The area code for #{lookup} is #{areacode}.\"\n else\n puts \"#{lookup} not found in book, please try again or type view to see available cities.\"\n end\nend", "def hashcode(key)\n hashcode_with_internal_hashes(key).first\n end", "def get_code(dial_book, key)\n dial_book[key]\nend", "def get_areacode(dial_book, prompt)\n dial_book[prompt]\nend", "def getAreaCode(city_name, dial_book)\n \n areaCode = dial_book.select { |k, v| k == city_name }\n \n areaCode.select { |k, v| return v} # Return just the area code\n \nend", "def hash_for_location(offense); end", "def get_hash(key)\n (Zlib.crc32(key).abs % 100).to_s(36)\n end", "def hash\n code.hash\n end", "def area_code\n number[0..2]\n end", "def verification_code\n raise ArgumentError, 'Hash is not set' if @hash.nil?\n\n binary = @hash.unpack1('B*').split //\n [*binary.first(6), *binary.last(7)].join.to_i(2)\n end", "def area\n info[:area].to_sym\n end", "def code_to_key\n @code[0..2]\n end", "def hash\n code.hash\n end", "def country_code\n decode hash[\"CountryCode\"]\n end", "def get_city_names(somehash)\n puts \"What city do you want the area code for?\"\n somehash.each { |k, v| puts k.capitalize } # somehash.keys could be used\n code = gets.chomp\n get_area_code(somehash, code.downcase)\nend", "def area_code\n fetch('phone_number.area_code')\n rescue I18n::MissingTranslationData\n nil\n end", "def area_code\n fetch('phone_number.area_code')\n rescue I18n::MissingTranslationData\n nil\n end", "def hash(key); end", "def read_hash(lh)\n # lh => location hash\n # lh = decodeURI(location.hash);\n p = false\n hi = false\n h = []\n s = {}\n\n # Version 2 of Emphasis (I am ignoring v1 here because I have not used it on the client side anyways)\n # #h[tbsaoa,Sstaoo,2,4],p[FWaadw] -> p = \"FWaadw\", h = [ \"tbsaoa\", \"Sstaoo\" ], s = { \"Sstaoo\" : [ 2, 4 ] }\n\n # findp = lh.match(/p\\[([^[\\]]*)\\]/)\n # findh = lh.match(/h\\[([^[\\]]*)\\]/)\n # p = (findp && findp.length>0) ? findp[1] : false;\n # hi = (findh && findh.length>0) ? findh[1] : false;\n\n # SEB: strange. it looks like that there was an error in the javascript regexp here but it still works in js!!!\n if lh =~ /p\\[([^\\]]*)\\]/\n p = $1\n end\n if lh =~ /h\\[([^\\]]*)\\]/\n hi = $1\n end\n # puts p\n # puts hi\n\n # undef = nil\n # hi = nil\n\n highlightings = []\n\n if (hi)\n hi = hi.scan(/[a-zA-Z]+(?:,[0-9]+)*/)\n\n hi.each do |hi_element|\n a = hi_element.split(',');\n key = a[0];\n # pos = this.find_key(key)['index']\n\n highlightings.push(find_key(key))\n\n # puts key\n # paragraph_for_key = find_key(key)\n # puts paragraph_for_key['index']\n # puts paragraph_for_key['elm'].to_html\n\n # if (pos != false) {\n # h.push(parseInt(pos)+1);\n # var b = a;\n # b.shift();\n # if (b.length>0) {\n # for (var j=1; j<b.length; j++) {\n # b[j] = parseInt(b[j]);\n # }\n # }\n # s[h[h.length - 1]] = b;\n # }\n # break\n end\n end\n\n # @p = p;\n # @h = h;\n # @s = s;\n return highlightings\n end", "def area_code_search(city)\n if $dictionary.has_key?(city) == false\n puts \"You have entered an invalid city.\"\n else\n area_code = $dictionary.values_at(city)\n puts \"The area code for #{city} is #{area_code.join}!\"\n end\n end", "def select_branch(hash)\n #if RIPPLE_VERIFY_NODEOBJECT_KEYS\n raise if depth >= 64\n raise if (hash.to_bn & mask.to_bn) != key.to_bn\n #end\n\n # Extract hash byte at local node depth\n br = hash[depth / 2].ord\n\n # Reduce to relevant nibble\n if (depth & 1) == 1\n br &= 0xf\n else\n br >>= 4\n end\n\n raise unless (br >= 0) && (br < 16)\n br\n end", "def hashcode_with_internal_hashes(key)\n h, full_hs = phf_with_hashes(key)\n if @g[h] == @r\n return NON_KEY, full_hs # no key\n end\n a, b = h.divmod(RANK_SUPERBLOCKSIZE)\n if a == 0\n result = 0\n else\n result = @rs[a-1]\n end\n b, c = b.divmod(RANK_BLOCKSIZE)\n if b != 0\n result += @rb[a*(RANK_SUPERBLOCKSIZE/RANK_BLOCKSIZE-1)+b-1]\n end\n (h-c).upto(h-1) {|i|\n result += 1 if @g[i] != @r\n }\n return result, full_hs\n end", "def load_area_code(sections)\n return if sections.empty? || sections.first.length != 3\n\n raise \"invalid area code\" unless sections.second&.length == 3\n\n sections.shift\n end", "def get_lh_hash(key)\n res = 0\n key.upcase.bytes do |byte|\n res *= 37\n res += byte.ord\n end\n return res % 0x100000000\n end", "def currency_code\n hash[\"CurrencyCode\"]\n end", "def identify(path, key) = Zlib.crc32(\"#{path.keyname}/#{key}\") % MAX_ID", "def hash\n address.hash\n end", "def identify_hash(hash)\n hash = hash.to_s.strip\n case\n # operating systems\n when hash.start_with?('$1$') && hash.length == 34\n return 'md5'\n when hash.start_with?('$2$') && hash.length == 59,\n hash.start_with?('$2a$') && hash.length == 60,\n hash.start_with?('$2b$') && hash.length == 60,\n hash.start_with?('$2x$') && hash.length == 60,\n hash.start_with?('$2y$') && hash.length == 60\n return 'bf' #bcrypt\n when hash.start_with?('$5$') && hash.split('$').last.length == 43\n # we dont check full length since it may have 'rounds=' in the [1] area or not with an arbitrary length number\n return 'sha256,crypt'\n when hash.start_with?('$6$') && hash.split('$').last.length == 86\n # we dont check full length since it may have 'rounds=' in the [1] area or not with an arbitrary length number\n return 'sha512,crypt'\n when hash.start_with?('@S@') && hash.length == 148\n return 'qnx,sha512'\n when hash.start_with?('@s@') && hash.length == 84\n return 'qnx,sha256'\n when hash.start_with?('@m@') && hash.length == 52\n return 'qnx,md5'\n when hash.start_with?('_') && hash.length == 20\n return 'des,bsdi,crypt'\n when hash =~ /^[\\.\\/\\dA-Za-z]{13}$/ # hash.length == 13\n return 'des,crypt'\n when hash =~ /^\\$dynamic_82\\$[\\da-f]{128}\\$HEX\\$[\\da-f]{32}$/ # jtr vmware ldap https://github.com/rapid7/metasploit-framework/pull/13865#issuecomment-660718108\n return 'dynamic_82'\n when hash.start_with?(/{SSHA}/i)\n return 'ssha'\n when hash.start_with?(/{SHA512}/i)\n return 'raw-sha512'\n when hash.start_with?(/{SHA}/i)\n return 'raw-sha1'\n when hash.start_with?(/{MD5}/i)\n return 'raw-md5'\n when hash.start_with?(/{SMD5}/i)\n return 'smd5'\n when hash.start_with?(/{SSHA256}/i)\n return 'ssha256'\n when hash.start_with?(/{SSHA512}/i)\n return 'ssha512'\n # windows\n when hash.length == 65 && hash =~ /^[\\da-fA-F]{32}:[\\da-fA-F]{32}$/ && hash.split(':').first.upcase == 'AAD3B435B51404EEAAD3B435B51404EE'\n return 'nt'\n when hash.length == 65 && hash =~ /^[\\da-fA-F]{32}:[\\da-fA-F]{32}$/\n return 'lm'\n # OSX\n when hash.start_with?('$ml$') && hash.split('$').last.length == 256\n return 'pbkdf2-hmac-sha512,osx' # 10.8+\n when hash =~ /^[\\da-fA-F]{48}$/ # hash.length == 48\n return 'xsha,osx' # 10.4-10.6\n # databases\n when hash.start_with?('0x0100') && hash.length == 54\n return 'mssql05'\n when hash.start_with?('0x0100') && hash.length == 94\n return 'mssql'\n when hash.start_with?('0x0200') && hash.length == 142\n return 'mssql12'\n when hash =~ /^[\\da-f]{16}$/ # hash.length == 16\n return 'mysql' # mysql323 (pre 4.1)\n when hash.start_with?('*') && hash.length == 41\n return 'mysql-sha1' # mysql 4.1+\n when hash.start_with?('md5') && hash.length == 35\n return 'postgres'\n when hash =~ /^[\\da-fA-F]{16}$/\n return 'des,oracle' # pre 11g\n when hash =~ /^S:[\\dA-F]{60}$/\n return 'raw-sha1,oracle11'\n when hash =~ /^S:[\\dA-F]{60};H:[\\dA-F]{32};T:[\\dA-F]{160}$/\n return 'raw-sha1,oracle'\n when hash =~ /^H:[\\dA-F]{32};T:[\\dA-F]{160}$/\n return 'pbkdf2,oracle12c'\n # webapps\n when hash.start_with?('$P$') && hash.length == 34,\n hash.start_with?('$H$') && hash.length == 34\n return 'phpass' # wordpress, drupal, phpbb3 (H not P)\n when hash.start_with?('$ml$') && hash.length == 203\n return 'PBKDF2-HMAC-SHA512'\n when hash.start_with?('{PKCS5S2}') && hash.length == 73\n return 'PBKDF2-HMAC-SHA1'\n when hash.start_with?('$B$') && hash.split('$').last.length == 32\n return 'mediawiki'\n # mobile\n when hash =~/^[A-F0-9]{40}:[a-f0-9]{16}$/\n return 'android-sha1'\n when hash =~/^[A-F0-9]{32}:[a-f0-9]{16}$/\n return 'android-md5'\n # other\n when hash =~ /^<\\d+@.+?>#[\\w]{32}$/\n return 'hmac-md5'\n when hash.length == 114 && hash.start_with?('$M$')\n return 'F5-Secure-Vault'\n when hash =~ /^M\\$[[:print:]]+#[\\da-fA-F]{32}(?:(?::[[:print:]]*$)|$)/\n return 'mscash'\n when hash =~ /^\\$DCC2\\$\\d+#[[:print:]]+#[\\da-fA-F]{32}(?:(?::[[:print:]]*$)|$)/\n return 'mscash2'\n end\n ''\nend", "def get_area_code(cities, city_name)\n if !cities.key?(city_name)\n puts \"\\nInvalid city. Please try again.\"\n else\n puts \"\\n#{city_name} is #{cities[city_name]}\"\n end\nend", "def adventure_land(adventure_hash)\n adventure_hash[:land]\nend", "def geohash(key, member); end", "def area(hash)\n raise 'Hash must contain a name, coordinates, and actions pair.' unless hash.has_keys?(:name, :coordinates, :actions)\n name = hash[:name]; coordinates = hash[:coordinates]; actions = hash[:actions]\n\n AREAS << Area.new(name, coordinates, actions.is_a?(Symbol) ? [actions] : actions)\nend", "def display_area_code(my_dial_book, city_name)\n area_code = my_dial_book[city_name]\n puts \"The Area code of #{city_name} is #{area_code}\"\nend", "def hash\n [is_bot, is_tor_node, is_threat, is_eu, location, currency_code, currency_name, region_area, subregion_area].hash\n end", "def result(hash, key)\n hash[key]\nend", "def state_code\n decode hash[\"StateCode\"]\n end", "def hash_code; end", "def lookup(key)\n if key_pair = pair(key, hash(key))\n key_pair[1]\n end\n end", "def decode_center(geohash)\n res = decode(geohash)\n #get center of each set\n [((res[0][0] + res[1][0]) / 2), ((res[0][1] + res[1][1]) / 2)]\n end", "def parse_area_table(hash)\n @pref_by_city ||= {}\n @id_by_city ||= {}\n hash[\"rss\"][\"channel\"][\"source\"][\"pref\"].each do |pref|\n pref_name = canonical_pref(pref[\"title\"])\n\n cities = [pref[\"city\"]].flatten\n cities.each do |city|\n id = city[\"id\"].to_i\n title = city[\"title\"]\n @id_by_city[title] = id\n @pref_by_city[title] = pref_name\n end\n end\n rescue\n raise ParseError, \"Failed to parse area data from API\"\n end", "def _hash_val(b_key, &block)\n return ((b_key[block.call(3)] << 24) | \n (b_key[block.call(2)] << 16) | \n (b_key[block.call(1)] << 8) | \n (b_key[block.call(0)])) \n end", "def area(index)\n i = get_field_index_by_external_id(index,@fields[:area])\n fields(index, i)['item_id'].to_i unless i.nil?\n end", "def get_area_code(phone)\n country_code,number = strip_country_code(phone)\n if country_code == @@_default_country_code && number.length == 10\n number[0..2]\n else\n nil\n end\n end", "def key_for(data)\n data.hash\n end", "def split_hash(h)\n _, v, c, mash = h.split('$')\n return v.to_str, c.to_i, h[0, 29].to_str, mash[-31, 31].to_str\n end", "def hash_code(str)\n str.each_char.reduce(0) do |result, char|\n [((result << 5) - result) + char.ord].pack('L').unpack('l').first\n end\n end", "def id_from_hash(h)\n return nil if h.blank?\n # new format\n return h.to_i if h =~ /^[0-9]*$/\n # old format\n (uid, *code) = Base64.decode64(h).split(DIVIDER)\n code = code.join(DIVIDER)\n code == encode(uid) ? uid.to_i : nil\n end", "def c_hash\n sha256 = Digest::SHA256.new\n token = @code.token.token\n hashed_token = sha256.digest(token)\n first_half = hashed_token[0...hashed_token.length / 2]\n Base64.urlsafe_encode64(first_half).tr('=', '')\n end", "def get_key_address(ret, key)\n\ta=ret[key]\n\n\tputs \"Matching addr #{a}\"\n\n\tm=a.match(RE_RANGE)\n\tif m.nil?\n\t\tm=a.match(RE_CIDR)\n\t\tif m.nil?\n\t\t\tm=a.match(RE_ADDR)\n\t\t\tif m.nil?\n\t\t\t\tret[:unknown] = \"Unknown address format [#{a}]\"\n\t\t\telse\n\t\t\t\tret=match2addr(m, ret)\n\t\t\tend\n\t\telse\n\t\t\tret=match2cidr(m, ret)\n\t\tend\n\telse\n\t\tret=match2range(m, ret)\n\tend\n\n\tret\nend", "def extract_code!\n data = @data\n data.gsub!(/^``` ?([^\\r\\n]+)?\\r?\\n(.+?)\\r?\\n```\\r?$/m) do\n id = Digest::SHA1.hexdigest($2)\n cached = check_cache(:code, id)\n @codemap[id] = cached ?\n { :output => cached } :\n { :lang => $1, :code => $2 }\n id\n end\n data\n end", "def test_calc_hash\r\n\t\ts = \"SYSTEM>Gaozu(100)\"\r\n\t\ttb = Block.new(\"0\", \"0\", s, \"1518893687.329767000\", \"fd19\")\r\n\t\tstringVal = tb.get_calculated_hash\r\n\t\tval = stringVal.strip.eql? \"fd18\"\r\n\t\t\r\n\t\tassert_equal val, true\r\n\tend", "def display_area_code(dial_book, userChoice)\n if dial_book.include?(userChoice.downcase)\n puts \"#{userChoice} area code is #{dial_book[userChoice.downcase]}\"\n else\n puts \"#{userChoice} is not found in our dial book\"\n end\nend", "def read_key; end", "def split_hash(h)\n b, v, c, mash = h.split('$')\n return v, c.to_i, h[0, 29].to_str, mash[-31, 31].to_str\n end", "def hipaa_code(crosswalk_record = nil, hipaa_code_from_entity = nil)\n rcc_log.debug \"Obtaining HIPAA CODE.\"\n hipaa_code = hipaa_code_from_entity\n if hipaa_code.blank? && crosswalk_record.present?\n hipaa_code = crosswalk_record.hipaa_adjustment_code\n rcc_log.debug \"HIPAA CODE : #{hipaa_code}\"\n end\n hipaa_code.to_s.upcase\n end", "def address_book_id\n hash[\"AddressBookId\"]\n end", "def place_details place_key\n\tplace_node = @places_auth_file.xpath \"//t:place[@xml:id='#{place_key}']\", @ns\n\tdetails_hash = {}\n\tdetails_hash[:geo] = place_node.xpath(\"t:location/t:geo\", @ns).text()\n\tdetails_hash[:settlement] = place_node.xpath(\"t:placeName[1]/t:settlement\", @ns).text()\n\tdetails_hash[:settlement_type] = place_node.xpath(\"t:placeName[1]/t:settlement/@type\", @ns).text()\n\tdetails_hash[:country_key] = place_node.xpath(\"t:placeName[1]/t:country/@key\", @ns).text()\n\tdetails_hash[:country_name] = place_node.xpath(\"t:placeName[1]/t:country\", @ns).text()\n\tdetails_hash\nend", "def north_american_area_code_for(some_number)\n some_number = clean(some_number)\n\n itu_code = parse_code(some_number)\n\n return nil if itu_code.nil? || !north_american?(itu_code)\n\n code = itu_code\n\n north_american_codes.each { |_, v| code = some_number[0,4] if v.include?(some_number[0,4]) }\n\n return code\n end", "def valid_block_for_hash(hash)\n if !Toshi::Models::Block.main_or_side_branch.where(hsh: hash).first\n return nil\n end\n stored_block = Toshi::Models::RawBlock.where(hsh: hash).first\n if !stored_block\n return nil\n end\n Bitcoin::Protocol::Block.new(stored_block.payload)\n end", "def get_k( key )\n HTMapHelper.get_map( self, key )\n end", "def hash\n offset.hash\n end", "def get_hash_from_height(height)\n db.get(height_key(height))\n end", "def repository_code(marc)\n canonical_values = REPOS.keys\n sf = marc['040'].subfields.detect {|s| s.code == 'a' }\n return nil unless sf\n sf = sf.value.downcase\n return sf if canonical_values.include?(sf)\n # TODO identify variants used in the legacy script\n return 'nnc-a' if sf.eql?('nnc-av')\n if sf.eql?('zcu')\n # OCLC identifer for CUL, look in holdings sublocation\n return 'nnc-a' if marc['852'] && (marc['852']['b'].to_s.downcase == 'avr')\n end\n if marc['996']\n name = marc['996']['a']\n code, attrs = REPOS.detect {|code, attrs| attrs['name'] == name }\n return code\n end\n end", "def [](key)\n self.address_hash[key]\n end", "def hashify(key)\n array = key.split('')\n count = array.count\n index = array.inject(0) do |object,char|\n object += char.ord ** count\n count -= 1\n object\n end\n index % 89\n end", "def unhashTag(hash)\n \thash = (hash[1]+hash[4]+hash[0]+hash[3]+hash[2]).downcase\n \tnewnumber = 0\n \tfor i in (4).downto(0)\n \t\tnewnumber *= 20\n \t\tnewnumber += CODESTRING.index(hash[i])\n \tend\n \tif (newnumber <= MAX/4)\n \t\tnewnumber = (MAX/4 - newnumber)*4\n \telsif (newnumber <= MAX/2)\n \t\tnewnumber = (MAX/2 - newnumber) * 4 + 2\n \telsif (newnumber <= 3 * MAX / 4)\n \t\tnewnumber = (3*MAX/4 - newnumber) * 4 + 1\n \telse\n \t\tnewnumber = (MAX - newnumber) * 4 + 3\n \tend\n\n \treturn newnumber;\n end", "def hash_key(key)\n key.downcase\n end", "def _key(*args); args.hash; end", "def region_code(region_name)\n region_string = self.name.to_s + region_name.to_s\n deterministic_hash(region_string)\n end", "def find_area height, width\n\n\theight * width\nend", "def set_area_code\n @area_code = AreaCode.find(params[:id])\n end" ]
[ "0.83546644", "0.8275985", "0.81900907", "0.79980356", "0.7952049", "0.79248387", "0.79248387", "0.79227644", "0.7880038", "0.7821541", "0.77975863", "0.7790438", "0.7685832", "0.75850207", "0.7423085", "0.73710346", "0.735917", "0.7281254", "0.7193891", "0.7108609", "0.6992524", "0.67427576", "0.6671763", "0.65984607", "0.6597191", "0.6583526", "0.6569861", "0.6258371", "0.61620903", "0.60895324", "0.60503304", "0.60364413", "0.59912187", "0.58486766", "0.5833669", "0.5809304", "0.57736945", "0.57557", "0.5717269", "0.5662431", "0.5652795", "0.5622995", "0.5571678", "0.55116034", "0.55106", "0.55106", "0.54564804", "0.54502875", "0.54085106", "0.5394419", "0.53749585", "0.53468007", "0.5318889", "0.53170156", "0.5308659", "0.5277995", "0.527792", "0.5268816", "0.5263083", "0.5260844", "0.5258936", "0.5255506", "0.52159107", "0.5213164", "0.52057576", "0.51996315", "0.5194859", "0.5194428", "0.5193386", "0.5159408", "0.5158155", "0.515109", "0.5141128", "0.5129559", "0.511034", "0.5109476", "0.5086441", "0.5068849", "0.50606775", "0.5054925", "0.5038338", "0.5033244", "0.5032898", "0.50223017", "0.5018612", "0.5017498", "0.50161994", "0.50146866", "0.50138676", "0.50119567", "0.50018585", "0.5000864", "0.4991889", "0.49730772", "0.49599573", "0.49466112", "0.4945467", "0.4939782", "0.49388245", "0.4935007" ]
0.8265433
2
render a confirmation page unless the 'confirm' param is 'true' (which should only be set in the submit button on said confirmation page)
def destroy @user = User.find(params[:id]) case params['commit'] when 'cancel' redirect_back_or @user when 'confirm' logger.info "deleting #{@user}" logger.info params['reason_for_leaving'] # TODO @user.destroy flash.now.warning \ :user_destroyed, 'Bye bye', "You've successfully deleted your account. We're sorry to see you go!" redirect_to root_path and return else render 'confirm_delete' and return end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def confirm\n options.fetch(:confirm, nil)\n end", "def confirm\n\n end", "def require_confirmation\n if account_signed_in? and !current_account.confirmed?\n redirect_to waiting_pages_path\n end\n end", "def confirmation_form\n end", "def confirm\n end", "def confirm\n end", "def confirmation_required?; end", "def approval_confirm\n @minimal_ui = true\n \n case params[:decision]\n when 'approve'\n render :confirm_approve\n when 'disapprove'\n render :confirm_disapprove\n else\n raise\n end\n end", "def confirmation\n end", "def confirmation_required?\n false\n end", "def confirmation_required?\n false\n end", "def confirmation_required?\n false\n end", "def confirmation_required?\n false\n end", "def confirmation_required?\n false\n end", "def confirmation_required?\n false\n end", "def confirm\n # try to grab the confirmation code\n code = params[:id]\n if (! code)\n flash[:error] = \"No confirmation code provided!\"\n redirect_to :action => 'subscribe'\n return\n end\n begin\n @recipient = Subscription.subscribe_confirm( @project, code )\n rescue\n flash[:error] = $!\n redirect_to :action => 'subscribe'\n return\n end\n render :text => @project.templets.find_by_name('PAGE_CONFIRMED').render( @project ), :layout => true\n end", "def confirm msg\n document.get_default_view.confirm(msg)\n end", "def confirm!\n @@api.post(endpoint: self.endpoint + ['confirm'])\n end", "def confirmation_required?\n false\n end", "def confirmation_required?\n true\n end", "def confirm\n confirm_user(params[:confirmation_code])\n if @user and @user.confirmed?\n @current_user_session = FrontendUserSession.new\n render :template => 'frontend/users/confirmed'\n else\n render :template => 'frontend/users/confirm_now'\n end\n end", "def confirmation_required?\n return true\n end", "def confirm\n case request.request_method\n when \"POST\"\n @confirm = Confirm.new(params[:confirm])\n when \"PUT\"\n @confirm = Confirm.find(params[:id])\n @confirm.attributes = params[:confirm]\n end\n\n render :action => (@confirm.new_record? ? :new : :edit) unless @confirm.valid?\n end", "def confirm\n # can't confirma reservation in the past!\n render false && return unless @reservation.start_datetime > Time.current\n if @reservation.confirm && @reservation.save\n flash[:notice] = \"You are confirmed for #{@reservation.start_datetime_human}, with #{@reservation.user.name}.\"\n else\n flash[:alert] = 'Error'\n end\n respond_to do |format|\n format.html { redirect_to calendar_path(token: @visitor.token, reservation_id: @reservation.id) }\n format.js { render text: \"$('#reservationModal').modal('hide'); $('#calendar').fullCalendar( 'refetchEvents' );\" }\n end\n end", "def confirm\n @trip = Trip.find_by(confirmation_token: params[:id])\n if @trip\n if @trip.confirm!\n # do nothing, render confirm page\n else\n render :not_found # let's give no information on this error to the internet\n end\n else\n render :not_found # let's give no information on this error to the internet\n end\n end", "def confirm_destroy\n render :action => 'confirm_destroy'\n end", "def confirmation_required?\n super\n end", "def confirmation_required?\n super\n end", "def confirm\n @petition = @signature.petition\n # generate the update signature url\n @url = petition_signature_confirm_submit_path(@petition, @signature.unique_key)\n\n # check if we are in the unconfirmed table\n if @signature.class == NewSignature\n\n # check if we need to have extra information\n # and inform user about it\n if @signature.require_full_address? ||\n # @signature.require_person_birth_city? ||\n @signature.require_born_at? ||\n @signature.require_person_country?\n\n # create the information needed messages\n @action = t('confirm.form.action.confirm_and_save')\n @message = t('confirm.form.add_information_and_confirm')\n else\n # we don't need extra information so everything is fine\n @message = t('confirm.form.is_confirmed_add_information')\n end\n # always move new_signature to signature\n # since the user must be real\n confirm_signature\n else\n @message = t('confirm.form.update_information')\n @action = t('confirm.form.action.add_details')\n end\n # add some javascript data to allow for data checking\n add_check_fields\n end", "def confirmation_required?\n !confirmed?\n end", "def confirm!\n return false if purchased?\n confirmed!\n end", "def confirmation\n @message = Message.find(params[:smsg_refno], current_user)\n # Only handle a file upload if they can attach\n if can?(RS::AuthorisationHelper::CREATE_ATTACHMENT) &&\n handle_file_upload(parent_param: :dashboard_message, before_add: :add_document,\n before_delete: :delete_document)\n render(status: :unprocessable_entity)\n else\n return unless params[:finish]\n\n # clear cache\n clear_resource_items\n redirect_to dashboard_messages_path\n end\n end", "def proceed_to_confirm(params = {})\n self.status = 'confirming'\n if self.update(params)\n true\n else\n false\n end\n end", "def confirmation_required?\n !confirmed?\n end", "def confirmation\n # Read the confirmation data from the request\n @confirmation = TBK::Webpay::Confirmation.new({\n request_ip: request.ip,\n body: request.raw_post\n })\n\n # confirmation is invalid for some reason (wrong order_id or amount, double payment, etc...)\n if @confirmation.amount != 5000.0\n render text: @confirmation.reject\n return # reject and stop execution\n end\n\n if @confirmation.success?\n # EXITO!\n # perform everything you have to do here.\n self.last_confirmation = @confirmation\n end\n\n # Acknowledge payment\n render text: @confirmation.acknowledge\n end", "def skip_confirmation!; end", "def confirm_if_required(confirm, contents)\n string = ''\n if(confirm)\n string << \"if(confirm(#{format_type_to_js(confirm)})){\"\n string << contents\n string << \"}\"\n else\n string << contents\n end\n string\n end", "def confirmed?\n confirmation == 'yes'\n end", "def confirm_registration\n @user = User.find_by_confirmation_key(params[:id])\n @user or flash.now[:error] = 'Sorry, but there is no such confirmation required.'\n render :action => 'confirm_registration'\n end", "def confirm_destroy\n\t\t@tournament_admin = TournamentAdmin.find(params[:id])\n\t\trender 'tournament_admins/_confirm_destroy', layout: false\n\tend", "def confirm!\n welcome_message\n super\n end", "def confirm!\n welcome_message\n super\n end", "def show\n if params[:destroy]\n render :confirm_destroy and return\n end\n end", "def confirm_now\n confirm_user(params[:confirmation_code])\n unless request.xhr?\n if @user and @user.confirmed?\n unless logged_in?\n @current_user_session = FrontendUserSession.new\n render({:template => 'frontend/users/confirmed'})\n else\n flash[:info] = c_t(:success_message, {:domain_name => @host_name})\n redirect_to(frontend_user_account_url) \n end\n else\n render({:template => 'frontend/users/confirm_now'})\n end\n else\n render({:template => 'frontend/users/confirm_now.js.rjs'})\n end\n end", "def confirm # shortcut to add 'confirm:true' flag\n params[:flag_name] = 'confirm:true'\n flag\n end", "def is_confirmable?\n true\n end", "def confirmation\n flash[:danger]= \"<p class='m-b-md'>Are you sure you want to delete this event?</p> <a class='button is-danger is-block center-block' style='width: 50%;' data-method='delete' href='/events/#{@event.id}'> Yes</a>\"\n redirect_to my_events_path\n end", "def patch_confirm\n if current_user.character\n if current_user.character.confirmed\n flash[:error] = 'You have already confirmed your character.'\n redirect_to root_path\n return\n end\n else\n flash[:error] = 'You need to connect a character to your account before you can confirm it.'\n redirect_to root_path\n return\n end\n\n @character.confirm_character\n\n respond_to do |format|\n if @character.save\n flash[:success] = \"Successfully confirmed character!\"\n format.html { redirect_to @character.user }\n format.json { head :no_content }\n else\n format.html { render action: 'confirm' }\n format.json { render json: @character.errors, status: :unprocessable_entity }\n end\n end\n end", "def confirmed?\n confirmation == 'yes'\n end", "def confirm_admin\n redirect_to root_path unless current_user.admin?\n end", "def confirm_placement\n end", "def new_wizard_confirm\n init_variables_from_sessions\n\n if params[:back_button]\n redirect_to new_wizard_channel_settings_admin_room_type_channel_mappings_path\n else\n\n if @room_type_channel_mapping.valid? and (!@room_type_channel_mapping.is_configuration_master_rate? or @room_type_master_rate_channel_mapping.valid?)\n # do nothing\n @room_type_channel_mapping.disabled = true\n else\n if @room_type_channel_mapping.is_configuration_master_rate?\n put_model_errors_to_flash(@room_type_master_rate_channel_mapping.errors, 'redirect')\n else\n put_model_errors_to_flash(@room_type_channel_mapping.errors, 'redirect')\n end\n redirect_to new_wizard_rate_admin_room_type_channel_mappings_path\n end\n end\n end", "def send_confirmation\n reply 'confirmation'\n end", "def button_with_confirm(value = \"\", url = \"\", options = {}, html_options = {})\n options = {\n message: _t(:confirm_to_proceed),\n ok_label: _t(\"Yes\"),\n title: _t(:please_confirm),\n cancel_label: _t(\"No\")\n }.merge(options)\n form_tag url, {method: html_options.delete(:method)} do\n button_tag value, html_options.merge('data-alchemy-confirm' => options.to_json)\n end\n end", "def ensure_eligible_for_confirmation\n unless @offering.confirmations_allowed?\n flash[:error] = \"We're sorry, but the confirmation process is currently disabled.\"\n redirect_to apply_url(@offering) and return\n end\n unless @user_application.passed_status?(\"fully_accepted\") || @user_application.passed_status?(\"fully_accepted_vad\")\n flash[:error] = \"You cannot go through the confirmation process until your application has been fully accepted.\"\n redirect_to apply_url(@offering) and return\n end\n end", "def confirmed?; end", "def delete_confirmation\n requested_resource\n\n render :delete_confirmation,\n layout: 'admin/application',\n locals: {\n page: Administrate::Page::Form.new(dashboard, requested_resource)\n }\n end", "def new_wizard_confirm\n init_variables_from_sessions\n\n if params[:back_button]\n redirect_to new_wizard_conversion_property_channels_path\n else\n if @property_channel.valid?\n # do nothing\n else\n put_model_errors_to_flash(@property_channel.errors, 'redirect')\n redirect_to new_wizard_rate_multiplier_property_channels_path\n end\n end\n end", "def confirm\n #@asset_categorization = AssetCategorization.find(params[:id])\n if @asset_categorization.confirm!(current_user)\n AssetCategorizationMailer.confirmed_email(@asset_categorization.id).deliver\n respond_to do |format|\n format.html { redirect_to asset_categorizations_url, notice: I18n.t('controllers.confirm_success', name: @asset_categorization.class.model_name.human) }\n format.json { head :no_content }\n format.xml { head :no_content }\n end\n else\n respond_to do |format|\n format.html { redirect_to asset_categorizations_url, flash: { error: @asset_categorization.errors.messages.values.join } }\n format.json { head :no_content }\n format.xml { head :no_content }\n end\n end\n end", "def app_admin_confirm\n end", "def confirm_quit\n connection.puts \"Are you sure you want to quit?\"\n if yes_entered?\n connection.close\n\n else\n @world.render\n end\n end", "def confirm_admin\n \tunless session[:admin]\n \t\tflash[:notice] = \"You are not an admin.\"\n \t\tredirect_to(user_path( :id => session[:user_id]))\n \tend\n end", "def send_free_confirmation\n send_free_message(\"confirmation\")\n end", "def confirm(question)\n CLI::UI.confirm(question)\n end", "def confirmed?\n flash[:alert] = 'Check your email to confirm yourself.(You are not allowed to create posts)' unless current_user&.email_confirmed?\n end", "def confirmed\n render text: 'Confirmation success you can login on Mobile App'\n end", "def agree_to_be_civil_modal\n render :partial => 'agree_to_be_civil_modal', :layout => nil\n end", "def confirm\n @trip = Trip.find_by(confirmation_token: params[:token])\n if @trip\n if @trip.confirm!\n redirect_to @trip, notice: 'Votre annonce est publiée! Merci pour votre contribution à la communauté!'\n else\n render :not_found # let's give no information on this error to the internet\n end\n else\n render :not_found # let's give no information on this error to the internet\n end\n end", "def handleConfirm(page, message)\n @text = message\n return handleConfirmValue.nil? ? true : handleConfirmValue\n end", "def toggle_confirmation\n if user_params[:to_confirm] == 'true'\n @user.confirm\n elsif user_params[:to_confirm] == 'false'\n @user.confirmed_at = nil\n @user.save\n end\n head :ok\n end", "def confirm_abstract\n if !@user_application.status.offering_status.allow_abstract_confirmation?\n flash[:error] = \"Your abstract does not need confirmation, so you are not allowed to access that page.\"\n redirect_to :action => \"index\" and return\n end\n if request.post?\n if params[:pdf_button]\n redirect_to :action => \"abstract\", :format => :pdf and return\n else\n @user_application.set_status \"fully_accepted\"\n flash[:notice] = \"Thank you for confirming your abstract changes. You may now confirm your participation.\"\n redirect_to :action => \"index\" and return\n end\n end\n end", "def confirm\n puts \"#{@gre}[ok] #{@lastMsg}. #{@ncl}\"\n end", "def confirm_post_action?(controller, action)\n controller == \"users\" && action == \"send_confirmation_email\"\n end", "def confirmed?\n confirmation == 'Confirmed'\n end", "def js_confirm(status)\n page.evaluate_script 'window.original_confirm_function = window.confirm;'\n page.evaluate_script \"window.confirm = function(msg) { return #{status == 'accept'}; }\"\n yield\n page.evaluate_script 'window.confirm = window.original_confirm_function;'\nend", "def require_confirmation!(msg=\"\", &block)\n answer = ask(\"#{msg} [yn]\") do |q|\n q.echo = false\n q.character = true\n q.validate = /\\A[yn]\\Z/\n end\n exit(0) if answer.index('n')\n end", "def confirm?(text='')\n return self.run_cmd('confirm ' + text) == 0\n end", "def show_warning_if_not_confirmed!\n unless current_user.confirmed_at?\n flash.now['warning_persist'] = \"#{I18n.t('flash.warning.confirm_email.text')} <a href=\\\"#{resend_confirmation_email_dashboard_users_path}\\\">#{I18n.t('flash.warning.confirm_email.button')}</a>\".html_safe\n end\n end", "def update_confirm\n @post_form = PostForm.new(post_form_params)\n unless @post_form.valid?\n render :edit\n end\n end", "def confirmation\n @reservation = Reservation.find(params[:id])\n render action: \"show\"\n end", "def do_confirm\n if current_user.type == \"User\" || current_attendee.affiliate == current_user\n if registration = current_attendee.event_registrations.for_event(current_object).first\n registration.confirm!\n # log confirmation activity\n log_checkin_activity(\"Confirmed for '#{current_object.display_name}'\")\n \n @attendee_id = current_attendee.id\n @event_id = params[:id]\n end\n end\n\n render :text => \"Confirmed\"\n end", "def confirm!\n welcome_email\n super\n end", "def confirm\n \t\tuser = User.find_by_uid params[:uid]\n \t\tuser.confirm_email params[:confirmation_code]\n \t\tif not user.confirmed?\n \t\tflash[:error] = \"You're link doesn't match what we have on record.\"\n \t\tredirect_to signup_path\n \t\telse\n \t\tsession[:user] = user\n \t\tflash[:success] = \"We will update you at #{user.email} with new information as it because available\"\n \t\tredirect_to dashboard_path\n \t\tend \n \tend", "def show\n \t@user = User.find_by_confirmation_token_and_id(params[:confirmation_token], params[:id])\n \tif @user.user_state == \"confirmed\"\n flash[:notice] = \"\" + @user.first_name + \", your account is already confirmed.\"\n redirect_to(:action => 'already_confirmed')\n else\n render :layout => \"activate\"\n end\n end", "def send_confirmation_notification?\n false\n end", "def send_confirmation_notification?\n false\n end", "def show_wait_for_trip_confirmation_form?\n self.persisted? && !self.wtg_to_clear_pickup? && !self.wtg_for_driver_dispatch?\n end", "def confirm\n begin\n @result = Braintree::TransparentRedirect.confirm(request.query_string)\n if @result.success?\n current_user.update_user_with_plan_and_braintree_id(session[:user_plan], @result.customer.id)\n session[:user_plan]=nil\n flash[:success] = \"You have successfully converted to paid member. Now you can activate to offer by clicking on the Activate button\"\n redirect_to offers_path\n else\n flash[:error] = \"Your payment was not success. Check your card information.\"\n redirect_to offers_path\n end\n rescue\n flash[:error] = \"Your payment was not success. Check your card information.\"\n redirect_to offers_path\n end\n end", "def send_confirmation_notification?\n confirmation_required? && !@skip_confirmation_notification\n end", "def request_confirmation(options = Hash.new,&block)\n button1 = options[:button1] || \"Continue\"\n button2 = options[:button2] || \"Cancel\"\n title = options[:title] || \"Something Happened\"\n prompt = options[:prompt] || \"Should we continue or cancel?\"\n\n \tres = alert(:informational, title, prompt, button1, button2)\n\n if res == button1 then\n block_given? ? yield : true\n else\n block_given? ? raise(SystemExit) : false\n end\n end", "def confirm_submit\n @petition = @signature.petition\n\n if @petition && @signature.update(signature_params) && @signature.valid?\n # signature also passed validation\n @signature.confirmed = true\n\n respond_to do |format|\n format.json { render :show, status: :ok }\n format.html do\n redirect_to @petition,\n notice: t('confirmed.signaturesuccessfully', default: 'signature successfully confirmed')\n end\n end\n else\n # there are errors\n # render a normal edit view\n add_check_fields\n @error_fields = @signature.errors.keys\n @url = petition_signature_confirm_submit_path(@petition, @signature.unique_key)\n\n respond_to do |format|\n format.json { render json: @signature.errors, status: :unprocessable_entity }\n format.html { render 'confirm' }\n end\n end\n end", "def confirm_own_account_page\n #\t unless ((@user_id == session[:user_id])||(session[:admin]))\n # \t\tflash[:notice] = \"That URL is not for your account!\"\n #\t\t redirect_to(user_path( :id => session[:user_id]))\n #\t end\n end", "def send_confirmation\n send_message(\"confirmation\")\n end", "def confirm_destroy\n @listing = Listing.has_permission(current_user).find(params[:management_listing_id])\n @confirm_destroy = true\n respond_to do |format|\n format.html { render(layout: 'management') }\n end \n end", "def send_confirmation_instructions; end", "def apphelp_confirm\n heading = apphelp_heading( controller, :delete, '' )\n heading << \"\\n\\n\" unless ( heading.empty? )\n\n return heading + apphelp_generic( :confirmation )\n end", "def confirming?\n self.status == 'confirming'\n end", "def confirm\n #@sub_items = Spree::Order.get_receipt_items(current_user.id)\n order_ids = params[:confirmed_order_ids]\n if order_ids.present?\n @sub_items = Spree::Order.get_snack_queue_updated_orders(order_ids)\n @delivery_dates = Spree::Order.get_delivery_dates(order_ids)\n\n else\n redirect_to main_app.profile_users_path and return if @sub_items.blank?\n end\n\n #after confirmation if user wishes to reload page then it'll auto redirect user to profile section.\n end", "def before_confirm\n if [email protected]_photos_valid?\n if @order.line_items.count > 0\n flash.now[:error]=\"Please Review Your Order\"\n flash.now[:payment]='A photo in your order was deleted while you were checking out. )'+\\\n ' The item has been removed and your order re-calculated.)'+\\\n ' You can now place your order. '\n respond_with(@order) { |format| format.html { render :edit } } and return\n else\n flash[:error]=\"Please Select More Photos\"\n flash[:payment]='The photo in your order was deleted while you were checking out. )'+\\\n ' The line item has been removed and your cart is now empty'\n redirect_to cart_url\n end\n end\n end", "def confirmation_required?\n !confirmed? && !@skip_confirmation_notification\n end", "def send_confirmation_notification?\n false\n end" ]
[ "0.7100115", "0.7023031", "0.69155264", "0.68982965", "0.68524027", "0.68524027", "0.6768341", "0.6726914", "0.66671365", "0.6593077", "0.6593077", "0.6593077", "0.6593077", "0.6593077", "0.65924346", "0.65599346", "0.6547198", "0.65462995", "0.6536393", "0.65114444", "0.6506007", "0.6492455", "0.64840275", "0.645212", "0.64278084", "0.6417652", "0.6389846", "0.6389846", "0.63871473", "0.6383168", "0.6360878", "0.63587326", "0.63284373", "0.6295529", "0.62955046", "0.6285181", "0.62491065", "0.6247171", "0.6244069", "0.6219559", "0.62187266", "0.62187266", "0.6200847", "0.61583567", "0.613487", "0.6121226", "0.6113173", "0.61059475", "0.6099224", "0.60815024", "0.608044", "0.6073811", "0.60730505", "0.6064664", "0.60571736", "0.6038586", "0.60352653", "0.6029805", "0.6013599", "0.6010193", "0.60025877", "0.5992535", "0.5989736", "0.5989469", "0.59803903", "0.59772193", "0.59705174", "0.5964261", "0.5957701", "0.5939492", "0.593926", "0.59316856", "0.5912653", "0.591007", "0.59086335", "0.5903282", "0.58974576", "0.589698", "0.5895977", "0.58940256", "0.5893306", "0.5877353", "0.5857398", "0.5848954", "0.5840341", "0.5840341", "0.58369464", "0.5826705", "0.5825635", "0.58212197", "0.5813215", "0.5810636", "0.5806904", "0.58045334", "0.58007985", "0.57996404", "0.5790117", "0.57811075", "0.5779623", "0.5775659", "0.5760078" ]
0.0
-1
void cancel() Handle a 'Cancel' button press.
def cancel redirect_to( default_path ) if params[:commit] == 'cancel' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cancel\n end", "def cancel\n end", "def cancel; end", "def cancel; end", "def cancel!; end", "def cancel\r\n # @todo Emit a warning for attempts to cancel an action after it's been\r\n # executed\r\n @cancelled = true\r\n end", "def cancel_button_clicked\n\t\t\t@path = nil\n\t\t\tclose_and_cleanup\n\t\tend", "def cancel\n # Define this later\n end", "def cancel\n @error = :cancelled\n end", "def cancel\n throw(:abort)\n end", "def cancel\n @result = :cancel\n $game_system.se_play($data_system.cancel_se)\n end", "def cancel\n begin\n $results.log_action(\"button(#{@params[0]})\")\n # Cancel button can be either a link or an actual button object\n begin\n if @driver.find_element(:id, \"lnk-cancel\").displayed?\n @driver.find_element(:id, \"lnk-cancel\").click\n $results.success\n end\n rescue\n if @driver.find_element(:id, \"btn-cancel\").displayed?\n @driver.find_element(:id, \"btn-cancel\").click\n $results.success\n end\n end\n rescue => ex\n $results.fail(\"button(#{@params[0..-1].join(' ')})\", ex)\n end\n end", "def subject_cancel\n self.cancel_button.click\n end", "def cancel_cli\n generic_step(\"cancel\")\n end", "def cancel\n super\n end", "def cancel\n # TODO: That thing I'm claiming to do in the comments\n super\n end", "def cancel\n super\n end", "def cancel(*args)\n commit('cancel', *args)\n end", "def cancel\n super\n end", "def cancel\n super\n end", "def cancel\n super\n end", "def cancel\n super\n end", "def cancel\n super\n end", "def cancel\n super\n end", "def cancel\n super\n end", "def cancel\n super\n end", "def cancel\n super\n end", "def cancel\n super\n end", "def cancel\n super\n end", "def cancel\n super\n end", "def cancel\n super\n end", "def cancel\n super\n end", "def cancel\n super\n end", "def cancel\n super\n end", "def cancel\n super\n end", "def cancel\n @service.context.post(@control_path, :action => 'cancel')\n self\n end", "def cancel\n set_params\n show_translation\n end", "def cancel!\n state_guard { modify_call 'Status' => 'cancelled' }\n end", "def cancel\n self.class.cancel(self)\n end", "def cancel\n super\nend", "def cancel\n super\n end", "def cancel\n super\n end", "def cancel\n super\n end", "def cancel\n self.solved(:abort)\n end", "def call_cancel_handler; call_handler(:cancel); end", "def onCancel flag, view\n ## puts \"onCancel called\"\n\t\tself.reset(view)\n\tend", "def command_cancel\r\n # Play decision SE\r\n $game_system.se_play($data_system.decision_se)\r\n # Switch to menu screen\r\n $scene = Scene_Menu.new(5)\r\n end", "def cancelled?; end", "def process_cancel\n Sound.play_cancel\n Input.update\n deactivate if @symbol.nil?\n @symbol = nil\n call_cancel_handler\n end", "def onCancel(flag, view)\n self.reset(view)\n end", "def cancel\n @confirmation_header = \"confirm cancellation\"\n @confirmation_body = \"Are you Sure to cancel this subscription?\"\n @cancel = \"No, Thank you\"\n @submit = \"Confirm cancellation\"\n end", "def buttonCancel__clicked(*a)\n @builder[:window1].destroy\n end", "def cancelled!\n @cancelled = true\n end", "def cancel\n self.update_status :cancelled\n end", "def cancel_frame\n end", "def cancel(*)\n super.tap do\n __debug_sim('USER has decided to withdraw the submission.')\n end\n end", "def on_cancel &b\n @cancel_proc = b\n self\n end", "def cancel?\n self.type == :cancel\n end", "def onCancel(flag, view)\n self.reset(view)\nend", "def cancel_enabled?; handle?(:cancel); end", "def cancel element\n element.perform :cancel\n end", "def cancel\n redirect_to root_url, flash[:alert] = \"Something went wrong.\"\n end", "def cancel(id); end", "def cancel()\n require_relative 'message'\n Message.new(@api, @api.do_request(\"POST\", get_base_api_path() + \"/cancel\"))\n end", "def cancel()\n require_relative 'message'\n Message.new(@api, @api.do_request(\"POST\", get_base_api_path() + \"/cancel\"))\n end", "def cancel\n # renders static page\n end", "def cancel\n if @event.cancel\n render :json => @event.to_json, :status => :ok\n else\n render :nothing => true, :status => :unprocessable_entity\n end\n end", "def cancel\n flash[:notice] = \"Canceling accounts is not enabled.\"\n redirect_to root_path\n end", "def cancel!\n\t\t\t\t# The simplest way to keep track of cancelled status is to nullify the\n\t\t\t\t# callback. This should also be optimal for garbage collection.\n\t\t\t\t@callback = nil\n\t\t\tend", "def command_cancel\n Sound.play_decision\n return_scene\n end", "def cancel!\n update(request_cancelled: true)\n end", "def cancel\n flash[:notice] = \"We're sorry you didn't buy :(. Please tell Sven at <a href='mailto:[email protected]'>sven@paperboat</a> why you chose to cancel.\"\n redirect_to root_path\n end", "def cancel(params)\n request(Resources::RESOURCE_CANCEL, HTTP_METHOD_POST, params)\n end", "def onCancel(flag, view)\n self.reset(view)\n \tSketchup.undo\n end", "def cancel\n @stage.close\n end", "def cancel_form handle_form_text \n click_to_handle_form handle_form_text\n cancel_form_alert_ok \n end", "def cancel!\n # Context is already cleared in action_for_message\n end", "def cancel_and_redirect\r\n redirect_back\r\n end", "def cancel_button(destination_path)\n @template.link_to I18n.t('form.cancel'), destination_path,\n class: \"btn btn-default\"\n end", "def cancel\n self.dismissModalViewControllerAnimated true\n end", "def cancel\n self.break_condition = 1\n end", "def cancel!\n Bumbleworks.dashboard.cancel_expression(@fei)\n end", "def cancel\n return unless @running\n @running = false\n end", "def cancel\n # clear the Gtk::Entry\n @search_entry.set_text(\"\")\n\n # Colorize the Gtk::Entry\n state(CLEAR)\n\n # Refresh the modules treeview\n $gtk2driver.module_tree.refresh\n\n # Register the current state\n @@state = CLEAR\n end", "def __cancel__(what, &blk)\n req = Request.new\n req.verb = Request::Verb::CANCEL\n req.id = what.tag\n\n # Hold on to the tag as unavaiable for reuse until the cancel succeeds.\n @cbx[what.tag] = nil\n\n send(req) do |res|\n # Do not send any more responses from the server to this request.\n @cbx.delete(what.tag)\n blk.call(res) if blk\n end\n end", "def cancel!\n # The simplest way to keep track of cancelled status is to nullify the\n # callback. This should also be optimal for garbage collection.\n @callback = nil\n end", "def cancel()\n @callback = nil\n @cancelled = true\n end", "def cancel\n @procedure&.cancel\n @cancel = true\n self\n end", "def clicked\n @cancel.clicked\n end", "def cancel!\n @callback = nil\n end", "def cancel\n @order.cancel\n render_update @order\n end", "def cancel(params={})\n self.request(__method__, params)\n end", "def cancel?(id); end", "def cancel\n\n close_node\n\n do_wrap_cancel_children ||\n pop_on_receive_last ||\n wrap_cancelled\n end", "def cancel\n redirect_to checkid_request.cancel_url\n end", "def clicked\n # @cancel.clicked\n end", "def canceled?\n @state == :cancel\n end", "def cancel(path, edit_path = nil, options ={})\n options[:class] ||= ''\n options[:class] << \"btn btn-default\"\n options[:data] = { confirm: \"Cancel without saving?\"}\n\n if edit_path && object.persisted?\n path = edit_path\n end\n @template.link_to('Cancel', path, options)\n end", "def cancel\n raise CancelInterpolation.new\n end", "def on_btn_Cancel_clicked(widget)\n @db.close unless @db.nil?\n Gtk.main_quit\n end" ]
[ "0.83979553", "0.83979553", "0.79665047", "0.79665047", "0.78787744", "0.7859218", "0.78412783", "0.7671917", "0.76702726", "0.7656187", "0.76331735", "0.7604381", "0.76022077", "0.7563968", "0.7503058", "0.74916416", "0.7449462", "0.74391484", "0.7419796", "0.7419796", "0.7419796", "0.7419796", "0.7419796", "0.7419796", "0.7419796", "0.7419796", "0.7419796", "0.7419796", "0.7419796", "0.7419796", "0.7419796", "0.7419796", "0.7419796", "0.7419796", "0.7419796", "0.74033207", "0.7394658", "0.7376325", "0.7365409", "0.73337436", "0.7308245", "0.7308245", "0.7308245", "0.7268743", "0.7255994", "0.7238173", "0.72177887", "0.72001314", "0.719819", "0.71344507", "0.71303266", "0.71280324", "0.71083474", "0.7102131", "0.7074341", "0.7056613", "0.7048054", "0.7046835", "0.70266974", "0.7023702", "0.70139325", "0.69937974", "0.6979923", "0.6963996", "0.6963996", "0.6940042", "0.69011694", "0.68950576", "0.6874504", "0.6869701", "0.6862421", "0.685554", "0.6841937", "0.68411535", "0.68334955", "0.68280506", "0.6818948", "0.68151224", "0.6808957", "0.6805782", "0.6802996", "0.6802395", "0.6778889", "0.6776051", "0.6774728", "0.6760511", "0.67409015", "0.67191803", "0.66918755", "0.66906005", "0.6674508", "0.66210747", "0.6617984", "0.66150284", "0.6614465", "0.6611238", "0.65878177", "0.65850675", "0.6578532", "0.6567183" ]
0.73756367
38
value should enter at the root, then go down
def add(value) @root = add_at_node(@root, value) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def insert(value)\n puts \"Inserting :\" + value.to_s\n current_node = @root\n\n while nil != current_node\n\n if (value < current_node.value) && (current_node.left == nil)\n current_node.left = TreeNode.new(value,nil,nil)\n puts \"val is less\"\n\n elsif (value > current_node.value) && (current_node.right == nil)\n current_node.right = TreeNode.new(value,nil,nil)\n puts \"val is more\"\n\n elsif (value < current_node.value)\n current_node = current_node.left\n puts \"doing this not nil left\"\n\n elsif (value > current_node.value)\n current_node = current_node.right\n puts \"doing this not nil right\"\n\n else\n return\n end\n end\n end", "def explore_upwards(node)\n node = node.parent until node.parent.nil? || node.parent.left == node\n node.parent.nil? ? nil : node.parent.data\nend", "def insert(value)\n current_node = @root\n while nil != current_node\n if (value < current_node.value) && (current_node.left == nil)\n current_node.left = TreeNode.new(value,nil,nil)\n elsif (value > current_node.value) && (current_node.right == nil)\n current_node.right = TreeNode.new(value,nil,nil)\n elsif (value < current_node.value)\n current_node = current_node.left\n elsif (value > current_node.value)\n current_node = current_node.right\n else\n return\n end\n end\n end", "def root=(value) @root = value end", "def root=(value) @root = value end", "def insert(value)\n current_node = @root\n until current_node.nil?\n if current_node.data < value\n if current_node.right_child.nil?\n current_node.right_child = Node.new(value)\n break\n end\n current_node = current_node.right_child\n elsif current_node.data > value\n if current_node.left_child.nil?\n current_node.left_child = Node.new(value)\n break\n end\n current_node = current_node.left_child\n else\n puts 'Input error'\n break\n end\n end\n end", "def set_value(input, root)\n\t\treturn root = Node.new(input) if root == nil\n\n\t\tcase input <=> root.value\n\t\twhen -1\n\t\t\treturn root.small_child = Node.new(input, root) if root.small_child == nil\n\t\t\tset_value(input, root.small_child)\n\t\twhen 1\n\t\t\treturn root.big_child = Node.new(input, root) if root.big_child == nil\n\t\t\tset_value(input, root.big_child)\n\t\twhen 0\n\t\t\troot.count += 1\n\t\tend\n\tend", "def insert(value)\n puts \"Inserting: #{value.to_s}\"\n current_node = @root\n while nil != current_node\n if (value < current_node.value) && (current_node.left == nil)\n current_node.left = TreeNode.new(value, nil, nil)\n elsif (value > current_node.value) && (current_node.right == nil)\n current_node.right = TreeNode.new(value, nil, nil)\n elsif (value < current_node.value)\n current_node = current_node.left\n elsif (value > current_node.value)\n current_node = current_node.right\n else\n return\n end\n end\n end", "def explore_downwards(node)\n node = node.left until node.left.nil?\n node.data\nend", "def search(value)\n return 'not found' if @root.nil?\n return 'found' if @root.value == value\n\n if value < @root.value\n @root = root.left\n search(value)\n elsif value > @root.value\n @root = root.right\n search(value)\n end\n end", "def delete_value(value, root = self)\n if root.nil?\n return\n elsif value > root.value\n root.right = delete_value(value, root.right)\n elsif value < root.value\n root.left = delete_value(value, root.left)\n else # i.e. value == root.value\n if root.left.nil? # also catches cases when both child nodes are empty\n root = root.right\n elsif root.right.nil?\n root = root.left\n else\n root = shift_values(root)\n end\n end\n root\n end", "def insert(value)\n new_node = Node.new(value)\n\n return @root = new_node if is_empty\n\n current = @root\n parent = nil\n\n while current != nil\n parent = current\n current = value <= current.value ? current.left : current.right\n end\n\n value <= parent.value ? parent.left = new_node : parent.right = new_node\n end", "def insert(value)\n current = self\n while true\n if current.value > value\n if current.left.nil?\n current.left = BST.new(value)\n break\n else\n current = current.left\n end\n else\n if current.right.nil?\n current.right= BST.new(value)\n break\n else\n current = current.right\n end\n end\n end\n end", "def insertion(value)\n insertion_recursion(value, @root)\n end", "def node_available(value,cur_node)\n #if current node is at the bottom of the tree\n if value > cur_node.value && cur_node.right == nil\n node = BSTNode.new(value)\n node.parent = cur_node\n cur_node.right = node\n elsif value <= cur_node.value && cur_node.left == nil\n node = BSTNode.new(value)\n node.parent = cur_node\n cur_node.left = node\n elsif value > cur_node.value\n cur_node = cur_node.right\n else\n cur_node = cur_node.left\n end\n return cur_node\n end", "def delete_from(value)\n L.log '', \"Attempting to delete #{value} from BST\"\n outcome, new_root = @root_tree.delete_element(@root_tree, Node.new(value))\n @root_tree = new_root\n display_tree\n return outcome\n end", "def insert(value, tree)\n if tree[:root] == nil\n tree[:root] = value\n return\n end\n if tree[:root] >= value\n insert_left(value, tree)\n return\n end\n insert_right(value, tree)\nend", "def insert(value)\n @size += 1\n if empty?\n @root = TreeNode.new(value)\n return\n end\n\n # Attempt to bring the new value to the top of the tree.\n splay(value)\n # If value is @root, it must already be in the tree\n return if not empty? and @root.value == value\n\n # Otherwise, we need to insert a new root.\n new_root = TreeNode.new(value)\n if empty?\n # This value will be the new root if the tree is empty.\n @root = new_root\n elsif new_root.value > @root.value\n # If the element is larger than the old root, @root becomes the left child of the new root.\n new_root.left = @root\n new_root.right = @root.right\n @root.right = nil\n else\n # Alternatively, @root becomes new_root's left child.\n new_root.right = @root\n new_root.left = @root.left\n @root.left = nil\n end\n @root = new_root\n end", "def order_tree(value)\n\n (0..t.children().length-1).each do |i|\n\n if (t.children[i].value.to_s==\"\")\n\n (i..t.children().length).each do |j|\n if(j+1<t.children().length)\n aux=t.children[j+1].value.to_s\n t.children[j+1].value=t.children[j].value.to_s\n t.children[j].value=aux\n end\n end\n\n end\n puts t.children[i].value.to_s\n end\n end", "def insert(value)\n inserted = false\n\n if @root.nil?\n @root = BSTNode.new(value)\n inserted = true\n end\n\n current_node = @root\n\n until inserted\n # p current_node.value\n # p value\n\n if value <= current_node.value && current_node.left.nil?\n # p \"inserted left\"\n current_node.left = BSTNode.new(value)\n inserted = true\n elsif value <= current_node.value\n # p \"switching to left child\"\n current_node = current_node.left\n next\n elsif value > current_node.value && current_node.right.nil?\n # p \"inserted right\"\n current_node.right = BSTNode.new(value)\n inserted = true\n elsif value > current_node.value\n # p \"switching to right child\"\n current_node = current_node.right\n next\n end\n end\n\n end", "def delete(value)\n return \"BST is empty\" if is_empty\n\n parent = nil\n current = @root\n\n while current && current.value != value\n parent = current\n current = current.value > value ? current.left : current.right\n end\n\n return \"Value to delete not found\" if current == nil\n\n if !current.left && !current.right\n parent.left = nil\n parent.right = nil\n end\n\n puts \"NOT COMPLETE\"\n end", "def postOrder(root)\n return nil if root == nil\n\n postOrder(root.left)\n postOrder(root.right)\n print \" #{root.value}\"\nend", "def shift_values(root)\n root.value = get_next_value(root.right)\n root.right = right_subtree_without_next_value(root.right)\n root\n end", "def delete(value)\n node = find(value, @root)\n if node.left || node.right \n if node.left && node.right \n max = maximum(node.left)\n if max.left \n max.parent.right = max.left \n max.left = nil\n end\n node.left.parent = max \n node.right.parent = max\n if (node.value <= node.parent.value)\n node.parent.left = max\n else \n node.parent.right = max\n end \n else \n replacement_node = node.left ? node.left : node.right \n parent = node.parent\n if replacement_node.value <= parent.value \n parent.left = replacement_node\n else \n parent.right = replacement_node\n end \n end \n else \n if node.parent \n parent = node.parent \n if (node.value <= parent.value)\n parent.left = nil\n else \n parent.right = nil\n end\n else \n @root = nil \n nil\n end \n end \n end", "def inorder(root)\n inorder(root.left) if root.left\n puts root.value\n inorder(root.right) if root.right\nend", "def insert_into_tree(root, new_value, index)\n if root.val == new_value\n return root\n elsif new_value < root.val\n if root.left\n insert_into_tree(root.left, new_value, index)\n else\n root.left = TreeNode.new(new_value, index )\n end\n else\n if root.right\n insert_into_tree(root.right, new_value, index)\n else\n root.right = TreeNode.new(new_value, index)\n end\n end\nend", "def root(e)\n while e != id[e]\n id[e] = id[id[e]] # halve the tree\n e = id[e]\n end\n e\n end", "def insert(value)\n if root.nil?\n self.root= BSTNode.new(value) #if root doesn't exist\n else\n root = self.root\n while(root)\n if value > root.value\n if root.right.nil?\n new_node = BSTNode.new(value)\n root.right = new_node\n root = root.right\n return root.right #return the newly added node\n else\n root = root.right #traverse\n end\n else\n if root.left.nil?\n new_node = BSTNode.new(value)\n root.left = new_node\n return root.left #return the newly added node\n else\n root = root.left #traverse\n end\n end\n end\n end\n root\n end", "def insert(value)\n if empty?\n @root = Node.new(value)\n return\n end\n\n x = Node.new(value)\n\n # find right leaf to insert under\n temp = @root\n while !temp.nil? do\n # need to track parent so when we exit the loop,\n # we can still reference the leaf node found\n found_leaf = temp\n\n if temp.val > value\n temp = temp.left\n elsif temp.val < value\n temp = temp.right\n else\n puts DUPLICATE_VAL\n return\n end\n end\n\n if found_leaf.val > value\n found_leaf.left = x\n else\n found_leaf.right = x\n end\n end", "def delete(value)\n current_node = @root\n until current_node.nil?\n if current_node.data < value\n next_node = current_node.right_child\n if next_node.data == value\n current_node.right_child = delete_aux(next_node, value)\n break\n end\n current_node = current_node.right_child\n elsif current_node.data > value\n next_node = current_node.left_child\n if next_node.data == value\n current_node.left_child = delete_aux(next_node, value)\n break\n end\n current_node = current_node.left_child\n elsif current_node.data == value\n @root = build_tree(in_order_traversal(current_node) - [value])\n break\n end\n end\n end", "def find(value)\n current_node = @root\n until current_node.nil?\n if current_node.data < value\n current_node = current_node.right_child\n elsif current_node.data > value\n current_node = current_node.left_child\n else\n return current_node\n end\n end\n return nil\n end", "def set_root(value)\n\t\t@root = BSTNode.new(value)\n\tend", "def calculate_down_child\n # Guard condition for movement not possible\n return nil if blank_y - 1 < 0\n\n # Make the movement\n new_state = swap_down\n\n # Avoids loop\n parents_array = parent_states(10)\n return nil if parents_array.include?(new_state)\n\n # Returns new node\n Node.new(new_state, self, blank_x, blank_y - 1)\n end", "def root=(value)\n @root = value\n end", "def set_next_node(data)\n data_placed = false\n temp = @root\n until data_placed\n if data == temp.value\n data_placed = true\n elsif data < temp.value\n if temp.left_child.nil?\n temp.left_child = Node.new(data, temp)\n data_placed = true\n else\n temp = temp.left_child\n end\n else # data > temp.value\n if temp.right_child.nil?\n temp.right_child = Node.new(data, temp)\n data_placed = true\n else\n temp = temp.right_child\n end\n end\n end\n end", "def root=(value)\n @root = value\n end", "def root=(value)\n @root = value\n end", "def depth_first(value)\n\tend", "def push(key, value)\n if @root.nil?\n @root = Node.new(key, value, nil, nil)\n @size = 1\n return value\n end\n splay(key)\n \n cmp = (key <=> @root.key)\n if cmp == 0\n @root.value = value\n return value\n end\n node = Node.new(key, value, nil, nil)\n if cmp < 1\n node.left = @root.left\n node.right = @root\n @root.left = nil\n else\n node.right = @root.right\n node.left = @root\n @root.right = nil\n end\n @root = node\n @size += 1\n value\n end", "def down(start)\n if start <= 0\n puts start\n else\n puts start\n down(start-1)\n end\nend", "def add(key, value)\n current_node = @root\n\n @root = TreeNode.new(key, value) if current_node.nil?\n\n until current_node.nil?\n if (key < current_node.key) && current_node.left.nil?\n current_node.left = TreeNode.new(key, value)\n elsif (key > current_node.key) && current_node.right.nil?\n current_node.right = TreeNode.new(key, value)\n elsif key < current_node.key\n current_node = current_node.left\n elsif key > current_node.key\n current_node = current_node.right\n else\n return\n end\n end\n end", "def depth_first_search node= self.root, value\n\t\tstack =[node]\n\n\t\twhile stack.length > 0\n\t\t\tcurrent = stack.pop\n\t\t\treturn \"Value #{value} found in #{current.to_s}\" if current.value == value\n\t\t\tstack.push(current.left) if current.left\n\t\t\tstack.push(current.right) if current.right\n\t\tend\n\tend", "def find(value)\n curr = @root\n while curr\n return curr if curr.data == value\n\n if value < curr.data\n curr = curr.left\n elsif value > curr.data\n curr = curr.right\n end\n end\n curr\n end", "def test_depth_of_value_returns_depth_1_node\n @tree.insert(\"a\")\n assert_equal 0, @tree.depth_of?(\"a\")\n end", "def check_children(value, node)\n if value < node.value\n node.left\n else\n node.right\n end\n end", "def insert(value)\n\t\tcurrent_node = @head \n\t\tif current_node.value >= value \n\t\t\t@head = Node.new(value, current_node)\n\t\tend \n\t\tuntil current_node.next_node.value =< value \n\t\t\tbreak if current_node.next_node == nil \n\t\t\tcurrent_node = current_node.next_node\n\t\tend \n\t\tcurrent_node.next_node = Node.new(value, current_node.next_node)\n\tend", "def move_to_root\n move_to nil, :root\n end", "def move_to_root\n move_to nil, :root\n end", "def move_to_root\n move_to nil, :root\n end", "def move_to_root\n self.move_to(nil, :root)\n end", "def DFS(root, target)\n ## base case: \n return nil if root.nil?\n return root if root.value == target\n ##indecutive step: \n ## DFS on the left side then DFS on the right side \n root.children.each do |child|\n search_result = DFS(child, target) ## better to save the actual value then check the value then return nil\n return search_result unless search_result.nil?\n end \n return nil\nend", "def inOrder(root)\n return nil if root == nil\n\n inOrder(root.left)\n print \" #{root.value}\"\n inOrder(root.right)\nend", "def find value, root_node=@root\n case value <=> root_node.data\n when -1\n find(value, root_node.left)\n when 1\n find(value, root_node.right)\n when 0\n return root_node\n else\n return\n end\n end", "def insert(current_node = root, value)\n # compare nodes,decide if left or right \n return nil if value == current_node.value\n\n if value < current_node.value\n current_node.left.nil? ? current_node.left = Node.new(value) : insert(current_node.left, value)\n else\n current_node.right.nil? ? current_node.right = Node.new(value) : insert(current_node.right, value)\n end\n end", "def left_side_of_tree(root, current_level)\n return if root.nil?\n if (current_level > @max_level)\n puts root.val\n @max_level = current_level\n end\n left_side_of_tree(root.left, current_level + 1)\n left_side_of_tree(root.right, current_level + 1)\nend", "def bubble_up(index, node)\n while (index!=0 && @ary[(index-1)/2].key > node.key) #while parent is bigger,\n @ary[index], @ary[(index-1)/2] = @ary[(index-1)/2], @ary[index] #swap\n index = (index-1)/2\n end\n end", "def test_insert_node_to_left_of_root\n @tree.insert(\"b\")\n @tree.insert(\"a\")\n refute_equal nil, @tree.root.left\n end", "def find_parent(value, tree_node = @root)\n return nil if @root.value == value \n # puts \"tree_node.value\", tree_node.value\n # puts \"tree_node.left.value\", tree_node.left.value\n # puts \"tree_node.right.value\", tree_node.right.value\n return tree_node if tree_node.left.value == value || tree_node.right.value == value \n\n if tree_node.value > value \n tree_node = tree_node.left\n find_parent(value, tree_node)\n else\n tree_node = tree_node.right\n find_parent(value,tree_node)\n end \n\n end", "def move_up\n unless @value.eql? 1\n @y -= 50\n @value -= 1\n end\n end", "def in_order_succ(val, root=@root)\n return nil if root.nil?\n #\n # val, current node (=root), ary == [parent, gparent and link],\n _in_order_succ(val, root, [root, root, :root], nil)\n end", "def swim index\n parent_index = (index - 1) / 2\n\n # continue to bubble upward while we have not reached the root,\n # and while we are less than the parent element\n while (index > 0 && less_than?(index, parent_index))\n \n # swap the two values\n swap_values_at(index, parent_index)\n index = parent_index\n # set new parent index based on the bubble up\n parent_index = (index - 1) / 2\n end\n end", "def test_slide_1\n TaxonName.slide(2, 3)\n assert_equal 6, @child_middle.reload.l\n TaxonName.slide(-2, 3)\n assert @root_node.reload.check_subtree\n end", "def find(value, current_node = root)\n return current_node if current_node.nil? || current_node.value == value\n value < current_node.value ? find(value, current_node.left) : find(value, current_node.right)\n\n end", "def search(value)\n return false if is_empty\n\n current = @root\n\n while current != nil\n if current.value == value\n return true\n else\n current = current.value < value ? current.right : current.left\n end\n end\n\n return false\n end", "def get(key)\n return nil if @root.nil?\n \n splay(key)\n (@root.key <=> key) == 0 ? @root.value : nil\n end", "def search(current_node = @root ,value)\n \tif current_node\n\t \tif current_node.value == value\n\t \t\treturn 1\n\t \telsif current_node.value > value\n\t \t\tsearch(current_node.left, value)\n\t \telsif current_node.value < value\n\t \t\tsearch(current_node.right, value)\n\t \tend\n \telse\n \t\treturn 0\n \tend\n end", "def level_down\r\r\n return if @level.zero?\r\r\n @level -= 1\r\r\n level_update\r\r\n end", "def test_depth_value_not_exist\n @tree.insert(\"c\")\n refute_equal 0, @tree.depth_of?(\"a\")\n end", "def remove_value(value, node)\n if node.left && value < node.data\n if node.left.data == value\n if node.left.left\n link = max_search(node.left.left)\n link.right = node.left.right\n node.left = node.left.left\n elsif node.left.right\n node.left = node.left.right\n else\n node.left = nil\n end\n else\n remove_value(value, node.left)\n end\n\n elsif node.right && value > node.data\n if node.right.data == value\n if node.right.left\n link = max_search(node.right.left)\n link.right = node.right.right\n node.right = node.right.left\n elsif node.right.right\n node.right = node.right.right\n else\n node.right = nil\n end\n else\n remove_value(value, node.right)\n end\n end\n end", "def calculate_up_child\n # Guard condition for movement not possible\n return nil if blank_y + 1 == size\n\n # Make the movement\n new_state = swap_up\n\n # Avoids loop\n parents_array = parent_states(3)\n return nil if parents_array.include?(new_state)\n\n # Returns new node\n Node.new(new_state, self, blank_x, blank_y + 1)\n end", "def insert(value, title)\n node = @root\n i = 0\n while node != nil\n parent_node = node\n node = value < node.value ? node.left : node.right\n i += 1\n end\n\n if has_root?\n parent_node.left = Node.new(value, title, parent_node, i) if value < parent_node.value\n parent_node.right = Node.new(value, title, parent_node, i) if value >= parent_node.value\n else\n @root = Node.new(value, title, nil, i)\n end\n i\n end", "def find_beeper()\n while not next_to_a_beeper?()\n move_toward_beeper()\n end\n end", "def left=(value)\n @left = value\n end", "def left=(value)\n @left = value\n end", "def find_node(value)\n current = @anchor.next_node\n while current != @anchor\n return current if current.value == value\n current = current.next_node\n end\n end", "def preOrder(root) # O(n)\n\n return nil if root == nil\n\n print \" #{root.value}\"\n preOrder(root.left)\n preOrder(root.right)\n\nend", "def build_tree( n , d )\n \n if d.key?('v')\n n < d['v'] ? build_tree(n , d['l']) : build_tree(n, d['r'])\n else\n d['l'] = {}\n d['v'] = n\n d['r'] = {}\n end\n \nend", "def add_node(key, value)\n node = Node.new(key, value)\n\n # if there is current no root node set for the tree we need to set it\n if root.nil?\n @root = node\n else\n # lets find where we need to place the node \n current = @root\n placed = false\n\n while not placed\n # get the property to travese, either left_child or right_child\n property = direction(node.key, current.key)\n\n # set a pointer to remember the previous loops node value and\n # change the current value current based on the property flag \n parent = current\n current = current.send(property)\n\n # if the node under examination is nil then this means we have found\n # a spot to place the current node and we set the placed flag to \n # true in order to exit out of the loop\n if current.nil?\n parent.send(property+'=', node)\n placed = true\n end\n end\n\n end\n end", "def insert_into_tree(root_node, value)\n return BSTNode.new(value) if root_node.nil?\n\n if value <= root_node.value \n root_node.left = insert_into_tree(root_node.left, value)\n else\n root_node.right = insert_into_tree(root_node.right, value)\n end\n\n root_node\n end", "def insert(node, value)\n if node.left.nil? && value < node.val\n return node.left = TreeNode.new(value)\n elsif node.right.nil? && value > node.val\n return node.right = TreeNode.new(value)\n end\n\n insert(node.left, value) if value < node.val\n insert(node.right, value) if value > node.val\n\n return node\nend", "def root(idx)\n idx_value = @array[idx][:value]\n while idx != idx_value\n # OPTIMIZATION (line 67): Path compression. Make every other node in the path point to its grandparent. No reason not to do this! We're already hitting each node anyway.\n @array[idx][:value] = @array[idx_value][:value]\n # Keeps tree almost completely flat!\n idx = idx_value\n end\n @array[idx]\n end", "def delete(val)\n node = find(val)\n\n if node == @root\n @root = nil\n return\n end\n\n parent = find_parent(@root, node)\n left = node.left\n right = node.right\n\n if left.nil? && right.nil?\n parent.right = nil if parent.value < val\n parent.left = nil if parent.value >= val\n elsif left.nil? ^ right.nil?\n if parent.left == node\n if left\n parent.left = left\n left.parent = parent\n else\n parent.left = right\n right.parent = parent\n end\n else\n if left\n parent.right = left\n left.parent = parent\n else\n parent.right = right\n right.parent = parent\n end\n end\n else\n max_node = maximum(left)\n max_node_parent = find_parent(@root, max_node)\n max_node_left_parent = find_parent(@root, max_node.left)\n\n if max_node.left\n max_node_parent.right = max_node.left\n max_node_left_parent = max_node_parent\n end\n\n if parent.left = node\n parent.left = max_node\n max_node_parent = parent\n max_node.left = left\n max_node.right = right\n else\n parent.right = max_node\n max_node_parent = parent\n max_node.left = left\n max_node.right = right\n end\n end\n end", "def push(value)\n @parent, @top = @top, value\n end", "def add(key, value)\n # raise NotImplementedError\n # if the root is nil set the root to be a new node with the given value and return the node.\n return @root = TreeNode.new(key, value) if @root.nil?\n current = @root\n while current != nil \n if key <= current.key \n if current.left.nil?\n current.left = TreeNode.new(key, value)\n return\n end\n current = current.left\n else\n if current.right.nil?\n current.right = TreeNode.new(key, value)\n return\n end\n current = current.right\n end\n end\n end", "def insert_node(node_value, root, parent = nil)\n\t\tif root.nil?\n\t\t\tnew_node = Node.new(node_value)\n\n\t\t\tif node_value < parent.value\n\t\t\t\tparent.left_child = new_node\n\t\t\telse\n\t\t\t\tparent.right_child = new_node\n\t\t\tend\n\n new_node.parent = parent\n\t\telsif node_value < root.value\n\t\t\tparent = root\n\t\t\troot = root.left_child\n\t\t\tinsert_node(node_value, root, parent)\n\t\telsif node_value > root.value\n\t\t\tparent = root\n\t\t\troot = root.right_child\n\t\t\tinsert_node(node_value, root, parent)\n\t\tend\n\n\tend", "def insert_into_subtree(value, root)\n if (value <= root.value)\n if root.left\n root = root.left\n insert_into_subtree(value, root)\n else\n root.left = BSTNode.new(value, root)\n end\n else\n if root.right\n root = root.right\n insert_into_subtree(value, root)\n else\n root.right = BSTNode.new(value, root)\n end\n end\n end", "def add(key, value, current = @root)\n new_node = TreeNode.new(key, value)\n\n if @root == nil\n @root = new_node\n else\n if key <= current.key\n\n if current.left == nil\n current.left = new_node\n else\n add(key, value, current.left)\n end\n\n else\n\n if current.right == nil\n current.right = new_node\n else\n add(key, value, current.right)\n end\n\n end\n end\n end", "def find(value, root = @root)\n return nil if root.nil?\n return root if root.data == value\n\n value < root.data ? find(value, root.left) : find(value, root.right)\n end", "def add(key, value)\n if @root.nil?\n @root = TreeNode.new(key, value)\n return\n end\n\n current_node = @root\n\n while current_node != nil\n if current_node.key < key \n if current_node.right == nil\n current_node.right = TreeNode.new(key, value)\n return\n end\n current_node = current_node.right \n else \n if current_node.left == nil\n current_node.left = TreeNode.new(key, value)\n return \n end\n current_node = current_node.left\n end\n end\n end", "def dfs_rec(tree, value)\n return nil if tree.nil?\n\n left = dfs_rec(tree.left, value)\n return left if left && left.value == value\n\n\n right = dfs_rec(tree.right, value)\n return right if right && right.value == value\n\n p tree.value\n return tree if tree.value == value\n\nend", "def root(value)\n self.get_framework(self.current_framework)[:root] = value.to_s unless value.blank?\n return nil\n end", "def breadth_first_search node= self.root, value\n\t\tqueue = [node]\n\t\twhile queue.length > 0\n\t\t\tcurrent = queue.pop\n\t\t\treturn \"Value #{value} found in #{current.to_s}\" if current.value == value\n\t\t\tqueue.unshift(current.left) if current.left\n\t\t\tqueue.unshift(current.right) if current.right\n\t\tend\n\tend", "def walk_towards_key(key)\n stack = []\n\n # Start with root node\n in_node = root\n node_id = NodeID.new\n\n # Iterate until node is no longer inner\n while in_node.inner?\n stack.push [in_node, node_id]\n\n return nil, stack if v2? && in_node.common_prefix?(key)\n\n # Select tree branch which has key\n # we are looking for, ensure it is not empty\n branch = node_id.select_branch(key)\n return nil, stack if in_node.empty_branch?(branch)\n\n # Descend to branch node\n in_node = descend_throw in_node, branch\n if v2?\n if in_node.inner?\n node_id = NodeID.new :depth => in_node.depth,\n :key => in_node.common\n else\n node_id = NodeID.new :depth => 64,\n :key => in_node.key\n end\n\n else\n # Get ID of branch node\n node_id = node_id.child_node_id branch\n end\n end\n\n # Push final node (assumably corresponding to key)\n stack.push [in_node, node_id]\n\n # Return final node (corresponding to key) and stack\n return in_node, stack\n end", "def add(key, value)\n new_node = TreeNode.new(key, value)\n\n if @root == nil\n @root = new_node\n return\n end\n\n current = @root\n\n while current != nil\n if current.key >= key\n break if current.left == nil\n current = current.left\n else\n break if current.right == nil\n current = current.right\n end\n end\n\n current.key >= key ? current.left = new_node : current.right = new_node\n end", "def dfs_rec(cur_node, value)\n return nil if cur_node.nil?\n \n if cur_node.value == value\n\tcur_node\n else\n tgt_node = nil\n cur_node.children.each do |child| \n\t tgt_node = dfs_rec(child, value)\n\t break unless tgt_node.nil?\n\tend\n\ttgt_node\n end\nend", "def find(val)\n return val if root?(val)\n parent[val] = find parent[val]\n end", "def add(key, value, current=@root)\n # if the root is nil, the tree is empty, add a new node as root\n return @root = TreeNode.new(key, value) unless @root\n\n if key < current.key\n return add(key, value, current.left) if current.left\n current.left = TreeNode.new(key, value)\n elsif key > current.key\n return add(key, value, current.right) if current.right\n current.right = TreeNode.new(key, value)\n end\n end", "def insert_left(value, tree)\n left = tree[:left]\n if left == nil\n left = Hash.new()\n left[:parent] = tree\n tree[:left] = left\n end\n insert(value, left)\nend", "def insert!(value, papa)\n if value <= papa.value && papa.left\n insert!(value, papa.left)\n elsif value <= papa.value\n papa.left = BSTNode.new(value)\n papa.left.papa = papa\n elsif value > papa.value && papa.right\n insert!(value, papa.right)\n else\n papa.right = BSTNode.new(value)\n papa.right.papa = papa\n end\n end", "def downto_recursive\n num = 0\n 11.downto(1) do |num|\n num -= 1\n puts num\n end\nend", "def search_path_for_insert_position(start_node_index, end_node_index, key_value)\n \n if start_node_index >= end_node_index\n return start_node_index\n end\n \n if parent_index(end_node_index) == start_node_index\n #if only two elements in the path\n #use the end one as the midpoint\n mid = end_node_index\n else\n #calculate the mid point of the path\n mid_advances = 0.5 * height_of_heap(start_node_index, end_node_index)\n mid = end_node_index\n mid_advances.floor.downto(1) do |i|\n mid = parent_index(mid)\n end\n end\n\n if self[mid - 1] > key_value\n search_path_for_insert_position(next_child_in_path(start_node_index, end_node_index), end_node_index, key_value)\n elsif self[mid - 1] < key_value\n search_path_for_insert_position(start_node_index, parent_index(mid), key_value)\n else\n #we've found the insert position \n mid \n end \n end" ]
[ "0.64694065", "0.63584346", "0.632828", "0.6324421", "0.6324421", "0.6314161", "0.62989813", "0.6204862", "0.61975", "0.6174148", "0.6157001", "0.61506456", "0.60948265", "0.6080464", "0.6078495", "0.60756147", "0.6074412", "0.6071448", "0.6064325", "0.6064235", "0.60470855", "0.5976257", "0.5967941", "0.59152734", "0.59093314", "0.5900912", "0.5896866", "0.58782005", "0.58659005", "0.58357686", "0.5823763", "0.581334", "0.5810148", "0.5809647", "0.5802346", "0.58011836", "0.58011836", "0.57890856", "0.57877403", "0.5786943", "0.5777287", "0.5739792", "0.5738217", "0.57359535", "0.57198066", "0.5718324", "0.5707695", "0.5707695", "0.5707695", "0.57048386", "0.5700773", "0.5699907", "0.56943715", "0.5693158", "0.5684713", "0.5678172", "0.5662604", "0.56541705", "0.56458336", "0.5643078", "0.5642258", "0.5616029", "0.5614058", "0.56120265", "0.5610922", "0.5604339", "0.5575591", "0.5572885", "0.55725515", "0.5568817", "0.5558344", "0.5550701", "0.5547947", "0.5547947", "0.55417067", "0.5534981", "0.5532106", "0.55320793", "0.5531623", "0.5527873", "0.552705", "0.5506589", "0.55024827", "0.5498978", "0.54966974", "0.549633", "0.549484", "0.5493915", "0.54915", "0.5489374", "0.54889077", "0.5488719", "0.5488504", "0.5486391", "0.5484577", "0.54829335", "0.5482289", "0.5479233", "0.5469084", "0.5466855", "0.5465335" ]
0.0
-1
add a value to the tree anchored at a node
def add_at_node(node, value) if node == nil return Node.new(value) else if value <= node.value node.left_child = add_at_node(node.left_child, value) else node.right_child = add_at_node(node.right_child, value) end return node end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add(value)\n @root = add_at_node(@root, value)\n end", "def add(node, value)\n tree_navigator.descendents(node).each do |descendent|\n values[descendent] += value\n end\n end", "def add(key, value)\n current_and_parent_pair = find_current_and_parent_nodes(key)\n if current_and_parent_pair[:current]\n # update new value if key exists\n current_and_parent_pair[:current].value = value\n else\n new_node = TreeNode.new(key,value)\n parent = current_and_parent_pair[:parent]\n link_node_to_parent(parent, new_node)\n end\n end", "def add value\n if !@root\n @root = Node.new value, nil, @cmp\n @length = 1\n else\n @root.add value\n @length += 1\n end\n value\n end", "def add value\n if @cmp.call(@value, value) < 0\n if @left\n @left.add value, cmp\n else\n @left = Node.new value, self, @cmp\n end\n else\n if @right\n @right.add value\n else\n @right = Node.new value, self, @cmp\n end\n end\n end", "def add(key, value)\n new_node = TreeNode.new(key, value)\n \n if @root.nil?\n @root = new_node\n return\n end\n\n return add_helper(@root, new_node)\n end", "def add(key, value)\n new_node = TreeNode.new(key, value)\n if !@root \n @root = new_node\n return \n end\n add_node(new_node, @root)\n\n end", "def add(key, value)\n new_node = TreeNode.new(key,value)\n \n if @root.nil?\n @root = new_node\n else \n add_helper(@root, key, value)\n end\n end", "def add(key, value)\n new_node = TreeNode.new(key, value)\n\n if @root.nil?\n @root = new_node \n else \n @root = add_helper(@root, new_node)\n end\n\n end", "def add(key, value)\n new_nodelet = TreeNode.new(key, value)\n\n if @root.nil?\n @root = new_nodelet \n else \n @root = add_helper(@root, new_nodelet)\n end \n end", "def add_node(node)\n nodes[node.value] = node\n end", "def add(key, value)\n #recursive\n @root = add_helper(@root, key, value)\n end", "def add(key, value)\n new_node = TreeNode.new(key, value)\n\n if @root.nil?\n @root = new_node\n else\n add_helper(@root, new_node)\n end\n end", "def add(key, value)\n if @root.nil?\n @root = TreeNode.new(key, value)\n else\n self.add_helper(@root, key, value)\n end\n end", "def add(key, value)\n @root = add_helper(@root, key, value)\n end", "def add(key, value)\n # if root.nil?\n if !root\n @root = TreeNode.new(key, value)\n else\n root.add(key, value)\n end\n end", "def add(key, value)\n new_node = TreeNode.new(key, value)\n\n if @root == nil\n @root = new_node\n else\n add_node(@root, new_node)\n end\n end", "def add(key, value)\n if @root.nil?\n @root = TreeNode.new(key, value)\n return\n end\n\n current_node = @root\n\n while current_node != nil\n if current_node.key < key \n if current_node.right == nil\n current_node.right = TreeNode.new(key, value)\n return\n end\n current_node = current_node.right \n else \n if current_node.left == nil\n current_node.left = TreeNode.new(key, value)\n return \n end\n current_node = current_node.left\n end\n end\n end", "def add(key, value)\n @root = add_helper(@root, key, value)\n end", "def add(key, value)\n @root = add_helper(@root, key, value)\n end", "def add(key, value)\n @root = add_helper(@root, key, value)\n end", "def add(key, value)\n @root = add_helper(@root, key, value)\n end", "def add_node(node); end", "def insert_into_tree(root, new_value, index)\n if root.val == new_value\n return root\n elsif new_value < root.val\n if root.left\n insert_into_tree(root.left, new_value, index)\n else\n root.left = TreeNode.new(new_value, index )\n end\n else\n if root.right\n insert_into_tree(root.right, new_value, index)\n else\n root.right = TreeNode.new(new_value, index)\n end\n end\nend", "def add(key, value, current=@root)\n # if the root is nil, the tree is empty, add a new node as root\n return @root = TreeNode.new(key, value) unless @root\n\n if key < current.key\n return add(key, value, current.left) if current.left\n current.left = TreeNode.new(key, value)\n elsif key > current.key\n return add(key, value, current.right) if current.right\n current.right = TreeNode.new(key, value)\n end\n end", "def add(key, value)\n new_node = TreeNode.new(key, value)\n if @root == nil\n @root = new_node\n return new_node\n else\n add_helper(@root, new_node)\n end\n end", "def add_node(current_node, v)\n left = current_node.left if current_node.left\n right = current_node.right if current_node.right\n current_node.left = TreeNode.new(v)\n current_node.right = TreeNode.new(v)\n current_node.left.left = left\n current_node.right.right = right\nend", "def add(key, value)\n # raise NotImplementedError\n # if the root is nil set the root to be a new node with the given value and return the node.\n return @root = TreeNode.new(key, value) if @root.nil?\n current = @root\n while current != nil \n if key <= current.key \n if current.left.nil?\n current.left = TreeNode.new(key, value)\n return\n end\n current = current.left\n else\n if current.right.nil?\n current.right = TreeNode.new(key, value)\n return\n end\n current = current.right\n end\n end\n end", "def add(key, value)\n new_tree_node = TreeNode.new(key, value)\n\n if @root.nil?\n @root = new_tree_node\n else\n current = @root\n while current\n if new_tree_node.key <= current.key\n if !current.left\n current.left = new_tree_node\n return\n else\n current = current.left\n end\n else\n if !current.right\n current.right = new_tree_node\n return\n else\n current = current.right\n end\n end\n end\n end\n end", "def add(key, value)\n # recursive solution with helper method\n @root = add_helper(@root, key, value)\n\n # the while-looping way\n # if @root.nil?\n # @root = TreeNode.new(key, value)\n # else\n # current = @root\n # while true\n # if key < current.key\n # if !current.left.nil?\n # current = current.left\n # else\n # current.left = TreeNode.new(key, value)\n # return\n # end\n # else\n # if !current.right.nil?\n # current = current.right\n # else\n # current.right = TreeNode.new(key, value)\n # return\n # end\n # end\n # end\n # end\n end", "def push_node(node, value)\n new_node = Node.new(value)\n if node\n if(value > node.value)\n if(node.right)\n push_node(node.right, value)\n else\n node.right = new_node\n end\n else\n if(node.left)\n push_node(node.left, value)\n else\n node.left = new_node\n end\n end\n else\n @root = new_node\n end\n end", "def add(key, value)\n new_node = TreeNode.new(key, value)\n\n if @root == nil\n @root = new_node\n return\n end\n\n current = @root\n\n while current != nil\n if current.key >= key\n break if current.left == nil\n current = current.left\n else\n break if current.right == nil\n current = current.right\n end\n end\n\n current.key >= key ? current.left = new_node : current.right = new_node\n end", "def add(key, value)\n if key.empty?\n @value = value\n else\n letter = key.shift\n if !@children[letter]\n @children[letter] = Node.new()\n end\n @children[letter].add(key, value)\n end\n end", "def add(value)\n\t\tif @head != nil \n\t\t\tcurrent = @head\n\t\t\twhile current.nnode != nil\n\t\t\t\tcurrent = current.nnode\n\t\t\tend\n\t\t\tcurrent.nnode = Node.new(value, nil)\n\t\telse\n\t\t\t@head = Node.new(value,nil)\n\t\tend\n\tend", "def add_child(value)\n @children.unshift(Tree(value))\n end", "def add_child(value)\n @children.unshift(Tree(value))\n end", "def push_node node, value\n if value > node.data\n if node.right\n push_node node.right, value\n else\n node.right = Node.new value\n end\n else\n if node.left\n push_node node.left, value\n else\n node.left = Node.new value\n end\n end\nend", "def insert(value, node = root)\n return nil if value == node.data\n \n if value < node.data\n node.left.nil? ? node.left = Node.new(value) : insert(value, node.left)\n else\n node.right.nil? ? node.right = Node.new(value) : insert(value, node.right)\n end\n end", "def insert_after( node, value )\n # Find the specified node, and add a new node\n # with the given value between that found node\n # and the next\n\n end", "def add_node(key, value)\n node = Node.new(key, value)\n\n # if there is current no root node set for the tree we need to set it\n if root.nil?\n @root = node\n else\n # lets find where we need to place the node \n current = @root\n placed = false\n\n while not placed\n # get the property to travese, either left_child or right_child\n property = direction(node.key, current.key)\n\n # set a pointer to remember the previous loops node value and\n # change the current value current based on the property flag \n parent = current\n current = current.send(property)\n\n # if the node under examination is nil then this means we have found\n # a spot to place the current node and we set the placed flag to \n # true in order to exit out of the loop\n if current.nil?\n parent.send(property+'=', node)\n placed = true\n end\n end\n\n end\n end", "def add(key, value)\n current_node = @root\n\n @root = TreeNode.new(key, value) if current_node.nil?\n\n until current_node.nil?\n if (key < current_node.key) && current_node.left.nil?\n current_node.left = TreeNode.new(key, value)\n elsif (key > current_node.key) && current_node.right.nil?\n current_node.right = TreeNode.new(key, value)\n elsif key < current_node.key\n current_node = current_node.left\n elsif key > current_node.key\n current_node = current_node.right\n else\n return\n end\n end\n end", "def add_value(value)\n @children['value'][:value] << value\n end", "def add(key, value)\n # raise NotImplementedError\n # Non recursion\n # if @root = nil? \n # return @root = TreeNode.new(key, value)\n # else\n # current = @root\n # while true\n # if key < current.key\n # if !current.left.nil?\n # current = current.left\n # else\n # current.left = TreeNode.new(key,value)\n # return\n # end\n # else\n # if !current.right.nil?\n # current = current.right\n # else\n # current.right = TreeNode.new(key,value)\n # return\n # end\n # end\n # end\n # end\n\n # until current.left == nil && current.right == nil\n # if key < current.key\n # current.left = TreeNode.new\n # else\n # current.right = TreeNode.new\n # end\n # end\n\n # Recursive Method\n @root = add_helper(@root, key, value)\n end", "def add_to_tree(item, node)\n return rebalance(super(item, node))\n end", "def add(key, value)\n \n # iterative loop way\n if @root.nil? \n @root = TreeNode.new(key, value)\n else\n current = @root\n while true \n if key < current.key\n\n if !current.left.nil?\n current = current.left\n else\n current.left = TreeNode.new(key, value)\n return \n end\n else\n if !current.right.nil?\n current = current.right\n else\n current.right = TreeNode.new(key, value)\n return \n end\n end\n end \n end \n # recursive way\n # @root = add_helper(@root, key, value)\n end", "def insert(key, value, __level = nil)\n @mutex.synchronize do\n newlevel = __level || random_level\n x = anchor\n level = node_level(x)\n update = Array.new(level)\n x = find_with_update(x, level, key, update)\n \n # rewrite existing key\n \t if node_compare(x, key) == 0\n \t node_set_value!(x, value)\n \t # insert in a middle\n \t else\n \t level = newlevel\n \t newx = new_node(newlevel, key, value)\n \t while level > 0\n \t level -= 1\n \t node_insert_after!(newx, update[level], level)\n end\n \t end\n end\n \tself\n \tend", "def add(key, value, current = @root)\n new_node = TreeNode.new(key, value)\n\n if @root == nil\n @root = new_node\n else\n if key <= current.key\n\n if current.left == nil\n current.left = new_node\n else\n add(key, value, current.left)\n end\n\n else\n\n if current.right == nil\n current.right = new_node\n else\n add(key, value, current.right)\n end\n\n end\n end\n end", "def add?(value)\n node = TreeNode.new(value)\n added = if root.nil?\n @root = node\n else\n @root.add(node)\n end\n if added\n @length += 1\n self\n else\n nil\n end\n end", "def add_node(value, node=nil)\n new_node = Node.new(value)\n if node\n new_node.parent = node\n node.children << new_node\n else\n @head = new_node\n end\n end", "def add(v)\n if @root == nil\n @root = Node.new(v)\n @count = 1\n return\n end\n @root, inc_count = @root.add(v)\n @count += 1 if inc_count\n end", "def add(v)\n case\n when v < @value1\n if is_leaf\n return Node.new(@value1, Node.new(v), Node.new(@value2)), true if @type == 3\n @type, @value1, @value2 = 3, v, @value1\n return self, true\n end\n child, inc_count = @left.add(v)\n return self, inc_count if child == @left\n return Node.new(@value1, child, Node.new(@value2,@mid,@right)), true if @type == 3\n shift_right\n @type, @left, @value1, @mid = 3, child.left, child.value1, child.mid\n return self, true\n when v == @value1\n @value1 = v\n return self, false\n when @type == 2\n if is_leaf\n @type, @value2 = 3, v\n return self, true\n end\n child, inc_count = @mid.add(v)\n if child != @mid\n @type, @mid, @value2, @right = 3, child.left, child.value1, child.mid\n end\n return self, inc_count\n when v < @value2\n if is_leaf\n return Node.new(v, Node.new(@value1), Node.new(@value2)), true\n end\n child, inc_count = @mid.add(v)\n return self, inc_count if child == @mid\n return Node.new(child.value1, Node.new(@value1,@left,child.left),\n Node.new(@value2,child.mid,@right)), true\n when v == @value2\n @value2 = v\n return self, false\n else # v > @value2\n if is_leaf\n return Node.new(@value2, Node.new(@value1), Node.new(v)), true\n end\n child, inc_count = @right.add(v)\n return self, inc_count if child == @right\n return Node.new(@value2, Node.new(@value1, @left, @mid), child), true\n end\n end", "def []=(leaf_id, new_value)\n \n end", "def add(k)\n # create new node\n n = AvlNode.new k\n # start recursive procedure for inserting the node\n insert_avl(@root, n)\n end", "def insert(key, value, __level = nil)\n @mutex.synchronize do\n newlevel = __level || random_level\n x = node_first\n level = node_level(x)\n update = Array.new(level)\n x = find_with_update(x, level, key, update)\n \n # rewrite existing key\n \t if node_compare(x, key) == 0\n \t node_set_value!(x, value)\n \t # insert in a middle\n \t else\n \t level = newlevel\n \t newx = new_node(newlevel, key, value)\n \t while level > 0\n \t level -= 1\n \t node_insert_after!(newx, update[level], level)\n end\n \t end\n end\n \tself\n \tend", "def add(val)\n get_node(val) #every new element that has to be added should point to a new node correponding to it.\n list_size = @elements.size\n last_element_index = list_size - 1\n @elements[last_element_index].next_node = list_size\n new_element_index = list_size\n @elements[new_element_index] = @node\n end", "def update(leaf_id, new_value)\n @nodes[@leaf_count + leaf_id] = new_value\n visit_path_to_root(leaf_id) do |node|\n next if leaf_node?(node)\n \n @nodes[node] = HashTree.node_hash node, @nodes[HashTree.left_child(node)],\n @nodes[HashTree.right_child(node)]\n end\n self\n end", "def insert(node)\n case @value <=> node.value\n when 1\n # alphabetically greater than, insert to left\n insert_into(:left, node)\n when 0\n # same value, so increase count of `self` node\n @count += 1\n when -1\n # alphabetically less than, insert to right\n insert_into(:right, node)\n end\n end", "def set_value(input, root)\n\t\treturn root = Node.new(input) if root == nil\n\n\t\tcase input <=> root.value\n\t\twhen -1\n\t\t\treturn root.small_child = Node.new(input, root) if root.small_child == nil\n\t\t\tset_value(input, root.small_child)\n\t\twhen 1\n\t\t\treturn root.big_child = Node.new(input, root) if root.big_child == nil\n\t\t\tset_value(input, root.big_child)\n\t\twhen 0\n\t\t\troot.count += 1\n\t\tend\n\tend", "def insert(new_value)\n if new_value > @value\n @right ? @right.insert(new_value) : (@right = Node.new(new_value))\n else\n @left ? @left.insert(new_value) : (@left = Node.new(new_value))\n end\n end", "def insert node, value= nil\n\t\t\tif value < node.value\n\t\t\t\tnode.left.nil? ? node.left = Node.new(value, node) : insert(node.left, value)\n\t\t\telsif value >= node.value\n\t\t\t\tnode.right.nil? ? node.right = Node.new(value, node) : insert(node.right, value)\n\t\t\tend\t\t\n\tend", "def insert new_value\n if new_value <= @value\n @left.nil? ? @left = Node.new(new_value) : @left.insert(new_value)\n elsif new_value > @value\n @right.nil? ? @right = Node.new(new_value) : @right.insert(new_value)\n end\n end", "def add_node(key, val)\n @store.append(key, val)\n end", "def insert_after value\n node = Node.new value, @nxt, self\n @nxt.prv = node if @nxt\n @nxt = node\n end", "def insertar(value)\n insert(Node.new(value, nil, nil))\n end", "def insert_node(tree_node, value)\r\n\r\n # Base Case: Found a space\r\n if tree_node.nil?\r\n tree_node = Node.new(value)\r\n\r\n elsif tree_node.value == value\r\n tree_node.value = value\r\n elsif tree_node.value < value\r\n tree_node.right = insert_node(tree_node.right, value)\r\n else\r\n tree_node.left = insert_node(tree_node.left, value)\r\n end\r\n tree_node\r\n end", "def insert(current_node = root, value)\n # compare nodes,decide if left or right \n return nil if value == current_node.value\n\n if value < current_node.value\n current_node.left.nil? ? current_node.left = Node.new(value) : insert(current_node.left, value)\n else\n current_node.right.nil? ? current_node.right = Node.new(value) : insert(current_node.right, value)\n end\n end", "def set_new_value(path, located_entry)\n aug.set(path, located_entry.entry_value)\n # we need to get new path as path used in aug.set can contains\n # \"[last() + 1]\", so adding subtree to it, adds additional entry.\n # So here, we replace \"[last() + 1]\" with \"[last()]\" so it will match\n # path created by previous aug.set\n match_str = path.gsub(/\\[\\s*last\\(\\)\\s*\\+\\s*1\\]/, \"[last()]\")\n\n new_path = aug.match(match_str).first\n add_subtree(located_entry.entry_tree, new_path)\n end", "def add(key,value)\n @root = Node.new(key[0], nil) if (@root == nil)\n @root.add_vertical(key,value)\n end", "def insert_after( node, value )\n # Find the specified node, and add a new node\n # with the given value between that found node\n # and the next\n node = find node\n node_after = node.next\n node_inserted = Node.new value\n node.next = node_inserted\n node_inserted.next = node_after\n node_inserted\n end", "def add_helper(current_node, key, value)\n if current_node.nil?\n return TreeNode.new(key, value) \n end\n\n if key < current_node.key\n current_node.left = add_helper(current_node.left, key, value)\n else\n current_node.right = add_helper(current_node.right, key, value)\n end\n \n return current_node\n end", "def push(key, value)\n if @root.nil?\n @root = Node.new(key, value, nil, nil)\n @size = 1\n return value\n end\n splay(key)\n \n cmp = (key <=> @root.key)\n if cmp == 0\n @root.value = value\n return value\n end\n node = Node.new(key, value, nil, nil)\n if cmp < 1\n node.left = @root.left\n node.right = @root\n @root.left = nil\n else\n node.right = @root.right\n node.left = @root\n @root.right = nil\n end\n @root = node\n @size += 1\n value\n end", "def node_insert(node, value)\n if value < node.value\n if node.left\n node_insert(node.left, value)\n else\n node.left = BSTNode.new(value, node)\n end\n else\n if node.right\n node_insert(node.right, value)\n else\n node.right = BSTNode.new(value, node)\n end\n end\n end", "def add_node(value)\n if @head\n @head = Node.new value, @head\n else\n @head = Node.new value, nil\n end\n end", "def push (value)\n @top = Node.new(value, @top)\n end", "def append(value)\n new_node = Node.new(value)\n @node_counter += 1\n if @head == nil\n @head = new_node\n else\n last_node = traverse_nodes(@head)\n # require 'pry'; binding.pry\n last_node.next_node = new_node\n end\n end", "def put(key, value)\n @root = put_node(@root, key, value, 0)\n end", "def add_node(value)\n add_node_support(value, :linked_list)\n end", "def insert_after(value)\n node = Node(value)\n @next = node\n node\n end", "def add_to_index(name, key, node); end", "def append( value )\n last.next = Node.new value\n end", "def insert(value, tree)\n if tree[:root] == nil\n tree[:root] = value\n return\n end\n if tree[:root] >= value\n insert_left(value, tree)\n return\n end\n insert_right(value, tree)\nend", "def add_iteratively_to_bst(root, value)\n if root.nil?\n root = TreeNode.new(value)\n else\n current_node = root\n while current_node\n if value < current_node.value\n if current_node.left == nil\n # Adding the new value to the tree\n current_node.left = TreeNode.new(value)\n return root# Added the element, retrun reference to root of the tree\n else\n current_node = current_node.left\n end\n else\n if current_node.right == nil\n # Adding the new value to the tree\n current_node.right = TreeNode.new(value)\n return root# Added the element, retrun reference to root of the tree\n else\n current_node = current_node.right\n end\n end\n end\n end\n return root\n end", "def add(e, node = @head)\n if node.value == nil\n node.value = e\n node.lchild = Node.new\n node.rchild = Node.new\n @size += 1\n elsif node.value > e\n add e, node.lchild\n elsif node.value < e\n add e, node.rchild\n end\n return self\n end", "def push(value)\n\t\tlast_node = find_last\n\t\tlast_node.next_node = Node.new(value)\n\tend", "def push(value)\n # IMPLEMENT ME!\n @data = Node.new(value, @data)\n end", "def put(key, value)\n @root = put_node(@root, key, value)\n end", "def push_at(index, value)\n new_node = create_node(value)\n node = node_at(index - 1)\n push_after(node, new_node) if node\n self.head = new_node if index == 0\n self.size += 1\n new_node.data\n end", "def test_insert_adds_node_at_root\n @tree.insert(\"a\")\n assert_equal \"a\", @tree.root.value\n end", "def []=(key, value)\n pair = Pair.new(key,value)\n @tree.add(pair)\n return value\n end", "def insert(value)\n new_node = Node.new(value)\n\n return @root = new_node if is_empty\n\n current = @root\n parent = nil\n\n while current != nil\n parent = current\n current = value <= current.value ? current.left : current.right\n end\n\n value <= parent.value ? parent.left = new_node : parent.right = new_node\n end", "def +(delta)\n clone.increment(Meangirls.node, delta)\n end", "def insert_at(index, node_value)\n if index == 0\n node = Node.new(node_value)\n node.next_node = @head\n @head = node\n else\n target = at(index)\n if target.nil?\n append(node_value)\n else\n node = Node.new(node_value)\n pre_target = at(index - 1)\n node.next_node = target\n pre_target.next_node = node\n end\n end\n\n node\n end", "def insert(node)\n if(node.value < @value)\n unless @left==nil\n @left.insert(node)\n else\n @left=node\n @left.root=self\n end\n elsif(node.value >@value)\n unless @right==nil\n @right.insert(node)\n else\n @right=node\n @right.root=self\n end\n else\n @value = node.value\n end\n end", "def append(value)\n new_node = Node.new(value)\n node = @node\n\n while node.next\n node = node.next\n end\n\n node.next = new_node\n end", "def add_helper(current_node, key, value)\n return TreeNode.new(key, value) if current_node.nil?\n\n if key < current_node.key\n current_node.left = add_helper(current_node.left, key, value)\n else\n current_node.right = add_helper(current_node.right, key, value)\n end\n return current_node\n end", "def add_helper(current_node, key, value)\n return TreeNode.new(key, value) if current_node.nil?\n\n if key < current_node.key\n current_node.left = add_helper(current_node.left, key, value)\n else\n current_node.right = add_helper(current_node.right, key, value)\n end\n return current_node\n end", "def find_plus(value, queue=[@root])\n root = queue.shift\n return root if root.nil? || root.value == value\n queue << root.left_child if root.left_child != nil\n queue << root.right_child if root.right_child != nil\n find_plus(value, queue)\n end", "def add(val)\n # debugger\n current = @head\n while current.next != nil\n current = current.next\n end\n current.next = Node.new(val, nil)\n \n # current.next.value\n self\n end", "def add_at_head(val)\n \n end", "def []=(index, value)\n node = find_node(index)\n node.value = value\n end" ]
[ "0.76587677", "0.7567673", "0.74158627", "0.71036375", "0.7068475", "0.69247437", "0.6859794", "0.6847555", "0.68399704", "0.68210447", "0.682073", "0.6818211", "0.67921317", "0.67771864", "0.6752892", "0.67485195", "0.6742964", "0.6738661", "0.6729502", "0.6729502", "0.6729502", "0.6729502", "0.67187655", "0.6683568", "0.6681941", "0.66777664", "0.66714203", "0.66551894", "0.6628334", "0.6622797", "0.6612632", "0.6606002", "0.6590836", "0.65889627", "0.6574255", "0.6571971", "0.6571271", "0.6565704", "0.6563547", "0.65543205", "0.6540621", "0.6518099", "0.6496312", "0.64918095", "0.6478711", "0.64780074", "0.6427369", "0.6407469", "0.63887703", "0.6382308", "0.6371135", "0.6370673", "0.6345881", "0.6332507", "0.6327241", "0.6327105", "0.6323049", "0.6321365", "0.6319585", "0.6316358", "0.6307406", "0.62984186", "0.6289637", "0.6286869", "0.6278548", "0.6262217", "0.6226087", "0.6222018", "0.6217046", "0.62087035", "0.6206422", "0.6200344", "0.61800045", "0.6178948", "0.61700374", "0.61697805", "0.616871", "0.6155316", "0.6151813", "0.61456823", "0.6145019", "0.61301076", "0.61289865", "0.61248034", "0.61187226", "0.61133057", "0.6106533", "0.61051273", "0.60876846", "0.60847723", "0.6075442", "0.60714513", "0.60681194", "0.60659593", "0.60656387", "0.60656387", "0.6061933", "0.6061372", "0.60571384", "0.605667" ]
0.7449494
2
Get a list of a list of all nodes at each depth Modified breadthfirst traversal with queues
def get_list_of_lists # placeholder for all the list of lists we will return list_of_lists = [] # initialize list and assume root is available current_list = [] current_list << @root # look at current level - do we have anything to see? while !current_list.empty? # for the next level items, we don't want to touch those yet list_for_next_level = [] # list of nodes we are able to find at this level list_at_this_level = [] # now iterate through all the items at this level while !current_list.empty? node = current_list.shift list_at_this_level << node.value list_for_next_level << node.left_child if node.left_child list_for_next_level << node.right_child if node.right_child end # add the list at this level to the return list list_of_lists << list_at_this_level # update current list being seen with the list of the next level current_list = list_for_next_level end return list_of_lists end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def breadth_first\n result = []\n queue = [self]\n while !queue.empty?\n node = queue.shift\n result << node\n node.children.sort.each do |child|\n queue << child\n end\n end\n return result\n end", "def bfs\n q = []\n list = []\n\n return [] if @root.nil?\n\n current_node = @root\n \n q.push(current_node)\n # put current node into queue\n while q.length != 0\n # put current node into list and delete from queue\n # add current node's children into the queue\n list.push({key: q[0].key, value: q[0].value})\n q.shift\n \n if current_node.left != nil \n q.push(current_node.left) \n end \n\n if current_node.right != nil \n q.push(current_node.right)\n end\n current_node = q[0] \n end \n\n return list\n end", "def bfs(tree)\n Enumerator.new do |yielder|\n queue = [tree]\n while !queue.empty?\n node = queue.shift\n children = node[1..-1]\n yielder << node.first\n children.each do |child|\n queue << child\n end\n end\n end\nend", "def bfs\n bfs_queue = []\n curr = @root\n node_list = []\n while curr\n visit(curr, node_list)\n bfs_queue << curr.left if curr.left\n bfs_queue << curr.right if curr.right\n curr = bfs_queue.shift\n end\n return node_list\n end", "def bfs\n return [] if @root.nil?\n queue = []\n list = []\n queue.push(@root)\n while queue.length > 0\n curr_node = queue[0]\n list << {key: curr_node.key, value: curr_node.value}\n queue.push(curr_node.left) if curr_node.left\n queue.push(curr_node.right) if curr_node.right\n queue.shift\n end\n return list \n end", "def bfs\n list = []\n if @root\n queue = []\n queue << @root\n queue.each do |current|\n list << {key: current.key, value: current.value}\n queue << current.left if current.left\n queue << current.right if current.right\n end\n end\n return list\n end", "def traverse_bfs\n q = Queue.new\n q.push @tree\n \n loop do\n break if q.empty?\n node = q.shift\n if block_given?\n yield node\n else\n @visited << node.data\n end\n node.children.each{ |n| q.push n } if node.children\n end\n end", "def bfs(start_node_num)\n node = find_node(start_node_num)\n _clear_visited\n ret_list = [node.value]\n # Your code here\n q = Queue.new\n q << node\n node.visited = true\n\n until q.empty?\n current = q.pop\n current.edges.each do |edge|\n next if edge.node_to.visited\n q << edge.node_to\n edge.node_to.visited = true\n ret_list << edge.node_to.value\n end\n end\n\n return ret_list\n end", "def bfs\n result = []\n\n return result if @root.nil?\n\n queue = [@root]\n\n while !queue.empty?\n node = queue.shift\n\n result << { key: node.key, value: node.value }\n\n if node.left\n queue << node.left\n end\n\n if node.right\n queue << node.right\n end\n end\n\n return result\n end", "def breadth_first\n queue = []\n values = []\n queue << @root\n\n while queue.size > 0\n node = queue.shift\n queue << node.left unless node.left.nil?\n queue << node.right unless node.right.nil?\n\n values << node.value\n end\n\n values\n end", "def bfs\n # this is 'really' a traversal, but this type of search is similar to what we'll be doing with graphs and it's called 'breadth first search'\n list = []\n return list if @root.nil?\n queue = [@root]\n\n until queue.empty?\n # big O of shift is O(n)\n current = queue.shift\n # how to check if current has a left subtree?\n queue.push(current.left) unless current.left.nil?\n queue.push(current.right) unless current.right.nil?\n\n list << { key: current.key, value: current.value}\n end\n end", "def bfs(root)\n # NOTE implement real queue for performance\n queue = []\n root.marked = true\n queue.push(root)\n\n while !queue.empty?\n node = queue.shift\n node.visit\n\n node.adjacent.each do |node|\n if node.marked == false\n node.marked = true\n queue.push(node)\n end\n end\n end\nend", "def bfs\n return [] unless @root\n q = [@root]\n out = []\n\n until q.empty? do\n current = q.shift\n out << { key: current.key, value: current.value }\n q << current.left if current.left\n q << current.right if current.right\n end\n\n return out\n end", "def breadth_traversal(top_node)\n # start with the first nodes\n nodes = [top_node]\n nodes_to_iterate = [top_node]\n\n # while we have more nodes to print\n while (!nodes_to_iterate.empty?)\n next_nodes = [] # start with an empty list\n # for each node we iterate over in this, find their children\n nodes_to_iterate.each do |n|\n # add the next nodes we iterate\n next_nodes.concat(n.children)\n end\n\n #\n nodes.concat(next_nodes)\n nodes_to_iterate = next_nodes\n end\n\n # print them out in order\n # nb: (this could be a nested structure so you could print out\n # each row on a separate line, which might be cool)\n nodes.each {|n| yield n.value }\nend", "def each\n queue = [@root]\n until queue.empty?\n node = queue.shift\n queue += node.children\n yield node\n end\n end", "def all_children\n reload\n nodes = []\n queue = children.to_a\n until queue.empty?\n node = queue.pop\n nodes.push(node)\n queue += node.children.to_a\n queue.flatten!\n end\n nodes\n end", "def breadthFirstSearch(array)\n queue = [self]\n\n while queue.length > 0\n current = queue.shift\n array.append(current.name)\n for child in current.children\n queue.append(child)\n end\n end\n\n return array\n\n end", "def flatten\n nodes = []\n queue = [node]\n\n while node = queue.shift\n nodes << node\n queue.unshift(*node.children) unless node.leaf?\n end\n\n nodes\n end", "def bfs(tree, value)\n q = MyQueue.new\n q.enqueue(tree)\n current_tree = q.dequeue() #need to do something when i dequeue \n \n while current_tree != nil\n puts current_tree.payload\n\n if current_tree.payload != value\n current_tree.children.each do |leaf|\n q.enqueue(leaf)\n end\n else\n q = MyQueue.new\n end\n current_tree = q.dequeue()\n end\nend", "def bft(&block)\n queue = Queue.new\n \n # Set all nodes to not enqueued\n self.each do |node|\n node.enqueued = false\n end\n\n queue.push(self) \n self.enqueued = true\n\n while(queue.size > 0)\n # Get next node in the queue\n node = queue.pop\n \n # Pass node off to block\n block.call(node)\n\n # Enqueue all children nodes\n node.child_array.each do |child|\n if !child.enqueued\n queue.push(child)\n child.enqueued = true\n end\n end\n\n end #while\n end", "def bfs_search(root)\n queue = []\n\n root.marked = true\n queue.push(root)\n\n while queue.length != 0\n current = queue.shift\n visit(current)\n\n current.adjacent.each do |node|\n if !node.marked\n node.marked = true\n queue.push(node)\n end\n end\n end\nend", "def bfs_adj_list(queue, item)\n @checked_edges = []\n @current_node = start\n queue.add(@current_node)\n until current_node == item || current_node.nil?\n @current_node.linked_list.each do |next_node|\n queue.add(next_node)\n end\n current_node = queue.pop\n end\n return @current_node\n end", "def bfs\r\n q = Queue.new\r\n visited = Set.new\r\n\r\n q << [0, panda]\r\n visited << panda\r\n\r\n until q.empty?\r\n level, current_panda = q.shift\r\n unvisited = @members[current_panda].select { |v| !visited.include? v }\r\n unvisited.each do |v|\r\n q << [level + 1, v]\r\n visited << v\r\n end\r\n end\r\n end", "def bfs(target)\n queue = [self]\n until queue.empty?\n return queue.first if queue.first.position == target\n queue += queue.first.children\n queue.shift\n end \n end", "def get_all_operations\n list = []\n queue = Queue.new\n queue << node\n until queue.empty?\n n = queue.pop\n puts \"NODE: \" + n.to_s\n if n.operation != NodeOperation::NODE\n list.push(n)\n n.nodes.each do |sub_node|\n queue << sub_node\n end\n end\n end\n list\n end", "def inorder_traversal_i(root)\n # declare a queue (Stack)'\n # declare an array variable\n # until root.value.nil? \n # push all the left nodes to the stack\n # once reach to root.value, push stack value to array \n arr = []\n stack = Queue.new \n currentNode = root\n while (!currentNode.nil? || !stack.empty?)\n while !currentNode.nil?\n stack.push(currentNode)\n currentNode = root.left\n end \n currentNode = stack.pop \n arr.push(currentNode.val)\n currentNode = currentNode.right \n end \n return arr\n\nend", "def traverse\n @result.clear\n @queue.clear\n\n @queue.enqueue(@node)\n @result.push @node\n\n\n while not @queue.empty?\n node = @queue.dequeue\n return @result unless node\n # puts \"Visiting node: #{node}\"\n return node if (@search and node==@search)\n node && node.children.each do |node|\n unless @result.include?(node)\n @result.push(node)\n @queue.enqueue(node)\n end\n end\n end\n return result\n end", "def bfs(val) \n queue = [self] \n\n until queue.empty? \n if queue.first.value == val\n return queue.first\n else\n queue.concat(queue.shift.children) #you add [] + children's children\n end\n end\n nil #if noting == val\n end", "def all\n result = []\n\n queue = []\n current_node = self.find_root\n queue << current_node\n\n until queue.empty?\n current_node = queue[0]\n result << current_node.val\n # use empty nodes to maintain two-childs for each node so it's easier to read the array output\n if current_node.val != \"E\"\n if current_node.left\n queue << current_node.left\n else\n # only insert an empty node when the other branch exists\n # prevents excessive empty nodes for external nodes\n queue << BSTNode.new(\"E\", parent = current_node) if current_node.right\n end\n if current_node.right\n queue << current_node.right\n else\n # only insert an empty node when the other branch exists\n # prevents excessive empty nodes for external nodes\n queue << BSTNode.new(\"E\", parent = current_node) if current_node.left\n end\n end\n queue.shift\n end\n\n result\n end", "def level_order(root)\n return [] if root.nil? #\"If there is no root return an empty array\"\n queue = [ root ] #\" Our Queue starts with the root inside of it\"\n level = [] #\"All nodes per level go here\"\n order = [] #\"Our return value for all levels\"\n children = [] # All the nodes children go here\"\n\n while queue.length > 0 #\"Until our queue is empty\"\n node = queue.shift #\"We must Shift(FIFO), Our current Node, and how we escape out of the loop\"\n level.push(node.val) #\"Collect the node's value, one by one\"\n\n children.push(node.left) if !node.left.nil? #\"Notice we push it into the children Array if there is a left child\"\n children.push(node.right) if !node.right.nil? #\"Same for the right child\"\n\n if queue.empty? #\"Important. Once the queue is empty we know the level is complete\"\n order.push(level) #\"Push our level into our Order Array and reset its value below\"\n level = [] \n\n if children.length > 0 #\"When the queue is empty(above) and IF there are children\"\n queue.push(*children) #\"We push the children into our Queue...we are ready for the next level, also notice we are using the spread operator to push the children in as arguements and not an array\"\n children = [] #\" Reset the children value.\n end\n end\n end\n\n return order #\"Once we are out of the loop we have collected all our levels\"\n\nend", "def breadth_first\n return do_breadth_first( [Node.new(@start)], Set.new, @dest)\n end", "def bfs_iterative(target)\n queue = [self]\n\n until queue.empty?\n node = queue.shift\n\n return node if node.value == target\n\n node.children.each do |child|\n queue << child\n end\n end\n\n nil\n end", "def find_order_bfs\n queue = []\n @num_courses.times { |v| queue.push(v) if @in_degrees[v].zero? } # 入度为0的全都放入\n\n visited = []\n until queue.empty?\n node_key = queue.shift\n\n visited.unshift(node_key) # 注意顺序\n\n @nodes[node_key]&.each do |neighbor|\n @in_degrees[neighbor] -= 1\n queue.push(neighbor) if @in_degrees[neighbor].zero?\n end\n end\n\n visited.size == @num_courses ? visited : []\n end", "def printBreadthFirst()\n # println(\"printBreadthFirst\");\n #\n # // queues for pushing and saving all elements in \"breadth first search\" style\n # ArrayList items = new ArrayList();\n # ArrayList depths = new ArrayList();\n # ArrayList indicesParent = new ArrayList();\n #\n # // add first elements and startingpoint\n # items.add(this);\n # depths.add(0);\n # indicesParent.add(-1);\n #\n # // tmp vars for running in while loop\n # int index = 0;\n # int itemCount = 1;\n #\n # while (itemCount > index) {\n # FileSystemItem item = (FileSystemItem) items.get(index);\n # int depth = (Integer) depths.get(index);\n # int indexToParent = (Integer) indicesParent.get(index);\n #\n # // print four spaces for each level of depth + debug println\n # for (int i = 0; i < depth; i++) print(\" \");\n # println(index+\" \"+indexToParent+\"<-->\"+index+\" (\"+depth+\") \"+item.file.getName());\n #\n # // is current node a directory?\n # // yes -> push all children to the end of the items\n # if (item.file.isDirectory()) {\n # for (int i = 0; i < item.childCount; i++) {\n # items.add(item.children[i]);\n # depths.add(depth+1);\n # indicesParent.add(index);\n # }\n # itemCount += item.childCount;\n # }\n # index++;\n # }\n # println(index+\" files\");\n end", "def level_order(queue = [@root])\n return [] if queue.empty? # base case where traversal is done\n\n node = queue.shift # dequeue\n queue.push(node.left) unless node.left.nil? # enqueue unless nil\n queue.push(node.right) unless node.right.nil? # enqueue unless nil\n # prepend the result to the result of recursive call\n level_order(queue).unshift(node.value)\n end", "def level_order(queue = [@root])\n return [] if queue.empty? # base case where traversal is done\n\n node = queue.shift # dequeue\n queue.push(node.left) unless node.left.nil? # enqueue unless nil\n queue.push(node.right) unless node.right.nil? # enqueue unless nil\n # prepend the result to the result of recursive call\n level_order(queue).unshift(node.value)\n end", "def bfs(starting_node, target_value)\n return starting_node if starting_node.value == target_value\n queue = [starting_node]\n until queue.empty?\n queue += starting_node.neighbors\n queue.each { |neighbor| bfs(neighbor, tar) }\n end\n nil\nend", "def inorder\n @queue = []\n inorder_traversal(@root)\n @queue\n end", "def bfs(target_pos) #this is called on the root node \n tar_x, tar_y = target_pos \n\n arr = [self]\n\n until arr.empty?\n current_check = arr.shift \n return current_check if current_check.root_node == target_pos\n arr.concat(current_check.children)\n end\n nil\n end", "def breadth_first_traverse(s)\n a = []\n # marking visited nodes\n visited = Array.new(@vertices)\n # create a queue for BFS\n queue = Queue.new\n\n # mark the current node as visited and enqueue it\n visited[s] = true\n queue.enqueue(s)\n\n until queue.empty?\n\n # Dequeue a vertex from queue and print it or push it into 'a' array\n s = queue.poll\n\n # print \"#{s} \"\n a.push(s)\n\n # get all adjacent vertices of the dequeued vertex s\n # if a adjacent has not been visited, then mark it\n # visited and dequeue it\n adjacent_vertices = @adjList[s]\n\n i = 0\n while i < adjacent_vertices.length\n\n n = adjacent_vertices[i]\n\n unless visited[n]\n visited[n] = true\n queue.enqueue(n)\n end\n\n i += 1\n end\n\n end\n # returning the list on BFS order\n a\n end", "def each\n queue = [@root]\n until queue.empty?\n kids = queue.shift.children\n kids.each do |x| yield x end\n queue.concat kids\n end\n end", "def level_order(root)\n res = []\n return res if root.nil?\n queue = [root]\n tmp = [root.val]\n until queue.empty?\n res << tmp\n parent = queue\n queue = []\n tmp = []\n parent.each do |nodes|\n queue << nodes.left unless nodes.left.nil?\n queue << nodes.right unless nodes.right.nil?\n tmp << nodes.left.val unless nodes.left.nil?\n tmp << nodes.right.val unless nodes.right.nil?\n end\n end\n res\nend", "def bfs_search(queue, item)\n root = @tree.root\n queue.add(root)\n current_node = queue.pop\n until current_node == item || current_node.nil?\n queue.add(current_node.left_child)\n queue.add(current_node.add_child)\n current_node = queue.pop\n end\n return current_node\nend", "def traverse\n nodes = [self]\n until nodes.empty?\n node = nodes.pop\n yield node\n nodes += node.children.reverse unless node.children.empty?\n end\n end", "def bnodes\n @graphs.inject([]) {|memo, g| memo += g.bnodes}\n end", "def bread_first_search(first)\n puts sprintf(\"%-25s %s\", \"Queue: [ bottom - top ]\", \"Visited list\")\n enqueue(first)\n insert_visited(first)\n print\n\n while !queue.empty?\n element = dequeue # => |V|\n @source.fetch(element).each do |s| \n unless @visited.include?(s) # => |E|\n enqueue(s)\n @T.push([element,s]) \n insert_visited(s) \n end\n end\n print\n end\n # spanning tree\n p @T\n end", "def traversal\n list_array = []\n curr_node = @head\n while curr_node do\n list_array << curr_node\n curr_node = curr_node.next\n end\n\n list_array\n end", "def breadth_first_search(data)\n node = nil\n @list << @root if @root\n\n until @list.empty?\n # get next node from the queue\n node = @list.shift\n puts \"Visiting node #{node.value}\" if @debug\n break if node.value == data\n # place each child in the queue, from left to right\n @list << node.left if node.left\n @list << node.right if node.right\n end\n @list.clear # remove any remaining items from the queue\n\t node\n end", "def bfs(starting_node, target_value)\n visited = Set.new()\n queue = [starting_node]\n until queue.empty?\n dequeued = queue.shift\n return dequeued if dequeued.val == target_value\n visited.add(dequeued)\n dequeued.neighbors.each do |neighbor|\n queue << neighbor unless visited.include?(neighbor)\n end\n end\n nil\nend", "def path_finder \n until queue.empty? \n current_node = queue.shift()\n generate_neighbours(current_node)\n current_node.neighbour_nodes.each do |neighbour|\n track_visited(current_node, neighbour)\n correct_node?(neighbour) ? (return neighbour.visited) : (queue << neighbour)\n end\n end\n end", "def breadthTraversal(path, parent = nil)\n\[email protected] Job.new(path, parent)\n\n\twhile not @jobs.empty?\n\t\tbtraverse(@jobs.pop)\n\tend\nend", "def topological_sort(vertices) # Kahn's Algorithm. Queue is breadth first search\n sorted = []\n top_queue = []\n in_edge_count = Hash.new(0)\n vertices.each do |vertex|\n in_edge_count[vertex] = vertex.in_edges.length\n top_queue.unshift(vertex) if vertex.in_edges.empty?\n end\n until top_queue.empty?\n # debugger\n current = top_queue.pop\n sorted << current\n current.out_edges.each do |edge|\n top_queue.unshift(edge.to_vertex) if in_edge_count[edge.to_vertex] <= 1\n in_edge_count[edge.to_vertex] -= 1\n end\n # current.destroy!\n\n end\n if sorted.length == vertices.length\n return sorted\n else\n return []\n end\nend", "def tree_by_levels(node)\n return [] if node.nil?\n queue = [node]\n visited = []\n while !queue.empty?\n node = queue.shift\n visited << node.value\n [node.left, node.right].each do |child|\n queue << child if child\n end\n end\n visited\nend", "def expand_breadth(node) #:nodoc:\n cached_relations = []\n\n # 1. yield direct relations first\n relations_for(node).each do |rel|\n yield_node(rel)\n\n # memoize relation for next iteration\n cached_relations << rel unless @description.prune_node?(rel)\n end\n\n # 2. dig deeper\n cached_relations.each do |rel|\n expand_breadth(rel)\n end\n end", "def bfs(starting_node, target_value)\n queue = [starting_node]\n visited = Set.new()\n\n starting_node.neighbors.each do |neighb_nodes|\n\n return queue.first.value if queue.first.value == target_value\n\n visited.add(queue.shift) \n\n queue.push(neighb_nodes) unless visited.include?(neighb_nodes)\n \n end\n nil\nend", "def bfs\n return [] if @root.nil?\n end", "def dfs_helper(start_node)\n\n ret_list = [start_node.value]\n # Your code here\n start_node.visited = true\n start_node.edges.each do |edge|\n unless edge.node_to.visited\n ret_list += dfs_helper(edge.node_to)\n end\n end\n return ret_list\n end", "def bfs(graph, starting_point)\n q = Queue.new()\n q.enq(starting_point)\n visited = [] \n loop do \n node = q.deq\n visited.push(node) unless visited.include?(node) \n graph.values[node].each{ |x| q.enq(x) }\n break if visited.length == graph.length\n end \n visited\n end", "def dfs_tree_postorder(start, edges)\n require 'set'\n queue = [[start,nil]]\n visited = Set[start]\n bq = []\n while queue.size > 0\n f = queue.pop\n bq << f\n ts = edges[f[0]].keys.reject{ |t| visited.member?(t) }\n ts.each{ |t| visited << t; queue << [t,f[0]] }\n end\n bq.reverse_each{ |f| yield(*f) }\nend", "def inorder\n return [] if @root.nil?\n\n nodelets_array = []\n\n inorder_helper(@root, nodelets_array)\n\n return nodelets_array\n end", "def postorder\n nodelets_array = []\n\n postorder_helper(@root, nodelets_array)\n \n return nodelets_array\n end", "def nodes_breadthfirst(node = self.root, &block)\n @nodes = []\n iterate_breadthfirst(node, &block)\n ensure\n @nodes = nil\n end", "def level_order_traversal(root_node)\n queue = Queue.new\n queue.enq root_node\n while(!queue.empty?)\n magic_node = queue.deq\n\n puts magic_node.value\n\n queue.enq(magic_node.left) unless magic_node.left.nil?\n\n queue.enq(magic_node.right) unless magic_node.right.nil?\n end \n end", "def bfs_for(coords, current_node = @tree, queue = [], hit_squares = [], benchmark = false)\n\t\tif is_current_square_match?(coords, current_node)\n\t\t\tmatch_found(coords, current_node, benchmark)\n\t\telse\n\t\t\thit_squares << get_coords_from_node(current_node)\n\t\t\tcurrent_node.children.each {|child| queue.unshift(child) unless hit_squares.include?(get_coords_from_node(child))} if current_node.children\n\t\t\tnext_node = queue.pop\n\t\t\tnext_node.nil? ? not_found(coords, benchmark) : bfs_for(coords, next_node, queue, hit_squares, benchmark) \n\t\tend\n\tend", "def setBredthLevels\n stack = []\n queue = []\n level = 0\n\n queue.push(@root)\n\n while(queue.size != 0)\n node = queue.shift\n\n stack.append([node.name, node.level])\n\n node.children.each_with_index do |child, i|\n level += 1 if i == 0\n child.level = level\n queue.push(child)\n end\n end\n\n return stack\n end", "def bst_sequences(node)\n depth = Hash.new { |h, k| h[k] = [] }\n q = []\n q << node\n\n # use BFS to group nodes by depth\n until q.empty?\n current = q.shift\n depth[current.d] << current.v\n q << current.l if current.l\n q << current.r if current.r\n end\n depth = depth.map { |k, v| depth[k] = v.permutation.to_a }\n # return all the permutations of nodes\n solution = depth.first.first.product(*(depth[1..-1]))\n solution.map!(&:flatten)\nend", "def build_move_tree\n queue = [@root_node]\n until queue.empty?\n current_node = queue.shift\n possible_positions = new_move_positions(current_node.value) #[]\n possible_positions.each do |position| #[1,2]\n child_node = PolyTreeNode.new(position) #node object(value = 1,2)\n child_node.parent = current_node\n current_node.add_child(child_node)\n queue << child_node\n end\n end\n end", "def post_order_traversal\n nodes = []\n nodes += @left.post_order_traversal if @left\n nodes += @right.post_order_traversal if @right\n nodes.push(@root_value)\n nodes\n end", "def visit_nodes\n # Run a depth-first traversal of the graph with a worklist and a\n # visited set.\n\n worklist = [@start]\n visited = Set.new\n until worklist.empty?\n node = worklist.pop\n if visited.add?(node)\n yield node\n worklist.push *node.inputs.nodes\n worklist.push *node.outputs.nodes\n end\n end\n end", "def find_childless\n @childless = []\n queue = [@root]\n until queue.empty?\n curr_node = queue[0]\n if curr_node.children.empty?\n @childless << curr_node\n else \n queue += curr_node.children\n end\n queue.shift\n end\n @childless\n end", "def BFT_iterative(root)\n print '[\"I\", \"O\", \"H\", \"L\", \"R\", \"T\", \"M\", \"A\", \"G\"]' + \"\\n\"\n if root == nil\n return\n end\n q = Queue.new\n q.enqueue(root)\n\n while !q.empty?\n root = q.dequeue # I\n print(\"#{root.value}\\n\") \n if !root.left.nil?\n q.enqueue(root.left)\n end\n if !root.left.nil?\n q.enqueue(root.right)\n end\n end\n end", "def bfs(target_value)\n queue = [self]\n\n until queue.empty?\n head = queue.shift\n return head if head.value == target_value\n\n head.children.each { |child| queue << child }\n end\n end", "def bst_sequences(node)\n results = []\n\n # Nothing to do, return empty array\n if node.nil?\n results << []\n return results\n end\n\n # Recurse down to begin generating possible subsequences\n left = bst_sequences(node.left)\n right = bst_sequences(node.right)\n\n # Root nodes must come before children nodes, so save the prefix\n prefix = [node.data]\n\n # Each valid sequence of each child must be mixed with the other child\n left.each do |left_sequence|\n right.each do |right_sequence|\n results += mix_sequences(left_sequence, right_sequence, prefix)\n end\n end\n results\nend", "def postorder\n postorder_traversal(@root, [])\n end", "def topological_sort(vertices)\n result = []\n queue = []\n visited_nodes = 0\n remaining_vert = vertices.dup\n while result.length < vertices.length\n # print 'hey'\n # print remaining_vert.map{|vert| vert.in_edges.length}\n # print remaining_vert.map{|vert| vert.value}\n remaining_vert.each do |vert|\n if vert.in_edges.length == 0\n queue.push(vert)\n new_vert = []\n remaining_vert.each do |vert2|\n new_vert.push(vert2) unless vert2 == vert\n end\n remaining_vert = new_vert\n end\n end\n # print 'hi'\n # print queue.map{|queue| queue.out_edges.length}\n return [] if remaining_vert.length>0 && queue.length == 0\n next_vert = queue.shift()\n next_vert.out_edges.each do |edge|\n edge.destroy!\n end\n result.push(next_vert)\n # print result.map{|queue| queue.out_edges.length}\n visited_nodes+=1\n end\n result\nend", "def build\n\t\t\tfifo_q = Array.new\n\t\n\t\t\t# Set the failures for the nodes coming out of the root node.\n\t\t\[email protected]_pair do |item, node|\n\t\t\t\tnode.failure = @root\n\t\t\t\tfifo_q.push node\n\t\t\tend\n\n\t\t\t# Set the failures in breadth-first search order\n\t\t\t# using a FIFO queue. A failure identifies the deepest node\n\t\t\t# that is a proper suffix of the current node. \n\t\t\twhile !fifo_q.empty?\n\t\t\t\tp_node = fifo_q.shift\n\t\t\t\tif p_node.get\n\t\t\t\t\tp_node.get.each_pair do |item, node|\n\t\t\t\t\t\t# Push the current node onto the queue, so any child\n\t\t\t\t\t\t# nodes can be processed later.\n\t\t\t\t\t\tfifo_q.push node \n\t\t\t\t\t\n\t\t\t\t\t\tf_node = p_node.failure\n\t\t\t\t\t\t\n\t\t\t\t\t\t# Follow the failures until we find a goto transition\n\t\t\t\t\t\t# or arrive back at the root node\n\t\t\t\t\t\twhile f_node.goto(item) == nil and !f_node.eql? @root\n\t\t\t\t\t\t\tf_node = f_node.failure\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\tif f_node.eql? @root and f_node.goto(item) == nil\n\t\t\t\t\t\t\tnode.failure = @root\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tnode.failure = f_node.goto(item)\n\t\t\t\t\t\t\tif block_given?\n\t\t\t\t\t\t\t\tnode.output = yield node.output, (node.failure).output\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tif node.output && (node.failure).output\n\t\t\t\t\t\t\t\t\tnode.output = node.output + (node.failure).output\n\t\t\t\t\t\t\t\telsif (node.failure).output\n\t\t\t\t\t\t\t\t\tnode.output = (node.failure).output\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tbuild_dfa if @type == :DFA\n\n\t\tend", "def preorder\n nodelets_array = []\n\n preorder_helper(@root, nodelets_array)\n\n return nodelets_array\n end", "def bst_sequence(node)\n result = []\n children_array = node.children.permutation.to_a\n children_array.map do |array|\n array.unshift(node)\n end\nend", "def linked_list_per_depth\n list = Array.new(height)\n each_depth do |layer, depth|\n n = layer.size - 1\n list[depth] = (0..n).reduce(nil) do |acc, i|\n layer[n-i].nil? ? acc : LinkedList.new(layer[n-i].value, acc)\n end\n end\n list\n end", "def nodes_by_level (depth, node = self.node)\n if depth == 0\n return [node]\n elsif !node.nodes.empty?\n nodes = []\n node.nodes.each {|n| nodes = nodes + nodes_by_level(depth-1, n)}\n return nodes\n else\n return []\n end\n end", "def level_order_traversal\n array_to_be_string = []\n queue = []\n queue.push(@root)\n until queue.empty?\n current_node = queue.first\n array_to_be_string.push(current_node.data)\n queue.push(current_node.left_child) unless current_node.left_child.nil?\n queue.push(current_node.right_child) unless current_node.right_child.nil?\n queue.shift\n end\n array_to_be_string\n end", "def children\n out = [] \n (0..2).each do |row|\n (0..2).each do |col|\n pos = [row, col]\n out << next_move_node(pos) if @board.empty?(pos)\n end\n end\n out\n end", "def postorder_traversal_rec(root)\n res = []\n postorder_dfs(root, res)\n res\nend", "def bfs(starting_node, target_value)\n queue = [starting_node]\n checked_nodes = Set.new\n\n until queue.empty?\n current = queue.shift\n unless checked_nodes.include?(current)\n checked_nodes.add(current)\n return current if current.value == target_value\n queue += current.neighbors\n end\n end\n nil\nend", "def bfs(target)\n q = [self]\n until q.empty?\n shifted = q.shift\n return shifted if shifted.value == target\n q += shifted.children\n # debugger\n end\n nil\n end", "def build_tree(start, finish, node = Node.new(start), queue = [node])\n @root = node\n\n until queue.index { |n| n.value == finish }\n node = queue.shift\n node.children = generate_move_nodes(node.value, finish)\n node.children.each { |c| queue << c }\n end\n end", "def find_breadth_traversal_tree(in_order,post_order,level, h)\n # level => 0F 0T 1F 1T etc\n if in_order.size == nil || in_order.size == 0\n puts \"finish\"\n elsif in_order.size == 1\n # finish\n yield(level, in_order[0])\n puts \"#{level} \\t #{in_order[0]}\"\n else \n # this is not finished yet\n max_index_in_post = 0\n max_index_in_in = 0\n in_order.each_with_index do |in_ele,in_index|\n post_index = post_order.index(in_ele)\n\n if post_index > max_index_in_post\n max_index_in_post = post_index\n max_index_in_in = in_index\n end\n\n end\n current_root = in_order[max_index_in_in]\n yield(level, current_root)\n puts \"#{level} \\t #{current_root}\"\n\n level[0] = (Integer(level[0])+1).to_s\n next_level_f = level+\"F\"\n next_level_t = level+\"T\"\n front_of_in = in_order[0...max_index_in_in]\n tail_of_in = in_order[(max_index_in_in+1)...in_order.size]\n \n #\n find_breadth_traversal_tree(front_of_in,post_order,next_level_f, h) {|level,ele| h[level] = ele}\n find_breadth_traversal_tree(tail_of_in,post_order,next_level_t, h) {|level,ele| h[level] = ele}\n\n #\n end # end of else\n\n\nend", "def breadth_first(node, target)\n # Setup\n queue = Queue.new\n queue.enqueue(node)\n # While queue exists\n while queue.elements?\n # Pop bottom off\n current_node = queue.dequeue\n # Check if it is target or nil\n return 'Could not locate your payload :(' if current_node.nil?\n return 'Found your target' if current_node.payload == target\n # Otherwise add its children to\n # back of line for checking\n add_kids_to_queue(current_node, queue)\n end\nend", "def nodes_inorder\n ret = []\n inorder(root, ret)\n ret\n end", "def level_order(root)\n ordered = []\n return ordered unless root\n queue = [[root]]\n\n until queue.empty?\n current = queue.shift\n same_level = []\n vals = []\n\n current.each do |node|\n same_level << node.left if node.left\n same_level << node.right if node.right\n vals << node.val\n end\n\n ordered << vals\n queue << same_level unless same_level.empty?\n end\n\n ordered\nend", "def bfs(target)\n visited = {}\n @graph.keys.each { |key| visited[key] = false }\n node = @graph.keys[0]\n queue = Queue.new\n queue << node\n while !(queue.length == 0)\n visited[node] = true\n puts \"node is #{node}\"\n return node if node == target\n @graph[node].each do |nabe|\n queue << nabe unless visited[nabe] == true\n end\n node = queue.pop\n end\n end", "def nodelist; end", "def nodelist; end", "def pre_order_traversal\n nodes = []\n nodes.push(@root_value)\n nodes += @left.pre_order_traversal if @left\n nodes += @right.pre_order_traversal if @right\n nodes\n end", "def get_all_trees_from_preorder(array, start=0, end_index=array.size-1)\n #Pre-order visits root first. So 1st element is always root of the tree. next element could be left or right\n #Form all trees with next element being its left, then trees with next element as its right etc.\n # [1,2,3,4] => Use DP approach, bottom up approach. Go all the way down to last 2 nodes\n # 3 3\n # 4 and 4\n # Now 2 can be added as the root and left could be 3 and right could be 3\n # 4 4\n # And follow this till root\n if (start == array.size-1)\n return [Node.new(array[start])]\n end\n results = []\n trees = get_all_trees_from_preorder(array, start+1, end_index-1)\n trees.each do |tree|\n node1 = Node.new(array[start])\n node1.left = tree\n results << node1\n node2 = Node.new(array[start])\n node2.right = tree\n results << node2\n end\n results\nend", "def in_order_traversal\n nodes = []\n nodes += @left.in_order_traversal if @left\n nodes.push(@root_value)\n nodes += @right.in_order_traversal if @right\n nodes\n end", "def level_order\n return nil if root.nil?\n\n q = [root] # queue for breath-first traversal\n level_order_array = []\n until q.empty?\n node = q.shift\n q.push(node.left) unless node.left.nil?\n q.push(node.right) unless node.right.nil?\n level_order_array.push(node)\n yield node if block_given?\n end\n level_order_array\n end", "def find_path(target)\n queue = [root_node]\n until queue.empty?\n p current_node = queue.shift\n p queue\n return current_node if current_node.value == target\n current_node.children.each do |child|\n queue << child\n end\n end\n nil\nend", "def cache_nodes_to_array\n arr = []\n node = @rear_node\n begin\n arr << node.value\n node = node.parent\n end while !node.nil?\n return arr\n end", "def dfs(initial)\n nodes, seen = Set.new, Set.new\n stack = Array(initial).reverse\n\n while node = stack.pop\n if seen.include?(node)\n nodes.add(node)\n else\n seen.add(node)\n stack.push(node)\n stack.concat(Array(yield node).reverse)\n end\n end\n\n nodes\n end", "def preorder_traversal_rec(root)\n res = []\n preorder_dfs(root, res)\n res\nend" ]
[ "0.7893685", "0.76704955", "0.7622377", "0.7541304", "0.74240565", "0.7318918", "0.7299305", "0.72898924", "0.71443915", "0.7019555", "0.6918057", "0.6884628", "0.6732115", "0.67297536", "0.66902626", "0.66781795", "0.66743857", "0.6670282", "0.66371065", "0.6633641", "0.66008705", "0.6594071", "0.6573254", "0.6560293", "0.6532027", "0.6486728", "0.6473317", "0.6467988", "0.6466401", "0.6438141", "0.6419368", "0.63993436", "0.6376263", "0.6341029", "0.63273054", "0.63273054", "0.62946665", "0.6255535", "0.62528324", "0.62389505", "0.6228095", "0.61903673", "0.618071", "0.6168838", "0.616505", "0.6158807", "0.612721", "0.6118425", "0.6104439", "0.6103288", "0.60844535", "0.60723454", "0.60680085", "0.6037226", "0.60353553", "0.6024928", "0.602235", "0.60164136", "0.60156476", "0.6015565", "0.6012687", "0.60099286", "0.60017955", "0.6001718", "0.59962714", "0.5987408", "0.59842217", "0.5976081", "0.59742516", "0.59667015", "0.5960663", "0.59583515", "0.5958204", "0.595066", "0.5940256", "0.5940122", "0.59171504", "0.59160393", "0.5894552", "0.58827615", "0.5879149", "0.58790046", "0.58788663", "0.58709633", "0.58702797", "0.58698165", "0.58568966", "0.58512145", "0.58487934", "0.58472437", "0.5844788", "0.5843628", "0.5843628", "0.58386034", "0.58297825", "0.5828574", "0.581833", "0.5817034", "0.5799076", "0.5791938", "0.5788663" ]
0.0
-1
= 5 4! 4 3! 3 2! 20! = 20 19 18 ...
def factorial_iterative(n) result = 1 while n > 1 result *= n # mutation: changing result n -= 1 # mutation: changing n end result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def magic_numbers(count)\nend", "def faculty(n)\n return (1..n).inject(1, :*)\nend", "def solution\n (1..40).inject(:*) / (1..20).inject(:*)**2\nend", "def cracklepop3\n (1..100).zip(Array.new 100, nil).map do |i,x|\n [i%3, i%5].map.with_index do |y, j| \n x = x.to_s + ['crackle','pop'][j] if y==0\n end\n x ? x : i\n end\nend", "def reduce!(n)\n loop do\n # pp n\n next if explode!(n)\n next if split!(n)\n # pp n\n return\n end\nend", "def persistence(n)\n multiples = []\n until n.to_s.chars.count < 2 do\n n = n.to_s.chars.map(&:to_i).inject(:*)\n multiples << n\n end\n multiples.count\nend", "def solve\n return ((1..40).inject(:*) / ((1..20).inject(:*) ** 2))\nend", "def part2 groups\n yeses = groups.map { | g |\n members = g.split(\"\\n\")\n shared_answers = members.reduce(\"abcdefghijklmnopqrstuvwxyz\".chars) { |m,v |\n m & v.chars\n }.uniq.length\n }.reduce(0){ |m,v|\n m+v\n }\nend", "def part1()\n @seats = @input.map(&:dup)\n until rules_part1() == 0\n end\n count = 0\n @seats.each { |row| count += row.count('#') }\n count\nend", "def hole6\n [?A,*(?2..'10'),?J,?K,?Q].product([?C,?H,?S,?D]).map(&:join) + [?J,?J]\n # put your implementation in here, but please leave the comments above and at the 'end'\n\n end", "def explode(nines, double)\r\n\tdummy = (rand * 10).to_i + 1\r\n\tif double then\r\n\t\tif dummy == 10 || ((dummy == 9) && nines) then \r\n\t\t\tdummy += explode(nines, double) + explode(nines, double)\r\n\t\tend\r\n\telse\r\n\t\tif dummy == 10 || ((dummy == 9) && nines) then \r\n\t\t\tdummy += explode(nines, double)\r\n\t\tend\r\n\tend\r\n\tdummy\r\nend", "def given\n [6,5,3,1,8,7,2,3]\nend", "def custom_primer_exp_2\n [[0,0],[0,1],[0,2],[0,3],[0,4],[0,5],[0,6],[0,7],[0,8],[0,9],\n [4,0],[4,1],[4,2],[4,3],[4,4],[4,5],[4,6],[4,7],[4,8],[4,9],\n [1,0],[1,1],[1,2],[1,3],[1,4],[1,5],[1,6],[1,7],[1,8],[1,9],\n [5,0],[5,1],[5,2],[5,3],[5,4],[5,5],[5,6],[5,7],[5,8],[5,9],\n [2,0],[2,1],[2,2],[2,3],[2,4],[2,5],[2,6],[2,7],[2,8],[2,9],\n [6,0],[6,1],[6,2],[6,3],[6,4],[6,5],[6,6],[6,7],[6,8],[6,9]] \n end", "def p5\n\tdivisors = (1..20).to_a\n\tnum = divisors[-1]\n\tloop do\n\t\tbreak if divisible?(num, divisors)\n\t\tnum += divisors[-1]\n\tend\n\treturn num\nend", "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 magic_numbers(count)\n num = 1\n result = []\n while result.length < count\n result << num if is_magic_number?(num)\n num += 1\n end\n result\nend", "def collect_multiples(number)\n \n numbers = Array.new(number - 1, 0)\n count = 0\n while count < numbers.length \n numbers[count] = count + 1\n count += 1\n end\n\n numbers.select do |element|\n element % 3 == 0 || element % 5 == 0\n end\n\nend", "def solve_zero_vs_six_vs_nine\n return if @arr[1].nil? || @arr[4].nil?\n\n #p \"1,4: #{@arr[1]},#{@arr[4]}\"\n\n @words.filter{|x| x.length == 6 && @hash[x].nil?}.each{|w|\n if @arr[4].chars.all?{|c| w.chars.include?(c)}\n solved(9, w)\n elsif @arr[1].chars.all?{|c2| w.chars.include?(c2)}\n solved(0, w)\n else\n solved(6, w)\n end\n }\n end", "def multiple(*nums)\n nums.inject(:*)\nend", "def problem1 limit\n (0...limit).map {|n| (n%3==0 || n%5==0) ? n : 0 }.reduce(:+)\nend", "def every_other\n i = 1\n numbers = []\n 50.times do\n numbers << i\n i+= 2\n end\n return numbers\nend", "def collect_multiples(limit)\n #numbers = [1..(limit-1)]\n multiple_numbers = []\n (1..(limit-1)).map do |number|\n if number % 3 == 0 || number % 5 == 0\n multiple_numbers << number\n end\n end\n multiple_numbers\nend", "def pure_number(n)\n arr = []\n arr[0] = \"\"\n blocks = 0\n displacement = 0\n i = 1\n while(i <= n)\n blocks = blocks + 1 if(is_power_of_2?(i+1))\n if(is_4_series?(i, blocks))\n displacement = power_of_num(2, blocks-1)\n arr[i] = \"4\" + arr[i-displacement] + \"4\"\n else\n displacement = power_of_num(2, blocks) \n arr[i] = \"5\" + arr[i-displacement] + \"5\"\n end\n i+=1\n end\n arr\nend", "def divisible_by_5_and_3\n numbers = (1..100).to_a # this will create an array from 1 to 100. Check the Range class from Ruby - https://ruby-doc.org/core-2.5.1/Range.html\nend", "def deal5cards (n)", "def multiple()\n\tresult = 0\n\t\tfor i in 1...1000\n\t\t\tif i%3 == 0 || i%5 == 0\n\tresult += i\n\t\t\tend\n\t\tend\n\treturn result\nend", "def more(values)\n \tnew_numbers = values.reject { |n| n >= 5 }\n end", "def collect_multiples(num)\n range = (3...num)\n multiples = []\n range.each do |num|\n if num % 3 == 0 || num % 5 == 0\n multiples << num\n end\n end\n multiples\nend", "def slippery_numbers(n)\r\n array, num = [], 3\r\n while array.length < n\r\n array << num if is_slippery?(num)\r\n num += 1\r\n end\r\n array\r\nend", "def slippery_numbers(n)\r\n array, num = [], 3\r\n while array.length < n\r\n array << num if is_slippery?(num)\r\n num += 1\r\n end\r\n array\r\nend", "def problem_76a\n num = 100\n solve = lambda do |a,off,max|\n n = 0\n while a[off] < max && (a.length-off) >= 2 \n a[off] += a.pop\n n += 1\n n += solve.call(a.dup,off+1,a[off]) if a.length - off > 1\n end\n n\n end\n puts 1 + solve.call([1] * num, 0,num-1)\nend", "def multiples(numbers)\n numbers.inject(0) do |a, e|\n # sum the elements into the accumulator\n # if they are divisible by 3 or 5\n a += e if e % 3 == 0 || e % 5 == 0\n a\n end\nend", "def multiples(num)\n (1...num).select { |n| n % 3 == 0 || n % 5 == 0 }.inject(:+)\nend", "def clumsy(n)\n a = (1..n).to_a.reverse\n \n result = [a[0]]\n \n a[1..a.size - 1].each_with_index do |num, index|\n if index % 4 == 0\n result << '*'\n elsif index % 4 == 1 \n result << '/'\n elsif index % 4 == 2\n result << '+'\n else\n result << '-'\n end\n \n result << num\n end\n \n result = multiply_and_divide_all_results(result)\n \n add_and_subtract_all_results(result)\nend", "def collect_multiples(limit)\n array=*(1...limit)\n array.select {|num| num % 3 == 0 || num % 5 ==0}\nend", "def solution(number)\r\n (3...number).each_with_object([]) { |n, arr| arr << n if (n % 3).zero? || (n % 5).zero? }.uniq.sum\r\nend", "def threes_and_fives\n for i in 100..4000000\n if (i % 3 == 0 and not i % 5 == 0) or (i % 5 == 0 and not i % 3)\n puts i\n end\n end\nend", "def multiple_of_three_and_five(limit)\r\n (3...limit).select { |number| number % 3 == 0 || number % 5 ==0 }.inject(:+)\r\nend", "def slippery_numbers(n)\nend", "def collect_multiples(limit)\n multiples = []\n numbers = (1..limit.to_i-1).to_a\n numbers.each do |i|\n if i % 3 == 0 || i % 5 == 0\n multiples.push(i)\n end\n end\n multiples \nend", "def toggle_lights(n)\n multipled_substring = []\n\n (1..n).each do |count|\n multiplier = 1\n\n loop do\n product = count * multiplier\n break if product > n\n multipled_substring << product\n multiplier += 1\n end\n end\n #multipled_substring\n\n final_result = []\n (1..n).each do |number|\n times_of_toggle = multipled_substring.count(number)\n \n final_result << number if times_of_toggle.odd?\n end\n p final_result\nend", "def hole5(l)\n (0..l).select { |n| n.to_s(2).count(?1).even? }\n # put your implementation in here, but please leave the comments above and at the 'end'\n\n end", "def step_4\n\t\t@keystream_num_array = []\n\t\[email protected] do |letter|\n\t\t\t@keystream_num_array << (@alphabet.index(letter) + 1)\n\t\tend\n\t\t@keystream_num_array\n\tend", "def set_mod_list(k, s)\n arr = []\n k.times do |i|\n arr.push(s.count { |a| a % k == i })\n end\n arr\nend", "def solution\n (2..(9**5 * 6)).select do |n|\n n.to_s.split(//).map do |d|\n d.to_i ** 5\n end.reduce(:+) == n\n end.reduce(:+)\nend", "def answer(n, a)\n count = 0\n n.times do |nn|\n next if a[nn] != nn + 1\n a[nn], a[nn + 1] = a[nn + 1], a[nn]\n count += 1\n end\n count\nend", "def multiples_3_5_v1\n\tmultiples = (1...1000).find_all do |i| \n\t\ti % 3 == 0 || i % 5 == 0\n\tend\n\n\tanswer = multiples.inject do |memo, num|\n\t\tmemo + num\n\tend\n\n\treturn answer\nend", "def five(array)\n array.map.inject(:+) *2\nend", "def evens_and_odds(numbers)\nend", "def many_results(n)\r\n\treturn 1, n /2, n\r\nend", "def p13\n\tnumbers = [\n\t\t37107287533902102798797998220837590246510135740250,\n\t\t46376937677490009712648124896970078050417018260538,\n\t\t74324986199524741059474233309513058123726617309629,\n\t\t91942213363574161572522430563301811072406154908250,\n\t\t23067588207539346171171980310421047513778063246676,\n\t\t89261670696623633820136378418383684178734361726757,\n\t\t28112879812849979408065481931592621691275889832738,\n\t\t44274228917432520321923589422876796487670272189318,\n\t\t47451445736001306439091167216856844588711603153276,\n\t\t70386486105843025439939619828917593665686757934951,\n\t\t62176457141856560629502157223196586755079324193331,\n\t\t64906352462741904929101432445813822663347944758178,\n\t\t92575867718337217661963751590579239728245598838407,\n\t\t58203565325359399008402633568948830189458628227828,\n\t\t80181199384826282014278194139940567587151170094390,\n\t\t35398664372827112653829987240784473053190104293586,\n\t\t86515506006295864861532075273371959191420517255829,\n\t\t71693888707715466499115593487603532921714970056938,\n\t\t54370070576826684624621495650076471787294438377604,\n\t\t53282654108756828443191190634694037855217779295145,\n\t\t36123272525000296071075082563815656710885258350721,\n\t\t45876576172410976447339110607218265236877223636045,\n\t\t17423706905851860660448207621209813287860733969412,\n\t\t81142660418086830619328460811191061556940512689692,\n\t\t51934325451728388641918047049293215058642563049483,\n\t\t62467221648435076201727918039944693004732956340691,\n\t\t15732444386908125794514089057706229429197107928209,\n\t\t55037687525678773091862540744969844508330393682126,\n\t\t18336384825330154686196124348767681297534375946515,\n\t\t80386287592878490201521685554828717201219257766954,\n\t\t78182833757993103614740356856449095527097864797581,\n\t\t16726320100436897842553539920931837441497806860984,\n\t\t48403098129077791799088218795327364475675590848030,\n\t\t87086987551392711854517078544161852424320693150332,\n\t\t59959406895756536782107074926966537676326235447210,\n\t\t69793950679652694742597709739166693763042633987085,\n\t\t41052684708299085211399427365734116182760315001271,\n\t\t65378607361501080857009149939512557028198746004375,\n\t\t35829035317434717326932123578154982629742552737307,\n\t\t94953759765105305946966067683156574377167401875275,\n\t\t88902802571733229619176668713819931811048770190271,\n\t\t25267680276078003013678680992525463401061632866526,\n\t\t36270218540497705585629946580636237993140746255962,\n\t\t24074486908231174977792365466257246923322810917141,\n\t\t91430288197103288597806669760892938638285025333403,\n\t\t34413065578016127815921815005561868836468420090470,\n\t\t23053081172816430487623791969842487255036638784583,\n\t\t11487696932154902810424020138335124462181441773470,\n\t\t63783299490636259666498587618221225225512486764533,\n\t\t67720186971698544312419572409913959008952310058822,\n\t\t95548255300263520781532296796249481641953868218774,\n\t\t76085327132285723110424803456124867697064507995236,\n\t\t37774242535411291684276865538926205024910326572967,\n\t\t23701913275725675285653248258265463092207058596522,\n\t\t29798860272258331913126375147341994889534765745501,\n\t\t18495701454879288984856827726077713721403798879715,\n\t\t38298203783031473527721580348144513491373226651381,\n\t\t34829543829199918180278916522431027392251122869539,\n\t\t40957953066405232632538044100059654939159879593635,\n\t\t29746152185502371307642255121183693803580388584903,\n\t\t41698116222072977186158236678424689157993532961922,\n\t\t62467957194401269043877107275048102390895523597457,\n\t\t23189706772547915061505504953922979530901129967519,\n\t\t86188088225875314529584099251203829009407770775672,\n\t\t11306739708304724483816533873502340845647058077308,\n\t\t82959174767140363198008187129011875491310547126581,\n\t\t97623331044818386269515456334926366572897563400500,\n\t\t42846280183517070527831839425882145521227251250327,\n\t\t55121603546981200581762165212827652751691296897789,\n\t\t32238195734329339946437501907836945765883352399886,\n\t\t75506164965184775180738168837861091527357929701337,\n\t\t62177842752192623401942399639168044983993173312731,\n\t\t32924185707147349566916674687634660915035914677504,\n\t\t99518671430235219628894890102423325116913619626622,\n\t\t73267460800591547471830798392868535206946944540724,\n\t\t76841822524674417161514036427982273348055556214818,\n\t\t97142617910342598647204516893989422179826088076852,\n\t\t87783646182799346313767754307809363333018982642090,\n\t\t10848802521674670883215120185883543223812876952786,\n\t\t71329612474782464538636993009049310363619763878039,\n\t\t62184073572399794223406235393808339651327408011116,\n\t\t66627891981488087797941876876144230030984490851411,\n\t\t60661826293682836764744779239180335110989069790714,\n\t\t85786944089552990653640447425576083659976645795096,\n\t\t66024396409905389607120198219976047599490197230297,\n\t\t64913982680032973156037120041377903785566085089252,\n\t\t16730939319872750275468906903707539413042652315011,\n\t\t94809377245048795150954100921645863754710598436791,\n\t\t78639167021187492431995700641917969777599028300699,\n\t\t15368713711936614952811305876380278410754449733078,\n\t\t40789923115535562561142322423255033685442488917353,\n\t\t44889911501440648020369068063960672322193204149535,\n\t\t41503128880339536053299340368006977710650566631954,\n\t\t81234880673210146739058568557934581403627822703280,\n\t\t82616570773948327592232845941706525094512325230608,\n\t\t22918802058777319719839450180888072429661980811197,\n\t\t77158542502016545090413245809786882778948721859617,\n\t\t72107838435069186155435662884062257473692284509516,\n\t\t20849603980134001723930671666823555245252804609722,\n\t\t53503534226472524250874054075591789781264330331690,\n\t]\n\n\tsum = numbers.reduce(:+)\n\tsum.to_s[0..9].to_i\nend", "def collect_multiples\n (1..@limit).select{|num| num%3 == 0 || num%5 == 0}\n end", "def secret_numbers\n\t\t(1..5).to_a \n\tend", "def how_much_i_love_you(n)\nf = [\"I love you\",\n \"a little\",\n \"a lot\",\n \"passionately\",\n \"madly\",\n \"not at all\"]*n\nf[n-n+n-1]\nend", "def multiples_of_three_and_five(limit)\n arr = []\n i = 1\n\n while i < limit do\n if i % 5 == 0 || i % 3 == 0\n arr << i\n i += 1\n else\n i += 1\n end\n # puts $arr.inspect\n end\n\n arr_size = arr.count\n # puts arr_size\n total = 0\n i = 0\n\n while i < arr_size do\n total += arr[i]\n i += 1\n end\n\n return total\nend", "def next5\n x = @exact[0,5]\n x + @list[0,5 - x.size]\n end", "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 collect_multiples(limit)\n array = []\n (1...limit).each do |num|\n array << num if (num % 3 == 0) || (num % 5 == 0)\n end\n array\nend", "def ex2\n for i in (0..5)\n for j in (1..(4 - (4 - i).abs))\n print '#'\n end\n print \"\\n\"\n end\nend", "def fds(n)\n\n # arr = []\n # (n + 1).times.each{|e| arr << e if e > 0}\n # arr.flat_map.reduce(:*)\n # arr.flat_map.reduce(:*).to_s.split(//).map(&:to_i).reduce(:+)\n (1..n).to_a.flat_map.reduce(:*).to_s.split(//).map(&:to_i).reduce(:+)\n\nend", "def the_interview\n (1..100).each{ |n| puts n % 15 == 0 ? \"fizzbuzz\" : n % 3 == 0 ? \"fizz\" : n % 5 == 0 ? \"buzz\" : n }\n (0..99).reverse_each{|n| puts \"I have #{n} bottles.\"}\nend", "def multipleSet(n)\n return (n..99).step(n).to_a.to_set\nend", "def problem1(num)\n (1..num-1).select{|a| a%3 ==0 or a%5==0}.reduce(:+)\nend", "def fizz_buzz_no_cons\n\tpossible_fizz = [1, 0, 0]\n possible_buzz = [2, 0, 0, 0, 0]\n words = [None, \"Fizz\", \"Buzz\", \"FizzBuzz\"]\n \n n.times do |i|\n words[0] = i\n puts(words[possible_fizz[i%3] + possible_buzz[i%5]])\n end\n \nend", "def p206\n re = /1.2.3.4.5.6.7.8.9.0/\n max = Math.sqrt(1929394959697989990).floor\n\n # Round since only squares of multiples of 30 and 70 end with 9_0 (e.g. 900)\n i = round_up Math.sqrt(1020304050607080900).floor, 100\n while i < max\n p30 = (i+30) ** 2\n p70 = (i+70) ** 2\n\n if re === \"#{p30}\"\n return \"#{i+30}^2 = #{p30}\"\n elsif re === \"#{p70}\"\n return \"#{i+70}^2 = #{p70}\"\n end\n\n i += 100\n end\nend", "def partials(b)\n \"Starting from the left, calculate partial sums of a brickset.\"\n (0..b.length - 2).collect {|i| b[0..i].sum}\nend", "def solution(size=5)\n ([1] + (3..size).select(&:odd?).map do |x|\n 4*x**2 - 6*x + 6\n end).reduce(:+)\nend", "def multiples(number)\n number_array = Array(1..number)\n multiples_array = []\n\n number_array.each do |num|\n if num % 3 == 0 || num % 5 == 0\n multiples_array << num\n end\n end\n multiples_array.inject(:+)\nend", "def cows\n (@arr & @guess_num).size\n end", "def kickers\n repeat_values + (aces_low? ? aces_low_values.reverse : single_values)\n end", "def problem5 ( )\n lcm_1_to_n(20)\nend", "def repeated_number_ranges(arr)\n\n\nend", "def buddy(start, nd)\r\n start.upto(nd) do |n|\r\n potential_match = sum_divisors(n)\r\n next if potential_match < n\r\n return \"(#{n} #{potential_match})\" if sum_divisors(potential_match) == n\r\n end\r\n 'Nothing'\r\nend", "def by_three?(n)\n return n % 3 == 0\nend", "def five\n i = 1\n begin\n i = i + 1\n end until (div_n(20, i) == true)\n return i\nend", "def repetitions(n)\n @hand.group_by{ |card| card.point }.select { |k, v| v.count == n }\n end", "def fivesSet(s)\n return (s.find_all {|i| i%5 == 0}).to_set\nend", "def multiples_3_and_5 (top_range_num)\n three_five_array = []\n i = 1\n while i < top_range_num\n if i%3 == 0\n three_five_array.push(i)\n elsif i%5 == 0\n three_five_array.push(i)\n end\n i += 1\n end\n three_five_array = three_five_array.uniq\n sum = three_five_array.inject {|total, x| total + x}\n puts sum\nend", "def collect_multiples(limit)\n multiples = []\n\n for i in 1...limit do\n if (i % 5 == 0 || i % 3 == 0)\n multiples << i\n end\n end\n\n return multiples\n\nend", "def similarshelves(n)\n similar(n)\n end", "def find_it(seq)\n set_num = 0\n seq.each do |num|\n if seq.count(num) % 2 != 0\n set_num = num\n end\n end\n\n set_num\nend", "def _reduce_62(val, _values, result)\n result = paragraph [val[0]].concat(val[1])\n\n result\nend", "def threefive(num)\n\n if num < 1 || num > 100\n return \"Number must be between 1-100\"\n end\n mult_arr = []\n mult_arr << 0\n i = 0\n\n while num > i\n if (i % 3) == 0\n mult_arr << i\n elsif (i % 5) == 0\n mult_arr << i\n end\n i += 1\n end\n return mult_arr.inject{|sum,n| sum + n}\n\nend", "def euler29(n)\n terms = []\n 2.upto(n) do |i|\n 2.upto(n) do |j|\n if terms.include?(i ** j) == false\n terms << i ** j\n end\n end\n end\n \n terms.length\nend", "def multiples(n)\n (1...n).select do |num|\n num if (num % 3).zero? || (num % 5).zero?\n end.reduce(:+)\nend", "def problem_five\n (1..20).reduce(1) { |res, n| res.lcm n }\n end", "def count_triple\nend", "def repeater(string, n)\n string * n\nend", "def make_hundred\n arr = [\"+\", \"-\", \"\"].repeated_permutation(8).to_a.map do |operators|\n ((1..9).to_a).zip(operators).flatten.compact\n end.map(&:join).select {|x| eval(x) == 100}\nend", "def spinWords(string)\r\n \r\n var= string.split(' ') #[\"Hey\", \"fellow\", \"warriors\"]\r\n finalarry=[]\r\n var.each do |x|\r\n arry= x.split('') \r\n if arry.count >= 5\r\n finalarry << arry.reverse\r\n else\r\n finalarry<< arry\r\n end\r\n\r\n \r\n end\r\n \r\n lastarry=[]\r\n finalarry.each do |y|\r\n lastarry << y.join(\"\")\r\n \r\n end\r\n \r\n result= lastarry\r\n p result.join(' ')\r\n\r\n\r\n \r\n \r\nend", "def series_up(num)\n seq = 0\n list = []\n # list[(num * (num + 1) / 2) - 1] = num wasn't doing anything for me\n num.times do |pat| # I swtiched to num.times because I couldn't do list.each because list is blank\n t = 0\n num.times do |numb|\n list[t + seq] = t + 1 # How it knows where to put what number\n t += 1\n end\n seq += pat + 1 # grows exponentially to make it add a new space every time\n end\n return list\nend", "def group\n students = (1...59).to_a\n students.each_slice(5).to_a\n\nend", "def triangular_number_with_n_divisitors(num)\r\n\trunner = 0\r\n\ti = 2\r\n\twhile runner < num do\r\n\t\ti += 1\r\n\t\trunner = triangular_number_of_divisitors(i)\r\n\tend\r\nend", "def solution2(a)\n\n counts = Hash.new(0)\n\n a.each do |int|\n counts[int] += 1\n end\n\n non_divisors = []\n\n a.each do |int|\n div_count = 0\n for i in 1..int do\n div_count += counts[i] if int % i == 0\n end\n non_divisors << a.length - div_count\n end\n\n non_divisors\n\nend", "def problem(nth = 6,i = 13)\n while nth < 10001\n i += 2\n nth += 1 if i.prime?\n end\n i\n end", "def magic_numbers(count)\n index = 0\n array = []\n found = 0\n while found < count\n if is_magic_number?(index)\n array.push(index)\n found += 1\n end\n index += 1\n end\n return array\nend", "def check_split\n (meal + ((meal * tip) / 100)) / group\n end", "def collect_multiples(limit)\n (1...limit).to_a.select{|i| i % 3 == 0 || i % 5 == 0}\nend", "def cracklepop1\n def aux x\n /[A-Z]+/i.match(x.to_s).to_s\n end\n (1..100).map do |i|\n x = i%3==0 ? 'crackle' : i\n i%5==0 ? (aux(x)+'pop') : x\n end\nend", "def mix!(cnt, ap, bp)\n @aa += cnt * ap * bp\n @ab += cnt * (1-ap) * bp\n @ab += cnt * ap * (1-bp)\n @bb += cnt * (1-ap) * (1-bp)\nend", "def arrangements(open_spots)\n arrangements = 0\n open_spots.each do |array|\n arrangements += array.permutation(5).to_a.size\n end\n arrangements\n end" ]
[ "0.571617", "0.55380774", "0.55144596", "0.53439206", "0.533198", "0.5294451", "0.518323", "0.5177784", "0.5175835", "0.51668876", "0.5159616", "0.51539", "0.51419765", "0.5128577", "0.5127559", "0.5123809", "0.5103327", "0.5102613", "0.5099302", "0.5098045", "0.5083513", "0.50810844", "0.5077073", "0.50743175", "0.50679344", "0.50673896", "0.5063863", "0.5062655", "0.5056537", "0.5056537", "0.5044426", "0.5044103", "0.50235295", "0.5018522", "0.5004585", "0.50011295", "0.4996242", "0.49887165", "0.4986186", "0.49845916", "0.4982275", "0.4978233", "0.49753374", "0.49745533", "0.49735028", "0.49727252", "0.49704066", "0.49608645", "0.49535036", "0.49528906", "0.49438062", "0.49410316", "0.49359047", "0.4932688", "0.4931507", "0.49263096", "0.49254775", "0.49254322", "0.4924582", "0.49214178", "0.4920089", "0.49182674", "0.4913276", "0.4911846", "0.49096337", "0.4905106", "0.4893024", "0.48913923", "0.4888467", "0.4887373", "0.4885723", "0.48857173", "0.48830348", "0.48820898", "0.48820332", "0.48810753", "0.48800704", "0.48787048", "0.48774844", "0.4869602", "0.4869313", "0.4866844", "0.4865109", "0.48573682", "0.48552397", "0.4850629", "0.48501217", "0.4849513", "0.48487842", "0.4838217", "0.4838187", "0.48329434", "0.48263806", "0.48219854", "0.48189047", "0.48172265", "0.48166683", "0.48161352", "0.4808195", "0.48015782", "0.4800258" ]
0.0
-1
thanks to bruce williams for this trick
def method_missing(meth, *args, &block) #:nodoc: returning template.__send__(meth, *args, &block) do self.class.class_eval %{delegate :#{meth}, :to => :template} end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def rassoc(p0) end", "def probers; end", "def anchored; end", "def formation; end", "def offences_by; end", "def schubert; end", "def terpene; end", "def stderrs; end", "def pos; end", "def pos; end", "def pos; end", "def pos; end", "def pos; end", "def pos; end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def malts; end", "def pos() end", "def pos() end", "def pos() end", "def pos() end", "def berlioz; end", "def trd; end", "def deco_pos; end", "def transform; end", "def transformations; end", "def ismn; end", "def suivre; end", "def starting_position; end", "def at(p0) end", "def transforms; end", "def bs; end", "def blg; end", "def position; end", "def position; end", "def position; end", "def position; end", "def position; end", "def position; end", "def position; end", "def position; end", "def verdi; end", "def offences_by=(_arg0); end", "def schumann; end", "def index(p0) end", "def index(p0) end", "def getc() end", "def getc() end", "def getc() end", "def expanded; end", "def parts; end", "def parts; end", "def parts; end", "def x_offset; end", "def intensifier; end", "def same; end", "def probers=(_arg0); end", "def first_offset; end", "def first_offset; end", "def tld; end", "def tld; end", "def identify; end", "def villian; end", "def escaper; end", "def preproc; end", "def yyerrok; end", "def yyerrok; end", "def leading; end", "def sld; end", "def loc; end", "def loc; end", "def loc; end", "def parslet; end", "def parslet; end", "def parslet; end", "def parslet; end", "def starting_position=(_arg0); end", "def gounod; end", "def custom; end", "def custom; end", "def required_positionals; end", "def tr(p0, p1) end", "def rest_positionals; end", "def celebration; end", "def original; end", "def pos\n end", "def pos\n end", "def pos\n end", "def lcts(array)\nend", "def operations; end", "def operations; end", "def succ() end", "def succ() end", "def succ() end", "def lsi; end", "def chars_left; end", "def pos=(_arg0); end", "def offset; end" ]
[ "0.6200665", "0.5924958", "0.59247", "0.5911556", "0.5719761", "0.5682469", "0.5678156", "0.5676054", "0.56355536", "0.551877", "0.551877", "0.551877", "0.551877", "0.551877", "0.551877", "0.54856586", "0.54856586", "0.54856586", "0.54856586", "0.5473758", "0.54667515", "0.54667515", "0.54667515", "0.54667515", "0.5452672", "0.54404503", "0.5430555", "0.5361014", "0.5354558", "0.5342016", "0.5324292", "0.5294648", "0.5256278", "0.5239397", "0.52348876", "0.5231139", "0.5230861", "0.5230861", "0.5230861", "0.5230861", "0.5230861", "0.5230861", "0.5230861", "0.5230861", "0.52300006", "0.5222117", "0.5175261", "0.5175194", "0.5175194", "0.51576585", "0.51576585", "0.51576585", "0.51551056", "0.51508015", "0.51508015", "0.51508015", "0.5147637", "0.5142812", "0.5127316", "0.51185066", "0.51153606", "0.51153606", "0.5113247", "0.5113247", "0.5105947", "0.51058906", "0.50963", "0.50890434", "0.5082441", "0.5082441", "0.50807476", "0.5078793", "0.5076399", "0.5076399", "0.5076399", "0.5065252", "0.5065252", "0.5065252", "0.5065252", "0.506034", "0.505199", "0.50512666", "0.50512666", "0.5028854", "0.5009", "0.50052536", "0.5004726", "0.49986637", "0.49970752", "0.49970752", "0.49970752", "0.49850813", "0.498313", "0.498313", "0.4981305", "0.4981305", "0.4981305", "0.49790034", "0.49783167", "0.49771452", "0.49757656" ]
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def image_params params.require(:image).permit(:article_id, :user_id, :uploaded_image) 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 /items GET /items.json
def index @items = if params[:cart_id] Cart.find(params[:cart_id]).items elsif params[:customer_id] Customer.find(params[:customer_id]).items elsif params[:sort] case params[:sort] when 'cart_id' Item.order("cart_id #{params[:cart_sort_direction]}") when 'product_color_id' Item.order("product_color_id #{params[:product_color_sort_direction]}") when 'size_id' Item.order("size_id #{params[:size_sort_direction]}") when 'purchased' Item.order("charges.result #{params[:purchased_sort_direction]}").joins(:charges) when 'coupon' Item.order("coupons.name #{params[:coupon_sort_direction]}").joins(:coupons) end else Item end.order('created_at desc').page(params[:page]) respond_to do |format| format.html # index.html.erb format.json { render json: @items } 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